[Libreoffice-commits] core.git: sc/inc sc/qa sc/source

Eike Rathke erack at redhat.com
Thu Jul 25 07:11:31 PDT 2013


 sc/inc/cellform.hxx                                    |    5 -
 sc/inc/cellvalue.hxx                                   |   11 ++-
 sc/inc/chgtrack.hxx                                    |    7 +
 sc/inc/editutil.hxx                                    |   13 ++-
 sc/inc/global.hxx                                      |    7 +
 sc/qa/unit/subsequent_filters-test.cxx                 |    9 ++
 sc/qa/unit/ucalc.cxx                                   |    2 
 sc/source/core/data/cellvalue.cxx                      |    4 -
 sc/source/core/data/column.cxx                         |    2 
 sc/source/core/data/column2.cxx                        |   26 +++----
 sc/source/core/data/column3.cxx                        |   23 +++---
 sc/source/core/data/conditio.cxx                       |    9 +-
 sc/source/core/data/dociter.cxx                        |   10 +-
 sc/source/core/data/document.cxx                       |    2 
 sc/source/core/data/global.cxx                         |   16 ++++
 sc/source/core/data/table3.cxx                         |    2 
 sc/source/core/data/table4.cxx                         |   10 +-
 sc/source/core/data/validat.cxx                        |    2 
 sc/source/core/tool/cellform.cxx                       |   10 +-
 sc/source/core/tool/chgtrack.cxx                       |   22 +++---
 sc/source/core/tool/editutil.cxx                       |   61 +++++++++++------
 sc/source/core/tool/interpr4.cxx                       |   10 +-
 sc/source/core/tool/rangeseq.cxx                       |    2 
 sc/source/filter/dif/difexp.cxx                        |    2 
 sc/source/filter/html/htmlexp.cxx                      |    2 
 sc/source/filter/xcl97/XclExpChangeTrack.cxx           |    2 
 sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx |    8 +-
 sc/source/ui/docshell/docsh.cxx                        |    4 -
 sc/source/ui/docshell/docsh3.cxx                       |    4 -
 sc/source/ui/docshell/externalrefmgr.cxx               |    4 -
 sc/source/ui/miscdlgs/acredlin.cxx                     |    4 -
 sc/source/ui/unoobj/cellsuno.cxx                       |    4 -
 sc/source/ui/view/output2.cxx                          |    3 
 33 files changed, 191 insertions(+), 111 deletions(-)

New commits:
commit 1ecdc7aaf661e97a33cf521f553481d79cd26de2
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jul 25 15:33:49 2013 +0200

    resolved fdo#67249 use ScFieldEditEngine to resolve field content
    
    ScEditUtil::GetString() iterated over the paragraphs of an
    EditTextObject where GetText() does not resolve field content but
    returns the embedded field markers. To resolve field content an
    ScFieldEditEngine is needed.
    
    This makes it necessary to pass an ScDocument* to obtain the
    ScFieldEditEngine from, or for cases where there is no ScDocument in the
    context use a static ScFieldEditEngine which unfortunately is not
    capable of resolving document specific fields of course, such as
    DOCINFO_TITLE and TABLE.
    
    Also added unit test.
    
    Change-Id: Ife3c23b2fec2514b32303239d276c49869786eb5

diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index 6a164a0..d384e54 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -43,7 +43,7 @@ public:
 
     static void GetString(
         ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString,
-        Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true,
+        Color** ppColor, SvNumberFormatter& rFormatter, const ScDocument* pDoc, bool bNullVals = true,
         bool bFormula  = false, ScForceTextFmt eForceTextFmt = ftDontForce,
         bool bUseStarFormat = false );
 
@@ -53,7 +53,8 @@ public:
         bool bFormula  = false, ScForceTextFmt eForceTextFmt = ftDontForce, bool bUseStarFormat = false );
 
     static void GetInputString(
-        ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString, SvNumberFormatter& rFormatter );
+        ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString, SvNumberFormatter& rFormatter,
+        const ScDocument* pDoc );
 };
 
 
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 43e7a05..0e2987c 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -134,7 +134,16 @@ struct SC_DLLPUBLIC ScRefCellValue
 
     double getValue();
 
-    OUString getString();
+    /** Retrieve string value.
+
+        @param  pDoc
+                Needed to resolve EditCells' field contents, obtain a
+                ScFieldEditEngine from that document. May be NULL if there is
+                no ScDocument in the calling context but then the document
+                specific fields can not be resolved. See
+                ScEditUtil::GetString().
+     */
+    OUString getString( const ScDocument* pDoc );
 
     bool isEmpty() const;
 
diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index aef13cf..872f268 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -702,7 +702,8 @@ class ScChangeActionContent : public ScChangeAction
 
     void SetValueString( OUString& rValue, ScCellValue& rCell, const OUString& rStr, ScDocument* pDoc );
 
-    void GetValueString( OUString& rStr, const OUString& rValue, const ScCellValue& rCell ) const;
+    void GetValueString( OUString& rStr, const OUString& rValue, const ScCellValue& rCell,
+                         const ScDocument* pDoc ) const;
 
     void GetFormulaString( OUString& rStr, const ScFormulaCell* pCell ) const;
 
@@ -788,8 +789,8 @@ public:
     // assigns string / creates forumula cell
     void SetOldValue( const OUString& rOld, ScDocument* pDoc );
 
-    void GetOldString( OUString& rStr ) const;
-    void GetNewString( OUString& rStr ) const;
+    void GetOldString( OUString& rStr, const ScDocument* pDoc ) const;
+    void GetNewString( OUString& rStr, const ScDocument* pDoc ) const;
     SC_DLLPUBLIC const ScCellValue& GetOldCell() const;
     SC_DLLPUBLIC const ScCellValue& GetNewCell() const;
     virtual void GetDescription(
diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index 10bec82..88a42e8 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -54,12 +54,19 @@ public:
     static OUString ModifyDelimiters( const OUString& rOld );
 
     /// Retrieves string with paragraphs delimited by spaces
-    static String GetSpaceDelimitedString( const EditEngine& rEngine );
+    static OUString GetSpaceDelimitedString( const EditEngine& rEngine );
 
     /// Retrieves string with paragraphs delimited by new lines ('\n').
-    static String GetMultilineString( const EditEngine& rEngine );
+    static OUString GetMultilineString( const EditEngine& rEngine );
 
-    SC_DLLPUBLIC static OUString GetString( const EditTextObject& rEditText );
+    /** Retrieves string with paragraphs delimited by new lines ('\n').
+
+        @param pDoc
+               If not NULL, use pDoc->GetEditEngine() to retrieve field content.
+               If NULL, a static mutex-guarded ScFieldEditEngine is used that
+               is not capable of resolving document specific fields; avoid.
+     */
+    SC_DLLPUBLIC static OUString GetString( const EditTextObject& rEditText, const ScDocument* pDoc );
 
     static EditTextObject* CreateURLObjectFromURL(
         ScDocument& rDoc, const OUString& rURL, const OUString& rText );
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 2b86a7c..69e22f5 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -485,6 +485,7 @@ class CalendarWrapper;
 class CollatorWrapper;
 class IntlWrapper;
 class OutputDevice;
+class ScFieldEditEngine;
 
 namespace com { namespace sun { namespace star {
     namespace lang {
@@ -534,6 +535,8 @@ class ScGlobal
     static IntlWrapper*         pScIntlWrapper;
     static ::com::sun::star::lang::Locale*      pLocale;
 
+    static ScFieldEditEngine*   pFieldEditEngine;
+
 public:
     static SvtSysLocale*        pSysLocale;
     // for faster access a pointer to the single instance provided by SvtSysLocale
@@ -694,6 +697,10 @@ SC_DLLPUBLIC    static const sal_Unicode* FindUnquoted( const sal_Unicode* pStri
 
     /** Obtain the ordinal suffix for a number according to the system locale */
     static String           GetOrdinalSuffix( sal_Int32 nNumber);
+
+    /** A static instance of ScFieldEditEngine not capable of resolving
+        document specific fields, to be used only by ScEditUtil::GetString(). */
+    static ScFieldEditEngine&   GetStaticFieldEditEngine();
 };
 #endif
 
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 79d31c8..49ec5fd 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -45,6 +45,7 @@
 #include "patattr.hxx"
 #include "scitems.hxx"
 #include "docsh.hxx"
+#include "editutil.hxx"
 
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/drawing/XControlShape.hpp>
@@ -1582,6 +1583,8 @@ void ScFiltersTest::testRichTextContentODS()
     aParaText = pEditText->GetText(0);
     CPPUNIT_ASSERT_MESSAGE("Unexpected text.", aParaText.indexOf("Sheet name is ") == 0);
     CPPUNIT_ASSERT_MESSAGE("Sheet name field item not found.", pEditText->HasField(text::textfield::Type::TABLE));
+    CPPUNIT_ASSERT_EQUAL(OUString("Sheet name is Test."), ScEditUtil::GetString(*pEditText, pDoc));
+    CPPUNIT_ASSERT_EQUAL(OUString("Sheet name is ?."), ScEditUtil::GetString(*pEditText, NULL));
 
     // Cell with URL field item.
     aPos.IncRow();
@@ -1592,6 +1595,8 @@ void ScFiltersTest::testRichTextContentODS()
     aParaText = pEditText->GetText(0);
     CPPUNIT_ASSERT_MESSAGE("Unexpected text.", aParaText.indexOf("URL: ") == 0);
     CPPUNIT_ASSERT_MESSAGE("URL field item not found.", pEditText->HasField(text::textfield::Type::URL));
+    CPPUNIT_ASSERT_EQUAL(OUString("URL: http://libreoffice.org"), ScEditUtil::GetString(*pEditText, pDoc));
+    CPPUNIT_ASSERT_EQUAL(OUString("URL: http://libreoffice.org"), ScEditUtil::GetString(*pEditText, NULL));
 
     // Cell with Date field item.
     aPos.IncRow();
@@ -1602,6 +1607,8 @@ void ScFiltersTest::testRichTextContentODS()
     aParaText = pEditText->GetText(0);
     CPPUNIT_ASSERT_MESSAGE("Unexpected text.", aParaText.indexOf("Date: ") == 0);
     CPPUNIT_ASSERT_MESSAGE("Date field item not found.", pEditText->HasField(text::textfield::Type::DATE));
+    CPPUNIT_ASSERT_MESSAGE("Date field not resolved with pDoc.", ScEditUtil::GetString(*pEditText, pDoc).indexOf("/20") > 0);
+    CPPUNIT_ASSERT_MESSAGE("Date field not resolved with NULL.", ScEditUtil::GetString(*pEditText, NULL).indexOf("/20") > 0);
 
     // Cell with DocInfo title field item.
     aPos.IncRow();
@@ -1612,6 +1619,8 @@ void ScFiltersTest::testRichTextContentODS()
     aParaText = pEditText->GetText(0);
     CPPUNIT_ASSERT_MESSAGE("Unexpected text.", aParaText.indexOf("Title: ") == 0);
     CPPUNIT_ASSERT_MESSAGE("DocInfo title field item not found.", pEditText->HasField(text::textfield::Type::DOCINFO_TITLE));
+    CPPUNIT_ASSERT_EQUAL(OUString("Title: Test Document"), ScEditUtil::GetString(*pEditText, pDoc));
+    CPPUNIT_ASSERT_EQUAL(OUString("Title: ?"), ScEditUtil::GetString(*pEditText, NULL));
 
     // Cell with sentence with both bold and italic sequences.
     aPos.IncRow();
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 7d081bc..5e72136 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -621,7 +621,7 @@ bool checkHorizontalIterator(ScDocument* pDoc, const char* pData[][_Size], size_
         if (pChecks[i].nRow != nRow)
             return false;
 
-        if (OUString::createFromAscii(pChecks[i].pVal) != pCell->getString())
+        if (OUString::createFromAscii(pChecks[i].pVal) != pCell->getString(pDoc))
             return false;
     }
 
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
index 8e62836..2c40418 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -579,7 +579,7 @@ double ScRefCellValue::getValue()
     return 0.0;
 }
 
-OUString ScRefCellValue::getString()
+OUString ScRefCellValue::getString( const ScDocument* pDoc )
 {
     switch (meType)
     {
@@ -589,7 +589,7 @@ OUString ScRefCellValue::getString()
             return *mpString;
         case CELLTYPE_EDIT:
             if (mpEditText)
-                return ScEditUtil::GetString(*mpEditText);
+                return ScEditUtil::GetString(*mpEditText, pDoc);
         break;
         case CELLTYPE_FORMULA:
             return mpFormula->GetString();
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index da3cb49..5233629 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1480,7 +1480,7 @@ void ScColumn::CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol
                 for (; itData != itDataEnd; ++itData)
                 {
                     const EditTextObject& rObj = **itData;
-                    aConverted.push_back(ScEditUtil::GetString(rObj));
+                    aConverted.push_back(ScEditUtil::GetString(rObj, pDocument));
                 }
                 aDestPos.miCellPos = rDestCol.maCells.set(aDestPos.miCellPos, nCurRow, aConverted.begin(), aConverted.end());
             }
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 4d6c3fe6..ab6c88a 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -245,7 +245,7 @@ long ScColumn::GetNeededSize(
         Color* pColor;
         OUString aValStr;
         ScCellFormat::GetString(
-            aCell, nFormat, aValStr, &pColor, *pFormatter, true, rOptions.bFormula, ftCheck);
+            aCell, nFormat, aValStr, &pColor, *pFormatter, pDocument, true, rOptions.bFormula, ftCheck);
 
         if (!aValStr.isEmpty())
         {
@@ -407,7 +407,7 @@ long ScColumn::GetNeededSize(
             Color* pColor;
             OUString aString;
             ScCellFormat::GetString(
-                aCell, nFormat, aString, &pColor, *pFormatter, true,
+                aCell, nFormat, aString, &pColor, *pFormatter, pDocument, true,
                 rOptions.bFormula, ftCheck);
 
             if (!aString.isEmpty())
@@ -546,7 +546,7 @@ class MaxStrLenFinder
         Color* pColor;
         OUString aValStr;
         ScCellFormat::GetString(
-            rCell, mnFormat, aValStr, &pColor, *mrDoc.GetFormatTable(), true, false, ftCheck);
+            rCell, mnFormat, aValStr, &pColor, *mrDoc.GetFormatTable(), &mrDoc, true, false, ftCheck);
 
         if (aValStr.getLength() > mnMaxLen)
         {
@@ -628,7 +628,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
         {
             ScRefCellValue aCell = GetCellValue(pParam->mnMaxTextRow);
             ScCellFormat::GetString(
-                aCell, nFormat, aLongStr, &pColor, *pFormatter, true, false, ftCheck);
+                aCell, nFormat, aLongStr, &pColor, *pFormatter, pDocument, true, false, ftCheck);
         }
         else
         {
@@ -1897,9 +1897,10 @@ class ToMatrixHandler
     ScMatrix& mrMat;
     SCCOL mnMatCol;
     SCROW mnTopRow;
+    const ScDocument* mpDoc;
 public:
-    ToMatrixHandler(ScMatrix& rMat, SCCOL nMatCol, SCROW nTopRow) :
-        mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow) {}
+    ToMatrixHandler(ScMatrix& rMat, SCCOL nMatCol, SCROW nTopRow, const ScDocument* pDoc) :
+        mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow), mpDoc(pDoc) {}
 
     void operator() (size_t nRow, double fVal)
     {
@@ -1923,7 +1924,7 @@ public:
 
     void operator() (size_t nRow, const EditTextObject* pStr)
     {
-        mrMat.PutString(ScEditUtil::GetString(*pStr), mnMatCol, nRow - mnTopRow);
+        mrMat.PutString(ScEditUtil::GetString(*pStr, mpDoc), mnMatCol, nRow - mnTopRow);
     }
 };
 
@@ -1934,7 +1935,7 @@ bool ScColumn::ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow
     if (nRow1 > nRow2)
         return false;
 
-    ToMatrixHandler aFunc(rMat, nMatCol, nRow1);
+    ToMatrixHandler aFunc(rMat, nMatCol, nRow1, pDocument);
     sc::ParseAllNonEmpty(maCells.begin(), maCells, nRow1, nRow2, aFunc);
     return true;
 }
@@ -1982,10 +1983,11 @@ class FillMatrixHandler
 
     SCCOL mnCol;
     SCTAB mnTab;
+    const ScDocument* mpDoc;
 
 public:
-    FillMatrixHandler(ScMatrix& rMat, size_t nMatCol, size_t nTopRow, SCCOL nCol, SCTAB nTab) :
-        mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow), mnCol(nCol), mnTab(nTab) {}
+    FillMatrixHandler(ScMatrix& rMat, size_t nMatCol, size_t nTopRow, SCCOL nCol, SCTAB nTab, const ScDocument* pDoc) :
+        mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow), mnCol(nCol), mnTab(nTab), mpDoc(pDoc) {}
 
     void operator() (const sc::CellStoreType::value_type& node, size_t nOffset, size_t nDataSize)
     {
@@ -2014,7 +2016,7 @@ public:
                 sc::edittext_block::const_iterator itEnd = it;
                 std::advance(itEnd, nDataSize);
                 for (; it != itEnd; ++it)
-                    aStrs.push_back(ScEditUtil::GetString(**it));
+                    aStrs.push_back(ScEditUtil::GetString(**it, mpDoc));
 
                 const OUString* p = &aStrs[0];
                 mrMat.PutString(p, nDataSize, mnMatCol, nMatRow);
@@ -2091,7 +2093,7 @@ public:
 
 void ScColumn::FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2 ) const
 {
-    FillMatrixHandler aFunc(rMat, nMatCol, nRow1, nCol, nTab);
+    FillMatrixHandler aFunc(rMat, nMatCol, nRow1, nCol, nTab, pDocument);
     sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
 }
 
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 1e0ec16..a787df3 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -449,7 +449,7 @@ bool ScColumn::UpdateScriptType( sc::CellTextAttr& rAttr, SCROW nRow )
     OUString aStr;
     Color* pColor;
     sal_uLong nFormat = pPattern->GetNumberFormat(pFormatter, pCondSet);
-    ScCellFormat::GetString(aCell, nFormat, aStr, &pColor, *pFormatter);
+    ScCellFormat::GetString(aCell, nFormat, aStr, &pColor, *pFormatter, pDocument);
 
     // Store the real script type to the array.
     rAttr.mnScriptType = pDocument->GetStringScriptType(aStr);
@@ -1733,7 +1733,7 @@ class FilterEntriesHandler
         SvNumberFormatter* pFormatter = mrColumn.GetDoc().GetFormatTable();
         OUString aStr;
         sal_uLong nFormat = mrColumn.GetNumberFormat(nRow);
-        ScCellFormat::GetInputString(rCell, nFormat, aStr, *pFormatter);
+        ScCellFormat::GetInputString(rCell, nFormat, aStr, *pFormatter, &mrColumn.GetDoc());
 
         if (rCell.hasString())
         {
@@ -1834,9 +1834,10 @@ class StrCellIterator
     PosType maPos;
     sc::CellStoreType::const_iterator miBeg;
     sc::CellStoreType::const_iterator miEnd;
+    const ScDocument* mpDoc;
 public:
-    StrCellIterator(const sc::CellStoreType& rCells, SCROW nStart) :
-        maPos(rCells.position(nStart)), miBeg(rCells.begin()), miEnd(rCells.end()) {}
+    StrCellIterator(const sc::CellStoreType& rCells, SCROW nStart, const ScDocument* pDoc) :
+        maPos(rCells.position(nStart)), miBeg(rCells.begin()), miEnd(rCells.end()), mpDoc(pDoc) {}
 
     bool valid() const { return (maPos.first != miEnd); }
 
@@ -1929,7 +1930,7 @@ public:
             case sc::element_type_edittext:
             {
                 const EditTextObject* p = sc::edittext_block::at(*maPos.first->data, maPos.second);
-                return ScEditUtil::GetString(*p);
+                return ScEditUtil::GetString(*p, mpDoc);
             }
             default:
                 ;
@@ -1956,8 +1957,8 @@ bool ScColumn::GetDataEntries(
     // going upward and downward directions in parallel. The start position
     // cell must be skipped.
 
-    StrCellIterator aItrUp(maCells, nStartRow);
-    StrCellIterator aItrDown(maCells, nStartRow+1);
+    StrCellIterator aItrUp(maCells, nStartRow, pDocument);
+    StrCellIterator aItrDown(maCells, nStartRow+1, pDocument);
 
     bool bMoveUp = aItrUp.valid();
     if (!bMoveUp)
@@ -2179,7 +2180,7 @@ void ScColumn::GetString( SCROW nRow, OUString& rString ) const
 
     sal_uLong nFormat = GetNumberFormat(nRow);
     Color* pColor = NULL;
-    ScCellFormat::GetString(aCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable()));
+    ScCellFormat::GetString(aCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable()), pDocument);
 }
 
 const OUString* ScColumn::GetStringCell( SCROW nRow ) const
@@ -2212,7 +2213,7 @@ void ScColumn::GetInputString( SCROW nRow, OUString& rString ) const
 {
     ScRefCellValue aCell = GetCellValue(nRow);
     sal_uLong nFormat = GetNumberFormat(nRow);
-    ScCellFormat::GetInputString(aCell, nFormat, rString, *(pDocument->GetFormatTable()));
+    ScCellFormat::GetInputString(aCell, nFormat, rString, *(pDocument->GetFormatTable()), pDocument);
 }
 
 double ScColumn::GetValue( SCROW nRow ) const
@@ -2431,7 +2432,7 @@ class MaxStringLenHandler
         Color* pColor;
         OUString aString;
         sal_uInt32 nFormat = static_cast<const SfxUInt32Item*>(mrColumn.GetAttr(nRow, ATTR_VALUE_FORMAT))->GetValue();
-        ScCellFormat::GetString(rCell, nFormat, aString, &pColor, *mpFormatter);
+        ScCellFormat::GetString(rCell, nFormat, aString, &pColor, *mpFormatter, &mrColumn.GetDoc());
         sal_Int32 nLen = 0;
         if (mbOctetEncoding)
         {
@@ -2517,7 +2518,7 @@ class MaxNumStringLenHandler
         OUString aString;
         sal_uInt32 nFormat = static_cast<const SfxUInt32Item*>(
             mrColumn.GetAttr(nRow, ATTR_VALUE_FORMAT))->GetValue();
-        ScCellFormat::GetInputString(rCell, nFormat, aString, *mpFormatter);
+        ScCellFormat::GetInputString(rCell, nFormat, aString, *mpFormatter, &mrColumn.GetDoc());
         sal_Int32 nLen = aString.getLength();
         if (nLen <= 0)
             // Ignore empty string.
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index fe438af..baef656 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -734,7 +734,8 @@ void ScConditionEntry::Interpret( const ScAddress& rPos )
     bFirstRun = false;
 }
 
-static bool lcl_GetCellContent( ScRefCellValue& rCell, bool bIsStr1, double& rArg, OUString& rArgStr )
+static bool lcl_GetCellContent( ScRefCellValue& rCell, bool bIsStr1, double& rArg, OUString& rArgStr,
+        const ScDocument* pDoc )
 {
 
     if (rCell.isEmpty())
@@ -762,7 +763,7 @@ static bool lcl_GetCellContent( ScRefCellValue& rCell, bool bIsStr1, double& rAr
             if (rCell.meType == CELLTYPE_STRING)
                 rArgStr = *rCell.mpString;
             else if (rCell.mpEditText)
-                rArgStr = ScEditUtil::GetString(*rCell.mpEditText);
+                rArgStr = ScEditUtil::GetString(*rCell.mpEditText, pDoc);
         break;
         default:
             ;
@@ -806,7 +807,7 @@ void ScConditionEntry::FillCache() const
 
                     double nVal = 0.0;
                     OUString aStr;
-                    if (!lcl_GetCellContent(aCell, false, nVal, aStr))
+                    if (!lcl_GetCellContent(aCell, false, nVal, aStr, mpDoc))
                     {
                         std::pair<ScConditionEntryCache::StringCacheType::iterator, bool> aResult =
                             mpCache->maStrings.insert(
@@ -1270,7 +1271,7 @@ bool ScConditionEntry::IsCellValid( ScRefCellValue& rCell, const ScAddress& rPos
 
     double nArg = 0.0;
     OUString aArgStr;
-    bool bVal = lcl_GetCellContent( rCell, bIsStr1, nArg, aArgStr );
+    bool bVal = lcl_GetCellContent( rCell, bIsStr1, nArg, aArgStr, mpDoc );
     if (bVal)
         return IsValid( nArg, rPos );
     else
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 02cb39b..a31b7aa 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -454,7 +454,7 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue)
                         incPos();
                     else
                     {
-                        rValue.maString = aCell.getString();
+                        rValue.maString = aCell.getString(mpDoc);
                         rValue.mfValue = 0.0;
                         rValue.mnError = 0;
                         rValue.mbIsNumber = false;
@@ -933,7 +933,7 @@ CellType ScCellIterator::getType() const
 
 OUString ScCellIterator::getString()
 {
-    return maCurCell.getString();
+    return maCurCell.getString(mpDoc);
 }
 
 const EditTextObject* ScCellIterator::getEditText() const
@@ -1408,7 +1408,7 @@ bool ScQueryCellIterator::BinarySearch()
         OUString aCellStr;
         sal_uLong nFormat = pCol->GetNumberFormat(toLogicalPos(aLoPos));
         aCell.assign(aLoPos.first, aLoPos.second);
-        ScCellFormat::GetInputString(aCell, nFormat, aCellStr, rFormatter);
+        ScCellFormat::GetInputString(aCell, nFormat, aCellStr, rFormatter, pDoc);
         sal_Int32 nTmp = pCollator->compareString(aCellStr, rEntry.GetQueryItem().maString);
         if ((rEntry.eOp == SC_LESS_EQUAL && nTmp > 0) ||
                 (rEntry.eOp == SC_GREATER_EQUAL && nTmp < 0) ||
@@ -1455,7 +1455,7 @@ bool ScQueryCellIterator::BinarySearch()
         {
             sal_uLong nFormat = pCol->GetNumberFormat(toLogicalPos(aLastInRange));
             OUString aStr;
-            ScCellFormat::GetInputString(aCell, nFormat, aStr, rFormatter);
+            ScCellFormat::GetInputString(aCell, nFormat, aStr, rFormatter, pDoc);
             aLastInRangeString = aStr;
         }
         else
@@ -1558,7 +1558,7 @@ bool ScQueryCellIterator::BinarySearch()
             OUString aCellStr;
             sal_uLong nFormat = pCol->GetNumberFormat(i);
             aCell.assign(aPos.first, aPos.second);
-            ScCellFormat::GetInputString(aCell, nFormat, aCellStr, rFormatter);
+            ScCellFormat::GetInputString(aCell, nFormat, aCellStr, rFormatter, pDoc);
 
             nRes = pCollator->compareString(aCellStr, rEntry.GetQueryItem().maString);
             if (nRes < 0 && bLessEqual)
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index f32fcd5..ef73c7c 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3241,7 +3241,7 @@ sal_uInt16 ScDocument::GetStringForFormula( const ScAddress& rPos, OUString& rSt
     {
         case CELLTYPE_STRING:
         case CELLTYPE_EDIT:
-            aStr = aCell.getString();
+            aStr = aCell.getString(this);
         break;
         case CELLTYPE_FORMULA:
         {
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 1ca26a7..bc31365 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -77,6 +77,7 @@
 #include "scmod.hxx"
 #include "appoptio.hxx"
 #include "random.hxx"
+#include "editutil.hxx"
 
 // -----------------------------------------------------------------------
 
@@ -117,6 +118,7 @@ ScFunctionMgr*  ScGlobal::pStarCalcFunctionMgr  = NULL;
 
 ScUnitConverter* ScGlobal::pUnitConverter = NULL;
 SvNumberFormatter* ScGlobal::pEnglishFormatter = NULL;
+ScFieldEditEngine* ScGlobal::pFieldEditEngine = NULL;
 
 double          ScGlobal::nScreenPPTX           = 96.0;
 double          ScGlobal::nScreenPPTY           = 96.0;
@@ -684,6 +686,7 @@ void ScGlobal::Clear()
     DELETEZ(pStrClipDocName);
 
     DELETEZ(pUnitConverter);
+    DELETEZ(pFieldEditEngine);
 
     ScDocumentPool::DeleteVersionMaps();
 
@@ -1195,4 +1198,17 @@ IntlWrapper*         ScGlobal::GetScIntlWrapper()
     return pLocale;
 }
 
+ScFieldEditEngine& ScGlobal::GetStaticFieldEditEngine()
+{
+    if (!pFieldEditEngine)
+    {
+        // Creating a ScFieldEditEngine with pDocument=NULL leads to document
+        // specific fields not being resolvable! See
+        // ScFieldEditEngine::CalcFieldValue(). pEnginePool=NULL lets
+        // EditEngine internally create and delete a default pool.
+        pFieldEditEngine = new ScFieldEditEngine( NULL, NULL);
+    }
+    return *pFieldEditEngine;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 9971816..0e30d0a 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1418,7 +1418,7 @@ public:
             else
             {
                 sal_uLong nFormat = mrTab.GetNumberFormat( static_cast<SCCOL>(rEntry.nField), nRow );
-                ScCellFormat::GetInputString(rCell, nFormat, aCellStr, *mrDoc.GetFormatTable());
+                ScCellFormat::GetInputString(rCell, nFormat, aCellStr, *mrDoc.GetFormatTable(), &mrDoc);
             }
         }
         else
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 5df6257..3797a90 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -400,7 +400,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                         CellType eType = aCell.meType;
                         if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
                         {
-                            aStr = aCell.getString();
+                            aStr = aCell.getString(pDocument);
                             aString = aStr;
                             nFlag2 = lcl_DecompValueString( aString, nVal2, &rMinDigits );
                             aStr = aString;
@@ -796,7 +796,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                                     if ( eCellType == CELLTYPE_STRING )
                                         aValue = *aSrcCell.mpString;
                                     else
-                                        aValue = ScEditUtil::GetString(*aSrcCell.mpEditText);
+                                        aValue = ScEditUtil::GetString(*aSrcCell.mpEditText, pDocument);
                                     if ( !(nScFillModeMouseModifier & KEY_MOD1) && !bHasFiltered )
                                     {
                                         nCellDigits = 0;    // look at each source cell individually
@@ -1040,7 +1040,7 @@ String ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW n
                     case CELLTYPE_STRING:
                     case CELLTYPE_EDIT:
                     {
-                        aValue = aCell.getString();
+                        aValue = aCell.getString(pDocument);
 
                         if ( !(nScFillModeMouseModifier & KEY_MOD1) )
                         {
@@ -1096,7 +1096,7 @@ String ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW n
                     case CELLTYPE_STRING:
                     case CELLTYPE_EDIT:
                     {
-                        aValue = aCell.getString();
+                        aValue = aCell.getString(pDocument);
                         nHeadNoneTail = lcl_DecompValueString( aValue, nVal );
                         if ( nHeadNoneTail )
                             nStart = (double)nVal;
@@ -1587,7 +1587,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                 if (eCellType == CELLTYPE_STRING)
                     aValue = *aSrcCell.mpString;
                 else
-                    aValue = ScEditUtil::GetString(*aSrcCell.mpEditText);
+                    aValue = ScEditUtil::GetString(*aSrcCell.mpEditText, pDocument);
                 sal_Int32 nStringValue;
                 sal_uInt16 nMinDigits = nArgMinDigits;
                 short nHeadNoneTail = lcl_DecompValueString( aValue, nStringValue, &nMinDigits );
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index ea65bb5..eaee651 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -494,7 +494,7 @@ bool ScValidationData::IsDataValid( ScRefCellValue& rCell, const ScAddress& rPos
         break;
         case CELLTYPE_EDIT:
             if (rCell.mpEditText)
-                aString = ScEditUtil::GetString(*rCell.mpEditText);
+                aString = ScEditUtil::GetString(*rCell.mpEditText, GetDocument());
             bIsVal = false;
         break;
         case CELLTYPE_FORMULA:
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index a33405f..bc65f91 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -34,14 +34,14 @@
 const ScFormulaCell* pLastFormulaTreeTop = 0;
 
 void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString,
-                              Color** ppColor, SvNumberFormatter& rFormatter,
+                              Color** ppColor, SvNumberFormatter& rFormatter, const ScDocument* pDoc,
                               bool bNullVals, bool bFormula, ScForceTextFmt eForceTextFmt,
                               bool bUseStarFormat )
 {
     *ppColor = NULL;
     if (&rFormatter==NULL)
     {
-        rString = OUString();
+        rString = EMPTY_OUSTRING;
         return;
     }
 
@@ -51,7 +51,7 @@ void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString
             rFormatter.GetOutputString(*rCell.mpString, nFormat, rString, ppColor, bUseStarFormat);
         break;
         case CELLTYPE_EDIT:
-            rFormatter.GetOutputString(rCell.getString(), nFormat, rString, ppColor );
+            rFormatter.GetOutputString(rCell.getString(pDoc), nFormat, rString, ppColor );
         break;
         case CELLTYPE_VALUE:
         {
@@ -223,7 +223,7 @@ OUString ScCellFormat::GetString(
 }
 
 void ScCellFormat::GetInputString(
-    ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString, SvNumberFormatter& rFormatter )
+    ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString, SvNumberFormatter& rFormatter, const ScDocument* pDoc )
 {
     if (&rFormatter == NULL)
     {
@@ -236,7 +236,7 @@ void ScCellFormat::GetInputString(
     {
         case CELLTYPE_STRING:
         case CELLTYPE_EDIT:
-            aString = rCell.getString();
+            aString = rCell.getString(pDoc);
         break;
         case CELLTYPE_VALUE:
             rFormatter.GetInputLineString(rCell.mfValue, nFormat, aString );
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 5265722..62461eb 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -1503,15 +1503,15 @@ void ScChangeActionContent::SetOldValue( const OUString& rOld, ScDocument* pDoc
 }
 
 
-void ScChangeActionContent::GetOldString( OUString& rStr ) const
+void ScChangeActionContent::GetOldString( OUString& rStr, const ScDocument* pDoc ) const
 {
-    GetValueString(rStr, maOldValue, maOldCell);
+    GetValueString(rStr, maOldValue, maOldCell, pDoc);
 }
 
 
-void ScChangeActionContent::GetNewString( OUString& rStr ) const
+void ScChangeActionContent::GetNewString( OUString& rStr, const ScDocument* pDoc ) const
 {
-    GetValueString(rStr, maNewValue, maNewCell);
+    GetValueString(rStr, maNewValue, maNewCell, pDoc);
 }
 
 const ScCellValue& ScChangeActionContent::GetOldCell() const
@@ -1542,7 +1542,7 @@ void ScChangeActionContent::GetDescription(
         nPos += aTmpStr.getLength();
     }
 
-    GetOldString( aTmpStr );
+    GetOldString( aTmpStr, pDoc );
     if (aTmpStr.isEmpty())
         aTmpStr = ScGlobal::GetRscString( STR_CHANGED_BLANK );
 
@@ -1553,7 +1553,7 @@ void ScChangeActionContent::GetDescription(
         nPos += aTmpStr.getLength();
     }
 
-    GetNewString( aTmpStr );
+    GetNewString( aTmpStr, pDoc );
     if (aTmpStr.isEmpty())
         aTmpStr = ScGlobal::GetRscString( STR_CHANGED_BLANK );
 
@@ -1717,7 +1717,7 @@ void ScChangeActionContent::GetStringOfCell(
         break;
         case CELLTYPE_EDIT:
             if (rCell.mpEditText)
-                rStr = ScEditUtil::GetString(*rCell.mpEditText);
+                rStr = ScEditUtil::GetString(*rCell.mpEditText, pDoc);
         break;
         case CELLTYPE_FORMULA:
             rCell.mpFormula->GetFormula(rStr);
@@ -1852,7 +1852,7 @@ void ScChangeActionContent::SetCell( OUString& rStr, ScCellValue& rCell, sal_uLo
 
 
 void ScChangeActionContent::GetValueString(
-    OUString& rStr, const OUString& rValue, const ScCellValue& rCell ) const
+    OUString& rStr, const OUString& rValue, const ScCellValue& rCell, const ScDocument* pDoc ) const
 {
     if (!rValue.isEmpty())
     {
@@ -1867,7 +1867,7 @@ void ScChangeActionContent::GetValueString(
         break;
         case CELLTYPE_EDIT :
             if (rCell.mpEditText)
-                rStr = ScEditUtil::GetString(*rCell.mpEditText);
+                rStr = ScEditUtil::GetString(*rCell.mpEditText, pDoc);
         break;
         case CELLTYPE_VALUE :   // ist immer in rValue
             rStr = rValue;
@@ -4580,7 +4580,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const
             ScCellValue aClonedNewCell;
             aClonedNewCell.assign(rNewCell, *pDocument);
             OUString aNewValue;
-            pContent->GetNewString( aNewValue );
+            pContent->GetNewString( aNewValue, pDocument );
             pClonedTrack->nGeneratedMin = pGenerated->GetActionNumber() + 1;
             pClonedTrack->AddLoadedGenerated(aClonedNewCell, pGenerated->GetBigRange(), aNewValue);
         }
@@ -4665,7 +4665,7 @@ ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const
                     ScCellValue aClonedOldCell;
                     aClonedOldCell.assign(rOldCell, *pDocument);
                     OUString aOldValue;
-                    pContent->GetOldString( aOldValue );
+                    pContent->GetOldString( aOldValue, pDocument );
 
                     ScChangeActionContent* pClonedContent = new ScChangeActionContent(
                         pAction->GetActionNumber(),
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index a74b62a..ea87597 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -68,40 +68,49 @@ OUString ScEditUtil::ModifyDelimiters( const OUString& rOld )
     return aRet;
 }
 
-static String lcl_GetDelimitedString( const EditEngine& rEngine, const sal_Char c )
+static OUString lcl_GetDelimitedString( const EditEngine& rEngine, const sal_Char c )
 {
-    String aRet;
     sal_Int32 nParCount = rEngine.GetParagraphCount();
+    OUStringBuffer aRet( nParCount * 80 );
     for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
     {
         if (nPar > 0)
-            aRet += c;
-        aRet += rEngine.GetText( nPar );
+            aRet.append(c);
+        aRet.append( rEngine.GetText( nPar ));
     }
-    return aRet;
+    return aRet.makeStringAndClear();
 }
 
-String ScEditUtil::GetSpaceDelimitedString( const EditEngine& rEngine )
+OUString ScEditUtil::GetSpaceDelimitedString( const EditEngine& rEngine )
 {
     return lcl_GetDelimitedString(rEngine, ' ');
 }
 
-String ScEditUtil::GetMultilineString( const EditEngine& rEngine )
+OUString ScEditUtil::GetMultilineString( const EditEngine& rEngine )
 {
     return lcl_GetDelimitedString(rEngine, '\n');
 }
 
-OUString ScEditUtil::GetString( const EditTextObject& rEditText )
+OUString ScEditUtil::GetString( const EditTextObject& rEditText, const ScDocument* pDoc )
 {
-    OUStringBuffer aRet;
-    sal_Int32 n = rEditText.GetParagraphCount();
-    for (sal_Int32 i = 0; i < n; ++i)
+    // ScFieldEditEngine is needed to resolve field contents.
+    if (pDoc)
     {
-        if (i > 0)
-            aRet.append('\n');
-        aRet.append(rEditText.GetText(i));
+        /* TODO: make ScDocument::GetEditEngine() const? Most likely it's only
+         * not const because of the pointer assignment, make that mutable, and
+         * then remove the ugly const_cast here. */
+        EditEngine& rEE = const_cast<ScDocument*>(pDoc)->GetEditEngine();
+        rEE.SetText( rEditText);
+        return GetMultilineString( rEE);
+    }
+    else
+    {
+        static osl::Mutex aMutex;
+        osl::MutexGuard aGuard( aMutex);
+        EditEngine& rEE = ScGlobal::GetStaticFieldEditEngine();
+        rEE.SetText( rEditText);
+        return GetMultilineString( rEE);
     }
-    return aRet.makeStringAndClear();
 }
 
 EditTextObject* ScEditUtil::CreateURLObjectFromURL( ScDocument& rDoc, const OUString& rURL, const OUString& rText )
@@ -817,6 +826,12 @@ OUString ScFieldEditEngine::CalcFieldValue( const SvxFieldItem& rField,
             const SvxExtTimeField* pField = static_cast<const SvxExtTimeField*>(pFieldData);
             if (mpDoc)
                 aRet = pField->GetFormatted(*mpDoc->GetFormatTable(), ScGlobal::eLnge);
+            else
+            {
+                /* TODO: quite expensive, we could have a global formatter? */
+                SvNumberFormatter aFormatter( comphelper::getProcessComponentContext(), ScGlobal::eLnge );
+                aRet = pField->GetFormatted( aFormatter, ScGlobal::eLnge);
+            }
         }
         break;
         case text::textfield::Type::DATE:
@@ -827,10 +842,18 @@ OUString ScFieldEditEngine::CalcFieldValue( const SvxFieldItem& rField,
         break;
         case text::textfield::Type::DOCINFO_TITLE:
         {
-            SfxObjectShell* pDocShell = mpDoc->GetDocumentShell();
-            aRet = pDocShell->getDocProperties()->getTitle();
+            if (mpDoc)
+            {
+                SfxObjectShell* pDocShell = mpDoc->GetDocumentShell();
+                if (pDocShell)
+                {
+                    aRet = pDocShell->getDocProperties()->getTitle();
+                    if (aRet.isEmpty())
+                        aRet = pDocShell->GetTitle();
+                }
+            }
             if (aRet.isEmpty())
-                aRet = pDocShell->GetTitle();
+                aRet = "?";
         }
         break;
         case text::textfield::Type::TABLE:
@@ -838,7 +861,7 @@ OUString ScFieldEditEngine::CalcFieldValue( const SvxFieldItem& rField,
             const SvxTableField* pField = static_cast<const SvxTableField*>(pFieldData);
             SCTAB nTab = pField->GetTab();
             OUString aName;
-            if (mpDoc->GetName(nTab, aName))
+            if (mpDoc && mpDoc->GetName(nTab, aName))
                 aRet = aName;
             else
                 aRet = "?";
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index c3a47a4..5ad79c4 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -485,7 +485,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, ScRefCellValue&
         {
             // SUM(A1:A2) differs from A1+A2. No good. But people insist on
             // it ... #i5658#
-            OUString aStr = rCell.getString();
+            OUString aStr = rCell.getString(pDok);
             fValue = ConvertStringToValue( aStr );
         }
         break;
@@ -505,7 +505,7 @@ void ScInterpreter::GetCellString( OUString& rStr, ScRefCellValue& rCell )
     {
         case CELLTYPE_STRING:
         case CELLTYPE_EDIT:
-            rStr = rCell.getString();
+            rStr = rCell.getString(pDok);
         break;
         case CELLTYPE_FORMULA:
         {
@@ -669,7 +669,7 @@ bool ScInterpreter::CreateStringArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
                     {
                         case CELLTYPE_STRING:
                         case CELLTYPE_EDIT:
-                            aStr = aCell.getString();
+                            aStr = aCell.getString(pDok);
                             break;
                         case CELLTYPE_FORMULA:
                             if (!aCell.mpFormula->IsValue())
@@ -773,7 +773,7 @@ bool ScInterpreter::CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
                     {
                         case CELLTYPE_STRING :
                         case CELLTYPE_EDIT :
-                            aStr = aCell.getString();
+                            aStr = aCell.getString(pDok);
                             nType = 1;
                             break;
                         case CELLTYPE_VALUE :
@@ -3391,7 +3391,7 @@ bool ScInterpreter::SetSbxVariable( SbxVariable* pVar, const ScAddress& rPos )
             break;
             case CELLTYPE_STRING :
             case CELLTYPE_EDIT :
-                pVar->PutString(aCell.getString());
+                pVar->PutString(aCell.getString(pDok));
             break;
             case CELLTYPE_FORMULA :
                 nErr = aCell.mpFormula->GetErrCode();
diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx
index 11743c7..db55a3f 100644
--- a/sc/source/core/tool/rangeseq.cxx
+++ b/sc/source/core/tool/rangeseq.cxx
@@ -282,7 +282,7 @@ sal_Bool ScRangeToSequence::FillMixedArray( uno::Any& rAny, ScDocument* pDoc, co
             else if (aCell.hasNumeric())
                 rElement <<= aCell.getValue();
             else
-                rElement <<= aCell.getString();
+                rElement <<= aCell.getString(pDoc);
         }
         pRowAry[nRow] = aColSeq;
     }
diff --git a/sc/source/filter/dif/difexp.cxx b/sc/source/filter/dif/difexp.cxx
index e4b5a77..91d6f9f 100644
--- a/sc/source/filter/dif/difexp.cxx
+++ b/sc/source/filter/dif/difexp.cxx
@@ -182,7 +182,7 @@ FltError ScFormatFilterPluginImpl::ScExportDif( SvStream& rOut, ScDocument* pDoc
                 break;
                 case CELLTYPE_EDIT:
                 case CELLTYPE_STRING:
-                    aString = aCell.getString();
+                    aString = aCell.getString(pDoc);
                     bWriteStringData = true;
                 break;
                 case CELLTYPE_FORMULA:
diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx
index 603dfee..5cbf833 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -1141,7 +1141,7 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
                 break;
             //! else: fallthru
         default:
-            ScCellFormat::GetString(aCell, nFormat, aStrOut, &pColor, *pFormatter);
+            ScCellFormat::GetString(aCell, nFormat, aStrOut, &pColor, *pFormatter, pDoc);
     }
 
     if ( !bFieldText )
diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
index 5e37df0..e6a05fb 100644
--- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
@@ -854,7 +854,7 @@ void XclExpChTrCellContent::GetCellData(
                 XclExpHyperlinkHelper aLinkHelper( rRoot, aPosition );
                 if (rScCell.mpEditText)
                 {
-                    sCellStr = ScEditUtil::GetString(*rScCell.mpEditText);
+                    sCellStr = ScEditUtil::GetString(*rScCell.mpEditText, &GetDoc());
                     rpData->mpFormattedString = XclExpStringHelper::CreateCellString(
                         rRoot, *rScCell.mpEditText, NULL, aLinkHelper);
                 }
diff --git a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx
index d6b60eb..551a2b2 100644
--- a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx
+++ b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx
@@ -153,7 +153,7 @@ void ScChangeTrackingExportHelper::WriteGenerated(const ScChangeAction* pGenerat
     SvXMLElementExport aElemPrev(rExport, XML_NAMESPACE_TABLE, XML_CELL_CONTENT_DELETION, true, true);
     WriteBigRange(pGeneratedAction->GetBigRange(), XML_CELL_ADDRESS);
     OUString sValue;
-    static_cast<const ScChangeActionContent*>(pGeneratedAction)->GetNewString(sValue);
+    static_cast<const ScChangeActionContent*>(pGeneratedAction)->GetNewString(sValue, rExport.GetDocument());
     WriteCell(static_cast<const ScChangeActionContent*>(pGeneratedAction)->GetNewCell(), sValue);
 }
 
@@ -172,7 +172,7 @@ void ScChangeTrackingExportHelper::WriteDeleted(const ScChangeAction* pDeletedAc
                 if (static_cast<const ScChangeActionContent*>(pDeletedAction)->IsTopContent() && pDeletedAction->IsDeletedIn())
                 {
                     OUString sValue;
-                    pContentAction->GetNewString(sValue);
+                    pContentAction->GetNewString(sValue, rExport.GetDocument());
                     WriteCell(pContentAction->GetNewCell(), sValue);
                 }
             }
@@ -307,7 +307,7 @@ void ScChangeTrackingExportHelper::WriteEditCell(const ScCellValue& rCell)
 
     OUString sString;
     if (rCell.mpEditText)
-        sString = ScEditUtil::GetString(*rCell.mpEditText);
+        sString = ScEditUtil::GetString(*rCell.mpEditText, rExport.GetDocument());
 
     rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING);
     SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_CHANGE_TRACK_TABLE_CELL, true, true);
@@ -424,7 +424,7 @@ void ScChangeTrackingExportHelper::WriteContentChange(ScChangeAction* pAction)
             rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ID, GetChangeID(pPrevAction->GetActionNumber()));
         SvXMLElementExport aElemPrev(rExport, XML_NAMESPACE_TABLE, XML_PREVIOUS, true, true);
         OUString sValue;
-        static_cast<ScChangeActionContent*>(pAction)->GetOldString(sValue);
+        static_cast<ScChangeActionContent*>(pAction)->GetOldString(sValue, rExport.GetDocument());
         WriteCell(static_cast<ScChangeActionContent*>(pAction)->GetOldCell(), sValue);
     }
 }
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 33535ac..4b39da6 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1935,7 +1935,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
                         }
                         else
                         {
-                            ScCellFormat::GetInputString(*pCell, nFormat, aString, rFormatter);
+                            ScCellFormat::GetInputString(*pCell, nFormat, aString, rFormatter, &aDocument);
                             bString = false;
                         }
                     }
@@ -1985,7 +1985,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
                     }
                     else
                     {
-                        ScCellFormat::GetInputString(*pCell, nFormat, aString, rFormatter);
+                        ScCellFormat::GetInputString(*pCell, nFormat, aString, rFormatter, &aDocument);
                         bString = false;
                     }
                 }
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index afa49ba..c07913f 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -940,7 +940,7 @@ void ScDocShell::MergeDocument( ScDocument& rOtherDoc, bool bShared, bool bCheck
 #if OSL_DEBUG_LEVEL > 0
                 OUString aValue;
                 if ( eSourceType == SC_CAT_CONTENT )
-                    ((const ScChangeActionContent*)pSourceAction)->GetNewString( aValue );
+                    ((const ScChangeActionContent*)pSourceAction)->GetNewString( aValue, &aDocument );
                 OStringBuffer aError(OUStringToOString(aValue,
                     osl_getThreadTextEncoding()));
                 aError.append(RTL_CONSTASCII_STRINGPARAM(" weggelassen"));
@@ -1005,7 +1005,7 @@ void ScDocShell::MergeDocument( ScDocument& rOtherDoc, bool bShared, bool bCheck
                             OSL_ENSURE( aSourceRange.aStart == aSourceRange.aEnd, "huch?" );
                             ScAddress aPos = aSourceRange.aStart;
                             OUString aValue;
-                            ((const ScChangeActionContent*)pSourceAction)->GetNewString( aValue );
+                            ((const ScChangeActionContent*)pSourceAction)->GetNewString( aValue, &aDocument );
                             sal_uInt8 eMatrix = MM_NONE;
                             const ScCellValue& rCell = ((const ScChangeActionContent*)pSourceAction)->GetNewCell();
                             if (rCell.meType == CELLTYPE_FORMULA)
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 87a9b16..4ab3d03 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1274,7 +1274,7 @@ static FormulaToken* convertToToken( ScRefCellValue& rCell )
     {
         case CELLTYPE_EDIT:
         case CELLTYPE_STRING:
-            return new formula::FormulaStringToken(rCell.getString());
+            return new formula::FormulaStringToken(rCell.getString(NULL));
         case CELLTYPE_VALUE:
             return new formula::FormulaDoubleToken(rCell.mfValue);
         case CELLTYPE_FORMULA:
@@ -1364,7 +1364,7 @@ static ScTokenArray* convertToTokenArray(
                 {
                     case CELLTYPE_EDIT:
                     case CELLTYPE_STRING:
-                        xMat->PutString(aCell.getString(), nC, nR);
+                        xMat->PutString(aCell.getString(NULL), nC, nR);
                     break;
                     case CELLTYPE_VALUE:
                         xMat->PutDouble(aCell.mfValue, nC, nR);
diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx
index 4580909..7c5f54b 100644
--- a/sc/source/ui/miscdlgs/acredlin.cxx
+++ b/sc/source/ui/miscdlgs/acredlin.cxx
@@ -663,7 +663,7 @@ SvTreeListEntry* ScAcceptChgDlg::InsertChangeActionContent(const ScChangeActionC
     if(nSpecial==RD_SPECIAL_CONTENT)
     {
         OUString aTmp;
-        pScChangeAction->GetOldString(aTmp);
+        pScChangeAction->GetOldString(aTmp, pDoc);
         a2String = aTmp;
         if(a2String.Len()==0) a2String=aStrEmpty;
 
@@ -677,7 +677,7 @@ SvTreeListEntry* ScAcceptChgDlg::InsertChangeActionContent(const ScChangeActionC
     else
     {
         OUString aTmp;
-        pScChangeAction->GetNewString(aTmp);
+        pScChangeAction->GetNewString(aTmp, pDoc);
         a2String = aTmp;
         if(a2String.Len()==0)
         {
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index f1c288f..51a9b8d 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1379,7 +1379,7 @@ static OUString lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPos, sal
         }
     }
     else
-        ScCellFormat::GetInputString(aCell, nNumFmt, aVal, *pFormatter);
+        ScCellFormat::GetInputString(aCell, nNumFmt, aVal, *pFormatter, pDoc);
 
     //  ggf. ein ' davorhaengen wie in ScTabViewShell::UpdateInputHandler
     if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
@@ -2313,7 +2313,7 @@ void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pE
                             ScRefCellValue aCell;
                             aCell.assign(*pDoc, aAddr);
 
-                            OUString aStr = aCell.getString();
+                            OUString aStr = aCell.getString(pDoc);
                             EditEngine aEngine( pDoc->GetEnginePool() );
                             aEngine.SetEditTextObjectPool(pDoc->GetEditPool());
 
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 1491613..af55bcd 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -501,6 +501,7 @@ bool ScDrawStringsVars::SetText( ScRefCellValue& rCell )
             ScCellFormat::GetString( rCell,
                                      nFormat, aOUString, &pColor,
                                      *pOutput->mpDoc->GetFormatTable(),
+                                     pOutput->mpDoc,
                                      pOutput->mbShowNullValues,
                                      pOutput->mbShowFormulas,
                                      ftCheck, true );
@@ -2287,6 +2288,7 @@ bool ScOutputData::DrawEditParam::readCellContent(
         ScCellFormat::GetString( maCell,
                                  nFormat,aString, &pColor,
                                  *pDoc->GetFormatTable(),
+                                 pDoc,
                                  bShowNullValues,
                                  bShowFormulas,
                                  ftCheck );
@@ -4933,6 +4935,7 @@ void ScOutputData::DrawRotated(sal_Bool bPixelToLogic)
                                 ScCellFormat::GetString( aCell,
                                                          nFormat,aString, &pColor,
                                                          *mpDoc->GetFormatTable(),
+                                                         mpDoc,
                                                          mbShowNullValues,
                                                          mbShowFormulas,
                                                          ftCheck );


More information about the Libreoffice-commits mailing list