[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sw/qa writerfilter/source

Justin Luth justin_luth at sil.org
Wed Dec 14 04:54:44 UTC 2016


 sw/qa/extras/ooxmlexport/data/tdf46940_dontEquallyDistributeColumns.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx                                |   10 ++++
 writerfilter/source/dmapper/PropertyMap.cxx                              |   21 +++++++++-
 writerfilter/source/dmapper/PropertyMap.hxx                              |    2 
 4 files changed, 32 insertions(+), 1 deletion(-)

New commits:
commit 8820ca525a40f33fbb067868bc19a944597148af
Author: Justin Luth <justin_luth at sil.org>
Date:   Sat Dec 10 09:35:09 2016 +0300

    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 at libreoffice.org>
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit ede1a83e110ce7bc7d3560f415d6269ea3feb947)
    Reviewed-on: https://gerrit.libreoffice.org/31943

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 0000000..657da5e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf46940_dontEquallyDistributeColumns.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 476f553..2206afe 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -61,6 +61,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 03198f3..cea2dc4 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 7042d29..efee542 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 );


More information about the Libreoffice-commits mailing list