LCOV - code coverage report
Current view: top level - svl/source/items - poolitem.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 32 84 38.1 %
Date: 2014-04-11 Functions: 30 53 56.6 %
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             : 
      21             : #include <svl/poolitem.hxx>
      22             : #include <tools/stream.hxx>
      23             : 
      24     6389745 : TYPEINIT0(SfxPoolItem);
      25    17523538 : TYPEINIT1(SfxVoidItem, SfxPoolItem);
      26             : // @@@ TYPEINIT1(SfxInvalidItem, SfxPoolItem);
      27     2824968 : TYPEINIT1(SfxSetItem, SfxPoolItem);
      28             : // @@@ TYPEINIT1(SfxItemChangedHint, SfxHint);
      29             : 
      30             : 
      31             : #if OSL_DEBUG_LEVEL > 1
      32             : static sal_uLong nItemCount = 0;
      33             : 
      34             : const char* pw1 = "Wow! 10.000 items!";
      35             : const char* pw2 = "Wow! 100.000 items!";
      36             : const char* pw3 = "Wow! 1.000.000 items!";
      37             : const char* pw4 = "Wow! 50.000.000 items!";
      38             : const char* pw5 = "Wow! 10.000.000 items!";
      39             : #endif
      40             : 
      41      481375 : IMPL_PTRHINT(SfxPoolItemHint,SfxPoolItem)
      42             : 
      43             : // SfxPoolItem -----------------------------------------------------------
      44    12674181 : SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich)
      45             :     : m_nRefCount(0)
      46             :     , m_nWhich(nWhich)
      47    12674181 :     , m_nKind(0)
      48             : {
      49             :     DBG_ASSERT(nWhich <= SHRT_MAX, "invalid WhichId");
      50             : #if OSL_DEBUG_LEVEL > 1
      51             :     ++nItemCount;
      52             :     if ( pw1 && nItemCount>=10000 )
      53             :     {
      54             :         DBG_WARNING( pw1 );
      55             :         pw1 = NULL;
      56             :     }
      57             :     if ( pw2 && nItemCount>=100000 )
      58             :     {
      59             :         DBG_WARNING( pw2 );
      60             :         pw2 = NULL;
      61             :     }
      62             :     if ( pw3 && nItemCount>=1000000 )
      63             :     {
      64             :         DBG_WARNING( pw3 );
      65             :         pw3 = NULL;
      66             :     }
      67             :     if ( pw4 && nItemCount>=5000000 )
      68             :     {
      69             :         DBG_WARNING( pw4 );
      70             :         pw4 = NULL;
      71             :     }
      72             :     if ( pw5 && nItemCount>=10000000 )
      73             :     {
      74             :         DBG_WARNING( pw5 );
      75             :         pw5 = NULL;
      76             :     }
      77             : #endif
      78    12674181 : }
      79             : 
      80             : 
      81     3367877 : SfxPoolItem::SfxPoolItem( const SfxPoolItem& rCpy )
      82             :     : m_nRefCount(0) // don't copy that
      83     3367877 :     , m_nWhich(rCpy.Which()) // call function because of ChkThis() (WTF does that mean?)
      84     6735754 :     , m_nKind( 0 )
      85             : {
      86             : #if OSL_DEBUG_LEVEL > 1
      87             :     ++nItemCount;
      88             :     if ( pw1 && nItemCount>=10000 )
      89             :     {
      90             :         DBG_WARNING( pw1 );
      91             :         pw1 = NULL;
      92             :     }
      93             :     if ( pw2 && nItemCount>=100000 )
      94             :     {
      95             :         DBG_WARNING( pw2 );
      96             :         pw2 = NULL;
      97             :     }
      98             :     if ( pw3 && nItemCount>=1000000 )
      99             :     {
     100             :         DBG_WARNING( pw3 );
     101             :         pw3 = NULL;
     102             :     }
     103             :     if ( pw4 && nItemCount>=5000000 )
     104             :     {
     105             :         DBG_WARNING( pw4 );
     106             :         pw4 = NULL;
     107             :     }
     108             :     if ( pw5 && nItemCount>=10000000 )
     109             :     {
     110             :         DBG_WARNING( pw5 );
     111             :         pw5 = NULL;
     112             :     }
     113             : #endif
     114     3367877 : }
     115             : 
     116             : 
     117    15937089 : SfxPoolItem::~SfxPoolItem()
     118             : {
     119             :     DBG_ASSERT(m_nRefCount == 0 || m_nRefCount > SFX_ITEMS_MAXREF,
     120             :             "destroying item in use");
     121             : #if OSL_DEBUG_LEVEL > 1
     122             :     --nItemCount;
     123             : #endif
     124    15937089 : }
     125             : 
     126             : 
     127           0 : int SfxPoolItem::Compare( const SfxPoolItem& ) const
     128             : {
     129           0 :     return 0;
     130             : }
     131             : 
     132             : 
     133           0 : int SfxPoolItem::Compare( const SfxPoolItem& rWith, const IntlWrapper& ) const
     134             : {
     135           0 :     return Compare( rWith );
     136             : }
     137             : 
     138             : 
     139       96837 : bool SfxPoolItem::operator==( const SfxPoolItem& rCmp ) const
     140             : {
     141       96837 :     return rCmp.Type() == Type();
     142             : }
     143             : 
     144             : 
     145           0 : SfxPoolItem* SfxPoolItem::Create(SvStream &, sal_uInt16) const
     146             : {
     147           0 :     return Clone(0);
     148             : }
     149             : 
     150             : 
     151      265506 : sal_uInt16 SfxPoolItem::GetVersion( sal_uInt16 ) const
     152             : {
     153      265506 :     return 0;
     154             : }
     155             : 
     156             : 
     157           0 : SvStream& SfxPoolItem::Store(SvStream &rStream, sal_uInt16 ) const
     158             : {
     159           0 :     return rStream;
     160             : }
     161             : 
     162             : // static
     163           0 : OUString SfxPoolItem::readByteString(SvStream& rStream)
     164             : {
     165           0 :     return rStream.ReadUniOrByteString(rStream.GetStreamCharSet());
     166             : }
     167             : 
     168             : // static
     169        3444 : void SfxPoolItem::writeByteString(SvStream & rStream, const OUString& rString)
     170             : {
     171        3444 :     rStream.WriteUniOrByteString(rString, rStream.GetStreamCharSet());
     172        3444 : }
     173             : 
     174             : // static
     175           0 : OUString SfxPoolItem::readUnicodeString(SvStream & rStream, bool bUnicode)
     176             : {
     177             :     return rStream.ReadUniOrByteString(bUnicode ? RTL_TEXTENCODING_UCS2 :
     178           0 :                                       rStream.GetStreamCharSet());
     179             : }
     180             : 
     181             : // static
     182           0 : void SfxPoolItem::writeUnicodeString(SvStream & rStream, const OUString& rString)
     183             : {
     184           0 :     rStream.WriteUniOrByteString(rString, RTL_TEXTENCODING_UCS2);
     185           0 : }
     186             : 
     187             : 
     188           0 : SfxItemPresentation SfxPoolItem::GetPresentation
     189             : (
     190             :     SfxItemPresentation /*ePresentation*/,       // IN:  wie formatiert werden soll
     191             :     SfxMapUnit          /*eCoreMetric*/,         // IN:  Ma\seinheit des SfxPoolItems
     192             :     SfxMapUnit          /*ePresentationMetric*/, // IN:  Wunsch-Ma\einheit der Darstellung
     193             :     OUString&           /*rText*/,               // OUT: textuelle Darstellung
     194             :     const IntlWrapper *
     195             : )   const
     196             : 
     197             : /*  [Beschreibung]
     198             : 
     199             :     "Uber diese virtuelle Methode kann von den SfxPoolItem-Subklassen
     200             :     eine textuelle Datstellung des Wertes erhalten werden. Sie sollte
     201             :     von allen UI-relevanten SfxPoolItem-Subklassen "uberladen werden.
     202             : 
     203             :     Da die Ma\seinheit des Wertes im SfxItemPool nur "uber
     204             :     <SfxItemPool::GetMetric(sal_uInt16)const> erfragbar ist, und nicht etwa
     205             :     in der SfxPoolItem-Instanz oder -Subklasse  verf"ugbar ist, wird die
     206             :     eigene Ma\seinheit als 'eCoreMetric' "ubergeben.
     207             : 
     208             :     Die darzustellende Ma\seinheit wird als 'ePresentationMetric'
     209             :     "ubergeben.
     210             : 
     211             : 
     212             :     [R"uckgabewert]
     213             : 
     214             :     SfxItemPresentation     SFX_ITEM_PRESENTATION_NONE
     215             :                             es konnte keine Text-Darstellung erzeugt werden
     216             : 
     217             :                             SFX_ITEM_PRESENTATION_NAMELESS
     218             :                             es konnte eine Text-Darstellung (ggf. mit
     219             :                             Ma\seinheit) erzeugt werden, die jedoch keine
     220             :                             semantische Bedeutung enth"alt
     221             : 
     222             :                             SFX_ITEM_PRESENTATION_COMPLETE
     223             :                             es konnte eine komplette Text-Darstellung mit
     224             :                             semantischer Bedeutung (und ggf. Ma\seinheit)
     225             :                             erzeugt werden
     226             : 
     227             : 
     228             :     [Beispiele]
     229             : 
     230             :     pSvxFontItem->GetPresentation( SFX_PRESENTATION_NAMELESS, ... )
     231             :         "12pt" mit return SFX_ITEM_PRESENTATION_NAMELESS
     232             : 
     233             :     pSvxColorItem->GetPresentation( SFX_PRESENTATION_COMPLETE, ... )
     234             :         "rot" mit return SFX_ITEM_PRESENTATION_NAMELESS
     235             :         (das das SvxColorItem nicht wei\s, was f"ur eine Farbe es darstellt,
     236             :         kann es keinen Namen angeben, was durch den Returnwert mitgeteilt wird.
     237             : 
     238             :     pSvxBorderItem->GetPresentation( SFX_PRESENTATION_COMPLETE, ... )
     239             :         "1cm oberer Rand, 2cm linker Rand, 0,2cm unterer Rand, ..."
     240             : */
     241             : 
     242             : {
     243           0 :     return SFX_ITEM_PRESENTATION_NONE;
     244             : }
     245             : 
     246             : // SfxVoidItem ------------------------------------------------------------
     247      340763 : SfxVoidItem::SfxVoidItem( sal_uInt16 which ):
     248      340763 :     SfxPoolItem(which)
     249             : {
     250      340763 : }
     251             : 
     252             : // SfxVoidItem ------------------------------------------------------------
     253       28764 : SfxVoidItem::SfxVoidItem( const SfxVoidItem& rCopy):
     254       28764 :     SfxPoolItem(rCopy)
     255             : {
     256       28764 : }
     257             : 
     258             : 
     259        7253 : bool SfxVoidItem::operator==( const SfxPoolItem&
     260             : #ifdef DBG_UTIL
     261             : rCmp
     262             : #endif
     263             : ) const
     264             : {
     265             :     DBG_ASSERT( SfxPoolItem::operator==( rCmp ), "unequal type" );
     266        7253 :     return true;
     267             : }
     268             : 
     269             : 
     270           0 : SfxItemPresentation SfxVoidItem::GetPresentation
     271             : (
     272             :     SfxItemPresentation     /*ePresentation*/,
     273             :     SfxMapUnit              /*eCoreMetric*/,
     274             :     SfxMapUnit              /*ePresentationMetric*/,
     275             :     OUString&               rText,
     276             :     const IntlWrapper *
     277             : )   const
     278             : {
     279           0 :     rText = "Void";
     280           0 :     return SFX_ITEM_PRESENTATION_NAMELESS;
     281             : }
     282             : 
     283             : 
     284       28764 : SfxPoolItem* SfxVoidItem::Clone(SfxItemPool *) const
     285             : {
     286       28764 :     return new SfxVoidItem(*this);
     287             : }
     288             : 
     289             : // SfxInvalidItem ---------------------------------------------------------
     290             : 
     291             : // SfxItemHandle ----------------------------------------------------------
     292           0 : SfxItemHandle::SfxItemHandle(SfxPoolItem &rItem):
     293             :     pRef(new sal_uInt16(1)),
     294           0 :     pItem(rItem.Clone(0))
     295             : {
     296           0 : }
     297             : 
     298             : 
     299           0 : SfxItemHandle::SfxItemHandle(const SfxItemHandle &rCopy):
     300             :     pRef(rCopy.pRef),
     301           0 :     pItem(rCopy.pItem)
     302             : {
     303           0 :     ++(*pRef);
     304           0 : }
     305             : 
     306             : 
     307           0 : const SfxItemHandle &SfxItemHandle::operator=(const SfxItemHandle &rCopy)
     308             : {
     309           0 :     if(&rCopy == this || pItem == rCopy.pItem)
     310           0 :         return *this;
     311           0 :     --(*pRef);
     312           0 :     if(!(*pRef))
     313             :     {
     314           0 :         delete pItem;
     315           0 :         pItem = 0;
     316             :     }
     317           0 :     pRef = rCopy.pRef;
     318           0 :     ++(*pRef);
     319           0 :     pItem = rCopy.pItem;
     320           0 :     return *this;
     321             : }
     322             : 
     323             : 
     324           0 : SfxItemHandle::~SfxItemHandle()
     325             : {
     326           0 :     --(*pRef);
     327           0 :     if(!(*pRef)) {
     328           0 :         delete pRef; pRef = 0;
     329           0 :         delete pItem; pItem = 0;
     330             :     }
     331           0 : }
     332             : 
     333             : 
     334           0 : bool SfxPoolItem::ScaleMetrics( long /*lMult*/, long /*lDiv*/ )
     335             : {
     336           0 :     return false;
     337             : }
     338             : 
     339             : 
     340           0 : bool SfxPoolItem::HasMetrics() const
     341             : {
     342           0 :     return false;
     343             : }
     344             : 
     345             : 
     346             : 
     347           0 : bool SfxPoolItem::QueryValue( com::sun::star::uno::Any&, sal_uInt8 ) const
     348             : {
     349             :     OSL_FAIL("There is no implementation for QueryValue for this item!");
     350           0 :     return false;
     351             : }
     352             : 
     353             : 
     354             : 
     355           0 : bool SfxPoolItem::PutValue( const com::sun::star::uno::Any&, sal_uInt8 )
     356             : {
     357             :     OSL_FAIL("There is no implementation for PutValue for this item!");
     358           0 :     return false;
     359             : }
     360             : 
     361      428855 : SfxVoidItem::~SfxVoidItem()
     362             : {
     363      428855 : }
     364             : 
     365             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10