[Libreoffice-commits] core.git: Branch 'private/kohei/find-replace-all-perf' - sc/inc sc/Library_sc.mk sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Fri May 23 19:17:54 PDT 2014
sc/Library_sc.mk | 1
sc/inc/clipcontext.hxx | 25 +++------------
sc/inc/columnblockcontext.hxx | 46 +++++++++++++++++++++++++++++
sc/inc/listenercontext.hxx | 15 +--------
sc/source/core/data/clipcontext.cxx | 18 ++---------
sc/source/core/data/columnblockcontext.cxx | 36 ++++++++++++++++++++++
sc/source/core/data/listenercontext.cxx | 34 ++++-----------------
7 files changed, 102 insertions(+), 73 deletions(-)
New commits:
commit f2873593d7aff304dfc6ed68f517a5b8f3fe3332
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri May 23 21:55:30 2014 -0400
Simple context that only contains column block position set.
And use it as the base class for various context classes containing
column block position set.
Change-Id: I4e9fec9d9db51fc06b2ede807100a82dc4a73dd3
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 9b55aa4..4129e47 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -107,6 +107,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/data/column2 \
sc/source/core/data/column3 \
sc/source/core/data/column4 \
+ sc/source/core/data/columnblockcontext \
sc/source/core/data/columniterator \
sc/source/core/data/columnset \
sc/source/core/data/columnspanset \
diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index 7791a93..7b82f13 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -12,6 +12,7 @@
#include "address.hxx"
#include "cellvalue.hxx"
+#include <columnblockcontext.hxx>
#include <vector>
#include <boost/unordered_map.hpp>
@@ -26,23 +27,7 @@ class ScConditionalFormatList;
namespace sc {
-struct ColumnBlockPosition;
-class ColumnBlockPositionSet;
-
-class ClipContextBase : boost::noncopyable
-{
- boost::scoped_ptr<ColumnBlockPositionSet> mpSet;
-
- ClipContextBase(); // disabled
-
-public:
- ClipContextBase(ScDocument& rDoc);
- virtual ~ClipContextBase();
-
- ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
-};
-
-class CopyFromClipContext : public ClipContextBase
+class CopyFromClipContext : public ColumnBlockContext
{
SCCOL mnDestCol1;
SCCOL mnDestCol2;
@@ -116,7 +101,7 @@ public:
bool isDateCell( const ScColumn& rCol, SCROW nRow ) const;
};
-class CopyToClipContext : public ClipContextBase
+class CopyToClipContext : public ColumnBlockContext
{
bool mbKeepScenarioFlags:1;
bool mbCloneNotes:1;
@@ -131,14 +116,14 @@ public:
bool isCloneNotes() const;
};
-class CopyToDocContext : public ClipContextBase
+class CopyToDocContext : public ColumnBlockContext
{
public:
CopyToDocContext(ScDocument& rDoc);
virtual ~CopyToDocContext();
};
-class MixDocContext : public ClipContextBase
+class MixDocContext : public ColumnBlockContext
{
public:
MixDocContext(ScDocument& rDoc);
diff --git a/sc/inc/columnblockcontext.hxx b/sc/inc/columnblockcontext.hxx
new file mode 100644
index 0000000..1a188b6
--- /dev/null
+++ b/sc/inc/columnblockcontext.hxx
@@ -0,0 +1,46 @@
+/* -*- 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_COLUMNBLOCKCONTEXT_HXX
+#define SC_COLUMNBLOCKCONTEXT_HXX
+
+#include <types.hxx>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/noncopyable.hpp>
+
+class ScDocument;
+
+namespace sc {
+
+struct ColumnBlockPosition;
+class ColumnBlockPositionSet;
+
+class ColumnBlockContext : boost::noncopyable
+{
+ ScDocument& mrDoc;
+ boost::shared_ptr<ColumnBlockPositionSet> mpSet;
+
+ ColumnBlockContext(); // disabled
+
+public:
+ ColumnBlockContext(ScDocument& rDoc);
+ ColumnBlockContext(ScDocument& rDoc, const boost::shared_ptr<ColumnBlockPositionSet>& pSet);
+
+ virtual ~ColumnBlockContext();
+
+ ScDocument& getDoc();
+ ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/listenercontext.hxx b/sc/inc/listenercontext.hxx
index 7d66f924..b553465 100644
--- a/sc/inc/listenercontext.hxx
+++ b/sc/inc/listenercontext.hxx
@@ -12,6 +12,7 @@
#include "address.hxx"
#include "columnspanset.hxx"
+#include <columnblockcontext.hxx>
#include <boost/noncopyable.hpp>
#include <boost/scoped_ptr.hpp>
@@ -25,23 +26,16 @@ namespace sc {
struct ColumnBlockPosition;
class ColumnBlockPositionSet;
-class StartListeningContext : boost::noncopyable
+class StartListeningContext : public ColumnBlockContext
{
- ScDocument& mrDoc;
- boost::shared_ptr<ColumnBlockPositionSet> mpSet;
public:
StartListeningContext(ScDocument& rDoc);
StartListeningContext(ScDocument& rDoc, const boost::shared_ptr<ColumnBlockPositionSet>& pSet);
- ScDocument& getDoc();
-
- ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
};
-class EndListeningContext : boost::noncopyable
+class EndListeningContext : public ColumnBlockContext
{
- ScDocument& mrDoc;
ColumnSpanSet maSet;
- boost::shared_ptr<ColumnBlockPositionSet> mpPosSet;
ScTokenArray* mpOldCode;
ScAddress maPosDelta; // Add this to get the old position prior to the move.
@@ -51,12 +45,9 @@ public:
void setPositionDelta( const ScAddress& rDelta );
- ScDocument& getDoc();
ScTokenArray* getOldCode();
ScAddress getOldPosition( const ScAddress& rPos ) const;
- ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
-
void addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, SCROW nRow);
void purgeEmptyBroadcasters();
};
diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx
index c70d9d4..5168458 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -17,20 +17,10 @@
namespace sc {
-ClipContextBase::ClipContextBase(ScDocument& rDoc) :
- mpSet(new ColumnBlockPositionSet(rDoc)) {}
-
-ClipContextBase::~ClipContextBase() {}
-
-ColumnBlockPosition* ClipContextBase::getBlockPosition(SCTAB nTab, SCCOL nCol)
-{
- return mpSet->getBlockPosition(nTab, nCol);
-}
-
CopyFromClipContext::CopyFromClipContext(ScDocument& rDoc,
ScDocument* pRefUndoDoc, ScDocument* pClipDoc, sal_uInt16 nInsertFlag,
bool bAsLink, bool bSkipAttrForEmptyCells) :
- ClipContextBase(rDoc),
+ ColumnBlockContext(rDoc),
mnDestCol1(-1), mnDestCol2(-1),
mnDestRow1(-1), mnDestRow2(-1),
mnTabStart(-1), mnTabEnd(-1),
@@ -175,7 +165,7 @@ bool CopyFromClipContext::isDateCell( const ScColumn& rCol, SCROW nRow ) const
CopyToClipContext::CopyToClipContext(
ScDocument& rDoc, bool bKeepScenarioFlags, bool bCloneNotes) :
- ClipContextBase(rDoc), mbKeepScenarioFlags(bKeepScenarioFlags), mbCloneNotes(bCloneNotes) {}
+ ColumnBlockContext(rDoc), mbKeepScenarioFlags(bKeepScenarioFlags), mbCloneNotes(bCloneNotes) {}
CopyToClipContext::~CopyToClipContext() {}
@@ -189,10 +179,10 @@ bool CopyToClipContext::isCloneNotes() const
return mbCloneNotes;
}
-CopyToDocContext::CopyToDocContext(ScDocument& rDoc) : ClipContextBase(rDoc) {}
+CopyToDocContext::CopyToDocContext(ScDocument& rDoc) : ColumnBlockContext(rDoc) {}
CopyToDocContext::~CopyToDocContext() {}
-MixDocContext::MixDocContext(ScDocument& rDoc) : ClipContextBase(rDoc) {}
+MixDocContext::MixDocContext(ScDocument& rDoc) : ColumnBlockContext(rDoc) {}
MixDocContext::~MixDocContext() {}
}
diff --git a/sc/source/core/data/columnblockcontext.cxx b/sc/source/core/data/columnblockcontext.cxx
new file mode 100644
index 0000000..8ae8f1d
--- /dev/null
+++ b/sc/source/core/data/columnblockcontext.cxx
@@ -0,0 +1,36 @@
+/* -*- 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 <columnblockcontext.hxx>
+#include <mtvelements.hxx>
+
+namespace sc {
+
+ColumnBlockContext::ColumnBlockContext(ScDocument& rDoc) :
+ mrDoc(rDoc), mpSet(new ColumnBlockPositionSet(rDoc)) {}
+
+ColumnBlockContext::ColumnBlockContext(
+ ScDocument& rDoc, const boost::shared_ptr<ColumnBlockPositionSet>& pSet) :
+ mrDoc(rDoc), mpSet(pSet) {}
+
+ColumnBlockContext::~ColumnBlockContext() {}
+
+ScDocument& ColumnBlockContext::getDoc()
+{
+ return mrDoc;
+}
+
+ColumnBlockPosition* ColumnBlockContext::getBlockPosition(SCTAB nTab, SCCOL nCol)
+{
+ return mpSet->getBlockPosition(nTab, nCol);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/listenercontext.cxx b/sc/source/core/data/listenercontext.cxx
index dcdffac..94078702 100644
--- a/sc/source/core/data/listenercontext.cxx
+++ b/sc/source/core/data/listenercontext.cxx
@@ -14,41 +14,26 @@
namespace sc {
StartListeningContext::StartListeningContext(ScDocument& rDoc) :
- mrDoc(rDoc), mpSet(new ColumnBlockPositionSet(rDoc)) {}
+ ColumnBlockContext(rDoc) {}
StartListeningContext::StartListeningContext(
ScDocument& rDoc, const boost::shared_ptr<ColumnBlockPositionSet>& pSet) :
- mrDoc(rDoc), mpSet(pSet) {}
-
-ScDocument& StartListeningContext::getDoc()
-{
- return mrDoc;
-}
-
-ColumnBlockPosition* StartListeningContext::getBlockPosition(SCTAB nTab, SCCOL nCol)
-{
- return mpSet->getBlockPosition(nTab, nCol);
-}
+ ColumnBlockContext(rDoc, pSet) {}
EndListeningContext::EndListeningContext(ScDocument& rDoc, ScTokenArray* pOldCode) :
- mrDoc(rDoc), maSet(false), mpPosSet(new ColumnBlockPositionSet(rDoc)),
- mpOldCode(pOldCode), maPosDelta(0,0,0) {}
+ ColumnBlockContext(rDoc),
+ maSet(false), mpOldCode(pOldCode), maPosDelta(0,0,0) {}
EndListeningContext::EndListeningContext(
ScDocument& rDoc, const boost::shared_ptr<ColumnBlockPositionSet>& pSet, ScTokenArray* pOldCode) :
- mrDoc(rDoc), maSet(false), mpPosSet(pSet),
- mpOldCode(pOldCode), maPosDelta(0,0,0) {}
+ ColumnBlockContext(rDoc, pSet),
+ maSet(false), mpOldCode(pOldCode), maPosDelta(0,0,0) {}
void EndListeningContext::setPositionDelta( const ScAddress& rDelta )
{
maPosDelta = rDelta;
}
-ScDocument& EndListeningContext::getDoc()
-{
- return mrDoc;
-}
-
ScTokenArray* EndListeningContext::getOldCode()
{
return mpOldCode;
@@ -63,11 +48,6 @@ ScAddress EndListeningContext::getOldPosition( const ScAddress& rPos ) const
return aOldPos;
}
-ColumnBlockPosition* EndListeningContext::getBlockPosition(SCTAB nTab, SCCOL nCol)
-{
- return mpPosSet->getBlockPosition(nTab, nCol);
-}
-
void EndListeningContext::addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, SCROW nRow)
{
maSet.set(nTab, nCol, nRow, true);
@@ -75,7 +55,7 @@ void EndListeningContext::addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, SC
void EndListeningContext::purgeEmptyBroadcasters()
{
- PurgeListenerAction aAction(mrDoc);
+ PurgeListenerAction aAction(getDoc());
maSet.executeAction(aAction);
}
More information about the Libreoffice-commits
mailing list