LCOV - code coverage report
Current view: top level - include/editeng - lrspitem.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 54 56 96.4 %
Date: 2014-04-11 Functions: 24 25 96.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_EDITENG_LRSPITEM_HXX
      20             : #define INCLUDED_EDITENG_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      276714 : 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             :     bool        bAutoFirst  : 1;    // Automatic calculation of the first line indent
      60             :     bool        bExplicitZeroMarginValRight;
      61             :     bool        bExplicitZeroMarginValLeft;
      62             : 
      63             :     void   AdjustLeft();        // nLeftMargin and nTxtLeft are being adjusted.
      64             : 
      65             : public:
      66             : 
      67             :     TYPEINFO_OVERRIDE();
      68             : 
      69             :     explicit SvxLRSpaceItem( const sal_uInt16 nId  );
      70             :     SvxLRSpaceItem( const long nLeft, const long nRight,
      71             :                     const long nTLeft /*= 0*/, const short nOfset /*= 0*/,
      72             :                     const sal_uInt16 nId  );
      73             :     inline SvxLRSpaceItem& operator=( const SvxLRSpaceItem &rCpy );
      74             : 
      75             :     // "pure virtual Methods" from SfxPoolItem
      76             :     virtual bool            operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
      77             : 
      78             :     virtual bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
      79             :     virtual bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) SAL_OVERRIDE;
      80             : 
      81             :     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
      82             :                                     SfxMapUnit eCoreMetric,
      83             :                                     SfxMapUnit ePresMetric,
      84             :                                     OUString &rText, const IntlWrapper * = 0 ) const SAL_OVERRIDE;
      85             : 
      86             :     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
      87             :     virtual SfxPoolItem*     Create(SvStream &, sal_uInt16) const SAL_OVERRIDE;
      88             :     virtual SvStream&        Store(SvStream &, sal_uInt16 nItemVersion ) const SAL_OVERRIDE;
      89             :     virtual sal_uInt16           GetVersion( sal_uInt16 nFileVersion ) const SAL_OVERRIDE;
      90             :     virtual bool                 ScaleMetrics( long nMult, long nDiv ) SAL_OVERRIDE;
      91             :     virtual bool                 HasMetrics() const SAL_OVERRIDE;
      92             : 
      93             :     // Die "Layout-Schnittstelle":
      94             :     inline void   SetLeft ( const long nL, const sal_uInt16 nProp = 100 );
      95             :     inline void   SetRight( const long nR, const sal_uInt16 nProp = 100 );
      96             : 
      97             :     // Query/direct setting of the absolute values
      98      402037 :     inline long GetLeft()  const { return nLeftMargin; }
      99      783728 :     inline long GetRight() const { return nRightMargin;}
     100         558 :     inline void SetLeftValue( const long nL ) { nTxtLeft = nLeftMargin = nL; }
     101         558 :     inline void SetRightValue( const long nR ) { nRightMargin = nR; }
     102      152171 :     inline bool IsAutoFirst()  const { return bAutoFirst; }
     103          73 :     inline void SetAutoFirst( const bool bNew ) { bAutoFirst = bNew; }
     104             : 
     105       43457 :     inline bool IsExplicitZeroMarginValRight()  const { return bExplicitZeroMarginValRight; }
     106       38224 :     inline bool IsExplicitZeroMarginValLeft()  const { return bExplicitZeroMarginValLeft; }
     107        4028 :     inline void SetExplicitZeroMarginValRight( const bool eR ) { bExplicitZeroMarginValRight = eR; }
     108        2466 :     inline void SetExplicitZeroMarginValLeft( const bool eL ) { bExplicitZeroMarginValLeft = eL; }
     109             :     // Query/Setting the percentage values
     110             :     inline void SetPropLeft( const sal_uInt16 nProp = 100 )
     111             :                     { nPropLeftMargin = nProp; }
     112             :     inline void SetPropRight( const sal_uInt16 nProp = 100 )
     113             :                     { nPropRightMargin = nProp;}
     114       42784 :     inline sal_uInt16 GetPropLeft()  const { return nPropLeftMargin; }
     115       42782 :     inline sal_uInt16 GetPropRight() const { return nPropRightMargin;}
     116             : 
     117             :     // The UI/text interface:
     118             :     inline void SetTxtLeft( const long nL, const sal_uInt16 nProp = 100 );
     119      887769 :     inline long GetTxtLeft() const { return nTxtLeft; }
     120             : 
     121             :     inline void   SetTxtFirstLineOfst( const short nF, const sal_uInt16 nProp = 100 );
     122      764034 :     inline short  GetTxtFirstLineOfst() const { return nFirstLineOfst; }
     123           0 :     inline void SetPropTxtFirstLineOfst( const sal_uInt16 nProp = 100 )
     124           0 :                     { nPropFirstLineOfst = nProp; }
     125       42783 :     inline sal_uInt16 GetPropTxtFirstLineOfst() const
     126       42783 :                     { return nPropFirstLineOfst; }
     127         996 :     inline void SetTxtFirstLineOfstValue( const short nValue )
     128         996 :                     { nFirstLineOfst = nValue; }
     129             : };
     130             : 
     131        6117 : inline SvxLRSpaceItem &SvxLRSpaceItem::operator=( const SvxLRSpaceItem &rCpy )
     132             : {
     133        6117 :     nFirstLineOfst = rCpy.nFirstLineOfst;
     134        6117 :     nTxtLeft = rCpy.nTxtLeft;
     135        6117 :     nLeftMargin = rCpy.nLeftMargin;
     136        6117 :     nRightMargin = rCpy.nRightMargin;
     137        6117 :     nPropFirstLineOfst = rCpy.nPropFirstLineOfst;
     138        6117 :     nPropLeftMargin = rCpy.nPropLeftMargin;
     139        6117 :     nPropRightMargin = rCpy.nPropRightMargin;
     140        6117 :     bAutoFirst = rCpy.bAutoFirst;
     141        6117 :     bExplicitZeroMarginValRight = rCpy.bExplicitZeroMarginValRight;
     142        6117 :     bExplicitZeroMarginValLeft = rCpy.bExplicitZeroMarginValLeft;
     143        6117 :     return *this;
     144             : }
     145             : 
     146       12513 : inline void SvxLRSpaceItem::SetLeft( const long nL, const sal_uInt16 nProp )
     147             : {
     148       12513 :     nLeftMargin = (nL * nProp) / 100;
     149       12513 :     nTxtLeft = nLeftMargin;
     150       12513 :     nPropLeftMargin = nProp;
     151       12513 : }
     152       14457 : inline void SvxLRSpaceItem::SetRight( const long nR, const sal_uInt16 nProp )
     153             : {
     154       14457 :     if (0 == nR)
     155             :     {
     156        4028 :         SetExplicitZeroMarginValRight(true);
     157             :     }
     158       14457 :     nRightMargin = (nR * nProp) / 100;
     159       14457 :     nPropRightMargin = nProp;
     160       14457 : }
     161        3784 : inline void SvxLRSpaceItem::SetTxtFirstLineOfst( const short nF,
     162             :                                                  const sal_uInt16 nProp )
     163             : {
     164        3784 :     nFirstLineOfst = short((long(nF) * nProp ) / 100);
     165        3784 :     nPropFirstLineOfst = nProp;
     166        3784 :     AdjustLeft();
     167        3784 : }
     168             : 
     169        5555 : inline void SvxLRSpaceItem::SetTxtLeft( const long nL, const sal_uInt16 nProp )
     170             : {
     171        5555 :     if (0 == nL)
     172             :     {
     173        2466 :         SetExplicitZeroMarginValLeft(true);
     174             :     }
     175        5555 :     nTxtLeft = (nL * nProp) / 100;
     176        5555 :     nPropLeftMargin = nProp;
     177        5555 :     AdjustLeft();
     178        5555 : }
     179             : 
     180             : #endif
     181             : 
     182             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10