sc/inc/document.hxx | 1 + sc/source/core/data/document.cxx | 11 +++++++++++ sc/source/ui/docshell/docsh.cxx | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 1 deletion(-)
New commits: commit 831d1b6e62e91e67f171bd00305651043731d496 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Thu Jan 10 16:21:05 2013 -0500 fdo#58069: Invalidate sheet stream cache when directory path changes. To properly regenerate hyperlinks (among other things) which depend on the full path of the host document. Change-Id: I44fdd5b0ef0a57bf4fae13f29f1ebacfe1ab19a8 diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index a72f759..7573a80 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -572,6 +572,7 @@ public: void AppendTabOnLoad(const rtl::OUString& rName); void SetTabNameOnLoad(SCTAB nTab, const rtl::OUString& rName); + void InvalidateStreamOnSave(); SC_DLLPUBLIC bool InsertTab( SCTAB nPos, const rtl::OUString& rName, bool bExternalDocument = false ); diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 78ae823..a3e5cfa 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -402,6 +402,17 @@ void ScDocument::SetTabNameOnLoad(SCTAB nTab, const rtl::OUString& rName) maTabs[nTab]->SetName(rName); } +void ScDocument::InvalidateStreamOnSave() +{ + TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end(); + for (; it != itEnd; ++it) + { + ScTable* pTab = *it; + if (pTab) + pTab->SetStreamValid(false); + } +} + bool ScDocument::InsertTab( SCTAB nPos, const rtl::OUString& rName, bool bExternalDocument ) { diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index c8ff10b..2c35c01 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -34,6 +34,7 @@ #include <sfx2/objface.hxx> #include <svl/documentlockfile.hxx> #include <svl/sharecontrolfile.hxx> +#include "svl/urihelper.hxx" #include "chgtrack.hxx" #include "chgviset.hxx" #include <com/sun/star/awt/Key.hpp> @@ -1528,10 +1529,45 @@ sal_Bool ScDocShell::Save() return bRet; } +namespace { + +/** + * Remove the file name from the full path, to keep only the directory path. + */ +void popFileName(OUString& rPath) +{ + if (!rPath.isEmpty()) + { + INetURLObject aURLObj(rPath); + aURLObj.removeSegment(); + rPath = aURLObj.GetMainURL(INetURLObject::NO_DECODE); + } +} + +} sal_Bool ScDocShell::SaveAs( SfxMedium& rMedium ) { - RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::SaveAs" ); + OUString aCurPath; // empty for new document that hasn't been saved. + const SfxMedium* pCurMedium = GetMedium(); + if (pCurMedium) + { + aCurPath = pCurMedium->GetName(); + popFileName(aCurPath); + } + + if (!aCurPath.isEmpty()) + { + // current document has a path -> not a brand-new document. + OUString aNewPath = rMedium.GetName(); + popFileName(aNewPath); + OUString aRel = URIHelper::simpleNormalizedMakeRelative(aCurPath, aNewPath); + if (!aRel.isEmpty()) + { + // Directory path will change before and after the save. + aDocument.InvalidateStreamOnSave(); + } + } ScTabViewShell* pViewShell = GetBestViewShell(); bool bNeedsRehash = ScPassHashHelper::needsPassHashRegen(aDocument, PASSHASH_SHA1); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits