[Libreoffice-commits] .: sc/inc sc/source
Eike Rathke
erack at kemper.freedesktop.org
Thu Apr 19 14:26:29 PDT 2012
sc/inc/compiler.hxx | 7 ++++++
sc/inc/rangenam.hxx | 2 -
sc/source/core/data/table1.cxx | 8 ++++---
sc/source/core/tool/compiler.cxx | 43 ++++++++++++++++-----------------------
sc/source/core/tool/rangenam.cxx | 2 -
5 files changed, 32 insertions(+), 30 deletions(-)
New commits:
commit 409f11ae387c859dcf9275c08093649a676e1f9e
Author: Eike Rathke <erack at redhat.com>
Date: Thu Apr 19 23:26:16 2012 +0200
fdo#48856 update sheet-local named expressions correctly
* Named expression must be updated before any formulas that would access them.
* Handle all ocName tokens differentiating between global and sheet-local
names.
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index b83448b..58a3c6c 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -364,6 +364,13 @@ private:
void SetRelNameReference();
+ /** Obtain range data for ocName token, global or sheet local.
+
+ Prerequisite: rToken is a FormulaIndexToken so IsGlobal() and
+ GetIndex() can be called on it. We don't check with RTTI.
+ */
+ ScRangeData* GetRangeData( const formula::FormulaToken& pToken ) const;
+
static void InitCharClassEnglish();
public:
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 2e3c007..dfb7d9e 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -201,7 +201,7 @@ public:
SC_DLLPUBLIC const ScRangeData* findByRange(const ScRange& rRange) const;
SC_DLLPUBLIC ScRangeData* findByUpperName(const rtl::OUString& rName);
SC_DLLPUBLIC const ScRangeData* findByUpperName(const rtl::OUString& rName) const;
- SC_DLLPUBLIC ScRangeData* findByIndex(sal_uInt16 i);
+ SC_DLLPUBLIC ScRangeData* findByIndex(sal_uInt16 i) const;
void UpdateReference(UpdateRefMode eUpdateRefMode, const ScRange& rRange,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz, bool bLocal = false);
void UpdateTabRef(SCTAB nTable, sal_uInt16 nFlag, SCTAB nNewTable = 0, SCTAB nNewSheets = 1);
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index acf5205..40cc82c 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1372,16 +1372,18 @@ void ScTable::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW
i = 0;
iMax = MAXCOL;
}
- for ( ; i<=iMax; i++)
- bUpdated |= aCol[i].UpdateReference(
- eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, pUndoDoc );
+ // Named expressions need to be updated before formulas acessing them.
if (mpRangeName)
{
ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );;
mpRangeName->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz, true );
}
+ for ( ; i<=iMax; i++)
+ bUpdated |= aCol[i].UpdateReference(
+ eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, pUndoDoc );
+
if ( bIncludeDraw )
UpdateDrawRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, bUpdateNoteCaptionPos );
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index be051c9..a46bd00 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3978,22 +3978,27 @@ ScTokenArray* ScCompiler::CompileString( const String& rFormula, const String& r
}
-bool ScCompiler::HandleRange()
+ScRangeData* ScCompiler::GetRangeData( const FormulaToken& rToken ) const
{
ScRangeData* pRangeData = NULL;
-
- bool bGlobal = pToken->IsGlobal();
+ bool bGlobal = rToken.IsGlobal();
if (bGlobal)
// global named range.
- pRangeData = pDoc->GetRangeName()->findByIndex( pToken->GetIndex() );
+ pRangeData = pDoc->GetRangeName()->findByIndex( rToken.GetIndex());
else
{
// sheet local named range.
- ScRangeName* pRN = pDoc->GetRangeName(aPos.Tab());
+ const ScRangeName* pRN = pDoc->GetRangeName( aPos.Tab());
if (pRN)
- pRangeData = pRN->findByIndex( pToken->GetIndex() );
+ pRangeData = pRN->findByIndex( rToken.GetIndex());
}
+ return pRangeData;
+}
+
+bool ScCompiler::HandleRange()
+{
+ const ScRangeData* pRangeData = GetRangeData( *pToken);
if (pRangeData)
{
sal_uInt16 nErr = pRangeData->GetErrCode();
@@ -4118,7 +4123,7 @@ bool ScCompiler::HasModifiedRange()
OpCode eOpCode = t->GetOpCode();
if ( eOpCode == ocName )
{
- ScRangeData* pRangeData = pDoc->GetRangeName()->findByIndex(t->GetIndex());
+ const ScRangeData* pRangeData = GetRangeData( *t);
if (pRangeData && pRangeData->IsModified())
return true;
}
@@ -4239,7 +4244,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
{
if( j->GetOpCode() == ocName )
{
- ScRangeData* pName = pDoc->GetRangeName()->findByIndex( j->GetIndex() );
+ ScRangeData* pName = GetRangeData( *j);
if (pName && pName->HasType(RT_SHARED))
pRangeData = pName;
}
@@ -4292,7 +4297,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
{
if( t->GetOpCode() == ocName )
{
- ScRangeData* pName = pDoc->GetRangeName()->findByIndex( t->GetIndex() );
+ ScRangeData* pName = GetRangeData( *t);
if (pName && pName->HasType(RT_SHAREDMOD))
{
pRangeData = pName; // maybe need a replacement of shared with own code
@@ -4582,7 +4587,7 @@ ScRangeData* ScCompiler::UpdateInsertTab( SCTAB nTable, bool bIsName , SCTAB nNe
{
if (!bIsName)
{
- ScRangeData* pName = pDoc->GetRangeName()->findByIndex(t->GetIndex());
+ ScRangeData* pName = GetRangeData( *t);
if (pName && pName->HasType(RT_SHAREDMOD))
pRangeData = pName;
}
@@ -4693,7 +4698,7 @@ ScRangeData* ScCompiler::UpdateDeleteTab(SCTAB nTable, bool /* bIsMove */, bool
{
if (!bIsName)
{
- ScRangeData* pName = pDoc->GetRangeName()->findByIndex(t->GetIndex());
+ ScRangeData* pName = GetRangeData( *t);
if (pName && pName->HasType(RT_SHAREDMOD))
pRangeData = pName;
}
@@ -4903,7 +4908,7 @@ ScRangeData* ScCompiler::UpdateMoveTab( SCTAB nOldTab, SCTAB nNewTab,
{
if (!bIsName)
{
- ScRangeData* pName = pDoc->GetRangeName()->findByIndex(t->GetIndex());
+ ScRangeData* pName = GetRangeData( *t);
if (pName && pName->HasType(RT_SHAREDMOD))
pRangeData = pName;
}
@@ -5157,19 +5162,7 @@ void ScCompiler::CreateStringFromIndex(rtl::OUStringBuffer& rBuffer,FormulaToken
{
case ocName:
{
- bool bGlobal = _pTokenP->IsGlobal();
- ScRangeData* pData = NULL;
- if (bGlobal)
- // global named range.
- pData = pDoc->GetRangeName()->findByIndex(_pTokenP->GetIndex());
- else
- {
- // sheet local named range.
- ScRangeName* pRN = pDoc->GetRangeName(aPos.Tab());
- if (pRN)
- pData = pRN->findByIndex(_pTokenP->GetIndex());
- }
-
+ ScRangeData* pData = GetRangeData( *_pTokenP);
if (pData)
{
if (pData->HasType(RT_SHARED))
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 8f10302..e671585 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -768,7 +768,7 @@ const ScRangeData* ScRangeName::findByUpperName(const OUString& rName) const
return itr == maData.end() ? NULL : itr->second;
}
-ScRangeData* ScRangeName::findByIndex(sal_uInt16 i)
+ScRangeData* ScRangeName::findByIndex(sal_uInt16 i) const
{
if (!i)
// index should never be zero.
More information about the Libreoffice-commits
mailing list