summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-12-27 07:37:02 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-12-27 07:56:06 +0100
commit32f38931ee5973b5db2255e1ee0c63b3a7b00831 (patch)
tree5a65a4b67dbc910a7548e54d63fb9957fd2e2907 /sc
parentf36743fe31efaff4203a6728ab55bc694a012618 (diff)
better handling for unsaved external references
Now references to unsaved documents can be created in the sheet and not only through copy/paste This fixes the problem that otherwise editing these refs resulted in #REF
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index bec7700e56ee..536dea74183f 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2142,6 +2142,17 @@ const ScDocument* ScExternalRefManager::getSrcDocument(sal_uInt16 nFileId)
return static_cast<ScDocShell*>(p)->GetDocument();
}
+ itrEnd = maUnsavedDocShells.end();
+ itr = maUnsavedDocShells.find(nFileId);
+ if (itr != itrEnd)
+ {
+ //document is unsaved document
+
+ SfxObjectShell* p = itr->second.maShell;
+ itr->second.maLastAccess = Time( Time::SYSTEM );
+ return static_cast<ScDocShell*>(p)->GetDocument();
+ }
+
const OUString* pFile = getExternalFileName(nFileId);
if (!pFile)
// no file name associated with this ID.
@@ -2356,6 +2367,17 @@ bool ScExternalRefManager::isOwnDocument(const OUString& rFile) const
void ScExternalRefManager::convertToAbsName(OUString& rFile) const
{
+ // unsaved documents have no AbsName
+ TypeId aType(TYPE(ScDocShell));
+ ScDocShell* pShell = static_cast<ScDocShell*>(SfxObjectShell::GetFirst(&aType, false));
+ while (pShell)
+ {
+ if (rFile == rtl::OUString(pShell->GetName()))
+ return;
+
+ pShell = static_cast<ScDocShell*>(SfxObjectShell::GetNext(*pShell, &aType, false));
+ }
+
SfxObjectShell* pDocShell = mpDoc->GetDocumentShell();
rFile = ScGlobal::GetAbsDocName(rFile, pDocShell);
}