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 char cByteChar = 0;
152 BuildAppend( std::string_view(&cByteChar, 1) );
153 }
154 else
155 {
156 OString aByteStr( &cChar, 1, eTextEnc ); // length may be >1
157 BuildAppend( aByteStr );
158 }
159}
160
161// formatting runs ------------------------------------------------------------
162
163void XclExpString::AppendFormat( sal_uInt16 nChar, sal_uInt16 nFontIdx, bool bDropDuplicate )
164{
165 OSL_ENSURE( maFormats.empty() || (maFormats.back().mnChar < nChar), "XclExpString::AppendFormat - invalid char index" );
166 size_t nMaxSize = static_cast< size_t >( mbIsBiff8 ? EXC_STR_MAXLEN : EXC_STR_MAXLEN_8BIT );
167 if( maFormats.empty() || ((maFormats.size() < nMaxSize) && (!bDropDuplicate || (maFormats.back().mnFontIdx != nFontIdx))) )
168 maFormats.emplace_back( nChar, nFontIdx );
169}
170
171void XclExpString::AppendTrailingFormat( sal_uInt16 nFontIdx )
172{
173 AppendFormat( mnLen, nFontIdx, false );
174}
175
176void XclExpString::LimitFormatCount( sal_uInt16 nMaxCount )
177{
178 if( maFormats.size() > nMaxCount )
179 maFormats.erase( maFormats.begin() + nMaxCount, maFormats.end() );
180}
181
183{
184 sal_uInt16 nFontIdx = EXC_FONT_NOTFOUND;
185 if( !maFormats.empty() && (maFormats.front().mnChar == 0) )
186 {
187 nFontIdx = maFormats.front().mnFontIdx;
188 }
189 return nFontIdx;
190}
191
193{
194 sal_uInt16 nFontIdx = GetLeadingFont();
195 if( nFontIdx != EXC_FONT_NOTFOUND )
196 {
197 maFormats.erase( maFormats.begin() );
198 }
199 return nFontIdx;
200}
201
202bool XclExpString::IsEqual( const XclExpString& rCmp ) const
203{
204 return
205 (mnLen == rCmp.mnLen) &&
206 (mbIsBiff8 == rCmp.mbIsBiff8) &&
207 (mbIsUnicode == rCmp.mbIsUnicode) &&
208 (mbWrapped == rCmp.mbWrapped) &&
209 (
210 ( mbIsBiff8 && (maUniBuffer == rCmp.maUniBuffer)) ||
211 (!mbIsBiff8 && (maCharBuffer == rCmp.maCharBuffer))
212 ) &&
213 (maFormats == rCmp.maFormats);
214}
215
216bool XclExpString::IsLessThan( const XclExpString& rCmp ) const
217{
218 int nResult = mbIsBiff8 ?
219 lclCompareVectors( maUniBuffer, rCmp.maUniBuffer ) :
220 lclCompareVectors( maCharBuffer, rCmp.maCharBuffer );
221 return (nResult != 0) ? (nResult < 0) : (maFormats < rCmp.maFormats);
222}
223
224// get data -------------------------------------------------------------------
225
227{
228 return static_cast< sal_uInt16 >( maFormats.size() );
229}
230
232{
233 return (mbIsUnicode ? EXC_STRF_16BIT : 0) | (IsWriteFormats() ? EXC_STRF_RICH : 0);
234}
235
237{
238 return
239 (mb8BitLen ? 1 : 2) + // length field
240 (IsWriteFlags() ? 1 : 0) + // flag field
241 (IsWriteFormats() ? 2 : 0); // richtext formatting count
242}
243
245{
246 return static_cast<std::size_t>(mnLen) * (mbIsUnicode ? 2 : 1);
247}
248
249std::size_t XclExpString::GetSize() const
250{
251 return
252 GetHeaderSize() + // header
253 GetBufferSize() + // character buffer
254 (IsWriteFormats() ? (4 * GetFormatsCount()) : 0); // richtext formatting
255}
256
257sal_uInt16 XclExpString::GetChar( sal_uInt16 nCharIdx ) const
258{
259 OSL_ENSURE( nCharIdx < Len(), "XclExpString::GetChar - invalid character index" );
260 return static_cast< sal_uInt16 >( mbIsBiff8 ? maUniBuffer[ nCharIdx ] : maCharBuffer[ nCharIdx ] );
261}
262
263sal_uInt16 XclExpString::GetHash() const
264{
265 return
266 (mbIsBiff8 ? lclHashVector( maUniBuffer ) : lclHashVector( maCharBuffer )) ^
267 lclHashVector( maFormats, XclFormatRunHasher() );
268}
269
270// streaming ------------------------------------------------------------------
271
273{
274 if( mb8BitLen )
275 rStrm << static_cast< sal_uInt8 >( mnLen );
276 else
277 rStrm << mnLen;
278}
279
281{
282 if( mbIsBiff8 )
283 {
284 PrepareWrite( rStrm, 1 );
285 rStrm << GetFlagField();
286 rStrm.SetSliceSize( 0 );
287 }
288}
289
291{
292 OSL_ENSURE( !mb8BitLen || (mnLen < 256), "XclExpString::WriteHeader - string too long" );
294 // length
296 // flag field
297 if( IsWriteFlags() )
298 rStrm << GetFlagField();
299 // format run count
300 if( IsWriteFormats() )
302 rStrm.SetSliceSize( 0 );
303}
304
306{
307 if( mbIsBiff8 )
308 rStrm.WriteUnicodeBuffer( maUniBuffer, GetFlagField() );
309 else
310 rStrm.WriteCharBuffer( maCharBuffer );
311}
312
313void XclExpString::WriteFormats( XclExpStream& rStrm, bool bWriteSize ) const
314{
315 if( !IsRich() )
316 return;
317
318 if( mbIsBiff8 )
319 {
320 if( bWriteSize )
322 rStrm.SetSliceSize( 4 );
323 for( const auto& rFormat : maFormats )
324 rStrm << rFormat.mnChar << rFormat.mnFontIdx;
325 }
326 else
327 {
328 if( bWriteSize )
329 rStrm << static_cast< sal_uInt8 >( GetFormatsCount() );
330 rStrm.SetSliceSize( 2 );
331 for( const auto& rFormat : maFormats )
332 rStrm << static_cast< sal_uInt8 >( rFormat.mnChar ) << static_cast< sal_uInt8 >( rFormat.mnFontIdx );
333 }
334 rStrm.SetSliceSize( 0 );
335}
336
338{
339 if (!mbSkipHeader)
342 if( IsWriteFormats() ) // only in BIFF8 included in string
344}
345
347{
348 assert(pnMem);
349 OSL_ENSURE( !mb8BitLen || (mnLen < 256), "XclExpString::WriteHeaderToMem - string too long" );
350 OSL_ENSURE( !IsWriteFormats(), "XclExpString::WriteHeaderToMem - formatted strings not supported" );
351 // length
352 if( mb8BitLen )
353 {
354 *pnMem = static_cast< sal_uInt8 >( mnLen );
355 ++pnMem;
356 }
357 else
358 {
359 ShortToSVBT16( mnLen, pnMem );
360 pnMem += 2;
361 }
362 // flag field
363 if( IsWriteFlags() )
364 *pnMem = GetFlagField();
365}
366
368{
369 assert(pnMem);
370 if( IsEmpty() )
371 return;
372
373 if( mbIsBiff8 )
374 {
375 for( const sal_uInt16 nChar : maUniBuffer )
376 {
377 *pnMem = static_cast< sal_uInt8 >( nChar );
378 ++pnMem;
379 if( mbIsUnicode )
380 {
381 *pnMem = static_cast< sal_uInt8 >( nChar >> 8 );
382 ++pnMem;
383 }
384 }
385 }
386 else
387 memcpy( pnMem, maCharBuffer.data(), mnLen );
388}
389
391{
392 WriteHeaderToMem( pnMem );
393 WriteBufferToMem( pnMem + GetHeaderSize() );
394}
395
396static sal_uInt16 lcl_WriteRun( XclExpXmlStream& rStrm, const ScfUInt16Vec& rBuffer, sal_uInt16 nStart, sal_Int32 nLength, const XclExpFont* pFont )
397{
398 if( nLength == 0 )
399 return nStart;
400
401 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
402
403 rWorksheet->startElement(XML_r);
404 if( pFont )
405 {
406 const XclFontData& rFontData = pFont->GetFontData();
407 rWorksheet->startElement(XML_rPr);
408 XclXmlUtils::WriteFontData( rWorksheet, rFontData, XML_rFont );
409 rWorksheet->endElement( XML_rPr );
410 }
411 rWorksheet->startElement(XML_t, FSNS(XML_xml, XML_space), "preserve");
412 rWorksheet->writeEscaped( XclXmlUtils::ToOUString( rBuffer, nStart, nLength ) );
413 rWorksheet->endElement( XML_t );
414 rWorksheet->endElement( XML_r );
415 return nStart + nLength;
416}
417
419{
420 sax_fastparser::FSHelperPtr rWorksheet = rStrm.GetCurrentStream();
421
422 if( !IsWriteFormats() )
423 {
424 rWorksheet->startElement(XML_t, FSNS(XML_xml, XML_space), "preserve");
425 rWorksheet->writeEscaped( XclXmlUtils::ToOUString( *this ) );
426 rWorksheet->endElement( XML_t );
427 }
428 else
429 {
430 XclExpFontBuffer& rFonts = rStrm.GetRoot().GetFontBuffer();
431
432 sal_uInt16 nStart = 0;
433 const XclExpFont* pFont = nullptr;
434 for ( const auto& rFormat : maFormats )
435 {
437 nStart, rFormat.mnChar-nStart, pFont );
438 pFont = rFonts.GetFont( rFormat.mnFontIdx );
439 }
441 nStart, GetUnicodeBuffer().size() - nStart, pFont );
442 }
443}
444
446{
447 return mbIsBiff8 && (!IsEmpty() || !mbSmartFlags);
448}
449
451{
452 return mbIsBiff8 && !mbSkipFormats && IsRich();
453}
454
455void XclExpString::SetStrLen( sal_Int32 nNewLen )
456{
457 sal_uInt16 nAllowedLen = (mb8BitLen && (mnMaxLen > 255)) ? 255 : mnMaxLen;
458 mnLen = limit_cast< sal_uInt16 >( nNewLen, 0, nAllowedLen );
459}
460
461void XclExpString::CharsToBuffer( const sal_Unicode* pcSource, sal_Int32 nBegin, sal_Int32 nLen )
462{
463 OSL_ENSURE( maUniBuffer.size() >= o3tl::make_unsigned( nBegin + nLen ),
464 "XclExpString::CharsToBuffer - char buffer invalid" );
465 ScfUInt16Vec::iterator aBeg = maUniBuffer.begin() + nBegin;
466 ScfUInt16Vec::iterator aEnd = aBeg + nLen;
467 const sal_Unicode* pcSrcChar = pcSource;
468 for( ScfUInt16Vec::iterator aIt = aBeg; aIt != aEnd; ++aIt, ++pcSrcChar )
469 {
470 *aIt = static_cast< sal_uInt16 >( *pcSrcChar );
471 if( *aIt & 0xFF00 )
472 mbIsUnicode = true;
473 }
474 if( !mbWrapped )
475 mbWrapped = ::std::find( aBeg, aEnd, EXC_LF ) != aEnd;
476}
477
478void XclExpString::CharsToBuffer( const char* pcSource, sal_Int32 nBegin, sal_Int32 nLen )
479{
480 OSL_ENSURE( maCharBuffer.size() >= o3tl::make_unsigned( nBegin + nLen ),
481 "XclExpString::CharsToBuffer - char buffer invalid" );
482 ScfUInt8Vec::iterator aBeg = maCharBuffer.begin() + nBegin;
483 ScfUInt8Vec::iterator aEnd = aBeg + nLen;
484 const char* pcSrcChar = pcSource;
485 for( ScfUInt8Vec::iterator aIt = aBeg; aIt != aEnd; ++aIt, ++pcSrcChar )
486 *aIt = static_cast< sal_uInt8 >( *pcSrcChar );
487 mbIsUnicode = false;
488 if( !mbWrapped )
489 mbWrapped = ::std::find( aBeg, aEnd, EXC_LF_C ) != aEnd;
490}
491
492void XclExpString::Init( sal_Int32 nCurrLen, XclStrFlags nFlags, sal_uInt16 nMaxLen, bool bBiff8 )
493{
494 mbIsBiff8 = bBiff8;
495 mbIsUnicode = bBiff8 && ( nFlags & XclStrFlags::ForceUnicode );
496 mb8BitLen = bool( nFlags & XclStrFlags::EightBitLength );
497 mbSmartFlags = bBiff8 && ( nFlags & XclStrFlags::SmartFlags );
499 mbWrapped = false;
500 mbSkipHeader = bool( nFlags & XclStrFlags::NoHeader );
501 mnMaxLen = nMaxLen;
502 SetStrLen( nCurrLen );
503
504 maFormats.clear();
505 if( mbIsBiff8 )
506 {
507 maCharBuffer.clear();
508 maUniBuffer.resize( mnLen );
509 }
510 else
511 {
512 maUniBuffer.clear();
513 maCharBuffer.resize( mnLen );
514 }
515}
516
517void XclExpString::Build( const sal_Unicode* pcSource, sal_Int32 nCurrLen, XclStrFlags nFlags, sal_uInt16 nMaxLen )
518{
519 Init( nCurrLen, nFlags, nMaxLen, true );
520 CharsToBuffer( pcSource, 0, mnLen );
521}
522
523void XclExpString::Build( const char* pcSource, sal_Int32 nCurrLen, XclStrFlags nFlags, sal_uInt16 nMaxLen )
524{
525 Init( nCurrLen, nFlags, nMaxLen, false );
526 CharsToBuffer( pcSource, 0, mnLen );
527}
528
529void XclExpString::InitAppend( sal_Int32 nAddLen )
530{
531 SetStrLen( static_cast< sal_Int32 >( mnLen ) + nAddLen );
532 if( mbIsBiff8 )
533 maUniBuffer.resize( mnLen );
534 else
535 maCharBuffer.resize( mnLen );
536}
537
538void XclExpString::BuildAppend( std::u16string_view rSource )
539{
540 OSL_ENSURE( mbIsBiff8, "XclExpString::BuildAppend - must not be called at byte strings" );
541 if( mbIsBiff8 )
542 {
543 sal_uInt16 nOldLen = mnLen;
544 InitAppend( rSource.size() );
545 CharsToBuffer( rSource.data(), nOldLen, mnLen - nOldLen );
546 }
547}
548
549void XclExpString::BuildAppend( std::string_view rSource )
550{
551 OSL_ENSURE( !mbIsBiff8, "XclExpString::BuildAppend - must not be called at unicode strings" );
552 if( !mbIsBiff8 )
553 {
554 sal_uInt16 nOldLen = mnLen;
555 InitAppend( rSource.size() );
556 CharsToBuffer( rSource.data(), nOldLen, mnLen - nOldLen );
557 }
558}
559
560void XclExpString::PrepareWrite( XclExpStream& rStrm, sal_uInt16 nBytes ) const
561{
562 rStrm.SetSliceSize( nBytes + (mbIsUnicode ? 2 : 1) );
563}
564
565/* 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:290
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:280
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:231
void InitAppend(sal_Int32 nAddLen)
Initializes string length and resizes character buffers for appending operation.
Definition: xestring.cxx:529
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:517
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:163
void WriteLenField(XclExpStream &rStrm) const
Writes the string length field (1 byte or 2 bytes).
Definition: xestring.cxx:272
void WriteBufferToMem(sal_uInt8 *pnMem) const
Writes the raw character buffer to memory (8-bit or 16-bit little-endian).
Definition: xestring.cxx:367
void WriteToMem(sal_uInt8 *pnMem) const
Writes the entire string to memory.
Definition: xestring.cxx:390
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:226
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:492
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:461
void SetStrLen(sal_Int32 nNewLen)
Sets the string length but regards the limit given in mnMaxLen.
Definition: xestring.cxx:455
void PrepareWrite(XclExpStream &rStrm, sal_uInt16 nBytes) const
Initializes write process on stream.
Definition: xestring.cxx:560
ScfUInt16Vec maUniBuffer
Definition: xestring.hxx:229
sal_uInt16 GetHeaderSize() const
Returns the byte count the header will take on export.
Definition: xestring.cxx:236
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:202
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:216
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:313
std::size_t GetSize() const
Returns the byte count the whole string will take on export.
Definition: xestring.cxx:249
void LimitFormatCount(sal_uInt16 nMaxCount)
Removes formatting runs at the end, if the string contains too much.
Definition: xestring.cxx:176
sal_uInt16 GetLeadingFont()
Returns the font index of the first char in the formatting run, or EXC_FONT_NOTFOUND.
Definition: xestring.cxx:182
void BuildAppend(std::u16string_view)
Appends the given Unicode array to the character buffer.
Definition: xestring.cxx:538
XclFormatRunVec maFormats
The byte character buffer.
Definition: xestring.hxx:231
sal_uInt16 GetHash() const
Returns a hash value for the string.
Definition: xestring.cxx:263
std::size_t GetBufferSize() const
Returns the byte count the character buffer will take on export.
Definition: xestring.cxx:244
void WriteXml(XclExpXmlStream &rStrm) const
Definition: xestring.cxx:418
void WriteBuffer(XclExpStream &rStrm) const
Writes the raw character buffer.
Definition: xestring.cxx:305
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:171
sal_uInt16 RemoveLeadingFont()
The same as above + additionally remove the given font from the formatting run.
Definition: xestring.cxx:192
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:257
void WriteHeaderToMem(sal_uInt8 *pnMem) const
Writes the string header to memory.
Definition: xestring.cxx:346
bool IsWriteFormats() const
Returns true, if the formatting run vector should be written.
Definition: xestring.cxx:450
const ScfUInt16Vec & GetUnicodeBuffer() const
Definition: xestring.hxx:149
bool IsWriteFlags() const
Returns true, if the flag field should be written.
Definition: xestring.cxx:445
void Write(XclExpStream &rStrm) const
Writes the complete Unicode string.
Definition: xestring.cxx:337
static sax_fastparser::FSHelperPtr WriteFontData(sax_fastparser::FSHelperPtr pStream, const XclFontData &rFontData, sal_Int32 nNameId)
Definition: xestream.cxx:871
static OUString ToOUString(const char *s)
Definition: xestream.cxx:788
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:284
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:396
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