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