officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs |    6 +++
 sw/inc/IDocumentSettingAccess.hxx                                 |    2 +
 sw/inc/strings.hrc                                                |    1 
 sw/inc/viewsh.hxx                                                 |    2 +
 sw/source/core/doc/DocumentSettingManager.cxx                     |   16 
+++++++-
 sw/source/core/inc/DocumentSettingManager.hxx                     |    1 
 sw/source/core/inc/fntcache.hxx                                   |    6 ++-
 sw/source/core/inc/swfont.hxx                                     |   17 
++++++--
 sw/source/core/text/inftxt.hxx                                    |    2 -
 sw/source/core/text/porlay.cxx                                    |    5 +-
 sw/source/core/txtnode/fntcache.cxx                               |   15 
+++++--
 sw/source/core/txtnode/swfont.cxx                                 |    5 +-
 sw/source/core/view/viewsh.cxx                                    |   14 
+++++++
 sw/source/filter/ww8/ww8par.cxx                                   |    2 +
 sw/source/ui/config/optcomp.cxx                                   |    6 +++
 sw/source/uibase/uno/SwXDocumentSettings.cxx                      |   20 
+++++++++-
 sw/source/writerfilter/dmapper/DomainMapper.cxx                   |    3 +
 17 files changed, 103 insertions(+), 20 deletions(-)

New commits:
commit 2155684c819dcdc52968c59276046fb0cad83561
Author:     Jonathan Clark <jonat...@libreoffice.org>
AuthorDate: Thu Sep 19 22:05:08 2024 -0600
Commit:     Jonathan Clark <jonat...@libreoffice.org>
CommitDate: Fri Sep 20 10:43:34 2024 +0200

    tdf#129808 sw: Use ext leading for text grid spacing on DOC import
    
    This change adds a Writer compatibility flag, MS_WORD_COMP_GRID_METRICS.
    When set, Writer will always use the font's external leading when
    calculating line height for text grid, even if ADD_EXT_LEADING is unset.
    
    This change also automatically sets the MS_WORD_COMP_GRID_METRICS
    compatibility flag when importing DOC and DOCX files.
    
    Change-Id: I63a94d7d20354163f1f97745a38e286686d6a4a8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173693
    Tested-by: Jenkins
    Reviewed-by: Jonathan Clark <jonat...@libreoffice.org>

diff --git a/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
index c1fc01658ad3..a421f1f347ae 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
@@ -164,6 +164,12 @@
         </info>
         <value>false</value>
       </prop>
+      <prop oor:name="MsWordCompGridMetrics" oor:type="xs:boolean" 
oor:nillable="false">
+        <info>
+          <desc>Use Word-compatible font metrics for text grid</desc>
+        </info>
+        <value>false</value>
+      </prop>
     </group>
   </templates>
   <component>
diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index 133fd12811b7..53fb5bed5e8f 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -137,6 +137,8 @@ enum class DocumentSettingId
     PAINT_HELL_OVER_HEADER_FOOTER,
     // tdf#155229 calculate minimum row height including horizontal border 
width
     MIN_ROW_HEIGHT_INCL_BORDER,
+    // tdf#129808 MS Word always includes ext leading for text grid line height
+    MS_WORD_COMP_GRID_METRICS,
 };
 
 /** Provides access to settings of a document
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 7724887cc467..96ed8bab484d 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -1496,6 +1496,7 @@
 #define STR_COMPAT_OPT_TABOVERMARGIN            
NC_("STR_COMPAT_OPT_TABOVERMARGIN", "Allow tabs to extend beyond the right 
margin")
 #define STR_COMPAT_OPT_DO_NOT_MIRROR_RTL_DRAW_OBJS 
NC_("STR_COMPAT_OPT_DO_NOT_MIRROR_RTL_DRAW_OBJS", "Do not mirror drawing 
objects anchored in paragraphs with an RTL writing direction")
 #define STR_COMPAT_OPT_CONTINUOUS_ENDNOTES 
NC_("STR_COMPAT_OPT_CONTINUOUS_ENDNOTES", "Render endnotes at the end of 
document inline, rather than on a separate page")
+#define STR_COMPAT_OPT_MSWORDCOMPGRIDMETRICS 
NC_("STR_COMPAT_OPT_MSWORDCOMPGRIDMETRICS", "Use Word-compatible font metrics 
for text grid")
 
 #define STR_TABLE_PANEL_ALIGN_AUTO              
NC_("sidebartableedit|alignautolabel", "Automatic")
 #define STR_TABLE_PANEL_ALIGN_LEFT              
NC_("sidebartableedit|alignleftlabel", "Left")
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 9b4c54a8b444..896a237b27c4 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -455,6 +455,8 @@ public:
 
     SW_DLLPUBLIC void SetContinuousEndnotes(bool bContinuousEndnotes);
 
+    SW_DLLPUBLIC void SetMsWordCompGridMetrics(bool bMsWordCompGridMetrics);
+
     // DOCUMENT COMPATIBILITY FLAGS END
 
     // Calls Idle-formatter of Layout.
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index adcbc033970b..8015878f2357 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -109,7 +109,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc 
&rDoc)
     mbDropCapPunctuation(true),
     mbUseVariableWidthNBSP(false),
     mbPaintHellOverHeaderFooter(false),
-    mbMinRowHeightInclBorder(false)
+    mbMinRowHeightInclBorder(false),
+    mbMsWordCompGridMetrics(false) // tdf#129808
 
     // COMPATIBILITY FLAGS END
 {
@@ -143,6 +144,7 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc 
&rDoc)
         mbTabOverMargin                     = 
aOptions.get(u"TabOverMargin"_ustr);
         mbDoNotMirrorRtlDrawObjs            = 
aOptions.get(u"DoNotMirrorRtlDrawObjs"_ustr);
         mbContinuousEndnotes                = 
aOptions.get(u"ContinuousEndnotes"_ustr);
+        mbMsWordCompGridMetrics             = 
aOptions.get(u"MsWordCompGridMetrics"_ustr);
     }
     else
     {
@@ -270,6 +272,8 @@ bool sw::DocumentSettingManager::get(/*[in]*/ 
DocumentSettingId id) const
         case DocumentSettingId::USE_VARIABLE_WIDTH_NBSP: return 
mbUseVariableWidthNBSP;
         case DocumentSettingId::PAINT_HELL_OVER_HEADER_FOOTER: return 
mbPaintHellOverHeaderFooter;
         case DocumentSettingId::MIN_ROW_HEIGHT_INCL_BORDER: return 
mbMinRowHeightInclBorder;
+        // tdf#129808
+        case DocumentSettingId::MS_WORD_COMP_GRID_METRICS: return 
mbMsWordCompGridMetrics;
         default:
             OSL_FAIL("Invalid setting id");
     }
@@ -586,6 +590,10 @@ void sw::DocumentSettingManager::set(/*[in]*/ 
DocumentSettingId id, /*[in]*/ boo
         case DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND:
             mbFootnoteInColumnToPageEnd = value;
             break;
+        // tdf#129808
+        case DocumentSettingId::MS_WORD_COMP_GRID_METRICS:
+            mbMsWordCompGridMetrics = value;
+            break;
         default:
             OSL_FAIL("Invalid setting id");
     }
@@ -765,6 +773,7 @@ void 
sw::DocumentSettingManager::ReplaceCompatibilityOptions(const DocumentSetti
     mbFootnoteInColumnToPageEnd = rSource.mbFootnoteInColumnToPageEnd;
     mbDropCapPunctuation = rSource.mbDropCapPunctuation;
     mbUseVariableWidthNBSP = rSource.mbUseVariableWidthNBSP;
+    mbMsWordCompGridMetrics = rSource.mbMsWordCompGridMetrics;
 }
 
 sal_uInt32 sw::DocumentSettingManager::Getn32DummyCompatibilityOptions1() const
@@ -1140,6 +1149,11 @@ void 
sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const
                                 
BAD_CAST(OString::boolean(mbDoNotMirrorRtlDrawObjs).getStr()));
     (void)xmlTextWriterEndElement(pWriter);
 
+    (void)xmlTextWriterStartElement(pWriter, 
BAD_CAST("mbMsWordCompGridMetrics"));
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
+                                      
BAD_CAST(OString::boolean(mbMsWordCompGridMetrics).getStr()));
+    (void)xmlTextWriterEndElement(pWriter);
+
     (void)xmlTextWriterEndElement(pWriter);
 }
 
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx 
b/sw/source/core/inc/DocumentSettingManager.hxx
index fd40e8acf22c..f9e1faf9aacd 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -186,6 +186,7 @@ class DocumentSettingManager final :
     bool mbUseVariableWidthNBSP : 1; // tdf#41652
     bool mbPaintHellOverHeaderFooter : 1; // tdf#160198
     bool mbMinRowHeightInclBorder : 1; // tdf#155229
+    bool mbMsWordCompGridMetrics : 1; // tdf#129808
 
 public:
 
diff --git a/sw/source/core/inc/fntcache.hxx b/sw/source/core/inc/fntcache.hxx
index bea6663e1420..6505de2c7b8e 100644
--- a/sw/source/core/inc/fntcache.hxx
+++ b/sw/source/core/inc/fntcache.hxx
@@ -97,8 +97,10 @@ public:
     sal_uInt16 GetExternalLeading() const  { return m_nExtLeading; }
 
     sal_uInt16 GetFontAscent( const SwViewShell *pSh, const OutputDevice& rOut 
);
-    sal_uInt16 GetFontHeight( const SwViewShell *pSh, const OutputDevice& rOut 
);
-    sal_uInt16 GetFontLeading( const SwViewShell *pSh, const OutputDevice& 
rOut );
+    sal_uInt16 GetFontHeight(const SwViewShell* pSh, const OutputDevice& rOut,
+                             bool bIsCJKGridContext = false);
+    sal_uInt16 GetFontLeading(const SwViewShell* pSh, const OutputDevice& rOut,
+                              bool bIsCJKGridContext = false);
     sal_uInt16 GetFontHangingBaseline( const SwViewShell *pSh, const 
OutputDevice& rOut );
 
     void GuessLeading( const SwViewShell& rSh, const FontMetric& rMet );
diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx
index 25453744bd3f..6e4aafef7cc9 100644
--- a/sw/source/core/inc/swfont.hxx
+++ b/sw/source/core/inc/swfont.hxx
@@ -73,7 +73,8 @@ class SwSubFont final : public SvxFont
     bool ChgFnt( SwViewShell const *pSh, OutputDevice& rOut );
     bool IsSymbol( SwViewShell const *pSh );
     sal_uInt16 GetAscent( SwViewShell const *pSh, const OutputDevice& rOut );
-    sal_uInt16 GetHeight( SwViewShell const *pSh, const OutputDevice& rOut );
+    sal_uInt16 GetHeight(SwViewShell const* pSh, const OutputDevice& rOut,
+                         bool bIsCJKGridContext = false);
     sal_uInt16 GetHangingBaseline( SwViewShell const *pSh, const OutputDevice& 
rOut );
     Size GetTextSize_( SwDrawTextInfo& rInf );
     Size GetCapitalSize( SwDrawTextInfo& rInf );
@@ -332,10 +333,16 @@ public:
     short CheckKerning()
         { return m_aSub[m_nActual].CheckKerning(); }
 
-    sal_uInt16 GetAscent( SwViewShell const *pSh, const OutputDevice& rOut )
-        { return m_aSub[m_nActual].GetAscent( pSh, rOut ); }
-    sal_uInt16 GetHeight( SwViewShell const *pSh, const OutputDevice& rOut )
-        { return m_aSub[m_nActual].GetHeight( pSh, rOut ); }
+    sal_uInt16 GetAscent(SwViewShell const* pSh, const OutputDevice& rOut)
+    {
+        return m_aSub[m_nActual].GetAscent(pSh, rOut);
+    }
+
+    sal_uInt16 GetHeight(SwViewShell const* pSh, const OutputDevice& rOut,
+                         bool bIsCJKGridContext = false)
+    {
+        return m_aSub[m_nActual].GetHeight(pSh, rOut, bIsCJKGridContext);
+    }
 
     sal_uInt16 GetHangingBaseline( SwViewShell const *pSh, const OutputDevice& 
rOut )
         { return m_nActual == SwFontScript::CTL ? 
m_aSub[m_nActual].GetHangingBaseline( pSh, rOut ) : 0; }
diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx
index 4a79177366c9..461d7a1261eb 100644
--- a/sw/source/core/text/inftxt.hxx
+++ b/sw/source/core/text/inftxt.hxx
@@ -760,7 +760,7 @@ inline sal_uInt16 SwTextSizeInfo::GetAscent() const
 inline sal_uInt16 SwTextSizeInfo::GetTextHeight() const
 {
     assert(GetOut());
-    return const_cast<SwFont*>(GetFont())->GetHeight( m_pVsh, *GetOut() );
+    return const_cast<SwFont*>(GetFont())->GetHeight(m_pVsh, *GetOut(), 
SnapToGrid());
 }
 
 inline sal_uInt16 SwTextSizeInfo::GetHangingBaseline() const
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 6837ae58539d..923d5286c458 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -561,8 +561,7 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, 
SwTextFormatInfo &rInf )
                                     nPosHeight += nTmp - nPosAscent;
                                     nPosAscent = nTmp;
                                 }
-                                nTmp = rInf.GetFont()->GetHeight( 
rInf.GetVsh(),
-                                                                 
*rInf.GetOut() );
+                                nTmp = rInf.GetTextHeight();
                                 if( nTmp > nPosHeight )
                                     nPosHeight = nTmp;
                             }
@@ -667,7 +666,7 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, 
SwTextFormatInfo &rInf )
 
             if( bOnlyPostIts && !( bHasBlankPortion && bHasOnlyBlankPortions ) 
)
             {
-                Height( rInf.GetFont()->GetHeight( rInf.GetVsh(), 
*rInf.GetOut() ) );
+                Height(rInf.GetTextHeight());
                 mnAscent = rInf.GetFont()->GetAscent( rInf.GetVsh(), 
*rInf.GetOut() );
             }
         }
diff --git a/sw/source/core/txtnode/fntcache.cxx 
b/sw/source/core/txtnode/fntcache.cxx
index a57173c32c61..1e1fc24e0a5f 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -305,7 +305,8 @@ sal_uInt16 SwFntObj::GetFontAscent( const SwViewShell *pSh, 
const OutputDevice&
 
 // Returns the height of the Font on the given output device;
 // it may be necessary to create the screen font first.
-sal_uInt16 SwFntObj::GetFontHeight( const SwViewShell* pSh, const 
OutputDevice& rOut )
+sal_uInt16 SwFntObj::GetFontHeight(const SwViewShell* pSh, const OutputDevice& 
rOut,
+                                   bool bIsCJKGridContext)
 {
     sal_uInt16 nRet = 0;
     const OutputDevice& rRefDev = pSh ? pSh->GetRefDev() : rOut;
@@ -314,7 +315,7 @@ sal_uInt16 SwFntObj::GetFontHeight( const SwViewShell* pSh, 
const OutputDevice&
     {
         CreateScrFont( *pSh, rOut );
         OSL_ENSURE( USHRT_MAX != m_nScrHeight, "nScrHeight is going berzerk" );
-        nRet = m_nScrHeight + GetFontLeading( pSh, rRefDev );
+        nRet = m_nScrHeight + GetFontLeading(pSh, rRefDev, bIsCJKGridContext);
     }
     else
     {
@@ -337,14 +338,15 @@ sal_uInt16 SwFntObj::GetFontHeight( const SwViewShell* 
pSh, const OutputDevice&
             const_cast<OutputDevice&>(rRefDev).SetFont( aOldFnt );
         }
 
-        nRet = m_nPrtHeight + GetFontLeading( pSh, rRefDev );
+        nRet = m_nPrtHeight + GetFontLeading(pSh, rRefDev, bIsCJKGridContext);
     }
 
     OSL_ENSURE( USHRT_MAX != nRet, "GetFontHeight returned USHRT_MAX" );
     return nRet;
 }
 
-sal_uInt16 SwFntObj::GetFontLeading( const SwViewShell *pSh, const 
OutputDevice& rOut )
+sal_uInt16 SwFntObj::GetFontLeading(const SwViewShell* pSh, const 
OutputDevice& rOut,
+                                    bool bIsCJKGridContext)
 {
     sal_uInt16 nRet = 0;
 
@@ -384,8 +386,11 @@ sal_uInt16 SwFntObj::GetFontLeading( const SwViewShell 
*pSh, const OutputDevice&
         const bool bBrowse = ( pSh->GetWin() &&
                                pSh->GetViewOptions()->getBrowseMode() &&
                               !pSh->GetViewOptions()->IsPrtFormat() );
+        const bool bUseRealLeading
+            = rIDSA.get(DocumentSettingId::ADD_EXT_LEADING)
+              || (bIsCJKGridContext && 
rIDSA.get(DocumentSettingId::MS_WORD_COMP_GRID_METRICS));
 
-        if ( !bBrowse && rIDSA.get(DocumentSettingId::ADD_EXT_LEADING) )
+        if (!bBrowse && bUseRealLeading)
             nRet = m_nExtLeading;
         else
             nRet = m_nGuessedLeading;
diff --git a/sw/source/core/txtnode/swfont.cxx 
b/sw/source/core/txtnode/swfont.cxx
index 33a37e6b3caf..0b65fb0af231 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -970,11 +970,12 @@ sal_uInt16 SwSubFont::GetAscent( SwViewShell const *pSh, 
const OutputDevice& rOu
     return GetEscapement() ? CalcEscAscent( nAscent ) : nAscent;
 }
 
-sal_uInt16 SwSubFont::GetHeight( SwViewShell const *pSh, const OutputDevice& 
rOut )
+sal_uInt16 SwSubFont::GetHeight(SwViewShell const* pSh, const OutputDevice& 
rOut,
+                                bool bIsCJKGridContext)
 {
     SV_STAT( nGetTextSize );
     SwFntAccess aFntAccess( m_nFontCacheId, m_nFontIndex, this, pSh );
-    const sal_uInt16 nHeight = aFntAccess.Get()->GetFontHeight( pSh, rOut );
+    const sal_uInt16 nHeight = aFntAccess.Get()->GetFontHeight(pSh, rOut, 
bIsCJKGridContext);
     if ( GetEscapement() )
     {
         const sal_uInt16 nAscent = aFntAccess.Get()->GetFontAscent( pSh, rOut 
);
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 5db3b3a79162..ee06ea0179d7 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1108,6 +1108,20 @@ void SwViewShell::SetContinuousEndnotes(bool 
bContinuousEndnotes)
     }
 }
 
+void SwViewShell::SetMsWordCompGridMetrics(bool _bMsWordCompGridMetrics)
+{
+    IDocumentSettingAccess& rIDSA = getIDocumentSettingAccess();
+    if (rIDSA.get(DocumentSettingId::MS_WORD_COMP_GRID_METRICS) != 
_bMsWordCompGridMetrics)
+    {
+        SwWait aWait(*GetDoc()->GetDocShell(), true);
+        rIDSA.set(DocumentSettingId::MS_WORD_COMP_GRID_METRICS, 
_bMsWordCompGridMetrics);
+        const SwInvalidateFlags nInv = SwInvalidateFlags::PrtArea | 
SwInvalidateFlags::Pos
+                                       | SwInvalidateFlags::Size | 
SwInvalidateFlags::Table
+                                       | SwInvalidateFlags::Section;
+        lcl_InvalidateAllContent(*this, nInv);
+    }
+}
+
 void SwViewShell::Reformat()
 {
     SwWait aWait( *GetDoc()->GetDocShell(), true );
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index f33256aa5cdd..a59c7042968a 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1878,6 +1878,8 @@ void SwWW8ImplReader::ImportDop()
     // tdf#155229 calculate minimum row height including horizontal border 
width
     m_rDoc.getIDocumentSettingAccess().set(
         DocumentSettingId::MIN_ROW_HEIGHT_INCL_BORDER, true);
+    // tdf#129808 use Word-compatible CJK text grid metrics
+    
m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::MS_WORD_COMP_GRID_METRICS,
 true);
 
     // Import Default Tabs
     tools::Long nDefTabSiz = m_xWDop->dxaTab;
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index 10488cf7d36d..61617a82ed6e 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -64,6 +64,7 @@ constexpr std::pair<OUString, TranslateId> options_list[]{
     { u"TabOverMargin"_ustr, STR_COMPAT_OPT_TABOVERMARGIN },
     { u"DoNotMirrorRtlDrawObjs"_ustr, 
STR_COMPAT_OPT_DO_NOT_MIRROR_RTL_DRAW_OBJS },
     { u"ContinuousEndnotes"_ustr, STR_COMPAT_OPT_CONTINUOUS_ENDNOTES },
+    { u"MsWordCompGridMetrics"_ustr, STR_COMPAT_OPT_MSWORDCOMPGRIDMETRICS },
 };
 
 // DocumentSettingId, negate?
@@ -91,6 +92,7 @@ std::pair<DocumentSettingId, bool> 
DocumentSettingForOption(const OUString& opti
         { u"DoNotMirrorRtlDrawObjs"_ustr, { 
DocumentSettingId::DO_NOT_MIRROR_RTL_DRAW_OBJS, false } },
         { u"ContinuousEndnotes"_ustr, { 
DocumentSettingId::CONTINUOUS_ENDNOTES, false } },
 //        { u"AddTableLineSpacing"_ustr, { 
DocumentSettingId::ADD_PARA_LINE_SPACING_TO_TABLE_CELLS, false } },
+        { u"MsWordCompGridMetrics"_ustr, { 
DocumentSettingId::MS_WORD_COMP_GRID_METRICS, false } },
     };
     return map.at(option);
 }
@@ -330,6 +332,10 @@ bool SwCompatibilityOptPage::FillItemSet( SfxItemSet*  )
                         m_pWrtShell->SetContinuousEndnotes(bChecked);
                         break;
 
+                    case DocumentSettingId::MS_WORD_COMP_GRID_METRICS:
+                        m_pWrtShell->SetMsWordCompGridMetrics(bChecked);
+                        break;
+
                     default:
                         break;
                 }
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx 
b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index 99338f8894f3..6baeff0a965a 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -162,7 +162,8 @@ enum SwDocumentSettingsPropertyHandles
     HANDLE_APPLY_TEXT_ATTR_TO_EMPTY_LINE_AT_END_OF_PARAGRAPH,
     HANDLE_DO_NOT_MIRROR_RTL_DRAW_OBJS,
     HANDLE_PAINT_HELL_OVER_HEADER_FOOTER,
-    HANDLE_MIN_ROW_HEIGHT_INCL_BORDER
+    HANDLE_MIN_ROW_HEIGHT_INCL_BORDER,
+    HANDLE_MS_WORD_COMP_GRID_METRICS
 };
 
 }
@@ -272,6 +273,7 @@ static rtl::Reference<MasterPropertySetInfo> 
lcl_createSettingsInfo()
         { u"DoNotMirrorRtlDrawObjs"_ustr, HANDLE_DO_NOT_MIRROR_RTL_DRAW_OBJS, 
cppu::UnoType<bool>::get(), 0 },
         { u"PaintHellOverHeaderFooter"_ustr, 
HANDLE_PAINT_HELL_OVER_HEADER_FOOTER, cppu::UnoType<bool>::get(), 0 },
         { u"MinRowHeightInclBorder"_ustr, HANDLE_MIN_ROW_HEIGHT_INCL_BORDER, 
cppu::UnoType<bool>::get(), 0 },
+        { u"MsWordCompGridMetrics"_ustr, HANDLE_MS_WORD_COMP_GRID_METRICS, 
cppu::UnoType<bool>::get(), 0 },
 
 /*
  * As OS said, we don't have a view when we need to set this, so I have to
@@ -1172,6 +1174,16 @@ void SwXDocumentSettings::_setSingleValue( const 
comphelper::PropertyInfo & rInf
                     DocumentSettingId::MIN_ROW_HEIGHT_INCL_BORDER, bTmp);
         }
         break;
+        case HANDLE_MS_WORD_COMP_GRID_METRICS:
+        {
+            bool bTmp;
+            if (rValue >>= bTmp)
+            {
+                
mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::MS_WORD_COMP_GRID_METRICS,
+                                                       bTmp);
+            }
+        }
+        break;
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
@@ -1760,6 +1772,12 @@ void SwXDocumentSettings::_getSingleValue( const 
comphelper::PropertyInfo & rInf
                 DocumentSettingId::MIN_ROW_HEIGHT_INCL_BORDER);
         }
         break;
+        case HANDLE_MS_WORD_COMP_GRID_METRICS:
+        {
+            rValue <<= mpDoc->getIDocumentSettingAccess().get(
+                DocumentSettingId::MS_WORD_COMP_GRID_METRICS);
+        }
+        break;
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx 
b/sw/source/writerfilter/dmapper/DomainMapper.cxx
index 12cd131002dc..280fcd89231b 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx
@@ -154,6 +154,9 @@ DomainMapper::DomainMapper( const uno::Reference< 
uno::XComponentContext >& xCon
         
m_pImpl->SetDocumentSettingsProperty(u"IgnoreTabsAndBlanksForLineCalculation"_ustr,uno::Any(true));
         // calculate table row height with 'atLeast' including horizontal 
border width
         
m_pImpl->SetDocumentSettingsProperty(u"MinRowHeightInclBorder"_ustr,uno::Any(true));
+
+        // tdf#129808 Enable compatible grid font metrics for documents with 
noLeading
+        m_pImpl->SetDocumentSettingsProperty(u"MsWordCompGridMetrics"_ustr, 
uno::Any(true));
     }
 
     // Initialize RDF metadata, to be able to add statements during the import.

Reply via email to