21#include <com/sun/star/ucb/XCommandEnvironment.hpp>
22#include <com/sun/star/ucb/InsertCommandArgument.hpp>
23#include <com/sun/star/ucb/NameClashException.hpp>
24#include <com/sun/star/io/WrongFormatException.hpp>
25#include <com/sun/star/io/TempFile.hpp>
26#include <com/sun/star/io/XStream.hpp>
27#include <com/sun/star/io/XInputStream.hpp>
28#include <com/sun/star/io/XOutputStream.hpp>
29#include <com/sun/star/io/XSeekable.hpp>
30#include <com/sun/star/io/XTruncate.hpp>
34#include <rtl/string.hxx>
35#include <rtl/ustring.hxx>
36#include <rtl/ustrbuf.hxx>
60 uno::Reference < css::ucb::XCommandEnvironment > xEnv;
73 uno::Reference< io::XStream > xTempFile(
75 uno::UNO_QUERY_THROW );
76 uno::Reference< io::XSeekable > xSeekable( xTempFile, uno::UNO_QUERY_THROW );
78 uno::Reference< io::XInputStream > xInput = xTempFile->getInputStream();
79 uno::Reference< io::XOutputStream > xOutput = xTempFile->getOutputStream();
81 if ( !xInput.is() || !xOutput.is() )
82 throw uno::RuntimeException();
86 xOutput->closeOutput();
90 uno::Reference < css::ucb::XCommandEnvironment > xEnv;
93 ucb::InsertCommandArgument aInsertArg;
94 aInsertArg.Data = xInput;
95 aInsertArg.ReplaceExisting =
false;
97 aCmdArg <<= aInsertArg;
103 }
catch( uno::Exception& ) {}
105 catch( ucb::NameClashException& )
120 uno::Reference < css::ucb::XCommandEnvironment > xEnv;
126 uno::Reference< io::XOutputStream > xOutput =
xStream->getOutputStream();
127 uno::Reference< io::XTruncate > xTruncate( xOutput, uno::UNO_QUERY_THROW );
129 xTruncate->truncate();
131 xOutput->closeOutput();
133 catch( uno::Exception& )
143 std::unique_lock aGuard(
m_aMutex );
152 throw io::IOException();
159 uno::Reference < css::ucb::XCommandEnvironment > xEnv;
183 std::unique_lock<std::mutex>& ,
184 const LockFileEntry& aEntry,
const uno::Reference< io::XOutputStream >& xOutput )
198 uno::Sequence< sal_Int8 >
aData(
reinterpret_cast<sal_Int8 const *
>(aStringData.getStr()), aStringData.getLength() );
199 xOutput->writeBytes(
aData );
204 uno::Reference< io::XInputStream > xInput =
OpenStream(rGuard);
206 throw uno::RuntimeException();
208 const sal_Int32 nBufLen = 32000;
209 uno::Sequence< sal_Int8 >
aBuffer( nBufLen );
211 sal_Int32 nRead = xInput->readBytes(
aBuffer, nBufLen );
212 xInput->closeInput();
214 if ( nRead == nBufLen )
215 throw io::WrongFormatException();
217 sal_Int32 nCurPos = 0;
virtual void WriteEntryToStream(std::unique_lock< std::mutex > &rGuard, const LockFileEntry &aEntry, const css::uno::Reference< css::io::XOutputStream > &xStream) override
virtual LockFileEntry GetLockDataImpl(std::unique_lock< std::mutex > &rGuard) override
DocumentLockFile(std::u16string_view aOrigURL)
virtual ~DocumentLockFile() override
Generalized class for LO and MSO lockfile handling.
virtual css::uno::Reference< css::io::XInputStream > OpenStream(std::unique_lock< std::mutex > &rGuard)
LockFileEntry GetLockData()
virtual ~GenDocumentLockFile() override
bool OverwriteOwnLockFile()
virtual LockFileEntry GetLockDataImpl(std::unique_lock< std::mutex > &rGuard)=0
void RemoveFileDirectly()
Only delete lockfile, disregarding ownership.
GenDocumentLockFile(const OUString &aLockFileURL)
virtual void RemoveFile()
Delete the Lockfile, if current user is the owner.
virtual void WriteEntryToStream(std::unique_lock< std::mutex > &rGuard, const LockFileEntry &aEntry, const css::uno::Reference< css::io::XOutputStream > &xStream)=0
This is a general implementation that is used in document lock file implementation and in sharing con...
static LockFileEntry GenerateOwnEntry()
static OUString EscapeCharacters(const OUString &aSource)
const OUString & GetURL() const
static LockFileEntry ParseEntry(const css::uno::Sequence< sal_Int8 > &aBuffer, sal_Int32 &o_nCurPos)
css::uno::Any setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue)
css::uno::Any executeCommand(const OUString &rCommandName, const css::uno::Any &rCommandArgument)
css::uno::Reference< css::io::XStream > openWriteableStreamNoLock()
css::uno::Reference< css::io::XInputStream > openStream()
constexpr OUStringLiteral aData
Reference< XComponentContext > getProcessComponentContext()
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::unique_ptr< char[]> aBuffer