1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 25 #ifndef _WINFILEOPENIMPL_HXX_ 26 #define _WINFILEOPENIMPL_HXX_ 27 28 //------------------------------------------------------------------------ 29 // includes 30 //------------------------------------------------------------------------ 31 32 #ifndef _COM_SUN_STAR_UI_DIALOGS_XEXTENDEDFILEPICKER_HPP_ 33 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> 34 #endif 35 #include <com/sun/star/ui/dialogs/FilePickerEvent.hpp> 36 #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp> 37 #include "FilterContainer.hxx" 38 #include "FileOpenDlg.hxx" 39 #include "previewadapter.hxx" 40 #include "helppopupwindow.hxx" 41 #include "customcontrol.hxx" 42 #include "customcontrolfactory.hxx" 43 #include "..\misc\resourceprovider.hxx" 44 45 #include <utility> 46 #include <memory> 47 #include <vector> 48 #include <osl/conditn.hxx> 49 50 //------------------------------------------------------------------------ 51 // deklarations 52 //------------------------------------------------------------------------ 53 54 // forward declaration 55 class CFilePicker; 56 class CFilePickerState; 57 class CExecuteFilePickerState; 58 class CNonExecuteFilePickerState; 59 60 class CWinFileOpenImpl : public CFileOpenDialog 61 { 62 public: 63 CWinFileOpenImpl( 64 CFilePicker* aFilePicker, 65 sal_Bool bFileOpenDialog = sal_True, 66 sal_uInt32 dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 67 sal_uInt32 dwTemplateId = 0, 68 HINSTANCE hInstance = 0 ); 69 70 virtual ~CWinFileOpenImpl( ); 71 72 //----------------------------------------------------------------------------------------- 73 // XExecutableDialog 74 //----------------------------------------------------------------------------------------- 75 76 virtual sal_Int16 SAL_CALL execute( ); 77 78 //----------------------------------------------------------------------------------------- 79 // XFilePicker 80 //----------------------------------------------------------------------------------------- 81 82 virtual void SAL_CALL setDefaultName( const ::rtl::OUString& aName ); 83 84 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles( ); 85 86 virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& aDirectory ); 87 88 virtual ::rtl::OUString SAL_CALL getDisplayDirectory( ); 89 90 //----------------------------------------------------------------------------------------- 91 // XFilterManager 92 //----------------------------------------------------------------------------------------- 93 94 virtual void SAL_CALL appendFilter( const ::rtl::OUString& aTitle, const ::rtl::OUString& aFilter ); 95 96 virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& aTitle ); 97 98 virtual ::rtl::OUString SAL_CALL getCurrentFilter( ); 99 100 //----------------------------------------------------------------------------------------- 101 // XFilterGroupManager 102 //----------------------------------------------------------------------------------------- 103 104 virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString& sGroupTitle, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair >& aFilters ); 105 106 //----------------------------------------------------------------------------------------- 107 // XFilePickerControlAccess 108 //----------------------------------------------------------------------------------------- 109 110 virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const ::com::sun::star::uno::Any& aValue ); 111 112 virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction ); 113 114 virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable ); 115 116 virtual void SAL_CALL setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel ); 117 118 virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 aControlId ); 119 120 //------------------------------------------------ 121 // XFilePreview 122 //------------------------------------------------ 123 124 virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ); 125 126 virtual sal_Int32 SAL_CALL getTargetColorDepth( ); 127 128 virtual sal_Int32 SAL_CALL getAvailableWidth( ); 129 130 virtual sal_Int32 SAL_CALL getAvailableHeight( ); 131 132 virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any& aImage ); 133 134 virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ); 135 136 virtual sal_Bool SAL_CALL getShowState( ); 137 138 //------------------------------------------------ 139 // XCancelable 140 //------------------------------------------------ 141 142 virtual void SAL_CALL cancel( ); 143 144 //------------------------------------------------ 145 // Implementation details 146 //------------------------------------------------ 147 148 protected: 149 sal_Int16 SAL_CALL getFocused( ); 150 151 virtual bool SAL_CALL preModal( ); 152 virtual void SAL_CALL postModal( sal_Int16 nDialogResult ); 153 154 virtual UINT_PTR SAL_CALL onFileOk(); 155 virtual void SAL_CALL onSelChanged( HWND hwndListBox ); 156 157 // only called back if OFN_EXPLORER is set 158 virtual void SAL_CALL onInitDone(); 159 virtual void SAL_CALL onFolderChanged(); 160 virtual void SAL_CALL onTypeChanged( sal_uInt32 nFilterIndex ); 161 162 // call base class method first when overloading 163 virtual void SAL_CALL onInitDialog( HWND hwndDlg ); 164 165 virtual UINT_PTR SAL_CALL onCtrlCommand( HWND hwndDlg, sal_uInt16 ctrlId, sal_uInt16 notifyCode ); 166 167 168 void onWMSize(); 169 void onWMShow(sal_Bool bShow); 170 void onWMWindowPosChanged(); 171 void onCustomControlHelpRequest(LPHELPINFO lphi); 172 173 private: 174 inline void SAL_CALL appendFilterGroupSeparator( ); 175 176 inline sal_Bool SAL_CALL IsCustomControlHelpRequested(LPHELPINFO lphi) const; 177 178 void EnlargeStdControlLabels() const; 179 180 // initialize all controls from cache 181 void SAL_CALL InitControlLabel( HWND hWnd ); 182 void SAL_CALL InitCustomControlContainer(HWND hCustomControl); 183 184 // save the control state 185 void SAL_CALL CacheControlState(HWND hWnd); 186 187 void SAL_CALL SetDefaultExtension(); 188 void SAL_CALL InitialSetDefaultName(); 189 190 static LRESULT CALLBACK SubClassFunc(HWND hWnd, UINT wMessage, WPARAM wParam, LPARAM lParam); 191 192 static BOOL CALLBACK EnumChildWndProc( HWND hWnd, LPARAM lParam ); 193 194 private: 195 std::auto_ptr<CFilterContainer> m_filterContainer; 196 std::auto_ptr<CPreviewAdapter> m_Preview; 197 std::auto_ptr<CCustomControlFactory> m_CustomControlFactory; 198 std::auto_ptr<CCustomControl> m_CustomControls; 199 CFilePicker* m_FilePicker; 200 WNDPROC m_pfnOldDlgProc; 201 rtl::OUString m_defaultName; 202 sal_Bool m_bInitialSelChanged; 203 CHelpPopupWindow m_HelpPopupWindow; 204 CFilePickerState* m_FilePickerState; 205 CExecuteFilePickerState* m_ExecuteFilePickerState; 206 CNonExecuteFilePickerState* m_NonExecuteFilePickerState; 207 CResourceProvider m_ResProvider; 208 }; 209 210 211 #endif 212