[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - svl/inc sw/inc sw/source

Michael Stahl mstahl at redhat.com
Sun Jul 28 06:14:01 PDT 2013


 svl/inc/svl/style.hxx         |    4 ++--
 sw/inc/docstyle.hxx           |    4 ++++
 sw/source/ui/app/docstyle.cxx |   19 ++++++++++++++++++-
 3 files changed, 24 insertions(+), 3 deletions(-)

New commits:
commit c83026ede5a9ae57683b92d1919e874696024944
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Jul 26 17:05:24 2013 +0200

    fdo#67303: sw: speed up setting IsHidden property on styles
    
    Importing an ODF document with 4089 styles is ridiculously slow,
    spending most of the time in SwStyleSheetIterator::First() to reset
    an existing iterator.
    
    Since the SwStyleSheetIterator can handle the case when First() has not
    been called anyway, just add a new method that resets the bFirstCalled
    flag, which takes next to no time.
    
    (regression from a0dcf961879ab644a52f801f65466756cb144b72)
    
    (cherry picked from commit 8fb210a2ddc0b09288316cf459bebfe196ea94fb)
    
    Conflicts:
    	svl/inc/svl/style.hxx
    
    Change-Id: I8741b4c0cd51f8c244462ce28a754abc427d0df3
    Reviewed-on: https://gerrit.libreoffice.org/5138
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/svl/inc/svl/style.hxx b/svl/inc/svl/style.hxx
index 48557c5..cfe1a9b 100644
--- a/svl/inc/svl/style.hxx
+++ b/svl/inc/svl/style.hxx
@@ -202,9 +202,9 @@ friend class SfxStyleSheetBase;
 
     SfxStyleSheetBasePool_Impl *pImp;
 
-private:
-    SVL_DLLPRIVATE SfxStyleSheetIterator&      GetIterator_Impl();
 protected:
+    SfxStyleSheetIterator&      GetIterator_Impl();
+
     String                      aAppName;
     SfxItemPool&                rPool;
     SfxStyles                   aStyles;
diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx
index 42d1b92..b4245b5 100644
--- a/sw/inc/docstyle.hxx
+++ b/sw/inc/docstyle.hxx
@@ -175,6 +175,8 @@ public:
     virtual SfxStyleSheetBase* Find(const rtl::OUString& rStr);
 
     virtual void Notify( SfxBroadcaster&, const SfxHint& );
+
+    void InvalidateIterator();
 };
 
 
@@ -218,6 +220,8 @@ public:
     virtual void SAL_CALL acquire(  ) throw ();
     virtual void SAL_CALL release(  ) throw ();
 
+    void InvalidateIterator();
+
 protected:
     virtual ~SwDocStyleSheetPool();
 
diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx
index 4a8458a..3c9da90 100644
--- a/sw/source/ui/app/docstyle.cxx
+++ b/sw/source/ui/app/docstyle.cxx
@@ -511,7 +511,8 @@ void SwDocStyleSheet::SetHidden( sal_Bool bValue )
 
     if( bChg )
     {
-        pPool->First();  // internal list has to be updated
+        // calling pPool->First() here would be quite slow...
+        dynamic_cast<SwDocStyleSheetPool*>(pPool)->InvalidateIterator(); // internal list has to be updated
         pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) );
         SwEditShell* pSh = rDoc.GetEditShell();
         if( pSh )
@@ -2853,6 +2854,7 @@ SfxStyleSheetBase*  SwStyleSheetIterator::First()
 
 SfxStyleSheetBase*  SwStyleSheetIterator::Next()
 {
+    assert(bFirstCalled);
     ++nLastPos;
     if(!aLst.empty() && nLastPos < aLst.size())
     {
@@ -2947,6 +2949,21 @@ void SwStyleSheetIterator::AppendStyleList(const boost::ptr_vector<String>& rLis
     }
 }
 
+void SwDocStyleSheetPool::InvalidateIterator()
+{
+    dynamic_cast<SwStyleSheetIterator&>(GetIterator_Impl()).InvalidateIterator();
+}
+
+void  SwStyleSheetIterator::InvalidateIterator()
+{
+    // potentially we could send an SfxHint to Notify but currently it's
+    // iterating over the vector anyway so would still be slow - why does
+    // this iterator not use a map?
+    bFirstCalled = false;
+    nLastPos = 0;
+    aLst.Erase();
+}
+
 void  SwStyleSheetIterator::Notify( SfxBroadcaster&, const SfxHint& rHint )
 {
     // search and remove from View-List!!


More information about the Libreoffice-commits mailing list