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-06 18:57:15 +0200
commit779f38adf952e816218e2dac26513e8ff106d651 (patch)
tree30e0f285ca0329efda14fae73bd37bac9babd54e
parentb1f87dcc0a3007c9e47b10a39a5c8d88bc9a2112 (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> (cherry picked from commit 168f3572dc4c17910543ca0e93a0c5e04113fbf2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136770 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-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 940da26416fe..ac095cccdd26 100644
--- a/sc/source/filter/inc/sheetdatabuffer.hxx
+++ b/sc/source/filter/inc/sheetdatabuffer.hxx
@@ -73,22 +73,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
@@ -96,9 +80,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. */
@@ -224,7 +205,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 63b9b4f11145..014b0fc61ae3 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 ddc3c9fd5eab..6a038cac8701 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -286,7 +286,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 )
{
@@ -301,7 +300,6 @@ void SheetDataContext::importRow( const AttributeList& rAttribs )
{
const sal_Int32 nCol2 = aColSpanToken.copy( nSepPos + 1 ).toInt32() - 1;
mrAddressConv.checkCol( nCol2, true);
- aModel.insertColSpan( ValueRange( nCol1, ::std::min( nCol2, nMaxCol )));
}
}
}
@@ -395,16 +393,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 95625751d4a0..1cb02316ebdf 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
@@ -900,8 +894,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 );
}
}