summaryrefslogtreecommitdiff
path: root/sc/source/core/data/document10.cxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-04-29 22:05:05 +0200
committerEike Rathke <erack@redhat.com>2016-04-30 00:30:35 +0200
commit02a8589553b5ce0e57a7ee9e66327376125b4378 (patch)
tree3c3424c1947613df77f7b682445577c2013e77d4 /sc/source/core/data/document10.cxx
parent8162cf2a005be68262525c2a11947fa0e10d15ed (diff)
Resolves: tdf#76523 copy used names or pointing to sheet to other document
Change-Id: I767ed1f212c257741fd982e8bbd0882a29d439c1
Diffstat (limited to 'sc/source/core/data/document10.cxx')
-rw-r--r--sc/source/core/data/document10.cxx7
1 files changed, 5 insertions, 2 deletions
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index f7ed6e89b80c..4690f9ba855b 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -656,7 +656,8 @@ ScRangeData* copyRangeNames( SheetIndexMap& rSheetIndexMap, std::vector<ScRangeD
} // namespace
bool ScDocument::CopyAdjustRangeName( SCTAB& rSheet, sal_uInt16& rIndex, ScRangeData*& rpRangeData,
- ScDocument& rNewDoc, const ScAddress& rNewPos, const ScAddress& rOldPos, const bool bGlobalNamesToLocal) const
+ ScDocument& rNewDoc, const ScAddress& rNewPos, const ScAddress& rOldPos, const bool bGlobalNamesToLocal,
+ const bool bUsedByFormula ) const
{
const bool bSameDoc = (rNewDoc.GetPool() == const_cast<ScDocument*>(this)->GetPool());
if (bSameDoc && ((rSheet < 0 && !bGlobalNamesToLocal) || (rSheet >= 0 && rSheet != rOldPos.Tab())))
@@ -725,7 +726,9 @@ bool ScDocument::CopyAdjustRangeName( SCTAB& rSheet, sal_uInt16& rIndex, ScRange
// If no range name was found copy it.
if (!rpRangeData)
{
- bool bEarlyBailOut = (nOldSheet < 0 && bSameDoc);
+ // Do not copy global name if it doesn't reference sheet or is not used
+ // by a formula copied to another document.
+ bool bEarlyBailOut = (nOldSheet < 0 && (bSameDoc || !bUsedByFormula));
MightReferenceSheet eMightReference = mightRangeNameReferenceSheet( pOldRangeData, nOldTab);
if (bEarlyBailOut && eMightReference == MightReferenceSheet::NONE)
return false;