tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / app / uiitems.cxx
bloba22afdbf16d56530c93f6d766acb4da87e7210ad
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>
28 #include <utility>
30 /**
31 * Status update for entry field
33 ScInputStatusItem::ScInputStatusItem(
34 sal_uInt16 nWhichP, const ScAddress& rCurPos, const ScAddress& rStartPos,
35 const ScAddress& rEndPos, OUString _aString, const EditTextObject* pData ) :
36 SfxPoolItem ( nWhichP, SfxItemType::ScInputStatusItemType ),
37 aCursorPos ( rCurPos ),
38 aStartPos ( rStartPos ),
39 aEndPos ( rEndPos ),
40 aString (std::move( _aString )),
41 pEditData ( pData ? pData->Clone() : nullptr ),
42 mpMisspellRanges(nullptr)
46 ScInputStatusItem::ScInputStatusItem( const ScInputStatusItem& rItem ) :
47 SfxPoolItem ( rItem ),
48 aCursorPos ( rItem.aCursorPos ),
49 aStartPos ( rItem.aStartPos ),
50 aEndPos ( rItem.aEndPos ),
51 aString ( rItem.aString ),
52 pEditData ( rItem.pEditData ? rItem.pEditData->Clone() : nullptr ),
53 mpMisspellRanges(rItem.mpMisspellRanges)
57 ScInputStatusItem::~ScInputStatusItem()
61 bool ScInputStatusItem::operator==( const SfxPoolItem& rItem ) const
63 assert(SfxPoolItem::operator==(rItem));
65 return (aStartPos == static_cast<const ScInputStatusItem&>(rItem).aStartPos)
66 && (aEndPos == static_cast<const ScInputStatusItem&>(rItem).aEndPos)
67 && (aCursorPos == static_cast<const ScInputStatusItem&>(rItem).aCursorPos)
68 && (aString == static_cast<const ScInputStatusItem&>(rItem).aString);
69 //TODO: Compare Edit data!
72 ScInputStatusItem* ScInputStatusItem::Clone( SfxItemPool * ) const
74 return new ScInputStatusItem( *this );
77 void ScInputStatusItem::SetMisspellRanges( const std::vector<editeng::MisspellRanges>* pRanges )
79 mpMisspellRanges = pRanges;
82 // ScPaintHint was moved to hints.cxx
84 /**
85 * Adapt Views when inserting/deleting a table
87 ScTablesHint::ScTablesHint(sal_uInt16 nNewId, SCTAB nTable1, SCTAB nTable2) :
88 SfxHint(SfxHintId::ScTables),
89 nId( nNewId ),
90 nTab1( nTable1 ),
91 nTab2( nTable2 )
95 ScTablesHint::~ScTablesHint()
99 ScIndexHint::ScIndexHint(SfxHintId nNewId, sal_uInt16 nIdx) :
100 SfxHint( nNewId ),
101 nIndex( nIdx )
105 ScIndexHint::~ScIndexHint()
110 * Create new EditView for Cursorposition
112 ScEditViewHint::ScEditViewHint( ScEditEngineDefaulter* pEngine, const ScAddress& rCurPos ) :
113 SfxHint(SfxHintId::ScEditView),
114 pEditEngine( pEngine ),
115 aCursorPos( rCurPos )
119 ScEditViewHint::~ScEditViewHint()
124 * Data for the sorting dialog
126 ScSortItem::ScSortItem( sal_uInt16 nWhichP,
127 ScViewData* ptrViewData,
128 const ScSortParam* pSortData ) :
129 SfxPoolItem ( nWhichP, SfxItemType::ScSortItemType ),
130 pViewData ( ptrViewData )
132 if ( pSortData ) theSortData = *pSortData;
135 ScSortItem::ScSortItem( sal_uInt16 nWhichP,
136 const ScSortParam* pSortData ) :
137 SfxPoolItem ( nWhichP, SfxItemType::ScSortItemType ),
138 pViewData ( nullptr )
140 if ( pSortData ) theSortData = *pSortData;
143 bool ScSortItem::operator==( const SfxPoolItem& rItem ) const
145 assert(SfxPoolItem::operator==(rItem));
147 const ScSortItem& rOther = static_cast<const ScSortItem&>(rItem);
149 return ( (pViewData == rOther.pViewData)
150 && (theSortData == rOther.theSortData) );
153 ScSortItem* ScSortItem::Clone( SfxItemPool * ) const
155 return new ScSortItem( *this );
158 bool ScSortItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /* nMemberUd */ ) const
160 // Return empty value as there is no useful conversion
161 rVal = css::uno::Any();
162 return true;
166 * Data for the Filter dialog
168 ScQueryItem::ScQueryItem( sal_uInt16 nWhichP,
169 ScViewData* ptrViewData,
170 const ScQueryParam* pQueryData ) :
171 SfxPoolItem ( nWhichP, SfxItemType::ScQueryItemType ),
172 pViewData ( ptrViewData ),
173 bIsAdvanced ( false )
175 if (pQueryData)
176 mpQueryData.reset(new ScQueryParam(*pQueryData));
177 else
178 mpQueryData.reset(new ScQueryParam);
181 ScQueryItem::ScQueryItem( sal_uInt16 nWhichP,
182 const ScQueryParam* pQueryData ) :
183 SfxPoolItem ( nWhichP, SfxItemType::ScQueryItemType ),
184 pViewData ( nullptr ),
185 bIsAdvanced ( false )
187 if (pQueryData)
188 mpQueryData.reset(new ScQueryParam(*pQueryData));
189 else
190 mpQueryData.reset(new ScQueryParam);
193 ScQueryItem::ScQueryItem( const ScQueryItem& rItem ) :
194 SfxPoolItem ( rItem ),
195 mpQueryData(new ScQueryParam(*rItem.mpQueryData)),
196 pViewData ( rItem.pViewData ),
197 aAdvSource ( rItem.aAdvSource ),
198 bIsAdvanced ( rItem.bIsAdvanced )
202 ScQueryItem::~ScQueryItem()
206 void ScQueryItem::SetAdvancedQuerySource(const ScRange* pSource)
208 if (pSource)
210 aAdvSource = *pSource;
211 bIsAdvanced = true;
213 else
214 bIsAdvanced = false;
217 const ScQueryParam& ScQueryItem::GetQueryData() const
219 return *mpQueryData;
222 bool ScQueryItem::GetAdvancedQuerySource(ScRange& rSource) const
224 rSource = aAdvSource;
225 return bIsAdvanced;
228 bool ScQueryItem::operator==( const SfxPoolItem& rItem ) const
230 assert(SfxPoolItem::operator==(rItem));
232 const ScQueryItem& rQueryItem = static_cast<const ScQueryItem&>(rItem);
234 return ( (pViewData == rQueryItem.pViewData)
235 && (bIsAdvanced == rQueryItem.bIsAdvanced)
236 && (aAdvSource == rQueryItem.aAdvSource)
237 && (*mpQueryData == *rQueryItem.mpQueryData) );
240 ScQueryItem* ScQueryItem::Clone( SfxItemPool * ) const
242 return new ScQueryItem( *this );
246 * Data for the SubTotal dialog
248 ScSubTotalItem::ScSubTotalItem( sal_uInt16 nWhichP,
249 ScViewData* ptrViewData,
250 const ScSubTotalParam* pSubTotalData ) :
251 SfxPoolItem ( nWhichP, SfxItemType::ScSubTotalItemType ),
252 pViewData ( ptrViewData )
254 if ( pSubTotalData ) theSubTotalData = *pSubTotalData;
257 bool ScSubTotalItem::operator==( const SfxPoolItem& rItem ) const
259 assert(SfxPoolItem::operator==(rItem));
261 const ScSubTotalItem& rSTItem = static_cast<const ScSubTotalItem&>(rItem);
263 return ( (pViewData == rSTItem.pViewData)
264 && (theSubTotalData == rSTItem.theSubTotalData) );
267 ScSubTotalItem* ScSubTotalItem::Clone( SfxItemPool * ) const
269 return new ScSubTotalItem( *this );
272 bool ScSubTotalItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /* nMemberUd */ ) const
274 // Return empty value as there is no useful conversion
275 rVal = css::uno::Any();
276 return true;
280 * Transporter for the UserLIst dialog
282 ScUserListItem::ScUserListItem( sal_uInt16 nWhichP )
283 : SfxPoolItem ( nWhichP, SfxItemType::ScUserListItemType )
287 ScUserListItem::ScUserListItem( const ScUserListItem& rItem )
288 : SfxPoolItem ( rItem )
290 if ( rItem.pUserList )
291 pUserList.reset( new ScUserList( *(rItem.pUserList) ) );
294 ScUserListItem::~ScUserListItem()
298 bool ScUserListItem::operator==( const SfxPoolItem& rItem ) const
300 assert(SfxPoolItem::operator==(rItem));
302 const ScUserListItem& r = static_cast<const ScUserListItem&>(rItem);
303 bool bEqual = false;
305 if ( !pUserList || !r.pUserList )
306 bEqual = ( !pUserList && !r.pUserList );
307 else
308 bEqual = ( *pUserList == *(r.pUserList) );
310 return bEqual;
313 ScUserListItem* ScUserListItem::Clone( SfxItemPool * ) const
315 return new ScUserListItem( *this );
318 void ScUserListItem::SetUserList( const ScUserList& rUserList )
320 pUserList.reset( new ScUserList( rUserList ) );
324 * Data for the Consolidate dialog
326 ScConsolidateItem::ScConsolidateItem(
327 sal_uInt16 nWhichP,
328 const ScConsolidateParam* pConsolidateData ) :
329 SfxPoolItem ( nWhichP, SfxItemType::ScConsolidateItemType )
331 if ( pConsolidateData ) theConsData = *pConsolidateData;
334 bool ScConsolidateItem::operator==( const SfxPoolItem& rItem ) const
336 assert(SfxPoolItem::operator==(rItem));
338 const ScConsolidateItem& rCItem = static_cast<const ScConsolidateItem&>(rItem);
340 return ( theConsData == rCItem.theConsData);
343 ScConsolidateItem* ScConsolidateItem::Clone( SfxItemPool * ) const
345 return new ScConsolidateItem( *this );
349 * Data for the Pivot dialog
351 ScPivotItem::ScPivotItem( sal_uInt16 nWhichP, const ScDPSaveData* pData,
352 const ScRange* pRange, bool bNew ) :
353 SfxPoolItem ( nWhichP, SfxItemType::ScPivotItemType )
355 // pSaveData must always exist
356 if ( pData )
357 pSaveData.reset( new ScDPSaveData(*pData) );
358 else
359 pSaveData.reset( new ScDPSaveData );
360 if ( pRange ) aDestRange = *pRange;
361 bNewSheet = bNew;
364 ScPivotItem::ScPivotItem( const ScPivotItem& rItem ) :
365 SfxPoolItem ( rItem ),
366 aDestRange ( rItem.aDestRange ),
367 bNewSheet ( rItem.bNewSheet )
369 assert(rItem.pSaveData && "pSaveData");
370 pSaveData.reset( new ScDPSaveData(*rItem.pSaveData) );
373 ScPivotItem::~ScPivotItem()
377 bool ScPivotItem::operator==( const SfxPoolItem& rItem ) const
379 assert(SfxPoolItem::operator==(rItem));
381 const ScPivotItem& rPItem = static_cast<const ScPivotItem&>(rItem);
382 OSL_ENSURE( pSaveData && rPItem.pSaveData, "pSaveData" );
383 return ( *pSaveData == *rPItem.pSaveData &&
384 aDestRange == rPItem.aDestRange &&
385 bNewSheet == rPItem.bNewSheet );
388 ScPivotItem* ScPivotItem::Clone( SfxItemPool * ) const
390 return new ScPivotItem( *this );
394 * Data for the Solver dialog
396 ScSolveItem::ScSolveItem( sal_uInt16 nWhichP,
397 const ScSolveParam* pSolveData )
398 : SfxPoolItem ( nWhichP, SfxItemType::ScSolveItemType )
400 if ( pSolveData ) theSolveData = *pSolveData;
403 bool ScSolveItem::operator==( const SfxPoolItem& rItem ) const
405 assert(SfxPoolItem::operator==(rItem));
407 const ScSolveItem& rPItem = static_cast<const ScSolveItem&>(rItem);
409 return ( theSolveData == rPItem.theSolveData );
412 ScSolveItem* ScSolveItem::Clone( SfxItemPool * ) const
414 return new ScSolveItem( *this );
418 * Data for the TabOp dialog
420 ScTabOpItem::ScTabOpItem( sal_uInt16 nWhichP,
421 const ScTabOpParam* pTabOpData )
422 : SfxPoolItem ( nWhichP, SfxItemType::ScTabOpItemType )
424 if ( pTabOpData ) theTabOpData = *pTabOpData;
427 bool ScTabOpItem::operator==( const SfxPoolItem& rItem ) const
429 assert(SfxPoolItem::operator==(rItem));
431 const ScTabOpItem& rPItem = static_cast<const ScTabOpItem&>(rItem);
433 return ( theTabOpData == rPItem.theTabOpData );
436 ScTabOpItem* ScTabOpItem::Clone( SfxItemPool * ) const
438 return new ScTabOpItem( *this );
441 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */