summaryrefslogtreecommitdiff
path: root/sc/inc/attarray.hxx
diff options
context:
space:
mode:
authorDennis Francis <dennisfrancis.in@gmail.com>2016-04-15 21:43:42 +0530
committerEike Rathke <erack@redhat.com>2016-11-10 15:11:28 +0000
commit06d3294502413a231e5c5265609862c7f67a2f2b (patch)
tree10ae793388158381a933632457d0eb17726586b9 /sc/inc/attarray.hxx
parent5e416099f088a2f8a8980e08e3d5b731da0a6d9c (diff)
Refactor ScAttrArray for tdf#50916
For a default column, now ScAttrArray does not store the default format. So the case of default pattern from 0 to MAXROW is represented as nCount = 0 and pData = nullptr in ScAttrArray. A new ScAttrArray object (aNextColAttrArray) is introduced as a member of ScTable. This is used to store the formatting of *unallocated* columns (whose indices are from aCol.size() to MAXCOL). In next patches for this bug, I plan to refactor table*.cxx functions related to formatting such that : 1) In formatting setter functions, if colspan of the input range spans the colrange(aCol.size() to MAXCOL) then instead of allocating columns, apply that formatting to aNextColAttrArray. 2) In formatting getter (const) functions, if requested colspan has some intersection with the colrange(aCol.size() to MAXCOL) then use the formatting info stored in aNextColAttrArray to calculate the formatting of the input range. 3) In general setter (non-const) functions if we really need to allocate new columns (example, when data is entered), use the formatting info stored in aNextColAttrArray to create pAttrArray of the new column. Change-Id: Ieb56f853209b396d92fdb2c27e39361703576423 Reviewed-on: https://gerrit.libreoffice.org/27828 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/inc/attarray.hxx')
-rw-r--r--sc/inc/attarray.hxx38
1 files changed, 33 insertions, 5 deletions
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index 2b440402e0d0..49626ea9e124 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -100,12 +100,13 @@ friend class ScHorizontalAttrIterator;
void RemoveCellCharAttribs( SCROW nStartRow, SCROW nEndRow,
const ScPatternAttr* pPattern, ScEditDataArray* pDataArray );
+ void SetDefaultIfNotInit( SCSIZE nNeeded = 1 );
ScAttrArray(const ScAttrArray&) = delete;
ScAttrArray& operator=(const ScAttrArray&) = delete;
public:
- ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc );
+ ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc, ScAttrArray* pNextColAttrArray = nullptr, bool bCreateEmpty = false );
~ScAttrArray();
void SetTab(SCTAB nNewTab) { nTab = nNewTab; }
@@ -205,23 +206,30 @@ public:
class ScAttrIterator
{
const ScAttrArray* pArray;
+ const ScPatternAttr* pDefPattern;
SCSIZE nPos;
SCROW nRow;
SCROW nEndRow;
public:
- inline ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStart, SCROW nEnd );
+ inline ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStart, SCROW nEnd, const ScPatternAttr* pDefaultPattern );
inline const ScPatternAttr* Next( SCROW& rTop, SCROW& rBottom );
inline const ScPatternAttr* Resync( SCROW nRow, SCROW& rTop, SCROW& rBottom );
SCROW GetNextRow() const { return nRow; }
};
-inline ScAttrIterator::ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStart, SCROW nEnd ) :
+inline ScAttrIterator::ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStart, SCROW nEnd, const ScPatternAttr* pDefaultPattern ) :
pArray( pNewArray ),
+ pDefPattern( pDefaultPattern ),
nRow( nStart ),
nEndRow( nEnd )
{
- if ( nStart > 0 )
- pArray->Search( nStart, nPos );
+ if ( pArray->nCount )
+ {
+ if ( nStart > 0 )
+ pArray->Search( nStart, nPos );
+ else
+ nPos = 0;
+ }
else
nPos = 0;
}
@@ -229,6 +237,21 @@ inline ScAttrIterator::ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStar
inline const ScPatternAttr* ScAttrIterator::Next( SCROW& rTop, SCROW& rBottom )
{
const ScPatternAttr* pRet;
+ if ( !pArray->nCount )
+ {
+ if ( !nPos )
+ {
+ ++nPos;
+ if ( nRow > MAXROW )
+ return nullptr;
+ rTop = nRow;
+ rBottom = std::min( nEndRow, MAXROW );
+ nRow = rBottom + 1;
+ return pDefPattern;
+ }
+ return nullptr;
+ }
+
if ( nPos < pArray->nCount && nRow <= nEndRow )
{
rTop = nRow;
@@ -245,6 +268,11 @@ inline const ScPatternAttr* ScAttrIterator::Next( SCROW& rTop, SCROW& rBottom )
inline const ScPatternAttr* ScAttrIterator::Resync( SCROW nRowP, SCROW& rTop, SCROW& rBottom )
{
nRow = nRowP;
+ if ( !pArray->nCount )
+ {
+ nPos = 0;
+ return Next( rTop, rBottom );
+ }
// 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