summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-30 15:15:03 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-30 19:17:03 +0200
commit2e32150731f0ec5176731686d77e2873023e9dd4 (patch)
tree5b2fdac39bca2a7571cf67f8d10ddec0cca8ee15 /xmloff
parent7b87afa899be289306c709d35eb1d32c0b73b1ed (diff)
these can be stack allocated
Change-Id: Ief9a0732d50af95d679d1d6b66dec9d2e2d141df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135132 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/draw/ximpcustomshape.cxx26
-rw-r--r--xmloff/source/style/PageMasterImportPropMapper.cxx30
-rw-r--r--xmloff/source/text/txtimppr.cxx56
3 files changed, 54 insertions, 58 deletions
diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx
index b50172624eec..fbc32e53eceb 100644
--- a/xmloff/source/draw/ximpcustomshape.cxx
+++ b/xmloff/source/draw/ximpcustomshape.cxx
@@ -1224,12 +1224,12 @@ void XMLEnhancedCustomShapeContext::endFastElement(sal_Int32 )
if ( !maEquations.empty() )
{
// creating hash map containing the name and index of each equation
- std::unique_ptr<EquationHashMap> pH = std::make_unique<EquationHashMap>();
+ EquationHashMap aH;
std::vector< OUString >::iterator aEquationNameIter = maEquationNames.begin();
std::vector< OUString >::iterator aEquationNameEnd = maEquationNames.end();
while( aEquationNameIter != aEquationNameEnd )
{
- (*pH)[ *aEquationNameIter ] = static_cast<sal_Int32>( aEquationNameIter - maEquationNames.begin() );
+ aH[ *aEquationNameIter ] = static_cast<sal_Int32>( aEquationNameIter - maEquationNames.begin() );
++aEquationNameIter;
}
@@ -1247,8 +1247,8 @@ void XMLEnhancedCustomShapeContext::endFastElement(sal_Int32 )
{
// copying first characters inclusive '?'
sal_Int32 nIndex = 0;
- EquationHashMap::iterator aHashIter( pH->find( aEquationName ) );
- if ( aHashIter != pH->end() )
+ EquationHashMap::iterator aHashIter( aH.find( aEquationName ) );
+ if ( aHashIter != aH.end() )
nIndex = (*aHashIter).second;
OUString aNew = rEquation.subView( 0, nIndexOf + 1 ) +
OUString::number( nIndex ) +
@@ -1274,8 +1274,8 @@ void XMLEnhancedCustomShapeContext::endFastElement(sal_Int32 )
rPathItem.Value);
for ( const auto& rElem : rSeq )
{
- CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.First), pH.get() );
- CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.Second), pH.get() );
+ CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.First), &aH );
+ CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.Second), &aH );
}
}
break;
@@ -1286,10 +1286,10 @@ void XMLEnhancedCustomShapeContext::endFastElement(sal_Int32 )
rPathItem.Value);
for ( const auto& rElem : rSeq )
{
- CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.TopLeft.First), pH.get() );
- CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.TopLeft.Second), pH.get() );
- CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.BottomRight.First), pH.get() );
- CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.BottomRight.Second), pH.get() );
+ CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.TopLeft.First), &aH );
+ CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.TopLeft.Second), &aH );
+ CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.BottomRight.First), &aH );
+ CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.BottomRight.Second), &aH );
}
}
break;
@@ -1311,7 +1311,7 @@ void XMLEnhancedCustomShapeContext::endFastElement(sal_Int32 )
case EAS_RadiusRangeMaximum :
{
CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(*o3tl::doAccess<css::drawing::EnhancedCustomShapeParameter>(
- propValue.Value)), pH.get() );
+ propValue.Value)), &aH );
}
break;
@@ -1319,9 +1319,9 @@ void XMLEnhancedCustomShapeContext::endFastElement(sal_Int32 )
case EAS_Polar :
{
CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>((*o3tl::doAccess<css::drawing::EnhancedCustomShapeParameterPair>(
- propValue.Value)).First), pH.get() );
+ propValue.Value)).First), &aH );
CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>((*o3tl::doAccess<css::drawing::EnhancedCustomShapeParameterPair>(
- propValue.Value)).Second), pH.get() );
+ propValue.Value)).Second), &aH );
}
break;
default:
diff --git a/xmloff/source/style/PageMasterImportPropMapper.cxx b/xmloff/source/style/PageMasterImportPropMapper.cxx
index 8ee711804333..d4eba76017e7 100644
--- a/xmloff/source/style/PageMasterImportPropMapper.cxx
+++ b/xmloff/source/style/PageMasterImportPropMapper.cxx
@@ -115,19 +115,19 @@ void PageMasterImportPropertyMapper::finished(std::vector< XMLPropertyState >& r
XMLPropertyState* pFooterBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
XMLPropertyState* pHeaderHeight = nullptr;
XMLPropertyState* pHeaderMinHeight = nullptr;
- std::unique_ptr<XMLPropertyState> xHeaderDynamic;
+ std::optional<XMLPropertyState> xHeaderDynamic;
XMLPropertyState* pFooterHeight = nullptr;
XMLPropertyState* pFooterMinHeight = nullptr;
- std::unique_ptr<XMLPropertyState> xFooterDynamic;
+ std::optional<XMLPropertyState> xFooterDynamic;
XMLPropertyState* pAllMarginProperty = nullptr;
XMLPropertyState* pMargins[4] = { nullptr, nullptr, nullptr, nullptr };
- std::unique_ptr<XMLPropertyState> pNewMargins[4];
+ std::optional<XMLPropertyState> pNewMargins[4];
XMLPropertyState* pAllHeaderMarginProperty = nullptr;
XMLPropertyState* pHeaderMargins[4] = { nullptr, nullptr, nullptr, nullptr };
- std::unique_ptr<XMLPropertyState> pNewHeaderMargins[4];
+ std::optional<XMLPropertyState> pNewHeaderMargins[4];
XMLPropertyState* pAllFooterMarginProperty = nullptr;
XMLPropertyState* pFooterMargins[4] = { nullptr, nullptr, nullptr, nullptr };
- std::unique_ptr<XMLPropertyState> pNewFooterMargins[4];
+ std::optional<XMLPropertyState> pNewFooterMargins[4];
XMLPropertyState* pMarginGutter = nullptr;
XMLPropertyState* pRtlGutter = nullptr;
@@ -232,21 +232,21 @@ void PageMasterImportPropertyMapper::finished(std::vector< XMLPropertyState >& r
{
if (pAllMarginProperty && !pMargins[i])
{
- pNewMargins[i].reset(new XMLPropertyState(
+ pNewMargins[i].emplace(
pAllMarginProperty->mnIndex + 1 + i,
- pAllMarginProperty->maValue));
+ pAllMarginProperty->maValue);
}
if (pAllHeaderMarginProperty && !pHeaderMargins[i])
{
- pNewHeaderMargins[i].reset(new XMLPropertyState(
+ pNewHeaderMargins[i].emplace(
pAllHeaderMarginProperty->mnIndex + 1 + i,
- pAllHeaderMarginProperty->maValue));
+ pAllHeaderMarginProperty->maValue);
}
if (pAllFooterMarginProperty && !pFooterMargins[i])
{
- pNewFooterMargins[i].reset(new XMLPropertyState(
+ pNewFooterMargins[i].emplace(
pAllFooterMarginProperty->mnIndex + 1 + i,
- pAllFooterMarginProperty->maValue));
+ pAllFooterMarginProperty->maValue);
}
if (pAllPaddingProperty && !pPadding[i])
pNewPadding[i] = new XMLPropertyState(pAllPaddingProperty->mnIndex + 1 + i, pAllPaddingProperty->maValue);
@@ -324,19 +324,19 @@ void PageMasterImportPropertyMapper::finished(std::vector< XMLPropertyState >& r
if (pHeaderHeight)
{
- xHeaderDynamic.reset(new XMLPropertyState(pHeaderHeight->mnIndex + 2, Any(false)));
+ xHeaderDynamic.emplace(pHeaderHeight->mnIndex + 2, Any(false));
}
if (pHeaderMinHeight)
{
- xHeaderDynamic.reset(new XMLPropertyState(pHeaderMinHeight->mnIndex + 1, Any(true)));
+ xHeaderDynamic.emplace(pHeaderMinHeight->mnIndex + 1, Any(true));
}
if (pFooterHeight)
{
- xFooterDynamic.reset(new XMLPropertyState(pFooterHeight->mnIndex + 2, Any(false)));
+ xFooterDynamic.emplace(pFooterHeight->mnIndex + 2, Any(false));
}
if (pFooterMinHeight)
{
- xFooterDynamic.reset(new XMLPropertyState(pFooterMinHeight->mnIndex + 1, Any(true)));
+ xFooterDynamic.emplace(pFooterMinHeight->mnIndex + 1, Any(true));
}
// fdo#38056: nerf the various AllFoo properties so they do not override
diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx
index b2016d5fd88e..dcf9d1d3e57e 100644
--- a/xmloff/source/text/txtimppr.cxx
+++ b/xmloff/source/text/txtimppr.cxx
@@ -187,10 +187,10 @@ void XMLTextImportPropertyMapper::FontDefaultsCheck(
XMLPropertyState const * pFontFamily,
XMLPropertyState const * pFontPitch,
XMLPropertyState const * pFontCharSet,
- std::unique_ptr<XMLPropertyState>* ppNewFontStyleName,
- std::unique_ptr<XMLPropertyState>* ppNewFontFamily,
- std::unique_ptr<XMLPropertyState>* ppNewFontPitch,
- std::unique_ptr<XMLPropertyState>* ppNewFontCharSet ) const
+ std::optional<XMLPropertyState>* ppNewFontStyleName,
+ std::optional<XMLPropertyState>* ppNewFontFamily,
+ std::optional<XMLPropertyState>* ppNewFontPitch,
+ std::optional<XMLPropertyState>* ppNewFontCharSet ) const
{
if( pFontFamilyName )
{
@@ -204,8 +204,7 @@ void XMLTextImportPropertyMapper::FontDefaultsCheck(
pFontFamilyName->mnIndex + 1 );
assert(nTmp == CTF_FONTSTYLENAME || nTmp == CTF_FONTSTYLENAME_CJK || nTmp == CTF_FONTSTYLENAME_CTL);
#endif
- ppNewFontStyleName->reset(new XMLPropertyState( pFontFamilyName->mnIndex + 1,
- aAny ));
+ ppNewFontStyleName->emplace( pFontFamilyName->mnIndex + 1, aAny );
}
if( !pFontFamily )
@@ -217,8 +216,7 @@ void XMLTextImportPropertyMapper::FontDefaultsCheck(
pFontFamilyName->mnIndex + 2 );
assert(nTmp == CTF_FONTFAMILY || nTmp == CTF_FONTFAMILY_CJK || nTmp == CTF_FONTFAMILY_CTL);
#endif
- ppNewFontFamily->reset(new XMLPropertyState( pFontFamilyName->mnIndex + 2,
- aAny ));
+ ppNewFontFamily->emplace( pFontFamilyName->mnIndex + 2, aAny );
}
if( !pFontPitch )
@@ -229,8 +227,7 @@ void XMLTextImportPropertyMapper::FontDefaultsCheck(
pFontFamilyName->mnIndex + 3 );
assert(nTmp == CTF_FONTPITCH || nTmp == CTF_FONTPITCH_CJK || nTmp == CTF_FONTPITCH_CTL);
#endif
- ppNewFontPitch->reset(new XMLPropertyState( pFontFamilyName->mnIndex + 3,
- aAny ));
+ ppNewFontPitch->emplace( pFontFamilyName->mnIndex + 3, aAny );
}
if( !pFontCharSet )
@@ -241,8 +238,7 @@ void XMLTextImportPropertyMapper::FontDefaultsCheck(
pFontFamilyName->mnIndex + 4 );
assert(nTmp == CTF_FONTCHARSET || nTmp == CTF_FONTCHARSET_CJK || nTmp == CTF_FONTCHARSET_CTL);
#endif
- ppNewFontCharSet->reset(new XMLPropertyState( pFontFamilyName->mnIndex + 4,
- aAny ));
+ ppNewFontCharSet->emplace( pFontFamilyName->mnIndex + 4, aAny );
}
}
@@ -366,28 +362,28 @@ void XMLTextImportPropertyMapper::finished(
XMLPropertyState* pFontFamily = nullptr;
XMLPropertyState* pFontPitch = nullptr;
XMLPropertyState* pFontCharSet = nullptr;
- std::unique_ptr<XMLPropertyState> pNewFontStyleName;
- std::unique_ptr<XMLPropertyState> pNewFontFamily;
- std::unique_ptr<XMLPropertyState> pNewFontPitch;
- std::unique_ptr<XMLPropertyState> pNewFontCharSet;
+ std::optional<XMLPropertyState> pNewFontStyleName;
+ std::optional<XMLPropertyState> pNewFontFamily;
+ std::optional<XMLPropertyState> pNewFontPitch;
+ std::optional<XMLPropertyState> pNewFontCharSet;
XMLPropertyState* pFontFamilyNameCJK = nullptr;
XMLPropertyState* pFontStyleNameCJK = nullptr;
XMLPropertyState* pFontFamilyCJK = nullptr;
XMLPropertyState* pFontPitchCJK = nullptr;
XMLPropertyState* pFontCharSetCJK = nullptr;
- std::unique_ptr<XMLPropertyState> pNewFontStyleNameCJK;
- std::unique_ptr<XMLPropertyState> pNewFontFamilyCJK;
- std::unique_ptr<XMLPropertyState> pNewFontPitchCJK;
- std::unique_ptr<XMLPropertyState> pNewFontCharSetCJK;
+ std::optional<XMLPropertyState> pNewFontStyleNameCJK;
+ std::optional<XMLPropertyState> pNewFontFamilyCJK;
+ std::optional<XMLPropertyState> pNewFontPitchCJK;
+ std::optional<XMLPropertyState> pNewFontCharSetCJK;
XMLPropertyState* pFontFamilyNameCTL = nullptr;
XMLPropertyState* pFontStyleNameCTL = nullptr;
XMLPropertyState* pFontFamilyCTL = nullptr;
XMLPropertyState* pFontPitchCTL = nullptr;
XMLPropertyState* pFontCharSetCTL = nullptr;
- std::unique_ptr<XMLPropertyState> pNewFontStyleNameCTL;
- std::unique_ptr<XMLPropertyState> pNewFontFamilyCTL;
- std::unique_ptr<XMLPropertyState> pNewFontPitchCTL;
- std::unique_ptr<XMLPropertyState> pNewFontCharSetCTL;
+ std::optional<XMLPropertyState> pNewFontStyleNameCTL;
+ std::optional<XMLPropertyState> pNewFontFamilyCTL;
+ std::optional<XMLPropertyState> pNewFontPitchCTL;
+ std::optional<XMLPropertyState> pNewFontCharSetCTL;
XMLPropertyState* pAllBorderDistance = nullptr;
XMLPropertyState* pBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
XMLPropertyState* pNewBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
@@ -410,10 +406,10 @@ void XMLTextImportPropertyMapper::finished(
XMLPropertyState* pBackTransparent = nullptr; // transparency as boolean
XMLPropertyState* pAllParaMargin = nullptr;
XMLPropertyState* pParaMargins[4] = { nullptr, nullptr, nullptr, nullptr };
- ::std::unique_ptr<XMLPropertyState> pNewParaMargins[4];
+ ::std::optional<XMLPropertyState> pNewParaMargins[4];
XMLPropertyState* pAllMargin = nullptr;
XMLPropertyState* pMargins[4] = { nullptr, nullptr, nullptr, nullptr };
- ::std::unique_ptr<XMLPropertyState> pNewMargins[4];
+ ::std::optional<XMLPropertyState> pNewMargins[4];
XMLPropertyState* pFillStyle(nullptr);
XMLPropertyState* pFillColor(nullptr);
@@ -551,8 +547,8 @@ void XMLTextImportPropertyMapper::finished(
assert(nTmp >= CTF_PARALEFTMARGIN &&
nTmp <= CTF_PARABOTTOMMARGIN_REL);
#endif
- pNewParaMargins[i].reset(new XMLPropertyState(
- pAllParaMargin->mnIndex + (2*i) + 2, pAllParaMargin->maValue));
+ pNewParaMargins[i].emplace(
+ pAllParaMargin->mnIndex + (2*i) + 2, pAllParaMargin->maValue);
}
if (pAllMargin && !pMargins[i])
{
@@ -561,8 +557,8 @@ void XMLTextImportPropertyMapper::finished(
pAllMargin->mnIndex + i + 1 );
assert(nTmp >= CTF_MARGINLEFT && nTmp <= CTF_MARGINBOTTOM);
#endif
- pNewMargins[i].reset(new XMLPropertyState(
- pAllMargin->mnIndex + i + 1, pAllMargin->maValue));
+ pNewMargins[i].emplace(
+ pAllMargin->mnIndex + i + 1, pAllMargin->maValue);
}
lcl_SeparateBorder(