sc/source/filter/excel/xistyle.cxx |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 3a5e1b44dc816184cc9bffc3f02b4d338a5c2e1a
Author:     Karthik Godha <[email protected]>
AuthorDate: Wed Jan 14 19:56:54 2026 +0530
Commit:     Michael Stahl <[email protected]>
CommitDate: Wed Feb 4 18:38:07 2026 +0100

    XLS -> XLSX: Discard overlapping merge ranges
    
    bug document: forum-en-5338.xls
    
    Change-Id: I5da6b650ae1c73606c6688210ba65f28920eeed4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197273
    Reviewed-by: Michael Stahl <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    (cherry picked from commit bea351faaf18f1c12fddc8aab13dcc840505667e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198418
    Tested-by: Jenkins

diff --git a/sc/source/filter/excel/xistyle.cxx 
b/sc/source/filter/excel/xistyle.cxx
index 1c5bb56b36fa..e1a64e4d29dc 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -1995,8 +1995,14 @@ void XclImpXFRangeBuffer::SetHyperlink( const XclRange& 
rXclRange, const OUStrin
 
 void XclImpXFRangeBuffer::SetMerge( SCCOL nScCol1, SCROW nScRow1, SCCOL 
nScCol2, SCROW nScRow2 )
 {
-    if( (nScCol1 < nScCol2) || (nScRow1 < nScRow2) )
-        maMergeList.push_back( ScRange( nScCol1, nScRow1, 0, nScCol2, nScRow2, 
0 ) );
+    if ((nScCol1 < nScCol2) || (nScRow1 < nScRow2))
+    {
+        ScRange aRange(nScCol1, nScRow1, 0, nScCol2, nScRow2, 0);
+        // If merge range intersects with existing merge ranges then discard 
it.
+        if (maMergeList.Intersects(aRange))
+            return;
+        maMergeList.push_back(aRange);
+    }
 }
 
 void XclImpXFRangeBuffer::Finalize()

Reply via email to