summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-03-26 16:12:49 +0100
committerAndras Timar <andras.timar@collabora.com>2019-03-27 21:48:27 +0100
commit59e89f7ef64ae2b40a37aa552c51a69ceea1cd42 (patch)
treeab94b7e322b1dc4377507404e92f966015553e0b /svl
parent5aa23e4d6e849f1ecccb2f6f290e7b34c9df7399 (diff)
MSO lockfiles: Deduplicate MSO lock file reading code
The removed code was extracted to MSODocumentLockFile class so use that class here too. Use openStreamNoLock() for reading MSO lockfiles, because otherwise we can not read lock files written by MSO. Change-Id: Ib31cb9f3783d0b0ce784f900821047b9d32156f2 Reviewed-on: https://gerrit.libreoffice.org/69759 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> (cherry picked from commit ad47e9b1c0d3f1720665b2786090e8c0927b5b45) Reviewed-on: https://gerrit.libreoffice.org/69844 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/misc/msodocumentlockfile.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/svl/source/misc/msodocumentlockfile.cxx b/svl/source/misc/msodocumentlockfile.cxx
index e1afd70ef2e8..0309f86bc41e 100644
--- a/svl/source/misc/msodocumentlockfile.cxx
+++ b/svl/source/misc/msodocumentlockfile.cxx
@@ -11,10 +11,13 @@
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
#include <algorithm>
+#include <ucbhelper/content.hxx>
+#include <comphelper/processfactory.hxx>
#include <com/sun/star/io/IOException.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
namespace svt
{
@@ -179,6 +182,17 @@ void MSODocumentLockFile::WriteEntryToStream(
xOutput->writeBytes(aData);
}
+css::uno::Reference<css::io::XInputStream> MSODocumentLockFile::OpenStream()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ css::uno::Reference<css::ucb::XCommandEnvironment> xEnv;
+ ::ucbhelper::Content aSourceContent(GetURL(), xEnv, comphelper::getProcessComponentContext());
+
+ // the file can be opened readonly, no locking will be done
+ return aSourceContent.openStreamNoLock();
+}
+
LockFileEntry MSODocumentLockFile::GetLockData()
{
::osl::MutexGuard aGuard(m_aMutex);