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