diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-11-30 17:48:32 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-12-01 14:57:16 +0100 |
commit | 7e403195e574be5174815a51cf5c42f06f76a87a (patch) | |
tree | c6147bcac095cd387f06dee63a25e15db6ca84c6 /include | |
parent | 7b3190eda387bcd897095205732f6752dedf01ef (diff) |
Introduce o3tl::optional as an alias for std::optional
...with a boost::optional fallback for Xcode < 10 (as std::optional is only
available starting with Xcode 10 according to
<https://en.cppreference.com/w/cpp/compiler_support>, and our baseline for iOS
and macOS is still Xcode 9.3 according to README.md). And mechanically rewrite
all code to use o3tl::optional instead of boost::optional.
One immediate benefit is that disabling -Wmaybe-uninitialized for GCC as per
fed7c3deb3f4ec81f78967c2d7f3c4554398cb9d "Slience bogus
-Werror=maybe-uninitialized" should no longer be necessary (and whose check
happened to no longer trigger for GCC 10 trunk, even though that compiler would
still emit bogus -Wmaybe-uninitialized for uses of boost::optional under
--enable-optimized, which made me ponder whether this switch from
boost::optional to std::optional would be a useful thing to do; I keep that
configure.ac check for now, though, and will only remove it in a follow up
commit).
Another longer-term benefit is that the code is now already in good shape for an
eventual switch to std::optional (a switch we would have done anyway once we no
longer need to support Xcode < 10).
Only desktop/qa/desktop_lib/test_desktop_lib.cxx heavily uses
boost::property_tree::ptree::get_child_optional returning boost::optional, so
let it keep using boost::optional for now.
After a number of preceding commits have paved the way for this change, this
commit is completely mechanical, done with
> git ls-files -z | grep -vz -e '^bin/find-unneeded-includes$' -e '^configure.ac$' -e '^desktop/qa/desktop_lib/test_desktop_lib.cxx$' -e '^dictionaries$' -e '^external/' -e '^helpcontent2$' -e '^include/IwyuFilter_include.yaml$' -e '^sc/IwyuFilter_sc.yaml$' -e '^solenv/gdb/boost/optional.py$' -e '^solenv/vs/LibreOffice.natvis$' -e '^translations$' -e '\.svg$' | xargs -0 sed -i -E -e 's|\<boost(/optional)?/optional\.hpp\>|o3tl/optional.hxx|g' -e 's/\<boost(\s*)::(\s*)(make_)?optional\>/o3tl\1::\2\3optional/g' -e 's/\<boost(\s*)::(\s*)none\>/o3tl\1::\2nullopt/g'
(before committing include/o3tl/optional.hxx, and relying on some GNU features).
It excludes some files where mention of boost::optional et al should apparently
not be changed (and the sub-repo directory stubs). It turned out that all uses
of boost::none across the code base were in combination with boost::optional, so
had all to be rewritten as o3tl::nullopt.
Change-Id: Ibfd9f4b3d5a8aee6e6eed310b988c4e5ffd8b11b
Reviewed-on: https://gerrit.libreoffice.org/84128
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include')
34 files changed, 175 insertions, 129 deletions
diff --git a/include/comphelper/configuration.hxx b/include/comphelper/configuration.hxx index cb2ad5675660..7c2a0a7fb4ec 100644 --- a/include/comphelper/configuration.hxx +++ b/include/comphelper/configuration.hxx @@ -12,7 +12,7 @@ #include <sal/config.h> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Reference.h> #include <comphelper/comphelperdllapi.h> @@ -158,18 +158,18 @@ private: }; /// @internal -template< typename T > struct Convert< boost::optional< T > > +template< typename T > struct Convert< o3tl::optional< T > > { - static css::uno::Any toAny(boost::optional< T > const & value) { + static css::uno::Any toAny(o3tl::optional< T > const & value) { return value ? css::uno::makeAny(*value) : css::uno::Any(); } - static boost::optional< T > fromAny(css::uno::Any const & value) + static o3tl::optional< T > fromAny(css::uno::Any const & value) { return value.hasValue() - ? boost::optional< T >(value.get< T >()) : boost::optional< T >(); + ? o3tl::optional< T >(value.get< T >()) : o3tl::optional< T >(); } private: @@ -200,7 +200,7 @@ template< typename T, typename U > struct ConfigurationProperty /// Get the value of the given (non-localized) configuration property. /// - /// For nillable properties, U is of type boost::optional<U'>. + /// For nillable properties, U is of type o3tl::optional<U'>. static U get( css::uno::Reference< css::uno::XComponentContext > const & context = comphelper::getProcessComponentContext()) @@ -216,7 +216,7 @@ template< typename T, typename U > struct ConfigurationProperty /// Set the value of the given (non-localized) configuration property, via a /// given changes batch. /// - /// For nillable properties, U is of type boost::optional<U'>. + /// For nillable properties, U is of type o3tl::optional<U'>. static void set( U const & value, std::shared_ptr< ConfigurationChanges > const & batch) @@ -244,7 +244,7 @@ template< typename T, typename U > struct ConfigurationLocalizedProperty /// locale currently set at the /// com.sun.star.configuration.theDefaultProvider. /// - /// For nillable properties, U is of type boost::optional<U'>. + /// For nillable properties, U is of type o3tl::optional<U'>. static U get(css::uno::Reference< css::uno::XComponentContext > const & context) { // Folding this into one statement causes a bogus error at least with @@ -260,7 +260,7 @@ template< typename T, typename U > struct ConfigurationLocalizedProperty /// com.sun.star.configuration.theDefaultProvider, via a given changes /// batch. /// - /// For nillable properties, U is of type boost::optional<U'>. + /// For nillable properties, U is of type o3tl::optional<U'>. static void set( U const & value, std::shared_ptr< ConfigurationChanges > const & batch) diff --git a/include/comphelper/logging.hxx b/include/comphelper/logging.hxx index 5057ff9d838f..1fa7601519db 100644 --- a/include/comphelper/logging.hxx +++ b/include/comphelper/logging.hxx @@ -23,7 +23,7 @@ #include <comphelper/comphelperdllapi.h> #include <rtl/ustring.hxx> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <memory> namespace com::sun::star::uno { template <class interface_type> class Reference; } @@ -65,7 +65,7 @@ namespace comphelper //= EventLogger class EventLogger_Impl; - typedef ::boost::optional< OUString > OptionalString; + typedef ::o3tl::optional< OUString > OptionalString; /** encapsulates a css::logging::XLogger diff --git a/include/comphelper/unwrapargs.hxx b/include/comphelper/unwrapargs.hxx index 7c1d26d3a0aa..3ba4e213c266 100644 --- a/include/comphelper/unwrapargs.hxx +++ b/include/comphelper/unwrapargs.hxx @@ -22,7 +22,7 @@ #include <sal/config.h> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <rtl/ustrbuf.hxx> #include <com/sun/star/uno/Sequence.hxx> @@ -67,7 +67,7 @@ namespace detail { template< typename T, typename... Args > inline void unwrapArgs( const css::uno::Sequence< css::uno::Any >& seq, - sal_Int32 nArg, ::boost::optional< T >& v, Args&... args ); + sal_Int32 nArg, ::o3tl::optional< T >& v, Args&... args ); template< typename T, typename... Args > inline void unwrapArgs( @@ -95,7 +95,7 @@ namespace detail { template< typename T, typename... Args > inline void unwrapArgs( const css::uno::Sequence< css::uno::Any >& seq, - sal_Int32 nArg, ::boost::optional< T >& v, Args&... args ) + sal_Int32 nArg, ::o3tl::optional< T >& v, Args&... args ) { if( nArg < seq.getLength() ) { diff --git a/include/connectivity/sqlerror.hxx b/include/connectivity/sqlerror.hxx index 9b4c60c49476..9b75657290f4 100644 --- a/include/connectivity/sqlerror.hxx +++ b/include/connectivity/sqlerror.hxx @@ -22,7 +22,7 @@ #include <com/sun/star/sdbc/SQLException.hpp> #include <connectivity/dbtoolsdllapi.hxx> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <memory> namespace connectivity @@ -61,11 +61,11 @@ namespace connectivity // - optional - /** convenience wrapper around boost::optional, allowing implicit construction + /** convenience wrapper around o3tl::optional, allowing implicit construction */ - class ParamValue : public ::boost::optional< OUString > + class ParamValue : public ::o3tl::optional< OUString > { - typedef ::boost::optional< OUString > base_type; + typedef ::o3tl::optional< OUString > base_type; public: ParamValue( ) : base_type( ) { } diff --git a/include/cppcanvas/renderer.hxx b/include/cppcanvas/renderer.hxx index 113bda783f20..ed1dc04a11f7 100644 --- a/include/cppcanvas/renderer.hxx +++ b/include/cppcanvas/renderer.hxx @@ -22,7 +22,7 @@ #include <sal/types.h> #include <rtl/ustring.hxx> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> #include <cppcanvas/canvasgraphic.hxx> #include <cppcanvas/color.hxx> @@ -100,16 +100,16 @@ namespace cppcanvas struct Parameters { /// Optionally forces the fill color attribute for all actions - ::boost::optional< IntSRGBA > maFillColor; + ::o3tl::optional< IntSRGBA > maFillColor; /// Optionally forces the line color attribute for all actions - ::boost::optional< IntSRGBA > maLineColor; + ::o3tl::optional< IntSRGBA > maLineColor; /// Optionally forces the text color attribute for all actions - ::boost::optional< IntSRGBA > maTextColor; + ::o3tl::optional< IntSRGBA > maTextColor; /// Optionally forces the given fontname for all text actions - ::boost::optional< OUString > maFontName; + ::o3tl::optional< OUString > maFontName; /** Optionally transforms all text output actions with the given matrix (in addition to the overall canvas @@ -119,16 +119,16 @@ namespace cppcanvas rect coordinate system, i.e. the metafile is assumed to be contained in the unit rect. */ - ::boost::optional< ::basegfx::B2DHomMatrix > maTextTransformation; + ::o3tl::optional< ::basegfx::B2DHomMatrix > maTextTransformation; /// Optionally forces the given font weight for all text actions - ::boost::optional< sal_Int8 > maFontWeight; + ::o3tl::optional< sal_Int8 > maFontWeight; /// Optionally forces the given font letter form (italics etc.) for all text actions - ::boost::optional< sal_Int8 > maFontLetterForm; + ::o3tl::optional< sal_Int8 > maFontLetterForm; /// Optionally forces underlining for all text actions - ::boost::optional< bool > maFontUnderline; + ::o3tl::optional< bool > maFontUnderline; }; }; diff --git a/include/dbaccess/genericcontroller.hxx b/include/dbaccess/genericcontroller.hxx index 0d4d460ad886..a63144ef76ab 100644 --- a/include/dbaccess/genericcontroller.hxx +++ b/include/dbaccess/genericcontroller.hxx @@ -27,7 +27,7 @@ #include <memory> #include <vector> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <com/sun/star/awt/XUserInputInterception.hpp> #include <com/sun/star/frame/CommandGroup.hpp> @@ -94,7 +94,7 @@ namespace dbaui class ODataView; template< typename T > - inline bool SAL_CALL operator >>= (const css::uno::Any& _any, boost::optional< T >& _value) + inline bool SAL_CALL operator >>= (const css::uno::Any& _any, o3tl::optional< T >& _value) { _value.reset(); // de-init the optional value @@ -118,10 +118,10 @@ namespace dbaui { bool bEnabled; - boost::optional<bool> bChecked; - boost::optional<bool> bInvisible; + o3tl::optional<bool> bChecked; + o3tl::optional<bool> bInvisible; css::uno::Any aValue; - boost::optional<OUString> sTitle; + o3tl::optional<OUString> sTitle; FeatureState() : bEnabled(false) { } }; diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index 12b4b0b28398..01dcffe10022 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -23,7 +23,7 @@ #include <memory> #include <vector> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/i18n/WordType.hpp> @@ -506,7 +506,7 @@ public: virtual OUString GetUndoComment( sal_uInt16 nUndoId ) const; virtual bool SpellNextDocument(); virtual void FieldClicked( const SvxFieldItem& rField ); - virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor ); + virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& rFldColor ); // override this if access to bullet information needs to be provided virtual const SvxNumberFormat * GetNumberFormat( sal_Int32 nPara ) const; diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index 70c08e5e45ee..2f6cc2d9abf3 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -40,7 +40,7 @@ #include <editeng/paragraphdata.hxx> #include <o3tl/typed_flags_set.hxx> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <functional> #include <memory> #include <vector> @@ -484,8 +484,8 @@ private: Outliner* pOutliner; const SvxFieldItem& rFldItem; - boost::optional<Color> mxTxtColor; - boost::optional<Color> mxFldColor; + o3tl::optional<Color> mxTxtColor; + o3tl::optional<Color> mxFldColor; OUString aRepresentation; @@ -509,11 +509,11 @@ public: const SvxFieldItem& GetField() const { return rFldItem; } - boost::optional<Color> const & GetTextColor() const { return mxTxtColor; } - void SetTextColor( boost::optional<Color> xCol ) { mxTxtColor = xCol; } + o3tl::optional<Color> const & GetTextColor() const { return mxTxtColor; } + void SetTextColor( o3tl::optional<Color> xCol ) { mxTxtColor = xCol; } - boost::optional<Color> const & GetFieldColor() const { return mxFldColor; } - void SetFieldColor( boost::optional<Color> xCol ) { mxFldColor = xCol; } + o3tl::optional<Color> const & GetFieldColor() const { return mxFldColor; } + void SetFieldColor( o3tl::optional<Color> xCol ) { mxFldColor = xCol; } sal_Int32 GetPara() const { return nPara; } sal_Int32 GetPos() const { return nPos; } @@ -880,7 +880,7 @@ public: bool UpdateFields(); void RemoveFields( const std::function<bool ( const SvxFieldData* )>& isFieldData = [] (const SvxFieldData* ){return true;} ); - virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor ); + virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& rFldColor ); void SetSpeller( css::uno::Reference< css::linguistic2::XSpellChecker1 > const &xSpeller ); css::uno::Reference< css::linguistic2::XSpellChecker1 > const & diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx index 46c3df27f18f..cde80d6aca83 100644 --- a/include/editeng/svxacorr.hxx +++ b/include/editeng/svxacorr.hxx @@ -28,7 +28,7 @@ #include <editeng/swafopt.hxx> #include <editeng/editengdllapi.h> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <map> #include <memory> @@ -155,7 +155,7 @@ public: ~SvxAutocorrWordList(); void DeleteAndDestroyAll(); const SvxAutocorrWord* Insert(SvxAutocorrWord aWord) const; - boost::optional<SvxAutocorrWord> FindAndRemove(const SvxAutocorrWord *pWord); + o3tl::optional<SvxAutocorrWord> FindAndRemove(const SvxAutocorrWord *pWord); void LoadEntry(const OUString& sWrong, const OUString& sRight, bool bOnlyTxt); bool empty() const; diff --git a/include/editeng/unoedprx.hxx b/include/editeng/unoedprx.hxx index 132cbbf96c66..a3aa0b915cc3 100644 --- a/include/editeng/unoedprx.hxx +++ b/include/editeng/unoedprx.hxx @@ -54,7 +54,7 @@ public: virtual SfxItemPool* GetPool() const override; - virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override; + virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor ) override; virtual void FieldClicked( const SvxFieldItem& rField ) override; virtual bool IsValid() const override; diff --git a/include/editeng/unoedsrc.hxx b/include/editeng/unoedsrc.hxx index e9f3ee0dd093..ab8a567d78d2 100644 --- a/include/editeng/unoedsrc.hxx +++ b/include/editeng/unoedsrc.hxx @@ -159,7 +159,7 @@ public: virtual void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ) = 0; virtual void QuickInsertLineBreak( const ESelection& rSel ) = 0; - virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) = 0; + virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor ) = 0; virtual void FieldClicked( const SvxFieldItem& rField ) = 0; virtual SfxItemPool* GetPool() const = 0; diff --git a/include/editeng/unofored.hxx b/include/editeng/unofored.hxx index 8222a3043bdb..a0cf70caf5f8 100644 --- a/include/editeng/unofored.hxx +++ b/include/editeng/unofored.hxx @@ -54,7 +54,7 @@ public: virtual SfxItemPool* GetPool() const override; - virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override; + virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor ) override; virtual void FieldClicked( const SvxFieldItem& rField ) override; virtual bool IsValid() const override; diff --git a/include/editeng/unoforou.hxx b/include/editeng/unoforou.hxx index f2d28a53e405..17029f9ca85c 100644 --- a/include/editeng/unoforou.hxx +++ b/include/editeng/unoforou.hxx @@ -72,7 +72,7 @@ public: virtual SfxItemPool* GetPool() const override; - virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override; + virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor ) override; virtual void FieldClicked( const SvxFieldItem& rField ) override; virtual bool IsValid() const override; diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx index 203bf309809d..4fae9a92dfe3 100644 --- a/include/editeng/unotext.hxx +++ b/include/editeng/unotext.hxx @@ -189,7 +189,7 @@ public: virtual void QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ) override; virtual void QuickInsertLineBreak( const ESelection& rSel ) override; - virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override; + virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor ) override; virtual void FieldClicked( const SvxFieldItem& rField ) override; virtual bool IsValid() const override; diff --git a/include/filter/msfilter/msdffimp.hxx b/include/filter/msfilter/msdffimp.hxx index 341dc2b5329e..efb71e6737ee 100644 --- a/include/filter/msfilter/msdffimp.hxx +++ b/include/filter/msfilter/msdffimp.hxx @@ -28,7 +28,7 @@ #include <vector> #include <unordered_map> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Reference.hxx> #include <comphelper/stl_types.hxx> @@ -226,9 +226,9 @@ struct MSFILTER_DLLPUBLIC SvxMSDffImportRec pClientDataBuffer; sal_uInt32 nClientDataLen; sal_uInt32 nXAlign; - boost::optional<sal_uInt32> nXRelTo; + o3tl::optional<sal_uInt32> nXRelTo; sal_uInt32 nYAlign; - boost::optional<sal_uInt32> nYRelTo; + o3tl::optional<sal_uInt32> nYRelTo; sal_uInt32 nLayoutInTableCell; ShapeFlag nFlags; sal_Int32 nDxTextLeft; ///< distance of text box from surrounding shape diff --git a/include/filter/msfilter/svdfppt.hxx b/include/filter/msfilter/svdfppt.hxx index 51bdd1917e35..ec50015bb191 100644 --- a/include/filter/msfilter/svdfppt.hxx +++ b/include/filter/msfilter/svdfppt.hxx @@ -25,7 +25,7 @@ #include <memory> #include <vector> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <com/sun/star/uno/Reference.hxx> #include <editeng/eeitem.hxx> @@ -491,7 +491,7 @@ struct MSFILTER_DLLPUBLIC PPTFieldEntry sal_uInt16 nTextRangeEnd; std::unique_ptr<SvxFieldItem> xField1; std::unique_ptr<SvxFieldItem> xField2; - boost::optional<OUString> xString; + o3tl::optional<OUString> xString; PPTFieldEntry() : nPos(0) @@ -813,7 +813,7 @@ class PPTNumberFormatCreator sal_uInt32 nLevel, TSS_Type nInstance, TSS_Type nInstanceInSheet, - boost::optional< sal_Int16 >& rStartNumbering, + o3tl::optional< sal_Int16 >& rStartNumbering, sal_uInt32 nFontHeight, PPTParagraphObj const * pPara ); @@ -841,7 +841,7 @@ public: SvxNumberFormat& rNumberFormat, PPTParagraphObj* pPara, TSS_Type nInstanceInSheet, - boost::optional< sal_Int16 >& rStartNumbering + o3tl::optional< sal_Int16 >& rStartNumbering ); }; @@ -1177,7 +1177,7 @@ public: void AppendPortion( PPTPortionObj& rPortion ); void ApplyTo( SfxItemSet& rSet, - boost::optional< sal_Int16 >& rStartNumbering, + o3tl::optional< sal_Int16 >& rStartNumbering, SdrPowerPointImport const & rManager, TSS_Type nInstanceInSheet ); diff --git a/include/o3tl/any.hxx b/include/o3tl/any.hxx index 141d788e15c4..b4d9e5272fc5 100644 --- a/include/o3tl/any.hxx +++ b/include/o3tl/any.hxx @@ -16,7 +16,7 @@ #include <type_traits> #include <utility> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/RuntimeException.hpp> @@ -36,37 +36,37 @@ namespace detail { struct Void {}; template<typename T> struct Optional { using type = T const *; }; -template<> struct Optional<void> { using type = boost::optional<Void const>; }; -template<> struct Optional<bool> { using type = boost::optional<bool const>; }; +template<> struct Optional<void> { using type = o3tl::optional<Void const>; }; +template<> struct Optional<bool> { using type = o3tl::optional<bool const>; }; template<> struct Optional<sal_Int8> { - using type = boost::optional<sal_Int8 const>; + using type = o3tl::optional<sal_Int8 const>; }; template<> struct Optional<sal_Int16> { - using type = boost::optional<sal_Int16 const>; + using type = o3tl::optional<sal_Int16 const>; }; template<> struct Optional<sal_uInt16> { - using type = boost::optional<sal_uInt16 const>; + using type = o3tl::optional<sal_uInt16 const>; }; template<> struct Optional<sal_Int32> { - using type = boost::optional<sal_Int32 const>; + using type = o3tl::optional<sal_Int32 const>; }; template<> struct Optional<sal_uInt32> { - using type = boost::optional<sal_uInt32 const>; + using type = o3tl::optional<sal_uInt32 const>; }; template<> struct Optional<sal_Int64> { - using type = boost::optional<sal_Int64 const>; + using type = o3tl::optional<sal_Int64 const>; }; template<> struct Optional<sal_uInt64> { - using type = boost::optional<sal_uInt64 const>; + using type = o3tl::optional<sal_uInt64 const>; }; template<> struct Optional<float> { - using type = boost::optional<float const>; + using type = o3tl::optional<float const>; }; template<> struct Optional<double> { - using type = boost::optional<double const>; + using type = o3tl::optional<double const>; }; template<typename T> struct Optional<css::uno::Reference<T>> { - using type = boost::optional<css::uno::Reference<T> const>; + using type = o3tl::optional<css::uno::Reference<T> const>; }; template<> struct Optional<css::uno::Reference<css::uno::XInterface>> { using type = css::uno::Reference<css::uno::XInterface> const *; @@ -85,12 +85,12 @@ template<typename T> struct IsUnoSequenceType<cppu::UnoSequenceType<T>>: std::true_type {}; -template<typename T> inline boost::optional<T const> tryGetConverted( +template<typename T> inline o3tl::optional<T const> tryGetConverted( css::uno::Any const & any) { T v; return (any >>= v) - ? boost::optional<T const>(std::move(v)) : boost::optional<T const>(); + ? o3tl::optional<T const>(std::move(v)) : o3tl::optional<T const>(); } } @@ -105,7 +105,7 @@ template<typename T> inline boost::optional<T const> tryGetConverted( proxy is positive. For a positive proxy P representing a value of requested type T, for any T other than void, the expression *P yields that value of type T. (Technically, the proxy is either a plain pointer or a - boost::optional, depending on whether a plain pointer into the given Any can + o3tl::optional, depending on whether a plain pointer into the given Any can be returned for the specified type.) @attention A proxy returned from this function must not outlive the @@ -124,7 +124,7 @@ template<typename T> inline boost::optional<T const> tryGetConverted( @note Ideally this would be a public member function of css::uno::Any (at least conditional on LIBO_INTERNAL_ONLY, as it requires C++11). However, as std::optional (which would be needed to implement the proxies) is only - available since C++14, we need to use boost::optional for now. But To not + available since C++14, we need to use o3tl::optional for now. But To not make every entity that includes <com/sun/star/uno/Any.hxx> depend on boost_headers, keep this here for now. @@ -156,8 +156,8 @@ template<> inline detail::Optional<void>::type tryAccess<void>( css::uno::Any const & any) { return any.hasValue() - ? boost::optional<detail::Void const>() - : boost::optional<detail::Void const>(detail::Void()); + ? o3tl::optional<detail::Void const>() + : o3tl::optional<detail::Void const>(detail::Void()); } template<> inline detail::Optional<bool>::type tryAccess<bool>( diff --git a/include/o3tl/optional.hxx b/include/o3tl/optional.hxx new file mode 100644 index 000000000000..6da85698c2d8 --- /dev/null +++ b/include/o3tl/optional.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +// A wrapper selecting either std::optional or boost::optional as a fallback for Xcode < 10. To be +// removed once std::optional is available everywhere. + +#ifndef INCLUDED_O3TL_OPTIONAL_HXX +#define INCLUDED_O3TL_OPTIONAL_HXX + +#include <sal/config.h> + +#if defined __APPLE__ && !__has_include(<optional>) + +#include <boost/none.hpp> +#include <boost/optional.hpp> + +namespace o3tl +{ +using boost::make_optional; +using boost::optional; + +inline constexpr auto nullopt = boost::none; +} + +#else + +#include <optional> + +namespace o3tl +{ +using std::make_optional; +using std::nullopt; +using std::optional; +} + +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/oox/helper/helper.hxx b/include/oox/helper/helper.hxx index d2077aaaa319..5a83c3780bc8 100644 --- a/include/oox/helper/helper.hxx +++ b/include/oox/helper/helper.hxx @@ -154,7 +154,7 @@ inline void setFlag( Type& ornBitField, Type nMask, bool bSet = true ) } -/** Optional value, similar to ::boost::optional<>, with convenience accessors. +/** Optional value, similar to ::o3tl::optional<>, with convenience accessors. */ template< typename Type > class OptValue diff --git a/include/sax/tools/converter.hxx b/include/sax/tools/converter.hxx index 967c395433ff..42b769706da0 100644 --- a/include/sax/tools/converter.hxx +++ b/include/sax/tools/converter.hxx @@ -22,7 +22,7 @@ #include <sal/config.h> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <sax/saxdllapi.h> @@ -196,7 +196,7 @@ public: css::util::Date * pDate, css::util::DateTime & rDateTime, bool & rbDateTime, - boost::optional<sal_Int16> * pTimeZoneOffset, + o3tl::optional<sal_Int16> * pTimeZoneOffset, const OUString & rString ); /** gets the position of the first comma after npos in the string diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx index 08be8bb5ea19..b02a3138b6c8 100644 --- a/include/sfx2/dinfdlg.hxx +++ b/include/sfx2/dinfdlg.hxx @@ -36,7 +36,7 @@ #include <sfx2/tabdlg.hxx> -#include <boost/optional/optional.hpp> +#include <o3tl/optional.hxx> #include <memory> namespace com::sun::star::beans { struct PropertyValue; } @@ -249,7 +249,7 @@ class CustomPropertiesDateField private: std::unique_ptr<SvtCalendarBox> m_xDateField; public: - ::boost::optional<sal_Int16> m_TZ; + ::o3tl::optional<sal_Int16> m_TZ; CustomPropertiesDateField(SvtCalendarBox* pDateField); void set_visible(bool bVisible) { m_xDateField->set_visible(bVisible); } diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx index 596382a36888..e65bceb78b6f 100644 --- a/include/sfx2/sidebar/SidebarController.hxx +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -36,7 +36,7 @@ #include <com/sun/star/ui/XContextChangeEventListener.hpp> #include <com/sun/star/ui/XSidebar.hpp> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/basemutex.hxx> @@ -196,8 +196,8 @@ private: mbIsDeckRequestedOpen. Normally both flags have the same value. A document being read-only can prevent the deck from opening. */ - ::boost::optional<bool> mbIsDeckRequestedOpen; - ::boost::optional<bool> mbIsDeckOpen; + ::o3tl::optional<bool> mbIsDeckRequestedOpen; + ::o3tl::optional<bool> mbIsDeckOpen; bool mbFloatingDeckClosed; diff --git a/include/svtools/table/tablemodel.hxx b/include/svtools/table/tablemodel.hxx index 088b9a81783a..8fadf6f10c54 100644 --- a/include/svtools/table/tablemodel.hxx +++ b/include/svtools/table/tablemodel.hxx @@ -30,7 +30,7 @@ #include <sal/types.h> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <memory> #include <vector> #include <o3tl/typed_flags_set.hxx> @@ -365,55 +365,55 @@ namespace svt { namespace table If this value is not set, a default color from the style settings will be used. */ - virtual ::boost::optional< ::Color > getLineColor() const = 0; + virtual ::o3tl::optional< ::Color > getLineColor() const = 0; /** returns the color to be used for rendering the header background. If this value is not set, a default color from the style settings will be used. */ - virtual ::boost::optional< ::Color > getHeaderBackgroundColor() const = 0; + virtual ::o3tl::optional< ::Color > getHeaderBackgroundColor() const = 0; /** returns the color to be used for rendering the header text. If this value is not set, a default color from the style settings will be used. */ - virtual ::boost::optional< ::Color > getHeaderTextColor() const = 0; + virtual ::o3tl::optional< ::Color > getHeaderTextColor() const = 0; /** returns the color to be used for the background of selected cells, when the control has the focus If this value is not set, a default color from the style settings will be used. */ - virtual ::boost::optional< ::Color > getActiveSelectionBackColor() const = 0; + virtual ::o3tl::optional< ::Color > getActiveSelectionBackColor() const = 0; /** returns the color to be used for the background of selected cells, when the control does not have the focus If this value is not set, a default color from the style settings will be used. */ - virtual ::boost::optional< ::Color > getInactiveSelectionBackColor() const = 0; + virtual ::o3tl::optional< ::Color > getInactiveSelectionBackColor() const = 0; /** returns the color to be used for the text of selected cells, when the control has the focus If this value is not set, a default color from the style settings will be used. */ - virtual ::boost::optional< ::Color > getActiveSelectionTextColor() const = 0; + virtual ::o3tl::optional< ::Color > getActiveSelectionTextColor() const = 0; /** returns the color to be used for the text of selected cells, when the control does not have the focus If this value is not set, a default color from the style settings will be used. */ - virtual ::boost::optional< ::Color > getInactiveSelectionTextColor() const = 0; + virtual ::o3tl::optional< ::Color > getInactiveSelectionTextColor() const = 0; /** returns the color to be used for rendering cell texts. If this value is not set, a default color from the style settings will be used. */ - virtual ::boost::optional< ::Color > getTextColor() const = 0; + virtual ::o3tl::optional< ::Color > getTextColor() const = 0; /** returns the color to be used for text lines (underline, strikethrough) when rendering cell text. If this value is not set, a default color from the style settings will be used. */ - virtual ::boost::optional< ::Color > getTextLineColor() const = 0; + virtual ::o3tl::optional< ::Color > getTextLineColor() const = 0; /** returns the colors to be used for the row backgrounds. @@ -426,7 +426,7 @@ namespace svt { namespace table If value is a non-empty sequence, then rows will have the background colors as specified in the sequence, in alternating order. */ - virtual ::boost::optional< ::std::vector< ::Color > > + virtual ::o3tl::optional< ::std::vector< ::Color > > getRowBackgroundColors() const = 0; /** determines the vertical alignment of content within a cell diff --git a/include/svx/ClassificationEditView.hxx b/include/svx/ClassificationEditView.hxx index fbea139b9792..8c30518b1816 100644 --- a/include/svx/ClassificationEditView.hxx +++ b/include/svx/ClassificationEditView.hxx @@ -24,7 +24,7 @@ class ClassificationEditEngine final : public EditEngine public: ClassificationEditEngine(SfxItemPool* pItemPool); - virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor) override; + virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& rFldColor) override; }; class ClassificationEditView final : public WeldEditView diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx index cce1df59819a..bb182c6e2f67 100644 --- a/include/svx/svdomeas.hxx +++ b/include/svx/svdomeas.hxx @@ -140,7 +140,7 @@ public: virtual OutlinerParaObject* GetOutlinerParaObject() const override; virtual bool CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, - bool bEdit, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor, OUString& rRet) const override; + bool bEdit, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor, OUString& rRet) const override; // #i97878# virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const override; diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index d49f1221dc98..ccb6686e883d 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -497,7 +497,7 @@ public: virtual void NbcReformatText() override; virtual bool CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, - bool bEdit, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor, OUString& rRet) const; + bool bEdit, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor, OUString& rRet) const; virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override; diff --git a/include/svx/svdoutl.hxx b/include/svx/svdoutl.hxx index 7655dee739b7..eb1b51523f53 100644 --- a/include/svx/svdoutl.hxx +++ b/include/svx/svdoutl.hxx @@ -43,7 +43,7 @@ public: void setVisualizedPage(const SdrPage* pPage) { if(pPage != mpVisualizedPage) mpVisualizedPage = pPage; } const SdrPage* getVisualizedPage() const { return mpVisualizedPage; } - virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor) override; + virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor) override; bool hasEditViewCallbacks() const; }; diff --git a/include/toolkit/controls/unocontrols.hxx b/include/toolkit/controls/unocontrols.hxx index 5ea17a412915..6bc0fafb570a 100644 --- a/include/toolkit/controls/unocontrols.hxx +++ b/include/toolkit/controls/unocontrols.hxx @@ -54,7 +54,7 @@ #include <memory> #include <vector> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> namespace com { namespace sun { namespace star { namespace graphic { class XGraphic; } } } } namespace com { namespace sun { namespace star { namespace graphic { class XGraphicObject; } } } } @@ -804,15 +804,15 @@ protected: private: void impl_notifyItemListEvent_nolck( const sal_Int32 i_nItemPosition, - const ::boost::optional< OUString >& i_rItemText, - const ::boost::optional< OUString >& i_rItemImageURL, + const ::o3tl::optional< OUString >& i_rItemText, + const ::o3tl::optional< OUString >& i_rItemImageURL, void ( SAL_CALL css::awt::XItemListListener::*NotificationMethod )( const css::awt::ItemListEvent& ) ); void impl_handleInsert( const sal_Int32 i_nItemPosition, - const ::boost::optional< OUString >& i_rItemText, - const ::boost::optional< OUString >& i_rItemImageURL, + const ::o3tl::optional< OUString >& i_rItemText, + const ::o3tl::optional< OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify ); @@ -823,8 +823,8 @@ private: void impl_handleModify( const sal_Int32 i_nItemPosition, - const ::boost::optional< OUString >& i_rItemText, - const ::boost::optional< OUString >& i_rItemImageURL, + const ::o3tl::optional< OUString >& i_rItemText, + const ::o3tl::optional< OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify ); diff --git a/include/unotools/historyoptions.hxx b/include/unotools/historyoptions.hxx index 87ce484533c3..b723dc9326b7 100644 --- a/include/unotools/historyoptions.hxx +++ b/include/unotools/historyoptions.hxx @@ -27,7 +27,7 @@ #include <unotools/options.hxx> #include <memory> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> namespace com { namespace sun { namespace star { namespace beans { struct PropertyValue; } } } } @@ -86,7 +86,7 @@ public: */ void AppendItem(EHistoryType eHistory, const OUString& sURL, const OUString& sFilter, const OUString& sTitle, - const boost::optional<OUString>& sThumbnail); + const o3tl::optional<OUString>& sThumbnail); /** Delete item from the specified list. */ diff --git a/include/vcl/fontcapabilities.hxx b/include/vcl/fontcapabilities.hxx index 51aa13e58ade..539dd2710d0c 100644 --- a/include/vcl/fontcapabilities.hxx +++ b/include/vcl/fontcapabilities.hxx @@ -10,7 +10,7 @@ #ifndef INCLUDED_VCL_FONTCAPABILITIES_HXX #define INCLUDED_VCL_FONTCAPABILITIES_HXX -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <bitset> //See OS/2 table, i.e. http://www.microsoft.com/typography/otspec/os2.htm#ur @@ -193,8 +193,8 @@ namespace vcl struct FontCapabilities { - boost::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> oUnicodeRange; - boost::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> oCodePageRange; + o3tl::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> oUnicodeRange; + o3tl::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> oCodePageRange; }; } diff --git a/include/vcl/outdevstate.hxx b/include/vcl/outdevstate.hxx index 493855248db0..5f0b12d41d86 100644 --- a/include/vcl/outdevstate.hxx +++ b/include/vcl/outdevstate.hxx @@ -28,7 +28,7 @@ #include <tools/fontenum.hxx> #include <o3tl/typed_flags_set.hxx> #include <memory> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <i18nlangtag/lang.h> namespace vcl { class Font; } @@ -81,17 +81,17 @@ struct OutDevState OutDevState(OutDevState&&); ~OutDevState(); - boost::optional<MapMode> mpMapMode; + o3tl::optional<MapMode> mpMapMode; bool mbMapActive; std::unique_ptr<vcl::Region> mpClipRegion; - boost::optional<Color> mpLineColor; - boost::optional<Color> mpFillColor; + o3tl::optional<Color> mpLineColor; + o3tl::optional<Color> mpFillColor; std::unique_ptr<vcl::Font> mpFont; - boost::optional<Color> mpTextColor; - boost::optional<Color> mpTextFillColor; - boost::optional<Color> mpTextLineColor; - boost::optional<Color> mpOverlineColor; - boost::optional<Point> mpRefPoint; + o3tl::optional<Color> mpTextColor; + o3tl::optional<Color> mpTextFillColor; + o3tl::optional<Color> mpTextLineColor; + o3tl::optional<Color> mpOverlineColor; + o3tl::optional<Point> mpRefPoint; TextAlign meTextAlign; RasterOp meRasterOp; ComplexTextLayoutFlags mnTextLayoutMode; diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx index 1f879b188c18..a45e0e685633 100644 --- a/include/vcl/settings.hxx +++ b/include/vcl/settings.hxx @@ -29,7 +29,7 @@ #include <memory> #include <vector> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> class BitmapEx; class LanguageTag; @@ -549,7 +549,7 @@ public: BitmapEx const & GetPersonaFooter() const; - const boost::optional<Color>& GetPersonaMenuBarTextColor() const; + const o3tl::optional<Color>& GetPersonaMenuBarTextColor() const; // global switch to allow EdgeBlenging; currently possible for ValueSet and ListBox // when activated there using Get/SetEdgeBlending; default is true diff --git a/include/vcl/threadex.hxx b/include/vcl/threadex.hxx index 05d0bada3f58..ceb3354556a8 100644 --- a/include/vcl/threadex.hxx +++ b/include/vcl/threadex.hxx @@ -24,7 +24,7 @@ #include <tools/link.hxx> #include <vcl/dllapi.h> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <memory> namespace vcl @@ -84,9 +84,9 @@ private: #else FuncT const m_func; #endif - // using boost::optional here omits the need that ResultT is default + // using o3tl::optional here omits the need that ResultT is default // constructable: - ::boost::optional<ResultT> m_result; + ::o3tl::optional<ResultT> m_result; }; template <typename FuncT> diff --git a/include/vcl/treelistentry.hxx b/include/vcl/treelistentry.hxx index 71c8e8229f11..deb733b7bf9a 100644 --- a/include/vcl/treelistentry.hxx +++ b/include/vcl/treelistentry.hxx @@ -27,7 +27,7 @@ #include <vcl/treelistentries.hxx> #include <o3tl/typed_flags_set.hxx> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <vector> #include <memory> @@ -64,7 +64,7 @@ class VCL_DLLPUBLIC SvTreeListEntry void* pUserData; SvTLEntryFlags nEntryFlags; Color maBackColor; - boost::optional<Color> mxTextColor; + o3tl::optional<Color> mxTextColor; private: void ClearChildren(); @@ -112,8 +112,8 @@ public: void SetBackColor( const Color& rColor ) { maBackColor = rColor; } const Color& GetBackColor() const { return maBackColor; } - void SetTextColor( boost::optional<Color> xColor ) { mxTextColor = xColor; } - boost::optional<Color> const & GetTextColor() const { return mxTextColor; } + void SetTextColor( o3tl::optional<Color> xColor ) { mxTextColor = xColor; } + o3tl::optional<Color> const & GetTextColor() const { return mxTextColor; } SvTreeListEntry* GetParent() const { return pParent; } |