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

Kohei Yoshida kohei.yoshida at gmail.com
Tue Mar 26 19:07:34 PDT 2013


 sc/inc/cellform.hxx              |    4 +-
 sc/source/core/data/column3.cxx  |   20 +++++++----
 sc/source/core/data/dociter.cxx  |   31 ++++++++----------
 sc/source/core/data/table3.cxx   |    5 ++
 sc/source/core/tool/cellform.cxx |   66 ++++++++++++++-------------------------
 sc/source/ui/docshell/docsh.cxx  |    8 +++-
 sc/source/ui/unoobj/cellsuno.cxx |    6 ++-
 7 files changed, 68 insertions(+), 72 deletions(-)

New commits:
commit d9c2157783aca6dc5fe8da5ccaf4ee26381515dc
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Mar 26 22:07:12 2013 -0400

    GetInputString() now takes ScRefCellValue instead of ScBaseCell.
    
    Change-Id: Ibf746351eb111a03be4f00ec719a4428c5fe47a4

diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index c7083ec..15f233e 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -53,8 +53,8 @@ public:
         Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true,
         bool bFormula  = false, ScForceTextFmt eForceTextFmt = ftDontForce, bool bUseStarFormat = false );
 
-    static void     GetInputString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUString& rString,
-                                      SvNumberFormatter& rFormatter );
+    static void GetInputString(
+        ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString, SvNumberFormatter& rFormatter );
 };
 
 
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 8a70ce6..aa04f39 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1527,9 +1527,11 @@ void ScColumn::GetFilterEntries(SCROW nStartRow, SCROW nEndRow, std::vector<ScTy
             break;
 
         ScBaseCell* pCell = maItems[nIndex].pCell;
+        ScRefCellValue aCell;
+        aCell.assign(*maItems[nIndex].pCell);
         sal_uLong nFormat = GetNumberFormat( nRow );
 
-        ScCellFormat::GetInputString( pCell, nFormat, aString, *pFormatter );
+        ScCellFormat::GetInputString(aCell, nFormat, aString, *pFormatter);
 
         if ( pDocument->HasStringData( nCol, nRow, nTab ) )
         {
@@ -1778,11 +1780,12 @@ void ScColumn::GetInputString( SCROW nRow, rtl::OUString& rString ) const
     SCSIZE  nIndex;
     if (Search(nRow, nIndex))
     {
-        ScBaseCell* pCell = maItems[nIndex].pCell;
-        if (pCell->GetCellType() != CELLTYPE_NOTE)
+        ScRefCellValue aCell;
+        aCell.assign(*maItems[nIndex].pCell);
+        if (aCell.meType != CELLTYPE_NOTE)
         {
             sal_uLong nFormat = GetNumberFormat( nRow );
-            ScCellFormat::GetInputString( pCell, nFormat, rString, *(pDocument->GetFormatTable()) );
+            ScCellFormat::GetInputString(aCell, nFormat, rString, *(pDocument->GetFormatTable()));
         }
         else
             rString = rtl::OUString();
@@ -1996,14 +1999,15 @@ xub_StrLen ScColumn::GetMaxNumberStringLen(
         Search( nRowStart, nIndex );
         while ( nIndex < maItems.size() && (nRow = maItems[nIndex].nRow) <= nRowEnd )
         {
-            ScBaseCell* pCell = maItems[nIndex].pCell;
-            CellType eType = pCell->GetCellType();
+            ScRefCellValue aCell;
+            aCell.assign(*maItems[nIndex].pCell);
+            CellType eType = aCell.meType;
             if ( eType == CELLTYPE_VALUE || (eType == CELLTYPE_FORMULA
-                    && ((ScFormulaCell*)pCell)->IsValue()) )
+                    && aCell.mpFormula->IsValue()) )
             {
                 sal_uLong nFormat = (sal_uLong) ((SfxUInt32Item*) GetAttr(
                     nRow, ATTR_VALUE_FORMAT ))->GetValue();
-                ScCellFormat::GetInputString( pCell, nFormat, aString, *pNumFmt );
+                ScCellFormat::GetInputString(aCell, nFormat, aString, *pNumFmt);
                 xub_StrLen nLen = aString.getLength();
                 if ( nLen )
                 {
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 6d8f758..dadf501 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1482,6 +1482,7 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
     if (!pCol->maItems.size())
         return 0;
 
+    ScRefCellValue aCell;
     ScBaseCell* pCell;
     SCSIZE nHi, nLo;
     CollatorWrapper* pCollator = (mpParam->bCaseSens ? ScGlobal::GetCaseCollator() :
@@ -1503,8 +1504,8 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
     {
         rtl::OUString aCellStr;
         sal_uLong nFormat = pCol->GetNumberFormat( pCol->maItems[nLo].nRow);
-        ScCellFormat::GetInputString( pCol->maItems[nLo].pCell, nFormat, aCellStr,
-                rFormatter);
+        aCell.assign(*pCol->maItems[nLo].pCell);
+        ScCellFormat::GetInputString(aCell, nFormat, aCellStr, rFormatter);
         sal_Int32 nTmp = pCollator->compareString(aCellStr, rEntry.GetQueryItem().maString);
         if ((rEntry.eOp == SC_LESS_EQUAL && nTmp > 0) ||
                 (rEntry.eOp == SC_GREATER_EQUAL && nTmp < 0) ||
@@ -1529,27 +1530,24 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
         aLastInRangeString.Assign( sal_Unicode(0xFFFF));
     if (nLastInRange < pCol->maItems.size())
     {
-        pCell = pCol->maItems[nLastInRange].pCell;
-        if (pCell->HasStringData())
+        aCell.assign(*pCol->maItems[nLastInRange].pCell);
+        if (aCell.hasString())
         {
             sal_uLong nFormat = pCol->GetNumberFormat( pCol->maItems[nLastInRange].nRow);
-            rtl::OUString aStr;
-            ScCellFormat::GetInputString( pCell, nFormat, aStr,
-                    rFormatter);
+            OUString aStr;
+            ScCellFormat::GetInputString(aCell, nFormat, aStr, rFormatter);
             aLastInRangeString = aStr;
         }
         else
         {
-            switch ( pCell->GetCellType() )
+            switch (aCell.meType)
             {
                 case CELLTYPE_VALUE :
-                    fLastInRangeValue =
-                        static_cast<ScValueCell*>(pCell)->GetValue();
-                    break;
+                    fLastInRangeValue = aCell.mfValue;
+                break;
                 case CELLTYPE_FORMULA :
-                    fLastInRangeValue =
-                        static_cast<ScFormulaCell*>(pCell)->GetValue();
-                    break;
+                    fLastInRangeValue = aCell.mpFormula->GetValue();
+                break;
                 default:
                 {
                     // added to avoid warnings
@@ -1639,8 +1637,9 @@ ScBaseCell* ScQueryCellIterator::BinarySearch()
         {
             rtl::OUString aCellStr;
             sal_uLong nFormat = pCol->GetNumberFormat( pCol->maItems[i].nRow);
-            ScCellFormat::GetInputString( pCol->maItems[i].pCell, nFormat, aCellStr,
-                    rFormatter);
+            aCell.assign(*pCol->maItems[i].pCell);
+            ScCellFormat::GetInputString(aCell, nFormat, aCellStr, rFormatter);
+
             nRes = pCollator->compareString(aCellStr, rEntry.GetQueryItem().maString);
             if (nRes < 0 && bLessEqual)
             {
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index f8e4413..a16d945 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -52,6 +52,7 @@
 #include "segmenttree.hxx"
 #include "subtotalparam.hxx"
 #include "docpool.hxx"
+#include "cellvalue.hxx"
 
 #include <vector>
 #include <boost/unordered_set.hpp>
@@ -1367,7 +1368,9 @@ public:
             else if (pCell->GetCellType() != CELLTYPE_NOTE)
             {
                 sal_uLong nFormat = mrTab.GetNumberFormat( static_cast<SCCOL>(rEntry.nField), nRow );
-                ScCellFormat::GetInputString(pCell, nFormat, aCellStr, *mrDoc.GetFormatTable());
+                ScRefCellValue aCell;
+                aCell.assign(*pCell);
+                ScCellFormat::GetInputString(aCell, nFormat, aCellStr, *mrDoc.GetFormatTable());
             }
         }
         else
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 8d0a903..d60627b 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -231,60 +231,42 @@ OUString ScCellFormat::GetString(
     return aString;
 }
 
-void ScCellFormat::GetInputString( ScBaseCell* pCell, sal_uLong nFormat, OUString& rString,
-                                      SvNumberFormatter& rFormatter )
+void ScCellFormat::GetInputString(
+    ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString, SvNumberFormatter& rFormatter )
 {
-    if (&rFormatter==NULL)
+    if (&rFormatter == NULL)
     {
-        rString = OUString();
+        rString = EMPTY_OUSTRING;
         return;
     }
 
-    String aString = rString;
-    CellType eType = pCell->GetCellType();
-    switch(eType)
+    OUString aString = rString;
+    switch (rCell.meType)
     {
         case CELLTYPE_STRING:
-            {
-                aString = ((ScStringCell*)pCell)->GetString();
-            }
-            break;
         case CELLTYPE_EDIT:
-            {
-                aString = ((ScEditCell*)pCell)->GetString();
-            }
-            break;
+            aString = rCell.getString();
+        break;
         case CELLTYPE_VALUE:
-            {
-                double nValue = ((ScValueCell*)pCell)->GetValue();
-                rFormatter.GetInputLineString( nValue, nFormat, aString );
-            }
-            break;
+            rFormatter.GetInputLineString(rCell.mfValue, nFormat, aString );
+        break;
         case CELLTYPE_FORMULA:
-            {
-                if (((ScFormulaCell*)pCell)->IsEmptyDisplayedAsString())
-                {
-                    aString.Erase();
-                }
-                else if (((ScFormulaCell*)pCell)->IsValue())
-                {
-                    double nValue = ((ScFormulaCell*)pCell)->GetValue();
-                    rFormatter.GetInputLineString( nValue, nFormat, aString );
-                }
-                else
-                {
-                    aString = ((ScFormulaCell*)pCell)->GetString();
-                }
+        {
+            ScFormulaCell* pFC = rCell.mpFormula;
+            if (pFC->IsEmptyDisplayedAsString())
+                aString = EMPTY_OUSTRING;
+            else if (pFC->IsValue())
+                rFormatter.GetInputLineString(pFC->GetValue(), nFormat, aString);
+            else
+                aString = pFC->GetString();
 
-                sal_uInt16 nErrCode = ((ScFormulaCell*)pCell)->GetErrCode();
-                if (nErrCode != 0)
-                {
-                    aString.Erase();
-                }
-            }
-            break;
+            sal_uInt16 nErrCode = pFC->GetErrCode();
+            if (nErrCode != 0)
+                aString = EMPTY_OUSTRING;
+        }
+        break;
         default:
-            aString.Erase();
+            aString = EMPTY_OUSTRING;
             break;
     }
     rString = aString;
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index cf4bcac..b87bb7b 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1921,7 +1921,9 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
                         }
                         else
                         {
-                            ScCellFormat::GetInputString( pCell, nFormat, aString, rFormatter );
+                            ScRefCellValue aCell;
+                            aCell.assign(*pCell);
+                            ScCellFormat::GetInputString(aCell, nFormat, aString, rFormatter);
                             bString = false;
                         }
                     }
@@ -1971,7 +1973,9 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
                     }
                     else
                     {
-                        ScCellFormat::GetInputString( pCell, nFormat, aString, rFormatter );
+                        ScRefCellValue aCell;
+                        aCell.assign(*pCell);
+                        ScCellFormat::GetInputString(aCell, nFormat, aString, rFormatter);
                         bString = false;
                     }
                 }
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index aa403d7..45e41da 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1427,7 +1427,11 @@ static String lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPosition,
                     }
                 }
                 else
-                    ScCellFormat::GetInputString( pCell, nNumFmt, aVal, *pFormatter );
+                {
+                    ScRefCellValue aCell;
+                    aCell.assign(*pCell);
+                    ScCellFormat::GetInputString(aCell, nNumFmt, aVal, *pFormatter);
+                }
 
                 //  ggf. ein ' davorhaengen wie in ScTabViewShell::UpdateInputHandler
                 if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )


More information about the Libreoffice-commits mailing list