[Libreoffice-commits] .: sc/inc sc/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Sun Apr 22 16:24:14 PDT 2012
sc/inc/tokenarray.hxx | 3 ++-
sc/source/core/data/cell.cxx | 7 ++++---
sc/source/core/tool/token.cxx | 14 +++++++-------
3 files changed, 13 insertions(+), 11 deletions(-)
New commits:
commit bba176a844bd993cf7fe6acce9ff18027870dfa5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Mon Apr 23 01:15:01 2012 +0200
only update absolute refs when copying between docs, fdo#48482
The copy/paste formulas code is getting a bit complex. I will try to
write some test cases for it.
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 48bf4c5..cc55936 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -108,8 +108,9 @@ public:
/**
* Make all absolute references pointing to the copied range if the range is copied too
+ * @param bCheckCopyArea should references pointing into the copy area be adjusted independently from being absolute, should be true only for copy&paste between documents
*/
- void AdjustAbsoluteRefs( const ScDocument* pOldDoc, const ScAddress& rOldPos, const ScAddress& rNewPos, bool bRangeName = false );
+ void AdjustAbsoluteRefs( const ScDocument* pOldDoc, const ScAddress& rOldPos, const ScAddress& rNewPos, bool bRangeName = false, bool bCheckCopyArea = false );
};
#endif // SC_TOKENARRAY_HXX
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index a4e5361..fd9499b 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -175,7 +175,7 @@ void adjustRangeName(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOl
if (rNewDoc.GetPool() != const_cast<ScDocument*>(pOldDoc)->GetPool())
{
pRangeNameToken->ReadjustAbsolute3DReferences(pOldDoc, &rNewDoc, pRangeData->GetPos(), true);
- pRangeNameToken->AdjustAbsoluteRefs(pOldDoc, aOldPos, aNewPos, true);
+ pRangeNameToken->AdjustAbsoluteRefs(pOldDoc, aOldPos, aNewPos, false, true);
}
bool bInserted;
@@ -811,12 +811,13 @@ ScFormulaCell::ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, cons
}
}
- if (pDocument->GetPool() != rCell.pDocument->GetPool())
+ bool bCopyBetweenDocs = pDocument->GetPool() != rCell.pDocument->GetPool();
+ if (bCopyBetweenDocs)
{
pCode->ReadjustAbsolute3DReferences( rCell.pDocument, &rDoc, rCell.aPos);
}
- pCode->AdjustAbsoluteRefs( rCell.pDocument, rCell.aPos, aPos );
+ pCode->AdjustAbsoluteRefs( rCell.pDocument, rCell.aPos, aPos, false, bCopyBetweenDocs );
}
if ( nCloneFlags & SC_CLONECELL_ADJUST3DREL )
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 0bbb3d6..dc88df1 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1832,7 +1832,7 @@ bool IsInCopyRange( const ScRange& rRange, const ScDocument* pClipDoc )
return rClipParam.maRanges.In(rRange);
}
-bool SkipReference(ScToken* pToken, const ScAddress& rPos, const ScDocument* pOldDoc, bool bRangeName)
+bool SkipReference(ScToken* pToken, const ScAddress& rPos, const ScDocument* pOldDoc, bool bRangeName, bool bCheckCopyArea)
{
ScRange aRange;
@@ -1862,7 +1862,7 @@ bool SkipReference(ScToken* pToken, const ScAddress& rPos, const ScDocument* pOl
}
}
- if (IsInCopyRange(aRange, pOldDoc))
+ if (bCheckCopyArea && IsInCopyRange(aRange, pOldDoc))
return true;
return false;
@@ -1894,7 +1894,7 @@ void ScTokenArray::ReadjustAbsolute3DReferences( const ScDocument* pOldDoc, cons
{
case svDoubleRef :
{
- if (SkipReference(static_cast<ScToken*>(pCode[j]), rPos, pOldDoc, bRangeName))
+ if (SkipReference(static_cast<ScToken*>(pCode[j]), rPos, pOldDoc, bRangeName, true))
continue;
ScComplexRefData& rRef = static_cast<ScToken*>(pCode[j])->GetDoubleRef();
@@ -1915,7 +1915,7 @@ void ScTokenArray::ReadjustAbsolute3DReferences( const ScDocument* pOldDoc, cons
break;
case svSingleRef :
{
- if (SkipReference(static_cast<ScToken*>(pCode[j]), rPos, pOldDoc, bRangeName))
+ if (SkipReference(static_cast<ScToken*>(pCode[j]), rPos, pOldDoc, bRangeName, true))
continue;
ScSingleRefData& rRef = static_cast<ScToken*>(pCode[j])->GetSingleRef();
@@ -1941,7 +1941,7 @@ void ScTokenArray::ReadjustAbsolute3DReferences( const ScDocument* pOldDoc, cons
}
}
-void ScTokenArray::AdjustAbsoluteRefs( const ScDocument* pOldDoc, const ScAddress& rOldPos, const ScAddress& rNewPos, bool bRangeName)
+void ScTokenArray::AdjustAbsoluteRefs( const ScDocument* pOldDoc, const ScAddress& rOldPos, const ScAddress& rNewPos, bool bRangeName, bool bCheckCopyRange)
{
for ( sal_uInt16 j=0; j<nLen; ++j )
{
@@ -1949,7 +1949,7 @@ void ScTokenArray::AdjustAbsoluteRefs( const ScDocument* pOldDoc, const ScAddres
{
case svDoubleRef :
{
- if (!SkipReference(static_cast<ScToken*>(pCode[j]), rOldPos, pOldDoc, false))
+ if (!SkipReference(static_cast<ScToken*>(pCode[j]), rOldPos, pOldDoc, false, bCheckCopyRange))
continue;
ScComplexRefData& rRef = static_cast<ScToken*>(pCode[j])->GetDoubleRef();
@@ -1966,7 +1966,7 @@ void ScTokenArray::AdjustAbsoluteRefs( const ScDocument* pOldDoc, const ScAddres
break;
case svSingleRef :
{
- if (!SkipReference(static_cast<ScToken*>(pCode[j]), rOldPos, pOldDoc, false))
+ if (!SkipReference(static_cast<ScToken*>(pCode[j]), rOldPos, pOldDoc, false, bCheckCopyRange))
continue;
ScSingleRefData& rRef = static_cast<ScToken*>(pCode[j])->GetSingleRef();
More information about the Libreoffice-commits
mailing list