summaryrefslogtreecommitdiff
path: root/writerfilter/source/filter/RtfFilter.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-03-30 21:10:33 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-03-31 09:05:58 +0200
commitc0f4bdcc7ca45e2920c676e5734353ba598bcdbc (patch)
tree6da051d851afda5ff79b1b91469a4acdd4b49431 /writerfilter/source/filter/RtfFilter.cxx
parent033b1d46653c30e44c1bbef5fff865db0f3c97d4 (diff)
RTF import: reset writerfilter bit even if the import fails
The old code did not handle when e.g. a lang::WrappedTargetRuntimeException is thrown between the set and unset. The DOCX import had the same problem. Change-Id: I7336d08057a875db985e8b647b320abd97c6eb81 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91381 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter/source/filter/RtfFilter.cxx')
-rw-r--r--writerfilter/source/filter/RtfFilter.cxx14
1 files changed, 8 insertions, 6 deletions
diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx
index cf1b31aeb016..bfa9a208786e 100644
--- a/writerfilter/source/filter/RtfFilter.cxx
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -35,6 +35,7 @@
#include <unotools/mediadescriptor.hxx>
#include <unotools/streamwrap.hxx>
#include <unotools/ucbstreamhelper.hxx>
+#include <comphelper/scopeguard.hxx>
#include <dmapper/DomainMapperFactory.hxx>
#include <rtftok/RTFDocument.hxx>
@@ -102,6 +103,13 @@ sal_Bool RtfFilter::filter(const uno::Sequence<beans::PropertyValue>& rDescripto
xDocProps.set(m_xDstDoc, uno::UNO_QUERY);
xDocProps->setPropertyValue("UndocumentedWriterfilterHack", uno::makeAny(true));
}
+ comphelper::ScopeGuard g([xDocProps] {
+ if (xDocProps.is()) // not in cppunittest?
+ {
+ // note: pStream.clear calls RemoveLastParagraph()
+ xDocProps->setPropertyValue("UndocumentedWriterfilterHack", uno::makeAny(false));
+ }
+ });
try
{
@@ -166,12 +174,6 @@ sal_Bool RtfFilter::filter(const uno::Sequence<beans::PropertyValue>& rDescripto
TOOLS_INFO_EXCEPTION("writerfilter", "Exception caught");
}
- if (m_xDstDoc.is()) // not in cppunittest?
- {
- // note: pStream.clear calls RemoveLastParagraph()
- xDocProps->setPropertyValue("UndocumentedWriterfilterHack", uno::makeAny(false));
- }
-
if (xStatusIndicator.is())
xStatusIndicator->end();
return bResult;