1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/uno/Any.hxx>
21 #include <com/sun/star/drawing/LineStyle.hpp>
22 #include <com/sun/star/script/Converter.hpp>
23 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 #include <com/sun/star/table/ShadowLocation.hpp>
25 #include <com/sun/star/table/TableBorder.hpp>
26 #include <com/sun/star/table/ShadowFormat.hpp>
27 #include <com/sun/star/table/CellRangeAddress.hpp>
28 #include <com/sun/star/table/CellContentType.hpp>
29 #include <com/sun/star/table/TableOrientation.hpp>
30 #include <com/sun/star/util/SortField.hpp>
31 #include <com/sun/star/util/SortFieldType.hpp>
32 #include <com/sun/star/table/BorderLine2.hpp>
33 #include <com/sun/star/table/BorderLineStyle.hpp>
34 #include <com/sun/star/table/CellOrientation.hpp>
35 #include <com/sun/star/table/CellAddress.hpp>
36 #include <com/sun/star/style/PageStyleLayout.hpp>
37 #include <com/sun/star/style/BreakType.hpp>
38 #include <com/sun/star/style/GraphicLocation.hpp>
39 #include <com/sun/star/awt/Rectangle.hpp>
40 #include <com/sun/star/awt/Selection.hpp>
41 #include <com/sun/star/awt/Size.hpp>
42 #include <com/sun/star/text/WritingMode2.hpp>
43 #include <com/sun/star/frame/status/UpperLowerMarginScale.hpp>
45 #include <unotools/ucbstreamhelper.hxx>
47 #include <comphelper/processfactory.hxx>
48 #include <svtools/grfmgr.hxx>
49 #include <tools/urlobj.hxx>
50 #include <comphelper/types.hxx>
51 #include <svl/memberid.hrc>
52 #include <svtools/wallitem.hxx>
53 #include <svl/cntwall.hxx>
54 #include <svtools/borderhelper.hxx>
55 #include <rtl/ustring.hxx>
56 #include <rtl/ustrbuf.hxx>
57 #include <vcl/graphicfilter.hxx>
58 #include <editeng/editids.hrc>
59 #include <editeng/editrids.hrc>
60 #include <editeng/pbinitem.hxx>
61 #include <editeng/sizeitem.hxx>
62 #include <editeng/lrspitem.hxx>
63 #include <editeng/ulspitem.hxx>
64 #include <editeng/prntitem.hxx>
65 #include <editeng/opaqitem.hxx>
66 #include <editeng/protitem.hxx>
67 #include <editeng/shaditem.hxx>
68 #include <editeng/boxitem.hxx>
69 #include <editeng/brkitem.hxx>
70 #include <editeng/keepitem.hxx>
71 #include <editeng/bolnitem.hxx>
72 #include <editeng/brshitem.hxx>
73 #include <editeng/frmdiritem.hxx>
74 #include <editeng/itemtype.hxx>
75 #include <editeng/eerdll.hxx>
76 #include <editeng/unoprnms.hxx>
77 #include <editeng/memberids.hrc>
78 #include <editeng/editerr.hxx>
80 using namespace ::editeng
;
81 using namespace ::rtl
;
82 using namespace ::com::sun::star
;
83 using namespace ::com::sun::star::table::BorderLineStyle
;
87 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
88 #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
89 #define TWIP_TO_MM100_UNSIGNED(TWIP) ((((TWIP)*127L+36L)/72L))
90 #define MM100_TO_TWIP_UNSIGNED(MM100) ((((MM100)*72L+63L)/127L))
92 // STATIC DATA -----------------------------------------------------------
94 inline void SetValueProp( XubString
& rStr
, const sal_uInt16 nValue
,
95 const sal_uInt16 nProp
)
98 rStr
+= String::CreateFromInt32( nValue
);
100 ( rStr
+= String::CreateFromInt32( nProp
)) += sal_Unicode('%');
103 inline void SetValueProp( XubString
& rStr
, const short nValue
,
104 const sal_uInt16 nProp
)
107 rStr
+= String::CreateFromInt32( nValue
);
109 ( rStr
+= String::CreateFromInt32( nProp
)) += sal_Unicode('%');
112 // -----------------------------------------------------------------------
115 SvxBorderLine is not an SfxPoolItem, and has no Store/Create serialization/deserialization methods.
116 Since border line information needs to be serialized by the table autoformat code, these file-local
117 methods are defined to encapsulate the necessary serialization logic.
121 /// Item version for saved border lines. The old version saves the line without style information.
122 const int BORDER_LINE_OLD_VERSION
= 0;
123 /// Item version for saved border lies. The new version includes line style.
124 const int BORDER_LINE_WITH_STYLE_VERSION
= 1;
126 /// Store a border line to a stream.
127 SvStream
& StoreBorderLine(SvStream
&stream
, const SvxBorderLine
&l
, sal_uInt16 version
)
129 stream
<< l
.GetColor()
134 if (version
>= BORDER_LINE_WITH_STYLE_VERSION
)
135 stream
<< static_cast<sal_uInt16
>(l
.GetBorderLineStyle());
140 /// Creates a border line from a stream.
141 SvxBorderLine
CreateBorderLine(SvStream
&stream
, sal_uInt16 version
)
143 sal_uInt16 nOutline
, nInline
, nDistance
;
144 sal_uInt16 nStyle
= NONE
;
146 stream
>> aColor
>> nOutline
>> nInline
>> nDistance
;
148 if (version
>= BORDER_LINE_WITH_STYLE_VERSION
)
151 SvxBorderLine
border(&aColor
);
152 border
.GuessLinesWidths(nStyle
, nOutline
, nInline
, nDistance
);
156 /// Retrieves a BORDER_LINE_* version from a BOX_BORDER_* version.
157 sal_uInt16
BorderLineVersionFromBoxVersion(sal_uInt16 boxVersion
)
159 return (boxVersion
>= BOX_BORDER_STYLE_VERSION
)? BORDER_LINE_WITH_STYLE_VERSION
: BORDER_LINE_OLD_VERSION
;
163 TYPEINIT1_FACTORY(SvxPaperBinItem
, SfxByteItem
, new SvxPaperBinItem(0));
164 TYPEINIT1_FACTORY(SvxSizeItem
, SfxPoolItem
, new SvxSizeItem(0));
165 TYPEINIT1_FACTORY(SvxLRSpaceItem
, SfxPoolItem
, new SvxLRSpaceItem(0));
166 TYPEINIT1_FACTORY(SvxULSpaceItem
, SfxPoolItem
, new SvxULSpaceItem(0));
167 TYPEINIT1_FACTORY(SvxPrintItem
, SfxBoolItem
, new SvxPrintItem(0));
168 TYPEINIT1_FACTORY(SvxOpaqueItem
, SfxBoolItem
, new SvxOpaqueItem(0));
169 TYPEINIT1_FACTORY(SvxProtectItem
, SfxPoolItem
, new SvxProtectItem(0));
170 TYPEINIT1_FACTORY(SvxBrushItem
, SfxPoolItem
, new SvxBrushItem(0));
171 TYPEINIT1_FACTORY(SvxShadowItem
, SfxPoolItem
, new SvxShadowItem(0));
172 TYPEINIT1_FACTORY(SvxBoxItem
, SfxPoolItem
, new SvxBoxItem(0));
173 TYPEINIT1_FACTORY(SvxBoxInfoItem
, SfxPoolItem
, new SvxBoxInfoItem(0));
174 TYPEINIT1_FACTORY(SvxFmtBreakItem
, SfxEnumItem
, new SvxFmtBreakItem(SVX_BREAK_NONE
, 0));
175 TYPEINIT1_FACTORY(SvxFmtKeepItem
, SfxBoolItem
, new SvxFmtKeepItem(sal_False
, 0));
176 TYPEINIT1_FACTORY(SvxLineItem
, SfxPoolItem
, new SvxLineItem(0));
177 TYPEINIT1_FACTORY(SvxFrameDirectionItem
, SfxUInt16Item
, new SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP
, 0));
179 // class SvxPaperBinItem ------------------------------------------------
181 SfxPoolItem
* SvxPaperBinItem::Clone( SfxItemPool
* ) const
183 return new SvxPaperBinItem( *this );
186 // -----------------------------------------------------------------------
188 SvStream
& SvxPaperBinItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
194 // -----------------------------------------------------------------------
196 SfxPoolItem
* SvxPaperBinItem::Create( SvStream
& rStrm
, sal_uInt16
) const
200 return new SvxPaperBinItem( Which(), nBin
);
203 // -----------------------------------------------------------------------
205 SfxItemPresentation
SvxPaperBinItem::GetPresentation
207 SfxItemPresentation ePres
,
208 SfxMapUnit
/*eCoreUnit*/,
209 SfxMapUnit
/*ePresUnit*/,
210 XubString
& rText
, const IntlWrapper
*
215 case SFX_ITEM_PRESENTATION_NONE
:
217 return SFX_ITEM_PRESENTATION_NONE
;
219 case SFX_ITEM_PRESENTATION_NAMELESS
:
220 rText
= String::CreateFromInt32( GetValue() );
221 return SFX_ITEM_PRESENTATION_NAMELESS
;
223 case SFX_ITEM_PRESENTATION_COMPLETE
:
225 sal_uInt8 nValue
= GetValue();
227 if ( PAPERBIN_PRINTER_SETTINGS
== nValue
)
228 rText
= EE_RESSTR(RID_SVXSTR_PAPERBIN_SETTINGS
);
231 rText
= EE_RESSTR(RID_SVXSTR_PAPERBIN
);
232 rText
+= sal_Unicode(' ');
233 rText
+= String::CreateFromInt32( nValue
);
235 return SFX_ITEM_PRESENTATION_COMPLETE
;
238 default: ;//prevent warning
241 return SFX_ITEM_PRESENTATION_NONE
;
244 // class SvxSizeItem -----------------------------------------------------
246 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId
, const Size
& rSize
) :
254 // -----------------------------------------------------------------------
255 bool SvxSizeItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
257 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
258 nMemberId
&= ~CONVERT_TWIPS
;
260 awt::Size
aTmp(aSize
.Width(), aSize
.Height());
263 aTmp
.Height
= TWIP_TO_MM100(aTmp
.Height
);
264 aTmp
.Width
= TWIP_TO_MM100(aTmp
.Width
);
269 case MID_SIZE_SIZE
: rVal
<<= aTmp
; break;
270 case MID_SIZE_WIDTH
: rVal
<<= aTmp
.Width
; break;
271 case MID_SIZE_HEIGHT
: rVal
<<= aTmp
.Height
; break;
272 default: OSL_FAIL("Wrong MemberId!"); return false;
277 // -----------------------------------------------------------------------
278 bool SvxSizeItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
280 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
281 nMemberId
&= ~CONVERT_TWIPS
;
292 aTmp
.Height
= MM100_TO_TWIP(aTmp
.Height
);
293 aTmp
.Width
= MM100_TO_TWIP(aTmp
.Width
);
295 aSize
= Size( aTmp
.Width
, aTmp
.Height
);
306 if(!(rVal
>>= nVal
))
309 aSize
.Width() = bConvert
? MM100_TO_TWIP(nVal
) : nVal
;
312 case MID_SIZE_HEIGHT
:
318 aSize
.Height() = bConvert
? MM100_TO_TWIP(nVal
) : nVal
;
321 default: OSL_FAIL("Wrong MemberId!");
327 // -----------------------------------------------------------------------
329 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId
) :
335 // -----------------------------------------------------------------------
337 int SvxSizeItem::operator==( const SfxPoolItem
& rAttr
) const
339 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
341 return ( aSize
== ( (SvxSizeItem
&)rAttr
).GetSize() );
344 // -----------------------------------------------------------------------
346 SfxPoolItem
* SvxSizeItem::Clone( SfxItemPool
* ) const
348 return new SvxSizeItem( *this );
351 //------------------------------------------------------------------------
353 SfxItemPresentation
SvxSizeItem::GetPresentation
355 SfxItemPresentation ePres
,
356 SfxMapUnit eCoreUnit
,
357 SfxMapUnit ePresUnit
,
358 XubString
& rText
, const IntlWrapper
*pIntl
363 case SFX_ITEM_PRESENTATION_NONE
:
365 return SFX_ITEM_PRESENTATION_NONE
;
367 case SFX_ITEM_PRESENTATION_NAMELESS
:
368 rText
= GetMetricText( aSize
.Width(), eCoreUnit
, ePresUnit
, pIntl
);
370 rText
+= GetMetricText( aSize
.Height(), eCoreUnit
, ePresUnit
, pIntl
);
371 return SFX_ITEM_PRESENTATION_NAMELESS
;
373 case SFX_ITEM_PRESENTATION_COMPLETE
:
374 rText
= EE_RESSTR(RID_SVXITEMS_SIZE_WIDTH
);
375 rText
+= GetMetricText( aSize
.Width(), eCoreUnit
, ePresUnit
, pIntl
);
376 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
378 rText
+= EE_RESSTR(RID_SVXITEMS_SIZE_HEIGHT
);
379 rText
+= GetMetricText( aSize
.Height(), eCoreUnit
, ePresUnit
, pIntl
);
380 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
381 return SFX_ITEM_PRESENTATION_COMPLETE
;
383 default: ;//prevent warning
386 return SFX_ITEM_PRESENTATION_NONE
;
389 // -----------------------------------------------------------------------
391 SvStream
& SvxSizeItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
393 //#fdo39428 SvStream no longer supports operator<<(long)
394 rStrm
<< sal::static_int_cast
<sal_Int32
>(aSize
.Width());
395 rStrm
<< sal::static_int_cast
<sal_Int32
>(aSize
.Height());
399 // -----------------------------------------------------------------------
401 bool SvxSizeItem::ScaleMetrics( long nMult
, long nDiv
)
403 aSize
.Width() = Scale( aSize
.Width(), nMult
, nDiv
);
404 aSize
.Height() = Scale( aSize
.Height(), nMult
, nDiv
);
408 // -----------------------------------------------------------------------
410 bool SvxSizeItem::HasMetrics() const
415 // -----------------------------------------------------------------------
417 SfxPoolItem
* SvxSizeItem::Create( SvStream
& rStrm
, sal_uInt16
) const
419 //#fdo39428 SvStream no longer supports operator>>(long&)
420 sal_Int32
nWidth(0), nHeight(0);
421 rStrm
>> nWidth
>> nHeight
;
423 SvxSizeItem
* pAttr
= new SvxSizeItem( Which() );
424 pAttr
->SetSize(Size(nWidth
, nHeight
));
429 // class SvxLRSpaceItem --------------------------------------------------
431 SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId
) :
435 nFirstLineOfst ( 0 ),
439 nPropFirstLineOfst( 100 ),
440 nPropLeftMargin( 100 ),
441 nPropRightMargin( 100 ),
446 // -----------------------------------------------------------------------
448 SvxLRSpaceItem::SvxLRSpaceItem( const long nLeft
, const long nRight
,
449 const long nTLeft
, const short nOfset
,
450 const sal_uInt16 nId
) :
454 nFirstLineOfst ( nOfset
),
456 nLeftMargin ( nLeft
),
457 nRightMargin ( nRight
),
458 nPropFirstLineOfst( 100 ),
459 nPropLeftMargin( 100 ),
460 nPropRightMargin( 100 ),
465 // -----------------------------------------------------------------------
466 bool SvxLRSpaceItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
469 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
470 nMemberId
&= ~CONVERT_TWIPS
;
475 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100(nLeftMargin
) : nLeftMargin
);
478 case MID_TXT_LMARGIN
:
479 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100(nTxtLeft
) : nTxtLeft
);
482 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100(nRightMargin
) : nRightMargin
);
484 case MID_L_REL_MARGIN
:
485 rVal
<<= (sal_Int16
)nPropLeftMargin
;
487 case MID_R_REL_MARGIN
:
488 rVal
<<= (sal_Int16
)nPropRightMargin
;
491 case MID_FIRST_LINE_INDENT
:
492 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100(nFirstLineOfst
) : nFirstLineOfst
);
495 case MID_FIRST_LINE_REL_INDENT
:
496 rVal
<<= (sal_Int16
)(nPropFirstLineOfst
);
500 rVal
= Bool2Any(IsAutoFirst());
505 OSL_FAIL("unknown MemberId");
510 // -----------------------------------------------------------------------
511 bool SvxLRSpaceItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
513 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
514 nMemberId
&= ~CONVERT_TWIPS
;
516 if( nMemberId
!= MID_FIRST_AUTO
&&
517 nMemberId
!= MID_L_REL_MARGIN
&& nMemberId
!= MID_R_REL_MARGIN
)
524 SetLeft((sal_Int32
)bConvert
? MM100_TO_TWIP(nVal
) : nVal
);
527 case MID_TXT_LMARGIN
:
528 SetTxtLeft((sal_Int32
)bConvert
? MM100_TO_TWIP(nVal
) : nVal
);
532 SetRight((sal_Int32
) bConvert
? MM100_TO_TWIP(nVal
) : nVal
);
534 case MID_L_REL_MARGIN
:
535 case MID_R_REL_MARGIN
:
538 if((rVal
>>= nRel
) && nRel
>= 0 && nRel
< USHRT_MAX
)
540 if(MID_L_REL_MARGIN
== nMemberId
)
541 nPropLeftMargin
= (sal_uInt16
)nRel
;
543 nPropRightMargin
= (sal_uInt16
)nRel
;
549 case MID_FIRST_LINE_INDENT
:
550 SetTxtFirstLineOfst((short)(bConvert
? MM100_TO_TWIP(nVal
) : nVal
));
553 case MID_FIRST_LINE_REL_INDENT
:
554 SetPropTxtFirstLineOfst ( (sal_uInt16
)nVal
);
558 SetAutoFirst( Any2Bool(rVal
) );
562 OSL_FAIL("unknown MemberId");
568 // -----------------------------------------------------------------------
570 // Adapt nLeftMargin and nTxtLeft.
572 void SvxLRSpaceItem::AdjustLeft()
574 if ( 0 > nFirstLineOfst
)
575 nLeftMargin
= nTxtLeft
+ nFirstLineOfst
;
577 nLeftMargin
= nTxtLeft
;
580 // -----------------------------------------------------------------------
582 int SvxLRSpaceItem::operator==( const SfxPoolItem
& rAttr
) const
584 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
587 nLeftMargin
== ((SvxLRSpaceItem
&)rAttr
).GetLeft() &&
588 nRightMargin
== ((SvxLRSpaceItem
&)rAttr
).GetRight() &&
589 nFirstLineOfst
== ((SvxLRSpaceItem
&)rAttr
).GetTxtFirstLineOfst() &&
590 nPropLeftMargin
== ((SvxLRSpaceItem
&)rAttr
).GetPropLeft() &&
591 nPropRightMargin
== ((SvxLRSpaceItem
&)rAttr
).GetPropRight() &&
592 nPropFirstLineOfst
== ((SvxLRSpaceItem
&)rAttr
).GetPropTxtFirstLineOfst() &&
593 bAutoFirst
== ((SvxLRSpaceItem
&)rAttr
).IsAutoFirst() );
596 // -----------------------------------------------------------------------
598 SfxPoolItem
* SvxLRSpaceItem::Clone( SfxItemPool
* ) const
600 return new SvxLRSpaceItem( *this );
603 //------------------------------------------------------------------------
605 SfxItemPresentation
SvxLRSpaceItem::GetPresentation
607 SfxItemPresentation ePres
,
608 SfxMapUnit eCoreUnit
,
609 SfxMapUnit ePresUnit
,
610 XubString
& rText
, const IntlWrapper
* pIntl
615 case SFX_ITEM_PRESENTATION_NONE
:
617 return SFX_ITEM_PRESENTATION_NONE
;
618 case SFX_ITEM_PRESENTATION_NAMELESS
:
620 if ( 100 != nPropLeftMargin
)
621 ( rText
= String::CreateFromInt32( nPropLeftMargin
)) += sal_Unicode('%');
623 rText
= GetMetricText( (long)nLeftMargin
,
624 eCoreUnit
, ePresUnit
, pIntl
);
626 if ( 100 != nPropFirstLineOfst
)
627 ( rText
+= String::CreateFromInt32( nPropFirstLineOfst
)) += sal_Unicode('%');
629 rText
+= GetMetricText( (long)nFirstLineOfst
,
630 eCoreUnit
, ePresUnit
, pIntl
);
632 if ( 100 != nRightMargin
)
633 ( rText
+= String::CreateFromInt32( nRightMargin
)) += sal_Unicode('%');
635 rText
+= GetMetricText( (long)nRightMargin
,
636 eCoreUnit
, ePresUnit
, pIntl
);
637 return SFX_ITEM_PRESENTATION_NAMELESS
;
639 case SFX_ITEM_PRESENTATION_COMPLETE
:
641 rText
= EE_RESSTR(RID_SVXITEMS_LRSPACE_LEFT
);
642 if ( 100 != nPropLeftMargin
)
643 ( rText
+= String::CreateFromInt32( nPropLeftMargin
)) += sal_Unicode('%');
646 rText
+= GetMetricText( (long)nLeftMargin
,
647 eCoreUnit
, ePresUnit
, pIntl
);
648 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
651 if ( 100 != nPropFirstLineOfst
|| nFirstLineOfst
)
653 rText
+= EE_RESSTR(RID_SVXITEMS_LRSPACE_FLINE
);
654 if ( 100 != nPropFirstLineOfst
)
655 ( rText
+= String::CreateFromInt32( nPropFirstLineOfst
))
659 rText
+= GetMetricText( (long)nFirstLineOfst
,
660 eCoreUnit
, ePresUnit
, pIntl
);
661 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
665 rText
+= EE_RESSTR(RID_SVXITEMS_LRSPACE_RIGHT
);
666 if ( 100 != nPropRightMargin
)
667 ( rText
+= String::CreateFromInt32( nPropRightMargin
)) += sal_Unicode('%');
670 rText
+= GetMetricText( (long)nRightMargin
,
671 eCoreUnit
, ePresUnit
, pIntl
);
672 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
674 return SFX_ITEM_PRESENTATION_COMPLETE
;
676 default: ;//prevent warning
678 return SFX_ITEM_PRESENTATION_NONE
;
681 // -----------------------------------------------------------------------
683 // BulletFI: Before 501 in the Outliner the bullet was not on the position of
684 // the FI, so in older documents one must set FI to 0.
685 #define BULLETLR_MARKER 0x599401FE
687 SvStream
& SvxLRSpaceItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
689 short nSaveFI
= nFirstLineOfst
;
690 ((SvxLRSpaceItem
*)this)->SetTxtFirstLineOfst( 0 ); // nLeftMargin is manipulated together with this, see Create()
692 sal_uInt16 nMargin
= 0;
693 if( nLeftMargin
> 0 )
694 nMargin
= sal_uInt16( nLeftMargin
);
696 rStrm
<< nPropLeftMargin
;
697 if( nRightMargin
> 0 )
698 nMargin
= sal_uInt16( nRightMargin
);
702 rStrm
<< nPropRightMargin
;
703 rStrm
<< nFirstLineOfst
;
704 rStrm
<< nPropFirstLineOfst
;
706 nMargin
= sal_uInt16( nTxtLeft
);
710 if( nItemVersion
>= LRSPACE_AUTOFIRST_VERSION
)
712 sal_Int8 nAutoFirst
= bAutoFirst
? 1 : 0;
713 if( nItemVersion
>= LRSPACE_NEGATIVE_VERSION
&&
714 ( nLeftMargin
< 0 || nRightMargin
< 0 || nTxtLeft
< 0 ) )
718 // From 6.0 onwards, do not write Magic numbers...
719 DBG_ASSERT( rStrm
.GetVersion() <= SOFFICE_FILEFORMAT_50
, "Change File format SvxLRSpaceItem!" );
720 rStrm
<< (sal_uInt32
) BULLETLR_MARKER
;
723 if( 0x80 & nAutoFirst
)
725 rStrm
<< static_cast<sal_Int32
>(nLeftMargin
);
726 rStrm
<< static_cast<sal_Int32
>(nRightMargin
);
730 ((SvxLRSpaceItem
*)this)->SetTxtFirstLineOfst( nSaveFI
);
735 // -----------------------------------------------------------------------
737 SfxPoolItem
* SvxLRSpaceItem::Create( SvStream
& rStrm
, sal_uInt16 nVersion
) const
739 sal_uInt16 left
, prpleft
, right
, prpright
, prpfirstline
, txtleft
;
741 sal_Int8 autofirst
= 0;
743 if ( nVersion
>= LRSPACE_AUTOFIRST_VERSION
)
745 rStrm
>> left
>> prpleft
>> right
>> prpright
>> firstline
>>
746 prpfirstline
>> txtleft
>> autofirst
;
748 sal_uInt32 nPos
= rStrm
.Tell();
751 if ( nMarker
== BULLETLR_MARKER
)
755 left
= left
+ static_cast<sal_uInt16
>(firstline
); // see below: txtleft = ...
760 else if ( nVersion
== LRSPACE_TXTLEFT_VERSION
)
762 rStrm
>> left
>> prpleft
>> right
>> prpright
>> firstline
>>
763 prpfirstline
>> txtleft
;
765 else if ( nVersion
== LRSPACE_16_VERSION
)
767 rStrm
>> left
>> prpleft
>> right
>> prpright
>> firstline
>>
772 sal_Int8 nL
, nR
, nFL
;
773 rStrm
>> left
>> nL
>> right
>> nR
>> firstline
>> nFL
;
774 prpleft
= (sal_uInt16
)nL
;
775 prpright
= (sal_uInt16
)nR
;
776 prpfirstline
= (sal_uInt16
)nFL
;
779 txtleft
= firstline
>= 0 ? left
: left
- firstline
;
780 SvxLRSpaceItem
* pAttr
= new SvxLRSpaceItem( Which() );
782 pAttr
->nLeftMargin
= left
;
783 pAttr
->nPropLeftMargin
= prpleft
;
784 pAttr
->nRightMargin
= right
;
785 pAttr
->nPropRightMargin
= prpright
;
786 pAttr
->nFirstLineOfst
= firstline
;
787 pAttr
->nPropFirstLineOfst
= prpfirstline
;
788 pAttr
->nTxtLeft
= txtleft
;
789 pAttr
->bAutoFirst
= autofirst
& 0x01;
790 if( nVersion
>= LRSPACE_NEGATIVE_VERSION
&& ( autofirst
& 0x80 ) )
794 pAttr
->nLeftMargin
= nMargin
;
795 pAttr
->nTxtLeft
= firstline
>= 0 ? nMargin
: nMargin
- firstline
;
797 pAttr
->nRightMargin
= nMargin
;
802 // -----------------------------------------------------------------------
804 sal_uInt16
SvxLRSpaceItem::GetVersion( sal_uInt16 nFileVersion
) const
806 return (nFileVersion
== SOFFICE_FILEFORMAT_31
)
807 ? LRSPACE_TXTLEFT_VERSION
808 : LRSPACE_NEGATIVE_VERSION
;
811 // -----------------------------------------------------------------------
813 bool SvxLRSpaceItem::ScaleMetrics( long nMult
, long nDiv
)
815 nFirstLineOfst
= (short)Scale( nFirstLineOfst
, nMult
, nDiv
);
816 nTxtLeft
= Scale( nTxtLeft
, nMult
, nDiv
);
817 nLeftMargin
= Scale( nLeftMargin
, nMult
, nDiv
);
818 nRightMargin
= Scale( nRightMargin
, nMult
, nDiv
);
822 // -----------------------------------------------------------------------
824 bool SvxLRSpaceItem::HasMetrics() const
829 // class SvxULSpaceItem --------------------------------------------------
831 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nId
)
841 // -----------------------------------------------------------------------
843 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nUp
, const sal_uInt16 nLow
,
844 const sal_uInt16 nId
)
854 // -----------------------------------------------------------------------
855 bool SvxULSpaceItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
857 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
858 nMemberId
&= ~CONVERT_TWIPS
;
864 ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale
;
865 aUpperLowerMarginScale
.Upper
= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nUpper
) : nUpper
);
866 aUpperLowerMarginScale
.Lower
= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nLower
) : nPropUpper
);
867 aUpperLowerMarginScale
.ScaleUpper
= (sal_Int16
)nPropUpper
;
868 aUpperLowerMarginScale
.ScaleLower
= (sal_Int16
)nPropLower
;
869 rVal
<<= aUpperLowerMarginScale
;
872 case MID_UP_MARGIN
: rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nUpper
) : nUpper
); break;
873 case MID_LO_MARGIN
: rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nLower
) : nLower
); break;
874 case MID_CTX_MARGIN
: rVal
<<= bContext
; break;
875 case MID_UP_REL_MARGIN
: rVal
<<= (sal_Int16
) nPropUpper
; break;
876 case MID_LO_REL_MARGIN
: rVal
<<= (sal_Int16
) nPropLower
; break;
881 // -----------------------------------------------------------------------
882 bool SvxULSpaceItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
884 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
885 nMemberId
&= ~CONVERT_TWIPS
;
892 ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale
;
893 if ( !(rVal
>>= aUpperLowerMarginScale
))
896 SetUpper((sal_uInt16
)(bConvert
? MM100_TO_TWIP( aUpperLowerMarginScale
.Upper
) : aUpperLowerMarginScale
.Upper
));
897 SetLower((sal_uInt16
)(bConvert
? MM100_TO_TWIP( aUpperLowerMarginScale
.Lower
) : aUpperLowerMarginScale
.Lower
));
898 if( aUpperLowerMarginScale
.ScaleUpper
> 1 )
899 nPropUpper
= aUpperLowerMarginScale
.ScaleUpper
;
900 if( aUpperLowerMarginScale
.ScaleLower
> 1 )
901 nPropUpper
= aUpperLowerMarginScale
.ScaleLower
;
906 if(!(rVal
>>= nVal
) || nVal
< 0)
908 SetUpper((sal_uInt16
)(bConvert
? MM100_TO_TWIP(nVal
) : nVal
));
911 if(!(rVal
>>= nVal
) || nVal
< 0)
913 SetLower((sal_uInt16
)(bConvert
? MM100_TO_TWIP(nVal
) : nVal
));
915 case MID_CTX_MARGIN
:
916 if (!(rVal
>>= bVal
))
918 SetContextValue(bVal
);
920 case MID_UP_REL_MARGIN
:
921 case MID_LO_REL_MARGIN
:
924 if((rVal
>>= nRel
) && nRel
> 1 )
926 if(MID_UP_REL_MARGIN
== nMemberId
)
927 nPropUpper
= (sal_uInt16
)nRel
;
929 nPropLower
= (sal_uInt16
)nRel
;
937 OSL_FAIL("unknown MemberId");
943 // -----------------------------------------------------------------------
945 int SvxULSpaceItem::operator==( const SfxPoolItem
& rAttr
) const
947 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
949 return ( nUpper
== ( (SvxULSpaceItem
&)rAttr
).nUpper
&&
950 nLower
== ( (SvxULSpaceItem
&)rAttr
).nLower
&&
951 bContext
== ( (SvxULSpaceItem
&)rAttr
).bContext
&&
952 nPropUpper
== ( (SvxULSpaceItem
&)rAttr
).nPropUpper
&&
953 nPropLower
== ( (SvxULSpaceItem
&)rAttr
).nPropLower
);
956 // -----------------------------------------------------------------------
958 SfxPoolItem
* SvxULSpaceItem::Clone( SfxItemPool
* ) const
960 return new SvxULSpaceItem( *this );
963 //------------------------------------------------------------------------
965 SfxItemPresentation
SvxULSpaceItem::GetPresentation
967 SfxItemPresentation ePres
,
968 SfxMapUnit eCoreUnit
,
969 SfxMapUnit ePresUnit
,
970 XubString
& rText
, const IntlWrapper
*pIntl
975 case SFX_ITEM_PRESENTATION_NONE
:
977 return SFX_ITEM_PRESENTATION_NONE
;
978 case SFX_ITEM_PRESENTATION_NAMELESS
:
980 if ( 100 != nPropUpper
)
981 ( rText
= String::CreateFromInt32( nPropUpper
)) += sal_Unicode('%');
983 rText
= GetMetricText( (long)nUpper
, eCoreUnit
, ePresUnit
, pIntl
);
985 if ( 100 != nPropLower
)
986 ( rText
+= String::CreateFromInt32( nPropLower
)) += sal_Unicode('%');
988 rText
+= GetMetricText( (long)nLower
, eCoreUnit
, ePresUnit
, pIntl
);
989 return SFX_ITEM_PRESENTATION_NAMELESS
;
991 case SFX_ITEM_PRESENTATION_COMPLETE
:
993 rText
= EE_RESSTR(RID_SVXITEMS_ULSPACE_UPPER
);
994 if ( 100 != nPropUpper
)
995 ( rText
+= String::CreateFromInt32( nPropUpper
)) += sal_Unicode('%');
998 rText
+= GetMetricText( (long)nUpper
, eCoreUnit
, ePresUnit
, pIntl
);
999 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
1002 rText
+= EE_RESSTR(RID_SVXITEMS_ULSPACE_LOWER
);
1003 if ( 100 != nPropLower
)
1004 ( rText
+= String::CreateFromInt32( nPropLower
)) += sal_Unicode('%');
1007 rText
+= GetMetricText( (long)nLower
, eCoreUnit
, ePresUnit
, pIntl
);
1008 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
1010 return SFX_ITEM_PRESENTATION_COMPLETE
;
1012 default: ;//prevent warning
1014 return SFX_ITEM_PRESENTATION_NONE
;
1017 // -----------------------------------------------------------------------
1019 SvStream
& SvxULSpaceItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1028 // -----------------------------------------------------------------------
1030 SfxPoolItem
* SvxULSpaceItem::Create( SvStream
& rStrm
, sal_uInt16 nVersion
) const
1032 sal_uInt16 upper
, lower
, nPL
= 0, nPU
= 0;
1034 if ( nVersion
== ULSPACE_16_VERSION
)
1035 rStrm
>> upper
>> nPU
>> lower
>> nPL
;
1039 rStrm
>> upper
>> nU
>> lower
>> nL
;
1040 nPL
= (sal_uInt16
)nL
;
1041 nPU
= (sal_uInt16
)nU
;
1044 SvxULSpaceItem
* pAttr
= new SvxULSpaceItem( Which() );
1045 pAttr
->SetUpperValue( upper
);
1046 pAttr
->SetLowerValue( lower
);
1047 pAttr
->SetPropUpper( nPU
);
1048 pAttr
->SetPropLower( nPL
);
1052 // -----------------------------------------------------------------------
1054 sal_uInt16
SvxULSpaceItem::GetVersion( sal_uInt16
/*nFileVersion*/ ) const
1056 return ULSPACE_16_VERSION
;
1059 // -----------------------------------------------------------------------
1061 bool SvxULSpaceItem::ScaleMetrics( long nMult
, long nDiv
)
1063 nUpper
= (sal_uInt16
)Scale( nUpper
, nMult
, nDiv
);
1064 nLower
= (sal_uInt16
)Scale( nLower
, nMult
, nDiv
);
1068 // -----------------------------------------------------------------------
1070 bool SvxULSpaceItem::HasMetrics() const
1075 // class SvxPrintItem ----------------------------------------------------
1077 SfxPoolItem
* SvxPrintItem::Clone( SfxItemPool
* ) const
1079 return new SvxPrintItem( *this );
1082 // -----------------------------------------------------------------------
1084 SvStream
& SvxPrintItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1086 rStrm
<< (sal_Int8
)GetValue();
1090 // -----------------------------------------------------------------------
1092 SfxPoolItem
* SvxPrintItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1096 return new SvxPrintItem( Which(), sal_Bool( bIsPrint
!= 0 ) );
1099 //------------------------------------------------------------------------
1101 SfxItemPresentation
SvxPrintItem::GetPresentation
1103 SfxItemPresentation ePres
,
1104 SfxMapUnit
/*eCoreUnit*/,
1105 SfxMapUnit
/*ePresUnit*/,
1106 XubString
& rText
, const IntlWrapper
*
1111 case SFX_ITEM_PRESENTATION_NONE
:
1115 case SFX_ITEM_PRESENTATION_NAMELESS
:
1116 case SFX_ITEM_PRESENTATION_COMPLETE
:
1118 sal_uInt16 nId
= RID_SVXITEMS_PRINT_FALSE
;
1121 nId
= RID_SVXITEMS_PRINT_TRUE
;
1122 rText
= EE_RESSTR(nId
);
1125 default: ;//prevent warning
1127 return SFX_ITEM_PRESENTATION_NONE
;
1130 // class SvxOpaqueItem ---------------------------------------------------
1132 SfxPoolItem
* SvxOpaqueItem::Clone( SfxItemPool
* ) const
1134 return new SvxOpaqueItem( *this );
1137 // -----------------------------------------------------------------------
1139 SvStream
& SvxOpaqueItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1141 rStrm
<< (sal_Int8
)GetValue();
1145 // -----------------------------------------------------------------------
1147 SfxPoolItem
* SvxOpaqueItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1151 return new SvxOpaqueItem( Which(), sal_Bool( bIsOpaque
!= 0 ) );
1154 //------------------------------------------------------------------------
1156 SfxItemPresentation
SvxOpaqueItem::GetPresentation
1158 SfxItemPresentation ePres
,
1159 SfxMapUnit
/*eCoreUnit*/,
1160 SfxMapUnit
/*ePresUnit*/,
1161 XubString
& rText
, const IntlWrapper
*
1166 case SFX_ITEM_PRESENTATION_NONE
:
1170 case SFX_ITEM_PRESENTATION_NAMELESS
:
1171 case SFX_ITEM_PRESENTATION_COMPLETE
:
1173 sal_uInt16 nId
= RID_SVXITEMS_OPAQUE_FALSE
;
1176 nId
= RID_SVXITEMS_OPAQUE_TRUE
;
1177 rText
= EE_RESSTR(nId
);
1180 default: ;//prevent warning
1182 return SFX_ITEM_PRESENTATION_NONE
;
1185 // class SvxProtectItem --------------------------------------------------
1187 int SvxProtectItem::operator==( const SfxPoolItem
& rAttr
) const
1189 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1191 return ( bCntnt
== ( (SvxProtectItem
&)rAttr
).bCntnt
&&
1192 bSize
== ( (SvxProtectItem
&)rAttr
).bSize
&&
1193 bPos
== ( (SvxProtectItem
&)rAttr
).bPos
);
1196 bool SvxProtectItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1198 nMemberId
&= ~CONVERT_TWIPS
;
1202 case MID_PROTECT_CONTENT
: bValue
= bCntnt
; break;
1203 case MID_PROTECT_SIZE
: bValue
= bSize
; break;
1204 case MID_PROTECT_POSITION
: bValue
= bPos
; break;
1206 OSL_FAIL("Wrong MemberId");
1210 rVal
= Bool2Any( bValue
);
1214 bool SvxProtectItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1216 nMemberId
&= ~CONVERT_TWIPS
;
1217 sal_Bool
bVal( Any2Bool(rVal
) );
1220 case MID_PROTECT_CONTENT
: bCntnt
= bVal
; break;
1221 case MID_PROTECT_SIZE
: bSize
= bVal
; break;
1222 case MID_PROTECT_POSITION
: bPos
= bVal
; break;
1224 OSL_FAIL("Wrong MemberId");
1230 // -----------------------------------------------------------------------
1232 SfxPoolItem
* SvxProtectItem::Clone( SfxItemPool
* ) const
1234 return new SvxProtectItem( *this );
1237 //------------------------------------------------------------------------
1239 SfxItemPresentation
SvxProtectItem::GetPresentation
1241 SfxItemPresentation ePres
,
1242 SfxMapUnit
/*eCoreUnit*/,
1243 SfxMapUnit
/*ePresUnit*/,
1244 XubString
& rText
, const IntlWrapper
*
1249 case SFX_ITEM_PRESENTATION_NONE
:
1253 case SFX_ITEM_PRESENTATION_NAMELESS
:
1254 case SFX_ITEM_PRESENTATION_COMPLETE
:
1256 sal_uInt16 nId
= RID_SVXITEMS_PROT_CONTENT_FALSE
;
1259 nId
= RID_SVXITEMS_PROT_CONTENT_TRUE
;
1260 rText
= EE_RESSTR(nId
);
1262 nId
= RID_SVXITEMS_PROT_SIZE_FALSE
;
1265 nId
= RID_SVXITEMS_PROT_SIZE_TRUE
;
1266 rText
+= EE_RESSTR(nId
);
1268 nId
= RID_SVXITEMS_PROT_POS_FALSE
;
1271 nId
= RID_SVXITEMS_PROT_POS_TRUE
;
1272 rText
+= EE_RESSTR(nId
);
1275 default: ;//prevent warning
1277 return SFX_ITEM_PRESENTATION_NONE
;
1280 // -----------------------------------------------------------------------
1282 SvStream
& SvxProtectItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1285 if( IsPosProtected() ) cProt
|= 0x01;
1286 if( IsSizeProtected() ) cProt
|= 0x02;
1287 if( IsCntntProtected() ) cProt
|= 0x04;
1288 rStrm
<< (sal_Int8
) cProt
;
1292 // -----------------------------------------------------------------------
1294 SfxPoolItem
* SvxProtectItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1298 SvxProtectItem
* pAttr
= new SvxProtectItem( Which() );
1299 pAttr
->SetPosProtect( sal_Bool( ( cFlags
& 0x01 ) != 0 ) );
1300 pAttr
->SetSizeProtect( sal_Bool( ( cFlags
& 0x02 ) != 0 ) );
1301 pAttr
->SetCntntProtect( sal_Bool( ( cFlags
& 0x04 ) != 0 ) );
1305 // class SvxShadowItem ---------------------------------------------------
1307 SvxShadowItem::SvxShadowItem( const sal_uInt16 nId
,
1308 const Color
*pColor
, const sal_uInt16 nW
,
1309 const SvxShadowLocation eLoc
) :
1310 SfxEnumItemInterface( nId
),
1311 aShadowColor(COL_GRAY
),
1316 aShadowColor
= *pColor
;
1319 // -----------------------------------------------------------------------
1320 bool SvxShadowItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1322 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1323 nMemberId
&= ~CONVERT_TWIPS
;
1325 table::ShadowFormat aShadow
;
1326 table::ShadowLocation eSet
= table::ShadowLocation_NONE
;
1329 case SVX_SHADOW_TOPLEFT
: eSet
= table::ShadowLocation_TOP_LEFT
; break;
1330 case SVX_SHADOW_TOPRIGHT
: eSet
= table::ShadowLocation_TOP_RIGHT
; break;
1331 case SVX_SHADOW_BOTTOMLEFT
: eSet
= table::ShadowLocation_BOTTOM_LEFT
; break;
1332 case SVX_SHADOW_BOTTOMRIGHT
: eSet
= table::ShadowLocation_BOTTOM_RIGHT
; break;
1333 default: ;//prevent warning
1335 aShadow
.Location
= eSet
;
1336 aShadow
.ShadowWidth
= bConvert
? TWIP_TO_MM100_UNSIGNED(nWidth
) : nWidth
;
1337 aShadow
.IsTransparent
= aShadowColor
.GetTransparency() > 0;
1338 aShadow
.Color
= aShadowColor
.GetRGBColor();
1340 switch ( nMemberId
)
1342 case MID_LOCATION
: rVal
<<= aShadow
.Location
; break;
1343 case MID_WIDTH
: rVal
<<= aShadow
.ShadowWidth
; break;
1344 case MID_TRANSPARENT
: rVal
<<= aShadow
.IsTransparent
; break;
1345 case MID_BG_COLOR
: rVal
<<= aShadow
.Color
; break;
1346 case 0: rVal
<<= aShadow
; break;
1347 default: OSL_FAIL("Wrong MemberId!"); return false;
1352 // -----------------------------------------------------------------------
1353 bool SvxShadowItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1355 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1356 nMemberId
&= ~CONVERT_TWIPS
;
1358 table::ShadowFormat aShadow
;
1360 bool bRet
= QueryValue( aAny
, bConvert
? CONVERT_TWIPS
: 0 ) && ( aAny
>>= aShadow
);
1361 switch ( nMemberId
)
1365 bRet
= (rVal
>>= aShadow
.Location
);
1369 bRet
= (rVal
>>= nVal
);
1370 aShadow
.Location
= (table::ShadowLocation
) nVal
;
1376 case MID_WIDTH
: rVal
>>= aShadow
.ShadowWidth
; break;
1377 case MID_TRANSPARENT
: rVal
>>= aShadow
.IsTransparent
; break;
1378 case MID_BG_COLOR
: rVal
>>= aShadow
.Color
; break;
1379 case 0: rVal
>>= aShadow
; break;
1380 default: OSL_FAIL("Wrong MemberId!"); return sal_False
;
1385 // SvxShadowLocation eSet = SVX_SHADOW_NONE;
1386 switch( aShadow
.Location
)
1388 case table::ShadowLocation_TOP_LEFT
: eLocation
= SVX_SHADOW_TOPLEFT
; break;
1389 case table::ShadowLocation_TOP_RIGHT
: eLocation
= SVX_SHADOW_TOPRIGHT
; break;
1390 case table::ShadowLocation_BOTTOM_LEFT
: eLocation
= SVX_SHADOW_BOTTOMLEFT
; break;
1391 case table::ShadowLocation_BOTTOM_RIGHT
: eLocation
= SVX_SHADOW_BOTTOMRIGHT
; break;
1392 default: ;//prevent warning
1395 nWidth
= bConvert
? MM100_TO_TWIP(aShadow
.ShadowWidth
) : aShadow
.ShadowWidth
;
1396 Color
aSet(aShadow
.Color
);
1397 aSet
.SetTransparency(aShadow
.IsTransparent
? 0xff : 0);
1398 aShadowColor
= aSet
;
1404 // -----------------------------------------------------------------------
1406 int SvxShadowItem::operator==( const SfxPoolItem
& rAttr
) const
1408 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1410 return ( ( aShadowColor
== ( (SvxShadowItem
&)rAttr
).aShadowColor
) &&
1411 ( nWidth
== ( (SvxShadowItem
&)rAttr
).GetWidth() ) &&
1412 ( eLocation
== ( (SvxShadowItem
&)rAttr
).GetLocation() ) );
1415 // -----------------------------------------------------------------------
1417 SfxPoolItem
* SvxShadowItem::Clone( SfxItemPool
* ) const
1419 return new SvxShadowItem( *this );
1422 // -----------------------------------------------------------------------
1424 sal_uInt16
SvxShadowItem::CalcShadowSpace( sal_uInt16 nShadow
) const
1426 sal_uInt16 nSpace
= 0;
1431 if ( eLocation
== SVX_SHADOW_TOPLEFT
||
1432 eLocation
== SVX_SHADOW_TOPRIGHT
)
1437 if ( eLocation
== SVX_SHADOW_BOTTOMLEFT
||
1438 eLocation
== SVX_SHADOW_BOTTOMRIGHT
)
1443 if ( eLocation
== SVX_SHADOW_TOPLEFT
||
1444 eLocation
== SVX_SHADOW_BOTTOMLEFT
)
1449 if ( eLocation
== SVX_SHADOW_TOPRIGHT
||
1450 eLocation
== SVX_SHADOW_BOTTOMRIGHT
)
1455 OSL_FAIL( "wrong shadow" );
1460 //------------------------------------------------------------------------
1462 SfxItemPresentation
SvxShadowItem::GetPresentation
1464 SfxItemPresentation ePres
,
1465 SfxMapUnit eCoreUnit
,
1466 SfxMapUnit ePresUnit
,
1467 XubString
& rText
, const IntlWrapper
*pIntl
1472 case SFX_ITEM_PRESENTATION_NONE
:
1476 case SFX_ITEM_PRESENTATION_NAMELESS
:
1478 rText
= ::GetColorString( aShadowColor
);
1480 sal_uInt16 nId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
1482 if ( aShadowColor
.GetTransparency() )
1483 nId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
1484 rText
+= EE_RESSTR(nId
);
1486 rText
+= GetMetricText( (long)nWidth
, eCoreUnit
, ePresUnit
, pIntl
);
1488 rText
+= EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN
+ eLocation
);
1491 case SFX_ITEM_PRESENTATION_COMPLETE
:
1493 rText
= EE_RESSTR(RID_SVXITEMS_SHADOW_COMPLETE
);
1494 rText
+= ::GetColorString( aShadowColor
);
1497 sal_uInt16 nId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
1498 if ( aShadowColor
.GetTransparency() )
1499 nId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
1500 rText
+= EE_RESSTR(nId
);
1502 rText
+= GetMetricText( (long)nWidth
, eCoreUnit
, ePresUnit
, pIntl
);
1503 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
1505 rText
+= EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN
+ eLocation
);
1508 default: ;//prevent warning
1510 return SFX_ITEM_PRESENTATION_NONE
;
1513 // -----------------------------------------------------------------------
1515 SvStream
& SvxShadowItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1517 rStrm
<< (sal_Int8
) GetLocation()
1518 << (sal_uInt16
) GetWidth()
1519 << (sal_Bool
)(aShadowColor
.GetTransparency() > 0)
1522 << (sal_Int8
)(aShadowColor
.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
1526 // -----------------------------------------------------------------------
1528 bool SvxShadowItem::ScaleMetrics( long nMult
, long nDiv
)
1530 nWidth
= (sal_uInt16
)Scale( nWidth
, nMult
, nDiv
);
1534 // -----------------------------------------------------------------------
1536 bool SvxShadowItem::HasMetrics() const
1541 // -----------------------------------------------------------------------
1543 SfxPoolItem
* SvxShadowItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1551 rStrm
>> cLoc
>> _nWidth
1552 >> bTrans
>> aColor
>> aFillColor
>> nStyle
;
1553 aColor
.SetTransparency(bTrans
? 0xff : 0);
1554 return new SvxShadowItem( Which(), &aColor
, _nWidth
, (SvxShadowLocation
)cLoc
);
1557 // -----------------------------------------------------------------------
1559 sal_uInt16
SvxShadowItem::GetValueCount() const
1561 return SVX_SHADOW_END
; // SVX_SHADOW_BOTTOMRIGHT + 1
1564 // -----------------------------------------------------------------------
1566 rtl::OUString
SvxShadowItem::GetValueTextByPos( sal_uInt16 nPos
) const
1568 DBG_ASSERT( nPos
< SVX_SHADOW_END
, "enum overflow!" );
1569 return EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN
+ nPos
);
1572 // -----------------------------------------------------------------------
1574 sal_uInt16
SvxShadowItem::GetEnumValue() const
1576 return (sal_uInt16
)GetLocation();
1579 // -----------------------------------------------------------------------
1581 void SvxShadowItem::SetEnumValue( sal_uInt16 nVal
)
1583 SetLocation( (const SvxShadowLocation
)nVal
);
1586 // class SvxBoxItem ------------------------------------------------------
1588 SvxBoxItem::SvxBoxItem( const SvxBoxItem
& rCpy
) :
1590 SfxPoolItem ( rCpy
),
1591 nTopDist ( rCpy
.nTopDist
),
1592 nBottomDist ( rCpy
.nBottomDist
),
1593 nLeftDist ( rCpy
.nLeftDist
),
1594 nRightDist ( rCpy
.nRightDist
)
1597 pTop
= rCpy
.GetTop() ? new SvxBorderLine( *rCpy
.GetTop() ) : 0;
1598 pBottom
= rCpy
.GetBottom() ? new SvxBorderLine( *rCpy
.GetBottom() ) : 0;
1599 pLeft
= rCpy
.GetLeft() ? new SvxBorderLine( *rCpy
.GetLeft() ) : 0;
1600 pRight
= rCpy
.GetRight() ? new SvxBorderLine( *rCpy
.GetRight() ) : 0;
1603 // -----------------------------------------------------------------------
1605 SvxBoxItem::SvxBoxItem( const sal_uInt16 nId
) :
1620 // -----------------------------------------------------------------------
1622 SvxBoxItem::~SvxBoxItem()
1630 // -----------------------------------------------------------------------
1632 SvxBoxItem
& SvxBoxItem::operator=( const SvxBoxItem
& rBox
)
1634 nTopDist
= rBox
.nTopDist
;
1635 nBottomDist
= rBox
.nBottomDist
;
1636 nLeftDist
= rBox
.nLeftDist
;
1637 nRightDist
= rBox
.nRightDist
;
1638 SetLine( rBox
.GetTop(), BOX_LINE_TOP
);
1639 SetLine( rBox
.GetBottom(), BOX_LINE_BOTTOM
);
1640 SetLine( rBox
.GetLeft(), BOX_LINE_LEFT
);
1641 SetLine( rBox
.GetRight(), BOX_LINE_RIGHT
);
1645 // -----------------------------------------------------------------------
1647 inline sal_Bool
CmpBrdLn( const SvxBorderLine
* pBrd1
, const SvxBorderLine
* pBrd2
)
1650 if( 0 != pBrd1
? 0 == pBrd2
: 0 != pBrd2
)
1656 bRet
= (*pBrd1
== *pBrd2
);
1660 // -----------------------------------------------------------------------
1662 int SvxBoxItem::operator==( const SfxPoolItem
& rAttr
) const
1664 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1667 ( nTopDist
== ( (SvxBoxItem
&)rAttr
).nTopDist
) &&
1668 ( nBottomDist
== ( (SvxBoxItem
&)rAttr
).nBottomDist
) &&
1669 ( nLeftDist
== ( (SvxBoxItem
&)rAttr
).nLeftDist
) &&
1670 ( nRightDist
== ( (SvxBoxItem
&)rAttr
).nRightDist
) &&
1671 CmpBrdLn( pTop
, ( (SvxBoxItem
&)rAttr
).GetTop() ) &&
1672 CmpBrdLn( pBottom
, ( (SvxBoxItem
&)rAttr
).GetBottom() ) &&
1673 CmpBrdLn( pLeft
, ( (SvxBoxItem
&)rAttr
).GetLeft() ) &&
1674 CmpBrdLn( pRight
, ( (SvxBoxItem
&)rAttr
).GetRight() ) );
1677 // -----------------------------------------------------------------------
1678 table::BorderLine2
SvxBoxItem::SvxLineToLine(const SvxBorderLine
* pLine
, sal_Bool bConvert
)
1680 table::BorderLine2 aLine
;
1683 aLine
.Color
= pLine
->GetColor().GetColor() ;
1684 aLine
.InnerLineWidth
= sal_uInt16( bConvert
? TWIP_TO_MM100_UNSIGNED(pLine
->GetInWidth() ): pLine
->GetInWidth() );
1685 aLine
.OuterLineWidth
= sal_uInt16( bConvert
? TWIP_TO_MM100_UNSIGNED(pLine
->GetOutWidth()): pLine
->GetOutWidth() );
1686 aLine
.LineDistance
= sal_uInt16( bConvert
? TWIP_TO_MM100_UNSIGNED(pLine
->GetDistance()): pLine
->GetDistance() );
1687 aLine
.LineStyle
= pLine
->GetBorderLineStyle();
1688 aLine
.LineWidth
= sal_uInt32( bConvert
? TWIP_TO_MM100( pLine
->GetWidth( ) ) : pLine
->GetWidth( ) );
1691 aLine
.Color
= aLine
.InnerLineWidth
= aLine
.OuterLineWidth
= aLine
.LineDistance
= 0;
1694 // -----------------------------------------------------------------------
1695 bool SvxBoxItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
1697 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1698 table::BorderLine2 aRetLine
;
1699 sal_uInt16 nDist
= 0;
1700 sal_Bool bDistMember
= sal_False
;
1701 nMemberId
&= ~CONVERT_TWIPS
;
1706 // 4 Borders and 5 distances
1707 uno::Sequence
< uno::Any
> aSeq( 9 );
1708 aSeq
[0] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetLeft(), bConvert
) );
1709 aSeq
[1] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetRight(), bConvert
) );
1710 aSeq
[2] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetBottom(), bConvert
) );
1711 aSeq
[3] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetTop(), bConvert
) );
1712 aSeq
[4] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( GetDistance()) : GetDistance()));
1713 aSeq
[5] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( nTopDist
) : nTopDist
));
1714 aSeq
[6] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( nBottomDist
) : nBottomDist
));
1715 aSeq
[7] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( nLeftDist
) : nLeftDist
));
1716 aSeq
[8] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( nRightDist
) : nRightDist
));
1717 rVal
= uno::makeAny( aSeq
);
1720 case MID_LEFT_BORDER
:
1722 aRetLine
= SvxBoxItem::SvxLineToLine(GetLeft(), bConvert
);
1724 case MID_RIGHT_BORDER
:
1726 aRetLine
= SvxBoxItem::SvxLineToLine(GetRight(), bConvert
);
1728 case MID_BOTTOM_BORDER
:
1730 aRetLine
= SvxBoxItem::SvxLineToLine(GetBottom(), bConvert
);
1732 case MID_TOP_BORDER
:
1734 aRetLine
= SvxBoxItem::SvxLineToLine(GetTop(), bConvert
);
1736 case BORDER_DISTANCE
:
1737 nDist
= GetDistance();
1738 bDistMember
= sal_True
;
1740 case TOP_BORDER_DISTANCE
:
1742 bDistMember
= sal_True
;
1744 case BOTTOM_BORDER_DISTANCE
:
1745 nDist
= nBottomDist
;
1746 bDistMember
= sal_True
;
1748 case LEFT_BORDER_DISTANCE
:
1750 bDistMember
= sal_True
;
1752 case RIGHT_BORDER_DISTANCE
:
1754 bDistMember
= sal_True
;
1759 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nDist
) : nDist
);
1770 lcl_lineToSvxLine(const table::BorderLine
& rLine
, SvxBorderLine
& rSvxLine
, sal_Bool bConvert
, sal_Bool bGuessWidth
)
1772 rSvxLine
.SetColor( Color(rLine
.Color
));
1775 rSvxLine
.GuessLinesWidths( rSvxLine
.GetBorderLineStyle(),
1776 sal_uInt16( bConvert
? MM100_TO_TWIP(rLine
.OuterLineWidth
) : rLine
.OuterLineWidth
),
1777 sal_uInt16( bConvert
? MM100_TO_TWIP(rLine
.InnerLineWidth
) : rLine
.InnerLineWidth
),
1778 sal_uInt16( bConvert
? MM100_TO_TWIP(rLine
.LineDistance
) : rLine
.LineDistance
));
1781 sal_Bool bRet
= !rSvxLine
.isEmpty();
1787 // -----------------------------------------------------------------------
1788 sal_Bool
SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine
& rLine
, SvxBorderLine
& rSvxLine
, sal_Bool bConvert
)
1790 return lcl_lineToSvxLine(rLine
, rSvxLine
, bConvert
, sal_True
);
1794 SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine2
& rLine
, SvxBorderLine
& rSvxLine
, sal_Bool bConvert
)
1796 SvxBorderStyle
const nStyle
=
1797 (rLine
.LineStyle
< 0 || BORDER_LINE_STYLE_MAX
< rLine
.LineStyle
)
1801 rSvxLine
.SetBorderLineStyle( nStyle
);
1803 sal_Bool bGuessWidth
= sal_True
;
1804 if ( rLine
.LineWidth
)
1806 rSvxLine
.SetWidth( bConvert
? MM100_TO_TWIP_UNSIGNED( rLine
.LineWidth
) : rLine
.LineWidth
);
1807 // fdo#46112: double does not necessarily mean symmetric
1808 // for backwards compatibility
1809 bGuessWidth
= (DOUBLE
== nStyle
) &&
1810 (rLine
.InnerLineWidth
> 0) && (rLine
.OuterLineWidth
> 0);
1813 return lcl_lineToSvxLine(rLine
, rSvxLine
, bConvert
, bGuessWidth
);
1816 // -----------------------------------------------------------------------
1822 lcl_extractBorderLine(const uno::Any
& rAny
, table::BorderLine2
& rLine
)
1827 table::BorderLine aBorderLine
;
1828 if (rAny
>>= aBorderLine
)
1830 rLine
.Color
= aBorderLine
.Color
;
1831 rLine
.InnerLineWidth
= aBorderLine
.InnerLineWidth
;
1832 rLine
.OuterLineWidth
= aBorderLine
.OuterLineWidth
;
1833 rLine
.LineDistance
= aBorderLine
.LineDistance
;
1834 rLine
.LineStyle
= table::BorderLineStyle::SOLID
;
1841 template<typename Item
>
1843 lcl_setLine(const uno::Any
& rAny
, Item
& rItem
, sal_uInt16 nLine
, const bool bConvert
)
1846 table::BorderLine2 aBorderLine
;
1847 if (lcl_extractBorderLine(rAny
, aBorderLine
))
1849 SvxBorderLine aLine
;
1850 bool bSet
= SvxBoxItem::LineToSvxLine(aBorderLine
, aLine
, bConvert
);
1851 rItem
.SetLine( bSet
? &aLine
: NULL
, nLine
);
1859 bool SvxBoxItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
1861 bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1862 sal_uInt16 nLine
= BOX_LINE_TOP
;
1863 sal_Bool bDistMember
= sal_False
;
1864 nMemberId
&= ~CONVERT_TWIPS
;
1869 uno::Sequence
< uno::Any
> aSeq
;
1870 if (( rVal
>>= aSeq
) && ( aSeq
.getLength() == 9 ))
1872 // 4 Borders and 5 distances
1873 const sal_uInt16 aBorders
[] = { BOX_LINE_LEFT
, BOX_LINE_RIGHT
, BOX_LINE_BOTTOM
, BOX_LINE_TOP
};
1874 for (int n(0); n
!= SAL_N_ELEMENTS(aBorders
); ++n
)
1876 if (!lcl_setLine(aSeq
[n
], *this, aBorders
[n
], bConvert
))
1880 // WTH are the borders and the distances saved in different order?
1881 sal_uInt16 nLines
[4] = { BOX_LINE_TOP
, BOX_LINE_BOTTOM
, BOX_LINE_LEFT
, BOX_LINE_RIGHT
};
1882 for ( sal_Int32 n
= 4; n
< 9; n
++ )
1884 sal_Int32 nDist
= 0;
1885 if ( aSeq
[n
] >>= nDist
)
1888 nDist
= MM100_TO_TWIP(nDist
);
1890 SetDistance( sal_uInt16( nDist
));
1892 SetDistance( sal_uInt16( nDist
), nLines
[n
-5] );
1903 case LEFT_BORDER_DISTANCE
:
1904 bDistMember
= sal_True
;
1906 case MID_LEFT_BORDER
:
1907 nLine
= BOX_LINE_LEFT
;
1909 case RIGHT_BORDER_DISTANCE
:
1910 bDistMember
= sal_True
;
1912 case MID_RIGHT_BORDER
:
1913 nLine
= BOX_LINE_RIGHT
;
1915 case BOTTOM_BORDER_DISTANCE
:
1916 bDistMember
= sal_True
;
1918 case MID_BOTTOM_BORDER
:
1919 nLine
= BOX_LINE_BOTTOM
;
1921 case TOP_BORDER_DISTANCE
:
1922 bDistMember
= sal_True
;
1924 case MID_TOP_BORDER
:
1925 nLine
= BOX_LINE_TOP
;
1929 drawing::LineStyle eDrawingStyle
;
1930 rVal
>>= eDrawingStyle
;
1931 editeng::SvxBorderStyle eBorderStyle
= NONE
;
1932 switch ( eDrawingStyle
)
1935 case drawing::LineStyle_NONE
:
1937 case drawing::LineStyle_SOLID
:
1938 eBorderStyle
= SOLID
;
1940 case drawing::LineStyle_DASH
:
1941 eBorderStyle
= DASHED
;
1945 // Set the line style on all borders
1946 const sal_uInt16 aBorders
[] = { BOX_LINE_LEFT
, BOX_LINE_RIGHT
, BOX_LINE_BOTTOM
, BOX_LINE_TOP
};
1947 for (int n(0); n
!= SAL_N_ELEMENTS(aBorders
); ++n
)
1949 editeng::SvxBorderLine
* pLine
= const_cast< editeng::SvxBorderLine
* >( GetLine( aBorders
[n
] ) );
1951 pLine
->SetBorderLineStyle( eBorderStyle
);
1958 // Set the line width on all borders
1962 nWidth
= MM100_TO_TWIP( nWidth
);
1964 // Set the line Width on all borders
1965 const sal_uInt16 aBorders
[] = { BOX_LINE_LEFT
, BOX_LINE_RIGHT
, BOX_LINE_BOTTOM
, BOX_LINE_TOP
};
1966 for (int n(0); n
!= SAL_N_ELEMENTS(aBorders
); ++n
)
1968 editeng::SvxBorderLine
* pLine
= const_cast< editeng::SvxBorderLine
* >( GetLine( aBorders
[n
] ) );
1969 pLine
->SetWidth( nWidth
);
1976 if( bDistMember
|| nMemberId
== BORDER_DISTANCE
)
1978 sal_Int32 nDist
= 0;
1979 if(!(rVal
>>= nDist
))
1985 nDist
= MM100_TO_TWIP(nDist
);
1986 if( nMemberId
== BORDER_DISTANCE
)
1987 SetDistance( sal_uInt16( nDist
));
1989 SetDistance( sal_uInt16( nDist
), nLine
);
1994 SvxBorderLine aLine
;
1995 if( !rVal
.hasValue() )
1998 table::BorderLine2 aBorderLine
;
1999 if( lcl_extractBorderLine(rVal
, aBorderLine
) )
2003 else if (rVal
.getValueTypeClass() == uno::TypeClass_SEQUENCE
)
2005 // serialization for basic macro recording
2006 uno::Reference
< script::XTypeConverter
> xConverter
2007 ( script::Converter::create(::comphelper::getProcessComponentContext()) );
2008 uno::Sequence
< uno::Any
> aSeq
;
2010 try { aNew
= xConverter
->convertTo( rVal
, ::getCppuType((const uno::Sequence
< uno::Any
>*)0) ); }
2011 catch (const uno::Exception
&) {}
2014 if (aSeq
.getLength() >= 4 && aSeq
.getLength() <= 6)
2017 if ( aSeq
[0] >>= nVal
)
2018 aBorderLine
.Color
= nVal
;
2019 if ( aSeq
[1] >>= nVal
)
2020 aBorderLine
.InnerLineWidth
= (sal_Int16
) nVal
;
2021 if ( aSeq
[2] >>= nVal
)
2022 aBorderLine
.OuterLineWidth
= (sal_Int16
) nVal
;
2023 if ( aSeq
[3] >>= nVal
)
2024 aBorderLine
.LineDistance
= (sal_Int16
) nVal
;
2025 if (aSeq
.getLength() >= 5) // fdo#40874 added fields
2027 if (aSeq
[4] >>= nVal
)
2029 aBorderLine
.LineStyle
= nVal
;
2031 if (aSeq
.getLength() >= 6)
2033 if (aSeq
[5] >>= nVal
)
2035 aBorderLine
.LineWidth
= nVal
;
2046 sal_Bool bSet
= SvxBoxItem::LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2047 SetLine(bSet
? &aLine
: 0, nLine
);
2053 // -----------------------------------------------------------------------
2055 SfxPoolItem
* SvxBoxItem::Clone( SfxItemPool
* ) const
2057 return new SvxBoxItem( *this );
2060 //------------------------------------------------------------------------
2062 SfxItemPresentation
SvxBoxItem::GetPresentation
2064 SfxItemPresentation ePres
,
2065 SfxMapUnit eCoreUnit
,
2066 SfxMapUnit ePresUnit
,
2067 XubString
& rText
, const IntlWrapper
*pIntl
2072 case SFX_ITEM_PRESENTATION_NONE
:
2074 return SFX_ITEM_PRESENTATION_NONE
;
2076 case SFX_ITEM_PRESENTATION_NAMELESS
:
2082 rText
= pTop
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
);
2085 if( !(pTop
&& pBottom
&& pLeft
&& pRight
&&
2086 *pTop
== *pBottom
&& *pTop
== *pLeft
&& *pTop
== *pRight
) )
2090 rText
+= pBottom
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
);
2095 rText
+= pLeft
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
);
2100 rText
+= pRight
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
);
2104 rText
+= GetMetricText( (long)nTopDist
, eCoreUnit
, ePresUnit
, pIntl
);
2105 if( nTopDist
!= nBottomDist
|| nTopDist
!= nLeftDist
||
2106 nTopDist
!= nRightDist
)
2108 (((((rText
+= cpDelim
)
2109 += GetMetricText( (long)nBottomDist
, eCoreUnit
,
2112 += GetMetricText( (long)nLeftDist
, eCoreUnit
, ePresUnit
, pIntl
))
2114 += GetMetricText( (long)nRightDist
, eCoreUnit
,
2117 return SFX_ITEM_PRESENTATION_NAMELESS
;
2119 case SFX_ITEM_PRESENTATION_COMPLETE
:
2121 if( !(pTop
|| pBottom
|| pLeft
|| pRight
) )
2123 rText
= EE_RESSTR(RID_SVXITEMS_BORDER_NONE
);
2128 rText
= EE_RESSTR(RID_SVXITEMS_BORDER_COMPLETE
);
2129 if( pTop
&& pBottom
&& pLeft
&& pRight
&&
2130 *pTop
== *pBottom
&& *pTop
== *pLeft
&& *pTop
== *pRight
)
2132 rText
+= pTop
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2139 rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_TOP
);
2140 rText
+= pTop
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2145 rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM
);
2146 rText
+= pBottom
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2151 rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_LEFT
);
2152 rText
+= pLeft
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2157 rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT
);
2158 rText
+= pRight
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2164 rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_DISTANCE
);
2165 if( nTopDist
== nBottomDist
&& nTopDist
== nLeftDist
&&
2166 nTopDist
== nRightDist
)
2168 rText
+= GetMetricText( (long)nTopDist
, eCoreUnit
,
2170 rText
+= EE_RESSTR(GetMetricId(ePresUnit
));
2174 (((rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_TOP
))
2175 += GetMetricText( (long)nTopDist
, eCoreUnit
,
2177 += EE_RESSTR(GetMetricId(ePresUnit
)))
2179 (((rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM
))
2180 += GetMetricText( (long)nBottomDist
, eCoreUnit
,
2182 += EE_RESSTR(GetMetricId(ePresUnit
)))
2184 (((rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_LEFT
))
2185 += GetMetricText( (long)nLeftDist
, eCoreUnit
,
2187 += EE_RESSTR(GetMetricId(ePresUnit
)))
2189 ((rText
+= EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT
))
2190 += GetMetricText( (long)nRightDist
, eCoreUnit
,
2192 += EE_RESSTR(GetMetricId(ePresUnit
));
2194 return SFX_ITEM_PRESENTATION_COMPLETE
;
2196 default: ;//prevent warning
2198 return SFX_ITEM_PRESENTATION_NONE
;
2201 // -----------------------------------------------------------------------
2203 SvStream
& SvxBoxItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
2205 rStrm
<< (sal_uInt16
) GetDistance();
2206 const SvxBorderLine
* pLine
[ 4 ]; // top, left, right, bottom
2207 pLine
[ 0 ] = GetTop();
2208 pLine
[ 1 ] = GetLeft();
2209 pLine
[ 2 ] = GetRight();
2210 pLine
[ 3 ] = GetBottom();
2212 for( int i
= 0; i
< 4; i
++ )
2214 const SvxBorderLine
* l
= pLine
[ i
];
2217 rStrm
<< static_cast<sal_Int8
>(i
);
2218 StoreBorderLine(rStrm
, *l
, BorderLineVersionFromBoxVersion(nItemVersion
));
2222 if( nItemVersion
>= BOX_4DISTS_VERSION
&&
2223 !(nTopDist
== nLeftDist
&&
2224 nTopDist
== nRightDist
&&
2225 nTopDist
== nBottomDist
) )
2232 if( nItemVersion
>= BOX_4DISTS_VERSION
&& (cLine
& 0x10) != 0 )
2234 rStrm
<< (sal_uInt16
)nTopDist
2235 << (sal_uInt16
)nLeftDist
2236 << (sal_uInt16
)nRightDist
2237 << (sal_uInt16
)nBottomDist
;
2243 // -----------------------------------------------------------------------
2245 sal_uInt16
SvxBoxItem::GetVersion( sal_uInt16 nFFVer
) const
2247 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
2248 SOFFICE_FILEFORMAT_40
==nFFVer
||
2249 SOFFICE_FILEFORMAT_50
==nFFVer
,
2250 "SvxBoxItem: Gibt es ein neues Fileformat?" );
2251 return SOFFICE_FILEFORMAT_31
==nFFVer
||
2252 SOFFICE_FILEFORMAT_40
==nFFVer
? 0 : BOX_BORDER_STYLE_VERSION
;
2255 // -----------------------------------------------------------------------
2257 bool SvxBoxItem::ScaleMetrics( long nMult
, long nDiv
)
2259 if ( pTop
) pTop
->ScaleMetrics( nMult
, nDiv
);
2260 if ( pBottom
) pBottom
->ScaleMetrics( nMult
, nDiv
);
2261 if ( pLeft
) pLeft
->ScaleMetrics( nMult
, nDiv
);
2262 if ( pRight
) pBottom
->ScaleMetrics( nMult
, nDiv
);
2263 nTopDist
= (sal_uInt16
)Scale( nTopDist
, nMult
, nDiv
);
2264 nBottomDist
= (sal_uInt16
)Scale( nBottomDist
, nMult
, nDiv
);
2265 nLeftDist
= (sal_uInt16
)Scale( nLeftDist
, nMult
, nDiv
);
2266 nRightDist
= (sal_uInt16
)Scale( nRightDist
, nMult
, nDiv
);
2270 // -----------------------------------------------------------------------
2272 bool SvxBoxItem::HasMetrics() const
2277 // -----------------------------------------------------------------------
2279 SfxPoolItem
* SvxBoxItem::Create( SvStream
& rStrm
, sal_uInt16 nIVersion
) const
2281 sal_uInt16 nDistance
;
2283 SvxBoxItem
* pAttr
= new SvxBoxItem( Which() );
2285 sal_uInt16 aLineMap
[4] = { BOX_LINE_TOP
, BOX_LINE_LEFT
,
2286 BOX_LINE_RIGHT
, BOX_LINE_BOTTOM
};
2296 SvxBorderLine aBorder
= CreateBorderLine(rStrm
, BorderLineVersionFromBoxVersion(nIVersion
));
2297 pAttr
->SetLine( &aBorder
, aLineMap
[cLine
] );
2300 if( nIVersion
>= BOX_4DISTS_VERSION
&& (cLine
&0x10) != 0 )
2302 for( sal_uInt16 i
=0; i
< 4; i
++ )
2306 pAttr
->SetDistance( nDist
, aLineMap
[i
] );
2311 pAttr
->SetDistance( nDistance
);
2317 // -----------------------------------------------------------------------
2319 const SvxBorderLine
*SvxBoxItem::GetLine( sal_uInt16 nLine
) const
2321 const SvxBorderLine
*pRet
= 0;
2328 case BOX_LINE_BOTTOM
:
2334 case BOX_LINE_RIGHT
:
2338 OSL_FAIL( "wrong line" );
2345 // -----------------------------------------------------------------------
2347 void SvxBoxItem::SetLine( const SvxBorderLine
* pNew
, sal_uInt16 nLine
)
2349 SvxBorderLine
* pTmp
= pNew
? new SvxBorderLine( *pNew
) : 0;
2357 case BOX_LINE_BOTTOM
:
2365 case BOX_LINE_RIGHT
:
2371 OSL_FAIL( "wrong line" );
2375 // -----------------------------------------------------------------------
2377 sal_uInt16
SvxBoxItem::GetDistance() const
2379 // The smallest distance that is not 0 will be returned.
2380 sal_uInt16 nDist
= nTopDist
;
2381 if( nBottomDist
&& (!nDist
|| nBottomDist
< nDist
) )
2382 nDist
= nBottomDist
;
2383 if( nLeftDist
&& (!nDist
|| nLeftDist
< nDist
) )
2385 if( nRightDist
&& (!nDist
|| nRightDist
< nDist
) )
2391 // -----------------------------------------------------------------------
2393 sal_uInt16
SvxBoxItem::GetDistance( sal_uInt16 nLine
) const
2395 sal_uInt16 nDist
= 0;
2401 case BOX_LINE_BOTTOM
:
2402 nDist
= nBottomDist
;
2407 case BOX_LINE_RIGHT
:
2411 OSL_FAIL( "wrong line" );
2417 // -----------------------------------------------------------------------
2419 void SvxBoxItem::SetDistance( sal_uInt16 nNew
, sal_uInt16 nLine
)
2426 case BOX_LINE_BOTTOM
:
2432 case BOX_LINE_RIGHT
:
2436 OSL_FAIL( "wrong line" );
2440 // -----------------------------------------------------------------------
2442 sal_uInt16
SvxBoxItem::CalcLineSpace( sal_uInt16 nLine
, sal_Bool bIgnoreLine
) const
2444 SvxBorderLine
* pTmp
= 0;
2445 sal_uInt16 nDist
= 0;
2452 case BOX_LINE_BOTTOM
:
2454 nDist
= nBottomDist
;
2460 case BOX_LINE_RIGHT
:
2465 OSL_FAIL( "wrong line" );
2470 nDist
= nDist
+ (sal_uInt16
)(pTmp
->GetOutWidth()) + (sal_uInt16
)(pTmp
->GetInWidth()) + (sal_uInt16
)(pTmp
->GetDistance());
2472 else if( !bIgnoreLine
)
2477 // class SvxBoxInfoItem --------------------------------------------------
2479 SvxBoxInfoItem::SvxBoxInfoItem( const sal_uInt16 nId
) :
2483 mbEnableHor( false ),
2484 mbEnableVer( false ),
2487 bDist
= bMinDist
= sal_False
;
2491 // -----------------------------------------------------------------------
2493 SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem
& rCpy
) :
2494 SfxPoolItem( rCpy
),
2495 mbEnableHor( rCpy
.mbEnableHor
),
2496 mbEnableVer( rCpy
.mbEnableVer
)
2498 pHori
= rCpy
.GetHori() ? new SvxBorderLine( *rCpy
.GetHori() ) : 0;
2499 pVert
= rCpy
.GetVert() ? new SvxBorderLine( *rCpy
.GetVert() ) : 0;
2500 bDist
= rCpy
.IsDist();
2501 bMinDist
= rCpy
.IsMinDist();
2502 nValidFlags
= rCpy
.nValidFlags
;
2503 nDefDist
= rCpy
.GetDefDist();
2506 // -----------------------------------------------------------------------
2508 SvxBoxInfoItem::~SvxBoxInfoItem()
2514 // -----------------------------------------------------------------------
2516 SvxBoxInfoItem
&SvxBoxInfoItem::operator=( const SvxBoxInfoItem
& rCpy
)
2520 pHori
= rCpy
.GetHori() ? new SvxBorderLine( *rCpy
.GetHori() ) : 0;
2521 pVert
= rCpy
.GetVert() ? new SvxBorderLine( *rCpy
.GetVert() ) : 0;
2522 mbEnableHor
= rCpy
.mbEnableHor
;
2523 mbEnableVer
= rCpy
.mbEnableVer
;
2524 bDist
= rCpy
.IsDist();
2525 bMinDist
= rCpy
.IsMinDist();
2526 nValidFlags
= rCpy
.nValidFlags
;
2527 nDefDist
= rCpy
.GetDefDist();
2531 // -----------------------------------------------------------------------
2533 int SvxBoxInfoItem::operator==( const SfxPoolItem
& rAttr
) const
2535 SvxBoxInfoItem
& rBoxInfo
= (SvxBoxInfoItem
&)rAttr
;
2537 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
2539 return ( mbEnableHor
== rBoxInfo
.mbEnableHor
2540 && mbEnableVer
== rBoxInfo
.mbEnableVer
2541 && bDist
== rBoxInfo
.IsDist()
2542 && bMinDist
== rBoxInfo
.IsMinDist()
2543 && nValidFlags
== rBoxInfo
.nValidFlags
2544 && nDefDist
== rBoxInfo
.GetDefDist()
2545 && CmpBrdLn( pHori
, rBoxInfo
.GetHori() )
2546 && CmpBrdLn( pVert
, rBoxInfo
.GetVert() )
2550 // -----------------------------------------------------------------------
2552 void SvxBoxInfoItem::SetLine( const SvxBorderLine
* pNew
, sal_uInt16 nLine
)
2554 SvxBorderLine
* pTmp
= pNew
? new SvxBorderLine( *pNew
) : 0;
2556 if ( BOXINFO_LINE_HORI
== nLine
)
2561 else if ( BOXINFO_LINE_VERT
== nLine
)
2569 OSL_FAIL( "wrong line" );
2573 // -----------------------------------------------------------------------
2575 SfxPoolItem
* SvxBoxInfoItem::Clone( SfxItemPool
* ) const
2577 return new SvxBoxInfoItem( *this );
2580 //------------------------------------------------------------------------
2582 SfxItemPresentation
SvxBoxInfoItem::GetPresentation
2584 SfxItemPresentation
/*ePres*/,
2585 SfxMapUnit
/*eCoreUnit*/,
2586 SfxMapUnit
/*ePresUnit*/,
2587 XubString
& rText
, const IntlWrapper
*
2591 return SFX_ITEM_PRESENTATION_NONE
;
2594 // -----------------------------------------------------------------------
2596 SvStream
& SvxBoxInfoItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2598 sal_Int8 cFlags
= 0;
2606 rStrm
<< (sal_Int8
) cFlags
2607 << (sal_uInt16
) GetDefDist();
2608 const SvxBorderLine
* pLine
[ 2 ];
2609 pLine
[ 0 ] = GetHori();
2610 pLine
[ 1 ] = GetVert();
2612 for( int i
= 0; i
< 2; i
++ )
2614 const SvxBorderLine
* l
= pLine
[ i
];
2619 << (short) l
->GetOutWidth()
2620 << (short) l
->GetInWidth()
2621 << (short) l
->GetDistance();
2628 // -----------------------------------------------------------------------
2630 bool SvxBoxInfoItem::ScaleMetrics( long nMult
, long nDiv
)
2632 if ( pHori
) pHori
->ScaleMetrics( nMult
, nDiv
);
2633 if ( pVert
) pVert
->ScaleMetrics( nMult
, nDiv
);
2634 nDefDist
= (sal_uInt16
)Scale( nDefDist
, nMult
, nDiv
);
2638 // -----------------------------------------------------------------------
2640 bool SvxBoxInfoItem::HasMetrics() const
2645 // -----------------------------------------------------------------------
2647 SfxPoolItem
* SvxBoxInfoItem::Create( SvStream
& rStrm
, sal_uInt16
) const
2650 sal_uInt16 _nDefDist
;
2651 rStrm
>> cFlags
>> _nDefDist
;
2653 SvxBoxInfoItem
* pAttr
= new SvxBoxInfoItem( Which() );
2655 pAttr
->SetTable ( ( cFlags
& 0x01 ) != 0 );
2656 pAttr
->SetDist ( ( cFlags
& 0x02 ) != 0 );
2657 pAttr
->SetMinDist( ( cFlags
& 0x04 ) != 0 );
2658 pAttr
->SetDefDist( _nDefDist
);
2667 short nOutline
, nInline
, nDistance
;
2669 rStrm
>> aColor
>> nOutline
>> nInline
>> nDistance
;
2670 SvxBorderLine
aBorder( &aColor
);
2671 aBorder
.GuessLinesWidths(NONE
, nOutline
, nInline
, nDistance
);
2675 case 0: pAttr
->SetLine( &aBorder
, BOXINFO_LINE_HORI
); break;
2676 case 1: pAttr
->SetLine( &aBorder
, BOXINFO_LINE_VERT
); break;
2682 // -----------------------------------------------------------------------
2684 void SvxBoxInfoItem::ResetFlags()
2686 nValidFlags
= 0x7F; // all valid except Disable
2689 bool SvxBoxInfoItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
2691 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
2692 table::BorderLine2 aRetLine
;
2694 sal_Bool bIntMember
= sal_False
;
2695 nMemberId
&= ~CONVERT_TWIPS
;
2700 // 2 BorderLines, flags, valid flags and distance
2701 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aSeq( 5 );
2702 aSeq
[0] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pHori
, bConvert
) );
2703 aSeq
[1] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pVert
, bConvert
) );
2710 aSeq
[2] = ::com::sun::star::uno::makeAny( nVal
);
2712 aSeq
[3] = ::com::sun::star::uno::makeAny( nVal
);
2713 aSeq
[4] = ::com::sun::star::uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist()) );
2714 rVal
= ::com::sun::star::uno::makeAny( aSeq
);
2718 case MID_HORIZONTAL
:
2719 aRetLine
= SvxBoxItem::SvxLineToLine( pHori
, bConvert
);
2722 aRetLine
= SvxBoxItem::SvxLineToLine( pVert
, bConvert
);
2725 bIntMember
= sal_True
;
2734 case MID_VALIDFLAGS
:
2735 bIntMember
= sal_True
;
2740 bIntMember
= sal_True
;
2741 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist());
2743 default: OSL_FAIL("Wrong MemberId!"); return false;
2752 // -----------------------------------------------------------------------
2754 bool SvxBoxInfoItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
2756 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
2757 nMemberId
&= ~CONVERT_TWIPS
;
2763 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aSeq
;
2764 if (( rVal
>>= aSeq
) && ( aSeq
.getLength() == 5 ))
2766 // 2 BorderLines, flags, valid flags and distance
2767 if (!lcl_setLine(aSeq
[0], *this, BOXINFO_LINE_HORI
, bConvert
))
2769 if (!lcl_setLine(aSeq
[1], *this, BOXINFO_LINE_VERT
, bConvert
))
2772 sal_Int16
nFlags( 0 );
2773 sal_Int32
nVal( 0 );
2774 if ( aSeq
[2] >>= nFlags
)
2776 SetTable ( ( nFlags
& 0x01 ) != 0 );
2777 SetDist ( ( nFlags
& 0x02 ) != 0 );
2778 SetMinDist( ( nFlags
& 0x04 ) != 0 );
2782 if ( aSeq
[3] >>= nFlags
)
2783 nValidFlags
= (sal_uInt8
)nFlags
;
2786 if (( aSeq
[4] >>= nVal
) && ( nVal
>= 0 ))
2789 nVal
= MM100_TO_TWIP(nVal
);
2790 SetDefDist( (sal_uInt16
)nVal
);
2796 case MID_HORIZONTAL
:
2799 if( !rVal
.hasValue() )
2802 table::BorderLine2 aBorderLine
;
2803 if( lcl_extractBorderLine(rVal
, aBorderLine
) )
2807 else if (rVal
.getValueTypeClass() == uno::TypeClass_SEQUENCE
)
2809 // serialization for basic macro recording
2810 uno::Reference
< script::XTypeConverter
> xConverter( script::Converter::create(::comphelper::getProcessComponentContext()) );
2812 uno::Sequence
< uno::Any
> aSeq
;
2813 try { aNew
= xConverter
->convertTo( rVal
, ::getCppuType((const uno::Sequence
< uno::Any
>*)0) ); }
2814 catch (const uno::Exception
&) {}
2816 if ((aNew
>>= aSeq
) &&
2817 aSeq
.getLength() >= 4 && aSeq
.getLength() <= 6)
2820 if ( aSeq
[0] >>= nVal
)
2821 aBorderLine
.Color
= nVal
;
2822 if ( aSeq
[1] >>= nVal
)
2823 aBorderLine
.InnerLineWidth
= (sal_Int16
) nVal
;
2824 if ( aSeq
[2] >>= nVal
)
2825 aBorderLine
.OuterLineWidth
= (sal_Int16
) nVal
;
2826 if ( aSeq
[3] >>= nVal
)
2827 aBorderLine
.LineDistance
= (sal_Int16
) nVal
;
2828 if (aSeq
.getLength() >= 5) // fdo#40874 added fields
2830 if (aSeq
[4] >>= nVal
)
2832 aBorderLine
.LineStyle
= nVal
;
2834 if (aSeq
.getLength() >= 6)
2836 if (aSeq
[5] >>= nVal
)
2838 aBorderLine
.LineWidth
= nVal
;
2846 else if (rVal
.getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence
< sal_Int16
>*)0) )
2848 // serialization for basic macro recording
2849 ::com::sun::star::uno::Sequence
< sal_Int16
> aSeq
;
2851 if (aSeq
.getLength() >= 4 && aSeq
.getLength() <= 6)
2853 aBorderLine
.Color
= aSeq
[0];
2854 aBorderLine
.InnerLineWidth
= aSeq
[1];
2855 aBorderLine
.OuterLineWidth
= aSeq
[2];
2856 aBorderLine
.LineDistance
= aSeq
[3];
2857 if (aSeq
.getLength() >= 5) // fdo#40874 added fields
2859 aBorderLine
.LineStyle
= aSeq
[4];
2860 if (aSeq
.getLength() >= 6)
2862 aBorderLine
.LineWidth
= aSeq
[5];
2872 SvxBorderLine aLine
;
2873 sal_Bool bSet
= SvxBoxItem::LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2875 SetLine( &aLine
, nMemberId
== MID_HORIZONTAL
? BOXINFO_LINE_HORI
: BOXINFO_LINE_VERT
);
2880 sal_Int16 nFlags
= sal_Int16();
2881 bRet
= (rVal
>>= nFlags
);
2884 SetTable ( ( nFlags
& 0x01 ) != 0 );
2885 SetDist ( ( nFlags
& 0x02 ) != 0 );
2886 SetMinDist( ( nFlags
& 0x04 ) != 0 );
2891 case MID_VALIDFLAGS
:
2893 sal_Int16 nFlags
= sal_Int16();
2894 bRet
= (rVal
>>= nFlags
);
2896 nValidFlags
= (sal_uInt8
)nFlags
;
2902 bRet
= (rVal
>>= nVal
);
2903 if ( bRet
&& nVal
>=0 )
2906 nVal
= MM100_TO_TWIP(nVal
);
2907 SetDefDist( (sal_uInt16
)nVal
);
2911 default: OSL_FAIL("Wrong MemberId!"); return sal_False
;
2917 // class SvxFmtBreakItem -------------------------------------------------
2919 int SvxFmtBreakItem::operator==( const SfxPoolItem
& rAttr
) const
2921 DBG_ASSERT( SfxPoolItem::operator==( rAttr
), "unequal types" );
2923 return GetValue() == ( (SvxFmtBreakItem
&)rAttr
).GetValue();
2926 //------------------------------------------------------------------------
2928 SfxItemPresentation
SvxFmtBreakItem::GetPresentation
2930 SfxItemPresentation ePres
,
2931 SfxMapUnit
/*eCoreUnit*/,
2932 SfxMapUnit
/*ePresUnit*/,
2933 XubString
& rText
, const IntlWrapper
*
2938 case SFX_ITEM_PRESENTATION_NONE
:
2940 return SFX_ITEM_PRESENTATION_NONE
;
2942 case SFX_ITEM_PRESENTATION_NAMELESS
:
2943 case SFX_ITEM_PRESENTATION_COMPLETE
:
2944 rText
= GetValueTextByPos( GetValue() );
2946 default: ;//prevent warning
2948 return SFX_ITEM_PRESENTATION_NONE
;
2951 // -----------------------------------------------------------------------
2953 rtl::OUString
SvxFmtBreakItem::GetValueTextByPos( sal_uInt16 nPos
) const
2955 DBG_ASSERT( nPos
< SVX_BREAK_END
, "enum overflow!" );
2956 return EE_RESSTR(RID_SVXITEMS_BREAK_BEGIN
+ nPos
);
2959 // -----------------------------------------------------------------------
2960 bool SvxFmtBreakItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ ) const
2962 style::BreakType eBreak
= style::BreakType_NONE
;
2963 switch ( (SvxBreak
)GetValue() )
2965 case SVX_BREAK_COLUMN_BEFORE
: eBreak
= style::BreakType_COLUMN_BEFORE
; break;
2966 case SVX_BREAK_COLUMN_AFTER
: eBreak
= style::BreakType_COLUMN_AFTER
; break;
2967 case SVX_BREAK_COLUMN_BOTH
: eBreak
= style::BreakType_COLUMN_BOTH
; break;
2968 case SVX_BREAK_PAGE_BEFORE
: eBreak
= style::BreakType_PAGE_BEFORE
; break;
2969 case SVX_BREAK_PAGE_AFTER
: eBreak
= style::BreakType_PAGE_AFTER
; break;
2970 case SVX_BREAK_PAGE_BOTH
: eBreak
= style::BreakType_PAGE_BOTH
; break;
2971 default: ;//prevent warning
2976 // -----------------------------------------------------------------------
2977 bool SvxFmtBreakItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/*nMemberId*/ )
2979 style::BreakType nBreak
;
2981 if(!(rVal
>>= nBreak
))
2983 sal_Int32 nValue
= 0;
2984 if(!(rVal
>>= nValue
))
2987 nBreak
= (style::BreakType
) nValue
;
2990 SvxBreak eBreak
= SVX_BREAK_NONE
;
2993 case style::BreakType_COLUMN_BEFORE
: eBreak
= SVX_BREAK_COLUMN_BEFORE
; break;
2994 case style::BreakType_COLUMN_AFTER
: eBreak
= SVX_BREAK_COLUMN_AFTER
; break;
2995 case style::BreakType_COLUMN_BOTH
: eBreak
= SVX_BREAK_COLUMN_BOTH
; break;
2996 case style::BreakType_PAGE_BEFORE
: eBreak
= SVX_BREAK_PAGE_BEFORE
; break;
2997 case style::BreakType_PAGE_AFTER
: eBreak
= SVX_BREAK_PAGE_AFTER
; break;
2998 case style::BreakType_PAGE_BOTH
: eBreak
= SVX_BREAK_PAGE_BOTH
; break;
2999 default: ;//prevent warning
3001 SetValue((sal_uInt16
) eBreak
);
3006 // -----------------------------------------------------------------------
3008 SfxPoolItem
* SvxFmtBreakItem::Clone( SfxItemPool
* ) const
3010 return new SvxFmtBreakItem( *this );
3013 // -----------------------------------------------------------------------
3015 SvStream
& SvxFmtBreakItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
3017 rStrm
<< (sal_Int8
)GetValue();
3018 if( FMTBREAK_NOAUTO
> nItemVersion
)
3019 rStrm
<< (sal_Int8
)0x01;
3023 // -----------------------------------------------------------------------
3025 sal_uInt16
SvxFmtBreakItem::GetVersion( sal_uInt16 nFFVer
) const
3027 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
3028 SOFFICE_FILEFORMAT_40
==nFFVer
||
3029 SOFFICE_FILEFORMAT_50
==nFFVer
,
3030 "SvxFmtBreakItem: Is there a new file format? ");
3031 return SOFFICE_FILEFORMAT_31
==nFFVer
||
3032 SOFFICE_FILEFORMAT_40
==nFFVer
? 0 : FMTBREAK_NOAUTO
;
3035 // -----------------------------------------------------------------------
3037 SfxPoolItem
* SvxFmtBreakItem::Create( SvStream
& rStrm
, sal_uInt16 nVersion
) const
3039 sal_Int8 eBreak
, bDummy
;
3041 if( FMTBREAK_NOAUTO
> nVersion
)
3043 return new SvxFmtBreakItem( (const SvxBreak
)eBreak
, Which() );
3046 // -----------------------------------------------------------------------
3048 sal_uInt16
SvxFmtBreakItem::GetValueCount() const
3050 return SVX_BREAK_END
; // SVX_BREAK_PAGE_BOTH + 1
3053 // class SvxFmtKeepItem -------------------------------------------------
3055 SfxPoolItem
* SvxFmtKeepItem::Clone( SfxItemPool
* ) const
3057 return new SvxFmtKeepItem( *this );
3060 // -----------------------------------------------------------------------
3062 SvStream
& SvxFmtKeepItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
3064 rStrm
<< (sal_Int8
)GetValue();
3068 // -----------------------------------------------------------------------
3070 SfxPoolItem
* SvxFmtKeepItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3074 return new SvxFmtKeepItem( sal_Bool( bIsKeep
!= 0 ), Which() );
3077 //------------------------------------------------------------------------
3079 SfxItemPresentation
SvxFmtKeepItem::GetPresentation
3081 SfxItemPresentation ePres
,
3082 SfxMapUnit
/*eCoreUnit*/,
3083 SfxMapUnit
/*ePresUnit*/,
3084 XubString
& rText
, const IntlWrapper
*
3089 case SFX_ITEM_PRESENTATION_NONE
:
3093 case SFX_ITEM_PRESENTATION_NAMELESS
:
3094 case SFX_ITEM_PRESENTATION_COMPLETE
:
3096 sal_uInt16 nId
= RID_SVXITEMS_FMTKEEP_FALSE
;
3099 nId
= RID_SVXITEMS_FMTKEEP_TRUE
;
3100 rText
= EE_RESSTR(nId
);
3103 default: ;//prevent warning
3105 return SFX_ITEM_PRESENTATION_NONE
;
3108 // class SvxLineItem ------------------------------------------------------
3110 SvxLineItem::SvxLineItem( const sal_uInt16 nId
) :
3112 SfxPoolItem ( nId
),
3118 // -----------------------------------------------------------------------
3120 SvxLineItem::SvxLineItem( const SvxLineItem
& rCpy
) :
3122 SfxPoolItem ( rCpy
)
3124 pLine
= rCpy
.GetLine() ? new SvxBorderLine( *rCpy
.GetLine() ) : 0;
3127 // -----------------------------------------------------------------------
3129 SvxLineItem::~SvxLineItem()
3134 // -----------------------------------------------------------------------
3136 SvxLineItem
& SvxLineItem::operator=( const SvxLineItem
& rLine
)
3138 SetLine( rLine
.GetLine() );
3143 // -----------------------------------------------------------------------
3145 int SvxLineItem::operator==( const SfxPoolItem
& rAttr
) const
3147 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
3149 return CmpBrdLn( pLine
, ((SvxLineItem
&)rAttr
).GetLine() );
3152 // -----------------------------------------------------------------------
3154 SfxPoolItem
* SvxLineItem::Clone( SfxItemPool
* ) const
3156 return new SvxLineItem( *this );
3159 bool SvxLineItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemId
) const
3161 sal_Bool bConvert
= 0!=(nMemId
&CONVERT_TWIPS
);
3162 nMemId
&= ~CONVERT_TWIPS
;
3165 rVal
<<= uno::makeAny( SvxBoxItem::SvxLineToLine(pLine
, bConvert
) );
3172 case MID_FG_COLOR
: rVal
<<= sal_Int32(pLine
->GetColor().GetColor()); break;
3173 case MID_OUTER_WIDTH
: rVal
<<= sal_Int32(pLine
->GetOutWidth()); break;
3174 case MID_INNER_WIDTH
: rVal
<<= sal_Int32(pLine
->GetInWidth( )); break;
3175 case MID_DISTANCE
: rVal
<<= sal_Int32(pLine
->GetDistance()); break;
3177 OSL_FAIL( "Wrong MemberId" );
3185 // -----------------------------------------------------------------------
3187 bool SvxLineItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemId
)
3189 sal_Bool bConvert
= 0!=(nMemId
&CONVERT_TWIPS
);
3190 nMemId
&= ~CONVERT_TWIPS
;
3194 table::BorderLine2 aLine
;
3195 if ( lcl_extractBorderLine(rVal
, aLine
) )
3198 pLine
= new SvxBorderLine
;
3199 if( !SvxBoxItem::LineToSvxLine(aLine
, *pLine
, bConvert
) )
3205 else if ( rVal
>>= nVal
)
3208 pLine
= new SvxBorderLine
;
3212 case MID_FG_COLOR
: pLine
->SetColor( Color(nVal
) ); break;
3213 case MID_LINE_STYLE
:
3214 pLine
->SetBorderLineStyle(static_cast<SvxBorderStyle
>(nVal
));
3217 OSL_FAIL( "Wrong MemberId" );
3227 //------------------------------------------------------------------------
3229 SfxItemPresentation
SvxLineItem::GetPresentation
3231 SfxItemPresentation ePres
,
3232 SfxMapUnit eCoreUnit
,
3233 SfxMapUnit ePresUnit
,
3234 XubString
& rText
, const IntlWrapper
*pIntl
3241 case SFX_ITEM_PRESENTATION_NONE
:
3242 return SFX_ITEM_PRESENTATION_NONE
;
3243 case SFX_ITEM_PRESENTATION_NAMELESS
:
3244 case SFX_ITEM_PRESENTATION_COMPLETE
:
3247 rText
= pLine
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
,
3248 (SFX_ITEM_PRESENTATION_COMPLETE
== ePres
) );
3251 default: ;//prevent warning
3253 return SFX_ITEM_PRESENTATION_NONE
;
3256 // -----------------------------------------------------------------------
3258 SvStream
& SvxLineItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
3262 rStrm
<< pLine
->GetColor()
3263 << (short)pLine
->GetOutWidth()
3264 << (short)pLine
->GetInWidth()
3265 << (short)pLine
->GetDistance();
3268 rStrm
<< Color() << (short)0 << (short)0 << (short)0;
3272 // -----------------------------------------------------------------------
3274 bool SvxLineItem::ScaleMetrics( long nMult
, long nDiv
)
3276 if ( pLine
) pLine
->ScaleMetrics( nMult
, nDiv
);
3280 // -----------------------------------------------------------------------
3282 bool SvxLineItem::HasMetrics() const
3287 // -----------------------------------------------------------------------
3289 SfxPoolItem
* SvxLineItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3291 SvxLineItem
* _pLine
= new SvxLineItem( Which() );
3292 short nOutline
, nInline
, nDistance
;
3295 rStrm
>> aColor
>> nOutline
>> nInline
>> nDistance
;
3298 SvxBorderLine
aLine( &aColor
);
3299 aLine
.GuessLinesWidths(NONE
, nOutline
, nInline
, nDistance
);
3300 _pLine
->SetLine( &aLine
);
3305 // -----------------------------------------------------------------------
3307 void SvxLineItem::SetLine( const SvxBorderLine
* pNew
)
3310 pLine
= pNew
? new SvxBorderLine( *pNew
) : 0;
3314 #pragma optimize ( "", off )
3317 // class SvxBrushItem ----------------------------------------------------
3319 #define LOAD_GRAPHIC ((sal_uInt16)0x0001)
3320 #define LOAD_LINK ((sal_uInt16)0x0002)
3321 #define LOAD_FILTER ((sal_uInt16)0x0004)
3323 // class SvxBrushItem_Impl -----------------------------------------------
3325 class SvxBrushItem_Impl
3328 GraphicObject
* pGraphicObject
;
3329 sal_Int8 nGraphicTransparency
; //contains a percentage value which is
3330 //copied to the GraphicObject when necessary
3334 SvxBrushItem_Impl( GraphicObject
* p
) : pGraphicObject( p
), nGraphicTransparency(0), pStream(0) {}
3337 // -----------------------------------------------------------------------
3339 void SvxBrushItem::SetDoneLink( const Link
& rLink
)
3341 pImpl
->aDoneLink
= rLink
;
3344 // -----------------------------------------------------------------------
3346 SvxBrushItem::SvxBrushItem( sal_uInt16 _nWhich
) :
3348 SfxPoolItem( _nWhich
),
3350 aColor ( COL_TRANSPARENT
),
3351 pImpl ( new SvxBrushItem_Impl( 0 ) ),
3353 pStrFilter ( NULL
),
3354 eGraphicPos ( GPOS_NONE
),
3355 bLoadAgain ( sal_True
)
3360 // -----------------------------------------------------------------------
3362 SvxBrushItem::SvxBrushItem( const Color
& rColor
, sal_uInt16 _nWhich
) :
3364 SfxPoolItem( _nWhich
),
3367 pImpl ( new SvxBrushItem_Impl( 0 ) ),
3369 pStrFilter ( NULL
),
3370 eGraphicPos ( GPOS_NONE
),
3371 bLoadAgain ( sal_True
)
3376 // -----------------------------------------------------------------------
3378 SvxBrushItem::SvxBrushItem( const Graphic
& rGraphic
, SvxGraphicPosition ePos
,
3379 sal_uInt16 _nWhich
) :
3381 SfxPoolItem( _nWhich
),
3383 aColor ( COL_TRANSPARENT
),
3384 pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphic
) ) ),
3386 pStrFilter ( NULL
),
3387 eGraphicPos ( ( GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
),
3388 bLoadAgain ( sal_True
)
3391 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3394 // -----------------------------------------------------------------------
3396 SvxBrushItem::SvxBrushItem( const GraphicObject
& rGraphicObj
,
3397 SvxGraphicPosition ePos
, sal_uInt16 _nWhich
) :
3399 SfxPoolItem( _nWhich
),
3401 aColor ( COL_TRANSPARENT
),
3402 pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphicObj
) ) ),
3404 pStrFilter ( NULL
),
3405 eGraphicPos ( ( GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
),
3406 bLoadAgain ( sal_True
)
3409 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3412 // -----------------------------------------------------------------------
3414 SvxBrushItem::SvxBrushItem(
3415 const String
& rLink
, const String
& rFilter
,
3416 SvxGraphicPosition ePos
, sal_uInt16 _nWhich
) :
3418 SfxPoolItem( _nWhich
),
3420 aColor ( COL_TRANSPARENT
),
3421 pImpl ( new SvxBrushItem_Impl( NULL
) ),
3422 pStrLink ( new String( rLink
) ),
3423 pStrFilter ( new String( rFilter
) ),
3424 eGraphicPos ( ( GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
),
3425 bLoadAgain ( sal_True
)
3428 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3431 // -----------------------------------------------------------------------
3433 SvxBrushItem::SvxBrushItem( SvStream
& rStream
, sal_uInt16 nVersion
,
3434 sal_uInt16 _nWhich
) :
3436 SfxPoolItem( _nWhich
),
3438 aColor ( COL_TRANSPARENT
),
3439 pImpl ( new SvxBrushItem_Impl( NULL
) ),
3441 pStrFilter ( NULL
),
3442 eGraphicPos ( GPOS_NONE
)
3447 Color aTempFillColor
;
3451 rStream
>> aTempColor
;
3452 rStream
>> aTempFillColor
;
3459 sal_uInt32 nRed
= aTempColor
.GetRed();
3460 sal_uInt32 nGreen
= aTempColor
.GetGreen();
3461 sal_uInt32 nBlue
= aTempColor
.GetBlue();
3462 nRed
+= (sal_uInt32
)(aTempFillColor
.GetRed())*2;
3463 nGreen
+= (sal_uInt32
)(aTempFillColor
.GetGreen())*2;
3464 nBlue
+= (sal_uInt32
)(aTempFillColor
.GetBlue())*2;
3465 aColor
= Color( (sal_Int8
)(nRed
/3), (sal_Int8
)(nGreen
/3), (sal_Int8
)(nBlue
/3) );
3471 sal_uInt32 nRed
= aTempColor
.GetRed();
3472 sal_uInt32 nGreen
= aTempColor
.GetGreen();
3473 sal_uInt32 nBlue
= aTempColor
.GetBlue();
3474 nRed
+= (sal_uInt32
)(aTempFillColor
.GetRed());
3475 nGreen
+= (sal_uInt32
)(aTempFillColor
.GetGreen());
3476 nBlue
+= (sal_uInt32
)(aTempFillColor
.GetBlue());
3477 aColor
= Color( (sal_Int8
)(nRed
/2), (sal_Int8
)(nGreen
/2), (sal_Int8
)(nBlue
/2) );
3483 sal_uInt32 nRed
= aTempColor
.GetRed()*2;
3484 sal_uInt32 nGreen
= aTempColor
.GetGreen()*2;
3485 sal_uInt32 nBlue
= aTempColor
.GetBlue()*2;
3486 nRed
+= (sal_uInt32
)(aTempFillColor
.GetRed());
3487 nGreen
+= (sal_uInt32
)(aTempFillColor
.GetGreen());
3488 nBlue
+= (sal_uInt32
)(aTempFillColor
.GetBlue());
3489 aColor
= Color( (sal_Int8
)(nRed
/3), (sal_Int8
)(nGreen
/3), (sal_Int8
)(nBlue
/3) );
3493 case 0://BRUSH_NULL:
3494 aColor
= Color( COL_TRANSPARENT
);
3498 aColor
= aTempColor
;
3501 if ( nVersion
>= BRUSH_GRAPHIC_VERSION
)
3503 sal_uInt16 nDoLoad
= 0;
3508 if ( nDoLoad
& LOAD_GRAPHIC
)
3512 rStream
>> aGraphic
;
3513 pImpl
->pGraphicObject
= new GraphicObject( aGraphic
);
3515 if( SVSTREAM_FILEFORMAT_ERROR
== rStream
.GetError() )
3517 rStream
.ResetError();
3518 rStream
.SetError( ERRCODE_SVX_GRAPHIC_WRONG_FILEFORMAT
|
3519 ERRCODE_WARNING_MASK
);
3523 if ( nDoLoad
& LOAD_LINK
)
3525 // UNICODE: rStream >> aRel;
3526 String aRel
= rStream
.ReadUniOrByteString(rStream
.GetStreamCharSet());
3528 // TODO/MBA: how can we get a BaseURL here?!
3529 OSL_FAIL("No BaseURL!");
3530 String aAbs
= INetURLObject::GetAbsURL( String(), aRel
);
3531 DBG_ASSERT( aAbs
.Len(), "Invalid URL!" );
3532 pStrLink
= new String( aAbs
);
3535 if ( nDoLoad
& LOAD_FILTER
)
3537 pStrFilter
= new String
;
3538 // UNICODE: rStream >> *pStrFilter;
3539 *pStrFilter
= rStream
.ReadUniOrByteString(rStream
.GetStreamCharSet());
3544 eGraphicPos
= (SvxGraphicPosition
)nPos
;
3548 // -----------------------------------------------------------------------
3550 SvxBrushItem::SvxBrushItem( const SvxBrushItem
& rItem
) :
3552 SfxPoolItem( rItem
.Which() ),
3554 pImpl ( new SvxBrushItem_Impl( NULL
) ),
3556 pStrFilter ( NULL
),
3557 eGraphicPos ( GPOS_NONE
),
3558 bLoadAgain ( sal_True
)
3564 // -----------------------------------------------------------------------
3566 SvxBrushItem::~SvxBrushItem()
3568 delete pImpl
->pGraphicObject
;
3574 // -----------------------------------------------------------------------
3576 sal_uInt16
SvxBrushItem::GetVersion( sal_uInt16
/*nFileVersion*/ ) const
3578 return BRUSH_GRAPHIC_VERSION
;
3581 // -----------------------------------------------------------------------
3582 static inline sal_Int8
lcl_PercentToTransparency(long nPercent
)
3584 //0xff must not be returned!
3585 return sal_Int8(nPercent
? (50 + 0xfe * nPercent
) / 100 : 0);
3587 static inline sal_Int8
lcl_TransparencyToPercent(sal_Int32 nTrans
)
3589 return (sal_Int8
)((nTrans
* 100 + 127) / 254);
3592 bool SvxBrushItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
3594 nMemberId
&= ~CONVERT_TWIPS
;
3597 case MID_BACK_COLOR
:
3598 rVal
<<= (sal_Int32
)( aColor
.GetColor() );
3600 case MID_BACK_COLOR_R_G_B
:
3601 rVal
<<= (sal_Int32
)( aColor
.GetRGBColor() );
3603 case MID_BACK_COLOR_TRANSPARENCY
:
3604 rVal
<<= lcl_TransparencyToPercent(aColor
.GetTransparency());
3606 case MID_GRAPHIC_POSITION
:
3607 rVal
<<= (style::GraphicLocation
)(sal_Int16
)eGraphicPos
;
3611 SAL_WARN( "editeng.items", "not implemented" );
3614 case MID_GRAPHIC_TRANSPARENT
:
3615 rVal
= Bool2Any( aColor
.GetTransparency() == 0xff );
3618 case MID_GRAPHIC_URL
:
3623 else if( pImpl
->pGraphicObject
)
3626 UNO_NAME_GRAPHOBJ_URLPREFIX
);
3627 OUString
sId(rtl::OStringToOUString(
3628 pImpl
->pGraphicObject
->GetUniqueID(),
3629 RTL_TEXTENCODING_ASCII_US
));
3630 sLink
= sPrefix
+ sId
;
3636 case MID_GRAPHIC_FILTER
:
3640 sFilter
= *pStrFilter
;
3644 case MID_GRAPHIC_TRANSPARENCY
:
3645 rVal
<<= pImpl
->nGraphicTransparency
;
3652 // -----------------------------------------------------------------------
3654 bool SvxBrushItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
3656 nMemberId
&= ~CONVERT_TWIPS
;
3659 case MID_BACK_COLOR
:
3660 case MID_BACK_COLOR_R_G_B
:
3663 if ( !( rVal
>>= nCol
) )
3665 if(MID_BACK_COLOR_R_G_B
== nMemberId
)
3667 nCol
= COLORDATA_RGB( nCol
);
3668 nCol
+= aColor
.GetColor() & 0xff000000;
3670 aColor
= Color( nCol
);
3673 case MID_BACK_COLOR_TRANSPARENCY
:
3675 sal_Int32 nTrans
= 0;
3676 if ( !( rVal
>>= nTrans
) || nTrans
< 0 || nTrans
> 100 )
3678 aColor
.SetTransparency(lcl_PercentToTransparency(nTrans
));
3682 case MID_GRAPHIC_POSITION
:
3684 style::GraphicLocation eLocation
;
3685 if ( !( rVal
>>=eLocation
) )
3687 sal_Int32 nValue
= 0;
3688 if ( !( rVal
>>= nValue
) )
3690 eLocation
= (style::GraphicLocation
)nValue
;
3692 SetGraphicPos( (SvxGraphicPosition
)(sal_uInt16
)eLocation
);
3697 SAL_WARN( "editeng.items", "not implemented" );
3700 case MID_GRAPHIC_TRANSPARENT
:
3701 aColor
.SetTransparency( Any2Bool( rVal
) ? 0xff : 0 );
3704 case MID_GRAPHIC_URL
:
3706 if ( rVal
.getValueType() == ::getCppuType( (OUString
*)0 ) )
3710 if( 0 == sLink
.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX
,
3711 sizeof(UNO_NAME_GRAPHOBJ_URLPKGPREFIX
)-1 ) )
3713 OSL_FAIL( "package urls aren't implemented" );
3715 else if( 0 == sLink
.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX
,
3716 sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX
)-1 ) )
3718 DELETEZ( pStrLink
);
3719 String
sTmp( sLink
);
3720 rtl::OString
sId(rtl::OUStringToOString(sTmp
.Copy(
3721 sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX
)-1),
3722 RTL_TEXTENCODING_ASCII_US
));
3723 GraphicObject
*pOldGrfObj
= pImpl
->pGraphicObject
;
3724 pImpl
->pGraphicObject
= new GraphicObject( sId
);
3725 ApplyGraphicTransparency_Impl();
3730 SetGraphicLink(sLink
);
3732 if ( !sLink
.isEmpty() && eGraphicPos
== GPOS_NONE
)
3733 eGraphicPos
= GPOS_MM
;
3734 else if( sLink
.isEmpty() )
3735 eGraphicPos
= GPOS_NONE
;
3740 case MID_GRAPHIC_FILTER
:
3742 if( rVal
.getValueType() == ::getCppuType( (OUString
*)0 ) )
3746 SetGraphicFilter( sLink
);
3750 case MID_GRAPHIC_TRANSPARENCY
:
3754 if(nTmp
>= 0 && nTmp
<= 100)
3756 pImpl
->nGraphicTransparency
= sal_Int8(nTmp
);
3757 if(pImpl
->pGraphicObject
)
3758 ApplyGraphicTransparency_Impl();
3767 // -----------------------------------------------------------------------
3769 SfxItemPresentation
SvxBrushItem::GetPresentation
3771 SfxItemPresentation ePres
,
3772 SfxMapUnit
/*eCoreUnit*/,
3773 SfxMapUnit
/*ePresUnit*/,
3774 XubString
& rText
, const IntlWrapper
*
3779 case SFX_ITEM_PRESENTATION_NONE
:
3783 case SFX_ITEM_PRESENTATION_NAMELESS
:
3784 case SFX_ITEM_PRESENTATION_COMPLETE
:
3786 if ( GPOS_NONE
== eGraphicPos
)
3788 rText
= ::GetColorString( aColor
);
3790 sal_uInt16 nId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
3792 if ( aColor
.GetTransparency() )
3793 nId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
3794 rText
+= EE_RESSTR(nId
);
3798 rText
= EE_RESSTR(RID_SVXITEMS_GRAPHIC
);
3803 default: ;//prevent warning
3806 return SFX_ITEM_PRESENTATION_NONE
;
3809 // -----------------------------------------------------------------------
3811 SvxBrushItem
& SvxBrushItem::operator=( const SvxBrushItem
& rItem
)
3813 aColor
= rItem
.aColor
;
3814 eGraphicPos
= rItem
.eGraphicPos
;
3816 DELETEZ( pImpl
->pGraphicObject
);
3817 DELETEZ( pStrLink
);
3818 DELETEZ( pStrFilter
);
3820 if ( GPOS_NONE
!= eGraphicPos
)
3822 if ( rItem
.pStrLink
)
3823 pStrLink
= new String( *rItem
.pStrLink
);
3824 if ( rItem
.pStrFilter
)
3825 pStrFilter
= new String( *rItem
.pStrFilter
);
3826 if ( rItem
.pImpl
->pGraphicObject
)
3828 pImpl
->pGraphicObject
= new GraphicObject( *rItem
.pImpl
->pGraphicObject
);
3831 pImpl
->nGraphicTransparency
= rItem
.pImpl
->nGraphicTransparency
;
3835 // -----------------------------------------------------------------------
3837 int SvxBrushItem::operator==( const SfxPoolItem
& rAttr
) const
3839 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
3841 SvxBrushItem
& rCmp
= (SvxBrushItem
&)rAttr
;
3842 sal_Bool bEqual
= ( aColor
== rCmp
.aColor
&& eGraphicPos
== rCmp
.eGraphicPos
&&
3843 pImpl
->nGraphicTransparency
== rCmp
.pImpl
->nGraphicTransparency
);
3847 if ( GPOS_NONE
!= eGraphicPos
)
3849 if ( !rCmp
.pStrLink
)
3852 bEqual
= pStrLink
&& ( *pStrLink
== *rCmp
.pStrLink
);
3856 if ( !rCmp
.pStrFilter
)
3857 bEqual
= !pStrFilter
;
3859 bEqual
= pStrFilter
&& ( *pStrFilter
== *rCmp
.pStrFilter
);
3862 if ( bEqual
&& !rCmp
.pStrLink
)
3864 if ( !rCmp
.pImpl
->pGraphicObject
)
3865 bEqual
= !pImpl
->pGraphicObject
;
3867 bEqual
= pImpl
->pGraphicObject
&&
3868 ( *pImpl
->pGraphicObject
== *rCmp
.pImpl
->pGraphicObject
);
3876 // -----------------------------------------------------------------------
3878 SfxPoolItem
* SvxBrushItem::Clone( SfxItemPool
* ) const
3880 return new SvxBrushItem( *this );
3883 // -----------------------------------------------------------------------
3885 SfxPoolItem
* SvxBrushItem::Create( SvStream
& rStream
, sal_uInt16 nVersion
) const
3887 return new SvxBrushItem( rStream
, nVersion
, Which() );
3890 // -----------------------------------------------------------------------
3892 SvStream
& SvxBrushItem::Store( SvStream
& rStream
, sal_uInt16
/*nItemVersion*/ ) const
3894 rStream
<< (sal_Bool
)sal_False
;
3897 rStream
<< (sal_Int8
)(aColor
.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
3899 sal_uInt16 nDoLoad
= 0;
3901 if ( pImpl
->pGraphicObject
&& !pStrLink
)
3902 nDoLoad
|= LOAD_GRAPHIC
;
3904 nDoLoad
|= LOAD_LINK
;
3906 nDoLoad
|= LOAD_FILTER
;
3909 if ( pImpl
->pGraphicObject
&& !pStrLink
)
3910 rStream
<< pImpl
->pGraphicObject
->GetGraphic();
3913 OSL_FAIL("No BaseURL!");
3914 // TODO/MBA: how to get a BaseURL?!
3915 String aRel
= INetURLObject::GetRelURL( String(), *pStrLink
);
3916 // UNICODE: rStream << aRel;
3917 rStream
.WriteUniOrByteString(aRel
, rStream
.GetStreamCharSet());
3921 // UNICODE: rStream << *pStrFilter;
3922 rStream
.WriteUniOrByteString(*pStrFilter
, rStream
.GetStreamCharSet());
3924 rStream
<< (sal_Int8
)eGraphicPos
;
3928 // -----------------------------------------------------------------------
3930 void SvxBrushItem::PurgeMedium() const
3932 DELETEZ( pImpl
->pStream
);
3935 // -----------------------------------------------------------------------
3936 const GraphicObject
* SvxBrushItem::GetGraphicObject() const
3938 if ( bLoadAgain
&& pStrLink
&& !pImpl
->pGraphicObject
)
3939 // when graphics already loaded, use as a cache
3941 // only with "valid" names - empty names now allowed
3942 if( pStrLink
->Len() )
3944 pImpl
->pStream
= utl::UcbStreamHelper::CreateStream( *pStrLink
, STREAM_STD_READ
);
3945 if( pImpl
->pStream
&& !pImpl
->pStream
->GetError() )
3949 pImpl
->pStream
->Seek( STREAM_SEEK_TO_BEGIN
);
3950 nRes
= GraphicFilter::GetGraphicFilter().
3951 ImportGraphic( aGraphic
, *pStrLink
, *pImpl
->pStream
,
3952 GRFILTER_FORMAT_DONTKNOW
, NULL
, GRFILTER_I_FLAGS_DONT_SET_LOGSIZE_FOR_JPEG
);
3954 if( nRes
!= GRFILTER_OK
)
3956 const_cast < SvxBrushItem
*> (this)->bLoadAgain
= sal_False
;
3960 pImpl
->pGraphicObject
= new GraphicObject
;
3961 pImpl
->pGraphicObject
->SetGraphic( aGraphic
);
3962 const_cast < SvxBrushItem
*> (this)->ApplyGraphicTransparency_Impl();
3967 const_cast < SvxBrushItem
*> (this)->bLoadAgain
= sal_False
;
3972 return pImpl
->pGraphicObject
;
3975 // -----------------------------------------------------------------------
3977 const Graphic
* SvxBrushItem::GetGraphic() const
3979 const GraphicObject
* pGrafObj
= GetGraphicObject();
3980 return( pGrafObj
? &( pGrafObj
->GetGraphic() ) : NULL
);
3983 // -----------------------------------------------------------------------
3985 void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew
)
3989 if ( GPOS_NONE
== eGraphicPos
)
3991 DELETEZ( pImpl
->pGraphicObject
);
3992 DELETEZ( pStrLink
);
3993 DELETEZ( pStrFilter
);
3997 if ( !pImpl
->pGraphicObject
&& !pStrLink
)
3999 pImpl
->pGraphicObject
= new GraphicObject
; // Creating a dummy
4004 // -----------------------------------------------------------------------
4006 void SvxBrushItem::SetGraphic( const Graphic
& rNew
)
4010 if ( pImpl
->pGraphicObject
)
4011 pImpl
->pGraphicObject
->SetGraphic( rNew
);
4013 pImpl
->pGraphicObject
= new GraphicObject( rNew
);
4015 ApplyGraphicTransparency_Impl();
4017 if ( GPOS_NONE
== eGraphicPos
)
4018 eGraphicPos
= GPOS_MM
; // None would be brush, then Default: middle
4022 OSL_FAIL( "SetGraphic() on linked graphic! :-/" );
4026 // -----------------------------------------------------------------------
4028 void SvxBrushItem::SetGraphicObject( const GraphicObject
& rNewObj
)
4032 if ( pImpl
->pGraphicObject
)
4033 *pImpl
->pGraphicObject
= rNewObj
;
4035 pImpl
->pGraphicObject
= new GraphicObject( rNewObj
);
4037 ApplyGraphicTransparency_Impl();
4039 if ( GPOS_NONE
== eGraphicPos
)
4040 eGraphicPos
= GPOS_MM
; // None would be brush, then Default: middle
4044 OSL_FAIL( "SetGraphic() on linked graphic! :-/" );
4048 // -----------------------------------------------------------------------
4050 void SvxBrushItem::SetGraphicLink( const String
& rNew
)
4053 DELETEZ( pStrLink
);
4059 pStrLink
= new String( rNew
);
4061 DELETEZ( pImpl
->pGraphicObject
);
4065 // -----------------------------------------------------------------------
4067 void SvxBrushItem::SetGraphicFilter( const String
& rNew
)
4070 DELETEZ( pStrFilter
);
4076 pStrFilter
= new String( rNew
);
4081 SvxGraphicPosition
SvxBrushItem::WallpaperStyle2GraphicPos( WallpaperStyle eStyle
)
4083 SvxGraphicPosition eResult
;
4084 // The switch is not the fastest, but the safest
4087 case WALLPAPER_NULL
: eResult
= GPOS_NONE
; break;
4088 case WALLPAPER_TILE
: eResult
= GPOS_TILED
; break;
4089 case WALLPAPER_CENTER
: eResult
= GPOS_MM
; break;
4090 case WALLPAPER_SCALE
: eResult
= GPOS_AREA
; break;
4091 case WALLPAPER_TOPLEFT
: eResult
= GPOS_LT
; break;
4092 case WALLPAPER_TOP
: eResult
= GPOS_MT
; break;
4093 case WALLPAPER_TOPRIGHT
: eResult
= GPOS_RT
; break;
4094 case WALLPAPER_LEFT
: eResult
= GPOS_LM
; break;
4095 case WALLPAPER_RIGHT
: eResult
= GPOS_RM
; break;
4096 case WALLPAPER_BOTTOMLEFT
: eResult
= GPOS_LB
; break;
4097 case WALLPAPER_BOTTOM
: eResult
= GPOS_MB
; break;
4098 case WALLPAPER_BOTTOMRIGHT
: eResult
= GPOS_RB
; break;
4099 default: eResult
= GPOS_NONE
;
4105 WallpaperStyle
SvxBrushItem::GraphicPos2WallpaperStyle( SvxGraphicPosition ePos
)
4107 WallpaperStyle eResult
;
4110 case GPOS_NONE
: eResult
= WALLPAPER_NULL
; break;
4111 case GPOS_TILED
: eResult
= WALLPAPER_TILE
; break;
4112 case GPOS_MM
: eResult
= WALLPAPER_CENTER
; break;
4113 case GPOS_AREA
: eResult
= WALLPAPER_SCALE
; break;
4114 case GPOS_LT
: eResult
= WALLPAPER_TOPLEFT
; break;
4115 case GPOS_MT
: eResult
= WALLPAPER_TOP
; break;
4116 case GPOS_RT
: eResult
= WALLPAPER_TOPRIGHT
; break;
4117 case GPOS_LM
: eResult
= WALLPAPER_LEFT
; break;
4118 case GPOS_RM
: eResult
= WALLPAPER_RIGHT
; break;
4119 case GPOS_LB
: eResult
= WALLPAPER_BOTTOMLEFT
; break;
4120 case GPOS_MB
: eResult
= WALLPAPER_BOTTOM
; break;
4121 case GPOS_RB
: eResult
= WALLPAPER_BOTTOMRIGHT
; break;
4122 default: eResult
= WALLPAPER_NULL
;
4127 SvxBrushItem::SvxBrushItem( const CntWallpaperItem
& rItem
, sal_uInt16 _nWhich
) :
4128 SfxPoolItem( _nWhich
),
4129 pImpl( new SvxBrushItem_Impl( 0 ) ),
4132 bLoadAgain( sal_True
)
4134 aColor
= rItem
.GetColor();
4136 if (!rItem
.GetBitmapURL().isEmpty())
4138 pStrLink
= new String( rItem
.GetBitmapURL() );
4139 SetGraphicPos( WallpaperStyle2GraphicPos((WallpaperStyle
)rItem
.GetStyle() ) );
4144 #pragma optimize ( "", on )
4147 void SvxBrushItem::ApplyGraphicTransparency_Impl()
4149 DBG_ASSERT(pImpl
->pGraphicObject
, "no GraphicObject available" );
4150 if(pImpl
->pGraphicObject
)
4152 GraphicAttr
aAttr(pImpl
->pGraphicObject
->GetAttr());
4153 aAttr
.SetTransparency(lcl_PercentToTransparency(
4154 pImpl
->nGraphicTransparency
));
4155 pImpl
->pGraphicObject
->SetAttr(aAttr
);
4158 // class SvxFrameDirectionItem ----------------------------------------------
4160 SvxFrameDirectionItem::SvxFrameDirectionItem( SvxFrameDirection nValue
,
4161 sal_uInt16 _nWhich
)
4162 : SfxUInt16Item( _nWhich
, (sal_uInt16
)nValue
)
4166 SvxFrameDirectionItem::~SvxFrameDirectionItem()
4170 int SvxFrameDirectionItem::operator==( const SfxPoolItem
& rCmp
) const
4172 DBG_ASSERT( SfxPoolItem::operator==(rCmp
), "unequal types" );
4174 return GetValue() == ((SvxFrameDirectionItem
&)rCmp
).GetValue();
4177 SfxPoolItem
* SvxFrameDirectionItem::Clone( SfxItemPool
* ) const
4179 return new SvxFrameDirectionItem( *this );
4182 SfxPoolItem
* SvxFrameDirectionItem::Create( SvStream
& rStrm
, sal_uInt16
/*nVer*/ ) const
4186 return new SvxFrameDirectionItem( (SvxFrameDirection
)nValue
, Which() );
4189 SvStream
& SvxFrameDirectionItem::Store( SvStream
& rStrm
, sal_uInt16
/*nIVer*/ ) const
4191 sal_uInt16 nValue
= GetValue();
4196 sal_uInt16
SvxFrameDirectionItem::GetVersion( sal_uInt16 nFVer
) const
4198 return SOFFICE_FILEFORMAT_50
> nFVer
? USHRT_MAX
: 0;
4201 SfxItemPresentation
SvxFrameDirectionItem::GetPresentation(
4202 SfxItemPresentation ePres
,
4203 SfxMapUnit
/*eCoreUnit*/,
4204 SfxMapUnit
/*ePresUnit*/,
4205 XubString
& rText
, const IntlWrapper
*) const
4207 SfxItemPresentation eRet
= ePres
;
4210 case SFX_ITEM_PRESENTATION_NONE
:
4214 case SFX_ITEM_PRESENTATION_NAMELESS
:
4215 case SFX_ITEM_PRESENTATION_COMPLETE
:
4216 rText
= EE_RESSTR( RID_SVXITEMS_FRMDIR_BEGIN
+ GetValue() );
4220 eRet
= SFX_ITEM_PRESENTATION_NONE
;
4225 bool SvxFrameDirectionItem::PutValue( const com::sun::star::uno::Any
& rVal
,
4228 sal_Int16 nVal
= sal_Int16();
4229 sal_Bool bRet
= ( rVal
>>= nVal
);
4232 // translate WritingDirection2 constants into SvxFrameDirection
4235 case text::WritingMode2::LR_TB
:
4236 SetValue( FRMDIR_HORI_LEFT_TOP
);
4238 case text::WritingMode2::RL_TB
:
4239 SetValue( FRMDIR_HORI_RIGHT_TOP
);
4241 case text::WritingMode2::TB_RL
:
4242 SetValue( FRMDIR_VERT_TOP_RIGHT
);
4244 case text::WritingMode2::TB_LR
:
4245 SetValue( FRMDIR_VERT_TOP_LEFT
);
4247 case text::WritingMode2::PAGE
:
4248 SetValue( FRMDIR_ENVIRONMENT
);
4259 bool SvxFrameDirectionItem::QueryValue( com::sun::star::uno::Any
& rVal
,
4262 // translate SvxFrameDirection into WritingDirection2
4265 switch( GetValue() )
4267 case FRMDIR_HORI_LEFT_TOP
:
4268 nVal
= text::WritingMode2::LR_TB
;
4270 case FRMDIR_HORI_RIGHT_TOP
:
4271 nVal
= text::WritingMode2::RL_TB
;
4273 case FRMDIR_VERT_TOP_RIGHT
:
4274 nVal
= text::WritingMode2::TB_RL
;
4276 case FRMDIR_VERT_TOP_LEFT
:
4277 nVal
= text::WritingMode2::TB_LR
;
4279 case FRMDIR_ENVIRONMENT
:
4280 nVal
= text::WritingMode2::PAGE
;
4283 OSL_FAIL("Unknown SvxFrameDirection value!");
4288 // return value + error state
4296 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */