Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / comphelper / seekableinput.hxx
blob3544f0e6cc83d8f53716a60f4fcada40dbb5e7fe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_COMPHELPER_SEEKABLEINPUT_HXX
20 #define INCLUDED_COMPHELPER_SEEKABLEINPUT_HXX
22 #include <osl/mutex.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/XSeekable.hpp>
27 #include <cppuhelper/implbase.hxx>
28 #include <comphelper/comphelperdllapi.h>
30 namespace comphelper
33 class SAL_DLLPUBLIC_TEMPLATE OSeekableInputWrapper_BASE
34 : public ::cppu::WeakImplHelper< css::io::XInputStream,
35 css::io::XSeekable >
36 {};
38 class COMPHELPER_DLLPUBLIC OSeekableInputWrapper
39 : public OSeekableInputWrapper_BASE
41 ::osl::Mutex m_aMutex;
43 css::uno::Reference< css::uno::XComponentContext > m_xContext;
45 css::uno::Reference< css::io::XInputStream > m_xOriginalStream;
47 css::uno::Reference< css::io::XInputStream > m_xCopyInput;
48 css::uno::Reference< css::io::XSeekable > m_xCopySeek;
50 private:
51 COMPHELPER_DLLPRIVATE void PrepareCopy_Impl();
53 public:
54 OSeekableInputWrapper(
55 const css::uno::Reference< css::io::XInputStream >& xInStream,
56 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
58 virtual ~OSeekableInputWrapper() override;
60 static css::uno::Reference< css::io::XInputStream > CheckSeekableCanWrap(
61 const css::uno::Reference< css::io::XInputStream >& xInStream,
62 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
64 // XInputStream
65 virtual sal_Int32 SAL_CALL readBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) override;
66 virtual sal_Int32 SAL_CALL readSomeBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) override;
67 virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) override;
68 virtual sal_Int32 SAL_CALL available() override;
69 virtual void SAL_CALL closeInput() override;
71 // XSeekable
72 virtual void SAL_CALL seek( sal_Int64 location ) override;
73 virtual sal_Int64 SAL_CALL getPosition() override;
74 virtual sal_Int64 SAL_CALL getLength() override;
78 } // namespace comphelper
80 #endif
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */