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