sw/qa/extras/ooxmlexport/ooxmlexport5.cxx         |    5 +--
 sw/source/filter/ww8/docxattributeoutput.cxx      |    9 +++++
 sw/source/filter/ww8/docxexport.cxx               |   34 ++++++++++++++++------
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    4 ++
 writerfilter/source/dmapper/SettingsTable.cxx     |    9 +++++
 writerfilter/source/dmapper/SettingsTable.hxx     |    1 
 6 files changed, 51 insertions(+), 11 deletions(-)

New commits:
commit 3cd3ae30217a80449799d7d9426c3756c572712e
Author:     Michael Stahl <michael.st...@cib.de>
AuthorDate: Tue Apr 14 18:10:53 2020 +0200
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Wed Apr 15 11:29:25 2020 +0200

    writerfilter: DOCX import: import w:noLeading as AddExternalLeading
    
    Change-Id: I3d7fa2984975205d284575c60c6c47284b00c4a0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92209
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@cib.de>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 1e7f8a99e663..010cb3e3fe21 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -6654,6 +6654,10 @@ void DomainMapper_Impl::ApplySettingsTable()
             if( m_pSettingsTable->GetEmbedSystemFonts())
                 xSettings->setPropertyValue( getPropertyName( 
PROP_EMBED_SYSTEM_FONTS ), uno::makeAny(true) );
             xSettings->setPropertyValue("AddParaTableSpacing", 
uno::makeAny(m_pSettingsTable->GetDoNotUseHTMLParagraphAutoSpacing()));
+            if (m_pSettingsTable->GetNoLeading())
+            {
+                xSettings->setPropertyValue("AddExternalLeading", 
uno::makeAny(!m_pSettingsTable->GetNoLeading()));
+            }
             if( m_pSettingsTable->GetProtectForm() )
                 xSettings->setPropertyValue("ProtectForm", uno::makeAny( true 
));
             if( m_pSettingsTable->GetReadOnly() )
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx 
b/writerfilter/source/dmapper/SettingsTable.cxx
index 303de47c8f71..81fadad6ac40 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -263,6 +263,7 @@ struct SettingsTable_Impl
     OUString            m_sRedlineProtectionKey;
     bool                m_bReadOnly;
     bool                m_bDisplayBackgroundShape;
+    bool                m_bNoLeading = false;
 
     uno::Sequence<beans::PropertyValue> m_pThemeFontLangProps;
 
@@ -575,6 +576,9 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
     case NS_ooxml::LN_CT_Settings_displayBackgroundShape:
         m_pImpl->m_bDisplayBackgroundShape = nIntValue;
         break;
+    case NS_ooxml::LN_CT_Compat_noLeading:
+        m_pImpl->m_bNoLeading = nIntValue != 0;
+        break;
     default:
     {
 #ifdef DBG_UTIL
@@ -851,6 +855,11 @@ bool SettingsTable::GetLongerSpaceSequence() const
     return m_pImpl->m_bLongerSpaceSequence;
 }
 
+bool SettingsTable::GetNoLeading() const
+{
+    return m_pImpl->m_bNoLeading;
+}
+
 }//namespace dmapper
 } //namespace writerfilter
 
diff --git a/writerfilter/source/dmapper/SettingsTable.hxx 
b/writerfilter/source/dmapper/SettingsTable.hxx
index e8cbe8abaf6e..e058420c27db 100644
--- a/writerfilter/source/dmapper/SettingsTable.hxx
+++ b/writerfilter/source/dmapper/SettingsTable.hxx
@@ -77,6 +77,7 @@ class SettingsTable : public LoggedProperties, public 
LoggedTable
     bool GetProtectForm() const;
     bool GetReadOnly() const;
     bool GetLongerSpaceSequence() const;
+    bool GetNoLeading() const;
     bool GetNoHyphenateCaps() const;
     sal_Int16 GetHypenationZone() const;
 
commit 968a7e3247169489d29cc7de0079eea12a663870
Author:     Michael Stahl <michael.st...@cib.de>
AuthorDate: Tue Apr 14 17:42:06 2020 +0200
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Wed Apr 15 11:29:15 2020 +0200

    sw: DOCX export: export AddExternalLeading as w:noLeading
    
    For 11pt Arial, can fit 59 paragraphs on a page vs. 57...
    
    This is annoyingly complicated by the fact that Word 2013 ignores
    w:noLeading element if compatibilityMode is 15.
    
    Change-Id: Ie3093eabba45cdf6e7903ed860f5bad24dcc0323
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92208
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@cib.de>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 95fcebbf9c42..ee4b35698533 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -1119,10 +1119,11 @@ DECLARE_OOXMLEXPORT_TEST(tdf106843, "tdf106843.fodt")
         assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit",  
             "trackedChanges");
         assertXPath(pXmlSettings, "/w:settings/w:documentProtection", 
"enforcement",        "1");
 
