Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef _SVX_BOXITEM_HXX
20 : #define _SVX_BOXITEM_HXX
21 :
22 : #include <svl/poolitem.hxx>
23 : #include <editeng/borderline.hxx>
24 : #include <editeng/editengdllapi.h>
25 : #include <com/sun/star/table/BorderLine2.hpp>
26 :
27 : namespace rtl { class OUString; }
28 :
29 : // class SvxBoxItem ------------------------------------------------------
30 :
31 : /* [Description]
32 :
33 : This item describes a border attribute
34 : (all four edges and the inward distance)
35 : */
36 :
37 : #define BOX_LINE_TOP ((sal_uInt16)0)
38 : #define BOX_LINE_BOTTOM ((sal_uInt16)1)
39 : #define BOX_LINE_LEFT ((sal_uInt16)2)
40 : #define BOX_LINE_RIGHT ((sal_uInt16)3)
41 :
42 : /**
43 : This version causes SvxBoxItem to store the 4 cell spacing distances separately
44 : when serializing to stream.
45 : */
46 : #define BOX_4DISTS_VERSION ((sal_uInt16)1)
47 : /**
48 : This version causes SvxBoxItem to store the styles for its border lines when
49 : serializing to stream.
50 : */
51 : #define BOX_BORDER_STYLE_VERSION ((sal_uInt16)2)
52 :
53 : class EDITENG_DLLPUBLIC SvxBoxItem : public SfxPoolItem
54 : {
55 : editeng::SvxBorderLine *pTop,
56 : *pBottom,
57 : *pLeft,
58 : *pRight;
59 : sal_uInt16 nTopDist,
60 : nBottomDist,
61 : nLeftDist,
62 : nRightDist;
63 :
64 : public:
65 : TYPEINFO();
66 :
67 : explicit SvxBoxItem( const sal_uInt16 nId );
68 : SvxBoxItem( const SvxBoxItem &rCpy );
69 : ~SvxBoxItem();
70 : SvxBoxItem &operator=( const SvxBoxItem& rBox );
71 :
72 : // "pure virtual Methods" from SfxPoolItem
73 : virtual int operator==( const SfxPoolItem& ) const;
74 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
75 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
76 :
77 : virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
78 : SfxMapUnit eCoreMetric,
79 : SfxMapUnit ePresMetric,
80 : String &rText, const IntlWrapper * = 0 ) const;
81 :
82 : virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
83 : virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const;
84 : virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion ) const;
85 : virtual sal_uInt16 GetVersion( sal_uInt16 nFileVersion ) const;
86 :
87 : virtual bool ScaleMetrics( long nMult, long nDiv );
88 : virtual bool HasMetrics() const;
89 :
90 137813 : const editeng::SvxBorderLine* GetTop() const { return pTop; }
91 81918 : const editeng::SvxBorderLine* GetBottom() const { return pBottom; }
92 70943 : const editeng::SvxBorderLine* GetLeft() const { return pLeft; }
93 63965 : const editeng::SvxBorderLine* GetRight() const { return pRight; }
94 :
95 : const editeng::SvxBorderLine* GetLine( sal_uInt16 nLine ) const;
96 :
97 : //The Pointers are being copied!
98 : void SetLine( const editeng::SvxBorderLine* pNew, sal_uInt16 nLine );
99 :
100 : sal_uInt16 GetDistance( sal_uInt16 nLine ) const;
101 : sal_uInt16 GetDistance() const;
102 :
103 : void SetDistance( sal_uInt16 nNew, sal_uInt16 nLine );
104 : inline void SetDistance( sal_uInt16 nNew );
105 :
106 : // Line width plus Space plus inward distance
107 : //bIgnoreLine = TRUE -> Also return distance, when no Line is set
108 : sal_uInt16 CalcLineSpace( sal_uInt16 nLine, sal_Bool bIgnoreLine = sal_False ) const;
109 : static com::sun::star::table::BorderLine2 SvxLineToLine( const editeng::SvxBorderLine* pLine, sal_Bool bConvert );
110 : static sal_Bool LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, editeng::SvxBorderLine& rSvxLine, sal_Bool bConvert);
111 : static sal_Bool LineToSvxLine(const ::com::sun::star::table::BorderLine2& rLine, editeng::SvxBorderLine& rSvxLine, sal_Bool bConvert);
112 : };
113 :
114 579 : inline void SvxBoxItem::SetDistance( sal_uInt16 nNew )
115 : {
116 579 : nTopDist = nBottomDist = nLeftDist = nRightDist = nNew;
117 579 : }
118 :
119 : // class SvxBoxInfoItem --------------------------------------------------
120 :
121 : /* [Description]
122 :
123 : Another item for the border. This item has only limited functionality.
124 : On one hand, the general Dialog is told by the item which options it
125 : should offer. On the other hand, this attribute may be used to
126 : transported the borderline for the inner horizontal and vertical lines.
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 : editeng::SvxBorderLine* pHori; //inner horizontal Line
144 : editeng::SvxBorderLine* pVert; //inner vertical Line
145 :
146 : bool mbEnableHor; /// true = Enable inner horizontal line.
147 : bool mbEnableVer; /// true = Enable inner vertical line.
148 :
149 : /*
150 : Currently only for StarWriter: distance inward from SvxBoxItem. If the
151 : distance is requested, then the field for the distance from the dialog be
152 : activated. nDefDist is regarded as a default value. If any line is
153 : turned on or will be turned on it must this distance be set to default.
154 : bMinDist indicates whether the user can go below this value or not.
155 : With NDIST is the current distance from the app transported back and
156 : forth to the dialogue.
157 : */
158 :
159 : sal_Bool bDist :1; // TRUE, Unlock Distance.
160 : sal_Bool bMinDist :1; // TRUE, Going below minimum Distance is prohibited
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; // The default or minimum distance.
173 :
174 : public:
175 : TYPEINFO();
176 :
177 : explicit SvxBoxInfoItem( const sal_uInt16 nId );
178 : SvxBoxInfoItem( const SvxBoxInfoItem &rCpy );
179 : ~SvxBoxInfoItem();
180 : SvxBoxInfoItem &operator=( const SvxBoxInfoItem &rCpy );
181 :
182 : // "pure virtual Methods" from 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 bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
189 : virtual 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 bool ScaleMetrics( long nMult, long nDiv );
195 : virtual bool HasMetrics() const;
196 :
197 10458 : const editeng::SvxBorderLine* GetHori() const { return pHori; }
198 10447 : const editeng::SvxBorderLine* GetVert() const { return pVert; }
199 :
200 : //The Pointers are being copied!
201 : void SetLine( const editeng::SvxBorderLine* pNew, sal_uInt16 nLine );
202 :
203 0 : sal_Bool IsTable() const { return mbEnableHor && mbEnableVer; }
204 4665 : void SetTable( sal_Bool bNew ) { mbEnableHor = mbEnableVer = bNew; }
205 :
206 0 : inline bool IsHorEnabled() const { return mbEnableHor; }
207 0 : inline void EnableHor( bool bEnable ) { mbEnableHor = bEnable; }
208 0 : inline bool IsVerEnabled() const { return mbEnableVer; }
209 0 : inline void EnableVer( bool bEnable ) { mbEnableVer = bEnable; }
210 :
211 10442 : sal_Bool IsDist() const { return bDist; }
212 4665 : void SetDist( sal_Bool bNew ) { bDist = bNew; }
213 10442 : sal_Bool IsMinDist() const { return bMinDist; }
214 3905 : void SetMinDist( sal_Bool bNew ) { bMinDist = bNew; }
215 10442 : sal_uInt16 GetDefDist() const { return nDefDist; }
216 3710 : void SetDefDist( sal_uInt16 nNew ) { nDefDist = nNew; }
217 :
218 2790 : sal_Bool IsValid( sal_uInt8 nValid ) const
219 2790 : { return ( nValidFlags & nValid ) == nValid; }
220 5558 : void SetValid( sal_uInt8 nValid, sal_Bool bValid = sal_True )
221 : { bValid ? ( nValidFlags |= nValid )
222 5558 : : ( nValidFlags &= ~nValid ); }
223 : void ResetFlags();
224 : };
225 : #endif
226 :
227 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|