1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SalAquaFilePicker.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SALAQUAFILEPICKER_HXX_
32 #define _SALAQUAFILEPICKER_HXX_
34 //_______________________________________________________________________________________________________________________
35 // includes of other projects
36 //_______________________________________________________________________________________________________________________
38 #include <cppuhelper/compbase8.hxx>
39 #include <com/sun/star/util/XCancellable.hpp>
40 #include <com/sun/star/lang/XInitialization.hpp>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
43 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
44 #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
45 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
46 #include <com/sun/star/beans/StringPair.hpp>
48 #ifndef _SALAQUAPICKER_HXX_
49 #include "SalAquaPicker.hxx"
55 #ifndef _RTL_USTRING_H_
56 #include <rtl/ustring.hxx>
58 #include "FilterHelper.hxx"
59 #include "AquaFilePickerDelegate.hxx"
61 //----------------------------------------------------------
62 // Implementation class for the XFilePicker Interface
63 //----------------------------------------------------------
65 //----------------------------------------------------------
66 // forward declarations
67 //----------------------------------------------------------
71 //----------------------------------------------------------
73 //----------------------------------------------------------
75 class SalAquaFilePicker
:
77 public cppu::WeakComponentImplHelper8
<
78 ::com::sun::star::ui::dialogs::XFilterManager
,
79 ::com::sun::star::ui::dialogs::XFilterGroupManager
,
80 ::com::sun::star::ui::dialogs::XFilePickerControlAccess
,
81 ::com::sun::star::ui::dialogs::XFilePickerNotifier
,
82 ::com::sun::star::lang::XInitialization
,
83 ::com::sun::star::util::XCancellable
,
84 ::com::sun::star::lang::XEventListener
,
85 ::com::sun::star::lang::XServiceInfo
>
90 SalAquaFilePicker( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xServiceMgr
);
92 //------------------------------------------------------------------------------------
93 // XFilePickerNotifier
94 //------------------------------------------------------------------------------------
96 virtual void SAL_CALL
addFilePickerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePickerListener
>& xListener
)
97 throw( ::com::sun::star::uno::RuntimeException
);
98 virtual void SAL_CALL
removeFilePickerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePickerListener
>& xListener
)
99 throw( ::com::sun::star::uno::RuntimeException
);
101 //------------------------------------------------------------------------------------
102 // XExecutableDialog functions
103 //------------------------------------------------------------------------------------
105 virtual void SAL_CALL
setTitle( const ::rtl::OUString
& aTitle
)
106 throw( ::com::sun::star::uno::RuntimeException
);
108 virtual sal_Int16 SAL_CALL
execute( )
109 throw( ::com::sun::star::uno::RuntimeException
);
111 //------------------------------------------------------------------------------------
112 // XFilePicker functions
113 //------------------------------------------------------------------------------------
115 virtual void SAL_CALL
setMultiSelectionMode( sal_Bool bMode
)
116 throw( ::com::sun::star::uno::RuntimeException
);
118 virtual void SAL_CALL
setDefaultName( const ::rtl::OUString
& aName
)
119 throw( ::com::sun::star::uno::RuntimeException
);
121 virtual void SAL_CALL
setDisplayDirectory( const ::rtl::OUString
& aDirectory
)
122 throw( com::sun::star::lang::IllegalArgumentException
,
123 ::com::sun::star::uno::RuntimeException
);
125 virtual ::rtl::OUString SAL_CALL
getDisplayDirectory( )
126 throw( ::com::sun::star::uno::RuntimeException
);
128 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getFiles( )
129 throw( ::com::sun::star::uno::RuntimeException
);
131 //------------------------------------------------------------------------------------
132 // XFilterManager functions
133 //------------------------------------------------------------------------------------
135 virtual void SAL_CALL
appendFilter( const ::rtl::OUString
& aTitle
, const ::rtl::OUString
& aFilter
)
136 throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
138 virtual void SAL_CALL
setCurrentFilter( const ::rtl::OUString
& aTitle
)
139 throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
141 virtual ::rtl::OUString SAL_CALL
getCurrentFilter( )
142 throw( ::com::sun::star::uno::RuntimeException
);
144 //------------------------------------------------------------------------------------
145 // XFilterGroupManager functions
146 //------------------------------------------------------------------------------------
148 virtual void SAL_CALL
appendFilterGroup( const ::rtl::OUString
& sGroupTitle
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::StringPair
>& aFilters
)
149 throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
151 //------------------------------------------------------------------------------------
152 // XFilePickerControlAccess functions
153 //------------------------------------------------------------------------------------
155 virtual void SAL_CALL
setValue( sal_Int16 nControlId
, sal_Int16 nControlAction
, const ::com::sun::star::uno::Any
& aValue
)
156 throw (::com::sun::star::uno::RuntimeException
);
158 virtual ::com::sun::star::uno::Any SAL_CALL
getValue( sal_Int16 aControlId
, sal_Int16 aControlAction
)
159 throw (::com::sun::star::uno::RuntimeException
);
161 virtual void SAL_CALL
enableControl( sal_Int16 nControlId
, sal_Bool bEnable
)
162 throw(::com::sun::star::uno::RuntimeException
);
164 virtual void SAL_CALL
setLabel( sal_Int16 nControlId
, const ::rtl::OUString
& aLabel
)
165 throw (::com::sun::star::uno::RuntimeException
);
167 virtual ::rtl::OUString SAL_CALL
getLabel( sal_Int16 nControlId
)
168 throw (::com::sun::star::uno::RuntimeException
);
170 //------------------------------------------------
172 //------------------------------------------------
174 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
)
175 throw(::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
177 //------------------------------------------------
179 //------------------------------------------------
181 virtual void SAL_CALL
cancel( )
182 throw( ::com::sun::star::uno::RuntimeException
);
184 //------------------------------------------------
186 //------------------------------------------------
188 using cppu::WeakComponentImplHelperBase::disposing
;
189 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& aEvent
)
190 throw(::com::sun::star::uno::RuntimeException
);
192 //------------------------------------------------
194 //------------------------------------------------
196 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
197 throw(::com::sun::star::uno::RuntimeException
);
199 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
200 throw(::com::sun::star::uno::RuntimeException
);
202 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
203 throw(::com::sun::star::uno::RuntimeException
);
205 //------------------------------------------------------------------------------------
206 // FilePicker Event functions
207 //------------------------------------------------------------------------------------
209 void SAL_CALL
fileSelectionChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent
);
210 void SAL_CALL
directoryChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent
);
211 // rtl::OUString SAL_CALL helpRequested( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ) const;
212 void SAL_CALL
controlStateChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent
);
213 void SAL_CALL
dialogSizeChanged( );
215 inline AquaFilePickerDelegate
* getDelegate() {
219 inline rtl::OUString
getSaveFileName() {
220 return m_sSaveFileName
;
224 // prevent copy and assignment
225 SalAquaFilePicker( const SalAquaFilePicker
& );
226 SalAquaFilePicker
& operator=( const SalAquaFilePicker
& );
228 virtual void ensureFilterHelper();
230 // to instantiate own services
231 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_xServiceMgr
;
233 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePickerListener
>
236 FilterHelper
*m_pFilterHelper
;
238 rtl::OUString m_sSaveFileName
;
240 AquaFilePickerDelegate
*m_pDelegate
;
242 void updateFilterUI();
243 void updateSaveFileNameExtension();
247 virtual ~SalAquaFilePicker();
249 void filterControlChanged();
251 void implInitialize();
255 #endif // _SALAQUAFILEPICKER_HXX_