summaryrefslogtreecommitdiff
path: root/sc/inc/attarray.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/inc/attarray.hxx')
-rw-r--r--sc/inc/attarray.hxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index 08e3c5a2d90c..9b6464b37247 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -206,6 +206,7 @@ class ScAttrIterator
public:
inline ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStart, SCROW nEnd );
inline const ScPatternAttr* Next( SCROW& rTop, SCROW& rBottom );
+ inline const ScPatternAttr* Resync( SCROW nRow, SCROW& rTop, SCROW& rBottom );
SCROW GetNextRow() const { return nRow; }
};
@@ -236,6 +237,26 @@ inline const ScPatternAttr* ScAttrIterator::Next( SCROW& rTop, SCROW& rBottom )
return pRet;
}
+inline const ScPatternAttr* ScAttrIterator::Resync( SCROW nRowP, SCROW& rTop, SCROW& rBottom )
+{
+ nRow = nRowP;
+ // Chances are high that the pattern changed on nRowP introduced a span
+ // starting right there. Assume that Next() was called so nPos already
+ // advanced. Another high chance is that the change extended a previous or
+ // next pattern. In all these cases we don't need to search.
+ if (3 <= nPos && nPos <= pArray->nCount && pArray->pData[nPos-3].nRow < nRowP &&
+ nRowP <= pArray->pData[nPos-2].nRow)
+ nPos -= 2;
+ else if (2 <= nPos && nPos <= pArray->nCount && pArray->pData[nPos-2].nRow < nRowP &&
+ nRowP <= pArray->pData[nPos-1].nRow)
+ --nPos;
+ else if (pArray->nCount > 0 && nRowP <= pArray->pData[0].nRow)
+ nPos = 0;
+ else
+ pArray->Search( nRowP, nPos );
+ return Next( rTop, rBottom);
+}
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */