summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sc/inc/table.hxx2
-rw-r--r--sc/source/core/data/compressedarray.cxx6
-rw-r--r--sc/source/core/data/table1.cxx10
-rw-r--r--sc/source/core/data/table2.cxx26
-rw-r--r--sc/source/core/data/table3.cxx2
-rw-r--r--sc/source/core/data/table5.cxx21
6 files changed, 27 insertions, 40 deletions
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index adf2a8743c2e..243bf132e8f5 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -180,7 +180,7 @@ private:
std::unique_ptr<ScCompressedArray<SCCOL, sal_uInt16>> mpColWidth;
std::unique_ptr<ScFlatUInt16RowSegments> mpRowHeights;
- std::unique_ptr<CRFlags[]> pColFlags;
+ std::unique_ptr<ScBitMaskCompressedArray<SCCOL, CRFlags>> mpColFlags;
ScBitMaskCompressedArray< SCROW, CRFlags>* pRowFlags;
std::unique_ptr<ScFlatBoolColSegments> mpHiddenCols;
std::unique_ptr<ScFlatBoolRowSegments> mpHiddenRows;
diff --git a/sc/source/core/data/compressedarray.cxx b/sc/source/core/data/compressedarray.cxx
index 0b5308a4fe26..a1426792086d 100644
--- a/sc/source/core/data/compressedarray.cxx
+++ b/sc/source/core/data/compressedarray.cxx
@@ -369,7 +369,7 @@ void ScBitMaskCompressedArray<A,D>::AndValue( A nStart, A nEnd,
{
if ((this->pData[nIndex].aValue & rValueToAnd) != this->pData[nIndex].aValue)
{
- A nS = ::std::max( (nIndex>0 ? this->pData[nIndex-1].nEnd+1 : 0), nStart);
+ A nS = ::std::max<A>( (nIndex>0 ? this->pData[nIndex-1].nEnd+1 : 0), nStart);
A nE = ::std::min( this->pData[nIndex].nEnd, nEnd);
this->SetValue( nS, nE, this->pData[nIndex].aValue & rValueToAnd);
if (nE >= nEnd)
@@ -395,7 +395,7 @@ void ScBitMaskCompressedArray<A,D>::OrValue( A nStart, A nEnd,
{
if ((this->pData[nIndex].aValue | rValueToOr) != this->pData[nIndex].aValue)
{
- A nS = ::std::max( (nIndex>0 ? this->pData[nIndex-1].nEnd+1 : 0), nStart);
+ A nS = ::std::max<A>( (nIndex>0 ? this->pData[nIndex-1].nEnd+1 : 0), nStart);
A nE = ::std::min( this->pData[nIndex].nEnd, nEnd);
this->SetValue( nS, nE, this->pData[nIndex].aValue | rValueToOr);
if (nE >= nEnd)
@@ -460,5 +460,7 @@ A ScBitMaskCompressedArray<A,D>::GetLastAnyBitAccess( const D& rBitMask ) const
template class ScCompressedArray< SCROW, CRFlags>; // flags, base class
template class ScBitMaskCompressedArray< SCROW, CRFlags>; // flags
template class ScCompressedArray< SCCOL, sal_uInt16>;
+template class ScCompressedArray< SCCOL, CRFlags>;
+template class ScBitMaskCompressedArray< SCCOL, CRFlags>;
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index d99e2c7004e1..7075913cd744 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -247,7 +247,6 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
nRepeatEndY( SCROW_REPEAT_NONE ),
pTabProtection( nullptr ),
mpRowHeights( static_cast<ScFlatUInt16RowSegments*>(nullptr) ),
- pColFlags( nullptr ),
pRowFlags( nullptr ),
mpHiddenCols(new ScFlatBoolColSegments),
mpHiddenRows(new ScFlatBoolRowSegments),
@@ -291,12 +290,7 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
if (bColInfo)
{
mpColWidth.reset( new ScCompressedArray<SCCOL, sal_uInt16>( MAXCOL+1, STD_COL_WIDTH ) );
- pColFlags.reset( new CRFlags[ MAXCOL+1 ] );
-
- for (SCCOL i=0; i<=MAXCOL; i++)
- {
- pColFlags[i] = CRFlags::NONE;
- }
+ mpColFlags.reset( new ScBitMaskCompressedArray<SCCOL, CRFlags>( MAXCOL+1, CRFlags::NONE ) );
}
if (bRowInfo)
@@ -1800,7 +1794,7 @@ void ScTable::FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW n
void ScTable::ExtendPrintArea( OutputDevice* pDev,
SCCOL /* nStartCol */, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow )
{
- if ( !pColFlags || !pRowFlags )
+ if ( !mpColFlags || !pRowFlags )
{
OSL_FAIL("ExtendPrintArea: No ColInfo or RowInfo");
return;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 6667aeaf213f..dc29cc917cb5 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -281,11 +281,10 @@ void ScTable::InsertCol(
{
if (nStartRow==0 && nEndRow==MAXROW)
{
- if (mpColWidth && pColFlags)
+ if (mpColWidth && mpColFlags)
{
mpColWidth->InsertPreservingSize(nStartCol, nSize, STD_COL_WIDTH);
- memmove( &pColFlags[nStartCol+nSize], &pColFlags[nStartCol],
- (MAXCOL - nStartCol + 1 - nSize) * sizeof(pColFlags[0]) );
+ mpColFlags->InsertPreservingSize(nStartCol, nSize, CRFlags::NONE);
}
if (pOutlineTable)
pOutlineTable->InsertCol( nStartCol, nSize );
@@ -356,12 +355,11 @@ void ScTable::DeleteCol(
{
if (nStartRow==0 && nEndRow==MAXROW)
{
- if (mpColWidth && pColFlags)
+ if (mpColWidth && mpColFlags)
{
assert( nStartCol + nSize <= MAXCOL+1 ); // moving 0 if ==MAXCOL+1 is correct
mpColWidth->RemovePreservingSize(nStartCol, nSize, STD_COL_WIDTH);
- memmove( &pColFlags[nStartCol], &pColFlags[nStartCol+nSize],
- (MAXCOL - nStartCol + 1 - nSize) * sizeof(pColFlags[0]) );
+ mpColFlags->RemovePreservingSize(nStartCol, nSize, CRFlags::NONE);
}
if (pOutlineTable)
if (pOutlineTable->DeleteCol( nStartCol, nSize ))
@@ -1130,12 +1128,12 @@ void ScTable::CopyToTable(
auto destTabColWidthIt = pDestTab->mpColWidth->begin() + nCol1;
auto thisTabColWidthIt = mpColWidth->begin() + nCol1;
pDestTab->mpColWidth->CopyFrom(*mpColWidth, nCol1, nCol2);
+ pDestTab->mpColFlags->CopyFrom(*mpColFlags, nCol1, nCol2);
for (SCCOL i = nCol1; i <= nCol2; ++i)
{
bool bThisHidden = ColHidden(i);
bool bHiddenChange = (pDestTab->ColHidden(i) != bThisHidden);
bool bChange = bHiddenChange || (*destTabColWidthIt != *thisTabColWidthIt);
- pDestTab->pColFlags[i] = pColFlags[i];
pDestTab->SetColHidden(i, i, bThisHidden);
//TODO: collect changes?
if (bHiddenChange && pCharts)
@@ -2091,7 +2089,7 @@ SCSIZE ScTable::FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCO
void ScTable::FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 )
{
- if ( !mpColWidth || !mpRowHeights || !pColFlags || !pRowFlags )
+ if ( !mpColWidth || !mpRowHeights || !mpColFlags || !pRowFlags )
{
OSL_FAIL( "Row/column info missing" );
return;
@@ -2944,7 +2942,7 @@ sal_uInt16 ScTable::GetColWidth( SCCOL nCol, bool bHiddenAsZero ) const
{
OSL_ENSURE(ValidCol(nCol),"wrong column number");
- if (ValidCol(nCol) && pColFlags && mpColWidth)
+ if (ValidCol(nCol) && mpColFlags && mpColWidth)
{
if (bHiddenAsZero && ColHidden(nCol))
return 0;
@@ -3357,8 +3355,8 @@ void ScTable::SetRowFlags( SCROW nStartRow, SCROW nEndRow, CRFlags nNewFlags )
CRFlags ScTable::GetColFlags( SCCOL nCol ) const
{
- if (ValidCol(nCol) && pColFlags)
- return pColFlags[nCol];
+ if (ValidCol(nCol) && mpColFlags)
+ return mpColFlags->GetValue(nCol);
else
return CRFlags::NONE;
}
@@ -3403,13 +3401,13 @@ SCROW ScTable::GetLastFlaggedRow() const
SCCOL ScTable::GetLastChangedCol() const
{
- if ( !pColFlags )
+ if ( !mpColFlags )
return 0;
SCCOL nLastFound = 0;
auto colWidthIt = mpColWidth->begin() + 1;
for ( SCCOL nCol = 1; nCol < aCol.size(); nCol++, ++colWidthIt )
- if ((pColFlags[nCol] & CRFlags::All) || (*colWidthIt != STD_COL_WIDTH))
+ if ((mpColFlags->GetValue(nCol) & CRFlags::All) || (*colWidthIt != STD_COL_WIDTH))
nLastFound = nCol;
return nLastFound;
@@ -3434,7 +3432,7 @@ SCROW ScTable::GetLastChangedRow() const
bool ScTable::UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, bool bShow )
{
- if (pOutlineTable && pColFlags)
+ if (pOutlineTable && mpColFlags)
{
return pOutlineTable->GetColArray().ManualAction( nStartCol, nEndCol, bShow, *this, true );
}
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 64234dbd9781..0a036d3db171 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -3487,7 +3487,7 @@ void ScTable::UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData&
const SCCOL nEndCol = aMarkArea.aEnd.Col();
for (SCCOL nCol = nStartCol; nCol <= nEndCol && !rData.bError; ++nCol)
{
- if (pColFlags && ColHidden(nCol))
+ if (mpColFlags && ColHidden(nCol))
continue;
aCol[nCol].UpdateSelectionFunction(aRanges, rData, *mpHiddenRows);
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index b224e6e2ea5e..d7402ed19dc1 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -951,15 +951,14 @@ bool ScTable::IsManualRowHeight(SCROW nRow) const
namespace {
void lcl_syncFlags(ScFlatBoolColSegments& rColSegments, const ScFlatBoolRowSegments& rRowSegments,
- CRFlags* pColFlags, ScBitMaskCompressedArray< SCROW, CRFlags>* pRowFlags, const CRFlags nFlagMask)
+ ScBitMaskCompressedArray<SCCOL, CRFlags>* pColFlags, ScBitMaskCompressedArray< SCROW, CRFlags>* pRowFlags, const CRFlags nFlagMask)
{
using ::sal::static_int_cast;
CRFlags nFlagMaskComplement = ~nFlagMask;
pRowFlags->AndValue(0, MAXROW, nFlagMaskComplement);
- for (SCCOL i = 0; i <= MAXCOL; ++i)
- pColFlags[i] &= nFlagMaskComplement;
+ pColFlags->AndValue(0, MAXCOL+1, nFlagMaskComplement);
{
// row hidden flags.
@@ -989,10 +988,7 @@ void lcl_syncFlags(ScFlatBoolColSegments& rColSegments, const ScFlatBoolRowSegme
break;
if (aData.mbValue)
- {
- for (SCCOL i = nCol; i <= aData.mnCol2; ++i)
- pColFlags[i] |= nFlagMask;
- }
+ pColFlags->OrValue(nCol, aData.mnCol2, nFlagMask);
nCol = aData.mnCol2 + 1;
}
@@ -1003,14 +999,11 @@ void lcl_syncFlags(ScFlatBoolColSegments& rColSegments, const ScFlatBoolRowSegme
void ScTable::SyncColRowFlags()
{
- using ::sal::static_int_cast;
-
CRFlags nManualBreakComplement = ~CRFlags::ManualBreak;
// Manual breaks.
pRowFlags->AndValue(0, MAXROW, nManualBreakComplement);
- for (SCCOL i = 0; i <= MAXCOL; ++i)
- pColFlags[i] &= nManualBreakComplement;
+ mpColFlags->AndValue(0, MAXCOL+1, nManualBreakComplement);
if (!maRowManualBreaks.empty())
{
@@ -1023,12 +1016,12 @@ void ScTable::SyncColRowFlags()
{
for (set<SCCOL>::const_iterator itr = maColManualBreaks.begin(), itrEnd = maColManualBreaks.end();
itr != itrEnd; ++itr)
- pColFlags[*itr] |= CRFlags::ManualBreak;
+ mpColFlags->OrValue(*itr, CRFlags::ManualBreak);
}
// Hidden flags.
- lcl_syncFlags(*mpHiddenCols, *mpHiddenRows, pColFlags.get(), pRowFlags, CRFlags::Hidden);
- lcl_syncFlags(*mpFilteredCols, *mpFilteredRows, pColFlags.get(), pRowFlags, CRFlags::Filtered);
+ lcl_syncFlags(*mpHiddenCols, *mpHiddenRows, mpColFlags.get(), pRowFlags, CRFlags::Hidden);
+ lcl_syncFlags(*mpFilteredCols, *mpFilteredRows, mpColFlags.get(), pRowFlags, CRFlags::Filtered);
}
void ScTable::SetPageSize( const Size& rSize )