[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/inc sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Tue Mar 19 09:52:17 PDT 2013


 sc/inc/column.hxx                        |    4 ++
 sc/inc/document.hxx                      |   15 +++++++++-
 sc/inc/table.hxx                         |    5 ++-
 sc/source/core/data/column3.cxx          |    4 ++
 sc/source/core/data/document.cxx         |   17 +++++++++++
 sc/source/core/data/table2.cxx           |   11 +++++++
 sc/source/core/data/table6.cxx           |    6 +++-
 sc/source/filter/excel/excimp8.cxx       |    5 ++-
 sc/source/filter/excel/impop.cxx         |    6 +---
 sc/source/filter/excel/xicontent.cxx     |   11 -------
 sc/source/filter/excel/xihelper.cxx      |   44 ++++++++++++++++++++-----------
 sc/source/filter/inc/xicontent.hxx       |    4 --
 sc/source/filter/inc/xihelper.hxx        |   10 ++-----
 sc/source/filter/oox/worksheethelper.cxx |    3 --
 sc/source/filter/rtf/eeimpars.cxx        |   14 ++++-----
 sc/source/filter/xml/xmlcelli.cxx        |    4 +-
 sc/source/ui/app/transobj.cxx            |   10 +++++--
 sc/source/ui/docshell/impex.cxx          |    4 ++
 sc/source/ui/inc/anyrefdg.hxx            |    2 -
 sc/source/ui/inc/formula.hxx             |    1 
 sc/source/ui/miscdlgs/anyrefdg.cxx       |    1 
 sc/source/ui/undo/undoblk3.cxx           |    7 ++++
 sc/source/ui/unoobj/cellsuno.cxx         |    2 -
 sc/source/ui/view/viewfun4.cxx           |    5 +--
 24 files changed, 128 insertions(+), 67 deletions(-)

New commits:
commit b37e1ae79a1f259350d95950ae23df4423b47916
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Mar 19 12:51:47 2013 -0400

    Remove use of ScBaseCell and its derivatives outside ScDocument.
    
    This is still work in progress.
    
    Change-Id: Ifcdbefbdd307a2a8819b073d896e90a16980781e

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 4776a70..d8e4a38 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -257,10 +257,12 @@ public:
 
     bool               HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW& rFirst) const;
 
-                //     TRUE = format for numbers is set
     bool SetString(
         SCROW nRow, SCTAB nTab, const String& rString, formula::FormulaGrammar::AddressConvention eConv,
         ScSetStringParam* pParam = NULL );
+
+    void SetEditText( SCROW nRow, EditTextObject* pEditText );
+
     void        SetValue( SCROW nRow, const double& rVal);
     void        SetError( SCROW nRow, const sal_uInt16 nError);
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 98b21eb..91e003e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -750,7 +750,18 @@ public:
     SC_DLLPUBLIC bool           SetString(
         SCCOL nCol, SCROW nRow, SCTAB nTab, const rtl::OUString& rString,
         ScSetStringParam* pParam = NULL );
-    bool SetString( const ScAddress& rPos, const OUString& rString, ScSetStringParam* pParam = NULL );
+    SC_DLLPUBLIC bool SetString( const ScAddress& rPos, const OUString& rString, ScSetStringParam* pParam = NULL );
+
+    /**
+     * This method manages the lifecycle of the passed edit text object. When
+     * the text is successfully inserted, the cell takes over the ownership of
+     * the text object. If not, the text object gets deleted.
+     *
+     * <p>The caller must ensure that the passed edit text object <i>uses the
+     * SfxItemPool instance returned from ScDocument::GetEditPool()</i>.
+     * This is very important.</p>
+     */
+    SC_DLLPUBLIC void SetEditText( const ScAddress& rPos, EditTextObject* pEditText );
 
     SC_DLLPUBLIC void           SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal );
     void            SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const sal_uInt16 nError);
@@ -1875,6 +1886,8 @@ private: // CLOOK-Impl-methods
         ScDocument* mpDoc;
     };
 
