xref: /AOO41X/main/sax/inc/sax/fastattribs.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SAX_FASTATTRIBS_HXX_
29 #define _SAX_FASTATTRIBS_HXX_
30 
31 #include <com/sun/star/xml/sax/XFastAttributeList.hpp>
32 #include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
33 #include <com/sun/star/xml/Attribute.hpp>
34 #include <com/sun/star/xml/FastAttribute.hpp>
35 
36 #include <cppuhelper/implbase1.hxx>
37 #include "sax/dllapi.h"
38 
39 #include <map>
40 #include <vector>
41 
42 namespace sax_fastparser
43 {
44 
45 struct UnknownAttribute
46 {
47 	::rtl::OUString maNamespaceURL;
48 	::rtl::OString maName;
49 	::rtl::OString maValue;
50 
51 	UnknownAttribute( const ::rtl::OUString& rNamespaceURL, const ::rtl::OString& rName, const ::rtl::OString& rValue );
52 
53 	UnknownAttribute( const ::rtl::OString& rName, const ::rtl::OString& rValue );
54 
55 	void FillAttribute( ::com::sun::star::xml::Attribute* pAttrib ) const;
56 };
57 
58 typedef std::map< sal_Int32, ::rtl::OString > FastAttributeMap;
59 typedef std::vector< UnknownAttribute > UnknownAttributeList;
60 
61 class SAX_DLLPUBLIC FastAttributeList : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XFastAttributeList >
62 {
63 public:
64 	FastAttributeList( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >& xTokenHandler );
65 	virtual ~FastAttributeList();
66 
67 	void clear();
68 	void add( sal_Int32 nToken, const ::rtl::OString& rValue );
69 	void addUnknown( const ::rtl::OUString& rNamespaceURL, const ::rtl::OString& rName, const ::rtl::OString& rValue );
70 	void addUnknown( const ::rtl::OString& rName, const ::rtl::OString& rValue );
71 
72     // XFastAttributeList
73     virtual ::sal_Bool SAL_CALL hasAttribute( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException);
74     virtual ::sal_Int32 SAL_CALL getValueToken( ::sal_Int32 Token ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
75     virtual ::sal_Int32 SAL_CALL getOptionalValueToken( ::sal_Int32 Token, ::sal_Int32 Default ) throw (::com::sun::star::uno::RuntimeException);
76     virtual ::rtl::OUString SAL_CALL getValue( ::sal_Int32 Token ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
77     virtual ::rtl::OUString SAL_CALL getOptionalValue( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException);
78     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::xml::Attribute > SAL_CALL getUnknownAttributes(  ) throw (::com::sun::star::uno::RuntimeException);
79     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::xml::FastAttribute > SAL_CALL getFastAttributes() throw (::com::sun::star::uno::RuntimeException);
80 
81 private:
82 	FastAttributeMap maAttributes;
83 	UnknownAttributeList maUnknownAttributes;
84 	FastAttributeMap::iterator maLastIter;
85 	::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler > mxTokenHandler;
86 
87 };
88 
89 }
90 
91 #endif
92