sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak.docx  |binary
 sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak2.docx |binary
 sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak3.docx |binary
 sw/qa/extras/ooxmlexport/data/tdf153613_inlineAfterPgBreak.docx    |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx                         |   28 
++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx                       |    3 -
 6 files changed, 30 insertions(+), 1 deletion(-)

New commits:
commit 02444789bb5e59e2582fdb92a5852db9c6471eac
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Tue Feb 14 19:06:12 2023 -0500
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Wed Feb 15 19:19:39 2023 +0000

    tdf#153613 writerfilter: anchors ignore prior run with page break
    
    Although an image that is INLINE with the text DOES move
    to the following page when it is preceded by a w:br,
    an anchored image does not (when it is the last property
    in the paragraph).
    
    make CppunitTest_sw_ooxmlexport18 
CPPUNIT_TEST_NAME=testTdf153613_anchoredAfterPgBreak
    make CppunitTest_sw_ooxmlexport18 
CPPUNIT_TEST_NAME=testTdf153613_inlineAfterPgBreak
    
    I also tested with <w:t>x<</w:t> following the anchor
    and it already works correctly.
    make CppunitTest_sw_ooxmlexport18 
CPPUNIT_TEST_NAME=testTdf153613_anchoredAfterPgBreak2
    
    I also tested with <w:splitPgBreakAndParaMark/>
    and it already works correctly.
    make CppunitTest_sw_ooxmlexport18 
CPPUNIT_TEST_NAME=testTdf153613_anchoredAfterPgBreak3
    
    Change-Id: Ibf9c0d38c4dfe56db4e05416a40e3b7881693b17
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147032
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak.docx
new file mode 100644
index 000000000000..45010820867d
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak2.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak2.docx
new file mode 100644
index 000000000000..c29f8a49516b
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak2.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak3.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak3.docx
new file mode 100644
index 000000000000..5dd61ec7f409
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153613_anchoredAfterPgBreak3.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153613_inlineAfterPgBreak.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153613_inlineAfterPgBreak.docx
new file mode 100644
index 000000000000..6b25d6c70c1e
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf153613_inlineAfterPgBreak.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 8c2aa0c8a845..81267209e7bc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -121,6 +121,34 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf153592_columnBreaks)
     assertXPath(pXmlDoc, "//w:br", 2);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf153613_anchoredAfterPgBreak, 
"tdf153613_anchoredAfterPgBreak.docx")
+{
+    const auto& pLayout = parseLayoutDump();
+    // An anchored TO character image anchors before the page break.
+    assertXPath(pLayout, "//page[1]//anchored", 1);
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf153613_anchoredAfterPgBreak2, 
"tdf153613_anchoredAfterPgBreak2.docx")
+{
+    const auto& pLayout = parseLayoutDump();
+    // An anchored TO character image, followed by more characters moves to 
the following page
+    assertXPath(pLayout, "//page[2]//anchored", 1);
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf153613_anchoredAfterPgBreak3, 
"tdf153613_anchoredAfterPgBreak3.docx")
+{
+    const auto& pLayout = parseLayoutDump();
+    // An anchored TO character image, with setting splitPgBreakAndParaMark 
moves to the following page
+    assertXPath(pLayout, "//page[2]//anchored", 1);
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf153613_inlineAfterPgBreak, 
"tdf153613_inlineAfterPgBreak.docx")
+{
+    const auto& pLayout = parseLayoutDump();
+    // An inline AS character image moves to the following page when after the 
page break.
+    assertXPath(pLayout, "//page[2]//anchored", 1);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert)
 {
     // Given a docx document with a shape with vert="mongolianVert".
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 35dd9940a652..85d91fd454fe 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2519,7 +2519,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
         if ( m_pImpl->IsDiscardHeaderFooter() )
             break;
         //tdf112342: Break before images as well, if there are page break
-        if (m_pImpl->isBreakDeferred(BreakType::PAGE_BREAK))
+        if (m_pImpl->isBreakDeferred(BreakType::PAGE_BREAK)
+            && nSprmId == NS_ooxml::LN_inline_inline)
         {
             m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)
                 ->Insert(PROP_BREAK_TYPE, 
uno::Any(style::BreakType_PAGE_BEFORE));

Reply via email to