+    bool TableExists( SCTAB nTab ) const;
+
     void    MergeNumberFormatter(ScDocument* pSrcDoc);
 
     void    ImplCreateOptions(); // Suggestion: switch to on-demand?
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 036dcca..990b0fc 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -299,9 +299,12 @@ public:
     void        PutCell( const ScAddress&, ScBaseCell* pCell );
     void        PutCell( SCCOL nCol, SCROW nRow, ScBaseCell* pCell );
     void        PutCell(SCCOL nCol, SCROW nRow, sal_uLong nFormatIndex, ScBaseCell* pCell);
-                //  TRUE = numberformat set
+
     bool        SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString,
                            ScSetStringParam* pParam = NULL );
+
+    void SetEditText( SCCOL nCol, SCROW nRow, EditTextObject* pEditText );
+
     void        SetValue( SCCOL nCol, SCROW nRow, const double& rVal );
     void        SetError( SCCOL nCol, SCROW nRow, sal_uInt16 nError);
 
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index fb6c212..4397834 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1490,6 +1490,10 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
     return bNumFmtSet;
 }
 
+void ScColumn::SetEditText( SCROW nRow, EditTextObject* pEditText )
+{
+    Insert(nRow, new ScEditCell(pEditText, pDocument));
+}
 
 void ScColumn::GetFilterEntries(SCROW nStartRow, SCROW nEndRow, std::vector<ScTypedStrData>& rStrings, bool& rHasDates)
 {
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 90f90ce..1065181 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -22,6 +22,7 @@
 
 #include <editeng/boxitem.hxx>
 #include <editeng/frmdiritem.hxx>
+#include "editeng/editobj.hxx"
 #include <svx/pageitem.hxx>
 #include <editeng/editeng.hxx>
 #include <svx/svditer.hxx>
@@ -2158,6 +2159,11 @@ ScDocument::NumFmtMergeHandler::~NumFmtMergeHandler()
     mpDoc->pFormatExchangeList = NULL;
 }
 
+bool ScDocument::TableExists( SCTAB nTab ) const
+{
+    return ValidTab(nTab) && static_cast<size_t>(nTab) < maTabs.size() && maTabs[nTab];
+}
+
 void ScDocument::MergeNumberFormatter(ScDocument* pSrcDoc)
 {
     SvNumberFormatter* pThisFormatter = xPoolHelper->GetFormTable();
@@ -2962,6 +2968,17 @@ bool ScDocument::SetString(
     return SetString(rPos.Col(), rPos.Row(), rPos.Tab(), rString, pParam);
 }
 
+void ScDocument::SetEditText( const ScAddress& rPos, EditTextObject* pEditText )
+{
+    if (!TableExists(rPos.Tab()))
+    {
+        delete pEditText;
+        return;
+    }
+
+    maTabs[rPos.Tab()]->SetEditText(rPos.Col(), rPos.Row(), pEditText);
+}
+
 void ScDocument::SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal )
 {
     if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()))
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 9acc677..32b11dd 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -19,6 +19,7 @@
 
 #include "scitems.hxx"
 #include <editeng/boxitem.hxx>
+#include "editeng/editobj.hxx"
 #include <svl/poolcach.hxx>
 #include <unotools/charclass.hxx>
 #include <math.h>
@@ -1322,6 +1323,16 @@ bool ScTable::SetString( SCCOL nCol, SCROW nRow, SCTAB nTabP, const String& rStr
         return false;
 }
 
+void ScTable::SetEditText( SCCOL nCol, SCROW nRow, EditTextObject* pEditText )
+{
+    if (!ValidColRow(nCol, nRow))
+    {
+        delete pEditText;
+        return;
+    }
+
+    aCol[nCol].SetEditText(nRow, pEditText);
+}
 
 void ScTable::SetValue( SCCOL nCol, SCROW nRow, const double& rVal )
 {
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index f4a5d25..640ed59 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -222,7 +222,11 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRo
                 aCol[nCol].Insert( nRow, pFCell );
             }
             else if ( bMultiLine && aString.indexOf('\n') != -1 )
-                PutCell( nCol, nRow, new ScEditCell( aString, pDocument ) );
+            {
+                ScFieldEditEngine& rEngine = pDocument->GetEditEngine();
+                rEngine.SetText(aString);
+                SetEditText(nCol, nRow, rEngine.CreateTextObject());
+            }
             else
                 aCol[nCol].SetString(nRow, nTab, aString, pDocument->GetAddressConvention());
             // pCell is invalid now (deleted)
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index 5285247..68ceed5 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -296,8 +296,9 @@ void ImportExcel8::Labelsst( void )
     if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
     {
         GetXFRangeBuffer().SetXF( aScPos, nXF );
-        if( ScBaseCell* pCell = GetSst().CreateCell( nSst, nXF ) )
-            GetDoc().PutCell( aScPos.Col(), aScPos.Row(), aScPos.Tab(), pCell );
+        const XclImpString* pXclStr = GetSst().GetString(nSst);
+        if (pXclStr)
+            XclImpStringHelper::SetToDocument(GetDoc(), aScPos, *this, *pXclStr, nXF);
     }
 }
 
diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index 8e62e5d..f6ed980 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -338,8 +338,7 @@ void ImportExcel::ReadLabel()
         SetTextEncoding( eOldTextEnc );
 
         GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
-        if( ScBaseCell* pCell = XclImpStringHelper::CreateCell( GetRoot(), aString, nXFIdx ) )
-            GetDoc().PutCell( aScPos, pCell );
+        XclImpStringHelper::SetToDocument(GetDoc(), aScPos, GetRoot(), aString, nXFIdx);
     }
 }
 
@@ -902,8 +901,7 @@ void ImportExcel::Rstring( void )
             aString.ReadFormats( maStrm );
 
         GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
-        if( ScBaseCell* pCell = XclImpStringHelper::CreateCell( *this, aString, nXFIdx ) )
-            GetDoc().PutCell( aScPos, pCell );
+        XclImpStringHelper::SetToDocument(GetDoc(), aScPos, *this, aString, nXFIdx);
     }
 }
 
diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx
index de6fd13..86ed9de 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -91,14 +91,6 @@ const XclImpString* XclImpSst::GetString( sal_uInt32 nSstIndex ) const
     return (nSstIndex < maStrings.size()) ? &maStrings[ nSstIndex ] : 0;
 }
 
-ScBaseCell* XclImpSst::CreateCell( sal_uInt32 nSstIndex, sal_uInt16 nXFIndex ) const
-{
-    ScBaseCell* pCell = 0;
-    if( const XclImpString* pString = GetString( nSstIndex ) )
-        pCell = XclImpStringHelper::CreateCell( *this, *pString, nXFIndex );
-    return pCell;
-}
-
 // Hyperlinks =================================================================
 
 namespace {
@@ -197,8 +189,7 @@ void lclInsertUrl( const XclImpRoot& rRoot, const String& rUrl, SCCOL nScCol, SC
             }
 
             // The cell will own the text object instance.
-            ScEditCell* pCell = new ScEditCell(rEE.CreateTextObject(), &rDoc);
-            rDoc.PutCell( aScPos, pCell );
+            rDoc.SetEditText(aScPos, rEE.CreateTextObject());
         }
         break;
 
diff --git a/sc/source/filter/excel/xihelper.cxx b/sc/source/filter/excel/xihelper.cxx
index ef840f9..4f114a9 100644
--- a/sc/source/filter/excel/xihelper.cxx
+++ b/sc/source/filter/excel/xihelper.cxx
@@ -25,15 +25,14 @@
 #include <editeng/eeitem.hxx>
 #include <editeng/flditem.hxx>
 #include "document.hxx"
-#include "cell.hxx"
 #include "rangelst.hxx"
 #include "editutil.hxx"
 #include "attrib.hxx"
 #include "xltracer.hxx"
 #include "xistream.hxx"
 #include "xistyle.hxx"
-
 #include "excform.hxx"
+#include "stringutil.hxx"
 
 // Excel->Calc cell address/range conversion ==================================
 
@@ -220,24 +219,39 @@ EditTextObject* XclImpStringHelper::CreateTextObject(
     return lclCreateTextObject( rRoot, rString, EXC_FONTITEM_EDITENG, 0 );
 }
 
-ScBaseCell* XclImpStringHelper::CreateCell(
-        const XclImpRoot& rRoot, const XclImpString& rString, sal_uInt16 nXFIndex )
+void XclImpStringHelper::SetToDocument(
+        ScDocument& rDoc, const ScAddress& rPos, const XclImpRoot& rRoot,
+        const XclImpString& rString, sal_uInt16 nXFIndex )
 {
-    ScBaseCell* pCell = 0;
+    if (!rString.GetText().Len())
+        return;
 
-    if( rString.GetText().Len() )
-    {
-        ::std::auto_ptr< EditTextObject > pTextObj( lclCreateTextObject( rRoot, rString, EXC_FONTITEM_EDITENG, nXFIndex ) );
-        ScDocument& rDoc = rRoot.GetDoc();
+    ::std::auto_ptr< EditTextObject > pTextObj( lclCreateTextObject( rRoot, rString, EXC_FONTITEM_EDITENG, nXFIndex ) );
 
-        if( pTextObj.get() )
-            // ScEditCell will own the text object instance.
-            pCell = new ScEditCell(pTextObj.release(), &rDoc);
+    if (pTextObj.get())
+    {
+        rDoc.SetEditText(rPos, pTextObj.release());
+    }
+    else
+    {
+        OUString aStr = rString.GetText();
+        if (aStr.indexOf('\n') != -1 || aStr.indexOf(CHAR_CR) != -1)
+        {
+            // Multiline content.
+            ScFieldEditEngine& rEngine = rDoc.GetEditEngine();
+            rEngine.SetText(aStr);
+            rDoc.SetEditText(rPos, rEngine.CreateTextObject());
+        }
         else
-            pCell = ScBaseCell::CreateTextCell( rString.GetText(), &rDoc );
+        {
+            // Normal text cell.
+            ScSetStringParam aParam;
+            aParam.mbDetectNumberFormat = false;
+            aParam.mbHandleApostrophe = false;
+            aParam.meSetTextNumFormat = ScSetStringParam::Always;
+            rDoc.SetString(rPos, aStr, &aParam);
+        }
     }
-
-    return pCell;
 }
 
 // Header/footer conversion ===================================================
diff --git a/sc/source/filter/inc/xicontent.hxx b/sc/source/filter/inc/xicontent.hxx
index f4128ad..c5d7aae 100644
--- a/sc/source/filter/inc/xicontent.hxx
+++ b/sc/source/filter/inc/xicontent.hxx
@@ -64,10 +64,6 @@ public:
     /** Returns a pointer to the string with the passed index. */
     const XclImpString* GetString( sal_uInt32 nSstIndex ) const;
 
-    /** Creates a new text cell or edit cell for a Calc document.
-        @param nXFIndex  Index to XF for first text portion (checks escapement). */
-    ScBaseCell*         CreateCell( sal_uInt32 nSstIndex, sal_uInt16 nXFIndex = 0 ) const;
-
 private:
     typedef ::std::vector< XclImpString > XclImpStringVec;
     XclImpStringVec     maStrings;          /// List with all strings in the SST.
diff --git a/sc/source/filter/inc/xihelper.hxx b/sc/source/filter/inc/xihelper.hxx
index 8917a7d..84eb924 100644
--- a/sc/source/filter/inc/xihelper.hxx
+++ b/sc/source/filter/inc/xihelper.hxx
@@ -109,12 +109,10 @@ public:
                             const XclImpRoot& rRoot,
                             const XclImpString& rString );
 
