summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-28 15:35:25 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-29 19:23:44 +0200
commit66438a0ad5a3c6d2792f4c6c04c2d2405b5679cb (patch)
tree29eb826ce08a4e4f691b8306d9af968396e7b56c /sw/source/core
parent397ba047c941eb7d77a15a8de72e20ace4744da1 (diff)
std::unique_ptr->std::optional
Change-Id: Ie09ede2ce21c206ca158a5a89d50143cdde45e3e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116381 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx4
-rw-r--r--sw/source/core/undo/untblk.cxx6
-rw-r--r--sw/source/core/unocore/unostyle.cxx20
3 files changed, 15 insertions, 15 deletions
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 254d0fc00085..c5313a093470 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4732,7 +4732,7 @@ bool DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
std::shared_ptr<SwUnoCursor> const pCopyPam(rDoc.CreateUnoCursor(rPos));
SwTableNumFormatMerge aTNFM( m_rDoc, rDoc );
- std::unique_ptr<std::vector<SwFrameFormat*>> pFlys;
+ std::optional<std::vector<SwFrameFormat*>> pFlys;
std::vector<SwFrameFormat*> const* pFlysAtInsPos;
if (rDoc.GetIDocumentUndoRedo().DoesUndo())
@@ -4743,7 +4743,7 @@ bool DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
else
{
pFlys = sw::GetFlysAnchoredAt(rDoc, rPos.nNode.GetIndex());
- pFlysAtInsPos = pFlys.get();
+ pFlysAtInsPos = pFlys ? &*pFlys : nullptr;
}
RedlineFlags eOld = rDoc.getIDocumentRedlineAccess().GetRedlineFlags();
diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx
index 5fd92fe63eca..fc30657333b9 100644
--- a/sw/source/core/undo/untblk.cxx
+++ b/sw/source/core/undo/untblk.cxx
@@ -36,10 +36,10 @@
namespace sw {
-std::unique_ptr<std::vector<SwFrameFormat*>>
+std::optional<std::vector<SwFrameFormat*>>
GetFlysAnchoredAt(SwDoc & rDoc, sal_uLong const nSttNode)
{
- std::unique_ptr<std::vector<SwFrameFormat*>> pFrameFormats;
+ std::optional<std::vector<SwFrameFormat*>> pFrameFormats;
const size_t nArrLen = rDoc.GetSpzFrameFormats()->size();
for (size_t n = 0; n < nArrLen; ++n)
{
@@ -52,7 +52,7 @@ GetFlysAnchoredAt(SwDoc & rDoc, sal_uLong const nSttNode)
|| (pAnchor->GetAnchorId() == RndStdIds::FLY_AT_CHAR)))
{
if (!pFrameFormats)
- pFrameFormats.reset( new std::vector<SwFrameFormat*> );
+ pFrameFormats.emplace();
pFrameFormats->push_back( pFormat );
}
}
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 6633906e5346..ac72abefd161 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1899,10 +1899,10 @@ void SwXStyle::SetPropertyValue<FN_UNO_CATEGORY>(const SfxItemPropertyMapEntry&,
{
if(!o_rStyleBase.getNewBase()->IsUserDefined() || !rValue.has<paragraphstyle_t>())
throw lang::IllegalArgumentException();
- static std::unique_ptr<std::map<paragraphstyle_t, SfxStyleSearchBits>> pUnoToCore;
+ static std::optional<std::map<paragraphstyle_t, SfxStyleSearchBits>> pUnoToCore;
if(!pUnoToCore)
{
- pUnoToCore.reset(new std::map<paragraphstyle_t, SfxStyleSearchBits>);
+ pUnoToCore.emplace();
auto pEntries = lcl_GetParagraphStyleCategoryEntries();
std::transform(pEntries->begin(), pEntries->end(), std::inserter(*pUnoToCore, pUnoToCore->end()),
[] (const ParagraphStyleCategoryEntry& rEntry) { return std::pair<paragraphstyle_t, SfxStyleSearchBits>(rEntry.m_eCategory, rEntry.m_nSwStyleBits); });
@@ -2003,10 +2003,10 @@ void SwXStyle::SetStyleProperty(const SfxItemPropertyMapEntry& rEntry, const Sfx
{
using propertytype_t = decltype(rEntry.nWID);
using coresetter_t = std::function<void(SwXStyle&, const SfxItemPropertyMapEntry&, const SfxItemPropertySet&, const uno::Any&, SwStyleBase_Impl&)>;
- static std::unique_ptr<std::map<propertytype_t, coresetter_t>> pUnoToCore;
+ static std::optional<std::map<propertytype_t, coresetter_t>> pUnoToCore;
if(!pUnoToCore)
{
- pUnoToCore.reset(new std::map<propertytype_t, coresetter_t> {
+ pUnoToCore = std::map<propertytype_t, coresetter_t> {
// these explicit std::mem_fn() calls shouldn't be needed, but apparently MSVC is currently too stupid for C++11 again
{ FN_UNO_HIDDEN, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_HIDDEN>) },
{ FN_UNO_STYLE_INTEROP_GRAB_BAG, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_STYLE_INTEROP_GRAB_BAG>) },
@@ -2029,7 +2029,7 @@ void SwXStyle::SetStyleProperty(const SfxItemPropertyMapEntry& rEntry, const Sfx
{ RES_TXTATR_CJK_RUBY, std::mem_fn(&SwXStyle::SetPropertyValue<sal_uInt16(RES_TXTATR_CJK_RUBY)>) },
{ RES_PARATR_DROP, std::mem_fn(&SwXStyle::SetPropertyValue<sal_uInt16(RES_PARATR_DROP)>) },
{ RES_PARATR_NUMRULE, std::mem_fn(&SwXStyle::SetPropertyValue<sal_uInt16(RES_PARATR_NUMRULE)>) }
- });
+ };
}
const auto pUnoToCoreIt(pUnoToCore->find(rEntry.nWID));
if(pUnoToCoreIt != pUnoToCore->end())
@@ -2262,10 +2262,10 @@ template<>
uno::Any SwXStyle::GetStyleProperty<FN_UNO_CATEGORY>(const SfxItemPropertyMapEntry&, const SfxItemPropertySet&, SwStyleBase_Impl& rBase)
{
PrepareStyleBase(rBase);
- static std::unique_ptr<std::map<collectionbits_t, paragraphstyle_t>> pUnoToCore;
+ static std::optional<std::map<collectionbits_t, paragraphstyle_t>> pUnoToCore;
if(!pUnoToCore)
{
- pUnoToCore.reset(new std::map<collectionbits_t, paragraphstyle_t>);
+ pUnoToCore.emplace();
auto pEntries = lcl_GetParagraphStyleCategoryEntries();
std::transform(pEntries->begin(), pEntries->end(), std::inserter(*pUnoToCore, pUnoToCore->end()),
[] (const ParagraphStyleCategoryEntry& rEntry) { return std::pair<collectionbits_t, paragraphstyle_t>(rEntry.m_nCollectionBits, rEntry.m_eCategory); });
@@ -2343,10 +2343,10 @@ uno::Any SwXStyle::GetStyleProperty_Impl(const SfxItemPropertyMapEntry& rEntry,
{
using propertytype_t = decltype(rEntry.nWID);
using coresetter_t = std::function<uno::Any(SwXStyle&, const SfxItemPropertyMapEntry&, const SfxItemPropertySet&, SwStyleBase_Impl&)>;
- static std::unique_ptr<std::map<propertytype_t, coresetter_t>> pUnoToCore;
+ static std::optional<std::map<propertytype_t, coresetter_t>> pUnoToCore;
if(!pUnoToCore)
{
- pUnoToCore.reset(new std::map<propertytype_t, coresetter_t> {
+ pUnoToCore = std::map<propertytype_t, coresetter_t> {
// these explicit std::mem_fn() calls shouldn't be needed, but apparently MSVC is currently too stupid for C++11 again
{ FN_UNO_IS_PHYSICAL, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_IS_PHYSICAL>) },
{ FN_UNO_HIDDEN, std::mem_fn(&SwXStyle::GetStyleProperty<FN_UNO_HIDDEN>) },
@@ -2363,7 +2363,7 @@ uno::Any SwXStyle::GetStyleProperty_Impl(const SfxItemPropertyMapEntry& rEntry,
{ SID_SWREGISTER_COLLECTION, std::mem_fn(&SwXStyle::GetStyleProperty<SID_SWREGISTER_COLLECTION>) },
{ RES_BACKGROUND, std::mem_fn(&SwXStyle::GetStyleProperty<sal_uInt16(RES_BACKGROUND)>) },
{ OWN_ATTR_FILLBMP_MODE, std::mem_fn(&SwXStyle::GetStyleProperty<OWN_ATTR_FILLBMP_MODE>) }
- });
+ };
}
const auto pUnoToCoreIt(pUnoToCore->find(rEntry.nWID));
if(pUnoToCoreIt != pUnoToCore->end())