[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - 8 commits - external/libwpd sax/source sc/qa sc/source sd/source sw/qa sw/source vcl/source xmloff/source

Dennis Francis dennis.francis at collabora.co.uk
Fri Sep 8 09:39:53 UTC 2017


 external/libwpd/UnpackedTarball_libwpd.mk                         |    1 
 external/libwpd/libwpd-tdf112269.patch.1                          |   42 ++++++++++
 sax/source/expatwrap/sax_expat.cxx                                |   15 ++-
 sc/qa/unit/data/xlsm/tdf111974.xlsm                               |binary
 sc/qa/unit/subsequent_filters-test.cxx                            |   10 ++
 sc/source/filter/oox/workbookfragment.cxx                         |    2 
 sd/source/ui/view/sdview4.cxx                                     |    8 +
 sw/qa/core/data/odt/fail/c2dfc5bd-8366-40e7-b862-55e13fdc52dc.odt |binary
 sw/qa/core/data/odt/fail/tdf102018.odt                            |binary
 sw/source/core/text/frmform.cxx                                   |   15 ++-
 sw/source/filter/xml/xmltbli.cxx                                  |    2 
 vcl/source/font/fontmetric.cxx                                    |   25 +++--
 xmloff/source/text/txtparai.cxx                                   |   11 ++
 13 files changed, 106 insertions(+), 25 deletions(-)

New commits:
commit 5f85c70dc299ee27d5d94d6bb3eaabf0aba5fa58
Author: Dennis Francis <dennis.francis at collabora.co.uk>
Date:   Thu Aug 31 14:22:15 2017 +0530

    tdf#111974: Ensure sufficient space for all sheets in FormulaBuffer...
    
    and not just for the number of sheet fragments. This is important
    because we changed the internal storage of FormulaBuffer from based
    on std::map to std::vector in d17a83fa549f828f29e6939b16ba8b568a75f95e
    
    Added simple unit test that loads the bugdoc in
    subsequent_filters-test.cxx
    
    Reviewed-on: https://gerrit.libreoffice.org/41792
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Dennis Francis <dennis.francis at collabora.co.uk>
    (cherry picked from commit 20169423d492b58ab93fb0e8e9d2918c0baebc92)
    
    Reviewed-on: https://gerrit.libreoffice.org/41841
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>
    
     Conflicts:
            sc/qa/unit/subsequent_filters-test.cxx
    
    Backported.
    
    Change-Id: I7320dd537266e540d585d3fccfbb8665bba457c7
    Reviewed-on: https://gerrit.libreoffice.org/42057
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 500b5727fd5902b7d14c6e707c2ad3d2b227bb1a)

diff --git a/sc/qa/unit/data/xlsm/tdf111974.xlsm b/sc/qa/unit/data/xlsm/tdf111974.xlsm
new file mode 100644
index 000000000000..bb6ac6d0a2d3
Binary files /dev/null and b/sc/qa/unit/data/xlsm/tdf111974.xlsm differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 5c5e730ef591..b53803c4e425 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -241,6 +241,7 @@ public:
     void testTdf100458();
     void testTdf100709XLSX();
     void testTdf97598XLSX();
+    void testTdf111974XLSM();
 
     CPPUNIT_TEST_SUITE(ScFiltersTest);
     CPPUNIT_TEST(testBooleanFormatXLSX);
@@ -359,6 +360,7 @@ public:
     CPPUNIT_TEST(testTdf100458);
     CPPUNIT_TEST(testTdf100709XLSX);
     CPPUNIT_TEST(testTdf97598XLSX);
+    CPPUNIT_TEST(testTdf111974XLSM);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -3778,6 +3780,14 @@ void ScFiltersTest::testColumnStyle2XLSX()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testTdf111974XLSM()
+{
+    // Would crash without the fix on loading
+    ScDocShellRef xDocSh = loadDoc("tdf111974.", FORMAT_XLSM);
+    CPPUNIT_ASSERT_MESSAGE("Failed to open doc", xDocSh.Is());
+    xDocSh->DoClose();
+}
+
 void ScFiltersTest::testBnc762542()
 {
     ScDocShellRef xDocSh = loadDoc("bnc762542.", FORMAT_XLSX);
diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx
index 53ae02fc26b9..37e196aae1d5 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -452,7 +452,7 @@ void WorkbookFragment::finalizeImport()
     }
 
     // setup structure sizes for the number of sheets
