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 :
28 : // class SvxBoxItem ------------------------------------------------------
29 :
30 : /* [Description]
31 :
32 : This item describes a border attribute
33 : (all four edges and the inward distance)
34 : */
35 :
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)
40 :
41 : /**
42 : This version causes SvxBoxItem to store the 4 cell spacing distances separately
43 : when serializing to stream.
44 : */
45 : #define BOX_4DISTS_VERSION ((sal_uInt16)1)
46 : /**
47 : This version causes SvxBoxItem to store the styles for its border lines when
48 : serializing to stream.
49 : */
50 : #define BOX_BORDER_STYLE_VERSION ((sal_uInt16)2)
51 :
52 : class EDITENG_DLLPUBLIC SvxBoxItem : public SfxPoolItem
53 : {
54 : editeng::SvxBorderLine *pTop,
55 : *pBottom,
56 : *pLeft,
57 : *pRight;
58 : sal_uInt16 nTopDist,
59 : nBottomDist,
60 : nLeftDist,
61 : nRightDist;
62 :
63 : public:
64 : TYPEINFO();
65 :
66 : explicit SvxBoxItem( const sal_uInt16 nId );
67 : SvxBoxItem( const SvxBoxItem &rCpy );
68 : ~SvxBoxItem();
69 : SvxBoxItem &operator=( const SvxBoxItem& rBox );
70 :
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 );
75 :
76 : virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
77 : SfxMapUnit eCoreMetric,
78 : SfxMapUnit ePresMetric,
79 : OUString &rText, const IntlWrapper * = 0 ) const;
80 :
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;
85 :
86 : virtual bool ScaleMetrics( long nMult, long nDiv );
87 : virtual bool HasMetrics() const;
88 :
89 3384283 : const editeng::SvxBorderLine* GetTop() const { return pTop; }
90 3312109 : const editeng::SvxBorderLine* GetBottom() const { return pBottom; }
91 3303540 : const editeng::SvxBorderLine* GetLeft() const { return pLeft; }
92 3289568 : const editeng::SvxBorderLine* GetRight() const { return pRight; }
93 :
94 : const editeng::SvxBorderLine* GetLine( sal_uInt16 nLine ) const;
95 :
96 : //The Pointers are being copied!
97 : void SetLine( const editeng::SvxBorderLine* pNew, sal_uInt16 nLine );
98 :
99 : sal_uInt16 GetDistance( sal_uInt16 nLine ) const;
100 : sal_uInt16 GetDistance() const;
101 :
102 : void SetDistance( sal_uInt16 nNew, sal_uInt16 nLine );
103 : inline void SetDistance( sal_uInt16 nNew );
104 :
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);
111 : };
112 :
113 2375 : inline void SvxBoxItem::SetDistance( sal_uInt16 nNew )
114 : {
115 2375 : nTopDist = nBottomDist = nLeftDist = nRightDist = nNew;
116 2375 : }
117 :
118 : // class SvxBoxInfoItem --------------------------------------------------
119 :
120 : /* [Description]
121 :
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.
126 : */
127 :
128 : #define BOXINFO_LINE_HORI ((sal_uInt16)0)
129 : #define BOXINFO_LINE_VERT ((sal_uInt16)1)
130 :
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
139 :
140 : class EDITENG_DLLPUBLIC SvxBoxInfoItem : public SfxPoolItem
141 : {
142 : editeng::SvxBorderLine* pHori; //inner horizontal Line
143 : editeng::SvxBorderLine* pVert; //inner vertical Line
144 :
145 : bool mbEnableHor; /// true = Enable inner horizontal line.
146 : bool mbEnableVer; /// true = Enable inner vertical line.
147 :
148 : /*
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.
156 : */
157 :
158 : sal_Bool bDist :1; // TRUE, Unlock Distance.
159 : sal_Bool bMinDist :1; // TRUE, Going below minimum Distance is prohibited
160 :
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
170 :
171 : sal_uInt16 nDefDist; // The default or minimum distance.
172 :
173 : public:
174 : TYPEINFO();
175 :
176 : explicit SvxBoxInfoItem( const sal_uInt16 nId );
177 : SvxBoxInfoItem( const SvxBoxInfoItem &rCpy );
178 : ~SvxBoxInfoItem();
179 : SvxBoxInfoItem &operator=( const SvxBoxInfoItem &rCpy );
180 :
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 );
189 :
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;
195 :
196 26752 : const editeng::SvxBorderLine* GetHori() const { return pHori; }
197 26776 : const editeng::SvxBorderLine* GetVert() const { return pVert; }
198 :
199 : //The Pointers are being copied!
200 : void SetLine( const editeng::SvxBorderLine* pNew, sal_uInt16 nLine );
201 :
202 0 : sal_Bool IsTable() const { return mbEnableHor && mbEnableVer; }
203 13419 : void SetTable( sal_Bool bNew ) { mbEnableHor = mbEnableVer = bNew; }
204 :
205 0 : inline bool IsHorEnabled() const { return mbEnableHor; }
206 54 : inline void EnableHor( bool bEnable ) { mbEnableHor = bEnable; }
207 0 : inline bool IsVerEnabled() const { return mbEnableVer; }
208 54 : inline void EnableVer( bool bEnable ) { mbEnableVer = bEnable; }
209 :
210 25626 : sal_Bool IsDist() const { return bDist; }
211 13413 : void SetDist( sal_Bool bNew ) { bDist = bNew; }
212 25626 : sal_Bool IsMinDist() const { return bMinDist; }
213 10707 : void SetMinDist( sal_Bool bNew ) { bMinDist = bNew; }
214 25626 : sal_uInt16 GetDefDist() const { return nDefDist; }
215 9675 : void SetDefDist( sal_uInt16 nNew ) { nDefDist = nNew; }
216 :
217 14454 : sal_Bool IsValid( sal_uInt8 nValid ) const
218 14454 : { return ( nValidFlags & nValid ) == nValid; }
219 16568 : void SetValid( sal_uInt8 nValid, sal_Bool bValid = sal_True )
220 : { bValid ? ( nValidFlags |= nValid )
221 16568 : : ( nValidFlags &= ~nValid ); }
222 : void ResetFlags();
223 : };
224 : #endif
225 :
226 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|