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