diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-10-31 17:00:45 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-10-31 17:17:02 +0100 |
commit | 693014c9d3dcbf3c649d775143918e531b6e3ac0 (patch) | |
tree | ac0fef8fdc8a2522810c5dd44a18d832b79a9b50 | |
parent | 32bbe44e894a6575899418cff88f0ccdd5dae393 (diff) |
SwXShapesEnumeration: don't generate a set of TextBoxes for each shape
Instead, generate it once and then pass around that list. Again, this
helps ODF export.
For a test document of 2000 mail merge records and 16 frames, the times
for css::text::MailMerge::execute() are 7m53.575s -> 7m30.261s.
Change-Id: Iec993ec34392350b1e26857f7d5434a0a9c494a3
-rw-r--r-- | sw/inc/unodraw.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/unocore/unodraw.cxx | 26 |
2 files changed, 26 insertions, 4 deletions
diff --git a/sw/inc/unodraw.hxx b/sw/inc/unodraw.hxx index 540448dd6965..06b4c3004710 100644 --- a/sw/inc/unodraw.hxx +++ b/sw/inc/unodraw.hxx @@ -34,6 +34,7 @@ #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/drawing/HomogenMatrix3.hpp> #include <svl/itemprop.hxx> +#include <set> class SdrMarkList; class SdrView; @@ -116,6 +117,9 @@ public: SwFmDrawPage* GetSvxPage(); // renamed and outlined to detect where it's called void InvalidateSwDoc(); // {pDoc = 0;} + SwDoc* GetDoc(); + /// Same as getByIndex(nIndex), except that it also takes a set of formats to ignore, so the method itself doesn't have to generate such a list. + css::uno::Any getByIndex(sal_Int32 nIndex, std::set<const SwFrmFmt*>* pTextBoxes) throw(css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception); }; class SwShapeDescriptor_Impl; diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index af81b3550b14..8bcb838d3227 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -404,9 +404,10 @@ SwXShapesEnumeration::SwXShapesEnumeration(SwXDrawPage* const pDrawPage) SolarMutexGuard aGuard; ::std::insert_iterator<shapescontainer_t> pInserter = ::std::insert_iterator<shapescontainer_t>(m_aShapes, m_aShapes.begin()); sal_Int32 nCount = pDrawPage->getCount(); + std::set<const SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDrawPage->GetDoc()); for(sal_Int32 nIdx = 0; nIdx < nCount; nIdx++) { - uno::Reference<drawing::XShape> xShape = uno::Reference<drawing::XShape>(pDrawPage->getByIndex(nIdx), uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape = uno::Reference<drawing::XShape>(pDrawPage->getByIndex(nIdx, &aTextBoxes), uno::UNO_QUERY); *pInserter++ = uno::makeAny(xShape); } } @@ -545,6 +546,12 @@ uno::Any SwXDrawPage::getByIndex(sal_Int32 nIndex) throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) { + return getByIndex(nIndex, 0); +} + +uno::Any SwXDrawPage::getByIndex(sal_Int32 nIndex, std::set<const SwFrmFmt*>* pTextBoxes) + throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception) +{ SolarMutexGuard aGuard; if(!pDoc) throw uno::RuntimeException(); @@ -552,11 +559,17 @@ uno::Any SwXDrawPage::getByIndex(sal_Int32 nIndex) throw lang::IndexOutOfBoundsException(); ((SwXDrawPage*)this)->GetSvxPage(); - std::set<const SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); - if (aTextBoxes.empty()) + std::set<const SwFrmFmt*> aTextBoxes; + if (!pTextBoxes) + { + // We got no set, so let's generate one. + aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc); + pTextBoxes = &aTextBoxes; + } + if (pTextBoxes->empty()) return pDrawPage->getByIndex( nIndex ); else - return SwTextBoxHelper::getByIndex(pDrawPage->GetSdrPage(), nIndex, aTextBoxes); + return SwTextBoxHelper::getByIndex(pDrawPage->GetSdrPage(), nIndex, *pTextBoxes); } uno::Type SwXDrawPage::getElementType(void) throw( uno::RuntimeException, std::exception ) @@ -864,6 +877,11 @@ void SwXDrawPage::InvalidateSwDoc() pDoc = 0; } +SwDoc* SwXDrawPage::GetDoc() +{ + return pDoc; +} + TYPEINIT1(SwXShape, SwClient); namespace |