diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-06-21 13:17:09 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-06-27 11:32:42 +0200 |
commit | 04073c5fedd33654f242fecb7e39afb07cf0e273 (patch) | |
tree | 467852ad2c7ca41b90c89eff2b6c9e4ae5544617 /include/oox | |
parent | 5b21b65572610df88986e700b81f1156aff14f65 (diff) |
replace oox::OptValue with std::optional
Change-Id: I16e7179b2851640b4d73665685dcc1e84042ddaf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136270
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/oox')
-rw-r--r-- | include/oox/drawingml/shape.hxx | 4 | ||||
-rw-r--r-- | include/oox/helper/attributelist.hxx | 20 | ||||
-rw-r--r-- | include/oox/helper/helper.hxx | 32 | ||||
-rw-r--r-- | include/oox/ppt/pptshape.hxx | 3 | ||||
-rw-r--r-- | include/oox/vml/vmlformatting.hxx | 64 | ||||
-rw-r--r-- | include/oox/vml/vmlshape.hxx | 26 | ||||
-rw-r--r-- | include/oox/vml/vmlshapecontext.hxx | 2 | ||||
-rw-r--r-- | include/oox/vml/vmltextbox.hxx | 26 |
8 files changed, 74 insertions, 103 deletions
diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx index 5f4173c9de87..246a964fc2a6 100644 --- a/include/oox/drawingml/shape.hxx +++ b/include/oox/drawingml/shape.hxx @@ -179,7 +179,7 @@ public: void setSubType( sal_Int32 nSubType ) { mnSubType = nSubType; } sal_Int32 getSubType() const { return mnSubType; } void setSubTypeIndex( sal_Int32 nSubTypeIndex ) { moSubTypeIndex = nSubTypeIndex; } - const OptValue< sal_Int32 >& getSubTypeIndex() const { return moSubTypeIndex; } + const std::optional< sal_Int32 >& getSubTypeIndex() const { return moSubTypeIndex; } // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value) void setDefaults(bool bHeight); @@ -353,7 +353,7 @@ protected: OUString msId; OUString msDescription; sal_Int32 mnSubType; // if this type is not zero, then the shape is a placeholder - OptValue< sal_Int32 > moSubTypeIndex; + std::optional< sal_Int32 > moSubTypeIndex; ShapeStyleRefMap maShapeStyleRefs; diff --git a/include/oox/helper/attributelist.hxx b/include/oox/helper/attributelist.hxx index fb4079714a5c..d58305bffa54 100644 --- a/include/oox/helper/attributelist.hxx +++ b/include/oox/helper/attributelist.hxx @@ -95,41 +95,41 @@ public: // optional return values ------------------------------------------------- /** Returns the token identifier of the value of the specified attribute. */ - OptValue< sal_Int32 > getToken( sal_Int32 nAttrToken ) const; + std::optional< sal_Int32 > getToken( sal_Int32 nAttrToken ) const; /** Returns the Color object of highlight of the text. */ oox::drawingml::Color getHighlightColor(sal_Int32 nAttrToken) const; /** Returns the string value of the specified attribute. */ - OptValue< OUString > getString( sal_Int32 nAttrToken ) const; + std::optional< OUString > getString( sal_Int32 nAttrToken ) const; /** Returns the string value of the specified attribute, returns an empty string if attribute not present. */ OUString getStringDefaulted( sal_Int32 nAttrToken ) const; /** Returns the string value of the specified attribute. All characters in the format '_xHHHH_' (H being a hexadecimal digit), will be decoded. */ - OptValue< OUString > getXString( sal_Int32 nAttrToken ) const; + std::optional< OUString > getXString( sal_Int32 nAttrToken ) const; /** Returns the double value of the specified attribute. */ - OptValue< double > getDouble( sal_Int32 nAttrToken ) const; + std::optional< double > getDouble( sal_Int32 nAttrToken ) const; /** Returns the 32-bit signed integer value of the specified attribute (decimal). */ - OptValue< sal_Int32 > getInteger( sal_Int32 nAttrToken ) const; + std::optional< sal_Int32 > getInteger( sal_Int32 nAttrToken ) const; /** Returns the 32-bit unsigned integer value of the specified attribute (decimal). */ - OptValue< sal_uInt32 > getUnsigned( sal_Int32 nAttrToken ) const; + std::optional< sal_uInt32 > getUnsigned( sal_Int32 nAttrToken ) const; /** Returns the 64-bit signed integer value of the specified attribute (decimal). */ - OptValue< sal_Int64 > getHyper( sal_Int32 nAttrToken ) const; + std::optional< sal_Int64 > getHyper( sal_Int32 nAttrToken ) const; /** Returns the 32-bit signed integer value of the specified attribute (hexadecimal). */ - OptValue< sal_Int32 > getIntegerHex( sal_Int32 nAttrToken ) const; + std::optional< sal_Int32 > getIntegerHex( sal_Int32 nAttrToken ) const; /** Returns the boolean value of the specified attribute. */ - OptValue< bool > getBool( sal_Int32 nAttrToken ) const; + std::optional< bool > getBool( sal_Int32 nAttrToken ) const; /** Returns the date/time value of the specified attribute. */ - OptValue< css::util::DateTime > getDateTime( sal_Int32 nAttrToken ) const; + std::optional< css::util::DateTime > getDateTime( sal_Int32 nAttrToken ) const; // defaulted return values ------------------------------------------------ diff --git a/include/oox/helper/helper.hxx b/include/oox/helper/helper.hxx index ef066f31d338..f9bdd1cec9c2 100644 --- a/include/oox/helper/helper.hxx +++ b/include/oox/helper/helper.hxx @@ -24,6 +24,7 @@ #include <cstring> #include <limits> +#include <optional> #include <o3tl/safeint.hxx> #include <osl/endian.h> @@ -168,37 +169,8 @@ inline void setFlag( Type& ornBitField, Type nMask, bool bSet = true ) } -/** Optional value, similar to ::std::optional<>, with convenience accessors. - */ -template< typename Type > -class OptValue -{ -public: - OptValue() : maValue(), mbHasValue( false ) {} - explicit OptValue( const Type& rValue ) : maValue( rValue ), mbHasValue( true ) {} - - bool has_value() const { return mbHasValue; } - bool operator!() const { return !mbHasValue; } - - 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; } - Type& emplace() { mbHasValue = true; maValue = Type(); return maValue; } - - OptValue& operator=( const Type& rValue ) { maValue = rValue; mbHasValue = true; return *this; } - bool operator==( const OptValue& rValue ) const { - return ( ( !mbHasValue && rValue.mbHasValue == false ) || - ( mbHasValue == rValue.mbHasValue && maValue == rValue.maValue ) ); - } - -private: - Type maValue; - bool mbHasValue; -}; - template< typename Type > -void assignIfUsed( OptValue<Type>& rDestValue, const OptValue<Type>& rSourceValue ) +void assignIfUsed( std::optional<Type>& rDestValue, const std::optional<Type>& rSourceValue ) { if( rSourceValue.has_value() ) rDestValue = rSourceValue.value(); diff --git a/include/oox/ppt/pptshape.hxx b/include/oox/ppt/pptshape.hxx index ead382b52685..fd5268ea0a89 100644 --- a/include/oox/ppt/pptshape.hxx +++ b/include/oox/ppt/pptshape.hxx @@ -39,7 +39,6 @@ namespace com::sun::star { namespace oox { namespace core { class XmlFilterBase; } namespace drawingml { class Theme; } - template <typename Type> class OptValue; } namespace oox::ppt { @@ -83,7 +82,7 @@ public: bool hasNonInheritedShapeProperties() const { return mbHasNoninheritedShapeProperties; } static oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nFirstSubType, - const sal_Int32 nSecondSubType, const OptValue< sal_Int32 >& oSubTypeIndex, + const sal_Int32 nSecondSubType, const std::optional< sal_Int32 >& oSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes, bool bMasterOnly = false ); static oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes, bool bMasterOnly = false ); diff --git a/include/oox/vml/vmlformatting.hxx b/include/oox/vml/vmlformatting.hxx index 3f7bbe60a457..f35ab118aec8 100644 --- a/include/oox/vml/vmlformatting.hxx +++ b/include/oox/vml/vmlformatting.hxx @@ -166,8 +166,8 @@ OOX_DLLPUBLIC sal_Int32 decodeMeasureToTwip(const GraphicHelper& rGraphicHelper, */ OOX_DLLPUBLIC ::oox::drawingml::Color decodeColor( const GraphicHelper& rGraphicHelper, - const OptValue< OUString >& roVmlColor, - const OptValue< double >& roVmlOpacity, + const std::optional< OUString >& roVmlColor, + const std::optional< double >& roVmlOpacity, ::Color nDefaultRgb, ::Color nPrimaryRgb = API_RGB_TRANSPARENT ); @@ -193,9 +193,9 @@ OOX_DLLPUBLIC sal_Int32 decodeMeasureToTwip(const GraphicHelper& rGraphicHelper, /** The stroke arrow model structure contains all properties for a line end arrow. */ struct StrokeArrowModel { - OptValue< sal_Int32 > moArrowType; - OptValue< sal_Int32 > moArrowWidth; - OptValue< sal_Int32 > moArrowLength; + std::optional< sal_Int32 > moArrowType; + std::optional< sal_Int32 > moArrowWidth; + std::optional< sal_Int32 > moArrowLength; void assignUsed( const StrokeArrowModel& rSource ); }; @@ -204,16 +204,16 @@ struct StrokeArrowModel /** The stroke model structure contains all shape border properties. */ struct StrokeModel { - OptValue< bool > moStroked; ///< Shape border line on/off. + std::optional< bool > moStroked; ///< Shape border line on/off. StrokeArrowModel maStartArrow; ///< Start line arrow style. StrokeArrowModel maEndArrow; ///< End line arrow style. - OptValue< OUString > moColor; ///< Solid line color. - OptValue< double > moOpacity; ///< Solid line color opacity. - OptValue< OUString > moWeight; ///< Line width. - OptValue< OUString > moDashStyle; ///< Line dash (predefined or manually). - OptValue< sal_Int32 > moLineStyle; ///< Line style (single, double, ...). - OptValue< sal_Int32 > moEndCap; ///< Type of line end cap. - OptValue< sal_Int32 > moJoinStyle; ///< Type of line join. + std::optional< OUString > moColor; ///< Solid line color. + std::optional< double > moOpacity; ///< Solid line color opacity. + std::optional< OUString > moWeight; ///< Line width. + std::optional< OUString > moDashStyle; ///< Line dash (predefined or manually). + std::optional< sal_Int32 > moLineStyle; ///< Line style (single, double, ...). + std::optional< sal_Int32 > moEndCap; ///< Type of line end cap. + std::optional< sal_Int32 > moJoinStyle; ///< Type of line join. void assignUsed( const StrokeModel& rSource ); @@ -227,18 +227,18 @@ struct StrokeModel /** The fill model structure contains all shape fill properties. */ struct OOX_DLLPUBLIC FillModel { - OptValue< bool > moFilled; ///< Shape fill on/off. - OptValue< OUString > moColor; ///< Solid fill color. - OptValue< double > moOpacity; ///< Solid fill color opacity. - OptValue< OUString > moColor2; ///< End color of gradient. - OptValue< double > moOpacity2; ///< End color opacity of gradient. - OptValue< sal_Int32 > moType; ///< Fill type. - OptValue< sal_Int32 > moAngle; ///< Gradient rotation angle. - OptValue< double > moFocus; ///< Linear gradient focus of second color. - OptValue< DoublePair > moFocusPos; ///< Rectangular gradient focus position of second color. - OptValue< DoublePair > moFocusSize; ///< Rectangular gradient focus size of second color. - OptValue< OUString > moBitmapPath; ///< Path to fill bitmap fragment. - OptValue< bool > moRotate; ///< True = rotate gradient/bitmap with shape. + std::optional< bool > moFilled; ///< Shape fill on/off. + std::optional< OUString > moColor; ///< Solid fill color. + std::optional< double > moOpacity; ///< Solid fill color opacity. + std::optional< OUString > moColor2; ///< End color of gradient. + std::optional< double > moOpacity2; ///< End color opacity of gradient. + std::optional< sal_Int32 > moType; ///< Fill type. + std::optional< sal_Int32 > moAngle; ///< Gradient rotation angle. + std::optional< double > moFocus; ///< Linear gradient focus of second color. + std::optional< DoublePair > moFocusPos; ///< Rectangular gradient focus position of second color. + std::optional< DoublePair > moFocusSize; ///< Rectangular gradient focus size of second color. + std::optional< OUString > moBitmapPath; ///< Path to fill bitmap fragment. + std::optional< bool > moRotate; ///< True = rotate gradient/bitmap with shape. void assignUsed( const FillModel& rSource ); @@ -253,10 +253,10 @@ struct OOX_DLLPUBLIC FillModel struct OOX_DLLPUBLIC ShadowModel { bool mbHasShadow; ///< Is a v:shadow element seen? - OptValue<bool> moShadowOn; ///< Is the element turned on? - OptValue<OUString> moColor; ///< Specifies the color of the shadow. - OptValue<OUString> moOffset; ///< Specifies the shadow's offset from the shape's location. - OptValue<double> moOpacity; ///< Specifies the opacity of the shadow. + std::optional<bool> moShadowOn; ///< Is the element turned on? + std::optional<OUString> moColor; ///< Specifies the color of the shadow. + std::optional<OUString> moOffset; ///< Specifies the shadow's offset from the shape's location. + std::optional<double> moOpacity; ///< Specifies the opacity of the shadow. ShadowModel(); @@ -267,9 +267,9 @@ struct OOX_DLLPUBLIC ShadowModel /** The shadow model structure contains all shape textpath properties. */ struct TextpathModel { - OptValue<OUString> moString; ///< Specifies the string of the textpath. - OptValue<OUString> moStyle; ///< Specifies the style of the textpath. - OptValue<bool> moTrim; ///< Specifies whether extra space is removed above and below the text + std::optional<OUString> moString; ///< Specifies the string of the textpath. + std::optional<OUString> moStyle; ///< Specifies the style of the textpath. + std::optional<bool> moTrim; ///< Specifies whether extra space is removed above and below the text TextpathModel(); diff --git a/include/oox/vml/vmlshape.hxx b/include/oox/vml/vmlshape.hxx index 7a17bda51ccd..36a9511a2632 100644 --- a/include/oox/vml/vmlshape.hxx +++ b/include/oox/vml/vmlshape.hxx @@ -62,10 +62,10 @@ struct ShapeTypeModel OUString maShapeId; ///< Unique identifier of the shape. OUString maLegacyId; ///< Plaintext identifier of the shape. OUString maShapeName; ///< Name of the shape, if present. - OptValue< sal_Int32 > moShapeType; ///< Builtin shape type identifier. + std::optional< sal_Int32 > moShapeType; ///< Builtin shape type identifier. - OptValue< Int32Pair > moCoordPos; ///< Top-left position of coordinate system for children scaling. - OptValue< Int32Pair > moCoordSize; ///< Size of coordinate system for children scaling. + std::optional< Int32Pair > moCoordPos; ///< Top-left position of coordinate system for children scaling. + std::optional< Int32Pair > moCoordSize; ///< Size of coordinate system for children scaling. OUString maPosition; ///< Position type of the shape. OUString maZIndex; ///< ZIndex of the shape OUString maLeft; ///< X position of the shape bounding box (number with unit). @@ -96,21 +96,21 @@ struct ShapeTypeModel ShadowModel maShadowModel; ///< Shape shadow formatting. TextpathModel maTextpathModel; ///< Shape textpath formatting. - OptValue< OUString > moGraphicPath; ///< Path to a graphic for this shape. - OptValue< OUString > moGraphicTitle; ///< Title of the graphic. - OptValue< OUString > moWrapAnchorX; ///< The base object from which our horizontal positioning should be calculated. - OptValue< OUString > moWrapAnchorY; ///< The base object from which our vertical positioning should be calculated. - OptValue< OUString > moWrapType; ///< How to wrap the text around the object - OptValue< OUString > moWrapSide; ///< On which side to wrap the text around the object + std::optional< OUString > moGraphicPath; ///< Path to a graphic for this shape. + std::optional< OUString > moGraphicTitle; ///< Title of the graphic. + std::optional< OUString > moWrapAnchorX; ///< The base object from which our horizontal positioning should be calculated. + std::optional< OUString > moWrapAnchorY; ///< The base object from which our vertical positioning should be calculated. + std::optional< OUString > moWrapType; ///< How to wrap the text around the object + std::optional< OUString > moWrapSide; ///< On which side to wrap the text around the object OUString maVTextAnchor; ///< How the text inside the shape is anchored vertically. OUString maWrapDistanceLeft; ///< Distance from the left side of the shape to the text that wraps around it. OUString maWrapDistanceRight; ///< Distance from the right side of the shape to the text that wraps around it. OUString maWrapDistanceTop; ///< Distance from the top of the shape to the text that wraps around it. OUString maWrapDistanceBottom; ///< Distance from the bottom of the shape to the text that wraps around it. - OptValue<OUString> moCropBottom; ///< Specifies the how much to crop the image from the bottom up as a fraction of picture size. - OptValue<OUString> moCropLeft; ///< Specifies how much to crop the image from the left in as a fraction of picture size. - OptValue<OUString> moCropRight; ///< Specifies how much to crop the image from the right in as a fraction of picture size. - OptValue<OUString> moCropTop; ///< Specifies how much to crop the image from the top down as a fraction of picture size. + std::optional<OUString> moCropBottom; ///< Specifies the how much to crop the image from the bottom up as a fraction of picture size. + std::optional<OUString> moCropLeft; ///< Specifies how much to crop the image from the left in as a fraction of picture size. + std::optional<OUString> moCropRight; ///< Specifies how much to crop the image from the right in as a fraction of picture size. + std::optional<OUString> moCropTop; ///< Specifies how much to crop the image from the top down as a fraction of picture size. OUString maLayoutFlowAlt; ///< Specifies the alternate layout flow for text in textboxes. /// An adjustment for the intensity of all colors, i.e. contrast, on a 0..0x10000 scale. diff --git a/include/oox/vml/vmlshapecontext.hxx b/include/oox/vml/vmlshapecontext.hxx index ce838297cdf0..61e189fc009f 100644 --- a/include/oox/vml/vmlshapecontext.hxx +++ b/include/oox/vml/vmlshapecontext.hxx @@ -109,7 +109,7 @@ private: void setStyle( std::u16string_view rStyle ); /** Resolve a relation identifier to a fragment path. */ - OptValue< OUString > decodeFragmentPath( const AttributeList& rAttribs, sal_Int32 nToken ) const; + std::optional< OUString > decodeFragmentPath( const AttributeList& rAttribs, sal_Int32 nToken ) const; private: std::shared_ptr<ShapeType> m_pShapeType; diff --git a/include/oox/vml/vmltextbox.hxx b/include/oox/vml/vmltextbox.hxx index fb6983315b61..f3c4bf4f2fd6 100644 --- a/include/oox/vml/vmltextbox.hxx +++ b/include/oox/vml/vmltextbox.hxx @@ -41,24 +41,24 @@ struct ShapeTypeModel; /// A text paragraph in a textbox. struct TextParagraphModel { - OptValue<OUString> moParaAdjust; ///< Paragraph adjust (left, center, right, etc.) - OptValue<OUString> moParaStyleName; + std::optional<OUString> moParaAdjust; ///< Paragraph adjust (left, center, right, etc.) + std::optional<OUString> moParaStyleName; }; /** Font settings for a text portion in a textbox. */ struct OOX_DLLPUBLIC TextFontModel { - OptValue< OUString > moName; ///< Font name. - OptValue< OUString > moNameAsian; ///< Asian font name. - OptValue< OUString > moNameComplex; ///< Complex font name. - OptValue< OUString > moColor; ///< Font color, HTML encoded, sort of. - OptValue< sal_Int32 > monSize; ///< Font size in twips. - OptValue< sal_Int32 > monUnderline; ///< Single or double underline. - OptValue< sal_Int32 > monEscapement; ///< Subscript or superscript. - OptValue< bool > mobBold; - OptValue< bool > mobItalic; - OptValue< bool > mobStrikeout; - OptValue<sal_Int32> monSpacing; + std::optional< OUString > moName; ///< Font name. + std::optional< OUString > moNameAsian; ///< Asian font name. + std::optional< OUString > moNameComplex; ///< Complex font name. + std::optional< OUString > moColor; ///< Font color, HTML encoded, sort of. + std::optional< sal_Int32 > monSize; ///< Font size in twips. + std::optional< sal_Int32 > monUnderline; ///< Single or double underline. + std::optional< sal_Int32 > monEscapement; ///< Subscript or superscript. + std::optional< bool > mobBold; + std::optional< bool > mobItalic; + std::optional< bool > mobStrikeout; + std::optional<sal_Int32> monSpacing; explicit TextFontModel(); }; |