sc/inc/document.hxx                 |    2 ++
 sc/source/core/data/clipcontext.cxx |    8 ++------
 sc/source/core/data/column4.cxx     |    5 +----
 sc/source/core/data/documen2.cxx    |   11 +++++++++++
 4 files changed, 16 insertions(+), 10 deletions(-)

New commits:
commit 17b302b092b5c90552720097fe87c8eedc8f83df
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Wed Dec 7 22:05:15 2022 +0100
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Thu Dec 8 12:24:47 2022 +0000

    Related: tdf#120190 Factor out ScDocument::CreateSharedStringTextObject()
    
    Change-Id: I51c1244406e30f5a3893eac42aed65fc92ab1d38
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143805
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index cd7e08b0dde4..20e42a999ac8 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2510,6 +2510,8 @@ public:
     SC_DLLPUBLIC ScFieldEditEngine& GetEditEngine();
     SC_DLLPUBLIC ScNoteEditEngine&  GetNoteEngine();
 
+    std::unique_ptr<EditTextObject> CreateSharedStringTextObject( const 
svl::SharedString& rSS );
+
     std::unique_ptr<ScRefreshTimerControl> const & 
GetRefreshTimerControlAddress() const
                                        { return pRefreshTimerControl; }
 
diff --git a/sc/source/core/data/clipcontext.cxx 
b/sc/source/core/data/clipcontext.cxx
index ee97d315077b..d291c7c91f49 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -253,12 +253,8 @@ void CopyFromClipContext::setSingleCell( const ScAddress& 
rSrcPos, const ScColum
                 // Turn this into a string or edit cell.
                 if (rSrcCell.getFormula()->IsMultilineResult())
                 {
-                    // TODO : Add shared string support to the edit engine to
-                    // make this process simpler.
-                    ScFieldEditEngine& rEngine = mrDestDoc.GetEditEngine();
-                    
rEngine.SetTextCurrentDefaults(rSrcCell.getFormula()->GetString().getString());
-                    std::unique_ptr<EditTextObject> 
pObj(rEngine.CreateTextObject());
-                    pObj->NormalizeString(mrDestDoc.GetSharedStringPool());
+                    std::unique_ptr<EditTextObject> 
pObj(mrDestDoc.CreateSharedStringTextObject(
+                                rSrcCell.getFormula()->GetString()));
                     rSrcCell.set(*pObj);
                 }
                 else
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 83123dffd88b..0de5deff335c 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -501,10 +501,7 @@ public:
             case sc::FormulaResultValue::String:
                 if (aRes.mbMultiLine)
                 {
-                    ScFieldEditEngine& rEngine = mrDoc.GetEditEngine();
-                    rEngine.SetTextCurrentDefaults(aRes.maString.getString());
-                    std::unique_ptr<EditTextObject> 
pObj(rEngine.CreateTextObject());
-                    pObj->NormalizeString(mrDoc.GetSharedStringPool());
+                    std::unique_ptr<EditTextObject> 
pObj(mrDoc.CreateSharedStringTextObject(aRes.maString));
                     maResValues.setValue(nRow, std::move(pObj));
                 }
                 else
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index af4629d7aef3..e21da4be599b 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -511,6 +511,17 @@ ScNoteEditEngine& ScDocument::GetNoteEngine()
     return *mpNoteEngine;
 }
 
+std::unique_ptr<EditTextObject> ScDocument::CreateSharedStringTextObject( 
const svl::SharedString& rSS )
+{
+    /* TODO: Add shared string support to the edit engine to make this process
+     * simpler. */
+    ScFieldEditEngine& rEngine = GetEditEngine();
+    rEngine.SetTextCurrentDefaults( rSS.getString());
+    std::unique_ptr<EditTextObject> pObj( rEngine.CreateTextObject());
+    pObj->NormalizeString( GetSharedStringPool());
+    return pObj;
+}
+
 void ScDocument::ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks )
 {
     if (bIsClip)

Reply via email to