Project not found: devel:openQA:GitHub:os-autoinst:openQA:PR-6642

File bsc1176197.diff of Package libreoffice

From 2331e98a7000421db99f14433f06c98da764b5ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCl=C5=9Fah=20K=C3=B6se?= <gulsah.kose@collabora.com>
Date: Mon, 5 Oct 2020 14:57:33 +0300
Subject: [PATCH] bsc#1176197.diff
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

tdf#128212 Change the text z camera rotation order.

Old order:
1) Apply all rotation values (normal and camera z)
2) Do the adjustment (top, middle, bottom)

New Order:
1) Apply rotation values except camera z
2) Do the adjustment (top, middle, bottom)
3) Apply camera z rotation.

We rotate the text at the center of the already positioned rectangle
of the text, which depends on e.g. the length of the laid out text.
This matches the PowerPoint behavior.

Change-Id: I8741cf443834bf01cc07c04318fd6205ed6a0dd6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103965
Tested-by: Jenkins
Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104448
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
---
 include/svx/svdoashp.hxx                      |  1 -
 include/svx/svdotext.hxx                      |  1 +
 svx/qa/unit/customshapes.cxx                  |  2 +-
 .../viewcontactofsdrobjcustomshape.cxx        | 21 +++--------
 svx/source/svdraw/svdoashp.cxx                | 17 ---------
 svx/source/svdraw/svdotextdecomposition.cxx   | 35 +++++++++++++++++++
 6 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx
index ff51e20ec974..a5ab4eac2d12 100644
--- a/include/svx/svdoashp.hxx
+++ b/include/svx/svdoashp.hxx
@@ -142,7 +142,6 @@ public:
 
     double GetObjectRotation() const { return fObjectRotation;}
     double GetExtraTextRotation( const bool bPreRotation = false ) const;
-    double GetCameraRotation() const;
 
     SdrObjCustomShape(SdrModel& rSdrModel);
 
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 020bcb6cdd22..6efae0b58feb 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -577,6 +577,7 @@ public:
     // Set single item at the local ItemSet. *Does not use* AllowItemChange(),
     // ItemChange(), PostItemChange() and ItemSetChanged() calls.
     void SetObjectItemNoBroadcast(const SfxPoolItem& rItem);
+    double GetCameraZRotation() const;
 
 public:
 
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index 796fa4824809..2e0ec9ce4d55 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -520,7 +520,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf126060_3D_Z_Rotation)
     SdrObjCustomShape& rSdrObjCustomShape(
         static_cast<SdrObjCustomShape&>(*GetSdrObjectFromXShape(xShape)));
 
-    if (rSdrObjCustomShape.GetCameraRotation() != 90)
+    if (rSdrObjCustomShape.GetCameraZRotation() != 90)
         sErrors += "Wrong text camera Z rotation";
 
     basegfx::B2DHomMatrix aObjectTransform;
diff --git a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
index 7a5c0487a13f..7132a1282540 100644
--- a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
@@ -167,18 +167,13 @@ namespace sdr
                     // #i101684# get the text range unrotated and absolute to the object range
                     const basegfx::B2DRange aTextRange(getCorrectedTextBoundRect());
 
-                    // Get the text range before unrotated and independent from object range
-                    const tools::Rectangle aIndTextRect(Point(aTextRange.getMinX(), aTextRange.getMinY()), GetCustomShapeObj().GetTextSize());
-                    const basegfx::B2DRange aIndTextRange = vcl::unotools::b2DRectangleFromRectangle(aIndTextRect);
-
                     // Rotation before scaling
-                    if(!basegfx::fTools::equalZero(GetCustomShapeObj().GetExtraTextRotation(true)) ||
-                       !basegfx::fTools::equalZero(GetCustomShapeObj().GetCameraRotation()))
+                    if(!basegfx::fTools::equalZero(GetCustomShapeObj().GetExtraTextRotation(true)))
                     {
                         basegfx::B2DVector aTranslation(0.5, 0.5);
                         aTextBoxMatrix.translate( -aTranslation.getX(), -aTranslation.getY() );
                         aTextBoxMatrix.rotate(basegfx::deg2rad(
-                            360.0 - GetCustomShapeObj().GetExtraTextRotation(true) - GetCustomShapeObj().GetCameraRotation()));
+                            360.0 - GetCustomShapeObj().GetExtraTextRotation(true)));
                         aTextBoxMatrix.translate( aTranslation.getX(), aTranslation.getY() );
                     }
                     // give text object a size
@@ -186,7 +181,6 @@ namespace sdr
 
                     // check if we have a rotation/shear at all to take care of
                     const double fExtraTextRotation(GetCustomShapeObj().GetExtraTextRotation());
-                    const double fTextCameraZRotation(GetCustomShapeObj().GetCameraRotation());
                     const GeoStat& rGeoStat(GetCustomShapeObj().GetGeoStat());
 
                     if(rGeoStat.nShearAngle || rGeoStat.nRotationAngle || !basegfx::fTools::equalZero(fExtraTextRotation))
@@ -199,13 +193,13 @@ namespace sdr
                                 aTextRange.getMinY() - aObjectRange.getMinimum().getY());
                         }
 
-                        if(!basegfx::fTools::equalZero(fExtraTextRotation) || !basegfx::fTools::equalZero(fTextCameraZRotation))
+                        if(!basegfx::fTools::equalZero(fExtraTextRotation))
                         {
                             basegfx::B2DVector aTranslation(
                                 ( aTextRange.getWidth() / 2 ) + ( aTextRange.getMinX() - aObjectRange.getMinimum().getX() ),
                                 ( aTextRange.getHeight() / 2 ) + ( aTextRange.getMinY() - aObjectRange.getMinimum().getY() ) );
                             aTextBoxMatrix.translate( -aTranslation.getX(), -aTranslation.getY() );
-                            aTextBoxMatrix.rotate(basegfx::deg2rad(360.0 - fExtraTextRotation + fTextCameraZRotation));
+                            aTextBoxMatrix.rotate(basegfx::deg2rad(360.0 - fExtraTextRotation));
                             aTextBoxMatrix.translate( aTranslation.getX(), aTranslation.getY() );
                         }
 
@@ -222,13 +216,6 @@ namespace sdr
                         // give text it's target position
                         aTextBoxMatrix.translate(aObjectRange.getMinimum().getX(), aObjectRange.getMinimum().getY());
                     }
-                    // If text overflows from textbox we should use text info instead of textbox to relocation.
-                    else if((aTextRange.getWidth() < aIndTextRange.getWidth() ||
-                            aTextRange.getHeight() < aIndTextRange.getHeight()) &&
-                            !basegfx::fTools::equalZero(fTextCameraZRotation))
-                    {
-                        aTextBoxMatrix.translate(aIndTextRange.getCenterX(), aIndTextRange.getCenterY());
-                    }
                     else
                     {
                         aTextBoxMatrix.translate(aTextRange.getMinX(), aTextRange.getMinY());
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 7d78963ea192..df25f2617343 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -529,23 +529,6 @@ double SdrObjCustomShape::GetExtraTextRotation( const bool bPreRotation ) const
     return fExtraTextRotateAngle;
 }
 
-double SdrObjCustomShape::GetCameraRotation() const
-{
-    const css::uno::Any* pAny;
-    double fTextCameraZRotateAngle = 0.0;
-    const SdrCustomShapeGeometryItem& rGeometryItem = GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
-    const OUString sTextCameraZRotateAngle( "TextCameraZRotateAngle" );
-
-    pAny = rGeometryItem.GetPropertyValueByName(sTextCameraZRotateAngle);
-
-    if ( pAny )
-        *pAny >>= fTextCameraZRotateAngle;
-
-    return fTextCameraZRotateAngle;
-}
-
-
-
 bool SdrObjCustomShape::GetTextBounds( tools::Rectangle& rTextBound ) const
 {
     bool bRet = false;
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx
index 1cc2b8a1df37..8d292764e1db 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -25,6 +25,7 @@
 #include <svx/svdmodel.hxx>
 #include <svx/textchain.hxx>
 #include <svx/textchainflow.hxx>
+#include <svx/sdasitm.hxx>
 #include <svx/sdtacitm.hxx>
 #include <svx/sdtayitm.hxx>
 #include <svx/sdtaiitm.hxx>
@@ -45,6 +46,7 @@
 #include <drawinglayer/animation/animationtiming.hxx>
 #include <basegfx/color/bcolor.hxx>
 #include <vcl/svapp.hxx>
+#include <vcl/canvastools.hxx>
 #include <editeng/escapementitem.hxx>
 #include <editeng/svxenum.hxx>
 #include <editeng/flditem.hxx>
@@ -1085,6 +1087,23 @@ void SdrTextObj::impDecomposeBlockTextPrimitive(
     const basegfx::B2DTuple aAdjOffset(fStartInX, fStartInY);
     basegfx::B2DHomMatrix aNewTransformA(basegfx::utils::createTranslateB2DHomMatrix(aAdjOffset.getX(), aAdjOffset.getY()));
 
+    // Apply the camera rotation. It have to be applied after adjustment of
+    // the text (top, bottom, center, left, right).
+    if(GetCameraZRotation() != 0)
+    {
+        // First find the text rect.
+        basegfx::B2DRange aTextRectangle(/*x1=*/aTranslate.getX() + aAdjustTranslate.getX(),
+                                         /*y1=*/aTranslate.getY() + aAdjustTranslate.getY(),
+                                         /*x2=*/aTranslate.getX() + aOutlinerScale.getX() - aAdjustTranslate.getX(),
+                                         /*y2=*/aTranslate.getY() + aOutlinerScale.getY() - aAdjustTranslate.getY());
+
+        // Rotate the text from the center point.
+        basegfx::B2DVector aTranslateToCenter(aTextRectangle.getWidth() / 2, aTextRectangle.getHeight() / 2);
+        aNewTransformA.translate(-aTranslateToCenter.getX(), -aTranslateToCenter.getY());
+        aNewTransformA.rotate(basegfx::deg2rad(360.0 - GetCameraZRotation() ));
+        aNewTransformA.translate(aTranslateToCenter.getX(), aTranslateToCenter.getY());
+    }
+
     // mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
     // move the null point which was top left to bottom right.
     const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
@@ -1096,6 +1115,7 @@ void SdrTextObj::impDecomposeBlockTextPrimitive(
         bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0,
         fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
 
+
     // create ClipRange (if needed)
     basegfx::B2DRange aClipRange;
 
@@ -1640,4 +1660,19 @@ void SdrTextObj::impDecomposeBlockTextPrimitiveDirect(
     rTarget.append(aConverter.getPrimitive2DSequence());
 }
 
+double SdrTextObj::GetCameraZRotation() const
+{
+    const css::uno::Any* pAny;
+    double fTextCameraZRotateAngle = 0.0;
+    const SfxItemSet& rSet = GetObjectItemSet();
+    const SdrCustomShapeGeometryItem& rGeometryItem(rSet.Get(SDRATTR_CUSTOMSHAPE_GEOMETRY));
+
+    pAny = rGeometryItem.GetPropertyValueByName("TextCameraZRotateAngle");
+
+    if ( pAny )
+        *pAny >>= fTextCameraZRotateAngle;
+
+    return fTextCameraZRotateAngle;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-- 
2.26.2

openSUSE Build Service is sponsored by