diff options
author | Noel <noelgrandin@gmail.com> | 2020-10-26 10:26:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-10-26 14:55:58 +0100 |
commit | 1efcc72d4ac27c9c5f151e410ca3066521c14355 (patch) | |
tree | cb36ae6fadd7264f05bf25c1483831bf9b65f19f /sc | |
parent | 8a9a0447807ad7544a3df5a067dd26a4ee6613f1 (diff) |
std::unique_ptr -> std::optional
Change-Id: I25f8b337a3f9cecb4d7785c18d91dae89ba20799
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104797
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/colorscale.hxx | 6 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 8 | ||||
-rw-r--r-- | sc/source/core/data/colorscale.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/excel/xeextlst.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/oox/condformatbuffer.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcondformat.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/condformat/colorformat.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/unoobj/condformatuno.cxx | 10 |
9 files changed, 23 insertions, 23 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index c6539ec52409..49e09e04bb26 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -17,6 +17,7 @@ #include <memory> #include <vector> +#include <optional> //TODO: merge this with conditio.hxx @@ -116,8 +117,7 @@ struct SC_DLLPUBLIC ScDataBarFormatData mnMaxLength(r.mnMaxLength), mbOnlyBar(r.mbOnlyBar) { - if(r.mpNegativeColor) - mpNegativeColor.reset(new Color(*r.mpNegativeColor)); + mxNegativeColor = r.mxNegativeColor; if(r.mpLowerLimit) mpLowerLimit.reset( new ScColorScaleEntry(*r.mpLowerLimit)); @@ -138,7 +138,7 @@ struct SC_DLLPUBLIC ScDataBarFormatData * * Default color is 0xFF0000, this value is not set */ - std::unique_ptr<Color> mpNegativeColor; + std::optional<Color> mxNegativeColor; /** * Color of the axis if used * Default color is black diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 3053f7bb8257..335ce70d51fa 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -2380,8 +2380,8 @@ void ScFiltersTest::testCondFormatThemeColorXLSX() const ScDataBarFormatData* pDataBarFormatData = pDataBar->GetDataBarData(); CPPUNIT_ASSERT_EQUAL(Color(157, 195, 230), pDataBarFormatData->maPositiveColor); - CPPUNIT_ASSERT(pDataBarFormatData->mpNegativeColor); - CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, *pDataBarFormatData->mpNegativeColor); + CPPUNIT_ASSERT(pDataBarFormatData->mxNegativeColor); + CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, *pDataBarFormatData->mxNegativeColor); CPPUNIT_ASSERT_EQUAL(size_t(1), rDoc.GetCondFormList(1)->size()); pFormat = rDoc.GetCondFormat(0, 0, 1); @@ -2419,8 +2419,8 @@ void ScFiltersTest::testCondFormatThemeColor2XLSX() const ScDataBarFormatData* pDataBarFormatData = pDataBar->GetDataBarData(); CPPUNIT_ASSERT_EQUAL(Color(99, 142, 198), pDataBarFormatData->maPositiveColor); - CPPUNIT_ASSERT(pDataBarFormatData->mpNegativeColor); - CPPUNIT_ASSERT_EQUAL(Color(217, 217, 217), *pDataBarFormatData->mpNegativeColor); + CPPUNIT_ASSERT(pDataBarFormatData->mxNegativeColor); + CPPUNIT_ASSERT_EQUAL(Color(217, 217, 217), *pDataBarFormatData->mxNegativeColor); CPPUNIT_ASSERT_EQUAL(Color(197, 90, 17), pDataBarFormatData->maAxisColor); xDocSh->DoClose(); diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index f12220ce110e..52496653ab1b 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -935,9 +935,9 @@ std::unique_ptr<ScDataBarInfo> ScDataBarFormat::GetDataBarInfo(const ScAddress& // set color if(mpFormatData->mbNeg && nValue < 0) { - if(mpFormatData->mpNegativeColor) + if(mpFormatData->mxNegativeColor) { - pInfo->maColor = *mpFormatData->mpNegativeColor; + pInfo->maColor = *mpFormatData->mxNegativeColor; } else { diff --git a/sc/source/filter/excel/xeextlst.cxx b/sc/source/filter/excel/xeextlst.cxx index 35d2fac152d7..cca940350173 100644 --- a/sc/source/filter/excel/xeextlst.cxx +++ b/sc/source/filter/excel/xeextlst.cxx @@ -209,8 +209,8 @@ XclExpExtDataBar::XclExpExtDataBar( const XclExpRoot& rRoot, const ScDataBarForm const ScDataBarFormatData& rFormatData = *rFormat.GetDataBarData(); mpLowerLimit.reset(new XclExpExtCfvo(*this, *rFormatData.mpLowerLimit, rPos, true)); mpUpperLimit.reset(new XclExpExtCfvo(*this, *rFormatData.mpUpperLimit, rPos, false)); - if (rFormatData.mpNegativeColor) - mpNegativeColor.reset(new XclExpExtNegativeColor(*rFormatData.mpNegativeColor)); + if (rFormatData.mxNegativeColor) + mpNegativeColor.reset(new XclExpExtNegativeColor(*rFormatData.mxNegativeColor)); else mpNegativeColor.reset( new XclExpExtNegativeColor( rFormatData.maPositiveColor ) ); mpAxisColor.reset( new XclExpExtAxisColor( rFormatData.maAxisColor ) ); diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx index 066a310a3d17..551cd1585a54 100644 --- a/sc/source/filter/oox/condformatbuffer.cxx +++ b/sc/source/filter/oox/condformatbuffer.cxx @@ -1302,7 +1302,7 @@ void ExtCfDataBarRule::finalizeImport() case NEGATIVEFILLCOLOR: { ScDataBarFormatData* pDataBar = mpTarget; - pDataBar->mpNegativeColor.reset( new ::Color(maModel.mnNegativeColor) ); + pDataBar->mxNegativeColor = maModel.mnNegativeColor; pDataBar->mbNeg = true; break; } diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx index 9c3ca0904b6c..42a96e04c195 100644 --- a/sc/source/filter/xml/xmlcondformat.cxx +++ b/sc/source/filter/xml/xmlcondformat.cxx @@ -471,7 +471,7 @@ ScXMLDataBarFormatContext::ScXMLDataBarFormatContext( ScXMLImport& rImport, // we might check here for 0xff0000 and don't write it Color nColor; sax::Converter::convertColor( nColor, sNegativeColor ); - mpFormatData->mpNegativeColor.reset(new Color(nColor)); + mpFormatData->mxNegativeColor = nColor; } else mpFormatData->mbNeg = false; diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 999cfb866ba4..0d748fcc4071 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -4677,10 +4677,10 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab) if(pFormatData->mbNeg) { - if(pFormatData->mpNegativeColor) + if(pFormatData->mxNegativeColor) { OUStringBuffer aBuffer; - ::sax::Converter::convertColor(aBuffer, *pFormatData->mpNegativeColor); + ::sax::Converter::convertColor(aBuffer, *pFormatData->mxNegativeColor); AddAttribute(XML_NAMESPACE_CALC_EXT, XML_NEGATIVE_COLOR, aBuffer.makeStringAndClear()); } else diff --git a/sc/source/ui/condformat/colorformat.cxx b/sc/source/ui/condformat/colorformat.cxx index 974cd567b9a3..c4d2a79effd2 100644 --- a/sc/source/ui/condformat/colorformat.cxx +++ b/sc/source/ui/condformat/colorformat.cxx @@ -94,8 +94,8 @@ ScDataBarSettingsDlg::ScDataBarSettingsDlg(weld::Window* pParent, const ScDataBa mxLbPos->SelectEntry(rData.maPositiveColor); mxLbFillType->set_active( rData.mbGradient ? 1 : 0 ); - if (rData.mpNegativeColor) - mxLbNeg->SelectEntry(*rData.mpNegativeColor); + if (rData.mxNegativeColor) + mxLbNeg->SelectEntry(*rData.mxNegativeColor); switch (rData.meAxisPosition) { @@ -175,7 +175,7 @@ ScDataBarFormatData* ScDataBarSettingsDlg::GetData() { ScDataBarFormatData* pData = new ScDataBarFormatData(); pData->maPositiveColor = mxLbPos->GetSelectEntryColor(); - pData->mpNegativeColor.reset(new Color(mxLbNeg->GetSelectEntryColor())); + pData->mxNegativeColor = mxLbNeg->GetSelectEntryColor(); pData->mbGradient = ( mxLbFillType->get_active() == 1 ); pData->mpUpperLimit.reset(new ScColorScaleEntry()); pData->mpLowerLimit.reset(new ScColorScaleEntry()); diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index 241c443d040d..c679f423bb48 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -1197,9 +1197,9 @@ void SAL_CALL ScDataBarFormatObj::setPropertyValue( if (aValue >>= bUseNegativeColor) { getCoreObject()->GetDataBarData()->mbNeg = bUseNegativeColor; - if (bUseNegativeColor && !getCoreObject()->GetDataBarData()->mpNegativeColor) + if (bUseNegativeColor && !getCoreObject()->GetDataBarData()->mxNegativeColor) { - getCoreObject()->GetDataBarData()->mpNegativeColor.reset(new Color(COL_AUTO)); + getCoreObject()->GetDataBarData()->mxNegativeColor = COL_AUTO; } } } @@ -1237,7 +1237,7 @@ void SAL_CALL ScDataBarFormatObj::setPropertyValue( if (!(aValue >>= nNegativeColor) || !getCoreObject()->GetDataBarData()->mbNeg) throw lang::IllegalArgumentException(); - (*getCoreObject()->GetDataBarData()->mpNegativeColor) = nNegativeColor; + getCoreObject()->GetDataBarData()->mxNegativeColor = nNegativeColor; } break; @@ -1332,9 +1332,9 @@ uno::Any SAL_CALL ScDataBarFormatObj::getPropertyValue( const OUString& aPropert break; case NegativeColor: { - if (getCoreObject()->GetDataBarData()->mbNeg && getCoreObject()->GetDataBarData()->mpNegativeColor) + if (getCoreObject()->GetDataBarData()->mbNeg && getCoreObject()->GetDataBarData()->mxNegativeColor) { - aAny <<= *getCoreObject()->GetDataBarData()->mpNegativeColor; + aAny <<= *getCoreObject()->GetDataBarData()->mxNegativeColor; } } break; |