summaryrefslogtreecommitdiff
path: root/oox/source
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
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')
-rw-r--r--oox/source/drawingml/connectorshapecontext.cxx12
-rw-r--r--oox/source/drawingml/customshapegeometry.cxx26
-rw-r--r--oox/source/drawingml/diagram/datamodelcontext.cxx18
-rw-r--r--oox/source/drawingml/diagram/diagramdefinitioncontext.cxx14
-rw-r--r--oox/source/drawingml/diagram/layoutnodecontext.cxx12
-rw-r--r--oox/source/drawingml/embeddedwavaudiofile.cxx4
-rw-r--r--oox/source/drawingml/graphicshapecontext.cxx14
-rw-r--r--oox/source/drawingml/hyperlinkcontext.cxx8
-rw-r--r--oox/source/drawingml/shapecontext.cxx8
-rw-r--r--oox/source/drawingml/shapegroupcontext.cxx6
-rw-r--r--oox/source/drawingml/table/tablecellcontext.cxx4
-rw-r--r--oox/source/drawingml/table/tablecontext.cxx2
-rw-r--r--oox/source/drawingml/table/tablerowcontext.cxx2
-rw-r--r--oox/source/drawingml/table/tablestylecontext.cxx4
-rw-r--r--oox/source/drawingml/table/tablestylelistfragmenthandler.cxx2
-rw-r--r--oox/source/drawingml/textbodypropertiescontext.cxx2
-rw-r--r--oox/source/drawingml/textcharacterpropertiescontext.cxx6
-rw-r--r--oox/source/drawingml/texteffectscontext.cxx2
-rw-r--r--oox/source/drawingml/textfieldcontext.cxx4
-rw-r--r--oox/source/drawingml/textparagraphpropertiescontext.cxx12
-rw-r--r--oox/source/drawingml/textspacingcontext.cxx4
-rw-r--r--oox/source/drawingml/texttabstoplistcontext.cxx2
-rw-r--r--oox/source/drawingml/themeelementscontext.cxx4
-rw-r--r--oox/source/drawingml/themefragmenthandler.cxx2
-rw-r--r--oox/source/drawingml/transform2dcontext.cxx20
-rw-r--r--oox/source/helper/attributelist.cxx8
-rw-r--r--oox/source/ppt/pptgraphicshapecontext.cxx6
-rw-r--r--oox/source/ppt/pptshapecontext.cxx6
-rw-r--r--oox/source/ppt/pptshapegroupcontext.cxx8
-rw-r--r--oox/source/ppt/presPropsfragmenthandler.cxx4
-rw-r--r--oox/source/shape/LockedCanvasContext.cxx4
-rw-r--r--oox/source/vml/vmltextboxcontext.cxx4
32 files changed, 121 insertions, 113 deletions
diff --git a/oox/source/drawingml/connectorshapecontext.cxx b/oox/source/drawingml/connectorshapecontext.cxx
index ebafb5116f8b..8ea0bcca6965 100644
--- a/oox/source/drawingml/connectorshapecontext.cxx
+++ b/oox/source/drawingml/connectorshapecontext.cxx
@@ -70,15 +70,15 @@ ConnectorShapePropertiesContext::onCreateContext(sal_Int32 aElementToken,
switch (getBaseToken(aElementToken))
{
case XML_cNvPr:
- mpConnectorShapePtr->setId(rAttribs.getString(XML_id).value());
- mpConnectorShapePtr->setName(rAttribs.getString(XML_name).value());
+ mpConnectorShapePtr->setId(rAttribs.getStringDefaulted(XML_id));
+ mpConnectorShapePtr->setName(rAttribs.getStringDefaulted(XML_name));
break;
case XML_stCxn:
{
ConnectorShapeProperties aConnectorShapeProps;
aConnectorShapeProps.mbStartShape = true;
- aConnectorShapeProps.maDestShapeId = rAttribs.getString(XML_id).value();
- aConnectorShapeProps.mnDestGlueId = rAttribs.getInteger(XML_idx).value();
+ aConnectorShapeProps.maDestShapeId = rAttribs.getStringDefaulted(XML_id);
+ aConnectorShapeProps.mnDestGlueId = rAttribs.getInteger(XML_idx, 0);
mrConnectorShapePropertiesList.push_back(aConnectorShapeProps);
break;
}
@@ -86,8 +86,8 @@ ConnectorShapePropertiesContext::onCreateContext(sal_Int32 aElementToken,
{
ConnectorShapeProperties aConnectorShapeProps;
aConnectorShapeProps.mbStartShape = false;
- aConnectorShapeProps.maDestShapeId = rAttribs.getString(XML_id).value();
- aConnectorShapeProps.mnDestGlueId = rAttribs.getInteger(XML_idx).value();
+ aConnectorShapeProps.maDestShapeId = rAttribs.getStringDefaulted(XML_id);
+ aConnectorShapeProps.mnDestGlueId = rAttribs.getInteger(XML_idx, 0);
mrConnectorShapePropertiesList.push_back(aConnectorShapeProps);
break;
}
diff --git a/oox/source/drawingml/customshapegeometry.cxx b/oox/source/drawingml/customshapegeometry.cxx
index de240281833c..e3856b3a59c6 100644
--- a/oox/source/drawingml/customshapegeometry.cxx
+++ b/oox/source/drawingml/customshapegeometry.cxx
@@ -621,8 +621,8 @@ ContextHandlerRef GeomGuideListContext::onCreateContext( sal_Int32 aElementToken
if ( aElementToken == A_TOKEN( gd ) ) // CT_GeomGuide
{
CustomShapeGuide aGuide;
- aGuide.maName = rAttribs.getString( XML_name ).value();
- aGuide.maFormula = convertToOOEquation( mrCustomShapeProperties, rAttribs.getString( XML_fmla ).value() );
+ aGuide.maName = rAttribs.getStringDefaulted( XML_name );
+ aGuide.maFormula = convertToOOEquation( mrCustomShapeProperties, rAttribs.getStringDefaulted( XML_fmla ) );
mrGuideList.push_back( aGuide );
}
return this;
@@ -647,8 +647,8 @@ public:
AdjPoint2DContext::AdjPoint2DContext( ContextHandler2Helper const & rParent, const AttributeList& rAttribs, CustomShapeProperties& rCustomShapeProperties, EnhancedCustomShapeParameterPair& rAdjPoint2D )
: ContextHandler2( rParent )
{
- rAdjPoint2D.First = GetAdjCoordinate( rCustomShapeProperties, rAttribs.getString( XML_x ).value() );
- rAdjPoint2D.Second = GetAdjCoordinate( rCustomShapeProperties, rAttribs.getString( XML_y ).value() );
+ rAdjPoint2D.First = GetAdjCoordinate( rCustomShapeProperties, rAttribs.getStringDefaulted( XML_x ) );
+ rAdjPoint2D.Second = GetAdjCoordinate( rCustomShapeProperties, rAttribs.getStringDefaulted( XML_y ) );
}
namespace {
@@ -823,7 +823,7 @@ ConnectionSiteContext::ConnectionSiteContext( ContextHandler2Helper const & rPar
, mrConnectionSite( rConnectionSite )
, mrCustomShapeProperties( rCustomShapeProperties )
{
- mrConnectionSite.ang = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getString( XML_ang ).value() );
+ mrConnectionSite.ang = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getStringDefaulted( XML_ang ) );
}
ContextHandlerRef ConnectionSiteContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
@@ -1099,8 +1099,8 @@ ContextHandlerRef Path2DContext::onCreateContext( sal_Int32 aElementToken,
EnhancedCustomShapeParameterPair aScale;
EnhancedCustomShapeParameterPair aAngles;
- aScale.First = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getString( XML_wR ).value() );
- aScale.Second = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getString( XML_hR ).value() );
+ aScale.First = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getStringDefaulted( XML_wR ) );
+ aScale.Second = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getStringDefaulted( XML_hR ) );
CustomShapeGuide aGuide;
sal_Int32 nArcNum = mrCustomShapeProperties.getArcNum();
@@ -1108,7 +1108,7 @@ ContextHandlerRef Path2DContext::onCreateContext( sal_Int32 aElementToken,
// start angle
aGuide.maName = "arctosa" + OUString::number( nArcNum );
aGuide.maFormula = "("
- + GetFormulaParameter( GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getString( XML_stAng ).value() ) )
+ + GetFormulaParameter( GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getStringDefaulted( XML_stAng ) ) )
+ ")/60000.0";
aAngles.First.Value <<= CustomShapeProperties::SetCustomShapeGuideValue( mrCustomShapeProperties.getGuideList(), aGuide );
aAngles.First.Type = EnhancedCustomShapeParameterType::EQUATION;
@@ -1116,7 +1116,7 @@ ContextHandlerRef Path2DContext::onCreateContext( sal_Int32 aElementToken,
// swing angle
aGuide.maName = "arctosw" + OUString::number( nArcNum );
aGuide.maFormula = "("
- + GetFormulaParameter( GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getString( XML_swAng ).value() ) )
+ + GetFormulaParameter( GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getStringDefaulted( XML_swAng ) ) )
+ ")/60000.0";
aAngles.Second.Value <<= CustomShapeProperties::SetCustomShapeGuideValue( mrCustomShapeProperties.getGuideList(), aGuide );
aAngles.Second.Type = EnhancedCustomShapeParameterType::EQUATION;
@@ -1234,10 +1234,10 @@ ContextHandlerRef CustomShapeGeometryContext::onCreateContext( sal_Int32 aElemen
case A_TOKEN( rect ): // CT_GeomRectList geometry rect list
{
GeomRect aGeomRect;
- aGeomRect.l = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getString( XML_l ).value() );
- aGeomRect.t = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getString( XML_t ).value() );
- aGeomRect.r = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getString( XML_r ).value() );
- aGeomRect.b = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getString( XML_b ).value() );
+ aGeomRect.l = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getStringDefaulted( XML_l ) );
+ aGeomRect.t = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getStringDefaulted( XML_t ) );
+ aGeomRect.r = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getStringDefaulted( XML_r ) );
+ aGeomRect.b = GetAdjCoordinate( mrCustomShapeProperties, rAttribs.getStringDefaulted( XML_b ) );
mrCustomShapeProperties.getTextRect() = aGeomRect;
}
break;
diff --git a/oox/source/drawingml/diagram/datamodelcontext.cxx b/oox/source/drawingml/diagram/datamodelcontext.cxx
index 86f330467aa2..97c46c25365c 100644
--- a/oox/source/drawingml/diagram/datamodelcontext.cxx
+++ b/oox/source/drawingml/diagram/datamodelcontext.cxx
@@ -57,12 +57,12 @@ public:
svx::diagram::Connection& rConnection=mrConnection.back();
rConnection.mnXMLType = static_cast<svx::diagram::TypeConstant>(rAttribs.getToken( XML_type, XML_parOf ));
- rConnection.msModelId = rAttribs.getString( XML_modelId ).value();
- rConnection.msSourceId = rAttribs.getString( XML_srcId ).value();
- rConnection.msDestId = rAttribs.getString( XML_destId ).value();
- rConnection.msPresId = rAttribs.getString( XML_presId ).value();
- rConnection.msSibTransId = rAttribs.getString( XML_sibTransId ).value();
- rConnection.msParTransId = rAttribs.getString( XML_parTransId ).value();
+ rConnection.msModelId = rAttribs.getStringDefaulted( XML_modelId );
+ rConnection.msSourceId = rAttribs.getStringDefaulted( XML_srcId );
+ rConnection.msDestId = rAttribs.getStringDefaulted( XML_destId );
+ rConnection.msPresId = rAttribs.getStringDefaulted( XML_presId );
+ rConnection.msSibTransId = rAttribs.getStringDefaulted( XML_sibTransId );
+ rConnection.msParTransId = rAttribs.getStringDefaulted( XML_parTransId );
rConnection.mnSourceOrder = rAttribs.getInteger( XML_srcOrd, 0 );
rConnection.mnDestOrder = rAttribs.getInteger( XML_destOrd, 0 );
@@ -214,7 +214,7 @@ public:
mrPoint( rPoint ),
mrDiagramData( rDiagramData )
{
- mrPoint.msModelId = rAttribs.getString( XML_modelId ).value();
+ mrPoint.msModelId = rAttribs.getStringDefaulted( XML_modelId );
// the default type is XML_node
const sal_Int32 nType = rAttribs.getToken( XML_type, XML_node );
@@ -222,7 +222,7 @@ public:
// ignore the cxnId unless it is this type. See 5.15.3.1.3 in Primer
if( ( nType == XML_parTrans ) || ( nType == XML_sibTrans ) )
- mrPoint.msCnxId = rAttribs.getString( XML_cxnId ).value();
+ mrPoint.msCnxId = rAttribs.getStringDefaulted( XML_cxnId );
}
virtual ContextHandlerRef
@@ -371,7 +371,7 @@ DataModelContext::onCreateContext( ::sal_Int32 aElement,
case A_TOKEN( ext ):
break;
case DSP_TOKEN( dataModelExt ):
- mpDataModel->getExtDrawings().push_back( rAttribs.getString( XML_relId ).value() );
+ mpDataModel->getExtDrawings().push_back( rAttribs.getStringDefaulted( XML_relId ) );
break;
default:
break;
diff --git a/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
index d569ed6d6dbe..3742a250c14b 100644
--- a/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
+++ b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
@@ -37,14 +37,14 @@ DiagramDefinitionContext::DiagramDefinitionContext( ContextHandler2Helper const
: ContextHandler2( rParent )
, mpLayout( pLayout )
{
- mpLayout->setDefStyle( rAttributes.getString( XML_defStyle ).value() );
- OUString sValue = rAttributes.getString( XML_minVer ).value();
+ mpLayout->setDefStyle( rAttributes.getStringDefaulted( XML_defStyle ) );
+ OUString sValue = rAttributes.getStringDefaulted( XML_minVer );
if( sValue.isEmpty() )
{
sValue = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
}
mpLayout->setMinVer( sValue );
- mpLayout->setUniqueId( rAttributes.getString( XML_uniqueId ).value() );
+ mpLayout->setUniqueId( rAttributes.getStringDefaulted( XML_uniqueId ) );
}
DiagramDefinitionContext::~DiagramDefinitionContext()
@@ -61,18 +61,18 @@ DiagramDefinitionContext::onCreateContext( ::sal_Int32 aElement,
switch( aElement )
{
case DGM_TOKEN( title ):
- mpLayout->setTitle( rAttribs.getString( XML_val ).value() );
+ mpLayout->setTitle( rAttribs.getStringDefaulted( XML_val ) );
break;
case DGM_TOKEN( desc ):
- mpLayout->setDesc( rAttribs.getString( XML_val ).value() );
+ mpLayout->setDesc( rAttribs.getStringDefaulted( XML_val ) );
break;
case DGM_TOKEN( layoutNode ):
{
LayoutNodePtr pNode = std::make_shared<LayoutNode>(mpLayout->getDiagram());
mpLayout->getNode() = pNode;
pNode->setChildOrder( rAttribs.getToken( XML_chOrder, XML_b ) );
- pNode->setMoveWith( rAttribs.getString( XML_moveWith ).value() );
- pNode->setStyleLabel( rAttribs.getString( XML_styleLbl ).value() );
+ pNode->setMoveWith( rAttribs.getStringDefaulted( XML_moveWith ) );
+ pNode->setStyleLabel( rAttribs.getStringDefaulted( XML_styleLbl ) );
return new LayoutNodeContext( *this, rAttribs, pNode );
}
case DGM_TOKEN( clrData ):
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx
index 74ad212b318d..68ec7b1367b9 100644
--- a/oox/source/drawingml/diagram/layoutnodecontext.cxx
+++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx
@@ -102,7 +102,7 @@ public:
: ContextHandler2( rParent )
, mpNode( pNode )
{
- msName = rAttribs.getString( XML_name ).value();
+ msName = rAttribs.getStringDefaulted( XML_name );
}
virtual ContextHandlerRef
@@ -143,7 +143,7 @@ public:
ForEachContext( ContextHandler2Helper const & rParent, const AttributeList& rAttribs, const ForEachAtomPtr& pAtom )
: LayoutNodeContext( rParent, rAttribs, pAtom )
{
- pAtom->setRef(rAttribs.getString(XML_ref).value());
+ pAtom->setRef(rAttribs.getStringDefaulted(XML_ref));
pAtom->iterator().loadFromXAttr( rAttribs.getFastAttributeList() );
LayoutAtomMap& rLayoutAtomMap = pAtom->getLayoutNode().getDiagram().getLayout()->getLayoutAtomMap();
@@ -164,7 +164,7 @@ public:
virtual ContextHandlerRef onCreateContext( ::sal_Int32 aElement, const AttributeList& rAttribs ) override
{
- mVariables[ getBaseToken(aElement) ] = rAttribs.getString( XML_val ).value();
+ mVariables[ getBaseToken(aElement) ] = rAttribs.getStringDefaulted( XML_val );
return this;
}
private:
@@ -181,7 +181,7 @@ LayoutNodeContext::LayoutNodeContext( ContextHandler2Helper const & rParent,
, mpNode( pAtom )
{
assert( pAtom && "Node must NOT be NULL" );
- mpNode->setName( rAttribs.getString( XML_name ).value() );
+ mpNode->setName( rAttribs.getStringDefaulted( XML_name ) );
}
LayoutNodeContext::~LayoutNodeContext()
@@ -216,8 +216,8 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement,
}
}
- pNode->setMoveWith( rAttribs.getString( XML_moveWith ).value() );
- pNode->setStyleLabel( rAttribs.getString( XML_styleLbl ).value() );
+ pNode->setMoveWith( rAttribs.getStringDefaulted( XML_moveWith ) );
+ pNode->setStyleLabel( rAttribs.getStringDefaulted( XML_styleLbl ) );
return new LayoutNodeContext( *this, rAttribs, pNode );
}
case DGM_TOKEN( shape ):
diff --git a/oox/source/drawingml/embeddedwavaudiofile.cxx b/oox/source/drawingml/embeddedwavaudiofile.cxx
index 8f88733cfce9..e55ada369a01 100644
--- a/oox/source/drawingml/embeddedwavaudiofile.cxx
+++ b/oox/source/drawingml/embeddedwavaudiofile.cxx
@@ -28,9 +28,9 @@ namespace oox::drawingml
OUString getEmbeddedWAVAudioFile(const core::Relations& rRelations, const AttributeList& rAttribs)
{
if (rAttribs.getBool(XML_builtIn, false))
- return rAttribs.getString(XML_name).value();
+ return rAttribs.getStringDefaulted(XML_name);
else
- return rRelations.getFragmentPathFromRelId(rAttribs.getString(R_TOKEN(embed)).value());
+ return rRelations.getFragmentPathFromRelId(rAttribs.getStringDefaulted(R_TOKEN(embed)));
}
}
diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx
index bab0a7a65d91..1d0909b3d5e4 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -96,7 +96,7 @@ ContextHandlerRef GraphicShapeContext::onCreateContext( sal_Int32 aElementToken,
case XML_videoFile:
{
OUString rPath = getRelations().getFragmentPathFromRelId(
- rAttribs.getString(R_TOKEN(link)).value() );
+ rAttribs.getStringDefaulted(R_TOKEN(link)) );
if (!rPath.isEmpty())
{
Reference<XInputStream> xMediaStream = lcl_GetMediaStream(rPath, getFilter());
@@ -110,7 +110,7 @@ ContextHandlerRef GraphicShapeContext::onCreateContext( sal_Int32 aElementToken,
else
{
rPath = getRelations().getExternalTargetFromRelId(
- rAttribs.getString(R_TOKEN(link)).value());
+ rAttribs.getStringDefaulted(R_TOKEN(link)));
if (!rPath.isEmpty()) // linked media file
mpShapePtr->getGraphicProperties().m_sMediaPackageURL
= getFilter().getAbsoluteUrl(rPath);
@@ -154,7 +154,7 @@ ContextHandlerRef GraphicalObjectFrameContext::onCreateContext( sal_Int32 aEleme
case XML_graphicData : // CT_GraphicalObjectData
{
- OUString sUri( rAttribs.getString( XML_uri ).value() );
+ OUString sUri( rAttribs.getStringDefaulted( XML_uri ) );
if ( sUri == "http://schemas.openxmlformats.org/presentationml/2006/ole" ||
sUri == "http://purl.oclc.org/ooxml/presentationml/ole" )
return new OleObjectGraphicDataContext( *this, mpShapePtr );
@@ -277,10 +277,10 @@ ContextHandlerRef DiagramGraphicDataContext::onCreateContext( ::sal_Int32 aEleme
{
case DGM_TOKEN( relIds ):
{
- msDm = rAttribs.getString( R_TOKEN( dm ) ).value();
- msLo = rAttribs.getString( R_TOKEN( lo ) ).value();
- msQs = rAttribs.getString( R_TOKEN( qs ) ).value();
- msCs = rAttribs.getString( R_TOKEN( cs ) ).value();
+ msDm = rAttribs.getStringDefaulted( R_TOKEN( dm ) );
+ msLo = rAttribs.getStringDefaulted( R_TOKEN( lo ) );
+ msQs = rAttribs.getStringDefaulted( R_TOKEN( qs ) );
+ msCs = rAttribs.getStringDefaulted( R_TOKEN( cs ) );
loadDiagram(mpShapePtr,
getFilter(),
getFragmentPathFromRelId( msDm ),
diff --git a/oox/source/drawingml/hyperlinkcontext.cxx b/oox/source/drawingml/hyperlinkcontext.cxx
index 1193a6c3af95..ab52c0f5e397 100644
--- a/oox/source/drawingml/hyperlinkcontext.cxx
+++ b/oox/source/drawingml/hyperlinkcontext.cxx
@@ -42,7 +42,7 @@ HyperLinkContext::HyperLinkContext( ContextHandler2Helper const & rParent,
, maProperties(aProperties)
{
OUString sURL, sHref;
- OUString aRelId = rAttribs.getString( R_TOKEN( id ) ).value();
+ OUString aRelId = rAttribs.getStringDefaulted( R_TOKEN( id ) );
if ( !aRelId.isEmpty() )
{
sHref = getRelations().getExternalTargetFromRelId( aRelId );
@@ -56,13 +56,13 @@ HyperLinkContext::HyperLinkContext( ContextHandler2Helper const & rParent,
sURL = getRelations().getInternalTargetFromRelId( aRelId );
}
}
- OUString sTooltip = rAttribs.getString( R_TOKEN( tooltip ) ).value();
+ OUString sTooltip = rAttribs.getStringDefaulted( R_TOKEN( tooltip ) );
if ( !sTooltip.isEmpty() )
maProperties.setProperty(PROP_Representation, sTooltip);
- OUString sFrame = rAttribs.getString( R_TOKEN( tgtFrame ) ).value();
+ OUString sFrame = rAttribs.getStringDefaulted( R_TOKEN( tgtFrame ) );
if( !sFrame.isEmpty() )
maProperties.setProperty(PROP_TargetFrame, sFrame);
- OUString aAction = rAttribs.getString( XML_action ).value();
+ OUString aAction = rAttribs.getStringDefaulted( XML_action );
if ( !aAction.isEmpty() )
{
// reserved values of the unrestricted string aAction:
diff --git a/oox/source/drawingml/shapecontext.cxx b/oox/source/drawingml/shapecontext.cxx
index 5cf910b3c07b..17acea153984 100644
--- a/oox/source/drawingml/shapecontext.cxx
+++ b/oox/source/drawingml/shapecontext.cxx
@@ -67,9 +67,9 @@ ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 aElementToken, const
case XML_cNvPr:
{
mpShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
- mpShapePtr->setId( rAttribs.getString( XML_id ).value() );
- mpShapePtr->setName( rAttribs.getString( XML_name ).value() );
- mpShapePtr->setDescription( rAttribs.getString( XML_descr ).value() );
+ mpShapePtr->setId( rAttribs.getStringDefaulted( XML_id ) );
+ mpShapePtr->setName( rAttribs.getStringDefaulted( XML_name ) );
+ mpShapePtr->setDescription( rAttribs.getStringDefaulted( XML_descr ) );
break;
}
case XML_hlinkMouseOver:
@@ -78,7 +78,7 @@ ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 aElementToken, const
case XML_ph:
mpShapePtr->setSubType( rAttribs.getToken( XML_type, XML_obj ) );
if( rAttribs.hasAttribute( XML_idx ) )
- mpShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).value().toInt32() );
+ mpShapePtr->setSubTypeIndex( rAttribs.getStringDefaulted( XML_idx ).toInt32() );
break;
// nvSpPr CT_ShapeNonVisual end
diff --git a/oox/source/drawingml/shapegroupcontext.cxx b/oox/source/drawingml/shapegroupcontext.cxx
index d0c53a34ad26..616388a895a6 100644
--- a/oox/source/drawingml/shapegroupcontext.cxx
+++ b/oox/source/drawingml/shapegroupcontext.cxx
@@ -60,14 +60,14 @@ ContextHandlerRef ShapeGroupContext::onCreateContext( sal_Int32 aElementToken, c
case XML_cNvPr:
{
mpGroupShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
- mpGroupShapePtr->setId( rAttribs.getString( XML_id ).value() );
- mpGroupShapePtr->setName( rAttribs.getString( XML_name ).value() );
+ mpGroupShapePtr->setId( rAttribs.getStringDefaulted( XML_id ) );
+ mpGroupShapePtr->setName( rAttribs.getStringDefaulted( XML_name ) );
break;
}
case XML_ph:
mpGroupShapePtr->setSubType( rAttribs.getToken( XML_type, FastToken::DONTKNOW ) );
if( rAttribs.hasAttribute( XML_idx ) )
- mpGroupShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).value().toInt32() );
+ mpGroupShapePtr->setSubTypeIndex( rAttribs.getStringDefaulted( XML_idx ).toInt32() );
break;
// nvSpPr CT_ShapeNonVisual end
diff --git a/oox/source/drawingml/table/tablecellcontext.cxx b/oox/source/drawingml/table/tablecellcontext.cxx
index e02889514119..0227a03f0f0c 100644
--- a/oox/source/drawingml/table/tablecellcontext.cxx
+++ b/oox/source/drawingml/table/tablecellcontext.cxx
@@ -36,9 +36,9 @@ TableCellContext::TableCellContext( ContextHandler2Helper const & rParent, const
, mrTableCell( rTableCell )
{
if ( rAttribs.hasAttribute( XML_rowSpan ) )
- mrTableCell.setRowSpan( rAttribs.getString( XML_rowSpan ).value().toInt32() );
+ mrTableCell.setRowSpan( rAttribs.getStringDefaulted( XML_rowSpan ).toInt32() );
if ( rAttribs.hasAttribute( XML_gridSpan ) )
- mrTableCell.setGridSpan( rAttribs.getString( XML_gridSpan ).value().toInt32() );
+ mrTableCell.setGridSpan( rAttribs.getStringDefaulted( XML_gridSpan ).toInt32() );
mrTableCell.sethMerge( rAttribs.getBool( XML_hMerge, false ) );
mrTableCell.setvMerge( rAttribs.getBool( XML_vMerge, false ) );
diff --git a/oox/source/drawingml/table/tablecontext.cxx b/oox/source/drawingml/table/tablecontext.cxx
index b57af6d24f55..65c5ff4b782b 100644
--- a/oox/source/drawingml/table/tablecontext.cxx
+++ b/oox/source/drawingml/table/tablecontext.cxx
@@ -79,7 +79,7 @@ TableContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& r
case A_TOKEN( gridCol ): // CT_TableCol
{
std::vector< sal_Int32 >& rvTableGrid( mrTableProperties.getTableGrid() );
- rvTableGrid.push_back( rAttribs.getString( XML_w ).value().toInt32() );
+ rvTableGrid.push_back( rAttribs.getStringDefaulted( XML_w ).toInt32() );
}
break;
case A_TOKEN( tr ): // CT_TableRow
diff --git a/oox/source/drawingml/table/tablerowcontext.cxx b/oox/source/drawingml/table/tablerowcontext.cxx
index c6a34afa54b4..744c3302f123 100644
--- a/oox/source/drawingml/table/tablerowcontext.cxx
+++ b/oox/source/drawingml/table/tablerowcontext.cxx
@@ -34,7 +34,7 @@ TableRowContext::TableRowContext( ContextHandler2Helper const & rParent, const A
: ContextHandler2( rParent )
, mrTableRow( rTableRow )
{
- rTableRow.setHeight( rAttribs.getString( XML_h ).value().toInt32() );
+ rTableRow.setHeight( rAttribs.getStringDefaulted( XML_h ).toInt32() );
}
TableRowContext::~TableRowContext()
diff --git a/oox/source/drawingml/table/tablestylecontext.cxx b/oox/source/drawingml/table/tablestylecontext.cxx
index 242889b63d80..23208cc2c5eb 100644
--- a/oox/source/drawingml/table/tablestylecontext.cxx
+++ b/oox/source/drawingml/table/tablestylecontext.cxx
@@ -37,8 +37,8 @@ TableStyleContext::TableStyleContext( ContextHandler2Helper const & rParent,
: ContextHandler2( rParent )
, mrTableStyle( rTableStyle )
{
- mrTableStyle.getStyleId() = rAttribs.getString( XML_styleId ).value();
- mrTableStyle.getStyleName() = rAttribs.getString( XML_styleName ).value();
+ mrTableStyle.getStyleId() = rAttribs.getStringDefaulted( XML_styleId );
+ mrTableStyle.getStyleName() = rAttribs.getStringDefaulted( XML_styleName );
}
TableStyleContext::~TableStyleContext()
diff --git a/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx b/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx
index 20ff3e0dc105..c41f937fd2ab 100644
--- a/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx
+++ b/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx
@@ -48,7 +48,7 @@ ContextHandlerRef TableStyleListFragmentHandler::onCreateContext(
switch( aElementToken )
{
case A_TOKEN( tblStyleLst ): // CT_TableStyleList
- mrTableStyleList.getDefaultStyleId() = rAttribs.getString( XML_def ).value();
+ mrTableStyleList.getDefaultStyleId() = rAttribs.getStringDefaulted( XML_def );
break;
case A_TOKEN( tblStyle ): // CT_TableStyle
std::vector< TableStyle >& rTableStyles = mrTableStyleList.getTableStyles();
diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx
index 7a0a0212ef51..b0d05f61bd48 100644
--- a/oox/source/drawingml/textbodypropertiescontext.cxx
+++ b/oox/source/drawingml/textbodypropertiescontext.cxx
@@ -68,7 +68,7 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler2Helper cons
sal_Int32 aIns[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
for( sal_Int32 i = 0; i < sal_Int32(SAL_N_ELEMENTS( aIns )); i++)
{
- sValue = rAttribs.getString( aIns[i] ).value();
+ sValue = rAttribs.getStringDefaulted( aIns[i] );
if( !sValue.isEmpty() )
mrTextBodyProp.moInsets[i] = GetCoordinate( sValue );
}
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;
}
diff --git a/oox/source/drawingml/texteffectscontext.cxx b/oox/source/drawingml/texteffectscontext.cxx
index 61529a2c9b9c..0e33a4c3c13b 100644
--- a/oox/source/drawingml/texteffectscontext.cxx
+++ b/oox/source/drawingml/texteffectscontext.cxx
@@ -119,7 +119,7 @@ void TextEffectsContext::pushAttributeToGrabBag (sal_Int32 aAttributeId, const O
{
if (!rAttribs.hasAttribute(aAttributeId))
return;
- OUString aString = rAttribs.getString(aAttributeId).value();
+ OUString aString = rAttribs.getStringDefaulted(aAttributeId);
mpGrabBagStack->addString(rElementName, aString);
}
diff --git a/oox/source/drawingml/textfieldcontext.cxx b/oox/source/drawingml/textfieldcontext.cxx
index 2bd53a745528..b356d6fa6153 100644
--- a/oox/source/drawingml/textfieldcontext.cxx
+++ b/oox/source/drawingml/textfieldcontext.cxx
@@ -38,8 +38,8 @@ TextFieldContext::TextFieldContext( ContextHandler2Helper const & rParent,
, mrTextField( rTextField )
, mbIsInText( false )
{
- mrTextField.setUuid( rAttributes.getString( XML_id ).value() );
- mrTextField.setType( rAttributes.getString( XML_type ).value() );
+ mrTextField.setUuid( rAttributes.getStringDefaulted( XML_id ) );
+ mrTextField.setType( rAttributes.getStringDefaulted( XML_type ) );
}
void TextFieldContext::onEndElement( )
diff --git a/oox/source/drawingml/textparagraphpropertiescontext.cxx b/oox/source/drawingml/textparagraphpropertiescontext.cxx
index 076361d121df..8a8c30db61cb 100644
--- a/oox/source/drawingml/textparagraphpropertiescontext.cxx
+++ b/oox/source/drawingml/textparagraphpropertiescontext.cxx
@@ -119,7 +119,7 @@ TextParagraphPropertiesContext::TextParagraphPropertiesContext( ContextHandler2H
// ST_Coordinate
if ( rAttribs.hasAttribute( XML_indent ) )
{
- sValue = rAttribs.getString( XML_indent ).value();
+ sValue = rAttribs.getStringDefaulted( XML_indent );
mrTextParagraphProperties.getFirstLineIndentation() = std::optional< sal_Int32 >( sValue.isEmpty() ? 0 : GetCoordinate( sValue ) );
}
@@ -142,14 +142,14 @@ TextParagraphPropertiesContext::TextParagraphPropertiesContext( ContextHandler2H
// ParaLeftMargin
if ( rAttribs.hasAttribute( XML_marL ) )
{
- sValue = rAttribs.getString( XML_marL ).value();
+ sValue = rAttribs.getStringDefaulted( XML_marL );
mrTextParagraphProperties.getParaLeftMargin() = std::optional< sal_Int32 >( sValue.isEmpty() ? 0 : GetCoordinate( sValue ) );
}
// ParaRightMargin
if ( rAttribs.hasAttribute( XML_marR ) )
{
- sValue = rAttribs.getString( XML_marR ).value();
+ sValue = rAttribs.getStringDefaulted( XML_marR );
sal_Int32 nMarR = sValue.isEmpty() ? 0 : GetCoordinate( sValue ) ;
rPropertyMap.setProperty( PROP_ParaRightMargin, nMarR);
}
@@ -216,11 +216,11 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl
mrBulletList.mbBulletSizeFollowText <<= true;
break;
case A_TOKEN( buSzPct ): // CT_TextBulletSizePercent
- mrBulletList.setBulletSize( std::lround( GetPercent( rAttribs.getString( XML_val ).value() ) / 1000.f ) );
+ mrBulletList.setBulletSize( std::lround( GetPercent( rAttribs.getStringDefaulted( XML_val ) ) / 1000.f ) );
break;
case A_TOKEN( buSzPts ): // CT_TextBulletSizePoint
mrBulletList.setBulletSize(0);
- mrBulletList.setFontSize( static_cast<sal_Int16>(GetTextSize( rAttribs.getString( XML_val ).value() ) ) );
+ mrBulletList.setFontSize( static_cast<sal_Int16>(GetTextSize( rAttribs.getStringDefaulted( XML_val ) ) ) );
break;
// EG_TextBulletTypeface
@@ -260,7 +260,7 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl
case A_TOKEN( buChar ): // CT_TextCharBullet
try {
- mrBulletList.setBulletChar( rAttribs.getString( XML_char ).value() );
+ mrBulletList.setBulletChar( rAttribs.getStringDefaulted( XML_char ) );
mrBulletList.setSuffixNone();
}
catch(SAXException& /* e */)
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:
diff --git a/oox/source/drawingml/texttabstoplistcontext.cxx b/oox/source/drawingml/texttabstoplistcontext.cxx
index 5387d3b5365e..bfd9bfcc7ee6 100644
--- a/oox/source/drawingml/texttabstoplistcontext.cxx
+++ b/oox/source/drawingml/texttabstoplistcontext.cxx
@@ -50,7 +50,7 @@ namespace oox::drawingml {
{
OUString sValue;
TabStop aTabStop;
- sValue = rAttribs.getString( XML_pos ).value();
+ sValue = rAttribs.getStringDefaulted( XML_pos );
if( !sValue.isEmpty() )
{
aTabStop.Position = GetCoordinate( sValue );
diff --git a/oox/source/drawingml/themeelementscontext.cxx b/oox/source/drawingml/themeelementscontext.cxx
index 57ce15a4c0c5..9ff178c00cd1 100644
--- a/oox/source/drawingml/themeelementscontext.cxx
+++ b/oox/source/drawingml/themeelementscontext.cxx
@@ -216,14 +216,14 @@ ContextHandlerRef ThemeElementsContext::onCreateContext( sal_Int32 nElement, con
case A_TOKEN( clrScheme ): // CT_ColorScheme
if (rAttribs.hasAttribute(XML_name))
{
- mrTheme.getClrScheme().SetName(rAttribs.getString(XML_name).value());
+ mrTheme.getClrScheme().SetName(rAttribs.getStringDefaulted(XML_name));
}
return new clrSchemeContext( *this, mrTheme.getClrScheme() );
case A_TOKEN( fontScheme ): // CT_FontScheme
return new FontSchemeContext( *this, mrTheme.getFontScheme() );
case A_TOKEN( fmtScheme ): // CT_StyleMatrix
- mrTheme.setStyleName( rAttribs.getString( XML_name ).value() );
+ mrTheme.setStyleName( rAttribs.getStringDefaulted( XML_name ) );
return this;
case A_TOKEN( fillStyleLst ): // CT_FillStyleList
diff --git a/oox/source/drawingml/themefragmenthandler.cxx b/oox/source/drawingml/themefragmenthandler.cxx
index 5616dd75a08b..30dba148364d 100644
--- a/oox/source/drawingml/themefragmenthandler.cxx
+++ b/oox/source/drawingml/themefragmenthandler.cxx
@@ -48,7 +48,7 @@ ContextHandlerRef ThemeFragmentHandler::onCreateContext( sal_Int32 nElement, con
{
case A_TOKEN( theme ):
{
- mrTheme.setThemeName(rAttribs.getString(XML_name).value());
+ mrTheme.setThemeName(rAttribs.getStringDefaulted(XML_name));
return this;
}
}
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;
diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx
index 7e17d5b77171..2ee3ced80c5b 100644
--- a/oox/source/helper/attributelist.cxx
+++ b/oox/source/helper/attributelist.cxx
@@ -174,6 +174,14 @@ OptValue< OUString > AttributeList::getString( sal_Int32 nAttrToken ) const
return OptValue< OUString >();
}
+OUString AttributeList::getStringDefaulted( sal_Int32 nAttrToken ) const
+{
+ // check if the attribute exists (empty string may be different to missing attribute)
+ if( mxAttribs->hasAttribute( nAttrToken ) )
+ return mxAttribs->getOptionalValue( nAttrToken );
+ return OUString();
+}
+
OptValue< OUString > AttributeList::getXString( sal_Int32 nAttrToken ) const
{
// check if the attribute exists (empty string may be different to missing attribute)
diff --git a/oox/source/ppt/pptgraphicshapecontext.cxx b/oox/source/ppt/pptgraphicshapecontext.cxx
index a98d38624b5c..3a29d1c76ed5 100644
--- a/oox/source/ppt/pptgraphicshapecontext.cxx
+++ b/oox/source/ppt/pptgraphicshapecontext.cxx
@@ -51,14 +51,14 @@ ContextHandlerRef PPTGraphicShapeContext::onCreateContext( sal_Int32 aElementTok
// case NMSP_PPT|XML_drElemPr:
// break;
case PPT_TOKEN(cNvPr):
- mpShapePtr->setId( rAttribs.getString( XML_id ).value() );
- mpShapePtr->setName( rAttribs.getString( XML_name ).value() );
+ mpShapePtr->setId( rAttribs.getStringDefaulted( XML_id ) );
+ mpShapePtr->setName( rAttribs.getStringDefaulted( XML_name ) );
break;
case PPT_TOKEN(ph):
{
sal_Int32 nSubType( rAttribs.getToken( XML_type, XML_obj ) );
mpShapePtr->setSubType( nSubType );
- OUString sIdx( rAttribs.getString( XML_idx ).value() );
+ OUString sIdx( rAttribs.getStringDefaulted( XML_idx ) );
bool bHasIdx = !sIdx.isEmpty();
sal_Int32 nIdx = sIdx.toInt32();
if( rAttribs.hasAttribute( XML_idx ) )
diff --git a/oox/source/ppt/pptshapecontext.cxx b/oox/source/ppt/pptshapecontext.cxx
index 1bf7e1f30622..14b551864170 100644
--- a/oox/source/ppt/pptshapecontext.cxx
+++ b/oox/source/ppt/pptshapecontext.cxx
@@ -59,8 +59,8 @@ ContextHandlerRef PPTShapeContext::onCreateContext( sal_Int32 aElementToken, con
case PPT_TOKEN( cNvPr ):
{
mpShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
- mpShapePtr->setId( rAttribs.getString( XML_id ).value() );
- mpShapePtr->setName( rAttribs.getString( XML_name ).value() );
+ mpShapePtr->setId( rAttribs.getStringDefaulted( XML_id ) );
+ mpShapePtr->setName( rAttribs.getStringDefaulted( XML_name ) );
break;
}
case PPT_TOKEN( ph ):
@@ -74,7 +74,7 @@ ContextHandlerRef PPTShapeContext::onCreateContext( sal_Int32 aElementToken, con
if( rAttribs.hasAttribute( XML_idx ) )
{
- sal_Int32 nSubTypeIndex = rAttribs.getString( XML_idx ).value().toInt32();
+ sal_Int32 nSubTypeIndex = rAttribs.getStringDefaulted( XML_idx ).toInt32();
mpShapePtr->setSubTypeIndex( nSubTypeIndex );
if(!oSubType.has_value() && pMasterPersist)
diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx
index 6d7d33dbda16..6e7ca833b1f5 100644
--- a/oox/source/ppt/pptshapegroupcontext.cxx
+++ b/oox/source/ppt/pptshapegroupcontext.cxx
@@ -69,15 +69,15 @@ ContextHandlerRef PPTShapeGroupContext::onCreateContext( sal_Int32 aElementToken
// don't override SmartArt properties for embedded drawing's spTree
mpGroupShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
if (mpGroupShapePtr->getId().isEmpty())
- mpGroupShapePtr->setId(rAttribs.getString(XML_id).value());
+ mpGroupShapePtr->setId(rAttribs.getStringDefaulted(XML_id));
if (mpGroupShapePtr->getName().isEmpty())
- mpGroupShapePtr->setName( rAttribs.getString( XML_name ).value() );
+ mpGroupShapePtr->setName( rAttribs.getStringDefaulted( XML_name ) );
break;
}
case PPT_TOKEN( ph ):
mpGroupShapePtr->setSubType( rAttribs.getToken( XML_type, FastToken::DONTKNOW ) );
if( rAttribs.hasAttribute( XML_idx ) )
- mpGroupShapePtr->setSubTypeIndex( rAttribs.getString( XML_idx ).value().toInt32() );
+ mpGroupShapePtr->setSubTypeIndex( rAttribs.getStringDefaulted( XML_idx ).toInt32() );
break;
// nvSpPr CT_ShapeNonVisual end
@@ -106,7 +106,7 @@ ContextHandlerRef PPTShapeGroupContext::onCreateContext( sal_Int32 aElementToken
pShape->getFillProperties().moFillType = XML_noFill;
pShape->getFillProperties().moUseBgFill = true;
}
- pShape->setModelId(rAttribs.getString( XML_modelId ).value());
+ pShape->setModelId(rAttribs.getStringDefaulted( XML_modelId ));
return new PPTShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, pShape );
}
case PPT_TOKEN( pic ): // CT_Picture
diff --git a/oox/source/ppt/presPropsfragmenthandler.cxx b/oox/source/ppt/presPropsfragmenthandler.cxx
index 611021d4ace6..2cd9d82950d0 100644
--- a/oox/source/ppt/presPropsfragmenthandler.cxx
+++ b/oox/source/ppt/presPropsfragmenthandler.cxx
@@ -76,10 +76,10 @@ core::ContextHandlerRef PresPropsFragmentHandler::onCreateContext(sal_Int32 aEle
m_bTiming = rAttribs.getBool(XML_useTimings, true);
return this;
case PPT_TOKEN(custShow):
- m_sId = rAttribs.getString(XML_id).value();
+ m_sId = rAttribs.getStringDefaulted(XML_id);
return this;
case PPT_TOKEN(sldRg):
- m_sSt = rAttribs.getString(XML_st).value();
+ m_sSt = rAttribs.getStringDefaulted(XML_st);
return this;
}
return this;
diff --git a/oox/source/shape/LockedCanvasContext.cxx b/oox/source/shape/LockedCanvasContext.cxx
index 6b2f77a5a4b6..ab745158275a 100644
--- a/oox/source/shape/LockedCanvasContext.cxx
+++ b/oox/source/shape/LockedCanvasContext.cxx
@@ -79,8 +79,8 @@ LockedCanvasContext::onCreateContext(sal_Int32 nElementToken, const ::oox::Attri
case XML_cNvPr: // CT_NonVisualDrawingProps
{
mpShapePtr->setHidden(rAttribs.getBool(XML_hidden, false));
- mpShapePtr->setId(rAttribs.getString(XML_id).value());
- mpShapePtr->setName(rAttribs.getString(XML_name).value());
+ mpShapePtr->setId(rAttribs.getStringDefaulted(XML_id));
+ mpShapePtr->setName(rAttribs.getStringDefaulted(XML_name));
break;
}
case XML_cNvGrpSpPr: // CT_NonVisualGroupDrawingShapeProps
diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx
index da248bfd1349..c9cb789d28a9 100644
--- a/oox/source/vml/vmltextboxcontext.cxx
+++ b/oox/source/vml/vmltextboxcontext.cxx
@@ -181,9 +181,9 @@ TextBoxContext::TextBoxContext( ContextHandler2Helper const & rParent, TextBox&
ContextHandler2( rParent ),
mrTextBox( rTextBox )
{
- if( rAttribs.getString( XML_insetmode ).value() != "auto" )
+ if( rAttribs.getStringDefaulted( XML_insetmode ) != "auto" )
{
- OUString inset = rAttribs.getString( XML_inset ).value();
+ OUString inset = rAttribs.getStringDefaulted( XML_inset );
std::u16string_view value;
std::u16string_view remainingStr;