1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*63bba73cSAndrew Rist * distributed with this work for additional information
6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at
10*63bba73cSAndrew Rist *
11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*63bba73cSAndrew Rist *
13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the
17*63bba73cSAndrew Rist * specific language governing permissions and limitations
18*63bba73cSAndrew Rist * under the License.
19*63bba73cSAndrew Rist *
20*63bba73cSAndrew Rist *************************************************************/
21*63bba73cSAndrew Rist
22*63bba73cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir #include <tools/debug.hxx>
27cdf0e10cSrcweir #include <xmloff/xmlaustp.hxx>
28cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
29cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
30cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
31cdf0e10cSrcweir #include <xmloff/attrlist.hxx>
32cdf0e10cSrcweir #include "impastpl.hxx"
33cdf0e10cSrcweir #include <xmloff/xmlexppr.hxx>
34cdf0e10cSrcweir #include <xmloff/xmlexp.hxx>
35cdf0e10cSrcweir #include <xmloff/families.hxx>
36cdf0e10cSrcweir #ifndef _XMLOFF_PAGEMASTERSTYLEMAP_HXX
37cdf0e10cSrcweir #include <xmloff/PageMasterStyleMap.hxx>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir
40cdf0e10cSrcweir using namespace ::std;
41cdf0e10cSrcweir using ::rtl::OUString;
42cdf0e10cSrcweir using ::rtl::OUStringBuffer;
43cdf0e10cSrcweir
44cdf0e10cSrcweir using namespace ::com::sun::star;
45cdf0e10cSrcweir using namespace ::xmloff::token;
46cdf0e10cSrcweir
47cdf0e10cSrcweir //#############################################################################
48cdf0e10cSrcweir //
49cdf0e10cSrcweir // Class SvXMLAutoStylePool_Impl
50cdf0e10cSrcweir //
51cdf0e10cSrcweir
52cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////////
53cdf0e10cSrcweir //
54cdf0e10cSrcweir // ctor/dtor class SvXMLAutoStylePool_Impl
55cdf0e10cSrcweir //
56cdf0e10cSrcweir
SvXMLAutoStylePoolP_Impl(SvXMLExport & rExp)57cdf0e10cSrcweir SvXMLAutoStylePoolP_Impl::SvXMLAutoStylePoolP_Impl( SvXMLExport& rExp)
58cdf0e10cSrcweir : rExport( rExp ),
59cdf0e10cSrcweir maFamilyList( 5, 5 )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir }
62cdf0e10cSrcweir
~SvXMLAutoStylePoolP_Impl()63cdf0e10cSrcweir SvXMLAutoStylePoolP_Impl::~SvXMLAutoStylePoolP_Impl()
64cdf0e10cSrcweir {
65cdf0e10cSrcweir for (;;) {
66cdf0e10cSrcweir XMLFamilyData_Impl* pData = maFamilyList.Remove( sal_uLong(0) );
67cdf0e10cSrcweir if (pData == NULL) {
68cdf0e10cSrcweir break;
69cdf0e10cSrcweir }
70cdf0e10cSrcweir delete pData;
71cdf0e10cSrcweir }
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
74cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////////
75cdf0e10cSrcweir //
76cdf0e10cSrcweir // Adds stylefamily-informations to sorted list
77cdf0e10cSrcweir //
78cdf0e10cSrcweir
AddFamily(sal_Int32 nFamily,const OUString & rStrName,const UniReference<SvXMLExportPropertyMapper> & rMapper,const OUString & rStrPrefix,sal_Bool bAsFamily)79cdf0e10cSrcweir void SvXMLAutoStylePoolP_Impl::AddFamily(
80cdf0e10cSrcweir sal_Int32 nFamily,
81cdf0e10cSrcweir const OUString& rStrName,
82cdf0e10cSrcweir const UniReference < SvXMLExportPropertyMapper > & rMapper,
83cdf0e10cSrcweir const OUString& rStrPrefix,
84cdf0e10cSrcweir sal_Bool bAsFamily )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir // store family in a list if not already stored
87cdf0e10cSrcweir sal_uLong nPos;
88cdf0e10cSrcweir
89cdf0e10cSrcweir sal_uInt16 nExportFlags = GetExport().getExportFlags();
90cdf0e10cSrcweir sal_Bool bStylesOnly = (nExportFlags & EXPORT_STYLES) != 0 && (nExportFlags & EXPORT_CONTENT) == 0;
91cdf0e10cSrcweir
92cdf0e10cSrcweir OUString aPrefix( rStrPrefix );
93cdf0e10cSrcweir if( bStylesOnly )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir aPrefix = OUString( 'M' );
96cdf0e10cSrcweir aPrefix += rStrPrefix;
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
99cdf0e10cSrcweir XMLFamilyData_Impl *pFamily = new XMLFamilyData_Impl( nFamily, rStrName, rMapper, aPrefix, bAsFamily );
100cdf0e10cSrcweir if( !maFamilyList.Seek_Entry( pFamily, &nPos ) )
101cdf0e10cSrcweir maFamilyList.Insert( pFamily );
102cdf0e10cSrcweir else
103cdf0e10cSrcweir delete pFamily;
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
106cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////////
107cdf0e10cSrcweir //
108cdf0e10cSrcweir // Adds a name to list
109cdf0e10cSrcweir //
110cdf0e10cSrcweir
RegisterName(sal_Int32 nFamily,const OUString & rName)111cdf0e10cSrcweir void SvXMLAutoStylePoolP_Impl::RegisterName( sal_Int32 nFamily, const OUString& rName )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir SvXMLAutoStylePoolNamesP_Impl *pNames = 0;
114cdf0e10cSrcweir
115cdf0e10cSrcweir sal_uLong nPos;
116cdf0e10cSrcweir XMLFamilyData_Impl aTmp( nFamily );
117cdf0e10cSrcweir if( maFamilyList.Seek_Entry( &aTmp, &nPos ) )
118cdf0e10cSrcweir pNames = maFamilyList.GetObject( nPos )->mpNameList;
119cdf0e10cSrcweir
120cdf0e10cSrcweir DBG_ASSERT( pNames,
121cdf0e10cSrcweir "SvXMLAutoStylePool_Impl::RegisterName: unknown family" );
122cdf0e10cSrcweir if( pNames )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir OUString *pName = new OUString( rName );
125cdf0e10cSrcweir if( !pNames->Insert( pName ) )
126cdf0e10cSrcweir delete pName;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir }
129cdf0e10cSrcweir
130cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////////
131cdf0e10cSrcweir //
132cdf0e10cSrcweir // Retrieve the list of registered names
133cdf0e10cSrcweir //
134cdf0e10cSrcweir
GetRegisteredNames(uno::Sequence<sal_Int32> & rFamilies,uno::Sequence<OUString> & rNames)135cdf0e10cSrcweir void SvXMLAutoStylePoolP_Impl::GetRegisteredNames(
136cdf0e10cSrcweir uno::Sequence<sal_Int32>& rFamilies,
137cdf0e10cSrcweir uno::Sequence<OUString>& rNames )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir // collect registered names + families
140cdf0e10cSrcweir vector<sal_Int32> aFamilies;
141cdf0e10cSrcweir vector<OUString> aNames;
142cdf0e10cSrcweir
143cdf0e10cSrcweir // iterate over families
144cdf0e10cSrcweir sal_uInt32 nCount = maFamilyList.Count();
145cdf0e10cSrcweir for( sal_uInt32 i = 0; i < nCount; i++ )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir XMLFamilyData_Impl* pFamily = maFamilyList.GetObject( i );
148cdf0e10cSrcweir
149cdf0e10cSrcweir // iterate over names
150cdf0e10cSrcweir SvXMLAutoStylePoolNamesP_Impl* pNames = pFamily->mpNameList;
151cdf0e10cSrcweir sal_uInt32 nNames = ( pNames != NULL ) ? pNames->Count() : 0;
152cdf0e10cSrcweir for( sal_uInt32 j = 0; j < nNames; j++ )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir aFamilies.push_back( pFamily->mnFamily );
155cdf0e10cSrcweir aNames.push_back( *pNames->GetObject( j ) );
156cdf0e10cSrcweir }
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
159cdf0e10cSrcweir // copy the families + names into the sequence types
160cdf0e10cSrcweir DBG_ASSERT( aFamilies.size() == aNames.size(), "families != names" );
161cdf0e10cSrcweir
162cdf0e10cSrcweir rFamilies.realloc( aFamilies.size() );
163cdf0e10cSrcweir std::copy( aFamilies.begin(), aFamilies.end(), rFamilies.getArray() );
164cdf0e10cSrcweir
165cdf0e10cSrcweir rNames.realloc( aNames.size() );
166cdf0e10cSrcweir std::copy( aNames.begin(), aNames.end(), rNames.getArray() );
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
169cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////////
170cdf0e10cSrcweir //
171cdf0e10cSrcweir // Adds a array of XMLPropertyState ( vector< XMLPropertyState > ) to list
172cdf0e10cSrcweir // if not added, yet.
173cdf0e10cSrcweir //
174cdf0e10cSrcweir
175cdf0e10cSrcweir /*OUString SvXMLAutoStylePoolP_Impl::Add( sal_Int32 nFamily,
176cdf0e10cSrcweir const OUString& rParent,
177cdf0e10cSrcweir const vector< XMLPropertyState >& rProperties,
178cdf0e10cSrcweir sal_Bool bCache )*/
Add(OUString & rName,sal_Int32 nFamily,const OUString & rParent,const::std::vector<XMLPropertyState> & rProperties,sal_Bool bCache,bool bDontSeek)179cdf0e10cSrcweir sal_Bool SvXMLAutoStylePoolP_Impl::Add(OUString& rName, sal_Int32 nFamily,
180cdf0e10cSrcweir const OUString& rParent,
181cdf0e10cSrcweir const ::std::vector< XMLPropertyState >& rProperties,
182cdf0e10cSrcweir sal_Bool bCache,
183cdf0e10cSrcweir bool bDontSeek )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir sal_Bool bRet(sal_False);
186cdf0e10cSrcweir sal_uLong nPos;
187cdf0e10cSrcweir
188cdf0e10cSrcweir XMLFamilyData_Impl *pFamily = 0;
189cdf0e10cSrcweir XMLFamilyData_Impl aTemporary( nFamily );
190cdf0e10cSrcweir if( maFamilyList.Seek_Entry( &aTemporary, &nPos ) )
191cdf0e10cSrcweir {
192cdf0e10cSrcweir pFamily = maFamilyList.GetObject( nPos );
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
195cdf0e10cSrcweir DBG_ASSERT( pFamily, "SvXMLAutoStylePool_Impl::Add: unknown family" );
196cdf0e10cSrcweir if( pFamily )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir SvXMLAutoStylePoolParentP_Impl aTmp( rParent );
199cdf0e10cSrcweir SvXMLAutoStylePoolParentP_Impl *pParent = 0;
200cdf0e10cSrcweir
201cdf0e10cSrcweir SvXMLAutoStylePoolParentsP_Impl *pParents = pFamily->mpParentList;
202cdf0e10cSrcweir if( pParents->Seek_Entry( &aTmp, &nPos ) )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir pParent = pParents->GetObject( nPos );
205cdf0e10cSrcweir }
206cdf0e10cSrcweir else
207cdf0e10cSrcweir {
208cdf0e10cSrcweir pParent = new SvXMLAutoStylePoolParentP_Impl( rParent );
209cdf0e10cSrcweir pParents->Insert( pParent );
210cdf0e10cSrcweir }
211cdf0e10cSrcweir
212cdf0e10cSrcweir if( pParent->Add( pFamily, rProperties, rName, bDontSeek ) )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir pFamily->mnCount++;
215cdf0e10cSrcweir bRet = sal_True;
216cdf0e10cSrcweir }
217cdf0e10cSrcweir
218cdf0e10cSrcweir if( bCache )
219cdf0e10cSrcweir {
220cdf0e10cSrcweir if( !pFamily->pCache )
221cdf0e10cSrcweir pFamily->pCache = new SvXMLAutoStylePoolCache_Impl( 256, 256 );
222cdf0e10cSrcweir if( pFamily->pCache->Count() < MAX_CACHE_SIZE )
223cdf0e10cSrcweir pFamily->pCache->Insert( new OUString( rName ),
224cdf0e10cSrcweir pFamily->pCache->Count() );
225cdf0e10cSrcweir }
226cdf0e10cSrcweir }
227cdf0e10cSrcweir
228cdf0e10cSrcweir return bRet;
229cdf0e10cSrcweir }
230cdf0e10cSrcweir
AddNamed(const OUString & rName,sal_Int32 nFamily,const OUString & rParent,const::std::vector<XMLPropertyState> & rProperties)231cdf0e10cSrcweir sal_Bool SvXMLAutoStylePoolP_Impl::AddNamed(const OUString& rName, sal_Int32 nFamily,
232cdf0e10cSrcweir const OUString& rParent, const ::std::vector< XMLPropertyState >& rProperties )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir // get family and parent the same way as in Add()
235cdf0e10cSrcweir sal_Bool bRet(sal_False);
236cdf0e10cSrcweir sal_uLong nPos;
237cdf0e10cSrcweir
238cdf0e10cSrcweir XMLFamilyData_Impl *pFamily = 0;
239cdf0e10cSrcweir XMLFamilyData_Impl aTemporary( nFamily );
240cdf0e10cSrcweir if( maFamilyList.Seek_Entry( &aTemporary, &nPos ) )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir pFamily = maFamilyList.GetObject( nPos );
243cdf0e10cSrcweir }
244cdf0e10cSrcweir
245cdf0e10cSrcweir DBG_ASSERT( pFamily, "SvXMLAutoStylePool_Impl::Add: unknown family" );
246cdf0e10cSrcweir if( pFamily )
247cdf0e10cSrcweir {
248cdf0e10cSrcweir SvXMLAutoStylePoolParentP_Impl aTmp( rParent );
249cdf0e10cSrcweir SvXMLAutoStylePoolParentP_Impl *pParent = 0;
250cdf0e10cSrcweir
251cdf0e10cSrcweir SvXMLAutoStylePoolParentsP_Impl *pParents = pFamily->mpParentList;
252cdf0e10cSrcweir if( pParents->Seek_Entry( &aTmp, &nPos ) )
253cdf0e10cSrcweir {
254cdf0e10cSrcweir pParent = pParents->GetObject( nPos );
255cdf0e10cSrcweir }
256cdf0e10cSrcweir else
257cdf0e10cSrcweir {
258cdf0e10cSrcweir pParent = new SvXMLAutoStylePoolParentP_Impl( rParent );
259cdf0e10cSrcweir pParents->Insert( pParent );
260cdf0e10cSrcweir }
261cdf0e10cSrcweir
262cdf0e10cSrcweir if( pParent->AddNamed( pFamily, rProperties, rName ) )
263cdf0e10cSrcweir {
264cdf0e10cSrcweir pFamily->mnCount++;
265cdf0e10cSrcweir bRet = sal_True;
266cdf0e10cSrcweir }
267cdf0e10cSrcweir }
268cdf0e10cSrcweir
269cdf0e10cSrcweir return bRet;
270cdf0e10cSrcweir }
271cdf0e10cSrcweir
AddToCache(sal_Int32 nFamily,const OUString & rParent)272cdf0e10cSrcweir OUString SvXMLAutoStylePoolP_Impl::AddToCache( sal_Int32 nFamily,
273cdf0e10cSrcweir const OUString& rParent )
274cdf0e10cSrcweir {
275cdf0e10cSrcweir sal_uLong nPos;
276cdf0e10cSrcweir
277cdf0e10cSrcweir XMLFamilyData_Impl *pFamily = 0;
278cdf0e10cSrcweir XMLFamilyData_Impl aTmp( nFamily );
279cdf0e10cSrcweir if( maFamilyList.Seek_Entry( &aTmp, &nPos ) )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir pFamily = maFamilyList.GetObject( nPos );
282cdf0e10cSrcweir }
283cdf0e10cSrcweir
284cdf0e10cSrcweir DBG_ASSERT( pFamily, "SvXMLAutoStylePool_Impl::Add: unknown family" );
285cdf0e10cSrcweir if( pFamily )
286cdf0e10cSrcweir {
287cdf0e10cSrcweir if( !pFamily->pCache )
288cdf0e10cSrcweir pFamily->pCache = new SvXMLAutoStylePoolCache_Impl( 256, 256 );
289cdf0e10cSrcweir if( pFamily->pCache->Count() < MAX_CACHE_SIZE )
290cdf0e10cSrcweir pFamily->pCache->Insert( new OUString( rParent ),
291cdf0e10cSrcweir pFamily->pCache->Count() );
292cdf0e10cSrcweir }
293cdf0e10cSrcweir
294cdf0e10cSrcweir return rParent;
295cdf0e10cSrcweir }
296cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////////
297cdf0e10cSrcweir //
298cdf0e10cSrcweir // Search for a array of XMLPropertyState ( vector< XMLPropertyState > ) in list
299cdf0e10cSrcweir //
300cdf0e10cSrcweir
Find(sal_Int32 nFamily,const OUString & rParent,const vector<XMLPropertyState> & rProperties) const301cdf0e10cSrcweir OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily,
302cdf0e10cSrcweir const OUString& rParent,
303cdf0e10cSrcweir const vector< XMLPropertyState >& rProperties ) const
304cdf0e10cSrcweir {
305cdf0e10cSrcweir OUString sName;
306cdf0e10cSrcweir
307cdf0e10cSrcweir sal_uLong nPos;
308cdf0e10cSrcweir XMLFamilyData_Impl aTemporary( nFamily );
309cdf0e10cSrcweir XMLFamilyData_Impl *pFamily = 0;
310cdf0e10cSrcweir if( maFamilyList.Seek_Entry( &aTemporary, &nPos ) )
311cdf0e10cSrcweir {
312cdf0e10cSrcweir pFamily = maFamilyList.GetObject( nPos );
313cdf0e10cSrcweir }
314cdf0e10cSrcweir
315cdf0e10cSrcweir DBG_ASSERT( pFamily, "SvXMLAutoStylePool_Impl::Find: unknown family" );
316cdf0e10cSrcweir
317cdf0e10cSrcweir if( pFamily )
318cdf0e10cSrcweir {
319cdf0e10cSrcweir SvXMLAutoStylePoolParentP_Impl aTmp( rParent );
320cdf0e10cSrcweir
321cdf0e10cSrcweir const SvXMLAutoStylePoolParentsP_Impl* pParents =
322cdf0e10cSrcweir pFamily->mpParentList;
323cdf0e10cSrcweir if( pParents->Seek_Entry( &aTmp, &nPos ) )
324cdf0e10cSrcweir sName = pParents->GetObject( nPos )->Find( pFamily, rProperties );
325cdf0e10cSrcweir }
326cdf0e10cSrcweir
327cdf0e10cSrcweir return sName;
328cdf0e10cSrcweir }
329cdf0e10cSrcweir
FindAndRemoveCached(sal_Int32 nFamily) const330cdf0e10cSrcweir OUString SvXMLAutoStylePoolP_Impl::FindAndRemoveCached( sal_Int32 nFamily ) const
331cdf0e10cSrcweir {
332cdf0e10cSrcweir OUString sName;
333cdf0e10cSrcweir
334cdf0e10cSrcweir sal_uLong nPos;
335cdf0e10cSrcweir XMLFamilyData_Impl aTmp( nFamily );
336cdf0e10cSrcweir XMLFamilyData_Impl *pFamily = 0;
337cdf0e10cSrcweir if( maFamilyList.Seek_Entry( &aTmp, &nPos ) )
338cdf0e10cSrcweir {
339cdf0e10cSrcweir pFamily = maFamilyList.GetObject( nPos );
340cdf0e10cSrcweir }
341cdf0e10cSrcweir
342cdf0e10cSrcweir DBG_ASSERT( pFamily, "SvXMLAutoStylePool_Impl::Find: unknown family" );
343cdf0e10cSrcweir
344cdf0e10cSrcweir if( pFamily )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir DBG_ASSERT( pFamily->pCache, "family doesn't have a cache" );
347cdf0e10cSrcweir
348cdf0e10cSrcweir // The cache may be empty already. This happens if it was filled
349cdf0e10cSrcweir // completly.
350cdf0e10cSrcweir if( pFamily->pCache && pFamily->pCache->Count() )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir OUString *pName = pFamily->pCache->Remove( 0UL );
353cdf0e10cSrcweir sName = *pName;
354cdf0e10cSrcweir delete pName;
355cdf0e10cSrcweir }
356cdf0e10cSrcweir }
357cdf0e10cSrcweir
358cdf0e10cSrcweir return sName;
359cdf0e10cSrcweir }
360cdf0e10cSrcweir
361cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////////
362cdf0e10cSrcweir //
363cdf0e10cSrcweir // export
364cdf0e10cSrcweir //
365cdf0e10cSrcweir
exportXML(sal_Int32 nFamily,const uno::Reference<::com::sun::star::xml::sax::XDocumentHandler> &,const SvXMLUnitConverter &,const SvXMLNamespaceMap &,const SvXMLAutoStylePoolP * pAntiImpl) const366cdf0e10cSrcweir void SvXMLAutoStylePoolP_Impl::exportXML(
367cdf0e10cSrcweir sal_Int32 nFamily,
368cdf0e10cSrcweir const uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > &,
369cdf0e10cSrcweir const SvXMLUnitConverter&,
370cdf0e10cSrcweir const SvXMLNamespaceMap&,
371cdf0e10cSrcweir const SvXMLAutoStylePoolP *pAntiImpl) const
372cdf0e10cSrcweir {
373cdf0e10cSrcweir sal_uInt32 nCount = 0;
374cdf0e10cSrcweir
375cdf0e10cSrcweir // Get list of parents for current family (nFamily)
376cdf0e10cSrcweir sal_uLong nPos;
377cdf0e10cSrcweir XMLFamilyData_Impl aTmp( nFamily );
378cdf0e10cSrcweir XMLFamilyData_Impl *pFamily = 0;
379cdf0e10cSrcweir if( maFamilyList.Seek_Entry( &aTmp, &nPos ) )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir pFamily = maFamilyList.GetObject( nPos );
382cdf0e10cSrcweir nCount = pFamily->mnCount;
383cdf0e10cSrcweir }
384cdf0e10cSrcweir
385cdf0e10cSrcweir DBG_ASSERT( pFamily,
386cdf0e10cSrcweir "SvXMLAutoStylePool_Impl::exportXML: unknown family" );
387cdf0e10cSrcweir if( pFamily && nCount > 0 )
388cdf0e10cSrcweir {
389cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////////////
390cdf0e10cSrcweir // create, initialize and fill helper-structure (SvXMLAutoStylePoolProperties_Impl)
391cdf0e10cSrcweir // wich contains a parent-name and a SvXMLAutoStylePoolProperties_Impl
392cdf0e10cSrcweir //
393cdf0e10cSrcweir const SvXMLAutoStylePoolParentsP_Impl *pParents =
394cdf0e10cSrcweir pFamily->mpParentList;
395cdf0e10cSrcweir
396cdf0e10cSrcweir SvXMLAutoStylePoolPExport_Impl* aExpStyles =
397cdf0e10cSrcweir new SvXMLAutoStylePoolPExport_Impl[nCount];
398cdf0e10cSrcweir
399cdf0e10cSrcweir sal_uInt32 i;
400cdf0e10cSrcweir for( i=0; i < nCount; i++ )
401cdf0e10cSrcweir {
402cdf0e10cSrcweir aExpStyles[i].mpParent = 0;
403cdf0e10cSrcweir aExpStyles[i].mpProperties = 0;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
406cdf0e10cSrcweir sal_uInt32 nParents = pParents->Count();
407cdf0e10cSrcweir for( i=0; i < nParents; i++ )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir const SvXMLAutoStylePoolParentP_Impl* pParent =
410cdf0e10cSrcweir pParents->GetObject( i );
411cdf0e10cSrcweir sal_uInt32 nProperties = pParent->GetPropertiesList().Count();
412cdf0e10cSrcweir for( sal_uInt32 j=0; j < nProperties; j++ )
413cdf0e10cSrcweir {
414cdf0e10cSrcweir const SvXMLAutoStylePoolPropertiesP_Impl *pProperties =
415cdf0e10cSrcweir pParent->GetPropertiesList().GetObject( j );
416cdf0e10cSrcweir nPos = pProperties->GetPos();
417cdf0e10cSrcweir DBG_ASSERT( nPos < nCount,
418cdf0e10cSrcweir "SvXMLAutoStylePool_Impl::exportXML: wrong position" );
419cdf0e10cSrcweir if( nPos < nCount )
420cdf0e10cSrcweir {
421cdf0e10cSrcweir DBG_ASSERT( !aExpStyles[nPos].mpProperties,
422cdf0e10cSrcweir "SvXMLAutoStylePool_Impl::exportXML: double position" );
423cdf0e10cSrcweir aExpStyles[nPos].mpProperties = pProperties;
424cdf0e10cSrcweir aExpStyles[nPos].mpParent = &pParent->GetParent();
425cdf0e10cSrcweir }
426cdf0e10cSrcweir }
427cdf0e10cSrcweir }
428cdf0e10cSrcweir
429cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////////////
430cdf0e10cSrcweir //
431cdf0e10cSrcweir // create string to export for each XML-style. That means for each property-list
432cdf0e10cSrcweir //
433cdf0e10cSrcweir OUString aStrFamilyName = pFamily->maStrFamilyName;
434cdf0e10cSrcweir
435cdf0e10cSrcweir for( i=0; i<nCount; i++ )
436cdf0e10cSrcweir {
437cdf0e10cSrcweir DBG_ASSERT( aExpStyles[i].mpProperties,
438cdf0e10cSrcweir "SvXMLAutoStylePool_Impl::exportXML: empty position" );
439cdf0e10cSrcweir
440cdf0e10cSrcweir if( aExpStyles[i].mpProperties )
441cdf0e10cSrcweir {
442cdf0e10cSrcweir GetExport().AddAttribute(
443cdf0e10cSrcweir XML_NAMESPACE_STYLE, XML_NAME,
444cdf0e10cSrcweir aExpStyles[i].mpProperties->GetName() );
445cdf0e10cSrcweir
446cdf0e10cSrcweir if( pFamily->bAsFamily )
447cdf0e10cSrcweir {
448cdf0e10cSrcweir GetExport().AddAttribute(
449cdf0e10cSrcweir XML_NAMESPACE_STYLE, XML_FAMILY, aStrFamilyName );
450cdf0e10cSrcweir }
451cdf0e10cSrcweir
452cdf0e10cSrcweir if( aExpStyles[i].mpParent->getLength() )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir GetExport().AddAttribute(
455cdf0e10cSrcweir XML_NAMESPACE_STYLE, XML_PARENT_STYLE_NAME,
456cdf0e10cSrcweir GetExport().EncodeStyleName(
457cdf0e10cSrcweir *aExpStyles[i].mpParent ) );
458cdf0e10cSrcweir }
459cdf0e10cSrcweir
460cdf0e10cSrcweir OUString sName;
461cdf0e10cSrcweir if( pFamily->bAsFamily )
462cdf0e10cSrcweir sName = GetXMLToken(XML_STYLE);
463cdf0e10cSrcweir else
464cdf0e10cSrcweir sName = pFamily->maStrFamilyName;
465cdf0e10cSrcweir
466cdf0e10cSrcweir pAntiImpl->exportStyleAttributes(
467cdf0e10cSrcweir GetExport().GetAttrList(),
468cdf0e10cSrcweir nFamily,
469cdf0e10cSrcweir aExpStyles[i].mpProperties->GetProperties(),
470cdf0e10cSrcweir *pFamily->mxMapper.get()
471cdf0e10cSrcweir , GetExport().GetMM100UnitConverter(),
472cdf0e10cSrcweir GetExport().GetNamespaceMap()
473cdf0e10cSrcweir );
474cdf0e10cSrcweir
475cdf0e10cSrcweir SvXMLElementExport aElem( GetExport(),
476cdf0e10cSrcweir XML_NAMESPACE_STYLE, sName,
477cdf0e10cSrcweir sal_True, sal_True );
478cdf0e10cSrcweir
479cdf0e10cSrcweir sal_Int32 nStart(-1);
480cdf0e10cSrcweir sal_Int32 nEnd(-1);
481cdf0e10cSrcweir if (nFamily == XML_STYLE_FAMILY_PAGE_MASTER)
482cdf0e10cSrcweir {
483cdf0e10cSrcweir nStart = 0;
484cdf0e10cSrcweir sal_Int32 nIndex = 0;
485cdf0e10cSrcweir UniReference< XMLPropertySetMapper > aPropMapper =
486cdf0e10cSrcweir pFamily->mxMapper->getPropertySetMapper();
487cdf0e10cSrcweir sal_Int16 nContextID;
488cdf0e10cSrcweir while(nIndex < aPropMapper->GetEntryCount() && nEnd == -1)
489cdf0e10cSrcweir {
490cdf0e10cSrcweir nContextID = aPropMapper->GetEntryContextId( nIndex );
491cdf0e10cSrcweir if (nContextID && ((nContextID & CTF_PM_FLAGMASK) != XML_PM_CTF_START))
492cdf0e10cSrcweir nEnd = nIndex;
493cdf0e10cSrcweir nIndex++;
494cdf0e10cSrcweir }
495cdf0e10cSrcweir if (nEnd == -1)
496cdf0e10cSrcweir nEnd = nIndex;
497cdf0e10cSrcweir }
498cdf0e10cSrcweir
499cdf0e10cSrcweir pFamily->mxMapper->exportXML(
500cdf0e10cSrcweir GetExport(),
501cdf0e10cSrcweir aExpStyles[i].mpProperties->GetProperties(),
502cdf0e10cSrcweir nStart, nEnd, XML_EXPORT_FLAG_IGN_WS );
503cdf0e10cSrcweir
504cdf0e10cSrcweir pAntiImpl->exportStyleContent(
505cdf0e10cSrcweir GetExport().GetDocHandler(),
506cdf0e10cSrcweir nFamily,
507cdf0e10cSrcweir aExpStyles[i].mpProperties->GetProperties(),
508cdf0e10cSrcweir *pFamily->mxMapper.get(),
509cdf0e10cSrcweir GetExport().GetMM100UnitConverter(),
510cdf0e10cSrcweir GetExport().GetNamespaceMap()
511cdf0e10cSrcweir );
512cdf0e10cSrcweir }
513cdf0e10cSrcweir }
514cdf0e10cSrcweir
515cdf0e10cSrcweir delete[] aExpStyles;
516cdf0e10cSrcweir }
517cdf0e10cSrcweir }
518cdf0e10cSrcweir
ClearEntries()519cdf0e10cSrcweir void SvXMLAutoStylePoolP_Impl::ClearEntries()
520cdf0e10cSrcweir {
521cdf0e10cSrcweir for(sal_uInt32 a = 0L; a < maFamilyList.Count(); a++)
522cdf0e10cSrcweir maFamilyList[a]->ClearEntries();
523cdf0e10cSrcweir }
524