LCOV - code coverage report
Current view: top level - libreoffice/svl/source/inc - poolio.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 29 89.7 %
Date: 2012-12-27 Functions: 6 7 85.7 %
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             : #include <svl/brdcst.hxx>
      20             : #include <boost/shared_ptr.hpp>
      21             : #include <deque>
      22             : #include <vector>
      23             : 
      24             : #ifndef DELETEZ
      25             : #define DELETEZ(pPtr) { delete pPtr; pPtr = 0; }
      26             : #endif
      27             : 
      28             : 
      29             : struct SfxPoolVersion_Impl
      30             : {
      31             :     sal_uInt16          _nVer;
      32             :     sal_uInt16          _nStart, _nEnd;
      33             :     const sal_uInt16*         _pMap;
      34             : 
      35       35181 :                     SfxPoolVersion_Impl( sal_uInt16 nVer, sal_uInt16 nStart, sal_uInt16 nEnd,
      36             :                                          const sal_uInt16 *pMap )
      37             :                     :   _nVer( nVer ),
      38             :                         _nStart( nStart ),
      39             :                         _nEnd( nEnd ),
      40       35181 :                         _pMap( pMap )
      41       35181 :                     {}
      42           0 :                     SfxPoolVersion_Impl( const SfxPoolVersion_Impl &rOrig )
      43             :                     :   _nVer( rOrig._nVer ),
      44             :                         _nStart( rOrig._nStart ),
      45             :                         _nEnd( rOrig._nEnd ),
      46           0 :                         _pMap( rOrig._pMap )
      47           0 :                     {}
      48             : };
      49             : 
      50             : typedef std::vector<SfxPoolItem*> SfxPoolItemArrayBase_Impl;
      51             : 
      52             : typedef boost::shared_ptr< SfxPoolVersion_Impl > SfxPoolVersion_ImplPtr;
      53             : typedef std::deque< SfxPoolVersion_ImplPtr > SfxPoolVersionArr_Impl;
      54             : 
      55       51561 : struct SfxPoolItemArray_Impl: public SfxPoolItemArrayBase_Impl
      56             : {
      57             :     size_t  nFirstFree;
      58             : 
      59       64643 :     SfxPoolItemArray_Impl ()
      60       64643 :         : nFirstFree( 0 )
      61       64643 :     {}
      62             : };
      63             : 
      64             : struct SfxItemPool_Impl
      65             : {
      66             :     SfxBroadcaster                  aBC;
      67             :     std::vector<SfxPoolItemArray_Impl*> maPoolItems;
      68             :     std::vector<SfxItemPoolUser*> maSfxItemPoolUsers; /// ObjectUser section
      69             :     rtl::OUString                   aName;
      70             :     SfxPoolItem**                   ppPoolDefaults;
      71             :     SfxPoolItem**                   ppStaticDefaults;
      72             :     SfxItemPool*                    mpMaster;
      73             :     SfxItemPool*                    mpSecondary;
      74             :     sal_uInt16*                     mpPoolRanges;
      75             :     SfxPoolVersionArr_Impl          aVersions;
      76             :     sal_uInt16                      mnStart;
      77             :     sal_uInt16                      mnEnd;
      78             :     sal_uInt16                      mnFileFormatVersion;
      79             :     sal_uInt16                          nVersion;
      80             :     sal_uInt16                          nLoadingVersion;
      81             :     sal_uInt16                          nInitRefCount; // 1, beim Laden ggf. 2
      82             :     sal_uInt16                          nVerStart, nVerEnd; // WhichRange in Versions
      83             :     sal_uInt16                          nStoringStart, nStoringEnd; // zu speichernder Range
      84             :     sal_uInt8                           nMajorVer, nMinorVer; // Pool selbst
      85             :     SfxMapUnit                      eDefMetric;
      86             :     bool                            bInSetItem;
      87             :     bool                            bStreaming; // in Load() bzw. Store()
      88             :     bool                            mbPersistentRefCounts;
      89             : 
      90        7218 :     SfxItemPool_Impl( SfxItemPool* pMaster, const rtl::OUString& rName, sal_uInt16 nStart, sal_uInt16 nEnd )
      91             :         : maPoolItems(nEnd - nStart + 1, static_cast<SfxPoolItemArray_Impl*>(NULL))
      92             :         , aName(rName)
      93        7218 :         , ppPoolDefaults(new SfxPoolItem* [nEnd - nStart + 1])
      94             :         , ppStaticDefaults(0)
      95             :         , mpMaster(pMaster)
      96             :         , mpSecondary(NULL)
      97             :         , mpPoolRanges(NULL)
      98             :         , mnStart(nStart)
      99             :         , mnEnd(nEnd)
     100             :         , mnFileFormatVersion(0)
     101             :         , nLoadingVersion(0)
     102             :         , nInitRefCount(0)
     103             :         , nVerStart(0)
     104             :         , nVerEnd(0)
     105             :         , nStoringStart(0)
     106             :         , nStoringEnd(0)
     107             :         , nMajorVer(0)
     108             :         , nMinorVer(0)
     109             :         , bInSetItem(false)
     110       14436 :         , bStreaming(false)
     111             :     {
     112             :         DBG_ASSERT(mnStart, "Start-Which-Id must be greater 0" );
     113        7218 :         memset( ppPoolDefaults, 0, sizeof( SfxPoolItem* ) * (nEnd - nStart + 1));
     114        7218 :     }
     115             : 
     116        5767 :     ~SfxItemPool_Impl()
     117        5767 :     {
     118        5767 :         DeleteItems();
     119        5767 :     }
     120             : 
     121       11534 :     void DeleteItems()
     122             :     {
     123       11534 :         std::vector<SfxPoolItemArray_Impl*>::iterator itr = maPoolItems.begin(), itrEnd = maPoolItems.end();
     124      363504 :         for (; itr != itrEnd; ++itr)
     125      351970 :             delete *itr;
     126       11534 :         maPoolItems.clear();
     127             : 
     128       11534 :         delete[] mpPoolRanges;
     129       11534 :         mpPoolRanges = NULL;
     130       11534 :         delete[] ppPoolDefaults;
     131       11534 :         ppPoolDefaults = NULL;
     132       11534 :     }
     133             : 
     134             :     void readTheItems(SvStream & rStream, sal_uInt32 nCount, sal_uInt16 nVersion,
     135             :                       SfxPoolItem * pDefItem, SfxPoolItemArray_Impl ** pArr);
     136             : };
     137             : 
     138             : // -----------------------------------------------------------------------
     139             : 
     140             : // IBM-C-Set mag keine doppelten Defines
     141             : #ifdef DBG
     142             : #  undef DBG
     143             : #endif
     144             : 
     145             : #if defined(DBG_UTIL) && defined(MSC)
     146             : #define DBG(x) x
     147             : #else
     148             : #define DBG(x)
     149             : #endif
     150             : 
     151             : #define CHECK_FILEFORMAT( rStream, nTag ) \
     152             :     {   sal_uInt16 nFileTag; \
     153             :         rStream >> nFileTag; \
     154             :         if ( nTag != nFileTag ) \
     155             :         { \
     156             :             OSL_FAIL( #nTag ); /*! s.u. */ \
     157             :             /*! error-code setzen und auswerten! */ \
     158             :             (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); \
     159             :             pImp->bStreaming = sal_False; \
     160             :             return rStream; \
     161             :         } \
     162             :     }
     163             : 
     164             : #define CHECK_FILEFORMAT_RELEASE( rStream, nTag, pPointer ) \
     165             :    {   sal_uInt16 nFileTag; \
     166             :        rStream >> nFileTag; \
     167             :        if ( nTag != nFileTag ) \
     168             :         { \
     169             :            OSL_FAIL( #nTag ); /*! s.u. */ \
     170             :            /*! error-code setzen und auswerten! */ \
     171             :            (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); \
     172             :            pImp->bStreaming = sal_False; \
     173             :            delete pPointer; \
     174             :             return rStream; \
     175             :         } \
     176             :     }
     177             : 
     178             : #define CHECK_FILEFORMAT2( rStream, nTag1, nTag2 ) \
     179             :     {   sal_uInt16 nFileTag; \
     180             :         rStream >> nFileTag; \
     181             :         if ( nTag1 != nFileTag && nTag2 != nFileTag ) \
     182             :         { \
     183             :             OSL_FAIL( #nTag1 ); /*! s.u. */ \
     184             :             /*! error-code setzen und auswerten! */ \
     185             :             (rStream).SetError(SVSTREAM_FILEFORMAT_ERROR); \
     186             :             pImp->bStreaming = sal_False; \
     187             :             return rStream; \
     188             :         } \
     189             :     }
     190             : 
     191             : #define SFX_ITEMPOOL_VER_MAJOR          sal_uInt8(2)
     192             : #define SFX_ITEMPOOL_VER_MINOR          sal_uInt8(0)
     193             : 
     194             : #define SFX_ITEMPOOL_TAG_STARTPOOL_4    sal_uInt16(0x1111)
     195             : #define SFX_ITEMPOOL_TAG_STARTPOOL_5    sal_uInt16(0xBBBB)
     196             : #define SFX_ITEMPOOL_TAG_ITEMPOOL       sal_uInt16(0xAAAA)
     197             : #define SFX_ITEMPOOL_TAG_ITEMS          sal_uInt16(0x2222)
     198             : #define SFX_ITEMPOOL_TAG_ITEM           sal_uInt16(0x7777)
     199             : #define SFX_ITEMPOOL_TAG_SIZES          sal_uInt16(0x3333)
     200             : #define SFX_ITEMPOOL_TAG_DEFAULTS       sal_uInt16(0x4444)
     201             : #define SFX_ITEMPOOL_TAG_VERSIONMAP     sal_uInt16(0x5555)
     202             : #define SFX_ITEMPOOL_TAG_HEADER         sal_uInt16(0x6666)
     203             : #define SFX_ITEMPOOL_TAG_ENDPOOL        sal_uInt16(0xEEEE)
     204             : #define SFX_ITEMPOOL_TAG_TRICK4OLD      sal_uInt16(0xFFFF)
     205             : 
     206             : #define SFX_ITEMPOOL_REC                sal_uInt8(0x01)
     207             : #define SFX_ITEMPOOL_REC_HEADER         sal_uInt8(0x10)
     208             : #define SFX_ITEMPOOL_REC_VERSIONMAP     sal_uInt16(0x0020)
     209             : #define SFX_ITEMPOOL_REC_WHICHIDS       sal_uInt16(0x0030)
     210             : #define SFX_ITEMPOOL_REC_ITEMS          sal_uInt16(0x0040)
     211             : #define SFX_ITEMPOOL_REC_DEFAULTS       sal_uInt16(0x0050)
     212             : 
     213             : #define SFX_ITEMSET_REC                 sal_uInt8(0x02)
     214             : 
     215             : #define SFX_STYLES_REC                  sal_uInt8(0x03)
     216             : #define SFX_STYLES_REC_HEADER       sal_uInt16(0x0010)
     217             : #define SFX_STYLES_REC_STYLES       sal_uInt16(0x0020)
     218             : 
     219             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10