From 98cdf3324314ebf7ee69605af2a8fc28be092528 Mon Sep 17 00:00:00 2001 From: "Eike Rathke [er]" Date: Fri, 16 Jul 2010 15:58:36 +0200 Subject: calc56: #i113139# various performance improvements for 1MB rows, especially with large hidden segments --- sc/source/filter/xml/XMLStylesExportHelper.cxx | 27 +++++++++++++++++++++++--- sc/source/filter/xml/XMLStylesExportHelper.hxx | 1 + sc/source/filter/xml/xmlexprt.cxx | 7 +++---- 3 files changed, 28 insertions(+), 7 deletions(-) (limited to 'sc/source/filter/xml') diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx index f8bafa32f205..66f3ea613a3a 100644 --- a/sc/source/filter/xml/XMLStylesExportHelper.cxx +++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx @@ -1234,10 +1234,31 @@ void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nFie const sal_Int32 nStringIndex) { DBG_ASSERT(static_cast(nTable) < aTables.size(), "wrong table"); - DBG_ASSERT(aTables[nTable].size() >= static_cast(nField), "wrong field"); - if (aTables[nTable].size() == static_cast(nField)) + DBG_ASSERT(aTables[nTable].size() >= static_cast(nField), "wrong field"); + if (aTables[nTable].size() == static_cast(nField)) aTables[nTable].push_back(nStringIndex); - aTables[nTable][nField] = nStringIndex; + else + aTables[nTable][nField] = nStringIndex; +} + +void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nStartField, + const sal_Int32 nStringIndex, const sal_Int32 nEndField) +{ + DBG_ASSERT( nStartField <= nEndField, "bad field range"); + DBG_ASSERT(static_cast(nTable) < aTables.size(), "wrong table"); + DBG_ASSERT(aTables[nTable].size() >= static_cast(nStartField), "wrong field"); + ScMysalInt32Vec& rTable = aTables[nTable]; + size_t nSize = rTable.size(); + if (nSize == static_cast(nStartField)) + rTable.insert( rTable.end(), static_cast(nEndField - nStartField + 1), nStringIndex); + else + { + size_t nField = static_cast(nStartField); + for ( ; nField < nSize && nField <= static_cast(nEndField); ++nField) + rTable[nField] = nStringIndex; + if (nField <= static_cast(nEndField)) + rTable.insert( rTable.end(), static_cast(nEndField - nField + 1), nStringIndex); + } } rtl::OUString* ScRowStyles::GetStyleName(const sal_Int32 nTable, const sal_Int32 nField) diff --git a/sc/source/filter/xml/XMLStylesExportHelper.hxx b/sc/source/filter/xml/XMLStylesExportHelper.hxx index 34672aeef96e..79b19b7ce9ab 100644 --- a/sc/source/filter/xml/XMLStylesExportHelper.hxx +++ b/sc/source/filter/xml/XMLStylesExportHelper.hxx @@ -286,6 +286,7 @@ public: virtual void AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields); sal_Int32 GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField); void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField, const sal_Int32 nStringIndex); + void AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nStartField, const sal_Int32 nStringIndex, const sal_Int32 nEndField); virtual rtl::OUString* GetStyleName(const sal_Int32 nTable, const sal_Int32 nField); }; diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 0563f6430063..b34abb29443c 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2576,14 +2576,13 @@ void ScXMLExport::_ExportAutoStyles() } sal_Int32 nOld(nRow); nRow = pDoc->GetNextDifferentChangedRow(sal::static_int_cast(nTable), static_cast(nRow), false); - for (sal_Int32 i = nOld + 1; i < nRow; ++i) - pRowStyles->AddFieldStyleName(nTable, i, nIndex); + if (nRow > nOld + 1) + pRowStyles->AddFieldStyleName(nTable, nOld + 1, nIndex, nRow - 1); } if (aCellAddress.EndRow > nRows) { sal_Int32 nIndex(pRowStyles->GetStyleNameIndex(nTable, nRows)); - for (sal_Int32 i = nRows + 1; i <= aCellAddress.EndRow; ++i) - pRowStyles->AddFieldStyleName(nTable, i, nIndex); + pRowStyles->AddFieldStyleName(nTable, nRows + 1, nIndex, aCellAddress.EndRow); } } } -- cgit