xref: /aoo41x/main/svtools/source/contnr/templwin.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 #ifndef _SVTOOLS_TEMPLWIN_HXX
28 #define _SVTOOLS_TEMPLWIN_HXX
29 
30 #include <tools/resary.hxx>
31 #include <vcl/splitwin.hxx>
32 #include <vcl/toolbox.hxx>
33 #include <vcl/window.hxx>
34 #include <svtools/headbar.hxx>
35 #include <svtools/fileview.hxx>
36 #include <svtools/ivctrl.hxx>
37 #include <svtools/svmedit2.hxx>
38 #include <svl/restrictedpaths.hxx>
39 #include <com/sun/star/frame/XDispatch.hpp>
40 #include <com/sun/star/lang/Locale.hpp>
41 
42 namespace com{ namespace sun { namespace star { namespace awt   { class XWindow; } } } }
43 namespace com{ namespace sun { namespace star { namespace frame { class XFrame; } } } }
44 namespace com{ namespace sun { namespace star { namespace document {
45     class XDocumentProperties;
46 } } } }
47 namespace svtools
48 {
49 	class ODocumentInfoPreview;
50 }
51 
52 // class SvtDummyHeaderBar_Impl ------------------------------------------
53 
54 class SvtDummyHeaderBar_Impl : public Window
55 {
56 private:
57 	void				UpdateBackgroundColor();
58 
59 public:
60 						SvtDummyHeaderBar_Impl( Window* pParent );
61 						~SvtDummyHeaderBar_Impl();
62 
63 	virtual void        DataChanged( const DataChangedEvent& rDCEvt );
64 };
65 
66 // class SvtIconWindow_Impl ----------------------------------------------
67 
68 class SvtIconWindow_Impl : public Window
69 {
70 private:
71 	SvtDummyHeaderBar_Impl	aDummyHeaderBar;	// spaceholder instead of HeaderBar
72 	SvtIconChoiceCtrl	aIconCtrl;
73 
74 	String				aNewDocumentRootURL;
75 	String				aTemplateRootURL;
76 	String				aMyDocumentsRootURL;
77 	String				aSamplesFolderRootURL;
78 
79 	long				nMaxTextLength;
80 
81 	SvxIconChoiceCtrlEntry*	GetEntry( const String& rURL ) const;
82 
83 public:
84 	SvtIconWindow_Impl( Window* pParent );
85 	~SvtIconWindow_Impl();
86 
87 	virtual void		Resize();
88 
89 	inline long			GetMaxTextLength() const { return nMaxTextLength; }
90 	inline void			SetClickHdl( const Link& rLink ) { aIconCtrl.SetClickHdl( rLink ); }
91 
92 	String				GetSelectedIconURL() const;
93 	String				GetSelectedIconText() const;
94 	String				GetCursorPosIconURL() const;
95 	String				GetIconText( const String& rURL ) const;
96 	void				InvalidateIconControl();
97 	void				SetCursorPos( sal_uLong nPos );
98 	sal_uLong				GetCursorPos() const;
99 	sal_uLong				GetSelectEntryPos() const;
100 	void				SetFocus();
101 	long 				CalcHeight() const;
102 	sal_Bool			IsRootURL( const String& rURL ) const;
103 	sal_uLong				GetRootPos( const String& rURL ) const;
104 	void				UpdateIcons( sal_Bool _bHiContrast );
105 
106 	inline sal_Bool			ProcessKeyEvent( const KeyEvent& rKEvt );
107 
108 	inline const String&	GetTemplateRootURL() const		{ return aTemplateRootURL; }
109 	inline const String&	GetMyDocumentsRootURL() const	{ return aMyDocumentsRootURL; }
110 	inline const String& 	GetSamplesFolderURL() const		{ return aSamplesFolderRootURL; }
111 
112     void                SelectFolder(sal_Int32 nFolderPos);
113 };
114 
115 inline sal_Bool SvtIconWindow_Impl::ProcessKeyEvent( const KeyEvent& rKEvt )
116 {
117 	return ( rKEvt.GetKeyCode().IsMod2() ? aIconCtrl.DoKeyInput( rKEvt ) : sal_False );
118 }
119 
120 // class SvtFileViewWindow_Impl ------------------------------------------
121 
122 class SvtTemplateWindow;
123 
124 class SvtFileViewWindow_Impl : public Window
125 {
126 private:
127 	SvtTemplateWindow&	rParent;
128 	SvtFileView	   		aFileView;
129 	Link				aNewFolderLink;
130 	String				aCurrentRootURL;
131 	String				aFolderURL;
132 	String				aMyDocumentsURL;
133 	String				aSamplesFolderURL;
134     ::svt::RestrictedPaths
135                         aURLFilter;
136 
137 	sal_Bool			bIsTemplateFolder;
138 
139 	::com::sun::star::uno::Sequence< ::rtl::OUString >
140 						GetNewDocContents() const;
141 
142 public:
143 	SvtFileViewWindow_Impl( SvtTemplateWindow* pParent );
144 	~SvtFileViewWindow_Impl();
145 
146 	virtual void		Resize();
147 
148 	inline void			SetSelectHdl( const Link& rLink ) { aFileView.SetSelectHdl( rLink ); }
149 	inline void			SetDoubleClickHdl( const Link& rLink ) { aFileView.SetDoubleClickHdl( rLink ); }
150 	inline void			SetNewFolderHdl( const Link& rLink ) { aNewFolderLink = rLink; }
151 	inline void			ResetCursor() { aFileView.ResetCursor(); }
152 	inline sal_Bool		IsTemplateFolder() const { return bIsTemplateFolder; }
153 	inline String		GetFolderURL() const { return aFolderURL; }
154 	inline String		GetRootURL() const { return aCurrentRootURL; }
155 	inline void			OpenRoot( const String& rRootURL )
156 							{ aCurrentRootURL = rRootURL; OpenFolder( rRootURL ); }
157 	inline void			SetMyDocumentsURL( const String& _rNewURL ) { aMyDocumentsURL = _rNewURL; }
158 	inline void			SetSamplesFolderURL( const String& _rNewURL ) { aSamplesFolderURL = _rNewURL; }
159 
160 	String				GetSelectedFile() const;
161 	void				OpenFolder( const String& rURL );
162 	sal_Bool			HasPreviousLevel( String& rURL ) const;
163 	String				GetFolderTitle() const;
164 	void				SetFocus();
165 };
166 
167 // class SvtFrameWindow_Impl ---------------------------------------------
168 
169 class SvtDocInfoTable_Impl : public ResStringArray
170 {
171 private:
172 	String			aEmptyString;
173 
174 public:
175 	SvtDocInfoTable_Impl();
176 
177 	const String&	GetString( long nId ) const;
178 };
179 
180 class SvtExtendedMultiLineEdit_Impl : public ExtMultiLineEdit
181 {
182 public:
183 	SvtExtendedMultiLineEdit_Impl( Window* pParent,WinBits _nBits );
184 	inline ~SvtExtendedMultiLineEdit_Impl() {}
185 
186 	inline void			Clear() { SetText( String() ); }
187 	void				InsertEntry( const String& rTitle, const String& rValue );
188 };
189 
190 class SvtFrameWindow_Impl : public Window
191 {
192 private:
193     ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >
194 								xFrame;
195     ::com::sun::star::uno::Reference < ::com::sun::star::document::XDocumentProperties>
196 								m_xDocProps;
197     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >
198 								xWindow;
199 
200 	::svtools::ODocumentInfoPreview*
201 									pEditWin;
202 	Window*							pTextWin;
203 	Window*							pEmptyWin;
204 	::com::sun::star::lang::Locale	aLocale;
205 	SvtDocInfoTable_Impl			aInfoTable;
206 	String							aCurrentURL;
207 	::rtl::OUString					m_aOpenURL;
208 	sal_Bool						bDocInfo;
209 
210 	void					ShowDocInfo( const String& rURL );
211 	void					ViewEditWin();
212 	void					ViewTextWin();
213 	void					ViewEmptyWin();
214 	void					ViewNonEmptyWin();	// views depending on bDocInfo
215 
216     struct SvtExecuteInfo
217     {
218         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >     xDispatch;
219         ::com::sun::star::util::URL                                                aTargetURL;
220     };
221 
222     DECL_STATIC_LINK(       SvtFrameWindow_Impl, ExecuteHdl_Impl, SvtExecuteInfo* );
223 
224 public:
225 	SvtFrameWindow_Impl( Window* pParent );
226 	~SvtFrameWindow_Impl();
227 
228 	virtual void			Resize();
229 
230 	void					OpenFile( const String& rURL, sal_Bool bPreview, sal_Bool bIsTemplate, sal_Bool bAsTemplate );
231 	void					ToggleView( sal_Bool bDocInfo );
232 };
233 
234 // class SvtTemplateWindow -----------------------------------------------
235 
236 class HistoryList_Impl;
237 
238 class SvtTemplateWindow : public Window
239 {
240 private:
241 	ToolBox						aFileViewTB;
242 	ToolBox						aFrameWinTB;
243 	SplitWindow					aSplitWin;
244 
245 	SvtIconWindow_Impl*			pIconWin;
246 	SvtFileViewWindow_Impl*		pFileWin;
247 	SvtFrameWindow_Impl*		pFrameWin;
248 	HistoryList_Impl*			pHistoryList;
249 
250 	Link						aSelectHdl;
251 	Link						aDoubleClickHdl;
252 	Link						aNewFolderHdl;
253 	Link						aSendFocusHdl;
254 
255 	Timer						aSelectTimer;
256 
257 	String						aFolderTitle;
258 
259 	virtual void		Resize();
260 
261 	DECL_LINK(			IconClickHdl_Impl, SvtIconChoiceCtrl* );
262 	DECL_LINK(			FileSelectHdl_Impl, SvtFileView* );
263 	DECL_LINK(			FileDblClickHdl_Impl, SvtFileView* );
264 	DECL_LINK(			NewFolderHdl_Impl, SvtFileView* );
265 	DECL_LINK(			TimeoutHdl_Impl, Timer* );
266 	DECL_LINK(			ClickHdl_Impl, ToolBox* );
267 	DECL_LINK(			ResizeHdl_Impl, SplitWindow* );		// used for split and initial setting of toolbar pos
268 
269 	void				PrintFile( const String& rURL );
270 	void				AppendHistoryURL( const String& rURL, sal_uLong nGroup );
271 	void				OpenHistory();
272 	void				DoAction( sal_uInt16 nAction );
273 	void				InitToolBoxes();
274 	void				InitToolBoxImages();
275 	void				UpdateIcons();
276 
277 protected:
278 	virtual long        PreNotify( NotifyEvent& rNEvt );
279 	virtual void 		DataChanged( const DataChangedEvent& rDCEvt );
280 
281 public:
282     SvtTemplateWindow( Window* pParent );
283 	~SvtTemplateWindow();
284 
285 	inline void			SetSelectHdl( const Link& rLink ) { aSelectHdl = rLink; }
286 	inline void			SetDoubleClickHdl( const Link& rLink ) { aDoubleClickHdl = rLink; }
287 	inline void			SetNewFolderHdl( const Link& rLink ) { aNewFolderHdl = rLink; }
288 	inline void			SetSendFocusHdl( const Link& rLink ) { aSendFocusHdl = rLink; }
289 	inline sal_Bool		IsTemplateFolderOpen() const { return pFileWin->IsTemplateFolder(); }
290 	inline sal_Bool		HasIconWinFocus() const { return pIconWin->HasChildPathFocus(); }
291 
292 	void				ReadViewSettings( );
293 	void				WriteViewSettings( );
294 	sal_Bool			IsFileSelected() const;
295 	String				GetSelectedFile() const;
296 	void				OpenFile( sal_Bool bNotAsTemplate );
297 	String				GetFolderTitle() const;
298 	String				GetFolderURL() const;
299 	void				SetFocus( sal_Bool bIconWin );
300 	void 				OpenTemplateRoot();
301 	void				SetPrevLevelButtonState( const String& rURL );	// sets state (enable/disable) for previous level button
302 	void				ClearHistory();
303 	long				CalcHeight() const;
304 
305     void                SelectFolder(sal_Int32 nFolderPosition);
306 };
307 
308 #endif // _SVTOOLS_TEMPLWIN_HXX
309 
310