[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 2 commits - sc/inc sc/Library_sc.mk sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Thu Mar 21 17:11:47 PDT 2013
sc/Library_sc.mk | 1
sc/inc/cellvalue.hxx | 56 ++++++++++++++++++
sc/inc/chgtrack.hxx | 7 --
sc/source/core/data/cellvalue.cxx | 116 ++++++++++++++++++++++++++++++++++++++
sc/source/core/tool/chgtrack.cxx | 23 +++----
sc/source/ui/docshell/docfunc.cxx | 3
sc/source/ui/inc/undocell.hxx | 45 +-------------
sc/source/ui/undo/undocell.cxx | 106 ----------------------------------
8 files changed, 194 insertions(+), 163 deletions(-)
New commits:
commit a0fc9284aeaa52f8e3bde8c2e53cf79b7181169e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Thu Mar 21 20:11:23 2013 -0400
What the heck is this !? Kill it.
Change-Id: Iceecf6129977241847711488d116ebddaf639e24
diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index c4c22a9..2b283ed 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -32,11 +32,7 @@
#include "global.hxx"
#include "bigrange.hxx"
#include "scdllapi.h"
-
-#ifdef SC_CHGTRACK_CXX
-// core/inc
#include "refupdat.hxx"
-#endif
class ScBaseCell;
class ScDocument;
@@ -949,7 +945,6 @@ class ScChangeTrack : public utl::ConfigurationListener
ScChangeTrack( const ScChangeTrack& );
ScChangeTrack& operator=( const ScChangeTrack& );
-#ifdef SC_CHGTRACK_CXX
static SCROW InitContentRowsPerSlot();
// true if one is MM_FORMULA and the other is
@@ -1022,8 +1017,6 @@ class ScChangeTrack : public utl::ConfigurationListener
// bRecursion == called from reject with table
bool Reject( ScChangeAction*, ScChangeActionMap*, bool bRecursion );
-#endif // SC_CHGTRACK_CXX
-
void ClearMsgQueue();
virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index d35fd7d..29b0017 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -17,16 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <tools/shl.hxx> // SHL_CALC
-#include <tools/rtti.hxx>
-#include <svl/zforlist.hxx>
-#include <svl/itemset.hxx>
-#include <svl/isethint.hxx>
-#include <svl/itempool.hxx>
-#include <sfx2/app.hxx>
-#include <unotools/useroptions.hxx>
-#include <sfx2/sfxsids.hrc>
-
+#include "chgtrack.hxx"
#include "cell.hxx"
#include "document.hxx"
#include "dociter.hxx"
@@ -38,11 +29,17 @@
#include "patattr.hxx"
#include "hints.hxx"
#include "markdata.hxx"
-
#include "globstr.hrc"
-#define SC_CHGTRACK_CXX
-#include "chgtrack.hxx"
+#include <tools/shl.hxx> // SHL_CALC
+#include <tools/rtti.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/itemset.hxx>
+#include <svl/isethint.hxx>
+#include <svl/itempool.hxx>
+#include <sfx2/app.hxx>
+#include <unotools/useroptions.hxx>
+#include <sfx2/sfxsids.hrc>
IMPL_FIXEDMEMPOOL_NEWDEL( ScChangeActionCellListEntry )
commit e0009abd292e072ca9388ad75c9c507c8d334780
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Thu Mar 21 19:50:03 2013 -0400
Move ScCellValue into its own header/source files.
This can be used outside the undo code, like change tracking code.
Change-Id: Iad936acef0dacbd19d8c179da4713b1cdc7f9c84
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 48ebfd2..1935b7a 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -101,6 +101,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/data/bigrange \
sc/source/core/data/cell \
sc/source/core/data/cell2 \
+ sc/source/core/data/cellvalue \
sc/source/core/data/clipparam \
sc/source/core/data/column \
sc/source/core/data/column2 \
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
new file mode 100644
index 0000000..409e178
--- /dev/null
+++ b/sc/inc/cellvalue.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef __SC_CELLVALUE_HXX__
+#define __SC_CELLVALUE_HXX__
+
+#include "global.hxx"
+
+class ScDocument;
+class ScFormulaCell;
+class EditTextObject;
+
+/**
+ * Store arbitrary cell value of any kind. It only stores cell value and
+ * nothing else.
+ */
+struct ScCellValue
+{
+ CellType meType;
+ union {
+ double mfValue;
+ OUString* mpString;
+ EditTextObject* mpEditText;
+ ScFormulaCell* mpFormula;
+ };
+
+ ScCellValue();
+ ScCellValue( double fValue );
+ ScCellValue( const OUString& rString );
+ ScCellValue( const EditTextObject& rEditText );
+ ScCellValue( const ScFormulaCell& rFormula );
+ ScCellValue( const ScCellValue& r );
+ ~ScCellValue();
+
+ void clear();
+
+ /**
+ * Take cell value from specified position in specified document.
+ */
+ void assign( const ScDocument& rDoc, const ScAddress& rPos );
+
+ /**
+ * Set cell value at specified position in specified document.
+ */
+ void commit( ScDocument& rDoc, const ScAddress& rPos );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
new file mode 100644
index 0000000..fe038ce
--- /dev/null
+++ b/sc/source/core/data/cellvalue.cxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "cellvalue.hxx"
+#include "document.hxx"
+#include "cell.hxx"
+#include "editeng/editobj.hxx"
+#include "stringutil.hxx"
+
+ScCellValue::ScCellValue() : meType(CELLTYPE_NONE), mfValue(0.0) {}
+ScCellValue::ScCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue(fValue) {}
+ScCellValue::ScCellValue( const OUString& rString ) : meType(CELLTYPE_STRING), mpString(new OUString(rString)) {}
+ScCellValue::ScCellValue( const EditTextObject& rEditText ) : meType(CELLTYPE_EDIT), mpEditText(rEditText.Clone()) {}
+ScCellValue::ScCellValue( const ScFormulaCell& rFormula ) : meType(CELLTYPE_FORMULA), mpFormula(rFormula.Clone()) {}
+
+ScCellValue::ScCellValue( const ScCellValue& r ) : meType(r.meType), mfValue(r.mfValue)
+{
+ switch (r.meType)
+ {
+ case CELLTYPE_STRING:
+ mpString = new OUString(*r.mpString);
+ break;
+ case CELLTYPE_EDIT:
+ mpEditText = r.mpEditText->Clone();
+ break;
+ case CELLTYPE_FORMULA:
+ mpFormula = r.mpFormula->Clone();
+ break;
+ default:
+ ;
+ }
+}
+
+ScCellValue::~ScCellValue()
+{
+ clear();
+}
+
+void ScCellValue::clear()
+{
+ switch (meType)
+ {
+ case CELLTYPE_STRING:
+ delete mpString;
+ break;
+ case CELLTYPE_EDIT:
+ delete mpEditText;
+ break;
+ case CELLTYPE_FORMULA:
+ mpFormula->Delete();
+ break;
+ default:
+ ;
+ }
+
+ // Reset to empty value.
+ meType = CELLTYPE_NONE;
+ mfValue = 0.0;
+}
+
+void ScCellValue::assign( const ScDocument& rDoc, const ScAddress& rPos )
+{
+ clear();
+
+ meType = rDoc.GetCellType(rPos);
+ switch (meType)
+ {
+ case CELLTYPE_STRING:
+ mpString = new OUString(rDoc.GetString(rPos));
+ break;
+ case CELLTYPE_EDIT:
+ mpEditText = rDoc.GetEditText(rPos)->Clone();
+ break;
+ case CELLTYPE_VALUE:
+ mfValue = rDoc.GetValue(rPos);
+ break;
+ case CELLTYPE_FORMULA:
+ mpFormula = rDoc.GetFormulaCell(rPos)->Clone();
+ break;
+ default:
+ meType = CELLTYPE_NONE; // reset to empty.
+ }
+}
+
+void ScCellValue::commit( ScDocument& rDoc, const ScAddress& rPos )
+{
+ switch (meType)
+ {
+ case CELLTYPE_STRING:
+ {
+ ScSetStringParam aParam;
+ aParam.setTextInput();
+ rDoc.SetString(rPos, *mpString, &aParam);
+ }
+ break;
+ case CELLTYPE_EDIT:
+ rDoc.SetEditText(rPos, mpEditText->Clone());
+ break;
+ case CELLTYPE_VALUE:
+ rDoc.SetValue(rPos, mfValue);
+ break;
+ case CELLTYPE_FORMULA:
+ rDoc.SetFormulaCell(rPos, mpFormula->Clone());
+ break;
+ default:
+ rDoc.SetEmptyCell(rPos);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index d3061e1..70ca4c3 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -81,6 +81,7 @@
#include "progress.hxx"
#include "dpobject.hxx"
#include "stringutil.hxx"
+#include "cellvalue.hxx"
#include <memory>
#include <basic/basmgr.hxx>
@@ -809,7 +810,7 @@ sal_Bool ScDocFunc::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos,
namespace {
-void pushUndoSetCell( ScDocShell& rDocShell, ScDocument* pDoc, const ScAddress& rPos, const ScUndoCellValue& rNewVal )
+void pushUndoSetCell( ScDocShell& rDocShell, ScDocument* pDoc, const ScAddress& rPos, const ScCellValue& rNewVal )
{
svl::IUndoManager* pUndoMgr = rDocShell.GetUndoManager();
switch (pDoc->GetCellType(rPos))
diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx
index a9ff3f1..e550cc0 100644
--- a/sc/source/ui/inc/undocell.hxx
+++ b/sc/source/ui/inc/undocell.hxx
@@ -22,6 +22,7 @@
#include "undobase.hxx"
#include "postit.hxx"
+#include "cellvalue.hxx"
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
@@ -36,40 +37,6 @@ class ScDetOpData;
class ScRangeName;
class ScDocument;
-/**
- * Store arbitrary cell value of any kind for undo objects.
- */
-struct ScUndoCellValue
-{
- CellType meType;
- union {
- double mfValue;
- OUString* mpString;
- EditTextObject* mpEditText;
- ScFormulaCell* mpFormula;
- };
-
- ScUndoCellValue();
- ScUndoCellValue( double fValue );
- ScUndoCellValue( const OUString& rString );
- ScUndoCellValue( const EditTextObject& rEditText );
- ScUndoCellValue( const ScFormulaCell& rFormula );
- ScUndoCellValue( const ScUndoCellValue& r );
- ~ScUndoCellValue();
-
- void clear();
-
- /**
- * Take cell value from specified position in specified document.
- */
- void assign( const ScDocument& rDoc, const ScAddress& rPos );
-
- /**
- * Set cell value at specified position in specified document.
- */
- void commit( ScDocument& rDoc, const ScAddress& rPos );
-};
-
class ScUndoCursorAttr: public ScSimpleUndo
{
public:
@@ -179,8 +146,8 @@ class ScUndoSetCell : public ScSimpleUndo
{
public:
TYPEINFO();
- ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScUndoCellValue& rNewVal );
- ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScUndoCellValue& rOldVal, const ScUndoCellValue& rNewVal );
+ ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScCellValue& rNewVal );
+ ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScCellValue& rOldVal, const ScCellValue& rNewVal );
virtual ~ScUndoSetCell();
@@ -191,12 +158,12 @@ public:
virtual OUString GetComment() const;
private:
- void SetValue( const ScUndoCellValue& rVal );
+ void SetValue( const ScCellValue& rVal );
private:
ScAddress maPos;
- ScUndoCellValue maOldValue;
- ScUndoCellValue maNewValue;
+ ScCellValue maOldValue;
+ ScCellValue maNewValue;
};
class ScUndoPageBreak: public ScSimpleUndo
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 171a758..574ddba 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -45,106 +45,6 @@
using ::boost::shared_ptr;
-ScUndoCellValue::ScUndoCellValue() : meType(CELLTYPE_NONE), mfValue(0.0) {}
-ScUndoCellValue::ScUndoCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue(fValue) {}
-ScUndoCellValue::ScUndoCellValue( const OUString& rString ) : meType(CELLTYPE_STRING), mpString(new OUString(rString)) {}
-ScUndoCellValue::ScUndoCellValue( const EditTextObject& rEditText ) : meType(CELLTYPE_EDIT), mpEditText(rEditText.Clone()) {}
-ScUndoCellValue::ScUndoCellValue( const ScFormulaCell& rFormula ) : meType(CELLTYPE_FORMULA), mpFormula(rFormula.Clone()) {}
-
-ScUndoCellValue::ScUndoCellValue( const ScUndoCellValue& r ) : meType(r.meType), mfValue(r.mfValue)
-{
- switch (r.meType)
- {
- case CELLTYPE_STRING:
- mpString = new OUString(*r.mpString);
- break;
- case CELLTYPE_EDIT:
- mpEditText = r.mpEditText->Clone();
- break;
- case CELLTYPE_FORMULA:
- mpFormula = r.mpFormula->Clone();
- break;
- default:
- ;
- }
-}
-
-ScUndoCellValue::~ScUndoCellValue()
-{
- clear();
-}
-
-void ScUndoCellValue::clear()
-{
- switch (meType)
- {
- case CELLTYPE_STRING:
- delete mpString;
- break;
- case CELLTYPE_EDIT:
- delete mpEditText;
- break;
- case CELLTYPE_FORMULA:
- mpFormula->Delete();
- break;
- default:
- ;
- }
-
- // Reset to empty value.
- meType = CELLTYPE_NONE;
- mfValue = 0.0;
-}
-
-void ScUndoCellValue::assign( const ScDocument& rDoc, const ScAddress& rPos )
-{
- clear();
-
- meType = rDoc.GetCellType(rPos);
- switch (meType)
- {
- case CELLTYPE_STRING:
- mpString = new OUString(rDoc.GetString(rPos));
- break;
- case CELLTYPE_EDIT:
- mpEditText = rDoc.GetEditText(rPos)->Clone();
- break;
- case CELLTYPE_VALUE:
- mfValue = rDoc.GetValue(rPos);
- break;
- case CELLTYPE_FORMULA:
- mpFormula = rDoc.GetFormulaCell(rPos)->Clone();
- break;
- default:
- meType = CELLTYPE_NONE; // reset to empty.
- }
-}
-
-void ScUndoCellValue::commit( ScDocument& rDoc, const ScAddress& rPos )
-{
- switch (meType)
- {
- case CELLTYPE_STRING:
- {
- ScSetStringParam aParam;
- aParam.setTextInput();
- rDoc.SetString(rPos, *mpString, &aParam);
- }
- break;
- case CELLTYPE_EDIT:
- rDoc.SetEditText(rPos, mpEditText->Clone());
- break;
- case CELLTYPE_VALUE:
- rDoc.SetValue(rPos, mfValue);
- break;
- case CELLTYPE_FORMULA:
- rDoc.SetFormulaCell(rPos, mpFormula->Clone());
- break;
- default:
- rDoc.SetEmptyCell(rPos);
- }
-}
-
TYPEINIT1(ScUndoCursorAttr, ScSimpleUndo);
TYPEINIT1(ScUndoEnterData, ScSimpleUndo);
TYPEINIT1(ScUndoEnterValue, ScSimpleUndo);
@@ -515,10 +415,10 @@ sal_Bool ScUndoEnterValue::CanRepeat(SfxRepeatTarget& /* rTarget */) const
return false;
}
-ScUndoSetCell::ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScUndoCellValue& rNewVal ) :
+ScUndoSetCell::ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScCellValue& rNewVal ) :
ScSimpleUndo(pDocSh), maPos(rPos), maNewValue(rNewVal) {}
-ScUndoSetCell::ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScUndoCellValue& rOldVal, const ScUndoCellValue& rNewVal ) :
+ScUndoSetCell::ScUndoSetCell( ScDocShell* pDocSh, const ScAddress& rPos, const ScCellValue& rOldVal, const ScCellValue& rNewVal ) :
ScSimpleUndo(pDocSh), maPos(rPos), maOldValue(rOldVal), maNewValue(rNewVal) {}
ScUndoSetCell::~ScUndoSetCell() {}
@@ -554,7 +454,7 @@ OUString ScUndoSetCell::GetComment() const
return ScGlobal::GetRscString(STR_UNDO_ENTERDATA); // "Input"
}
-void ScUndoSetCell::SetValue( const ScUndoCellValue& rVal )
+void ScUndoSetCell::SetValue( const ScCellValue& rVal )
{
ScDocument* pDoc = pDocShell->GetDocument();
More information about the Libreoffice-commits
mailing list