fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / core / data / attrib.cxx
blob9adee79936d9b01515114d0a5ce31ad830c42bd4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/util/CellProtection.hpp>
21 #include <com/sun/star/util/XProtectable.hpp>
22 #include <com/sun/star/text/XText.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include "scitems.hxx"
26 #include <editeng/eeitem.hxx>
28 #include <editeng/boxitem.hxx>
29 #include <editeng/editdata.hxx>
30 #include <editeng/editeng.hxx>
31 #include <editeng/editobj.hxx>
32 #include <editeng/flditem.hxx>
34 #include "attrib.hxx"
35 #include "global.hxx"
36 #include "editutil.hxx"
37 #include "sc.hrc"
38 #include "globstr.hrc"
40 #include "textuno.hxx"
42 using namespace com::sun::star;
44 TYPEINIT1(ScMergeAttr, SfxPoolItem);
45 TYPEINIT1_AUTOFACTORY(ScProtectionAttr, SfxPoolItem);
46 TYPEINIT1(ScRangeItem, SfxPoolItem);
47 TYPEINIT1(ScTableListItem, SfxPoolItem);
48 TYPEINIT1(ScPageHFItem, SfxPoolItem);
49 TYPEINIT1(ScViewObjectModeItem, SfxEnumItem);
50 TYPEINIT1(ScDoubleItem, SfxPoolItem);
51 TYPEINIT1(ScPageScaleToItem, SfxPoolItem);
52 TYPEINIT1(ScCondFormatItem, SfxPoolItem);
54 /**
55 * General Help Function
57 bool ScHasPriority( const ::editeng::SvxBorderLine* pThis, const ::editeng::SvxBorderLine* pOther )
60 if (!pThis)
61 return false;
62 if (!pOther)
63 return true;
65 sal_uInt16 nThisSize = pThis->GetScaledWidth();
66 sal_uInt16 nOtherSize = pOther->GetScaledWidth();
68 if (nThisSize > nOtherSize)
69 return true;
70 else if (nThisSize < nOtherSize)
71 return false;
72 else
74 if ( pOther->GetInWidth() && !pThis->GetInWidth() )
75 return true;
76 else if ( pThis->GetInWidth() && !pOther->GetInWidth() )
77 return false;
78 else
80 return true; // FIXME: What is this?
85 /** Item - Implementations */
87 /**
88 * Merge
90 ScMergeAttr::ScMergeAttr():
91 SfxPoolItem(ATTR_MERGE),
92 nColMerge(0),
93 nRowMerge(0)
96 ScMergeAttr::ScMergeAttr( SCsCOL nCol, SCsROW nRow):
97 SfxPoolItem(ATTR_MERGE),
98 nColMerge(nCol),
99 nRowMerge(nRow)
102 ScMergeAttr::ScMergeAttr(const ScMergeAttr& rItem):
103 SfxPoolItem(ATTR_MERGE)
105 nColMerge = rItem.nColMerge;
106 nRowMerge = rItem.nRowMerge;
109 ScMergeAttr::~ScMergeAttr()
113 bool ScMergeAttr::operator==( const SfxPoolItem& rItem ) const
115 OSL_ENSURE( Which() != rItem.Which() || Type() == rItem.Type(), "which ==, type !=" );
116 return (Which() == rItem.Which())
117 && (nColMerge == static_cast<const ScMergeAttr&>(rItem).nColMerge)
118 && (nRowMerge == static_cast<const ScMergeAttr&>(rItem).nRowMerge);
121 SfxPoolItem* ScMergeAttr::Clone( SfxItemPool * ) const
123 return new ScMergeAttr(*this);
126 SfxPoolItem* ScMergeAttr::Create( SvStream& rStream, sal_uInt16 /* nVer */ ) const
128 sal_Int16 nCol;
129 sal_Int16 nRow;
130 rStream.ReadInt16( nCol );
131 rStream.ReadInt16( nRow );
132 return new ScMergeAttr(static_cast<SCCOL>(nCol),static_cast<SCROW>(nRow));
136 * MergeFlag
138 ScMergeFlagAttr::ScMergeFlagAttr():
139 SfxInt16Item(ATTR_MERGE_FLAG, 0)
143 ScMergeFlagAttr::ScMergeFlagAttr(sal_Int16 nFlags):
144 SfxInt16Item(ATTR_MERGE_FLAG, nFlags)
148 ScMergeFlagAttr::~ScMergeFlagAttr()
152 SfxPoolItem * ScMergeFlagAttr::Clone(SfxItemPool *) const
154 return new ScMergeFlagAttr(*this);
157 bool ScMergeFlagAttr::HasPivotButton() const
159 return (GetValue() & SC_MF_BUTTON) != 0;
162 bool ScMergeFlagAttr::HasPivotPopupButton() const
164 return (GetValue() & SC_MF_BUTTON_POPUP) != 0;
168 * Protection
170 ScProtectionAttr::ScProtectionAttr():
171 SfxPoolItem(ATTR_PROTECTION),
172 bProtection(true),
173 bHideFormula(false),
174 bHideCell(false),
175 bHidePrint(false)
179 ScProtectionAttr::ScProtectionAttr( bool bProtect, bool bHFormula,
180 bool bHCell, bool bHPrint):
181 SfxPoolItem(ATTR_PROTECTION),
182 bProtection(bProtect),
183 bHideFormula(bHFormula),
184 bHideCell(bHCell),
185 bHidePrint(bHPrint)
189 ScProtectionAttr::ScProtectionAttr(const ScProtectionAttr& rItem):
190 SfxPoolItem(ATTR_PROTECTION)
192 bProtection = rItem.bProtection;
193 bHideFormula = rItem.bHideFormula;
194 bHideCell = rItem.bHideCell;
195 bHidePrint = rItem.bHidePrint;
198 ScProtectionAttr::~ScProtectionAttr()
202 bool ScProtectionAttr::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
204 nMemberId &= ~CONVERT_TWIPS;
205 switch ( nMemberId )
207 case 0 :
209 util::CellProtection aProtection;
210 aProtection.IsLocked = bProtection;
211 aProtection.IsFormulaHidden = bHideFormula;
212 aProtection.IsHidden = bHideCell;
213 aProtection.IsPrintHidden = bHidePrint;
214 rVal <<= aProtection;
215 break;
217 case MID_1 :
218 rVal <<= bProtection; break;
219 case MID_2 :
220 rVal <<= bHideFormula; break;
221 case MID_3 :
222 rVal <<= bHideCell; break;
223 case MID_4 :
224 rVal <<= bHidePrint; break;
225 default:
226 OSL_FAIL("Wrong MemberID!");
227 return false;
230 return true;
233 bool ScProtectionAttr::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
235 bool bRet = false;
236 bool bVal = false;
237 nMemberId &= ~CONVERT_TWIPS;
238 switch ( nMemberId )
240 case 0 :
242 util::CellProtection aProtection;
243 if ( rVal >>= aProtection )
245 bProtection = aProtection.IsLocked;
246 bHideFormula = aProtection.IsFormulaHidden;
247 bHideCell = aProtection.IsHidden;
248 bHidePrint = aProtection.IsPrintHidden;
249 bRet = true;
251 else
253 OSL_FAIL("exception - wrong argument");
255 break;
257 case MID_1 :
258 bRet = (rVal >>= bVal); if (bRet) bProtection=bVal; break;
259 case MID_2 :
260 bRet = (rVal >>= bVal); if (bRet) bHideFormula=bVal; break;
261 case MID_3 :
262 bRet = (rVal >>= bVal); if (bRet) bHideCell=bVal; break;
263 case MID_4 :
264 bRet = (rVal >>= bVal); if (bRet) bHidePrint=bVal; break;
265 default:
266 OSL_FAIL("Wrong MemberID!");
269 return bRet;
272 OUString ScProtectionAttr::GetValueText() const
274 const OUString aStrYes ( ScGlobal::GetRscString(STR_YES) );
275 const OUString aStrNo ( ScGlobal::GetRscString(STR_NO) );
277 const OUString aValue = "("
278 + (bProtection ? aStrYes : aStrNo)
279 + ","
280 + (bHideFormula ? aStrYes : aStrNo)
281 + ","
282 + (bHideCell ? aStrYes : aStrNo)
283 + ","
284 + (bHidePrint ? aStrYes : aStrNo)
285 + ")";
287 return aValue;
290 bool ScProtectionAttr::GetPresentation
292 SfxItemPresentation ePres,
293 SfxMapUnit /* eCoreMetric */,
294 SfxMapUnit /* ePresMetric */,
295 OUString& rText,
296 const IntlWrapper* /* pIntl */
297 ) const
299 const OUString aStrYes ( ScGlobal::GetRscString(STR_YES) );
300 const OUString aStrNo ( ScGlobal::GetRscString(STR_NO) );
302 switch ( ePres )
304 case SFX_ITEM_PRESENTATION_NAMELESS:
305 rText = GetValueText();
306 break;
308 case SFX_ITEM_PRESENTATION_COMPLETE:
309 rText = ScGlobal::GetRscString(STR_PROTECTION)
310 + ": "
311 + (bProtection ? aStrYes : aStrNo)
312 + ", "
313 + ScGlobal::GetRscString(STR_FORMULAS)
314 + ": "
315 + (!bHideFormula ? aStrYes : aStrNo)
316 + ", "
317 + ScGlobal::GetRscString(STR_HIDE)
318 + ": "
319 + (bHideCell ? aStrYes : aStrNo)
320 + ", "
321 + ScGlobal::GetRscString(STR_PRINT)
322 + ": "
323 + (!bHidePrint ? aStrYes : aStrNo);
324 break;
326 default: break;
329 return true;
332 bool ScProtectionAttr::operator==( const SfxPoolItem& rItem ) const
334 OSL_ENSURE( Which() != rItem.Which() || Type() == rItem.Type(), "which ==, type !=" );
335 return (Which() == rItem.Which())
336 && (bProtection == static_cast<const ScProtectionAttr&>(rItem).bProtection)
337 && (bHideFormula == static_cast<const ScProtectionAttr&>(rItem).bHideFormula)
338 && (bHideCell == static_cast<const ScProtectionAttr&>(rItem).bHideCell)
339 && (bHidePrint == static_cast<const ScProtectionAttr&>(rItem).bHidePrint);
342 SfxPoolItem* ScProtectionAttr::Clone( SfxItemPool * ) const
344 return new ScProtectionAttr(*this);
347 SfxPoolItem* ScProtectionAttr::Create( SvStream& rStream, sal_uInt16 /* n */ ) const
349 bool bProtect;
350 bool bHFormula;
351 bool bHCell;
352 bool bHPrint;
354 rStream.ReadCharAsBool( bProtect );
355 rStream.ReadCharAsBool( bHFormula );
356 rStream.ReadCharAsBool( bHCell );
357 rStream.ReadCharAsBool( bHPrint );
359 return new ScProtectionAttr(bProtect,bHFormula,bHCell,bHPrint);
362 bool ScProtectionAttr::SetProtection( bool bProtect)
364 bProtection = bProtect;
365 return true;
368 bool ScProtectionAttr::SetHideFormula( bool bHFormula)
370 bHideFormula = bHFormula;
371 return true;
374 bool ScProtectionAttr::SetHideCell( bool bHCell)
376 bHideCell = bHCell;
377 return true;
380 bool ScProtectionAttr::SetHidePrint( bool bHPrint)
382 bHidePrint = bHPrint;
383 return true;
387 * ScRangeItem - Table range
389 bool ScRangeItem::operator==( const SfxPoolItem& rAttr ) const
391 assert(SfxPoolItem::operator==(rAttr));
393 return aRange == static_cast<const ScRangeItem&>(rAttr).aRange;
396 SfxPoolItem* ScRangeItem::Clone( SfxItemPool* ) const
398 return new ScRangeItem( *this );
401 bool ScRangeItem::GetPresentation
403 SfxItemPresentation ePres,
404 SfxMapUnit /* eCoreUnit */,
405 SfxMapUnit /* ePresUnit */,
406 OUString& rText,
407 const IntlWrapper* /* pIntl */
408 ) const
410 rText.clear();
412 switch ( ePres )
414 case SFX_ITEM_PRESENTATION_COMPLETE:
415 rText = ScGlobal::GetRscString(STR_AREA) + ": ";
416 /* !!! fall-through !!! */
418 case SFX_ITEM_PRESENTATION_NAMELESS:
420 /* Always use OOo:A1 format */
421 rText += aRange.Format();
423 break;
425 default:
427 // added to avoid warnings
431 return true;
435 * ScTableListItem - List from Tables (-numbers)
437 ScTableListItem::ScTableListItem( const ScTableListItem& rCpy )
438 : SfxPoolItem ( rCpy.Which() ),
439 nCount ( rCpy.nCount )
441 if ( nCount > 0 )
443 pTabArr = new SCTAB [nCount];
445 for ( sal_uInt16 i=0; i<nCount; i++ )
446 pTabArr[i] = rCpy.pTabArr[i];
448 else
449 pTabArr = NULL;
452 ScTableListItem::~ScTableListItem()
454 delete [] pTabArr;
457 ScTableListItem& ScTableListItem::operator=( const ScTableListItem& rCpy )
459 delete [] pTabArr;
461 if ( rCpy.nCount > 0 )
463 pTabArr = new SCTAB [rCpy.nCount];
464 for ( sal_uInt16 i=0; i<rCpy.nCount; i++ )
465 pTabArr[i] = rCpy.pTabArr[i];
467 else
468 pTabArr = NULL;
470 nCount = rCpy.nCount;
472 return *this;
475 bool ScTableListItem::operator==( const SfxPoolItem& rAttr ) const
477 assert(SfxPoolItem::operator==(rAttr));
479 const ScTableListItem& rCmp = static_cast<const ScTableListItem&>(rAttr);
480 bool bEqual = (nCount == rCmp.nCount);
482 if ( nCount > 0 )
484 sal_uInt16 i=0;
486 bEqual = ( pTabArr && rCmp.pTabArr );
488 while ( bEqual && i<nCount )
490 bEqual = ( pTabArr[i] == rCmp.pTabArr[i] );
491 i++;
494 return bEqual;
497 SfxPoolItem* ScTableListItem::Clone( SfxItemPool* ) const
499 return new ScTableListItem( *this );
502 bool ScTableListItem::GetPresentation
504 SfxItemPresentation ePres,
505 SfxMapUnit /* eCoreUnit */,
506 SfxMapUnit /* ePresUnit */,
507 OUString& rText,
508 const IntlWrapper* /* pIntl */
509 ) const
511 switch ( ePres )
513 case SFX_ITEM_PRESENTATION_NAMELESS:
515 rText = "(";
516 if ( nCount>0 && pTabArr )
517 for ( sal_uInt16 i=0; i<nCount; i++ )
519 rText += OUString::number( pTabArr[i] );
520 if ( i<(nCount-1) )
521 rText += ",";
523 rText += ")";
525 return true;
527 case SFX_ITEM_PRESENTATION_COMPLETE:
528 rText.clear();
529 return false;
531 default:
533 // added to avoid warnings
537 return false;
541 * ScPageHFItem - Dates from the Head and Foot lines
543 ScPageHFItem::ScPageHFItem( sal_uInt16 nWhichP )
544 : SfxPoolItem ( nWhichP ),
545 pLeftArea ( NULL ),
546 pCenterArea ( NULL ),
547 pRightArea ( NULL )
551 ScPageHFItem::ScPageHFItem( const ScPageHFItem& rItem )
552 : SfxPoolItem ( rItem ),
553 pLeftArea ( NULL ),
554 pCenterArea ( NULL ),
555 pRightArea ( NULL )
557 if ( rItem.pLeftArea )
558 pLeftArea = rItem.pLeftArea->Clone();
559 if ( rItem.pCenterArea )
560 pCenterArea = rItem.pCenterArea->Clone();
561 if ( rItem.pRightArea )
562 pRightArea = rItem.pRightArea->Clone();
565 ScPageHFItem::~ScPageHFItem()
567 delete pLeftArea;
568 delete pCenterArea;
569 delete pRightArea;
572 bool ScPageHFItem::QueryValue( uno::Any& rVal, sal_uInt8 /* nMemberId */ ) const
574 uno::Reference<sheet::XHeaderFooterContent> xContent =
575 new ScHeaderFooterContentObj( pLeftArea, pCenterArea, pRightArea );
577 rVal <<= xContent;
578 return true;
581 bool ScPageHFItem::PutValue( const uno::Any& rVal, sal_uInt8 /* nMemberId */ )
583 bool bRet = false;
584 uno::Reference<sheet::XHeaderFooterContent> xContent;
585 if ( rVal >>= xContent )
587 if ( xContent.is() )
589 rtl::Reference<ScHeaderFooterContentObj> pImp =
590 ScHeaderFooterContentObj::getImplementation( xContent );
591 if (pImp.is())
593 const EditTextObject* pImpLeft = pImp->GetLeftEditObject();
594 delete pLeftArea;
595 pLeftArea = pImpLeft ? pImpLeft->Clone() : NULL;
597 const EditTextObject* pImpCenter = pImp->GetCenterEditObject();
598 delete pCenterArea;
599 pCenterArea = pImpCenter ? pImpCenter->Clone() : NULL;
601 const EditTextObject* pImpRight = pImp->GetRightEditObject();
602 delete pRightArea;
603 pRightArea = pImpRight ? pImpRight->Clone() : NULL;
605 if ( !pLeftArea || !pCenterArea || !pRightArea )
607 // no Text with Null are left
608 ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), true );
609 if (!pLeftArea)
610 pLeftArea = aEngine.CreateTextObject();
611 if (!pCenterArea)
612 pCenterArea = aEngine.CreateTextObject();
613 if (!pRightArea)
614 pRightArea = aEngine.CreateTextObject();
617 bRet = true;
622 if (!bRet)
624 OSL_FAIL("exception - wrong argument");
627 return true;
630 bool ScPageHFItem::operator==( const SfxPoolItem& rItem ) const
632 assert(SfxPoolItem::operator==(rItem));
634 const ScPageHFItem& r = static_cast<const ScPageHFItem&>(rItem);
636 return ScGlobal::EETextObjEqual(pLeftArea, r.pLeftArea)
637 && ScGlobal::EETextObjEqual(pCenterArea, r.pCenterArea)
638 && ScGlobal::EETextObjEqual(pRightArea, r.pRightArea);
641 SfxPoolItem* ScPageHFItem::Clone( SfxItemPool* ) const
643 return new ScPageHFItem( *this );
646 static void lcl_SetSpace( OUString& rStr, const ESelection& rSel )
648 // Text replaced by a space to ensure they are positions:
649 sal_Int32 nLen = rSel.nEndPos-rSel.nStartPos;
650 rStr = rStr.replaceAt( rSel.nStartPos, nLen, " " );
653 static bool lcl_ConvertFields(EditEngine& rEng, const OUString* pCommands)
655 bool bChange = false;
656 sal_Int32 nParCnt = rEng.GetParagraphCount();
657 for (sal_Int32 nPar = 0; nPar<nParCnt; nPar++)
659 OUString aStr = rEng.GetText( nPar );
660 sal_Int32 nPos;
662 while ((nPos = aStr.indexOf(pCommands[0])) != -1)
664 ESelection aSel( nPar,nPos, nPar,nPos+pCommands[0].getLength() );
665 rEng.QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), aSel );
666 lcl_SetSpace(aStr, aSel ); bChange = true;
668 while ((nPos = aStr.indexOf(pCommands[1])) != -1)
670 ESelection aSel( nPar,nPos, nPar,nPos+pCommands[1].getLength() );
671 rEng.QuickInsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), aSel );
672 lcl_SetSpace(aStr, aSel ); bChange = true;
674 while ((nPos = aStr.indexOf(pCommands[2])) != -1)
676 ESelection aSel( nPar,nPos, nPar,nPos+pCommands[2].getLength() );
677 rEng.QuickInsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SVXDATETYPE_VAR), EE_FEATURE_FIELD), aSel );
678 lcl_SetSpace(aStr, aSel ); bChange = true;
680 while ((nPos = aStr.indexOf(pCommands[3])) != -1)
682 ESelection aSel( nPar,nPos, nPar,nPos+pCommands[3].getLength() );
683 rEng.QuickInsertField( SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD ), aSel );
684 lcl_SetSpace(aStr, aSel ); bChange = true;
686 while ((nPos = aStr.indexOf(pCommands[4])) != -1)
688 ESelection aSel( nPar,nPos, nPar,nPos+pCommands[4].getLength() );
689 rEng.QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), aSel );
690 lcl_SetSpace(aStr, aSel ); bChange = true;
692 while ((nPos = aStr.indexOf(pCommands[5])) != -1)
694 ESelection aSel( nPar,nPos, nPar,nPos+pCommands[5].getLength() );
695 rEng.QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), aSel );
696 lcl_SetSpace(aStr, aSel ); bChange = true;
699 return bChange;
702 #define SC_FIELD_COUNT 6
704 SfxPoolItem* ScPageHFItem::Create( SvStream& rStream, sal_uInt16 nVer ) const
706 EditTextObject* pLeft = EditTextObject::Create(rStream);
707 EditTextObject* pCenter = EditTextObject::Create(rStream);
708 EditTextObject* pRight = EditTextObject::Create(rStream);
710 OSL_ENSURE( pLeft && pCenter && pRight, "Error reading ScPageHFItem" );
712 if ( pLeft == NULL || pLeft->GetParagraphCount() == 0 ||
713 pCenter == NULL || pCenter->GetParagraphCount() == 0 ||
714 pRight == NULL || pRight->GetParagraphCount() == 0 )
716 // If successfully loaded, each object contains at least one paragraph.
717 // Excel import in 5.1 created broken TextObjects (#67442#) that are
718 // corrected here to avoid saving wrong files again (#90487#).
719 ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), true );
720 if ( pLeft == NULL || pLeft->GetParagraphCount() == 0 )
722 delete pLeft;
723 pLeft = aEngine.CreateTextObject();
725 if ( pCenter == NULL || pCenter->GetParagraphCount() == 0 )
727 delete pCenter;
728 pCenter = aEngine.CreateTextObject();
730 if ( pRight == NULL || pRight->GetParagraphCount() == 0 )
732 delete pRight;
733 pRight = aEngine.CreateTextObject();
737 if ( nVer < 1 ) // old field command conversions
739 sal_uInt16 i;
740 const OUString& rDel = ScGlobal::GetRscString( STR_HFCMD_DELIMITER );
741 OUString aCommands[SC_FIELD_COUNT];
742 for (i=0; i<SC_FIELD_COUNT; i++)
743 aCommands[i] = rDel;
744 aCommands[0] += ScGlobal::GetRscString(STR_HFCMD_PAGE);
745 aCommands[1] += ScGlobal::GetRscString(STR_HFCMD_PAGES);
746 aCommands[2] += ScGlobal::GetRscString(STR_HFCMD_DATE);
747 aCommands[3] += ScGlobal::GetRscString(STR_HFCMD_TIME);
748 aCommands[4] += ScGlobal::GetRscString(STR_HFCMD_FILE);
749 aCommands[5] += ScGlobal::GetRscString(STR_HFCMD_TABLE);
750 for (i=0; i<SC_FIELD_COUNT; i++)
751 aCommands[i] += rDel;
753 ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), true );
754 aEngine.SetText(*pLeft);
755 if (lcl_ConvertFields(aEngine,aCommands))
757 delete pLeft;
758 pLeft = aEngine.CreateTextObject();
760 aEngine.SetText(*pCenter);
761 if (lcl_ConvertFields(aEngine,aCommands))
763 delete pCenter;
764 pCenter = aEngine.CreateTextObject();
766 aEngine.SetText(*pRight);
767 if (lcl_ConvertFields(aEngine,aCommands))
769 delete pRight;
770 pRight = aEngine.CreateTextObject();
773 else if ( nVer < 2 ) {} // nothing to do: SvxFileField is not exchanged for SvxExtFileField
775 ScPageHFItem* pItem = new ScPageHFItem( Which() );
776 pItem->SetArea( pLeft, SC_HF_LEFTAREA );
777 pItem->SetArea( pCenter, SC_HF_CENTERAREA );
778 pItem->SetArea( pRight, SC_HF_RIGHTAREA );
780 return pItem;
783 void ScPageHFItem::SetLeftArea( const EditTextObject& rNew )
785 delete pLeftArea;
786 pLeftArea = rNew.Clone();
789 void ScPageHFItem::SetCenterArea( const EditTextObject& rNew )
791 delete pCenterArea;
792 pCenterArea = rNew.Clone();
795 void ScPageHFItem::SetRightArea( const EditTextObject& rNew )
797 delete pRightArea;
798 pRightArea = rNew.Clone();
801 void ScPageHFItem::SetArea( EditTextObject *pNew, int nArea )
803 switch ( nArea )
805 case SC_HF_LEFTAREA: delete pLeftArea; pLeftArea = pNew; break;
806 case SC_HF_CENTERAREA: delete pCenterArea; pCenterArea = pNew; break;
807 case SC_HF_RIGHTAREA: delete pRightArea; pRightArea = pNew; break;
808 default:
809 OSL_FAIL( "New Area?" );
814 * ScViewObjectModeItem - Display Mode of View Objects
816 ScViewObjectModeItem::ScViewObjectModeItem( sal_uInt16 nWhichP )
817 : SfxEnumItem( nWhichP, VOBJ_MODE_SHOW )
821 ScViewObjectModeItem::ScViewObjectModeItem( sal_uInt16 nWhichP, ScVObjMode eMode )
822 : SfxEnumItem( nWhichP, sal::static_int_cast<sal_uInt16>(eMode) )
826 ScViewObjectModeItem::~ScViewObjectModeItem()
830 bool ScViewObjectModeItem::GetPresentation
832 SfxItemPresentation ePres,
833 SfxMapUnit /* eCoreUnit */,
834 SfxMapUnit /* ePresUnit */,
835 OUString& rText,
836 const IntlWrapper* /* pIntl */
837 ) const
839 OUString aDel(": ");
840 rText.clear();
842 switch ( ePres )
844 case SFX_ITEM_PRESENTATION_COMPLETE:
845 switch( Which() )
847 case SID_SCATTR_PAGE_CHARTS:
848 rText = ScGlobal::GetRscString(STR_VOBJ_CHART) + aDel;
849 break;
851 case SID_SCATTR_PAGE_OBJECTS:
852 rText = ScGlobal::GetRscString(STR_VOBJ_OBJECT) + aDel;
853 break;
855 case SID_SCATTR_PAGE_DRAWINGS:
856 rText = ScGlobal::GetRscString(STR_VOBJ_DRAWINGS) + aDel;
857 break;
859 default:
860 ePres = SFX_ITEM_PRESENTATION_NAMELESS; // Default setting!
861 break;
863 /* !!! fall-through !!! */
864 case SFX_ITEM_PRESENTATION_NAMELESS:
865 rText += ScGlobal::GetRscString(STR_VOBJ_MODE_SHOW+GetValue());
866 return true;
867 break;
869 default: break;
870 // added to avoid warnings
873 return false;
876 sal_uInt16 ScViewObjectModeItem::GetValueCount() const
878 return 2;
881 SfxPoolItem* ScViewObjectModeItem::Clone( SfxItemPool* ) const
883 return new ScViewObjectModeItem( *this );
886 sal_uInt16 ScViewObjectModeItem::GetVersion( sal_uInt16 /* nFileVersion */ ) const
888 return 1;
891 SfxPoolItem* ScViewObjectModeItem::Create(
892 SvStream& rStream,
893 sal_uInt16 nVersion ) const
895 if ( nVersion == 0 )
897 // Old Version with AllEnuItem -> produce with Mode "Show"
898 return new ScViewObjectModeItem( Which() );
900 else
902 sal_uInt16 nVal;
903 rStream.ReadUInt16( nVal );
905 //#i80528# adapt to new range eventually
906 if((sal_uInt16)VOBJ_MODE_HIDE < nVal) nVal = (sal_uInt16)VOBJ_MODE_SHOW;
908 return new ScViewObjectModeItem( Which(), (ScVObjMode)nVal);
913 * Double
915 ScDoubleItem::ScDoubleItem( sal_uInt16 nWhichP, double nVal )
916 : SfxPoolItem ( nWhichP ),
917 nValue ( nVal )
921 ScDoubleItem::ScDoubleItem( const ScDoubleItem& rItem )
922 : SfxPoolItem ( rItem )
924 nValue = rItem.nValue;
927 bool ScDoubleItem::operator==( const SfxPoolItem& rItem ) const
929 assert(SfxPoolItem::operator==(rItem));
930 const ScDoubleItem& _rItem = static_cast<const ScDoubleItem&>(rItem);
931 return nValue == _rItem.nValue;
934 SfxPoolItem* ScDoubleItem::Clone( SfxItemPool* ) const
936 return new ScDoubleItem( *this );
939 SfxPoolItem* ScDoubleItem::Create( SvStream& rStream, sal_uInt16 /* nVer */ ) const
941 double nTmp=0;
942 rStream.ReadDouble( nTmp );
944 ScDoubleItem* pItem = new ScDoubleItem( Which(), nTmp );
946 return pItem;
949 ScDoubleItem::~ScDoubleItem()
953 ScPageScaleToItem::ScPageScaleToItem() :
954 SfxPoolItem( ATTR_PAGE_SCALETO ),
955 mnWidth( 0 ),
956 mnHeight( 0 )
960 ScPageScaleToItem::ScPageScaleToItem( sal_uInt16 nWidth, sal_uInt16 nHeight ) :
961 SfxPoolItem( ATTR_PAGE_SCALETO ),
962 mnWidth( nWidth ),
963 mnHeight( nHeight )
967 ScPageScaleToItem::~ScPageScaleToItem()
971 ScPageScaleToItem* ScPageScaleToItem::Clone( SfxItemPool* ) const
973 return new ScPageScaleToItem( *this );
976 bool ScPageScaleToItem::operator==( const SfxPoolItem& rCmp ) const
978 assert(SfxPoolItem::operator==(rCmp));
979 const ScPageScaleToItem& rPageCmp = static_cast< const ScPageScaleToItem& >( rCmp );
980 return (mnWidth == rPageCmp.mnWidth) && (mnHeight == rPageCmp.mnHeight);
983 namespace {
984 void lclAppendScalePageCount( OUString& rText, sal_uInt16 nPages )
986 rText += ": ";
987 if( nPages )
989 OUString aPages( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_PAGES ) );
990 rText += aPages.replaceFirst( "%1", OUString::number( nPages ) );
992 else
993 rText += ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_AUTO );
995 } // namespace
997 bool ScPageScaleToItem::GetPresentation(
998 SfxItemPresentation ePres, SfxMapUnit, SfxMapUnit, OUString& rText, const IntlWrapper* ) const
1000 rText.clear();
1001 if( !IsValid())
1002 return false;
1004 OUString aName( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALETO ) );
1005 OUString aValue( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_WIDTH ) );
1006 lclAppendScalePageCount( aValue, mnWidth );
1007 aValue = aValue + ", " + ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_HEIGHT );
1008 lclAppendScalePageCount( aValue, mnHeight );
1010 switch( ePres )
1012 case SFX_ITEM_PRESENTATION_NAMELESS:
1013 rText = aValue;
1014 return true;
1015 break;
1017 case SFX_ITEM_PRESENTATION_COMPLETE:
1018 rText = aName + " (" + aValue + ")";
1019 return true;
1020 break;
1022 default:
1023 OSL_FAIL( "ScPageScaleToItem::GetPresentation - unknown presentation mode" );
1025 return false;
1028 bool ScPageScaleToItem::QueryValue( uno::Any& rAny, sal_uInt8 nMemberId ) const
1030 bool bRet = true;
1031 switch( nMemberId )
1033 case SC_MID_PAGE_SCALETO_WIDTH: rAny <<= mnWidth; break;
1034 case SC_MID_PAGE_SCALETO_HEIGHT: rAny <<= mnHeight; break;
1035 default:
1036 OSL_FAIL( "ScPageScaleToItem::QueryValue - unknown member ID" );
1037 bRet = false;
1039 return bRet;
1042 bool ScPageScaleToItem::PutValue( const uno::Any& rAny, sal_uInt8 nMemberId )
1044 bool bRet = false;
1045 switch( nMemberId )
1047 case SC_MID_PAGE_SCALETO_WIDTH: bRet = rAny >>= mnWidth; break;
1048 case SC_MID_PAGE_SCALETO_HEIGHT: bRet = rAny >>= mnHeight; break;
1049 default:
1050 OSL_FAIL( "ScPageScaleToItem::PutValue - unknown member ID" );
1052 return bRet;
1055 ScCondFormatItem::ScCondFormatItem():
1056 SfxPoolItem( ATTR_CONDITIONAL )
1060 ScCondFormatItem::ScCondFormatItem( const std::vector<sal_uInt32>& rIndex ):
1061 SfxPoolItem( ATTR_CONDITIONAL ),
1062 maIndex( rIndex )
1066 ScCondFormatItem::~ScCondFormatItem()
1070 bool ScCondFormatItem::operator==( const SfxPoolItem& rCmp ) const
1072 return maIndex == static_cast<const ScCondFormatItem&>(rCmp).maIndex;
1075 ScCondFormatItem* ScCondFormatItem::Clone(SfxItemPool*) const
1077 return new ScCondFormatItem(maIndex);
1080 void ScCondFormatItem::AddCondFormatData( sal_uInt32 nIndex )
1082 maIndex.push_back(nIndex);
1085 void ScCondFormatItem::SetCondFormatData( const std::vector<sal_uInt32>& rIndex )
1087 maIndex = rIndex;
1090 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */