21#include <com/sun/star/ucb/SimpleFileAccess.hpp>
22#include <com/sun/star/ucb/XCommandEnvironment.hpp>
23#include <com/sun/star/ucb/XContent.hpp>
24#include <com/sun/star/ucb/InsertCommandArgument.hpp>
25#include <com/sun/star/ucb/InteractiveIOException.hpp>
26#include <com/sun/star/io/NotConnectedException.hpp>
30#include <rtl/string.hxx>
31#include <rtl/ustring.hxx>
32#include <rtl/ustrbuf.hxx>
52 uno::Reference< ucb::XCommandEnvironment > xDummyEnv;
55 uno::Reference< ucb::XContentIdentifier > xContId( aContent.
get().is() ? aContent.
get()->getIdentifier() :
nullptr );
56 if ( !xContId.is() || xContId->getContentProviderScheme() !=
"file" )
57 throw io::IOException();
59 uno::Reference< io::XStream >
xStream;
69 catch ( ucb::InteractiveIOException
const & e )
71 if ( e.Code == ucb::IOErrorCode_NOT_EXISTING )
75 uno::Reference< io::XInputStream > xInput( new ::utl::OInputStreamWrapper( aStream ) );
76 ucb::InsertCommandArgument aInsertArg;
77 aInsertArg.Data = xInput;
78 aInsertArg.ReplaceExisting =
false;
84 }
catch( uno::Exception& ) {}
101 throw io::NotConnectedException();
110 catch( uno::Exception& )
128 catch( uno::Exception& )
149 throw io::NotConnectedException();
155 throw uno::RuntimeException();
157 uno::Sequence< sal_Int8 >
aBuffer(
static_cast<sal_Int32
>(
nLength) );
161 auto aBufferRange = asNonConstRange(
aBuffer);
165 uno::Sequence< sal_Int8 > aTmpBuf(
static_cast<sal_Int32
>(
nLength) );
168 throw uno::RuntimeException();
170 for ( sal_Int32 nInd = 0; nInd < nRead; nInd++ )
171 aBufferRange[
aBuffer.getLength() -
static_cast<sal_Int32
>(
nLength) + nInd] = aTmpBuf[nInd];
185 throw io::NotConnectedException();
188 throw uno::RuntimeException();
194 for (
const auto & rData : aUsersData)
207 uno::Sequence< sal_Int8 >
aData(
reinterpret_cast<sal_Int8 const *
>(aStringData.getStr()), aStringData.getLength() );
215 std::unique_lock aGuard(
m_aMutex );
218 throw io::NotConnectedException();
224 bool bExists =
false;
225 sal_Int32 nNewInd = 0;
234 aNewData[nNewInd] = aNewEntry;
240 aNewData[nNewInd] = rEntry;
247 aNewData.push_back( aNewEntry );
257 std::unique_lock aGuard(
m_aMutex );
261 throw io::NotConnectedException();
288 std::unique_lock aGuard(
m_aMutex );
291 throw io::NotConnectedException();
295 std::vector< LockFileEntry > aNewData;
303 aNewData.push_back( rEntry );
307 const bool bNewDataEmpty = aNewData.empty();
327 throw io::NotConnectedException();
332 xSimpleFileAccess->kill(
GetURL() );
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 void ParseList(const css::uno::Sequence< sal_Int8 > &aBuffer, std::vector< LockFileEntry > &rOutput)
std::vector< LockFileEntry > GetUsersData()
css::uno::Reference< css::io::XStream > m_xStream
css::uno::Reference< css::io::XSeekable > m_xSeekable
css::uno::Reference< css::io::XOutputStream > m_xOutputStream
css::uno::Reference< css::io::XTruncate > m_xTruncate
LockFileEntry InsertOwnEntry()
std::vector< LockFileEntry > m_aUsersData
void RemoveFileImpl(std::unique_lock< std::mutex > &rGuard)
ShareControlFile(std::u16string_view aOrigURL)
virtual ~ShareControlFile() override
css::uno::Reference< css::io::XInputStream > m_xInputStream
std::vector< LockFileEntry > GetUsersDataImpl(std::unique_lock< std::mutex > &rGuard)
void SetUsersDataAndStore(std::unique_lock< std::mutex > &rGuard, std::vector< LockFileEntry > &&aUserNames)
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::ucb::XContent > get() const
constexpr OUStringLiteral aData
Reference< XComponentContext > getProcessComponentContext()
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::unique_ptr< char[]> aBuffer