sw/qa/extras/ooxmlexport/data/columnbreak.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 11 +++++++++- writerfilter/inc/dmapper/DomainMapper.hxx | 1 writerfilter/source/dmapper/DomainMapper.cxx | 24 ++++++++++++++++++++-- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 1 writerfilter/source/dmapper/DomainMapper_Impl.hxx | 4 +++ 6 files changed, 38 insertions(+), 3 deletions(-)
New commits: commit 0c61ffc15ecd8122cb9102d2591561e1d4e37327 Author: Vinaya Mandke <vinaya.man...@synerzip.com> Date: Thu Dec 5 18:22:56 2013 +0530 Fix for Column Break if it appears in w:r which is not the first run. Explicitly ended paragraph when the column break appears in a run (which is not the first run in the paragraph), as Writer adds a column break only for new paragraph. Also the created paragraph must have the same para properties as the earlier one. Hence avoided pushing new para properties if paragraph is split to adjust a col break. Added UT for the same. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/6953 Change-Id: If7d503b7a4bfab31f40ceb0119876e5909252b2f diff --git a/sw/qa/extras/ooxmlexport/data/columnbreak.docx b/sw/qa/extras/ooxmlexport/data/columnbreak.docx new file mode 100644 index 0000000..f55780e Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/columnbreak.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index aea310f..c4efcfd 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -39,7 +39,7 @@ #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/text/WrapTextMode.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> - +#include <com/sun/star/style/BreakType.hpp> #include <unotools/tempfile.hxx> #include <unotools/ucbstreamhelper.hxx> #include <rtl/strbuf.hxx> @@ -2084,6 +2084,15 @@ DECLARE_OOXMLEXPORT_TEST(testExtraSectionBreak, "1_page.docx") CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage()); } +DECLARE_OOXMLEXPORT_TEST(testcolumnbreak, "columnbreak.docx") +{ + CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(5, "This is first line after col brk."), "BreakType")); + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:r[1]/w:br", "type", "column"); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/inc/dmapper/DomainMapper.hxx b/writerfilter/inc/dmapper/DomainMapper.hxx index d6b5d37..78067fc 100644 --- a/writerfilter/inc/dmapper/DomainMapper.hxx +++ b/writerfilter/inc/dmapper/DomainMapper.hxx @@ -164,6 +164,7 @@ private: sal_Int32 mnBackgroundColor; bool mbIsHighlightSet; bool mbIsBIDI; + bool mbIsSplitPara; boost::scoped_ptr< GraphicZOrderHelper > zOrderHelper; }; diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 742ef98..8502466 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -97,7 +97,7 @@ LoggedProperties(dmapper_logger, "DomainMapper"), LoggedTable(dmapper_logger, "DomainMapper"), LoggedStream(dmapper_logger, "DomainMapper"), m_pImpl( new DomainMapper_Impl( *this, xContext, xModel, eDocumentType, xInsertTextRange, bIsNewDoc )), - mnBackgroundColor(0), mbIsHighlightSet(false), mbIsBIDI(false) + mnBackgroundColor(0), mbIsHighlightSet(false), mbIsBIDI(false), mbIsSplitPara(false) { // #i24363# tab stops relative to indent m_pImpl->SetDocumentSettingsProperty( @@ -3669,7 +3669,17 @@ void DomainMapper::lcl_endSectionGroup() void DomainMapper::lcl_startParagraphGroup() { m_pImpl->getTableManager().startParagraphGroup(); - m_pImpl->PushProperties(CONTEXT_PARAGRAPH); + /* + * Add new para properties only if paragraph is not split + * or the top context is not of paragraph properties + * Set mbIsSplitPara to false as it has been handled + */ + if (!mbIsSplitPara) + m_pImpl->PushProperties(CONTEXT_PARAGRAPH); + mbIsSplitPara = false; + if (!(m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH) == m_pImpl->GetTopContext())) + m_pImpl->PushProperties(CONTEXT_PARAGRAPH); + static OUString sDefault("Standard"); if (m_pImpl->GetTopContext()) { @@ -3683,6 +3693,7 @@ void DomainMapper::lcl_startParagraphGroup() else if (m_pImpl->isBreakDeferred(COLUMN_BREAK)) m_pImpl->GetTopContext()->Insert( PROP_BREAK_TYPE, uno::makeAny( com::sun::star::style::BreakType_COLUMN_BEFORE) ); } + m_pImpl->SetIsFirstRun(); m_pImpl->clearDeferredBreaks(); } @@ -3933,7 +3944,15 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) if (m_pImpl->isBreakDeferred(PAGE_BREAK)) 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()) + { + mbIsSplitPara = 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_COLUMN_BEFORE) ); + } m_pImpl->clearDeferredBreaks(); } @@ -3958,6 +3977,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) } } + m_pImpl->UpdateIsFirstRun(); } catch( const uno::RuntimeException& ) { diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 048e691..7b60f09 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -170,6 +170,7 @@ DomainMapper_Impl::DomainMapper_Impl( m_bParaSectpr( false ), m_bUsingEnhancedFields( false ), m_bSdt(false), + m_isFirstRun(false), m_xInsertTextRange(xInsertTextRange), m_bIsNewDoc(bIsNewDoc), m_bInTableStyleRunProps(false), diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 1ebf067..34b87a2 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -387,6 +387,7 @@ private: bool m_bUsingEnhancedFields; /// If the current paragraph is inside a structured document element. bool m_bSdt; + bool m_isFirstRun; //annotation import uno::Reference< beans::XPropertySet > m_xAnnotationField; @@ -677,6 +678,9 @@ public: void RemoveCurrentRedline( ); void ResetParaRedline( ); void SetCurrentRedlineInitials( OUString sInitials ); + bool IsFirstRun() { return m_isFirstRun;} + void SetIsFirstRun() { m_isFirstRun = true;} + void UpdateIsFirstRun() { m_isFirstRun = false;} void ApplySettingsTable(); SectionPropertyMap * GetSectionContext(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits