summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-07-26 17:05:24 +0200
committerMichael Stahl <mstahl@redhat.com>2013-07-27 00:45:19 +0200
commit8fb210a2ddc0b09288316cf459bebfe196ea94fb (patch)
treeddaef024a1ca4639ee0b811b5cd430fc3eef983f
parent2f9d2489791ee97a169df0cea932ed7f9ba1e66c (diff)
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) Change-Id: I8741b4c0cd51f8c244462ce28a754abc427d0df3
-rw-r--r--include/svl/style.hxx4
-rw-r--r--sw/inc/docstyle.hxx4
-rw-r--r--sw/source/ui/app/docstyle.cxx19
3 files changed, 24 insertions, 3 deletions
diff --git a/include/svl/style.hxx b/include/svl/style.hxx
index c54313ec96a2..9671bcf67918 100644
--- a/include/svl/style.hxx
+++ b/include/svl/style.hxx
@@ -203,9 +203,9 @@ friend class SfxStyleSheetBase;
SfxStyleSheetBasePool_Impl *pImp;
-private:
- SVL_DLLPRIVATE SfxStyleSheetIterator& GetIterator_Impl();
protected:
+ SfxStyleSheetIterator& GetIterator_Impl();
+
OUString aAppName;
SfxItemPool& rPool;
SfxStyles aStyles;
diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx
index fc2a59f7c137..14a7891a8b30 100644
--- a/sw/inc/docstyle.hxx
+++ b/sw/inc/docstyle.hxx
@@ -175,6 +175,8 @@ public:
virtual SfxStyleSheetBase* Find(const OUString& rStr);
virtual void Notify( SfxBroadcaster&, const SfxHint& );
+
+ void InvalidateIterator();
};
@@ -217,6 +219,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 740b30fd0341..4e55b76a9bb1 100644
--- a/sw/source/ui/app/docstyle.cxx
+++ b/sw/source/ui/app/docstyle.cxx
@@ -476,7 +476,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 )
@@ -2772,6 +2773,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First()
SfxStyleSheetBase* SwStyleSheetIterator::Next()
{
+ assert(bFirstCalled);
++nLastPos;
if(!aLst.empty() && nLastPos < aLst.size())
{
@@ -2866,6 +2868,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!!