xref: /aoo42x/main/sc/source/ui/inc/navipi.hxx (revision 37fee4fd)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_NAVIPI_HXX
25 #define SC_NAVIPI_HXX
26 
27 #include <vector>
28 #include <vcl/toolbox.hxx>
29 #include <vcl/field.hxx>
30 #include <vcl/lstbox.hxx>
31 #include <svtools/stdctrl.hxx>
32 #include <svl/poolitem.hxx>
33 #include <svl/lstner.hxx>
34 #include <sfx2/childwin.hxx>
35 #include "content.hxx"
36 #include <svtools/svmedit.hxx>
37 
38 
39 class ScTabViewShell;
40 class ScViewData;
41 class ScArea;
42 class ScScenarioWindow;
43 class ScNavigatorControllerItem;
44 class ScNavigatorDialogWrapper;
45 class ScNavigatorDlg;
46 class ScNavigatorSettings;
47 class ScRange;
48 
49 //========================================================================
50 
51 #define SC_DROPMODE_URL			0
52 #define SC_DROPMODE_LINK		1
53 #define SC_DROPMODE_COPY		2
54 
55 enum NavListMode { NAV_LMODE_NONE		= 0x4000,
56 				   NAV_LMODE_AREAS		= 0x2000,
57 				   NAV_LMODE_DBAREAS	= 0x1000,
58 				   NAV_LMODE_DOCS		= 0x800,
59 				   NAV_LMODE_SCENARIOS	= 0x400 };
60 
61 //========================================================================
62 // class ScScenarioListBox -----------------------------------------------
63 //========================================================================
64 
65 class ScScenarioListBox : public ListBox
66 {
67 public:
68     explicit            ScScenarioListBox( ScScenarioWindow& rParent );
69     virtual             ~ScScenarioListBox();
70 
71     void                UpdateEntries( List* pNewEntryList );
72 
73 protected:
74     virtual void        Select();
75     virtual void        DoubleClick();
76     virtual long        Notify( NotifyEvent& rNEvt );
77 
78 private:
79     struct ScenarioEntry
80     {
81         String              maName;
82         String              maComment;
83         bool                mbProtected;
84 
ScenarioEntryScScenarioListBox::ScenarioEntry85         inline explicit     ScenarioEntry() : mbProtected( false ) {}
86     };
87     typedef ::std::vector< ScenarioEntry > ScenarioList;
88 
89 private:
90     const ScenarioEntry* GetSelectedEntry() const;
91 
92     void                ExecuteScenarioSlot( sal_uInt16 nSlotId );
93     void                SelectScenario();
94     void                EditScenario();
95     void                DeleteScenario( bool bQueryBox );
96 
97 private:
98     ScScenarioWindow&   mrParent;
99     ScenarioList        maEntries;
100 };
101 
102 //========================================================================
103 // class ScScenarioWindow ------------------------------------------------
104 //========================================================================
105 class ScScenarioWindow : public Window
106 {
107 public:
108 			ScScenarioWindow( Window* pParent,const String& aQH_List,const String& aQH_Comment);
109 			~ScScenarioWindow();
110 
111 	void	NotifyState( const SfxPoolItem* pState );
SetComment(const String & rComment)112 	void	SetComment( const String& rComment )
113 				{ aEdComment.SetText( rComment ); }
114 
115 	void	SetSizePixel( const Size& rNewSize );
116 
117 protected:
118 
119 	virtual void	Paint( const Rectangle& rRec );
120 
121 private:
122 	ScScenarioListBox	aLbScenario;
123 	MultiLineEdit		aEdComment;
124 };
125 
126 //==================================================================
127 //	class ColumnEdit
128 //==================================================================
129 class ColumnEdit : public SpinField
130 {
131 public:
132 			ColumnEdit( ScNavigatorDlg* pParent, const ResId& rResId );
133 			~ColumnEdit();
134 
GetCol()135 	SCCOL	GetCol() { return nCol; }
136 	void	SetCol( SCCOL nColNo );
137 
138 protected:
139 	virtual long	Notify( NotifyEvent& rNEvt );
140 	virtual void	LoseFocus();
141 	virtual void	Up();
142 	virtual void	Down();
143 	virtual void	First();
144 	virtual void	Last();
145 
146 private:
147 	ScNavigatorDlg& rDlg;
148 	SCCOL			nCol;
149 	sal_uInt16			nKeyGroup;
150 
151 	void	EvalText		();
152 	void	ExecuteCol		();
153 	SCCOL	AlphaToNum		( String& rStr );
154 	SCCOL	NumStrToAlpha	( String& rStr );
155 	SCCOL	NumToAlpha		( SCCOL nColNo, String& rStr );
156 };
157 
158 
159 //==================================================================
160 //	class RowEdit
161 //==================================================================
162 class RowEdit : public NumericField
163 {
164 public:
165 			RowEdit( ScNavigatorDlg* pParent, const ResId& rResId );
166 			~RowEdit();
167 
GetRow()168 	SCROW	GetRow()				{ return (SCROW)GetValue(); }
SetRow(SCROW nRow)169 	void	SetRow( SCROW nRow ){ SetValue( nRow ); }
170 
171 protected:
172 	virtual long	Notify( NotifyEvent& rNEvt );
173 	virtual void	LoseFocus();
174 
175 private:
176 	ScNavigatorDlg& rDlg;
177 
178 	void	ExecuteRow();
179 };
180 
181 
182 //==================================================================
183 //	class ScDocListBox
184 //==================================================================
185 class ScDocListBox : public ListBox
186 {
187 public:
188 			ScDocListBox( ScNavigatorDlg* pParent, const ResId& rResId );
189 			~ScDocListBox();
190 
191 protected:
192 	virtual void	Select();
193 
194 private:
195 	ScNavigatorDlg& rDlg;
196 };
197 
198 
199 //==================================================================
200 //	class CommandToolBox
201 //==================================================================
202 class CommandToolBox : public ToolBox
203 {
204 public:
205 			CommandToolBox( ScNavigatorDlg* pParent, const ResId& rResId );
206 			~CommandToolBox();
207 
208 	void Select( sal_uInt16 nId );
209 	void UpdateButtons();
210     void InitImageList();
211 
212 	virtual void	DataChanged( const DataChangedEvent& rDCEvt );
213 
214     DECL_LINK( ToolBoxDropdownClickHdl, ToolBox* );
215 
216 protected:
217 	virtual void	Select();
218 	virtual void	Click();
219 
220 private:
221 	ScNavigatorDlg& rDlg;
222 };
223 
224 //==================================================================
225 //	class ScNavigatorDlg
226 //==================================================================
227 
228 class ScNavigatorDlg : public Window, public SfxListener
229 {
230 friend class ScNavigatorControllerItem;
231 friend class ScNavigatorDialogWrapper;
232 friend class ColumnEdit;
233 friend class RowEdit;
234 friend class ScDocListBox;
235 friend class CommandToolBox;
236 friend class ScContentTree;
237 
238 private:
239 	SfxBindings&		rBindings;		// must be first member
240 
241 	ImageList			aCmdImageList;	// must be before aTbxCmd
242     ImageList           aCmdImageListH;
243 	FixedInfo			aFtCol;
244 	ColumnEdit			aEdCol;
245 	FixedInfo			aFtRow;
246 	RowEdit				aEdRow;
247 	CommandToolBox		aTbxCmd;
248 	ScContentTree		aLbEntries;
249     ScScenarioWindow    aWndScenarios;
250 	ScDocListBox		aLbDocuments;
251 
252 	Timer			aContentTimer;
253 
254 	String			aTitleBase;
255 	String			aStrDragMode;
256 	String			aStrDisplay;
257 	String			aStrActive;
258 	String			aStrNotActive;
259 	String			aStrHidden;
260 	String			aStrActiveWin;
261 
262     SfxChildWindowContext*  pContextWin;
263     Size                    aInitSize;
264     ScArea*                 pMarkArea;
265     ScViewData*             pViewData;
266 
267     long            nBorderOffset;
268 	long			nListModeHeight;
269 	long			nInitListHeight;
270 	NavListMode		eListMode;
271 	sal_uInt16			nDropMode;
272 	SCCOL			nCurCol;
273 	SCROW			nCurRow;
274 	SCTAB			nCurTab;
275 	sal_Bool			bFirstBig;
276     bool mbUseStyleSettingsBackground;
277 
278 	ScNavigatorControllerItem** ppBoundItems;
279 
280 	DECL_LINK( TimeHdl, Timer* );
281 
282 	void	DoResize();
283 
GetBindings()284     SfxBindings&    GetBindings()
285                     { return rBindings; }
286 
287 	void	SetCurrentCell( SCCOL nCol, SCROW Row );
288 	void	SetCurrentCellStr( const String rName );
289 	void	SetCurrentTable( SCTAB nTab );
290 	void	SetCurrentTableStr( const String rName );
291 	void	SetCurrentObject( const String rName );
292 	void	SetCurrentDoc( const String& rDocName );
293 
294     ScTabViewShell*         GetTabViewShell() const;
295     ScNavigatorSettings*    GetNavigatorSettings();
296     sal_Bool                    GetViewData();
297 
298 	void	UpdateColumn	( const SCCOL* pCol = NULL );
299 	void	UpdateRow		( const SCROW* pRow = NULL );
300 	void	UpdateTable		( const SCTAB* pTab = NULL );
301 	void	UpdateAll		();
302 
303 	void	GetDocNames(const String* pSelEntry = NULL);
304 
305 	void	SetListMode		( NavListMode eMode, sal_Bool bSetSize = sal_True );
306 	void	ShowList		( sal_Bool bShow, sal_Bool bSetSize );
307 	void	ShowScenarios	( sal_Bool bShow, sal_Bool bSetSize );
308 
309 	void	SetDropMode(sal_uInt16 nNew);
GetDropMode() const310 	sal_uInt16	GetDropMode() const			{ return nDropMode; }
311 
GetStrDragMode() const312 	const String& GetStrDragMode() const	{ return aStrDragMode; }
GetStrDisplay() const313 	const String& GetStrDisplay() const		{ return aStrDisplay; }
314 
315 	void	CheckDataArea	();
316 	void	MarkDataArea	();
317 	void	UnmarkDataArea	();
318 	void	StartOfDataArea	();
319 	void	EndOfDataArea	();
320 
321 	static void ReleaseFocus();
322 
323 protected:
324 	virtual void	Resize();
325 	virtual void	Paint( const Rectangle& rRec );
326 	virtual void	Resizing( Size& rSize );
327 
328 public:
329                 ScNavigatorDlg( SfxBindings* pB, SfxChildWindowContext* pCW, Window* pParent,
330                     const bool bUseStyleSettingsBackground);
331 				~ScNavigatorDlg();
332 
333     using Window::Notify;
334 	virtual void 	Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
335 
336 	void			CursorPosChanged();
337 
338 	virtual SfxChildAlignment
339 					CheckAlignment(SfxChildAlignment,SfxChildAlignment);
340 	virtual void	DataChanged( const DataChangedEvent& rDCEvt );
341 };
342 
343 //==================================================================
344 
345 class ScNavigatorDialogWrapper: public SfxChildWindowContext
346 {
347 public:
348 			ScNavigatorDialogWrapper( Window*			pParent,
349 									  sal_uInt16			nId,
350 									  SfxBindings*		pBindings,
351 									  SfxChildWinInfo*	pInfo );
352 
353 	SFX_DECL_CHILDWINDOWCONTEXT(ScNavigatorDialogWrapper)
354 
355 	virtual void	Resizing( Size& rSize );
356 
357 private:
358 	ScNavigatorDlg* pNavigator;
359 };
360 
361 
362 
363 #endif // SC_NAVIPI_HXX
364 
365