Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _XMLOFF_XMLASTPL_IMPL_HXX
30 : : #define _XMLOFF_XMLASTPL_IMPL_HXX
31 : :
32 : : #include <boost/ptr_container/ptr_set.hpp>
33 : : #include <sal/types.h>
34 : : #include <rtl/ustring.hxx>
35 : : #include <set>
36 : : #include <vector>
37 : : #include <com/sun/star/uno/Reference.h>
38 : : #include <com/sun/star/xml/sax/XAttributeList.hpp>
39 : : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
40 : : #include <o3tl/sorted_vector.hxx>
41 : : #include <xmloff/maptype.hxx>
42 : : #include <xmloff/xmlexppr.hxx>
43 : :
44 : : class SvXMLAutoStylePoolP;
45 : : class SvXMLAutoStylePoolParentsP_Impl;
46 : : typedef std::set<rtl::OUString> SvXMLAutoStylePoolNamesP_Impl;
47 : : class SvXMLExportPropertyMapper;
48 : : class SvXMLExport;
49 : :
50 : : #define MAX_CACHE_SIZE 65536
51 : :
52 : : ///////////////////////////////////////////////////////////////////////////////
53 : : //
54 : : // Implementationclass for stylefamily-information
55 : : //
56 : :
57 : : typedef ::rtl::OUString* OUStringPtr;
58 : : typedef ::std::vector< OUStringPtr > SvXMLAutoStylePoolCache_Impl;
59 : :
60 : : class XMLFamilyData_Impl
61 : : {
62 : : public:
63 : : SvXMLAutoStylePoolCache_Impl *pCache;
64 : : sal_uInt32 mnFamily;
65 : : ::rtl::OUString maStrFamilyName;
66 : : UniReference < SvXMLExportPropertyMapper > mxMapper;
67 : :
68 : : SvXMLAutoStylePoolParentsP_Impl* mpParentList;
69 : : SvXMLAutoStylePoolNamesP_Impl* mpNameList;
70 : : sal_uInt32 mnCount;
71 : : sal_uInt32 mnName;
72 : : ::rtl::OUString maStrPrefix;
73 : : sal_Bool bAsFamily;
74 : :
75 : : public:
76 : : XMLFamilyData_Impl( sal_Int32 nFamily, const ::rtl::OUString& rStrName,
77 : : const UniReference < SvXMLExportPropertyMapper > & rMapper,
78 : : const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True );
79 : :
80 : 9791 : XMLFamilyData_Impl( sal_Int32 nFamily ) :
81 : : pCache( 0 ),
82 : : mnFamily( nFamily ), mpParentList( NULL ),
83 : 9791 : mpNameList( NULL ), mnCount( 0 ), mnName( 0 )
84 : :
85 : 9791 : {}
86 : : ~XMLFamilyData_Impl();
87 : :
88 : : friend bool operator<(const XMLFamilyData_Impl& r1, const XMLFamilyData_Impl& r2);
89 : :
90 : : void ClearEntries();
91 : : };
92 : :
93 : : typedef boost::ptr_set<XMLFamilyData_Impl> XMLFamilyDataList_Impl;
94 : :
95 : : ///////////////////////////////////////////////////////////////////////////////
96 : : //
97 : : // Properties of a pool
98 : : //
99 : :
100 : : class SvXMLAutoStylePoolPropertiesP_Impl
101 : : {
102 : : ::rtl::OUString msName;
103 : : ::std::vector< XMLPropertyState > maProperties;
104 : : sal_uInt32 mnPos;
105 : :
106 : : public:
107 : :
108 : : SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties );
109 : :
110 : 246 : ~SvXMLAutoStylePoolPropertiesP_Impl()
111 : 246 : {
112 : 246 : }
113 : :
114 : 789 : const ::rtl::OUString& GetName() const { return msName; }
115 : 2809 : const ::std::vector< XMLPropertyState >& GetProperties() const { return maProperties; }
116 : 250 : sal_uInt32 GetPos() const { return mnPos; }
117 : :
118 : 0 : void SetName( const ::rtl::OUString& rNew ) { msName = rNew; }
119 : : };
120 : :
121 : : typedef SvXMLAutoStylePoolPropertiesP_Impl* SvXMLAutoStylePoolPropertiesPPtr;
122 : : typedef ::std::vector< SvXMLAutoStylePoolPropertiesPPtr > SvXMLAutoStylePoolPropertiesPList_Impl;
123 : :
124 : : ///////////////////////////////////////////////////////////////////////////////
125 : : //
126 : : // Parents of AutoStylePool's
127 : : //
128 : :
129 : : class SvXMLAutoStylePoolParentP_Impl
130 : : {
131 : : ::rtl::OUString msParent;
132 : : SvXMLAutoStylePoolPropertiesPList_Impl maPropertiesList;
133 : :
134 : : public:
135 : :
136 : 738 : SvXMLAutoStylePoolParentP_Impl( const ::rtl::OUString & rParent ) :
137 [ + - ]: 738 : msParent( rParent )
138 : : {
139 : 738 : }
140 : :
141 : : ~SvXMLAutoStylePoolParentP_Impl();
142 : :
143 : : sal_Bool Add( XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties, ::rtl::OUString& rName, bool bDontSeek = false );
144 : :
145 : : sal_Bool AddNamed( XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties, const ::rtl::OUString& rName );
146 : :
147 : : ::rtl::OUString Find( const XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties ) const;
148 : :
149 : 2230 : const ::rtl::OUString& GetParent() const { return msParent; }
150 : :
151 : 355 : const SvXMLAutoStylePoolPropertiesPList_Impl& GetPropertiesList() const
152 : : {
153 : 355 : return maPropertiesList;
154 : : }
155 : : };
156 : :
157 : : struct SvXMLAutoStylePoolParentPCmp_Impl
158 : : {
159 : 990 : bool operator()( SvXMLAutoStylePoolParentP_Impl* const& lhs, SvXMLAutoStylePoolParentP_Impl* const& rhs) const
160 : : {
161 : 990 : return lhs->GetParent().compareTo( rhs->GetParent() ) < 0;
162 : : }
163 : : };
164 : 2766 : class SvXMLAutoStylePoolParentsP_Impl : public o3tl::sorted_vector<SvXMLAutoStylePoolParentP_Impl*, SvXMLAutoStylePoolParentPCmp_Impl>
165 : : {
166 : : public:
167 [ + - ]: 2766 : ~SvXMLAutoStylePoolParentsP_Impl() { DeleteAndDestroyAll(); }
168 : : };
169 : :
170 : : ///////////////////////////////////////////////////////////////////////////////
171 : : //
172 : : // Implementationclass of SvXMLAutoStylePool
173 : : //
174 : :
175 : : class SvXMLAutoStylePoolP_Impl
176 : : {
177 : : SvXMLExport& rExport;
178 : :
179 : : XMLFamilyDataList_Impl maFamilyList;
180 : :
181 : : public:
182 : :
183 : : SvXMLAutoStylePoolP_Impl( SvXMLExport& rExport );
184 : : ~SvXMLAutoStylePoolP_Impl();
185 : :
186 : 9710 : SvXMLExport& GetExport() const { return rExport; }
187 : :
188 : : void AddFamily( sal_Int32 nFamily, const ::rtl::OUString& rStrName,
189 : : const UniReference < SvXMLExportPropertyMapper > & rMapper,
190 : : const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True );
191 : : void SetFamilyPropSetMapper( sal_Int32 nFamily,
192 : : const UniReference < SvXMLExportPropertyMapper > & rMapper );
193 : : void RegisterName( sal_Int32 nFamily, const ::rtl::OUString& rName );
194 : : void GetRegisteredNames(
195 : : com::sun::star::uno::Sequence<sal_Int32>& aFamilies,
196 : : com::sun::star::uno::Sequence<rtl::OUString>& aNames );
197 : :
198 : : sal_Bool Add( ::rtl::OUString& rName, sal_Int32 nFamily,
199 : : const ::rtl::OUString& rParent,
200 : : const ::std::vector< XMLPropertyState >& rProperties,
201 : : sal_Bool bCache = sal_False,
202 : : bool bDontSeek = false );
203 : : sal_Bool AddNamed( const ::rtl::OUString& rName, sal_Int32 nFamily,
204 : : const ::rtl::OUString& rParent,
205 : : const ::std::vector< XMLPropertyState >& rProperties );
206 : :
207 : : ::rtl::OUString Find( sal_Int32 nFamily, const ::rtl::OUString& rParent,
208 : : const ::std::vector< XMLPropertyState >& rProperties ) const;
209 : :
210 : : void exportXML( sal_Int32 nFamily,
211 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
212 : : const SvXMLUnitConverter& rUnitConverter,
213 : : const SvXMLNamespaceMap& rNamespaceMap,
214 : : const SvXMLAutoStylePoolP *pAntiImpl) const;
215 : :
216 : : void ClearEntries();
217 : : };
218 : :
219 : : struct SvXMLAutoStylePoolPExport_Impl
220 : : {
221 : : const ::rtl::OUString *mpParent;
222 : : const SvXMLAutoStylePoolPropertiesP_Impl *mpProperties;
223 : : };
224 : :
225 : : #endif
226 : :
227 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|