summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-03-26 16:12:49 +0100
committerTamás Zolnai <tamas.zolnai@collabora.com>2019-06-20 14:23:21 +0200
commitc9dcc2172727cd75f512409c39eef460d44396dd (patch)
treeb1dcdcf08d1d328a3db3787a811914ffb31f984d /svl
parentdac99f6818e6e68198896e93835760b82df2703e (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)
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);