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 
36 namespace oox::xls {
37 
38 using namespace ::com::sun::star::text;
39 using namespace ::com::sun::star::uno;
40 
41 namespace {
42 
43 const sal_uInt8 BIFF12_STRINGFLAG_FONTS = 0x01;
44 const sal_uInt8 BIFF12_STRINGFLAG_PHONETICS = 0x02;
45 
46 bool lclNeedsRichTextFormat( const oox::xls::Font* pFont )
47 {
48  return pFont && pFont->needsRichTextFormat();
49 }
50 
51 sal_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 
65 bool 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 
79 OUString 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  WorkbookHelper( rHelper ),
165  mnFontId( -1 ),
166  mbConverted( false )
167 {
168 }
169 
170 void RichStringPortion::setText( const OUString& rText )
171 {
172  maText = lcl_unEscapeUnicodeChars(rText);
173 }
174 
176 {
177  mxFont = std::make_shared<Font>( *this, false );
178  return mxFont;
179 }
180 
181 void RichStringPortion::setFontId( sal_Int32 nFontId )
182 {
183  mnFontId = nFontId;
184 }
185 
187 {
188  if( mxFont )
189  mxFont->finalizeImport();
190  else if( mnFontId >= 0 )
192 }
193 
194 void RichStringPortion::convert( const Reference< XText >& rxText, bool bReplace )
195 {
196  if ( mbConverted )
197  return;
198 
199  Reference< XTextRange > xRange;
200  if( bReplace )
201  xRange = rxText;
202  else
203  xRange = rxText->getEnd();
204  OSL_ENSURE( xRange.is(), "RichStringPortion::convert - cannot get text range interface" );
205 
206  if( xRange.is() )
207  {
208  xRange->setString( maText );
209  if( mxFont )
210  {
211  PropertySet aPropSet( xRange );
212  mxFont->writeToPropertySet( aPropSet );
213  }
214  }
215 
216  mbConverted = true;
217 }
218 
220 {
221  rSelection.nStartPos = rSelection.nEndPos;
222  rSelection.nStartPara = rSelection.nEndPara;
223  SfxItemSet aItemSet( rEE.GetEmptyItemSet() );
224 
225  const Font* pFontToUse = mxFont ? mxFont.get() : lclNeedsRichTextFormat( pFont ) ? pFont : nullptr;
226 
227  if ( pFontToUse )
228  pFontToUse->fillToItemSet( aItemSet, true );
229 
230  // #TODO need to manually adjust nEndPos ( and nEndPara ) to cater for any paragraphs
231  sal_Int32 nLastParaLoc = -1;
232  sal_Int32 nSearchIndex = maText.indexOf( '\n' );
233  sal_Int32 nParaOccurrence = 0;
234  while ( nSearchIndex != -1 )
235  {
236  nLastParaLoc = nSearchIndex;
237  ++nParaOccurrence;
238  rSelection.nEndPos = 0;
239  nSearchIndex = maText.indexOf( '\n', nSearchIndex + 1);
240  }
241 
242  rSelection.nEndPara += nParaOccurrence;
243  if ( nLastParaLoc != -1 )
244  {
245  rSelection.nEndPos = maText.getLength() - 1 - nLastParaLoc;
246  }
247  else
248  {
249  rSelection.nEndPos = rSelection.nStartPos + maText.getLength();
250  }
251  rEE.QuickSetAttribs( aItemSet, rSelection );
252 }
253 
254 void RichStringPortion::writeFontProperties( const Reference<XText>& rxText ) const
255 {
256  PropertySet aPropSet(rxText);
257 
258  if (mxFont)
259  mxFont->writeToPropertySet(aPropSet);
260 }
261 
263 {
264  mnPos = rStrm.readuInt16();
265  mnFontId = rStrm.readuInt16();
266 }
267 
269 {
270  // #i33341# real life -- same character index may occur several times
271  OSL_ENSURE( mvModels.empty() || (mvModels.back().mnPos <= rPortion.mnPos), "FontPortionModelList::appendPortion - wrong char order" );
272  if( mvModels.empty() || (mvModels.back().mnPos < rPortion.mnPos) )
273  mvModels.push_back( rPortion );
274  else
275  mvModels.back().mnFontId = rPortion.mnFontId;
276 }
277 
279 {
280  sal_Int32 nCount = rStrm.readInt32();
281  mvModels.clear();
282  if( nCount > 0 )
283  {
284  mvModels.reserve( getLimitedValue< size_t, sal_Int64 >( nCount, 0, rStrm.getRemaining() / 4 ) );
285  /* #i33341# real life -- same character index may occur several times
286  -> use appendPortion() to validate string position. */
287  FontPortionModel aPortion;
288  for( sal_Int32 nIndex = 0; !rStrm.isEof() && (nIndex < nCount); ++nIndex )
289  {
290  aPortion.read( rStrm );
291  appendPortion( aPortion );
292  }
293  }
294 }
295 
297  mnFontId( -1 ),
298  mnType( XML_fullwidthKatakana ),
299  mnAlignment( XML_left )
300 {
301 }
302 
303 void PhoneticDataModel::setBiffData( sal_Int32 nType, sal_Int32 nAlignment )
304 {
305  static const sal_Int32 spnTypeIds[] = { XML_halfwidthKatakana, XML_fullwidthKatakana, XML_hiragana, XML_noConversion };
306  mnType = STATIC_ARRAY_SELECT( spnTypeIds, nType, XML_fullwidthKatakana );
307 
308  static const sal_Int32 spnAlignments[] = { XML_noControl, XML_left, XML_center, XML_distributed };
309  mnAlignment = STATIC_ARRAY_SELECT( spnAlignments, nAlignment, XML_left );
310 }
311 
313  WorkbookHelper( rHelper )
314 {
315 }
316 
318 {
319  maModel.mnFontId = rAttribs.getInteger( XML_fontId, -1 );
320  maModel.mnType = rAttribs.getToken( XML_type, XML_fullwidthKatakana );
321  maModel.mnAlignment = rAttribs.getToken( XML_alignment, XML_left );
322 }
323 
325 {
326  sal_uInt16 nFontId;
327  sal_Int32 nType, nAlignment;
328  nFontId = rStrm.readuInt16();
329  nType = rStrm.readInt32();
330  nAlignment = rStrm.readInt32();
331  maModel.mnFontId = nFontId;
332  maModel.setBiffData( nType, nAlignment );
333 }
334 
336 {
337  sal_uInt16 nFontId, nFlags;
338  nFontId = rStrm.readuInt16();
339  nFlags = rStrm.readuInt16();
340  maModel.mnFontId = nFontId;
341  maModel.setBiffData( extractValue< sal_Int32 >( nFlags, 0, 2 ), extractValue< sal_Int32 >( nFlags, 2, 2 ) );
342 }
343 
345  WorkbookHelper( rHelper ),
346  mnBasePos( -1 ),
347  mnBaseEnd( -1 )
348 {
349 }
350 
351 void RichStringPhonetic::setText( const OUString& rText )
352 {
353  maText = rText;
354 }
355 
357 {
358  mnBasePos = rAttribs.getInteger( XML_sb, -1 );
359  mnBaseEnd = rAttribs.getInteger( XML_eb, -1 );
360 }
361 
362 void RichStringPhonetic::setBaseRange( sal_Int32 nBasePos, sal_Int32 nBaseEnd )
363 {
364  mnBasePos = nBasePos;
365  mnBaseEnd = nBaseEnd;
366 }
367 
369 {
370  mnPos = rStrm.readuInt16();
371  mnBasePos = rStrm.readuInt16();
372  mnBaseLen = rStrm.readuInt16();
373 }
374 
376 {
377  // same character index may occur several times
378  OSL_ENSURE( mvModels.empty() || ((mvModels.back().mnPos <= rPortion.mnPos) &&
379  (mvModels.back().mnBasePos + mvModels.back().mnBaseLen <= rPortion.mnBasePos)),
380  "PhoneticPortionModelList::appendPortion - wrong char order" );
381  if( mvModels.empty() || (mvModels.back().mnPos < rPortion.mnPos) )
382  {
383  mvModels.push_back( rPortion );
384  }
385  else if( mvModels.back().mnPos == rPortion.mnPos )
386  {
387  mvModels.back().mnBasePos = rPortion.mnBasePos;
388  mvModels.back().mnBaseLen = rPortion.mnBaseLen;
389  }
390 }
391 
393 {
394  sal_Int32 nCount = rStrm.readInt32();
395  mvModels.clear();
396  if( nCount > 0 )
397  {
398  mvModels.reserve( getLimitedValue< size_t, sal_Int64 >( nCount, 0, rStrm.getRemaining() / 6 ) );
399  PhoneticPortionModel aPortion;
400  for( sal_Int32 nIndex = 0; !rStrm.isEof() && (nIndex < nCount); ++nIndex )
401  {
402  aPortion.read( rStrm );
403  appendPortion( aPortion );
404  }
405  }
406 }
407 
409  WorkbookHelper( rHelper ),
410  maPhonSettings( rHelper )
411 {
412 }
413 
415 {
416  return createPortion();
417 }
418 
420 {
421  return createPortion();
422 }
423 
425 {
427  xPhonetic->importPhoneticRun( rAttribs );
428  return xPhonetic;
429 }
430 
432 {
433  maPhonSettings.importPhoneticPr( rAttribs );
434 }
435 
437 {
438  sal_uInt8 nFlags = bRich ? rStrm.readuInt8() : 0;
439  OUString aBaseText = BiffHelper::readString( rStrm );
440 
441  if( !rStrm.isEof() && getFlag( nFlags, BIFF12_STRINGFLAG_FONTS ) )
442  {
443  FontPortionModelList aPortions;
444  aPortions.importPortions( rStrm );
445  createTextPortions( aBaseText, aPortions );
446  }
447  else
448  {
449  createPortion()->setText( aBaseText );
450  }
451 
452  if( !rStrm.isEof() && getFlag( nFlags, BIFF12_STRINGFLAG_PHONETICS ) )
453  {
454  OUString aPhoneticText = BiffHelper::readString( rStrm );
455  PhoneticPortionModelList aPortions;
456  aPortions.importPortions( rStrm );
458  createPhoneticPortions( aPhoneticText, aPortions, aBaseText.getLength() );
459  }
460 }
461 
463 {
465 }
466 
467 bool RichString::extractPlainString( OUString& orString, const oox::xls::Font* pFirstPortionFont ) const
468 {
469  if( !maPhonPortions.empty() )
470  return false;
471  if( maTextPortions.empty() )
472  {
473  orString.clear();
474  return true;
475  }
476  if( (maTextPortions.size() == 1) && !maTextPortions.front()->hasFont() && !lclNeedsRichTextFormat( pFirstPortionFont ) )
477  {
478  orString = maTextPortions.front()->getText();
479  return orString.indexOf( '\x0A' ) < 0;
480  }
481  return false;
482 }
483 
484 void RichString::convert( const Reference< XText >& rxText ) const
485 {
486  if (maTextPortions.size() == 1)
487  {
488  // Set text directly to the cell when the string has only one portion.
489  // It's much faster this way.
490  RichStringPortion& rPtn = *maTextPortions.front();
491  rxText->setString(rPtn.getText());
492  rPtn.writeFontProperties(rxText);
493  return;
494  }
495 
496  bool bReplaceOld = true;
497  for( const auto& rxTextPortion : maTextPortions )
498  {
499  rxTextPortion->convert( rxText, bReplaceOld );
500  bReplaceOld = false; // do not replace first portion text with following portions
501  }
502 }
503 
504 std::unique_ptr<EditTextObject> RichString::convert( ScEditEngineDefaulter& rEE, const oox::xls::Font* pFirstPortionFont ) const
505 {
506  ESelection aSelection;
507 
508  OUStringBuffer sString;
509  for( const auto& rxTextPortion : maTextPortions )
510  sString.append(rxTextPortion->getText());
511 
512  // fdo#84370 - diving into editeng is not thread safe.
513  SolarMutexGuard aGuard;
514 
515  rEE.SetTextCurrentDefaults( sString.makeStringAndClear() );
516 
517  for( const auto& rxTextPortion : maTextPortions )
518  {
519  rxTextPortion->convert( rEE, aSelection, pFirstPortionFont );
520  pFirstPortionFont = nullptr;
521  }
522 
523  return rEE.CreateTextObject();
524 }
525 
526 // private --------------------------------------------------------------------
527 
529 {
530  RichStringPortionRef xPortion = std::make_shared<RichStringPortion>( *this );
531  maTextPortions.push_back( xPortion );
532  return xPortion;
533 }
534 
536 {
537  RichStringPhoneticRef xPhonetic = std::make_shared<RichStringPhonetic>( *this );
538  maPhonPortions.push_back( xPhonetic );
539  return xPhonetic;
540 }
541 
542 void RichString::createTextPortions( const OUString& rText, FontPortionModelList& rPortions )
543 {
544  maTextPortions.clear();
545  if( rText.isEmpty() )
546  return;
547 
548  sal_Int32 nStrLen = rText.getLength();
549  // add leading and trailing string position to ease the following loop
550  if( rPortions.empty() || (rPortions.front().mnPos > 0) )
551  rPortions.insert( rPortions.begin(), FontPortionModel( 0 ) );
552  if( rPortions.back().mnPos < nStrLen )
553  rPortions.push_back( FontPortionModel( nStrLen ) );
554 
555  // create all string portions according to the font id vector
556  for( ::std::vector< FontPortionModel >::const_iterator aIt = rPortions.begin(); aIt->mnPos < nStrLen; ++aIt )
557  {
558  sal_Int32 nPortionLen = (aIt + 1)->mnPos - aIt->mnPos;
559  if( (0 < nPortionLen) && (aIt->mnPos + nPortionLen <= nStrLen) )
560  {
561  RichStringPortionRef xPortion = createPortion();
562  xPortion->setText( rText.copy( aIt->mnPos, nPortionLen ) );
563  xPortion->setFontId( aIt->mnFontId );
564  }
565  }
566 }
567 
568 void RichString::createPhoneticPortions( const OUString& rText, PhoneticPortionModelList& rPortions, sal_Int32 nBaseLen )
569 {
570  maPhonPortions.clear();
571  if( rText.isEmpty())
572  return;
573 
574  sal_Int32 nStrLen = rText.getLength();
575  // no portions - assign phonetic text to entire base text
576  if( rPortions.empty() )
577  rPortions.push_back( PhoneticPortionModel( 0, 0, nBaseLen ) );
578  // add trailing string position to ease the following loop
579  if( rPortions.back().mnPos < nStrLen )
580  rPortions.push_back( PhoneticPortionModel( nStrLen, nBaseLen, 0 ) );
581 
582  // create all phonetic portions according to the portions vector
583  for( ::std::vector< PhoneticPortionModel >::const_iterator aIt = rPortions.begin(); aIt->mnPos < nStrLen; ++aIt )
584  {
585  sal_Int32 nPortionLen = (aIt + 1)->mnPos - aIt->mnPos;
586  if( (0 < nPortionLen) && (aIt->mnPos + nPortionLen <= nStrLen) )
587  {
589  xPhonetic->setText( rText.copy( aIt->mnPos, nPortionLen ) );
590  xPhonetic->setBaseRange( aIt->mnBasePos, aIt->mnBasePos + aIt->mnBaseLen );
591  }
592  }
593 }
594 
595 } // namespace oox::xls
596 
597 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Helper class to provide access to global workbook data.
void importPhoneticPr(const AttributeList &rAttribs)
Imports phonetic settings from the rPhoneticPr element.
Definition: richstring.cxx:431
void setText(const OUString &rText)
Sets text data for this portion.
Definition: richstring.cxx:170
Represents a position in a rich-string containing current font identifier.
Definition: richstring.hxx:82
sal_Int32 nStartPara
sal_Int32 mnAlignment
Phonetic text type.
Definition: richstring.hxx:123
sal_Int32 nIndex
Contains text data and font attributes for a part of a rich formatted string.
Definition: richstring.hxx:38
void push_back(const PhoneticPortionModel &rModel)
Definition: richstring.hxx:194
void importPortions(SequenceInputStream &rStrm)
Reads all phonetic portions from the passed stream.
Definition: richstring.cxx:392
void setBaseRange(sal_Int32 nBasePos, sal_Int32 nBaseEnd)
Sets the associated range in base text for this phonetic portion.
Definition: richstring.cxx:362
RichStringPortion(const WorkbookHelper &rHelper)
Definition: richstring.cxx:163
const SfxItemSet & GetEmptyItemSet() const
std::shared_ptr< RichStringPortion > RichStringPortionRef
Definition: richstring.hxx:74
OptValue< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
::std::vector< FontPortionModel >::iterator begin()
Definition: richstring.hxx:111
RichStringPortionRef importRun()
Appends and returns a portion object for a new formatting run (r element).
Definition: richstring.cxx:419
PhoneticVector maPhonPortions
Phonetic settings for this string.
Definition: richstring.hxx:257
sal_Int32 mnBaseEnd
Start position in base text.
Definition: richstring.hxx:164
void convert(const css::uno::Reference< css::text::XText > &rxText, bool bReplace)
Converts the portion and replaces or appends to the passed XText.
void insert(::std::vector< FontPortionModel >::iterator it, const FontPortionModel &rModel)
Definition: richstring.hxx:107
aBuf
const FontPortionModel & front() const
Definition: richstring.hxx:103
#define STATIC_ARRAY_SELECT(array, index, def)
void importPortions(SequenceInputStream &rStrm)
Reads count and font identifiers from the passed stream.
Definition: richstring.cxx:278
StylesBuffer & getStyles() const
Returns all cell formatting objects read from the styles substream.
void read(SequenceInputStream &rStrm)
Definition: richstring.cxx:368
void setFontId(sal_Int32 nFontId)
Links this portion to a font object from the global font list.
Definition: richstring.cxx:181
void importPhoneticPr(const AttributeList &rAttribs)
Imports phonetic settings from the phoneticPr element.
Definition: richstring.cxx:317
void createPhoneticPortions(const OUString &rText, PhoneticPortionModelList &rPortions, sal_Int32 nBaseLen)
Create phonetic text portions from the passed string and portion data.
Definition: richstring.cxx:568
void finalizeImport()
Final processing after import of all strings.
Definition: richstring.cxx:462
void forEachMem(FuncType pFunc) const
FontRef mxFont
Portion text.
Definition: richstring.hxx:69
sal_uInt16 sal_Unicode
sal_Int32 mnBaseLen
First character in base text.
Definition: richstring.hxx:175
sal_uInt16 readuInt16()
::std::vector< FontPortionModel > mvModels
Definition: richstring.hxx:95
void importString(SequenceInputStream &rStrm, bool bRich)
Imports a Unicode rich-string from the passed record stream.
Definition: richstring.cxx:436
PhoneticSettings(const WorkbookHelper &rHelper)
Definition: richstring.cxx:312
PhoneticDataModel maModel
Definition: richstring.hxx:145
int nCount
void appendPortion(const PhoneticPortionModel &rPortion)
Appends a rich-string phonetic portion.
Definition: richstring.cxx:375
A vector with all font portions in a rich-string.
Definition: richstring.hxx:94
RichStringPhonetic(const WorkbookHelper &rHelper)
Definition: richstring.cxx:344
const OUString & getText() const
Returns the text data of this portion.
Definition: richstring.hxx:54
void push_back(const FontPortionModel &rModel)
Definition: richstring.hxx:105
void writeFontProperties(const css::uno::Reference< css::text::XText > &rxText) const
Definition: richstring.cxx:254
sal_Int32 nEndPos
void setText(const OUString &rText)
Sets text data for this phonetic portion.
Definition: richstring.cxx:351
bool getFlag(Type nBitField, Type nMask)
void importStringData(SequenceInputStream &rStrm)
Imports phonetic settings from a rich string.
Definition: richstring.cxx:335
RichStringPhoneticRef importPhoneticRun(const AttributeList &rAttribs)
Appends and returns a phonetic text object for a new phonetic run (rPh element).
Definition: richstring.cxx:424
void read(SequenceInputStream &rStrm)
Definition: richstring.cxx:262
sal_Int32 nEndPara
sal_Int32 mnBasePos
Portion text.
Definition: richstring.hxx:163
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
Definition: editutil.cxx:596
bool needsRichTextFormat() const
Returns true, if the font requires rich text formatting in Calc.
PhoneticSettings maPhonSettings
String portions with font data.
Definition: richstring.hxx:256
sal_Int32 mnType
FontRef getFont(sal_Int32 nFontId) const
Returns the specified font object.
static OUString readString(SequenceInputStream &rStrm, bool b32BitLen=true)
Reads a BIFF12 string with leading 16-bit or 32-bit length field.
Definition: biffhelper.cxx:80
std::unique_ptr< EditTextObject > CreateTextObject()
void importPhoneticRun(const AttributeList &rAttribs)
Imports attributes of a phonetic run (rPh element).
Definition: richstring.cxx:356
void convert(const css::uno::Reference< css::text::XText > &rxText) const
Converts the string and writes it into the passed XText, replace old contents of the text object...
bool mbConverted
Link to global font list.
Definition: richstring.hxx:71
const PhoneticPortionModel & back() const
Definition: richstring.hxx:192
PortionVector maTextPortions
Definition: richstring.hxx:255
::std::vector< PhoneticPortionModel > mvModels
Definition: richstring.hxx:204
RichStringPortionRef createPortion()
Creates, appends, and returns a new empty string portion.
Definition: richstring.cxx:528
std::shared_ptr< Font > FontRef
void createTextPortions(const OUString &rText, FontPortionModelList &rPortions)
Create base text portions from the passed string and character formatting.
Definition: richstring.cxx:542
Represents a phonetic text portion in a rich-string with phonetic text.
Definition: richstring.hxx:171
RichStringPortionRef importText()
Appends and returns a portion object for a plain string (t element).
Definition: richstring.cxx:414
void fillToItemSet(SfxItemSet &rItemSet, bool bEditEngineText, bool bSkipPoolDefs=false) const
sal_Int64 getRemaining() const
void appendPortion(const FontPortionModel &rPortion)
Appends a rich-string font identifier.
Definition: richstring.cxx:268
unsigned char sal_uInt8
void setBiffData(sal_Int32 nType, sal_Int32 nAlignment)
Sets the passed data from binary import.
Definition: richstring.cxx:303
sal_Int32 mnBasePos
First character in phonetic text.
Definition: richstring.hxx:174
A vector with all phonetic portions in a rich-string.
Definition: richstring.hxx:185
void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
void finalizeImport()
Final processing after import of all strings.
Definition: richstring.cxx:186
sal_Int32 mnFontId
First character in the string.
Definition: richstring.hxx:85
sal_Int32 mnType
Font identifier for text formatting.
Definition: richstring.hxx:122
FontRef const & createFont()
Creates and returns a new font formatting object.
Definition: richstring.cxx:175
bool isEof() const
sal_Int32 mnFontId
Embedded portion font, may be empty.
Definition: richstring.hxx:70
::std::vector< PhoneticPortionModel >::const_iterator begin() const
Definition: richstring.hxx:196
RichString(const WorkbookHelper &rHelper)
Definition: richstring.cxx:408
std::shared_ptr< RichStringPhonetic > RichStringPhoneticRef
Definition: richstring.hxx:167
bool extractPlainString(OUString &orString, const oox::xls::Font *pFirstPortionFont) const
Tries to extract a plain string from this object.
Definition: richstring.cxx:467
RichStringPhoneticRef createPhonetic()
Creates, appends, and returns a new empty phonetic text portion.
Definition: richstring.cxx:535
PhoneticDataModel()
Phonetic portion alignment.
Definition: richstring.cxx:296
OptValue< sal_Int32 > getToken(sal_Int32 nAttrToken) const
const FontPortionModel & back() const
Definition: richstring.hxx:102
sal_Int32 nStartPos