xref: /aoo4110/main/xmloff/source/style/impastp1.cxx (revision b1cdbd2c)
1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski  *
3*b1cdbd2cSJim Jagielski  * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski  * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski  * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski  * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski  * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski  * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski  * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski  *
11*b1cdbd2cSJim Jagielski  *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski  *
13*b1cdbd2cSJim Jagielski  * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski  * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski  * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski  * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski  * under the License.
19*b1cdbd2cSJim Jagielski  *
20*b1cdbd2cSJim Jagielski  *************************************************************/
21*b1cdbd2cSJim Jagielski 
22*b1cdbd2cSJim Jagielski 
23*b1cdbd2cSJim Jagielski 
24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove
25*b1cdbd2cSJim Jagielski #include "precompiled_xmloff.hxx"
26*b1cdbd2cSJim Jagielski #include <tools/debug.hxx>
27*b1cdbd2cSJim Jagielski #include "impastpl.hxx"
28*b1cdbd2cSJim Jagielski 
29*b1cdbd2cSJim Jagielski using namespace rtl;
30*b1cdbd2cSJim Jagielski 
31*b1cdbd2cSJim Jagielski //#############################################################################
32*b1cdbd2cSJim Jagielski //
33*b1cdbd2cSJim Jagielski // Class XMLFamilyData_Impl
34*b1cdbd2cSJim Jagielski //
35*b1cdbd2cSJim Jagielski 
36*b1cdbd2cSJim Jagielski ///////////////////////////////////////////////////////////////////////////////
37*b1cdbd2cSJim Jagielski //
38*b1cdbd2cSJim Jagielski // ctor/dtor class XMLFamilyData_Impl
39*b1cdbd2cSJim Jagielski //
40*b1cdbd2cSJim Jagielski 
XMLFamilyData_Impl(sal_Int32 nFamily,const::rtl::OUString & rStrName,const UniReference<SvXMLExportPropertyMapper> & rMapper,const OUString & rStrPrefix,sal_Bool bAsFam)41*b1cdbd2cSJim Jagielski XMLFamilyData_Impl::XMLFamilyData_Impl(
42*b1cdbd2cSJim Jagielski 		sal_Int32 nFamily,
43*b1cdbd2cSJim Jagielski 		const ::rtl::OUString& rStrName,
44*b1cdbd2cSJim Jagielski 		const UniReference < SvXMLExportPropertyMapper > &rMapper,
45*b1cdbd2cSJim Jagielski 		const OUString& rStrPrefix,
46*b1cdbd2cSJim Jagielski 		sal_Bool bAsFam )
47*b1cdbd2cSJim Jagielski 	: pCache( 0 ), mnFamily( nFamily ), maStrFamilyName( rStrName), mxMapper( rMapper ),
48*b1cdbd2cSJim Jagielski 	  mnCount( 0 ), mnName( 0 ), maStrPrefix( rStrPrefix ), bAsFamily( bAsFam )
49*b1cdbd2cSJim Jagielski 
50*b1cdbd2cSJim Jagielski {
51*b1cdbd2cSJim Jagielski 	mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 );
52*b1cdbd2cSJim Jagielski 	mpNameList   = new SvXMLAutoStylePoolNamesP_Impl( 5, 5 );
53*b1cdbd2cSJim Jagielski }
54*b1cdbd2cSJim Jagielski 
~XMLFamilyData_Impl()55*b1cdbd2cSJim Jagielski XMLFamilyData_Impl::~XMLFamilyData_Impl()
56*b1cdbd2cSJim Jagielski {
57*b1cdbd2cSJim Jagielski 	if( mpParentList ) delete mpParentList;
58*b1cdbd2cSJim Jagielski 	if( mpNameList ) delete mpNameList;
59*b1cdbd2cSJim Jagielski 	DBG_ASSERT( !pCache || !pCache->Count(),
60*b1cdbd2cSJim Jagielski 				"auto style pool cache is not empty!" );
61*b1cdbd2cSJim Jagielski 	if( pCache )
62*b1cdbd2cSJim Jagielski 	{
63*b1cdbd2cSJim Jagielski 		while( pCache->Count() )
64*b1cdbd2cSJim Jagielski 			delete pCache->Remove( 0UL );
65*b1cdbd2cSJim Jagielski 	}
66*b1cdbd2cSJim Jagielski }
67*b1cdbd2cSJim Jagielski 
ClearEntries()68*b1cdbd2cSJim Jagielski void XMLFamilyData_Impl::ClearEntries()
69*b1cdbd2cSJim Jagielski {
70*b1cdbd2cSJim Jagielski 	if( mpParentList )
71*b1cdbd2cSJim Jagielski 		delete mpParentList;
72*b1cdbd2cSJim Jagielski 	mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 );
73*b1cdbd2cSJim Jagielski 	DBG_ASSERT( !pCache || !pCache->Count(),
74*b1cdbd2cSJim Jagielski 				"auto style pool cache is not empty!" );
75*b1cdbd2cSJim Jagielski 	if( pCache )
76*b1cdbd2cSJim Jagielski 	{
77*b1cdbd2cSJim Jagielski 		while( pCache->Count() )
78*b1cdbd2cSJim Jagielski 			delete pCache->Remove( 0UL );
79*b1cdbd2cSJim Jagielski 	}
80*b1cdbd2cSJim Jagielski }
81*b1cdbd2cSJim Jagielski 
82*b1cdbd2cSJim Jagielski ///////////////////////////////////////////////////////////////////////////////
83*b1cdbd2cSJim Jagielski //
84*b1cdbd2cSJim Jagielski // friendfunction of class XMLFamilyData_Impl for sorting listelements
85*b1cdbd2cSJim Jagielski //
86*b1cdbd2cSJim Jagielski 
XMLFamilyDataSort_Impl(const XMLFamilyData_Impl & r1,const XMLFamilyData_Impl & r2)87*b1cdbd2cSJim Jagielski int XMLFamilyDataSort_Impl( const XMLFamilyData_Impl& r1, const XMLFamilyData_Impl& r2 )
88*b1cdbd2cSJim Jagielski {
89*b1cdbd2cSJim Jagielski 	int nRet = 0;
90*b1cdbd2cSJim Jagielski 
91*b1cdbd2cSJim Jagielski 	if( r1.mnFamily != r2.mnFamily )
92*b1cdbd2cSJim Jagielski 		nRet = ( r1.mnFamily > r2.mnFamily ? 1 : -1 );
93*b1cdbd2cSJim Jagielski 
94*b1cdbd2cSJim Jagielski 	return nRet;
95*b1cdbd2cSJim Jagielski }
96*b1cdbd2cSJim Jagielski 
97*b1cdbd2cSJim Jagielski ///////////////////////////////////////////////////////////////////////////////
98*b1cdbd2cSJim Jagielski //
99*b1cdbd2cSJim Jagielski // Implementation of sorted list of XMLFamilyData_Impl - elements
100*b1cdbd2cSJim Jagielski //
101*b1cdbd2cSJim Jagielski 
IMPL_CONTAINER_SORT(XMLFamilyDataList_Impl,XMLFamilyData_Impl,XMLFamilyDataSort_Impl)102*b1cdbd2cSJim Jagielski IMPL_CONTAINER_SORT( XMLFamilyDataList_Impl, XMLFamilyData_Impl, XMLFamilyDataSort_Impl )
103*b1cdbd2cSJim Jagielski 
104*b1cdbd2cSJim Jagielski //#############################################################################
105*b1cdbd2cSJim Jagielski //
106*b1cdbd2cSJim Jagielski // Sorted list of OUString - elements
107*b1cdbd2cSJim Jagielski //
108*b1cdbd2cSJim Jagielski 
109*b1cdbd2cSJim Jagielski ///////////////////////////////////////////////////////////////////////////////
110*b1cdbd2cSJim Jagielski //
111*b1cdbd2cSJim Jagielski // Sort-function for OUString-list
112*b1cdbd2cSJim Jagielski //
113*b1cdbd2cSJim Jagielski 
114*b1cdbd2cSJim Jagielski int SvXMLAutoStylePoolNamesPCmp_Impl( const OUString& r1,
115*b1cdbd2cSJim Jagielski 									 const OUString& r2 )
116*b1cdbd2cSJim Jagielski {
117*b1cdbd2cSJim Jagielski 	return (int)r1.compareTo( r2 );
118*b1cdbd2cSJim Jagielski }
119*b1cdbd2cSJim Jagielski 
120*b1cdbd2cSJim Jagielski ///////////////////////////////////////////////////////////////////////////////
121*b1cdbd2cSJim Jagielski //
122*b1cdbd2cSJim Jagielski // Implementation of sorted OUString-list
123*b1cdbd2cSJim Jagielski //
124*b1cdbd2cSJim Jagielski 
125*b1cdbd2cSJim Jagielski IMPL_CONTAINER_SORT( SvXMLAutoStylePoolNamesP_Impl,
126*b1cdbd2cSJim Jagielski 					 OUString,
127*b1cdbd2cSJim Jagielski 				     SvXMLAutoStylePoolNamesPCmp_Impl )
128*b1cdbd2cSJim Jagielski 
129