[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Fri Sep 24 14:24:58 UTC 2021
sc/inc/cellsuno.hxx | 7 ++++---
sc/source/ui/inc/undostyl.hxx | 6 ++++--
sc/source/ui/undo/undostyl.cxx | 13 ++++++++-----
sc/source/ui/unoobj/cellsuno.cxx | 26 +++++++++++++++++---------
4 files changed, 33 insertions(+), 19 deletions(-)
New commits:
commit 8792cf693dba3e05ed72a353685bc99d0d34c250
Author: Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Fri Sep 24 11:48:58 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Sep 24 16:24:34 2021 +0200
no need to allocate this SfxItemSet on the heap
Change-Id: I651d6091db543ebc958f888598edd2cdef4df43a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122574
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/ui/inc/undostyl.hxx b/sc/source/ui/inc/undostyl.hxx
index 6ea88d0d9550..a4b3a7f44f76 100644
--- a/sc/source/ui/inc/undostyl.hxx
+++ b/sc/source/ui/inc/undostyl.hxx
@@ -20,7 +20,9 @@
#pragma once
#include <memory>
+#include <optional>
#include <svl/style.hxx>
+#include <svl/itemset.hxx>
#include "undobase.hxx"
class ScDocShell;
@@ -30,7 +32,7 @@ class ScStyleSaveData
private:
OUString aName;
OUString aParent;
- std::unique_ptr<SfxItemSet> xItems;
+ std::optional<SfxItemSet> moItems;
public:
ScStyleSaveData();
@@ -41,7 +43,7 @@ public:
const OUString& GetName() const { return aName; }
const OUString& GetParent() const { return aParent; }
- const SfxItemSet* GetItems() const { return xItems.get(); }
+ const std::optional<SfxItemSet>& GetItems() const { return moItems; }
};
class ScUndoModifyStyle: public ScSimpleUndo
diff --git a/sc/source/ui/undo/undostyl.cxx b/sc/source/ui/undo/undostyl.cxx
index f110d0190051..a9d47feec685 100644
--- a/sc/source/ui/undo/undostyl.cxx
+++ b/sc/source/ui/undo/undostyl.cxx
@@ -41,8 +41,8 @@ ScStyleSaveData::ScStyleSaveData( const ScStyleSaveData& rOther ) :
aName( rOther.aName ),
aParent( rOther.aParent )
{
- if (rOther.xItems)
- xItems.reset(new SfxItemSet(*rOther.xItems));
+ if (rOther.moItems)
+ moItems.emplace(*rOther.moItems);
}
ScStyleSaveData& ScStyleSaveData::operator=( const ScStyleSaveData& rOther )
@@ -51,7 +51,10 @@ ScStyleSaveData& ScStyleSaveData::operator=( const ScStyleSaveData& rOther )
{
aName = rOther.aName;
aParent = rOther.aParent;
- xItems.reset(rOther.xItems ? new SfxItemSet(*rOther.xItems) : nullptr);
+ if (rOther.moItems)
+ moItems.emplace(*rOther.moItems);
+ else
+ moItems.reset();
}
return *this;
}
@@ -62,7 +65,7 @@ void ScStyleSaveData::InitFromStyle( const SfxStyleSheetBase* pSource )
{
aName = pSource->GetName();
aParent = pSource->GetParent();
- xItems.reset(new SfxItemSet(const_cast<SfxStyleSheetBase*>(pSource)->GetItemSet()));
+ moItems.emplace(const_cast<SfxStyleSheetBase*>(pSource)->GetItemSet());
}
else
*this = ScStyleSaveData(); // empty
@@ -157,7 +160,7 @@ void ScUndoModifyStyle::DoChange( ScDocShell* pDocSh, const OUString& rName,
pStyle->SetParent( aNewParent );
SfxItemSet& rStyleSet = pStyle->GetItemSet();
- const SfxItemSet* pNewSet = rData.GetItems();
+ const std::optional<SfxItemSet>& pNewSet = rData.GetItems();
OSL_ENSURE( pNewSet, "no ItemSet for style" );
if (pNewSet)
rStyleSet.Set( *pNewSet, false );
commit e69ca434253d3278975078600f8a77291d97b9fc
Author: Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Fri Sep 24 11:54:23 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Sep 24 16:24:21 2021 +0200
no need to allocate this SfxItemSet on the heap
Change-Id: I4982d075f21f74b3d0db1c61a499dceb92e50c87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122575
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/inc/cellsuno.hxx b/sc/inc/cellsuno.hxx
index 7f1b1a0106ad..3d2080a29224 100644
--- a/sc/inc/cellsuno.hxx
+++ b/sc/inc/cellsuno.hxx
@@ -26,6 +26,7 @@
#include <rtl/ref.hxx>
#include <sal/types.h>
#include <tools/link.hxx>
+#include <svl/itemset.hxx>
#include <svl/lstner.hxx>
#include <svl/listener.hxx>
#include <com/sun/star/table/XTableChartsSupplier.hpp>
@@ -89,6 +90,7 @@
#include <cppuhelper/weakref.hxx>
#include <memory>
+#include <optional>
#include <vector>
namespace com::sun::star::table { struct BorderLine2; }
@@ -112,7 +114,6 @@ class SfxBroadcaster;
class SfxHint;
class SfxItemPropertyMap;
class SfxItemPropertySet;
-class SfxItemSet;
struct SfxItemPropertyMapEntry;
namespace editeng { class SvxBorderLine; }
@@ -181,8 +182,8 @@ private:
std::unique_ptr<ScLinkListener> pValueListener;
std::unique_ptr<ScPatternAttr> pCurrentFlat;
std::unique_ptr<ScPatternAttr> pCurrentDeep;
- std::unique_ptr<SfxItemSet> pCurrentDataSet;
- std::unique_ptr<SfxItemSet> pNoDfltCurrentDataSet;
+ std::optional<SfxItemSet> moCurrentDataSet;
+ std::optional<SfxItemSet> moNoDfltCurrentDataSet;
std::unique_ptr<ScMarkData> pMarkData;
ScRangeList aRanges;
sal_Int64 nObjectId;
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 0d9e076269bc..bab189c43d15 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1432,10 +1432,8 @@ void ScCellRangesBase::ForgetCurrentAttrs()
{
pCurrentFlat.reset();
pCurrentDeep.reset();
- pCurrentDataSet.reset();
- pNoDfltCurrentDataSet.reset();
- pCurrentDataSet = nullptr;
- pNoDfltCurrentDataSet = nullptr;
+ moCurrentDataSet.reset();
+ moNoDfltCurrentDataSet.reset();
// #i62483# pMarkData can remain unchanged, is deleted only if the range changes (RefChanged)
}
@@ -1471,18 +1469,28 @@ const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsDeep()
SfxItemSet* ScCellRangesBase::GetCurrentDataSet(bool bNoDflt)
{
- if(!pCurrentDataSet)
+ if(!moCurrentDataSet)
{
const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
if ( pPattern )
{
// replace Dontcare with Default, so that we always have a reflection
- pCurrentDataSet.reset( new SfxItemSet( pPattern->GetItemSet() ) );
- pNoDfltCurrentDataSet.reset( new SfxItemSet( pPattern->GetItemSet() ) );
- pCurrentDataSet->ClearInvalidItems();
+ moCurrentDataSet.emplace( pPattern->GetItemSet() );
+ moNoDfltCurrentDataSet.emplace( pPattern->GetItemSet() );
+ moCurrentDataSet->ClearInvalidItems();
}
}
- return bNoDflt ? pNoDfltCurrentDataSet.get() : pCurrentDataSet.get();
+ if (bNoDflt)
+ {
+ if (moNoDfltCurrentDataSet)
+ return &*moNoDfltCurrentDataSet;
+ }
+ else
+ {
+ if (moCurrentDataSet)
+ return &*moCurrentDataSet;
+ }
+ return nullptr;
}
const ScMarkData* ScCellRangesBase::GetMarkData()
More information about the Libreoffice-commits
mailing list