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