Kaydet (Commit) a8232b30 authored tarafından Markus Mohrhard's avatar Markus Mohrhard Kaydeden (comit) Markus Mohrhard

tdf#94858, avoid O(n^2) algorithm during outline import

The old code set called the outline visibility code for each row. Now we
are just calling it once at the end of the import.

Change-Id: Ie19f8bd538495cb50a7618156aed8de832885c2a
Reviewed-on: https://gerrit.libreoffice.org/22239Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 8c125eca
......@@ -2164,6 +2164,8 @@ public:
void SwapNonEmpty( sc::TableValues& rValues );
void finalizeOutlineImport();
private:
/**
......
......@@ -103,6 +103,8 @@ public:
*/
void setAttrEntries( SCTAB nTab, SCCOL nCol, Attrs& rAttrs );
void setRowsVisible(SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, bool bVisible);
void finalize();
private:
......
......@@ -136,6 +136,8 @@ public:
bool ManualAction(
SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, const ScTable& rTable, bool bCol);
void finalizeImport(ScTable& rTable, bool bCol);
void RemoveAll();
};
......
......@@ -954,6 +954,8 @@ public:
void SwapNonEmpty(
sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
void finalizeOutlineImport();
#if DEBUG_COLUMN_STORAGE
void DumpFormulaGroups( SCCOL nCol ) const;
#endif
......
......@@ -429,4 +429,14 @@ void ScDocument::StartAllListeners( const ScRange& rRange )
}
}
void ScDocument::finalizeOutlineImport()
{
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end();
for (; it != itEnd; ++it)
{
ScTable* p = *it;
p->finalizeOutlineImport();
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -465,6 +465,20 @@ void ScDocumentImport::setAttrEntries( SCTAB nTab, SCCOL nCol, Attrs& rAttrs )
pCol->pAttrArray->SetAttrEntries(rAttrs.mpData, rAttrs.mnSize);
}
void ScDocumentImport::setRowsVisible(SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, bool bVisible)
{
if (!bVisible)
{
getDoc().ShowRows(nRowStart, nRowEnd, nTab, false);
getDoc().SetDrawPageSize(nTab);
getDoc().UpdatePageBreaks( nTab );
}
else
{
assert(false);
}
}
namespace {
class CellStoreInitializer
......@@ -597,6 +611,8 @@ void ScDocumentImport::finalize()
for (SCCOL nColIdx = 0; nColIdx < nNumCols; ++nColIdx)
initColumn(rTab.aCol[nColIdx]);
}
mpImpl->mrDoc.finalizeOutlineImport();
}
void ScDocumentImport::initColumn(ScColumn& rCol)
......
......@@ -769,6 +769,27 @@ void ScOutlineArray::RemoveAll()
nDepth = 0;
}
void ScOutlineArray::finalizeImport(ScTable& rTable, bool bCol)
{
ScSubOutlineIterator aIter( this );
ScOutlineEntry* pEntry;
while((pEntry=aIter.GetNext())!=nullptr)
{
if (!pEntry->IsHidden())
continue;
SCCOLROW nEntryStart = pEntry->GetStart();
SCCOLROW nEntryEnd = pEntry->GetEnd();
SCCOLROW nEnd = rTable.LastHiddenColRow(nEntryStart, bCol);
bool bAllHidden = (nEntryEnd <= nEnd && nEnd <
::std::numeric_limits<SCCOLROW>::max());
pEntry->SetHidden(bAllHidden);
SetVisibleBelow(aIter.LastLevel(), aIter.LastEntry(), !bAllHidden, !bAllHidden);
}
}
ScOutlineTable::ScOutlineTable()
{
}
......
......@@ -15,6 +15,7 @@
#include <segmenttree.hxx>
#include <sharedformula.hxx>
#include <cellvalues.hxx>
#include "olinetab.hxx"
bool ScTable::IsMerged( SCCOL nCol, SCROW nRow ) const
{
......@@ -238,4 +239,12 @@ void ScTable::SetNeedsListeningGroup( SCCOL nCol, SCROW nRow )
aCol[nCol].SetNeedsListeningGroup(nRow);
}
void ScTable::finalizeOutlineImport()
{
if (pOutlineTable && pRowFlags)
{
pOutlineTable->GetRowArray().finalizeImport(*this, false);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -26,6 +26,7 @@
#include "docuno.hxx"
#include "olinetab.hxx"
#include "sheetdata.hxx"
#include "documentimport.hxx"
#include <xmloff/xmltkmap.hxx>
#include <xmloff/nmspmap.hxx>
......@@ -39,7 +40,6 @@
#include <com/sun/star/table/CellAddress.hpp>
#define SC_ISVISIBLE "IsVisible"
#define SC_ISFILTERED "IsFiltered"
using namespace com::sun::star;
......@@ -200,7 +200,9 @@ void ScXMLTableRowContext::EndElement()
bFiltered = true;
}
if (!bVisible)
xRowProperties->setPropertyValue(SC_ISVISIBLE, uno::makeAny(bVisible));
{
rXMLImport.GetDoc().setRowsVisible(nSheet, nFirstRow, nCurrentRow, false);
}
if (bFiltered)
xRowProperties->setPropertyValue(SC_ISFILTERED, uno::makeAny(bFiltered));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment