Avoid potential negative array index access to cached text.
[LibreOffice.git] / writerperfect / source / writer / EPUBExportUIComponent.cxx
blob0e392ffe00ec374d109cad153bd75fc9fda623e1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include "EPUBExportUIComponent.hxx"
12 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
13 #include <comphelper/namedvaluecollection.hxx>
14 #include <cppuhelper/supportsservice.hxx>
15 #include <vcl/svapp.hxx>
17 #include "EPUBExportDialog.hxx"
19 using namespace com::sun::star;
21 namespace writerperfect
23 EPUBExportUIComponent::EPUBExportUIComponent(uno::Reference<uno::XComponentContext> xContext)
24 : mxContext(std::move(xContext))
28 uno::Sequence<beans::PropertyValue> EPUBExportUIComponent::getPropertyValues()
30 maMediaDescriptor["FilterData"] <<= maFilterData.getAsConstPropertyValueList();
31 return maMediaDescriptor.getAsConstPropertyValueList();
34 void EPUBExportUIComponent::setPropertyValues(
35 const uno::Sequence<beans::PropertyValue>& rProperties)
37 maMediaDescriptor.clear();
38 maMediaDescriptor << rProperties;
39 auto it = maMediaDescriptor.find("FilterData");
40 if (it != maMediaDescriptor.end())
42 uno::Sequence<beans::PropertyValue> aFilterData;
43 if (it->second >>= aFilterData)
45 maFilterData.clear();
46 maFilterData << aFilterData;
51 OUString EPUBExportUIComponent::getImplementationName()
53 return "com.sun.star.comp.Writer.EPUBExportUIComponent";
56 sal_Bool EPUBExportUIComponent::supportsService(const OUString& rServiceName)
58 return cppu::supportsService(this, rServiceName);
61 uno::Sequence<OUString> EPUBExportUIComponent::getSupportedServiceNames()
63 uno::Sequence<OUString> aRet = { OUString("com.sun.star.ui.dialogs.FilterOptionsDialog") };
64 return aRet;
67 void EPUBExportUIComponent::setTitle(const OUString& /*rTitle*/) {}
69 void SAL_CALL EPUBExportUIComponent::initialize(const uno::Sequence<uno::Any>& rArguments)
71 ::comphelper::NamedValueCollection aProperties(rArguments);
72 if (aProperties.has("ParentWindow"))
73 aProperties.get("ParentWindow") >>= mxDialogParent;
76 sal_Int16 EPUBExportUIComponent::execute()
78 SolarMutexGuard aGuard;
80 EPUBExportDialog aDialog(Application::GetFrameWeld(mxDialogParent), maFilterData, mxContext,
81 mxSourceDocument);
82 if (aDialog.run() == RET_OK)
83 return ui::dialogs::ExecutableDialogResults::OK;
84 return ui::dialogs::ExecutableDialogResults::CANCEL;
87 void SAL_CALL EPUBExportUIComponent::setSourceDocument(
88 const css::uno::Reference<css::lang::XComponent>& xDocument)
90 mxSourceDocument = xDocument;
93 void SAL_CALL EPUBExportUIComponent::setDialogTitle(const OUString& aTitle) { setTitle(aTitle); }
95 void SAL_CALL EPUBExportUIComponent::startExecuteModal(
96 const css::uno::Reference<css::ui::dialogs::XDialogClosedListener>& xListener)
98 SolarMutexGuard aSolarGuard;
100 if (!mxAsyncDialog)
102 if (mxSourceDocument.is())
103 mxAsyncDialog
104 = std::make_shared<EPUBExportDialog>(Application::GetFrameWeld(mxDialogParent),
105 maFilterData, mxContext, mxSourceDocument);
107 if (!mxAsyncDialog)
108 return;
111 weld::DialogController::runAsync(mxAsyncDialog, [xListener](sal_Int32 nResponse) {
112 css::ui::dialogs::DialogClosedEvent aEvent;
113 aEvent.DialogResult = nResponse;
114 xListener->dialogClosed(aEvent);
118 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
119 com_sun_star_comp_Writer_EPUBExportUIComponent_get_implementation(
120 uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
122 return cppu::acquire(new EPUBExportUIComponent(pCtx));
125 } // namespace writerperfect
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */