Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_PVLAYDLG_HXX
30 : : #define SC_PVLAYDLG_HXX
31 : :
32 : : #include <vector>
33 : : #include <memory>
34 : : #include <boost/ptr_container/ptr_vector.hpp>
35 : : #include <boost/scoped_ptr.hpp>
36 : :
37 : : #include <vcl/lstbox.hxx>
38 : : #include <vcl/scrbar.hxx>
39 : : #include <svtools/stdctrl.hxx>
40 : : #include <vcl/morebtn.hxx>
41 : : #include "pivot.hxx"
42 : : #include "anyrefdg.hxx"
43 : : #include "fieldwnd.hxx"
44 : : #include "formula/funcutl.hxx"
45 : :
46 : : /*==========================================================================*\
47 : :
48 : : An instance of the class ScPivotLayoutDlg is a (semi-)modal dialog
49 : : that can be associated to the mouse fields with column headings of
50 : : the three pivot categories "column", "row" and "data".
51 : :
52 : : The dialog receives information about these headers (name,
53 : : type (number/string) and function mask) in the label data structure
54 : : Furthermore, three pivot field arrays are passed on, with which the three
55 : : category windows are initialized. A window class is represented by an
56 : : instance of class FieldWindow. Such a window is responsible for the
57 : : representation of data structures on the screen. It reports on mouse
58 : : actions in the dialogue and provides appropriate methods for
59 : : changing the representation. The dialogue provides the adjustment of the
60 : : internal data structures with respect to the representation on the screen.
61 : : Another FieldWindow(Select) provides all table headers for selection,
62 : : is thus "read only".
63 : :
64 : : \*==========================================================================*/
65 : :
66 : : //============================================================================
67 : :
68 : : class ScViewData;
69 : : class ScDocument;
70 : : struct ScDPFuncData;
71 : : class ScDPObject;
72 : :
73 : : //============================================================================
74 : :
75 : : class ScDPLayoutDlg : public ScAnyRefDlg
76 : : {
77 : : /** data source type */
78 : : enum DataSrcType {
79 : : SRC_REF, /// range reference
80 : : SRC_NAME, /// range name
81 : : SRC_INVALID /// invalid range
82 : : };
83 : : public:
84 : : ScDPLayoutDlg(
85 : : SfxBindings* pB,
86 : : SfxChildWindow* pCW,
87 : : Window* pParent,
88 : : const ScDPObject& rDPObject,
89 : : bool bNewOutput );
90 : : virtual ~ScDPLayoutDlg();
91 : :
92 : : virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
93 : 0 : virtual sal_Bool IsRefInputMode() const { return bRefInputMode; }
94 : : virtual void SetActive();
95 : : virtual sal_Bool Close();
96 : : virtual void StateChanged( StateChangedType nStateChange );
97 : :
98 : : void NotifyDoubleClick ( ScDPFieldType eType, size_t nFieldIndex );
99 : : PointerStyle NotifyMouseButtonDown( ScDPFieldType eType, size_t nFieldIndex );
100 : : void NotifyMouseButtonUp ( const Point& rAt );
101 : : PointerStyle NotifyMouseMove ( const Point& rAt );
102 : : void NotifyFieldFocus ( ScDPFieldType eType, bool bGotFocus );
103 : : void NotifyMoveFieldToEnd ( ScDPFieldType eToType );
104 : : void NotifyRemoveField ( ScDPFieldType eType, size_t nFieldIndex );
105 : :
106 : : Size GetStdFieldBtnSize() const;
107 : :
108 : : protected:
109 : : virtual void Deactivate();
110 : :
111 : : private:
112 : : typedef boost::ptr_vector<ScDPFuncData> ScDPFuncDataVec;
113 : : typedef boost::scoped_ptr<ScDPObject> ScDPObjectPtr;
114 : :
115 : : FixedLine aFlLayout;
116 : : FixedText aFtPage;
117 : : ScDPPageFieldControl aWndPage;
118 : : FixedText aFtCol;
119 : : ScDPColFieldControl aWndCol;
120 : : FixedText aFtRow;
121 : : ScDPRowFieldControl aWndRow;
122 : : FixedText aFtData;
123 : : ScDPDataFieldControl aWndData;
124 : : ScDPSelectFieldControl aWndSelect;
125 : : FixedInfo aFtInfo;
126 : :
127 : : FixedLine aFlAreas;
128 : :
129 : : // DP source selection
130 : : FixedText aFtInArea;
131 : : ::formula::RefEdit aEdInPos;
132 : : ::formula::RefButton aRbInPos;
133 : :
134 : : // DP output location
135 : : ListBox aLbOutPos;
136 : : FixedText aFtOutArea;
137 : : formula::RefEdit aEdOutPos;
138 : : formula::RefButton aRbOutPos;
139 : :
140 : : CheckBox aBtnIgnEmptyRows;
141 : : CheckBox aBtnDetectCat;
142 : : CheckBox aBtnTotalCol;
143 : : CheckBox aBtnTotalRow;
144 : : CheckBox aBtnFilter;
145 : : CheckBox aBtnDrillDown;
146 : :
147 : : OKButton aBtnOk;
148 : : CancelButton aBtnCancel;
149 : : HelpButton aBtnHelp;
150 : : PushButton aBtnRemove;
151 : : PushButton aBtnOptions;
152 : : MoreButton aBtnMore;
153 : :
154 : : const rtl::OUString aStrUndefined;
155 : : const rtl::OUString aStrNewTable;
156 : : std::vector<rtl::OUString> aFuncNameArr;
157 : :
158 : : ScDPFieldType eDnDFromType;
159 : : size_t nDnDFromIndex;
160 : : bool bIsDrag;
161 : :
162 : : ::formula::RefEdit* pEditActive;
163 : :
164 : : Rectangle aRectPage;
165 : : Rectangle aRectRow;
166 : : Rectangle aRectCol;
167 : : Rectangle aRectData;
168 : : Rectangle aRectSelect;
169 : :
170 : : ScDPLabelDataVec aLabelDataArr; // (nCol, Field name, Number/Text)
171 : :
172 : : ScDPFieldType eLastActiveType; /// Type of last active area.
173 : : size_t nOffset; /// Offset of first field in TYPE_SELECT area.
174 : :
175 : : ScDPFuncDataVec aSelectArr;
176 : : ScDPFuncDataVec aPageArr;
177 : : ScDPFuncDataVec aColArr;
178 : : ScDPFuncDataVec aRowArr;
179 : : ScDPFuncDataVec aDataArr;
180 : :
181 : : long mnFieldObjSpace;
182 : :
183 : : ScDPObjectPtr xDlgDPObject;
184 : : ScRange aOldRange;
185 : : ScPivotParam thePivotData;
186 : : ScViewData* pViewData;
187 : : ScDocument* pDoc;
188 : : bool bRefInputMode;
189 : :
190 : : private:
191 : : void Init (bool bNewOutput);
192 : : void InitWndSelect(const ScDPLabelDataVec& rLabels);
193 : : void InitWndData(const std::vector<PivotField>& rFields);
194 : : void InitFieldWindow ( const ::std::vector<PivotField>& rFields, ScDPFieldType eType );
195 : : void InitFocus ();
196 : : void InitFields ();
197 : : void CalcWndSizes ();
198 : : void AdjustDlgSize();
199 : : Point DlgPos2WndPos ( const Point& rPt, Window& rWnd );
200 : : ScDPLabelData* GetLabelData ( SCsCOL nCol, size_t* pPos = NULL );
201 : : rtl::OUString GetLabelString(SCsCOL nCol);
202 : : bool IsOrientationAllowed( SCsCOL nCol, ScDPFieldType eType );
203 : : rtl::OUString GetFuncString( sal_uInt16& rFuncMask, bool bIsValue = true );
204 : : bool Contains( ScDPFuncDataVec* pArr, const ScDPFuncData& rData, size_t& nAt );
205 : : void Remove ( ScDPFuncDataVec* pArr, size_t nAt );
206 : : void Insert ( ScDPFuncDataVec* pArr, const ScDPFuncData& rFData, size_t nAt );
207 : :
208 : : void AddField ( size_t nFromIndex,
209 : : ScDPFieldType eToType, const Point& rAtPos );
210 : : void AppendField(size_t nFromIndex, ScDPFieldType eToType);
211 : : void MoveField ( ScDPFieldType eFromType, size_t nFromIndex,
212 : : ScDPFieldType eToType, const Point& rAtPos );
213 : : void MoveFieldToEnd(ScDPFieldType eFromType, size_t nFromIndex, ScDPFieldType eToType);
214 : : void RemoveField ( ScDPFieldType eRemType, size_t nRemIndex );
215 : :
216 : : bool GetPivotArrays( ::std::vector<PivotField>& rPageFields,
217 : : ::std::vector<PivotField>& rColFields,
218 : : ::std::vector<PivotField>& rRowFields,
219 : : ::std::vector<PivotField>& rDataFields );
220 : :
221 : : void UpdateSrcRange();
222 : : void RepaintFieldWindows();
223 : :
224 : : ScDPFieldControlBase* GetFieldWindow(ScDPFieldType eType);
225 : :
226 : : /**
227 : : * Get pointers to field windows that are <b>not</b> the window of
228 : : * specified type. The select window type is not included.
229 : : */
230 : : void GetOtherFieldWindows(
231 : : ScDPFieldType eType, ScDPFieldControlBase*& rpWnd1, ScDPFieldControlBase*& rpWnd2);
232 : :
233 : : ScDPFuncDataVec* GetFieldDataArray(ScDPFieldType eType);
234 : :
235 : : /**
236 : : * Like GetOtherFieldWindows(), get pointers to data arrays of the fields
237 : : * that are <b>not</b> the specified field type.
238 : : */
239 : : void GetOtherDataArrays(
240 : : ScDPFieldType eType, ScDPFuncDataVec*& rpArr1, ScDPFuncDataVec*& rpArr2);
241 : :
242 : : sal_uInt8 GetNextDupCount(const ScDPFuncDataVec& rArr, const ScDPFuncData& rData, size_t nDataIndex) const;
243 : :
244 : : // Handler
245 : : DECL_LINK( ClickHdl, PushButton * );
246 : : DECL_LINK( SelAreaHdl, void * );
247 : : DECL_LINK( MoreClickHdl, void * );
248 : : DECL_LINK( EdModifyHdl, void * );
249 : : DECL_LINK( EdInModifyHdl, void * );
250 : : DECL_LINK( OkHdl, void * );
251 : : DECL_LINK( CancelHdl, void * );
252 : : DECL_LINK( GetFocusHdl, Control* );
253 : : };
254 : :
255 : : #endif // SC_PVLAYDLG_HXX
256 : :
257 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|