sw/qa/extras/ooxmlimport/data/unbalanced-columns.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 8 ++++++++ sw/qa/extras/rtfimport/data/unbalanced-columns.rtf | 5 +++++ sw/qa/extras/rtfimport/rtfimport.cxx | 8 ++++++++ writerfilter/inc/dmapper/DomainMapper.hxx | 1 + writerfilter/inc/resourcemodel/WW8ResourceModel.hxx | 3 +++ writerfilter/source/dmapper/DomainMapper.cxx | 5 +++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 6 ++++++ writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 +++ writerfilter/source/dmapper/PropertyMap.cxx | 9 ++++++--- writerfilter/source/dmapper/PropertyMap.hxx | 2 +- writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 5 +++++ writerfilter/source/ooxml/OOXMLFastContextHandler.hxx | 1 + writerfilter/source/ooxml/model.xml | 1 + writerfilter/source/rtftok/rtfdocumentimpl.cxx | 6 ++++++ 15 files changed, 59 insertions(+), 4 deletions(-)
New commits: commit 084d5986823e7bd7baaa68450c0a6b4772c84246 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Jul 17 14:59:19 2014 +0200 fdo#84645 RTF import: set DontBalanceTextColumns=true for the last section ... ... if it has multiple columns. See commit d185204737031955c56a24356ed003d342548434 (DOCX import: set DontBalanceTextColumns=true for the last section, 2014-07-17) for the DOCX equivalent of this problem; this just adapts the RTF tokenizer to dmapper. (cherry picked from commit d185204737031955c56a24356ed003d342548434) (cherry picked from commit f4bb73164a51ec83fe1d5975b1232d35f8a9e88a) Change-Id: Ib30f9b386e204b8b2987832ab17ee0cc53b3f0bc Reviewed-on: https://gerrit.libreoffice.org/12462 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/qa/extras/ooxmlimport/data/unbalanced-columns.docx b/sw/qa/extras/ooxmlimport/data/unbalanced-columns.docx new file mode 100755 index 0000000..da6f93f Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/unbalanced-columns.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 900a25e..0082009 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -2395,6 +2395,14 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx") CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(10), 3), "IsStart")); } +DECLARE_OOXMLIMPORT_TEST(testUnbalancedColumns, "unbalanced-columns.docx") +{ + uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); + // This was false, last section was balanced, but it's unbalanced in Word. + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(2), "DontBalanceTextColumns")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/rtfimport/data/unbalanced-columns.rtf b/sw/qa/extras/rtfimport/data/unbalanced-columns.rtf new file mode 100644 index 0000000..aa57e38 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/unbalanced-columns.rtf @@ -0,0 +1,5 @@ +{\rtf1 +\cols2 +\pard\plain First paragraph.\par +Second paragraph.\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 1214051..8a6c6da 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -2009,6 +2009,14 @@ DECLARE_RTFIMPORT_TEST(testFdo82512, "fdo82512.rtf") CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(2), "BreakType")); } +DECLARE_RTFIMPORT_TEST(testUnbalancedColumns, "unbalanced-columns.rtf") +{ + uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); + // This was false, last section was balanced, but it's unbalanced in Word. + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/inc/dmapper/DomainMapper.hxx b/writerfilter/inc/dmapper/DomainMapper.hxx index 9266f08..7143219 100644 --- a/writerfilter/inc/dmapper/DomainMapper.hxx +++ b/writerfilter/inc/dmapper/DomainMapper.hxx @@ -87,6 +87,7 @@ public: // Stream virtual void markLastParagraphInSection() SAL_OVERRIDE; + virtual void markLastSectionGroup() SAL_OVERRIDE; // BinaryObj virtual void data(const sal_uInt8* buf, size_t len, diff --git a/writerfilter/inc/resourcemodel/WW8ResourceModel.hxx b/writerfilter/inc/resourcemodel/WW8ResourceModel.hxx index 0d36342..dd64b34 100644 --- a/writerfilter/inc/resourcemodel/WW8ResourceModel.hxx +++ b/writerfilter/inc/resourcemodel/WW8ResourceModel.hxx @@ -197,6 +197,9 @@ public: */ virtual void endSectionGroup() = 0; + /// The current section is the last one in this body text. + virtual void markLastSectionGroup( ) { }; + /** Receives start mark for group with the same paragraph properties. */ diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 7c8ac20..8bc3320 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2576,6 +2576,11 @@ void DomainMapper::markLastParagraphInSection( ) m_pImpl->SetIsLastParagraphInSection( true ); } +void DomainMapper::markLastSectionGroup( ) +{ + m_pImpl->SetIsLastSectionGroup( true ); +} + void DomainMapper::lcl_startShape( uno::Reference< drawing::XShape > xShape ) { if (m_pImpl->GetTopContext()) diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 41d12af..c3343f1 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -188,6 +188,7 @@ DomainMapper_Impl::DomainMapper_Impl( m_bDummyParaAddedForTableInSection( false ), m_bTextFrameInserted(false), m_bIsLastParaInSection( false ), + m_bIsLastSectionGroup( false ), m_bIsInComments( false ), m_bParaSectpr( false ), m_bUsingEnhancedFields( false ), @@ -396,6 +397,11 @@ sal_Int32 DomainMapper_Impl::GetSymbolData() return m_nSymboldata; } +void DomainMapper_Impl::SetIsLastSectionGroup( bool bIsLast ) +{ + m_bIsLastSectionGroup = bIsLast; +} + void DomainMapper_Impl::SetIsLastParagraphInSection( bool bIsLast ) { m_bIsLastParaInSection = bIsLast; diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index e60eab4..f72c866 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -374,6 +374,7 @@ private: bool m_bDummyParaAddedForTableInSection; bool m_bTextFrameInserted; bool m_bIsLastParaInSection; + bool m_bIsLastSectionGroup; bool m_bIsInComments; /// If the current paragraph contains section property definitions. bool m_bParaSectpr; @@ -452,6 +453,8 @@ public: void RemoveLastParagraph( ); void SetIsLastParagraphInSection( bool bIsLast ); bool GetIsLastParagraphInSection(); + void SetIsLastSectionGroup( bool bIsLast ); + bool GetIsLastSectionGroup() { return m_bIsLastSectionGroup;} void SetIsFirstParagraphInSection( bool bIsFirst ); bool GetIsFirstParagraphInSection(); void SetIsDummyParaAddedForTableInSection( bool bIsAdded ); diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 2512a9d..5014d63 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -619,7 +619,7 @@ void SectionPropertyMap::SetBorderDistance( uno::Reference< beans::XPropertySet uno::Reference< text::XTextColumns > SectionPropertyMap::ApplyColumnProperties( - uno::Reference< beans::XPropertySet > xColumnContainer ) + uno::Reference< beans::XPropertySet > xColumnContainer, bool bLast ) { uno::Reference< text::XTextColumns > xColumns; try @@ -671,6 +671,8 @@ uno::Reference< text::XTextColumns > SectionPropertyMap::ApplyColumnProperties( rPropNameSupplier.GetName( PROP_SEPARATOR_LINE_IS_ON ), uno::makeAny( m_bSeparatorLineIsOn )); xColumnContainer->setPropertyValue( sTextColumns, uno::makeAny( xColumns ) ); + if (bLast) + xColumnContainer->setPropertyValue("DontBalanceTextColumns", uno::makeAny(true)); } catch( const uno::Exception& ) { @@ -980,7 +982,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) uno::Reference< beans::XPropertySet > xSection = rDM_Impl.appendTextSectionAfter( m_xStartingRange ); if( m_nColumnCount > 0 && xSection.is()) - ApplyColumnProperties( xSection ); + ApplyColumnProperties( xSection, rDM_Impl.GetIsLastSectionGroup() ); uno::Reference<beans::XPropertySet> xRangeProperties(lcl_GetRangeProperties(m_bIsFirstSection, rDM_Impl, m_xStartingRange)); if (xRangeProperties.is()) { @@ -1036,7 +1038,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) } uno::Reference< text::XTextColumns > xColumns; if( m_nColumnCount > 0 ) - xColumns = ApplyColumnProperties( xFollowPageStyle ); + xColumns = ApplyColumnProperties( xFollowPageStyle, rDM_Impl.GetIsLastSectionGroup() ); //prepare text grid properties sal_Int32 nHeight = 1; @@ -1197,6 +1199,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) OSL_FAIL( "Exception in SectionPropertyMap::CloseSectionGroup"); } } + rDM_Impl.SetIsLastSectionGroup(false); rDM_Impl.SetIsFirstParagraphInSection(true); } diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx index 58487d6..63721b6 100644 --- a/writerfilter/source/dmapper/PropertyMap.hxx +++ b/writerfilter/source/dmapper/PropertyMap.hxx @@ -221,7 +221,7 @@ class SectionPropertyMap : public PropertyMap void _ApplyProperties( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xStyle ); ::com::sun::star::uno::Reference< com::sun::star::text::XTextColumns > ApplyColumnProperties( - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xFollowPageStyle ); + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xFollowPageStyle, bool bLast ); void CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Impl& rDM_Impl ); void CopyHeaderFooter( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPrevStyle, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xStyle ); diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index 7fd973c..5104574 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -738,6 +738,11 @@ void OOXMLFastContextHandler::setLastParagraphInSection() mpStream->markLastParagraphInSection( ); } +void OOXMLFastContextHandler::setLastSectionGroup() +{ + mpStream->markLastSectionGroup( ); +} + void OOXMLFastContextHandler::newProperty (const Id & /*nId*/, OOXMLValue::Pointer_t /*pVal*/) { diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx index a7d9bfa..f56f5e9 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx @@ -186,6 +186,7 @@ public: void startSectionGroup(); void setLastParagraphInSection(); + void setLastSectionGroup(); void endSectionGroup(); void startParagraphGroup(); void endParagraphGroup(); diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index b3f25af..1e427b1 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -25887,6 +25887,7 @@ --> <action name="end" action="endCharacterGroup"/> <action name="end" action="endParagraphGroup"/> + <action name="end" action="setLastSectionGroup"/> <action name="end" action="endSectionGroup"/> </resource> <resource xmlns:v="urn:schemas-microsoft-com:vml" name="CT_ShapeDefaults" resource="Properties" tag="shape"> diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 6c6e282..b372d34 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -601,6 +601,12 @@ void RTFDocumentImpl::sectBreak(bool bFinal = false) writerfilter::Reference<Properties>::Pointer_t const pProperties( new RTFReferenceProperties(aAttributes, aSprms) ); + + if (bFinal && !m_pSuperstream) + // This is the end of the document, not just the end of e.g. a header. + // This makes sure that dmapper can set DontBalanceTextColumns=true for this section if necessary. + Mapper().markLastSectionGroup(); + // The trick is that we send properties of the previous section right now, which will be exactly what dmapper expects. Mapper().props(pProperties); Mapper().endParagraphGroup();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits