Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/uno/Any.hxx>
30 : : #include <com/sun/star/drawing/LineStyle.hpp>
31 : : #include <com/sun/star/script/XTypeConverter.hpp>
32 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 : : #include <com/sun/star/table/ShadowLocation.hpp>
34 : : #include <com/sun/star/table/TableBorder.hpp>
35 : : #include <com/sun/star/table/ShadowFormat.hpp>
36 : : #include <com/sun/star/table/CellRangeAddress.hpp>
37 : : #include <com/sun/star/table/CellContentType.hpp>
38 : : #include <com/sun/star/table/TableOrientation.hpp>
39 : : #include <com/sun/star/util/SortField.hpp>
40 : : #include <com/sun/star/util/SortFieldType.hpp>
41 : : #include <com/sun/star/table/BorderLine2.hpp>
42 : : #include <com/sun/star/table/BorderLineStyle.hpp>
43 : : #include <com/sun/star/table/CellOrientation.hpp>
44 : : #include <com/sun/star/table/CellAddress.hpp>
45 : : #include <com/sun/star/style/PageStyleLayout.hpp>
46 : : #include <com/sun/star/style/BreakType.hpp>
47 : : #include <com/sun/star/style/GraphicLocation.hpp>
48 : : #include <com/sun/star/awt/Rectangle.hpp>
49 : : #include <com/sun/star/awt/Selection.hpp>
50 : : #include <com/sun/star/awt/Size.hpp>
51 : : #include <com/sun/star/text/WritingMode2.hpp>
52 : : #include <com/sun/star/frame/status/UpperLowerMarginScale.hpp>
53 : :
54 : : #include <unotools/ucbstreamhelper.hxx>
55 : : #include <limits.h>
56 : : #include <comphelper/processfactory.hxx>
57 : : #include <svtools/grfmgr.hxx>
58 : : #include <tools/urlobj.hxx>
59 : : #include <comphelper/types.hxx>
60 : : #include <svl/memberid.hrc>
61 : : #include <svtools/wallitem.hxx>
62 : : #include <svl/cntwall.hxx>
63 : : #include <svtools/borderhelper.hxx>
64 : : #include <rtl/ustring.hxx>
65 : : #include <rtl/ustrbuf.hxx>
66 : : #include <svtools/filter.hxx>
67 : : #include <editeng/editids.hrc>
68 : : #include <editeng/editrids.hrc>
69 : : #include <editeng/pbinitem.hxx>
70 : : #include <editeng/sizeitem.hxx>
71 : : #include <editeng/lrspitem.hxx>
72 : : #include <editeng/ulspitem.hxx>
73 : : #include <editeng/prntitem.hxx>
74 : : #include <editeng/opaqitem.hxx>
75 : : #include <editeng/protitem.hxx>
76 : : #include <editeng/shaditem.hxx>
77 : : #include <editeng/boxitem.hxx>
78 : : #include <editeng/brkitem.hxx>
79 : : #include <editeng/keepitem.hxx>
80 : : #include <editeng/bolnitem.hxx>
81 : : #include <editeng/brshitem.hxx>
82 : : #include <editeng/frmdiritem.hxx>
83 : : #include <editeng/itemtype.hxx>
84 : : #include <editeng/eerdll.hxx>
85 : : #include <editeng/unoprnms.hxx>
86 : : #include <editeng/memberids.hrc>
87 : : #include <editeng/editerr.hxx>
88 : :
89 : : using namespace ::editeng;
90 : : using namespace ::rtl;
91 : : using namespace ::com::sun::star;
92 : : using namespace ::com::sun::star::table::BorderLineStyle;
93 : :
94 : :
95 : : // Conversion for UNO
96 : : #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
97 : : #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
98 : : #define TWIP_TO_MM100_UNSIGNED(TWIP) ((((TWIP)*127L+36L)/72L))
99 : : #define MM100_TO_TWIP_UNSIGNED(MM100) ((((MM100)*72L+63L)/127L))
100 : :
101 : : // STATIC DATA -----------------------------------------------------------
102 : :
103 : : inline void SetValueProp( XubString& rStr, const sal_uInt16 nValue,
104 : : const sal_uInt16 nProp )
105 : : {
106 : : if( 100 == nProp )
107 : : rStr += String::CreateFromInt32( nValue );
108 : : else
109 : : ( rStr += String::CreateFromInt32( nProp )) += sal_Unicode('%');
110 : : }
111 : :
112 : : inline void SetValueProp( XubString& rStr, const short nValue,
113 : : const sal_uInt16 nProp )
114 : : {
115 : : if( 100 == nProp )
116 : : rStr += String::CreateFromInt32( nValue );
117 : : else
118 : : ( rStr += String::CreateFromInt32( nProp )) += sal_Unicode('%');
119 : : }
120 : :
121 : : // -----------------------------------------------------------------------
122 : :
123 : : /*
124 : : SvxBorderLine is not an SfxPoolItem, and has no Store/Create serialization/deserialization methods.
125 : : Since border line information needs to be serialized by the table autoformat code, these file-local
126 : : methods are defined to encapsulate the necessary serialization logic.
127 : : */
128 : : namespace
129 : : {
130 : : /// Item version for saved border lines. The old version saves the line without style information.
131 : : const int BORDER_LINE_OLD_VERSION = 0;
132 : : /// Item version for saved border lies. The new version includes line style.
133 : : const int BORDER_LINE_WITH_STYLE_VERSION = 1;
134 : :
135 : : /// Store a border line to a stream.
136 : 716 : SvStream& StoreBorderLine(SvStream &stream, const SvxBorderLine &l, sal_uInt16 version)
137 : : {
138 : 716 : stream << l.GetColor()
139 : 1432 : << l.GetOutWidth()
140 : 1432 : << l.GetInWidth()
141 : 1432 : << l.GetDistance();
142 : :
143 [ + - ]: 716 : if (version >= BORDER_LINE_WITH_STYLE_VERSION)
144 : 716 : stream << static_cast<sal_uInt16>(l.GetBorderLineStyle());
145 : :
146 : 716 : return stream;
147 : : }
148 : :
149 : : /// Creates a border line from a stream.
150 : 308 : SvxBorderLine CreateBorderLine(SvStream &stream, sal_uInt16 version)
151 : : {
152 : : sal_uInt16 nOutline, nInline, nDistance;
153 : 308 : sal_uInt16 nStyle = NONE;
154 : 308 : Color aColor;
155 [ + - ][ + - ]: 308 : stream >> aColor >> nOutline >> nInline >> nDistance;
[ + - ][ + - ]
156 : :
157 [ - + ]: 308 : if (version >= BORDER_LINE_WITH_STYLE_VERSION)
158 [ # # ]: 0 : stream >> nStyle;
159 : :
160 [ + - ]: 308 : SvxBorderLine border(&aColor);
161 [ + - ]: 308 : border.GuessLinesWidths(nStyle, nOutline, nInline, nDistance);
162 : 308 : return border;
163 : : }
164 : :
165 : : /// Retrieves a BORDER_LINE_* version from a BOX_BORDER_* version.
166 : 1024 : sal_uInt16 BorderLineVersionFromBoxVersion(sal_uInt16 boxVersion)
167 : : {
168 [ + + ]: 1024 : return (boxVersion >= BOX_BORDER_STYLE_VERSION)? BORDER_LINE_WITH_STYLE_VERSION : BORDER_LINE_OLD_VERSION;
169 : : }
170 : : }
171 : :
172 [ - + ][ - + ]: 6814 : TYPEINIT1_FACTORY(SvxPaperBinItem, SfxByteItem, new SvxPaperBinItem(0));
[ # # ]
173 [ + + ][ - + ]: 10382 : TYPEINIT1_FACTORY(SvxSizeItem, SfxPoolItem, new SvxSizeItem(0));
[ + - ]
174 [ + + ][ - + ]: 282034 : TYPEINIT1_FACTORY(SvxLRSpaceItem, SfxPoolItem, new SvxLRSpaceItem(0));
[ # # ]
175 [ + + ][ - + ]: 184760 : TYPEINIT1_FACTORY(SvxULSpaceItem, SfxPoolItem, new SvxULSpaceItem(0));
[ # # ]
176 [ - + ][ - + ]: 4593 : TYPEINIT1_FACTORY(SvxPrintItem, SfxBoolItem, new SvxPrintItem(0));
[ # # ]
177 [ - + ][ - + ]: 4593 : TYPEINIT1_FACTORY(SvxOpaqueItem, SfxBoolItem, new SvxOpaqueItem(0));
[ # # ]
178 [ + + ][ - + ]: 11511 : TYPEINIT1_FACTORY(SvxProtectItem, SfxPoolItem, new SvxProtectItem(0));
[ # # ]
179 [ + + ][ - + ]: 18343 : TYPEINIT1_FACTORY(SvxBrushItem, SfxPoolItem, new SvxBrushItem(0));
[ # # ]
180 [ + + ][ - + ]: 7400 : TYPEINIT1_FACTORY(SvxShadowItem, SfxPoolItem, new SvxShadowItem(0));
[ # # ]
181 [ + + ][ - + ]: 33800 : TYPEINIT1_FACTORY(SvxBoxItem, SfxPoolItem, new SvxBoxItem(0));
[ # # ]
182 [ - + ][ - + ]: 12234 : TYPEINIT1_FACTORY(SvxBoxInfoItem, SfxPoolItem, new SvxBoxInfoItem(0));
[ # # ]
183 [ + + ][ - + ]: 6585 : TYPEINIT1_FACTORY(SvxFmtBreakItem, SfxEnumItem, new SvxFmtBreakItem(SVX_BREAK_NONE, 0));
[ # # ]
184 [ - + ][ - + ]: 5054 : TYPEINIT1_FACTORY(SvxFmtKeepItem, SfxBoolItem, new SvxFmtKeepItem(sal_False, 0));
[ # # ]
185 [ - + ][ - + ]: 25517 : TYPEINIT1_FACTORY(SvxLineItem, SfxPoolItem, new SvxLineItem(0));
[ + - ]
186 [ + + ][ - + ]: 422975 : TYPEINIT1_FACTORY(SvxFrameDirectionItem, SfxUInt16Item, new SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP, 0));
[ # # ]
187 : :
188 : : // class SvxPaperBinItem ------------------------------------------------
189 : :
190 : 2 : SfxPoolItem* SvxPaperBinItem::Clone( SfxItemPool* ) const
191 : : {
192 [ + - ]: 2 : return new SvxPaperBinItem( *this );
193 : : }
194 : :
195 : : // -----------------------------------------------------------------------
196 : :
197 : 0 : SvStream& SvxPaperBinItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
198 : : {
199 : 0 : rStrm << GetValue();
200 : 0 : return rStrm;
201 : : }
202 : :
203 : : // -----------------------------------------------------------------------
204 : :
205 : 0 : SfxPoolItem* SvxPaperBinItem::Create( SvStream& rStrm, sal_uInt16 ) const
206 : : {
207 : : sal_Int8 nBin;
208 [ # # ]: 0 : rStrm >> nBin;
209 [ # # ][ # # ]: 0 : return new SvxPaperBinItem( Which(), nBin );
210 : : }
211 : :
212 : : // -----------------------------------------------------------------------
213 : :
214 : 0 : SfxItemPresentation SvxPaperBinItem::GetPresentation
215 : : (
216 : : SfxItemPresentation ePres,
217 : : SfxMapUnit /*eCoreUnit*/,
218 : : SfxMapUnit /*ePresUnit*/,
219 : : XubString& rText, const IntlWrapper *
220 : : ) const
221 : : {
222 [ # # # # ]: 0 : switch ( ePres )
223 : : {
224 : : case SFX_ITEM_PRESENTATION_NONE:
225 : 0 : rText.Erase();
226 : 0 : return SFX_ITEM_PRESENTATION_NONE;
227 : :
228 : : case SFX_ITEM_PRESENTATION_NAMELESS:
229 [ # # ]: 0 : rText = String::CreateFromInt32( GetValue() );
230 : 0 : return SFX_ITEM_PRESENTATION_NAMELESS;
231 : :
232 : : case SFX_ITEM_PRESENTATION_COMPLETE:
233 : : {
234 : 0 : sal_uInt8 nValue = GetValue();
235 : :
236 [ # # ]: 0 : if ( PAPERBIN_PRINTER_SETTINGS == nValue )
237 [ # # ][ # # ]: 0 : rText = EE_RESSTR(RID_SVXSTR_PAPERBIN_SETTINGS);
238 : : else
239 : : {
240 [ # # ][ # # ]: 0 : rText = EE_RESSTR(RID_SVXSTR_PAPERBIN);
241 : 0 : rText += sal_Unicode(' ');
242 [ # # ]: 0 : rText += String::CreateFromInt32( nValue );
243 : : }
244 : 0 : return SFX_ITEM_PRESENTATION_COMPLETE;
245 : : }
246 : : //no break necessary
247 : : default: ;//prevent warning
248 : : }
249 : :
250 : 0 : return SFX_ITEM_PRESENTATION_NONE;
251 : : }
252 : :
253 : : // class SvxSizeItem -----------------------------------------------------
254 : :
255 : 9178 : SvxSizeItem::SvxSizeItem( const sal_uInt16 nId, const Size& rSize ) :
256 : :
257 : : SfxPoolItem( nId ),
258 : :
259 : 9178 : aSize( rSize )
260 : : {
261 : 9178 : }
262 : :
263 : : // -----------------------------------------------------------------------
264 : 291 : bool SvxSizeItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
265 : : {
266 : 291 : sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
267 : 291 : nMemberId &= ~CONVERT_TWIPS;
268 : :
269 : 291 : awt::Size aTmp(aSize.Width(), aSize.Height());
270 [ + + ]: 291 : if( bConvert )
271 : : {
272 [ + - ]: 84 : aTmp.Height = TWIP_TO_MM100(aTmp.Height);
273 [ + - ]: 84 : aTmp.Width = TWIP_TO_MM100(aTmp.Width);
274 : : }
275 : :
276 [ + + + - ]: 291 : switch( nMemberId )
277 : : {
278 [ + - ]: 213 : case MID_SIZE_SIZE: rVal <<= aTmp; break;
279 [ + - ]: 31 : case MID_SIZE_WIDTH: rVal <<= aTmp.Width; break;
280 [ + - ]: 47 : case MID_SIZE_HEIGHT: rVal <<= aTmp.Height; break;
281 : 0 : default: OSL_FAIL("Wrong MemberId!"); return false;
282 : : }
283 : :
284 : 291 : return true;
285 : : }
286 : : // -----------------------------------------------------------------------
287 : 2083 : bool SvxSizeItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
288 : : {
289 : 2083 : sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
290 : 2083 : nMemberId &= ~CONVERT_TWIPS;
291 : :
292 [ + + + - ]: 2083 : switch( nMemberId )
293 : : {
294 : : case MID_SIZE_SIZE:
295 : : {
296 : 252 : awt::Size aTmp;
297 [ + - ][ + - ]: 252 : if( rVal >>= aTmp )
298 : : {
299 [ + + ]: 252 : if(bConvert)
300 : : {
301 [ + - ]: 45 : aTmp.Height = MM100_TO_TWIP(aTmp.Height);
302 [ + - ]: 45 : aTmp.Width = MM100_TO_TWIP(aTmp.Width);
303 : : }
304 : 252 : aSize = Size( aTmp.Width, aTmp.Height );
305 : : }
306 : : else
307 : : {
308 : 0 : return false;
309 : : }
310 : : }
311 : 252 : break;
312 : : case MID_SIZE_WIDTH:
313 : : {
314 : 634 : sal_Int32 nVal = 0;
315 [ - + ]: 634 : if(!(rVal >>= nVal ))
316 : 0 : return false;
317 : :
318 [ + - ][ + - ]: 634 : aSize.Width() = bConvert ? MM100_TO_TWIP(nVal) : nVal;
319 : : }
320 : 634 : break;
321 : : case MID_SIZE_HEIGHT:
322 : : {
323 : 1197 : sal_Int32 nVal = 0;
324 [ - + ]: 1197 : if(!(rVal >>= nVal))
325 : 0 : return true;
326 : :
327 [ + - ][ + - ]: 1197 : aSize.Height() = bConvert ? MM100_TO_TWIP(nVal) : nVal;
328 : : }
329 : 1197 : break;
330 : : default: OSL_FAIL("Wrong MemberId!");
331 : 0 : return false;
332 : : }
333 : 2083 : return true;
334 : : }
335 : :
336 : : // -----------------------------------------------------------------------
337 : :
338 : 2007 : SvxSizeItem::SvxSizeItem( const sal_uInt16 nId ) :
339 : :
340 : 2007 : SfxPoolItem( nId )
341 : : {
342 : 2007 : }
343 : :
344 : : // -----------------------------------------------------------------------
345 : :
346 : 3236 : int SvxSizeItem::operator==( const SfxPoolItem& rAttr ) const
347 : : {
348 : : DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
349 : :
350 : 3236 : return ( aSize == ( (SvxSizeItem&)rAttr ).GetSize() );
351 : : }
352 : :
353 : : // -----------------------------------------------------------------------
354 : :
355 : 18169 : SfxPoolItem* SvxSizeItem::Clone( SfxItemPool* ) const
356 : : {
357 [ + - ]: 18169 : return new SvxSizeItem( *this );
358 : : }
359 : :
360 : : //------------------------------------------------------------------------
361 : :
362 : 0 : SfxItemPresentation SvxSizeItem::GetPresentation
363 : : (
364 : : SfxItemPresentation ePres,
365 : : SfxMapUnit eCoreUnit,
366 : : SfxMapUnit ePresUnit,
367 : : XubString& rText, const IntlWrapper *pIntl
368 : : ) const
369 : : {
370 [ # # # # ]: 0 : switch ( ePres )
371 : : {
372 : : case SFX_ITEM_PRESENTATION_NONE:
373 : 0 : rText.Erase();
374 : 0 : return SFX_ITEM_PRESENTATION_NONE;
375 : :
376 : : case SFX_ITEM_PRESENTATION_NAMELESS:
377 [ # # ]: 0 : rText = GetMetricText( aSize.Width(), eCoreUnit, ePresUnit, pIntl );
378 : 0 : rText += cpDelim;
379 [ # # ]: 0 : rText += GetMetricText( aSize.Height(), eCoreUnit, ePresUnit, pIntl );
380 : 0 : return SFX_ITEM_PRESENTATION_NAMELESS;
381 : :
382 : : case SFX_ITEM_PRESENTATION_COMPLETE:
383 [ # # ][ # # ]: 0 : rText = EE_RESSTR(RID_SVXITEMS_SIZE_WIDTH);
384 [ # # ]: 0 : rText += GetMetricText( aSize.Width(), eCoreUnit, ePresUnit, pIntl );
385 [ # # ][ # # ]: 0 : rText += EE_RESSTR(GetMetricId(ePresUnit));
386 : 0 : rText += cpDelim;
387 [ # # ][ # # ]: 0 : rText += EE_RESSTR(RID_SVXITEMS_SIZE_HEIGHT);
388 [ # # ]: 0 : rText += GetMetricText( aSize.Height(), eCoreUnit, ePresUnit, pIntl );
389 [ # # ][ # # ]: 0 : rText += EE_RESSTR(GetMetricId(ePresUnit));
390 : 0 : return SFX_ITEM_PRESENTATION_COMPLETE;
391 : : //no break necessary
392 : : default: ;//prevent warning
393 : :
394 : : }
395 : 0 : return SFX_ITEM_PRESENTATION_NONE;
396 : : }
397 : :
398 : : // -----------------------------------------------------------------------
399 : :
400 : 0 : SvStream& SvxSizeItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
401 : : {
402 : : //#fdo39428 SvStream no longer supports operator<<(long)
403 : 0 : rStrm << sal::static_int_cast<sal_Int32>(aSize.Width());
404 : 0 : rStrm << sal::static_int_cast<sal_Int32>(aSize.Height());
405 : 0 : return rStrm;
406 : : }
407 : :
408 : : // -----------------------------------------------------------------------
409 : :
410 : 0 : bool SvxSizeItem::ScaleMetrics( long nMult, long nDiv )
411 : : {
412 : 0 : aSize.Width() = Scale( aSize.Width(), nMult, nDiv );
413 : 0 : aSize.Height() = Scale( aSize.Height(), nMult, nDiv );
414 : 0 : return true;
415 : : }
416 : :
417 : : // -----------------------------------------------------------------------
418 : :
419 : 0 : bool SvxSizeItem::HasMetrics() const
420 : : {
421 : 0 : return true;
422 : : }
423 : :
424 : : // -----------------------------------------------------------------------
425 : :
426 : 0 : SfxPoolItem* SvxSizeItem::Create( SvStream& rStrm, sal_uInt16 ) const
427 : : {
428 : : //#fdo39428 SvStream no longer supports operator>>(long&)
429 : 0 : sal_Int32 nWidth(0), nHeight(0);
430 [ # # ][ # # ]: 0 : rStrm >> nWidth >> nHeight;
431 : :
432 [ # # ][ # # ]: 0 : SvxSizeItem* pAttr = new SvxSizeItem( Which() );
433 : 0 : pAttr->SetSize(Size(nWidth, nHeight));
434 : :
435 : 0 : return pAttr;
436 : : }
437 : :
438 : : // class SvxLRSpaceItem --------------------------------------------------
439 : :
440 : 13278 : SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId ) :
441 : :
442 : : SfxPoolItem( nId ),
443 : :
444 : : nFirstLineOfst ( 0 ),
445 : : nTxtLeft ( 0 ),
446 : : nLeftMargin ( 0 ),
447 : : nRightMargin ( 0 ),
448 : : nPropFirstLineOfst( 100 ),
449 : : nPropLeftMargin( 100 ),
450 : : nPropRightMargin( 100 ),
451 : 13278 : bAutoFirst ( 0 )
452 : : {
453 : 13278 : }
454 : :
455 : : // -----------------------------------------------------------------------
456 : :
457 : 3445 : SvxLRSpaceItem::SvxLRSpaceItem( const long nLeft, const long nRight,
458 : : const long nTLeft, const short nOfset,
459 : : const sal_uInt16 nId ) :
460 : :
461 : : SfxPoolItem( nId ),
462 : :
463 : : nFirstLineOfst ( nOfset ),
464 : : nTxtLeft ( nTLeft ),
465 : : nLeftMargin ( nLeft ),
466 : : nRightMargin ( nRight ),
467 : : nPropFirstLineOfst( 100 ),
468 : : nPropLeftMargin( 100 ),
469 : : nPropRightMargin( 100 ),
470 : 3445 : bAutoFirst ( 0 )
471 : : {
472 : 3445 : }
473 : :
474 : : // -----------------------------------------------------------------------
475 : 1116 : bool SvxLRSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
476 : : {
477 : 1116 : bool bRet = true;
478 : 1116 : sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
479 : 1116 : nMemberId &= ~CONVERT_TWIPS;
480 [ + + + + : 1116 : switch( nMemberId )
+ + + +
- ]
481 : : {
482 : : // now all signed
483 : : case MID_L_MARGIN:
484 [ + - ][ + - ]: 71 : rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nLeftMargin) : nLeftMargin);
[ + - ]
485 : 71 : break;
486 : :
487 : : case MID_TXT_LMARGIN :
488 [ + + ][ + - ]: 292 : rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nTxtLeft) : nTxtLeft);
[ + - ]
489 : 292 : break;
490 : : case MID_R_MARGIN:
491 [ + + ][ + - ]: 354 : rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nRightMargin) : nRightMargin);
[ + - ]
492 : 354 : break;
493 : : case MID_L_REL_MARGIN:
494 [ + - ]: 26 : rVal <<= (sal_Int16)nPropLeftMargin;
495 : 26 : break;
496 : : case MID_R_REL_MARGIN:
497 [ + - ]: 26 : rVal <<= (sal_Int16)nPropRightMargin;
498 : 26 : break;
499 : :
500 : : case MID_FIRST_LINE_INDENT:
501 [ + + ][ + + ]: 309 : rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nFirstLineOfst) : nFirstLineOfst);
[ + - ]
502 : 309 : break;
503 : :
504 : : case MID_FIRST_LINE_REL_INDENT:
505 [ + - ]: 18 : rVal <<= (sal_Int16)(nPropFirstLineOfst);
506 : 18 : break;
507 : :
508 : : case MID_FIRST_AUTO:
509 : 20 : rVal = Bool2Any(IsAutoFirst());
510 : 20 : break;
511 : :
512 : : default:
513 : 0 : bRet = false;
514 : : OSL_FAIL("unknown MemberId");
515 : : }
516 : 1116 : return bRet;
517 : : }
518 : :
519 : : // -----------------------------------------------------------------------
520 : 5635 : bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
521 : : {
522 : 5635 : sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
523 : 5635 : nMemberId &= ~CONVERT_TWIPS;
524 : 5635 : sal_Int32 nVal = 0;
525 [ + + ][ + + ]: 5635 : if( nMemberId != MID_FIRST_AUTO &&
[ + + ]
526 : : nMemberId != MID_L_REL_MARGIN && nMemberId != MID_R_REL_MARGIN)
527 [ - + ]: 5551 : if(!(rVal >>= nVal))
528 : 0 : return sal_False;
529 : :
530 [ + + + + : 5635 : switch( nMemberId )
+ - + - ]
531 : : {
532 : : case MID_L_MARGIN:
533 [ + - ][ + + ]: 1216 : SetLeft((sal_Int32)bConvert ? MM100_TO_TWIP(nVal) : nVal);
534 : 1216 : break;
535 : :
536 : : case MID_TXT_LMARGIN :
537 [ + + ][ + - ]: 1400 : SetTxtLeft((sal_Int32)bConvert ? MM100_TO_TWIP(nVal) : nVal);
[ + - ]
538 : 1400 : break;
539 : :
540 : : case MID_R_MARGIN:
541 [ + + ][ + + ]: 2481 : SetRight((sal_Int32) bConvert ? MM100_TO_TWIP(nVal) : nVal);
542 : 2481 : break;
543 : : case MID_L_REL_MARGIN:
544 : : case MID_R_REL_MARGIN:
545 : : {
546 : 8 : sal_Int32 nRel = 0;
547 [ + - ][ + - ]: 8 : if((rVal >>= nRel) && nRel >= 0 && nRel < USHRT_MAX)
[ + - ][ + - ]
548 : : {
549 [ + + ]: 8 : if(MID_L_REL_MARGIN== nMemberId)
550 : 4 : nPropLeftMargin = (sal_uInt16)nRel;
551 : : else
552 : 4 : nPropRightMargin = (sal_uInt16)nRel;
553 : : }
554 : : else
555 : 0 : return false;
556 : : }
557 : 8 : break;
558 : : case MID_FIRST_LINE_INDENT :
559 [ + + ][ + + ]: 454 : SetTxtFirstLineOfst((short)(bConvert ? MM100_TO_TWIP(nVal) : nVal));
[ + - ]
560 : 454 : break;
561 : :
562 : : case MID_FIRST_LINE_REL_INDENT:
563 : 0 : SetPropTxtFirstLineOfst ( (sal_uInt16)nVal );
564 : 0 : break;
565 : :
566 : : case MID_FIRST_AUTO:
567 [ + - ]: 76 : SetAutoFirst( Any2Bool(rVal) );
568 : 76 : break;
569 : :
570 : : default:
571 : : OSL_FAIL("unknown MemberId");
572 : 0 : return false;
573 : : }
574 : 5635 : return true;
575 : : }
576 : :
577 : : // -----------------------------------------------------------------------
578 : :
579 : : // Adapt nLeftMargin and nTxtLeft.
580 : :
581 : 4369 : void SvxLRSpaceItem::AdjustLeft()
582 : : {
583 [ + + ]: 4369 : if ( 0 > nFirstLineOfst )
584 : 883 : nLeftMargin = nTxtLeft + nFirstLineOfst;
585 : : else
586 : 3486 : nLeftMargin = nTxtLeft;
587 : 4369 : }
588 : :
589 : : // -----------------------------------------------------------------------
590 : :
591 : 65912 : int SvxLRSpaceItem::operator==( const SfxPoolItem& rAttr ) const
592 : : {
593 : : DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
594 : :
595 : : return (
596 : 65912 : nLeftMargin == ((SvxLRSpaceItem&)rAttr).GetLeft() &&
597 : 29317 : nRightMargin == ((SvxLRSpaceItem&)rAttr).GetRight() &&
598 : 25042 : nFirstLineOfst == ((SvxLRSpaceItem&)rAttr).GetTxtFirstLineOfst() &&
599 : 22295 : nPropLeftMargin == ((SvxLRSpaceItem&)rAttr).GetPropLeft() &&
600 : 22293 : nPropRightMargin == ((SvxLRSpaceItem&)rAttr).GetPropRight() &&
601 : 22281 : nPropFirstLineOfst == ((SvxLRSpaceItem&)rAttr).GetPropTxtFirstLineOfst() &&
602 [ + - ][ + + : 187140 : bAutoFirst == ((SvxLRSpaceItem&)rAttr).IsAutoFirst() );
+ + + + +
+ + + +
- ]
603 : : }
604 : :
605 : : // -----------------------------------------------------------------------
606 : :
607 : 22909 : SfxPoolItem* SvxLRSpaceItem::Clone( SfxItemPool* ) const
608 : : {
609 [ + - ]: 22909 : return new SvxLRSpaceItem( *this );
610 : : }
611 : :
612 : : //------------------------------------------------------------------------
613 : :
614 : 0 : SfxItemPresentation SvxLRSpaceItem::GetPresentation
615 : : (
616 : : SfxItemPresentation ePres,
617 : : SfxMapUnit eCoreUnit,
618 : : SfxMapUnit ePresUnit,
619 : : XubString& rText, const IntlWrapper* pIntl
620 : : ) const
621 : : {
622 [ # # # # ]: 0 : switch ( ePres )
623 : : {
624 : : case SFX_ITEM_PRESENTATION_NONE:
625 : 0 : rText.Erase();
626 : 0 : return SFX_ITEM_PRESENTATION_NONE;
627 : : case SFX_ITEM_PRESENTATION_NAMELESS:
628 : : {
629 [ # # ]: 0 : if ( 100 != nPropLeftMargin )
630 [ # # ][ # # ]: 0 : ( rText = String::CreateFromInt32( nPropLeftMargin )) += sal_Unicode('%');
631 : : else
632 : : rText = GetMetricText( (long)nLeftMargin,
633 [ # # ]: 0 : eCoreUnit, ePresUnit, pIntl );
634 : 0 : rText += cpDelim;
635 [ # # ]: 0 : if ( 100 != nPropFirstLineOfst )
636 [ # # ][ # # ]: 0 : ( rText += String::CreateFromInt32( nPropFirstLineOfst )) += sal_Unicode('%');
637 : : else
638 : : rText += GetMetricText( (long)nFirstLineOfst,
639 [ # # ]: 0 : eCoreUnit, ePresUnit, pIntl );
640 : 0 : rText += cpDelim;
641 [ # # ]: 0 : if ( 100 != nRightMargin )
642 [ # # ][ # # ]: 0 : ( rText += String::CreateFromInt32( nRightMargin )) += sal_Unicode('%');
643 : : else
644 : : rText += GetMetricText( (long)nRightMargin,
645 [ # # ]: 0 : eCoreUnit, ePresUnit, pIntl );
646 : 0 : return SFX_ITEM_PRESENTATION_NAMELESS;
647 : : }
648 : : case SFX_ITEM_PRESENTATION_COMPLETE:
649 : : {
650 [ # # ][ # # ]: 0 : rText = EE_RESSTR(RID_SVXITEMS_LRSPACE_LEFT);
651 [ # # ]: 0 : if ( 100 != nPropLeftMargin )
652 [ # # ][ # # ]: 0 : ( rText += String::CreateFromInt32( nPropLeftMargin )) += sal_Unicode('%');
653 : : else
654 : : {
655 : : rText += GetMetricText( (long)nLeftMargin,
656 [ # # ]: 0 : eCoreUnit, ePresUnit, pIntl );
657 [ # # ][ # # ]: 0 : rText += EE_RESSTR(GetMetricId(ePresUnit));
658 : : }
659 : 0 : rText += cpDelim;
660 [ # # ][ # # ]: 0 : if ( 100 != nPropFirstLineOfst || nFirstLineOfst )
661 : : {
662 [ # # ][ # # ]: 0 : rText += EE_RESSTR(RID_SVXITEMS_LRSPACE_FLINE);
663 [ # # ]: 0 : if ( 100 != nPropFirstLineOfst )
664 [ # # ]: 0 : ( rText += String::CreateFromInt32( nPropFirstLineOfst ))
665 [ # # ]: 0 : += sal_Unicode('%');
666 : : else
667 : : {
668 : : rText += GetMetricText( (long)nFirstLineOfst,
669 [ # # ]: 0 : eCoreUnit, ePresUnit, pIntl );
670 [ # # ][ # # ]: 0 : rText += EE_RESSTR(GetMetricId(ePresUnit));
671 : : }
672 : 0 : rText += cpDelim;
673 : : }
674 [ # # ][ # # ]: 0 : rText += EE_RESSTR(RID_SVXITEMS_LRSPACE_RIGHT);
675 [ # # ]: 0 : if ( 100 != nPropRightMargin )
676 [ # # ][ # # ]: 0 : ( rText += String::CreateFromInt32( nPropRightMargin )) += sal_Unicode('%');
677 : : else
678 : : {
679 : : rText += GetMetricText( (long)nRightMargin,
680 [ # # ]: 0 : eCoreUnit, ePresUnit, pIntl );
681 [ # # ][ # # ]: 0 : rText += EE_RESSTR(GetMetricId(ePresUnit));
682 : : }
683 : 0 : return SFX_ITEM_PRESENTATION_COMPLETE;
684 : : }
685 : : default: ;//prevent warning
686 : : }
687 : 0 : return SFX_ITEM_PRESENTATION_NONE;
688 : : }
689 : :
690 : : // -----------------------------------------------------------------------
691 : :
692 : : // BulletFI: Before 501 in the Outliner the bullet was not on the position of
693 : : // the FI, so in older documents one must set FI to 0.
694 : : #define BULLETLR_MARKER 0x599401FE
695 : :
696 : 0 : SvStream& SvxLRSpaceItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
697 : : {
698 : 0 : short nSaveFI = nFirstLineOfst;
699 : 0 : ((SvxLRSpaceItem*)this)->SetTxtFirstLineOfst( 0 ); // nLeftMargin is manipulated together with this, see Create()
700 : :
701 : 0 : sal_uInt16 nMargin = 0;
702 [ # # ]: 0 : if( nLeftMargin > 0 )
703 : 0 : nMargin = sal_uInt16( nLeftMargin );
704 : 0 : rStrm << nMargin;
705 : 0 : rStrm << nPropLeftMargin;
706 [ # # ]: 0 : if( nRightMargin > 0 )
707 : 0 : nMargin = sal_uInt16( nRightMargin );
708 : : else
709 : 0 : nMargin = 0;
710 : 0 : rStrm << nMargin;
711 : 0 : rStrm << nPropRightMargin;
712 : 0 : rStrm << nFirstLineOfst;
713 : 0 : rStrm << nPropFirstLineOfst;
714 [ # # ]: 0 : if( nTxtLeft > 0 )
715 : 0 : nMargin = sal_uInt16( nTxtLeft );
716 : : else
717 : 0 : nMargin = 0;
718 : 0 : rStrm << nMargin;
719 [ # # ]: 0 : if( nItemVersion >= LRSPACE_AUTOFIRST_VERSION )
720 : : {
721 : 0 : sal_Int8 nAutoFirst = bAutoFirst ? 1 : 0;
722 [ # # ][ # # ]: 0 : if( nItemVersion >= LRSPACE_NEGATIVE_VERSION &&
[ # # ][ # # ]
723 : : ( nLeftMargin < 0 || nRightMargin < 0 || nTxtLeft < 0 ) )
724 : 0 : nAutoFirst |= 0x80;
725 : 0 : rStrm << nAutoFirst;
726 : :
727 : : // From 6.0 onwards, do not write Magic numbers...
728 : : DBG_ASSERT( rStrm.GetVersion() <= SOFFICE_FILEFORMAT_50, "Change File format SvxLRSpaceItem!" );
729 : 0 : rStrm << (sal_uInt32) BULLETLR_MARKER;
730 : 0 : rStrm << nSaveFI;
731 : :
732 [ # # ]: 0 : if( 0x80 & nAutoFirst )
733 : : {
734 : 0 : rStrm << static_cast<sal_Int32>(nLeftMargin);
735 : 0 : rStrm << static_cast<sal_Int32>(nRightMargin);
736 : : }
737 : : }
738 : :
739 : 0 : ((SvxLRSpaceItem*)this)->SetTxtFirstLineOfst( nSaveFI );
740 : :
741 : 0 : return rStrm;
742 : : }
743 : :
744 : : // -----------------------------------------------------------------------
745 : :
746 : 0 : SfxPoolItem* SvxLRSpaceItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
747 : : {
748 : : sal_uInt16 left, prpleft, right, prpright, prpfirstline, txtleft;
749 : : short firstline;
750 : 0 : sal_Int8 autofirst = 0;
751 : :
752 [ # # ]: 0 : if ( nVersion >= LRSPACE_AUTOFIRST_VERSION )
753 : : {
754 [ # # ][ # # ]: 0 : rStrm >> left >> prpleft >> right >> prpright >> firstline >>
[ # # ][ # # ]
[ # # ]
755 [ # # ][ # # ]: 0 : prpfirstline >> txtleft >> autofirst;
[ # # ]
756 : :
757 : 0 : sal_uInt32 nPos = rStrm.Tell();
758 : : sal_uInt32 nMarker;
759 [ # # ]: 0 : rStrm >> nMarker;
760 [ # # ]: 0 : if ( nMarker == BULLETLR_MARKER )
761 : : {
762 [ # # ]: 0 : rStrm >> firstline;
763 [ # # ]: 0 : if ( firstline < 0 )
764 : 0 : left = left + static_cast<sal_uInt16>(firstline); // see below: txtleft = ...
765 : : }
766 : : else
767 [ # # ]: 0 : rStrm.Seek( nPos );
768 : : }
769 [ # # ]: 0 : else if ( nVersion == LRSPACE_TXTLEFT_VERSION )
770 : : {
771 [ # # ][ # # ]: 0 : rStrm >> left >> prpleft >> right >> prpright >> firstline >>
[ # # ][ # # ]
[ # # ]
772 [ # # ][ # # ]: 0 : prpfirstline >> txtleft;
773 : : }
774 [ # # ]: 0 : else if ( nVersion == LRSPACE_16_VERSION )
775 : : {
776 [ # # ][ # # ]: 0 : rStrm >> left >> prpleft >> right >> prpright >> firstline >>
[ # # ][ # # ]
[ # # ]
777 [ # # ]: 0 : prpfirstline;
778 : : }
779 : : else
780 : : {
781 : : sal_Int8 nL, nR, nFL;
782 [ # # ][ # # ]: 0 : rStrm >> left >> nL >> right >> nR >> firstline >> nFL;
[ # # ][ # # ]
[ # # ][ # # ]
783 : 0 : prpleft = (sal_uInt16)nL;
784 : 0 : prpright = (sal_uInt16)nR;
785 : 0 : prpfirstline = (sal_uInt16)nFL;
786 : : }
787 : :
788 [ # # ]: 0 : txtleft = firstline >= 0 ? left : left - firstline;
789 [ # # ][ # # ]: 0 : SvxLRSpaceItem* pAttr = new SvxLRSpaceItem( Which() );
790 : :
791 : 0 : pAttr->nLeftMargin = left;
792 : 0 : pAttr->nPropLeftMargin = prpleft;
793 : 0 : pAttr->nRightMargin = right;
794 : 0 : pAttr->nPropRightMargin = prpright;
795 : 0 : pAttr->nFirstLineOfst = firstline;
796 : 0 : pAttr->nPropFirstLineOfst = prpfirstline;
797 : 0 : pAttr->nTxtLeft = txtleft;
798 : 0 : pAttr->bAutoFirst = autofirst & 0x01;
799 [ # # ][ # # ]: 0 : if( nVersion >= LRSPACE_NEGATIVE_VERSION && ( autofirst & 0x80 ) )
800 : : {
801 : : sal_Int32 nMargin;
802 [ # # ]: 0 : rStrm >> nMargin;
803 : 0 : pAttr->nLeftMargin = nMargin;
804 [ # # ]: 0 : pAttr->nTxtLeft = firstline >= 0 ? nMargin : nMargin - firstline;
805 [ # # ]: 0 : rStrm >> nMargin;
806 : 0 : pAttr->nRightMargin = nMargin;
807 : : }
808 : 0 : return pAttr;
809 : : }
810 : :
811 : : // -----------------------------------------------------------------------
812 : :
813 : 14232 : sal_uInt16 SvxLRSpaceItem::GetVersion( sal_uInt16 nFileVersion ) const
814 : : {
815 : : return (nFileVersion == SOFFICE_FILEFORMAT_31)
816 : : ? LRSPACE_TXTLEFT_VERSION
817 [ - + ]: 14232 : : LRSPACE_NEGATIVE_VERSION;
818 : : }
819 : :
820 : : // -----------------------------------------------------------------------
821 : :
822 : 0 : bool SvxLRSpaceItem::ScaleMetrics( long nMult, long nDiv )
823 : : {
824 : 0 : nFirstLineOfst = (short)Scale( nFirstLineOfst, nMult, nDiv );
825 : 0 : nTxtLeft = Scale( nTxtLeft, nMult, nDiv );
826 : 0 : nLeftMargin = Scale( nLeftMargin, nMult, nDiv );
827 : 0 : nRightMargin = Scale( nRightMargin, nMult, nDiv );
828 : 0 : return true;
829 : : }
830 : :
831 : : // -----------------------------------------------------------------------
832 : :
833 : 0 : bool SvxLRSpaceItem::HasMetrics() const
834 : : {
835 : 0 : return true;
836 : : }
837 : :
838 : : // class SvxULSpaceItem --------------------------------------------------
839 : :
840 : 7320 : SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nId )
841 : : : SfxPoolItem(nId)
842 : : , nUpper(0)
843 : : , nLower(0)
844 : : , bContext(false)
845 : : , nPropUpper(100)
846 : 7320 : , nPropLower(100)
847 : : {
848 : 7320 : }
849 : :
850 : : // -----------------------------------------------------------------------
851 : :
852 : 6526 : SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nUp, const sal_uInt16 nLow,
853 : : const sal_uInt16 nId )
854 : : : SfxPoolItem(nId)
855 : : , nUpper(nUp)
856 : : , nLower(nLow)
857 : : , bContext(false)
858 : : , nPropUpper(100)
859 : 6526 : , nPropLower(100)
860 : : {
861 : 6526 : }
862 : :
863 : : // -----------------------------------------------------------------------
864 : 1131 : bool SvxULSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
865 : : {
866 : 1131 : bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
867 : 1131 : nMemberId &= ~CONVERT_TWIPS;
868 [ - + + + : 1131 : switch( nMemberId )
+ + - ]
869 : : {
870 : : // now all signed
871 : : case 0:
872 : : {
873 : 0 : ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale;
874 [ # # ]: 0 : aUpperLowerMarginScale.Upper = (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nUpper) : nUpper);
875 [ # # ]: 0 : aUpperLowerMarginScale.Lower = (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nLower) : nPropUpper);
876 : 0 : aUpperLowerMarginScale.ScaleUpper = (sal_Int16)nPropUpper;
877 : 0 : aUpperLowerMarginScale.ScaleLower = (sal_Int16)nPropLower;
878 [ # # ]: 0 : rVal <<= aUpperLowerMarginScale;
879 : : break;
880 : : }
881 [ + + ][ + - ]: 459 : case MID_UP_MARGIN: rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nUpper) : nUpper); break;
882 [ + + ][ + - ]: 453 : case MID_LO_MARGIN: rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nLower) : nLower); break;
883 : 75 : case MID_CTX_MARGIN: rVal <<= bContext; break;
884 [ + - ]: 72 : case MID_UP_REL_MARGIN: rVal <<= (sal_Int16) nPropUpper; break;
885 [ + - ]: 72 : case MID_LO_REL_MARGIN: rVal <<= (sal_Int16) nPropLower; break;
886 : : }
887 : 1131 : return true;
888 : : }
889 : :
890 : : // -----------------------------------------------------------------------
891 : 6969 : bool SvxULSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
892 : : {
893 : 6969 : sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
894 : 6969 : nMemberId &= ~CONVERT_TWIPS;
895 : 6969 : sal_Int32 nVal = 0;
896 : 6969 : sal_Bool bVal = 0;
897 [ - + + + : 6969 : switch( nMemberId )
+ - ]
898 : : {
899 : : case 0:
900 : : {
901 : 0 : ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale;
902 [ # # ][ # # ]: 0 : if ( !(rVal >>= aUpperLowerMarginScale ))
903 : 0 : return false;
904 : : {
905 [ # # ][ # # ]: 0 : SetUpper((sal_uInt16)(bConvert ? MM100_TO_TWIP( aUpperLowerMarginScale.Upper ) : aUpperLowerMarginScale.Upper));
906 [ # # ][ # # ]: 0 : SetLower((sal_uInt16)(bConvert ? MM100_TO_TWIP( aUpperLowerMarginScale.Lower ) : aUpperLowerMarginScale.Lower));
907 [ # # ]: 0 : if( aUpperLowerMarginScale.ScaleUpper > 1 )
908 : 0 : nPropUpper = aUpperLowerMarginScale.ScaleUpper;
909 [ # # ]: 0 : if( aUpperLowerMarginScale.ScaleLower > 1 )
910 : 0 : nPropUpper = aUpperLowerMarginScale.ScaleLower;
911 : : }
912 : : }
913 : :
914 : : case MID_UP_MARGIN :
915 [ + - ][ - + ]: 3169 : if(!(rVal >>= nVal) || nVal < 0)
[ - + ]
916 : 0 : return false;
917 [ + + ][ + - ]: 3169 : SetUpper((sal_uInt16)(bConvert ? MM100_TO_TWIP(nVal) : nVal));
918 : 3169 : break;
919 : : case MID_LO_MARGIN :
920 [ + - ][ - + ]: 3314 : if(!(rVal >>= nVal) || nVal < 0)
[ - + ]
921 : 0 : return false;
922 [ + + ][ + - ]: 3314 : SetLower((sal_uInt16)(bConvert ? MM100_TO_TWIP(nVal) : nVal));
923 : 3314 : break;
924 : : case MID_CTX_MARGIN :
925 [ - + ]: 450 : if (!(rVal >>= bVal))
926 : 0 : return false;
927 : 450 : SetContextValue(bVal);
928 : 450 : break;
929 : : case MID_UP_REL_MARGIN:
930 : : case MID_LO_REL_MARGIN:
931 : : {
932 : 36 : sal_Int32 nRel = 0;
933 [ + - ][ + - ]: 36 : if((rVal >>= nRel) && nRel > 1 )
[ + - ]
934 : : {
935 [ + + ]: 36 : if(MID_UP_REL_MARGIN == nMemberId)
936 : 18 : nPropUpper = (sal_uInt16)nRel;
937 : : else
938 : 18 : nPropLower = (sal_uInt16)nRel;
939 : : }
940 : : else
941 : 0 : return false;
942 : : }
943 : 36 : break;
944 : :
945 : : default:
946 : : OSL_FAIL("unknown MemberId");
947 : 0 : return false;
948 : : }
949 : 6969 : return true;
950 : : }
951 : :
952 : : // -----------------------------------------------------------------------
953 : :
954 : 76795 : int SvxULSpaceItem::operator==( const SfxPoolItem& rAttr ) const
955 : : {
956 : : DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
957 : :
958 : : return ( nUpper == ( (SvxULSpaceItem&)rAttr ).nUpper &&
959 : : nLower == ( (SvxULSpaceItem&)rAttr ).nLower &&
960 : : bContext == ( (SvxULSpaceItem&)rAttr ).bContext &&
961 : : nPropUpper == ( (SvxULSpaceItem&)rAttr ).nPropUpper &&
962 [ + + ][ + + ]: 76795 : nPropLower == ( (SvxULSpaceItem&)rAttr ).nPropLower );
[ + + ][ + - ]
[ + + ]
963 : : }
964 : :
965 : : // -----------------------------------------------------------------------
966 : :
967 : 21041 : SfxPoolItem* SvxULSpaceItem::Clone( SfxItemPool* ) const
968 : : {
969 [ + - ]: 21041 : return new SvxULSpaceItem( *this );
970 : : }
971 : :
972 : : //------------------------------------------------------------------------
973 : :
974 : 0 : SfxItemPresentation SvxULSpaceItem::GetPresentation
975 : : (
976 : : SfxItemPresentation ePres,
977 : : SfxMapUnit eCoreUnit,
978 : : SfxMapUnit ePresUnit,
979 : : XubString& rText, const IntlWrapper *pIntl
980 : : ) const
981 : : {
982 [ # # # # ]: 0 : switch ( ePres )
983 : : {
984 : : case SFX_ITEM_PRESENTATION_NONE:
985 : 0 : rText.Erase();
986 : 0 : return SFX_ITEM_PRESENTATION_NONE;
987 : : case SFX_ITEM_PRESENTATION_NAMELESS:
988 : : {
989 [ # # ]: 0 : if ( 100 != nPropUpper )
990 [ # # ][ # # ]: 0 : ( rText = String::CreateFromInt32( nPropUpper )) += sal_Unicode('%');
991 : : else
992 [ # # ]: 0 : rText = GetMetricText( (long)nUpper, eCoreUnit, ePresUnit, pIntl );
993 : 0 : rText += cpDelim;
994 [ # # ]: 0 : if ( 100 != nPropLower )
995 [ # # ][ # # ]: 0 : ( rText += String::CreateFromInt32( nPropLower )) += sal_Unicode('%');
996 : : else
997 [ # # ]: 0 : rText += GetMetricText( (long)nLower, eCoreUnit, ePresUnit, pIntl );
998 : 0 : return SFX_ITEM_PRESENTATION_NAMELESS;
999 : : }
1000 : : case SFX_ITEM_PRESENTATION_COMPLETE:
1001 : : {
1002 [ # # ][ # # ]: 0 : rText = EE_RESSTR(RID_SVXITEMS_ULSPACE_UPPER);
1003 [ # # ]: 0 : if ( 100 != nPropUpper )
1004 [ # # ][ # # ]: 0 : ( rText += String::CreateFromInt32( nPropUpper )) += sal_Unicode('%');
1005 : : else
1006 : : {
1007 [ # # ]: 0 : rText += GetMetricText( (long)nUpper, eCoreUnit, ePresUnit, pIntl );
1008 [ # # ][ # # ]: 0 : rText += EE_RESSTR(GetMetricId(ePresUnit));
1009 : : }
1010 : 0 : rText += cpDelim;
1011 [ # # ][ # # ]: 0 : rText += EE_RESSTR(RID_SVXITEMS_ULSPACE_LOWER);
1012 [ # # ]: 0 : if ( 100 != nPropLower )
1013 [ # # ][ # # ]: 0 : ( rText += String::CreateFromInt32( nPropLower )) += sal_Unicode('%');
1014 : : else
1015 : : {
1016 [ # # ]: 0 : rText += GetMetricText( (long)nLower, eCoreUnit, ePresUnit, pIntl );
1017 [ # # ][ # # ]: 0 : rText += EE_RESSTR(GetMetricId(ePresUnit));
1018 : : }
1019 : 0 : return SFX_ITEM_PRESENTATION_COMPLETE;
1020 : : }
1021 : : default: ;//prevent warning
1022 : : }
1023 : 0 : return SFX_ITEM_PRESENTATION_NONE;
1024 : : }
1025 : :
1026 : : // -----------------------------------------------------------------------
1027 : :
1028 : 0 : SvStream& SvxULSpaceItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1029 : : {
1030 : 0 : rStrm << GetUpper()
1031 : 0 : << GetPropUpper()
1032 : 0 : << GetLower()
1033 : 0 : << GetPropLower();
1034 : 0 : return rStrm;
1035 : : }
1036 : :
1037 : : // -----------------------------------------------------------------------
1038 : :
1039 : 0 : SfxPoolItem* SvxULSpaceItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
1040 : : {
1041 : 0 : sal_uInt16 upper, lower, nPL = 0, nPU = 0;
1042 : :
1043 [ # # ]: 0 : if ( nVersion == ULSPACE_16_VERSION )
1044 [ # # ][ # # ]: 0 : rStrm >> upper >> nPU >> lower >> nPL;
[ # # ][ # # ]
1045 : : else
1046 : : {
1047 : : sal_Int8 nU, nL;
1048 [ # # ][ # # ]: 0 : rStrm >> upper >> nU >> lower >> nL;
[ # # ][ # # ]
1049 : 0 : nPL = (sal_uInt16)nL;
1050 : 0 : nPU = (sal_uInt16)nU;
1051 : : }
1052 : :
1053 [ # # ][ # # ]: 0 : SvxULSpaceItem* pAttr = new SvxULSpaceItem( Which() );
1054 : 0 : pAttr->SetUpperValue( upper );
1055 : 0 : pAttr->SetLowerValue( lower );
1056 : 0 : pAttr->SetPropUpper( nPU );
1057 : 0 : pAttr->SetPropLower( nPL );
1058 : 0 : return pAttr;
1059 : : }
1060 : :
1061 : : // -----------------------------------------------------------------------
1062 : :
1063 : 7116 : sal_uInt16 SvxULSpaceItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const
1064 : : {
1065 : 7116 : return ULSPACE_16_VERSION;
1066 : : }
1067 : :
1068 : : // -----------------------------------------------------------------------
1069 : :
1070 : 0 : bool SvxULSpaceItem::ScaleMetrics( long nMult, long nDiv )
1071 : : {
1072 : 0 : nUpper = (sal_uInt16)Scale( nUpper, nMult, nDiv );
1073 : 0 : nLower = (sal_uInt16)Scale( nLower, nMult, nDiv );
1074 : 0 : return true;
1075 : : }
1076 : :
1077 : : // -----------------------------------------------------------------------
1078 : :
1079 : 0 : bool SvxULSpaceItem::HasMetrics() const
1080 : : {
1081 : 0 : return true;
1082 : : }
1083 : :
1084 : : // class SvxPrintItem ----------------------------------------------------
1085 : :
1086 : 2 : SfxPoolItem* SvxPrintItem::Clone( SfxItemPool* ) const
1087 : : {
1088 [ + - ]: 2 : return new SvxPrintItem( *this );
1089 : : }
1090 : :
1091 : : // -----------------------------------------------------------------------
1092 : :
1093 : 0 : SvStream& SvxPrintItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1094 : : {
1095 : 0 : rStrm << (sal_Int8)GetValue();
1096 : 0 : return rStrm;
1097 : : }
1098 : :
1099 : : // -----------------------------------------------------------------------
1100 : :
1101 : 0 : SfxPoolItem* SvxPrintItem::Create( SvStream& rStrm, sal_uInt16 ) const
1102 : : {
1103 : : sal_Int8 bIsPrint;
1104 [ # # ]: 0 : rStrm >> bIsPrint;
1105 [ # # ][ # # ]: 0 : return new SvxPrintItem( Which(), sal_Bool( bIsPrint != 0 ) );
1106 : : }
1107 : :
1108 : : //------------------------------------------------------------------------
1109 : :
1110 : 0 : SfxItemPresentation SvxPrintItem::GetPresentation
1111 : : (
1112 : : SfxItemPresentation ePres,
1113 : : SfxMapUnit /*eCoreUnit*/,
1114 : : SfxMapUnit /*ePresUnit*/,
1115 : : XubString& rText, const IntlWrapper *
1116 : : ) const
1117 : : {
1118 [ # # # ]: 0 : switch ( ePres )
1119 : : {
1120 : : case SFX_ITEM_PRESENTATION_NONE:
1121 : 0 : rText.Erase();
1122 : 0 : return ePres;
1123 : :
1124 : : case SFX_ITEM_PRESENTATION_NAMELESS:
1125 : : case SFX_ITEM_PRESENTATION_COMPLETE:
1126 : : {
1127 : 0 : sal_uInt16 nId = RID_SVXITEMS_PRINT_FALSE;
1128 : :
1129 [ # # ]: 0 : if ( GetValue() )
1130 : 0 : nId = RID_SVXITEMS_PRINT_TRUE;
1131 [ # # ][ # # ]: 0 : rText = EE_RESSTR(nId);
1132 : 0 : return ePres;
1133 : : }
1134 : : default: ;//prevent warning
1135 : : }
1136 : 0 : return SFX_ITEM_PRESENTATION_NONE;
1137 : : }
1138 : :
1139 : : // class SvxOpaqueItem ---------------------------------------------------
1140 : :
1141 : 14 : SfxPoolItem* SvxOpaqueItem::Clone( SfxItemPool* ) const
1142 : : {
1143 [ + - ]: 14 : return new SvxOpaqueItem( *this );
1144 : : }
1145 : :
1146 : : // -----------------------------------------------------------------------
1147 : :
1148 : 0 : SvStream& SvxOpaqueItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1149 : : {
1150 : 0 : rStrm << (sal_Int8)GetValue();
1151 : 0 : return rStrm;
1152 : : }
1153 : :
1154 : : // -----------------------------------------------------------------------
1155 : :
1156 : 0 : SfxPoolItem* SvxOpaqueItem::Create( SvStream& rStrm, sal_uInt16 ) const
1157 : : {
1158 : : sal_Int8 bIsOpaque;
1159 [ # # ]: 0 : rStrm >> bIsOpaque;
1160 [ # # ][ # # ]: 0 : return new SvxOpaqueItem( Which(), sal_Bool( bIsOpaque != 0 ) );
1161 : : }
1162 : :
1163 : : //------------------------------------------------------------------------
1164 : :
1165 : 0 : SfxItemPresentation SvxOpaqueItem::GetPresentation
1166 : : (
1167 : : SfxItemPresentation ePres,
1168 : : SfxMapUnit /*eCoreUnit*/,
1169 : : SfxMapUnit /*ePresUnit*/,
1170 : : XubString& rText, const IntlWrapper *
1171 : : ) const
1172 : : {
1173 [ # # # ]: 0 : switch ( ePres )
1174 : : {
1175 : : case SFX_ITEM_PRESENTATION_NONE:
1176 : 0 : rText.Erase();
1177 : 0 : return ePres;
1178 : :
1179 : : case SFX_ITEM_PRESENTATION_NAMELESS:
1180 : : case SFX_ITEM_PRESENTATION_COMPLETE:
1181 : : {
1182 : 0 : sal_uInt16 nId = RID_SVXITEMS_OPAQUE_FALSE;
1183 : :
1184 [ # # ]: 0 : if ( GetValue() )
1185 : 0 : nId = RID_SVXITEMS_OPAQUE_TRUE;
1186 [ # # ][ # # ]: 0 : rText = EE_RESSTR(nId);
1187 : 0 : return ePres;
1188 : : }
1189 : : default: ;//prevent warning
1190 : : }
1191 : 0 : return SFX_ITEM_PRESENTATION_NONE;
1192 : : }
1193 : :
1194 : : // class SvxProtectItem --------------------------------------------------
1195 : :
1196 : 491 : int SvxProtectItem::operator==( const SfxPoolItem& rAttr ) const
1197 : : {
1198 : : DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
1199 : :
1200 : : return ( bCntnt == ( (SvxProtectItem&)rAttr ).bCntnt &&
1201 : : bSize == ( (SvxProtectItem&)rAttr ).bSize &&
1202 [ + + ][ + + ]: 491 : bPos == ( (SvxProtectItem&)rAttr ).bPos );
[ + - ]
1203 : : }
1204 : :
1205 : 14 : bool SvxProtectItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1206 : : {
1207 : 14 : nMemberId &= ~CONVERT_TWIPS;
1208 : : sal_Bool bValue;
1209 [ + - - - ]: 14 : switch(nMemberId)
1210 : : {
1211 : 14 : case MID_PROTECT_CONTENT : bValue = bCntnt; break;
1212 : 0 : case MID_PROTECT_SIZE : bValue = bSize; break;
1213 : 0 : case MID_PROTECT_POSITION: bValue = bPos; break;
1214 : : default:
1215 : : OSL_FAIL("Wrong MemberId");
1216 : 0 : return false;
1217 : : }
1218 : :
1219 : 14 : rVal = Bool2Any( bValue );
1220 : 14 : return true;
1221 : : }
1222 : :
1223 : 6 : bool SvxProtectItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1224 : : {
1225 : 6 : nMemberId &= ~CONVERT_TWIPS;
1226 : 6 : sal_Bool bVal( Any2Bool(rVal) );
1227 [ + - - - ]: 6 : switch(nMemberId)
1228 : : {
1229 : 6 : case MID_PROTECT_CONTENT : bCntnt = bVal; break;
1230 : 0 : case MID_PROTECT_SIZE : bSize = bVal; break;
1231 : 0 : case MID_PROTECT_POSITION: bPos = bVal; break;
1232 : : default:
1233 : : OSL_FAIL("Wrong MemberId");
1234 : 0 : return false;
1235 : : }
1236 : 6 : return true;
1237 : : }
1238 : :
1239 : : // -----------------------------------------------------------------------
1240 : :
1241 : 1876 : SfxPoolItem* SvxProtectItem::Clone( SfxItemPool* ) const
1242 : : {
1243 [ + - ]: 1876 : return new SvxProtectItem( *this );
1244 : : }
1245 : :
1246 : : //------------------------------------------------------------------------
1247 : :
1248 : 0 : SfxItemPresentation SvxProtectItem::GetPresentation
1249 : : (
1250 : : SfxItemPresentation ePres,
1251 : : SfxMapUnit /*eCoreUnit*/,
1252 : : SfxMapUnit /*ePresUnit*/,
1253 : : XubString& rText, const IntlWrapper *
1254 : : ) const
1255 : : {
1256 [ # # # ]: 0 : switch ( ePres )
1257 : : {
1258 : : case SFX_ITEM_PRESENTATION_NONE:
1259 : 0 : rText.Erase();
1260 : 0 : return ePres;
1261 : :
1262 : : case SFX_ITEM_PRESENTATION_NAMELESS:
1263 : : case SFX_ITEM_PRESENTATION_COMPLETE:
1264 : : {
1265 : 0 : sal_uInt16 nId = RID_SVXITEMS_PROT_CONTENT_FALSE;
1266 : :
1267 [ # # ]: 0 : if ( bCntnt )
1268 : 0 : nId = RID_SVXITEMS_PROT_CONTENT_TRUE;
1269 [ # # ][ # # ]: 0 : rText = EE_RESSTR(nId);
1270 : 0 : rText += cpDelim;
1271 : 0 : nId = RID_SVXITEMS_PROT_SIZE_FALSE;
1272 : :
1273 [ # # ]: 0 : if ( bSize )
1274 : 0 : nId = RID_SVXITEMS_PROT_SIZE_TRUE;
1275 [ # # ][ # # ]: 0 : rText += EE_RESSTR(nId);
1276 : 0 : rText += cpDelim;
1277 : 0 : nId = RID_SVXITEMS_PROT_POS_FALSE;
1278 : :
1279 [ # # ]: 0 : if ( bPos )
1280 : 0 : nId = RID_SVXITEMS_PROT_POS_TRUE;
1281 [ # # ][ # # ]: 0 : rText += EE_RESSTR(nId);
1282 : 0 : return ePres;
1283 : : }
1284 : : default: ;//prevent warning
1285 : : }
1286 : 0 : return SFX_ITEM_PRESENTATION_NONE;
1287 : : }
1288 : :
1289 : : // -----------------------------------------------------------------------
1290 : :
1291 : 0 : SvStream& SvxProtectItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1292 : : {
1293 : 0 : sal_Int8 cProt = 0;
1294 [ # # ]: 0 : if( IsPosProtected() ) cProt |= 0x01;
1295 [ # # ]: 0 : if( IsSizeProtected() ) cProt |= 0x02;
1296 [ # # ]: 0 : if( IsCntntProtected() ) cProt |= 0x04;
1297 : 0 : rStrm << (sal_Int8) cProt;
1298 : 0 : return rStrm;
1299 : : }
1300 : :
1301 : : // -----------------------------------------------------------------------
1302 : :
1303 : 0 : SfxPoolItem* SvxProtectItem::Create( SvStream& rStrm, sal_uInt16 ) const
1304 : : {
1305 : : sal_Int8 cFlags;
1306 [ # # ]: 0 : rStrm >> cFlags;
1307 [ # # ][ # # ]: 0 : SvxProtectItem* pAttr = new SvxProtectItem( Which() );
1308 : 0 : pAttr->SetPosProtect( sal_Bool( ( cFlags & 0x01 ) != 0 ) );
1309 : 0 : pAttr->SetSizeProtect( sal_Bool( ( cFlags & 0x02 ) != 0 ) );
1310 : 0 : pAttr->SetCntntProtect( sal_Bool( ( cFlags & 0x04 ) != 0 ) );
1311 : 0 : return pAttr;
1312 : : }
1313 : :
1314 : : // class SvxShadowItem ---------------------------------------------------
1315 : :
1316 : 1072 : SvxShadowItem::SvxShadowItem( const sal_uInt16 nId,
1317 : : const Color *pColor, const sal_uInt16 nW,
1318 : : const SvxShadowLocation eLoc ) :
1319 : : SfxEnumItemInterface( nId ),
1320 : : aShadowColor(COL_GRAY),
1321 : : nWidth ( nW ),
1322 : 1072 : eLocation ( eLoc )
1323 : : {
1324 [ - + ]: 1072 : if ( pColor )
1325 : 0 : aShadowColor = *pColor;
1326 : 1072 : }
1327 : :
1328 : : // -----------------------------------------------------------------------
1329 : 92 : bool SvxShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1330 : : {
1331 : 92 : sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1332 : 92 : nMemberId &= ~CONVERT_TWIPS;
1333 : :
1334 : 92 : table::ShadowFormat aShadow;
1335 : 92 : table::ShadowLocation eSet = table::ShadowLocation_NONE;
1336 [ - - - - : 92 : switch( eLocation )
+ ]
1337 : : {
1338 : 0 : case SVX_SHADOW_TOPLEFT : eSet = table::ShadowLocation_TOP_LEFT ; break;
1339 : 0 : case SVX_SHADOW_TOPRIGHT : eSet = table::ShadowLocation_TOP_RIGHT ; break;
1340 : 0 : case SVX_SHADOW_BOTTOMLEFT : eSet = table::ShadowLocation_BOTTOM_LEFT ; break;
1341 : 0 : case SVX_SHADOW_BOTTOMRIGHT: eSet = table::ShadowLocation_BOTTOM_RIGHT; break;
1342 : : default: ;//prevent warning
1343 : : }
1344 : 92 : aShadow.Location = eSet;
1345 [ + + ]: 92 : aShadow.ShadowWidth = bConvert ? TWIP_TO_MM100_UNSIGNED(nWidth) : nWidth;
1346 : 92 : aShadow.IsTransparent = aShadowColor.GetTransparency() > 0;
1347 : 92 : aShadow.Color = aShadowColor.GetRGBColor();
1348 : :
1349 [ - - - - : 92 : switch ( nMemberId )
+ - ]
1350 : : {
1351 [ # # ]: 0 : case MID_LOCATION: rVal <<= aShadow.Location; break;
1352 [ # # ]: 0 : case MID_WIDTH: rVal <<= aShadow.ShadowWidth; break;
1353 [ # # ]: 0 : case MID_TRANSPARENT: rVal <<= aShadow.IsTransparent; break;
1354 [ # # ]: 0 : case MID_BG_COLOR: rVal <<= aShadow.Color; break;
1355 [ + - ]: 92 : case 0: rVal <<= aShadow; break;
1356 : 0 : default: OSL_FAIL("Wrong MemberId!"); return false;
1357 : : }
1358 : :
1359 : 92 : return true;
1360 : : }
1361 : : // -----------------------------------------------------------------------
1362 : 37 : bool SvxShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1363 : : {
1364 : 37 : sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1365 : 37 : nMemberId &= ~CONVERT_TWIPS;
1366 : :
1367 : 37 : table::ShadowFormat aShadow;
1368 : 37 : uno::Any aAny;
1369 [ + - ][ + - ]: 37 : bool bRet = QueryValue( aAny, bConvert ? CONVERT_TWIPS : 0 ) && ( aAny >>= aShadow );
[ + - ][ + - ]
[ + + ]
1370 [ - - - - : 37 : switch ( nMemberId )
+ - ]
1371 : : {
1372 : : case MID_LOCATION:
1373 : : {
1374 [ # # ]: 0 : bRet = (rVal >>= aShadow.Location);
1375 [ # # ]: 0 : if ( !bRet )
1376 : : {
1377 : 0 : sal_Int16 nVal = 0;
1378 : 0 : bRet = (rVal >>= nVal);
1379 : 0 : aShadow.Location = (table::ShadowLocation) nVal;
1380 : : }
1381 : :
1382 : 0 : break;
1383 : : }
1384 : :
1385 : 0 : case MID_WIDTH: rVal >>= aShadow.ShadowWidth; break;
1386 : 0 : case MID_TRANSPARENT: rVal >>= aShadow.IsTransparent; break;
1387 : 0 : case MID_BG_COLOR: rVal >>= aShadow.Color; break;
1388 [ + - ]: 37 : case 0: rVal >>= aShadow; break;
1389 : 0 : default: OSL_FAIL("Wrong MemberId!"); return sal_False;
1390 : : }
1391 : :
1392 [ + - ]: 37 : if ( bRet )
1393 : : {
1394 : : // SvxShadowLocation eSet = SVX_SHADOW_NONE;
1395 [ - - - - : 37 : switch( aShadow.Location )
+ ]
1396 : : {
1397 : 0 : case table::ShadowLocation_TOP_LEFT : eLocation = SVX_SHADOW_TOPLEFT; break;
1398 : 0 : case table::ShadowLocation_TOP_RIGHT : eLocation = SVX_SHADOW_TOPRIGHT; break;
1399 : 0 : case table::ShadowLocation_BOTTOM_LEFT : eLocation = SVX_SHADOW_BOTTOMLEFT ; break;
1400 : 0 : case table::ShadowLocation_BOTTOM_RIGHT: eLocation = SVX_SHADOW_BOTTOMRIGHT; break;
1401 : : default: ;//prevent warning
1402 : : }
1403 : :
1404 [ + + ][ + - ]: 37 : nWidth = bConvert ? MM100_TO_TWIP(aShadow.ShadowWidth) : aShadow.ShadowWidth;
1405 : 37 : Color aSet(aShadow.Color);
1406 [ + - ][ + + ]: 37 : aSet.SetTransparency(aShadow.IsTransparent ? 0xff : 0);
1407 : 37 : aShadowColor = aSet;
1408 : : }
1409 : :
1410 : 37 : return bRet;
1411 : : }
1412 : :
1413 : : // -----------------------------------------------------------------------
1414 : :
1415 : 11942 : int SvxShadowItem::operator==( const SfxPoolItem& rAttr ) const
1416 : : {
1417 : : DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
1418 : :
1419 : 11942 : return ( ( aShadowColor == ( (SvxShadowItem&)rAttr ).aShadowColor ) &&
1420 : 11912 : ( nWidth == ( (SvxShadowItem&)rAttr ).GetWidth() ) &&
1421 [ + - ]: 23854 : ( eLocation == ( (SvxShadowItem&)rAttr ).GetLocation() ) );
[ + + + - ]
1422 : : }
1423 : :
1424 : : // -----------------------------------------------------------------------
1425 : :
1426 : 79 : SfxPoolItem* SvxShadowItem::Clone( SfxItemPool* ) const
1427 : : {
1428 [ + - ]: 79 : return new SvxShadowItem( *this );
1429 : : }
1430 : :
1431 : : // -----------------------------------------------------------------------
1432 : :
1433 : 41724 : sal_uInt16 SvxShadowItem::CalcShadowSpace( sal_uInt16 nShadow ) const
1434 : : {
1435 : 41724 : sal_uInt16 nSpace = 0;
1436 : :
1437 [ + + + + : 41724 : switch ( nShadow )
- ]
1438 : : {
1439 : : case SHADOW_TOP:
1440 [ + - ][ - + ]: 10556 : if ( eLocation == SVX_SHADOW_TOPLEFT ||
1441 : : eLocation == SVX_SHADOW_TOPRIGHT )
1442 : 0 : nSpace = nWidth;
1443 : 10556 : break;
1444 : :
1445 : : case SHADOW_BOTTOM:
1446 [ + - ][ - + ]: 10556 : if ( eLocation == SVX_SHADOW_BOTTOMLEFT ||
1447 : : eLocation == SVX_SHADOW_BOTTOMRIGHT )
1448 : 0 : nSpace = nWidth;
1449 : 10556 : break;
1450 : :
1451 : : case SHADOW_LEFT:
1452 [ + - ][ - + ]: 10306 : if ( eLocation == SVX_SHADOW_TOPLEFT ||
1453 : : eLocation == SVX_SHADOW_BOTTOMLEFT )
1454 : 0 : nSpace = nWidth;
1455 : 10306 : break;
1456 : :
1457 : : case SHADOW_RIGHT:
1458 [ + - ][ - + ]: 10306 : if ( eLocation == SVX_SHADOW_TOPRIGHT ||
1459 : : eLocation == SVX_SHADOW_BOTTOMRIGHT )
1460 : 0 : nSpace = nWidth;
1461 : 10306 : break;
1462 : :
1463 : : default:
1464 : : OSL_FAIL( "wrong shadow" );
1465 : : }
1466 : 41724 : return nSpace;
1467 : : }
1468 : :
1469 : : //------------------------------------------------------------------------
1470 : :
1471 : 0 : SfxItemPresentation SvxShadowItem::GetPresentation
1472 : : (
1473 : : SfxItemPresentation ePres,
1474 : : SfxMapUnit eCoreUnit,
1475 : : SfxMapUnit ePresUnit,
1476 : : XubString& rText, const IntlWrapper *pIntl
1477 : : ) const
1478 : : {
1479 [ # # # # ]: 0 : switch ( ePres )
1480 : : {
1481 : : case SFX_ITEM_PRESENTATION_NONE:
1482 : 0 : rText.Erase();
1483 : 0 : return ePres;
1484 : :
1485 : : case SFX_ITEM_PRESENTATION_NAMELESS:
1486 : : {
1487 [ # # ]: 0 : rText = ::GetColorString( aShadowColor );
1488 : 0 : rText += cpDelim;
1489 : 0 : sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
1490 : :
1491 [ # # ]: 0 : if ( aShadowColor.GetTransparency() )
1492 : 0 : nId = RID_SVXITEMS_TRANSPARENT_TRUE;
1493 [ # # ][ # # ]: 0 : rText += EE_RESSTR(nId);
1494 : 0 : rText += cpDelim;
1495 [ # # ]: 0 : rText += GetMetricText( (long)nWidth, eCoreUnit, ePresUnit, pIntl );
1496 : 0 : rText += cpDelim;
1497 [ # # ][ # # ]: 0 : rText += EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN + eLocation);
1498 : 0 : return ePres;
1499 : : }
1500 : : case SFX_ITEM_PRESENTATION_COMPLETE:
1501 : : {
1502 [ # # ][ # # ]: 0 : rText = EE_RESSTR(RID_SVXITEMS_SHADOW_COMPLETE);
1503 [ # # ]: 0 : rText += ::GetColorString( aShadowColor );
1504 : 0 : rText += cpDelim;
1505 : :
1506 : 0 : sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
1507 [ # # ]: 0 : if ( aShadowColor.GetTransparency() )
1508 : 0 : nId = RID_SVXITEMS_TRANSPARENT_TRUE;
1509 [ # # ][ # # ]: 0 : rText += EE_RESSTR(nId);
1510 : 0 : rText += cpDelim;
1511 [ # # ]: 0 : rText += GetMetricText( (long)nWidth, eCoreUnit, ePresUnit, pIntl );
1512 [ # # ][ # # ]: 0 : rText += EE_RESSTR(GetMetricId(ePresUnit));
1513 : 0 : rText += cpDelim;
1514 [ # # ][ # # ]: 0 : rText += EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN + eLocation);
1515 : 0 : return ePres;
1516 : : }
1517 : : default: ;//prevent warning
1518 : : }
1519 : 0 : return SFX_ITEM_PRESENTATION_NONE;
1520 : : }
1521 : :
1522 : : // -----------------------------------------------------------------------
1523 : :
1524 : 0 : SvStream& SvxShadowItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1525 : : {
1526 : 0 : rStrm << (sal_Int8) GetLocation()
1527 : 0 : << (sal_uInt16) GetWidth()
1528 : 0 : << (sal_Bool)(aShadowColor.GetTransparency() > 0)
1529 : 0 : << GetColor()
1530 : 0 : << GetColor()
1531 : 0 : << (sal_Int8)(aShadowColor.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
1532 : 0 : return rStrm;
1533 : : }
1534 : :
1535 : : // -----------------------------------------------------------------------
1536 : :
1537 : 0 : bool SvxShadowItem::ScaleMetrics( long nMult, long nDiv )
1538 : : {
1539 : 0 : nWidth = (sal_uInt16)Scale( nWidth, nMult, nDiv );
1540 : 0 : return true;
1541 : : }
1542 : :
1543 : : // -----------------------------------------------------------------------
1544 : :
1545 : 0 : bool SvxShadowItem::HasMetrics() const
1546 : : {
1547 : 0 : return true;
1548 : : }
1549 : :
1550 : : // -----------------------------------------------------------------------
1551 : :
1552 : 0 : SfxPoolItem* SvxShadowItem::Create( SvStream& rStrm, sal_uInt16 ) const
1553 : : {
1554 : : sal_Int8 cLoc;
1555 : : sal_uInt16 _nWidth;
1556 : : sal_Bool bTrans;
1557 : 0 : Color aColor;
1558 : 0 : Color aFillColor;
1559 : : sal_Int8 nStyle;
1560 [ # # ][ # # ]: 0 : rStrm >> cLoc >> _nWidth
1561 [ # # ][ # # ]: 0 : >> bTrans >> aColor >> aFillColor >> nStyle;
[ # # ][ # # ]
1562 [ # # ][ # # ]: 0 : aColor.SetTransparency(bTrans ? 0xff : 0);
1563 [ # # ][ # # ]: 0 : return new SvxShadowItem( Which(), &aColor, _nWidth, (SvxShadowLocation)cLoc );
1564 : : }
1565 : :
1566 : : // -----------------------------------------------------------------------
1567 : :
1568 : 0 : sal_uInt16 SvxShadowItem::GetValueCount() const
1569 : : {
1570 : 0 : return SVX_SHADOW_END; // SVX_SHADOW_BOTTOMRIGHT + 1
1571 : : }
1572 : :
1573 : : // -----------------------------------------------------------------------
1574 : :
1575 : 0 : rtl::OUString SvxShadowItem::GetValueTextByPos( sal_uInt16 nPos ) const
1576 : : {
1577 : : DBG_ASSERT( nPos < SVX_SHADOW_END, "enum overflow!" );
1578 [ # # ]: 0 : return EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN + nPos );
1579 : : }
1580 : :
1581 : : // -----------------------------------------------------------------------
1582 : :
1583 : 0 : sal_uInt16 SvxShadowItem::GetEnumValue() const
1584 : : {
1585 : 0 : return (sal_uInt16)GetLocation();
1586 : : }
1587 : :
1588 : : // -----------------------------------------------------------------------
1589 : :
1590 : 0 : void SvxShadowItem::SetEnumValue( sal_uInt16 nVal )
1591 : : {
1592 : 0 : SetLocation( (const SvxShadowLocation)nVal );
1593 : 0 : }
1594 : :
1595 : : // class SvxBoxItem ------------------------------------------------------
1596 : :
1597 : 19046 : SvxBoxItem::SvxBoxItem( const SvxBoxItem& rCpy ) :
1598 : :
1599 : : SfxPoolItem ( rCpy ),
1600 : : nTopDist ( rCpy.nTopDist ),
1601 : : nBottomDist ( rCpy.nBottomDist ),
1602 : : nLeftDist ( rCpy.nLeftDist ),
1603 : 19046 : nRightDist ( rCpy.nRightDist )
1604 : :
1605 : : {
1606 [ + - ][ + - ]: 19046 : pTop = rCpy.GetTop() ? new SvxBorderLine( *rCpy.GetTop() ) : 0;
[ + + ]
1607 [ + + ][ + - ]: 19046 : pBottom = rCpy.GetBottom() ? new SvxBorderLine( *rCpy.GetBottom() ) : 0;
[ + - ]
1608 [ + + ][ + - ]: 19046 : pLeft = rCpy.GetLeft() ? new SvxBorderLine( *rCpy.GetLeft() ) : 0;
[ + - ]
1609 [ + + ][ + - ]: 19046 : pRight = rCpy.GetRight() ? new SvxBorderLine( *rCpy.GetRight() ) : 0;
[ + - ]
1610 : 19046 : }
1611 : :
1612 : : // -----------------------------------------------------------------------
1613 : :
1614 : 10243 : SvxBoxItem::SvxBoxItem( const sal_uInt16 nId ) :
1615 : : SfxPoolItem( nId ),
1616 : :
1617 : : pTop ( 0 ),
1618 : : pBottom ( 0 ),
1619 : : pLeft ( 0 ),
1620 : : pRight ( 0 ),
1621 : : nTopDist ( 0 ),
1622 : : nBottomDist ( 0 ),
1623 : : nLeftDist ( 0 ),
1624 : 10243 : nRightDist ( 0 )
1625 : :
1626 : : {
1627 : 10243 : }
1628 : :
1629 : : // -----------------------------------------------------------------------
1630 : :
1631 : 28067 : SvxBoxItem::~SvxBoxItem()
1632 : : {
1633 : 28067 : delete pTop;
1634 : 28067 : delete pBottom;
1635 : 28067 : delete pLeft;
1636 : 28067 : delete pRight;
1637 [ - + ]: 43532 : }
1638 : :
1639 : : // -----------------------------------------------------------------------
1640 : :
1641 : 1682 : SvxBoxItem& SvxBoxItem::operator=( const SvxBoxItem& rBox )
1642 : : {
1643 : 1682 : nTopDist = rBox.nTopDist;
1644 : 1682 : nBottomDist = rBox.nBottomDist;
1645 : 1682 : nLeftDist = rBox.nLeftDist;
1646 : 1682 : nRightDist = rBox.nRightDist;
1647 : 1682 : SetLine( rBox.GetTop(), BOX_LINE_TOP );
1648 : 1682 : SetLine( rBox.GetBottom(), BOX_LINE_BOTTOM );
1649 : 1682 : SetLine( rBox.GetLeft(), BOX_LINE_LEFT );
1650 : 1682 : SetLine( rBox.GetRight(), BOX_LINE_RIGHT );
1651 : 1682 : return *this;
1652 : : }
1653 : :
1654 : : // -----------------------------------------------------------------------
1655 : :
1656 : 171279 : inline sal_Bool CmpBrdLn( const SvxBorderLine* pBrd1, const SvxBorderLine* pBrd2 )
1657 : : {
1658 : : sal_Bool bRet;
1659 [ + + ][ + + ]: 171279 : if( 0 != pBrd1 ? 0 == pBrd2 : 0 != pBrd2 )
1660 : 51259 : bRet = sal_False;
1661 : : else
1662 [ + + ]: 120020 : if( !pBrd1 )
1663 : 44067 : bRet = sal_True;
1664 : : else
1665 : 75953 : bRet = (*pBrd1 == *pBrd2);
1666 : 171279 : return bRet;
1667 : : }
1668 : :
1669 : : // -----------------------------------------------------------------------
1670 : :
1671 : 100781 : int SvxBoxItem::operator==( const SfxPoolItem& rAttr ) const
1672 : : {
1673 : : DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
1674 : :
1675 : : return (
1676 : : ( nTopDist == ( (SvxBoxItem&)rAttr ).nTopDist ) &&
1677 : : ( nBottomDist == ( (SvxBoxItem&)rAttr ).nBottomDist ) &&
1678 : : ( nLeftDist == ( (SvxBoxItem&)rAttr ).nLeftDist ) &&
1679 : : ( nRightDist == ( (SvxBoxItem&)rAttr ).nRightDist ) &&
1680 : 92696 : CmpBrdLn( pTop, ( (SvxBoxItem&)rAttr ).GetTop() ) &&
1681 : 36542 : CmpBrdLn( pBottom, ( (SvxBoxItem&)rAttr ).GetBottom() ) &&
1682 : 22127 : CmpBrdLn( pLeft, ( (SvxBoxItem&)rAttr ).GetLeft() ) &&
1683 [ + + ][ + + ]: 252146 : CmpBrdLn( pRight, ( (SvxBoxItem&)rAttr ).GetRight() ) );
[ + + ][ + +
+ + + + +
+ ][ + + ]
1684 : : }
1685 : :
1686 : : // -----------------------------------------------------------------------
1687 : 1664 : table::BorderLine2 SvxBoxItem::SvxLineToLine(const SvxBorderLine* pLine, sal_Bool bConvert)
1688 : : {
1689 : 1664 : table::BorderLine2 aLine;
1690 [ + + ]: 1664 : if(pLine)
1691 : : {
1692 : 845 : aLine.Color = pLine->GetColor().GetColor() ;
1693 [ + - ]: 845 : aLine.InnerLineWidth = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetInWidth() ): pLine->GetInWidth() );
1694 [ + - ]: 845 : aLine.OuterLineWidth = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetOutWidth()): pLine->GetOutWidth() );
1695 [ + - ]: 845 : aLine.LineDistance = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetDistance()): pLine->GetDistance() );
1696 : 845 : aLine.LineStyle = pLine->GetBorderLineStyle();
1697 [ + - ][ + - ]: 845 : aLine.LineWidth = sal_uInt32( bConvert ? TWIP_TO_MM100( pLine->GetWidth( ) ) : pLine->GetWidth( ) );
1698 : : }
1699 : : else
1700 : 819 : aLine.Color = aLine.InnerLineWidth = aLine.OuterLineWidth = aLine.LineDistance = 0;
1701 : 1664 : return aLine;
1702 : : }
1703 : : // -----------------------------------------------------------------------
1704 : 1271 : bool SvxBoxItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1705 : : {
1706 : 1271 : sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1707 : 1271 : table::BorderLine2 aRetLine;
1708 : 1271 : sal_uInt16 nDist = 0;
1709 : 1271 : sal_Bool bDistMember = sal_False;
1710 : 1271 : nMemberId &= ~CONVERT_TWIPS;
1711 [ - + + + : 1271 : switch(nMemberId)
+ + + + +
+ - ]
1712 : : {
1713 : : case 0:
1714 : : {
1715 : : // 4 Borders and 5 distances
1716 [ # # ]: 0 : uno::Sequence< uno::Any > aSeq( 9 );
1717 [ # # ][ # # ]: 0 : aSeq[0] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetLeft(), bConvert) );
[ # # ]
1718 [ # # ][ # # ]: 0 : aSeq[1] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetRight(), bConvert) );
[ # # ]
1719 [ # # ][ # # ]: 0 : aSeq[2] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetBottom(), bConvert) );
[ # # ]
1720 [ # # ][ # # ]: 0 : aSeq[3] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetTop(), bConvert) );
[ # # ]
1721 [ # # ][ # # ]: 0 : aSeq[4] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( GetDistance()) : GetDistance()));
[ # # ][ # # ]
[ # # ][ # # ]
1722 [ # # ][ # # ]: 0 : aSeq[5] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nTopDist ) : nTopDist ));
[ # # ][ # # ]
1723 [ # # ][ # # ]: 0 : aSeq[6] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nBottomDist ) : nBottomDist ));
[ # # ][ # # ]
1724 [ # # ][ # # ]: 0 : aSeq[7] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nLeftDist ) : nLeftDist ));
[ # # ][ # # ]
1725 [ # # ][ # # ]: 0 : aSeq[8] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nRightDist ) : nRightDist ));
[ # # ][ # # ]
1726 [ # # ]: 0 : rVal = uno::makeAny( aSeq );
1727 [ # # ]: 0 : return sal_True;
1728 : : }
1729 : : case MID_LEFT_BORDER:
1730 : : case LEFT_BORDER:
1731 [ + - ]: 147 : aRetLine = SvxBoxItem::SvxLineToLine(GetLeft(), bConvert);
1732 : 147 : break;
1733 : : case MID_RIGHT_BORDER:
1734 : : case RIGHT_BORDER:
1735 [ + - ]: 144 : aRetLine = SvxBoxItem::SvxLineToLine(GetRight(), bConvert);
1736 : 144 : break;
1737 : : case MID_BOTTOM_BORDER:
1738 : : case BOTTOM_BORDER:
1739 [ + - ]: 147 : aRetLine = SvxBoxItem::SvxLineToLine(GetBottom(), bConvert);
1740 : 147 : break;
1741 : : case MID_TOP_BORDER:
1742 : : case TOP_BORDER:
1743 [ + - ]: 678 : aRetLine = SvxBoxItem::SvxLineToLine(GetTop(), bConvert);
1744 : 678 : break;
1745 : : case BORDER_DISTANCE:
1746 [ + - ]: 12 : nDist = GetDistance();
1747 : 12 : bDistMember = sal_True;
1748 : 12 : break;
1749 : : case TOP_BORDER_DISTANCE:
1750 : 35 : nDist = nTopDist;
1751 : 35 : bDistMember = sal_True;
1752 : 35 : break;
1753 : : case BOTTOM_BORDER_DISTANCE:
1754 : 35 : nDist = nBottomDist;
1755 : 35 : bDistMember = sal_True;
1756 : 35 : break;
1757 : : case LEFT_BORDER_DISTANCE:
1758 : 38 : nDist = nLeftDist;
1759 : 38 : bDistMember = sal_True;
1760 : 38 : break;
1761 : : case RIGHT_BORDER_DISTANCE:
1762 : 35 : nDist = nRightDist;
1763 : 35 : bDistMember = sal_True;
1764 : 35 : break;
1765 : : }
1766 : :
1767 [ + + ]: 1271 : if( bDistMember )
1768 [ + - ][ + - ]: 155 : rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nDist) : nDist);
1769 : : else
1770 [ + - ]: 1116 : rVal <<= aRetLine;
1771 : :
1772 : 1271 : return true;
1773 : : }
1774 : :
1775 : : namespace
1776 : : {
1777 : :
1778 : : sal_Bool
1779 : 4024 : lcl_lineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert, sal_Bool bGuessWidth)
1780 : : {
1781 : 4024 : rSvxLine.SetColor( Color(rLine.Color));
1782 [ + + ]: 4024 : if ( bGuessWidth )
1783 : : {
1784 : 2273 : rSvxLine.GuessLinesWidths( rSvxLine.GetBorderLineStyle(),
1785 : : sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.OuterLineWidth) : rLine.OuterLineWidth ),
1786 : : sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.InnerLineWidth) : rLine.InnerLineWidth ),
1787 [ + + ][ + - ]: 4546 : sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.LineDistance ) : rLine.LineDistance ));
[ + + ][ + - ]
[ + + ][ + - ]
1788 : : }
1789 : :
1790 : 4024 : sal_Bool bRet = !rSvxLine.isEmpty();
1791 : 4024 : return bRet;
1792 : : }
1793 : :
1794 : : }
1795 : :
1796 : : // -----------------------------------------------------------------------
1797 : 54 : sal_Bool SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert)
1798 : : {
1799 : 54 : return lcl_lineToSvxLine(rLine, rSvxLine, bConvert, sal_True);
1800 : : }
1801 : :
1802 : : sal_Bool
1803 : 3970 : SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine2& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert)
1804 : : {
1805 : : SvxBorderStyle const nStyle =
1806 : : (rLine.LineStyle < 0 || INSET < rLine.LineStyle)
1807 : : ? SOLID // default
1808 [ + - ][ + + ]: 3970 : : rLine.LineStyle;
1809 : :
1810 : 3970 : rSvxLine.SetBorderLineStyle( nStyle );
1811 : :
1812 : 3970 : sal_Bool bGuessWidth = sal_True;
1813 [ + + ]: 3970 : if ( rLine.LineWidth )
1814 : : {
1815 [ + + ]: 1902 : rSvxLine.SetWidth( bConvert? MM100_TO_TWIP_UNSIGNED( rLine.LineWidth ) : rLine.LineWidth );
1816 : : // fdo#46112: double does not necessarily mean symmetric
1817 : : // for backwards compatibility
1818 : : bGuessWidth = (DOUBLE == nStyle) &&
1819 [ + + ][ + - ]: 1902 : (rLine.InnerLineWidth > 0) && (rLine.OuterLineWidth > 0);
[ + + ]
1820 : : }
1821 : :
1822 : 3970 : return lcl_lineToSvxLine(rLine, rSvxLine, bConvert, bGuessWidth);
1823 : : }
1824 : :
1825 : : // -----------------------------------------------------------------------
1826 : :
1827 : : namespace
1828 : : {
1829 : :
1830 : : bool
1831 : 3742 : lcl_extractBorderLine(const uno::Any& rAny, table::BorderLine2& rLine)
1832 : : {
1833 [ + - ][ + - ]: 3742 : if (rAny >>= rLine)
1834 : 3742 : return true;
1835 : :
1836 : 0 : table::BorderLine aBorderLine;
1837 [ # # ][ # # ]: 0 : if (rAny >>= aBorderLine)
1838 : : {
1839 : 0 : rLine.Color = aBorderLine.Color;
1840 : 0 : rLine.InnerLineWidth = aBorderLine.InnerLineWidth;
1841 : 0 : rLine.OuterLineWidth = aBorderLine.OuterLineWidth;
1842 : 0 : rLine.LineDistance = aBorderLine.LineDistance;
1843 : 0 : rLine.LineStyle = table::BorderLineStyle::SOLID;
1844 : 0 : return true;
1845 : : }
1846 : :
1847 : 3742 : return false;
1848 : : }
1849 : :
1850 : : template<typename Item>
1851 : : bool
1852 : 0 : lcl_setLine(const uno::Any& rAny, Item& rItem, sal_uInt16 nLine, const bool bConvert)
1853 : : {
1854 : 0 : bool bDone = false;
1855 : 0 : table::BorderLine2 aBorderLine;
1856 [ # # # # ]: 0 : if (lcl_extractBorderLine(rAny, aBorderLine))
[ # # ][ # # ]
1857 : : {
1858 [ # # ][ # # ]: 0 : SvxBorderLine aLine;
1859 [ # # ][ # # ]: 0 : bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
1860 [ # # ][ # # ]: 0 : rItem.SetLine( bSet ? &aLine : NULL, nLine);
[ # # ][ # # ]
1861 : 0 : bDone = true;
1862 : : }
1863 : 0 : return bDone;
1864 : : }
1865 : :
1866 : : }
1867 : :
1868 : 6360 : bool SvxBoxItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1869 : : {
1870 : 6360 : bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1871 : 6360 : sal_uInt16 nLine = BOX_LINE_TOP;
1872 : 6360 : sal_Bool bDistMember = sal_False;
1873 : 6360 : nMemberId &= ~CONVERT_TWIPS;
1874 [ - + + + : 6360 : switch(nMemberId)
+ + + + +
+ - - ]
1875 : : {
1876 : : case 0:
1877 : : {
1878 [ # # ]: 0 : uno::Sequence< uno::Any > aSeq;
1879 [ # # ][ # # ]: 0 : if (( rVal >>= aSeq ) && ( aSeq.getLength() == 9 ))
[ # # ][ # # ]
1880 : : {
1881 : : // 4 Borders and 5 distances
1882 : 0 : const sal_uInt16 aBorders[] = { BOX_LINE_LEFT, BOX_LINE_RIGHT, BOX_LINE_BOTTOM, BOX_LINE_TOP };
1883 [ # # ]: 0 : for (int n(0); n != SAL_N_ELEMENTS(aBorders); ++n)
1884 : : {
1885 [ # # ][ # # ]: 0 : if (!lcl_setLine(aSeq[n], *this, aBorders[n], bConvert))
[ # # ]
1886 : 0 : return sal_False;
1887 : : }
1888 : :
1889 : : // WTH are the borders and the distances saved in different order?
1890 : 0 : sal_uInt16 nLines[4] = { BOX_LINE_TOP, BOX_LINE_BOTTOM, BOX_LINE_LEFT, BOX_LINE_RIGHT };
1891 [ # # ]: 0 : for ( sal_Int32 n = 4; n < 9; n++ )
1892 : : {
1893 : 0 : sal_Int32 nDist = 0;
1894 [ # # ][ # # ]: 0 : if ( aSeq[n] >>= nDist )
1895 : : {
1896 [ # # ]: 0 : if( bConvert )
1897 [ # # ]: 0 : nDist = MM100_TO_TWIP(nDist);
1898 [ # # ]: 0 : if ( n == 4 )
1899 : 0 : SetDistance( sal_uInt16( nDist ));
1900 : : else
1901 [ # # ]: 0 : SetDistance( sal_uInt16( nDist ), nLines[n-5] );
1902 : : }
1903 : : else
1904 : 0 : return sal_False;
1905 : : }
1906 : :
1907 : 0 : return sal_True;
1908 : : }
1909 : : else
1910 [ # # ]: 0 : return sal_False;
1911 : : }
1912 : : case LEFT_BORDER_DISTANCE:
1913 : 669 : bDistMember = sal_True;
1914 : : case LEFT_BORDER:
1915 : : case MID_LEFT_BORDER:
1916 : 1581 : nLine = BOX_LINE_LEFT;
1917 : 1581 : break;
1918 : : case RIGHT_BORDER_DISTANCE:
1919 : 669 : bDistMember = sal_True;
1920 : : case RIGHT_BORDER:
1921 : : case MID_RIGHT_BORDER:
1922 : 1581 : nLine = BOX_LINE_RIGHT;
1923 : 1581 : break;
1924 : : case BOTTOM_BORDER_DISTANCE:
1925 : 675 : bDistMember = sal_True;
1926 : : case BOTTOM_BORDER:
1927 : : case MID_BOTTOM_BORDER:
1928 : 1593 : nLine = BOX_LINE_BOTTOM;
1929 : 1593 : break;
1930 : : case TOP_BORDER_DISTANCE:
1931 : 675 : bDistMember = sal_True;
1932 : : case TOP_BORDER:
1933 : : case MID_TOP_BORDER:
1934 : 1593 : nLine = BOX_LINE_TOP;
1935 : 1593 : break;
1936 : : case LINE_STYLE:
1937 : : {
1938 : : drawing::LineStyle eDrawingStyle;
1939 [ + - ]: 12 : rVal >>= eDrawingStyle;
1940 : 12 : editeng::SvxBorderStyle eBorderStyle = NONE;
1941 [ - + - ]: 12 : switch ( eDrawingStyle )
1942 : : {
1943 : : default:
1944 : : case drawing::LineStyle_NONE:
1945 : 0 : break;
1946 : : case drawing::LineStyle_SOLID:
1947 : 12 : eBorderStyle = SOLID;
1948 : 12 : break;
1949 : : case drawing::LineStyle_DASH:
1950 : 0 : eBorderStyle = DASHED;
1951 : 0 : break;
1952 : : }
1953 : :
1954 : : // Set the line style on all borders
1955 : 12 : const sal_uInt16 aBorders[] = { BOX_LINE_LEFT, BOX_LINE_RIGHT, BOX_LINE_BOTTOM, BOX_LINE_TOP };
1956 [ + + ]: 60 : for (int n(0); n != SAL_N_ELEMENTS(aBorders); ++n)
1957 : : {
1958 [ + - ]: 48 : editeng::SvxBorderLine* pLine = const_cast< editeng::SvxBorderLine* >( GetLine( aBorders[n] ) );
1959 [ + - ]: 48 : if( pLine )
1960 [ + - ]: 48 : pLine->SetBorderLineStyle( eBorderStyle );
1961 : : }
1962 : 12 : return sal_True;
1963 : : }
1964 : : break;
1965 : : case LINE_WIDTH:
1966 : : {
1967 : : // Set the line width on all borders
1968 : 0 : long nWidth(0);
1969 : 0 : rVal >>= nWidth;
1970 [ # # ]: 0 : if( bConvert )
1971 [ # # ]: 0 : nWidth = MM100_TO_TWIP( nWidth );
1972 : :
1973 : : // Set the line Width on all borders
1974 : 0 : const sal_uInt16 aBorders[] = { BOX_LINE_LEFT, BOX_LINE_RIGHT, BOX_LINE_BOTTOM, BOX_LINE_TOP };
1975 [ # # ]: 0 : for (int n(0); n != SAL_N_ELEMENTS(aBorders); ++n)
1976 : : {
1977 [ # # ]: 0 : editeng::SvxBorderLine* pLine = const_cast< editeng::SvxBorderLine* >( GetLine( aBorders[n] ) );
1978 : 0 : pLine->SetWidth( nWidth );
1979 : : }
1980 : : }
1981 : 0 : return sal_True;
1982 : : break;
1983 : : }
1984 : :
1985 [ + + ][ - + ]: 6348 : if( bDistMember || nMemberId == BORDER_DISTANCE )
1986 : : {
1987 : 2688 : sal_Int32 nDist = 0;
1988 [ - + ]: 2688 : if(!(rVal >>= nDist))
1989 : 0 : return sal_False;
1990 : :
1991 [ + - ]: 2688 : if(nDist >= 0)
1992 : : {
1993 [ + - ]: 2688 : if( bConvert )
1994 [ + - ]: 2688 : nDist = MM100_TO_TWIP(nDist);
1995 [ - + ]: 2688 : if( nMemberId == BORDER_DISTANCE )
1996 : 0 : SetDistance( sal_uInt16( nDist ));
1997 : : else
1998 [ + - ]: 2688 : SetDistance( sal_uInt16( nDist ), nLine );
1999 : 2688 : }
2000 : : }
2001 : : else
2002 : : {
2003 [ + - ]: 3660 : SvxBorderLine aLine;
2004 [ - + ]: 3660 : if( !rVal.hasValue() )
2005 : 0 : return sal_False;
2006 : :
2007 : 3660 : table::BorderLine2 aBorderLine;
2008 [ - + ][ + - ]: 3660 : if( lcl_extractBorderLine(rVal, aBorderLine) )
2009 : : {
2010 : : // usual struct
2011 : : }
2012 [ # # ]: 0 : else if (rVal.getValueTypeClass() == uno::TypeClass_SEQUENCE )
2013 : : {
2014 : : // serialization for basic macro recording
2015 : : uno::Reference < script::XTypeConverter > xConverter
2016 [ # # ]: 0 : ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString("com.sun.star.script.Converter")),
[ # # # # ]
2017 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
2018 [ # # ]: 0 : uno::Sequence < uno::Any > aSeq;
2019 : 0 : uno::Any aNew;
2020 [ # # ][ # # ]: 0 : try { aNew = xConverter->convertTo( rVal, ::getCppuType((const uno::Sequence < uno::Any >*)0) ); }
[ # # ]
2021 [ # # ]: 0 : catch (const uno::Exception&) {}
2022 : :
2023 [ # # ]: 0 : aNew >>= aSeq;
2024 [ # # ][ # # ]: 0 : if (aSeq.getLength() >= 4 && aSeq.getLength() <= 6)
[ # # ]
2025 : : {
2026 : 0 : sal_Int32 nVal = 0;
2027 [ # # ][ # # ]: 0 : if ( aSeq[0] >>= nVal )
2028 : 0 : aBorderLine.Color = nVal;
2029 [ # # ][ # # ]: 0 : if ( aSeq[1] >>= nVal )
2030 : 0 : aBorderLine.InnerLineWidth = (sal_Int16) nVal;
2031 [ # # ][ # # ]: 0 : if ( aSeq[2] >>= nVal )
2032 : 0 : aBorderLine.OuterLineWidth = (sal_Int16) nVal;
2033 [ # # ][ # # ]: 0 : if ( aSeq[3] >>= nVal )
2034 : 0 : aBorderLine.LineDistance = (sal_Int16) nVal;
2035 [ # # ]: 0 : if (aSeq.getLength() >= 5) // fdo#40874 added fields
2036 : : {
2037 [ # # ][ # # ]: 0 : if (aSeq[4] >>= nVal)
2038 : : {
2039 : 0 : aBorderLine.LineStyle = nVal;
2040 : : }
2041 [ # # ]: 0 : if (aSeq.getLength() >= 6)
2042 : : {
2043 [ # # ][ # # ]: 0 : if (aSeq[5] >>= nVal)
2044 : : {
2045 : 0 : aBorderLine.LineWidth = nVal;
2046 : : }
2047 : : }
2048 : : }
2049 : : }
2050 : : else
2051 [ # # ][ # # ]: 0 : return sal_False;
[ # # ][ # # ]
2052 : : }
2053 : : else
2054 : 0 : return sal_False;
2055 : :
2056 [ + - ]: 3660 : sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
2057 [ + + ][ + - ]: 3660 : SetLine(bSet ? &aLine : 0, nLine);
2058 : : }
2059 : :
2060 : 6360 : return sal_True;
2061 : : }
2062 : :
2063 : : // -----------------------------------------------------------------------
2064 : :
2065 : 11939 : SfxPoolItem* SvxBoxItem::Clone( SfxItemPool* ) const
2066 : : {
2067 [ + - ]: 11939 : return new SvxBoxItem( *this );
2068 : : }
2069 : :
2070 : : //------------------------------------------------------------------------
2071 : :
2072 : 0 : SfxItemPresentation SvxBoxItem::GetPresentation
2073 : : (
2074 : : SfxItemPresentation ePres,
2075 : : SfxMapUnit eCoreUnit,
2076 : : SfxMapUnit ePresUnit,
2077 : : XubString& rText, const IntlWrapper *pIntl
2078 : : ) const
2079 : : {
2080 [ # # # # ]: 0 : switch ( ePres )
2081 : : {
2082 : : case SFX_ITEM_PRESENTATION_NONE:
2083 : 0 : rText.Erase();
2084 : 0 : return SFX_ITEM_PRESENTATION_NONE;
2085 : :
2086 : : case SFX_ITEM_PRESENTATION_NAMELESS:
2087 : : {
2088 : 0 : rText.Erase();
2089 : :
2090 [ # # ]: 0 : if ( pTop )
2091 : : {
2092 [ # # ]: 0 : rText = pTop->GetValueString( eCoreUnit, ePresUnit, pIntl );
2093 : 0 : rText += cpDelim;
2094 : : }
2095 [ # # ]: 0 : if( !(pTop && pBottom && pLeft && pRight &&
2096 [ # # ][ # # ]: 0 : *pTop == *pBottom && *pTop == *pLeft && *pTop == *pRight) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
2097 : : {
2098 [ # # ]: 0 : if ( pBottom )
2099 : : {
2100 [ # # ]: 0 : rText += pBottom->GetValueString( eCoreUnit, ePresUnit, pIntl );
2101 : 0 : rText += cpDelim;
2102 : : }
2103 [ # # ]: 0 : if ( pLeft )
2104 : : {
2105 [ # # ]: 0 : rText += pLeft->GetValueString( eCoreUnit, ePresUnit, pIntl );
2106 : 0 : rText += cpDelim;
2107 : : }
2108 [ # # ]: 0 : if ( pRight )
2109 : : {
2110 [ # # ]: 0 : rText += pRight->GetValueString( eCoreUnit, ePresUnit, pIntl );
2111 : 0 : rText += cpDelim;
2112 : : }
2113 : : }
2114 [ # # ]: 0 : rText += GetMetricText( (long)nTopDist, eCoreUnit, ePresUnit, pIntl );
2115 [ # # ][ # # ]: 0 : if( nTopDist != nBottomDist || nTopDist != nLeftDist ||
[ # # ]
2116 : : nTopDist != nRightDist )
2117 : : {
2118 [ # # ]: 0 : (((((rText += cpDelim)
2119 : : += GetMetricText( (long)nBottomDist, eCoreUnit,
2120 [ # # ][ # # ]: 0 : ePresUnit, pIntl ))
[ # # ]
2121 [ # # ]: 0 : += cpDelim)
2122 [ # # ][ # # ]: 0 : += GetMetricText( (long)nLeftDist, eCoreUnit, ePresUnit, pIntl ))
[ # # ]
2123 [ # # ]: 0 : += cpDelim)
2124 : : += GetMetricText( (long)nRightDist, eCoreUnit,
2125 [ # # ]: 0 : ePresUnit, pIntl );
2126 : : }
2127 : 0 : return SFX_ITEM_PRESENTATION_NAMELESS;
2128 : : }
2129 : : case SFX_ITEM_PRESENTATION_COMPLETE:
2130 : : {
2131 [ # # ][ # # ]: 0 : if( !(pTop || pBottom || pLeft || pRight) )
[ # # ][ # # ]
2132 : : {
2133 [ # # ][ # # ]: 0 : rText = EE_RESSTR(RID_SVXITEMS_BORDER_NONE);
2134 : 0 : rText += cpDelim;
2135 : : }
2136 : : else
2137 : : {
2138 [ # # ][ # # ]: 0 : rText = EE_RESSTR(RID_SVXITEMS_BORDER_COMPLETE);
2139 [ # # ][ # # ]: 0 : if( pTop && pBottom && pLeft && pRight &&
[ # # # #
# # # # ]
[ # # ][ # # ]
2140 : 0 : *pTop == *pBottom && *pTop == *pLeft && *pTop == *pRight )
2141 : : {
2142 [ # # ]: 0 : rText += pTop->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2143 : 0 : rText += cpDelim;
2144 : : }
2145 : : else
2146 : : {
2147 [ # # ]: 0 : if ( pTop )
2148 : : {
2149 [ # # ][ # # ]: 0 : rText += EE_RESSTR(RID_SVXITEMS_BORDER_TOP);
2150 [ # # ]: 0 : rText += pTop->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2151 : 0 : rText += cpDelim;
2152 : : }
2153 [ # # ]: 0 : if ( pBottom )
2154 : : {
2155 [ # # ][ # # ]: 0 : rText += EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM);
2156 [ # # ]: 0 : rText += pBottom->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2157 : 0 : rText += cpDelim;
2158 : : }
2159 [ # # ]: 0 : if ( pLeft )
2160 : : {
2161 [ # # ][ # # ]: 0 : rText += EE_RESSTR(RID_SVXITEMS_BORDER_LEFT);
2162 [ # # ]: 0 : rText += pLeft->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2163 : 0 : rText += cpDelim;
2164 : : }
2165 [ # # ]: 0 : if ( pRight )
2166 : : {
2167 [ # # ][ # # ]: 0 : rText += EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT);
2168 [ # # ]: 0 : rText += pRight->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2169 : 0 : rText += cpDelim;
2170 : : }
2171 : : }
2172 : : }
2173 : :
2174 [ # # ][ # # ]: 0 : rText += EE_RESSTR(RID_SVXITEMS_BORDER_DISTANCE);
2175 [ # # ][ # # ]: 0 : if( nTopDist == nBottomDist && nTopDist == nLeftDist &&
[ # # ]
2176 : : nTopDist == nRightDist )
2177 : : {
2178 : : rText += GetMetricText( (long)nTopDist, eCoreUnit,
2179 [ # # ]: 0 : ePresUnit, pIntl );
2180 [ # # ][ # # ]: 0 : rText += EE_RESSTR(GetMetricId(ePresUnit));
2181 : : }
2182 : : else
2183 : : {
2184 [ # # ][ # # ]: 0 : (((rText += EE_RESSTR(RID_SVXITEMS_BORDER_TOP))
[ # # ]
2185 : : += GetMetricText( (long)nTopDist, eCoreUnit,
2186 [ # # ]: 0 : ePresUnit, pIntl ))
[ # # # # ]
2187 [ # # ][ # # ]: 0 : += EE_RESSTR(GetMetricId(ePresUnit)))
2188 [ # # ]: 0 : += cpDelim;
2189 [ # # ][ # # ]: 0 : (((rText += EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM))
[ # # ]
2190 : : += GetMetricText( (long)nBottomDist, eCoreUnit,
2191 [ # # ]: 0 : ePresUnit, pIntl ))
[ # # # # ]
2192 [ # # ][ # # ]: 0 : += EE_RESSTR(GetMetricId(ePresUnit)))
2193 [ # # ]: 0 : += cpDelim;
2194 [ # # ][ # # ]: 0 : (((rText += EE_RESSTR(RID_SVXITEMS_BORDER_LEFT))
[ # # ]
2195 : : += GetMetricText( (long)nLeftDist, eCoreUnit,
2196 [ # # ]: 0 : ePresUnit, pIntl ))
[ # # # # ]
2197 [ # # ][ # # ]: 0 : += EE_RESSTR(GetMetricId(ePresUnit)))
2198 [ # # ]: 0 : += cpDelim;
2199 [ # # ][ # # ]: 0 : ((rText += EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT))
[ # # ]
2200 : : += GetMetricText( (long)nRightDist, eCoreUnit,
2201 [ # # ]: 0 : ePresUnit, pIntl ))
[ # # # # ]
2202 [ # # ][ # # ]: 0 : += EE_RESSTR(GetMetricId(ePresUnit));
2203 : : }
2204 : 0 : return SFX_ITEM_PRESENTATION_COMPLETE;
2205 : : }
2206 : : default: ;//prevent warning
2207 : : }
2208 : 0 : return SFX_ITEM_PRESENTATION_NONE;
2209 : : }
2210 : :
2211 : : // -----------------------------------------------------------------------
2212 : :
2213 : 528 : SvStream& SvxBoxItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
2214 : : {
2215 [ + - ][ + - ]: 528 : rStrm << (sal_uInt16) GetDistance();
2216 : : const SvxBorderLine* pLine[ 4 ]; // top, left, right, bottom
2217 : 528 : pLine[ 0 ] = GetTop();
2218 : 528 : pLine[ 1 ] = GetLeft();
2219 : 528 : pLine[ 2 ] = GetRight();
2220 : 528 : pLine[ 3 ] = GetBottom();
2221 : :
2222 [ + + ]: 2640 : for( int i = 0; i < 4; i++ )
2223 : : {
2224 : 2112 : const SvxBorderLine* l = pLine[ i ];
2225 [ + + ]: 2112 : if( l )
2226 : : {
2227 [ + - ]: 716 : rStrm << static_cast<sal_Int8>(i);
2228 [ + - ]: 716 : StoreBorderLine(rStrm, *l, BorderLineVersionFromBoxVersion(nItemVersion));
2229 : : }
2230 : : }
2231 : 528 : sal_Int8 cLine = 4;
2232 [ + - ][ + - ]: 528 : if( nItemVersion >= BOX_4DISTS_VERSION &&
2233 : : !(nTopDist == nLeftDist &&
2234 : : nTopDist == nRightDist &&
2235 [ + - ][ - + ]: 528 : nTopDist == nBottomDist) )
2236 : : {
2237 : 0 : cLine |= 0x10;
2238 : : }
2239 : :
2240 [ + - ]: 528 : rStrm << cLine;
2241 : :
2242 [ + - ][ - + ]: 528 : if( nItemVersion >= BOX_4DISTS_VERSION && (cLine & 0x10) != 0 )
2243 : : {
2244 [ # # ]: 0 : rStrm << (sal_uInt16)nTopDist
2245 [ # # ]: 0 : << (sal_uInt16)nLeftDist
2246 [ # # ]: 0 : << (sal_uInt16)nRightDist
2247 [ # # ]: 0 : << (sal_uInt16)nBottomDist;
2248 : : }
2249 : :
2250 : 528 : return rStrm;
2251 : : }
2252 : :
2253 : : // -----------------------------------------------------------------------
2254 : :
2255 : 530 : sal_uInt16 SvxBoxItem::GetVersion( sal_uInt16 nFFVer ) const
2256 : : {
2257 : : DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
2258 : : SOFFICE_FILEFORMAT_40==nFFVer ||
2259 : : SOFFICE_FILEFORMAT_50==nFFVer,
2260 : : "SvxBoxItem: Gibt es ein neues Fileformat?" );
2261 : : return SOFFICE_FILEFORMAT_31==nFFVer ||
2262 [ + - ][ - + ]: 530 : SOFFICE_FILEFORMAT_40==nFFVer ? 0 : BOX_BORDER_STYLE_VERSION;
2263 : : }
2264 : :
2265 : : // -----------------------------------------------------------------------
2266 : :
2267 : 0 : bool SvxBoxItem::ScaleMetrics( long nMult, long nDiv )
2268 : : {
2269 [ # # ]: 0 : if ( pTop ) pTop->ScaleMetrics( nMult, nDiv );
2270 [ # # ]: 0 : if ( pBottom ) pBottom->ScaleMetrics( nMult, nDiv );
2271 [ # # ]: 0 : if ( pLeft ) pLeft->ScaleMetrics( nMult, nDiv );
2272 [ # # ]: 0 : if ( pRight ) pBottom->ScaleMetrics( nMult, nDiv );
2273 : 0 : nTopDist = (sal_uInt16)Scale( nTopDist, nMult, nDiv );
2274 : 0 : nBottomDist = (sal_uInt16)Scale( nBottomDist, nMult, nDiv );
2275 : 0 : nLeftDist = (sal_uInt16)Scale( nLeftDist, nMult, nDiv );
2276 : 0 : nRightDist = (sal_uInt16)Scale( nRightDist, nMult, nDiv );
2277 : 0 : return true;
2278 : : }
2279 : :
2280 : : // -----------------------------------------------------------------------
2281 : :
2282 : 0 : bool SvxBoxItem::HasMetrics() const
2283 : : {
2284 : 0 : return true;
2285 : : }
2286 : :
2287 : : // -----------------------------------------------------------------------
2288 : :
2289 : 256 : SfxPoolItem* SvxBoxItem::Create( SvStream& rStrm, sal_uInt16 nIVersion ) const
2290 : : {
2291 : : sal_uInt16 nDistance;
2292 [ + - ]: 256 : rStrm >> nDistance;
2293 [ + - ][ + - ]: 256 : SvxBoxItem* pAttr = new SvxBoxItem( Which() );
2294 : :
2295 : : sal_uInt16 aLineMap[4] = { BOX_LINE_TOP, BOX_LINE_LEFT,
2296 : 256 : BOX_LINE_RIGHT, BOX_LINE_BOTTOM };
2297 : :
2298 : : sal_Int8 cLine;
2299 : 308 : while( sal_True )
2300 : : {
2301 [ + - ]: 564 : rStrm >> cLine;
2302 : :
2303 [ + + ]: 564 : if( cLine > 3 )
2304 : : break;
2305 : :
2306 [ + - ]: 308 : SvxBorderLine aBorder = CreateBorderLine(rStrm, BorderLineVersionFromBoxVersion(nIVersion));
2307 [ + - ]: 308 : pAttr->SetLine( &aBorder, aLineMap[cLine] );
2308 : : }
2309 : :
2310 [ - + ][ # # ]: 256 : if( nIVersion >= BOX_4DISTS_VERSION && (cLine&0x10) != 0 )
2311 : : {
2312 [ # # ]: 0 : for( sal_uInt16 i=0; i < 4; i++ )
2313 : : {
2314 : : sal_uInt16 nDist;
2315 [ # # ]: 0 : rStrm >> nDist;
2316 [ # # ]: 0 : pAttr->SetDistance( nDist, aLineMap[i] );
2317 : 0 : }
2318 : : }
2319 : : else
2320 : : {
2321 : 256 : pAttr->SetDistance( nDistance );
2322 : : }
2323 : :
2324 : 256 : return pAttr;
2325 : : }
2326 : :
2327 : : // -----------------------------------------------------------------------
2328 : :
2329 : 35262 : const SvxBorderLine *SvxBoxItem::GetLine( sal_uInt16 nLine ) const
2330 : : {
2331 : 35262 : const SvxBorderLine *pRet = 0;
2332 : :
2333 [ + + + + : 35262 : switch ( nLine )
- ]
2334 : : {
2335 : : case BOX_LINE_TOP:
2336 : 8505 : pRet = pTop;
2337 : 8505 : break;
2338 : : case BOX_LINE_BOTTOM:
2339 : 8511 : pRet = pBottom;
2340 : 8511 : break;
2341 : : case BOX_LINE_LEFT:
2342 : 9153 : pRet = pLeft;
2343 : 9153 : break;
2344 : : case BOX_LINE_RIGHT:
2345 : 9093 : pRet = pRight;
2346 : 9093 : break;
2347 : : default:
2348 : : OSL_FAIL( "wrong line" );
2349 : 0 : break;
2350 : : }
2351 : :
2352 : 35262 : return pRet;
2353 : : }
2354 : :
2355 : : // -----------------------------------------------------------------------
2356 : :
2357 : 38150 : void SvxBoxItem::SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine )
2358 : : {
2359 [ + + ][ + - ]: 38150 : SvxBorderLine* pTmp = pNew ? new SvxBorderLine( *pNew ) : 0;
2360 : :
2361 [ + + + + : 38150 : switch ( nLine )
- ]
2362 : : {
2363 : : case BOX_LINE_TOP:
2364 : 9624 : delete pTop;
2365 : 9624 : pTop = pTmp;
2366 : 9624 : break;
2367 : : case BOX_LINE_BOTTOM:
2368 : 9834 : delete pBottom;
2369 : 9834 : pBottom = pTmp;
2370 : 9834 : break;
2371 : : case BOX_LINE_LEFT:
2372 : 9120 : delete pLeft;
2373 : 9120 : pLeft = pTmp;
2374 : 9120 : break;
2375 : : case BOX_LINE_RIGHT:
2376 : 9572 : delete pRight;
2377 : 9572 : pRight = pTmp;
2378 : 9572 : break;
2379 : : default:
2380 : 0 : delete pTmp;
2381 : : OSL_FAIL( "wrong line" );
2382 : : }
2383 : 38150 : }
2384 : :
2385 : : // -----------------------------------------------------------------------
2386 : :
2387 : 611 : sal_uInt16 SvxBoxItem::GetDistance() const
2388 : : {
2389 : : // The smallest distance that is not 0 will be returned.
2390 : 611 : sal_uInt16 nDist = nTopDist;
2391 [ + + ][ + - ]: 611 : if( nBottomDist && (!nDist || nBottomDist < nDist) )
[ - + ]
2392 : 0 : nDist = nBottomDist;
2393 [ + + ][ + - ]: 611 : if( nLeftDist && (!nDist || nLeftDist < nDist) )
[ - + ]
2394 : 0 : nDist = nLeftDist;
2395 [ + + ][ + - ]: 611 : if( nRightDist && (!nDist || nRightDist < nDist) )
[ - + ]
2396 : 0 : nDist = nRightDist;
2397 : :
2398 : 611 : return nDist;
2399 : : }
2400 : :
2401 : : // -----------------------------------------------------------------------
2402 : :
2403 : 39250 : sal_uInt16 SvxBoxItem::GetDistance( sal_uInt16 nLine ) const
2404 : : {
2405 : 39250 : sal_uInt16 nDist = 0;
2406 [ + + + + : 39250 : switch ( nLine )
- ]
2407 : : {
2408 : : case BOX_LINE_TOP:
2409 : 9066 : nDist = nTopDist;
2410 : 9066 : break;
2411 : : case BOX_LINE_BOTTOM:
2412 : 16528 : nDist = nBottomDist;
2413 : 16528 : break;
2414 : : case BOX_LINE_LEFT:
2415 : 7046 : nDist = nLeftDist;
2416 : 7046 : break;
2417 : : case BOX_LINE_RIGHT:
2418 : 6610 : nDist = nRightDist;
2419 : 6610 : break;
2420 : : default:
2421 : : OSL_FAIL( "wrong line" );
2422 : : }
2423 : :
2424 : 39250 : return nDist;
2425 : : }
2426 : :
2427 : : // -----------------------------------------------------------------------
2428 : :
2429 : 9849 : void SvxBoxItem::SetDistance( sal_uInt16 nNew, sal_uInt16 nLine )
2430 : : {
2431 [ + + + + : 9849 : switch ( nLine )
- ]
2432 : : {
2433 : : case BOX_LINE_TOP:
2434 : 2598 : nTopDist = nNew;
2435 : 2598 : break;
2436 : : case BOX_LINE_BOTTOM:
2437 : 2448 : nBottomDist = nNew;
2438 : 2448 : break;
2439 : : case BOX_LINE_LEFT:
2440 : 2403 : nLeftDist = nNew;
2441 : 2403 : break;
2442 : : case BOX_LINE_RIGHT:
2443 : 2400 : nRightDist = nNew;
2444 : 2400 : break;
2445 : : default:
2446 : : OSL_FAIL( "wrong line" );
2447 : : }
2448 : 9849 : }
2449 : :
2450 : : // -----------------------------------------------------------------------
2451 : :
2452 : 59239 : sal_uInt16 SvxBoxItem::CalcLineSpace( sal_uInt16 nLine, sal_Bool bIgnoreLine ) const
2453 : : {
2454 : 59239 : SvxBorderLine* pTmp = 0;
2455 : 59239 : sal_uInt16 nDist = 0;
2456 [ + + + + : 59239 : switch ( nLine )
- ]
2457 : : {
2458 : : case BOX_LINE_TOP:
2459 : 18782 : pTmp = pTop;
2460 : 18782 : nDist = nTopDist;
2461 : 18782 : break;
2462 : : case BOX_LINE_BOTTOM:
2463 : 18797 : pTmp = pBottom;
2464 : 18797 : nDist = nBottomDist;
2465 : 18797 : break;
2466 : : case BOX_LINE_LEFT:
2467 : 10830 : pTmp = pLeft;
2468 : 10830 : nDist = nLeftDist;
2469 : 10830 : break;
2470 : : case BOX_LINE_RIGHT:
2471 : 10830 : pTmp = pRight;
2472 : 10830 : nDist = nRightDist;
2473 : 10830 : break;
2474 : : default:
2475 : : OSL_FAIL( "wrong line" );
2476 : : }
2477 : :
2478 [ + + ]: 59239 : if( pTmp )
2479 : : {
2480 : 10262 : nDist = nDist + (sal_uInt16)(pTmp->GetOutWidth()) + (sal_uInt16)(pTmp->GetInWidth()) + (sal_uInt16)(pTmp->GetDistance());
2481 : : }
2482 [ + + ]: 48977 : else if( !bIgnoreLine )
2483 : 41730 : nDist = 0;
2484 : 59239 : return nDist;
2485 : : }
2486 : :
2487 : : // class SvxBoxInfoItem --------------------------------------------------
2488 : :
2489 : 17319 : SvxBoxInfoItem::SvxBoxInfoItem( const sal_uInt16 nId ) :
2490 : : SfxPoolItem( nId ),
2491 : : pHori ( 0 ),
2492 : : pVert ( 0 ),
2493 : : mbEnableHor( false ),
2494 : : mbEnableVer( false ),
2495 : 17319 : nDefDist( 0 )
2496 : : {
2497 : 17319 : bDist = bMinDist = sal_False;
2498 [ + - ]: 17319 : ResetFlags();
2499 : 17319 : }
2500 : :
2501 : : // -----------------------------------------------------------------------
2502 : :
2503 : 22033 : SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem& rCpy ) :
2504 : : SfxPoolItem( rCpy ),
2505 : : mbEnableHor( rCpy.mbEnableHor ),
2506 : 22033 : mbEnableVer( rCpy.mbEnableVer )
2507 : : {
2508 [ + - ][ + - ]: 22033 : pHori = rCpy.GetHori() ? new SvxBorderLine( *rCpy.GetHori() ) : 0;
[ + + ]
2509 [ + + ][ + - ]: 22033 : pVert = rCpy.GetVert() ? new SvxBorderLine( *rCpy.GetVert() ) : 0;
[ + - ]
2510 : 22033 : bDist = rCpy.IsDist();
2511 : 22033 : bMinDist = rCpy.IsMinDist();
2512 : 22033 : nValidFlags = rCpy.nValidFlags;
2513 : 22033 : nDefDist = rCpy.GetDefDist();
2514 : 22033 : }
2515 : :
2516 : : // -----------------------------------------------------------------------
2517 : :
2518 : 38948 : SvxBoxInfoItem::~SvxBoxInfoItem()
2519 : : {
2520 : 38948 : delete pHori;
2521 : 38948 : delete pVert;
2522 [ - + ]: 64951 : }
2523 : :
2524 : : // -----------------------------------------------------------------------
2525 : :
2526 : 0 : SvxBoxInfoItem &SvxBoxInfoItem::operator=( const SvxBoxInfoItem& rCpy )
2527 : : {
2528 : 0 : delete pHori;
2529 : 0 : delete pVert;
2530 [ # # ][ # # ]: 0 : pHori = rCpy.GetHori() ? new SvxBorderLine( *rCpy.GetHori() ) : 0;
2531 [ # # ][ # # ]: 0 : pVert = rCpy.GetVert() ? new SvxBorderLine( *rCpy.GetVert() ) : 0;
2532 : 0 : mbEnableHor = rCpy.mbEnableHor;
2533 : 0 : mbEnableVer = rCpy.mbEnableVer;
2534 : 0 : bDist = rCpy.IsDist();
2535 : 0 : bMinDist = rCpy.IsMinDist();
2536 : 0 : nValidFlags = rCpy.nValidFlags;
2537 : 0 : nDefDist = rCpy.GetDefDist();
2538 : 0 : return *this;
2539 : : }
2540 : :
2541 : : // -----------------------------------------------------------------------
2542 : :
2543 : 2562 : int SvxBoxInfoItem::operator==( const SfxPoolItem& rAttr ) const
2544 : : {
2545 : 2562 : SvxBoxInfoItem& rBoxInfo = (SvxBoxInfoItem&)rAttr;
2546 : :
2547 : : DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
2548 : :
2549 : : return ( mbEnableHor == rBoxInfo.mbEnableHor
2550 : : && mbEnableVer == rBoxInfo.mbEnableVer
2551 : 2562 : && bDist == rBoxInfo.IsDist()
2552 : 2562 : && bMinDist == rBoxInfo.IsMinDist()
2553 : : && nValidFlags == rBoxInfo.nValidFlags
2554 : 2562 : && nDefDist == rBoxInfo.GetDefDist()
2555 : 2562 : && CmpBrdLn( pHori, rBoxInfo.GetHori() )
2556 : 2536 : && CmpBrdLn( pVert, rBoxInfo.GetVert() )
2557 [ + - ][ + - : 15346 : );
+ - + - ]
[ + - + -
+ + + - ]
2558 : : }
2559 : :
2560 : : // -----------------------------------------------------------------------
2561 : :
2562 : 2119 : void SvxBoxInfoItem::SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine )
2563 : : {
2564 [ + + ][ + - ]: 2119 : SvxBorderLine* pTmp = pNew ? new SvxBorderLine( *pNew ) : 0;
2565 : :
2566 [ + + ]: 2119 : if ( BOXINFO_LINE_HORI == nLine )
2567 : : {
2568 : 1092 : delete pHori;
2569 : 1092 : pHori = pTmp;
2570 : : }
2571 [ + - ]: 1027 : else if ( BOXINFO_LINE_VERT == nLine )
2572 : : {
2573 : 1027 : delete pVert;
2574 : 1027 : pVert = pTmp;
2575 : : }
2576 : : else
2577 : : {
2578 : 0 : delete pTmp;
2579 : : OSL_FAIL( "wrong line" );
2580 : : }
2581 : 2119 : }
2582 : :
2583 : : // -----------------------------------------------------------------------
2584 : :
2585 : 21988 : SfxPoolItem* SvxBoxInfoItem::Clone( SfxItemPool* ) const
2586 : : {
2587 [ + - ]: 21988 : return new SvxBoxInfoItem( *this );
2588 : : }
2589 : :
2590 : : //------------------------------------------------------------------------
2591 : :
2592 : 0 : SfxItemPresentation SvxBoxInfoItem::GetPresentation
2593 : : (
2594 : : SfxItemPresentation /*ePres*/,
2595 : : SfxMapUnit /*eCoreUnit*/,
2596 : : SfxMapUnit /*ePresUnit*/,
2597 : : XubString& rText, const IntlWrapper *
2598 : : ) const
2599 : : {
2600 : 0 : rText.Erase();
2601 : 0 : return SFX_ITEM_PRESENTATION_NONE;
2602 : : }
2603 : :
2604 : : // -----------------------------------------------------------------------
2605 : :
2606 : 0 : SvStream& SvxBoxInfoItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2607 : : {
2608 : 0 : sal_Int8 cFlags = 0;
2609 : :
2610 [ # # ]: 0 : if ( IsTable() )
2611 : 0 : cFlags |= 0x01;
2612 [ # # ]: 0 : if ( IsDist() )
2613 : 0 : cFlags |= 0x02;
2614 [ # # ]: 0 : if ( IsMinDist() )
2615 : 0 : cFlags |= 0x04;
2616 [ # # ]: 0 : rStrm << (sal_Int8) cFlags
2617 [ # # ]: 0 : << (sal_uInt16) GetDefDist();
2618 : : const SvxBorderLine* pLine[ 2 ];
2619 : 0 : pLine[ 0 ] = GetHori();
2620 : 0 : pLine[ 1 ] = GetVert();
2621 : :
2622 [ # # ]: 0 : for( int i = 0; i < 2; i++ )
2623 : : {
2624 : 0 : const SvxBorderLine* l = pLine[ i ];
2625 [ # # ]: 0 : if( l )
2626 : : {
2627 [ # # ]: 0 : rStrm << (char) i
2628 [ # # ]: 0 : << l->GetColor()
2629 [ # # ][ # # ]: 0 : << (short) l->GetOutWidth()
2630 [ # # ][ # # ]: 0 : << (short) l->GetInWidth()
2631 [ # # ][ # # ]: 0 : << (short) l->GetDistance();
2632 : : }
2633 : : }
2634 [ # # ]: 0 : rStrm << (char) 2;
2635 : 0 : return rStrm;
2636 : : }
2637 : :
2638 : : // -----------------------------------------------------------------------
2639 : :
2640 : 0 : bool SvxBoxInfoItem::ScaleMetrics( long nMult, long nDiv )
2641 : : {
2642 [ # # ]: 0 : if ( pHori ) pHori->ScaleMetrics( nMult, nDiv );
2643 [ # # ]: 0 : if ( pVert ) pVert->ScaleMetrics( nMult, nDiv );
2644 : 0 : nDefDist = (sal_uInt16)Scale( nDefDist, nMult, nDiv );
2645 : 0 : return true;
2646 : : }
2647 : :
2648 : : // -----------------------------------------------------------------------
2649 : :
2650 : 0 : bool SvxBoxInfoItem::HasMetrics() const
2651 : : {
2652 : 0 : return true;
2653 : : }
2654 : :
2655 : : // -----------------------------------------------------------------------
2656 : :
2657 : 0 : SfxPoolItem* SvxBoxInfoItem::Create( SvStream& rStrm, sal_uInt16 ) const
2658 : : {
2659 : : sal_Int8 cFlags;
2660 : : sal_uInt16 _nDefDist;
2661 [ # # ][ # # ]: 0 : rStrm >> cFlags >> _nDefDist;
2662 : :
2663 [ # # ][ # # ]: 0 : SvxBoxInfoItem* pAttr = new SvxBoxInfoItem( Which() );
2664 : :
2665 : 0 : pAttr->SetTable ( ( cFlags & 0x01 ) != 0 );
2666 : 0 : pAttr->SetDist ( ( cFlags & 0x02 ) != 0 );
2667 : 0 : pAttr->SetMinDist( ( cFlags & 0x04 ) != 0 );
2668 : 0 : pAttr->SetDefDist( _nDefDist );
2669 : :
2670 : 0 : while( sal_True )
2671 : : {
2672 : : sal_Int8 cLine;
2673 [ # # ]: 0 : rStrm >> cLine;
2674 : :
2675 [ # # ]: 0 : if( cLine > 1 )
2676 : : break;
2677 : : short nOutline, nInline, nDistance;
2678 : 0 : Color aColor;
2679 [ # # ][ # # ]: 0 : rStrm >> aColor >> nOutline >> nInline >> nDistance;
[ # # ][ # # ]
2680 [ # # ]: 0 : SvxBorderLine aBorder( &aColor );
2681 [ # # ]: 0 : aBorder.GuessLinesWidths(NONE, nOutline, nInline, nDistance);
2682 : :
2683 [ # # # ]: 0 : switch( cLine )
2684 : : {
2685 [ # # ]: 0 : case 0: pAttr->SetLine( &aBorder, BOXINFO_LINE_HORI ); break;
2686 [ # # ]: 0 : case 1: pAttr->SetLine( &aBorder, BOXINFO_LINE_VERT ); break;
2687 : : }
2688 : : }
2689 : 0 : return pAttr;
2690 : : }
2691 : :
2692 : : // -----------------------------------------------------------------------
2693 : :
2694 : 17357 : void SvxBoxInfoItem::ResetFlags()
2695 : : {
2696 : 17357 : nValidFlags = 0x7F; // all valid except Disable
2697 : 17357 : }
2698 : :
2699 : 0 : bool SvxBoxInfoItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2700 : : {
2701 : 0 : sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2702 : 0 : table::BorderLine2 aRetLine;
2703 : 0 : sal_Int16 nVal=0;
2704 : 0 : sal_Bool bIntMember = sal_False;
2705 : 0 : nMemberId &= ~CONVERT_TWIPS;
2706 [ # # # # : 0 : switch(nMemberId)
# # # ]
2707 : : {
2708 : : case 0:
2709 : : {
2710 : : // 2 BorderLines, flags, valid flags and distance
2711 [ # # ]: 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq( 5 );
2712 [ # # ][ # # ]: 0 : aSeq[0] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pHori, bConvert) );
[ # # ]
2713 [ # # ][ # # ]: 0 : aSeq[1] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pVert, bConvert) );
[ # # ]
2714 [ # # ]: 0 : if ( IsTable() )
2715 : 0 : nVal |= 0x01;
2716 [ # # ]: 0 : if ( IsDist() )
2717 : 0 : nVal |= 0x02;
2718 [ # # ]: 0 : if ( IsMinDist() )
2719 : 0 : nVal |= 0x04;
2720 [ # # ][ # # ]: 0 : aSeq[2] = ::com::sun::star::uno::makeAny( nVal );
2721 : 0 : nVal = nValidFlags;
2722 [ # # ][ # # ]: 0 : aSeq[3] = ::com::sun::star::uno::makeAny( nVal );
2723 [ # # ][ # # ]: 0 : aSeq[4] = ::com::sun::star::uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist()) );
[ # # ]
2724 [ # # ]: 0 : rVal = ::com::sun::star::uno::makeAny( aSeq );
2725 [ # # ]: 0 : return sal_True;
2726 : : }
2727 : :
2728 : : case MID_HORIZONTAL:
2729 [ # # ]: 0 : aRetLine = SvxBoxItem::SvxLineToLine( pHori, bConvert);
2730 : 0 : break;
2731 : : case MID_VERTICAL:
2732 [ # # ]: 0 : aRetLine = SvxBoxItem::SvxLineToLine( pVert, bConvert);
2733 : 0 : break;
2734 : : case MID_FLAGS:
2735 : 0 : bIntMember = sal_True;
2736 [ # # ]: 0 : if ( IsTable() )
2737 : 0 : nVal |= 0x01;
2738 [ # # ]: 0 : if ( IsDist() )
2739 : 0 : nVal |= 0x02;
2740 [ # # ]: 0 : if ( IsMinDist() )
2741 : 0 : nVal |= 0x04;
2742 [ # # ]: 0 : rVal <<= nVal;
2743 : 0 : break;
2744 : : case MID_VALIDFLAGS:
2745 : 0 : bIntMember = sal_True;
2746 : 0 : nVal = nValidFlags;
2747 [ # # ]: 0 : rVal <<= nVal;
2748 : 0 : break;
2749 : : case MID_DISTANCE:
2750 : 0 : bIntMember = sal_True;
2751 [ # # ][ # # ]: 0 : rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist());
2752 : 0 : break;
2753 : 0 : default: OSL_FAIL("Wrong MemberId!"); return false;
2754 : : }
2755 : :
2756 [ # # ]: 0 : if( !bIntMember )
2757 [ # # ]: 0 : rVal <<= aRetLine;
2758 : :
2759 : 0 : return true;
2760 : : }
2761 : :
2762 : : // -----------------------------------------------------------------------
2763 : :
2764 : 0 : bool SvxBoxInfoItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2765 : : {
2766 : 0 : sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2767 : 0 : nMemberId &= ~CONVERT_TWIPS;
2768 : : sal_Bool bRet;
2769 [ # # # # : 0 : switch(nMemberId)
# # ]
2770 : : {
2771 : : case 0:
2772 : : {
2773 [ # # ]: 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq;
2774 [ # # ][ # # ]: 0 : if (( rVal >>= aSeq ) && ( aSeq.getLength() == 5 ))
[ # # ][ # # ]
2775 : : {
2776 : : // 2 BorderLines, flags, valid flags and distance
2777 [ # # ][ # # ]: 0 : if (!lcl_setLine(aSeq[0], *this, BOXINFO_LINE_HORI, bConvert))
[ # # ]
2778 : 0 : return sal_False;
2779 [ # # ][ # # ]: 0 : if (!lcl_setLine(aSeq[1], *this, BOXINFO_LINE_VERT, bConvert))
[ # # ]
2780 : 0 : return sal_False;
2781 : :
2782 : 0 : sal_Int16 nFlags( 0 );
2783 : 0 : sal_Int32 nVal( 0 );
2784 [ # # ][ # # ]: 0 : if ( aSeq[2] >>= nFlags )
2785 : : {
2786 : 0 : SetTable ( ( nFlags & 0x01 ) != 0 );
2787 : 0 : SetDist ( ( nFlags & 0x02 ) != 0 );
2788 : 0 : SetMinDist( ( nFlags & 0x04 ) != 0 );
2789 : : }
2790 : : else
2791 : 0 : return sal_False;
2792 [ # # ][ # # ]: 0 : if ( aSeq[3] >>= nFlags )
2793 : 0 : nValidFlags = (sal_uInt8)nFlags;
2794 : : else
2795 : 0 : return sal_False;
2796 [ # # ][ # # ]: 0 : if (( aSeq[4] >>= nVal ) && ( nVal >= 0 ))
[ # # ][ # # ]
2797 : : {
2798 [ # # ]: 0 : if( bConvert )
2799 [ # # ]: 0 : nVal = MM100_TO_TWIP(nVal);
2800 : 0 : SetDefDist( (sal_uInt16)nVal );
2801 : : }
2802 : : }
2803 [ # # ]: 0 : return sal_True;
2804 : : }
2805 : :
2806 : : case MID_HORIZONTAL:
2807 : : case MID_VERTICAL:
2808 : : {
2809 [ # # ]: 0 : if( !rVal.hasValue() )
2810 : 0 : return sal_False;
2811 : :
2812 : 0 : table::BorderLine2 aBorderLine;
2813 [ # # ][ # # ]: 0 : if( lcl_extractBorderLine(rVal, aBorderLine) )
2814 : : {
2815 : : // usual struct
2816 : : }
2817 [ # # ]: 0 : else if (rVal.getValueTypeClass() == uno::TypeClass_SEQUENCE )
2818 : : {
2819 : : // serialization for basic macro recording
2820 : : uno::Reference < script::XTypeConverter > xConverter
2821 [ # # ]: 0 : ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString("com.sun.star.script.Converter")),
[ # # # # ]
2822 [ # # ][ # # ]: 0 : uno::UNO_QUERY );
2823 : 0 : uno::Any aNew;
2824 [ # # ]: 0 : uno::Sequence < uno::Any > aSeq;
2825 [ # # ][ # # ]: 0 : try { aNew = xConverter->convertTo( rVal, ::getCppuType((const uno::Sequence < uno::Any >*)0) ); }
[ # # ]
2826 [ # # ]: 0 : catch (const uno::Exception&) {}
2827 : :
2828 [ # # ][ # # : 0 : if ((aNew >>= aSeq) &&
# # # # ]
[ # # ]
2829 : 0 : aSeq.getLength() >= 4 && aSeq.getLength() <= 6)
2830 : : {
2831 : 0 : sal_Int32 nVal = 0;
2832 [ # # ][ # # ]: 0 : if ( aSeq[0] >>= nVal )
2833 : 0 : aBorderLine.Color = nVal;
2834 [ # # ][ # # ]: 0 : if ( aSeq[1] >>= nVal )
2835 : 0 : aBorderLine.InnerLineWidth = (sal_Int16) nVal;
2836 [ # # ][ # # ]: 0 : if ( aSeq[2] >>= nVal )
2837 : 0 : aBorderLine.OuterLineWidth = (sal_Int16) nVal;
2838 [ # # ][ # # ]: 0 : if ( aSeq[3] >>= nVal )
2839 : 0 : aBorderLine.LineDistance = (sal_Int16) nVal;
2840 [ # # ]: 0 : if (aSeq.getLength() >= 5) // fdo#40874 added fields
2841 : : {
2842 [ # # ][ # # ]: 0 : if (aSeq[4] >>= nVal)
2843 : : {
2844 : 0 : aBorderLine.LineStyle = nVal;
2845 : : }
2846 [ # # ]: 0 : if (aSeq.getLength() >= 6)
2847 : : {
2848 [ # # ][ # # ]: 0 : if (aSeq[5] >>= nVal)
2849 : : {
2850 : 0 : aBorderLine.LineWidth = nVal;
2851 : : }
2852 : : }
2853 : : }
2854 : : }
2855 : : else
2856 [ # # ][ # # ]: 0 : return sal_False;
[ # # ][ # # ]
2857 : : }
2858 [ # # ][ # # ]: 0 : else if (rVal.getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < sal_Int16 >*)0) )
2859 : : {
2860 : : // serialization for basic macro recording
2861 [ # # ]: 0 : ::com::sun::star::uno::Sequence < sal_Int16 > aSeq;
2862 [ # # ]: 0 : rVal >>= aSeq;
2863 [ # # ][ # # ]: 0 : if (aSeq.getLength() >= 4 && aSeq.getLength() <= 6)
[ # # ]
2864 : : {
2865 [ # # ]: 0 : aBorderLine.Color = aSeq[0];
2866 [ # # ]: 0 : aBorderLine.InnerLineWidth = aSeq[1];
2867 [ # # ]: 0 : aBorderLine.OuterLineWidth = aSeq[2];
2868 [ # # ]: 0 : aBorderLine.LineDistance = aSeq[3];
2869 [ # # ]: 0 : if (aSeq.getLength() >= 5) // fdo#40874 added fields
2870 : : {
2871 [ # # ]: 0 : aBorderLine.LineStyle = aSeq[4];
2872 [ # # ]: 0 : if (aSeq.getLength() >= 6)
2873 : : {
2874 [ # # ]: 0 : aBorderLine.LineWidth = aSeq[5];
2875 : : }
2876 : : }
2877 : : }
2878 : : else
2879 [ # # ][ # # ]: 0 : return sal_False;
2880 : : }
2881 : : else
2882 : 0 : return sal_False;
2883 : :
2884 [ # # ]: 0 : SvxBorderLine aLine;
2885 [ # # ]: 0 : sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
2886 [ # # ]: 0 : if ( bSet )
2887 [ # # ]: 0 : SetLine( &aLine, nMemberId == MID_HORIZONTAL ? BOXINFO_LINE_HORI : BOXINFO_LINE_VERT );
2888 : : break;
2889 : : }
2890 : : case MID_FLAGS:
2891 : : {
2892 : 0 : sal_Int16 nFlags = sal_Int16();
2893 : 0 : bRet = (rVal >>= nFlags);
2894 [ # # ]: 0 : if ( bRet )
2895 : : {
2896 : 0 : SetTable ( ( nFlags & 0x01 ) != 0 );
2897 : 0 : SetDist ( ( nFlags & 0x02 ) != 0 );
2898 : 0 : SetMinDist( ( nFlags & 0x04 ) != 0 );
2899 : : }
2900 : :
2901 : : break;
2902 : : }
2903 : : case MID_VALIDFLAGS:
2904 : : {
2905 : 0 : sal_Int16 nFlags = sal_Int16();
2906 : 0 : bRet = (rVal >>= nFlags);
2907 [ # # ]: 0 : if ( bRet )
2908 : 0 : nValidFlags = (sal_uInt8)nFlags;
2909 : : break;
2910 : : }
2911 : : case MID_DISTANCE:
2912 : : {
2913 : 0 : sal_Int32 nVal = 0;
2914 : 0 : bRet = (rVal >>= nVal);
2915 [ # # ][ # # ]: 0 : if ( bRet && nVal>=0 )
2916 : : {
2917 [ # # ]: 0 : if( bConvert )
2918 [ # # ]: 0 : nVal = MM100_TO_TWIP(nVal);
2919 : 0 : SetDefDist( (sal_uInt16)nVal );
2920 : : }
2921 : : break;
2922 : : }
2923 : 0 : default: OSL_FAIL("Wrong MemberId!"); return sal_False;
2924 : : }
2925 : :
2926 : 0 : return sal_True;
2927 : : }
2928 : :
2929 : : // class SvxFmtBreakItem -------------------------------------------------
2930 : :
2931 : 366 : int SvxFmtBreakItem::operator==( const SfxPoolItem& rAttr ) const
2932 : : {
2933 : : DBG_ASSERT( SfxPoolItem::operator==( rAttr ), "unequal types" );
2934 : :
2935 : 366 : return GetValue() == ( (SvxFmtBreakItem&)rAttr ).GetValue();
2936 : : }
2937 : :
2938 : : //------------------------------------------------------------------------
2939 : :
2940 : 0 : SfxItemPresentation SvxFmtBreakItem::GetPresentation
2941 : : (
2942 : : SfxItemPresentation ePres,
2943 : : SfxMapUnit /*eCoreUnit*/,
2944 : : SfxMapUnit /*ePresUnit*/,
2945 : : XubString& rText, const IntlWrapper *
2946 : : ) const
2947 : : {
2948 [ # # # ]: 0 : switch ( ePres )
2949 : : {
2950 : : case SFX_ITEM_PRESENTATION_NONE:
2951 : 0 : rText.Erase();
2952 : 0 : return SFX_ITEM_PRESENTATION_NONE;
2953 : :
2954 : : case SFX_ITEM_PRESENTATION_NAMELESS:
2955 : : case SFX_ITEM_PRESENTATION_COMPLETE:
2956 [ # # ]: 0 : rText = GetValueTextByPos( GetValue() );
2957 : 0 : return ePres;
2958 : : default: ;//prevent warning
2959 : : }
2960 : 0 : return SFX_ITEM_PRESENTATION_NONE;
2961 : : }
2962 : :
2963 : : // -----------------------------------------------------------------------
2964 : :
2965 : 0 : rtl::OUString SvxFmtBreakItem::GetValueTextByPos( sal_uInt16 nPos ) const
2966 : : {
2967 : : DBG_ASSERT( nPos < SVX_BREAK_END, "enum overflow!" );
2968 [ # # ]: 0 : return EE_RESSTR(RID_SVXITEMS_BREAK_BEGIN + nPos);
2969 : : }
2970 : :
2971 : : // -----------------------------------------------------------------------
2972 : 10 : bool SvxFmtBreakItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
2973 : : {
2974 : 10 : style::BreakType eBreak = style::BreakType_NONE;
2975 [ - + - - : 10 : switch ( (SvxBreak)GetValue() )
- - + ]
2976 : : {
2977 : 0 : case SVX_BREAK_COLUMN_BEFORE: eBreak = style::BreakType_COLUMN_BEFORE; break;
2978 : 2 : case SVX_BREAK_COLUMN_AFTER: eBreak = style::BreakType_COLUMN_AFTER ; break;
2979 : 0 : case SVX_BREAK_COLUMN_BOTH: eBreak = style::BreakType_COLUMN_BOTH ; break;
2980 : 0 : case SVX_BREAK_PAGE_BEFORE: eBreak = style::BreakType_PAGE_BEFORE ; break;
2981 : 0 : case SVX_BREAK_PAGE_AFTER: eBreak = style::BreakType_PAGE_AFTER ; break;
2982 : 0 : case SVX_BREAK_PAGE_BOTH: eBreak = style::BreakType_PAGE_BOTH ; break;
2983 : : default: ;//prevent warning
2984 : : }
2985 [ + - ]: 10 : rVal <<= eBreak;
2986 : 10 : return true;
2987 : : }
2988 : : // -----------------------------------------------------------------------
2989 : 20 : bool SvxFmtBreakItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
2990 : : {
2991 : : style::BreakType nBreak;
2992 : :
2993 [ + - ][ - + ]: 20 : if(!(rVal >>= nBreak))
2994 : : {
2995 : 0 : sal_Int32 nValue = 0;
2996 [ # # ]: 0 : if(!(rVal >>= nValue))
2997 : 0 : return sal_False;
2998 : :
2999 : 0 : nBreak = (style::BreakType) nValue;
3000 : : }
3001 : :
3002 : 20 : SvxBreak eBreak = SVX_BREAK_NONE;
3003 [ + + - + : 20 : switch( nBreak )
- - - ]
3004 : : {
3005 : 3 : case style::BreakType_COLUMN_BEFORE: eBreak = SVX_BREAK_COLUMN_BEFORE; break;
3006 : 2 : case style::BreakType_COLUMN_AFTER: eBreak = SVX_BREAK_COLUMN_AFTER; break;
3007 : 0 : case style::BreakType_COLUMN_BOTH: eBreak = SVX_BREAK_COLUMN_BOTH; break;
3008 : 15 : case style::BreakType_PAGE_BEFORE: eBreak = SVX_BREAK_PAGE_BEFORE; break;
3009 : 0 : case style::BreakType_PAGE_AFTER: eBreak = SVX_BREAK_PAGE_AFTER; break;
3010 : 0 : case style::BreakType_PAGE_BOTH: eBreak = SVX_BREAK_PAGE_BOTH; break;
3011 : : default: ;//prevent warning
3012 : : }
3013 : 20 : SetValue((sal_uInt16) eBreak);
3014 : :
3015 : 20 : return true;
3016 : : }
3017 : :
3018 : : // -----------------------------------------------------------------------
3019 : :
3020 : 111 : SfxPoolItem* SvxFmtBreakItem::Clone( SfxItemPool* ) const
3021 : : {
3022 [ + - ]: 111 : return new SvxFmtBreakItem( *this );
3023 : : }
3024 : :
3025 : : // -----------------------------------------------------------------------
3026 : :
3027 : 0 : SvStream& SvxFmtBreakItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
3028 : : {
3029 : 0 : rStrm << (sal_Int8)GetValue();
3030 [ # # ]: 0 : if( FMTBREAK_NOAUTO > nItemVersion )
3031 : 0 : rStrm << (sal_Int8)0x01;
3032 : 0 : return rStrm;
3033 : : }
3034 : :
3035 : : // -----------------------------------------------------------------------
3036 : :
3037 : 0 : sal_uInt16 SvxFmtBreakItem::GetVersion( sal_uInt16 nFFVer ) const
3038 : : {
3039 : : DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
3040 : : SOFFICE_FILEFORMAT_40==nFFVer ||
3041 : : SOFFICE_FILEFORMAT_50==nFFVer,
3042 : : "SvxFmtBreakItem: Is there a new file format? ");
3043 : : return SOFFICE_FILEFORMAT_31==nFFVer ||
3044 [ # # ][ # # ]: 0 : SOFFICE_FILEFORMAT_40==nFFVer ? 0 : FMTBREAK_NOAUTO;
3045 : : }
3046 : :
3047 : : // -----------------------------------------------------------------------
3048 : :
3049 : 0 : SfxPoolItem* SvxFmtBreakItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
3050 : : {
3051 : : sal_Int8 eBreak, bDummy;
3052 [ # # ]: 0 : rStrm >> eBreak;
3053 [ # # ]: 0 : if( FMTBREAK_NOAUTO > nVersion )
3054 [ # # ]: 0 : rStrm >> bDummy;
3055 [ # # ][ # # ]: 0 : return new SvxFmtBreakItem( (const SvxBreak)eBreak, Which() );
3056 : : }
3057 : :
3058 : : // -----------------------------------------------------------------------
3059 : :
3060 : 0 : sal_uInt16 SvxFmtBreakItem::GetValueCount() const
3061 : : {
3062 : 0 : return SVX_BREAK_END; // SVX_BREAK_PAGE_BOTH + 1
3063 : : }
3064 : :
3065 : : // class SvxFmtKeepItem -------------------------------------------------
3066 : :
3067 : 1980 : SfxPoolItem* SvxFmtKeepItem::Clone( SfxItemPool* ) const
3068 : : {
3069 [ + - ]: 1980 : return new SvxFmtKeepItem( *this );
3070 : : }
3071 : :
3072 : : // -----------------------------------------------------------------------
3073 : :
3074 : 0 : SvStream& SvxFmtKeepItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
3075 : : {
3076 : 0 : rStrm << (sal_Int8)GetValue();
3077 : 0 : return rStrm;
3078 : : }
3079 : :
3080 : : // -----------------------------------------------------------------------
3081 : :
3082 : 0 : SfxPoolItem* SvxFmtKeepItem::Create( SvStream& rStrm, sal_uInt16 ) const
3083 : : {
3084 : : sal_Int8 bIsKeep;
3085 [ # # ]: 0 : rStrm >> bIsKeep;
3086 [ # # ][ # # ]: 0 : return new SvxFmtKeepItem( sal_Bool( bIsKeep != 0 ), Which() );
3087 : : }
3088 : :
3089 : : //------------------------------------------------------------------------
3090 : :
3091 : 0 : SfxItemPresentation SvxFmtKeepItem::GetPresentation
3092 : : (
3093 : : SfxItemPresentation ePres,
3094 : : SfxMapUnit /*eCoreUnit*/,
3095 : : SfxMapUnit /*ePresUnit*/,
3096 : : XubString& rText, const IntlWrapper *
3097 : : ) const
3098 : : {
3099 [ # # # ]: 0 : switch ( ePres )
3100 : : {
3101 : : case SFX_ITEM_PRESENTATION_NONE:
3102 : 0 : rText.Erase();
3103 : 0 : return ePres;
3104 : :
3105 : : case SFX_ITEM_PRESENTATION_NAMELESS:
3106 : : case SFX_ITEM_PRESENTATION_COMPLETE:
3107 : : {
3108 : 0 : sal_uInt16 nId = RID_SVXITEMS_FMTKEEP_FALSE;
3109 : :
3110 [ # # ]: 0 : if ( GetValue() )
3111 : 0 : nId = RID_SVXITEMS_FMTKEEP_TRUE;
3112 [ # # ][ # # ]: 0 : rText = EE_RESSTR(nId);
3113 : 0 : return ePres;
3114 : : }
3115 : : default: ;//prevent warning
3116 : : }
3117 : 0 : return SFX_ITEM_PRESENTATION_NONE;
3118 : : }
3119 : :
3120 : : // class SvxLineItem ------------------------------------------------------
3121 : :
3122 : 10581 : SvxLineItem::SvxLineItem( const sal_uInt16 nId ) :
3123 : :
3124 : : SfxPoolItem ( nId ),
3125 : :
3126 : 10581 : pLine( NULL )
3127 : : {
3128 : 10581 : }
3129 : :
3130 : : // -----------------------------------------------------------------------
3131 : :
3132 : 245 : SvxLineItem::SvxLineItem( const SvxLineItem& rCpy ) :
3133 : :
3134 : 245 : SfxPoolItem ( rCpy )
3135 : : {
3136 [ + - ][ + - ]: 245 : pLine = rCpy.GetLine() ? new SvxBorderLine( *rCpy.GetLine() ) : 0;
[ + + ]
3137 : 245 : }
3138 : :
3139 : : // -----------------------------------------------------------------------
3140 : :
3141 : 10050 : SvxLineItem::~SvxLineItem()
3142 : : {
3143 : 10050 : delete pLine;
3144 [ - + ]: 18797 : }
3145 : :
3146 : : // -----------------------------------------------------------------------
3147 : :
3148 : 512 : SvxLineItem& SvxLineItem::operator=( const SvxLineItem& rLine )
3149 : : {
3150 : 512 : SetLine( rLine.GetLine() );
3151 : :
3152 : 512 : return *this;
3153 : : }
3154 : :
3155 : : // -----------------------------------------------------------------------
3156 : :
3157 : 639 : int SvxLineItem::operator==( const SfxPoolItem& rAttr ) const
3158 : : {
3159 : : DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
3160 : :
3161 : 639 : return CmpBrdLn( pLine, ((SvxLineItem&)rAttr).GetLine() );
3162 : : }
3163 : :
3164 : : // -----------------------------------------------------------------------
3165 : :
3166 : 181 : SfxPoolItem* SvxLineItem::Clone( SfxItemPool* ) const
3167 : : {
3168 [ + - ]: 181 : return new SvxLineItem( *this );
3169 : : }
3170 : :
3171 : 122 : bool SvxLineItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemId ) const
3172 : : {
3173 : 122 : sal_Bool bConvert = 0!=(nMemId&CONVERT_TWIPS);
3174 : 122 : nMemId &= ~CONVERT_TWIPS;
3175 [ + - ]: 122 : if ( nMemId == 0 )
3176 : : {
3177 [ + - ][ + - ]: 122 : rVal <<= uno::makeAny( SvxBoxItem::SvxLineToLine(pLine, bConvert) );
3178 : 122 : return true;
3179 : : }
3180 [ # # ]: 0 : else if ( pLine )
3181 : : {
3182 [ # # # # : 0 : switch ( nMemId )
# ]
3183 : : {
3184 [ # # ]: 0 : case MID_FG_COLOR: rVal <<= sal_Int32(pLine->GetColor().GetColor()); break;
3185 [ # # ]: 0 : case MID_OUTER_WIDTH: rVal <<= sal_Int32(pLine->GetOutWidth()); break;
3186 [ # # ]: 0 : case MID_INNER_WIDTH: rVal <<= sal_Int32(pLine->GetInWidth( )); break;
3187 [ # # ]: 0 : case MID_DISTANCE: rVal <<= sal_Int32(pLine->GetDistance()); break;
3188 : : default:
3189 : : OSL_FAIL( "Wrong MemberId" );
3190 : 0 : return false;
3191 : : }
3192 : : }
3193 : :
3194 : 122 : return true;
3195 : : }
3196 : :
3197 : : // -----------------------------------------------------------------------
3198 : :
3199 : 82 : bool SvxLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemId )
3200 : : {
3201 : 82 : sal_Bool bConvert = 0!=(nMemId&CONVERT_TWIPS);
3202 : 82 : nMemId &= ~CONVERT_TWIPS;
3203 : 82 : sal_Int32 nVal = 0;
3204 [ + - ]: 82 : if ( nMemId == 0 )
3205 : : {
3206 : 82 : table::BorderLine2 aLine;
3207 [ + - ][ + - ]: 82 : if ( lcl_extractBorderLine(rVal, aLine) )
3208 : : {
3209 [ + - ]: 82 : if ( !pLine )
3210 [ + - ][ + - ]: 82 : pLine = new SvxBorderLine;
3211 [ + - ][ + + ]: 82 : if( !SvxBoxItem::LineToSvxLine(aLine, *pLine, bConvert) )
3212 : 76 : DELETEZ( pLine );
3213 : 82 : return true;
3214 : : }
3215 : 82 : return false;
3216 : : }
3217 [ # # ]: 0 : else if ( rVal >>= nVal )
3218 : : {
3219 [ # # ]: 0 : if ( !pLine )
3220 [ # # ][ # # ]: 0 : pLine = new SvxBorderLine;
3221 : :
3222 [ # # # ]: 0 : switch ( nMemId )
3223 : : {
3224 : 0 : case MID_FG_COLOR: pLine->SetColor( Color(nVal) ); break;
3225 : : case MID_LINE_STYLE:
3226 [ # # ]: 0 : pLine->SetBorderLineStyle(static_cast<SvxBorderStyle>(nVal));
3227 : 0 : break;
3228 : : default:
3229 : : OSL_FAIL( "Wrong MemberId" );
3230 : 0 : return sal_False;
3231 : : }
3232 : :
3233 : 0 : return true;
3234 : : }
3235 : :
3236 : 82 : return false;
3237 : : }
3238 : :
3239 : : //------------------------------------------------------------------------
3240 : :
3241 : 0 : SfxItemPresentation SvxLineItem::GetPresentation
3242 : : (
3243 : : SfxItemPresentation ePres,
3244 : : SfxMapUnit eCoreUnit,
3245 : : SfxMapUnit ePresUnit,
3246 : : XubString& rText, const IntlWrapper *pIntl
3247 : : ) const
3248 : : {
3249 : 0 : rText.Erase();
3250 : :
3251 [ # # # ]: 0 : switch ( ePres )
3252 : : {
3253 : : case SFX_ITEM_PRESENTATION_NONE:
3254 : 0 : return SFX_ITEM_PRESENTATION_NONE;
3255 : : case SFX_ITEM_PRESENTATION_NAMELESS:
3256 : : case SFX_ITEM_PRESENTATION_COMPLETE:
3257 : : {
3258 [ # # ]: 0 : if ( pLine )
3259 : : rText = pLine->GetValueString( eCoreUnit, ePresUnit, pIntl,
3260 [ # # ]: 0 : (SFX_ITEM_PRESENTATION_COMPLETE == ePres) );
3261 : 0 : return ePres;
3262 : : }
3263 : : default: ;//prevent warning
3264 : : }
3265 : 0 : return SFX_ITEM_PRESENTATION_NONE;
3266 : : }
3267 : :
3268 : : // -----------------------------------------------------------------------
3269 : :
3270 : 1056 : SvStream& SvxLineItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
3271 : : {
3272 [ - + ]: 1056 : if( pLine )
3273 : : {
3274 : 0 : rStrm << pLine->GetColor()
3275 : 0 : << (short)pLine->GetOutWidth()
3276 : 0 : << (short)pLine->GetInWidth()
3277 : 0 : << (short)pLine->GetDistance();
3278 : : }
3279 : : else
3280 [ + - ][ + - ]: 1056 : rStrm << Color() << (short)0 << (short)0 << (short)0;
[ + - ][ + - ]
3281 : 1056 : return rStrm;
3282 : : }
3283 : :
3284 : : // -----------------------------------------------------------------------
3285 : :
3286 : 0 : bool SvxLineItem::ScaleMetrics( long nMult, long nDiv )
3287 : : {
3288 [ # # ]: 0 : if ( pLine ) pLine->ScaleMetrics( nMult, nDiv );
3289 : 0 : return true;
3290 : : }
3291 : :
3292 : : // -----------------------------------------------------------------------
3293 : :
3294 : 0 : bool SvxLineItem::HasMetrics() const
3295 : : {
3296 : 0 : return true;
3297 : : }
3298 : :
3299 : : // -----------------------------------------------------------------------
3300 : :
3301 : 512 : SfxPoolItem* SvxLineItem::Create( SvStream& rStrm, sal_uInt16 ) const
3302 : : {
3303 [ + - ][ + - ]: 512 : SvxLineItem* _pLine = new SvxLineItem( Which() );
3304 : : short nOutline, nInline, nDistance;
3305 : 512 : Color aColor;
3306 : :
3307 [ + - ][ + - ]: 512 : rStrm >> aColor >> nOutline >> nInline >> nDistance;
[ + - ][ + - ]
3308 [ - + ]: 512 : if( nOutline )
3309 : : {
3310 [ # # ]: 0 : SvxBorderLine aLine( &aColor );
3311 [ # # ]: 0 : aLine.GuessLinesWidths(NONE, nOutline, nInline, nDistance);
3312 [ # # ]: 0 : _pLine->SetLine( &aLine );
3313 : : }
3314 : 512 : return _pLine;
3315 : : }
3316 : :
3317 : : // -----------------------------------------------------------------------
3318 : :
3319 : 525 : void SvxLineItem::SetLine( const SvxBorderLine* pNew )
3320 : : {
3321 : 525 : delete pLine;
3322 [ + - ][ + + ]: 525 : pLine = pNew ? new SvxBorderLine( *pNew ) : 0;
3323 : 525 : }
3324 : :
3325 : : #ifdef _MSC_VER
3326 : : #pragma optimize ( "", off )
3327 : : #endif
3328 : :
3329 : : // class SvxBrushItem ----------------------------------------------------
3330 : :
3331 : : #define LOAD_GRAPHIC ((sal_uInt16)0x0001)
3332 : : #define LOAD_LINK ((sal_uInt16)0x0002)
3333 : : #define LOAD_FILTER ((sal_uInt16)0x0004)
3334 : :
3335 : : // class SvxBrushItem_Impl -----------------------------------------------
3336 : :
3337 : : class SvxBrushItem_Impl
3338 : : {
3339 : : public:
3340 : : GraphicObject* pGraphicObject;
3341 : : sal_Int8 nGraphicTransparency; //contains a percentage value which is
3342 : : //copied to the GraphicObject when necessary
3343 : : Link aDoneLink;
3344 : : SvStream* pStream;
3345 : :
3346 : 7321 : SvxBrushItem_Impl( GraphicObject* p ) : pGraphicObject( p ), nGraphicTransparency(0), pStream(0) {}
3347 : : };
3348 : :
3349 : : // -----------------------------------------------------------------------
3350 : :
3351 : 489 : void SvxBrushItem::SetDoneLink( const Link& rLink )
3352 : : {
3353 : 489 : pImpl->aDoneLink = rLink;
3354 : 489 : }
3355 : :
3356 : : // -----------------------------------------------------------------------
3357 : :
3358 : 2452 : SvxBrushItem::SvxBrushItem( sal_uInt16 _nWhich ) :
3359 : :
3360 : : SfxPoolItem( _nWhich ),
3361 : :
3362 : : aColor ( COL_TRANSPARENT ),
3363 [ + - ]: 2452 : pImpl ( new SvxBrushItem_Impl( 0 ) ),
3364 : : pStrLink ( NULL ),
3365 : : pStrFilter ( NULL ),
3366 : : eGraphicPos ( GPOS_NONE ),
3367 [ + - ]: 2452 : bLoadAgain ( sal_True )
3368 : :
3369 : : {
3370 : 2452 : }
3371 : :
3372 : : // -----------------------------------------------------------------------
3373 : :
3374 : 2004 : SvxBrushItem::SvxBrushItem( const Color& rColor, sal_uInt16 _nWhich) :
3375 : :
3376 : : SfxPoolItem( _nWhich ),
3377 : :
3378 : : aColor ( rColor ),
3379 [ + - ]: 2004 : pImpl ( new SvxBrushItem_Impl( 0 ) ),
3380 : : pStrLink ( NULL ),
3381 : : pStrFilter ( NULL ),
3382 : : eGraphicPos ( GPOS_NONE ),
3383 [ + - ]: 2004 : bLoadAgain ( sal_True )
3384 : :
3385 : : {
3386 : 2004 : }
3387 : :
3388 : : // -----------------------------------------------------------------------
3389 : :
3390 : 0 : SvxBrushItem::SvxBrushItem( const Graphic& rGraphic, SvxGraphicPosition ePos,
3391 : : sal_uInt16 _nWhich ) :
3392 : :
3393 : : SfxPoolItem( _nWhich ),
3394 : :
3395 : : aColor ( COL_TRANSPARENT ),
3396 [ # # ][ # # ]: 0 : pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphic ) ) ),
3397 : : pStrLink ( NULL ),
3398 : : pStrFilter ( NULL ),
3399 : : eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
3400 [ # # ][ # # ]: 0 : bLoadAgain ( sal_True )
[ # # ]
3401 : :
3402 : : {
3403 : : DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3404 : 0 : }
3405 : :
3406 : : // -----------------------------------------------------------------------
3407 : :
3408 : 0 : SvxBrushItem::SvxBrushItem( const GraphicObject& rGraphicObj,
3409 : : SvxGraphicPosition ePos, sal_uInt16 _nWhich ) :
3410 : :
3411 : : SfxPoolItem( _nWhich ),
3412 : :
3413 : : aColor ( COL_TRANSPARENT ),
3414 [ # # ][ # # ]: 0 : pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphicObj ) ) ),
3415 : : pStrLink ( NULL ),
3416 : : pStrFilter ( NULL ),
3417 : : eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
3418 [ # # ][ # # ]: 0 : bLoadAgain ( sal_True )
[ # # ]
3419 : :
3420 : : {
3421 : : DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3422 : 0 : }
3423 : :
3424 : : // -----------------------------------------------------------------------
3425 : :
3426 : 0 : SvxBrushItem::SvxBrushItem(
3427 : : const String& rLink, const String& rFilter,
3428 : : SvxGraphicPosition ePos, sal_uInt16 _nWhich ) :
3429 : :
3430 : : SfxPoolItem( _nWhich ),
3431 : :
3432 : : aColor ( COL_TRANSPARENT ),
3433 [ # # ]: 0 : pImpl ( new SvxBrushItem_Impl( NULL ) ),
3434 [ # # ]: 0 : pStrLink ( new String( rLink ) ),
3435 [ # # ]: 0 : pStrFilter ( new String( rFilter ) ),
3436 : : eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
3437 [ # # ][ # # ]: 0 : bLoadAgain ( sal_True )
[ # # ][ # # ]
3438 : :
3439 : : {
3440 : : DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3441 : 0 : }
3442 : :
3443 : : // -----------------------------------------------------------------------
3444 : :
3445 : 256 : SvxBrushItem::SvxBrushItem( SvStream& rStream, sal_uInt16 nVersion,
3446 : : sal_uInt16 _nWhich ) :
3447 : :
3448 : : SfxPoolItem( _nWhich ),
3449 : :
3450 : : aColor ( COL_TRANSPARENT ),
3451 [ + - ]: 256 : pImpl ( new SvxBrushItem_Impl( NULL ) ),
3452 : : pStrLink ( NULL ),
3453 : : pStrFilter ( NULL ),
3454 [ + - ]: 256 : eGraphicPos ( GPOS_NONE )
3455 : :
3456 : : {
3457 : : sal_Bool bTrans;
3458 : 256 : Color aTempColor;
3459 : 256 : Color aTempFillColor;
3460 : : sal_Int8 nStyle;
3461 : :
3462 [ + - ]: 256 : rStream >> bTrans;
3463 [ + - ]: 256 : rStream >> aTempColor;
3464 [ + - ]: 256 : rStream >> aTempFillColor;
3465 [ + - ]: 256 : rStream >> nStyle;
3466 : :
3467 [ - - - + : 256 : switch ( nStyle )
+ ]
3468 : : {
3469 : : case 8://BRUSH_25:
3470 : : {
3471 : 0 : sal_uInt32 nRed = aTempColor.GetRed();
3472 : 0 : sal_uInt32 nGreen = aTempColor.GetGreen();
3473 : 0 : sal_uInt32 nBlue = aTempColor.GetBlue();
3474 : 0 : nRed += (sal_uInt32)(aTempFillColor.GetRed())*2;
3475 : 0 : nGreen += (sal_uInt32)(aTempFillColor.GetGreen())*2;
3476 : 0 : nBlue += (sal_uInt32)(aTempFillColor.GetBlue())*2;
3477 : 0 : aColor = Color( (sal_Int8)(nRed/3), (sal_Int8)(nGreen/3), (sal_Int8)(nBlue/3) );
3478 : : }
3479 : 0 : break;
3480 : :
3481 : : case 9://BRUSH_50:
3482 : : {
3483 : 0 : sal_uInt32 nRed = aTempColor.GetRed();
3484 : 0 : sal_uInt32 nGreen = aTempColor.GetGreen();
3485 : 0 : sal_uInt32 nBlue = aTempColor.GetBlue();
3486 : 0 : nRed += (sal_uInt32)(aTempFillColor.GetRed());
3487 : 0 : nGreen += (sal_uInt32)(aTempFillColor.GetGreen());
3488 : 0 : nBlue += (sal_uInt32)(aTempFillColor.GetBlue());
3489 : 0 : aColor = Color( (sal_Int8)(nRed/2), (sal_Int8)(nGreen/2), (sal_Int8)(nBlue/2) );
3490 : : }
3491 : 0 : break;
3492 : :
3493 : : case 10://BRUSH_75:
3494 : : {
3495 : 0 : sal_uInt32 nRed = aTempColor.GetRed()*2;
3496 : 0 : sal_uInt32 nGreen = aTempColor.GetGreen()*2;
3497 : 0 : sal_uInt32 nBlue = aTempColor.GetBlue()*2;
3498 : 0 : nRed += (sal_uInt32)(aTempFillColor.GetRed());
3499 : 0 : nGreen += (sal_uInt32)(aTempFillColor.GetGreen());
3500 : 0 : nBlue += (sal_uInt32)(aTempFillColor.GetBlue());
3501 : 0 : aColor = Color( (sal_Int8)(nRed/3), (sal_Int8)(nGreen/3), (sal_Int8)(nBlue/3) );
3502 : : }
3503 : 0 : break;
3504 : :
3505 : : case 0://BRUSH_NULL:
3506 : 4 : aColor = Color( COL_TRANSPARENT );
3507 : 4 : break;
3508 : :
3509 : : default:
3510 : 252 : aColor = aTempColor;
3511 : : }
3512 : :
3513 [ + - ]: 256 : if ( nVersion >= BRUSH_GRAPHIC_VERSION )
3514 : : {
3515 : 256 : sal_uInt16 nDoLoad = 0;
3516 : : sal_Int8 nPos;
3517 : :
3518 [ + - ]: 256 : rStream >> nDoLoad;
3519 : :
3520 [ - + ]: 256 : if ( nDoLoad & LOAD_GRAPHIC )
3521 : : {
3522 [ # # ]: 0 : Graphic aGraphic;
3523 : :
3524 [ # # ]: 0 : rStream >> aGraphic;
3525 [ # # ][ # # ]: 0 : pImpl->pGraphicObject = new GraphicObject( aGraphic );
3526 : :
3527 [ # # ]: 0 : if( SVSTREAM_FILEFORMAT_ERROR == rStream.GetError() )
3528 : : {
3529 [ # # ]: 0 : rStream.ResetError();
3530 : : rStream.SetError( ERRCODE_SVX_GRAPHIC_WRONG_FILEFORMAT|
3531 [ # # ]: 0 : ERRCODE_WARNING_MASK );
3532 [ # # ]: 0 : }
3533 : : }
3534 : :
3535 [ - + ]: 256 : if ( nDoLoad & LOAD_LINK )
3536 : : {
3537 : : // UNICODE: rStream >> aRel;
3538 [ # # ][ # # ]: 0 : String aRel = rStream.ReadUniOrByteString(rStream.GetStreamCharSet());
3539 : :
3540 : : // TODO/MBA: how can we get a BaseURL here?!
3541 : : OSL_FAIL("No BaseURL!");
3542 [ # # ][ # # ]: 0 : String aAbs = INetURLObject::GetAbsURL( String(), aRel );
[ # # ][ # # ]
[ # # ][ # # ]
3543 : : DBG_ASSERT( aAbs.Len(), "Invalid URL!" );
3544 [ # # ][ # # ]: 0 : pStrLink = new String( aAbs );
[ # # ][ # # ]
3545 : : }
3546 : :
3547 [ - + ]: 256 : if ( nDoLoad & LOAD_FILTER )
3548 : : {
3549 [ # # ][ # # ]: 0 : pStrFilter = new String;
3550 : : // UNICODE: rStream >> *pStrFilter;
3551 [ # # ][ # # ]: 0 : *pStrFilter = rStream.ReadUniOrByteString(rStream.GetStreamCharSet());
3552 : : }
3553 : :
3554 [ + - ]: 256 : rStream >> nPos;
3555 : :
3556 : 256 : eGraphicPos = (SvxGraphicPosition)nPos;
3557 : : }
3558 : 256 : }
3559 : :
3560 : : // -----------------------------------------------------------------------
3561 : :
3562 : 2609 : SvxBrushItem::SvxBrushItem( const SvxBrushItem& rItem ) :
3563 : :
3564 : 2609 : SfxPoolItem( rItem.Which() ),
3565 : :
3566 [ + - ]: 2609 : pImpl ( new SvxBrushItem_Impl( NULL ) ),
3567 : : pStrLink ( NULL ),
3568 : : pStrFilter ( NULL ),
3569 : : eGraphicPos ( GPOS_NONE ),
3570 [ + - ]: 2609 : bLoadAgain ( sal_True )
3571 : :
3572 : : {
3573 [ + - ]: 2609 : *this = rItem;
3574 : 2609 : }
3575 : :
3576 : : // -----------------------------------------------------------------------
3577 : :
3578 : 6975 : SvxBrushItem::~SvxBrushItem()
3579 : : {
3580 [ + + ][ + - ]: 6975 : delete pImpl->pGraphicObject;
3581 : 6975 : delete pImpl;
3582 [ + - ][ + + ]: 6975 : delete pStrLink;
3583 [ + + ][ + - ]: 6975 : delete pStrFilter;
3584 [ - + ]: 11035 : }
3585 : :
3586 : : // -----------------------------------------------------------------------
3587 : :
3588 : 530 : sal_uInt16 SvxBrushItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const
3589 : : {
3590 : 530 : return BRUSH_GRAPHIC_VERSION;
3591 : : }
3592 : :
3593 : : // -----------------------------------------------------------------------
3594 : 0 : inline sal_Int8 lcl_PercentToTransparency(long nPercent)
3595 : : {
3596 : : //0xff must not be returned!
3597 [ # # ]: 0 : return sal_Int8(nPercent ? (50 + 0xfe * nPercent) / 100 : 0);
3598 : : }
3599 : 3 : inline sal_Int8 lcl_TransparencyToPercent(sal_Int32 nTrans)
3600 : : {
3601 : 3 : return (sal_Int8)((nTrans * 100 + 127) / 254);
3602 : : }
3603 : :
3604 : 501 : bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
3605 : : {
3606 : 501 : nMemberId &= ~CONVERT_TWIPS;
3607 [ + - + + : 501 : switch( nMemberId)
- + + + -
- ]
3608 : : {
3609 : : case MID_BACK_COLOR:
3610 [ + - ]: 162 : rVal <<= (sal_Int32)( aColor.GetColor() );
3611 : 162 : break;
3612 : : case MID_BACK_COLOR_R_G_B:
3613 [ # # ]: 0 : rVal <<= (sal_Int32)( aColor.GetRGBColor() );
3614 : 0 : break;
3615 : : case MID_BACK_COLOR_TRANSPARENCY:
3616 [ + - ]: 3 : rVal <<= lcl_TransparencyToPercent(aColor.GetTransparency());
3617 : 3 : break;
3618 : : case MID_GRAPHIC_POSITION:
3619 [ + - ]: 74 : rVal <<= (style::GraphicLocation)(sal_Int16)eGraphicPos;
3620 : 74 : break;
3621 : :
3622 : : case MID_GRAPHIC:
3623 : : SAL_WARN( "editeng.items", "not implemented" );
3624 : 0 : break;
3625 : :
3626 : : case MID_GRAPHIC_TRANSPARENT:
3627 : 150 : rVal = Bool2Any( aColor.GetTransparency() == 0xff );
3628 : 150 : break;
3629 : :
3630 : : case MID_GRAPHIC_URL:
3631 : : {
3632 : 44 : OUString sLink;
3633 [ + + ]: 44 : if ( pStrLink )
3634 [ + - ]: 6 : sLink = *pStrLink;
3635 [ - + ]: 38 : else if( pImpl->pGraphicObject )
3636 : : {
3637 : : OUString sPrefix(
3638 : 0 : UNO_NAME_GRAPHOBJ_URLPREFIX);
3639 : : OUString sId(rtl::OStringToOUString(
3640 : : pImpl->pGraphicObject->GetUniqueID(),
3641 [ # # ][ # # ]: 0 : RTL_TEXTENCODING_ASCII_US));
3642 : 0 : sLink = sPrefix + sId;
3643 : : }
3644 [ + - ]: 44 : rVal <<= sLink;
3645 : : }
3646 : 44 : break;
3647 : :
3648 : : case MID_GRAPHIC_FILTER:
3649 : : {
3650 : 68 : OUString sFilter;
3651 [ + + ]: 68 : if ( pStrFilter )
3652 [ + - ]: 24 : sFilter = *pStrFilter;
3653 [ + - ]: 68 : rVal <<= sFilter;
3654 : : }
3655 : 68 : break;
3656 : : case MID_GRAPHIC_TRANSPARENCY :
3657 : 0 : rVal <<= pImpl->nGraphicTransparency;
3658 : 0 : break;
3659 : : }
3660 : :
3661 : 501 : return true;
3662 : : }
3663 : :
3664 : : // -----------------------------------------------------------------------
3665 : :
3666 : 1293 : bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
3667 : : {
3668 : 1293 : nMemberId &= ~CONVERT_TWIPS;
3669 [ + - + - : 1293 : switch( nMemberId)
+ + + -
- ]
3670 : : {
3671 : : case MID_BACK_COLOR:
3672 : : case MID_BACK_COLOR_R_G_B:
3673 : : {
3674 : 324 : sal_Int32 nCol = 0;
3675 [ - + ]: 324 : if ( !( rVal >>= nCol ) )
3676 : 0 : return sal_False;
3677 [ - + ]: 324 : if(MID_BACK_COLOR_R_G_B == nMemberId)
3678 : : {
3679 : 0 : nCol = COLORDATA_RGB( nCol );
3680 : 0 : nCol += aColor.GetColor() & 0xff000000;
3681 : : }
3682 : 324 : aColor = Color( nCol );
3683 : : }
3684 : 324 : break;
3685 : : case MID_BACK_COLOR_TRANSPARENCY:
3686 : : {
3687 : 0 : sal_Int32 nTrans = 0;
3688 [ # # ][ # # ]: 0 : if ( !( rVal >>= nTrans ) || nTrans < 0 || nTrans > 100 )
[ # # ][ # # ]
3689 : 0 : return sal_False;
3690 [ # # ]: 0 : aColor.SetTransparency(lcl_PercentToTransparency(nTrans));
3691 : : }
3692 : 0 : break;
3693 : :
3694 : : case MID_GRAPHIC_POSITION:
3695 : : {
3696 : : style::GraphicLocation eLocation;
3697 [ + - ][ - + ]: 228 : if ( !( rVal>>=eLocation ) )
3698 : : {
3699 : 0 : sal_Int32 nValue = 0;
3700 [ # # ]: 0 : if ( !( rVal >>= nValue ) )
3701 : 0 : return sal_False;
3702 : 0 : eLocation = (style::GraphicLocation)nValue;
3703 : : }
3704 [ + - ]: 228 : SetGraphicPos( (SvxGraphicPosition)(sal_uInt16)eLocation );
3705 : : }
3706 : 228 : break;
3707 : :
3708 : : case MID_GRAPHIC:
3709 : : SAL_WARN( "editeng.items", "not implemented" );
3710 : 0 : break;
3711 : :
3712 : : case MID_GRAPHIC_TRANSPARENT:
3713 [ + + ]: 299 : aColor.SetTransparency( Any2Bool( rVal ) ? 0xff : 0 );
3714 : 299 : break;
3715 : :
3716 : : case MID_GRAPHIC_URL:
3717 : : {
3718 [ + - ]: 216 : if ( rVal.getValueType() == ::getCppuType( (OUString*)0 ) )
3719 : : {
3720 : 216 : OUString sLink;
3721 : 216 : rVal >>= sLink;
3722 [ + - ]: 216 : if( 0 == sLink.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX,
3723 : 216 : sizeof(UNO_NAME_GRAPHOBJ_URLPKGPREFIX)-1 ) )
3724 : : {
3725 : : OSL_FAIL( "package urls aren't implemented" );
3726 : : }
3727 [ - + ]: 216 : else if( 0 == sLink.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX,
3728 : 216 : sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX)-1 ) )
3729 : : {
3730 [ # # ][ # # ]: 0 : DELETEZ( pStrLink );
3731 [ # # ]: 0 : String sTmp( sLink );
3732 : : rtl::OString sId(rtl::OUStringToOString(sTmp.Copy(
3733 : : sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX)-1),
3734 [ # # ][ # # ]: 0 : RTL_TEXTENCODING_ASCII_US));
[ # # ][ # # ]
3735 : 0 : GraphicObject *pOldGrfObj = pImpl->pGraphicObject;
3736 [ # # ][ # # ]: 0 : pImpl->pGraphicObject = new GraphicObject( sId );
3737 [ # # ]: 0 : ApplyGraphicTransparency_Impl();
3738 [ # # ][ # # ]: 0 : delete pOldGrfObj;
[ # # ]
3739 : : }
3740 : : else
3741 : : {
3742 [ + - ][ + - ]: 216 : SetGraphicLink(sLink);
[ + - ]
3743 : : }
3744 [ + + ][ + - ]: 216 : if ( !sLink.isEmpty() && eGraphicPos == GPOS_NONE )
[ + + ]
3745 : 6 : eGraphicPos = GPOS_MM;
3746 [ + - ]: 210 : else if( sLink.isEmpty() )
3747 : 216 : eGraphicPos = GPOS_NONE;
3748 : : }
3749 : : }
3750 : 216 : break;
3751 : :
3752 : : case MID_GRAPHIC_FILTER:
3753 : : {
3754 [ + - ]: 226 : if( rVal.getValueType() == ::getCppuType( (OUString*)0 ) )
3755 : : {
3756 : 226 : OUString sLink;
3757 : 226 : rVal >>= sLink;
3758 [ + - ][ + - ]: 226 : SetGraphicFilter( sLink );
[ + - ]
3759 : : }
3760 : : }
3761 : 226 : break;
3762 : : case MID_GRAPHIC_TRANSPARENCY :
3763 : : {
3764 : 0 : sal_Int32 nTmp = 0;
3765 : 0 : rVal >>= nTmp;
3766 [ # # ][ # # ]: 0 : if(nTmp >= 0 && nTmp <= 100)
3767 : : {
3768 : 0 : pImpl->nGraphicTransparency = sal_Int8(nTmp);
3769 [ # # ]: 0 : if(pImpl->pGraphicObject)
3770 [ # # ]: 0 : ApplyGraphicTransparency_Impl();
3771 : : }
3772 : : }
3773 : 0 : break;
3774 : : }
3775 : :
3776 : 1293 : return true;
3777 : : }
3778 : :
3779 : : // -----------------------------------------------------------------------
3780 : :
3781 : 0 : SfxItemPresentation SvxBrushItem::GetPresentation
3782 : : (
3783 : : SfxItemPresentation ePres,
3784 : : SfxMapUnit /*eCoreUnit*/,
3785 : : SfxMapUnit /*ePresUnit*/,
3786 : : XubString& rText, const IntlWrapper *
3787 : : ) const
3788 : : {
3789 [ # # # ]: 0 : switch ( ePres )
3790 : : {
3791 : : case SFX_ITEM_PRESENTATION_NONE:
3792 : 0 : rText.Erase();
3793 : 0 : return ePres;
3794 : :
3795 : : case SFX_ITEM_PRESENTATION_NAMELESS:
3796 : : case SFX_ITEM_PRESENTATION_COMPLETE:
3797 : : {
3798 [ # # ]: 0 : if ( GPOS_NONE == eGraphicPos )
3799 : : {
3800 [ # # ]: 0 : rText = ::GetColorString( aColor );
3801 : 0 : rText += cpDelim;
3802 : 0 : sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
3803 : :
3804 [ # # ]: 0 : if ( aColor.GetTransparency() )
3805 : 0 : nId = RID_SVXITEMS_TRANSPARENT_TRUE;
3806 [ # # ][ # # ]: 0 : rText += EE_RESSTR(nId);
3807 : : }
3808 : : else
3809 : : {
3810 [ # # ][ # # ]: 0 : rText = EE_RESSTR(RID_SVXITEMS_GRAPHIC);
3811 : : }
3812 : :
3813 : 0 : return ePres;
3814 : : }
3815 : : default: ;//prevent warning
3816 : : }
3817 : :
3818 : 0 : return SFX_ITEM_PRESENTATION_NONE;
3819 : : }
3820 : :
3821 : : // -----------------------------------------------------------------------
3822 : :
3823 : 4130 : SvxBrushItem& SvxBrushItem::operator=( const SvxBrushItem& rItem )
3824 : : {
3825 : 4130 : aColor = rItem.aColor;
3826 : 4130 : eGraphicPos = rItem.eGraphicPos;
3827 : :
3828 [ - + ]: 4130 : DELETEZ( pImpl->pGraphicObject );
3829 [ - + ]: 4130 : DELETEZ( pStrLink );
3830 [ - + ]: 4130 : DELETEZ( pStrFilter );
3831 : :
3832 [ + + ]: 4130 : if ( GPOS_NONE != eGraphicPos )
3833 : : {
3834 [ + + ]: 126 : if ( rItem.pStrLink )
3835 [ + - ]: 70 : pStrLink = new String( *rItem.pStrLink );
3836 [ + + ]: 126 : if ( rItem.pStrFilter )
3837 [ + - ]: 76 : pStrFilter = new String( *rItem.pStrFilter );
3838 [ + + ]: 126 : if ( rItem.pImpl->pGraphicObject )
3839 : : {
3840 [ + - ]: 56 : pImpl->pGraphicObject = new GraphicObject( *rItem.pImpl->pGraphicObject );
3841 : : }
3842 : : }
3843 : 4130 : pImpl->nGraphicTransparency = rItem.pImpl->nGraphicTransparency;
3844 : 4130 : return *this;
3845 : : }
3846 : :
3847 : : // -----------------------------------------------------------------------
3848 : :
3849 : 8261 : int SvxBrushItem::operator==( const SfxPoolItem& rAttr ) const
3850 : : {
3851 : : DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
3852 : :
3853 : 8261 : SvxBrushItem& rCmp = (SvxBrushItem&)rAttr;
3854 : 8261 : sal_Bool bEqual = ( aColor == rCmp.aColor && eGraphicPos == rCmp.eGraphicPos &&
3855 [ + + ][ + - ]: 8261 : pImpl->nGraphicTransparency == rCmp.pImpl->nGraphicTransparency);
[ + + ]
3856 : :
3857 [ + + ]: 8261 : if ( bEqual )
3858 : : {
3859 [ + + ]: 5399 : if ( GPOS_NONE != eGraphicPos )
3860 : : {
3861 [ + + ]: 48 : if ( !rCmp.pStrLink )
3862 : 18 : bEqual = !pStrLink;
3863 : : else
3864 [ + - ][ + - ]: 30 : bEqual = pStrLink && ( *pStrLink == *rCmp.pStrLink );
3865 : :
3866 [ + - ]: 48 : if ( bEqual )
3867 : : {
3868 [ + + ]: 48 : if ( !rCmp.pStrFilter )
3869 : 18 : bEqual = !pStrFilter;
3870 : : else
3871 [ + + ][ - + ]: 30 : bEqual = pStrFilter && ( *pStrFilter == *rCmp.pStrFilter );
3872 : : }
3873 : :
3874 [ + + ][ + - ]: 48 : if ( bEqual && !rCmp.pStrLink )
3875 : : {
3876 [ - + ]: 2 : if ( !rCmp.pImpl->pGraphicObject )
3877 : 0 : bEqual = !pImpl->pGraphicObject;
3878 : : else
3879 : : bEqual = pImpl->pGraphicObject &&
3880 [ + - ][ + - ]: 2 : ( *pImpl->pGraphicObject == *rCmp.pImpl->pGraphicObject );
3881 : : }
3882 : : }
3883 : : }
3884 : :
3885 : 8261 : return bEqual;
3886 : : }
3887 : :
3888 : : // -----------------------------------------------------------------------
3889 : :
3890 : 2546 : SfxPoolItem* SvxBrushItem::Clone( SfxItemPool* ) const
3891 : : {
3892 [ + - ]: 2546 : return new SvxBrushItem( *this );
3893 : : }
3894 : :
3895 : : // -----------------------------------------------------------------------
3896 : :
3897 : 256 : SfxPoolItem* SvxBrushItem::Create( SvStream& rStream, sal_uInt16 nVersion ) const
3898 : : {
3899 [ + - ]: 256 : return new SvxBrushItem( rStream, nVersion, Which() );
3900 : : }
3901 : :
3902 : : // -----------------------------------------------------------------------
3903 : :
3904 : 528 : SvStream& SvxBrushItem::Store( SvStream& rStream , sal_uInt16 /*nItemVersion*/ ) const
3905 : : {
3906 : 528 : rStream << (sal_Bool)sal_False;
3907 : 528 : rStream << aColor;
3908 : 528 : rStream << aColor;
3909 : 528 : rStream << (sal_Int8)(aColor.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
3910 : :
3911 : 528 : sal_uInt16 nDoLoad = 0;
3912 : :
3913 [ # # ][ - + ]: 528 : if ( pImpl->pGraphicObject && !pStrLink )
3914 : 0 : nDoLoad |= LOAD_GRAPHIC;
3915 [ - + ]: 528 : if ( pStrLink )
3916 : 0 : nDoLoad |= LOAD_LINK;
3917 [ - + ]: 528 : if ( pStrFilter )
3918 : 0 : nDoLoad |= LOAD_FILTER;
3919 : 528 : rStream << nDoLoad;
3920 : :
3921 [ # # ][ - + ]: 528 : if ( pImpl->pGraphicObject && !pStrLink )
3922 : 0 : rStream << pImpl->pGraphicObject->GetGraphic();
3923 [ - + ]: 528 : if ( pStrLink )
3924 : : {
3925 : : OSL_FAIL("No BaseURL!");
3926 : : // TODO/MBA: how to get a BaseURL?!
3927 [ # # ][ # # ]: 0 : String aRel = INetURLObject::GetRelURL( String(), *pStrLink );
[ # # ][ # # ]
[ # # ][ # # ]
3928 : : // UNICODE: rStream << aRel;
3929 [ # # ][ # # ]: 0 : rStream.WriteUniOrByteString(aRel, rStream.GetStreamCharSet());
[ # # ]
3930 : : }
3931 [ - + ]: 528 : if ( pStrFilter )
3932 : : {
3933 : : // UNICODE: rStream << *pStrFilter;
3934 [ # # ]: 0 : rStream.WriteUniOrByteString(*pStrFilter, rStream.GetStreamCharSet());
3935 : : }
3936 : 528 : rStream << (sal_Int8)eGraphicPos;
3937 : 528 : return rStream;
3938 : : }
3939 : :
3940 : : // -----------------------------------------------------------------------
3941 : :
3942 : 0 : void SvxBrushItem::PurgeMedium() const
3943 : : {
3944 [ # # ]: 0 : DELETEZ( pImpl->pStream );
3945 : 0 : }
3946 : :
3947 : : // -----------------------------------------------------------------------
3948 : 3608 : const GraphicObject* SvxBrushItem::GetGraphicObject() const
3949 : : {
3950 [ + + ][ + + ]: 3608 : if ( bLoadAgain && pStrLink && !pImpl->pGraphicObject )
[ + - ]
3951 : : // when graphics already loaded, use as a cache
3952 : : {
3953 : : // only with "valid" names - empty names now allowed
3954 [ + - ]: 9 : if( pStrLink->Len() )
3955 : : {
3956 : 9 : pImpl->pStream = utl::UcbStreamHelper::CreateStream( *pStrLink, STREAM_STD_READ );
3957 [ # # ][ - + ]: 9 : if( pImpl->pStream && !pImpl->pStream->GetError() )
[ - + ]
3958 : : {
3959 [ # # ]: 0 : Graphic aGraphic;
3960 : : int nRes;
3961 [ # # ]: 0 : pImpl->pStream->Seek( STREAM_SEEK_TO_BEGIN );
3962 [ # # ]: 0 : nRes = GraphicFilter::GetGraphicFilter().
3963 : : ImportGraphic( aGraphic, *pStrLink, *pImpl->pStream,
3964 [ # # ]: 0 : GRFILTER_FORMAT_DONTKNOW, NULL, GRFILTER_I_FLAGS_DONT_SET_LOGSIZE_FOR_JPEG );
3965 : :
3966 [ # # ]: 0 : if( nRes != GRFILTER_OK )
3967 : : {
3968 : 0 : const_cast < SvxBrushItem*> (this)->bLoadAgain = sal_False;
3969 : : }
3970 : : else
3971 : : {
3972 [ # # ][ # # ]: 0 : pImpl->pGraphicObject = new GraphicObject;
3973 [ # # ]: 0 : pImpl->pGraphicObject->SetGraphic( aGraphic );
3974 [ # # ]: 0 : const_cast < SvxBrushItem*> (this)->ApplyGraphicTransparency_Impl();
3975 [ # # ]: 0 : }
3976 : : }
3977 : : else
3978 : : {
3979 : 9 : const_cast < SvxBrushItem*> (this)->bLoadAgain = sal_False;
3980 : : }
3981 : : }
3982 : : }
3983 : :
3984 : 3608 : return pImpl->pGraphicObject;
3985 : : }
3986 : :
3987 : : // -----------------------------------------------------------------------
3988 : :
3989 : 492 : const Graphic* SvxBrushItem::GetGraphic() const
3990 : : {
3991 : 492 : const GraphicObject* pGrafObj = GetGraphicObject();
3992 [ + + ]: 492 : return( pGrafObj ? &( pGrafObj->GetGraphic() ) : NULL );
3993 : : }
3994 : :
3995 : : // -----------------------------------------------------------------------
3996 : :
3997 : 228 : void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew )
3998 : : {
3999 : 228 : eGraphicPos = eNew;
4000 : :
4001 [ + + ]: 228 : if ( GPOS_NONE == eGraphicPos )
4002 : : {
4003 [ - + ]: 210 : DELETEZ( pImpl->pGraphicObject );
4004 [ - + ]: 210 : DELETEZ( pStrLink );
4005 [ - + ]: 210 : DELETEZ( pStrFilter );
4006 : : }
4007 : : else
4008 : : {
4009 [ + + ][ + + ]: 18 : if ( !pImpl->pGraphicObject && !pStrLink )
4010 : : {
4011 [ + - ]: 4 : pImpl->pGraphicObject = new GraphicObject; // Creating a dummy
4012 : : }
4013 : : }
4014 : 228 : }
4015 : :
4016 : : // -----------------------------------------------------------------------
4017 : :
4018 : 0 : void SvxBrushItem::SetGraphic( const Graphic& rNew )
4019 : : {
4020 [ # # ]: 0 : if ( !pStrLink )
4021 : : {
4022 [ # # ]: 0 : if ( pImpl->pGraphicObject )
4023 : 0 : pImpl->pGraphicObject->SetGraphic( rNew );
4024 : : else
4025 [ # # ]: 0 : pImpl->pGraphicObject = new GraphicObject( rNew );
4026 : :
4027 : 0 : ApplyGraphicTransparency_Impl();
4028 : :
4029 [ # # ]: 0 : if ( GPOS_NONE == eGraphicPos )
4030 : 0 : eGraphicPos = GPOS_MM; // None would be brush, then Default: middle
4031 : : }
4032 : : else
4033 : : {
4034 : : OSL_FAIL( "SetGraphic() on linked graphic! :-/" );
4035 : : }
4036 : 0 : }
4037 : :
4038 : : // -----------------------------------------------------------------------
4039 : :
4040 : 0 : void SvxBrushItem::SetGraphicObject( const GraphicObject& rNewObj )
4041 : : {
4042 [ # # ]: 0 : if ( !pStrLink )
4043 : : {
4044 [ # # ]: 0 : if ( pImpl->pGraphicObject )
4045 : 0 : *pImpl->pGraphicObject = rNewObj;
4046 : : else
4047 [ # # ]: 0 : pImpl->pGraphicObject = new GraphicObject( rNewObj );
4048 : :
4049 : 0 : ApplyGraphicTransparency_Impl();
4050 : :
4051 [ # # ]: 0 : if ( GPOS_NONE == eGraphicPos )
4052 : 0 : eGraphicPos = GPOS_MM; // None would be brush, then Default: middle
4053 : : }
4054 : : else
4055 : : {
4056 : : OSL_FAIL( "SetGraphic() on linked graphic! :-/" );
4057 : : }
4058 : 0 : }
4059 : :
4060 : : // -----------------------------------------------------------------------
4061 : :
4062 : 216 : void SvxBrushItem::SetGraphicLink( const String& rNew )
4063 : : {
4064 [ + + ]: 216 : if ( !rNew.Len() )
4065 [ - + ]: 210 : DELETEZ( pStrLink );
4066 : : else
4067 : : {
4068 [ - + ]: 6 : if ( pStrLink )
4069 : 0 : *pStrLink = rNew;
4070 : : else
4071 [ + - ]: 6 : pStrLink = new String( rNew );
4072 : :
4073 [ - + ]: 6 : DELETEZ( pImpl->pGraphicObject );
4074 : : }
4075 : 216 : }
4076 : :
4077 : : // -----------------------------------------------------------------------
4078 : :
4079 : 226 : void SvxBrushItem::SetGraphicFilter( const String& rNew )
4080 : : {
4081 [ + + ]: 226 : if ( !rNew.Len() )
4082 [ - + ]: 210 : DELETEZ( pStrFilter );
4083 : : else
4084 : : {
4085 [ + + ]: 16 : if ( pStrFilter )
4086 : 6 : *pStrFilter = rNew;
4087 : : else
4088 [ + - ]: 10 : pStrFilter = new String( rNew );
4089 : : }
4090 : 226 : }
4091 : :
4092 : : //static
4093 : 0 : SvxGraphicPosition SvxBrushItem::WallpaperStyle2GraphicPos( WallpaperStyle eStyle )
4094 : : {
4095 : : SvxGraphicPosition eResult;
4096 : : // The switch is not the fastest, but the safest
4097 [ # # # # : 0 : switch( eStyle )
# # # # #
# # # # ]
4098 : : {
4099 : 0 : case WALLPAPER_NULL: eResult = GPOS_NONE; break;
4100 : 0 : case WALLPAPER_TILE: eResult = GPOS_TILED; break;
4101 : 0 : case WALLPAPER_CENTER: eResult = GPOS_MM; break;
4102 : 0 : case WALLPAPER_SCALE: eResult = GPOS_AREA; break;
4103 : 0 : case WALLPAPER_TOPLEFT: eResult = GPOS_LT; break;
4104 : 0 : case WALLPAPER_TOP: eResult = GPOS_MT; break;
4105 : 0 : case WALLPAPER_TOPRIGHT: eResult = GPOS_RT; break;
4106 : 0 : case WALLPAPER_LEFT: eResult = GPOS_LM; break;
4107 : 0 : case WALLPAPER_RIGHT: eResult = GPOS_RM; break;
4108 : 0 : case WALLPAPER_BOTTOMLEFT: eResult = GPOS_LB; break;
4109 : 0 : case WALLPAPER_BOTTOM: eResult = GPOS_MB; break;
4110 : 0 : case WALLPAPER_BOTTOMRIGHT: eResult = GPOS_RB; break;
4111 : 0 : default: eResult = GPOS_NONE;
4112 : : }
4113 : 0 : return eResult;
4114 : : };
4115 : :
4116 : : //static
4117 : 0 : WallpaperStyle SvxBrushItem::GraphicPos2WallpaperStyle( SvxGraphicPosition ePos )
4118 : : {
4119 : : WallpaperStyle eResult;
4120 [ # # # # : 0 : switch( ePos )
# # # # #
# # # # ]
4121 : : {
4122 : 0 : case GPOS_NONE: eResult = WALLPAPER_NULL; break;
4123 : 0 : case GPOS_TILED: eResult = WALLPAPER_TILE; break;
4124 : 0 : case GPOS_MM: eResult = WALLPAPER_CENTER; break;
4125 : 0 : case GPOS_AREA: eResult = WALLPAPER_SCALE; break;
4126 : 0 : case GPOS_LT: eResult = WALLPAPER_TOPLEFT; break;
4127 : 0 : case GPOS_MT: eResult = WALLPAPER_TOP; break;
4128 : 0 : case GPOS_RT: eResult = WALLPAPER_TOPRIGHT; break;
4129 : 0 : case GPOS_LM: eResult = WALLPAPER_LEFT; break;
4130 : 0 : case GPOS_RM: eResult = WALLPAPER_RIGHT; break;
4131 : 0 : case GPOS_LB: eResult = WALLPAPER_BOTTOMLEFT; break;
4132 : 0 : case GPOS_MB: eResult = WALLPAPER_BOTTOM; break;
4133 : 0 : case GPOS_RB: eResult = WALLPAPER_BOTTOMRIGHT; break;
4134 : 0 : default: eResult = WALLPAPER_NULL;
4135 : : }
4136 : 0 : return eResult;
4137 : : }
4138 : :
4139 : 0 : SvxBrushItem::SvxBrushItem( const CntWallpaperItem& rItem, sal_uInt16 _nWhich ) :
4140 : : SfxPoolItem( _nWhich ),
4141 [ # # ]: 0 : pImpl( new SvxBrushItem_Impl( 0 ) ),
4142 : : pStrLink(0),
4143 : : pStrFilter(0),
4144 [ # # ]: 0 : bLoadAgain( sal_True )
4145 : : {
4146 : 0 : aColor = rItem.GetColor();
4147 : :
4148 [ # # ]: 0 : if (!rItem.GetBitmapURL().isEmpty())
4149 : : {
4150 [ # # ][ # # ]: 0 : pStrLink = new String( rItem.GetBitmapURL() );
4151 [ # # ][ # # ]: 0 : SetGraphicPos( WallpaperStyle2GraphicPos((WallpaperStyle)rItem.GetStyle() ) );
4152 : : }
4153 : 0 : }
4154 : :
4155 : : #ifdef _MSC_VER
4156 : : #pragma optimize ( "", on )
4157 : : #endif
4158 : :
4159 : 0 : void SvxBrushItem::ApplyGraphicTransparency_Impl()
4160 : : {
4161 : : DBG_ASSERT(pImpl->pGraphicObject, "no GraphicObject available" );
4162 [ # # ]: 0 : if(pImpl->pGraphicObject)
4163 : : {
4164 : 0 : GraphicAttr aAttr(pImpl->pGraphicObject->GetAttr());
4165 : : aAttr.SetTransparency(lcl_PercentToTransparency(
4166 : 0 : pImpl->nGraphicTransparency));
4167 [ # # ][ # # ]: 0 : pImpl->pGraphicObject->SetAttr(aAttr);
4168 : : }
4169 : 0 : }
4170 : : // class SvxFrameDirectionItem ----------------------------------------------
4171 : :
4172 : 18598 : SvxFrameDirectionItem::SvxFrameDirectionItem( SvxFrameDirection nValue ,
4173 : : sal_uInt16 _nWhich )
4174 : 18598 : : SfxUInt16Item( _nWhich, (sal_uInt16)nValue )
4175 : : {
4176 : 18598 : }
4177 : :
4178 : 77260 : SvxFrameDirectionItem::~SvxFrameDirectionItem()
4179 : : {
4180 [ - + ]: 137032 : }
4181 : :
4182 : 105325 : int SvxFrameDirectionItem::operator==( const SfxPoolItem& rCmp ) const
4183 : : {
4184 : : DBG_ASSERT( SfxPoolItem::operator==(rCmp), "unequal types" );
4185 : :
4186 : 105325 : return GetValue() == ((SvxFrameDirectionItem&)rCmp).GetValue();
4187 : : }
4188 : :
4189 : 59642 : SfxPoolItem* SvxFrameDirectionItem::Clone( SfxItemPool * ) const
4190 : : {
4191 [ + - ]: 59642 : return new SvxFrameDirectionItem( *this );
4192 : : }
4193 : :
4194 : 0 : SfxPoolItem* SvxFrameDirectionItem::Create( SvStream & rStrm, sal_uInt16 /*nVer*/ ) const
4195 : : {
4196 : : sal_uInt16 nValue;
4197 [ # # ]: 0 : rStrm >> nValue;
4198 [ # # ][ # # ]: 0 : return new SvxFrameDirectionItem( (SvxFrameDirection)nValue, Which() );
4199 : : }
4200 : :
4201 : 446 : SvStream& SvxFrameDirectionItem::Store( SvStream & rStrm, sal_uInt16 /*nIVer*/ ) const
4202 : : {
4203 : 446 : sal_uInt16 nValue = GetValue();
4204 : 446 : rStrm << nValue;
4205 : 446 : return rStrm;
4206 : : }
4207 : :
4208 : 7562 : sal_uInt16 SvxFrameDirectionItem::GetVersion( sal_uInt16 nFVer ) const
4209 : : {
4210 [ - + ]: 7562 : return SOFFICE_FILEFORMAT_50 > nFVer ? USHRT_MAX : 0;
4211 : : }
4212 : :
4213 : 0 : SfxItemPresentation SvxFrameDirectionItem::GetPresentation(
4214 : : SfxItemPresentation ePres,
4215 : : SfxMapUnit /*eCoreUnit*/,
4216 : : SfxMapUnit /*ePresUnit*/,
4217 : : XubString& rText, const IntlWrapper *) const
4218 : : {
4219 : 0 : SfxItemPresentation eRet = ePres;
4220 [ # # # ]: 0 : switch( ePres )
4221 : : {
4222 : : case SFX_ITEM_PRESENTATION_NONE:
4223 : 0 : rText.Erase();
4224 : 0 : break;
4225 : :
4226 : : case SFX_ITEM_PRESENTATION_NAMELESS:
4227 : : case SFX_ITEM_PRESENTATION_COMPLETE:
4228 [ # # ][ # # ]: 0 : rText = EE_RESSTR( RID_SVXITEMS_FRMDIR_BEGIN + GetValue() );
4229 : 0 : break;
4230 : :
4231 : : default:
4232 : 0 : eRet = SFX_ITEM_PRESENTATION_NONE;
4233 : : }
4234 : 0 : return eRet;
4235 : : }
4236 : :
4237 : 23170 : bool SvxFrameDirectionItem::PutValue( const com::sun::star::uno::Any& rVal,
4238 : : sal_uInt8 )
4239 : : {
4240 : 23170 : sal_Int16 nVal = sal_Int16();
4241 : 23170 : sal_Bool bRet = ( rVal >>= nVal );
4242 [ + - ]: 23170 : if( bRet )
4243 : : {
4244 : : // translate WritingDirection2 constants into SvxFrameDirection
4245 [ + + + - : 23170 : switch( nVal )
+ + ]
4246 : : {
4247 : : case text::WritingMode2::LR_TB:
4248 : 790 : SetValue( FRMDIR_HORI_LEFT_TOP );
4249 : 790 : break;
4250 : : case text::WritingMode2::RL_TB:
4251 : 10 : SetValue( FRMDIR_HORI_RIGHT_TOP );
4252 : 10 : break;
4253 : : case text::WritingMode2::TB_RL:
4254 : 10 : SetValue( FRMDIR_VERT_TOP_RIGHT );
4255 : 10 : break;
4256 : : case text::WritingMode2::TB_LR:
4257 : 0 : SetValue( FRMDIR_VERT_TOP_LEFT );
4258 : 0 : break;
4259 : : case text::WritingMode2::PAGE:
4260 : 22061 : SetValue( FRMDIR_ENVIRONMENT );
4261 : 22061 : break;
4262 : : default:
4263 : 299 : bRet = false;
4264 : 23170 : break;
4265 : : }
4266 : : }
4267 : :
4268 : 23170 : return bRet;
4269 : : }
4270 : :
4271 : 206 : bool SvxFrameDirectionItem::QueryValue( com::sun::star::uno::Any& rVal,
4272 : : sal_uInt8 ) const
4273 : : {
4274 : : // translate SvxFrameDirection into WritingDirection2
4275 : : sal_Int16 nVal;
4276 : 206 : bool bRet = true;
4277 [ + + + - : 206 : switch( GetValue() )
+ - ]
4278 : : {
4279 : : case FRMDIR_HORI_LEFT_TOP:
4280 : 101 : nVal = text::WritingMode2::LR_TB;
4281 : 101 : break;
4282 : : case FRMDIR_HORI_RIGHT_TOP:
4283 : 8 : nVal = text::WritingMode2::RL_TB;
4284 : 8 : break;
4285 : : case FRMDIR_VERT_TOP_RIGHT:
4286 : 8 : nVal = text::WritingMode2::TB_RL;
4287 : 8 : break;
4288 : : case FRMDIR_VERT_TOP_LEFT:
4289 : 0 : nVal = text::WritingMode2::TB_LR;
4290 : 0 : break;
4291 : : case FRMDIR_ENVIRONMENT:
4292 : 89 : nVal = text::WritingMode2::PAGE;
4293 : 89 : break;
4294 : : default:
4295 : : OSL_FAIL("Unknown SvxFrameDirection value!");
4296 : 0 : bRet = false;
4297 : 0 : break;
4298 : : }
4299 : :
4300 : : // return value + error state
4301 [ + - ]: 206 : if( bRet )
4302 : : {
4303 [ + - ]: 206 : rVal <<= nVal;
4304 : : }
4305 : 206 : return bRet;
4306 : : }
4307 : :
4308 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|