xref: /AOO41X/main/editeng/inc/editeng/lrspitem.hxx (revision 4c5491ea21520f5347760e8fc7d072f082fcde5f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SVX_LRSPITEM_HXX
24 #define _SVX_LRSPITEM_HXX
25 
26 // include ---------------------------------------------------------------
27 
28 #include <svl/poolitem.hxx>
29 #include <editeng/editengdllapi.h>
30 
31 namespace rtl
32 {
33     class OUString;
34 }
35 
36 // class SvxLRSpaceItem --------------------------------------------------
37 
38 /*
39 [Beschreibung]
40 Linker/Rechter Rand sowie Erstzeileneinzug
41 
42 SvxLRSpaceItem bietet zwei Schnittstellen zur Befragung des linken
43 Randes und des Erstzeileneinzuges an. Die Get-Methoden liefern
44 die Member zurueck, wie sie das Layout bisher auch erwartete:
45 Der linke Rand verschiebt sich beim negativem Erstzeileneinzug
46 nach links. Die SetTxt/GetTxt-Methoden setzen voraus, dass der
47 linke Rand der 0-Punkt des Erstzeileneinzugs darstellt:
48 
49      UI         UI       LAYOUT   UI/TEXT      UI/TEXT    (Wo?)
50 SetTxtLeft SetTxtFirst GetLeft  GetTxtLeft  GetTxtFirst  (Was?)
51     500       -500        0        500         -500      (Wieviel?)
52     500         0        500       500           0
53     500       +500       500       500         +500
54     700       -500       200       700         -500
55 */
56 
57 #define LRSPACE_16_VERSION      ((sal_uInt16)0x0001)
58 #define LRSPACE_TXTLEFT_VERSION ((sal_uInt16)0x0002)
59 #define LRSPACE_AUTOFIRST_VERSION ((sal_uInt16)0x0003)
60 #define LRSPACE_NEGATIVE_VERSION ((sal_uInt16)0x0004)
61 
62 class EDITENG_DLLPUBLIC SvxLRSpaceItem : public SfxPoolItem
63 {
64     short   nFirstLineOfst;     // Erstzeileneinzug _immer_ relativ zu nTxtLeft
65     long    nTxtLeft;           // wir spendieren einen sal_uInt16
66     long    nLeftMargin;        // nLeft oder der neg. Erstzeileneinzug
67     long    nRightMargin;       // der unproblematische rechte Rand
68 
69     sal_uInt16  nPropFirstLineOfst, nPropLeftMargin, nPropRightMargin;
70     sal_Bool    bAutoFirst  : 1;    // Automatische Berechnung der Erstzeileneinzugs
71 
72     void   AdjustLeft();        // nLeftMargin und nTxtLeft werden angepasst.
73 
74 public:
75     TYPEINFO();
76 
77     SvxLRSpaceItem( const sal_uInt16 nId  );
78     SvxLRSpaceItem( const long nLeft, const long nRight,
79                     const long nTLeft /*= 0*/, const short nOfset /*= 0*/,
80                     const sal_uInt16 nId  );
81     inline SvxLRSpaceItem& operator=( const SvxLRSpaceItem &rCpy );
82 
83     // "pure virtual Methoden" vom SfxPoolItem
84     virtual int              operator==( const SfxPoolItem& ) const;
85 
86     virtual sal_Bool             QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
87     virtual sal_Bool             PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
88 
89     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
90                                     SfxMapUnit eCoreMetric,
91                                     SfxMapUnit ePresMetric,
92                                     String &rText, const IntlWrapper * = 0 ) const;
93 
94     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const;
95     virtual SfxPoolItem*     Create(SvStream &, sal_uInt16) const;
96     virtual SvStream&        Store(SvStream &, sal_uInt16 nItemVersion ) const;
97     virtual sal_uInt16           GetVersion( sal_uInt16 nFileVersion ) const;
98     virtual int              ScaleMetrics( long nMult, long nDiv );
99     virtual int              HasMetrics() const;
100 
101     // Die "Layout-Schnittstelle":
102     inline void   SetLeft ( const long nL, const sal_uInt16 nProp = 100 );
103     inline void   SetRight( const long nR, const sal_uInt16 nProp = 100 );
104 
105     // abfragen / direktes setzen der absoluten Werte
GetLeft() const106     inline long GetLeft()  const { return nLeftMargin; }
GetRight() const107     inline long GetRight() const { return nRightMargin;}
SetLeftValue(const long nL)108     inline void SetLeftValue( const long nL ) { nTxtLeft = nLeftMargin = nL; }
SetRightValue(const long nR)109     inline void SetRightValue( const long nR ) { nRightMargin = nR; }
IsAutoFirst() const110     inline sal_Bool IsAutoFirst()  const { return bAutoFirst; }
SetAutoFirst(const sal_Bool bNew)111     inline void SetAutoFirst( const sal_Bool bNew ) { bAutoFirst = bNew; }
112 
113     // abfragen / setzen der Prozent-Werte
SetPropLeft(const sal_uInt16 nProp=100)114     inline void SetPropLeft( const sal_uInt16 nProp = 100 )
115                     { nPropLeftMargin = nProp; }
SetPropRight(const sal_uInt16 nProp=100)116     inline void SetPropRight( const sal_uInt16 nProp = 100 )
117                     { nPropRightMargin = nProp;}
GetPropLeft() const118     inline sal_uInt16 GetPropLeft()  const { return nPropLeftMargin; }
GetPropRight() const119     inline sal_uInt16 GetPropRight() const { return nPropRightMargin;}
120 
121     // Die "UI/Text-Schnittstelle":
122     inline void SetTxtLeft( const long nL, const sal_uInt16 nProp = 100 );
GetTxtLeft() const123     inline long GetTxtLeft() const { return nTxtLeft; }
124 
125     inline void   SetTxtFirstLineOfst( const short nF, const sal_uInt16 nProp = 100 );
GetTxtFirstLineOfst() const126     inline short  GetTxtFirstLineOfst() const { return nFirstLineOfst; }
SetPropTxtFirstLineOfst(const sal_uInt16 nProp=100)127     inline void SetPropTxtFirstLineOfst( const sal_uInt16 nProp = 100 )
128                     { nPropFirstLineOfst = nProp; }
GetPropTxtFirstLineOfst() const129     inline sal_uInt16 GetPropTxtFirstLineOfst() const
130                     { return nPropFirstLineOfst; }
SetTxtFirstLineOfstValue(const short nValue)131     inline void SetTxtFirstLineOfstValue( const short nValue )
132                     { nFirstLineOfst = nValue; }
133 };
134 
operator =(const SvxLRSpaceItem & rCpy)135 inline SvxLRSpaceItem &SvxLRSpaceItem::operator=( const SvxLRSpaceItem &rCpy )
136 {
137     nFirstLineOfst = rCpy.nFirstLineOfst;
138     nTxtLeft = rCpy.nTxtLeft;
139     nLeftMargin = rCpy.nLeftMargin;
140     nRightMargin = rCpy.nRightMargin;
141     nPropFirstLineOfst = rCpy.nPropFirstLineOfst;
142     nPropLeftMargin = rCpy.nPropLeftMargin;
143     nPropRightMargin = rCpy.nPropRightMargin;
144     bAutoFirst = rCpy.bAutoFirst;
145     return *this;
146 }
147 
SetLeft(const long nL,const sal_uInt16 nProp)148 inline void SvxLRSpaceItem::SetLeft( const long nL, const sal_uInt16 nProp )
149 {
150     nLeftMargin = (nL * nProp) / 100;
151     nTxtLeft = nLeftMargin;
152     nPropLeftMargin = nProp;
153 }
SetRight(const long nR,const sal_uInt16 nProp)154 inline void SvxLRSpaceItem::SetRight( const long nR, const sal_uInt16 nProp )
155 {
156     nRightMargin = (nR * nProp) / 100;
157     nPropRightMargin = nProp;
158 }
SetTxtFirstLineOfst(const short nF,const sal_uInt16 nProp)159 inline void SvxLRSpaceItem::SetTxtFirstLineOfst( const short nF,
160                                                  const sal_uInt16 nProp )
161 {
162     nFirstLineOfst = short((long(nF) * nProp ) / 100);
163     nPropFirstLineOfst = nProp;
164     AdjustLeft();
165 }
166 
SetTxtLeft(const long nL,const sal_uInt16 nProp)167 inline void SvxLRSpaceItem::SetTxtLeft( const long nL, const sal_uInt16 nProp )
168 {
169     nTxtLeft = (nL * nProp) / 100;
170     nPropLeftMargin = nProp;
171     AdjustLeft();
172 }
173 
174 #endif
175 
176