xref: /aoo41x/main/editeng/inc/editeng/lrspitem.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SVX_LRSPITEM_HXX
28 #define _SVX_LRSPITEM_HXX
29 
30 // include ---------------------------------------------------------------
31 
32 #include <svl/poolitem.hxx>
33 #include <editeng/editengdllapi.h>
34 
35 namespace rtl
36 {
37 	class OUString;
38 }
39 
40 // class SvxLRSpaceItem --------------------------------------------------
41 
42 /*
43 [Beschreibung]
44 Linker/Rechter Rand sowie Erstzeileneinzug
45 
46 SvxLRSpaceItem bietet zwei Schnittstellen zur Befragung des linken
47 Randes und des Erstzeileneinzuges an. Die Get-Methoden liefern
48 die Member zurueck, wie sie das Layout bisher auch erwartete:
49 Der linke Rand verschiebt sich beim negativem Erstzeileneinzug
50 nach links. Die SetTxt/GetTxt-Methoden setzen voraus, dass der
51 linke Rand der 0-Punkt des Erstzeileneinzugs darstellt:
52 
53 	 UI         UI       LAYOUT   UI/TEXT      UI/TEXT    (Wo?)
54 SetTxtLeft SetTxtFirst GetLeft  GetTxtLeft  GetTxtFirst  (Was?)
55 	500       -500        0        500         -500      (Wieviel?)
56 	500         0        500       500           0
57 	500       +500       500       500         +500
58 	700       -500       200       700         -500
59 */
60 
61 #define	LRSPACE_16_VERSION		((sal_uInt16)0x0001)
62 #define	LRSPACE_TXTLEFT_VERSION	((sal_uInt16)0x0002)
63 #define	LRSPACE_AUTOFIRST_VERSION ((sal_uInt16)0x0003)
64 #define	LRSPACE_NEGATIVE_VERSION ((sal_uInt16)0x0004)
65 
66 class EDITENG_DLLPUBLIC SvxLRSpaceItem : public SfxPoolItem
67 {
68 	short	nFirstLineOfst;     // Erstzeileneinzug _immer_ relativ zu nTxtLeft
69 	long	nTxtLeft;           // wir spendieren einen sal_uInt16
70 	long	nLeftMargin;        // nLeft oder der neg. Erstzeileneinzug
71 	long	nRightMargin;		// der unproblematische rechte Rand
72 
73 	sal_uInt16	nPropFirstLineOfst, nPropLeftMargin, nPropRightMargin;
74 	sal_Bool 	bAutoFirst	: 1;	// Automatische Berechnung der Erstzeileneinzugs
75 
76 	void   AdjustLeft();		// nLeftMargin und nTxtLeft werden angepasst.
77 
78 public:
79 	TYPEINFO();
80 
81     SvxLRSpaceItem( const sal_uInt16 nId  );
82 	SvxLRSpaceItem( const long nLeft, const long nRight,
83                     const long nTLeft /*= 0*/, const short nOfset /*= 0*/,
84                     const sal_uInt16 nId  );
85 	inline SvxLRSpaceItem& operator=( const SvxLRSpaceItem &rCpy );
86 
87 	// "pure virtual Methoden" vom SfxPoolItem
88 	virtual int 			 operator==( const SfxPoolItem& ) const;
89 
90 	virtual	sal_Bool        	 QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
91 	virtual	sal_Bool			 PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
92 
93 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
94 									SfxMapUnit eCoreMetric,
95 									SfxMapUnit ePresMetric,
96                                     String &rText, const IntlWrapper * = 0 ) const;
97 
98 	virtual SfxPoolItem*	 Clone( SfxItemPool *pPool = 0 ) const;
99 	virtual SfxPoolItem*	 Create(SvStream &, sal_uInt16) const;
100 	virtual SvStream&		 Store(SvStream &, sal_uInt16 nItemVersion ) const;
101 	virtual sal_uInt16			 GetVersion( sal_uInt16 nFileVersion ) const;
102 	virtual int				 ScaleMetrics( long nMult, long nDiv );
103 	virtual	int				 HasMetrics() const;
104 
105 	// Die "Layout-Schnittstelle":
106 	inline void   SetLeft ( const long nL, const sal_uInt16 nProp = 100 );
107 	inline void   SetRight( const long nR, const sal_uInt16 nProp = 100 );
108 
109 	// abfragen / direktes setzen der absoluten Werte
110 	inline long GetLeft()  const { return nLeftMargin; }
111 	inline long GetRight() const { return nRightMargin;}
112 	inline void SetLeftValue( const long nL ) { nTxtLeft = nLeftMargin = nL; }
113 	inline void SetRightValue( const long nR ) { nRightMargin = nR; }
114 	inline sal_Bool IsAutoFirst()  const { return bAutoFirst; }
115 	inline void SetAutoFirst( const sal_Bool bNew ) { bAutoFirst = bNew; }
116 
117 	// abfragen / setzen der Prozent-Werte
118 	inline void SetPropLeft( const sal_uInt16 nProp = 100 )
119 					{ nPropLeftMargin = nProp; }
120 	inline void SetPropRight( const sal_uInt16 nProp = 100 )
121 					{ nPropRightMargin = nProp;}
122 	inline sal_uInt16 GetPropLeft()  const { return nPropLeftMargin; }
123 	inline sal_uInt16 GetPropRight() const { return nPropRightMargin;}
124 
125 	// Die "UI/Text-Schnittstelle":
126 	inline void SetTxtLeft( const long nL, const sal_uInt16 nProp = 100 );
127 	inline long GetTxtLeft() const { return nTxtLeft; }
128 
129 	inline void   SetTxtFirstLineOfst( const short nF, const sal_uInt16 nProp = 100 );
130 	inline short  GetTxtFirstLineOfst() const { return nFirstLineOfst; }
131 	inline void SetPropTxtFirstLineOfst( const sal_uInt16 nProp = 100 )
132 					{ nPropFirstLineOfst = nProp; }
133 	inline sal_uInt16 GetPropTxtFirstLineOfst() const
134 					{ return nPropFirstLineOfst; }
135 	inline void SetTxtFirstLineOfstValue( const short nValue )
136 					{ nFirstLineOfst = nValue; }
137 };
138 
139 inline SvxLRSpaceItem &SvxLRSpaceItem::operator=( const SvxLRSpaceItem &rCpy )
140 {
141 	nFirstLineOfst = rCpy.nFirstLineOfst;
142 	nTxtLeft = rCpy.nTxtLeft;
143 	nLeftMargin = rCpy.nLeftMargin;
144 	nRightMargin = rCpy.nRightMargin;
145 	nPropFirstLineOfst = rCpy.nPropFirstLineOfst;
146 	nPropLeftMargin = rCpy.nPropLeftMargin;
147 	nPropRightMargin = rCpy.nPropRightMargin;
148 	bAutoFirst = rCpy.bAutoFirst;
149 	return *this;
150 }
151 
152 inline void SvxLRSpaceItem::SetLeft( const long nL, const sal_uInt16 nProp )
153 {
154 	nLeftMargin = (nL * nProp) / 100;
155 	nTxtLeft = nLeftMargin;
156 	nPropLeftMargin = nProp;
157 }
158 inline void SvxLRSpaceItem::SetRight( const long nR, const sal_uInt16 nProp )
159 {
160 	nRightMargin = (nR * nProp) / 100;
161 	nPropRightMargin = nProp;
162 }
163 inline void SvxLRSpaceItem::SetTxtFirstLineOfst( const short nF,
164 												 const sal_uInt16 nProp )
165 {
166 	nFirstLineOfst = short((long(nF) * nProp ) / 100);
167 	nPropFirstLineOfst = nProp;
168 	AdjustLeft();
169 }
170 
171 inline void SvxLRSpaceItem::SetTxtLeft( const long nL, const sal_uInt16 nProp )
172 {
173 	nTxtLeft = (nL * nProp) / 100;
174 	nPropLeftMargin = nProp;
175 	AdjustLeft();
176 }
177 
178 #endif
179 
180