1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _XMLOFF_XMLASTPL_IMPL_HXX
21 #define _XMLOFF_XMLASTPL_IMPL_HXX
23 #include <boost/ptr_container/ptr_set.hpp>
24 #include <sal/types.h>
25 #include <rtl/ustring.hxx>
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>
35 class SvXMLAutoStylePoolP
;
36 class SvXMLAutoStylePoolParentsP_Impl
;
37 typedef std::set
<OUString
> SvXMLAutoStylePoolNamesP_Impl
;
38 class SvXMLExportPropertyMapper
;
41 #define MAX_CACHE_SIZE 65536
43 ///////////////////////////////////////////////////////////////////////////////
45 // Implementationclass for stylefamily-information
48 typedef OUString
* OUStringPtr
;
49 typedef ::std::vector
< OUStringPtr
> SvXMLAutoStylePoolCache_Impl
;
51 class XMLFamilyData_Impl
54 SvXMLAutoStylePoolCache_Impl
*pCache
;
56 OUString maStrFamilyName
;
57 UniReference
< SvXMLExportPropertyMapper
> mxMapper
;
59 SvXMLAutoStylePoolParentsP_Impl
* mpParentList
;
60 SvXMLAutoStylePoolNamesP_Impl
* mpNameList
;
67 XMLFamilyData_Impl( sal_Int32 nFamily
, const OUString
& rStrName
,
68 const UniReference
< SvXMLExportPropertyMapper
> & rMapper
,
69 const OUString
& rStrPrefix
, sal_Bool bAsFamily
= sal_True
);
71 XMLFamilyData_Impl( sal_Int32 nFamily
) :
73 mnFamily( nFamily
), mpParentList( NULL
),
74 mpNameList( NULL
), mnCount( 0 ), mnName( 0 )
77 ~XMLFamilyData_Impl();
79 friend bool operator<(const XMLFamilyData_Impl
& r1
, const XMLFamilyData_Impl
& r2
);
84 /// A set that finds and sorts based only on mnFamily
85 typedef boost::ptr_set
<XMLFamilyData_Impl
> XMLFamilyDataList_Impl
;
87 ///////////////////////////////////////////////////////////////////////////////
89 // Properties of a pool
92 class SvXMLAutoStylePoolPropertiesP_Impl
95 ::std::vector
< XMLPropertyState
> maProperties
;
100 SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl
& rFamilyData
, const ::std::vector
< XMLPropertyState
>& rProperties
);
102 ~SvXMLAutoStylePoolPropertiesP_Impl()
106 const OUString
& GetName() const { return msName
; }
107 const ::std::vector
< XMLPropertyState
>& GetProperties() const { return maProperties
; }
108 sal_uInt32
GetPos() const { return mnPos
; }
110 void SetName( const OUString
& rNew
) { msName
= rNew
; }
113 typedef SvXMLAutoStylePoolPropertiesP_Impl
* SvXMLAutoStylePoolPropertiesPPtr
;
114 typedef ::std::vector
< SvXMLAutoStylePoolPropertiesPPtr
> SvXMLAutoStylePoolPropertiesPList_Impl
;
116 ///////////////////////////////////////////////////////////////////////////////
118 // Parents of AutoStylePool's
121 class SvXMLAutoStylePoolParentP_Impl
124 SvXMLAutoStylePoolPropertiesPList_Impl maPropertiesList
;
128 SvXMLAutoStylePoolParentP_Impl( const OUString
& rParent
) :
133 ~SvXMLAutoStylePoolParentP_Impl();
135 sal_Bool
Add( XMLFamilyData_Impl
& rFamilyData
, const ::std::vector
< XMLPropertyState
>& rProperties
, OUString
& rName
, bool bDontSeek
= false );
137 sal_Bool
AddNamed( XMLFamilyData_Impl
& rFamilyData
, const ::std::vector
< XMLPropertyState
>& rProperties
, const OUString
& rName
);
139 OUString
Find( const XMLFamilyData_Impl
& rFamilyData
, const ::std::vector
< XMLPropertyState
>& rProperties
) const;
141 const OUString
& GetParent() const { return msParent
; }
143 const SvXMLAutoStylePoolPropertiesPList_Impl
& GetPropertiesList() const
145 return maPropertiesList
;
149 struct SvXMLAutoStylePoolParentPCmp_Impl
151 bool operator()( SvXMLAutoStylePoolParentP_Impl
* const& lhs
, SvXMLAutoStylePoolParentP_Impl
* const& rhs
) const
153 return lhs
->GetParent().compareTo( rhs
->GetParent() ) < 0;
156 class SvXMLAutoStylePoolParentsP_Impl
: public o3tl::sorted_vector
<SvXMLAutoStylePoolParentP_Impl
*, SvXMLAutoStylePoolParentPCmp_Impl
>
159 ~SvXMLAutoStylePoolParentsP_Impl() { DeleteAndDestroyAll(); }
162 ///////////////////////////////////////////////////////////////////////////////
164 // Implementationclass of SvXMLAutoStylePool
167 class SvXMLAutoStylePoolP_Impl
169 SvXMLExport
& rExport
;
171 XMLFamilyDataList_Impl maFamilyList
;
175 SvXMLAutoStylePoolP_Impl( SvXMLExport
& rExport
);
176 ~SvXMLAutoStylePoolP_Impl();
178 SvXMLExport
& GetExport() const { return rExport
; }
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
);
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
);
199 OUString
Find( sal_Int32 nFamily
, const OUString
& rParent
,
200 const ::std::vector
< XMLPropertyState
>& rProperties
) const;
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;
211 struct SvXMLAutoStylePoolPExport_Impl
213 const OUString
*mpParent
;
214 const SvXMLAutoStylePoolPropertiesP_Impl
*mpProperties
;
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */