[Libreoffice-commits] core.git: sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Oct 31 09:17:33 PDT 2014


 sw/inc/unodraw.hxx                 |    4 ++++
 sw/source/core/unocore/unodraw.cxx |   26 ++++++++++++++++++++++----
 2 files changed, 26 insertions(+), 4 deletions(-)

New commits:
commit 693014c9d3dcbf3c649d775143918e531b6e3ac0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Oct 31 17:00:45 2014 +0100

    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

diff --git a/sw/inc/unodraw.hxx b/sw/inc/unodraw.hxx
index 540448d..06b4c30 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 af81b35..8bcb838 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


More information about the Libreoffice-commits mailing list