[Libreoffice-commits] core.git: sc/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri May 31 07:37:21 UTC 2019


 sc/source/filter/xml/xmlexprt.cxx |   41 ++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 15 deletions(-)

New commits:
commit 36cee080555c759443896cb3b34c3f710f33e0f0
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu May 30 21:30:29 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri May 31 09:36:43 2019 +0200

    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 at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

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;
             }
         }
 


More information about the Libreoffice-commits mailing list