From 7e403195e574be5174815a51cf5c42f06f76a87a Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Sat, 30 Nov 2019 17:48:32 +0100 Subject: 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 , 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|\|o3tl/optional.hxx|g' -e 's/\/o3tl\1::\2\3optional/g' -e 's/\/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 --- editeng/inc/editattr.hxx | 10 +++++----- editeng/inc/pch/precompiled_editeng.hxx | 2 +- editeng/qa/unit/core-test.cxx | 2 +- editeng/source/editeng/editeng.cxx | 2 +- editeng/source/editeng/impedit.hxx | 4 ++-- editeng/source/misc/svxacorr.cxx | 10 +++++----- editeng/source/outliner/outleeng.cxx | 2 +- editeng/source/outliner/outleeng.hxx | 2 +- editeng/source/outliner/outliner.cxx | 2 +- editeng/source/uno/unoedprx.cxx | 2 +- editeng/source/uno/unofored.cxx | 2 +- editeng/source/uno/unoforou.cxx | 2 +- editeng/source/uno/unotext.cxx | 6 +++--- 13 files changed, 24 insertions(+), 24 deletions(-) (limited to 'editeng') diff --git a/editeng/inc/editattr.hxx b/editeng/inc/editattr.hxx index 2b74427f6619..99faa6ecaf9d 100644 --- a/editeng/inc/editattr.hxx +++ b/editeng/inc/editattr.hxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -364,8 +364,8 @@ public: class EditCharAttribField: public EditCharAttrib { OUString aFieldValue; - boost::optional mxTxtColor; - boost::optional mxFldColor; + o3tl::optional mxTxtColor; + o3tl::optional mxFldColor; EditCharAttribField& operator = ( const EditCharAttribField& rAttr ) = delete; @@ -379,8 +379,8 @@ public: { return !(operator == ( rAttr ) ); } virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; - boost::optional& GetTextColor() { return mxTxtColor; } - boost::optional& GetFieldColor() { return mxFldColor; } + o3tl::optional& GetTextColor() { return mxTxtColor; } + o3tl::optional& GetFieldColor() { return mxFldColor; } const OUString& GetFieldValue() const { return aFieldValue;} void SetFieldValue(const OUString& rVal); diff --git a/editeng/inc/pch/precompiled_editeng.hxx b/editeng/inc/pch/precompiled_editeng.hxx index fb6950330079..391feb2b9a66 100644 --- a/editeng/inc/pch/precompiled_editeng.hxx +++ b/editeng/inc/pch/precompiled_editeng.hxx @@ -49,7 +49,7 @@ #include #include #include -#include +#include #endif // PCH_LEVEL >= 1 #if PCH_LEVEL >= 2 #include diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index e832dffd39d6..d5fb5482f111 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -813,7 +813,7 @@ class UrlEditEngine : public EditEngine public: explicit UrlEditEngine(SfxItemPool *pPool) : EditEngine(pPool) {} - virtual OUString CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, boost::optional&, boost::optional& ) override + virtual OUString CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, o3tl::optional&, o3tl::optional& ) override { return "jim@bob.com"; // a sophisticated view of value: } diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index e7faf821f0ee..2cf4d88a9e6d 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -2577,7 +2577,7 @@ tools::Rectangle EditEngine::GetBulletArea( sal_Int32 ) return tools::Rectangle( Point(), Point() ); } -OUString EditEngine::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, boost::optional&, boost::optional& ) +OUString EditEngine::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, o3tl::optional&, o3tl::optional& ) { return OUString(' '); } diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 5d3db66f5e18..ee0fe7948034 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -61,7 +61,7 @@ #include #include -#include +#include #include #include @@ -238,7 +238,7 @@ private: EditEngine* pEditEngine; VclPtr pOutWin; EditView::OutWindowSet aOutWindowSet; - boost::optional mxPointer; + o3tl::optional mxPointer; std::unique_ptr pDragAndDropInfo; css::uno::Reference< css::datatransfer::dnd::XDragSourceListener > mxDnDListener; diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 7e4273203183..cad718e86f6a 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -2514,7 +2514,7 @@ bool SvxAutoCorrectLanguageLists::MakeCombinedChanges( std::vector xFoundEntry = pAutocorr_List->FindAndRemove( &aWordToDelete ); + o3tl::optional xFoundEntry = pAutocorr_List->FindAndRemove( &aWordToDelete ); if( xFoundEntry ) { if( !xFoundEntry->IsTextOnly() ) @@ -2537,7 +2537,7 @@ bool SvxAutoCorrectLanguageLists::MakeCombinedChanges( std::vector xRemoved = pAutocorr_List->FindAndRemove( &aWordToAdd ); + o3tl::optional xRemoved = pAutocorr_List->FindAndRemove( &aWordToAdd ); if( xRemoved ) { if( !xRemoved->IsTextOnly() ) @@ -2583,7 +2583,7 @@ bool SvxAutoCorrectLanguageLists::PutText( const OUString& rShort, const OUStrin if( bRet ) { SvxAutocorrWord aNew(rShort, rLong, true ); - boost::optional xRemove = pAutocorr_List->FindAndRemove( &aNew ); + o3tl::optional xRemove = pAutocorr_List->FindAndRemove( &aNew ); if( xRemove ) { if( !xRemove->IsTextOnly() ) @@ -2719,7 +2719,7 @@ bool SvxAutocorrWordList::empty() const return mpImpl->maHash.empty() && mpImpl->maSortedVector.empty(); } -boost::optional SvxAutocorrWordList::FindAndRemove(const SvxAutocorrWord *pWord) +o3tl::optional SvxAutocorrWordList::FindAndRemove(const SvxAutocorrWord *pWord) { if ( mpImpl->maSortedVector.empty() ) // use the hash @@ -2742,7 +2742,7 @@ boost::optional SvxAutocorrWordList::FindAndRemove(const SvxAut return pMatch; } } - return boost::optional(); + return o3tl::optional(); } // return the sorted contents - defer sorting until we have to. diff --git a/editeng/source/outliner/outleeng.cxx b/editeng/source/outliner/outleeng.cxx index eb9881e89efd..fe122a91fb0a 100644 --- a/editeng/source/outliner/outleeng.cxx +++ b/editeng/source/outliner/outleeng.cxx @@ -169,7 +169,7 @@ void OutlinerEditEng::DrawingTab( const Point& rStartPos, long nWidth, const OUS bEndOfLine, bEndOfParagraph, rOverlineColor, rTextLineColor ); } -OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional& rpTxtColor, boost::optional& rpFldColor ) +OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional& rpTxtColor, o3tl::optional& rpFldColor ) { return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor ); } diff --git a/editeng/source/outliner/outleeng.hxx b/editeng/source/outliner/outleeng.hxx index 5110d8be28ef..46970c75d9db 100644 --- a/editeng/source/outliner/outleeng.hxx +++ b/editeng/source/outliner/outleeng.hxx @@ -71,7 +71,7 @@ public: // for text conversion virtual bool ConvertNextDocument() override; - virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional& rTxtColor, boost::optional& rFldColor ) override; + virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional& rTxtColor, o3tl::optional& rFldColor ) override; virtual tools::Rectangle GetBulletArea( sal_Int32 nPara ) override; diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 16a3833eeea2..71b3cf56ce1a 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -648,7 +648,7 @@ void Outliner::AddText( const OutlinerParaObject& rPObj, bool bAppend ) pEditEngine->SetUpdateMode( bUpdate ); } -OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional& rpTxtColor, boost::optional& rpFldColor ) +OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional& rpTxtColor, o3tl::optional& rpFldColor ) { if ( !aCalcFieldValueHdl.IsSet() ) return OUString( ' ' ); diff --git a/editeng/source/uno/unoedprx.cxx b/editeng/source/uno/unoedprx.cxx index c7ac1bc3786b..a56404cc0805 100644 --- a/editeng/source/uno/unoedprx.cxx +++ b/editeng/source/uno/unoedprx.cxx @@ -618,7 +618,7 @@ SfxItemPool* SvxAccessibleTextAdapter::GetPool() const return mpTextForwarder->GetPool(); } -OUString SvxAccessibleTextAdapter::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional& rpTxtColor, boost::optional& rpFldColor ) +OUString SvxAccessibleTextAdapter::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional& rpTxtColor, o3tl::optional& rpFldColor ) { assert(mpTextForwarder && "SvxAccessibleTextAdapter: no forwarder"); diff --git a/editeng/source/uno/unofored.cxx b/editeng/source/uno/unofored.cxx index 73a49039fa3d..fb1236632dde 100644 --- a/editeng/source/uno/unofored.cxx +++ b/editeng/source/uno/unofored.cxx @@ -153,7 +153,7 @@ bool SvxEditEngineForwarder::IsValid() const return rEditEngine.GetUpdateMode(); } -OUString SvxEditEngineForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional& rpTxtColor, boost::optional& rpFldColor ) +OUString SvxEditEngineForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional& rpTxtColor, o3tl::optional& rpFldColor ) { return rEditEngine.CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor ); } diff --git a/editeng/source/uno/unoforou.cxx b/editeng/source/uno/unoforou.cxx index b9abddf04455..9fb555470456 100644 --- a/editeng/source/uno/unoforou.cxx +++ b/editeng/source/uno/unoforou.cxx @@ -220,7 +220,7 @@ void SvxOutlinerForwarder::QuickSetAttribs( const SfxItemSet& rSet, const ESelec rOutliner.QuickSetAttribs( rSet, rSel ); } -OUString SvxOutlinerForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional& rpTxtColor, boost::optional& rpFldColor ) +OUString SvxOutlinerForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional& rpTxtColor, o3tl::optional& rpFldColor ) { return rOutliner.CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor ); } diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index e0ffbfe82a20..25d2b70c3098 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -634,8 +634,8 @@ void SvxUnoTextRangeBase::getPropertyValue( const SfxItemPropertySimpleEntry* pM uno::Reference< text::XTextRange > xAnchor( this ); // get presentation string for field - boost::optional pTColor; - boost::optional pFColor; + o3tl::optional pTColor; + o3tl::optional pFColor; SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder(); OUString aPresentation( pForwarder->CalcFieldValue( SvxFieldItem(*pData, EE_FEATURE_FIELD), maSelection.nStartPara, maSelection.nStartPos, pTColor, pFColor ) ); @@ -2359,7 +2359,7 @@ void SvxDummyTextSource::QuickInsertLineBreak( const ESelection& ) { }; -OUString SvxDummyTextSource::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, boost::optional&, boost::optional& ) +OUString SvxDummyTextSource::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, o3tl::optional&, o3tl::optional& ) { return OUString(); } -- cgit