summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/core/unocore/data/broken-embedded-object.odtbin0 -> 14360 bytes
-rw-r--r--sw/qa/core/unocore/unocore.cxx31
-rw-r--r--sw/source/core/unocore/unoframe.cxx20
3 files changed, 51 insertions, 0 deletions
diff --git a/sw/qa/core/unocore/data/broken-embedded-object.odt b/sw/qa/core/unocore/data/broken-embedded-object.odt
new file mode 100644
index 000000000000..94a0809235e9
--- /dev/null
+++ b/sw/qa/core/unocore/data/broken-embedded-object.odt
Binary files differ
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index a4a39489da60..a0cd7a253cba 100644
--- a/sw/qa/core/unocore/unocore.cxx
+++ b/sw/qa/core/unocore/unocore.cxx
@@ -31,6 +31,7 @@
#include <comphelper/propertyvalue.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/graphicfilter.hxx>
+#include <vcl/errinf.hxx>
#include <wrtsh.hxx>
#include <ndtxt.hxx>
@@ -108,6 +109,36 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, flyAtParaAnchor)
xText->insertTextContent(xAnchor, xFieldmark, false);
}
+/// Fails the test if an error popup would be presented.
+static void BasicDisplayErrorHandler(const OUString& /*rErr*/, const OUString& /*rAction*/)
+{
+ CPPUNIT_ASSERT(false);
+}
+
+CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testBrokenEmbeddedObject)
+{
+ // Given a document with a broken embedded object (the XML markup is not well-formed):
+ load(DATA_DIRECTORY, "broken-embedded-object.odt");
+ uno::Reference<text::XTextEmbeddedObjectsSupplier> xSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xObjects(xSupplier->getEmbeddedObjects(),
+ uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xObject(xObjects->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<lang::XServiceInfo> xEmbeddedObject;
+ // Get the property first, which initializes Draw, which would overwrite our error handler.
+ xObject->getPropertyValue("EmbeddedObject") >>= xEmbeddedObject;
+ ErrorRegistry::RegisterDisplay(&BasicDisplayErrorHandler);
+
+ // When trying to load that embedded object:
+ xObject->getPropertyValue("EmbeddedObject") >>= xEmbeddedObject;
+
+ // Then make sure we get a non-empty reference and an error popup it not shown:
+ CPPUNIT_ASSERT(xEmbeddedObject.is());
+ // Without the accompanying fix in place, we got this reference, but first an error popup was
+ // shown to the user.
+ CPPUNIT_ASSERT(
+ xEmbeddedObject->supportsService("com.sun.star.comp.embed.OCommonEmbeddedObject"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index a04ac6908b92..58801e2fb971 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -112,6 +112,7 @@
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <sal/log.hxx>
+#include <vcl/errinf.hxx>
#include <svx/unobrushitemhelper.hxx>
#include <svx/xbtmpit.hxx>
@@ -1958,9 +1959,28 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any&
throw uno::RuntimeException();
}
+namespace
+{
+/// Redirect error popups to developer warnings for the duration of the UNO API call.
+class DisplayLockGuard
+{
+ bool m_bLock;
+
+public:
+ DisplayLockGuard()
+ {
+ m_bLock = ErrorRegistry::GetLock();
+ ErrorRegistry::SetLock(true);
+ }
+
+ ~DisplayLockGuard() { ErrorRegistry::SetLock(m_bLock); }
+};
+}
+
uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName)
{
SolarMutexGuard aGuard;
+ DisplayLockGuard aDisplayGuard;
uno::Any aAny;
SwFrameFormat* pFormat = GetFrameFormat();
const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName(rPropertyName);