xref: /aoo41x/main/editeng/inc/editeng/boxitem.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_BOXITEM_HXX
28 #define _SVX_BOXITEM_HXX
29 
30 #include <svl/poolitem.hxx>
31 #include <editeng/borderline.hxx>
32 #include <editeng/editengdllapi.h>
33 #include <com/sun/star/table/BorderLine.hpp>
34 
35 namespace rtl { class OUString; }
36 
37 // class SvxBoxItem ------------------------------------------------------
38 
39 /*
40 [Beschreibung]
41 Dieses Item beschreibt ein Umrandungsattribut (alle vier Kanten und
42 Abstand nach innen.
43 */
44 
45 #define BOX_LINE_TOP	((sal_uInt16)0)
46 #define BOX_LINE_BOTTOM	((sal_uInt16)1)
47 #define BOX_LINE_LEFT	((sal_uInt16)2)
48 #define BOX_LINE_RIGHT	((sal_uInt16)3)
49 
50 #define BOX_4DISTS_VERSION ((sal_uInt16)1)
51 
52 class EDITENG_DLLPUBLIC SvxBoxItem : public SfxPoolItem
53 {
54 	SvxBorderLine  *pTop,
55 				   *pBottom,
56 				   *pLeft,
57 				   *pRight;
58 	sal_uInt16			nTopDist,
59 					nBottomDist,
60 					nLeftDist,
61 					nRightDist;
62 
63 public:
64 	TYPEINFO();
65 
66     SvxBoxItem( const sal_uInt16 nId );
67 	SvxBoxItem( const SvxBoxItem &rCpy );
68 	~SvxBoxItem();
69 	SvxBoxItem &operator=( const SvxBoxItem& rBox );
70 
71 	// "pure virtual Methoden" vom SfxPoolItem
72 	virtual int 			 operator==( const SfxPoolItem& ) const;
73 	virtual	sal_Bool        	 QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
74 	virtual	sal_Bool			 PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
75 
76 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
77 									SfxMapUnit eCoreMetric,
78 									SfxMapUnit ePresMetric,
79                                     String &rText, const IntlWrapper * = 0 ) const;
80 
81 	virtual SfxPoolItem*	 Clone( SfxItemPool *pPool = 0 ) const;
82 	virtual SfxPoolItem*	 Create(SvStream &, sal_uInt16) const;
83 	virtual SvStream&		 Store(SvStream &, sal_uInt16 nItemVersion ) const;
84 	virtual sal_uInt16			 GetVersion( sal_uInt16 nFileVersion ) const;
85 
86 	virtual int				 ScaleMetrics( long nMult, long nDiv );
87 	virtual	int				 HasMetrics() const;
88 
89 	const	SvxBorderLine* GetTop()    const { return pTop; }
90 	const	SvxBorderLine* GetBottom() const { return pBottom; }
91 	const	SvxBorderLine* GetLeft()   const { return pLeft; }
92 	const	SvxBorderLine* GetRight()  const { return pRight; }
93 
94 	const	SvxBorderLine* GetLine( sal_uInt16 nLine ) const;
95 
96 		//Die Pointer werden kopiert!
97 	void	SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine );
98 
99 	sal_uInt16	GetDistance( sal_uInt16 nLine ) const;
100 	sal_uInt16	GetDistance() const;
101 
102 	void 	SetDistance( sal_uInt16 nNew, sal_uInt16 nLine );
103 	inline void SetDistance( sal_uInt16 nNew );
104 
105 		//Breite der Linien plus Zwischenraum plus Abstand nach innen.
106 		//JP 09.06.99: bIgnoreLine = sal_True -> Distance auch returnen, wenn
107 		//							keine Line gesetzt ist
108 	sal_uInt16 	CalcLineSpace( sal_uInt16 nLine, sal_Bool bIgnoreLine = sal_False ) const;
109     static com::sun::star::table::BorderLine SvxLineToLine( const SvxBorderLine* pLine, sal_Bool bConvert );
110     static sal_Bool LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert);
111 };
112 
113 inline void SvxBoxItem::SetDistance( sal_uInt16 nNew )
114 {
115 	nTopDist = nBottomDist = nLeftDist = nRightDist = nNew;
116 }
117 
118 // class SvxBoxInfoItem --------------------------------------------------
119 
120 /*
121 [Beschreibung]
122 Noch ein Item fuer die Umrandung. Dieses Item hat lediglich SS-Funktionalitaet.
123 Einerseits wird dem allgemeinen Dialog mit diesem Item mitgeteilt, welche
124 Moeglichkeiten er anbieten soll.
125 Andererseits werden ueber dieses Attribut ggf. die BorderLines fuer die
126 horizontalen und vertikalen innerern Linien transportiert.
127 */
128 
129 #define BOXINFO_LINE_HORI	((sal_uInt16)0)
130 #define BOXINFO_LINE_VERT	((sal_uInt16)1)
131 
132 #define VALID_TOP			0x01
133 #define VALID_BOTTOM		0x02
134 #define VALID_LEFT			0x04
135 #define VALID_RIGHT			0x08
136 #define VALID_HORI			0x10
137 #define VALID_VERT			0x20
138 #define VALID_DISTANCE		0x40
139 #define VALID_DISABLE		0x80
140 
141 class EDITENG_DLLPUBLIC SvxBoxInfoItem : public SfxPoolItem
142 {
143 	SvxBorderLine* pHori;   //innere horizontale Linie
144 	SvxBorderLine* pVert;   //innere vertikale Linie
145 
146     bool                mbEnableHor;   /// true = Enable inner horizonal line.
147     bool                mbEnableVer;   /// true = Enable inner vertical line.
148 
149 	/*
150 	 z.Z. nur fuer StarWriter: Abstand nach innen von SvxBoxItem.
151 	 Wenn der Abstand gewuenscht ist, so muss das Feld fuer den Abstand vom
152 	 Dialog freigeschaltet werden. nDefDist ist als Defaultwert anzusehen.
153 	 Wenn irgendeine	Linie eingeschalt ist oder wird, so muss dieser
154 	 Abstand defaultet werden. bMinDist gibt an, ob der Wert durch den
155 	 Anwender unterschritten werden darf. Mit nDist wird der aktuelle
156 	 Abstand von der App zum Dialog und zurueck transportiert.
157 	*/
158 
159 	sal_Bool	bDist      :1;  // sal_True, Abstand freischalten.
160 	sal_Bool	bMinDist   :1;  // sal_True, Abstand darf nicht unterschritten werden.
161 
162 	sal_uInt8	nValidFlags;	// 0000 0000
163 							// ���� ����� VALID_TOP
164 							// ���� ����� VALID_BOTTOM
165 							// ���� ����� VALID_LEFT
166 							// ���� ����� VALID_RIGHT
167 							// ���������� VALID_HORI
168 							// ���������� VALID_VERT
169 							// ���������� VALID_DIST
170 							// ���������� VALID_DISABLE
171 
172 	sal_uInt16	nDefDist;       // Der Default- bzw. Minimalabstand.
173 
174 public:
175 	TYPEINFO();
176 
177     SvxBoxInfoItem( const sal_uInt16 nId );
178 	SvxBoxInfoItem( const SvxBoxInfoItem &rCpy );
179 	~SvxBoxInfoItem();
180 	SvxBoxInfoItem &operator=( const SvxBoxInfoItem &rCpy );
181 
182 	// "pure virtual Methoden" vom SfxPoolItem
183 	virtual int 			 operator==( const SfxPoolItem& ) const;
184 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
185 									SfxMapUnit eCoreMetric,
186 									SfxMapUnit ePresMetric,
187                                     String &rText, const IntlWrapper * = 0 ) const;
188 	virtual	sal_Bool        	 QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
189 	virtual	sal_Bool			 PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
190 
191 	virtual SfxPoolItem*	Clone( SfxItemPool *pPool = 0 ) const;
192 	virtual SfxPoolItem*	Create(SvStream &, sal_uInt16) const;
193 	virtual SvStream&		Store(SvStream &, sal_uInt16 nItemVersion ) const;
194 	virtual int				 ScaleMetrics( long nMult, long nDiv );
195 	virtual	int				 HasMetrics() const;
196 
197 	const SvxBorderLine*	GetHori() const { return pHori; }
198 	const SvxBorderLine*	GetVert() const { return pVert; }
199 
200 	//Die Pointer werden kopiert!
201 	void					SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine );
202 
203     sal_Bool    IsTable() const             { return mbEnableHor && mbEnableVer; }
204     void    SetTable( sal_Bool bNew )       { mbEnableHor = mbEnableVer = bNew; }
205 
206     inline bool         IsHorEnabled() const { return mbEnableHor; }
207     inline void         EnableHor( bool bEnable ) { mbEnableHor = bEnable; }
208     inline bool         IsVerEnabled() const { return mbEnableVer; }
209     inline void         EnableVer( bool bEnable ) { mbEnableVer = bEnable; }
210 
211 	sal_Bool 	IsDist() const				{ return bDist; }
212 	void 	SetDist( sal_Bool bNew )		{ bDist = bNew; }
213 	sal_Bool 	IsMinDist() const			{ return bMinDist; }
214 	void 	SetMinDist( sal_Bool bNew )		{ bMinDist = bNew; }
215 	sal_uInt16	GetDefDist() const			{ return nDefDist; }
216 	void 	SetDefDist( sal_uInt16 nNew )	{ nDefDist = nNew; }
217 
218 	sal_Bool					IsValid( sal_uInt8 nValid ) const
219 								{ return ( nValidFlags & nValid ) == nValid; }
220 	void 					SetValid( sal_uInt8 nValid, sal_Bool bValid = sal_True )
221 								{ bValid ? ( nValidFlags |= nValid )
222 										 : ( nValidFlags &= ~nValid ); }
223 	void					ResetFlags();
224 };
225 #endif
226 
227