[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - writerfilter/source
Michael Stahl (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jun 9 12:44:22 UTC 2020
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
New commits:
commit e0e1c3bcc9445c177a4d97ba11639ae4f2f83163
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Jun 8 13:05:27 2020 +0200
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Tue Jun 9 14:43:49 2020 +0200
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 at cib.de>
(cherry picked from commit 7a5afa492a7233b36165b3aba2774a1b03cdefc6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95823
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 155105c466df..abde5e06db47 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2370,6 +2370,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;
@@ -2383,6 +2384,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,
@@ -2410,15 +2416,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");
}
}
}
More information about the Libreoffice-commits
mailing list