fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / inc / xistring.hxx
blob9d95b3bf97d031fa168fe1ce63e41174d57c3814
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_SC_SOURCE_FILTER_INC_XISTRING_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XISTRING_HXX
23 #include "xlstring.hxx"
25 // Byte/Unicode strings =======================================================
27 class XclImpStream;
29 /** This class represents an unformatted or formatted string and provides importing from stream. */
30 class XclImpString
32 public:
33 /** Constructs an empty string. */
34 explicit XclImpString();
35 /** Constructs an unformatted string. */
36 explicit XclImpString( const OUString& rString );
38 ~XclImpString();
40 /** Reads a complete string from the passed stream. */
41 void Read( XclImpStream& rStrm, XclStrFlags nFlags = EXC_STR_DEFAULT );
43 /** Sets the passed string data. */
44 inline void SetText( const OUString& rText ) { maString = rText; }
45 /** Sets the passed formatting buffer. */
46 inline void SetFormats( const XclFormatRunVec& rFormats ) { maFormats = rFormats; }
47 /** Insert a formatting run to the format buffer. */
48 inline void AppendFormat( sal_uInt16 nChar, sal_uInt16 nFontIdx ) { AppendFormat( maFormats, nChar, nFontIdx ); }
49 /** Reads and appends the formatting information (run count and runs) from stream. */
50 inline void ReadFormats( XclImpStream& rStrm ) { ReadFormats( rStrm, maFormats ); }
51 /** Reads and appends nRunCount formatting runs from stream. */
52 inline void ReadFormats( XclImpStream& rStrm, sal_uInt16 nRunCount ) { ReadFormats( rStrm, maFormats, nRunCount ); }
53 /** Reads and appends formatting runs from an OBJ or TXO record. */
54 inline void ReadObjFormats( XclImpStream& rStrm, sal_uInt16 nFormatSize ) { ReadObjFormats( rStrm, maFormats, nFormatSize ); }
56 /** Returns true, if the string is empty. */
57 inline bool IsEmpty() const { return maString.isEmpty(); }
58 /** Returns the pure text data of the string. */
59 inline const OUString& GetText() const { return maString; }
61 /** Returns true, if the string contains formatting information. */
62 inline bool IsRich() const { return !maFormats.empty(); }
63 /** Returns the formatting run vector. */
64 inline const XclFormatRunVec& GetFormats() const { return maFormats; }
66 /** Insert a formatting run to the passed format buffer. */
67 static void AppendFormat( XclFormatRunVec& rFormats, sal_uInt16 nChar, sal_uInt16 nFontIdx );
68 /** Reads and appends the formatting information (run count and runs) from stream. */
69 static void ReadFormats( XclImpStream& rStrm, XclFormatRunVec& rFormats );
70 /** Reads and appends nRunCount formatting runs from stream. */
71 static void ReadFormats( XclImpStream& rStrm, XclFormatRunVec& rFormats, sal_uInt16 nRunCount );
72 /** Reads and appends formatting runs from an OBJ or TXO record. */
73 static void ReadObjFormats( XclImpStream& rStrm, XclFormatRunVec& rFormats, sal_uInt16 nFormatSize );
75 private:
76 OUString maString; /// The text data of the string.
77 XclFormatRunVec maFormats; /// All formatting runs.
80 // String iterator ============================================================
82 /** Iterates over formatted string portions. */
83 class XclImpStringIterator
85 public:
86 explicit XclImpStringIterator( const XclImpString& rString );
88 /** Returns true, if the iterator references a valid text portion. */
89 inline bool Is() const { return mnTextBeg < mrText.getLength(); }
90 /** Returns the index of the current text portion. */
91 inline size_t GetPortionIndex() const { return mnPortion; }
92 /** Returns the string of the current text portion. */
93 OUString GetPortionText() const;
94 /** Returns the font index of the current text portion. */
95 sal_uInt16 GetPortionFont() const;
97 /** Moves iterator to next text portion. */
98 XclImpStringIterator& operator++();
100 private:
101 const OUString& mrText; /// The processed string.
102 const XclFormatRunVec& mrFormats; /// The vector of formatting runs.
103 size_t mnPortion; /// Current text portion.
104 sal_Int32 mnTextBeg; /// First character of current portion.
105 sal_Int32 mnTextEnd; /// First character of next portion.
106 size_t mnFormatsBeg; /// Formatting run index for current portion.
107 size_t mnFormatsEnd; /// Formatting run index for next portion.
110 #endif
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */