LibreOffice Module sc (master)  1
xistring.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XISTRING_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XISTRING_HXX
22 
23 #include <rtl/ustring.hxx>
24 #include "xlstring.hxx"
25 
26 // Byte/Unicode strings =======================================================
27 
28 class XclImpStream;
29 
32 {
33 public:
35  explicit XclImpString();
37  explicit XclImpString( const OUString& rString );
38 
41 
43  void SetText( const OUString& rText ) { maString = rText; }
45  void SetFormats( const XclFormatRunVec& rFormats ) { maFormats = rFormats; }
47  void ReadFormats( XclImpStream& rStrm ) { ReadFormats( rStrm, maFormats ); }
49  void ReadObjFormats( XclImpStream& rStrm, sal_uInt16 nFormatSize ) { ReadObjFormats( rStrm, maFormats, nFormatSize ); }
50 
52  bool IsEmpty() const { return maString.isEmpty(); }
54  const OUString& GetText() const { return maString; }
55 
57  bool IsRich() const { return !maFormats.empty(); }
59  const XclFormatRunVec& GetFormats() const { return maFormats; }
60 
62  static void AppendFormat( XclFormatRunVec& rFormats, sal_uInt16 nChar, sal_uInt16 nFontIdx );
64  static void ReadFormats( XclImpStream& rStrm, XclFormatRunVec& rFormats );
66  static void ReadFormats( XclImpStream& rStrm, XclFormatRunVec& rFormats, sal_uInt16 nRunCount );
68  static void ReadObjFormats( XclImpStream& rStrm, XclFormatRunVec& rFormats, sal_uInt16 nFormatSize );
69 
70 private:
71  OUString maString;
73 };
74 
75 // String iterator ============================================================
76 
79 {
80 public:
81  explicit XclImpStringIterator( const XclImpString& rString );
82 
84  bool Is() const { return mnTextBeg < mrText.getLength(); }
86  size_t GetPortionIndex() const { return mnPortion; }
88  OUString GetPortionText() const;
90  sal_uInt16 GetPortionFont() const;
91 
94 
95 private:
96  const OUString& mrText;
98  size_t mnPortion;
99  sal_Int32 mnTextBeg;
100  sal_Int32 mnTextEnd;
101  size_t mnFormatsBeg;
102  size_t mnFormatsEnd;
103 };
104 
105 #endif
106 
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ReadFormats(XclImpStream &rStrm)
Reads and appends the formatting information (run count and runs) from stream.
Definition: xistring.hxx:47
sal_Int32 mnTextEnd
First character of current portion.
Definition: xistring.hxx:100
XclStrFlags
Flags used to specify import/export mode of strings.
Definition: xlstring.hxx:29
sal_uInt16 GetPortionFont() const
Returns the font index of the current text portion.
Definition: xistring.cxx:185
void Read(XclImpStream &rStrm, XclStrFlags nFlags=XclStrFlags::NONE)
Reads a complete string from the passed stream.
Definition: xistring.cxx:41
OUString GetPortionText() const
Returns the string of the current text portion.
Definition: xistring.cxx:180
const XclFormatRunVec & GetFormats() const
Returns the formatting run vector.
Definition: xistring.hxx:59
bool IsRich() const
Returns true, if the string contains formatting information.
Definition: xistring.hxx:57
void SetFormats(const XclFormatRunVec &rFormats)
Sets the passed formatting buffer.
Definition: xistring.hxx:45
::std::vector< XclFormatRun > XclFormatRunVec
A vector with all formatting runs for a rich-string.
Definition: xlstring.hxx:85
size_t GetPortionIndex() const
Returns the index of the current text portion.
Definition: xistring.hxx:86
OUString maString
Definition: xistring.hxx:71
void ReadObjFormats(XclImpStream &rStrm, sal_uInt16 nFormatSize)
Reads and appends formatting runs from an OBJ or TXO record.
Definition: xistring.hxx:49
bool Is() const
Returns true, if the iterator references a valid text portion.
Definition: xistring.hxx:84
size_t mnFormatsBeg
First character of next portion.
Definition: xistring.hxx:101
Iterates over formatted string portions.
Definition: xistring.hxx:78
const XclFormatRunVec & mrFormats
The processed string.
Definition: xistring.hxx:97
XclFormatRunVec maFormats
The text data of the string.
Definition: xistring.hxx:72
static void AppendFormat(XclFormatRunVec &rFormats, sal_uInt16 nChar, sal_uInt16 nFontIdx)
Insert a formatting run to the passed format buffer.
Definition: xistring.cxx:92
XclImpString()
Constructs an empty string.
Definition: xistring.cxx:32
XclImpStringIterator(const XclImpString &rString)
Definition: xistring.cxx:163
const OUString & GetText() const
Returns the pure text data of the string.
Definition: xistring.hxx:54
XclImpStringIterator & operator++()
Moves iterator to next text portion.
Definition: xistring.cxx:190
const OUString & mrText
Definition: xistring.hxx:96
bool IsEmpty() const
Returns true, if the string is empty.
Definition: xistring.hxx:52
sal_Int32 mnTextBeg
Current text portion.
Definition: xistring.hxx:99
void SetText(const OUString &rText)
Sets the passed string data.
Definition: xistring.hxx:43
size_t mnFormatsEnd
Formatting run index for current portion.
Definition: xistring.hxx:102
This class is used to import record oriented streams.
Definition: xistream.hxx:278
void SvStream & rStrm
This class represents an unformatted or formatted string and provides importing from stream...
Definition: xistring.hxx:31
size_t mnPortion
The vector of formatting runs.
Definition: xistring.hxx:98