LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/editeng - lrspitem.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 44 46 95.7 %
Date: 2012-08-25 Functions: 20 21 95.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #ifndef _SVX_LRSPITEM_HXX
      29                 :            : #define _SVX_LRSPITEM_HXX
      30                 :            : 
      31                 :            : #include <svl/poolitem.hxx>
      32                 :            : #include <editeng/editengdllapi.h>
      33                 :            : 
      34                 :            : namespace rtl
      35                 :            : {
      36                 :            :     class OUString;
      37                 :            : }
      38                 :            : 
      39                 :            : // class SvxLRSpaceItem --------------------------------------------------
      40                 :            : 
      41                 :            : /*  [Description]
      42                 :            : 
      43                 :            :     Left/Right margin and first line indent
      44                 :            : 
      45                 :            :     SvxLRSpaceItem offers two interfaces for views from the left margin and
      46                 :            :     first line indent. The get methods return the member, with the layout also
      47                 :            :     as expected: the left edge shifts to the negative first line indent to the
      48                 :            :     left. The SetTxt/Gettxt methods assume that the left side represents the
      49                 :            :     0 coordinate for the first line indent:
      50                 :            : 
      51                 :            :     UI         UI       LAYOUT   UI/TEXT      UI/TEXT    (Where?)
      52                 :            :     SetTxtLeft SetTxtFirst GetLeft  GetTxtLeft  GetTxtFirst  (What?)
      53                 :            :     500       -500        0        500         -500      (How much?)
      54                 :            :     500         0        500       500           0
      55                 :            :     500       +500       500       500         +500
      56                 :            :     700       -500       200       700         -500
      57                 :            : */
      58                 :            : 
      59                 :            : #define LRSPACE_16_VERSION      ((sal_uInt16)0x0001)
      60                 :            : #define LRSPACE_TXTLEFT_VERSION ((sal_uInt16)0x0002)
      61                 :            : #define LRSPACE_AUTOFIRST_VERSION ((sal_uInt16)0x0003)
      62                 :            : #define LRSPACE_NEGATIVE_VERSION ((sal_uInt16)0x0004)
      63                 :            : 
      64         [ -  + ]:     127937 : class EDITENG_DLLPUBLIC SvxLRSpaceItem : public SfxPoolItem
      65                 :            : {
      66                 :            :     short   nFirstLineOfst;     // First-line indent _always_ relative to nTxtLeft
      67                 :            :     long    nTxtLeft;           // We spend a sal_uInt16
      68                 :            :     long    nLeftMargin;        // nLeft or the negative first-line indent
      69                 :            :     long    nRightMargin;       // The unproblematic right edge
      70                 :            : 
      71                 :            :     sal_uInt16  nPropFirstLineOfst, nPropLeftMargin, nPropRightMargin;
      72                 :            :     sal_Bool    bAutoFirst  : 1;    // Automatic calculation of the first line indent
      73                 :            : 
      74                 :            :     void   AdjustLeft();        // nLeftMargin and nTxtLeft are being adjusted.
      75                 :            : 
      76                 :            : public:
      77                 :            :     TYPEINFO();
      78                 :            : 
      79                 :            :     SvxLRSpaceItem( const sal_uInt16 nId  );
      80                 :            :     SvxLRSpaceItem( const long nLeft, const long nRight,
      81                 :            :                     const long nTLeft /*= 0*/, const short nOfset /*= 0*/,
      82                 :            :                     const sal_uInt16 nId  );
      83                 :            :     inline SvxLRSpaceItem& operator=( const SvxLRSpaceItem &rCpy );
      84                 :            : 
      85                 :            :     // "pure virtual Methods" from SfxPoolItem
      86                 :            :     virtual int              operator==( const SfxPoolItem& ) const;
      87                 :            : 
      88                 :            :     virtual bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
      89                 :            :     virtual bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
      90                 :            : 
      91                 :            :     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
      92                 :            :                                     SfxMapUnit eCoreMetric,
      93                 :            :                                     SfxMapUnit ePresMetric,
      94                 :            :                                     String &rText, const IntlWrapper * = 0 ) const;
      95                 :            : 
      96                 :            :     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const;
      97                 :            :     virtual SfxPoolItem*     Create(SvStream &, sal_uInt16) const;
      98                 :            :     virtual SvStream&        Store(SvStream &, sal_uInt16 nItemVersion ) const;
      99                 :            :     virtual sal_uInt16           GetVersion( sal_uInt16 nFileVersion ) const;
     100                 :            :     virtual bool                 ScaleMetrics( long nMult, long nDiv );
     101                 :            :     virtual bool                 HasMetrics() const;
     102                 :            : 
     103                 :            :     // Die "Layout-Schnittstelle":
     104                 :            :     inline void   SetLeft ( const long nL, const sal_uInt16 nProp = 100 );
     105                 :            :     inline void   SetRight( const long nR, const sal_uInt16 nProp = 100 );
     106                 :            : 
     107                 :            :     // Query/direct setting of the absolute values
     108                 :     222737 :     inline long GetLeft()  const { return nLeftMargin; }
     109                 :     617712 :     inline long GetRight() const { return nRightMargin;}
     110                 :        495 :     inline void SetLeftValue( const long nL ) { nTxtLeft = nLeftMargin = nL; }
     111                 :        495 :     inline void SetRightValue( const long nR ) { nRightMargin = nR; }
     112                 :      99036 :     inline sal_Bool IsAutoFirst()  const { return bAutoFirst; }
     113                 :         76 :     inline void SetAutoFirst( const sal_Bool bNew ) { bAutoFirst = bNew; }
     114                 :            : 
     115                 :            :     // Query/Setting the percentage values
     116                 :            :     inline void SetPropLeft( const sal_uInt16 nProp = 100 )
     117                 :            :                     { nPropLeftMargin = nProp; }
     118                 :            :     inline void SetPropRight( const sal_uInt16 nProp = 100 )
     119                 :            :                     { nPropRightMargin = nProp;}
     120                 :      22384 :     inline sal_uInt16 GetPropLeft()  const { return nPropLeftMargin; }
     121                 :      22382 :     inline sal_uInt16 GetPropRight() const { return nPropRightMargin;}
     122                 :            : 
     123                 :            :     // The UI/text interface:
     124                 :            :     inline void SetTxtLeft( const long nL, const sal_uInt16 nProp = 100 );
     125                 :     707585 :     inline long GetTxtLeft() const { return nTxtLeft; }
     126                 :            : 
     127                 :            :     inline void   SetTxtFirstLineOfst( const short nF, const sal_uInt16 nProp = 100 );
     128                 :     537128 :     inline short  GetTxtFirstLineOfst() const { return nFirstLineOfst; }
     129                 :          0 :     inline void SetPropTxtFirstLineOfst( const sal_uInt16 nProp = 100 )
     130                 :          0 :                     { nPropFirstLineOfst = nProp; }
     131                 :      22368 :     inline sal_uInt16 GetPropTxtFirstLineOfst() const
     132                 :      22368 :                     { return nPropFirstLineOfst; }
     133                 :        369 :     inline void SetTxtFirstLineOfstValue( const short nValue )
     134                 :        369 :                     { nFirstLineOfst = nValue; }
     135                 :            : };
     136                 :            : 
     137                 :       4964 : inline SvxLRSpaceItem &SvxLRSpaceItem::operator=( const SvxLRSpaceItem &rCpy )
     138                 :            : {
     139                 :       4964 :     nFirstLineOfst = rCpy.nFirstLineOfst;
     140                 :       4964 :     nTxtLeft = rCpy.nTxtLeft;
     141                 :       4964 :     nLeftMargin = rCpy.nLeftMargin;
     142                 :       4964 :     nRightMargin = rCpy.nRightMargin;
     143                 :       4964 :     nPropFirstLineOfst = rCpy.nPropFirstLineOfst;
     144                 :       4964 :     nPropLeftMargin = rCpy.nPropLeftMargin;
     145                 :       4964 :     nPropRightMargin = rCpy.nPropRightMargin;
     146                 :       4964 :     bAutoFirst = rCpy.bAutoFirst;
     147                 :       4964 :     return *this;
     148                 :            : }
     149                 :            : 
     150                 :       7364 : inline void SvxLRSpaceItem::SetLeft( const long nL, const sal_uInt16 nProp )
     151                 :            : {
     152                 :       7364 :     nLeftMargin = (nL * nProp) / 100;
     153                 :       7364 :     nTxtLeft = nLeftMargin;
     154                 :       7364 :     nPropLeftMargin = nProp;
     155                 :       7364 : }
     156                 :       8029 : inline void SvxLRSpaceItem::SetRight( const long nR, const sal_uInt16 nProp )
     157                 :            : {
     158                 :       8029 :     nRightMargin = (nR * nProp) / 100;
     159                 :       8029 :     nPropRightMargin = nProp;
     160                 :       8029 : }
     161                 :       1444 : inline void SvxLRSpaceItem::SetTxtFirstLineOfst( const short nF,
     162                 :            :                                                  const sal_uInt16 nProp )
     163                 :            : {
     164                 :       1444 :     nFirstLineOfst = short((long(nF) * nProp ) / 100);
     165                 :       1444 :     nPropFirstLineOfst = nProp;
     166                 :       1444 :     AdjustLeft();
     167                 :       1444 : }
     168                 :            : 
     169                 :       2925 : inline void SvxLRSpaceItem::SetTxtLeft( const long nL, const sal_uInt16 nProp )
     170                 :            : {
     171                 :       2925 :     nTxtLeft = (nL * nProp) / 100;
     172                 :       2925 :     nPropLeftMargin = nProp;
     173                 :       2925 :     AdjustLeft();
     174                 :       2925 : }
     175                 :            : 
     176                 :            : #endif
     177                 :            : 
     178                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10