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 #ifndef _FILEPICKERSTATE_HXX_ 29 #define _FILEPICKERSTATE_HXX_ 30 31 //------------------------------------------------------------------------ 32 // includes 33 //------------------------------------------------------------------------ 34 35 #include <sal/types.h> 36 #include "controlcommand.hxx" 37 #include <com/sun/star/uno/Any.hxx> 38 #include <com/sun/star/uno/Sequence.hxx> 39 #include <rtl/ustring.hxx> 40 41 #define WIN32_LEAN_AND_MEAN 42 #if defined _MSC_VER 43 #pragma warning(push, 1) 44 #endif 45 #include <windows.h> 46 #if defined _MSC_VER 47 #pragma warning(pop) 48 #endif 49 //--------------------------------------------- 50 // 51 //--------------------------------------------- 52 53 class CControlCommand; 54 class CFileOpenDialog; 55 56 //--------------------------------------------- 57 // declaration 58 //--------------------------------------------- 59 60 class CFilePickerState 61 { 62 public: 63 virtual ~CFilePickerState( ); 64 65 virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const ::com::sun::star::uno::Any& aValue ) = 0; 66 67 virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction ) = 0; 68 69 virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable ) = 0; 70 71 virtual void SAL_CALL setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel ) = 0; 72 73 virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 aControlId ) = 0; 74 75 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles( CFileOpenDialog* aFileOpenDialog ) = 0; 76 77 virtual rtl::OUString SAL_CALL getDisplayDirectory( CFileOpenDialog* aFileOpenDialog ) = 0; 78 }; 79 80 //--------------------------------------------- 81 // this class is not thread-safe 82 //--------------------------------------------- 83 84 class CNonExecuteFilePickerState : public CFilePickerState 85 { 86 public: 87 CNonExecuteFilePickerState( ); 88 89 virtual ~CNonExecuteFilePickerState( ); 90 91 virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const ::com::sun::star::uno::Any& aValue ); 92 93 virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction ); 94 95 virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable ); 96 97 virtual void SAL_CALL setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel ); 98 99 virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 aControlId ); 100 101 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles( CFileOpenDialog* aFileOpenDialog ); 102 103 virtual rtl::OUString SAL_CALL getDisplayDirectory( CFileOpenDialog* aFileOpenDialog ); 104 105 void SAL_CALL reset( ); 106 107 CControlCommand* SAL_CALL getControlCommand( ) const; 108 109 protected: 110 void SAL_CALL addControlCommand( CControlCommand* aControlCommand ); 111 112 private: 113 CControlCommand* m_FirstControlCommand; 114 }; 115 116 //--------------------------------------------- 117 // this class is not thread-safe 118 //--------------------------------------------- 119 120 class CExecuteFilePickerState : public CFilePickerState 121 { 122 public: 123 CExecuteFilePickerState( HWND hwndDlg = NULL ); 124 125 virtual void SAL_CALL setValue( sal_Int16 aControlId, sal_Int16 aControlAction, const ::com::sun::star::uno::Any& aValue ); 126 127 virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction ); 128 129 virtual void SAL_CALL enableControl( sal_Int16 aControlId, sal_Bool bEnable ); 130 131 virtual void SAL_CALL setLabel( sal_Int16 aControlId, const ::rtl::OUString& aLabel ); 132 133 virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 aControlId ); 134 135 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles( CFileOpenDialog* aFileOpenDialog ); 136 137 virtual rtl::OUString SAL_CALL getDisplayDirectory( CFileOpenDialog* aFileOpenDialog ); 138 139 void SAL_CALL initFilePickerControls( CControlCommand* firstControlCommand ); 140 141 void SAL_CALL cacheControlState( HWND hwndControl, CFilePickerState* aFilePickerState ); 142 143 void SAL_CALL setHwnd( HWND hwndDlg ); 144 145 private: 146 147 inline sal_Bool SAL_CALL IsListboxControl( HWND hwndControl ) const; 148 149 inline sal_Int16 SAL_CALL ListboxIdToListboxLabelId( sal_Int16 aListboxId ) const; 150 151 inline HWND SAL_CALL GetListboxLabelItem( sal_Int16 aControlId ) const; 152 153 // returns a hwnd for a control if successful 154 // if bIncludeStdCtrls is false, the standard file dialog 155 // controls like OK button, etc. will not be considered 156 // the function return 0 on failure 157 HWND SAL_CALL GetHwndDlgItem( sal_Int16 aControlId, sal_Bool bIncludeStdCtrls = sal_True ) const; 158 159 HWND m_hwndDlg; 160 }; 161 162 #endif 163