LibreOffice Module sfx2 (master) 1
oleprops.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
21#include "oleprops.hxx"
22
23#include <comphelper/types.hxx>
24#include <o3tl/safeint.hxx>
25#include <tools/datetime.hxx>
26#include <rtl/tencinfo.h>
27#include <sal/log.hxx>
28#include <utility>
29
30
31#define STREAM_BUFFER_SIZE 2048
32
33// usings
34using ::com::sun::star::uno::Any;
35
36using namespace ::com::sun::star;
37
38#define TIMESTAMP_INVALID_DATETIME ( DateTime ( Date ( 1, 1, 1601 ), tools::Time ( 0, 0, 0 ) ) )
40#define TIMESTAMP_INVALID_UTILDATETIME (util::DateTime(0, 0, 0, 0, 1, 1, 1601, false))
42#define TIMESTAMP_INVALID_UTILDATE (util::Date(1, 1, 1601))
43
44namespace {
45
47class SfxOleInt32Property : public SfxOlePropertyBase
48{
49public:
50 explicit SfxOleInt32Property( sal_Int32 nPropId, sal_Int32 nValue = 0 );
51
52 sal_Int32 GetValue() const { return mnValue; }
53
54private:
55 virtual void ImplLoad( SvStream& rStrm ) override;
56 virtual void ImplSave( SvStream& rStrm ) override;
57
58private:
59 sal_Int32 mnValue;
60};
61
62
64class SfxOleDoubleProperty : public SfxOlePropertyBase
65{
66public:
67 explicit SfxOleDoubleProperty( sal_Int32 nPropId, double fValue = 0.0 );
68
69 double GetValue() const { return mfValue; }
70
71private:
72 virtual void ImplLoad( SvStream& rStrm ) override;
73 virtual void ImplSave( SvStream& rStrm ) override;
74
75private:
76 double mfValue;
77};
78
79
81class SfxOleBoolProperty : public SfxOlePropertyBase
82{
83public:
84 explicit SfxOleBoolProperty( sal_Int32 nPropId, bool bValue = false );
85
86 bool GetValue() const { return mbValue; }
87
88private:
89 virtual void ImplLoad( SvStream& rStrm ) override;
90 virtual void ImplSave( SvStream& rStrm ) override;
91
92private:
93 bool mbValue;
94};
95
96
98class SfxOleStringPropertyBase : public SfxOlePropertyBase, public SfxOleStringHelper
99{
100public:
101 explicit SfxOleStringPropertyBase(
102 sal_Int32 nPropId, sal_Int32 nPropType,
103 const SfxOleTextEncoding& rTextEnc );
104 explicit SfxOleStringPropertyBase(
105 sal_Int32 nPropId, sal_Int32 nPropType,
106 const SfxOleTextEncoding& rTextEnc, OUString aValue );
107 explicit SfxOleStringPropertyBase(
108 sal_Int32 nPropId, sal_Int32 nPropType,
109 rtl_TextEncoding eTextEnc );
110
111 const OUString& GetValue() const { return maValue; }
112 void SetValue( const OUString& rValue ) { maValue = rValue; }
113
114private:
115 OUString maValue;
116};
117
118
120class SfxOleString8Property : public SfxOleStringPropertyBase
121{
122public:
123 explicit SfxOleString8Property(
124 sal_Int32 nPropId, const SfxOleTextEncoding& rTextEnc );
125 explicit SfxOleString8Property(
126 sal_Int32 nPropId, const SfxOleTextEncoding& rTextEnc,
127 const OUString& rValue );
128
129private:
130 virtual void ImplLoad( SvStream& rStrm ) override;
131 virtual void ImplSave( SvStream& rStrm ) override;
132};
133
134
136class SfxOleString16Property : public SfxOleStringPropertyBase
137{
138public:
139 explicit SfxOleString16Property( sal_Int32 nPropId );
140
141private:
142 virtual void ImplLoad( SvStream& rStrm ) override;
143 virtual void ImplSave( SvStream& rStrm ) override;
144};
145
146
148class SfxOleFileTimeProperty : public SfxOlePropertyBase
149{
150public:
151 explicit SfxOleFileTimeProperty( sal_Int32 nPropId );
153 explicit SfxOleFileTimeProperty( sal_Int32 nPropId, const util::DateTime& rDateTime );
154
156 const util::DateTime& GetValue() const { return maDateTime; }
157
158private:
159 virtual void ImplLoad( SvStream& rStrm ) override;
160 virtual void ImplSave( SvStream& rStrm ) override;
161
162private:
163 util::DateTime maDateTime;
164};
165
167class SfxOleDateProperty : public SfxOlePropertyBase
168{
169public:
170 explicit SfxOleDateProperty( sal_Int32 nPropId );
171
173 const util::Date& GetValue() const { return maDate; }
174
175private:
176 virtual void ImplLoad( SvStream& rStrm ) override;
177 virtual void ImplSave( SvStream& rStrm ) override;
178
179private:
180 util::Date maDate;
181};
182
183
188class SfxOleThumbnailProperty : public SfxOlePropertyBase
189{
190public:
191 explicit SfxOleThumbnailProperty( sal_Int32 nPropId,
192 const uno::Sequence<sal_Int8> & i_rData);
193
194 bool IsValid() const { return mData.hasElements(); }
195
196private:
197 virtual void ImplLoad( SvStream& rStrm ) override;
198 virtual void ImplSave( SvStream& rStrm ) override;
199
200private:
201 uno::Sequence<sal_Int8> mData;
202};
203
204
210class SfxOleBlobProperty : public SfxOlePropertyBase
211{
212public:
213 explicit SfxOleBlobProperty( sal_Int32 nPropId,
214 const uno::Sequence<sal_Int8> & i_rData);
215 bool IsValid() const { return mData.hasElements(); }
216
217private:
218 virtual void ImplLoad( SvStream& rStrm ) override;
219 virtual void ImplSave( SvStream& rStrm ) override;
220
221private:
222 uno::Sequence<sal_Int8> mData;
223};
224
225}
226
228{
229 sal_uInt16 nCodePage = IsUnicode() ? CODEPAGE_UNICODE :
230 static_cast< sal_uInt16 >( rtl_getWindowsCodePageFromTextEncoding( *mxTextEnc ) );
231 return (nCodePage == CODEPAGE_UNKNOWN) ? CODEPAGE_UTF8 : nCodePage;
232}
233
234void SfxOleTextEncoding::SetCodePage( sal_uInt16 nCodePage )
235{
236 if( nCodePage == CODEPAGE_UNICODE )
237 SetUnicode();
238 else
239 {
240 rtl_TextEncoding eTextEnc = rtl_getTextEncodingFromWindowsCodePage( nCodePage );
241 if( eTextEnc != RTL_TEXTENCODING_DONTKNOW )
242 *mxTextEnc = eTextEnc;
243 }
244}
245
246
248{
250}
251
252void SfxOleStringHelper::SaveString8( SvStream& rStrm, std::u16string_view rValue ) const
253{
254 if( IsUnicode() )
255 ImplSaveString16( rStrm, rValue );
256 else
257 ImplSaveString8( rStrm, rValue );
258}
259
261{
262 return ImplLoadString16( rStrm );
263}
264
265void SfxOleStringHelper::SaveString16( SvStream& rStrm, std::u16string_view rValue )
266{
267 ImplSaveString16( rStrm, rValue );
268}
269
271{
272 // read size field (signed 32-bit)
273 sal_Int32 nSize(0);
274 rStrm.ReadInt32( nSize );
275 // size field includes trailing NUL character
276 SAL_WARN_IF(nSize < 1 || nSize > 0xFFFF, "sfx.doc", "SfxOleStringHelper::ImplLoadString8 - invalid string of len " << nSize);
277 if (nSize < 1 || nSize > 0xFFFF)
278 return OUString();
279 // load character buffer
280 OString sValue(read_uInt8s_ToOString(rStrm, nSize - 1));
281 if (rStrm.good() && rStrm.remainingSize())
282 rStrm.SeekRel(1); // skip null-byte at end
283 return OStringToOUString(sValue, GetTextEncoding());
284}
285
287{
288 // read size field (signed 32-bit), may be buffer size or character count
289 sal_Int32 nSize(0);
290 rStrm.ReadInt32(nSize);
291 SAL_WARN_IF(nSize < 1 || nSize > 0xFFFF, "sfx.doc", "SfxOleStringHelper::ImplLoadString16 - invalid string of len " << nSize);
292 // size field includes trailing NUL character
293 if (nSize < 1 || nSize > 0xFFFF)
294 return OUString();
295 // load character buffer
296 OUString aValue = read_uInt16s_ToOUString(rStrm, nSize - 1);
297 sal_Int32 nSkip(2); // skip null-byte at end
298 // stream is always padded to 32-bit boundary, skip 2 bytes on odd character count
299 if ((nSize & 1) == 1)
300 nSkip += 2;
301 nSkip = std::min<sal_uInt32>(nSkip, rStrm.remainingSize());
302 if (rStrm.good() && nSkip)
303 rStrm.SeekRel(nSkip);
304 return aValue;
305}
306
307void SfxOleStringHelper::ImplSaveString8( SvStream& rStrm, std::u16string_view rValue ) const
308{
309 // encode to byte string
310 OString aEncoded(OUStringToOString(rValue, GetTextEncoding()));
311 // write size field (including trailing NUL character)
312 sal_Int32 nSize = aEncoded.getLength() + 1;
313 rStrm.WriteInt32( nSize );
314 // write character array with trailing NUL character
315 rStrm.WriteBytes(aEncoded.getStr(), aEncoded.getLength());
316 rStrm.WriteUChar( 0 );
317}
318
319void SfxOleStringHelper::ImplSaveString16( SvStream& rStrm, std::u16string_view rValue )
320{
321 // write size field (including trailing NUL character)
322 sal_Int32 nSize = static_cast< sal_Int32 >( rValue.size() + 1 );
323 rStrm.WriteInt32( nSize );
324 // write character array with trailing NUL character
325 for( size_t nIdx = 0; nIdx < rValue.size(); ++nIdx )
326 rStrm.WriteUInt16( rValue[ nIdx ] );
327 rStrm.WriteUInt16( 0 );
328 // stream is always padded to 32-bit boundary, add 2 bytes on odd character count
329 if( (nSize & 1) == 1 )
330 rStrm.WriteUInt16( 0 );
331}
332
333
335{
336}
337
339{
341 ImplLoad( rStrm );
343 return GetError();
344}
345
347{
349 ImplSave( rStrm );
351 return GetError();
352}
353
355{
356 SetError( rObj.Load( rStrm ) );
357}
358
360{
361 SetError( rObj.Save( rStrm ) );
362}
363
364
367{
368}
369
371{
372 // property type is signed int16, but we use always unsigned int16 for codepages
373 sal_uInt16 nCodePage(0);
374 rStrm.ReadUInt16(nCodePage);
375 SetCodePage(nCodePage);
376}
377
379{
380 // property type is signed int16, but we use always unsigned int16 for codepages
382}
383
384
385SfxOleInt32Property::SfxOleInt32Property( sal_Int32 nPropId, sal_Int32 nValue ) :
387 mnValue( nValue )
388{
389}
390
391void SfxOleInt32Property::ImplLoad( SvStream& rStrm )
392{
393 rStrm.ReadInt32( mnValue );
394}
395
396void SfxOleInt32Property::ImplSave( SvStream& rStrm )
397{
398 rStrm.WriteInt32( mnValue );
399}
400
401
402SfxOleDoubleProperty::SfxOleDoubleProperty( sal_Int32 nPropId, double fValue ) :
404 mfValue( fValue )
405{
406}
407
408void SfxOleDoubleProperty::ImplLoad( SvStream& rStrm )
409{
410 rStrm.ReadDouble( mfValue );
411}
412
413void SfxOleDoubleProperty::ImplSave( SvStream& rStrm )
414{
415 rStrm.WriteDouble( mfValue );
416}
417
418
419SfxOleBoolProperty::SfxOleBoolProperty( sal_Int32 nPropId, bool bValue ) :
421 mbValue( bValue )
422{
423}
424
425void SfxOleBoolProperty::ImplLoad( SvStream& rStrm )
426{
427 sal_Int16 nValue(0);
428 rStrm.ReadInt16( nValue );
429 mbValue = nValue != 0;
430}
431
432void SfxOleBoolProperty::ImplSave( SvStream& rStrm )
433{
434 rStrm.WriteInt16( mbValue ? -1 : 0 );
435}
436
437
438SfxOleStringPropertyBase::SfxOleStringPropertyBase(
439 sal_Int32 nPropId, sal_Int32 nPropType, const SfxOleTextEncoding& rTextEnc ) :
440 SfxOlePropertyBase( nPropId, nPropType ),
441 SfxOleStringHelper( rTextEnc )
442{
443}
444
445SfxOleStringPropertyBase::SfxOleStringPropertyBase(
446 sal_Int32 nPropId, sal_Int32 nPropType, const SfxOleTextEncoding& rTextEnc, OUString aValue ) :
447 SfxOlePropertyBase( nPropId, nPropType ),
448 SfxOleStringHelper( rTextEnc ),
449 maValue(std::move( aValue ))
450{
451}
452
453SfxOleStringPropertyBase::SfxOleStringPropertyBase(
454 sal_Int32 nPropId, sal_Int32 nPropType, rtl_TextEncoding eTextEnc ) :
455 SfxOlePropertyBase( nPropId, nPropType ),
456 SfxOleStringHelper( eTextEnc )
457{
458}
459
460
461SfxOleString8Property::SfxOleString8Property(
462 sal_Int32 nPropId, const SfxOleTextEncoding& rTextEnc ) :
463 SfxOleStringPropertyBase( nPropId, PROPTYPE_STRING8, rTextEnc )
464{
465}
466
467SfxOleString8Property::SfxOleString8Property(
468 sal_Int32 nPropId, const SfxOleTextEncoding& rTextEnc, const OUString& rValue ) :
469 SfxOleStringPropertyBase( nPropId, PROPTYPE_STRING8, rTextEnc, rValue )
470{
471}
472
473void SfxOleString8Property::ImplLoad( SvStream& rStrm )
474{
475 SetValue( LoadString8( rStrm ) );
476}
477
478void SfxOleString8Property::ImplSave( SvStream& rStrm )
479{
480 SaveString8( rStrm, GetValue() );
481}
482
483
484SfxOleString16Property::SfxOleString16Property( sal_Int32 nPropId ) :
485 SfxOleStringPropertyBase( nPropId, PROPTYPE_STRING16, RTL_TEXTENCODING_UCS2 )
486{
487}
488
489void SfxOleString16Property::ImplLoad( SvStream& rStrm )
490{
491 SetValue( LoadString16( rStrm ) );
492}
493
494void SfxOleString16Property::ImplSave( SvStream& rStrm )
495{
496 SaveString16( rStrm, GetValue() );
497}
498
499
500SfxOleFileTimeProperty::SfxOleFileTimeProperty( sal_Int32 nPropId ) :
502{
503}
504
505SfxOleFileTimeProperty::SfxOleFileTimeProperty( sal_Int32 nPropId, const util::DateTime& rDateTime ) :
507 maDateTime( rDateTime )
508{
509}
510
511void SfxOleFileTimeProperty::ImplLoad( SvStream& rStrm )
512{
513 sal_uInt32 nLower(0), nUpper(0);
514 rStrm.ReadUInt32( nLower ).ReadUInt32( nUpper );
515 ::DateTime aDateTime = DateTime::CreateFromWin32FileDateTime( nLower, nUpper );
516 // note: editing duration is stored as offset to TIMESTAMP_INVALID_DATETIME
517 // of course we should not convert the time zone of a duration!
518 // heuristic to detect editing durations (which we assume to be < 1 year):
519 // check only the year, not the entire date
520 if ( aDateTime.GetYear() != TIMESTAMP_INVALID_DATETIME.GetYear() )
521 aDateTime.ConvertToLocalTime();
522 maDateTime.Year = aDateTime.GetYear();
523 maDateTime.Month = aDateTime.GetMonth();
524 maDateTime.Day = aDateTime.GetDay();
525 maDateTime.Hours = aDateTime.GetHour();
526 maDateTime.Minutes = aDateTime.GetMin();
527 maDateTime.Seconds = aDateTime.GetSec();
528 maDateTime.NanoSeconds = aDateTime.GetNanoSec();
529 maDateTime.IsUTC = false;
530}
531
532void SfxOleFileTimeProperty::ImplSave( SvStream& rStrm )
533{
534 DateTime aDateTimeUtc(
535 Date(
536 maDateTime.Day,
537 maDateTime.Month,
538 static_cast< sal_uInt16 >( maDateTime.Year ) ),
540 maDateTime.Hours,
541 maDateTime.Minutes,
542 maDateTime.Seconds,
543 maDateTime.NanoSeconds ) );
544 // invalid time stamp is not converted to UTC
545 // heuristic to detect editing durations (which we assume to be < 1 year):
546 // check only the year, not the entire date
547 if( aDateTimeUtc.IsValidAndGregorian()
548 && aDateTimeUtc.GetYear() != TIMESTAMP_INVALID_DATETIME.GetYear() ) {
549 aDateTimeUtc.ConvertToUTC();
550 }
551 sal_uInt32 nLower, nUpper;
552 aDateTimeUtc.GetWin32FileDateTime( nLower, nUpper );
553 rStrm.WriteUInt32( nLower ).WriteUInt32( nUpper );
554}
555
556SfxOleDateProperty::SfxOleDateProperty( sal_Int32 nPropId ) :
558{
559}
560
561void SfxOleDateProperty::ImplLoad( SvStream& rStrm )
562{
563 double fValue(0.0);
564 rStrm.ReadDouble( fValue );
565 //stored as number of days (not seconds) since December 31, 1899
566 sal_Int32 nDays = fValue;
567 sal_Int32 nStartDays = ::Date::DateToDays(31, 12, 1899);
568 if (o3tl::checked_add(nStartDays, nDays, nStartDays))
569 SAL_WARN("sfx.doc", "SfxOleDateProperty::ImplLoad bad date, ignored");
570 else
571 {
572 ::Date aDate(31, 12, 1899);
573 aDate.AddDays(nDays);
574 maDate.Day = aDate.GetDay();
575 maDate.Month = aDate.GetMonth();
576 maDate.Year = aDate.GetYear();
577 }
578}
579
580void SfxOleDateProperty::ImplSave( SvStream& rStrm )
581{
582 sal_Int32 nDays = ::Date::DateToDays(maDate.Day, maDate.Month, maDate.Year);
583 //number of days (not seconds) since December 31, 1899
584 sal_Int32 nStartDays = ::Date::DateToDays(31, 12, 1899);
585 double fValue = nDays-nStartDays;
586 rStrm.WriteDouble( fValue );
587}
588
589
590SfxOleThumbnailProperty::SfxOleThumbnailProperty(
591 sal_Int32 nPropId, const uno::Sequence<sal_Int8> & i_rData) :
593 mData(i_rData)
594{
595}
596
597void SfxOleThumbnailProperty::ImplLoad( SvStream& )
598{
599 SAL_WARN( "sfx.doc", "SfxOleThumbnailProperty::ImplLoad - not implemented" );
600 SetError( SVSTREAM_INVALID_ACCESS );
601}
602
603void SfxOleThumbnailProperty::ImplSave( SvStream& rStrm )
604{
605 /* Type Contents
606 -----------------------------------------------------------------------
607 int32 size of following data
608 int32 clipboard format tag (see below)
609 byte[] clipboard data (see below)
610
611 Clipboard format tag:
612 -1 = Windows clipboard format
613 -2 = Macintosh clipboard format
614 -3 = GUID that contains a format identifier (FMTID)
615 >0 = custom clipboard format name plus data (see msdn site below)
616 0 = no data
617
618 References:
619 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/stg/stg/propvariant.asp
620 http://jakarta.apache.org/poi/hpsf/thumbnails.html
621 http://linux.com.hk/docs/poi/org/apache/poi/hpsf/Thumbnail.html
622 https://web.archive.org/web/20060126202945/http://sparks.discreet.com/knowledgebase/public/solutions/ExtractThumbnailImg.htm
623 */
624 if( IsValid() )
625 {
626 // clipboard size: clip_format_tag + data_format_tag + bitmap_len
627 sal_Int32 nClipSize = static_cast< sal_Int32 >( 4 + 4 + mData.getLength() );
629 rStrm.WriteBytes(mData.getConstArray(), mData.getLength());
630 }
631 else
632 {
633 SAL_WARN( "sfx.doc", "SfxOleThumbnailProperty::ImplSave - invalid thumbnail property" );
634 SetError( SVSTREAM_INVALID_ACCESS );
635 }
636}
637
638
639SfxOleBlobProperty::SfxOleBlobProperty( sal_Int32 nPropId,
640 const uno::Sequence<sal_Int8> & i_rData) :
642 mData(i_rData)
643{
644}
645
646void SfxOleBlobProperty::ImplLoad( SvStream& )
647{
648 SAL_WARN( "sfx.doc", "SfxOleBlobProperty::ImplLoad - not implemented" );
649 SetError( SVSTREAM_INVALID_ACCESS );
650}
651
652void SfxOleBlobProperty::ImplSave( SvStream& rStrm )
653{
654 if (IsValid()) {
655 rStrm.WriteBytes(mData.getConstArray(), mData.getLength());
656 } else {
657 SAL_WARN( "sfx.doc", "SfxOleBlobProperty::ImplSave - invalid BLOB property" );
658 SetError( SVSTREAM_INVALID_ACCESS );
659 }
660}
661
662
665 SfxOleStringHelper( rTextEnc )
666{
667}
668
669OUString SfxOleDictionaryProperty::GetPropertyName( sal_Int32 nPropId ) const
670{
671 SfxOlePropNameMap::const_iterator aIt = maPropNameMap.find( nPropId );
672 return (aIt == maPropNameMap.end()) ? OUString() : aIt->second;
673}
674
675void SfxOleDictionaryProperty::SetPropertyName( sal_Int32 nPropId, const OUString& rPropName )
676{
677 maPropNameMap[ nPropId ] = rPropName;
678 // dictionary property contains number of pairs in property type field
679 SetPropType( static_cast< sal_Int32 >( maPropNameMap.size() ) );
680}
681
683{
684 // dictionary property contains number of pairs in property type field
685 sal_Int32 nNameCount = GetPropType();
686 // read property ID/name pairs
687 maPropNameMap.clear();
688 for (sal_Int32 nIdx = 0; nIdx < nNameCount && rStrm.good() && rStrm.remainingSize() >= 4; ++nIdx)
689 {
690 sal_Int32 nPropId(0);
691 rStrm.ReadInt32(nPropId);
692 // name always stored as byte string
693 maPropNameMap[nPropId] = LoadString8(rStrm);
694 }
695}
696
698{
699 // write property ID/name pairs
700 for (auto const& propName : maPropNameMap)
701 {
702 rStrm.WriteInt32( propName.first );
703 // name always stored as byte string
704 SaveString8( rStrm, propName.second );
705 }
706}
707
708
709SfxOleSection::SfxOleSection( bool bSupportsDict ) :
710 maDictProp( maCodePageProp ),
711 mnStartPos( 0 ),
712 mbSupportsDict( bSupportsDict )
713{
714}
715
717{
718 SfxOlePropertyRef xProp;
719 SfxOlePropMap::const_iterator aIt = maPropMap.find( nPropId );
720 if( aIt != maPropMap.end() )
721 xProp = aIt->second;
722 return xProp;
723}
724
725bool SfxOleSection::GetInt32Value( sal_Int32& rnValue, sal_Int32 nPropId ) const
726{
727 SfxOlePropertyRef xProp = GetProperty( nPropId );
728 const SfxOleInt32Property* pProp =
729 dynamic_cast< const SfxOleInt32Property* >( xProp.get() );
730 if( pProp )
731 rnValue = pProp->GetValue();
732 return pProp != nullptr;
733}
734
735bool SfxOleSection::GetDoubleValue( double& rfValue, sal_Int32 nPropId ) const
736{
737 SfxOlePropertyRef xProp = GetProperty( nPropId );
738 const SfxOleDoubleProperty* pProp =
739 dynamic_cast< const SfxOleDoubleProperty* >( xProp.get() );
740 if( pProp )
741 rfValue = pProp->GetValue();
742 return pProp != nullptr;
743}
744
745bool SfxOleSection::GetBoolValue( bool& rbValue, sal_Int32 nPropId ) const
746{
747 SfxOlePropertyRef xProp = GetProperty( nPropId );
748 const SfxOleBoolProperty* pProp =
749 dynamic_cast< const SfxOleBoolProperty* >( xProp.get() );
750 if( pProp )
751 rbValue = pProp->GetValue();
752 return pProp != nullptr;
753}
754
755bool SfxOleSection::GetStringValue( OUString& rValue, sal_Int32 nPropId ) const
756{
757 SfxOlePropertyRef xProp = GetProperty( nPropId );
758 const SfxOleStringPropertyBase* pProp =
759 dynamic_cast< const SfxOleStringPropertyBase* >( xProp.get() );
760 if( pProp )
761 rValue = pProp->GetValue();
762 return pProp != nullptr;
763}
764
765bool SfxOleSection::GetFileTimeValue( util::DateTime& rValue, sal_Int32 nPropId ) const
766{
767 SfxOlePropertyRef xProp = GetProperty( nPropId );
768 const SfxOleFileTimeProperty* pProp =
769 dynamic_cast< const SfxOleFileTimeProperty* >( xProp.get() );
770 if( pProp )
771 {
772 if ( pProp->GetValue() == TIMESTAMP_INVALID_UTILDATETIME )
773 rValue = util::DateTime();
774 else
775 rValue = pProp->GetValue();
776 }
777 return pProp != nullptr;
778}
779
780bool SfxOleSection::GetDateValue( util::Date& rValue, sal_Int32 nPropId ) const
781{
782 SfxOlePropertyRef xProp = GetProperty( nPropId );
783 const SfxOleDateProperty* pProp =
784 dynamic_cast< const SfxOleDateProperty* >( xProp.get() );
785 if( pProp )
786 {
787 if ( pProp->GetValue() == TIMESTAMP_INVALID_UTILDATE )
788 rValue = util::Date();
789 else
790 rValue = pProp->GetValue();
791 }
792 return pProp != nullptr;
793}
794
796{
797 if( xProp )
798 maPropMap[ xProp->GetPropId() ] = xProp;
799}
800
801void SfxOleSection::SetInt32Value( sal_Int32 nPropId, sal_Int32 nValue )
802{
803 SetProperty( std::make_shared<SfxOleInt32Property>( nPropId, nValue ) );
804}
805
806void SfxOleSection::SetDoubleValue( sal_Int32 nPropId, double fValue )
807{
808 SetProperty( std::make_shared<SfxOleDoubleProperty>( nPropId, fValue ) );
809}
810
811void SfxOleSection::SetBoolValue( sal_Int32 nPropId, bool bValue )
812{
813 SetProperty( std::make_shared<SfxOleBoolProperty>( nPropId, bValue ) );
814}
815
816bool SfxOleSection::SetStringValue( sal_Int32 nPropId, const OUString& rValue )
817{
818 bool bInserted = !rValue.isEmpty();
819 if( bInserted )
820 SetProperty( std::make_shared<SfxOleString8Property>( nPropId, maCodePageProp, rValue ) );
821 return bInserted;
822}
823
824void SfxOleSection::SetFileTimeValue( sal_Int32 nPropId, const util::DateTime& rValue )
825{
826 if ( rValue.Year == 0 || rValue.Month == 0 || rValue.Day == 0 )
827 SetProperty( std::make_shared<SfxOleFileTimeProperty>( nPropId, TIMESTAMP_INVALID_UTILDATETIME ) );
828 else
829 SetProperty( std::make_shared<SfxOleFileTimeProperty>( nPropId, rValue ) );
830}
831
832void SfxOleSection::SetDateValue( sal_Int32 nPropId, const util::Date& rValue )
833{
834 //Annoyingly MS2010 considers VT_DATE apparently as an invalid possibility, so here we use VT_FILETIME
835 //instead :-(
836 if ( rValue.Year == 0 || rValue.Month == 0 || rValue.Day == 0 )
837 SetProperty( std::make_shared<SfxOleFileTimeProperty>( nPropId, TIMESTAMP_INVALID_UTILDATETIME ) );
838 else
839 {
840 const util::DateTime aValue(0, 0, 0, 0, rValue.Day, rValue.Month,
841 rValue.Year, false );
842 SetProperty( std::make_shared<SfxOleFileTimeProperty>( nPropId, aValue ) );
843 }
844}
845
846void SfxOleSection::SetThumbnailValue( sal_Int32 nPropId,
847 const uno::Sequence<sal_Int8> & i_rData)
848{
849 auto pThumbnail = std::make_shared<SfxOleThumbnailProperty>( nPropId, i_rData );
850 if( pThumbnail->IsValid() )
851 SetProperty( pThumbnail );
852}
853
854void SfxOleSection::SetBlobValue( sal_Int32 nPropId,
855 const uno::Sequence<sal_Int8> & i_rData)
856{
857 auto pBlob = std::make_shared<SfxOleBlobProperty>( nPropId, i_rData );
858 if( pBlob->IsValid() )
859 SetProperty( pBlob );
860}
861
862Any SfxOleSection::GetAnyValue( sal_Int32 nPropId ) const
863{
864 Any aValue;
865 sal_Int32 nInt32 = 0;
866 double fDouble = 0.0;
867 bool bBool = false;
868 OUString aString;
869 css::util::DateTime aApiDateTime;
870 css::util::Date aApiDate;
871
872 if( GetInt32Value( nInt32, nPropId ) )
873 aValue <<= nInt32;
874 else if( GetDoubleValue( fDouble, nPropId ) )
875 aValue <<= fDouble;
876 else if( GetBoolValue( bBool, nPropId ) )
877 aValue <<= bBool;
878 else if( GetStringValue( aString, nPropId ) )
879 aValue <<= aString;
880 else if( GetFileTimeValue( aApiDateTime, nPropId ) )
881 {
882 aValue <<= aApiDateTime;
883 }
884 else if( GetDateValue( aApiDate, nPropId ) )
885 {
886 aValue <<= aApiDate;
887 }
888 return aValue;
889}
890
891bool SfxOleSection::SetAnyValue( sal_Int32 nPropId, const Any& rValue )
892{
893 bool bInserted = true;
894 sal_Int32 nInt32 = 0;
895 double fDouble = 0.0;
896 OUString aString;
897 css::util::DateTime aApiDateTime;
898 css::util::Date aApiDate;
899
900 if( rValue.getValueType() == cppu::UnoType<bool>::get() )
901 SetBoolValue( nPropId, ::comphelper::getBOOL( rValue ) );
902 else if( rValue >>= nInt32 )
903 SetInt32Value( nPropId, nInt32 );
904 else if( rValue >>= fDouble )
905 SetDoubleValue( nPropId, fDouble );
906 else if( rValue >>= aString )
907 bInserted = SetStringValue( nPropId, aString );
908 else if( rValue >>= aApiDateTime )
909 SetFileTimeValue( nPropId, aApiDateTime );
910 else if( rValue >>= aApiDate )
911 SetDateValue( nPropId, aApiDate );
912 else
913 bInserted = false;
914 return bInserted;
915}
916
917OUString SfxOleSection::GetPropertyName( sal_Int32 nPropId ) const
918{
919 return maDictProp.GetPropertyName( nPropId );
920}
921
922void SfxOleSection::SetPropertyName( sal_Int32 nPropId, const OUString& rPropName )
923{
924 maDictProp.SetPropertyName( nPropId, rPropName );
925}
926
927void SfxOleSection::GetPropertyIds( ::std::vector< sal_Int32 >& rPropIds ) const
928{
929 rPropIds.clear();
930 for (auto const& prop : maPropMap)
931 rPropIds.push_back(prop.first);
932}
933
935{
936 return maPropMap.empty() ? PROPID_FIRSTCUSTOM : (maPropMap.rbegin()->first + 1);
937}
938
940{
941 // read section header
943 sal_uInt32 nSize(0);
944 sal_Int32 nPropCount(0);
945 rStrm.ReadUInt32( nSize ).ReadInt32( nPropCount );
946
947 // read property ID/position pairs
948 typedef ::std::map< sal_Int32, sal_uInt32 > SfxOlePropPosMap;
949 SfxOlePropPosMap aPropPosMap;
950 for (sal_Int32 nPropIdx = 0; nPropIdx < nPropCount && rStrm.good(); ++nPropIdx)
951 {
952 sal_Int32 nPropId(0);
953 sal_uInt32 nPropPos(0);
954 rStrm.ReadInt32( nPropId ).ReadUInt32( nPropPos );
955 aPropPosMap[ nPropId ] = nPropPos;
956 }
957
958 // read codepage property
959 SfxOlePropPosMap::iterator aCodePageIt = aPropPosMap.find( PROPID_CODEPAGE );
960 if( (aCodePageIt != aPropPosMap.end()) && SeekToPropertyPos( rStrm, aCodePageIt->second ) )
961 {
962 // codepage property must be of type signed int-16
963 sal_Int32 nPropType(0);
964 rStrm.ReadInt32( nPropType );
965 if( nPropType == PROPTYPE_INT16 )
967 // remove property position
968 aPropPosMap.erase( aCodePageIt );
969 }
970
971 // read dictionary property
972 SfxOlePropPosMap::iterator aDictIt = aPropPosMap.find( PROPID_DICTIONARY );
973 if( (aDictIt != aPropPosMap.end()) && SeekToPropertyPos( rStrm, aDictIt->second ) )
974 {
975 // #i66214# #i66428# applications may write broken dictionary properties in wrong sections
976 if( mbSupportsDict )
977 {
978 // dictionary property contains number of pairs in property type field
979 sal_Int32 nNameCount(0);
980 rStrm.ReadInt32( nNameCount );
981 maDictProp.SetNameCount( nNameCount );
983 }
984 // always remove position of dictionary property (do not try to read it again below)
985 aPropPosMap.erase( aDictIt );
986 }
987
988 // read other properties
989 maPropMap.clear();
990 for (auto const& propPos : aPropPosMap)
991 if( SeekToPropertyPos( rStrm, propPos.second ) )
992 LoadProperty( rStrm, propPos.first );
993}
994
996{
997 /* Always export with UTF-8 encoding. All dependent properties (bytestring
998 and dictionary) will be updated automatically. */
999 maCodePageProp.SetTextEncoding( RTL_TEXTENCODING_UTF8 );
1000
1001 // write section header
1002 mnStartPos = rStrm.Tell();
1003 sal_Int32 nPropCount = static_cast< sal_Int32 >( maPropMap.size() + 1 );
1005 ++nPropCount;
1006 rStrm.WriteUInt32( 0 ).WriteInt32( nPropCount );
1007
1008 // write placeholders for property ID/position pairs
1009 sal_uInt64 nPropPosPos = rStrm.Tell();
1010 rStrm.SeekRel( static_cast< sal_sSize >( 8 * nPropCount ) );
1011
1012 // write dictionary property
1014 SaveProperty( rStrm, maDictProp, nPropPosPos );
1015 // write codepage property
1016 SaveProperty( rStrm, maCodePageProp, nPropPosPos );
1017 // write other properties
1018 for (auto const& prop : maPropMap)
1019 SaveProperty( rStrm, *prop.second, nPropPosPos );
1020
1021 // write section size (first field in section header)
1022 sal_uInt32 nSectSize = static_cast< sal_uInt32 >( rStrm.TellEnd() - mnStartPos );
1024 rStrm.WriteUInt32( nSectSize );
1025}
1026
1027bool SfxOleSection::SeekToPropertyPos( SvStream& rStrm, sal_uInt32 nPropPos ) const
1028{
1029 return checkSeek(rStrm, static_cast<std::size_t>(mnStartPos + nPropPos)) &&
1031}
1032
1033void SfxOleSection::LoadProperty( SvStream& rStrm, sal_Int32 nPropId )
1034{
1035 // property data type
1036 sal_Int32 nPropType(0);
1037 rStrm.ReadInt32( nPropType );
1038 // create empty property object
1039 SfxOlePropertyRef xProp;
1040 switch( nPropType )
1041 {
1042 case PROPTYPE_INT32:
1043 xProp = std::make_shared<SfxOleInt32Property>( nPropId );
1044 break;
1045 case PROPTYPE_DOUBLE:
1046 xProp = std::make_shared<SfxOleDoubleProperty>( nPropId );
1047 break;
1048 case PROPTYPE_BOOL:
1049 xProp = std::make_shared<SfxOleBoolProperty>( nPropId );
1050 break;
1051 case PROPTYPE_STRING8:
1052 xProp = std::make_shared<SfxOleString8Property>( nPropId, maCodePageProp );
1053 break;
1054 case PROPTYPE_STRING16:
1055 xProp = std::make_shared<SfxOleString16Property>( nPropId );
1056 break;
1057 case PROPTYPE_FILETIME:
1058 xProp = std::make_shared<SfxOleFileTimeProperty>( nPropId );
1059 break;
1060 case PROPTYPE_DATE:
1061 xProp = std::make_shared<SfxOleDateProperty>( nPropId );
1062 break;
1063 }
1064 // load property contents
1065 if( xProp )
1066 {
1067 SetError( xProp->Load( rStrm ) );
1068 maPropMap[ nPropId ] = xProp;
1069 }
1070}
1071
1072void SfxOleSection::SaveProperty( SvStream& rStrm, SfxOlePropertyBase& rProp, sal_uInt64 & rnPropPosPos )
1073{
1075 sal_uInt32 nPropPos = static_cast< sal_uInt32 >( rStrm.Tell() - mnStartPos );
1076 // property data type
1077 rStrm.WriteInt32( rProp.GetPropType() );
1078 // write property contents
1079 SaveObject( rStrm, rProp );
1080 // align to 32-bit
1081 while( (rStrm.Tell() & 3) != 0 )
1082 rStrm.WriteUChar( 0 );
1083 // write property ID/position pair
1084 rStrm.Seek( rnPropPosPos );
1085 rStrm.WriteInt32( rProp.GetPropId() ).WriteUInt32( nPropPos );
1086 rnPropPosPos = rStrm.Tell();
1087}
1088
1089
1090ErrCode const & SfxOlePropertySet::LoadPropertySet( SotStorage* pStrg, const OUString& rStrmName )
1091{
1092 if( pStrg )
1093 {
1094 tools::SvRef<SotStorageStream> xStrm = pStrg->OpenSotStream( rStrmName, StreamMode::STD_READ );
1095 if( xStrm.is() && (xStrm->GetError() == ERRCODE_NONE) )
1096 {
1097 xStrm->SetBufferSize( STREAM_BUFFER_SIZE );
1098 Load( *xStrm );
1099 }
1100 else
1102 }
1103 else
1105 return GetError();
1106}
1107
1108ErrCode const & SfxOlePropertySet::SavePropertySet( SotStorage* pStrg, const OUString& rStrmName )
1109{
1110 if( pStrg )
1111 {
1112 tools::SvRef<SotStorageStream> xStrm = pStrg->OpenSotStream( rStrmName, StreamMode::TRUNC | StreamMode::STD_WRITE );
1113 if( xStrm.is() )
1114 Save( *xStrm );
1115 else
1117 }
1118 else
1120 return GetError();
1121}
1122
1124{
1125 return GetSection( GetSectionGuid( eSection ) );
1126}
1127
1129{
1130 SfxOleSectionRef xSection;
1131 SfxOleSectionMap::const_iterator aIt = maSectionMap.find( rSectionGuid );
1132 if( aIt != maSectionMap.end() )
1133 xSection = aIt->second;
1134 return xSection;
1135}
1136
1138{
1139 return AddSection( GetSectionGuid( eSection ) );
1140}
1141
1143{
1144 SfxOleSectionRef xSection = GetSection( rSectionGuid );
1145 if( !xSection )
1146 {
1147 // #i66214# #i66428# applications may write broken dictionary properties in wrong sections
1148 bool bSupportsDict = rSectionGuid == GetSectionGuid( SECTION_CUSTOM );
1149 xSection = std::make_shared<SfxOleSection>( bSupportsDict );
1150 maSectionMap[ rSectionGuid ] = xSection;
1151 }
1152 return *xSection;
1153}
1154
1156{
1157 // read property set header
1158 sal_uInt16 nByteOrder;
1159 sal_uInt16 nVersion;
1160 sal_uInt16 nOsMinor;
1161 sal_uInt16 nOsType;
1162 SvGlobalName aGuid;
1163 sal_Int32 nSectCount(0);
1164 rStrm.ReadUInt16( nByteOrder ).ReadUInt16( nVersion ).ReadUInt16( nOsMinor ).ReadUInt16( nOsType );
1165 rStrm >> aGuid;
1166 rStrm.ReadInt32( nSectCount );
1167
1168 // read sections
1169 sal_uInt64 nSectPosPos = rStrm.Tell();
1170 for (sal_Int32 nSectIdx = 0; nSectIdx < nSectCount; ++nSectIdx)
1171 {
1172 // read section guid/position pair
1173 rStrm.Seek(nSectPosPos);
1174 SvGlobalName aSectGuid;
1175 rStrm >> aSectGuid;
1176 sal_uInt32 nSectPos(0);
1177 rStrm.ReadUInt32(nSectPos);
1178 if (!rStrm.good())
1179 break;
1180 nSectPosPos = rStrm.Tell();
1181 // read section
1182 if (!checkSeek(rStrm, nSectPos))
1183 break;
1184 LoadObject(rStrm, AddSection(aSectGuid));
1185 if (!rStrm.good())
1186 break;
1187 }
1188}
1189
1191{
1192 // write property set header
1193 SvGlobalName aGuid;
1194 sal_Int32 nSectCount = static_cast< sal_Int32 >( maSectionMap.size() );
1195 rStrm .WriteUInt16( 0xFFFE ) // byte order
1196 .WriteUInt16( 0 ) // version
1197 .WriteUInt16( 1 ) // OS minor version
1198 .WriteUInt16( 2 ); // OS type always windows for text encoding
1199 WriteSvGlobalName( rStrm, aGuid ); // unused guid
1200 rStrm .WriteInt32( nSectCount ); // number of sections
1201
1202 // write placeholders for section guid/position pairs
1203 sal_uInt64 nSectPosPos = rStrm.Tell();
1204 rStrm.SeekRel( static_cast< sal_sSize >( 20 * nSectCount ) );
1205
1206 // write sections
1207 for (auto const& section : maSectionMap)
1208 {
1209 SfxOleSection& rSection = *section.second;
1211 sal_uInt32 nSectPos = static_cast< sal_uInt32 >( rStrm.Tell() );
1212 // write the section
1213 SaveObject( rStrm, rSection );
1214 // write section guid/position pair
1215 rStrm.Seek( nSectPosPos );
1217 rStrm.WriteUInt32( nSectPos );
1218 nSectPosPos = rStrm.Tell();
1219 }
1220}
1221
1223{
1224 static const SvGlobalName saGlobalGuid( 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 );
1225 static const SvGlobalName saBuiltInGuid( 0xD5CDD502, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE );
1226 static const SvGlobalName saCustomGuid( 0xD5CDD505, 0x2E9C, 0x101B, 0x93, 0x97, 0x08, 0x00, 0x2B, 0x2C, 0xF9, 0xAE );
1227 static const SvGlobalName saEmptyGuid;
1228 switch( eSection )
1229 {
1230 case SECTION_GLOBAL: return saGlobalGuid;
1231 case SECTION_BUILTIN: return saBuiltInGuid;
1232 case SECTION_CUSTOM: return saCustomGuid;
1233 default: SAL_WARN( "sfx.doc", "SfxOlePropertySet::GetSectionGuid - unknown section type" );
1234 }
1235 return saEmptyGuid;
1236}
1237
1238
1239//} // namespace
1240
1241/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const sal_uInt16 nVersion
Definition: childwin.cxx:43
void ConvertToLocalTime()
static DateTime CreateFromWin32FileDateTime(sal_uInt32 rLower, sal_uInt32 rUpper)
sal_Int16 GetYear() const
sal_uInt16 GetDay() const
static sal_Int32 DateToDays(sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear)
sal_uInt16 GetMonth() const
virtual void ImplLoad(SvStream &rStrm) override
Derived classes implement loading the object from the passed steam.
Definition: oleprops.cxx:370
virtual void ImplSave(SvStream &rStrm) override
Derived classes implement saving the object to the passed steam.
Definition: oleprops.cxx:378
SfxOleDictionaryProperty(const SfxOleTextEncoding &rTextEnc)
Definition: oleprops.cxx:663
virtual void ImplLoad(SvStream &rStrm) override
Derived classes implement loading the object from the passed steam.
Definition: oleprops.cxx:682
virtual void ImplSave(SvStream &rStrm) override
Derived classes implement saving the object to the passed steam.
Definition: oleprops.cxx:697
OUString GetPropertyName(sal_Int32 nPropId) const
Returns the custom name for the passed property ID, or an empty string, if name not found.
Definition: oleprops.cxx:669
void SetPropertyName(sal_Int32 nPropId, const OUString &rPropName)
Sets a custom name for the passed property ID.
Definition: oleprops.cxx:675
bool HasPropertyNames() const
Returns true, if the property contains at least one custom property name.
Definition: oleprops.hxx:241
void SetNameCount(sal_Int32 nNameCount)
Prepares the property for loading.
Definition: oleprops.hxx:243
SfxOlePropNameMap maPropNameMap
Definition: oleprops.hxx:256
Base class for all classes related to OLE property sets.
Definition: oleprops.hxx:168
ErrCode mnErrCode
Definition: oleprops.hxx:197
virtual ~SfxOleObjectBase()
Definition: oleprops.cxx:334
void SetError(ErrCode nErrCode)
Sets the passed error code.
Definition: oleprops.hxx:184
virtual void ImplSave(SvStream &rStrm)=0
Derived classes implement saving the object to the passed steam.
void SaveObject(SvStream &rStrm, SfxOleObjectBase &rObj)
Saves the passed object to the stream.
Definition: oleprops.cxx:359
ErrCode const & GetError() const
Returns the current error code.
Definition: oleprops.hxx:174
ErrCode const & Load(SvStream &rStrm)
Loads this object from the passed stream.
Definition: oleprops.cxx:338
void LoadObject(SvStream &rStrm, SfxOleObjectBase &rObj)
Loads the passed object from the stream.
Definition: oleprops.cxx:354
ErrCode const & Save(SvStream &rStrm)
Saves this object to the passed stream.
Definition: oleprops.cxx:346
virtual void ImplLoad(SvStream &rStrm)=0
Derived classes implement loading the object from the passed steam.
Base class for all OLE property objects.
Definition: oleprops.hxx:203
sal_Int32 GetPropType() const
Definition: oleprops.hxx:209
void SetPropType(sal_Int32 nPropType)
Definition: oleprops.hxx:212
sal_Int32 GetPropId() const
Definition: oleprops.hxx:208
virtual void ImplLoad(SvStream &rStrm) override
Derived classes implement loading the object from the passed steam.
Definition: oleprops.cxx:1155
SfxOleSection & AddSection(SfxOleSectionType eSection)
Creates and returns the specified section, or just returns it if it already exists.
Definition: oleprops.cxx:1137
ErrCode const & LoadPropertySet(SotStorage *pStrg, const OUString &rStrmName)
Loads this object from the passed storage.
Definition: oleprops.cxx:1090
SfxOleSectionMap maSectionMap
Definition: oleprops.hxx:386
ErrCode const & SavePropertySet(SotStorage *pStrg, const OUString &rStrmName)
Saves this object to the passed storage.
Definition: oleprops.cxx:1108
virtual void ImplSave(SvStream &rStrm) override
Derived classes implement saving the object to the passed steam.
Definition: oleprops.cxx:1190
SfxOleSectionRef GetSection(SfxOleSectionType eSection) const
Returns the specified section, or an empty reference, if nothing found.
Definition: oleprops.cxx:1123
static const SvGlobalName & GetSectionGuid(SfxOleSectionType eSection)
Returns the GUID for the specified section.
Definition: oleprops.cxx:1222
A section in a property set.
Definition: oleprops.hxx:262
bool GetFileTimeValue(css::util::DateTime &rValue, sal_Int32 nPropId) const
Returns the value of a time stamp property with the passed ID in rValue.
Definition: oleprops.cxx:765
virtual void ImplLoad(SvStream &rStrm) override
Derived classes implement loading the object from the passed steam.
Definition: oleprops.cxx:939
SfxOlePropertyRef GetProperty(sal_Int32 nPropId) const
Returns the property with the passed ID, or an empty reference, if nothing found.
Definition: oleprops.cxx:716
SfxOleDictionaryProperty maDictProp
The codepage property.
Definition: oleprops.hxx:339
void SetDateValue(sal_Int32 nPropId, const css::util::Date &rValue)
Inserts a date property with the passed value.
Definition: oleprops.cxx:832
bool GetInt32Value(sal_Int32 &rnValue, sal_Int32 nPropId) const
Returns the value of a signed int32 property with the passed ID in rnValue.
Definition: oleprops.cxx:725
bool SeekToPropertyPos(SvStream &rStrm, sal_uInt32 nPropPos) const
Definition: oleprops.cxx:1027
void SetPropertyName(sal_Int32 nPropId, const OUString &rPropName)
Sets a custom name for the passed property ID.
Definition: oleprops.cxx:922
css::uno::Any GetAnyValue(sal_Int32 nPropId) const
Returns the value of the property with the passed ID in a UNO any.
Definition: oleprops.cxx:862
void SetFileTimeValue(sal_Int32 nPropId, const css::util::DateTime &rValue)
Inserts a time stamp property with the passed value.
Definition: oleprops.cxx:824
bool GetBoolValue(bool &rbValue, sal_Int32 nPropId) const
Returns the value of a boolean property with the passed ID in rbValue.
Definition: oleprops.cxx:745
virtual void ImplSave(SvStream &rStrm) override
Derived classes implement saving the object to the passed steam.
Definition: oleprops.cxx:995
SfxOlePropMap maPropMap
Definition: oleprops.hxx:337
void LoadProperty(SvStream &rStrm, sal_Int32 nPropId)
Definition: oleprops.cxx:1033
bool GetStringValue(OUString &rValue, sal_Int32 nPropId) const
Returns the value of a string property with the passed ID in rValue.
Definition: oleprops.cxx:755
void GetPropertyIds(::std::vector< sal_Int32 > &rPropIds) const
Returns the identifiers of all existing properties in the passed vector.
Definition: oleprops.cxx:927
SfxOleCodePageProperty maCodePageProp
All properties in this section, by identifier.
Definition: oleprops.hxx:338
sal_Int32 GetFreePropertyId() const
Returns a property identifier not used in this section.
Definition: oleprops.cxx:934
void SetBoolValue(sal_Int32 nPropId, bool bValue)
Inserts a boolean property with the passed value.
Definition: oleprops.cxx:811
bool GetDateValue(css::util::Date &rValue, sal_Int32 nPropId) const
Returns the value of a date property with the passed ID in rValue.
Definition: oleprops.cxx:780
void SetDoubleValue(sal_Int32 nPropId, double fValue)
Inserts a floating-point property with the passed value.
Definition: oleprops.cxx:806
void SetThumbnailValue(sal_Int32 nPropId, const css::uno::Sequence< sal_Int8 > &i_rData)
Inserts a thumbnail property from the passed meta file.
Definition: oleprops.cxx:846
void SetInt32Value(sal_Int32 nPropId, sal_Int32 nValue)
Inserts a signed int32 property with the passed value.
Definition: oleprops.cxx:801
void SetProperty(const SfxOlePropertyRef &xProp)
Adds the passed property to the property set.
Definition: oleprops.cxx:795
void SaveProperty(SvStream &rStrm, SfxOlePropertyBase &rProp, sal_uInt64 &rnPropPosPos)
Definition: oleprops.cxx:1072
bool GetDoubleValue(double &rfValue, sal_Int32 nPropId) const
Returns the value of a floating-point property with the passed ID in rfValue.
Definition: oleprops.cxx:735
OUString GetPropertyName(sal_Int32 nPropId) const
Returns the custom name for the passed property ID, or an empty string, if name not found.
Definition: oleprops.cxx:917
bool SetStringValue(sal_Int32 nPropId, const OUString &rValue)
Inserts a string property with the passed value.
Definition: oleprops.cxx:816
SfxOleSection(bool bSupportsDict)
Definition: oleprops.cxx:709
void SetBlobValue(sal_Int32 nPropId, const css::uno::Sequence< sal_Int8 > &i_rData)
Inserts a BLOB property with the passed data.
Definition: oleprops.cxx:854
bool SetAnyValue(sal_Int32 nPropId, const css::uno::Any &rValue)
Inserts a property created from the passed any.
Definition: oleprops.cxx:891
sal_uInt64 mnStartPos
The dictionary property.
Definition: oleprops.hxx:340
bool mbSupportsDict
Start stream position of the section.
Definition: oleprops.hxx:341
Helper for classes that need to load or save string values.
Definition: oleprops.hxx:135
static void SaveString16(SvStream &rStrm, std::u16string_view rValue)
Saves a Unicode string to the passed stream, ignores own encoding.
Definition: oleprops.cxx:265
void ImplSaveString8(SvStream &rStrm, std::u16string_view rValue) const
Definition: oleprops.cxx:307
static OUString LoadString16(SvStream &rStrm)
Loads a Unicode string from the passed stream, ignores own encoding.
Definition: oleprops.cxx:260
OUString LoadString8(SvStream &rStrm) const
Loads a string from the passed stream with current encoding (maybe Unicode).
Definition: oleprops.cxx:247
void SaveString8(SvStream &rStrm, std::u16string_view rValue) const
Saves a string to the passed stream with current encoding (maybe Unicode).
Definition: oleprops.cxx:252
static void ImplSaveString16(SvStream &rStrm, std::u16string_view rValue)
Definition: oleprops.cxx:319
OUString ImplLoadString8(SvStream &rStrm) const
Definition: oleprops.cxx:270
static OUString ImplLoadString16(SvStream &rStrm)
Definition: oleprops.cxx:286
Helper for classes that need text encoding settings.
Definition: oleprops.hxx:102
std::shared_ptr< rtl_TextEncoding > mxTextEnc
Definition: oleprops.hxx:125
void SetTextEncoding(rtl_TextEncoding eTextEnc)
Sets the passed text encoding.
Definition: oleprops.hxx:112
bool IsUnicode() const
Returns true, if this object contains Unicode text encoding.
Definition: oleprops.hxx:115
void SetUnicode()
Sets Unicode text encoding to this object.
Definition: oleprops.hxx:117
rtl_TextEncoding GetTextEncoding() const
Returns the current text encoding identifier.
Definition: oleprops.hxx:110
void SetCodePage(sal_uInt16 nCodePage)
Sets the current text encoding from a Windows codepage identifier.
Definition: oleprops.cxx:234
sal_uInt16 GetCodePage() const
Converts the current settings to a Windows codepage identifier.
Definition: oleprops.cxx:227
tools::SvRef< SotStorageStream > OpenSotStream(const OUString &rEleName, StreamMode=StreamMode::STD_READWRITE)
SvStream & WriteDouble(const double &rDouble)
SvStream & WriteInt32(sal_Int32 nInt32)
sal_uInt64 Tell() const
bool good() const
virtual sal_uInt64 TellEnd()
SvStream & ReadDouble(double &rDouble)
SvStream & ReadInt16(sal_Int16 &rInt16)
std::size_t WriteBytes(const void *pData, std::size_t nSize)
SvStream & WriteInt16(sal_Int16 nInt16)
SvStream & WriteUChar(unsigned char nChar)
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)
sal_uInt64 SeekRel(sal_Int64 nPos)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
ErrCode const & GetErrorCode() const
sal_uInt64 remainingSize()
bool is() const
sal_uInt16 GetSec() const
sal_uInt16 GetMin() const
sal_uInt16 GetHour() const
sal_uInt32 GetNanoSec() const
virtual void SetValue(tools::Long nNew) override
#define ERRCODE_IO_ACCESSDENIED
#define ERRCODE_NONE
double maValue
sal_Int16 nValue
SvStream & WriteSvGlobalName(SvStream &rOStr, const SvGlobalName &rObj)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
@ section
void SvStream & rStrm
std::enable_if< std::is_signed< T >::value, bool >::type checked_add(T a, T b, T &result)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
#define STREAM_BUFFER_SIZE
Definition: oleprops.cxx:31
#define TIMESTAMP_INVALID_UTILDATETIME
Invalid value for date and time to create invalid instance of TimeStamp.
Definition: oleprops.cxx:40
#define TIMESTAMP_INVALID_UTILDATE
Invalid value for date to create invalid instance of TimeStamp.
Definition: oleprops.cxx:42
#define TIMESTAMP_INVALID_DATETIME
Definition: oleprops.cxx:38
const sal_uInt16 CODEPAGE_UNKNOWN
Definition: oleprops.hxx:85
SfxOleSectionType
Enumerates different section types in OLE property sets.
Definition: oleprops.hxx:349
@ SECTION_BUILTIN
Globally defined properties.
Definition: oleprops.hxx:351
@ SECTION_GLOBAL
Definition: oleprops.hxx:350
@ SECTION_CUSTOM
Properties built into MS Office.
Definition: oleprops.hxx:352
const sal_uInt16 CODEPAGE_UNICODE
Definition: oleprops.hxx:86
const sal_Int32 PROPTYPE_DOUBLE
Definition: oleprops.hxx:42
const sal_Int32 PROPTYPE_INT16
Definition: oleprops.hxx:39
const sal_uInt16 CODEPAGE_UTF8
Definition: oleprops.hxx:87
const sal_Int32 PROPTYPE_INT32
Definition: oleprops.hxx:40
const sal_Int32 PROPTYPE_BOOL
Definition: oleprops.hxx:46
std::shared_ptr< SfxOlePropertyBase > SfxOlePropertyRef
Definition: oleprops.hxx:219
const sal_Int32 PROPTYPE_BLOB
Definition: oleprops.hxx:57
const sal_Int32 CLIPDATAFMT_DIB
Definition: oleprops.hxx:93
const sal_Int32 PROPTYPE_DATE
Definition: oleprops.hxx:43
const sal_Int32 PROPID_DICTIONARY
Definition: oleprops.hxx:61
const sal_Int32 PROPTYPE_FILETIME
Definition: oleprops.hxx:56
std::shared_ptr< SfxOleSection > SfxOleSectionRef
Definition: oleprops.hxx:344
const sal_Int32 PROPTYPE_STRING16
Definition: oleprops.hxx:55
const sal_Int32 PROPID_CODEPAGE
Definition: oleprops.hxx:62
const sal_Int32 CLIPFMT_WIN
Definition: oleprops.hxx:90
const sal_Int32 PROPTYPE_STRING8
Definition: oleprops.hxx:54
const sal_Int32 PROPTYPE_CLIPFMT
Definition: oleprops.hxx:58
const sal_Int32 PROPID_FIRSTCUSTOM
Definition: oleprops.hxx:63
const char GetValue[]
DateTime maDateTime
const double mnValue
TOOLS_DLLPUBLIC OString read_uInt8s_ToOString(SvStream &rStrm, std::size_t nUnits)
#define STREAM_SEEK_TO_END
TOOLS_DLLPUBLIC OUString read_uInt16s_ToOUString(SvStream &rStrm, std::size_t nUnits)
TOOLS_DLLPUBLIC bool checkSeek(SvStream &rSt, sal_uInt64 nOffset)
int SetError()