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