xref: /trunk/main/fpicker/source/office/OfficeFilePicker.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*10ce8018SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*10ce8018SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*10ce8018SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*10ce8018SAndrew Rist  * distributed with this work for additional information
6*10ce8018SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*10ce8018SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*10ce8018SAndrew Rist  * "License"); you may not use this file except in compliance
9*10ce8018SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*10ce8018SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*10ce8018SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*10ce8018SAndrew Rist  * software distributed under the License is distributed on an
15*10ce8018SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*10ce8018SAndrew Rist  * KIND, either express or implied.  See the License for the
17*10ce8018SAndrew Rist  * specific language governing permissions and limitations
18*10ce8018SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*10ce8018SAndrew Rist  *************************************************************/
21*10ce8018SAndrew Rist 
22*10ce8018SAndrew Rist 
23cdf0e10cSrcweir #ifndef INCLUDED_SVT_FILEPICKER_HXX
24cdf0e10cSrcweir #define INCLUDED_SVT_FILEPICKER_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <cppuhelper/implbase7.hxx>
27cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
28cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
29cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
30cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
31cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
32cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
33cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
34cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
35cdf0e10cSrcweir #include <com/sun/star/lang/XEventListener.hpp>
36cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_XCOMPONENT_CONTEXT_HPP_
37cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <tools/wintypes.hxx>
42cdf0e10cSrcweir #include "commonpicker.hxx"
43cdf0e10cSrcweir #include "pickercallbacks.hxx"
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <list>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir class Dialog;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir struct FilterEntry;
50cdf0e10cSrcweir struct ElementEntry_Impl;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir typedef ::std::list< FilterEntry >                          FilterList;     // can be maintained more effectively
53cdf0e10cSrcweir typedef ::std::list < ElementEntry_Impl >                   ElementList;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir typedef ::com::sun::star::beans::StringPair                 UnoFilterEntry;
56cdf0e10cSrcweir typedef ::com::sun::star::uno::Sequence< UnoFilterEntry >   UnoFilterList;  // can be transported more effectively
57cdf0e10cSrcweir typedef ::com::sun::star::uno::Sequence< ::rtl::OUString >  OUStringList;   // can be transported more effectively
58cdf0e10cSrcweir 
59cdf0e10cSrcweir // class SvtFilePicker ---------------------------------------------------
60cdf0e10cSrcweir 
61cdf0e10cSrcweir typedef ::cppu::ImplHelper7 <   ::com::sun::star::ui::dialogs::XFilePickerControlAccess
62cdf0e10cSrcweir                             ,   ::com::sun::star::ui::dialogs::XFilePickerNotifier
63cdf0e10cSrcweir                             ,   ::com::sun::star::ui::dialogs::XFilePreview
64cdf0e10cSrcweir                             ,   ::com::sun::star::ui::dialogs::XFilterManager
65cdf0e10cSrcweir                             ,   ::com::sun::star::ui::dialogs::XFilterGroupManager
66cdf0e10cSrcweir                             ,   ::com::sun::star::lang::XServiceInfo
67cdf0e10cSrcweir                             ,   ::com::sun::star::ui::dialogs::XAsynchronousExecutableDialog
68cdf0e10cSrcweir                             >   SvtFilePicker_Base;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir class SvtFilePicker :public SvtFilePicker_Base
71cdf0e10cSrcweir                     ,public ::svt::OCommonPicker
72cdf0e10cSrcweir                     ,public ::svt::IFilePickerListener
73cdf0e10cSrcweir {
74cdf0e10cSrcweir private:
75cdf0e10cSrcweir     FilterList*         m_pFilterList;
76cdf0e10cSrcweir     ElementList*        m_pElemList;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     sal_Bool            m_bMultiSelection;
79cdf0e10cSrcweir     sal_Int16           m_nServiceType;
80cdf0e10cSrcweir     ::rtl::OUString     m_aDefaultName;
81cdf0e10cSrcweir     ::rtl::OUString     m_aCurrentFilter;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     // #97148# --------------
84cdf0e10cSrcweir     ::rtl::OUString     m_aOldDisplayDirectory;
85cdf0e10cSrcweir     ::rtl::OUString     m_aOldHideDirectory;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     ::rtl::OUString     m_aStandardDir;
88cdf0e10cSrcweir     OUStringList        m_aBlackList;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >
91cdf0e10cSrcweir                         m_xListener;
92cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener >
93cdf0e10cSrcweir                         m_xDlgClosedListener;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir public:
96cdf0e10cSrcweir                        SvtFilePicker( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& xFactory );
97cdf0e10cSrcweir     virtual           ~SvtFilePicker();
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     //------------------------------------------------------------------------------------
100cdf0e10cSrcweir     // disambiguate XInterface
101cdf0e10cSrcweir     //------------------------------------------------------------------------------------
102cdf0e10cSrcweir     DECLARE_XINTERFACE( )
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     //------------------------------------------------------------------------------------
105cdf0e10cSrcweir     // disambiguate XTypeProvider
106cdf0e10cSrcweir     //------------------------------------------------------------------------------------
107cdf0e10cSrcweir     DECLARE_XTYPEPROVIDER( )
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     //------------------------------------------------------------------------------------
110cdf0e10cSrcweir     // XExecutableDialog functions
111cdf0e10cSrcweir     //------------------------------------------------------------------------------------
112cdf0e10cSrcweir     virtual void SAL_CALL setTitle( const ::rtl::OUString& _rTitle ) throw (::com::sun::star::uno::RuntimeException);
113cdf0e10cSrcweir     virtual sal_Int16 SAL_CALL execute(  ) throw (::com::sun::star::uno::RuntimeException);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     //------------------------------------------------------------------------------------
116cdf0e10cSrcweir     // XAsynchronousExecutableDialog functions
117cdf0e10cSrcweir     //------------------------------------------------------------------------------------
118cdf0e10cSrcweir     virtual void SAL_CALL setDialogTitle( const ::rtl::OUString& _rTitle ) throw (::com::sun::star::uno::RuntimeException);
119cdf0e10cSrcweir     virtual void SAL_CALL startExecuteModal( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     //------------------------------------------------------------------------------------
122cdf0e10cSrcweir     // XFilePicker functions
123cdf0e10cSrcweir     //------------------------------------------------------------------------------------
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     virtual void SAL_CALL           setMultiSelectionMode( sal_Bool bMode ) throw( ::com::sun::star::uno::RuntimeException );
126cdf0e10cSrcweir     virtual void SAL_CALL           setDefaultName( const ::rtl::OUString& aName ) throw( ::com::sun::star::uno::RuntimeException );
127cdf0e10cSrcweir     virtual void SAL_CALL           setDisplayDirectory( const ::rtl::OUString& aDirectory ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
128cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL    getDisplayDirectory() throw( ::com::sun::star::uno::RuntimeException );
129cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles() throw( ::com::sun::star::uno::RuntimeException );
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     //------------------------------------------------------------------------------------
132cdf0e10cSrcweir     // XFilePickerControlAccess functions
133cdf0e10cSrcweir     //------------------------------------------------------------------------------------
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     virtual void SAL_CALL           setValue( sal_Int16 ElementID, sal_Int16 ControlAction, const com::sun::star::uno::Any& value ) throw( ::com::sun::star::uno::RuntimeException );
136cdf0e10cSrcweir     virtual com::sun::star::uno::Any SAL_CALL           getValue( sal_Int16 ElementID, sal_Int16 ControlAction ) throw( ::com::sun::star::uno::RuntimeException );
137cdf0e10cSrcweir     virtual void SAL_CALL           setLabel( sal_Int16 ElementID, const ::rtl::OUString& aValue ) throw ( ::com::sun::star::uno::RuntimeException );
138cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL    getLabel( sal_Int16 ElementID ) throw ( ::com::sun::star::uno::RuntimeException );
139cdf0e10cSrcweir     virtual void SAL_CALL           enableControl( sal_Int16 ElementID, sal_Bool bEnable ) throw( ::com::sun::star::uno::RuntimeException );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     //------------------------------------------------------------------------------------
142cdf0e10cSrcweir     // XFilePickerNotifier functions
143cdf0e10cSrcweir     //------------------------------------------------------------------------------------
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     virtual void SAL_CALL           addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw ( ::com::sun::star::uno::RuntimeException );
146cdf0e10cSrcweir     virtual void SAL_CALL           removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw ( ::com::sun::star::uno::RuntimeException );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     //------------------------------------------------------------------------------------
149cdf0e10cSrcweir     // XFilePreview functions
150cdf0e10cSrcweir     //------------------------------------------------------------------------------------
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats() throw ( ::com::sun::star::uno::RuntimeException );
153cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL      getTargetColorDepth() throw ( ::com::sun::star::uno::RuntimeException );
154cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL      getAvailableWidth() throw ( ::com::sun::star::uno::RuntimeException );
155cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL      getAvailableHeight() throw ( ::com::sun::star::uno::RuntimeException );
156cdf0e10cSrcweir     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 );
157cdf0e10cSrcweir     virtual sal_Bool SAL_CALL       setShowState( sal_Bool bShowState ) throw ( ::com::sun::star::uno::RuntimeException );
158cdf0e10cSrcweir     virtual sal_Bool SAL_CALL       getShowState() throw ( ::com::sun::star::uno::RuntimeException );
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     //------------------------------------------------------------------------------------
161cdf0e10cSrcweir     // XFilterManager functions
162cdf0e10cSrcweir     //------------------------------------------------------------------------------------
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     virtual void SAL_CALL           appendFilter( const ::rtl::OUString& aTitle, const ::rtl::OUString& aFilter ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
165cdf0e10cSrcweir     virtual void SAL_CALL           setCurrentFilter( const ::rtl::OUString& aTitle ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
166cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL    getCurrentFilter() throw( ::com::sun::star::uno::RuntimeException );
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     //------------------------------------------------------------------------------------
169cdf0e10cSrcweir     // XFilterGroupManager functions
170cdf0e10cSrcweir     //------------------------------------------------------------------------------------
171cdf0e10cSrcweir     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);
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     //------------------------------------------------------------------------------------
174cdf0e10cSrcweir     // XInitialization functions
175cdf0e10cSrcweir     //------------------------------------------------------------------------------------
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     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 );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     //------------------------------------------------------------------------------------
180cdf0e10cSrcweir     // XServiceInfo functions
181cdf0e10cSrcweir     //------------------------------------------------------------------------------------
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     /* XServiceInfo */
184cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL    getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
185cdf0e10cSrcweir     virtual sal_Bool SAL_CALL       supportsService( const ::rtl::OUString& sServiceName ) throw( ::com::sun::star::uno::RuntimeException );
186cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
187cdf0e10cSrcweir                                     getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     /* Helper for XServiceInfo */
190cdf0e10cSrcweir     static com::sun::star::uno::Sequence< ::rtl::OUString >
191cdf0e10cSrcweir                                     impl_getStaticSupportedServiceNames();
192cdf0e10cSrcweir     static ::rtl::OUString          impl_getStaticImplementationName();
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     /* Helper for registry */
195cdf0e10cSrcweir     static ::com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL impl_createInstance (
196cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext )
197cdf0e10cSrcweir         throw( com::sun::star::uno::Exception );
198cdf0e10cSrcweir 
199cdf0e10cSrcweir protected:
200cdf0e10cSrcweir     //------------------------------------------------------------------------------------
201cdf0e10cSrcweir     // OCommonPicker overridables
202cdf0e10cSrcweir     //------------------------------------------------------------------------------------
203cdf0e10cSrcweir     virtual SvtFileDialog*  implCreateDialog( Window* _pParent );
204cdf0e10cSrcweir     virtual sal_Int16       implExecutePicker( );
205cdf0e10cSrcweir     virtual sal_Bool        implHandleInitializationArgument(
206cdf0e10cSrcweir                                 const ::rtl::OUString& _rName,
207cdf0e10cSrcweir                                 const ::com::sun::star::uno::Any& _rValue
208cdf0e10cSrcweir                             )
209cdf0e10cSrcweir                             SAL_THROW( ( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ) );
210cdf0e10cSrcweir 
211cdf0e10cSrcweir private:
212cdf0e10cSrcweir     WinBits             getWinBits( WinBits& rExtraBits );
213cdf0e10cSrcweir     virtual void        notify( sal_Int16 _nEventId, sal_Int16 _nControlId );
214cdf0e10cSrcweir 
215cdf0e10cSrcweir     sal_Bool            FilterNameExists( const ::rtl::OUString& rTitle );
216cdf0e10cSrcweir     sal_Bool            FilterNameExists( const UnoFilterList& _rGroupedFilters );
217cdf0e10cSrcweir 
218cdf0e10cSrcweir     void                ensureFilterList( const ::rtl::OUString& _rInitialCurrentFilter );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     void                prepareExecute( );
221cdf0e10cSrcweir 
222cdf0e10cSrcweir     DECL_LINK(          DialogClosedHdl, Dialog* );
223cdf0e10cSrcweir };
224cdf0e10cSrcweir 
225cdf0e10cSrcweir #endif // INCLUDED_SVT_FILEPICKER_HXX
226