xref: /trunk/main/editeng/source/items/frmitems.cxx (revision 137931e43899a1545869cb6af6ea936d8cee4956) !
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_editeng.hxx"
26 
27 // include ---------------------------------------------------------------
28 #include <com/sun/star/uno/Any.hxx>
29 #include <com/sun/star/script/XTypeConverter.hpp>
30 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31 #include <com/sun/star/table/CellVertJustify.hpp>
32 #include <com/sun/star/table/ShadowLocation.hpp>
33 #include <com/sun/star/table/TableBorder.hpp>
34 #include <com/sun/star/table/ShadowFormat.hpp>
35 #include <com/sun/star/table/CellRangeAddress.hpp>
36 #include <com/sun/star/table/CellContentType.hpp>
37 #include <com/sun/star/table/TableOrientation.hpp>
38 #include <com/sun/star/table/CellHoriJustify.hpp>
39 #include <com/sun/star/util/SortField.hpp>
40 #include <com/sun/star/util/SortFieldType.hpp>
41 #include <com/sun/star/table/CellOrientation.hpp>
42 #include <com/sun/star/table/CellAddress.hpp>
43 #include <com/sun/star/style/PageStyleLayout.hpp>
44 #include <com/sun/star/style/BreakType.hpp>
45 #include <com/sun/star/style/GraphicLocation.hpp>
46 #include <com/sun/star/awt/Rectangle.hpp>
47 #include <com/sun/star/awt/Selection.hpp>
48 #include <com/sun/star/awt/Size.hpp>
49 #include <com/sun/star/text/WritingMode2.hpp>
50 #include <com/sun/star/frame/status/UpperLowerMarginScale.hpp>
51 
52 #include <unotools/ucbstreamhelper.hxx>
53 #include <limits.h>
54 #include <comphelper/processfactory.hxx>
55 #include <svtools/grfmgr.hxx>
56 #include <svtools/linkpolicy.hxx>
57 #include <tools/urlobj.hxx>
58 #include <comphelper/types.hxx>
59 #include <svl/memberid.hrc>
60 #include <svtools/wallitem.hxx>
61 #include <svl/cntwall.hxx>
62 #include <rtl/ustring.hxx>
63 #include <rtl/ustrbuf.hxx>
64 #include <svtools/filter.hxx>
65 
66 #define GLOBALOVERFLOW3
67 
68 #define _SVX_FRMITEMS_CXX
69 
70 #include <editeng/editids.hrc>
71 #include <editeng/editrids.hrc>
72 #include <editeng/pbinitem.hxx>
73 #include <editeng/sizeitem.hxx>
74 #include <editeng/lrspitem.hxx>
75 #include <editeng/ulspitem.hxx>
76 #include <editeng/prntitem.hxx>
77 #include <editeng/opaqitem.hxx>
78 #include <editeng/protitem.hxx>
79 #include <editeng/shaditem.hxx>
80 #include <editeng/boxitem.hxx>
81 #include <editeng/brkitem.hxx>
82 #include <editeng/keepitem.hxx>
83 #include <editeng/bolnitem.hxx>
84 #include <editeng/brshitem.hxx>
85 #include <editeng/frmdiritem.hxx>
86 #include <editeng/itemtype.hxx>
87 #include <editeng/eerdll.hxx>
88 #include <editeng/unoprnms.hxx>
89 #include <editeng/memberids.hrc>
90 #include <editeng/editerr.hxx>
91 
92 using namespace ::rtl;
93 using namespace ::com::sun::star;
94 
95 
96 // Konvertierung fuer UNO
97 #define TWIP_TO_MM100(TWIP)     ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
98 #define MM100_TO_TWIP(MM100)    ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
99 #define TWIP_TO_MM100_UNSIGNED(TWIP)     ((((TWIP)*127L+36L)/72L))
100 #define MM100_TO_TWIP_UNSIGNED(MM100)    ((((MM100)*72L+63L)/127L))
101 
102 // STATIC DATA -----------------------------------------------------------
103 
104 
SetValueProp(XubString & rStr,const sal_uInt16 nValue,const sal_uInt16 nProp)105 inline void SetValueProp( XubString& rStr, const sal_uInt16 nValue,
106                           const sal_uInt16 nProp )
107 {
108     if( 100 == nProp )
109         rStr += String::CreateFromInt32( nValue );
110     else
111         ( rStr += String::CreateFromInt32( nProp )) += sal_Unicode('%');
112 }
113 
SetValueProp(XubString & rStr,const short nValue,const sal_uInt16 nProp)114 inline void SetValueProp( XubString& rStr, const short nValue,
115                           const sal_uInt16 nProp )
116 {
117     if( 100 == nProp )
118         rStr += String::CreateFromInt32( nValue );
119     else
120         ( rStr += String::CreateFromInt32( nProp )) += sal_Unicode('%');
121 }
122 
123 // -----------------------------------------------------------------------
124 
125 TYPEINIT1_FACTORY(SvxPaperBinItem, SfxByteItem, new SvxPaperBinItem(0));
126 TYPEINIT1_FACTORY(SvxSizeItem, SfxPoolItem, new SvxSizeItem(0));
127 TYPEINIT1_FACTORY(SvxLRSpaceItem, SfxPoolItem, new SvxLRSpaceItem(0));
128 TYPEINIT1_FACTORY(SvxULSpaceItem, SfxPoolItem, new SvxULSpaceItem(0));
129 TYPEINIT1_FACTORY(SvxPrintItem, SfxBoolItem, new SvxPrintItem(0));
130 TYPEINIT1_FACTORY(SvxOpaqueItem, SfxBoolItem, new SvxOpaqueItem(0));
131 TYPEINIT1_FACTORY(SvxProtectItem, SfxPoolItem, new SvxProtectItem(0));
132 TYPEINIT1_FACTORY(SvxBrushItem, SfxPoolItem, new SvxBrushItem(0));
133 TYPEINIT1_FACTORY(SvxShadowItem, SfxPoolItem, new SvxShadowItem(0));
134 TYPEINIT1_FACTORY(SvxBoxItem, SfxPoolItem, new SvxBoxItem(0));
135 TYPEINIT1_FACTORY(SvxBoxInfoItem, SfxPoolItem, new SvxBoxInfoItem(0));
136 TYPEINIT1_FACTORY(SvxFmtBreakItem, SfxEnumItem, new SvxFmtBreakItem(SVX_BREAK_NONE, 0));
137 TYPEINIT1_FACTORY(SvxFmtKeepItem, SfxBoolItem, new SvxFmtKeepItem(sal_False, 0));
138 TYPEINIT1_FACTORY(SvxLineItem, SfxPoolItem, new SvxLineItem(0));
139 TYPEINIT1_FACTORY(SvxFrameDirectionItem, SfxUInt16Item, new SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP, 0));
140 
141 
142 // class SvxPaperBinItem ------------------------------------------------
143 
Clone(SfxItemPool *) const144 SfxPoolItem* SvxPaperBinItem::Clone( SfxItemPool* ) const
145 {
146     return new SvxPaperBinItem( *this );
147 }
148 
149 // -----------------------------------------------------------------------
150 
Store(SvStream & rStrm,sal_uInt16) const151 SvStream& SvxPaperBinItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
152 {
153     rStrm << GetValue();
154     return rStrm;
155 }
156 
157 // -----------------------------------------------------------------------
158 
Create(SvStream & rStrm,sal_uInt16) const159 SfxPoolItem* SvxPaperBinItem::Create( SvStream& rStrm, sal_uInt16 ) const
160 {
161     sal_Int8 nBin;
162     rStrm >> nBin;
163     return new SvxPaperBinItem( Which(), nBin );
164 }
165 
166 // -----------------------------------------------------------------------
167 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const168 SfxItemPresentation SvxPaperBinItem::GetPresentation
169 (
170     SfxItemPresentation ePres,
171     SfxMapUnit          /*eCoreUnit*/,
172     SfxMapUnit          /*ePresUnit*/,
173     XubString&          rText, const IntlWrapper *
174 )   const
175 {
176     switch ( ePres )
177     {
178         case SFX_ITEM_PRESENTATION_NONE:
179             rText.Erase();
180             return SFX_ITEM_PRESENTATION_NONE;
181 
182         case SFX_ITEM_PRESENTATION_NAMELESS:
183             rText = String::CreateFromInt32( GetValue() );
184             return SFX_ITEM_PRESENTATION_NAMELESS;
185 
186         case SFX_ITEM_PRESENTATION_COMPLETE:
187         {
188             sal_uInt8 nValue = GetValue();
189 
190             if ( PAPERBIN_PRINTER_SETTINGS == nValue )
191                 rText = EE_RESSTR(RID_SVXSTR_PAPERBIN_SETTINGS);
192             else
193             {
194                 rText = EE_RESSTR(RID_SVXSTR_PAPERBIN);
195                 rText += sal_Unicode(' ');
196                 rText += String::CreateFromInt32( nValue );
197             }
198             return SFX_ITEM_PRESENTATION_COMPLETE;
199         }
200         //no break necessary
201         default: ;//prevent warning
202     }
203 
204     return SFX_ITEM_PRESENTATION_NONE;
205 }
206 
207 // class SvxSizeItem -----------------------------------------------------
208 
SvxSizeItem(const sal_uInt16 nId,const Size & rSize)209 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId, const Size& rSize ) :
210 
211     SfxPoolItem( nId ),
212 
213     aSize( rSize )
214 {
215 }
216 
217 // -----------------------------------------------------------------------
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const218 sal_Bool SvxSizeItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
219 {
220     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
221     nMemberId &= ~CONVERT_TWIPS;
222 
223     awt::Size aTmp(aSize.Width(), aSize.Height());
224     if( bConvert )
225     {
226         aTmp.Height = TWIP_TO_MM100(aTmp.Height);
227         aTmp.Width = TWIP_TO_MM100(aTmp.Width);
228     }
229 
230     switch( nMemberId )
231     {
232         case MID_SIZE_SIZE:  rVal <<= aTmp; break;
233         case MID_SIZE_WIDTH: rVal <<= aTmp.Width; break;
234         case MID_SIZE_HEIGHT: rVal <<= aTmp.Height;  break;
235         default: DBG_ERROR("Wrong MemberId!"); return sal_False;
236     }
237 
238     return sal_True;
239 }
240 // -----------------------------------------------------------------------
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)241 sal_Bool SvxSizeItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
242 {
243     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
244     nMemberId &= ~CONVERT_TWIPS;
245 
246     switch( nMemberId )
247     {
248         case MID_SIZE_SIZE:
249         {
250             awt::Size aTmp;
251             if( rVal >>= aTmp )
252             {
253                 if(bConvert)
254                 {
255                     aTmp.Height = MM100_TO_TWIP(aTmp.Height);
256                     aTmp.Width = MM100_TO_TWIP(aTmp.Width);
257                 }
258                 aSize = Size( aTmp.Width, aTmp.Height );
259             }
260             else
261             {
262                 return sal_False;
263             }
264         }
265         break;
266         case MID_SIZE_WIDTH:
267         {
268             sal_Int32 nVal = 0;
269             if(!(rVal >>= nVal ))
270                 return sal_False;
271 
272             aSize.Width() = bConvert ? MM100_TO_TWIP(nVal) : nVal;
273         }
274         break;
275         case MID_SIZE_HEIGHT:
276         {
277             sal_Int32 nVal = 0;
278             if(!(rVal >>= nVal))
279                 return sal_True;
280 
281             aSize.Height() = bConvert ? MM100_TO_TWIP(nVal) : nVal;
282         }
283         break;
284         default: DBG_ERROR("Wrong MemberId!");
285             return sal_False;
286     }
287     return sal_True;
288 }
289 
290 // -----------------------------------------------------------------------
291 
SvxSizeItem(const sal_uInt16 nId)292 SvxSizeItem::SvxSizeItem( const sal_uInt16 nId ) :
293 
294     SfxPoolItem( nId )
295 {
296 }
297 
298 // -----------------------------------------------------------------------
299 
operator ==(const SfxPoolItem & rAttr) const300 int SvxSizeItem::operator==( const SfxPoolItem& rAttr ) const
301 {
302     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
303 
304     return ( aSize == ( (SvxSizeItem&)rAttr ).GetSize() );
305 }
306 
307 // -----------------------------------------------------------------------
308 
Clone(SfxItemPool *) const309 SfxPoolItem* SvxSizeItem::Clone( SfxItemPool* ) const
310 {
311     return new SvxSizeItem( *this );
312 }
313 
314 //------------------------------------------------------------------------
315 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,XubString & rText,const IntlWrapper * pIntl) const316 SfxItemPresentation SvxSizeItem::GetPresentation
317 (
318     SfxItemPresentation ePres,
319     SfxMapUnit          eCoreUnit,
320     SfxMapUnit          ePresUnit,
321     XubString&          rText, const IntlWrapper *pIntl
322 )   const
323 {
324 #ifndef SVX_LIGHT
325     switch ( ePres )
326     {
327         case SFX_ITEM_PRESENTATION_NONE:
328             rText.Erase();
329             return SFX_ITEM_PRESENTATION_NONE;
330 
331         case SFX_ITEM_PRESENTATION_NAMELESS:
332             rText = GetMetricText( aSize.Width(), eCoreUnit, ePresUnit, pIntl );
333             rText += cpDelim;
334             rText += GetMetricText( aSize.Height(), eCoreUnit, ePresUnit, pIntl );
335             return SFX_ITEM_PRESENTATION_NAMELESS;
336 
337         case SFX_ITEM_PRESENTATION_COMPLETE:
338             rText = EE_RESSTR(RID_SVXITEMS_SIZE_WIDTH);
339             rText += GetMetricText( aSize.Width(), eCoreUnit, ePresUnit, pIntl );
340             rText += sal_Unicode(' ');
341             rText += EE_RESSTR(GetMetricId(ePresUnit));
342             rText += cpDelim;
343             rText += EE_RESSTR(RID_SVXITEMS_SIZE_HEIGHT);
344             rText += GetMetricText( aSize.Height(), eCoreUnit, ePresUnit, pIntl );
345             rText += sal_Unicode(' ');
346             rText += EE_RESSTR(GetMetricId(ePresUnit));
347             return SFX_ITEM_PRESENTATION_COMPLETE;
348         //no break necessary
349         default: ;//prevent warning
350 
351     }
352 #endif // !SVX_LIGHT
353     return SFX_ITEM_PRESENTATION_NONE;
354 }
355 
356 // -----------------------------------------------------------------------
357 
Store(SvStream & rStrm,sal_uInt16) const358 SvStream& SvxSizeItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
359 {
360     rStrm << aSize.Width();
361     rStrm << aSize.Height();
362     return rStrm;
363 }
364 
365 // -----------------------------------------------------------------------
366 
ScaleMetrics(long nMult,long nDiv)367 int SvxSizeItem::ScaleMetrics( long nMult, long nDiv )
368 {
369     aSize.Width() = Scale( aSize.Width(), nMult, nDiv );
370     aSize.Height() = Scale( aSize.Height(), nMult, nDiv );
371     return 1;
372 }
373 
374 // -----------------------------------------------------------------------
375 
HasMetrics() const376 int SvxSizeItem::HasMetrics() const
377 {
378     return 1;
379 }
380 
381 // -----------------------------------------------------------------------
382 
383 
Create(SvStream & rStrm,sal_uInt16) const384 SfxPoolItem* SvxSizeItem::Create( SvStream& rStrm, sal_uInt16 ) const
385 {
386     long nWidth, nHeight;
387     rStrm >> nWidth >> nHeight;
388 
389     SvxSizeItem* pAttr = new SvxSizeItem( Which() );
390     pAttr->SetSize(Size(nWidth, nHeight));
391 
392     return pAttr;
393 }
394 
395 // class SvxLRSpaceItem --------------------------------------------------
396 
SvxLRSpaceItem(const sal_uInt16 nId)397 SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId ) :
398 
399     SfxPoolItem( nId ),
400 
401     nFirstLineOfst  ( 0 ),
402     nTxtLeft        ( 0 ),
403     nLeftMargin     ( 0 ),
404     nRightMargin    ( 0 ),
405     nPropFirstLineOfst( 100 ),
406     nPropLeftMargin( 100 ),
407     nPropRightMargin( 100 ),
408     bAutoFirst      ( 0 )
409 {
410 }
411 
412 // -----------------------------------------------------------------------
413 
SvxLRSpaceItem(const long nLeft,const long nRight,const long nTLeft,const short nOfset,const sal_uInt16 nId)414 SvxLRSpaceItem::SvxLRSpaceItem( const long nLeft, const long nRight,
415                                 const long nTLeft, const short nOfset,
416                                 const sal_uInt16 nId ) :
417 
418     SfxPoolItem( nId ),
419 
420     nFirstLineOfst  ( nOfset ),
421     nTxtLeft        ( nTLeft ),
422     nLeftMargin     ( nLeft ),
423     nRightMargin    ( nRight ),
424     nPropFirstLineOfst( 100 ),
425     nPropLeftMargin( 100 ),
426     nPropRightMargin( 100 ),
427     bAutoFirst      ( 0 )
428 {
429 }
430 
431 // -----------------------------------------------------------------------
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const432 sal_Bool SvxLRSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
433 {
434     sal_Bool bRet = sal_True;
435     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
436     nMemberId &= ~CONVERT_TWIPS;
437     switch( nMemberId )
438     {
439         //  jetzt alles signed
440         case MID_L_MARGIN:
441             rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nLeftMargin) : nLeftMargin);
442             break;
443 
444         case MID_TXT_LMARGIN :
445             rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nTxtLeft) : nTxtLeft);
446         break;
447         case MID_R_MARGIN:
448             rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nRightMargin) : nRightMargin);
449             break;
450         case MID_L_REL_MARGIN:
451             rVal <<= (sal_Int16)nPropLeftMargin;
452         break;
453         case MID_R_REL_MARGIN:
454             rVal <<= (sal_Int16)nPropRightMargin;
455         break;
456 
457         case MID_FIRST_LINE_INDENT:
458             rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nFirstLineOfst) : nFirstLineOfst);
459             break;
460 
461         case MID_FIRST_LINE_REL_INDENT:
462             rVal <<= (sal_Int16)(nPropFirstLineOfst);
463             break;
464 
465         case MID_FIRST_AUTO:
466             rVal = Bool2Any(IsAutoFirst());
467             break;
468 
469         default:
470             bRet = sal_False;
471             DBG_ERROR("unknown MemberId");
472     }
473     return bRet;
474 }
475 
476 // -----------------------------------------------------------------------
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)477 sal_Bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
478 {
479     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
480     nMemberId &= ~CONVERT_TWIPS;
481     sal_Int32 nVal = 0;
482     if( nMemberId != MID_FIRST_AUTO &&
483             nMemberId != MID_L_REL_MARGIN && nMemberId != MID_R_REL_MARGIN)
484         if(!(rVal >>= nVal))
485             return sal_False;
486 
487     switch( nMemberId )
488     {
489         case MID_L_MARGIN:
490             SetLeft((sal_Int32)bConvert ? MM100_TO_TWIP(nVal) : nVal);
491             break;
492 
493         case MID_TXT_LMARGIN :
494             SetTxtLeft((sal_Int32)bConvert ? MM100_TO_TWIP(nVal) : nVal);
495         break;
496 
497         case MID_R_MARGIN:
498             SetRight((sal_Int32)    bConvert ? MM100_TO_TWIP(nVal) : nVal);
499             break;
500         case MID_L_REL_MARGIN:
501         case MID_R_REL_MARGIN:
502         {
503             sal_Int32 nRel = 0;
504             if((rVal >>= nRel) && nRel >= 0 && nRel < USHRT_MAX)
505             {
506                 if(MID_L_REL_MARGIN== nMemberId)
507                     nPropLeftMargin = (sal_uInt16)nRel;
508                 else
509                     nPropRightMargin = (sal_uInt16)nRel;
510             }
511             else
512                 return sal_False;
513         }
514         break;
515         case MID_FIRST_LINE_INDENT     :
516             SetTxtFirstLineOfst((short)(bConvert ?  MM100_TO_TWIP(nVal) : nVal));
517             break;
518 
519         case MID_FIRST_LINE_REL_INDENT:
520             SetPropTxtFirstLineOfst ( (sal_uInt16)nVal );
521             break;
522 
523         case MID_FIRST_AUTO:
524             SetAutoFirst( Any2Bool(rVal) );
525             break;
526 
527         default:
528             DBG_ERROR("unknown MemberId");
529             return sal_False;
530     }
531     return sal_True;
532 }
533 
534 // -----------------------------------------------------------------------
535 
536 // nLeftMargin und nTxtLeft anpassen.
537 
AdjustLeft()538 void SvxLRSpaceItem::AdjustLeft()
539 {
540     if ( 0 > nFirstLineOfst )
541         nLeftMargin = nTxtLeft + nFirstLineOfst;
542     else
543         nLeftMargin = nTxtLeft;
544 }
545 
546 // -----------------------------------------------------------------------
547 
operator ==(const SfxPoolItem & rAttr) const548 int SvxLRSpaceItem::operator==( const SfxPoolItem& rAttr ) const
549 {
550     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
551 
552     return (
553         nLeftMargin == ((SvxLRSpaceItem&)rAttr).GetLeft()  &&
554         nRightMargin == ((SvxLRSpaceItem&)rAttr).GetRight() &&
555         nFirstLineOfst == ((SvxLRSpaceItem&)rAttr).GetTxtFirstLineOfst() &&
556         nPropLeftMargin == ((SvxLRSpaceItem&)rAttr).GetPropLeft()  &&
557         nPropRightMargin == ((SvxLRSpaceItem&)rAttr).GetPropRight() &&
558         nPropFirstLineOfst == ((SvxLRSpaceItem&)rAttr).GetPropTxtFirstLineOfst() &&
559         bAutoFirst == ((SvxLRSpaceItem&)rAttr).IsAutoFirst() );
560 }
561 
562 // -----------------------------------------------------------------------
563 
Clone(SfxItemPool *) const564 SfxPoolItem* SvxLRSpaceItem::Clone( SfxItemPool* ) const
565 {
566     return new SvxLRSpaceItem( *this );
567 }
568 
569 //------------------------------------------------------------------------
570 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,XubString & rText,const IntlWrapper * pIntl) const571 SfxItemPresentation SvxLRSpaceItem::GetPresentation
572 (
573     SfxItemPresentation ePres,
574     SfxMapUnit          eCoreUnit,
575     SfxMapUnit          ePresUnit,
576     XubString&          rText, const IntlWrapper* pIntl
577 )   const
578 {
579 #ifndef SVX_LIGHT
580     switch ( ePres )
581     {
582         case SFX_ITEM_PRESENTATION_NONE:
583             rText.Erase();
584             return SFX_ITEM_PRESENTATION_NONE;
585         case SFX_ITEM_PRESENTATION_NAMELESS:
586         {
587             if ( 100 != nPropLeftMargin )
588                 ( rText = String::CreateFromInt32( nPropLeftMargin )) += sal_Unicode('%');
589             else
590                 rText = GetMetricText( (long)nLeftMargin,
591                                        eCoreUnit, ePresUnit, pIntl );
592             rText += cpDelim;
593             if ( 100 != nPropFirstLineOfst )
594                 ( rText += String::CreateFromInt32( nPropFirstLineOfst )) += sal_Unicode('%');
595             else
596                 rText += GetMetricText( (long)nFirstLineOfst,
597                                         eCoreUnit, ePresUnit, pIntl );
598             rText += cpDelim;
599             if ( 100 != nRightMargin )
600                 ( rText += String::CreateFromInt32( nRightMargin )) += sal_Unicode('%');
601             else
602                 rText += GetMetricText( (long)nRightMargin,
603                                         eCoreUnit, ePresUnit, pIntl );
604             return SFX_ITEM_PRESENTATION_NAMELESS;
605         }
606         case SFX_ITEM_PRESENTATION_COMPLETE:
607         {
608             rText = EE_RESSTR(RID_SVXITEMS_LRSPACE_LEFT);
609             if ( 100 != nPropLeftMargin )
610                 ( rText += String::CreateFromInt32( nPropLeftMargin )) += sal_Unicode('%');
611             else
612             {
613                 rText += GetMetricText( (long)nLeftMargin,
614                                        eCoreUnit, ePresUnit, pIntl );
615                 rText += sal_Unicode(' ');
616                 rText += EE_RESSTR(GetMetricId(ePresUnit));
617             }
618             rText += cpDelim;
619             if ( 100 != nPropFirstLineOfst || nFirstLineOfst )
620             {
621                 rText += EE_RESSTR(RID_SVXITEMS_LRSPACE_FLINE);
622                 if ( 100 != nPropFirstLineOfst )
623                     ( rText += String::CreateFromInt32( nPropFirstLineOfst ))
624                             += sal_Unicode('%');
625                 else
626                 {
627                     rText += GetMetricText( (long)nFirstLineOfst,
628                                             eCoreUnit, ePresUnit, pIntl );
629                     rText += sal_Unicode(' ');
630                     rText += EE_RESSTR(GetMetricId(ePresUnit));
631                 }
632                 rText += cpDelim;
633             }
634             rText += EE_RESSTR(RID_SVXITEMS_LRSPACE_RIGHT);
635             if ( 100 != nPropRightMargin )
636                 ( rText += String::CreateFromInt32( nPropRightMargin )) += sal_Unicode('%');
637             else
638             {
639                 rText += GetMetricText( (long)nRightMargin,
640                                         eCoreUnit, ePresUnit, pIntl );
641                 rText += sal_Unicode(' ');
642                 rText += EE_RESSTR(GetMetricId(ePresUnit));
643             }
644             return SFX_ITEM_PRESENTATION_COMPLETE;
645         }
646         default: ;//prevent warning
647     }
648 #endif // !SVX_LIGHT
649     return SFX_ITEM_PRESENTATION_NONE;
650 }
651 
652 // -----------------------------------------------------------------------
653 
654 // MT: BulletFI: Vor 501 wurde im Outliner das Bullet nicht auf der Position des
655 // FI positioniert, deshalb muss in aelteren Dokumenten der FI auf 0 stehen.
656 
657 #define BULLETLR_MARKER 0x599401FE
658 
Store(SvStream & rStrm,sal_uInt16 nItemVersion) const659 SvStream& SvxLRSpaceItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
660 {
661     short nSaveFI = nFirstLineOfst;
662     ((SvxLRSpaceItem*)this)->SetTxtFirstLineOfst( 0 );  // nLeftMargin wird mitmanipuliert, siehe Create()
663 
664     sal_uInt16 nMargin = 0;
665     if( nLeftMargin > 0 )
666         nMargin = sal_uInt16( nLeftMargin );
667     rStrm << nMargin;
668     rStrm << nPropLeftMargin;
669     if( nRightMargin > 0 )
670         nMargin = sal_uInt16( nRightMargin );
671     else
672         nMargin = 0;
673     rStrm << nMargin;
674     rStrm << nPropRightMargin;
675     rStrm << nFirstLineOfst;
676     rStrm << nPropFirstLineOfst;
677     if( nTxtLeft > 0 )
678         nMargin = sal_uInt16( nTxtLeft );
679     else
680         nMargin = 0;
681     rStrm << nMargin;
682     if( nItemVersion >= LRSPACE_AUTOFIRST_VERSION )
683     {
684         sal_Int8 nAutoFirst = bAutoFirst ? 1 : 0;
685         if( nItemVersion >= LRSPACE_NEGATIVE_VERSION &&
686             ( nLeftMargin < 0 || nRightMargin < 0 || nTxtLeft < 0 ) )
687             nAutoFirst |= 0x80;
688         rStrm << nAutoFirst;
689 
690         // Ab 6.0 keine Magicnumber schreiben...
691         DBG_ASSERT( rStrm.GetVersion() <= SOFFICE_FILEFORMAT_50, "MT: Fileformat SvxLRSpaceItem aendern!" );
692         rStrm << (sal_uInt32) BULLETLR_MARKER;
693         rStrm << nSaveFI;
694 
695         if( 0x80 & nAutoFirst )
696         {
697             rStrm << nLeftMargin;
698             rStrm << nRightMargin;
699         }
700     }
701 
702     ((SvxLRSpaceItem*)this)->SetTxtFirstLineOfst( nSaveFI );
703 
704     return rStrm;
705 }
706 
707 // -----------------------------------------------------------------------
708 
Create(SvStream & rStrm,sal_uInt16 nVersion) const709 SfxPoolItem* SvxLRSpaceItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
710 {
711     sal_uInt16 left, prpleft, right, prpright, prpfirstline, txtleft;
712     short firstline;
713     sal_Int8 autofirst = 0;
714 
715     if ( nVersion >= LRSPACE_AUTOFIRST_VERSION )
716     {
717         rStrm >> left >> prpleft >> right >> prpright >> firstline >>
718                  prpfirstline >> txtleft >> autofirst;
719 
720         sal_uInt32 nPos = rStrm.Tell();
721         sal_uInt32 nMarker;
722         rStrm >> nMarker;
723         if ( nMarker == BULLETLR_MARKER )
724         {
725             rStrm >> firstline;
726             if ( firstline < 0 )
727                 left = left + static_cast<sal_uInt16>(firstline);   // s.u.: txtleft = ...
728         }
729         else
730             rStrm.Seek( nPos );
731     }
732     else if ( nVersion == LRSPACE_TXTLEFT_VERSION )
733     {
734         rStrm >> left >> prpleft >> right >> prpright >> firstline >>
735                  prpfirstline >> txtleft;
736     }
737     else if ( nVersion == LRSPACE_16_VERSION )
738     {
739         rStrm >> left >> prpleft >> right >> prpright >> firstline >>
740                  prpfirstline;
741     }
742     else
743     {
744         sal_Int8 nL, nR, nFL;
745         rStrm >> left >> nL >> right >> nR >> firstline >> nFL;
746         prpleft = (sal_uInt16)nL;
747         prpright = (sal_uInt16)nR;
748         prpfirstline = (sal_uInt16)nFL;
749     }
750 
751     txtleft = firstline >= 0 ? left : left - firstline;
752     SvxLRSpaceItem* pAttr = new SvxLRSpaceItem( Which() );
753 
754     pAttr->nLeftMargin = left;
755     pAttr->nPropLeftMargin = prpleft;
756     pAttr->nRightMargin = right;
757     pAttr->nPropRightMargin = prpright;
758     pAttr->nFirstLineOfst = firstline;
759     pAttr->nPropFirstLineOfst = prpfirstline;
760     pAttr->nTxtLeft = txtleft;
761     pAttr->bAutoFirst = autofirst & 0x01;
762     if( nVersion >= LRSPACE_NEGATIVE_VERSION && ( autofirst & 0x80 ) )
763     {
764         sal_Int32 nMargin;
765         rStrm >> nMargin;
766         pAttr->nLeftMargin = nMargin;
767         pAttr->nTxtLeft = firstline >= 0 ? nMargin : nMargin - firstline;
768         rStrm >> nMargin;
769         pAttr->nRightMargin = nMargin;
770     }
771     return pAttr;
772 }
773 
774 // -----------------------------------------------------------------------
775 
GetVersion(sal_uInt16 nFileVersion) const776 sal_uInt16 SvxLRSpaceItem::GetVersion( sal_uInt16 nFileVersion ) const
777 {
778     return (nFileVersion == SOFFICE_FILEFORMAT_31)
779                ? LRSPACE_TXTLEFT_VERSION
780                : LRSPACE_NEGATIVE_VERSION;
781 }
782 
783 // -----------------------------------------------------------------------
784 
ScaleMetrics(long nMult,long nDiv)785 int SvxLRSpaceItem::ScaleMetrics( long nMult, long nDiv )
786 {
787     nFirstLineOfst = (short)Scale( nFirstLineOfst, nMult, nDiv );
788     nTxtLeft = Scale( nTxtLeft, nMult, nDiv );
789     nLeftMargin = Scale( nLeftMargin, nMult, nDiv );
790     nRightMargin = Scale( nRightMargin, nMult, nDiv );
791     return 1;
792 }
793 
794 // -----------------------------------------------------------------------
795 
HasMetrics() const796 int SvxLRSpaceItem::HasMetrics() const
797 {
798     return 1;
799 }
800 
801 // class SvxULSpaceItem --------------------------------------------------
802 
SvxULSpaceItem(const sal_uInt16 nId)803 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nId ) :
804 
805     SfxPoolItem( nId ),
806 
807     nUpper( 0 ),
808     nLower( 0 ),
809     nPropUpper( 100 ),
810     nPropLower( 100 )
811 {
812 }
813 
814 // -----------------------------------------------------------------------
815 
SvxULSpaceItem(const sal_uInt16 nUp,const sal_uInt16 nLow,const sal_uInt16 nId)816 SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nUp, const sal_uInt16 nLow,
817                                 const sal_uInt16 nId ) :
818 
819     SfxPoolItem( nId ),
820 
821     nUpper( nUp  ),
822     nLower( nLow ),
823     nPropUpper( 100 ),
824     nPropLower( 100 )
825 {
826 }
827 
828 // -----------------------------------------------------------------------
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const829 sal_Bool    SvxULSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
830 {
831     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
832     nMemberId &= ~CONVERT_TWIPS;
833     switch( nMemberId )
834     {
835         //  jetzt alles signed
836         case 0:
837         {
838             ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale;
839             aUpperLowerMarginScale.Upper = (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nUpper) : nUpper);
840             aUpperLowerMarginScale.Lower = (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nLower) : nPropUpper);
841             aUpperLowerMarginScale.ScaleUpper = (sal_Int16)nPropUpper;
842             aUpperLowerMarginScale.ScaleLower = (sal_Int16)nPropLower;
843             rVal <<= aUpperLowerMarginScale;
844             break;
845         }
846         case MID_UP_MARGIN: rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nUpper) : nUpper); break;
847         case MID_LO_MARGIN: rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nLower) : nLower); break;
848         case MID_UP_REL_MARGIN: rVal <<= (sal_Int16) nPropUpper; break;
849         case MID_LO_REL_MARGIN: rVal <<= (sal_Int16) nPropLower; break;
850     }
851     return sal_True;
852 }
853 
854 // -----------------------------------------------------------------------
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)855 sal_Bool SvxULSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
856 {
857     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
858     nMemberId &= ~CONVERT_TWIPS;
859     sal_Int32 nVal = 0;
860     switch( nMemberId )
861     {
862         case 0:
863         {
864             ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale;
865             if ( !(rVal >>= aUpperLowerMarginScale ))
866                 return sal_False;
867             {
868                 SetUpper((sal_uInt16)(bConvert ? MM100_TO_TWIP( aUpperLowerMarginScale.Upper ) : aUpperLowerMarginScale.Upper));
869                 SetLower((sal_uInt16)(bConvert ? MM100_TO_TWIP( aUpperLowerMarginScale.Lower ) : aUpperLowerMarginScale.Lower));
870                 if( aUpperLowerMarginScale.ScaleUpper > 1 )
871                     nPropUpper = aUpperLowerMarginScale.ScaleUpper;
872                 if( aUpperLowerMarginScale.ScaleLower > 1 )
873                     nPropUpper = aUpperLowerMarginScale.ScaleLower;
874             }
875         }
876 
877         case MID_UP_MARGIN :
878             if(!(rVal >>= nVal) || nVal < 0)
879                 return sal_False;
880             SetUpper((sal_uInt16)(bConvert ? MM100_TO_TWIP(nVal) : nVal));
881             break;
882         case MID_LO_MARGIN :
883             if(!(rVal >>= nVal) || nVal < 0)
884                 return sal_False;
885             SetLower((sal_uInt16)(bConvert ? MM100_TO_TWIP(nVal) : nVal));
886             break;
887         case MID_UP_REL_MARGIN:
888         case MID_LO_REL_MARGIN:
889         {
890             sal_Int32 nRel = 0;
891             if((rVal >>= nRel) && nRel > 1 )
892             {
893                 if(MID_UP_REL_MARGIN == nMemberId)
894                     nPropUpper = (sal_uInt16)nRel;
895                 else
896                     nPropLower = (sal_uInt16)nRel;
897             }
898             else
899                 return sal_False;
900         }
901         break;
902 
903 
904         default:
905             DBG_ERROR("unknown MemberId");
906             return sal_False;
907     }
908     return sal_True;
909 }
910 
911 // -----------------------------------------------------------------------
912 
operator ==(const SfxPoolItem & rAttr) const913 int SvxULSpaceItem::operator==( const SfxPoolItem& rAttr ) const
914 {
915     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
916 
917     return ( nUpper == ( (SvxULSpaceItem&)rAttr ).nUpper &&
918              nLower == ( (SvxULSpaceItem&)rAttr ).nLower &&
919              nPropUpper == ( (SvxULSpaceItem&)rAttr ).nPropUpper &&
920              nPropLower == ( (SvxULSpaceItem&)rAttr ).nPropLower );
921 }
922 
923 // -----------------------------------------------------------------------
924 
Clone(SfxItemPool *) const925 SfxPoolItem* SvxULSpaceItem::Clone( SfxItemPool* ) const
926 {
927     return new SvxULSpaceItem( *this );
928 }
929 
930 //------------------------------------------------------------------------
931 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,XubString & rText,const IntlWrapper * pIntl) const932 SfxItemPresentation SvxULSpaceItem::GetPresentation
933 (
934     SfxItemPresentation ePres,
935     SfxMapUnit          eCoreUnit,
936     SfxMapUnit          ePresUnit,
937     XubString&          rText, const IntlWrapper *pIntl
938 )   const
939 {
940 #ifndef SVX_LIGHT
941     switch ( ePres )
942     {
943         case SFX_ITEM_PRESENTATION_NONE:
944             rText.Erase();
945             return SFX_ITEM_PRESENTATION_NONE;
946         case SFX_ITEM_PRESENTATION_NAMELESS:
947         {
948             if ( 100 != nPropUpper )
949                 ( rText = String::CreateFromInt32( nPropUpper )) += sal_Unicode('%');
950             else
951                 rText = GetMetricText( (long)nUpper, eCoreUnit, ePresUnit, pIntl );
952             rText += cpDelim;
953             if ( 100 != nPropLower )
954                 ( rText += String::CreateFromInt32( nPropLower )) += sal_Unicode('%');
955             else
956                 rText += GetMetricText( (long)nLower, eCoreUnit, ePresUnit, pIntl );
957             return SFX_ITEM_PRESENTATION_NAMELESS;
958         }
959         case SFX_ITEM_PRESENTATION_COMPLETE:
960         {
961             rText = EE_RESSTR(RID_SVXITEMS_ULSPACE_UPPER);
962             if ( 100 != nPropUpper )
963                 ( rText += String::CreateFromInt32( nPropUpper )) += sal_Unicode('%');
964             else
965             {
966                 rText += GetMetricText( (long)nUpper, eCoreUnit, ePresUnit, pIntl );
967                 rText += sal_Unicode(' ');
968                 rText += EE_RESSTR(GetMetricId(ePresUnit));
969             }
970             rText += cpDelim;
971             rText += EE_RESSTR(RID_SVXITEMS_ULSPACE_LOWER);
972             if ( 100 != nPropLower )
973                 ( rText += String::CreateFromInt32( nPropLower )) += sal_Unicode('%');
974             else
975             {
976                 rText += GetMetricText( (long)nLower, eCoreUnit, ePresUnit, pIntl );
977                 rText += sal_Unicode(' ');
978                 rText += EE_RESSTR(GetMetricId(ePresUnit));
979             }
980             return SFX_ITEM_PRESENTATION_COMPLETE;
981         }
982         default: ;//prevent warning
983     }
984 #endif
985     return SFX_ITEM_PRESENTATION_NONE;
986 }
987 
988 // -----------------------------------------------------------------------
989 
Store(SvStream & rStrm,sal_uInt16) const990 SvStream& SvxULSpaceItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
991 {
992     rStrm << GetUpper()
993           << GetPropUpper()
994           << GetLower()
995           << GetPropLower();
996     return rStrm;
997 }
998 
999 // -----------------------------------------------------------------------
1000 
Create(SvStream & rStrm,sal_uInt16 nVersion) const1001 SfxPoolItem* SvxULSpaceItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
1002 {
1003     sal_uInt16 upper, lower, nPL = 0, nPU = 0;
1004 
1005     if ( nVersion == ULSPACE_16_VERSION )
1006         rStrm >> upper >> nPU >> lower >> nPL;
1007     else
1008     {
1009         sal_Int8 nU, nL;
1010         rStrm >> upper >> nU >> lower >> nL;
1011         nPL = (sal_uInt16)nL;
1012         nPU = (sal_uInt16)nU;
1013     }
1014 
1015     SvxULSpaceItem* pAttr = new SvxULSpaceItem( Which() );
1016     pAttr->SetUpperValue( upper );
1017     pAttr->SetLowerValue( lower );
1018     pAttr->SetPropUpper( nPU );
1019     pAttr->SetPropLower( nPL );
1020     return pAttr;
1021 }
1022 
1023 // -----------------------------------------------------------------------
1024 
GetVersion(sal_uInt16) const1025 sal_uInt16 SvxULSpaceItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const
1026 {
1027     return ULSPACE_16_VERSION;
1028 }
1029 
1030 // -----------------------------------------------------------------------
1031 
ScaleMetrics(long nMult,long nDiv)1032 int SvxULSpaceItem::ScaleMetrics( long nMult, long nDiv )
1033 {
1034     nUpper = (sal_uInt16)Scale( nUpper, nMult, nDiv );
1035     nLower = (sal_uInt16)Scale( nLower, nMult, nDiv );
1036     return 1;
1037 }
1038 
1039 // -----------------------------------------------------------------------
1040 
HasMetrics() const1041 int SvxULSpaceItem::HasMetrics() const
1042 {
1043     return 1;
1044 }
1045 
1046 
1047 // class SvxPrintItem ----------------------------------------------------
1048 
Clone(SfxItemPool *) const1049 SfxPoolItem* SvxPrintItem::Clone( SfxItemPool* ) const
1050 {
1051     return new SvxPrintItem( *this );
1052 }
1053 
1054 // -----------------------------------------------------------------------
1055 
Store(SvStream & rStrm,sal_uInt16) const1056 SvStream& SvxPrintItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1057 {
1058     rStrm << (sal_Int8)GetValue();
1059     return rStrm;
1060 }
1061 
1062 // -----------------------------------------------------------------------
1063 
Create(SvStream & rStrm,sal_uInt16) const1064 SfxPoolItem* SvxPrintItem::Create( SvStream& rStrm, sal_uInt16 ) const
1065 {
1066     sal_Int8 bIsPrint;
1067     rStrm >> bIsPrint;
1068     return new SvxPrintItem( Which(), sal_Bool( bIsPrint != 0 ) );
1069 }
1070 
1071 //------------------------------------------------------------------------
1072 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const1073 SfxItemPresentation SvxPrintItem::GetPresentation
1074 (
1075     SfxItemPresentation ePres,
1076     SfxMapUnit          /*eCoreUnit*/,
1077     SfxMapUnit          /*ePresUnit*/,
1078     XubString&          rText, const IntlWrapper *
1079 )   const
1080 {
1081 #ifndef SVX_LIGHT
1082     switch ( ePres )
1083     {
1084         case SFX_ITEM_PRESENTATION_NONE:
1085             rText.Erase();
1086             return ePres;
1087 
1088         case SFX_ITEM_PRESENTATION_NAMELESS:
1089         case SFX_ITEM_PRESENTATION_COMPLETE:
1090         {
1091             sal_uInt16 nId = RID_SVXITEMS_PRINT_FALSE;
1092 
1093             if ( GetValue() )
1094                 nId = RID_SVXITEMS_PRINT_TRUE;
1095             rText = EE_RESSTR(nId);
1096             return ePres;
1097         }
1098         default: ;//prevent warning
1099     }
1100 #endif // !SVX_LIGHT
1101     return SFX_ITEM_PRESENTATION_NONE;
1102 }
1103 
1104 // class SvxOpaqueItem ---------------------------------------------------
1105 
Clone(SfxItemPool *) const1106 SfxPoolItem* SvxOpaqueItem::Clone( SfxItemPool* ) const
1107 {
1108     return new SvxOpaqueItem( *this );
1109 }
1110 
1111 // -----------------------------------------------------------------------
1112 
Store(SvStream & rStrm,sal_uInt16) const1113 SvStream& SvxOpaqueItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1114 {
1115     rStrm << (sal_Int8)GetValue();
1116     return rStrm;
1117 }
1118 
1119 // -----------------------------------------------------------------------
1120 
Create(SvStream & rStrm,sal_uInt16) const1121 SfxPoolItem* SvxOpaqueItem::Create( SvStream& rStrm, sal_uInt16 ) const
1122 {
1123     sal_Int8 bIsOpaque;
1124     rStrm >> bIsOpaque;
1125     return new SvxOpaqueItem( Which(), sal_Bool( bIsOpaque != 0 ) );
1126 }
1127 
1128 //------------------------------------------------------------------------
1129 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const1130 SfxItemPresentation SvxOpaqueItem::GetPresentation
1131 (
1132     SfxItemPresentation ePres,
1133     SfxMapUnit          /*eCoreUnit*/,
1134     SfxMapUnit          /*ePresUnit*/,
1135     XubString&          rText, const IntlWrapper *
1136 )   const
1137 {
1138 #ifndef SVX_LIGHT
1139     switch ( ePres )
1140     {
1141         case SFX_ITEM_PRESENTATION_NONE:
1142             rText.Erase();
1143             return ePres;
1144 
1145         case SFX_ITEM_PRESENTATION_NAMELESS:
1146         case SFX_ITEM_PRESENTATION_COMPLETE:
1147         {
1148             sal_uInt16 nId = RID_SVXITEMS_OPAQUE_FALSE;
1149 
1150             if ( GetValue() )
1151                 nId = RID_SVXITEMS_OPAQUE_TRUE;
1152             rText = EE_RESSTR(nId);
1153             return ePres;
1154         }
1155         default: ;//prevent warning
1156     }
1157 #endif // !SVX_LIGHT
1158     return SFX_ITEM_PRESENTATION_NONE;
1159 }
1160 
1161 // class SvxProtectItem --------------------------------------------------
1162 
operator ==(const SfxPoolItem & rAttr) const1163 int SvxProtectItem::operator==( const SfxPoolItem& rAttr ) const
1164 {
1165     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
1166 
1167     return ( bCntnt == ( (SvxProtectItem&)rAttr ).bCntnt &&
1168              bSize  == ( (SvxProtectItem&)rAttr ).bSize  &&
1169              bPos   == ( (SvxProtectItem&)rAttr ).bPos );
1170 }
1171 
1172 /*-----------------16.03.98 12:42-------------------
1173 --------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1174 sal_Bool SvxProtectItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1175 {
1176 //  sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1177     nMemberId &= ~CONVERT_TWIPS;
1178     sal_Bool bValue;
1179     switch(nMemberId)
1180     {
1181         case MID_PROTECT_CONTENT :  bValue = bCntnt; break;
1182         case MID_PROTECT_SIZE    :  bValue = bSize; break;
1183         case MID_PROTECT_POSITION:  bValue = bPos; break;
1184         default:
1185             DBG_ERROR("falsche MemberId");
1186             return sal_False;
1187     }
1188 
1189     rVal = Bool2Any( bValue );
1190     return sal_True;
1191 }
1192 /*-----------------16.03.98 12:42-------------------
1193 
1194 --------------------------------------------------*/
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)1195 sal_Bool    SvxProtectItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1196 {
1197 //  sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1198     nMemberId &= ~CONVERT_TWIPS;
1199     sal_Bool bVal( Any2Bool(rVal) );
1200     switch(nMemberId)
1201     {
1202         case MID_PROTECT_CONTENT :  bCntnt = bVal;  break;
1203         case MID_PROTECT_SIZE    :  bSize  = bVal;  break;
1204         case MID_PROTECT_POSITION:  bPos   = bVal;  break;
1205         default:
1206             DBG_ERROR("falsche MemberId");
1207             return sal_False;
1208     }
1209     return sal_True;
1210 }
1211 
1212 // -----------------------------------------------------------------------
1213 
Clone(SfxItemPool *) const1214 SfxPoolItem* SvxProtectItem::Clone( SfxItemPool* ) const
1215 {
1216     return new SvxProtectItem( *this );
1217 }
1218 
1219 //------------------------------------------------------------------------
1220 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const1221 SfxItemPresentation SvxProtectItem::GetPresentation
1222 (
1223     SfxItemPresentation ePres,
1224     SfxMapUnit          /*eCoreUnit*/,
1225     SfxMapUnit          /*ePresUnit*/,
1226     XubString&          rText, const IntlWrapper *
1227 )   const
1228 {
1229 #ifndef SVX_LIGHT
1230     switch ( ePres )
1231     {
1232         case SFX_ITEM_PRESENTATION_NONE:
1233             rText.Erase();
1234             return ePres;
1235 
1236         case SFX_ITEM_PRESENTATION_NAMELESS:
1237         case SFX_ITEM_PRESENTATION_COMPLETE:
1238         {
1239             sal_uInt16 nId = RID_SVXITEMS_PROT_CONTENT_FALSE;
1240 
1241             if ( bCntnt )
1242                 nId = RID_SVXITEMS_PROT_CONTENT_TRUE;
1243             rText = EE_RESSTR(nId);
1244             rText += cpDelim;
1245             nId = RID_SVXITEMS_PROT_SIZE_FALSE;
1246 
1247             if ( bSize )
1248                 nId = RID_SVXITEMS_PROT_SIZE_TRUE;
1249             rText += EE_RESSTR(nId);
1250             rText += cpDelim;
1251             nId = RID_SVXITEMS_PROT_POS_FALSE;
1252 
1253             if ( bPos )
1254                 nId = RID_SVXITEMS_PROT_POS_TRUE;
1255             rText += EE_RESSTR(nId);
1256             return ePres;
1257         }
1258         default: ;//prevent warning
1259     }
1260 #endif // !SVX_LIGHT
1261     return SFX_ITEM_PRESENTATION_NONE;
1262 }
1263 
1264 // -----------------------------------------------------------------------
1265 
Store(SvStream & rStrm,sal_uInt16) const1266 SvStream& SvxProtectItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1267 {
1268     sal_Int8 cProt = 0;
1269     if( IsPosProtected() )   cProt |= 0x01;
1270     if( IsSizeProtected() )  cProt |= 0x02;
1271     if( IsCntntProtected() ) cProt |= 0x04;
1272     rStrm << (sal_Int8) cProt;
1273     return rStrm;
1274 }
1275 
1276 // -----------------------------------------------------------------------
1277 
Create(SvStream & rStrm,sal_uInt16) const1278 SfxPoolItem* SvxProtectItem::Create( SvStream& rStrm, sal_uInt16 ) const
1279 {
1280     sal_Int8 cFlags;
1281     rStrm >> cFlags;
1282     SvxProtectItem* pAttr = new SvxProtectItem( Which() );
1283     pAttr->SetPosProtect( sal_Bool( ( cFlags & 0x01 ) != 0 ) );
1284     pAttr->SetSizeProtect( sal_Bool(  ( cFlags & 0x02 ) != 0 ) );
1285     pAttr->SetCntntProtect( sal_Bool(  ( cFlags & 0x04 ) != 0 ) );
1286     return pAttr;
1287 }
1288 
1289 // class SvxShadowItem ---------------------------------------------------
1290 
SvxShadowItem(const sal_uInt16 nId,const Color * pColor,const sal_uInt16 nW,const SvxShadowLocation eLoc)1291 SvxShadowItem::SvxShadowItem( const sal_uInt16 nId,
1292                  const Color *pColor, const sal_uInt16 nW,
1293                  const SvxShadowLocation eLoc ) :
1294     SfxEnumItemInterface( nId ),
1295     aShadowColor(COL_GRAY),
1296     nWidth      ( nW ),
1297     eLocation   ( eLoc )
1298 {
1299     if ( pColor )
1300         aShadowColor = *pColor;
1301 }
1302 
1303 // -----------------------------------------------------------------------
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1304 sal_Bool SvxShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1305 {
1306     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1307     nMemberId &= ~CONVERT_TWIPS;
1308 
1309     table::ShadowFormat aShadow;
1310     table::ShadowLocation eSet = table::ShadowLocation_NONE;
1311     switch( eLocation )
1312     {
1313         case SVX_SHADOW_TOPLEFT    : eSet = table::ShadowLocation_TOP_LEFT    ; break;
1314         case SVX_SHADOW_TOPRIGHT   : eSet = table::ShadowLocation_TOP_RIGHT   ; break;
1315         case SVX_SHADOW_BOTTOMLEFT : eSet = table::ShadowLocation_BOTTOM_LEFT ; break;
1316         case SVX_SHADOW_BOTTOMRIGHT: eSet = table::ShadowLocation_BOTTOM_RIGHT; break;
1317         default: ;//prevent warning
1318     }
1319     aShadow.Location = eSet;
1320     aShadow.ShadowWidth =   bConvert ? TWIP_TO_MM100_UNSIGNED(nWidth) : nWidth;
1321     aShadow.IsTransparent = aShadowColor.GetTransparency() > 0;
1322     aShadow.Color = aShadowColor.GetRGBColor();
1323 
1324     switch ( nMemberId )
1325     {
1326         case MID_LOCATION: rVal <<= aShadow.Location; break;
1327         case MID_WIDTH: rVal <<= aShadow.ShadowWidth; break;
1328         case MID_TRANSPARENT: rVal <<= aShadow.IsTransparent; break;
1329         case MID_BG_COLOR: rVal <<= aShadow.Color; break;
1330         case 0: rVal <<= aShadow; break;
1331         default: DBG_ERROR("Wrong MemberId!"); return sal_False;
1332     }
1333 
1334     return sal_True;
1335 }
1336 // -----------------------------------------------------------------------
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)1337 sal_Bool SvxShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1338 {
1339     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1340     nMemberId &= ~CONVERT_TWIPS;
1341 
1342     table::ShadowFormat aShadow;
1343     uno::Any aAny;
1344     sal_Bool bRet = QueryValue( aAny, bConvert ? CONVERT_TWIPS : 0 ) && ( aAny >>= aShadow );
1345     switch ( nMemberId )
1346     {
1347         case MID_LOCATION:
1348         {
1349             bRet = (rVal >>= aShadow.Location);
1350             if ( !bRet )
1351             {
1352                 sal_Int16 nVal = 0;
1353                 bRet = (rVal >>= nVal);
1354                 aShadow.Location = (table::ShadowLocation) nVal;
1355             }
1356 
1357             break;
1358         }
1359 
1360         case MID_WIDTH: rVal >>= aShadow.ShadowWidth; break;
1361         case MID_TRANSPARENT: rVal >>= aShadow.IsTransparent; break;
1362         case MID_BG_COLOR: rVal >>= aShadow.Color; break;
1363         case 0: rVal >>= aShadow; break;
1364         default: DBG_ERROR("Wrong MemberId!"); return sal_False;
1365     }
1366 
1367     if ( bRet )
1368     {
1369 //      SvxShadowLocation eSet = SVX_SHADOW_NONE;
1370         switch( aShadow.Location )
1371         {
1372             case table::ShadowLocation_TOP_LEFT    : eLocation = SVX_SHADOW_TOPLEFT; break;
1373             case table::ShadowLocation_TOP_RIGHT   : eLocation = SVX_SHADOW_TOPRIGHT; break;
1374             case table::ShadowLocation_BOTTOM_LEFT : eLocation = SVX_SHADOW_BOTTOMLEFT ; break;
1375             case table::ShadowLocation_BOTTOM_RIGHT: eLocation = SVX_SHADOW_BOTTOMRIGHT; break;
1376             default: ;//prevent warning
1377         }
1378 
1379         nWidth = bConvert ? MM100_TO_TWIP(aShadow.ShadowWidth) : aShadow.ShadowWidth;
1380         Color aSet(aShadow.Color);
1381         aSet.SetTransparency(aShadow.IsTransparent ? 0xff : 0);
1382         aShadowColor = aSet;
1383     }
1384 
1385     return bRet;
1386 }
1387 
1388 // -----------------------------------------------------------------------
1389 
operator ==(const SfxPoolItem & rAttr) const1390 int SvxShadowItem::operator==( const SfxPoolItem& rAttr ) const
1391 {
1392     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
1393 
1394     return ( ( aShadowColor == ( (SvxShadowItem&)rAttr ).aShadowColor ) &&
1395              ( nWidth    == ( (SvxShadowItem&)rAttr ).GetWidth() ) &&
1396              ( eLocation == ( (SvxShadowItem&)rAttr ).GetLocation() ) );
1397 }
1398 
1399 // -----------------------------------------------------------------------
1400 
Clone(SfxItemPool *) const1401 SfxPoolItem* SvxShadowItem::Clone( SfxItemPool* ) const
1402 {
1403     return new SvxShadowItem( *this );
1404 }
1405 
1406 // -----------------------------------------------------------------------
1407 
CalcShadowSpace(sal_uInt16 nShadow) const1408 sal_uInt16 SvxShadowItem::CalcShadowSpace( sal_uInt16 nShadow ) const
1409 {
1410     sal_uInt16 nSpace = 0;
1411 
1412     switch ( nShadow )
1413     {
1414         case SHADOW_TOP:
1415             if ( eLocation == SVX_SHADOW_TOPLEFT ||
1416                  eLocation == SVX_SHADOW_TOPRIGHT  )
1417                 nSpace = nWidth;
1418             break;
1419 
1420         case SHADOW_BOTTOM:
1421             if ( eLocation == SVX_SHADOW_BOTTOMLEFT ||
1422                  eLocation == SVX_SHADOW_BOTTOMRIGHT  )
1423                 nSpace = nWidth;
1424             break;
1425 
1426         case SHADOW_LEFT:
1427             if ( eLocation == SVX_SHADOW_TOPLEFT ||
1428                  eLocation == SVX_SHADOW_BOTTOMLEFT )
1429                 nSpace = nWidth;
1430             break;
1431 
1432         case SHADOW_RIGHT:
1433             if ( eLocation == SVX_SHADOW_TOPRIGHT ||
1434                  eLocation == SVX_SHADOW_BOTTOMRIGHT )
1435                 nSpace = nWidth;
1436             break;
1437 
1438         default:
1439             DBG_ERROR( "wrong shadow" );
1440     }
1441     return nSpace;
1442 }
1443 
1444 //------------------------------------------------------------------------
1445 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,XubString & rText,const IntlWrapper * pIntl) const1446 SfxItemPresentation SvxShadowItem::GetPresentation
1447 (
1448     SfxItemPresentation ePres,
1449     SfxMapUnit          eCoreUnit,
1450     SfxMapUnit          ePresUnit,
1451     XubString&          rText, const IntlWrapper *pIntl
1452 )   const
1453 {
1454 #ifndef SVX_LIGHT
1455     switch ( ePres )
1456     {
1457         case SFX_ITEM_PRESENTATION_NONE:
1458             rText.Erase();
1459             return ePres;
1460 
1461         case SFX_ITEM_PRESENTATION_NAMELESS:
1462         {
1463             rText = ::GetColorString( aShadowColor );
1464             rText += cpDelim;
1465             sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
1466 
1467             if ( aShadowColor.GetTransparency() )
1468                 nId = RID_SVXITEMS_TRANSPARENT_TRUE;
1469             rText += EE_RESSTR(nId);
1470             rText += cpDelim;
1471             rText += GetMetricText( (long)nWidth, eCoreUnit, ePresUnit, pIntl );
1472             rText += cpDelim;
1473             rText += EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN + eLocation);
1474             return ePres;
1475         }
1476         case SFX_ITEM_PRESENTATION_COMPLETE:
1477         {
1478             rText = EE_RESSTR(RID_SVXITEMS_SHADOW_COMPLETE);
1479             rText += ::GetColorString( aShadowColor );
1480             rText += cpDelim;
1481 
1482             sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
1483             if ( aShadowColor.GetTransparency() )
1484                 nId = RID_SVXITEMS_TRANSPARENT_TRUE;
1485             rText += EE_RESSTR(nId);
1486             rText += cpDelim;
1487             rText += GetMetricText( (long)nWidth, eCoreUnit, ePresUnit, pIntl );
1488             rText += sal_Unicode(' ');
1489             rText += EE_RESSTR(GetMetricId(ePresUnit));
1490             rText += cpDelim;
1491             rText += EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN + eLocation);
1492             return ePres;
1493         }
1494         default: ;//prevent warning
1495     }
1496 #endif
1497     return SFX_ITEM_PRESENTATION_NONE;
1498 }
1499 
1500 // -----------------------------------------------------------------------
1501 
Store(SvStream & rStrm,sal_uInt16) const1502 SvStream& SvxShadowItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1503 {
1504     rStrm << (sal_Int8) GetLocation()
1505           << (sal_uInt16) GetWidth()
1506           << (sal_Bool)(aShadowColor.GetTransparency() > 0)
1507           << GetColor()
1508           << GetColor()
1509           << (sal_Int8)(aShadowColor.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
1510     return rStrm;
1511 }
1512 
1513 // -----------------------------------------------------------------------
1514 
ScaleMetrics(long nMult,long nDiv)1515 int SvxShadowItem::ScaleMetrics( long nMult, long nDiv )
1516 {
1517     nWidth = (sal_uInt16)Scale( nWidth, nMult, nDiv );
1518     return 1;
1519 }
1520 
1521 // -----------------------------------------------------------------------
1522 
HasMetrics() const1523 int SvxShadowItem::HasMetrics() const
1524 {
1525     return 1;
1526 }
1527 
1528 // -----------------------------------------------------------------------
1529 
Create(SvStream & rStrm,sal_uInt16) const1530 SfxPoolItem* SvxShadowItem::Create( SvStream& rStrm, sal_uInt16 ) const
1531 {
1532     sal_Int8 cLoc;
1533     sal_uInt16 _nWidth;
1534     sal_Bool bTrans;
1535     Color aColor;
1536     Color aFillColor;
1537     sal_Int8 nStyle;
1538     rStrm >> cLoc >> _nWidth
1539           >> bTrans >> aColor >> aFillColor >> nStyle;
1540     aColor.SetTransparency(bTrans ? 0xff : 0);
1541     return new SvxShadowItem( Which(), &aColor, _nWidth, (SvxShadowLocation)cLoc );
1542 }
1543 
1544 // -----------------------------------------------------------------------
1545 
GetValueCount() const1546 sal_uInt16 SvxShadowItem::GetValueCount() const
1547 {
1548     return SVX_SHADOW_END;  // SVX_SHADOW_BOTTOMRIGHT + 1
1549 }
1550 
1551 // -----------------------------------------------------------------------
1552 
GetValueTextByPos(sal_uInt16 nPos) const1553 XubString SvxShadowItem::GetValueTextByPos( sal_uInt16 nPos ) const
1554 {
1555     DBG_ASSERT( nPos < SVX_SHADOW_END, "enum overflow!" );
1556     return XubString( EditResId( RID_SVXITEMS_SHADOW_BEGIN + nPos ) );
1557 }
1558 
1559 // -----------------------------------------------------------------------
1560 
GetEnumValue() const1561 sal_uInt16 SvxShadowItem::GetEnumValue() const
1562 {
1563     return (sal_uInt16)GetLocation();
1564 }
1565 
1566 // -----------------------------------------------------------------------
1567 
SetEnumValue(sal_uInt16 nVal)1568 void SvxShadowItem::SetEnumValue( sal_uInt16 nVal )
1569 {
1570     SetLocation( (const SvxShadowLocation)nVal );
1571 }
1572 
1573 // class SvxBorderLine  --------------------------------------------------
1574 
SvxBorderLine(const Color * pCol,sal_uInt16 nOut,sal_uInt16 nIn,sal_uInt16 nDist)1575 SvxBorderLine::SvxBorderLine( const Color *pCol, sal_uInt16 nOut, sal_uInt16 nIn, sal_uInt16 nDist )
1576 : nOutWidth( nOut )
1577 , nInWidth ( nIn )
1578 , nDistance( nDist )
1579 {
1580     if ( pCol )
1581         aColor = *pCol;
1582 }
1583 
1584 // -----------------------------------------------------------------------
1585 
SvxBorderLine(const SvxBorderLine & r)1586 SvxBorderLine::SvxBorderLine( const SvxBorderLine& r )
1587 {
1588     *this = r;
1589 }
1590 
1591 // -----------------------------------------------------------------------
1592 
operator =(const SvxBorderLine & r)1593 SvxBorderLine& SvxBorderLine::operator=( const SvxBorderLine& r )
1594 {
1595     aColor = r.aColor;
1596     nOutWidth = r.nOutWidth;
1597     nInWidth = r.nInWidth;
1598     nDistance = r.nDistance;
1599     return *this;
1600 }
1601 
1602 // -----------------------------------------------------------------------
1603 
ScaleMetrics(long nMult,long nDiv)1604 void SvxBorderLine::ScaleMetrics( long nMult, long nDiv )
1605 {
1606     nOutWidth = (sal_uInt16)Scale( nOutWidth, nMult, nDiv );
1607     nInWidth = (sal_uInt16)Scale( nInWidth, nMult, nDiv );
1608     nDistance = (sal_uInt16)Scale( nDistance, nMult, nDiv );
1609 }
1610 
1611 // -----------------------------------------------------------------------
1612 
operator ==(const SvxBorderLine & rCmp) const1613 sal_Bool SvxBorderLine::operator==( const SvxBorderLine& rCmp ) const
1614 {
1615     return ( ( aColor    == rCmp.GetColor() )    &&
1616              ( nInWidth  == rCmp.GetInWidth() )  &&
1617              ( nOutWidth == rCmp.GetOutWidth() ) &&
1618              ( nDistance == rCmp.GetDistance() ) );
1619 }
1620 
1621 // -----------------------------------------------------------------------
1622 
GetValueString(SfxMapUnit eSrcUnit,SfxMapUnit eDestUnit,const IntlWrapper * pIntl,sal_Bool bMetricStr) const1623 XubString SvxBorderLine::GetValueString( SfxMapUnit eSrcUnit,
1624                                       SfxMapUnit eDestUnit,
1625                                       const IntlWrapper* pIntl,
1626                                       sal_Bool bMetricStr) const
1627 {
1628 #ifndef SVX_LIGHT
1629     sal_uInt16 nResId = 0;
1630 
1631     if ( 0 == nDistance )
1632     {
1633         // einfach Linie
1634         if ( DEF_LINE_WIDTH_0 == nOutWidth )
1635             nResId = RID_SINGLE_LINE0;
1636         else if ( DEF_LINE_WIDTH_1 == nOutWidth )
1637             nResId = RID_SINGLE_LINE1;
1638         else if ( DEF_LINE_WIDTH_2 == nOutWidth )
1639             nResId = RID_SINGLE_LINE2;
1640         else if ( DEF_LINE_WIDTH_3 == nOutWidth )
1641             nResId = RID_SINGLE_LINE3;
1642         else if ( DEF_LINE_WIDTH_4 == nOutWidth )
1643             nResId = RID_SINGLE_LINE4;
1644     }
1645     else if ( DEF_LINE_WIDTH_1 == nDistance )
1646     {
1647         // doppelte Linie, kleiner Abstand
1648         if ( DEF_LINE_WIDTH_0 == nOutWidth && DEF_LINE_WIDTH_0 == nInWidth )
1649             nResId = RID_DOUBLE_LINE0;
1650         else if ( DEF_LINE_WIDTH_1 == nOutWidth &&
1651                   DEF_LINE_WIDTH_1 == nInWidth )
1652             nResId = RID_DOUBLE_LINE2;
1653         else if ( DEF_LINE_WIDTH_1 == nOutWidth &&
1654                   DEF_LINE_WIDTH_2 == nInWidth )
1655             nResId = RID_DOUBLE_LINE8;
1656     }
1657     else if ( DEF_LINE_WIDTH_2 == nDistance )
1658     {
1659         // doppelte Linie, gro\ser Abstand
1660         if ( DEF_LINE_WIDTH_0 == nOutWidth && DEF_LINE_WIDTH_0 == nInWidth )
1661             nResId = RID_DOUBLE_LINE1;
1662         else if ( DEF_LINE_WIDTH_2 == nOutWidth &&
1663                   DEF_LINE_WIDTH_2 == nInWidth )
1664             nResId = RID_DOUBLE_LINE3;
1665         else if ( DEF_LINE_WIDTH_1 == nOutWidth &&
1666                   DEF_LINE_WIDTH_0 == nInWidth )
1667             nResId = RID_DOUBLE_LINE4;
1668         else if ( DEF_LINE_WIDTH_2 == nOutWidth &&
1669                   DEF_LINE_WIDTH_0 == nInWidth )
1670             nResId = RID_DOUBLE_LINE5;
1671         else if ( DEF_LINE_WIDTH_3 == nOutWidth &&
1672                   DEF_LINE_WIDTH_0 == nInWidth )
1673             nResId = RID_DOUBLE_LINE6;
1674         else if ( DEF_LINE_WIDTH_2 == nOutWidth &&
1675                   DEF_LINE_WIDTH_1 == nInWidth )
1676             nResId = RID_DOUBLE_LINE7;
1677         else if ( DEF_LINE_WIDTH_3 == nOutWidth &&
1678                   DEF_LINE_WIDTH_2 == nInWidth )
1679             nResId = RID_DOUBLE_LINE9;
1680         else if ( DEF_LINE_WIDTH_2 == nOutWidth &&
1681                   DEF_LINE_WIDTH_3 == nInWidth )
1682             nResId = RID_DOUBLE_LINE10;
1683     }
1684     String aStr;
1685     aStr += sal_Unicode('(');
1686     aStr += ::GetColorString( aColor );
1687     aStr += cpDelim;
1688 
1689     if ( nResId )
1690         aStr += EE_RESSTR(nResId);
1691     else
1692     {
1693         String sMetric = EE_RESSTR(GetMetricId( eDestUnit ));
1694         sMetric.Insert( sal_Unicode(' '), 0 );
1695         aStr += GetMetricText( (long)nInWidth, eSrcUnit, eDestUnit, pIntl );
1696         if ( bMetricStr )
1697             aStr += sMetric;
1698         aStr += cpDelim;
1699         aStr += GetMetricText( (long)nOutWidth, eSrcUnit, eDestUnit, pIntl );
1700         if ( bMetricStr )
1701             aStr += sMetric;
1702         aStr += cpDelim;
1703         aStr += GetMetricText( (long)nDistance, eSrcUnit, eDestUnit, pIntl );
1704         if ( bMetricStr )
1705             aStr += sMetric;
1706     }
1707     aStr += sal_Unicode(')');
1708     return aStr;
1709 #else
1710     return UniString();
1711 #endif
1712 }
1713 
HasPriority(const SvxBorderLine & rOtherLine) const1714 bool SvxBorderLine::HasPriority( const SvxBorderLine& rOtherLine ) const
1715 {
1716     const sal_uInt16 nThisSize = GetOutWidth() + GetDistance() + GetInWidth();
1717     const sal_uInt16 nOtherSize = rOtherLine.GetOutWidth() + rOtherLine.GetDistance() + rOtherLine.GetInWidth();
1718 
1719     if (nThisSize > nOtherSize)
1720     {
1721         return true;
1722     }
1723     else if (nThisSize < nOtherSize)
1724     {
1725         return false;
1726     }
1727     else
1728     {
1729         if ( rOtherLine.GetInWidth() && !GetInWidth() )
1730         {
1731             return true;
1732         }
1733         else if ( GetInWidth() && !rOtherLine.GetInWidth() )
1734         {
1735             return false;
1736         }
1737         else
1738         {
1739             return false;
1740         }
1741     }
1742 }
1743 
1744 // class SvxBoxItem ------------------------------------------------------
1745 
SvxBoxItem(const SvxBoxItem & rCpy)1746 SvxBoxItem::SvxBoxItem( const SvxBoxItem& rCpy ) :
1747 
1748     SfxPoolItem ( rCpy ),
1749     nTopDist    ( rCpy.nTopDist ),
1750     nBottomDist ( rCpy.nBottomDist ),
1751     nLeftDist   ( rCpy.nLeftDist ),
1752     nRightDist  ( rCpy.nRightDist )
1753 
1754 {
1755     pTop    = rCpy.GetTop()     ? new SvxBorderLine( *rCpy.GetTop() )    : 0;
1756     pBottom = rCpy.GetBottom()  ? new SvxBorderLine( *rCpy.GetBottom() ) : 0;
1757     pLeft   = rCpy.GetLeft()    ? new SvxBorderLine( *rCpy.GetLeft() )   : 0;
1758     pRight  = rCpy.GetRight()   ? new SvxBorderLine( *rCpy.GetRight() )  : 0;
1759 }
1760 
1761 // -----------------------------------------------------------------------
1762 
SvxBoxItem(const sal_uInt16 nId)1763 SvxBoxItem::SvxBoxItem( const sal_uInt16 nId ) :
1764     SfxPoolItem( nId ),
1765 
1766     pTop        ( 0 ),
1767     pBottom     ( 0 ),
1768     pLeft       ( 0 ),
1769     pRight      ( 0 ),
1770     nTopDist    ( 0 ),
1771     nBottomDist ( 0 ),
1772     nLeftDist   ( 0 ),
1773     nRightDist  ( 0 )
1774 
1775 {
1776 }
1777 
1778 // -----------------------------------------------------------------------
1779 
~SvxBoxItem()1780 SvxBoxItem::~SvxBoxItem()
1781 {
1782     delete pTop;
1783     delete pBottom;
1784     delete pLeft;
1785     delete pRight;
1786 }
1787 
1788 // -----------------------------------------------------------------------
1789 
operator =(const SvxBoxItem & rBox)1790 SvxBoxItem& SvxBoxItem::operator=( const SvxBoxItem& rBox )
1791 {
1792     nTopDist = rBox.nTopDist;
1793     nBottomDist = rBox.nBottomDist;
1794     nLeftDist = rBox.nLeftDist;
1795     nRightDist = rBox.nRightDist;
1796     SetLine( rBox.GetTop(), BOX_LINE_TOP );
1797     SetLine( rBox.GetBottom(), BOX_LINE_BOTTOM );
1798     SetLine( rBox.GetLeft(), BOX_LINE_LEFT );
1799     SetLine( rBox.GetRight(), BOX_LINE_RIGHT );
1800     return *this;
1801 }
1802 
1803 // -----------------------------------------------------------------------
1804 
CmpBrdLn(const SvxBorderLine * pBrd1,const SvxBorderLine * pBrd2)1805 inline sal_Bool CmpBrdLn( const SvxBorderLine* pBrd1, const SvxBorderLine* pBrd2 )
1806 {
1807     sal_Bool bRet;
1808     if( 0 != pBrd1 ?  0 == pBrd2 : 0 != pBrd2 )
1809         bRet = sal_False;
1810     else
1811         if( !pBrd1 )
1812             bRet = sal_True;
1813         else
1814             bRet = (*pBrd1 == *pBrd2);
1815     return bRet;
1816 }
1817 
1818 // -----------------------------------------------------------------------
1819 
operator ==(const SfxPoolItem & rAttr) const1820 int SvxBoxItem::operator==( const SfxPoolItem& rAttr ) const
1821 {
1822     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
1823 
1824     return (
1825         ( nTopDist == ( (SvxBoxItem&)rAttr ).nTopDist ) &&
1826         ( nBottomDist == ( (SvxBoxItem&)rAttr ).nBottomDist )   &&
1827         ( nLeftDist == ( (SvxBoxItem&)rAttr ).nLeftDist )   &&
1828         ( nRightDist == ( (SvxBoxItem&)rAttr ).nRightDist ) &&
1829         CmpBrdLn( pTop, ( (SvxBoxItem&)rAttr ).GetTop() )           &&
1830         CmpBrdLn( pBottom, ( (SvxBoxItem&)rAttr ).GetBottom() )     &&
1831         CmpBrdLn( pLeft, ( (SvxBoxItem&)rAttr ).GetLeft() )         &&
1832         CmpBrdLn( pRight, ( (SvxBoxItem&)rAttr ).GetRight() ) );
1833 }
1834 
1835 // -----------------------------------------------------------------------
SvxLineToLine(const SvxBorderLine * pLine,sal_Bool bConvert)1836 table::BorderLine SvxBoxItem::SvxLineToLine(const SvxBorderLine* pLine, sal_Bool bConvert)
1837 {
1838     table::BorderLine aLine;
1839     if(pLine)
1840     {
1841         aLine.Color          = pLine->GetColor().GetColor() ;
1842         aLine.InnerLineWidth = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetInWidth() ): pLine->GetInWidth() );
1843         aLine.OuterLineWidth = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetOutWidth()): pLine->GetOutWidth() );
1844         aLine.LineDistance   = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetDistance()): pLine->GetDistance() );
1845     }
1846     else
1847         aLine.Color          = aLine.InnerLineWidth = aLine.OuterLineWidth = aLine.LineDistance  = 0;
1848     return aLine;
1849 }
1850 // -----------------------------------------------------------------------
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1851 sal_Bool SvxBoxItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId  ) const
1852 {
1853     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1854     table::BorderLine aRetLine;
1855     sal_uInt16 nDist = 0;
1856     sal_Bool bDistMember = sal_False;
1857     nMemberId &= ~CONVERT_TWIPS;
1858     sal_Bool bSerialize = sal_False;
1859     switch(nMemberId)
1860     {
1861         case 0:
1862         {
1863             // 4 Borders and 5 distances
1864             uno::Sequence< uno::Any > aSeq( 9 );
1865             aSeq[0] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetLeft(), bConvert) );
1866             aSeq[1] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetRight(), bConvert) );
1867             aSeq[2] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetBottom(), bConvert) );
1868             aSeq[3] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetTop(), bConvert) );
1869             aSeq[4] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( GetDistance()) : GetDistance()));
1870             aSeq[5] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nTopDist ) : nTopDist ));
1871             aSeq[6] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nBottomDist ) : nBottomDist ));
1872             aSeq[7] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nLeftDist ) : nLeftDist ));
1873             aSeq[8] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nRightDist ) : nRightDist ));
1874             rVal = uno::makeAny( aSeq );
1875             return sal_True;
1876         }
1877         case MID_LEFT_BORDER:
1878             bSerialize = sal_True;      // intentionally no break!
1879         case LEFT_BORDER:
1880             aRetLine = SvxBoxItem::SvxLineToLine(GetLeft(), bConvert);
1881             break;
1882         case MID_RIGHT_BORDER:
1883             bSerialize = sal_True;      // intentionally no break!
1884         case RIGHT_BORDER:
1885             aRetLine = SvxBoxItem::SvxLineToLine(GetRight(), bConvert);
1886             break;
1887         case MID_BOTTOM_BORDER:
1888             bSerialize = sal_True;      // intentionally no break!
1889         case BOTTOM_BORDER:
1890             aRetLine = SvxBoxItem::SvxLineToLine(GetBottom(), bConvert);
1891             break;
1892         case MID_TOP_BORDER:
1893             bSerialize = sal_True;      // intentionally no break!
1894         case TOP_BORDER:
1895             aRetLine = SvxBoxItem::SvxLineToLine(GetTop(), bConvert);
1896             break;
1897         case BORDER_DISTANCE:
1898             nDist = GetDistance();
1899             bDistMember = sal_True;
1900             break;
1901         case TOP_BORDER_DISTANCE:
1902             nDist = nTopDist;
1903             bDistMember = sal_True;
1904             break;
1905         case BOTTOM_BORDER_DISTANCE:
1906             nDist = nBottomDist;
1907             bDistMember = sal_True;
1908             break;
1909         case LEFT_BORDER_DISTANCE:
1910             nDist = nLeftDist;
1911             bDistMember = sal_True;
1912             break;
1913         case RIGHT_BORDER_DISTANCE:
1914             nDist = nRightDist;
1915             bDistMember = sal_True;
1916             break;
1917     }
1918 
1919     if( bDistMember )
1920         rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nDist) : nDist);
1921     else
1922     {
1923 /*
1924         if ( bSerialize )
1925         {
1926             ::com::sun::star::uno::Sequence < ::com::sun::star::uno::Any > aSeq(4);
1927             aSeq[0] <<= aRetLine.Color;
1928             aSeq[1] <<= aRetLine.InnerLineWidth;
1929             aSeq[2] <<= aRetLine.OuterLineWidth;
1930             aSeq[3] <<= aRetLine.LineDistance;
1931             rVal <<= aSeq;
1932         }
1933         else
1934 */
1935             rVal <<= aRetLine;
1936     }
1937 
1938     return sal_True;
1939 }
1940 
1941 // -----------------------------------------------------------------------
LineToSvxLine(const::com::sun::star::table::BorderLine & rLine,SvxBorderLine & rSvxLine,sal_Bool bConvert)1942 sal_Bool SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert)
1943 {
1944     rSvxLine.SetColor(   Color(rLine.Color));
1945     rSvxLine.SetInWidth( sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.InnerLineWidth) : rLine.InnerLineWidth  ));
1946     rSvxLine.SetOutWidth( sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.OuterLineWidth) : rLine.OuterLineWidth  ));
1947     rSvxLine.SetDistance( sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.LineDistance   )  : rLine.LineDistance  ));
1948     sal_Bool bRet = rLine.InnerLineWidth > 0 || rLine.OuterLineWidth > 0;
1949     return bRet;
1950 }
1951 
1952 // -----------------------------------------------------------------------
1953 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)1954 sal_Bool SvxBoxItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1955 {
1956     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1957     sal_uInt16 nLine = BOX_LINE_TOP;
1958     sal_Bool bDistMember = sal_False;
1959     nMemberId &= ~CONVERT_TWIPS;
1960     switch(nMemberId)
1961     {
1962         case 0:
1963         {
1964             uno::Sequence< uno::Any > aSeq;
1965             if (( rVal >>= aSeq ) && ( aSeq.getLength() == 9 ))
1966             {
1967                 // 4 Borders and 5 distances
1968                 sal_Int32 nDist = 0;
1969                 SvxBorderLine aLine;
1970                 table::BorderLine aBorderLine;
1971                 if ( aSeq[0] >>= aBorderLine )
1972                 {
1973                     sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
1974                     SetLine(bSet ? &aLine : 0, BOX_LINE_LEFT );
1975                 }
1976                 else
1977                     return sal_False;
1978 
1979                 if ( aSeq[1] >>= aBorderLine )
1980                 {
1981                     sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
1982                     SetLine(bSet ? &aLine : 0, BOX_LINE_RIGHT );
1983                 }
1984                 else
1985                     return sal_False;
1986 
1987                 if ( aSeq[2] >>= aBorderLine )
1988                 {
1989                     sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
1990                     SetLine(bSet ? &aLine : 0, BOX_LINE_BOTTOM );
1991                 }
1992                 else
1993                     return sal_False;
1994 
1995                 if ( aSeq[3] >>= aBorderLine )
1996                 {
1997                     sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
1998                     SetLine(bSet ? &aLine : 0, BOX_LINE_TOP );
1999                 }
2000                 else
2001                     return sal_False;
2002 
2003                 sal_uInt16 nLines[4] = { BOX_LINE_TOP, BOX_LINE_BOTTOM, BOX_LINE_LEFT, BOX_LINE_RIGHT };
2004                 for ( sal_Int32 n = 4; n < 9; n++ )
2005                 {
2006                     if ( aSeq[n] >>= nDist )
2007                     {
2008                         if( bConvert )
2009                             nDist = MM100_TO_TWIP(nDist);
2010                         if ( n == 4 )
2011                             SetDistance( sal_uInt16( nDist ));
2012                         else
2013                             SetDistance( sal_uInt16( nDist ), nLines[n-5] );
2014                     }
2015                     else
2016                         return sal_False;
2017                 }
2018 
2019                 return sal_True;
2020             }
2021             else
2022                 return sal_False;
2023         }
2024         case LEFT_BORDER_DISTANCE:
2025             bDistMember = sal_True;
2026         case LEFT_BORDER:
2027         case MID_LEFT_BORDER:
2028             nLine = BOX_LINE_LEFT;
2029             break;
2030         case RIGHT_BORDER_DISTANCE:
2031             bDistMember = sal_True;
2032         case RIGHT_BORDER:
2033         case MID_RIGHT_BORDER:
2034             nLine = BOX_LINE_RIGHT;
2035             break;
2036         case BOTTOM_BORDER_DISTANCE:
2037             bDistMember = sal_True;
2038         case BOTTOM_BORDER:
2039         case MID_BOTTOM_BORDER:
2040             nLine = BOX_LINE_BOTTOM;
2041             break;
2042         case TOP_BORDER_DISTANCE:
2043             bDistMember = sal_True;
2044         case TOP_BORDER:
2045         case MID_TOP_BORDER:
2046             nLine = BOX_LINE_TOP;
2047             break;
2048     }
2049 
2050     if( bDistMember || nMemberId == BORDER_DISTANCE )
2051     {
2052         sal_Int32 nDist = 0;
2053         if(!(rVal >>= nDist))
2054             return sal_False;
2055 
2056         if(nDist >= 0)
2057         {
2058             if( bConvert )
2059                 nDist = MM100_TO_TWIP(nDist);
2060             if( nMemberId == BORDER_DISTANCE )
2061                 SetDistance( sal_uInt16( nDist ));
2062             else
2063                 SetDistance( sal_uInt16( nDist ), nLine );
2064         }
2065     }
2066     else
2067     {
2068         SvxBorderLine aLine;
2069         if( !rVal.hasValue() )
2070             return sal_False;
2071 
2072         table::BorderLine aBorderLine;
2073         if( rVal >>= aBorderLine )
2074         {
2075             // usual struct
2076         }
2077         else if (rVal.getValueTypeClass() == uno::TypeClass_SEQUENCE )
2078         {
2079             // serialization for basic macro recording
2080             uno::Reference < script::XTypeConverter > xConverter
2081                     ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")),
2082                     uno::UNO_QUERY );
2083             uno::Sequence < uno::Any > aSeq;
2084             uno::Any aNew;
2085             try { aNew = xConverter->convertTo( rVal, ::getCppuType((const uno::Sequence < uno::Any >*)0) ); }
2086             catch (uno::Exception&) {}
2087 
2088             aNew >>= aSeq;
2089             if ( aSeq.getLength() == 4 )
2090             {
2091                 sal_Int32 nVal = 0;
2092                 if ( aSeq[0] >>= nVal )
2093                     aBorderLine.Color = nVal;
2094                 if ( aSeq[1] >>= nVal )
2095                     aBorderLine.InnerLineWidth = (sal_Int16) nVal;
2096                 if ( aSeq[2] >>= nVal )
2097                     aBorderLine.OuterLineWidth = (sal_Int16) nVal;
2098                 if ( aSeq[3] >>= nVal )
2099                     aBorderLine.LineDistance = (sal_Int16) nVal;
2100             }
2101             else
2102                 return sal_False;
2103         }
2104         else
2105             return sal_False;
2106 
2107         sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
2108         SetLine(bSet ? &aLine : 0, nLine);
2109     }
2110 
2111     return sal_True;
2112 }
2113 
2114 // -----------------------------------------------------------------------
2115 
Clone(SfxItemPool *) const2116 SfxPoolItem* SvxBoxItem::Clone( SfxItemPool* ) const
2117 {
2118     return new SvxBoxItem( *this );
2119 }
2120 
2121 //------------------------------------------------------------------------
2122 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,XubString & rText,const IntlWrapper * pIntl) const2123 SfxItemPresentation SvxBoxItem::GetPresentation
2124 (
2125     SfxItemPresentation ePres,
2126     SfxMapUnit          eCoreUnit,
2127     SfxMapUnit          ePresUnit,
2128     XubString&          rText, const IntlWrapper *pIntl
2129 )   const
2130 {
2131 #ifndef SVX_LIGHT
2132     switch ( ePres )
2133     {
2134         case SFX_ITEM_PRESENTATION_NONE:
2135             rText.Erase();
2136             return SFX_ITEM_PRESENTATION_NONE;
2137 
2138         case SFX_ITEM_PRESENTATION_NAMELESS:
2139         {
2140             rText.Erase();
2141 
2142             if ( pTop )
2143             {
2144                 rText = pTop->GetValueString( eCoreUnit, ePresUnit, pIntl );
2145                 rText += cpDelim;
2146             }
2147             if( !(pTop && pBottom && pLeft && pRight &&
2148                   *pTop == *pBottom && *pTop == *pLeft && *pTop == *pRight) )
2149             {
2150                 if ( pBottom )
2151                 {
2152                     rText += pBottom->GetValueString( eCoreUnit, ePresUnit, pIntl );
2153                     rText += cpDelim;
2154                 }
2155                 if ( pLeft )
2156                 {
2157                     rText += pLeft->GetValueString( eCoreUnit, ePresUnit, pIntl );
2158                     rText += cpDelim;
2159                 }
2160                 if ( pRight )
2161                 {
2162                     rText += pRight->GetValueString( eCoreUnit, ePresUnit, pIntl );
2163                     rText += cpDelim;
2164                 }
2165             }
2166             rText += GetMetricText( (long)nTopDist, eCoreUnit, ePresUnit, pIntl );
2167             if( nTopDist != nBottomDist || nTopDist != nLeftDist ||
2168                 nTopDist != nRightDist )
2169             {
2170                 (((((rText += cpDelim)
2171                       += GetMetricText( (long)nBottomDist, eCoreUnit,
2172                                         ePresUnit, pIntl ))
2173                       += cpDelim)
2174                       += GetMetricText( (long)nLeftDist, eCoreUnit, ePresUnit, pIntl ))
2175                       += cpDelim)
2176                       += GetMetricText( (long)nRightDist, eCoreUnit,
2177                                         ePresUnit, pIntl );
2178             }
2179             return SFX_ITEM_PRESENTATION_NAMELESS;
2180         }
2181         case SFX_ITEM_PRESENTATION_COMPLETE:
2182         {
2183             if( !(pTop || pBottom || pLeft || pRight) )
2184             {
2185                 rText = EE_RESSTR(RID_SVXITEMS_BORDER_NONE);
2186                 rText += cpDelim;
2187             }
2188             else
2189             {
2190                 rText = EE_RESSTR(RID_SVXITEMS_BORDER_COMPLETE);
2191                 if( pTop && pBottom && pLeft && pRight &&
2192                     *pTop == *pBottom && *pTop == *pLeft && *pTop == *pRight )
2193                 {
2194                     rText += pTop->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2195                     rText += cpDelim;
2196                 }
2197                 else
2198                 {
2199                     if ( pTop )
2200                     {
2201                         rText += EE_RESSTR(RID_SVXITEMS_BORDER_TOP);
2202                         rText += pTop->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2203                         rText += cpDelim;
2204                     }
2205                     if ( pBottom )
2206                     {
2207                         rText += EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM);
2208                         rText += pBottom->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2209                         rText += cpDelim;
2210                     }
2211                     if ( pLeft )
2212                     {
2213                         rText += EE_RESSTR(RID_SVXITEMS_BORDER_LEFT);
2214                         rText += pLeft->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2215                         rText += cpDelim;
2216                     }
2217                     if ( pRight )
2218                     {
2219                         rText += EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT);
2220                         rText += pRight->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2221                         rText += cpDelim;
2222                     }
2223                 }
2224             }
2225 
2226             rText += EE_RESSTR(RID_SVXITEMS_BORDER_DISTANCE);
2227             if( nTopDist == nBottomDist && nTopDist == nLeftDist &&
2228                 nTopDist == nRightDist )
2229             {
2230                 rText += GetMetricText( (long)nTopDist, eCoreUnit,
2231                                             ePresUnit, pIntl );
2232                 rText += sal_Unicode(' ');
2233                 rText += EE_RESSTR(GetMetricId(ePresUnit));
2234             }
2235             else
2236             {
2237                 ((((rText += EE_RESSTR(RID_SVXITEMS_BORDER_TOP))
2238                       += GetMetricText( (long)nTopDist, eCoreUnit,
2239                                         ePresUnit, pIntl ))
2240                       += sal_Unicode(' '))
2241                       += EE_RESSTR(GetMetricId(ePresUnit)))
2242                       += cpDelim;
2243                 ((((rText += EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM))
2244                       += GetMetricText( (long)nBottomDist, eCoreUnit,
2245                                         ePresUnit, pIntl ))
2246                       += sal_Unicode(' '))
2247                       += EE_RESSTR(GetMetricId(ePresUnit)))
2248                       += cpDelim;
2249                 ((((rText += EE_RESSTR(RID_SVXITEMS_BORDER_LEFT))
2250                       += GetMetricText( (long)nLeftDist, eCoreUnit,
2251                                         ePresUnit, pIntl ))
2252                       += sal_Unicode(' '))
2253                       += EE_RESSTR(GetMetricId(ePresUnit)))
2254                       += cpDelim;
2255                 (((rText += EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT))
2256                       += GetMetricText( (long)nRightDist, eCoreUnit,
2257                                         ePresUnit, pIntl ))
2258                       += sal_Unicode(' '))
2259                       += EE_RESSTR(GetMetricId(ePresUnit));
2260             }
2261             return SFX_ITEM_PRESENTATION_COMPLETE;
2262         }
2263         default: ;//prevent warning
2264     }
2265 #endif // !SVX_LIGHT
2266     return SFX_ITEM_PRESENTATION_NONE;
2267 }
2268 
2269 // -----------------------------------------------------------------------
2270 
Store(SvStream & rStrm,sal_uInt16 nItemVersion) const2271 SvStream& SvxBoxItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
2272 {
2273     rStrm << (sal_uInt16) GetDistance();
2274     const SvxBorderLine* pLine[ 4 ];    // top, left, right, bottom
2275     pLine[ 0 ] = GetTop();
2276     pLine[ 1 ] = GetLeft();
2277     pLine[ 2 ] = GetRight();
2278     pLine[ 3 ] = GetBottom();
2279 
2280     for( int i = 0; i < 4; i++ )
2281     {
2282         const SvxBorderLine* l = pLine[ i ];
2283         if( l )
2284         {
2285             rStrm << (sal_Int8) i
2286                   << l->GetColor()
2287                   << (sal_uInt16) l->GetOutWidth()
2288                   << (sal_uInt16) l->GetInWidth()
2289                   << (sal_uInt16) l->GetDistance();
2290         }
2291     }
2292     sal_Int8 cLine = 4;
2293     if( nItemVersion >= BOX_4DISTS_VERSION &&
2294         !(nTopDist == nLeftDist &&
2295           nTopDist == nRightDist &&
2296           nTopDist == nBottomDist) )
2297     {
2298         cLine |= 0x10;
2299     }
2300 
2301     rStrm << cLine;
2302 
2303     if( nItemVersion >= BOX_4DISTS_VERSION && (cLine & 0x10) != 0 )
2304     {
2305         rStrm << (sal_uInt16)nTopDist
2306               << (sal_uInt16)nLeftDist
2307               << (sal_uInt16)nRightDist
2308               << (sal_uInt16)nBottomDist;
2309     }
2310 
2311     return rStrm;
2312 }
2313 
2314 // -----------------------------------------------------------------------
2315 
GetVersion(sal_uInt16 nFFVer) const2316 sal_uInt16 SvxBoxItem::GetVersion( sal_uInt16 nFFVer ) const
2317 {
2318     DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
2319             SOFFICE_FILEFORMAT_40==nFFVer ||
2320             SOFFICE_FILEFORMAT_50==nFFVer,
2321             "SvxBoxItem: Gibt es ein neues Fileformat?" );
2322     return SOFFICE_FILEFORMAT_31==nFFVer ||
2323            SOFFICE_FILEFORMAT_40==nFFVer ? 0 : BOX_4DISTS_VERSION;
2324 }
2325 
2326 // -----------------------------------------------------------------------
2327 
ScaleMetrics(long nMult,long nDiv)2328 int SvxBoxItem::ScaleMetrics( long nMult, long nDiv )
2329 {
2330     if ( pTop )     pTop->ScaleMetrics( nMult, nDiv );
2331     if ( pBottom )  pBottom->ScaleMetrics( nMult, nDiv );
2332     if ( pLeft )    pLeft->ScaleMetrics( nMult, nDiv );
2333     if ( pRight )   pBottom->ScaleMetrics( nMult, nDiv );
2334     nTopDist = (sal_uInt16)Scale( nTopDist, nMult, nDiv );
2335     nBottomDist = (sal_uInt16)Scale( nBottomDist, nMult, nDiv );
2336     nLeftDist = (sal_uInt16)Scale( nLeftDist, nMult, nDiv );
2337     nRightDist = (sal_uInt16)Scale( nRightDist, nMult, nDiv );
2338     return 1;
2339 }
2340 
2341 // -----------------------------------------------------------------------
2342 
HasMetrics() const2343 int SvxBoxItem::HasMetrics() const
2344 {
2345     return 1;
2346 }
2347 
2348 // -----------------------------------------------------------------------
2349 
Create(SvStream & rStrm,sal_uInt16 nIVersion) const2350 SfxPoolItem* SvxBoxItem::Create( SvStream& rStrm, sal_uInt16 nIVersion ) const
2351 {
2352     sal_uInt16 nDistance;
2353     rStrm >> nDistance;
2354     SvxBoxItem* pAttr = new SvxBoxItem( Which() );
2355 
2356     sal_uInt16 aLineMap[4] = { BOX_LINE_TOP, BOX_LINE_LEFT,
2357                            BOX_LINE_RIGHT, BOX_LINE_BOTTOM };
2358 
2359     sal_Int8 cLine;
2360     while( sal_True )
2361     {
2362         rStrm >> cLine;
2363 
2364         if( cLine > 3 )
2365             break;
2366         sal_uInt16 nOutline, nInline, _nDistance;
2367         Color aColor;
2368         rStrm >> aColor >> nOutline >> nInline >> _nDistance;
2369         SvxBorderLine aBorder( &aColor, nOutline, nInline, _nDistance );
2370 
2371         pAttr->SetLine( &aBorder, aLineMap[cLine] );
2372     }
2373 
2374     if( nIVersion >= BOX_4DISTS_VERSION && (cLine&0x10) != 0 )
2375     {
2376         for( sal_uInt16 i=0; i < 4; i++ )
2377         {
2378             sal_uInt16 nDist;
2379             rStrm >> nDist;
2380             pAttr->SetDistance( nDist, aLineMap[i] );
2381         }
2382     }
2383     else
2384     {
2385         pAttr->SetDistance( nDistance );
2386     }
2387 
2388     return pAttr;
2389 }
2390 
2391 // -----------------------------------------------------------------------
2392 
GetLine(sal_uInt16 nLine) const2393 const SvxBorderLine *SvxBoxItem::GetLine( sal_uInt16 nLine ) const
2394 {
2395     const SvxBorderLine *pRet = 0;
2396 
2397     switch ( nLine )
2398     {
2399         case BOX_LINE_TOP:
2400             pRet = pTop;
2401             break;
2402         case BOX_LINE_BOTTOM:
2403             pRet = pBottom;
2404             break;
2405         case BOX_LINE_LEFT:
2406             pRet = pLeft;
2407             break;
2408         case BOX_LINE_RIGHT:
2409             pRet = pRight;
2410             break;
2411         default:
2412             DBG_ERROR( "wrong line" );
2413             break;
2414     }
2415 
2416     return pRet;
2417 }
2418 
2419 // -----------------------------------------------------------------------
2420 
SetLine(const SvxBorderLine * pNew,sal_uInt16 nLine)2421 void SvxBoxItem::SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine )
2422 {
2423     SvxBorderLine* pTmp = pNew ? new SvxBorderLine( *pNew ) : 0;
2424 
2425     switch ( nLine )
2426     {
2427         case BOX_LINE_TOP:
2428             delete pTop;
2429             pTop = pTmp;
2430             break;
2431         case BOX_LINE_BOTTOM:
2432             delete pBottom;
2433             pBottom = pTmp;
2434             break;
2435         case BOX_LINE_LEFT:
2436             delete pLeft;
2437             pLeft = pTmp;
2438             break;
2439         case BOX_LINE_RIGHT:
2440             delete pRight;
2441             pRight = pTmp;
2442             break;
2443         default:
2444             DBG_ERROR( "wrong line" );
2445     }
2446 }
2447 
2448 // -----------------------------------------------------------------------
2449 
GetDistance() const2450 sal_uInt16 SvxBoxItem::GetDistance() const
2451 {
2452     // The smallest distance that is not 0 will be returned.
2453     sal_uInt16 nDist = nTopDist;
2454     if( nBottomDist && (!nDist || nBottomDist < nDist) )
2455         nDist = nBottomDist;
2456     if( nLeftDist && (!nDist || nLeftDist < nDist) )
2457         nDist = nLeftDist;
2458     if( nRightDist && (!nDist || nRightDist < nDist) )
2459         nDist = nRightDist;
2460 
2461     return nDist;
2462 }
2463 
2464 // -----------------------------------------------------------------------
2465 
GetDistance(sal_uInt16 nLine) const2466 sal_uInt16 SvxBoxItem::GetDistance( sal_uInt16 nLine ) const
2467 {
2468     sal_uInt16 nDist = 0;
2469     switch ( nLine )
2470     {
2471         case BOX_LINE_TOP:
2472             nDist = nTopDist;
2473             break;
2474         case BOX_LINE_BOTTOM:
2475             nDist = nBottomDist;
2476             break;
2477         case BOX_LINE_LEFT:
2478             nDist = nLeftDist;
2479             break;
2480         case BOX_LINE_RIGHT:
2481             nDist = nRightDist;
2482             break;
2483         default:
2484             DBG_ERROR( "wrong line" );
2485     }
2486 
2487     return nDist;
2488 }
2489 
2490 // -----------------------------------------------------------------------
2491 
SetDistance(sal_uInt16 nNew,sal_uInt16 nLine)2492 void SvxBoxItem::SetDistance( sal_uInt16 nNew, sal_uInt16 nLine )
2493 {
2494     switch ( nLine )
2495     {
2496         case BOX_LINE_TOP:
2497             nTopDist = nNew;
2498             break;
2499         case BOX_LINE_BOTTOM:
2500             nBottomDist = nNew;
2501             break;
2502         case BOX_LINE_LEFT:
2503             nLeftDist = nNew;
2504             break;
2505         case BOX_LINE_RIGHT:
2506             nRightDist = nNew;
2507             break;
2508         default:
2509             DBG_ERROR( "wrong line" );
2510     }
2511 }
2512 
2513 // -----------------------------------------------------------------------
2514 
CalcLineSpace(sal_uInt16 nLine,sal_Bool bIgnoreLine) const2515 sal_uInt16 SvxBoxItem::CalcLineSpace( sal_uInt16 nLine, sal_Bool bIgnoreLine ) const
2516 {
2517     SvxBorderLine* pTmp = 0;
2518     sal_uInt16 nDist = 0;
2519     switch ( nLine )
2520     {
2521     case BOX_LINE_TOP:
2522         pTmp = pTop;
2523         nDist = nTopDist;
2524         break;
2525     case BOX_LINE_BOTTOM:
2526         pTmp = pBottom;
2527         nDist = nBottomDist;
2528         break;
2529     case BOX_LINE_LEFT:
2530         pTmp = pLeft;
2531         nDist = nLeftDist;
2532         break;
2533     case BOX_LINE_RIGHT:
2534         pTmp = pRight;
2535         nDist = nRightDist;
2536         break;
2537     default:
2538         DBG_ERROR( "wrong line" );
2539     }
2540 
2541     if( pTmp )
2542     {
2543         nDist = nDist + (sal_uInt16)(pTmp->GetOutWidth()) + (sal_uInt16)(pTmp->GetInWidth()) + (sal_uInt16)(pTmp->GetDistance());
2544     }
2545     else if( !bIgnoreLine )
2546         nDist = 0;
2547     return nDist;
2548 }
2549 
2550 // class SvxBoxInfoItem --------------------------------------------------
2551 
SvxBoxInfoItem(const sal_uInt16 nId)2552 SvxBoxInfoItem::SvxBoxInfoItem( const sal_uInt16 nId ) :
2553     SfxPoolItem( nId ),
2554     pHori   ( 0 ),
2555     pVert   ( 0 ),
2556     mbEnableHor( false ),
2557     mbEnableVer( false ),
2558     nDefDist( 0 )
2559 {
2560     bDist = bMinDist = sal_False;
2561     ResetFlags();
2562 }
2563 
2564 // -----------------------------------------------------------------------
2565 
SvxBoxInfoItem(const SvxBoxInfoItem & rCpy)2566 SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem& rCpy ) :
2567     SfxPoolItem( rCpy ),
2568     mbEnableHor( rCpy.mbEnableHor ),
2569     mbEnableVer( rCpy.mbEnableVer )
2570 {
2571     pHori       = rCpy.GetHori() ? new SvxBorderLine( *rCpy.GetHori() ) : 0;
2572     pVert       = rCpy.GetVert() ? new SvxBorderLine( *rCpy.GetVert() ) : 0;
2573     bDist       = rCpy.IsDist();
2574     bMinDist    = rCpy.IsMinDist();
2575     nValidFlags = rCpy.nValidFlags;
2576     nDefDist    = rCpy.GetDefDist();
2577 }
2578 
2579 // -----------------------------------------------------------------------
2580 
~SvxBoxInfoItem()2581 SvxBoxInfoItem::~SvxBoxInfoItem()
2582 {
2583     delete pHori;
2584     delete pVert;
2585 }
2586 
2587 // -----------------------------------------------------------------------
2588 
operator =(const SvxBoxInfoItem & rCpy)2589 SvxBoxInfoItem &SvxBoxInfoItem::operator=( const SvxBoxInfoItem& rCpy )
2590 {
2591     delete pHori;
2592     delete pVert;
2593     pHori       = rCpy.GetHori() ? new SvxBorderLine( *rCpy.GetHori() ) : 0;
2594     pVert       = rCpy.GetVert() ? new SvxBorderLine( *rCpy.GetVert() ) : 0;
2595     mbEnableHor = rCpy.mbEnableHor;
2596     mbEnableVer = rCpy.mbEnableVer;
2597     bDist       = rCpy.IsDist();
2598     bMinDist    = rCpy.IsMinDist();
2599     nValidFlags = rCpy.nValidFlags;
2600     nDefDist    = rCpy.GetDefDist();
2601     return *this;
2602 }
2603 
2604 // -----------------------------------------------------------------------
2605 
operator ==(const SfxPoolItem & rAttr) const2606 int SvxBoxInfoItem::operator==( const SfxPoolItem& rAttr ) const
2607 {
2608     SvxBoxInfoItem& rBoxInfo = (SvxBoxInfoItem&)rAttr;
2609 
2610     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
2611 
2612     return (   mbEnableHor               == rBoxInfo.mbEnableHor
2613             && mbEnableVer               == rBoxInfo.mbEnableVer
2614             && bDist                     == rBoxInfo.IsDist()
2615             && bMinDist                  == rBoxInfo.IsMinDist()
2616             && nValidFlags               == rBoxInfo.nValidFlags
2617             && nDefDist                  == rBoxInfo.GetDefDist()
2618             && CmpBrdLn( pHori, rBoxInfo.GetHori() )
2619             && CmpBrdLn( pVert, rBoxInfo.GetVert() )
2620            );
2621 }
2622 
2623 // -----------------------------------------------------------------------
2624 
SetLine(const SvxBorderLine * pNew,sal_uInt16 nLine)2625 void SvxBoxInfoItem::SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine )
2626 {
2627     SvxBorderLine* pTmp = pNew ? new SvxBorderLine( *pNew ) : 0;
2628 
2629     if ( BOXINFO_LINE_HORI == nLine )
2630     {
2631         delete pHori;
2632         pHori = pTmp;
2633     }
2634     else if ( BOXINFO_LINE_VERT == nLine )
2635     {
2636         delete pVert;
2637         pVert = pTmp;
2638     }
2639     else
2640     {
2641         DBG_ERROR( "wrong line" );
2642     }
2643 }
2644 
2645 
2646 // -----------------------------------------------------------------------
2647 
Clone(SfxItemPool *) const2648 SfxPoolItem* SvxBoxInfoItem::Clone( SfxItemPool* ) const
2649 {
2650     return new SvxBoxInfoItem( *this );
2651 }
2652 
2653 //------------------------------------------------------------------------
2654 
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const2655 SfxItemPresentation SvxBoxInfoItem::GetPresentation
2656 (
2657     SfxItemPresentation /*ePres*/,
2658     SfxMapUnit          /*eCoreUnit*/,
2659     SfxMapUnit          /*ePresUnit*/,
2660     XubString&          rText, const IntlWrapper *
2661 )   const
2662 {
2663 #ifndef SVX_LIGHT
2664 /*!!!
2665     ResMgr* pMgr = DIALOG_MGR();
2666     if ( pHori )
2667     {
2668         rText += pHori->GetValueString();
2669         rText += cpDelim;
2670     }
2671     if ( pVert )
2672     {
2673         rText += pVert->GetValueString();
2674         rText += cpDelim;
2675     }
2676     if ( bTable )
2677         rText += String( ResId( RID_SVXITEMS_BOXINF_TABLE_TRUE, pMgr ) );
2678     else
2679         rText += String( ResId( RID_SVXITEMS_BOXINF_TABLE_FALSE, pMgr ) );
2680     rText += cpDelim;
2681     if ( bDist )
2682         rText += String( ResId( RID_SVXITEMS_BOXINF_DIST_TRUE, pMgr ) );
2683     else
2684         rText += String( ResId( RID_SVXITEMS_BOXINF_DIST_FALSE, pMgr ) );
2685     rText += cpDelim;
2686     if ( bMinDist )
2687         rText += String( ResId( RID_SVXITEMS_BOXINF_MDIST_TRUE, pMgr ) );
2688     else
2689         rText += String( ResId( RID_SVXITEMS_BOXINF_MDIST_FALSE, pMgr ) );
2690     rText += cpDelim;
2691     rText += nDefDist;
2692     return SFX_ITEM_PRESENTATION_NAMELESS;
2693 */
2694     rText.Erase();
2695 #endif // !SVX_LIGHT
2696     return SFX_ITEM_PRESENTATION_NONE;
2697 }
2698 
2699 // -----------------------------------------------------------------------
2700 
Store(SvStream & rStrm,sal_uInt16) const2701 SvStream& SvxBoxInfoItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2702 {
2703     sal_Int8 cFlags = 0;
2704 
2705     if ( IsTable() )
2706         cFlags |= 0x01;
2707     if ( IsDist() )
2708         cFlags |= 0x02;
2709     if ( IsMinDist() )
2710         cFlags |= 0x04;
2711     rStrm << (sal_Int8)   cFlags
2712           << (sal_uInt16) GetDefDist();
2713     const SvxBorderLine* pLine[ 2 ];
2714     pLine[ 0 ] = GetHori();
2715     pLine[ 1 ] = GetVert();
2716 
2717     for( int i = 0; i < 2; i++ )
2718     {
2719         const SvxBorderLine* l = pLine[ i ];
2720         if( l )
2721         {
2722             rStrm << (char) i
2723                   << l->GetColor()
2724                   << (short) l->GetOutWidth()
2725                   << (short) l->GetInWidth()
2726                   << (short) l->GetDistance();
2727         }
2728     }
2729     rStrm << (char) 2;
2730     return rStrm;
2731 }
2732 
2733 // -----------------------------------------------------------------------
2734 
ScaleMetrics(long nMult,long nDiv)2735 int SvxBoxInfoItem::ScaleMetrics( long nMult, long nDiv )
2736 {
2737     if ( pHori ) pHori->ScaleMetrics( nMult, nDiv );
2738     if ( pVert ) pVert->ScaleMetrics( nMult, nDiv );
2739     nDefDist = (sal_uInt16)Scale( nDefDist, nMult, nDiv );
2740     return 1;
2741 }
2742 
2743 // -----------------------------------------------------------------------
2744 
HasMetrics() const2745 int SvxBoxInfoItem::HasMetrics() const
2746 {
2747     return 1;
2748 }
2749 
2750 // -----------------------------------------------------------------------
2751 
Create(SvStream & rStrm,sal_uInt16) const2752 SfxPoolItem* SvxBoxInfoItem::Create( SvStream& rStrm, sal_uInt16 ) const
2753 {
2754     sal_Int8 cFlags;
2755     sal_uInt16 _nDefDist;
2756     rStrm >> cFlags >> _nDefDist;
2757 
2758     SvxBoxInfoItem* pAttr = new SvxBoxInfoItem( Which() );
2759 
2760     pAttr->SetTable  ( ( cFlags & 0x01 ) != 0 );
2761     pAttr->SetDist   ( ( cFlags & 0x02 ) != 0 );
2762     pAttr->SetMinDist( ( cFlags & 0x04 ) != 0 );
2763     pAttr->SetDefDist( _nDefDist );
2764 
2765     while( sal_True )
2766     {
2767         sal_Int8 cLine;
2768         rStrm >> cLine;
2769 
2770         if( cLine > 1 )
2771             break;
2772         short nOutline, nInline, nDistance;
2773         Color aColor;
2774         rStrm >> aColor >> nOutline >> nInline >> nDistance;
2775         SvxBorderLine aBorder( &aColor, nOutline, nInline, nDistance );
2776 
2777         switch( cLine )
2778         {
2779             case 0: pAttr->SetLine( &aBorder, BOXINFO_LINE_HORI ); break;
2780             case 1: pAttr->SetLine( &aBorder, BOXINFO_LINE_VERT ); break;
2781         }
2782     }
2783     return pAttr;
2784 }
2785 
2786 // -----------------------------------------------------------------------
2787 
ResetFlags()2788 void SvxBoxInfoItem::ResetFlags()
2789 {
2790     nValidFlags = 0x7F; // alles g"ultig au/ser Disable
2791 }
2792 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const2793 sal_Bool SvxBoxInfoItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId  ) const
2794 {
2795     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2796     table::BorderLine aRetLine;
2797     sal_Int16 nVal=0;
2798     sal_Bool bIntMember = sal_False;
2799     nMemberId &= ~CONVERT_TWIPS;
2800     sal_Bool bSerialize = sal_False;
2801     switch(nMemberId)
2802     {
2803         case 0:
2804         {
2805             // 2 BorderLines, flags, valid flags and distance
2806             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq( 5 );
2807             aSeq[0] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pHori, bConvert) );
2808             aSeq[1] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pVert, bConvert) );
2809             if ( IsTable() )
2810                 nVal |= 0x01;
2811             if ( IsDist() )
2812                 nVal |= 0x02;
2813             if ( IsMinDist() )
2814                 nVal |= 0x04;
2815             aSeq[2] = ::com::sun::star::uno::makeAny( nVal );
2816             nVal = nValidFlags;
2817             aSeq[3] = ::com::sun::star::uno::makeAny( nVal );
2818             aSeq[4] = ::com::sun::star::uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist()) );
2819             rVal = ::com::sun::star::uno::makeAny( aSeq );
2820             return sal_True;
2821         }
2822 
2823         case MID_HORIZONTAL:
2824             bSerialize = sal_True;
2825             aRetLine = SvxBoxItem::SvxLineToLine( pHori, bConvert);
2826             break;
2827         case MID_VERTICAL:
2828             bSerialize = sal_True;
2829             aRetLine = SvxBoxItem::SvxLineToLine( pVert, bConvert);
2830             break;
2831         case MID_FLAGS:
2832             bIntMember = sal_True;
2833             if ( IsTable() )
2834                 nVal |= 0x01;
2835             if ( IsDist() )
2836                 nVal |= 0x02;
2837             if ( IsMinDist() )
2838                 nVal |= 0x04;
2839             rVal <<= nVal;
2840             break;
2841         case MID_VALIDFLAGS:
2842             bIntMember = sal_True;
2843             nVal = nValidFlags;
2844             rVal <<= nVal;
2845             break;
2846         case MID_DISTANCE:
2847             bIntMember = sal_True;
2848             rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist());
2849             break;
2850         default: DBG_ERROR("Wrong MemberId!"); return sal_False;
2851     }
2852 
2853     if( !bIntMember )
2854     {
2855 /*
2856         if ( bSerialize )
2857         {
2858             ::com::sun::star::uno::Sequence < ::com::sun::star::uno::Any > aSeq(4);
2859             aSeq[0] <<= aRetLine.Color;
2860             aSeq[1] <<= aRetLine.InnerLineWidth;
2861             aSeq[2] <<= aRetLine.OuterLineWidth;
2862             aSeq[3] <<= aRetLine.LineDistance;
2863             rVal <<= aSeq;
2864         }
2865         else
2866  */
2867             rVal <<= aRetLine;
2868     }
2869 
2870     return sal_True;
2871 }
2872 
2873 // -----------------------------------------------------------------------
2874 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)2875 sal_Bool SvxBoxInfoItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2876 {
2877     sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2878 //  sal_uInt16 nLine = BOX_LINE_TOP;
2879 //  sal_Bool bDistMember = sal_False;
2880     nMemberId &= ~CONVERT_TWIPS;
2881     sal_Bool bRet;
2882     switch(nMemberId)
2883     {
2884         case 0:
2885         {
2886             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq;
2887             if (( rVal >>= aSeq ) && ( aSeq.getLength() == 5 ))
2888             {
2889                 // 2 BorderLines, flags, valid flags and distance
2890                 table::BorderLine aBorderLine;
2891                 SvxBorderLine aLine;
2892                 sal_Int16 nFlags( 0 );
2893                 sal_Int32 nVal( 0 );
2894                 if ( aSeq[0] >>= aBorderLine )
2895                 {
2896                     sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
2897                     if ( bSet )
2898                         SetLine( &aLine, BOXINFO_LINE_HORI );
2899                 }
2900                 else
2901                     return sal_False;
2902                 if ( aSeq[1] >>= aBorderLine )
2903                 {
2904                     sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
2905                     if ( bSet )
2906                         SetLine( &aLine, BOXINFO_LINE_VERT );
2907                 }
2908                 else
2909                     return sal_False;
2910                 if ( aSeq[2] >>= nFlags )
2911                 {
2912                     SetTable  ( ( nFlags & 0x01 ) != 0 );
2913                     SetDist   ( ( nFlags & 0x02 ) != 0 );
2914                     SetMinDist( ( nFlags & 0x04 ) != 0 );
2915                 }
2916                 else
2917                     return sal_False;
2918                 if ( aSeq[3] >>= nFlags )
2919                     nValidFlags = (sal_uInt8)nFlags;
2920                 else
2921                     return sal_False;
2922                 if (( aSeq[4] >>= nVal ) && ( nVal >= 0 ))
2923                 {
2924                     if( bConvert )
2925                         nVal = MM100_TO_TWIP(nVal);
2926                     SetDefDist( (sal_uInt16)nVal );
2927                 }
2928             }
2929             return sal_True;
2930         }
2931 
2932         case MID_HORIZONTAL:
2933         case MID_VERTICAL:
2934         {
2935             if( !rVal.hasValue() )
2936                 return sal_False;
2937 
2938             table::BorderLine aBorderLine;
2939             if( rVal >>= aBorderLine )
2940             {
2941                 // usual struct
2942             }
2943             else if (rVal.getValueTypeClass() == uno::TypeClass_SEQUENCE )
2944             {
2945                 // serialization for basic macro recording
2946                 uno::Reference < script::XTypeConverter > xConverter
2947                         ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")),
2948                         uno::UNO_QUERY );
2949                 uno::Any aNew;
2950                 uno::Sequence < uno::Any > aSeq;
2951                 try { aNew = xConverter->convertTo( rVal, ::getCppuType((const uno::Sequence < uno::Any >*)0) ); }
2952                 catch (uno::Exception&) {}
2953 
2954                 if( (aNew >>= aSeq) && aSeq.getLength() == 4 )
2955                 {
2956                     sal_Int32 nVal = 0;
2957                     if ( aSeq[0] >>= nVal )
2958                         aBorderLine.Color = nVal;
2959                     if ( aSeq[1] >>= nVal )
2960                         aBorderLine.InnerLineWidth = (sal_Int16) nVal;
2961                     if ( aSeq[2] >>= nVal )
2962                         aBorderLine.OuterLineWidth = (sal_Int16) nVal;
2963                     if ( aSeq[3] >>= nVal )
2964                         aBorderLine.LineDistance = (sal_Int16) nVal;
2965                 }
2966                 else
2967                     return sal_False;
2968             }
2969             else if (rVal.getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < sal_Int16 >*)0) )
2970             {
2971                 // serialization for basic macro recording
2972                 ::com::sun::star::uno::Sequence < sal_Int16 > aSeq;
2973                 rVal >>= aSeq;
2974                 if ( aSeq.getLength() == 4 )
2975                 {
2976                     aBorderLine.Color = aSeq[0];
2977                     aBorderLine.InnerLineWidth = aSeq[1];
2978                     aBorderLine.OuterLineWidth = aSeq[2];
2979                     aBorderLine.LineDistance = aSeq[3];
2980                 }
2981                 else
2982                     return sal_False;
2983             }
2984             else
2985                 return sal_False;
2986 
2987             SvxBorderLine aLine;
2988             sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
2989             if ( bSet )
2990                 SetLine( &aLine, nMemberId == MID_HORIZONTAL ? BOXINFO_LINE_HORI : BOXINFO_LINE_VERT );
2991             break;
2992         }
2993         case MID_FLAGS:
2994         {
2995             sal_Int16 nFlags = sal_Int16();
2996             bRet = (rVal >>= nFlags);
2997             if ( bRet )
2998             {
2999                 SetTable  ( ( nFlags & 0x01 ) != 0 );
3000                 SetDist   ( ( nFlags & 0x02 ) != 0 );
3001                 SetMinDist( ( nFlags & 0x04 ) != 0 );
3002             }
3003 
3004             break;
3005         }
3006         case MID_VALIDFLAGS:
3007         {
3008             sal_Int16 nFlags = sal_Int16();
3009             bRet = (rVal >>= nFlags);
3010             if ( bRet )
3011                 nValidFlags = (sal_uInt8)nFlags;
3012             break;
3013         }
3014         case MID_DISTANCE:
3015         {
3016             sal_Int32 nVal = 0;
3017             bRet = (rVal >>= nVal);
3018             if ( bRet && nVal>=0 )
3019             {
3020                 if( bConvert )
3021                     nVal = MM100_TO_TWIP(nVal);
3022                 SetDefDist( (sal_uInt16)nVal );
3023             }
3024             break;
3025         }
3026         default: DBG_ERROR("Wrong MemberId!"); return sal_False;
3027     }
3028 
3029     return sal_True;
3030 }
3031 
3032 // class SvxFmtBreakItem -------------------------------------------------
3033 
operator ==(const SfxPoolItem & rAttr) const3034 int SvxFmtBreakItem::operator==( const SfxPoolItem& rAttr ) const
3035 {
3036     DBG_ASSERT( SfxPoolItem::operator==( rAttr ), "unequal types" );
3037 
3038     return GetValue() == ( (SvxFmtBreakItem&)rAttr ).GetValue();
3039 }
3040 
3041 //------------------------------------------------------------------------
3042 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const3043 SfxItemPresentation SvxFmtBreakItem::GetPresentation
3044 (
3045     SfxItemPresentation ePres,
3046     SfxMapUnit          /*eCoreUnit*/,
3047     SfxMapUnit          /*ePresUnit*/,
3048     XubString&          rText, const IntlWrapper *
3049 )   const
3050 {
3051 #ifndef SVX_LIGHT
3052     switch ( ePres )
3053     {
3054         case SFX_ITEM_PRESENTATION_NONE:
3055             rText.Erase();
3056             return SFX_ITEM_PRESENTATION_NONE;
3057 
3058         case SFX_ITEM_PRESENTATION_NAMELESS:
3059         case SFX_ITEM_PRESENTATION_COMPLETE:
3060             rText = GetValueTextByPos( GetValue() );
3061             return ePres;
3062         default: ;//prevent warning
3063     }
3064 #endif // !SVX_LIGHT
3065     return SFX_ITEM_PRESENTATION_NONE;
3066 }
3067 
3068 // -----------------------------------------------------------------------
3069 
GetValueTextByPos(sal_uInt16 nPos) const3070 XubString SvxFmtBreakItem::GetValueTextByPos( sal_uInt16 nPos ) const
3071 {
3072     DBG_ASSERT( nPos < SVX_BREAK_END, "enum overflow!" );
3073     XubString aStr( EditResId( RID_SVXITEMS_BREAK_BEGIN + nPos ) );
3074     return aStr;
3075 }
3076 
3077 // -----------------------------------------------------------------------
QueryValue(uno::Any & rVal,sal_uInt8) const3078 sal_Bool SvxFmtBreakItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
3079 {
3080     style::BreakType eBreak = style::BreakType_NONE;
3081     switch ( (SvxBreak)GetValue() )
3082     {
3083         case SVX_BREAK_COLUMN_BEFORE:   eBreak = style::BreakType_COLUMN_BEFORE; break;
3084         case SVX_BREAK_COLUMN_AFTER:    eBreak = style::BreakType_COLUMN_AFTER ; break;
3085         case SVX_BREAK_COLUMN_BOTH:     eBreak = style::BreakType_COLUMN_BOTH  ; break;
3086         case SVX_BREAK_PAGE_BEFORE:     eBreak = style::BreakType_PAGE_BEFORE  ; break;
3087         case SVX_BREAK_PAGE_AFTER:      eBreak = style::BreakType_PAGE_AFTER   ; break;
3088         case SVX_BREAK_PAGE_BOTH:       eBreak = style::BreakType_PAGE_BOTH    ; break;
3089         default: ;//prevent warning
3090     }
3091     rVal <<= eBreak;
3092     return sal_True;
3093 }
3094 // -----------------------------------------------------------------------
PutValue(const uno::Any & rVal,sal_uInt8)3095 sal_Bool SvxFmtBreakItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
3096 {
3097     style::BreakType nBreak;
3098 
3099     if(!(rVal >>= nBreak))
3100     {
3101         sal_Int32 nValue = 0;
3102         if(!(rVal >>= nValue))
3103             return sal_False;
3104 
3105         nBreak = (style::BreakType) nValue;
3106     }
3107 
3108     SvxBreak eBreak = SVX_BREAK_NONE;
3109     switch( nBreak )
3110     {
3111         case style::BreakType_COLUMN_BEFORE:    eBreak = SVX_BREAK_COLUMN_BEFORE; break;
3112         case style::BreakType_COLUMN_AFTER: eBreak = SVX_BREAK_COLUMN_AFTER;  break;
3113         case style::BreakType_COLUMN_BOTH:      eBreak = SVX_BREAK_COLUMN_BOTH;   break;
3114         case style::BreakType_PAGE_BEFORE:      eBreak = SVX_BREAK_PAGE_BEFORE;   break;
3115         case style::BreakType_PAGE_AFTER:       eBreak = SVX_BREAK_PAGE_AFTER;    break;
3116         case style::BreakType_PAGE_BOTH:        eBreak = SVX_BREAK_PAGE_BOTH;     break;
3117         default: ;//prevent warning
3118     }
3119     SetValue((sal_uInt16) eBreak);
3120 
3121     return sal_True;
3122 }
3123 
3124 // -----------------------------------------------------------------------
3125 
Clone(SfxItemPool *) const3126 SfxPoolItem* SvxFmtBreakItem::Clone( SfxItemPool* ) const
3127 {
3128     return new SvxFmtBreakItem( *this );
3129 }
3130 
3131 // -----------------------------------------------------------------------
3132 
Store(SvStream & rStrm,sal_uInt16 nItemVersion) const3133 SvStream& SvxFmtBreakItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
3134 {
3135     rStrm << (sal_Int8)GetValue();
3136     if( FMTBREAK_NOAUTO > nItemVersion )
3137         rStrm << (sal_Int8)0x01;
3138     return rStrm;
3139 }
3140 
3141 // -----------------------------------------------------------------------
3142 
GetVersion(sal_uInt16 nFFVer) const3143 sal_uInt16 SvxFmtBreakItem::GetVersion( sal_uInt16 nFFVer ) const
3144 {
3145     DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
3146             SOFFICE_FILEFORMAT_40==nFFVer ||
3147             SOFFICE_FILEFORMAT_50==nFFVer,
3148             "SvxFmtBreakItem: Gibt es ein neues Fileformat?" );
3149     return SOFFICE_FILEFORMAT_31==nFFVer ||
3150            SOFFICE_FILEFORMAT_40==nFFVer ? 0 : FMTBREAK_NOAUTO;
3151 }
3152 
3153 // -----------------------------------------------------------------------
3154 
Create(SvStream & rStrm,sal_uInt16 nVersion) const3155 SfxPoolItem* SvxFmtBreakItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
3156 {
3157     sal_Int8 eBreak, bDummy;
3158     rStrm >> eBreak;
3159     if( FMTBREAK_NOAUTO > nVersion )
3160         rStrm >> bDummy;
3161     return new SvxFmtBreakItem( (const SvxBreak)eBreak, Which() );
3162 }
3163 
3164 // -----------------------------------------------------------------------
3165 
GetValueCount() const3166 sal_uInt16 SvxFmtBreakItem::GetValueCount() const
3167 {
3168     return SVX_BREAK_END;   // SVX_BREAK_PAGE_BOTH + 1
3169 }
3170 
3171 // class SvxFmtKeepItem -------------------------------------------------
3172 
Clone(SfxItemPool *) const3173 SfxPoolItem* SvxFmtKeepItem::Clone( SfxItemPool* ) const
3174 {
3175     return new SvxFmtKeepItem( *this );
3176 }
3177 
3178 // -----------------------------------------------------------------------
3179 
Store(SvStream & rStrm,sal_uInt16) const3180 SvStream& SvxFmtKeepItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
3181 {
3182     rStrm << (sal_Int8)GetValue();
3183     return rStrm;
3184 }
3185 
3186 // -----------------------------------------------------------------------
3187 
Create(SvStream & rStrm,sal_uInt16) const3188 SfxPoolItem* SvxFmtKeepItem::Create( SvStream& rStrm, sal_uInt16 ) const
3189 {
3190     sal_Int8 bIsKeep;
3191     rStrm >> bIsKeep;
3192     return new SvxFmtKeepItem( sal_Bool( bIsKeep != 0 ), Which() );
3193 }
3194 
3195 //------------------------------------------------------------------------
3196 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const3197 SfxItemPresentation SvxFmtKeepItem::GetPresentation
3198 (
3199     SfxItemPresentation ePres,
3200     SfxMapUnit          /*eCoreUnit*/,
3201     SfxMapUnit          /*ePresUnit*/,
3202     XubString&          rText, const IntlWrapper *
3203     ) const
3204 {
3205 #ifndef SVX_LIGHT
3206     switch ( ePres )
3207     {
3208         case SFX_ITEM_PRESENTATION_NONE:
3209             rText.Erase();
3210             return ePres;
3211 
3212         case SFX_ITEM_PRESENTATION_NAMELESS:
3213         case SFX_ITEM_PRESENTATION_COMPLETE:
3214         {
3215             sal_uInt16 nId = RID_SVXITEMS_FMTKEEP_FALSE;
3216 
3217             if ( GetValue() )
3218                 nId = RID_SVXITEMS_FMTKEEP_TRUE;
3219             rText = EE_RESSTR(nId);
3220             return ePres;
3221         }
3222         default: ;//prevent warning
3223     }
3224 #endif
3225     return SFX_ITEM_PRESENTATION_NONE;
3226 }
3227 
3228 // class SvxLineItem ------------------------------------------------------
3229 
SvxLineItem(const sal_uInt16 nId)3230 SvxLineItem::SvxLineItem( const sal_uInt16 nId ) :
3231 
3232     SfxPoolItem ( nId ),
3233 
3234     pLine( NULL )
3235 {
3236 }
3237 
3238 // -----------------------------------------------------------------------
3239 
SvxLineItem(const SvxLineItem & rCpy)3240 SvxLineItem::SvxLineItem( const SvxLineItem& rCpy ) :
3241 
3242     SfxPoolItem ( rCpy )
3243 {
3244     pLine = rCpy.GetLine() ? new SvxBorderLine( *rCpy.GetLine() ) : 0;
3245 }
3246 
3247 
3248 // -----------------------------------------------------------------------
3249 
~SvxLineItem()3250 SvxLineItem::~SvxLineItem()
3251 {
3252     delete pLine;
3253 }
3254 
3255 // -----------------------------------------------------------------------
3256 
operator =(const SvxLineItem & rLine)3257 SvxLineItem& SvxLineItem::operator=( const SvxLineItem& rLine )
3258 {
3259     SetLine( rLine.GetLine() );
3260 
3261     return *this;
3262 }
3263 
3264 // -----------------------------------------------------------------------
3265 
operator ==(const SfxPoolItem & rAttr) const3266 int SvxLineItem::operator==( const SfxPoolItem& rAttr ) const
3267 {
3268     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
3269 
3270     return CmpBrdLn( pLine, ((SvxLineItem&)rAttr).GetLine() );
3271 }
3272 
3273 // -----------------------------------------------------------------------
3274 
Clone(SfxItemPool *) const3275 SfxPoolItem* SvxLineItem::Clone( SfxItemPool* ) const
3276 {
3277     return new SvxLineItem( *this );
3278 }
3279 
QueryValue(uno::Any & rVal,sal_uInt8 nMemId) const3280 sal_Bool SvxLineItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemId ) const
3281 {
3282     sal_Bool bConvert = 0!=(nMemId&CONVERT_TWIPS);
3283     nMemId &= ~CONVERT_TWIPS;
3284     if ( nMemId == 0 )
3285     {
3286         rVal <<= uno::makeAny( SvxBoxItem::SvxLineToLine(pLine, bConvert) );
3287         return sal_True;
3288     }
3289     else if ( pLine )
3290     {
3291         switch ( nMemId )
3292         {
3293             case MID_FG_COLOR:      rVal <<= sal_Int32(pLine->GetColor().GetColor()); break;
3294             case MID_OUTER_WIDTH:   rVal <<= sal_Int32(pLine->GetOutWidth());   break;
3295             case MID_INNER_WIDTH:   rVal <<= sal_Int32(pLine->GetInWidth( ));   break;
3296             case MID_DISTANCE:      rVal <<= sal_Int32(pLine->GetDistance());   break;
3297             default:
3298                 DBG_ERROR( "Wrong MemberId" );
3299                 return sal_False;
3300         }
3301     }
3302 
3303     return sal_True;
3304 }
3305 
3306 // -----------------------------------------------------------------------
3307 
PutValue(const uno::Any & rVal,sal_uInt8 nMemId)3308 sal_Bool SvxLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemId )
3309 {
3310     sal_Bool bConvert = 0!=(nMemId&CONVERT_TWIPS);
3311     nMemId &= ~CONVERT_TWIPS;
3312     sal_Int32 nVal = 0;
3313     if ( nMemId == 0 )
3314     {
3315         table::BorderLine aLine;
3316         if ( rVal >>= aLine )
3317         {
3318             if ( !pLine )
3319                 pLine = new SvxBorderLine;
3320             if( !SvxBoxItem::LineToSvxLine(aLine, *pLine, bConvert) )
3321                 DELETEZ( pLine );
3322             return sal_True;
3323         }
3324         return sal_False;
3325     }
3326     else if ( rVal >>= nVal )
3327     {
3328         if ( !pLine )
3329             pLine = new SvxBorderLine;
3330 
3331         switch ( nMemId )
3332         {
3333             case MID_FG_COLOR:      pLine->SetColor( Color(nVal) ); break;
3334             case MID_OUTER_WIDTH:   pLine->SetOutWidth((sal_uInt16)nVal);   break;
3335             case MID_INNER_WIDTH:   pLine->SetInWidth((sal_uInt16)nVal);   break;
3336             case MID_DISTANCE:      pLine->SetDistance((sal_uInt16)nVal);   break;
3337             default:
3338                 DBG_ERROR( "Wrong MemberId" );
3339                 return sal_False;
3340         }
3341 
3342         return sal_True;
3343     }
3344 
3345     return sal_False;
3346 }
3347 
3348 //------------------------------------------------------------------------
3349 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,XubString & rText,const IntlWrapper * pIntl) const3350 SfxItemPresentation SvxLineItem::GetPresentation
3351 (
3352     SfxItemPresentation ePres,
3353     SfxMapUnit          eCoreUnit,
3354     SfxMapUnit          ePresUnit,
3355     XubString&          rText, const IntlWrapper *pIntl
3356 )   const
3357 {
3358 #ifndef SVX_LIGHT
3359     rText.Erase();
3360 
3361     switch ( ePres )
3362     {
3363         case SFX_ITEM_PRESENTATION_NONE:
3364             return SFX_ITEM_PRESENTATION_NONE;
3365         case SFX_ITEM_PRESENTATION_NAMELESS:
3366         case SFX_ITEM_PRESENTATION_COMPLETE:
3367         {
3368             if ( pLine )
3369                 rText = pLine->GetValueString( eCoreUnit, ePresUnit, pIntl,
3370                     (SFX_ITEM_PRESENTATION_COMPLETE == ePres) );
3371             return ePres;
3372         }
3373         default: ;//prevent warning
3374     }
3375 #endif
3376     return SFX_ITEM_PRESENTATION_NONE;
3377 }
3378 
3379 // -----------------------------------------------------------------------
3380 
Store(SvStream & rStrm,sal_uInt16) const3381 SvStream& SvxLineItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
3382 {
3383     if( pLine )
3384     {
3385         rStrm << pLine->GetColor()
3386               << (short)pLine->GetOutWidth()
3387               << (short)pLine->GetInWidth()
3388               << (short)pLine->GetDistance();
3389     }
3390     else
3391         rStrm << Color() << (short)0 << (short)0 << (short)0;
3392     return rStrm;
3393 }
3394 
3395 // -----------------------------------------------------------------------
3396 
ScaleMetrics(long nMult,long nDiv)3397 int SvxLineItem::ScaleMetrics( long nMult, long nDiv )
3398 {
3399     if ( pLine ) pLine->ScaleMetrics( nMult, nDiv );
3400     return 1;
3401 }
3402 
3403 // -----------------------------------------------------------------------
3404 
HasMetrics() const3405 int SvxLineItem::HasMetrics() const
3406 {
3407     return 1;
3408 }
3409 
3410 // -----------------------------------------------------------------------
3411 
Create(SvStream & rStrm,sal_uInt16) const3412 SfxPoolItem* SvxLineItem::Create( SvStream& rStrm, sal_uInt16 ) const
3413 {
3414     SvxLineItem* _pLine = new SvxLineItem( Which() );
3415     short        nOutline, nInline, nDistance;
3416     Color        aColor;
3417 
3418     rStrm >> aColor >> nOutline >> nInline >> nDistance;
3419     if( nOutline )
3420     {
3421         SvxBorderLine aLine( &aColor, nOutline, nInline, nDistance );
3422         _pLine->SetLine( &aLine );
3423     }
3424     return _pLine;
3425 }
3426 
3427 // -----------------------------------------------------------------------
3428 
SetLine(const SvxBorderLine * pNew)3429 void SvxLineItem::SetLine( const SvxBorderLine* pNew )
3430 {
3431     delete pLine;
3432     pLine = pNew ? new SvxBorderLine( *pNew ) : 0;
3433 }
3434 
3435 #ifdef _MSC_VER
3436 #pragma optimize ( "", off )
3437 #endif
3438 
3439 // class SvxBrushItem ----------------------------------------------------
3440 
3441 #define LOAD_GRAPHIC    ((sal_uInt16)0x0001)
3442 #define LOAD_LINK       ((sal_uInt16)0x0002)
3443 #define LOAD_FILTER     ((sal_uInt16)0x0004)
3444 
3445 // class SvxBrushItem_Impl -----------------------------------------------
3446 
3447 class SvxBrushItem_Impl
3448 {
3449 public:
3450     GraphicObject*  pGraphicObject;
3451     sal_Int8        nGraphicTransparency; //contains a percentage value which is
3452                                           //copied to the GraphicObject when necessary
3453     Link            aDoneLink;
3454     SvStream*       pStream;
3455 
SvxBrushItem_Impl(GraphicObject * p)3456     SvxBrushItem_Impl( GraphicObject* p ) : pGraphicObject( p ), nGraphicTransparency(0), pStream(0) {}
3457 };
3458 
3459 // -----------------------------------------------------------------------
3460 
SetDoneLink(const Link & rLink)3461 void SvxBrushItem::SetDoneLink( const Link& rLink )
3462 {
3463     pImpl->aDoneLink = rLink;
3464 }
3465 
3466 // -----------------------------------------------------------------------
3467 
SvxBrushItem(sal_uInt16 _nWhich)3468 SvxBrushItem::SvxBrushItem( sal_uInt16 _nWhich ) :
3469 
3470     SfxPoolItem( _nWhich ),
3471 
3472     aColor      ( COL_TRANSPARENT ),
3473     pImpl       ( new SvxBrushItem_Impl( 0 ) ),
3474     pStrLink    ( NULL ),
3475     pStrFilter  ( NULL ),
3476     eGraphicPos ( GPOS_NONE ),
3477     bLoadAgain  ( sal_True )
3478 
3479 {
3480 }
3481 
3482 // -----------------------------------------------------------------------
3483 
SvxBrushItem(const Color & rColor,sal_uInt16 _nWhich)3484 SvxBrushItem::SvxBrushItem( const Color& rColor, sal_uInt16 _nWhich) :
3485 
3486     SfxPoolItem( _nWhich ),
3487 
3488     aColor      ( rColor ),
3489     pImpl       ( new SvxBrushItem_Impl( 0 ) ),
3490     pStrLink    ( NULL ),
3491     pStrFilter  ( NULL ),
3492     eGraphicPos ( GPOS_NONE ),
3493     bLoadAgain  ( sal_True )
3494 
3495 {
3496 }
3497 
3498 // -----------------------------------------------------------------------
3499 
SvxBrushItem(const Graphic & rGraphic,SvxGraphicPosition ePos,sal_uInt16 _nWhich)3500 SvxBrushItem::SvxBrushItem( const Graphic& rGraphic, SvxGraphicPosition ePos,
3501                             sal_uInt16 _nWhich ) :
3502 
3503     SfxPoolItem( _nWhich ),
3504 
3505     aColor      ( COL_TRANSPARENT ),
3506     pImpl       ( new SvxBrushItem_Impl( new GraphicObject( rGraphic ) ) ),
3507     pStrLink    ( NULL ),
3508     pStrFilter  ( NULL ),
3509     eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
3510     bLoadAgain  ( sal_True )
3511 
3512 {
3513     DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3514 }
3515 
3516 // -----------------------------------------------------------------------
3517 
SvxBrushItem(const GraphicObject & rGraphicObj,SvxGraphicPosition ePos,sal_uInt16 _nWhich)3518 SvxBrushItem::SvxBrushItem( const GraphicObject& rGraphicObj,
3519                             SvxGraphicPosition ePos, sal_uInt16 _nWhich ) :
3520 
3521     SfxPoolItem( _nWhich ),
3522 
3523     aColor      ( COL_TRANSPARENT ),
3524     pImpl       ( new SvxBrushItem_Impl( new GraphicObject( rGraphicObj ) ) ),
3525     pStrLink    ( NULL ),
3526     pStrFilter  ( NULL ),
3527     eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
3528     bLoadAgain  ( sal_True )
3529 
3530 {
3531     DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3532 }
3533 
3534 // -----------------------------------------------------------------------
3535 
SvxBrushItem(const String & rLink,const String & rFilter,SvxGraphicPosition ePos,sal_uInt16 _nWhich)3536 SvxBrushItem::SvxBrushItem(
3537     const String& rLink, const String& rFilter,
3538     SvxGraphicPosition ePos, sal_uInt16 _nWhich ) :
3539 
3540     SfxPoolItem( _nWhich ),
3541 
3542     aColor      ( COL_TRANSPARENT ),
3543     pImpl       ( new SvxBrushItem_Impl( NULL ) ),
3544     pStrLink    ( new String( rLink ) ),
3545     pStrFilter  ( new String( rFilter ) ),
3546     eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
3547     bLoadAgain  ( sal_True )
3548 
3549 {
3550     DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3551 }
3552 
3553 // -----------------------------------------------------------------------
3554 
SvxBrushItem(SvStream & rStream,sal_uInt16 nVersion,sal_uInt16 _nWhich)3555 SvxBrushItem::SvxBrushItem( SvStream& rStream, sal_uInt16 nVersion,
3556                             sal_uInt16 _nWhich ) :
3557 
3558     SfxPoolItem( _nWhich ),
3559 
3560     aColor      ( COL_TRANSPARENT ),
3561     pImpl       ( new SvxBrushItem_Impl( NULL ) ),
3562     pStrLink    ( NULL ),
3563     pStrFilter  ( NULL ),
3564     eGraphicPos ( GPOS_NONE )
3565 
3566 {
3567     sal_Bool bTrans;
3568     Color aTempColor;
3569     Color aTempFillColor;
3570     sal_Int8 nStyle;
3571 
3572     rStream >> bTrans;
3573     rStream >> aTempColor;
3574     rStream >> aTempFillColor;
3575     rStream >> nStyle;
3576 
3577     switch ( nStyle )
3578     {
3579         case 8://BRUSH_25:
3580         {
3581             sal_uInt32  nRed    = aTempColor.GetRed();
3582             sal_uInt32  nGreen  = aTempColor.GetGreen();
3583             sal_uInt32  nBlue   = aTempColor.GetBlue();
3584             nRed   += (sal_uInt32)(aTempFillColor.GetRed())*2;
3585             nGreen += (sal_uInt32)(aTempFillColor.GetGreen())*2;
3586             nBlue  += (sal_uInt32)(aTempFillColor.GetBlue())*2;
3587             aColor = Color( (sal_Int8)(nRed/3), (sal_Int8)(nGreen/3), (sal_Int8)(nBlue/3) );
3588         }
3589         break;
3590 
3591         case 9://BRUSH_50:
3592         {
3593             sal_uInt32  nRed    = aTempColor.GetRed();
3594             sal_uInt32  nGreen  = aTempColor.GetGreen();
3595             sal_uInt32  nBlue   = aTempColor.GetBlue();
3596             nRed   += (sal_uInt32)(aTempFillColor.GetRed());
3597             nGreen += (sal_uInt32)(aTempFillColor.GetGreen());
3598             nBlue  += (sal_uInt32)(aTempFillColor.GetBlue());
3599             aColor = Color( (sal_Int8)(nRed/2), (sal_Int8)(nGreen/2), (sal_Int8)(nBlue/2) );
3600         }
3601         break;
3602 
3603         case 10://BRUSH_75:
3604         {
3605             sal_uInt32  nRed    = aTempColor.GetRed()*2;
3606             sal_uInt32  nGreen  = aTempColor.GetGreen()*2;
3607             sal_uInt32  nBlue   = aTempColor.GetBlue()*2;
3608             nRed   += (sal_uInt32)(aTempFillColor.GetRed());
3609             nGreen += (sal_uInt32)(aTempFillColor.GetGreen());
3610             nBlue  += (sal_uInt32)(aTempFillColor.GetBlue());
3611             aColor = Color( (sal_Int8)(nRed/3), (sal_Int8)(nGreen/3), (sal_Int8)(nBlue/3) );
3612         }
3613         break;
3614 
3615         case 0://BRUSH_NULL:
3616             aColor = Color( COL_TRANSPARENT );
3617         break;
3618 
3619         default:
3620             aColor = aTempColor;
3621     }
3622 
3623     if ( nVersion >= BRUSH_GRAPHIC_VERSION )
3624     {
3625         sal_uInt16 nDoLoad = 0;
3626         sal_Int8 nPos;
3627 
3628         rStream >> nDoLoad;
3629 
3630         if ( nDoLoad & LOAD_GRAPHIC )
3631         {
3632             Graphic aGraphic;
3633 
3634             rStream >> aGraphic;
3635             pImpl->pGraphicObject = new GraphicObject( aGraphic );
3636 
3637             if( SVSTREAM_FILEFORMAT_ERROR == rStream.GetError() )
3638             {
3639                 rStream.ResetError();
3640                 rStream.SetError( ERRCODE_SVX_GRAPHIC_WRONG_FILEFORMAT|
3641                                   ERRCODE_WARNING_MASK  );
3642             }
3643         }
3644 
3645         if ( nDoLoad & LOAD_LINK )
3646         {
3647             String aRel;
3648             // UNICODE: rStream >> aRel;
3649             rStream.ReadByteString(aRel);
3650 
3651             // TODO/MBA: how can we get a BaseURL here?!
3652             DBG_ERROR("No BaseURL!");
3653             String aAbs = INetURLObject::GetAbsURL( String(), aRel );
3654             DBG_ASSERT( aAbs.Len(), "Invalid URL!" );
3655             pStrLink = new String( aAbs );
3656         }
3657 
3658         if ( nDoLoad & LOAD_FILTER )
3659         {
3660             pStrFilter = new String;
3661             // UNICODE: rStream >> *pStrFilter;
3662             rStream.ReadByteString(*pStrFilter);
3663         }
3664 
3665         rStream >> nPos;
3666 
3667         eGraphicPos = (SvxGraphicPosition)nPos;
3668     }
3669 }
3670 
3671 // -----------------------------------------------------------------------
3672 
SvxBrushItem(const SvxBrushItem & rItem)3673 SvxBrushItem::SvxBrushItem( const SvxBrushItem& rItem ) :
3674 
3675     SfxPoolItem( rItem.Which() ),
3676 
3677     pImpl       ( new SvxBrushItem_Impl( NULL ) ),
3678     pStrLink    ( NULL ),
3679     pStrFilter  ( NULL ),
3680     eGraphicPos ( GPOS_NONE ),
3681     bLoadAgain  ( sal_True )
3682 
3683 {
3684     *this = rItem;
3685 }
3686 
3687 // -----------------------------------------------------------------------
3688 
~SvxBrushItem()3689 SvxBrushItem::~SvxBrushItem()
3690 {
3691     delete pImpl->pGraphicObject;
3692     delete pImpl;
3693     delete pStrLink;
3694     delete pStrFilter;
3695 }
3696 
3697 // -----------------------------------------------------------------------
3698 
GetVersion(sal_uInt16) const3699 sal_uInt16 SvxBrushItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const
3700 {
3701     return BRUSH_GRAPHIC_VERSION;
3702 }
3703 
3704 // -----------------------------------------------------------------------
lcl_PercentToTransparency(long nPercent)3705 inline sal_Int8 lcl_PercentToTransparency(long nPercent)
3706 {
3707     //0xff must not be returned!
3708     return sal_Int8(nPercent ? (50 + 0xfe * nPercent) / 100 : 0);
3709 }
lcl_TransparencyToPercent(sal_Int32 nTrans)3710 inline sal_Int8 lcl_TransparencyToPercent(sal_Int32 nTrans)
3711 {
3712     return (sal_Int8)((nTrans * 100 + 127) / 254);
3713 }
3714 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const3715 sal_Bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
3716 {
3717 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3718     nMemberId &= ~CONVERT_TWIPS;
3719     switch( nMemberId)
3720     {
3721         case MID_BACK_COLOR:
3722             rVal <<= (sal_Int32)( aColor.GetColor() );
3723         break;
3724         case MID_BACK_COLOR_R_G_B:
3725             rVal <<= (sal_Int32)( aColor.GetRGBColor() );
3726         break;
3727         case MID_BACK_COLOR_TRANSPARENCY:
3728             rVal <<= lcl_TransparencyToPercent(aColor.GetTransparency());
3729         break;
3730         case MID_GRAPHIC_POSITION:
3731             rVal <<= (style::GraphicLocation)(sal_Int16)eGraphicPos;
3732         break;
3733 
3734         case MID_GRAPHIC:
3735             DBG_ERRORFILE( "not implemented" );
3736         break;
3737 
3738         case MID_GRAPHIC_TRANSPARENT:
3739             rVal = Bool2Any( aColor.GetTransparency() == 0xff );
3740         break;
3741 
3742         case MID_GRAPHIC_URL:
3743         {
3744             OUString sLink;
3745             if ( pStrLink )
3746                 sLink = *pStrLink;
3747             else if( pImpl->pGraphicObject )
3748             {
3749                 OUString sPrefix(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
3750                 String sId( pImpl->pGraphicObject->GetUniqueID(),
3751                             RTL_TEXTENCODING_ASCII_US );
3752                 sLink = sPrefix;
3753                 sLink += OUString(sId);
3754             }
3755             rVal <<= sLink;
3756         }
3757         break;
3758 
3759         case MID_GRAPHIC_FILTER:
3760         {
3761             OUString sFilter;
3762             if ( pStrFilter )
3763                 sFilter = *pStrFilter;
3764             rVal <<= sFilter;
3765         }
3766         break;
3767         case MID_GRAPHIC_TRANSPARENCY :
3768             rVal <<= pImpl->nGraphicTransparency;
3769         break;
3770     }
3771 
3772     return sal_True;
3773 }
3774 
3775 // -----------------------------------------------------------------------
3776 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)3777 sal_Bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
3778 {
3779 //    sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3780     nMemberId &= ~CONVERT_TWIPS;
3781     switch( nMemberId)
3782     {
3783         case MID_BACK_COLOR:
3784         case MID_BACK_COLOR_R_G_B:
3785         {
3786             sal_Int32 nCol = 0;
3787             if ( !( rVal >>= nCol ) )
3788                 return sal_False;
3789             if(MID_BACK_COLOR_R_G_B == nMemberId)
3790             {
3791                 nCol = COLORDATA_RGB( nCol );
3792                 nCol += aColor.GetColor() & 0xff000000;
3793             }
3794             aColor = Color( nCol );
3795         }
3796         break;
3797         case MID_BACK_COLOR_TRANSPARENCY:
3798         {
3799             sal_Int32 nTrans = 0;
3800             if ( !( rVal >>= nTrans ) || nTrans < 0 || nTrans > 100 )
3801                 return sal_False;
3802             aColor.SetTransparency(lcl_PercentToTransparency(nTrans));
3803         }
3804         break;
3805 
3806         case MID_GRAPHIC_POSITION:
3807         {
3808             style::GraphicLocation eLocation;
3809             if ( !( rVal>>=eLocation ) )
3810             {
3811                 sal_Int32 nValue = 0;
3812                 if ( !( rVal >>= nValue ) )
3813                     return sal_False;
3814                 eLocation = (style::GraphicLocation)nValue;
3815             }
3816             SetGraphicPos( (SvxGraphicPosition)(sal_uInt16)eLocation );
3817         }
3818         break;
3819 
3820         case MID_GRAPHIC:
3821             DBG_ERRORFILE( "not implemented" );
3822         break;
3823 
3824         case MID_GRAPHIC_TRANSPARENT:
3825             aColor.SetTransparency( Any2Bool( rVal ) ? 0xff : 0 );
3826         break;
3827 
3828         case MID_GRAPHIC_URL:
3829         {
3830             if ( rVal.getValueType() == ::getCppuType( (OUString*)0 ) )
3831             {
3832                 OUString sLink;
3833                 rVal >>= sLink;
3834                 if( 0 == sLink.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX,
3835                                   sizeof(UNO_NAME_GRAPHOBJ_URLPKGPREFIX)-1 ) )
3836                 {
3837                     DBG_ERROR( "package urls aren't implemented" );
3838                 }
3839                 else if( 0 == sLink.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX,
3840                                    sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX)-1 ) )
3841                 {
3842                     DELETEZ( pStrLink );
3843                     String sTmp( sLink );
3844                     ByteString sId( sTmp.Copy(
3845                                         sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX)-1),
3846                                     RTL_TEXTENCODING_ASCII_US );
3847                     GraphicObject *pOldGrfObj = pImpl->pGraphicObject;
3848                     pImpl->pGraphicObject = new GraphicObject( sId );
3849                     ApplyGraphicTransparency_Impl();
3850                     delete pOldGrfObj;
3851                 }
3852                 else
3853                 {
3854                     SetGraphicLink(sLink);
3855                 }
3856                 if ( sLink.getLength() && eGraphicPos == GPOS_NONE )
3857                     eGraphicPos = GPOS_MM;
3858                 else if( !sLink.getLength() )
3859                     eGraphicPos = GPOS_NONE;
3860             }
3861         }
3862         break;
3863 
3864         case MID_GRAPHIC_FILTER:
3865         {
3866             if( rVal.getValueType() == ::getCppuType( (OUString*)0 ) )
3867             {
3868                 OUString sLink;
3869                 rVal >>= sLink;
3870                 SetGraphicFilter( sLink );
3871             }
3872         }
3873         break;
3874         case MID_GRAPHIC_TRANSPARENCY :
3875         {
3876             sal_Int32 nTmp = 0;
3877             rVal >>= nTmp;
3878             if(nTmp >= 0 && nTmp <= 100)
3879             {
3880                 pImpl->nGraphicTransparency = sal_Int8(nTmp);
3881                 if(pImpl->pGraphicObject)
3882                     ApplyGraphicTransparency_Impl();
3883             }
3884         }
3885         break;
3886     }
3887 
3888     return sal_True;
3889 }
3890 
3891 // -----------------------------------------------------------------------
3892 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const3893 SfxItemPresentation SvxBrushItem::GetPresentation
3894 (
3895     SfxItemPresentation ePres,
3896     SfxMapUnit          /*eCoreUnit*/,
3897     SfxMapUnit          /*ePresUnit*/,
3898     XubString&          rText, const IntlWrapper *
3899     ) const
3900 {
3901     switch ( ePres )
3902     {
3903         case SFX_ITEM_PRESENTATION_NONE:
3904             rText.Erase();
3905             return ePres;
3906 
3907         case SFX_ITEM_PRESENTATION_NAMELESS:
3908         case SFX_ITEM_PRESENTATION_COMPLETE:
3909         {
3910             if ( GPOS_NONE  == eGraphicPos )
3911             {
3912                 rText = ::GetColorString( aColor );
3913                 rText += cpDelim;
3914                 sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
3915 
3916                 if ( aColor.GetTransparency() )
3917                     nId = RID_SVXITEMS_TRANSPARENT_TRUE;
3918                 rText += EE_RESSTR(nId);
3919             }
3920             else
3921             {
3922                 rText = EE_RESSTR(RID_SVXITEMS_GRAPHIC);
3923             }
3924 
3925             return ePres;
3926         }
3927         default: ;//prevent warning
3928     }
3929 
3930     return SFX_ITEM_PRESENTATION_NONE;
3931 }
3932 
3933 // -----------------------------------------------------------------------
3934 
operator =(const SvxBrushItem & rItem)3935 SvxBrushItem& SvxBrushItem::operator=( const SvxBrushItem& rItem )
3936 {
3937     aColor = rItem.aColor;
3938     eGraphicPos = rItem.eGraphicPos;
3939 
3940     DELETEZ( pImpl->pGraphicObject );
3941     DELETEZ( pStrLink );
3942     DELETEZ( pStrFilter );
3943 
3944     if ( GPOS_NONE != eGraphicPos )
3945     {
3946         if ( rItem.pStrLink )
3947             pStrLink = new String( *rItem.pStrLink );
3948         if ( rItem.pStrFilter )
3949             pStrFilter = new String( *rItem.pStrFilter );
3950         if ( rItem.pImpl->pGraphicObject )
3951         {
3952             pImpl->pGraphicObject = new GraphicObject( *rItem.pImpl->pGraphicObject );
3953         }
3954     }
3955     pImpl->nGraphicTransparency = rItem.pImpl->nGraphicTransparency;
3956     return *this;
3957 }
3958 
3959 // -----------------------------------------------------------------------
3960 
operator ==(const SfxPoolItem & rAttr) const3961 int SvxBrushItem::operator==( const SfxPoolItem& rAttr ) const
3962 {
3963     DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
3964 
3965     SvxBrushItem& rCmp = (SvxBrushItem&)rAttr;
3966     sal_Bool bEqual = ( aColor == rCmp.aColor && eGraphicPos == rCmp.eGraphicPos &&
3967         pImpl->nGraphicTransparency == rCmp.pImpl->nGraphicTransparency);
3968 
3969     if ( bEqual )
3970     {
3971         if ( GPOS_NONE != eGraphicPos )
3972         {
3973             if ( !rCmp.pStrLink )
3974                 bEqual = !pStrLink;
3975             else
3976                 bEqual = pStrLink && ( *pStrLink == *rCmp.pStrLink );
3977 
3978             if ( bEqual )
3979             {
3980                 if ( !rCmp.pStrFilter )
3981                     bEqual = !pStrFilter;
3982                 else
3983                     bEqual = pStrFilter && ( *pStrFilter == *rCmp.pStrFilter );
3984             }
3985 
3986             if ( bEqual && !rCmp.pStrLink )
3987             {
3988                 if ( !rCmp.pImpl->pGraphicObject )
3989                     bEqual = !pImpl->pGraphicObject;
3990                 else
3991                     bEqual = pImpl->pGraphicObject &&
3992                              ( *pImpl->pGraphicObject == *rCmp.pImpl->pGraphicObject );
3993             }
3994         }
3995     }
3996 
3997     return bEqual;
3998 }
3999 
4000 // -----------------------------------------------------------------------
4001 
Clone(SfxItemPool *) const4002 SfxPoolItem* SvxBrushItem::Clone( SfxItemPool* ) const
4003 {
4004     return new SvxBrushItem( *this );
4005 }
4006 
4007 // -----------------------------------------------------------------------
4008 
Create(SvStream & rStream,sal_uInt16 nVersion) const4009 SfxPoolItem* SvxBrushItem::Create( SvStream& rStream, sal_uInt16 nVersion ) const
4010 {
4011     return new SvxBrushItem( rStream, nVersion, Which() );
4012 }
4013 
4014 // -----------------------------------------------------------------------
4015 
Store(SvStream & rStream,sal_uInt16) const4016 SvStream& SvxBrushItem::Store( SvStream& rStream , sal_uInt16 /*nItemVersion*/ ) const
4017 {
4018     rStream << (sal_Bool)sal_False;
4019     rStream << aColor;
4020     rStream << aColor;
4021     rStream << (sal_Int8)(aColor.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
4022 
4023     sal_uInt16 nDoLoad = 0;
4024 
4025     if ( pImpl->pGraphicObject && !pStrLink )
4026         nDoLoad |= LOAD_GRAPHIC;
4027     if ( pStrLink )
4028         nDoLoad |= LOAD_LINK;
4029     if ( pStrFilter )
4030         nDoLoad |= LOAD_FILTER;
4031     rStream << nDoLoad;
4032 
4033     if ( pImpl->pGraphicObject && !pStrLink )
4034         rStream << pImpl->pGraphicObject->GetGraphic();
4035     if ( pStrLink )
4036     {
4037         DBG_ERROR("No BaseURL!");
4038         // TODO/MBA: how to get a BaseURL?!
4039         String aRel = INetURLObject::GetRelURL( String(), *pStrLink );
4040         // UNICODE: rStream << aRel;
4041         rStream.WriteByteString(aRel);
4042     }
4043     if ( pStrFilter )
4044     {
4045         // UNICODE: rStream << *pStrFilter;
4046         rStream.WriteByteString(*pStrFilter);
4047     }
4048     rStream << (sal_Int8)eGraphicPos;
4049     return rStream;
4050 }
4051 
4052 // -----------------------------------------------------------------------
4053 // const wegcasten, da const als logisches const zu verstehen ist
4054 // wenn GetGraphic() gerufen wird, soll sich das Item darum kuemmern,
4055 // eine gelinkte Grafik zu holen.
4056 // -----------------------------------------------------------------------
4057 
PurgeGraphic() const4058 void SvxBrushItem::PurgeGraphic() const
4059 {
4060     PurgeMedium();
4061     DELETEZ( pImpl->pGraphicObject );
4062     ((SvxBrushItem*)this)->bLoadAgain = sal_True;
4063 }
4064 
4065 // -----------------------------------------------------------------------
4066 
PurgeMedium() const4067 void SvxBrushItem::PurgeMedium() const
4068 {
4069     DELETEZ( pImpl->pStream );
4070 }
4071 
4072 // -----------------------------------------------------------------------
GetGraphicObject() const4073 const GraphicObject* SvxBrushItem::GetGraphicObject() const
4074 {
4075     if ( bLoadAgain && pStrLink && !pImpl->pGraphicObject )
4076     // wenn Grafik schon geladen, als Cache benutzen
4077     {
4078         //JP 29.6.2001: only with "valid" names - empty names now allowed
4079         if( pStrLink->Len() )
4080         {
4081             // currently we don't have asynchronous processing
4082 /*          if( pImpl->aDoneLink.IsSet() )
4083             {
4084                 // Auf besonderen Wunsch des Writers wird der synchrone und der
4085                 // asynchrone Fall was die Benachrichtigung angeht unterschiedlich
4086                 // behandelt. Der Callback erfolgt nur bei asynchronem Eintreffen
4087                 // der Daten
4088 
4089                 Link aTmp = pImpl->aDoneLink;
4090                 pImpl->aDoneLink = Link();
4091                 pImpl->xMedium->DownLoad(
4092                     STATIC_LINK( this, SvxBrushItem, DoneHdl_Impl ) );
4093                 pImpl->aDoneLink = aTmp;
4094             } */
4095 
4096             // The link is document content, so the shared policy decides (see
4097             // svtools/linkpolicy.hxx). A refusal is final for this item: no stream is
4098             // opened, and no retry.
4099             if( !::svt::linkpolicy::mayLoadDocumentReference( *pStrLink ) )
4100             {
4101                 const_cast < SvxBrushItem*> (this)->bLoadAgain = sal_False;
4102                 return pImpl->pGraphicObject;
4103             }
4104 
4105             pImpl->pStream = utl::UcbStreamHelper::CreateStream( *pStrLink, STREAM_STD_READ );
4106             if( pImpl->pStream && !pImpl->pStream->GetError() )
4107             {
4108                 Graphic aGraphic;
4109                 int nRes;
4110                 pImpl->pStream->Seek( STREAM_SEEK_TO_BEGIN );
4111                 nRes = GraphicFilter::GetGraphicFilter()->
4112                     ImportGraphic( aGraphic, *pStrLink, *pImpl->pStream,
4113                                    GRFILTER_FORMAT_DONTKNOW, NULL, GRFILTER_I_FLAGS_DONT_SET_LOGSIZE_FOR_JPEG );
4114 
4115                 if( nRes != GRFILTER_OK )
4116                 {
4117                     const_cast < SvxBrushItem*> (this)->bLoadAgain = sal_False;
4118                 }
4119                 else
4120                 {
4121                     pImpl->pGraphicObject = new GraphicObject;
4122                     pImpl->pGraphicObject->SetGraphic( aGraphic );
4123                     const_cast < SvxBrushItem*> (this)->ApplyGraphicTransparency_Impl();
4124                 }
4125             }
4126             else
4127             {
4128                 const_cast < SvxBrushItem*> (this)->bLoadAgain = sal_False;
4129             }
4130 
4131             // currently we don't have asynchronous processing
4132 //          pThis->pImpl->aDoneLink.Call( pThis );
4133         }
4134     }
4135 
4136     return pImpl->pGraphicObject;
4137 }
4138 
4139 // -----------------------------------------------------------------------
4140 //UUUU
getGraphicTransparency() const4141 sal_Int8 SvxBrushItem::getGraphicTransparency() const
4142 {
4143     return pImpl->nGraphicTransparency;
4144 }
4145 
4146 // -----------------------------------------------------------------------
4147 //UUUU
setGraphicTransparency(sal_Int8 nNew)4148 void SvxBrushItem::setGraphicTransparency(sal_Int8 nNew)
4149 {
4150     if(nNew != pImpl->nGraphicTransparency)
4151     {
4152         pImpl->nGraphicTransparency = nNew;
4153         ApplyGraphicTransparency_Impl();
4154     }
4155 }
4156 
4157 // -----------------------------------------------------------------------
4158 
GetGraphic() const4159 const Graphic* SvxBrushItem::GetGraphic() const
4160 {
4161     const GraphicObject* pGrafObj = GetGraphicObject();
4162     return( pGrafObj ? &( pGrafObj->GetGraphic() ) : NULL );
4163 }
4164 
4165 // -----------------------------------------------------------------------
4166 
SetGraphicPos(SvxGraphicPosition eNew)4167 void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew )
4168 {
4169     eGraphicPos = eNew;
4170 
4171     if ( GPOS_NONE == eGraphicPos )
4172     {
4173         DELETEZ( pImpl->pGraphicObject );
4174         DELETEZ( pStrLink );
4175         DELETEZ( pStrFilter );
4176     }
4177     else
4178     {
4179         if ( !pImpl->pGraphicObject && !pStrLink )
4180         {
4181             pImpl->pGraphicObject = new GraphicObject; // dummy anlegen
4182         }
4183     }
4184 }
4185 
4186 // -----------------------------------------------------------------------
4187 
SetGraphic(const Graphic & rNew)4188 void SvxBrushItem::SetGraphic( const Graphic& rNew )
4189 {
4190     if ( !pStrLink )
4191     {
4192         if ( pImpl->pGraphicObject )
4193             pImpl->pGraphicObject->SetGraphic( rNew );
4194         else
4195             pImpl->pGraphicObject = new GraphicObject( rNew );
4196 
4197         ApplyGraphicTransparency_Impl();
4198 
4199         if ( GPOS_NONE == eGraphicPos )
4200             eGraphicPos = GPOS_MM; // None waere Brush, also Default: Mitte
4201     }
4202     else
4203     {
4204         DBG_ERROR( "SetGraphic() on linked graphic! :-/" );
4205     }
4206 }
4207 
4208 // -----------------------------------------------------------------------
4209 
SetGraphicObject(const GraphicObject & rNewObj)4210 void SvxBrushItem::SetGraphicObject( const GraphicObject& rNewObj )
4211 {
4212     if ( !pStrLink )
4213     {
4214         if ( pImpl->pGraphicObject )
4215             *pImpl->pGraphicObject = rNewObj;
4216         else
4217             pImpl->pGraphicObject = new GraphicObject( rNewObj );
4218 
4219         ApplyGraphicTransparency_Impl();
4220 
4221         if ( GPOS_NONE == eGraphicPos )
4222             eGraphicPos = GPOS_MM; // None waere Brush, also Default: Mitte
4223     }
4224     else
4225     {
4226         DBG_ERROR( "SetGraphic() on linked graphic! :-/" );
4227     }
4228 }
4229 
4230 // -----------------------------------------------------------------------
4231 
SetGraphicLink(const String & rNew)4232 void SvxBrushItem::SetGraphicLink( const String& rNew )
4233 {
4234     if ( !rNew.Len() )
4235         DELETEZ( pStrLink );
4236     else
4237     {
4238         if ( pStrLink )
4239             *pStrLink = rNew;
4240         else
4241             pStrLink = new String( rNew );
4242 
4243         DELETEZ( pImpl->pGraphicObject );
4244     }
4245 }
4246 
4247 // -----------------------------------------------------------------------
4248 
SetGraphicFilter(const String & rNew)4249 void SvxBrushItem::SetGraphicFilter( const String& rNew )
4250 {
4251     if ( !rNew.Len() )
4252         DELETEZ( pStrFilter );
4253     else
4254     {
4255         if ( pStrFilter )
4256             *pStrFilter = rNew;
4257         else
4258             pStrFilter = new String( rNew );
4259     }
4260 }
4261 
4262 //static
WallpaperStyle2GraphicPos(WallpaperStyle eStyle)4263 SvxGraphicPosition SvxBrushItem::WallpaperStyle2GraphicPos( WallpaperStyle eStyle )
4264 {
4265     SvxGraphicPosition eResult;
4266     // der Switch ist nicht der schnellste, dafuer aber am sichersten
4267     switch( eStyle )
4268     {
4269         case WALLPAPER_NULL: eResult = GPOS_NONE; break;
4270         case WALLPAPER_TILE: eResult = GPOS_TILED; break;
4271         case WALLPAPER_CENTER: eResult = GPOS_MM; break;
4272         case WALLPAPER_SCALE: eResult = GPOS_AREA; break;
4273         case WALLPAPER_TOPLEFT: eResult = GPOS_LT; break;
4274         case WALLPAPER_TOP: eResult = GPOS_MT; break;
4275         case WALLPAPER_TOPRIGHT: eResult = GPOS_RT; break;
4276         case WALLPAPER_LEFT: eResult = GPOS_LM; break;
4277         case WALLPAPER_RIGHT: eResult = GPOS_RM; break;
4278         case WALLPAPER_BOTTOMLEFT: eResult = GPOS_LB; break;
4279         case WALLPAPER_BOTTOM: eResult = GPOS_MB; break;
4280         case WALLPAPER_BOTTOMRIGHT: eResult = GPOS_RB; break;
4281         default: eResult = GPOS_NONE;
4282     }
4283     return eResult;
4284 };
4285 
4286 //static
GraphicPos2WallpaperStyle(SvxGraphicPosition ePos)4287 WallpaperStyle SvxBrushItem::GraphicPos2WallpaperStyle( SvxGraphicPosition ePos )
4288 {
4289     WallpaperStyle eResult;
4290     switch( ePos )
4291     {
4292         case GPOS_NONE: eResult = WALLPAPER_NULL; break;
4293         case GPOS_TILED: eResult = WALLPAPER_TILE; break;
4294         case GPOS_MM: eResult = WALLPAPER_CENTER; break;
4295         case GPOS_AREA: eResult = WALLPAPER_SCALE; break;
4296         case GPOS_LT: eResult = WALLPAPER_TOPLEFT; break;
4297         case GPOS_MT: eResult = WALLPAPER_TOP; break;
4298         case GPOS_RT: eResult = WALLPAPER_TOPRIGHT; break;
4299         case GPOS_LM: eResult = WALLPAPER_LEFT; break;
4300         case GPOS_RM: eResult = WALLPAPER_RIGHT; break;
4301         case GPOS_LB: eResult = WALLPAPER_BOTTOMLEFT; break;
4302         case GPOS_MB: eResult = WALLPAPER_BOTTOM; break;
4303         case GPOS_RB: eResult = WALLPAPER_BOTTOMRIGHT; break;
4304         default: eResult = WALLPAPER_NULL;
4305     }
4306     return eResult;
4307 }
4308 
4309 
SvxBrushItem(const CntWallpaperItem & rItem,sal_uInt16 _nWhich)4310 SvxBrushItem::SvxBrushItem( const CntWallpaperItem& rItem, sal_uInt16 _nWhich ) :
4311     SfxPoolItem( _nWhich ),
4312     pImpl( new SvxBrushItem_Impl( 0 ) ),
4313     pStrLink(0),
4314     pStrFilter(0),
4315     bLoadAgain( sal_True )
4316 {
4317     aColor = rItem.GetColor();
4318 
4319     if( rItem.GetBitmapURL().Len() )
4320     {
4321         pStrLink    = new String( rItem.GetBitmapURL() );
4322         SetGraphicPos( WallpaperStyle2GraphicPos((WallpaperStyle)rItem.GetStyle() ) );
4323     }
4324 }
4325 
CreateCntWallpaperItem() const4326 CntWallpaperItem* SvxBrushItem::CreateCntWallpaperItem() const
4327 {
4328     CntWallpaperItem* pItem = new CntWallpaperItem( 0 );
4329     pItem->SetColor( aColor.GetColor() );
4330     pItem->SetStyle( (sal_uInt16)GraphicPos2WallpaperStyle( GetGraphicPos() ) );
4331     sal_Bool bLink = (pStrLink != 0);
4332     if( bLink )
4333     {
4334         String aURL = *pStrLink;
4335         pItem->SetBitmapURL( aURL );
4336     }
4337     if( pImpl->pGraphicObject )
4338     {
4339         DBG_ERRORFILE( "Don't know what to do with a graphic" );
4340     }
4341 //      pItem->SetGraphic( *pImpl->pGraphic, bLink );
4342 
4343     return pItem;
4344 }
4345 
4346 #ifdef _MSC_VER
4347 #pragma optimize ( "", on )
4348 #endif
4349 /* -----------------------------16.08.2002 09:18------------------------------
4350 
4351  ---------------------------------------------------------------------------*/
ApplyGraphicTransparency_Impl()4352 void  SvxBrushItem::ApplyGraphicTransparency_Impl()
4353 {
4354     DBG_ASSERT(pImpl->pGraphicObject, "no GraphicObject available" );
4355     if(pImpl->pGraphicObject)
4356     {
4357         GraphicAttr aAttr(pImpl->pGraphicObject->GetAttr());
4358         aAttr.SetTransparency(lcl_PercentToTransparency(
4359                             pImpl->nGraphicTransparency));
4360         pImpl->pGraphicObject->SetAttr(aAttr);
4361     }
4362 }
4363 // class SvxFrameDirectionItem ----------------------------------------------
4364 
SvxFrameDirectionItem(sal_uInt16 _nWhich)4365 SvxFrameDirectionItem::SvxFrameDirectionItem( sal_uInt16 _nWhich )
4366     : SfxUInt16Item( _nWhich, (sal_uInt16)FRMDIR_HORI_LEFT_TOP )
4367 {
4368 }
4369 
SvxFrameDirectionItem(SvxFrameDirection nValue,sal_uInt16 _nWhich)4370 SvxFrameDirectionItem::SvxFrameDirectionItem( SvxFrameDirection nValue ,
4371                                             sal_uInt16 _nWhich )
4372     : SfxUInt16Item( _nWhich, (sal_uInt16)nValue )
4373 {
4374 }
4375 
~SvxFrameDirectionItem()4376 SvxFrameDirectionItem::~SvxFrameDirectionItem()
4377 {
4378 }
4379 
operator ==(const SfxPoolItem & rCmp) const4380 int SvxFrameDirectionItem::operator==( const SfxPoolItem& rCmp ) const
4381 {
4382     DBG_ASSERT( SfxPoolItem::operator==(rCmp), "unequal types" );
4383 
4384     return GetValue() == ((SvxFrameDirectionItem&)rCmp).GetValue();
4385 }
4386 
Clone(SfxItemPool *) const4387 SfxPoolItem* SvxFrameDirectionItem::Clone( SfxItemPool * ) const
4388 {
4389     return new SvxFrameDirectionItem( *this );
4390 }
4391 
Create(SvStream & rStrm,sal_uInt16) const4392 SfxPoolItem* SvxFrameDirectionItem::Create( SvStream & rStrm, sal_uInt16 /*nVer*/ ) const
4393 {
4394     sal_uInt16 nValue;
4395     rStrm >> nValue;
4396     return new SvxFrameDirectionItem( (SvxFrameDirection)nValue, Which() );
4397 }
4398 
Store(SvStream & rStrm,sal_uInt16) const4399 SvStream& SvxFrameDirectionItem::Store( SvStream & rStrm, sal_uInt16 /*nIVer*/ ) const
4400 {
4401     sal_uInt16 nValue = GetValue();
4402     rStrm << nValue;
4403     return rStrm;
4404 }
4405 
GetVersion(sal_uInt16 nFVer) const4406 sal_uInt16 SvxFrameDirectionItem::GetVersion( sal_uInt16 nFVer ) const
4407 {
4408     return SOFFICE_FILEFORMAT_50 > nFVer ? USHRT_MAX : 0;
4409 }
4410 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const4411 SfxItemPresentation SvxFrameDirectionItem::GetPresentation(
4412     SfxItemPresentation ePres,
4413     SfxMapUnit          /*eCoreUnit*/,
4414     SfxMapUnit          /*ePresUnit*/,
4415     XubString&          rText, const IntlWrapper *) const
4416 {
4417     SfxItemPresentation eRet = ePres;
4418     switch( ePres )
4419     {
4420     case SFX_ITEM_PRESENTATION_NONE:
4421         rText.Erase();
4422         break;
4423 
4424     case SFX_ITEM_PRESENTATION_NAMELESS:
4425     case SFX_ITEM_PRESENTATION_COMPLETE:
4426         rText = EE_RESSTR( RID_SVXITEMS_FRMDIR_BEGIN + GetValue() );
4427         break;
4428 
4429     default:
4430         eRet = SFX_ITEM_PRESENTATION_NONE;
4431     }
4432     return eRet;
4433 }
4434 
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)4435 sal_Bool SvxFrameDirectionItem::PutValue( const com::sun::star::uno::Any& rVal,
4436                                             sal_uInt8 )
4437 {
4438     sal_Int16 nVal = sal_Int16();
4439     sal_Bool bRet = ( rVal >>= nVal );
4440     if( bRet )
4441     {
4442         // translate WritingDirection2 constants into SvxFrameDirection
4443         switch( nVal )
4444         {
4445             case text::WritingMode2::LR_TB:
4446                 SetValue( FRMDIR_HORI_LEFT_TOP );
4447                 break;
4448             case text::WritingMode2::RL_TB:
4449                 SetValue( FRMDIR_HORI_RIGHT_TOP );
4450                 break;
4451             case text::WritingMode2::TB_RL:
4452                 SetValue( FRMDIR_VERT_TOP_RIGHT );
4453                 break;
4454             case text::WritingMode2::TB_LR:
4455                 SetValue( FRMDIR_VERT_TOP_LEFT );
4456                 break;
4457             case text::WritingMode2::PAGE:
4458                 SetValue( FRMDIR_ENVIRONMENT );
4459                 break;
4460             default:
4461                 bRet = sal_False;
4462                 break;
4463         }
4464     }
4465 
4466     return bRet;
4467 }
4468 
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const4469 sal_Bool SvxFrameDirectionItem::QueryValue( com::sun::star::uno::Any& rVal,
4470                                             sal_uInt8 ) const
4471 {
4472     // translate SvxFrameDirection into WritingDirection2
4473     sal_Int16 nVal;
4474     sal_Bool bRet = sal_True;
4475     switch( GetValue() )
4476     {
4477         case FRMDIR_HORI_LEFT_TOP:
4478             nVal = text::WritingMode2::LR_TB;
4479             break;
4480         case FRMDIR_HORI_RIGHT_TOP:
4481             nVal = text::WritingMode2::RL_TB;
4482             break;
4483         case FRMDIR_VERT_TOP_RIGHT:
4484             nVal = text::WritingMode2::TB_RL;
4485             break;
4486         case FRMDIR_VERT_TOP_LEFT:
4487             nVal = text::WritingMode2::TB_LR;
4488             break;
4489         case FRMDIR_ENVIRONMENT:
4490             nVal = text::WritingMode2::PAGE;
4491             break;
4492         default:
4493             DBG_ERROR("Unknown SvxFrameDirection value!");
4494             bRet = sal_False;
4495             break;
4496     }
4497 
4498     // return value + error state
4499     if( bRet )
4500     {
4501         rVal <<= nVal;
4502     }
4503     return bRet;
4504 }
4505