diff options
author | Eike Rathke <erack@redhat.com> | 2013-07-25 15:33:49 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-07-25 16:11:09 +0200 |
commit | 1ecdc7aaf661e97a33cf521f553481d79cd26de2 (patch) | |
tree | 34811d2f9f17691c749622ff61a42b79f1da15d5 | |
parent | bb98778dbf761a0c88c96117add00a66e5cc6c95 (diff) |
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
33 files changed, 191 insertions, 111 deletions
diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx index 6a164a0c98e8..d384e54d5916 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 43e7a058b377..0e2987cfc04b 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 aef13cf562c8..872f268599e0 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 10bec821b00a..88a42e8696da 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 2b86a7c1e6db..69e22f530f79 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 79d31c85b524..49ec5fd7b3c8 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 7d081bc1ee1f..5e7213642483 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 8e6283605f9a..2c4041886541 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 da3cb4927613..523362918688 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 4d6c3fe65278..ab6c88a2e1a5 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 1e0ec16339e4..a787df3a383f 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 fe438af0a694..baef65684fdc 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 02cb39bb3bc4..a31b7aa03fad 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 f32fcd5c1c36..ef73c7cf4b40 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 1ca26a7e55ab..bc3136591dd0 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 99718164027f..0e30d0a8a678 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 5df625709dbd..3797a907e8b3 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 ea65bb596b32..eaee6510f185 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 a33405f9a05a..bc65f9199a39 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 526572225811..62461eb92fee 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 a74b62a299b0..ea87597db03a 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 c3a47a464634..5ad79c481944 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 11743c723ba0..db55a3fd1c13 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 e4b5a77dc123..91d6f9f70414 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 603dfee65738..5cbf833ca3b3 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 5e37df0c674b..e6a05fb90938 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 d6b60eb60231..551a2b2f440b 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 33535ac59835..4b39da6209bc 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 afa49ba356b0..c07913f882fe 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 87a9b16c84fa..4ab3d03ff747 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 45809091a11b..7c5f54b8a280 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 f1c288f2dcaf..51a9b8d72030 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 14916131e98d..af55bcd34e8e 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 ); |