1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: frmitems.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
35 #include <com/sun/star/uno/Any.hxx>
36 #include <com/sun/star/script/XTypeConverter.hpp>
39 #include <comphelper/processfactory.hxx>
42 #include <goodies/grfmgr.hxx>
43 #include <tools/urlobj.hxx>
45 #ifndef _SFXDOCFILE_HXX //autogen
46 #include <sfx2/docfile.hxx>
48 #include <sfx2/objsh.hxx>
50 #include <basic/sbx.hxx>
51 #define GLOBALOVERFLOW3
53 #define _SVX_FRMITEMS_CXX
55 #include <svtools/memberid.hrc>
56 #include <svtools/wallitem.hxx>
57 #include <svtools/cntwall.hxx>
59 #include <rtl/ustring.hxx>
60 #include <rtl/ustrbuf.hxx>
63 #include <svx/svxids.hrc>
64 #include <svx/svxitems.hrc>
65 #include <svx/dialogs.hrc>
67 #include <svx/pbinitem.hxx>
68 #include <svx/sizeitem.hxx>
69 #include <svx/lrspitem.hxx>
70 #include <svx/ulspitem.hxx>
71 #include "prntitem.hxx"
72 #include "opaqitem.hxx"
73 #include "protitem.hxx"
74 #include <svx/shaditem.hxx>
75 #include <svx/boxitem.hxx>
76 #include <svx/brkitem.hxx>
77 #include <svx/keepitem.hxx>
78 #include "bolnitem.hxx"
79 #include <svx/brshitem.hxx>
80 //CHINA001 #include "backgrnd.hxx"
81 #include <svx/frmdiritem.hxx>
83 #include <svx/itemtype.hxx>
84 #include <svx/dialmgr.hxx>
86 #include <svx/unoprnms.hxx>
87 #include <com/sun/star/table/BorderLine.hpp>
88 #include <com/sun/star/table/CellVertJustify.hpp>
89 #include <com/sun/star/table/ShadowLocation.hpp>
90 #include <com/sun/star/table/TableBorder.hpp>
91 #include <com/sun/star/table/ShadowFormat.hpp>
92 #include <com/sun/star/table/CellRangeAddress.hpp>
93 #include <com/sun/star/table/CellContentType.hpp>
94 #include <com/sun/star/table/TableOrientation.hpp>
95 #include <com/sun/star/table/CellHoriJustify.hpp>
96 #include <com/sun/star/util/SortField.hpp>
97 #include <com/sun/star/util/SortFieldType.hpp>
98 #include <com/sun/star/table/CellOrientation.hpp>
99 #include <com/sun/star/table/CellAddress.hpp>
100 #include <com/sun/star/style/PageStyleLayout.hpp>
101 #include <com/sun/star/style/BreakType.hpp>
102 #include <com/sun/star/style/GraphicLocation.hpp>
103 #include <com/sun/star/awt/Rectangle.hpp>
104 #include <com/sun/star/awt/Selection.hpp>
105 #include <com/sun/star/awt/Size.hpp>
106 #include <com/sun/star/text/WritingMode2.hpp>
107 #include <com/sun/star/frame/status/UpperLowerMarginScale.hpp>
109 #include <comphelper/types.hxx>
110 #include <svx/unomid.hxx>
112 using namespace ::rtl
;
113 using namespace ::com::sun::star
;
116 // Konvertierung fuer UNO
117 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
118 #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
119 #define TWIP_TO_MM100_UNSIGNED(TWIP) ((((TWIP)*127L+36L)/72L))
120 #define MM100_TO_TWIP_UNSIGNED(MM100) ((((MM100)*72L+63L)/127L))
122 // STATIC DATA -----------------------------------------------------------
125 inline void SetValueProp( XubString
& rStr
, const sal_uInt16 nValue
,
126 const sal_uInt16 nProp
)
129 rStr
+= String::CreateFromInt32( nValue
);
131 ( rStr
+= String::CreateFromInt32( nProp
)) += sal_Unicode('%');
134 inline void SetValueProp( XubString
& rStr
, const short nValue
,
135 const sal_uInt16 nProp
)
138 rStr
+= String::CreateFromInt32( nValue
);
140 ( rStr
+= String::CreateFromInt32( nProp
)) += sal_Unicode('%');
143 // -----------------------------------------------------------------------
145 TYPEINIT1_FACTORY(SvxPaperBinItem
, SfxByteItem
, new SvxPaperBinItem(0));
146 TYPEINIT1_FACTORY(SvxSizeItem
, SfxPoolItem
, new SvxSizeItem(0));
147 TYPEINIT1_FACTORY(SvxLRSpaceItem
, SfxPoolItem
, new SvxLRSpaceItem(0));
148 TYPEINIT1_FACTORY(SvxULSpaceItem
, SfxPoolItem
, new SvxULSpaceItem(0));
149 TYPEINIT1_FACTORY(SvxPrintItem
, SfxBoolItem
, new SvxPrintItem(0));
150 TYPEINIT1_FACTORY(SvxOpaqueItem
, SfxBoolItem
, new SvxOpaqueItem(0));
151 TYPEINIT1_FACTORY(SvxProtectItem
, SfxPoolItem
, new SvxProtectItem(0));
152 TYPEINIT1_FACTORY(SvxBrushItem
, SfxPoolItem
, new SvxBrushItem(0));
153 TYPEINIT1_FACTORY(SvxShadowItem
, SfxPoolItem
, new SvxShadowItem(0));
154 TYPEINIT1_FACTORY(SvxBoxItem
, SfxPoolItem
, new SvxBoxItem(0));
155 TYPEINIT1_FACTORY(SvxBoxInfoItem
, SfxPoolItem
, new SvxBoxInfoItem(0));
156 TYPEINIT1_FACTORY(SvxFmtBreakItem
, SfxEnumItem
, new SvxFmtBreakItem(SVX_BREAK_NONE
, 0));
157 TYPEINIT1_FACTORY(SvxFmtKeepItem
, SfxBoolItem
, new SvxFmtKeepItem(sal_False
, 0));
158 TYPEINIT1_FACTORY(SvxLineItem
, SfxPoolItem
, new SvxLineItem(0));
159 TYPEINIT1_FACTORY(SvxFrameDirectionItem
, SfxUInt16Item
, new SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP
, 0));
162 // class SvxPaperBinItem ------------------------------------------------
164 SfxPoolItem
* SvxPaperBinItem::Clone( SfxItemPool
* ) const
166 return new SvxPaperBinItem( *this );
169 // -----------------------------------------------------------------------
171 SvStream
& SvxPaperBinItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
177 // -----------------------------------------------------------------------
179 SfxPoolItem
* SvxPaperBinItem::Create( SvStream
& rStrm
, sal_uInt16
) const
183 return new SvxPaperBinItem( Which(), nBin
);
186 // -----------------------------------------------------------------------
188 SfxItemPresentation
SvxPaperBinItem::GetPresentation
190 SfxItemPresentation ePres
,
191 SfxMapUnit
/*eCoreUnit*/,
192 SfxMapUnit
/*ePresUnit*/,
193 XubString
& rText
, const IntlWrapper
*
199 case SFX_ITEM_PRESENTATION_NONE
:
201 return SFX_ITEM_PRESENTATION_NONE
;
203 case SFX_ITEM_PRESENTATION_NAMELESS
:
204 rText
= String::CreateFromInt32( GetValue() );
205 return SFX_ITEM_PRESENTATION_NAMELESS
;
207 case SFX_ITEM_PRESENTATION_COMPLETE
:
209 BYTE nValue
= GetValue();
211 if ( PAPERBIN_PRINTER_SETTINGS
== nValue
)
212 rText
= SVX_RESSTR(RID_SVXSTR_PAPERBIN_SETTINGS
);
215 rText
= SVX_RESSTR(RID_SVXSTR_PAPERBIN
);
216 rText
+= sal_Unicode(' ');
217 rText
+= String::CreateFromInt32( nValue
);
219 return SFX_ITEM_PRESENTATION_COMPLETE
;
222 default: ;//prevent warning
225 return SFX_ITEM_PRESENTATION_NONE
;
228 // class SvxSizeItem -----------------------------------------------------
230 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId
, const Size
& rSize
) :
238 // -----------------------------------------------------------------------
239 sal_Bool
SvxSizeItem::QueryValue( uno::Any
& rVal
, BYTE nMemberId
) const
241 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
242 nMemberId
&= ~CONVERT_TWIPS
;
244 awt::Size
aTmp(aSize
.Width(), aSize
.Height());
247 aTmp
.Height
= TWIP_TO_MM100(aTmp
.Height
);
248 aTmp
.Width
= TWIP_TO_MM100(aTmp
.Width
);
253 case MID_SIZE_SIZE
: rVal
<<= aTmp
; break;
254 case MID_SIZE_WIDTH
: rVal
<<= aTmp
.Width
; break;
255 case MID_SIZE_HEIGHT
: rVal
<<= aTmp
.Height
; break;
256 default: DBG_ERROR("Wrong MemberId!"); return sal_False
;
261 // -----------------------------------------------------------------------
262 sal_Bool
SvxSizeItem::PutValue( const uno::Any
& rVal
, BYTE nMemberId
)
264 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
265 nMemberId
&= ~CONVERT_TWIPS
;
276 aTmp
.Height
= MM100_TO_TWIP(aTmp
.Height
);
277 aTmp
.Width
= MM100_TO_TWIP(aTmp
.Width
);
279 aSize
= Size( aTmp
.Width
, aTmp
.Height
);
290 if(!(rVal
>>= nVal
))
293 aSize
.Width() = bConvert
? MM100_TO_TWIP(nVal
) : nVal
;
296 case MID_SIZE_HEIGHT
:
302 aSize
.Height() = bConvert
? MM100_TO_TWIP(nVal
) : nVal
;
305 default: DBG_ERROR("Wrong MemberId!");
311 // -----------------------------------------------------------------------
313 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId
) :
319 // -----------------------------------------------------------------------
321 int SvxSizeItem::operator==( const SfxPoolItem
& rAttr
) const
323 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
325 return ( aSize
== ( (SvxSizeItem
&)rAttr
).GetSize() );
328 // -----------------------------------------------------------------------
330 SfxPoolItem
* SvxSizeItem::Clone( SfxItemPool
* ) const
332 return new SvxSizeItem( *this );
335 //------------------------------------------------------------------------
337 SfxItemPresentation
SvxSizeItem::GetPresentation
339 SfxItemPresentation ePres
,
340 SfxMapUnit eCoreUnit
,
341 SfxMapUnit ePresUnit
,
342 XubString
& rText
, const IntlWrapper
*pIntl
348 case SFX_ITEM_PRESENTATION_NONE
:
350 return SFX_ITEM_PRESENTATION_NONE
;
352 case SFX_ITEM_PRESENTATION_NAMELESS
:
353 rText
= GetMetricText( aSize
.Width(), eCoreUnit
, ePresUnit
, pIntl
);
355 rText
+= GetMetricText( aSize
.Height(), eCoreUnit
, ePresUnit
, pIntl
);
356 return SFX_ITEM_PRESENTATION_NAMELESS
;
358 case SFX_ITEM_PRESENTATION_COMPLETE
:
359 rText
= SVX_RESSTR(RID_SVXITEMS_SIZE_WIDTH
);
360 rText
+= GetMetricText( aSize
.Width(), eCoreUnit
, ePresUnit
, pIntl
);
361 rText
+= SVX_RESSTR(GetMetricId(ePresUnit
));
363 rText
+= SVX_RESSTR(RID_SVXITEMS_SIZE_HEIGHT
);
364 rText
+= GetMetricText( aSize
.Height(), eCoreUnit
, ePresUnit
, pIntl
);
365 rText
+= SVX_RESSTR(GetMetricId(ePresUnit
));
366 return SFX_ITEM_PRESENTATION_COMPLETE
;
368 default: ;//prevent warning
372 return SFX_ITEM_PRESENTATION_NONE
;
375 // -----------------------------------------------------------------------
377 SvStream
& SvxSizeItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
379 rStrm
<< aSize
.Width();
380 rStrm
<< aSize
.Height();
384 // -----------------------------------------------------------------------
386 int SvxSizeItem::ScaleMetrics( long nMult
, long nDiv
)
388 aSize
.Width() = Scale( aSize
.Width(), nMult
, nDiv
);
389 aSize
.Height() = Scale( aSize
.Height(), nMult
, nDiv
);
393 // -----------------------------------------------------------------------
395 int SvxSizeItem::HasMetrics() const
400 // -----------------------------------------------------------------------
403 SfxPoolItem
* SvxSizeItem::Create( SvStream
& rStrm
, sal_uInt16
) const
405 long nWidth
, nHeight
;
406 rStrm
>> nWidth
>> nHeight
;
408 SvxSizeItem
* pAttr
= new SvxSizeItem( Which() );
409 pAttr
->SetSize(Size(nWidth
, nHeight
));
414 // class SvxLRSpaceItem --------------------------------------------------
416 SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId
) :
420 nFirstLineOfst ( 0 ),
424 nPropFirstLineOfst( 100 ),
425 nPropLeftMargin( 100 ),
426 nPropRightMargin( 100 ),
431 // -----------------------------------------------------------------------
433 SvxLRSpaceItem::SvxLRSpaceItem( const long nLeft
, const long nRight
,
434 const long nTLeft
, const short nOfset
,
435 const sal_uInt16 nId
) :
439 nFirstLineOfst ( nOfset
),
441 nLeftMargin ( nLeft
),
442 nRightMargin ( nRight
),
443 nPropFirstLineOfst( 100 ),
444 nPropLeftMargin( 100 ),
445 nPropRightMargin( 100 ),
450 // -----------------------------------------------------------------------
451 sal_Bool
SvxLRSpaceItem::QueryValue( uno::Any
& rVal
, BYTE nMemberId
) const
453 sal_Bool bRet
= sal_True
;
454 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
455 nMemberId
&= ~CONVERT_TWIPS
;
458 // jetzt alles signed
460 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100(nLeftMargin
) : nLeftMargin
);
463 case MID_TXT_LMARGIN
:
464 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100(nTxtLeft
) : nTxtLeft
);
467 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100(nRightMargin
) : nRightMargin
);
469 case MID_L_REL_MARGIN
:
470 rVal
<<= (sal_Int16
)nPropLeftMargin
;
472 case MID_R_REL_MARGIN
:
473 rVal
<<= (sal_Int16
)nPropRightMargin
;
476 case MID_FIRST_LINE_INDENT
:
477 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100(nFirstLineOfst
) : nFirstLineOfst
);
480 case MID_FIRST_LINE_REL_INDENT
:
481 rVal
<<= (sal_Int16
)(nPropFirstLineOfst
);
485 rVal
= Bool2Any(IsAutoFirst());
490 DBG_ERROR("unknown MemberId");
495 // -----------------------------------------------------------------------
496 sal_Bool
SvxLRSpaceItem::PutValue( const uno::Any
& rVal
, BYTE nMemberId
)
498 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
499 nMemberId
&= ~CONVERT_TWIPS
;
501 if( nMemberId
!= MID_FIRST_AUTO
&&
502 nMemberId
!= MID_L_REL_MARGIN
&& nMemberId
!= MID_R_REL_MARGIN
)
509 SetLeft((sal_Int32
)bConvert
? MM100_TO_TWIP(nVal
) : nVal
);
512 case MID_TXT_LMARGIN
:
513 SetTxtLeft((sal_Int32
)bConvert
? MM100_TO_TWIP(nVal
) : nVal
);
517 SetRight((sal_Int32
) bConvert
? MM100_TO_TWIP(nVal
) : nVal
);
519 case MID_L_REL_MARGIN
:
520 case MID_R_REL_MARGIN
:
523 if((rVal
>>= nRel
) && nRel
>= 0 && nRel
< USHRT_MAX
)
525 if(MID_L_REL_MARGIN
== nMemberId
)
526 nPropLeftMargin
= (USHORT
)nRel
;
528 nPropRightMargin
= (USHORT
)nRel
;
534 case MID_FIRST_LINE_INDENT
:
535 SetTxtFirstLineOfst((short)(bConvert
? MM100_TO_TWIP(nVal
) : nVal
));
538 case MID_FIRST_LINE_REL_INDENT
:
539 SetPropTxtFirstLineOfst ( (USHORT
)nVal
);
543 SetAutoFirst( Any2Bool(rVal
) );
547 DBG_ERROR("unknown MemberId");
553 // -----------------------------------------------------------------------
555 // nLeftMargin und nTxtLeft anpassen.
557 void SvxLRSpaceItem::AdjustLeft()
559 if ( 0 > nFirstLineOfst
)
560 nLeftMargin
= nTxtLeft
+ nFirstLineOfst
;
562 nLeftMargin
= nTxtLeft
;
565 // -----------------------------------------------------------------------
567 int SvxLRSpaceItem::operator==( const SfxPoolItem
& rAttr
) const
569 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
572 nLeftMargin
== ((SvxLRSpaceItem
&)rAttr
).GetLeft() &&
573 nRightMargin
== ((SvxLRSpaceItem
&)rAttr
).GetRight() &&
574 nFirstLineOfst
== ((SvxLRSpaceItem
&)rAttr
).GetTxtFirstLineOfst() &&
575 nPropLeftMargin
== ((SvxLRSpaceItem
&)rAttr
).GetPropLeft() &&
576 nPropRightMargin
== ((SvxLRSpaceItem
&)rAttr
).GetPropRight() &&
577 nPropFirstLineOfst
== ((SvxLRSpaceItem
&)rAttr
).GetPropTxtFirstLineOfst() &&
578 bAutoFirst
== ((SvxLRSpaceItem
&)rAttr
).IsAutoFirst() );
581 // -----------------------------------------------------------------------
583 SfxPoolItem
* SvxLRSpaceItem::Clone( SfxItemPool
* ) const
585 return new SvxLRSpaceItem( *this );
588 //------------------------------------------------------------------------
590 SfxItemPresentation
SvxLRSpaceItem::GetPresentation
592 SfxItemPresentation ePres
,
593 SfxMapUnit eCoreUnit
,
594 SfxMapUnit ePresUnit
,
595 XubString
& rText
, const IntlWrapper
* pIntl
601 case SFX_ITEM_PRESENTATION_NONE
:
603 return SFX_ITEM_PRESENTATION_NONE
;
604 case SFX_ITEM_PRESENTATION_NAMELESS
:
606 if ( 100 != nPropLeftMargin
)
607 ( rText
= String::CreateFromInt32( nPropLeftMargin
)) += sal_Unicode('%');
609 rText
= GetMetricText( (long)nLeftMargin
,
610 eCoreUnit
, ePresUnit
, pIntl
);
612 if ( 100 != nPropFirstLineOfst
)
613 ( rText
+= String::CreateFromInt32( nPropFirstLineOfst
)) += sal_Unicode('%');
615 rText
+= GetMetricText( (long)nFirstLineOfst
,
616 eCoreUnit
, ePresUnit
, pIntl
);
618 if ( 100 != nRightMargin
)
619 ( rText
+= String::CreateFromInt32( nRightMargin
)) += sal_Unicode('%');
621 rText
+= GetMetricText( (long)nRightMargin
,
622 eCoreUnit
, ePresUnit
, pIntl
);
623 return SFX_ITEM_PRESENTATION_NAMELESS
;
625 case SFX_ITEM_PRESENTATION_COMPLETE
:
627 rText
= SVX_RESSTR(RID_SVXITEMS_LRSPACE_LEFT
);
628 if ( 100 != nPropLeftMargin
)
629 ( rText
+= String::CreateFromInt32( nPropLeftMargin
)) += sal_Unicode('%');
632 rText
+= GetMetricText( (long)nLeftMargin
,
633 eCoreUnit
, ePresUnit
, pIntl
);
634 rText
+= SVX_RESSTR(GetMetricId(ePresUnit
));
637 if ( 100 != nPropFirstLineOfst
|| nFirstLineOfst
)
639 rText
+= SVX_RESSTR(RID_SVXITEMS_LRSPACE_FLINE
);
640 if ( 100 != nPropFirstLineOfst
)
641 ( rText
+= String::CreateFromInt32( nPropFirstLineOfst
))
645 rText
+= GetMetricText( (long)nFirstLineOfst
,
646 eCoreUnit
, ePresUnit
, pIntl
);
647 rText
+= SVX_RESSTR(GetMetricId(ePresUnit
));
651 rText
+= SVX_RESSTR(RID_SVXITEMS_LRSPACE_RIGHT
);
652 if ( 100 != nPropRightMargin
)
653 ( rText
+= String::CreateFromInt32( nPropRightMargin
)) += sal_Unicode('%');
656 rText
+= GetMetricText( (long)nRightMargin
,
657 eCoreUnit
, ePresUnit
, pIntl
);
658 rText
+= SVX_RESSTR(GetMetricId(ePresUnit
));
660 return SFX_ITEM_PRESENTATION_COMPLETE
;
662 default: ;//prevent warning
665 return SFX_ITEM_PRESENTATION_NONE
;
668 // -----------------------------------------------------------------------
670 // MT: BulletFI: Vor 501 wurde im Outliner das Bullet nicht auf der Position des
671 // FI positioniert, deshalb muss in aelteren Dokumenten der FI auf 0 stehen.
673 #define BULLETLR_MARKER 0x599401FE
675 SvStream
& SvxLRSpaceItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
677 short nSaveFI
= nFirstLineOfst
;
678 ((SvxLRSpaceItem
*)this)->SetTxtFirstLineOfst( 0 ); // nLeftMargin wird mitmanipuliert, siehe Create()
680 sal_uInt16 nMargin
= 0;
681 if( nLeftMargin
> 0 )
682 nMargin
= sal_uInt16( nLeftMargin
);
684 rStrm
<< nPropLeftMargin
;
685 if( nRightMargin
> 0 )
686 nMargin
= sal_uInt16( nRightMargin
);
690 rStrm
<< nPropRightMargin
;
691 rStrm
<< nFirstLineOfst
;
692 rStrm
<< nPropFirstLineOfst
;
694 nMargin
= sal_uInt16( nTxtLeft
);
698 if( nItemVersion
>= LRSPACE_AUTOFIRST_VERSION
)
700 sal_Int8 nAutoFirst
= bAutoFirst
? 1 : 0;
701 if( nItemVersion
>= LRSPACE_NEGATIVE_VERSION
&&
702 ( nLeftMargin
< 0 || nRightMargin
< 0 || nTxtLeft
< 0 ) )
706 // Ab 6.0 keine Magicnumber schreiben...
707 DBG_ASSERT( rStrm
.GetVersion() <= SOFFICE_FILEFORMAT_50
, "MT: Fileformat SvxLRSpaceItem aendern!" );
708 rStrm
<< (sal_uInt32
) BULLETLR_MARKER
;
711 if( 0x80 & nAutoFirst
)
713 rStrm
<< nLeftMargin
;
714 rStrm
<< nRightMargin
;
718 ((SvxLRSpaceItem
*)this)->SetTxtFirstLineOfst( nSaveFI
);
723 // -----------------------------------------------------------------------
725 SfxPoolItem
* SvxLRSpaceItem::Create( SvStream
& rStrm
, sal_uInt16 nVersion
) const
727 sal_uInt16 left
, prpleft
, right
, prpright
, prpfirstline
, txtleft
;
729 sal_Int8 autofirst
= 0;
731 if ( nVersion
>= LRSPACE_AUTOFIRST_VERSION
)
733 rStrm
>> left
>> prpleft
>> right
>> prpright
>> firstline
>>
734 prpfirstline
>> txtleft
>> autofirst
;
736 sal_uInt32 nPos
= rStrm
.Tell();
739 if ( nMarker
== BULLETLR_MARKER
)
743 left
= left
+ static_cast<sal_uInt16
>(firstline
); // s.u.: txtleft = ...
748 else if ( nVersion
== LRSPACE_TXTLEFT_VERSION
)
750 rStrm
>> left
>> prpleft
>> right
>> prpright
>> firstline
>>
751 prpfirstline
>> txtleft
;
753 else if ( nVersion
== LRSPACE_16_VERSION
)
755 rStrm
>> left
>> prpleft
>> right
>> prpright
>> firstline
>>
760 sal_Int8 nL
, nR
, nFL
;
761 rStrm
>> left
>> nL
>> right
>> nR
>> firstline
>> nFL
;
762 prpleft
= (sal_uInt16
)nL
;
763 prpright
= (sal_uInt16
)nR
;
764 prpfirstline
= (sal_uInt16
)nFL
;
767 txtleft
= firstline
>= 0 ? left
: left
- firstline
;
768 SvxLRSpaceItem
* pAttr
= new SvxLRSpaceItem( Which() );
770 pAttr
->nLeftMargin
= left
;
771 pAttr
->nPropLeftMargin
= prpleft
;
772 pAttr
->nRightMargin
= right
;
773 pAttr
->nPropRightMargin
= prpright
;
774 pAttr
->nFirstLineOfst
= firstline
;
775 pAttr
->nPropFirstLineOfst
= prpfirstline
;
776 pAttr
->nTxtLeft
= txtleft
;
777 pAttr
->bAutoFirst
= autofirst
& 0x01;
778 if( nVersion
>= LRSPACE_NEGATIVE_VERSION
&& ( autofirst
& 0x80 ) )
782 pAttr
->nLeftMargin
= nMargin
;
783 pAttr
->nTxtLeft
= firstline
>= 0 ? nMargin
: nMargin
- firstline
;
785 pAttr
->nRightMargin
= nMargin
;
790 // -----------------------------------------------------------------------
792 sal_uInt16
SvxLRSpaceItem::GetVersion( sal_uInt16 nFileVersion
) const
794 return (nFileVersion
== SOFFICE_FILEFORMAT_31
)
795 ? LRSPACE_TXTLEFT_VERSION
796 : LRSPACE_NEGATIVE_VERSION
;
799 // -----------------------------------------------------------------------
801 int SvxLRSpaceItem::ScaleMetrics( long nMult
, long nDiv
)
803 nFirstLineOfst
= (short)Scale( nFirstLineOfst
, nMult
, nDiv
);
804 nTxtLeft
= Scale( nTxtLeft
, nMult
, nDiv
);
805 nLeftMargin
= Scale( nLeftMargin
, nMult
, nDiv
);
806 nRightMargin
= Scale( nRightMargin
, nMult
, nDiv
);
810 // -----------------------------------------------------------------------
812 int SvxLRSpaceItem::HasMetrics() const
817 // class SvxULSpaceItem --------------------------------------------------
819 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nId
) :
830 // -----------------------------------------------------------------------
832 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nUp
, const sal_uInt16 nLow
,
833 const sal_uInt16 nId
) :
844 // -----------------------------------------------------------------------
845 sal_Bool
SvxULSpaceItem::QueryValue( uno::Any
& rVal
, BYTE nMemberId
) const
847 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
848 nMemberId
&= ~CONVERT_TWIPS
;
851 // jetzt alles signed
854 ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale
;
855 aUpperLowerMarginScale
.Upper
= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nUpper
) : nUpper
);
856 aUpperLowerMarginScale
.Lower
= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nLower
) : nPropUpper
);
857 aUpperLowerMarginScale
.ScaleUpper
= (sal_Int16
)nPropUpper
;
858 aUpperLowerMarginScale
.ScaleLower
= (sal_Int16
)nPropLower
;
859 rVal
<<= aUpperLowerMarginScale
;
862 case MID_UP_MARGIN
: rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nUpper
) : nUpper
); break;
863 case MID_LO_MARGIN
: rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nLower
) : nLower
); break;
864 case MID_UP_REL_MARGIN
: rVal
<<= (sal_Int16
) nPropUpper
; break;
865 case MID_LO_REL_MARGIN
: rVal
<<= (sal_Int16
) nPropLower
; break;
870 // -----------------------------------------------------------------------
871 sal_Bool
SvxULSpaceItem::PutValue( const uno::Any
& rVal
, BYTE nMemberId
)
873 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
874 nMemberId
&= ~CONVERT_TWIPS
;
880 ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale
;
881 if ( !(rVal
>>= aUpperLowerMarginScale
))
884 SetUpper((sal_uInt16
)(bConvert
? MM100_TO_TWIP( aUpperLowerMarginScale
.Upper
) : aUpperLowerMarginScale
.Upper
));
885 SetLower((sal_uInt16
)(bConvert
? MM100_TO_TWIP( aUpperLowerMarginScale
.Lower
) : aUpperLowerMarginScale
.Lower
));
886 if( aUpperLowerMarginScale
.ScaleUpper
> 1 )
887 nPropUpper
= aUpperLowerMarginScale
.ScaleUpper
;
888 if( aUpperLowerMarginScale
.ScaleLower
> 1 )
889 nPropUpper
= aUpperLowerMarginScale
.ScaleLower
;
894 if(!(rVal
>>= nVal
) || nVal
< 0)
896 SetUpper((USHORT
)(bConvert
? MM100_TO_TWIP(nVal
) : nVal
));
899 if(!(rVal
>>= nVal
) || nVal
< 0)
901 SetLower((USHORT
)(bConvert
? MM100_TO_TWIP(nVal
) : nVal
));
903 case MID_UP_REL_MARGIN
:
904 case MID_LO_REL_MARGIN
:
907 if((rVal
>>= nRel
) && nRel
> 1 )
909 if(MID_UP_REL_MARGIN
== nMemberId
)
910 nPropUpper
= (USHORT
)nRel
;
912 nPropLower
= (USHORT
)nRel
;
921 DBG_ERROR("unknown MemberId");
927 // -----------------------------------------------------------------------
929 int SvxULSpaceItem::operator==( const SfxPoolItem
& rAttr
) const
931 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
933 return ( nUpper
== ( (SvxULSpaceItem
&)rAttr
).nUpper
&&
934 nLower
== ( (SvxULSpaceItem
&)rAttr
).nLower
&&
935 nPropUpper
== ( (SvxULSpaceItem
&)rAttr
).nPropUpper
&&
936 nPropLower
== ( (SvxULSpaceItem
&)rAttr
).nPropLower
);
939 // -----------------------------------------------------------------------
941 SfxPoolItem
* SvxULSpaceItem::Clone( SfxItemPool
* ) const
943 return new SvxULSpaceItem( *this );
946 //------------------------------------------------------------------------
948 SfxItemPresentation
SvxULSpaceItem::GetPresentation
950 SfxItemPresentation ePres
,
951 SfxMapUnit eCoreUnit
,
952 SfxMapUnit ePresUnit
,
953 XubString
& rText
, const IntlWrapper
*pIntl
959 case SFX_ITEM_PRESENTATION_NONE
:
961 return SFX_ITEM_PRESENTATION_NONE
;
962 case SFX_ITEM_PRESENTATION_NAMELESS
:
964 if ( 100 != nPropUpper
)
965 ( rText
= String::CreateFromInt32( nPropUpper
)) += sal_Unicode('%');
967 rText
= GetMetricText( (long)nUpper
, eCoreUnit
, ePresUnit
, pIntl
);
969 if ( 100 != nPropLower
)
970 ( rText
+= String::CreateFromInt32( nPropLower
)) += sal_Unicode('%');
972 rText
+= GetMetricText( (long)nLower
, eCoreUnit
, ePresUnit
, pIntl
);
973 return SFX_ITEM_PRESENTATION_NAMELESS
;
975 case SFX_ITEM_PRESENTATION_COMPLETE
:
977 rText
= SVX_RESSTR(RID_SVXITEMS_ULSPACE_UPPER
);
978 if ( 100 != nPropUpper
)
979 ( rText
+= String::CreateFromInt32( nPropUpper
)) += sal_Unicode('%');
982 rText
+= GetMetricText( (long)nUpper
, eCoreUnit
, ePresUnit
, pIntl
);
983 rText
+= SVX_RESSTR(GetMetricId(ePresUnit
));
986 rText
+= SVX_RESSTR(RID_SVXITEMS_ULSPACE_LOWER
);
987 if ( 100 != nPropLower
)
988 ( rText
+= String::CreateFromInt32( nPropLower
)) += sal_Unicode('%');
991 rText
+= GetMetricText( (long)nLower
, eCoreUnit
, ePresUnit
, pIntl
);
992 rText
+= SVX_RESSTR(GetMetricId(ePresUnit
));
994 return SFX_ITEM_PRESENTATION_COMPLETE
;
996 default: ;//prevent warning
999 return SFX_ITEM_PRESENTATION_NONE
;
1002 // -----------------------------------------------------------------------
1004 SvStream
& SvxULSpaceItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1013 // -----------------------------------------------------------------------
1015 SfxPoolItem
* SvxULSpaceItem::Create( SvStream
& rStrm
, sal_uInt16 nVersion
) const
1017 sal_uInt16 upper
, lower
, nPL
= 0, nPU
= 0;
1019 if ( nVersion
== ULSPACE_16_VERSION
)
1020 rStrm
>> upper
>> nPU
>> lower
>> nPL
;
1024 rStrm
>> upper
>> nU
>> lower
>> nL
;
1025 nPL
= (sal_uInt16
)nL
;
1026 nPU
= (sal_uInt16
)nU
;
1029 SvxULSpaceItem
* pAttr
= new SvxULSpaceItem( Which() );
1030 pAttr
->SetUpperValue( upper
);
1031 pAttr
->SetLowerValue( lower
);
1032 pAttr
->SetPropUpper( nPU
);
1033 pAttr
->SetPropLower( nPL
);
1037 // -----------------------------------------------------------------------
1039 sal_uInt16
SvxULSpaceItem::GetVersion( sal_uInt16
/*nFileVersion*/ ) const
1041 return ULSPACE_16_VERSION
;
1044 // -----------------------------------------------------------------------
1046 int SvxULSpaceItem::ScaleMetrics( long nMult
, long nDiv
)
1048 nUpper
= (sal_uInt16
)Scale( nUpper
, nMult
, nDiv
);
1049 nLower
= (sal_uInt16
)Scale( nLower
, nMult
, nDiv
);
1053 // -----------------------------------------------------------------------
1055 int SvxULSpaceItem::HasMetrics() const
1061 // class SvxPrintItem ----------------------------------------------------
1063 SfxPoolItem
* SvxPrintItem::Clone( SfxItemPool
* ) const
1065 return new SvxPrintItem( *this );
1068 // -----------------------------------------------------------------------
1070 SvStream
& SvxPrintItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1072 rStrm
<< (sal_Int8
)GetValue();
1076 // -----------------------------------------------------------------------
1078 SfxPoolItem
* SvxPrintItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1082 return new SvxPrintItem( Which(), sal_Bool( bIsPrint
!= 0 ) );
1085 //------------------------------------------------------------------------
1087 SfxItemPresentation
SvxPrintItem::GetPresentation
1089 SfxItemPresentation ePres
,
1090 SfxMapUnit
/*eCoreUnit*/,
1091 SfxMapUnit
/*ePresUnit*/,
1092 XubString
& rText
, const IntlWrapper
*
1098 case SFX_ITEM_PRESENTATION_NONE
:
1102 case SFX_ITEM_PRESENTATION_NAMELESS
:
1103 case SFX_ITEM_PRESENTATION_COMPLETE
:
1105 sal_uInt16 nId
= RID_SVXITEMS_PRINT_FALSE
;
1108 nId
= RID_SVXITEMS_PRINT_TRUE
;
1109 rText
= SVX_RESSTR(nId
);
1112 default: ;//prevent warning
1114 #endif // !SVX_LIGHT
1115 return SFX_ITEM_PRESENTATION_NONE
;
1118 // class SvxOpaqueItem ---------------------------------------------------
1120 SfxPoolItem
* SvxOpaqueItem::Clone( SfxItemPool
* ) const
1122 return new SvxOpaqueItem( *this );
1125 // -----------------------------------------------------------------------
1127 SvStream
& SvxOpaqueItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1129 rStrm
<< (sal_Int8
)GetValue();
1133 // -----------------------------------------------------------------------
1135 SfxPoolItem
* SvxOpaqueItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1139 return new SvxOpaqueItem( Which(), sal_Bool( bIsOpaque
!= 0 ) );
1142 //------------------------------------------------------------------------
1144 SfxItemPresentation
SvxOpaqueItem::GetPresentation
1146 SfxItemPresentation ePres
,
1147 SfxMapUnit
/*eCoreUnit*/,
1148 SfxMapUnit
/*ePresUnit*/,
1149 XubString
& rText
, const IntlWrapper
*
1155 case SFX_ITEM_PRESENTATION_NONE
:
1159 case SFX_ITEM_PRESENTATION_NAMELESS
:
1160 case SFX_ITEM_PRESENTATION_COMPLETE
:
1162 sal_uInt16 nId
= RID_SVXITEMS_OPAQUE_FALSE
;
1165 nId
= RID_SVXITEMS_OPAQUE_TRUE
;
1166 rText
= SVX_RESSTR(nId
);
1169 default: ;//prevent warning
1171 #endif // !SVX_LIGHT
1172 return SFX_ITEM_PRESENTATION_NONE
;
1175 // class SvxProtectItem --------------------------------------------------
1177 int SvxProtectItem::operator==( const SfxPoolItem
& rAttr
) const
1179 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1181 return ( bCntnt
== ( (SvxProtectItem
&)rAttr
).bCntnt
&&
1182 bSize
== ( (SvxProtectItem
&)rAttr
).bSize
&&
1183 bPos
== ( (SvxProtectItem
&)rAttr
).bPos
);
1186 /*-----------------16.03.98 12:42-------------------
1187 --------------------------------------------------*/
1188 sal_Bool
SvxProtectItem::QueryValue( uno::Any
& rVal
, BYTE nMemberId
) const
1190 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1191 nMemberId
&= ~CONVERT_TWIPS
;
1195 case MID_PROTECT_CONTENT
: bValue
= bCntnt
; break;
1196 case MID_PROTECT_SIZE
: bValue
= bSize
; break;
1197 case MID_PROTECT_POSITION
: bValue
= bPos
; break;
1199 DBG_ERROR("falsche MemberId");
1203 rVal
= Bool2Any( bValue
);
1206 /*-----------------16.03.98 12:42-------------------
1208 --------------------------------------------------*/
1209 sal_Bool
SvxProtectItem::PutValue( const uno::Any
& rVal
, BYTE nMemberId
)
1211 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1212 nMemberId
&= ~CONVERT_TWIPS
;
1213 sal_Bool
bVal( Any2Bool(rVal
) );
1216 case MID_PROTECT_CONTENT
: bCntnt
= bVal
; break;
1217 case MID_PROTECT_SIZE
: bSize
= bVal
; break;
1218 case MID_PROTECT_POSITION
: bPos
= bVal
; break;
1220 DBG_ERROR("falsche MemberId");
1226 // -----------------------------------------------------------------------
1228 SfxPoolItem
* SvxProtectItem::Clone( SfxItemPool
* ) const
1230 return new SvxProtectItem( *this );
1233 //------------------------------------------------------------------------
1235 SfxItemPresentation
SvxProtectItem::GetPresentation
1237 SfxItemPresentation ePres
,
1238 SfxMapUnit
/*eCoreUnit*/,
1239 SfxMapUnit
/*ePresUnit*/,
1240 XubString
& rText
, const IntlWrapper
*
1246 case SFX_ITEM_PRESENTATION_NONE
:
1250 case SFX_ITEM_PRESENTATION_NAMELESS
:
1251 case SFX_ITEM_PRESENTATION_COMPLETE
:
1253 sal_uInt16 nId
= RID_SVXITEMS_PROT_CONTENT_FALSE
;
1256 nId
= RID_SVXITEMS_PROT_CONTENT_TRUE
;
1257 rText
= SVX_RESSTR(nId
);
1259 nId
= RID_SVXITEMS_PROT_SIZE_FALSE
;
1262 nId
= RID_SVXITEMS_PROT_SIZE_TRUE
;
1263 rText
+= SVX_RESSTR(nId
);
1265 nId
= RID_SVXITEMS_PROT_POS_FALSE
;
1268 nId
= RID_SVXITEMS_PROT_POS_TRUE
;
1269 rText
+= SVX_RESSTR(nId
);
1272 default: ;//prevent warning
1274 #endif // !SVX_LIGHT
1275 return SFX_ITEM_PRESENTATION_NONE
;
1278 // -----------------------------------------------------------------------
1280 SvStream
& SvxProtectItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
1283 if( IsPosProtected() ) cProt
|= 0x01;
1284 if( IsSizeProtected() ) cProt
|= 0x02;
1285 if( IsCntntProtected() ) cProt
|= 0x04;
1286 rStrm
<< (sal_Int8
) cProt
;
1290 // -----------------------------------------------------------------------
1292 SfxPoolItem
* SvxProtectItem::Create( SvStream
& rStrm
, sal_uInt16
) const
1296 SvxProtectItem
* pAttr
= new SvxProtectItem( Which() );
1297 pAttr
->SetPosProtect( sal_Bool( ( cFlags
& 0x01 ) != 0 ) );
1298 pAttr
->SetSizeProtect( sal_Bool( ( cFlags
& 0x02 ) != 0 ) );
1299 pAttr
->SetCntntProtect( sal_Bool( ( cFlags
& 0x04 ) != 0 ) );
1303 // class SvxShadowItem ---------------------------------------------------
1305 SvxShadowItem::SvxShadowItem( const USHORT nId
,
1306 const Color
*pColor
, const USHORT nW
,
1307 const SvxShadowLocation eLoc
) :
1308 SfxEnumItemInterface( nId
),
1309 aShadowColor(COL_GRAY
),
1314 aShadowColor
= *pColor
;
1317 // -----------------------------------------------------------------------
1318 sal_Bool
SvxShadowItem::QueryValue( uno::Any
& rVal
, BYTE nMemberId
) const
1320 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1321 nMemberId
&= ~CONVERT_TWIPS
;
1323 table::ShadowFormat aShadow
;
1324 table::ShadowLocation eSet
= table::ShadowLocation_NONE
;
1327 case SVX_SHADOW_TOPLEFT
: eSet
= table::ShadowLocation_TOP_LEFT
; break;
1328 case SVX_SHADOW_TOPRIGHT
: eSet
= table::ShadowLocation_TOP_RIGHT
; break;
1329 case SVX_SHADOW_BOTTOMLEFT
: eSet
= table::ShadowLocation_BOTTOM_LEFT
; break;
1330 case SVX_SHADOW_BOTTOMRIGHT
: eSet
= table::ShadowLocation_BOTTOM_RIGHT
; break;
1331 default: ;//prevent warning
1333 aShadow
.Location
= eSet
;
1334 aShadow
.ShadowWidth
= bConvert
? TWIP_TO_MM100_UNSIGNED(nWidth
) : nWidth
;
1335 aShadow
.IsTransparent
= aShadowColor
.GetTransparency() > 0;
1336 aShadow
.Color
= aShadowColor
.GetRGBColor();
1338 switch ( nMemberId
)
1340 case MID_LOCATION
: rVal
<<= aShadow
.Location
; break;
1341 case MID_WIDTH
: rVal
<<= aShadow
.ShadowWidth
; break;
1342 case MID_TRANSPARENT
: rVal
<<= aShadow
.IsTransparent
; break;
1343 case MID_BG_COLOR
: rVal
<<= aShadow
.Color
; break;
1344 case 0: rVal
<<= aShadow
; break;
1345 default: DBG_ERROR("Wrong MemberId!"); return sal_False
;
1350 // -----------------------------------------------------------------------
1351 sal_Bool
SvxShadowItem::PutValue( const uno::Any
& rVal
, BYTE nMemberId
)
1353 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1354 nMemberId
&= ~CONVERT_TWIPS
;
1356 table::ShadowFormat aShadow
;
1358 sal_Bool bRet
= QueryValue( aAny
, bConvert
? CONVERT_TWIPS
: 0 ) && ( aAny
>>= aShadow
);
1359 switch ( nMemberId
)
1363 bRet
= (rVal
>>= aShadow
.Location
);
1367 bRet
= (rVal
>>= nVal
);
1368 aShadow
.Location
= (table::ShadowLocation
) nVal
;
1374 case MID_WIDTH
: rVal
>>= aShadow
.ShadowWidth
; break;
1375 case MID_TRANSPARENT
: rVal
>>= aShadow
.IsTransparent
; break;
1376 case MID_BG_COLOR
: rVal
>>= aShadow
.Color
; break;
1377 case 0: rVal
>>= aShadow
; break;
1378 default: DBG_ERROR("Wrong MemberId!"); return sal_False
;
1383 // SvxShadowLocation eSet = SVX_SHADOW_NONE;
1384 switch( aShadow
.Location
)
1386 case table::ShadowLocation_TOP_LEFT
: eLocation
= SVX_SHADOW_TOPLEFT
; break;
1387 case table::ShadowLocation_TOP_RIGHT
: eLocation
= SVX_SHADOW_TOPRIGHT
; break;
1388 case table::ShadowLocation_BOTTOM_LEFT
: eLocation
= SVX_SHADOW_BOTTOMLEFT
; break;
1389 case table::ShadowLocation_BOTTOM_RIGHT
: eLocation
= SVX_SHADOW_BOTTOMRIGHT
; break;
1390 default: ;//prevent warning
1393 nWidth
= bConvert
? MM100_TO_TWIP(aShadow
.ShadowWidth
) : aShadow
.ShadowWidth
;
1394 Color
aSet(aShadow
.Color
);
1395 aSet
.SetTransparency(aShadow
.IsTransparent
? 0xff : 0);
1396 aShadowColor
= aSet
;
1402 // -----------------------------------------------------------------------
1404 int SvxShadowItem::operator==( const SfxPoolItem
& rAttr
) const
1406 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1408 return ( ( aShadowColor
== ( (SvxShadowItem
&)rAttr
).aShadowColor
) &&
1409 ( nWidth
== ( (SvxShadowItem
&)rAttr
).GetWidth() ) &&
1410 ( eLocation
== ( (SvxShadowItem
&)rAttr
).GetLocation() ) );
1413 // -----------------------------------------------------------------------
1415 SfxPoolItem
* SvxShadowItem::Clone( SfxItemPool
* ) const
1417 return new SvxShadowItem( *this );
1420 // -----------------------------------------------------------------------
1422 sal_uInt16
SvxShadowItem::CalcShadowSpace( sal_uInt16 nShadow
) const
1424 sal_uInt16 nSpace
= 0;
1429 if ( eLocation
== SVX_SHADOW_TOPLEFT
||
1430 eLocation
== SVX_SHADOW_TOPRIGHT
)
1435 if ( eLocation
== SVX_SHADOW_BOTTOMLEFT
||
1436 eLocation
== SVX_SHADOW_BOTTOMRIGHT
)
1441 if ( eLocation
== SVX_SHADOW_TOPLEFT
||
1442 eLocation
== SVX_SHADOW_BOTTOMLEFT
)
1447 if ( eLocation
== SVX_SHADOW_TOPRIGHT
||
1448 eLocation
== SVX_SHADOW_BOTTOMRIGHT
)
1453 DBG_ERROR( "wrong shadow" );
1458 //------------------------------------------------------------------------
1460 SfxItemPresentation
SvxShadowItem::GetPresentation
1462 SfxItemPresentation ePres
,
1463 SfxMapUnit eCoreUnit
,
1464 SfxMapUnit ePresUnit
,
1465 XubString
& rText
, const IntlWrapper
*pIntl
1471 case SFX_ITEM_PRESENTATION_NONE
:
1475 case SFX_ITEM_PRESENTATION_NAMELESS
:
1477 rText
= ::GetColorString( aShadowColor
);
1479 sal_uInt16 nId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
1481 if ( aShadowColor
.GetTransparency() )
1482 nId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
1483 rText
+= SVX_RESSTR(nId
);
1485 rText
+= GetMetricText( (long)nWidth
, eCoreUnit
, ePresUnit
, pIntl
);
1487 rText
+= SVX_RESSTR(RID_SVXITEMS_SHADOW_BEGIN
+ eLocation
);
1490 case SFX_ITEM_PRESENTATION_COMPLETE
:
1492 rText
= SVX_RESSTR(RID_SVXITEMS_SHADOW_COMPLETE
);
1493 rText
+= ::GetColorString( aShadowColor
);
1496 sal_uInt16 nId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
1497 if ( aShadowColor
.GetTransparency() )
1498 nId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
1499 rText
+= SVX_RESSTR(nId
);
1501 rText
+= GetMetricText( (long)nWidth
, eCoreUnit
, ePresUnit
, pIntl
);
1502 rText
+= SVX_RESSTR(GetMetricId(ePresUnit
));
1504 rText
+= SVX_RESSTR(RID_SVXITEMS_SHADOW_BEGIN
+ eLocation
);
1507 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 int SvxShadowItem::ScaleMetrics( long nMult
, long nDiv
)
1530 nWidth
= (sal_uInt16
)Scale( nWidth
, nMult
, nDiv
);
1534 // -----------------------------------------------------------------------
1536 int 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 XubString
SvxShadowItem::GetValueTextByPos( sal_uInt16 nPos
) const
1568 DBG_ASSERT( nPos
< SVX_SHADOW_END
, "enum overflow!" );
1569 return XubString( SVX_RES( 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 SvxBorderLine --------------------------------------------------
1588 SvxBorderLine::SvxBorderLine( const Color
*pCol
, sal_uInt16 nOut
, sal_uInt16 nIn
, sal_uInt16 nDist
)
1591 , nDistance( nDist
)
1597 // -----------------------------------------------------------------------
1599 SvxBorderLine::SvxBorderLine( const SvxBorderLine
& r
)
1604 // -----------------------------------------------------------------------
1606 SvxBorderLine
& SvxBorderLine::operator=( const SvxBorderLine
& r
)
1609 nOutWidth
= r
.nOutWidth
;
1610 nInWidth
= r
.nInWidth
;
1611 nDistance
= r
.nDistance
;
1615 // -----------------------------------------------------------------------
1617 void SvxBorderLine::ScaleMetrics( long nMult
, long nDiv
)
1619 nOutWidth
= (sal_uInt16
)Scale( nOutWidth
, nMult
, nDiv
);
1620 nInWidth
= (sal_uInt16
)Scale( nInWidth
, nMult
, nDiv
);
1621 nDistance
= (sal_uInt16
)Scale( nDistance
, nMult
, nDiv
);
1624 // -----------------------------------------------------------------------
1626 sal_Bool
SvxBorderLine::operator==( const SvxBorderLine
& rCmp
) const
1628 return ( ( aColor
== rCmp
.GetColor() ) &&
1629 ( nInWidth
== rCmp
.GetInWidth() ) &&
1630 ( nOutWidth
== rCmp
.GetOutWidth() ) &&
1631 ( nDistance
== rCmp
.GetDistance() ) );
1634 // -----------------------------------------------------------------------
1636 XubString
SvxBorderLine::GetValueString( SfxMapUnit eSrcUnit
,
1637 SfxMapUnit eDestUnit
,
1638 const IntlWrapper
* pIntl
,
1639 sal_Bool bMetricStr
) const
1642 sal_uInt16 nResId
= 0;
1644 if ( 0 == nDistance
)
1647 if ( DEF_LINE_WIDTH_0
== nOutWidth
)
1648 nResId
= RID_SINGLE_LINE0
;
1649 else if ( DEF_LINE_WIDTH_1
== nOutWidth
)
1650 nResId
= RID_SINGLE_LINE1
;
1651 else if ( DEF_LINE_WIDTH_2
== nOutWidth
)
1652 nResId
= RID_SINGLE_LINE2
;
1653 else if ( DEF_LINE_WIDTH_3
== nOutWidth
)
1654 nResId
= RID_SINGLE_LINE3
;
1655 else if ( DEF_LINE_WIDTH_4
== nOutWidth
)
1656 nResId
= RID_SINGLE_LINE4
;
1658 else if ( DEF_LINE_WIDTH_1
== nDistance
)
1660 // doppelte Linie, kleiner Abstand
1661 if ( DEF_LINE_WIDTH_0
== nOutWidth
&& DEF_LINE_WIDTH_0
== nInWidth
)
1662 nResId
= RID_DOUBLE_LINE0
;
1663 else if ( DEF_LINE_WIDTH_1
== nOutWidth
&&
1664 DEF_LINE_WIDTH_1
== nInWidth
)
1665 nResId
= RID_DOUBLE_LINE2
;
1666 else if ( DEF_LINE_WIDTH_1
== nOutWidth
&&
1667 DEF_LINE_WIDTH_2
== nInWidth
)
1668 nResId
= RID_DOUBLE_LINE8
;
1670 else if ( DEF_LINE_WIDTH_2
== nDistance
)
1672 // doppelte Linie, gro\ser Abstand
1673 if ( DEF_LINE_WIDTH_0
== nOutWidth
&& DEF_LINE_WIDTH_0
== nInWidth
)
1674 nResId
= RID_DOUBLE_LINE1
;
1675 else if ( DEF_LINE_WIDTH_2
== nOutWidth
&&
1676 DEF_LINE_WIDTH_2
== nInWidth
)
1677 nResId
= RID_DOUBLE_LINE3
;
1678 else if ( DEF_LINE_WIDTH_1
== nOutWidth
&&
1679 DEF_LINE_WIDTH_0
== nInWidth
)
1680 nResId
= RID_DOUBLE_LINE4
;
1681 else if ( DEF_LINE_WIDTH_2
== nOutWidth
&&
1682 DEF_LINE_WIDTH_0
== nInWidth
)
1683 nResId
= RID_DOUBLE_LINE5
;
1684 else if ( DEF_LINE_WIDTH_3
== nOutWidth
&&
1685 DEF_LINE_WIDTH_0
== nInWidth
)
1686 nResId
= RID_DOUBLE_LINE6
;
1687 else if ( DEF_LINE_WIDTH_2
== nOutWidth
&&
1688 DEF_LINE_WIDTH_1
== nInWidth
)
1689 nResId
= RID_DOUBLE_LINE7
;
1690 else if ( DEF_LINE_WIDTH_3
== nOutWidth
&&
1691 DEF_LINE_WIDTH_2
== nInWidth
)
1692 nResId
= RID_DOUBLE_LINE9
;
1693 else if ( DEF_LINE_WIDTH_2
== nOutWidth
&&
1694 DEF_LINE_WIDTH_3
== nInWidth
)
1695 nResId
= RID_DOUBLE_LINE10
;
1698 aStr
+= sal_Unicode('(');
1699 aStr
+= ::GetColorString( aColor
);
1703 aStr
+= SVX_RESSTR(nResId
);
1706 String sMetric
= SVX_RESSTR(GetMetricId( eDestUnit
));
1707 aStr
+= GetMetricText( (long)nInWidth
, eSrcUnit
, eDestUnit
, pIntl
);
1711 aStr
+= GetMetricText( (long)nOutWidth
, eSrcUnit
, eDestUnit
, pIntl
);
1715 aStr
+= GetMetricText( (long)nDistance
, eSrcUnit
, eDestUnit
, pIntl
);
1719 aStr
+= sal_Unicode(')');
1726 bool SvxBorderLine::HasPriority( const SvxBorderLine
& rOtherLine
) const
1728 const USHORT nThisSize
= GetOutWidth() + GetDistance() + GetInWidth();
1729 const USHORT nOtherSize
= rOtherLine
.GetOutWidth() + rOtherLine
.GetDistance() + rOtherLine
.GetInWidth();
1731 if (nThisSize
> nOtherSize
)
1735 else if (nThisSize
< nOtherSize
)
1741 if ( rOtherLine
.GetInWidth() && !GetInWidth() )
1745 else if ( GetInWidth() && !rOtherLine
.GetInWidth() )
1756 // class SvxBoxItem ------------------------------------------------------
1758 SvxBoxItem::SvxBoxItem( const SvxBoxItem
& rCpy
) :
1760 SfxPoolItem ( rCpy
),
1761 nTopDist ( rCpy
.nTopDist
),
1762 nBottomDist ( rCpy
.nBottomDist
),
1763 nLeftDist ( rCpy
.nLeftDist
),
1764 nRightDist ( rCpy
.nRightDist
)
1767 pTop
= rCpy
.GetTop() ? new SvxBorderLine( *rCpy
.GetTop() ) : 0;
1768 pBottom
= rCpy
.GetBottom() ? new SvxBorderLine( *rCpy
.GetBottom() ) : 0;
1769 pLeft
= rCpy
.GetLeft() ? new SvxBorderLine( *rCpy
.GetLeft() ) : 0;
1770 pRight
= rCpy
.GetRight() ? new SvxBorderLine( *rCpy
.GetRight() ) : 0;
1773 // -----------------------------------------------------------------------
1775 SvxBoxItem::SvxBoxItem( const sal_uInt16 nId
) :
1790 // -----------------------------------------------------------------------
1792 SvxBoxItem::~SvxBoxItem()
1800 // -----------------------------------------------------------------------
1802 SvxBoxItem
& SvxBoxItem::operator=( const SvxBoxItem
& rBox
)
1804 nTopDist
= rBox
.nTopDist
;
1805 nBottomDist
= rBox
.nBottomDist
;
1806 nLeftDist
= rBox
.nLeftDist
;
1807 nRightDist
= rBox
.nRightDist
;
1808 SetLine( rBox
.GetTop(), BOX_LINE_TOP
);
1809 SetLine( rBox
.GetBottom(), BOX_LINE_BOTTOM
);
1810 SetLine( rBox
.GetLeft(), BOX_LINE_LEFT
);
1811 SetLine( rBox
.GetRight(), BOX_LINE_RIGHT
);
1815 // -----------------------------------------------------------------------
1817 inline sal_Bool
CmpBrdLn( const SvxBorderLine
* pBrd1
, const SvxBorderLine
* pBrd2
)
1820 if( 0 != pBrd1
? 0 == pBrd2
: 0 != pBrd2
)
1826 bRet
= (*pBrd1
== *pBrd2
);
1830 // -----------------------------------------------------------------------
1832 int SvxBoxItem::operator==( const SfxPoolItem
& rAttr
) const
1834 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
1837 ( nTopDist
== ( (SvxBoxItem
&)rAttr
).nTopDist
) &&
1838 ( nBottomDist
== ( (SvxBoxItem
&)rAttr
).nBottomDist
) &&
1839 ( nLeftDist
== ( (SvxBoxItem
&)rAttr
).nLeftDist
) &&
1840 ( nRightDist
== ( (SvxBoxItem
&)rAttr
).nRightDist
) &&
1841 CmpBrdLn( pTop
, ( (SvxBoxItem
&)rAttr
).GetTop() ) &&
1842 CmpBrdLn( pBottom
, ( (SvxBoxItem
&)rAttr
).GetBottom() ) &&
1843 CmpBrdLn( pLeft
, ( (SvxBoxItem
&)rAttr
).GetLeft() ) &&
1844 CmpBrdLn( pRight
, ( (SvxBoxItem
&)rAttr
).GetRight() ) );
1847 // -----------------------------------------------------------------------
1848 table::BorderLine
lcl_SvxLineToLine(const SvxBorderLine
* pLine
, sal_Bool bConvert
)
1850 table::BorderLine aLine
;
1853 aLine
.Color
= pLine
->GetColor().GetColor() ;
1854 aLine
.InnerLineWidth
= sal_uInt16( bConvert
? TWIP_TO_MM100_UNSIGNED(pLine
->GetInWidth() ): pLine
->GetInWidth() );
1855 aLine
.OuterLineWidth
= sal_uInt16( bConvert
? TWIP_TO_MM100_UNSIGNED(pLine
->GetOutWidth()): pLine
->GetOutWidth() );
1856 aLine
.LineDistance
= sal_uInt16( bConvert
? TWIP_TO_MM100_UNSIGNED(pLine
->GetDistance()): pLine
->GetDistance() );
1859 aLine
.Color
= aLine
.InnerLineWidth
= aLine
.OuterLineWidth
= aLine
.LineDistance
= 0;
1862 // -----------------------------------------------------------------------
1863 sal_Bool
SvxBoxItem::QueryValue( uno::Any
& rVal
, BYTE nMemberId
) const
1865 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1866 table::BorderLine aRetLine
;
1867 sal_uInt16 nDist
= 0;
1868 sal_Bool bDistMember
= sal_False
;
1869 nMemberId
&= ~CONVERT_TWIPS
;
1870 sal_Bool bSerialize
= sal_False
;
1875 // 4 Borders and 5 distances
1876 uno::Sequence
< uno::Any
> aSeq( 9 );
1877 aSeq
[0] = uno::makeAny( lcl_SvxLineToLine(GetLeft(), bConvert
) );
1878 aSeq
[1] = uno::makeAny( lcl_SvxLineToLine(GetRight(), bConvert
) );
1879 aSeq
[2] = uno::makeAny( lcl_SvxLineToLine(GetBottom(), bConvert
) );
1880 aSeq
[3] = uno::makeAny( lcl_SvxLineToLine(GetTop(), bConvert
) );
1881 aSeq
[4] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( GetDistance()) : GetDistance()));
1882 aSeq
[5] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( nTopDist
) : nTopDist
));
1883 aSeq
[6] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( nBottomDist
) : nBottomDist
));
1884 aSeq
[7] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( nLeftDist
) : nLeftDist
));
1885 aSeq
[8] <<= uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED( nRightDist
) : nRightDist
));
1886 rVal
= uno::makeAny( aSeq
);
1889 case MID_LEFT_BORDER
:
1890 bSerialize
= sal_True
; // intentionally no break!
1892 aRetLine
= lcl_SvxLineToLine(GetLeft(), bConvert
);
1894 case MID_RIGHT_BORDER
:
1895 bSerialize
= sal_True
; // intentionally no break!
1897 aRetLine
= lcl_SvxLineToLine(GetRight(), bConvert
);
1899 case MID_BOTTOM_BORDER
:
1900 bSerialize
= sal_True
; // intentionally no break!
1902 aRetLine
= lcl_SvxLineToLine(GetBottom(), bConvert
);
1904 case MID_TOP_BORDER
:
1905 bSerialize
= sal_True
; // intentionally no break!
1907 aRetLine
= lcl_SvxLineToLine(GetTop(), bConvert
);
1909 case BORDER_DISTANCE
:
1910 nDist
= GetDistance();
1911 bDistMember
= sal_True
;
1913 case TOP_BORDER_DISTANCE
:
1915 bDistMember
= sal_True
;
1917 case BOTTOM_BORDER_DISTANCE
:
1918 nDist
= nBottomDist
;
1919 bDistMember
= sal_True
;
1921 case LEFT_BORDER_DISTANCE
:
1923 bDistMember
= sal_True
;
1925 case RIGHT_BORDER_DISTANCE
:
1927 bDistMember
= sal_True
;
1932 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(nDist
) : nDist
);
1938 ::com::sun::star::uno::Sequence < ::com::sun::star::uno::Any > aSeq(4);
1939 aSeq[0] <<= aRetLine.Color;
1940 aSeq[1] <<= aRetLine.InnerLineWidth;
1941 aSeq[2] <<= aRetLine.OuterLineWidth;
1942 aSeq[3] <<= aRetLine.LineDistance;
1953 // -----------------------------------------------------------------------
1954 sal_Bool
lcl_LineToSvxLine(const ::com::sun::star::table::BorderLine
& rLine
, SvxBorderLine
& rSvxLine
, sal_Bool bConvert
)
1956 rSvxLine
.SetColor( Color(rLine
.Color
));
1957 rSvxLine
.SetInWidth( sal_uInt16( bConvert
? MM100_TO_TWIP(rLine
.InnerLineWidth
) : rLine
.InnerLineWidth
));
1958 rSvxLine
.SetOutWidth( sal_uInt16( bConvert
? MM100_TO_TWIP(rLine
.OuterLineWidth
) : rLine
.OuterLineWidth
));
1959 rSvxLine
.SetDistance( sal_uInt16( bConvert
? MM100_TO_TWIP(rLine
.LineDistance
) : rLine
.LineDistance
));
1960 sal_Bool bRet
= rLine
.InnerLineWidth
> 0 || rLine
.OuterLineWidth
> 0;
1964 // -----------------------------------------------------------------------
1966 sal_Bool
SvxBoxItem::PutValue( const uno::Any
& rVal
, BYTE nMemberId
)
1968 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
1969 sal_uInt16 nLine
= BOX_LINE_TOP
;
1970 sal_Bool bDistMember
= sal_False
;
1971 nMemberId
&= ~CONVERT_TWIPS
;
1976 uno::Sequence
< uno::Any
> aSeq
;
1977 if (( rVal
>>= aSeq
) && ( aSeq
.getLength() == 9 ))
1979 // 4 Borders and 5 distances
1980 sal_Int32 nDist
= 0;
1981 SvxBorderLine aLine
;
1982 table::BorderLine aBorderLine
;
1983 if ( aSeq
[0] >>= aBorderLine
)
1985 sal_Bool bSet
= lcl_LineToSvxLine(aBorderLine
, aLine
, bConvert
);
1986 SetLine(bSet
? &aLine
: 0, BOX_LINE_LEFT
);
1991 if ( aSeq
[1] >>= aBorderLine
)
1993 sal_Bool bSet
= lcl_LineToSvxLine(aBorderLine
, aLine
, bConvert
);
1994 SetLine(bSet
? &aLine
: 0, BOX_LINE_RIGHT
);
1999 if ( aSeq
[2] >>= aBorderLine
)
2001 sal_Bool bSet
= lcl_LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2002 SetLine(bSet
? &aLine
: 0, BOX_LINE_BOTTOM
);
2007 if ( aSeq
[3] >>= aBorderLine
)
2009 sal_Bool bSet
= lcl_LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2010 SetLine(bSet
? &aLine
: 0, BOX_LINE_TOP
);
2015 sal_uInt16 nLines
[4] = { BOX_LINE_TOP
, BOX_LINE_BOTTOM
, BOX_LINE_LEFT
, BOX_LINE_RIGHT
};
2016 for ( sal_Int32 n
= 4; n
< 9; n
++ )
2018 if ( aSeq
[n
] >>= nDist
)
2021 nDist
= MM100_TO_TWIP(nDist
);
2023 SetDistance( sal_uInt16( nDist
));
2025 SetDistance( sal_uInt16( nDist
), nLines
[n
-5] );
2036 case LEFT_BORDER_DISTANCE
:
2037 bDistMember
= sal_True
;
2039 case MID_LEFT_BORDER
:
2040 nLine
= BOX_LINE_LEFT
;
2042 case RIGHT_BORDER_DISTANCE
:
2043 bDistMember
= sal_True
;
2045 case MID_RIGHT_BORDER
:
2046 nLine
= BOX_LINE_RIGHT
;
2048 case BOTTOM_BORDER_DISTANCE
:
2049 bDistMember
= sal_True
;
2051 case MID_BOTTOM_BORDER
:
2052 nLine
= BOX_LINE_BOTTOM
;
2054 case TOP_BORDER_DISTANCE
:
2055 bDistMember
= sal_True
;
2057 case MID_TOP_BORDER
:
2058 nLine
= BOX_LINE_TOP
;
2062 if( bDistMember
|| nMemberId
== BORDER_DISTANCE
)
2064 sal_Int32 nDist
= 0;
2065 if(!(rVal
>>= nDist
))
2071 nDist
= MM100_TO_TWIP(nDist
);
2072 if( nMemberId
== BORDER_DISTANCE
)
2073 SetDistance( sal_uInt16( nDist
));
2075 SetDistance( sal_uInt16( nDist
), nLine
);
2080 SvxBorderLine aLine
;
2081 if( !rVal
.hasValue() )
2084 table::BorderLine aBorderLine
;
2085 if( rVal
>>= aBorderLine
)
2089 else if (rVal
.getValueTypeClass() == uno::TypeClass_SEQUENCE
)
2091 // serialization for basic macro recording
2092 uno::Reference
< script::XTypeConverter
> xConverter
2093 ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")),
2095 uno::Sequence
< uno::Any
> aSeq
;
2097 try { aNew
= xConverter
->convertTo( rVal
, ::getCppuType((const uno::Sequence
< uno::Any
>*)0) ); }
2098 catch (uno::Exception
&) {}
2101 if ( aSeq
.getLength() == 4 )
2104 if ( aSeq
[0] >>= nVal
)
2105 aBorderLine
.Color
= nVal
;
2106 if ( aSeq
[1] >>= nVal
)
2107 aBorderLine
.InnerLineWidth
= (sal_Int16
) nVal
;
2108 if ( aSeq
[2] >>= nVal
)
2109 aBorderLine
.OuterLineWidth
= (sal_Int16
) nVal
;
2110 if ( aSeq
[3] >>= nVal
)
2111 aBorderLine
.LineDistance
= (sal_Int16
) nVal
;
2119 sal_Bool bSet
= lcl_LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2120 SetLine(bSet
? &aLine
: 0, nLine
);
2126 // -----------------------------------------------------------------------
2128 SfxPoolItem
* SvxBoxItem::Clone( SfxItemPool
* ) const
2130 return new SvxBoxItem( *this );
2133 //------------------------------------------------------------------------
2135 SfxItemPresentation
SvxBoxItem::GetPresentation
2137 SfxItemPresentation ePres
,
2138 SfxMapUnit eCoreUnit
,
2139 SfxMapUnit ePresUnit
,
2140 XubString
& rText
, const IntlWrapper
*pIntl
2146 case SFX_ITEM_PRESENTATION_NONE
:
2148 return SFX_ITEM_PRESENTATION_NONE
;
2150 case SFX_ITEM_PRESENTATION_NAMELESS
:
2156 rText
= pTop
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
);
2159 if( !(pTop
&& pBottom
&& pLeft
&& pRight
&&
2160 *pTop
== *pBottom
&& *pTop
== *pLeft
&& *pTop
== *pRight
) )
2164 rText
+= pBottom
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
);
2169 rText
+= pLeft
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
);
2174 rText
+= pRight
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
);
2178 rText
+= GetMetricText( (long)nTopDist
, eCoreUnit
, ePresUnit
, pIntl
);
2179 if( nTopDist
!= nBottomDist
|| nTopDist
!= nLeftDist
||
2180 nTopDist
!= nRightDist
)
2182 (((((rText
+= cpDelim
)
2183 += GetMetricText( (long)nBottomDist
, eCoreUnit
,
2186 += GetMetricText( (long)nLeftDist
, eCoreUnit
, ePresUnit
, pIntl
))
2188 += GetMetricText( (long)nRightDist
, eCoreUnit
,
2191 return SFX_ITEM_PRESENTATION_NAMELESS
;
2193 case SFX_ITEM_PRESENTATION_COMPLETE
:
2195 if( !(pTop
|| pBottom
|| pLeft
|| pRight
) )
2197 rText
= SVX_RESSTR(RID_SVXITEMS_BORDER_NONE
);
2202 rText
= SVX_RESSTR(RID_SVXITEMS_BORDER_COMPLETE
);
2203 if( pTop
&& pBottom
&& pLeft
&& pRight
&&
2204 *pTop
== *pBottom
&& *pTop
== *pLeft
&& *pTop
== *pRight
)
2206 rText
+= pTop
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2213 rText
+= SVX_RESSTR(RID_SVXITEMS_BORDER_TOP
);
2214 rText
+= pTop
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2219 rText
+= SVX_RESSTR(RID_SVXITEMS_BORDER_BOTTOM
);
2220 rText
+= pBottom
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2225 rText
+= SVX_RESSTR(RID_SVXITEMS_BORDER_LEFT
);
2226 rText
+= pLeft
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2231 rText
+= SVX_RESSTR(RID_SVXITEMS_BORDER_RIGHT
);
2232 rText
+= pRight
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
, sal_True
);
2238 rText
+= SVX_RESSTR(RID_SVXITEMS_BORDER_DISTANCE
);
2239 if( nTopDist
== nBottomDist
&& nTopDist
== nLeftDist
&&
2240 nTopDist
== nRightDist
)
2242 rText
+= GetMetricText( (long)nTopDist
, eCoreUnit
,
2244 rText
+= SVX_RESSTR(GetMetricId(ePresUnit
));
2248 (((rText
+= SVX_RESSTR(RID_SVXITEMS_BORDER_TOP
))
2249 += GetMetricText( (long)nTopDist
, eCoreUnit
,
2251 += SVX_RESSTR(GetMetricId(ePresUnit
)))
2253 (((rText
+= SVX_RESSTR(RID_SVXITEMS_BORDER_BOTTOM
))
2254 += GetMetricText( (long)nBottomDist
, eCoreUnit
,
2256 += SVX_RESSTR(GetMetricId(ePresUnit
)))
2258 (((rText
+= SVX_RESSTR(RID_SVXITEMS_BORDER_LEFT
))
2259 += GetMetricText( (long)nLeftDist
, eCoreUnit
,
2261 += SVX_RESSTR(GetMetricId(ePresUnit
)))
2263 ((rText
+= SVX_RESSTR(RID_SVXITEMS_BORDER_RIGHT
))
2264 += GetMetricText( (long)nRightDist
, eCoreUnit
,
2266 += SVX_RESSTR(GetMetricId(ePresUnit
));
2268 return SFX_ITEM_PRESENTATION_COMPLETE
;
2270 default: ;//prevent warning
2272 #endif // !SVX_LIGHT
2273 return SFX_ITEM_PRESENTATION_NONE
;
2276 // -----------------------------------------------------------------------
2278 SvStream
& SvxBoxItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
2280 rStrm
<< (sal_uInt16
) GetDistance();
2281 const SvxBorderLine
* pLine
[ 4 ]; // top, left, right, bottom
2282 pLine
[ 0 ] = GetTop();
2283 pLine
[ 1 ] = GetLeft();
2284 pLine
[ 2 ] = GetRight();
2285 pLine
[ 3 ] = GetBottom();
2287 for( int i
= 0; i
< 4; i
++ )
2289 const SvxBorderLine
* l
= pLine
[ i
];
2292 rStrm
<< (sal_Int8
) i
2294 << (sal_uInt16
) l
->GetOutWidth()
2295 << (sal_uInt16
) l
->GetInWidth()
2296 << (sal_uInt16
) l
->GetDistance();
2300 if( nItemVersion
>= BOX_4DISTS_VERSION
&&
2301 !(nTopDist
== nLeftDist
&&
2302 nTopDist
== nRightDist
&&
2303 nTopDist
== nBottomDist
) )
2310 if( nItemVersion
>= BOX_4DISTS_VERSION
&& (cLine
& 0x10) != 0 )
2312 rStrm
<< (sal_uInt16
)nTopDist
2313 << (sal_uInt16
)nLeftDist
2314 << (sal_uInt16
)nRightDist
2315 << (sal_uInt16
)nBottomDist
;
2321 // -----------------------------------------------------------------------
2323 sal_uInt16
SvxBoxItem::GetVersion( sal_uInt16 nFFVer
) const
2325 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
2326 SOFFICE_FILEFORMAT_40
==nFFVer
||
2327 SOFFICE_FILEFORMAT_50
==nFFVer
,
2328 "SvxBoxItem: Gibt es ein neues Fileformat?" );
2329 return SOFFICE_FILEFORMAT_31
==nFFVer
||
2330 SOFFICE_FILEFORMAT_40
==nFFVer
? 0 : BOX_4DISTS_VERSION
;
2333 // -----------------------------------------------------------------------
2335 int SvxBoxItem::ScaleMetrics( long nMult
, long nDiv
)
2337 if ( pTop
) pTop
->ScaleMetrics( nMult
, nDiv
);
2338 if ( pBottom
) pBottom
->ScaleMetrics( nMult
, nDiv
);
2339 if ( pLeft
) pLeft
->ScaleMetrics( nMult
, nDiv
);
2340 if ( pRight
) pBottom
->ScaleMetrics( nMult
, nDiv
);
2341 nTopDist
= (sal_uInt16
)Scale( nTopDist
, nMult
, nDiv
);
2342 nBottomDist
= (sal_uInt16
)Scale( nBottomDist
, nMult
, nDiv
);
2343 nLeftDist
= (sal_uInt16
)Scale( nLeftDist
, nMult
, nDiv
);
2344 nRightDist
= (sal_uInt16
)Scale( nRightDist
, nMult
, nDiv
);
2348 // -----------------------------------------------------------------------
2350 int SvxBoxItem::HasMetrics() const
2355 // -----------------------------------------------------------------------
2357 SfxPoolItem
* SvxBoxItem::Create( SvStream
& rStrm
, sal_uInt16 nIVersion
) const
2359 sal_uInt16 nDistance
;
2361 SvxBoxItem
* pAttr
= new SvxBoxItem( Which() );
2363 sal_uInt16 aLineMap
[4] = { BOX_LINE_TOP
, BOX_LINE_LEFT
,
2364 BOX_LINE_RIGHT
, BOX_LINE_BOTTOM
};
2373 sal_uInt16 nOutline
, nInline
, _nDistance
;
2375 rStrm
>> aColor
>> nOutline
>> nInline
>> _nDistance
;
2376 SvxBorderLine
aBorder( &aColor
, nOutline
, nInline
, _nDistance
);
2378 pAttr
->SetLine( &aBorder
, aLineMap
[cLine
] );
2381 if( nIVersion
>= BOX_4DISTS_VERSION
&& (cLine
&0x10) != 0 )
2383 for( sal_uInt16 i
=0; i
< 4; i
++ )
2387 pAttr
->SetDistance( nDist
, aLineMap
[i
] );
2392 pAttr
->SetDistance( nDistance
);
2398 // -----------------------------------------------------------------------
2400 const SvxBorderLine
*SvxBoxItem::GetLine( sal_uInt16 nLine
) const
2402 const SvxBorderLine
*pRet
= 0;
2409 case BOX_LINE_BOTTOM
:
2415 case BOX_LINE_RIGHT
:
2419 DBG_ERROR( "wrong line" );
2426 // -----------------------------------------------------------------------
2428 void SvxBoxItem::SetLine( const SvxBorderLine
* pNew
, sal_uInt16 nLine
)
2430 SvxBorderLine
* pTmp
= pNew
? new SvxBorderLine( *pNew
) : 0;
2438 case BOX_LINE_BOTTOM
:
2446 case BOX_LINE_RIGHT
:
2451 DBG_ERROR( "wrong line" );
2455 // -----------------------------------------------------------------------
2457 sal_uInt16
SvxBoxItem::GetDistance() const
2459 // The smallest distance that is not 0 will be returned.
2460 sal_uInt16 nDist
= nTopDist
;
2461 if( nBottomDist
&& (!nDist
|| nBottomDist
< nDist
) )
2462 nDist
= nBottomDist
;
2463 if( nLeftDist
&& (!nDist
|| nLeftDist
< nDist
) )
2465 if( nRightDist
&& (!nDist
|| nRightDist
< nDist
) )
2471 // -----------------------------------------------------------------------
2473 sal_uInt16
SvxBoxItem::GetDistance( sal_uInt16 nLine
) const
2475 sal_uInt16 nDist
= 0;
2481 case BOX_LINE_BOTTOM
:
2482 nDist
= nBottomDist
;
2487 case BOX_LINE_RIGHT
:
2491 DBG_ERROR( "wrong line" );
2497 // -----------------------------------------------------------------------
2499 void SvxBoxItem::SetDistance( sal_uInt16 nNew
, sal_uInt16 nLine
)
2506 case BOX_LINE_BOTTOM
:
2512 case BOX_LINE_RIGHT
:
2516 DBG_ERROR( "wrong line" );
2520 // -----------------------------------------------------------------------
2522 sal_uInt16
SvxBoxItem::CalcLineSpace( sal_uInt16 nLine
, sal_Bool bIgnoreLine
) const
2524 SvxBorderLine
* pTmp
= 0;
2525 sal_uInt16 nDist
= 0;
2532 case BOX_LINE_BOTTOM
:
2534 nDist
= nBottomDist
;
2540 case BOX_LINE_RIGHT
:
2545 DBG_ERROR( "wrong line" );
2550 nDist
= nDist
+ (sal_uInt16
)(pTmp
->GetOutWidth()) + (sal_uInt16
)(pTmp
->GetInWidth()) + (sal_uInt16
)(pTmp
->GetDistance());
2552 else if( !bIgnoreLine
)
2557 // class SvxBoxInfoItem --------------------------------------------------
2559 SvxBoxInfoItem::SvxBoxInfoItem( const sal_uInt16 nId
) :
2563 mbEnableHor( false ),
2564 mbEnableVer( false ),
2567 bDist
= bMinDist
= sal_False
;
2571 // -----------------------------------------------------------------------
2573 SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem
& rCpy
) :
2574 SfxPoolItem( rCpy
),
2575 mbEnableHor( rCpy
.mbEnableHor
),
2576 mbEnableVer( rCpy
.mbEnableVer
)
2578 pHori
= rCpy
.GetHori() ? new SvxBorderLine( *rCpy
.GetHori() ) : 0;
2579 pVert
= rCpy
.GetVert() ? new SvxBorderLine( *rCpy
.GetVert() ) : 0;
2580 bDist
= rCpy
.IsDist();
2581 bMinDist
= rCpy
.IsMinDist();
2582 nValidFlags
= rCpy
.nValidFlags
;
2583 nDefDist
= rCpy
.GetDefDist();
2586 // -----------------------------------------------------------------------
2588 SvxBoxInfoItem::~SvxBoxInfoItem()
2594 // -----------------------------------------------------------------------
2596 SvxBoxInfoItem
&SvxBoxInfoItem::operator=( const SvxBoxInfoItem
& rCpy
)
2600 pHori
= rCpy
.GetHori() ? new SvxBorderLine( *rCpy
.GetHori() ) : 0;
2601 pVert
= rCpy
.GetVert() ? new SvxBorderLine( *rCpy
.GetVert() ) : 0;
2602 mbEnableHor
= rCpy
.mbEnableHor
;
2603 mbEnableVer
= rCpy
.mbEnableVer
;
2604 bDist
= rCpy
.IsDist();
2605 bMinDist
= rCpy
.IsMinDist();
2606 nValidFlags
= rCpy
.nValidFlags
;
2607 nDefDist
= rCpy
.GetDefDist();
2611 // -----------------------------------------------------------------------
2613 int SvxBoxInfoItem::operator==( const SfxPoolItem
& rAttr
) const
2615 SvxBoxInfoItem
& rBoxInfo
= (SvxBoxInfoItem
&)rAttr
;
2617 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
2619 return ( mbEnableHor
== rBoxInfo
.mbEnableHor
2620 && mbEnableVer
== rBoxInfo
.mbEnableVer
2621 && bDist
== rBoxInfo
.IsDist()
2622 && bMinDist
== rBoxInfo
.IsMinDist()
2623 && nValidFlags
== rBoxInfo
.nValidFlags
2624 && nDefDist
== rBoxInfo
.GetDefDist()
2625 && CmpBrdLn( pHori
, rBoxInfo
.GetHori() )
2626 && CmpBrdLn( pVert
, rBoxInfo
.GetVert() )
2630 // -----------------------------------------------------------------------
2632 void SvxBoxInfoItem::SetLine( const SvxBorderLine
* pNew
, sal_uInt16 nLine
)
2634 SvxBorderLine
* pTmp
= pNew
? new SvxBorderLine( *pNew
) : 0;
2636 if ( BOXINFO_LINE_HORI
== nLine
)
2641 else if ( BOXINFO_LINE_VERT
== nLine
)
2648 DBG_ERROR( "wrong line" );
2653 // -----------------------------------------------------------------------
2655 SfxPoolItem
* SvxBoxInfoItem::Clone( SfxItemPool
* ) const
2657 return new SvxBoxInfoItem( *this );
2660 //------------------------------------------------------------------------
2662 SfxItemPresentation
SvxBoxInfoItem::GetPresentation
2664 SfxItemPresentation
/*ePres*/,
2665 SfxMapUnit
/*eCoreUnit*/,
2666 SfxMapUnit
/*ePresUnit*/,
2667 XubString
& rText
, const IntlWrapper
*
2672 ResMgr* pMgr = DIALOG_MGR();
2675 rText += pHori->GetValueString();
2680 rText += pVert->GetValueString();
2684 rText += String( ResId( RID_SVXITEMS_BOXINF_TABLE_TRUE, pMgr ) );
2686 rText += String( ResId( RID_SVXITEMS_BOXINF_TABLE_FALSE, pMgr ) );
2689 rText += String( ResId( RID_SVXITEMS_BOXINF_DIST_TRUE, pMgr ) );
2691 rText += String( ResId( RID_SVXITEMS_BOXINF_DIST_FALSE, pMgr ) );
2694 rText += String( ResId( RID_SVXITEMS_BOXINF_MDIST_TRUE, pMgr ) );
2696 rText += String( ResId( RID_SVXITEMS_BOXINF_MDIST_FALSE, pMgr ) );
2699 return SFX_ITEM_PRESENTATION_NAMELESS;
2702 #endif // !SVX_LIGHT
2703 return SFX_ITEM_PRESENTATION_NONE
;
2706 // -----------------------------------------------------------------------
2708 SvStream
& SvxBoxInfoItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
2710 sal_Int8 cFlags
= 0;
2718 rStrm
<< (sal_Int8
) cFlags
2719 << (sal_uInt16
) GetDefDist();
2720 const SvxBorderLine
* pLine
[ 2 ];
2721 pLine
[ 0 ] = GetHori();
2722 pLine
[ 1 ] = GetVert();
2724 for( int i
= 0; i
< 2; i
++ )
2726 const SvxBorderLine
* l
= pLine
[ i
];
2731 << (short) l
->GetOutWidth()
2732 << (short) l
->GetInWidth()
2733 << (short) l
->GetDistance();
2740 // -----------------------------------------------------------------------
2742 int SvxBoxInfoItem::ScaleMetrics( long nMult
, long nDiv
)
2744 if ( pHori
) pHori
->ScaleMetrics( nMult
, nDiv
);
2745 if ( pVert
) pVert
->ScaleMetrics( nMult
, nDiv
);
2746 nDefDist
= (sal_uInt16
)Scale( nDefDist
, nMult
, nDiv
);
2750 // -----------------------------------------------------------------------
2752 int SvxBoxInfoItem::HasMetrics() const
2757 // -----------------------------------------------------------------------
2759 SfxPoolItem
* SvxBoxInfoItem::Create( SvStream
& rStrm
, sal_uInt16
) const
2762 sal_uInt16 _nDefDist
;
2763 rStrm
>> cFlags
>> _nDefDist
;
2765 SvxBoxInfoItem
* pAttr
= new SvxBoxInfoItem( Which() );
2767 pAttr
->SetTable ( ( cFlags
& 0x01 ) != 0 );
2768 pAttr
->SetDist ( ( cFlags
& 0x02 ) != 0 );
2769 pAttr
->SetMinDist( ( cFlags
& 0x04 ) != 0 );
2770 pAttr
->SetDefDist( _nDefDist
);
2779 short nOutline
, nInline
, nDistance
;
2781 rStrm
>> aColor
>> nOutline
>> nInline
>> nDistance
;
2782 SvxBorderLine
aBorder( &aColor
, nOutline
, nInline
, nDistance
);
2786 case 0: pAttr
->SetLine( &aBorder
, BOXINFO_LINE_HORI
); break;
2787 case 1: pAttr
->SetLine( &aBorder
, BOXINFO_LINE_VERT
); break;
2793 // -----------------------------------------------------------------------
2795 void SvxBoxInfoItem::ResetFlags()
2797 nValidFlags
= 0x7F; // alles g"ultig au/ser Disable
2800 sal_Bool
SvxBoxInfoItem::QueryValue( uno::Any
& rVal
, BYTE nMemberId
) const
2802 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
2803 table::BorderLine aRetLine
;
2805 sal_Bool bIntMember
= sal_False
;
2806 nMemberId
&= ~CONVERT_TWIPS
;
2807 sal_Bool bSerialize
= sal_False
;
2812 // 2 BorderLines, flags, valid flags and distance
2813 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aSeq( 5 );
2814 aSeq
[0] = ::com::sun::star::uno::makeAny( lcl_SvxLineToLine( pHori
, bConvert
) );
2815 aSeq
[1] = ::com::sun::star::uno::makeAny( lcl_SvxLineToLine( pVert
, bConvert
) );
2822 aSeq
[2] = ::com::sun::star::uno::makeAny( nVal
);
2824 aSeq
[3] = ::com::sun::star::uno::makeAny( nVal
);
2825 aSeq
[4] = ::com::sun::star::uno::makeAny( (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist()) );
2826 rVal
= ::com::sun::star::uno::makeAny( aSeq
);
2830 case MID_HORIZONTAL
:
2831 bSerialize
= sal_True
;
2832 aRetLine
= lcl_SvxLineToLine( pHori
, bConvert
);
2835 bSerialize
= sal_True
;
2836 aRetLine
= lcl_SvxLineToLine( pVert
, bConvert
);
2839 bIntMember
= sal_True
;
2848 case MID_VALIDFLAGS
:
2849 bIntMember
= sal_True
;
2854 bIntMember
= sal_True
;
2855 rVal
<<= (sal_Int32
)(bConvert
? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist());
2857 default: DBG_ERROR("Wrong MemberId!"); return sal_False
;
2865 ::com::sun::star::uno::Sequence < ::com::sun::star::uno::Any > aSeq(4);
2866 aSeq[0] <<= aRetLine.Color;
2867 aSeq[1] <<= aRetLine.InnerLineWidth;
2868 aSeq[2] <<= aRetLine.OuterLineWidth;
2869 aSeq[3] <<= aRetLine.LineDistance;
2880 // -----------------------------------------------------------------------
2882 sal_Bool
SvxBoxInfoItem::PutValue( const uno::Any
& rVal
, BYTE nMemberId
)
2884 sal_Bool bConvert
= 0!=(nMemberId
&CONVERT_TWIPS
);
2885 // sal_uInt16 nLine = BOX_LINE_TOP;
2886 // sal_Bool bDistMember = sal_False;
2887 nMemberId
&= ~CONVERT_TWIPS
;
2893 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aSeq
;
2894 if (( rVal
>>= aSeq
) && ( aSeq
.getLength() == 5 ))
2896 // 2 BorderLines, flags, valid flags and distance
2897 table::BorderLine aBorderLine
;
2898 SvxBorderLine aLine
;
2899 sal_Int16
nFlags( 0 );
2900 sal_Int32
nVal( 0 );
2901 if ( aSeq
[0] >>= aBorderLine
)
2903 sal_Bool bSet
= lcl_LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2905 SetLine( &aLine
, BOXINFO_LINE_HORI
);
2909 if ( aSeq
[1] >>= aBorderLine
)
2911 sal_Bool bSet
= lcl_LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2913 SetLine( &aLine
, BOXINFO_LINE_VERT
);
2917 if ( aSeq
[2] >>= nFlags
)
2919 SetTable ( ( nFlags
& 0x01 ) != 0 );
2920 SetDist ( ( nFlags
& 0x02 ) != 0 );
2921 SetMinDist( ( nFlags
& 0x04 ) != 0 );
2925 if ( aSeq
[3] >>= nFlags
)
2926 nValidFlags
= (BYTE
)nFlags
;
2929 if (( aSeq
[4] >>= nVal
) && ( nVal
>= 0 ))
2932 nVal
= MM100_TO_TWIP(nVal
);
2933 SetDefDist( (USHORT
)nVal
);
2939 case MID_HORIZONTAL
:
2942 if( !rVal
.hasValue() )
2945 table::BorderLine aBorderLine
;
2946 if( rVal
>>= aBorderLine
)
2950 else if (rVal
.getValueTypeClass() == uno::TypeClass_SEQUENCE
)
2952 // serialization for basic macro recording
2953 uno::Reference
< script::XTypeConverter
> xConverter
2954 ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")),
2957 uno::Sequence
< uno::Any
> aSeq
;
2958 try { aNew
= xConverter
->convertTo( rVal
, ::getCppuType((const uno::Sequence
< uno::Any
>*)0) ); }
2959 catch (uno::Exception
&) {}
2961 if( (aNew
>>= aSeq
) && aSeq
.getLength() == 4 )
2964 if ( aSeq
[0] >>= nVal
)
2965 aBorderLine
.Color
= nVal
;
2966 if ( aSeq
[1] >>= nVal
)
2967 aBorderLine
.InnerLineWidth
= (sal_Int16
) nVal
;
2968 if ( aSeq
[2] >>= nVal
)
2969 aBorderLine
.OuterLineWidth
= (sal_Int16
) nVal
;
2970 if ( aSeq
[3] >>= nVal
)
2971 aBorderLine
.LineDistance
= (sal_Int16
) nVal
;
2976 else if (rVal
.getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence
< sal_Int16
>*)0) )
2978 // serialization for basic macro recording
2979 ::com::sun::star::uno::Sequence
< sal_Int16
> aSeq
;
2981 if ( aSeq
.getLength() == 4 )
2983 aBorderLine
.Color
= aSeq
[0];
2984 aBorderLine
.InnerLineWidth
= aSeq
[1];
2985 aBorderLine
.OuterLineWidth
= aSeq
[2];
2986 aBorderLine
.LineDistance
= aSeq
[3];
2994 SvxBorderLine aLine
;
2995 sal_Bool bSet
= lcl_LineToSvxLine(aBorderLine
, aLine
, bConvert
);
2997 SetLine( &aLine
, nMemberId
== MID_HORIZONTAL
? BOXINFO_LINE_HORI
: BOXINFO_LINE_VERT
);
3002 sal_Int16 nFlags
= sal_Int16();
3003 bRet
= (rVal
>>= nFlags
);
3006 SetTable ( ( nFlags
& 0x01 ) != 0 );
3007 SetDist ( ( nFlags
& 0x02 ) != 0 );
3008 SetMinDist( ( nFlags
& 0x04 ) != 0 );
3013 case MID_VALIDFLAGS
:
3015 sal_Int16 nFlags
= sal_Int16();
3016 bRet
= (rVal
>>= nFlags
);
3018 nValidFlags
= (BYTE
)nFlags
;
3024 bRet
= (rVal
>>= nVal
);
3025 if ( bRet
&& nVal
>=0 )
3028 nVal
= MM100_TO_TWIP(nVal
);
3029 SetDefDist( (USHORT
)nVal
);
3033 default: DBG_ERROR("Wrong MemberId!"); return sal_False
;
3039 // class SvxFmtBreakItem -------------------------------------------------
3041 int SvxFmtBreakItem::operator==( const SfxPoolItem
& rAttr
) const
3043 DBG_ASSERT( SfxPoolItem::operator==( rAttr
), "unequal types" );
3045 return GetValue() == ( (SvxFmtBreakItem
&)rAttr
).GetValue();
3048 //------------------------------------------------------------------------
3050 SfxItemPresentation
SvxFmtBreakItem::GetPresentation
3052 SfxItemPresentation ePres
,
3053 SfxMapUnit
/*eCoreUnit*/,
3054 SfxMapUnit
/*ePresUnit*/,
3055 XubString
& rText
, const IntlWrapper
*
3061 case SFX_ITEM_PRESENTATION_NONE
:
3063 return SFX_ITEM_PRESENTATION_NONE
;
3065 case SFX_ITEM_PRESENTATION_NAMELESS
:
3066 case SFX_ITEM_PRESENTATION_COMPLETE
:
3067 rText
= GetValueTextByPos( GetValue() );
3069 default: ;//prevent warning
3071 #endif // !SVX_LIGHT
3072 return SFX_ITEM_PRESENTATION_NONE
;
3075 // -----------------------------------------------------------------------
3077 XubString
SvxFmtBreakItem::GetValueTextByPos( sal_uInt16 nPos
) const
3079 DBG_ASSERT( nPos
< SVX_BREAK_END
, "enum overflow!" );
3080 XubString
aStr( SVX_RES( RID_SVXITEMS_BREAK_BEGIN
+ nPos
) );
3084 // -----------------------------------------------------------------------
3085 sal_Bool
SvxFmtBreakItem::QueryValue( uno::Any
& rVal
, BYTE
/*nMemberId*/ ) const
3087 style::BreakType eBreak
= style::BreakType_NONE
;
3088 switch ( (SvxBreak
)GetValue() )
3090 case SVX_BREAK_COLUMN_BEFORE
: eBreak
= style::BreakType_COLUMN_BEFORE
; break;
3091 case SVX_BREAK_COLUMN_AFTER
: eBreak
= style::BreakType_COLUMN_AFTER
; break;
3092 case SVX_BREAK_COLUMN_BOTH
: eBreak
= style::BreakType_COLUMN_BOTH
; break;
3093 case SVX_BREAK_PAGE_BEFORE
: eBreak
= style::BreakType_PAGE_BEFORE
; break;
3094 case SVX_BREAK_PAGE_AFTER
: eBreak
= style::BreakType_PAGE_AFTER
; break;
3095 case SVX_BREAK_PAGE_BOTH
: eBreak
= style::BreakType_PAGE_BOTH
; break;
3096 default: ;//prevent warning
3101 // -----------------------------------------------------------------------
3102 sal_Bool
SvxFmtBreakItem::PutValue( const uno::Any
& rVal
, BYTE
/*nMemberId*/ )
3104 style::BreakType nBreak
;
3106 if(!(rVal
>>= nBreak
))
3108 sal_Int32 nValue
= 0;
3109 if(!(rVal
>>= nValue
))
3112 nBreak
= (style::BreakType
) nValue
;
3115 SvxBreak eBreak
= SVX_BREAK_NONE
;
3118 case style::BreakType_COLUMN_BEFORE
: eBreak
= SVX_BREAK_COLUMN_BEFORE
; break;
3119 case style::BreakType_COLUMN_AFTER
: eBreak
= SVX_BREAK_COLUMN_AFTER
; break;
3120 case style::BreakType_COLUMN_BOTH
: eBreak
= SVX_BREAK_COLUMN_BOTH
; break;
3121 case style::BreakType_PAGE_BEFORE
: eBreak
= SVX_BREAK_PAGE_BEFORE
; break;
3122 case style::BreakType_PAGE_AFTER
: eBreak
= SVX_BREAK_PAGE_AFTER
; break;
3123 case style::BreakType_PAGE_BOTH
: eBreak
= SVX_BREAK_PAGE_BOTH
; break;
3124 default: ;//prevent warning
3126 SetValue((sal_uInt16
) eBreak
);
3131 // -----------------------------------------------------------------------
3133 SfxPoolItem
* SvxFmtBreakItem::Clone( SfxItemPool
* ) const
3135 return new SvxFmtBreakItem( *this );
3138 // -----------------------------------------------------------------------
3140 SvStream
& SvxFmtBreakItem::Store( SvStream
& rStrm
, sal_uInt16 nItemVersion
) const
3142 rStrm
<< (sal_Int8
)GetValue();
3143 if( FMTBREAK_NOAUTO
> nItemVersion
)
3144 rStrm
<< (sal_Int8
)0x01;
3148 // -----------------------------------------------------------------------
3150 sal_uInt16
SvxFmtBreakItem::GetVersion( sal_uInt16 nFFVer
) const
3152 DBG_ASSERT( SOFFICE_FILEFORMAT_31
==nFFVer
||
3153 SOFFICE_FILEFORMAT_40
==nFFVer
||
3154 SOFFICE_FILEFORMAT_50
==nFFVer
,
3155 "SvxFmtBreakItem: Gibt es ein neues Fileformat?" );
3156 return SOFFICE_FILEFORMAT_31
==nFFVer
||
3157 SOFFICE_FILEFORMAT_40
==nFFVer
? 0 : FMTBREAK_NOAUTO
;
3160 // -----------------------------------------------------------------------
3162 SfxPoolItem
* SvxFmtBreakItem::Create( SvStream
& rStrm
, sal_uInt16 nVersion
) const
3164 sal_Int8 eBreak
, bDummy
;
3166 if( FMTBREAK_NOAUTO
> nVersion
)
3168 return new SvxFmtBreakItem( (const SvxBreak
)eBreak
, Which() );
3171 // -----------------------------------------------------------------------
3173 sal_uInt16
SvxFmtBreakItem::GetValueCount() const
3175 return SVX_BREAK_END
; // SVX_BREAK_PAGE_BOTH + 1
3178 // class SvxFmtKeepItem -------------------------------------------------
3180 SfxPoolItem
* SvxFmtKeepItem::Clone( SfxItemPool
* ) const
3182 return new SvxFmtKeepItem( *this );
3185 // -----------------------------------------------------------------------
3187 SvStream
& SvxFmtKeepItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
3189 rStrm
<< (sal_Int8
)GetValue();
3193 // -----------------------------------------------------------------------
3195 SfxPoolItem
* SvxFmtKeepItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3199 return new SvxFmtKeepItem( sal_Bool( bIsKeep
!= 0 ), Which() );
3202 //------------------------------------------------------------------------
3204 SfxItemPresentation
SvxFmtKeepItem::GetPresentation
3206 SfxItemPresentation ePres
,
3207 SfxMapUnit
/*eCoreUnit*/,
3208 SfxMapUnit
/*ePresUnit*/,
3209 XubString
& rText
, const IntlWrapper
*
3215 case SFX_ITEM_PRESENTATION_NONE
:
3219 case SFX_ITEM_PRESENTATION_NAMELESS
:
3220 case SFX_ITEM_PRESENTATION_COMPLETE
:
3222 sal_uInt16 nId
= RID_SVXITEMS_FMTKEEP_FALSE
;
3225 nId
= RID_SVXITEMS_FMTKEEP_TRUE
;
3226 rText
= SVX_RESSTR(nId
);
3229 default: ;//prevent warning
3232 return SFX_ITEM_PRESENTATION_NONE
;
3235 // class SvxLineItem ------------------------------------------------------
3237 SvxLineItem::SvxLineItem( const sal_uInt16 nId
) :
3239 SfxPoolItem ( nId
),
3245 // -----------------------------------------------------------------------
3247 SvxLineItem::SvxLineItem( const SvxLineItem
& rCpy
) :
3249 SfxPoolItem ( rCpy
)
3251 pLine
= rCpy
.GetLine() ? new SvxBorderLine( *rCpy
.GetLine() ) : 0;
3255 // -----------------------------------------------------------------------
3257 SvxLineItem::~SvxLineItem()
3262 // -----------------------------------------------------------------------
3264 SvxLineItem
& SvxLineItem::operator=( const SvxLineItem
& rLine
)
3266 SetLine( rLine
.GetLine() );
3271 // -----------------------------------------------------------------------
3273 int SvxLineItem::operator==( const SfxPoolItem
& rAttr
) const
3275 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
3277 return CmpBrdLn( pLine
, ((SvxLineItem
&)rAttr
).GetLine() );
3280 // -----------------------------------------------------------------------
3282 SfxPoolItem
* SvxLineItem::Clone( SfxItemPool
* ) const
3284 return new SvxLineItem( *this );
3287 sal_Bool
SvxLineItem::QueryValue( uno::Any
& rVal
, BYTE nMemId
) const
3289 sal_Bool bConvert
= 0!=(nMemId
&CONVERT_TWIPS
);
3290 nMemId
&= ~CONVERT_TWIPS
;
3293 rVal
<<= uno::makeAny( lcl_SvxLineToLine(pLine
, bConvert
) );
3300 case MID_FG_COLOR
: rVal
<<= sal_Int32(pLine
->GetColor().GetColor()); break;
3301 case MID_OUTER_WIDTH
: rVal
<<= sal_Int32(pLine
->GetOutWidth()); break;
3302 case MID_INNER_WIDTH
: rVal
<<= sal_Int32(pLine
->GetInWidth( )); break;
3303 case MID_DISTANCE
: rVal
<<= sal_Int32(pLine
->GetDistance()); break;
3305 DBG_ERROR( "Wrong MemberId" );
3313 // -----------------------------------------------------------------------
3315 sal_Bool
SvxLineItem::PutValue( const uno::Any
& rVal
, BYTE nMemId
)
3317 sal_Bool bConvert
= 0!=(nMemId
&CONVERT_TWIPS
);
3318 nMemId
&= ~CONVERT_TWIPS
;
3322 table::BorderLine aLine
;
3323 if ( rVal
>>= aLine
)
3326 pLine
= new SvxBorderLine
;
3327 if( !lcl_LineToSvxLine(aLine
, *pLine
, bConvert
) )
3333 else if ( rVal
>>= nVal
)
3336 pLine
= new SvxBorderLine
;
3340 case MID_FG_COLOR
: pLine
->SetColor( Color(nVal
) ); break;
3341 case MID_OUTER_WIDTH
: pLine
->SetOutWidth((USHORT
)nVal
); break;
3342 case MID_INNER_WIDTH
: pLine
->SetInWidth((USHORT
)nVal
); break;
3343 case MID_DISTANCE
: pLine
->SetDistance((USHORT
)nVal
); break;
3345 DBG_ERROR( "Wrong MemberId" );
3355 //------------------------------------------------------------------------
3357 SfxItemPresentation
SvxLineItem::GetPresentation
3359 SfxItemPresentation ePres
,
3360 SfxMapUnit eCoreUnit
,
3361 SfxMapUnit ePresUnit
,
3362 XubString
& rText
, const IntlWrapper
*pIntl
3370 case SFX_ITEM_PRESENTATION_NONE
:
3371 return SFX_ITEM_PRESENTATION_NONE
;
3372 case SFX_ITEM_PRESENTATION_NAMELESS
:
3373 case SFX_ITEM_PRESENTATION_COMPLETE
:
3376 rText
= pLine
->GetValueString( eCoreUnit
, ePresUnit
, pIntl
,
3377 (SFX_ITEM_PRESENTATION_COMPLETE
== ePres
) );
3380 default: ;//prevent warning
3383 return SFX_ITEM_PRESENTATION_NONE
;
3386 // -----------------------------------------------------------------------
3388 SvStream
& SvxLineItem::Store( SvStream
& rStrm
, sal_uInt16
/*nItemVersion*/ ) const
3392 rStrm
<< pLine
->GetColor()
3393 << (short)pLine
->GetOutWidth()
3394 << (short)pLine
->GetInWidth()
3395 << (short)pLine
->GetDistance();
3398 rStrm
<< Color() << (short)0 << (short)0 << (short)0;
3402 // -----------------------------------------------------------------------
3404 int SvxLineItem::ScaleMetrics( long nMult
, long nDiv
)
3406 if ( pLine
) pLine
->ScaleMetrics( nMult
, nDiv
);
3410 // -----------------------------------------------------------------------
3412 int SvxLineItem::HasMetrics() const
3417 // -----------------------------------------------------------------------
3419 SfxPoolItem
* SvxLineItem::Create( SvStream
& rStrm
, sal_uInt16
) const
3421 SvxLineItem
* _pLine
= new SvxLineItem( Which() );
3422 short nOutline
, nInline
, nDistance
;
3425 rStrm
>> aColor
>> nOutline
>> nInline
>> nDistance
;
3428 SvxBorderLine
aLine( &aColor
, nOutline
, nInline
, nDistance
);
3429 _pLine
->SetLine( &aLine
);
3434 // -----------------------------------------------------------------------
3436 void SvxLineItem::SetLine( const SvxBorderLine
* pNew
)
3439 pLine
= pNew
? new SvxBorderLine( *pNew
) : 0;
3443 #pragma optimize ( "", off )
3446 // class SvxBrushItem ----------------------------------------------------
3448 #define LOAD_GRAPHIC ((sal_uInt16)0x0001)
3449 #define LOAD_LINK ((sal_uInt16)0x0002)
3450 #define LOAD_FILTER ((sal_uInt16)0x0004)
3452 // class SvxBrushItem_Impl -----------------------------------------------
3454 class SvxBrushItem_Impl
3457 GraphicObject
* pGraphicObject
;
3458 sal_Int8 nGraphicTransparency
; //contains a percentage value which is
3459 //copied to the GraphicObject when necessary
3461 SfxMediumRef xMedium
;
3465 SvxBrushItem_Impl( GraphicObject
* p
) : pGraphicObject( p
), nGraphicTransparency(0) {}
3468 // class SvxBrushItemLink_Impl -------------------------------------------
3470 class SvxBrushItemLink_Impl : public SfxBrushItemLink
3472 virtual Graphic GetGraphic( const String& rLink, const String& rFilter );
3473 virtual CreateSvxBrushTabPage GetBackgroundTabpageCreateFunc();
3474 virtual GetSvxBrushTabPageRanges GetBackgroundTabpageRanges();
3477 // -----------------------------------------------------------------------
3479 Graphic SvxBrushItemLink_Impl::GetGraphic( const String& rLink, const String& rFilter)
3482 SvxBrushItem aItem( rLink, rFilter, GPOS_TILED );
3483 const Graphic* pGraph = aItem.GetGraphic();
3489 // -----------------------------------------------------------------------
3491 CreateSvxBrushTabPage SvxBrushItemLink_Impl::GetBackgroundTabpageCreateFunc()
3494 return (CreateSvxBrushTabPage)SvxBackgroundTabPage::Create;
3496 return CreateSvxBrushTabPage();
3500 // -----------------------------------------------------------------------
3502 GetSvxBrushTabPageRanges SvxBrushItemLink_Impl::GetBackgroundTabpageRanges()
3505 return (GetSvxBrushTabPageRanges)SvxBackgroundTabPage::GetRanges;
3507 return GetSvxBrushTabPageRanges();
3511 // -----------------------------------------------------------------------
3513 void SvxBrushItem::InitSfxLink()
3515 SfxBrushItemLink::Set( new SvxBrushItemLink_Impl );
3518 // -----------------------------------------------------------------------
3520 void SvxBrushItem::SetDoneLink( const Link
& rLink
)
3522 pImpl
->aDoneLink
= rLink
;
3525 // -----------------------------------------------------------------------
3527 SvxBrushItem::SvxBrushItem( sal_uInt16 _nWhich
) :
3529 SfxPoolItem( _nWhich
),
3531 aColor ( COL_TRANSPARENT
),
3532 pImpl ( new SvxBrushItem_Impl( 0 ) ),
3534 pStrFilter ( NULL
),
3535 eGraphicPos ( GPOS_NONE
),
3536 bLoadAgain ( sal_True
)
3541 // -----------------------------------------------------------------------
3543 SvxBrushItem::SvxBrushItem( const Color
& rColor
, sal_uInt16 _nWhich
) :
3545 SfxPoolItem( _nWhich
),
3548 pImpl ( new SvxBrushItem_Impl( 0 ) ),
3550 pStrFilter ( NULL
),
3551 eGraphicPos ( GPOS_NONE
),
3552 bLoadAgain ( sal_True
)
3557 // -----------------------------------------------------------------------
3559 SvxBrushItem::SvxBrushItem( const Graphic
& rGraphic
, SvxGraphicPosition ePos
,
3560 sal_uInt16 _nWhich
) :
3562 SfxPoolItem( _nWhich
),
3564 aColor ( COL_TRANSPARENT
),
3565 pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphic
) ) ),
3567 pStrFilter ( NULL
),
3568 eGraphicPos ( ( GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
),
3569 bLoadAgain ( sal_True
)
3572 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3575 // -----------------------------------------------------------------------
3577 SvxBrushItem::SvxBrushItem( const GraphicObject
& rGraphicObj
,
3578 SvxGraphicPosition ePos
, sal_uInt16 _nWhich
) :
3580 SfxPoolItem( _nWhich
),
3582 aColor ( COL_TRANSPARENT
),
3583 pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphicObj
) ) ),
3585 pStrFilter ( NULL
),
3586 eGraphicPos ( ( GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
),
3587 bLoadAgain ( sal_True
)
3590 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3593 // -----------------------------------------------------------------------
3595 SvxBrushItem::SvxBrushItem(
3596 const String
& rLink
, const String
& rFilter
,
3597 SvxGraphicPosition ePos
, sal_uInt16 _nWhich
) :
3599 SfxPoolItem( _nWhich
),
3601 aColor ( COL_TRANSPARENT
),
3602 pImpl ( new SvxBrushItem_Impl( NULL
) ),
3603 pStrLink ( new String( rLink
) ),
3604 pStrFilter ( new String( rFilter
) ),
3605 eGraphicPos ( ( GPOS_NONE
!= ePos
) ? ePos
: GPOS_MM
),
3606 bLoadAgain ( sal_True
)
3609 DBG_ASSERT( GPOS_NONE
!= ePos
, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3612 // -----------------------------------------------------------------------
3614 SvxBrushItem::SvxBrushItem( SvStream
& rStream
, sal_uInt16 nVersion
,
3615 sal_uInt16 _nWhich
) :
3617 SfxPoolItem( _nWhich
),
3619 aColor ( COL_TRANSPARENT
),
3620 pImpl ( new SvxBrushItem_Impl( NULL
) ),
3622 pStrFilter ( NULL
),
3623 eGraphicPos ( GPOS_NONE
)
3628 Color aTempFillColor
;
3632 rStream
>> aTempColor
;
3633 rStream
>> aTempFillColor
;
3640 sal_uInt32 nRed
= aTempColor
.GetRed();
3641 sal_uInt32 nGreen
= aTempColor
.GetGreen();
3642 sal_uInt32 nBlue
= aTempColor
.GetBlue();
3643 nRed
+= (sal_uInt32
)(aTempFillColor
.GetRed())*2;
3644 nGreen
+= (sal_uInt32
)(aTempFillColor
.GetGreen())*2;
3645 nBlue
+= (sal_uInt32
)(aTempFillColor
.GetBlue())*2;
3646 aColor
= Color( (sal_Int8
)(nRed
/3), (sal_Int8
)(nGreen
/3), (sal_Int8
)(nBlue
/3) );
3652 sal_uInt32 nRed
= aTempColor
.GetRed();
3653 sal_uInt32 nGreen
= aTempColor
.GetGreen();
3654 sal_uInt32 nBlue
= aTempColor
.GetBlue();
3655 nRed
+= (sal_uInt32
)(aTempFillColor
.GetRed());
3656 nGreen
+= (sal_uInt32
)(aTempFillColor
.GetGreen());
3657 nBlue
+= (sal_uInt32
)(aTempFillColor
.GetBlue());
3658 aColor
= Color( (sal_Int8
)(nRed
/2), (sal_Int8
)(nGreen
/2), (sal_Int8
)(nBlue
/2) );
3664 sal_uInt32 nRed
= aTempColor
.GetRed()*2;
3665 sal_uInt32 nGreen
= aTempColor
.GetGreen()*2;
3666 sal_uInt32 nBlue
= aTempColor
.GetBlue()*2;
3667 nRed
+= (sal_uInt32
)(aTempFillColor
.GetRed());
3668 nGreen
+= (sal_uInt32
)(aTempFillColor
.GetGreen());
3669 nBlue
+= (sal_uInt32
)(aTempFillColor
.GetBlue());
3670 aColor
= Color( (sal_Int8
)(nRed
/3), (sal_Int8
)(nGreen
/3), (sal_Int8
)(nBlue
/3) );
3674 case 0://BRUSH_NULL:
3675 aColor
= Color( COL_TRANSPARENT
);
3679 aColor
= aTempColor
;
3682 if ( nVersion
>= BRUSH_GRAPHIC_VERSION
)
3684 sal_uInt16 nDoLoad
= 0;
3689 if ( nDoLoad
& LOAD_GRAPHIC
)
3693 rStream
>> aGraphic
;
3694 pImpl
->pGraphicObject
= new GraphicObject( aGraphic
);
3696 if( SVSTREAM_FILEFORMAT_ERROR
== rStream
.GetError() )
3698 rStream
.ResetError();
3699 rStream
.SetError( ERRCODE_SVX_GRAPHIC_WRONG_FILEFORMAT
|
3700 ERRCODE_WARNING_MASK
);
3704 if ( nDoLoad
& LOAD_LINK
)
3707 // UNICODE: rStream >> aRel;
3708 rStream
.ReadByteString(aRel
);
3710 // TODO/MBA: how can we get a BaseURL here?!
3711 DBG_ERROR("No BaseURL!");
3712 String aAbs
= INetURLObject::GetAbsURL( String(), aRel
);
3713 DBG_ASSERT( aAbs
.Len(), "Invalid URL!" );
3714 pStrLink
= new String( aAbs
);
3717 if ( nDoLoad
& LOAD_FILTER
)
3719 pStrFilter
= new String
;
3720 // UNICODE: rStream >> *pStrFilter;
3721 rStream
.ReadByteString(*pStrFilter
);
3726 eGraphicPos
= (SvxGraphicPosition
)nPos
;
3730 // -----------------------------------------------------------------------
3732 SvxBrushItem::SvxBrushItem( const SvxBrushItem
& rItem
) :
3734 SfxPoolItem( rItem
.Which() ),
3736 pImpl ( new SvxBrushItem_Impl( NULL
) ),
3738 pStrFilter ( NULL
),
3739 eGraphicPos ( GPOS_NONE
),
3740 bLoadAgain ( sal_True
)
3746 // -----------------------------------------------------------------------
3748 SvxBrushItem::~SvxBrushItem()
3751 if( pImpl
->xMedium
.Is() )
3752 pImpl
->xMedium
->SetDoneLink( Link() );
3754 delete pImpl
->pGraphicObject
;
3760 // -----------------------------------------------------------------------
3762 sal_uInt16
SvxBrushItem::GetVersion( sal_uInt16
/*nFileVersion*/ ) const
3764 return BRUSH_GRAPHIC_VERSION
;
3767 // -----------------------------------------------------------------------
3768 inline sal_Int8
lcl_PercentToTransparency(long nPercent
)
3770 //0xff must not be returned!
3771 return sal_Int8(nPercent
? (50 + 0xfe * nPercent
) / 100 : 0);
3773 inline sal_Int8
lcl_TransparencyToPercent(sal_Int32 nTrans
)
3775 return (sal_Int8
)((nTrans
* 100 + 127) / 254);
3778 sal_Bool
SvxBrushItem::QueryValue( uno::Any
& rVal
, BYTE nMemberId
) const
3780 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3781 nMemberId
&= ~CONVERT_TWIPS
;
3784 case MID_BACK_COLOR
:
3785 rVal
<<= (sal_Int32
)( aColor
.GetColor() );
3787 case MID_BACK_COLOR_R_G_B
:
3788 rVal
<<= (sal_Int32
)( aColor
.GetRGBColor() );
3790 case MID_BACK_COLOR_TRANSPARENCY
:
3791 rVal
<<= lcl_TransparencyToPercent(aColor
.GetTransparency());
3793 case MID_GRAPHIC_POSITION
:
3794 rVal
<<= (style::GraphicLocation
)(sal_Int16
)eGraphicPos
;
3798 DBG_ERRORFILE( "not implemented" );
3801 case MID_GRAPHIC_TRANSPARENT
:
3802 rVal
= Bool2Any( aColor
.GetTransparency() == 0xff );
3805 case MID_GRAPHIC_URL
:
3810 else if( pImpl
->pGraphicObject
)
3812 OUString
sPrefix(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX
));
3813 String
sId( pImpl
->pGraphicObject
->GetUniqueID(),
3814 RTL_TEXTENCODING_ASCII_US
);
3816 sLink
+= OUString(sId
);
3822 case MID_GRAPHIC_FILTER
:
3826 sFilter
= *pStrFilter
;
3830 case MID_GRAPHIC_TRANSPARENCY
:
3831 rVal
<<= pImpl
->nGraphicTransparency
;
3838 // -----------------------------------------------------------------------
3840 sal_Bool
SvxBrushItem::PutValue( const uno::Any
& rVal
, BYTE nMemberId
)
3842 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3843 nMemberId
&= ~CONVERT_TWIPS
;
3846 case MID_BACK_COLOR
:
3847 case MID_BACK_COLOR_R_G_B
:
3850 if ( !( rVal
>>= nCol
) )
3852 if(MID_BACK_COLOR_R_G_B
== nMemberId
)
3854 nCol
= COLORDATA_RGB( nCol
);
3855 nCol
+= aColor
.GetColor() & 0xff000000;
3857 aColor
= Color( nCol
);
3860 case MID_BACK_COLOR_TRANSPARENCY
:
3862 sal_Int32 nTrans
= 0;
3863 if ( !( rVal
>>= nTrans
) || nTrans
< 0 || nTrans
> 100 )
3865 aColor
.SetTransparency(lcl_PercentToTransparency(nTrans
));
3869 case MID_GRAPHIC_POSITION
:
3871 style::GraphicLocation eLocation
;
3872 if ( !( rVal
>>=eLocation
) )
3874 sal_Int32 nValue
= 0;
3875 if ( !( rVal
>>= nValue
) )
3877 eLocation
= (style::GraphicLocation
)nValue
;
3879 SetGraphicPos( (SvxGraphicPosition
)(sal_uInt16
)eLocation
);
3884 DBG_ERRORFILE( "not implemented" );
3887 case MID_GRAPHIC_TRANSPARENT
:
3888 aColor
.SetTransparency( Any2Bool( rVal
) ? 0xff : 0 );
3891 case MID_GRAPHIC_URL
:
3893 if ( rVal
.getValueType() == ::getCppuType( (OUString
*)0 ) )
3897 if( 0 == sLink
.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX
,
3898 sizeof(UNO_NAME_GRAPHOBJ_URLPKGPREFIX
)-1 ) )
3900 DBG_ERROR( "package urls aren't implemented" );
3902 else if( 0 == sLink
.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX
,
3903 sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX
)-1 ) )
3905 DELETEZ( pStrLink
);
3906 String
sTmp( sLink
);
3907 ByteString
sId( sTmp
.Copy(
3908 sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX
)-1),
3909 RTL_TEXTENCODING_ASCII_US
);
3910 GraphicObject
*pOldGrfObj
= pImpl
->pGraphicObject
;
3911 pImpl
->pGraphicObject
= new GraphicObject( sId
);
3912 ApplyGraphicTransparency_Impl();
3917 SetGraphicLink(sLink
);
3919 if ( sLink
.getLength() && eGraphicPos
== GPOS_NONE
)
3920 eGraphicPos
= GPOS_MM
;
3921 else if( !sLink
.getLength() )
3922 eGraphicPos
= GPOS_NONE
;
3927 case MID_GRAPHIC_FILTER
:
3929 if( rVal
.getValueType() == ::getCppuType( (OUString
*)0 ) )
3933 SetGraphicFilter( sLink
);
3937 case MID_GRAPHIC_TRANSPARENCY
:
3941 if(nTmp
>= 0 && nTmp
<= 100)
3943 pImpl
->nGraphicTransparency
= sal_Int8(nTmp
);
3944 if(pImpl
->pGraphicObject
)
3945 ApplyGraphicTransparency_Impl();
3954 // -----------------------------------------------------------------------
3956 SfxItemPresentation
SvxBrushItem::GetPresentation
3958 SfxItemPresentation ePres
,
3959 SfxMapUnit
/*eCoreUnit*/,
3960 SfxMapUnit
/*ePresUnit*/,
3961 XubString
& rText
, const IntlWrapper
*
3967 case SFX_ITEM_PRESENTATION_NONE
:
3971 case SFX_ITEM_PRESENTATION_NAMELESS
:
3972 case SFX_ITEM_PRESENTATION_COMPLETE
:
3974 if ( GPOS_NONE
== eGraphicPos
)
3976 rText
= ::GetColorString( aColor
);
3978 sal_uInt16 nId
= RID_SVXITEMS_TRANSPARENT_FALSE
;
3980 if ( aColor
.GetTransparency() )
3981 nId
= RID_SVXITEMS_TRANSPARENT_TRUE
;
3982 rText
+= SVX_RESSTR(nId
);
3986 rText
= SVX_RESSTR(RID_SVXITEMS_GRAPHIC
);
3991 default: ;//prevent warning
3993 #endif // !SVX_LIGHT
3994 return SFX_ITEM_PRESENTATION_NONE
;
3997 // -----------------------------------------------------------------------
3999 SvxBrushItem
& SvxBrushItem::operator=( const SvxBrushItem
& rItem
)
4001 aColor
= rItem
.aColor
;
4002 eGraphicPos
= rItem
.eGraphicPos
;
4004 DELETEZ( pImpl
->pGraphicObject
);
4005 DELETEZ( pStrLink
);
4006 DELETEZ( pStrFilter
);
4008 if ( GPOS_NONE
!= eGraphicPos
)
4010 if ( rItem
.pStrLink
)
4011 pStrLink
= new String( *rItem
.pStrLink
);
4012 if ( rItem
.pStrFilter
)
4013 pStrFilter
= new String( *rItem
.pStrFilter
);
4014 if ( rItem
.pImpl
->pGraphicObject
)
4016 pImpl
->pGraphicObject
= new GraphicObject( *rItem
.pImpl
->pGraphicObject
);
4019 pImpl
->nGraphicTransparency
= rItem
.pImpl
->nGraphicTransparency
;
4023 // -----------------------------------------------------------------------
4025 int SvxBrushItem::operator==( const SfxPoolItem
& rAttr
) const
4027 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
4029 SvxBrushItem
& rCmp
= (SvxBrushItem
&)rAttr
;
4030 sal_Bool bEqual
= ( aColor
== rCmp
.aColor
&& eGraphicPos
== rCmp
.eGraphicPos
&&
4031 pImpl
->nGraphicTransparency
== rCmp
.pImpl
->nGraphicTransparency
);
4035 if ( GPOS_NONE
!= eGraphicPos
)
4037 if ( !rCmp
.pStrLink
)
4040 bEqual
= pStrLink
&& ( *pStrLink
== *rCmp
.pStrLink
);
4044 if ( !rCmp
.pStrFilter
)
4045 bEqual
= !pStrFilter
;
4047 bEqual
= pStrFilter
&& ( *pStrFilter
== *rCmp
.pStrFilter
);
4050 if ( bEqual
&& !rCmp
.pStrLink
)
4052 if ( !rCmp
.pImpl
->pGraphicObject
)
4053 bEqual
= !pImpl
->pGraphicObject
;
4055 bEqual
= pImpl
->pGraphicObject
&&
4056 ( *pImpl
->pGraphicObject
== *rCmp
.pImpl
->pGraphicObject
);
4064 // -----------------------------------------------------------------------
4066 SfxPoolItem
* SvxBrushItem::Clone( SfxItemPool
* ) const
4068 return new SvxBrushItem( *this );
4071 // -----------------------------------------------------------------------
4073 SfxPoolItem
* SvxBrushItem::Create( SvStream
& rStream
, sal_uInt16 nVersion
) const
4075 return new SvxBrushItem( rStream
, nVersion
, Which() );
4078 // -----------------------------------------------------------------------
4080 SvStream
& SvxBrushItem::Store( SvStream
& rStream
, sal_uInt16
/*nItemVersion*/ ) const
4082 rStream
<< (sal_Bool
)sal_False
;
4085 rStream
<< (sal_Int8
)(aColor
.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
4087 sal_uInt16 nDoLoad
= 0;
4089 if ( pImpl
->pGraphicObject
&& !pStrLink
)
4090 nDoLoad
|= LOAD_GRAPHIC
;
4092 nDoLoad
|= LOAD_LINK
;
4094 nDoLoad
|= LOAD_FILTER
;
4097 if ( pImpl
->pGraphicObject
&& !pStrLink
)
4098 rStream
<< pImpl
->pGraphicObject
->GetGraphic();
4101 DBG_ERROR("No BaseURL!");
4102 // TODO/MBA: how to get a BaseURL?!
4103 String aRel
= INetURLObject::GetRelURL( String(), *pStrLink
);
4104 // UNICODE: rStream << aRel;
4105 rStream
.WriteByteString(aRel
);
4109 // UNICODE: rStream << *pStrFilter;
4110 rStream
.WriteByteString(*pStrFilter
);
4112 rStream
<< (sal_Int8
)eGraphicPos
;
4116 // -----------------------------------------------------------------------
4117 // const wegcasten, da const als logisches const zu verstehen ist
4118 // wenn GetGraphic() gerufen wird, soll sich das Item darum kuemmern,
4119 // eine gelinkte Grafik zu holen.
4121 GraphicFilter
* GetGrfFilter();
4123 IMPL_STATIC_LINK( SvxBrushItem
, DoneHdl_Impl
, void*, EMPTYARG
)
4126 pThis
->pImpl
->pGraphicObject
= new GraphicObject
;
4127 SvStream
* pStream
= pThis
->pImpl
->xMedium
->GetInStream();
4128 if( pStream
&& !pStream
->GetError() )
4132 pStream
->Seek( STREAM_SEEK_TO_BEGIN
);
4133 nRes
= GetGrfFilter()->
4134 ImportGraphic( aGraphic
, *pThis
->pStrLink
, *pStream
,
4135 GRFILTER_FORMAT_DONTKNOW
, NULL
, GRFILTER_I_FLAGS_DONT_SET_LOGSIZE_FOR_JPEG
);
4137 if( nRes
!= GRFILTER_OK
)
4139 DELETEZ( pThis
->pImpl
->pGraphicObject
);
4140 pThis
->bLoadAgain
= sal_False
;
4144 pThis
->pImpl
->pGraphicObject
->SetGraphic( aGraphic
);
4145 pThis
->ApplyGraphicTransparency_Impl();
4150 DELETEZ( pThis
->pImpl
->pGraphicObject
);
4151 pThis
->bLoadAgain
= sal_False
;
4154 pThis
->pImpl
->xMedium
.Clear();
4155 pThis
->pImpl
->aDoneLink
.Call( pThis
);
4160 // -----------------------------------------------------------------------
4162 void SvxBrushItem::PurgeGraphic() const
4166 DELETEZ( pImpl
->pGraphicObject
);
4167 ((SvxBrushItem
*)this)->bLoadAgain
= sal_True
;
4171 // -----------------------------------------------------------------------
4173 void SvxBrushItem::PurgeMedium() const
4176 pImpl
->xMedium
.Clear();
4180 // -----------------------------------------------------------------------
4182 const GraphicObject
* SvxBrushItem::GetGraphicObject( SfxObjectShell
* pSh
) const
4185 if ( bLoadAgain
&& pStrLink
&& !pImpl
->pGraphicObject
&& !pImpl
->xMedium
.Is() )
4186 // wenn Grafik schon geladen, als Cache benutzen
4188 //JP 29.6.2001: only with "valid" names - empty names now allowed
4189 if( pStrLink
->Len() )
4191 pImpl
->xMedium
= new SfxMedium(
4192 *pStrLink
, STREAM_STD_READ
, sal_False
);
4194 if( pImpl
->xMedium
->IsRemote() )
4198 pSh
->RegisterTransfer( *pImpl
->xMedium
);
4202 DBG_WARNING( "SvxBrushItem::GetGraphic ohne DocShell" );
4206 SfxMediumRef
xRef( pImpl
->xMedium
);
4207 // Ref halten wg. synchr. DoneCallback
4208 if( pImpl
->aDoneLink
.IsSet() )
4210 // Auf besonderen Wunsch des Writers wird der synchrone und der
4211 // asynchrone Fall was die Benachrichtigung angeht unterschiedlich
4212 // behandelt. Der Callback erfolgt nur bei asynchronem Eintreffen
4215 Link aTmp
= pImpl
->aDoneLink
;
4216 pImpl
->aDoneLink
= Link();
4217 pImpl
->xMedium
->DownLoad(
4218 STATIC_LINK( this, SvxBrushItem
, DoneHdl_Impl
) );
4219 pImpl
->aDoneLink
= aTmp
;
4223 pImpl
->xMedium
->DownLoad( );
4224 DoneHdl_Impl( (SvxBrushItem
*)this, 0 );
4229 return pImpl
->pGraphicObject
;
4232 // -----------------------------------------------------------------------
4234 const Graphic
* SvxBrushItem::GetGraphic( SfxObjectShell
* pSh
) const
4236 const GraphicObject
* pGrafObj
= GetGraphicObject( pSh
);
4237 return( pGrafObj
? &( pGrafObj
->GetGraphic() ) : NULL
);
4240 // -----------------------------------------------------------------------
4242 void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew
)
4246 if ( GPOS_NONE
== eGraphicPos
)
4248 DELETEZ( pImpl
->pGraphicObject
);
4249 DELETEZ( pStrLink
);
4250 DELETEZ( pStrFilter
);
4254 if ( !pImpl
->pGraphicObject
&& !pStrLink
)
4256 pImpl
->pGraphicObject
= new GraphicObject
; // dummy anlegen
4261 // -----------------------------------------------------------------------
4263 void SvxBrushItem::SetGraphic( const Graphic
& rNew
)
4267 if ( pImpl
->pGraphicObject
)
4268 pImpl
->pGraphicObject
->SetGraphic( rNew
);
4270 pImpl
->pGraphicObject
= new GraphicObject( rNew
);
4272 ApplyGraphicTransparency_Impl();
4274 if ( GPOS_NONE
== eGraphicPos
)
4275 eGraphicPos
= GPOS_MM
; // None waere Brush, also Default: Mitte
4279 DBG_ERROR( "SetGraphic() on linked graphic! :-/" );
4283 // -----------------------------------------------------------------------
4285 void SvxBrushItem::SetGraphicObject( const GraphicObject
& rNewObj
)
4289 if ( pImpl
->pGraphicObject
)
4290 *pImpl
->pGraphicObject
= rNewObj
;
4292 pImpl
->pGraphicObject
= new GraphicObject( rNewObj
);
4294 ApplyGraphicTransparency_Impl();
4296 if ( GPOS_NONE
== eGraphicPos
)
4297 eGraphicPos
= GPOS_MM
; // None waere Brush, also Default: Mitte
4301 DBG_ERROR( "SetGraphic() on linked graphic! :-/" );
4305 // -----------------------------------------------------------------------
4307 void SvxBrushItem::SetGraphicLink( const String
& rNew
)
4310 DELETEZ( pStrLink
);
4316 pStrLink
= new String( rNew
);
4318 DELETEZ( pImpl
->pGraphicObject
);
4322 // -----------------------------------------------------------------------
4324 void SvxBrushItem::SetGraphicFilter( const String
& rNew
)
4327 DELETEZ( pStrFilter
);
4333 pStrFilter
= new String( rNew
);
4338 SvxGraphicPosition
SvxBrushItem::WallpaperStyle2GraphicPos( WallpaperStyle eStyle
)
4340 SvxGraphicPosition eResult
;
4341 // der Switch ist nicht der schnellste, dafuer aber am sichersten
4344 case WALLPAPER_NULL
: eResult
= GPOS_NONE
; break;
4345 case WALLPAPER_TILE
: eResult
= GPOS_TILED
; break;
4346 case WALLPAPER_CENTER
: eResult
= GPOS_MM
; break;
4347 case WALLPAPER_SCALE
: eResult
= GPOS_AREA
; break;
4348 case WALLPAPER_TOPLEFT
: eResult
= GPOS_LT
; break;
4349 case WALLPAPER_TOP
: eResult
= GPOS_MT
; break;
4350 case WALLPAPER_TOPRIGHT
: eResult
= GPOS_RT
; break;
4351 case WALLPAPER_LEFT
: eResult
= GPOS_LM
; break;
4352 case WALLPAPER_RIGHT
: eResult
= GPOS_RM
; break;
4353 case WALLPAPER_BOTTOMLEFT
: eResult
= GPOS_LB
; break;
4354 case WALLPAPER_BOTTOM
: eResult
= GPOS_MB
; break;
4355 case WALLPAPER_BOTTOMRIGHT
: eResult
= GPOS_RB
; break;
4356 default: eResult
= GPOS_NONE
;
4362 WallpaperStyle
SvxBrushItem::GraphicPos2WallpaperStyle( SvxGraphicPosition ePos
)
4364 WallpaperStyle eResult
;
4367 case GPOS_NONE
: eResult
= WALLPAPER_NULL
; break;
4368 case GPOS_TILED
: eResult
= WALLPAPER_TILE
; break;
4369 case GPOS_MM
: eResult
= WALLPAPER_CENTER
; break;
4370 case GPOS_AREA
: eResult
= WALLPAPER_SCALE
; break;
4371 case GPOS_LT
: eResult
= WALLPAPER_TOPLEFT
; break;
4372 case GPOS_MT
: eResult
= WALLPAPER_TOP
; break;
4373 case GPOS_RT
: eResult
= WALLPAPER_TOPRIGHT
; break;
4374 case GPOS_LM
: eResult
= WALLPAPER_LEFT
; break;
4375 case GPOS_RM
: eResult
= WALLPAPER_RIGHT
; break;
4376 case GPOS_LB
: eResult
= WALLPAPER_BOTTOMLEFT
; break;
4377 case GPOS_MB
: eResult
= WALLPAPER_BOTTOM
; break;
4378 case GPOS_RB
: eResult
= WALLPAPER_BOTTOMRIGHT
; break;
4379 default: eResult
= WALLPAPER_NULL
;
4385 SvxBrushItem::SvxBrushItem( const CntWallpaperItem
& rItem
, sal_uInt16 _nWhich
) :
4386 SfxPoolItem( _nWhich
),
4387 pImpl( new SvxBrushItem_Impl( 0 ) ),
4390 bLoadAgain( sal_True
)
4392 aColor
= rItem
.GetColor();
4394 if( rItem
.GetBitmapURL().Len() )
4396 pStrLink
= new String( rItem
.GetBitmapURL() );
4397 SetGraphicPos( WallpaperStyle2GraphicPos((WallpaperStyle
)rItem
.GetStyle() ) );
4401 CntWallpaperItem
* SvxBrushItem::CreateCntWallpaperItem() const
4403 CntWallpaperItem
* pItem
= new CntWallpaperItem( 0 );
4404 pItem
->SetColor( aColor
.GetColor() );
4405 pItem
->SetStyle( (USHORT
)GraphicPos2WallpaperStyle( GetGraphicPos() ) );
4406 sal_Bool bLink
= (pStrLink
!= 0);
4409 String aURL
= *pStrLink
;
4410 pItem
->SetBitmapURL( aURL
);
4412 if( pImpl
->pGraphicObject
)
4414 DBG_ERRORFILE( "Don't know what to do with a graphic" );
4416 // pItem->SetGraphic( *pImpl->pGraphic, bLink );
4422 #pragma optimize ( "", on )
4424 /* -----------------------------16.08.2002 09:18------------------------------
4426 ---------------------------------------------------------------------------*/
4427 void SvxBrushItem::ApplyGraphicTransparency_Impl()
4429 DBG_ASSERT(pImpl
->pGraphicObject
, "no GraphicObject available" );
4430 if(pImpl
->pGraphicObject
)
4432 GraphicAttr
aAttr(pImpl
->pGraphicObject
->GetAttr());
4433 aAttr
.SetTransparency(lcl_PercentToTransparency(
4434 pImpl
->nGraphicTransparency
));
4435 pImpl
->pGraphicObject
->SetAttr(aAttr
);
4438 // class SvxFrameDirectionItem ----------------------------------------------
4440 SvxFrameDirectionItem::SvxFrameDirectionItem( USHORT _nWhich
)
4441 : SfxUInt16Item( _nWhich
, (UINT16
)FRMDIR_HORI_LEFT_TOP
)
4445 SvxFrameDirectionItem::SvxFrameDirectionItem( SvxFrameDirection nValue
,
4447 : SfxUInt16Item( _nWhich
, (UINT16
)nValue
)
4451 SvxFrameDirectionItem::~SvxFrameDirectionItem()
4455 int SvxFrameDirectionItem::operator==( const SfxPoolItem
& rCmp
) const
4457 DBG_ASSERT( SfxPoolItem::operator==(rCmp
), "unequal types" );
4459 return GetValue() == ((SvxFrameDirectionItem
&)rCmp
).GetValue();
4462 SfxPoolItem
* SvxFrameDirectionItem::Clone( SfxItemPool
* ) const
4464 return new SvxFrameDirectionItem( *this );
4467 SfxPoolItem
* SvxFrameDirectionItem::Create( SvStream
& rStrm
, USHORT
/*nVer*/ ) const
4471 return new SvxFrameDirectionItem( (SvxFrameDirection
)nValue
, Which() );
4474 SvStream
& SvxFrameDirectionItem::Store( SvStream
& rStrm
, USHORT
/*nIVer*/ ) const
4476 sal_uInt16 nValue
= GetValue();
4481 USHORT
SvxFrameDirectionItem::GetVersion( USHORT nFVer
) const
4483 return SOFFICE_FILEFORMAT_50
> nFVer
? USHRT_MAX
: 0;
4486 SfxItemPresentation
SvxFrameDirectionItem::GetPresentation(
4487 SfxItemPresentation ePres
,
4488 SfxMapUnit
/*eCoreUnit*/,
4489 SfxMapUnit
/*ePresUnit*/,
4490 XubString
& rText
, const IntlWrapper
*) const
4492 SfxItemPresentation eRet
= ePres
;
4495 case SFX_ITEM_PRESENTATION_NONE
:
4499 case SFX_ITEM_PRESENTATION_NAMELESS
:
4500 case SFX_ITEM_PRESENTATION_COMPLETE
:
4501 rText
= SVX_RESSTR( RID_SVXITEMS_FRMDIR_BEGIN
+ GetValue() );
4505 eRet
= SFX_ITEM_PRESENTATION_NONE
;
4510 sal_Bool
SvxFrameDirectionItem::PutValue( const com::sun::star::uno::Any
& rVal
,
4513 sal_Int16 nVal
= sal_Int16();
4514 sal_Bool bRet
= ( rVal
>>= nVal
);
4517 // translate WritingDirection2 constants into SvxFrameDirection
4520 case text::WritingMode2::LR_TB
:
4521 SetValue( FRMDIR_HORI_LEFT_TOP
);
4523 case text::WritingMode2::RL_TB
:
4524 SetValue( FRMDIR_HORI_RIGHT_TOP
);
4526 case text::WritingMode2::TB_RL
:
4527 SetValue( FRMDIR_VERT_TOP_RIGHT
);
4529 case text::WritingMode2::TB_LR
:
4530 SetValue( FRMDIR_VERT_TOP_LEFT
);
4532 case text::WritingMode2::PAGE
:
4533 SetValue( FRMDIR_ENVIRONMENT
);
4544 sal_Bool
SvxFrameDirectionItem::QueryValue( com::sun::star::uno::Any
& rVal
,
4547 // translate SvxFrameDirection into WritingDirection2
4549 sal_Bool bRet
= sal_True
;
4550 switch( GetValue() )
4552 case FRMDIR_HORI_LEFT_TOP
:
4553 nVal
= text::WritingMode2::LR_TB
;
4555 case FRMDIR_HORI_RIGHT_TOP
:
4556 nVal
= text::WritingMode2::RL_TB
;
4558 case FRMDIR_VERT_TOP_RIGHT
:
4559 nVal
= text::WritingMode2::TB_RL
;
4561 case FRMDIR_VERT_TOP_LEFT
:
4562 nVal
= text::WritingMode2::TB_LR
;
4564 case FRMDIR_ENVIRONMENT
:
4565 nVal
= text::WritingMode2::PAGE
;
4568 DBG_ERROR("Unknown SvxFrameDirection value!");
4573 // return value + error state