Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / inc / pvlaydlg.hxx
blob59ad13b321be9ec147ff3c69a4a6cb2b9eaf1b58
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 * This file incorporates work covered by the following license notice:
29 * Licensed to the Apache Software Foundation (ASF) under one or more
30 * contributor license agreements. See the NOTICE file distributed
31 * with this work for additional information regarding copyright
32 * ownership. The ASF licenses this file to you under the Apache
33 * License, Version 2.0 (the "License"); you may not use this file
34 * except in compliance with the License. You may obtain a copy of
35 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
36 ************************************************************************/
38 #ifndef SC_PVLAYDLG_HXX
39 #define SC_PVLAYDLG_HXX
41 #include <config_lgpl.h>
43 #include <memory>
44 #include <vector>
46 #include <boost/ptr_container/ptr_vector.hpp>
47 #include <boost/scoped_ptr.hpp>
49 #include <formula/funcutl.hxx>
50 #include <svtools/stdctrl.hxx>
51 #include <vcl/lstbox.hxx>
52 #include <vcl/morebtn.hxx>
53 #include <vcl/scrbar.hxx>
55 #include "anyrefdg.hxx"
56 #include "fieldwnd.hxx"
58 /*==========================================================================*\
60 An instance of the class ScPivotLayoutDlg is a (semi-)modal dialog
61 that can be associated to the mouse fields with column headings of
62 the three pivot categories "column", "row" and "data".
64 The dialog receives information about these headers (name,
65 type (number/string) and function mask) in the label data structure
66 Furthermore, three pivot field arrays are passed on, with which the three
67 category windows are initialized. A window class is represented by an
68 instance of class FieldWindow. Such a window is responsible for the
69 representation of data structures on the screen. It reports on mouse
70 actions in the dialogue and provides appropriate methods for
71 changing the representation. The dialogue provides the adjustment of the
72 internal data structures with respect to the representation on the screen.
73 Another FieldWindow(Select) provides all table headers for selection,
74 is thus "read only".
76 \*==========================================================================*/
78 class ScViewData;
79 class ScDocument;
80 struct ScPivotFuncData;
81 class ScDPObject;
83 class ScPivotLayoutDlg : public ScAnyRefDlg
85 /** data source type */
86 enum DataSrcType {
87 SRC_REF, /// range reference
88 SRC_NAME, /// range name
89 SRC_INVALID /// invalid range
91 public:
92 ScPivotLayoutDlg(
93 SfxBindings* pB,
94 SfxChildWindow* pCW,
95 Window* pParent,
96 const ScDPObject& rDPObject,
97 bool bNewOutput );
98 virtual ~ScPivotLayoutDlg();
100 void NotifyDoubleClick ( ScPivotFieldType eType, size_t nFieldIndex );
101 PointerStyle NotifyMouseButtonDown( ScPivotFieldType eType, size_t nFieldIndex );
102 void NotifyFieldFocus ( ScPivotFieldType eType, bool bGotFocus );
103 void NotifyMoveFieldToEnd ( ScPivotFieldType eToType );
104 void NotifyRemoveField ( ScPivotFieldType eType, size_t nFieldIndex );
106 Size GetStdFieldBtnSize() const;
109 * Drop currently dragged field item into specified position.
111 * @param rScrPos screen position of mouse cursor.
112 * @param eToType type of field at mouse cursor position.
114 void DropFieldItem( const Point& rScrPos, ScPivotFieldType eToType );
117 * Get pointer style at current mouse position during dragging of field
118 * item.
120 PointerStyle GetPointerStyleAtPoint( const Point& rScrPos, ScPivotFieldType eFieldType );
123 * Determine the type of field at mouse cursor position.
125 * @param rScrPos mouse cursor position (screen position).
127 ScPivotFieldType GetFieldTypeAtPoint( const Point& rScrPos ) const;
129 protected:
130 virtual void Deactivate();
131 virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
132 virtual sal_Bool IsRefInputMode() const;
133 virtual void SetActive();
134 virtual sal_Bool Close();
136 private:
137 /** Returns the localized function name for the specified (1-based) resource index. */
138 inline const OUString& GetFuncName( sal_uInt16 nFuncIdx ) const { return maFuncNames[nFuncIdx-1]; }
140 /** Fills the field windows from the current pivot table settings. */
141 void InitFieldWindows();
142 /** Sets focus to the specified field control, if it is not empty. */
143 void GrabFieldFocus( ScDPFieldControlBase& rFieldWindow );
145 void InitWndSelect(const ScDPLabelDataVector& rLabels);
146 void InitWndData(const std::vector<ScPivotField>& rFields);
147 void InitFieldWindow ( const ::std::vector<ScPivotField>& rFields, ScPivotFieldType eType );
148 void AdjustDlgSize();
149 ScDPLabelData* GetLabelData( SCCOL nCol );
150 OUString GetLabelString(SCsCOL nCol);
151 bool IsOrientationAllowed( SCsCOL nCol, ScPivotFieldType eType );
152 OUString GetFuncString( sal_uInt16& rFuncMask, bool bIsValue = true );
154 void AddField ( size_t nFromIndex,
155 ScPivotFieldType eToType, const Point& rAtPos );
156 void AppendField(size_t nFromIndex, ScPivotFieldType eToType);
157 void MoveField ( ScPivotFieldType eFromType, size_t nFromIndex,
158 ScPivotFieldType eToType, const Point& rAtPos );
159 void MoveFieldToEnd(ScPivotFieldType eFromType, size_t nFromIndex, ScPivotFieldType eToType);
160 void RemoveField ( ScPivotFieldType eRemType, size_t nRemIndex );
162 bool GetPivotArrays( ::std::vector<ScPivotField>& rPageFields,
163 ::std::vector<ScPivotField>& rColFields,
164 ::std::vector<ScPivotField>& rRowFields,
165 ::std::vector<ScPivotField>& rDataFields );
167 void UpdateSrcRange();
168 void UpdateOutputPos();
169 void OutputPosUpdated();
170 void MoreBtnClicked();
172 void RepaintFieldWindows();
175 * Initialize control sizes and the dialog size which depends on them.
177 void InitControlAndDlgSizes();
179 ScDPFieldControlBase* GetFieldWindow(ScPivotFieldType eType);
182 * Get pointers to field windows that are <b>not</b> the window of
183 * specified type. The select window type is not included.
185 void GetOtherFieldWindows(
186 ScPivotFieldType eType, ScDPFieldControlBase*& rpWnd1, ScDPFieldControlBase*& rpWnd2);
188 // Handler
189 DECL_LINK( ClickHdl, PushButton * );
190 DECL_LINK( OkHdl, void * );
191 DECL_LINK( CancelHdl, void * );
192 DECL_LINK( MoreClickHdl, void * );
193 DECL_LINK( EdOutModifyHdl, void * );
194 DECL_LINK( EdInModifyHdl, void * );
195 DECL_LINK( SelAreaHdl, void * );
196 DECL_LINK( GetRefEditFocusHdl, formula::RefEdit* );
198 private:
199 typedef boost::scoped_ptr<ScDPObject> ScDPObjectPtr;
201 FixedLine maFlLayout;
202 FixedText maFtPage;
203 ScDPPageFieldControl maWndPage;
204 FixedText maFtCol;
205 ScDPColFieldControl maWndCol;
206 FixedText maFtRow;
207 ScDPRowFieldControl maWndRow;
208 FixedText maFtData;
209 ScDPDataFieldControl maWndData;
210 ScDPSelectFieldControl maWndSelect;
211 FixedInfo maFtInfo;
213 std::vector<ScDPFieldControlBase*> maFieldCtrls;
215 FixedLine maFlAreas;
216 FixedText maFtInArea;
217 ::formula::RefEdit maEdInPos;
218 ::formula::RefButton maRbInPos;
219 ListBox maLbOutPos;
220 FixedText maFtOutArea;
221 formula::RefEdit maEdOutPos;
222 formula::RefButton maRbOutPos;
223 CheckBox maBtnIgnEmptyRows;
224 CheckBox maBtnDetectCat;
225 CheckBox maBtnTotalCol;
226 CheckBox maBtnTotalRow;
227 CheckBox maBtnFilter;
228 CheckBox maBtnDrillDown;
230 OKButton maBtnOk;
231 CancelButton maBtnCancel;
232 HelpButton maBtnHelp;
233 PushButton maBtnRemove;
234 PushButton maBtnOptions;
235 MoreButton maBtnMore;
236 std::vector<OUString> maFuncNames; /// Localized function names from resource.
237 boost::ptr_vector<OUString> maRefStrs; /// Reference strings stored with the output list box.
238 ScDPObjectPtr mxDlgDPObject; /// Clone of the pivot table object this dialog is based on.
239 ScPivotParam maPivotData; /// The pivot table field configuration.
240 ScDPLabelDataVector maLabelData; /// Information about all dimensions.
242 ScViewData* mpViewData;
243 ScDocument* mpDoc;
244 formula::RefEdit* mpRefInputEdit;
246 const OUString maStrUndefined;
247 const OUString maStrNewTable;
248 OUString maOutputRefStr; /// Used only for caching in UI.
250 ScPivotFieldType meDnDFromType;
251 size_t mnDnDFromIndex;
252 bool mbIsDrag;
254 ScPivotFieldType meLastActiveType; /// Type of last active area.
255 size_t mnOffset; /// Offset of first field in TYPE_SELECT area.
257 ScRange maOldRange;
258 bool mbRefInputMode;
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
264 #endif