1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23 #ifndef _SVX_BOXITEM_HXX
24 #define _SVX_BOXITEM_HXX
25
26 #include <svl/poolitem.hxx>
27 #include <editeng/borderline.hxx>
28 #include <editeng/editengdllapi.h>
29 #include <com/sun/star/table/BorderLine.hpp>
30
31 namespace rtl { class OUString; }
32
33 // class SvxBoxItem ------------------------------------------------------
34
35 /*
36 [Beschreibung]
37 Dieses Item beschreibt ein Umrandungsattribut (alle vier Kanten und
38 Abstand nach innen.
39 */
40
41 #define BOX_LINE_TOP ((sal_uInt16)0)
42 #define BOX_LINE_BOTTOM ((sal_uInt16)1)
43 #define BOX_LINE_LEFT ((sal_uInt16)2)
44 #define BOX_LINE_RIGHT ((sal_uInt16)3)
45
46 #define BOX_4DISTS_VERSION ((sal_uInt16)1)
47
48 class EDITENG_DLLPUBLIC SvxBoxItem : public SfxPoolItem
49 {
50 SvxBorderLine *pTop,
51 *pBottom,
52 *pLeft,
53 *pRight;
54 sal_uInt16 nTopDist,
55 nBottomDist,
56 nLeftDist,
57 nRightDist;
58
59 public:
60 TYPEINFO();
61
62 SvxBoxItem( const sal_uInt16 nId );
63 SvxBoxItem( const SvxBoxItem &rCpy );
64 ~SvxBoxItem();
65 SvxBoxItem &operator=( const SvxBoxItem& rBox );
66
67 // "pure virtual Methoden" vom SfxPoolItem
68 virtual int operator==( const SfxPoolItem& ) const;
69 virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
70 virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
71
72 virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
73 SfxMapUnit eCoreMetric,
74 SfxMapUnit ePresMetric,
75 String &rText, const IntlWrapper * = 0 ) const;
76
77 virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
78 virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const;
79 virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion ) const;
80 virtual sal_uInt16 GetVersion( sal_uInt16 nFileVersion ) const;
81
82 virtual int ScaleMetrics( long nMult, long nDiv );
83 virtual int HasMetrics() const;
84
GetTop() const85 const SvxBorderLine* GetTop() const { return pTop; }
GetBottom() const86 const SvxBorderLine* GetBottom() const { return pBottom; }
GetLeft() const87 const SvxBorderLine* GetLeft() const { return pLeft; }
GetRight() const88 const SvxBorderLine* GetRight() const { return pRight; }
89
90 const SvxBorderLine* GetLine( sal_uInt16 nLine ) const;
91
92 //Die Pointer werden kopiert!
93 void SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine );
94
95 sal_uInt16 GetDistance( sal_uInt16 nLine ) const;
96 sal_uInt16 GetDistance() const;
97
98 void SetDistance( sal_uInt16 nNew, sal_uInt16 nLine );
99 inline void SetDistance( sal_uInt16 nNew );
100
101 //Breite der Linien plus Zwischenraum plus Abstand nach innen.
102 //JP 09.06.99: bIgnoreLine = sal_True -> Distance auch returnen, wenn
103 // keine Line gesetzt ist
104 sal_uInt16 CalcLineSpace( sal_uInt16 nLine, sal_Bool bIgnoreLine = sal_False ) const;
105 static com::sun::star::table::BorderLine SvxLineToLine( const SvxBorderLine* pLine, sal_Bool bConvert );
106 static sal_Bool LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert);
107 };
108
SetDistance(sal_uInt16 nNew)109 inline void SvxBoxItem::SetDistance( sal_uInt16 nNew )
110 {
111 nTopDist = nBottomDist = nLeftDist = nRightDist = nNew;
112 }
113
114 // class SvxBoxInfoItem --------------------------------------------------
115
116 /*
117 [Beschreibung]
118 Noch ein Item fuer die Umrandung. Dieses Item hat lediglich SS-Funktionalitaet.
119 Einerseits wird dem allgemeinen Dialog mit diesem Item mitgeteilt, welche
120 Moeglichkeiten er anbieten soll.
121 Andererseits werden ueber dieses Attribut ggf. die BorderLines fuer die
122 horizontalen und vertikalen innerern Linien transportiert.
123 */
124
125 #define BOXINFO_LINE_HORI ((sal_uInt16)0)
126 #define BOXINFO_LINE_VERT ((sal_uInt16)1)
127
128 #define VALID_TOP 0x01
129 #define VALID_BOTTOM 0x02
130 #define VALID_LEFT 0x04
131 #define VALID_RIGHT 0x08
132 #define VALID_HORI 0x10
133 #define VALID_VERT 0x20
134 #define VALID_DISTANCE 0x40
135 #define VALID_DISABLE 0x80
136
137 class EDITENG_DLLPUBLIC SvxBoxInfoItem : public SfxPoolItem
138 {
139 SvxBorderLine* pHori; //innere horizontale Linie
140 SvxBorderLine* pVert; //innere vertikale Linie
141
142 bool mbEnableHor; /// true = Enable inner horizonal line.
143 bool mbEnableVer; /// true = Enable inner vertical line.
144
145 /*
146 z.Z. nur fuer StarWriter: Abstand nach innen von SvxBoxItem.
147 Wenn der Abstand gewuenscht ist, so muss das Feld fuer den Abstand vom
148 Dialog freigeschaltet werden. nDefDist ist als Defaultwert anzusehen.
149 Wenn irgendeine Linie eingeschalt ist oder wird, so muss dieser
150 Abstand defaultet werden. bMinDist gibt an, ob der Wert durch den
151 Anwender unterschritten werden darf. Mit nDist wird der aktuelle
152 Abstand von der App zum Dialog und zurueck transportiert.
153 */
154
155 sal_Bool bDist :1; // sal_True, Abstand freischalten.
156 sal_Bool bMinDist :1; // sal_True, Abstand darf nicht unterschritten werden.
157
158 sal_uInt8 nValidFlags; // 0000 0000
159 // ���� ����� VALID_TOP
160 // ���� ����� VALID_BOTTOM
161 // ���� ����� VALID_LEFT
162 // ���� ����� VALID_RIGHT
163 // ���������� VALID_HORI
164 // ���������� VALID_VERT
165 // ���������� VALID_DIST
166 // ���������� VALID_DISABLE
167
168 sal_uInt16 nDefDist; // Der Default- bzw. Minimalabstand.
169
170 public:
171 TYPEINFO();
172
173 SvxBoxInfoItem( const sal_uInt16 nId );
174 SvxBoxInfoItem( const SvxBoxInfoItem &rCpy );
175 ~SvxBoxInfoItem();
176 SvxBoxInfoItem &operator=( const SvxBoxInfoItem &rCpy );
177
178 // "pure virtual Methoden" vom SfxPoolItem
179 virtual int operator==( const SfxPoolItem& ) const;
180 virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
181 SfxMapUnit eCoreMetric,
182 SfxMapUnit ePresMetric,
183 String &rText, const IntlWrapper * = 0 ) const;
184 virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
185 virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
186
187 virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
188 virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const;
189 virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion ) const;
190 virtual int ScaleMetrics( long nMult, long nDiv );
191 virtual int HasMetrics() const;
192
GetHori() const193 const SvxBorderLine* GetHori() const { return pHori; }
GetVert() const194 const SvxBorderLine* GetVert() const { return pVert; }
195
196 //Die Pointer werden kopiert!
197 void SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine );
198
IsTable() const199 sal_Bool IsTable() const { return mbEnableHor && mbEnableVer; }
SetTable(sal_Bool bNew)200 void SetTable( sal_Bool bNew ) { mbEnableHor = mbEnableVer = bNew; }
201
IsHorEnabled() const202 inline bool IsHorEnabled() const { return mbEnableHor; }
EnableHor(bool bEnable)203 inline void EnableHor( bool bEnable ) { mbEnableHor = bEnable; }
IsVerEnabled() const204 inline bool IsVerEnabled() const { return mbEnableVer; }
EnableVer(bool bEnable)205 inline void EnableVer( bool bEnable ) { mbEnableVer = bEnable; }
206
IsDist() const207 sal_Bool IsDist() const { return bDist; }
SetDist(sal_Bool bNew)208 void SetDist( sal_Bool bNew ) { bDist = bNew; }
IsMinDist() const209 sal_Bool IsMinDist() const { return bMinDist; }
SetMinDist(sal_Bool bNew)210 void SetMinDist( sal_Bool bNew ) { bMinDist = bNew; }
GetDefDist() const211 sal_uInt16 GetDefDist() const { return nDefDist; }
SetDefDist(sal_uInt16 nNew)212 void SetDefDist( sal_uInt16 nNew ) { nDefDist = nNew; }
213
IsValid(sal_uInt8 nValid) const214 sal_Bool IsValid( sal_uInt8 nValid ) const
215 { return ( nValidFlags & nValid ) == nValid; }
SetValid(sal_uInt8 nValid,sal_Bool bValid=sal_True)216 void SetValid( sal_uInt8 nValid, sal_Bool bValid = sal_True )
217 { bValid ? ( nValidFlags |= nValid )
218 : ( nValidFlags &= ~nValid ); }
219 void ResetFlags();
220 };
221 #endif
222
223