-    /** Creates a new text cell or edit cell for a Calc document.
-        @param nXFIndex  Index to XF for first text portion (for escapement). */
-    static ScBaseCell*  CreateCell(
-                            const XclImpRoot& rRoot,
-                            const XclImpString& rString,
-                            sal_uInt16 nXFIndex = 0 );
+    static void SetToDocument(
+        ScDocument& rDoc, const ScAddress& rPos, const XclImpRoot& rRoot,
+        const XclImpString& rString, sal_uInt16 nXFIndex = 0 );
+
 private:
     /** We don't want anybody to instantiate this class, since it is just a
         collection of static methods. To enforce this, the default constructor
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx
index 3f93056..c83e3c0 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -1572,10 +1572,9 @@ void WorksheetHelper::putRichString( const CellAddress& rAddress, const RichStri
     ScEditEngineDefaulter& rEE = getEditEngine();
 
     // The cell will own the text object instance returned from convert().
-    ScBaseCell* pNewCell = new ScEditCell(rString.convert(rEE, pFirstPortionFont), &rDoc);
     ScAddress aAddress;
     ScUnoConversion::FillScAddress( aAddress, rAddress );
-    rDoc.PutCell( aAddress, pNewCell );
+    rDoc.SetEditText(aAddress, rString.convert(rEE, pFirstPortionFont));
 }
 
 void WorksheetHelper::putFormulaTokens( const CellAddress& rAddress, const ApiTokenSequence& rTokens ) const
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index 5e3dd69..23a4c3c 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -47,7 +47,6 @@
 #include "docpool.hxx"
 #include "attrib.hxx"
 #include "patattr.hxx"
-#include "cell.hxx"
 #include "eeparser.hxx"
 #include "drwlayer.hxx"
 #include "rangenam.hxx"
@@ -386,19 +385,20 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu
                     aStr.SearchAndReplaceAll( (sal_Unicode)'\n', (sal_Unicode)' ' );
 
                     if (bTextFormat)
-                        mpDoc->PutCell( nCol, nRow, nTab, new ScStringCell( aStr));
-                    else
                     {
-                        aParam.mbDetectNumberFormat = bConvertDate;
-                        mpDoc->SetString( nCol, nRow, nTab, aStr, &aParam );
+                        aParam.mbDetectNumberFormat = false;
+                        aParam.meSetTextNumFormat = ScSetStringParam::Always;
                     }
+                    else
+                        aParam.mbDetectNumberFormat = bConvertDate;
+
+                    mpDoc->SetString(nCol, nRow, nTab, aStr, &aParam);
                 }
             }
             else
             {
                 // The cell will own the text object instance.
-                mpDoc->PutCell(
-                    nCol, nRow, nTab, new ScEditCell(mpEngine->CreateTextObject(pE->aSel), mpDoc));
+                mpDoc->SetEditText(ScAddress(nCol,nRow,nTab), mpEngine->CreateTextObject(pE->aSel));
             }
             if ( pE->maImageList.size() )
                 bHasGraphics |= GraphicSize( nCol, nRow, nTab, pE );
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 7126f14..19b9041 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1053,14 +1053,14 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
                 // This edit engine uses the SfxItemPool instance returned
                 // from pDoc->GetEditPool() to create the text object, which
                 // is a prerequisite for using this constructor of ScEditCell.
-                pNewCell = new ScEditCell(mpEditEngine->CreateTextObject(), pDoc);
+                pDoc->SetEditText(rCurrentPos, mpEditEngine->CreateTextObject());
             }
         }
         else if ( nCurrentCol > 0 && pOUText && !pOUText->isEmpty() )
             pNewCell = ScBaseCell::CreateTextCell( *pOUText, pDoc );
 
         bDoIncrement = pNewCell != NULL;
-        if ( bDoIncrement )
+        if (bDoIncrement && pNewCell)
             pDoc->PutCell( rCurrentPos, pNewCell );
     }
     // #i56027# This is about setting simple text, not edit cells,
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 5325fac..b756000 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -817,11 +817,17 @@ void ScTransferObj::StripRefs( ScDocument* pDoc,
                 {
                     String aStr = pFCell->GetString();
                     if ( pFCell->IsMultilineResult() )
-                        pNew = new ScEditCell( aStr, pDestDoc );
+                    {
+                        ScFieldEditEngine& rEngine = pDestDoc->GetEditEngine();
+                        rEngine.SetText(aStr);
+                        pDestDoc->SetEditText(ScAddress(nCol,nRow,nDestTab), rEngine.CreateTextObject());
+                    }
                     else
                         pNew = new ScStringCell( aStr );
                 }
-                pDestDoc->PutCell( nCol,nRow,nDestTab, pNew );
+
+                if (pNew)
+                    pDestDoc->PutCell(nCol, nRow, nDestTab, pNew);
 
                 //  number formats
 
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 0c9d73b..1a2af82 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1204,7 +1204,9 @@ static bool lcl_PutString(
     else
     {
         bMultiLine = true;
-        pDoc->PutCell( nCol, nRow, nTab, new ScEditCell( rStr, pDoc ) );
+        ScFieldEditEngine& rEngine = pDoc->GetEditEngine();
+        rEngine.SetText(rStr);
+        pDoc->SetEditText(ScAddress(nCol,nRow,nTab), rEngine.CreateTextObject());
     }
     return bMultiLine;
 }
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index fd8c3e0..0510a21 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -49,6 +49,7 @@
 #include "postit.hxx"
 #include "docuno.hxx"
 #include "progress.hxx"
+#include "editutil.hxx"
 
 // STATIC DATA ---------------------------------------------------------------
 
@@ -1023,7 +1024,11 @@ void ScUndoReplace::Undo()
     {
         // aUndoStr may contain line breaks
         if ( aUndoStr.Search('\n') != STRING_NOTFOUND )
-            pDoc->PutCell( aCursorPos, new ScEditCell( aUndoStr, pDoc ) );
+        {
+            ScFieldEditEngine& rEngine = pDoc->GetEditEngine();
+            rEngine.SetText(aUndoStr);
+            pDoc->SetEditText(aCursorPos, rEngine.CreateTextObject());
+        }
         else
             pDoc->SetString( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), aUndoStr );
         if (pViewShell)
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index bcab454..efa6c8e 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -2359,7 +2359,7 @@ void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pE
                                 aEngine.QuickSetAttribs( aAttr, ESelection( 0, 0, 0, aStr.Len()));
 
                                 // The cell will own the text object instance.
-                                pDoc->PutCell(aRanges[0]->aStart, new ScEditCell(aEngine.CreateTextObject(), pDoc));
+                                pDoc->SetEditText(aRanges[0]->aStart, aEngine.CreateTextObject());
                             }
                         }
                     }
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index cd48942..8dd7e5e 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -414,9 +414,8 @@ void ScViewFunc::DoThesaurus( sal_Bool bRecord )
         if (pCell && pTObject)
         {
             // The cell will own the text object instance.
-            pDoc->PutCell(
-                nCol, nRow, nTab,
-                new ScEditCell(pThesaurusEngine->CreateTextObject(), pDoc));
+            pDoc->SetEditText(
+                ScAddress(nCol,nRow,nTab), pThesaurusEngine->CreateTextObject());
         }
         else
         {
commit 6789befc32c6800ec2ba8cdcbc88cc1f0df90514
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Mar 19 10:00:07 2013 -0400

    This ScFormulaCell member is not used. Also remove cell.hxx include...
    
    Change-Id: I5d188bb080943acc4b8e4ae44a4c8ef01a837c2f

diff --git a/sc/source/ui/inc/anyrefdg.hxx b/sc/source/ui/inc/anyrefdg.hxx
index 760879a..bba97a7 100644
--- a/sc/source/ui/inc/anyrefdg.hxx
+++ b/sc/source/ui/inc/anyrefdg.hxx
@@ -26,7 +26,6 @@
 #include <sfx2/basedlgs.hxx>
 #include <sfx2/tabdlg.hxx>
 #include "address.hxx"
-#include "cell.hxx"
 #include "compiler.hxx"
 #include "formula/funcutl.hxx"
 #include "IAnyRefDialog.hxx"
@@ -45,7 +44,6 @@ class ScRangeList;
 class ScFormulaReferenceHelper
 {
     IAnyRefDialog*      m_pDlg;
-    ::std::auto_ptr<ScFormulaCell>      pRefCell;
     ::std::auto_ptr<ScCompiler>         pRefComp;
     formula::RefEdit*    pRefEdit;               // active input field
     formula::RefButton*  pRefBtn;                // associated button
diff --git a/sc/source/ui/inc/formula.hxx b/sc/source/ui/inc/formula.hxx
index 1b3790e..997e198 100644
--- a/sc/source/ui/inc/formula.hxx
+++ b/sc/source/ui/inc/formula.hxx
@@ -38,6 +38,7 @@ class ScDocument;
 class ScFuncDesc;
 class ScInputHandler;
 class ScDocShell;
+class ScFormulaCell;
 
 //============================================================================
 typedef ScTabViewShell* PtrTabViewShell;
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index e1b60ba..cec4522 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -323,7 +323,6 @@ void ScFormulaReferenceHelper::Init()
         ScAddress aCursorPos( nCol, nRow, nTab );
 
         String rStrExp;
-        pRefCell.reset( new ScFormulaCell( pDoc, aCursorPos, rStrExp ) );
         pRefComp.reset( new ScCompiler( pDoc, aCursorPos) );
         pRefComp->SetGrammar( pDoc->GetGrammar() );
         pRefComp->SetCompileForFAP(true);


More information about the Libreoffice-commits mailing list