summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2019-04-16 14:14:03 +0300
committerAndras Timar <andras.timar@collabora.com>2019-09-22 19:04:33 +0200
commit0a5e7464cf94a9a2cd55439a66f97cc7333e959c (patch)
treed3dfbdcdb3a82a2ed20acdd645c609c0fda4536b
parenttdf#124907 vcl: react to pan gesture for listbox and other widgets (diff)
downloadcore-0a5e7464cf94a9a2cd55439a66f97cc7333e959c.tar.gz
core-0a5e7464cf94a9a2cd55439a66f97cc7333e959c.zip
tdf#123636 writerfilter: handle deferred breaks on frames
and... related tdf#123636 writerfilter: split newline also if PAGE_BREAK ...but only with old MSWord compat flag SplitPgBreakAndParaMark. All of the other cases (COLUMN_BREAK and non-empty runs) split the paragraph, so why not here? This document shows it is needed, but only for SplitPgBreakAndParaMark documents. Note: Word 2003 doesn't display "modern" docx well in this regard. It adds extra paragraphs where it shouldn't. There are already example unit tests that ensure that extra paragraphs aren't written for SplitPgBreakAndParaMark == false. The actual bug's document is not related to the compatibility flag. That will be handled in separate commit. Reviewed-on: https://gerrit.libreoffice.org/70835 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> (cherry picked from commit 89e44da1ab450f6e2f4106103efd169227683f20) tdf#123636 writerfilter: handle deferred breaks on frames ...similar to handling breaks before shapes in lcl_startShape. Three different examples found to create/split a paragraph. Which one to use? (addDummy, m_bIsSplitPara, and lcl_startCharacterGroup). SplitPara is not good because the paragraph properties probably should not be copied to the dummy paragraph (like numbering for example). Slightly modified the lcl_startChar example to ensure that the dummy paragraph doesn't steal a part of the properties, but is only default properties plus page-break. This doesn't export very well, so roundtripping is very poor. Research Note: There exists a compat flag showBreaksInFrames (Display Page/Column Breaks Present in Frames) "This element specifies whether applications should honor the presence of page and/or column breaks which are present within the contents of paragraphs which have been defined as frames using the framePr element." --Currently, LO does nothing with this flag. Probably too exotic and irrelevant (word 2003 era?). No existing unit tests found that have isSet(pg_brk) frames. Reviewed-on: https://gerrit.libreoffice.org/71255 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit f6f53f76e15f5eecc5b6ce56e471c53cebfea8ad) Change-Id: I29f815355401c7af8b347a3ed9d0298bc9b27b93
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak.docxbin0 -> 10107 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak2.docxbin0 -> 15014 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak3.docxbin0 -> 10411 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak4.docxbin0 -> 10347 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx27
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport6.cxx2
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx23
7 files changed, 52 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak.docx b/sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak.docx
new file mode 100644
index 000000000000..6f7b4b144547
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak2.docx b/sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak2.docx
new file mode 100644
index 000000000000..a876bea84e02
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak2.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak3.docx b/sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak3.docx
new file mode 100644
index 000000000000..1bcc335fdc59
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak3.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak4.docx b/sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak4.docx
new file mode 100644
index 000000000000..3a9d86ee21e2
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf123636_newlinePageBreak4.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 8a82f0f04d38..87019efcec3d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -962,6 +962,33 @@ DECLARE_OOXMLEXPORT_TEST(testInputListExport, "tdf122186_input_list.odt")
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[4]/w:t", 0);
}
+DECLARE_OOXMLEXPORT_TEST(testTdf123636_newlinePageBreak, "tdf123636_newlinePageBreak.docx")
+{
+ //MS Compatibility flag: SplitPgBreakAndParaMark
+ //special case: split first empty paragraph in a section.
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Paragraphs", 2, getParagraphs() );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 2, getPages() );
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf123636_newlinePageBreak2, "tdf123636_newlinePageBreak2.docx")
+{
+ //WITHOUT SplitPgBreakAndParaMark: a following anchored shape should force a page break
+ //CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Paragraphs", 2, getParagraphs() );
+ CPPUNIT_ASSERT_EQUAL(OUString(), getProperty<OUString>(getParagraph(2, ""), "NumberingStyleName"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 2, getPages() );
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf123636_newlinePageBreak4, "tdf123636_newlinePageBreak4.docx")
+{
+ //MS Compatibility flag: SplitPgBreakAndParaMark
+ //special case: an empty paragraph doesn't split (except if first paragraph).
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Paragraphs", 3, getParagraphs() );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 2, getPages() );
+
+ xmlDocPtr pDump = parseLayoutDump();
+ assertXPath(pDump, "/root/page[2]/body/txt[1]/Text", 0);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index 097048febe40..5b4e7c99e67b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -938,6 +938,8 @@ DECLARE_OOXMLEXPORT_TEST(testExtentValue, "fdo74605.docx")
sal_Int32 nX = getXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:extent", "cx").toInt32();
// This was negative.
CPPUNIT_ASSERT(nX >= 0);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 2, getPages() );
}
// part of tdf#93676, word gives the frame in the exported .docx a huge height,
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index e408b74df7e0..9381a5fb8682 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1965,6 +1965,22 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
if( pContext.get() )
{
+ // If there is a deferred page break applied to this framed paragraph,
+ // create a dummy paragraph without extra properties,
+ // so that the anchored frame will be on the correct page (similar to shapes).
+ if (pContext->isSet(PROP_BREAK_TYPE))
+ {
+ pContext->Erase(PROP_BREAK_TYPE);
+
+ lcl_startParagraphGroup();
+ m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE));
+ lcl_startCharacterGroup();
+ sal_uInt8 const sBreak[] = { 0xd };
+ lcl_text(sBreak, 1);
+ lcl_endCharacterGroup();
+ lcl_endParagraphGroup();
+ }
+
ParagraphPropertyMap* pParaContext = dynamic_cast< ParagraphPropertyMap* >( pContext.get() );
if (pParaContext)
pParaContext->SetFrameMode();
@@ -3273,6 +3289,13 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
{
if (m_pImpl->GetSettingsTable()->GetSplitPgBreakAndParaMark())
{
+ if ( m_pImpl->GetIsFirstParagraphInSection() || !m_pImpl->IsFirstRun() )
+ {
+ m_pImpl->m_bIsSplitPara = true;
+ m_pImpl->finishParagraph( m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH) );
+ lcl_startParagraphGroup();
+ }
+
pContext->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE));
m_pImpl->clearDeferredBreaks();
}