summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2016-12-10 09:35:09 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-12-13 07:41:56 +0000
commitede1a83e110ce7bc7d3560f415d6269ea3feb947 (patch)
treeef3cbb0c0947d7beae71ee9d54a50e4dd7ab33a8 /writerfilter
parent0fda52cc4a5c78c55f96850faa734ea66891808c (diff)
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 <ci@libreoffice.org> Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx21
-rw-r--r--writerfilter/source/dmapper/PropertyMap.hxx2
2 files changed, 22 insertions, 1 deletions
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<PropertyMap::Property> 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<css::beans::XPropertySet> const& xStyle);
+ void DontBalanceTextColumns();
css::uno::Reference<css::text::XTextColumns> ApplyColumnProperties(css::uno::Reference<css::beans::XPropertySet> const& xFollowPageStyle,
DomainMapper_Impl& rDM_Impl);
void CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Impl& rDM_Impl );