sw/source/uibase/fldui/fldmgr.cxx |    4 ++--
 sw/source/uibase/inc/fldmgr.hxx   |    5 +++--
 sw/source/uibase/wrtsh/wrtsh1.cxx |    4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)

New commits:
commit b55180df249fe9a2efa145142a9c1ed7c51be849
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Mon Aug 8 18:55:46 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Aug 10 16:28:10 2022 +0200

    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.gran...@collabora.co.uk>

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());
                 }
             }
         }

Reply via email to