summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorGülşah Köse <gulsah.kose@collabora.com>2019-10-03 08:37:00 +0300
committerMiklos Vajna <vmiklos@collabora.com>2019-10-30 09:42:04 +0100
commit96d3c1ad905e4c694df4dccba51079b8f0a54d32 (patch)
tree0637576aca97e4e2f4ff74b99ac9b5f73ec2a444 /svx
parent09dfad2098d1737c0519c8ad74dd67b4292e73d1 (diff)
tdf#126060 Handle text camera z rotation while pptx import.
Reviewed-on: https://gerrit.libreoffice.org/80587 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com> tdf#128209 Add check for crash handling 3D rotation. Handling text 3D z rotation works only for custom shapes. Prevent to use it for other services. Reviewed-on: https://gerrit.libreoffice.org/80974 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com> 49e0127419dbad8a75f1899db02115a2fe54aacd Change-Id: Ifa4589fb50affc4c5ffb52288db8533c98ec6dd9 Reviewed-on: https://gerrit.libreoffice.org/80928 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/qa/unit/customshapes.cxx31
-rw-r--r--svx/qa/unit/data/tdf126060_3D_Z_Rotation.pptxbin0 -> 32602 bytes
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx22
-rw-r--r--svx/source/svdraw/svdoashp.cxx17
4 files changed, 66 insertions, 4 deletions
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index b70a8e536218..a7f399c74ecf 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -413,6 +413,37 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testQuadraticCurveTo)
//Add some tolerance
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("bad height of quadraticcurveto", 3004, fHeight, 10.0);
}
+
+CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf126060_3D_Z_Rotation)
+{
+ // The document contains one textbox with inside overflowed text
+ // and the text has 3D z rotation. When we open the document we
+ // should see the text vertically and rotated from text bound center not text box.
+
+ const OUString sFileName("tdf126060_3D_Z_Rotation.pptx");
+ OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + sFileName;
+ mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument");
+ CPPUNIT_ASSERT_MESSAGE("Could not load document", mxComponent.is());
+ OUString sErrors; // sErrors collects the errors and should be empty in case all is OK.
+
+ uno::Reference<drawing::XShape> xShape(getShape(0));
+ SdrObjCustomShape& rSdrObjCustomShape(
+ static_cast<SdrObjCustomShape&>(*GetSdrObjectFromXShape(xShape)));
+
+ if (rSdrObjCustomShape.GetCameraRotation() != 90)
+ sErrors += "Wrong text camera Z rotation";
+
+ basegfx::B2DHomMatrix aObjectTransform;
+ basegfx::B2DPolyPolygon aObjectPolyPolygon;
+ rSdrObjCustomShape.TRGetBaseGeometry(aObjectTransform, aObjectPolyPolygon);
+
+ if (aObjectTransform.get(0, 0) != 1492 || aObjectTransform.get(0, 1) != 0
+ || aObjectTransform.get(0, 2) != 1129 || aObjectTransform.get(1, 0) != 0
+ || aObjectTransform.get(1, 1) != 2500 || aObjectTransform.get(1, 2) != 5846)
+ sErrors += " Wrong transformation matrix";
+
+ CPPUNIT_ASSERT_EQUAL(OUString(), sErrors);
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/qa/unit/data/tdf126060_3D_Z_Rotation.pptx b/svx/qa/unit/data/tdf126060_3D_Z_Rotation.pptx
new file mode 100644
index 000000000000..8c8798f21a61
--- /dev/null
+++ b/svx/qa/unit/data/tdf126060_3D_Z_Rotation.pptx
Binary files differ
diff --git a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
index 8a1029138751..d26753030b6f 100644
--- a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
@@ -30,6 +30,7 @@
#include <svx/obj3d.hxx>
#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
#include <vcl/canvastools.hxx>
+#include <sal/log.hxx>
namespace sdr
@@ -156,13 +157,18 @@ 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)))
+ if(!basegfx::fTools::equalZero(GetCustomShapeObj().GetExtraTextRotation(true)) ||
+ !basegfx::fTools::equalZero(GetCustomShapeObj().GetCameraRotation()))
{
basegfx::B2DVector aTranslation(0.5, 0.5);
aTextBoxMatrix.translate( -aTranslation.getX(), -aTranslation.getY() );
aTextBoxMatrix.rotate(basegfx::deg2rad(
- 360.0 - GetCustomShapeObj().GetExtraTextRotation(true)));
+ 360.0 - GetCustomShapeObj().GetExtraTextRotation(true) - GetCustomShapeObj().GetCameraRotation()));
aTextBoxMatrix.translate( aTranslation.getX(), aTranslation.getY() );
}
// give text object a size
@@ -170,6 +176,7 @@ 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))
@@ -182,13 +189,13 @@ namespace sdr
aTextRange.getMinY() - aObjectRange.getMinimum().getY());
}
- if(!basegfx::fTools::equalZero(fExtraTextRotation))
+ if(!basegfx::fTools::equalZero(fExtraTextRotation) || !basegfx::fTools::equalZero(fTextCameraZRotation))
{
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));
+ aTextBoxMatrix.rotate(basegfx::deg2rad(360.0 - fExtraTextRotation + fTextCameraZRotation));
aTextBoxMatrix.translate( aTranslation.getX(), aTranslation.getY() );
}
@@ -205,6 +212,13 @@ 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 f9b0e58e0aba..c1ebcfd2753b 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -544,6 +544,23 @@ 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;