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 _XMLOFF_FORMS_ATTRIBLISTMERGE_HXX_
25 #define _XMLOFF_FORMS_ATTRIBLISTMERGE_HXX_
26 
27 #include <comphelper/stl_types.hxx>
28 #include <cppuhelper/implbase1.hxx>
29 #include <osl/mutex.hxx>
30 #include <com/sun/star/xml/sax/XAttributeList.hpp>
31 
32 //.........................................................................
33 namespace xmloff
34 {
35 //.........................................................................
36 
37 	//=====================================================================
38 	//= OAttribListMerger
39 	//=====================================================================
40 	typedef ::cppu::WeakImplHelper1	<	::com::sun::star::xml::sax::XAttributeList
41 									>	OAttribListMerger_Base;
42 	/** implements the XAttributeList list by merging different source attribute lists
43 
44 		<p>Currently, the time behavious is O(n), though it would be possible to change it to O(log n).</p>
45 	*/
46 	class OAttribListMerger : public OAttribListMerger_Base
47 	{
48 	protected:
49 		::osl::Mutex		m_aMutex;
50 		DECLARE_STL_VECTOR( ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >, AttributeListArray );
51 		AttributeListArray	m_aLists;
52 
~OAttribListMerger()53 		~OAttribListMerger() { }
54 
55 	public:
OAttribListMerger()56 		OAttribListMerger() { }
57 
58 		// attribute list handling
59 		// (very thinn at the moment ... only adding lists is allowed ... add more if you need it :)
60 		void addList(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rList);
61 
62 		// XAttributeList
63 		virtual sal_Int16 SAL_CALL getLength(  ) throw(::com::sun::star::uno::RuntimeException);
64 		virtual ::rtl::OUString SAL_CALL getNameByIndex( sal_Int16 i ) throw(::com::sun::star::uno::RuntimeException);
65 		virtual ::rtl::OUString SAL_CALL getTypeByIndex( sal_Int16 i ) throw(::com::sun::star::uno::RuntimeException);
66 		virtual ::rtl::OUString SAL_CALL getTypeByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
67 		virtual ::rtl::OUString SAL_CALL getValueByIndex( sal_Int16 i ) throw(::com::sun::star::uno::RuntimeException);
68 		virtual ::rtl::OUString SAL_CALL getValueByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
69 
70 	protected:
71 		sal_Bool seekToIndex(sal_Int16 _nGlobalIndex, ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rSubList, sal_Int16& _rLocalIndex);
72 		sal_Bool seekToName(const ::rtl::OUString& _rName, ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rSubList, sal_Int16& _rLocalIndex);
73 	};
74 
75 
76 //.........................................................................
77 }	// namespace xmloff
78 //.........................................................................
79 
80 #endif // _XMLOFF_FORMS_ATTRIBLISTMERGE_HXX_
81 
82