/** Returns the current text encoding identifier. */
rtl_TextEncoding GetTextEncoding() const { return *mxTextEnc; } /** Sets the passed text encoding. */ void SetTextEncoding( rtl_TextEncoding eTextEnc ) { *mxTextEnc = eTextEnc; }
/** Returns true, if this object contains Unicode text encoding. */ bool IsUnicode() const { return GetTextEncoding() == RTL_TEXTENCODING_UCS2; } /** Sets Unicode text encoding to this object. */ void SetUnicode() { SetTextEncoding( RTL_TEXTENCODING_UCS2 ); }
/** Converts the current settings to a Windows codepage identifier. */
sal_uInt16 GetCodePage() const; /** Sets the current text encoding from a Windows codepage identifier. */ void SetCodePage( sal_uInt16 nCodePage );
/** Helper for classes that need to load or save string values.
Classesderivedfromthisclasscontainfunctionstoloadandsavestring valueswiththetextencodingpassedintheconstructor.
*/ class SfxOleStringHelper : public SfxOleTextEncoding
{ public: /** Creates a string helper object depending on an external text encoding. */ explicit SfxOleStringHelper( const SfxOleTextEncoding& rTextEnc ) :
SfxOleTextEncoding( rTextEnc ) {} /** Creates a string helper object with own text encoding. */ explicit SfxOleStringHelper( rtl_TextEncoding eTextEnc ) :
SfxOleTextEncoding( eTextEnc ) {}
/** Loads a string from the passed stream with current encoding (maybe Unicode). */
OUString LoadString8( SvStream& rStrm ) const; /** Saves a string to the passed stream with current encoding (maybe Unicode). */ void SaveString8( SvStream& rStrm, std::u16string_view rValue ) const;
/** Loads a Unicode string from the passed stream, ignores own encoding. */ static OUString LoadString16( SvStream& rStrm ); /** Saves a Unicode string to the passed stream, ignores own encoding. */ staticvoid SaveString16( SvStream& rStrm, std::u16string_view rValue );
/** Returns the current error code. */
ErrCode const & GetError() const { return mnErrCode; }
/** Loads this object from the passed stream. Calls virtual ImplLoad(). */
ErrCode const & Load( SvStream& rStrm ); /** Saves this object to the passed stream. Calls virtual ImplSave(). */
ErrCode const & Save( SvStream& rStrm );
protected: /** Sets the passed error code. Will be returned by Load() and Save() functions.
Always the first error code is stored. Multiple calls have no effect. */ void SetError( ErrCode nErrCode ) { if( mnErrCode == ERRCODE_NONE ) mnErrCode = nErrCode; } /** Loads the passed object from the stream. Sets returned error code as own error. */ void LoadObject( SvStream& rStrm, SfxOleObjectBase& rObj ); /** Saves the passed object to the stream. Sets returned error code as own error. */ void SaveObject( SvStream& rStrm, SfxOleObjectBase& rObj );
private: /** Derived classes implement loading the object from the passed steam. */ virtualvoid ImplLoad( SvStream& rStrm ) = 0; /** Derived classes implement saving the object to the passed steam. */ virtualvoid ImplSave( SvStream& rStrm ) = 0;
private:
ErrCode mnErrCode; /// Current error code.
};
/** Base class for all OLE property objects. */ class SfxOlePropertyBase : public SfxOleObjectBase
{ public: explicit SfxOlePropertyBase( sal_Int32 nPropId, sal_Int32 nPropType ) :
mnPropId( nPropId ), mnPropType( nPropType ) {}
/** Property representing the codepage used to encode bytestrings in the entire property set. */ class SfxOleCodePageProperty : public SfxOlePropertyBase, public SfxOleTextEncoding
{ public: explicit SfxOleCodePageProperty();
/** Property containing custom names for other properties in the property set. */ class SfxOleDictionaryProperty : public SfxOlePropertyBase, public SfxOleStringHelper
{ public: explicit SfxOleDictionaryProperty( const SfxOleTextEncoding& rTextEnc );
/** Returns true, if the property contains at least one custom property name. */ bool HasPropertyNames() const { return !maPropNameMap.empty(); } /** Prepares the property for loading. Does not affect contained names for its own. */ void SetNameCount( sal_Int32 nNameCount ) { SetPropType( nNameCount ); }
/** Returns the custom name for the passed property ID, or an empty string, if name not found. */
OUString GetPropertyName( sal_Int32 nPropId ) const; /** Sets a custom name for the passed property ID. */ void SetPropertyName( sal_Int32 nPropId, const OUString& rPropName );
/** A section in a property set. Contains properties with unique identifiers. */ class SfxOleSection : public SfxOleObjectBase
{ private: typedef ::std::map< sal_Int32, SfxOlePropertyRef > SfxOlePropMap;
/** Returns the property with the passed ID, or an empty reference, if nothing found. */
SfxOlePropertyRef GetProperty( sal_Int32 nPropId ) const; /** Returns the value of a signed int32 property with the passed ID in rnValue.
@return true = Property found, rnValue is valid; false = Property not found. */ bool GetInt32Value( sal_Int32& rnValue, sal_Int32 nPropId ) const; /** Returns the value of a floating-point property with the passed ID in rfValue.
@return true = Property found, rfValue is valid; false = Property not found. */ bool GetDoubleValue( double& rfValue, sal_Int32 nPropId ) const; /** Returns the value of a boolean property with the passed ID in rbValue.
@return true = Property found, rbValue is valid; false = Property not found. */ bool GetBoolValue( bool& rbValue, sal_Int32 nPropId ) const; /** Returns the value of a string property with the passed ID in rValue.
@return true = Property found, rValue is valid; false = Property not found. */ bool GetStringValue( OUString& rValue, sal_Int32 nPropId ) const; /** Returns the value of a time stamp property with the passed ID in rValue.
@return true = Property found, rValue is valid; false = Property not found. */ bool GetFileTimeValue( css::util::DateTime& rValue, sal_Int32 nPropId ) const; /** Returns the value of a date property with the passed ID in rValue.
@return true = Property found, rValue is valid; false = Property not found. */ bool GetDateValue( css::util::Date& rValue, sal_Int32 nPropId ) const;
/** Adds the passed property to the property set. Drops an existing old property. */ void SetProperty( const SfxOlePropertyRef& xProp ); /** Inserts a signed int32 property with the passed value. */ void SetInt32Value( sal_Int32 nPropId, sal_Int32 nValue ); /** Inserts a floating-point property with the passed value. */ void SetDoubleValue( sal_Int32 nPropId, double fValue ); /** Inserts a boolean property with the passed value. */ void SetBoolValue( sal_Int32 nPropId, bool bValue ); /** Inserts a string property with the passed value.
@return true = Property inserted; false = String was empty, property not inserted. */ bool SetStringValue( sal_Int32 nPropId, const OUString& rValue ); /** Inserts a time stamp property with the passed value. */ void SetFileTimeValue( sal_Int32 nPropId, const css::util::DateTime& rValue ); /** Inserts a date property with the passed value. */ void SetDateValue( sal_Int32 nPropId, const css::util::Date& rValue ); /** Inserts a thumbnail property from the passed meta file. */ void SetThumbnailValue( sal_Int32 nPropId, const css::uno::Sequence<sal_Int8> & i_rData); /** Inserts a BLOB property with the passed data. */ void SetBlobValue( sal_Int32 nPropId, const css::uno::Sequence<sal_Int8> & i_rData);
/** Returns the value of the property with the passed ID in a UNO any. */
css::uno::Any GetAnyValue( sal_Int32 nPropId ) const; /** Inserts a property created from the passed any.
@return true = Property converted and inserted; false = Property type not supported. */ bool SetAnyValue( sal_Int32 nPropId, const css::uno::Any& rValue );
/** Returns the custom name for the passed property ID, or an empty string, if name not found. */
OUString GetPropertyName( sal_Int32 nPropId ) const; /** Sets a custom name for the passed property ID. */ void SetPropertyName( sal_Int32 nPropId, const OUString& rPropName );
/** Returns the identifiers of all existing properties in the passed vector. */ void GetPropertyIds( ::std::vector< sal_Int32 >& rPropIds ) const; /** Returns a property identifier not used in this section. */
sal_Int32 GetFreePropertyId() const;
private:
SfxOlePropMap maPropMap; /// All properties in this section, by identifier.
SfxOleCodePageProperty maCodePageProp; /// The codepage property.
SfxOleDictionaryProperty maDictProp; /// The dictionary property.
sal_uInt64 mnStartPos; /// Start stream position of the section. bool mbSupportsDict; /// true = section supports dictionary.
};
/** Enumerates different section types in OLE property sets. */ enum SfxOleSectionType
{
SECTION_GLOBAL, /// Globally defined properties.
SECTION_BUILTIN, /// Properties built into MS Office.
SECTION_CUSTOM /// Custom properties.
};
/** Represents a complete property set, may consist of several property sections. */ class SfxOlePropertySet : public SfxOleObjectBase
{ public: explicit SfxOlePropertySet() {}
/** Loads this object from the passed storage. */
ErrCode const & LoadPropertySet( SotStorage* pStrg, const OUString& rStrmName ); /** Saves this object to the passed storage. */
ErrCode const & SavePropertySet( SotStorage* pStrg, const OUString& rStrmName );
/** Returns the specified section, or an empty reference, if nothing found. */
SfxOleSectionRef GetSection( SfxOleSectionType eSection ) const; /** Returns the specified section, or an empty reference, if nothing found. */
SfxOleSectionRef GetSection( const SvGlobalName& rSectionGuid ) const;
/** Creates and returns the specified section, or just returns it if it already exists. */
SfxOleSection& AddSection( SfxOleSectionType eSection ); /** Creates and returns the specified section, or just returns it if it already exists. */
SfxOleSection& AddSection( const SvGlobalName& rSectionGuid );
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.