From ede1a83e110ce7bc7d3560f415d6269ea3feb947 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Sat, 10 Dec 2016 09:35:09 +0300 Subject: tdf#46941 docx: don't balance columns before page-break-section Pleasantly surprised to see we already don't balance before regular page-breaks or at the end of the document. This adds not balancing before a page-break-section. Change-Id: Ifedff5cc45b154a005f13b3212154c443727e286 Reviewed-on: https://gerrit.libreoffice.org/31826 Tested-by: Jenkins Reviewed-by: Justin Luth Reviewed-by: Miklos Vajna --- writerfilter/source/dmapper/PropertyMap.cxx | 21 ++++++++++++++++++++- writerfilter/source/dmapper/PropertyMap.hxx | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'writerfilter') diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 03198f349d4f..cea2dc473a8d 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -398,6 +398,7 @@ SectionPropertyMap::SectionPropertyMap(bool bIsFirstSection) : ,m_bTitlePage( false ) ,m_nColumnCount( 0 ) ,m_nColumnDistance( 1249 ) + ,m_xColumnContainer( nullptr ) ,m_bSeparatorLineIsOn( false ) ,m_bEvenlySpaced( false ) ,m_bIsLandscape( false ) @@ -698,6 +699,18 @@ void SectionPropertyMap::SetBorderDistance( uno::Reference< beans::XPropertySet xStyle->setPropertyValue( sBorderDistanceName, uno::makeAny( nDist )); } +void SectionPropertyMap::DontBalanceTextColumns() +{ + try + { + if( m_xColumnContainer.is() ) + m_xColumnContainer->setPropertyValue("DontBalanceTextColumns", uno::makeAny(true)); + } + catch( const uno::Exception& ) + { + OSL_FAIL( "Exception in SectionPropertyMap::DontBalanceTextColumns"); + } +} uno::Reference< text::XTextColumns > SectionPropertyMap::ApplyColumnProperties( uno::Reference< beans::XPropertySet > const& xColumnContainer, DomainMapper_Impl& rDM_Impl ) @@ -757,8 +770,9 @@ uno::Reference< text::XTextColumns > SectionPropertyMap::ApplyColumnProperties( } xColumnContainer->setPropertyValue( sTextColumns, uno::makeAny( xColumns ) ); // Set the columns to be unbalanced if that compatibility option is set or this is the last section. + m_xColumnContainer = xColumnContainer; if (rDM_Impl.GetSettingsTable()->GetNoColumnBalance() || rDM_Impl.GetIsLastSectionGroup()) - xColumnContainer->setPropertyValue("DontBalanceTextColumns", uno::makeAny(true)); + DontBalanceTextColumns(); } catch( const uno::Exception& ) { @@ -1236,6 +1250,11 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) if( m_nColumnCount > 0 ) xColumns = ApplyColumnProperties( xFollowPageStyle, rDM_Impl ); + // these BreakTypes are effectively page-breaks: don't evenly distribute text in columns before a page break; + SectionPropertyMap* pLastContext = rDM_Impl.GetLastSectionContext(); + if( pLastContext && pLastContext->ColumnCount() ) + pLastContext->DontBalanceTextColumns(); + //prepare text grid properties sal_Int32 nHeight = 1; boost::optional pProp = getProperty(PROP_HEIGHT); diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx index 7042d293043a..efee54294c4f 100644 --- a/writerfilter/source/dmapper/PropertyMap.hxx +++ b/writerfilter/source/dmapper/PropertyMap.hxx @@ -194,6 +194,7 @@ class SectionPropertyMap : public PropertyMap bool m_bTitlePage; sal_Int16 m_nColumnCount; sal_Int32 m_nColumnDistance; + css::uno::Reference< css::beans::XPropertySet > m_xColumnContainer; ::std::vector< sal_Int32 > m_aColWidth; ::std::vector< sal_Int32 > m_aColDistance; @@ -239,6 +240,7 @@ class SectionPropertyMap : public PropertyMap bool m_bFirstPageFooterLinkToPrevious; void ApplyProperties_(css::uno::Reference const& xStyle); + void DontBalanceTextColumns(); css::uno::Reference ApplyColumnProperties(css::uno::Reference const& xFollowPageStyle, DomainMapper_Impl& rDM_Impl); void CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Impl& rDM_Impl ); -- cgit