[Libreoffice-commits] core.git: sc/inc sc/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Mon Feb 15 02:59:48 UTC 2016
sc/inc/document.hxx | 2 ++
sc/inc/documentimport.hxx | 2 ++
sc/inc/olinetab.hxx | 2 ++
sc/inc/table.hxx | 2 ++
sc/source/core/data/document10.cxx | 10 ++++++++++
sc/source/core/data/documentimport.cxx | 16 ++++++++++++++++
sc/source/core/data/olinetab.cxx | 21 +++++++++++++++++++++
sc/source/core/data/table7.cxx | 9 +++++++++
sc/source/filter/xml/xmlrowi.cxx | 6 ++++--
9 files changed, 68 insertions(+), 2 deletions(-)
New commits:
commit a8232b30687879f31768b89f4ff0bcf9457a7e77
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Tue Feb 9 04:26:49 2016 +0100
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/22239
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index ce1017e..9b8ab5e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2164,6 +2164,8 @@ public:
void SwapNonEmpty( sc::TableValues& rValues );
+ void finalizeOutlineImport();
+
private:
/**
diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx
index fc1c7c4..e90be0b 100644
--- a/sc/inc/documentimport.hxx
+++ b/sc/inc/documentimport.hxx
@@ -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:
diff --git a/sc/inc/olinetab.hxx b/sc/inc/olinetab.hxx
index ec0a83f..27ec0d3 100644
--- a/sc/inc/olinetab.hxx
+++ b/sc/inc/olinetab.hxx
@@ -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();
};
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 43a4897..e1b0706 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -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
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index a2f13920..d73eac5 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -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: */
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 49243d8..6f7030b 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -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)
diff --git a/sc/source/core/data/olinetab.cxx b/sc/source/core/data/olinetab.cxx
index a90e0b1..1d94b79 100644
--- a/sc/source/core/data/olinetab.cxx
+++ b/sc/source/core/data/olinetab.cxx
@@ -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()
{
}
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index 6c0cefa..c6f6f9f 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -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: */
diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx
index 521209b..2de0899 100644
--- a/sc/source/filter/xml/xmlrowi.cxx
+++ b/sc/source/filter/xml/xmlrowi.cxx
@@ -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));
}
More information about the Libreoffice-commits
mailing list