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 //------------------------------------------------------------------------
46 TYPEINIT1(ScMergeAttr
, SfxPoolItem
);
47 TYPEINIT1_AUTOFACTORY(ScProtectionAttr
, SfxPoolItem
);
48 TYPEINIT1(ScRangeItem
, SfxPoolItem
);
49 TYPEINIT1(ScTableListItem
, SfxPoolItem
);
50 TYPEINIT1(ScPageHFItem
, SfxPoolItem
);
51 TYPEINIT1(ScViewObjectModeItem
, SfxEnumItem
);
52 TYPEINIT1(ScDoubleItem
, SfxPoolItem
);
53 TYPEINIT1(ScPageScaleToItem
, SfxPoolItem
);
54 TYPEINIT1(ScCondFormatItem
, SfxPoolItem
);
56 //------------------------------------------------------------------------
59 // General Help Function
62 bool ScHasPriority( const ::editeng::SvxBorderLine
* pThis
, const ::editeng::SvxBorderLine
* pOther
)
70 sal_uInt16 nThisSize
= pThis
->GetScaledWidth();
71 sal_uInt16 nOtherSize
= pOther
->GetScaledWidth();
73 if (nThisSize
> nOtherSize
)
75 else if (nThisSize
< nOtherSize
)
79 if ( pOther
->GetInWidth() && !pThis
->GetInWidth() )
81 else if ( pThis
->GetInWidth() && !pOther
->GetInWidth() )
92 // Item - Implementierungen
95 //------------------------------------------------------------------------
97 //------------------------------------------------------------------------
99 ScMergeAttr::ScMergeAttr():
100 SfxPoolItem(ATTR_MERGE
),
105 //------------------------------------------------------------------------
107 ScMergeAttr::ScMergeAttr( SCsCOL nCol
, SCsROW nRow
):
108 SfxPoolItem(ATTR_MERGE
),
113 //------------------------------------------------------------------------
115 ScMergeAttr::ScMergeAttr(const ScMergeAttr
& rItem
):
116 SfxPoolItem(ATTR_MERGE
)
118 nColMerge
= rItem
.nColMerge
;
119 nRowMerge
= rItem
.nRowMerge
;
122 ScMergeAttr::~ScMergeAttr()
126 //------------------------------------------------------------------------
128 OUString
ScMergeAttr::GetValueText() const
131 + OUString::number(static_cast<sal_Int32
>(nColMerge
))
133 + OUString::number(static_cast<sal_Int32
>(nRowMerge
))
138 //------------------------------------------------------------------------
140 int ScMergeAttr::operator==( const SfxPoolItem
& rItem
) const
142 OSL_ENSURE( Which() != rItem
.Which() || Type() == rItem
.Type(), "which ==, type !=" );
143 return (Which() == rItem
.Which())
144 && (nColMerge
== ((ScMergeAttr
&)rItem
).nColMerge
)
145 && (nRowMerge
== ((ScMergeAttr
&)rItem
).nRowMerge
);
148 //------------------------------------------------------------------------
150 SfxPoolItem
* ScMergeAttr::Clone( SfxItemPool
* ) const
152 return new ScMergeAttr(*this);
155 //------------------------------------------------------------------------
157 SfxPoolItem
* ScMergeAttr::Create( SvStream
& rStream
, sal_uInt16
/* nVer */ ) const
163 return new ScMergeAttr(static_cast<SCCOL
>(nCol
),static_cast<SCROW
>(nRow
));
166 //------------------------------------------------------------------------
168 //------------------------------------------------------------------------
170 ScMergeFlagAttr::ScMergeFlagAttr():
171 SfxInt16Item(ATTR_MERGE_FLAG
, 0)
175 //------------------------------------------------------------------------
177 ScMergeFlagAttr::ScMergeFlagAttr(sal_Int16 nFlags
):
178 SfxInt16Item(ATTR_MERGE_FLAG
, nFlags
)
182 ScMergeFlagAttr::~ScMergeFlagAttr()
186 bool ScMergeFlagAttr::HasPivotButton() const
188 return (GetValue() & SC_MF_BUTTON
) != 0;
191 bool ScMergeFlagAttr::HasPivotPopupButton() const
193 return (GetValue() & SC_MF_BUTTON_POPUP
) != 0;
196 //------------------------------------------------------------------------
198 //------------------------------------------------------------------------
200 ScProtectionAttr::ScProtectionAttr():
201 SfxPoolItem(ATTR_PROTECTION
),
209 //------------------------------------------------------------------------
211 ScProtectionAttr::ScProtectionAttr( bool bProtect
, bool bHFormula
,
212 bool bHCell
, bool bHPrint
):
213 SfxPoolItem(ATTR_PROTECTION
),
214 bProtection(bProtect
),
215 bHideFormula(bHFormula
),
221 //------------------------------------------------------------------------
223 ScProtectionAttr::ScProtectionAttr(const ScProtectionAttr
& rItem
):
224 SfxPoolItem(ATTR_PROTECTION
)
226 bProtection
= rItem
.bProtection
;
227 bHideFormula
= rItem
.bHideFormula
;
228 bHideCell
= rItem
.bHideCell
;
229 bHidePrint
= rItem
.bHidePrint
;
232 ScProtectionAttr::~ScProtectionAttr()
236 //------------------------------------------------------------------------
238 bool ScProtectionAttr::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
240 nMemberId
&= ~CONVERT_TWIPS
;
245 util::CellProtection aProtection
;
246 aProtection
.IsLocked
= bProtection
;
247 aProtection
.IsFormulaHidden
= bHideFormula
;
248 aProtection
.IsHidden
= bHideCell
;
249 aProtection
.IsPrintHidden
= bHidePrint
;
250 rVal
<<= aProtection
;
254 rVal
<<= (sal_Bool
) bProtection
; break;
256 rVal
<<= (sal_Bool
) bHideFormula
; break;
258 rVal
<<= (sal_Bool
) bHideCell
; break;
260 rVal
<<= (sal_Bool
) bHidePrint
; break;
262 OSL_FAIL("Wrong MemberID!");
269 bool ScProtectionAttr::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
272 sal_Bool bVal
= sal_False
;
273 nMemberId
&= ~CONVERT_TWIPS
;
278 util::CellProtection aProtection
;
279 if ( rVal
>>= aProtection
)
281 bProtection
= aProtection
.IsLocked
;
282 bHideFormula
= aProtection
.IsFormulaHidden
;
283 bHideCell
= aProtection
.IsHidden
;
284 bHidePrint
= aProtection
.IsPrintHidden
;
289 OSL_FAIL("exception - wrong argument");
294 bRet
= (rVal
>>= bVal
); if (bRet
) bProtection
=bVal
; break;
296 bRet
= (rVal
>>= bVal
); if (bRet
) bHideFormula
=bVal
; break;
298 bRet
= (rVal
>>= bVal
); if (bRet
) bHideCell
=bVal
; break;
300 bRet
= (rVal
>>= bVal
); if (bRet
) bHidePrint
=bVal
; break;
302 OSL_FAIL("Wrong MemberID!");
308 //------------------------------------------------------------------------
310 OUString
ScProtectionAttr::GetValueText() const
312 const OUString
aStrYes ( ScGlobal::GetRscString(STR_YES
) );
313 const OUString
aStrNo ( ScGlobal::GetRscString(STR_NO
) );
315 const OUString aValue
= "("
316 + (bProtection
? aStrYes
: aStrNo
)
318 + (bHideFormula
? aStrYes
: aStrNo
)
320 + (bHideCell
? aStrYes
: aStrNo
)
322 + (bHidePrint
? aStrYes
: aStrNo
)
328 //------------------------------------------------------------------------
330 SfxItemPresentation
ScProtectionAttr::GetPresentation
332 SfxItemPresentation ePres
,
333 SfxMapUnit
/* eCoreMetric */,
334 SfxMapUnit
/* ePresMetric */,
336 const IntlWrapper
* /* pIntl */
339 const OUString
aStrYes ( ScGlobal::GetRscString(STR_YES
) );
340 const OUString
aStrNo ( ScGlobal::GetRscString(STR_NO
) );
344 case SFX_ITEM_PRESENTATION_NONE
:
348 case SFX_ITEM_PRESENTATION_NAMELESS
:
349 rText
= GetValueText();
352 case SFX_ITEM_PRESENTATION_COMPLETE
:
353 rText
= ScGlobal::GetRscString(STR_PROTECTION
)
355 + (bProtection
? aStrYes
: aStrNo
)
357 + ScGlobal::GetRscString(STR_FORMULAS
)
359 + (!bHideFormula
? aStrYes
: aStrNo
)
361 + ScGlobal::GetRscString(STR_HIDE
)
363 + (bHideCell
? aStrYes
: aStrNo
)
365 + ScGlobal::GetRscString(STR_PRINT
)
367 + (!bHidePrint
? aStrYes
: aStrNo
);
371 ePres
= SFX_ITEM_PRESENTATION_NONE
;
377 //------------------------------------------------------------------------
379 int ScProtectionAttr::operator==( const SfxPoolItem
& rItem
) const
381 OSL_ENSURE( Which() != rItem
.Which() || Type() == rItem
.Type(), "which ==, type !=" );
382 return (Which() == rItem
.Which())
383 && (bProtection
== ((ScProtectionAttr
&)rItem
).bProtection
)
384 && (bHideFormula
== ((ScProtectionAttr
&)rItem
).bHideFormula
)
385 && (bHideCell
== ((ScProtectionAttr
&)rItem
).bHideCell
)
386 && (bHidePrint
== ((ScProtectionAttr
&)rItem
).bHidePrint
);
389 //------------------------------------------------------------------------
391 SfxPoolItem
* ScProtectionAttr::Clone( SfxItemPool
* ) const
393 return new ScProtectionAttr(*this);
396 //------------------------------------------------------------------------
398 SfxPoolItem
* ScProtectionAttr::Create( SvStream
& rStream
, sal_uInt16
/* n */ ) const
406 rStream
>> bHFormula
;
410 return new ScProtectionAttr(bProtect
,bHFormula
,bHCell
,bHPrint
);
413 //------------------------------------------------------------------------
415 bool ScProtectionAttr::SetProtection( bool bProtect
)
417 bProtection
= bProtect
;
421 //------------------------------------------------------------------------
423 bool ScProtectionAttr::SetHideFormula( bool bHFormula
)
425 bHideFormula
= bHFormula
;
429 //------------------------------------------------------------------------
431 bool ScProtectionAttr::SetHideCell( bool bHCell
)
437 //------------------------------------------------------------------------
439 bool ScProtectionAttr::SetHidePrint( bool bHPrint
)
441 bHidePrint
= bHPrint
;
445 // -----------------------------------------------------------------------
446 // ScRangeItem - Tabellenbereich
447 // -----------------------------------------------------------------------
449 int ScRangeItem::operator==( const SfxPoolItem
& rAttr
) const
451 OSL_ENSURE( SfxPoolItem::operator==(rAttr
), "unequal types" );
453 return ( aRange
== ( (ScRangeItem
&)rAttr
).aRange
);
456 // -----------------------------------------------------------------------
458 SfxPoolItem
* ScRangeItem::Clone( SfxItemPool
* ) const
460 return new ScRangeItem( *this );
463 //------------------------------------------------------------------------
465 SfxItemPresentation
ScRangeItem::GetPresentation
467 SfxItemPresentation ePres
,
468 SfxMapUnit
/* eCoreUnit */,
469 SfxMapUnit
/* ePresUnit */,
471 const IntlWrapper
* /* pIntl */
478 case SFX_ITEM_PRESENTATION_COMPLETE
:
479 rText
= ScGlobal::GetRscString(STR_AREA
) + ": ";
480 /* !!! fall-through !!! */
482 case SFX_ITEM_PRESENTATION_NAMELESS
:
484 /* Always use OOo:A1 format */
485 rText
+= aRange
.Format();
491 // added to avoid warnings
498 // -----------------------------------------------------------------------
499 // ScTableListItem - List from Tables (-numbers)
500 // -----------------------------------------------------------------------
502 ScTableListItem::ScTableListItem( const ScTableListItem
& rCpy
)
503 : SfxPoolItem ( rCpy
.Which() ),
504 nCount ( rCpy
.nCount
)
508 pTabArr
= new SCTAB
[nCount
];
510 for ( sal_uInt16 i
=0; i
<nCount
; i
++ )
511 pTabArr
[i
] = rCpy
.pTabArr
[i
];
517 // -----------------------------------------------------------------------
520 ScTableListItem::~ScTableListItem()
525 // -----------------------------------------------------------------------
527 ScTableListItem
& ScTableListItem::operator=( const ScTableListItem
& rCpy
)
531 if ( rCpy
.nCount
> 0 )
533 pTabArr
= new SCTAB
[rCpy
.nCount
];
534 for ( sal_uInt16 i
=0; i
<rCpy
.nCount
; i
++ )
535 pTabArr
[i
] = rCpy
.pTabArr
[i
];
540 nCount
= rCpy
.nCount
;
545 // -----------------------------------------------------------------------
547 int ScTableListItem::operator==( const SfxPoolItem
& rAttr
) const
549 OSL_ENSURE( SfxPoolItem::operator==(rAttr
), "unequal types" );
551 ScTableListItem
& rCmp
= (ScTableListItem
&)rAttr
;
552 bool bEqual
= (nCount
== rCmp
.nCount
);
558 bEqual
= ( pTabArr
&& rCmp
.pTabArr
);
560 while ( bEqual
&& i
<nCount
)
562 bEqual
= ( pTabArr
[i
] == rCmp
.pTabArr
[i
] );
569 // -----------------------------------------------------------------------
571 SfxPoolItem
* ScTableListItem::Clone( SfxItemPool
* ) const
573 return new ScTableListItem( *this );
576 //------------------------------------------------------------------------
578 SfxItemPresentation
ScTableListItem::GetPresentation
580 SfxItemPresentation ePres
,
581 SfxMapUnit
/* eCoreUnit */,
582 SfxMapUnit
/* ePresUnit */,
584 const IntlWrapper
* /* pIntl */
589 case SFX_ITEM_PRESENTATION_NONE
:
593 case SFX_ITEM_PRESENTATION_NAMELESS
:
596 if ( nCount
>0 && pTabArr
)
597 for ( sal_uInt16 i
=0; i
<nCount
; i
++ )
599 rText
+= OUString::number( pTabArr
[i
] );
607 case SFX_ITEM_PRESENTATION_COMPLETE
:
609 return SFX_ITEM_PRESENTATION_NONE
;
613 // added to avoid warnings
617 return SFX_ITEM_PRESENTATION_NONE
;
621 // -----------------------------------------------------------------------
622 // ScPageHFItem - Dates from the Head and Foot lines
623 // -----------------------------------------------------------------------
625 ScPageHFItem::ScPageHFItem( sal_uInt16 nWhichP
)
626 : SfxPoolItem ( nWhichP
),
628 pCenterArea ( NULL
),
633 //------------------------------------------------------------------------
635 ScPageHFItem::ScPageHFItem( const ScPageHFItem
& rItem
)
636 : SfxPoolItem ( rItem
),
638 pCenterArea ( NULL
),
641 if ( rItem
.pLeftArea
)
642 pLeftArea
= rItem
.pLeftArea
->Clone();
643 if ( rItem
.pCenterArea
)
644 pCenterArea
= rItem
.pCenterArea
->Clone();
645 if ( rItem
.pRightArea
)
646 pRightArea
= rItem
.pRightArea
->Clone();
649 //------------------------------------------------------------------------
651 ScPageHFItem::~ScPageHFItem()
658 //------------------------------------------------------------------------
660 bool ScPageHFItem::QueryValue( uno::Any
& rVal
, sal_uInt8
/* nMemberId */ ) const
662 uno::Reference
<sheet::XHeaderFooterContent
> xContent
=
663 new ScHeaderFooterContentObj( pLeftArea
, pCenterArea
, pRightArea
);
669 bool ScPageHFItem::PutValue( const uno::Any
& rVal
, sal_uInt8
/* nMemberId */ )
672 uno::Reference
<sheet::XHeaderFooterContent
> xContent
;
673 if ( rVal
>>= xContent
)
677 ScHeaderFooterContentObj
* pImp
=
678 ScHeaderFooterContentObj::getImplementation( xContent
);
681 const EditTextObject
* pImpLeft
= pImp
->GetLeftEditObject();
683 pLeftArea
= pImpLeft
? pImpLeft
->Clone() : NULL
;
685 const EditTextObject
* pImpCenter
= pImp
->GetCenterEditObject();
687 pCenterArea
= pImpCenter
? pImpCenter
->Clone() : NULL
;
689 const EditTextObject
* pImpRight
= pImp
->GetRightEditObject();
691 pRightArea
= pImpRight
? pImpRight
->Clone() : NULL
;
693 if ( !pLeftArea
|| !pCenterArea
|| !pRightArea
)
695 // no Text with Null are left
696 ScEditEngineDefaulter
aEngine( EditEngine::CreatePool(), true );
698 pLeftArea
= aEngine
.CreateTextObject();
700 pCenterArea
= aEngine
.CreateTextObject();
702 pRightArea
= aEngine
.CreateTextObject();
712 OSL_FAIL("exception - wrong argument");
718 //------------------------------------------------------------------------
720 OUString
ScPageHFItem::GetValueText() const
722 return OUString("ScPageHFItem");
725 //------------------------------------------------------------------------
727 int ScPageHFItem::operator==( const SfxPoolItem
& rItem
) const
729 OSL_ENSURE( SfxPoolItem::operator==( rItem
), "unequal Which or Type" );
731 const ScPageHFItem
& r
= (const ScPageHFItem
&)rItem
;
733 return ScGlobal::EETextObjEqual(pLeftArea
, r
.pLeftArea
)
734 && ScGlobal::EETextObjEqual(pCenterArea
, r
.pCenterArea
)
735 && ScGlobal::EETextObjEqual(pRightArea
, r
.pRightArea
);
738 //------------------------------------------------------------------------
740 SfxPoolItem
* ScPageHFItem::Clone( SfxItemPool
* ) const
742 return new ScPageHFItem( *this );
745 //------------------------------------------------------------------------
747 static void lcl_SetSpace( OUString
& rStr
, const ESelection
& rSel
)
749 // Text replaced by a space to ensure they are positions:
751 xub_StrLen nLen
= rSel
.nEndPos
-rSel
.nStartPos
;
752 rStr
= rStr
.replaceAt( rSel
.nStartPos
, nLen
, " " );
755 static bool lcl_ConvertFields(EditEngine
& rEng
, const OUString
* pCommands
)
757 bool bChange
= false;
758 sal_Int32 nParCnt
= rEng
.GetParagraphCount();
759 for (sal_Int32 nPar
= 0; nPar
<nParCnt
; nPar
++)
761 OUString aStr
= rEng
.GetText( nPar
);
764 while ((nPos
= aStr
.indexOf(pCommands
[0])) != -1)
766 ESelection
aSel( nPar
,nPos
, nPar
,nPos
+pCommands
[0].getLength() );
767 rEng
.QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD
), aSel
);
768 lcl_SetSpace(aStr
, aSel
); bChange
= true;
770 while ((nPos
= aStr
.indexOf(pCommands
[1])) != -1)
772 ESelection
aSel( nPar
,nPos
, nPar
,nPos
+pCommands
[1].getLength() );
773 rEng
.QuickInsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD
), aSel
);
774 lcl_SetSpace(aStr
, aSel
); bChange
= true;
776 while ((nPos
= aStr
.indexOf(pCommands
[2])) != -1)
778 ESelection
aSel( nPar
,nPos
, nPar
,nPos
+pCommands
[2].getLength() );
779 rEng
.QuickInsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM
),SVXDATETYPE_VAR
), EE_FEATURE_FIELD
), aSel
);
780 lcl_SetSpace(aStr
, aSel
); bChange
= true;
782 while ((nPos
= aStr
.indexOf(pCommands
[3])) != -1)
784 ESelection
aSel( nPar
,nPos
, nPar
,nPos
+pCommands
[3].getLength() );
785 rEng
.QuickInsertField( SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD
), aSel
);
786 lcl_SetSpace(aStr
, aSel
); bChange
= true;
788 while ((nPos
= aStr
.indexOf(pCommands
[4])) != -1)
790 ESelection
aSel( nPar
,nPos
, nPar
,nPos
+pCommands
[4].getLength() );
791 rEng
.QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD
), aSel
);
792 lcl_SetSpace(aStr
, aSel
); bChange
= true;
794 while ((nPos
= aStr
.indexOf(pCommands
[5])) != -1)
796 ESelection
aSel( nPar
,nPos
, nPar
,nPos
+pCommands
[5].getLength() );
797 rEng
.QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD
), aSel
);
798 lcl_SetSpace(aStr
, aSel
); bChange
= true;
804 #define SC_FIELD_COUNT 6
806 SfxPoolItem
* ScPageHFItem::Create( SvStream
& rStream
, sal_uInt16 nVer
) const
808 EditTextObject
* pLeft
= EditTextObject::Create(rStream
);
809 EditTextObject
* pCenter
= EditTextObject::Create(rStream
);
810 EditTextObject
* pRight
= EditTextObject::Create(rStream
);
812 OSL_ENSURE( pLeft
&& pCenter
&& pRight
, "Error reading ScPageHFItem" );
814 if ( pLeft
== NULL
|| pLeft
->GetParagraphCount() == 0 ||
815 pCenter
== NULL
|| pCenter
->GetParagraphCount() == 0 ||
816 pRight
== NULL
|| pRight
->GetParagraphCount() == 0 )
818 // If successfully loaded, each object contains at least one paragraph.
819 // Excel import in 5.1 created broken TextObjects (#67442#) that are
820 // corrected here to avoid saving wrong files again (#90487#).
822 ScEditEngineDefaulter
aEngine( EditEngine::CreatePool(), true );
823 if ( pLeft
== NULL
|| pLeft
->GetParagraphCount() == 0 )
826 pLeft
= aEngine
.CreateTextObject();
828 if ( pCenter
== NULL
|| pCenter
->GetParagraphCount() == 0 )
831 pCenter
= aEngine
.CreateTextObject();
833 if ( pRight
== NULL
|| pRight
->GetParagraphCount() == 0 )
836 pRight
= aEngine
.CreateTextObject();
840 if ( nVer
< 1 ) //old field command conversions
843 const OUString
& rDel
= ScGlobal::GetRscString( STR_HFCMD_DELIMITER
);
844 OUString aCommands
[SC_FIELD_COUNT
];
845 for (i
=0; i
<SC_FIELD_COUNT
; i
++)
847 aCommands
[0] += ScGlobal::GetRscString(STR_HFCMD_PAGE
);
848 aCommands
[1] += ScGlobal::GetRscString(STR_HFCMD_PAGES
);
849 aCommands
[2] += ScGlobal::GetRscString(STR_HFCMD_DATE
);
850 aCommands
[3] += ScGlobal::GetRscString(STR_HFCMD_TIME
);
851 aCommands
[4] += ScGlobal::GetRscString(STR_HFCMD_FILE
);
852 aCommands
[5] += ScGlobal::GetRscString(STR_HFCMD_TABLE
);
853 for (i
=0; i
<SC_FIELD_COUNT
; i
++)
854 aCommands
[i
] += rDel
;
856 ScEditEngineDefaulter
aEngine( EditEngine::CreatePool(), true );
857 aEngine
.SetText(*pLeft
);
858 if (lcl_ConvertFields(aEngine
,aCommands
))
861 pLeft
= aEngine
.CreateTextObject();
863 aEngine
.SetText(*pCenter
);
864 if (lcl_ConvertFields(aEngine
,aCommands
))
867 pCenter
= aEngine
.CreateTextObject();
869 aEngine
.SetText(*pRight
);
870 if (lcl_ConvertFields(aEngine
,aCommands
))
873 pRight
= aEngine
.CreateTextObject();
877 { // not to do, SvxFileField is not exchanged for SvxExtFileField
880 ScPageHFItem
* pItem
= new ScPageHFItem( Which() );
881 pItem
->SetArea( pLeft
, SC_HF_LEFTAREA
);
882 pItem
->SetArea( pCenter
, SC_HF_CENTERAREA
);
883 pItem
->SetArea( pRight
, SC_HF_RIGHTAREA
);
888 //------------------------------------------------------------------------
891 void ScPageHFItem::SetLeftArea( const EditTextObject
& rNew
)
894 pLeftArea
= rNew
.Clone();
897 //------------------------------------------------------------------------
899 void ScPageHFItem::SetCenterArea( const EditTextObject
& rNew
)
902 pCenterArea
= rNew
.Clone();
905 //------------------------------------------------------------------------
907 void ScPageHFItem::SetRightArea( const EditTextObject
& rNew
)
910 pRightArea
= rNew
.Clone();
913 void ScPageHFItem::SetArea( EditTextObject
*pNew
, int nArea
)
917 case SC_HF_LEFTAREA
: delete pLeftArea
; pLeftArea
= pNew
; break;
918 case SC_HF_CENTERAREA
: delete pCenterArea
; pCenterArea
= pNew
; break;
919 case SC_HF_RIGHTAREA
: delete pRightArea
; pRightArea
= pNew
; break;
921 OSL_FAIL( "New Area?" );
925 //-----------------------------------------------------------------------
926 // ScViewObjectModeItem - Display Mode of View Objects
927 //-----------------------------------------------------------------------
929 ScViewObjectModeItem::ScViewObjectModeItem( sal_uInt16 nWhichP
)
930 : SfxEnumItem( nWhichP
, VOBJ_MODE_SHOW
)
934 //------------------------------------------------------------------------
936 ScViewObjectModeItem::ScViewObjectModeItem( sal_uInt16 nWhichP
, ScVObjMode eMode
)
937 : SfxEnumItem( nWhichP
, sal::static_int_cast
<sal_uInt16
>(eMode
) )
941 //------------------------------------------------------------------------
943 ScViewObjectModeItem::~ScViewObjectModeItem()
947 //------------------------------------------------------------------------
949 SfxItemPresentation
ScViewObjectModeItem::GetPresentation
951 SfxItemPresentation ePres
,
952 SfxMapUnit
/* eCoreUnit */,
953 SfxMapUnit
/* ePresUnit */,
955 const IntlWrapper
* /* pIntl */
963 case SFX_ITEM_PRESENTATION_COMPLETE
:
966 case SID_SCATTR_PAGE_CHARTS
:
967 rText
= ScGlobal::GetRscString(STR_VOBJ_CHART
) + aDel
;
970 case SID_SCATTR_PAGE_OBJECTS
:
971 rText
= ScGlobal::GetRscString(STR_VOBJ_OBJECT
) + aDel
;
974 case SID_SCATTR_PAGE_DRAWINGS
:
975 rText
= ScGlobal::GetRscString(STR_VOBJ_DRAWINGS
) + aDel
;
979 ePres
= SFX_ITEM_PRESENTATION_NAMELESS
;//this always goes!
982 /* !!! fall-through !!! */
984 case SFX_ITEM_PRESENTATION_NAMELESS
:
985 rText
+= ScGlobal::GetRscString(STR_VOBJ_MODE_SHOW
+GetValue());
990 // added to avoid warnings
997 //------------------------------------------------------------------------
999 OUString
ScViewObjectModeItem::GetValueText( sal_uInt16 nVal
) const
1001 OSL_ENSURE( nVal
<= VOBJ_MODE_HIDE
, "enum overflow!" );
1003 return ScGlobal::GetRscString( STR_VOBJ_MODE_SHOW
+ (nVal
% 2));
1006 //------------------------------------------------------------------------
1008 sal_uInt16
ScViewObjectModeItem::GetValueCount() const
1013 //------------------------------------------------------------------------
1015 SfxPoolItem
* ScViewObjectModeItem::Clone( SfxItemPool
* ) const
1017 return new ScViewObjectModeItem( *this );
1020 //------------------------------------------------------------------------
1022 sal_uInt16
ScViewObjectModeItem::GetVersion( sal_uInt16
/* nFileVersion */ ) const
1027 //------------------------------------------------------------------------
1029 SfxPoolItem
* ScViewObjectModeItem::Create(
1031 sal_uInt16 nVersion
) const
1033 if ( nVersion
== 0 )
1035 // Old Version with AllEnuItem -> produce with Mode "Show"
1036 return new ScViewObjectModeItem( Which() );
1043 //#i80528# adapt to new range eventually
1044 if((sal_uInt16
)VOBJ_MODE_HIDE
< nVal
) nVal
= (sal_uInt16
)VOBJ_MODE_SHOW
;
1046 return new ScViewObjectModeItem( Which(), (ScVObjMode
)nVal
);
1050 // -----------------------------------------------------------------------
1052 // -----------------------------------------------------------------------
1054 ScDoubleItem::ScDoubleItem( sal_uInt16 nWhichP
, double nVal
)
1055 : SfxPoolItem ( nWhichP
),
1060 //------------------------------------------------------------------------
1062 ScDoubleItem::ScDoubleItem( const ScDoubleItem
& rItem
)
1063 : SfxPoolItem ( rItem
)
1065 nValue
= rItem
.nValue
;
1068 //------------------------------------------------------------------------
1070 OUString
ScDoubleItem::GetValueText() const
1072 return OUString("ScDoubleItem");
1075 //------------------------------------------------------------------------
1077 int ScDoubleItem::operator==( const SfxPoolItem
& rItem
) const
1079 OSL_ENSURE( SfxPoolItem::operator==( rItem
), "unequal Which or Type" );
1080 const ScDoubleItem
& _rItem
= (const ScDoubleItem
&)rItem
;
1081 return int(nValue
== _rItem
.nValue
);
1084 //------------------------------------------------------------------------
1086 SfxPoolItem
* ScDoubleItem::Clone( SfxItemPool
* ) const
1088 return new ScDoubleItem( *this );
1091 //------------------------------------------------------------------------
1093 SfxPoolItem
* ScDoubleItem::Create( SvStream
& rStream
, sal_uInt16
/* nVer */ ) const
1098 ScDoubleItem
* pItem
= new ScDoubleItem( Which(), nTmp
);
1103 //------------------------------------------------------------------------
1105 ScDoubleItem::~ScDoubleItem()
1110 // ============================================================================
1112 ScPageScaleToItem::ScPageScaleToItem() :
1113 SfxPoolItem( ATTR_PAGE_SCALETO
),
1119 ScPageScaleToItem::ScPageScaleToItem( sal_uInt16 nWidth
, sal_uInt16 nHeight
) :
1120 SfxPoolItem( ATTR_PAGE_SCALETO
),
1126 ScPageScaleToItem::~ScPageScaleToItem()
1130 ScPageScaleToItem
* ScPageScaleToItem::Clone( SfxItemPool
* ) const
1132 return new ScPageScaleToItem( *this );
1135 int ScPageScaleToItem::operator==( const SfxPoolItem
& rCmp
) const
1137 OSL_ENSURE( SfxPoolItem::operator==( rCmp
), "ScPageScaleToItem::operator== - unequal wid or type" );
1138 const ScPageScaleToItem
& rPageCmp
= static_cast< const ScPageScaleToItem
& >( rCmp
);
1139 return ((mnWidth
== rPageCmp
.mnWidth
) && (mnHeight
== rPageCmp
.mnHeight
)) ? 1 : 0;
1143 void lclAppendScalePageCount( OUString
& rText
, sal_uInt16 nPages
)
1148 OUString
aPages( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_PAGES
) );
1149 rText
+= aPages
.replaceFirst( "%1", OUString::number( nPages
) );
1152 rText
+= ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_AUTO
);
1156 SfxItemPresentation
ScPageScaleToItem::GetPresentation(
1157 SfxItemPresentation ePres
, SfxMapUnit
, SfxMapUnit
, OUString
& rText
, const IntlWrapper
* ) const
1160 if( !IsValid() || (ePres
== SFX_ITEM_PRESENTATION_NONE
) )
1161 return SFX_ITEM_PRESENTATION_NONE
;
1163 OUString
aName( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALETO
) );
1164 OUString
aValue( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_WIDTH
) );
1165 lclAppendScalePageCount( aValue
, mnWidth
);
1166 aValue
= aValue
+ ", " + ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_HEIGHT
);
1167 lclAppendScalePageCount( aValue
, mnHeight
);
1171 case SFX_ITEM_PRESENTATION_NONE
:
1174 case SFX_ITEM_PRESENTATION_NAMEONLY
:
1178 case SFX_ITEM_PRESENTATION_NAMELESS
:
1182 case SFX_ITEM_PRESENTATION_COMPLETE
:
1183 rText
= aName
+ " (" + aValue
+ ")";
1187 OSL_FAIL( "ScPageScaleToItem::GetPresentation - unknown presentation mode" );
1188 ePres
= SFX_ITEM_PRESENTATION_NONE
;
1193 bool ScPageScaleToItem::QueryValue( uno::Any
& rAny
, sal_uInt8 nMemberId
) const
1198 case SC_MID_PAGE_SCALETO_WIDTH
: rAny
<<= mnWidth
; break;
1199 case SC_MID_PAGE_SCALETO_HEIGHT
: rAny
<<= mnHeight
; break;
1201 OSL_FAIL( "ScPageScaleToItem::QueryValue - unknown member ID" );
1207 bool ScPageScaleToItem::PutValue( const uno::Any
& rAny
, sal_uInt8 nMemberId
)
1212 case SC_MID_PAGE_SCALETO_WIDTH
: bRet
= rAny
>>= mnWidth
; break;
1213 case SC_MID_PAGE_SCALETO_HEIGHT
: bRet
= rAny
>>= mnHeight
; break;
1215 OSL_FAIL( "ScPageScaleToItem::PutValue - unknown member ID" );
1220 // ============================================================================
1222 ScCondFormatItem::ScCondFormatItem():
1223 SfxPoolItem( ATTR_CONDITIONAL
)
1227 ScCondFormatItem::ScCondFormatItem( const std::vector
<sal_uInt32
>& rIndex
):
1228 SfxPoolItem( ATTR_CONDITIONAL
),
1233 ScCondFormatItem::~ScCondFormatItem()
1237 int ScCondFormatItem::operator==( const SfxPoolItem
& rCmp
) const
1239 return maIndex
== static_cast<const ScCondFormatItem
&>(rCmp
).maIndex
;
1242 ScCondFormatItem
* ScCondFormatItem::Clone(SfxItemPool
*) const
1244 return new ScCondFormatItem(maIndex
);
1247 const std::vector
<sal_uInt32
>& ScCondFormatItem::GetCondFormatData() const
1252 void ScCondFormatItem::AddCondFormatData( sal_uInt32 nIndex
)
1254 maIndex
.push_back(nIndex
);
1257 void ScCondFormatItem::SetCondFormatData( const std::vector
<sal_uInt32
>& rIndex
)
1263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */