Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/1634
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/34/1634/1
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
---
M sc/inc/document.hxx
M sc/source/core/data/document.cxx
M sc/source/ui/docshell/docsh.cxx
3 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 5b5a472..76df284 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -571,6 +571,7 @@
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 9d8a8c3..65e904f 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -402,6 +402,17 @@
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 291f5e0..948f622 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>
@@ -1526,10 +1527,45 @@
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);
--
To view, visit https://gerrit.libreoffice.org/1634
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I44fdd5b0ef0a57bf4fae13f29f1ebacfe1ab19a8
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Kohei Yoshida <kohei.yoshida@gmail.com>
Context
- [PATCH] Change in core[libreoffice-4-0]: fdo#58069: Invalidate sheet stream cache when directory path... · Kohei Yoshida (via Code Review)
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.