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#pragma once
21
22#include <rtl/ustring.hxx>
23#include "xlstring.hxx"
24
25// Byte/Unicode strings =======================================================
26
27class XclImpStream;
28
31{
32public:
34 explicit XclImpString();
36 explicit XclImpString( OUString aString );
37
40
42 void SetText( const OUString& rText ) { maString = rText; }
44 void SetFormats( XclFormatRunVec&& rFormats ) { maFormats = std::move(rFormats); }
48 void ReadObjFormats( XclImpStream& rStrm, sal_uInt16 nFormatSize ) { ReadObjFormats( rStrm, maFormats, nFormatSize ); }
49
51 bool IsEmpty() const { return maString.isEmpty(); }
53 const OUString& GetText() const { return maString; }
54
56 bool IsRich() const { return !maFormats.empty(); }
58 const XclFormatRunVec& GetFormats() const { return maFormats; }
59
61 static void AppendFormat( XclFormatRunVec& rFormats, sal_uInt16 nChar, sal_uInt16 nFontIdx );
63 static void ReadFormats( XclImpStream& rStrm, XclFormatRunVec& rFormats );
65 static void ReadFormats( XclImpStream& rStrm, XclFormatRunVec& rFormats, sal_uInt16 nRunCount );
67 static void ReadObjFormats( XclImpStream& rStrm, XclFormatRunVec& rFormats, sal_uInt16 nFormatSize );
68
69private:
70 OUString maString;
72};
73
74// String iterator ============================================================
75
78{
79public:
80 explicit XclImpStringIterator( const XclImpString& rString );
81
83 bool Is() const { return mnTextBeg < mrText.getLength(); }
85 size_t GetPortionIndex() const { return mnPortion; }
87 OUString GetPortionText() const;
89 sal_uInt16 GetPortionFont() const;
90
93
94private:
95 const OUString& mrText;
97 size_t mnPortion;
98 sal_Int32 mnTextBeg;
99 sal_Int32 mnTextEnd;
102};
103
104/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class is used to import record oriented streams.
Definition: xistream.hxx:278
Iterates over formatted string portions.
Definition: xistring.hxx:78
XclImpStringIterator & operator++()
Moves iterator to next text portion.
Definition: xistring.cxx:191
XclImpStringIterator(const XclImpString &rString)
Definition: xistring.cxx:164
size_t mnFormatsBeg
First character of next portion.
Definition: xistring.hxx:100
sal_Int32 mnTextBeg
Current text portion.
Definition: xistring.hxx:98
sal_uInt16 GetPortionFont() const
Returns the font index of the current text portion.
Definition: xistring.cxx:186
const XclFormatRunVec & mrFormats
The processed string.
Definition: xistring.hxx:96
size_t GetPortionIndex() const
Returns the index of the current text portion.
Definition: xistring.hxx:85
size_t mnFormatsEnd
Formatting run index for current portion.
Definition: xistring.hxx:101
size_t mnPortion
The vector of formatting runs.
Definition: xistring.hxx:97
OUString GetPortionText() const
Returns the string of the current text portion.
Definition: xistring.cxx:181
sal_Int32 mnTextEnd
First character of current portion.
Definition: xistring.hxx:99
bool Is() const
Returns true, if the iterator references a valid text portion.
Definition: xistring.hxx:83
const OUString & mrText
Definition: xistring.hxx:95
This class represents an unformatted or formatted string and provides importing from stream.
Definition: xistring.hxx:31
void SetFormats(XclFormatRunVec &&rFormats)
Sets the passed formatting buffer.
Definition: xistring.hxx:44
void ReadObjFormats(XclImpStream &rStrm, sal_uInt16 nFormatSize)
Reads and appends formatting runs from an OBJ or TXO record.
Definition: xistring.hxx:48
bool IsEmpty() const
Returns true, if the string is empty.
Definition: xistring.hxx:51
bool IsRich() const
Returns true, if the string contains formatting information.
Definition: xistring.hxx:56
XclFormatRunVec maFormats
The text data of the string.
Definition: xistring.hxx:71
XclImpString()
Constructs an empty string.
Definition: xistring.cxx:33
void Read(XclImpStream &rStrm, XclStrFlags nFlags=XclStrFlags::NONE)
Reads a complete string from the passed stream.
Definition: xistring.cxx:42
const XclFormatRunVec & GetFormats() const
Returns the formatting run vector.
Definition: xistring.hxx:58
OUString maString
Definition: xistring.hxx:70
static void AppendFormat(XclFormatRunVec &rFormats, sal_uInt16 nChar, sal_uInt16 nFontIdx)
Insert a formatting run to the passed format buffer.
Definition: xistring.cxx:93
void ReadFormats(XclImpStream &rStrm)
Reads and appends the formatting information (run count and runs) from stream.
Definition: xistring.hxx:46
void SetText(const OUString &rText)
Sets the passed string data.
Definition: xistring.hxx:42
const OUString & GetText() const
Returns the pure text data of the string.
Definition: xistring.hxx:53
void SvStream & rStrm
::std::vector< XclFormatRun > XclFormatRunVec
A vector with all formatting runs for a rich-string.
Definition: xlstring.hxx:85
XclStrFlags
Flags used to specify import/export mode of strings.
Definition: xlstring.hxx:29