LCOV - code coverage report
Current view: top level - include/svl - poolitem.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 46 0.0 %
Date: 2014-04-14 Functions: 0 20 0.0 %
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             : #ifndef INCLUDED_SVL_POOLITEM_HXX
      20             : #define INCLUDED_SVL_POOLITEM_HXX
      21             : 
      22             : #include <svl/svldllapi.h>
      23             : #include <com/sun/star/uno/Any.hxx>
      24             : 
      25             : #include <sal/config.h>
      26             : #include <tools/rtti.hxx>
      27             : #include <limits.h>
      28             : #include <tools/solar.h>
      29             : #include <tools/debug.hxx>
      30             : #include <svl/hint.hxx>
      31             : 
      32             : typedef long SfxArgumentError;
      33             : 
      34             : class SbxVariable;
      35             : class SbxObject;
      36             : class SvStream;
      37             : class Color;
      38             : class IntlWrapper;
      39             : 
      40             : namespace com { namespace sun { namespace star { namespace uno { class Any; } } } }
      41             : 
      42             : static const sal_uInt32 SFX_ITEMS_DIRECT=   0xffffffff;
      43             : static const sal_uInt32 SFX_ITEMS_NULL=     0xfffffff0;  // instead StoreSurrogate
      44             : static const sal_uInt32 SFX_ITEMS_DEFAULT=  0xfffffffe;
      45             : 
      46             : #define SFX_ITEMS_POOLDEFAULT               0xffff
      47             : #define SFX_ITEMS_STATICDEFAULT             0xfffe
      48             : #define SFX_ITEMS_DELETEONIDLE              0xfffd
      49             : 
      50             : #define SFX_ITEMS_OLD_MAXREF                0xffef
      51             : #define SFX_ITEMS_MAXREF                    0xfffffffe
      52             : #define SFX_ITEMS_SPECIAL                   0xffffffff
      53             : 
      54             : #define CONVERT_TWIPS                       0x80    //Uno-Konvertierung fuer Massangaben (fuer MemberId)
      55             : 
      56             : 
      57             : 
      58             : // UNO3 shortcuts
      59             : 
      60             : // warning, if there is no boolean inside the any this will always return the value false
      61           0 : inline bool Any2Bool( const ::com::sun::star::uno::Any&rValue )
      62             : {
      63           0 :     bool nValue = false;
      64           0 :     if( rValue.hasValue() )
      65             :     {
      66           0 :         if( rValue.getValueType() == ::getCppuBooleanType() )
      67             :         {
      68           0 :             nValue = *(sal_Bool*)rValue.getValue();
      69             :         }
      70             :         else
      71             :         {
      72           0 :             sal_Int32 nNum = 0;
      73           0 :             if( rValue >>= nNum )
      74           0 :                 nValue = nNum != 0;
      75             :         }
      76             :     }
      77             : 
      78           0 :     return nValue;
      79             : }
      80             : 
      81           0 : inline ::com::sun::star::uno::Any Bool2Any( bool bValue )
      82             : {
      83           0 :     return ::com::sun::star::uno::Any( &bValue, ::getCppuBooleanType() );
      84             : }
      85             : 
      86             : 
      87             : 
      88             : //! Notloesung!!!
      89             : enum SfxFieldUnit
      90             : {
      91             :     SFX_FUNIT_NONE, SFX_FUNIT_MM, SFX_FUNIT_CM, SFX_FUNIT_M, SFX_FUNIT_KM,
      92             :     SFX_FUNIT_TWIP, SFX_FUNIT_POINT, SFX_FUNIT_PICA,
      93             :     SFX_FUNIT_INCH, SFX_FUNIT_FOOT, SFX_FUNIT_MILE, SFX_FUNIT_CHAR, SFX_FUNIT_LINE, SFX_FUNIT_CUSTOM
      94             : };
      95             : 
      96             : enum SfxMapUnit
      97             : {
      98             :     SFX_MAPUNIT_100TH_MM,
      99             :     SFX_MAPUNIT_10TH_MM,
     100             :     SFX_MAPUNIT_MM,
     101             :     SFX_MAPUNIT_CM,
     102             :     SFX_MAPUNIT_1000TH_INCH,
     103             :     SFX_MAPUNIT_100TH_INCH,
     104             :     SFX_MAPUNIT_10TH_INCH,
     105             :     SFX_MAPUNIT_INCH,
     106             :     SFX_MAPUNIT_POINT,
     107             :     SFX_MAPUNIT_TWIP,
     108             :     SFX_MAPUNIT_PIXEL,
     109             :     SFX_MAPUNIT_SYSFONT,
     110             :     SFX_MAPUNIT_APPFONT,
     111             :     SFX_MAPUNIT_RELATIVE,
     112             :     SFX_MAPUNIT_ABSOLUTE
     113             : };
     114             : 
     115             : 
     116             : 
     117             : enum SfxItemPresentation
     118             : 
     119             : /*  [Beschreibung]
     120             : 
     121             :     Die Werte dieses Enums bezeichnen den Grad der textuellen
     122             :     Presentation eines Items nach Aufruf der virtuellen Methode
     123             :     <SfxPoolItem::GetPresentation()const>.
     124             : */
     125             : 
     126             : {
     127             :     SFX_ITEM_PRESENTATION_NONE,
     128             :     SFX_ITEM_PRESENTATION_NAMEONLY,
     129             :     SFX_ITEM_PRESENTATION_NAMELESS,
     130             :     SFX_ITEM_PRESENTATION_COMPLETE
     131             : };
     132             : 
     133             : 
     134             : 
     135             : typedef sal_uInt16 SfxItemState;
     136             : 
     137             : #define SFX_ITEM_UNKNOWN    0x0000
     138             : 
     139             : #define SFX_ITEM_DISABLED   0x0001
     140             : #define SFX_ITEM_READONLY   0x0002
     141             : 
     142             : #define SFX_ITEM_DONTCARE   0x0010
     143             : #define SFX_ITEM_DEFAULT    0x0020
     144             : #define SFX_ITEM_SET        0x0030
     145             : 
     146             : // old stuff - dont use!!!
     147             : #define SFX_ITEM_AVAILABLE  SFX_ITEM_DEFAULT
     148             : #define SFX_ITEM_OFF        SFX_ITEM_DEFAULT
     149             : #define SFX_ITEM_ON         SFX_ITEM_SET
     150             : 
     151             : class SvXMLUnitConverter;
     152             : class SfxItemPool;
     153             : class SfxItemSet;
     154             : 
     155             : 
     156             : 
     157             : 
     158             : class SVL_DLLPUBLIC SfxPoolItem
     159             : {
     160             : friend class SfxItemPool;
     161             : friend class SfxItemDesruptor_Impl;
     162             : friend class SfxItemPoolCache;
     163             : friend class SfxItemSet;
     164             : friend class SfxVoidItem;
     165             : 
     166             :     sal_uLong   m_nRefCount;
     167             :     sal_uInt16  m_nWhich;
     168             :     sal_uInt16  m_nKind;
     169             : 
     170             : private:
     171             :     inline void              SetRefCount( sal_uLong n );
     172             :     inline void              SetKind( sal_uInt16 n );
     173             : public:
     174             :     inline sal_uLong             AddRef( sal_uLong n = 1 ) const;
     175             : private:
     176             :     inline sal_uLong             ReleaseRef( sal_uLong n = 1 ) const;
     177             :     SVL_DLLPRIVATE long      Delete_Impl(void*);
     178             : 
     179             : protected:
     180             :                              explicit SfxPoolItem( sal_uInt16 nWhich = 0 );
     181             :                              SfxPoolItem( const SfxPoolItem& );
     182             : 
     183             : public:
     184             :                              TYPEINFO();
     185             :     virtual                  ~SfxPoolItem();
     186             : 
     187           0 :     void                     SetWhich( sal_uInt16 nId ) { m_nWhich = nId; }
     188           0 :     sal_uInt16                   Which() const { return m_nWhich; }
     189             :     virtual bool             operator==( const SfxPoolItem& ) const = 0;
     190           0 :     bool                     operator!=( const SfxPoolItem& rItem ) const
     191           0 :                              { return !(*this == rItem); }
     192             :     virtual int              Compare( const SfxPoolItem &rWith ) const;
     193             :     virtual int              Compare( const SfxPoolItem &rWith, const IntlWrapper& rIntlWrapper ) const;
     194             : 
     195             :     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePresentation,
     196             :                                     SfxMapUnit eCoreMetric,
     197             :                                     SfxMapUnit ePresentationMetric,
     198             :                                     OUString &rText,
     199             :                                     const IntlWrapper * pIntlWrapper = 0 ) const;
     200             : 
     201             :     virtual sal_uInt16           GetVersion( sal_uInt16 nFileFormatVersion ) const;
     202             :     virtual bool             ScaleMetrics( long lMult, long lDiv );
     203             :     virtual bool             HasMetrics() const;
     204             : 
     205             :     virtual bool             QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
     206             :     virtual bool             PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
     207             : 
     208             :     virtual SfxPoolItem*     Create( SvStream &, sal_uInt16 nItemVersion ) const;
     209             :     virtual SvStream&        Store( SvStream &, sal_uInt16 nItemVersion ) const;
     210             :     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const = 0;
     211             : 
     212           0 :     sal_uLong                    GetRefCount() const { return m_nRefCount; }
     213           0 :     inline sal_uInt16            GetKind() const { return m_nKind; }
     214             : 
     215             :     /** Read in a Unicode string from a streamed byte string representation.
     216             : 
     217             :         @param rStream  Some (input) stream.  Its Stream/TargetCharSets must
     218             :         be set to correct values!
     219             : 
     220             :         @return  On success, returns the reconstructed Unicode string.
     221             :      */
     222             :     static OUString readByteString(SvStream & rStream);
     223             : 
     224             :     /** Write a byte string representation of a Unicode string into a stream.
     225             : 
     226             :         @param rStream  Some (output) stream.  Its Stream/TargetCharSets must
     227             :         be set to correct values!
     228             : 
     229             :         @param rString  Some Unicode string.
     230             :      */
     231             :     static void writeByteString(SvStream & rStream,
     232             :                                 const OUString& rString);
     233             : 
     234             :     /** Read in a Unicode string from either a streamed Unicode or byte string
     235             :         representation.
     236             : 
     237             :         @param rStream  Some (input) stream.  If bUnicode is false, its
     238             :         Stream/TargetCharSets must be set to correct values!
     239             : 
     240             :         @param bUnicode  Whether to read in a stream Unicode (true) or byte
     241             :         string (false) representation.
     242             : 
     243             :         @return          On success, returns the reconstructed Unicode string.
     244             :      */
     245             :     static OUString readUnicodeString(SvStream & rStream, bool bUnicode);
     246             : 
     247             :     /** Write a Unicode string representation of a Unicode string into a
     248             :         stream.
     249             : 
     250             :         @param rStream  Some (output) stream.
     251             : 
     252             :         @param rString  Some Unicode string.
     253             :      */
     254             :     static void writeUnicodeString(SvStream & rStream,
     255             :                                    const OUString& rString);
     256             : 
     257             : private:
     258             :     SfxPoolItem&             operator=( const SfxPoolItem& );    // n.i.!!
     259             : };
     260             : 
     261             : 
     262             : 
     263           0 : inline void SfxPoolItem::SetRefCount( sal_uLong n )
     264             : {
     265           0 :     m_nRefCount = n;
     266           0 :     m_nKind = 0;
     267           0 : }
     268             : 
     269           0 : inline void SfxPoolItem::SetKind( sal_uInt16 n )
     270             : {
     271           0 :     m_nRefCount = SFX_ITEMS_SPECIAL;
     272           0 :     m_nKind = n;
     273           0 : }
     274             : 
     275           0 : inline sal_uLong SfxPoolItem::AddRef( sal_uLong n ) const
     276             : {
     277             :     DBG_ASSERT(m_nRefCount <= SFX_ITEMS_MAXREF, "AddRef with non-Pool-Item");
     278             :     DBG_ASSERT(ULONG_MAX - m_nRefCount > n, "AddRef: refcount overflow");
     279           0 :     return (const_cast<SfxPoolItem *>(this)->m_nRefCount += n);
     280             : }
     281             : 
     282           0 : inline sal_uLong SfxPoolItem::ReleaseRef( sal_uLong n ) const
     283             : {
     284             :     DBG_ASSERT(m_nRefCount <= SFX_ITEMS_MAXREF, "AddRef with non-Pool-Item");
     285             :     DBG_ASSERT(m_nRefCount >= n, "AddRef: refcount underflow");
     286           0 :     const_cast<SfxPoolItem *>(this)->m_nRefCount -= n;
     287           0 :     return m_nRefCount;
     288             : }
     289             : 
     290             : 
     291             : 
     292           0 : inline bool IsPoolDefaultItem(const SfxPoolItem *pItem )
     293             : {
     294           0 :     return pItem && pItem->GetKind() == SFX_ITEMS_POOLDEFAULT;
     295             : }
     296             : 
     297           0 : inline bool IsStaticDefaultItem(const SfxPoolItem *pItem )
     298             : {
     299           0 :     return pItem && pItem->GetKind() == SFX_ITEMS_STATICDEFAULT;
     300             : }
     301             : 
     302           0 : inline bool IsDefaultItem( const SfxPoolItem *pItem )
     303             : {
     304           0 :     return pItem && pItem->GetKind() >= SFX_ITEMS_STATICDEFAULT;
     305             : }
     306             : 
     307           0 : inline bool IsPooledItem( const SfxPoolItem *pItem )
     308             : {
     309           0 :     return pItem && pItem->GetRefCount() > 0 && pItem->GetRefCount() <= SFX_ITEMS_MAXREF;
     310             : }
     311             : 
     312           0 : inline bool IsInvalidItem(const SfxPoolItem *pItem)
     313             : {
     314           0 :     return pItem == (SfxPoolItem *)-1;
     315             : }
     316             : 
     317             : 
     318             : 
     319             : class SVL_DLLPUBLIC SfxVoidItem: public SfxPoolItem
     320             : {
     321             :     SfxVoidItem & operator=( const SfxVoidItem& ); // not implemented.
     322             : public:
     323             :                             TYPEINFO_OVERRIDE();
     324             :                             explicit SfxVoidItem( sal_uInt16 nWhich );
     325             :                             SfxVoidItem( sal_uInt16 nWhich, SvStream & );
     326             :                             SfxVoidItem( const SfxVoidItem& );
     327             :                             virtual ~SfxVoidItem();
     328             : 
     329             :     virtual bool            operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
     330             : 
     331             :     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
     332             :                                     SfxMapUnit eCoreMetric,
     333             :                                     SfxMapUnit ePresMetric,
     334             :                                     OUString &rText,
     335             :                                     const IntlWrapper * = 0 ) const SAL_OVERRIDE;
     336             : 
     337             :     // von sich selbst eine Kopie erzeugen
     338             :     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
     339             :             void            SetWhich(sal_uInt16 nWh) { m_nWhich = nWh; }
     340             : };
     341             : 
     342             : 
     343             : 
     344             : class SVL_DLLPUBLIC SfxSetItem: public SfxPoolItem
     345             : {
     346             :     SfxItemSet              *pSet;
     347             : 
     348             :     SfxSetItem & operator=( const SfxSetItem& ); // not implemented.
     349             : 
     350             : public:
     351             :                             TYPEINFO_OVERRIDE();
     352             :                             SfxSetItem( sal_uInt16 nWhich, SfxItemSet *pSet );
     353             :                             SfxSetItem( sal_uInt16 nWhich, const SfxItemSet &rSet );
     354             :                             SfxSetItem( const SfxSetItem&, SfxItemPool *pPool = 0 );
     355             :                             virtual ~SfxSetItem();
     356             : 
     357             :     virtual bool            operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
     358             : 
     359             :     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
     360             :                                     SfxMapUnit eCoreMetric,
     361             :                                     SfxMapUnit ePresMetric,
     362             :                                     OUString &rText,
     363             :                                     const IntlWrapper * = 0 ) const SAL_OVERRIDE;
     364             : 
     365             :     // von sich selbst eine Kopie erzeugen
     366             :     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE = 0;
     367             :     virtual SfxPoolItem*    Create(SvStream &, sal_uInt16 nVersion) const SAL_OVERRIDE = 0;
     368             :     virtual SvStream&       Store(SvStream &, sal_uInt16 nVer) const SAL_OVERRIDE;
     369             : 
     370           0 :     const SfxItemSet&       GetItemSet() const
     371           0 :                             { return *pSet; }
     372           0 :     SfxItemSet&             GetItemSet()
     373           0 :                             { return *pSet; }
     374             : };
     375             : 
     376             : 
     377             : // Handle Klasse fuer PoolItems
     378             : 
     379             : class SVL_DLLPUBLIC SfxItemHandle
     380             : {
     381             :     sal_uInt16      *pRef;
     382             :     SfxPoolItem *pItem;
     383             : public:
     384             :     explicit SfxItemHandle( SfxPoolItem& );
     385             :     SfxItemHandle( const SfxItemHandle& );
     386             :     ~SfxItemHandle();
     387             : 
     388             :     const SfxItemHandle &operator=(const SfxItemHandle &);
     389           0 :     const SfxPoolItem &GetItem() const { return *pItem; }
     390             : };
     391             : 
     392             : 
     393             : 
     394           0 : DECL_PTRHINT(SVL_DLLPUBLIC, SfxPoolItemHint, SfxPoolItem);
     395             : 
     396             : 
     397             : 
     398             : #endif // INCLUDED_SVL_POOLITEM_HXX
     399             : 
     400             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10