xref: /aoo41x/main/xmloff/source/style/impastpl.hxx (revision cdf0e10c)
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_XMLASTPL_IMPL_HXX
29 #define _XMLOFF_XMLASTPL_IMPL_HXX
30 
31 #include <sal/types.h>
32 #include <tools/list.hxx>
33 #include <svl/cntnrsrt.hxx>
34 #include <rtl/ustring.hxx>
35 #include <vector>
36 #include <com/sun/star/uno/Reference.h>
37 #include <com/sun/star/xml/sax/XAttributeList.hpp>
38 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
39 #include <xmloff/maptype.hxx>
40 #include <xmloff/xmlexppr.hxx>
41 
42 class SvXMLAutoStylePoolP;
43 class SvXMLAutoStylePoolParentsP_Impl;
44 class SvXMLAutoStylePoolNamesP_Impl;
45 class SvXMLAttributeList;
46 class SvXMLExportPropertyMapper;
47 class SvXMLExport;
48 
49 #define MAX_CACHE_SIZE 65536
50 
51 ///////////////////////////////////////////////////////////////////////////////
52 //
53 // Implementationclass for stylefamily-information
54 //
55 
56 typedef ::rtl::OUString *OUStringPtr;
57 DECLARE_LIST( SvXMLAutoStylePoolCache_Impl, OUStringPtr )
58 
59 class XMLFamilyData_Impl
60 {
61 public:
62 	SvXMLAutoStylePoolCache_Impl		*pCache;
63 	sal_uInt32							mnFamily;
64 	::rtl::OUString						maStrFamilyName;
65 	UniReference < SvXMLExportPropertyMapper >	mxMapper;
66 
67 	SvXMLAutoStylePoolParentsP_Impl*	mpParentList;
68 	SvXMLAutoStylePoolNamesP_Impl*	    mpNameList;
69 	sal_uInt32							mnCount;
70 	sal_uInt32							mnName;
71 	::rtl::OUString						maStrPrefix;
72 	sal_Bool							bAsFamily;
73 
74 public:
75 	XMLFamilyData_Impl( sal_Int32 nFamily, const ::rtl::OUString& rStrName,
76 			const UniReference < SvXMLExportPropertyMapper > &  rMapper,
77 			const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True );
78 
79 	XMLFamilyData_Impl( sal_Int32 nFamily ) :
80 		pCache( 0 ),
81 		mnFamily( nFamily ), mpParentList( NULL ),
82 		mpNameList( NULL ), mnCount( 0 ), mnName( 0 )
83 
84 	{}
85 	~XMLFamilyData_Impl();
86 
87 	friend int XMLFamilyDataSort_Impl( const XMLFamilyData_Impl& r1, const XMLFamilyData_Impl& r2 );
88 
89 	void ClearEntries();
90 };
91 
92 DECLARE_CONTAINER_SORT( XMLFamilyDataList_Impl, XMLFamilyData_Impl )
93 
94 ///////////////////////////////////////////////////////////////////////////////
95 //
96 //
97 //
98 
99 DECLARE_CONTAINER_SORT_DEL( SvXMLAutoStylePoolNamesP_Impl,
100 						   ::rtl::OUString )
101 
102 ///////////////////////////////////////////////////////////////////////////////
103 //
104 // Properties of a pool
105 //
106 
107 class SvXMLAutoStylePoolPropertiesP_Impl
108 {
109 	::rtl::OUString						msName;
110 	::std::vector< XMLPropertyState >	maProperties;
111 	sal_uInt32							mnPos;
112 
113 public:
114 
115 	SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties );
116 
117 	~SvXMLAutoStylePoolPropertiesP_Impl()
118 	{
119 	}
120 
121 	const ::rtl::OUString& GetName() const { return msName; }
122 	const ::std::vector< XMLPropertyState >& GetProperties() const { return maProperties; }
123 	sal_uInt32 GetPos() const { return mnPos; }
124 
125 	void SetName( const ::rtl::OUString& rNew ) { msName = rNew; }
126 };
127 
128 typedef SvXMLAutoStylePoolPropertiesP_Impl *SvXMLAutoStylePoolPropertiesPPtr;
129 DECLARE_LIST( SvXMLAutoStylePoolPropertiesPList_Impl, SvXMLAutoStylePoolPropertiesPPtr )
130 
131 ///////////////////////////////////////////////////////////////////////////////
132 //
133 // Parents of AutoStylePool's
134 //
135 
136 class SvXMLAutoStylePoolParentP_Impl
137 {
138 	::rtl::OUString 						msParent;
139 	SvXMLAutoStylePoolPropertiesPList_Impl	maPropertiesList;
140 
141 public:
142 
143 	SvXMLAutoStylePoolParentP_Impl( const ::rtl::OUString & rParent ) :
144 		msParent( rParent )
145 	{
146 	}
147 
148 	~SvXMLAutoStylePoolParentP_Impl();
149 
150     sal_Bool Add( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties, ::rtl::OUString& rName, bool bDontSeek = false );
151 
152     sal_Bool AddNamed( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties, const ::rtl::OUString& rName );
153 
154 	::rtl::OUString Find( const XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties ) const;
155 
156 	const ::rtl::OUString& GetParent() const { return msParent; }
157 
158 	const SvXMLAutoStylePoolPropertiesPList_Impl& GetPropertiesList() const
159 	{
160 		return maPropertiesList;
161 	}
162 };
163 
164 DECLARE_CONTAINER_SORT_DEL( SvXMLAutoStylePoolParentsP_Impl,
165 							SvXMLAutoStylePoolParentP_Impl )
166 
167 ///////////////////////////////////////////////////////////////////////////////
168 //
169 // Implementationclass of SvXMLAutoStylePool
170 //
171 
172 class SvXMLAutoStylePoolP_Impl
173 {
174     SvXMLExport& rExport;
175 
176 	XMLFamilyDataList_Impl		maFamilyList;
177 
178 public:
179 
180 	SvXMLAutoStylePoolP_Impl( SvXMLExport& rExport );
181 	~SvXMLAutoStylePoolP_Impl();
182 
183     SvXMLExport& GetExport() const { return rExport; }
184 
185 	void AddFamily( sal_Int32 nFamily, const ::rtl::OUString& rStrName,
186 		const UniReference < SvXMLExportPropertyMapper > & rMapper,
187 		const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True );
188 	void RegisterName( sal_Int32 nFamily, const ::rtl::OUString& rName );
189 	void GetRegisteredNames(
190         com::sun::star::uno::Sequence<sal_Int32>& aFamilies,
191         com::sun::star::uno::Sequence<rtl::OUString>& aNames );
192 
193 //	::rtl::OUString Add( sal_Int32 nFamily, const ::rtl::OUString& rParent,
194 //		                 const ::std::vector< XMLPropertyState >& rProperties,
195 //					  	 sal_Bool bCache = sal_False );
196 	sal_Bool Add( ::rtl::OUString& rName, sal_Int32 nFamily,
197 				const ::rtl::OUString& rParent,
198 				const ::std::vector< XMLPropertyState >& rProperties,
199                 sal_Bool bCache = sal_False,
200                 bool bDontSeek = false );
201     sal_Bool AddNamed( const ::rtl::OUString& rName, sal_Int32 nFamily,
202                 const ::rtl::OUString& rParent,
203                 const ::std::vector< XMLPropertyState >& rProperties );
204 
205 	::rtl::OUString AddToCache( sal_Int32 nFamily,
206 								const ::rtl::OUString& rParent );
207 	::rtl::OUString Find( sal_Int32 nFamily, const ::rtl::OUString& rParent,
208 		                  const ::std::vector< XMLPropertyState >& rProperties ) const;
209 
210 	::rtl::OUString FindAndRemoveCached( sal_Int32 nFamily ) const;
211 
212 	void exportXML( sal_Int32 nFamily,
213 		const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
214 		const SvXMLUnitConverter& rUnitConverter,
215 		const SvXMLNamespaceMap& rNamespaceMap,
216 		const SvXMLAutoStylePoolP *pAntiImpl) const;
217 
218 	void ClearEntries();
219 };
220 
221 struct SvXMLAutoStylePoolPExport_Impl
222 {
223 	const ::rtl::OUString					*mpParent;
224 	const SvXMLAutoStylePoolPropertiesP_Impl	*mpProperties;
225 };
226 
227 #endif
228