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

Generated by: LCOV version 1.10