summaryrefslogtreecommitdiff
path: root/oox/source/drawingml/transform2dcontext.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-06-23 14:45:26 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-06-24 10:40:19 +0200
commit08489c211a902398c5f49c4f4676184b1657694c (patch)
tree07a53549a45f49e5bbce39f50a9074ee0dde36ee /oox/source/drawingml/transform2dcontext.cxx
parent66365b89f6f335e62db690add57482e91418c7d2 (diff)
almost nobody is using the oox::AttributeList::get methods properly
Most of the call sites just ignore the fact that we are returning an optional value here. Which means that when an attribute is missing, they get an empty string or zero. And we seem to be fine with that. So make a plugin that warns about calling value() on a temporay OptValue. And add a utility method so we don't have to pay the cost of passing a default value to getString() The need for this is driven by wanting to change to std::optional, which will throw an exception if code attempts to read an empty std::optional Change-Id: Idb0a5ad1eac66b5caa93d6195928bad9e0b2ad70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136283 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'oox/source/drawingml/transform2dcontext.cxx')
-rw-r--r--oox/source/drawingml/transform2dcontext.cxx20
1 files changed, 10 insertions, 10 deletions
diff --git a/oox/source/drawingml/transform2dcontext.cxx b/oox/source/drawingml/transform2dcontext.cxx
index 20c90731ed8d..f16dc06489f0 100644
--- a/oox/source/drawingml/transform2dcontext.cxx
+++ b/oox/source/drawingml/transform2dcontext.cxx
@@ -43,7 +43,7 @@ Transform2DContext::Transform2DContext( ContextHandler2Helper const & rParent, c
else
{
if( rAttribs.hasAttribute( XML_rot ) )
- mrShape.getTextBody()->getTextProperties().moRotation = rAttribs.getInteger( XML_rot ).value();
+ mrShape.getTextBody()->getTextProperties().moRotation = rAttribs.getInteger( XML_rot, 0 );
}
}
@@ -59,8 +59,8 @@ ContextHandlerRef Transform2DContext::onCreateContext( sal_Int32 aElementToken,
{
case A_TOKEN( off ):
{
- const OUString sXValue = rAttribs.getString( XML_x ).value();
- const OUString sYValue = rAttribs.getString( XML_y ).value();
+ const OUString sXValue = rAttribs.getStringDefaulted( XML_x );
+ const OUString sYValue = rAttribs.getStringDefaulted( XML_y );
if( !sXValue.isEmpty() && nType != XML_ellipse )
mrShape.getTextBody()->getTextProperties().moTextOffLeft = GetCoordinate( sXValue.toInt32() - mrShape.getPosition().X );
@@ -70,8 +70,8 @@ ContextHandlerRef Transform2DContext::onCreateContext( sal_Int32 aElementToken,
break;
case A_TOKEN( ext ):
{
- const OUString sXValue = rAttribs.getString( XML_cx ).value();
- const OUString sYValue = rAttribs.getString( XML_cy ).value();
+ const OUString sXValue = rAttribs.getStringDefaulted( XML_cx );
+ const OUString sYValue = rAttribs.getStringDefaulted( XML_cy );
if( !sXValue.isEmpty() && nType == XML_rect )
{
@@ -96,22 +96,22 @@ ContextHandlerRef Transform2DContext::onCreateContext( sal_Int32 aElementToken,
switch( aElementToken )
{
case A_TOKEN( off ): // horz/vert translation
- mrShape.setPosition( awt::Point( rAttribs.getString( XML_x ).value().toInt32(), rAttribs.getString( XML_y ).value().toInt32() ) );
+ mrShape.setPosition( awt::Point( rAttribs.getStringDefaulted( XML_x ).toInt32(), rAttribs.getStringDefaulted( XML_y ).toInt32() ) );
break;
case A_TOKEN( ext ): // horz/vert size
- mrShape.setSize( awt::Size( rAttribs.getString( XML_cx ).value().toInt32(), rAttribs.getString( XML_cy ).value().toInt32() ) );
+ mrShape.setSize( awt::Size( rAttribs.getStringDefaulted( XML_cx ).toInt32(), rAttribs.getStringDefaulted( XML_cy ).toInt32() ) );
break;
case A_TOKEN( chOff ): // horz/vert translation of children
- mrShape.setChildPosition( awt::Point( rAttribs.getString( XML_x ).value().toInt32(), rAttribs.getString( XML_y ).value().toInt32() ) );
+ mrShape.setChildPosition( awt::Point( rAttribs.getStringDefaulted( XML_x ).toInt32(), rAttribs.getStringDefaulted( XML_y ).toInt32() ) );
break;
case A_TOKEN( chExt ): // horz/vert size of children
{
- sal_Int32 nChExtCx = rAttribs.getString(XML_cx).value().toInt32();
+ sal_Int32 nChExtCx = rAttribs.getStringDefaulted(XML_cx).toInt32();
if(nChExtCx == 0)
nChExtCx = mrShape.getSize().Width;
- sal_Int32 nChExtCy = rAttribs.getString(XML_cy).value().toInt32();
+ sal_Int32 nChExtCy = rAttribs.getStringDefaulted(XML_cy).toInt32();
if(nChExtCy == 0)
nChExtCy = mrShape.getSize().Height;