summaryrefslogtreecommitdiff
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
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>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf46940_dontEquallyDistributeColumns.docxbin0 -> 8068 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx10
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx21
-rw-r--r--writerfilter/source/dmapper/PropertyMap.hxx2
4 files changed, 32 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf46940_dontEquallyDistributeColumns.docx b/sw/qa/extras/ooxmlexport/data/tdf46940_dontEquallyDistributeColumns.docx
new file mode 100644
index 000000000000..657da5eb09c9
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf46940_dontEquallyDistributeColumns.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 606510fa7fe4..1c7385037a33 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -67,6 +67,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf41542_borderlessPadding, "tdf41542_borderlessPad
CPPUNIT_ASSERT_EQUAL( 3, getPages() );
}
+DECLARE_OOXMLEXPORT_TEST(testTdf46940_dontEquallyDistributeColumns, "tdf46940_dontEquallyDistributeColumns.docx")
+{
+ uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns"));
+ // This was false, columns before a section-page-break were balanced.
+ CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(2), "DontBalanceTextColumns"));
+ CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(3), "DontBalanceTextColumns"));
+}
+
DECLARE_OOXMLEXPORT_TEST(testRhbz988516, "rhbz988516.docx")
{
// The problem was that the list properties of the footer leaked into body
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 );