LibreOffice Module sc (master) 1
richstring.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
23#include "stylesbuffer.hxx"
24
25class EditTextObject;
26struct ESelection;
28
29namespace com::sun::star {
30 namespace text { class XText; }
31}
32
33namespace oox { class SequenceInputStream; }
34
35namespace oox::xls {
36
39{
40public:
42
44 void setText( const OUString& rText );
46 FontRef const & createFont(const WorkbookHelper& rHelper);
48 void setFontId( sal_Int32 nFontId );
49
51 void finalizeImport(const WorkbookHelper& rHelper);
52
54 const OUString& getText() const { return maText; }
56 bool hasFont() const { return bool(mxFont); }
57
59 void convert(
60 const css::uno::Reference< css::text::XText >& rxText,
61 bool bReplace );
62 void convert( ScEditEngineDefaulter& rEE, ESelection& rSelection, const oox::xls::Font* pFont );
63
65 const css::uno::Reference< css::text::XText >& rxText ) const;
66
67private:
68 OUString maText;
70 sal_Int32 mnFontId;
72};
73
81{
82 sal_Int32 mnPos;
83 sal_Int32 mnFontId;
84
85 explicit FontPortionModel() : mnPos( 0 ), mnFontId( -1 ) {}
86 explicit FontPortionModel( sal_Int32 nPos ) : mnPos( nPos ), mnFontId( -1 ) {}
87
88 void read( SequenceInputStream& rStrm );
89};
90
93 ::std::vector< FontPortionModel > mvModels;
94
95public:
97
98 bool empty() const { return mvModels.empty(); }
99
100 const FontPortionModel& back() const { return mvModels.back(); }
101 const FontPortionModel& front() const { return mvModels.front(); }
102
103 void push_back(const FontPortionModel& rModel) { mvModels.push_back(rModel); }
104
105 void insert(::std::vector< FontPortionModel >::iterator it,
106 const FontPortionModel& rModel)
107 { mvModels.insert(it, rModel); }
108
109 ::std::vector< FontPortionModel >::iterator begin() { return mvModels.begin(); }
110
112 void appendPortion( const FontPortionModel& rPortion );
114 void importPortions( SequenceInputStream& rStrm );
115};
116
118{
119 sal_Int32 mnFontId;
120 sal_Int32 mnType;
121 sal_Int32 mnAlignment;
122
123 explicit PhoneticDataModel();
124
126 void setBiffData( sal_Int32 nType, sal_Int32 nAlignment );
127};
128
130{
131public:
132 explicit PhoneticSettings( const WorkbookHelper& rHelper );
133
135 void importPhoneticPr( const AttributeList& rAttribs );
138
141
142private:
144};
145
148{
149public:
151
153 void setText( const OUString& rText );
155 void importPhoneticRun( const AttributeList& rAttribs );
157 void setBaseRange( sal_Int32 nBasePos, sal_Int32 nBaseEnd );
158
159private:
160 OUString maText;
161 sal_Int32 mnBasePos;
162 sal_Int32 mnBaseEnd;
163};
164
165typedef std::shared_ptr< RichStringPhonetic > RichStringPhoneticRef;
166
170{
171 sal_Int32 mnPos;
172 sal_Int32 mnBasePos;
173 sal_Int32 mnBaseLen;
174
175 explicit PhoneticPortionModel() : mnPos( -1 ), mnBasePos( -1 ), mnBaseLen( 0 ) {}
176 explicit PhoneticPortionModel( sal_Int32 nPos, sal_Int32 nBasePos, sal_Int32 nBaseLen ) :
177 mnPos( nPos ), mnBasePos( nBasePos ), mnBaseLen( nBaseLen ) {}
178
179 void read( SequenceInputStream& rStrm );
180};
181
184{
185public:
187
188 bool empty() const { return mvModels.empty(); }
189
190 const PhoneticPortionModel& back() const { return mvModels.back(); }
191
192 void push_back(const PhoneticPortionModel& rModel) { mvModels.push_back(rModel); }
193
194 ::std::vector< PhoneticPortionModel >::const_iterator begin() const { return mvModels.begin(); }
195
197 void appendPortion( const PhoneticPortionModel& rPortion );
199 void importPortions( SequenceInputStream& rStrm );
200
201private:
202 ::std::vector< PhoneticPortionModel > mvModels;
203};
204
207{
208public:
209
211 sal_Int32 importText(const AttributeList& rAttribs);
213 sal_Int32 importRun();
217 void importPhoneticPr( const AttributeList& rAttribs, const WorkbookHelper& rHelper );
218
220 void importString( SequenceInputStream& rStrm, bool bRich, const WorkbookHelper& rHelper );
221
223 void finalizeImport(const WorkbookHelper& rHelper);
224
228 OUString& orString,
229 const oox::xls::Font* pFirstPortionFont ) const;
230
234 void convert( const css::uno::Reference< css::text::XText >& rxText );
235 std::unique_ptr<EditTextObject> convert( ScEditEngineDefaulter& rEE, const oox::xls::Font* pFont );
236
237 RichStringPortion& getPortion(sal_Int32 nPortionIdx) { return maTextPortions[nPortionIdx]; }
238
239 void setAttributes(const AttributeList& rAttribs);
240
241 bool isPreserveSpace() const { return mbPreserveSpace; }
242
243private:
245 sal_Int32 createPortion();
248
250 void createTextPortions( std::u16string_view aText, FontPortionModelList& rPortions );
252 void createPhoneticPortions( std::u16string_view aText, PhoneticPortionModelList& rPortions, sal_Int32 nBaseLen );
253
254private:
256
257 std::vector<RichStringPortion> maTextPortions;
258 std::unique_ptr<PhoneticSettings> mxPhonSettings;
260 bool mbPreserveSpace = false;
261};
262
263typedef std::shared_ptr< RichString > RichStringRef;
264
265} // namespace oox::xls
266
267/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
A vector with all font portions in a rich-string.
Definition: richstring.hxx:92
void push_back(const FontPortionModel &rModel)
Definition: richstring.hxx:103
::std::vector< FontPortionModel > mvModels
Definition: richstring.hxx:93
void insert(::std::vector< FontPortionModel >::iterator it, const FontPortionModel &rModel)
Definition: richstring.hxx:105
::std::vector< FontPortionModel >::iterator begin()
Definition: richstring.hxx:109
void importPortions(SequenceInputStream &rStrm)
Reads count and font identifiers from the passed stream.
Definition: richstring.cxx:168
const FontPortionModel & front() const
Definition: richstring.hxx:101
const FontPortionModel & back() const
Definition: richstring.hxx:100
void appendPortion(const FontPortionModel &rPortion)
Appends a rich-string font identifier.
Definition: richstring.cxx:158
A vector with all phonetic portions in a rich-string.
Definition: richstring.hxx:184
::std::vector< PhoneticPortionModel > mvModels
Definition: richstring.hxx:202
void importPortions(SequenceInputStream &rStrm)
Reads all phonetic portions from the passed stream.
Definition: richstring.cxx:281
void push_back(const PhoneticPortionModel &rModel)
Definition: richstring.hxx:192
::std::vector< PhoneticPortionModel >::const_iterator begin() const
Definition: richstring.hxx:194
const PhoneticPortionModel & back() const
Definition: richstring.hxx:190
void appendPortion(const PhoneticPortionModel &rPortion)
Appends a rich-string phonetic portion.
Definition: richstring.cxx:264
void importStringData(SequenceInputStream &rStrm)
Imports phonetic settings from a rich string.
Definition: richstring.cxx:225
PhoneticSettings(const WorkbookHelper &rHelper)
Definition: richstring.cxx:202
void importPhoneticPr(const AttributeList &rAttribs)
Imports phonetic settings from the phoneticPr element.
Definition: richstring.cxx:207
PhoneticDataModel maModel
Definition: richstring.hxx:143
Contains text data and positioning information for a phonetic text portion.
Definition: richstring.hxx:148
void setBaseRange(sal_Int32 nBasePos, sal_Int32 nBaseEnd)
Sets the associated range in base text for this phonetic portion.
Definition: richstring.cxx:251
void importPhoneticRun(const AttributeList &rAttribs)
Imports attributes of a phonetic run (rPh element).
Definition: richstring.cxx:245
void setText(const OUString &rText)
Sets text data for this phonetic portion.
Definition: richstring.cxx:240
sal_Int32 mnBaseEnd
Start position in base text.
Definition: richstring.hxx:162
sal_Int32 mnBasePos
Portion text.
Definition: richstring.hxx:161
Contains text data and font attributes for a part of a rich formatted string.
Definition: richstring.hxx:39
bool hasFont() const
Returns true, if the portion contains font formatting.
Definition: richstring.hxx:56
FontRef mxFont
Portion text.
Definition: richstring.hxx:69
void convert(const css::uno::Reference< css::text::XText > &rxText, bool bReplace)
Converts the portion and replaces or appends to the passed XText.
void writeFontProperties(const css::uno::Reference< css::text::XText > &rxText) const
Definition: richstring.cxx:144
bool mbConverted
Link to global font list.
Definition: richstring.hxx:71
FontRef const & createFont(const WorkbookHelper &rHelper)
Creates and returns a new font formatting object.
Definition: richstring.cxx:65
const OUString & getText() const
Returns the text data of this portion.
Definition: richstring.hxx:54
void setFontId(sal_Int32 nFontId)
Links this portion to a font object from the global font list.
Definition: richstring.cxx:71
void finalizeImport(const WorkbookHelper &rHelper)
Final processing after import of all strings.
Definition: richstring.cxx:76
sal_Int32 mnFontId
Embedded portion font, may be empty.
Definition: richstring.hxx:70
void setText(const OUString &rText)
Sets text data for this portion.
Definition: richstring.cxx:60
Contains string data and a list of formatting runs for a rich formatted string.
Definition: richstring.hxx:207
void finalizeImport(const WorkbookHelper &rHelper)
Final processing after import of all strings.
Definition: richstring.cxx:358
RefVector< RichStringPhonetic > PhoneticVector
Definition: richstring.hxx:255
void createPhoneticPortions(std::u16string_view aText, PhoneticPortionModelList &rPortions, sal_Int32 nBaseLen)
Create phonetic text portions from the passed string and portion data.
Definition: richstring.cxx:464
void importString(SequenceInputStream &rStrm, bool bRich, const WorkbookHelper &rHelper)
Imports a Unicode rich-string from the passed record stream.
Definition: richstring.cxx:330
void importPhoneticPr(const AttributeList &rAttribs, const WorkbookHelper &rHelper)
Imports phonetic settings from the rPhoneticPr element.
Definition: richstring.cxx:323
std::unique_ptr< PhoneticSettings > mxPhonSettings
String portions with font data.
Definition: richstring.hxx:258
std::vector< RichStringPortion > maTextPortions
Definition: richstring.hxx:257
PhoneticVector maPhonPortions
Phonetic settings for this string.
Definition: richstring.hxx:259
bool extractPlainString(OUString &orString, const oox::xls::Font *pFirstPortionFont) const
Tries to extract a plain string from this object.
Definition: richstring.cxx:364
bool mbPreserveSpace
Phonetic text portions.
Definition: richstring.hxx:260
sal_Int32 createPortion()
Creates, appends, and returns a new empty string portion.
Definition: richstring.cxx:425
void convert(const css::uno::Reference< css::text::XText > &rxText)
Converts the string and writes it into the passed XText, replace old contents of the text object,...
void setAttributes(const AttributeList &rAttribs)
Definition: richstring.cxx:309
RichStringPhoneticRef importPhoneticRun(const AttributeList &rAttribs)
Appends and returns a phonetic text object for a new phonetic run (rPh element).
Definition: richstring.cxx:316
RichStringPortion & getPortion(sal_Int32 nPortionIdx)
Definition: richstring.hxx:237
sal_Int32 importText(const AttributeList &rAttribs)
Appends and returns an index of a portion object for a plain string (t element).
Definition: richstring.cxx:297
bool isPreserveSpace() const
Definition: richstring.hxx:241
RichStringPhoneticRef createPhonetic()
Creates, appends, and returns a new empty phonetic text portion.
Definition: richstring.cxx:431
sal_Int32 importRun()
Appends and returns an index of a portion object for a new formatting run (r element).
Definition: richstring.cxx:304
void createTextPortions(std::u16string_view aText, FontPortionModelList &rPortions)
Create base text portions from the passed string and character formatting.
Definition: richstring.cxx:438
Helper class to provide access to global workbook data.
sal_uInt16 nPos
def text(shape, orig_st)
void SvStream & rStrm
std::shared_ptr< RichStringPhonetic > RichStringPhoneticRef
Definition: richstring.hxx:165
std::shared_ptr< Font > FontRef
std::shared_ptr< RichString > RichStringRef
Definition: richstring.hxx:263
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
Represents a position in a rich-string containing current font identifier.
Definition: richstring.hxx:81
FontPortionModel(sal_Int32 nPos)
Definition: richstring.hxx:86
FontPortionModel()
Font identifier for the next characters.
Definition: richstring.hxx:85
sal_Int32 mnFontId
First character in the string.
Definition: richstring.hxx:83
void read(SequenceInputStream &rStrm)
Definition: richstring.cxx:152
sal_Int32 mnType
Font identifier for text formatting.
Definition: richstring.hxx:120
sal_Int32 mnAlignment
Phonetic text type.
Definition: richstring.hxx:121
PhoneticDataModel()
Phonetic portion alignment.
Definition: richstring.cxx:186
void setBiffData(sal_Int32 nType, sal_Int32 nAlignment)
Sets the passed data from binary import.
Definition: richstring.cxx:193
Represents a phonetic text portion in a rich-string with phonetic text.
Definition: richstring.hxx:170
PhoneticPortionModel(sal_Int32 nPos, sal_Int32 nBasePos, sal_Int32 nBaseLen)
Definition: richstring.hxx:176
void read(SequenceInputStream &rStrm)
Definition: richstring.cxx:257
sal_Int32 mnBasePos
First character in phonetic text.
Definition: richstring.hxx:172
PhoneticPortionModel()
Number of characters in base text.
Definition: richstring.hxx:175
sal_Int32 mnBaseLen
First character in base text.
Definition: richstring.hxx:173