vcl/Library_vclplug_qt5.mk | 1 vcl/Library_vclplug_qt6.mk | 1 vcl/inc/qt5/QtFilePicker.hxx | 1 vcl/inc/qt5/QtInstanceWindow.hxx | 4 vcl/inc/qt5/QtXWindow.hxx | 28 ++++ vcl/inc/qt6/QtXWindow.hxx | 12 ++ vcl/qt5/QtFilePicker.cxx | 233 ++++++++++++++++++++------------------- vcl/qt5/QtInstanceWindow.cxx | 11 + vcl/qt5/QtXWindow.cxx | 24 ++++ vcl/qt6/QtXWindow.cxx | 12 ++ 10 files changed, 213 insertions(+), 114 deletions(-)
New commits: commit 429b08357e0c904d8096ff5830d844a199cd59b0 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Feb 21 23:48:47 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Feb 22 10:55:53 2025 +0100 tdf#130857 qt weld: Introduce QtXWindow Similar to how gtk3's SalGtkXWindow, introduce QtXWindow as a class implementing XWindow via the TransportAsXWindow subclass. Implement QtInstanceWindow::GetXWindow to return an instance of this new class. In QtFilePicker::initialize, extract the QWidget parent from the QtXWindow if the parent is one. This is used e.g. in a WIP branch adding support for the "Macro Security" dialog using native Qt widgets (SAL_VCL_QT_USE_WELDED_WIDGETS=1) in the following scenario to set the proper parent for the file dialog. * start Writer * "Tools" -> "Options" -> "Security" -> "Macro Security" * in the "Macro Security" dialog, switch to the "Trusted Sources" tab * Click on the "Add" button in the "Trusted File Locations" section to open a folder picker. Change-Id: I55637876c9b93bbbfb63459caba6c89dfd4188a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182024 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk index 1ef3fe6b1d77..c1c4ef31482b 100644 --- a/vcl/Library_vclplug_qt5.mk +++ b/vcl/Library_vclplug_qt5.mk @@ -149,6 +149,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\ vcl/qt5/QtVirtualDevice \ vcl/qt5/QtWidget \ vcl/qt5/QtXAccessible \ + vcl/qt5/QtXWindow \ $(if $(USING_X11), \ vcl/qt5/QtX11Support \ ) \ diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk index 17ee2027ee92..4e2060a616c0 100644 --- a/vcl/Library_vclplug_qt6.mk +++ b/vcl/Library_vclplug_qt6.mk @@ -148,6 +148,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\ vcl/qt6/QtVirtualDevice \ vcl/qt6/QtWidget \ vcl/qt6/QtXAccessible \ + vcl/qt6/QtXWindow \ $(if $(USING_X11), \ vcl/qt6/QtX11Support \ ) \ diff --git a/vcl/inc/qt5/QtInstanceWindow.hxx b/vcl/inc/qt5/QtInstanceWindow.hxx index 151e6d47e6ad..e22ec9a4cb76 100644 --- a/vcl/inc/qt5/QtInstanceWindow.hxx +++ b/vcl/inc/qt5/QtInstanceWindow.hxx @@ -10,13 +10,17 @@ #pragma once #include "QtInstanceContainer.hxx" +#include "QtXWindow.hxx" class QtInstanceWindow : public QtInstanceContainer, public virtual weld::Window { Q_OBJECT + rtl::Reference<QtXWindow> m_xWindow; + public: QtInstanceWindow(QWidget* pWidget); + virtual ~QtInstanceWindow(); virtual void set_title(const OUString& rTitle) override; virtual OUString get_title() const override; diff --git a/vcl/inc/qt5/QtXWindow.hxx b/vcl/inc/qt5/QtXWindow.hxx new file mode 100644 index 000000000000..680c2bac4510 --- /dev/null +++ b/vcl/inc/qt5/QtXWindow.hxx @@ -0,0 +1,28 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include "QtInstanceWidget.hxx" + +#include <vcl/weldutils.hxx> + +class QtXWindow final : public weld::TransportAsXWindow +{ + QWidget* m_pQWidget; + +public: + QtXWindow(QtInstanceWidget* pQtInstanceWindow); + + QWidget* getQWidget() { return m_pQWidget; } + + virtual void clear() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/qt6/QtXWindow.hxx b/vcl/inc/qt6/QtXWindow.hxx new file mode 100644 index 000000000000..a25210937d23 --- /dev/null +++ b/vcl/inc/qt6/QtXWindow.hxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../qt5/QtXWindow.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/qt5/QtFilePicker.cxx b/vcl/qt5/QtFilePicker.cxx index 03596fd419a2..8faec2311fc5 100644 --- a/vcl/qt5/QtFilePicker.cxx +++ b/vcl/qt5/QtFilePicker.cxx @@ -27,6 +27,7 @@ #include <QtTools.hxx> #include <QtWidget.hxx> #include <QtInstance.hxx> +#include <QtXWindow.hxx> #include <com/sun/star/awt/SystemDependentXWindow.hpp> #include <com/sun/star/awt/XSystemDependentWindowPeer.hpp> @@ -858,6 +859,12 @@ void SAL_CALL QtFilePicker::initialize(const uno::Sequence<uno::Any>& args) if (!xParentWindow.is()) return; + if (QtXWindow* pQtXWindow = dynamic_cast<QtXWindow*>(xParentWindow.get())) + { + m_pParentWidget = pQtXWindow->getQWidget(); + return; + } + css::uno::Reference<css::awt::XSystemDependentWindowPeer> xSysWinPeer(xParentWindow, css::uno::UNO_QUERY); if (!xSysWinPeer.is()) diff --git a/vcl/qt5/QtInstanceWindow.cxx b/vcl/qt5/QtInstanceWindow.cxx index 4d1cde125cfb..b90aed35fbfc 100644 --- a/vcl/qt5/QtInstanceWindow.cxx +++ b/vcl/qt5/QtInstanceWindow.cxx @@ -21,6 +21,12 @@ QtInstanceWindow::QtInstanceWindow(QWidget* pWidget) pWidget->installEventFilter(this); } +QtInstanceWindow::~QtInstanceWindow() +{ + if (m_xWindow.is()) + m_xWindow->clear(); +} + void QtInstanceWindow::set_title(const OUString& rTitle) { SolarMutexGuard g; @@ -181,8 +187,9 @@ OUString QtInstanceWindow::get_window_state(vcl::WindowDataMask eMask) const css::uno::Reference<css::awt::XWindow> QtInstanceWindow::GetXWindow() { - assert(false && "Not implemented yet"); - return css::uno::Reference<css::awt::XWindow>(); + if (!m_xWindow.is()) + m_xWindow.set(new QtXWindow(this)); + return m_xWindow; } SystemEnvData QtInstanceWindow::get_system_data() const diff --git a/vcl/qt5/QtXWindow.cxx b/vcl/qt5/QtXWindow.cxx new file mode 100644 index 000000000000..4e5cbcea65b6 --- /dev/null +++ b/vcl/qt5/QtXWindow.cxx @@ -0,0 +1,24 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <QtXWindow.hxx> + +QtXWindow::QtXWindow(QtInstanceWidget* pQtInstanceWindow) + : TransportAsXWindow(pQtInstanceWindow) + , m_pQWidget(pQtInstanceWindow->getQWidget()) +{ +} + +void QtXWindow::clear() +{ + m_pQWidget = nullptr; + TransportAsXWindow::clear(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/qt6/QtXWindow.cxx b/vcl/qt6/QtXWindow.cxx new file mode 100644 index 000000000000..01906891e2ce --- /dev/null +++ b/vcl/qt6/QtXWindow.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../qt5/QtXWindow.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ commit 6b389c157370e3482a9093f05c292fb9934b1b60 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Feb 21 23:11:46 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Feb 22 10:55:45 2025 +0100 tdf#130857 qt: Don't expect XFilePicker3 template in XFolderPicker2 init QtFilePicker implements both, the XFilePicker3 and the XFolderPicker2 interfaces. While a sal_Int16 specifying the TemplateDescription to use is passed to the initialize method in case of XFilePicker3 (s. FileDialogHelper_Impl::FileDialogHelper_Impl), that is not the case for XFolderPicker2 (s. sfx2::createFolderPicker, frame 2 in the below sample backtrace; a sal_Int32 with value 0 is passed there instead). However, QtFilePicker was always expecting it and throwing an IllegalArgumentException and thus not executing the rest of the initialize method (but the folder picker would still show up and work otherwise). This can for example be seen for the following scenario: * start Writer * "Tools" -> "Options" -> "Security" -> "Macro Security" * in the "Macro Security" dialog, switch to the "Trusted Sources" tab * Click on the "Add" button in the "Trusted File Locations" section to open a folder picker. This is a preexisting issue. But in an upcoming commit that implements QtInstanceWindow::GetXWindow and the use of native Qt widgets for that macro security dialog, the fact that the parent widget isn't set (which would only happen further down in QtFilePicker::initialize) would now have the practical implication that the file dialog isn't properly shown as modal and blocking the macro security dialog that is its parent. Fix this by no longer throwing an exception when the first arg is not a template ID, but simply make the code using it conditional on that and skip it otherwise. Also extract it to a new helper method QtFilePicker::applyTemplate for readability. (For comparison, note how for gtk3 the XFilePicker3 implementation in SalGtkFilePicker is separate from the XFolderPicker2 implementation in SalGtkFolderPicker and only the former tries to extract a template ID.) Sample backtrace: 1 QtFilePicker::initialize QtFilePicker.cxx 730 0x7fc196b45652 2 sfx2::createFolderPicker filedlghelper.cxx 1217 0x7fc1a6544781 3 MacroSecurityTrustedSourcesTP::AddLocPBHdl macrosecurity.cxx 303 0x7fc158926afc 4 MacroSecurityTrustedSourcesTP::LinkStubAddLocPBHdl macrosecurity.cxx 298 0x7fc158926a2d 5 Link<weld::Button&, void>::Call link.hxx 105 0x7fc1a1426331 6 weld::Button::signal_clicked weld.hxx 1558 0x7fc1a1401fdc 7 SalInstanceButton::ClickHdl salvtables.cxx 2955 0x7fc1a13d32b8 8 SalInstanceButton::LinkStubClickHdl salvtables.cxx 2943 0x7fc1a13d280d 9 Link<Button *, void>::Call link.hxx 105 0x7fc1a0cd5881 10 Button::Click()::$_0::operator()() const button.cxx 130 0x7fc1a0ccd082 11 std::__invoke_impl<void, Button::Click()::$_0&>(std::__invoke_other, Button::Click()::$_0&) invoke.h 61 0x7fc1a0ccd055 12 std::__invoke_r<void, Button::Click()::$_0&>(Button::Click()::$_0&) invoke.h 111 0x7fc1a0ccd005 13 std::_Function_handler<void(), Button::Click()::$_0>::_M_invoke std_function.h 290 0x7fc1a0cccf2d 14 std::function<void()>::operator() std_function.h 591 0x7fc1a0cf700e 15 Control::ImplCallEventListenersAndHandler ctrl.cxx 307 0x7fc1a0cf51cb 16 Button::Click button.cxx 130 0x7fc1a0cb98d8 17 PushButton::Tracking button.cxx 1321 0x7fc1a0cbf71b 18 vcl::Window::EndTracking window2.cxx 341 0x7fc1a0c6a763 19 ImplHandleMouseEvent winproc.cxx 713 0x7fc1a0ca4aae 20 ImplHandleSalMouseButtonUp winproc.cxx 2351 0x7fc1a0ca9041 21 ImplWindowFrameProc winproc.cxx 2700 0x7fc1a0ca7d55 22 SalFrame::CallCallback salframe.hxx 311 0x7fc196b6ebac 23 QtFrame::CallCallback QtFrame.hxx 235 0x7fc196b6bc05 24 QtWidget::handleMouseButtonEvent QtWidget.cxx 117 0x7fc196c7c5ca [...] Change-Id: I008cb851d1ec1f9383e0f1e4342a2bb2a05e5c41 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182023 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtFilePicker.hxx b/vcl/inc/qt5/QtFilePicker.hxx index 57e99890f61a..d52e98d8cbf8 100644 --- a/vcl/inc/qt5/QtFilePicker.hxx +++ b/vcl/inc/qt5/QtFilePicker.hxx @@ -167,6 +167,7 @@ private: QtFilePicker& operator=(const QtFilePicker&) = delete; static QString getResString(TranslateId pRedId); + void applyTemplate(sal_Int16 nTemplateId); static css::uno::Any handleGetListValue(const QComboBox* pWidget, sal_Int16 nControlAction); static void handleSetListValue(QComboBox* pQComboBox, sal_Int16 nAction, const css::uno::Any& rValue); diff --git a/vcl/qt5/QtFilePicker.cxx b/vcl/qt5/QtFilePicker.cxx index e97d8cb39608..03596fd419a2 100644 --- a/vcl/qt5/QtFilePicker.cxx +++ b/vcl/qt5/QtFilePicker.cxx @@ -603,6 +603,112 @@ QString QtFilePicker::getResString(TranslateId pResId) return aResString.replace('~', '&'); } +void QtFilePicker::applyTemplate(sal_Int16 nTemplateId) +{ + QFileDialog::AcceptMode acceptMode = QFileDialog::AcceptOpen; + switch (nTemplateId) + { + case FILEOPEN_SIMPLE: + break; + + case FILESAVE_SIMPLE: + acceptMode = QFileDialog::AcceptSave; + break; + + case FILESAVE_AUTOEXTENSION: + acceptMode = QFileDialog::AcceptSave; + addCustomControl(CHECKBOX_AUTOEXTENSION); + break; + + case FILESAVE_AUTOEXTENSION_PASSWORD: + acceptMode = QFileDialog::AcceptSave; + addCustomControl(CHECKBOX_AUTOEXTENSION); + addCustomControl(CHECKBOX_PASSWORD); + addCustomControl(CHECKBOX_GPGENCRYPTION); +#if HAVE_FEATURE_GPGME + addCustomControl(CHECKBOX_GPGSIGN); +#endif + break; + + case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS: + acceptMode = QFileDialog::AcceptSave; + addCustomControl(CHECKBOX_AUTOEXTENSION); + addCustomControl(CHECKBOX_PASSWORD); + addCustomControl(CHECKBOX_GPGENCRYPTION); +#if HAVE_FEATURE_GPGME + addCustomControl(CHECKBOX_GPGSIGN); +#endif + addCustomControl(CHECKBOX_FILTEROPTIONS); + break; + + case FILESAVE_AUTOEXTENSION_SELECTION: + acceptMode = QFileDialog::AcceptSave; + addCustomControl(CHECKBOX_AUTOEXTENSION); + addCustomControl(CHECKBOX_SELECTION); + break; + + case FILESAVE_AUTOEXTENSION_TEMPLATE: + acceptMode = QFileDialog::AcceptSave; + addCustomControl(CHECKBOX_AUTOEXTENSION); + addCustomControl(LISTBOX_TEMPLATE); + break; + + case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE: + addCustomControl(CHECKBOX_LINK); + addCustomControl(CHECKBOX_PREVIEW); + addCustomControl(LISTBOX_IMAGE_TEMPLATE); + break; + + case FILEOPEN_LINK_PREVIEW_IMAGE_ANCHOR: + addCustomControl(CHECKBOX_LINK); + addCustomControl(CHECKBOX_PREVIEW); + addCustomControl(LISTBOX_IMAGE_ANCHOR); + break; + + case FILEOPEN_PLAY: + addCustomControl(PUSHBUTTON_PLAY); + break; + + case FILEOPEN_LINK_PLAY: + addCustomControl(CHECKBOX_LINK); + addCustomControl(PUSHBUTTON_PLAY); + break; + + case FILEOPEN_READONLY_VERSION: + addCustomControl(CHECKBOX_READONLY); + addCustomControl(LISTBOX_VERSION); + break; + + case FILEOPEN_LINK_PREVIEW: + addCustomControl(CHECKBOX_LINK); + addCustomControl(CHECKBOX_PREVIEW); + break; + + case FILEOPEN_PREVIEW: + addCustomControl(CHECKBOX_PREVIEW); + break; + + default: + throw lang::IllegalArgumentException(u"Unknown template"_ustr, + static_cast<XFilePicker2*>(this), 1); + } + + TranslateId resId; + switch (acceptMode) + { + case QFileDialog::AcceptOpen: + resId = STR_FILEDLG_OPEN; + break; + case QFileDialog::AcceptSave: + resId = STR_FILEDLG_SAVE; + m_pFileDialog->setFileMode(QFileDialog::AnyFile); + break; + } + + m_pFileDialog->setAcceptMode(acceptMode); + m_pFileDialog->setWindowTitle(getResString(resId)); +} + void QtFilePicker::addCustomControl(sal_Int16 controlId) { QWidget* widget = nullptr; @@ -717,20 +823,10 @@ void QtFilePicker::addCustomControl(sal_Int16 controlId) void SAL_CALL QtFilePicker::initialize(const uno::Sequence<uno::Any>& args) { // parameter checking - uno::Any arg; if (args.getLength() == 0) throw lang::IllegalArgumentException(u"no arguments"_ustr, static_cast<XFilePicker2*>(this), 1); - arg = args[0]; - - if ((arg.getValueType() != cppu::UnoType<sal_Int16>::get()) - && (arg.getValueType() != cppu::UnoType<sal_Int8>::get())) - { - throw lang::IllegalArgumentException(u"invalid argument type"_ustr, - static_cast<XFilePicker2*>(this), 1); - } - SolarMutexGuard g; QtInstance& rQtInstance = GetQtInstance(); if (!rQtInstance.IsMainThread()) @@ -744,112 +840,18 @@ void SAL_CALL QtFilePicker::initialize(const uno::Sequence<uno::Any>& args) m_aTitleToFilterMap.clear(); m_aCurrentFilter.clear(); - sal_Int16 templateId = -1; - arg >>= templateId; - - QFileDialog::AcceptMode acceptMode = QFileDialog::AcceptOpen; - switch (templateId) - { - case FILEOPEN_SIMPLE: - break; - - case FILESAVE_SIMPLE: - acceptMode = QFileDialog::AcceptSave; - break; - - case FILESAVE_AUTOEXTENSION: - acceptMode = QFileDialog::AcceptSave; - addCustomControl(CHECKBOX_AUTOEXTENSION); - break; - - case FILESAVE_AUTOEXTENSION_PASSWORD: - acceptMode = QFileDialog::AcceptSave; - addCustomControl(CHECKBOX_AUTOEXTENSION); - addCustomControl(CHECKBOX_PASSWORD); - addCustomControl(CHECKBOX_GPGENCRYPTION); -#if HAVE_FEATURE_GPGME - addCustomControl(CHECKBOX_GPGSIGN); -#endif - break; - - case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS: - acceptMode = QFileDialog::AcceptSave; - addCustomControl(CHECKBOX_AUTOEXTENSION); - addCustomControl(CHECKBOX_PASSWORD); - addCustomControl(CHECKBOX_GPGENCRYPTION); -#if HAVE_FEATURE_GPGME - addCustomControl(CHECKBOX_GPGSIGN); -#endif - addCustomControl(CHECKBOX_FILTEROPTIONS); - break; - - case FILESAVE_AUTOEXTENSION_SELECTION: - acceptMode = QFileDialog::AcceptSave; - addCustomControl(CHECKBOX_AUTOEXTENSION); - addCustomControl(CHECKBOX_SELECTION); - break; - - case FILESAVE_AUTOEXTENSION_TEMPLATE: - acceptMode = QFileDialog::AcceptSave; - addCustomControl(CHECKBOX_AUTOEXTENSION); - addCustomControl(LISTBOX_TEMPLATE); - break; - - case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE: - addCustomControl(CHECKBOX_LINK); - addCustomControl(CHECKBOX_PREVIEW); - addCustomControl(LISTBOX_IMAGE_TEMPLATE); - break; - - case FILEOPEN_LINK_PREVIEW_IMAGE_ANCHOR: - addCustomControl(CHECKBOX_LINK); - addCustomControl(CHECKBOX_PREVIEW); - addCustomControl(LISTBOX_IMAGE_ANCHOR); - break; - - case FILEOPEN_PLAY: - addCustomControl(PUSHBUTTON_PLAY); - break; - - case FILEOPEN_LINK_PLAY: - addCustomControl(CHECKBOX_LINK); - addCustomControl(PUSHBUTTON_PLAY); - break; - - case FILEOPEN_READONLY_VERSION: - addCustomControl(CHECKBOX_READONLY); - addCustomControl(LISTBOX_VERSION); - break; - - case FILEOPEN_LINK_PREVIEW: - addCustomControl(CHECKBOX_LINK); - addCustomControl(CHECKBOX_PREVIEW); - break; - - case FILEOPEN_PREVIEW: - addCustomControl(CHECKBOX_PREVIEW); - break; - - default: - throw lang::IllegalArgumentException(u"Unknown template"_ustr, - static_cast<XFilePicker2*>(this), 1); - } + // handle template which is set in XFilePicker3, but not XFolderPicker2 initialization + uno::Any arg; + arg = args[0]; - TranslateId resId; - switch (acceptMode) + if ((arg.getValueType() == cppu::UnoType<sal_Int16>::get()) + || (arg.getValueType() == cppu::UnoType<sal_Int8>::get())) { - case QFileDialog::AcceptOpen: - resId = STR_FILEDLG_OPEN; - break; - case QFileDialog::AcceptSave: - resId = STR_FILEDLG_SAVE; - m_pFileDialog->setFileMode(QFileDialog::AnyFile); - break; + sal_Int16 templateId = -1; + arg >>= templateId; + applyTemplate(templateId); } - m_pFileDialog->setAcceptMode(acceptMode); - m_pFileDialog->setWindowTitle(getResString(resId)); - css::uno::Reference<css::awt::XWindow> xParentWindow; if (args.getLength() > 1) args[1] >>= xParentWindow;