xref: /trunk/main/fpicker/source/aqua/SalAquaFilePicker.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 
24cdf0e10cSrcweir #ifndef _SALAQUAFILEPICKER_HXX_
25cdf0e10cSrcweir #define _SALAQUAFILEPICKER_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_______________________________________________________________________________________________________________________
28cdf0e10cSrcweir //  includes of other projects
29cdf0e10cSrcweir //_______________________________________________________________________________________________________________________
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <cppuhelper/compbase8.hxx>
32cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
34cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
35cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
36cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
37cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
38cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
39cdf0e10cSrcweir #include <com/sun/star/beans/StringPair.hpp>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #ifndef _SALAQUAPICKER_HXX_
42cdf0e10cSrcweir #include "SalAquaPicker.hxx"
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <memory>
46cdf0e10cSrcweir #include <list>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #ifndef _RTL_USTRING_H_
49cdf0e10cSrcweir #include <rtl/ustring.hxx>
50cdf0e10cSrcweir #endif
51cdf0e10cSrcweir #include "FilterHelper.hxx"
52cdf0e10cSrcweir #include "AquaFilePickerDelegate.hxx"
53cdf0e10cSrcweir 
54cdf0e10cSrcweir //----------------------------------------------------------
55cdf0e10cSrcweir // Implementation class for the XFilePicker Interface
56cdf0e10cSrcweir //----------------------------------------------------------
57cdf0e10cSrcweir 
58cdf0e10cSrcweir //----------------------------------------------------------
59cdf0e10cSrcweir // forward declarations
60cdf0e10cSrcweir //----------------------------------------------------------
61cdf0e10cSrcweir 
62cdf0e10cSrcweir using namespace rtl;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir //----------------------------------------------------------
65cdf0e10cSrcweir // class declaration
66cdf0e10cSrcweir //----------------------------------------------------------
67cdf0e10cSrcweir 
68cdf0e10cSrcweir class SalAquaFilePicker :
69cdf0e10cSrcweir     public SalAquaPicker,
70cdf0e10cSrcweir     public cppu::WeakComponentImplHelper8<
71cdf0e10cSrcweir     ::com::sun::star::ui::dialogs::XFilterManager,
72cdf0e10cSrcweir     ::com::sun::star::ui::dialogs::XFilterGroupManager,
73cdf0e10cSrcweir     ::com::sun::star::ui::dialogs::XFilePickerControlAccess,
74cdf0e10cSrcweir     ::com::sun::star::ui::dialogs::XFilePickerNotifier,
75cdf0e10cSrcweir     ::com::sun::star::lang::XInitialization,
76cdf0e10cSrcweir     ::com::sun::star::util::XCancellable,
77cdf0e10cSrcweir     ::com::sun::star::lang::XEventListener,
78cdf0e10cSrcweir     ::com::sun::star::lang::XServiceInfo >
79cdf0e10cSrcweir {
80cdf0e10cSrcweir public:
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     // constructor
83cdf0e10cSrcweir     SalAquaFilePicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceMgr );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     //------------------------------------------------------------------------------------
86cdf0e10cSrcweir     // XFilePickerNotifier
87cdf0e10cSrcweir     //------------------------------------------------------------------------------------
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     virtual void SAL_CALL addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener )
90cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
91cdf0e10cSrcweir     virtual void SAL_CALL removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener )
92cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     //------------------------------------------------------------------------------------
95cdf0e10cSrcweir     // XExecutableDialog functions
96cdf0e10cSrcweir     //------------------------------------------------------------------------------------
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     virtual void SAL_CALL setTitle( const ::rtl::OUString& aTitle )
99cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     virtual sal_Int16 SAL_CALL execute(  )
102cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     //------------------------------------------------------------------------------------
105cdf0e10cSrcweir     // XFilePicker functions
106cdf0e10cSrcweir     //------------------------------------------------------------------------------------
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode )
109cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     virtual void SAL_CALL setDefaultName( const ::rtl::OUString& aName )
112cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString& aDirectory )
115cdf0e10cSrcweir         throw( com::sun::star::lang::IllegalArgumentException,
116cdf0e10cSrcweir                ::com::sun::star::uno::RuntimeException );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getDisplayDirectory(  )
119cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles(  )
122cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     //------------------------------------------------------------------------------------
125cdf0e10cSrcweir     // XFilterManager functions
126cdf0e10cSrcweir     //------------------------------------------------------------------------------------
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     virtual void SAL_CALL appendFilter( const ::rtl::OUString& aTitle, const ::rtl::OUString& aFilter )
129cdf0e10cSrcweir         throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString& aTitle )
132cdf0e10cSrcweir         throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getCurrentFilter(  )
135cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     //------------------------------------------------------------------------------------
138cdf0e10cSrcweir     // XFilterGroupManager functions
139cdf0e10cSrcweir     //------------------------------------------------------------------------------------
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString& sGroupTitle, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair >& aFilters )
142cdf0e10cSrcweir         throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     //------------------------------------------------------------------------------------
145cdf0e10cSrcweir     // XFilePickerControlAccess functions
146cdf0e10cSrcweir     //------------------------------------------------------------------------------------
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     virtual void SAL_CALL setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const ::com::sun::star::uno::Any& aValue )
149cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 aControlId, sal_Int16 aControlAction )
152cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     virtual void SAL_CALL enableControl( sal_Int16 nControlId, sal_Bool bEnable )
155cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException );
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     virtual void SAL_CALL setLabel( sal_Int16 nControlId, const ::rtl::OUString& aLabel )
158cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 nControlId )
161cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     //------------------------------------------------
164cdf0e10cSrcweir     // XInitialization
165cdf0e10cSrcweir     //------------------------------------------------
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
168cdf0e10cSrcweir         throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     //------------------------------------------------
171cdf0e10cSrcweir     // XCancellable
172cdf0e10cSrcweir     //------------------------------------------------
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     virtual void SAL_CALL cancel( )
175cdf0e10cSrcweir         throw( ::com::sun::star::uno::RuntimeException );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     //------------------------------------------------
178cdf0e10cSrcweir     // XEventListener
179cdf0e10cSrcweir     //------------------------------------------------
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     using cppu::WeakComponentImplHelperBase::disposing;
182cdf0e10cSrcweir     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent )
183cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException);
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     //------------------------------------------------
186cdf0e10cSrcweir     // XServiceInfo
187cdf0e10cSrcweir     //------------------------------------------------
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName(  )
190cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException);
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
193cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException);
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
196cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException);
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     //------------------------------------------------------------------------------------
199cdf0e10cSrcweir     // FilePicker Event functions
200cdf0e10cSrcweir     //------------------------------------------------------------------------------------
201cdf0e10cSrcweir 
202cdf0e10cSrcweir    void SAL_CALL fileSelectionChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent );
203cdf0e10cSrcweir    void SAL_CALL directoryChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent );
204cdf0e10cSrcweir    // rtl::OUString SAL_CALL helpRequested( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ) const;
205cdf0e10cSrcweir    void SAL_CALL controlStateChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent );
206cdf0e10cSrcweir    void SAL_CALL dialogSizeChanged( );
207cdf0e10cSrcweir 
getDelegate()208cdf0e10cSrcweir    inline AquaFilePickerDelegate * getDelegate() {
209cdf0e10cSrcweir        return m_pDelegate;
210cdf0e10cSrcweir    }
211cdf0e10cSrcweir 
getSaveFileName()212cdf0e10cSrcweir    inline rtl::OUString getSaveFileName() {
213cdf0e10cSrcweir        return m_sSaveFileName;
214cdf0e10cSrcweir    }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir private:
217cdf0e10cSrcweir     // prevent copy and assignment
218cdf0e10cSrcweir     SalAquaFilePicker( const SalAquaFilePicker& );
219cdf0e10cSrcweir     SalAquaFilePicker& operator=( const SalAquaFilePicker& );
220cdf0e10cSrcweir 
221cdf0e10cSrcweir     virtual void ensureFilterHelper();
222cdf0e10cSrcweir 
223cdf0e10cSrcweir     // to instantiate own services
224cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceMgr;
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >
227cdf0e10cSrcweir     m_xListener;
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     FilterHelper *m_pFilterHelper;
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     rtl::OUString m_sSaveFileName;
232cdf0e10cSrcweir 
233cdf0e10cSrcweir     AquaFilePickerDelegate *m_pDelegate;
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     void updateFilterUI();
236cdf0e10cSrcweir     void updateSaveFileNameExtension();
237cdf0e10cSrcweir 
238cdf0e10cSrcweir public:
239cdf0e10cSrcweir 
240cdf0e10cSrcweir     virtual ~SalAquaFilePicker();
241cdf0e10cSrcweir 
242cdf0e10cSrcweir     void filterControlChanged();
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     void implInitialize();
245cdf0e10cSrcweir 
246cdf0e10cSrcweir };
247cdf0e10cSrcweir 
248cdf0e10cSrcweir #endif // _SALAQUAFILEPICKER_HXX_
249