fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / app / uiitems.cxx
blob08144fc4e857426ba1d24004ff258c665506e2d4
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 <osl/diagnose.h>
27 #include <editeng/editobj.hxx>
29 // STATIC DATA -----------------------------------------------------------
31 TYPEINIT1(ScInputStatusItem, SfxPoolItem);
32 TYPEINIT1(ScSortItem, SfxPoolItem);
33 TYPEINIT1(ScQueryItem, SfxPoolItem);
34 TYPEINIT1(ScSubTotalItem, SfxPoolItem);
35 TYPEINIT1(ScUserListItem, SfxPoolItem);
36 TYPEINIT1(ScConsolidateItem, SfxPoolItem);
37 TYPEINIT1(ScPivotItem, SfxPoolItem);
38 TYPEINIT1(ScSolveItem, SfxPoolItem);
39 TYPEINIT1(ScTabOpItem, SfxPoolItem);
42 /**
43 * Status update for entry field
45 ScInputStatusItem::ScInputStatusItem(
46 sal_uInt16 nWhichP, const ScAddress& rCurPos, const ScAddress& rStartPos,
47 const ScAddress& rEndPos, const OUString& rString, const EditTextObject* pData ) :
48 SfxPoolItem ( nWhichP ),
49 aCursorPos ( rCurPos ),
50 aStartPos ( rStartPos ),
51 aEndPos ( rEndPos ),
52 aString ( rString ),
53 pEditData ( pData ? pData->Clone() : NULL ),
54 mpMisspellRanges(NULL)
58 ScInputStatusItem::ScInputStatusItem( const ScInputStatusItem& rItem ) :
59 SfxPoolItem ( rItem ),
60 aCursorPos ( rItem.aCursorPos ),
61 aStartPos ( rItem.aStartPos ),
62 aEndPos ( rItem.aEndPos ),
63 aString ( rItem.aString ),
64 pEditData ( rItem.pEditData ? rItem.pEditData->Clone() : NULL ),
65 mpMisspellRanges(rItem.mpMisspellRanges)
69 ScInputStatusItem::~ScInputStatusItem()
71 delete pEditData;
74 bool ScInputStatusItem::operator==( const SfxPoolItem& rItem ) const
76 assert(SfxPoolItem::operator==(rItem));
78 return (aStartPos == static_cast<const ScInputStatusItem&>(rItem).aStartPos)
79 && (aEndPos == static_cast<const ScInputStatusItem&>(rItem).aEndPos)
80 && (aCursorPos == static_cast<const ScInputStatusItem&>(rItem).aCursorPos)
81 && (aString == static_cast<const ScInputStatusItem&>(rItem).aString);
82 //TODO: Compare Edit data!
85 SfxPoolItem* ScInputStatusItem::Clone( SfxItemPool * ) const
87 return new ScInputStatusItem( *this );
90 void ScInputStatusItem::SetMisspellRanges( const std::vector<editeng::MisspellRanges>* pRanges )
92 mpMisspellRanges = pRanges;
95 // ScPaintHint was moved to schints.cxx
97 /**
98 * Adapt Views when inserting/deleting a table
100 ScTablesHint::ScTablesHint(sal_uInt16 nNewId, SCTAB nTable1, SCTAB nTable2) :
101 nId( nNewId ),
102 nTab1( nTable1 ),
103 nTab2( nTable2 )
107 ScTablesHint::~ScTablesHint()
111 ScIndexHint::ScIndexHint(sal_uInt16 nNewId, sal_uInt16 nIdx) :
112 nId( nNewId ),
113 nIndex( nIdx )
117 ScIndexHint::~ScIndexHint()
122 * Create new EditView for Cursorposition
124 ScEditViewHint::ScEditViewHint( ScEditEngineDefaulter* pEngine, const ScAddress& rCurPos ) :
125 pEditEngine( pEngine ),
126 aCursorPos( rCurPos )
130 ScEditViewHint::~ScEditViewHint()
135 * Data for the sorting dialog
137 ScSortItem::ScSortItem( sal_uInt16 nWhichP,
138 ScViewData* ptrViewData,
139 const ScSortParam* pSortData ) :
140 SfxPoolItem ( nWhichP ),
141 pViewData ( ptrViewData )
143 if ( pSortData ) theSortData = *pSortData;
146 ScSortItem::ScSortItem( sal_uInt16 nWhichP,
147 const ScSortParam* pSortData ) :
148 SfxPoolItem ( nWhichP ),
149 pViewData ( NULL )
151 if ( pSortData ) theSortData = *pSortData;
154 ScSortItem::ScSortItem( const ScSortItem& rItem ) :
155 SfxPoolItem ( rItem ),
156 pViewData ( rItem.pViewData ),
157 theSortData ( rItem.theSortData )
161 ScSortItem::~ScSortItem()
165 bool ScSortItem::operator==( const SfxPoolItem& rItem ) const
167 assert(SfxPoolItem::operator==(rItem));
169 const ScSortItem& rOther = static_cast<const ScSortItem&>(rItem);
171 return ( (pViewData == rOther.pViewData)
172 && (theSortData == rOther.theSortData) );
175 SfxPoolItem* ScSortItem::Clone( SfxItemPool * ) const
177 return new ScSortItem( *this );
180 bool ScSortItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /* nMemberUd */ ) const
182 // Return empty value as there is no useful conversion
183 rVal = com::sun::star::uno::Any();
184 return true;
188 * Data for the Filter dialog
190 ScQueryItem::ScQueryItem( sal_uInt16 nWhichP,
191 ScViewData* ptrViewData,
192 const ScQueryParam* pQueryData ) :
193 SfxPoolItem ( nWhichP ),
194 mpQueryData(NULL),
195 pViewData ( ptrViewData ),
196 bIsAdvanced ( false )
198 if (pQueryData)
199 mpQueryData.reset(new ScQueryParam(*pQueryData));
200 else
201 mpQueryData.reset(new ScQueryParam);
204 ScQueryItem::ScQueryItem( sal_uInt16 nWhichP,
205 const ScQueryParam* pQueryData ) :
206 SfxPoolItem ( nWhichP ),
207 mpQueryData(NULL),
208 pViewData ( NULL ),
209 bIsAdvanced ( false )
211 if (pQueryData)
212 mpQueryData.reset(new ScQueryParam(*pQueryData));
213 else
214 mpQueryData.reset(new ScQueryParam);
217 ScQueryItem::ScQueryItem( const ScQueryItem& rItem ) :
218 SfxPoolItem ( rItem ),
219 mpQueryData(new ScQueryParam(*rItem.mpQueryData)),
220 pViewData ( rItem.pViewData ),
221 aAdvSource ( rItem.aAdvSource ),
222 bIsAdvanced ( rItem.bIsAdvanced )
226 ScQueryItem::~ScQueryItem()
230 void ScQueryItem::SetAdvancedQuerySource(const ScRange* pSource)
232 if (pSource)
234 aAdvSource = *pSource;
235 bIsAdvanced = true;
237 else
238 bIsAdvanced = false;
241 const ScQueryParam& ScQueryItem::GetQueryData() const
243 return *mpQueryData;
246 bool ScQueryItem::GetAdvancedQuerySource(ScRange& rSource) const
248 rSource = aAdvSource;
249 return bIsAdvanced;
252 bool ScQueryItem::operator==( const SfxPoolItem& rItem ) const
254 assert(SfxPoolItem::operator==(rItem));
256 const ScQueryItem& rQueryItem = static_cast<const ScQueryItem&>(rItem);
258 return ( (pViewData == rQueryItem.pViewData)
259 && (bIsAdvanced == rQueryItem.bIsAdvanced)
260 && (aAdvSource == rQueryItem.aAdvSource)
261 && (*mpQueryData == *rQueryItem.mpQueryData) );
264 SfxPoolItem* ScQueryItem::Clone( SfxItemPool * ) const
266 return new ScQueryItem( *this );
270 * Data for the SubTotal dialog
272 ScSubTotalItem::ScSubTotalItem( sal_uInt16 nWhichP,
273 ScViewData* ptrViewData,
274 const ScSubTotalParam* pSubTotalData ) :
275 SfxPoolItem ( nWhichP ),
276 pViewData ( ptrViewData )
278 if ( pSubTotalData ) theSubTotalData = *pSubTotalData;
281 ScSubTotalItem::ScSubTotalItem( sal_uInt16 nWhichP,
282 const ScSubTotalParam* pSubTotalData ) :
283 SfxPoolItem ( nWhichP ),
284 pViewData ( NULL )
286 if ( pSubTotalData ) theSubTotalData = *pSubTotalData;
289 ScSubTotalItem::ScSubTotalItem( const ScSubTotalItem& rItem ) :
290 SfxPoolItem ( rItem ),
291 pViewData ( rItem.pViewData ),
292 theSubTotalData ( rItem.theSubTotalData )
296 ScSubTotalItem::~ScSubTotalItem()
300 bool ScSubTotalItem::operator==( const SfxPoolItem& rItem ) const
302 assert(SfxPoolItem::operator==(rItem));
304 const ScSubTotalItem& rSTItem = static_cast<const ScSubTotalItem&>(rItem);
306 return ( (pViewData == rSTItem.pViewData)
307 && (theSubTotalData == rSTItem.theSubTotalData) );
310 SfxPoolItem* ScSubTotalItem::Clone( SfxItemPool * ) const
312 return new ScSubTotalItem( *this );
315 bool ScSubTotalItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /* nMemberUd */ ) const
317 // Return empty value as there is no useful conversion
318 rVal = com::sun::star::uno::Any();
319 return true;
323 * Transporter for the UserLIst dialog
325 ScUserListItem::ScUserListItem( sal_uInt16 nWhichP )
326 : SfxPoolItem ( nWhichP ),
327 pUserList ( NULL )
331 ScUserListItem::ScUserListItem( const ScUserListItem& rItem )
332 : SfxPoolItem ( rItem )
334 if ( rItem.pUserList )
335 pUserList = new ScUserList( *(rItem.pUserList) );
336 else
337 pUserList = NULL;
340 ScUserListItem::~ScUserListItem()
342 delete pUserList;
345 bool ScUserListItem::operator==( const SfxPoolItem& rItem ) const
347 assert(SfxPoolItem::operator==(rItem));
349 const ScUserListItem& r = static_cast<const ScUserListItem&>(rItem);
350 bool bEqual = false;
352 if ( !pUserList || !(r.pUserList) )
353 bEqual = ( !pUserList && !(r.pUserList) );
354 else
355 bEqual = ( *pUserList == *(r.pUserList) );
357 return bEqual;
360 SfxPoolItem* ScUserListItem::Clone( SfxItemPool * ) const
362 return new ScUserListItem( *this );
365 void ScUserListItem::SetUserList( const ScUserList& rUserList )
367 delete pUserList;
368 pUserList = new ScUserList( rUserList );
372 * Data for the Consolidate dialog
374 ScConsolidateItem::ScConsolidateItem(
375 sal_uInt16 nWhichP,
376 const ScConsolidateParam* pConsolidateData ) :
377 SfxPoolItem ( nWhichP )
379 if ( pConsolidateData ) theConsData = *pConsolidateData;
382 ScConsolidateItem::ScConsolidateItem( const ScConsolidateItem& rItem ) :
383 SfxPoolItem ( rItem ),
384 theConsData ( rItem.theConsData )
388 ScConsolidateItem::~ScConsolidateItem()
392 bool ScConsolidateItem::operator==( const SfxPoolItem& rItem ) const
394 assert(SfxPoolItem::operator==(rItem));
396 const ScConsolidateItem& rCItem = static_cast<const ScConsolidateItem&>(rItem);
398 return ( theConsData == rCItem.theConsData);
401 SfxPoolItem* ScConsolidateItem::Clone( SfxItemPool * ) const
403 return new ScConsolidateItem( *this );
407 * Data for the Pivot dialog
409 ScPivotItem::ScPivotItem( sal_uInt16 nWhichP, const ScDPSaveData* pData,
410 const ScRange* pRange, bool bNew ) :
411 SfxPoolItem ( nWhichP )
413 // pSaveData must always exist
414 if ( pData )
415 pSaveData = new ScDPSaveData(*pData);
416 else
417 pSaveData = new ScDPSaveData;
418 if ( pRange ) aDestRange = *pRange;
419 bNewSheet = bNew;
422 ScPivotItem::ScPivotItem( const ScPivotItem& rItem ) :
423 SfxPoolItem ( rItem ),
424 aDestRange ( rItem.aDestRange ),
425 bNewSheet ( rItem.bNewSheet )
427 assert(rItem.pSaveData && "pSaveData");
428 pSaveData = new ScDPSaveData(*rItem.pSaveData);
431 ScPivotItem::~ScPivotItem()
433 delete pSaveData;
436 bool ScPivotItem::operator==( const SfxPoolItem& rItem ) const
438 assert(SfxPoolItem::operator==(rItem));
440 const ScPivotItem& rPItem = static_cast<const ScPivotItem&>(rItem);
441 OSL_ENSURE( pSaveData && rPItem.pSaveData, "pSaveData" );
442 return ( *pSaveData == *rPItem.pSaveData &&
443 aDestRange == rPItem.aDestRange &&
444 bNewSheet == rPItem.bNewSheet );
447 SfxPoolItem* ScPivotItem::Clone( SfxItemPool * ) const
449 return new ScPivotItem( *this );
453 * Data for the Solver dialog
455 ScSolveItem::ScSolveItem( sal_uInt16 nWhichP,
456 const ScSolveParam* pSolveData )
457 : SfxPoolItem ( nWhichP )
459 if ( pSolveData ) theSolveData = *pSolveData;
462 ScSolveItem::ScSolveItem( const ScSolveItem& rItem )
463 : SfxPoolItem ( rItem ),
464 theSolveData ( rItem.theSolveData )
468 ScSolveItem::~ScSolveItem()
472 bool ScSolveItem::operator==( const SfxPoolItem& rItem ) const
474 assert(SfxPoolItem::operator==(rItem));
476 const ScSolveItem& rPItem = static_cast<const ScSolveItem&>(rItem);
478 return ( theSolveData == rPItem.theSolveData );
481 SfxPoolItem* ScSolveItem::Clone( SfxItemPool * ) const
483 return new ScSolveItem( *this );
487 * Data for the TabOp dialog
489 ScTabOpItem::ScTabOpItem( sal_uInt16 nWhichP,
490 const ScTabOpParam* pTabOpData )
491 : SfxPoolItem ( nWhichP )
493 if ( pTabOpData ) theTabOpData = *pTabOpData;
496 ScTabOpItem::ScTabOpItem( const ScTabOpItem& rItem )
497 : SfxPoolItem ( rItem ),
498 theTabOpData ( rItem.theTabOpData )
502 ScTabOpItem::~ScTabOpItem()
506 bool ScTabOpItem::operator==( const SfxPoolItem& rItem ) const
508 assert(SfxPoolItem::operator==(rItem));
510 const ScTabOpItem& rPItem = static_cast<const ScTabOpItem&>(rItem);
512 return ( theTabOpData == rPItem.theTabOpData );
515 SfxPoolItem* ScTabOpItem::Clone( SfxItemPool * ) const
517 return new ScTabOpItem( *this );
520 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */