diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-27 14:04:29 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-28 08:39:35 +0200 |
commit | e32c56855b04ef825b720b20220245365eec51fd (patch) | |
tree | d497c6fad6e3e7ac39a8bc80fa8e81fc7192f199 /sc/source/filter/excel | |
parent | b2e8bbeafa35c15d168961de711e4970eb0985cb (diff) |
use boost::optional in sc and svgio
instead of using std:unique_ptr to allocate small objects on the heap
Change-Id: Ifd309a9bf331910354406b827b89a0363f3b7eda
Reviewed-on: https://gerrit.libreoffice.org/51945
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/filter/excel')
-rw-r--r-- | sc/source/filter/excel/xepivot.cxx | 15 | ||||
-rw-r--r-- | sc/source/filter/excel/xepivotxml.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xipivot.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xlpivot.cxx | 9 |
4 files changed, 13 insertions, 15 deletions
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; } |