diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-03-26 16:12:49 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-03-27 10:01:33 +0100 |
commit | ad47e9b1c0d3f1720665b2786090e8c0927b5b45 (patch) | |
tree | c36ae294d606e935ec1716b07deea622a743986f /svl | |
parent | f1e52cbdd4a9753a9b9d562ef280a00e52db1dae (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>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/misc/msodocumentlockfile.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/svl/source/misc/msodocumentlockfile.cxx b/svl/source/misc/msodocumentlockfile.cxx index ddb5de6c5632..432fb6e07ecd 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); |