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