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