summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-06-15 15:15:52 +0200
committerEike Rathke <erack@redhat.com>2017-06-15 15:49:15 +0200
commitd48ea7a1db4eaae0bae094f2155dcd3bc87720eb (patch)
treeb4736d7aeb1cf3591f08f8bbf488af7d75eff659
parent1d0890bb241d7ef3d52057e3d2715277d081b0e5 (diff)
Prevent excess rows included in the resulting range list, tdf#95883 follow-up
Change-Id: Id2fdffa4d7bba8225ea5fcf583a562467342ad3d Reviewed-on: https://gerrit.libreoffice.org/38728 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/inc/attarray.hxx7
-rw-r--r--sc/source/core/data/attarray.cxx7
-rw-r--r--sc/source/core/data/column4.cxx23
3 files changed, 32 insertions, 5 deletions
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index bfa224cbc791..7504610f6a06 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -122,7 +122,14 @@ public:
bool Concat(SCSIZE nPos);
const ScPatternAttr* GetPattern( SCROW nRow ) const;
+
+ /** Returns if you search for attributes at nRow the range from rStartRow
+ to rEndRow where that attribute combination (ScPatternAttr) is applied.
+ The next ScPatternAttr different from this one starts at rEndRow+1
+ (if that is <= MAXROW).
+ */
const ScPatternAttr* GetPatternRange( SCROW& rStartRow, SCROW& rEndRow, SCROW nRow ) const;
+
void MergePatternArea( SCROW nStartRow, SCROW nEndRow, ScMergePatternState& rState, bool bDeep ) const;
void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner, ScLineFlags& rFlags,
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 28fd7e5681a4..7ef3044ed633 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -211,6 +211,13 @@ bool ScAttrArray::Concat(SCSIZE nPos)
return bRet;
}
+/*
+ * nCount is the number of runs of different attribute combinations;
+ * no attribute in a column => nCount==1, one attribute somewhere => nCount == 3
+ * (ie. one run with no attribute + one attribute + another run with no attribute)
+ * so a range of identical attributes is only one entry in ScAttrArray.
+ */
+
bool ScAttrArray::Search( SCROW nRow, SCSIZE& nIndex ) const
{
long nHi = static_cast<long>(nCount) - 1;
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 3541c8fced6b..cafe77043671 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -769,21 +769,34 @@ void ScColumn::GetNotesInRange(SCROW nStartRow, SCROW nEndRow,
std::for_each(it, ++itEnd, NoteEntryCollector(rNotes, nTab, nCol, nStartRow, nEndRow));
}
-void ScColumn::GetUnprotectedCells(SCROW nStartRow, SCROW nEndRow,
- ScRangeList& rRangeList ) const
+void ScColumn::GetUnprotectedCells( SCROW nStartRow, SCROW nEndRow, ScRangeList& rRangeList ) const
{
SCROW nTmpStartRow = nStartRow, nTmpEndRow = nEndRow;
const ScPatternAttr* pPattern = pAttrArray->GetPatternRange(nTmpStartRow, nTmpEndRow, nStartRow);
bool bProtection = static_cast<const ScProtectionAttr&>(pPattern->GetItem(ATTR_PROTECTION)).GetProtection();
- if(!bProtection)
- rRangeList.Join(ScRange( nCol, nTmpStartRow, nTab, nCol, nTmpEndRow, nTab));
+ if (!bProtection)
+ {
+ // Limit the span to the range in question.
+ if (nTmpStartRow < nStartRow)
+ nTmpStartRow = nStartRow;
+ if (nTmpEndRow > nEndRow)
+ nTmpEndRow = nEndRow;
+ rRangeList.Join( ScRange( nCol, nTmpStartRow, nTab, nCol, nTmpEndRow, nTab));
+ }
while (nEndRow > nTmpEndRow)
{
nStartRow = nTmpEndRow + 1;
pPattern = pAttrArray->GetPatternRange(nTmpStartRow, nTmpEndRow, nStartRow);
bool bTmpProtection = static_cast<const ScProtectionAttr&>(pPattern->GetItem(ATTR_PROTECTION)).GetProtection();
if (!bTmpProtection)
- rRangeList.Join(ScRange( nCol, nTmpStartRow, nTab, nCol, nTmpEndRow, nTab));
+ {
+ // Limit the span to the range in question.
+ // Only end row needs to be checked as we enter here only for spans
+ // below the original nStartRow.
+ if (nTmpEndRow > nEndRow)
+ nTmpEndRow = nEndRow;
+ rRangeList.Join( ScRange( nCol, nTmpStartRow, nTab, nCol, nTmpEndRow, nTab));
+ }
}
}