include/oox/helper/helper.hxx                  |    2 +-
 oox/source/drawingml/chart/seriesconverter.cxx |    2 +-
 oox/source/drawingml/shape.cxx                 |    2 +-
 oox/source/vml/vmlformatting.cxx               |    2 +-
 oox/source/vml/vmlshape.cxx                    |    6 ++++--
 oox/source/vml/vmltextbox.cxx                  |    4 ++--
 6 files changed, 10 insertions(+), 8 deletions(-)

New commits:
commit 79f3abc0e200ffa772bc7722b5f384eb538d7576
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Jun 24 11:55:13 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Jun 24 20:37:10 2022 +0200

    make oox::OptValue::value() assert if empty
    
    as part of replacing OptValue with std::optional, we need to mimc the
    behaviour of std::optional::value(), which will throw
    bad_optional_access
    
    Change-Id: Icf5141cefd4623a6a1bb7b3a3449d3af382e01c1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136365
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/oox/helper/helper.hxx b/include/oox/helper/helper.hxx
index 9d5b7c3e2549..ef066f31d338 100644
--- a/include/oox/helper/helper.hxx
+++ b/include/oox/helper/helper.hxx
@@ -180,7 +180,7 @@ public:
     bool         has_value() const { return mbHasValue; }
     bool         operator!() const { return !mbHasValue; }
 
-    const Type&  value() const { return maValue; }
+    const Type&  value() const { assert(mbHasValue); return maValue; }
     const Type&  value_or( const Type& rDefValue ) const { return mbHasValue ? 
maValue : rDefValue; }
 
     Type&        operator*() { assert(mbHasValue); return maValue; }
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx 
b/oox/source/drawingml/chart/seriesconverter.cxx
index 383e5bd3fa4b..03e97d3e3339 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -197,7 +197,7 @@ void importBorderProperties( PropertySet& rPropSet, Shape& 
rShape, const Graphic
 {
     LineProperties& rLP = rShape.getLineProperties();
     // no fill has the same effect as no border so skip it
-    if (rLP.maLineFill.moFillType.value() == XML_noFill)
+    if (rLP.maLineFill.moFillType.has_value() && 
rLP.maLineFill.moFillType.value() == XML_noFill)
         return;
 
     if (rLP.moLineWidth.has_value())
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 236e0bea3c82..20564b584f76 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1685,7 +1685,7 @@ Reference< XShape > const & Shape::createAndInsert(
                 mpCustomShapePropertiesPtr->setMirroredY( true );
             if( getTextBody() )
             {
-                sal_Int32 nTextCameraZRotation = static_cast< sal_Int32 >( 
getTextBody()->get3DProperties().maCameraRotation.mnRevolution.value() );
+                sal_Int32 nTextCameraZRotation = 
getTextBody()->get3DProperties().maCameraRotation.mnRevolution.value_or(0);
                 mpCustomShapePropertiesPtr->setTextCameraZRotateAngle( 
nTextCameraZRotation / 60000 );
 
                 sal_Int32 nTextRotateAngle = static_cast< sal_Int32 >( 
getTextBody()->getTextProperties().moRotation.value_or( 0 ) );
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index 6d80193e7b37..00a346748531 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -981,7 +981,7 @@ void TextpathModel::pushToPropMap(ShapePropertyMap& 
rPropMap, const uno::Referen
     if (moTrim.has_value() && moTrim.value())
         return;
 
-    OUString sText = moString.value();
+    OUString sText = moString.value_or("");
     ScopedVclPtrInstance<VirtualDevice> pDevice;
     vcl::Font aFont = pDevice->GetFont();
     aFont.SetFamilyName(sFont);
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 2cb8261f1af4..22ea45a3bdd3 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -578,7 +578,7 @@ SimpleShape::SimpleShape( Drawing& rDrawing, const 
OUString& rService ) :
 
 static void lcl_setSurround(PropertySet& rPropSet, const ShapeTypeModel& 
rTypeModel, const GraphicHelper& rGraphicHelper)
 {
-    OUString aWrapType = rTypeModel.moWrapType.value();
+    OUString aWrapType = rTypeModel.moWrapType.value_or("");
 
     // Extreme negative top margin? Then the shape will end up at the top of 
the page, it's pointless to perform any kind of wrapping.
     sal_Int32 nMarginTop = 
ConversionHelper::decodeMeasureToHmm(rGraphicHelper, rTypeModel.maMarginTop, 0, 
false, true);
@@ -590,7 +590,9 @@ static void lcl_setSurround(PropertySet& rPropSet, const 
ShapeTypeModel& rTypeMo
          aWrapType == "through" )
     {
         nSurround = css::text::WrapTextMode_PARALLEL;
-        if ( rTypeModel.moWrapSide.value() == "left" )
+        if ( !rTypeModel.moWrapSide.has_value() )
+            ; // leave as PARALLEL
+        else if ( rTypeModel.moWrapSide.value() == "left" )
             nSurround = css::text::WrapTextMode_LEFT;
         else if ( rTypeModel.moWrapSide.value() == "right" )
             nSurround = css::text::WrapTextMode_RIGHT;
diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx
index cf31236c48ca..e6da71a06d78 100644
--- a/oox/source/vml/vmltextbox.cxx
+++ b/oox/source/vml/vmltextbox.cxx
@@ -93,11 +93,11 @@ void TextBox::convert(const 
uno::Reference<drawing::XShape>& xShape) const
             aPropVec.push_back(aPropertyValue);
 
             aPropertyValue.Name = "CharFontNameAsian";
-            aPropertyValue.Value <<= rFont.moNameAsian.value();
+            aPropertyValue.Value <<= rFont.moNameAsian.value_or("");
             aPropVec.push_back(aPropertyValue);
 
             aPropertyValue.Name = "CharFontNameComplex";
-            aPropertyValue.Value <<= rFont.moNameComplex.value();
+            aPropertyValue.Value <<= rFont.moNameComplex.value_or("");
             aPropVec.push_back(aPropertyValue);
         }
         if (rFont.mobBold.has_value())

Reply via email to