merge the formfield patch from ooo-build
[ooovba.git] / svx / source / items / frmitems.cxx
blob5b1bef3c9c1bd1c3fe17e7a645b478363d4f4ba3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: frmitems.cxx,v $
10 * $Revision: 1.53 $
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>
38 #include <limits.h>
39 #include <comphelper/processfactory.hxx>
42 #include <goodies/grfmgr.hxx>
43 #include <tools/urlobj.hxx>
44 #ifndef SVX_LIGHT
45 #ifndef _SFXDOCFILE_HXX //autogen
46 #include <sfx2/docfile.hxx>
47 #endif
48 #include <sfx2/objsh.hxx>
49 #endif // !SVX_LIGHT
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>
62 #include <impgrf.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>
85 #include "svxerr.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 )
128 if( 100 == nProp )
129 rStr += String::CreateFromInt32( nValue );
130 else
131 ( rStr += String::CreateFromInt32( nProp )) += sal_Unicode('%');
134 inline void SetValueProp( XubString& rStr, const short nValue,
135 const sal_uInt16 nProp )
137 if( 100 == nProp )
138 rStr += String::CreateFromInt32( nValue );
139 else
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
173 rStrm << GetValue();
174 return rStrm;
177 // -----------------------------------------------------------------------
179 SfxPoolItem* SvxPaperBinItem::Create( SvStream& rStrm, sal_uInt16 ) const
181 sal_Int8 nBin;
182 rStrm >> nBin;
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 *
194 ) const
196 #ifndef SVX_LIGHT
197 switch ( ePres )
199 case SFX_ITEM_PRESENTATION_NONE:
200 rText.Erase();
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);
213 else
215 rText = SVX_RESSTR(RID_SVXSTR_PAPERBIN);
216 rText += sal_Unicode(' ');
217 rText += String::CreateFromInt32( nValue );
219 return SFX_ITEM_PRESENTATION_COMPLETE;
221 //no break necessary
222 default: ;//prevent warning
224 #endif // !SVX_LIGHT
225 return SFX_ITEM_PRESENTATION_NONE;
228 // class SvxSizeItem -----------------------------------------------------
230 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId, const Size& rSize ) :
232 SfxPoolItem( nId ),
234 aSize( 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());
245 if( bConvert )
247 aTmp.Height = TWIP_TO_MM100(aTmp.Height);
248 aTmp.Width = TWIP_TO_MM100(aTmp.Width);
251 switch( nMemberId )
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;
259 return sal_True;
261 // -----------------------------------------------------------------------
262 sal_Bool SvxSizeItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
264 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
265 nMemberId &= ~CONVERT_TWIPS;
267 switch( nMemberId )
269 case MID_SIZE_SIZE:
271 awt::Size aTmp;
272 if( rVal >>= aTmp )
274 if(bConvert)
276 aTmp.Height = MM100_TO_TWIP(aTmp.Height);
277 aTmp.Width = MM100_TO_TWIP(aTmp.Width);
279 aSize = Size( aTmp.Width, aTmp.Height );
281 else
283 return sal_False;
286 break;
287 case MID_SIZE_WIDTH:
289 sal_Int32 nVal = 0;
290 if(!(rVal >>= nVal ))
291 return sal_False;
293 aSize.Width() = bConvert ? MM100_TO_TWIP(nVal) : nVal;
295 break;
296 case MID_SIZE_HEIGHT:
298 sal_Int32 nVal = 0;
299 if(!(rVal >>= nVal))
300 return sal_True;
302 aSize.Height() = bConvert ? MM100_TO_TWIP(nVal) : nVal;
304 break;
305 default: DBG_ERROR("Wrong MemberId!");
306 return sal_False;
308 return sal_True;
311 // -----------------------------------------------------------------------
313 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId ) :
315 SfxPoolItem( 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
343 ) const
345 #ifndef SVX_LIGHT
346 switch ( ePres )
348 case SFX_ITEM_PRESENTATION_NONE:
349 rText.Erase();
350 return SFX_ITEM_PRESENTATION_NONE;
352 case SFX_ITEM_PRESENTATION_NAMELESS:
353 rText = GetMetricText( aSize.Width(), eCoreUnit, ePresUnit, pIntl );
354 rText += cpDelim;
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));
362 rText += cpDelim;
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;
367 //no break necessary
368 default: ;//prevent warning
371 #endif // !SVX_LIGHT
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();
381 return rStrm;
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 );
390 return 1;
393 // -----------------------------------------------------------------------
395 int SvxSizeItem::HasMetrics() const
397 return 1;
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));
411 return pAttr;
414 // class SvxLRSpaceItem --------------------------------------------------
416 SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId ) :
418 SfxPoolItem( nId ),
420 nFirstLineOfst ( 0 ),
421 nTxtLeft ( 0 ),
422 nLeftMargin ( 0 ),
423 nRightMargin ( 0 ),
424 nPropFirstLineOfst( 100 ),
425 nPropLeftMargin( 100 ),
426 nPropRightMargin( 100 ),
427 bAutoFirst ( 0 )
431 // -----------------------------------------------------------------------
433 SvxLRSpaceItem::SvxLRSpaceItem( const long nLeft, const long nRight,
434 const long nTLeft, const short nOfset,
435 const sal_uInt16 nId ) :
437 SfxPoolItem( nId ),
439 nFirstLineOfst ( nOfset ),
440 nTxtLeft ( nTLeft ),
441 nLeftMargin ( nLeft ),
442 nRightMargin ( nRight ),
443 nPropFirstLineOfst( 100 ),
444 nPropLeftMargin( 100 ),
445 nPropRightMargin( 100 ),
446 bAutoFirst ( 0 )
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;
456 switch( nMemberId )
458 // jetzt alles signed
459 case MID_L_MARGIN:
460 rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nLeftMargin) : nLeftMargin);
461 break;
463 case MID_TXT_LMARGIN :
464 rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nTxtLeft) : nTxtLeft);
465 break;
466 case MID_R_MARGIN:
467 rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nRightMargin) : nRightMargin);
468 break;
469 case MID_L_REL_MARGIN:
470 rVal <<= (sal_Int16)nPropLeftMargin;
471 break;
472 case MID_R_REL_MARGIN:
473 rVal <<= (sal_Int16)nPropRightMargin;
474 break;
476 case MID_FIRST_LINE_INDENT:
477 rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nFirstLineOfst) : nFirstLineOfst);
478 break;
480 case MID_FIRST_LINE_REL_INDENT:
481 rVal <<= (sal_Int16)(nPropFirstLineOfst);
482 break;
484 case MID_FIRST_AUTO:
485 rVal = Bool2Any(IsAutoFirst());
486 break;
488 default:
489 bRet = sal_False;
490 DBG_ERROR("unknown MemberId");
492 return bRet;
495 // -----------------------------------------------------------------------
496 sal_Bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
498 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
499 nMemberId &= ~CONVERT_TWIPS;
500 sal_Int32 nVal = 0;
501 if( nMemberId != MID_FIRST_AUTO &&
502 nMemberId != MID_L_REL_MARGIN && nMemberId != MID_R_REL_MARGIN)
503 if(!(rVal >>= nVal))
504 return sal_False;
506 switch( nMemberId )
508 case MID_L_MARGIN:
509 SetLeft((sal_Int32)bConvert ? MM100_TO_TWIP(nVal) : nVal);
510 break;
512 case MID_TXT_LMARGIN :
513 SetTxtLeft((sal_Int32)bConvert ? MM100_TO_TWIP(nVal) : nVal);
514 break;
516 case MID_R_MARGIN:
517 SetRight((sal_Int32) bConvert ? MM100_TO_TWIP(nVal) : nVal);
518 break;
519 case MID_L_REL_MARGIN:
520 case MID_R_REL_MARGIN:
522 sal_Int32 nRel = 0;
523 if((rVal >>= nRel) && nRel >= 0 && nRel < USHRT_MAX)
525 if(MID_L_REL_MARGIN== nMemberId)
526 nPropLeftMargin = (USHORT)nRel;
527 else
528 nPropRightMargin = (USHORT)nRel;
530 else
531 return FALSE;
533 break;
534 case MID_FIRST_LINE_INDENT :
535 SetTxtFirstLineOfst((short)(bConvert ? MM100_TO_TWIP(nVal) : nVal));
536 break;
538 case MID_FIRST_LINE_REL_INDENT:
539 SetPropTxtFirstLineOfst ( (USHORT)nVal );
540 break;
542 case MID_FIRST_AUTO:
543 SetAutoFirst( Any2Bool(rVal) );
544 break;
546 default:
547 DBG_ERROR("unknown MemberId");
548 return sal_False;
550 return sal_True;
553 // -----------------------------------------------------------------------
555 // nLeftMargin und nTxtLeft anpassen.
557 void SvxLRSpaceItem::AdjustLeft()
559 if ( 0 > nFirstLineOfst )
560 nLeftMargin = nTxtLeft + nFirstLineOfst;
561 else
562 nLeftMargin = nTxtLeft;
565 // -----------------------------------------------------------------------
567 int SvxLRSpaceItem::operator==( const SfxPoolItem& rAttr ) const
569 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
571 return (
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
596 ) const
598 #ifndef SVX_LIGHT
599 switch ( ePres )
601 case SFX_ITEM_PRESENTATION_NONE:
602 rText.Erase();
603 return SFX_ITEM_PRESENTATION_NONE;
604 case SFX_ITEM_PRESENTATION_NAMELESS:
606 if ( 100 != nPropLeftMargin )
607 ( rText = String::CreateFromInt32( nPropLeftMargin )) += sal_Unicode('%');
608 else
609 rText = GetMetricText( (long)nLeftMargin,
610 eCoreUnit, ePresUnit, pIntl );
611 rText += cpDelim;
612 if ( 100 != nPropFirstLineOfst )
613 ( rText += String::CreateFromInt32( nPropFirstLineOfst )) += sal_Unicode('%');
614 else
615 rText += GetMetricText( (long)nFirstLineOfst,
616 eCoreUnit, ePresUnit, pIntl );
617 rText += cpDelim;
618 if ( 100 != nRightMargin )
619 ( rText += String::CreateFromInt32( nRightMargin )) += sal_Unicode('%');
620 else
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('%');
630 else
632 rText += GetMetricText( (long)nLeftMargin,
633 eCoreUnit, ePresUnit, pIntl );
634 rText += SVX_RESSTR(GetMetricId(ePresUnit));
636 rText += cpDelim;
637 if ( 100 != nPropFirstLineOfst || nFirstLineOfst )
639 rText += SVX_RESSTR(RID_SVXITEMS_LRSPACE_FLINE);
640 if ( 100 != nPropFirstLineOfst )
641 ( rText += String::CreateFromInt32( nPropFirstLineOfst ))
642 += sal_Unicode('%');
643 else
645 rText += GetMetricText( (long)nFirstLineOfst,
646 eCoreUnit, ePresUnit, pIntl );
647 rText += SVX_RESSTR(GetMetricId(ePresUnit));
649 rText += cpDelim;
651 rText += SVX_RESSTR(RID_SVXITEMS_LRSPACE_RIGHT);
652 if ( 100 != nPropRightMargin )
653 ( rText += String::CreateFromInt32( nPropRightMargin )) += sal_Unicode('%');
654 else
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
664 #endif // !SVX_LIGHT
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 );
683 rStrm << nMargin;
684 rStrm << nPropLeftMargin;
685 if( nRightMargin > 0 )
686 nMargin = sal_uInt16( nRightMargin );
687 else
688 nMargin = 0;
689 rStrm << nMargin;
690 rStrm << nPropRightMargin;
691 rStrm << nFirstLineOfst;
692 rStrm << nPropFirstLineOfst;
693 if( nTxtLeft > 0 )
694 nMargin = sal_uInt16( nTxtLeft );
695 else
696 nMargin = 0;
697 rStrm << nMargin;
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 ) )
703 nAutoFirst |= 0x80;
704 rStrm << nAutoFirst;
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;
709 rStrm << nSaveFI;
711 if( 0x80 & nAutoFirst )
713 rStrm << nLeftMargin;
714 rStrm << nRightMargin;
718 ((SvxLRSpaceItem*)this)->SetTxtFirstLineOfst( nSaveFI );
720 return rStrm;
723 // -----------------------------------------------------------------------
725 SfxPoolItem* SvxLRSpaceItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
727 sal_uInt16 left, prpleft, right, prpright, prpfirstline, txtleft;
728 short firstline;
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();
737 sal_uInt32 nMarker;
738 rStrm >> nMarker;
739 if ( nMarker == BULLETLR_MARKER )
741 rStrm >> firstline;
742 if ( firstline < 0 )
743 left = left + static_cast<sal_uInt16>(firstline); // s.u.: txtleft = ...
745 else
746 rStrm.Seek( nPos );
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 >>
756 prpfirstline;
758 else
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 ) )
780 sal_Int32 nMargin;
781 rStrm >> nMargin;
782 pAttr->nLeftMargin = nMargin;
783 pAttr->nTxtLeft = firstline >= 0 ? nMargin : nMargin - firstline;
784 rStrm >> nMargin;
785 pAttr->nRightMargin = nMargin;
787 return pAttr;
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 );
807 return 1;
810 // -----------------------------------------------------------------------
812 int SvxLRSpaceItem::HasMetrics() const
814 return 1;
817 // class SvxULSpaceItem --------------------------------------------------
819 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nId ) :
821 SfxPoolItem( nId ),
823 nUpper( 0 ),
824 nLower( 0 ),
825 nPropUpper( 100 ),
826 nPropLower( 100 )
830 // -----------------------------------------------------------------------
832 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nUp, const sal_uInt16 nLow,
833 const sal_uInt16 nId ) :
835 SfxPoolItem( nId ),
837 nUpper( nUp ),
838 nLower( nLow ),
839 nPropUpper( 100 ),
840 nPropLower( 100 )
844 // -----------------------------------------------------------------------
845 sal_Bool SvxULSpaceItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
847 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
848 nMemberId &= ~CONVERT_TWIPS;
849 switch( nMemberId )
851 // jetzt alles signed
852 case 0:
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;
860 break;
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;
867 return sal_True;
870 // -----------------------------------------------------------------------
871 sal_Bool SvxULSpaceItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
873 sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
874 nMemberId &= ~CONVERT_TWIPS;
875 sal_Int32 nVal = 0;
876 switch( nMemberId )
878 case 0:
880 ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale;
881 if ( !(rVal >>= aUpperLowerMarginScale ))
882 return sal_False;
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;
893 case MID_UP_MARGIN :
894 if(!(rVal >>= nVal) || nVal < 0)
895 return sal_False;
896 SetUpper((USHORT)(bConvert ? MM100_TO_TWIP(nVal) : nVal));
897 break;
898 case MID_LO_MARGIN :
899 if(!(rVal >>= nVal) || nVal < 0)
900 return sal_False;
901 SetLower((USHORT)(bConvert ? MM100_TO_TWIP(nVal) : nVal));
902 break;
903 case MID_UP_REL_MARGIN:
904 case MID_LO_REL_MARGIN:
906 sal_Int32 nRel = 0;
907 if((rVal >>= nRel) && nRel > 1 )
909 if(MID_UP_REL_MARGIN == nMemberId)
910 nPropUpper = (USHORT)nRel;
911 else
912 nPropLower = (USHORT)nRel;
914 else
915 return FALSE;
917 break;
920 default:
921 DBG_ERROR("unknown MemberId");
922 return sal_False;
924 return sal_True;
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
954 ) const
956 #ifndef SVX_LIGHT
957 switch ( ePres )
959 case SFX_ITEM_PRESENTATION_NONE:
960 rText.Erase();
961 return SFX_ITEM_PRESENTATION_NONE;
962 case SFX_ITEM_PRESENTATION_NAMELESS:
964 if ( 100 != nPropUpper )
965 ( rText = String::CreateFromInt32( nPropUpper )) += sal_Unicode('%');
966 else
967 rText = GetMetricText( (long)nUpper, eCoreUnit, ePresUnit, pIntl );
968 rText += cpDelim;
969 if ( 100 != nPropLower )
970 ( rText += String::CreateFromInt32( nPropLower )) += sal_Unicode('%');
971 else
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('%');
980 else
982 rText += GetMetricText( (long)nUpper, eCoreUnit, ePresUnit, pIntl );
983 rText += SVX_RESSTR(GetMetricId(ePresUnit));
985 rText += cpDelim;
986 rText += SVX_RESSTR(RID_SVXITEMS_ULSPACE_LOWER);
987 if ( 100 != nPropLower )
988 ( rText += String::CreateFromInt32( nPropLower )) += sal_Unicode('%');
989 else
991 rText += GetMetricText( (long)nLower, eCoreUnit, ePresUnit, pIntl );
992 rText += SVX_RESSTR(GetMetricId(ePresUnit));
994 return SFX_ITEM_PRESENTATION_COMPLETE;
996 default: ;//prevent warning
998 #endif
999 return SFX_ITEM_PRESENTATION_NONE;
1002 // -----------------------------------------------------------------------
1004 SvStream& SvxULSpaceItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1006 rStrm << GetUpper()
1007 << GetPropUpper()
1008 << GetLower()
1009 << GetPropLower();
1010 return rStrm;
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;
1021 else
1023 sal_Int8 nU, nL;
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 );
1034 return pAttr;
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 );
1050 return 1;
1053 // -----------------------------------------------------------------------
1055 int SvxULSpaceItem::HasMetrics() const
1057 return 1;
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();
1073 return rStrm;
1076 // -----------------------------------------------------------------------
1078 SfxPoolItem* SvxPrintItem::Create( SvStream& rStrm, sal_uInt16 ) const
1080 sal_Int8 bIsPrint;
1081 rStrm >> bIsPrint;
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 *
1093 ) const
1095 #ifndef SVX_LIGHT
1096 switch ( ePres )
1098 case SFX_ITEM_PRESENTATION_NONE:
1099 rText.Erase();
1100 return ePres;
1102 case SFX_ITEM_PRESENTATION_NAMELESS:
1103 case SFX_ITEM_PRESENTATION_COMPLETE:
1105 sal_uInt16 nId = RID_SVXITEMS_PRINT_FALSE;
1107 if ( GetValue() )
1108 nId = RID_SVXITEMS_PRINT_TRUE;
1109 rText = SVX_RESSTR(nId);
1110 return ePres;
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();
1130 return rStrm;
1133 // -----------------------------------------------------------------------
1135 SfxPoolItem* SvxOpaqueItem::Create( SvStream& rStrm, sal_uInt16 ) const
1137 sal_Int8 bIsOpaque;
1138 rStrm >> bIsOpaque;
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 *
1150 ) const
1152 #ifndef SVX_LIGHT
1153 switch ( ePres )
1155 case SFX_ITEM_PRESENTATION_NONE:
1156 rText.Erase();
1157 return ePres;
1159 case SFX_ITEM_PRESENTATION_NAMELESS:
1160 case SFX_ITEM_PRESENTATION_COMPLETE:
1162 sal_uInt16 nId = RID_SVXITEMS_OPAQUE_FALSE;
1164 if ( GetValue() )
1165 nId = RID_SVXITEMS_OPAQUE_TRUE;
1166 rText = SVX_RESSTR(nId);
1167 return ePres;
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;
1192 sal_Bool bValue;
1193 switch(nMemberId)
1195 case MID_PROTECT_CONTENT : bValue = bCntnt; break;
1196 case MID_PROTECT_SIZE : bValue = bSize; break;
1197 case MID_PROTECT_POSITION: bValue = bPos; break;
1198 default:
1199 DBG_ERROR("falsche MemberId");
1200 return sal_False;
1203 rVal = Bool2Any( bValue );
1204 return sal_True;
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) );
1214 switch(nMemberId)
1216 case MID_PROTECT_CONTENT : bCntnt = bVal; break;
1217 case MID_PROTECT_SIZE : bSize = bVal; break;
1218 case MID_PROTECT_POSITION: bPos = bVal; break;
1219 default:
1220 DBG_ERROR("falsche MemberId");
1221 return sal_False;
1223 return sal_True;
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 *
1241 ) const
1243 #ifndef SVX_LIGHT
1244 switch ( ePres )
1246 case SFX_ITEM_PRESENTATION_NONE:
1247 rText.Erase();
1248 return ePres;
1250 case SFX_ITEM_PRESENTATION_NAMELESS:
1251 case SFX_ITEM_PRESENTATION_COMPLETE:
1253 sal_uInt16 nId = RID_SVXITEMS_PROT_CONTENT_FALSE;
1255 if ( bCntnt )
1256 nId = RID_SVXITEMS_PROT_CONTENT_TRUE;
1257 rText = SVX_RESSTR(nId);
1258 rText += cpDelim;
1259 nId = RID_SVXITEMS_PROT_SIZE_FALSE;
1261 if ( bSize )
1262 nId = RID_SVXITEMS_PROT_SIZE_TRUE;
1263 rText += SVX_RESSTR(nId);
1264 rText += cpDelim;
1265 nId = RID_SVXITEMS_PROT_POS_FALSE;
1267 if ( bPos )
1268 nId = RID_SVXITEMS_PROT_POS_TRUE;
1269 rText += SVX_RESSTR(nId);
1270 return ePres;
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
1282 sal_Int8 cProt = 0;
1283 if( IsPosProtected() ) cProt |= 0x01;
1284 if( IsSizeProtected() ) cProt |= 0x02;
1285 if( IsCntntProtected() ) cProt |= 0x04;
1286 rStrm << (sal_Int8) cProt;
1287 return rStrm;
1290 // -----------------------------------------------------------------------
1292 SfxPoolItem* SvxProtectItem::Create( SvStream& rStrm, sal_uInt16 ) const
1294 sal_Int8 cFlags;
1295 rStrm >> cFlags;
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 ) );
1300 return pAttr;
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),
1310 nWidth ( nW ),
1311 eLocation ( eLoc )
1313 if ( pColor )
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;
1325 switch( eLocation )
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;
1348 return sal_True;
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;
1357 uno::Any aAny;
1358 sal_Bool bRet = QueryValue( aAny, bConvert ? CONVERT_TWIPS : 0 ) && ( aAny >>= aShadow );
1359 switch ( nMemberId )
1361 case MID_LOCATION:
1363 bRet = (rVal >>= aShadow.Location);
1364 if ( !bRet )
1366 sal_Int16 nVal = 0;
1367 bRet = (rVal >>= nVal);
1368 aShadow.Location = (table::ShadowLocation) nVal;
1371 break;
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;
1381 if ( bRet )
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;
1399 return bRet;
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;
1426 switch ( nShadow )
1428 case SHADOW_TOP:
1429 if ( eLocation == SVX_SHADOW_TOPLEFT ||
1430 eLocation == SVX_SHADOW_TOPRIGHT )
1431 nSpace = nWidth;
1432 break;
1434 case SHADOW_BOTTOM:
1435 if ( eLocation == SVX_SHADOW_BOTTOMLEFT ||
1436 eLocation == SVX_SHADOW_BOTTOMRIGHT )
1437 nSpace = nWidth;
1438 break;
1440 case SHADOW_LEFT:
1441 if ( eLocation == SVX_SHADOW_TOPLEFT ||
1442 eLocation == SVX_SHADOW_BOTTOMLEFT )
1443 nSpace = nWidth;
1444 break;
1446 case SHADOW_RIGHT:
1447 if ( eLocation == SVX_SHADOW_TOPRIGHT ||
1448 eLocation == SVX_SHADOW_BOTTOMRIGHT )
1449 nSpace = nWidth;
1450 break;
1452 default:
1453 DBG_ERROR( "wrong shadow" );
1455 return nSpace;
1458 //------------------------------------------------------------------------
1460 SfxItemPresentation SvxShadowItem::GetPresentation
1462 SfxItemPresentation ePres,
1463 SfxMapUnit eCoreUnit,
1464 SfxMapUnit ePresUnit,
1465 XubString& rText, const IntlWrapper *pIntl
1466 ) const
1468 #ifndef SVX_LIGHT
1469 switch ( ePres )
1471 case SFX_ITEM_PRESENTATION_NONE:
1472 rText.Erase();
1473 return ePres;
1475 case SFX_ITEM_PRESENTATION_NAMELESS:
1477 rText = ::GetColorString( aShadowColor );
1478 rText += cpDelim;
1479 sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
1481 if ( aShadowColor.GetTransparency() )
1482 nId = RID_SVXITEMS_TRANSPARENT_TRUE;
1483 rText += SVX_RESSTR(nId);
1484 rText += cpDelim;
1485 rText += GetMetricText( (long)nWidth, eCoreUnit, ePresUnit, pIntl );
1486 rText += cpDelim;
1487 rText += SVX_RESSTR(RID_SVXITEMS_SHADOW_BEGIN + eLocation);
1488 return ePres;
1490 case SFX_ITEM_PRESENTATION_COMPLETE:
1492 rText = SVX_RESSTR(RID_SVXITEMS_SHADOW_COMPLETE);
1493 rText += ::GetColorString( aShadowColor );
1494 rText += cpDelim;
1496 sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
1497 if ( aShadowColor.GetTransparency() )
1498 nId = RID_SVXITEMS_TRANSPARENT_TRUE;
1499 rText += SVX_RESSTR(nId);
1500 rText += cpDelim;
1501 rText += GetMetricText( (long)nWidth, eCoreUnit, ePresUnit, pIntl );
1502 rText += SVX_RESSTR(GetMetricId(ePresUnit));
1503 rText += cpDelim;
1504 rText += SVX_RESSTR(RID_SVXITEMS_SHADOW_BEGIN + eLocation);
1505 return ePres;
1507 default: ;//prevent warning
1509 #endif
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)
1520 << GetColor()
1521 << GetColor()
1522 << (sal_Int8)(aShadowColor.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
1523 return rStrm;
1526 // -----------------------------------------------------------------------
1528 int SvxShadowItem::ScaleMetrics( long nMult, long nDiv )
1530 nWidth = (sal_uInt16)Scale( nWidth, nMult, nDiv );
1531 return 1;
1534 // -----------------------------------------------------------------------
1536 int SvxShadowItem::HasMetrics() const
1538 return 1;
1541 // -----------------------------------------------------------------------
1543 SfxPoolItem* SvxShadowItem::Create( SvStream& rStrm, sal_uInt16 ) const
1545 sal_Int8 cLoc;
1546 sal_uInt16 _nWidth;
1547 sal_Bool bTrans;
1548 Color aColor;
1549 Color aFillColor;
1550 sal_Int8 nStyle;
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 )
1589 : nOutWidth( nOut )
1590 , nInWidth ( nIn )
1591 , nDistance( nDist )
1593 if ( pCol )
1594 aColor = *pCol;
1597 // -----------------------------------------------------------------------
1599 SvxBorderLine::SvxBorderLine( const SvxBorderLine& r )
1601 *this = r;
1604 // -----------------------------------------------------------------------
1606 SvxBorderLine& SvxBorderLine::operator=( const SvxBorderLine& r )
1608 aColor = r.aColor;
1609 nOutWidth = r.nOutWidth;
1610 nInWidth = r.nInWidth;
1611 nDistance = r.nDistance;
1612 return *this;
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
1641 #ifndef SVX_LIGHT
1642 sal_uInt16 nResId = 0;
1644 if ( 0 == nDistance )
1646 // einfach Linie
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;
1697 String aStr;
1698 aStr += sal_Unicode('(');
1699 aStr += ::GetColorString( aColor );
1700 aStr += cpDelim;
1702 if ( nResId )
1703 aStr += SVX_RESSTR(nResId);
1704 else
1706 String sMetric = SVX_RESSTR(GetMetricId( eDestUnit ));
1707 aStr += GetMetricText( (long)nInWidth, eSrcUnit, eDestUnit, pIntl );
1708 if ( bMetricStr )
1709 aStr += sMetric;
1710 aStr += cpDelim;
1711 aStr += GetMetricText( (long)nOutWidth, eSrcUnit, eDestUnit, pIntl );
1712 if ( bMetricStr )
1713 aStr += sMetric;
1714 aStr += cpDelim;
1715 aStr += GetMetricText( (long)nDistance, eSrcUnit, eDestUnit, pIntl );
1716 if ( bMetricStr )
1717 aStr += sMetric;
1719 aStr += sal_Unicode(')');
1720 return aStr;
1721 #else
1722 return UniString();
1723 #endif
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)
1733 return true;
1735 else if (nThisSize < nOtherSize)
1737 return false;
1739 else
1741 if ( rOtherLine.GetInWidth() && !GetInWidth() )
1743 return true;
1745 else if ( GetInWidth() && !rOtherLine.GetInWidth() )
1747 return false;
1749 else
1751 return false;
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 ) :
1776 SfxPoolItem( nId ),
1778 pTop ( 0 ),
1779 pBottom ( 0 ),
1780 pLeft ( 0 ),
1781 pRight ( 0 ),
1782 nTopDist ( 0 ),
1783 nBottomDist ( 0 ),
1784 nLeftDist ( 0 ),
1785 nRightDist ( 0 )
1790 // -----------------------------------------------------------------------
1792 SvxBoxItem::~SvxBoxItem()
1794 delete pTop;
1795 delete pBottom;
1796 delete pLeft;
1797 delete pRight;
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 );
1812 return *this;
1815 // -----------------------------------------------------------------------
1817 inline sal_Bool CmpBrdLn( const SvxBorderLine* pBrd1, const SvxBorderLine* pBrd2 )
1819 sal_Bool bRet;
1820 if( 0 != pBrd1 ? 0 == pBrd2 : 0 != pBrd2 )
1821 bRet = sal_False;
1822 else
1823 if( !pBrd1 )
1824 bRet = sal_True;
1825 else
1826 bRet = (*pBrd1 == *pBrd2);
1827 return bRet;
1830 // -----------------------------------------------------------------------
1832 int SvxBoxItem::operator==( const SfxPoolItem& rAttr ) const
1834 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
1836 return (
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;
1851 if(pLine)
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() );
1858 else
1859 aLine.Color = aLine.InnerLineWidth = aLine.OuterLineWidth = aLine.LineDistance = 0;
1860 return aLine;
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;
1871 switch(nMemberId)
1873 case 0:
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 );
1887 return sal_True;
1889 case MID_LEFT_BORDER:
1890 bSerialize = sal_True; // intentionally no break!
1891 case LEFT_BORDER:
1892 aRetLine = lcl_SvxLineToLine(GetLeft(), bConvert);
1893 break;
1894 case MID_RIGHT_BORDER:
1895 bSerialize = sal_True; // intentionally no break!
1896 case RIGHT_BORDER:
1897 aRetLine = lcl_SvxLineToLine(GetRight(), bConvert);
1898 break;
1899 case MID_BOTTOM_BORDER:
1900 bSerialize = sal_True; // intentionally no break!
1901 case BOTTOM_BORDER:
1902 aRetLine = lcl_SvxLineToLine(GetBottom(), bConvert);
1903 break;
1904 case MID_TOP_BORDER:
1905 bSerialize = sal_True; // intentionally no break!
1906 case TOP_BORDER:
1907 aRetLine = lcl_SvxLineToLine(GetTop(), bConvert);
1908 break;
1909 case BORDER_DISTANCE:
1910 nDist = GetDistance();
1911 bDistMember = sal_True;
1912 break;
1913 case TOP_BORDER_DISTANCE:
1914 nDist = nTopDist;
1915 bDistMember = sal_True;
1916 break;
1917 case BOTTOM_BORDER_DISTANCE:
1918 nDist = nBottomDist;
1919 bDistMember = sal_True;
1920 break;
1921 case LEFT_BORDER_DISTANCE:
1922 nDist = nLeftDist;
1923 bDistMember = sal_True;
1924 break;
1925 case RIGHT_BORDER_DISTANCE:
1926 nDist = nRightDist;
1927 bDistMember = sal_True;
1928 break;
1931 if( bDistMember )
1932 rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nDist) : nDist);
1933 else
1936 if ( bSerialize )
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;
1943 rVal <<= aSeq;
1945 else
1947 rVal <<= aRetLine;
1950 return sal_True;
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;
1961 return bRet;
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;
1972 switch(nMemberId)
1974 case 0:
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 );
1988 else
1989 return sal_False;
1991 if ( aSeq[1] >>= aBorderLine )
1993 sal_Bool bSet = lcl_LineToSvxLine(aBorderLine, aLine, bConvert);
1994 SetLine(bSet ? &aLine : 0, BOX_LINE_RIGHT );
1996 else
1997 return sal_False;
1999 if ( aSeq[2] >>= aBorderLine )
2001 sal_Bool bSet = lcl_LineToSvxLine(aBorderLine, aLine, bConvert);
2002 SetLine(bSet ? &aLine : 0, BOX_LINE_BOTTOM );
2004 else
2005 return sal_False;
2007 if ( aSeq[3] >>= aBorderLine )
2009 sal_Bool bSet = lcl_LineToSvxLine(aBorderLine, aLine, bConvert);
2010 SetLine(bSet ? &aLine : 0, BOX_LINE_TOP );
2012 else
2013 return sal_False;
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 )
2020 if( bConvert )
2021 nDist = MM100_TO_TWIP(nDist);
2022 if ( n == 4 )
2023 SetDistance( sal_uInt16( nDist ));
2024 else
2025 SetDistance( sal_uInt16( nDist ), nLines[n-5] );
2027 else
2028 return sal_False;
2031 return sal_True;
2033 else
2034 return sal_False;
2036 case LEFT_BORDER_DISTANCE:
2037 bDistMember = sal_True;
2038 case LEFT_BORDER:
2039 case MID_LEFT_BORDER:
2040 nLine = BOX_LINE_LEFT;
2041 break;
2042 case RIGHT_BORDER_DISTANCE:
2043 bDistMember = sal_True;
2044 case RIGHT_BORDER:
2045 case MID_RIGHT_BORDER:
2046 nLine = BOX_LINE_RIGHT;
2047 break;
2048 case BOTTOM_BORDER_DISTANCE:
2049 bDistMember = sal_True;
2050 case BOTTOM_BORDER:
2051 case MID_BOTTOM_BORDER:
2052 nLine = BOX_LINE_BOTTOM;
2053 break;
2054 case TOP_BORDER_DISTANCE:
2055 bDistMember = sal_True;
2056 case TOP_BORDER:
2057 case MID_TOP_BORDER:
2058 nLine = BOX_LINE_TOP;
2059 break;
2062 if( bDistMember || nMemberId == BORDER_DISTANCE )
2064 sal_Int32 nDist = 0;
2065 if(!(rVal >>= nDist))
2066 return sal_False;
2068 if(nDist >= 0)
2070 if( bConvert )
2071 nDist = MM100_TO_TWIP(nDist);
2072 if( nMemberId == BORDER_DISTANCE )
2073 SetDistance( sal_uInt16( nDist ));
2074 else
2075 SetDistance( sal_uInt16( nDist ), nLine );
2078 else
2080 SvxBorderLine aLine;
2081 if( !rVal.hasValue() )
2082 return sal_False;
2084 table::BorderLine aBorderLine;
2085 if( rVal >>= aBorderLine )
2087 // usual struct
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")),
2094 uno::UNO_QUERY );
2095 uno::Sequence < uno::Any > aSeq;
2096 uno::Any aNew;
2097 try { aNew = xConverter->convertTo( rVal, ::getCppuType((const uno::Sequence < uno::Any >*)0) ); }
2098 catch (uno::Exception&) {}
2100 aNew >>= aSeq;
2101 if ( aSeq.getLength() == 4 )
2103 sal_Int32 nVal = 0;
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;
2113 else
2114 return sal_False;
2116 else
2117 return sal_False;
2119 sal_Bool bSet = lcl_LineToSvxLine(aBorderLine, aLine, bConvert);
2120 SetLine(bSet ? &aLine : 0, nLine);
2123 return sal_True;
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
2141 ) const
2143 #ifndef SVX_LIGHT
2144 switch ( ePres )
2146 case SFX_ITEM_PRESENTATION_NONE:
2147 rText.Erase();
2148 return SFX_ITEM_PRESENTATION_NONE;
2150 case SFX_ITEM_PRESENTATION_NAMELESS:
2152 rText.Erase();
2154 if ( pTop )
2156 rText = pTop->GetValueString( eCoreUnit, ePresUnit, pIntl );
2157 rText += cpDelim;
2159 if( !(pTop && pBottom && pLeft && pRight &&
2160 *pTop == *pBottom && *pTop == *pLeft && *pTop == *pRight) )
2162 if ( pBottom )
2164 rText += pBottom->GetValueString( eCoreUnit, ePresUnit, pIntl );
2165 rText += cpDelim;
2167 if ( pLeft )
2169 rText += pLeft->GetValueString( eCoreUnit, ePresUnit, pIntl );
2170 rText += cpDelim;
2172 if ( pRight )
2174 rText += pRight->GetValueString( eCoreUnit, ePresUnit, pIntl );
2175 rText += cpDelim;
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,
2184 ePresUnit, pIntl ))
2185 += cpDelim)
2186 += GetMetricText( (long)nLeftDist, eCoreUnit, ePresUnit, pIntl ))
2187 += cpDelim)
2188 += GetMetricText( (long)nRightDist, eCoreUnit,
2189 ePresUnit, pIntl );
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);
2198 rText += cpDelim;
2200 else
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 );
2207 rText += cpDelim;
2209 else
2211 if ( pTop )
2213 rText += SVX_RESSTR(RID_SVXITEMS_BORDER_TOP);
2214 rText += pTop->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2215 rText += cpDelim;
2217 if ( pBottom )
2219 rText += SVX_RESSTR(RID_SVXITEMS_BORDER_BOTTOM);
2220 rText += pBottom->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2221 rText += cpDelim;
2223 if ( pLeft )
2225 rText += SVX_RESSTR(RID_SVXITEMS_BORDER_LEFT);
2226 rText += pLeft->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2227 rText += cpDelim;
2229 if ( pRight )
2231 rText += SVX_RESSTR(RID_SVXITEMS_BORDER_RIGHT);
2232 rText += pRight->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2233 rText += cpDelim;
2238 rText += SVX_RESSTR(RID_SVXITEMS_BORDER_DISTANCE);
2239 if( nTopDist == nBottomDist && nTopDist == nLeftDist &&
2240 nTopDist == nRightDist )
2242 rText += GetMetricText( (long)nTopDist, eCoreUnit,
2243 ePresUnit, pIntl );
2244 rText += SVX_RESSTR(GetMetricId(ePresUnit));
2246 else
2248 (((rText += SVX_RESSTR(RID_SVXITEMS_BORDER_TOP))
2249 += GetMetricText( (long)nTopDist, eCoreUnit,
2250 ePresUnit, pIntl ))
2251 += SVX_RESSTR(GetMetricId(ePresUnit)))
2252 += cpDelim;
2253 (((rText += SVX_RESSTR(RID_SVXITEMS_BORDER_BOTTOM))
2254 += GetMetricText( (long)nBottomDist, eCoreUnit,
2255 ePresUnit, pIntl ))
2256 += SVX_RESSTR(GetMetricId(ePresUnit)))
2257 += cpDelim;
2258 (((rText += SVX_RESSTR(RID_SVXITEMS_BORDER_LEFT))
2259 += GetMetricText( (long)nLeftDist, eCoreUnit,
2260 ePresUnit, pIntl ))
2261 += SVX_RESSTR(GetMetricId(ePresUnit)))
2262 += cpDelim;
2263 ((rText += SVX_RESSTR(RID_SVXITEMS_BORDER_RIGHT))
2264 += GetMetricText( (long)nRightDist, eCoreUnit,
2265 ePresUnit, pIntl ))
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 ];
2290 if( l )
2292 rStrm << (sal_Int8) i
2293 << l->GetColor()
2294 << (sal_uInt16) l->GetOutWidth()
2295 << (sal_uInt16) l->GetInWidth()
2296 << (sal_uInt16) l->GetDistance();
2299 sal_Int8 cLine = 4;
2300 if( nItemVersion >= BOX_4DISTS_VERSION &&
2301 !(nTopDist == nLeftDist &&
2302 nTopDist == nRightDist &&
2303 nTopDist == nBottomDist) )
2305 cLine |= 0x10;
2308 rStrm << cLine;
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;
2318 return rStrm;
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 );
2345 return 1;
2348 // -----------------------------------------------------------------------
2350 int SvxBoxItem::HasMetrics() const
2352 return 1;
2355 // -----------------------------------------------------------------------
2357 SfxPoolItem* SvxBoxItem::Create( SvStream& rStrm, sal_uInt16 nIVersion ) const
2359 sal_uInt16 nDistance;
2360 rStrm >> 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 };
2366 sal_Int8 cLine;
2367 while( sal_True )
2369 rStrm >> cLine;
2371 if( cLine > 3 )
2372 break;
2373 sal_uInt16 nOutline, nInline, _nDistance;
2374 Color aColor;
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++ )
2385 sal_uInt16 nDist;
2386 rStrm >> nDist;
2387 pAttr->SetDistance( nDist, aLineMap[i] );
2390 else
2392 pAttr->SetDistance( nDistance );
2395 return pAttr;
2398 // -----------------------------------------------------------------------
2400 const SvxBorderLine *SvxBoxItem::GetLine( sal_uInt16 nLine ) const
2402 const SvxBorderLine *pRet = 0;
2404 switch ( nLine )
2406 case BOX_LINE_TOP:
2407 pRet = pTop;
2408 break;
2409 case BOX_LINE_BOTTOM:
2410 pRet = pBottom;
2411 break;
2412 case BOX_LINE_LEFT:
2413 pRet = pLeft;
2414 break;
2415 case BOX_LINE_RIGHT:
2416 pRet = pRight;
2417 break;
2418 default:
2419 DBG_ERROR( "wrong line" );
2420 break;
2423 return pRet;
2426 // -----------------------------------------------------------------------
2428 void SvxBoxItem::SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine )
2430 SvxBorderLine* pTmp = pNew ? new SvxBorderLine( *pNew ) : 0;
2432 switch ( nLine )
2434 case BOX_LINE_TOP:
2435 delete pTop;
2436 pTop = pTmp;
2437 break;
2438 case BOX_LINE_BOTTOM:
2439 delete pBottom;
2440 pBottom = pTmp;
2441 break;
2442 case BOX_LINE_LEFT:
2443 delete pLeft;
2444 pLeft = pTmp;
2445 break;
2446 case BOX_LINE_RIGHT:
2447 delete pRight;
2448 pRight = pTmp;
2449 break;
2450 default:
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) )
2464 nDist = nLeftDist;
2465 if( nRightDist && (!nDist || nRightDist < nDist) )
2466 nDist = nRightDist;
2468 return nDist;
2471 // -----------------------------------------------------------------------
2473 sal_uInt16 SvxBoxItem::GetDistance( sal_uInt16 nLine ) const
2475 sal_uInt16 nDist = 0;
2476 switch ( nLine )
2478 case BOX_LINE_TOP:
2479 nDist = nTopDist;
2480 break;
2481 case BOX_LINE_BOTTOM:
2482 nDist = nBottomDist;
2483 break;
2484 case BOX_LINE_LEFT:
2485 nDist = nLeftDist;
2486 break;
2487 case BOX_LINE_RIGHT:
2488 nDist = nRightDist;
2489 break;
2490 default:
2491 DBG_ERROR( "wrong line" );
2494 return nDist;
2497 // -----------------------------------------------------------------------
2499 void SvxBoxItem::SetDistance( sal_uInt16 nNew, sal_uInt16 nLine )
2501 switch ( nLine )
2503 case BOX_LINE_TOP:
2504 nTopDist = nNew;
2505 break;
2506 case BOX_LINE_BOTTOM:
2507 nBottomDist = nNew;
2508 break;
2509 case BOX_LINE_LEFT:
2510 nLeftDist = nNew;
2511 break;
2512 case BOX_LINE_RIGHT:
2513 nRightDist = nNew;
2514 break;
2515 default:
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;
2526 switch ( nLine )
2528 case BOX_LINE_TOP:
2529 pTmp = pTop;
2530 nDist = nTopDist;
2531 break;
2532 case BOX_LINE_BOTTOM:
2533 pTmp = pBottom;
2534 nDist = nBottomDist;
2535 break;
2536 case BOX_LINE_LEFT:
2537 pTmp = pLeft;
2538 nDist = nLeftDist;
2539 break;
2540 case BOX_LINE_RIGHT:
2541 pTmp = pRight;
2542 nDist = nRightDist;
2543 break;
2544 default:
2545 DBG_ERROR( "wrong line" );
2548 if( pTmp )
2550 nDist = nDist + (sal_uInt16)(pTmp->GetOutWidth()) + (sal_uInt16)(pTmp->GetInWidth()) + (sal_uInt16)(pTmp->GetDistance());
2552 else if( !bIgnoreLine )
2553 nDist = 0;
2554 return nDist;
2557 // class SvxBoxInfoItem --------------------------------------------------
2559 SvxBoxInfoItem::SvxBoxInfoItem( const sal_uInt16 nId ) :
2560 SfxPoolItem( nId ),
2561 pHori ( 0 ),
2562 pVert ( 0 ),
2563 mbEnableHor( false ),
2564 mbEnableVer( false ),
2565 nDefDist( 0 )
2567 bDist = bMinDist = sal_False;
2568 ResetFlags();
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()
2590 delete pHori;
2591 delete pVert;
2594 // -----------------------------------------------------------------------
2596 SvxBoxInfoItem &SvxBoxInfoItem::operator=( const SvxBoxInfoItem& rCpy )
2598 delete pHori;
2599 delete pVert;
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();
2608 return *this;
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 )
2638 delete pHori;
2639 pHori = pTmp;
2641 else if ( BOXINFO_LINE_VERT == nLine )
2643 delete pVert;
2644 pVert = pTmp;
2646 else
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 *
2668 ) const
2670 #ifndef SVX_LIGHT
2671 /*!!!
2672 ResMgr* pMgr = DIALOG_MGR();
2673 if ( pHori )
2675 rText += pHori->GetValueString();
2676 rText += cpDelim;
2678 if ( pVert )
2680 rText += pVert->GetValueString();
2681 rText += cpDelim;
2683 if ( bTable )
2684 rText += String( ResId( RID_SVXITEMS_BOXINF_TABLE_TRUE, pMgr ) );
2685 else
2686 rText += String( ResId( RID_SVXITEMS_BOXINF_TABLE_FALSE, pMgr ) );
2687 rText += cpDelim;
2688 if ( bDist )
2689 rText += String( ResId( RID_SVXITEMS_BOXINF_DIST_TRUE, pMgr ) );
2690 else
2691 rText += String( ResId( RID_SVXITEMS_BOXINF_DIST_FALSE, pMgr ) );
2692 rText += cpDelim;
2693 if ( bMinDist )
2694 rText += String( ResId( RID_SVXITEMS_BOXINF_MDIST_TRUE, pMgr ) );
2695 else
2696 rText += String( ResId( RID_SVXITEMS_BOXINF_MDIST_FALSE, pMgr ) );
2697 rText += cpDelim;
2698 rText += nDefDist;
2699 return SFX_ITEM_PRESENTATION_NAMELESS;
2701 rText.Erase();
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;
2712 if ( IsTable() )
2713 cFlags |= 0x01;
2714 if ( IsDist() )
2715 cFlags |= 0x02;
2716 if ( IsMinDist() )
2717 cFlags |= 0x04;
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 ];
2727 if( l )
2729 rStrm << (char) i
2730 << l->GetColor()
2731 << (short) l->GetOutWidth()
2732 << (short) l->GetInWidth()
2733 << (short) l->GetDistance();
2736 rStrm << (char) 2;
2737 return rStrm;
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 );
2747 return 1;
2750 // -----------------------------------------------------------------------
2752 int SvxBoxInfoItem::HasMetrics() const
2754 return 1;
2757 // -----------------------------------------------------------------------
2759 SfxPoolItem* SvxBoxInfoItem::Create( SvStream& rStrm, sal_uInt16 ) const
2761 sal_Int8 cFlags;
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 );
2772 while( sal_True )
2774 sal_Int8 cLine;
2775 rStrm >> cLine;
2777 if( cLine > 1 )
2778 break;
2779 short nOutline, nInline, nDistance;
2780 Color aColor;
2781 rStrm >> aColor >> nOutline >> nInline >> nDistance;
2782 SvxBorderLine aBorder( &aColor, nOutline, nInline, nDistance );
2784 switch( cLine )
2786 case 0: pAttr->SetLine( &aBorder, BOXINFO_LINE_HORI ); break;
2787 case 1: pAttr->SetLine( &aBorder, BOXINFO_LINE_VERT ); break;
2790 return pAttr;
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;
2804 sal_Int16 nVal=0;
2805 sal_Bool bIntMember = sal_False;
2806 nMemberId &= ~CONVERT_TWIPS;
2807 sal_Bool bSerialize = sal_False;
2808 switch(nMemberId)
2810 case 0:
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) );
2816 if ( IsTable() )
2817 nVal |= 0x01;
2818 if ( IsDist() )
2819 nVal |= 0x02;
2820 if ( IsMinDist() )
2821 nVal |= 0x04;
2822 aSeq[2] = ::com::sun::star::uno::makeAny( nVal );
2823 nVal = nValidFlags;
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 );
2827 return sal_True;
2830 case MID_HORIZONTAL:
2831 bSerialize = sal_True;
2832 aRetLine = lcl_SvxLineToLine( pHori, bConvert);
2833 break;
2834 case MID_VERTICAL:
2835 bSerialize = sal_True;
2836 aRetLine = lcl_SvxLineToLine( pVert, bConvert);
2837 break;
2838 case MID_FLAGS:
2839 bIntMember = sal_True;
2840 if ( IsTable() )
2841 nVal |= 0x01;
2842 if ( IsDist() )
2843 nVal |= 0x02;
2844 if ( IsMinDist() )
2845 nVal |= 0x04;
2846 rVal <<= nVal;
2847 break;
2848 case MID_VALIDFLAGS:
2849 bIntMember = sal_True;
2850 nVal = nValidFlags;
2851 rVal <<= nVal;
2852 break;
2853 case MID_DISTANCE:
2854 bIntMember = sal_True;
2855 rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist());
2856 break;
2857 default: DBG_ERROR("Wrong MemberId!"); return sal_False;
2860 if( !bIntMember )
2863 if ( bSerialize )
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;
2870 rVal <<= aSeq;
2872 else
2874 rVal <<= aRetLine;
2877 return sal_True;
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;
2888 sal_Bool bRet;
2889 switch(nMemberId)
2891 case 0:
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);
2904 if ( bSet )
2905 SetLine( &aLine, BOXINFO_LINE_HORI );
2907 else
2908 return sal_False;
2909 if ( aSeq[1] >>= aBorderLine )
2911 sal_Bool bSet = lcl_LineToSvxLine(aBorderLine, aLine, bConvert);
2912 if ( bSet )
2913 SetLine( &aLine, BOXINFO_LINE_VERT );
2915 else
2916 return sal_False;
2917 if ( aSeq[2] >>= nFlags )
2919 SetTable ( ( nFlags & 0x01 ) != 0 );
2920 SetDist ( ( nFlags & 0x02 ) != 0 );
2921 SetMinDist( ( nFlags & 0x04 ) != 0 );
2923 else
2924 return sal_False;
2925 if ( aSeq[3] >>= nFlags )
2926 nValidFlags = (BYTE)nFlags;
2927 else
2928 return sal_False;
2929 if (( aSeq[4] >>= nVal ) && ( nVal >= 0 ))
2931 if( bConvert )
2932 nVal = MM100_TO_TWIP(nVal);
2933 SetDefDist( (USHORT)nVal );
2936 return sal_True;
2939 case MID_HORIZONTAL:
2940 case MID_VERTICAL:
2942 if( !rVal.hasValue() )
2943 return sal_False;
2945 table::BorderLine aBorderLine;
2946 if( rVal >>= aBorderLine )
2948 // usual struct
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")),
2955 uno::UNO_QUERY );
2956 uno::Any aNew;
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 )
2963 sal_Int32 nVal = 0;
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;
2973 else
2974 return sal_False;
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;
2980 rVal >>= 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];
2988 else
2989 return sal_False;
2991 else
2992 return sal_False;
2994 SvxBorderLine aLine;
2995 sal_Bool bSet = lcl_LineToSvxLine(aBorderLine, aLine, bConvert);
2996 if ( bSet )
2997 SetLine( &aLine, nMemberId == MID_HORIZONTAL ? BOXINFO_LINE_HORI : BOXINFO_LINE_VERT );
2998 break;
3000 case MID_FLAGS:
3002 sal_Int16 nFlags = sal_Int16();
3003 bRet = (rVal >>= nFlags);
3004 if ( bRet )
3006 SetTable ( ( nFlags & 0x01 ) != 0 );
3007 SetDist ( ( nFlags & 0x02 ) != 0 );
3008 SetMinDist( ( nFlags & 0x04 ) != 0 );
3011 break;
3013 case MID_VALIDFLAGS:
3015 sal_Int16 nFlags = sal_Int16();
3016 bRet = (rVal >>= nFlags);
3017 if ( bRet )
3018 nValidFlags = (BYTE)nFlags;
3019 break;
3021 case MID_DISTANCE:
3023 sal_Int32 nVal = 0;
3024 bRet = (rVal >>= nVal);
3025 if ( bRet && nVal>=0 )
3027 if( bConvert )
3028 nVal = MM100_TO_TWIP(nVal);
3029 SetDefDist( (USHORT)nVal );
3031 break;
3033 default: DBG_ERROR("Wrong MemberId!"); return sal_False;
3036 return sal_True;
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 *
3056 ) const
3058 #ifndef SVX_LIGHT
3059 switch ( ePres )
3061 case SFX_ITEM_PRESENTATION_NONE:
3062 rText.Erase();
3063 return SFX_ITEM_PRESENTATION_NONE;
3065 case SFX_ITEM_PRESENTATION_NAMELESS:
3066 case SFX_ITEM_PRESENTATION_COMPLETE:
3067 rText = GetValueTextByPos( GetValue() );
3068 return ePres;
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 ) );
3081 return aStr;
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
3098 rVal <<= eBreak;
3099 return sal_True;
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))
3110 return sal_False;
3112 nBreak = (style::BreakType) nValue;
3115 SvxBreak eBreak = SVX_BREAK_NONE;
3116 switch( nBreak )
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);
3128 return sal_True;
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;
3145 return rStrm;
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;
3165 rStrm >> eBreak;
3166 if( FMTBREAK_NOAUTO > nVersion )
3167 rStrm >> bDummy;
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();
3190 return rStrm;
3193 // -----------------------------------------------------------------------
3195 SfxPoolItem* SvxFmtKeepItem::Create( SvStream& rStrm, sal_uInt16 ) const
3197 sal_Int8 bIsKeep;
3198 rStrm >> bIsKeep;
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 *
3210 ) const
3212 #ifndef SVX_LIGHT
3213 switch ( ePres )
3215 case SFX_ITEM_PRESENTATION_NONE:
3216 rText.Erase();
3217 return ePres;
3219 case SFX_ITEM_PRESENTATION_NAMELESS:
3220 case SFX_ITEM_PRESENTATION_COMPLETE:
3222 sal_uInt16 nId = RID_SVXITEMS_FMTKEEP_FALSE;
3224 if ( GetValue() )
3225 nId = RID_SVXITEMS_FMTKEEP_TRUE;
3226 rText = SVX_RESSTR(nId);
3227 return ePres;
3229 default: ;//prevent warning
3231 #endif
3232 return SFX_ITEM_PRESENTATION_NONE;
3235 // class SvxLineItem ------------------------------------------------------
3237 SvxLineItem::SvxLineItem( const sal_uInt16 nId ) :
3239 SfxPoolItem ( nId ),
3241 pLine( NULL )
3245 // -----------------------------------------------------------------------
3247 SvxLineItem::SvxLineItem( const SvxLineItem& rCpy ) :
3249 SfxPoolItem ( rCpy )
3251 pLine = rCpy.GetLine() ? new SvxBorderLine( *rCpy.GetLine() ) : 0;
3255 // -----------------------------------------------------------------------
3257 SvxLineItem::~SvxLineItem()
3259 delete pLine;
3262 // -----------------------------------------------------------------------
3264 SvxLineItem& SvxLineItem::operator=( const SvxLineItem& rLine )
3266 SetLine( rLine.GetLine() );
3268 return *this;
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;
3291 if ( nMemId == 0 )
3293 rVal <<= uno::makeAny( lcl_SvxLineToLine(pLine, bConvert) );
3294 return sal_True;
3296 else if ( pLine )
3298 switch ( nMemId )
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;
3304 default:
3305 DBG_ERROR( "Wrong MemberId" );
3306 return sal_False;
3310 return TRUE;
3313 // -----------------------------------------------------------------------
3315 sal_Bool SvxLineItem::PutValue( const uno::Any& rVal, BYTE nMemId )
3317 sal_Bool bConvert = 0!=(nMemId&CONVERT_TWIPS);
3318 nMemId &= ~CONVERT_TWIPS;
3319 sal_Int32 nVal = 0;
3320 if ( nMemId == 0 )
3322 table::BorderLine aLine;
3323 if ( rVal >>= aLine )
3325 if ( !pLine )
3326 pLine = new SvxBorderLine;
3327 if( !lcl_LineToSvxLine(aLine, *pLine, bConvert) )
3328 DELETEZ( pLine );
3329 return sal_True;
3331 return sal_False;
3333 else if ( rVal >>= nVal )
3335 if ( !pLine )
3336 pLine = new SvxBorderLine;
3338 switch ( nMemId )
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;
3344 default:
3345 DBG_ERROR( "Wrong MemberId" );
3346 return sal_False;
3349 return sal_True;
3352 return sal_False;
3355 //------------------------------------------------------------------------
3357 SfxItemPresentation SvxLineItem::GetPresentation
3359 SfxItemPresentation ePres,
3360 SfxMapUnit eCoreUnit,
3361 SfxMapUnit ePresUnit,
3362 XubString& rText, const IntlWrapper *pIntl
3363 ) const
3365 #ifndef SVX_LIGHT
3366 rText.Erase();
3368 switch ( ePres )
3370 case SFX_ITEM_PRESENTATION_NONE:
3371 return SFX_ITEM_PRESENTATION_NONE;
3372 case SFX_ITEM_PRESENTATION_NAMELESS:
3373 case SFX_ITEM_PRESENTATION_COMPLETE:
3375 if ( pLine )
3376 rText = pLine->GetValueString( eCoreUnit, ePresUnit, pIntl,
3377 (SFX_ITEM_PRESENTATION_COMPLETE == ePres) );
3378 return ePres;
3380 default: ;//prevent warning
3382 #endif
3383 return SFX_ITEM_PRESENTATION_NONE;
3386 // -----------------------------------------------------------------------
3388 SvStream& SvxLineItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
3390 if( pLine )
3392 rStrm << pLine->GetColor()
3393 << (short)pLine->GetOutWidth()
3394 << (short)pLine->GetInWidth()
3395 << (short)pLine->GetDistance();
3397 else
3398 rStrm << Color() << (short)0 << (short)0 << (short)0;
3399 return rStrm;
3402 // -----------------------------------------------------------------------
3404 int SvxLineItem::ScaleMetrics( long nMult, long nDiv )
3406 if ( pLine ) pLine->ScaleMetrics( nMult, nDiv );
3407 return 1;
3410 // -----------------------------------------------------------------------
3412 int SvxLineItem::HasMetrics() const
3414 return 1;
3417 // -----------------------------------------------------------------------
3419 SfxPoolItem* SvxLineItem::Create( SvStream& rStrm, sal_uInt16 ) const
3421 SvxLineItem* _pLine = new SvxLineItem( Which() );
3422 short nOutline, nInline, nDistance;
3423 Color aColor;
3425 rStrm >> aColor >> nOutline >> nInline >> nDistance;
3426 if( nOutline )
3428 SvxBorderLine aLine( &aColor, nOutline, nInline, nDistance );
3429 _pLine->SetLine( &aLine );
3431 return _pLine;
3434 // -----------------------------------------------------------------------
3436 void SvxLineItem::SetLine( const SvxBorderLine* pNew )
3438 delete pLine;
3439 pLine = pNew ? new SvxBorderLine( *pNew ) : 0;
3442 #ifdef _MSC_VER
3443 #pragma optimize ( "", off )
3444 #endif
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
3456 public:
3457 GraphicObject* pGraphicObject;
3458 sal_Int8 nGraphicTransparency; //contains a percentage value which is
3459 //copied to the GraphicObject when necessary
3460 #ifndef SVX_LIGHT
3461 SfxMediumRef xMedium;
3462 #endif
3463 Link aDoneLink;
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)
3481 Graphic aResult;
3482 SvxBrushItem aItem( rLink, rFilter, GPOS_TILED );
3483 const Graphic* pGraph = aItem.GetGraphic();
3484 if( pGraph )
3485 aResult = *pGraph;
3486 return aResult;
3489 // -----------------------------------------------------------------------
3491 CreateSvxBrushTabPage SvxBrushItemLink_Impl::GetBackgroundTabpageCreateFunc()
3493 #ifndef SVX_LIGHT
3494 return (CreateSvxBrushTabPage)SvxBackgroundTabPage::Create;
3495 #else
3496 return CreateSvxBrushTabPage();
3497 #endif
3500 // -----------------------------------------------------------------------
3502 GetSvxBrushTabPageRanges SvxBrushItemLink_Impl::GetBackgroundTabpageRanges()
3504 #ifndef SVX_LIGHT
3505 return (GetSvxBrushTabPageRanges)SvxBackgroundTabPage::GetRanges;
3506 #else
3507 return GetSvxBrushTabPageRanges();
3508 #endif
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 ) ),
3533 pStrLink ( NULL ),
3534 pStrFilter ( NULL ),
3535 eGraphicPos ( GPOS_NONE ),
3536 bLoadAgain ( sal_True )
3541 // -----------------------------------------------------------------------
3543 SvxBrushItem::SvxBrushItem( const Color& rColor, sal_uInt16 _nWhich) :
3545 SfxPoolItem( _nWhich ),
3547 aColor ( rColor ),
3548 pImpl ( new SvxBrushItem_Impl( 0 ) ),
3549 pStrLink ( NULL ),
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 ) ) ),
3566 pStrLink ( NULL ),
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 ) ) ),
3584 pStrLink ( NULL ),
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 ) ),
3621 pStrLink ( NULL ),
3622 pStrFilter ( NULL ),
3623 eGraphicPos ( GPOS_NONE )
3626 sal_Bool bTrans;
3627 Color aTempColor;
3628 Color aTempFillColor;
3629 sal_Int8 nStyle;
3631 rStream >> bTrans;
3632 rStream >> aTempColor;
3633 rStream >> aTempFillColor;
3634 rStream >> nStyle;
3636 switch ( nStyle )
3638 case 8://BRUSH_25:
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) );
3648 break;
3650 case 9://BRUSH_50:
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) );
3660 break;
3662 case 10://BRUSH_75:
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) );
3672 break;
3674 case 0://BRUSH_NULL:
3675 aColor = Color( COL_TRANSPARENT );
3676 break;
3678 default:
3679 aColor = aTempColor;
3682 if ( nVersion >= BRUSH_GRAPHIC_VERSION )
3684 sal_uInt16 nDoLoad = 0;
3685 sal_Int8 nPos;
3687 rStream >> nDoLoad;
3689 if ( nDoLoad & LOAD_GRAPHIC )
3691 Graphic aGraphic;
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 )
3706 String aRel;
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);
3724 rStream >> nPos;
3726 eGraphicPos = (SvxGraphicPosition)nPos;
3730 // -----------------------------------------------------------------------
3732 SvxBrushItem::SvxBrushItem( const SvxBrushItem& rItem ) :
3734 SfxPoolItem( rItem.Which() ),
3736 pImpl ( new SvxBrushItem_Impl( NULL ) ),
3737 pStrLink ( NULL ),
3738 pStrFilter ( NULL ),
3739 eGraphicPos ( GPOS_NONE ),
3740 bLoadAgain ( sal_True )
3743 *this = rItem;
3746 // -----------------------------------------------------------------------
3748 SvxBrushItem::~SvxBrushItem()
3750 #ifndef SVX_LIGHT
3751 if( pImpl->xMedium.Is() )
3752 pImpl->xMedium->SetDoneLink( Link() );
3753 #endif
3754 delete pImpl->pGraphicObject;
3755 delete pImpl;
3756 delete pStrLink;
3757 delete pStrFilter;
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;
3782 switch( nMemberId)
3784 case MID_BACK_COLOR:
3785 rVal <<= (sal_Int32)( aColor.GetColor() );
3786 break;
3787 case MID_BACK_COLOR_R_G_B:
3788 rVal <<= (sal_Int32)( aColor.GetRGBColor() );
3789 break;
3790 case MID_BACK_COLOR_TRANSPARENCY:
3791 rVal <<= lcl_TransparencyToPercent(aColor.GetTransparency());
3792 break;
3793 case MID_GRAPHIC_POSITION:
3794 rVal <<= (style::GraphicLocation)(sal_Int16)eGraphicPos;
3795 break;
3797 case MID_GRAPHIC:
3798 DBG_ERRORFILE( "not implemented" );
3799 break;
3801 case MID_GRAPHIC_TRANSPARENT:
3802 rVal = Bool2Any( aColor.GetTransparency() == 0xff );
3803 break;
3805 case MID_GRAPHIC_URL:
3807 OUString sLink;
3808 if ( pStrLink )
3809 sLink = *pStrLink;
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 );
3815 sLink = sPrefix;
3816 sLink += OUString(sId);
3818 rVal <<= sLink;
3820 break;
3822 case MID_GRAPHIC_FILTER:
3824 OUString sFilter;
3825 if ( pStrFilter )
3826 sFilter = *pStrFilter;
3827 rVal <<= sFilter;
3829 break;
3830 case MID_GRAPHIC_TRANSPARENCY :
3831 rVal <<= pImpl->nGraphicTransparency;
3832 break;
3835 return sal_True;
3838 // -----------------------------------------------------------------------
3840 sal_Bool SvxBrushItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
3842 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3843 nMemberId &= ~CONVERT_TWIPS;
3844 switch( nMemberId)
3846 case MID_BACK_COLOR:
3847 case MID_BACK_COLOR_R_G_B:
3849 sal_Int32 nCol = 0;
3850 if ( !( rVal >>= nCol ) )
3851 return sal_False;
3852 if(MID_BACK_COLOR_R_G_B == nMemberId)
3854 nCol = COLORDATA_RGB( nCol );
3855 nCol += aColor.GetColor() & 0xff000000;
3857 aColor = Color( nCol );
3859 break;
3860 case MID_BACK_COLOR_TRANSPARENCY:
3862 sal_Int32 nTrans = 0;
3863 if ( !( rVal >>= nTrans ) || nTrans < 0 || nTrans > 100 )
3864 return sal_False;
3865 aColor.SetTransparency(lcl_PercentToTransparency(nTrans));
3867 break;
3869 case MID_GRAPHIC_POSITION:
3871 style::GraphicLocation eLocation;
3872 if ( !( rVal>>=eLocation ) )
3874 sal_Int32 nValue = 0;
3875 if ( !( rVal >>= nValue ) )
3876 return sal_False;
3877 eLocation = (style::GraphicLocation)nValue;
3879 SetGraphicPos( (SvxGraphicPosition)(sal_uInt16)eLocation );
3881 break;
3883 case MID_GRAPHIC:
3884 DBG_ERRORFILE( "not implemented" );
3885 break;
3887 case MID_GRAPHIC_TRANSPARENT:
3888 aColor.SetTransparency( Any2Bool( rVal ) ? 0xff : 0 );
3889 break;
3891 case MID_GRAPHIC_URL:
3893 if ( rVal.getValueType() == ::getCppuType( (OUString*)0 ) )
3895 OUString sLink;
3896 rVal >>= sLink;
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();
3913 delete pOldGrfObj;
3915 else
3917 SetGraphicLink(sLink);
3919 if ( sLink.getLength() && eGraphicPos == GPOS_NONE )
3920 eGraphicPos = GPOS_MM;
3921 else if( !sLink.getLength() )
3922 eGraphicPos = GPOS_NONE;
3925 break;
3927 case MID_GRAPHIC_FILTER:
3929 if( rVal.getValueType() == ::getCppuType( (OUString*)0 ) )
3931 OUString sLink;
3932 rVal >>= sLink;
3933 SetGraphicFilter( sLink );
3936 break;
3937 case MID_GRAPHIC_TRANSPARENCY :
3939 sal_Int32 nTmp = 0;
3940 rVal >>= nTmp;
3941 if(nTmp >= 0 && nTmp <= 100)
3943 pImpl->nGraphicTransparency = sal_Int8(nTmp);
3944 if(pImpl->pGraphicObject)
3945 ApplyGraphicTransparency_Impl();
3948 break;
3951 return sal_True;
3954 // -----------------------------------------------------------------------
3956 SfxItemPresentation SvxBrushItem::GetPresentation
3958 SfxItemPresentation ePres,
3959 SfxMapUnit /*eCoreUnit*/,
3960 SfxMapUnit /*ePresUnit*/,
3961 XubString& rText, const IntlWrapper *
3962 ) const
3964 #ifndef SVX_LIGHT
3965 switch ( ePres )
3967 case SFX_ITEM_PRESENTATION_NONE:
3968 rText.Erase();
3969 return ePres;
3971 case SFX_ITEM_PRESENTATION_NAMELESS:
3972 case SFX_ITEM_PRESENTATION_COMPLETE:
3974 if ( GPOS_NONE == eGraphicPos )
3976 rText = ::GetColorString( aColor );
3977 rText += cpDelim;
3978 sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
3980 if ( aColor.GetTransparency() )
3981 nId = RID_SVXITEMS_TRANSPARENT_TRUE;
3982 rText += SVX_RESSTR(nId);
3984 else
3986 rText = SVX_RESSTR(RID_SVXITEMS_GRAPHIC);
3989 return ePres;
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;
4020 return *this;
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);
4033 if ( bEqual )
4035 if ( GPOS_NONE != eGraphicPos )
4037 if ( !rCmp.pStrLink )
4038 bEqual = !pStrLink;
4039 else
4040 bEqual = pStrLink && ( *pStrLink == *rCmp.pStrLink );
4042 if ( bEqual )
4044 if ( !rCmp.pStrFilter )
4045 bEqual = !pStrFilter;
4046 else
4047 bEqual = pStrFilter && ( *pStrFilter == *rCmp.pStrFilter );
4050 if ( bEqual && !rCmp.pStrLink )
4052 if ( !rCmp.pImpl->pGraphicObject )
4053 bEqual = !pImpl->pGraphicObject;
4054 else
4055 bEqual = pImpl->pGraphicObject &&
4056 ( *pImpl->pGraphicObject == *rCmp.pImpl->pGraphicObject );
4061 return bEqual;
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;
4083 rStream << aColor;
4084 rStream << aColor;
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;
4091 if ( pStrLink )
4092 nDoLoad |= LOAD_LINK;
4093 if ( pStrFilter )
4094 nDoLoad |= LOAD_FILTER;
4095 rStream << nDoLoad;
4097 if ( pImpl->pGraphicObject && !pStrLink )
4098 rStream << pImpl->pGraphicObject->GetGraphic();
4099 if ( pStrLink )
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);
4107 if ( pStrFilter )
4109 // UNICODE: rStream << *pStrFilter;
4110 rStream.WriteByteString(*pStrFilter);
4112 rStream << (sal_Int8)eGraphicPos;
4113 return rStream;
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 )
4125 #ifndef SVX_LIGHT
4126 pThis->pImpl->pGraphicObject = new GraphicObject;
4127 SvStream* pStream = pThis->pImpl->xMedium->GetInStream();
4128 if( pStream && !pStream->GetError() )
4130 Graphic aGraphic;
4131 int nRes;
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;
4142 else
4144 pThis->pImpl->pGraphicObject->SetGraphic( aGraphic );
4145 pThis->ApplyGraphicTransparency_Impl();
4148 else
4150 DELETEZ( pThis->pImpl->pGraphicObject );
4151 pThis->bLoadAgain = sal_False;
4154 pThis->pImpl->xMedium.Clear();
4155 pThis->pImpl->aDoneLink.Call( pThis );
4156 #endif
4157 return 0;
4160 // -----------------------------------------------------------------------
4162 void SvxBrushItem::PurgeGraphic() const
4164 #ifndef SVX_LIGHT
4165 PurgeMedium();
4166 DELETEZ( pImpl->pGraphicObject );
4167 ((SvxBrushItem*)this)->bLoadAgain = sal_True;
4168 #endif
4171 // -----------------------------------------------------------------------
4173 void SvxBrushItem::PurgeMedium() const
4175 #ifndef SVX_LIGHT
4176 pImpl->xMedium.Clear();
4177 #endif
4180 // -----------------------------------------------------------------------
4182 const GraphicObject* SvxBrushItem::GetGraphicObject( SfxObjectShell* pSh ) const
4184 #ifndef SVX_LIGHT
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() )
4196 if( pSh )
4198 pSh->RegisterTransfer( *pImpl->xMedium );
4200 else
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
4213 // der Daten
4215 Link aTmp = pImpl->aDoneLink;
4216 pImpl->aDoneLink = Link();
4217 pImpl->xMedium->DownLoad(
4218 STATIC_LINK( this, SvxBrushItem, DoneHdl_Impl ) );
4219 pImpl->aDoneLink = aTmp;
4221 else
4223 pImpl->xMedium->DownLoad( );
4224 DoneHdl_Impl( (SvxBrushItem*)this, 0 );
4228 #endif
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 )
4244 eGraphicPos = eNew;
4246 if ( GPOS_NONE == eGraphicPos )
4248 DELETEZ( pImpl->pGraphicObject );
4249 DELETEZ( pStrLink );
4250 DELETEZ( pStrFilter );
4252 else
4254 if ( !pImpl->pGraphicObject && !pStrLink )
4256 pImpl->pGraphicObject = new GraphicObject; // dummy anlegen
4261 // -----------------------------------------------------------------------
4263 void SvxBrushItem::SetGraphic( const Graphic& rNew )
4265 if ( !pStrLink )
4267 if ( pImpl->pGraphicObject )
4268 pImpl->pGraphicObject->SetGraphic( rNew );
4269 else
4270 pImpl->pGraphicObject = new GraphicObject( rNew );
4272 ApplyGraphicTransparency_Impl();
4274 if ( GPOS_NONE == eGraphicPos )
4275 eGraphicPos = GPOS_MM; // None waere Brush, also Default: Mitte
4277 else
4279 DBG_ERROR( "SetGraphic() on linked graphic! :-/" );
4283 // -----------------------------------------------------------------------
4285 void SvxBrushItem::SetGraphicObject( const GraphicObject& rNewObj )
4287 if ( !pStrLink )
4289 if ( pImpl->pGraphicObject )
4290 *pImpl->pGraphicObject = rNewObj;
4291 else
4292 pImpl->pGraphicObject = new GraphicObject( rNewObj );
4294 ApplyGraphicTransparency_Impl();
4296 if ( GPOS_NONE == eGraphicPos )
4297 eGraphicPos = GPOS_MM; // None waere Brush, also Default: Mitte
4299 else
4301 DBG_ERROR( "SetGraphic() on linked graphic! :-/" );
4305 // -----------------------------------------------------------------------
4307 void SvxBrushItem::SetGraphicLink( const String& rNew )
4309 if ( !rNew.Len() )
4310 DELETEZ( pStrLink );
4311 else
4313 if ( pStrLink )
4314 *pStrLink = rNew;
4315 else
4316 pStrLink = new String( rNew );
4318 DELETEZ( pImpl->pGraphicObject );
4322 // -----------------------------------------------------------------------
4324 void SvxBrushItem::SetGraphicFilter( const String& rNew )
4326 if ( !rNew.Len() )
4327 DELETEZ( pStrFilter );
4328 else
4330 if ( pStrFilter )
4331 *pStrFilter = rNew;
4332 else
4333 pStrFilter = new String( rNew );
4337 //static
4338 SvxGraphicPosition SvxBrushItem::WallpaperStyle2GraphicPos( WallpaperStyle eStyle )
4340 SvxGraphicPosition eResult;
4341 // der Switch ist nicht der schnellste, dafuer aber am sichersten
4342 switch( eStyle )
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;
4358 return eResult;
4361 //static
4362 WallpaperStyle SvxBrushItem::GraphicPos2WallpaperStyle( SvxGraphicPosition ePos )
4364 WallpaperStyle eResult;
4365 switch( ePos )
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;
4381 return eResult;
4385 SvxBrushItem::SvxBrushItem( const CntWallpaperItem& rItem, sal_uInt16 _nWhich ) :
4386 SfxPoolItem( _nWhich ),
4387 pImpl( new SvxBrushItem_Impl( 0 ) ),
4388 pStrLink(0),
4389 pStrFilter(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);
4407 if( bLink )
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 );
4418 return pItem;
4421 #ifdef _MSC_VER
4422 #pragma optimize ( "", on )
4423 #endif
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 ,
4446 USHORT _nWhich )
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
4469 sal_uInt16 nValue;
4470 rStrm >> nValue;
4471 return new SvxFrameDirectionItem( (SvxFrameDirection)nValue, Which() );
4474 SvStream& SvxFrameDirectionItem::Store( SvStream & rStrm, USHORT /*nIVer*/ ) const
4476 sal_uInt16 nValue = GetValue();
4477 rStrm << nValue;
4478 return rStrm;
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;
4493 switch( ePres )
4495 case SFX_ITEM_PRESENTATION_NONE:
4496 rText.Erase();
4497 break;
4499 case SFX_ITEM_PRESENTATION_NAMELESS:
4500 case SFX_ITEM_PRESENTATION_COMPLETE:
4501 rText = SVX_RESSTR( RID_SVXITEMS_FRMDIR_BEGIN + GetValue() );
4502 break;
4504 default:
4505 eRet = SFX_ITEM_PRESENTATION_NONE;
4507 return eRet;
4510 sal_Bool SvxFrameDirectionItem::PutValue( const com::sun::star::uno::Any& rVal,
4511 BYTE )
4513 sal_Int16 nVal = sal_Int16();
4514 sal_Bool bRet = ( rVal >>= nVal );
4515 if( bRet )
4517 // translate WritingDirection2 constants into SvxFrameDirection
4518 switch( nVal )
4520 case text::WritingMode2::LR_TB:
4521 SetValue( FRMDIR_HORI_LEFT_TOP );
4522 break;
4523 case text::WritingMode2::RL_TB:
4524 SetValue( FRMDIR_HORI_RIGHT_TOP );
4525 break;
4526 case text::WritingMode2::TB_RL:
4527 SetValue( FRMDIR_VERT_TOP_RIGHT );
4528 break;
4529 case text::WritingMode2::TB_LR:
4530 SetValue( FRMDIR_VERT_TOP_LEFT );
4531 break;
4532 case text::WritingMode2::PAGE:
4533 SetValue( FRMDIR_ENVIRONMENT );
4534 break;
4535 default:
4536 bRet = sal_False;
4537 break;
4541 return bRet;
4544 sal_Bool SvxFrameDirectionItem::QueryValue( com::sun::star::uno::Any& rVal,
4545 BYTE ) const
4547 // translate SvxFrameDirection into WritingDirection2
4548 sal_Int16 nVal;
4549 sal_Bool bRet = sal_True;
4550 switch( GetValue() )
4552 case FRMDIR_HORI_LEFT_TOP:
4553 nVal = text::WritingMode2::LR_TB;
4554 break;
4555 case FRMDIR_HORI_RIGHT_TOP:
4556 nVal = text::WritingMode2::RL_TB;
4557 break;
4558 case FRMDIR_VERT_TOP_RIGHT:
4559 nVal = text::WritingMode2::TB_RL;
4560 break;
4561 case FRMDIR_VERT_TOP_LEFT:
4562 nVal = text::WritingMode2::TB_LR;
4563 break;
4564 case FRMDIR_ENVIRONMENT:
4565 nVal = text::WritingMode2::PAGE;
4566 break;
4567 default:
4568 DBG_ERROR("Unknown SvxFrameDirection value!");
4569 bRet = sal_False;
4570 break;
4573 // return value + error state
4574 if( bRet )
4576 rVal <<= nVal;
4578 return bRet;