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: ...@@ -2164,6 +2164,8 @@ public:
void SwapNonEmpty( sc::TableValues& rValues ); void SwapNonEmpty( sc::TableValues& rValues );
void finalizeOutlineImport();
private: private:
/** /**
......
...@@ -103,6 +103,8 @@ public: ...@@ -103,6 +103,8 @@ public:
*/ */
void setAttrEntries( SCTAB nTab, SCCOL nCol, Attrs& rAttrs ); void setAttrEntries( SCTAB nTab, SCCOL nCol, Attrs& rAttrs );
void setRowsVisible(SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, bool bVisible);
void finalize(); void finalize();
private: private:
......
...@@ -136,6 +136,8 @@ public: ...@@ -136,6 +136,8 @@ public:
bool ManualAction( bool ManualAction(
SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, const ScTable& rTable, bool bCol); SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, const ScTable& rTable, bool bCol);
void finalizeImport(ScTable& rTable, bool bCol);
void RemoveAll(); void RemoveAll();
}; };
......
...@@ -954,6 +954,8 @@ public: ...@@ -954,6 +954,8 @@ public:
void SwapNonEmpty( void SwapNonEmpty(
sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt ); sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
void finalizeOutlineImport();
#if DEBUG_COLUMN_STORAGE #if DEBUG_COLUMN_STORAGE
void DumpFormulaGroups( SCCOL nCol ) const; void DumpFormulaGroups( SCCOL nCol ) const;
#endif #endif
......
...@@ -429,4 +429,14 @@ void ScDocument::StartAllListeners( const ScRange& rRange ) ...@@ -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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -465,6 +465,20 @@ void ScDocumentImport::setAttrEntries( SCTAB nTab, SCCOL nCol, Attrs& rAttrs ) ...@@ -465,6 +465,20 @@ void ScDocumentImport::setAttrEntries( SCTAB nTab, SCCOL nCol, Attrs& rAttrs )
pCol->pAttrArray->SetAttrEntries(rAttrs.mpData, rAttrs.mnSize); 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 { namespace {
class CellStoreInitializer class CellStoreInitializer
...@@ -597,6 +611,8 @@ void ScDocumentImport::finalize() ...@@ -597,6 +611,8 @@ void ScDocumentImport::finalize()
for (SCCOL nColIdx = 0; nColIdx < nNumCols; ++nColIdx) for (SCCOL nColIdx = 0; nColIdx < nNumCols; ++nColIdx)
initColumn(rTab.aCol[nColIdx]); initColumn(rTab.aCol[nColIdx]);
} }
mpImpl->mrDoc.finalizeOutlineImport();
} }
void ScDocumentImport::initColumn(ScColumn& rCol) void ScDocumentImport::initColumn(ScColumn& rCol)
......
...@@ -769,6 +769,27 @@ void ScOutlineArray::RemoveAll() ...@@ -769,6 +769,27 @@ void ScOutlineArray::RemoveAll()
nDepth = 0; 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() ScOutlineTable::ScOutlineTable()
{ {
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <segmenttree.hxx> #include <segmenttree.hxx>
#include <sharedformula.hxx> #include <sharedformula.hxx>
#include <cellvalues.hxx> #include <cellvalues.hxx>
#include "olinetab.hxx"
bool ScTable::IsMerged( SCCOL nCol, SCROW nRow ) const bool ScTable::IsMerged( SCCOL nCol, SCROW nRow ) const
{ {
...@@ -238,4 +239,12 @@ void ScTable::SetNeedsListeningGroup( SCCOL nCol, SCROW nRow ) ...@@ -238,4 +239,12 @@ void ScTable::SetNeedsListeningGroup( SCCOL nCol, SCROW nRow )
aCol[nCol].SetNeedsListeningGroup(nRow); aCol[nCol].SetNeedsListeningGroup(nRow);
} }
void ScTable::finalizeOutlineImport()
{
if (pOutlineTable && pRowFlags)
{
pOutlineTable->GetRowArray().finalizeImport(*this, false);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "docuno.hxx" #include "docuno.hxx"
#include "olinetab.hxx" #include "olinetab.hxx"
#include "sheetdata.hxx" #include "sheetdata.hxx"
#include "documentimport.hxx"
#include <xmloff/xmltkmap.hxx> #include <xmloff/xmltkmap.hxx>
#include <xmloff/nmspmap.hxx> #include <xmloff/nmspmap.hxx>
...@@ -39,7 +40,6 @@ ...@@ -39,7 +40,6 @@
#include <com/sun/star/table/CellAddress.hpp> #include <com/sun/star/table/CellAddress.hpp>
#define SC_ISVISIBLE "IsVisible"
#define SC_ISFILTERED "IsFiltered" #define SC_ISFILTERED "IsFiltered"
using namespace com::sun::star; using namespace com::sun::star;
...@@ -200,7 +200,9 @@ void ScXMLTableRowContext::EndElement() ...@@ -200,7 +200,9 @@ void ScXMLTableRowContext::EndElement()
bFiltered = true; bFiltered = true;
} }
if (!bVisible) if (!bVisible)
xRowProperties->setPropertyValue(SC_ISVISIBLE, uno::makeAny(bVisible)); {
rXMLImport.GetDoc().setRowsVisible(nSheet, nFirstRow, nCurrentRow, false);
}
if (bFiltered) if (bFiltered)
xRowProperties->setPropertyValue(SC_ISFILTERED, uno::makeAny(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