-    getFormulaBuffer().SetSheetCount( aSheetFragments.size() );
+    getFormulaBuffer().SetSheetCount( nWorksheetCount );
 
     // create all database ranges and defined names, in that order
     getTables().finalizeImport();
commit 2b94af6b30700434b82eaaa0a49e35f42b32fa4b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Sep 7 13:37:30 2017 +0100

    Resolves: tdf#112269 libwpd fix
    
    Change-Id: I0d8d6887fa360c05d5f9e2a070410c77926b9ce1
    Reviewed-on: https://gerrit.libreoffice.org/42056
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: David Tardon <dtardon at redhat.com>
    (cherry picked from commit 05da1c67e49a2d758799db735a826c4d292fea44)

diff --git a/external/libwpd/UnpackedTarball_libwpd.mk b/external/libwpd/UnpackedTarball_libwpd.mk
index 7fb7c3b2181d..495824d804b5 100644
--- a/external/libwpd/UnpackedTarball_libwpd.mk
+++ b/external/libwpd/UnpackedTarball_libwpd.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libwpd,0))
 $(eval $(call gb_UnpackedTarball_add_patches,libwpd,\
 	external/libwpd/libwpd-vs2013.patch.1 \
 	$(if $(SYSTEM_REVENGE),,external/libwpd/rpath.patch) \
+	external/libwpd/libwpd-tdf112269.patch.1 \
 ))
 
 ifneq ($(OS),MACOSX)
