LibreOffice Module sc (master) 1
xestring.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 <algorithm>
21#include <cassert>
22
23#include <o3tl/safeint.hxx>
24#include <osl/diagnose.h>
25#include <tools/solar.h>
26#include <xlstyle.hxx>
27#include <xestyle.hxx>
28#include <xestream.hxx>
29#include <xestring.hxx>
30#include <oox/token/tokens.hxx>
31
32using namespace ::oox;
33
34namespace {
35
36// compare vectors
37
41template< typename Type >
42int lclCompareVectors( const ::std::vector< Type >& rLeft, const ::std::vector< Type >& rRight )
43{
44 int nResult = 0;
45
46 // 1st: compare all elements of the vectors
47 auto [aItL, aItR] = std::mismatch(rLeft.begin(), rLeft.end(), rRight.begin(), rRight.end());
48 if ((aItL != rLeft.end()) && (aItR != rRight.end()))
49 nResult = static_cast< int >( *aItL ) - static_cast< int >( *aItR );
50 else
51 // 2nd: compare the vector sizes. Shorter vector is less
52 nResult = static_cast< int >( rLeft.size() ) - static_cast< int >( rRight.size() );
53
54 return nResult;
55}
56
57// hashing helpers
58
61template< typename Type >
62struct XclHasher {};
63
64template< typename Type >
65struct XclDirectHasher : public XclHasher< Type >
66{
67 sal_uInt32 operator()( Type nVal ) const { return nVal; }
68};
69
70struct XclFormatRunHasher : public XclHasher< const XclFormatRun& >
71{
72 sal_uInt32 operator()( const XclFormatRun& rRun ) const
73 { return (rRun.mnChar << 8) ^ rRun.mnFontIdx; }
74};
75
79template< typename Type, typename ValueHasher >
80sal_uInt16 lclHashVector( const ::std::vector< Type >& rVec, const ValueHasher& rHasher )
81{
82 sal_uInt32 nHash = rVec.size();
83 for( const auto& rItem : rVec )
84 nHash = (nHash * 31) + rHasher( rItem );
85 return static_cast< sal_uInt16 >( nHash ^ (nHash >> 16) );
86}
87
89template< typename Type >
90sal_uInt16 lclHashVector( const ::std::vector< Type >& rVec )
91{
92 return lclHashVector( rVec, XclDirectHasher< Type >() );
93}
94
95} // namespace
96
97// constructors ---------------------------------------------------------------
98
99XclExpString::XclExpString( XclStrFlags nFlags, sal_uInt16 nMaxLen )
100{
101 Init( 0, nFlags, nMaxLen, true );
102}
103
104XclExpString::XclExpString( const OUString& rString, XclStrFlags nFlags, sal_uInt16 nMaxLen )
105{
106 Assign( rString, nFlags, nMaxLen );
107}
108
109// assign ---------------------------------------------------------------------
110
111void XclExpString::Assign( const OUString& rString, XclStrFlags nFlags, sal_uInt16 nMaxLen )
112{
113 Build( rString.getStr(), rString.getLength(), nFlags, nMaxLen );
114}
115
117{
119}
120
122 std::u16string_view rString, rtl_TextEncoding eTextEnc, XclStrFlags nFlags,
123 sal_uInt16 nMaxLen )
124{
125 // length may differ from length of rString
126 OString aByteStr(OUStringToOString(rString, eTextEnc));
127 Build(aByteStr.getStr(), aByteStr.getLength(), nFlags, nMaxLen);
128}
129
130// append ---------------------------------------------------------------------
131
132void XclExpString::Append( std::u16string_view rString )
133{
134 BuildAppend( rString );
135}
136
137void XclExpString::AppendByte( std::u16string_view rString, rtl_TextEncoding eTextEnc )
138{
139 if (!rString.empty())
140 {
141 // length may differ from length of rString
142 OString aByteStr(OUStringToOString(rString, eTextEnc));
143 BuildAppend(aByteStr);
144 }
145}
146
147void XclExpString::AppendByte( sal_Unicode cChar, rtl_TextEncoding eTextEnc )
148{
149 if( !cChar )
150 {
151 BuildAppend( "\0" );
152 }
153 else
154 {
155 OString aByteStr( &cChar, 1, eTextEnc ); // length may be >1
156 BuildAppend( aByteStr );
157 }
158}
159
160// formatting runs ------------------------------------------------------------
161
162void XclExpString::AppendFormat( sal_uInt16 nChar, sal_uInt16 nFontIdx, bool bDropDuplicate )
163{
164 OSL_ENSURE( maFormats.empty() || (maFormats.back().mnChar < nChar), "XclExpString::AppendFormat - invalid char index" );
165 size_t nMaxSize = static_cast< size_t >( mbIsBiff8 ? EXC_STR_MAXLEN : EXC_STR_MAXLEN_8BIT );
166 if( maFormats.empty() || ((maFormats.size() < nMaxSize) && (!bDropDuplicate || (maFormats.back().mnFontIdx != nFontIdx))) )
167 maFormats.emplace_back( nChar, nFontIdx );
168}
169
170void XclExpString::AppendTrailingFormat( sal_uInt16 nFontIdx )
171{
172 AppendFormat( mnLen, nFontIdx, false );
173}
174
175void XclExpString::LimitFormatCount( sal_uInt16 nMaxCount )
176{
177 if( maFormats.size() > nMaxCount )
178 maFormats.erase( maFormats.begin() + nMaxCount, maFormats.end() );
179}
180
182{
183 sal_uInt16 nFontIdx = EXC_FONT_NOTFOUND;
184 if( !maFormats.empty() && (maFormats.front().mnChar == 0) )
185 {
186 nFontIdx = maFormats.front().mnFontIdx;
187 }
188 return nFontIdx;
189}
190
192{
193 sal_uInt16 nFontIdx = GetLeadingFont();
194 if( nFontIdx != EXC_FONT_NOTFOUND )
195 {
196 maFormats.erase( maFormats.begin() );
197 }
198 return nFontIdx;
199}
200
201bool XclExpString::IsEqual( const XclExpString& rCmp ) const
202{
203 return
204 (mnLen == rCmp.mnLen) &&
205 (mbIsBiff8 == rCmp.mbIsBiff8) &&
206 (mbIsUnicode == rCmp.mbIsUnicode) &&
207 (mbWrapped == rCmp.mbWrapped) &&
208 (
209 ( mbIsBiff8 && (maUniBuffer == rCmp.maUniBuffer)) ||
210 (!mbIsBiff8 && (maCharBuffer == rCmp.maCharBuffer))
211 ) &&
212 (maFormats == rCmp.maFormats);
213}
214
215bool XclExpString::IsLessThan( const XclExpString& rCmp ) const
216{
217 int nResult = mbIsBiff8 ?
218 lclCompareVectors( maUniBuffer, rCmp.maUniBuffer ) :
219 lclCompareVectors( maCharBuffer, rCmp.maCharBuffer );
220 return (nResult != 0) ? (nResult < 0) : (maFormats < rCmp.maFormats);
221}
222
223// get data -------------------------------------------------------------------
224
226{
227 return static_cast< sal_uInt16 >( maFormats.size() );
228}
229
231{
232 return (mbIsUnicode ? EXC_STRF_16BIT : 0) | (IsWriteFormats() ? EXC_STRF_RICH : 0);
233}
234
236{
237 return
238 (mb8BitLen ? 1 : 2) + // length field
239 (IsWriteFlags() ? 1 : 0) + // flag field
240 (IsWriteFormats() ? 2 : 0); // richtext formatting count
241}
242
244{
245 return static_cast<std::size_t>(mnLen) * (mbIsUnicode ? 2 : 1);
246}
247
248std::size_t XclExpString::GetSize() const
249{
250 return
251 GetHeaderSize() + // header
252 GetBufferSize() + // character buffer
253 (IsWriteFormats() ? (4 * GetFormatsCount()) : 0); // richtext formatting
254}
255
256sal_uInt16 XclExpString::GetChar( sal_uInt16 nCharIdx ) const
257{
258 OSL_ENSURE( nCharIdx < Len(), "XclExpString::GetChar - invalid character index" );
259 return static_cast< sal_uInt16 >( mbIsBiff8 ? maUniBuffer[ nCharIdx ] : maCharBuffer[ nCharIdx ] );
260}
261
262sal_uInt16 XclExpString::GetHash() const
263{
264 return
265 (mbIsBiff8 ? lclHashVector( maUniBuffer ) : lclHashVector( maCharBuffer )) ^
266 lclHashVector( maFormats, XclFormatRunHasher() );
267}
268
269// streaming ------------------------------------------------------------------
270
272{
273 if( mb8BitLen )
274 rStrm << static_cast< sal_uInt8 >( mnLen );
275 else
276 rStrm << mnLen;
277}
278
280{
281 if( mbIsBiff8 )
282 {
283 PrepareWrite( rStrm, 1 );
284 rStrm << GetFlagField();
285 rStrm.SetSliceSize( 0 );
286 }
287}
288
290{
291 OSL_ENSURE( !mb8BitLen || (mnLen < 256), "XclExpString::WriteHeader - string too long" );
293 // length
295 // flag field
296 if( IsWriteFlags() )
297 rStrm << GetFlagField();
298 // format run count
299 if( IsWriteFormats() )
301 rStrm.SetSliceSize( 0 );
302}
303
305{
306 if( mbIsBiff8 )
307 rStrm.WriteUnicodeBuffer( maUniBuffer, GetFlagField() );
308 else
309 rStrm.WriteCharBuffer( maCharBuffer );
310}
311
312void XclExpString::WriteFormats( XclExpStream& rStrm, bool bWriteSize ) const
313{
314 if( !IsRich() )
315 return;
316
317 if( mbIsBiff8 )
318 {
319 if( bWriteSize )
321 rStrm.SetSliceSize( 4 );
322 for( const auto& rFormat : maFormats )
323 rStrm << rFormat.mnChar << rFormat.mnFontIdx;
324 }
325 else
326 {
327 if( bWriteSize )
328 rStrm << static_cast< sal_uInt8 >( GetFormatsCount() );
329 rStrm.SetSliceSize( 2 );
330 for( const auto& rFormat : maFormats )
331 rStrm << static_cast< sal_uInt8 >( rFormat.mnChar ) << static_cast< sal_uInt8 >( rFormat.mnFontIdx );
332 }
333 rStrm.SetSliceSize( 0 );
334}
335
337{
338 if (!mbSkipHeader)
341 if( IsWriteFormats() ) // only in BIFF8 included in string
343}
344
346{
347 assert(pnMem);
348 OSL_ENSURE( !mb8BitLen || (mnLen < 256), "XclExpString::WriteHeaderToMem - string too long" );
349 OSL_ENSURE( !IsWriteFormats(), "XclExpString::WriteHeaderToMem - formatted strings not supported" );
350 // length
351 if( mb8BitLen )
352 {
353 *pnMem = static_cast< sal_uInt8 >( mnLen );
354 ++pnMem;
355 }
356 else
357 {
358 ShortToSVBT16( mnLen, pnMem );
359 pnMem += 2;
360 }
361 // flag field
362 if( IsWriteFlags() )
363 *pnMem = GetFlagField();
364}
365
367{
368 assert(pnMem);
369 if( IsEmpty() )
370 return;
371
372 if( mbIsBiff8 )
373 {
374 for( const sal_uInt16 nChar : maUniBuffer )
375 {
376 *pnMem = static_cast< sal_uInt8 >( nChar );
377 ++pnMem;
378 if( mbIsUnicode )
379 {
380 *pnMem = static_cast< sal_uInt8 >( nChar >> 8 );
381 ++pnMem;
382 }
383 }
384 }
385 else
386 memcpy( pnMem, maCharBuffer.data(), mnLen );
387}
388
390{
391 WriteHeaderToMem( pnMem );
392 WriteBufferToMem( pnMem + GetHeaderSize() );
393}
394
395static sal_uInt16 lcl_WriteRun( XclExpXmlStream& rStrm, const ScfUInt16Vec& rBuffer, sal_uInt16 nStart, sal_Int32 nLength, const XclExpFont* pFont )
396{
397 if( nLength == 0 )
398 return nStart;
399
400 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
401
402 rWorksheet->startElement(XML_r);
403 if( pFont )
404 {
405 const XclFontData& rFontData = pFont->GetFontData();
406 rWorksheet->startElement(XML_rPr);
407 XclXmlUtils::WriteFontData( rWorksheet, rFontData, XML_rFont );
408 rWorksheet->endElement( XML_rPr );
409 }
410 rWorksheet->startElement(XML_t, FSNS(XML_xml, XML_space), "preserve");
411 rWorksheet->writeEscaped( XclXmlUtils::ToOUString( rBuffer, nStart, nLength ) );
412 rWorksheet->endElement( XML_t );
413 rWorksheet->endElement( XML_r );
414 return nStart + nLength;
415}
416
418{
419 sax_fastparser::FSHelperPtr rWorksheet = rStrm.GetCurrentStream();
420
421 if( !IsWriteFormats() )
422 {
423 rWorksheet->startElement(XML_t, FSNS(XML_xml, XML_space), "preserve");
424 rWorksheet->writeEscaped( XclXmlUtils::ToOUString( *this ) );
425 rWorksheet->endElement( XML_t );
426 }
427 else
428 {
429 XclExpFontBuffer& rFonts = rStrm.GetRoot().GetFontBuffer();
430
431 sal_uInt16 nStart = 0;
432 const XclExpFont* pFont = nullptr;
433 for ( const auto& rFormat : maFormats )
434 {
436 nStart, rFormat.mnChar-nStart, pFont );
437 pFont = rFonts.GetFont( rFormat.mnFontIdx );
438 }
440 nStart, GetUnicodeBuffer().size() - nStart, pFont );
441 }
442}
443
445{
446 return mbIsBiff8 && (!IsEmpty() || !mbSmartFlags);
447}
448
450{
451 return mbIsBiff8 && !mbSkipFormats && IsRich();
452}
453
454void XclExpString::SetStrLen( sal_Int32 nNewLen )
455{
456 sal_uInt16 nAllowedLen = (mb8BitLen && (mnMaxLen > 255)) ? 255 : mnMaxLen;
457 mnLen = limit_cast< sal_uInt16 >( nNewLen, 0, nAllowedLen );
458}
459
460void XclExpString::CharsToBuffer( const sal_Unicode* pcSource, sal_Int32 nBegin, sal_Int32 nLen )
461{
462 OSL_ENSURE( maUniBuffer.size() >= o3tl::make_unsigned( nBegin + nLen ),
463 "XclExpString::CharsToBuffer - char buffer invalid" );
464 ScfUInt16Vec::iterator aBeg = maUniBuffer.begin() + nBegin;
465 ScfUInt16Vec::iterator aEnd = aBeg + nLen;
466 const sal_Unicode* pcSrcChar = pcSource;
467 for( ScfUInt16Vec::iterator aIt = aBeg; aIt != aEnd; ++aIt, ++pcSrcChar )
468 {
469 *aIt = static_cast< sal_uInt16 >( *pcSrcChar );
470 if( *aIt & 0xFF00 )
471 mbIsUnicode = true;
472 }
473 if( !mbWrapped )
474 mbWrapped = ::std::find( aBeg, aEnd, EXC_LF ) != aEnd;
475}
476
477void XclExpString::CharsToBuffer( const char* pcSource, sal_Int32 nBegin, sal_Int32 nLen )
478{
479 OSL_ENSURE( maCharBuffer.size() >= o3tl::make_unsigned( nBegin + nLen ),
480 "XclExpString::CharsToBuffer - char buffer invalid" );
481 ScfUInt8Vec::iterator aBeg = maCharBuffer.begin() + nBegin;
482 ScfUInt8Vec::iterator aEnd = aBeg + nLen;
483 const char* pcSrcChar = pcSource;
484 for( ScfUInt8Vec::iterator aIt = aBeg; aIt != aEnd; ++aIt, ++pcSrcChar )
485 *aIt = static_cast< sal_uInt8 >( *pcSrcChar );
486 mbIsUnicode = false;
487 if( !mbWrapped )
488 mbWrapped = ::std::find( aBeg, aEnd, EXC_LF_C ) != aEnd;
489}
490
491void XclExpString::Init( sal_Int32 nCurrLen, XclStrFlags nFlags, sal_uInt16 nMaxLen, bool bBiff8 )
492{
493 mbIsBiff8 = bBiff8;
494 mbIsUnicode = bBiff8 && ( nFlags & XclStrFlags::ForceUnicode );
495 mb8BitLen = bool( nFlags & XclStrFlags::EightBitLength );
496 mbSmartFlags = bBiff8 && ( nFlags & XclStrFlags::SmartFlags );
498 mbWrapped = false;
499 mbSkipHeader = bool( nFlags & XclStrFlags::NoHeader );
500 mnMaxLen = nMaxLen;
501 SetStrLen( nCurrLen );
502
503 maFormats.clear();
504 if( mbIsBiff8 )
505 {
506 maCharBuffer.clear();
507 maUniBuffer.resize( mnLen );
508 }
509 else
510 {
511 maUniBuffer.clear();
512 maCharBuffer.resize( mnLen );
513 }
514}
515
516void XclExpString::Build( const sal_Unicode* pcSource, sal_Int32 nCurrLen, XclStrFlags nFlags, sal_uInt16 nMaxLen )
517{
518 Init( nCurrLen, nFlags, nMaxLen, true );
519 CharsToBuffer( pcSource, 0, mnLen );
520}
521
522void XclExpString::Build( const char* pcSource, sal_Int32 nCurrLen, XclStrFlags nFlags, sal_uInt16 nMaxLen )
523{
524 Init( nCurrLen, nFlags, nMaxLen, false );
525 CharsToBuffer( pcSource, 0, mnLen );
526}
527
528void XclExpString::InitAppend( sal_Int32 nAddLen )
529{
530 SetStrLen( static_cast< sal_Int32 >( mnLen ) + nAddLen );
531 if( mbIsBiff8 )
532 maUniBuffer.resize( mnLen );
533 else
534 maCharBuffer.resize( mnLen );
535}
536
537void XclExpString::BuildAppend( std::u16string_view rSource )
538{
539 OSL_ENSURE( mbIsBiff8, "XclExpString::BuildAppend - must not be called at byte strings" );
540 if( mbIsBiff8 )
541 {
542 sal_uInt16 nOldLen = mnLen;
543 InitAppend( rSource.size() );
544 CharsToBuffer( rSource.data(), nOldLen, mnLen - nOldLen );
545 }
546}
547
548void XclExpString::BuildAppend( std::string_view rSource )
549{
550 OSL_ENSURE( !mbIsBiff8, "XclExpString::BuildAppend - must not be called at unicode strings" );
551 if( !mbIsBiff8 )
552 {
553 sal_uInt16 nOldLen = mnLen;
554 InitAppend( rSource.size() );
555 CharsToBuffer( rSource.data(), nOldLen, mnLen - nOldLen );
556 }
557}
558
559void XclExpString::PrepareWrite( XclExpStream& rStrm, sal_uInt16 nBytes ) const
560{
561 rStrm.SetSliceSize( nBytes + (mbIsUnicode ? 2 : 1) );
562}
563
564/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Stores the data of all fonts used in the document.
Definition: xestyle.hxx:208
const XclExpFont * GetFont(sal_uInt16 nXclFont) const
Returns the specified font from font list.
Definition: xestyle.cxx:1183
Stores all data of an Excel font and provides export of FONT records.
Definition: xestyle.hxx:155
const XclFontData & GetFontData() const
Returns read-only access to font data.
Definition: xestyle.hxx:161
This class is used to export Excel record streams.
Definition: xestream.hxx:73
This class stores an unformatted or formatted string for Excel export.
Definition: xestring.hxx:48
void WriteHeader(XclExpStream &rStrm) const
Writes 8-bit or 16-bit length field and string flags field.
Definition: xestring.cxx:289
bool mb8BitLen
true, if at least one character is >0xFF.
Definition: xestring.hxx:236
bool IsEmpty() const
Returns true, if the string is empty.
Definition: xestring.hxx:120
void WriteFlagField(XclExpStream &rStrm) const
Writes the string flags field (1 byte).
Definition: xestring.cxx:279
void AppendByte(std::u16string_view rString, rtl_TextEncoding eTextEnc)
Appends a string.
Definition: xestring.cxx:137
sal_uInt8 GetFlagField() const
Returns the current string flags field to export.
Definition: xestring.cxx:230
void InitAppend(sal_Int32 nAddLen)
Initializes string length and resizes character buffers for appending operation.
Definition: xestring.cxx:528
void Build(const sal_Unicode *pcSource, sal_Int32 nCurrLen, XclStrFlags nFlags, sal_uInt16 nMaxLen)
Creates the character buffer from the given Unicode array.
Definition: xestring.cxx:516
ScfUInt8Vec maCharBuffer
The Unicode character buffer.
Definition: xestring.hxx:230
void AppendFormat(sal_uInt16 nChar, sal_uInt16 nFontIdx, bool bDropDuplicate=true)
Appends a formatting run.
Definition: xestring.cxx:162
void WriteLenField(XclExpStream &rStrm) const
Writes the string length field (1 byte or 2 bytes).
Definition: xestring.cxx:271
void WriteBufferToMem(sal_uInt8 *pnMem) const
Writes the raw character buffer to memory (8-bit or 16-bit little-endian).
Definition: xestring.cxx:366
void WriteToMem(sal_uInt8 *pnMem) const
Writes the entire string to memory.
Definition: xestring.cxx:389
bool mbSmartFlags
true = write 8-bit string length; false = 16-bit.
Definition: xestring.hxx:237
bool mbSkipHeader
true = text contains several paragraphs.
Definition: xestring.hxx:240
sal_uInt16 GetFormatsCount() const
Returns the current count of formatting runs for rich strings.
Definition: xestring.cxx:225
XclExpString(XclStrFlags nFlags=XclStrFlags::NONE, sal_uInt16 nMaxLen=EXC_STR_MAXLEN)
Constructs an empty BIFF8 Unicode string.
Definition: xestring.cxx:99
void Append(std::u16string_view rString)
Appends a string.
Definition: xestring.cxx:132
void AssignByte(std::u16string_view rString, rtl_TextEncoding eTextEnc, XclStrFlags nFlags=XclStrFlags::NONE, sal_uInt16 nMaxLen=EXC_STR_MAXLEN)
Assigns an unformatted string, converts this object to a BIFF2-BIFF7 byte string.
Definition: xestring.cxx:121
void Init(sal_Int32 nCurrLen, XclStrFlags nFlags, sal_uInt16 nMaxLen, bool bBiff8)
Initializes flags, string length, and resizes character buffer.
Definition: xestring.cxx:491
void CharsToBuffer(const sal_Unicode *pcSource, sal_Int32 nBegin, sal_Int32 nLen)
Inserts the passed character array into the internal character buffer.
Definition: xestring.cxx:460
void SetStrLen(sal_Int32 nNewLen)
Sets the string length but regards the limit given in mnMaxLen.
Definition: xestring.cxx:454
void PrepareWrite(XclExpStream &rStrm, sal_uInt16 nBytes) const
Initializes write process on stream.
Definition: xestring.cxx:559
ScfUInt16Vec maUniBuffer
Definition: xestring.hxx:229
sal_uInt16 GetHeaderSize() const
Returns the byte count the header will take on export.
Definition: xestring.cxx:235
void Assign(const OUString &rString, XclStrFlags nFlags=XclStrFlags::NONE, sal_uInt16 nMaxLen=EXC_STR_MAXLEN)
Assigns an unformatted string, converts this object to a BIFF8 Unicode string.
Definition: xestring.cxx:111
sal_uInt16 mnLen
All formatting runs.
Definition: xestring.hxx:232
bool mbIsUnicode
true = BIFF8 Unicode string, false = BIFF2-7 bytestring.
Definition: xestring.hxx:235
bool IsEqual(const XclExpString &rCmp) const
Returns true, if this string is equal to the passed string.
Definition: xestring.cxx:201
sal_uInt16 mnMaxLen
Character count to export.
Definition: xestring.hxx:233
bool mbWrapped
true = skip formats on export; false = write complete formatted string.
Definition: xestring.hxx:239
bool IsLessThan(const XclExpString &rCmp) const
Returns true, if this string is less than the passed string.
Definition: xestring.cxx:215
bool IsRich() const
Returns true, if the string contains formatting information.
Definition: xestring.hxx:129
void WriteFormats(XclExpStream &rStrm, bool bWriteSize=false) const
Writes the raw formatting run buffer.
Definition: xestring.cxx:312
std::size_t GetSize() const
Returns the byte count the whole string will take on export.
Definition: xestring.cxx:248
void LimitFormatCount(sal_uInt16 nMaxCount)
Removes formatting runs at the end, if the string contains too much.
Definition: xestring.cxx:175
sal_uInt16 GetLeadingFont()
Returns the font index of the first char in the formatting run, or EXC_FONT_NOTFOUND.
Definition: xestring.cxx:181
void BuildAppend(std::u16string_view)
Appends the given Unicode array to the character buffer.
Definition: xestring.cxx:537
XclFormatRunVec maFormats
The byte character buffer.
Definition: xestring.hxx:231
sal_uInt16 GetHash() const
Returns a hash value for the string.
Definition: xestring.cxx:262
std::size_t GetBufferSize() const
Returns the byte count the character buffer will take on export.
Definition: xestring.cxx:243
void WriteXml(XclExpXmlStream &rStrm) const
Definition: xestring.cxx:417
void WriteBuffer(XclExpStream &rStrm) const
Writes the raw character buffer.
Definition: xestring.cxx:304
sal_uInt16 Len() const
Returns the character count of the string.
Definition: xestring.hxx:118
void AppendTrailingFormat(sal_uInt16 nFontIdx)
Appends a trailing formatting run with the passed font index.
Definition: xestring.cxx:170
sal_uInt16 RemoveLeadingFont()
The same as above + additionally remove the given font from the formatting run.
Definition: xestring.cxx:191
bool mbSkipFormats
true = omit flags on empty string; false = always write flags.
Definition: xestring.hxx:238
bool mbIsBiff8
Maximum allowed number of characters.
Definition: xestring.hxx:234
sal_uInt16 GetChar(sal_uInt16 nCharIdx) const
Returns the specified character from the (already encoded) string.
Definition: xestring.cxx:256
void WriteHeaderToMem(sal_uInt8 *pnMem) const
Writes the string header to memory.
Definition: xestring.cxx:345
bool IsWriteFormats() const
Returns true, if the formatting run vector should be written.
Definition: xestring.cxx:449
const ScfUInt16Vec & GetUnicodeBuffer() const
Definition: xestring.hxx:149
bool IsWriteFlags() const
Returns true, if the flag field should be written.
Definition: xestring.cxx:444
void Write(XclExpStream &rStrm) const
Writes the complete Unicode string.
Definition: xestring.cxx:336
static sax_fastparser::FSHelperPtr WriteFontData(sax_fastparser::FSHelperPtr pStream, const XclFontData &rFontData, sal_Int32 nNameId)
Definition: xestream.cxx:868
static OUString ToOUString(const char *s)
Definition: xestream.cxx:785
constexpr sal_Int32 FSNS(sal_Int32 namespc, sal_Int32 element)
::std::vector< sal_uInt16 > ScfUInt16Vec
Definition: ftools.hxx:255
size
Type
void SvStream & rStrm
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::shared_ptr< FastSerializerHelper > FSHelperPtr
This struct helps reading and writing Excel fonts.
Definition: xlstyle.hxx:286
NUL character (unicode).
Definition: xlstring.hxx:65
sal_uInt16 mnChar
Definition: xlstring.hxx:66
sal_uInt16 mnFontIdx
First character this format applies to.
Definition: xlstring.hxx:67
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
static sal_uInt16 lcl_WriteRun(XclExpXmlStream &rStrm, const ScfUInt16Vec &rBuffer, sal_uInt16 nStart, sal_Int32 nLength, const XclExpFont *pFont)
Definition: xestring.cxx:395
const sal_uInt16 EXC_LF
LF character (used for line break).
Definition: xlstring.hxx:52
const sal_uInt8 EXC_STRF_RICH
Definition: xlstring.hxx:47
const sal_uInt16 EXC_STR_MAXLEN_8BIT
Definition: xlstring.hxx:42
const sal_uInt16 EXC_STR_MAXLEN
Definition: xlstring.hxx:43
const sal_uInt8 EXC_LF_C
Definition: xlstring.hxx:51
XclStrFlags
Flags used to specify import/export mode of strings.
Definition: xlstring.hxx:29
@ EightBitLength
Always use UCS-2 characters (default: try to compress). BIFF8 only.
@ NoHeader
Import: Keep old formats when reading unformatted string (default: clear formats); Export: Write unfo...
@ SeparateFormats
Omit flags on empty string (default: read/write always). BIFF8 only.
@ ForceUnicode
Default string settings.
@ SmartFlags
8-bit string length field (default: 16-bit).
const sal_uInt8 EXC_STRF_16BIT
Definition: xlstring.hxx:45
const sal_uInt16 EXC_FONT_NOTFOUND
Application font index.
Definition: xlstyle.hxx:77
sal_Int32 nLength