[Libreoffice-commits] core.git: sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Jul 17 09:17:32 PDT 2014


 sw/qa/extras/ooxmlimport/data/unbalanced-columns-compat.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx                     |    8 ++++++++
 writerfilter/source/dmapper/PropertyMap.cxx                  |    9 +++++----
 writerfilter/source/dmapper/PropertyMap.hxx                  |    2 +-
 writerfilter/source/dmapper/SettingsTable.cxx                |   10 ++++++++++
 writerfilter/source/dmapper/SettingsTable.hxx                |    1 +
 6 files changed, 25 insertions(+), 5 deletions(-)

New commits:
commit 9da4fe80c81b3464b2f6834052a24ce57c2fd07e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jul 17 18:05:47 2014 +0200

    DOCX import: handle <w:noColumnBalance> compat setting
    
    Change-Id: Ieffd1fe52d6167d84ada5ebb11686f20d6dce8fa

diff --git a/sw/qa/extras/ooxmlimport/data/unbalanced-columns-compat.docx b/sw/qa/extras/ooxmlimport/data/unbalanced-columns-compat.docx
new file mode 100755
index 0000000..da980c8
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/unbalanced-columns-compat.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 9de6c29..061c393 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2282,6 +2282,14 @@ DECLARE_OOXMLIMPORT_TEST(testUnbalancedColumns, "unbalanced-columns.docx")
     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(2), "DontBalanceTextColumns"));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testUnbalancedColumnsCompat, "unbalanced-columns-compat.docx")
+{
+    uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
+    // This was false, we ignored the relevant compat setting to make this non-last section unbalanced.
+    CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns"));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 44a8168..3ec36cd 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -607,7 +607,7 @@ void SectionPropertyMap::SetBorderDistance( uno::Reference< beans::XPropertySet
 
 
 uno::Reference< text::XTextColumns > SectionPropertyMap::ApplyColumnProperties(
-                            uno::Reference< beans::XPropertySet > xColumnContainer, bool bLast )
+                            uno::Reference< beans::XPropertySet > xColumnContainer, DomainMapper_Impl& rDM_Impl )
 {
     uno::Reference< text::XTextColumns > xColumns;
     try
@@ -659,7 +659,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)
+        // Set the columns to be unbalanced if that compatability option is set or this is the last section.
+        if (rDM_Impl.GetSettingsTable()->GetNoColumnBalance() || rDM_Impl.GetIsLastSectionGroup())
             xColumnContainer->setPropertyValue("DontBalanceTextColumns", uno::makeAny(true));
     }
     catch( const uno::Exception& )
@@ -956,7 +957,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, rDM_Impl.GetIsLastSectionGroup() );
+            ApplyColumnProperties( xSection, rDM_Impl );
         uno::Reference<beans::XPropertySet> xRangeProperties(lcl_GetRangeProperties(m_bIsFirstSection, rDM_Impl, m_xStartingRange));
         if (xRangeProperties.is())
         {
@@ -1012,7 +1013,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
         }
         uno::Reference< text::XTextColumns > xColumns;
         if( m_nColumnCount > 0 )
-            xColumns = ApplyColumnProperties( xFollowPageStyle, rDM_Impl.GetIsLastSectionGroup() );
+            xColumns = ApplyColumnProperties( xFollowPageStyle, rDM_Impl );
 
         //prepare text grid properties
         sal_Int32 nHeight = 1;
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index 59a6559..98e4a1f 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -203,7 +203,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, bool bLast );
+            ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xFollowPageStyle, DomainMapper_Impl& rDM_Impl );
     void CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Impl& rDM_Impl );
     void PrepareHeaderFooterProperties( bool bFirstPage );
     bool HasHeader( bool bFirstPage ) const;
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx
index 16b054d..07ad91a 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -74,6 +74,7 @@ struct SettingsTable_Impl
     bool                embedTrueTypeFonts;
     bool                embedSystemFonts;
     bool                m_bDoNotUseHTMLParagraphAutoSpacing;
+    bool                m_bNoColumnBalance;
     bool                m_bSplitPgBreakAndParaMark;
     bool                m_bMirrorMargin;
     uno::Sequence<beans::PropertyValue> m_pThemeFontLangProps;
@@ -104,6 +105,7 @@ struct SettingsTable_Impl
     , embedTrueTypeFonts(false)
     , embedSystemFonts(false)
     , m_bDoNotUseHTMLParagraphAutoSpacing(false)
+    , m_bNoColumnBalance(false)
     , m_bSplitPgBreakAndParaMark(false)
     , m_bMirrorMargin(false)
     , m_pThemeFontLangProps(3)
@@ -276,6 +278,9 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
         }
     }
     break;
+    case NS_ooxml::LN_CT_Compat_noColumnBalance:
+        m_pImpl->m_bNoColumnBalance = nIntValue;
+        break;
     default:
     {
 #ifdef DEBUG_DOMAINMAPPER
@@ -338,6 +343,11 @@ bool SettingsTable::GetDoNotUseHTMLParagraphAutoSpacing() const
     return m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing;
 }
 
+bool SettingsTable::GetNoColumnBalance() const
+{
+    return m_pImpl->m_bNoColumnBalance;
+}
+
 bool SettingsTable::GetSplitPgBreakAndParaMark() const
 {
     return m_pImpl->m_bSplitPgBreakAndParaMark;
diff --git a/writerfilter/source/dmapper/SettingsTable.hxx b/writerfilter/source/dmapper/SettingsTable.hxx
index 59584fa..36c9bb5 100644
--- a/writerfilter/source/dmapper/SettingsTable.hxx
+++ b/writerfilter/source/dmapper/SettingsTable.hxx
@@ -71,6 +71,7 @@ class SettingsTable : public LoggedProperties, public LoggedTable
     bool GetDoNotUseHTMLParagraphAutoSpacing() const;
     bool GetSplitPgBreakAndParaMark() const;
     bool GetMirrorMarginSettings() const;
+    bool GetNoColumnBalance() const;
 
     css::uno::Sequence<css::beans::PropertyValue> GetThemeFontLangProperties() const;
 


More information about the Libreoffice-commits mailing list