-        // LO intends to export a .docx format that is natively compatible 
with 2013.
+        // LO intends to export a .docx format that is natively compatible 
with 2013
+        // but this document has an implicitly added setting 
AddExternalLeading = false
         assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", 
"name", "compatibilityMode");
         assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", 
"uri", "http://schemas.microsoft.com/office/word";);
-        assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", 
"val", "15"); // compatible with 2003/2016/2019
+        assertXPath(pXmlSettings, "/w:settings/w:compat/w:compatSetting[1]", 
"val", "14"); // compatible with 2010
     }
 }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index a8ed8e88a47d..10afeb9fd918 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3770,6 +3770,15 @@ sal_Int32 lcl_getWordCompatibilityMode( const SwDoc& 
rDoc )
         }
     }
 
+    // TODO: this is duplicative, better store it in DocxExport member?
+    if 
(!rDoc.getIDocumentSettingAccess().get(DocumentSettingId::ADD_EXT_LEADING))
+    {
+        if (nWordCompatibilityMode == -1 || 14 < nWordCompatibilityMode)
+        {
+            nWordCompatibilityMode = 14;
+        }
+    }
+
     return nWordCompatibilityMode;
 }
 
diff --git a/sw/source/filter/ww8/docxexport.cxx 
b/sw/source/filter/ww8/docxexport.cxx
index 035f50cbeaac..b18d94410027 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -944,6 +944,25 @@ void DocxExport::WriteDocVars(const 
sax_fastparser::FSHelperPtr& pFS)
     }
 }
 
+static auto
+WriteCompat(SwDoc const& rDoc, ::sax_fastparser::FSHelperPtr const& rpFS,
+        sal_Int32 & rTargetCompatibilityMode) -> void
+{
+    if 
(!rDoc.getIDocumentSettingAccess().get(DocumentSettingId::ADD_EXT_LEADING))
+    {
+        rpFS->singleElementNS(XML_w, XML_noLeading);
+        if (rTargetCompatibilityMode > 14)
+        {   // Word ignores noLeading in compatibilityMode 15
+            rTargetCompatibilityMode = 14;
+        }
+    }
+    // Do not justify lines with manual break
+    if 
(rDoc.getIDocumentSettingAccess().get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK))
+    {
+        rpFS->singleElementNS(XML_w, XML_doNotExpandShiftReturn);
+    }
+}
+
 void DocxExport::WriteSettings()
 {
     SwViewShell 
*pViewShell(m_pDoc->getIDocumentLayoutAccess().GetCurrentViewShell());
@@ -1027,14 +1046,6 @@ void DocxExport::WriteSettings()
         pFS->singleElementNS( XML_w, XML_defaultTabStop, FSNS( XML_w, XML_val 
),
             OString::number(m_aSettings.defaultTabStop) );
 
-    // Do not justify lines with manual break
-    if( m_pDoc->getIDocumentSettingAccess().get( 
DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK ))
-    {
-        pFS->startElementNS(XML_w, XML_compat);
-        pFS->singleElementNS(XML_w, XML_doNotExpandShiftReturn);
-        pFS->endElementNS( XML_w, XML_compat );
-    }
-
     // export current mail merge database and table names
     SwDBData aData = m_pDoc->GetDBData();
     if ( !aData.sDataSource.isEmpty() && aData.nCommandType == 
css::sdb::CommandType::TABLE && !aData.sCommand.isEmpty() )
@@ -1121,7 +1132,7 @@ void DocxExport::WriteSettings()
      * 2.) Many years later, change the TargetCompatilityMode for new 
documents, when we no longer care
      *     about working with perfect compatibility with older versions of MS 
Word.
      */
-    const sal_Int32 nTargetCompatibilityMode = 15; //older versions might not 
open our files well
+    sal_Int32 nTargetCompatibilityMode = 15; //older versions might not open 
our files well
     bool bHasCompatibilityMode = false;
     const OUString aGrabBagName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
     if ( xPropSetInfo->hasPropertyByName( aGrabBagName ) )
@@ -1154,6 +1165,8 @@ void DocxExport::WriteSettings()
             {
                 pFS->startElementNS(XML_w, XML_compat);
 
+                WriteCompat(*m_pDoc, pFS, nTargetCompatibilityMode);
+
                 uno::Sequence< beans::PropertyValue > aCompatSettingsSequence;
                 rProp.Value >>= aCompatSettingsSequence;
 
@@ -1282,6 +1295,9 @@ void DocxExport::WriteSettings()
     if ( !bHasCompatibilityMode )
     {
         pFS->startElementNS(XML_w, XML_compat);
+
+        WriteCompat(*m_pDoc, pFS, nTargetCompatibilityMode);
+
         pFS->singleElementNS( XML_w, XML_compatSetting,
             FSNS( XML_w, XML_name ), "compatibilityMode",
             FSNS( XML_w, XML_uri ),  
"http://schemas.microsoft.com/office/word";,
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to