Update ooo320-m1
[ooovba.git] / xmloff / source / style / impastpl.hxx
blob64aca01b6a607b713c3a76384fb5eb3cb20fcd98
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: impastpl.hxx,v $
10 * $Revision: 1.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _XMLOFF_XMLASTPL_IMPL_HXX
32 #define _XMLOFF_XMLASTPL_IMPL_HXX
34 #include <sal/types.h>
35 #include <tools/list.hxx>
36 #include <svtools/cntnrsrt.hxx>
37 #include <rtl/ustring.hxx>
38 #include <vector>
39 #include <com/sun/star/uno/Reference.h>
40 #include <com/sun/star/xml/sax/XAttributeList.hpp>
41 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
42 #include <xmloff/maptype.hxx>
43 #include <xmloff/xmlexppr.hxx>
45 class SvXMLAutoStylePoolP;
46 class SvXMLAutoStylePoolParentsP_Impl;
47 class SvXMLAutoStylePoolNamesP_Impl;
48 class SvXMLAttributeList;
49 class SvXMLExportPropertyMapper;
50 class SvXMLExport;
52 #define MAX_CACHE_SIZE 65536
54 ///////////////////////////////////////////////////////////////////////////////
56 // Implementationclass for stylefamily-information
59 typedef ::rtl::OUString *OUStringPtr;
60 DECLARE_LIST( SvXMLAutoStylePoolCache_Impl, OUStringPtr )
62 class XMLFamilyData_Impl
64 public:
65 SvXMLAutoStylePoolCache_Impl *pCache;
66 sal_uInt32 mnFamily;
67 ::rtl::OUString maStrFamilyName;
68 UniReference < SvXMLExportPropertyMapper > mxMapper;
70 SvXMLAutoStylePoolParentsP_Impl* mpParentList;
71 SvXMLAutoStylePoolNamesP_Impl* mpNameList;
72 sal_uInt32 mnCount;
73 sal_uInt32 mnName;
74 ::rtl::OUString maStrPrefix;
75 sal_Bool bAsFamily;
77 public:
78 XMLFamilyData_Impl( sal_Int32 nFamily, const ::rtl::OUString& rStrName,
79 const UniReference < SvXMLExportPropertyMapper > & rMapper,
80 const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True );
82 XMLFamilyData_Impl( sal_Int32 nFamily ) :
83 pCache( 0 ),
84 mnFamily( nFamily ), mpParentList( NULL ),
85 mpNameList( NULL ), mnCount( 0 ), mnName( 0 )
88 ~XMLFamilyData_Impl();
90 friend int XMLFamilyDataSort_Impl( const XMLFamilyData_Impl& r1, const XMLFamilyData_Impl& r2 );
92 void ClearEntries();
95 DECLARE_CONTAINER_SORT( XMLFamilyDataList_Impl, XMLFamilyData_Impl )
97 ///////////////////////////////////////////////////////////////////////////////
102 DECLARE_CONTAINER_SORT_DEL( SvXMLAutoStylePoolNamesP_Impl,
103 ::rtl::OUString )
105 ///////////////////////////////////////////////////////////////////////////////
107 // Properties of a pool
110 class SvXMLAutoStylePoolPropertiesP_Impl
112 ::rtl::OUString msName;
113 ::std::vector< XMLPropertyState > maProperties;
114 sal_uInt32 mnPos;
116 public:
118 SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties );
120 ~SvXMLAutoStylePoolPropertiesP_Impl()
124 const ::rtl::OUString& GetName() const { return msName; }
125 const ::std::vector< XMLPropertyState >& GetProperties() const { return maProperties; }
126 sal_uInt32 GetPos() const { return mnPos; }
128 void SetName( const ::rtl::OUString& rNew ) { msName = rNew; }
131 typedef SvXMLAutoStylePoolPropertiesP_Impl *SvXMLAutoStylePoolPropertiesPPtr;
132 DECLARE_LIST( SvXMLAutoStylePoolPropertiesPList_Impl, SvXMLAutoStylePoolPropertiesPPtr )
134 ///////////////////////////////////////////////////////////////////////////////
136 // Parents of AutoStylePool's
139 class SvXMLAutoStylePoolParentP_Impl
141 ::rtl::OUString msParent;
142 SvXMLAutoStylePoolPropertiesPList_Impl maPropertiesList;
144 public:
146 SvXMLAutoStylePoolParentP_Impl( const ::rtl::OUString & rParent ) :
147 msParent( rParent )
151 ~SvXMLAutoStylePoolParentP_Impl();
153 sal_Bool Add( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties, ::rtl::OUString& rName, bool bDontSeek = false );
155 sal_Bool AddNamed( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties, const ::rtl::OUString& rName );
157 ::rtl::OUString Find( const XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties ) const;
159 const ::rtl::OUString& GetParent() const { return msParent; }
161 const SvXMLAutoStylePoolPropertiesPList_Impl& GetPropertiesList() const
163 return maPropertiesList;
167 DECLARE_CONTAINER_SORT_DEL( SvXMLAutoStylePoolParentsP_Impl,
168 SvXMLAutoStylePoolParentP_Impl )
170 ///////////////////////////////////////////////////////////////////////////////
172 // Implementationclass of SvXMLAutoStylePool
175 class SvXMLAutoStylePoolP_Impl
177 SvXMLExport& rExport;
179 XMLFamilyDataList_Impl maFamilyList;
181 public:
183 SvXMLAutoStylePoolP_Impl( SvXMLExport& rExport );
184 ~SvXMLAutoStylePoolP_Impl();
186 SvXMLExport& GetExport() const { return rExport; }
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 RegisterName( sal_Int32 nFamily, const ::rtl::OUString& rName );
192 void GetRegisteredNames(
193 com::sun::star::uno::Sequence<sal_Int32>& aFamilies,
194 com::sun::star::uno::Sequence<rtl::OUString>& aNames );
196 // ::rtl::OUString Add( sal_Int32 nFamily, const ::rtl::OUString& rParent,
197 // const ::std::vector< XMLPropertyState >& rProperties,
198 // sal_Bool bCache = sal_False );
199 sal_Bool Add( ::rtl::OUString& rName, sal_Int32 nFamily,
200 const ::rtl::OUString& rParent,
201 const ::std::vector< XMLPropertyState >& rProperties,
202 sal_Bool bCache = sal_False,
203 bool bDontSeek = false );
204 sal_Bool AddNamed( const ::rtl::OUString& rName, sal_Int32 nFamily,
205 const ::rtl::OUString& rParent,
206 const ::std::vector< XMLPropertyState >& rProperties );
208 ::rtl::OUString AddToCache( sal_Int32 nFamily,
209 const ::rtl::OUString& rParent );
210 ::rtl::OUString Find( sal_Int32 nFamily, const ::rtl::OUString& rParent,
211 const ::std::vector< XMLPropertyState >& rProperties ) const;
213 ::rtl::OUString FindAndRemoveCached( sal_Int32 nFamily ) const;
215 void exportXML( sal_Int32 nFamily,
216 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
217 const SvXMLUnitConverter& rUnitConverter,
218 const SvXMLNamespaceMap& rNamespaceMap,
219 const SvXMLAutoStylePoolP *pAntiImpl) const;
221 void ClearEntries();
224 struct SvXMLAutoStylePoolPExport_Impl
226 const ::rtl::OUString *mpParent;
227 const SvXMLAutoStylePoolPropertiesP_Impl *mpProperties;
230 #endif