1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <cppuhelper/implbase5.hxx>
22 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
23 #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
24 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
25 #include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
26 #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/lang/XEventListener.hpp>
31 #include "commonpicker.hxx"
32 #include "pickercallbacks.hxx"
38 struct ElementEntry_Impl
;
39 enum class PickerFlags
;
41 typedef ::std::vector
< FilterEntry
> FilterList
; // can be maintained more effectively
42 typedef ::std::vector
< ElementEntry_Impl
> ElementList
;
44 typedef css::beans::StringPair UnoFilterEntry
;
45 typedef css::uno::Sequence
< UnoFilterEntry
> UnoFilterList
; // can be transported more effectively
47 // class SvtFilePicker ---------------------------------------------------
49 typedef ::cppu::ImplHelper5
< css::ui::dialogs::XFilePicker3
50 , css::ui::dialogs::XFilePickerControlAccess
51 , css::ui::dialogs::XFilePreview
52 , css::lang::XServiceInfo
53 , css::ui::dialogs::XAsynchronousExecutableDialog
56 class SvtFilePicker
:public SvtFilePicker_Base
57 ,public ::svt::OCommonPicker
58 ,public ::svt::IFilePickerListener
61 std::unique_ptr
<FilterList
>
63 std::unique_ptr
<ElementList
>
66 bool m_bMultiSelection
;
67 sal_Int16 m_nServiceType
;
68 OUString m_aDefaultName
;
69 OUString m_aCurrentFilter
;
71 OUString m_aOldDisplayDirectory
;
72 OUString m_aOldHideDirectory
;
74 OUString m_aStandardDir
;
75 css::uno::Sequence
< OUString
>
78 css::uno::Reference
< css::ui::dialogs::XFilePickerListener
>
80 css::uno::Reference
< css::ui::dialogs::XDialogClosedListener
>
85 virtual ~SvtFilePicker() override
;
88 // disambiguate XInterface
93 // disambiguate XTypeProvider
95 DECLARE_XTYPEPROVIDER( )
98 // XExecutableDialog functions
100 virtual void SAL_CALL
setTitle( const OUString
& _rTitle
) override
;
101 virtual sal_Int16 SAL_CALL
execute( ) override
;
104 // XAsynchronousExecutableDialog functions
106 virtual void SAL_CALL
setDialogTitle( const OUString
& _rTitle
) override
;
107 virtual void SAL_CALL
startExecuteModal( const css::uno::Reference
< css::ui::dialogs::XDialogClosedListener
>& xListener
) override
;
110 // XFilePicker functions
113 virtual void SAL_CALL
setMultiSelectionMode( sal_Bool bMode
) override
;
114 virtual void SAL_CALL
setDefaultName( const OUString
& aName
) override
;
115 virtual void SAL_CALL
setDisplayDirectory( const OUString
& aDirectory
) override
;
116 virtual OUString SAL_CALL
getDisplayDirectory() override
;
117 virtual css::uno::Sequence
< OUString
> SAL_CALL
getFiles() override
;
118 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSelectedFiles() override
;
121 // XFilePickerControlAccess functions
124 virtual void SAL_CALL
setValue( sal_Int16 ElementID
, sal_Int16 ControlAction
, const css::uno::Any
& value
) override
;
125 virtual css::uno::Any SAL_CALL
getValue( sal_Int16 ElementID
, sal_Int16 ControlAction
) override
;
126 virtual void SAL_CALL
setLabel( sal_Int16 ElementID
, const OUString
& aValue
) override
;
127 virtual OUString SAL_CALL
getLabel( sal_Int16 ElementID
) override
;
128 virtual void SAL_CALL
enableControl( sal_Int16 ElementID
, sal_Bool bEnable
) override
;
131 // XFilePickerNotifier functions
134 virtual void SAL_CALL
addFilePickerListener( const css::uno::Reference
< css::ui::dialogs::XFilePickerListener
>& xListener
) override
;
135 virtual void SAL_CALL
removeFilePickerListener( const css::uno::Reference
< css::ui::dialogs::XFilePickerListener
>& xListener
) override
;
138 // XFilePreview functions
141 virtual css::uno::Sequence
< sal_Int16
> SAL_CALL
getSupportedImageFormats() override
;
142 virtual sal_Int32 SAL_CALL
getTargetColorDepth() override
;
143 virtual sal_Int32 SAL_CALL
getAvailableWidth() override
;
144 virtual sal_Int32 SAL_CALL
getAvailableHeight() override
;
145 virtual void SAL_CALL
setImage( sal_Int16 aImageFormat
, const css::uno::Any
& aImage
) override
;
146 virtual sal_Bool SAL_CALL
setShowState( sal_Bool bShowState
) override
;
147 virtual sal_Bool SAL_CALL
getShowState() override
;
150 // XFilterManager functions
153 virtual void SAL_CALL
appendFilter( const OUString
& aTitle
, const OUString
& aFilter
) override
;
154 virtual void SAL_CALL
setCurrentFilter( const OUString
& aTitle
) override
;
155 virtual OUString SAL_CALL
getCurrentFilter() override
;
158 // XFilterGroupManager functions
160 virtual void SAL_CALL
appendFilterGroup( const OUString
& sGroupTitle
, const css::uno::Sequence
< css::beans::StringPair
>& aFilters
) override
;
163 // these methods are here because they're ambiguous
165 virtual void SAL_CALL
cancel() override
166 { ::svt::OCommonPicker::cancel(); }
167 virtual void SAL_CALL
dispose() override
168 { ::svt::OCommonPicker::dispose(); }
169 virtual void SAL_CALL
addEventListener(const css::uno::Reference
<css::lang::XEventListener
>& l
) override
170 { ::svt::OCommonPicker::addEventListener(l
); }
171 virtual void SAL_CALL
removeEventListener(const css::uno::Reference
<css::lang::XEventListener
>& l
) override
172 { ::svt::OCommonPicker::removeEventListener(l
); }
175 // XInitialization functions
178 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
181 // XServiceInfo functions
185 virtual OUString SAL_CALL
getImplementationName() override
;
186 virtual sal_Bool SAL_CALL
supportsService( const OUString
& sServiceName
) override
;
187 virtual css::uno::Sequence
< OUString
> SAL_CALL
188 getSupportedServiceNames() override
;
192 // OCommonPicker overridables
194 virtual std::shared_ptr
<SvtFileDialog_Base
> implCreateDialog( weld::Window
* pParent
) override
;
195 virtual sal_Int16
implExecutePicker( ) override
;
196 virtual bool implHandleInitializationArgument(
197 const OUString
& _rName
,
198 const css::uno::Any
& _rValue
202 PickerFlags
getPickerFlags() const;
203 virtual void notify( sal_Int16 _nEventId
, sal_Int16 _nControlId
) override
;
205 bool FilterNameExists( const OUString
& rTitle
);
206 bool FilterNameExists( const UnoFilterList
& _rGroupedFilters
);
208 void ensureFilterList( const OUString
& _rInitialCurrentFilter
);
210 void prepareExecute( );
212 void DialogClosedHdl(sal_Int32 nResult
);
215 // SvtRemoteFilePicker
217 class SvtRemoteFilePicker
: public SvtFilePicker
220 SvtRemoteFilePicker();
222 virtual std::shared_ptr
<SvtFileDialog_Base
> implCreateDialog( weld::Window
* pParent
) override
;
224 // disambiguate XInterface
226 DECLARE_XINTERFACE( )
228 // disambiguate XTypeProvider
230 DECLARE_XTYPEPROVIDER( )
233 virtual OUString SAL_CALL
getImplementationName() override
;
234 virtual sal_Bool SAL_CALL
supportsService( const OUString
& sServiceName
) override
;
235 virtual css::uno::Sequence
< OUString
> SAL_CALL
236 getSupportedServiceNames() override
;
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */