[Libreoffice-commits] core.git: Branch 'libreoffice-4-2-2' - sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Tue Feb 25 23:01:07 PST 2014


 sc/source/ui/docshell/externalrefmgr.cxx |   33 +++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

New commits:
commit 392d4260a4dcde72d072ed1a8ab8dcfede18e031
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Feb 20 16:05:51 2014 -0500

    fdo#72041: Intern strings in the external ref cache with the host document.
    
    To ensure that string comparison with those from the external ref cache
    works correctly in functions such as VLOOKUP.
    
    Change-Id: Ib5a466cb6c4b26439abe61b0c17406fc8139f6c0
    (cherry picked from commit 2bcd18892f1903d2434bc5dc6828841e49bb78a2)
    Reviewed-on: https://gerrit.libreoffice.org/8149
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Reviewed-on: https://gerrit.libreoffice.org/8153
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 4646103..b2a19d9 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1300,7 +1300,7 @@ IMPL_LINK_NOARG(ScExternalRefLink, ExternalRefEndEditHdl)
 
 // ============================================================================
 
-static FormulaToken* convertToToken( ScRefCellValue& rCell )
+static FormulaToken* convertToToken( ScDocument* pHostDoc, ScDocument* pSrcDoc, ScRefCellValue& rCell )
 {
     if (rCell.hasEmptyValue())
     {
@@ -1312,7 +1312,11 @@ static FormulaToken* convertToToken( ScRefCellValue& rCell )
     {
         case CELLTYPE_EDIT:
         case CELLTYPE_STRING:
-            return new formula::FormulaStringToken(rCell.getString(NULL));
+        {
+            OUString aStr = rCell.getString(pSrcDoc);
+            svl::SharedString aSS = pHostDoc->GetSharedStringPool().intern(aStr);
+            return new formula::FormulaStringToken(aSS);
+        }
         case CELLTYPE_VALUE:
             return new formula::FormulaDoubleToken(rCell.mfValue);
         case CELLTYPE_FORMULA:
@@ -1342,13 +1346,20 @@ static FormulaToken* convertToToken( ScRefCellValue& rCell )
 template<class T>
 struct ColumnBatch
 {
+    ScDocument* mpHostDoc;
+    ScDocument* mpSrcDoc;
+
     std::vector<T> maStorage;
     CellType meType1;
     CellType meType2;
     SCROW mnRowStart;
 
-    ColumnBatch(CellType eType1, CellType eType2) :
-        meType1(eType1), meType2(eType2), mnRowStart(-1) {}
+    ColumnBatch( ScDocument* pHostDoc, ScDocument* pSrcDoc, CellType eType1, CellType eType2 ) :
+        mpHostDoc(pHostDoc),
+        mpSrcDoc(pSrcDoc),
+        meType1(eType1),
+        meType2(eType2),
+        mnRowStart(-1) {}
 
     void update(ScRefCellValue& raCell, const SCCOL nCol, const SCROW nRow, ScMatrixRef& xMat)
     {
@@ -1380,7 +1391,8 @@ struct ColumnBatch
 template<>
 inline svl::SharedString ColumnBatch<svl::SharedString>::getValue(ScRefCellValue& rCell) const
 {
-    return svl::SharedString(rCell.getString(NULL));
+    OUString aStr = rCell.getString(mpSrcDoc);
+    return mpHostDoc->GetSharedStringPool().intern(aStr);
 }
 
 template<class T>
@@ -1402,7 +1414,7 @@ inline void ColumnBatch<T>::putValues(ScMatrixRef& xMat, const SCCOL nCol) const
 }
 
 static ScTokenArray* convertToTokenArray(
-    ScDocument* pSrcDoc, ScRange& rRange, vector<ScExternalRefCache::SingleRangeData>& rCacheData )
+    ScDocument* pHostDoc, ScDocument* pSrcDoc, ScRange& rRange, vector<ScExternalRefCache::SingleRangeData>& rCacheData )
 {
     ScAddress& s = rRange.aStart;
     ScAddress& e = rRange.aEnd;
@@ -1448,8 +1460,8 @@ static ScTokenArray* convertToTokenArray(
             static_cast<SCSIZE>(nCol2-nCol1+1), static_cast<SCSIZE>(nRow2-nRow1+1));
 
         ScRefCellValue aCell;
-        ColumnBatch<svl::SharedString> aStringBatch(CELLTYPE_STRING, CELLTYPE_EDIT);
-        ColumnBatch<double> aDoubleBatch(CELLTYPE_VALUE, CELLTYPE_VALUE);
+        ColumnBatch<svl::SharedString> aStringBatch(pHostDoc, pSrcDoc, CELLTYPE_STRING, CELLTYPE_EDIT);
+        ColumnBatch<double> aDoubleBatch(pHostDoc, pSrcDoc, CELLTYPE_VALUE, CELLTYPE_VALUE);
 
         for (SCCOL nCol = nDataCol1; nCol <= nDataCol2; ++nCol)
         {
@@ -1483,6 +1495,7 @@ static ScTokenArray* convertToTokenArray(
                         else
                         {
                             svl::SharedString aStr = pFCell->GetString();
+                            aStr = pHostDoc->GetSharedStringPool().intern(aStr.getString());
                             xMat->PutString(aStr, nC, nR);
                         }
                     }
@@ -2033,7 +2046,7 @@ ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefTokenFromSrcDoc(
     // Get the cell from src doc, and convert it into a token.
     ScRefCellValue aCell;
     aCell.assign(*pSrcDoc, rPos);
-    ScExternalRefCache::TokenRef pToken(convertToToken(aCell));
+    ScExternalRefCache::TokenRef pToken(convertToToken(mpDoc, pSrcDoc, aCell));
 
     if (!pToken.get())
     {
@@ -2086,7 +2099,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokensFromSr
     aRange.aStart.SetTab(nTab1);
     aRange.aEnd.SetTab(nTab1 + nTabSpan);
 
-    pArray.reset(convertToTokenArray(pSrcDoc, aRange, aCacheData));
+    pArray.reset(convertToTokenArray(mpDoc, pSrcDoc, aRange, aCacheData));
     rRange = aRange;
     rCacheData.swap(aCacheData);
     return pArray;


More information about the Libreoffice-commits mailing list