1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 29 #ifndef _WINFILEOPENIMPL_HXX_ 30 #define _WINFILEOPENIMPL_HXX_ 31 32 //------------------------------------------------------------------------ 33 // includes 34 //------------------------------------------------------------------------ 35 36 #ifndef _COM_SUN_STAR_UI_DIALOGS_XEXTENDEDFILEPICKER_HPP_ 37 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> 38 #endif 39 #include <com/sun/star/ui/dialogs/FilePickerEvent.hpp> 40 #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp> 41 #include "FilterContainer.hxx" 42 #include "FileOpenDlg.hxx" 43 #include "previewadapter.hxx" 44 #include "helppopupwindow.hxx" 45 #include "customcontrol.hxx" 46 #include "customcontrolfactory.hxx" 47 #include "..\misc\resourceprovider.hxx" 48 49 #include <utility> 50 #include <memory> 51 #include <vector> 52 #include <osl/conditn.hxx> 53 54 //------------------------------------------------------------------------ 55 // deklarations 56 //------------------------------------------------------------------------ 57 58 // forward declaration 59 class CFilePicker; 60 class CFilePickerState; 61 class CExecuteFilePickerState; 62 class CNonExecuteFilePickerState; 63 64 class CWinFileOpenImpl : public CFileOpenDialog 65 { 66 public: 67 CWinFileOpenImpl( 68 CFilePicker* aFilePicker, 69 sal_Bool bFileOpenDialog = sal_True, 70 sal_uInt32 dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 71 sal_uInt32 dwTemplateId = 0, 72 HINSTANCE hInstance = 0 ); 73 74 virtual ~CWinFileOpenImpl( ); 75 76 //----------------------------------------------------------------------------------------- 77 // XExecutableDialog 78 //----------------------------------------------------------------------------------------- 79 80 virtual sal_Int16 SAL_CALL execute( ) throw( ::com::sun::star::uno::RuntimeException ); 81 82 //----------------------------------------------------------------------------------------- 83 // XFilePicker 84 //----------------------------------------------------------------------------------------- 85 86 virtual void SAL_CALL setDefaultName( const ::rtl::OUString& aName ) 87 throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 88 89 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles( ) 90 throw(::com::sun::star::uno::RuntimeException ); 91 92 virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& aDirectory ) 93 throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 94 95 virtual ::rtl::OUString SAL_CALL getDisplayDirectory( ) throw ( ::com::sun::star::uno::RuntimeException ); 96 97 //----------------------------------------------------------------------------------------- 98 // XFilterManager 99 //----------------------------------------------------------------------------------------- 100 101 virtual void SAL_CALL appendFilter( const ::rtl::OUString& aTitle, const ::rtl::OUString& aFilter ) 102 throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 103 104 virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& aTitle ) 105 throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); 106 107 virtual ::rtl::OUString SAL_CALL getCurrentFilter( ) 108 throw( ::com::sun::star::uno::RuntimeException ); 109 110 //----------------------------------------------------------------------------------------- 111 // XFilterGroupManager 112 //----------------------------------------------------------------------------------------- 113 114 virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString& sGroupTitle, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair >& aFilters ) 115 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 116 117 //----------------------------------------------------------------------------------------- 118 // XFilePickerControlAccess 119 //----------------------------------------------------------------------------------------- 120 121 virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const ::com::sun::star::uno::Any& aValue ) 122 throw( ::com::sun::star::uno::RuntimeException ); 123 124 virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction ) 125 throw( ::com::sun::star::uno::RuntimeException ); 126 127 virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable ) 128 throw( ::com::sun::star::uno::RuntimeException ); 129 130 virtual void SAL_CALL setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel ) 131 throw (::com::sun::star::uno::RuntimeException); 132 133 virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 aControlId ) 134 throw ( ::com::sun::star::uno::RuntimeException); 135 136 //------------------------------------------------ 137 // XFilePreview 138 //------------------------------------------------ 139 140 virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ) 141 throw (::com::sun::star::uno::RuntimeException); 142 143 virtual sal_Int32 SAL_CALL getTargetColorDepth( ) 144 throw (::com::sun::star::uno::RuntimeException); 145 146 virtual sal_Int32 SAL_CALL getAvailableWidth( ) 147 throw (::com::sun::star::uno::RuntimeException); 148 149 virtual sal_Int32 SAL_CALL getAvailableHeight( ) 150 throw (::com::sun::star::uno::RuntimeException); 151 152 virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& aImage ) 153 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 154 155 virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) 156 throw (::com::sun::star::uno::RuntimeException); 157 158 virtual sal_Bool SAL_CALL getShowState( ) 159 throw (::com::sun::star::uno::RuntimeException); 160 161 //------------------------------------------------ 162 // XCancelable 163 //------------------------------------------------ 164 165 virtual void SAL_CALL cancel( ); 166 167 //------------------------------------------------ 168 // Implementation details 169 //------------------------------------------------ 170 171 protected: 172 sal_Int16 SAL_CALL getFocused( ); 173 174 virtual bool SAL_CALL preModal( ); 175 virtual void SAL_CALL postModal( sal_Int16 nDialogResult ); 176 177 virtual sal_uInt32 SAL_CALL onFileOk(); 178 virtual void SAL_CALL onSelChanged( HWND hwndListBox ); 179 180 // only called back if OFN_EXPLORER is set 181 virtual void SAL_CALL onInitDone(); 182 virtual void SAL_CALL onFolderChanged(); 183 virtual void SAL_CALL onTypeChanged( sal_uInt32 nFilterIndex ); 184 185 // call base class method first when overloading 186 virtual void SAL_CALL onInitDialog( HWND hwndDlg ); 187 188 virtual sal_uInt32 SAL_CALL onCtrlCommand( HWND hwndDlg, sal_uInt16 ctrlId, sal_uInt16 notifyCode ); 189 190 191 void onWMSize(); 192 void onWMShow(sal_Bool bShow); 193 void onWMWindowPosChanged(); 194 void onCustomControlHelpRequest(LPHELPINFO lphi); 195 196 private: 197 inline void SAL_CALL appendFilterGroupSeparator( ); 198 199 inline sal_Bool SAL_CALL IsCustomControlHelpRequested(LPHELPINFO lphi) const; 200 201 void EnlargeStdControlLabels() const; 202 203 // initialize all controls from cache 204 void SAL_CALL InitControlLabel( HWND hWnd ); 205 void SAL_CALL InitCustomControlContainer(HWND hCustomControl); 206 207 // save the control state 208 void SAL_CALL CacheControlState(HWND hWnd); 209 210 void SAL_CALL SetDefaultExtension(); 211 void SAL_CALL InitialSetDefaultName(); 212 213 static LRESULT CALLBACK SubClassFunc(HWND hWnd, UINT wMessage, WPARAM wParam, LPARAM lParam); 214 215 static BOOL CALLBACK EnumChildWndProc( HWND hWnd, LPARAM lParam ); 216 217 private: 218 std::auto_ptr<CFilterContainer> m_filterContainer; 219 std::auto_ptr<CPreviewAdapter> m_Preview; 220 std::auto_ptr<CCustomControlFactory> m_CustomControlFactory; 221 std::auto_ptr<CCustomControl> m_CustomControls; 222 CFilePicker* m_FilePicker; 223 WNDPROC m_pfnOldDlgProc; 224 rtl::OUString m_defaultName; 225 sal_Bool m_bInitialSelChanged; 226 CHelpPopupWindow m_HelpPopupWindow; 227 CFilePickerState* m_FilePickerState; 228 CExecuteFilePickerState* m_ExecuteFilePickerState; 229 CNonExecuteFilePickerState* m_NonExecuteFilePickerState; 230 CResourceProvider m_ResProvider; 231 }; 232 233 234 #endif 235