1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _SVX_BOXITEM_HXX
20 #define _SVX_BOXITEM_HXX
22 #include <svl/poolitem.hxx>
23 #include <editeng/borderline.hxx>
24 #include <editeng/editengdllapi.h>
25 #include <com/sun/star/table/BorderLine2.hpp>
28 // class SvxBoxItem ------------------------------------------------------
32 This item describes a border attribute
33 (all four edges and the inward distance)
36 #define BOX_LINE_TOP ((sal_uInt16)0)
37 #define BOX_LINE_BOTTOM ((sal_uInt16)1)
38 #define BOX_LINE_LEFT ((sal_uInt16)2)
39 #define BOX_LINE_RIGHT ((sal_uInt16)3)
42 This version causes SvxBoxItem to store the 4 cell spacing distances separately
43 when serializing to stream.
45 #define BOX_4DISTS_VERSION ((sal_uInt16)1)
47 This version causes SvxBoxItem to store the styles for its border lines when
48 serializing to stream.
50 #define BOX_BORDER_STYLE_VERSION ((sal_uInt16)2)
52 class EDITENG_DLLPUBLIC SvxBoxItem
: public SfxPoolItem
54 editeng::SvxBorderLine
*pTop
,
66 explicit SvxBoxItem( const sal_uInt16 nId
);
67 SvxBoxItem( const SvxBoxItem
&rCpy
);
69 SvxBoxItem
&operator=( const SvxBoxItem
& rBox
);
71 // "pure virtual Methods" from SfxPoolItem
72 virtual int operator==( const SfxPoolItem
& ) const;
73 virtual bool QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const;
74 virtual bool PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 );
76 virtual SfxItemPresentation
GetPresentation( SfxItemPresentation ePres
,
77 SfxMapUnit eCoreMetric
,
78 SfxMapUnit ePresMetric
,
79 OUString
&rText
, const IntlWrapper
* = 0 ) const;
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;
86 virtual bool ScaleMetrics( long nMult
, long nDiv
);
87 virtual bool HasMetrics() const;
89 const editeng::SvxBorderLine
* GetTop() const { return pTop
; }
90 const editeng::SvxBorderLine
* GetBottom() const { return pBottom
; }
91 const editeng::SvxBorderLine
* GetLeft() const { return pLeft
; }
92 const editeng::SvxBorderLine
* GetRight() const { return pRight
; }
94 const editeng::SvxBorderLine
* GetLine( sal_uInt16 nLine
) const;
96 //The Pointers are being copied!
97 void SetLine( const editeng::SvxBorderLine
* pNew
, sal_uInt16 nLine
);
99 sal_uInt16
GetDistance( sal_uInt16 nLine
) const;
100 sal_uInt16
GetDistance() const;
102 void SetDistance( sal_uInt16 nNew
, sal_uInt16 nLine
);
103 inline void SetDistance( sal_uInt16 nNew
);
105 // Line width plus Space plus inward distance
106 //bIgnoreLine = TRUE -> Also return distance, when no Line is set
107 sal_uInt16
CalcLineSpace( sal_uInt16 nLine
, sal_Bool bIgnoreLine
= sal_False
) const;
108 static com::sun::star::table::BorderLine2
SvxLineToLine( const editeng::SvxBorderLine
* pLine
, sal_Bool bConvert
);
109 static sal_Bool
LineToSvxLine(const ::com::sun::star::table::BorderLine
& rLine
, editeng::SvxBorderLine
& rSvxLine
, sal_Bool bConvert
);
110 static sal_Bool
LineToSvxLine(const ::com::sun::star::table::BorderLine2
& rLine
, editeng::SvxBorderLine
& rSvxLine
, sal_Bool bConvert
);
113 inline void SvxBoxItem::SetDistance( sal_uInt16 nNew
)
115 nTopDist
= nBottomDist
= nLeftDist
= nRightDist
= nNew
;
118 // class SvxBoxInfoItem --------------------------------------------------
122 Another item for the border. This item has only limited functionality.
123 On one hand, the general Dialog is told by the item which options it
124 should offer. On the other hand, this attribute may be used to
125 transported the borderline for the inner horizontal and vertical lines.
128 #define BOXINFO_LINE_HORI ((sal_uInt16)0)
129 #define BOXINFO_LINE_VERT ((sal_uInt16)1)
131 #define VALID_TOP 0x01
132 #define VALID_BOTTOM 0x02
133 #define VALID_LEFT 0x04
134 #define VALID_RIGHT 0x08
135 #define VALID_HORI 0x10
136 #define VALID_VERT 0x20
137 #define VALID_DISTANCE 0x40
138 #define VALID_DISABLE 0x80
140 class EDITENG_DLLPUBLIC SvxBoxInfoItem
: public SfxPoolItem
142 editeng::SvxBorderLine
* pHori
; //inner horizontal Line
143 editeng::SvxBorderLine
* pVert
; //inner vertical Line
145 bool mbEnableHor
; /// true = Enable inner horizontal line.
146 bool mbEnableVer
; /// true = Enable inner vertical line.
149 Currently only for StarWriter: distance inward from SvxBoxItem. If the
150 distance is requested, then the field for the distance from the dialog be
151 activated. nDefDist is regarded as a default value. If any line is
152 turned on or will be turned on it must this distance be set to default.
153 bMinDist indicates whether the user can go below this value or not.
154 With NDIST is the current distance from the app transported back and
155 forth to the dialogue.
158 sal_Bool bDist
:1; // TRUE, Unlock Distance.
159 sal_Bool bMinDist
:1; // TRUE, Going below minimum Distance is prohibited
161 sal_uInt8 nValidFlags
; // 0000 0000
162 // ³³³³ ³³³ÀÄ VALID_TOP
163 // ³³³³ ³³ÀÄÄ VALID_BOTTOM
164 // ³³³³ ³ÀÄÄÄ VALID_LEFT
165 // ³³³³ ÀÄÄÄÄ VALID_RIGHT
166 // ³³³ÀÄÄÄÄÄÄ VALID_HORI
167 // ³³ÀÄÄÄÄÄÄÄ VALID_VERT
168 // ³ÀÄÄÄÄÄÄÄÄ VALID_DIST
169 // ÀÄÄÄÄÄÄÄÄÄ VALID_DISABLE
171 sal_uInt16 nDefDist
; // The default or minimum distance.
176 explicit SvxBoxInfoItem( const sal_uInt16 nId
);
177 SvxBoxInfoItem( const SvxBoxInfoItem
&rCpy
);
179 SvxBoxInfoItem
&operator=( const SvxBoxInfoItem
&rCpy
);
181 // "pure virtual Methods" from SfxPoolItem
182 virtual int operator==( const SfxPoolItem
& ) const;
183 virtual SfxItemPresentation
GetPresentation( SfxItemPresentation ePres
,
184 SfxMapUnit eCoreMetric
,
185 SfxMapUnit ePresMetric
,
186 OUString
&rText
, const IntlWrapper
* = 0 ) const;
187 virtual bool QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const;
188 virtual bool PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 );
190 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= 0 ) const;
191 virtual SfxPoolItem
* Create(SvStream
&, sal_uInt16
) const;
192 virtual SvStream
& Store(SvStream
&, sal_uInt16 nItemVersion
) const;
193 virtual bool ScaleMetrics( long nMult
, long nDiv
);
194 virtual bool HasMetrics() const;
196 const editeng::SvxBorderLine
* GetHori() const { return pHori
; }
197 const editeng::SvxBorderLine
* GetVert() const { return pVert
; }
199 //The Pointers are being copied!
200 void SetLine( const editeng::SvxBorderLine
* pNew
, sal_uInt16 nLine
);
202 sal_Bool
IsTable() const { return mbEnableHor
&& mbEnableVer
; }
203 void SetTable( sal_Bool bNew
) { mbEnableHor
= mbEnableVer
= bNew
; }
205 inline bool IsHorEnabled() const { return mbEnableHor
; }
206 inline void EnableHor( bool bEnable
) { mbEnableHor
= bEnable
; }
207 inline bool IsVerEnabled() const { return mbEnableVer
; }
208 inline void EnableVer( bool bEnable
) { mbEnableVer
= bEnable
; }
210 sal_Bool
IsDist() const { return bDist
; }
211 void SetDist( sal_Bool bNew
) { bDist
= bNew
; }
212 sal_Bool
IsMinDist() const { return bMinDist
; }
213 void SetMinDist( sal_Bool bNew
) { bMinDist
= bNew
; }
214 sal_uInt16
GetDefDist() const { return nDefDist
; }
215 void SetDefDist( sal_uInt16 nNew
) { nDefDist
= nNew
; }
217 sal_Bool
IsValid( sal_uInt8 nValid
) const
218 { return ( nValidFlags
& nValid
) == nValid
; }
219 void SetValid( sal_uInt8 nValid
, sal_Bool bValid
= sal_True
)
220 { bValid
? ( nValidFlags
|= nValid
)
221 : ( nValidFlags
&= ~nValid
); }
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */