xref: /trunk/main/xmloff/source/style/impastp1.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmloff.hxx"
30 #include <tools/debug.hxx>
31 #include "impastpl.hxx"
32 
33 using namespace rtl;
34 
35 //#############################################################################
36 //
37 // Class XMLFamilyData_Impl
38 //
39 
40 ///////////////////////////////////////////////////////////////////////////////
41 //
42 // ctor/dtor class XMLFamilyData_Impl
43 //
44 
45 XMLFamilyData_Impl::XMLFamilyData_Impl(
46         sal_Int32 nFamily,
47         const ::rtl::OUString& rStrName,
48         const UniReference < SvXMLExportPropertyMapper > &rMapper,
49         const OUString& rStrPrefix,
50         sal_Bool bAsFam )
51     : pCache( 0 ), mnFamily( nFamily ), maStrFamilyName( rStrName), mxMapper( rMapper ),
52       mnCount( 0 ), mnName( 0 ), maStrPrefix( rStrPrefix ), bAsFamily( bAsFam )
53 
54 {
55     mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 );
56     mpNameList   = new SvXMLAutoStylePoolNamesP_Impl( 5, 5 );
57 }
58 
59 XMLFamilyData_Impl::~XMLFamilyData_Impl()
60 {
61     if( mpParentList ) delete mpParentList;
62     if( mpNameList ) delete mpNameList;
63     DBG_ASSERT( !pCache || !pCache->Count(),
64                 "auto style pool cache is not empty!" );
65     if( pCache )
66     {
67         while( pCache->Count() )
68             delete pCache->Remove( 0UL );
69     }
70 }
71 
72 void XMLFamilyData_Impl::ClearEntries()
73 {
74     if( mpParentList )
75         delete mpParentList;
76     mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 );
77     DBG_ASSERT( !pCache || !pCache->Count(),
78                 "auto style pool cache is not empty!" );
79     if( pCache )
80     {
81         while( pCache->Count() )
82             delete pCache->Remove( 0UL );
83     }
84 }
85 
86 ///////////////////////////////////////////////////////////////////////////////
87 //
88 // friendfunction of class XMLFamilyData_Impl for sorting listelements
89 //
90 
91 int XMLFamilyDataSort_Impl( const XMLFamilyData_Impl& r1, const XMLFamilyData_Impl& r2 )
92 {
93     int nRet = 0;
94 
95     if( r1.mnFamily != r2.mnFamily )
96         nRet = ( r1.mnFamily > r2.mnFamily ? 1 : -1 );
97 
98     return nRet;
99 }
100 
101 ///////////////////////////////////////////////////////////////////////////////
102 //
103 // Implementation of sorted list of XMLFamilyData_Impl - elements
104 //
105 
106 IMPL_CONTAINER_SORT( XMLFamilyDataList_Impl, XMLFamilyData_Impl, XMLFamilyDataSort_Impl )
107 
108 //#############################################################################
109 //
110 // Sorted list of OUString - elements
111 //
112 
113 ///////////////////////////////////////////////////////////////////////////////
114 //
115 // Sort-function for OUString-list
116 //
117 
118 int SvXMLAutoStylePoolNamesPCmp_Impl( const OUString& r1,
119                                      const OUString& r2 )
120 {
121     return (int)r1.compareTo( r2 );
122 }
123 
124 ///////////////////////////////////////////////////////////////////////////////
125 //
126 // Implementation of sorted OUString-list
127 //
128 
129 IMPL_CONTAINER_SORT( SvXMLAutoStylePoolNamesP_Impl,
130                      OUString,
131                      SvXMLAutoStylePoolNamesPCmp_Impl )
132 
133