Line data Source code
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 :
21 : #include <algorithm>
22 : #include <stdio.h>
23 : #include "xlstyle.hxx"
24 : #include "xestyle.hxx"
25 : #include "xestream.hxx"
26 : #include "xestring.hxx"
27 :
28 : using namespace ::oox;
29 :
30 :
31 : namespace {
32 :
33 : // compare vectors
34 :
35 : /** Compares two vectors.
36 : @return A negative value, if rLeft<rRight; or a positive value, if rLeft>rRight;
37 : or 0, if rLeft==rRight. */
38 : template< typename Type >
39 0 : int lclCompareVectors( const ::std::vector< Type >& rLeft, const ::std::vector< Type >& rRight )
40 : {
41 0 : int nResult = 0;
42 :
43 : // 1st: compare all elements of the vectors
44 : typedef typename ::std::vector< Type >::const_iterator CIT;
45 0 : CIT aEndL = rLeft.end(), aEndR = rRight.end();
46 0 : for( CIT aItL = rLeft.begin(), aItR = rRight.begin(); !nResult && (aItL != aEndL) && (aItR != aEndR); ++aItL, ++aItR )
47 0 : nResult = static_cast< int >( *aItL ) - static_cast< int >( *aItR );
48 :
49 : // 2nd: no differences found so far -> compare the vector sizes. Shorter vector is less
50 0 : if( !nResult )
51 0 : nResult = static_cast< int >( rLeft.size() ) - static_cast< int >( rRight.size() );
52 :
53 0 : return nResult;
54 : }
55 :
56 : // hashing helpers
57 :
58 : /** Base class for value hashers.
59 : @descr These function objects are used to hash any value to a sal_uInt32 value. */
60 : template< typename Type >
61 : struct XclHasher : public ::std::unary_function< Type, sal_uInt32 > {};
62 :
63 : template< typename Type >
64 : struct XclDirectHasher : public XclHasher< Type >
65 : {
66 0 : inline sal_uInt32 operator()( Type nVal ) const { return nVal; }
67 : };
68 :
69 : struct XclFormatRunHasher : public XclHasher< const XclFormatRun& >
70 : {
71 0 : inline sal_uInt32 operator()( const XclFormatRun& rRun ) const
72 0 : { return (rRun.mnChar << 8) ^ rRun.mnFontIdx; }
73 : };
74 :
75 : /** Calculates a hash value from a vector.
76 : @descr Uses the passed hasher function object to calculate hash values from
77 : all vector elements. */
78 : template< typename Type, typename ValueHasher >
79 0 : sal_uInt16 lclHashVector( const ::std::vector< Type >& rVec, const ValueHasher& rHasher )
80 : {
81 0 : sal_uInt32 nHash = rVec.size();
82 : typedef typename ::std::vector< Type >::const_iterator CIT;
83 0 : for( CIT aIt = rVec.begin(), aEnd = rVec.end(); aIt != aEnd; ++aIt )
84 0 : (nHash *= 31) += rHasher( *aIt );
85 0 : return static_cast< sal_uInt16 >( nHash ^ (nHash >> 16) );
86 : }
87 :
88 : /** Calculates a hash value from a vector. Uses XclDirectHasher to hash the vector elements. */
89 : template< typename Type >
90 0 : inline sal_uInt16 lclHashVector( const ::std::vector< Type >& rVec )
91 : {
92 0 : return lclHashVector( rVec, XclDirectHasher< Type >() );
93 : }
94 :
95 : } // namespace
96 :
97 : // constructors ---------------------------------------------------------------
98 :
99 0 : XclExpString::XclExpString( XclStrFlags nFlags, sal_uInt16 nMaxLen )
100 : {
101 0 : Init( 0, nFlags, nMaxLen, true );
102 0 : }
103 :
104 0 : XclExpString::XclExpString( const OUString& rString, XclStrFlags nFlags, sal_uInt16 nMaxLen )
105 : {
106 0 : Assign( rString, nFlags, nMaxLen );
107 0 : }
108 :
109 : // assign ---------------------------------------------------------------------
110 :
111 0 : void XclExpString::Assign( const OUString& rString, XclStrFlags nFlags, sal_uInt16 nMaxLen )
112 : {
113 0 : Build( rString.getStr(), rString.getLength(), nFlags, nMaxLen );
114 0 : }
115 :
116 0 : void XclExpString::Assign( sal_Unicode cChar, XclStrFlags nFlags, sal_uInt16 nMaxLen )
117 : {
118 0 : Build( &cChar, 1, nFlags, nMaxLen );
119 0 : }
120 :
121 0 : void XclExpString::AssignByte(
122 : const OUString& rString, rtl_TextEncoding eTextEnc, XclStrFlags nFlags, sal_uInt16 nMaxLen )
123 : {
124 : // length may differ from length of rString
125 0 : OString aByteStr(OUStringToOString(rString, eTextEnc));
126 0 : Build(aByteStr.getStr(), aByteStr.getLength(), nFlags, nMaxLen);
127 0 : }
128 :
129 : // append ---------------------------------------------------------------------
130 :
131 0 : void XclExpString::Append( const OUString& rString )
132 : {
133 0 : BuildAppend( rString.getStr(), rString.getLength() );
134 0 : }
135 :
136 0 : void XclExpString::AppendByte( const OUString& rString, rtl_TextEncoding eTextEnc )
137 : {
138 0 : if (!rString.isEmpty())
139 : {
140 : // length may differ from length of rString
141 0 : OString aByteStr(OUStringToOString(rString, eTextEnc));
142 0 : BuildAppend(aByteStr.getStr(), aByteStr.getLength());
143 : }
144 0 : }
145 :
146 0 : void XclExpString::AppendByte( sal_Unicode cChar, rtl_TextEncoding eTextEnc )
147 : {
148 0 : if( !cChar )
149 : {
150 0 : sal_Char cByteChar = 0;
151 0 : BuildAppend( &cByteChar, 1 );
152 : }
153 : else
154 : {
155 0 : OString aByteStr( &cChar, 1, eTextEnc ); // length may be >1
156 0 : BuildAppend( aByteStr.getStr(), aByteStr.getLength() );
157 : }
158 0 : }
159 :
160 : // formatting runs ------------------------------------------------------------
161 :
162 0 : void 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 0 : size_t nMaxSize = static_cast< size_t >( mbIsBiff8 ? EXC_STR_MAXLEN : EXC_STR_MAXLEN_8BIT );
166 0 : if( maFormats.empty() || ((maFormats.size() < nMaxSize) && (!bDropDuplicate || (maFormats.back().mnFontIdx != nFontIdx))) )
167 0 : maFormats.push_back( XclFormatRun( nChar, nFontIdx ) );
168 0 : }
169 :
170 0 : void XclExpString::AppendTrailingFormat( sal_uInt16 nFontIdx )
171 : {
172 0 : AppendFormat( mnLen, nFontIdx, false );
173 0 : }
174 :
175 0 : void XclExpString::LimitFormatCount( sal_uInt16 nMaxCount )
176 : {
177 0 : if( maFormats.size() > nMaxCount )
178 0 : maFormats.erase( maFormats.begin() + nMaxCount, maFormats.end() );
179 0 : }
180 :
181 0 : sal_uInt16 XclExpString::RemoveLeadingFont()
182 : {
183 0 : sal_uInt16 nFontIdx = EXC_FONT_NOTFOUND;
184 0 : if( !maFormats.empty() && (maFormats.front().mnChar == 0) )
185 : {
186 0 : nFontIdx = maFormats.front().mnFontIdx;
187 0 : maFormats.erase( maFormats.begin() );
188 : }
189 0 : return nFontIdx;
190 : }
191 :
192 0 : bool XclExpString::IsEqual( const XclExpString& rCmp ) const
193 : {
194 : return
195 0 : (mnLen == rCmp.mnLen) &&
196 0 : (mbIsBiff8 == rCmp.mbIsBiff8) &&
197 0 : (mbIsUnicode == rCmp.mbIsUnicode) &&
198 0 : (mbWrapped == rCmp.mbWrapped) &&
199 : (
200 0 : ( mbIsBiff8 && (maUniBuffer == rCmp.maUniBuffer)) ||
201 0 : (!mbIsBiff8 && (maCharBuffer == rCmp.maCharBuffer))
202 0 : ) &&
203 0 : (maFormats == rCmp.maFormats);
204 : }
205 :
206 0 : bool XclExpString::IsLessThan( const XclExpString& rCmp ) const
207 : {
208 : int nResult = mbIsBiff8 ?
209 0 : lclCompareVectors( maUniBuffer, rCmp.maUniBuffer ) :
210 0 : lclCompareVectors( maCharBuffer, rCmp.maCharBuffer );
211 0 : return (nResult != 0) ? (nResult < 0) : (maFormats < rCmp.maFormats);
212 : }
213 :
214 : // get data -------------------------------------------------------------------
215 :
216 0 : sal_uInt16 XclExpString::GetFormatsCount() const
217 : {
218 0 : return static_cast< sal_uInt16 >( maFormats.size() );
219 : }
220 :
221 0 : sal_uInt8 XclExpString::GetFlagField() const
222 : {
223 0 : return (mbIsUnicode ? EXC_STRF_16BIT : 0) | (IsWriteFormats() ? EXC_STRF_RICH : 0);
224 : }
225 :
226 0 : sal_uInt16 XclExpString::GetHeaderSize() const
227 : {
228 : return
229 : (mb8BitLen ? 1 : 2) + // length field
230 0 : (IsWriteFlags() ? 1 : 0) + // flag field
231 0 : (IsWriteFormats() ? 2 : 0); // richtext formattting count
232 : }
233 :
234 0 : sal_Size XclExpString::GetBufferSize() const
235 : {
236 0 : return mnLen * (mbIsUnicode ? 2 : 1);
237 : }
238 :
239 0 : sal_Size XclExpString::GetSize() const
240 : {
241 : return
242 0 : GetHeaderSize() + // header
243 0 : GetBufferSize() + // character buffer
244 0 : (IsWriteFormats() ? (4 * GetFormatsCount()) : 0); // richtext formattting
245 : }
246 :
247 0 : sal_uInt16 XclExpString::GetChar( sal_uInt16 nCharIdx ) const
248 : {
249 : OSL_ENSURE( nCharIdx < Len(), "XclExpString::GetChar - invalid character index" );
250 0 : return static_cast< sal_uInt16 >( mbIsBiff8 ? maUniBuffer[ nCharIdx ] : maCharBuffer[ nCharIdx ] );
251 : }
252 :
253 0 : sal_uInt16 XclExpString::GetHash() const
254 : {
255 : return
256 0 : (mbIsBiff8 ? lclHashVector( maUniBuffer ) : lclHashVector( maCharBuffer )) ^
257 0 : lclHashVector( maFormats, XclFormatRunHasher() );
258 : }
259 :
260 : // streaming ------------------------------------------------------------------
261 :
262 0 : void XclExpString::WriteLenField( XclExpStream& rStrm ) const
263 : {
264 0 : if( mb8BitLen )
265 0 : rStrm << static_cast< sal_uInt8 >( mnLen );
266 : else
267 0 : rStrm << mnLen;
268 0 : }
269 :
270 0 : void XclExpString::WriteFlagField( XclExpStream& rStrm ) const
271 : {
272 0 : if( mbIsBiff8 )
273 : {
274 0 : PrepareWrite( rStrm, 1 );
275 0 : rStrm << GetFlagField();
276 0 : rStrm.SetSliceSize( 0 );
277 : }
278 0 : }
279 :
280 0 : void XclExpString::WriteHeader( XclExpStream& rStrm ) const
281 : {
282 : OSL_ENSURE( !mb8BitLen || (mnLen < 256), "XclExpString::WriteHeader - string too long" );
283 0 : PrepareWrite( rStrm, GetHeaderSize() );
284 : // length
285 0 : WriteLenField( rStrm );
286 : // flag field
287 0 : if( IsWriteFlags() )
288 0 : rStrm << GetFlagField();
289 : // format run count
290 0 : if( IsWriteFormats() )
291 0 : rStrm << GetFormatsCount();
292 0 : rStrm.SetSliceSize( 0 );
293 0 : }
294 :
295 0 : void XclExpString::WriteBuffer( XclExpStream& rStrm ) const
296 : {
297 0 : if( mbIsBiff8 )
298 0 : rStrm.WriteUnicodeBuffer( maUniBuffer, GetFlagField() );
299 : else
300 0 : rStrm.WriteCharBuffer( maCharBuffer );
301 0 : }
302 :
303 0 : void XclExpString::WriteFormats( XclExpStream& rStrm, bool bWriteSize ) const
304 : {
305 0 : if( IsRich() )
306 : {
307 0 : XclFormatRunVec::const_iterator aIt = maFormats.begin(), aEnd = maFormats.end();
308 0 : if( mbIsBiff8 )
309 : {
310 0 : if( bWriteSize )
311 0 : rStrm << GetFormatsCount();
312 0 : rStrm.SetSliceSize( 4 );
313 0 : for( ; aIt != aEnd; ++aIt )
314 0 : rStrm << aIt->mnChar << aIt->mnFontIdx;
315 : }
316 : else
317 : {
318 0 : if( bWriteSize )
319 0 : rStrm << static_cast< sal_uInt8 >( GetFormatsCount() );
320 0 : rStrm.SetSliceSize( 2 );
321 0 : for( ; aIt != aEnd; ++aIt )
322 0 : rStrm << static_cast< sal_uInt8 >( aIt->mnChar ) << static_cast< sal_uInt8 >( aIt->mnFontIdx );
323 : }
324 0 : rStrm.SetSliceSize( 0 );
325 : }
326 0 : }
327 :
328 0 : void XclExpString::Write( XclExpStream& rStrm ) const
329 : {
330 0 : if (!mbSkipHeader)
331 0 : WriteHeader( rStrm );
332 0 : WriteBuffer( rStrm );
333 0 : if( IsWriteFormats() ) // only in BIFF8 included in string
334 0 : WriteFormats( rStrm );
335 0 : }
336 :
337 0 : void XclExpString::WriteHeaderToMem( sal_uInt8* pnMem ) const
338 : {
339 : OSL_ENSURE( pnMem, "XclExpString::WriteHeaderToMem - no memory to write to" );
340 : OSL_ENSURE( !mb8BitLen || (mnLen < 256), "XclExpString::WriteHeaderToMem - string too long" );
341 : OSL_ENSURE( !IsWriteFormats(), "XclExpString::WriteHeaderToMem - formatted strings not supported" );
342 : // length
343 0 : if( mb8BitLen )
344 : {
345 0 : *pnMem = static_cast< sal_uInt8 >( mnLen );
346 0 : ++pnMem;
347 : }
348 : else
349 : {
350 0 : ShortToSVBT16( mnLen, pnMem );
351 0 : pnMem += 2;
352 : }
353 : // flag field
354 0 : if( IsWriteFlags() )
355 0 : *pnMem = GetFlagField();
356 0 : }
357 :
358 0 : void XclExpString::WriteBufferToMem( sal_uInt8* pnMem ) const
359 : {
360 : OSL_ENSURE( pnMem, "XclExpString::WriteBufferToMem - no memory to write to" );
361 0 : if( !IsEmpty() )
362 : {
363 0 : if( mbIsBiff8 )
364 : {
365 0 : for( ScfUInt16Vec::const_iterator aIt = maUniBuffer.begin(), aEnd = maUniBuffer.end(); aIt != aEnd; ++aIt )
366 : {
367 0 : sal_uInt16 nChar = *aIt;
368 0 : *pnMem = static_cast< sal_uInt8 >( nChar );
369 0 : ++pnMem;
370 0 : if( mbIsUnicode )
371 : {
372 0 : *pnMem = static_cast< sal_uInt8 >( nChar >> 8 );
373 0 : ++pnMem;
374 : }
375 : }
376 : }
377 : else
378 0 : memcpy( pnMem, &maCharBuffer[ 0 ], mnLen );
379 : }
380 0 : }
381 :
382 0 : void XclExpString::WriteToMem( sal_uInt8* pnMem ) const
383 : {
384 0 : WriteHeaderToMem( pnMem );
385 0 : WriteBufferToMem( pnMem + GetHeaderSize() );
386 0 : }
387 :
388 0 : static sal_uInt16 lcl_WriteRun( XclExpXmlStream& rStrm, const ScfUInt16Vec& rBuffer, sal_uInt16 nStart, sal_Int32 nLength, const XclExpFont* pFont )
389 : {
390 0 : if( nLength == 0 )
391 0 : return nStart;
392 :
393 0 : sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
394 :
395 0 : rWorksheet->startElement( XML_r, FSEND );
396 0 : if( pFont )
397 : {
398 0 : const XclFontData& rFontData = pFont->GetFontData();
399 0 : rWorksheet->startElement( XML_rPr, FSEND );
400 0 : XclXmlUtils::WriteFontData( rWorksheet, rFontData, XML_rFont );
401 0 : rWorksheet->endElement( XML_rPr );
402 : }
403 : rWorksheet->startElement( XML_t,
404 0 : FSEND );
405 0 : rWorksheet->writeEscaped( XclXmlUtils::ToOUString( rBuffer, nStart, nLength ) );
406 0 : rWorksheet->endElement( XML_t );
407 0 : rWorksheet->endElement( XML_r );
408 0 : return nStart + nLength;
409 : }
410 :
411 0 : void XclExpString::WriteXml( XclExpXmlStream& rStrm ) const
412 : {
413 0 : sax_fastparser::FSHelperPtr rWorksheet = rStrm.GetCurrentStream();
414 :
415 0 : if( !IsWriteFormats() )
416 : {
417 0 : rWorksheet->startElement( XML_t, FSEND );
418 0 : rWorksheet->writeEscaped( XclXmlUtils::ToOUString( *this ) );
419 0 : rWorksheet->endElement( XML_t );
420 : }
421 : else
422 : {
423 0 : XclExpFontBuffer& rFonts = rStrm.GetRoot().GetFontBuffer();
424 0 : XclFormatRunVec::const_iterator aIt = maFormats.begin(), aEnd = maFormats.end();
425 :
426 0 : sal_uInt16 nStart = 0;
427 0 : const XclExpFont* pFont = NULL;
428 0 : for ( ; aIt != aEnd; ++aIt )
429 : {
430 0 : nStart = lcl_WriteRun( rStrm, GetUnicodeBuffer(),
431 0 : nStart, aIt->mnChar-nStart, pFont );
432 0 : pFont = rFonts.GetFont( aIt->mnFontIdx );
433 : }
434 0 : lcl_WriteRun( rStrm, GetUnicodeBuffer(),
435 0 : nStart, GetUnicodeBuffer().size() - nStart, pFont );
436 0 : }
437 0 : }
438 :
439 0 : bool XclExpString::IsWriteFlags() const
440 : {
441 0 : return mbIsBiff8 && (!IsEmpty() || !mbSmartFlags);
442 : }
443 :
444 0 : bool XclExpString::IsWriteFormats() const
445 : {
446 0 : return mbIsBiff8 && !mbSkipFormats && IsRich();
447 : }
448 :
449 0 : void XclExpString::SetStrLen( sal_Int32 nNewLen )
450 : {
451 0 : sal_uInt16 nAllowedLen = (mb8BitLen && (mnMaxLen > 255)) ? 255 : mnMaxLen;
452 0 : mnLen = limit_cast< sal_uInt16 >( nNewLen, 0, nAllowedLen );
453 0 : }
454 :
455 0 : void XclExpString::CharsToBuffer( const sal_Unicode* pcSource, sal_Int32 nBegin, sal_Int32 nLen )
456 : {
457 : OSL_ENSURE( maUniBuffer.size() >= static_cast< size_t >( nBegin + nLen ),
458 : "XclExpString::CharsToBuffer - char buffer invalid" );
459 0 : ScfUInt16Vec::iterator aBeg = maUniBuffer.begin() + nBegin;
460 0 : ScfUInt16Vec::iterator aEnd = aBeg + nLen;
461 0 : const sal_Unicode* pcSrcChar = pcSource;
462 0 : for( ScfUInt16Vec::iterator aIt = aBeg; aIt != aEnd; ++aIt, ++pcSrcChar )
463 : {
464 0 : *aIt = static_cast< sal_uInt16 >( *pcSrcChar );
465 0 : if( *aIt & 0xFF00 )
466 0 : mbIsUnicode = true;
467 : }
468 0 : if( !mbWrapped )
469 0 : mbWrapped = ::std::find( aBeg, aEnd, EXC_LF ) != aEnd;
470 0 : }
471 :
472 0 : void XclExpString::CharsToBuffer( const sal_Char* pcSource, sal_Int32 nBegin, sal_Int32 nLen )
473 : {
474 : OSL_ENSURE( maCharBuffer.size() >= static_cast< size_t >( nBegin + nLen ),
475 : "XclExpString::CharsToBuffer - char buffer invalid" );
476 0 : ScfUInt8Vec::iterator aBeg = maCharBuffer.begin() + nBegin;
477 0 : ScfUInt8Vec::iterator aEnd = aBeg + nLen;
478 0 : const sal_Char* pcSrcChar = pcSource;
479 0 : for( ScfUInt8Vec::iterator aIt = aBeg; aIt != aEnd; ++aIt, ++pcSrcChar )
480 0 : *aIt = static_cast< sal_uInt8 >( *pcSrcChar );
481 0 : mbIsUnicode = false;
482 0 : if( !mbWrapped )
483 0 : mbWrapped = ::std::find( aBeg, aEnd, EXC_LF_C ) != aEnd;
484 0 : }
485 :
486 0 : void XclExpString::Init( sal_Int32 nCurrLen, XclStrFlags nFlags, sal_uInt16 nMaxLen, bool bBiff8 )
487 : {
488 0 : mbIsBiff8 = bBiff8;
489 0 : mbIsUnicode = bBiff8 && ::get_flag( nFlags, EXC_STR_FORCEUNICODE );
490 0 : mb8BitLen = ::get_flag( nFlags, EXC_STR_8BITLENGTH );
491 0 : mbSmartFlags = bBiff8 && ::get_flag( nFlags, EXC_STR_SMARTFLAGS );
492 0 : mbSkipFormats = ::get_flag( nFlags, EXC_STR_SEPARATEFORMATS );
493 0 : mbWrapped = false;
494 0 : mbSkipHeader = ::get_flag( nFlags, EXC_STR_NOHEADER );
495 0 : mnMaxLen = nMaxLen;
496 0 : SetStrLen( nCurrLen );
497 :
498 0 : maFormats.clear();
499 0 : if( mbIsBiff8 )
500 : {
501 0 : maCharBuffer.clear();
502 0 : maUniBuffer.resize( mnLen );
503 : }
504 : else
505 : {
506 0 : maUniBuffer.clear();
507 0 : maCharBuffer.resize( mnLen );
508 : }
509 0 : }
510 :
511 0 : void XclExpString::Build( const sal_Unicode* pcSource, sal_Int32 nCurrLen, XclStrFlags nFlags, sal_uInt16 nMaxLen )
512 : {
513 0 : Init( nCurrLen, nFlags, nMaxLen, true );
514 0 : CharsToBuffer( pcSource, 0, mnLen );
515 0 : }
516 :
517 0 : void XclExpString::Build( const sal_Char* pcSource, sal_Int32 nCurrLen, XclStrFlags nFlags, sal_uInt16 nMaxLen )
518 : {
519 0 : Init( nCurrLen, nFlags, nMaxLen, false );
520 0 : CharsToBuffer( pcSource, 0, mnLen );
521 0 : }
522 :
523 0 : void XclExpString::InitAppend( sal_Int32 nAddLen )
524 : {
525 0 : SetStrLen( static_cast< sal_Int32 >( mnLen ) + nAddLen );
526 0 : if( mbIsBiff8 )
527 0 : maUniBuffer.resize( mnLen );
528 : else
529 0 : maCharBuffer.resize( mnLen );
530 0 : }
531 :
532 0 : void XclExpString::BuildAppend( const sal_Unicode* pcSource, sal_Int32 nAddLen )
533 : {
534 : OSL_ENSURE( mbIsBiff8, "XclExpString::BuildAppend - must not be called at byte strings" );
535 0 : if( mbIsBiff8 )
536 : {
537 0 : sal_uInt16 nOldLen = mnLen;
538 0 : InitAppend( nAddLen );
539 0 : CharsToBuffer( pcSource, nOldLen, mnLen - nOldLen );
540 : }
541 0 : }
542 :
543 0 : void XclExpString::BuildAppend( const sal_Char* pcSource, sal_Int32 nAddLen )
544 : {
545 : OSL_ENSURE( !mbIsBiff8, "XclExpString::BuildAppend - must not be called at unicode strings" );
546 0 : if( !mbIsBiff8 )
547 : {
548 0 : sal_uInt16 nOldLen = mnLen;
549 0 : InitAppend( nAddLen );
550 0 : CharsToBuffer( pcSource, nOldLen, mnLen - nOldLen );
551 : }
552 0 : }
553 :
554 0 : void XclExpString::PrepareWrite( XclExpStream& rStrm, sal_uInt16 nBytes ) const
555 : {
556 0 : rStrm.SetSliceSize( nBytes + (mbIsUnicode ? 2 : 1) );
557 0 : }
558 :
559 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|