summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-07-05 12:08:07 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-07-05 17:49:26 +0200
commit3c90f2bd1ad87e86f0562920b49ea55c2cb317c9 (patch)
treeeeaf5620c31c8ce018e32f636e23b815dc5b9c54
parenta5d25a06a48b32fd35148265f3c328a28d21f73e (diff)
remove span data storage from oox import
We are not using it, and removing it reduces peak memory load from 648M to 548M when loading a large spreadsheet Change-Id: I683bfba6c8f151d8845bbd7d5f92cde2a9c17807 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136825 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/source/filter/inc/pivotcachebuffer.hxx2
-rw-r--r--sc/source/filter/inc/sheetdatabuffer.hxx20
-rw-r--r--sc/source/filter/inc/worksheethelper.hxx3
-rw-r--r--sc/source/filter/oox/pivotcachebuffer.cxx7
-rw-r--r--sc/source/filter/oox/sheetdatabuffer.cxx23
-rw-r--r--sc/source/filter/oox/sheetdatacontext.cxx7
-rw-r--r--sc/source/filter/oox/worksheethelper.cxx8
7 files changed, 5 insertions, 65 deletions
diff --git a/sc/source/filter/inc/pivotcachebuffer.hxx b/sc/source/filter/inc/pivotcachebuffer.hxx
index 5997d8db3d2c..e255c79eae15 100644
--- a/sc/source/filter/inc/pivotcachebuffer.hxx
+++ b/sc/source/filter/inc/pivotcachebuffer.hxx
@@ -409,7 +409,7 @@ private:
/** Creates a dummy sheet that will be filled with the pivot cache data. */
void prepareSourceDataSheet();
/** Checks, if the row index has changed since last call, and initializes the sheet data buffer. */
- void updateSourceDataRow( const WorksheetHelper& rSheetHelper, sal_Int32 nRow ) const;
+ void updateSourceDataRow( sal_Int32 nRow ) const;
private:
typedef RefVector< PivotCacheField > PivotCacheFieldVector;
diff --git a/sc/source/filter/inc/sheetdatabuffer.hxx b/sc/source/filter/inc/sheetdatabuffer.hxx
index a6bec5a55807..538631330082 100644
--- a/sc/source/filter/inc/sheetdatabuffer.hxx
+++ b/sc/source/filter/inc/sheetdatabuffer.hxx
@@ -72,22 +72,6 @@ struct DataTableModel
explicit DataTableModel();
};
-/** Manages all cell blocks currently in use. */
-class CellBlockBuffer : public WorksheetHelper
-{
-public:
- explicit CellBlockBuffer( const WorksheetHelper& rHelper );
-
- /** Sets column span information for a row. */
- void setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpans );
-
-private:
- typedef ::std::map< sal_Int32, ValueRangeVector > ColSpanVectorMap;
-
- ColSpanVectorMap maColSpans; /// Buffered column spans, mapped by row index.
- sal_Int32 mnCurrRow; /// Current row index used for buffered cell import.
-};
-
/** Manages the cell contents and cell formatting of a sheet.
*/
class SheetDataBuffer : public WorksheetHelper
@@ -95,9 +79,6 @@ class SheetDataBuffer : public WorksheetHelper
public:
explicit SheetDataBuffer( const WorksheetHelper& rHelper );
- /** Sets column span information for a row. */
- void setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpans );
-
/** Inserts a blank cell (with formatting) into the sheet. */
void setBlankCell( const CellModel& rModel );
/** Inserts a value cell into the sheet. */
@@ -223,7 +204,6 @@ private:
typedef ::std::vector< MergedRange > MergedRangeVector;
ColStyles maStylesPerColumn; /// Stores cell styles by column ( in row ranges )
- CellBlockBuffer maCellBlocks; /// Manages all open cell blocks.
ArrayFormulaVector maArrayFormulas; /// All array formulas in the sheet.
std::vector< TableOperation >
maTableOperations; /// All table operations in the sheet.
diff --git a/sc/source/filter/inc/worksheethelper.hxx b/sc/source/filter/inc/worksheethelper.hxx
index 7beacf7c2105..3aeb576f93de 100644
--- a/sc/source/filter/inc/worksheethelper.hxx
+++ b/sc/source/filter/inc/worksheethelper.hxx
@@ -85,7 +85,6 @@ struct ColumnModel
struct RowModel
{
sal_Int32 mnRow; /// 1-based (!) index of the described row.
- ValueRangeSet maColSpans; /// 0-based (!) column ranges of used cells.
double mfHeight; /// Row height in points.
sal_Int32 mnXfId; /// Row default formatting (see mbIsFormatted).
sal_Int32 mnLevel; /// Row outline level.
@@ -99,8 +98,6 @@ struct RowModel
explicit RowModel();
- /** Inserts the passed column span into the row model. */
- void insertColSpan( const ValueRange& rColSpan );
/** Returns true, if this entry can be merged with the passed row range (row settings are equal). */
bool isMergeable( const RowModel& rModel ) const;
};
diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx b/sc/source/filter/oox/pivotcachebuffer.cxx
index b1b12ba435e8..4cf8e234b9df 100644
--- a/sc/source/filter/oox/pivotcachebuffer.cxx
+++ b/sc/source/filter/oox/pivotcachebuffer.cxx
@@ -1057,7 +1057,7 @@ void PivotCache::writeSourceHeaderCells( const WorksheetHelper& rSheetHelper ) c
SCCOL nMaxCol = getAddressConverter().getMaxApiAddress().Col();
SCROW nRow = maSheetSrcModel.maRange.aStart.Row();
mnCurrRow = -1;
- updateSourceDataRow( rSheetHelper, nRow );
+ updateSourceDataRow( nRow );
for( const auto& rxDatabaseField : maDatabaseFields )
{
if (nCol > nMaxCol)
@@ -1073,7 +1073,7 @@ void PivotCache::writeSourceDataCell( const WorksheetHelper& rSheetHelper, sal_I
OSL_ENSURE( ( maSheetSrcModel.maRange.aStart.Col() <= nCol ) && ( nCol <= maSheetSrcModel.maRange.aEnd.Col() ), "PivotCache::writeSourceDataCell - invalid column index" );
SCROW nRow = maSheetSrcModel.maRange.aStart.Row() + nRowIdx;
OSL_ENSURE( ( maSheetSrcModel.maRange.aStart.Row() < nRow ) && ( nRow <= maSheetSrcModel.maRange.aEnd.Row() ), "PivotCache::writeSourceDataCell - invalid row index" );
- updateSourceDataRow( rSheetHelper, nRow );
+ updateSourceDataRow( nRow );
if( const PivotCacheField* pCacheField = maDatabaseFields.get( nColIdx ).get() )
pCacheField->writeSourceDataCell( rSheetHelper, nCol, nRow, rItem );
}
@@ -1167,11 +1167,10 @@ void PivotCache::prepareSourceDataSheet()
}
}
-void PivotCache::updateSourceDataRow( const WorksheetHelper& rSheetHelper, sal_Int32 nRow ) const
+void PivotCache::updateSourceDataRow( sal_Int32 nRow ) const
{
if( mnCurrRow != nRow )
{
- rSheetHelper.getSheetData().setColSpans( nRow, maColSpans );
mnCurrRow = nRow;
}
}
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index 244d70b62844..280c39f70c10 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -91,35 +91,12 @@ DataTableModel::DataTableModel() :
{
}
-CellBlockBuffer::CellBlockBuffer( const WorksheetHelper& rHelper ) :
- WorksheetHelper( rHelper ),
- mnCurrRow( -1 )
-{
-}
-
-void CellBlockBuffer::setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpans )
-{
- OSL_ENSURE( maColSpans.count( nRow ) == 0, "CellBlockBuffer::setColSpans - multiple column spans for the same row" );
- OSL_ENSURE( (mnCurrRow < nRow) && (maColSpans.empty() || (maColSpans.rbegin()->first < nRow)), "CellBlockBuffer::setColSpans - rows are unsorted" );
- if( mnCurrRow >= nRow )
- return;
- auto pair = maColSpans.try_emplace(nRow, rColSpans.getRanges());
- if( pair.second ) // insert happened
- mnCurrRow = nRow;
-}
-
SheetDataBuffer::SheetDataBuffer( const WorksheetHelper& rHelper ) :
WorksheetHelper( rHelper ),
- maCellBlocks( rHelper ),
mbPendingSharedFmla( false )
{
}
-void SheetDataBuffer::setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpans )
-{
- maCellBlocks.setColSpans( nRow, rColSpans );
-}
-
void SheetDataBuffer::setBlankCell( const CellModel& rModel )
{
setCellFormat( rModel );
diff --git a/sc/source/filter/oox/sheetdatacontext.cxx b/sc/source/filter/oox/sheetdatacontext.cxx
index f4a9330b437a..8e8e7d75d802 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -287,7 +287,6 @@ void SheetDataContext::importRow( const AttributeList& rAttribs )
// decode the column spans (space-separated list of colon-separated integer pairs)
OUString aColSpansText = rAttribs.getString( XML_spans, OUString() );
- sal_Int32 nMaxCol = mrAddressConv.getMaxApiAddress().Col();
sal_Int32 nIndex = 0;
while( nIndex >= 0 )
{
@@ -302,7 +301,6 @@ void SheetDataContext::importRow( const AttributeList& rAttribs )
{
const sal_Int32 nCol2 = o3tl::toInt32(aColSpanToken.substr( nSepPos + 1 )) - 1;
mrAddressConv.checkCol( nCol2, true);
- aModel.insertColSpan( ValueRange( nCol1, ::std::min( nCol2, nMaxCol )));
}
}
}
@@ -396,16 +394,13 @@ void SheetDataContext::importRow( SequenceInputStream& rStrm )
aModel.mbThickBottom = getFlag( nFlags1, BIFF12_ROW_THICKBOTTOM );
// read the column spans
- sal_Int32 nMaxCol = mrAddressConv.getMaxApiAddress().Col();
for( sal_Int32 nSpanIdx = 0; (nSpanIdx < nSpanCount) && !rStrm.isEof(); ++nSpanIdx )
{
sal_Int32 nFirstCol, nLastCol;
nFirstCol = rStrm.readInt32();
- const bool bValid1 = mrAddressConv.checkCol( nFirstCol, true);
+ mrAddressConv.checkCol( nFirstCol, true);
nLastCol = rStrm.readInt32();
mrAddressConv.checkCol( nLastCol, true);
- if (bValid1)
- aModel.insertColSpan( ValueRange( nFirstCol, ::std::min( nLastCol, nMaxCol ) ) );
}
// set row properties in the current sheet
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx
index af0c4649d723..5e9ef3726a5f 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -148,12 +148,6 @@ RowModel::RowModel() :
{
}
-void RowModel::insertColSpan( const ValueRange& rColSpan )
-{
- if( (0 <= rColSpan.mnFirst) && (rColSpan.mnFirst <= rColSpan.mnLast) )
- maColSpans.insert( rColSpan );
-}
-
bool RowModel::isMergeable( const RowModel& rModel ) const
{
return
@@ -898,8 +892,6 @@ void WorksheetGlobals::setRowModel( const RowModel& rModel )
maRowModels[ nRow ] = RowModelRange( rModel, nRow );
// set row formatting
maSheetData.setRowFormat( nRow, rModel.mnXfId, rModel.mbCustomFormat );
- // set column spans
- maSheetData.setColSpans( nRow, rModel.maColSpans );
}
}