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