1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _XMLOFF_XMLASTPL_IMPL_HXX 29*cdf0e10cSrcweir #define _XMLOFF_XMLASTPL_IMPL_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <sal/types.h> 32*cdf0e10cSrcweir #include <tools/list.hxx> 33*cdf0e10cSrcweir #include <svl/cntnrsrt.hxx> 34*cdf0e10cSrcweir #include <rtl/ustring.hxx> 35*cdf0e10cSrcweir #include <vector> 36*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 37*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 39*cdf0e10cSrcweir #include <xmloff/maptype.hxx> 40*cdf0e10cSrcweir #include <xmloff/xmlexppr.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir class SvXMLAutoStylePoolP; 43*cdf0e10cSrcweir class SvXMLAutoStylePoolParentsP_Impl; 44*cdf0e10cSrcweir class SvXMLAutoStylePoolNamesP_Impl; 45*cdf0e10cSrcweir class SvXMLAttributeList; 46*cdf0e10cSrcweir class SvXMLExportPropertyMapper; 47*cdf0e10cSrcweir class SvXMLExport; 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #define MAX_CACHE_SIZE 65536 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////// 52*cdf0e10cSrcweir // 53*cdf0e10cSrcweir // Implementationclass for stylefamily-information 54*cdf0e10cSrcweir // 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir typedef ::rtl::OUString *OUStringPtr; 57*cdf0e10cSrcweir DECLARE_LIST( SvXMLAutoStylePoolCache_Impl, OUStringPtr ) 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir class XMLFamilyData_Impl 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir public: 62*cdf0e10cSrcweir SvXMLAutoStylePoolCache_Impl *pCache; 63*cdf0e10cSrcweir sal_uInt32 mnFamily; 64*cdf0e10cSrcweir ::rtl::OUString maStrFamilyName; 65*cdf0e10cSrcweir UniReference < SvXMLExportPropertyMapper > mxMapper; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir SvXMLAutoStylePoolParentsP_Impl* mpParentList; 68*cdf0e10cSrcweir SvXMLAutoStylePoolNamesP_Impl* mpNameList; 69*cdf0e10cSrcweir sal_uInt32 mnCount; 70*cdf0e10cSrcweir sal_uInt32 mnName; 71*cdf0e10cSrcweir ::rtl::OUString maStrPrefix; 72*cdf0e10cSrcweir sal_Bool bAsFamily; 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir public: 75*cdf0e10cSrcweir XMLFamilyData_Impl( sal_Int32 nFamily, const ::rtl::OUString& rStrName, 76*cdf0e10cSrcweir const UniReference < SvXMLExportPropertyMapper > & rMapper, 77*cdf0e10cSrcweir const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True ); 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir XMLFamilyData_Impl( sal_Int32 nFamily ) : 80*cdf0e10cSrcweir pCache( 0 ), 81*cdf0e10cSrcweir mnFamily( nFamily ), mpParentList( NULL ), 82*cdf0e10cSrcweir mpNameList( NULL ), mnCount( 0 ), mnName( 0 ) 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir {} 85*cdf0e10cSrcweir ~XMLFamilyData_Impl(); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir friend int XMLFamilyDataSort_Impl( const XMLFamilyData_Impl& r1, const XMLFamilyData_Impl& r2 ); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir void ClearEntries(); 90*cdf0e10cSrcweir }; 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir DECLARE_CONTAINER_SORT( XMLFamilyDataList_Impl, XMLFamilyData_Impl ) 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////// 95*cdf0e10cSrcweir // 96*cdf0e10cSrcweir // 97*cdf0e10cSrcweir // 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir DECLARE_CONTAINER_SORT_DEL( SvXMLAutoStylePoolNamesP_Impl, 100*cdf0e10cSrcweir ::rtl::OUString ) 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////// 103*cdf0e10cSrcweir // 104*cdf0e10cSrcweir // Properties of a pool 105*cdf0e10cSrcweir // 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir class SvXMLAutoStylePoolPropertiesP_Impl 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir ::rtl::OUString msName; 110*cdf0e10cSrcweir ::std::vector< XMLPropertyState > maProperties; 111*cdf0e10cSrcweir sal_uInt32 mnPos; 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir public: 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties ); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir ~SvXMLAutoStylePoolPropertiesP_Impl() 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir const ::rtl::OUString& GetName() const { return msName; } 122*cdf0e10cSrcweir const ::std::vector< XMLPropertyState >& GetProperties() const { return maProperties; } 123*cdf0e10cSrcweir sal_uInt32 GetPos() const { return mnPos; } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir void SetName( const ::rtl::OUString& rNew ) { msName = rNew; } 126*cdf0e10cSrcweir }; 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir typedef SvXMLAutoStylePoolPropertiesP_Impl *SvXMLAutoStylePoolPropertiesPPtr; 129*cdf0e10cSrcweir DECLARE_LIST( SvXMLAutoStylePoolPropertiesPList_Impl, SvXMLAutoStylePoolPropertiesPPtr ) 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////// 132*cdf0e10cSrcweir // 133*cdf0e10cSrcweir // Parents of AutoStylePool's 134*cdf0e10cSrcweir // 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir class SvXMLAutoStylePoolParentP_Impl 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir ::rtl::OUString msParent; 139*cdf0e10cSrcweir SvXMLAutoStylePoolPropertiesPList_Impl maPropertiesList; 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir public: 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir SvXMLAutoStylePoolParentP_Impl( const ::rtl::OUString & rParent ) : 144*cdf0e10cSrcweir msParent( rParent ) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir ~SvXMLAutoStylePoolParentP_Impl(); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir sal_Bool Add( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties, ::rtl::OUString& rName, bool bDontSeek = false ); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir sal_Bool AddNamed( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties, const ::rtl::OUString& rName ); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir ::rtl::OUString Find( const XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties ) const; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir const ::rtl::OUString& GetParent() const { return msParent; } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir const SvXMLAutoStylePoolPropertiesPList_Impl& GetPropertiesList() const 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir return maPropertiesList; 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir }; 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir DECLARE_CONTAINER_SORT_DEL( SvXMLAutoStylePoolParentsP_Impl, 165*cdf0e10cSrcweir SvXMLAutoStylePoolParentP_Impl ) 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////// 168*cdf0e10cSrcweir // 169*cdf0e10cSrcweir // Implementationclass of SvXMLAutoStylePool 170*cdf0e10cSrcweir // 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir class SvXMLAutoStylePoolP_Impl 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir SvXMLExport& rExport; 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir XMLFamilyDataList_Impl maFamilyList; 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir public: 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir SvXMLAutoStylePoolP_Impl( SvXMLExport& rExport ); 181*cdf0e10cSrcweir ~SvXMLAutoStylePoolP_Impl(); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir SvXMLExport& GetExport() const { return rExport; } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir void AddFamily( sal_Int32 nFamily, const ::rtl::OUString& rStrName, 186*cdf0e10cSrcweir const UniReference < SvXMLExportPropertyMapper > & rMapper, 187*cdf0e10cSrcweir const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True ); 188*cdf0e10cSrcweir void RegisterName( sal_Int32 nFamily, const ::rtl::OUString& rName ); 189*cdf0e10cSrcweir void GetRegisteredNames( 190*cdf0e10cSrcweir com::sun::star::uno::Sequence<sal_Int32>& aFamilies, 191*cdf0e10cSrcweir com::sun::star::uno::Sequence<rtl::OUString>& aNames ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir // ::rtl::OUString Add( sal_Int32 nFamily, const ::rtl::OUString& rParent, 194*cdf0e10cSrcweir // const ::std::vector< XMLPropertyState >& rProperties, 195*cdf0e10cSrcweir // sal_Bool bCache = sal_False ); 196*cdf0e10cSrcweir sal_Bool Add( ::rtl::OUString& rName, sal_Int32 nFamily, 197*cdf0e10cSrcweir const ::rtl::OUString& rParent, 198*cdf0e10cSrcweir const ::std::vector< XMLPropertyState >& rProperties, 199*cdf0e10cSrcweir sal_Bool bCache = sal_False, 200*cdf0e10cSrcweir bool bDontSeek = false ); 201*cdf0e10cSrcweir sal_Bool AddNamed( const ::rtl::OUString& rName, sal_Int32 nFamily, 202*cdf0e10cSrcweir const ::rtl::OUString& rParent, 203*cdf0e10cSrcweir const ::std::vector< XMLPropertyState >& rProperties ); 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir ::rtl::OUString AddToCache( sal_Int32 nFamily, 206*cdf0e10cSrcweir const ::rtl::OUString& rParent ); 207*cdf0e10cSrcweir ::rtl::OUString Find( sal_Int32 nFamily, const ::rtl::OUString& rParent, 208*cdf0e10cSrcweir const ::std::vector< XMLPropertyState >& rProperties ) const; 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir ::rtl::OUString FindAndRemoveCached( sal_Int32 nFamily ) const; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir void exportXML( sal_Int32 nFamily, 213*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler, 214*cdf0e10cSrcweir const SvXMLUnitConverter& rUnitConverter, 215*cdf0e10cSrcweir const SvXMLNamespaceMap& rNamespaceMap, 216*cdf0e10cSrcweir const SvXMLAutoStylePoolP *pAntiImpl) const; 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir void ClearEntries(); 219*cdf0e10cSrcweir }; 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir struct SvXMLAutoStylePoolPExport_Impl 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir const ::rtl::OUString *mpParent; 224*cdf0e10cSrcweir const SvXMLAutoStylePoolPropertiesP_Impl *mpProperties; 225*cdf0e10cSrcweir }; 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir #endif 228