summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-09-19 20:40:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-09-20 08:55:56 +0200
commit494358661a05ce548d09e51703f72cd2c012437b (patch)
treeca7d15cb6f7b318e78f352b9d86c2805423087cc
parent9819f4221ced92fced1760d75019d399c9a3383c (diff)
no need to allocate SfxItemSet separately in SvxOutlinerForwarder
Change-Id: I6042993749b5e0b841e82e3b6930e656b88c7fd7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122327 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--editeng/source/uno/unoforou.cxx24
-rw-r--r--include/editeng/unoforou.hxx6
2 files changed, 16 insertions, 14 deletions
diff --git a/editeng/source/uno/unoforou.cxx b/editeng/source/uno/unoforou.cxx
index 21ffb0df2976..7edf6923dec1 100644
--- a/editeng/source/uno/unoforou.cxx
+++ b/editeng/source/uno/unoforou.cxx
@@ -94,18 +94,18 @@ static SfxItemSet ImplOutlinerForwarderGetAttribs( const ESelection& rSel, EditE
SfxItemSet SvxOutlinerForwarder::GetAttribs( const ESelection& rSel, EditEngineAttribs nOnlyHardAttrib ) const
{
- if( mpAttribsCache && ( EditEngineAttribs::All == nOnlyHardAttrib ) )
+ if( moAttribsCache && ( EditEngineAttribs::All == nOnlyHardAttrib ) )
{
// have we the correct set in cache?
if( maAttribCacheSelection == rSel )
{
// yes! just return the cache
- return *mpAttribsCache;
+ return *moAttribsCache;
}
else
{
// no, we need delete the old cache
- mpAttribsCache.reset();
+ moAttribsCache.reset();
}
}
@@ -117,7 +117,7 @@ SfxItemSet SvxOutlinerForwarder::GetAttribs( const ESelection& rSel, EditEngineA
if( EditEngineAttribs::All == nOnlyHardAttrib )
{
- mpAttribsCache.reset(new SfxItemSet( aSet ));
+ moAttribsCache.emplace( aSet );
maAttribCacheSelection = rSel;
}
@@ -130,31 +130,31 @@ SfxItemSet SvxOutlinerForwarder::GetAttribs( const ESelection& rSel, EditEngineA
SfxItemSet SvxOutlinerForwarder::GetParaAttribs( sal_Int32 nPara ) const
{
- if( mpParaAttribsCache )
+ if( moParaAttribsCache )
{
// have we the correct set in cache?
if( nPara == mnParaAttribsCache )
{
// yes! just return the cache
- return *mpParaAttribsCache;
+ return *moParaAttribsCache;
}
else
{
// no, we need delete the old cache
- mpParaAttribsCache.reset();
+ moParaAttribsCache.reset();
}
}
- mpParaAttribsCache.reset(new SfxItemSet( rOutliner.GetParaAttribs( nPara ) ));
+ moParaAttribsCache.emplace( rOutliner.GetParaAttribs( nPara ) );
mnParaAttribsCache = nPara;
EditEngine& rEditEngine = const_cast<EditEngine&>(rOutliner.GetEditEngine());
SfxStyleSheet* pStyle = rEditEngine.GetStyleSheet( nPara );
if( pStyle )
- mpParaAttribsCache->SetParent( &(pStyle->GetItemSet() ) );
+ moParaAttribsCache->SetParent( &(pStyle->GetItemSet() ) );
- return *mpParaAttribsCache;
+ return *moParaAttribsCache;
}
void SvxOutlinerForwarder::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
@@ -247,8 +247,8 @@ SfxItemState SvxOutlinerForwarder::GetItemState( sal_Int32 nPara, sal_uInt16 nWh
void SvxOutlinerForwarder::flushCache()
{
- mpAttribsCache.reset();
- mpParaAttribsCache.reset();
+ moAttribsCache.reset();
+ moParaAttribsCache.reset();
}
LanguageType SvxOutlinerForwarder::GetLanguage( sal_Int32 nPara, sal_Int32 nIndex ) const
diff --git a/include/editeng/unoforou.hxx b/include/editeng/unoforou.hxx
index 4695077fa7c7..bbc92541735c 100644
--- a/include/editeng/unoforou.hxx
+++ b/include/editeng/unoforou.hxx
@@ -23,7 +23,9 @@
#include <editeng/unoedsrc.hxx>
#include <editeng/editengdllapi.h>
#include <editeng/editdata.hxx>
+#include <svl/itemset.hxx>
#include <memory>
+#include <optional>
class Outliner;
@@ -37,14 +39,14 @@ private:
/** this pointer may be null or point to an item set for the attribs of
the selection maAttribsSelection */
- mutable std::unique_ptr<SfxItemSet> mpAttribsCache;
+ mutable std::optional<SfxItemSet> moAttribsCache;
/** if we have a cached attribute item set, this is the selection of it */
mutable ESelection maAttribCacheSelection;
/** this pointer may be null or point to an item set for the paragraph
mnParaAttribsCache */
- mutable std::unique_ptr<SfxItemSet> mpParaAttribsCache;
+ mutable std::optional<SfxItemSet> moParaAttribsCache;
/** if we have a cached para attribute item set, this is the paragraph of it */
mutable sal_Int32 mnParaAttribsCache;