LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/editeng - tstpitem.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 27 96.3 %
Date: 2013-07-09 Functions: 15 16 93.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             : #ifndef _SVX_TSPTITEM_HXX
      20             : #define _SVX_TSPTITEM_HXX
      21             : 
      22             : #include <svl/poolitem.hxx>
      23             : #include <editeng/svxenum.hxx>
      24             : #include <editeng/editengdllapi.h>
      25             : #include <o3tl/sorted_vector.hxx>
      26             : 
      27             : // class SvxTabStop ------------------------------------------------------
      28             : 
      29             : #define SVX_TAB_DEFCOUNT    10
      30             : #define SVX_TAB_DEFDIST     1134            // 2cm in twips
      31             : #define SVX_TAB_NOTFOUND    USHRT_MAX
      32             : #define cDfltDecimalChar    (sal_Unicode(0x00)) // Get from IntlWrapper
      33             : #define cDfltFillChar       (sal_Unicode(' '))
      34             : 
      35             : class EDITENG_DLLPUBLIC SvxTabStop
      36             : {
      37             : private:
      38             :     sal_Int32 nTabPos;
      39             : 
      40             :     SvxTabAdjust    eAdjustment;
      41             :     mutable sal_Unicode     m_cDecimal;
      42             :     sal_Unicode     cFill;
      43             : 
      44             :     EDITENG_DLLPRIVATE friend SvStream& operator<<( SvStream&, SvxTabStop& );
      45             : 
      46             :     void fillDecimal() const;
      47             : 
      48             : public:
      49             :     SvxTabStop();
      50             :     explicit SvxTabStop( const sal_Int32 nPos,
      51             :                 const SvxTabAdjust eAdjst = SVX_TAB_ADJUST_LEFT,
      52             :                 const sal_Unicode cDec = cDfltDecimalChar,
      53             :                 const sal_Unicode cFil = cDfltFillChar );
      54             : 
      55         156 :     sal_Int32& GetTabPos() { return nTabPos; }
      56       23491 :     sal_Int32 GetTabPos() const { return nTabPos; }
      57             : 
      58         160 :     SvxTabAdjust&   GetAdjustment() { return eAdjustment; }
      59        6009 :     SvxTabAdjust    GetAdjustment() const { return eAdjustment; }
      60             : 
      61           0 :     sal_Unicode&  GetDecimal() { fillDecimal(); return m_cDecimal; }
      62        2846 :     sal_Unicode   GetDecimal() const { fillDecimal(); return m_cDecimal; }
      63             : 
      64         154 :     sal_Unicode&  GetFill() { return cFill; }
      65        2922 :     sal_Unicode   GetFill() const { return cFill; }
      66             : 
      67             :     OUString      GetValueString() const;
      68             : 
      69             :     // the "old" operator==()
      70        5064 :     sal_Bool            IsEqual( const SvxTabStop& rTS ) const
      71             :                         {
      72        8727 :                             return ( nTabPos     == rTS.nTabPos     &&
      73        7312 :                                      eAdjustment == rTS.eAdjustment &&
      74       12317 :                                      m_cDecimal    == rTS.m_cDecimal    &&
      75        8668 :                                      cFill       == rTS.cFill );
      76             :                         }
      77             : 
      78             :     // For the SortedArray:
      79             :     sal_Bool            operator==( const SvxTabStop& rTS ) const
      80             :                         { return nTabPos == rTS.nTabPos; }
      81       11671 :     sal_Bool            operator <( const SvxTabStop& rTS ) const
      82       11671 :                         { return nTabPos < rTS.nTabPos; }
      83             : 
      84          22 :     SvxTabStop&     operator=( const SvxTabStop& rTS )
      85             :                         {
      86          22 :                             nTabPos = rTS.nTabPos;
      87          22 :                             eAdjustment = rTS.eAdjustment;
      88          22 :                             m_cDecimal = rTS.m_cDecimal;
      89          22 :                             cFill = rTS.cFill;
      90          22 :                             return *this;
      91             :                         }
      92             : };
      93             : 
      94             : // class SvxTabStopItem --------------------------------------------------
      95             : 
      96             : typedef o3tl::sorted_vector<SvxTabStop> SvxTabStopArr;
      97             : 
      98             : /*  [Description]
      99             : 
     100             :     This item describes a list of TabStops.
     101             : */
     102             : 
     103      116453 : class EDITENG_DLLPUBLIC SvxTabStopItem : public SfxPoolItem
     104             : {
     105             :     SvxTabStopArr maTabStops;
     106             : 
     107             : public:
     108             :     TYPEINFO();
     109             : 
     110             :     explicit SvxTabStopItem( sal_uInt16 nWhich  );
     111             :     SvxTabStopItem( const sal_uInt16 nTabs,
     112             :                     const sal_uInt16 nDist,
     113             :                     const SvxTabAdjust eAdjst /*= SVX_TAB_ADJUST_DEFAULT*/,
     114             :                     sal_uInt16 nWhich  );
     115             :     SvxTabStopItem( const SvxTabStopItem& rTSI );
     116             : 
     117             :     // Returns index of the tab or TAB_NOTFOUND
     118             :     sal_uInt16          GetPos( const SvxTabStop& rTab ) const;
     119             : 
     120             :     // Returns index of the tab at nPos, or TAB_NOTFOUND
     121             :     sal_uInt16          GetPos( const sal_Int32 nPos ) const;
     122             : 
     123             :     // unprivatized:
     124       51038 :     sal_uInt16          Count() const { return maTabStops.size(); }
     125             :     bool                Insert( const SvxTabStop& rTab );
     126             :     void                Insert( const SvxTabStopItem* pTabs, sal_uInt16 nStart = 0,
     127             :                             sal_uInt16 nEnd = USHRT_MAX );
     128             :     void                Remove( SvxTabStop& rTab )
     129             :                         { maTabStops.erase( rTab ); }
     130         690 :     void                Remove( const sal_uInt16 nPos, const sal_uInt16 nLen = 1 )
     131         690 :                         { maTabStops.erase( maTabStops.begin() + nPos, maTabStops.begin() + nPos + nLen ); }
     132             : 
     133             :     // Assignment operator, equality operator (caution: expensive!)
     134             :     SvxTabStopItem& operator=( const SvxTabStopItem& rTSI );
     135             : 
     136             :     // this is already included in SfxPoolItem declaration
     137             :     //int             operator!=( const SvxTabStopItem& rTSI ) const
     138             :     //                  { return !( operator==( rTSI ) ); }
     139             : 
     140       31022 :     const SvxTabStop& operator[]( const sal_uInt16 nPos ) const
     141       31022 :                         { return maTabStops[nPos]; }
     142             : 
     143             :     // "pure virtual Methods" from SfxPoolItem
     144             :     virtual int              operator==( const SfxPoolItem& ) const;
     145             :     virtual bool             QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
     146             :     virtual bool             PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
     147             : 
     148             :     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
     149             :                                     SfxMapUnit eCoreMetric,
     150             :                                     SfxMapUnit ePresMetric,
     151             :                                     OUString &rText, const IntlWrapper * = 0 ) const;
     152             : 
     153             :     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const;
     154             :     virtual SfxPoolItem*     Create( SvStream&, sal_uInt16 ) const;
     155             :     virtual SvStream&        Store( SvStream& , sal_uInt16 nItemVersion ) const;
     156             : 
     157             : };
     158             : 
     159             : #endif
     160             : 
     161             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10