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