summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2020-12-22 15:42:08 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-01-02 15:26:38 +0100
commit11e52fe2979b0947814a49b9c17ec373795cbf8e (patch)
tree48268579f052b7fdfcc2c334fffe8c91d29cb234 /oox
parent610ceb05025c9c7a9a34dddcb0dac506b8eab441 (diff)
introduce Degree100 strong_int type
Change-Id: I78f837a1340be0ca5c49097f543a481b7b43a632 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108367 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/shape.cxx5
-rw-r--r--oox/source/export/drawingml.cxx31
-rw-r--r--oox/source/shape/WpsContext.cxx4
-rw-r--r--oox/source/vml/vmlformatting.cxx10
-rw-r--r--oox/source/vml/vmlshape.cxx12
5 files changed, 34 insertions, 28 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index ce30b436ffec..98ef5de040b7 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1048,7 +1048,7 @@ Reference< XShape > const & Shape::createAndInsert(
aShapeProps.assignUsed( getShapeProperties() );
aShapeProps.assignUsed( maDefaultShapeProperties );
if(mnRotation != 0 && bIsCustomShape)
- aShapeProps.setProperty( PROP_RotateAngle, sal_Int32( NormAngle36000( mnRotation / -600 ) ));
+ aShapeProps.setProperty( PROP_RotateAngle, sal_Int32( NormAngle36000( Degree100(mnRotation / -600) ) ));
if ( bIsEmbMedia || aServiceName == "com.sun.star.drawing.GraphicObjectShape" || aServiceName == "com.sun.star.drawing.OLE2Shape" || bIsCustomShape )
mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper );
if ( mpTablePropertiesPtr && aServiceName == "com.sun.star.drawing.TableShape" )
@@ -1486,7 +1486,8 @@ Reference< XShape > const & Shape::createAndInsert(
if ( !bUseRotationTransform && (mnRotation != 0 || nCameraRotation != 0) )
{
// use the same logic for rotation from VML exporter (SimpleShape::implConvertAndInsert at vmlshape.cxx)
- aPropertySet.setAnyProperty( PROP_RotateAngle, makeAny( sal_Int32( NormAngle36000( (mnRotation - nCameraRotation) / -600 ) ) ) );
+ Degree100 nAngle = NormAngle36000( Degree100((mnRotation - nCameraRotation) / -600) );
+ aPropertySet.setAnyProperty( PROP_RotateAngle, makeAny( sal_Int32( nAngle.get() ) ) );
aPropertySet.setAnyProperty( PROP_HoriOrientPosition, makeAny( maPosition.X ) );
aPropertySet.setAnyProperty( PROP_VertOrientPosition, makeAny( maPosition.Y ) );
}
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 0571aeed7d93..da3edf2169c7 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1717,8 +1717,8 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa
{
SAL_INFO("oox.shape", "write shape transformation");
- sal_Int32 nRotation = 0;
- sal_Int32 nCameraRotation = 0;
+ Degree100 nRotation;
+ Degree100 nCameraRotation;
awt::Point aPos = rXShape->getPosition();
awt::Size aSize = rXShape->getSize();
@@ -1741,22 +1741,26 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa
if (!bSuppressRotation)
{
SdrObject* pShape = GetSdrObjectFromXShape( rXShape );
- nRotation = pShape ? pShape->GetRotateAngle() : 0;
+ nRotation = pShape ? pShape->GetRotateAngle() : 0_deg100;
if ( GetDocumentType() != DOCUMENT_DOCX )
{
int faccos=bFlipV ? -1 : 1;
int facsin=bFlipH ? -1 : 1;
- aPos.X-=(1-faccos*cos(nRotation*F_PI18000))*aSize.Width/2-facsin*sin(nRotation*F_PI18000)*aSize.Height/2;
- aPos.Y-=(1-faccos*cos(nRotation*F_PI18000))*aSize.Height/2+facsin*sin(nRotation*F_PI18000)*aSize.Width/2;
+ aPos.X-=(1-faccos*cos(nRotation.get()*F_PI18000))*aSize.Width/2-facsin*sin(nRotation.get()*F_PI18000)*aSize.Height/2;
+ aPos.Y-=(1-faccos*cos(nRotation.get()*F_PI18000))*aSize.Height/2+facsin*sin(nRotation.get()*F_PI18000)*aSize.Width/2;
}
// The RotateAngle property's value is independent from any flipping, and that's exactly what we need here.
uno::Reference<beans::XPropertySet> xPropertySet(rXShape, uno::UNO_QUERY);
uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
if (xPropertySetInfo->hasPropertyByName("RotateAngle"))
- xPropertySet->getPropertyValue("RotateAngle") >>= nRotation;
+ {
+ sal_Int32 nTmp;
+ if (xPropertySet->getPropertyValue("RotateAngle") >>= nTmp)
+ nRotation = Degree100(nTmp);
+ }
// tdf#133037: restore original rotate angle before output
- if (nRotation != 0 && xPropertySetInfo->hasPropertyByName(UNO_NAME_MISC_OBJ_INTEROPGRABBAG))
+ if (nRotation && xPropertySetInfo->hasPropertyByName(UNO_NAME_MISC_OBJ_INTEROPGRABBAG))
{
uno::Sequence<beans::PropertyValue> aGrabBagProps;
xPropertySet->getPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG) >>= aGrabBagProps;
@@ -1776,8 +1780,9 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa
[](const PropertyValue& rProp) { return rProp.Name == "rotRev"; });
if (pZRotationProp != std::cend(aCameraProps))
{
- pZRotationProp->Value >>= nCameraRotation;
- nCameraRotation = NormAngle36000(nCameraRotation / -600);
+ sal_Int32 nTmp;
+ pZRotationProp->Value >>= nTmp;
+ nCameraRotation = NormAngle36000(Degree100(nTmp / -600));
}
}
}
@@ -1786,7 +1791,7 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa
// OOXML flips shapes before rotating them.
if(bFlipH != bFlipV)
- nRotation = nRotation * -1 + 36000;
+ nRotation = Degree100(nRotation.get() * -1 + 36000);
WriteTransformation(tools::Rectangle(Point(aPos.X, aPos.Y), Size(aSize.Width, aSize.Height)), nXmlNamespace,
bFlipHWrite, bFlipVWrite, ExportRotateClockwisify(nRotation + nCameraRotation), IsGroupShape( rXShape ));
@@ -4981,8 +4986,8 @@ void DrawingML::WriteFromTo(const uno::Reference<css::drawing::XShape>& rXShape,
SdrObject* pObj = SdrObject::getSdrObjectFromXShape(rXShape.get());
if (pObj)
{
- sal_Int32 nRotation = pObj->GetRotateAngle();
- if (nRotation != 0)
+ Degree100 nRotation = pObj->GetRotateAngle();
+ if (nRotation)
{
sal_Int16 nHalfWidth = aSize.Width / 2;
sal_Int16 nHalfHeight = aSize.Height / 2;
@@ -4997,7 +5002,7 @@ void DrawingML::WriteFromTo(const uno::Reference<css::drawing::XShape>& rXShape,
// MSO changes the anchor positions at these angles and that does an extra 90 degrees
// rotation on our shapes, so we output it in such position that MSO
// can draw this shape correctly.
- if ((nRotation >= 45 * 100 && nRotation < 135 * 100) || (nRotation >= 225 * 100 && nRotation < 315 * 100))
+ if ((nRotation >= 4500_deg100 && nRotation < 13500_deg100) || (nRotation >= 22500_deg100 && nRotation < 31500_deg100))
{
aTopLeft.X = aTopLeft.X - nHalfHeight + nHalfWidth;
aTopLeft.Y = aTopLeft.Y - nHalfWidth + nHalfHeight;
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 5a4210572e51..834dc9f5a730 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -84,8 +84,8 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
// If the text is not rotated the way the shape wants it already, set the angle.
const sal_Int32 nRotation = nVert == XML_vert270 ? -270 : -90;
- if (static_cast<tools::Long>(basegfx::rad2deg(fRotate))
- != NormAngle36000(static_cast<tools::Long>(nRotation) * 100) / 100)
+ if (static_cast<sal_Int32>(basegfx::rad2deg(fRotate))
+ != NormAngle36000(Degree100(nRotation * 100)).get() / 100)
{
comphelper::SequenceAsHashMap aCustomShapeGeometry(
xPropertySet->getPropertyValue("CustomShapeGeometry"));
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index 62da5dedf10f..60ef7f900d15 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -118,16 +118,16 @@ double ConversionHelper::decodePercent( const OUString& rValue, double fDefValue
return fDefValue;
}
-sal_Int32 ConversionHelper::decodeRotation( const OUString& rValue )
+Degree100 ConversionHelper::decodeRotation( const OUString& rValue )
{
if( rValue.isEmpty() )
- return 0;
+ return 0_deg100;
double fValue = 0.0;
double fRotation = 0.0;
sal_Int32 nEndPos = 0;
if( !lclExtractDouble(fValue, nEndPos, rValue) )
- return 0;
+ return 0_deg100;
if( nEndPos == rValue.getLength() )
fRotation = fValue;
@@ -136,10 +136,10 @@ sal_Int32 ConversionHelper::decodeRotation( const OUString& rValue )
else
{
OSL_FAIL("ConversionHelper::decodeRotation - unknown measure unit");
- return 0;
+ return 0_deg100;
}
- return NormAngle36000(fRotation * -100);
+ return NormAngle36000(Degree100(static_cast<sal_Int32>(fRotation * -100)));
}
sal_Int64 ConversionHelper::decodeMeasureToEmu( const GraphicHelper& rGraphicHelper,
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 5b081660148d..32c1ec93ed49 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -405,7 +405,7 @@ Reference< XShape > ShapeBase::convertAndInsert( const Reference< XShapes >& rxS
}
if(!maTypeModel.maRotation.isEmpty())
- aGrabBag.push_back(comphelper::makePropertyValue("mso-rotation-angle", ConversionHelper::decodeRotation(maTypeModel.maRotation)));
+ aGrabBag.push_back(comphelper::makePropertyValue("mso-rotation-angle", ConversionHelper::decodeRotation(maTypeModel.maRotation).get()));
propertySet->setPropertyValue("FrameInteropGrabBag", uno::makeAny(comphelper::containerToSequence(aGrabBag)));
sal_Int32 backColorTransparency = 0;
propertySet->getPropertyValue("BackColorTransparency")
@@ -685,7 +685,7 @@ static void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rType
Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const
{
awt::Rectangle aShapeRect(rShapeRect);
- std::optional<sal_Int32> oRotation;
+ std::optional<Degree100> oRotation;
bool bFlipX = false, bFlipY = false;
// tdf#137765: skip this rotation for line shapes
if (!maTypeModel.maRotation.isEmpty() && maService != "com.sun.star.drawing.LineShape")
@@ -840,7 +840,7 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
{
if (oRotation)
{
- aPropertySet.setAnyProperty(PROP_RotateAngle, makeAny(*oRotation));
+ aPropertySet.setAnyProperty(PROP_RotateAngle, makeAny((*oRotation).get()));
uno::Reference<lang::XServiceInfo> xServiceInfo(rxShapes, uno::UNO_QUERY);
if (!xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"))
{
@@ -947,7 +947,7 @@ Reference< XShape > SimpleShape::createPictureObject(const Reference< XShapes >&
}
// fdo#70457: preserve rotation information
if ( !maTypeModel.maRotation.isEmpty() )
- aPropSet.setAnyProperty(PROP_RotateAngle, makeAny(ConversionHelper::decodeRotation(maTypeModel.maRotation)));
+ aPropSet.setAnyProperty(PROP_RotateAngle, makeAny(ConversionHelper::decodeRotation(maTypeModel.maRotation).get()));
const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
lcl_SetAnchorType(aPropSet, maTypeModel, rGraphicHelper);
@@ -1082,7 +1082,7 @@ namespace
// -1 is required because the direction of MSO rotation is the opposite of ours
// 100 is required because in this part of the code the angle is in a hundredth of
// degrees.
- auto nAngle = -1 * 100.0 * rTypeModel.maRotation.toDouble();
+ Degree100 nAngle( static_cast<sal_Int32>(-1 * 100.0 * rTypeModel.maRotation.toDouble()) );
pShape->NbcRotate(pShape->GetSnapRect().Center(), nAngle);
}
}
@@ -1535,7 +1535,7 @@ Reference< XShape > GroupShape::implConvertAndInsert( const Reference< XShapes >
const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
lcl_SetAnchorType(aPropertySet, maTypeModel, rGraphicHelper);
if (!maTypeModel.maRotation.isEmpty())
- aPropertySet.setAnyProperty(PROP_RotateAngle, makeAny(ConversionHelper::decodeRotation(maTypeModel.maRotation)));
+ aPropertySet.setAnyProperty(PROP_RotateAngle, makeAny(ConversionHelper::decodeRotation(maTypeModel.maRotation).get()));
return xGroupShape;
}