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 /sc/source/ui | |
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 'sc/source/ui')
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleDocument.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/dbgui/pvfundlg.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/RandomNumberGeneratorDialog.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/pagedlg/scuitphfedit.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/unoobj/dapiuno.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/unoobj/fielduno.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/dbfunc3.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/output.cxx | 14 |
10 files changed, 28 insertions, 28 deletions
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index 74d0b60ffe52..a9da52b3d073 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -93,13 +93,13 @@ struct ScAccessibleShapeData ScAccessibleShapeData(css::uno::Reference< css::drawing::XShape > xShape_); ~ScAccessibleShapeData(); mutable rtl::Reference< ::accessibility::AccessibleShape > pAccShape; - mutable boost::optional<ScAddress> xRelationCell; // if it is NULL this shape is anchored on the table + mutable o3tl::optional<ScAddress> xRelationCell; // if it is NULL this shape is anchored on the table css::uno::Reference< css::drawing::XShape > xShape; mutable bool bSelected; bool bSelectable; // cache these to make the sorting cheaper - boost::optional<sal_Int16> mxLayerID; - boost::optional<sal_Int32> mxZOrder; + o3tl::optional<sal_Int16> mxLayerID; + o3tl::optional<sal_Int32> mxZOrder; }; } @@ -271,7 +271,7 @@ private: void FillShapes(std::vector < uno::Reference < drawing::XShape > >& rShapes) const; bool FindSelectedShapesChanges(const css::uno::Reference<css::drawing::XShapes>& xShapes) const; - boost::optional<ScAddress> GetAnchor(const uno::Reference<drawing::XShape>& xShape) const; + o3tl::optional<ScAddress> GetAnchor(const uno::Reference<drawing::XShape>& xShape) const; uno::Reference<XAccessibleRelationSet> GetRelationSet(const ScAccessibleShapeData* pData) const; void SetAnchor(const uno::Reference<drawing::XShape>& xShape, ScAccessibleShapeData* pData) const; void AddShape(const uno::Reference<drawing::XShape>& xShape, bool bCommitChange) const; @@ -1119,7 +1119,7 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::X return bResult; } -boost::optional<ScAddress> ScChildrenShapes::GetAnchor(const uno::Reference<drawing::XShape>& xShape) const +o3tl::optional<ScAddress> ScChildrenShapes::GetAnchor(const uno::Reference<drawing::XShape>& xShape) const { if (mpViewShell) { @@ -1130,12 +1130,12 @@ boost::optional<ScAddress> ScChildrenShapes::GetAnchor(const uno::Reference<draw if (SdrObject *pSdrObj = pShapeImp->GetSdrObject()) { if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pSdrObj)) - return boost::optional<ScAddress>(pAnchor->maStart); + return o3tl::optional<ScAddress>(pAnchor->maStart); } } } - return boost::optional<ScAddress>(); + return o3tl::optional<ScAddress>(); } uno::Reference<XAccessibleRelationSet> ScChildrenShapes::GetRelationSet(const ScAccessibleShapeData* pData) const @@ -1171,7 +1171,7 @@ void ScChildrenShapes::SetAnchor(const uno::Reference<drawing::XShape>& xShape, { if (pData) { - boost::optional<ScAddress> xAddress = GetAnchor(xShape); + o3tl::optional<ScAddress> xAddress = GetAnchor(xShape); if ((xAddress && pData->xRelationCell && (*xAddress != *(pData->xRelationCell))) || (!xAddress && pData->xRelationCell) || (xAddress && !pData->xRelationCell)) { diff --git a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx index c4f358c5e7d0..4bb3f1fee9dd 100644 --- a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx @@ -175,7 +175,7 @@ void ScRandomNumberGeneratorDialog::SelectGeneratorAndGenerateNumbers() double parameter1 = parameterInteger1 / static_cast<double>(PRECISION); double parameter2 = parameterInteger2 / static_cast<double>(PRECISION); - boost::optional<sal_Int8> aDecimalPlaces; + o3tl::optional<sal_Int8> aDecimalPlaces; if (mxEnableRounding->get_active()) { aDecimalPlaces = static_cast<sal_Int8>(mxDecimalPlaces->get_value()); @@ -250,7 +250,7 @@ void ScRandomNumberGeneratorDialog::SelectGeneratorAndGenerateNumbers() } template<class RNG> -void ScRandomNumberGeneratorDialog::GenerateNumbers(RNG& randomGenerator, const char* pDistributionStringId, boost::optional<sal_Int8> aDecimalPlaces) +void ScRandomNumberGeneratorDialog::GenerateNumbers(RNG& randomGenerator, const char* pDistributionStringId, o3tl::optional<sal_Int8> aDecimalPlaces) { OUString aUndo = ScResId(STR_UNDO_DISTRIBUTION_TEMPLATE); OUString aDistributionName = ScResId(pDistributionStringId); diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx index f9df9a244eb7..3d03cf867b4e 100644 --- a/sc/source/ui/dbgui/pvfundlg.cxx +++ b/sc/source/ui/dbgui/pvfundlg.cxx @@ -868,7 +868,7 @@ ScDPShowDetailDlg::ScDPShowDetailDlg(weld::Window* pParent, ScDPObject& rDPObj, { if (pDimension) { - const boost::optional<OUString> & pLayoutName = pDimension->GetLayoutName(); + const o3tl::optional<OUString> & pLayoutName = pDimension->GetLayoutName(); if (pLayoutName) aName = *pLayoutName; } diff --git a/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx b/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx index f965ded0e605..ff2fbd1f6351 100644 --- a/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx +++ b/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx @@ -13,7 +13,7 @@ #include <sal/config.h> -#include <boost/optional.hpp> +#include <o3tl/optional.hxx> #include <address.hxx> #include "anyrefdg.hxx" @@ -63,7 +63,7 @@ private: template<class RNG> - void GenerateNumbers(RNG& randomGenerator, const char* pDistributionStringId, const boost::optional<sal_Int8> aDecimalPlaces); + void GenerateNumbers(RNG& randomGenerator, const char* pDistributionStringId, const o3tl::optional<sal_Int8> aDecimalPlaces); void SelectGeneratorAndGenerateNumbers(); diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index bd4ca07159c5..a03b40e6685d 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -104,7 +104,7 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHel std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOHeader; std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOShrink; - boost::optional<tools::Rectangle> mpAutoFillRect; + o3tl::optional<tools::Rectangle> mpAutoFillRect; /// LibreOfficeKit needs a persistent FmFormView for tiled rendering, /// otherwise the invalidations from drawinglayer do not work. diff --git a/sc/source/ui/pagedlg/scuitphfedit.cxx b/sc/source/ui/pagedlg/scuitphfedit.cxx index b12592bcf29c..239e7634f454 100644 --- a/sc/source/ui/pagedlg/scuitphfedit.cxx +++ b/sc/source/ui/pagedlg/scuitphfedit.cxx @@ -184,8 +184,8 @@ void ScHFEditPage::InitPreDefinedList() { SvtUserOptions aUserOpt; - boost::optional<Color> pTxtColour; - boost::optional<Color> pFldColour; + o3tl::optional<Color> pTxtColour; + o3tl::optional<Color> pFldColour; // Get the all field values at the outset. OUString aPageFieldValue(m_xWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour)); diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index 14698deec829..a0e0f3ea263f 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -873,7 +873,7 @@ Any SAL_CALL ScDataPilotDescriptorBase::getPropertyValue( const OUString& aPrope } else if ( aPropertyName == SC_UNO_DP_GRANDTOTAL_NAME ) { - const boost::optional<OUString> & pGrandTotalName = aNewData.GetGrandTotalName(); + const o3tl::optional<OUString> & pGrandTotalName = aNewData.GetGrandTotalName(); if (pGrandTotalName) aRet <<= *pGrandTotalName; // same behavior as in ScDPSource } @@ -1672,7 +1672,7 @@ OUString SAL_CALL ScDataPilotFieldObj::getName() aName = SC_DATALAYOUT_NAME; else { - const boost::optional<OUString> & pLayoutName = pDim->GetLayoutName(); + const o3tl::optional<OUString> & pLayoutName = pDim->GetLayoutName(); if (pLayoutName) aName = *pLayoutName; else diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx index 331b38de448a..6de682a5ce14 100644 --- a/sc/source/ui/unoobj/fielduno.cxx +++ b/sc/source/ui/unoobj/fielduno.cxx @@ -177,7 +177,7 @@ public: explicit ScUnoEditEngine(ScEditEngineDefaulter* pSource); virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, - boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor ) override; + o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& rFldColor ) override; sal_uInt16 CountFields(); SvxFieldData* FindByIndex(sal_uInt16 nIndex); @@ -203,7 +203,7 @@ ScUnoEditEngine::ScUnoEditEngine(ScEditEngineDefaulter* pSource) } OUString ScUnoEditEngine::CalcFieldValue( const SvxFieldItem& rField, - sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor ) + sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& rFldColor ) { OUString aRet(EditEngine::CalcFieldValue( rField, nPara, nPos, rTxtColor, rFldColor )); if (eMode != SC_UNO_COLLECT_NONE) diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index 07a61bf4fc64..0a76a774fa8e 100644 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -1541,7 +1541,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const OUString& rString ) if (pDim->GetSubTotalFunc(0) != ScGeneralFunction::AUTO) break; - const boost::optional<OUString> & pLayoutName = pMem->GetLayoutName(); + const o3tl::optional<OUString> & pLayoutName = pMem->GetLayoutName(); OUString aMemberName; if (pLayoutName) aMemberName = *pLayoutName; diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index e14647bd7954..9af78a03f5fa 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -774,8 +774,8 @@ static bool lcl_EqualBack( const RowInfo& rFirst, const RowInfo& rOther, for ( nX=nX1; nX<=nX2; nX++ ) { - boost::optional<Color> const & pCol1 = rFirst.pCellInfo[nX+1].mxColorScale; - boost::optional<Color> const & pCol2 = rOther.pCellInfo[nX+1].mxColorScale; + o3tl::optional<Color> const & pCol1 = rFirst.pCellInfo[nX+1].mxColorScale; + o3tl::optional<Color> const & pCol2 = rOther.pCellInfo[nX+1].mxColorScale; if( (pCol1 && !pCol2) || (!pCol1 && pCol2) ) return false; @@ -909,7 +909,7 @@ void drawIconSets(vcl::RenderContext& rRenderContext, const ScIconSetInfo* pOldI rRenderContext.DrawBitmapEx( Point( rRect.Left() + 2 * nOneX, rRect.Top() + 2 * nOneY), Size(aOrigSize, aOrigSize), rIcon ); } -void drawCells(vcl::RenderContext& rRenderContext, boost::optional<Color> const & pColor, const SvxBrushItem* pBackground, boost::optional<Color>& pOldColor, const SvxBrushItem*& pOldBackground, +void drawCells(vcl::RenderContext& rRenderContext, o3tl::optional<Color> const & pColor, const SvxBrushItem* pBackground, o3tl::optional<Color>& pOldColor, const SvxBrushItem*& pOldBackground, tools::Rectangle& rRect, long nPosX, long nLayoutSign, long nOneX, long nOneY, const ScDataBarInfo* pDataBarInfo, const ScDataBarInfo*& pOldDataBarInfo, const ScIconSetInfo* pIconSetInfo, const ScIconSetInfo*& pOldIconSetInfo, sc::IconSetBitmapMap & rIconSetBitmapMap) @@ -1059,7 +1059,7 @@ void ScOutputData::DrawBackground(vcl::RenderContext& rRenderContext) const SvxBrushItem* pOldBackground = nullptr; const SvxBrushItem* pBackground = nullptr; - boost::optional<Color> pOldColor; + o3tl::optional<Color> pOldColor; const ScDataBarInfo* pOldDataBarInfo = nullptr; const ScIconSetInfo* pOldIconSetInfo = nullptr; SCCOL nMergedCols = 1; @@ -1104,7 +1104,7 @@ void ScOutputData::DrawBackground(vcl::RenderContext& rRenderContext) pBackground = lcl_FindBackground( mpDoc, nX, nY, nTab ); } - boost::optional<Color> const & pColor = pInfo->mxColorScale; + o3tl::optional<Color> const & pColor = pInfo->mxColorScale; const ScDataBarInfo* pDataBarInfo = pInfo->pDataBar.get(); const ScIconSetInfo* pIconSetInfo = pInfo->pIconSet.get(); @@ -1136,7 +1136,7 @@ void ScOutputData::DrawBackground(vcl::RenderContext& rRenderContext) if (bWorksInPixels) nPosXLogic = rRenderContext.PixelToLogic(Point(nPosX, 0)).X(); - drawCells(rRenderContext, boost::optional<Color>(), nullptr, pOldColor, pOldBackground, aRect, nPosXLogic, nLayoutSign, nOneXLogic, nOneYLogic, nullptr, pOldDataBarInfo, nullptr, pOldIconSetInfo, mpDoc->GetIconSetBitmapMap()); + drawCells(rRenderContext, o3tl::optional<Color>(), nullptr, pOldColor, pOldBackground, aRect, nPosXLogic, nLayoutSign, nOneXLogic, nOneYLogic, nullptr, pOldDataBarInfo, nullptr, pOldIconSetInfo, mpDoc->GetIconSetBitmapMap()); nArrY += nSkip; } @@ -1650,7 +1650,7 @@ void ScOutputData::DrawRotatedFrame(vcl::RenderContext& rRenderContext) else { tools::Polygon aPoly(4, aPoints); - boost::optional<Color> const & pColor = pInfo->mxColorScale; + o3tl::optional<Color> const & pColor = pInfo->mxColorScale; // for DrawPolygon, without Pen one pixel is left out // to the right and below... |