sw/qa/extras/ooxmlexport/data/tdf118701.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 18 ++++++++++++++++-- writerfilter/source/dmapper/DomainMapper.cxx | 5 +++-- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 22 +++++----------------- writerfilter/source/dmapper/DomainMapper_Impl.hxx | 5 ++++- 5 files changed, 28 insertions(+), 22 deletions(-)
New commits: commit 342afecbd35921e18dde4cfd29f27ca520d1b7a0 Author: László Németh <nem...@numbertext.org> AuthorDate: Fri Jul 10 18:52:42 2020 +0200 Commit: Gabor Kelemen <kelemen.gab...@nisz.hu> CommitDate: Tue Sep 15 14:00:54 2020 +0200 tdf#134793 DOCX import: fix numbering with inline images before page break. Previous fix for tdf#118701 didn't keep numbering of the paragraph marked for deletion. This reverts commit b216fc5b583050cfb1cdf9bd82ec3c1bd2e09d70 (tdf#118701 DOCX import: fix image position on page break). Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98541 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 616a47c9570f9ce67b18a124f08f4a342bff3468) Change-Id: I5bde927f15b4b1f682d81482734fadff7690f6d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102649 Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu> diff --git a/sw/qa/extras/ooxmlexport/data/tdf118701.docx b/sw/qa/extras/ooxmlexport/data/tdf118701.docx index 654a22709919..8fb26669d1fa 100644 Binary files a/sw/qa/extras/ooxmlexport/data/tdf118701.docx and b/sw/qa/extras/ooxmlexport/data/tdf118701.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index 8ec18a49eb4a..3d0f8f91a172 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -466,9 +466,23 @@ DECLARE_OOXMLIMPORT_TEST(TestTdf132483, "tdf132483.docx") text::RelOrientation::PAGE_FRAME , nHRelPos); } -DECLARE_OOXMLIMPORT_TEST(testTdf118701, "tdf118701.docx") +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf118701, "tdf118701.docx") { - CPPUNIT_ASSERT_EQUAL_MESSAGE("At least one paragraph is missing from the file!", 3, getParagraphs()); + // This was 6, related to moving inline images after the page breaks + CPPUNIT_ASSERT_EQUAL(4, getPages()); + + xmlDocPtr pXmlDoc = parseExport(); + + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr[1]/w:numPr", 0); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr[1]/w:numPr", 0); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr[1]/w:numPr", 0); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr[1]/w:numPr", 1); + + // Keep numbering of the paragraph of the inline image + assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:pPr[1]/w:numPr", 0); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr[1]/w:numPr", 1); + // This was 0 + assertXPath(pXmlDoc, "/w:document/w:body/w:p[10]/w:pPr[1]/w:numPr", 1); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 3339bb27e220..86ed6e3cfdb3 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3460,7 +3460,8 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) && !bSingleParagraphAfterRedline && !m_pImpl->GetIsDummyParaAddedForTableInSection() && !( pSectionContext && pSectionContext->GetBreakType() != -1 && pContext && pContext->isSet(PROP_BREAK_TYPE) ) - && !m_pImpl->GetIsPreviousParagraphFramed()); + && !m_pImpl->GetIsPreviousParagraphFramed() + && !m_pImpl->IsParaWithInlineObject()); const bool bNoNumbering = bRemove || (!m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr() && bSingleParagraph); PropertyMapPtr xContext = bNoNumbering ? m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH) : PropertyMapPtr(); @@ -3475,7 +3476,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) } m_pImpl->SetParaSectpr(false); finishParagraph(bRemove); - if (bRemove && m_pImpl->IsLastParaEmpty()) + if (bRemove) m_pImpl->RemoveLastParagraph(); } else diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index b77428a35f53..67ec8b869544 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -310,7 +310,8 @@ DomainMapper_Impl::DomainMapper_Impl( m_bParaHadField(false), m_bParaAutoBefore(false), m_bFirstParagraphInCell(true), - m_bSaveFirstParagraphInCell(false) + m_bSaveFirstParagraphInCell(false), + m_bParaWithInlineObject(false) { m_aBaseUrl = rMediaDesc.getUnpackedValueOrDefault( @@ -477,22 +478,6 @@ void DomainMapper_Impl::AddDummyParaForTableInSection() } } -bool DomainMapper_Impl::IsLastParaEmpty() -{ - bool bRet = true; - if (!m_aTextAppendStack.empty() && m_aTextAppendStack.top().xTextAppend) - { - //creating cursor for finding text content - uno::Reference<text::XTextCursor> xCursor = m_aTextAppendStack.top().xTextAppend->createTextCursor(); - xCursor->gotoEnd(false); - //selecting the last 2 characters in the document - xCursor->goLeft(2, true); - //the last paragraph is empty, if they are newlines - bRet = xCursor->getString().match(OUString(SAL_NEWLINE_STRING).concat(SAL_NEWLINE_STRING)); - } - return bRet; -} - void DomainMapper_Impl::RemoveLastParagraph( ) { if (m_bDiscardHeaderFooter) @@ -1884,6 +1869,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con m_bFirstParagraphInCell = false; m_bParaAutoBefore = false; + m_bParaWithInlineObject = false; #ifdef DBG_UTIL TagLogger::getInstance().endElement(); @@ -6239,6 +6225,8 @@ void DomainMapper_Impl::ImportGraphic(const writerfilter::Reference< Properties } m_aTextAppendStack.top().m_aAnchoredObjects.push_back(aInfo); } + else if (eGraphicImportType == IMPORT_AS_DETECTED_INLINE) + m_bParaWithInlineObject = true; } // Clear the reference, so in case the embedded object is inside a diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 9eef8dbee58d..fc6c3c5b5724 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -619,7 +619,6 @@ public: void RemoveDummyParaForTableInSection(); void AddDummyParaForTableInSection(); - bool IsLastParaEmpty(); void RemoveLastParagraph( ); void SetIsLastParagraphInSection( bool bIsLast ); bool GetIsLastParagraphInSection() const { return m_bIsLastParaInSection;} @@ -1057,6 +1056,8 @@ public: bool m_bIsActualParagraphFramed; std::vector<css::uno::Any> aFramedRedlines; + bool IsParaWithInlineObject() const { return m_bParaWithInlineObject; } + private: void PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType); // Start a new index section; if needed, finish current paragraph @@ -1070,6 +1071,8 @@ private: /// Current paragraph in a table is first paragraph of a cell bool m_bFirstParagraphInCell; bool m_bSaveFirstParagraphInCell; + /// Current paragraph had at least one inline object in it. + bool m_bParaWithInlineObject; }; } //namespace dmapper _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits