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

Kohei Yoshida kohei.yoshida at collabora.com
Mon Nov 10 18:29:16 PST 2014


 sc/inc/clipcontext.hxx              |    2 
 sc/source/core/data/clipcontext.cxx |  126 ++++++++++++++++++++++++++++++++++++
 sc/source/core/data/document10.cxx  |  118 ---------------------------------
 3 files changed, 129 insertions(+), 117 deletions(-)

New commits:
commit 5ac3ade190258b62e0ab05e8befebfa083fb5651
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Nov 10 21:27:16 2014 -0500

    Scope reduction.
    
    Change-Id: Ic0cb74d220dccdcb4f607f4883b9b7fdf86bb080

diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx
index 85c079c..5fd08da 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -126,9 +126,9 @@ ScCellValue& CopyFromClipContext::getSingleCell( size_t nColOffset )
 void CopyFromClipContext::setSingleCell( const ScAddress& rSrcPos, const ScColumn& rSrcCol )
 {
     SCCOL nColOffset = rSrcPos.Col() - mpClipDoc->GetClipParam().getWholeRange().aStart.Col();
-
     ScCellValue& rSrcCell = getSingleCell(nColOffset);
-    if (isAsLink())
+
+    if (mbAsLink)
     {
         ScSingleRefData aRef;
         aRef.InitAddress(rSrcPos);
@@ -137,112 +137,111 @@ void CopyFromClipContext::setSingleCell( const ScAddress& rSrcPos, const ScColum
         ScTokenArray aArr;
         aArr.AddSingleReference(aRef);
         rSrcCell.set(new ScFormulaCell(mpClipDoc, rSrcPos, aArr));
+        return;
     }
-    else
+
+    rSrcCell.assign(*mpClipDoc, rSrcPos);
+
+    // Check the paste flag to see whether we want to paste this cell.  If the
+    // flag says we don't want to paste this cell, we'll return with true.
+    InsertDeleteFlags nFlags = getInsertFlag();
+    bool bNumeric  = (nFlags & IDF_VALUE) != IDF_NONE;
+    bool bDateTime = (nFlags & IDF_DATETIME) != IDF_NONE;
+    bool bString   = (nFlags & IDF_STRING) != IDF_NONE;
+    bool bBoolean  = (nFlags & IDF_SPECIAL_BOOLEAN) != IDF_NONE;
+    bool bFormula  = (nFlags & IDF_FORMULA) != IDF_NONE;
+
+    switch (rSrcCell.meType)
     {
-        rSrcCell.assign(*mpClipDoc, rSrcPos);
-
-        // Check the paste flag to see whether we want to paste this cell.  If the
-        // flag says we don't want to paste this cell, we'll return with true.
-        InsertDeleteFlags nFlags = getInsertFlag();
-        bool bNumeric  = (nFlags & IDF_VALUE) != IDF_NONE;
-        bool bDateTime = (nFlags & IDF_DATETIME) != IDF_NONE;
-        bool bString   = (nFlags & IDF_STRING) != IDF_NONE;
-        bool bBoolean  = (nFlags & IDF_SPECIAL_BOOLEAN) != IDF_NONE;
-        bool bFormula  = (nFlags & IDF_FORMULA) != IDF_NONE;
-
-        switch (rSrcCell.meType)
+        case CELLTYPE_VALUE:
+        {
+            bool bPaste = isDateCell(rSrcCol, rSrcPos.Row()) ? bDateTime : bNumeric;
+            if (!bPaste)
+                // Don't paste this.
+                rSrcCell.clear();
+        }
+        break;
+        case CELLTYPE_STRING:
+        case CELLTYPE_EDIT:
+        {
+            if (!bString)
+                // Skip pasting.
+                rSrcCell.clear();
+        }
+        break;
+        case CELLTYPE_FORMULA:
         {
-            case CELLTYPE_VALUE:
+            if (bBoolean)
             {
-                bool bPaste = isDateCell(rSrcCol, rSrcPos.Row()) ? bDateTime : bNumeric;
-                if (!bPaste)
-                    // Don't paste this.
-                    rSrcCell.clear();
+                // Check if this formula cell is a boolean cell, and if so, go ahead and paste it.
+                ScTokenArray* pCode = rSrcCell.mpFormula->GetCode();
+                if (pCode && pCode->GetLen() == 1)
+                {
+                    const formula::FormulaToken* p = pCode->First();
+                    if (p->GetOpCode() == ocTrue || p->GetOpCode() == ocFalse)
+                        // This is a boolean formula. Good.
+                        break;
+                }
             }
-            break;
-            case CELLTYPE_STRING:
-            case CELLTYPE_EDIT:
+
+            if (bFormula)
+                // Good.
+                break;
+
+            sal_uInt16 nErr = rSrcCell.mpFormula->GetErrCode();
+            if (nErr)
             {
-                if (!bString)
-                    // Skip pasting.
+                // error codes are cloned with values
+                if (!bNumeric)
+                    // Error code is treated as numeric value. Don't paste it.
                     rSrcCell.clear();
             }
-            break;
-            case CELLTYPE_FORMULA:
+            else if (rSrcCell.mpFormula->IsValue())
             {
-                if (bBoolean)
+                bool bPaste = isDateCell(rSrcCol, rSrcPos.Row()) ? bDateTime : bNumeric;
+                if (!bPaste)
                 {
-                    // Check if this formula cell is a boolean cell, and if so, go ahead and paste it.
-                    ScTokenArray* pCode = rSrcCell.mpFormula->GetCode();
-                    if (pCode && pCode->GetLen() == 1)
-                    {
-                        const formula::FormulaToken* p = pCode->First();
-                        if (p->GetOpCode() == ocTrue || p->GetOpCode() == ocFalse)
-                            // This is a boolean formula. Good.
-                            break;
-                    }
-                }
-
-                if (bFormula)
-                    // Good.
+                    // Don't paste this.
+                    rSrcCell.clear();
                     break;
+                }
 
-                sal_uInt16 nErr = rSrcCell.mpFormula->GetErrCode();
-                if (nErr)
+                // Turn this into a numeric cell.
+                rSrcCell.set(rSrcCell.mpFormula->GetValue());
+            }
+            else if (bString)
+            {
+                svl::SharedString aStr = rSrcCell.mpFormula->GetString();
+                if (aStr.isEmpty())
                 {
-                    // error codes are cloned with values
-                    if (!bNumeric)
-                        // Error code is treated as numeric value. Don't paste it.
-                        rSrcCell.clear();
+                    // do not clone empty string
+                    rSrcCell.clear();
+                    break;
                 }
-                else if (rSrcCell.mpFormula->IsValue())
-                {
-                    bool bPaste = isDateCell(rSrcCol, rSrcPos.Row()) ? bDateTime : bNumeric;
-                    if (!bPaste)
-                    {
-                        // Don't paste this.
-                        rSrcCell.clear();
-                        break;
-                    }
 
-                    // Turn this into a numeric cell.
-                    rSrcCell.set(rSrcCell.mpFormula->GetValue());
-                }
-                else if (bString)
+                // Turn this into a string or edit cell.
+                if (rSrcCell.mpFormula->IsMultilineResult())
                 {
-                    svl::SharedString aStr = rSrcCell.mpFormula->GetString();
-                    if (aStr.isEmpty())
-                    {
-                        // do not clone empty string
-                        rSrcCell.clear();
-                        break;
-                    }
-
-                    // Turn this into a string or edit cell.
-                    if (rSrcCell.mpFormula->IsMultilineResult())
-                    {
-                        // TODO : Add shared string support to the edit engine to
-                        // make this process simpler.
-                        ScFieldEditEngine& rEngine = mrDestDoc.GetEditEngine();
-                        rEngine.SetText(rSrcCell.mpFormula->GetString().getString());
-                        boost::scoped_ptr<EditTextObject> pObj(rEngine.CreateTextObject());
-                        pObj->NormalizeString(mrDestDoc.GetSharedStringPool());
-                        rSrcCell.set(*pObj);
-                    }
-                    else
-                        rSrcCell.set(rSrcCell.mpFormula->GetString());
+                    // TODO : Add shared string support to the edit engine to
+                    // make this process simpler.
+                    ScFieldEditEngine& rEngine = mrDestDoc.GetEditEngine();
+                    rEngine.SetText(rSrcCell.mpFormula->GetString().getString());
+                    boost::scoped_ptr<EditTextObject> pObj(rEngine.CreateTextObject());
+                    pObj->NormalizeString(mrDestDoc.GetSharedStringPool());
+                    rSrcCell.set(*pObj);
                 }
                 else
-                    // We don't want to paste this.
-                    rSrcCell.clear();
+                    rSrcCell.set(rSrcCell.mpFormula->GetString());
             }
-            break;
-            case CELLTYPE_NONE:
-            default:
-                // There is nothing to paste.
+            else
+                // We don't want to paste this.
                 rSrcCell.clear();
         }
+        break;
+        case CELLTYPE_NONE:
+        default:
+            // There is nothing to paste.
+            rSrcCell.clear();
     }
 }
 
commit 39dbab27cc0395c4d48e130025daa4cc2299604a
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Nov 10 21:22:34 2014 -0500

    Move this code to the context class.
    
    Change-Id: I387dba24993d418a2b3923eac992ad2506229704

diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index ccaca67..3891274 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -50,6 +50,7 @@ class CopyFromClipContext : public ClipContextBase
     SCROW mnDestRow2;
     SCTAB mnTabStart;
     SCTAB mnTabEnd;
+    ScDocument& mrDestDoc;
     ScDocument* mpRefUndoDoc;
     ScDocument* mpClipDoc;
     InsertDeleteFlags mnInsertFlag;
@@ -106,6 +107,7 @@ public:
     void setSingleCellColumnSize( size_t nSize );
 
     ScCellValue& getSingleCell( size_t nColOffset );
+    void setSingleCell( const ScAddress& rSrcPos, const ScColumn& rSrcCol );
 
     const ScPatternAttr* getSingleCellPattern( size_t nColOffset ) const;
     void setSingleCellPattern( size_t nColOffset, const ScPatternAttr* pAttr );
diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx
index a414cfd4..85c079c 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -12,6 +12,9 @@
 #include "mtvelements.hxx"
 #include <column.hxx>
 #include <scitems.hxx>
+#include <tokenarray.hxx>
+#include <editutil.hxx>
+#include <clipparam.hxx>
 
 #include <svl/intitem.hxx>
 
