1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: templwin.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SVTOOLS_TEMPLWIN_HXX
31 #define _SVTOOLS_TEMPLWIN_HXX
33 #include <tools/resary.hxx>
34 #include <vcl/splitwin.hxx>
35 #include <vcl/toolbox.hxx>
36 #include <vcl/window.hxx>
37 #include <svtools/headbar.hxx>
38 #include "fileview.hxx"
40 #include <svtools/svmedit2.hxx>
41 #include <svtools/restrictedpaths.hxx>
42 #include <com/sun/star/frame/XDispatch.hpp>
43 #include <com/sun/star/lang/Locale.hpp>
45 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{ class XWindow
; } } } }
46 namespace com
{ namespace sun
{ namespace star
{ namespace frame
{ class XFrame
; } } } }
47 namespace com
{ namespace sun
{ namespace star
{ namespace document
{
48 class XDocumentProperties
;
52 class ODocumentInfoPreview
;
55 // class SvtDummyHeaderBar_Impl ------------------------------------------
57 class SvtDummyHeaderBar_Impl
: public Window
60 void UpdateBackgroundColor();
63 SvtDummyHeaderBar_Impl( Window
* pParent
);
64 ~SvtDummyHeaderBar_Impl();
66 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
69 // class SvtIconWindow_Impl ----------------------------------------------
71 class SvtIconWindow_Impl
: public Window
74 SvtDummyHeaderBar_Impl aDummyHeaderBar
; // spaceholder instead of HeaderBar
75 SvtIconChoiceCtrl aIconCtrl
;
77 String aNewDocumentRootURL
;
78 String aTemplateRootURL
;
79 String aMyDocumentsRootURL
;
80 String aSamplesFolderRootURL
;
84 SvxIconChoiceCtrlEntry
* GetEntry( const String
& rURL
) const;
87 SvtIconWindow_Impl( Window
* pParent
);
88 ~SvtIconWindow_Impl();
90 virtual void Resize();
92 inline long GetMaxTextLength() const { return nMaxTextLength
; }
93 inline void SetClickHdl( const Link
& rLink
) { aIconCtrl
.SetClickHdl( rLink
); }
95 String
GetSelectedIconURL() const;
96 String
GetSelectedIconText() const;
97 String
GetCursorPosIconURL() const;
98 String
GetIconText( const String
& rURL
) const;
99 void InvalidateIconControl();
100 void SetCursorPos( ULONG nPos
);
101 ULONG
GetCursorPos() const;
102 ULONG
GetSelectEntryPos() const;
104 long CalcHeight() const;
105 sal_Bool
IsRootURL( const String
& rURL
) const;
106 ULONG
GetRootPos( const String
& rURL
) const;
107 void UpdateIcons( sal_Bool _bHiContrast
);
109 inline sal_Bool
ProcessKeyEvent( const KeyEvent
& rKEvt
);
111 inline const String
& GetTemplateRootURL() const { return aTemplateRootURL
; }
112 inline const String
& GetMyDocumentsRootURL() const { return aMyDocumentsRootURL
; }
113 inline const String
& GetSamplesFolderURL() const { return aSamplesFolderRootURL
; }
115 void SelectFolder(sal_Int32 nFolderPos
);
118 inline sal_Bool
SvtIconWindow_Impl::ProcessKeyEvent( const KeyEvent
& rKEvt
)
120 return ( rKEvt
.GetKeyCode().IsMod2() ? aIconCtrl
.DoKeyInput( rKEvt
) : sal_False
);
123 // class SvtFileViewWindow_Impl ------------------------------------------
125 class SvtTemplateWindow
;
127 class SvtFileViewWindow_Impl
: public Window
130 SvtTemplateWindow
& rParent
;
131 SvtFileView aFileView
;
133 String aCurrentRootURL
;
135 String aMyDocumentsURL
;
136 String aSamplesFolderURL
;
137 ::svt::RestrictedPaths
140 sal_Bool bIsTemplateFolder
;
142 ::com::sun::star::uno::Sequence
< ::rtl::OUString
>
143 GetNewDocContents() const;
146 SvtFileViewWindow_Impl( SvtTemplateWindow
* pParent
);
147 ~SvtFileViewWindow_Impl();
149 virtual void Resize();
151 inline void SetSelectHdl( const Link
& rLink
) { aFileView
.SetSelectHdl( rLink
); }
152 inline void SetDoubleClickHdl( const Link
& rLink
) { aFileView
.SetDoubleClickHdl( rLink
); }
153 inline void SetNewFolderHdl( const Link
& rLink
) { aNewFolderLink
= rLink
; }
154 inline void ResetCursor() { aFileView
.ResetCursor(); }
155 inline sal_Bool
IsTemplateFolder() const { return bIsTemplateFolder
; }
156 inline String
GetFolderURL() const { return aFolderURL
; }
157 inline String
GetRootURL() const { return aCurrentRootURL
; }
158 inline void OpenRoot( const String
& rRootURL
)
159 { aCurrentRootURL
= rRootURL
; OpenFolder( rRootURL
); }
160 inline void SetMyDocumentsURL( const String
& _rNewURL
) { aMyDocumentsURL
= _rNewURL
; }
161 inline void SetSamplesFolderURL( const String
& _rNewURL
) { aSamplesFolderURL
= _rNewURL
; }
163 String
GetSelectedFile() const;
164 void OpenFolder( const String
& rURL
);
165 sal_Bool
HasPreviousLevel( String
& rURL
) const;
166 String
GetFolderTitle() const;
170 // class SvtFrameWindow_Impl ---------------------------------------------
172 class SvtDocInfoTable_Impl
: public ResStringArray
178 SvtDocInfoTable_Impl();
180 const String
& GetString( long nId
) const;
183 class SvtExtendedMultiLineEdit_Impl
: public ExtMultiLineEdit
186 SvtExtendedMultiLineEdit_Impl( Window
* pParent
,WinBits _nBits
);
187 inline ~SvtExtendedMultiLineEdit_Impl() {}
189 inline void Clear() { SetText( String() ); }
190 void InsertEntry( const String
& rTitle
, const String
& rValue
);
193 class SvtFrameWindow_Impl
: public Window
196 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>
198 ::com::sun::star::uno::Reference
< ::com::sun::star::document::XDocumentProperties
>
200 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>
203 ::svtools::ODocumentInfoPreview
*
207 ::com::sun::star::lang::Locale aLocale
;
208 SvtDocInfoTable_Impl aInfoTable
;
210 ::rtl::OUString m_aOpenURL
;
213 void ShowDocInfo( const String
& rURL
);
217 void ViewNonEmptyWin(); // views depending on bDocInfo
219 struct SvtExecuteInfo
221 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> xDispatch
;
222 ::com::sun::star::util::URL aTargetURL
;
225 DECL_STATIC_LINK( SvtFrameWindow_Impl
, ExecuteHdl_Impl
, SvtExecuteInfo
* );
228 SvtFrameWindow_Impl( Window
* pParent
);
229 ~SvtFrameWindow_Impl();
231 virtual void Resize();
233 void OpenFile( const String
& rURL
, sal_Bool bPreview
, sal_Bool bIsTemplate
, sal_Bool bAsTemplate
);
234 void ToggleView( sal_Bool bDocInfo
);
237 // class SvtTemplateWindow -----------------------------------------------
239 class HistoryList_Impl
;
241 class SvtTemplateWindow
: public Window
246 SplitWindow aSplitWin
;
248 SvtIconWindow_Impl
* pIconWin
;
249 SvtFileViewWindow_Impl
* pFileWin
;
250 SvtFrameWindow_Impl
* pFrameWin
;
251 HistoryList_Impl
* pHistoryList
;
254 Link aDoubleClickHdl
;
262 virtual void Resize();
264 DECL_LINK( IconClickHdl_Impl
, SvtIconChoiceCtrl
* );
265 DECL_LINK( FileSelectHdl_Impl
, SvtFileView
* );
266 DECL_LINK( FileDblClickHdl_Impl
, SvtFileView
* );
267 DECL_LINK( NewFolderHdl_Impl
, SvtFileView
* );
268 DECL_LINK( TimeoutHdl_Impl
, Timer
* );
269 DECL_LINK( ClickHdl_Impl
, ToolBox
* );
270 DECL_LINK( ResizeHdl_Impl
, SplitWindow
* ); // used for split and initial setting of toolbar pos
272 void PrintFile( const String
& rURL
);
273 void AppendHistoryURL( const String
& rURL
, ULONG nGroup
);
275 void DoAction( USHORT nAction
);
276 void InitToolBoxes();
277 void InitToolBoxImages();
281 virtual long PreNotify( NotifyEvent
& rNEvt
);
282 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
285 SvtTemplateWindow( Window
* pParent
);
286 ~SvtTemplateWindow();
288 inline void SetSelectHdl( const Link
& rLink
) { aSelectHdl
= rLink
; }
289 inline void SetDoubleClickHdl( const Link
& rLink
) { aDoubleClickHdl
= rLink
; }
290 inline void SetNewFolderHdl( const Link
& rLink
) { aNewFolderHdl
= rLink
; }
291 inline void SetSendFocusHdl( const Link
& rLink
) { aSendFocusHdl
= rLink
; }
292 inline sal_Bool
IsTemplateFolderOpen() const { return pFileWin
->IsTemplateFolder(); }
293 inline sal_Bool
HasIconWinFocus() const { return pIconWin
->HasChildPathFocus(); }
295 void ReadViewSettings( );
296 void WriteViewSettings( );
297 sal_Bool
IsFileSelected() const;
298 String
GetSelectedFile() const;
299 void OpenFile( sal_Bool bNotAsTemplate
);
300 String
GetFolderTitle() const;
301 String
GetFolderURL() const;
302 void SetFocus( sal_Bool bIconWin
);
303 void OpenTemplateRoot();
304 void SetPrevLevelButtonState( const String
& rURL
); // sets state (enable/disable) for previous level button
306 long CalcHeight() const;
308 void SelectFolder(sal_Int32 nFolderPosition
);
311 #endif // _SVTOOLS_TEMPLWIN_HXX