summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsushil_shinde <sushil.shinde@synerzip.com>2014-04-28 17:10:27 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-05-05 07:34:45 +0000
commit61e8452c62a587b40bf80076642b869cbd1b7ed6 (patch)
treee413601b06fead2f59e0efd42461f32620003b2a
parent82a623fb08afc72decb78f061b751a43ae503678 (diff)
fdo#77727 PAGEBREAK In first paragraph was not rendered and exported.
Case 1: If PAGEBREAK appears in first paragraph, LO was inserting BreakType_PAGE_BEFORE but since it was first paragraph, PAGEBREAK was not rendered in LO hence not exported back to docx file properly. case 2: If PAGEBREAK appears after first run of any paragraph in document LO was rendering it in wrong paragraph. case 3: If COLUMNBREAK appears in first paragraph of section, LO was not rendering and exporting it. Change-Id: Ic557b3e6f80cfa6dd3eb6b4204be7e6531b9ecbf Reviewed-on: https://gerrit.libreoffice.org/9191 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo77727.docxbin0 -> 48777 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx12
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx14
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx11
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx3
5 files changed, 38 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo77727.docx b/sw/qa/extras/ooxmlexport/data/fdo77727.docx
new file mode 100644
index 000000000000..9f553e210df6
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo77727.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 2edbd28cbc1a..44b9aa730046 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3210,6 +3210,18 @@ DECLARE_OOXMLEXPORT_TEST(testContentTypeOLE, "fdo77759.docx")
"/word/embeddings/oleObject1.xlsx");
}
+DECLARE_OOXMLEXPORT_TEST(testPageBreakInFirstPara,"fdo77727.docx")
+{
+ /* Break to next page was not exported if it is in first paragraph of the section.
+ * Now after fix , LO writes Next Page Break and also preserves <w:br> tag.
+ */
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/w:br","type","page");
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 858bb93f5c5d..43b382d962fc 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2795,10 +2795,22 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
if ( pContext && !pContext->GetFootnote().is() )
{
if (m_pImpl->isBreakDeferred(PAGE_BREAK))
+ {
+ /* If PAGEBREAK appears in first paragraph of the section or
+ * after first run of any paragraph then need to split paragraph
+ * to handle it properly.
+ */
+ if (m_pImpl->GetIsFirstParagraphInSection() || !m_pImpl->IsFirstRun())
+ {
+ m_pImpl->m_bIsSplitPara = true;
+ m_pImpl->finishParagraph(m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH));
+ lcl_startParagraphGroup();
+ }
m_pImpl->GetTopContext()->Insert( PROP_BREAK_TYPE, uno::makeAny( com::sun::star::style::BreakType_PAGE_BEFORE) );
+ }
else if (m_pImpl->isBreakDeferred(COLUMN_BREAK))
{
- if (!m_pImpl->IsFirstRun())
+ if (m_pImpl->GetIsFirstParagraphInSection() || !m_pImpl->IsFirstRun())
{
mbIsSplitPara = true;
m_pImpl->finishParagraph(m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH));
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index a738d8364565..410b064f525b 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -198,6 +198,7 @@ DomainMapper_Impl::DomainMapper_Impl(
m_bIgnoreNextPara(false),
m_bIgnoreNextTab(false),
m_bFrameBtLr(false),
+ m_bIsSplitPara(false),
m_vTextFramesForChaining()
{
@@ -459,7 +460,15 @@ void DomainMapper_Impl::PushProperties(ContextType eId)
pSectionContext_->SetStart( xTextAppend->getEnd() );
}
}
- m_aPropertyStacks[eId].push( pInsert );
+ if(eId == CONTEXT_PARAGRAPH && m_bIsSplitPara)
+ {
+ m_aPropertyStacks[eId].push( GetTopContextOfType(eId));
+ m_bIsSplitPara = false;
+ }
+ else
+ {
+ m_aPropertyStacks[eId].push( pInsert );
+ }
m_aContextStack.push(eId);
m_pTopContext = m_aPropertyStacks[eId].top();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index ab98cfec4630..2694a5108b39 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -784,6 +784,9 @@ public:
void substream(Id rName, ::writerfilter::Reference<Stream>::Pointer_t const& ref);
+ /// If the document needs to split paragraph.
+ bool m_bIsSplitPara;
+
private:
void PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType);
std::vector<uno::Reference< drawing::XShape > > m_vTextFramesForChaining ;