summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/core/data/table2.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 9839763e8a14..2a288c46423f 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1656,7 +1656,9 @@ CommentCaptionState ScTable::GetAllNoteCaptionsState(const ScRange& rRange, std:
bool bIsFirstNoteShownState = true; // because of error: -Werror=maybe-uninitialized
bool bFirstControl = true;
- for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol)
+ ScTable* pTab = pDocument->FetchTable(nTab);
+ const SCCOL nEndCol = pTab->ClampToAllocatedColumns(rRange.aEnd.Col());
+ for (SCCOL nCol = rRange.aStart.Col(); nCol <= nEndCol; ++nCol)
{
if (bFirstControl && pDocument->HasColNotes(nCol, nTab)) // detect status of first note caption
{