1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
36 #include "editutil.hxx"
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
);
55 * General Help Function
57 bool ScHasPriority( const ::editeng::SvxBorderLine
* pThis
, const ::editeng::SvxBorderLine
* pOther
)
65 sal_uInt16 nThisSize
= pThis
->GetScaledWidth();
66 sal_uInt16 nOtherSize
= pOther
->GetScaledWidth();
68 if (nThisSize
> nOtherSize
)
70 else if (nThisSize
< nOtherSize
)
74 if ( pOther
->GetInWidth() && !pThis
->GetInWidth() )
76 else if ( pThis
->GetInWidth() && !pOther
->GetInWidth() )
80 return true; // FIXME: What is this?
85 /** Item - Implementations */
90 ScMergeAttr::ScMergeAttr():
91 SfxPoolItem(ATTR_MERGE
),
96 ScMergeAttr::ScMergeAttr( SCsCOL nCol
, SCsROW nRow
):
97 SfxPoolItem(ATTR_MERGE
),
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
130 rStream
.ReadInt16( nCol
);
131 rStream
.ReadInt16( nRow
);
132 return new ScMergeAttr(static_cast<SCCOL
>(nCol
),static_cast<SCROW
>(nRow
));
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;
170 ScProtectionAttr::ScProtectionAttr():
171 SfxPoolItem(ATTR_PROTECTION
),
179 ScProtectionAttr::ScProtectionAttr( bool bProtect
, bool bHFormula
,
180 bool bHCell
, bool bHPrint
):
181 SfxPoolItem(ATTR_PROTECTION
),
182 bProtection(bProtect
),
183 bHideFormula(bHFormula
),
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
;
209 util::CellProtection aProtection
;
210 aProtection
.IsLocked
= bProtection
;
211 aProtection
.IsFormulaHidden
= bHideFormula
;
212 aProtection
.IsHidden
= bHideCell
;
213 aProtection
.IsPrintHidden
= bHidePrint
;
214 rVal
<<= aProtection
;
218 rVal
<<= bProtection
; break;
220 rVal
<<= bHideFormula
; break;
222 rVal
<<= bHideCell
; break;
224 rVal
<<= bHidePrint
; break;
226 OSL_FAIL("Wrong MemberID!");
233 bool ScProtectionAttr::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
237 nMemberId
&= ~CONVERT_TWIPS
;
242 util::CellProtection aProtection
;
243 if ( rVal
>>= aProtection
)
245 bProtection
= aProtection
.IsLocked
;
246 bHideFormula
= aProtection
.IsFormulaHidden
;
247 bHideCell
= aProtection
.IsHidden
;
248 bHidePrint
= aProtection
.IsPrintHidden
;
253 OSL_FAIL("exception - wrong argument");
258 bRet
= (rVal
>>= bVal
); if (bRet
) bProtection
=bVal
; break;
260 bRet
= (rVal
>>= bVal
); if (bRet
) bHideFormula
=bVal
; break;
262 bRet
= (rVal
>>= bVal
); if (bRet
) bHideCell
=bVal
; break;
264 bRet
= (rVal
>>= bVal
); if (bRet
) bHidePrint
=bVal
; break;
266 OSL_FAIL("Wrong MemberID!");
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
)
280 + (bHideFormula
? aStrYes
: aStrNo
)
282 + (bHideCell
? aStrYes
: aStrNo
)
284 + (bHidePrint
? aStrYes
: aStrNo
)
290 bool ScProtectionAttr::GetPresentation
292 SfxItemPresentation ePres
,
293 SfxMapUnit
/* eCoreMetric */,
294 SfxMapUnit
/* ePresMetric */,
296 const IntlWrapper
* /* pIntl */
299 const OUString
aStrYes ( ScGlobal::GetRscString(STR_YES
) );
300 const OUString
aStrNo ( ScGlobal::GetRscString(STR_NO
) );
304 case SFX_ITEM_PRESENTATION_NAMELESS
:
305 rText
= GetValueText();
308 case SFX_ITEM_PRESENTATION_COMPLETE
:
309 rText
= ScGlobal::GetRscString(STR_PROTECTION
)
311 + (bProtection
? aStrYes
: aStrNo
)
313 + ScGlobal::GetRscString(STR_FORMULAS
)
315 + (!bHideFormula
? aStrYes
: aStrNo
)
317 + ScGlobal::GetRscString(STR_HIDE
)
319 + (bHideCell
? aStrYes
: aStrNo
)
321 + ScGlobal::GetRscString(STR_PRINT
)
323 + (!bHidePrint
? aStrYes
: aStrNo
);
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
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
;
368 bool ScProtectionAttr::SetHideFormula( bool bHFormula
)
370 bHideFormula
= bHFormula
;
374 bool ScProtectionAttr::SetHideCell( bool bHCell
)
380 bool ScProtectionAttr::SetHidePrint( bool bHPrint
)
382 bHidePrint
= bHPrint
;
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 */,
407 const IntlWrapper
* /* pIntl */
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();
427 // added to avoid warnings
435 * ScTableListItem - List from Tables (-numbers)
437 ScTableListItem::ScTableListItem( const ScTableListItem
& rCpy
)
438 : SfxPoolItem ( rCpy
.Which() ),
439 nCount ( rCpy
.nCount
)
443 pTabArr
= new SCTAB
[nCount
];
445 for ( sal_uInt16 i
=0; i
<nCount
; i
++ )
446 pTabArr
[i
] = rCpy
.pTabArr
[i
];
452 ScTableListItem::~ScTableListItem()
457 ScTableListItem
& ScTableListItem::operator=( const ScTableListItem
& rCpy
)
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
];
470 nCount
= rCpy
.nCount
;
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
);
486 bEqual
= ( pTabArr
&& rCmp
.pTabArr
);
488 while ( bEqual
&& i
<nCount
)
490 bEqual
= ( pTabArr
[i
] == rCmp
.pTabArr
[i
] );
497 SfxPoolItem
* ScTableListItem::Clone( SfxItemPool
* ) const
499 return new ScTableListItem( *this );
502 bool ScTableListItem::GetPresentation
504 SfxItemPresentation ePres
,
505 SfxMapUnit
/* eCoreUnit */,
506 SfxMapUnit
/* ePresUnit */,
508 const IntlWrapper
* /* pIntl */
513 case SFX_ITEM_PRESENTATION_NAMELESS
:
516 if ( nCount
>0 && pTabArr
)
517 for ( sal_uInt16 i
=0; i
<nCount
; i
++ )
519 rText
+= OUString::number( pTabArr
[i
] );
527 case SFX_ITEM_PRESENTATION_COMPLETE
:
533 // added to avoid warnings
541 * ScPageHFItem - Dates from the Head and Foot lines
543 ScPageHFItem::ScPageHFItem( sal_uInt16 nWhichP
)
544 : SfxPoolItem ( nWhichP
),
546 pCenterArea ( NULL
),
551 ScPageHFItem::ScPageHFItem( const ScPageHFItem
& rItem
)
552 : SfxPoolItem ( rItem
),
554 pCenterArea ( 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()
572 bool ScPageHFItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/* nMemberId */ ) const
574 uno::Reference
<sheet::XHeaderFooterContent
> xContent
=
575 new ScHeaderFooterContentObj( pLeftArea
, pCenterArea
, pRightArea
);
581 bool ScPageHFItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/* nMemberId */ )
584 uno::Reference
<sheet::XHeaderFooterContent
> xContent
;
585 if ( rVal
>>= xContent
)
589 rtl::Reference
<ScHeaderFooterContentObj
> pImp
=
590 ScHeaderFooterContentObj::getImplementation( xContent
);
593 const EditTextObject
* pImpLeft
= pImp
->GetLeftEditObject();
595 pLeftArea
= pImpLeft
? pImpLeft
->Clone() : NULL
;
597 const EditTextObject
* pImpCenter
= pImp
->GetCenterEditObject();
599 pCenterArea
= pImpCenter
? pImpCenter
->Clone() : NULL
;
601 const EditTextObject
* pImpRight
= pImp
->GetRightEditObject();
603 pRightArea
= pImpRight
? pImpRight
->Clone() : NULL
;
605 if ( !pLeftArea
|| !pCenterArea
|| !pRightArea
)
607 // no Text with Null are left
608 ScEditEngineDefaulter
aEngine( EditEngine::CreatePool(), true );
610 pLeftArea
= aEngine
.CreateTextObject();
612 pCenterArea
= aEngine
.CreateTextObject();
614 pRightArea
= aEngine
.CreateTextObject();
624 OSL_FAIL("exception - wrong argument");
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
);
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;
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 )
723 pLeft
= aEngine
.CreateTextObject();
725 if ( pCenter
== NULL
|| pCenter
->GetParagraphCount() == 0 )
728 pCenter
= aEngine
.CreateTextObject();
730 if ( pRight
== NULL
|| pRight
->GetParagraphCount() == 0 )
733 pRight
= aEngine
.CreateTextObject();
737 if ( nVer
< 1 ) // old field command conversions
740 const OUString
& rDel
= ScGlobal::GetRscString( STR_HFCMD_DELIMITER
);
741 OUString aCommands
[SC_FIELD_COUNT
];
742 for (i
=0; i
<SC_FIELD_COUNT
; i
++)
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
))
758 pLeft
= aEngine
.CreateTextObject();
760 aEngine
.SetText(*pCenter
);
761 if (lcl_ConvertFields(aEngine
,aCommands
))
764 pCenter
= aEngine
.CreateTextObject();
766 aEngine
.SetText(*pRight
);
767 if (lcl_ConvertFields(aEngine
,aCommands
))
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
);
783 void ScPageHFItem::SetLeftArea( const EditTextObject
& rNew
)
786 pLeftArea
= rNew
.Clone();
789 void ScPageHFItem::SetCenterArea( const EditTextObject
& rNew
)
792 pCenterArea
= rNew
.Clone();
795 void ScPageHFItem::SetRightArea( const EditTextObject
& rNew
)
798 pRightArea
= rNew
.Clone();
801 void ScPageHFItem::SetArea( EditTextObject
*pNew
, int 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;
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 */,
836 const IntlWrapper
* /* pIntl */
844 case SFX_ITEM_PRESENTATION_COMPLETE
:
847 case SID_SCATTR_PAGE_CHARTS
:
848 rText
= ScGlobal::GetRscString(STR_VOBJ_CHART
) + aDel
;
851 case SID_SCATTR_PAGE_OBJECTS
:
852 rText
= ScGlobal::GetRscString(STR_VOBJ_OBJECT
) + aDel
;
855 case SID_SCATTR_PAGE_DRAWINGS
:
856 rText
= ScGlobal::GetRscString(STR_VOBJ_DRAWINGS
) + aDel
;
860 ePres
= SFX_ITEM_PRESENTATION_NAMELESS
; // Default setting!
863 /* !!! fall-through !!! */
864 case SFX_ITEM_PRESENTATION_NAMELESS
:
865 rText
+= ScGlobal::GetRscString(STR_VOBJ_MODE_SHOW
+GetValue());
870 // added to avoid warnings
876 sal_uInt16
ScViewObjectModeItem::GetValueCount() const
881 SfxPoolItem
* ScViewObjectModeItem::Clone( SfxItemPool
* ) const
883 return new ScViewObjectModeItem( *this );
886 sal_uInt16
ScViewObjectModeItem::GetVersion( sal_uInt16
/* nFileVersion */ ) const
891 SfxPoolItem
* ScViewObjectModeItem::Create(
893 sal_uInt16 nVersion
) const
897 // Old Version with AllEnuItem -> produce with Mode "Show"
898 return new ScViewObjectModeItem( Which() );
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
);
915 ScDoubleItem::ScDoubleItem( sal_uInt16 nWhichP
, double nVal
)
916 : SfxPoolItem ( nWhichP
),
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
942 rStream
.ReadDouble( nTmp
);
944 ScDoubleItem
* pItem
= new ScDoubleItem( Which(), nTmp
);
949 ScDoubleItem::~ScDoubleItem()
953 ScPageScaleToItem::ScPageScaleToItem() :
954 SfxPoolItem( ATTR_PAGE_SCALETO
),
960 ScPageScaleToItem::ScPageScaleToItem( sal_uInt16 nWidth
, sal_uInt16 nHeight
) :
961 SfxPoolItem( ATTR_PAGE_SCALETO
),
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
);
984 void lclAppendScalePageCount( OUString
& rText
, sal_uInt16 nPages
)
989 OUString
aPages( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_PAGES
) );
990 rText
+= aPages
.replaceFirst( "%1", OUString::number( nPages
) );
993 rText
+= ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_AUTO
);
997 bool ScPageScaleToItem::GetPresentation(
998 SfxItemPresentation ePres
, SfxMapUnit
, SfxMapUnit
, OUString
& rText
, const IntlWrapper
* ) const
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
);
1012 case SFX_ITEM_PRESENTATION_NAMELESS
:
1017 case SFX_ITEM_PRESENTATION_COMPLETE
:
1018 rText
= aName
+ " (" + aValue
+ ")";
1023 OSL_FAIL( "ScPageScaleToItem::GetPresentation - unknown presentation mode" );
1028 bool ScPageScaleToItem::QueryValue( uno::Any
& rAny
, sal_uInt8 nMemberId
) const
1033 case SC_MID_PAGE_SCALETO_WIDTH
: rAny
<<= mnWidth
; break;
1034 case SC_MID_PAGE_SCALETO_HEIGHT
: rAny
<<= mnHeight
; break;
1036 OSL_FAIL( "ScPageScaleToItem::QueryValue - unknown member ID" );
1042 bool ScPageScaleToItem::PutValue( const uno::Any
& rAny
, sal_uInt8 nMemberId
)
1047 case SC_MID_PAGE_SCALETO_WIDTH
: bRet
= rAny
>>= mnWidth
; break;
1048 case SC_MID_PAGE_SCALETO_HEIGHT
: bRet
= rAny
>>= mnHeight
; break;
1050 OSL_FAIL( "ScPageScaleToItem::PutValue - unknown member ID" );
1055 ScCondFormatItem::ScCondFormatItem():
1056 SfxPoolItem( ATTR_CONDITIONAL
)
1060 ScCondFormatItem::ScCondFormatItem( const std::vector
<sal_uInt32
>& rIndex
):
1061 SfxPoolItem( ATTR_CONDITIONAL
),
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
)
1090 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */