diff options
32 files changed, 165 insertions, 202 deletions
diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx index 4ba46fc0f1b5..5a6c20729ca7 100644 --- a/sc/inc/dpsave.hxx +++ b/sc/inc/dpsave.hxx @@ -34,6 +34,7 @@ #include <unordered_map> #include <unordered_set> +#include <boost/optional.hpp> namespace com { namespace sun { namespace star { namespace sheet { struct DataPilotFieldReference; @@ -52,7 +53,7 @@ class ScDPSaveMember { private: OUString aName; - std::unique_ptr<OUString> mpLayoutName; // custom name to be displayed in the table. + boost::optional<OUString> mpLayoutName; // custom name to be displayed in the table. sal_uInt16 nVisibleMode; sal_uInt16 nShowDetailsMode; @@ -79,7 +80,7 @@ public: void SetName( const OUString& rNew ); // used if the source member was renamed (groups) SC_DLLPUBLIC void SetLayoutName( const OUString& rName ); - SC_DLLPUBLIC const OUString* GetLayoutName() const; + SC_DLLPUBLIC const boost::optional<OUString> & GetLayoutName() const; void RemoveLayoutName(); void WriteToSource( const css::uno::Reference<css::uno::XInterface>& xMember, @@ -94,8 +95,8 @@ class SC_DLLPUBLIC ScDPSaveDimension { private: OUString aName; - std::unique_ptr<OUString> mpLayoutName; - std::unique_ptr<OUString> mpSubtotalName; + boost::optional<OUString> mpLayoutName; + boost::optional<OUString> mpSubtotalName; bool bIsDataLayout; bool bDupFlag; css::sheet::DataPilotFieldOrientation nOrientation; @@ -170,10 +171,10 @@ public: { return nUsedHierarchy; } void SetLayoutName(const OUString& rName); - const OUString* GetLayoutName() const; + const boost::optional<OUString> & GetLayoutName() const; void RemoveLayoutName(); void SetSubtotalName(const OUString& rName); - const OUString* GetSubtotalName() const; + const boost::optional<OUString> & GetSubtotalName() const; void RemoveSubtotalName(); bool IsMemberNameInUse(const OUString& rName) const; @@ -252,7 +253,7 @@ private: * created. */ bool mbDimensionMembersBuilt; - std::unique_ptr<OUString> mpGrandTotalName; + boost::optional<OUString> mpGrandTotalName; mutable std::unique_ptr<DimOrderType> mpDimOrder; // dimension order for row and column dimensions, to traverse result tree. public: @@ -265,7 +266,7 @@ public: bool operator== ( const ScDPSaveData& r ) const; SC_DLLPUBLIC void SetGrandTotalName(const OUString& rName); - SC_DLLPUBLIC const OUString* GetGrandTotalName() const; + SC_DLLPUBLIC const boost::optional<OUString> & GetGrandTotalName() const; const DimsType& GetDimensions() const { return m_DimList; } diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx index b963f0894ed8..6fe05b8a1aad 100644 --- a/sc/inc/dptabsrc.hxx +++ b/sc/inc/dptabsrc.hxx @@ -52,6 +52,7 @@ #include <unordered_map> #include <unordered_set> #include <vector> +#include <boost/optional.hpp> namespace com { namespace sun { namespace star { namespace sheet { @@ -115,7 +116,7 @@ private: bool bResultOverflow; bool bPageFiltered; // set if page field filters have been applied to cache table - ::std::unique_ptr<OUString> mpGrandTotalName; + boost::optional<OUString> mpGrandTotalName; void CreateRes_Impl(); void FillMemberResults(); @@ -150,7 +151,8 @@ public: ScDPTableData* GetData() { return pData; } const ScDPTableData* GetData() const { return pData; } - const OUString* GetGrandTotalName() const; + const boost::optional<OUString> & + GetGrandTotalName() const; css::sheet::DataPilotFieldOrientation GetOrientation(long nColumn); @@ -273,8 +275,8 @@ class ScDPDimension : public cppu::WeakImplHelper< rtl::Reference<ScDPHierarchies> mxHierarchies; ScGeneralFunction nFunction; OUString aName; // if empty, take from source - std::unique_ptr<OUString> mpLayoutName; - std::unique_ptr<OUString> mpSubtotalName; + boost::optional<OUString> mpLayoutName; + boost::optional<OUString> mpSubtotalName; long nSourceDim; // >=0 if dup'ed css::sheet::DataPilotFieldReference aReferenceValue; // settings for "show data as" / "displayed value" @@ -296,8 +298,8 @@ public: ScDPDimension* CreateCloneObject(); ScDPHierarchies* GetHierarchiesObject(); - SC_DLLPUBLIC const OUString* GetLayoutName() const; - const OUString* GetSubtotalName() const; + SC_DLLPUBLIC const boost::optional<OUString> & GetLayoutName() const; + const boost::optional<OUString> & GetSubtotalName() const; // XNamed virtual OUString SAL_CALL getName() override; @@ -609,7 +611,7 @@ private: long nLev; SCROW mnDataId; - std::unique_ptr<OUString> mpLayoutName; + boost::optional<OUString> mpLayoutName; sal_Int32 nPosition; // manual sorting bool bVisible; @@ -627,7 +629,7 @@ public: SCROW GetItemDataId() const { return mnDataId; } bool IsNamedItem(SCROW nIndex) const; - SC_DLLPUBLIC const OUString* GetLayoutName() const; + SC_DLLPUBLIC const boost::optional<OUString> & GetLayoutName() const; long GetDim() const { return nDim;} sal_Int32 Compare( const ScDPMember& rOther ) const; // visible order diff --git a/sc/inc/paramisc.hxx b/sc/inc/paramisc.hxx index 5ab41a8f625b..4a6e74dab3dc 100644 --- a/sc/inc/paramisc.hxx +++ b/sc/inc/paramisc.hxx @@ -23,12 +23,13 @@ #include <memory> #include "address.hxx" #include <sal/types.h> +#include <boost/optional.hpp> struct ScSolveParam { ScAddress aRefFormulaCell; ScAddress aRefVariableCell; - std::unique_ptr<OUString> pStrTargetVal; + boost::optional<OUString> pStrTargetVal; ScSolveParam(); ScSolveParam( const ScSolveParam& r ); diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx index 8abfdd8ae278..b155700f240a 100644 --- a/sc/inc/patattr.hxx +++ b/sc/inc/patattr.hxx @@ -52,7 +52,7 @@ enum ScAutoFontColorMode class SC_DLLPUBLIC ScPatternAttr: public SfxSetItem { - std::unique_ptr<OUString> pName; + boost::optional<OUString> pName; ScStyleSheet* pStyle; sal_uInt64 mnKey; public: diff --git a/sc/qa/unit/pivottable_filters_test.cxx b/sc/qa/unit/pivottable_filters_test.cxx index ec477e89fe8f..fcecedb26714 100644 --- a/sc/qa/unit/pivottable_filters_test.cxx +++ b/sc/qa/unit/pivottable_filters_test.cxx @@ -2308,7 +2308,7 @@ void ScPivotTableFiltersTest::testTdf112106() // Check that we have an existing data layout dimension const ScDPSaveDimension* pDim = pSaveData->GetExistingDataLayoutDimension(); CPPUNIT_ASSERT(pDim); - const OUString* pLayoutName = pDim->GetLayoutName(); + const boost::optional<OUString> & pLayoutName = pDim->GetLayoutName(); CPPUNIT_ASSERT(pLayoutName); CPPUNIT_ASSERT_EQUAL(ScGlobal::GetRscString(STR_PIVOT_DATA), (*pLayoutName)); diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 6d40fa552e30..10d271eff637 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -1332,7 +1332,7 @@ public: bool operator() (const ScDPSaveDimension* pDim) const { // Layout name takes precedence. - const OUString* pLayoutName = pDim->GetLayoutName(); + const boost::optional<OUString> & pLayoutName = pDim->GetLayoutName(); if (pLayoutName && ScGlobal::pCharClass->uppercase(*pLayoutName) == maName) return true; diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx index a07908a223c6..2a30a7055202 100644 --- a/sc/source/core/data/dpsave.cxx +++ b/sc/source/core/data/dpsave.cxx @@ -69,7 +69,6 @@ static void lcl_SetBoolProperty( const uno::Reference<beans::XPropertySet>& xPro ScDPSaveMember::ScDPSaveMember(const OUString& rName) : aName( rName ), - mpLayoutName(nullptr), nVisibleMode( SC_DPSAVEMODE_DONTKNOW ), nShowDetailsMode( SC_DPSAVEMODE_DONTKNOW ) { @@ -77,12 +76,10 @@ ScDPSaveMember::ScDPSaveMember(const OUString& rName) : ScDPSaveMember::ScDPSaveMember(const ScDPSaveMember& r) : aName( r.aName ), - mpLayoutName(nullptr), + mpLayoutName( r.mpLayoutName ), nVisibleMode( r.nVisibleMode ), nShowDetailsMode( r.nShowDetailsMode ) { - if (r.mpLayoutName) - mpLayoutName.reset(new OUString(*r.mpLayoutName)); } ScDPSaveMember::~ScDPSaveMember() @@ -126,12 +123,12 @@ void ScDPSaveMember::SetName( const OUString& rNew ) void ScDPSaveMember::SetLayoutName( const OUString& rName ) { - mpLayoutName.reset(new OUString(rName)); + mpLayoutName = rName; } -const OUString* ScDPSaveMember::GetLayoutName() const +const boost::optional<OUString> & ScDPSaveMember::GetLayoutName() const { - return mpLayoutName.get(); + return mpLayoutName; } void ScDPSaveMember::RemoveLayoutName() @@ -189,8 +186,6 @@ void ScDPSaveMember::Dump(int nIndent) const ScDPSaveDimension::ScDPSaveDimension(const OUString& rName, bool bDataLayout) : aName( rName ), - mpLayoutName(nullptr), - mpSubtotalName(nullptr), bIsDataLayout( bDataLayout ), bDupFlag( false ), nOrientation( sheet::DataPilotFieldOrientation_HIDDEN ), @@ -208,8 +203,8 @@ ScDPSaveDimension::ScDPSaveDimension(const OUString& rName, bool bDataLayout) : ScDPSaveDimension::ScDPSaveDimension(const ScDPSaveDimension& r) : aName( r.aName ), - mpLayoutName(nullptr), - mpSubtotalName(nullptr), + mpLayoutName( r.mpLayoutName ), + mpSubtotalName( r.mpSubtotalName ), bIsDataLayout( r.bIsDataLayout ), bDupFlag( r.bDupFlag ), nOrientation( r.nOrientation ), @@ -235,10 +230,6 @@ ScDPSaveDimension::ScDPSaveDimension(const ScDPSaveDimension& r) : pAutoShowInfo.reset( new sheet::DataPilotFieldAutoShowInfo( *(r.pAutoShowInfo) ) ); if (r.pLayoutInfo) pLayoutInfo.reset(new sheet::DataPilotFieldLayoutInfo( *(r.pLayoutInfo) )); - if (r.mpLayoutName) - mpLayoutName.reset(new OUString(*r.mpLayoutName)); - if (r.mpSubtotalName) - mpSubtotalName.reset(new OUString(*r.mpSubtotalName)); } ScDPSaveDimension::~ScDPSaveDimension() @@ -373,12 +364,12 @@ void ScDPSaveDimension::SetUsedHierarchy(long nNew) void ScDPSaveDimension::SetSubtotalName(const OUString& rName) { - mpSubtotalName.reset(new OUString(rName)); + mpSubtotalName = rName; } -const OUString* ScDPSaveDimension::GetSubtotalName() const +const boost::optional<OUString> & ScDPSaveDimension::GetSubtotalName() const { - return mpSubtotalName.get(); + return mpSubtotalName; } void ScDPSaveDimension::RemoveSubtotalName() @@ -395,7 +386,7 @@ bool ScDPSaveDimension::IsMemberNameInUse(const OUString& rName) const if (rName.equalsIgnoreAsciiCase(pMem->GetName())) return true; - const OUString* pLayoutName = pMem->GetLayoutName(); + const boost::optional<OUString> & pLayoutName = pMem->GetLayoutName(); if (pLayoutName && rName.equalsIgnoreAsciiCase(*pLayoutName)) return true; } @@ -404,12 +395,12 @@ bool ScDPSaveDimension::IsMemberNameInUse(const OUString& rName) const void ScDPSaveDimension::SetLayoutName(const OUString& rName) { - mpLayoutName.reset(new OUString(rName)); + mpLayoutName = rName; } -const OUString* ScDPSaveDimension::GetLayoutName() const +const boost::optional<OUString> & ScDPSaveDimension::GetLayoutName() const { - return mpLayoutName.get(); + return mpLayoutName; } void ScDPSaveDimension::RemoveLayoutName() @@ -533,7 +524,7 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD if (mpLayoutName) ScUnoHelpFunctions::SetOptionalPropertyValue(xDimProp, SC_UNO_DP_LAYOUTNAME, *mpLayoutName); - const OUString* pSubTotalName = GetSubtotalName(); + const boost::optional<OUString> & pSubTotalName = GetSubtotalName(); if (pSubTotalName) // Custom subtotal name, with '?' being replaced by the visible field name later. ScUnoHelpFunctions::SetOptionalPropertyValue(xDimProp, SC_UNO_DP_FIELD_SUBTOTALNAME, *pSubTotalName); @@ -740,8 +731,7 @@ ScDPSaveData::ScDPSaveData() : nRepeatEmptyMode( SC_DPSAVEMODE_DONTKNOW ), bFilterButton( true ), bDrillDown( true ), - mbDimensionMembersBuilt(false), - mpGrandTotalName(nullptr) + mbDimensionMembersBuilt(false) { } @@ -753,7 +743,7 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) : bFilterButton( r.bFilterButton ), bDrillDown( r.bDrillDown ), mbDimensionMembersBuilt(r.mbDimensionMembersBuilt), - mpGrandTotalName(nullptr), + mpGrandTotalName(r.mpGrandTotalName), mpDimOrder(nullptr) { if ( r.pDimensionData ) @@ -763,9 +753,6 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) : { m_DimList.push_back(o3tl::make_unique<ScDPSaveDimension>(*it)); } - - if (r.mpGrandTotalName) - mpGrandTotalName.reset(new OUString(*r.mpGrandTotalName)); } ScDPSaveData& ScDPSaveData::operator= ( const ScDPSaveData& r ) @@ -815,12 +802,12 @@ ScDPSaveData::~ScDPSaveData() void ScDPSaveData::SetGrandTotalName(const OUString& rName) { - mpGrandTotalName.reset(new OUString(rName)); + mpGrandTotalName = rName; } -const OUString* ScDPSaveData::GetGrandTotalName() const +const boost::optional<OUString> & ScDPSaveData::GetGrandTotalName() const { - return mpGrandTotalName.get(); + return mpGrandTotalName; } namespace { @@ -1110,7 +1097,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie // no error } - const OUString* pGrandTotalName = GetGrandTotalName(); + const boost::optional<OUString> & pGrandTotalName = GetGrandTotalName(); if (pGrandTotalName) ScUnoHelpFunctions::SetOptionalPropertyValue(xSourceProp, SC_UNO_DP_GRANDTOTAL_NAME, *pGrandTotalName); } diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index 48f3c95f0156..27447785f0d2 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -850,7 +850,7 @@ OUString ScDPResultData::GetMeasureString(long nMeasure, bool bForce, ScSubTotal const ScDPDimension* pDataDim = mrSource.GetDataDimension(nMeasure); if (pDataDim) { - const OUString* pLayoutName = pDataDim->GetLayoutName(); + const boost::optional<OUString> & pLayoutName = pDataDim->GetLayoutName(); if (pLayoutName) return *pLayoutName; } @@ -1376,7 +1376,7 @@ void ScDPResultMember::FillMemberResults( const ScDPMember* pMemberDesc = GetDPMember(); if (pMemberDesc) { - const OUString* pLayoutName = pMemberDesc->GetLayoutName(); + const boost::optional<OUString> & pLayoutName = pMemberDesc->GetLayoutName(); if (pLayoutName) { aCaption = *pLayoutName; @@ -1478,7 +1478,7 @@ void ScDPResultMember::FillMemberResults( if (pMemberDesc) { // single data field layout. - const OUString* pSubtotalName = pParentDim->GetSubtotalName(); + const boost::optional<OUString> & pSubtotalName = pParentDim->GetSubtotalName(); if (pSubtotalName) aSubStr = lcl_parseSubtotalName(*pSubtotalName, aCaption); pArray[rPos].Flags &= ~sheet::MemberResultFlags::GRANDTOTAL; @@ -1486,7 +1486,7 @@ void ScDPResultMember::FillMemberResults( else { // root member - subtotal (grand total?) for multi-data field layout. - const OUString* pGrandTotalName = pResultData->GetSource().GetGrandTotalName(); + const boost::optional<OUString> & pGrandTotalName = pResultData->GetSource().GetGrandTotalName(); if (pGrandTotalName) aSubStr = *pGrandTotalName; pArray[rPos].Flags |= sheet::MemberResultFlags::GRANDTOTAL; diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index e84e9bcc2718..d407585bff01 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -116,9 +116,9 @@ ScDPSource::~ScDPSource() pResData.reset(); } -const OUString* ScDPSource::GetGrandTotalName() const +const boost::optional<OUString> & ScDPSource::GetGrandTotalName() const { - return mpGrandTotalName.get(); + return mpGrandTotalName; } sheet::DataPilotFieldOrientation ScDPSource::GetOrientation(long nColumn) @@ -1126,7 +1126,7 @@ void SAL_CALL ScDPSource::setPropertyValue( const OUString& aPropertyName, const { OUString aName; if (aValue >>= aName) - mpGrandTotalName.reset(new OUString(aName)); + mpGrandTotalName = aName; } else { @@ -1156,7 +1156,7 @@ uno::Any SAL_CALL ScDPSource::getPropertyValue( const OUString& aPropertyName ) aRet <<= static_cast<sal_Int32>(maDataDims.size()); else if (aPropertyName == SC_UNO_DP_GRANDTOTAL_NAME) { - if (mpGrandTotalName.get()) + if (mpGrandTotalName) aRet <<= *mpGrandTotalName; } else @@ -1295,8 +1295,6 @@ ScDPDimension::ScDPDimension( ScDPSource* pSrc, long nD ) : pSource( pSrc ), nDim( nD ), nFunction( ScGeneralFunction::SUM ), // sum is default - mpLayoutName(nullptr), - mpSubtotalName(nullptr), nSourceDim( -1 ), bHasSelectedPage( false ), pSelectedData( nullptr ), @@ -1319,14 +1317,14 @@ ScDPHierarchies* ScDPDimension::GetHierarchiesObject() return mxHierarchies.get(); } -const OUString* ScDPDimension::GetLayoutName() const +const boost::optional<OUString> & ScDPDimension::GetLayoutName() const { - return mpLayoutName.get(); + return mpLayoutName; } -const OUString* ScDPDimension::GetSubtotalName() const +const boost::optional<OUString> & ScDPDimension::GetSubtotalName() const { - return mpSubtotalName.get(); + return mpSubtotalName; } uno::Reference<container::XNameAccess> SAL_CALL ScDPDimension::getHierarchies() @@ -1510,13 +1508,13 @@ void SAL_CALL ScDPDimension::setPropertyValue( const OUString& aPropertyName, co { OUString aTmpName; if (aValue >>= aTmpName) - mpLayoutName.reset(new OUString(aTmpName)); + mpLayoutName = aTmpName; } else if (aPropertyName == SC_UNO_DP_FIELD_SUBTOTALNAME) { OUString aTmpName; if (aValue >>= aTmpName) - mpSubtotalName.reset(new OUString(aTmpName)); + mpSubtotalName = aTmpName; } else if (aPropertyName == SC_UNO_DP_HAS_HIDDEN_MEMBER) { @@ -1613,9 +1611,9 @@ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const OUString& aPropertyName aRet <<= uno::Sequence<sheet::TableFilterField>(0); } else if (aPropertyName == SC_UNO_DP_LAYOUTNAME) - aRet <<= mpLayoutName.get() ? *mpLayoutName : OUString(); + aRet <<= mpLayoutName ? *mpLayoutName : OUString(); else if (aPropertyName == SC_UNO_DP_FIELD_SUBTOTALNAME) - aRet <<= mpSubtotalName.get() ? *mpSubtotalName : OUString(); + aRet <<= mpSubtotalName ? *mpSubtotalName : OUString(); else if (aPropertyName == SC_UNO_DP_HAS_HIDDEN_MEMBER) aRet <<= mbHasHiddenMember; else if (aPropertyName == SC_UNO_DP_FLAGS) @@ -2182,7 +2180,7 @@ uno::Any SAL_CALL ScDPLevel::getPropertyValue( const OUString& aPropertyName ) if (!pDim) return aRet; - const OUString* pLayoutName = pDim->GetLayoutName(); + const boost::optional<OUString> & pLayoutName = pDim->GetLayoutName(); if (!pLayoutName) return aRet; @@ -2482,7 +2480,6 @@ ScDPMember::ScDPMember( nHier( nH ), nLev( nL ), mnDataId( nIndex ), - mpLayoutName(nullptr), nPosition( -1 ), bVisible( true ), bShowDet( true ) @@ -2548,9 +2545,9 @@ ScDPItemData ScDPMember::FillItemData() const return (pData ? *pData : ScDPItemData()); } -const OUString* ScDPMember::GetLayoutName() const +const boost::optional<OUString> & ScDPMember::GetLayoutName() const { - return mpLayoutName.get(); + return mpLayoutName; } OUString ScDPMember::GetNameStr( bool bLocaleIndependent ) const @@ -2602,7 +2599,7 @@ void SAL_CALL ScDPMember::setPropertyValue( const OUString& aPropertyName, const { OUString aName; if (aValue >>= aName) - mpLayoutName.reset(new OUString(aName)); + mpLayoutName = aName; } else { @@ -2620,7 +2617,7 @@ uno::Any SAL_CALL ScDPMember::getPropertyValue( const OUString& aPropertyName ) else if ( aPropertyName == SC_UNO_DP_POSITION ) aRet <<= nPosition; else if (aPropertyName == SC_UNO_DP_LAYOUTNAME) - aRet <<= mpLayoutName.get() ? *mpLayoutName : OUString(); + aRet <<= mpLayoutName ? *mpLayoutName : OUString(); else { OSL_FAIL("unknown property"); diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx index 4187d5b5de72..56349cd7e949 100644 --- a/sc/source/core/data/global2.cxx +++ b/sc/source/core/data/global2.cxx @@ -207,16 +207,13 @@ void ScConsolidateParam::SetAreas( ScArea* const* ppAreas, sal_uInt16 nCount ) // struct ScSolveParam ScSolveParam::ScSolveParam() - : pStrTargetVal( nullptr ) { } ScSolveParam::ScSolveParam( const ScSolveParam& r ) : aRefFormulaCell ( r.aRefFormulaCell ), aRefVariableCell( r.aRefVariableCell ), - pStrTargetVal ( r.pStrTargetVal - ? new OUString(*r.pStrTargetVal) - : nullptr ) + pStrTargetVal ( r.pStrTargetVal ) { } @@ -225,7 +222,7 @@ ScSolveParam::ScSolveParam( const ScAddress& rFormulaCell, const OUString& rTargetValStr ) : aRefFormulaCell ( rFormulaCell ), aRefVariableCell( rVariableCell ), - pStrTargetVal ( new OUString(rTargetValStr) ) + pStrTargetVal ( rTargetValStr ) { } @@ -237,9 +234,7 @@ ScSolveParam& ScSolveParam::operator=( const ScSolveParam& r ) { aRefFormulaCell = r.aRefFormulaCell; aRefVariableCell = r.aRefVariableCell; - pStrTargetVal.reset( r.pStrTargetVal - ? new OUString(*r.pStrTargetVal) - : nullptr); + pStrTargetVal = r.pStrTargetVal; return *this; } diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 3cc8c729bc1c..d0940a051592 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -70,7 +70,7 @@ using sc::TwipsToHMM; ScPatternAttr::ScPatternAttr( std::unique_ptr<SfxItemSet>&& pItemSet, const OUString& rStyleName ) : SfxSetItem ( ATTR_PATTERN, std::move(pItemSet) ), - pName ( new OUString( rStyleName ) ), + pName ( rStyleName ), pStyle ( nullptr ), mnKey(0) { @@ -78,7 +78,6 @@ ScPatternAttr::ScPatternAttr( std::unique_ptr<SfxItemSet>&& pItemSet, const OUSt ScPatternAttr::ScPatternAttr( std::unique_ptr<SfxItemSet>&& pItemSet ) : SfxSetItem ( ATTR_PATTERN, std::move(pItemSet) ), - pName ( nullptr ), pStyle ( nullptr ), mnKey(0) { @@ -86,7 +85,6 @@ ScPatternAttr::ScPatternAttr( std::unique_ptr<SfxItemSet>&& pItemSet ) ScPatternAttr::ScPatternAttr( SfxItemPool* pItemPool ) : SfxSetItem ( ATTR_PATTERN, o3tl::make_unique<SfxItemSet>( *pItemPool, svl::Items<ATTR_PATTERN_START, ATTR_PATTERN_END>{} ) ), - pName ( nullptr ), pStyle ( nullptr ), mnKey(0) { @@ -94,11 +92,10 @@ ScPatternAttr::ScPatternAttr( SfxItemPool* pItemPool ) ScPatternAttr::ScPatternAttr( const ScPatternAttr& rPatternAttr ) : SfxSetItem ( rPatternAttr ), + pName ( rPatternAttr.pName ), pStyle ( rPatternAttr.pStyle ), mnKey(rPatternAttr.mnKey) { - if (rPatternAttr.pName) - pName.reset( new OUString(*rPatternAttr.pName) ); } ScPatternAttr::~ScPatternAttr() @@ -110,7 +107,7 @@ SfxPoolItem* ScPatternAttr::Clone( SfxItemPool *pPool ) const ScPatternAttr* pPattern = new ScPatternAttr( std::unique_ptr<SfxItemSet>(GetItemSet().Clone(true, pPool)) ); pPattern->pStyle = pStyle; - pPattern->pName.reset( pName ? new OUString(*pName) : nullptr ); + pPattern->pName = pName; return pPattern; } @@ -1134,7 +1131,7 @@ bool ScPatternAttr::IsVisibleEqual( const ScPatternAttr& rOther ) const const OUString* ScPatternAttr::GetStyleName() const { - return pName ? pName.get() : ( pStyle ? &pStyle->GetName() : nullptr ); + return pName ? &*pName : ( pStyle ? &pStyle->GetName() : nullptr ); } void ScPatternAttr::SetStyleSheet( ScStyleSheet* pNewStyle, bool bClearDirectFormat ) @@ -1195,11 +1192,7 @@ void ScPatternAttr::StyleToName() if ( pStyle ) { - if ( pName ) - *pName = pStyle->GetName(); - else - pName.reset( new OUString( pStyle->GetName() ) ); - + pName = pStyle->GetName(); pStyle = nullptr; GetItemSet().SetParent( nullptr ); } diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx index c954e85ed097..d763d74ccc89 100644 --- a/sc/source/filter/excel/xepivot.cxx +++ b/sc/source/filter/excel/xepivot.cxx @@ -919,7 +919,7 @@ void XclExpPTItem::SetPropertiesFromMember( const ScDPSaveMember& rSaveMem ) ::set_flag( maItemInfo.mnFlags, EXC_SXVI_HIDEDETAIL, rSaveMem.HasShowDetails() && !rSaveMem.GetShowDetails() ); // visible name - const OUString* pVisName = rSaveMem.GetLayoutName(); + const boost::optional<OUString> & pVisName = rSaveMem.GetLayoutName(); if (pVisName && *pVisName != GetItemName()) maItemInfo.SetVisName(*pVisName); } @@ -1002,15 +1002,15 @@ void XclExpPTField::SetPropertiesFromDim( const ScDPSaveDimension& rSaveDim ) ::set_flag( maFieldExtInfo.mnFlags, EXC_SXVDEX_SHOWALL, rSaveDim.HasShowEmpty() && rSaveDim.GetShowEmpty() ); // visible name - const OUString* pLayoutName = rSaveDim.GetLayoutName(); + const boost::optional<OUString> & pLayoutName = rSaveDim.GetLayoutName(); if (pLayoutName && *pLayoutName != GetFieldName()) maFieldInfo.SetVisName(*pLayoutName); - const OUString* pSubtotalName = rSaveDim.GetSubtotalName(); + const boost::optional<OUString> & pSubtotalName = rSaveDim.GetSubtotalName(); if (pSubtotalName) { OUString aSubName = lcl_convertCalcSubtotalName(*pSubtotalName); - maFieldExtInfo.mpFieldTotalName.reset(new OUString(aSubName)); + maFieldExtInfo.mpFieldTotalName = aSubName; } // subtotals @@ -1073,7 +1073,7 @@ void XclExpPTField::SetDataPropertiesFromDim( const ScDPSaveDimension& rSaveDim rDataInfo.SetApiAggFunc( eFunc ); // visible name - const OUString* pVisName = rSaveDim.GetLayoutName(); + const boost::optional<OUString> & pVisName = rSaveDim.GetLayoutName(); if (pVisName) rDataInfo.SetVisName(*pVisName); else @@ -1305,9 +1305,8 @@ void XclExpPivotTable::SetPropertiesFromDP( const ScDPSaveData& rSaveData ) mbFilterBtn = rSaveData.GetFilterButton(); const ScDPSaveDimension* pDim = rSaveData.GetExistingDataLayoutDimension(); - const OUString* pLayoutName = pDim ? pDim->GetLayoutName() : nullptr; - if (pLayoutName) - maPTInfo.maDataName = *pLayoutName; + if (pDim && pDim->GetLayoutName()) + maPTInfo.maDataName = *pDim->GetLayoutName(); else maPTInfo.maDataName = ScGlobal::GetRscString(STR_PIVOT_DATA); } diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx index a7e88479c4e1..ffa2eb724f84 100644 --- a/sc/source/filter/excel/xepivotxml.cxx +++ b/sc/source/filter/excel/xepivotxml.cxx @@ -954,7 +954,7 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP long nDimIdx = it->mnPos; assert(aCachedDims[nDimIdx]); // the loop above should have screened for NULL's. const ScDPSaveDimension& rDim = *it->mpDim; - const OUString* pName = rDim.GetLayoutName(); + const boost::optional<OUString> & pName = rDim.GetLayoutName(); pPivotStrm->write("<")->writeId(XML_dataField); if (pName) rStrm.WriteAttributes(XML_name, XclXmlUtils::ToOString(*pName), FSEND); diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx index 122f99fcfe6b..118e9a014691 100644 --- a/sc/source/filter/excel/xipivot.cxx +++ b/sc/source/filter/excel/xipivot.cxx @@ -1158,7 +1158,7 @@ void XclImpPTField::ConvertRCPField( ScDPSaveData& rSaveData ) const pCacheField->ConvertGroupField( rSaveData, mrPTable.GetVisFieldNames() ); // custom subtotal name - if (maFieldExtInfo.mpFieldTotalName.get()) + if (maFieldExtInfo.mpFieldTotalName) { OUString aSubName = lcl_convertExcelSubtotalName(*maFieldExtInfo.mpFieldTotalName); rSaveDim.SetSubtotalName(aSubName); diff --git a/sc/source/filter/excel/xlpivot.cxx b/sc/source/filter/excel/xlpivot.cxx index 908f0a0e28a2..b6deec337767 100644 --- a/sc/source/filter/excel/xlpivot.cxx +++ b/sc/source/filter/excel/xlpivot.cxx @@ -568,8 +568,7 @@ XclPTFieldExtInfo::XclPTFieldExtInfo() : mnFlags( EXC_SXVDEX_DEFAULTFLAGS ), mnSortField( EXC_SXVDEX_SORT_OWN ), mnShowField( EXC_SXVDEX_SHOW_NONE ), - mnNumFmt(0), - mpFieldTotalName(nullptr) + mnNumFmt(0) { } @@ -637,7 +636,7 @@ XclImpStream& operator>>( XclImpStream& rStrm, XclPTFieldExtInfo& rInfo ) rStrm.Ignore(10); if (nNameLen != 0xFF) // Custom field total name is used. Pick it up. - rInfo.mpFieldTotalName.reset(new OUString(rStrm.ReadUniString(nNameLen, 0))); + rInfo.mpFieldTotalName = rStrm.ReadUniString(nNameLen, 0); return rStrm; } @@ -649,7 +648,7 @@ XclExpStream& operator<<( XclExpStream& rStrm, const XclPTFieldExtInfo& rInfo ) << rInfo.mnShowField << EXC_SXVDEX_FORMAT_NONE; - if (rInfo.mpFieldTotalName.get() && !rInfo.mpFieldTotalName->isEmpty()) + if (rInfo.mpFieldTotalName && !rInfo.mpFieldTotalName->isEmpty()) { OUString aFinalName = *rInfo.mpFieldTotalName; if (aFinalName.getLength() >= 254) @@ -990,7 +989,7 @@ void XclPTViewEx9Info::Init( const ScDPObject& rDPObj ) const ScDPSaveData* pData = rDPObj.GetSaveData(); if (pData) { - const OUString* pGrandTotal = pData->GetGrandTotalName(); + const boost::optional<OUString> & pGrandTotal = pData->GetGrandTotalName(); if (pGrandTotal) maGrandTotalName = *pGrandTotal; } diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index e53eec4d04fe..630b27cebce8 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -987,12 +987,12 @@ void ScHTMLLayoutParser::TableDataOn( HtmlImportInfo* pInfo ) break; case HtmlOptionId::SDVAL: { - mxActEntry->pValStr.reset(new OUString(rOption.GetString())); + mxActEntry->pValStr = rOption.GetString(); } break; case HtmlOptionId::SDNUM: { - mxActEntry->pNumStr.reset(new OUString(rOption.GetString())); + mxActEntry->pNumStr = rOption.GetString(); } break; default: break; @@ -1425,7 +1425,7 @@ void ScHTMLLayoutParser::AnchorOn( HtmlImportInfo* pInfo ) for (const auto & rOption : rOptions) { if( rOption.GetToken() == HtmlOptionId::NAME ) - mxActEntry->pName.reset(new OUString(rOption.GetString())); + mxActEntry->pName = rOption.GetString(); } } @@ -2078,7 +2078,7 @@ void ScHTMLTable::DataOn( const HtmlImportInfo& rInfo ) { // read needed options from the <td> tag ScHTMLSize aSpanSize( 1, 1 ); - std::unique_ptr<OUString> pValStr, pNumStr; + boost::optional<OUString> pValStr, pNumStr; const HTMLOptions& rOptions = static_cast<HTMLParser*>(rInfo.pParser)->GetOptions(); HTMLOptions::const_iterator itr = rOptions.begin(), itrEnd = rOptions.end(); sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND; @@ -2093,10 +2093,10 @@ void ScHTMLTable::DataOn( const HtmlImportInfo& rInfo ) aSpanSize.mnRows = static_cast<SCROW>( getLimitedValue<sal_Int32>( itr->GetString().toInt32(), 1, 256 ) ); break; case HtmlOptionId::SDVAL: - pValStr.reset(new OUString(itr->GetString())); + pValStr = itr->GetString(); break; case HtmlOptionId::SDNUM: - pNumStr.reset(new OUString(itr->GetString())); + pNumStr = itr->GetString(); break; case HtmlOptionId::CLASS: { @@ -2132,8 +2132,8 @@ void ScHTMLTable::DataOn( const HtmlImportInfo& rInfo ) ProcessFormatOptions( *mxDataItemSet, rInfo ); CreateNewEntry( rInfo ); - mxCurrEntry->pValStr.reset( pValStr.release() ); - mxCurrEntry->pNumStr.reset( pNumStr.release() ); + mxCurrEntry->pValStr = std::move(pValStr); + mxCurrEntry->pNumStr = std::move(pNumStr); } else CreateNewEntry( rInfo ); diff --git a/sc/source/filter/inc/eeparser.hxx b/sc/source/filter/inc/eeparser.hxx index 9419e5e850e9..7b174044690f 100644 --- a/sc/source/filter/inc/eeparser.hxx +++ b/sc/source/filter/inc/eeparser.hxx @@ -50,11 +50,11 @@ struct ScEEParseEntry { SfxItemSet aItemSet; ESelection aSel; // Selection in EditEngine - std::unique_ptr<OUString> + boost::optional<OUString> pValStr; // HTML possibly SDVAL string - std::unique_ptr<OUString> + boost::optional<OUString> pNumStr; // HTML possibly SDNUM string - std::unique_ptr<OUString> + boost::optional<OUString> pName; // HTML possibly anchor/RangeName OUString aAltText; // HTML IMG ALT Text std::vector< std::unique_ptr<ScHTMLImage> > maImageList; // graphics in this cell @@ -70,16 +70,14 @@ struct ScEEParseEntry bool bEntirePara:1; // true = use entire paragraph, false = use selection ScEEParseEntry( SfxItemPool* pPool ) : - aItemSet( *pPool ), pValStr( nullptr ), - pNumStr( nullptr ), pName( nullptr ), + aItemSet( *pPool ), nCol(SCCOL_MAX), nRow(SCROW_MAX), nTab(0), nTwips(0), nColOverlap(1), nRowOverlap(1), nOffset(0), nWidth(0), bHasGraphic(false), bEntirePara(true) {} ScEEParseEntry( const SfxItemSet& rItemSet ) : - aItemSet( rItemSet ), pValStr( nullptr ), - pNumStr( nullptr ), pName( nullptr ), + aItemSet( rItemSet ), nCol(SCCOL_MAX), nRow(SCROW_MAX), nTab(0), nTwips(0), nColOverlap(1), nRowOverlap(1), nOffset(0), nWidth(0), bHasGraphic(false), bEntirePara(true) diff --git a/sc/source/filter/inc/xlpivot.hxx b/sc/source/filter/inc/xlpivot.hxx index 394500942def..5306bbbf690c 100644 --- a/sc/source/filter/inc/xlpivot.hxx +++ b/sc/source/filter/inc/xlpivot.hxx @@ -33,6 +33,7 @@ #include <dpobject.hxx> #include <memory> +#include <boost/optional.hpp> class XclImpStream; class XclExpStream; @@ -625,7 +626,7 @@ struct XclPTFieldExtInfo sal_uInt16 mnSortField; /// Index to data field sorting bases on. sal_uInt16 mnShowField; /// Index to data field AutoShow bases on. sal_uInt16 mnNumFmt; - std::unique_ptr<OUString> mpFieldTotalName; + boost::optional<OUString> mpFieldTotalName; explicit XclPTFieldExtInfo(); diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx index 4b8bf5213fc6..436cf515ed1e 100644 --- a/sc/source/filter/xml/XMLExportDataPilot.cxx +++ b/sc/source/filter/xml/XMLExportDataPilot.cxx @@ -431,7 +431,7 @@ void ScXMLExportDataPilot::WriteLayoutInfo(const ScDPSaveDimension* pDim) void ScXMLExportDataPilot::WriteSubTotals(const ScDPSaveDimension* pDim) { sal_Int32 nSubTotalCount = pDim->GetSubTotalsCount(); - const OUString* pLayoutName = nullptr; + boost::optional<OUString> pLayoutName; if (rExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012) // Export display names only for 1.2 extended or later. pLayoutName = pDim->GetSubtotalName(); @@ -467,7 +467,7 @@ void ScXMLExportDataPilot::WriteMembers(const ScDPSaveDimension* pDim) if (rExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012) { // Export display names only for ODF 1.2 extended or later. - const OUString* pLayoutName = (*i)->GetLayoutName(); + const boost::optional<OUString> & pLayoutName = (*i)->GetLayoutName(); if (pLayoutName) rExport.AddAttribute(XML_NAMESPACE_TABLE_EXT, XML_DISPLAY_NAME, *pLayoutName); } @@ -677,7 +677,7 @@ void ScXMLExportDataPilot::WriteDimension(const ScDPSaveDimension* pDim, const S if (rExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012) { // Export display names only for ODF 1.2 extended or later. - const OUString* pLayoutName = pDim->GetLayoutName(); + const boost::optional<OUString> & pLayoutName = pDim->GetLayoutName(); if (pLayoutName) rExport.AddAttribute(XML_NAMESPACE_TABLE_EXT, XML_DISPLAY_NAME, *pLayoutName); } @@ -723,7 +723,7 @@ void ScXMLExportDataPilot::WriteDimensions(const ScDPSaveData* pDPSave) } } -void ScXMLExportDataPilot::WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const OUString* pGrandTotal) +void ScXMLExportDataPilot::WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const boost::optional<OUString> & pGrandTotal) { rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, bVisible ? XML_TRUE : XML_FALSE); rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ORIENTATION, eOrient); @@ -811,7 +811,7 @@ void ScXMLExportDataPilot::WriteDataPilots() // grand total elements. - const OUString* pGrandTotalName = pDPSave->GetGrandTotalName(); + const boost::optional<OUString> & pGrandTotalName = pDPSave->GetGrandTotalName(); if (pGrandTotalName && rExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012) { // Use the new data-pilot-grand-total element. diff --git a/sc/source/filter/xml/XMLExportDataPilot.hxx b/sc/source/filter/xml/XMLExportDataPilot.hxx index 22cfe310fb69..16cee372d596 100644 --- a/sc/source/filter/xml/XMLExportDataPilot.hxx +++ b/sc/source/filter/xml/XMLExportDataPilot.hxx @@ -25,6 +25,7 @@ #include <global.hxx> #include <xmloff/xmltoken.hxx> #include <unotools/textsearch.hxx> +#include <boost/optional.hpp> class ScXMLExport; class ScDocument; @@ -62,7 +63,7 @@ class ScXMLExportDataPilot void WriteDimension(const ScDPSaveDimension* pDim, const ScDPDimensionSaveData* pDimData); void WriteDimensions(const ScDPSaveData* pDPSave); - void WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const OUString* pGrandTotal); + void WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const boost::optional<OUString> & pGrandTotal); public: explicit ScXMLExportDataPilot(ScXMLExport& rExport); diff --git a/sc/source/filter/xml/XMLStylesImportHelper.cxx b/sc/source/filter/xml/XMLStylesImportHelper.cxx index 28142107b0d1..1dbceb61943d 100644 --- a/sc/source/filter/xml/XMLStylesImportHelper.cxx +++ b/sc/source/filter/xml/XMLStylesImportHelper.cxx @@ -110,7 +110,7 @@ void ScMyStyleRanges::AddRange(const ScRange& rRange, const sal_Int16 nType) } } -void ScMyStyleRanges::AddCurrencyRange(const ScRange& rRange, const OUString* pCurrency) +void ScMyStyleRanges::AddCurrencyRange(const ScRange& rRange, const boost::optional<OUString> & pCurrency) { if (!pCurrencyList) pCurrencyList.reset( new ScMyCurrencyStylesSet ); @@ -238,10 +238,6 @@ ScMyStylesImportHelper::ScMyStylesImportHelper(ScXMLImport& rTempImport) : aRowDefaultStyle(aCellStyles.end()), rImport(rTempImport), - pStyleName(nullptr), - pPrevStyleName(nullptr), - pCurrency(nullptr), - pPrevCurrency(nullptr), nCellType(0), nPrevCellType(0), bPrevRangeAdded(true) @@ -254,13 +250,13 @@ ScMyStylesImportHelper::~ScMyStylesImportHelper() void ScMyStylesImportHelper::ResetAttributes() { - pPrevStyleName.reset( pStyleName.release() ); - pPrevCurrency.reset( pCurrency.release() ); + pPrevStyleName = std::move(pStyleName); + pPrevCurrency = std::move(pCurrency); nPrevCellType = nCellType; nCellType = 0; } -ScMyStylesSet::iterator ScMyStylesImportHelper::GetIterator(const OUString* pStyleNameP) +ScMyStylesSet::iterator ScMyStylesImportHelper::GetIterator(const boost::optional<OUString> & pStyleNameP) { ScMyStyle aStyle; if (pStyleNameP) @@ -303,7 +299,7 @@ void ScMyStylesImportHelper::AddDefaultRange(const ScRange& rRange) ScRange aRange(rRange); aRange.aStart.SetCol(nStartCol); aRange.aEnd.SetCol(i - 1); - pPrevStyleName.reset( new OUString(aPrevItr->sStyleName) ); + pPrevStyleName = aPrevItr->sStyleName; AddSingleRange(aRange); nStartCol = i; aPrevItr = aColDefaultStyles[i]; @@ -313,7 +309,7 @@ void ScMyStylesImportHelper::AddDefaultRange(const ScRange& rRange) { ScRange aRange(rRange); aRange.aStart.SetCol(nStartCol); - pPrevStyleName.reset( new OUString(aPrevItr->sStyleName) ); + pPrevStyleName = aPrevItr->sStyleName; AddSingleRange(aRange); } else @@ -328,20 +324,20 @@ void ScMyStylesImportHelper::AddDefaultRange(const ScRange& rRange) } else { - pPrevStyleName.reset( new OUString(aRowDefaultStyle->sStyleName) ); + pPrevStyleName = aRowDefaultStyle->sStyleName; AddSingleRange(rRange); } } void ScMyStylesImportHelper::AddSingleRange(const ScRange& rRange) { - ScMyStylesSet::iterator aItr(GetIterator(pPrevStyleName.get())); + ScMyStylesSet::iterator aItr(GetIterator(pPrevStyleName)); if (aItr != aCellStyles.end()) { if (nPrevCellType != util::NumberFormat::CURRENCY) aItr->xRanges->AddRange(rRange, nPrevCellType); else - aItr->xRanges->AddCurrencyRange(rRange, pPrevCurrency.get()); + aItr->xRanges->AddCurrencyRange(rRange, pPrevCurrency); } } @@ -357,7 +353,7 @@ void ScMyStylesImportHelper::AddRange() void ScMyStylesImportHelper::AddColumnStyle(const OUString& sStyleName, const sal_Int32 nColumn, const sal_Int32 nRepeat) { OSL_ENSURE(static_cast<sal_uInt32>(nColumn) == aColDefaultStyles.size(), "some columns are absent"); - ScMyStylesSet::iterator aItr(GetIterator(&sStyleName)); + ScMyStylesSet::iterator aItr(GetIterator(sStyleName)); OSL_ENSURE(aItr != aCellStyles.end(), "no column default style"); aColDefaultStyles.reserve(aColDefaultStyles.size() + nRepeat); for (sal_Int32 i = 0; i < nRepeat; ++i) @@ -366,14 +362,14 @@ void ScMyStylesImportHelper::AddColumnStyle(const OUString& sStyleName, const sa void ScMyStylesImportHelper::SetRowStyle(const OUString& sStyleName) { - aRowDefaultStyle = GetIterator(&sStyleName); + aRowDefaultStyle = GetIterator(sStyleName); } -void ScMyStylesImportHelper::SetAttributes(OUString* pStyleNameP, - OUString* pCurrencyP, const sal_Int16 nCellTypeP) +void ScMyStylesImportHelper::SetAttributes(boost::optional<OUString> pStyleNameP, + boost::optional<OUString> pCurrencyP, const sal_Int16 nCellTypeP) { - pStyleName.reset( pStyleNameP ); - pCurrency.reset( pCurrencyP ); + pStyleName = std::move(pStyleNameP); + pCurrency = std::move(pCurrencyP); nCellType = nCellTypeP; } @@ -383,8 +379,8 @@ void ScMyStylesImportHelper::AddRange(const ScRange& rRange) { bool bAddRange(false); if (nCellType == nPrevCellType && - IsEqual(pStyleName.get(), pPrevStyleName.get()) && - IsEqual(pCurrency.get(), pPrevCurrency.get())) + pStyleName == pPrevStyleName && + pCurrency == pPrevCurrency) { if (rRange.aStart.Row() == aPrevRange.aStart.Row()) { diff --git a/sc/source/filter/xml/XMLStylesImportHelper.hxx b/sc/source/filter/xml/XMLStylesImportHelper.hxx index b98f62c65cd7..ccffeb7f0c8f 100644 --- a/sc/source/filter/xml/XMLStylesImportHelper.hxx +++ b/sc/source/filter/xml/XMLStylesImportHelper.hxx @@ -28,6 +28,7 @@ #include <memory> #include <set> #include <vector> +#include <boost/optional.hpp> class ScXMLImport; @@ -99,7 +100,7 @@ public: ScMyStyleRanges(); virtual ~ScMyStyleRanges() override; void AddRange(const ScRange& rRange, const sal_Int16 nType); - void AddCurrencyRange(const ScRange& rRange, const OUString* pCurrency); + void AddCurrencyRange(const ScRange& rRange, const boost::optional<OUString> & pCurrency); void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab); void SetStylesToRanges(const OUString* pStyleName, ScXMLImport& rImport); }; @@ -128,13 +129,13 @@ class ScMyStylesImportHelper std::vector<ScMyStylesSet::iterator> aColDefaultStyles; ScMyStylesSet::iterator aRowDefaultStyle; ScXMLImport& rImport; - std::unique_ptr<OUString> + boost::optional<OUString> pStyleName; - std::unique_ptr<OUString> + boost::optional<OUString> pPrevStyleName; - std::unique_ptr<OUString> + boost::optional<OUString> pCurrency; - std::unique_ptr<OUString> + boost::optional<OUString> pPrevCurrency; ScRange aPrevRange; sal_Int16 nCellType; @@ -142,7 +143,7 @@ class ScMyStylesImportHelper bool bPrevRangeAdded; void ResetAttributes(); - ScMyStylesSet::iterator GetIterator(const OUString* pStyleName); + ScMyStylesSet::iterator GetIterator(const boost::optional<OUString> & pStyleName); void AddDefaultRange(const ScRange& rRange); void AddSingleRange(const ScRange& rRange); void AddRange(); @@ -158,8 +159,8 @@ public: ~ScMyStylesImportHelper(); void AddColumnStyle(const OUString& rStyleName, const sal_Int32 nColumn, const sal_Int32 nRepeat); void SetRowStyle(const OUString& rStyleName); - void SetAttributes(OUString* pStyleName, - OUString* pCurrency, const sal_Int16 nCellType); + void SetAttributes(boost::optional<OUString> pStyleName, + boost::optional<OUString> pCurrency, const sal_Int16 nCellType); void AddRange(const ScRange& rRange); void AddCell(const ScAddress& rAddress); void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab); // a col is inserted before nCol diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx index ff9f68af4448..75410c627865 100644 --- a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx +++ b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx @@ -97,7 +97,7 @@ void XMLTableShapeImportHelper::finishShape( sal_Int32 nEndX(-1); sal_Int32 nEndY(-1); sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - std::unique_ptr<OUString> xRangeList; + boost::optional<OUString> xRangeList; SdrLayerID nLayerID = SDRLAYER_NOTFOUND; for( sal_Int16 i=0; i < nAttrCount; ++i ) { @@ -138,7 +138,7 @@ void XMLTableShapeImportHelper::finishShape( else if(nPrefix == XML_NAMESPACE_DRAW) { if (IsXMLToken(aLocalName, XML_NOTIFY_ON_UPDATE_OF_RANGES)) - xRangeList.reset(new OUString(rValue)); + xRangeList = rValue; } } SetLayer(rShape, nLayerID, rShape->getShapeType()); diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index d52d31e35158..b1c4f4cf0e3c 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -155,8 +155,8 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, rXMLImport.GetTables().AddColumn(bTempIsCovered); - std::unique_ptr<OUString> xStyleName; - std::unique_ptr<OUString> xCurrencySymbol; + boost::optional<OUString> xStyleName; + boost::optional<OUString> xCurrencySymbol; if ( rAttrList.is() ) { for (auto &it : *rAttrList) @@ -164,7 +164,7 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, switch ( it.getToken() ) { case XML_ELEMENT( TABLE, XML_STYLE_NAME ): - xStyleName.reset( new OUString( it.toString() ) ); + xStyleName = it.toString(); mbHasStyle = true; break; case XML_ELEMENT( TABLE, XML_CONTENT_VALIDATION_NAME ): @@ -273,7 +273,7 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, } break; case XML_ELEMENT( OFFICE, XML_CURRENCY ): - xCurrencySymbol.reset( new OUString( it.toString() ) ); + xCurrencySymbol = it.toString(); break; default: ; @@ -293,7 +293,7 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, if(bIsEmpty) bFormulaTextResult = true; } - rXMLImport.GetStylesImportHelper()->SetAttributes(xStyleName.release(), xCurrencySymbol.release(), nCellType); + rXMLImport.GetStylesImportHelper()->SetAttributes(std::move(xStyleName), std::move(xCurrencySymbol), nCellType); } ScXMLTableRowCellContext::~ScXMLTableRowCellContext() diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx index b840ed762fa7..d89d9eca5a59 100644 --- a/sc/source/ui/dbgui/pvfundlg.cxx +++ b/sc/source/ui/dbgui/pvfundlg.cxx @@ -833,7 +833,7 @@ ScDPShowDetailDlg::ScDPShowDetailDlg( vcl::Window* pParent, ScDPObject& rDPObj, { if (pDimension) { - const OUString* pLayoutName = pDimension->GetLayoutName(); + const boost::optional<OUString> & pLayoutName = pDimension->GetLayoutName(); if (pLayoutName) aName = *pLayoutName; } diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 5190385de016..2788f3574be0 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -104,7 +104,7 @@ class ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSou std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOHeader; std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOShrink; - std::unique_ptr<tools::Rectangle> mpAutoFillRect; + boost::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/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx index 9c2a26d65b7a..9e4af7a49688 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -918,7 +918,7 @@ Any SAL_CALL ScDataPilotDescriptorBase::getPropertyValue( const OUString& aPrope } else if ( aPropertyName == SC_UNO_DP_GRANDTOTAL_NAME ) { - const OUString* pGrandTotalName = aNewData.GetGrandTotalName(); + const boost::optional<OUString> & pGrandTotalName = aNewData.GetGrandTotalName(); if (pGrandTotalName) aRet <<= *pGrandTotalName; // same behavior as in ScDPSource } @@ -1766,7 +1766,7 @@ OUString SAL_CALL ScDataPilotFieldObj::getName() aName = SC_DATALAYOUT_NAME; else { - const OUString* pLayoutName = pDim->GetLayoutName(); + const boost::optional<OUString> & pLayoutName = pDim->GetLayoutName(); if (pLayoutName) aName = *pLayoutName; else diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index 48f14dca7935..0c8fd4f7ff10 100644 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -1556,7 +1556,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const OUString& rString ) if (pDim->GetSubTotalFunc(0) != ScGeneralFunction::AUTO) break; - const OUString* pLayoutName = pMem->GetLayoutName(); + const boost::optional<OUString> & pLayoutName = pMem->GetLayoutName(); OUString aMemberName; if (pLayoutName) aMemberName = *pLayoutName; diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index edca231aee27..803e09809a33 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -417,7 +417,6 @@ ScGridWindow::ScGridWindow( vcl::Window* pParent, ScViewData* pData, ScSplitPos mpOODragRect(), mpOOHeader(), mpOOShrink(), - mpAutoFillRect(static_cast<tools::Rectangle*>(nullptr)), pViewData( pData ), eWhich( eWhichPos ), mpNoteMarker(), @@ -6087,10 +6086,10 @@ void ScGridWindow::UpdateAutoFillOverlay() tools::Rectangle aFillRect(aFillPos, aFillHandleSize); // expand rect to increase hit area - mpAutoFillRect.reset(new tools::Rectangle(aFillRect.Left() - fScaleFactor, + mpAutoFillRect = tools::Rectangle(aFillRect.Left() - fScaleFactor, aFillRect.Top() - fScaleFactor, aFillRect.Right() + fScaleFactor, - aFillRect.Bottom() + fScaleFactor)); + aFillRect.Bottom() + fScaleFactor); // #i70788# get the OverlayManager safely rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager(); diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 6b3d0d83df0d..956593bfd234 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -2052,8 +2052,8 @@ void ScViewFunc::Solve( const ScSolveParam& rParam ) } OUString aTargetValStr; - if ( rParam.pStrTargetVal != nullptr ) - aTargetValStr = *(rParam.pStrTargetVal); + if ( rParam.pStrTargetVal ) + aTargetValStr = *rParam.pStrTargetVal; OUString aMsgStr; OUString aResStr; diff --git a/svgio/inc/svgnode.hxx b/svgio/inc/svgnode.hxx index 7fd8129a48b8..45d9730be909 100644 --- a/svgio/inc/svgnode.hxx +++ b/svgio/inc/svgnode.hxx @@ -27,6 +27,7 @@ #include <com/sun/star/xml/sax/XAttributeList.hpp> #include <memory> #include <vector> +#include <boost/optional.hpp> // predefines namespace svgio @@ -94,10 +95,10 @@ namespace svgio std::vector< std::unique_ptr<SvgNode> > maChildren; /// Id svan value - std::unique_ptr<OUString> mpId; + boost::optional<OUString> mpId; /// Class svan value - std::unique_ptr<OUString> mpClass; + boost::optional<OUString> mpClass; /// XmlSpace value XmlSpace maXmlSpace; @@ -163,12 +164,12 @@ namespace svgio double getCurrentXHeight() const; /// Id access - const OUString* getId() const { return mpId.get(); } - void setId(const OUString* pfId); + boost::optional<OUString> const & getId() const { return mpId; } + void setId(OUString const &); /// Class access - const OUString* getClass() const { return mpClass.get(); } - void setClass(const OUString* pfClass); + boost::optional<OUString> const & getClass() const { return mpClass; } + void setClass(OUString const &); /// XmlSpace access XmlSpace getXmlSpace() const; diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx index 9f3687e67a25..f6395a24527d 100644 --- a/svgio/source/svgreader/svgnode.cxx +++ b/svgio/source/svgreader/svgnode.cxx @@ -263,8 +263,6 @@ namespace svgio mpParent(pParent), mpAlternativeParent(nullptr), maChildren(), - mpId(nullptr), - mpClass(nullptr), maXmlSpace(XmlSpace_notset), maDisplay(Display_inline), maCssStyleVector(), @@ -422,7 +420,7 @@ namespace svgio { if(!aContent.isEmpty()) { - setId(&aContent); + setId(aContent); } break; } @@ -430,7 +428,7 @@ namespace svgio { if(!aContent.isEmpty()) { - setClass(&aContent); + setClass(aContent); } break; } @@ -629,7 +627,7 @@ namespace svgio return getCurrentXHeightInherited(); } - void SvgNode::setId(const OUString* pfId) + void SvgNode::setId(OUString const & rId) { if(mpId) { @@ -637,14 +635,11 @@ namespace svgio mpId.reset(); } - if(pfId) - { - mpId.reset( new OUString(*pfId) ); - mrDocument.addSvgNodeToMapper(*mpId, *this); - } + mpId = rId; + mrDocument.addSvgNodeToMapper(*mpId, *this); } - void SvgNode::setClass(const OUString* pfClass) + void SvgNode::setClass(OUString const & rClass) { if(mpClass) { @@ -652,11 +647,8 @@ namespace svgio mpClass.reset(); } - if(pfClass) - { - mpClass.reset( new OUString(*pfClass) ); - mrDocument.addSvgNodeToMapper(*mpClass, *this); - } + mpClass = rClass; + mrDocument.addSvgNodeToMapper(*mpClass, *this); } XmlSpace SvgNode::getXmlSpace() const |