1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: attrib.cxx,v $
10 * $Revision: 1.19.32.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
39 #include <com/sun/star/util/CellProtection.hpp>
40 #include <com/sun/star/util/XProtectable.hpp>
41 #include <com/sun/star/text/XText.hpp>
42 #include <com/sun/star/beans/XPropertySet.hpp>
44 #include "scitems.hxx"
45 #include <svx/eeitem.hxx>
47 #include <svx/boxitem.hxx>
48 #include <svx/editdata.hxx>
49 #include <svx/editeng.hxx>
50 #include <svx/editobj.hxx>
51 #include <svx/flditem.hxx>
55 #include "editutil.hxx"
57 #include "globstr.hrc"
59 #include "textuno.hxx" // ScHeaderFooterContentObj
61 using namespace com::sun::star
;
63 //------------------------------------------------------------------------
65 TYPEINIT1(ScMergeAttr
, SfxPoolItem
);
66 TYPEINIT1_AUTOFACTORY(ScProtectionAttr
, SfxPoolItem
);
67 TYPEINIT1(ScRangeItem
, SfxPoolItem
);
68 TYPEINIT1(ScTableListItem
, SfxPoolItem
);
69 TYPEINIT1(ScPageHFItem
, SfxPoolItem
);
70 TYPEINIT1(ScViewObjectModeItem
, SfxEnumItem
);
71 TYPEINIT1(ScDoubleItem
, SfxPoolItem
);
72 TYPEINIT1(ScPageScaleToItem
, SfxPoolItem
);
74 //------------------------------------------------------------------------
77 // allgemeine Hilfsfunktionen
80 BOOL
ScHasPriority( const SvxBorderLine
* pThis
, const SvxBorderLine
* pOther
)
82 // DBG_ASSERT( pThis || pOther, "LineAttr == 0" );
89 USHORT nThisSize
= pThis
->GetOutWidth() + pThis
->GetDistance() + pThis
->GetInWidth();
90 USHORT nOtherSize
= pOther
->GetOutWidth() + pOther
->GetDistance() + pOther
->GetInWidth();
92 if (nThisSize
> nOtherSize
)
94 else if (nThisSize
< nOtherSize
)
98 if ( pOther
->GetInWidth() && !pThis
->GetInWidth() )
100 else if ( pThis
->GetInWidth() && !pOther
->GetInWidth() )
111 // Item - Implementierungen
114 //------------------------------------------------------------------------
116 //------------------------------------------------------------------------
118 ScMergeAttr::ScMergeAttr():
119 SfxPoolItem(ATTR_MERGE
),
124 //------------------------------------------------------------------------
126 ScMergeAttr::ScMergeAttr( SCsCOL nCol
, SCsROW nRow
):
127 SfxPoolItem(ATTR_MERGE
),
132 //------------------------------------------------------------------------
134 ScMergeAttr::ScMergeAttr(const ScMergeAttr
& rItem
):
135 SfxPoolItem(ATTR_MERGE
)
137 nColMerge
= rItem
.nColMerge
;
138 nRowMerge
= rItem
.nRowMerge
;
141 ScMergeAttr::~ScMergeAttr()
145 //------------------------------------------------------------------------
147 String
ScMergeAttr::GetValueText() const
149 String
aString( '(' );
150 aString
+= String::CreateFromInt32( nColMerge
);
152 aString
+= String::CreateFromInt32( nRowMerge
);
157 //------------------------------------------------------------------------
159 int ScMergeAttr::operator==( const SfxPoolItem
& rItem
) const
161 DBG_ASSERT( Which() != rItem
.Which() || Type() == rItem
.Type(), "which ==, type !=" );
162 return (Which() == rItem
.Which())
163 && (nColMerge
== ((ScMergeAttr
&)rItem
).nColMerge
)
164 && (nRowMerge
== ((ScMergeAttr
&)rItem
).nRowMerge
);
167 //------------------------------------------------------------------------
169 SfxPoolItem
* ScMergeAttr::Clone( SfxItemPool
* ) const
171 return new ScMergeAttr(*this);
174 //------------------------------------------------------------------------
176 SfxPoolItem
* ScMergeAttr::Create( SvStream
& rStream
, USHORT
/* nVer */ ) const
182 return new ScMergeAttr(static_cast<SCCOL
>(nCol
),static_cast<SCROW
>(nRow
));
185 //------------------------------------------------------------------------
187 //------------------------------------------------------------------------
189 ScMergeFlagAttr::ScMergeFlagAttr():
190 SfxInt16Item(ATTR_MERGE_FLAG
, 0)
194 //------------------------------------------------------------------------
196 ScMergeFlagAttr::ScMergeFlagAttr(INT16 nFlags
):
197 SfxInt16Item(ATTR_MERGE_FLAG
, nFlags
)
201 ScMergeFlagAttr::~ScMergeFlagAttr()
205 //------------------------------------------------------------------------
207 //------------------------------------------------------------------------
209 ScProtectionAttr::ScProtectionAttr():
210 SfxPoolItem(ATTR_PROTECTION
),
218 //------------------------------------------------------------------------
220 ScProtectionAttr::ScProtectionAttr( BOOL bProtect
, BOOL bHFormula
,
221 BOOL bHCell
, BOOL bHPrint
):
222 SfxPoolItem(ATTR_PROTECTION
),
223 bProtection(bProtect
),
224 bHideFormula(bHFormula
),
230 //------------------------------------------------------------------------
232 ScProtectionAttr::ScProtectionAttr(const ScProtectionAttr
& rItem
):
233 SfxPoolItem(ATTR_PROTECTION
)
235 bProtection
= rItem
.bProtection
;
236 bHideFormula
= rItem
.bHideFormula
;
237 bHideCell
= rItem
.bHideCell
;
238 bHidePrint
= rItem
.bHidePrint
;
241 ScProtectionAttr::~ScProtectionAttr()
245 //------------------------------------------------------------------------
247 BOOL
ScProtectionAttr::QueryValue( uno::Any
& rVal
, BYTE nMemberId
) const
249 nMemberId
&= ~CONVERT_TWIPS
;
254 util::CellProtection aProtection
;
255 aProtection
.IsLocked
= bProtection
;
256 aProtection
.IsFormulaHidden
= bHideFormula
;
257 aProtection
.IsHidden
= bHideCell
;
258 aProtection
.IsPrintHidden
= bHidePrint
;
259 rVal
<<= aProtection
;
263 rVal
<<= (sal_Bool
) bProtection
; break;
265 rVal
<<= (sal_Bool
) bHideFormula
; break;
267 rVal
<<= (sal_Bool
) bHideCell
; break;
269 rVal
<<= (sal_Bool
) bHidePrint
; break;
271 DBG_ERROR("Wrong MemberID!");
278 BOOL
ScProtectionAttr::PutValue( const uno::Any
& rVal
, BYTE nMemberId
)
281 sal_Bool bVal
= sal_Bool();
282 nMemberId
&= ~CONVERT_TWIPS
;
287 util::CellProtection aProtection
;
288 if ( rVal
>>= aProtection
)
290 bProtection
= aProtection
.IsLocked
;
291 bHideFormula
= aProtection
.IsFormulaHidden
;
292 bHideCell
= aProtection
.IsHidden
;
293 bHidePrint
= aProtection
.IsPrintHidden
;
298 DBG_ERROR("exception - wrong argument");
303 bRet
= (rVal
>>= bVal
); if (bRet
) bProtection
=bVal
; break;
305 bRet
= (rVal
>>= bVal
); if (bRet
) bHideFormula
=bVal
; break;
307 bRet
= (rVal
>>= bVal
); if (bRet
) bHideCell
=bVal
; break;
309 bRet
= (rVal
>>= bVal
); if (bRet
) bHidePrint
=bVal
; break;
311 DBG_ERROR("Wrong MemberID!");
317 //------------------------------------------------------------------------
319 String
ScProtectionAttr::GetValueText() const
322 String
aStrYes ( ScGlobal::GetRscString(STR_YES
) );
323 String
aStrNo ( ScGlobal::GetRscString(STR_NO
) );
324 sal_Unicode cDelim
= ',';
327 aValue
+= (bProtection
? aStrYes
: aStrNo
); aValue
+= cDelim
;
328 aValue
+= (bHideFormula
? aStrYes
: aStrNo
); aValue
+= cDelim
;
329 aValue
+= (bHideCell
? aStrYes
: aStrNo
); aValue
+= cDelim
;
330 aValue
+= (bHidePrint
? aStrYes
: aStrNo
);
336 //------------------------------------------------------------------------
338 SfxItemPresentation
ScProtectionAttr::GetPresentation
340 SfxItemPresentation ePres
,
341 SfxMapUnit
/* eCoreMetric */,
342 SfxMapUnit
/* ePresMetric */,
344 const IntlWrapper
* /* pIntl */
347 String
aStrYes ( ScGlobal::GetRscString(STR_YES
) );
348 String
aStrNo ( ScGlobal::GetRscString(STR_NO
) );
349 String aStrSep
= String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
350 String aStrDelim
= String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( ", " ));
354 case SFX_ITEM_PRESENTATION_NONE
:
358 case SFX_ITEM_PRESENTATION_NAMELESS
:
359 rText
= GetValueText();
362 case SFX_ITEM_PRESENTATION_COMPLETE
:
363 rText
= ScGlobal::GetRscString(STR_PROTECTION
); rText
+= aStrSep
;
364 rText
+= (bProtection
? aStrYes
: aStrNo
); rText
+= aStrDelim
;
365 rText
+= ScGlobal::GetRscString(STR_FORMULAS
); rText
+= aStrSep
;
366 rText
+= (!bHideFormula
? aStrYes
: aStrNo
); rText
+= aStrDelim
;
367 rText
+= ScGlobal::GetRscString(STR_HIDE
); rText
+= aStrSep
;
368 rText
+= (bHideCell
? aStrYes
: aStrNo
); rText
+= aStrDelim
;
369 rText
+= ScGlobal::GetRscString(STR_PRINT
); rText
+= aStrSep
;
370 rText
+= (!bHidePrint
? aStrYes
: aStrNo
);
374 ePres
= SFX_ITEM_PRESENTATION_NONE
;
380 //------------------------------------------------------------------------
382 int ScProtectionAttr::operator==( const SfxPoolItem
& rItem
) const
384 DBG_ASSERT( Which() != rItem
.Which() || Type() == rItem
.Type(), "which ==, type !=" );
385 return (Which() == rItem
.Which())
386 && (bProtection
== ((ScProtectionAttr
&)rItem
).bProtection
)
387 && (bHideFormula
== ((ScProtectionAttr
&)rItem
).bHideFormula
)
388 && (bHideCell
== ((ScProtectionAttr
&)rItem
).bHideCell
)
389 && (bHidePrint
== ((ScProtectionAttr
&)rItem
).bHidePrint
);
392 //------------------------------------------------------------------------
394 SfxPoolItem
* ScProtectionAttr::Clone( SfxItemPool
* ) const
396 return new ScProtectionAttr(*this);
399 //------------------------------------------------------------------------
401 SfxPoolItem
* ScProtectionAttr::Create( SvStream
& rStream
, USHORT
/* n */ ) const
409 rStream
>> bHFormula
;
413 return new ScProtectionAttr(bProtect
,bHFormula
,bHCell
,bHPrint
);
416 //------------------------------------------------------------------------
418 BOOL
ScProtectionAttr::SetProtection( BOOL bProtect
)
420 bProtection
= bProtect
;
424 //------------------------------------------------------------------------
426 BOOL
ScProtectionAttr::SetHideFormula( BOOL bHFormula
)
428 bHideFormula
= bHFormula
;
432 //------------------------------------------------------------------------
434 BOOL
ScProtectionAttr::SetHideCell( BOOL bHCell
)
440 //------------------------------------------------------------------------
442 BOOL
ScProtectionAttr::SetHidePrint( BOOL bHPrint
)
444 bHidePrint
= bHPrint
;
448 // -----------------------------------------------------------------------
449 // ScRangeItem - Tabellenbereich
450 // -----------------------------------------------------------------------
452 int ScRangeItem::operator==( const SfxPoolItem
& rAttr
) const
454 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
456 return ( aRange
== ( (ScRangeItem
&)rAttr
).aRange
);
459 // -----------------------------------------------------------------------
461 SfxPoolItem
* ScRangeItem::Clone( SfxItemPool
* ) const
463 return new ScRangeItem( *this );
466 //------------------------------------------------------------------------
468 SfxItemPresentation
ScRangeItem::GetPresentation
470 SfxItemPresentation ePres
,
471 SfxMapUnit
/* eCoreUnit */,
472 SfxMapUnit
/* ePresUnit */,
474 const IntlWrapper
* /* pIntl */
481 case SFX_ITEM_PRESENTATION_COMPLETE
:
482 rText
= ScGlobal::GetRscString(STR_AREA
);
483 rText
.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
484 // break;// Durchfallen !!!
486 case SFX_ITEM_PRESENTATION_NAMELESS
:
489 /* Always use OOo:A1 format */
490 aRange
.Format( aText
);
497 // added to avoid warnings
504 // -----------------------------------------------------------------------
505 // ScTableListItem - Liste von Tabellen(-nummern)
506 // -----------------------------------------------------------------------
508 ScTableListItem::ScTableListItem( const ScTableListItem
& rCpy
)
509 : SfxPoolItem ( rCpy
.Which() ),
510 nCount ( rCpy
.nCount
)
514 pTabArr
= new SCTAB
[nCount
];
516 for ( USHORT i
=0; i
<nCount
; i
++ )
517 pTabArr
[i
] = rCpy
.pTabArr
[i
];
523 // -----------------------------------------------------------------------
525 //UNUSED2008-05 ScTableListItem::ScTableListItem( const USHORT nWhichP, const List& rList )
526 //UNUSED2008-05 : SfxPoolItem ( nWhichP ),
527 //UNUSED2008-05 nCount ( 0 ),
528 //UNUSED2008-05 pTabArr ( NULL )
530 //UNUSED2008-05 SetTableList( rList );
533 // -----------------------------------------------------------------------
535 ScTableListItem::~ScTableListItem()
540 // -----------------------------------------------------------------------
542 ScTableListItem
& ScTableListItem::operator=( const ScTableListItem
& rCpy
)
546 if ( rCpy
.nCount
> 0 )
548 pTabArr
= new SCTAB
[rCpy
.nCount
];
549 for ( USHORT i
=0; i
<rCpy
.nCount
; i
++ )
550 pTabArr
[i
] = rCpy
.pTabArr
[i
];
555 nCount
= rCpy
.nCount
;
560 // -----------------------------------------------------------------------
562 int ScTableListItem::operator==( const SfxPoolItem
& rAttr
) const
564 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
566 ScTableListItem
& rCmp
= (ScTableListItem
&)rAttr
;
567 BOOL bEqual
= (nCount
== rCmp
.nCount
);
573 bEqual
= ( pTabArr
&& rCmp
.pTabArr
);
575 while ( bEqual
&& i
<nCount
)
577 bEqual
= ( pTabArr
[i
] == rCmp
.pTabArr
[i
] );
584 // -----------------------------------------------------------------------
586 SfxPoolItem
* ScTableListItem::Clone( SfxItemPool
* ) const
588 return new ScTableListItem( *this );
591 //------------------------------------------------------------------------
593 SfxItemPresentation
ScTableListItem::GetPresentation
595 SfxItemPresentation ePres
,
596 SfxMapUnit
/* eCoreUnit */,
597 SfxMapUnit
/* ePresUnit */,
599 const IntlWrapper
* /* pIntl */
602 const sal_Unicode cDelim
= ',';
606 case SFX_ITEM_PRESENTATION_NONE
:
610 case SFX_ITEM_PRESENTATION_NAMELESS
:
613 if ( nCount
>0 && pTabArr
)
614 for ( USHORT i
=0; i
<nCount
; i
++ )
616 rText
+= String::CreateFromInt32( pTabArr
[i
] );
624 case SFX_ITEM_PRESENTATION_COMPLETE
:
626 return SFX_ITEM_PRESENTATION_NONE
;
630 // added to avoid warnings
634 return SFX_ITEM_PRESENTATION_NONE
;
637 // -----------------------------------------------------------------------
639 //UNUSED2009-05 BOOL ScTableListItem::GetTableList( List& aList ) const
641 //UNUSED2009-05 for ( USHORT i=0; i<nCount; i++ )
642 //UNUSED2009-05 aList.Insert( new SCTAB( pTabArr[i] ) );
644 //UNUSED2009-05 return ( nCount > 0 );
647 // -----------------------------------------------------------------------
649 //UNUSED2009-05 void ScTableListItem::SetTableList( const List& rList )
651 //UNUSED2009-05 nCount = (USHORT)rList.Count();
653 //UNUSED2009-05 delete [] pTabArr;
655 //UNUSED2009-05 if ( nCount > 0 )
657 //UNUSED2009-05 pTabArr = new SCTAB [nCount];
659 //UNUSED2009-05 for ( USHORT i=0; i<nCount; i++ )
660 //UNUSED2009-05 pTabArr[i] = *( (SCTAB*)rList.GetObject( i ) );
663 //UNUSED2009-05 pTabArr = NULL;
667 // -----------------------------------------------------------------------
668 // ScPageHFItem - Daten der Kopf-/Fusszeilen
669 // -----------------------------------------------------------------------
671 ScPageHFItem::ScPageHFItem( USHORT nWhichP
)
672 : SfxPoolItem ( nWhichP
),
674 pCenterArea ( NULL
),
679 //------------------------------------------------------------------------
681 ScPageHFItem::ScPageHFItem( const ScPageHFItem
& rItem
)
682 : SfxPoolItem ( rItem
),
684 pCenterArea ( NULL
),
687 if ( rItem
.pLeftArea
)
688 pLeftArea
= rItem
.pLeftArea
->Clone();
689 if ( rItem
.pCenterArea
)
690 pCenterArea
= rItem
.pCenterArea
->Clone();
691 if ( rItem
.pRightArea
)
692 pRightArea
= rItem
.pRightArea
->Clone();
695 //------------------------------------------------------------------------
697 ScPageHFItem::~ScPageHFItem()
704 //------------------------------------------------------------------------
706 BOOL
ScPageHFItem::QueryValue( uno::Any
& rVal
, BYTE
/* nMemberId */ ) const
708 uno::Reference
<sheet::XHeaderFooterContent
> xContent
=
709 new ScHeaderFooterContentObj( pLeftArea
, pCenterArea
, pRightArea
);
715 BOOL
ScPageHFItem::PutValue( const uno::Any
& rVal
, BYTE
/* nMemberId */ )
718 uno::Reference
<sheet::XHeaderFooterContent
> xContent
;
719 if ( rVal
>>= xContent
)
723 ScHeaderFooterContentObj
* pImp
=
724 ScHeaderFooterContentObj::getImplementation( xContent
);
727 const EditTextObject
* pImpLeft
= pImp
->GetLeftEditObject();
729 pLeftArea
= pImpLeft
? pImpLeft
->Clone() : NULL
;
731 const EditTextObject
* pImpCenter
= pImp
->GetCenterEditObject();
733 pCenterArea
= pImpCenter
? pImpCenter
->Clone() : NULL
;
735 const EditTextObject
* pImpRight
= pImp
->GetRightEditObject();
737 pRightArea
= pImpRight
? pImpRight
->Clone() : NULL
;
739 if ( !pLeftArea
|| !pCenterArea
|| !pRightArea
)
741 // keine Texte auf NULL stehen lassen
742 ScEditEngineDefaulter
aEngine( EditEngine::CreatePool(), TRUE
);
744 pLeftArea
= aEngine
.CreateTextObject();
746 pCenterArea
= aEngine
.CreateTextObject();
748 pRightArea
= aEngine
.CreateTextObject();
758 DBG_ERROR("exception - wrong argument");
764 //------------------------------------------------------------------------
766 String
ScPageHFItem::GetValueText() const
768 return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScPageHFItem"));
771 //------------------------------------------------------------------------
773 int ScPageHFItem::operator==( const SfxPoolItem
& rItem
) const
775 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal Which or Type" );
777 const ScPageHFItem
& r
= (const ScPageHFItem
&)rItem
;
779 return ScGlobal::EETextObjEqual(pLeftArea
, r
.pLeftArea
)
780 && ScGlobal::EETextObjEqual(pCenterArea
, r
.pCenterArea
)
781 && ScGlobal::EETextObjEqual(pRightArea
, r
.pRightArea
);
784 //------------------------------------------------------------------------
786 SfxPoolItem
* ScPageHFItem::Clone( SfxItemPool
* ) const
788 return new ScPageHFItem( *this );
791 //------------------------------------------------------------------------
793 void lcl_SetSpace( String
& rStr
, const ESelection
& rSel
)
795 // Text durch ein Leerzeichen ersetzen, damit Positionen stimmen:
797 xub_StrLen nLen
= rSel
.nEndPos
-rSel
.nStartPos
;
798 rStr
.Erase( rSel
.nStartPos
, nLen
-1 );
799 rStr
.SetChar( rSel
.nStartPos
, ' ' );
802 BOOL
lcl_ConvertFields(EditEngine
& rEng
, const String
* pCommands
)
804 BOOL bChange
= FALSE
;
805 USHORT nParCnt
= rEng
.GetParagraphCount();
806 for (USHORT nPar
= 0; nPar
<nParCnt
; nPar
++)
808 String aStr
= rEng
.GetText( nPar
);
811 while ((nPos
= aStr
.Search(pCommands
[0])) != STRING_NOTFOUND
)
813 ESelection
aSel( nPar
,nPos
, nPar
,nPos
+pCommands
[0].Len() );
814 rEng
.QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD
), aSel
);
815 lcl_SetSpace(aStr
, aSel
); bChange
= TRUE
;
817 while ((nPos
= aStr
.Search(pCommands
[1])) != STRING_NOTFOUND
)
819 ESelection
aSel( nPar
,nPos
, nPar
,nPos
+pCommands
[1].Len() );
820 rEng
.QuickInsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD
), aSel
);
821 lcl_SetSpace(aStr
, aSel
); bChange
= TRUE
;
823 while ((nPos
= aStr
.Search(pCommands
[2])) != STRING_NOTFOUND
)
825 ESelection
aSel( nPar
,nPos
, nPar
,nPos
+pCommands
[2].Len() );
826 rEng
.QuickInsertField( SvxFieldItem(SvxDateField(Date(),SVXDATETYPE_VAR
), EE_FEATURE_FIELD
), aSel
);
827 lcl_SetSpace(aStr
, aSel
); bChange
= TRUE
;
829 while ((nPos
= aStr
.Search(pCommands
[3])) != STRING_NOTFOUND
)
831 ESelection
aSel( nPar
,nPos
, nPar
,nPos
+pCommands
[3].Len() );
832 rEng
.QuickInsertField( SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD
), aSel
);
833 lcl_SetSpace(aStr
, aSel
); bChange
= TRUE
;
835 while ((nPos
= aStr
.Search(pCommands
[4])) != STRING_NOTFOUND
)
837 ESelection
aSel( nPar
,nPos
, nPar
,nPos
+pCommands
[4].Len() );
838 rEng
.QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD
), aSel
);
839 lcl_SetSpace(aStr
, aSel
); bChange
= TRUE
;
841 while ((nPos
= aStr
.Search(pCommands
[5])) != STRING_NOTFOUND
)
843 ESelection
aSel( nPar
,nPos
, nPar
,nPos
+pCommands
[5].Len() );
844 rEng
.QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD
), aSel
);
845 lcl_SetSpace(aStr
, aSel
); bChange
= TRUE
;
851 #define SC_FIELD_COUNT 6
853 SfxPoolItem
* ScPageHFItem::Create( SvStream
& rStream
, USHORT nVer
) const
855 EditTextObject
* pLeft
= EditTextObject::Create(rStream
);
856 EditTextObject
* pCenter
= EditTextObject::Create(rStream
);
857 EditTextObject
* pRight
= EditTextObject::Create(rStream
);
859 DBG_ASSERT( pLeft
&& pCenter
&& pRight
, "Error reading ScPageHFItem" );
861 if ( pLeft
== NULL
|| pLeft
->GetParagraphCount() == 0 ||
862 pCenter
== NULL
|| pCenter
->GetParagraphCount() == 0 ||
863 pRight
== NULL
|| pRight
->GetParagraphCount() == 0 )
865 // If successfully loaded, each object contains at least one paragraph.
866 // Excel import in 5.1 created broken TextObjects (#67442#) that are
867 // corrected here to avoid saving wrong files again (#90487#).
869 ScEditEngineDefaulter
aEngine( EditEngine::CreatePool(), TRUE
);
870 if ( pLeft
== NULL
|| pLeft
->GetParagraphCount() == 0 )
873 pLeft
= aEngine
.CreateTextObject();
875 if ( pCenter
== NULL
|| pCenter
->GetParagraphCount() == 0 )
878 pCenter
= aEngine
.CreateTextObject();
880 if ( pRight
== NULL
|| pRight
->GetParagraphCount() == 0 )
883 pRight
= aEngine
.CreateTextObject();
887 if ( nVer
< 1 ) // alte Feldbefehle umsetzen
890 const String
& rDel
= ScGlobal::GetRscString( STR_HFCMD_DELIMITER
);
891 String aCommands
[SC_FIELD_COUNT
];
892 for (i
=0; i
<SC_FIELD_COUNT
; i
++)
894 aCommands
[0] += ScGlobal::GetRscString(STR_HFCMD_PAGE
);
895 aCommands
[1] += ScGlobal::GetRscString(STR_HFCMD_PAGES
);
896 aCommands
[2] += ScGlobal::GetRscString(STR_HFCMD_DATE
);
897 aCommands
[3] += ScGlobal::GetRscString(STR_HFCMD_TIME
);
898 aCommands
[4] += ScGlobal::GetRscString(STR_HFCMD_FILE
);
899 aCommands
[5] += ScGlobal::GetRscString(STR_HFCMD_TABLE
);
900 for (i
=0; i
<SC_FIELD_COUNT
; i
++)
901 aCommands
[i
] += rDel
;
903 ScEditEngineDefaulter
aEngine( EditEngine::CreatePool(), TRUE
);
904 aEngine
.SetText(*pLeft
);
905 if (lcl_ConvertFields(aEngine
,aCommands
))
908 pLeft
= aEngine
.CreateTextObject();
910 aEngine
.SetText(*pCenter
);
911 if (lcl_ConvertFields(aEngine
,aCommands
))
914 pCenter
= aEngine
.CreateTextObject();
916 aEngine
.SetText(*pRight
);
917 if (lcl_ConvertFields(aEngine
,aCommands
))
920 pRight
= aEngine
.CreateTextObject();
924 { // nichts tun, SvxFileField nicht gegen SvxExtFileField austauschen
927 ScPageHFItem
* pItem
= new ScPageHFItem( Which() );
928 pItem
->SetArea( pLeft
, SC_HF_LEFTAREA
);
929 pItem
->SetArea( pCenter
, SC_HF_CENTERAREA
);
930 pItem
->SetArea( pRight
, SC_HF_RIGHTAREA
);
935 //------------------------------------------------------------------------
937 //UNUSED2009-05 class ScFieldChangerEditEngine : public ScEditEngineDefaulter
939 //UNUSED2009-05 TypeId aExtFileId;
940 //UNUSED2009-05 USHORT nConvPara;
941 //UNUSED2009-05 xub_StrLen nConvPos;
942 //UNUSED2009-05 BOOL bConvert;
944 //UNUSED2009-05 public:
945 //UNUSED2009-05 ScFieldChangerEditEngine( SfxItemPool* pEnginePool, BOOL bDeleteEnginePool );
946 //UNUSED2009-05 virtual ~ScFieldChangerEditEngine() {}
948 //UNUSED2009-05 virtual String CalcFieldValue( const SvxFieldItem& rField, USHORT nPara,
949 //UNUSED2009-05 USHORT nPos, Color*& rTxtColor,
950 //UNUSED2009-05 Color*& rFldColor );
952 //UNUSED2009-05 BOOL ConvertFields();
955 //UNUSED2009-05 ScFieldChangerEditEngine::ScFieldChangerEditEngine( SfxItemPool* pEnginePoolP,
956 //UNUSED2009-05 BOOL bDeleteEnginePoolP ) :
957 //UNUSED2009-05 ScEditEngineDefaulter( pEnginePoolP, bDeleteEnginePoolP ),
958 //UNUSED2009-05 aExtFileId( TYPE( SvxExtFileField ) ),
959 //UNUSED2009-05 nConvPara( 0 ),
960 //UNUSED2009-05 nConvPos( 0 ),
961 //UNUSED2009-05 bConvert( FALSE )
965 //UNUSED2009-05 String ScFieldChangerEditEngine::CalcFieldValue( const SvxFieldItem& rField,
966 //UNUSED2009-05 USHORT nPara, USHORT nPos, Color*& /* rTxtColor */, Color*& /* rFldColor */ )
968 //UNUSED2009-05 const SvxFieldData* pFieldData = rField.GetField();
969 //UNUSED2009-05 if ( pFieldData && pFieldData->Type() == aExtFileId )
971 //UNUSED2009-05 bConvert = TRUE;
972 //UNUSED2009-05 nConvPara = nPara;
973 //UNUSED2009-05 nConvPos = nPos;
975 //UNUSED2009-05 return EMPTY_STRING;
978 //UNUSED2009-05 BOOL ScFieldChangerEditEngine::ConvertFields()
980 //UNUSED2009-05 BOOL bConverted = FALSE;
983 //UNUSED2009-05 bConvert = FALSE;
984 //UNUSED2009-05 UpdateFields();
985 //UNUSED2009-05 if ( bConvert )
987 //UNUSED2009-05 ESelection aSel( nConvPara, nConvPos, nConvPara, nConvPos+1 );
988 //UNUSED2009-05 QuickInsertField( SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD), aSel );
989 //UNUSED2009-05 bConverted = TRUE;
991 //UNUSED2009-05 } while ( bConvert );
992 //UNUSED2009-05 return bConverted;
995 void ScPageHFItem::SetLeftArea( const EditTextObject
& rNew
)
998 pLeftArea
= rNew
.Clone();
1001 //------------------------------------------------------------------------
1003 void ScPageHFItem::SetCenterArea( const EditTextObject
& rNew
)
1006 pCenterArea
= rNew
.Clone();
1009 //------------------------------------------------------------------------
1011 void ScPageHFItem::SetRightArea( const EditTextObject
& rNew
)
1014 pRightArea
= rNew
.Clone();
1017 void ScPageHFItem::SetArea( EditTextObject
*pNew
, int nArea
)
1021 case SC_HF_LEFTAREA
: delete pLeftArea
; pLeftArea
= pNew
; break;
1022 case SC_HF_CENTERAREA
: delete pCenterArea
; pCenterArea
= pNew
; break;
1023 case SC_HF_RIGHTAREA
: delete pRightArea
; pRightArea
= pNew
; break;
1025 DBG_ERROR( "New Area?" );
1029 //-----------------------------------------------------------------------
1030 // ScViewObjectModeItem - Darstellungsmodus von ViewObjekten
1031 //-----------------------------------------------------------------------
1033 ScViewObjectModeItem::ScViewObjectModeItem( USHORT nWhichP
)
1034 : SfxEnumItem( nWhichP
, VOBJ_MODE_SHOW
)
1038 //------------------------------------------------------------------------
1040 ScViewObjectModeItem::ScViewObjectModeItem( USHORT nWhichP
, ScVObjMode eMode
)
1041 : SfxEnumItem( nWhichP
, sal::static_int_cast
<USHORT
>(eMode
) )
1045 //------------------------------------------------------------------------
1047 ScViewObjectModeItem::~ScViewObjectModeItem()
1051 //------------------------------------------------------------------------
1053 SfxItemPresentation
ScViewObjectModeItem::GetPresentation
1055 SfxItemPresentation ePres
,
1056 SfxMapUnit
/* eCoreUnit */,
1057 SfxMapUnit
/* ePresUnit */,
1059 const IntlWrapper
* /* pIntl */
1062 String aDel
= String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(": "));
1067 case SFX_ITEM_PRESENTATION_COMPLETE
:
1070 case SID_SCATTR_PAGE_CHARTS
:
1071 rText
= ScGlobal::GetRscString(STR_VOBJ_CHART
);
1075 case SID_SCATTR_PAGE_OBJECTS
:
1076 rText
= ScGlobal::GetRscString(STR_VOBJ_OBJECT
);
1080 case SID_SCATTR_PAGE_DRAWINGS
:
1081 rText
= ScGlobal::GetRscString(STR_VOBJ_DRAWINGS
);
1086 ePres
= SFX_ITEM_PRESENTATION_NAMELESS
;//das geht immer!
1089 // break; // DURCHFALLEN!!!
1091 case SFX_ITEM_PRESENTATION_NAMELESS
:
1092 rText
+= ScGlobal::GetRscString(STR_VOBJ_MODE_SHOW
+GetValue());
1097 // added to avoid warnings
1104 //------------------------------------------------------------------------
1106 String
ScViewObjectModeItem::GetValueText( USHORT nVal
) const
1108 DBG_ASSERT( nVal
<= VOBJ_MODE_HIDE
, "enum overflow!" );
1110 return ScGlobal::GetRscString( STR_VOBJ_MODE_SHOW
+ (nVal
% 2));
1113 //------------------------------------------------------------------------
1115 USHORT
ScViewObjectModeItem::GetValueCount() const
1120 //------------------------------------------------------------------------
1122 SfxPoolItem
* ScViewObjectModeItem::Clone( SfxItemPool
* ) const
1124 return new ScViewObjectModeItem( *this );
1127 //------------------------------------------------------------------------
1129 USHORT
ScViewObjectModeItem::GetVersion( USHORT
/* nFileVersion */ ) const
1134 //------------------------------------------------------------------------
1136 SfxPoolItem
* ScViewObjectModeItem::Create(
1138 USHORT nVersion
) const
1140 if ( nVersion
== 0 )
1142 // alte Version mit AllEnumItem -> mit Mode "Show" erzeugen
1143 return new ScViewObjectModeItem( Which() );
1150 //#i80528# adapt to new range eventually
1151 if((USHORT
)VOBJ_MODE_HIDE
< nVal
) nVal
= (USHORT
)VOBJ_MODE_SHOW
;
1153 return new ScViewObjectModeItem( Which(), (ScVObjMode
)nVal
);
1157 // -----------------------------------------------------------------------
1159 // -----------------------------------------------------------------------
1161 ScDoubleItem::ScDoubleItem( USHORT nWhichP
, double nVal
)
1162 : SfxPoolItem ( nWhichP
),
1167 //------------------------------------------------------------------------
1169 ScDoubleItem::ScDoubleItem( const ScDoubleItem
& rItem
)
1170 : SfxPoolItem ( rItem
)
1172 nValue
= rItem
.nValue
;
1175 //------------------------------------------------------------------------
1177 String
ScDoubleItem::GetValueText() const
1179 return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScDoubleItem"));
1182 //------------------------------------------------------------------------
1184 int ScDoubleItem::operator==( const SfxPoolItem
& rItem
) const
1186 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal Which or Type" );
1187 const ScDoubleItem
& _rItem
= (const ScDoubleItem
&)rItem
;
1188 return int(nValue
== _rItem
.nValue
);
1189 //int(nValue == ((const ScDoubleItem&)rItem).nValue);
1192 //------------------------------------------------------------------------
1194 SfxPoolItem
* ScDoubleItem::Clone( SfxItemPool
* ) const
1196 return new ScDoubleItem( *this );
1199 //------------------------------------------------------------------------
1201 SfxPoolItem
* ScDoubleItem::Create( SvStream
& rStream
, USHORT
/* nVer */ ) const
1206 ScDoubleItem
* pItem
= new ScDoubleItem( Which(), nTmp
);
1211 //------------------------------------------------------------------------
1213 ScDoubleItem::~ScDoubleItem()
1218 // ============================================================================
1220 ScPageScaleToItem::ScPageScaleToItem() :
1221 SfxPoolItem( ATTR_PAGE_SCALETO
),
1227 ScPageScaleToItem::ScPageScaleToItem( sal_uInt16 nWidth
, sal_uInt16 nHeight
) :
1228 SfxPoolItem( ATTR_PAGE_SCALETO
),
1234 ScPageScaleToItem::~ScPageScaleToItem()
1238 ScPageScaleToItem
* ScPageScaleToItem::Clone( SfxItemPool
* ) const
1240 return new ScPageScaleToItem( *this );
1243 int ScPageScaleToItem::operator==( const SfxPoolItem
& rCmp
) const
1245 DBG_ASSERT( SfxPoolItem::operator==( rCmp
), "ScPageScaleToItem::operator== - unequal wid or type" );
1246 const ScPageScaleToItem
& rPageCmp
= static_cast< const ScPageScaleToItem
& >( rCmp
);
1247 return ((mnWidth
== rPageCmp
.mnWidth
) && (mnHeight
== rPageCmp
.mnHeight
)) ? 1 : 0;
1251 void lclAppendScalePageCount( String
& rText
, sal_uInt16 nPages
)
1253 rText
.AppendAscii( ": " );
1256 String
aPages( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_PAGES
) );
1257 aPages
.SearchAndReplaceAscii( "%1", String::CreateFromInt32( nPages
) );
1258 rText
.Append( aPages
);
1261 rText
.Append( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_AUTO
) );
1265 SfxItemPresentation
ScPageScaleToItem::GetPresentation(
1266 SfxItemPresentation ePres
, SfxMapUnit
, SfxMapUnit
, XubString
& rText
, const IntlWrapper
* ) const
1269 if( !IsValid() || (ePres
== SFX_ITEM_PRESENTATION_NONE
) )
1270 return SFX_ITEM_PRESENTATION_NONE
;
1272 String
aName( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALETO
) );
1273 String
aValue( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_WIDTH
) );
1274 lclAppendScalePageCount( aValue
, mnWidth
);
1275 aValue
.AppendAscii( ", " ).Append( ScGlobal::GetRscString( STR_SCATTR_PAGE_SCALE_HEIGHT
) );
1276 lclAppendScalePageCount( aValue
, mnHeight
);
1280 case SFX_ITEM_PRESENTATION_NONE
:
1283 case SFX_ITEM_PRESENTATION_NAMEONLY
:
1287 case SFX_ITEM_PRESENTATION_NAMELESS
:
1291 case SFX_ITEM_PRESENTATION_COMPLETE
:
1292 rText
.Assign( aName
).AppendAscii( " (" ).Append( aValue
).Append( ')' );
1296 DBG_ERRORFILE( "ScPageScaleToItem::GetPresentation - unknown presentation mode" );
1297 ePres
= SFX_ITEM_PRESENTATION_NONE
;
1302 BOOL
ScPageScaleToItem::QueryValue( uno::Any
& rAny
, BYTE nMemberId
) const
1307 case SC_MID_PAGE_SCALETO_WIDTH
: rAny
<<= mnWidth
; break;
1308 case SC_MID_PAGE_SCALETO_HEIGHT
: rAny
<<= mnHeight
; break;
1310 DBG_ERRORFILE( "ScPageScaleToItem::QueryValue - unknown member ID" );
1316 BOOL
ScPageScaleToItem::PutValue( const uno::Any
& rAny
, BYTE nMemberId
)
1321 case SC_MID_PAGE_SCALETO_WIDTH
: bRet
= rAny
>>= mnWidth
; break;
1322 case SC_MID_PAGE_SCALETO_HEIGHT
: bRet
= rAny
>>= mnHeight
; break;
1324 DBG_ERRORFILE( "ScPageScaleToItem::PutValue - unknown member ID" );
1329 // ============================================================================