summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-05-30 21:30:29 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-05-31 09:36:43 +0200
commit36cee080555c759443896cb3b34c3f710f33e0f0 (patch)
tree974541af9ad7e7b8a7554c0dcebc25c811cc7f42
parent35870d411de99f278507785c4386dd02f9537073 (diff)
tdf#66765 - FILESAVE: saving sheet with some queries in it takes forever
This takes the save time from 5m30 to 1s. We were firing up the editeng stuff for every single style entry, when most of the style entries share the same cell. Change-Id: Id11af0b7f5646ff7ccdf1b85014fa384b0465054 Reviewed-on: https://gerrit.libreoffice.org/73239 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx41
1 files changed, 26 insertions, 15 deletions
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 7a0c605cba00..06917c278589 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2449,31 +2449,42 @@ void ScXMLExport::collectAutoStyles()
// stored text styles
+ // Calling createTextCursor fires up editeng, which is very slow, and often subsequent style entries
+ // refer to the same cell, so cache it.
+ ScAddress aPrevPos;
+ uno::Reference<beans::XPropertySet> xPrevCursorProp;
const std::vector<ScTextStyleEntry>& rTextEntries = pSheetData->GetTextStyles();
for (const auto& rTextEntry : rTextEntries)
{
ScAddress aPos = rTextEntry.maCellPos;
sal_Int32 nTable = aPos.Tab();
bool bCopySheet = pDoc->IsStreamValid( static_cast<SCTAB>(nTable) );
- if (bCopySheet)
- {
- //! separate method AddStyleFromText needed?
- //! cache sheet object
+ if (!bCopySheet)
+ continue;
+ //! separate method AddStyleFromText needed?
+ //! cache sheet object
+
+ uno::Reference<beans::XPropertySet> xCursorProp;
+ if (xPrevCursorProp && aPrevPos == aPos)
+ xCursorProp = xPrevCursorProp;
+ else
+ {
uno::Reference<table::XCellRange> xCellRange(xIndex->getByIndex(nTable), uno::UNO_QUERY);
uno::Reference<text::XSimpleText> xCellText(xCellRange->getCellByPosition(aPos.Col(), aPos.Row()), uno::UNO_QUERY);
- uno::Reference<beans::XPropertySet> xCursorProp(xCellText->createTextCursor(), uno::UNO_QUERY);
- ScCellTextCursor* pCursor = ScCellTextCursor::getImplementation( xCursorProp );
- if (pCursor)
- {
- pCursor->SetSelection( rTextEntry.maSelection );
-
- std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(xCursorProp));
- OUString sName( rTextEntry.maName );
- GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_TEXT, OUString(), aPropStates);
- GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_TEXT, sName);
- }
+ xCursorProp.set(xCellText->createTextCursor(), uno::UNO_QUERY);
}
+ ScCellTextCursor* pCursor = ScCellTextCursor::getImplementation( xCursorProp );
+ if (!pCursor)
+ continue;
+ pCursor->SetSelection( rTextEntry.maSelection );
+
+ std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(xCursorProp));
+ OUString sName( rTextEntry.maName );
+ GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TEXT_TEXT, OUString(), aPropStates);
+ GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TEXT_TEXT, sName);
+ xPrevCursorProp = xCursorProp;
+ aPrevPos = aPos;
}
}