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 .
22 #include <cppuhelper/compbase.hxx>
23 #include <com/sun/star/lang/XInitialization.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
26 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
27 #include <com/sun/star/beans/StringPair.hpp>
29 #include "SalAquaPicker.hxx"
31 #include <rtl/ustring.hxx>
32 #include "FilterHelper.hxx"
33 #include "AquaFilePickerDelegate.hxx"
35 // Implementation class for the XFilePicker Interface
37 typedef ::cppu::WeakComponentImplHelper
<
38 css::ui::dialogs::XFilePicker3
,
39 css::ui::dialogs::XFilePickerControlAccess
,
40 css::lang::XInitialization
,
41 css::lang::XServiceInfo
> SalAquaFilePicker_Base
;
43 class SalAquaFilePicker
:
45 public SalAquaFilePicker_Base
52 // XFilePickerNotifier
54 virtual void SAL_CALL
addFilePickerListener( const css::uno::Reference
< css::ui::dialogs::XFilePickerListener
>& xListener
) override
;
55 virtual void SAL_CALL
removeFilePickerListener( const css::uno::Reference
< css::ui::dialogs::XFilePickerListener
>& xListener
) override
;
57 // XExecutableDialog functions
59 virtual void SAL_CALL
setTitle( const OUString
& aTitle
) override
;
61 virtual sal_Int16 SAL_CALL
execute( ) override
;
63 // XFilePicker functions
65 virtual void SAL_CALL
setMultiSelectionMode( sal_Bool bMode
) override
;
67 virtual void SAL_CALL
setDefaultName( const OUString
& aName
) override
;
69 virtual void SAL_CALL
setDisplayDirectory( const OUString
& aDirectory
) override
;
71 virtual OUString SAL_CALL
getDisplayDirectory( ) override
;
73 virtual css::uno::Sequence
< OUString
> SAL_CALL
getFiles( ) override
;
75 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSelectedFiles( ) override
;
77 // XFilterManager functions
79 virtual void SAL_CALL
appendFilter( const OUString
& aTitle
, const OUString
& aFilter
) override
;
81 virtual void SAL_CALL
setCurrentFilter( const OUString
& aTitle
) override
;
83 virtual OUString SAL_CALL
getCurrentFilter( ) override
;
85 // XFilterGroupManager functions
87 virtual void SAL_CALL
appendFilterGroup( const OUString
& sGroupTitle
, const css::uno::Sequence
< css::beans::StringPair
>& aFilters
) override
;
89 // XFilePickerControlAccess functions
91 virtual void SAL_CALL
setValue( sal_Int16 nControlId
, sal_Int16 nControlAction
, const css::uno::Any
& aValue
) override
;
93 virtual css::uno::Any SAL_CALL
getValue( sal_Int16 aControlId
, sal_Int16 aControlAction
) override
;
95 virtual void SAL_CALL
enableControl( sal_Int16 nControlId
, sal_Bool bEnable
) override
;
97 virtual void SAL_CALL
setLabel( sal_Int16 nControlId
, const OUString
& aLabel
) override
;
99 virtual OUString SAL_CALL
getLabel( sal_Int16 nControlId
) override
;
103 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
107 virtual void SAL_CALL
cancel( ) override
;
111 using cppu::WeakComponentImplHelperBase::disposing
;
112 /// @throws css::uno::RuntimeException
113 virtual void disposing( const css::lang::EventObject
& aEvent
);
117 virtual OUString SAL_CALL
getImplementationName( ) override
;
119 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
121 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
123 // FilePicker Event functions
125 void fileSelectionChanged( css::ui::dialogs::FilePickerEvent aEvent
);
126 void directoryChanged( css::ui::dialogs::FilePickerEvent aEvent
);
127 // OUString SAL_CALL helpRequested( css::ui::dialogs::FilePickerEvent aEvent ) const;
128 void controlStateChanged( css::ui::dialogs::FilePickerEvent aEvent
);
129 void dialogSizeChanged( );
131 AquaFilePickerDelegate
* getDelegate() {
135 OUString
const & getSaveFileName() {
136 return m_sSaveFileName
;
140 SalAquaFilePicker( const SalAquaFilePicker
& ) = delete;
141 SalAquaFilePicker
& operator=( const SalAquaFilePicker
& ) = delete;
143 virtual void ensureFilterHelper();
145 css::uno::Reference
< css::ui::dialogs::XFilePickerListener
> m_xListener
;
146 FilterHelper
*m_pFilterHelper
;
147 OUString m_sSaveFileName
;
148 AquaFilePickerDelegate
*m_pDelegate
;
150 void updateFilterUI();
151 void updateSaveFileNameExtension();
155 virtual ~SalAquaFilePicker() override
;
157 void filterControlChanged();
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */