Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/source/ui/app/uiitems.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
20
#include <uiitems.hxx>
21
22
#include <userlist.hxx>
23
#include <dpsave.hxx>
24
#include <queryparam.hxx>
25
26
#include <osl/diagnose.h>
27
#include <editeng/editobj.hxx>
28
#include <utility>
29
30
/**
31
 * Status update for entry field
32
 */
33
ScInputStatusItem::ScInputStatusItem(
34
    sal_uInt16 nWhichP, const ScAddress& rCurPos, const ScAddress& rStartPos,
35
    const ScAddress& rEndPos, OUString _aString, const EditTextObject* pData ) :
36
0
    SfxPoolItem ( nWhichP ),
37
0
    aCursorPos  ( rCurPos ),
38
0
    aStartPos   ( rStartPos ),
39
0
    aEndPos     ( rEndPos ),
40
0
    aString     (std::move( _aString )),
41
0
    pEditData   ( pData ? pData->Clone() : nullptr )
42
0
{
43
0
}
44
45
ScInputStatusItem::ScInputStatusItem( const ScInputStatusItem& rItem ) :
46
0
    SfxPoolItem ( rItem ),
47
0
    aCursorPos  ( rItem.aCursorPos ),
48
0
    aStartPos   ( rItem.aStartPos ),
49
0
    aEndPos     ( rItem.aEndPos ),
50
0
    aString     ( rItem.aString ),
51
0
    pEditData   ( rItem.pEditData ? rItem.pEditData->Clone() : nullptr ),
52
0
    maMisspellRanges(rItem.maMisspellRanges)
53
0
{
54
0
}
55
56
ScInputStatusItem::~ScInputStatusItem()
57
0
{
58
0
}
59
60
bool ScInputStatusItem::operator==( const SfxPoolItem& rItem ) const
61
0
{
62
0
    assert(SfxPoolItem::operator==(rItem));
63
64
0
    return (aStartPos  == static_cast<const ScInputStatusItem&>(rItem).aStartPos)
65
0
             && (aEndPos    == static_cast<const ScInputStatusItem&>(rItem).aEndPos)
66
0
             && (aCursorPos == static_cast<const ScInputStatusItem&>(rItem).aCursorPos)
67
0
             && (aString    == static_cast<const ScInputStatusItem&>(rItem).aString);
68
             //TODO: Compare Edit data!
69
0
}
70
71
ScInputStatusItem* ScInputStatusItem::Clone( SfxItemPool * ) const
72
0
{
73
0
    return new ScInputStatusItem( *this );
74
0
}
75
76
void ScInputStatusItem::SetMisspellRanges( const sc::MisspellRangeResult& rRanges )
77
0
{
78
0
    maMisspellRanges = rRanges;
79
0
}
80
81
// ScPaintHint was moved to hints.cxx
82
83
/**
84
 * Adapt Views when inserting/deleting a table
85
 */
86
ScTablesHint::ScTablesHint(sal_uInt16 nNewId, SCTAB nTable1, SCTAB nTable2) :
87
22
    SfxHint(SfxHintId::ScTables),
88
22
    nId( nNewId ),
89
22
    nTab1( nTable1 ),
90
22
    nTab2( nTable2 )
91
22
{
92
22
}
93
94
ScTablesHint::~ScTablesHint()
95
22
{
96
22
}
97
98
ScIndexHint::ScIndexHint(SfxHintId nNewId, sal_uInt16 nIdx) :
99
0
    SfxHint( nNewId ),
100
0
    nIndex( nIdx )
101
0
{
102
0
}
103
104
ScIndexHint::~ScIndexHint()
105
0
{
106
0
}
107
108
/**
109
 * Create new EditView for Cursorposition
110
 */
111
ScEditViewHint::ScEditViewHint( ScEditEngineDefaulter& rEngine, const ScAddress& rCurPos ) :
112
0
    SfxHint(SfxHintId::ScEditView),
113
0
    rEditEngine( rEngine ),
114
0
    aCursorPos( rCurPos )
115
0
{
116
0
}
117
118
ScEditViewHint::~ScEditViewHint()
119
0
{
120
0
}
121
122
/**
123
 * Data for the sorting dialog
124
 */
125
ScSortItem::ScSortItem( sal_uInt16              nWhichP,
126
                        ScViewData*         ptrViewData,
127
                        const ScSortParam*  pSortData ) :
128
11
        SfxPoolItem ( nWhichP ),
129
11
        pViewData   ( ptrViewData )
130
11
{
131
11
    if ( pSortData ) theSortData = *pSortData;
132
11
}
133
134
bool ScSortItem::operator==( const SfxPoolItem& rItem ) const
135
0
{
136
0
    assert(SfxPoolItem::operator==(rItem));
137
138
0
    const ScSortItem& rOther = static_cast<const ScSortItem&>(rItem);
139
140
0
    return (   (pViewData   == rOther.pViewData)
141
0
            && (theSortData == rOther.theSortData) );
142
0
}
143
144
ScSortItem* ScSortItem::Clone( SfxItemPool * ) const
145
0
{
146
0
    return new ScSortItem( *this );
147
0
}
148
149
bool ScSortItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /* nMemberUd */ ) const
150
0
{
151
    // Return empty value as there is no useful conversion
152
0
    rVal = css::uno::Any();
153
0
    return true;
154
0
}
155
156
/**
157
 * Data for the Filter dialog
158
 */
159
ScQueryItem::ScQueryItem( sal_uInt16                nWhichP,
160
                          const ScQueryParam*   pQueryData ) :
161
11
        SfxPoolItem ( nWhichP ),
162
11
        bIsAdvanced ( false )
163
11
{
164
11
    if (pQueryData)
165
0
        mpQueryData.reset(new ScQueryParam(*pQueryData));
166
11
    else
167
11
        mpQueryData.reset(new ScQueryParam);
168
11
}
169
170
ScQueryItem::ScQueryItem( const ScQueryItem& rItem ) :
171
0
        SfxPoolItem ( rItem ),
172
0
        mpQueryData(new ScQueryParam(*rItem.mpQueryData)),
173
0
        aAdvSource  ( rItem.aAdvSource ),
174
0
        bIsAdvanced ( rItem.bIsAdvanced )
175
0
{
176
0
}
177
178
ScQueryItem::~ScQueryItem()
179
11
{
180
11
}
181
182
void ScQueryItem::SetAdvancedQuerySource(const ScRange* pSource)
183
0
{
184
0
    if (pSource)
185
0
    {
186
0
        aAdvSource = *pSource;
187
0
        bIsAdvanced = true;
188
0
    }
189
0
    else
190
0
        bIsAdvanced = false;
191
0
}
192
193
const ScQueryParam& ScQueryItem::GetQueryData() const
194
0
{
195
0
    return *mpQueryData;
196
0
}
197
198
bool ScQueryItem::GetAdvancedQuerySource(ScRange& rSource) const
199
0
{
200
0
    rSource = aAdvSource;
201
0
    return bIsAdvanced;
202
0
}
203
204
bool ScQueryItem::operator==( const SfxPoolItem& rItem ) const
205
0
{
206
0
    assert(SfxPoolItem::operator==(rItem));
207
208
0
    const ScQueryItem& rQueryItem = static_cast<const ScQueryItem&>(rItem);
209
210
0
    return ( (bIsAdvanced  == rQueryItem.bIsAdvanced)
211
0
            && (aAdvSource   == rQueryItem.aAdvSource)
212
0
            && (*mpQueryData == *rQueryItem.mpQueryData) );
213
0
}
214
215
ScQueryItem* ScQueryItem::Clone( SfxItemPool * ) const
216
0
{
217
0
    return new ScQueryItem( *this );
218
0
}
219
220
/**
221
 * Data for the SubTotal dialog
222
 */
223
ScSubTotalItem::ScSubTotalItem( sal_uInt16                  nWhichP,
224
                                ScViewData*             ptrViewData,
225
                                const ScSubTotalParam*  pSubTotalData ) :
226
11
        SfxPoolItem ( nWhichP ),
227
11
        pViewData   ( ptrViewData )
228
11
{
229
11
    if ( pSubTotalData ) theSubTotalData = *pSubTotalData;
230
11
}
231
232
bool ScSubTotalItem::operator==( const SfxPoolItem& rItem ) const
233
0
{
234
0
    assert(SfxPoolItem::operator==(rItem));
235
236
0
    const ScSubTotalItem& rSTItem = static_cast<const ScSubTotalItem&>(rItem);
237
238
0
    return (   (pViewData       == rSTItem.pViewData)
239
0
            && (theSubTotalData == rSTItem.theSubTotalData) );
240
0
}
241
242
ScSubTotalItem* ScSubTotalItem::Clone( SfxItemPool * ) const
243
0
{
244
0
    return new ScSubTotalItem( *this );
245
0
}
246
247
bool ScSubTotalItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /* nMemberUd */ ) const
248
0
{
249
    // Return empty value as there is no useful conversion
250
0
    rVal = css::uno::Any();
251
0
    return true;
252
0
}
253
254
/**
255
 * Transporter for the UserLIst dialog
256
 */
257
ScUserListItem::ScUserListItem( sal_uInt16 nWhichP )
258
11
    :   SfxPoolItem ( nWhichP )
259
11
{
260
11
}
261
262
ScUserListItem::ScUserListItem( const ScUserListItem& rItem )
263
0
    :   SfxPoolItem ( rItem )
264
0
{
265
0
    if ( rItem.pUserList )
266
0
        pUserList.reset( new ScUserList( *(rItem.pUserList) ) );
267
0
}
268
269
ScUserListItem::~ScUserListItem()
270
11
{
271
11
}
272
273
bool ScUserListItem::operator==( const SfxPoolItem& rItem ) const
274
0
{
275
0
    assert(SfxPoolItem::operator==(rItem));
276
277
0
    const ScUserListItem& r = static_cast<const ScUserListItem&>(rItem);
278
0
    bool bEqual = false;
279
280
0
    if ( !pUserList || !r.pUserList )
281
0
        bEqual = ( !pUserList && !r.pUserList );
282
0
    else
283
0
        bEqual = ( *pUserList == *(r.pUserList) );
284
285
0
    return bEqual;
286
0
}
287
288
ScUserListItem* ScUserListItem::Clone( SfxItemPool * ) const
289
0
{
290
0
    return new ScUserListItem( *this );
291
0
}
292
293
void ScUserListItem::SetUserList( const ScUserList& rUserList )
294
0
{
295
0
    pUserList.reset( new ScUserList( rUserList ) );
296
0
}
297
298
/**
299
 * Data for the Consolidate dialog
300
 */
301
ScConsolidateItem::ScConsolidateItem(
302
                            sal_uInt16                      nWhichP,
303
                            const ScConsolidateParam*   pConsolidateData ) :
304
11
        SfxPoolItem ( nWhichP )
305
11
{
306
11
    if ( pConsolidateData ) theConsData = *pConsolidateData;
307
11
}
308
309
bool ScConsolidateItem::operator==( const SfxPoolItem& rItem ) const
310
0
{
311
0
    assert(SfxPoolItem::operator==(rItem));
312
313
0
    const ScConsolidateItem& rCItem = static_cast<const ScConsolidateItem&>(rItem);
314
315
0
    return ( theConsData == rCItem.theConsData);
316
0
}
317
318
ScConsolidateItem* ScConsolidateItem::Clone( SfxItemPool * ) const
319
0
{
320
0
    return new ScConsolidateItem( *this );
321
0
}
322
323
/**
324
 * Data for the Pivot dialog
325
 */
326
ScPivotItem::ScPivotItem( sal_uInt16 nWhichP, const ScDPSaveData* pData,
327
                             const ScRange* pRange, bool bNew ) :
328
11
        SfxPoolItem ( nWhichP )
329
11
{
330
    // pSaveData must always exist
331
11
    if ( pData )
332
0
        pSaveData.reset( new ScDPSaveData(*pData) );
333
11
    else
334
11
        pSaveData.reset( new ScDPSaveData );
335
11
    if ( pRange ) aDestRange = *pRange;
336
11
    bNewSheet = bNew;
337
11
}
338
339
ScPivotItem::ScPivotItem( const ScPivotItem& rItem ) :
340
0
        SfxPoolItem ( rItem ),
341
0
        aDestRange  ( rItem.aDestRange ),
342
0
        bNewSheet   ( rItem.bNewSheet )
343
0
{
344
0
    assert(rItem.pSaveData && "pSaveData");
345
0
    pSaveData.reset( new ScDPSaveData(*rItem.pSaveData) );
346
0
}
347
348
ScPivotItem::~ScPivotItem()
349
11
{
350
11
}
351
352
bool ScPivotItem::operator==( const SfxPoolItem& rItem ) const
353
0
{
354
0
    assert(SfxPoolItem::operator==(rItem));
355
356
0
    const ScPivotItem& rPItem = static_cast<const ScPivotItem&>(rItem);
357
0
    OSL_ENSURE( pSaveData && rPItem.pSaveData, "pSaveData" );
358
0
    return ( *pSaveData == *rPItem.pSaveData &&
359
0
             aDestRange == rPItem.aDestRange &&
360
0
             bNewSheet  == rPItem.bNewSheet );
361
0
}
362
363
ScPivotItem* ScPivotItem::Clone( SfxItemPool * ) const
364
0
{
365
0
    return new ScPivotItem( *this );
366
0
}
367
368
/**
369
 * Data for the Solver dialog
370
 */
371
ScSolveItem::ScSolveItem( sal_uInt16                nWhichP,
372
                          const ScSolveParam*   pSolveData )
373
11
    :   SfxPoolItem ( nWhichP )
374
11
{
375
11
    if ( pSolveData ) theSolveData = *pSolveData;
376
11
}
377
378
bool ScSolveItem::operator==( const SfxPoolItem& rItem ) const
379
0
{
380
0
    assert(SfxPoolItem::operator==(rItem));
381
382
0
    const ScSolveItem& rPItem = static_cast<const ScSolveItem&>(rItem);
383
384
0
    return ( theSolveData == rPItem.theSolveData );
385
0
}
386
387
ScSolveItem* ScSolveItem::Clone( SfxItemPool * ) const
388
0
{
389
0
    return new ScSolveItem( *this );
390
0
}
391
392
/**
393
 * Data for the TabOp dialog
394
 */
395
ScTabOpItem::ScTabOpItem( sal_uInt16                nWhichP,
396
                          const ScTabOpParam*   pTabOpData )
397
0
    :   SfxPoolItem ( nWhichP )
398
0
{
399
0
    if ( pTabOpData ) theTabOpData = *pTabOpData;
400
0
}
401
402
bool ScTabOpItem::operator==( const SfxPoolItem& rItem ) const
403
0
{
404
0
    assert(SfxPoolItem::operator==(rItem));
405
406
0
    const ScTabOpItem& rPItem = static_cast<const ScTabOpItem&>(rItem);
407
408
0
    return ( theTabOpData == rPItem.theTabOpData );
409
0
}
410
411
ScTabOpItem* ScTabOpItem::Clone( SfxItemPool * ) const
412
0
{
413
0
    return new ScTabOpItem( *this );
414
0
}
415
416
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */