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