LibreOffice Module basic (master) 1
image.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 <tools/stream.hxx>
21#include <tools/tenccvt.hxx>
22#include <osl/thread.h>
23#include <o3tl/safeint.hxx>
24#include <sal/log.hxx>
25#include <basic/sbx.hxx>
26#include <sb.hxx>
27#include <sbxprop.hxx>
28#include <string.h>
29#include <image.hxx>
30#include <codegen.hxx>
31#include <memory>
32#include <string_view>
33
35 : bError(false)
36 , nFlags(SbiImageFlags::NONE)
37 , nStringSize(0)
38 , nDimBase(0)
39 , eCharSet(osl_getThreadTextEncoding())
40 , nStringIdx(0)
41 , nStringOff(0)
42 , bInit(false)
43 , bFirstInit(true)
44{
45}
46
48{
49}
50
52{
53 mvStringOffsets.clear();
54 pStrings.reset();
55 aCode.clear();
56 aLegacyPCode.clear();
58 nStringSize= 0;
59 eCharSet = osl_getThreadTextEncoding();
60 nDimBase = 0;
61 bError = false;
62}
63
64// Open Record
65static sal_uInt64 SbiOpenRecord( SvStream& r, FileOffset nSignature, sal_uInt16 nElem )
66{
67 sal_uInt64 nPos = r.Tell();
68 r.WriteUInt16( static_cast<sal_uInt16>( nSignature ) )
69 .WriteInt32( 0 ).WriteUInt16( nElem );
70 return nPos;
71}
72
73// Close Record
74static void SbiCloseRecord( SvStream& r, sal_uInt64 nOff )
75{
76 sal_uInt64 nPos = r.Tell();
77 r.Seek( nOff + 2 );
78 r.WriteInt32(nPos - nOff - 8 );
79 r.Seek( nPos );
80}
81
82constexpr sal_uInt32 nUnicodeDataMagicNumber = 0x556E6920; // "Uni " BE
83
84static bool GetToUnicodePoolData(SvStream& r, sal_uInt64 nLen, sal_uInt64 nNext)
85{
86 const auto nPos = r.Tell();
87 // Check space for legacy data, magic number and Unicode data
88 bool bResult = nPos + nLen + sizeof(sal_uInt32) + nLen * sizeof(sal_Unicode) <= nNext;
89 if (bResult)
90 {
91 r.SeekRel(nLen); // Skip legacy data
92 sal_uInt32 nMagic = 0;
95 {
96 r.Seek(nPos); // return
97 bResult = false;
98 }
99 }
100 return bResult;
101}
102
103bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion )
104{
105
106 sal_uInt16 nSign, nCount;
107 sal_uInt32 nLen;
108
109 Clear();
110 // Read Master-Record
111 r.ReadUInt16( nSign ).ReadUInt32( nLen ).ReadUInt16( nCount );
112 sal_uInt64 nLast = r.Tell() + nLen;
113 bool bBadVer = false;
114 if( nSign == static_cast<sal_uInt16>( FileOffset::Module ) )
115 {
116 sal_uInt32 nCharSet; // System charset
117 sal_uInt32 lDimBase;
118 sal_uInt16 nTmpFlags;
119 sal_uInt16 nReserved1;
120 sal_uInt32 nReserved2;
121 sal_uInt32 nReserved3;
122 r.ReadUInt32( nVersion ).ReadUInt32( nCharSet ).ReadUInt32( lDimBase )
123 .ReadUInt16( nTmpFlags ).ReadUInt16( nReserved1 ).ReadUInt32( nReserved2 ).ReadUInt32( nReserved3 );
124 nFlags = static_cast<SbiImageFlags>(nTmpFlags);
125 eCharSet = nCharSet;
127 bBadVer = ( nVersion > B_IMG_VERSION_13 );
128 nDimBase = static_cast<sal_uInt16>(lDimBase);
129 }
130
131 bool bLegacy = ( nVersion < B_IMG_VERSION_12 );
132
133 sal_uInt64 nNext;
134 while( ( nNext = r.Tell() ) < nLast )
135 {
136
137 r.ReadUInt16( nSign ).ReadUInt32( nLen ).ReadUInt16( nCount );
138 nNext += nLen + 8;
139 if( r.GetError() == ERRCODE_NONE )
140 {
141 switch( static_cast<FileOffset>( nSign ) )
142 {
143 case FileOffset::Name:
145 break;
148 break;
150 {
152 break;
153 }
155 {
156 //assuming an empty string with just the lead 32bit/16bit len indicator
157 const size_t nMinStringSize = (eCharSet == RTL_TEXTENCODING_UNICODE) ? 4 : 2;
158 const sal_uInt64 nMaxStrings = r.remainingSize() / nMinStringSize;
159 if (nCount > nMaxStrings)
160 {
161 SAL_WARN("basic", "Parsing error: " << nMaxStrings <<
162 " max possible entries, but " << nCount << " claimed, truncating");
163 nCount = nMaxStrings;
164 }
165 for( sal_uInt16 j = 0; j < nCount; ++j)
166 {
168 }
169 break;
170 }
172 if( bBadVer ) break;
173 aCode.resize(nLen);
174 r.ReadBytes(aCode.data(), aCode.size());
175 if ( bLegacy )
176 {
177 aLegacyPCode = std::move(aCode);
178
180 aLegacyPCode.size());
181 aLegacyToNew.convert();
182 aCode = aLegacyToNew.GetBuffer();
183 // we don't release the legacy buffer
184 // right now, that's because the module
185 // needs it to fix up the method
186 // nStart members. When that is done
187 // the module can release the buffer
188 // or it can wait until this routine
189 // is called again or when this class // destructs all of which will trigger
190 // release of the buffer.
191 }
192 break;
197 break;
199 {
200 // the data layout is: nCount of 32-bit offsets into both legacy 1-byte char stream
201 // and resulting char buffer (1:1 correspondence assumed; 16 of 32 bits used);
202 // 32-bit length N of following 1-byte char stream (16 bits used); N bytes of 1-byte
203 // char stream; then optional magic number and stream of N sal_Unicode characters.
204
205 if( bBadVer ) break;
206 //assuming an empty string with just the lead 32bit len indicator
207 const sal_uInt64 nMinStringSize = 4;
208 const sal_uInt64 nMaxStrings = r.remainingSize() / nMinStringSize;
209 if (nCount > nMaxStrings)
210 {
211 SAL_WARN("basic", "Parsing error: " << nMaxStrings <<
212 " max possible entries, but " << nCount << " claimed, truncating");
213 nCount = nMaxStrings;
214 }
216 for (size_t i = 0; i < mvStringOffsets.size() && r.good(); i++)
217 {
218 sal_uInt32 nOff;
219 r.ReadUInt32( nOff );
220 mvStringOffsets[ i ] = static_cast<sal_uInt16>(nOff);
221 }
222 r.ReadUInt32( nLen );
223 if (r.good())
224 {
225 pStrings.reset(new sal_Unicode[ nLen ]);
226 nStringSize = static_cast<sal_uInt16>(nLen);
227
228 if (GetToUnicodePoolData(r, nLen, nNext))
229 {
230 OUString s = read_uInt16s_ToOUString(r, nLen);
231 memcpy(pStrings.get(), s.getStr(), s.getLength() * sizeof(sal_Unicode));
232 }
233 else
234 {
235 std::unique_ptr<char[]> pByteStrings(new char[nLen]);
236 r.ReadBytes(pByteStrings.get(), nLen);
237 for (size_t j = 0; j < mvStringOffsets.size(); j++)
238 {
239 sal_uInt16 nOff2 = static_cast<sal_uInt16>(mvStringOffsets[j]);
240 OUString aStr(pByteStrings.get() + nOff2, strlen(pByteStrings.get() + nOff2), eCharSet);
241 memcpy(pStrings.get() + nOff2, aStr.getStr(), (aStr.getLength() + 1) * sizeof(sal_Unicode));
242 }
243 }
244 }
245 break;
246 }
248 {
249 //assuming an empty string with just the lead 32bit/16bit len indicator
250 const size_t nMinStringSize = (eCharSet == RTL_TEXTENCODING_UNICODE) ? 4 : 2;
251 const sal_uInt64 nMinRecordSize = nMinStringSize + sizeof(sal_Int16);
252 const sal_uInt64 nMaxRecords = r.remainingSize() / nMinRecordSize;
253 if (nCount > nMaxRecords)
254 {
255 SAL_WARN("basic", "Parsing error: " << nMaxRecords <<
256 " max possible entries, but " << nCount << " claimed, truncating");
257 nCount = nMaxRecords;
258 }
259
260 // User defined types; ref.: SbiParser::DefType
261 for (sal_uInt16 i = 0; i < nCount; i++)
262 {
263 OUString aTypeName = r.ReadUniOrByteString(eCharSet);
264
265 sal_uInt16 nTypeMembers;
266 r.ReadUInt16(nTypeMembers);
267
268 const sal_uInt64 nMaxTypeMembers = r.remainingSize() / 8;
269 if (nTypeMembers > nMaxTypeMembers)
270 {
271 SAL_WARN("basic", "Parsing error: " << nMaxTypeMembers <<
272 " max possible entries, but " << nTypeMembers << " claimed, truncating");
273 nTypeMembers = nMaxTypeMembers;
274 }
275
276 SbxObject *pType = new SbxObject(aTypeName);
277 SbxArray *pTypeMembers = pType->GetProperties();
278
279 for (sal_uInt16 j = 0; j < nTypeMembers; j++)
280 {
281 OUString aMemberName = r.ReadUniOrByteString(eCharSet);
282
283 sal_Int16 aIntMemberType;
284 r.ReadInt16(aIntMemberType);
285 SbxDataType aMemberType = static_cast< SbxDataType > ( aIntMemberType );
286
287 SbxProperty *pTypeElem = new SbxProperty( aMemberName, aMemberType );
288
289 sal_uInt32 aIntFlag;
290 r.ReadUInt32(aIntFlag);
291 SbxFlagBits nElemFlags = static_cast< SbxFlagBits > ( aIntFlag );
292
293 pTypeElem->SetFlags(nElemFlags);
294
295 sal_Int16 hasObject;
296 r.ReadInt16(hasObject);
297
298 if (hasObject == 1)
299 {
300 if(aMemberType == SbxOBJECT)
301 {
302 // nested user defined types
303 // declared before use, so it is ok to reference it by name on load
304 OUString aNestedTypeName = r.ReadUniOrByteString(eCharSet);
305 SbxObject* pNestedTypeObj = static_cast< SbxObject* >( rTypes->Find( aNestedTypeName, SbxClassType::Object ) );
306 if (pNestedTypeObj)
307 {
308 SbxObjectRef pCloneObj = cloneTypeObjectImpl( *pNestedTypeObj );
309 pTypeElem->PutObject( pCloneObj.get() );
310 }
311 }
312 else
313 {
314 // an array
315 SbxDimArray* pArray = new SbxDimArray(
316 static_cast<SbxDataType>(aMemberType & 0x0FFF));
317
318 sal_Int16 isFixedSize;
319 r.ReadInt16(isFixedSize);
320 if (isFixedSize == 1)
321 pArray->setHasFixedSize( true );
322
323 sal_Int32 nDims;
324 r.ReadInt32(nDims);
325 for (sal_Int32 d = 0; d < nDims; d++)
326 {
327 sal_Int32 lBound;
328 sal_Int32 uBound;
329 r.ReadInt32(lBound).ReadInt32(uBound);
330 pArray->unoAddDim(lBound, uBound);
331 }
332
333 const SbxFlagBits nSavFlags = pTypeElem->GetFlags();
334 // need to reset the FIXED flag
335 // when calling PutObject ( because the type will not match Object )
336 pTypeElem->ResetFlag(SbxFlagBits::Fixed);
337 pTypeElem->PutObject( pArray );
338 pTypeElem->SetFlags(nSavFlags);
339 }
340 }
341
342 pTypeMembers->Insert(pTypeElem, pTypeMembers->Count());
343
344 }
345
346 pType->Remove( "Name", SbxClassType::DontCare );
347 pType->Remove( "Parent", SbxClassType::DontCare );
348
349 AddType(pType);
350 }
351 break;
352 }
354 goto done;
355 default:
356 break;
357 }
358 }
359 else
360 {
361 break;
362 }
363 r.Seek( nNext );
364 }
365done:
366 r.Seek( nLast );
367 if (!r.good())
368 {
369 bError = true;
370 }
371 return !bError;
372}
373
374bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
375{
376 // First of all the header
377 sal_uInt64 nStart = SbiOpenRecord( r, FileOffset::Module, 1 );
378 sal_uInt64 nPos;
379
381 r .WriteInt32( nVer )
384 .WriteInt16( static_cast<sal_uInt16>(nFlags) )
385 .WriteInt16( 0 )
386 .WriteInt32( 0 )
387 .WriteInt32( 0 );
388
389 // Name?
390 if (!aName.isEmpty() && r.good())
391 {
394 SbiCloseRecord( r, nPos );
395 }
396 // Comment?
397 if (!aComment.isEmpty() && r.good())
398 {
401 SbiCloseRecord( r, nPos );
402 }
403 // Source?
404 if (!aOUSource.isEmpty() && r.good())
405 {
408 SbiCloseRecord( r, nPos );
409 }
410 // Binary data?
411 if (aCode.size() && r.good())
412 {
414 r.WriteBytes(aCode.data(), aCode.size());
415 SbiCloseRecord( r, nPos );
416 }
417 // String-Pool?
418 if( !mvStringOffsets.empty() )
419 {
421 // For every String:
422 // sal_uInt32 Offset of the Strings in the Stringblock
423 for (size_t i = 0; i < mvStringOffsets.size() && r.good(); i++)
424 {
426 }
427 // Then the String-Block
428 std::unique_ptr<char[]> pByteStrings(new char[ nStringSize ]);
429 for( size_t i = 0; i < mvStringOffsets.size(); i++ )
430 {
431 sal_uInt16 nOff = static_cast<sal_uInt16>(mvStringOffsets[ i ]);
432 OString aStr(OUStringToOString(std::u16string_view(pStrings.get() + nOff), eCharSet));
433 memcpy( pByteStrings.get() + nOff, aStr.getStr(), (aStr.getLength() + 1) * sizeof( char ) );
434 }
436 r.WriteBytes(pByteStrings.get(), nStringSize);
437 pByteStrings.reset();
438
439 // Now write magic number and store the same data in UTF-16; this is backward compatible:
440 // old readers will not read this data after having read legacy data, and will proceed
441 // straight to the end of the record. So no version restriction here.
443 write_uInt16s_FromOUString(r, std::u16string_view(pStrings.get(), nStringSize));
444
445 SbiCloseRecord( r, nPos );
446 }
447 // User defined types
448 if ( rTypes.is() )
449 {
450 sal_uInt32 nTypes = rTypes->Count();
451 assert(nTypes <= std::numeric_limits<sal_uInt16>::max());
452 if (nTypes > 0 )
453 {
454 nPos = SbiOpenRecord( r, FileOffset::UserTypes, sal::static_int_cast<sal_uInt16>(nTypes) );
455
456 for (sal_uInt32 i = 0; i < nTypes; i++)
457 {
458 SbxObject* pType = static_cast<SbxObject*>(rTypes->Get(i));
459 OUString aTypeName = pType->GetClassName();
460
461 r.WriteUniOrByteString( aTypeName, eCharSet );
462
463 SbxArray *pTypeMembers = pType->GetProperties();
464 sal_uInt32 nTypeMembers = pTypeMembers->Count();
465 assert(nTypeMembers <= std::numeric_limits<sal_uInt16>::max());
466
467 r.WriteInt16(sal::static_int_cast<sal_uInt16>(nTypeMembers));
468
469 for (sal_uInt32 j = 0; j < nTypeMembers; j++)
470 {
471
472 SbxProperty* pTypeElem = static_cast<SbxProperty*>(pTypeMembers->Get(j));
473
474 const OUString& aElemName = pTypeElem->GetName();
475 r.WriteUniOrByteString( aElemName, eCharSet );
476
477 SbxDataType dataType = pTypeElem->GetType();
478 r.WriteInt16(dataType);
479
480 SbxFlagBits nElemFlags = pTypeElem->GetFlags();
481 r.WriteUInt32(static_cast< sal_uInt32 > (nElemFlags) );
482
483 SbxBase* pElemObject = pTypeElem->GetObject();
484
485 if (pElemObject)
486 {
487 r.WriteInt16(1); // has elem Object
488
489 if( dataType == SbxOBJECT )
490 {
491 // nested user defined types
492 // declared before use, so it is ok to reference it by name on load
493 SbxObject* pNestedType = static_cast< SbxObject* > ( pElemObject );
494 r.WriteUniOrByteString( pNestedType->GetClassName(), eCharSet );
495 }
496 else
497 {
498 // an array
499 SbxDimArray* pArray = static_cast< SbxDimArray* > ( pElemObject );
500
501 bool bFixedSize = pArray->hasFixedSize();
502 if (bFixedSize)
503 r.WriteInt16(1);
504 else
505 r.WriteInt16(0);
506
507 sal_Int32 nDims = pArray->GetDims();
508 r.WriteInt32(nDims);
509
510 for (sal_Int32 d = 1; d <= nDims; d++)
511 {
512 sal_Int32 lBound;
513 sal_Int32 uBound;
514 pArray->GetDim(d, lBound, uBound);
515 r.WriteInt32(lBound).WriteInt32(uBound);
516 }
517 }
518 }
519 else
520 r.WriteInt16(0); // no elem Object
521
522 }
523 }
524 SbiCloseRecord( r, nPos );
525 }
526 }
527 // Set overall length
528 SbiCloseRecord( r, nStart );
529 if (!r.good())
530 {
531 bError = true;
532 }
533 return !bError;
534}
535
536void SbiImage::MakeStrings( short nSize )
537{
538 nStringIdx = 0;
539 nStringOff = 0;
540 nStringSize = 1024;
541 pStrings.reset( new sal_Unicode[ nStringSize ]);
542 mvStringOffsets.resize(nSize);
543 if (nSize != 0) {
544 memset( mvStringOffsets.data(), 0, nSize * sizeof( sal_uInt32 ) );
545 }
546 memset( pStrings.get(), 0, nStringSize * sizeof( sal_Unicode ) );
547}
548
549// Add a string to StringPool. The String buffer is dynamically
550// growing in 1K-Steps
551void SbiImage::AddString( const OUString& r )
552{
553 if( nStringIdx >= mvStringOffsets.size() )
554 {
555 bError = true;
556 }
557 if( bError )
558 return;
559
560 sal_Int32 len = r.getLength() + 1;
561 sal_uInt32 needed = nStringOff + len;
562 if( needed > 0xFFFFFF00 )
563 {
564 bError = true; // out of mem!
565 }
566 else if( needed > nStringSize )
567 {
568 sal_uInt32 nNewLen = needed + 1024;
569 nNewLen &= 0xFFFFFC00; // trim to 1K border
570 std::unique_ptr<sal_Unicode[]> p(new sal_Unicode[nNewLen]);
571 memcpy( p.get(), pStrings.get(), nStringSize * sizeof( sal_Unicode ) );
572 pStrings = std::move(p);
573 nStringSize = sal::static_int_cast< sal_uInt16 >(nNewLen);
574 }
575 if( !bError )
576 {
578 memcpy( pStrings.get() + nStringOff, r.getStr(), len * sizeof( sal_Unicode ) );
579 nStringOff = nStringOff + len;
580 // Last String? The update the size of the buffer
581 if( nStringIdx >= mvStringOffsets.size() )
582 {
584 }
585 }
586}
587
588// Add code block
589// The block was fetched by the compiler from class SbBuffer and
590// is already created with new. Additionally it contains all Integers
591// in Big Endian format, so can be directly read/written.
592void SbiImage::AddCode(std::vector<sal_uInt8>&& v)
593{
594 aCode = std::move(v);
595}
596
597// Add user type
598void SbiImage::AddType(SbxObject const * pObject)
599{
600 if( !rTypes.is() )
601 {
602 rTypes = new SbxArray;
603 }
604 SbxObject *pCopyObject = new SbxObject(*pObject);
605 rTypes->Insert(pCopyObject, rTypes->Count());
606}
607
608void SbiImage::AddEnum(SbxObject* pObject) // Register enum type
609{
610 if( !rEnums.is() )
611 {
612 rEnums = new SbxArray;
613 }
614 rEnums->Insert(pObject, rEnums->Count());
615}
616
617// Note: IDs start with 1
618OUString SbiImage::GetString( sal_uInt32 nId, SbxDataType *eType ) const
619{
620 if( nId && nId <= mvStringOffsets.size() )
621 {
622 sal_uInt32 nOff = mvStringOffsets[ nId - 1 ];
623 sal_Unicode* pStr = pStrings.get() + nOff;
624
625 sal_uInt32 nNextOff = (nId < mvStringOffsets.size()) ? mvStringOffsets[ nId ] : nStringSize;
626 sal_uInt32 nLen = nNextOff - nOff - 1;
627 // #i42467: Special treatment for vbNullChar
628 if (*pStr == 0)
629 {
630 if( nLen == 1 )
631 {
632 return OUString( u'\0');
633 }
634 }
635 else
636 {
637 // tdf#143707 - check if the data type character was added after the string termination
638 // symbol. It was added in basic/source/comp/symtbl.cxx.
639 OUString aOUStr(pStr);
640 if (eType != nullptr)
641 {
642 *eType = SbxSTRING;
643 if (o3tl::make_unsigned(aOUStr.getLength()) < nLen)
644 {
645 const sal_Unicode pTypeChar = *(pStrings.get() + nOff + aOUStr.getLength() + 1);
646 switch (pTypeChar)
647 {
648 // See GetSuffixType in basic/source/comp/scanner.cxx for type characters
649 case '%': *eType = SbxINTEGER; break;
650 case '&': *eType = SbxLONG; break;
651 case '!': *eType = SbxSINGLE; break;
652 case '#': *eType = SbxDOUBLE; break;
653 case '@': *eType = SbxCURRENCY; break;
654 // tdf#142460 - properly handle boolean values in string pool
655 case 'b': *eType = SbxBOOL; break;
656 }
657 }
658 }
659 return aOUStr;
660 }
661 }
662 return OUString();
663}
664
665const SbxObject* SbiImage::FindType (const OUString& aTypeName) const
666{
667 return rTypes.is() ? static_cast<SbxObject*>(rTypes->Find(aTypeName,SbxClassType::Object)) : nullptr;
668}
669
670sal_uInt16 SbiImage::CalcLegacyOffset( sal_Int32 nOffset )
671{
672 return SbiCodeGen::calcLegacyOffSet(aCode.data(), nOffset);
673}
674
675sal_uInt32 SbiImage::CalcNewOffset( sal_Int16 nOffset )
676{
677 return SbiCodeGen::calcNewOffSet(aLegacyPCode.data(), nOffset);
678}
679
681{
682 aLegacyPCode.clear();
683}
684
686{
687 return (nStringSize > 0xFF00) || (CalcLegacyOffset(aCode.size()) > 0xFF00);
688}
689
691{
692 const sal_Int16 nMax = std::numeric_limits<sal_Int16>::max();
693 return nStringSize >= nMax || CalcLegacyOffset(aCode.size()) >= nMax;
694}
695
696/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
double d
std::vector< sal_uInt8 > && GetBuffer()
Definition: codegen.hxx:78
static sal_uInt32 calcNewOffSet(sal_uInt8 const *pCode, sal_uInt16 nOffset)
Definition: codegen.cxx:560
static sal_uInt16 calcLegacyOffSet(sal_uInt8 const *pCode, sal_uInt32 nOffset)
Definition: codegen.cxx:566
bool Save(SvStream &, sal_uInt32)
Definition: image.cxx:374
OUString GetString(sal_uInt32 nId, SbxDataType *eType=nullptr) const
Definition: image.cxx:618
const SbxObject * FindType(const OUString &aTypeName) const
Definition: image.cxx:665
sal_uInt32 nStringOff
Definition: image.hxx:61
SbiImageFlags nFlags
Definition: image.hxx:55
~SbiImage()
Definition: image.cxx:47
OUString aOUSource
Definition: image.hxx:71
sal_uInt16 CalcLegacyOffset(sal_Int32 nOffset)
Definition: image.cxx:670
void Clear()
Definition: image.cxx:51
std::vector< sal_uInt32 > mvStringOffsets
Definition: image.hxx:50
void AddEnum(SbxObject *)
Definition: image.cxx:608
void MakeStrings(short)
Definition: image.cxx:536
bool ExceedsImgVersion12Limits()
Definition: image.cxx:690
bool ExceedsLegacyLimits()
Definition: image.cxx:685
OUString aComment
Definition: image.hxx:72
sal_uInt32 nStringSize
Definition: image.hxx:56
void ReleaseLegacyBuffer()
Definition: image.cxx:680
sal_uInt32 CalcNewOffset(sal_Int16 nOffset)
Definition: image.cxx:675
OUString aName
Definition: image.hxx:70
SbxArrayRef rTypes
Definition: image.hxx:48
std::size_t nStringIdx
Definition: image.hxx:60
SbiImage()
Definition: image.cxx:34
bool Load(SvStream &, sal_uInt32 &nVer)
Definition: image.cxx:103
rtl_TextEncoding eCharSet
Definition: image.hxx:58
std::unique_ptr< sal_Unicode[]> pStrings
Definition: image.hxx:51
std::vector< sal_uInt8 > aLegacyPCode
Definition: image.hxx:53
void AddCode(std::vector< sal_uInt8 > &&)
Definition: image.cxx:592
bool bError
Definition: image.hxx:54
void AddString(const OUString &)
Definition: image.cxx:551
SbxArrayRef rEnums
Definition: image.hxx:49
std::vector< sal_uInt8 > aCode
Definition: image.hxx:52
void AddType(SbxObject const *)
Definition: image.cxx:598
sal_uInt16 nDimBase
Definition: image.hxx:57
Definition: sbx.hxx:95
void Insert(SbxVariable *, sal_uInt32)
Definition: sbxarray.cxx:175
sal_uInt32 Count() const
Definition: sbxarray.cxx:87
SbxVariable * Get(sal_uInt32)
Definition: sbxarray.cxx:108
void SetFlags(SbxFlagBits n)
Definition: sbxcore.hxx:102
SbxFlagBits GetFlags() const
Definition: sbxcore.hxx:105
void ResetFlag(SbxFlagBits n)
Definition: sbxcore.hxx:111
bool GetDim(sal_Int32, sal_Int32 &, sal_Int32 &) const
Definition: sbxarray.cxx:458
sal_Int32 GetDims() const
Definition: sbx.hxx:160
bool hasFixedSize() const
Definition: sbx.hxx:164
void setHasFixedSize(bool bHasFixedSize)
Definition: sbx.hxx:165
void unoAddDim(sal_Int32, sal_Int32)
Definition: sbxarray.cxx:450
SbxArray * GetProperties()
Definition: sbxobj.hxx:79
const OUString & GetClassName() const
Definition: sbxobj.hxx:56
void Remove(const OUString &, SbxClassType)
Definition: sbxobj.cxx:499
SbxBase * GetObject() const
Definition: sbxvar.hxx:157
bool PutObject(SbxBase *)
virtual SbxDataType GetType() const override
Definition: sbxvar.cxx:321
const OUString & GetName(SbxNameType=SbxNameType::NONE) const
Definition: sbxvar.cxx:199
SvStream & WriteInt32(sal_Int32 nInt32)
sal_uInt64 Tell() const
bool good() const
SvStream & WriteUniOrByteString(std::u16string_view rStr, rtl_TextEncoding eDestCharSet)
OUString ReadUniOrByteString(rtl_TextEncoding eSrcCharSet)
SvStream & ReadInt16(sal_Int16 &rInt16)
std::size_t WriteBytes(const void *pData, std::size_t nSize)
SvStream & WriteInt16(sal_Int16 nInt16)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & WriteUInt32(sal_uInt32 nUInt32)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & ReadInt32(sal_Int32 &rInt32)
std::size_t ReadBytes(void *pData, std::size_t nSize)
sal_uInt64 SeekRel(sal_Int64 nPos)
ErrCode GetError() const
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_uInt64 remainingSize()
T * get() const
bool is() const
int nCount
float v
float u
EmbeddedObjectRef * pObject
#define ERRCODE_NONE
sal_Int16 nVersion
FileOffset
Definition: filefmt.hxx:61
#define B_IMG_VERSION_12
Definition: filefmt.hxx:48
#define B_IMG_VERSION_13
Definition: filefmt.hxx:49
DocumentType eType
constexpr sal_uInt32 nUnicodeDataMagicNumber
Definition: image.cxx:82
static bool GetToUnicodePoolData(SvStream &r, sal_uInt64 nLen, sal_uInt64 nNext)
Definition: image.cxx:84
static sal_uInt64 SbiOpenRecord(SvStream &r, FileOffset nSignature, sal_uInt16 nElem)
Definition: image.cxx:65
static void SbiCloseRecord(SvStream &r, sal_uInt64 nOff)
Definition: image.cxx:74
SbiImageFlags
Definition: image.hxx:33
void * p
sal_uInt16 nPos
#define SAL_WARN(area, stream)
aStr
NONE
int i
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)
sal_Int16 nId
const sal_uInt16 nMagic
SbxObjectRef cloneTypeObjectImpl(const SbxObject &rTypeObj)
Definition: sb.cxx:520
SbxBOOL
Definition: sbxdef.hxx:215
SbxDataType
Definition: sbxdef.hxx:37
@ SbxOBJECT
Definition: sbxdef.hxx:47
@ SbxLONG
Definition: sbxdef.hxx:41
@ SbxCURRENCY
Definition: sbxdef.hxx:44
@ SbxSINGLE
Definition: sbxdef.hxx:42
@ SbxSTRING
Definition: sbxdef.hxx:46
@ SbxINTEGER
Definition: sbxdef.hxx:40
@ SbxDOUBLE
Definition: sbxdef.hxx:43
SbxFlagBits
Definition: sbxdef.hxx:131
TOOLS_DLLPUBLIC OUString read_uInt16s_ToOUString(SvStream &rStrm, std::size_t nUnits)
TOOLS_DLLPUBLIC std::size_t write_uInt16s_FromOUString(SvStream &rStrm, std::u16string_view rStr, std::size_t nUnits)
TOOLS_DLLPUBLIC rtl_TextEncoding GetSOStoreTextEncoding(rtl_TextEncoding eEncoding)
TOOLS_DLLPUBLIC rtl_TextEncoding GetSOLoadTextEncoding(rtl_TextEncoding eEncoding)
sal_uInt16 sal_Unicode