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

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Fri Jan 26 20:42:57 UTC 2018


 sc/inc/drwlayer.hxx              |    1 +
 sc/source/core/data/column.cxx   |    9 ++-------
 sc/source/core/data/drwlayer.cxx |   25 +++++++++++++++++++++++++
 3 files changed, 28 insertions(+), 7 deletions(-)

New commits:
commit 401d4516234994d317a7c899358e8c2eef447fdc
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Tue Jan 23 11:22:27 2018 +0100

    Improve performance when searching for blocks w/o draw objects
    
    ... by returning when the first object in the lookup range has been found
    
    Follow-up for 3a2a430ae8e2c1647c18d8904477949f6e2e7941
    
    Change-Id: I5cc9a268793eb8d156a39b0a2de557220da96748
    Reviewed-on: https://gerrit.libreoffice.org/48395
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx
index 56c820d465d3..d9155d0d90f0 100644
--- a/sc/inc/drwlayer.hxx
+++ b/sc/inc/drwlayer.hxx
@@ -183,6 +183,7 @@ public:
     static void             UpdateCellAnchorFromPositionEnd( const SdrObject &rObj, ScDrawObjData &rAnchor, const ScDocument &rDoc, SCTAB nTab, bool bUseLogicRect = true );
     static ScAnchorType     GetAnchorType( const SdrObject& );
     std::vector<SdrObject*> GetObjectsAnchoredToCell(const ScAddress& rPos);
+    bool                    HasObjectsAnchoredInRange(ScRange& rRange);
     void MoveObject(SdrObject* pObj, ScAddress& rNewPosition);
 
     // positions for detektive lines
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index e8d773f6923f..71c9da711428 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1927,13 +1927,8 @@ bool ScColumn::IsDrawObjectsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const
     if (!pDrawLayer)
         return true;
 
-    for (SCROW nCurrentRow = nStartRow; nCurrentRow <= nEndRow; nCurrentRow++)
-    {
-        ScAddress aCell(nCol, nCurrentRow, nTab);
-        if (!pDrawLayer->GetObjectsAnchoredToCell(aCell).empty())
-            return false;
-    }
-    return true;
+    ScRange aRange(nCol, nStartRow, nTab, nCol, nEndRow, nTab);
+    return !pDrawLayer->HasObjectsAnchoredInRange(aRange);
 }
 
 void ScColumn::SwapCol(ScColumn& rCol)
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 7f2124d98755..4be458e21500 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -2017,6 +2017,31 @@ std::vector<SdrObject*> ScDrawLayer::GetObjectsAnchoredToCell(const ScAddress& r
     return pObjects;
 }
 
+bool ScDrawLayer::HasObjectsAnchoredInRange(ScRange& rRange)
+{
+    // This only works for one table at a time
+    assert(rRange.aStart.Tab() == rRange.aEnd.Tab());
+
+    SdrPage* pPage = GetPage(static_cast<sal_uInt16>(rRange.aStart.Tab()));
+    if (!pPage || pPage->GetObjCount() < 1)
+        return false;
+
+    SdrObjListIter aIter( *pPage, SdrIterMode::Flat );
+    SdrObject* pObject = aIter.Next();
+    ScDrawObjData* pObjData;
+    while (pObject)
+    {
+        if (!dynamic_cast<SdrCaptionObj*>(pObject)) // Caption objects are handled differently
+        {
+            pObjData = GetObjData(pObject);
+            if (pObjData && rRange.In(pObjData->maStart)) // Object is in given range
+                return true;
+        }
+        pObject = aIter.Next();
+    }
+    return false;
+}
+
 void ScDrawLayer::MoveObject(SdrObject* pObject, ScAddress& rNewPosition)
 {
     // Get anchor data


More information about the Libreoffice-commits mailing list