sc/inc/postit.hxx              |    5 +++++
 sc/source/core/data/postit.cxx |   41 +++++++++++++++++++++++++----------------
 2 files changed, 30 insertions(+), 16 deletions(-)

New commits:
commit ac40c3923580e4ec0e738d57ff8b885da93301ef
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri Aug 11 13:08:36 2023 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Aug 11 18:14:15 2023 +0200

    split out a common CreateNoteData
    
    Change-Id: Ieeaf50f3a086d01b5492eb3ab9b211f132f045ac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155611
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index 92602e5150ac..c6ac3b5a4bd4 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -178,6 +178,9 @@ class SC_DLLPUBLIC ScNoteUtil
 {
     static ScPostIt* InsertNote(ScDocument& rDoc, const ScAddress& rPos, 
ScNoteData&& rNoteData,
                                 bool bAlwaysCreateCaption, sal_uInt32 
nPostItId);
+
+    static ScNoteData CreateNoteData(ScDocument& rDoc, const ScAddress& rPos, 
const OutlinerParaObject& rOutlinerObj,
+                                     const tools::Rectangle& rCaptionRect, 
bool bShown);
 public:
 
     /** Creates and returns a caption object for a temporary caption. */
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 8fa13927d3d9..378323338eb1 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -929,17 +929,13 @@ ScPostIt* ScNoteUtil::CreateNoteFromCaption(
     return pNote;
 }
 
-ScPostIt* ScNoteUtil::CreateNoteFromObjectData(
-        ScDocument& rDoc, const ScAddress& rPos, SfxItemSet&& rItemSet, const 
OUString& rStyleName,
-        const OutlinerParaObject& rOutlinerObj, const tools::Rectangle& 
rCaptionRect,
-        bool bShown )
+ScNoteData ScNoteUtil::CreateNoteData(ScDocument& rDoc, const ScAddress& rPos, 
const OutlinerParaObject& rOutlinerObj,
+                                      const tools::Rectangle& rCaptionRect, 
bool bShown)
 {
     ScNoteData aNoteData( bShown );
     aNoteData.mxInitData = std::make_shared<ScCaptionInitData>();
     ScCaptionInitData& rInitData = *aNoteData.mxInitData;
-    rInitData.moItemSet.emplace(std::move(rItemSet));
     rInitData.mxOutlinerObj = rOutlinerObj;
-    rInitData.maStyleName = 
ScStyleNameConversion::ProgrammaticToDisplayName(rStyleName, 
SfxStyleFamily::Frame);
 
     // convert absolute caption position to relative position
     rInitData.mbDefaultPosSize = rCaptionRect.IsEmpty();
@@ -952,6 +948,19 @@ ScPostIt* ScNoteUtil::CreateNoteFromObjectData(
         rInitData.maCaptionSize = rCaptionRect.GetSize();
     }
 
+    return aNoteData;
+}
+
+ScPostIt* ScNoteUtil::CreateNoteFromObjectData(
+        ScDocument& rDoc, const ScAddress& rPos, SfxItemSet&& rItemSet, const 
OUString& rStyleName,
+        const OutlinerParaObject& rOutlinerObj, const tools::Rectangle& 
rCaptionRect,
+        bool bShown )
+{
+    ScNoteData aNoteData(CreateNoteData(rDoc, rPos, rOutlinerObj, 
rCaptionRect, bShown));
+    ScCaptionInitData& rInitData = *aNoteData.mxInitData;
+    rInitData.moItemSet.emplace(std::move(rItemSet));
+    rInitData.maStyleName = 
ScStyleNameConversion::ProgrammaticToDisplayName(rStyleName, 
SfxStyleFamily::Frame);
+
     return InsertNote(rDoc, rPos, std::move(aNoteData), 
/*bAlwaysCreateCaption*/false, 0/*nPostItId*/);
 }
 
commit 5ae486eea7a381403a9f81e5aa8ef1a0a57b95b6
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri Aug 11 13:01:17 2023 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Aug 11 18:14:05 2023 +0200

    split out common ScPostIt insertion piece
    
    Change-Id: Ie9d718293f907e19e29ed6f8aea4a2bf9d88dfe9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155610
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index 828d094e49d1..92602e5150ac 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -176,6 +176,8 @@ private:
 
 class SC_DLLPUBLIC ScNoteUtil
 {
+    static ScPostIt* InsertNote(ScDocument& rDoc, const ScAddress& rPos, 
ScNoteData&& rNoteData,
+                                bool bAlwaysCreateCaption, sal_uInt32 
nPostItId);
 public:
 
     /** Creates and returns a caption object for a temporary caption. */
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index cbb2eff1ff14..8fa13927d3d9 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -23,8 +23,8 @@
 #include <rtl/ustrbuf.hxx>
 #include <sal/log.hxx>
 #include <unotools/useroptions.hxx>
-#include <svx/svdpage.hxx>
 #include <svx/svdocapt.hxx>
+#include <svx/svdpage.hxx>
 #include <editeng/outlobj.hxx>
 #include <editeng/editobj.hxx>
 #include <basegfx/polygon/b2dpolygon.hxx>
@@ -952,13 +952,18 @@ ScPostIt* ScNoteUtil::CreateNoteFromObjectData(
         rInitData.maCaptionSize = rCaptionRect.GetSize();
     }
 
+    return InsertNote(rDoc, rPos, std::move(aNoteData), 
/*bAlwaysCreateCaption*/false, 0/*nPostItId*/);
+}
+
+ScPostIt* ScNoteUtil::InsertNote(ScDocument& rDoc, const ScAddress& rPos, 
ScNoteData&& rNoteData,
+                                 bool bAlwaysCreateCaption, sal_uInt32 
nPostItId)
+{
     /*  Create the note and insert it into the document. If the note is
         visible, the caption object will be created automatically. */
-    ScPostIt* pNote = new ScPostIt( rDoc, rPos, std::move(aNoteData), 
/*bAlwaysCreateCaption*/false, 0/*nPostItId*/ );
+    ScPostIt* pNote = new ScPostIt( rDoc, rPos, std::move(rNoteData), 
bAlwaysCreateCaption, nPostItId );
     pNote->AutoStamp();
-
+    //insert takes ownership
     rDoc.SetNote(rPos, std::unique_ptr<ScPostIt>(pNote));
-
     return pNote;
 }
 
@@ -976,12 +981,7 @@ ScPostIt* ScNoteUtil::CreateNoteFromString(
         rInitData.maStyleName = ScResId(STR_STYLENAME_NOTE);
         rInitData.mbDefaultPosSize = true;
 
-        /*  Create the note and insert it into the document. If the note is
-            visible, the caption object will be created automatically. */
-        pNote = new ScPostIt( rDoc, rPos, std::move(aNoteData), 
bAlwaysCreateCaption, nPostItId );
-        pNote->AutoStamp();
-        //insert takes ownership
-        rDoc.SetNote(rPos, std::unique_ptr<ScPostIt>(pNote));
+        pNote = InsertNote(rDoc, rPos, std::move(aNoteData), 
bAlwaysCreateCaption, nPostItId);
     }
     return pNote;
 }

Reply via email to