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