xref: /aoo4110/main/sax/inc/sax/fastattribs.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SAX_FASTATTRIBS_HXX_
25 #define _SAX_FASTATTRIBS_HXX_
26 
27 #include <com/sun/star/xml/sax/XFastAttributeList.hpp>
28 #include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
29 #include <com/sun/star/xml/Attribute.hpp>
30 #include <com/sun/star/xml/FastAttribute.hpp>
31 
32 #include <cppuhelper/implbase1.hxx>
33 #include "sax/dllapi.h"
34 
35 #include <map>
36 #include <vector>
37 
38 namespace sax_fastparser
39 {
40 
41 struct UnknownAttribute
42 {
43 	::rtl::OUString maNamespaceURL;
44 	::rtl::OString maName;
45 	::rtl::OString maValue;
46 
47 	UnknownAttribute( const ::rtl::OUString& rNamespaceURL, const ::rtl::OString& rName, const ::rtl::OString& rValue );
48 
49 	UnknownAttribute( const ::rtl::OString& rName, const ::rtl::OString& rValue );
50 
51 	void FillAttribute( ::com::sun::star::xml::Attribute* pAttrib ) const;
52 };
53 
54 typedef std::map< sal_Int32, ::rtl::OString > FastAttributeMap;
55 typedef std::vector< UnknownAttribute > UnknownAttributeList;
56 
57 class SAX_DLLPUBLIC FastAttributeList : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XFastAttributeList >
58 {
59 public:
60 	FastAttributeList( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler >& xTokenHandler );
61 	virtual ~FastAttributeList();
62 
63 	void clear();
64 	void add( sal_Int32 nToken, const ::rtl::OString& rValue );
65 	void addUnknown( const ::rtl::OUString& rNamespaceURL, const ::rtl::OString& rName, const ::rtl::OString& rValue );
66 	void addUnknown( const ::rtl::OString& rName, const ::rtl::OString& rValue );
67 
68     // XFastAttributeList
69     virtual ::sal_Bool SAL_CALL hasAttribute( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException);
70     virtual ::sal_Int32 SAL_CALL getValueToken( ::sal_Int32 Token ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
71     virtual ::sal_Int32 SAL_CALL getOptionalValueToken( ::sal_Int32 Token, ::sal_Int32 Default ) throw (::com::sun::star::uno::RuntimeException);
72     virtual ::rtl::OUString SAL_CALL getValue( ::sal_Int32 Token ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
73     virtual ::rtl::OUString SAL_CALL getOptionalValue( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException);
74     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::xml::Attribute > SAL_CALL getUnknownAttributes(  ) throw (::com::sun::star::uno::RuntimeException);
75     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::xml::FastAttribute > SAL_CALL getFastAttributes() throw (::com::sun::star::uno::RuntimeException);
76 
77 private:
78 	FastAttributeMap maAttributes;
79 	UnknownAttributeList maUnknownAttributes;
80 	FastAttributeMap::iterator maLastIter;
81 	::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler > mxTokenHandler;
82 
83 };
84 
85 }
86 
87 #endif
88