1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 // include ---------------------------------------------------------------
31 #include <com/sun/star/uno/Any.hxx>
32 #include <com/sun/star/drawing/LineStyle.hpp>
33 #include <com/sun/star/script/XTypeConverter.hpp>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <com/sun/star/table/ShadowLocation.hpp>
36 #include <com/sun/star/table/TableBorder.hpp>
37 #include <com/sun/star/table/ShadowFormat.hpp>
38 #include <com/sun/star/table/CellRangeAddress.hpp>
39 #include <com/sun/star/table/CellContentType.hpp>
40 #include <com/sun/star/table/TableOrientation.hpp>
41 #include <com/sun/star/util/SortField.hpp>
42 #include <com/sun/star/util/SortFieldType.hpp>
43 #include <com/sun/star/table/BorderLine2.hpp>
44 #include <com/sun/star/table/BorderLineStyle.hpp>
45 #include <com/sun/star/table/CellOrientation.hpp>
46 #include <com/sun/star/table/CellAddress.hpp>
47 #include <com/sun/star/style/PageStyleLayout.hpp>
48 #include <com/sun/star/style/BreakType.hpp>
49 #include <com/sun/star/style/GraphicLocation.hpp>
50 #include <com/sun/star/awt/Rectangle.hpp>
51 #include <com/sun/star/awt/Selection.hpp>
52 #include <com/sun/star/awt/Size.hpp>
53 #include <com/sun/star/text/WritingMode2.hpp>
54 #include <com/sun/star/frame/status/UpperLowerMarginScale.hpp>
56 #include <unotools/ucbstreamhelper.hxx>
58 #include <comphelper/processfactory.hxx>
59 #include <svtools/grfmgr.hxx>
60 #include <tools/urlobj.hxx>
61 #include <comphelper/types.hxx>
62 #include <svl/memberid.hrc>
63 #include <svtools/wallitem.hxx>
64 #include <svl/cntwall.hxx>
65 #include <svtools/borderhelper.hxx>
66 #include <rtl/ustring.hxx>
67 #include <rtl/ustrbuf.hxx>
68 #include <vcl/graphicfilter.hxx>
70 #define _SVX_FRMITEMS_CXX
72 #include <editeng/editids.hrc>
73 #include <editeng/editrids.hrc>
74 #include <editeng/pbinitem.hxx>
75 #include <editeng/sizeitem.hxx>
76 #include <editeng/lrspitem.hxx>
77 #include <editeng/ulspitem.hxx>
78 #include <editeng/prntitem.hxx>
79 #include <editeng/opaqitem.hxx>
80 #include <editeng/protitem.hxx>
81 #include <editeng/shaditem.hxx>
82 #include <editeng/boxitem.hxx>
83 #include <editeng/brkitem.hxx>
84 #include <editeng/keepitem.hxx>
85 #include <editeng/bolnitem.hxx>
86 #include <editeng/brshitem.hxx>
87 #include <editeng/frmdiritem.hxx>
88 #include <editeng/itemtype.hxx>
89 #include <editeng/eerdll.hxx>
90 #include <editeng/unoprnms.hxx>
91 #include <editeng/memberids.hrc>
92 #include <editeng/editerr.hxx>
94 using namespace ::editeng
;
95 using namespace ::rtl
;
96 using namespace ::com::sun::star
;
97 using namespace ::com::sun::star::table::BorderLineStyle
;
100 // Conversion for UNO
101 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
102 #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
103 #define TWIP_TO_MM100_UNSIGNED(TWIP) ((((TWIP)*127L+36L)/72L))
104 #define MM100_TO_TWIP_UNSIGNED(MM100) ((((MM100)*72L+63L)/127L))
106 // STATIC DATA -----------------------------------------------------------
108 inline void SetValueProp( XubString
& rStr
, const sal_uInt16 nValue
,
109 const sal_uInt16 nProp
)
112 rStr
+= String::CreateFromInt32( nValue
);
114 ( rStr
+= String::CreateFromInt32( nProp
)) += sal_Unicode('%');
117 inline void SetValueProp( XubString
& rStr
, const short nValue
,
118 const sal_uInt16 nProp
)
121 rStr
+= String::CreateFromInt32( nValue
);
123 ( rStr
+= String::CreateFromInt32( nProp
)) += sal_Unicode('%');
126 // -----------------------------------------------------------------------
129 SvxBorderLine is not an SfxPoolItem, and has no Store/Create serialization/deserialization methods.
130 Since border line information needs to be serialized by the table autoformat code, these file-local
131 methods are defined to encapsulate the necessary serialization logic.
135 /// Item version for saved border lines. The old version saves the line without style information.
136 const int BORDER_LINE_OLD_VERSION
= 0;
137 /// Item version for saved border lies. The new version includes line style.
138 const int BORDER_LINE_WITH_STYLE_VERSION
= 1;
140 /// Store a border line to a stream.
141 SvStream
& StoreBorderLine(SvStream
&stream
, const SvxBorderLine
&l
, sal_uInt16 version
)
143 stream
<< l
.GetColor()
148 if (version
>= BORDER_LINE_WITH_STYLE_VERSION
)
149 stream
<< static_cast<sal_uInt16
>(l
.GetBorderLineStyle());
154 /// Creates a border line from a stream.
155 SvxBorderLine
CreateBorderLine(SvStream
&stream
, sal_uInt16 version
)
157 sal_uInt16 nOutline
, nInline
, nDistance
;
158 sal_uInt16 nStyle
= NONE
;
160 stream
>> aColor
>> nOutline
>> nInline
>> nDistance
;
162 if (version
>= BORDER_LINE_WITH_STYLE_VERSION
)
165 SvxBorderLine
border(&aColor
);
166 border
.GuessLinesWidths(nStyle
, nOutline
, nInline
, nDistance
);
170 /// Retrieves a BORDER_LINE_* version from a BOX_BORDER_* version.
171 sal_uInt16
BorderLineVersionFromBoxVersion(sal_uInt16 boxVersion
)
173 return (boxVersion
>= BOX_BORDER_STYLE_VERSION
)? BORDER_LINE_WITH_STYLE_VERSION
: BORDER_LINE_OLD_VERSION
;
177 TYPEINIT1_FACTORY(SvxPaperBinItem
, SfxByteItem
, new SvxPaperBinItem(0));
178 TYPEINIT1_FACTORY(SvxSizeItem
, SfxPoolItem
, new SvxSizeItem(0));
179 TYPEINIT1_FACTORY(SvxLRSpaceItem
, SfxPoolItem
, new SvxLRSpaceItem(0));
180 TYPEINIT1_FACTORY(SvxULSpaceItem
, SfxPoolItem
, new SvxULSpaceItem(0));
181 TYPEINIT1_FACTORY(SvxPrintItem
, SfxBoolItem
, new SvxPrintItem(0));
182 TYPEINIT1_FACTORY(SvxOpaqueItem
, SfxBoolItem
, new SvxOpaqueItem(0));
183 TYPEINIT1_FACTORY(SvxProtectItem
, SfxPoolItem
, new SvxProtectItem(0));
184 TYPEINIT1_FACTORY(SvxBrushItem
, SfxPoolItem
, new SvxBrushItem(0));
185 TYPEINIT1_FACTORY(SvxShadowItem
, SfxPoolItem
, new SvxShadowItem(0));
186 TYPEINIT1_FACTORY(SvxBoxItem
, SfxPoolItem
, new SvxBoxItem(0));
187 TYPEINIT1_FACTORY(SvxBoxInfoItem
, SfxPoolItem
, new SvxBoxInfoItem(0));
188 TYPEINIT1_FACTORY(SvxFmtBreakItem
, SfxEnumItem
, new SvxFmtBreakItem(SVX_BREAK_NONE
, 0));
189 TYPEINIT1_FACTORY(SvxFmtKeepItem
, SfxBoolItem
, new SvxFmtKeepItem(sal_False
, 0));
190 TYPEINIT1_FACTORY(SvxLineItem
, SfxPoolItem
, new SvxLineItem(0));
191 TYPEINIT1_FACTORY(SvxFrameDirectionItem
, SfxUInt16Item
, new SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP
, 0));
193 // class SvxPaperBinItem ------------------------------------------------
195 SfxPoolItem
* SvxPaperBinItem::Clone( SfxItemPool
* ) const
197 return new SvxPaperBinItem( *this );
200 // -----------------------------------------------------------------------
202 SvStream
& SvxPaperBinItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
208 // -----------------------------------------------------------------------
210 SfxPoolItem
* SvxPaperBinItem::Create( SvStream
& rStrm
, sal_uInt16
) const
214 return new SvxPaperBinItem( Which(), nBin
);
217 // -----------------------------------------------------------------------
219 SfxItemPresentation
SvxPaperBinItem::GetPresentation
221 SfxItemPresentation ePres
,
222 SfxMapUnit
/*eCoreUnit*/,
223 SfxMapUnit
/*ePresUnit*/,
224 XubString
& rText
, const IntlWrapper
*
229 case SFX_ITEM_PRESENTATION_NONE
:
231 return SFX_ITEM_PRESENTATION_NONE
;
233 case SFX_ITEM_PRESENTATION_NAMELESS
:
234 rText
= String::CreateFromInt32( GetValue() );
235 return SFX_ITEM_PRESENTATION_NAMELESS
;
237 case SFX_ITEM_PRESENTATION_COMPLETE
:
239 sal_uInt8 nValue
= GetValue();
241 if ( PAPERBIN_PRINTER_SETTINGS
== nValue
)
242 rText
= EE_RESSTR(RID_SVXSTR_PAPERBIN_SETTINGS
);
245 rText
= EE_RESSTR(RID_SVXSTR_PAPERBIN
);
246 rText
+= sal_Unicode(' ');
247 rText
+= String::CreateFromInt32( nValue
);
249 return SFX_ITEM_PRESENTATION_COMPLETE
;
252 default: ;//prevent warning
255 return SFX_ITEM_PRESENTATION_NONE
;
258 // class SvxSizeItem -----------------------------------------------------
260 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId
, const Size
& rSize
) :
268 // -----------------------------------------------------------------------
269 bool SvxSizeItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
271 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
272 nMemberId
&= ~CONVERT_TWIPS
;
274 awt::Size
aTmp(aSize
.Width(), aSize
.Height());
277 aTmp
.Height
= TWIP_TO_MM100(aTmp
.Height
);
278 aTmp
.Width
= TWIP_TO_MM100(aTmp
.Width
);
283 case MID_SIZE_SIZE
: rVal
<<= aTmp
; break;
284 case MID_SIZE_WIDTH
: rVal
<<= aTmp
.Width
; break;
285 case MID_SIZE_HEIGHT
: rVal
<<= aTmp
.Height
; break;
286 default: OSL_FAIL("Wrong MemberId!"); return false;
291 // -----------------------------------------------------------------------
292 bool SvxSizeItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
294 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
295 nMemberId
&= ~CONVERT_TWIPS
;
306 aTmp
.Height
= MM100_TO_TWIP(aTmp
.Height
);
307 aTmp
.Width
= MM100_TO_TWIP(aTmp
.Width
);
309 aSize
= Size( aTmp
.Width
, aTmp
.Height
);
320 if(!(rVal
>>= nVal
))
323 aSize
.Width() = bConvert
? MM100_TO_TWIP(nVal
) : nVal
;
326 case MID_SIZE_HEIGHT
:
332 aSize
.Height() = bConvert
? MM100_TO_TWIP(nVal
) : nVal
;
335 default: OSL_FAIL("Wrong MemberId!");
341 // -----------------------------------------------------------------------
343 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId
) :
349 // -----------------------------------------------------------------------
351 int SvxSizeItem::operator==( const SfxPoolItem
& rAttr
) const
353 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
355 return ( aSize
== ( (SvxSizeItem
&)rAttr
).GetSize() );
358 // -----------------------------------------------------------------------
360 SfxPoolItem
* SvxSizeItem::Clone( SfxItemPool
* ) const
362 return new SvxSizeItem( *this );
365 //------------------------------------------------------------------------
367 SfxItemPresentation
SvxSizeItem::GetPresentation
369 SfxItemPresentation ePres
,
370 SfxMapUnit eCoreUnit
,
371 SfxMapUnit ePresUnit
,
372 XubString
& rText
, const IntlWrapper
*pIntl
377 case SFX_ITEM_PRESENTATION_NONE
:
379 return SFX_ITEM_PRESENTATION_NONE
;
381 case SFX_ITEM_PRESENTATION_NAMELESS
:
382 rText
= GetMetricText( aSize
.Width(), eCoreUnit
, ePresUnit
, pIntl
);
384 rText
+= GetMetricText( aSize
.Height(), eCoreUnit
, ePresUnit
, pIntl
);
385 return SFX_ITEM_PRESENTATION_NAMELESS
;
387 case SFX_ITEM_PRESENTATION_COMPLETE
:
388 rText
= EE_RESSTR(RID_SVXITEMS_SIZE_WIDTH
);
389 rText
+= GetMetricText( aSize
.Width(), eCoreUnit
, ePresUnit
, pIntl
);
390 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
392 rText
+= EE_RESSTR(RID_SVXITEMS_SIZE_HEIGHT
);
393 rText
+= GetMetricText( aSize
.Height(), eCoreUnit
, ePresUnit
, pIntl
);
394 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
395 return SFX_ITEM_PRESENTATION_COMPLETE
;
397 default: ;//prevent warning
400 return SFX_ITEM_PRESENTATION_NONE
;
403 // -----------------------------------------------------------------------
405 SvStream
& SvxSizeItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
407 //#fdo39428 SvStream no longer supports operator<<(long)
408 rStrm
<< sal::static_int_cast
<sal_Int32
>(aSize
.Width());
409 rStrm
<< sal::static_int_cast
<sal_Int32
>(aSize
.Height());
413 // -----------------------------------------------------------------------
415 bool SvxSizeItem::ScaleMetrics( long nMult
, long nDiv
)
417 aSize
.Width() = Scale( aSize
.Width(), nMult
, nDiv
);
418 aSize
.Height() = Scale( aSize
.Height(), nMult
, nDiv
);
422 // -----------------------------------------------------------------------
424 bool SvxSizeItem::HasMetrics() const
429 // -----------------------------------------------------------------------
431 SfxPoolItem
* SvxSizeItem::Create( SvStream
& rStrm
, sal_uInt16
) const
433 //#fdo39428 SvStream no longer supports operator>>(long&)
434 sal_Int32
nWidth(0), nHeight(0);
435 rStrm
>> nWidth
>> nHeight
;
437 SvxSizeItem
* pAttr
= new SvxSizeItem( Which() );
438 pAttr
->SetSize(Size(nWidth
, nHeight
));
443 // class SvxLRSpaceItem --------------------------------------------------
445 SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId
) :
449 nFirstLineOfst ( 0 ),
453 nPropFirstLineOfst( 100 ),
454 nPropLeftMargin( 100 ),
455 nPropRightMargin( 100 ),
460 // -----------------------------------------------------------------------
462 SvxLRSpaceItem::SvxLRSpaceItem( const long nLeft
, const long nRight
,
463 const long nTLeft
, const short nOfset
,
464 const sal_uInt16 nId
) :
468 nFirstLineOfst ( nOfset
),
470 nLeftMargin ( nLeft
),
471 nRightMargin ( nRight
),
472 nPropFirstLineOfst( 100 ),
473 nPropLeftMargin( 100 ),
474 nPropRightMargin( 100 ),
479 // -----------------------------------------------------------------------
480 bool SvxLRSpaceItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
483 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
484 nMemberId
&= ~CONVERT_TWIPS
;
489 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100(nLeftMargin
) : nLeftMargin
);
492 case MID_TXT_LMARGIN
:
493 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100(nTxtLeft
) : nTxtLeft
);
496 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100(nRightMargin
) : nRightMargin
);
498 case MID_L_REL_MARGIN
:
499 rVal
<<= (sal_Int16
)nPropLeftMargin
;
501 case MID_R_REL_MARGIN
:
502 rVal
<<= (sal_Int16
)nPropRightMargin
;
505 case MID_FIRST_LINE_INDENT
:
506 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100(nFirstLineOfst
) : nFirstLineOfst
);
509 case MID_FIRST_LINE_REL_INDENT
:
510 rVal
<<= (sal_Int16
)(nPropFirstLineOfst
);
514 rVal
= Bool2Any(IsAutoFirst());
519 OSL_FAIL("unknown MemberId");
524 // -----------------------------------------------------------------------
525 bool SvxLRSpaceItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
527 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
528 nMemberId
&= ~CONVERT_TWIPS
;
530 if( nMemberId
!= MID_FIRST_AUTO
&&
531 nMemberId
!= MID_L_REL_MARGIN
&& nMemberId
!= MID_R_REL_MARGIN
)
538 SetLeft((sal_Int32
)bConvert
? MM100_TO_TWIP(nVal
) : nVal
);
541 case MID_TXT_LMARGIN
:
542 SetTxtLeft((sal_Int32
)bConvert
? MM100_TO_TWIP(nVal
) : nVal
);
546 SetRight((sal_Int32
) bConvert
? MM100_TO_TWIP(nVal
) : nVal
);
548 case MID_L_REL_MARGIN
:
549 case MID_R_REL_MARGIN
:
552 if((rVal
>>= nRel
) && nRel
>= 0 && nRel
< USHRT_MAX
)
554 if(MID_L_REL_MARGIN
== nMemberId
)
555 nPropLeftMargin
= (sal_uInt16
)nRel
;
557 nPropRightMargin
= (sal_uInt16
)nRel
;
563 case MID_FIRST_LINE_INDENT
:
564 SetTxtFirstLineOfst((short)(bConvert
? MM100_TO_TWIP(nVal
) : nVal
));
567 case MID_FIRST_LINE_REL_INDENT
:
568 SetPropTxtFirstLineOfst ( (sal_uInt16
)nVal
);
572 SetAutoFirst( Any2Bool(rVal
) );
576 OSL_FAIL("unknown MemberId");
582 // -----------------------------------------------------------------------
584 // Adapt nLeftMargin and nTxtLeft.
586 void SvxLRSpaceItem::AdjustLeft()
588 if ( 0 > nFirstLineOfst
)
589 nLeftMargin
= nTxtLeft
+ nFirstLineOfst
;
591 nLeftMargin
= nTxtLeft
;
594 // -----------------------------------------------------------------------
596 int SvxLRSpaceItem::operator==( const SfxPoolItem
& rAttr
) const
598 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
601 nLeftMargin
== ((SvxLRSpaceItem
&)rAttr
).GetLeft() &&
602 nRightMargin
== ((SvxLRSpaceItem
&)rAttr
).GetRight() &&
603 nFirstLineOfst
== ((SvxLRSpaceItem
&)rAttr
).GetTxtFirstLineOfst() &&
604 nPropLeftMargin
== ((SvxLRSpaceItem
&)rAttr
).GetPropLeft() &&
605 nPropRightMargin
== ((SvxLRSpaceItem
&)rAttr
).GetPropRight() &&
606 nPropFirstLineOfst
== ((SvxLRSpaceItem
&)rAttr
).GetPropTxtFirstLineOfst() &&
607 bAutoFirst
== ((SvxLRSpaceItem
&)rAttr
).IsAutoFirst() );
610 // -----------------------------------------------------------------------
612 SfxPoolItem
* SvxLRSpaceItem::Clone( SfxItemPool
* ) const
614 return new SvxLRSpaceItem( *this );
617 //------------------------------------------------------------------------
619 SfxItemPresentation
SvxLRSpaceItem::GetPresentation
621 SfxItemPresentation ePres
,
622 SfxMapUnit eCoreUnit
,
623 SfxMapUnit ePresUnit
,
624 XubString
& rText
, const IntlWrapper
* pIntl
629 case SFX_ITEM_PRESENTATION_NONE
:
631 return SFX_ITEM_PRESENTATION_NONE
;
632 case SFX_ITEM_PRESENTATION_NAMELESS
:
634 if ( 100 != nPropLeftMargin
)
635 ( rText
= String::CreateFromInt32( nPropLeftMargin
)) += sal_Unicode('%');
637 rText
= GetMetricText( (long)nLeftMargin
,
638 eCoreUnit
, ePresUnit
, pIntl
);
640 if ( 100 != nPropFirstLineOfst
)
641 ( rText
+= String::CreateFromInt32( nPropFirstLineOfst
)) += sal_Unicode('%');
643 rText
+= GetMetricText( (long)nFirstLineOfst
,
644 eCoreUnit
, ePresUnit
, pIntl
);
646 if ( 100 != nRightMargin
)
647 ( rText
+= String::CreateFromInt32( nRightMargin
)) += sal_Unicode('%');
649 rText
+= GetMetricText( (long)nRightMargin
,
650 eCoreUnit
, ePresUnit
, pIntl
);
651 return SFX_ITEM_PRESENTATION_NAMELESS
;
653 case SFX_ITEM_PRESENTATION_COMPLETE
:
655 rText
= EE_RESSTR(RID_SVXITEMS_LRSPACE_LEFT
);
656 if ( 100 != nPropLeftMargin
)
657 ( rText
+= String::CreateFromInt32( nPropLeftMargin
)) += sal_Unicode('%');
660 rText
+= GetMetricText( (long)nLeftMargin
,
661 eCoreUnit
, ePresUnit
, pIntl
);
662 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
665 if ( 100 != nPropFirstLineOfst
|| nFirstLineOfst
)
667 rText
+= EE_RESSTR(RID_SVXITEMS_LRSPACE_FLINE
);
668 if ( 100 != nPropFirstLineOfst
)
669 ( rText
+= String::CreateFromInt32( nPropFirstLineOfst
))
673 rText
+= GetMetricText( (long)nFirstLineOfst
,
674 eCoreUnit
, ePresUnit
, pIntl
);
675 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
679 rText
+= EE_RESSTR(RID_SVXITEMS_LRSPACE_RIGHT
);
680 if ( 100 != nPropRightMargin
)
681 ( rText
+= String::CreateFromInt32( nPropRightMargin
)) += sal_Unicode('%');
684 rText
+= GetMetricText( (long)nRightMargin
,
685 eCoreUnit
, ePresUnit
, pIntl
);
686 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
688 return SFX_ITEM_PRESENTATION_COMPLETE
;
690 default: ;//prevent warning
692 return SFX_ITEM_PRESENTATION_NONE
;
695 // -----------------------------------------------------------------------
697 // BulletFI: Before 501 in the Outliner the bullet was not on the position of
698 // the FI, so in older documents one must set FI to 0.
699 #define BULLETLR_MARKER 0x599401FE
701 SvStream
& SvxLRSpaceItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
703 short nSaveFI
= nFirstLineOfst
;
704 ((SvxLRSpaceItem
*)this)->SetTxtFirstLineOfst( 0 ); // nLeftMargin is manipulated together with this, see Create()
706 sal_uInt16 nMargin
= 0;
707 if( nLeftMargin
> 0 )
708 nMargin
= sal_uInt16( nLeftMargin
);
710 rStrm
<< nPropLeftMargin
;
711 if( nRightMargin
> 0 )
712 nMargin
= sal_uInt16( nRightMargin
);
716 rStrm
<< nPropRightMargin
;
717 rStrm
<< nFirstLineOfst
;
718 rStrm
<< nPropFirstLineOfst
;
720 nMargin
= sal_uInt16( nTxtLeft
);
724 if( nItemVersion
>= LRSPACE_AUTOFIRST_VERSION
)
726 sal_Int8 nAutoFirst
= bAutoFirst
? 1 : 0;
727 if( nItemVersion
>= LRSPACE_NEGATIVE_VERSION
&&
728 ( nLeftMargin
< 0 || nRightMargin
< 0 || nTxtLeft
< 0 ) )
732 // From 6.0 onwards, do not write Magic numbers...
733 DBG_ASSERT( rStrm
.GetVersion() <= SOFFICE_FILEFORMAT_50
, "Change File format SvxLRSpaceItem!" );
734 rStrm
<< (sal_uInt32
) BULLETLR_MARKER
;
737 if( 0x80 & nAutoFirst
)
739 rStrm
<< static_cast<sal_Int32
>(nLeftMargin
);
740 rStrm
<< static_cast<sal_Int32
>(nRightMargin
);
744 ((SvxLRSpaceItem
*)this)->SetTxtFirstLineOfst( nSaveFI
);
749 // -----------------------------------------------------------------------
751 SfxPoolItem
* SvxLRSpaceItem::Create( SvStream
& rStrm
, sal_uInt16 nVersion
) const
753 sal_uInt16 left
, prpleft
, right
, prpright
, prpfirstline
, txtleft
;
755 sal_Int8 autofirst
= 0;
757 if ( nVersion
>= LRSPACE_AUTOFIRST_VERSION
)
759 rStrm
>> left
>> prpleft
>> right
>> prpright
>> firstline
>>
760 prpfirstline
>> txtleft
>> autofirst
;
762 sal_uInt32 nPos
= rStrm
.Tell();
765 if ( nMarker
== BULLETLR_MARKER
)
769 left
= left
+ static_cast<sal_uInt16
>(firstline
); // see below: txtleft = ...
774 else if ( nVersion
== LRSPACE_TXTLEFT_VERSION
)
776 rStrm
>> left
>> prpleft
>> right
>> prpright
>> firstline
>>
777 prpfirstline
>> txtleft
;
779 else if ( nVersion
== LRSPACE_16_VERSION
)
781 rStrm
>> left
>> prpleft
>> right
>> prpright
>> firstline
>>
786 sal_Int8 nL
, nR
, nFL
;
787 rStrm
>> left
>> nL
>> right
>> nR
>> firstline
>> nFL
;
788 prpleft
= (sal_uInt16
)nL
;
789 prpright
= (sal_uInt16
)nR
;
790 prpfirstline
= (sal_uInt16
)nFL
;
793 txtleft
= firstline
>= 0 ? left
: left
- firstline
;
794 SvxLRSpaceItem
* pAttr
= new SvxLRSpaceItem( Which() );
796 pAttr
->nLeftMargin
= left
;
797 pAttr
->nPropLeftMargin
= prpleft
;
798 pAttr
->nRightMargin
= right
;
799 pAttr
->nPropRightMargin
= prpright
;
800 pAttr
->nFirstLineOfst
= firstline
;
801 pAttr
->nPropFirstLineOfst
= prpfirstline
;
802 pAttr
->nTxtLeft
= txtleft
;
803 pAttr
->bAutoFirst
= autofirst
& 0x01;
804 if( nVersion
>= LRSPACE_NEGATIVE_VERSION
&& ( autofirst
& 0x80 ) )
808 pAttr
->nLeftMargin
= nMargin
;
809 pAttr
->nTxtLeft
= firstline
>= 0 ? nMargin
: nMargin
- firstline
;
811 pAttr
->nRightMargin
= nMargin
;
816 // -----------------------------------------------------------------------
818 sal_uInt16
SvxLRSpaceItem::GetVersion( sal_uInt16 nFileVersion
) const
820 return (nFileVersion
== SOFFICE_FILEFORMAT_31
)
821 ? LRSPACE_TXTLEFT_VERSION
822 : LRSPACE_NEGATIVE_VERSION
;
825 // -----------------------------------------------------------------------
827 bool SvxLRSpaceItem::ScaleMetrics( long nMult
, long nDiv
)
829 nFirstLineOfst
= (short)Scale( nFirstLineOfst
, nMult
, nDiv
);
830 nTxtLeft
= Scale( nTxtLeft
, nMult
, nDiv
);
831 nLeftMargin
= Scale( nLeftMargin
, nMult
, nDiv
);
832 nRightMargin
= Scale( nRightMargin
, nMult
, nDiv
);
836 // -----------------------------------------------------------------------
838 bool SvxLRSpaceItem::HasMetrics() const
843 // class SvxULSpaceItem --------------------------------------------------
845 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nId
)
855 // -----------------------------------------------------------------------
857 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nUp
, const sal_uInt16 nLow
,
858 const sal_uInt16 nId
)
868 // -----------------------------------------------------------------------
869 bool SvxULSpaceItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
871 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
872 nMemberId
&= ~CONVERT_TWIPS
;
878 ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale
;
879 aUpperLowerMarginScale
.Upper
= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nUpper
) : nUpper
);
880 aUpperLowerMarginScale
.Lower
= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nLower
) : nPropUpper
);
881 aUpperLowerMarginScale
.ScaleUpper
= (sal_Int16
)nPropUpper
;
882 aUpperLowerMarginScale
.ScaleLower
= (sal_Int16
)nPropLower
;
883 rVal
<<= aUpperLowerMarginScale
;
886 case MID_UP_MARGIN
: rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nUpper
) : nUpper
); break;
887 case MID_LO_MARGIN
: rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nLower
) : nLower
); break;
888 case MID_CTX_MARGIN
: rVal
<<= bContext
; break;
889 case MID_UP_REL_MARGIN
: rVal
<<= (sal_Int16
) nPropUpper
; break;
890 case MID_LO_REL_MARGIN
: rVal
<<= (sal_Int16
) nPropLower
; break;
895 // -----------------------------------------------------------------------
896 bool SvxULSpaceItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
898 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
899 nMemberId
&= ~CONVERT_TWIPS
;
906 ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale
;
907 if ( !(rVal
>>= aUpperLowerMarginScale
))
910 SetUpper((sal_uInt16
)(bConvert
? MM100_TO_TWIP( aUpperLowerMarginScale
.Upper
) : aUpperLowerMarginScale
.Upper
));
911 SetLower((sal_uInt16
)(bConvert
? MM100_TO_TWIP( aUpperLowerMarginScale
.Lower
) : aUpperLowerMarginScale
.Lower
));
912 if( aUpperLowerMarginScale
.ScaleUpper
> 1 )
913 nPropUpper
= aUpperLowerMarginScale
.ScaleUpper
;
914 if( aUpperLowerMarginScale
.ScaleLower
> 1 )
915 nPropUpper
= aUpperLowerMarginScale
.ScaleLower
;
920 if(!(rVal
>>= nVal
) || nVal
< 0)
922 SetUpper((sal_uInt16
)(bConvert
? MM100_TO_TWIP(nVal
) : nVal
));
925 if(!(rVal
>>= nVal
) || nVal
< 0)
927 SetLower((sal_uInt16
)(bConvert
? MM100_TO_TWIP(nVal
) : nVal
));
929 case MID_CTX_MARGIN
:
930 if (!(rVal
>>= bVal
))
932 SetContextValue(bVal
);
934 case MID_UP_REL_MARGIN
:
935 case MID_LO_REL_MARGIN
:
938 if((rVal
>>= nRel
) && nRel
> 1 )
940 if(MID_UP_REL_MARGIN
== nMemberId
)
941 nPropUpper
= (sal_uInt16
)nRel
;
943 nPropLower
= (sal_uInt16
)nRel
;
951 OSL_FAIL("unknown MemberId");
957 // -----------------------------------------------------------------------
959 int SvxULSpaceItem::operator==( const SfxPoolItem
& rAttr
) const
961 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
963 return ( nUpper
== ( (SvxULSpaceItem
&)rAttr
).nUpper
&&
964 nLower
== ( (SvxULSpaceItem
&)rAttr
).nLower
&&
965 bContext
== ( (SvxULSpaceItem
&)rAttr
).bContext
&&
966 nPropUpper
== ( (SvxULSpaceItem
&)rAttr
).nPropUpper
&&
967 nPropLower
== ( (SvxULSpaceItem
&)rAttr
).nPropLower
);
970 // -----------------------------------------------------------------------
972 SfxPoolItem
* SvxULSpaceItem::Clone( SfxItemPool
* ) const
974 return new SvxULSpaceItem( *this );
977 //------------------------------------------------------------------------
979 SfxItemPresentation
SvxULSpaceItem::GetPresentation
981 SfxItemPresentation ePres
,
982 SfxMapUnit eCoreUnit
,
983 SfxMapUnit ePresUnit
,
984 XubString
& rText
, const IntlWrapper
*pIntl
989 case SFX_ITEM_PRESENTATION_NONE
:
991 return SFX_ITEM_PRESENTATION_NONE
;
992 case SFX_ITEM_PRESENTATION_NAMELESS
:
994 if ( 100 != nPropUpper
)
995 ( rText
= String::CreateFromInt32( nPropUpper
)) += sal_Unicode('%');
997 rText
= GetMetricText( (long)nUpper
, eCoreUnit
, ePresUnit
, pIntl
);
999 if ( 100 != nPropLower
)
1000 ( rText
+= String::CreateFromInt32( nPropLower
)) += sal_Unicode('%');
1002 rText
+= GetMetricText( (long)nLower
, eCoreUnit
, ePresUnit
, pIntl
);
1003 return SFX_ITEM_PRESENTATION_NAMELESS
;
1005 case SFX_ITEM_PRESENTATION_COMPLETE
:
1007 rText
= EE_RESSTR(RID_SVXITEMS_ULSPACE_UPPER
);
1008 if ( 100 != nPropUpper
)
1009 ( rText
+= String::CreateFromInt32( nPropUpper
)) += sal_Unicode('%');
1012 rText
+= GetMetricText( (long)nUpper
, eCoreUnit
, ePresUnit
, pIntl
);
1013 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
1016 rText
+= EE_RESSTR(RID_SVXITEMS_ULSPACE_LOWER
);
1017 if ( 100 != nPropLower
)
1018 ( rText
+= String::CreateFromInt32( nPropLower
)) += sal_Unicode('%');
1021 rText
+= GetMetricText( (long)nLower
, eCoreUnit
, ePresUnit
, pIntl
);
1022 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
1024 return SFX_ITEM_PRESENTATION_COMPLETE
;
1026 default: ;//prevent warning
1028 return SFX_ITEM_PRESENTATION_NONE
;
1031 // -----------------------------------------------------------------------
1033 SvStream
& SvxULSpaceItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1042 // -----------------------------------------------------------------------
1044 SfxPoolItem
* SvxULSpaceItem::Create( SvStream
& rStrm
, sal_uInt16 nVersion
) const
1046 sal_uInt16 upper
, lower
, nPL
= 0, nPU
= 0;
1048 if ( nVersion
== ULSPACE_16_VERSION
)
1049 rStrm
>> upper
>> nPU
>> lower
>> nPL
;
1053 rStrm
>> upper
>> nU
>> lower
>> nL
;
1054 nPL
= (sal_uInt16
)nL
;
1055 nPU
= (sal_uInt16
)nU
;
1058 SvxULSpaceItem
* pAttr
= new SvxULSpaceItem( Which() );
1059 pAttr
->SetUpperValue( upper
);
1060 pAttr
->SetLowerValue( lower
);
1061 pAttr
->SetPropUpper( nPU
);
1062 pAttr
->SetPropLower( nPL
);
1066 // -----------------------------------------------------------------------
1068 sal_uInt16
SvxULSpaceItem::GetVersion( sal_uInt16
/*nFileVersion*/ ) const
1070 return ULSPACE_16_VERSION
;
1073 // -----------------------------------------------------------------------
1075 bool SvxULSpaceItem::ScaleMetrics( long nMult
, long nDiv
)
1077 nUpper
= (sal_uInt16
)Scale( nUpper
, nMult
, nDiv
);
1078 nLower
= (sal_uInt16
)Scale( nLower
, nMult
, nDiv
);
1082 // -----------------------------------------------------------------------
1084 bool SvxULSpaceItem::HasMetrics() const
1089 // class SvxPrintItem ----------------------------------------------------
1091 SfxPoolItem
* SvxPrintItem::Clone( SfxItemPool
* ) const
1093 return new SvxPrintItem( *this );
1096 // -----------------------------------------------------------------------
1098 SvStream
& SvxPrintItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1100 rStrm
<< (sal_Int8
)GetValue();
1104 // -----------------------------------------------------------------------
1106 SfxPoolItem
* SvxPrintItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1110 return new SvxPrintItem( Which(), sal_Bool( bIsPrint
!= 0 ) );
1113 //------------------------------------------------------------------------
1115 SfxItemPresentation
SvxPrintItem::GetPresentation
1117 SfxItemPresentation ePres
,
1118 SfxMapUnit
/*eCoreUnit*/,
1119 SfxMapUnit
/*ePresUnit*/,
1120 XubString
& rText
, const IntlWrapper
*
1125 case SFX_ITEM_PRESENTATION_NONE
:
1129 case SFX_ITEM_PRESENTATION_NAMELESS
:
1130 case SFX_ITEM_PRESENTATION_COMPLETE
:
1132 sal_uInt16 nId
= RID_SVXITEMS_PRINT_FALSE
;
1135 nId
= RID_SVXITEMS_PRINT_TRUE
;
1136 rText
= EE_RESSTR(nId
);
1139 default: ;//prevent warning
1141 return SFX_ITEM_PRESENTATION_NONE
;
1144 // class SvxOpaqueItem ---------------------------------------------------
1146 SfxPoolItem
* SvxOpaqueItem::Clone( SfxItemPool
* ) const
1148 return new SvxOpaqueItem( *this );
1151 // -----------------------------------------------------------------------
1153 SvStream
& SvxOpaqueItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1155 rStrm
<< (sal_Int8
)GetValue();
1159 // -----------------------------------------------------------------------
1161 SfxPoolItem
* SvxOpaqueItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1165 return new SvxOpaqueItem( Which(), sal_Bool( bIsOpaque
!= 0 ) );
1168 //------------------------------------------------------------------------
1170 SfxItemPresentation
SvxOpaqueItem::GetPresentation
1172 SfxItemPresentation ePres
,
1173 SfxMapUnit
/*eCoreUnit*/,
1174 SfxMapUnit
/*ePresUnit*/,
1175 XubString
& rText
, const IntlWrapper
*
1180 case SFX_ITEM_PRESENTATION_NONE
:
1184 case SFX_ITEM_PRESENTATION_NAMELESS
:
1185 case SFX_ITEM_PRESENTATION_COMPLETE
:
1187 sal_uInt16 nId
= RID_SVXITEMS_OPAQUE_FALSE
;
1190 nId
= RID_SVXITEMS_OPAQUE_TRUE
;
1191 rText
= EE_RESSTR(nId
);
1194 default: ;//prevent warning
1196 return SFX_ITEM_PRESENTATION_NONE
;
1199 // class SvxProtectItem --------------------------------------------------
1201 int SvxProtectItem::operator==( const SfxPoolItem
& rAttr
) const
1203 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1205 return ( bCntnt
== ( (SvxProtectItem
&)rAttr
).bCntnt
&&
1206 bSize
== ( (SvxProtectItem
&)rAttr
).bSize
&&
1207 bPos
== ( (SvxProtectItem
&)rAttr
).bPos
);
1210 bool SvxProtectItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1212 nMemberId
&= ~CONVERT_TWIPS
;
1216 case MID_PROTECT_CONTENT
: bValue
= bCntnt
; break;
1217 case MID_PROTECT_SIZE
: bValue
= bSize
; break;
1218 case MID_PROTECT_POSITION
: bValue
= bPos
; break;
1220 OSL_FAIL("Wrong MemberId");
1224 rVal
= Bool2Any( bValue
);
1228 bool SvxProtectItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1230 nMemberId
&= ~CONVERT_TWIPS
;
1231 sal_Bool
bVal( Any2Bool(rVal
) );
1234 case MID_PROTECT_CONTENT
: bCntnt
= bVal
; break;
1235 case MID_PROTECT_SIZE
: bSize
= bVal
; break;
1236 case MID_PROTECT_POSITION
: bPos
= bVal
; break;
1238 OSL_FAIL("Wrong MemberId");
1244 // -----------------------------------------------------------------------
1246 SfxPoolItem
* SvxProtectItem::Clone( SfxItemPool
* ) const
1248 return new SvxProtectItem( *this );
1251 //------------------------------------------------------------------------
1253 SfxItemPresentation
SvxProtectItem::GetPresentation
1255 SfxItemPresentation ePres
,
1256 SfxMapUnit
/*eCoreUnit*/,
1257 SfxMapUnit
/*ePresUnit*/,
1258 XubString
& rText
, const IntlWrapper
*
1263 case SFX_ITEM_PRESENTATION_NONE
:
1267 case SFX_ITEM_PRESENTATION_NAMELESS
:
1268 case SFX_ITEM_PRESENTATION_COMPLETE
:
1270 sal_uInt16 nId
= RID_SVXITEMS_PROT_CONTENT_FALSE
;
1273 nId
= RID_SVXITEMS_PROT_CONTENT_TRUE
;
1274 rText
= EE_RESSTR(nId
);
1276 nId
= RID_SVXITEMS_PROT_SIZE_FALSE
;
1279 nId
= RID_SVXITEMS_PROT_SIZE_TRUE
;
1280 rText
+= EE_RESSTR(nId
);
1282 nId
= RID_SVXITEMS_PROT_POS_FALSE
;
1285 nId
= RID_SVXITEMS_PROT_POS_TRUE
;
1286 rText
+= EE_RESSTR(nId
);
1289 default: ;//prevent warning
1291 return SFX_ITEM_PRESENTATION_NONE
;
1294 // -----------------------------------------------------------------------
1296 SvStream
& SvxProtectItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1299 if( IsPosProtected() ) cProt
|= 0x01;
1300 if( IsSizeProtected() ) cProt
|= 0x02;
1301 if( IsCntntProtected() ) cProt
|= 0x04;
1302 rStrm
<< (sal_Int8
) cProt
;
1306 // -----------------------------------------------------------------------
1308 SfxPoolItem
* SvxProtectItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1312 SvxProtectItem
* pAttr
= new SvxProtectItem( Which() );
1313 pAttr
->SetPosProtect( sal_Bool( ( cFlags
& 0x01 ) != 0 ) );
1314 pAttr
->SetSizeProtect( sal_Bool( ( cFlags
& 0x02 ) != 0 ) );
1315 pAttr
->SetCntntProtect( sal_Bool( ( cFlags
& 0x04 ) != 0 ) );
1319 // class SvxShadowItem ---------------------------------------------------
1321 SvxShadowItem::SvxShadowItem( const sal_uInt16 nId
,
1322 const Color
*pColor
, const sal_uInt16 nW
,
1323 const SvxShadowLocation eLoc
) :
1324 SfxEnumItemInterface( nId
),
1325 aShadowColor(COL_GRAY
),
1330 aShadowColor
= *pColor
;
1333 // -----------------------------------------------------------------------
1334 bool SvxShadowItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1336 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1337 nMemberId
&= ~CONVERT_TWIPS
;
1339 table::ShadowFormat aShadow
;
1340 table::ShadowLocation eSet
= table::ShadowLocation_NONE
;
1343 case SVX_SHADOW_TOPLEFT
: eSet
= table::ShadowLocation_TOP_LEFT
; break;
1344 case SVX_SHADOW_TOPRIGHT
: eSet
= table::ShadowLocation_TOP_RIGHT
; break;
1345 case SVX_SHADOW_BOTTOMLEFT
: eSet
= table::ShadowLocation_BOTTOM_LEFT
; break;
1346 case SVX_SHADOW_BOTTOMRIGHT
: eSet
= table::ShadowLocation_BOTTOM_RIGHT
; break;
1347 default: ;//prevent warning
1349 aShadow
.Location
= eSet
;
1350 aShadow
.ShadowWidth
= bConvert
? TWIP_TO_MM100_UNSIGNED(nWidth
) : nWidth
;
1351 aShadow
.IsTransparent
= aShadowColor
.GetTransparency() > 0;
1352 aShadow
.Color
= aShadowColor
.GetRGBColor();
1354 switch ( nMemberId
)
1356 case MID_LOCATION
: rVal
<<= aShadow
.Location
; break;
1357 case MID_WIDTH
: rVal
<<= aShadow
.ShadowWidth
; break;
1358 case MID_TRANSPARENT
: rVal
<<= aShadow
.IsTransparent
; break;
1359 case MID_BG_COLOR
: rVal
<<= aShadow
.Color
; break;
1360 case 0: rVal
<<= aShadow
; break;
1361 default: OSL_FAIL("Wrong MemberId!"); return false;
1366 // -----------------------------------------------------------------------
1367 bool SvxShadowItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1369 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1370 nMemberId
&= ~CONVERT_TWIPS
;
1372 table::ShadowFormat aShadow
;
1374 bool bRet
= QueryValue( aAny
, bConvert
? CONVERT_TWIPS
: 0 ) && ( aAny
>>= aShadow
);
1375 switch ( nMemberId
)
1379 bRet
= (rVal
>>= aShadow
.Location
);
1383 bRet
= (rVal
>>= nVal
);
1384 aShadow
.Location
= (table::ShadowLocation
) nVal
;
1390 case MID_WIDTH
: rVal
>>= aShadow
.ShadowWidth
; break;
1391 case MID_TRANSPARENT
: rVal
>>= aShadow
.IsTransparent
; break;
1392 case MID_BG_COLOR
: rVal
>>= aShadow
.Color
; break;
1393 case 0: rVal
>>= aShadow
; break;
1394 default: OSL_FAIL("Wrong MemberId!"); return sal_False
;
1399 // SvxShadowLocation eSet = SVX_SHADOW_NONE;
1400 switch( aShadow
.Location
)
1402 case table::ShadowLocation_TOP_LEFT
: eLocation
= SVX_SHADOW_TOPLEFT
; break;
1403 case table::ShadowLocation_TOP_RIGHT
: eLocation
= SVX_SHADOW_TOPRIGHT
; break;
1404 case table::ShadowLocation_BOTTOM_LEFT
: eLocation
= SVX_SHADOW_BOTTOMLEFT
; break;
1405 case table::ShadowLocation_BOTTOM_RIGHT
: eLocation
= SVX_SHADOW_BOTTOMRIGHT
; break;
1406 default: ;//prevent warning
1409 nWidth
= bConvert
? MM100_TO_TWIP(aShadow
.ShadowWidth
) : aShadow
.ShadowWidth
;
1410 Color
aSet(aShadow
.Color
);
1411 aSet
.SetTransparency(aShadow
.IsTransparent
? 0xff : 0);
1412 aShadowColor
= aSet
;
1418 // -----------------------------------------------------------------------
1420 int SvxShadowItem::operator==( const SfxPoolItem
& rAttr
) const
1422 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1424 return ( ( aShadowColor
== ( (SvxShadowItem
&)rAttr
).aShadowColor
) &&
1425 ( nWidth
== ( (SvxShadowItem
&)rAttr
).GetWidth() ) &&
1426 ( eLocation
== ( (SvxShadowItem
&)rAttr
).GetLocation() ) );
1429 // -----------------------------------------------------------------------
1431 SfxPoolItem
* SvxShadowItem::Clone( SfxItemPool
* ) const
1433 return new SvxShadowItem( *this );
1436 // -----------------------------------------------------------------------
1438 sal_uInt16
SvxShadowItem::CalcShadowSpace( sal_uInt16 nShadow
) const
1440 sal_uInt16 nSpace
= 0;
1445 if ( eLocation
== SVX_SHADOW_TOPLEFT
||
1446 eLocation
== SVX_SHADOW_TOPRIGHT
)
1451 if ( eLocation
== SVX_SHADOW_BOTTOMLEFT
||
1452 eLocation
== SVX_SHADOW_BOTTOMRIGHT
)
1457 if ( eLocation
== SVX_SHADOW_TOPLEFT
||
1458 eLocation
== SVX_SHADOW_BOTTOMLEFT
)
1463 if ( eLocation
== SVX_SHADOW_TOPRIGHT
||
1464 eLocation
== SVX_SHADOW_BOTTOMRIGHT
)
1469 OSL_FAIL( "wrong shadow" );
1474 //------------------------------------------------------------------------
1476 SfxItemPresentation
SvxShadowItem::GetPresentation
1478 SfxItemPresentation ePres
,
1479 SfxMapUnit eCoreUnit
,
1480 SfxMapUnit ePresUnit
,
1481 XubString
& rText
, const IntlWrapper
*pIntl
1486 case SFX_ITEM_PRESENTATION_NONE
:
1490 case SFX_ITEM_PRESENTATION_NAMELESS
:
1492 rText
= ::GetColorString( aShadowColor
);
1494 sal_uInt16 nId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
1496 if ( aShadowColor
.GetTransparency() )
1497 nId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
1498 rText
+= EE_RESSTR(nId
);
1500 rText
+= GetMetricText( (long)nWidth
, eCoreUnit
, ePresUnit
, pIntl
);
1502 rText
+= EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN
+ eLocation
);
1505 case SFX_ITEM_PRESENTATION_COMPLETE
:
1507 rText
= EE_RESSTR(RID_SVXITEMS_SHADOW_COMPLETE
);
1508 rText
+= ::GetColorString( aShadowColor
);
1511 sal_uInt16 nId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
1512 if ( aShadowColor
.GetTransparency() )
1513 nId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
1514 rText
+= EE_RESSTR(nId
);
1516 rText
+= GetMetricText( (long)nWidth
, eCoreUnit
, ePresUnit
, pIntl
);
1517 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
1519 rText
+= EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN
+ eLocation
);
1522 default: ;//prevent warning
1524 return SFX_ITEM_PRESENTATION_NONE
;
1527 // -----------------------------------------------------------------------
1529 SvStream
& SvxShadowItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1531 rStrm
<< (sal_Int8
) GetLocation()
1532 << (sal_uInt16
) GetWidth()
1533 << (sal_Bool
)(aShadowColor
.GetTransparency() > 0)
1536 << (sal_Int8
)(aShadowColor
.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
1540 // -----------------------------------------------------------------------
1542 bool SvxShadowItem::ScaleMetrics( long nMult
, long nDiv
)
1544 nWidth
= (sal_uInt16
)Scale( nWidth
, nMult
, nDiv
);
1548 // -----------------------------------------------------------------------
1550 bool SvxShadowItem::HasMetrics() const
1555 // -----------------------------------------------------------------------
1557 SfxPoolItem
* SvxShadowItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1565 rStrm
>> cLoc
>> _nWidth
1566 >> bTrans
>> aColor
>> aFillColor
>> nStyle
;
1567 aColor
.SetTransparency(bTrans
? 0xff : 0);
1568 return new SvxShadowItem( Which(), &aColor
, _nWidth
, (SvxShadowLocation
)cLoc
);
1571 // -----------------------------------------------------------------------
1573 sal_uInt16
SvxShadowItem::GetValueCount() const
1575 return SVX_SHADOW_END
; // SVX_SHADOW_BOTTOMRIGHT + 1
1578 // -----------------------------------------------------------------------
1580 rtl::OUString
SvxShadowItem::GetValueTextByPos( sal_uInt16 nPos
) const
1582 DBG_ASSERT( nPos
< SVX_SHADOW_END
, "enum overflow!" );
1583 return EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN
+ nPos
);
1586 // -----------------------------------------------------------------------
1588 sal_uInt16
SvxShadowItem::GetEnumValue() const
1590 return (sal_uInt16
)GetLocation();
1593 // -----------------------------------------------------------------------
1595 void SvxShadowItem::SetEnumValue( sal_uInt16 nVal
)
1597 SetLocation( (const SvxShadowLocation
)nVal
);
1600 // class SvxBoxItem ------------------------------------------------------
1602 SvxBoxItem::SvxBoxItem( const SvxBoxItem
& rCpy
) :
1604 SfxPoolItem ( rCpy
),
1605 nTopDist ( rCpy
.nTopDist
),
1606 nBottomDist ( rCpy
.nBottomDist
),
1607 nLeftDist ( rCpy
.nLeftDist
),
1608 nRightDist ( rCpy
.nRightDist
)
1611 pTop
= rCpy
.GetTop() ? new SvxBorderLine( *rCpy
.GetTop() ) : 0;
1612 pBottom
= rCpy
.GetBottom() ? new SvxBorderLine( *rCpy
.GetBottom() ) : 0;
1613 pLeft
= rCpy
.GetLeft() ? new SvxBorderLine( *rCpy
.GetLeft() ) : 0;
1614 pRight
= rCpy
.GetRight() ? new SvxBorderLine( *rCpy
.GetRight() ) : 0;
1617 // -----------------------------------------------------------------------
1619 SvxBoxItem::SvxBoxItem( const sal_uInt16 nId
) :
1634 // -----------------------------------------------------------------------
1636 SvxBoxItem::~SvxBoxItem()
1644 // -----------------------------------------------------------------------
1646 SvxBoxItem
& SvxBoxItem::operator=( const SvxBoxItem
& rBox
)
1648 nTopDist
= rBox
.nTopDist
;
1649 nBottomDist
= rBox
.nBottomDist
;
1650 nLeftDist
= rBox
.nLeftDist
;
1651 nRightDist
= rBox
.nRightDist
;
1652 SetLine( rBox
.GetTop(), BOX_LINE_TOP
);
1653 SetLine( rBox
.GetBottom(), BOX_LINE_BOTTOM
);
1654 SetLine( rBox
.GetLeft(), BOX_LINE_LEFT
);
1655 SetLine( rBox
.GetRight(), BOX_LINE_RIGHT
);
1659 // -----------------------------------------------------------------------
1661 inline sal_Bool
CmpBrdLn( const SvxBorderLine
* pBrd1
, const SvxBorderLine
* pBrd2
)
1664 if( 0 != pBrd1
? 0 == pBrd2
: 0 != pBrd2
)
1670 bRet
= (*pBrd1
== *pBrd2
);
1674 // -----------------------------------------------------------------------
1676 int SvxBoxItem::operator==( const SfxPoolItem
& rAttr
) const
1678 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1681 ( nTopDist
== ( (SvxBoxItem
&)rAttr
).nTopDist
) &&
1682 ( nBottomDist
== ( (SvxBoxItem
&)rAttr
).nBottomDist
) &&
1683 ( nLeftDist
== ( (SvxBoxItem
&)rAttr
).nLeftDist
) &&
1684 ( nRightDist
== ( (SvxBoxItem
&)rAttr
).nRightDist
) &&
1685 CmpBrdLn( pTop
, ( (SvxBoxItem
&)rAttr
).GetTop() ) &&
1686 CmpBrdLn( pBottom
, ( (SvxBoxItem
&)rAttr
).GetBottom() ) &&
1687 CmpBrdLn( pLeft
, ( (SvxBoxItem
&)rAttr
).GetLeft() ) &&
1688 CmpBrdLn( pRight
, ( (SvxBoxItem
&)rAttr
).GetRight() ) );
1691 // -----------------------------------------------------------------------
1692 table::BorderLine2
SvxBoxItem::SvxLineToLine(const SvxBorderLine
* pLine
, sal_Bool bConvert
)
1694 table::BorderLine2 aLine
;
1697 aLine
.Color
= pLine
->GetColor().GetColor() ;
1698 aLine
.InnerLineWidth
= sal_uInt16( bConvert
? TWIP_TO_MM100_UNSIGNED(pLine
->GetInWidth() ): pLine
->GetInWidth() );
1699 aLine
.OuterLineWidth
= sal_uInt16( bConvert
? TWIP_TO_MM100_UNSIGNED(pLine
->GetOutWidth()): pLine
->GetOutWidth() );
1700 aLine
.LineDistance
= sal_uInt16( bConvert
? TWIP_TO_MM100_UNSIGNED(pLine
->GetDistance()): pLine
->GetDistance() );
1701 aLine
.LineStyle
= pLine
->GetBorderLineStyle();
1702 aLine
.LineWidth
= sal_uInt32( bConvert
? TWIP_TO_MM100( pLine
->GetWidth( ) ) : pLine
->GetWidth( ) );
1705 aLine
.Color
= aLine
.InnerLineWidth
= aLine
.OuterLineWidth
= aLine
.LineDistance
= 0;
1708 // -----------------------------------------------------------------------
1709 bool SvxBoxItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1711 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1712 table::BorderLine2 aRetLine
;
1713 sal_uInt16 nDist
= 0;
1714 sal_Bool bDistMember
= sal_False
;
1715 nMemberId
&= ~CONVERT_TWIPS
;
1720 // 4 Borders and 5 distances
1721 uno::Sequence
< uno::Any
> aSeq( 9 );
1722 aSeq
[0] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetLeft(), bConvert
) );
1723 aSeq
[1] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetRight(), bConvert
) );
1724 aSeq
[2] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetBottom(), bConvert
) );
1725 aSeq
[3] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetTop(), bConvert
) );
1726 aSeq
[4] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( GetDistance()) : GetDistance()));
1727 aSeq
[5] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( nTopDist
) : nTopDist
));
1728 aSeq
[6] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( nBottomDist
) : nBottomDist
));
1729 aSeq
[7] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( nLeftDist
) : nLeftDist
));
1730 aSeq
[8] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( nRightDist
) : nRightDist
));
1731 rVal
= uno::makeAny( aSeq
);
1734 case MID_LEFT_BORDER
:
1736 aRetLine
= SvxBoxItem::SvxLineToLine(GetLeft(), bConvert
);
1738 case MID_RIGHT_BORDER
:
1740 aRetLine
= SvxBoxItem::SvxLineToLine(GetRight(), bConvert
);
1742 case MID_BOTTOM_BORDER
:
1744 aRetLine
= SvxBoxItem::SvxLineToLine(GetBottom(), bConvert
);
1746 case MID_TOP_BORDER
:
1748 aRetLine
= SvxBoxItem::SvxLineToLine(GetTop(), bConvert
);
1750 case BORDER_DISTANCE
:
1751 nDist
= GetDistance();
1752 bDistMember
= sal_True
;
1754 case TOP_BORDER_DISTANCE
:
1756 bDistMember
= sal_True
;
1758 case BOTTOM_BORDER_DISTANCE
:
1759 nDist
= nBottomDist
;
1760 bDistMember
= sal_True
;
1762 case LEFT_BORDER_DISTANCE
:
1764 bDistMember
= sal_True
;
1766 case RIGHT_BORDER_DISTANCE
:
1768 bDistMember
= sal_True
;
1773 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nDist
) : nDist
);
1784 lcl_lineToSvxLine(const table::BorderLine
& rLine
, SvxBorderLine
& rSvxLine
, sal_Bool bConvert
, sal_Bool bGuessWidth
)
1786 rSvxLine
.SetColor( Color(rLine
.Color
));
1789 rSvxLine
.GuessLinesWidths( rSvxLine
.GetBorderLineStyle(),
1790 sal_uInt16( bConvert
? MM100_TO_TWIP(rLine
.OuterLineWidth
) : rLine
.OuterLineWidth
),
1791 sal_uInt16( bConvert
? MM100_TO_TWIP(rLine
.InnerLineWidth
) : rLine
.InnerLineWidth
),
1792 sal_uInt16( bConvert
? MM100_TO_TWIP(rLine
.LineDistance
) : rLine
.LineDistance
));
1795 sal_Bool bRet
= !rSvxLine
.isEmpty();
1801 // -----------------------------------------------------------------------
1802 sal_Bool
SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine
& rLine
, SvxBorderLine
& rSvxLine
, sal_Bool bConvert
)
1804 return lcl_lineToSvxLine(rLine
, rSvxLine
, bConvert
, sal_True
);
1808 SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine2
& rLine
, SvxBorderLine
& rSvxLine
, sal_Bool bConvert
)
1810 SvxBorderStyle
const nStyle
=
1811 (rLine
.LineStyle
< 0 || BORDER_LINE_STYLE_MAX
< rLine
.LineStyle
)
1815 rSvxLine
.SetBorderLineStyle( nStyle
);
1817 sal_Bool bGuessWidth
= sal_True
;
1818 if ( rLine
.LineWidth
)
1820 rSvxLine
.SetWidth( bConvert
? MM100_TO_TWIP_UNSIGNED( rLine
.LineWidth
) : rLine
.LineWidth
);
1821 // fdo#46112: double does not necessarily mean symmetric
1822 // for backwards compatibility
1823 bGuessWidth
= (DOUBLE
== nStyle
) &&
1824 (rLine
.InnerLineWidth
> 0) && (rLine
.OuterLineWidth
> 0);
1827 return lcl_lineToSvxLine(rLine
, rSvxLine
, bConvert
, bGuessWidth
);
1830 // -----------------------------------------------------------------------
1836 lcl_extractBorderLine(const uno::Any
& rAny
, table::BorderLine2
& rLine
)
1841 table::BorderLine aBorderLine
;
1842 if (rAny
>>= aBorderLine
)
1844 rLine
.Color
= aBorderLine
.Color
;
1845 rLine
.InnerLineWidth
= aBorderLine
.InnerLineWidth
;
1846 rLine
.OuterLineWidth
= aBorderLine
.OuterLineWidth
;
1847 rLine
.LineDistance
= aBorderLine
.LineDistance
;
1848 rLine
.LineStyle
= table::BorderLineStyle::SOLID
;
1855 template<typename Item
>
1857 lcl_setLine(const uno::Any
& rAny
, Item
& rItem
, sal_uInt16 nLine
, const bool bConvert
)
1860 table::BorderLine2 aBorderLine
;
1861 if (lcl_extractBorderLine(rAny
, aBorderLine
))
1863 SvxBorderLine aLine
;
1864 bool bSet
= SvxBoxItem::LineToSvxLine(aBorderLine
, aLine
, bConvert
);
1865 rItem
.SetLine( bSet
? &aLine
: NULL
, nLine
);
1873 bool SvxBoxItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1875 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1876 sal_uInt16 nLine
= BOX_LINE_TOP
;
1877 sal_Bool bDistMember
= sal_False
;
1878 nMemberId
&= ~CONVERT_TWIPS
;
1883 uno::Sequence
< uno::Any
> aSeq
;
1884 if (( rVal
>>= aSeq
) && ( aSeq
.getLength() == 9 ))
1886 // 4 Borders and 5 distances
1887 const sal_uInt16 aBorders
[] = { BOX_LINE_LEFT
, BOX_LINE_RIGHT
, BOX_LINE_BOTTOM
, BOX_LINE_TOP
};
1888 for (int n(0); n
!= SAL_N_ELEMENTS(aBorders
); ++n
)
1890 if (!lcl_setLine(aSeq
[n
], *this, aBorders
[n
], bConvert
))
1894 // WTH are the borders and the distances saved in different order?
1895 sal_uInt16 nLines
[4] = { BOX_LINE_TOP
, BOX_LINE_BOTTOM
, BOX_LINE_LEFT
, BOX_LINE_RIGHT
};
1896 for ( sal_Int32 n
= 4; n
< 9; n
++ )
1898 sal_Int32 nDist
= 0;
1899 if ( aSeq
[n
] >>= nDist
)
1902 nDist
= MM100_TO_TWIP(nDist
);
1904 SetDistance( sal_uInt16( nDist
));
1906 SetDistance( sal_uInt16( nDist
), nLines
[n
-5] );
1917 case LEFT_BORDER_DISTANCE
:
1918 bDistMember
= sal_True
;
1920 case MID_LEFT_BORDER
:
1921 nLine
= BOX_LINE_LEFT
;
1923 case RIGHT_BORDER_DISTANCE
:
1924 bDistMember
= sal_True
;
1926 case MID_RIGHT_BORDER
:
1927 nLine
= BOX_LINE_RIGHT
;
1929 case BOTTOM_BORDER_DISTANCE
:
1930 bDistMember
= sal_True
;
1932 case MID_BOTTOM_BORDER
:
1933 nLine
= BOX_LINE_BOTTOM
;
1935 case TOP_BORDER_DISTANCE
:
1936 bDistMember
= sal_True
;
1938 case MID_TOP_BORDER
:
1939 nLine
= BOX_LINE_TOP
;
1943 drawing::LineStyle eDrawingStyle
;
1944 rVal
>>= eDrawingStyle
;
1945 editeng::SvxBorderStyle eBorderStyle
= NONE
;
1946 switch ( eDrawingStyle
)
1949 case drawing::LineStyle_NONE
:
1951 case drawing::LineStyle_SOLID
:
1952 eBorderStyle
= SOLID
;
1954 case drawing::LineStyle_DASH
:
1955 eBorderStyle
= DASHED
;
1959 // Set the line style on all borders
1960 const sal_uInt16 aBorders
[] = { BOX_LINE_LEFT
, BOX_LINE_RIGHT
, BOX_LINE_BOTTOM
, BOX_LINE_TOP
};
1961 for (int n(0); n
!= SAL_N_ELEMENTS(aBorders
); ++n
)
1963 editeng::SvxBorderLine
* pLine
= const_cast< editeng::SvxBorderLine
* >( GetLine( aBorders
[n
] ) );
1965 pLine
->SetBorderLineStyle( eBorderStyle
);
1972 // Set the line width on all borders
1976 nWidth
= MM100_TO_TWIP( nWidth
);
1978 // Set the line Width on all borders
1979 const sal_uInt16 aBorders
[] = { BOX_LINE_LEFT
, BOX_LINE_RIGHT
, BOX_LINE_BOTTOM
, BOX_LINE_TOP
};
1980 for (int n(0); n
!= SAL_N_ELEMENTS(aBorders
); ++n
)
1982 editeng::SvxBorderLine
* pLine
= const_cast< editeng::SvxBorderLine
* >( GetLine( aBorders
[n
] ) );
1983 pLine
->SetWidth( nWidth
);
1990 if( bDistMember
|| nMemberId
== BORDER_DISTANCE
)
1992 sal_Int32 nDist
= 0;
1993 if(!(rVal
>>= nDist
))
1999 nDist
= MM100_TO_TWIP(nDist
);
2000 if( nMemberId
== BORDER_DISTANCE
)
2001 SetDistance( sal_uInt16( nDist
));
2003 SetDistance( sal_uInt16( nDist
), nLine
);
2008 SvxBorderLine aLine
;
2009 if( !rVal
.hasValue() )
2012 table::BorderLine2 aBorderLine
;
2013 if( lcl_extractBorderLine(rVal
, aBorderLine
) )
2017 else if (rVal
.getValueTypeClass() == uno::TypeClass_SEQUENCE
)
2019 // serialization for basic macro recording
2020 uno::Reference
< script::XTypeConverter
> xConverter
2021 ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString("com.sun.star.script.Converter")),
2023 uno::Sequence
< uno::Any
> aSeq
;
2025 try { aNew
= xConverter
->convertTo( rVal
, ::getCppuType((const uno::Sequence
< uno::Any
>*)0) ); }
2026 catch (const uno::Exception
&) {}
2029 if (aSeq
.getLength() >= 4 && aSeq
.getLength() <= 6)
2032 if ( aSeq
[0] >>= nVal
)
2033 aBorderLine
.Color
= nVal
;
2034 if ( aSeq
[1] >>= nVal
)
2035 aBorderLine
.InnerLineWidth
= (sal_Int16
) nVal
;
2036 if ( aSeq
[2] >>= nVal
)
2037 aBorderLine
.OuterLineWidth
= (sal_Int16
) nVal
;
2038 if ( aSeq
[3] >>= nVal
)
2039 aBorderLine
.LineDistance
= (sal_Int16
) nVal
;
2040 if (aSeq
.getLength() >= 5) // fdo#40874 added fields
2042 if (aSeq
[4] >>= nVal
)
2044 aBorderLine
.LineStyle
= nVal
;
2046 if (aSeq
.getLength() >= 6)
2048 if (aSeq
[5] >>= nVal
)
2050 aBorderLine
.LineWidth
= nVal
;
2061 sal_Bool bSet
= SvxBoxItem::LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2062 SetLine(bSet
? &aLine
: 0, nLine
);
2068 // -----------------------------------------------------------------------
2070 SfxPoolItem
* SvxBoxItem::Clone( SfxItemPool
* ) const
2072 return new SvxBoxItem( *this );
2075 //------------------------------------------------------------------------
2077 SfxItemPresentation
SvxBoxItem::GetPresentation
2079 SfxItemPresentation ePres
,
2080 SfxMapUnit eCoreUnit
,
2081 SfxMapUnit ePresUnit
,
2082 XubString
& rText
, const IntlWrapper
*pIntl
2087 case SFX_ITEM_PRESENTATION_NONE
:
2089 return SFX_ITEM_PRESENTATION_NONE
;
2091 case SFX_ITEM_PRESENTATION_NAMELESS
:
2097 rText
= pTop
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
);
2100 if( !(pTop
&& pBottom
&& pLeft
&& pRight
&&
2101 *pTop
== *pBottom
&& *pTop
== *pLeft
&& *pTop
== *pRight
) )
2105 rText
+= pBottom
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
);
2110 rText
+= pLeft
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
);
2115 rText
+= pRight
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
);
2119 rText
+= GetMetricText( (long)nTopDist
, eCoreUnit
, ePresUnit
, pIntl
);
2120 if( nTopDist
!= nBottomDist
|| nTopDist
!= nLeftDist
||
2121 nTopDist
!= nRightDist
)
2123 (((((rText
+= cpDelim
)
2124 += GetMetricText( (long)nBottomDist
, eCoreUnit
,
2127 += GetMetricText( (long)nLeftDist
, eCoreUnit
, ePresUnit
, pIntl
))
2129 += GetMetricText( (long)nRightDist
, eCoreUnit
,
2132 return SFX_ITEM_PRESENTATION_NAMELESS
;
2134 case SFX_ITEM_PRESENTATION_COMPLETE
:
2136 if( !(pTop
|| pBottom
|| pLeft
|| pRight
) )
2138 rText
= EE_RESSTR(RID_SVXITEMS_BORDER_NONE
);
2143 rText
= EE_RESSTR(RID_SVXITEMS_BORDER_COMPLETE
);
2144 if( pTop
&& pBottom
&& pLeft
&& pRight
&&
2145 *pTop
== *pBottom
&& *pTop
== *pLeft
&& *pTop
== *pRight
)
2147 rText
+= pTop
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2154 rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_TOP
);
2155 rText
+= pTop
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2160 rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM
);
2161 rText
+= pBottom
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2166 rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_LEFT
);
2167 rText
+= pLeft
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2172 rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT
);
2173 rText
+= pRight
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2179 rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_DISTANCE
);
2180 if( nTopDist
== nBottomDist
&& nTopDist
== nLeftDist
&&
2181 nTopDist
== nRightDist
)
2183 rText
+= GetMetricText( (long)nTopDist
, eCoreUnit
,
2185 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
2189 (((rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_TOP
))
2190 += GetMetricText( (long)nTopDist
, eCoreUnit
,
2192 += EE_RESSTR(GetMetricId(ePresUnit
)))
2194 (((rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM
))
2195 += GetMetricText( (long)nBottomDist
, eCoreUnit
,
2197 += EE_RESSTR(GetMetricId(ePresUnit
)))
2199 (((rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_LEFT
))
2200 += GetMetricText( (long)nLeftDist
, eCoreUnit
,
2202 += EE_RESSTR(GetMetricId(ePresUnit
)))
2204 ((rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT
))
2205 += GetMetricText( (long)nRightDist
, eCoreUnit
,
2207 += EE_RESSTR(GetMetricId(ePresUnit
));
2209 return SFX_ITEM_PRESENTATION_COMPLETE
;
2211 default: ;//prevent warning
2213 return SFX_ITEM_PRESENTATION_NONE
;
2216 // -----------------------------------------------------------------------
2218 SvStream
& SvxBoxItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
2220 rStrm
<< (sal_uInt16
) GetDistance();
2221 const SvxBorderLine
* pLine
[ 4 ]; // top, left, right, bottom
2222 pLine
[ 0 ] = GetTop();
2223 pLine
[ 1 ] = GetLeft();
2224 pLine
[ 2 ] = GetRight();
2225 pLine
[ 3 ] = GetBottom();
2227 for( int i
= 0; i
< 4; i
++ )
2229 const SvxBorderLine
* l
= pLine
[ i
];
2232 rStrm
<< static_cast<sal_Int8
>(i
);
2233 StoreBorderLine(rStrm
, *l
, BorderLineVersionFromBoxVersion(nItemVersion
));
2237 if( nItemVersion
>= BOX_4DISTS_VERSION
&&
2238 !(nTopDist
== nLeftDist
&&
2239 nTopDist
== nRightDist
&&
2240 nTopDist
== nBottomDist
) )
2247 if( nItemVersion
>= BOX_4DISTS_VERSION
&& (cLine
& 0x10) != 0 )
2249 rStrm
<< (sal_uInt16
)nTopDist
2250 << (sal_uInt16
)nLeftDist
2251 << (sal_uInt16
)nRightDist
2252 << (sal_uInt16
)nBottomDist
;
2258 // -----------------------------------------------------------------------
2260 sal_uInt16
SvxBoxItem::GetVersion( sal_uInt16 nFFVer
) const
2262 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
2263 SOFFICE_FILEFORMAT_40
==nFFVer
||
2264 SOFFICE_FILEFORMAT_50
==nFFVer
,
2265 "SvxBoxItem: Gibt es ein neues Fileformat?" );
2266 return SOFFICE_FILEFORMAT_31
==nFFVer
||
2267 SOFFICE_FILEFORMAT_40
==nFFVer
? 0 : BOX_BORDER_STYLE_VERSION
;
2270 // -----------------------------------------------------------------------
2272 bool SvxBoxItem::ScaleMetrics( long nMult
, long nDiv
)
2274 if ( pTop
) pTop
->ScaleMetrics( nMult
, nDiv
);
2275 if ( pBottom
) pBottom
->ScaleMetrics( nMult
, nDiv
);
2276 if ( pLeft
) pLeft
->ScaleMetrics( nMult
, nDiv
);
2277 if ( pRight
) pBottom
->ScaleMetrics( nMult
, nDiv
);
2278 nTopDist
= (sal_uInt16
)Scale( nTopDist
, nMult
, nDiv
);
2279 nBottomDist
= (sal_uInt16
)Scale( nBottomDist
, nMult
, nDiv
);
2280 nLeftDist
= (sal_uInt16
)Scale( nLeftDist
, nMult
, nDiv
);
2281 nRightDist
= (sal_uInt16
)Scale( nRightDist
, nMult
, nDiv
);
2285 // -----------------------------------------------------------------------
2287 bool SvxBoxItem::HasMetrics() const
2292 // -----------------------------------------------------------------------
2294 SfxPoolItem
* SvxBoxItem::Create( SvStream
& rStrm
, sal_uInt16 nIVersion
) const
2296 sal_uInt16 nDistance
;
2298 SvxBoxItem
* pAttr
= new SvxBoxItem( Which() );
2300 sal_uInt16 aLineMap
[4] = { BOX_LINE_TOP
, BOX_LINE_LEFT
,
2301 BOX_LINE_RIGHT
, BOX_LINE_BOTTOM
};
2311 SvxBorderLine aBorder
= CreateBorderLine(rStrm
, BorderLineVersionFromBoxVersion(nIVersion
));
2312 pAttr
->SetLine( &aBorder
, aLineMap
[cLine
] );
2315 if( nIVersion
>= BOX_4DISTS_VERSION
&& (cLine
&0x10) != 0 )
2317 for( sal_uInt16 i
=0; i
< 4; i
++ )
2321 pAttr
->SetDistance( nDist
, aLineMap
[i
] );
2326 pAttr
->SetDistance( nDistance
);
2332 // -----------------------------------------------------------------------
2334 const SvxBorderLine
*SvxBoxItem::GetLine( sal_uInt16 nLine
) const
2336 const SvxBorderLine
*pRet
= 0;
2343 case BOX_LINE_BOTTOM
:
2349 case BOX_LINE_RIGHT
:
2353 OSL_FAIL( "wrong line" );
2360 // -----------------------------------------------------------------------
2362 void SvxBoxItem::SetLine( const SvxBorderLine
* pNew
, sal_uInt16 nLine
)
2364 SvxBorderLine
* pTmp
= pNew
? new SvxBorderLine( *pNew
) : 0;
2372 case BOX_LINE_BOTTOM
:
2380 case BOX_LINE_RIGHT
:
2386 OSL_FAIL( "wrong line" );
2390 // -----------------------------------------------------------------------
2392 sal_uInt16
SvxBoxItem::GetDistance() const
2394 // The smallest distance that is not 0 will be returned.
2395 sal_uInt16 nDist
= nTopDist
;
2396 if( nBottomDist
&& (!nDist
|| nBottomDist
< nDist
) )
2397 nDist
= nBottomDist
;
2398 if( nLeftDist
&& (!nDist
|| nLeftDist
< nDist
) )
2400 if( nRightDist
&& (!nDist
|| nRightDist
< nDist
) )
2406 // -----------------------------------------------------------------------
2408 sal_uInt16
SvxBoxItem::GetDistance( sal_uInt16 nLine
) const
2410 sal_uInt16 nDist
= 0;
2416 case BOX_LINE_BOTTOM
:
2417 nDist
= nBottomDist
;
2422 case BOX_LINE_RIGHT
:
2426 OSL_FAIL( "wrong line" );
2432 // -----------------------------------------------------------------------
2434 void SvxBoxItem::SetDistance( sal_uInt16 nNew
, sal_uInt16 nLine
)
2441 case BOX_LINE_BOTTOM
:
2447 case BOX_LINE_RIGHT
:
2451 OSL_FAIL( "wrong line" );
2455 // -----------------------------------------------------------------------
2457 sal_uInt16
SvxBoxItem::CalcLineSpace( sal_uInt16 nLine
, sal_Bool bIgnoreLine
) const
2459 SvxBorderLine
* pTmp
= 0;
2460 sal_uInt16 nDist
= 0;
2467 case BOX_LINE_BOTTOM
:
2469 nDist
= nBottomDist
;
2475 case BOX_LINE_RIGHT
:
2480 OSL_FAIL( "wrong line" );
2485 nDist
= nDist
+ (sal_uInt16
)(pTmp
->GetOutWidth()) + (sal_uInt16
)(pTmp
->GetInWidth()) + (sal_uInt16
)(pTmp
->GetDistance());
2487 else if( !bIgnoreLine
)
2492 // class SvxBoxInfoItem --------------------------------------------------
2494 SvxBoxInfoItem::SvxBoxInfoItem( const sal_uInt16 nId
) :
2498 mbEnableHor( false ),
2499 mbEnableVer( false ),
2502 bDist
= bMinDist
= sal_False
;
2506 // -----------------------------------------------------------------------
2508 SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem
& rCpy
) :
2509 SfxPoolItem( rCpy
),
2510 mbEnableHor( rCpy
.mbEnableHor
),
2511 mbEnableVer( rCpy
.mbEnableVer
)
2513 pHori
= rCpy
.GetHori() ? new SvxBorderLine( *rCpy
.GetHori() ) : 0;
2514 pVert
= rCpy
.GetVert() ? new SvxBorderLine( *rCpy
.GetVert() ) : 0;
2515 bDist
= rCpy
.IsDist();
2516 bMinDist
= rCpy
.IsMinDist();
2517 nValidFlags
= rCpy
.nValidFlags
;
2518 nDefDist
= rCpy
.GetDefDist();
2521 // -----------------------------------------------------------------------
2523 SvxBoxInfoItem::~SvxBoxInfoItem()
2529 // -----------------------------------------------------------------------
2531 SvxBoxInfoItem
&SvxBoxInfoItem::operator=( const SvxBoxInfoItem
& rCpy
)
2535 pHori
= rCpy
.GetHori() ? new SvxBorderLine( *rCpy
.GetHori() ) : 0;
2536 pVert
= rCpy
.GetVert() ? new SvxBorderLine( *rCpy
.GetVert() ) : 0;
2537 mbEnableHor
= rCpy
.mbEnableHor
;
2538 mbEnableVer
= rCpy
.mbEnableVer
;
2539 bDist
= rCpy
.IsDist();
2540 bMinDist
= rCpy
.IsMinDist();
2541 nValidFlags
= rCpy
.nValidFlags
;
2542 nDefDist
= rCpy
.GetDefDist();
2546 // -----------------------------------------------------------------------
2548 int SvxBoxInfoItem::operator==( const SfxPoolItem
& rAttr
) const
2550 SvxBoxInfoItem
& rBoxInfo
= (SvxBoxInfoItem
&)rAttr
;
2552 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
2554 return ( mbEnableHor
== rBoxInfo
.mbEnableHor
2555 && mbEnableVer
== rBoxInfo
.mbEnableVer
2556 && bDist
== rBoxInfo
.IsDist()
2557 && bMinDist
== rBoxInfo
.IsMinDist()
2558 && nValidFlags
== rBoxInfo
.nValidFlags
2559 && nDefDist
== rBoxInfo
.GetDefDist()
2560 && CmpBrdLn( pHori
, rBoxInfo
.GetHori() )
2561 && CmpBrdLn( pVert
, rBoxInfo
.GetVert() )
2565 // -----------------------------------------------------------------------
2567 void SvxBoxInfoItem::SetLine( const SvxBorderLine
* pNew
, sal_uInt16 nLine
)
2569 SvxBorderLine
* pTmp
= pNew
? new SvxBorderLine( *pNew
) : 0;
2571 if ( BOXINFO_LINE_HORI
== nLine
)
2576 else if ( BOXINFO_LINE_VERT
== nLine
)
2584 OSL_FAIL( "wrong line" );
2588 // -----------------------------------------------------------------------
2590 SfxPoolItem
* SvxBoxInfoItem::Clone( SfxItemPool
* ) const
2592 return new SvxBoxInfoItem( *this );
2595 //------------------------------------------------------------------------
2597 SfxItemPresentation
SvxBoxInfoItem::GetPresentation
2599 SfxItemPresentation
/*ePres*/,
2600 SfxMapUnit
/*eCoreUnit*/,
2601 SfxMapUnit
/*ePresUnit*/,
2602 XubString
& rText
, const IntlWrapper
*
2606 return SFX_ITEM_PRESENTATION_NONE
;
2609 // -----------------------------------------------------------------------
2611 SvStream
& SvxBoxInfoItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2613 sal_Int8 cFlags
= 0;
2621 rStrm
<< (sal_Int8
) cFlags
2622 << (sal_uInt16
) GetDefDist();
2623 const SvxBorderLine
* pLine
[ 2 ];
2624 pLine
[ 0 ] = GetHori();
2625 pLine
[ 1 ] = GetVert();
2627 for( int i
= 0; i
< 2; i
++ )
2629 const SvxBorderLine
* l
= pLine
[ i
];
2634 << (short) l
->GetOutWidth()
2635 << (short) l
->GetInWidth()
2636 << (short) l
->GetDistance();
2643 // -----------------------------------------------------------------------
2645 bool SvxBoxInfoItem::ScaleMetrics( long nMult
, long nDiv
)
2647 if ( pHori
) pHori
->ScaleMetrics( nMult
, nDiv
);
2648 if ( pVert
) pVert
->ScaleMetrics( nMult
, nDiv
);
2649 nDefDist
= (sal_uInt16
)Scale( nDefDist
, nMult
, nDiv
);
2653 // -----------------------------------------------------------------------
2655 bool SvxBoxInfoItem::HasMetrics() const
2660 // -----------------------------------------------------------------------
2662 SfxPoolItem
* SvxBoxInfoItem::Create( SvStream
& rStrm
, sal_uInt16
) const
2665 sal_uInt16 _nDefDist
;
2666 rStrm
>> cFlags
>> _nDefDist
;
2668 SvxBoxInfoItem
* pAttr
= new SvxBoxInfoItem( Which() );
2670 pAttr
->SetTable ( ( cFlags
& 0x01 ) != 0 );
2671 pAttr
->SetDist ( ( cFlags
& 0x02 ) != 0 );
2672 pAttr
->SetMinDist( ( cFlags
& 0x04 ) != 0 );
2673 pAttr
->SetDefDist( _nDefDist
);
2682 short nOutline
, nInline
, nDistance
;
2684 rStrm
>> aColor
>> nOutline
>> nInline
>> nDistance
;
2685 SvxBorderLine
aBorder( &aColor
);
2686 aBorder
.GuessLinesWidths(NONE
, nOutline
, nInline
, nDistance
);
2690 case 0: pAttr
->SetLine( &aBorder
, BOXINFO_LINE_HORI
); break;
2691 case 1: pAttr
->SetLine( &aBorder
, BOXINFO_LINE_VERT
); break;
2697 // -----------------------------------------------------------------------
2699 void SvxBoxInfoItem::ResetFlags()
2701 nValidFlags
= 0x7F; // all valid except Disable
2704 bool SvxBoxInfoItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2706 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
2707 table::BorderLine2 aRetLine
;
2709 sal_Bool bIntMember
= sal_False
;
2710 nMemberId
&= ~CONVERT_TWIPS
;
2715 // 2 BorderLines, flags, valid flags and distance
2716 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aSeq( 5 );
2717 aSeq
[0] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pHori
, bConvert
) );
2718 aSeq
[1] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pVert
, bConvert
) );
2725 aSeq
[2] = ::com::sun::star::uno::makeAny( nVal
);
2727 aSeq
[3] = ::com::sun::star::uno::makeAny( nVal
);
2728 aSeq
[4] = ::com::sun::star::uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist()) );
2729 rVal
= ::com::sun::star::uno::makeAny( aSeq
);
2733 case MID_HORIZONTAL
:
2734 aRetLine
= SvxBoxItem::SvxLineToLine( pHori
, bConvert
);
2737 aRetLine
= SvxBoxItem::SvxLineToLine( pVert
, bConvert
);
2740 bIntMember
= sal_True
;
2749 case MID_VALIDFLAGS
:
2750 bIntMember
= sal_True
;
2755 bIntMember
= sal_True
;
2756 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist());
2758 default: OSL_FAIL("Wrong MemberId!"); return false;
2767 // -----------------------------------------------------------------------
2769 bool SvxBoxInfoItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2771 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
2772 nMemberId
&= ~CONVERT_TWIPS
;
2778 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aSeq
;
2779 if (( rVal
>>= aSeq
) && ( aSeq
.getLength() == 5 ))
2781 // 2 BorderLines, flags, valid flags and distance
2782 if (!lcl_setLine(aSeq
[0], *this, BOXINFO_LINE_HORI
, bConvert
))
2784 if (!lcl_setLine(aSeq
[1], *this, BOXINFO_LINE_VERT
, bConvert
))
2787 sal_Int16
nFlags( 0 );
2788 sal_Int32
nVal( 0 );
2789 if ( aSeq
[2] >>= nFlags
)
2791 SetTable ( ( nFlags
& 0x01 ) != 0 );
2792 SetDist ( ( nFlags
& 0x02 ) != 0 );
2793 SetMinDist( ( nFlags
& 0x04 ) != 0 );
2797 if ( aSeq
[3] >>= nFlags
)
2798 nValidFlags
= (sal_uInt8
)nFlags
;
2801 if (( aSeq
[4] >>= nVal
) && ( nVal
>= 0 ))
2804 nVal
= MM100_TO_TWIP(nVal
);
2805 SetDefDist( (sal_uInt16
)nVal
);
2811 case MID_HORIZONTAL
:
2814 if( !rVal
.hasValue() )
2817 table::BorderLine2 aBorderLine
;
2818 if( lcl_extractBorderLine(rVal
, aBorderLine
) )
2822 else if (rVal
.getValueTypeClass() == uno::TypeClass_SEQUENCE
)
2824 // serialization for basic macro recording
2825 uno::Reference
< script::XTypeConverter
> xConverter
2826 ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString("com.sun.star.script.Converter")),
2829 uno::Sequence
< uno::Any
> aSeq
;
2830 try { aNew
= xConverter
->convertTo( rVal
, ::getCppuType((const uno::Sequence
< uno::Any
>*)0) ); }
2831 catch (const uno::Exception
&) {}
2833 if ((aNew
>>= aSeq
) &&
2834 aSeq
.getLength() >= 4 && aSeq
.getLength() <= 6)
2837 if ( aSeq
[0] >>= nVal
)
2838 aBorderLine
.Color
= nVal
;
2839 if ( aSeq
[1] >>= nVal
)
2840 aBorderLine
.InnerLineWidth
= (sal_Int16
) nVal
;
2841 if ( aSeq
[2] >>= nVal
)
2842 aBorderLine
.OuterLineWidth
= (sal_Int16
) nVal
;
2843 if ( aSeq
[3] >>= nVal
)
2844 aBorderLine
.LineDistance
= (sal_Int16
) nVal
;
2845 if (aSeq
.getLength() >= 5) // fdo#40874 added fields
2847 if (aSeq
[4] >>= nVal
)
2849 aBorderLine
.LineStyle
= nVal
;
2851 if (aSeq
.getLength() >= 6)
2853 if (aSeq
[5] >>= nVal
)
2855 aBorderLine
.LineWidth
= nVal
;
2863 else if (rVal
.getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence
< sal_Int16
>*)0) )
2865 // serialization for basic macro recording
2866 ::com::sun::star::uno::Sequence
< sal_Int16
> aSeq
;
2868 if (aSeq
.getLength() >= 4 && aSeq
.getLength() <= 6)
2870 aBorderLine
.Color
= aSeq
[0];
2871 aBorderLine
.InnerLineWidth
= aSeq
[1];
2872 aBorderLine
.OuterLineWidth
= aSeq
[2];
2873 aBorderLine
.LineDistance
= aSeq
[3];
2874 if (aSeq
.getLength() >= 5) // fdo#40874 added fields
2876 aBorderLine
.LineStyle
= aSeq
[4];
2877 if (aSeq
.getLength() >= 6)
2879 aBorderLine
.LineWidth
= aSeq
[5];
2889 SvxBorderLine aLine
;
2890 sal_Bool bSet
= SvxBoxItem::LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2892 SetLine( &aLine
, nMemberId
== MID_HORIZONTAL
? BOXINFO_LINE_HORI
: BOXINFO_LINE_VERT
);
2897 sal_Int16 nFlags
= sal_Int16();
2898 bRet
= (rVal
>>= nFlags
);
2901 SetTable ( ( nFlags
& 0x01 ) != 0 );
2902 SetDist ( ( nFlags
& 0x02 ) != 0 );
2903 SetMinDist( ( nFlags
& 0x04 ) != 0 );
2908 case MID_VALIDFLAGS
:
2910 sal_Int16 nFlags
= sal_Int16();
2911 bRet
= (rVal
>>= nFlags
);
2913 nValidFlags
= (sal_uInt8
)nFlags
;
2919 bRet
= (rVal
>>= nVal
);
2920 if ( bRet
&& nVal
>=0 )
2923 nVal
= MM100_TO_TWIP(nVal
);
2924 SetDefDist( (sal_uInt16
)nVal
);
2928 default: OSL_FAIL("Wrong MemberId!"); return sal_False
;
2934 // class SvxFmtBreakItem -------------------------------------------------
2936 int SvxFmtBreakItem::operator==( const SfxPoolItem
& rAttr
) const
2938 DBG_ASSERT( SfxPoolItem::operator==( rAttr
), "unequal types" );
2940 return GetValue() == ( (SvxFmtBreakItem
&)rAttr
).GetValue();
2943 //------------------------------------------------------------------------
2945 SfxItemPresentation
SvxFmtBreakItem::GetPresentation
2947 SfxItemPresentation ePres
,
2948 SfxMapUnit
/*eCoreUnit*/,
2949 SfxMapUnit
/*ePresUnit*/,
2950 XubString
& rText
, const IntlWrapper
*
2955 case SFX_ITEM_PRESENTATION_NONE
:
2957 return SFX_ITEM_PRESENTATION_NONE
;
2959 case SFX_ITEM_PRESENTATION_NAMELESS
:
2960 case SFX_ITEM_PRESENTATION_COMPLETE
:
2961 rText
= GetValueTextByPos( GetValue() );
2963 default: ;//prevent warning
2965 return SFX_ITEM_PRESENTATION_NONE
;
2968 // -----------------------------------------------------------------------
2970 rtl::OUString
SvxFmtBreakItem::GetValueTextByPos( sal_uInt16 nPos
) const
2972 DBG_ASSERT( nPos
< SVX_BREAK_END
, "enum overflow!" );
2973 return EE_RESSTR(RID_SVXITEMS_BREAK_BEGIN
+ nPos
);
2976 // -----------------------------------------------------------------------
2977 bool SvxFmtBreakItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
2979 style::BreakType eBreak
= style::BreakType_NONE
;
2980 switch ( (SvxBreak
)GetValue() )
2982 case SVX_BREAK_COLUMN_BEFORE
: eBreak
= style::BreakType_COLUMN_BEFORE
; break;
2983 case SVX_BREAK_COLUMN_AFTER
: eBreak
= style::BreakType_COLUMN_AFTER
; break;
2984 case SVX_BREAK_COLUMN_BOTH
: eBreak
= style::BreakType_COLUMN_BOTH
; break;
2985 case SVX_BREAK_PAGE_BEFORE
: eBreak
= style::BreakType_PAGE_BEFORE
; break;
2986 case SVX_BREAK_PAGE_AFTER
: eBreak
= style::BreakType_PAGE_AFTER
; break;
2987 case SVX_BREAK_PAGE_BOTH
: eBreak
= style::BreakType_PAGE_BOTH
; break;
2988 default: ;//prevent warning
2993 // -----------------------------------------------------------------------
2994 bool SvxFmtBreakItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
2996 style::BreakType nBreak
;
2998 if(!(rVal
>>= nBreak
))
3000 sal_Int32 nValue
= 0;
3001 if(!(rVal
>>= nValue
))
3004 nBreak
= (style::BreakType
) nValue
;
3007 SvxBreak eBreak
= SVX_BREAK_NONE
;
3010 case style::BreakType_COLUMN_BEFORE
: eBreak
= SVX_BREAK_COLUMN_BEFORE
; break;
3011 case style::BreakType_COLUMN_AFTER
: eBreak
= SVX_BREAK_COLUMN_AFTER
; break;
3012 case style::BreakType_COLUMN_BOTH
: eBreak
= SVX_BREAK_COLUMN_BOTH
; break;
3013 case style::BreakType_PAGE_BEFORE
: eBreak
= SVX_BREAK_PAGE_BEFORE
; break;
3014 case style::BreakType_PAGE_AFTER
: eBreak
= SVX_BREAK_PAGE_AFTER
; break;
3015 case style::BreakType_PAGE_BOTH
: eBreak
= SVX_BREAK_PAGE_BOTH
; break;
3016 default: ;//prevent warning
3018 SetValue((sal_uInt16
) eBreak
);
3023 // -----------------------------------------------------------------------
3025 SfxPoolItem
* SvxFmtBreakItem::Clone( SfxItemPool
* ) const
3027 return new SvxFmtBreakItem( *this );
3030 // -----------------------------------------------------------------------
3032 SvStream
& SvxFmtBreakItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
3034 rStrm
<< (sal_Int8
)GetValue();
3035 if( FMTBREAK_NOAUTO
> nItemVersion
)
3036 rStrm
<< (sal_Int8
)0x01;
3040 // -----------------------------------------------------------------------
3042 sal_uInt16
SvxFmtBreakItem::GetVersion( sal_uInt16 nFFVer
) const
3044 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
3045 SOFFICE_FILEFORMAT_40
==nFFVer
||
3046 SOFFICE_FILEFORMAT_50
==nFFVer
,
3047 "SvxFmtBreakItem: Is there a new file format? ");
3048 return SOFFICE_FILEFORMAT_31
==nFFVer
||
3049 SOFFICE_FILEFORMAT_40
==nFFVer
? 0 : FMTBREAK_NOAUTO
;
3052 // -----------------------------------------------------------------------
3054 SfxPoolItem
* SvxFmtBreakItem::Create( SvStream
& rStrm
, sal_uInt16 nVersion
) const
3056 sal_Int8 eBreak
, bDummy
;
3058 if( FMTBREAK_NOAUTO
> nVersion
)
3060 return new SvxFmtBreakItem( (const SvxBreak
)eBreak
, Which() );
3063 // -----------------------------------------------------------------------
3065 sal_uInt16
SvxFmtBreakItem::GetValueCount() const
3067 return SVX_BREAK_END
; // SVX_BREAK_PAGE_BOTH + 1
3070 // class SvxFmtKeepItem -------------------------------------------------
3072 SfxPoolItem
* SvxFmtKeepItem::Clone( SfxItemPool
* ) const
3074 return new SvxFmtKeepItem( *this );
3077 // -----------------------------------------------------------------------
3079 SvStream
& SvxFmtKeepItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
3081 rStrm
<< (sal_Int8
)GetValue();
3085 // -----------------------------------------------------------------------
3087 SfxPoolItem
* SvxFmtKeepItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3091 return new SvxFmtKeepItem( sal_Bool( bIsKeep
!= 0 ), Which() );
3094 //------------------------------------------------------------------------
3096 SfxItemPresentation
SvxFmtKeepItem::GetPresentation
3098 SfxItemPresentation ePres
,
3099 SfxMapUnit
/*eCoreUnit*/,
3100 SfxMapUnit
/*ePresUnit*/,
3101 XubString
& rText
, const IntlWrapper
*
3106 case SFX_ITEM_PRESENTATION_NONE
:
3110 case SFX_ITEM_PRESENTATION_NAMELESS
:
3111 case SFX_ITEM_PRESENTATION_COMPLETE
:
3113 sal_uInt16 nId
= RID_SVXITEMS_FMTKEEP_FALSE
;
3116 nId
= RID_SVXITEMS_FMTKEEP_TRUE
;
3117 rText
= EE_RESSTR(nId
);
3120 default: ;//prevent warning
3122 return SFX_ITEM_PRESENTATION_NONE
;
3125 // class SvxLineItem ------------------------------------------------------
3127 SvxLineItem::SvxLineItem( const sal_uInt16 nId
) :
3129 SfxPoolItem ( nId
),
3135 // -----------------------------------------------------------------------
3137 SvxLineItem::SvxLineItem( const SvxLineItem
& rCpy
) :
3139 SfxPoolItem ( rCpy
)
3141 pLine
= rCpy
.GetLine() ? new SvxBorderLine( *rCpy
.GetLine() ) : 0;
3144 // -----------------------------------------------------------------------
3146 SvxLineItem::~SvxLineItem()
3151 // -----------------------------------------------------------------------
3153 SvxLineItem
& SvxLineItem::operator=( const SvxLineItem
& rLine
)
3155 SetLine( rLine
.GetLine() );
3160 // -----------------------------------------------------------------------
3162 int SvxLineItem::operator==( const SfxPoolItem
& rAttr
) const
3164 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
3166 return CmpBrdLn( pLine
, ((SvxLineItem
&)rAttr
).GetLine() );
3169 // -----------------------------------------------------------------------
3171 SfxPoolItem
* SvxLineItem::Clone( SfxItemPool
* ) const
3173 return new SvxLineItem( *this );
3176 bool SvxLineItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemId
) const
3178 sal_Bool bConvert
= 0!=(nMemId
&CONVERT_TWIPS
);
3179 nMemId
&= ~CONVERT_TWIPS
;
3182 rVal
<<= uno::makeAny( SvxBoxItem::SvxLineToLine(pLine
, bConvert
) );
3189 case MID_FG_COLOR
: rVal
<<= sal_Int32(pLine
->GetColor().GetColor()); break;
3190 case MID_OUTER_WIDTH
: rVal
<<= sal_Int32(pLine
->GetOutWidth()); break;
3191 case MID_INNER_WIDTH
: rVal
<<= sal_Int32(pLine
->GetInWidth( )); break;
3192 case MID_DISTANCE
: rVal
<<= sal_Int32(pLine
->GetDistance()); break;
3194 OSL_FAIL( "Wrong MemberId" );
3202 // -----------------------------------------------------------------------
3204 bool SvxLineItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemId
)
3206 sal_Bool bConvert
= 0!=(nMemId
&CONVERT_TWIPS
);
3207 nMemId
&= ~CONVERT_TWIPS
;
3211 table::BorderLine2 aLine
;
3212 if ( lcl_extractBorderLine(rVal
, aLine
) )
3215 pLine
= new SvxBorderLine
;
3216 if( !SvxBoxItem::LineToSvxLine(aLine
, *pLine
, bConvert
) )
3222 else if ( rVal
>>= nVal
)
3225 pLine
= new SvxBorderLine
;
3229 case MID_FG_COLOR
: pLine
->SetColor( Color(nVal
) ); break;
3230 case MID_LINE_STYLE
:
3231 pLine
->SetBorderLineStyle(static_cast<SvxBorderStyle
>(nVal
));
3234 OSL_FAIL( "Wrong MemberId" );
3244 //------------------------------------------------------------------------
3246 SfxItemPresentation
SvxLineItem::GetPresentation
3248 SfxItemPresentation ePres
,
3249 SfxMapUnit eCoreUnit
,
3250 SfxMapUnit ePresUnit
,
3251 XubString
& rText
, const IntlWrapper
*pIntl
3258 case SFX_ITEM_PRESENTATION_NONE
:
3259 return SFX_ITEM_PRESENTATION_NONE
;
3260 case SFX_ITEM_PRESENTATION_NAMELESS
:
3261 case SFX_ITEM_PRESENTATION_COMPLETE
:
3264 rText
= pLine
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
,
3265 (SFX_ITEM_PRESENTATION_COMPLETE
== ePres
) );
3268 default: ;//prevent warning
3270 return SFX_ITEM_PRESENTATION_NONE
;
3273 // -----------------------------------------------------------------------
3275 SvStream
& SvxLineItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
3279 rStrm
<< pLine
->GetColor()
3280 << (short)pLine
->GetOutWidth()
3281 << (short)pLine
->GetInWidth()
3282 << (short)pLine
->GetDistance();
3285 rStrm
<< Color() << (short)0 << (short)0 << (short)0;
3289 // -----------------------------------------------------------------------
3291 bool SvxLineItem::ScaleMetrics( long nMult
, long nDiv
)
3293 if ( pLine
) pLine
->ScaleMetrics( nMult
, nDiv
);
3297 // -----------------------------------------------------------------------
3299 bool SvxLineItem::HasMetrics() const
3304 // -----------------------------------------------------------------------
3306 SfxPoolItem
* SvxLineItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3308 SvxLineItem
* _pLine
= new SvxLineItem( Which() );
3309 short nOutline
, nInline
, nDistance
;
3312 rStrm
>> aColor
>> nOutline
>> nInline
>> nDistance
;
3315 SvxBorderLine
aLine( &aColor
);
3316 aLine
.GuessLinesWidths(NONE
, nOutline
, nInline
, nDistance
);
3317 _pLine
->SetLine( &aLine
);
3322 // -----------------------------------------------------------------------
3324 void SvxLineItem::SetLine( const SvxBorderLine
* pNew
)
3327 pLine
= pNew
? new SvxBorderLine( *pNew
) : 0;
3331 #pragma optimize ( "", off )
3334 // class SvxBrushItem ----------------------------------------------------
3336 #define LOAD_GRAPHIC ((sal_uInt16)0x0001)
3337 #define LOAD_LINK ((sal_uInt16)0x0002)
3338 #define LOAD_FILTER ((sal_uInt16)0x0004)
3340 // class SvxBrushItem_Impl -----------------------------------------------
3342 class SvxBrushItem_Impl
3345 GraphicObject
* pGraphicObject
;
3346 sal_Int8 nGraphicTransparency
; //contains a percentage value which is
3347 //copied to the GraphicObject when necessary
3351 SvxBrushItem_Impl( GraphicObject
* p
) : pGraphicObject( p
), nGraphicTransparency(0), pStream(0) {}
3354 // -----------------------------------------------------------------------
3356 void SvxBrushItem::SetDoneLink( const Link
& rLink
)
3358 pImpl
->aDoneLink
= rLink
;
3361 // -----------------------------------------------------------------------
3363 SvxBrushItem::SvxBrushItem( sal_uInt16 _nWhich
) :
3365 SfxPoolItem( _nWhich
),
3367 aColor ( COL_TRANSPARENT
),
3368 pImpl ( new SvxBrushItem_Impl( 0 ) ),
3370 pStrFilter ( NULL
),
3371 eGraphicPos ( GPOS_NONE
),
3372 bLoadAgain ( sal_True
)
3377 // -----------------------------------------------------------------------
3379 SvxBrushItem::SvxBrushItem( const Color
& rColor
, sal_uInt16 _nWhich
) :
3381 SfxPoolItem( _nWhich
),
3384 pImpl ( new SvxBrushItem_Impl( 0 ) ),
3386 pStrFilter ( NULL
),
3387 eGraphicPos ( GPOS_NONE
),
3388 bLoadAgain ( sal_True
)
3393 // -----------------------------------------------------------------------
3395 SvxBrushItem::SvxBrushItem( const Graphic
& rGraphic
, SvxGraphicPosition ePos
,
3396 sal_uInt16 _nWhich
) :
3398 SfxPoolItem( _nWhich
),
3400 aColor ( COL_TRANSPARENT
),
3401 pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphic
) ) ),
3403 pStrFilter ( NULL
),
3404 eGraphicPos ( ( GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
),
3405 bLoadAgain ( sal_True
)
3408 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3411 // -----------------------------------------------------------------------
3413 SvxBrushItem::SvxBrushItem( const GraphicObject
& rGraphicObj
,
3414 SvxGraphicPosition ePos
, sal_uInt16 _nWhich
) :
3416 SfxPoolItem( _nWhich
),
3418 aColor ( COL_TRANSPARENT
),
3419 pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphicObj
) ) ),
3421 pStrFilter ( NULL
),
3422 eGraphicPos ( ( GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
),
3423 bLoadAgain ( sal_True
)
3426 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3429 // -----------------------------------------------------------------------
3431 SvxBrushItem::SvxBrushItem(
3432 const String
& rLink
, const String
& rFilter
,
3433 SvxGraphicPosition ePos
, sal_uInt16 _nWhich
) :
3435 SfxPoolItem( _nWhich
),
3437 aColor ( COL_TRANSPARENT
),
3438 pImpl ( new SvxBrushItem_Impl( NULL
) ),
3439 pStrLink ( new String( rLink
) ),
3440 pStrFilter ( new String( rFilter
) ),
3441 eGraphicPos ( ( GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
),
3442 bLoadAgain ( sal_True
)
3445 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3448 // -----------------------------------------------------------------------
3450 SvxBrushItem::SvxBrushItem( SvStream
& rStream
, sal_uInt16 nVersion
,
3451 sal_uInt16 _nWhich
) :
3453 SfxPoolItem( _nWhich
),
3455 aColor ( COL_TRANSPARENT
),
3456 pImpl ( new SvxBrushItem_Impl( NULL
) ),
3458 pStrFilter ( NULL
),
3459 eGraphicPos ( GPOS_NONE
)
3464 Color aTempFillColor
;
3468 rStream
>> aTempColor
;
3469 rStream
>> aTempFillColor
;
3476 sal_uInt32 nRed
= aTempColor
.GetRed();
3477 sal_uInt32 nGreen
= aTempColor
.GetGreen();
3478 sal_uInt32 nBlue
= aTempColor
.GetBlue();
3479 nRed
+= (sal_uInt32
)(aTempFillColor
.GetRed())*2;
3480 nGreen
+= (sal_uInt32
)(aTempFillColor
.GetGreen())*2;
3481 nBlue
+= (sal_uInt32
)(aTempFillColor
.GetBlue())*2;
3482 aColor
= Color( (sal_Int8
)(nRed
/3), (sal_Int8
)(nGreen
/3), (sal_Int8
)(nBlue
/3) );
3488 sal_uInt32 nRed
= aTempColor
.GetRed();
3489 sal_uInt32 nGreen
= aTempColor
.GetGreen();
3490 sal_uInt32 nBlue
= aTempColor
.GetBlue();
3491 nRed
+= (sal_uInt32
)(aTempFillColor
.GetRed());
3492 nGreen
+= (sal_uInt32
)(aTempFillColor
.GetGreen());
3493 nBlue
+= (sal_uInt32
)(aTempFillColor
.GetBlue());
3494 aColor
= Color( (sal_Int8
)(nRed
/2), (sal_Int8
)(nGreen
/2), (sal_Int8
)(nBlue
/2) );
3500 sal_uInt32 nRed
= aTempColor
.GetRed()*2;
3501 sal_uInt32 nGreen
= aTempColor
.GetGreen()*2;
3502 sal_uInt32 nBlue
= aTempColor
.GetBlue()*2;
3503 nRed
+= (sal_uInt32
)(aTempFillColor
.GetRed());
3504 nGreen
+= (sal_uInt32
)(aTempFillColor
.GetGreen());
3505 nBlue
+= (sal_uInt32
)(aTempFillColor
.GetBlue());
3506 aColor
= Color( (sal_Int8
)(nRed
/3), (sal_Int8
)(nGreen
/3), (sal_Int8
)(nBlue
/3) );
3510 case 0://BRUSH_NULL:
3511 aColor
= Color( COL_TRANSPARENT
);
3515 aColor
= aTempColor
;
3518 if ( nVersion
>= BRUSH_GRAPHIC_VERSION
)
3520 sal_uInt16 nDoLoad
= 0;
3525 if ( nDoLoad
& LOAD_GRAPHIC
)
3529 rStream
>> aGraphic
;
3530 pImpl
->pGraphicObject
= new GraphicObject( aGraphic
);
3532 if( SVSTREAM_FILEFORMAT_ERROR
== rStream
.GetError() )
3534 rStream
.ResetError();
3535 rStream
.SetError( ERRCODE_SVX_GRAPHIC_WRONG_FILEFORMAT
|
3536 ERRCODE_WARNING_MASK
);
3540 if ( nDoLoad
& LOAD_LINK
)
3542 // UNICODE: rStream >> aRel;
3543 String aRel
= rStream
.ReadUniOrByteString(rStream
.GetStreamCharSet());
3545 // TODO/MBA: how can we get a BaseURL here?!
3546 OSL_FAIL("No BaseURL!");
3547 String aAbs
= INetURLObject::GetAbsURL( String(), aRel
);
3548 DBG_ASSERT( aAbs
.Len(), "Invalid URL!" );
3549 pStrLink
= new String( aAbs
);
3552 if ( nDoLoad
& LOAD_FILTER
)
3554 pStrFilter
= new String
;
3555 // UNICODE: rStream >> *pStrFilter;
3556 *pStrFilter
= rStream
.ReadUniOrByteString(rStream
.GetStreamCharSet());
3561 eGraphicPos
= (SvxGraphicPosition
)nPos
;
3565 // -----------------------------------------------------------------------
3567 SvxBrushItem::SvxBrushItem( const SvxBrushItem
& rItem
) :
3569 SfxPoolItem( rItem
.Which() ),
3571 pImpl ( new SvxBrushItem_Impl( NULL
) ),
3573 pStrFilter ( NULL
),
3574 eGraphicPos ( GPOS_NONE
),
3575 bLoadAgain ( sal_True
)
3581 // -----------------------------------------------------------------------
3583 SvxBrushItem::~SvxBrushItem()
3585 delete pImpl
->pGraphicObject
;
3591 // -----------------------------------------------------------------------
3593 sal_uInt16
SvxBrushItem::GetVersion( sal_uInt16
/*nFileVersion*/ ) const
3595 return BRUSH_GRAPHIC_VERSION
;
3598 // -----------------------------------------------------------------------
3599 inline sal_Int8
lcl_PercentToTransparency(long nPercent
)
3601 //0xff must not be returned!
3602 return sal_Int8(nPercent
? (50 + 0xfe * nPercent
) / 100 : 0);
3604 inline sal_Int8
lcl_TransparencyToPercent(sal_Int32 nTrans
)
3606 return (sal_Int8
)((nTrans
* 100 + 127) / 254);
3609 bool SvxBrushItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
3611 nMemberId
&= ~CONVERT_TWIPS
;
3614 case MID_BACK_COLOR
:
3615 rVal
<<= (sal_Int32
)( aColor
.GetColor() );
3617 case MID_BACK_COLOR_R_G_B
:
3618 rVal
<<= (sal_Int32
)( aColor
.GetRGBColor() );
3620 case MID_BACK_COLOR_TRANSPARENCY
:
3621 rVal
<<= lcl_TransparencyToPercent(aColor
.GetTransparency());
3623 case MID_GRAPHIC_POSITION
:
3624 rVal
<<= (style::GraphicLocation
)(sal_Int16
)eGraphicPos
;
3628 SAL_WARN( "editeng.items", "not implemented" );
3631 case MID_GRAPHIC_TRANSPARENT
:
3632 rVal
= Bool2Any( aColor
.GetTransparency() == 0xff );
3635 case MID_GRAPHIC_URL
:
3640 else if( pImpl
->pGraphicObject
)
3643 UNO_NAME_GRAPHOBJ_URLPREFIX
);
3644 OUString
sId(rtl::OStringToOUString(
3645 pImpl
->pGraphicObject
->GetUniqueID(),
3646 RTL_TEXTENCODING_ASCII_US
));
3647 sLink
= sPrefix
+ sId
;
3653 case MID_GRAPHIC_FILTER
:
3657 sFilter
= *pStrFilter
;
3661 case MID_GRAPHIC_TRANSPARENCY
:
3662 rVal
<<= pImpl
->nGraphicTransparency
;
3669 // -----------------------------------------------------------------------
3671 bool SvxBrushItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
3673 nMemberId
&= ~CONVERT_TWIPS
;
3676 case MID_BACK_COLOR
:
3677 case MID_BACK_COLOR_R_G_B
:
3680 if ( !( rVal
>>= nCol
) )
3682 if(MID_BACK_COLOR_R_G_B
== nMemberId
)
3684 nCol
= COLORDATA_RGB( nCol
);
3685 nCol
+= aColor
.GetColor() & 0xff000000;
3687 aColor
= Color( nCol
);
3690 case MID_BACK_COLOR_TRANSPARENCY
:
3692 sal_Int32 nTrans
= 0;
3693 if ( !( rVal
>>= nTrans
) || nTrans
< 0 || nTrans
> 100 )
3695 aColor
.SetTransparency(lcl_PercentToTransparency(nTrans
));
3699 case MID_GRAPHIC_POSITION
:
3701 style::GraphicLocation eLocation
;
3702 if ( !( rVal
>>=eLocation
) )
3704 sal_Int32 nValue
= 0;
3705 if ( !( rVal
>>= nValue
) )
3707 eLocation
= (style::GraphicLocation
)nValue
;
3709 SetGraphicPos( (SvxGraphicPosition
)(sal_uInt16
)eLocation
);
3714 SAL_WARN( "editeng.items", "not implemented" );
3717 case MID_GRAPHIC_TRANSPARENT
:
3718 aColor
.SetTransparency( Any2Bool( rVal
) ? 0xff : 0 );
3721 case MID_GRAPHIC_URL
:
3723 if ( rVal
.getValueType() == ::getCppuType( (OUString
*)0 ) )
3727 if( 0 == sLink
.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX
,
3728 sizeof(UNO_NAME_GRAPHOBJ_URLPKGPREFIX
)-1 ) )
3730 OSL_FAIL( "package urls aren't implemented" );
3732 else if( 0 == sLink
.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX
,
3733 sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX
)-1 ) )
3735 DELETEZ( pStrLink
);
3736 String
sTmp( sLink
);
3737 rtl::OString
sId(rtl::OUStringToOString(sTmp
.Copy(
3738 sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX
)-1),
3739 RTL_TEXTENCODING_ASCII_US
));
3740 GraphicObject
*pOldGrfObj
= pImpl
->pGraphicObject
;
3741 pImpl
->pGraphicObject
= new GraphicObject( sId
);
3742 ApplyGraphicTransparency_Impl();
3747 SetGraphicLink(sLink
);
3749 if ( !sLink
.isEmpty() && eGraphicPos
== GPOS_NONE
)
3750 eGraphicPos
= GPOS_MM
;
3751 else if( sLink
.isEmpty() )
3752 eGraphicPos
= GPOS_NONE
;
3757 case MID_GRAPHIC_FILTER
:
3759 if( rVal
.getValueType() == ::getCppuType( (OUString
*)0 ) )
3763 SetGraphicFilter( sLink
);
3767 case MID_GRAPHIC_TRANSPARENCY
:
3771 if(nTmp
>= 0 && nTmp
<= 100)
3773 pImpl
->nGraphicTransparency
= sal_Int8(nTmp
);
3774 if(pImpl
->pGraphicObject
)
3775 ApplyGraphicTransparency_Impl();
3784 // -----------------------------------------------------------------------
3786 SfxItemPresentation
SvxBrushItem::GetPresentation
3788 SfxItemPresentation ePres
,
3789 SfxMapUnit
/*eCoreUnit*/,
3790 SfxMapUnit
/*ePresUnit*/,
3791 XubString
& rText
, const IntlWrapper
*
3796 case SFX_ITEM_PRESENTATION_NONE
:
3800 case SFX_ITEM_PRESENTATION_NAMELESS
:
3801 case SFX_ITEM_PRESENTATION_COMPLETE
:
3803 if ( GPOS_NONE
== eGraphicPos
)
3805 rText
= ::GetColorString( aColor
);
3807 sal_uInt16 nId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
3809 if ( aColor
.GetTransparency() )
3810 nId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
3811 rText
+= EE_RESSTR(nId
);
3815 rText
= EE_RESSTR(RID_SVXITEMS_GRAPHIC
);
3820 default: ;//prevent warning
3823 return SFX_ITEM_PRESENTATION_NONE
;
3826 // -----------------------------------------------------------------------
3828 SvxBrushItem
& SvxBrushItem::operator=( const SvxBrushItem
& rItem
)
3830 aColor
= rItem
.aColor
;
3831 eGraphicPos
= rItem
.eGraphicPos
;
3833 DELETEZ( pImpl
->pGraphicObject
);
3834 DELETEZ( pStrLink
);
3835 DELETEZ( pStrFilter
);
3837 if ( GPOS_NONE
!= eGraphicPos
)
3839 if ( rItem
.pStrLink
)
3840 pStrLink
= new String( *rItem
.pStrLink
);
3841 if ( rItem
.pStrFilter
)
3842 pStrFilter
= new String( *rItem
.pStrFilter
);
3843 if ( rItem
.pImpl
->pGraphicObject
)
3845 pImpl
->pGraphicObject
= new GraphicObject( *rItem
.pImpl
->pGraphicObject
);
3848 pImpl
->nGraphicTransparency
= rItem
.pImpl
->nGraphicTransparency
;
3852 // -----------------------------------------------------------------------
3854 int SvxBrushItem::operator==( const SfxPoolItem
& rAttr
) const
3856 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
3858 SvxBrushItem
& rCmp
= (SvxBrushItem
&)rAttr
;
3859 sal_Bool bEqual
= ( aColor
== rCmp
.aColor
&& eGraphicPos
== rCmp
.eGraphicPos
&&
3860 pImpl
->nGraphicTransparency
== rCmp
.pImpl
->nGraphicTransparency
);
3864 if ( GPOS_NONE
!= eGraphicPos
)
3866 if ( !rCmp
.pStrLink
)
3869 bEqual
= pStrLink
&& ( *pStrLink
== *rCmp
.pStrLink
);
3873 if ( !rCmp
.pStrFilter
)
3874 bEqual
= !pStrFilter
;
3876 bEqual
= pStrFilter
&& ( *pStrFilter
== *rCmp
.pStrFilter
);
3879 if ( bEqual
&& !rCmp
.pStrLink
)
3881 if ( !rCmp
.pImpl
->pGraphicObject
)
3882 bEqual
= !pImpl
->pGraphicObject
;
3884 bEqual
= pImpl
->pGraphicObject
&&
3885 ( *pImpl
->pGraphicObject
== *rCmp
.pImpl
->pGraphicObject
);
3893 // -----------------------------------------------------------------------
3895 SfxPoolItem
* SvxBrushItem::Clone( SfxItemPool
* ) const
3897 return new SvxBrushItem( *this );
3900 // -----------------------------------------------------------------------
3902 SfxPoolItem
* SvxBrushItem::Create( SvStream
& rStream
, sal_uInt16 nVersion
) const
3904 return new SvxBrushItem( rStream
, nVersion
, Which() );
3907 // -----------------------------------------------------------------------
3909 SvStream
& SvxBrushItem::Store( SvStream
& rStream
, sal_uInt16
/*nItemVersion*/ ) const
3911 rStream
<< (sal_Bool
)sal_False
;
3914 rStream
<< (sal_Int8
)(aColor
.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
3916 sal_uInt16 nDoLoad
= 0;
3918 if ( pImpl
->pGraphicObject
&& !pStrLink
)
3919 nDoLoad
|= LOAD_GRAPHIC
;
3921 nDoLoad
|= LOAD_LINK
;
3923 nDoLoad
|= LOAD_FILTER
;
3926 if ( pImpl
->pGraphicObject
&& !pStrLink
)
3927 rStream
<< pImpl
->pGraphicObject
->GetGraphic();
3930 OSL_FAIL("No BaseURL!");
3931 // TODO/MBA: how to get a BaseURL?!
3932 String aRel
= INetURLObject::GetRelURL( String(), *pStrLink
);
3933 // UNICODE: rStream << aRel;
3934 rStream
.WriteUniOrByteString(aRel
, rStream
.GetStreamCharSet());
3938 // UNICODE: rStream << *pStrFilter;
3939 rStream
.WriteUniOrByteString(*pStrFilter
, rStream
.GetStreamCharSet());
3941 rStream
<< (sal_Int8
)eGraphicPos
;
3945 // -----------------------------------------------------------------------
3947 void SvxBrushItem::PurgeMedium() const
3949 DELETEZ( pImpl
->pStream
);
3952 // -----------------------------------------------------------------------
3953 const GraphicObject
* SvxBrushItem::GetGraphicObject() const
3955 if ( bLoadAgain
&& pStrLink
&& !pImpl
->pGraphicObject
)
3956 // when graphics already loaded, use as a cache
3958 // only with "valid" names - empty names now allowed
3959 if( pStrLink
->Len() )
3961 pImpl
->pStream
= utl::UcbStreamHelper::CreateStream( *pStrLink
, STREAM_STD_READ
);
3962 if( pImpl
->pStream
&& !pImpl
->pStream
->GetError() )
3966 pImpl
->pStream
->Seek( STREAM_SEEK_TO_BEGIN
);
3967 nRes
= GraphicFilter::GetGraphicFilter().
3968 ImportGraphic( aGraphic
, *pStrLink
, *pImpl
->pStream
,
3969 GRFILTER_FORMAT_DONTKNOW
, NULL
, GRFILTER_I_FLAGS_DONT_SET_LOGSIZE_FOR_JPEG
);
3971 if( nRes
!= GRFILTER_OK
)
3973 const_cast < SvxBrushItem
*> (this)->bLoadAgain
= sal_False
;
3977 pImpl
->pGraphicObject
= new GraphicObject
;
3978 pImpl
->pGraphicObject
->SetGraphic( aGraphic
);
3979 const_cast < SvxBrushItem
*> (this)->ApplyGraphicTransparency_Impl();
3984 const_cast < SvxBrushItem
*> (this)->bLoadAgain
= sal_False
;
3989 return pImpl
->pGraphicObject
;
3992 // -----------------------------------------------------------------------
3994 const Graphic
* SvxBrushItem::GetGraphic() const
3996 const GraphicObject
* pGrafObj
= GetGraphicObject();
3997 return( pGrafObj
? &( pGrafObj
->GetGraphic() ) : NULL
);
4000 // -----------------------------------------------------------------------
4002 void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew
)
4006 if ( GPOS_NONE
== eGraphicPos
)
4008 DELETEZ( pImpl
->pGraphicObject
);
4009 DELETEZ( pStrLink
);
4010 DELETEZ( pStrFilter
);
4014 if ( !pImpl
->pGraphicObject
&& !pStrLink
)
4016 pImpl
->pGraphicObject
= new GraphicObject
; // Creating a dummy
4021 // -----------------------------------------------------------------------
4023 void SvxBrushItem::SetGraphic( const Graphic
& rNew
)
4027 if ( pImpl
->pGraphicObject
)
4028 pImpl
->pGraphicObject
->SetGraphic( rNew
);
4030 pImpl
->pGraphicObject
= new GraphicObject( rNew
);
4032 ApplyGraphicTransparency_Impl();
4034 if ( GPOS_NONE
== eGraphicPos
)
4035 eGraphicPos
= GPOS_MM
; // None would be brush, then Default: middle
4039 OSL_FAIL( "SetGraphic() on linked graphic! :-/" );
4043 // -----------------------------------------------------------------------
4045 void SvxBrushItem::SetGraphicObject( const GraphicObject
& rNewObj
)
4049 if ( pImpl
->pGraphicObject
)
4050 *pImpl
->pGraphicObject
= rNewObj
;
4052 pImpl
->pGraphicObject
= new GraphicObject( rNewObj
);
4054 ApplyGraphicTransparency_Impl();
4056 if ( GPOS_NONE
== eGraphicPos
)
4057 eGraphicPos
= GPOS_MM
; // None would be brush, then Default: middle
4061 OSL_FAIL( "SetGraphic() on linked graphic! :-/" );
4065 // -----------------------------------------------------------------------
4067 void SvxBrushItem::SetGraphicLink( const String
& rNew
)
4070 DELETEZ( pStrLink
);
4076 pStrLink
= new String( rNew
);
4078 DELETEZ( pImpl
->pGraphicObject
);
4082 // -----------------------------------------------------------------------
4084 void SvxBrushItem::SetGraphicFilter( const String
& rNew
)
4087 DELETEZ( pStrFilter
);
4093 pStrFilter
= new String( rNew
);
4098 SvxGraphicPosition
SvxBrushItem::WallpaperStyle2GraphicPos( WallpaperStyle eStyle
)
4100 SvxGraphicPosition eResult
;
4101 // The switch is not the fastest, but the safest
4104 case WALLPAPER_NULL
: eResult
= GPOS_NONE
; break;
4105 case WALLPAPER_TILE
: eResult
= GPOS_TILED
; break;
4106 case WALLPAPER_CENTER
: eResult
= GPOS_MM
; break;
4107 case WALLPAPER_SCALE
: eResult
= GPOS_AREA
; break;
4108 case WALLPAPER_TOPLEFT
: eResult
= GPOS_LT
; break;
4109 case WALLPAPER_TOP
: eResult
= GPOS_MT
; break;
4110 case WALLPAPER_TOPRIGHT
: eResult
= GPOS_RT
; break;
4111 case WALLPAPER_LEFT
: eResult
= GPOS_LM
; break;
4112 case WALLPAPER_RIGHT
: eResult
= GPOS_RM
; break;
4113 case WALLPAPER_BOTTOMLEFT
: eResult
= GPOS_LB
; break;
4114 case WALLPAPER_BOTTOM
: eResult
= GPOS_MB
; break;
4115 case WALLPAPER_BOTTOMRIGHT
: eResult
= GPOS_RB
; break;
4116 default: eResult
= GPOS_NONE
;
4122 WallpaperStyle
SvxBrushItem::GraphicPos2WallpaperStyle( SvxGraphicPosition ePos
)
4124 WallpaperStyle eResult
;
4127 case GPOS_NONE
: eResult
= WALLPAPER_NULL
; break;
4128 case GPOS_TILED
: eResult
= WALLPAPER_TILE
; break;
4129 case GPOS_MM
: eResult
= WALLPAPER_CENTER
; break;
4130 case GPOS_AREA
: eResult
= WALLPAPER_SCALE
; break;
4131 case GPOS_LT
: eResult
= WALLPAPER_TOPLEFT
; break;
4132 case GPOS_MT
: eResult
= WALLPAPER_TOP
; break;
4133 case GPOS_RT
: eResult
= WALLPAPER_TOPRIGHT
; break;
4134 case GPOS_LM
: eResult
= WALLPAPER_LEFT
; break;
4135 case GPOS_RM
: eResult
= WALLPAPER_RIGHT
; break;
4136 case GPOS_LB
: eResult
= WALLPAPER_BOTTOMLEFT
; break;
4137 case GPOS_MB
: eResult
= WALLPAPER_BOTTOM
; break;
4138 case GPOS_RB
: eResult
= WALLPAPER_BOTTOMRIGHT
; break;
4139 default: eResult
= WALLPAPER_NULL
;
4144 SvxBrushItem::SvxBrushItem( const CntWallpaperItem
& rItem
, sal_uInt16 _nWhich
) :
4145 SfxPoolItem( _nWhich
),
4146 pImpl( new SvxBrushItem_Impl( 0 ) ),
4149 bLoadAgain( sal_True
)
4151 aColor
= rItem
.GetColor();
4153 if (!rItem
.GetBitmapURL().isEmpty())
4155 pStrLink
= new String( rItem
.GetBitmapURL() );
4156 SetGraphicPos( WallpaperStyle2GraphicPos((WallpaperStyle
)rItem
.GetStyle() ) );
4161 #pragma optimize ( "", on )
4164 void SvxBrushItem::ApplyGraphicTransparency_Impl()
4166 DBG_ASSERT(pImpl
->pGraphicObject
, "no GraphicObject available" );
4167 if(pImpl
->pGraphicObject
)
4169 GraphicAttr
aAttr(pImpl
->pGraphicObject
->GetAttr());
4170 aAttr
.SetTransparency(lcl_PercentToTransparency(
4171 pImpl
->nGraphicTransparency
));
4172 pImpl
->pGraphicObject
->SetAttr(aAttr
);
4175 // class SvxFrameDirectionItem ----------------------------------------------
4177 SvxFrameDirectionItem::SvxFrameDirectionItem( SvxFrameDirection nValue
,
4178 sal_uInt16 _nWhich
)
4179 : SfxUInt16Item( _nWhich
, (sal_uInt16
)nValue
)
4183 SvxFrameDirectionItem::~SvxFrameDirectionItem()
4187 int SvxFrameDirectionItem::operator==( const SfxPoolItem
& rCmp
) const
4189 DBG_ASSERT( SfxPoolItem::operator==(rCmp
), "unequal types" );
4191 return GetValue() == ((SvxFrameDirectionItem
&)rCmp
).GetValue();
4194 SfxPoolItem
* SvxFrameDirectionItem::Clone( SfxItemPool
* ) const
4196 return new SvxFrameDirectionItem( *this );
4199 SfxPoolItem
* SvxFrameDirectionItem::Create( SvStream
& rStrm
, sal_uInt16
/*nVer*/ ) const
4203 return new SvxFrameDirectionItem( (SvxFrameDirection
)nValue
, Which() );
4206 SvStream
& SvxFrameDirectionItem::Store( SvStream
& rStrm
, sal_uInt16
/*nIVer*/ ) const
4208 sal_uInt16 nValue
= GetValue();
4213 sal_uInt16
SvxFrameDirectionItem::GetVersion( sal_uInt16 nFVer
) const
4215 return SOFFICE_FILEFORMAT_50
> nFVer
? USHRT_MAX
: 0;
4218 SfxItemPresentation
SvxFrameDirectionItem::GetPresentation(
4219 SfxItemPresentation ePres
,
4220 SfxMapUnit
/*eCoreUnit*/,
4221 SfxMapUnit
/*ePresUnit*/,
4222 XubString
& rText
, const IntlWrapper
*) const
4224 SfxItemPresentation eRet
= ePres
;
4227 case SFX_ITEM_PRESENTATION_NONE
:
4231 case SFX_ITEM_PRESENTATION_NAMELESS
:
4232 case SFX_ITEM_PRESENTATION_COMPLETE
:
4233 rText
= EE_RESSTR( RID_SVXITEMS_FRMDIR_BEGIN
+ GetValue() );
4237 eRet
= SFX_ITEM_PRESENTATION_NONE
;
4242 bool SvxFrameDirectionItem::PutValue( const com::sun::star::uno::Any
& rVal
,
4245 sal_Int16 nVal
= sal_Int16();
4246 sal_Bool bRet
= ( rVal
>>= nVal
);
4249 // translate WritingDirection2 constants into SvxFrameDirection
4252 case text::WritingMode2::LR_TB
:
4253 SetValue( FRMDIR_HORI_LEFT_TOP
);
4255 case text::WritingMode2::RL_TB
:
4256 SetValue( FRMDIR_HORI_RIGHT_TOP
);
4258 case text::WritingMode2::TB_RL
:
4259 SetValue( FRMDIR_VERT_TOP_RIGHT
);
4261 case text::WritingMode2::TB_LR
:
4262 SetValue( FRMDIR_VERT_TOP_LEFT
);
4264 case text::WritingMode2::PAGE
:
4265 SetValue( FRMDIR_ENVIRONMENT
);
4276 bool SvxFrameDirectionItem::QueryValue( com::sun::star::uno::Any
& rVal
,
4279 // translate SvxFrameDirection into WritingDirection2
4282 switch( GetValue() )
4284 case FRMDIR_HORI_LEFT_TOP
:
4285 nVal
= text::WritingMode2::LR_TB
;
4287 case FRMDIR_HORI_RIGHT_TOP
:
4288 nVal
= text::WritingMode2::RL_TB
;
4290 case FRMDIR_VERT_TOP_RIGHT
:
4291 nVal
= text::WritingMode2::TB_RL
;
4293 case FRMDIR_VERT_TOP_LEFT
:
4294 nVal
= text::WritingMode2::TB_LR
;
4296 case FRMDIR_ENVIRONMENT
:
4297 nVal
= text::WritingMode2::PAGE
;
4300 OSL_FAIL("Unknown SvxFrameDirection value!");
4305 // return value + error state
4313 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */