LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/style - impastpl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 20 21 95.2 %
Date: 2012-12-27 Functions: 12 13 92.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef _XMLOFF_XMLASTPL_IMPL_HXX
      21             : #define _XMLOFF_XMLASTPL_IMPL_HXX
      22             : 
      23             : #include <boost/ptr_container/ptr_set.hpp>
      24             : #include <sal/types.h>
      25             : #include <rtl/ustring.hxx>
      26             : #include <set>
      27             : #include <vector>
      28             : #include <com/sun/star/uno/Reference.h>
      29             : #include <com/sun/star/xml/sax/XAttributeList.hpp>
      30             : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
      31             : #include <o3tl/sorted_vector.hxx>
      32             : #include <xmloff/maptype.hxx>
      33             : #include <xmloff/xmlexppr.hxx>
      34             : 
      35             : class SvXMLAutoStylePoolP;
      36             : class SvXMLAutoStylePoolParentsP_Impl;
      37             : typedef std::set<rtl::OUString> SvXMLAutoStylePoolNamesP_Impl;
      38             : class SvXMLExportPropertyMapper;
      39             : class SvXMLExport;
      40             : 
      41             : #define MAX_CACHE_SIZE 65536
      42             : 
      43             : ///////////////////////////////////////////////////////////////////////////////
      44             : //
      45             : // Implementationclass for stylefamily-information
      46             : //
      47             : 
      48             : typedef ::rtl::OUString* OUStringPtr;
      49             : typedef ::std::vector< OUStringPtr > SvXMLAutoStylePoolCache_Impl;
      50             : 
      51             : class XMLFamilyData_Impl
      52             : {
      53             : public:
      54             :     SvXMLAutoStylePoolCache_Impl        *pCache;
      55             :     sal_uInt32                          mnFamily;
      56             :     ::rtl::OUString                     maStrFamilyName;
      57             :     UniReference < SvXMLExportPropertyMapper >  mxMapper;
      58             : 
      59             :     SvXMLAutoStylePoolParentsP_Impl*    mpParentList;
      60             :     SvXMLAutoStylePoolNamesP_Impl*      mpNameList;
      61             :     sal_uInt32                          mnCount;
      62             :     sal_uInt32                          mnName;
      63             :     ::rtl::OUString                     maStrPrefix;
      64             :     sal_Bool                            bAsFamily;
      65             : 
      66             : public:
      67             :     XMLFamilyData_Impl( sal_Int32 nFamily, const ::rtl::OUString& rStrName,
      68             :             const UniReference < SvXMLExportPropertyMapper > &  rMapper,
      69             :             const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True );
      70             : 
      71         765 :     XMLFamilyData_Impl( sal_Int32 nFamily ) :
      72             :         pCache( 0 ),
      73             :         mnFamily( nFamily ), mpParentList( NULL ),
      74         765 :         mpNameList( NULL ), mnCount( 0 ), mnName( 0 )
      75             : 
      76         765 :     {}
      77             :     ~XMLFamilyData_Impl();
      78             : 
      79             :     friend bool operator<(const XMLFamilyData_Impl& r1, const XMLFamilyData_Impl& r2);
      80             : 
      81             :     void ClearEntries();
      82             : };
      83             : 
      84             : typedef boost::ptr_set<XMLFamilyData_Impl> XMLFamilyDataList_Impl;
      85             : 
      86             : ///////////////////////////////////////////////////////////////////////////////
      87             : //
      88             : // Properties of a pool
      89             : //
      90             : 
      91             : class SvXMLAutoStylePoolPropertiesP_Impl
      92             : {
      93             :     ::rtl::OUString                     msName;
      94             :     ::std::vector< XMLPropertyState >   maProperties;
      95             :     sal_uInt32                          mnPos;
      96             : 
      97             : public:
      98             : 
      99             :     SvXMLAutoStylePoolPropertiesP_Impl( XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties );
     100             : 
     101          17 :     ~SvXMLAutoStylePoolPropertiesP_Impl()
     102          17 :     {
     103          17 :     }
     104             : 
     105          40 :     const ::rtl::OUString& GetName() const { return msName; }
     106          90 :     const ::std::vector< XMLPropertyState >& GetProperties() const { return maProperties; }
     107          17 :     sal_uInt32 GetPos() const { return mnPos; }
     108             : 
     109           0 :     void SetName( const ::rtl::OUString& rNew ) { msName = rNew; }
     110             : };
     111             : 
     112             : typedef SvXMLAutoStylePoolPropertiesP_Impl* SvXMLAutoStylePoolPropertiesPPtr;
     113             : typedef ::std::vector< SvXMLAutoStylePoolPropertiesPPtr > SvXMLAutoStylePoolPropertiesPList_Impl;
     114             : 
     115             : ///////////////////////////////////////////////////////////////////////////////
     116             : //
     117             : // Parents of AutoStylePool's
     118             : //
     119             : 
     120             : class SvXMLAutoStylePoolParentP_Impl
     121             : {
     122             :     ::rtl::OUString                         msParent;
     123             :     SvXMLAutoStylePoolPropertiesPList_Impl  maPropertiesList;
     124             : 
     125             : public:
     126             : 
     127          43 :     SvXMLAutoStylePoolParentP_Impl( const ::rtl::OUString & rParent ) :
     128          43 :         msParent( rParent )
     129             :     {
     130          43 :     }
     131             : 
     132             :     ~SvXMLAutoStylePoolParentP_Impl();
     133             : 
     134             :     sal_Bool Add( XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties, ::rtl::OUString& rName, bool bDontSeek = false );
     135             : 
     136             :     sal_Bool AddNamed( XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties, const ::rtl::OUString& rName );
     137             : 
     138             :     ::rtl::OUString Find( const XMLFamilyData_Impl& rFamilyData, const ::std::vector< XMLPropertyState >& rProperties ) const;
     139             : 
     140          77 :     const ::rtl::OUString& GetParent() const { return msParent; }
     141             : 
     142          29 :     const SvXMLAutoStylePoolPropertiesPList_Impl& GetPropertiesList() const
     143             :     {
     144          29 :         return maPropertiesList;
     145             :     }
     146             : };
     147             : 
     148             : struct SvXMLAutoStylePoolParentPCmp_Impl
     149             : {
     150          30 :     bool operator()( SvXMLAutoStylePoolParentP_Impl* const& lhs, SvXMLAutoStylePoolParentP_Impl* const& rhs) const
     151             :     {
     152          30 :         return lhs->GetParent().compareTo( rhs->GetParent() ) < 0;
     153             :     }
     154             : };
     155         128 : class SvXMLAutoStylePoolParentsP_Impl : public o3tl::sorted_vector<SvXMLAutoStylePoolParentP_Impl*, SvXMLAutoStylePoolParentPCmp_Impl>
     156             : {
     157             : public:
     158         128 :     ~SvXMLAutoStylePoolParentsP_Impl() { DeleteAndDestroyAll(); }
     159             : };
     160             : 
     161             : ///////////////////////////////////////////////////////////////////////////////
     162             : //
     163             : // Implementationclass of SvXMLAutoStylePool
     164             : //
     165             : 
     166             : class SvXMLAutoStylePoolP_Impl
     167             : {
     168             :     SvXMLExport& rExport;
     169             : 
     170             :     XMLFamilyDataList_Impl      maFamilyList;
     171             : 
     172             : public:
     173             : 
     174             :     SvXMLAutoStylePoolP_Impl( SvXMLExport& rExport );
     175             :     ~SvXMLAutoStylePoolP_Impl();
     176             : 
     177         540 :     SvXMLExport& GetExport() const { return rExport; }
     178             : 
     179             :     void AddFamily( sal_Int32 nFamily, const ::rtl::OUString& rStrName,
     180             :         const UniReference < SvXMLExportPropertyMapper > & rMapper,
     181             :         const ::rtl::OUString& rStrPrefix, sal_Bool bAsFamily = sal_True );
     182             :     void SetFamilyPropSetMapper( sal_Int32 nFamily,
     183             :         const UniReference < SvXMLExportPropertyMapper > & rMapper );
     184             :     void RegisterName( sal_Int32 nFamily, const ::rtl::OUString& rName );
     185             :     void GetRegisteredNames(
     186             :         com::sun::star::uno::Sequence<sal_Int32>& aFamilies,
     187             :         com::sun::star::uno::Sequence<rtl::OUString>& aNames );
     188             : 
     189             :     sal_Bool Add( ::rtl::OUString& rName, sal_Int32 nFamily,
     190             :                 const ::rtl::OUString& rParent,
     191             :                 const ::std::vector< XMLPropertyState >& rProperties,
     192             :                 sal_Bool bCache = sal_False,
     193             :                 bool bDontSeek = false );
     194             :     sal_Bool AddNamed( const ::rtl::OUString& rName, sal_Int32 nFamily,
     195             :                 const ::rtl::OUString& rParent,
     196             :                 const ::std::vector< XMLPropertyState >& rProperties );
     197             : 
     198             :     ::rtl::OUString Find( sal_Int32 nFamily, const ::rtl::OUString& rParent,
     199             :                           const ::std::vector< XMLPropertyState >& rProperties ) const;
     200             : 
     201             :     void exportXML( sal_Int32 nFamily,
     202             :         const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & rHandler,
     203             :         const SvXMLUnitConverter& rUnitConverter,
     204             :         const SvXMLNamespaceMap& rNamespaceMap,
     205             :         const SvXMLAutoStylePoolP *pAntiImpl) const;
     206             : 
     207             :     void ClearEntries();
     208             : };
     209             : 
     210             : struct SvXMLAutoStylePoolPExport_Impl
     211             : {
     212             :     const ::rtl::OUString                   *mpParent;
     213             :     const SvXMLAutoStylePoolPropertiesP_Impl    *mpProperties;
     214             : };
     215             : 
     216             : #endif
     217             : 
     218             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10