1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
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>
46 #include <i18nutil/unicode.hxx>
47 #include <unotools/securityoptions.hxx>
48 #include <unotools/ucbstreamhelper.hxx>
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 <tools/mapunit.hxx>
60 #include <vcl/graphicfilter.hxx>
61 #include <vcl/settings.hxx>
62 #include <vcl/svapp.hxx>
63 #include <editeng/editids.hrc>
64 #include <editeng/editrids.hrc>
65 #include <editeng/pbinitem.hxx>
66 #include <editeng/sizeitem.hxx>
67 #include <editeng/lrspitem.hxx>
68 #include <editeng/ulspitem.hxx>
69 #include <editeng/prntitem.hxx>
70 #include <editeng/opaqitem.hxx>
71 #include <editeng/protitem.hxx>
72 #include <editeng/shaditem.hxx>
73 #include <editeng/boxitem.hxx>
74 #include <editeng/formatbreakitem.hxx>
75 #include <editeng/keepitem.hxx>
76 #include <editeng/lineitem.hxx>
77 #include <editeng/brushitem.hxx>
78 #include <editeng/frmdiritem.hxx>
79 #include <editeng/itemtype.hxx>
80 #include <editeng/eerdll.hxx>
81 #include <editeng/unoprnms.hxx>
82 #include <editeng/memberids.hrc>
83 #include <editeng/editerr.hxx>
84 #include <libxml/xmlwriter.h>
85 #include <o3tl/enumrange.hxx>
87 using namespace ::editeng
;
88 using namespace ::com::sun::star
;
89 using namespace ::com::sun::star::drawing
;
90 using namespace ::com::sun::star::table::BorderLineStyle
;
93 SvxBorderLine is not an SfxPoolItem, and has no Store/Create serialization/deserialization methods.
94 Since border line information needs to be serialized by the table autoformat code, these file-local
95 methods are defined to encapsulate the necessary serialization logic.
99 /// Item version for saved border lines. The old version saves the line without style information.
100 const int BORDER_LINE_OLD_VERSION
= 0;
101 /// Item version for saved border lies. The new version includes line style.
102 const int BORDER_LINE_WITH_STYLE_VERSION
= 1;
104 /// Store a border line to a stream.
105 SvStream
& StoreBorderLine(SvStream
&stream
, const SvxBorderLine
&l
, sal_uInt16 version
)
107 WriteColor( stream
, l
.GetColor() );
108 stream
.WriteUInt16( l
.GetOutWidth() )
109 .WriteUInt16( l
.GetInWidth() )
110 .WriteUInt16( l
.GetDistance() );
112 if (version
>= BORDER_LINE_WITH_STYLE_VERSION
)
113 stream
.WriteUInt16( l
.GetBorderLineStyle() );
118 /// Creates a border line from a stream.
119 SvxBorderLine
CreateBorderLine(SvStream
&stream
, sal_uInt16 version
)
121 sal_uInt16 nOutline
, nInline
, nDistance
;
122 sal_uInt16 nStyle
= css::table::BorderLineStyle::NONE
;
124 ReadColor( stream
, aColor
).ReadUInt16( nOutline
).ReadUInt16( nInline
).ReadUInt16( nDistance
);
126 if (version
>= BORDER_LINE_WITH_STYLE_VERSION
)
127 stream
.ReadUInt16( nStyle
);
129 SvxBorderLine
border(&aColor
);
130 border
.GuessLinesWidths(nStyle
, nOutline
, nInline
, nDistance
);
134 /// Retrieves a BORDER_LINE_* version from a BOX_BORDER_* version.
135 sal_uInt16
BorderLineVersionFromBoxVersion(sal_uInt16 boxVersion
)
137 return (boxVersion
>= BOX_BORDER_STYLE_VERSION
)? BORDER_LINE_WITH_STYLE_VERSION
: BORDER_LINE_OLD_VERSION
;
141 TYPEINIT1_FACTORY(SvxPaperBinItem
, SfxByteItem
, new SvxPaperBinItem(0));
142 TYPEINIT1_FACTORY(SvxSizeItem
, SfxPoolItem
, new SvxSizeItem(0));
143 TYPEINIT1_FACTORY(SvxLRSpaceItem
, SfxPoolItem
, new SvxLRSpaceItem(0));
144 TYPEINIT1_FACTORY(SvxULSpaceItem
, SfxPoolItem
, new SvxULSpaceItem(0));
145 TYPEINIT1_FACTORY(SvxPrintItem
, SfxBoolItem
, new SvxPrintItem(0));
146 TYPEINIT1_FACTORY(SvxOpaqueItem
, SfxBoolItem
, new SvxOpaqueItem(0));
147 TYPEINIT1_FACTORY(SvxProtectItem
, SfxPoolItem
, new SvxProtectItem(0));
148 TYPEINIT1_FACTORY(SvxBrushItem
, SfxPoolItem
, new SvxBrushItem(0));
149 TYPEINIT1_FACTORY(SvxShadowItem
, SfxPoolItem
, new SvxShadowItem(0));
150 TYPEINIT1_FACTORY(SvxBoxItem
, SfxPoolItem
, new SvxBoxItem(0));
151 TYPEINIT1_FACTORY(SvxBoxInfoItem
, SfxPoolItem
, new SvxBoxInfoItem(0));
152 TYPEINIT1_FACTORY(SvxFormatBreakItem
, SfxEnumItem
, new SvxFormatBreakItem(SVX_BREAK_NONE
, 0));
153 TYPEINIT1_FACTORY(SvxFormatKeepItem
, SfxBoolItem
, new SvxFormatKeepItem(false, 0));
154 TYPEINIT1_FACTORY(SvxLineItem
, SfxPoolItem
, new SvxLineItem(0));
155 TYPEINIT1_FACTORY(SvxFrameDirectionItem
, SfxUInt16Item
, new SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP
, 0));
157 // class SvxPaperBinItem ------------------------------------------------
159 SfxPoolItem
* SvxPaperBinItem::Clone( SfxItemPool
* ) const
161 return new SvxPaperBinItem( *this );
166 SvStream
& SvxPaperBinItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
168 rStrm
.WriteUChar( GetValue() );
174 SfxPoolItem
* SvxPaperBinItem::Create( SvStream
& rStrm
, sal_uInt16
) const
177 rStrm
.ReadSChar( nBin
);
178 return new SvxPaperBinItem( Which(), nBin
);
183 bool SvxPaperBinItem::GetPresentation
185 SfxItemPresentation ePres
,
186 SfxMapUnit
/*eCoreUnit*/,
187 SfxMapUnit
/*ePresUnit*/,
188 OUString
& rText
, const IntlWrapper
*
193 case SFX_ITEM_PRESENTATION_NAMELESS
:
194 rText
= OUString::number( GetValue() );
197 case SFX_ITEM_PRESENTATION_COMPLETE
:
199 sal_uInt8 nValue
= GetValue();
201 if ( PAPERBIN_PRINTER_SETTINGS
== nValue
)
202 rText
= EE_RESSTR(RID_SVXSTR_PAPERBIN_SETTINGS
);
205 rText
= EE_RESSTR(RID_SVXSTR_PAPERBIN
) + " " + OUString::number( nValue
);
210 default: ;//prevent warning
216 // class SvxSizeItem -----------------------------------------------------
218 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId
, const Size
& rSize
) :
227 bool SvxSizeItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
229 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
230 nMemberId
&= ~CONVERT_TWIPS
;
232 awt::Size
aTmp(aSize
.Width(), aSize
.Height());
235 aTmp
.Height
= convertTwipToMm100(aTmp
.Height
);
236 aTmp
.Width
= convertTwipToMm100(aTmp
.Width
);
241 case MID_SIZE_SIZE
: rVal
<<= aTmp
; break;
242 case MID_SIZE_WIDTH
: rVal
<<= aTmp
.Width
; break;
243 case MID_SIZE_HEIGHT
: rVal
<<= aTmp
.Height
; break;
244 default: OSL_FAIL("Wrong MemberId!"); return false;
250 bool SvxSizeItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
252 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
253 nMemberId
&= ~CONVERT_TWIPS
;
264 aTmp
.Height
= convertMm100ToTwip(aTmp
.Height
);
265 aTmp
.Width
= convertMm100ToTwip(aTmp
.Width
);
267 aSize
= Size( aTmp
.Width
, aTmp
.Height
);
278 if(!(rVal
>>= nVal
))
281 aSize
.Width() = bConvert
? convertMm100ToTwip(nVal
) : nVal
;
284 case MID_SIZE_HEIGHT
:
290 aSize
.Height() = bConvert
? convertMm100ToTwip(nVal
) : nVal
;
293 default: OSL_FAIL("Wrong MemberId!");
301 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId
) :
309 bool SvxSizeItem::operator==( const SfxPoolItem
& rAttr
) const
311 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
313 return ( aSize
== static_cast<const SvxSizeItem
&>( rAttr
).GetSize() );
318 SfxPoolItem
* SvxSizeItem::Clone( SfxItemPool
* ) const
320 return new SvxSizeItem( *this );
325 bool SvxSizeItem::GetPresentation
327 SfxItemPresentation ePres
,
328 SfxMapUnit eCoreUnit
,
329 SfxMapUnit ePresUnit
,
330 OUString
& rText
, const IntlWrapper
*pIntl
333 OUString
cpDelimTmp(cpDelim
);
336 case SFX_ITEM_PRESENTATION_NAMELESS
:
337 rText
= GetMetricText( aSize
.Width(), eCoreUnit
, ePresUnit
, pIntl
) +
339 GetMetricText( aSize
.Height(), eCoreUnit
, ePresUnit
, pIntl
);
342 case SFX_ITEM_PRESENTATION_COMPLETE
:
343 rText
= EE_RESSTR(RID_SVXITEMS_SIZE_WIDTH
) +
344 GetMetricText( aSize
.Width(), eCoreUnit
, ePresUnit
, pIntl
) +
345 " " + EE_RESSTR(GetMetricId(ePresUnit
)) +
347 EE_RESSTR(RID_SVXITEMS_SIZE_HEIGHT
) +
348 GetMetricText( aSize
.Height(), eCoreUnit
, ePresUnit
, pIntl
) +
349 " " + EE_RESSTR(GetMetricId(ePresUnit
));
352 default: ;//prevent warning
360 SvStream
& SvxSizeItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
362 rStrm
.WriteInt32( aSize
.Width() );
363 rStrm
.WriteInt32( aSize
.Height() );
369 bool SvxSizeItem::ScaleMetrics( long nMult
, long nDiv
)
371 aSize
.Width() = Scale( aSize
.Width(), nMult
, nDiv
);
372 aSize
.Height() = Scale( aSize
.Height(), nMult
, nDiv
);
378 bool SvxSizeItem::HasMetrics() const
385 SfxPoolItem
* SvxSizeItem::Create( SvStream
& rStrm
, sal_uInt16
) const
387 sal_Int32
nWidth(0), nHeight(0);
388 rStrm
.ReadInt32( nWidth
).ReadInt32( nHeight
);
390 SvxSizeItem
* pAttr
= new SvxSizeItem( Which() );
391 pAttr
->SetSize(Size(nWidth
, nHeight
));
396 // class SvxLRSpaceItem --------------------------------------------------
398 SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId
) :
402 nFirstLineOfst ( 0 ),
406 nPropFirstLineOfst( 100 ),
407 nPropLeftMargin( 100 ),
408 nPropRightMargin( 100 ),
409 bAutoFirst ( false ),
410 bExplicitZeroMarginValRight(false),
411 bExplicitZeroMarginValLeft(false)
417 SvxLRSpaceItem::SvxLRSpaceItem( const long nLeft
, const long nRight
,
418 const long nTLeft
, const short nOfset
,
419 const sal_uInt16 nId
) :
423 nFirstLineOfst ( nOfset
),
425 nLeftMargin ( nLeft
),
426 nRightMargin ( nRight
),
427 nPropFirstLineOfst( 100 ),
428 nPropLeftMargin( 100 ),
429 nPropRightMargin( 100 ),
430 bAutoFirst ( false ),
431 bExplicitZeroMarginValRight(false),
432 bExplicitZeroMarginValLeft(false)
437 bool SvxLRSpaceItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
440 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
441 nMemberId
&= ~CONVERT_TWIPS
;
446 rVal
<<= (sal_Int32
)(bConvert
? convertTwipToMm100(nLeftMargin
) : nLeftMargin
);
449 case MID_TXT_LMARGIN
:
450 rVal
<<= (sal_Int32
)(bConvert
? convertTwipToMm100(nTxtLeft
) : nTxtLeft
);
453 rVal
<<= (sal_Int32
)(bConvert
? convertTwipToMm100(nRightMargin
) : nRightMargin
);
455 case MID_L_REL_MARGIN
:
456 rVal
<<= (sal_Int16
)nPropLeftMargin
;
458 case MID_R_REL_MARGIN
:
459 rVal
<<= (sal_Int16
)nPropRightMargin
;
462 case MID_FIRST_LINE_INDENT
:
463 rVal
<<= (sal_Int32
)(bConvert
? convertTwipToMm100(nFirstLineOfst
) : nFirstLineOfst
);
466 case MID_FIRST_LINE_REL_INDENT
:
467 rVal
<<= (sal_Int16
)(nPropFirstLineOfst
);
471 rVal
= Bool2Any(IsAutoFirst());
476 OSL_FAIL("unknown MemberId");
482 bool SvxLRSpaceItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
484 bool bConvert
= 0 != (nMemberId
&CONVERT_TWIPS
);
485 nMemberId
&= ~CONVERT_TWIPS
;
487 if( nMemberId
!= MID_FIRST_AUTO
&&
488 nMemberId
!= MID_L_REL_MARGIN
&& nMemberId
!= MID_R_REL_MARGIN
)
495 SetLeft( bConvert
? convertMm100ToTwip(nVal
) : nVal
);
498 case MID_TXT_LMARGIN
:
499 SetTextLeft( bConvert
? convertMm100ToTwip(nVal
) : nVal
);
503 SetRight(bConvert
? convertMm100ToTwip(nVal
) : nVal
);
505 case MID_L_REL_MARGIN
:
506 case MID_R_REL_MARGIN
:
509 if((rVal
>>= nRel
) && nRel
>= 0 && nRel
< USHRT_MAX
)
511 if(MID_L_REL_MARGIN
== nMemberId
)
512 nPropLeftMargin
= (sal_uInt16
)nRel
;
514 nPropRightMargin
= (sal_uInt16
)nRel
;
520 case MID_FIRST_LINE_INDENT
:
521 SetTextFirstLineOfst((short)(bConvert
? convertMm100ToTwip(nVal
) : nVal
));
524 case MID_FIRST_LINE_REL_INDENT
:
525 SetPropTextFirstLineOfst ( (sal_uInt16
)nVal
);
529 SetAutoFirst( Any2Bool(rVal
) );
533 OSL_FAIL("unknown MemberId");
541 // Adapt nLeftMargin and nTxtLeft.
543 void SvxLRSpaceItem::AdjustLeft()
545 if ( 0 > nFirstLineOfst
)
546 nLeftMargin
= nTxtLeft
+ nFirstLineOfst
;
548 nLeftMargin
= nTxtLeft
;
553 bool SvxLRSpaceItem::operator==( const SfxPoolItem
& rAttr
) const
555 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
557 const SvxLRSpaceItem
& rOther
= static_cast<const SvxLRSpaceItem
&>(rAttr
);
560 nFirstLineOfst
== rOther
.GetTextFirstLineOfst() &&
561 nTxtLeft
== rOther
.GetTextLeft() &&
562 nLeftMargin
== rOther
.GetLeft() &&
563 nRightMargin
== rOther
.GetRight() &&
564 nPropFirstLineOfst
== rOther
.GetPropTextFirstLineOfst() &&
565 nPropLeftMargin
== rOther
.GetPropLeft() &&
566 nPropRightMargin
== rOther
.GetPropRight() &&
567 bAutoFirst
== rOther
.IsAutoFirst() &&
568 bExplicitZeroMarginValRight
== rOther
.IsExplicitZeroMarginValRight() &&
569 bExplicitZeroMarginValLeft
== rOther
.IsExplicitZeroMarginValLeft() );
574 SfxPoolItem
* SvxLRSpaceItem::Clone( SfxItemPool
* ) const
576 return new SvxLRSpaceItem( *this );
581 bool SvxLRSpaceItem::GetPresentation
583 SfxItemPresentation ePres
,
584 SfxMapUnit eCoreUnit
,
585 SfxMapUnit ePresUnit
,
586 OUString
& rText
, const IntlWrapper
* pIntl
591 case SFX_ITEM_PRESENTATION_NAMELESS
:
593 if ( 100 != nPropLeftMargin
)
595 rText
= unicode::formatPercent(nPropLeftMargin
,
596 Application::GetSettings().GetUILanguageTag());
599 rText
= GetMetricText( (long)nLeftMargin
,
600 eCoreUnit
, ePresUnit
, pIntl
);
601 rText
+= OUString(cpDelim
);
602 if ( 100 != nPropFirstLineOfst
)
604 rText
+= unicode::formatPercent(nPropFirstLineOfst
,
605 Application::GetSettings().GetUILanguageTag());
608 rText
+= GetMetricText( (long)nFirstLineOfst
,
609 eCoreUnit
, ePresUnit
, pIntl
);
610 rText
+= OUString(cpDelim
);
611 if ( 100 != nRightMargin
)
613 rText
+= unicode::formatPercent(nRightMargin
,
614 Application::GetSettings().GetUILanguageTag());
617 rText
+= GetMetricText( (long)nRightMargin
,
618 eCoreUnit
, ePresUnit
, pIntl
);
621 case SFX_ITEM_PRESENTATION_COMPLETE
:
623 rText
= EE_RESSTR(RID_SVXITEMS_LRSPACE_LEFT
);
624 if ( 100 != nPropLeftMargin
)
625 rText
+= unicode::formatPercent(nPropLeftMargin
,
626 Application::GetSettings().GetUILanguageTag());
630 GetMetricText( (long)nLeftMargin
, eCoreUnit
, ePresUnit
, pIntl
) +
631 " " + EE_RESSTR(GetMetricId(ePresUnit
));
633 rText
+= OUString(cpDelim
);
634 if ( 100 != nPropFirstLineOfst
|| nFirstLineOfst
)
636 rText
+= EE_RESSTR(RID_SVXITEMS_LRSPACE_FLINE
);
637 if ( 100 != nPropFirstLineOfst
)
638 rText
= rText
+ unicode::formatPercent(nPropFirstLineOfst
,
639 Application::GetSettings().GetUILanguageTag());
643 GetMetricText( (long)nFirstLineOfst
,
644 eCoreUnit
, ePresUnit
, pIntl
) +
645 " " + EE_RESSTR(GetMetricId(ePresUnit
));
647 rText
+= OUString(cpDelim
);
649 rText
+= EE_RESSTR(RID_SVXITEMS_LRSPACE_RIGHT
);
650 if ( 100 != nPropRightMargin
)
651 rText
= rText
+ unicode::formatPercent(nPropRightMargin
,
652 Application::GetSettings().GetUILanguageTag());
656 GetMetricText( (long)nRightMargin
,
657 eCoreUnit
, ePresUnit
, pIntl
) +
658 " " + EE_RESSTR(GetMetricId(ePresUnit
));
662 default: ;//prevent warning
669 // BulletFI: Before 501 in the Outliner the bullet was not on the position of
670 // the FI, so in older documents one must set FI to 0.
671 #define BULLETLR_MARKER 0x599401FE
673 SvStream
& SvxLRSpaceItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
675 short nSaveFI
= nFirstLineOfst
;
676 const_cast<SvxLRSpaceItem
*>(this)->SetTextFirstLineOfst( 0 ); // nLeftMargin is manipulated together with this, see Create()
678 sal_uInt16 nMargin
= 0;
679 if( nLeftMargin
> 0 )
680 nMargin
= sal_uInt16( nLeftMargin
);
681 rStrm
.WriteUInt16( nMargin
);
682 rStrm
.WriteUInt16( nPropLeftMargin
);
683 if( nRightMargin
> 0 )
684 nMargin
= sal_uInt16( nRightMargin
);
687 rStrm
.WriteUInt16( nMargin
);
688 rStrm
.WriteUInt16( nPropRightMargin
);
689 rStrm
.WriteInt16( nFirstLineOfst
);
690 rStrm
.WriteUInt16( nPropFirstLineOfst
);
692 nMargin
= sal_uInt16( nTxtLeft
);
695 rStrm
.WriteUInt16( nMargin
);
696 if( nItemVersion
>= LRSPACE_AUTOFIRST_VERSION
)
698 sal_Int8 nAutoFirst
= bAutoFirst
? 1 : 0;
699 if( nItemVersion
>= LRSPACE_NEGATIVE_VERSION
&&
700 ( nLeftMargin
< 0 || nRightMargin
< 0 || nTxtLeft
< 0 ) )
702 rStrm
.WriteSChar( nAutoFirst
);
704 // From 6.0 onwards, do not write Magic numbers...
705 DBG_ASSERT( rStrm
.GetVersion() <= SOFFICE_FILEFORMAT_50
, "Change File format SvxLRSpaceItem!" );
706 rStrm
.WriteUInt32( BULLETLR_MARKER
);
707 rStrm
.WriteInt16( nSaveFI
);
709 if( 0x80 & nAutoFirst
)
711 rStrm
.WriteInt32( nLeftMargin
);
712 rStrm
.WriteInt32( nRightMargin
);
716 const_cast<SvxLRSpaceItem
*>(this)->SetTextFirstLineOfst( nSaveFI
);
723 SfxPoolItem
* SvxLRSpaceItem::Create( SvStream
& rStrm
, sal_uInt16 nVersion
) const
725 sal_uInt16 left
, prpleft
, right
, prpright
, prpfirstline
, txtleft
;
727 sal_Int8 autofirst
= 0;
729 if ( nVersion
>= LRSPACE_AUTOFIRST_VERSION
)
731 rStrm
.ReadUInt16( left
).ReadUInt16( prpleft
).ReadUInt16( right
).ReadUInt16( prpright
).ReadInt16( firstline
). ReadUInt16( prpfirstline
).ReadUInt16( txtleft
).ReadSChar( autofirst
);
733 sal_Size nPos
= rStrm
.Tell();
735 rStrm
.ReadUInt32( nMarker
);
736 if ( nMarker
== BULLETLR_MARKER
)
738 rStrm
.ReadInt16( firstline
);
740 left
= left
+ static_cast<sal_uInt16
>(firstline
); // see below: txtleft = ...
745 else if ( nVersion
== LRSPACE_TXTLEFT_VERSION
)
747 rStrm
.ReadUInt16( left
).ReadUInt16( prpleft
).ReadUInt16( right
).ReadUInt16( prpright
).ReadInt16( firstline
). ReadUInt16( prpfirstline
).ReadUInt16( txtleft
);
749 else if ( nVersion
== LRSPACE_16_VERSION
)
751 rStrm
.ReadUInt16( left
).ReadUInt16( prpleft
).ReadUInt16( right
).ReadUInt16( prpright
).ReadInt16( firstline
). ReadUInt16( prpfirstline
);
755 sal_Int8 nL
, nR
, nFL
;
756 rStrm
.ReadUInt16( left
).ReadSChar( nL
).ReadUInt16( right
).ReadSChar( nR
).ReadInt16( firstline
).ReadSChar( nFL
);
757 prpleft
= (sal_uInt16
)nL
;
758 prpright
= (sal_uInt16
)nR
;
759 prpfirstline
= (sal_uInt16
)nFL
;
762 txtleft
= firstline
>= 0 ? left
: left
- firstline
;
763 SvxLRSpaceItem
* pAttr
= new SvxLRSpaceItem( Which() );
765 pAttr
->nLeftMargin
= left
;
766 pAttr
->nPropLeftMargin
= prpleft
;
767 pAttr
->nRightMargin
= right
;
768 pAttr
->nPropRightMargin
= prpright
;
769 pAttr
->nFirstLineOfst
= firstline
;
770 pAttr
->nPropFirstLineOfst
= prpfirstline
;
771 pAttr
->nTxtLeft
= txtleft
;
772 pAttr
->bAutoFirst
= autofirst
& 0x01;
773 if( nVersion
>= LRSPACE_NEGATIVE_VERSION
&& ( autofirst
& 0x80 ) )
776 rStrm
.ReadInt32( nMargin
);
777 pAttr
->nLeftMargin
= nMargin
;
778 pAttr
->nTxtLeft
= firstline
>= 0 ? nMargin
: nMargin
- firstline
;
779 rStrm
.ReadInt32( nMargin
);
780 pAttr
->nRightMargin
= nMargin
;
787 sal_uInt16
SvxLRSpaceItem::GetVersion( sal_uInt16 nFileVersion
) const
789 return (nFileVersion
== SOFFICE_FILEFORMAT_31
)
790 ? LRSPACE_TXTLEFT_VERSION
791 : LRSPACE_NEGATIVE_VERSION
;
796 bool SvxLRSpaceItem::ScaleMetrics( long nMult
, long nDiv
)
798 nFirstLineOfst
= (short)Scale( nFirstLineOfst
, nMult
, nDiv
);
799 nTxtLeft
= Scale( nTxtLeft
, nMult
, nDiv
);
800 nLeftMargin
= Scale( nLeftMargin
, nMult
, nDiv
);
801 nRightMargin
= Scale( nRightMargin
, nMult
, nDiv
);
807 bool SvxLRSpaceItem::HasMetrics() const
812 void SvxLRSpaceItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
814 xmlTextWriterStartElement(pWriter
, BAD_CAST("svxLRSpaceItem"));
815 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
816 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nFirstLineOfst"), BAD_CAST(OString::number(nFirstLineOfst
).getStr()));
817 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nTxtLeft"), BAD_CAST(OString::number(nTxtLeft
).getStr()));
818 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nLeftMargin"), BAD_CAST(OString::number(nLeftMargin
).getStr()));
819 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nRightMargin"), BAD_CAST(OString::number(nRightMargin
).getStr()));
820 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nPropFirstLineOfst"), BAD_CAST(OString::number(nPropFirstLineOfst
).getStr()));
821 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nPropLeftMargin"), BAD_CAST(OString::number(nPropLeftMargin
).getStr()));
822 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nPropRightMargin"), BAD_CAST(OString::number(nPropRightMargin
).getStr()));
823 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("bAutoFirst"), BAD_CAST(OString::number(int(bAutoFirst
)).getStr()));
824 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("bExplicitZeroMarginValRight"), BAD_CAST(OString::number(int(bExplicitZeroMarginValRight
)).getStr()));
825 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("bExplicitZeroMarginValLeft"), BAD_CAST(OString::number(int(bExplicitZeroMarginValLeft
)).getStr()));
826 xmlTextWriterEndElement(pWriter
);
829 // class SvxULSpaceItem --------------------------------------------------
831 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nId
)
843 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nUp
, const sal_uInt16 nLow
,
844 const sal_uInt16 nId
)
855 bool SvxULSpaceItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
857 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
858 nMemberId
&= ~CONVERT_TWIPS
;
864 ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale
;
865 aUpperLowerMarginScale
.Upper
= (sal_Int32
)(bConvert
? convertTwipToMm100(nUpper
) : nUpper
);
866 aUpperLowerMarginScale
.Lower
= (sal_Int32
)(bConvert
? convertTwipToMm100(nLower
) : nPropUpper
);
867 aUpperLowerMarginScale
.ScaleUpper
= (sal_Int16
)nPropUpper
;
868 aUpperLowerMarginScale
.ScaleLower
= (sal_Int16
)nPropLower
;
869 rVal
<<= aUpperLowerMarginScale
;
872 case MID_UP_MARGIN
: rVal
<<= (sal_Int32
)(bConvert
? convertTwipToMm100(nUpper
) : nUpper
); break;
873 case MID_LO_MARGIN
: rVal
<<= (sal_Int32
)(bConvert
? convertTwipToMm100(nLower
) : nLower
); break;
874 case MID_CTX_MARGIN
: rVal
<<= bContext
; break;
875 case MID_UP_REL_MARGIN
: rVal
<<= (sal_Int16
) nPropUpper
; break;
876 case MID_LO_REL_MARGIN
: rVal
<<= (sal_Int16
) nPropLower
; break;
882 bool SvxULSpaceItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
884 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
885 nMemberId
&= ~CONVERT_TWIPS
;
892 ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale
;
893 if ( !(rVal
>>= aUpperLowerMarginScale
))
896 SetUpper((sal_uInt16
)(bConvert
? convertMm100ToTwip( aUpperLowerMarginScale
.Upper
) : aUpperLowerMarginScale
.Upper
));
897 SetLower((sal_uInt16
)(bConvert
? convertMm100ToTwip( aUpperLowerMarginScale
.Lower
) : aUpperLowerMarginScale
.Lower
));
898 if( aUpperLowerMarginScale
.ScaleUpper
> 1 )
899 nPropUpper
= aUpperLowerMarginScale
.ScaleUpper
;
900 if( aUpperLowerMarginScale
.ScaleLower
> 1 )
901 nPropUpper
= aUpperLowerMarginScale
.ScaleLower
;
906 if(!(rVal
>>= nVal
) || nVal
< 0)
908 SetUpper((sal_uInt16
)(bConvert
? convertMm100ToTwip(nVal
) : nVal
));
911 if(!(rVal
>>= nVal
) || nVal
< 0)
913 SetLower((sal_uInt16
)(bConvert
? convertMm100ToTwip(nVal
) : nVal
));
915 case MID_CTX_MARGIN
:
916 if (!(rVal
>>= bVal
))
918 SetContextValue(bVal
);
920 case MID_UP_REL_MARGIN
:
921 case MID_LO_REL_MARGIN
:
924 if((rVal
>>= nRel
) && nRel
> 1 )
926 if(MID_UP_REL_MARGIN
== nMemberId
)
927 nPropUpper
= (sal_uInt16
)nRel
;
929 nPropLower
= (sal_uInt16
)nRel
;
937 OSL_FAIL("unknown MemberId");
945 bool SvxULSpaceItem::operator==( const SfxPoolItem
& rAttr
) const
947 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
949 const SvxULSpaceItem
& rSpaceItem
= static_cast<const SvxULSpaceItem
&>( rAttr
);
950 return ( nUpper
== rSpaceItem
.nUpper
&&
951 nLower
== rSpaceItem
.nLower
&&
952 bContext
== rSpaceItem
.bContext
&&
953 nPropUpper
== rSpaceItem
.nPropUpper
&&
954 nPropLower
== rSpaceItem
.nPropLower
);
959 SfxPoolItem
* SvxULSpaceItem::Clone( SfxItemPool
* ) const
961 return new SvxULSpaceItem( *this );
966 bool SvxULSpaceItem::GetPresentation
968 SfxItemPresentation ePres
,
969 SfxMapUnit eCoreUnit
,
970 SfxMapUnit ePresUnit
,
972 const IntlWrapper
*pIntl
977 case SFX_ITEM_PRESENTATION_NAMELESS
:
979 if ( 100 != nPropUpper
)
981 rText
= unicode::formatPercent(nPropUpper
,
982 Application::GetSettings().GetUILanguageTag());
985 rText
= GetMetricText( (long)nUpper
, eCoreUnit
, ePresUnit
, pIntl
);
986 rText
+= OUString(cpDelim
);
987 if ( 100 != nPropLower
)
989 rText
+= unicode::formatPercent(nPropLower
,
990 Application::GetSettings().GetUILanguageTag());
993 rText
+= GetMetricText( (long)nLower
, eCoreUnit
, ePresUnit
, pIntl
);
996 case SFX_ITEM_PRESENTATION_COMPLETE
:
998 rText
= EE_RESSTR(RID_SVXITEMS_ULSPACE_UPPER
);
999 if ( 100 != nPropUpper
)
1001 rText
+= unicode::formatPercent(nPropUpper
,
1002 Application::GetSettings().GetUILanguageTag());
1007 GetMetricText( (long)nUpper
, eCoreUnit
, ePresUnit
, pIntl
) +
1008 " " + EE_RESSTR(GetMetricId(ePresUnit
));
1010 rText
= rText
+ OUString(cpDelim
) + EE_RESSTR(RID_SVXITEMS_ULSPACE_LOWER
);
1011 if ( 100 != nPropLower
)
1013 rText
+= unicode::formatPercent(nPropLower
,
1014 Application::GetSettings().GetUILanguageTag());
1019 GetMetricText( (long)nLower
, eCoreUnit
, ePresUnit
, pIntl
) +
1020 " " + EE_RESSTR(GetMetricId(ePresUnit
));
1024 default: ;//prevent warning
1031 SvStream
& SvxULSpaceItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1033 rStrm
.WriteUInt16( GetUpper() )
1034 .WriteUInt16( GetPropUpper() )
1035 .WriteUInt16( GetLower() )
1036 .WriteUInt16( GetPropLower() );
1042 SfxPoolItem
* SvxULSpaceItem::Create( SvStream
& rStrm
, sal_uInt16 nVersion
) const
1044 sal_uInt16 upper
, lower
, nPL
= 0, nPU
= 0;
1046 if ( nVersion
== ULSPACE_16_VERSION
)
1047 rStrm
.ReadUInt16( upper
).ReadUInt16( nPU
).ReadUInt16( lower
).ReadUInt16( nPL
);
1051 rStrm
.ReadUInt16( upper
).ReadSChar( nU
).ReadUInt16( lower
).ReadSChar( nL
);
1052 nPL
= (sal_uInt16
)nL
;
1053 nPU
= (sal_uInt16
)nU
;
1056 SvxULSpaceItem
* pAttr
= new SvxULSpaceItem( Which() );
1057 pAttr
->SetUpperValue( upper
);
1058 pAttr
->SetLowerValue( lower
);
1059 pAttr
->SetPropUpper( nPU
);
1060 pAttr
->SetPropLower( nPL
);
1066 sal_uInt16
SvxULSpaceItem::GetVersion( sal_uInt16
/*nFileVersion*/ ) const
1068 return ULSPACE_16_VERSION
;
1073 bool SvxULSpaceItem::ScaleMetrics( long nMult
, long nDiv
)
1075 nUpper
= (sal_uInt16
)Scale( nUpper
, nMult
, nDiv
);
1076 nLower
= (sal_uInt16
)Scale( nLower
, nMult
, nDiv
);
1082 bool SvxULSpaceItem::HasMetrics() const
1087 void SvxULSpaceItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1089 xmlTextWriterStartElement(pWriter
, BAD_CAST("svxULSpaceItem"));
1090 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1091 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nUpper"), BAD_CAST(OString::number(nUpper
).getStr()));
1092 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nLower"), BAD_CAST(OString::number(nLower
).getStr()));
1093 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("bContext"), BAD_CAST(OString::boolean(bContext
).getStr()));
1094 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nPropUpper"), BAD_CAST(OString::number(nPropUpper
).getStr()));
1095 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nPropLower"), BAD_CAST(OString::number(nPropLower
).getStr()));
1096 xmlTextWriterEndElement(pWriter
);
1099 // class SvxPrintItem ----------------------------------------------------
1101 SfxPoolItem
* SvxPrintItem::Clone( SfxItemPool
* ) const
1103 return new SvxPrintItem( *this );
1108 SvStream
& SvxPrintItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1110 rStrm
.WriteSChar( (sal_Int8
)GetValue() );
1116 SfxPoolItem
* SvxPrintItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1119 rStrm
.ReadSChar( bIsPrint
);
1120 return new SvxPrintItem( Which(), bIsPrint
!= 0 );
1125 bool SvxPrintItem::GetPresentation
1127 SfxItemPresentation
/*ePres*/,
1128 SfxMapUnit
/*eCoreUnit*/,
1129 SfxMapUnit
/*ePresUnit*/,
1130 OUString
& rText
, const IntlWrapper
*
1133 sal_uInt16 nId
= RID_SVXITEMS_PRINT_FALSE
;
1136 nId
= RID_SVXITEMS_PRINT_TRUE
;
1137 rText
= EE_RESSTR(nId
);
1141 // class SvxOpaqueItem ---------------------------------------------------
1143 SfxPoolItem
* SvxOpaqueItem::Clone( SfxItemPool
* ) const
1145 return new SvxOpaqueItem( *this );
1150 SvStream
& SvxOpaqueItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1152 rStrm
.WriteSChar( (sal_Int8
)GetValue() );
1158 SfxPoolItem
* SvxOpaqueItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1161 rStrm
.ReadSChar( bIsOpaque
);
1162 return new SvxOpaqueItem( Which(), bIsOpaque
!= 0 );
1167 bool SvxOpaqueItem::GetPresentation
1169 SfxItemPresentation
/*ePres*/,
1170 SfxMapUnit
/*eCoreUnit*/,
1171 SfxMapUnit
/*ePresUnit*/,
1172 OUString
& rText
, const IntlWrapper
*
1175 sal_uInt16 nId
= RID_SVXITEMS_OPAQUE_FALSE
;
1178 nId
= RID_SVXITEMS_OPAQUE_TRUE
;
1179 rText
= EE_RESSTR(nId
);
1183 // class SvxProtectItem --------------------------------------------------
1185 bool SvxProtectItem::operator==( const SfxPoolItem
& rAttr
) const
1187 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1189 const SvxProtectItem
& rItem
= static_cast<const SvxProtectItem
&>(rAttr
);
1190 return ( bCntnt
== rItem
.bCntnt
&&
1191 bSize
== rItem
.bSize
&&
1192 bPos
== rItem
.bPos
);
1195 bool SvxProtectItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1197 nMemberId
&= ~CONVERT_TWIPS
;
1201 case MID_PROTECT_CONTENT
: bValue
= bCntnt
; break;
1202 case MID_PROTECT_SIZE
: bValue
= bSize
; break;
1203 case MID_PROTECT_POSITION
: bValue
= bPos
; break;
1205 OSL_FAIL("Wrong MemberId");
1209 rVal
= Bool2Any( bValue
);
1213 bool SvxProtectItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1215 nMemberId
&= ~CONVERT_TWIPS
;
1216 bool bVal( Any2Bool(rVal
) );
1219 case MID_PROTECT_CONTENT
: bCntnt
= bVal
; break;
1220 case MID_PROTECT_SIZE
: bSize
= bVal
; break;
1221 case MID_PROTECT_POSITION
: bPos
= bVal
; break;
1223 OSL_FAIL("Wrong MemberId");
1231 SfxPoolItem
* SvxProtectItem::Clone( SfxItemPool
* ) const
1233 return new SvxProtectItem( *this );
1238 bool SvxProtectItem::GetPresentation
1240 SfxItemPresentation
/*ePres*/,
1241 SfxMapUnit
/*eCoreUnit*/,
1242 SfxMapUnit
/*ePresUnit*/,
1243 OUString
& rText
, const IntlWrapper
*
1246 sal_uInt16 nId
= RID_SVXITEMS_PROT_CONTENT_FALSE
;
1249 nId
= RID_SVXITEMS_PROT_CONTENT_TRUE
;
1250 rText
= EE_RESSTR(nId
) + OUString(cpDelim
);
1251 nId
= RID_SVXITEMS_PROT_SIZE_FALSE
;
1254 nId
= RID_SVXITEMS_PROT_SIZE_TRUE
;
1255 rText
= rText
+ EE_RESSTR(nId
) + OUString(cpDelim
);
1256 nId
= RID_SVXITEMS_PROT_POS_FALSE
;
1259 nId
= RID_SVXITEMS_PROT_POS_TRUE
;
1260 rText
+= EE_RESSTR(nId
);
1266 SvStream
& SvxProtectItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1269 if( IsPosProtected() ) cProt
|= 0x01;
1270 if( IsSizeProtected() ) cProt
|= 0x02;
1271 if( IsContentProtected() ) cProt
|= 0x04;
1272 rStrm
.WriteSChar( cProt
);
1278 SfxPoolItem
* SvxProtectItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1281 rStrm
.ReadSChar( cFlags
);
1282 SvxProtectItem
* pAttr
= new SvxProtectItem( Which() );
1283 pAttr
->SetPosProtect( ( cFlags
& 0x01 ) != 0 );
1284 pAttr
->SetSizeProtect( ( cFlags
& 0x02 ) != 0 );
1285 pAttr
->SetContentProtect( ( cFlags
& 0x04 ) != 0 );
1289 void SvxProtectItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1291 xmlTextWriterStartElement(pWriter
, BAD_CAST("svxProtectItem"));
1292 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1293 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("content"), BAD_CAST(OString::boolean(bCntnt
).getStr()));
1294 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("size"), BAD_CAST(OString::boolean(bSize
).getStr()));
1295 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("position"), BAD_CAST(OString::boolean(bPos
).getStr()));
1296 xmlTextWriterEndElement(pWriter
);
1299 // class SvxShadowItem ---------------------------------------------------
1301 SvxShadowItem::SvxShadowItem( const sal_uInt16 nId
,
1302 const Color
*pColor
, const sal_uInt16 nW
,
1303 const SvxShadowLocation eLoc
) :
1304 SfxEnumItemInterface( nId
),
1305 aShadowColor(COL_GRAY
),
1310 aShadowColor
= *pColor
;
1314 bool SvxShadowItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1316 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1317 nMemberId
&= ~CONVERT_TWIPS
;
1319 table::ShadowFormat aShadow
;
1320 table::ShadowLocation eSet
= table::ShadowLocation_NONE
;
1323 case SVX_SHADOW_TOPLEFT
: eSet
= table::ShadowLocation_TOP_LEFT
; break;
1324 case SVX_SHADOW_TOPRIGHT
: eSet
= table::ShadowLocation_TOP_RIGHT
; break;
1325 case SVX_SHADOW_BOTTOMLEFT
: eSet
= table::ShadowLocation_BOTTOM_LEFT
; break;
1326 case SVX_SHADOW_BOTTOMRIGHT
: eSet
= table::ShadowLocation_BOTTOM_RIGHT
; break;
1327 default: ;//prevent warning
1329 aShadow
.Location
= eSet
;
1330 aShadow
.ShadowWidth
= bConvert
? convertTwipToMm100(nWidth
) : nWidth
;
1331 aShadow
.IsTransparent
= aShadowColor
.GetTransparency() > 0;
1332 aShadow
.Color
= aShadowColor
.GetColor();
1334 sal_Int8 nTransparence
= rtl::math::round(float(aShadowColor
.GetTransparency() * 100) / 255);
1336 switch ( nMemberId
)
1338 case MID_LOCATION
: rVal
<<= aShadow
.Location
; break;
1339 case MID_WIDTH
: rVal
<<= aShadow
.ShadowWidth
; break;
1340 case MID_TRANSPARENT
: rVal
<<= aShadow
.IsTransparent
; break;
1341 case MID_BG_COLOR
: rVal
<<= aShadow
.Color
; break;
1342 case 0: rVal
<<= aShadow
; break;
1343 case MID_SHADOW_TRANSPARENCE
: rVal
<<= nTransparence
; break;
1344 default: OSL_FAIL("Wrong MemberId!"); return false;
1350 bool SvxShadowItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1352 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1353 nMemberId
&= ~CONVERT_TWIPS
;
1355 table::ShadowFormat aShadow
;
1357 bool bRet
= QueryValue( aAny
, bConvert
? CONVERT_TWIPS
: 0 ) && ( aAny
>>= aShadow
);
1358 switch ( nMemberId
)
1362 bRet
= (rVal
>>= aShadow
.Location
);
1366 bRet
= (rVal
>>= nVal
);
1367 aShadow
.Location
= (table::ShadowLocation
) nVal
;
1373 case MID_WIDTH
: rVal
>>= aShadow
.ShadowWidth
; break;
1374 case MID_TRANSPARENT
: rVal
>>= aShadow
.IsTransparent
; break;
1375 case MID_BG_COLOR
: rVal
>>= aShadow
.Color
; break;
1376 case 0: rVal
>>= aShadow
; break;
1377 case MID_SHADOW_TRANSPARENCE
:
1379 sal_Int32 nTransparence
= 0;
1380 if (rVal
>>= nTransparence
)
1382 Color
aColor(aShadow
.Color
);
1383 aColor
.SetTransparency(rtl::math::round(float(nTransparence
* 255) / 100));
1384 aShadow
.Color
= aColor
.GetColor();
1388 default: OSL_FAIL("Wrong MemberId!"); return false;
1393 // SvxShadowLocation eSet = SVX_SHADOW_NONE;
1394 switch( aShadow
.Location
)
1396 case table::ShadowLocation_TOP_LEFT
: eLocation
= SVX_SHADOW_TOPLEFT
; break;
1397 case table::ShadowLocation_TOP_RIGHT
: eLocation
= SVX_SHADOW_TOPRIGHT
; break;
1398 case table::ShadowLocation_BOTTOM_LEFT
: eLocation
= SVX_SHADOW_BOTTOMLEFT
; break;
1399 case table::ShadowLocation_BOTTOM_RIGHT
: eLocation
= SVX_SHADOW_BOTTOMRIGHT
; break;
1400 default: ;//prevent warning
1403 nWidth
= bConvert
? convertMm100ToTwip(aShadow
.ShadowWidth
) : aShadow
.ShadowWidth
;
1404 Color
aSet(aShadow
.Color
);
1405 aShadowColor
= aSet
;
1413 bool SvxShadowItem::operator==( const SfxPoolItem
& rAttr
) const
1415 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1417 const SvxShadowItem
& rItem
= static_cast<const SvxShadowItem
&>(rAttr
);
1418 return ( ( aShadowColor
== rItem
.aShadowColor
) &&
1419 ( nWidth
== rItem
.GetWidth() ) &&
1420 ( eLocation
== rItem
.GetLocation() ) );
1425 SfxPoolItem
* SvxShadowItem::Clone( SfxItemPool
* ) const
1427 return new SvxShadowItem( *this );
1432 sal_uInt16
SvxShadowItem::CalcShadowSpace( SvxShadowItemSide nShadow
) const
1434 sal_uInt16 nSpace
= 0;
1438 case SvxShadowItemSide::TOP
:
1439 if ( eLocation
== SVX_SHADOW_TOPLEFT
||
1440 eLocation
== SVX_SHADOW_TOPRIGHT
)
1444 case SvxShadowItemSide::BOTTOM
:
1445 if ( eLocation
== SVX_SHADOW_BOTTOMLEFT
||
1446 eLocation
== SVX_SHADOW_BOTTOMRIGHT
)
1450 case SvxShadowItemSide::LEFT
:
1451 if ( eLocation
== SVX_SHADOW_TOPLEFT
||
1452 eLocation
== SVX_SHADOW_BOTTOMLEFT
)
1456 case SvxShadowItemSide::RIGHT
:
1457 if ( eLocation
== SVX_SHADOW_TOPRIGHT
||
1458 eLocation
== SVX_SHADOW_BOTTOMRIGHT
)
1463 OSL_FAIL( "wrong shadow" );
1470 bool SvxShadowItem::GetPresentation
1472 SfxItemPresentation ePres
,
1473 SfxMapUnit eCoreUnit
,
1474 SfxMapUnit ePresUnit
,
1475 OUString
& rText
, const IntlWrapper
*pIntl
1480 case SFX_ITEM_PRESENTATION_NAMELESS
:
1482 rText
= ::GetColorString( aShadowColor
) + OUString(cpDelim
);
1483 sal_uInt16 nId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
1485 if ( aShadowColor
.GetTransparency() )
1486 nId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
1490 GetMetricText( (long)nWidth
, eCoreUnit
, ePresUnit
, pIntl
) +
1492 EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN
+ eLocation
);
1495 case SFX_ITEM_PRESENTATION_COMPLETE
:
1497 rText
= EE_RESSTR(RID_SVXITEMS_SHADOW_COMPLETE
) +
1498 ::GetColorString( aShadowColor
) +
1501 sal_uInt16 nId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
1502 if ( aShadowColor
.GetTransparency() )
1503 nId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
1507 GetMetricText( (long)nWidth
, eCoreUnit
, ePresUnit
, pIntl
) +
1508 " " + EE_RESSTR(GetMetricId(ePresUnit
)) +
1510 EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN
+ eLocation
);
1513 default: ;//prevent warning
1520 SvStream
& SvxShadowItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1522 rStrm
.WriteSChar( GetLocation() )
1523 .WriteUInt16( GetWidth() )
1524 .WriteBool( aShadowColor
.GetTransparency() > 0 );
1525 WriteColor( rStrm
, GetColor() );
1526 WriteColor( rStrm
, GetColor() );
1527 rStrm
.WriteSChar( aShadowColor
.GetTransparency() > 0 ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID
1533 bool SvxShadowItem::ScaleMetrics( long nMult
, long nDiv
)
1535 nWidth
= (sal_uInt16
)Scale( nWidth
, nMult
, nDiv
);
1541 bool SvxShadowItem::HasMetrics() const
1548 SfxPoolItem
* SvxShadowItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1556 rStrm
.ReadSChar( cLoc
).ReadUInt16( _nWidth
)
1557 .ReadCharAsBool( bTrans
);
1558 ReadColor( rStrm
, aColor
);
1559 ReadColor( rStrm
, aFillColor
).ReadSChar( nStyle
);
1560 aColor
.SetTransparency(bTrans
? 0xff : 0);
1561 return new SvxShadowItem( Which(), &aColor
, _nWidth
, (SvxShadowLocation
)cLoc
);
1566 sal_uInt16
SvxShadowItem::GetValueCount() const
1568 return SVX_SHADOW_END
; // SVX_SHADOW_BOTTOMRIGHT + 1
1573 OUString
SvxShadowItem::GetValueTextByPos( sal_uInt16 nPos
) const
1575 DBG_ASSERT( nPos
< SVX_SHADOW_END
, "enum overflow!" );
1576 return EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN
+ nPos
);
1581 sal_uInt16
SvxShadowItem::GetEnumValue() const
1583 return (sal_uInt16
)GetLocation();
1588 void SvxShadowItem::SetEnumValue( sal_uInt16 nVal
)
1590 SetLocation( (const SvxShadowLocation
)nVal
);
1593 void SvxShadowItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
1595 xmlTextWriterStartElement(pWriter
, BAD_CAST("svxShadowItem"));
1596 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
1597 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("aShadowColor"), BAD_CAST(aShadowColor
.AsRGBHexString().toUtf8().getStr()));
1598 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("nWidth"), BAD_CAST(OString::number(nWidth
).getStr()));
1599 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("eLocation"), BAD_CAST(OString::number(eLocation
).getStr()));
1600 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("presentation"), BAD_CAST(EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN
+ eLocation
).toUtf8().getStr()));
1601 xmlTextWriterEndElement(pWriter
);
1604 // class SvxBoxItem ------------------------------------------------------
1606 SvxBoxItem::SvxBoxItem( const SvxBoxItem
& rCpy
) :
1608 SfxPoolItem ( rCpy
),
1609 nTopDist ( rCpy
.nTopDist
),
1610 nBottomDist ( rCpy
.nBottomDist
),
1611 nLeftDist ( rCpy
.nLeftDist
),
1612 nRightDist ( rCpy
.nRightDist
)
1615 pTop
= rCpy
.GetTop() ? new SvxBorderLine( *rCpy
.GetTop() ) : 0;
1616 pBottom
= rCpy
.GetBottom() ? new SvxBorderLine( *rCpy
.GetBottom() ) : 0;
1617 pLeft
= rCpy
.GetLeft() ? new SvxBorderLine( *rCpy
.GetLeft() ) : 0;
1618 pRight
= rCpy
.GetRight() ? new SvxBorderLine( *rCpy
.GetRight() ) : 0;
1623 SvxBoxItem::SvxBoxItem( const sal_uInt16 nId
) :
1640 SvxBoxItem::~SvxBoxItem()
1650 SvxBoxItem
& SvxBoxItem::operator=( const SvxBoxItem
& rBox
)
1652 nTopDist
= rBox
.nTopDist
;
1653 nBottomDist
= rBox
.nBottomDist
;
1654 nLeftDist
= rBox
.nLeftDist
;
1655 nRightDist
= rBox
.nRightDist
;
1656 SetLine( rBox
.GetTop(), SvxBoxItemLine::TOP
);
1657 SetLine( rBox
.GetBottom(), SvxBoxItemLine::BOTTOM
);
1658 SetLine( rBox
.GetLeft(), SvxBoxItemLine::LEFT
);
1659 SetLine( rBox
.GetRight(), SvxBoxItemLine::RIGHT
);
1665 inline bool CmpBrdLn( const SvxBorderLine
* pBrd1
, const SvxBorderLine
* pBrd2
)
1668 if( 0 != pBrd1
? 0 == pBrd2
: 0 != pBrd2
)
1674 bRet
= (*pBrd1
== *pBrd2
);
1680 bool SvxBoxItem::operator==( const SfxPoolItem
& rAttr
) const
1682 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1684 const SvxBoxItem
& rBoxItem
= static_cast<const SvxBoxItem
&>(rAttr
);
1686 ( nTopDist
== rBoxItem
.nTopDist
) &&
1687 ( nBottomDist
== rBoxItem
.nBottomDist
) &&
1688 ( nLeftDist
== rBoxItem
.nLeftDist
) &&
1689 ( nRightDist
== rBoxItem
.nRightDist
) &&
1690 CmpBrdLn( pTop
, rBoxItem
.GetTop() ) &&
1691 CmpBrdLn( pBottom
, rBoxItem
.GetBottom() ) &&
1692 CmpBrdLn( pLeft
, rBoxItem
.GetLeft() ) &&
1693 CmpBrdLn( pRight
, rBoxItem
.GetRight() ) );
1697 table::BorderLine2
SvxBoxItem::SvxLineToLine(const SvxBorderLine
* pLine
, bool bConvert
)
1699 table::BorderLine2 aLine
;
1702 aLine
.Color
= pLine
->GetColor().GetColor() ;
1703 aLine
.InnerLineWidth
= sal_uInt16( bConvert
? convertTwipToMm100(pLine
->GetInWidth() ): pLine
->GetInWidth() );
1704 aLine
.OuterLineWidth
= sal_uInt16( bConvert
? convertTwipToMm100(pLine
->GetOutWidth()): pLine
->GetOutWidth() );
1705 aLine
.LineDistance
= sal_uInt16( bConvert
? convertTwipToMm100(pLine
->GetDistance()): pLine
->GetDistance() );
1706 aLine
.LineStyle
= pLine
->GetBorderLineStyle();
1707 aLine
.LineWidth
= sal_uInt32( bConvert
? convertTwipToMm100( pLine
->GetWidth( ) ) : pLine
->GetWidth( ) );
1710 aLine
.Color
= aLine
.InnerLineWidth
= aLine
.OuterLineWidth
= aLine
.LineDistance
= 0;
1714 bool SvxBoxItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1716 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1717 table::BorderLine2 aRetLine
;
1718 sal_uInt16 nDist
= 0;
1719 bool bDistMember
= false;
1720 nMemberId
&= ~CONVERT_TWIPS
;
1725 // 4 Borders and 5 distances
1726 uno::Sequence
< uno::Any
> aSeq( 9 );
1727 aSeq
[0] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetLeft(), bConvert
) );
1728 aSeq
[1] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetRight(), bConvert
) );
1729 aSeq
[2] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetBottom(), bConvert
) );
1730 aSeq
[3] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetTop(), bConvert
) );
1731 aSeq
[4] <<= uno::makeAny( (sal_Int32
)(bConvert
? convertTwipToMm100( GetDistance()) : GetDistance()));
1732 aSeq
[5] <<= uno::makeAny( (sal_Int32
)(bConvert
? convertTwipToMm100( nTopDist
) : nTopDist
));
1733 aSeq
[6] <<= uno::makeAny( (sal_Int32
)(bConvert
? convertTwipToMm100( nBottomDist
) : nBottomDist
));
1734 aSeq
[7] <<= uno::makeAny( (sal_Int32
)(bConvert
? convertTwipToMm100( nLeftDist
) : nLeftDist
));
1735 aSeq
[8] <<= uno::makeAny( (sal_Int32
)(bConvert
? convertTwipToMm100( nRightDist
) : nRightDist
));
1736 rVal
= uno::makeAny( aSeq
);
1739 case MID_LEFT_BORDER
:
1741 aRetLine
= SvxBoxItem::SvxLineToLine(GetLeft(), bConvert
);
1743 case MID_RIGHT_BORDER
:
1745 aRetLine
= SvxBoxItem::SvxLineToLine(GetRight(), bConvert
);
1747 case MID_BOTTOM_BORDER
:
1749 aRetLine
= SvxBoxItem::SvxLineToLine(GetBottom(), bConvert
);
1751 case MID_TOP_BORDER
:
1753 aRetLine
= SvxBoxItem::SvxLineToLine(GetTop(), bConvert
);
1755 case BORDER_DISTANCE
:
1756 nDist
= GetDistance();
1759 case TOP_BORDER_DISTANCE
:
1763 case BOTTOM_BORDER_DISTANCE
:
1764 nDist
= nBottomDist
;
1767 case LEFT_BORDER_DISTANCE
:
1771 case RIGHT_BORDER_DISTANCE
:
1777 // it doesn't make sense to return a value for these since it's
1778 // probably ambiguous
1784 rVal
<<= (sal_Int32
)(bConvert
? convertTwipToMm100(nDist
) : nDist
);
1795 lcl_lineToSvxLine(const table::BorderLine
& rLine
, SvxBorderLine
& rSvxLine
, bool bConvert
, bool bGuessWidth
)
1797 rSvxLine
.SetColor( Color(rLine
.Color
));
1800 rSvxLine
.GuessLinesWidths( rSvxLine
.GetBorderLineStyle(),
1801 sal_uInt16( bConvert
? convertMm100ToTwip(rLine
.OuterLineWidth
) : rLine
.OuterLineWidth
),
1802 sal_uInt16( bConvert
? convertMm100ToTwip(rLine
.InnerLineWidth
) : rLine
.InnerLineWidth
),
1803 sal_uInt16( bConvert
? convertMm100ToTwip(rLine
.LineDistance
) : rLine
.LineDistance
));
1806 bool bRet
= !rSvxLine
.isEmpty();
1813 bool SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine
& rLine
, SvxBorderLine
& rSvxLine
, bool bConvert
)
1815 return lcl_lineToSvxLine(rLine
, rSvxLine
, bConvert
, true);
1819 SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine2
& rLine
, SvxBorderLine
& rSvxLine
, bool bConvert
)
1821 SvxBorderStyle
const nStyle
=
1822 (rLine
.LineStyle
< 0 || BORDER_LINE_STYLE_MAX
< rLine
.LineStyle
)
1826 rSvxLine
.SetBorderLineStyle( nStyle
);
1828 bool bGuessWidth
= true;
1829 if ( rLine
.LineWidth
)
1831 rSvxLine
.SetWidth( bConvert
? convertMm100ToTwip( rLine
.LineWidth
) : rLine
.LineWidth
);
1832 // fdo#46112: double does not necessarily mean symmetric
1833 // for backwards compatibility
1834 bGuessWidth
= ((DOUBLE
== nStyle
|| DOUBLE_THIN
== nStyle
)) &&
1835 (rLine
.InnerLineWidth
> 0) && (rLine
.OuterLineWidth
> 0);
1838 return lcl_lineToSvxLine(rLine
, rSvxLine
, bConvert
, bGuessWidth
);
1847 lcl_extractBorderLine(const uno::Any
& rAny
, table::BorderLine2
& rLine
)
1852 table::BorderLine aBorderLine
;
1853 if (rAny
>>= aBorderLine
)
1855 rLine
.Color
= aBorderLine
.Color
;
1856 rLine
.InnerLineWidth
= aBorderLine
.InnerLineWidth
;
1857 rLine
.OuterLineWidth
= aBorderLine
.OuterLineWidth
;
1858 rLine
.LineDistance
= aBorderLine
.LineDistance
;
1859 rLine
.LineStyle
= table::BorderLineStyle::SOLID
;
1866 template<typename Item
, typename Line
>
1868 lcl_setLine(const uno::Any
& rAny
, Item
& rItem
, Line nLine
, const bool bConvert
)
1871 table::BorderLine2 aBorderLine
;
1872 if (lcl_extractBorderLine(rAny
, aBorderLine
))
1874 SvxBorderLine aLine
;
1875 bool bSet
= SvxBoxItem::LineToSvxLine(aBorderLine
, aLine
, bConvert
);
1876 rItem
.SetLine( bSet
? &aLine
: NULL
, nLine
);
1884 bool SvxBoxItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1886 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1887 SvxBoxItemLine nLine
= SvxBoxItemLine::TOP
;
1888 bool bDistMember
= false;
1889 nMemberId
&= ~CONVERT_TWIPS
;
1894 uno::Sequence
< uno::Any
> aSeq
;
1895 if (( rVal
>>= aSeq
) && ( aSeq
.getLength() == 9 ))
1897 // 4 Borders and 5 distances
1898 const SvxBoxItemLine aBorders
[] = { SvxBoxItemLine::LEFT
, SvxBoxItemLine::RIGHT
, SvxBoxItemLine::BOTTOM
, SvxBoxItemLine::TOP
};
1899 for (int n(0); n
!= SAL_N_ELEMENTS(aBorders
); ++n
)
1901 if (!lcl_setLine(aSeq
[n
], *this, aBorders
[n
], bConvert
))
1905 // WTH are the borders and the distances saved in different order?
1906 SvxBoxItemLine nLines
[4] = { SvxBoxItemLine::TOP
, SvxBoxItemLine::BOTTOM
, SvxBoxItemLine::LEFT
, SvxBoxItemLine::RIGHT
};
1907 for ( sal_Int32 n
= 4; n
< 9; n
++ )
1909 sal_Int32 nDist
= 0;
1910 if ( aSeq
[n
] >>= nDist
)
1913 nDist
= convertMm100ToTwip(nDist
);
1915 SetDistance( sal_uInt16( nDist
));
1917 SetDistance( sal_uInt16( nDist
), nLines
[n
-5] );
1928 case LEFT_BORDER_DISTANCE
:
1932 case MID_LEFT_BORDER
:
1933 nLine
= SvxBoxItemLine::LEFT
;
1935 case RIGHT_BORDER_DISTANCE
:
1939 case MID_RIGHT_BORDER
:
1940 nLine
= SvxBoxItemLine::RIGHT
;
1942 case BOTTOM_BORDER_DISTANCE
:
1946 case MID_BOTTOM_BORDER
:
1947 nLine
= SvxBoxItemLine::BOTTOM
;
1949 case TOP_BORDER_DISTANCE
:
1953 case MID_TOP_BORDER
:
1954 nLine
= SvxBoxItemLine::TOP
;
1958 drawing::LineStyle eDrawingStyle
;
1959 rVal
>>= eDrawingStyle
;
1960 editeng::SvxBorderStyle eBorderStyle
= css::table::BorderLineStyle::NONE
;
1961 switch ( eDrawingStyle
)
1964 case drawing::LineStyle_NONE
:
1966 case drawing::LineStyle_SOLID
:
1967 eBorderStyle
= SOLID
;
1969 case drawing::LineStyle_DASH
:
1970 eBorderStyle
= DASHED
;
1974 // Set the line style on all borders
1975 for( SvxBoxItemLine n
: o3tl::enumrange
<SvxBoxItemLine
>() )
1977 editeng::SvxBorderLine
* pLine
= const_cast< editeng::SvxBorderLine
* >( GetLine( n
) );
1979 pLine
->SetBorderLineStyle( eBorderStyle
);
1986 // Set the line width on all borders
1990 nWidth
= convertMm100ToTwip( nWidth
);
1992 // Set the line Width on all borders
1993 for( SvxBoxItemLine n
: o3tl::enumrange
<SvxBoxItemLine
>() )
1995 editeng::SvxBorderLine
* pLine
= const_cast< editeng::SvxBorderLine
* >( GetLine( n
) );
1997 pLine
->SetWidth( nWidth
);
2003 if( bDistMember
|| nMemberId
== BORDER_DISTANCE
)
2005 sal_Int32 nDist
= 0;
2006 if(!(rVal
>>= nDist
))
2012 nDist
= convertMm100ToTwip(nDist
);
2013 if( nMemberId
== BORDER_DISTANCE
)
2014 SetDistance( sal_uInt16( nDist
));
2016 SetDistance( sal_uInt16( nDist
), nLine
);
2021 SvxBorderLine aLine
;
2022 if( !rVal
.hasValue() )
2025 table::BorderLine2 aBorderLine
;
2026 if( lcl_extractBorderLine(rVal
, aBorderLine
) )
2030 else if (rVal
.getValueTypeClass() == uno::TypeClass_SEQUENCE
)
2032 // serialization for basic macro recording
2033 uno::Reference
< script::XTypeConverter
> xConverter
2034 ( script::Converter::create(::comphelper::getProcessComponentContext()) );
2035 uno::Sequence
< uno::Any
> aSeq
;
2037 try { aNew
= xConverter
->convertTo( rVal
, cppu::UnoType
<uno::Sequence
< uno::Any
>>::get() ); }
2038 catch (const uno::Exception
&) {}
2041 if (aSeq
.getLength() >= 4 && aSeq
.getLength() <= 6)
2044 if ( aSeq
[0] >>= nVal
)
2045 aBorderLine
.Color
= nVal
;
2046 if ( aSeq
[1] >>= nVal
)
2047 aBorderLine
.InnerLineWidth
= (sal_Int16
) nVal
;
2048 if ( aSeq
[2] >>= nVal
)
2049 aBorderLine
.OuterLineWidth
= (sal_Int16
) nVal
;
2050 if ( aSeq
[3] >>= nVal
)
2051 aBorderLine
.LineDistance
= (sal_Int16
) nVal
;
2052 if (aSeq
.getLength() >= 5) // fdo#40874 added fields
2054 if (aSeq
[4] >>= nVal
)
2056 aBorderLine
.LineStyle
= nVal
;
2058 if (aSeq
.getLength() >= 6)
2060 if (aSeq
[5] >>= nVal
)
2062 aBorderLine
.LineWidth
= nVal
;
2073 bool bSet
= SvxBoxItem::LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2074 SetLine(bSet
? &aLine
: 0, nLine
);
2082 SfxPoolItem
* SvxBoxItem::Clone( SfxItemPool
* ) const
2084 return new SvxBoxItem( *this );
2089 bool SvxBoxItem::GetPresentation
2091 SfxItemPresentation ePres
,
2092 SfxMapUnit eCoreUnit
,
2093 SfxMapUnit ePresUnit
,
2094 OUString
& rText
, const IntlWrapper
*pIntl
2097 OUString cpDelimTmp
= OUString(cpDelim
);
2100 case SFX_ITEM_PRESENTATION_NAMELESS
:
2106 rText
= pTop
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
) + cpDelimTmp
;
2108 if( !(pTop
&& pBottom
&& pLeft
&& pRight
&&
2109 *pTop
== *pBottom
&& *pTop
== *pLeft
&& *pTop
== *pRight
) )
2113 rText
= rText
+ pBottom
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
) + cpDelimTmp
;
2117 rText
= rText
+ pLeft
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
) + cpDelimTmp
;
2121 rText
= rText
+ pRight
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
) + cpDelimTmp
;
2124 rText
+= GetMetricText( (long)nTopDist
, eCoreUnit
, ePresUnit
, pIntl
);
2125 if( nTopDist
!= nBottomDist
|| nTopDist
!= nLeftDist
||
2126 nTopDist
!= nRightDist
)
2130 GetMetricText( (long)nBottomDist
, eCoreUnit
,
2131 ePresUnit
, pIntl
) +
2133 GetMetricText( (long)nLeftDist
, eCoreUnit
, ePresUnit
, pIntl
) +
2135 GetMetricText( (long)nRightDist
, eCoreUnit
,
2140 case SFX_ITEM_PRESENTATION_COMPLETE
:
2142 if( !(pTop
|| pBottom
|| pLeft
|| pRight
) )
2144 rText
= EE_RESSTR(RID_SVXITEMS_BORDER_NONE
) + cpDelimTmp
;
2148 rText
= EE_RESSTR(RID_SVXITEMS_BORDER_COMPLETE
);
2149 if( pTop
&& pBottom
&& pLeft
&& pRight
&&
2150 *pTop
== *pBottom
&& *pTop
== *pLeft
&& *pTop
== *pRight
)
2152 rText
+= pTop
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, true ) + cpDelimTmp
;
2159 EE_RESSTR(RID_SVXITEMS_BORDER_TOP
) +
2160 pTop
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, true ) +
2166 EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM
) +
2167 pBottom
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, true ) +
2173 EE_RESSTR(RID_SVXITEMS_BORDER_LEFT
) +
2174 pLeft
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, true ) +
2180 EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT
) +
2181 pRight
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, true ) +
2187 rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_DISTANCE
);
2188 if( nTopDist
== nBottomDist
&& nTopDist
== nLeftDist
&&
2189 nTopDist
== nRightDist
)
2192 GetMetricText( (long)nTopDist
, eCoreUnit
,
2193 ePresUnit
, pIntl
) +
2194 " " + EE_RESSTR(GetMetricId(ePresUnit
));
2199 EE_RESSTR(RID_SVXITEMS_BORDER_TOP
) +
2200 GetMetricText( (long)nTopDist
, eCoreUnit
,
2201 ePresUnit
, pIntl
) +
2202 " " + EE_RESSTR(GetMetricId(ePresUnit
)) +
2204 EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM
) +
2205 GetMetricText( (long)nBottomDist
, eCoreUnit
,
2206 ePresUnit
, pIntl
) +
2207 " " + EE_RESSTR(GetMetricId(ePresUnit
)) +
2209 EE_RESSTR(RID_SVXITEMS_BORDER_LEFT
) +
2210 GetMetricText( (long)nLeftDist
, eCoreUnit
,
2211 ePresUnit
, pIntl
) +
2212 " " + EE_RESSTR(GetMetricId(ePresUnit
)) +
2214 EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT
) +
2215 GetMetricText( (long)nRightDist
, eCoreUnit
,
2216 ePresUnit
, pIntl
) +
2217 " " + EE_RESSTR(GetMetricId(ePresUnit
));
2221 default: ;//prevent warning
2228 SvStream
& SvxBoxItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
2230 rStrm
.WriteUInt16( GetDistance() );
2231 const SvxBorderLine
* pLine
[ 4 ]; // top, left, right, bottom
2232 pLine
[ 0 ] = GetTop();
2233 pLine
[ 1 ] = GetLeft();
2234 pLine
[ 2 ] = GetRight();
2235 pLine
[ 3 ] = GetBottom();
2237 for( int i
= 0; i
< 4; i
++ )
2239 const SvxBorderLine
* l
= pLine
[ i
];
2242 rStrm
.WriteSChar(i
);
2243 StoreBorderLine(rStrm
, *l
, BorderLineVersionFromBoxVersion(nItemVersion
));
2247 if( nItemVersion
>= BOX_4DISTS_VERSION
&&
2248 !(nTopDist
== nLeftDist
&&
2249 nTopDist
== nRightDist
&&
2250 nTopDist
== nBottomDist
) )
2255 rStrm
.WriteSChar( cLine
);
2257 if( nItemVersion
>= BOX_4DISTS_VERSION
&& (cLine
& 0x10) != 0 )
2259 rStrm
.WriteUInt16( nTopDist
)
2260 .WriteUInt16( nLeftDist
)
2261 .WriteUInt16( nRightDist
)
2262 .WriteUInt16( nBottomDist
);
2270 sal_uInt16
SvxBoxItem::GetVersion( sal_uInt16 nFFVer
) const
2272 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
2273 SOFFICE_FILEFORMAT_40
==nFFVer
||
2274 SOFFICE_FILEFORMAT_50
==nFFVer
,
2275 "SvxBoxItem: Gibt es ein neues Fileformat?" );
2276 return SOFFICE_FILEFORMAT_31
==nFFVer
||
2277 SOFFICE_FILEFORMAT_40
==nFFVer
? 0 : BOX_BORDER_STYLE_VERSION
;
2282 bool SvxBoxItem::ScaleMetrics( long nMult
, long nDiv
)
2284 if ( pTop
) pTop
->ScaleMetrics( nMult
, nDiv
);
2285 if ( pBottom
) pBottom
->ScaleMetrics( nMult
, nDiv
);
2286 if ( pLeft
) pLeft
->ScaleMetrics( nMult
, nDiv
);
2287 if ( pRight
) pRight
->ScaleMetrics( nMult
, nDiv
);
2288 nTopDist
= (sal_uInt16
)Scale( nTopDist
, nMult
, nDiv
);
2289 nBottomDist
= (sal_uInt16
)Scale( nBottomDist
, nMult
, nDiv
);
2290 nLeftDist
= (sal_uInt16
)Scale( nLeftDist
, nMult
, nDiv
);
2291 nRightDist
= (sal_uInt16
)Scale( nRightDist
, nMult
, nDiv
);
2297 bool SvxBoxItem::HasMetrics() const
2304 SfxPoolItem
* SvxBoxItem::Create( SvStream
& rStrm
, sal_uInt16 nIVersion
) const
2306 sal_uInt16 nDistance
;
2307 rStrm
.ReadUInt16( nDistance
);
2308 SvxBoxItem
* pAttr
= new SvxBoxItem( Which() );
2310 SvxBoxItemLine aLineMap
[4] = { SvxBoxItemLine::TOP
, SvxBoxItemLine::LEFT
,
2311 SvxBoxItemLine::RIGHT
, SvxBoxItemLine::BOTTOM
};
2316 rStrm
.ReadSChar( cLine
);
2321 SvxBorderLine aBorder
= CreateBorderLine(rStrm
, BorderLineVersionFromBoxVersion(nIVersion
));
2322 pAttr
->SetLine( &aBorder
, aLineMap
[cLine
] );
2325 if( nIVersion
>= BOX_4DISTS_VERSION
&& (cLine
&0x10) != 0 )
2327 for( sal_uInt16 i
=0; i
< 4; i
++ )
2330 rStrm
.ReadUInt16( nDist
);
2331 pAttr
->SetDistance( nDist
, aLineMap
[i
] );
2336 pAttr
->SetDistance( nDistance
);
2344 const SvxBorderLine
*SvxBoxItem::GetLine( SvxBoxItemLine nLine
) const
2346 const SvxBorderLine
*pRet
= 0;
2350 case SvxBoxItemLine::TOP
:
2353 case SvxBoxItemLine::BOTTOM
:
2356 case SvxBoxItemLine::LEFT
:
2359 case SvxBoxItemLine::RIGHT
:
2363 OSL_FAIL( "wrong line" );
2372 void SvxBoxItem::SetLine( const SvxBorderLine
* pNew
, SvxBoxItemLine nLine
)
2374 SvxBorderLine
* pTmp
= pNew
? new SvxBorderLine( *pNew
) : 0;
2378 case SvxBoxItemLine::TOP
:
2382 case SvxBoxItemLine::BOTTOM
:
2386 case SvxBoxItemLine::LEFT
:
2390 case SvxBoxItemLine::RIGHT
:
2396 OSL_FAIL( "wrong line" );
2402 sal_uInt16
SvxBoxItem::GetDistance() const
2404 // The smallest distance that is not 0 will be returned.
2405 sal_uInt16 nDist
= nTopDist
;
2406 if( nBottomDist
&& (!nDist
|| nBottomDist
< nDist
) )
2407 nDist
= nBottomDist
;
2408 if( nLeftDist
&& (!nDist
|| nLeftDist
< nDist
) )
2410 if( nRightDist
&& (!nDist
|| nRightDist
< nDist
) )
2418 sal_uInt16
SvxBoxItem::GetDistance( SvxBoxItemLine nLine
) const
2420 sal_uInt16 nDist
= 0;
2423 case SvxBoxItemLine::TOP
:
2426 case SvxBoxItemLine::BOTTOM
:
2427 nDist
= nBottomDist
;
2429 case SvxBoxItemLine::LEFT
:
2432 case SvxBoxItemLine::RIGHT
:
2436 OSL_FAIL( "wrong line" );
2444 void SvxBoxItem::SetDistance( sal_uInt16 nNew
, SvxBoxItemLine nLine
)
2448 case SvxBoxItemLine::TOP
:
2451 case SvxBoxItemLine::BOTTOM
:
2454 case SvxBoxItemLine::LEFT
:
2457 case SvxBoxItemLine::RIGHT
:
2461 OSL_FAIL( "wrong line" );
2467 sal_uInt16
SvxBoxItem::CalcLineSpace( SvxBoxItemLine nLine
, bool bIgnoreLine
) const
2469 SvxBorderLine
* pTmp
= 0;
2470 sal_uInt16 nDist
= 0;
2473 case SvxBoxItemLine::TOP
:
2477 case SvxBoxItemLine::BOTTOM
:
2479 nDist
= nBottomDist
;
2481 case SvxBoxItemLine::LEFT
:
2485 case SvxBoxItemLine::RIGHT
:
2490 OSL_FAIL( "wrong line" );
2495 nDist
= nDist
+ pTmp
->GetScaledWidth();
2497 else if( !bIgnoreLine
)
2502 // class SvxBoxInfoItem --------------------------------------------------
2504 SvxBoxInfoItem::SvxBoxInfoItem( const sal_uInt16 nId
) :
2508 mbEnableHor( false ),
2509 mbEnableVer( false ),
2512 bDist
= bMinDist
= false;
2518 SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem
& rCpy
) :
2519 SfxPoolItem( rCpy
),
2520 mbEnableHor( rCpy
.mbEnableHor
),
2521 mbEnableVer( rCpy
.mbEnableVer
)
2523 pHori
= rCpy
.GetHori() ? new SvxBorderLine( *rCpy
.GetHori() ) : 0;
2524 pVert
= rCpy
.GetVert() ? new SvxBorderLine( *rCpy
.GetVert() ) : 0;
2525 bDist
= rCpy
.IsDist();
2526 bMinDist
= rCpy
.IsMinDist();
2527 nValidFlags
= rCpy
.nValidFlags
;
2528 nDefDist
= rCpy
.GetDefDist();
2533 SvxBoxInfoItem::~SvxBoxInfoItem()
2541 SvxBoxInfoItem
&SvxBoxInfoItem::operator=( const SvxBoxInfoItem
& rCpy
)
2545 pHori
= rCpy
.GetHori() ? new SvxBorderLine( *rCpy
.GetHori() ) : 0;
2546 pVert
= rCpy
.GetVert() ? new SvxBorderLine( *rCpy
.GetVert() ) : 0;
2547 mbEnableHor
= rCpy
.mbEnableHor
;
2548 mbEnableVer
= rCpy
.mbEnableVer
;
2549 bDist
= rCpy
.IsDist();
2550 bMinDist
= rCpy
.IsMinDist();
2551 nValidFlags
= rCpy
.nValidFlags
;
2552 nDefDist
= rCpy
.GetDefDist();
2558 bool SvxBoxInfoItem::operator==( const SfxPoolItem
& rAttr
) const
2560 const SvxBoxInfoItem
& rBoxInfo
= static_cast<const SvxBoxInfoItem
&>(rAttr
);
2562 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
2564 return ( mbEnableHor
== rBoxInfo
.mbEnableHor
2565 && mbEnableVer
== rBoxInfo
.mbEnableVer
2566 && bDist
== rBoxInfo
.IsDist()
2567 && bMinDist
== rBoxInfo
.IsMinDist()
2568 && nValidFlags
== rBoxInfo
.nValidFlags
2569 && nDefDist
== rBoxInfo
.GetDefDist()
2570 && CmpBrdLn( pHori
, rBoxInfo
.GetHori() )
2571 && CmpBrdLn( pVert
, rBoxInfo
.GetVert() )
2577 void SvxBoxInfoItem::SetLine( const SvxBorderLine
* pNew
, SvxBoxInfoItemLine nLine
)
2579 SvxBorderLine
* pTmp
= pNew
? new SvxBorderLine( *pNew
) : 0;
2581 if ( SvxBoxInfoItemLine::HORI
== nLine
)
2586 else if ( SvxBoxInfoItemLine::VERT
== nLine
)
2594 OSL_FAIL( "wrong line" );
2600 SfxPoolItem
* SvxBoxInfoItem::Clone( SfxItemPool
* ) const
2602 return new SvxBoxInfoItem( *this );
2607 bool SvxBoxInfoItem::GetPresentation
2609 SfxItemPresentation
/*ePres*/,
2610 SfxMapUnit
/*eCoreUnit*/,
2611 SfxMapUnit
/*ePresUnit*/,
2612 OUString
& rText
, const IntlWrapper
*
2621 SvStream
& SvxBoxInfoItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2623 sal_Int8 cFlags
= 0;
2631 rStrm
.WriteSChar( cFlags
)
2632 .WriteUInt16( GetDefDist() );
2633 const SvxBorderLine
* pLine
[ 2 ];
2634 pLine
[ 0 ] = GetHori();
2635 pLine
[ 1 ] = GetVert();
2637 for( int i
= 0; i
< 2; i
++ )
2639 const SvxBorderLine
* l
= pLine
[ i
];
2642 rStrm
.WriteChar( (char) i
);
2643 WriteColor( rStrm
, l
->GetColor() );
2644 rStrm
.WriteInt16( l
->GetOutWidth() )
2645 .WriteInt16( l
->GetInWidth() )
2646 .WriteInt16( l
->GetDistance() );
2649 rStrm
.WriteChar( (char) 2 );
2655 bool SvxBoxInfoItem::ScaleMetrics( long nMult
, long nDiv
)
2657 if ( pHori
) pHori
->ScaleMetrics( nMult
, nDiv
);
2658 if ( pVert
) pVert
->ScaleMetrics( nMult
, nDiv
);
2659 nDefDist
= (sal_uInt16
)Scale( nDefDist
, nMult
, nDiv
);
2665 bool SvxBoxInfoItem::HasMetrics() const
2672 SfxPoolItem
* SvxBoxInfoItem::Create( SvStream
& rStrm
, sal_uInt16
) const
2675 sal_uInt16 _nDefDist
;
2676 rStrm
.ReadSChar( cFlags
).ReadUInt16( _nDefDist
);
2678 SvxBoxInfoItem
* pAttr
= new SvxBoxInfoItem( Which() );
2680 pAttr
->SetTable ( ( cFlags
& 0x01 ) != 0 );
2681 pAttr
->SetDist ( ( cFlags
& 0x02 ) != 0 );
2682 pAttr
->SetMinDist( ( cFlags
& 0x04 ) != 0 );
2683 pAttr
->SetDefDist( _nDefDist
);
2688 rStrm
.ReadSChar( cLine
);
2692 short nOutline
, nInline
, nDistance
;
2694 ReadColor( rStrm
, aColor
).ReadInt16( nOutline
).ReadInt16( nInline
).ReadInt16( nDistance
);
2695 SvxBorderLine
aBorder( &aColor
);
2696 aBorder
.GuessLinesWidths(css::table::BorderLineStyle::NONE
, nOutline
, nInline
, nDistance
);
2700 case 0: pAttr
->SetLine( &aBorder
, SvxBoxInfoItemLine::HORI
); break;
2701 case 1: pAttr
->SetLine( &aBorder
, SvxBoxInfoItemLine::VERT
); break;
2709 void SvxBoxInfoItem::ResetFlags()
2711 nValidFlags
= static_cast<SvxBoxInfoItemValidFlags
>(0x7F); // all valid except Disable
2714 bool SvxBoxInfoItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2716 bool bConvert
= 0 != (nMemberId
& CONVERT_TWIPS
);
2717 table::BorderLine2 aRetLine
;
2719 bool bIntMember
= false;
2720 nMemberId
&= ~CONVERT_TWIPS
;
2725 // 2 BorderLines, flags, valid flags and distance
2726 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aSeq( 5 );
2727 aSeq
[0] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pHori
, bConvert
) );
2728 aSeq
[1] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pVert
, bConvert
) );
2735 aSeq
[2] = ::com::sun::star::uno::makeAny( nVal
);
2736 aSeq
[3] = ::com::sun::star::uno::makeAny( static_cast<sal_Int16
>(nValidFlags
) );
2737 aSeq
[4] = ::com::sun::star::uno::makeAny( (sal_Int32
)(bConvert
? convertTwipToMm100(GetDefDist()) : GetDefDist()) );
2738 rVal
= ::com::sun::star::uno::makeAny( aSeq
);
2742 case MID_HORIZONTAL
:
2743 aRetLine
= SvxBoxItem::SvxLineToLine( pHori
, bConvert
);
2746 aRetLine
= SvxBoxItem::SvxLineToLine( pVert
, bConvert
);
2758 case MID_VALIDFLAGS
:
2760 rVal
<<= static_cast<sal_Int16
>(nValidFlags
);
2764 rVal
<<= (sal_Int32
)(bConvert
? convertTwipToMm100(GetDefDist()) : GetDefDist());
2766 default: OSL_FAIL("Wrong MemberId!"); return false;
2777 bool SvxBoxInfoItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2779 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
2780 nMemberId
&= ~CONVERT_TWIPS
;
2786 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aSeq
;
2787 if (( rVal
>>= aSeq
) && ( aSeq
.getLength() == 5 ))
2789 // 2 BorderLines, flags, valid flags and distance
2790 if (!lcl_setLine(aSeq
[0], *this, SvxBoxInfoItemLine::HORI
, bConvert
))
2792 if (!lcl_setLine(aSeq
[1], *this, SvxBoxInfoItemLine::VERT
, bConvert
))
2795 sal_Int16
nFlags( 0 );
2796 sal_Int32
nVal( 0 );
2797 if ( aSeq
[2] >>= nFlags
)
2799 SetTable ( ( nFlags
& 0x01 ) != 0 );
2800 SetDist ( ( nFlags
& 0x02 ) != 0 );
2801 SetMinDist( ( nFlags
& 0x04 ) != 0 );
2805 if ( aSeq
[3] >>= nFlags
)
2806 nValidFlags
= static_cast<SvxBoxInfoItemValidFlags
>(nFlags
);
2809 if (( aSeq
[4] >>= nVal
) && ( nVal
>= 0 ))
2812 nVal
= convertMm100ToTwip(nVal
);
2813 SetDefDist( (sal_uInt16
)nVal
);
2819 case MID_HORIZONTAL
:
2822 if( !rVal
.hasValue() )
2825 table::BorderLine2 aBorderLine
;
2826 if( lcl_extractBorderLine(rVal
, aBorderLine
) )
2830 else if (rVal
.getValueTypeClass() == uno::TypeClass_SEQUENCE
)
2832 // serialization for basic macro recording
2833 uno::Reference
< script::XTypeConverter
> xConverter( script::Converter::create(::comphelper::getProcessComponentContext()) );
2835 uno::Sequence
< uno::Any
> aSeq
;
2836 try { aNew
= xConverter
->convertTo( rVal
, cppu::UnoType
<uno::Sequence
< uno::Any
>>::get() ); }
2837 catch (const uno::Exception
&) {}
2839 if ((aNew
>>= aSeq
) &&
2840 aSeq
.getLength() >= 4 && aSeq
.getLength() <= 6)
2843 if ( aSeq
[0] >>= nVal
)
2844 aBorderLine
.Color
= nVal
;
2845 if ( aSeq
[1] >>= nVal
)
2846 aBorderLine
.InnerLineWidth
= (sal_Int16
) nVal
;
2847 if ( aSeq
[2] >>= nVal
)
2848 aBorderLine
.OuterLineWidth
= (sal_Int16
) nVal
;
2849 if ( aSeq
[3] >>= nVal
)
2850 aBorderLine
.LineDistance
= (sal_Int16
) nVal
;
2851 if (aSeq
.getLength() >= 5) // fdo#40874 added fields
2853 if (aSeq
[4] >>= nVal
)
2855 aBorderLine
.LineStyle
= nVal
;
2857 if (aSeq
.getLength() >= 6)
2859 if (aSeq
[5] >>= nVal
)
2861 aBorderLine
.LineWidth
= nVal
;
2869 else if (rVal
.getValueType() == cppu::UnoType
<css::uno::Sequence
< sal_Int16
>>::get() )
2871 // serialization for basic macro recording
2872 ::com::sun::star::uno::Sequence
< sal_Int16
> aSeq
;
2874 if (aSeq
.getLength() >= 4 && aSeq
.getLength() <= 6)
2876 aBorderLine
.Color
= aSeq
[0];
2877 aBorderLine
.InnerLineWidth
= aSeq
[1];
2878 aBorderLine
.OuterLineWidth
= aSeq
[2];
2879 aBorderLine
.LineDistance
= aSeq
[3];
2880 if (aSeq
.getLength() >= 5) // fdo#40874 added fields
2882 aBorderLine
.LineStyle
= aSeq
[4];
2883 if (aSeq
.getLength() >= 6)
2885 aBorderLine
.LineWidth
= aSeq
[5];
2895 SvxBorderLine aLine
;
2896 bool bSet
= SvxBoxItem::LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2898 SetLine( &aLine
, nMemberId
== MID_HORIZONTAL
? SvxBoxInfoItemLine::HORI
: SvxBoxInfoItemLine::VERT
);
2903 sal_Int16 nFlags
= sal_Int16();
2904 bRet
= (rVal
>>= nFlags
);
2907 SetTable ( ( nFlags
& 0x01 ) != 0 );
2908 SetDist ( ( nFlags
& 0x02 ) != 0 );
2909 SetMinDist( ( nFlags
& 0x04 ) != 0 );
2914 case MID_VALIDFLAGS
:
2916 sal_Int16 nFlags
= sal_Int16();
2917 bRet
= (rVal
>>= nFlags
);
2919 nValidFlags
= static_cast<SvxBoxInfoItemValidFlags
>(nFlags
);
2925 bRet
= (rVal
>>= nVal
);
2926 if ( bRet
&& nVal
>=0 )
2929 nVal
= convertMm100ToTwip(nVal
);
2930 SetDefDist( (sal_uInt16
)nVal
);
2934 default: OSL_FAIL("Wrong MemberId!"); return false;
2940 // class SvxFormatBreakItem -------------------------------------------------
2942 bool SvxFormatBreakItem::operator==( const SfxPoolItem
& rAttr
) const
2944 DBG_ASSERT( SfxPoolItem::operator==( rAttr
), "unequal types" );
2946 return GetValue() == static_cast<const SvxFormatBreakItem
&>( rAttr
).GetValue();
2951 bool SvxFormatBreakItem::GetPresentation
2953 SfxItemPresentation
/*ePres*/,
2954 SfxMapUnit
/*eCoreUnit*/,
2955 SfxMapUnit
/*ePresUnit*/,
2956 OUString
& rText
, const IntlWrapper
*
2959 rText
= GetValueTextByPos( GetValue() );
2965 OUString
SvxFormatBreakItem::GetValueTextByPos( sal_uInt16 nPos
) const
2967 DBG_ASSERT( nPos
< SVX_BREAK_END
, "enum overflow!" );
2968 return EE_RESSTR(RID_SVXITEMS_BREAK_BEGIN
+ nPos
);
2972 bool SvxFormatBreakItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
2974 style::BreakType eBreak
= style::BreakType_NONE
;
2975 switch ( (SvxBreak
)GetValue() )
2977 case SVX_BREAK_COLUMN_BEFORE
: eBreak
= style::BreakType_COLUMN_BEFORE
; break;
2978 case SVX_BREAK_COLUMN_AFTER
: eBreak
= style::BreakType_COLUMN_AFTER
; break;
2979 case SVX_BREAK_COLUMN_BOTH
: eBreak
= style::BreakType_COLUMN_BOTH
; break;
2980 case SVX_BREAK_PAGE_BEFORE
: eBreak
= style::BreakType_PAGE_BEFORE
; break;
2981 case SVX_BREAK_PAGE_AFTER
: eBreak
= style::BreakType_PAGE_AFTER
; break;
2982 case SVX_BREAK_PAGE_BOTH
: eBreak
= style::BreakType_PAGE_BOTH
; break;
2983 default: ;//prevent warning
2989 bool SvxFormatBreakItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
2991 style::BreakType nBreak
;
2993 if(!(rVal
>>= nBreak
))
2995 sal_Int32 nValue
= 0;
2996 if(!(rVal
>>= nValue
))
2999 nBreak
= (style::BreakType
) nValue
;
3002 SvxBreak eBreak
= SVX_BREAK_NONE
;
3005 case style::BreakType_COLUMN_BEFORE
: eBreak
= SVX_BREAK_COLUMN_BEFORE
; break;
3006 case style::BreakType_COLUMN_AFTER
: eBreak
= SVX_BREAK_COLUMN_AFTER
; break;
3007 case style::BreakType_COLUMN_BOTH
: eBreak
= SVX_BREAK_COLUMN_BOTH
; break;
3008 case style::BreakType_PAGE_BEFORE
: eBreak
= SVX_BREAK_PAGE_BEFORE
; break;
3009 case style::BreakType_PAGE_AFTER
: eBreak
= SVX_BREAK_PAGE_AFTER
; break;
3010 case style::BreakType_PAGE_BOTH
: eBreak
= SVX_BREAK_PAGE_BOTH
; break;
3011 default: ;//prevent warning
3013 SetValue((sal_uInt16
) eBreak
);
3020 SfxPoolItem
* SvxFormatBreakItem::Clone( SfxItemPool
* ) const
3022 return new SvxFormatBreakItem( *this );
3027 SvStream
& SvxFormatBreakItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
3029 rStrm
.WriteSChar( GetValue() );
3030 if( FMTBREAK_NOAUTO
> nItemVersion
)
3031 rStrm
.WriteSChar( 0x01 );
3037 sal_uInt16
SvxFormatBreakItem::GetVersion( sal_uInt16 nFFVer
) const
3039 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
3040 SOFFICE_FILEFORMAT_40
==nFFVer
||
3041 SOFFICE_FILEFORMAT_50
==nFFVer
,
3042 "SvxFormatBreakItem: Is there a new file format? ");
3043 return SOFFICE_FILEFORMAT_31
==nFFVer
||
3044 SOFFICE_FILEFORMAT_40
==nFFVer
? 0 : FMTBREAK_NOAUTO
;
3049 SfxPoolItem
* SvxFormatBreakItem::Create( SvStream
& rStrm
, sal_uInt16 nVersion
) const
3051 sal_Int8 eBreak
, bDummy
;
3052 rStrm
.ReadSChar( eBreak
);
3053 if( FMTBREAK_NOAUTO
> nVersion
)
3054 rStrm
.ReadSChar( bDummy
);
3055 return new SvxFormatBreakItem( (const SvxBreak
)eBreak
, Which() );
3060 sal_uInt16
SvxFormatBreakItem::GetValueCount() const
3062 return SVX_BREAK_END
; // SVX_BREAK_PAGE_BOTH + 1
3065 // class SvxFormatKeepItem -------------------------------------------------
3067 SfxPoolItem
* SvxFormatKeepItem::Clone( SfxItemPool
* ) const
3069 return new SvxFormatKeepItem( *this );
3074 SvStream
& SvxFormatKeepItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
3076 rStrm
.WriteSChar( (sal_Int8
)GetValue() );
3082 SfxPoolItem
* SvxFormatKeepItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3085 rStrm
.ReadSChar( bIsKeep
);
3086 return new SvxFormatKeepItem( bIsKeep
!= 0, Which() );
3091 bool SvxFormatKeepItem::GetPresentation
3093 SfxItemPresentation
/*ePres*/,
3094 SfxMapUnit
/*eCoreUnit*/,
3095 SfxMapUnit
/*ePresUnit*/,
3096 OUString
& rText
, const IntlWrapper
*
3099 sal_uInt16 nId
= RID_SVXITEMS_FMTKEEP_FALSE
;
3102 nId
= RID_SVXITEMS_FMTKEEP_TRUE
;
3103 rText
= EE_RESSTR(nId
);
3107 // class SvxLineItem ------------------------------------------------------
3109 SvxLineItem::SvxLineItem( const sal_uInt16 nId
) :
3111 SfxPoolItem ( nId
),
3119 SvxLineItem::SvxLineItem( const SvxLineItem
& rCpy
) :
3121 SfxPoolItem ( rCpy
)
3123 pLine
= rCpy
.GetLine() ? new SvxBorderLine( *rCpy
.GetLine() ) : 0;
3128 SvxLineItem::~SvxLineItem()
3135 SvxLineItem
& SvxLineItem::operator=( const SvxLineItem
& rLine
)
3137 SetLine( rLine
.GetLine() );
3144 bool SvxLineItem::operator==( const SfxPoolItem
& rAttr
) const
3146 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
3148 return CmpBrdLn( pLine
, static_cast<const SvxLineItem
&>(rAttr
).GetLine() );
3153 SfxPoolItem
* SvxLineItem::Clone( SfxItemPool
* ) const
3155 return new SvxLineItem( *this );
3158 bool SvxLineItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemId
) const
3160 bool bConvert
= 0!=(nMemId
&CONVERT_TWIPS
);
3161 nMemId
&= ~CONVERT_TWIPS
;
3164 rVal
<<= uno::makeAny( SvxBoxItem::SvxLineToLine(pLine
, bConvert
) );
3171 case MID_FG_COLOR
: rVal
<<= sal_Int32(pLine
->GetColor().GetColor()); break;
3172 case MID_OUTER_WIDTH
: rVal
<<= sal_Int32(pLine
->GetOutWidth()); break;
3173 case MID_INNER_WIDTH
: rVal
<<= sal_Int32(pLine
->GetInWidth( )); break;
3174 case MID_DISTANCE
: rVal
<<= sal_Int32(pLine
->GetDistance()); break;
3176 OSL_FAIL( "Wrong MemberId" );
3186 bool SvxLineItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemId
)
3188 bool bConvert
= 0!=(nMemId
&CONVERT_TWIPS
);
3189 nMemId
&= ~CONVERT_TWIPS
;
3193 table::BorderLine2 aLine
;
3194 if ( lcl_extractBorderLine(rVal
, aLine
) )
3197 pLine
= new SvxBorderLine
;
3198 if( !SvxBoxItem::LineToSvxLine(aLine
, *pLine
, bConvert
) )
3204 else if ( rVal
>>= nVal
)
3207 pLine
= new SvxBorderLine
;
3211 case MID_FG_COLOR
: pLine
->SetColor( Color(nVal
) ); break;
3212 case MID_LINE_STYLE
:
3213 pLine
->SetBorderLineStyle(static_cast<SvxBorderStyle
>(nVal
));
3216 OSL_FAIL( "Wrong MemberId" );
3228 bool SvxLineItem::GetPresentation
3230 SfxItemPresentation ePres
,
3231 SfxMapUnit eCoreUnit
,
3232 SfxMapUnit ePresUnit
,
3233 OUString
& rText
, const IntlWrapper
*pIntl
3239 rText
= pLine
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
,
3240 (SFX_ITEM_PRESENTATION_COMPLETE
== ePres
) );
3246 SvStream
& SvxLineItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
3250 WriteColor( rStrm
, pLine
->GetColor() );
3251 rStrm
.WriteInt16( pLine
->GetOutWidth() )
3252 .WriteInt16( pLine
->GetInWidth() )
3253 .WriteInt16( pLine
->GetDistance() );
3257 WriteColor( rStrm
, Color() );
3258 rStrm
.WriteInt16( 0 ).WriteInt16( 0 ).WriteInt16( 0 );
3265 bool SvxLineItem::ScaleMetrics( long nMult
, long nDiv
)
3267 if ( pLine
) pLine
->ScaleMetrics( nMult
, nDiv
);
3273 bool SvxLineItem::HasMetrics() const
3280 SfxPoolItem
* SvxLineItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3282 SvxLineItem
* _pLine
= new SvxLineItem( Which() );
3283 short nOutline
, nInline
, nDistance
;
3286 ReadColor( rStrm
, aColor
).ReadInt16( nOutline
).ReadInt16( nInline
).ReadInt16( nDistance
);
3289 SvxBorderLine
aLine( &aColor
);
3290 aLine
.GuessLinesWidths(css::table::BorderLineStyle::NONE
, nOutline
, nInline
, nDistance
);
3291 _pLine
->SetLine( &aLine
);
3298 void SvxLineItem::SetLine( const SvxBorderLine
* pNew
)
3301 pLine
= pNew
? new SvxBorderLine( *pNew
) : 0;
3304 // class SvxBrushItem ----------------------------------------------------
3306 #define LOAD_GRAPHIC ((sal_uInt16)0x0001)
3307 #define LOAD_LINK ((sal_uInt16)0x0002)
3308 #define LOAD_FILTER ((sal_uInt16)0x0004)
3310 // class SvxBrushItem_Impl -----------------------------------------------
3312 class SvxBrushItem_Impl
3315 GraphicObject
* pGraphicObject
;
3316 sal_Int8 nGraphicTransparency
; //contains a percentage value which is
3317 //copied to the GraphicObject when necessary
3321 SvxBrushItem_Impl( GraphicObject
* p
) : pGraphicObject( p
), nGraphicTransparency(0), pStream(0) {}
3326 void SvxBrushItem::SetDoneLink( const Link
<>& rLink
)
3328 pImpl
->aDoneLink
= rLink
;
3333 SvxBrushItem::SvxBrushItem( sal_uInt16 _nWhich
) :
3335 SfxPoolItem( _nWhich
),
3337 aColor ( COL_TRANSPARENT
),
3338 nShadingValue ( ShadingPattern::CLEAR
),
3339 pImpl ( new SvxBrushItem_Impl( 0 ) ),
3342 eGraphicPos ( GPOS_NONE
),
3350 SvxBrushItem::SvxBrushItem( const Color
& rColor
, sal_uInt16 _nWhich
) :
3352 SfxPoolItem( _nWhich
),
3355 nShadingValue ( ShadingPattern::CLEAR
),
3356 pImpl ( new SvxBrushItem_Impl( 0 ) ),
3359 eGraphicPos ( GPOS_NONE
),
3367 SvxBrushItem::SvxBrushItem( const Graphic
& rGraphic
, SvxGraphicPosition ePos
,
3368 sal_uInt16 _nWhich
) :
3370 SfxPoolItem( _nWhich
),
3372 aColor ( COL_TRANSPARENT
),
3373 nShadingValue ( ShadingPattern::CLEAR
),
3374 pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphic
) ) ),
3377 eGraphicPos ( ( GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
),
3381 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3386 SvxBrushItem::SvxBrushItem( const GraphicObject
& rGraphicObj
,
3387 SvxGraphicPosition ePos
, sal_uInt16 _nWhich
) :
3389 SfxPoolItem( _nWhich
),
3391 aColor ( COL_TRANSPARENT
),
3392 nShadingValue ( ShadingPattern::CLEAR
),
3393 pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphicObj
) ) ),
3396 eGraphicPos ( ( GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
),
3400 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3405 SvxBrushItem::SvxBrushItem(
3406 const OUString
& rLink
, const OUString
& rFilter
,
3407 SvxGraphicPosition ePos
, sal_uInt16 _nWhich
) :
3409 SfxPoolItem( _nWhich
),
3411 aColor ( COL_TRANSPARENT
),
3412 nShadingValue ( ShadingPattern::CLEAR
),
3413 pImpl ( new SvxBrushItem_Impl( NULL
) ),
3414 maStrLink ( rLink
),
3415 maStrFilter ( rFilter
),
3416 eGraphicPos ( ( GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
),
3420 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3425 SvxBrushItem::SvxBrushItem( SvStream
& rStream
, sal_uInt16 nVersion
,
3426 sal_uInt16 _nWhich
)
3427 : SfxPoolItem( _nWhich
)
3428 , aColor ( COL_TRANSPARENT
)
3429 , nShadingValue ( ShadingPattern::CLEAR
)
3430 , pImpl ( new SvxBrushItem_Impl( NULL
) )
3433 , eGraphicPos ( GPOS_NONE
)
3434 , bLoadAgain (false)
3438 Color aTempFillColor
;
3441 rStream
.ReadCharAsBool( bTrans
);
3442 ReadColor( rStream
, aTempColor
);
3443 ReadColor( rStream
, aTempFillColor
);
3444 rStream
.ReadSChar( nStyle
);
3450 sal_uInt32 nRed
= aTempColor
.GetRed();
3451 sal_uInt32 nGreen
= aTempColor
.GetGreen();
3452 sal_uInt32 nBlue
= aTempColor
.GetBlue();
3453 nRed
+= (sal_uInt32
)(aTempFillColor
.GetRed())*2;
3454 nGreen
+= (sal_uInt32
)(aTempFillColor
.GetGreen())*2;
3455 nBlue
+= (sal_uInt32
)(aTempFillColor
.GetBlue())*2;
3456 aColor
= Color( (sal_Int8
)(nRed
/3), (sal_Int8
)(nGreen
/3), (sal_Int8
)(nBlue
/3) );
3462 sal_uInt32 nRed
= aTempColor
.GetRed();
3463 sal_uInt32 nGreen
= aTempColor
.GetGreen();
3464 sal_uInt32 nBlue
= aTempColor
.GetBlue();
3465 nRed
+= (sal_uInt32
)(aTempFillColor
.GetRed());
3466 nGreen
+= (sal_uInt32
)(aTempFillColor
.GetGreen());
3467 nBlue
+= (sal_uInt32
)(aTempFillColor
.GetBlue());
3468 aColor
= Color( (sal_Int8
)(nRed
/2), (sal_Int8
)(nGreen
/2), (sal_Int8
)(nBlue
/2) );
3474 sal_uInt32 nRed
= aTempColor
.GetRed()*2;
3475 sal_uInt32 nGreen
= aTempColor
.GetGreen()*2;
3476 sal_uInt32 nBlue
= aTempColor
.GetBlue()*2;
3477 nRed
+= (sal_uInt32
)(aTempFillColor
.GetRed());
3478 nGreen
+= (sal_uInt32
)(aTempFillColor
.GetGreen());
3479 nBlue
+= (sal_uInt32
)(aTempFillColor
.GetBlue());
3480 aColor
= Color( (sal_Int8
)(nRed
/3), (sal_Int8
)(nGreen
/3), (sal_Int8
)(nBlue
/3) );
3484 case 0://BRUSH_NULL:
3485 aColor
= Color( COL_TRANSPARENT
);
3489 aColor
= aTempColor
;
3492 if ( nVersion
>= BRUSH_GRAPHIC_VERSION
)
3494 sal_uInt16 nDoLoad
= 0;
3497 rStream
.ReadUInt16( nDoLoad
);
3499 if ( nDoLoad
& LOAD_GRAPHIC
)
3503 ReadGraphic( rStream
, aGraphic
);
3504 pImpl
->pGraphicObject
= new GraphicObject( aGraphic
);
3506 if( SVSTREAM_FILEFORMAT_ERROR
== rStream
.GetError() )
3508 rStream
.ResetError();
3509 rStream
.SetError( ERRCODE_SVX_GRAPHIC_WRONG_FILEFORMAT
|
3510 ERRCODE_WARNING_MASK
);
3514 if ( nDoLoad
& LOAD_LINK
)
3516 // UNICODE: rStream >> aRel;
3517 OUString aRel
= rStream
.ReadUniOrByteString(rStream
.GetStreamCharSet());
3519 // TODO/MBA: how can we get a BaseURL here?!
3520 OSL_FAIL("No BaseURL!");
3521 OUString aAbs
= INetURLObject::GetAbsURL( "", aRel
);
3522 DBG_ASSERT( !aAbs
.isEmpty(), "Invalid URL!" );
3526 if ( nDoLoad
& LOAD_FILTER
)
3528 // UNICODE: rStream >> maStrFilter;
3529 maStrFilter
= rStream
.ReadUniOrByteString(rStream
.GetStreamCharSet());
3532 rStream
.ReadSChar( nPos
);
3534 eGraphicPos
= (SvxGraphicPosition
)nPos
;
3540 SvxBrushItem::SvxBrushItem( const SvxBrushItem
& rItem
) :
3542 SfxPoolItem( rItem
.Which() ),
3543 nShadingValue ( ShadingPattern::CLEAR
),
3544 pImpl ( new SvxBrushItem_Impl( NULL
) ),
3547 eGraphicPos ( GPOS_NONE
),
3556 SvxBrushItem::~SvxBrushItem()
3558 delete pImpl
->pGraphicObject
;
3564 sal_uInt16
SvxBrushItem::GetVersion( sal_uInt16
/*nFileVersion*/ ) const
3566 return BRUSH_GRAPHIC_VERSION
;
3570 static inline sal_Int8
lcl_PercentToTransparency(long nPercent
)
3572 //0xff must not be returned!
3573 return sal_Int8(nPercent
? (50 + 0xfe * nPercent
) / 100 : 0);
3575 sal_Int8
SvxBrushItem::TransparencyToPercent(sal_Int32 nTrans
)
3577 return (sal_Int8
)((nTrans
* 100 + 127) / 254);
3580 bool SvxBrushItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
3582 nMemberId
&= ~CONVERT_TWIPS
;
3585 case MID_BACK_COLOR
:
3586 rVal
<<= (sal_Int32
)( aColor
.GetColor() );
3588 case MID_BACK_COLOR_R_G_B
:
3589 rVal
<<= (sal_Int32
)( aColor
.GetRGBColor() );
3591 case MID_BACK_COLOR_TRANSPARENCY
:
3592 rVal
<<= SvxBrushItem::TransparencyToPercent(aColor
.GetTransparency());
3594 case MID_GRAPHIC_POSITION
:
3595 rVal
<<= (style::GraphicLocation
)(sal_Int16
)eGraphicPos
;
3599 SAL_WARN( "editeng.items", "not implemented" );
3602 case MID_GRAPHIC_TRANSPARENT
:
3603 rVal
= Bool2Any( aColor
.GetTransparency() == 0xff );
3606 case MID_GRAPHIC_URL
:
3609 if ( !maStrLink
.isEmpty() )
3611 else if( pImpl
->pGraphicObject
)
3614 UNO_NAME_GRAPHOBJ_URLPREFIX
);
3615 OUString
sId(OStringToOUString(
3616 pImpl
->pGraphicObject
->GetUniqueID(),
3617 RTL_TEXTENCODING_ASCII_US
));
3618 sLink
= sPrefix
+ sId
;
3624 case MID_GRAPHIC_FILTER
:
3626 rVal
<<= maStrFilter
;
3630 case MID_GRAPHIC_TRANSPARENCY
:
3631 rVal
<<= pImpl
->nGraphicTransparency
;
3634 case MID_SHADING_VALUE
:
3636 rVal
<<= nShadingValue
;
3646 bool SvxBrushItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
3648 nMemberId
&= ~CONVERT_TWIPS
;
3651 case MID_BACK_COLOR
:
3652 case MID_BACK_COLOR_R_G_B
:
3655 if ( !( rVal
>>= nCol
) )
3657 if(MID_BACK_COLOR_R_G_B
== nMemberId
)
3659 nCol
= COLORDATA_RGB( nCol
);
3660 nCol
+= aColor
.GetColor() & 0xff000000;
3662 aColor
= Color( nCol
);
3665 case MID_BACK_COLOR_TRANSPARENCY
:
3667 sal_Int32 nTrans
= 0;
3668 if ( !( rVal
>>= nTrans
) || nTrans
< 0 || nTrans
> 100 )
3670 aColor
.SetTransparency(lcl_PercentToTransparency(nTrans
));
3674 case MID_GRAPHIC_POSITION
:
3676 style::GraphicLocation eLocation
;
3677 if ( !( rVal
>>=eLocation
) )
3679 sal_Int32 nValue
= 0;
3680 if ( !( rVal
>>= nValue
) )
3682 eLocation
= (style::GraphicLocation
)nValue
;
3684 SetGraphicPos( (SvxGraphicPosition
)(sal_uInt16
)eLocation
);
3689 SAL_WARN( "editeng.items", "not implemented" );
3692 case MID_GRAPHIC_TRANSPARENT
:
3693 aColor
.SetTransparency( Any2Bool( rVal
) ? 0xff : 0 );
3696 case MID_GRAPHIC_URL
:
3698 if ( rVal
.getValueType() == ::cppu::UnoType
<OUString
>::get() )
3702 if( sLink
.startsWith( UNO_NAME_GRAPHOBJ_URLPKGPREFIX
) )
3704 OSL_FAIL( "package urls aren't implemented" );
3706 else if( sLink
.startsWith( UNO_NAME_GRAPHOBJ_URLPREFIX
) )
3709 OString
sId(OUStringToOString(sLink
.copy( sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX
)-1 ),
3710 RTL_TEXTENCODING_ASCII_US
));
3711 GraphicObject
*pOldGrfObj
= pImpl
->pGraphicObject
;
3712 pImpl
->pGraphicObject
= new GraphicObject( sId
);
3713 ApplyGraphicTransparency_Impl();
3718 SetGraphicLink(sLink
);
3720 if ( !sLink
.isEmpty() && eGraphicPos
== GPOS_NONE
)
3721 eGraphicPos
= GPOS_MM
;
3722 else if( sLink
.isEmpty() )
3723 eGraphicPos
= GPOS_NONE
;
3728 case MID_GRAPHIC_FILTER
:
3730 if( rVal
.getValueType() == ::cppu::UnoType
<OUString
>::get() )
3734 SetGraphicFilter( sLink
);
3738 case MID_GRAPHIC_TRANSPARENCY
:
3742 if(nTmp
>= 0 && nTmp
<= 100)
3744 pImpl
->nGraphicTransparency
= sal_Int8(nTmp
);
3745 if(pImpl
->pGraphicObject
)
3746 ApplyGraphicTransparency_Impl();
3751 case MID_SHADING_VALUE
:
3754 if (!(rVal
>>= nVal
))
3757 SetShadingValue( nVal
);
3767 bool SvxBrushItem::GetPresentation
3769 SfxItemPresentation
/*ePres*/,
3770 SfxMapUnit
/*eCoreUnit*/,
3771 SfxMapUnit
/*ePresUnit*/,
3772 OUString
& rText
, const IntlWrapper
*
3775 if ( GPOS_NONE
== eGraphicPos
)
3777 rText
= ::GetColorString( aColor
) + OUString(cpDelim
);
3778 sal_uInt16 nId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
3780 if ( aColor
.GetTransparency() )
3781 nId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
3782 rText
+= EE_RESSTR(nId
);
3786 rText
= EE_RESSTR(RID_SVXITEMS_GRAPHIC
);
3794 SvxBrushItem
& SvxBrushItem::operator=( const SvxBrushItem
& rItem
)
3796 aColor
= rItem
.aColor
;
3797 eGraphicPos
= rItem
.eGraphicPos
;
3799 DELETEZ( pImpl
->pGraphicObject
);
3801 maStrFilter
.clear();
3803 if ( GPOS_NONE
!= eGraphicPos
)
3805 maStrLink
= rItem
.maStrLink
;
3806 maStrFilter
= rItem
.maStrFilter
;
3807 if ( rItem
.pImpl
->pGraphicObject
)
3809 pImpl
->pGraphicObject
= new GraphicObject( *rItem
.pImpl
->pGraphicObject
);
3813 nShadingValue
= rItem
.nShadingValue
;
3815 pImpl
->nGraphicTransparency
= rItem
.pImpl
->nGraphicTransparency
;
3821 bool SvxBrushItem::operator==( const SfxPoolItem
& rAttr
) const
3823 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
3825 const SvxBrushItem
& rCmp
= static_cast<const SvxBrushItem
&>(rAttr
);
3826 bool bEqual
= ( aColor
== rCmp
.aColor
&& eGraphicPos
== rCmp
.eGraphicPos
&&
3827 pImpl
->nGraphicTransparency
== rCmp
.pImpl
->nGraphicTransparency
);
3831 if ( GPOS_NONE
!= eGraphicPos
)
3833 bEqual
= maStrLink
== rCmp
.maStrLink
;
3837 bEqual
= maStrFilter
== rCmp
.maStrFilter
;
3842 if ( !rCmp
.pImpl
->pGraphicObject
)
3843 bEqual
= !pImpl
->pGraphicObject
;
3845 bEqual
= pImpl
->pGraphicObject
&&
3846 ( *pImpl
->pGraphicObject
== *rCmp
.pImpl
->pGraphicObject
);
3852 bEqual
= nShadingValue
== rCmp
.nShadingValue
;
3861 SfxPoolItem
* SvxBrushItem::Clone( SfxItemPool
* ) const
3863 return new SvxBrushItem( *this );
3868 SfxPoolItem
* SvxBrushItem::Create( SvStream
& rStream
, sal_uInt16 nVersion
) const
3870 return new SvxBrushItem( rStream
, nVersion
, Which() );
3875 SvStream
& SvxBrushItem::Store( SvStream
& rStream
, sal_uInt16
/*nItemVersion*/ ) const
3877 rStream
.WriteBool( false );
3878 WriteColor( rStream
, aColor
);
3879 WriteColor( rStream
, aColor
);
3880 rStream
.WriteSChar( aColor
.GetTransparency() > 0 ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID
3882 sal_uInt16 nDoLoad
= 0;
3884 if ( pImpl
->pGraphicObject
&& maStrLink
.isEmpty() )
3885 nDoLoad
|= LOAD_GRAPHIC
;
3886 if ( !maStrLink
.isEmpty() )
3887 nDoLoad
|= LOAD_LINK
;
3888 if ( !maStrFilter
.isEmpty() )
3889 nDoLoad
|= LOAD_FILTER
;
3890 rStream
.WriteUInt16( nDoLoad
);
3892 if ( pImpl
->pGraphicObject
&& maStrLink
.isEmpty() )
3893 WriteGraphic( rStream
, pImpl
->pGraphicObject
->GetGraphic() );
3894 if ( !maStrLink
.isEmpty() )
3896 OSL_FAIL("No BaseURL!");
3897 // TODO/MBA: how to get a BaseURL?!
3898 OUString aRel
= INetURLObject::GetRelURL( "", maStrLink
);
3899 // UNICODE: rStream << aRel;
3900 rStream
.WriteUniOrByteString(aRel
, rStream
.GetStreamCharSet());
3902 if ( !maStrFilter
.isEmpty() )
3904 // UNICODE: rStream << maStrFilter;
3905 rStream
.WriteUniOrByteString(maStrFilter
, rStream
.GetStreamCharSet());
3907 rStream
.WriteSChar( eGraphicPos
);
3913 void SvxBrushItem::PurgeMedium() const
3915 DELETEZ( pImpl
->pStream
);
3919 const GraphicObject
* SvxBrushItem::GetGraphicObject(OUString
const & referer
) const
3921 if ( bLoadAgain
&& !maStrLink
.isEmpty() && !pImpl
->pGraphicObject
)
3922 // when graphics already loaded, use as a cache
3924 if (SvtSecurityOptions().isUntrustedReferer(referer
)) {
3927 pImpl
->pStream
= utl::UcbStreamHelper::CreateStream( maStrLink
, STREAM_STD_READ
);
3928 if( pImpl
->pStream
&& !pImpl
->pStream
->GetError() )
3932 pImpl
->pStream
->Seek( STREAM_SEEK_TO_BEGIN
);
3933 nRes
= GraphicFilter::GetGraphicFilter().
3934 ImportGraphic( aGraphic
, maStrLink
, *pImpl
->pStream
,
3935 GRFILTER_FORMAT_DONTKNOW
, NULL
, GraphicFilterImportFlags::DontSetLogsizeForJpeg
);
3937 if( nRes
!= GRFILTER_OK
)
3943 pImpl
->pGraphicObject
= new GraphicObject
;
3944 pImpl
->pGraphicObject
->SetGraphic( aGraphic
);
3945 const_cast < SvxBrushItem
*> (this)->ApplyGraphicTransparency_Impl();
3954 return pImpl
->pGraphicObject
;
3958 sal_Int8
SvxBrushItem::getGraphicTransparency() const
3960 return pImpl
->nGraphicTransparency
;
3963 // -----------------------------------------------------------------------
3965 void SvxBrushItem::setGraphicTransparency(sal_Int8 nNew
)
3967 if(nNew
!= pImpl
->nGraphicTransparency
)
3969 pImpl
->nGraphicTransparency
= nNew
;
3970 ApplyGraphicTransparency_Impl();
3974 // -----------------------------------------------------------------------
3977 const Graphic
* SvxBrushItem::GetGraphic(OUString
const & referer
) const
3979 const GraphicObject
* pGrafObj
= GetGraphicObject(referer
);
3980 return( pGrafObj
? &( pGrafObj
->GetGraphic() ) : NULL
);
3985 void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew
)
3989 if ( GPOS_NONE
== eGraphicPos
)
3991 DELETEZ( pImpl
->pGraphicObject
);
3993 maStrFilter
.clear();
3997 if ( !pImpl
->pGraphicObject
&& maStrLink
.isEmpty() )
3999 pImpl
->pGraphicObject
= new GraphicObject
; // Creating a dummy
4006 void SvxBrushItem::SetGraphic( const Graphic
& rNew
)
4008 if ( maStrLink
.isEmpty() )
4010 if ( pImpl
->pGraphicObject
)
4011 pImpl
->pGraphicObject
->SetGraphic( rNew
);
4013 pImpl
->pGraphicObject
= new GraphicObject( rNew
);
4015 ApplyGraphicTransparency_Impl();
4017 if ( GPOS_NONE
== eGraphicPos
)
4018 eGraphicPos
= GPOS_MM
; // None would be brush, then Default: middle
4022 OSL_FAIL( "SetGraphic() on linked graphic! :-/" );
4028 void SvxBrushItem::SetGraphicObject( const GraphicObject
& rNewObj
)
4030 if ( maStrLink
.isEmpty() )
4032 if ( pImpl
->pGraphicObject
)
4033 *pImpl
->pGraphicObject
= rNewObj
;
4035 pImpl
->pGraphicObject
= new GraphicObject( rNewObj
);
4037 ApplyGraphicTransparency_Impl();
4039 if ( GPOS_NONE
== eGraphicPos
)
4040 eGraphicPos
= GPOS_MM
; // None would be brush, then Default: middle
4044 OSL_FAIL( "SetGraphic() on linked graphic! :-/" );
4050 void SvxBrushItem::SetGraphicLink( const OUString
& rNew
)
4052 if ( rNew
.isEmpty() )
4057 DELETEZ( pImpl
->pGraphicObject
);
4063 void SvxBrushItem::SetGraphicFilter( const OUString
& rNew
)
4068 void SvxBrushItem::SetShadingValue( const sal_Int32 nNew
)
4070 nShadingValue
= nNew
;
4074 SvxGraphicPosition
SvxBrushItem::WallpaperStyle2GraphicPos( WallpaperStyle eStyle
)
4076 SvxGraphicPosition eResult
;
4077 // The switch is not the fastest, but the safest
4080 case WALLPAPER_NULL
: eResult
= GPOS_NONE
; break;
4081 case WALLPAPER_TILE
: eResult
= GPOS_TILED
; break;
4082 case WALLPAPER_CENTER
: eResult
= GPOS_MM
; break;
4083 case WALLPAPER_SCALE
: eResult
= GPOS_AREA
; break;
4084 case WALLPAPER_TOPLEFT
: eResult
= GPOS_LT
; break;
4085 case WALLPAPER_TOP
: eResult
= GPOS_MT
; break;
4086 case WALLPAPER_TOPRIGHT
: eResult
= GPOS_RT
; break;
4087 case WALLPAPER_LEFT
: eResult
= GPOS_LM
; break;
4088 case WALLPAPER_RIGHT
: eResult
= GPOS_RM
; break;
4089 case WALLPAPER_BOTTOMLEFT
: eResult
= GPOS_LB
; break;
4090 case WALLPAPER_BOTTOM
: eResult
= GPOS_MB
; break;
4091 case WALLPAPER_BOTTOMRIGHT
: eResult
= GPOS_RB
; break;
4092 default: eResult
= GPOS_NONE
;
4098 WallpaperStyle
SvxBrushItem::GraphicPos2WallpaperStyle( SvxGraphicPosition ePos
)
4100 WallpaperStyle eResult
;
4103 case GPOS_NONE
: eResult
= WALLPAPER_NULL
; break;
4104 case GPOS_TILED
: eResult
= WALLPAPER_TILE
; break;
4105 case GPOS_MM
: eResult
= WALLPAPER_CENTER
; break;
4106 case GPOS_AREA
: eResult
= WALLPAPER_SCALE
; break;
4107 case GPOS_LT
: eResult
= WALLPAPER_TOPLEFT
; break;
4108 case GPOS_MT
: eResult
= WALLPAPER_TOP
; break;
4109 case GPOS_RT
: eResult
= WALLPAPER_TOPRIGHT
; break;
4110 case GPOS_LM
: eResult
= WALLPAPER_LEFT
; break;
4111 case GPOS_RM
: eResult
= WALLPAPER_RIGHT
; break;
4112 case GPOS_LB
: eResult
= WALLPAPER_BOTTOMLEFT
; break;
4113 case GPOS_MB
: eResult
= WALLPAPER_BOTTOM
; break;
4114 case GPOS_RB
: eResult
= WALLPAPER_BOTTOMRIGHT
; break;
4115 default: eResult
= WALLPAPER_NULL
;
4120 SvxBrushItem::SvxBrushItem( const CntWallpaperItem
& rItem
, sal_uInt16 _nWhich
) :
4121 SfxPoolItem ( _nWhich
),
4122 nShadingValue ( ShadingPattern::CLEAR
),
4123 pImpl ( new SvxBrushItem_Impl( 0 ) ),
4128 aColor
= rItem
.GetColor();
4130 if (!rItem
.GetBitmapURL().isEmpty())
4132 maStrLink
= rItem
.GetBitmapURL();
4133 SetGraphicPos( WallpaperStyle2GraphicPos((WallpaperStyle
)rItem
.GetStyle() ) );
4137 SetGraphicPos( GPOS_NONE
);
4141 void SvxBrushItem::ApplyGraphicTransparency_Impl()
4143 DBG_ASSERT(pImpl
->pGraphicObject
, "no GraphicObject available" );
4144 if(pImpl
->pGraphicObject
)
4146 GraphicAttr
aAttr(pImpl
->pGraphicObject
->GetAttr());
4147 aAttr
.SetTransparency(lcl_PercentToTransparency(
4148 pImpl
->nGraphicTransparency
));
4149 pImpl
->pGraphicObject
->SetAttr(aAttr
);
4153 void SvxBrushItem::dumpAsXml(xmlTextWriterPtr pWriter
) const
4155 xmlTextWriterStartElement(pWriter
, BAD_CAST("svxBrushItem"));
4156 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
4157 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("color"), BAD_CAST(aColor
.AsRGBHexString().toUtf8().getStr()));
4158 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("shadingValue"), BAD_CAST(OString::number(nShadingValue
).getStr()));
4159 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("link"), BAD_CAST(maStrLink
.toUtf8().getStr()));
4160 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("filter"), BAD_CAST(maStrFilter
.toUtf8().getStr()));
4161 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("graphicPos"), BAD_CAST(OString::number(eGraphicPos
).getStr()));
4162 xmlTextWriterWriteAttribute(pWriter
, BAD_CAST("loadAgain"), BAD_CAST(OString::boolean(bLoadAgain
).getStr()));
4163 xmlTextWriterEndElement(pWriter
);
4166 // class SvxFrameDirectionItem ----------------------------------------------
4168 SvxFrameDirectionItem::SvxFrameDirectionItem( SvxFrameDirection nValue
,
4169 sal_uInt16 _nWhich
)
4170 : SfxUInt16Item( _nWhich
, (sal_uInt16
)nValue
)
4174 SvxFrameDirectionItem::~SvxFrameDirectionItem()
4178 bool SvxFrameDirectionItem::operator==( const SfxPoolItem
& rCmp
) const
4180 DBG_ASSERT( SfxPoolItem::operator==(rCmp
), "unequal types" );
4182 return GetValue() == static_cast<const SvxFrameDirectionItem
&>(rCmp
).GetValue();
4185 SfxPoolItem
* SvxFrameDirectionItem::Clone( SfxItemPool
* ) const
4187 return new SvxFrameDirectionItem( *this );
4190 SfxPoolItem
* SvxFrameDirectionItem::Create( SvStream
& rStrm
, sal_uInt16
/*nVer*/ ) const
4193 rStrm
.ReadUInt16( nValue
);
4194 return new SvxFrameDirectionItem( (SvxFrameDirection
)nValue
, Which() );
4197 SvStream
& SvxFrameDirectionItem::Store( SvStream
& rStrm
, sal_uInt16
/*nIVer*/ ) const
4199 sal_uInt16 nValue
= GetValue();
4200 rStrm
.WriteUInt16( nValue
);
4204 sal_uInt16
SvxFrameDirectionItem::GetVersion( sal_uInt16 nFVer
) const
4206 return SOFFICE_FILEFORMAT_50
> nFVer
? USHRT_MAX
: 0;
4209 bool SvxFrameDirectionItem::GetPresentation(
4210 SfxItemPresentation
/*ePres*/,
4211 SfxMapUnit
/*eCoreUnit*/,
4212 SfxMapUnit
/*ePresUnit*/,
4213 OUString
& rText
, const IntlWrapper
*) const
4215 rText
= EE_RESSTR( RID_SVXITEMS_FRMDIR_BEGIN
+ GetValue() );
4219 bool SvxFrameDirectionItem::PutValue( const com::sun::star::uno::Any
& rVal
,
4222 sal_Int16 nVal
= sal_Int16();
4223 bool bRet
= ( rVal
>>= nVal
);
4226 // translate WritingDirection2 constants into SvxFrameDirection
4229 case text::WritingMode2::LR_TB
:
4230 SetValue( FRMDIR_HORI_LEFT_TOP
);
4232 case text::WritingMode2::RL_TB
:
4233 SetValue( FRMDIR_HORI_RIGHT_TOP
);
4235 case text::WritingMode2::TB_RL
:
4236 SetValue( FRMDIR_VERT_TOP_RIGHT
);
4238 case text::WritingMode2::TB_LR
:
4239 SetValue( FRMDIR_VERT_TOP_LEFT
);
4241 case text::WritingMode2::PAGE
:
4242 SetValue( FRMDIR_ENVIRONMENT
);
4253 bool SvxFrameDirectionItem::QueryValue( com::sun::star::uno::Any
& rVal
,
4256 // translate SvxFrameDirection into WritingDirection2
4259 switch( GetValue() )
4261 case FRMDIR_HORI_LEFT_TOP
:
4262 nVal
= text::WritingMode2::LR_TB
;
4264 case FRMDIR_HORI_RIGHT_TOP
:
4265 nVal
= text::WritingMode2::RL_TB
;
4267 case FRMDIR_VERT_TOP_RIGHT
:
4268 nVal
= text::WritingMode2::TB_RL
;
4270 case FRMDIR_VERT_TOP_LEFT
:
4271 nVal
= text::WritingMode2::TB_LR
;
4273 case FRMDIR_ENVIRONMENT
:
4274 nVal
= text::WritingMode2::PAGE
;
4277 OSL_FAIL("Unknown SvxFrameDirection value!");
4282 // return value + error state
4290 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */