1*ecfe53c5SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ecfe53c5SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ecfe53c5SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ecfe53c5SAndrew Rist * distributed with this work for additional information 6*ecfe53c5SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ecfe53c5SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ecfe53c5SAndrew Rist * "License"); you may not use this file except in compliance 9*ecfe53c5SAndrew Rist * with the License. You may obtain a copy of the License at 10*ecfe53c5SAndrew Rist * 11*ecfe53c5SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ecfe53c5SAndrew Rist * 13*ecfe53c5SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ecfe53c5SAndrew Rist * software distributed under the License is distributed on an 15*ecfe53c5SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ecfe53c5SAndrew Rist * KIND, either express or implied. See the License for the 17*ecfe53c5SAndrew Rist * specific language governing permissions and limitations 18*ecfe53c5SAndrew Rist * under the License. 19*ecfe53c5SAndrew Rist * 20*ecfe53c5SAndrew Rist *************************************************************/ 21*ecfe53c5SAndrew Rist 22*ecfe53c5SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _XMLOFF_XMLASTPL_IMPL_HXX 25cdf0e10cSrcweir #define _XMLOFF_XMLASTPL_IMPL_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <sal/types.h> 28cdf0e10cSrcweir #include <tools/list.hxx> 29cdf0e10cSrcweir #include <svl/cntnrsrt.hxx> 30cdf0e10cSrcweir #include <rtl/ustring.hxx> 31cdf0e10cSrcweir #include <vector> 32cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 33cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp> 34cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 35cdf0e10cSrcweir #include <xmloff/maptype.hxx> 36cdf0e10cSrcweir #include <xmloff/xmlexppr.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir class SvXMLAutoStylePoolP; 39cdf0e10cSrcweir class SvXMLAutoStylePoolParentsP_Impl; 40cdf0e10cSrcweir class SvXMLAutoStylePoolNamesP_Impl; 41cdf0e10cSrcweir class SvXMLAttributeList; 42cdf0e10cSrcweir class SvXMLExportPropertyMapper; 43cdf0e10cSrcweir class SvXMLExport; 44cdf0e10cSrcweir 45cdf0e10cSrcweir #define MAX_CACHE_SIZE 65536 46cdf0e10cSrcweir 47cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////// 48cdf0e10cSrcweir // 49cdf0e10cSrcweir // Implementationclass for stylefamily-information 50cdf0e10cSrcweir // 51cdf0e10cSrcweir 52cdf0e10cSrcweir typedef ::rtl::OUString *OUStringPtr; 53cdf0e10cSrcweir DECLARE_LIST( SvXMLAutoStylePoolCache_Impl, OUStringPtr ) 54cdf0e10cSrcweir 55cdf0e10cSrcweir class XMLFamilyData_Impl 56cdf0e10cSrcweir { 57cdf0e10cSrcweir public: 58cdf0e10cSrcweir SvXMLAutoStylePoolCache_Impl *pCache; 59cdf0e10cSrcweir sal_uInt32 mnFamily; 60cdf0e10cSrcweir ::rtl::OUString maStrFamilyName; 61cdf0e10cSrcweir UniReference < SvXMLExportPropertyMapper > mxMapper; 62cdf0e10cSrcweir 63cdf0e10cSrcweir SvXMLAutoStylePoolParentsP_Impl* mpParentList; 64cdf0e10cSrcweir SvXMLAutoStylePoolNamesP_Impl* mpNameList; 65cdf0e10cSrcweir sal_uInt32 mnCount; 66cdf0e10cSrcweir sal_uInt32 mnName; 67cdf0e10cSrcweir ::rtl::OUString maStrPrefix; 68cdf0e10cSrcweir sal_Bool bAsFamily; 69cdf0e10cSrcweir 70cdf0e10cSrcweir public: 71cdf0e10cSrcweir XMLFamilyData_Impl( sal_Int32 nFamily, const ::rtl::OUString& rStrName, 72cdf0e10cSrcweir const UniReference < SvXMLExportPropertyMapper > & rMapper, 73cdf0e10cSrcweir const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True ); 74cdf0e10cSrcweir XMLFamilyData_Impl(sal_Int32 nFamily)75cdf0e10cSrcweir XMLFamilyData_Impl( sal_Int32 nFamily ) : 76cdf0e10cSrcweir pCache( 0 ), 77cdf0e10cSrcweir mnFamily( nFamily ), mpParentList( NULL ), 78cdf0e10cSrcweir mpNameList( NULL ), mnCount( 0 ), mnName( 0 ) 79cdf0e10cSrcweir 80cdf0e10cSrcweir {} 81cdf0e10cSrcweir ~XMLFamilyData_Impl(); 82cdf0e10cSrcweir 83cdf0e10cSrcweir friend int XMLFamilyDataSort_Impl( const XMLFamilyData_Impl& r1, const XMLFamilyData_Impl& r2 ); 84cdf0e10cSrcweir 85cdf0e10cSrcweir void ClearEntries(); 86cdf0e10cSrcweir }; 87cdf0e10cSrcweir 88cdf0e10cSrcweir DECLARE_CONTAINER_SORT( XMLFamilyDataList_Impl, XMLFamilyData_Impl ) 89cdf0e10cSrcweir 90cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////// 91cdf0e10cSrcweir // 92cdf0e10cSrcweir // 93cdf0e10cSrcweir // 94cdf0e10cSrcweir 95cdf0e10cSrcweir DECLARE_CONTAINER_SORT_DEL( SvXMLAutoStylePoolNamesP_Impl, 96cdf0e10cSrcweir ::rtl::OUString ) 97cdf0e10cSrcweir 98cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////// 99cdf0e10cSrcweir // 100cdf0e10cSrcweir // Properties of a pool 101cdf0e10cSrcweir // 102cdf0e10cSrcweir 103cdf0e10cSrcweir class SvXMLAutoStylePoolPropertiesP_Impl 104cdf0e10cSrcweir { 105cdf0e10cSrcweir ::rtl::OUString msName; 106cdf0e10cSrcweir ::std::vector< XMLPropertyState > maProperties; 107cdf0e10cSrcweir sal_uInt32 mnPos; 108cdf0e10cSrcweir 109cdf0e10cSrcweir public: 110cdf0e10cSrcweir 111cdf0e10cSrcweir SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties ); 112cdf0e10cSrcweir ~SvXMLAutoStylePoolPropertiesP_Impl()113cdf0e10cSrcweir ~SvXMLAutoStylePoolPropertiesP_Impl() 114cdf0e10cSrcweir { 115cdf0e10cSrcweir } 116cdf0e10cSrcweir GetName() const117cdf0e10cSrcweir const ::rtl::OUString& GetName() const { return msName; } GetProperties() const118cdf0e10cSrcweir const ::std::vector< XMLPropertyState >& GetProperties() const { return maProperties; } GetPos() const119cdf0e10cSrcweir sal_uInt32 GetPos() const { return mnPos; } 120cdf0e10cSrcweir SetName(const::rtl::OUString & rNew)121cdf0e10cSrcweir void SetName( const ::rtl::OUString& rNew ) { msName = rNew; } 122cdf0e10cSrcweir }; 123cdf0e10cSrcweir 124cdf0e10cSrcweir typedef SvXMLAutoStylePoolPropertiesP_Impl *SvXMLAutoStylePoolPropertiesPPtr; 125cdf0e10cSrcweir DECLARE_LIST( SvXMLAutoStylePoolPropertiesPList_Impl, SvXMLAutoStylePoolPropertiesPPtr ) 126cdf0e10cSrcweir 127cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////// 128cdf0e10cSrcweir // 129cdf0e10cSrcweir // Parents of AutoStylePool's 130cdf0e10cSrcweir // 131cdf0e10cSrcweir 132cdf0e10cSrcweir class SvXMLAutoStylePoolParentP_Impl 133cdf0e10cSrcweir { 134cdf0e10cSrcweir ::rtl::OUString msParent; 135cdf0e10cSrcweir SvXMLAutoStylePoolPropertiesPList_Impl maPropertiesList; 136cdf0e10cSrcweir 137cdf0e10cSrcweir public: 138cdf0e10cSrcweir SvXMLAutoStylePoolParentP_Impl(const::rtl::OUString & rParent)139cdf0e10cSrcweir SvXMLAutoStylePoolParentP_Impl( const ::rtl::OUString & rParent ) : 140cdf0e10cSrcweir msParent( rParent ) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir ~SvXMLAutoStylePoolParentP_Impl(); 145cdf0e10cSrcweir 146cdf0e10cSrcweir sal_Bool Add( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties, ::rtl::OUString& rName, bool bDontSeek = false ); 147cdf0e10cSrcweir 148cdf0e10cSrcweir sal_Bool AddNamed( XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties, const ::rtl::OUString& rName ); 149cdf0e10cSrcweir 150cdf0e10cSrcweir ::rtl::OUString Find( const XMLFamilyData_Impl* pFamilyData, const ::std::vector< XMLPropertyState >& rProperties ) const; 151cdf0e10cSrcweir GetParent() const152cdf0e10cSrcweir const ::rtl::OUString& GetParent() const { return msParent; } 153cdf0e10cSrcweir GetPropertiesList() const154cdf0e10cSrcweir const SvXMLAutoStylePoolPropertiesPList_Impl& GetPropertiesList() const 155cdf0e10cSrcweir { 156cdf0e10cSrcweir return maPropertiesList; 157cdf0e10cSrcweir } 158cdf0e10cSrcweir }; 159cdf0e10cSrcweir 160cdf0e10cSrcweir DECLARE_CONTAINER_SORT_DEL( SvXMLAutoStylePoolParentsP_Impl, 161cdf0e10cSrcweir SvXMLAutoStylePoolParentP_Impl ) 162cdf0e10cSrcweir 163cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////// 164cdf0e10cSrcweir // 165cdf0e10cSrcweir // Implementationclass of SvXMLAutoStylePool 166cdf0e10cSrcweir // 167cdf0e10cSrcweir 168cdf0e10cSrcweir class SvXMLAutoStylePoolP_Impl 169cdf0e10cSrcweir { 170cdf0e10cSrcweir SvXMLExport& rExport; 171cdf0e10cSrcweir 172cdf0e10cSrcweir XMLFamilyDataList_Impl maFamilyList; 173cdf0e10cSrcweir 174cdf0e10cSrcweir public: 175cdf0e10cSrcweir 176cdf0e10cSrcweir SvXMLAutoStylePoolP_Impl( SvXMLExport& rExport ); 177cdf0e10cSrcweir ~SvXMLAutoStylePoolP_Impl(); 178cdf0e10cSrcweir GetExport() const179cdf0e10cSrcweir SvXMLExport& GetExport() const { return rExport; } 180cdf0e10cSrcweir 181cdf0e10cSrcweir void AddFamily( sal_Int32 nFamily, const ::rtl::OUString& rStrName, 182cdf0e10cSrcweir const UniReference < SvXMLExportPropertyMapper > & rMapper, 183cdf0e10cSrcweir const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True ); 184cdf0e10cSrcweir void RegisterName( sal_Int32 nFamily, const ::rtl::OUString& rName ); 185cdf0e10cSrcweir void GetRegisteredNames( 186cdf0e10cSrcweir com::sun::star::uno::Sequence<sal_Int32>& aFamilies, 187cdf0e10cSrcweir com::sun::star::uno::Sequence<rtl::OUString>& aNames ); 188cdf0e10cSrcweir 189cdf0e10cSrcweir // ::rtl::OUString Add( sal_Int32 nFamily, const ::rtl::OUString& rParent, 190cdf0e10cSrcweir // const ::std::vector< XMLPropertyState >& rProperties, 191cdf0e10cSrcweir // sal_Bool bCache = sal_False ); 192cdf0e10cSrcweir sal_Bool Add( ::rtl::OUString& rName, sal_Int32 nFamily, 193cdf0e10cSrcweir const ::rtl::OUString& rParent, 194cdf0e10cSrcweir const ::std::vector< XMLPropertyState >& rProperties, 195cdf0e10cSrcweir sal_Bool bCache = sal_False, 196cdf0e10cSrcweir bool bDontSeek = false ); 197cdf0e10cSrcweir sal_Bool AddNamed( const ::rtl::OUString& rName, sal_Int32 nFamily, 198cdf0e10cSrcweir const ::rtl::OUString& rParent, 199cdf0e10cSrcweir const ::std::vector< XMLPropertyState >& rProperties ); 200cdf0e10cSrcweir 201cdf0e10cSrcweir ::rtl::OUString AddToCache( sal_Int32 nFamily, 202cdf0e10cSrcweir const ::rtl::OUString& rParent ); 203cdf0e10cSrcweir ::rtl::OUString Find( sal_Int32 nFamily, const ::rtl::OUString& rParent, 204cdf0e10cSrcweir const ::std::vector< XMLPropertyState >& rProperties ) const; 205cdf0e10cSrcweir 206cdf0e10cSrcweir ::rtl::OUString FindAndRemoveCached( sal_Int32 nFamily ) const; 207cdf0e10cSrcweir 208cdf0e10cSrcweir void exportXML( sal_Int32 nFamily, 209cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler, 210cdf0e10cSrcweir const SvXMLUnitConverter& rUnitConverter, 211cdf0e10cSrcweir const SvXMLNamespaceMap& rNamespaceMap, 212cdf0e10cSrcweir const SvXMLAutoStylePoolP *pAntiImpl) const; 213cdf0e10cSrcweir 214cdf0e10cSrcweir void ClearEntries(); 215cdf0e10cSrcweir }; 216cdf0e10cSrcweir 217cdf0e10cSrcweir struct SvXMLAutoStylePoolPExport_Impl 218cdf0e10cSrcweir { 219cdf0e10cSrcweir const ::rtl::OUString *mpParent; 220cdf0e10cSrcweir const SvXMLAutoStylePoolPropertiesP_Impl *mpProperties; 221cdf0e10cSrcweir }; 222cdf0e10cSrcweir 223cdf0e10cSrcweir #endif 224