[Libreoffice-commits] core.git: include/svx sd/source svx/source

Jochen Nitschke j.nitschke+logerrit at ok.de
Thu Sep 29 04:21:19 UTC 2016


 include/svx/svdpagv.hxx       |    7 ---
 sd/source/ui/func/fusel.cxx   |    2 -
 sd/source/ui/func/futext.cxx  |    2 -
 svx/source/svdraw/svdmrkv.cxx |   29 ----------------
 svx/source/svdraw/svdpagv.cxx |   74 +++++++++++++++++-------------------------
 5 files changed, 35 insertions(+), 79 deletions(-)

New commits:
commit a87a31602165cb2a37c32f5928e4f9daade7271d
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Tue Aug 2 14:30:09 2016 +0200

    merge SdrPageView::IsObjSelectable and SdrPageView::IsObjMarkable
    
    These member functions have the same purpose and share same
    functionality in great parts.
    The checks are rewritten for better readability and merged
    into IsObjMarkable.
    This adds IsInserted and a same page check to the function.
    
    Tested selection of nested grouped objects.
    Tested selection of objects in front of objects on master pages.
    
    The fix for #i43302# doesn't seem nessasary (saw no way to create
    empty groups) but leaving it on for now.
    
    Change-Id: I35d84c66dfd832d626ba2700f22d4c437593cac7
    Reviewed-on: https://gerrit.libreoffice.org/27786
    Reviewed-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>
    Tested-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>

diff --git a/include/svx/svdpagv.hxx b/include/svx/svdpagv.hxx
index e410b43..98bd49e 100644
--- a/include/svx/svdpagv.hxx
+++ b/include/svx/svdpagv.hxx
@@ -232,14 +232,9 @@ public:
     /// At least one member must be visible for the Group object and
     /// it must not be locked
     /// @returns
-    //       true, if the object's layer is visible and not locked
+    ///      true, if the object's layer is visible and not locked
     bool IsObjMarkable(SdrObject* pObj) const;
 
-    /// Hmm, selectable is surely the same as markable, now that I
-    /// see this as I look for a place to put it.
-    /// TODO: merge these
-    bool IsObjSelectable(SdrObject *pObj) const;
-
     /// Entering (editing) an object group
     /// After that, we have direct access to all member objects of the group.
     /// All other objects are not editable in the meantime (until the next
diff --git a/sd/source/ui/func/fusel.cxx b/sd/source/ui/func/fusel.cxx
index 6ba4695..007cb96 100644
--- a/sd/source/ui/func/fusel.cxx
+++ b/sd/source/ui/func/fusel.cxx
@@ -673,7 +673,7 @@ bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
                 SdrObject* pObj;
                 if (mpView->PickObj(aMDPos, mpView->getHitTolLog(), pObj, pPV, SdrSearchOptions::ALSOONMASTER | SdrSearchOptions::BEFOREMARK))
                 {
-                    if (pPV->IsObjSelectable(pObj))
+                    if (pPV->IsObjMarkable(pObj))
                     {
                         mpView->UnmarkAllObj();
                         mpView->MarkObj(pObj,pPV);
diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx
index 9b0979b..6ae69e7 100644
--- a/sd/source/ui/func/futext.cxx
+++ b/sd/source/ui/func/futext.cxx
@@ -660,7 +660,7 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt)
             SdrPageView* pPV;
             if (mpView->PickObj(aMDPos, mpView->getHitTolLog(), pObj, pPV, SdrSearchOptions::ALSOONMASTER | SdrSearchOptions::BEFOREMARK))
             {
-                if (pPV->IsObjSelectable(pObj))
+                if (pPV->IsObjMarkable(pObj))
                 {
                     mpView->UnmarkAllObj();
                     mpView->MarkObj(pObj,pPV);
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 3cc3836..5c66491 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -1270,33 +1270,6 @@ SfxViewShell* SdrMarkView::GetSfxViewShell() const
     return SfxViewShell::Current();
 }
 
-bool SdrPageView::IsObjSelectable(SdrObject *pObj) const
-{
-    SdrLayerID nLay=pObj->GetLayer();
-    bool bRaus=!pObj->IsInserted(); // Obj deleted?
-    if (!pObj->Is3DObj()) {
-        bRaus=bRaus || pObj->GetPage()!=GetPage();   // Obj suddenly in different Page or Group
-    }
-    bRaus=bRaus || GetLockedLayers().IsSet(nLay) ||  // Layer locked?
-                   !GetVisibleLayers().IsSet(nLay);  // Layer invisible?
-
-    if( !bRaus )
-        bRaus = !pObj->IsVisible(); // invisible objects can not be selected
-
-    if (!bRaus) {
-        // Grouped objects can now be selected.
-        // After EnterGroup the higher-level objects,
-        // have to be deselected, though.
-        const SdrObjList* pOOL=pObj->GetObjList();
-        const SdrObjList* pVOL=GetObjList();
-        while (pOOL!=nullptr && pOOL!=pVOL) {
-            pOOL=pOOL->GetUpList();
-        }
-        bRaus=pOOL!=pVOL;
-    }
-    return !bRaus;
-}
-
 void SdrMarkView::CheckMarked()
 {
     for (size_t nm=GetMarkedObjectCount(); nm>0;) {
@@ -1304,7 +1277,7 @@ void SdrMarkView::CheckMarked()
         SdrMark* pM = GetSdrMarkByIndex(nm);
         SdrObject* pObj = pM->GetMarkedSdrObj();
         SdrPageView* pPV = pM->GetPageView();
-        bool bRaus = !pObj || !pPV->IsObjSelectable(pObj);
+        bool bRaus = !pObj || !pPV->IsObjMarkable(pObj);
         if (bRaus)
         {
             GetMarkedObjectListWriteAccess().DeleteMark(nm);
diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx
index 8d2b06e..0fafd16 100644
--- a/svx/source/svdraw/svdpagv.cxx
+++ b/svx/source/svdraw/svdpagv.cxx
@@ -647,59 +647,47 @@ bool SdrPageView::IsLayer(const OUString& rName, const SetOfByte& rBS) const
 
 bool SdrPageView::IsObjMarkable(SdrObject* pObj) const
 {
-    if(pObj)
+    if (!pObj)
+        return false;
+    if (pObj->IsMarkProtect())
+        return false;    // excluded from selection?
+    if (!pObj->IsVisible())
+        return false;    // only visible are selectable
+    if (!pObj->IsInserted())
+        return false;    // Obj deleted?
+    if (dynamic_cast<const SdrObjGroup*>(pObj) !=  nullptr)
     {
-        // excluded from selection?
-        if(pObj->IsMarkProtect())
-        {
-            return false;
-        }
-
-        // only visible are selectable
-        if( !pObj->IsVisible() )
-        {
-            return false;
-        }
+        // If object is a Group object, visibility may depend on
+        // multiple layers. If one object is markable, Group is markable.
+        SdrObjList* pObjList = static_cast<SdrObjGroup*>(pObj)->GetSubList();
 
-        if(dynamic_cast<const SdrObjGroup*>( pObj) !=  nullptr)
+        if (pObjList && pObjList->GetObjCount())
         {
-            // If object is a Group object, visibility may depend on
-            // multiple layers. If one object is markable, Group is markable.
-            SdrObjList* pObjList = static_cast<SdrObjGroup*>(pObj)->GetSubList();
-
-            if(pObjList && pObjList->GetObjCount())
+            for (size_t a = 0; a < pObjList->GetObjCount(); ++a)
             {
-                bool bGroupIsMarkable(false);
-
-                for(size_t a = 0; !bGroupIsMarkable && a < pObjList->GetObjCount(); ++a)
-                {
-                    SdrObject* pCandidate = pObjList->GetObj(a);
-
-                    // call recursively
-                    if(IsObjMarkable(pCandidate))
-                    {
-                        bGroupIsMarkable = true;
-                    }
-                }
-
-                return bGroupIsMarkable;
-            }
-            else
-            {
-                // #i43302#
-                // Allow empty groups to be selected to be able to delete them
-                return true;
+                SdrObject* pCandidate = pObjList->GetObj(a);
+                // call recursively
+                if (IsObjMarkable(pCandidate))
+                    return true;
             }
+            return false;
         }
         else
         {
-            // the layer has to be visible and must not be locked
-            SdrLayerID nL = pObj->GetLayer();
-            return (aLayerVisi.IsSet(sal_uInt8(nL)) && !aLayerLock.IsSet(sal_uInt8(nL)));
+            // #i43302#
+            // Allow empty groups to be selected to be able to delete them
+            return true;
         }
     }
-
-    return false;
+    if (!pObj->Is3DObj() && pObj->GetPage()!=GetPage())
+        return false; // Obj suddenly in different Page
+    // the layer has to be visible and must not be locked
+    SdrLayerID nL = pObj->GetLayer();
+    if (!aLayerVisi.IsSet(sal_uInt8(nL)))
+        return false;
+    if (aLayerLock.IsSet(sal_uInt8(nL)))
+        return false;
+    return true;
 }
 
 void SdrPageView::SetPageOrigin(const Point& rOrg)


More information about the Libreoffice-commits mailing list