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

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Wed Nov 4 07:17:15 UTC 2020


 sw/qa/extras/ooxmlimport/data/tdf136952_pgBreak3.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx              |   14 ++++++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx          |    2 +-
 3 files changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 0b8c7a94c6c4b1aa10c7ae0a614d0f1f6cba1002
Author:     Justin Luth <justin.luth at collabora.com>
AuthorDate: Tue Sep 22 17:30:02 2020 +0300
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Nov 4 08:16:39 2020 +0100

    tdf#136952 writerfilter: PageBreakBefore - don't always overwrite
    
    There can be a number of things that can set PROP_BREAK_TYPE,
    and thus an un-inheriting value of PageBreakBefore should not
    cancel a w:br for example.
    
    There are two ways to approach this. One would be to never
    overwrite, and that should be safe in practice, since I don't
    see anywhere else that would specify a NONE value.
    
    However, if PageBreakBefore is true, it ought to override
    a theoretical NONE, or potential COLUMN break I would assume,
    so in that case a "yes" page break should probably override,
    but a "no" page break should not. Basically, if anything
    specifically requests a page break, they should get it.
    
    (Actually, I'm not sure how, but column and textWrapping
    breaks seem not to be affected by this - which is good.
    Only the page break seemed to be lost when PageBreakBefore=false.
    I tested by changing the w:br type to column,
    textWrapping, and the invalid value of none.)
    
    NOTE: If there is both a w:br and a PageBreakBefore=true,
    then MSWord 2003 treats both as a valid page break,
    but neither Word 2010 nor 2016 add the empty page.
    See bug report for two proof unit tests.
    
    Change-Id: I279874c60cc4cc572e0d190dc2afad0ad3431c43
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103223
    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/ooxmlimport/data/tdf136952_pgBreak3.docx b/sw/qa/extras/ooxmlimport/data/tdf136952_pgBreak3.docx
new file mode 100644
index 000000000000..3f3c1d37d5c3
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf136952_pgBreak3.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 91029dae7a1d..ec680a69a6ad 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1706,6 +1706,20 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108714, "tdf108714.docx")
     CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, breakType);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf136952_pgBreak3, "tdf136952_pgBreak3.docx")
+{
+    // The original 6 page ODT was designed to visually exaggerate the problems
+    // of emulating LO's followed-by-page-style into MSWord's sections.
+    // While much has been improved, there are extra pages present, which still need fixing.
+    xmlDocUniquePtr pDump = parseLayoutDump();
+
+    //Do not lose the page::breakAfter. This SHOULD be on page 4, but sadly it is not.
+    //The key part of this test is that the page starts with "Lorem ipsum"
+    //Prior to this, there was no page break, and so it was in the middle of a page.
+    CPPUNIT_ASSERT(getXPath(pDump, "//page[6]/body/txt[1]/Text[1]", "Portion").startsWith("Lorem ipsum"));
+}
+
+
 DECLARE_OOXMLIMPORT_TEST(testImageLazyRead, "image-lazy-read.docx")
 {
     auto xGraphic = getProperty<uno::Reference<graphic::XGraphic>>(getShape(1), "Graphic");
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index b489115d4980..cb46a925abab 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1296,7 +1296,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
         rContext->Insert(PROP_PARA_KEEP_TOGETHER, uno::makeAny( nIntValue != 0 ) );
         break;
     case NS_ooxml::LN_CT_PPrBase_pageBreakBefore:
-        rContext->Insert(PROP_BREAK_TYPE, uno::makeAny(nIntValue ? style::BreakType_PAGE_BEFORE : style::BreakType_NONE));
+        rContext->Insert(PROP_BREAK_TYPE, uno::makeAny(nIntValue ? style::BreakType_PAGE_BEFORE : style::BreakType_NONE), /*bOverwrite=*/bool(nIntValue));
     break;
     case NS_ooxml::LN_CT_NumPr_ilvl:
             if (nIntValue < 0 || 10 <= nIntValue) // Writer can't do everything


More information about the Libreoffice-commits mailing list