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