summaryrefslogtreecommitdiff
path: root/oox/source/drawingml/textcharacterpropertiescontext.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/textcharacterpropertiescontext.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/textcharacterpropertiescontext.cxx')
-rw-r--r--oox/source/drawingml/textcharacterpropertiescontext.cxx6
1 files changed, 3 insertions, 3 deletions
diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx b/oox/source/drawingml/textcharacterpropertiescontext.cxx
index a13803e5319d..d92653bb0c15 100644
--- a/oox/source/drawingml/textcharacterpropertiescontext.cxx
+++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx
@@ -67,7 +67,7 @@ TextCharacterPropertiesContext::TextCharacterPropertiesContext(
mrTextCharacterProperties.moUnderline = rAttribs.getToken( XML_u );
if ( rAttribs.hasAttribute( XML_strike ) )
mrTextCharacterProperties.moStrikeout = rAttribs.getToken( XML_strike );
- if ( rAttribs.hasAttribute( XML_baseline ) && rAttribs.getInteger( XML_baseline ).value() != 0 )
+ if ( rAttribs.hasAttribute( XML_baseline ) && rAttribs.getInteger( XML_baseline, 0 ) != 0 )
mrTextCharacterProperties.moBaseline = rAttribs.getInteger( XML_baseline );
if ( rAttribs.hasAttribute( XML_b ) )
@@ -263,14 +263,14 @@ ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aEl
case W_TOKEN( color ):
if (rAttribs.getInteger(W_TOKEN(val)).has_value())
{
- mrTextCharacterProperties.maFillProperties.maFillColor.setSrgbClr(rAttribs.getIntegerHex(W_TOKEN(val)).value());
+ mrTextCharacterProperties.maFillProperties.maFillColor.setSrgbClr(rAttribs.getIntegerHex(W_TOKEN(val), 0));
mrTextCharacterProperties.maFillProperties.moFillType = XML_solidFill;
}
break;
case W_TOKEN( sz ):
if (rAttribs.getInteger(W_TOKEN(val)).has_value())
{
- sal_Int32 nVal = rAttribs.getInteger(W_TOKEN(val)).value();
+ sal_Int32 nVal = rAttribs.getInteger(W_TOKEN(val), 0);
// wml has half points, dml has hundred points
mrTextCharacterProperties.moHeight = nVal * 50;
}