LCOV - code coverage report
Current view: top level - svl/source/items - poolitem.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 28 54 51.9 %
Date: 2015-06-13 12:38:46 Functions: 23 38 60.5 %
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             : #include <osl/diagnose.h>
      24             : #include <libxml/xmlwriter.h>
      25             : 
      26    10259142 : TYPEINIT0(SfxPoolItem);
      27    31135911 : TYPEINIT1(SfxVoidItem, SfxPoolItem);
      28             : // @@@ TYPEINIT1(SfxInvalidItem, SfxPoolItem);
      29     4389252 : TYPEINIT1(SfxSetItem, SfxPoolItem);
      30             : // @@@ TYPEINIT1(SfxItemChangedHint, SfxHint);
      31             : 
      32             : 
      33             : #if OSL_DEBUG_LEVEL > 1
      34             : static sal_uLong nItemCount = 0;
      35             : 
      36             : const char* pw1 = "Wow! 10.000 items!";
      37             : const char* pw2 = "Wow! 100.000 items!";
      38             : const char* pw3 = "Wow! 1.000.000 items!";
      39             : const char* pw4 = "Wow! 50.000.000 items!";
      40             : const char* pw5 = "Wow! 10.000.000 items!";
      41             : #endif
      42             : 
      43    20722943 : SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich)
      44             :     : m_nRefCount(0)
      45             :     , m_nWhich(nWhich)
      46    20722943 :     , 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    20722943 : }
      78             : 
      79             : 
      80     6450294 : SfxPoolItem::SfxPoolItem( const SfxPoolItem& rCpy )
      81             :     : m_nRefCount(0) // don't copy that
      82     6450294 :     , m_nWhich(rCpy.Which()) // call function because of ChkThis() (WTF does that mean?)
      83    12900588 :     , 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     6450294 : }
     114             : 
     115             : 
     116    27022194 : 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    27022194 : }
     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      111053 : bool SfxPoolItem::operator==( const SfxPoolItem& rCmp ) const
     139             : {
     140      111053 :     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      477374 : sal_uInt16 SfxPoolItem::GetVersion( sal_uInt16 ) const
     151             : {
     152      477374 :     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 overridden 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           0 : void SfxPoolItem::dumpAsXml(xmlTextWriterPtr pWriter) const
     210             : {
     211           0 :     xmlTextWriterStartElement(pWriter, BAD_CAST("sfxPoolItem"));
     212           0 :     xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
     213           0 :     xmlTextWriterEndElement(pWriter);
     214           0 : }
     215             : 
     216      549116 : SfxVoidItem::SfxVoidItem( sal_uInt16 which ):
     217      549116 :     SfxPoolItem(which)
     218             : {
     219      549116 : }
     220             : 
     221       48504 : SfxVoidItem::SfxVoidItem( const SfxVoidItem& rCopy):
     222       48504 :     SfxPoolItem(rCopy)
     223             : {
     224       48504 : }
     225             : 
     226             : 
     227       17448 : bool SfxVoidItem::operator==( const SfxPoolItem&
     228             : #ifdef DBG_UTIL
     229             : rCmp
     230             : #endif
     231             : ) const
     232             : {
     233             :     DBG_ASSERT( SfxPoolItem::operator==( rCmp ), "unequal type" );
     234       17448 :     return true;
     235             : }
     236             : 
     237             : 
     238           0 : bool SfxVoidItem::GetPresentation
     239             : (
     240             :     SfxItemPresentation     /*ePresentation*/,
     241             :     SfxMapUnit              /*eCoreMetric*/,
     242             :     SfxMapUnit              /*ePresentationMetric*/,
     243             :     OUString&               rText,
     244             :     const IntlWrapper *
     245             : )   const
     246             : {
     247           0 :     rText = "Void";
     248           0 :     return true;
     249             : }
     250             : 
     251             : 
     252       48504 : SfxPoolItem* SfxVoidItem::Clone(SfxItemPool *) const
     253             : {
     254       48504 :     return new SfxVoidItem(*this);
     255             : }
     256             : 
     257           0 : bool SfxPoolItem::ScaleMetrics( long /*lMult*/, long /*lDiv*/ )
     258             : {
     259           0 :     return false;
     260             : }
     261             : 
     262             : 
     263           0 : bool SfxPoolItem::HasMetrics() const
     264             : {
     265           0 :     return false;
     266             : }
     267             : 
     268             : 
     269             : 
     270           0 : bool SfxPoolItem::QueryValue( com::sun::star::uno::Any&, sal_uInt8 ) const
     271             : {
     272             :     OSL_FAIL("There is no implementation for QueryValue for this item!");
     273           0 :     return false;
     274             : }
     275             : 
     276             : 
     277             : 
     278           0 : bool SfxPoolItem::PutValue( const com::sun::star::uno::Any&, sal_uInt8 )
     279             : {
     280             :     OSL_FAIL("There is no implementation for PutValue for this item!");
     281           0 :     return false;
     282             : }
     283             : 
     284      695752 : SfxVoidItem::~SfxVoidItem()
     285             : {
     286      695752 : }
     287             : 
     288             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11