sc/inc/refdata.hxx              |    2 +-
 sc/source/core/tool/refdata.cxx |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 1e022eb12e1222d6d9c6d127a18b0ed8fd49b6c0
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Mon Jun 6 17:00:31 2022 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Mon Jun 6 17:55:58 2022 +0200

    ScSingleRefData::TabValid: for absolute reference take sheets into account
    
    Change-Id: I56e7e34f127345e2633b5bef07c2783ed8ffbbfe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135456
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 4cc296a0a394..d893248ba0bc 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -94,7 +94,7 @@ public:
     bool Valid(const ScDocument& rDoc) const;
     bool ColValid(const ScDocument& rDoc) const;
     bool RowValid(const ScDocument& rDoc) const;
-    bool TabValid() const;
+    bool TabValid(const ScDocument& rDoc) const;
     /** In external references nTab is -1 if the external document was not
         loaded but the sheet was cached, or >=0 if the external document was
         loaded. */
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 8bd55dfc92ec..3e1b9b1af8be 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -129,7 +129,7 @@ bool ScSingleRefData::IsDeleted() const
 
 bool ScSingleRefData::Valid(const ScDocument& rDoc) const
 {
-    return !IsDeleted() && ColValid(rDoc) && RowValid(rDoc) && TabValid();
+    return !IsDeleted() && ColValid(rDoc) && RowValid(rDoc) && TabValid(rDoc);
 }
 
 bool ScSingleRefData::ColValid(const ScDocument& rDoc) const
@@ -164,7 +164,7 @@ bool ScSingleRefData::RowValid(const ScDocument& rDoc) const
     return true;
 }
 
-bool ScSingleRefData::TabValid() const
+bool ScSingleRefData::TabValid(const ScDocument& rDoc) const
 {
     if (Flags.bTabRel)
     {
@@ -173,7 +173,7 @@ bool ScSingleRefData::TabValid() const
     }
     else
     {
-        if (mnTab < 0 || MAXTAB < mnTab)
+        if (mnTab < 0 || rDoc.GetTableCount() <= mnTab)
             return false;
     }
 

Reply via email to