Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _XMLOFF_XMLASTPL_IMPL_HXX
21 : #define _XMLOFF_XMLASTPL_IMPL_HXX
22 :
23 : #include <boost/ptr_container/ptr_set.hpp>
24 : #include <sal/types.h>
25 : #include <rtl/ustring.hxx>
26 : #include <set>
27 : #include <vector>
28 : #include <com/sun/star/uno/Reference.h>
29 : #include <com/sun/star/xml/sax/XAttributeList.hpp>
30 : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
31 : #include <o3tl/sorted_vector.hxx>
32 : #include <xmloff/maptype.hxx>
33 : #include <xmloff/xmlexppr.hxx>
34 :
35 : class SvXMLAutoStylePoolP;
36 : class SvXMLAutoStylePoolParentsP_Impl;
37 : typedef std::set<OUString> SvXMLAutoStylePoolNamesP_Impl;
38 : class SvXMLExportPropertyMapper;
39 : class SvXMLExport;
40 :
41 : #define MAX_CACHE_SIZE 65536
42 :
43 : ///////////////////////////////////////////////////////////////////////////////
44 : //
45 : // Implementationclass for stylefamily-information
46 : //
47 :
48 : typedef OUString* OUStringPtr;
49 : typedef ::std::vector< OUStringPtr > SvXMLAutoStylePoolCache_Impl;
50 :
51 : class XMLFamilyData_Impl
52 : {
53 : public:
54 : SvXMLAutoStylePoolCache_Impl *pCache;
55 : sal_uInt32 mnFamily;
56 : OUString maStrFamilyName;
57 : UniReference < SvXMLExportPropertyMapper > mxMapper;
58 :
59 : SvXMLAutoStylePoolParentsP_Impl* mpParentList;
60 : SvXMLAutoStylePoolNamesP_Impl* mpNameList;
61 : sal_uInt32 mnCount;
62 : sal_uInt32 mnName;
63 : OUString maStrPrefix;
64 : sal_Bool bAsFamily;
65 :
66 : public:
67 : XMLFamilyData_Impl( sal_Int32 nFamily, const OUString& rStrName,
68 : const UniReference < SvXMLExportPropertyMapper > & rMapper,
69 : const OUString& rStrPrefix, sal_Bool bAsFamily = sal_True );
70 :
71 7177 : XMLFamilyData_Impl( sal_Int32 nFamily ) :
72 : pCache( 0 ),
73 : mnFamily( nFamily ), mpParentList( NULL ),
74 7177 : mpNameList( NULL ), mnCount( 0 ), mnName( 0 )
75 :
76 7177 : {}
77 : ~XMLFamilyData_Impl();
78 :
79 : friend bool operator<(const XMLFamilyData_Impl& r1, const XMLFamilyData_Impl& r2);
80 :
81 : void ClearEntries();
82 : };
83 :
84 : /// A set that finds and sorts based only on mnFamily
85 : typedef boost::ptr_set<XMLFamilyData_Impl> XMLFamilyDataList_Impl;
86 :
87 : ///////////////////////////////////////////////////////////////////////////////
88 : //
89 : // Properties of a pool
90 : //
91 :
92 : class SvXMLAutoStylePoolPropertiesP_Impl
93 : {
94 : OUString msName;
95 : ::std::vector< XMLPropertyState > maProperties;
96 : sal_uInt32 mnPos;
97 :
98 : public:
99 :
100 : SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties );
101 :
102 210 : ~SvXMLAutoStylePoolPropertiesP_Impl()
103 210 : {
104 210 : }
105 :
106 602 : const OUString& GetName() const { return msName; }
107 2062 : const ::std::vector< XMLPropertyState >& GetProperties() const { return maProperties; }
108 211 : sal_uInt32 GetPos() const { return mnPos; }
109 :
110 0 : void SetName( const OUString& rNew ) { msName = rNew; }
111 : };
112 :
113 : typedef SvXMLAutoStylePoolPropertiesP_Impl* SvXMLAutoStylePoolPropertiesPPtr;
114 : typedef ::std::vector< SvXMLAutoStylePoolPropertiesPPtr > SvXMLAutoStylePoolPropertiesPList_Impl;
115 :
116 : ///////////////////////////////////////////////////////////////////////////////
117 : //
118 : // Parents of AutoStylePool's
119 : //
120 :
121 : class SvXMLAutoStylePoolParentP_Impl
122 : {
123 : OUString msParent;
124 : SvXMLAutoStylePoolPropertiesPList_Impl maPropertiesList;
125 :
126 : public:
127 :
128 565 : SvXMLAutoStylePoolParentP_Impl( const OUString & rParent ) :
129 565 : msParent( rParent )
130 : {
131 565 : }
132 :
133 : ~SvXMLAutoStylePoolParentP_Impl();
134 :
135 : sal_Bool Add( XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties, OUString& rName, bool bDontSeek = false );
136 :
137 : sal_Bool AddNamed( XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties, const OUString& rName );
138 :
139 : OUString Find( const XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties ) const;
140 :
141 1563 : const OUString& GetParent() const { return msParent; }
142 :
143 313 : const SvXMLAutoStylePoolPropertiesPList_Impl& GetPropertiesList() const
144 : {
145 313 : return maPropertiesList;
146 : }
147 : };
148 :
149 : struct SvXMLAutoStylePoolParentPCmp_Impl
150 : {
151 676 : bool operator()( SvXMLAutoStylePoolParentP_Impl* const& lhs, SvXMLAutoStylePoolParentP_Impl* const& rhs) const
152 : {
153 676 : return lhs->GetParent().compareTo( rhs->GetParent() ) < 0;
154 : }
155 : };
156 1882 : class SvXMLAutoStylePoolParentsP_Impl : public o3tl::sorted_vector<SvXMLAutoStylePoolParentP_Impl*, SvXMLAutoStylePoolParentPCmp_Impl>
157 : {
158 : public:
159 1882 : ~SvXMLAutoStylePoolParentsP_Impl() { DeleteAndDestroyAll(); }
160 : };
161 :
162 : ///////////////////////////////////////////////////////////////////////////////
163 : //
164 : // Implementationclass of SvXMLAutoStylePool
165 : //
166 :
167 : class SvXMLAutoStylePoolP_Impl
168 : {
169 : SvXMLExport& rExport;
170 :
171 : XMLFamilyDataList_Impl maFamilyList;
172 :
173 : public:
174 :
175 : SvXMLAutoStylePoolP_Impl( SvXMLExport& rExport );
176 : ~SvXMLAutoStylePoolP_Impl();
177 :
178 6940 : SvXMLExport& GetExport() const { return rExport; }
179 :
180 : void AddFamily( sal_Int32 nFamily, const OUString& rStrName,
181 : const UniReference < SvXMLExportPropertyMapper > & rMapper,
182 : const OUString& rStrPrefix, sal_Bool bAsFamily = sal_True );
183 : void SetFamilyPropSetMapper( sal_Int32 nFamily,
184 : const UniReference < SvXMLExportPropertyMapper > & rMapper );
185 : void RegisterName( sal_Int32 nFamily, const OUString& rName );
186 : void GetRegisteredNames(
187 : com::sun::star::uno::Sequence<sal_Int32>& aFamilies,
188 : com::sun::star::uno::Sequence<OUString>& aNames );
189 :
190 : sal_Bool Add( OUString& rName, sal_Int32 nFamily,
191 : const OUString& rParent,
192 : const ::std::vector< XMLPropertyState >& rProperties,
193 : sal_Bool bCache = sal_False,
194 : bool bDontSeek = false );
195 : sal_Bool AddNamed( const OUString& rName, sal_Int32 nFamily,
196 : const OUString& rParent,
197 : const ::std::vector< XMLPropertyState >& rProperties );
198 :
199 : OUString Find( sal_Int32 nFamily, const OUString& rParent,
200 : const ::std::vector< XMLPropertyState >& rProperties ) const;
201 :
202 : void exportXML( sal_Int32 nFamily,
203 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
204 : const SvXMLUnitConverter& rUnitConverter,
205 : const SvXMLNamespaceMap& rNamespaceMap,
206 : const SvXMLAutoStylePoolP *pAntiImpl) const;
207 :
208 : void ClearEntries();
209 : };
210 :
211 : struct SvXMLAutoStylePoolPExport_Impl
212 : {
213 : const OUString *mpParent;
214 : const SvXMLAutoStylePoolPropertiesP_Impl *mpProperties;
215 : };
216 :
217 : #endif
218 :
219 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|