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 #pragma once
21 
22 #include <sfx2/tabdlg.hxx>
23 #include <global.hxx>
24 #include <sheetlimits.hxx>
25 
26 class ScViewData;
27 class ScDocument;
28 struct ScSubTotalParam;
29 
30 class ScTpSubTotalGroup : public SfxTabPage
31 {
32 protected:
33     ScTpSubTotalGroup(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet);
34 
35 public:
36     virtual ~ScTpSubTotalGroup() override;
37 
38     bool            DoReset         ( sal_uInt16            nGroupNo,
39                                       const SfxItemSet& rArgSet  );
40     bool            DoFillItemSet   ( sal_uInt16        nGroupNo,
41                                       SfxItemSet&   rArgSet  );
42 protected:
43     const OUString    aStrNone;
44     const OUString    aStrColumn;
45 
46     ScViewData*             pViewData;
47     ScDocument*             pDoc;
48 
49     const sal_uInt16            nWhichSubTotals;
50     const ScSubTotalParam&  rSubTotalData;
51     std::vector<SCCOL>      mnFieldArr;
52     sal_uInt16              nFieldCount;
53 
54     std::unique_ptr<weld::ComboBox> mxLbGroup;
55     std::unique_ptr<weld::TreeView> mxLbColumns;
56     std::unique_ptr<weld::TreeView> mxLbFunctions;
57     std::unique_ptr<weld::CheckButton> mxLbSelectAllColumns;
58 
59 private:
60     void            Init            ();
61     void            FillListBoxes   ();
62     static ScSubTotalFunc  LbPosToFunc     ( sal_uInt16 nPos );
63     static sal_uInt16      FuncToLbPos     ( ScSubTotalFunc eFunc );
64     sal_uInt16          GetFieldSelPos  ( SCCOL nField );
65 
66     // Handler ------------------------
67     DECL_LINK( SelectListBoxHdl, weld::ComboBox&, void );
68     DECL_LINK( SelectTreeListBoxHdl, weld::TreeView&, void );
69     DECL_LINK(CheckHdl, const weld::TreeView::iter_col&, void);
70     DECL_LINK(CheckBoxHdl, weld::Toggleable&, void);
71     void SelectHdl(const weld::Widget*);
72 };
73 
74 class ScTpSubTotalGroup1 final : public ScTpSubTotalGroup
75 {
76 public:
77     ScTpSubTotalGroup1( weld::Container* pPage, weld::DialogController* pController,
78                         const SfxItemSet&    rArgSet );
79     static std::unique_ptr<SfxTabPage> Create      ( weld::Container* pPage, weld::DialogController* pController,
80             const SfxItemSet*     rArgSet );
81     virtual ~ScTpSubTotalGroup1() override;
82 
83     virtual bool        FillItemSet ( SfxItemSet* rArgSet ) override;
84     virtual void        Reset       ( const SfxItemSet* rArgSet ) override;
85 };
86 
87 class ScTpSubTotalGroup2 final : public ScTpSubTotalGroup
88 {
89 public:
90     ScTpSubTotalGroup2( weld::Container* pPage, weld::DialogController* pController,
91                         const SfxItemSet&    rArgSet );
92     static std::unique_ptr<SfxTabPage> Create      ( weld::Container* pPage, weld::DialogController* pController,
93             const SfxItemSet*     rArgSet );
94     virtual ~ScTpSubTotalGroup2() override;
95 
96     virtual bool        FillItemSet ( SfxItemSet* rArgSet ) override;
97     virtual void        Reset       ( const SfxItemSet* rArgSet ) override;
98 };
99 
100 class ScTpSubTotalGroup3 final : public ScTpSubTotalGroup
101 {
102 public:
103     ScTpSubTotalGroup3( weld::Container* pPage, weld::DialogController* pController,
104                         const SfxItemSet&    rArgSet );
105     static  std::unique_ptr<SfxTabPage> Create      ( weld::Container* pPage, weld::DialogController* pController,
106             const SfxItemSet*     rArgSet );
107     virtual ~ScTpSubTotalGroup3() override;
108 
109     virtual bool        FillItemSet ( SfxItemSet* rArgSet ) override;
110     virtual void        Reset       ( const SfxItemSet* rArgSet ) override;
111 };
112 
113 class ScTpSubTotalOptions final : public SfxTabPage
114 {
115 public:
116     ScTpSubTotalOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet);
117     static std::unique_ptr<SfxTabPage>  Create      ( weld::Container* pPage, weld::DialogController* pController,
118             const SfxItemSet*     rArgSet );
119     virtual ~ScTpSubTotalOptions() override;
120 
121     virtual bool        FillItemSet ( SfxItemSet* rArgSet ) override;
122     virtual void        Reset       ( const SfxItemSet* rArgSet ) override;
123 
124 private:
125     void Init                   ();
126     void FillUserSortListBox    ();
127 
128     // Handler ------------------------
129     DECL_LINK(CheckHdl, weld::Toggleable&, void);
130 
131     ScViewData*             pViewData;
132     ScDocument*             pDoc;
133     const sal_uInt16        nWhichSubTotals;
134     const ScSubTotalParam&  rSubTotalData;
135 
136     std::unique_ptr<weld::CheckButton> m_xBtnPagebreak;
137     std::unique_ptr<weld::CheckButton> m_xBtnCase;
138     std::unique_ptr<weld::CheckButton> m_xBtnSort;
139     std::unique_ptr<weld::Label> m_xFlSort;
140     std::unique_ptr<weld::RadioButton> m_xBtnAscending;
141     std::unique_ptr<weld::RadioButton> m_xBtnDescending;
142     std::unique_ptr<weld::CheckButton> m_xBtnFormats;
143     std::unique_ptr<weld::CheckButton> m_xBtnUserDef;
144     std::unique_ptr<weld::ComboBox> m_xLbUserDef;
145 };
146 
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
148