Kaydet (Commit) d48ea7a1 authored tarafından Eike Rathke's avatar Eike Rathke

Prevent excess rows included in the resulting range list, tdf#95883 follow-up

Change-Id: Id2fdffa4d7bba8225ea5fcf583a562467342ad3d
Reviewed-on: https://gerrit.libreoffice.org/38728Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarEike Rathke <erack@redhat.com>
üst 1d0890bb
...@@ -122,7 +122,14 @@ public: ...@@ -122,7 +122,14 @@ public:
bool Concat(SCSIZE nPos); bool Concat(SCSIZE nPos);
const ScPatternAttr* GetPattern( SCROW nRow ) const; 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; const ScPatternAttr* GetPatternRange( SCROW& rStartRow, SCROW& rEndRow, SCROW nRow ) const;
void MergePatternArea( SCROW nStartRow, SCROW nEndRow, ScMergePatternState& rState, bool bDeep ) const; void MergePatternArea( SCROW nStartRow, SCROW nEndRow, ScMergePatternState& rState, bool bDeep ) const;
void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner, ScLineFlags& rFlags, void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner, ScLineFlags& rFlags,
......
...@@ -211,6 +211,13 @@ bool ScAttrArray::Concat(SCSIZE nPos) ...@@ -211,6 +211,13 @@ bool ScAttrArray::Concat(SCSIZE nPos)
return bRet; 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 bool ScAttrArray::Search( SCROW nRow, SCSIZE& nIndex ) const
{ {
long nHi = static_cast<long>(nCount) - 1; long nHi = static_cast<long>(nCount) - 1;
......
...@@ -769,21 +769,34 @@ void ScColumn::GetNotesInRange(SCROW nStartRow, SCROW nEndRow, ...@@ -769,21 +769,34 @@ void ScColumn::GetNotesInRange(SCROW nStartRow, SCROW nEndRow,
std::for_each(it, ++itEnd, NoteEntryCollector(rNotes, nTab, nCol, nStartRow, nEndRow)); std::for_each(it, ++itEnd, NoteEntryCollector(rNotes, nTab, nCol, nStartRow, nEndRow));
} }
void ScColumn::GetUnprotectedCells(SCROW nStartRow, SCROW nEndRow, void ScColumn::GetUnprotectedCells( SCROW nStartRow, SCROW nEndRow, ScRangeList& rRangeList ) const
ScRangeList& rRangeList ) const
{ {
SCROW nTmpStartRow = nStartRow, nTmpEndRow = nEndRow; SCROW nTmpStartRow = nStartRow, nTmpEndRow = nEndRow;
const ScPatternAttr* pPattern = pAttrArray->GetPatternRange(nTmpStartRow, nTmpEndRow, nStartRow); const ScPatternAttr* pPattern = pAttrArray->GetPatternRange(nTmpStartRow, nTmpEndRow, nStartRow);
bool bProtection = static_cast<const ScProtectionAttr&>(pPattern->GetItem(ATTR_PROTECTION)).GetProtection(); bool bProtection = static_cast<const ScProtectionAttr&>(pPattern->GetItem(ATTR_PROTECTION)).GetProtection();
if(!bProtection) if (!bProtection)
rRangeList.Join(ScRange( nCol, nTmpStartRow, nTab, nCol, nTmpEndRow, nTab)); {
// 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) while (nEndRow > nTmpEndRow)
{ {
nStartRow = nTmpEndRow + 1; nStartRow = nTmpEndRow + 1;
pPattern = pAttrArray->GetPatternRange(nTmpStartRow, nTmpEndRow, nStartRow); pPattern = pAttrArray->GetPatternRange(nTmpStartRow, nTmpEndRow, nStartRow);
bool bTmpProtection = static_cast<const ScProtectionAttr&>(pPattern->GetItem(ATTR_PROTECTION)).GetProtection(); bool bTmpProtection = static_cast<const ScProtectionAttr&>(pPattern->GetItem(ATTR_PROTECTION)).GetProtection();
if (!bTmpProtection) 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));
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment