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