update dev300-m58
[ooovba.git] / sc / source / ui / inc / pvlaydlg.hxx
blob7c3021adf1a454486d512ab02113abfeb941eecb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pvlaydlg.hxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_PVLAYDLG_HXX
32 #define SC_PVLAYDLG_HXX
34 #include <vector>
35 #include <memory>
36 #include <boost/shared_ptr.hpp>
38 #ifndef _LSTBOX_HXX //autogen
39 #include <vcl/lstbox.hxx>
40 #endif
41 #ifndef _SCRBAR_HXX //autogen
42 #include <vcl/scrbar.hxx>
43 #endif
44 #include <svtools/stdctrl.hxx>
45 #ifndef _MOREBTN_HXX //autogen
46 #include <vcl/morebtn.hxx>
47 #endif
48 #include "pivot.hxx"
49 #include "anyrefdg.hxx"
50 #include "fieldwnd.hxx"
51 #include "formula/funcutl.hxx"
53 /*==========================================================================*\
55 Eine Instanz der Klasse ScPivotLayoutDlg ist ein (semi-)modaler
56 Dialog, in dem mit der Maus Felder mit Spaltenueberschriften den
57 drei Pivot-Kategorien "Spalte", "Zeile" und "Daten" zugeordnet
58 werden koennen.
60 Der Dialog erhaelt in der Struktur LabelData Informationen ueber
61 diese Ueberschriften (Name, Art (Zahl/String) und Funktionsmaske).
62 Weiterhin werden drei PivotFeld-Arrays uebergeben, mit denen die
63 drei Kategorie-Fenster initialisiert werden. Ein Kategorie-Fenster
64 wird durch eine Instanz der Klasse FieldWindow dargestellt. Ein
65 solches Fenster ist fuer die Darstellung der Datenstrukturen am
66 Schirm zustaendig. Es meldet Mausaktionen an den Dialog weiter und
67 bietet entsprechende Methoden zur Veraenderung der Darstellung.
68 Der Dialog sorgt fuer den Abgleich der interenen Datenstrukturen mit
69 der Bildschirmdarstellung. Ein weiteres FieldWindow (Select) bietet
70 alle Tabellenueberschriften zur Auswahl an, ist also "read-only".
72 \*==========================================================================*/
74 //============================================================================
76 class ScViewData;
77 class ScDocument;
78 class ScRangeData;
79 struct ScDPFuncData;
80 class ScDPObject;
82 //============================================================================
84 #define FUNC_COUNT 11
86 class ScDPLayoutDlg : public ScAnyRefDlg
88 public:
89 ScDPLayoutDlg(
90 SfxBindings* pB,
91 SfxChildWindow* pCW,
92 Window* pParent,
93 const ScDPObject& rDPObject,
94 bool bNewOutput );
95 virtual ~ScDPLayoutDlg();
97 virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
98 virtual BOOL IsRefInputMode() const { return bRefInputMode; }
99 virtual void SetActive();
100 virtual BOOL Close();
101 virtual void StateChanged( StateChangedType nStateChange );
103 void NotifyDoubleClick ( ScDPFieldType eType, size_t nFieldIndex );
104 PointerStyle NotifyMouseButtonDown( ScDPFieldType eType, size_t nFieldIndex );
105 void NotifyMouseButtonUp ( const Point& rAt );
106 PointerStyle NotifyMouseMove ( const Point& rAt );
107 void NotifyFieldFocus ( ScDPFieldType eType, BOOL bGotFocus );
108 void NotifyMoveField ( ScDPFieldType eToType );
109 void NotifyRemoveField ( ScDPFieldType eType, size_t nFieldIndex );
110 BOOL NotifyMoveSlider ( USHORT nKeyCode ); // return TRUE, if position changed
112 protected:
113 virtual void Deactivate();
115 private:
116 typedef boost::shared_ptr< ScDPFuncData > ScDPFuncDataRef;
117 typedef std::vector< ScDPFuncDataRef > ScDPFuncDataVec;
118 typedef std::auto_ptr< ScDPObject > ScDPObjectPtr;
120 FixedLine aFlLayout;
121 FixedText aFtPage;
122 ScDPFieldWindow aWndPage;
123 FixedText aFtCol;
124 ScDPFieldWindow aWndCol;
125 FixedText aFtRow;
126 ScDPFieldWindow aWndRow;
127 FixedText aFtData;
128 ScDPFieldWindow aWndData;
129 ScDPFieldWindow aWndSelect;
130 ScrollBar aSlider;
131 FixedInfo aFtInfo;
133 FixedLine aFlAreas;
135 // DP source selection
136 FixedText aFtInArea;
137 ::formula::RefEdit aEdInPos;
138 ::formula::RefButton aRbInPos;
140 // DP output location
141 ListBox aLbOutPos;
142 FixedText aFtOutArea;
143 formula::RefEdit aEdOutPos;
144 formula::RefButton aRbOutPos;
146 CheckBox aBtnIgnEmptyRows;
147 CheckBox aBtnDetectCat;
148 CheckBox aBtnTotalCol;
149 CheckBox aBtnTotalRow;
150 CheckBox aBtnFilter;
151 CheckBox aBtnDrillDown;
153 OKButton aBtnOk;
154 CancelButton aBtnCancel;
155 HelpButton aBtnHelp;
156 PushButton aBtnRemove;
157 PushButton aBtnOptions;
158 MoreButton aBtnMore;
160 const String aStrUndefined;
161 const String aStrNewTable;
162 std::vector< String > aFuncNameArr;
164 ScDPFieldType eDnDFromType;
165 size_t nDnDFromIndex;
166 BOOL bIsDrag;
168 ::formula::RefEdit* pEditActive;
170 Rectangle aRectPage;
171 Rectangle aRectRow;
172 Rectangle aRectCol;
173 Rectangle aRectData;
174 Rectangle aRectSelect;
176 ScDPLabelDataVec aLabelDataArr; // (nCol, Feldname, Zahl/Text)
178 ScDPFieldType eLastActiveType; /// Type of last active area.
179 size_t nOffset; /// Offset of first field in TYPE_SELECT area.
181 ScDPFuncDataVec aSelectArr;
182 ScDPFuncDataVec aPageArr;
183 ScDPFuncDataVec aColArr;
184 ScDPFuncDataVec aRowArr;
185 ScDPFuncDataVec aDataArr;
187 ScDPObjectPtr xDlgDPObject;
188 ScRange aOldRange;
189 ScPivotParam thePivotData;
190 ScViewData* pViewData;
191 ScDocument* pDoc;
192 BOOL bRefInputMode;
194 private:
195 ScDPFieldWindow& GetFieldWindow ( ScDPFieldType eType );
196 void Init (bool bNewOutput);
197 void InitWndSelect ( const ::std::vector<ScDPLabelDataRef>& rLabels );
198 void InitWnd ( PivotField* pArr, long nCount, ScDPFieldType eType );
199 void InitFocus ();
200 void InitFields ();
201 void CalcWndSizes ();
202 Point DlgPos2WndPos ( const Point& rPt, Window& rWnd );
203 ScDPLabelData* GetLabelData ( SCsCOL nCol, size_t* pPos = NULL );
204 String GetLabelString ( SCsCOL nCol );
205 String GetFuncString ( USHORT& rFuncMask, BOOL bIsValue = TRUE );
206 BOOL Contains ( ScDPFuncDataVec* pArr, SCsCOL nCol, size_t& nAt );
207 void Remove ( ScDPFuncDataVec* pArr, size_t nAt );
208 void Insert ( ScDPFuncDataVec* pArr, const ScDPFuncData& rFData, size_t nAt );
210 void AddField ( size_t nFromIndex,
211 ScDPFieldType eToType, const Point& rAtPos );
212 void MoveField ( ScDPFieldType eFromType, size_t nFromIndex,
213 ScDPFieldType eToType, const Point& rAtPos );
214 void RemoveField ( ScDPFieldType eRemType, size_t nRemIndex );
216 BOOL GetPivotArrays ( PivotField* pPageArr,
217 PivotField* pColArr,
218 PivotField* pRowArr,
219 PivotField* pDataArr,
220 USHORT& rPageCount,
221 USHORT& rColCount,
222 USHORT& rRowCount,
223 USHORT& rDataCount );
225 void UpdateSrcRange();
227 // Handler
228 DECL_LINK( ClickHdl, PushButton * );
229 DECL_LINK( ScrollHdl, ScrollBar * );
230 DECL_LINK( SelAreaHdl, ListBox * );
231 DECL_LINK( MoreClickHdl, MoreButton * );
232 DECL_LINK( EdModifyHdl, Edit * );
233 DECL_LINK( EdInModifyHdl, Edit * );
234 DECL_LINK( OkHdl, OKButton * );
235 DECL_LINK( CancelHdl, CancelButton * );
236 DECL_LINK( GetFocusHdl, Control* );
241 #endif // SC_PVLAYDLG_HXX