diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-06-23 14:45:26 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-06-24 10:40:19 +0200 |
commit | 08489c211a902398c5f49c4f4676184b1657694c (patch) | |
tree | 07a53549a45f49e5bbce39f50a9074ee0dde36ee /oox/source/drawingml/textspacingcontext.cxx | |
parent | 66365b89f6f335e62db690add57482e91418c7d2 (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/textspacingcontext.cxx')
-rw-r--r-- | oox/source/drawingml/textspacingcontext.cxx | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/oox/source/drawingml/textspacingcontext.cxx b/oox/source/drawingml/textspacingcontext.cxx index 83adaa806cf9..388f4fc78c11 100644 --- a/oox/source/drawingml/textspacingcontext.cxx +++ b/oox/source/drawingml/textspacingcontext.cxx @@ -44,11 +44,11 @@ namespace oox::drawingml { { case A_TOKEN( spcPct ): maSpacing.nUnit = TextSpacing::Unit::Percent; - maSpacing.nValue = GetPercent( rAttribs.getString( XML_val ).value() ); + maSpacing.nValue = GetPercent( rAttribs.getStringDefaulted( XML_val ) ); break; case A_TOKEN( spcPts ): maSpacing.nUnit = TextSpacing::Unit::Points; - maSpacing.nValue = GetTextSpacingPoint( rAttribs.getString( XML_val ).value() ); + maSpacing.nValue = GetTextSpacingPoint( rAttribs.getStringDefaulted( XML_val ) ); maSpacing.bExactValue = true; break; default: |