Line data Source code
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 : #ifndef INCLUDED_SC_SOURCE_UI_INC_PVFUNDLG_HXX
21 : #define INCLUDED_SC_SOURCE_UI_INC_PVFUNDLG_HXX
22 :
23 : #include <com/sun/star/sheet/DataPilotFieldReference.hpp>
24 : #include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
25 :
26 : #include <vcl/fixed.hxx>
27 : #include <vcl/layout.hxx>
28 : #include <vcl/lstbox.hxx>
29 : #include <vcl/dialog.hxx>
30 : #include <vcl/button.hxx>
31 : #include <vcl/morebtn.hxx>
32 : #include <vcl/field.hxx>
33 : #include <svtools/stdctrl.hxx>
34 : #include <svx/checklbx.hxx>
35 : #include <sfx2/itemconnect.hxx>
36 : #include "pivot.hxx"
37 :
38 : #include <boost/scoped_ptr.hpp>
39 : #include <unordered_map>
40 :
41 : typedef sfx::ListBoxWrapper< sal_Int32 > ScDPListBoxWrapper;
42 :
43 : class ScDPObject;
44 :
45 0 : class ScDPFunctionListBox : public ListBox
46 : {
47 : public:
48 : ScDPFunctionListBox(vcl::Window* pParent, WinBits nStyle);
49 :
50 : void SetSelection( sal_uInt16 nFuncMask );
51 : sal_uInt16 GetSelection() const;
52 :
53 : private:
54 : void FillFunctionNames();
55 : };
56 :
57 : class ScDPFunctionDlg : public ModalDialog
58 : {
59 : typedef std::unordered_map< OUString, OUString, OUStringHash > NameMapType;
60 : public:
61 : explicit ScDPFunctionDlg( vcl::Window* pParent, const ScDPLabelDataVector& rLabelVec,
62 : const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData );
63 : virtual ~ScDPFunctionDlg();
64 : virtual void dispose() SAL_OVERRIDE;
65 : sal_uInt16 GetFuncMask() const;
66 : ::com::sun::star::sheet::DataPilotFieldReference GetFieldRef() const;
67 :
68 : private:
69 : void Init( const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData );
70 :
71 : const OUString& GetBaseFieldName(const OUString& rLayoutName) const;
72 : const OUString& GetBaseItemName(const OUString& rLayoutName) const;
73 :
74 : /** Searches for a listbox entry, starts search at specified position. */
75 : sal_Int32 FindBaseItemPos( const OUString& rEntry, sal_Int32 nStartPos ) const;
76 :
77 : DECL_LINK( SelectHdl, ListBox* );
78 : DECL_LINK( DblClickHdl, void* );
79 :
80 : private:
81 : VclPtr<ScDPFunctionListBox> mpLbFunc;
82 : VclPtr<FixedText> mpFtName;
83 : VclPtr<ListBox> mpLbType;
84 : VclPtr<FixedText> mpFtBaseField;
85 : VclPtr<ListBox> mpLbBaseField;
86 : VclPtr<FixedText> mpFtBaseItem;
87 : VclPtr<ListBox> mpLbBaseItem;
88 : VclPtr<OKButton> mpBtnOk;
89 :
90 : NameMapType maBaseFieldNameMap; // cache for base field display -> original name.
91 : NameMapType maBaseItemNameMap; // cache for base item display -> original name.
92 :
93 : boost::scoped_ptr<ScDPListBoxWrapper> mxLbTypeWrp; /// Wrapper for direct usage of API constants.
94 :
95 : const ScDPLabelDataVector& mrLabelVec; /// Data of all labels.
96 : bool mbEmptyItem; /// true = Empty base item in listbox.
97 : };
98 :
99 : class ScDPSubtotalDlg : public ModalDialog
100 : {
101 : public:
102 : explicit ScDPSubtotalDlg( vcl::Window* pParent, ScDPObject& rDPObj,
103 : const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData,
104 : const ScDPNameVec& rDataFields, bool bEnableLayout );
105 : virtual ~ScDPSubtotalDlg();
106 : virtual void dispose() SAL_OVERRIDE;
107 : sal_uInt16 GetFuncMask() const;
108 :
109 : void FillLabelData( ScDPLabelData& rLabelData ) const;
110 :
111 : private:
112 : void Init( const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData );
113 :
114 : DECL_LINK(DblClickHdl, void *);
115 : DECL_LINK( RadioClickHdl, RadioButton* );
116 : DECL_LINK( ClickHdl, PushButton* );
117 :
118 : private:
119 : VclPtr<RadioButton> mpRbNone;
120 : VclPtr<RadioButton> mpRbAuto;
121 : VclPtr<RadioButton> mpRbUser;
122 : VclPtr<ScDPFunctionListBox> mpLbFunc;
123 : VclPtr<FixedText> mpFtName;
124 : VclPtr<CheckBox> mpCbShowAll;
125 : VclPtr<OKButton> mpBtnOk;
126 : VclPtr<PushButton> mpBtnOptions;
127 :
128 : ScDPObject& mrDPObj; /// The DataPilot object (for member names).
129 : const ScDPNameVec& mrDataFields; /// The list of all data field names.
130 :
131 : ScDPLabelData maLabelData; /// Cache for sub dialog.
132 : bool mbEnableLayout; /// true = Enable Layout mode controls.
133 : };
134 :
135 : class ScDPSubtotalOptDlg : public ModalDialog
136 : {
137 : public:
138 : explicit ScDPSubtotalOptDlg( vcl::Window* pParent, ScDPObject& rDPObj,
139 : const ScDPLabelData& rLabelData, const ScDPNameVec& rDataFields,
140 : bool bEnableLayout );
141 : virtual ~ScDPSubtotalOptDlg();
142 : virtual void dispose() SAL_OVERRIDE;
143 : void FillLabelData( ScDPLabelData& rLabelData ) const;
144 :
145 : private:
146 : void Init( const ScDPNameVec& rDataFields, bool bEnableLayout );
147 : void InitHideListBox();
148 :
149 : ScDPName GetFieldName(const OUString& rLayoutName) const;
150 :
151 : /** Searches for a listbox entry, starts search at specified position. */
152 : sal_Int32 FindListBoxEntry( const ListBox& rLBox, const OUString& rEntry, sal_Int32 nStartPos ) const;
153 :
154 : DECL_LINK( RadioClickHdl, RadioButton* );
155 : DECL_LINK( CheckHdl, CheckBox* );
156 : DECL_LINK( SelectHdl, ListBox* );
157 :
158 : private:
159 : VclPtr<ListBox> m_pLbSortBy;
160 : VclPtr<RadioButton> m_pRbSortAsc;
161 : VclPtr<RadioButton> m_pRbSortDesc;
162 : VclPtr<RadioButton> m_pRbSortMan;
163 : VclPtr<VclContainer> m_pLayoutFrame;
164 : VclPtr<ListBox> m_pLbLayout;
165 : VclPtr<CheckBox> m_pCbLayoutEmpty;
166 : VclPtr<CheckBox> m_pCbRepeatItemLabels;
167 : VclPtr<CheckBox> m_pCbShow;
168 : VclPtr<NumericField> m_pNfShow;
169 : VclPtr<FixedText> m_pFtShow;
170 : VclPtr<FixedText> m_pFtShowFrom;
171 : VclPtr<ListBox> m_pLbShowFrom;
172 : VclPtr<FixedText> m_pFtShowUsing;
173 : VclPtr<ListBox> m_pLbShowUsing;
174 : VclPtr<VclContainer> m_pHideFrame;
175 : VclPtr<SvxCheckListBox> m_pLbHide;
176 : VclPtr<FixedText> m_pFtHierarchy;
177 : VclPtr<ListBox> m_pLbHierarchy;
178 :
179 : boost::scoped_ptr<ScDPListBoxWrapper> m_xLbLayoutWrp; /// Wrapper for direct usage of API constants.
180 : boost::scoped_ptr<ScDPListBoxWrapper> m_xLbShowFromWrp; /// Wrapper for direct usage of API constants.
181 :
182 : ScDPObject& mrDPObj; /// The DataPilot object (for member names).
183 : ScDPLabelData maLabelData; /// Cache for members data.
184 :
185 : typedef std::unordered_map<OUString, ScDPName, OUStringHash> NameMapType;
186 : NameMapType maDataFieldNameMap; /// Cache for displayed name to field name mapping.
187 : };
188 :
189 : class ScDPShowDetailDlg : public ModalDialog
190 : {
191 : public:
192 : explicit ScDPShowDetailDlg( vcl::Window* pParent, ScDPObject& rDPObj, sal_uInt16 nOrient );
193 : virtual ~ScDPShowDetailDlg();
194 : virtual void dispose() SAL_OVERRIDE;
195 : virtual short Execute() SAL_OVERRIDE;
196 :
197 : /**
198 : * @return String internal name of the selected field. Note that this may
199 : * be different from the name displayed in the dialog if the field
200 : * has a layout name.
201 : */
202 : OUString GetDimensionName() const;
203 :
204 : private:
205 : DECL_LINK( DblClickHdl, ListBox* );
206 :
207 : private:
208 : VclPtr<ListBox> mpLbDims;
209 : VclPtr<OKButton> mpBtnOk;
210 :
211 : typedef std::unordered_map<OUString, long, OUStringHash> DimNameIndexMap;
212 : DimNameIndexMap maNameIndexMap;
213 : ScDPObject& mrDPObj;
214 : };
215 :
216 : #endif
217 :
218 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|