LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/editeng - lrspitem.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 44 46 95.7 %
Date: 2013-07-09 Functions: 20 21 95.2 %
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_LRSPITEM_HXX
      20             : #define _SVX_LRSPITEM_HXX
      21             : 
      22             : #include <svl/poolitem.hxx>
      23             : #include <editeng/editengdllapi.h>
      24             : 
      25             : 
      26             : // class SvxLRSpaceItem --------------------------------------------------
      27             : 
      28             : /*  [Description]
      29             : 
      30             :     Left/Right margin and first line indent
      31             : 
      32             :     SvxLRSpaceItem offers two interfaces for views from the left margin and
      33             :     first line indent. The get methods return the member, with the layout also
      34             :     as expected: the left edge shifts to the negative first line indent to the
      35             :     left. The SetTxt/Gettxt methods assume that the left side represents the
      36             :     0 coordinate for the first line indent:
      37             : 
      38             :     UI         UI       LAYOUT   UI/TEXT      UI/TEXT    (Where?)
      39             :     SetTxtLeft SetTxtFirst GetLeft  GetTxtLeft  GetTxtFirst  (What?)
      40             :     500       -500        0        500         -500      (How much?)
      41             :     500         0        500       500           0
      42             :     500       +500       500       500         +500
      43             :     700       -500       200       700         -500
      44             : */
      45             : 
      46             : #define LRSPACE_16_VERSION      ((sal_uInt16)0x0001)
      47             : #define LRSPACE_TXTLEFT_VERSION ((sal_uInt16)0x0002)
      48             : #define LRSPACE_AUTOFIRST_VERSION ((sal_uInt16)0x0003)
      49             : #define LRSPACE_NEGATIVE_VERSION ((sal_uInt16)0x0004)
      50             : 
      51       84879 : class EDITENG_DLLPUBLIC SvxLRSpaceItem : public SfxPoolItem
      52             : {
      53             :     short   nFirstLineOfst;     // First-line indent _always_ relative to nTxtLeft
      54             :     long    nTxtLeft;           // We spend a sal_uInt16
      55             :     long    nLeftMargin;        // nLeft or the negative first-line indent
      56             :     long    nRightMargin;       // The unproblematic right edge
      57             : 
      58             :     sal_uInt16  nPropFirstLineOfst, nPropLeftMargin, nPropRightMargin;
      59             :     sal_Bool    bAutoFirst  : 1;    // Automatic calculation of the first line indent
      60             : 
      61             :     void   AdjustLeft();        // nLeftMargin and nTxtLeft are being adjusted.
      62             : 
      63             : public:
      64             :     TYPEINFO();
      65             : 
      66             :     explicit SvxLRSpaceItem( const sal_uInt16 nId  );
      67             :     SvxLRSpaceItem( const long nLeft, const long nRight,
      68             :                     const long nTLeft /*= 0*/, const short nOfset /*= 0*/,
      69             :                     const sal_uInt16 nId  );
      70             :     inline SvxLRSpaceItem& operator=( const SvxLRSpaceItem &rCpy );
      71             : 
      72             :     // "pure virtual Methods" from SfxPoolItem
      73             :     virtual int              operator==( const SfxPoolItem& ) const;
      74             : 
      75             :     virtual bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
      76             :     virtual bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
      77             : 
      78             :     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
      79             :                                     SfxMapUnit eCoreMetric,
      80             :                                     SfxMapUnit ePresMetric,
      81             :                                     OUString &rText, const IntlWrapper * = 0 ) const;
      82             : 
      83             :     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const;
      84             :     virtual SfxPoolItem*     Create(SvStream &, sal_uInt16) const;
      85             :     virtual SvStream&        Store(SvStream &, sal_uInt16 nItemVersion ) const;
      86             :     virtual sal_uInt16           GetVersion( sal_uInt16 nFileVersion ) const;
      87             :     virtual bool                 ScaleMetrics( long nMult, long nDiv );
      88             :     virtual bool                 HasMetrics() const;
      89             : 
      90             :     // Die "Layout-Schnittstelle":
      91             :     inline void   SetLeft ( const long nL, const sal_uInt16 nProp = 100 );
      92             :     inline void   SetRight( const long nR, const sal_uInt16 nProp = 100 );
      93             : 
      94             :     // Query/direct setting of the absolute values
      95      125517 :     inline long GetLeft()  const { return nLeftMargin; }
      96      611962 :     inline long GetRight() const { return nRightMargin;}
      97         468 :     inline void SetLeftValue( const long nL ) { nTxtLeft = nLeftMargin = nL; }
      98         468 :     inline void SetRightValue( const long nR ) { nRightMargin = nR; }
      99       52848 :     inline sal_Bool IsAutoFirst()  const { return bAutoFirst; }
     100          38 :     inline void SetAutoFirst( const sal_Bool bNew ) { bAutoFirst = bNew; }
     101             : 
     102             :     // Query/Setting the percentage values
     103             :     inline void SetPropLeft( const sal_uInt16 nProp = 100 )
     104             :                     { nPropLeftMargin = nProp; }
     105             :     inline void SetPropRight( const sal_uInt16 nProp = 100 )
     106             :                     { nPropRightMargin = nProp;}
     107       13335 :     inline sal_uInt16 GetPropLeft()  const { return nPropLeftMargin; }
     108       13335 :     inline sal_uInt16 GetPropRight() const { return nPropRightMargin;}
     109             : 
     110             :     // The UI/text interface:
     111             :     inline void SetTxtLeft( const long nL, const sal_uInt16 nProp = 100 );
     112      735399 :     inline long GetTxtLeft() const { return nTxtLeft; }
     113             : 
     114             :     inline void   SetTxtFirstLineOfst( const short nF, const sal_uInt16 nProp = 100 );
     115      738649 :     inline short  GetTxtFirstLineOfst() const { return nFirstLineOfst; }
     116           0 :     inline void SetPropTxtFirstLineOfst( const sal_uInt16 nProp = 100 )
     117           0 :                     { nPropFirstLineOfst = nProp; }
     118       13328 :     inline sal_uInt16 GetPropTxtFirstLineOfst() const
     119       13328 :                     { return nPropFirstLineOfst; }
     120         933 :     inline void SetTxtFirstLineOfstValue( const short nValue )
     121         933 :                     { nFirstLineOfst = nValue; }
     122             : };
     123             : 
     124        2768 : inline SvxLRSpaceItem &SvxLRSpaceItem::operator=( const SvxLRSpaceItem &rCpy )
     125             : {
     126        2768 :     nFirstLineOfst = rCpy.nFirstLineOfst;
     127        2768 :     nTxtLeft = rCpy.nTxtLeft;
     128        2768 :     nLeftMargin = rCpy.nLeftMargin;
     129        2768 :     nRightMargin = rCpy.nRightMargin;
     130        2768 :     nPropFirstLineOfst = rCpy.nPropFirstLineOfst;
     131        2768 :     nPropLeftMargin = rCpy.nPropLeftMargin;
     132        2768 :     nPropRightMargin = rCpy.nPropRightMargin;
     133        2768 :     bAutoFirst = rCpy.bAutoFirst;
     134        2768 :     return *this;
     135             : }
     136             : 
     137        4888 : inline void SvxLRSpaceItem::SetLeft( const long nL, const sal_uInt16 nProp )
     138             : {
     139        4888 :     nLeftMargin = (nL * nProp) / 100;
     140        4888 :     nTxtLeft = nLeftMargin;
     141        4888 :     nPropLeftMargin = nProp;
     142        4888 : }
     143        4867 : inline void SvxLRSpaceItem::SetRight( const long nR, const sal_uInt16 nProp )
     144             : {
     145        4867 :     nRightMargin = (nR * nProp) / 100;
     146        4867 :     nPropRightMargin = nProp;
     147        4867 : }
     148         851 : inline void SvxLRSpaceItem::SetTxtFirstLineOfst( const short nF,
     149             :                                                  const sal_uInt16 nProp )
     150             : {
     151         851 :     nFirstLineOfst = short((long(nF) * nProp ) / 100);
     152         851 :     nPropFirstLineOfst = nProp;
     153         851 :     AdjustLeft();
     154         851 : }
     155             : 
     156        1923 : inline void SvxLRSpaceItem::SetTxtLeft( const long nL, const sal_uInt16 nProp )
     157             : {
     158        1923 :     nTxtLeft = (nL * nProp) / 100;
     159        1923 :     nPropLeftMargin = nProp;
     160        1923 :     AdjustLeft();
     161        1923 : }
     162             : 
     163             : #endif
     164             : 
     165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10