diff options
author | Justin Luth <justin_luth@sil.org> | 2018-12-11 15:55:26 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2018-12-14 14:08:35 +0100 |
commit | 5f0cfbbe1840428b07c1ba807ca8123df60bd8a0 (patch) | |
tree | 9a7b5d099ce4d7e6be77e3dd9c64e49dbde3a8bf | |
parent | c5d0d424bd7e78455cb6f9578cf2425ac0787004 (diff) |
sw export: restore ww8 FormatBreak() to pre-2014 logic
In LO 4.3, Feb 2014 commit a31fbb53dba76736b37213b98b64937f05929a67
totally changed the logic of the FormatBreak function, affecting
doc and rtf even though the focus was only on docx. This was quickly
patched for some specific cases, but the careless changes weren't fully
reversed.
Doing that now, because reading the code it just seems all wrong.
As I understand it, there seems to typically be two passes - a valid
pass for bBreakBefore and then a separate PageAfter pass. When DOC changed
to prefer a breakBefore sprm, it removed the bBefore flag, did nothing
on the bBreakBefore pass, and on the after pass, nC wasn't defined,
so it did nothing extra.
Dropping the bBefore flag probably broke the docx case.
Docx commit a31fbb53dba76736b37213b98b64937f05929a67 just blew that all
away, and swapped when SectionBreak was called.
Another 2014 patch restored the DOC PageBefore behaviour (nC not defined,
so nothing happens), but didn't restore the PageAfter behaviour
so SectionBreak was still swapped.
So what logically seems to be needed is to restore the bBefore flag
(prior to DOC's preference for breakBefore sprm), restore writing
PageBreak_After in after pass, and ignore the FollowPageDesc
(because it didn't seem to be included purposefully).
PageAfter only seems to be UI possible in a table's text flow. So it is
VERY uncommon (no instance at all in existing unit tests.) And, not
surprisingly, it doesn't export a page break after the table in
doc or docx format anyway. At least now it won't put the break BEFORE
the table in docx.
This will restore these previous behaviours:
-doc/rtf: PageAfter no longer written in bBreakBefore stage
-docx: -PageAfter no longer written in bBreakBefore stage
-PageBefore not affected by FollowPageDesc.
PageBefore is generally unaffected by this change, and now the
test for page/column break matches again, as would be expected.
Change-Id: I265541a04be49e6b60bfbd84c33ab5783b454058
Reviewed-on: https://gerrit.libreoffice.org/64983
Reviewed-by: Justin Luth <justin_luth@sil.org>
Tested-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/pageBreak_after.odt | bin | 0 -> 10162 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 13 |
3 files changed, 17 insertions, 5 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/pageBreak_after.odt b/sw/qa/extras/ooxmlexport/data/pageBreak_after.odt Binary files differnew file mode 100644 index 000000000000..c3096b58a50e --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/pageBreak_after.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 3b005e198b87..986414ff64a6 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -467,6 +467,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf104354_firstParaInSection, "tdf104354_firstParaI CPPUNIT_ASSERT_EQUAL(1, getPages()); } +DECLARE_OOXMLEXPORT_TEST(testPageBreak_after, "pageBreak_after.odt") +{ + // The problem was that the page breakAfter put the empty page BEFORE the table + xmlDocPtr pDump = parseLayoutDump(); + assertXPath(pDump, "/root/page[1]/body/tab", 1); + // There should be two pages actually - a blank page after a page break. + CPPUNIT_ASSERT_EQUAL_MESSAGE("Did you fix?? Table should be on page one of two", 1, getPages()); +} + DECLARE_OOXMLEXPORT_TEST(testTdf107035, "tdf107035.docx") { // Select the second run containing the page number field diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 6e41f51a8677..249ce32a6f99 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -3839,9 +3839,13 @@ void AttributeOutputBase::FormatBreak( const SvxFormatBreakItem& rBreak ) { if (!GetExport().m_bBreakBefore) PageBreakBefore(true); - break; } - [[fallthrough]]; + else + { + bBefore = true; + nC = msword::PageBreak; + } + break; case SvxBreak::PageAfter: case SvxBreak::PageBoth: nC = msword::PageBreak; @@ -3858,12 +3862,11 @@ void AttributeOutputBase::FormatBreak( const SvxFormatBreakItem& rBreak ) break; } - if ( (( bBefore != GetExport().m_bBreakBefore ) && ( nC == msword::PageBreak)) || - (( bBefore == GetExport().m_bBreakBefore ) && ( nC == msword::ColumnBreak)) ) + if ( ( bBefore == GetExport().m_bBreakBefore ) && nC ) { // #i76300# bool bFollowPageDescWritten = false; - if ( bCheckForFollowPageDesc && !bBefore ) + if ( bCheckForFollowPageDesc ) { bFollowPageDescWritten = GetExport().OutputFollowPageDesc( GetExport().GetCurItemSet(), |