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