merge the formfield patch from ooo-build
[ooovba.git] / fpicker / source / win32 / filepicker / WinFileOpenImpl.hxx
blob16c0c3b7cec9eb47c79e2f697ab6309c4ae66242
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WinFileOpenImpl.hxx,v $
10 * $Revision: 1.16 $
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 ************************************************************************/
32 #ifndef _WINFILEOPENIMPL_HXX_
33 #define _WINFILEOPENIMPL_HXX_
35 //------------------------------------------------------------------------
36 // includes
37 //------------------------------------------------------------------------
39 #ifndef _COM_SUN_STAR_UI_DIALOGS_XEXTENDEDFILEPICKER_HPP_
40 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
41 #endif
42 #include <com/sun/star/ui/dialogs/FilePickerEvent.hpp>
43 #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
44 #include "FilterContainer.hxx"
45 #include "FileOpenDlg.hxx"
46 #include "previewadapter.hxx"
47 #include "helppopupwindow.hxx"
48 #include "customcontrol.hxx"
49 #include "customcontrolfactory.hxx"
50 #include "..\misc\resourceprovider.hxx"
52 #include <utility>
53 #include <memory>
54 #include <vector>
55 #include <osl/conditn.hxx>
57 //------------------------------------------------------------------------
58 // deklarations
59 //------------------------------------------------------------------------
61 // forward declaration
62 class CFilePicker;
63 class CFilePickerState;
64 class CExecuteFilePickerState;
65 class CNonExecuteFilePickerState;
67 class CWinFileOpenImpl : public CFileOpenDialog
69 public:
70 CWinFileOpenImpl(
71 CFilePicker* aFilePicker,
72 sal_Bool bFileOpenDialog = sal_True,
73 sal_uInt32 dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
74 sal_uInt32 dwTemplateId = 0,
75 HINSTANCE hInstance = 0 );
77 virtual ~CWinFileOpenImpl( );
79 //-----------------------------------------------------------------------------------------
80 // XExecutableDialog
81 //-----------------------------------------------------------------------------------------
83 virtual sal_Int16 SAL_CALL execute( ) throw( ::com::sun::star::uno::RuntimeException );
85 //-----------------------------------------------------------------------------------------
86 // XFilePicker
87 //-----------------------------------------------------------------------------------------
89 virtual void SAL_CALL setDefaultName( const ::rtl::OUString& aName )
90 throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
92 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles( )
93 throw(::com::sun::star::uno::RuntimeException );
95 virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& aDirectory )
96 throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
98 virtual ::rtl::OUString SAL_CALL getDisplayDirectory( ) throw ( ::com::sun::star::uno::RuntimeException );
100 //-----------------------------------------------------------------------------------------
101 // XFilterManager
102 //-----------------------------------------------------------------------------------------
104 virtual void SAL_CALL appendFilter( const ::rtl::OUString& aTitle, const ::rtl::OUString& aFilter )
105 throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
107 virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& aTitle )
108 throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
110 virtual ::rtl::OUString SAL_CALL getCurrentFilter( )
111 throw( ::com::sun::star::uno::RuntimeException );
113 //-----------------------------------------------------------------------------------------
114 // XFilterGroupManager
115 //-----------------------------------------------------------------------------------------
117 virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString& sGroupTitle, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair >& aFilters )
118 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
120 //-----------------------------------------------------------------------------------------
121 // XFilePickerControlAccess
122 //-----------------------------------------------------------------------------------------
124 virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const ::com::sun::star::uno::Any& aValue )
125 throw( ::com::sun::star::uno::RuntimeException );
127 virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction )
128 throw( ::com::sun::star::uno::RuntimeException );
130 virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable )
131 throw( ::com::sun::star::uno::RuntimeException );
133 virtual void SAL_CALL setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel )
134 throw (::com::sun::star::uno::RuntimeException);
136 virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 aControlId )
137 throw ( ::com::sun::star::uno::RuntimeException);
139 //------------------------------------------------
140 // XFilePreview
141 //------------------------------------------------
143 virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( )
144 throw (::com::sun::star::uno::RuntimeException);
146 virtual sal_Int32 SAL_CALL getTargetColorDepth( )
147 throw (::com::sun::star::uno::RuntimeException);
149 virtual sal_Int32 SAL_CALL getAvailableWidth( )
150 throw (::com::sun::star::uno::RuntimeException);
152 virtual sal_Int32 SAL_CALL getAvailableHeight( )
153 throw (::com::sun::star::uno::RuntimeException);
155 virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& aImage )
156 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
158 virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState )
159 throw (::com::sun::star::uno::RuntimeException);
161 virtual sal_Bool SAL_CALL getShowState( )
162 throw (::com::sun::star::uno::RuntimeException);
164 //------------------------------------------------
165 // XCancelable
166 //------------------------------------------------
168 virtual void SAL_CALL cancel( );
170 //------------------------------------------------
171 // Implementation details
172 //------------------------------------------------
174 protected:
175 sal_Int16 SAL_CALL getFocused( );
177 virtual bool SAL_CALL preModal( );
178 virtual void SAL_CALL postModal( sal_Int16 nDialogResult );
180 virtual sal_uInt32 SAL_CALL onFileOk();
181 virtual void SAL_CALL onSelChanged( HWND hwndListBox );
183 // only called back if OFN_EXPLORER is set
184 virtual void SAL_CALL onInitDone();
185 virtual void SAL_CALL onFolderChanged();
186 virtual void SAL_CALL onTypeChanged( sal_uInt32 nFilterIndex );
188 // call base class method first when overloading
189 virtual void SAL_CALL onInitDialog( HWND hwndDlg );
191 virtual sal_uInt32 SAL_CALL onCtrlCommand( HWND hwndDlg, sal_uInt16 ctrlId, sal_uInt16 notifyCode );
194 void onWMSize();
195 void onWMShow(BOOL bShow);
196 void onWMWindowPosChanged();
197 void onCustomControlHelpRequest(LPHELPINFO lphi);
199 private:
200 inline void SAL_CALL appendFilterGroupSeparator( );
202 inline sal_Bool SAL_CALL IsCustomControlHelpRequested(LPHELPINFO lphi) const;
204 void EnlargeStdControlLabels() const;
206 // initialize all controls from cache
207 void SAL_CALL InitControlLabel( HWND hWnd );
208 void SAL_CALL InitCustomControlContainer(HWND hCustomControl);
210 // save the control state
211 void SAL_CALL CacheControlState(HWND hWnd);
213 void SAL_CALL SetDefaultExtension();
214 void SAL_CALL InitialSetDefaultName();
216 static LRESULT CALLBACK SubClassFunc(HWND hWnd, UINT wMessage, WPARAM wParam, LPARAM lParam);
218 static BOOL CALLBACK EnumChildWndProc( HWND hWnd, LPARAM lParam );
220 private:
221 std::auto_ptr<CFilterContainer> m_filterContainer;
222 std::auto_ptr<CPreviewAdapter> m_Preview;
223 std::auto_ptr<CCustomControlFactory> m_CustomControlFactory;
224 std::auto_ptr<CCustomControl> m_CustomControls;
225 CFilePicker* m_FilePicker;
226 WNDPROC m_pfnOldDlgProc;
227 rtl::OUString m_defaultName;
228 sal_Bool m_bInitialSelChanged;
229 CHelpPopupWindow m_HelpPopupWindow;
230 CFilePickerState* m_FilePickerState;
231 CExecuteFilePickerState* m_ExecuteFilePickerState;
232 CNonExecuteFilePickerState* m_NonExecuteFilePickerState;
233 CResourceProvider m_ResProvider;
237 #endif