only use the form import object when it is a form component

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I38968a0834a044ceb068337fe1d96eb364739019
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/13698
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
(cherry picked from commit ed137476afd19a0324bf117fd315b751bfa920c9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211626
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Caolán McNamara
2026-10-02 09:53:08 +02:00
committed by Xisco Fauli
parent 0e705d4a0b
commit 4f3909125e
+8
View File
@@ -37,6 +37,7 @@
#include <com/sun/star/util/XCloneable.hpp> #include <com/sun/star/util/XCloneable.hpp>
#include <com/sun/star/util/Duration.hpp> #include <com/sun/star/util/Duration.hpp>
#include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/form/FormComponentType.hpp>
#include <com/sun/star/form/XFormComponent.hpp>
#include <com/sun/star/awt/ImagePosition.hpp> #include <com/sun/star/awt/ImagePosition.hpp>
#include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/beans/XPropertyContainer.hpp> #include <com/sun/star/beans/XPropertyContainer.hpp>
@@ -587,6 +588,13 @@ namespace xmloff
OStringBuffer("OElementImport::createElement: service factory gave me no object (service name: " + OStringBuffer("OElementImport::createElement: service factory gave me no object (service name: " +
OUStringToOString(m_sServiceName, RTL_TEXTENCODING_ASCII_US) + OUStringToOString(m_sServiceName, RTL_TEXTENCODING_ASCII_US) +
")!").getStr()); ")!").getStr());
// only use the created object when it is a form component
if (!Reference< XFormComponent >(xPure, UNO_QUERY).is())
{
SAL_WARN("xmloff.forms", "OElementImport::createElement: " << m_sServiceName
<< " is not a form component");
return xReturn;
}
xReturn.set(xPure, UNO_QUERY); xReturn.set(xPure, UNO_QUERY);
if (auto const props = Reference<css::beans::XPropertySet>(xPure, css::uno::UNO_QUERY)) if (auto const props = Reference<css::beans::XPropertySet>(xPure, css::uno::UNO_QUERY))
{ {