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

Regina Henschel (via logerrit) logerrit at kemper.freedesktop.org
Wed Mar 4 13:23:42 UTC 2020


 sd/qa/unit/data/tdf131033_3D_SceneSizeIn2d.odg |binary
 sd/qa/unit/misc-tests.cxx                      |   26 +++++++++++++++++++++++++
 svx/source/engine3d/view3d.cxx                 |   16 +++++++--------
 3 files changed, 34 insertions(+), 8 deletions(-)

New commits:
commit a33484276ed16af7599a59653677f21f051c97e8
Author:     Regina Henschel <rb.henschel at t-online.de>
AuthorDate: Tue Mar 3 18:12:36 2020 +0100
Commit:     Regina Henschel <rb.henschel at t-online.de>
CommitDate: Wed Mar 4 14:22:49 2020 +0100

    tdf#131033 consider 20° tilt of 3D in 2D projection
    
    Error was, that the default 20° tilt of a newly created 3D scene was
    not applied to the rectangle for the 2D projection and therefore the
    projection was not high enough. The used method is the same as used
    when dragging a scene to tilt it. I don't know whether there exists
    a simpler way.
    
    Change-Id: Ic9745cc17ed520cd9e00b123e235fe0e93100073
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89901
    Tested-by: Jenkins
    Reviewed-by: Regina Henschel <rb.henschel at t-online.de>

diff --git a/sd/qa/unit/data/tdf131033_3D_SceneSizeIn2d.odg b/sd/qa/unit/data/tdf131033_3D_SceneSizeIn2d.odg
new file mode 100644
index 000000000000..f6cfc96e6b12
Binary files /dev/null and b/sd/qa/unit/data/tdf131033_3D_SceneSizeIn2d.odg differ
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx
index 6871b2d432e3..3e23752aa477 100644
--- a/sd/qa/unit/misc-tests.cxx
+++ b/sd/qa/unit/misc-tests.cxx
@@ -81,6 +81,7 @@ public:
     void testTdf120527();
     void testTdf98839_ShearVFlipH();
     void testTdf130988();
+    void testTdf131033();
 
     CPPUNIT_TEST_SUITE(SdMiscTest);
     CPPUNIT_TEST(testTdf96206);
@@ -100,6 +101,7 @@ public:
     CPPUNIT_TEST(testTdf120527);
     CPPUNIT_TEST(testTdf98839_ShearVFlipH);
     CPPUNIT_TEST(testTdf130988);
+    CPPUNIT_TEST(testTdf131033);
     CPPUNIT_TEST_SUITE_END();
 
 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -828,6 +830,30 @@ void SdMiscTest::testTdf130988()
     xDocShRef->DoClose();
 }
 
+void SdMiscTest::testTdf131033()
+{
+    const OUString sURL("sd/qa/unit/data/tdf131033_3D_SceneSizeIn2d.odg");
+    sd::DrawDocShellRef xDocShRef = Load(m_directories.getURLFromSrc(sURL), ODG);
+
+    // The document contains a polygon, so that emulate command .uno:ConvertInto3DLathe
+    // by direct call of ConvertMarkedObjTo3D works.
+    // It produces a rotation around a vertical axis, which is far away from the
+    // generating shape.
+    sd::ViewShell* pViewShell = xDocShRef->GetViewShell();
+    E3dView* pView = dynamic_cast<E3dView*>(pViewShell->GetView());
+    pView->MarkNextObj();
+    pView->ConvertMarkedObjTo3D(false, basegfx::B2DPoint(11000.0, -5000.0), basegfx::B2DPoint(11000.0, -9000.0));
+    E3dScene* pObj = dynamic_cast<E3dScene*>(pView->GetMarkedObjectByIndex(0));
+    CPPUNIT_ASSERT(pObj);
+
+    // Error was, that the 2D representation of the scene did not contain the default 20°
+    // rotation of the new scene around x-axis and therefore was not high enough.
+    const double fSnapRectHeight = pObj->GetSnapRect().getHeight();
+    CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("2D height", 7096.0, fSnapRectHeight, 1.0);
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx
index c756c90439c8..77d94ab1c581 100644
--- a/svx/source/engine3d/view3d.cxx
+++ b/svx/source/engine3d/view3d.cxx
@@ -50,6 +50,7 @@
 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+#include <svx/e3dsceneupdater.hxx>
 
 using namespace com::sun::star;
 
@@ -969,23 +970,22 @@ void E3dView::ConvertMarkedObjTo3D(bool bExtrude, const basegfx::B2DPoint& rPnt1
         MarkObj(pScene, pPV);
 
         // Rotate Rotation body around the axis of rotation
-        basegfx::B3DHomMatrix aRotate;
-
         if(!bExtrude && fRot3D != 0.0)
         {
+            basegfx::B3DHomMatrix aRotate;
             aRotate.rotate(0.0, 0.0, fRot3D);
+            pScene->SetTransform(aRotate * pScene->GetTransform());
         }
 
         // Set default rotation
-        aRotate.rotate(DEG2RAD(20.0), 0.0, 0.0);
-
-        if(!aRotate.isIdentity())
         {
+            basegfx::B3DHomMatrix aRotate;
+            aRotate.rotate(DEG2RAD(20.0), 0.0, 0.0);
+            // E3DModifySceneSnapRectUpdater updates the 2D representation of the scene.
+            // It prepares things in ctor and acts in dtor.
+            E3DModifySceneSnapRectUpdater aUpdater(pScene->getSdrObjectFromSdrObjList());
             pScene->SetTransform(aRotate * pScene->GetTransform());
         }
-
-        // Invalid SnapRects of objects
-        pScene->SetSnapRect(aRect);
     }
     else
     {


More information about the Libreoffice-commits mailing list