1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_PACKAGE_SOURCE_XSTOR_SWITCHPERSISTENCESTREAM_HXX
20 #define INCLUDED_PACKAGE_SOURCE_XSTOR_SWITCHPERSISTENCESTREAM_HXX
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>
32 #include <cppuhelper/implbase.hxx>
34 // SwitchablePersistenceStream
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!
40 struct SPStreamData_Impl
;
41 class SwitchablePersistenceStream
42 : public ::cppu::WeakImplHelper
<
44 css::io::XInputStream
,
45 css::io::XOutputStream
,
48 css::io::XAsyncOutputMonitor
>
52 std::unique_ptr
<SPStreamData_Impl
> m_pStreamData
;
58 SwitchablePersistenceStream(
59 const css::uno::Reference
< css::io::XStream
>& xStream
);
61 SwitchablePersistenceStream(
62 const css::uno::Reference
< css::io::XInputStream
>& xInStream
);
64 virtual ~SwitchablePersistenceStream() override
;
66 void SwitchPersistenceTo( const css::uno::Reference
< css::io::XStream
>& xStream
);
68 void SwitchPersistenceTo( const css::uno::Reference
< css::io::XInputStream
>& xInputStream
);
70 void CopyAndSwitchPersistenceTo( const css::uno::Reference
< css::io::XStream
>& 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
;
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
;
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
;
89 virtual void SAL_CALL
truncate( ) override
;
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
;
96 // css::io::XAsyncOutputMonitor
97 virtual void SAL_CALL
waitForCompletion( ) override
;
101 #endif // INCLUDED_PACKAGE_SOURCE_XSTOR_SWITCHPERSISTENCESTREAM_HXX
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */