update credits
[LibreOffice.git] / include / oox / helper / textinputstream.hxx
blob16a2d5145e9d7a81d1e43b3b1b53315a5fd4cfc4
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 OOX_HELPER_TEXTINPUTSTREAM_HXX
21 #define OOX_HELPER_TEXTINPUTSTREAM_HXX
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <rtl/ustring.hxx>
26 namespace com { namespace sun { namespace star {
27 namespace io { class XInputStream; }
28 namespace io { class XTextInputStream2; }
29 namespace uno { class XComponentContext; }
30 } } }
32 namespace oox {
34 class BinaryInputStream;
36 // ============================================================================
38 class TextInputStream
40 public:
41 explicit TextInputStream(
42 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
43 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm,
44 rtl_TextEncoding eTextEnc );
46 explicit TextInputStream(
47 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
48 BinaryInputStream& rInStrm,
49 rtl_TextEncoding eTextEnc );
51 ~TextInputStream();
53 /** Returns true, if no more text is available in the stream.
55 bool isEof() const;
57 /** Reads a text line from the stream.
59 If the last line in the stream is not terminated with line-end
60 character(s), the stream will immediately go into EOF state and return
61 the text line. Otherwise, if the last character in the stream is a
62 line-end character, the next call to this function will turn the stream
63 into EOF state and return an empty string.
65 OUString readLine();
67 /** Reads a text portion from the stream until the specified character is
68 found.
70 If the end of the stream is not terminated with the specified
71 character, the stream will immediately go into EOF state and return the
72 remaining text portion. Otherwise, if the last character in the stream
73 is the specified character (and caller specifies to read and return it,
74 see parameter bIncludeChar), the next call to this function will turn
75 the stream into EOF state and return an empty string.
77 @param cChar
78 The separator character to be read to.
80 @param bIncludeChar
81 True = if found, the specified character will be read from stream
82 and included in the returned string.
83 False = the specified character will neither be read from the
84 stream nor included in the returned string, but will be
85 returned as first character in the next call of this function
86 or readLine().
88 OUString readToChar( sal_Unicode cChar, bool bIncludeChar );
90 // ------------------------------------------------------------------------
92 /** Creates a UNO text input stream object from the passed UNO input stream.
94 static ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream2 >
95 createXTextInputStream(
96 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
97 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm,
98 rtl_TextEncoding eTextEnc );
100 // ------------------------------------------------------------------------
101 private:
102 void init(
103 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
104 const ::com::sun::star::uno::Reference< ::com::sun::star::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 ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream2 >
112 mxTextStrm;
113 sal_Unicode mcPendingChar;
116 // ============================================================================
118 } // namespace oox
120 #endif
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */