Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/source/ui/dbgui/consdlg.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 <sfx2/dispatch.hxx>
21
22
#include <tabvwsh.hxx>
23
#include <uiitems.hxx>
24
#include <dbdata.hxx>
25
#include <rangenam.hxx>
26
#include <rangeutl.hxx>
27
#include <reffact.hxx>
28
#include <document.hxx>
29
#include <scresid.hxx>
30
31
#include <globstr.hrc>
32
#include <strings.hrc>
33
34
#include <consdlg.hxx>
35
#include <o3tl/safeint.hxx>
36
#include <vcl/svapp.hxx>
37
#include <vcl/weld/Dialog.hxx>
38
#include <vcl/weld/MessageDialog.hxx>
39
#include <vcl/weld/weld.hxx>
40
41
namespace
42
{
43
    void INFOBOX(weld::Window* pWindow, TranslateId id)
44
0
    {
45
0
        std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWindow,
46
0
                                                      VclMessageType::Info, VclButtonsType::Ok,
47
0
                                                      ScResId(id)));
48
0
        xInfoBox->run();
49
0
    }
50
}
51
52
class ScAreaData
53
{
54
public:
55
    ScAreaData()
56
0
    {
57
0
    }
58
59
    void Set( const OUString& rName, const OUString& rArea )
60
0
    {
61
0
        aStrName  = rName;
62
0
        aStrArea  = rArea;
63
0
    }
64
65
    OUString  aStrName;
66
    OUString  aStrArea;
67
};
68
69
ScConsolidateDlg::ScConsolidateDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent,
70
                                   const SfxItemSet& rArgSet)
71
72
0
    : ScAnyRefDlgController(pB, pCW, pParent, u"modules/scalc/ui/consolidatedialog.ui"_ustr, u"ConsolidateDialog"_ustr)
73
0
    , aStrUndefined   ( ScResId( SCSTR_UNDEFINED ) )
74
0
    , theConsData     ( static_cast<const ScConsolidateItem&>(
75
0
                         rArgSet.Get( rArgSet.GetPool()->
76
0
                                          GetWhichIDFromSlotID( SID_CONSOLIDATE ) )
77
0
                                    ).GetData() )
78
0
    , rViewData       ( static_cast<ScTabViewShell*>(SfxViewShell::Current())->
79
0
                              GetViewData() )
80
0
    , rDoc            ( static_cast<ScTabViewShell*>(SfxViewShell::Current())->
81
0
                              GetViewData().GetDocument() )
82
0
    , nAreaDataCount  ( 0 )
83
0
    , nWhichCons      ( rArgSet.GetPool()->GetWhichIDFromSlotID( SID_CONSOLIDATE ) )
84
0
    , bDlgLostFocus   ( false )
85
0
    , m_xLbFunc(m_xBuilder->weld_combo_box(u"func"_ustr))
86
0
    , m_xLbConsAreas(m_xBuilder->weld_tree_view(u"consareas"_ustr))
87
0
    , m_xLbDataArea(m_xBuilder->weld_combo_box(u"lbdataarea"_ustr))
88
0
    , m_xEdDataArea(new formula::RefEdit(m_xBuilder->weld_entry(u"eddataarea"_ustr)))
89
0
    , m_xRbDataArea(new formula::RefButton(m_xBuilder->weld_button(u"rbdataarea"_ustr)))
90
0
    , m_xLbDestArea(m_xBuilder->weld_combo_box(u"lbdestarea"_ustr))
91
0
    , m_xEdDestArea(new formula::RefEdit(m_xBuilder->weld_entry(u"eddestarea"_ustr)))
92
0
    , m_xRbDestArea(new formula::RefButton(m_xBuilder->weld_button(u"rbdestarea"_ustr)))
93
0
    , m_xExpander(m_xBuilder->weld_expander(u"more"_ustr))
94
0
    , m_xBtnByRow(m_xBuilder->weld_check_button(u"byrow"_ustr))
95
0
    , m_xBtnByCol(m_xBuilder->weld_check_button(u"bycol"_ustr))
96
0
    , m_xBtnRefs(m_xBuilder->weld_check_button(u"refs"_ustr))
97
0
    , m_xBtnOk(m_xBuilder->weld_button(u"ok"_ustr))
98
0
    , m_xBtnCancel(m_xBuilder->weld_button(u"cancel"_ustr))
99
0
    , m_xBtnAdd(m_xBuilder->weld_button(u"add"_ustr))
