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-17 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       65649 : 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       70365 :     inline long GetLeft()  const { return nLeftMargin; }
     100       97237 :     inline long GetRight() const { return nRightMargin;}
     101         486 :     inline void SetLeftValue( const long nL ) { nTxtLeft = nLeftMargin = nL; }
     102         486 :     inline void SetRightValue( const long nR ) { nRightMargin = nR; }
     103       22085 :     inline sal_Bool IsAutoFirst()  const { return bAutoFirst; }
     104          34 :     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       12435 :     inline sal_uInt16 GetPropLeft()  const { return nPropLeftMargin; }
     112       12435 :     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       88499 :     inline long GetTxtLeft() const { return nTxtLeft; }
     117             : 
     118             :     inline void   SetTxtFirstLineOfst( const short nF, const sal_uInt16 nProp = 100 );
     119       92164 :     inline short  GetTxtFirstLineOfst() const { return nFirstLineOfst; }
     120           0 :     inline void SetPropTxtFirstLineOfst( const sal_uInt16 nProp = 100 )
     121           0 :                     { nPropFirstLineOfst = nProp; }
     122       12435 :     inline sal_uInt16 GetPropTxtFirstLineOfst() const
     123       12435 :                     { return nPropFirstLineOfst; }
     124        1698 :     inline void SetTxtFirstLineOfstValue( const short nValue )
     125        1698 :                     { nFirstLineOfst = nValue; }
     126             : };
     127             : 
     128        4659 : inline SvxLRSpaceItem &SvxLRSpaceItem::operator=( const SvxLRSpaceItem &rCpy )
     129             : {
     130        4659 :     nFirstLineOfst = rCpy.nFirstLineOfst;
     131        4659 :     nTxtLeft = rCpy.nTxtLeft;
     132        4659 :     nLeftMargin = rCpy.nLeftMargin;
     133        4659 :     nRightMargin = rCpy.nRightMargin;
     134        4659 :     nPropFirstLineOfst = rCpy.nPropFirstLineOfst;
     135        4659 :     nPropLeftMargin = rCpy.nPropLeftMargin;
     136        4659 :     nPropRightMargin = rCpy.nPropRightMargin;
     137        4659 :     bAutoFirst = rCpy.bAutoFirst;
     138        4659 :     return *this;
     139             : }
     140             : 
     141        4791 : inline void SvxLRSpaceItem::SetLeft( const long nL, const sal_uInt16 nProp )
     142             : {
     143        4791 :     nLeftMargin = (nL * nProp) / 100;
     144        4791 :     nTxtLeft = nLeftMargin;
     145        4791 :     nPropLeftMargin = nProp;
     146        4791 : }
     147        3817 : inline void SvxLRSpaceItem::SetRight( const long nR, const sal_uInt16 nProp )
     148             : {
     149        3817 :     nRightMargin = (nR * nProp) / 100;
     150        3817 :     nPropRightMargin = nProp;
     151        3817 : }
     152         928 : inline void SvxLRSpaceItem::SetTxtFirstLineOfst( const short nF,
     153             :                                                  const sal_uInt16 nProp )
     154             : {
     155         928 :     nFirstLineOfst = short((long(nF) * nProp ) / 100);
     156         928 :     nPropFirstLineOfst = nProp;
     157         928 :     AdjustLeft();
     158         928 : }
     159             : 
     160        2050 : inline void SvxLRSpaceItem::SetTxtLeft( const long nL, const sal_uInt16 nProp )
     161             : {
     162        2050 :     nTxtLeft = (nL * nProp) / 100;
     163        2050 :     nPropLeftMargin = nProp;
     164        2050 :     AdjustLeft();
     165        2050 : }
     166             : 
     167             : #endif
     168             : 
     169             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10