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 SVTOOLS_CONTROLACCESS_HXX
25 #define SVTOOLS_CONTROLACCESS_HXX
26 
27 #include <svtools/fileview.hxx>
28 #include <vcl/lstbox.hxx>
29 #include <com/sun/star/lang/IllegalArgumentException.hpp>
30 #include "pickercallbacks.hxx"
31 
32 //.........................................................................
33 namespace svt
34 {
35 //.........................................................................
36 
37 	// --------------------------------------------------------------------
38 	namespace InternalFilePickerElementIds
39 	{
40 		static const sal_Int16 PUSHBUTTON_HELP = (sal_Int16)0x1000;
41 		static const sal_Int16 TOOLBOXBUTOON_DEFAULT_LOCATION = (sal_Int16)0x1001;
42 		static const sal_Int16 TOOLBOXBUTOON_LEVEL_UP = (sal_Int16)0x1002;
43 		static const sal_Int16 TOOLBOXBUTOON_NEW_FOLDER = (sal_Int16)0x1003;
44 		static const sal_Int16 FIXEDTEXT_CURRENTFOLDER = (sal_Int16)0x1004;
45 	}
46 
47 	// --------------------------------------------------------------------
48 	/**	implements the XControlAccess, XControlInformation and XFilePickerControlAccess for the file picker
49 	*/
50 	class OControlAccess
51 	{
52 		IFilePickerController*	m_pFilePickerController;
53 		SvtFileView*			m_pFileView;
54 
55 	public:
56 		OControlAccess( IFilePickerController* _pController, SvtFileView* _pFileView );
57 
58 		// XControlAccess implementation
59 		void setControlProperty( const ::rtl::OUString& _rControlName, const ::rtl::OUString& _rControlProperty, const ::com::sun::star::uno::Any& _rValue );
60 		::com::sun::star::uno::Any	getControlProperty( const ::rtl::OUString& _rControlName, const ::rtl::OUString& _rControlProperty );
61 
62 		// XControlInformation implementation
63 		::com::sun::star::uno::Sequence< ::rtl::OUString >	getSupportedControls(  );
64 		::com::sun::star::uno::Sequence< ::rtl::OUString >	getSupportedControlProperties( const ::rtl::OUString& _rControlName );
65 		sal_Bool											isControlSupported( const ::rtl::OUString& _rControlName );
66 		sal_Bool											isControlPropertySupported( const ::rtl::OUString& _rControlName, const ::rtl::OUString& _rControlProperty );
67 
68 		// XFilePickerControlAccess
69 		void						setValue( sal_Int16 _nId, sal_Int16 _nCtrlAction, const ::com::sun::star::uno::Any& _rValue );
70 		::com::sun::star::uno::Any  getValue( sal_Int16 _nId, sal_Int16 _nCtrlAction ) const;
71 		void						setLabel( sal_Int16 _nId, const ::rtl::OUString& _rValue );
72 		::rtl::OUString             getLabel( sal_Int16 _nId ) const;
73 		void                        enableControl( sal_Int16 _nId, sal_Bool _bEnable );
74 
75 		static void				setHelpURL( Window* _pControl, const ::rtl::OUString& _rURL, sal_Bool _bFileView );
76 		static ::rtl::OUString	getHelpURL( Window* _pControl, sal_Bool _bFileView );
77 
78 	private:
79 		/** implements the various methods for setting properties on controls
80 
81             @param _nControlId
82                 the id of the control
83 			@param _pControl
84 				the affected control. Must be the same as referred by <arg>_nControlId</arg>, or NULL.
85 			@param _nProperty
86 				the property to set
87 				See PROPERTY_FLAG_*
88 			@param _rValue
89 				the value to set
90 			@param _bIgnoreIllegalArgument
91 				if <FALSE/>, an exception will be thrown if the given value is of improper type
92 		*/
93 		void						implSetControlProperty(
94                                         sal_Int16 _nControlId,
95 										Control* _pControl, sal_Int16 _nProperty, const ::com::sun::star::uno::Any& _rValue,
96 										sal_Bool _bIgnoreIllegalArgument = sal_True );
97 
98 		Control* implGetControl( const ::rtl::OUString& _rControlName, sal_Int16* _pId = NULL, sal_Int32* _pPropertyMask = NULL ) const SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) );
99 
100 		/** implements the various methods for retrieving properties from controls
101 
102 			@param _pControl
103 				the affected control
104 				@PRECOND not <NULL/>
105 			@param _nProperty
106 				the property to retrieve
107 				See PROPERTY_FLAG_*
108 			@return
109 		*/
110 		::com::sun::star::uno::Any	implGetControlProperty( Control* _pControl, sal_Int16 _nProperty ) const;
111 
112 		void implDoListboxAction( ListBox* _pListbox, sal_Int16 _nCtrlAction, const ::com::sun::star::uno::Any& _rValue );
113 
114 	};
115 
116 //.........................................................................
117 }	// namespace svt
118 //.........................................................................
119 
120 #endif // SVTOOLS_CONTROLACCESS_HXX
121 
122