100
0
    , m_xBtnRemove(m_xBuilder->weld_button(u"delete"_ustr))
101
0
    , m_xDataFT(m_xBuilder->weld_label(u"ftdataarea"_ustr))
102
0
    , m_xDestFT(m_xBuilder->weld_label(u"ftdestarea"_ustr))
103
0
{
104
0
    m_pRefInputEdit = m_xEdDataArea.get();
105
0
    Init();
106
0
}
107
108
ScConsolidateDlg::~ScConsolidateDlg()
109
0
{
110
0
}
111
112
void ScConsolidateDlg::Init()
113
0
{
114
0
    OUString aStr;
115
0
    sal_uInt16 i=0;
116
117
0
    m_xRbDataArea->SetReferences(this, m_xEdDataArea.get());
118
0
    m_xEdDataArea->SetReferences(this, m_xDataFT.get());
119
0
    m_xRbDestArea->SetReferences(this, m_xEdDestArea.get());
120
0
    m_xEdDestArea->SetReferences(this, m_xDestFT.get());
121
122
0
    m_xEdDataArea->SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetEditFocusHdl ) );
123
0
    m_xEdDestArea->SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetEditFocusHdl ) );
124
0
    m_xLbDataArea->connect_focus_in( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
125
0
    m_xLbDestArea->connect_focus_in( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
126
0
    m_xEdDataArea->SetModifyHdl( LINK( this, ScConsolidateDlg, ModifyHdl ) );
127
0
    m_xEdDestArea->SetModifyHdl( LINK( this, ScConsolidateDlg, ModifyHdl ) );
128
0
    m_xLbConsAreas->connect_selection_changed(LINK(this, ScConsolidateDlg, SelectTVHdl));
129
0
    m_xLbDataArea->connect_changed( LINK( this, ScConsolidateDlg, SelectCBHdl ) );
130
0
    m_xLbDestArea->connect_changed( LINK( this, ScConsolidateDlg, SelectCBHdl ) );
131
0
    m_xBtnOk->connect_clicked( LINK( this, ScConsolidateDlg, OkHdl ) );
132
0
    m_xBtnCancel->connect_clicked( LINK( this, ScConsolidateDlg, ClickHdl ) );
133
0
    m_xBtnAdd->connect_clicked( LINK( this, ScConsolidateDlg, ClickHdl ) );
134
0
    m_xBtnRemove->connect_clicked( LINK( this, ScConsolidateDlg, ClickHdl ) );
135
136
0
    m_xBtnAdd->set_sensitive(false);
137
0
    m_xBtnRemove->set_sensitive(false);
138
139
0
    m_xBtnByRow->set_active( theConsData.bByRow );
140
0
    m_xBtnByCol->set_active( theConsData.bByCol );
141
0
    m_xBtnRefs->set_active( theConsData.bReferenceData );
142
143
0
    m_xLbFunc->set_active( FuncToLbPos( theConsData.eFunction ) );
144
145
0
    m_xLbConsAreas->set_selection_mode(SelectionMode::Multiple);
146
0
    m_xLbConsAreas->set_size_request(m_xLbConsAreas->get_approximate_digit_width() * 16,
147
0
                                     m_xLbConsAreas->get_height_rows(5));
148
149
    // read consolidation areas
150
0
    m_xLbConsAreas->clear();
151
0
    const formula::FormulaGrammar::AddressConvention eConv = rDoc.GetAddressConvention();
152
0
    for ( i=0; i<theConsData.nDataAreaCount; i++ )
153
0
    {
154
0
        const ScArea& rArea = theConsData.pDataAreas[i];
155
0
        if ( rArea.nTab < rDoc.GetTableCount() )
156
0
        {
157
0
            aStr = ScRange( rArea.nColStart, rArea.nRowStart, rArea.nTab,
158
0
                    rArea.nColEnd, rArea.nRowEnd, rArea.nTab ).Format( rDoc,
159
0
                        ScRefFlags::RANGE_ABS_3D, eConv );
160
0
            m_xLbConsAreas->append_text(aStr);
161
0
        }
162
0
    }
163
164
0
    if ( theConsData.nTab < rDoc.GetTableCount() )
165
0
    {
166
0
        aStr = ScAddress( theConsData.nCol, theConsData.nRow, theConsData.nTab
167
0
                ).Format( ScRefFlags::ADDR_ABS_3D, &rDoc, eConv );
168
0
        m_xEdDestArea->SetText( aStr );
169
0
    }
170
0
    else
171
0
        m_xEdDestArea->SetText(OUString());
172
173
    // Use the ScAreaData helper class to save those range names from the
174
    // RangeNames and database ranges that appear in the ListBoxes.
175
176
0
    ScRangeName*    pRangeNames  = rDoc.GetRangeName();
177
0
    ScDBCollection* pDbNames     = rDoc.GetDBCollection();
178
0
    size_t nRangeCount = pRangeNames ? pRangeNames->size() : 0;
179
0
    size_t nDbCount = pDbNames ? pDbNames->getNamedDBs().size() : 0;
180
181
0
    nAreaDataCount = nRangeCount+nDbCount;
182
0
    pAreaData      = nullptr;
183
184
0
    if ( nAreaDataCount > 0 )
185
0
    {
186
0
        pAreaData.reset( new ScAreaData[nAreaDataCount] );
187
188
0
        OUString aStrName;
189
0
        sal_uInt16 nAt = 0;
190
0
        ScRange aRange;
191
0
        ScAreaNameIterator aIter( rDoc );
192
0
        while ( aIter.Next( aStrName, aRange ) )
193
0
        {
194
0
            OUString aStrArea(aRange.Format(rDoc, ScRefFlags::ADDR_ABS_3D, eConv));
195
0
            pAreaData[nAt++].Set( aStrName, aStrArea );
196
0
        }
197
0
    }
198
199
0
    FillAreaLists();
200
0
    ModifyHdl( *m_xEdDestArea );
201
0
    m_xLbDataArea->set_active( 0 );
202
0
    m_xEdDataArea->SetText(OUString());
203
0
    m_xEdDataArea->GrabFocus();
204
205
    //aFlSep.SetStyle( aFlSep.GetStyle() | WB_VERT );
206
207
    //@BugID 54702 enable/disable only in base class
208
    //SFX_APPWINDOW->set_sensitive(true);
209
0
}
210
211
void ScConsolidateDlg::FillAreaLists()
212
0
{
213
0
    m_xLbDataArea->clear();
214
0
    m_xLbDestArea->clear();
215
0
    m_xLbDataArea->append_text( aStrUndefined );
216
0
    m_xLbDestArea->append_text( aStrUndefined );
217
218
0
    if ( pAreaData && (nAreaDataCount > 0) )
219
0
    {
220
0
        for ( size_t i=0;
221
0
              (i<nAreaDataCount) && (!pAreaData[i].aStrName.isEmpty());
222
0
              i++ )
223
0
        {
224
0
            m_xLbDataArea->append_text(pAreaData[i].aStrName);
225
0
            m_xLbDestArea->append_text(pAreaData[i].aStrName);
226
0
        }
227
0
    }
228
0
}
229
230
// Handover of a range within a table that has been selected by the mouse.
231
// This range is then shown in the reference window as new selection.
232
233
void ScConsolidateDlg::SetReference( const ScRange& rRef, ScDocument& rDocP )
234
0
{
235
0
    if ( !m_pRefInputEdit )
236
0
        return;
237
238
0
    if ( rRef.aStart != rRef.aEnd )
239
0
        RefInputStart( m_pRefInputEdit );
240
241
0
    OUString      aStr;
242
0
    ScRefFlags      nFmt = ScRefFlags::RANGE_ABS_3D;       //!!! nCurTab is still missing
243
0
    const formula::FormulaGrammar::AddressConvention eConv = rDocP.GetAddressConvention();
244
245
0
    if ( rRef.aStart.Tab() != rRef.aEnd.Tab() )
246
0
        nFmt |= ScRefFlags::TAB2_3D;
247
248
0
    if ( m_pRefInputEdit == m_xEdDataArea.get())
249
0
        aStr = rRef.Format(rDocP, nFmt, eConv);
250
0
    else if ( m_pRefInputEdit == m_xEdDestArea.get() )
251
0
        aStr = rRef.aStart.Format(nFmt, &rDocP, eConv);
252
253
0
    m_pRefInputEdit->SetRefString( aStr );
254
0
    ModifyHdl( *m_pRefInputEdit );
255
0
}
256
257
void ScConsolidateDlg::Close()
258
0
{
259
0
    DoClose( ScConsolidateDlgWrapper::GetChildWindowId() );
260
0
}
261
262
void ScConsolidateDlg::SetActive()
263
0
{
264
0
    if ( bDlgLostFocus )
265
0
    {
266
0
        bDlgLostFocus = false;
267
268
0
        if ( m_pRefInputEdit )
269
0
        {
270
0
            m_pRefInputEdit->GrabFocus();
271
0
            ModifyHdl( *m_pRefInputEdit );
272
0
        }
273
0
    }
274
0
    else
275
0
        m_xDialog->grab_focus();
276
277
0
    RefInputDone();
278
0
}
279
280
void ScConsolidateDlg::Deactivate()
281
0
{
282
0
    bDlgLostFocus = true;
283
0
}
284
285
bool ScConsolidateDlg::VerifyEdit( formula::RefEdit* pEd )
286
0
{
287
0
    if (pEd != m_xEdDataArea.get() && pEd != m_xEdDestArea.get())
288
0
        return false;
289
290
0
    SCTAB nTab = rViewData.CurrentTabForData();
291
0
    bool bEditOk = false;
292
0
    OUString theCompleteStr;
293
0
    const formula::FormulaGrammar::AddressConvention eConv = rDoc.GetAddressConvention();
294
295
0
    if ( pEd == m_xEdDataArea.get() )
296
0
    {
297
0
        bEditOk = ScRangeUtil::IsAbsArea( pEd->GetText(), rDoc,
298
0
                                         nTab, &theCompleteStr, nullptr, nullptr, eConv );
299
0
    }
300
0
    else if ( pEd == m_xEdDestArea.get() )
301
0
    {
302
0
        OUString aPosStr;
303
304
0
        ScRangeUtil::CutPosString( pEd->GetText(), aPosStr );
305
0
        bEditOk = ScRangeUtil::IsAbsPos( aPosStr, rDoc,
306
0
                                        nTab, &theCompleteStr, nullptr, eConv );
307
0
    }
308
309
0
    if ( bEditOk )
310
0
        pEd->SetText( theCompleteStr );
311
312
0
    return bEditOk;
313
0
}
314
315
// Handler:
316
317
IMPL_LINK( ScConsolidateDlg, GetEditFocusHdl, formula::RefEdit&, rControl, void )
318
0
{
319
0
    m_pRefInputEdit = &rControl;
320
0
}
321
322
IMPL_LINK( ScConsolidateDlg, GetFocusHdl, weld::Widget&, rControl, void )
323
0
{
324
0
    if (&rControl == m_xLbDataArea.get())
325
0
        m_pRefInputEdit = m_xEdDataArea.get();
326
0
    else if (&rControl == m_xLbDestArea.get())
327
0
        m_pRefInputEdit = m_xEdDestArea.get();
328
0
}
329
330
IMPL_LINK_NOARG(ScConsolidateDlg, OkHdl, weld::Button&, void)
331
0
{
332
0
    const sal_Int32 nDataAreaCount = m_xLbConsAreas->n_children();
333
334
0
    if ( nDataAreaCount > 0 )
335
0
    {
336
0
        ScRefAddress aDestAddress;
337
0
        SCTAB nTab = rViewData.CurrentTabForData();
338
0
        OUString    aDestPosStr( m_xEdDestArea->GetText() );
339
0
        const formula::FormulaGrammar::AddressConvention eConv = rDoc.GetAddressConvention();
340
341
0
        if ( ScRangeUtil::IsAbsPos( aDestPosStr, rDoc, nTab, nullptr, &aDestAddress, eConv ) )
342
0
        {
343
0
            ScConsolidateParam  theOutParam( theConsData );
344
0
            std::unique_ptr<ScArea[]> pDataAreas(new ScArea[nDataAreaCount]);
345
346
0
            for ( sal_Int32 i=0; i<nDataAreaCount; ++i )
347
0
            {
348
0
                ScRangeUtil::MakeArea(m_xLbConsAreas->get_text(i),
349
0
                                      pDataAreas[i], rDoc, nTab, eConv);
350
0
            }
351
352
0
            theOutParam.nCol            = aDestAddress.Col();
353
0
            theOutParam.nRow            = aDestAddress.Row();
354
0
            theOutParam.nTab            = aDestAddress.Tab();
355
0
            theOutParam.eFunction       = LbPosToFunc( m_xLbFunc->get_active() );
356
0
            theOutParam.bByCol          = m_xBtnByCol->get_active();
357
0
            theOutParam.bByRow          = m_xBtnByRow->get_active();
358
0
            theOutParam.bReferenceData  = m_xBtnRefs->get_active();
359
0
            theOutParam.SetAreas( std::move(pDataAreas), nDataAreaCount );
360
361
0
            ScConsolidateItem aOutItem( nWhichCons, &theOutParam );
362
363
0
            SetDispatcherLock( false );
364
0
            SwitchToDocument();
365
0
            GetBindings().GetDispatcher()->ExecuteList(SID_CONSOLIDATE,
366
0
                                      SfxCallMode::SLOT | SfxCallMode::RECORD,
367
0
                                      { &aOutItem });
368
0
            response(RET_OK);
369
0
        }
370
0
        else
371
0
        {
372
0
            INFOBOX(m_xDialog.get(), STR_INVALID_TABREF);
373
0
            m_xEdDestArea->GrabFocus();
374
0
        }
375
0
    }
376
0
    else
377
0
        response(RET_CANCEL); // no area defined -> Cancel
378
0
}
379
380
IMPL_LINK( ScConsolidateDlg, ClickHdl, weld::Button&, rBtn, void )
381
0
{
382
0
    if ( &rBtn == m_xBtnCancel.get() )
383
0
        response(RET_CANCEL);
384
0
    else if ( &rBtn == m_xBtnAdd.get() )
385
0
    {
386
0
        if ( !m_xEdDataArea->GetText().isEmpty() )
387
0
        {
388
0
            OUString    aNewEntry( m_xEdDataArea->GetText() );
389
0
            std::unique_ptr<ScArea[]> ppAreas;
390
0
            sal_uInt16      nAreaCount = 0;
391
0
            const formula::FormulaGrammar::AddressConvention eConv = rDoc.GetAddressConvention();
392
393
0
            if ( ScRangeUtil::IsAbsTabArea( aNewEntry, &rDoc, &ppAreas, &nAreaCount, true, eConv ) )
394
0
            {
395
                // IsAbsTabArea() creates an array of ScArea pointers,
396
                // which have been created dynamically as well.
397
                // These objects need to be deleted here.
398
399
0
                for ( sal_uInt16 i=0; i<nAreaCount; i++ )
400
0
                {
401
0
                    const ScArea& rArea = ppAreas[i];
402
0
                    OUString aNewArea = ScRange( rArea.nColStart, rArea.nRowStart, rArea.nTab,
403
0
                            rArea.nColEnd, rArea.nRowEnd, rArea.nTab
404
0
                            ).Format(rDoc, ScRefFlags::RANGE_ABS_3D, eConv);
405
406
0
                    if (m_xLbConsAreas->find_text(aNewArea) == -1)
407
0
                    {
408
0
                        m_xLbConsAreas->append_text( aNewArea );
409
0
                    }
410
0
                }
411
0
            }
412
0
            else if ( VerifyEdit( m_xEdDataArea.get() ) )
413
0
            {
414
0
                OUString aNewArea( m_xEdDataArea->GetText() );
415
416
0
                if (m_xLbConsAreas->find_text(aNewArea) == -1)
417
0
                    m_xLbConsAreas->append_text(aNewArea);
418
0
                else
419
0
                    INFOBOX(m_xDialog.get(), STR_AREA_ALREADY_INSERTED);
420
0
            }
421
0
            else
422
0
            {
423
0
                INFOBOX(m_xDialog.get(), STR_INVALID_TABREF);
424
0
                m_xEdDataArea->GrabFocus();
425
0
            }
426
0
        }
427
0
    }
428
0
    else if ( &rBtn == m_xBtnRemove.get() )
429
0
    {
430
0
        std::vector<int> aSelectedRows(m_xLbConsAreas->get_selected_rows());
431
0
        std::sort(aSelectedRows.begin(), aSelectedRows.end());
432
0
        for (auto it = aSelectedRows.rbegin(); it != aSelectedRows.rend(); ++it)
433
0
            m_xLbConsAreas->remove(*it);
434
0
        m_xBtnRemove->set_sensitive(false);
435
0
    }
436
0
}
437
438
IMPL_LINK(ScConsolidateDlg, SelectTVHdl, weld::ItemView&, rLb, void)
439
0
{
440
0
    if (rLb.get_selected_index() != -1)
441
0
        m_xBtnRemove->set_sensitive(true);
442
0
    else
443
0
        m_xBtnRemove->set_sensitive(false);
444
0
}
445
446
IMPL_LINK( ScConsolidateDlg, SelectCBHdl, weld::ComboBox&, rLb, void )
447
0
{
448
0
    formula::RefEdit* pEd = (&rLb == m_xLbDataArea.get()) ? m_xEdDataArea.get() : m_xEdDestArea.get();
449
0
    const sal_Int32 nSelPos = rLb.get_active();
450
451
0
    if (   (nSelPos > 0)
452
0
        && (nAreaDataCount > 0)
453
0
        && (pAreaData != nullptr) )
454
0
    {
455
0
        if ( o3tl::make_unsigned(nSelPos) <= nAreaDataCount )
456
0
        {
457
0
            OUString aString( pAreaData[nSelPos-1].aStrArea );
458
459
0
            if ( &rLb == m_xLbDestArea.get() )
460
0
                ScRangeUtil::CutPosString( aString, aString );
461
462
0
            pEd->SetText( aString );
463
464
0
            if ( pEd == m_xEdDataArea.get() )
465
0
                m_xBtnAdd->set_sensitive(true);
466
0
        }
467
0
    }
468
0
    else
469
0
    {
470
0
        pEd->SetText( OUString() );
471
0
        if ( pEd == m_xEdDataArea.get() )
472
0
            m_xBtnAdd->set_sensitive(true);
473
0
    }
474
0
}
475
476
IMPL_LINK( ScConsolidateDlg, ModifyHdl, formula::RefEdit&, rEd, void )
477
0
{
478
0
    if ( &rEd == m_xEdDataArea.get() )
479
0
    {
480
0
        OUString aAreaStr( rEd.GetText() );
481
0
        if ( !aAreaStr.isEmpty() )
482
0
            m_xBtnAdd->set_sensitive(true);
483
0
        else
484
0
            m_xBtnAdd->set_sensitive(false);
485
0
    }
486
0
    else if ( &rEd == m_xEdDestArea.get() )
487
0
    {
488
0
        m_xLbDestArea->set_active(0);
489
0
    }
490
0
}
491
492
// TODO: generalize!
493
// Resource of the ListBox and these two conversion methods are also in
494
// tpsubt and everywhere, where StarCalc functions are selectable.
495
496
ScSubTotalFunc ScConsolidateDlg::LbPosToFunc( sal_Int32 nPos )
497
0
{
498
0
    switch ( nPos )
499
0
    {
500
0
        case  2:    return SUBTOTAL_FUNC_AVE;
501
0
        case  6:    return SUBTOTAL_FUNC_CNT;
502
0
        case  1:    return SUBTOTAL_FUNC_CNT2;
503
0
        case  3:    return SUBTOTAL_FUNC_MAX;
504
0
        case  4:    return SUBTOTAL_FUNC_MIN;
505
0
        case  5:    return SUBTOTAL_FUNC_PROD;
506
0
        case  7:    return SUBTOTAL_FUNC_STD;
507
0
        case  8:    return SUBTOTAL_FUNC_STDP;
508
0
        case  9:    return SUBTOTAL_FUNC_VAR;
509
0
        case 10:    return SUBTOTAL_FUNC_VARP;
510
0
        case  0:
511
0
        default:
512
0
            return SUBTOTAL_FUNC_SUM;
513
0
    }
514
0
}
515
516
sal_Int32 ScConsolidateDlg::FuncToLbPos( ScSubTotalFunc eFunc )
517
0
{
518
0
    switch ( eFunc )
519
0
    {
520
0
        case SUBTOTAL_FUNC_AVE:     return 2;
521
0
        case SUBTOTAL_FUNC_CNT:     return 6;
522
0
        case SUBTOTAL_FUNC_CNT2:    return 1;
523
0
        case SUBTOTAL_FUNC_MAX:     return 3;
524
0
        case SUBTOTAL_FUNC_MIN:     return 4;
525
0
        case SUBTOTAL_FUNC_PROD:    return 5;
526
0
        case SUBTOTAL_FUNC_STD:     return 7;
527
0
        case SUBTOTAL_FUNC_STDP:    return 8;
528
0
        case SUBTOTAL_FUNC_VAR:     return 9;
529
0
        case SUBTOTAL_FUNC_VARP:    return 10;
530
0
        case SUBTOTAL_FUNC_NONE:
531
0
        case SUBTOTAL_FUNC_SUM:
532
0
        default:
533
0
            return 0;
534
0
    }
535
0
}
536
537
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */