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
committerAndras Timar <andras.timar@collabora.com>2019-10-18 10:08:13 +0200
commit946ac247c2cf02f48b6a8009064e0763fd9e97af (patch)
tree8772585ba6b326faf0aa73fb67a6608ca77babc4 /svx
parent6f7034aa89c75b705b2e575493cbc82ab37d8299 (diff)
tdf#126060 Handle text camera z rotation while pptx import.
Change-Id: Ifa4589fb50affc4c5ffb52288db8533c98ec6dd9 Reviewed-on: https://gerrit.libreoffice.org/80587 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/80891 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx23
-rw-r--r--svx/source/svdraw/svdoashp.cxx17
2 files changed, 36 insertions, 4 deletions
diff --git a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
index c3f8666ad1d9..a8e85531df6c 100644
--- a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
@@ -28,6 +28,8 @@
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <svx/obj3d.hxx>
#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+#include <vcl/canvastools.hxx>
+#include <sal/log.hxx>
namespace sdr
@@ -168,13 +170,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
@@ -182,6 +189,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))
@@ -194,13 +202,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() );
}
@@ -217,6 +225,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 9bacffb665c7..e42443bdf00a 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -538,6 +538,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;