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