summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/ui/view/viewfun2.cxx25
1 files changed, 14 insertions, 11 deletions
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 17504f88f3fa..6cc498991e36 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -744,17 +744,20 @@ String ScViewFunc::GetAutoSumFormula( const ScRangeList& rRangeList, bool bSubTo
pArray->AddOpCode(ocSep);
}
- ScRangeList aRangeList = rRangeList;
- const ScRange* pFirst = aRangeList.front();
- size_t ListSize = aRangeList.size();
- for ( size_t i = 0; i < ListSize; ++i )
- {
- const ScRange* p = aRangeList[i];
- if (p != pFirst)
- pArray->AddOpCode(ocSep);
- ScComplexRefData aRef;
- aRef.InitRangeRel(*p, rAddr);
- pArray->AddDoubleReference(aRef);
+ if(!rRangeList.empty())
+ {
+ ScRangeList aRangeList = rRangeList;
+ const ScRange* pFirst = aRangeList.front();
+ size_t ListSize = aRangeList.size();
+ for ( size_t i = 0; i < ListSize; ++i )
+ {
+ const ScRange* p = aRangeList[i];
+ if (p != pFirst)
+ pArray->AddOpCode(ocSep);
+ ScComplexRefData aRef;
+ aRef.InitRangeRel(*p, rAddr);
+ pArray->AddDoubleReference(aRef);
+ }
}
pArray->AddOpCode(ocClose);