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

Kohei Yoshida kohei.yoshida at gmail.com
Wed Mar 20 17:04:23 PDT 2013


 sc/source/ui/docshell/docfunc.cxx |   47 +++++++++++++++++++++++++++-----------
 sc/source/ui/inc/docfunc.hxx      |    2 +
 sc/source/ui/unoobj/cellsuno.cxx  |   12 ---------
 3 files changed, 37 insertions(+), 24 deletions(-)

New commits:
commit 17de070cda66c3417899ea314147acb39bf99e21
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Mar 20 20:04:00 2013 -0400

    Another PutCell() gone.
    
    Change-Id: I9ea44c38b13f2158aa1fb25cf6d1d50abe78e4a5

diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index bb59dd3..ea63f54 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -931,6 +931,21 @@ bool ScDocFunc::SetEditCell( const ScAddress& rPos, const EditTextObject& rStr,
     return true;
 }
 
+bool ScDocFunc::SetStringOrEditCell( const ScAddress& rPos, const OUString& rStr, bool bInteraction )
+{
+    ScDocument* pDoc = rDocShell.GetDocument();
+
+    if (ScStringUtil::isMultiline(rStr))
+    {
+        ScFieldEditEngine& rEngine = pDoc->GetEditEngine();
+        rEngine.SetText(rStr);
+        boost::scoped_ptr<EditTextObject> pEditText(rEngine.CreateTextObject());
+        return SetEditCell(rPos, *pEditText, bInteraction);
+    }
+    else
+        return SetStringCell(rPos, rStr, bInteraction);
+}
+
 bool ScDocFunc::SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell, bool bInteraction )
 {
     SAL_WNODEPRECATED_DECLARATIONS_PUSH
@@ -1216,33 +1231,39 @@ sal_Bool ScDocFunc::SetCellText( const ScAddress& rPos, const String& rText,
         sal_Bool bInterpret, sal_Bool bEnglish, sal_Bool bApi,
         const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar )
 {
-    //  SetCellText ruft PutCell oder SetNormalString
-
-    ScDocument* pDoc = rDocShell.GetDocument();
-
     if ( bInterpret )
     {
         if ( bEnglish )
         {
+            ScDocument* pDoc = rDocShell.GetDocument();
+
             ::boost::scoped_ptr<ScExternalRefManager::ApiGuard> pExtRefGuard;
             if (bApi)
                 pExtRefGuard.reset(new ScExternalRefManager::ApiGuard(pDoc));
 
-            //  code moved to own method InterpretEnglishString because it is also used in
-            //  ScCellRangeObj::setFormulaArray
+            ScInputStringType aRes =
+                ScStringUtil::parseInputString(*pDoc->GetFormatTable(), rText, LANGUAGE_ENGLISH_US);
 
-            ScBaseCell* pNewCell = InterpretEnglishString( rPos, rText, rFormulaNmsp, eGrammar );
-            if (pNewCell)
-                return PutCell( rPos, pNewCell, bApi );
+            switch (aRes.meType)
+            {
+                case ScInputStringType::Formula:
+                    SetFormulaCell(rPos, new ScFormulaCell(pDoc, rPos, aRes.maText, eGrammar), !bApi);
+                break;
+                case ScInputStringType::Number:
+                    SetValueCell(rPos, aRes.mfValue, !bApi);
+                break;
+                case ScInputStringType::Text:
+                    SetStringOrEditCell(rPos, aRes.maText, !bApi);
+                break;
+                default:
+                    ;
+            }
         }
         // sonst Null behalten -> SetString mit lokalen Formeln/Zahlformat
     }
     else if ( rText.Len() )
     {
-        OSL_ENSURE( rFormulaNmsp.Len() == 0, "ScDocFunc::SetCellText - formula namespace, but do not interpret?" );
-        ScBaseCell* pNewCell = ScBaseCell::CreateTextCell( rText, pDoc );   // immer Text
-        if (pNewCell)
-            return PutCell( rPos, pNewCell, bApi );
+        SetStringOrEditCell(rPos, rText, !bApi);
     }
 
     bool bNumFmtSet = false;
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index 9053b4b..ca28cf0 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -93,6 +93,8 @@ public:
     virtual bool SetStringCell( const ScAddress& rPos, const OUString& rStr, bool bInteraction );
     virtual bool SetEditCell( const ScAddress& rPos, const EditTextObject& rStr, bool bInteraction );
 
+    bool SetStringOrEditCell( const ScAddress& rPos, const OUString& rStr, bool bInteraction );
+
     /**
      * This method takes ownership of the formula cell instance. The caller
      * must not delete it after passing it to this call.
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index dde15a6..450c681 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6387,17 +6387,7 @@ void ScCellObj::InputEnglishString( const ::rtl::OUString& rText )
             rFunc.SetValueCell(aCellPos, aRes.mfValue, false);
         break;
         case ScInputStringType::Text:
-        {
-            if (ScStringUtil::isMultiline(aRes.maText))
-            {
-                ScFieldEditEngine& rEngine = pDoc->GetEditEngine();
-                rEngine.SetText(aRes.maText);
-                boost::scoped_ptr<EditTextObject> pEditText(rEngine.CreateTextObject());
-                rFunc.SetEditCell(aCellPos, *pEditText, false);
-            }
-            else
-                rFunc.SetStringCell(aCellPos, aRes.maText, false);
-        }
+            rFunc.SetStringOrEditCell(aCellPos, aRes.maText, false);
         break;
         default:
             SetString_Impl(aString, false, false); // probably empty string


More information about the Libreoffice-commits mailing list