[Libreoffice-commits] core.git: sw/qa writerfilter/source
sushil_shinde
sushil.shinde at synerzip.com
Mon May 5 00:35:12 PDT 2014
sw/qa/extras/ooxmlexport/data/fdo77727.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 12 ++++++++++++
writerfilter/source/dmapper/DomainMapper.cxx | 14 +++++++++++++-
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 11 ++++++++++-
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 +++
5 files changed, 38 insertions(+), 2 deletions(-)
New commits:
commit 61e8452c62a587b40bf80076642b869cbd1b7ed6
Author: sushil_shinde <sushil.shinde at synerzip.com>
Date: Mon Apr 28 17:10:27 2014 +0530
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 at collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/sw/qa/extras/ooxmlexport/data/fdo77727.docx b/sw/qa/extras/ooxmlexport/data/fdo77727.docx
new file mode 100644
index 0000000..9f553e2
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo77727.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 2edbd28..44b9aa7 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 858bb93..43b382d 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 a738d83..410b064 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 ab98cfe..2694a51 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 ;
More information about the Libreoffice-commits
mailing list