LibreOffice Module package (master) 1
switchpersistencestream.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_PACKAGE_SOURCE_XSTOR_SWITCHPERSISTENCESTREAM_HXX
20#define INCLUDED_PACKAGE_SOURCE_XSTOR_SWITCHPERSISTENCESTREAM_HXX
21
22#include <com/sun/star/uno/Sequence.hxx>
23#include <com/sun/star/uno/Reference.hxx>
24#include <com/sun/star/uno/XComponentContext.hpp>
25#include <com/sun/star/io/XInputStream.hpp>
26#include <com/sun/star/io/XOutputStream.hpp>
27#include <com/sun/star/io/XSeekable.hpp>
28#include <com/sun/star/io/XTruncate.hpp>
29#include <com/sun/star/io/XStream.hpp>
30#include <com/sun/star/io/XAsyncOutputMonitor.hpp>
31#include <mutex>
33
34// SwitchablePersistenceStream
35
36// Allows to switch the stream persistence on the fly. The target
37// stream ( if not filled by the implementation ) MUST have the same
38// size as the original one!
39
42 : public ::cppu::WeakImplHelper <
43 css::io::XStream,
44 css::io::XInputStream,
45 css::io::XOutputStream,
46 css::io::XTruncate,
47 css::io::XSeekable,
48 css::io::XAsyncOutputMonitor >
49{
50 std::mutex m_aMutex;
51
52 std::unique_ptr<SPStreamData_Impl> m_pStreamData;
53
54 void CloseAll_Impl();
55
56public:
57
59 const css::uno::Reference< css::io::XStream >& xStream );
60
62 const css::uno::Reference< css::io::XInputStream >& xInStream );
63
64 virtual ~SwitchablePersistenceStream() override;
65
66 void SwitchPersistenceTo( const css::uno::Reference< css::io::XStream >& xStream );
67
68 void SwitchPersistenceTo( const css::uno::Reference< css::io::XInputStream >& xInputStream );
69
70 void CopyAndSwitchPersistenceTo( const css::uno::Reference< css::io::XStream >& xStream );
71
72// css::io::XStream
73 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getInputStream( ) override;
74 virtual css::uno::Reference< css::io::XOutputStream > SAL_CALL getOutputStream( ) override;
75
76// css::io::XInputStream
77 virtual ::sal_Int32 SAL_CALL readBytes( css::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead ) override;
78 virtual ::sal_Int32 SAL_CALL readSomeBytes( css::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead ) override;
79 virtual void SAL_CALL skipBytes( ::sal_Int32 nBytesToSkip ) override;
80 virtual ::sal_Int32 SAL_CALL available( ) override;
81 virtual void SAL_CALL closeInput( ) override;
82
83// css::io::XOutputStream
84 virtual void SAL_CALL writeBytes( const css::uno::Sequence< ::sal_Int8 >& aData ) override;
85 virtual void SAL_CALL flush( ) override;
86 virtual void SAL_CALL closeOutput( ) override;
87
88// css::io::XTruncate
89 virtual void SAL_CALL truncate( ) override;
90
91// css::io::XSeekable
92 virtual void SAL_CALL seek( ::sal_Int64 location ) override;
93 virtual ::sal_Int64 SAL_CALL getPosition( ) override;
94 virtual ::sal_Int64 SAL_CALL getLength( ) override;
95
96// css::io::XAsyncOutputMonitor
97 virtual void SAL_CALL waitForCompletion( ) override;
98
99};
100
101#endif // INCLUDED_PACKAGE_SOURCE_XSTOR_SWITCHPERSISTENCESTREAM_HXX
102
103/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ::sal_Int64 SAL_CALL getPosition() override
virtual void SAL_CALL closeInput() override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getInputStream() override
virtual void SAL_CALL writeBytes(const css::uno::Sequence< ::sal_Int8 > &aData) override
void SwitchPersistenceTo(const css::uno::Reference< css::io::XStream > &xStream)
virtual ::sal_Int32 SAL_CALL readSomeBytes(css::uno::Sequence< ::sal_Int8 > &aData, ::sal_Int32 nMaxBytesToRead) override
virtual ::sal_Int32 SAL_CALL available() override
virtual void SAL_CALL closeOutput() override
virtual void SAL_CALL truncate() override
void CopyAndSwitchPersistenceTo(const css::uno::Reference< css::io::XStream > &xStream)
virtual ::sal_Int64 SAL_CALL getLength() override
virtual void SAL_CALL flush() override
virtual css::uno::Reference< css::io::XOutputStream > SAL_CALL getOutputStream() override
virtual void SAL_CALL waitForCompletion() override
virtual ~SwitchablePersistenceStream() override
virtual void SAL_CALL seek(::sal_Int64 location) override
std::unique_ptr< SPStreamData_Impl > m_pStreamData
virtual ::sal_Int32 SAL_CALL readBytes(css::uno::Sequence< ::sal_Int8 > &aData, ::sal_Int32 nBytesToRead) override
virtual void SAL_CALL skipBytes(::sal_Int32 nBytesToSkip) override
SwitchablePersistenceStream(const css::uno::Reference< css::io::XStream > &xStream)
SwitchablePersistenceStream(const css::uno::Reference< css::io::XInputStream > &xInStream)
void SwitchPersistenceTo(const css::uno::Reference< css::io::XInputStream > &xInputStream)