diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-03-12 12:43:10 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-03-25 14:35:46 +0100 |
commit | 0185241456971f06a7795fb4f304317027f50db9 (patch) | |
tree | 8cafdcb8db8449ad7e3abcbb7d530f094e544b6d /writerfilter | |
parent | 3d264dc8742733a797a3e315033851d0bda3bffd (diff) |
ofz#21168 sw,writerfilter: limit writerfilter hack to writerfilter
The problem is that at the end of WW8 import, a delete redline is
inserted that ends up calling DeleteAndJoin from inside
AppendRedline(). A fly is anchored AT_CHAR at (node 46, offset 0)
and the deletion goes from (node 46, offset 0) to
(node 48, offset 13) hence the special case check in
IsDestroyFrameAnchoredAtChar() for the IsInReading() prevents it
from being deleted, and then its anchor is still registered at the
node 46 when it gets deleted.
So try to restrict the WriterfilterHack to writerfilter, so it won't
affect WW8 import.
Unfortunately this is far less obvious than expected, because import can
happen for creating a new file, in which case it's all done via UNO in
writerfilter, or when inserting into an existing file, in which case
SwReader::Read() is used.
The SwDocShell's pMedium can't be used becuse in insert file case it
will be the loaded file, not the inserted file.
There isn't any obvious alternative to adding a silly UNO property for
the writerfilter to use.
Change-Id: Ia7fdc9bb1925202f6692ebee6e4b6b1fe50e5345
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90384
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit c4dab726caaa73be9f9c731312080143b0a0b89d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90951
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/filter/RtfFilter.cxx | 14 | ||||
-rw-r--r-- | writerfilter/source/filter/WriterFilter.cxx | 5 |
2 files changed, 19 insertions, 0 deletions
diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx index 3cb4b3579d65..d9e5aa27788e 100644 --- a/writerfilter/source/filter/RtfFilter.cxx +++ b/writerfilter/source/filter/RtfFilter.cxx @@ -19,6 +19,7 @@ #include <memory> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/document/XExporter.hpp> #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XImporter.hpp> @@ -98,6 +99,13 @@ sal_Bool RtfFilter::filter(const uno::Sequence< beans::PropertyValue >& rDescrip bool bResult(false); uno::Reference<task::XStatusIndicator> xStatusIndicator; + uno::Reference<beans::XPropertySet> xDocProps; + if (m_xDstDoc.is()) // not in cppunittest? + { + xDocProps.set(m_xDstDoc, uno::UNO_QUERY); + xDocProps->setPropertyValue("UndocumentedWriterfilterHack", uno::makeAny(true)); + } + try { utl::MediaDescriptor aMediaDesc(rDescriptor); @@ -159,6 +167,12 @@ sal_Bool RtfFilter::filter(const uno::Sequence< beans::PropertyValue >& rDescrip 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; diff --git a/writerfilter/source/filter/WriterFilter.cxx b/writerfilter/source/filter/WriterFilter.cxx index 266367b4ac2b..3b2405867aad 100644 --- a/writerfilter/source/filter/WriterFilter.cxx +++ b/writerfilter/source/filter/WriterFilter.cxx @@ -151,6 +151,8 @@ sal_Bool WriterFilter::filter(const uno::Sequence< beans::PropertyValue >& rDesc } if (m_xDstDoc.is()) { + uno::Reference<beans::XPropertySet> const xDocProps(m_xDstDoc, uno::UNO_QUERY); + xDocProps->setPropertyValue("UndocumentedWriterfilterHack", uno::makeAny(true)); utl::MediaDescriptor aMediaDesc(rDescriptor); bool bRepairStorage = aMediaDesc.getUnpackedValueOrDefault("RepairPackage", false); bool bSkipImages = aMediaDesc.getUnpackedValueOrDefault("FilterOptions", OUString()) == "SkipImages"; @@ -264,6 +266,9 @@ sal_Bool WriterFilter::filter(const uno::Sequence< beans::PropertyValue >& rDesc pStream.clear(); + // note: pStream.clear calls RemoveLastParagraph() + xDocProps->setPropertyValue("UndocumentedWriterfilterHack", uno::makeAny(false)); + return true; } return false; |