Use COMReference to handle COM pointers in CreateShortcut
[LibreOffice.git] / include / oox / helper / textinputstream.hxx
blob4a5bcdbfe9944edc7e2753bde9075fb6e559c30f
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 .
20 #ifndef INCLUDED_OOX_HELPER_TEXTINPUTSTREAM_HXX
21 #define INCLUDED_OOX_HELPER_TEXTINPUTSTREAM_HXX
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <rtl/textenc.h>
25 #include <rtl/ustring.hxx>
26 #include <sal/types.h>
28 namespace com::sun::star {
29 namespace io { class XInputStream; }
30 namespace io { class XTextInputStream2; }
31 namespace uno { class XComponentContext; }
34 namespace oox {
36 class BinaryInputStream;
39 class TextInputStream
41 public:
42 explicit TextInputStream(
43 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
44 const css::uno::Reference< css::io::XInputStream >& rxInStrm,
45 rtl_TextEncoding eTextEnc );
47 explicit TextInputStream(
48 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
49 BinaryInputStream& rInStrm,
50 rtl_TextEncoding eTextEnc );
52 ~TextInputStream();
54 /** Returns true, if no more text is available in the stream.
56 bool isEof() const;
58 /** Reads a text line from the stream.
60 If the last line in the stream is not terminated with line-end
61 character(s), the stream will immediately go into EOF state and return
62 the text line. Otherwise, if the last character in the stream is a
63 line-end character, the next call to this function will turn the stream
64 into EOF state and return an empty string.
66 OUString readLine();
68 /** Reads a text portion from the stream until the specified character is
69 found.
71 If the end of the stream is not terminated with the specified
72 character, the stream will immediately go into EOF state and return the
73 remaining text portion. Otherwise, if the last character in the stream
74 is the specified character (and caller specifies to read and return it,
75 see parameter bIncludeChar), the next call to this function will turn
76 the stream into EOF state and return an empty string.
78 @param cChar
79 The separator character to be read to.
81 @param bIncludeChar
82 True = if found, the specified character will be read from stream
83 and included in the returned string.
84 False = the specified character will neither be read from the
85 stream nor included in the returned string, but will be
86 returned as first character in the next call of this function
87 or readLine().
89 OUString readToChar( sal_Unicode cChar, bool bIncludeChar );
92 /** Creates a UNO text input stream object from the passed UNO input stream.
94 static css::uno::Reference< css::io::XTextInputStream2 >
95 createXTextInputStream(
96 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
97 const css::uno::Reference< css::io::XInputStream >& rxInStrm,
98 rtl_TextEncoding eTextEnc );
101 private:
102 void init(
103 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
104 const css::uno::Reference< css::io::XInputStream >& rxInStrm,
105 rtl_TextEncoding eTextEnc );
107 /** Adds the pending character in front of the passed string, if existing. */
108 OUString createFinalString( const OUString& rString );
110 private:
111 css::uno::Reference< css::io::XTextInputStream2 >
112 mxTextStrm;
113 sal_Unicode mcPendingChar;
117 } // namespace oox
119 #endif
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */