LibreOffice Module sc (master) 1
richstring.cxx
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#include <richstring.hxx>
21#include <biffhelper.hxx>
22
23#include <com/sun/star/beans/XPropertySet.hpp>
24#include <com/sun/star/text/XText.hpp>
25#include <rtl/ustrbuf.hxx>
26#include <editeng/editobj.hxx>
27#include <osl/diagnose.h>
31#include <oox/token/tokens.hxx>
32#include <editutil.hxx>
33
34#include <vcl/svapp.hxx>
35
36namespace oox::xls {
37
38using namespace ::com::sun::star::text;
39using namespace ::com::sun::star::uno;
40
41namespace {
42
43const sal_uInt8 BIFF12_STRINGFLAG_FONTS = 0x01;
44const sal_uInt8 BIFF12_STRINGFLAG_PHONETICS = 0x02;
45
46bool lclNeedsRichTextFormat( const oox::xls::Font* pFont )
47{
48 return pFont && pFont->needsRichTextFormat();
49}
50
51sal_Int32 lcl_getHexLetterValue(sal_Unicode nCode)
52{
53 if (nCode >= '0' && nCode <= '9')
54 return nCode - '0';
55
56 if (nCode >= 'A' && nCode <= 'F')
57 return nCode - 'A' + 10;
58
59 if (nCode >= 'a' && nCode <= 'f')
60 return nCode - 'a' + 10;
61
62 return -1;
63}
64
65bool lcl_validEscape(sal_Unicode nCode)
66{
67 // Valid XML chars that can be escaped (ignoring the restrictions) as in the OOX open spec
68 // 2.1.1742 Part 1 Section 22.9.2.19, ST_Xstring (Escaped String)
69 if (nCode == 0x000D || nCode == 0x000A || nCode == 0x0009 || nCode == 0x005F)
70 return true;
71
72 // Other valid XML chars in basic multilingual plane that cannot be escaped.
73 if ((nCode >= 0x0020 && nCode <= 0xD7FF) || (nCode >= 0xE000 && nCode <= 0xFFFD))
74 return false;
75
76 return true;
77}
78
79OUString lcl_unEscapeUnicodeChars(const OUString& rSrc)
80{
81 // Example: Escaped representation of unicode char 0x000D is _x000D_
82
83 sal_Int32 nLen = rSrc.getLength();
84 if (!nLen)
85 return rSrc;
86
87 sal_Int32 nStart = 0;
88 bool bFound = false;
89 const OUString aPrefix = "_x";
90 sal_Int32 nPrefixStart = rSrc.indexOf(aPrefix, nStart);
91
92 if (nPrefixStart == -1)
93 return rSrc;
94
95 OUStringBuffer aBuf(rSrc);
96 sal_Int32 nOffset = 0; // index offset in aBuf w.r.t rSrc.
97
98 do
99 {
100 sal_Int32 nEnd = -1;
101 sal_Unicode nCode = 0;
102 bool bFoundThis = false;
103 for (sal_Int32 nIdx = 0; nIdx < 5; ++nIdx)
104 {
105 sal_Int32 nThisIdx = nPrefixStart + nIdx + 2;
106 if (nThisIdx >= nLen)
107 break;
108
109 sal_Unicode nThisCode = rSrc[nThisIdx];
110 sal_Int32 nLetter = lcl_getHexLetterValue(nThisCode);
111
112 if (!nIdx && nLetter < 0)
113 break;
114
115 if (nLetter >= 0)
116 {
117 nCode = (nCode << 4) + static_cast<sal_Unicode>(nLetter);
118 }
119 else if (nThisCode == '_')
120 {
121 nEnd = nThisIdx + 1;
122 bFoundThis = true;
123 break;
124 }
125 else
126 {
127 break;
128 }
129 }
130
131 if (bFoundThis)
132 {
133 // nEnd is already set inside the inner loop in this case.
134 if (lcl_validEscape(nCode))
135 {
136 bFound = true;
137 sal_Int32 nEscStrLen = nEnd - nPrefixStart;
138 aBuf.remove(nPrefixStart - nOffset, nEscStrLen);
139 aBuf.insert(nPrefixStart - nOffset, nCode);
140
141 nOffset += nEscStrLen - 1;
142 }
143 }
144 else
145 {
146 // Start the next search just after last "_x"
147 nEnd = nPrefixStart + 2;
148 }
149
150 nStart = nEnd;
151 nPrefixStart = rSrc.indexOf(aPrefix, nStart);
152 }
153 while (nPrefixStart != -1);
154
155 if (bFound)
156 return aBuf.makeStringAndClear();
157
158 return rSrc;
159}
160
161} // namespace
162
164 mnFontId( -1 ),
165 mbConverted( false )
166{
167}
168
169void RichStringPortion::setText( const OUString& rText )
170{
171 maText = lcl_unEscapeUnicodeChars(rText);
172}
173
175{
176 mxFont = std::make_shared<Font>( rHelper, false );
177 return mxFont;
178}
179
180void RichStringPortion::setFontId( sal_Int32 nFontId )
181{
182 mnFontId = nFontId;
183}
184
186{
187 if( mxFont )
188 mxFont->finalizeImport();
189 else if( mnFontId >= 0 )
190 mxFont = rHelper.getStyles().getFont( mnFontId );
191}
192
193void RichStringPortion::convert( const Reference< XText >& rxText, bool bReplace )
194{
195 if ( mbConverted )
196 return;
197
198 Reference< XTextRange > xRange;
199 if( bReplace )
200 xRange = rxText;
201 else
202 xRange = rxText->getEnd();
203 OSL_ENSURE( xRange.is(), "RichStringPortion::convert - cannot get text range interface" );
204
205 if( xRange.is() )
206 {
207 xRange->setString( maText );
208 if( mxFont )
209 {
210 PropertySet aPropSet( xRange );
211 mxFont->writeToPropertySet( aPropSet );
212 }
213 }
214
215 mbConverted = true;
216}
217
219{
220 rSelection.nStartPos = rSelection.nEndPos;
221 rSelection.nStartPara = rSelection.nEndPara;
222 SfxItemSet aItemSet( rEE.GetEmptyItemSet() );
223
224 const Font* pFontToUse = mxFont ? mxFont.get() : lclNeedsRichTextFormat( pFont ) ? pFont : nullptr;
225
226 if ( pFontToUse )
227 pFontToUse->fillToItemSet( aItemSet, true );
228
229 // #TODO need to manually adjust nEndPos ( and nEndPara ) to cater for any paragraphs
230 sal_Int32 nLastParaLoc = -1;
231 sal_Int32 nSearchIndex = maText.indexOf( '\n' );
232 sal_Int32 nParaOccurrence = 0;
233 while ( nSearchIndex != -1 )
234 {
235 nLastParaLoc = nSearchIndex;
236 ++nParaOccurrence;
237 rSelection.nEndPos = 0;
238 nSearchIndex = maText.indexOf( '\n', nSearchIndex + 1);
239 }
240
241 rSelection.nEndPara += nParaOccurrence;
242 if ( nLastParaLoc != -1 )
243 {
244 rSelection.nEndPos = maText.getLength() - 1 - nLastParaLoc;
245 }
246 else
247 {
248 rSelection.nEndPos = rSelection.nStartPos + maText.getLength();
249 }
250 rEE.QuickSetAttribs( aItemSet, rSelection );
251}
252
253void RichStringPortion::writeFontProperties( const Reference<XText>& rxText ) const
254{
255 PropertySet aPropSet(rxText);
256
257 if (mxFont)
258 mxFont->writeToPropertySet(aPropSet);
259}
260
262{
263 mnPos = rStrm.readuInt16();
264 mnFontId = rStrm.readuInt16();
265}
266
268{
269 // #i33341# real life -- same character index may occur several times
270 OSL_ENSURE( mvModels.empty() || (mvModels.back().mnPos <= rPortion.mnPos), "FontPortionModelList::appendPortion - wrong char order" );
271 if( mvModels.empty() || (mvModels.back().mnPos < rPortion.mnPos) )
272 mvModels.push_back( rPortion );
273 else
274 mvModels.back().mnFontId = rPortion.mnFontId;
275}
276
278{
279 sal_Int32 nCount = rStrm.readInt32();
280 mvModels.clear();
281 if( nCount > 0 )
282 {
283 mvModels.reserve( getLimitedValue< size_t, sal_Int64 >( nCount, 0, rStrm.getRemaining() / 4 ) );
284 /* #i33341# real life -- same character index may occur several times
285 -> use appendPortion() to validate string position. */
286 FontPortionModel aPortion;
287 for( sal_Int32 nIndex = 0; !rStrm.isEof() && (nIndex < nCount); ++nIndex )
288 {
289 aPortion.read( rStrm );
290 appendPortion( aPortion );
291 }
292 }
293}
294
296 mnFontId( -1 ),
297 mnType( XML_fullwidthKatakana ),
298 mnAlignment( XML_left )
299{
300}
301
302void PhoneticDataModel::setBiffData( sal_Int32 nType, sal_Int32 nAlignment )
303{
304 static const sal_Int32 spnTypeIds[] = { XML_halfwidthKatakana, XML_fullwidthKatakana, XML_hiragana, XML_noConversion };
305 mnType = STATIC_ARRAY_SELECT( spnTypeIds, nType, XML_fullwidthKatakana );
306
307 static const sal_Int32 spnAlignments[] = { XML_noControl, XML_left, XML_center, XML_distributed };
308 mnAlignment = STATIC_ARRAY_SELECT( spnAlignments, nAlignment, XML_left );
309}
310
312 WorkbookHelper( rHelper )
313{
314}
315
317{
318 maModel.mnFontId = rAttribs.getInteger( XML_fontId, -1 );
319 maModel.mnType = rAttribs.getToken( XML_type, XML_fullwidthKatakana );
320 maModel.mnAlignment = rAttribs.getToken( XML_alignment, XML_left );
321}
322
324{
325 sal_uInt16 nFontId;
326 sal_Int32 nType, nAlignment;
327 nFontId = rStrm.readuInt16();
328 nType = rStrm.readInt32();
329 nAlignment = rStrm.readInt32();
330 maModel.mnFontId = nFontId;
331 maModel.setBiffData( nType, nAlignment );
332}
333
335{
336 sal_uInt16 nFontId, nFlags;
337 nFontId = rStrm.readuInt16();
338 nFlags = rStrm.readuInt16();
339 maModel.mnFontId = nFontId;
340 maModel.setBiffData( extractValue< sal_Int32 >( nFlags, 0, 2 ), extractValue< sal_Int32 >( nFlags, 2, 2 ) );
341}
342
344 mnBasePos( -1 ),
345 mnBaseEnd( -1 )
346{
347}
348
349void RichStringPhonetic::setText( const OUString& rText )
350{
351 maText = rText;
352}
353
355{
356 mnBasePos = rAttribs.getInteger( XML_sb, -1 );
357 mnBaseEnd = rAttribs.getInteger( XML_eb, -1 );
358}
359
360void RichStringPhonetic::setBaseRange( sal_Int32 nBasePos, sal_Int32 nBaseEnd )
361{
362 mnBasePos = nBasePos;
363 mnBaseEnd = nBaseEnd;
364}
365
367{
368 mnPos = rStrm.readuInt16();
369 mnBasePos = rStrm.readuInt16();
370 mnBaseLen = rStrm.readuInt16();
371}
372
374{
375 // same character index may occur several times
376 OSL_ENSURE( mvModels.empty() || ((mvModels.back().mnPos <= rPortion.mnPos) &&
377 (mvModels.back().mnBasePos + mvModels.back().mnBaseLen <= rPortion.mnBasePos)),
378 "PhoneticPortionModelList::appendPortion - wrong char order" );
379 if( mvModels.empty() || (mvModels.back().mnPos < rPortion.mnPos) )
380 {
381 mvModels.push_back( rPortion );
382 }
383 else if( mvModels.back().mnPos == rPortion.mnPos )
384 {
385 mvModels.back().mnBasePos = rPortion.mnBasePos;
386 mvModels.back().mnBaseLen = rPortion.mnBaseLen;
387 }
388}
389
391{
392 sal_Int32 nCount = rStrm.readInt32();
393 mvModels.clear();
394 if( nCount > 0 )
395 {
396 mvModels.reserve( getLimitedValue< size_t, sal_Int64 >( nCount, 0, rStrm.getRemaining() / 6 ) );
397 PhoneticPortionModel aPortion;
398 for( sal_Int32 nIndex = 0; !rStrm.isEof() && (nIndex < nCount); ++nIndex )
399 {
400 aPortion.read( rStrm );
401 appendPortion( aPortion );
402 }
403 }
404}
405
407{
408 return createPortion();
409}
410
412{
413 return createPortion();
414}
415
417{
419 xPhonetic->importPhoneticRun( rAttribs );
420 return xPhonetic;
421}
422
423void RichString::importPhoneticPr( const AttributeList& rAttribs, const WorkbookHelper& rHelper )
424{
425 if (!mxPhonSettings)
426 mxPhonSettings.reset(new PhoneticSettings(rHelper));
427 mxPhonSettings->importPhoneticPr( rAttribs );
428}
429
430void RichString::importString( SequenceInputStream& rStrm, bool bRich, const WorkbookHelper& rHelper )
431{
432 sal_uInt8 nFlags = bRich ? rStrm.readuInt8() : 0;
433 OUString aBaseText = BiffHelper::readString( rStrm );
434
435 if( !rStrm.isEof() && getFlag( nFlags, BIFF12_STRINGFLAG_FONTS ) )
436 {
437 FontPortionModelList aPortions;
438 aPortions.importPortions( rStrm );
439 createTextPortions( aBaseText, aPortions );
440 }
441 else
442 {
443 getPortion(createPortion()).setText( aBaseText );
444 }
445
446 if( !rStrm.isEof() && getFlag( nFlags, BIFF12_STRINGFLAG_PHONETICS ) )
447 {
448 OUString aPhoneticText = BiffHelper::readString( rStrm );
449 PhoneticPortionModelList aPortions;
450 aPortions.importPortions( rStrm );
451 if (!mxPhonSettings)
452 mxPhonSettings.reset(new PhoneticSettings(rHelper));
453 mxPhonSettings->importStringData( rStrm );
454 createPhoneticPortions( aPhoneticText, aPortions, aBaseText.getLength() );
455 }
456}
457
459{
460 for (RichStringPortion& rPortion : maTextPortions)
461 rPortion.finalizeImport( rHelper );
462}
463
464bool RichString::extractPlainString( OUString& orString, const oox::xls::Font* pFirstPortionFont ) const
465{
466 if( !maPhonPortions.empty() )
467 return false;
468 if( maTextPortions.empty() )
469 {
470 orString.clear();
471 return true;
472 }
473 if( (maTextPortions.size() == 1) && !maTextPortions.front().hasFont() && !lclNeedsRichTextFormat( pFirstPortionFont ) )
474 {
475 orString = maTextPortions.front().getText();
476 return orString.indexOf( '\x0A' ) < 0;
477 }
478 return false;
479}
480
481void RichString::convert( const Reference< XText >& rxText )
482{
483 if (maTextPortions.size() == 1)
484 {
485 // Set text directly to the cell when the string has only one portion.
486 // It's much faster this way.
487 const RichStringPortion& rPtn = maTextPortions.front();
488 rxText->setString(rPtn.getText());
489 rPtn.writeFontProperties(rxText);
490 return;
491 }
492
493 bool bReplaceOld = true;
494 for( auto& rTextPortion : maTextPortions )
495 {
496 rTextPortion.convert( rxText, bReplaceOld );
497 bReplaceOld = false; // do not replace first portion text with following portions
498 }
499}
500
501std::unique_ptr<EditTextObject> RichString::convert( ScEditEngineDefaulter& rEE, const oox::xls::Font* pFirstPortionFont )
502{
503 ESelection aSelection;
504
505 OUStringBuffer sString;
506 for( auto& rTextPortion : maTextPortions )
507 sString.append(rTextPortion.getText());
508
509 // fdo#84370 - diving into editeng is not thread safe.
510 SolarMutexGuard aGuard;
511
512 rEE.SetTextCurrentDefaults( sString.makeStringAndClear() );
513
514 for( auto& rTextPortion : maTextPortions )
515 {
516 rTextPortion.convert( rEE, aSelection, pFirstPortionFont );
517 pFirstPortionFont = nullptr;
518 }
519
520 return rEE.CreateTextObject();
521}
522
523// private --------------------------------------------------------------------
524
526{
527 maTextPortions.emplace_back();
528 return maTextPortions.size() - 1;
529}
530
532{
533 RichStringPhoneticRef xPhonetic = std::make_shared<RichStringPhonetic>();
534 maPhonPortions.push_back( xPhonetic );
535 return xPhonetic;
536}
537
538void RichString::createTextPortions( std::u16string_view aText, FontPortionModelList& rPortions )
539{
540 maTextPortions.clear();
541 if( aText.empty() )
542 return;
543
544 sal_Int32 nStrLen = aText.size();
545 // add leading and trailing string position to ease the following loop
546 if( rPortions.empty() || (rPortions.front().mnPos > 0) )
547 rPortions.insert( rPortions.begin(), FontPortionModel( 0 ) );
548 if( rPortions.back().mnPos < nStrLen )
549 rPortions.push_back( FontPortionModel( nStrLen ) );
550
551 // create all string portions according to the font id vector
552 for( ::std::vector< FontPortionModel >::const_iterator aIt = rPortions.begin(); aIt->mnPos < nStrLen; ++aIt )
553 {
554 sal_Int32 nPortionLen = (aIt + 1)->mnPos - aIt->mnPos;
555 if( (0 < nPortionLen) && (aIt->mnPos + nPortionLen <= nStrLen) )
556 {
558 rPortion.setText( OUString(aText.substr( aIt->mnPos, nPortionLen )) );
559 rPortion.setFontId( aIt->mnFontId );
560 }
561 }
562}
563
564void RichString::createPhoneticPortions( std::u16string_view aText, PhoneticPortionModelList& rPortions, sal_Int32 nBaseLen )
565{
566 maPhonPortions.clear();
567 if( aText.empty())
568 return;
569
570 sal_Int32 nStrLen = aText.size();
571 // no portions - assign phonetic text to entire base text
572 if( rPortions.empty() )
573 rPortions.push_back( PhoneticPortionModel( 0, 0, nBaseLen ) );
574 // add trailing string position to ease the following loop
575 if( rPortions.back().mnPos < nStrLen )
576 rPortions.push_back( PhoneticPortionModel( nStrLen, nBaseLen, 0 ) );
577
578 // create all phonetic portions according to the portions vector
579 for( ::std::vector< PhoneticPortionModel >::const_iterator aIt = rPortions.begin(); aIt->mnPos < nStrLen; ++aIt )
580 {
581 sal_Int32 nPortionLen = (aIt + 1)->mnPos - aIt->mnPos;
582 if( (0 < nPortionLen) && (aIt->mnPos + nPortionLen <= nStrLen) )
583 {
585 xPhonetic->setText( OUString(aText.substr( aIt->mnPos, nPortionLen )) );
586 xPhonetic->setBaseRange( aIt->mnBasePos, aIt->mnBasePos + aIt->mnBaseLen );
587 }
588 }
589}
590
591} // namespace oox::xls
592
593/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< EditTextObject > CreateTextObject()
const SfxItemSet & GetEmptyItemSet() const
void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
Definition: editutil.cxx:616
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
static OUString readString(SequenceInputStream &rStrm, bool b32BitLen=true)
Reads a BIFF12 string with leading 16-bit or 32-bit length field.
Definition: biffhelper.cxx:79
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:277
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:267
void fillToItemSet(SfxItemSet &rItemSet, bool bEditEngineText, bool bSkipPoolDefs=false) const
bool needsRichTextFormat() const
Returns true, if the font requires rich text formatting in Calc.
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:390
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:373
void importStringData(SequenceInputStream &rStrm)
Imports phonetic settings from a rich string.
Definition: richstring.cxx:334
PhoneticSettings(const WorkbookHelper &rHelper)
Definition: richstring.cxx:311
void importPhoneticPr(const AttributeList &rAttribs)
Imports phonetic settings from the phoneticPr element.
Definition: richstring.cxx:316
PhoneticDataModel maModel
Definition: richstring.hxx:143
void setBaseRange(sal_Int32 nBasePos, sal_Int32 nBaseEnd)
Sets the associated range in base text for this phonetic portion.
Definition: richstring.cxx:360
void importPhoneticRun(const AttributeList &rAttribs)
Imports attributes of a phonetic run (rPh element).
Definition: richstring.cxx:354
void setText(const OUString &rText)
Sets text data for this phonetic portion.
Definition: richstring.cxx:349
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
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:253
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:174
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:180
void finalizeImport(const WorkbookHelper &rHelper)
Final processing after import of all strings.
Definition: richstring.cxx:185
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:169
void finalizeImport(const WorkbookHelper &rHelper)
Final processing after import of all strings.
Definition: richstring.cxx:458
sal_Int32 importText()
Appends and returns an index of a portion object for a plain string (t element).
Definition: richstring.cxx:406
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:564
void importString(SequenceInputStream &rStrm, bool bRich, const WorkbookHelper &rHelper)
Imports a Unicode rich-string from the passed record stream.
Definition: richstring.cxx:430
void importPhoneticPr(const AttributeList &rAttribs, const WorkbookHelper &rHelper)
Imports phonetic settings from the rPhoneticPr element.
Definition: richstring.cxx:423
std::unique_ptr< PhoneticSettings > mxPhonSettings
String portions with font data.
Definition: richstring.hxx:254
std::vector< RichStringPortion > maTextPortions
Definition: richstring.hxx:253
PhoneticVector maPhonPortions
Phonetic settings for this string.
Definition: richstring.hxx:255
bool extractPlainString(OUString &orString, const oox::xls::Font *pFirstPortionFont) const
Tries to extract a plain string from this object.
Definition: richstring.cxx:464
sal_Int32 createPortion()
Creates, appends, and returns a new empty string portion.
Definition: richstring.cxx:525
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,...
RichStringPhoneticRef importPhoneticRun(const AttributeList &rAttribs)
Appends and returns a phonetic text object for a new phonetic run (rPh element).
Definition: richstring.cxx:416
RichStringPortion & getPortion(sal_Int32 nPortionIdx)
Definition: richstring.hxx:237
RichStringPhoneticRef createPhonetic()
Creates, appends, and returns a new empty phonetic text portion.
Definition: richstring.cxx:531
sal_Int32 importRun()
Appends and returns an index of a portion object for a new formatting run (r element).
Definition: richstring.cxx:411
void createTextPortions(std::u16string_view aText, FontPortionModelList &rPortions)
Create base text portions from the passed string and character formatting.
Definition: richstring.cxx:538
FontRef getFont(sal_Int32 nFontId) const
Returns the specified font object.
Helper class to provide access to global workbook data.
StylesBuffer & getStyles() const
Returns all cell formatting objects read from the styles substream.
int nCount
#define STATIC_ARRAY_SELECT(array, index, def)
sal_Int32 nIndex
aBuf
sal_uInt16 nCode
void SvStream & rStrm
std::shared_ptr< RichStringPhonetic > RichStringPhoneticRef
Definition: richstring.hxx:165
std::shared_ptr< Font > FontRef
bool getFlag(Type nBitField, Type nMask)
XML_type
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
sal_Int32 mnType
sal_Int32 nStartPara
sal_Int32 nEndPos
sal_Int32 nStartPos
sal_Int32 nEndPara
Represents a position in a rich-string containing current font identifier.
Definition: richstring.hxx:81
sal_Int32 mnFontId
First character in the string.
Definition: richstring.hxx:83
void read(SequenceInputStream &rStrm)
Definition: richstring.cxx:261
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:295
void setBiffData(sal_Int32 nType, sal_Int32 nAlignment)
Sets the passed data from binary import.
Definition: richstring.cxx:302
Represents a phonetic text portion in a rich-string with phonetic text.
Definition: richstring.hxx:170
void read(SequenceInputStream &rStrm)
Definition: richstring.cxx:366
sal_Int32 mnBasePos
First character in phonetic text.
Definition: richstring.hxx:172
sal_Int32 mnBaseLen
First character in base text.
Definition: richstring.hxx:173
unsigned char sal_uInt8
sal_uInt16 sal_Unicode