xref: /aoo41x/main/sc/source/core/data/attrib.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 
32 
33 // INCLUDE ---------------------------------------------------------------
34 
35 
36 #include <com/sun/star/util/CellProtection.hpp>
37 #include <com/sun/star/util/XProtectable.hpp>
38 #include <com/sun/star/text/XText.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 
41 #include "scitems.hxx"
42 #include <editeng/eeitem.hxx>
43 
44 #include <editeng/boxitem.hxx>
45 #include <editeng/editdata.hxx>
46 #include <editeng/editeng.hxx>
47 #include <editeng/editobj.hxx>
48 #include <editeng/flditem.hxx>
49 
50 #include "attrib.hxx"
51 #include "global.hxx"
52 #include "editutil.hxx"
53 #include "sc.hrc"
54 #include "globstr.hrc"
55 
56 #include "textuno.hxx"	// ScHeaderFooterContentObj
57 
58 using namespace com::sun::star;
59 
60 //------------------------------------------------------------------------
61 
62 TYPEINIT1(ScMergeAttr,		 	SfxPoolItem);
63 TYPEINIT1_AUTOFACTORY(ScProtectionAttr,     SfxPoolItem);
64 TYPEINIT1(ScRangeItem,		 	SfxPoolItem);
65 TYPEINIT1(ScTableListItem,		SfxPoolItem);
66 TYPEINIT1(ScPageHFItem, 	 	SfxPoolItem);
67 TYPEINIT1(ScViewObjectModeItem, SfxEnumItem);
68 TYPEINIT1(ScDoubleItem, 		SfxPoolItem);
69 TYPEINIT1(ScPageScaleToItem,    SfxPoolItem);
70 
71 //------------------------------------------------------------------------
72 
73 //
74 //		allgemeine Hilfsfunktionen
75 //
76 
77 sal_Bool ScHasPriority( const SvxBorderLine* pThis, const SvxBorderLine* pOther )
78 {
79 //	  DBG_ASSERT( pThis || pOther, "LineAttr == 0" );
80 
81 	if (!pThis)
82 		return sal_False;
83 	if (!pOther)
84 		return sal_True;
85 
86 	sal_uInt16 nThisSize = pThis->GetOutWidth() + pThis->GetDistance() + pThis->GetInWidth();
87 	sal_uInt16 nOtherSize = pOther->GetOutWidth() + pOther->GetDistance() + pOther->GetInWidth();
88 
89 	if (nThisSize > nOtherSize)
90 		return sal_True;
91 	else if (nThisSize < nOtherSize)
92 		return sal_False;
93 	else
94 	{
95 		if ( pOther->GetInWidth() && !pThis->GetInWidth() )
96 			return sal_True;
97 		else if ( pThis->GetInWidth() && !pOther->GetInWidth() )
98 			return sal_False;
99 		else
100 		{
101 			return sal_True;			//! ???
102 		}
103 	}
104 }
105 
106 
107 //
108 //		Item - Implementierungen
109 //
110 
111 //------------------------------------------------------------------------
112 // Merge
113 //------------------------------------------------------------------------
114 
115 ScMergeAttr::ScMergeAttr():
116 	SfxPoolItem(ATTR_MERGE),
117 	nColMerge(0),
118 	nRowMerge(0)
119 {}
120 
121 //------------------------------------------------------------------------
122 
123 ScMergeAttr::ScMergeAttr( SCsCOL nCol, SCsROW nRow):
124 	SfxPoolItem(ATTR_MERGE),
125 	nColMerge(nCol),
126 	nRowMerge(nRow)
127 {}
128 
129 //------------------------------------------------------------------------
130 
131 ScMergeAttr::ScMergeAttr(const ScMergeAttr& rItem):
132 	SfxPoolItem(ATTR_MERGE)
133 {
134 	nColMerge = rItem.nColMerge;
135 	nRowMerge = rItem.nRowMerge;
136 }
137 
138 ScMergeAttr::~ScMergeAttr()
139 {
140 }
141 
142 //------------------------------------------------------------------------
143 
144 String ScMergeAttr::GetValueText() const
145 {
146 	String aString( '(' );
147 	aString += String::CreateFromInt32( nColMerge );
148 	aString += ',';
149 	aString += String::CreateFromInt32( nRowMerge );
150 	aString += ')';
151 	return aString;
152 }
153 
154 //------------------------------------------------------------------------
155 
156 int ScMergeAttr::operator==( const SfxPoolItem& rItem ) const
157 {
158 	DBG_ASSERT( Which() != rItem.Which() || Type() == rItem.Type(), "which ==, type !=" );
159 	return (Which() == rItem.Which())
160 			 && (nColMerge == ((ScMergeAttr&)rItem).nColMerge)
161 			 && (nRowMerge == ((ScMergeAttr&)rItem).nRowMerge);
162 }
163 
164 //------------------------------------------------------------------------
165 
166 SfxPoolItem* ScMergeAttr::Clone( SfxItemPool * ) const
167 {
168 	return new ScMergeAttr(*this);
169 }
170 
171 //------------------------------------------------------------------------
172 
173 SfxPoolItem* ScMergeAttr::Create( SvStream& rStream, sal_uInt16 /* nVer */ ) const
174 {
175 	sal_Int16	nCol;
176 	sal_Int16	nRow;
177 	rStream >> nCol;
178 	rStream >> nRow;
179 	return new ScMergeAttr(static_cast<SCCOL>(nCol),static_cast<SCROW>(nRow));
180 }
181 
182 //------------------------------------------------------------------------
183 // MergeFlag
184 //------------------------------------------------------------------------
185 
186 ScMergeFlagAttr::ScMergeFlagAttr():
187 	SfxInt16Item(ATTR_MERGE_FLAG, 0)
188 {
189 }
190 
191 //------------------------------------------------------------------------
192 
193 ScMergeFlagAttr::ScMergeFlagAttr(sal_Int16 nFlags):
194 	SfxInt16Item(ATTR_MERGE_FLAG, nFlags)
195 {
196 }
197 
198 ScMergeFlagAttr::~ScMergeFlagAttr()
199 {
200 }
201 
202 //------------------------------------------------------------------------
203 // Protection
204 //------------------------------------------------------------------------
205 
206 ScProtectionAttr::ScProtectionAttr():
207 	SfxPoolItem(ATTR_PROTECTION),
208 	bProtection(sal_True),
209 	bHideFormula(sal_False),
210 	bHideCell(sal_False),
211 	bHidePrint(sal_False)
212 {
213 }
214 
215 //------------------------------------------------------------------------
216 
217 ScProtectionAttr::ScProtectionAttr( sal_Bool bProtect, sal_Bool bHFormula,
218 									sal_Bool bHCell, sal_Bool bHPrint):
219 	SfxPoolItem(ATTR_PROTECTION),
220 	bProtection(bProtect),
221 	bHideFormula(bHFormula),
222 	bHideCell(bHCell),
223 	bHidePrint(bHPrint)
224 {
225 }
226 
227 //------------------------------------------------------------------------
228 
229 ScProtectionAttr::ScProtectionAttr(const ScProtectionAttr& rItem):
230 	SfxPoolItem(ATTR_PROTECTION)
231 {
232 	bProtection  = rItem.bProtection;
233 	bHideFormula = rItem.bHideFormula;
234 	bHideCell	 = rItem.bHideCell;
235 	bHidePrint	 = rItem.bHidePrint;
236 }
237 
238 ScProtectionAttr::~ScProtectionAttr()
239 {
240 }
241 
242 //------------------------------------------------------------------------
243 
244 sal_Bool ScProtectionAttr::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
245 {
246 	nMemberId &= ~CONVERT_TWIPS;
247     switch ( nMemberId  )
248     {
249         case 0 :
250         {
251             util::CellProtection aProtection;
252             aProtection.IsLocked        = bProtection;
253             aProtection.IsFormulaHidden = bHideFormula;
254             aProtection.IsHidden        = bHideCell;
255             aProtection.IsPrintHidden   = bHidePrint;
256             rVal <<= aProtection;
257             break;
258         }
259         case MID_1 :
260             rVal <<= (sal_Bool ) bProtection; break;
261         case MID_2 :
262             rVal <<= (sal_Bool ) bHideFormula; break;
263         case MID_3 :
264             rVal <<= (sal_Bool ) bHideCell; break;
265         case MID_4 :
266             rVal <<= (sal_Bool ) bHidePrint; break;
267         default:
268             DBG_ERROR("Wrong MemberID!");
269             return sal_False;
270     }
271 
272 	return sal_True;
273 }
274 
275 sal_Bool ScProtectionAttr::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
276 {
277 	sal_Bool bRet = sal_False;
278     sal_Bool bVal = sal_Bool();
279 	nMemberId &= ~CONVERT_TWIPS;
280     switch ( nMemberId )
281     {
282         case 0 :
283         {
284             util::CellProtection aProtection;
285             if ( rVal >>= aProtection )
286             {
287                 bProtection  = aProtection.IsLocked;
288                 bHideFormula = aProtection.IsFormulaHidden;
289                 bHideCell    = aProtection.IsHidden;
290                 bHidePrint   = aProtection.IsPrintHidden;
291                 bRet = sal_True;
292             }
293             else
294             {
295                 DBG_ERROR("exception - wrong argument");
296             }
297             break;
298         }
299         case MID_1 :
300             bRet = (rVal >>= bVal); if (bRet) bProtection=bVal; break;
301         case MID_2 :
302             bRet = (rVal >>= bVal); if (bRet) bHideFormula=bVal; break;
303         case MID_3 :
304             bRet = (rVal >>= bVal); if (bRet) bHideCell=bVal; break;
305         case MID_4 :
306             bRet = (rVal >>= bVal); if (bRet) bHidePrint=bVal; break;
307         default:
308             DBG_ERROR("Wrong MemberID!");
309     }
310 
311 	return bRet;
312 }
313 
314 //------------------------------------------------------------------------
315 
316 String ScProtectionAttr::GetValueText() const
317 {
318 	String aValue;
319 	String aStrYes ( ScGlobal::GetRscString(STR_YES) );
320 	String aStrNo  ( ScGlobal::GetRscString(STR_NO) );
321 	sal_Unicode cDelim = ',';
322 
323 	aValue	= '(';
324 	aValue += (bProtection	? aStrYes : aStrNo);	aValue += cDelim;
325 	aValue += (bHideFormula ? aStrYes : aStrNo);	aValue += cDelim;
326 	aValue += (bHideCell	? aStrYes : aStrNo);	aValue += cDelim;
327 	aValue += (bHidePrint	? aStrYes : aStrNo);
328 	aValue += ')';
329 
330 	return aValue;
331 }
332 
333 //------------------------------------------------------------------------
334 
335 SfxItemPresentation ScProtectionAttr::GetPresentation
336 	(
337 		SfxItemPresentation ePres,
338         SfxMapUnit /* eCoreMetric */,
339         SfxMapUnit /* ePresMetric */,
340 		String& rText,
341         const IntlWrapper* /* pIntl */
342 	) const
343 {
344 	String aStrYes	( ScGlobal::GetRscString(STR_YES) );
345 	String aStrNo	( ScGlobal::GetRscString(STR_NO) );
346 	String aStrSep	 = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
347 	String aStrDelim = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( ", " ));
348 
349 	switch ( ePres )
350 	{
351 		case SFX_ITEM_PRESENTATION_NONE:
352 			rText.Erase();
353 			break;
354 
355 		case SFX_ITEM_PRESENTATION_NAMELESS:
356 			rText = GetValueText();
357 			break;
358 
359 		case SFX_ITEM_PRESENTATION_COMPLETE:
360 			rText  = ScGlobal::GetRscString(STR_PROTECTION); rText += aStrSep;
361 			rText += (bProtection ? aStrYes : aStrNo);		 rText += aStrDelim;
362 			rText += ScGlobal::GetRscString(STR_FORMULAS);	 rText += aStrSep;
363 			rText += (!bHideFormula ? aStrYes : aStrNo);	 rText += aStrDelim;
364 			rText += ScGlobal::GetRscString(STR_HIDE);		 rText += aStrSep;
365 			rText += (bHideCell ? aStrYes : aStrNo);		 rText += aStrDelim;
366 			rText += ScGlobal::GetRscString(STR_PRINT); 	 rText += aStrSep;
367 			rText += (!bHidePrint ? aStrYes : aStrNo);
368 			break;
369 
370 		default:
371 			ePres = SFX_ITEM_PRESENTATION_NONE;
372 	}
373 
374 	return ePres;
375 }
376 
377 //------------------------------------------------------------------------
378 
379 int ScProtectionAttr::operator==( const SfxPoolItem& rItem ) const
380 {
381 	DBG_ASSERT( Which() != rItem.Which() || Type() == rItem.Type(), "which ==, type !=" );
382 	return (Which() == rItem.Which())
383 			 && (bProtection == ((ScProtectionAttr&)rItem).bProtection)
384 			 && (bHideFormula == ((ScProtectionAttr&)rItem).bHideFormula)
385 			 && (bHideCell == ((ScProtectionAttr&)rItem).bHideCell)
386 			 && (bHidePrint == ((ScProtectionAttr&)rItem).bHidePrint);
387 }
388 
389 //------------------------------------------------------------------------
390 
391 SfxPoolItem* ScProtectionAttr::Clone( SfxItemPool * ) const
392 {
393 	return new ScProtectionAttr(*this);
394 }
395 
396 //------------------------------------------------------------------------
397 
398 SfxPoolItem* ScProtectionAttr::Create( SvStream& rStream, sal_uInt16 /* n */ ) const
399 {
400 	sal_Bool bProtect;
401 	sal_Bool bHFormula;
402 	sal_Bool bHCell;
403 	sal_Bool bHPrint;
404 
405 	rStream >> bProtect;
406 	rStream >> bHFormula;
407 	rStream >> bHCell;
408 	rStream >> bHPrint;
409 
410 	return new ScProtectionAttr(bProtect,bHFormula,bHCell,bHPrint);
411 }
412 
413 //------------------------------------------------------------------------
414 
415 sal_Bool ScProtectionAttr::SetProtection( sal_Bool bProtect)
416 {
417 	bProtection =  bProtect;
418 	return sal_True;
419 }
420 
421 //------------------------------------------------------------------------
422 
423 sal_Bool ScProtectionAttr::SetHideFormula( sal_Bool bHFormula)
424 {
425 	bHideFormula = bHFormula;
426 	return sal_True;
427 }
428 
429 //------------------------------------------------------------------------
430 
431 sal_Bool ScProtectionAttr::SetHideCell( sal_Bool bHCell)
432 {
433 	bHideCell = bHCell;
434 	return sal_True;
435 }
436 
437 //------------------------------------------------------------------------
438 
439 sal_Bool ScProtectionAttr::SetHidePrint( sal_Bool bHPrint)
440 {
441 	bHidePrint = bHPrint;
442 	return sal_True;
443 }
444 
445 // -----------------------------------------------------------------------
446 //		ScRangeItem - Tabellenbereich
447 // -----------------------------------------------------------------------
448 
449 int ScRangeItem::operator==( const SfxPoolItem& rAttr ) const
450 {
451 	DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
452 
453 	return ( aRange == ( (ScRangeItem&)rAttr ).aRange );
454 }
455 
456 // -----------------------------------------------------------------------
457 
458 SfxPoolItem* ScRangeItem::Clone( SfxItemPool* ) const
459 {
460 	return new ScRangeItem( *this );
461 }
462 
463 //------------------------------------------------------------------------
464 
465 SfxItemPresentation ScRangeItem::GetPresentation
466 	(
467 		SfxItemPresentation ePres,
468         SfxMapUnit          /* eCoreUnit */,
469         SfxMapUnit          /* ePresUnit */,
470 		String& 			rText,
471         const IntlWrapper* /* pIntl */
472 	) const
473 {
474 	rText.Erase();
475 
476 	switch ( ePres )
477 	{
478 		case SFX_ITEM_PRESENTATION_COMPLETE:
479 		rText  = ScGlobal::GetRscString(STR_AREA);
480 		rText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
481 //		break;// Durchfallen !!!
482 
483 		case SFX_ITEM_PRESENTATION_NAMELESS:
484 		{
485 			String aText;
486 			/* Always use OOo:A1 format */
487 			aRange.Format( aText );
488 			rText += aText;
489 		}
490 		break;
491 
492         default:
493         {
494             // added to avoid warnings
495         }
496 	}
497 
498 	return ePres;
499 }
500 
501 // -----------------------------------------------------------------------
502 //		ScTableListItem - Liste von Tabellen(-nummern)
503 // -----------------------------------------------------------------------
504 
505 ScTableListItem::ScTableListItem( const ScTableListItem& rCpy )
506 	:	SfxPoolItem ( rCpy.Which() ),
507 		nCount		( rCpy.nCount )
508 {
509 	if ( nCount > 0 )
510 	{
511 		pTabArr = new SCTAB [nCount];
512 
513 		for ( sal_uInt16 i=0; i<nCount; i++ )
514 			pTabArr[i] = rCpy.pTabArr[i];
515 	}
516 	else
517 		pTabArr = NULL;
518 }
519 
520 // -----------------------------------------------------------------------
521 
522 //UNUSED2008-05  ScTableListItem::ScTableListItem( const sal_uInt16 nWhichP, const List& rList )
523 //UNUSED2008-05      :   SfxPoolItem ( nWhichP ),
524 //UNUSED2008-05          nCount      ( 0 ),
525 //UNUSED2008-05          pTabArr     ( NULL )
526 //UNUSED2008-05  {
527 //UNUSED2008-05      SetTableList( rList );
528 //UNUSED2008-05  }
529 
530 // -----------------------------------------------------------------------
531 
532 ScTableListItem::~ScTableListItem()
533 {
534 	delete [] pTabArr;
535 }
536 
537 // -----------------------------------------------------------------------
538 
539 ScTableListItem& ScTableListItem::operator=( const ScTableListItem& rCpy )
540 {
541 	delete [] pTabArr;
542 
543 	if ( rCpy.nCount > 0 )
544 	{
545 		pTabArr = new SCTAB [rCpy.nCount];
546 		for ( sal_uInt16 i=0; i<rCpy.nCount; i++ )
547 			pTabArr[i] = rCpy.pTabArr[i];
548 	}
549 	else
550 		pTabArr = NULL;
551 
552 	nCount = rCpy.nCount;
553 
554 	return *this;
555 }
556 
557 // -----------------------------------------------------------------------
558 
559 int ScTableListItem::operator==( const SfxPoolItem& rAttr ) const
560 {
561 	DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
562 
563 	ScTableListItem&	rCmp   = (ScTableListItem&)rAttr;
564 	sal_Bool				bEqual = (nCount == rCmp.nCount);
565 
566 	if ( nCount > 0 )
567 	{
568 		sal_uInt16	i=0;
569 
570 		bEqual = ( pTabArr && rCmp.pTabArr );
571 
572 		while ( bEqual && i<nCount )
573 		{
574 			bEqual = ( pTabArr[i] == rCmp.pTabArr[i] );
575 			i++;
576 		}
577 	}
578 	return bEqual;
579 }
580 
581 // -----------------------------------------------------------------------
582 
583 SfxPoolItem* ScTableListItem::Clone( SfxItemPool* ) const
584 {
585 	return new ScTableListItem( *this );
586 }
587 
588 //------------------------------------------------------------------------
589 
590 SfxItemPresentation ScTableListItem::GetPresentation
591 	(
592 		SfxItemPresentation ePres,
593         SfxMapUnit			/* eCoreUnit */,
594         SfxMapUnit			/* ePresUnit */,
595 		String& 			rText,
596         const IntlWrapper* /* pIntl */
597 	) const
598 {
599 	const sal_Unicode cDelim = ',';
600 
601 	switch ( ePres )
602 	{
603 		case SFX_ITEM_PRESENTATION_NONE:
604 			rText.Erase();
605 			return ePres;
606 
607 		case SFX_ITEM_PRESENTATION_NAMELESS:
608 			{
609 			rText  = '(';
610 			if ( nCount>0 && pTabArr )
611 				for ( sal_uInt16 i=0; i<nCount; i++ )
612 				{
613 					rText += String::CreateFromInt32( pTabArr[i] );
614 					if ( i<(nCount-1) )
615 						rText += cDelim;
616 				}
617 			rText += ')';
618 			}
619 			return ePres;
620 
621 		case SFX_ITEM_PRESENTATION_COMPLETE:
622 			rText.Erase();
623 			return SFX_ITEM_PRESENTATION_NONE;
624 
625         default:
626         {
627             // added to avoid warnings
628         }
629 	}
630 
631 	return SFX_ITEM_PRESENTATION_NONE;
632 }
633 
634 // -----------------------------------------------------------------------
635 
636 //UNUSED2009-05 sal_Bool ScTableListItem::GetTableList( List& aList ) const
637 //UNUSED2009-05 {
638 //UNUSED2009-05     for ( sal_uInt16 i=0; i<nCount; i++ )
639 //UNUSED2009-05         aList.Insert( new SCTAB( pTabArr[i] ) );
640 //UNUSED2009-05
641 //UNUSED2009-05     return ( nCount > 0 );
642 //UNUSED2009-05 }
643 
644 // -----------------------------------------------------------------------
645 
646 //UNUSED2009-05 void ScTableListItem::SetTableList( const List& rList )
647 //UNUSED2009-05 {
648 //UNUSED2009-05     nCount = (sal_uInt16)rList.Count();
649 //UNUSED2009-05
650 //UNUSED2009-05     delete [] pTabArr;
651 //UNUSED2009-05
652 //UNUSED2009-05     if ( nCount > 0 )
653 //UNUSED2009-05     {
654 //UNUSED2009-05         pTabArr = new SCTAB [nCount];
655 //UNUSED2009-05
656 //UNUSED2009-05         for ( sal_uInt16 i=0; i<nCount; i++ )
657 //UNUSED2009-05             pTabArr[i] = *( (SCTAB*)rList.GetObject( i ) );
658 //UNUSED2009-05     }
659 //UNUSED2009-05     else
660 //UNUSED2009-05         pTabArr = NULL;
661 //UNUSED2009-05 }
662 
663 
664 // -----------------------------------------------------------------------
665 //      ScPageHFItem - Daten der Kopf-/Fusszeilen
666 // -----------------------------------------------------------------------
667 
668 ScPageHFItem::ScPageHFItem( sal_uInt16 nWhichP )
669     :   SfxPoolItem ( nWhichP ),
670 		pLeftArea	( NULL ),
671 		pCenterArea ( NULL ),
672 		pRightArea	( NULL )
673 {
674 }
675 
676 //------------------------------------------------------------------------
677 
678 ScPageHFItem::ScPageHFItem( const ScPageHFItem& rItem )
679 	:	SfxPoolItem ( rItem ),
680 		pLeftArea	( NULL ),
681 		pCenterArea ( NULL ),
682 		pRightArea	( NULL )
683 {
684 	if ( rItem.pLeftArea )
685 		pLeftArea = rItem.pLeftArea->Clone();
686 	if ( rItem.pCenterArea )
687 		pCenterArea = rItem.pCenterArea->Clone();
688 	if ( rItem.pRightArea )
689 		pRightArea = rItem.pRightArea->Clone();
690 }
691 
692 //------------------------------------------------------------------------
693 
694 ScPageHFItem::~ScPageHFItem()
695 {
696 	delete pLeftArea;
697 	delete pCenterArea;
698 	delete pRightArea;
699 }
700 
701 //------------------------------------------------------------------------
702 
703 sal_Bool ScPageHFItem::QueryValue( uno::Any& rVal, sal_uInt8 /* nMemberId */ ) const
704 {
705 	uno::Reference<sheet::XHeaderFooterContent> xContent =
706 		new ScHeaderFooterContentObj( pLeftArea, pCenterArea, pRightArea );
707 
708 	rVal <<= xContent;
709 	return sal_True;
710 }
711 
712 sal_Bool ScPageHFItem::PutValue( const uno::Any& rVal, sal_uInt8 /* nMemberId */ )
713 {
714 	sal_Bool bRet = sal_False;
715 	uno::Reference<sheet::XHeaderFooterContent> xContent;
716 	if ( rVal >>= xContent )
717 	{
718 		if ( xContent.is() )
719 		{
720 			ScHeaderFooterContentObj* pImp =
721 					ScHeaderFooterContentObj::getImplementation( xContent );
722 			if (pImp)
723 			{
724 				const EditTextObject* pImpLeft = pImp->GetLeftEditObject();
725 				delete pLeftArea;
726 				pLeftArea = pImpLeft ? pImpLeft->Clone() : NULL;
727 
728 				const EditTextObject* pImpCenter = pImp->GetCenterEditObject();
729 				delete pCenterArea;
730 				pCenterArea = pImpCenter ? pImpCenter->Clone() : NULL;
731 
732 				const EditTextObject* pImpRight = pImp->GetRightEditObject();
733 				delete pRightArea;
734 				pRightArea = pImpRight ? pImpRight->Clone() : NULL;
735 
736 				if ( !pLeftArea || !pCenterArea || !pRightArea )
737 				{
738 					// keine Texte auf NULL stehen lassen
739 					ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), sal_True );
740 					if (!pLeftArea)
741 						pLeftArea = aEngine.CreateTextObject();
742 					if (!pCenterArea)
743 						pCenterArea = aEngine.CreateTextObject();
744 					if (!pRightArea)
745 						pRightArea = aEngine.CreateTextObject();
746 				}
747 
748 				bRet = sal_True;
749 			}
750 		}
751 	}
752 
753 	if (!bRet)
754 	{
755 		DBG_ERROR("exception - wrong argument");
756 	}
757 
758 	return bRet;
759 }
760 
761 //------------------------------------------------------------------------
762 
763 String ScPageHFItem::GetValueText() const
764 {
765 	return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScPageHFItem"));
766 }
767 
768 //------------------------------------------------------------------------
769 
770 int ScPageHFItem::operator==( const SfxPoolItem& rItem ) const
771 {
772 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
773 
774 	const ScPageHFItem&	r = (const ScPageHFItem&)rItem;
775 
776 	return    ScGlobal::EETextObjEqual(pLeftArea,   r.pLeftArea)
777 		   && ScGlobal::EETextObjEqual(pCenterArea, r.pCenterArea)
778 		   && ScGlobal::EETextObjEqual(pRightArea,  r.pRightArea);
779 }
780 
781 //------------------------------------------------------------------------
782 
783 SfxPoolItem* ScPageHFItem::Clone( SfxItemPool* ) const
784 {
785 	return new ScPageHFItem( *this );
786 }
787 
788 //------------------------------------------------------------------------
789 
790 void lcl_SetSpace( String& rStr, const ESelection& rSel )
791 {
792 	// Text durch ein Leerzeichen ersetzen, damit Positionen stimmen:
793 
794 	xub_StrLen nLen = rSel.nEndPos-rSel.nStartPos;
795 	rStr.Erase( rSel.nStartPos, nLen-1 );
796 	rStr.SetChar( rSel.nStartPos, ' ' );
797 }
798 
799 sal_Bool lcl_ConvertFields(EditEngine& rEng, const String* pCommands)
800 {
801 	sal_Bool bChange = sal_False;
802 	sal_uInt16 nParCnt = rEng.GetParagraphCount();
803 	for (sal_uInt16 nPar = 0; nPar<nParCnt; nPar++)
804 	{
805 		String aStr = rEng.GetText( nPar );
806 		xub_StrLen nPos;
807 
808 		while ((nPos = aStr.Search(pCommands[0])) != STRING_NOTFOUND)
809 		{
810 			ESelection aSel( nPar,nPos, nPar,nPos+pCommands[0].Len() );
811             rEng.QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), aSel );
812 			lcl_SetSpace(aStr, aSel ); bChange = sal_True;
813 		}
814 		while ((nPos = aStr.Search(pCommands[1])) != STRING_NOTFOUND)
815 		{
816 			ESelection aSel( nPar,nPos, nPar,nPos+pCommands[1].Len() );
817             rEng.QuickInsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), aSel );
818 			lcl_SetSpace(aStr, aSel ); bChange = sal_True;
819 		}
820 		while ((nPos = aStr.Search(pCommands[2])) != STRING_NOTFOUND)
821 		{
822 			ESelection aSel( nPar,nPos, nPar,nPos+pCommands[2].Len() );
823             rEng.QuickInsertField( SvxFieldItem(SvxDateField(Date(),SVXDATETYPE_VAR), EE_FEATURE_FIELD), aSel );
824 			lcl_SetSpace(aStr, aSel ); bChange = sal_True;
825 		}
826 		while ((nPos = aStr.Search(pCommands[3])) != STRING_NOTFOUND)
827 		{
828 			ESelection aSel( nPar,nPos, nPar,nPos+pCommands[3].Len() );
829             rEng.QuickInsertField( SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD ), aSel );
830 			lcl_SetSpace(aStr, aSel ); bChange = sal_True;
831 		}
832 		while ((nPos = aStr.Search(pCommands[4])) != STRING_NOTFOUND)
833 		{
834 			ESelection aSel( nPar,nPos, nPar,nPos+pCommands[4].Len() );
835             rEng.QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), aSel );
836 			lcl_SetSpace(aStr, aSel ); bChange = sal_True;
837 		}
838 		while ((nPos = aStr.Search(pCommands[5])) != STRING_NOTFOUND)
839 		{
840 			ESelection aSel( nPar,nPos, nPar,nPos+pCommands[5].Len() );
841             rEng.QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), aSel );
842 			lcl_SetSpace(aStr, aSel ); bChange = sal_True;
843 		}
844 	}
845 	return bChange;
846 }
847 
848 #define SC_FIELD_COUNT	6
849 
850 SfxPoolItem* ScPageHFItem::Create( SvStream& rStream, sal_uInt16 nVer ) const
851 {
852 	EditTextObject* pLeft	= EditTextObject::Create(rStream);
853 	EditTextObject* pCenter = EditTextObject::Create(rStream);
854 	EditTextObject* pRight	= EditTextObject::Create(rStream);
855 
856 	DBG_ASSERT( pLeft && pCenter && pRight, "Error reading ScPageHFItem" );
857 
858 	if ( pLeft == NULL   || pLeft->GetParagraphCount() == 0 ||
859 		 pCenter == NULL || pCenter->GetParagraphCount() == 0 ||
860 		 pRight == NULL  || pRight->GetParagraphCount() == 0 )
861 	{
862 		//	If successfully loaded, each object contains at least one paragraph.
863 		//	Excel import in 5.1 created broken TextObjects (#67442#) that are
864 		//	corrected here to avoid saving wrong files again (#90487#).
865 
866 		ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), sal_True );
867 		if ( pLeft == NULL || pLeft->GetParagraphCount() == 0 )
868 		{
869 			delete pLeft;
870 			pLeft = aEngine.CreateTextObject();
871 		}
872 		if ( pCenter == NULL || pCenter->GetParagraphCount() == 0 )
873 		{
874 			delete pCenter;
875 			pCenter = aEngine.CreateTextObject();
876 		}
877 		if ( pRight == NULL || pRight->GetParagraphCount() == 0 )
878 		{
879 			delete pRight;
880 			pRight = aEngine.CreateTextObject();
881 		}
882 	}
883 
884 	if ( nVer < 1 )				// alte Feldbefehle umsetzen
885 	{
886 		sal_uInt16 i;
887 		const String& rDel = ScGlobal::GetRscString( STR_HFCMD_DELIMITER );
888 		String aCommands[SC_FIELD_COUNT];
889 		for (i=0; i<SC_FIELD_COUNT; i++)
890 			aCommands[i] = rDel;
891 		aCommands[0] += ScGlobal::GetRscString(STR_HFCMD_PAGE);
892 		aCommands[1] += ScGlobal::GetRscString(STR_HFCMD_PAGES);
893 		aCommands[2] += ScGlobal::GetRscString(STR_HFCMD_DATE);
894 		aCommands[3] += ScGlobal::GetRscString(STR_HFCMD_TIME);
895 		aCommands[4] += ScGlobal::GetRscString(STR_HFCMD_FILE);
896 		aCommands[5] += ScGlobal::GetRscString(STR_HFCMD_TABLE);
897 		for (i=0; i<SC_FIELD_COUNT; i++)
898 			aCommands[i] += rDel;
899 
900 		ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), sal_True );
901 		aEngine.SetText(*pLeft);
902 		if (lcl_ConvertFields(aEngine,aCommands))
903 		{
904 			delete pLeft;
905 			pLeft = aEngine.CreateTextObject();
906 		}
907 		aEngine.SetText(*pCenter);
908 		if (lcl_ConvertFields(aEngine,aCommands))
909 		{
910 			delete pCenter;
911 			pCenter = aEngine.CreateTextObject();
912 		}
913 		aEngine.SetText(*pRight);
914 		if (lcl_ConvertFields(aEngine,aCommands))
915 		{
916 			delete pRight;
917 			pRight = aEngine.CreateTextObject();
918 		}
919 	}
920 	else if ( nVer < 2 )
921 	{	// nichts tun, SvxFileField nicht gegen SvxExtFileField austauschen
922 	}
923 
924 	ScPageHFItem* pItem = new ScPageHFItem( Which() );
925 	pItem->SetArea( pLeft,	  SC_HF_LEFTAREA   );
926 	pItem->SetArea( pCenter, SC_HF_CENTERAREA );
927 	pItem->SetArea( pRight,  SC_HF_RIGHTAREA  );
928 
929 	return pItem;
930 }
931 
932 //------------------------------------------------------------------------
933 
934 //UNUSED2009-05 class ScFieldChangerEditEngine : public ScEditEngineDefaulter
935 //UNUSED2009-05 {
936 //UNUSED2009-05     TypeId      aExtFileId;
937 //UNUSED2009-05     sal_uInt16      nConvPara;
938 //UNUSED2009-05     xub_StrLen  nConvPos;
939 //UNUSED2009-05     sal_Bool        bConvert;
940 //UNUSED2009-05
941 //UNUSED2009-05 public:
942 //UNUSED2009-05     ScFieldChangerEditEngine( SfxItemPool* pEnginePool, sal_Bool bDeleteEnginePool );
943 //UNUSED2009-05     virtual     ~ScFieldChangerEditEngine() {}
944 //UNUSED2009-05
945 //UNUSED2009-05     virtual String  CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara,
946 //UNUSED2009-05                                     sal_uInt16 nPos, Color*& rTxtColor,
947 //UNUSED2009-05                                     Color*& rFldColor );
948 //UNUSED2009-05
949 //UNUSED2009-05     sal_Bool            ConvertFields();
950 //UNUSED2009-05 };
951 //UNUSED2009-05
952 //UNUSED2009-05 ScFieldChangerEditEngine::ScFieldChangerEditEngine( SfxItemPool* pEnginePoolP,
953 //UNUSED2009-05             sal_Bool bDeleteEnginePoolP ) :
954 //UNUSED2009-05         ScEditEngineDefaulter( pEnginePoolP, bDeleteEnginePoolP ),
955 //UNUSED2009-05         aExtFileId( TYPE( SvxExtFileField ) ),
956 //UNUSED2009-05         nConvPara( 0 ),
957 //UNUSED2009-05         nConvPos( 0 ),
958 //UNUSED2009-05         bConvert( sal_False )
959 //UNUSED2009-05 {
960 //UNUSED2009-05 }
961 //UNUSED2009-05
962 //UNUSED2009-05 String ScFieldChangerEditEngine::CalcFieldValue( const SvxFieldItem& rField,
963 //UNUSED2009-05             sal_uInt16 nPara, sal_uInt16 nPos, Color*& /* rTxtColor */, Color*& /* rFldColor */ )
964 //UNUSED2009-05 {
965 //UNUSED2009-05     const SvxFieldData* pFieldData = rField.GetField();
966 //UNUSED2009-05     if ( pFieldData && pFieldData->Type() == aExtFileId )
967 //UNUSED2009-05     {
968 //UNUSED2009-05         bConvert = sal_True;
969 //UNUSED2009-05         nConvPara = nPara;
970 //UNUSED2009-05         nConvPos = nPos;
971 //UNUSED2009-05     }
972 //UNUSED2009-05     return EMPTY_STRING;
973 //UNUSED2009-05 }
974 //UNUSED2009-05
975 //UNUSED2009-05 sal_Bool ScFieldChangerEditEngine::ConvertFields()
976 //UNUSED2009-05 {
977 //UNUSED2009-05     sal_Bool bConverted = sal_False;
978 //UNUSED2009-05     do
979 //UNUSED2009-05     {
980 //UNUSED2009-05         bConvert = sal_False;
981 //UNUSED2009-05         UpdateFields();
982 //UNUSED2009-05         if ( bConvert )
983 //UNUSED2009-05         {
984 //UNUSED2009-05             ESelection aSel( nConvPara, nConvPos, nConvPara, nConvPos+1 );
985 //UNUSED2009-05             QuickInsertField( SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD), aSel );
986 //UNUSED2009-05             bConverted = sal_True;
987 //UNUSED2009-05         }
988 //UNUSED2009-05     } while ( bConvert );
989 //UNUSED2009-05     return bConverted;
990 //UNUSED2009-05 }
991 
992 void ScPageHFItem::SetLeftArea( const EditTextObject& rNew )
993 {
994 	delete pLeftArea;
995 	pLeftArea = rNew.Clone();
996 }
997 
998 //------------------------------------------------------------------------
999 
1000 void ScPageHFItem::SetCenterArea( const EditTextObject& rNew )
1001 {
1002 	delete pCenterArea;
1003 	pCenterArea = rNew.Clone();
1004 }
1005 
1006 //------------------------------------------------------------------------
1007 
1008 void ScPageHFItem::SetRightArea( const EditTextObject& rNew )
1009 {
1010 	delete pRightArea;
1011 	pRightArea = rNew.Clone();
1012 }
1013 
1014 void ScPageHFItem::SetArea( EditTextObject *pNew, int nArea )
1015 {
1016 	switch ( nArea )
1017 	{
1018 		case SC_HF_LEFTAREA:	delete pLeftArea;	pLeftArea   = pNew; break;
1019 		case SC_HF_CENTERAREA:  delete pCenterArea; pCenterArea = pNew; break;
1020 		case SC_HF_RIGHTAREA:	delete pRightArea;  pRightArea  = pNew; break;
1021 		default:
1022 			DBG_ERROR( "New Area?" );
1023 	}
1024 }
1025 
1026 //-----------------------------------------------------------------------
1027 //	ScViewObjectModeItem - Darstellungsmodus von ViewObjekten
1028 //-----------------------------------------------------------------------
1029 
1030 ScViewObjectModeItem::ScViewObjectModeItem( sal_uInt16 nWhichP )
1031     : SfxEnumItem( nWhichP, VOBJ_MODE_SHOW )
1032 {
1033 }
1034 
1035 //------------------------------------------------------------------------
1036 
1037 ScViewObjectModeItem::ScViewObjectModeItem( sal_uInt16 nWhichP, ScVObjMode eMode )
1038     : SfxEnumItem( nWhichP, sal::static_int_cast<sal_uInt16>(eMode) )
1039 {
1040 }
1041 
1042 //------------------------------------------------------------------------
1043 
1044 ScViewObjectModeItem::~ScViewObjectModeItem()
1045 {
1046 }
1047 
1048 //------------------------------------------------------------------------
1049 
1050 SfxItemPresentation ScViewObjectModeItem::GetPresentation
1051 (
1052 	SfxItemPresentation ePres,
1053     SfxMapUnit          /* eCoreUnit */,
1054     SfxMapUnit          /* ePresUnit */,
1055 	String&				rText,
1056     const IntlWrapper* /* pIntl */
1057 )	const
1058 {
1059 	String	aDel = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(": "));
1060 	rText.Erase();
1061 
1062 	switch ( ePres )
1063 	{
1064 		case SFX_ITEM_PRESENTATION_COMPLETE:
1065 		switch( Which() )
1066 		{
1067 			case SID_SCATTR_PAGE_CHARTS:
1068 			rText  = ScGlobal::GetRscString(STR_VOBJ_CHART);
1069 			rText += aDel;
1070 			break;
1071 
1072 			case SID_SCATTR_PAGE_OBJECTS:
1073 			rText  = ScGlobal::GetRscString(STR_VOBJ_OBJECT);
1074 			rText += aDel;
1075 			break;
1076 
1077 			case SID_SCATTR_PAGE_DRAWINGS:
1078 			rText  = ScGlobal::GetRscString(STR_VOBJ_DRAWINGS);
1079 			rText += aDel;
1080 			break;
1081 
1082 			default:
1083 			ePres = SFX_ITEM_PRESENTATION_NAMELESS;//das geht immer!
1084 			break;
1085 		}
1086 //		break; // DURCHFALLEN!!!
1087 
1088 		case SFX_ITEM_PRESENTATION_NAMELESS:
1089 		rText += ScGlobal::GetRscString(STR_VOBJ_MODE_SHOW+GetValue());
1090 		break;
1091 
1092         default:
1093         {
1094             // added to avoid warnings
1095         }
1096 	}
1097 
1098 	return ePres;
1099 }
1100 
1101 //------------------------------------------------------------------------
1102 
1103 String ScViewObjectModeItem::GetValueText( sal_uInt16 nVal ) const
1104 {
1105 	DBG_ASSERT( nVal <= VOBJ_MODE_HIDE, "enum overflow!" );
1106 
1107 	return ScGlobal::GetRscString( STR_VOBJ_MODE_SHOW + (nVal % 2));
1108 }
1109 
1110 //------------------------------------------------------------------------
1111 
1112 sal_uInt16 ScViewObjectModeItem::GetValueCount() const
1113 {
1114 	return 2;
1115 }
1116 
1117 //------------------------------------------------------------------------
1118 
1119 SfxPoolItem* ScViewObjectModeItem::Clone( SfxItemPool* ) const
1120 {
1121 	return new ScViewObjectModeItem( *this );
1122 }
1123 
1124 //------------------------------------------------------------------------
1125 
1126 sal_uInt16 ScViewObjectModeItem::GetVersion( sal_uInt16 /* nFileVersion */ ) const
1127 {
1128 	return 1;
1129 }
1130 
1131 //------------------------------------------------------------------------
1132 
1133 SfxPoolItem* ScViewObjectModeItem::Create(
1134 									SvStream&	rStream,
1135 									sal_uInt16		nVersion ) const
1136 {
1137 	if ( nVersion == 0 )
1138 	{
1139 		// alte Version mit AllEnumItem -> mit Mode "Show" erzeugen
1140 		return new ScViewObjectModeItem( Which() );
1141 	}
1142 	else
1143 	{
1144 		sal_uInt16 nVal;
1145 		rStream >> nVal;
1146 
1147 		//#i80528# adapt to new range eventually
1148 		if((sal_uInt16)VOBJ_MODE_HIDE < nVal) nVal = (sal_uInt16)VOBJ_MODE_SHOW;
1149 
1150 		return new ScViewObjectModeItem( Which(), (ScVObjMode)nVal);
1151 	}
1152 }
1153 
1154 // -----------------------------------------------------------------------
1155 //		double
1156 // -----------------------------------------------------------------------
1157 
1158 ScDoubleItem::ScDoubleItem( sal_uInt16 nWhichP, double nVal )
1159     :   SfxPoolItem ( nWhichP ),
1160 		nValue	( nVal )
1161 {
1162 }
1163 
1164 //------------------------------------------------------------------------
1165 
1166 ScDoubleItem::ScDoubleItem( const ScDoubleItem& rItem )
1167 	:	SfxPoolItem ( rItem )
1168 {
1169 		nValue = rItem.nValue;
1170 }
1171 
1172 //------------------------------------------------------------------------
1173 
1174 String ScDoubleItem::GetValueText() const
1175 {
1176 	return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScDoubleItem"));
1177 }
1178 
1179 //------------------------------------------------------------------------
1180 
1181 int ScDoubleItem::operator==( const SfxPoolItem& rItem ) const
1182 {
1183 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
1184     const ScDoubleItem& _rItem = (const ScDoubleItem&)rItem;
1185 	return int(nValue == _rItem.nValue);
1186         //int(nValue == ((const ScDoubleItem&)rItem).nValue);
1187 }
1188 
1189 //------------------------------------------------------------------------
1190 
1191 SfxPoolItem* ScDoubleItem::Clone( SfxItemPool* ) const
1192 {
1193 	return new ScDoubleItem( *this );
1194 }
1195 
1196 //------------------------------------------------------------------------
1197 
1198 SfxPoolItem* ScDoubleItem::Create( SvStream& rStream, sal_uInt16 /* nVer */ ) const
1199 {
1200 	double nTmp=0;
1201 	rStream >> nTmp;
1202 
1203 	ScDoubleItem* pItem = new ScDoubleItem( Which(), nTmp );
1204 
1205 	return pItem;
1206 }
1207 
1208 //------------------------------------------------------------------------
1209 
1210 ScDoubleItem::~ScDoubleItem()
1211 {
1212 }
1213 
1214 
1215 // ============================================================================
1216 
1217 ScPageScaleToItem::ScPageScaleToItem() :
1218     SfxPoolItem( ATTR_PAGE_SCALETO ),
1219     mnWidth( 0 ),
1220     mnHeight( 0 )
1221 {
1222 }
1223 
1224 ScPageScaleToItem::ScPageScaleToItem( sal_uInt16 nWidth, sal_uInt16 nHeight ) :
1225     SfxPoolItem( ATTR_PAGE_SCALETO ),
1226     mnWidth( nWidth ),
1227     mnHeight( nHeight )
1228 {
1229 }
1230 
1231 ScPageScaleToItem::~ScPageScaleToItem()
1232 {
1233 }
1234 
1235 ScPageScaleToItem* ScPageScaleToItem::Clone( SfxItemPool* ) const
1236 {
1237     return new ScPageScaleToItem( *this );
1238 }
1239 
1240 int ScPageScaleToItem::operator==( const SfxPoolItem& rCmp ) const
1241 {
1242     DBG_ASSERT( SfxPoolItem::operator==( rCmp ), "ScPageScaleToItem::operator== - unequal wid or type" );
1243     const ScPageScaleToItem& rPageCmp = static_cast< const ScPageScaleToItem& >( rCmp );
1244     return ((mnWidth == rPageCmp.mnWidth) && (mnHeight == rPageCmp.mnHeight)) ? 1 : 0;
1245 }
1246 
1247 namespace {
1248 void lclAppendScalePageCount( String& rText, sal_uInt16 nPages )
1249 {
1250     rText.AppendAscii( ": " );
1251     if( nPages )
1252     {
1253         String aPages( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_PAGES ) );
1254         aPages.SearchAndReplaceAscii( "%1", String::CreateFromInt32( nPages ) );
1255         rText.Append( aPages );
1256     }
1257     else
1258         rText.Append( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_AUTO ) );
1259 }
1260 } // namespace
1261 
1262 SfxItemPresentation ScPageScaleToItem::GetPresentation(
1263         SfxItemPresentation ePres, SfxMapUnit, SfxMapUnit, XubString& rText, const IntlWrapper* ) const
1264 {
1265     rText.Erase();
1266     if( !IsValid() || (ePres == SFX_ITEM_PRESENTATION_NONE) )
1267         return SFX_ITEM_PRESENTATION_NONE;
1268 
1269     String aName( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALETO ) );
1270     String aValue( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_WIDTH ) );
1271     lclAppendScalePageCount( aValue, mnWidth );
1272     aValue.AppendAscii( ", " ).Append( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_HEIGHT ) );
1273     lclAppendScalePageCount( aValue, mnHeight );
1274 
1275     switch( ePres )
1276     {
1277         case SFX_ITEM_PRESENTATION_NONE:
1278         break;
1279 
1280         case SFX_ITEM_PRESENTATION_NAMEONLY:
1281             rText = aName;
1282         break;
1283 
1284         case SFX_ITEM_PRESENTATION_NAMELESS:
1285             rText = aValue;
1286         break;
1287 
1288         case SFX_ITEM_PRESENTATION_COMPLETE:
1289             rText.Assign( aName ).AppendAscii( " (" ).Append( aValue ).Append( ')' );
1290         break;
1291 
1292         default:
1293             DBG_ERRORFILE( "ScPageScaleToItem::GetPresentation - unknown presentation mode" );
1294             ePres = SFX_ITEM_PRESENTATION_NONE;
1295     }
1296     return ePres;
1297 }
1298 
1299 sal_Bool ScPageScaleToItem::QueryValue( uno::Any& rAny, sal_uInt8 nMemberId ) const
1300 {
1301     sal_Bool bRet = sal_True;
1302     switch( nMemberId )
1303     {
1304         case SC_MID_PAGE_SCALETO_WIDTH:     rAny <<= mnWidth;   break;
1305         case SC_MID_PAGE_SCALETO_HEIGHT:    rAny <<= mnHeight;  break;
1306         default:
1307             DBG_ERRORFILE( "ScPageScaleToItem::QueryValue - unknown member ID" );
1308             bRet = sal_False;
1309     }
1310     return bRet;
1311 }
1312 
1313 sal_Bool ScPageScaleToItem::PutValue( const uno::Any& rAny, sal_uInt8 nMemberId )
1314 {
1315     sal_Bool bRet = sal_False;
1316     switch( nMemberId )
1317     {
1318         case SC_MID_PAGE_SCALETO_WIDTH:     bRet = rAny >>= mnWidth;    break;
1319         case SC_MID_PAGE_SCALETO_HEIGHT:    bRet = rAny >>= mnHeight;   break;
1320         default:
1321             DBG_ERRORFILE( "ScPageScaleToItem::PutValue - unknown member ID" );
1322     }
1323     return bRet;
1324 }
1325 
1326 // ============================================================================
1327 
1328 
1329