diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-08-08 18:55:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-08-10 16:28:10 +0200 |
commit | b55180df249fe9a2efa145142a9c1ed7c51be849 (patch) | |
tree | 869c498b1b0e7fcf0c83daaa9374d941701c40e0 /sw | |
parent | b099798085e7b883974928e06644a03ef98cea58 (diff) |
unique_ptr->optional in SwInsertField_Data
Change-Id: Ifcf9cf2b3f731737e12c5316e4fa584cc47fce36
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138076
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/fldui/fldmgr.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/inc/fldmgr.hxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/wrtsh/wrtsh1.cxx | 4 |
3 files changed, 7 insertions, 6 deletions
diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 7a860203f63d..ec544bca99ac 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -893,7 +893,7 @@ SwFieldTypesEnum SwFieldMgr::GetCurTypeId() const // Over string insert field or update bool SwFieldMgr::InsertField( - const SwInsertField_Data& rData) + SwInsertField_Data& rData) { std::unique_ptr<SwField> pField; bool bExp = false; @@ -1487,7 +1487,7 @@ bool SwFieldMgr::InsertField( // insert pCurShell->StartAllAction(); - bool const isSuccess = pCurShell->InsertField2(*pField, rData.m_pAnnotationRange.get()); + bool const isSuccess = pCurShell->InsertField2(*pField, rData.m_oAnnotationRange ? &*rData.m_oAnnotationRange : nullptr); if (isSuccess) { diff --git a/sw/source/uibase/inc/fldmgr.hxx b/sw/source/uibase/inc/fldmgr.hxx index 8c1a9d5918cc..c62d5cb00c97 100644 --- a/sw/source/uibase/inc/fldmgr.hxx +++ b/sw/source/uibase/inc/fldmgr.hxx @@ -25,6 +25,7 @@ #include <com/sun/star/uno/Reference.h> #include <com/sun/star/uno/Any.h> #include <memory> +#include <optional> #include <vector> namespace com::sun::star{ @@ -80,7 +81,7 @@ struct SwInsertField_Data css::uno::Any m_aDBColumn; weld::Widget* m_pParent; // parent widget used for SwWrtShell::StartInputFieldDlg() /// Marks the PostIt field's annotation start/end if it differs from the cursor selection. - std::unique_ptr<SwPaM> m_pAnnotationRange; + std::optional<SwPaM> m_oAnnotationRange; SwInsertField_Data(SwFieldTypesEnum nType, sal_uInt16 nSub, const OUString& rPar1, const OUString& rPar2, sal_uInt32 nFormatId, SwWrtShell* pShell = nullptr, sal_Unicode cSep = ' ', bool bIsAutoLanguage = true) : @@ -123,7 +124,7 @@ public: { m_pWrtShell = pShell; } // insert field using TypeID (TYP_ ...) - bool InsertField( const SwInsertField_Data& rData ); + bool InsertField( SwInsertField_Data& rData ); // change the current field directly void UpdateCurField(sal_uInt32 nFormat, diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index d61cb158c93f..805ec71f61d8 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -2276,8 +2276,8 @@ void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, const SfxRequest& rReq) } else if (pFormat && pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_CHAR) { - aData.m_pAnnotationRange.reset(new SwPaM(*GetCurrentShellCursor().Start(), - *GetCurrentShellCursor().End())); + aData.m_oAnnotationRange.emplace(*GetCurrentShellCursor().Start(), + *GetCurrentShellCursor().End()); } } } |