[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Tue Jul 16 07:46:02 PDT 2013
sc/inc/reftokenhelper.hxx | 7 ++++---
sc/source/core/tool/chartlis.cxx | 8 ++++----
sc/source/core/tool/detfunc.cxx | 3 +--
sc/source/core/tool/reftokenhelper.cxx | 32 +++++++++++---------------------
sc/source/core/tool/token.cxx | 3 +--
sc/source/ui/unoobj/chart2uno.cxx | 20 ++++++++++----------
sc/source/ui/view/viewfun6.cxx | 8 ++++----
7 files changed, 35 insertions(+), 46 deletions(-)
New commits:
commit c24999695d4ba9caec91c7cb2cf8dd02341b0ff0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Jul 16 10:46:11 2013 -0400
More of the same.
Change-Id: I65902231e714f9b18b2d1ef61434913cb79af847
diff --git a/sc/inc/reftokenhelper.hxx b/sc/inc/reftokenhelper.hxx
index 0451dad..d7cfa8e 100644
--- a/sc/inc/reftokenhelper.hxx
+++ b/sc/inc/reftokenhelper.hxx
@@ -45,9 +45,9 @@ public:
::std::vector<ScTokenRef>& rRefTokens, const OUString& rRangeStr, ScDocument* pDoc,
const sal_Unicode cSep, ::formula::FormulaGrammar::Grammar eGrammar, bool bOnly3DRef = false);
- static bool getRangeFromToken(ScRange& rRange, const ScTokenRef& pToken, bool bExternal = false);
+ static bool getRangeFromToken(ScRange& rRange, const ScTokenRef& pToken, const ScAddress& rPos, bool bExternal = false);
- static void getRangeListFromTokens(ScRangeList& rRangeList, const ::std::vector<ScTokenRef>& pTokens);
+ static void getRangeListFromTokens(ScRangeList& rRangeList, const ::std::vector<ScTokenRef>& pTokens, const ScAddress& rPos);
/**
* Create a double reference token from a range object.
@@ -59,7 +59,8 @@ public:
static bool SC_DLLPUBLIC isRef(const ScTokenRef& pToken);
static bool SC_DLLPUBLIC isExternalRef(const ScTokenRef& pToken);
- static bool SC_DLLPUBLIC intersects(const ::std::vector<ScTokenRef>& rTokens, const ScTokenRef& pToken);
+ static bool SC_DLLPUBLIC intersects(
+ const ::std::vector<ScTokenRef>& rTokens, const ScTokenRef& pToken, const ScAddress& rPos);
static void SC_DLLPUBLIC join(::std::vector<ScTokenRef>& rTokens, const ScTokenRef& pToken);
diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx
index df584d4..db5096a 100644
--- a/sc/source/core/tool/chartlis.cxx
+++ b/sc/source/core/tool/chartlis.cxx
@@ -245,7 +245,7 @@ void ScChartListener::Update()
ScRangeListRef ScChartListener::GetRangeList() const
{
ScRangeListRef aRLRef(new ScRangeList);
- ScRefTokenHelper::getRangeListFromTokens(*aRLRef, *mpTokens);
+ ScRefTokenHelper::getRangeListFromTokens(*aRLRef, *mpTokens, ScAddress());
return aRLRef;
}
@@ -289,7 +289,7 @@ public:
else
{
ScRange aRange;
- ScRefTokenHelper::getRangeFromToken(aRange, pToken, bExternal);
+ ScRefTokenHelper::getRangeFromToken(aRange, pToken, ScAddress(), bExternal);
if (mbStart)
startListening(aRange);
else
@@ -365,7 +365,7 @@ void ScChartListener::UpdateChartIntersecting( const ScRange& rRange )
ScTokenRef pToken;
ScRefTokenHelper::getTokenFromRange(pToken, rRange);
- if (ScRefTokenHelper::intersects(*mpTokens, pToken))
+ if (ScRefTokenHelper::intersects(*mpTokens, pToken, ScAddress()))
{
// force update (chart has to be loaded), don't use ScChartListener::Update
mpDoc->UpdateChart(GetName());
@@ -376,7 +376,7 @@ void ScChartListener::UpdateChartIntersecting( const ScRange& rRange )
void ScChartListener::UpdateSeriesRanges()
{
ScRangeListRef pRangeList(new ScRangeList);
- ScRefTokenHelper::getRangeListFromTokens(*pRangeList, *mpTokens);
+ ScRefTokenHelper::getRangeListFromTokens(*pRangeList, *mpTokens, ScAddress());
mpDoc->SetChartRangeList(GetName(), pRangeList);
}
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index 517a892..9240811 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -1426,8 +1426,7 @@ void ScDetectiveFunc::GetAllSuccs(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW n
{
const ScAddress& aPos = aIter.GetPos();
ScTokenRef pRef(static_cast<ScToken*>(p->Clone()));
- pRef->CalcAbsIfRel(aPos);
- if (ScRefTokenHelper::intersects(aSrcRange, pRef))
+ if (ScRefTokenHelper::intersects(aSrcRange, pRef, aPos))
{
// This address is absolute.
pRef = ScRefTokenHelper::createRefToken(aPos);
diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx
index dbacb44..4580c4f 100644
--- a/sc/source/core/tool/reftokenhelper.cxx
+++ b/sc/source/core/tool/reftokenhelper.cxx
@@ -121,19 +121,8 @@ void ScRefTokenHelper::compileRangeRepresentation(
rRefTokens.clear();
}
-namespace {
-
-//may return a relative address
-void singleRefToAddr(const ScSingleRefData& rRef, ScAddress& rAddr)
-{
- rAddr.SetCol(rRef.nCol);
- rAddr.SetRow(rRef.nRow);
- rAddr.SetTab(rRef.nTab);
-}
-
-}
-
-bool ScRefTokenHelper::getRangeFromToken(ScRange& rRange, const ScTokenRef& pToken, bool bExternal)
+bool ScRefTokenHelper::getRangeFromToken(
+ ScRange& rRange, const ScTokenRef& pToken, const ScAddress& rPos, bool bExternal)
{
StackVar eType = pToken->GetType();
switch (pToken->GetType())
@@ -146,7 +135,7 @@ bool ScRefTokenHelper::getRangeFromToken(ScRange& rRange, const ScTokenRef& pTok
return false;
const ScSingleRefData& rRefData = pToken->GetSingleRef();
- singleRefToAddr(rRefData, rRange.aStart);
+ rRange.aStart = rRefData.toAbs(rPos);
rRange.aEnd = rRange.aStart;
return true;
}
@@ -158,8 +147,7 @@ bool ScRefTokenHelper::getRangeFromToken(ScRange& rRange, const ScTokenRef& pTok
return false;
const ScComplexRefData& rRefData = pToken->GetDoubleRef();
- singleRefToAddr(rRefData.Ref1, rRange.aStart);
- singleRefToAddr(rRefData.Ref2, rRange.aEnd);
+ rRange = rRefData.toAbs(rPos);
return true;
}
default:
@@ -168,13 +156,14 @@ bool ScRefTokenHelper::getRangeFromToken(ScRange& rRange, const ScTokenRef& pTok
return false;
}
-void ScRefTokenHelper::getRangeListFromTokens(ScRangeList& rRangeList, const vector<ScTokenRef>& rTokens)
+void ScRefTokenHelper::getRangeListFromTokens(
+ ScRangeList& rRangeList, const vector<ScTokenRef>& rTokens, const ScAddress& rPos)
{
vector<ScTokenRef>::const_iterator itr = rTokens.begin(), itrEnd = rTokens.end();
for (; itr != itrEnd; ++itr)
{
ScRange aRange;
- getRangeFromToken(aRange, *itr);
+ getRangeFromToken(aRange, *itr, rPos);
rRangeList.Append(aRange);
}
}
@@ -251,7 +240,8 @@ bool ScRefTokenHelper::isExternalRef(const ScTokenRef& pToken)
return false;
}
-bool ScRefTokenHelper::intersects(const vector<ScTokenRef>& rTokens, const ScTokenRef& pToken)
+bool ScRefTokenHelper::intersects(
+ const vector<ScTokenRef>& rTokens, const ScTokenRef& pToken, const ScAddress& rPos)
{
if (!isRef(pToken))
return false;
@@ -260,7 +250,7 @@ bool ScRefTokenHelper::intersects(const vector<ScTokenRef>& rTokens, const ScTok
sal_uInt16 nFileId = bExternal ? pToken->GetIndex() : 0;
ScRange aRange;
- getRangeFromToken(aRange, pToken, bExternal);
+ getRangeFromToken(aRange, pToken, rPos, bExternal);
vector<ScTokenRef>::const_iterator itr = rTokens.begin(), itrEnd = rTokens.end();
for (; itr != itrEnd; ++itr)
@@ -273,7 +263,7 @@ bool ScRefTokenHelper::intersects(const vector<ScTokenRef>& rTokens, const ScTok
continue;
ScRange aRange2;
- getRangeFromToken(aRange2, p, bExternal);
+ getRangeFromToken(aRange2, p, rPos, bExternal);
if (bExternal && nFileId != p->GetIndex())
// different external file
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 8cc5313..250433a 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2060,8 +2060,7 @@ bool SkipReference(ScToken* pToken, const ScAddress& rPos, const ScDocument* pOl
{
ScRange aRange;
- pToken->CalcAbsIfRel(rPos);
- if (!ScRefTokenHelper::getRangeFromToken(aRange, pToken))
+ if (!ScRefTokenHelper::getRangeFromToken(aRange, pToken, rPos))
return true;
if (bRangeName && aRange.aStart.Tab() == rPos.Tab())
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index e3e9562..979b6b1 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -315,7 +315,7 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
if( eType==svExternal || eType==svExternalSingleRef || eType==svExternalDoubleRef || eType==svExternalName )
bExternal = true;//lllll todo correct?
ScTokenRef pSharedToken(static_cast<ScToken*>(pToken->Clone()));
- ScRefTokenHelper::getRangeFromToken(aRange, pSharedToken, bExternal );
+ ScRefTokenHelper::getRangeFromToken(aRange, pSharedToken, ScAddress(), bExternal);
SCCOL nCol1=0, nCol2=0;
SCROW nRow1=0, nRow2=0;
SCTAB nTab1=0, nTab2=0;
@@ -2529,7 +2529,7 @@ void ScChart2DataSequence::RefChanged()
for (; itr != itrEnd; ++itr)
{
ScRange aRange;
- if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr))
+ if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr, ScAddress()))
continue;
m_pDocument->StartListeningArea(aRange, m_pValueListener);
@@ -2569,7 +2569,7 @@ void ScChart2DataSequence::BuildDataCache()
else
{
ScRange aRange;
- if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr))
+ if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr, ScAddress()))
continue;
SCCOL nLastCol = -1;
@@ -2658,7 +2658,7 @@ sal_Int32 ScChart2DataSequence::FillCacheFromExternalRef(const ScTokenRef& pToke
{
ScExternalRefManager* pRefMgr = m_pDocument->GetExternalRefManager();
ScRange aRange;
- if (!ScRefTokenHelper::getRangeFromToken(aRange, pToken, true))
+ if (!ScRefTokenHelper::getRangeFromToken(aRange, pToken, ScAddress(), true))
return 0;
sal_uInt16 nFileId = pToken->GetIndex();
@@ -2866,7 +2866,7 @@ void ScChart2DataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint
if (!ScRefTokenHelper::isExternalRef(*itr))
{
ScRange aRange;
- ScRefTokenHelper::getRangeFromToken(aRange, *itr);
+ ScRefTokenHelper::getRangeFromToken(aRange, *itr, ScAddress());
aRanges.Append(aRange);
sal_uInt32 nPos = distance(itrBeg, itr);
m_pRangeIndices->push_back(nPos);
@@ -3115,7 +3115,7 @@ public:
{
ScRange r;
bool bExternal = ScRefTokenHelper::isExternalRef(pToken);
- ScRefTokenHelper::getRangeFromToken(r, pToken, bExternal);
+ ScRefTokenHelper::getRangeFromToken(r, pToken, ScAddress(), bExternal);
r.Justify();
mnCols += r.aEnd.Col() - r.aStart.Col() + 1;
mnRows += r.aEnd.Row() - r.aStart.Row() + 1;
@@ -3151,7 +3151,7 @@ public:
{
bool bExternal = ScRefTokenHelper::isExternalRef(pToken);
ScRange aRange;
- ScRefTokenHelper::getRangeFromToken(aRange, pToken, bExternal);
+ ScRefTokenHelper::getRangeFromToken(aRange, pToken, ScAddress(), bExternal);
OUString* pArr = mpLabels->getArray();
if (mbColumn)
{
@@ -3276,7 +3276,7 @@ sal_uLong getDisplayNumberFormat(ScDocument* pDoc, const ScAddress& rPos)
sal_Int32 nCount = 0;
ScRangeList aRanges;
- ScRefTokenHelper::getRangeListFromTokens(aRanges, *m_pTokens);
+ ScRefTokenHelper::getRangeListFromTokens(aRanges, *m_pTokens, ScAddress());
for (size_t i = 0, n = aRanges.size(); i < n; ++i)
{
ScRange* p = aRanges[i];
@@ -3376,7 +3376,7 @@ void SAL_CALL ScChart2DataSequence::addModifyListener( const uno::Reference< uti
return;
ScRangeList aRanges;
- ScRefTokenHelper::getRangeListFromTokens(aRanges, *m_pTokens);
+ ScRefTokenHelper::getRangeListFromTokens(aRanges, *m_pTokens, ScAddress());
uno::Reference<util::XModifyListener> *pObj =
new uno::Reference<util::XModifyListener>( aListener );
m_aValueListeners.push_back( pObj );
@@ -3396,7 +3396,7 @@ void SAL_CALL ScChart2DataSequence::addModifyListener( const uno::Reference< uti
for (; itr != itrEnd; ++itr)
{
ScRange aRange;
- if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr))
+ if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr, ScAddress()))
continue;
m_pDocument->StartListeningArea( aRange, m_pValueListener );
diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx
index 9927e86..be2178b 100644
--- a/sc/source/ui/view/viewfun6.cxx
+++ b/sc/source/ui/view/viewfun6.cxx
@@ -180,7 +180,7 @@ void ScViewFunc::DetectiveMarkPred()
const OUString* pPath = pRefMgr->getExternalFileName(nFileId);
ScRange aRange;
- if (pPath && ScRefTokenHelper::getRangeFromToken(aRange, p, true))
+ if (pPath && ScRefTokenHelper::getRangeFromToken(aRange, p, aCurPos, true))
{
const String& rTabName = p->GetString();
OUStringBuffer aBuf;
@@ -200,7 +200,7 @@ void ScViewFunc::DetectiveMarkPred()
else
{
ScRange aRange;
- ScRefTokenHelper::getRangeFromToken(aRange, p, false);
+ ScRefTokenHelper::getRangeFromToken(aRange, p, aCurPos, false);
if (aRange.aStart.Tab() != aCurPos.Tab())
{
// The first precedent range is on a different sheet. Jump to it
@@ -211,7 +211,7 @@ void ScViewFunc::DetectiveMarkPred()
}
ScRangeList aDestRanges;
- ScRefTokenHelper::getRangeListFromTokens(aDestRanges, aRefTokens);
+ ScRefTokenHelper::getRangeListFromTokens(aDestRanges, aRefTokens, aCurPos);
MarkAndJumpToRanges(aDestRanges);
}
@@ -235,7 +235,7 @@ void ScViewFunc::DetectiveMarkSucc()
return;
ScRangeList aDestRanges;
- ScRefTokenHelper::getRangeListFromTokens(aDestRanges, aRefTokens);
+ ScRefTokenHelper::getRangeListFromTokens(aDestRanges, aRefTokens, aCurPos);
MarkAndJumpToRanges(aDestRanges);
}
More information about the Libreoffice-commits
mailing list