Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / app / uiitems.cxx
blobab83063d74e0511a1c388f992c2950291173bdf4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "uiitems.hxx"
22 #include "userlist.hxx"
23 #include "dpsave.hxx"
24 #include "queryparam.hxx"
26 #include <editeng/editobj.hxx>
28 // STATIC DATA -----------------------------------------------------------
30 TYPEINIT1(ScInputStatusItem, SfxPoolItem);
31 TYPEINIT1(ScSortItem, SfxPoolItem);
32 TYPEINIT1(ScQueryItem, SfxPoolItem);
33 TYPEINIT1(ScSubTotalItem, SfxPoolItem);
34 TYPEINIT1(ScUserListItem, SfxPoolItem);
35 TYPEINIT1(ScConsolidateItem, SfxPoolItem);
36 TYPEINIT1(ScPivotItem, SfxPoolItem);
37 TYPEINIT1(ScSolveItem, SfxPoolItem);
38 TYPEINIT1(ScTabOpItem, SfxPoolItem);
40 TYPEINIT1(ScTablesHint, SfxHint);
41 TYPEINIT1(ScEditViewHint, SfxHint);
42 TYPEINIT1(ScIndexHint, SfxHint);
44 // -----------------------------------------------------------------------
45 // ScInputStatusItem - Status-Update fuer Eingabezeile
46 // -----------------------------------------------------------------------
48 ScInputStatusItem::ScInputStatusItem(
49 sal_uInt16 nWhichP, const ScAddress& rCurPos, const ScAddress& rStartPos,
50 const ScAddress& rEndPos, const OUString& rString, const EditTextObject* pData ) :
51 SfxPoolItem ( nWhichP ),
52 aCursorPos ( rCurPos ),
53 aStartPos ( rStartPos ),
54 aEndPos ( rEndPos ),
55 aString ( rString ),
56 pEditData ( pData ? pData->Clone() : NULL ),
57 mpMisspellRanges(NULL)
61 ScInputStatusItem::ScInputStatusItem( const ScInputStatusItem& rItem ) :
62 SfxPoolItem ( rItem ),
63 aCursorPos ( rItem.aCursorPos ),
64 aStartPos ( rItem.aStartPos ),
65 aEndPos ( rItem.aEndPos ),
66 aString ( rItem.aString ),
67 pEditData ( rItem.pEditData ? rItem.pEditData->Clone() : NULL ),
68 mpMisspellRanges(rItem.mpMisspellRanges)
72 ScInputStatusItem::~ScInputStatusItem()
74 delete pEditData;
77 OUString ScInputStatusItem::GetValueText() const
79 return OUString("InputStatus");
82 int ScInputStatusItem::operator==( const SfxPoolItem& rItem ) const
84 OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
86 return ( (aStartPos == ((ScInputStatusItem&)rItem).aStartPos)
87 && (aEndPos == ((ScInputStatusItem&)rItem).aEndPos)
88 && (aCursorPos == ((ScInputStatusItem&)rItem).aCursorPos)
89 && (aString == ((ScInputStatusItem&)rItem).aString) );
90 //! Edit-Daten vergleichen!
93 SfxPoolItem* ScInputStatusItem::Clone( SfxItemPool * ) const
95 return new ScInputStatusItem( *this );
98 void ScInputStatusItem::SetMisspellRanges( const std::vector<editeng::MisspellRanges>* pRanges )
100 mpMisspellRanges = pRanges;
103 const std::vector<editeng::MisspellRanges>* ScInputStatusItem::GetMisspellRanges() const
105 return mpMisspellRanges;
109 // ScPaintHint ist nach schints.cxx verschoben
112 // -----------------------------------------------------------------------
113 // ScTablesHint - Views anpassen, wenn Tabellen eingefuegt / geloescht
114 // -----------------------------------------------------------------------
116 ScTablesHint::ScTablesHint(sal_uInt16 nNewId, SCTAB nTable1, SCTAB nTable2) :
117 nId( nNewId ),
118 nTab1( nTable1 ),
119 nTab2( nTable2 )
123 ScTablesHint::~ScTablesHint()
128 // -----------------------------------------------------------------------
129 // ScIndexHint
130 // -----------------------------------------------------------------------
132 ScIndexHint::ScIndexHint(sal_uInt16 nNewId, sal_uInt16 nIdx) :
133 nId( nNewId ),
134 nIndex( nIdx )
138 ScIndexHint::~ScIndexHint()
143 // -----------------------------------------------------------------------
144 // ScEditViewHint - neue EditView fuer Cursorposition anlegen
145 // -----------------------------------------------------------------------
147 ScEditViewHint::ScEditViewHint( ScEditEngineDefaulter* pEngine, const ScAddress& rCurPos ) :
148 pEditEngine( pEngine ),
149 aCursorPos( rCurPos )
153 ScEditViewHint::~ScEditViewHint()
157 // -----------------------------------------------------------------------
158 // ScSortItem - Daten fuer den Sortierdialog
159 // -----------------------------------------------------------------------
161 ScSortItem::ScSortItem( sal_uInt16 nWhichP,
162 ScViewData* ptrViewData,
163 const ScSortParam* pSortData ) :
164 SfxPoolItem ( nWhichP ),
165 pViewData ( ptrViewData )
167 if ( pSortData ) theSortData = *pSortData;
170 //------------------------------------------------------------------------
172 ScSortItem::ScSortItem( sal_uInt16 nWhichP,
173 const ScSortParam* pSortData ) :
174 SfxPoolItem ( nWhichP ),
175 pViewData ( NULL )
177 if ( pSortData ) theSortData = *pSortData;
180 //------------------------------------------------------------------------
182 ScSortItem::ScSortItem( const ScSortItem& rItem ) :
183 SfxPoolItem ( rItem ),
184 pViewData ( rItem.pViewData ),
185 theSortData ( rItem.theSortData )
189 ScSortItem::~ScSortItem()
193 //------------------------------------------------------------------------
195 OUString ScSortItem::GetValueText() const
197 return OUString("SortItem");
200 //------------------------------------------------------------------------
202 int ScSortItem::operator==( const SfxPoolItem& rItem ) const
204 OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
206 const ScSortItem& rOther = (const ScSortItem&)rItem;
208 return ( (pViewData == rOther.pViewData)
209 && (theSortData == rOther.theSortData) );
212 //------------------------------------------------------------------------
214 SfxPoolItem* ScSortItem::Clone( SfxItemPool * ) const
216 return new ScSortItem( *this );
219 //------------------------------------------------------------------------
221 bool ScSortItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /* nMemberUd */ ) const
223 // Return empty value as there is no useful conversion
224 rVal = com::sun::star::uno::Any();
225 return true;
228 // -----------------------------------------------------------------------
229 // ScQueryItem - Daten fuer den Filterdialog
230 // -----------------------------------------------------------------------
232 ScQueryItem::ScQueryItem( sal_uInt16 nWhichP,
233 ScViewData* ptrViewData,
234 const ScQueryParam* pQueryData ) :
235 SfxPoolItem ( nWhichP ),
236 mpQueryData(NULL),
237 pViewData ( ptrViewData ),
238 bIsAdvanced ( false )
240 if (pQueryData)
241 mpQueryData.reset(new ScQueryParam(*pQueryData));
242 else
243 mpQueryData.reset(new ScQueryParam);
246 //------------------------------------------------------------------------
248 ScQueryItem::ScQueryItem( sal_uInt16 nWhichP,
249 const ScQueryParam* pQueryData ) :
250 SfxPoolItem ( nWhichP ),
251 mpQueryData(NULL),
252 pViewData ( NULL ),
253 bIsAdvanced ( false )
255 if (pQueryData)
256 mpQueryData.reset(new ScQueryParam(*pQueryData));
257 else
258 mpQueryData.reset(new ScQueryParam);
261 //------------------------------------------------------------------------
263 ScQueryItem::ScQueryItem( const ScQueryItem& rItem ) :
264 SfxPoolItem ( rItem ),
265 mpQueryData(new ScQueryParam(*rItem.mpQueryData)),
266 pViewData ( rItem.pViewData ),
267 aAdvSource ( rItem.aAdvSource ),
268 bIsAdvanced ( rItem.bIsAdvanced )
272 ScQueryItem::~ScQueryItem()
276 //------------------------------------------------------------------------
278 void ScQueryItem::SetAdvancedQuerySource(const ScRange* pSource)
280 if (pSource)
282 aAdvSource = *pSource;
283 bIsAdvanced = true;
285 else
286 bIsAdvanced = false;
289 const ScQueryParam& ScQueryItem::GetQueryData() const
291 return *mpQueryData;
294 bool ScQueryItem::GetAdvancedQuerySource(ScRange& rSource) const
296 rSource = aAdvSource;
297 return bIsAdvanced;
300 //------------------------------------------------------------------------
302 OUString ScQueryItem::GetValueText() const
304 return OUString("QueryItem");
307 //------------------------------------------------------------------------
309 int ScQueryItem::operator==( const SfxPoolItem& rItem ) const
311 OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
313 const ScQueryItem& rQueryItem = (const ScQueryItem&)rItem;
315 return ( (pViewData == rQueryItem.pViewData)
316 && (bIsAdvanced == rQueryItem.bIsAdvanced)
317 && (aAdvSource == rQueryItem.aAdvSource)
318 && (*mpQueryData == *rQueryItem.mpQueryData) );
321 //------------------------------------------------------------------------
323 SfxPoolItem* ScQueryItem::Clone( SfxItemPool * ) const
325 return new ScQueryItem( *this );
328 // -----------------------------------------------------------------------
329 // ScSubTotalItem - Daten fuer den Zwischenergebnisdialog
330 // -----------------------------------------------------------------------
332 ScSubTotalItem::ScSubTotalItem( sal_uInt16 nWhichP,
333 ScViewData* ptrViewData,
334 const ScSubTotalParam* pSubTotalData ) :
335 SfxPoolItem ( nWhichP ),
336 pViewData ( ptrViewData )
338 if ( pSubTotalData ) theSubTotalData = *pSubTotalData;
341 //------------------------------------------------------------------------
343 ScSubTotalItem::ScSubTotalItem( sal_uInt16 nWhichP,
344 const ScSubTotalParam* pSubTotalData ) :
345 SfxPoolItem ( nWhichP ),
346 pViewData ( NULL )
348 if ( pSubTotalData ) theSubTotalData = *pSubTotalData;
351 //------------------------------------------------------------------------
353 ScSubTotalItem::ScSubTotalItem( const ScSubTotalItem& rItem ) :
354 SfxPoolItem ( rItem ),
355 pViewData ( rItem.pViewData ),
356 theSubTotalData ( rItem.theSubTotalData )
360 ScSubTotalItem::~ScSubTotalItem()
364 //------------------------------------------------------------------------
366 OUString ScSubTotalItem::GetValueText() const
368 return OUString("SubTotalItem");
371 //------------------------------------------------------------------------
373 int ScSubTotalItem::operator==( const SfxPoolItem& rItem ) const
375 OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
377 const ScSubTotalItem& rSTItem = (const ScSubTotalItem&)rItem;
379 return ( (pViewData == rSTItem.pViewData)
380 && (theSubTotalData == rSTItem.theSubTotalData) );
383 //------------------------------------------------------------------------
385 SfxPoolItem* ScSubTotalItem::Clone( SfxItemPool * ) const
387 return new ScSubTotalItem( *this );
390 //------------------------------------------------------------------------
392 bool ScSubTotalItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /* nMemberUd */ ) const
394 // Return empty value as there is no useful conversion
395 rVal = com::sun::star::uno::Any();
396 return true;
399 // -----------------------------------------------------------------------
400 // ScUserListItem - Transporter fuer den Benutzerlisten-TabPage
401 // -----------------------------------------------------------------------
403 ScUserListItem::ScUserListItem( sal_uInt16 nWhichP )
404 : SfxPoolItem ( nWhichP ),
405 pUserList ( NULL )
409 //------------------------------------------------------------------------
411 ScUserListItem::ScUserListItem( const ScUserListItem& rItem )
412 : SfxPoolItem ( rItem )
414 if ( rItem.pUserList )
415 pUserList = new ScUserList( *(rItem.pUserList) );
416 else
417 pUserList = NULL;
420 ScUserListItem::~ScUserListItem()
422 delete pUserList;
425 //------------------------------------------------------------------------
427 OUString ScUserListItem::GetValueText() const
429 return OUString("ScUserListItem");
432 //------------------------------------------------------------------------
434 int ScUserListItem::operator==( const SfxPoolItem& rItem ) const
436 OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
438 const ScUserListItem& r = (const ScUserListItem&)rItem;
439 sal_Bool bEqual = false;
441 if ( !pUserList || !(r.pUserList) )
442 bEqual = ( !pUserList && !(r.pUserList) );
443 else
444 bEqual = ( *pUserList == *(r.pUserList) );
446 return bEqual;
450 //------------------------------------------------------------------------
452 SfxPoolItem* ScUserListItem::Clone( SfxItemPool * ) const
454 return new ScUserListItem( *this );
457 //------------------------------------------------------------------------
459 void ScUserListItem::SetUserList( const ScUserList& rUserList )
461 delete pUserList;
462 pUserList = new ScUserList( rUserList );
465 // -----------------------------------------------------------------------
466 // ScConsolidateItem - Daten fuer den Konsolidieren-Dialog
467 // -----------------------------------------------------------------------
469 ScConsolidateItem::ScConsolidateItem(
470 sal_uInt16 nWhichP,
471 const ScConsolidateParam* pConsolidateData ) :
472 SfxPoolItem ( nWhichP )
474 if ( pConsolidateData ) theConsData = *pConsolidateData;
477 //------------------------------------------------------------------------
479 ScConsolidateItem::ScConsolidateItem( const ScConsolidateItem& rItem ) :
480 SfxPoolItem ( rItem ),
481 theConsData ( rItem.theConsData )
485 //------------------------------------------------------------------------
487 ScConsolidateItem::~ScConsolidateItem()
491 //------------------------------------------------------------------------
493 OUString ScConsolidateItem::GetValueText() const
495 return OUString("ScConsolidateItem");
498 //------------------------------------------------------------------------
500 int ScConsolidateItem::operator==( const SfxPoolItem& rItem ) const
502 OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
504 const ScConsolidateItem& rCItem = (const ScConsolidateItem&)rItem;
506 return ( theConsData == rCItem.theConsData);
509 //------------------------------------------------------------------------
511 SfxPoolItem* ScConsolidateItem::Clone( SfxItemPool * ) const
513 return new ScConsolidateItem( *this );
517 // -----------------------------------------------------------------------
518 // ScPivotItem - Daten fuer den Pivot-Dialog
519 // -----------------------------------------------------------------------
521 ScPivotItem::ScPivotItem( sal_uInt16 nWhichP, const ScDPSaveData* pData,
522 const ScRange* pRange, sal_Bool bNew ) :
523 SfxPoolItem ( nWhichP )
525 // pSaveData must always exist
526 if ( pData )
527 pSaveData = new ScDPSaveData(*pData);
528 else
529 pSaveData = new ScDPSaveData;
530 if ( pRange ) aDestRange = *pRange;
531 bNewSheet = bNew;
534 //------------------------------------------------------------------------
536 ScPivotItem::ScPivotItem( const ScPivotItem& rItem ) :
537 SfxPoolItem ( rItem ),
538 aDestRange ( rItem.aDestRange ),
539 bNewSheet ( rItem.bNewSheet )
541 OSL_ENSURE(rItem.pSaveData, "pSaveData");
542 pSaveData = new ScDPSaveData(*rItem.pSaveData);
545 //------------------------------------------------------------------------
547 ScPivotItem::~ScPivotItem()
549 delete pSaveData;
552 //------------------------------------------------------------------------
554 OUString ScPivotItem::GetValueText() const
556 return OUString("ScPivotItem");
559 //------------------------------------------------------------------------
561 int ScPivotItem::operator==( const SfxPoolItem& rItem ) const
563 OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
565 const ScPivotItem& rPItem = (const ScPivotItem&)rItem;
566 OSL_ENSURE( pSaveData && rPItem.pSaveData, "pSaveData" );
567 return ( *pSaveData == *rPItem.pSaveData &&
568 aDestRange == rPItem.aDestRange &&
569 bNewSheet == rPItem.bNewSheet );
572 //------------------------------------------------------------------------
574 SfxPoolItem* ScPivotItem::Clone( SfxItemPool * ) const
576 return new ScPivotItem( *this );
580 // -----------------------------------------------------------------------
581 // ScSolveItem - Daten fuer den Solver-Dialog
582 // -----------------------------------------------------------------------
584 ScSolveItem::ScSolveItem( sal_uInt16 nWhichP,
585 const ScSolveParam* pSolveData )
586 : SfxPoolItem ( nWhichP )
588 if ( pSolveData ) theSolveData = *pSolveData;
591 //------------------------------------------------------------------------
593 ScSolveItem::ScSolveItem( const ScSolveItem& rItem )
594 : SfxPoolItem ( rItem ),
595 theSolveData ( rItem.theSolveData )
599 //------------------------------------------------------------------------
601 ScSolveItem::~ScSolveItem()
605 //------------------------------------------------------------------------
607 OUString ScSolveItem::GetValueText() const
609 return OUString("ScSolveItem");
612 //------------------------------------------------------------------------
614 int ScSolveItem::operator==( const SfxPoolItem& rItem ) const
616 OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
618 const ScSolveItem& rPItem = (const ScSolveItem&)rItem;
620 return ( theSolveData == rPItem.theSolveData );
623 //------------------------------------------------------------------------
625 SfxPoolItem* ScSolveItem::Clone( SfxItemPool * ) const
627 return new ScSolveItem( *this );
630 // -----------------------------------------------------------------------
631 // ScTabOpItem - Daten fuer den TabOp-Dialog
632 // -----------------------------------------------------------------------
634 ScTabOpItem::ScTabOpItem( sal_uInt16 nWhichP,
635 const ScTabOpParam* pTabOpData )
636 : SfxPoolItem ( nWhichP )
638 if ( pTabOpData ) theTabOpData = *pTabOpData;
641 //------------------------------------------------------------------------
643 ScTabOpItem::ScTabOpItem( const ScTabOpItem& rItem )
644 : SfxPoolItem ( rItem ),
645 theTabOpData ( rItem.theTabOpData )
649 //------------------------------------------------------------------------
651 ScTabOpItem::~ScTabOpItem()
655 //------------------------------------------------------------------------
657 OUString ScTabOpItem::GetValueText() const
659 return OUString("ScTabOpItem");
662 //------------------------------------------------------------------------
664 int ScTabOpItem::operator==( const SfxPoolItem& rItem ) const
666 OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
668 const ScTabOpItem& rPItem = (const ScTabOpItem&)rItem;
670 return ( theTabOpData == rPItem.theTabOpData );
673 //------------------------------------------------------------------------
675 SfxPoolItem* ScTabOpItem::Clone( SfxItemPool * ) const
677 return new ScTabOpItem( *this );
680 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */