[Libreoffice-commits] core.git: sc/inc sc/source

Caolán McNamara caolanm at redhat.com
Wed Dec 6 09:00:38 UTC 2017


 sc/inc/cellvalue.hxx              |    2 +
 sc/source/core/data/cellvalue.cxx |   48 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

New commits:
commit 097d12bd738467765ae9aa0f4129cf3153510241
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Dec 5 15:09:12 2017 +0000

    coverity#1421089 seems to be really reporting missing move ctors/assignments
    
    Change-Id: I434eebac395bbb53a0c586a43568f64ec3fb8448

diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 430212245870..153411c2b63e 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -44,6 +44,7 @@ struct SC_DLLPUBLIC ScCellValue
     ScCellValue( double fValue );
     ScCellValue( const svl::SharedString& rString );
     ScCellValue( const ScCellValue& r );
+    ScCellValue( ScCellValue&& r );
     ~ScCellValue();
 
     void clear();
@@ -84,6 +85,7 @@ struct SC_DLLPUBLIC ScCellValue
     bool equalsWithoutFormat( const ScCellValue& r ) const;
 
     ScCellValue& operator= ( const ScCellValue& r );
+    ScCellValue& operator= ( ScCellValue&& r );
     ScCellValue& operator= ( const ScRefCellValue& r );
 
     void swap( ScCellValue& r );
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
index 81c2cdc267b7..abaaad5e8cb6 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -244,6 +244,27 @@ ScCellValue::ScCellValue( const ScCellValue& r ) : meType(r.meType), mfValue(r.m
     }
 }
 
+ScCellValue::ScCellValue(ScCellValue&& r)
+    : meType(r.meType)
+    , mfValue(r.mfValue)
+{
+    switch (r.meType)
+    {
+        case CELLTYPE_STRING:
+            mpString = r.mpString;
+        break;
+        case CELLTYPE_EDIT:
+            mpEditText = r.mpEditText;
+        break;
+        case CELLTYPE_FORMULA:
+            mpFormula = r.mpFormula;
+        break;
+        default:
+            ;
+    }
+    r.meType = CELLTYPE_NONE;
+}
+
 ScCellValue::~ScCellValue()
 {
     clear();
@@ -492,6 +513,33 @@ ScCellValue& ScCellValue::operator= ( const ScCellValue& r )
     return *this;
 }
 
+ScCellValue& ScCellValue::operator=(ScCellValue&& rCell)
+{
+    clear();
+
+    meType = rCell.meType;
+    mfValue = rCell.mfValue;
+    switch (rCell.meType)
+    {
+        case CELLTYPE_STRING:
+            mpString = rCell.mpString;
+        break;
+        case CELLTYPE_EDIT:
+            mpEditText = rCell.mpEditText;
+        break;
+        case CELLTYPE_FORMULA:
+            mpFormula = rCell.mpFormula;
+        break;
+        default:
+            ;
+    }
+    //we don't need to reset mpString/mpEditText/mpFormula if we
+    //set meType to NONE as the ScCellValue dtor keys off the meType
+    rCell.meType = CELLTYPE_NONE;
+
+    return *this;
+}
+
 ScCellValue& ScCellValue::operator= ( const ScRefCellValue& r )
 {
     ScCellValue aTmp(r);


More information about the Libreoffice-commits mailing list