@@ -34,6 +37,7 @@ CopyFromClipContext::CopyFromClipContext(ScDocument& rDoc,
     mnDestCol1(-1), mnDestCol2(-1),
     mnDestRow1(-1), mnDestRow2(-1),
     mnTabStart(-1), mnTabEnd(-1),
+    mrDestDoc(rDoc),
     mpRefUndoDoc(pRefUndoDoc), mpClipDoc(pClipDoc),
     mnInsertFlag(nInsertFlag), mnDeleteFlag(IDF_NONE),
     mpCondFormatList(NULL),
@@ -119,6 +123,129 @@ ScCellValue& CopyFromClipContext::getSingleCell( size_t nColOffset )
     return maSingleCells[nColOffset];
 }
 
+void CopyFromClipContext::setSingleCell( const ScAddress& rSrcPos, const ScColumn& rSrcCol )
+{
+    SCCOL nColOffset = rSrcPos.Col() - mpClipDoc->GetClipParam().getWholeRange().aStart.Col();
+
+    ScCellValue& rSrcCell = getSingleCell(nColOffset);
+    if (isAsLink())
+    {
+        ScSingleRefData aRef;
+        aRef.InitAddress(rSrcPos);
+        aRef.SetFlag3D(true);
+
+        ScTokenArray aArr;
+        aArr.AddSingleReference(aRef);
+        rSrcCell.set(new ScFormulaCell(mpClipDoc, rSrcPos, aArr));
+    }
+    else
+    {
+        rSrcCell.assign(*mpClipDoc, rSrcPos);
+
+        // Check the paste flag to see whether we want to paste this cell.  If the
+        // flag says we don't want to paste this cell, we'll return with true.
+        InsertDeleteFlags nFlags = getInsertFlag();
+        bool bNumeric  = (nFlags & IDF_VALUE) != IDF_NONE;
+        bool bDateTime = (nFlags & IDF_DATETIME) != IDF_NONE;
+        bool bString   = (nFlags & IDF_STRING) != IDF_NONE;
+        bool bBoolean  = (nFlags & IDF_SPECIAL_BOOLEAN) != IDF_NONE;
+        bool bFormula  = (nFlags & IDF_FORMULA) != IDF_NONE;
+
+        switch (rSrcCell.meType)
+        {
+            case CELLTYPE_VALUE:
+            {
+                bool bPaste = isDateCell(rSrcCol, rSrcPos.Row()) ? bDateTime : bNumeric;
+                if (!bPaste)
+                    // Don't paste this.
+                    rSrcCell.clear();
+            }
+            break;
+            case CELLTYPE_STRING:
+            case CELLTYPE_EDIT:
+            {
+                if (!bString)
+                    // Skip pasting.
+                    rSrcCell.clear();
+            }
+            break;
+            case CELLTYPE_FORMULA:
+            {
+                if (bBoolean)
+                {
+                    // Check if this formula cell is a boolean cell, and if so, go ahead and paste it.
+                    ScTokenArray* pCode = rSrcCell.mpFormula->GetCode();
+                    if (pCode && pCode->GetLen() == 1)
+                    {
+                        const formula::FormulaToken* p = pCode->First();
+                        if (p->GetOpCode() == ocTrue || p->GetOpCode() == ocFalse)
+                            // This is a boolean formula. Good.
+                            break;
+                    }
+                }
+
+                if (bFormula)
+                    // Good.
+                    break;
+
+                sal_uInt16 nErr = rSrcCell.mpFormula->GetErrCode();
+                if (nErr)
+                {
+                    // error codes are cloned with values
+                    if (!bNumeric)
+                        // Error code is treated as numeric value. Don't paste it.
+                        rSrcCell.clear();
+                }
+                else if (rSrcCell.mpFormula->IsValue())
+                {
+                    bool bPaste = isDateCell(rSrcCol, rSrcPos.Row()) ? bDateTime : bNumeric;
+                    if (!bPaste)
+                    {
+                        // Don't paste this.
+                        rSrcCell.clear();
+                        break;
+                    }
+
+                    // Turn this into a numeric cell.
+                    rSrcCell.set(rSrcCell.mpFormula->GetValue());
+                }
+                else if (bString)
+                {
+                    svl::SharedString aStr = rSrcCell.mpFormula->GetString();
+                    if (aStr.isEmpty())
+                    {
+                        // do not clone empty string
+                        rSrcCell.clear();
+                        break;
+                    }
+
+                    // Turn this into a string or edit cell.
+                    if (rSrcCell.mpFormula->IsMultilineResult())
+                    {
+                        // TODO : Add shared string support to the edit engine to
+                        // make this process simpler.
+                        ScFieldEditEngine& rEngine = mrDestDoc.GetEditEngine();
+                        rEngine.SetText(rSrcCell.mpFormula->GetString().getString());
+                        boost::scoped_ptr<EditTextObject> pObj(rEngine.CreateTextObject());
+                        pObj->NormalizeString(mrDestDoc.GetSharedStringPool());
+                        rSrcCell.set(*pObj);
+                    }
+                    else
+                        rSrcCell.set(rSrcCell.mpFormula->GetString());
+                }
+                else
+                    // We don't want to paste this.
+                    rSrcCell.clear();
+            }
+            break;
+            case CELLTYPE_NONE:
+            default:
+                // There is nothing to paste.
+                rSrcCell.clear();
+        }
+    }
+}
+
 const ScPatternAttr* CopyFromClipContext::getSingleCellPattern( size_t nColOffset ) const
 {
     assert(nColOffset < maSinglePatterns.size());
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index 714bc23..49c0a9f 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -104,123 +104,7 @@ bool ScDocument::CopyOneCellFromClip(
         if ((rCxt.getInsertFlag() & (IDF_NOTE | IDF_ADDNOTES)) != IDF_NONE)
             rCxt.setSingleCellNote(nColOffset, pClipDoc->GetNote(aSrcPos));
 
-        ScCellValue& rSrcCell = rCxt.getSingleCell(nColOffset);
-        if (rCxt.isAsLink())
-        {
-            ScSingleRefData aRef;
-            aRef.InitAddress(aSrcPos);
-            aRef.SetFlag3D(true);
-
-            ScTokenArray aArr;
-            aArr.AddSingleReference(aRef);
-            rSrcCell.set(new ScFormulaCell(pClipDoc, aSrcPos, aArr));
-        }
-        else
-        {
-            rSrcCell.assign(*pClipDoc, aSrcPos);
-
-            // Check the paste flag to see whether we want to paste this cell.  If the
-            // flag says we don't want to paste this cell, we'll return with true.
-            InsertDeleteFlags nFlags = rCxt.getInsertFlag();
-            bool bNumeric  = (nFlags & IDF_VALUE) != IDF_NONE;
-            bool bDateTime = (nFlags & IDF_DATETIME) != IDF_NONE;
-            bool bString   = (nFlags & IDF_STRING) != IDF_NONE;
-            bool bBoolean  = (nFlags & IDF_SPECIAL_BOOLEAN) != IDF_NONE;
-            bool bFormula  = (nFlags & IDF_FORMULA) != IDF_NONE;
-
-            switch (rSrcCell.meType)
-            {
-                case CELLTYPE_VALUE:
-                {
-                    bool bPaste = rCxt.isDateCell(pSrcTab->aCol[aSrcPos.Col()], aSrcPos.Row()) ? bDateTime : bNumeric;
-                    if (!bPaste)
-                        // Don't paste this.
-                        rSrcCell.clear();
-                }
-                break;
-                case CELLTYPE_STRING:
-                case CELLTYPE_EDIT:
-                {
-                    if (!bString)
-                        // Skip pasting.
-                        rSrcCell.clear();
-                }
-                break;
-                case CELLTYPE_FORMULA:
-                {
-                    if (bBoolean)
-                    {
-                        // Check if this formula cell is a boolean cell, and if so, go ahead and paste it.
-                        ScTokenArray* pCode = rSrcCell.mpFormula->GetCode();
-                        if (pCode && pCode->GetLen() == 1)
-                        {
-                            const formula::FormulaToken* p = pCode->First();
-                            if (p->GetOpCode() == ocTrue || p->GetOpCode() == ocFalse)
-                                // This is a boolean formula. Good.
-                                break;
-                        }
-                    }
-
-                    if (bFormula)
-                        // Good.
-                        break;
-
-                    sal_uInt16 nErr = rSrcCell.mpFormula->GetErrCode();
-                    if (nErr)
-                    {
-                        // error codes are cloned with values
-                        if (!bNumeric)
-                            // Error code is treated as numeric value. Don't paste it.
-                            rSrcCell.clear();
-                    }
-                    else if (rSrcCell.mpFormula->IsValue())
-                    {
-                        bool bPaste = rCxt.isDateCell(pSrcTab->aCol[aSrcPos.Col()], aSrcPos.Row()) ? bDateTime : bNumeric;
-                        if (!bPaste)
-                        {
-                            // Don't paste this.
-                            rSrcCell.clear();
-                            break;
-                        }
-
-                        // Turn this into a numeric cell.
-                        rSrcCell.set(rSrcCell.mpFormula->GetValue());
-                    }
-                    else if (bString)
-                    {
-                        svl::SharedString aStr = rSrcCell.mpFormula->GetString();
-                        if (aStr.isEmpty())
-                        {
-                            // do not clone empty string
-                            rSrcCell.clear();
-                            break;
-                        }
-
-                        // Turn this into a string or edit cell.
-                        if (rSrcCell.mpFormula->IsMultilineResult())
-                        {
-                            // TODO : Add shared string support to the edit engine to
-                            // make this process simpler.
-                            ScFieldEditEngine& rEngine = GetEditEngine();
-                            rEngine.SetText(rSrcCell.mpFormula->GetString().getString());
-                            boost::scoped_ptr<EditTextObject> pObj(rEngine.CreateTextObject());
-                            pObj->NormalizeString(GetSharedStringPool());
-                            rSrcCell.set(*pObj);
-                        }
-                        else
-                            rSrcCell.set(rSrcCell.mpFormula->GetString());
-                    }
-                    else
-                        // We don't want to paste this.
-                        rSrcCell.clear();
-                }
-                break;
-                case CELLTYPE_NONE:
-                default:
-                    // There is nothing to paste.
-                    rSrcCell.clear();
-            }
-        }
+        rCxt.setSingleCell(aSrcPos, pSrcTab->aCol[aSrcPos.Col()]);
     }
 
     // All good. Proceed with the pasting.


More information about the Libreoffice-commits mailing list