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