[Libreoffice-commits] core.git: sw/qa writerfilter/source

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Mon Sep 7 15:41:39 UTC 2020


 sw/qa/extras/ooxmlexport/data/tdf135949_anchoredBeforeBreak.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx                       |    7 +++++++
 writerfilter/source/dmapper/DomainMapper.cxx                     |    1 +
 writerfilter/source/dmapper/DomainMapper_Impl.cxx                |    5 +++++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx                |    2 ++
 5 files changed, 15 insertions(+)

New commits:
commit 23b26103b3f79e578261fab7f11372c857c7de5e
Author:     Justin Luth <justin.luth at collabora.com>
AuthorDate: Fri Sep 4 19:11:51 2020 +0300
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Sep 7 17:40:59 2020 +0200

    tdf#135949 writerfilter: don't bRemove if anchoredObjects
    
    Surprised it took so long to find an example of an
    anchored object on the empty paragraph.
    
    I considered making a more useful function,
    but I didn't want to return a pointer,
    and my skills and understanding aren't good enough
    to intelligently return an empty vector reference,
    so I just left it as I first created it.
    
    It seems a bit silly to make a bool function
    just for this, but nothing returns anything
    that I wanted to use. So I just made a
    perfect-fit function for my unique need here.
    
    I would have preferred to create a potentially
    re-useable and flexible function...
    
    Change-Id: I8c2527403cd8059223d4bc610b10243656b1db3c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102060
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf135949_anchoredBeforeBreak.docx b/sw/qa/extras/ooxmlexport/data/tdf135949_anchoredBeforeBreak.docx
new file mode 100644
index 000000000000..6b61be383dab
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135949_anchoredBeforeBreak.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 95770433a6ab..2b49b47dbfd2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -389,6 +389,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf132149_pgBreak, "tdf132149_pgBreak.odt")
     //CPPUNIT_ASSERT(getXPathContent(pDump, "//page[5]/body/txt").startsWith("Lorem ipsum"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf135949_anchoredBeforeBreak, "tdf135949_anchoredBeforeBreak.docx")
+{
+    xmlDocUniquePtr pDump = parseLayoutDump();
+    //The picture was shown on page 2, because the empty paragraph before the page break was removed
+    assertXPath(pDump, "//page[1]/body/txt/anchored/fly", 1);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf129452_excessBorder, "tdf129452_excessBorder.docx")
 {
     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 38f8a493db09..b3faa5682ab6 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3511,6 +3511,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
                             && !m_pImpl->GetIsDummyParaAddedForTableInSection()
                             && !( pSectionContext && pSectionContext->GetBreakType() != -1 && pContext && pContext->isSet(PROP_BREAK_TYPE) )
                             && !m_pImpl->GetIsPreviousParagraphFramed()
+                            && !m_pImpl->HasTopAnchoredObjects()
                             && !m_pImpl->IsParaWithInlineObject());
 
             const bool bNoNumbering = bRemove || (!m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr() && bSingleParagraph);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 77d7ce21a0dd..e7b571de687b 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -734,6 +734,11 @@ FieldContextPtr const &  DomainMapper_Impl::GetTopFieldContext()
     return m_aFieldStack.back();
 }
 
+bool DomainMapper_Impl::HasTopAnchoredObjects() const
+{
+    return !m_aTextAppendStack.empty() && !m_aTextAppendStack.top().m_aAnchoredObjects.empty();
+}
+
 void DomainMapper_Impl::InitTabStopFromStyle( const uno::Sequence< style::TabStop >& rInitTabStops )
 {
     OSL_ENSURE(m_aCurrentTabStops.empty(), "tab stops already initialized");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 54a0f6c7ac25..33ec662c5feb 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -710,6 +710,8 @@ public:
     css::uno::Reference<css::text::XTextAppend> const & GetTopTextAppend();
     FieldContextPtr const & GetTopFieldContext();
 
+    bool HasTopAnchoredObjects() const;
+
     FontTablePtr const & GetFontTable()
     {
         if(!m_pFontTable)


More information about the Libreoffice-commits mailing list