diff --git a/external/libwpd/libwpd-tdf112269.patch.1 b/external/libwpd/libwpd-tdf112269.patch.1
new file mode 100644
index 000000000000..bc79ab0eaccd
--- /dev/null
+++ b/external/libwpd/libwpd-tdf112269.patch.1
@@ -0,0 +1,42 @@
+--- libwpd/src/lib/WP5StylesListener.cpp
++++ libwpd/src/lib/WP5StylesListener.cpp
+@@ -85,8 +85,9 @@
+ 		m_currentPage = WPXPageSpan(m_pageList.back(), 0.0, 0.0);
+ 		m_currentPage.setPageSpan(1);
+ 
+-		for (std::vector<WPXHeaderFooter>::const_iterator HFiter = (m_nextPage.getHeaderFooterList()).begin();
+-		        HFiter != (m_nextPage.getHeaderFooterList()).end(); ++HFiter)
++		std::vector<WPXHeaderFooter> headerFooterList = m_nextPage.getHeaderFooterList();
++		for (std::vector<WPXHeaderFooter>::const_iterator HFiter = headerFooterList.begin();
++		        HFiter != headerFooterList.end(); ++HFiter)
+ 		{
+ 			if ((*HFiter).getOccurrence() != NEVER)
+ 			{
+--- libwpd/src/lib/WP42StylesListener.cpp
++++ libwpd/src/lib/WP42StylesListener.cpp
+@@ -84,8 +84,9 @@
+ 			m_currentPage = WPXPageSpan(m_pageList.back(), 0.0, 0.0);
+ 			m_currentPage.setPageSpan(1);
+ 
+-			for (std::vector<WPXHeaderFooter>::const_iterator HFiter = (m_nextPage.getHeaderFooterList()).begin();
+-			        HFiter != (m_nextPage.getHeaderFooterList()).end(); ++HFiter)
++			std::vector<WPXHeaderFooter> headerFooterList = m_nextPage.getHeaderFooterList();
++			for (std::vector<WPXHeaderFooter>::const_iterator HFiter = headerFooterList.begin();
++			        HFiter != headerFooterList.end(); ++HFiter)
+ 			{
+ 				if ((*HFiter).getOccurrence() != NEVER)
+ 				{
+--- libwpd/src/lib/WP1StylesListener.cpp
++++ libwpd/src/lib/WP1StylesListener.cpp
+@@ -83,8 +83,9 @@
+ 			m_currentPage = WPXPageSpan(m_pageList.back(), 0.0, 0.0);
+ 			m_currentPage.setPageSpan(1);
+ 
+-			for (std::vector<WPXHeaderFooter>::const_iterator HFiter = (m_nextPage.getHeaderFooterList()).begin();
+-			        HFiter != (m_nextPage.getHeaderFooterList()).end(); ++HFiter)
++			std::vector<WPXHeaderFooter> headerFooterList = m_nextPage.getHeaderFooterList();
++			for (std::vector<WPXHeaderFooter>::const_iterator HFiter = headerFooterList.begin();
++			        HFiter != headerFooterList.end(); ++HFiter)
+ 			{
+ 				if ((*HFiter).getOccurrence() != NEVER)
+ 				{
commit fbad743a075b956f24e5f2f3d5fa5c6145d252dd
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Sep 6 23:18:23 2017 +0200

    tdf#112163 sw: avoid crashing in layout on this document
    
    SwTextFrame 0x5dfb7a0 is join locked so doesn't GetFormatted() so
    doesn't have a SwTextLineAccess created; add some defensive programming
    just to make it not crash.
    
    Whether this is the right fix or just a workaround for something going
    wrong in the 179 layout stack frames is beyond my meager knowledge.
    
    In case anybody has an obvious idea, the layout frames that are
    currently being formatted (SwTextFrame or SwTabFrame) are:
    
     #3 0x5dfb7a0 is master of 0x5e56330
    
     #4 0x5e56330
    
     #10 0x5e5f3f0 is follow of 0x5e56330
    
     #19 0x5e60d30 SwTabFrame::Split
    
     #30 0x5e56330
    
     #44 0x5dfb7a0
    
     #53 0x2cefae0 master of 0x5dfb7a0
    
     #57 0x63d1440 SwTabFrame::MakeAll is follow of #58
    
     #58 0x5e106c0 SwTabFrame::MakeAll
    
     #68 0x5e812d0
    
     #77 0x5e11f80 is master of #68
    
     #86 0x2cef600 is master of #77
    
     #90 0x5f86c00 SwTabFrame::MakeAll
    
     #91 0x63d0150 SwTabFrame::MakeAll
    
     #98 SwFlowFrame::MoveFwd
     #101 0x63cf3d0
    
     #110 0x5e05ff0 is master of #101
    
     #119 0x5e0c700 is master of #110
    
     #128 0x5bd0ad0 is master of #119
    
     #136 0x5f8b800 is master of #128
    
     #145 0x86b29a0 is master of #136
    
     #154 0x2c37340 is master of #145
    
     #158 0x5e04ab0 SwTabFrame::MakeAll
    
     #168 0x2c371a0
    
     #173 0x5e16340 SwTabFrame::MakeAll
    
    Change-Id: I716b5faec1512cbf1fbdb04a436da302bd628c51
    (cherry picked from commit 6c8c51231e7415ecc20d1343211acf8382666613)
    Reviewed-on: https://gerrit.libreoffice.org/42041
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit b8e84ac201f5611635177f8404c28f7fa8d0c806)

diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index 7cd2940a80bd..e25792532a13 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -1401,10 +1401,17 @@ void SwTextFrame::Format_( SwTextFormatter &rLine, SwTextFormatInfo &rInf,
         {
             if( !pMaster->HasPara() )
                 pMaster->GetFormatted();
-            SwTextSizeInfo aInf( pMaster );
-            SwTextIter aMasterLine( pMaster, &aInf );
-            aMasterLine.Bottom();
-            pLine = aMasterLine.GetCurr();
+            if (!pMaster->HasPara())
+            {   // master could be locked because it's being formatted upstack
+                SAL_WARN("sw", "SwTextFrame::Format_: failed to format master!");
+            }
+            else
+            {
+                SwTextSizeInfo aInf( pMaster );
+                SwTextIter aMasterLine( pMaster, &aInf );
+                aMasterLine.Bottom();
+                pLine = aMasterLine.GetCurr();
+            }
         }
         SwLinePortion* pRest = pLine ?
             rLine.MakeRestPortion(pLine, GetOfst()) : nullptr;
commit 39f0742222b203726c2d314877729de1f9d4d938
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Sep 5 22:01:12 2017 +0200

    tdf#112164 sax: handle errors on last call to XML_Parse()
    
    If XML_Parse() is called with isFinal=1 and there are open tags, that is
    an error (XML_ERROR_NO_ELEMENTS) that must be converted to an exception.
    
    This reveals that we already had an incomplete input document, which
    needs to be moved to "fail" now.
    
    (cherry picked from commit e530a7ddb1c9423487ce936e6b23b8e36449d555)
    
    tdf#112164 add test document
    (cherry picked from commit aad2cdce2a2e89f35366c55878129d268cc92bef)
    
    Change-Id: I7ce3b51bd87923b5edde621508cf38d7ebbc2b14
    Reviewed-on: https://gerrit.libreoffice.org/41965
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 3604ca211204b9a0971a65c96a5075ba43f15693)

diff --git a/sax/source/expatwrap/sax_expat.cxx b/sax/source/expatwrap/sax_expat.cxx
index ba87c6f9e146..dfe2246eec19 100644
--- a/sax/source/expatwrap/sax_expat.cxx
+++ b/sax/source/expatwrap/sax_expat.cxx
@@ -670,18 +670,23 @@ void SaxExpatParser_Impl::parse( )
     while( nRead ) {
         nRead = getEntity().converter.readAndConvert( seqOut , nBufSize );
 
+        bool bContinue(false);
+
         if( ! nRead ) {
-            XML_Parse( getEntity().pParser ,
+            // last call - must return OK
+            XML_Status const ret = XML_Parse( getEntity().pParser,
                                    reinterpret_cast<const char *>(seqOut.getConstArray()),
                                    0 ,
                                    1 );
-            break;
-        }
-
-        bool bContinue = ( XML_Parse( getEntity().pParser ,
+            if (ret == XML_STATUS_OK) {
+                break;
+            }
+        } else {
+            bContinue = ( XML_Parse( getEntity().pParser,
                                                 reinterpret_cast<const char *>(seqOut.getConstArray()),
                                                 nRead,
                                                 0 ) != XML_STATUS_ERROR );
+        }
 
         if( ! bContinue || this->bExceptionWasThrown ) {
 
diff --git a/sw/qa/core/data/odt/fail/c2dfc5bd-8366-40e7-b862-55e13fdc52dc.odt b/sw/qa/core/data/odt/fail/c2dfc5bd-8366-40e7-b862-55e13fdc52dc.odt
new file mode 100644
index 000000000000..7cafa8d5e19b
Binary files /dev/null and b/sw/qa/core/data/odt/fail/c2dfc5bd-8366-40e7-b862-55e13fdc52dc.odt differ
diff --git a/sw/qa/core/data/odt/pass/tdf102018.odt b/sw/qa/core/data/odt/fail/tdf102018.odt
similarity index 100%
rename from sw/qa/core/data/odt/pass/tdf102018.odt
rename to sw/qa/core/data/odt/fail/tdf102018.odt
commit 2df9df2b616467672d85b9374b31a8547da3ef1a
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Aug 31 15:15:41 2017 +0200

    tdf#112122 xmloff: inserting index marks into editengine throws
    
    Catch the exception, since that isn't even invalid input, editengine
    just can't do it.
    
    Change-Id: I362923889add4f1a1d3f8f18b0795993119d54b1
    (cherry picked from commit 98552e46521b012e7694c056eca956ae4ee27a0c)
    Reviewed-on: https://gerrit.libreoffice.org/41759
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 037d5fa9b129a4060f8f572cb72801b7dfa1608f)

diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx
index f2fad10da496..76d759f37f11 100644
--- a/xmloff/source/text/txtparai.cxx
+++ b/xmloff/source/text/txtparai.cxx
@@ -2110,8 +2110,15 @@ XMLParaContext::~XMLParaContext()
                     Reference<beans::XPropertySet> xMark(
                         static_cast<const XMLIndexMarkHint_Impl *>(pHint)->GetMark());
                     Reference<XTextContent> xContent(xMark, UNO_QUERY);
-                    xTxtImport->GetText()->insertTextContent(
-                        xAttrCursor, xContent, true );
+                    try
+                    {
+                        xTxtImport->GetText()->insertTextContent(
+                            xAttrCursor, xContent, true );
+                    }
+                    catch (uno::RuntimeException const& e)
+                    {
+                        SAL_INFO("xmloff.text", "could not insert index mark, presumably in editengine text " << e.Message);
+                    }
                 }
                 break;
             case XML_HINT_TEXT_FRAME:
commit 149cdbca68e00b6ce807ba1719d5ce6a5dc35803
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Sat Sep 2 06:19:05 2017 +0200

    tdf#109261: Crash when adding a video to a slide with zero undo steps
    
    When undo is disabled (no undo steps), ReplaceObjectAtView()
    method frees pPickObj, so we need to save it's reused data first.
    
    Reviewed-on: https://gerrit.libreoffice.org/41822
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 27068e6cc39aed8ebfa5fdd7a67acb89f5adcb89)
    
    Change-Id: Icbc800d4d33cf229006aecde7d62aa2a7ea35879
    Reviewed-on: https://gerrit.libreoffice.org/41861
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit 3ce90f78ed77c76ec6e0af3731f2fb37628ef89c)

diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx
index 96a2ffc5363c..63f8260e4aac 100644
--- a/sd/source/ui/view/sdview4.cxx
+++ b/sd/source/ui/view/sdview4.cxx
@@ -341,8 +341,12 @@ SdrMediaObj* View::InsertMediaObj( const OUString& rMediaURL, const OUString& rM
     else if( pPV )
     {
         Rectangle aRect( rPos, rSize );
+        SdrObjUserCall* pUserCall = nullptr;
         if( pPickObj )
+        {
             aRect = pPickObj->GetLogicRect();
+            pUserCall = pPickObj->GetUserCall(); // ReplaceObjectAtView can free pPickObj
+        }
 
         pNewMediaObj = new SdrMediaObj( aRect );
 
@@ -371,9 +375,9 @@ SdrMediaObj* View::InsertMediaObj( const OUString& rMediaURL, const OUString& rM
 
         if( pPickObj )
         {
-            pNewMediaObj->AdjustToMaxRect( pPickObj->GetLogicRect() );
+            pNewMediaObj->AdjustToMaxRect( aRect );
             if( bIsPres )
-                pNewMediaObj->SetUserCall(pPickObj->GetUserCall());
+                pNewMediaObj->SetUserCall( pUserCall );
         }
     }
 
commit 7b5d0439b7cb7255167e5bf572a4a72868db5d82
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Aug 29 12:27:23 2017 +0100

    Resolves: tdf#112018 number-columns-repeated has the data type positiveInteger
    
    Change-Id: I534885fe7a36a8e3ad891a3f5ed50b589f36e3b9
    Reviewed-on: https://gerrit.libreoffice.org/41692
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 3415764d00044a19568b3a1b5d5382c73a0342c9)
    Reviewed-on: https://gerrit.libreoffice.org/41964
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit eab61f66c6cfa4b290c8789a375e6894be054f32)

diff --git a/sw/qa/core/data/odt/pass/tdf102018.odt b/sw/qa/core/data/odt/pass/tdf102018.odt
new file mode 100644
index 000000000000..d804aec11df0
Binary files /dev/null and b/sw/qa/core/data/odt/pass/tdf102018.odt differ
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index 05d0d15f4e35..b44a68cb47ce 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -770,7 +770,7 @@ SwXMLTableColContext_Impl::SwXMLTableColContext_Impl(
             if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
                 aStyleName = rValue;
             else if( IsXMLToken( aLocalName, XML_NUMBER_COLUMNS_REPEATED ) )
-                nColRep = (sal_uInt32)rValue.toInt32();
+                nColRep = (sal_uInt32)std::max<sal_Int32>(1, rValue.toInt32());
             else if( IsXMLToken( aLocalName, XML_DEFAULT_CELL_STYLE_NAME ) )
                 aDfltCellStyleName = rValue;
         }
commit 42e0338f5ca1edb3a49d80eb061218a9771689dd
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Sep 5 15:24:26 2017 +0100

    Resolves: tdf#107249 round ascent/descent/extleading on conversion to int
    
    Reviewed-on: https://gerrit.libreoffice.org/41944
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 0c8b749e602b6743857a9bc4efb24b6183690311)
    
    Change-Id: Ia3ab5960d5288f5831aaa4ade800ca7513dad766
    Reviewed-on: https://gerrit.libreoffice.org/41956
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
    (cherry picked from commit e0ea7df25faeaae9f98ebde32f49eec92603d629)

diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx
index 3d7bf9a0b375..b48b0aaca348 100644
--- a/vcl/source/font/fontmetric.cxx
+++ b/vcl/source/font/fontmetric.cxx
@@ -448,6 +448,7 @@ void ImplFontMetricData::ImplCalcLineSpacing(const std::vector<uint8_t>& rHheaDa
     mnAscent = mnDescent = mnExtLeading = mnIntLeading = 0;
 
     double fScale = static_cast<double>(mnHeight) / nUPEM;
+    double fAscent = 0, fDescent = 0, fExtLeading = 0;
 
     vcl::TTGlobalFontInfo rInfo;
     memset(&rInfo, 0, sizeof(vcl::TTGlobalFontInfo));
@@ -456,30 +457,34 @@ void ImplFontMetricData::ImplCalcLineSpacing(const std::vector<uint8_t>& rHheaDa
     // Try hhea table first.
     if (rInfo.ascender || rInfo.descender)
     {
-        mnAscent     =  rInfo.ascender  * fScale;
-        mnDescent    = -rInfo.descender * fScale;
-        mnExtLeading =  rInfo.linegap   * fScale;
+        fAscent     = rInfo.ascender  * fScale;
+        fDescent    = -rInfo.descender * fScale;
+        fExtLeading = rInfo.linegap   * fScale;
     }
 
     // But if OS/2 is present, prefer it.
     if (rInfo.winAscent || rInfo.winDescent || rInfo.typoAscender || rInfo.typoDescender)
     {
-        if (mnAscent == 0 && mnDescent == 0)
+        if (fAscent == 0 && fDescent == 0)
         {
-            mnAscent     = rInfo.winAscent  * fScale;
-            mnDescent    = rInfo.winDescent * fScale;
-            mnExtLeading = 0;
+            fAscent     = rInfo.winAscent  * fScale;
+            fDescent    = rInfo.winDescent * fScale;
+            fExtLeading = 0;
         }
 
         const uint16_t kUseTypoMetricsMask = 1 << 7;
         if (rInfo.fsSelection & kUseTypoMetricsMask)
         {
-            mnAscent     =  rInfo.typoAscender  * fScale;
-            mnDescent    = -rInfo.typoDescender * fScale;
-            mnExtLeading =  rInfo.typoLineGap   * fScale;
+            fAscent     =  rInfo.typoAscender  * fScale;
+            fDescent    = -rInfo.typoDescender * fScale;
+            fExtLeading =  rInfo.typoLineGap   * fScale;
         }
     }
 
+    mnAscent = round(fAscent);
+    mnDescent = round(fDescent);
+    mnExtLeading = round(fExtLeading);
+
     if (mnAscent || mnDescent)
         mnIntLeading = mnAscent + mnDescent - mnHeight;
 


More information about the Libreoffice-commits mailing list