diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-06-08 13:05:27 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-06-11 13:16:56 +0200 |
commit | d8169824a626877d721d929e43a7b6af64f3e679 (patch) | |
tree | af346448068b3ffc4b334f81ce7cd010c100df0c /writerfilter | |
parent | 1c59f8f696e845705641e420013f62a3dc1ab07c (diff) |
tdf#132596 writerfilter: fix paste of RTF with header/footer
The problem is that writerfilter inserts the content of header/footer
into the body text, but then DomainMapper_Impl::PopPageHeaderFooter()
calls RemoveLastParagraph() and deletes a body paragraph containing a
fieldmark, and then in Undo some SwHistoryTextFieldmark can't find it,
and since ffb26b81e1c7ff1d64959200247bb2edd5a569da this crashes.
This is because of the borked error handling in
DomainMapper_Impl::PushPageHeaderFooter(); the
m_xBodyText->createTextCursorByRange() call throws an exception that is
swallowed, so the m_aTextAppendStack doesn't have an entry containing
the position in the header.
To fix the error handling, set m_bDiscardHeaderFooter = false only when
everything was successful.
Also fix the call to be xText->createTextCursorByRange instead
(this is a regression from 232ad2f2588beff50cb5c1f3b689c581ba317583).
Then it turns out that Undo still crashes, because sw can't Undo
changes of header/footer content, so just return early unless it's
a new document.
Change-Id: Ie5aeb45447c5fbd4b3ae15c4cffb9800583a6d1d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95797
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
(cherry picked from commit 27151ccf2305eac4192f8c4ceeee267170096a19)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95824
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index d37082120bdd..61fa9bf80d45 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -2243,6 +2243,7 @@ void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::P const PropertyIds ePropTextLeft = bHeader? PROP_HEADER_TEXT_LEFT: PROP_FOOTER_TEXT_LEFT; const PropertyIds ePropText = bHeader? PROP_HEADER_TEXT: PROP_FOOTER_TEXT; + m_bDiscardHeaderFooter = true; m_eInHeaderFooterImport = bHeader ? HeaderFooterImportState::header : HeaderFooterImportState::footer; @@ -2256,6 +2257,11 @@ void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::P // content is not copied from the previous section pSectionContext->ClearHeaderFooterLinkToPrevious(bHeader, eType); + if (!m_bIsNewDoc) + { + return; // TODO sw cannot Undo insert header/footer without crashing + } + uno::Reference< beans::XPropertySet > xPageStyle = pSectionContext->GetPageStyle( *this, @@ -2283,15 +2289,15 @@ void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::P xPageStyle->getPropertyValue(getPropertyName(bLeft? ePropTextLeft: ePropText)) >>= xText; m_aTextAppendStack.push(TextAppendContext(uno::Reference< text::XTextAppend >(xText, uno::UNO_QUERY_THROW), - m_bIsNewDoc? uno::Reference<text::XTextCursor>(): m_xBodyText->createTextCursorByRange(xText->getStart()))); - } - else - { - m_bDiscardHeaderFooter = true; + m_bIsNewDoc + ? uno::Reference<text::XTextCursor>() + : xText->createTextCursorByRange(xText->getStart()))); + m_bDiscardHeaderFooter = false; // set only on success! } } catch( const uno::Exception& ) { + DBG_UNHANDLED_EXCEPTION("writerfilter.dmapper"); } } } |