xref: /aoo41x/main/editeng/inc/editeng/boxitem.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _SVX_BOXITEM_HXX
28*cdf0e10cSrcweir #define _SVX_BOXITEM_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <svl/poolitem.hxx>
31*cdf0e10cSrcweir #include <editeng/borderline.hxx>
32*cdf0e10cSrcweir #include <editeng/editengdllapi.h>
33*cdf0e10cSrcweir #include <com/sun/star/table/BorderLine.hpp>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir namespace rtl { class OUString; }
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir // class SvxBoxItem ------------------------------------------------------
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir /*
40*cdf0e10cSrcweir [Beschreibung]
41*cdf0e10cSrcweir Dieses Item beschreibt ein Umrandungsattribut (alle vier Kanten und
42*cdf0e10cSrcweir Abstand nach innen.
43*cdf0e10cSrcweir */
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #define BOX_LINE_TOP	((sal_uInt16)0)
46*cdf0e10cSrcweir #define BOX_LINE_BOTTOM	((sal_uInt16)1)
47*cdf0e10cSrcweir #define BOX_LINE_LEFT	((sal_uInt16)2)
48*cdf0e10cSrcweir #define BOX_LINE_RIGHT	((sal_uInt16)3)
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #define BOX_4DISTS_VERSION ((sal_uInt16)1)
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir class EDITENG_DLLPUBLIC SvxBoxItem : public SfxPoolItem
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir 	SvxBorderLine  *pTop,
55*cdf0e10cSrcweir 				   *pBottom,
56*cdf0e10cSrcweir 				   *pLeft,
57*cdf0e10cSrcweir 				   *pRight;
58*cdf0e10cSrcweir 	sal_uInt16			nTopDist,
59*cdf0e10cSrcweir 					nBottomDist,
60*cdf0e10cSrcweir 					nLeftDist,
61*cdf0e10cSrcweir 					nRightDist;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir public:
64*cdf0e10cSrcweir 	TYPEINFO();
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir     SvxBoxItem( const sal_uInt16 nId );
67*cdf0e10cSrcweir 	SvxBoxItem( const SvxBoxItem &rCpy );
68*cdf0e10cSrcweir 	~SvxBoxItem();
69*cdf0e10cSrcweir 	SvxBoxItem &operator=( const SvxBoxItem& rBox );
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 	// "pure virtual Methoden" vom SfxPoolItem
72*cdf0e10cSrcweir 	virtual int 			 operator==( const SfxPoolItem& ) const;
73*cdf0e10cSrcweir 	virtual	sal_Bool        	 QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
74*cdf0e10cSrcweir 	virtual	sal_Bool			 PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
77*cdf0e10cSrcweir 									SfxMapUnit eCoreMetric,
78*cdf0e10cSrcweir 									SfxMapUnit ePresMetric,
79*cdf0e10cSrcweir                                     String &rText, const IntlWrapper * = 0 ) const;
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 	virtual SfxPoolItem*	 Clone( SfxItemPool *pPool = 0 ) const;
82*cdf0e10cSrcweir 	virtual SfxPoolItem*	 Create(SvStream &, sal_uInt16) const;
83*cdf0e10cSrcweir 	virtual SvStream&		 Store(SvStream &, sal_uInt16 nItemVersion ) const;
84*cdf0e10cSrcweir 	virtual sal_uInt16			 GetVersion( sal_uInt16 nFileVersion ) const;
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	virtual int				 ScaleMetrics( long nMult, long nDiv );
87*cdf0e10cSrcweir 	virtual	int				 HasMetrics() const;
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 	const	SvxBorderLine* GetTop()    const { return pTop; }
90*cdf0e10cSrcweir 	const	SvxBorderLine* GetBottom() const { return pBottom; }
91*cdf0e10cSrcweir 	const	SvxBorderLine* GetLeft()   const { return pLeft; }
92*cdf0e10cSrcweir 	const	SvxBorderLine* GetRight()  const { return pRight; }
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 	const	SvxBorderLine* GetLine( sal_uInt16 nLine ) const;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 		//Die Pointer werden kopiert!
97*cdf0e10cSrcweir 	void	SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine );
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 	sal_uInt16	GetDistance( sal_uInt16 nLine ) const;
100*cdf0e10cSrcweir 	sal_uInt16	GetDistance() const;
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	void 	SetDistance( sal_uInt16 nNew, sal_uInt16 nLine );
103*cdf0e10cSrcweir 	inline void SetDistance( sal_uInt16 nNew );
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 		//Breite der Linien plus Zwischenraum plus Abstand nach innen.
106*cdf0e10cSrcweir 		//JP 09.06.99: bIgnoreLine = sal_True -> Distance auch returnen, wenn
107*cdf0e10cSrcweir 		//							keine Line gesetzt ist
108*cdf0e10cSrcweir 	sal_uInt16 	CalcLineSpace( sal_uInt16 nLine, sal_Bool bIgnoreLine = sal_False ) const;
109*cdf0e10cSrcweir     static com::sun::star::table::BorderLine SvxLineToLine( const SvxBorderLine* pLine, sal_Bool bConvert );
110*cdf0e10cSrcweir     static sal_Bool LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert);
111*cdf0e10cSrcweir };
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir inline void SvxBoxItem::SetDistance( sal_uInt16 nNew )
114*cdf0e10cSrcweir {
115*cdf0e10cSrcweir 	nTopDist = nBottomDist = nLeftDist = nRightDist = nNew;
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir // class SvxBoxInfoItem --------------------------------------------------
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir /*
121*cdf0e10cSrcweir [Beschreibung]
122*cdf0e10cSrcweir Noch ein Item fuer die Umrandung. Dieses Item hat lediglich SS-Funktionalitaet.
123*cdf0e10cSrcweir Einerseits wird dem allgemeinen Dialog mit diesem Item mitgeteilt, welche
124*cdf0e10cSrcweir Moeglichkeiten er anbieten soll.
125*cdf0e10cSrcweir Andererseits werden ueber dieses Attribut ggf. die BorderLines fuer die
126*cdf0e10cSrcweir horizontalen und vertikalen innerern Linien transportiert.
127*cdf0e10cSrcweir */
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir #define BOXINFO_LINE_HORI	((sal_uInt16)0)
130*cdf0e10cSrcweir #define BOXINFO_LINE_VERT	((sal_uInt16)1)
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir #define VALID_TOP			0x01
133*cdf0e10cSrcweir #define VALID_BOTTOM		0x02
134*cdf0e10cSrcweir #define VALID_LEFT			0x04
135*cdf0e10cSrcweir #define VALID_RIGHT			0x08
136*cdf0e10cSrcweir #define VALID_HORI			0x10
137*cdf0e10cSrcweir #define VALID_VERT			0x20
138*cdf0e10cSrcweir #define VALID_DISTANCE		0x40
139*cdf0e10cSrcweir #define VALID_DISABLE		0x80
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir class EDITENG_DLLPUBLIC SvxBoxInfoItem : public SfxPoolItem
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir 	SvxBorderLine* pHori;   //innere horizontale Linie
144*cdf0e10cSrcweir 	SvxBorderLine* pVert;   //innere vertikale Linie
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     bool                mbEnableHor;   /// true = Enable inner horizonal line.
147*cdf0e10cSrcweir     bool                mbEnableVer;   /// true = Enable inner vertical line.
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 	/*
150*cdf0e10cSrcweir 	 z.Z. nur fuer StarWriter: Abstand nach innen von SvxBoxItem.
151*cdf0e10cSrcweir 	 Wenn der Abstand gewuenscht ist, so muss das Feld fuer den Abstand vom
152*cdf0e10cSrcweir 	 Dialog freigeschaltet werden. nDefDist ist als Defaultwert anzusehen.
153*cdf0e10cSrcweir 	 Wenn irgendeine	Linie eingeschalt ist oder wird, so muss dieser
154*cdf0e10cSrcweir 	 Abstand defaultet werden. bMinDist gibt an, ob der Wert durch den
155*cdf0e10cSrcweir 	 Anwender unterschritten werden darf. Mit nDist wird der aktuelle
156*cdf0e10cSrcweir 	 Abstand von der App zum Dialog und zurueck transportiert.
157*cdf0e10cSrcweir 	*/
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 	sal_Bool	bDist      :1;  // sal_True, Abstand freischalten.
160*cdf0e10cSrcweir 	sal_Bool	bMinDist   :1;  // sal_True, Abstand darf nicht unterschritten werden.
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 	sal_uInt8	nValidFlags;	// 0000 0000
163*cdf0e10cSrcweir 							// ���� ����� VALID_TOP
164*cdf0e10cSrcweir 							// ���� ����� VALID_BOTTOM
165*cdf0e10cSrcweir 							// ���� ����� VALID_LEFT
166*cdf0e10cSrcweir 							// ���� ����� VALID_RIGHT
167*cdf0e10cSrcweir 							// ���������� VALID_HORI
168*cdf0e10cSrcweir 							// ���������� VALID_VERT
169*cdf0e10cSrcweir 							// ���������� VALID_DIST
170*cdf0e10cSrcweir 							// ���������� VALID_DISABLE
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 	sal_uInt16	nDefDist;       // Der Default- bzw. Minimalabstand.
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir public:
175*cdf0e10cSrcweir 	TYPEINFO();
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir     SvxBoxInfoItem( const sal_uInt16 nId );
178*cdf0e10cSrcweir 	SvxBoxInfoItem( const SvxBoxInfoItem &rCpy );
179*cdf0e10cSrcweir 	~SvxBoxInfoItem();
180*cdf0e10cSrcweir 	SvxBoxInfoItem &operator=( const SvxBoxInfoItem &rCpy );
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 	// "pure virtual Methoden" vom SfxPoolItem
183*cdf0e10cSrcweir 	virtual int 			 operator==( const SfxPoolItem& ) const;
184*cdf0e10cSrcweir 	virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
185*cdf0e10cSrcweir 									SfxMapUnit eCoreMetric,
186*cdf0e10cSrcweir 									SfxMapUnit ePresMetric,
187*cdf0e10cSrcweir                                     String &rText, const IntlWrapper * = 0 ) const;
188*cdf0e10cSrcweir 	virtual	sal_Bool        	 QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
189*cdf0e10cSrcweir 	virtual	sal_Bool			 PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 	virtual SfxPoolItem*	Clone( SfxItemPool *pPool = 0 ) const;
192*cdf0e10cSrcweir 	virtual SfxPoolItem*	Create(SvStream &, sal_uInt16) const;
193*cdf0e10cSrcweir 	virtual SvStream&		Store(SvStream &, sal_uInt16 nItemVersion ) const;
194*cdf0e10cSrcweir 	virtual int				 ScaleMetrics( long nMult, long nDiv );
195*cdf0e10cSrcweir 	virtual	int				 HasMetrics() const;
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 	const SvxBorderLine*	GetHori() const { return pHori; }
198*cdf0e10cSrcweir 	const SvxBorderLine*	GetVert() const { return pVert; }
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir 	//Die Pointer werden kopiert!
201*cdf0e10cSrcweir 	void					SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine );
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir     sal_Bool    IsTable() const             { return mbEnableHor && mbEnableVer; }
204*cdf0e10cSrcweir     void    SetTable( sal_Bool bNew )       { mbEnableHor = mbEnableVer = bNew; }
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir     inline bool         IsHorEnabled() const { return mbEnableHor; }
207*cdf0e10cSrcweir     inline void         EnableHor( bool bEnable ) { mbEnableHor = bEnable; }
208*cdf0e10cSrcweir     inline bool         IsVerEnabled() const { return mbEnableVer; }
209*cdf0e10cSrcweir     inline void         EnableVer( bool bEnable ) { mbEnableVer = bEnable; }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 	sal_Bool 	IsDist() const				{ return bDist; }
212*cdf0e10cSrcweir 	void 	SetDist( sal_Bool bNew )		{ bDist = bNew; }
213*cdf0e10cSrcweir 	sal_Bool 	IsMinDist() const			{ return bMinDist; }
214*cdf0e10cSrcweir 	void 	SetMinDist( sal_Bool bNew )		{ bMinDist = bNew; }
215*cdf0e10cSrcweir 	sal_uInt16	GetDefDist() const			{ return nDefDist; }
216*cdf0e10cSrcweir 	void 	SetDefDist( sal_uInt16 nNew )	{ nDefDist = nNew; }
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir 	sal_Bool					IsValid( sal_uInt8 nValid ) const
219*cdf0e10cSrcweir 								{ return ( nValidFlags & nValid ) == nValid; }
220*cdf0e10cSrcweir 	void 					SetValid( sal_uInt8 nValid, sal_Bool bValid = sal_True )
221*cdf0e10cSrcweir 								{ bValid ? ( nValidFlags |= nValid )
222*cdf0e10cSrcweir 										 : ( nValidFlags &= ~nValid ); }
223*cdf0e10cSrcweir 	void					ResetFlags();
224*cdf0e10cSrcweir };
225*cdf0e10cSrcweir #endif
226*cdf0e10cSrcweir 
227