LCOV - code coverage report
Current view: top level - svl/source/items - poolitem.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 29 74 39.2 %
Date: 2014-11-03 Functions: 25 44 56.8 %
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    17833862 : TYPEINIT0(SfxPoolItem);
      25    29394966 : TYPEINIT1(SfxVoidItem, SfxPoolItem);
      26             : // @@@ TYPEINIT1(SfxInvalidItem, SfxPoolItem);
      27     7799179 : 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      100164 : IMPL_PTRHINT(SfxPoolItemHint,SfxPoolItem)
      42             : 
      43    29363094 : SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich)
      44             :     : m_nRefCount(0)
      45             :     , m_nWhich(nWhich)
      46    29363094 :     , m_nKind(SFX_ITEMS_NONE)
      47             : {
      48             :     DBG_ASSERT(nWhich <= SHRT_MAX, "invalid WhichId");
      49             : #if OSL_DEBUG_LEVEL > 1
      50             :     ++nItemCount;
      51             :     if ( pw1 && nItemCount>=10000 )
      52             :     {
      53             :         DBG_WARNING( pw1 );
      54             :         pw1 = NULL;
      55             :     }
      56             :     if ( pw2 && nItemCount>=100000 )
      57             :     {
      58             :         DBG_WARNING( pw2 );
      59             :         pw2 = NULL;
      60             :     }
      61             :     if ( pw3 && nItemCount>=1000000 )
      62             :     {
      63             :         DBG_WARNING( pw3 );
      64             :         pw3 = NULL;
      65             :     }
      66             :     if ( pw4 && nItemCount>=5000000 )
      67             :     {
      68             :         DBG_WARNING( pw4 );
      69             :         pw4 = NULL;
      70             :     }
      71             :     if ( pw5 && nItemCount>=10000000 )
      72             :     {
      73             :         DBG_WARNING( pw5 );
      74             :         pw5 = NULL;
      75             :     }
      76             : #endif
      77    29363094 : }
      78             : 
      79             : 
      80     8726568 : SfxPoolItem::SfxPoolItem( const SfxPoolItem& rCpy )
      81             :     : m_nRefCount(0) // don't copy that
      82     8726568 :     , m_nWhich(rCpy.Which()) // call function because of ChkThis() (WTF does that mean?)
      83    17453136 :     , m_nKind( SFX_ITEMS_NONE )
      84             : {
      85             : #if OSL_DEBUG_LEVEL > 1
      86             :     ++nItemCount;
      87             :     if ( pw1 && nItemCount>=10000 )
      88             :     {
      89             :         DBG_WARNING( pw1 );
      90             :         pw1 = NULL;
      91             :     }
      92             :     if ( pw2 && nItemCount>=100000 )
      93             :     {
      94             :         DBG_WARNING( pw2 );
      95             :         pw2 = NULL;
      96             :     }
      97             :     if ( pw3 && nItemCount>=1000000 )
      98             :     {
      99             :         DBG_WARNING( pw3 );
     100             :         pw3 = NULL;
     101             :     }
     102             :     if ( pw4 && nItemCount>=5000000 )
     103             :     {
     104             :         DBG_WARNING( pw4 );
     105             :         pw4 = NULL;
     106             :     }
     107             :     if ( pw5 && nItemCount>=10000000 )
     108             :     {
     109             :         DBG_WARNING( pw5 );
     110             :         pw5 = NULL;
     111             :     }
     112             : #endif
     113     8726568 : }
     114             : 
     115             : 
     116    38028367 : SfxPoolItem::~SfxPoolItem()
     117             : {
     118             :     DBG_ASSERT(m_nRefCount == 0 || m_nRefCount > SFX_ITEMS_MAXREF,
     119             :             "destroying item in use");
     120             : #if OSL_DEBUG_LEVEL > 1
     121             :     --nItemCount;
     122             : #endif
     123    38028367 : }
     124             : 
     125             : 
     126           0 : int SfxPoolItem::Compare( const SfxPoolItem& ) const
     127             : {
     128           0 :     return 0;
     129             : }
     130             : 
     131             : 
     132           0 : int SfxPoolItem::Compare( const SfxPoolItem& rWith, const IntlWrapper& ) const
     133             : {
     134           0 :     return Compare( rWith );
     135             : }
     136             : 
     137             : 
     138      217556 : bool SfxPoolItem::operator==( const SfxPoolItem& rCmp ) const
     139             : {
     140      217556 :     return rCmp.Type() == Type();
     141             : }
     142             : 
     143             : 
     144           0 : SfxPoolItem* SfxPoolItem::Create(SvStream &, sal_uInt16) const
     145             : {
     146           0 :     return Clone();
     147             : }
     148             : 
     149             : 
     150      812779 : sal_uInt16 SfxPoolItem::GetVersion( sal_uInt16 ) const
     151             : {
     152      812779 :     return 0;
     153             : }
     154             : 
     155             : 
     156           0 : SvStream& SfxPoolItem::Store(SvStream &rStream, sal_uInt16 ) const
     157             : {
     158           0 :     return rStream;
     159             : }
     160             : 
     161             : /**
     162             :  * This virtual method allows to get a textual representation of the value
     163             :  * for the SfxPoolItem subclasses. It should be overloaded by all UI-relevant
     164             :  * SfxPoolItem subclasses.
     165             :  *
     166             :  * Because the unit of measure of the value in the SfxItemPool is only
     167             :  * queryable via @see SfxItemPool::GetMetric(sal_uInt16) const (and not
     168             :  * via the SfxPoolItem instance or subclass, the own unit of measure is
     169             :  * passed to 'eCoreMetric'.
     170             :  *
     171             :  * The corresponding unit of measure is passed as 'ePresentationMetric'.
     172             :  *
     173             :  *
     174             :  * @return SfxItemPresentation     SFX_ITEM_PRESENTATION_NAMELESS
     175             :  *                                 A textual representation (if applicable
     176             :  *                                 with a unit of measure) could be created,
     177             :  *                                 but it doesn't contain any semantic meaning
     178             :  *
     179             :  *                                 SFX_ITEM_PRESENTATION_COMPLETE
     180             :  *                                 A complete textual representation could be
     181             :  *                                 created with semantic meaning (if applicable
     182             :  *                                 with unit of measure)
     183             :  *
     184             :  * Example:
     185             :  *
     186             :  *    pSvxFontItem->GetPresentation( SFX_PRESENTATION_NAMELESS, ... )
     187             :  *      "12pt" with return SFX_ITEM_PRESENTATION_NAMELESS
     188             :  *
     189             :  *    pSvxColorItem->GetPresentation( SFX_PRESENTATION_COMPLETE, ... )
     190             :  *        "red" with return SFX_ITEM_PRESENTATION_NAMELESS
     191             :  *        Because the SvxColorItem does not know which color it represents
     192             :  *        it cannot provide a name, which is communicated by the return value
     193             :  *
     194             :  *    pSvxBorderItem->GetPresentation( SFX_PRESENTATION_COMPLETE, ... )
     195             :  *        "1cm top border, 2cm left border, 0.2cm bottom border, ..."
     196             :  */
     197           0 : bool SfxPoolItem::GetPresentation
     198             : (
     199             :     SfxItemPresentation /*ePresentation*/,       // IN:  how we should format
     200             :     SfxMapUnit          /*eCoreMetric*/,         // IN:  current metric of the SfxPoolItems
     201             :     SfxMapUnit          /*ePresentationMetric*/, // IN:  target metric of the presentation
     202             :     OUString&           /*rText*/,               // OUT: textual representation
     203             :     const IntlWrapper *
     204             : )   const
     205             : {
     206           0 :     return false;
     207             : }
     208             : 
     209      566729 : SfxVoidItem::SfxVoidItem( sal_uInt16 which ):
     210      566729 :     SfxPoolItem(which)
     211             : {
     212      566729 : }
     213             : 
     214       27977 : SfxVoidItem::SfxVoidItem( const SfxVoidItem& rCopy):
     215       27977 :     SfxPoolItem(rCopy)
     216             : {
     217       27977 : }
     218             : 
     219             : 
     220        6878 : bool SfxVoidItem::operator==( const SfxPoolItem&
     221             : #ifdef DBG_UTIL
     222             : rCmp
     223             : #endif
     224             : ) const
     225             : {
     226             :     DBG_ASSERT( SfxPoolItem::operator==( rCmp ), "unequal type" );
     227        6878 :     return true;
     228             : }
     229             : 
     230             : 
     231           0 : bool SfxVoidItem::GetPresentation
     232             : (
     233             :     SfxItemPresentation     /*ePresentation*/,
     234             :     SfxMapUnit              /*eCoreMetric*/,
     235             :     SfxMapUnit              /*ePresentationMetric*/,
     236             :     OUString&               rText,
     237             :     const IntlWrapper *
     238             : )   const
     239             : {
     240           0 :     rText = "Void";
     241           0 :     return true;
     242             : }
     243             : 
     244             : 
     245       27977 : SfxPoolItem* SfxVoidItem::Clone(SfxItemPool *) const
     246             : {
     247       27977 :     return new SfxVoidItem(*this);
     248             : }
     249             : 
     250             : // SfxInvalidItem
     251             : 
     252           0 : SfxItemHandle::SfxItemHandle(SfxPoolItem &rItem):
     253             :     pRef(new sal_uInt16(1)),
     254           0 :     pItem(rItem.Clone())
     255             : {
     256           0 : }
     257             : 
     258             : 
     259           0 : SfxItemHandle::SfxItemHandle(const SfxItemHandle &rCopy):
     260             :     pRef(rCopy.pRef),
     261           0 :     pItem(rCopy.pItem)
     262             : {
     263           0 :     ++(*pRef);
     264           0 : }
     265             : 
     266             : 
     267           0 : const SfxItemHandle &SfxItemHandle::operator=(const SfxItemHandle &rCopy)
     268             : {
     269           0 :     if(&rCopy == this || pItem == rCopy.pItem)
     270           0 :         return *this;
     271           0 :     --(*pRef);
     272           0 :     if(!(*pRef))
     273             :     {
     274           0 :         delete pItem;
     275           0 :         pItem = 0;
     276             :     }
     277           0 :     pRef = rCopy.pRef;
     278           0 :     ++(*pRef);
     279           0 :     pItem = rCopy.pItem;
     280           0 :     return *this;
     281             : }
     282             : 
     283             : 
     284           0 : SfxItemHandle::~SfxItemHandle()
     285             : {
     286           0 :     --(*pRef);
     287           0 :     if(!(*pRef)) {
     288           0 :         delete pRef; pRef = 0;
     289           0 :         delete pItem; pItem = 0;
     290             :     }
     291           0 : }
     292             : 
     293             : 
     294           0 : bool SfxPoolItem::ScaleMetrics( long /*lMult*/, long /*lDiv*/ )
     295             : {
     296           0 :     return false;
     297             : }
     298             : 
     299             : 
     300           0 : bool SfxPoolItem::HasMetrics() const
     301             : {
     302           0 :     return false;
     303             : }
     304             : 
     305             : 
     306             : 
     307           0 : bool SfxPoolItem::QueryValue( com::sun::star::uno::Any&, sal_uInt8 ) const
     308             : {
     309             :     OSL_FAIL("There is no implementation for QueryValue for this item!");
     310           0 :     return false;
     311             : }
     312             : 
     313             : 
     314             : 
     315           0 : bool SfxPoolItem::PutValue( const com::sun::star::uno::Any&, sal_uInt8 )
     316             : {
     317             :     OSL_FAIL("There is no implementation for PutValue for this item!");
     318           0 :     return false;
     319             : }
     320             : 
     321      694738 : SfxVoidItem::~SfxVoidItem()
     322             : {
     323      694738 : }
     324             : 
     325             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10