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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 30 06:30:19 UTC 2019


 include/svx/svdcrtv.hxx                        |    3 +
 svx/source/svdraw/svdcrtv.cxx                  |   45 +++++++++++++------------
 sw/qa/extras/tiledrendering/tiledrendering.cxx |    6 ++-
 sw/source/core/frmedt/feshview.cxx             |    1 
 4 files changed, 34 insertions(+), 21 deletions(-)

New commits:
commit b6b28931435e44aca92b8c0e1659f701e3ed1a87
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Fri Jan 25 14:40:40 2019 +0100
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Wed Jan 30 07:29:52 2019 +0100

    sw: Ctrl + shape insertion was not setting up the layer.
    
    The consequence was that the shapes were inserted into the background
    layer.
    
    The problem was particularly visible with the LOK, but reproducible on
    the desktop too.
    
    Includes unit test.
    
    Change-Id: I16137331f944101e25679ec8c4a034bea658bc57
    Reviewed-on: https://gerrit.libreoffice.org/66917
    Tested-by: Jenkins
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/include/svx/svdcrtv.hxx b/include/svx/svdcrtv.hxx
index 9b6a08e8f93b..2b1941373fb0 100644
--- a/include/svx/svdcrtv.hxx
+++ b/include/svx/svdcrtv.hxx
@@ -118,6 +118,9 @@ public:
     bool IsCreateObj() const { return pCurrentCreate!=nullptr; }
     SdrObject* GetCreateObj() const { return pCurrentCreate; }
 
+    /// Setup layer (eg. foreground / background) of the given object.
+    static void SetupObjLayer(const SdrPageView* pPageView, const OUString& aActiveLayer, SdrObject* pObj);
+
     // BegCreateCaptionObj() creates a SdrCaptionObj (legend item).
     // rObjSiz is the initial size of the legend text frame.
     // Only the length of the tip is dragged
diff --git a/svx/source/svdraw/svdcrtv.cxx b/svx/source/svdraw/svdcrtv.cxx
index 911481038d79..711080113382 100644
--- a/svx/source/svdraw/svdcrtv.cxx
+++ b/svx/source/svdraw/svdcrtv.cxx
@@ -569,6 +569,30 @@ void SdrCreateView::MovCreateObj(const Point& rPnt)
     }
 }
 
+void SdrCreateView::SetupObjLayer(const SdrPageView* pPageView, const OUString& aActiveLayer, SdrObject* pObj)
+{
+    const SdrLayerAdmin& rAd = pPageView->GetPage()->GetLayerAdmin();
+    SdrLayerID nLayer(0);
+
+    // #i72535#
+    if(dynamic_cast<const FmFormObj*>( pObj) !=  nullptr)
+    {
+        // for FormControls, force to form layer
+        nLayer = rAd.GetLayerID(rAd.GetControlLayerName());
+    }
+    else
+    {
+        nLayer = rAd.GetLayerID(aActiveLayer);
+    }
+
+    if(SDRLAYER_NOTFOUND == nLayer)
+    {
+        nLayer = SdrLayerID(0);
+    }
+
+    pObj->SetLayer(nLayer);
+}
+
 bool SdrCreateView::EndCreateObj(SdrCreateCmd eCmd)
 {
     bool bRet=false;
@@ -599,26 +623,7 @@ bool SdrCreateView::EndCreateObj(SdrCreateCmd eCmd)
                 SdrObject* pObj=pCurrentCreate;
                 pCurrentCreate=nullptr;
 
-                const SdrLayerAdmin& rAd = pCreatePV->GetPage()->GetLayerAdmin();
-                SdrLayerID nLayer(0);
-
-                // #i72535#
-                if(dynamic_cast<const FmFormObj*>( pObj) !=  nullptr)
-                {
-                    // for FormControls, force to form layer
-                    nLayer = rAd.GetLayerID(rAd.GetControlLayerName());
-                }
-                else
-                {
-                    nLayer = rAd.GetLayerID(maActualLayer);
-                }
-
-                if(SDRLAYER_NOTFOUND == nLayer)
-                {
-                    nLayer = SdrLayerID(0);
-                }
-
-                pObj->SetLayer(nLayer);
+                SetupObjLayer(pCreatePV, maActualLayer, pObj);
 
                 // recognize creation of a new 3D object inside a 3D scene
                 bool bSceneIntoScene(false);
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 6bd016702026..be14c00a8ba6 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -470,10 +470,14 @@ void SwTiledRenderingTest::testInsertShape()
     comphelper::dispatchCommand(".uno:BasicShapes.circle", uno::Sequence<beans::PropertyValue>());
 
     // check that the shape was inserted in the visible area, not outside
-    SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+    IDocumentDrawModelAccess &rDrawModelAccess = pWrtShell->GetDoc()->getIDocumentDrawModelAccess();
+    SdrPage* pPage = rDrawModelAccess.GetDrawModel()->GetPage(0);
     SdrObject* pObject = pPage->GetObj(0);
     CPPUNIT_ASSERT_EQUAL(tools::Rectangle(2736, 868, 7264, 3132), pObject->GetSnapRect());
 
+    // check that it is in the foreground layer
+    CPPUNIT_ASSERT_EQUAL(rDrawModelAccess.GetHeavenId().get(), pObject->GetLayer().get());
+
     comphelper::LibreOfficeKit::setActive(false);
 }
 
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index e7486384e692..126c95074b9e 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -3147,6 +3147,7 @@ long SwFEShell::GetSectionWidth( SwFormat const & rFormat ) const
             }
         }
         SdrPageView* pPageView = pDrawView->GetSdrPageView();
+        SdrCreateView::SetupObjLayer(pPageView, pDrawView->GetActiveLayer(), pObj);
         pDrawView->InsertObjectAtView(pObj, *pPageView);
     }
     ImpEndCreate();


More information about the Libreoffice-commits mailing list