Update ooo320-m1
[ooovba.git] / fpicker / source / office / OfficeFilePicker.hxx
blob7244602edb3d1ccd2a8a8801fec3ec4296684d3f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OfficeFilePicker.hxx,v $
10 * $Revision: 1.8 $
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 ************************************************************************/
30 #ifndef INCLUDED_SVT_FILEPICKER_HXX
31 #define INCLUDED_SVT_FILEPICKER_HXX
33 #include <cppuhelper/implbase7.hxx>
34 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
35 #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
36 #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
37 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
38 #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
39 #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
40 #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/lang/XEventListener.hpp>
43 #ifndef _COM_SUN_STAR_UNO_XCOMPONENT_CONTEXT_HPP_
44 #include <com/sun/star/uno/XComponentContext.hpp>
45 #endif
48 #include <vcl/wintypes.hxx>
49 #include "commonpicker.hxx"
50 #include "pickercallbacks.hxx"
52 #include <list>
54 class Dialog;
56 struct FilterEntry;
57 struct ElementEntry_Impl;
59 typedef ::std::list< FilterEntry > FilterList; // can be maintained more effectively
60 typedef ::std::list < ElementEntry_Impl > ElementList;
62 typedef ::com::sun::star::beans::StringPair UnoFilterEntry;
63 typedef ::com::sun::star::uno::Sequence< UnoFilterEntry > UnoFilterList; // can be transported more effectively
64 typedef ::com::sun::star::uno::Sequence< ::rtl::OUString > OUStringList; // can be transported more effectively
66 // class SvtFilePicker ---------------------------------------------------
68 typedef ::cppu::ImplHelper7 < ::com::sun::star::ui::dialogs::XFilePickerControlAccess
69 , ::com::sun::star::ui::dialogs::XFilePickerNotifier
70 , ::com::sun::star::ui::dialogs::XFilePreview
71 , ::com::sun::star::ui::dialogs::XFilterManager
72 , ::com::sun::star::ui::dialogs::XFilterGroupManager
73 , ::com::sun::star::lang::XServiceInfo
74 , ::com::sun::star::ui::dialogs::XAsynchronousExecutableDialog
75 > SvtFilePicker_Base;
77 class SvtFilePicker :public SvtFilePicker_Base
78 ,public ::svt::OCommonPicker
79 ,public ::svt::IFilePickerListener
81 private:
82 FilterList* m_pFilterList;
83 ElementList* m_pElemList;
85 sal_Bool m_bMultiSelection;
86 sal_Int16 m_nServiceType;
87 ::rtl::OUString m_aDefaultName;
88 ::rtl::OUString m_aCurrentFilter;
90 // #97148# --------------
91 ::rtl::OUString m_aOldDisplayDirectory;
92 ::rtl::OUString m_aOldHideDirectory;
94 ::rtl::OUString m_aStandardDir;
95 OUStringList m_aBlackList;
97 ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >
98 m_xListener;
99 ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener >
100 m_xDlgClosedListener;
102 public:
103 SvtFilePicker( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& xFactory );
104 virtual ~SvtFilePicker();
106 //------------------------------------------------------------------------------------
107 // disambiguate XInterface
108 //------------------------------------------------------------------------------------
109 DECLARE_XINTERFACE( )
111 //------------------------------------------------------------------------------------
112 // disambiguate XTypeProvider
113 //------------------------------------------------------------------------------------
114 DECLARE_XTYPEPROVIDER( )
116 //------------------------------------------------------------------------------------
117 // XExecutableDialog functions
118 //------------------------------------------------------------------------------------
119 virtual void SAL_CALL setTitle( const ::rtl::OUString& _rTitle ) throw (::com::sun::star::uno::RuntimeException);
120 virtual sal_Int16 SAL_CALL execute( ) throw (::com::sun::star::uno::RuntimeException);
122 //------------------------------------------------------------------------------------
123 // XAsynchronousExecutableDialog functions
124 //------------------------------------------------------------------------------------
125 virtual void SAL_CALL setDialogTitle( const ::rtl::OUString& _rTitle ) throw (::com::sun::star::uno::RuntimeException);
126 virtual void SAL_CALL startExecuteModal( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
128 //------------------------------------------------------------------------------------
129 // XFilePicker functions
130 //------------------------------------------------------------------------------------
132 virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode ) throw( ::com::sun::star::uno::RuntimeException );
133 virtual void SAL_CALL setDefaultName( const ::rtl::OUString& aName ) throw( ::com::sun::star::uno::RuntimeException );
134 virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& aDirectory ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
135 virtual ::rtl::OUString SAL_CALL getDisplayDirectory() throw( ::com::sun::star::uno::RuntimeException );
136 virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles() throw( ::com::sun::star::uno::RuntimeException );
138 //------------------------------------------------------------------------------------
139 // XFilePickerControlAccess functions
140 //------------------------------------------------------------------------------------
142 virtual void SAL_CALL setValue( sal_Int16 ElementID, sal_Int16 ControlAction, const com::sun::star::uno::Any& value ) throw( ::com::sun::star::uno::RuntimeException );
143 virtual com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 ElementID, sal_Int16 ControlAction ) throw( ::com::sun::star::uno::RuntimeException );
144 virtual void SAL_CALL setLabel( sal_Int16 ElementID, const ::rtl::OUString& aValue ) throw ( ::com::sun::star::uno::RuntimeException );
145 virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 ElementID ) throw ( ::com::sun::star::uno::RuntimeException );
146 virtual void SAL_CALL enableControl( sal_Int16 ElementID, sal_Bool bEnable ) throw( ::com::sun::star::uno::RuntimeException );
148 //------------------------------------------------------------------------------------
149 // XFilePickerNotifier functions
150 //------------------------------------------------------------------------------------
152 virtual void SAL_CALL addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw ( ::com::sun::star::uno::RuntimeException );
153 virtual void SAL_CALL removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw ( ::com::sun::star::uno::RuntimeException );
155 //------------------------------------------------------------------------------------
156 // XFilePreview functions
157 //------------------------------------------------------------------------------------
159 virtual com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats() throw ( ::com::sun::star::uno::RuntimeException );
160 virtual sal_Int32 SAL_CALL getTargetColorDepth() throw ( ::com::sun::star::uno::RuntimeException );
161 virtual sal_Int32 SAL_CALL getAvailableWidth() throw ( ::com::sun::star::uno::RuntimeException );
162 virtual sal_Int32 SAL_CALL getAvailableHeight() throw ( ::com::sun::star::uno::RuntimeException );
163 virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const com::sun::star::uno::Any& aImage ) throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
164 virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw ( ::com::sun::star::uno::RuntimeException );
165 virtual sal_Bool SAL_CALL getShowState() throw ( ::com::sun::star::uno::RuntimeException );
167 //------------------------------------------------------------------------------------
168 // XFilterManager functions
169 //------------------------------------------------------------------------------------
171 virtual void SAL_CALL appendFilter( const ::rtl::OUString& aTitle, const ::rtl::OUString& aFilter ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
172 virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& aTitle ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
173 virtual ::rtl::OUString SAL_CALL getCurrentFilter() throw( ::com::sun::star::uno::RuntimeException );
175 //------------------------------------------------------------------------------------
176 // XFilterGroupManager functions
177 //------------------------------------------------------------------------------------
178 virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString& sGroupTitle, const com::sun::star::uno::Sequence< com::sun::star::beans::StringPair >& aFilters ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
180 //------------------------------------------------------------------------------------
181 // XInitialization functions
182 //------------------------------------------------------------------------------------
184 virtual void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments ) throw ( com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException );
186 //------------------------------------------------------------------------------------
187 // XServiceInfo functions
188 //------------------------------------------------------------------------------------
190 /* XServiceInfo */
191 virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
192 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName ) throw( ::com::sun::star::uno::RuntimeException );
193 virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
194 getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
196 /* Helper for XServiceInfo */
197 static com::sun::star::uno::Sequence< ::rtl::OUString >
198 impl_getStaticSupportedServiceNames();
199 static ::rtl::OUString impl_getStaticImplementationName();
201 /* Helper for registry */
202 static ::com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL impl_createInstance (
203 const ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext )
204 throw( com::sun::star::uno::Exception );
206 protected:
207 //------------------------------------------------------------------------------------
208 // OCommonPicker overridables
209 //------------------------------------------------------------------------------------
210 virtual SvtFileDialog* implCreateDialog( Window* _pParent );
211 virtual sal_Int16 implExecutePicker( );
212 virtual sal_Bool implHandleInitializationArgument(
213 const ::rtl::OUString& _rName,
214 const ::com::sun::star::uno::Any& _rValue
216 SAL_THROW( ( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) );
218 private:
219 WinBits getWinBits( WinBits& rExtraBits );
220 virtual void notify( sal_Int16 _nEventId, sal_Int16 _nControlId );
222 sal_Bool FilterNameExists( const ::rtl::OUString& rTitle );
223 sal_Bool FilterNameExists( const UnoFilterList& _rGroupedFilters );
225 void ensureFilterList( const ::rtl::OUString& _rInitialCurrentFilter );
227 void prepareExecute( );
229 DECL_LINK( DialogClosedHdl, Dialog* );
232 #endif // INCLUDED_SVT_FILEPICKER_HXX