summaryrefslogtreecommitdiff
path: root/sc/source/ui/inc/PivotLayoutDialog.hxx
blob: 25f12db90e5dac80885783c6a61c1ad59c830a57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 */

#ifndef INCLUDED_SC_SOURCE_UI_INC_PIVOTLAYOUTDIALOG_HXX
#define INCLUDED_SC_SOURCE_UI_INC_PIVOTLAYOUTDIALOG_HXX

#include <svx/checklbx.hxx>
#include <vcl/lstbox.hxx>
#include "anyrefdg.hxx"
#include <dpobject.hxx>
#include <dpsave.hxx>
#include <dpshttab.hxx>
#include <document.hxx>
#include "viewdata.hxx"

#include "PivotLayoutTreeList.hxx"
#include "PivotLayoutTreeListData.hxx"
#include "PivotLayoutTreeListLabel.hxx"

class ScItemValue final
{
public:
    OUString maName;
    ScPivotFuncData maFunctionData;
    ScItemValue* mpOriginalItemValue;

    ScItemValue(OUString const & aName, SCCOL nColumn, PivotFunc nFunctionMask);
    ScItemValue(const ScItemValue* pInputItemValue);

    ~ScItemValue();
};

class ScPivotLayoutDialog : public ScAnyRefDlg
{
public:
    ScDPObject maPivotTableObject;

private:
    ScViewData* mpViewData;
    ScDocument* mpDocument;

    bool mbNewPivotTable;

    VclPtr<ScPivotLayoutTreeListLabel> mpListBoxField;
    VclPtr<ScPivotLayoutTreeList>      mpListBoxPage;
    VclPtr<ScPivotLayoutTreeList>      mpListBoxColumn;
    VclPtr<ScPivotLayoutTreeList>      mpListBoxRow;
    VclPtr<ScPivotLayoutTreeListData>  mpListBoxData;

    VclPtr<CheckBox> mpCheckIgnoreEmptyRows;
    VclPtr<CheckBox> mpCheckTotalColumns;
    VclPtr<CheckBox> mpCheckAddFilter;
    VclPtr<CheckBox> mpCheckIdentifyCategories;
    VclPtr<CheckBox> mpCheckTotalRows;
    VclPtr<CheckBox> mpCheckDrillToDetail;

    VclPtr<RadioButton> mpSourceRadioNamedRange;
    VclPtr<RadioButton> mpSourceRadioSelection;

    VclPtr<ListBox>            mpSourceListBox;
    VclPtr<formula::RefEdit>   mpSourceEdit;
    VclPtr<formula::RefButton> mpSourceButton;

    VclPtr<RadioButton>        mpDestinationRadioNewSheet;
    VclPtr<RadioButton>        mpDestinationRadioNamedRange;
    VclPtr<RadioButton>        mpDestinationRadioSelection;

    VclPtr<ListBox>            mpDestinationListBox;
    VclPtr<formula::RefEdit>   mpDestinationEdit;
    VclPtr<formula::RefButton> mpDestinationButton;

    VclPtr<PushButton>       mpBtnOK;
    VclPtr<CancelButton>     mpBtnCancel;

    VclPtr<formula::RefEdit>   mpActiveEdit;
    ScAddress::Details  maAddressDetails;
    bool                mbDialogLostFocus;

    DECL_LINK(CancelClicked,       Button*, void);
    DECL_LINK(OKClicked,           Button*, void);
    DECL_LINK(GetFocusHandler,     Control&, void);
    DECL_LINK(LoseFocusHandler,    Control&, void);
    DECL_LINK(ToggleSource,        RadioButton&, void);
    DECL_LINK(ToggleDestination,   RadioButton&, void);
    DECL_LINK(SourceListSelected,  ListBox&, void);
    DECL_LINK(SourceEditModified,  Edit&, void);
    void ToggleSource();
    void ToggleDestination();
    virtual bool Close() override;

    ScPivotParam maPivotParameters;

    // UI
    void SetupSource();
    void SetupDestination();
    void FillValuesToListBoxes();

    // Other
    bool GetDestination(ScRange& aDestinationRange, bool& bToNewSheet);

public:
    ScPivotLayoutDialog(SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, vcl::Window* pParent,
                             ScViewData* pViewData, const ScDPObject* pPivotTableObject, bool bCreateNewPivotTable);
    virtual ~ScPivotLayoutDialog() override;
    virtual void dispose() override;

    virtual void SetReference(const ScRange& rReferenceRange, ScDocument* pDocument) override;
    virtual void SetActive() override;
    virtual bool IsRefInputMode() const override;

    void ItemInserted(const ScItemValue* pItemValue, ScPivotLayoutTreeList::SvPivotTreeListType eType);

    void UpdateSourceRange();

    void ApplyChanges();
    void ApplySaveData(ScDPSaveData& rSaveData);
    void ApplyLabelData(const ScDPSaveData& rSaveData);

    ScItemValue* GetItem(SCCOL nColumn);
    bool IsDataElement(SCCOL nColumn);

    ScDPLabelData& GetLabelData(SCCOL nColumn);
    ScDPLabelDataVector& GetLabelDataVector() { return maPivotParameters.maLabelArray;}
    void PushDataFieldNames(std::vector<ScDPName>& rDataFieldNames);

    ScPivotLayoutTreeListBase* FindListBoxFor(const SvTreeListEntry *pEntry);
};

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

#endif