Kaydet (Commit) 5f0cfbbe authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Miklos Vajna

sw export: restore ww8 FormatBreak() to pre-2014 logic

In LO 4.3, Feb 2014 commit a31fbb53
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 a31fbb53 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/64983Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
Tested-by: 's avatarJustin Luth <justin_luth@sil.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
üst c5d0d424
......@@ -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
......
......@@ -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(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment