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