1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include <map> 29*cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 30*cdf0e10cSrcweir #include <sot/storage.hxx> 31*cdf0e10cSrcweir #include <vcl/bitmapex.hxx> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir // ============================================================================ 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir //namespace { 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir // ============================================================================ 41*cdf0e10cSrcweir // property type IDs 42*cdf0e10cSrcweir const sal_Int32 PROPTYPE_INT16 = 2; 43*cdf0e10cSrcweir const sal_Int32 PROPTYPE_INT32 = 3; 44*cdf0e10cSrcweir const sal_Int32 PROPTYPE_FLOAT = 4; 45*cdf0e10cSrcweir const sal_Int32 PROPTYPE_DOUBLE = 5; 46*cdf0e10cSrcweir const sal_Int32 PROPTYPE_DATE = 7; 47*cdf0e10cSrcweir const sal_Int32 PROPTYPE_STRING = 8; 48*cdf0e10cSrcweir const sal_Int32 PROPTYPE_STATUS = 10; 49*cdf0e10cSrcweir const sal_Int32 PROPTYPE_BOOL = 11; 50*cdf0e10cSrcweir const sal_Int32 PROPTYPE_VARIANT = 12; 51*cdf0e10cSrcweir const sal_Int32 PROPTYPE_INT8 = 16; 52*cdf0e10cSrcweir const sal_Int32 PROPTYPE_UINT8 = 17; 53*cdf0e10cSrcweir const sal_Int32 PROPTYPE_UINT16 = 18; 54*cdf0e10cSrcweir const sal_Int32 PROPTYPE_UINT32 = 19; 55*cdf0e10cSrcweir const sal_Int32 PROPTYPE_INT64 = 20; 56*cdf0e10cSrcweir const sal_Int32 PROPTYPE_UINT64 = 21; 57*cdf0e10cSrcweir const sal_Int32 PROPTYPE_STRING8 = 30; 58*cdf0e10cSrcweir const sal_Int32 PROPTYPE_STRING16 = 31; 59*cdf0e10cSrcweir const sal_Int32 PROPTYPE_FILETIME = 64; 60*cdf0e10cSrcweir const sal_Int32 PROPTYPE_BLOB = 65; 61*cdf0e10cSrcweir const sal_Int32 PROPTYPE_CLIPFMT = 71; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir // static property IDs 64*cdf0e10cSrcweir const sal_Int32 PROPID_DICTIONARY = 0; 65*cdf0e10cSrcweir const sal_Int32 PROPID_CODEPAGE = 1; 66*cdf0e10cSrcweir const sal_Int32 PROPID_FIRSTCUSTOM = 2; 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir // property IDs for GlobalDocPropertySet 69*cdf0e10cSrcweir const sal_Int32 PROPID_TITLE = 2; 70*cdf0e10cSrcweir const sal_Int32 PROPID_SUBJECT = 3; 71*cdf0e10cSrcweir const sal_Int32 PROPID_AUTHOR = 4; 72*cdf0e10cSrcweir const sal_Int32 PROPID_KEYWORDS = 5; 73*cdf0e10cSrcweir const sal_Int32 PROPID_COMMENTS = 6; 74*cdf0e10cSrcweir const sal_Int32 PROPID_TEMPLATE = 7; 75*cdf0e10cSrcweir const sal_Int32 PROPID_LASTAUTHOR = 8; 76*cdf0e10cSrcweir const sal_Int32 PROPID_REVNUMBER = 9; 77*cdf0e10cSrcweir const sal_Int32 PROPID_EDITTIME = 10; 78*cdf0e10cSrcweir const sal_Int32 PROPID_LASTPRINTED = 11; 79*cdf0e10cSrcweir const sal_Int32 PROPID_CREATED = 12; 80*cdf0e10cSrcweir const sal_Int32 PROPID_LASTSAVED = 13; 81*cdf0e10cSrcweir const sal_Int32 PROPID_THUMBNAIL = 17; 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir // predefined codepages 84*cdf0e10cSrcweir const sal_uInt16 CODEPAGE_UNKNOWN = 0; 85*cdf0e10cSrcweir const sal_uInt16 CODEPAGE_UNICODE = 1200; 86*cdf0e10cSrcweir const sal_uInt16 CODEPAGE_UTF8 = 65001; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir // predefined clipboard format IDs 89*cdf0e10cSrcweir const sal_Int32 CLIPFMT_WIN = -1; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir // predefined clipboard data format IDs 92*cdf0e10cSrcweir const sal_Int32 CLIPDATAFMT_DIB = 8; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir // ============================================================================ 95*cdf0e10cSrcweir // ============================================================================ 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir /** Helper for classes that need text encoding settings. 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir Classes derived from this class will include functions to store and use 100*cdf0e10cSrcweir text encoding settings and to convert Windows codepage constants. 101*cdf0e10cSrcweir */ 102*cdf0e10cSrcweir class SfxOleTextEncoding 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir public: 105*cdf0e10cSrcweir inline explicit SfxOleTextEncoding() : 106*cdf0e10cSrcweir mxTextEnc( new rtl_TextEncoding( gsl_getSystemTextEncoding() ) ) {} 107*cdf0e10cSrcweir inline explicit SfxOleTextEncoding( rtl_TextEncoding eTextEnc ) : 108*cdf0e10cSrcweir mxTextEnc( new rtl_TextEncoding( eTextEnc ) ) {} 109*cdf0e10cSrcweir inline explicit SfxOleTextEncoding( sal_Int16 nCodePage ) : 110*cdf0e10cSrcweir mxTextEnc( new rtl_TextEncoding ) { SetCodePage( nCodePage ); } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir /** Returns the current text encoding identifier. */ 113*cdf0e10cSrcweir inline rtl_TextEncoding GetTextEncoding() const { return *mxTextEnc; } 114*cdf0e10cSrcweir /** Sets the passed text encoding. */ 115*cdf0e10cSrcweir inline void SetTextEncoding( rtl_TextEncoding eTextEnc ) { *mxTextEnc = eTextEnc; } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir /** Returns true, if this object contains Unicode text encoding. */ 118*cdf0e10cSrcweir inline bool IsUnicode() const { return GetTextEncoding() == RTL_TEXTENCODING_UCS2; } 119*cdf0e10cSrcweir /** Sets Unicode text encoding to this object. */ 120*cdf0e10cSrcweir inline void SetUnicode() { SetTextEncoding( RTL_TEXTENCODING_UCS2 ); } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir /** Converts the current settings to a Windows codepage identifier. */ 123*cdf0e10cSrcweir sal_uInt16 GetCodePage() const; 124*cdf0e10cSrcweir /** Sets the current text encoding from a Windows codepage identifier. */ 125*cdf0e10cSrcweir void SetCodePage( sal_uInt16 nCodePage ); 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir private: 128*cdf0e10cSrcweir typedef ::boost::shared_ptr< rtl_TextEncoding > TextEncRef; 129*cdf0e10cSrcweir TextEncRef mxTextEnc; 130*cdf0e10cSrcweir }; 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir // ============================================================================ 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir /** Helper for classes that need to load or save string values. 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir Classes derived from this class contain functions to load and save string 137*cdf0e10cSrcweir values with the text encoding passed in the constructor. 138*cdf0e10cSrcweir */ 139*cdf0e10cSrcweir class SfxOleStringHelper : public SfxOleTextEncoding 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir public: 142*cdf0e10cSrcweir /** Creates a string helper object depending on an external text encoding. */ 143*cdf0e10cSrcweir inline explicit SfxOleStringHelper( const SfxOleTextEncoding& rTextEnc ) : 144*cdf0e10cSrcweir SfxOleTextEncoding( rTextEnc ) {} 145*cdf0e10cSrcweir /** Creates a string helper object with own text encoding. */ 146*cdf0e10cSrcweir inline explicit SfxOleStringHelper( rtl_TextEncoding eTextEnc ) : 147*cdf0e10cSrcweir SfxOleTextEncoding( eTextEnc ) {} 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir /** Loads a string from the passed stream with current encoding (maybe Unicode). */ 150*cdf0e10cSrcweir String LoadString8( SvStream& rStrm ) const; 151*cdf0e10cSrcweir /** Saves a string to the passed stream with current encoding (maybe Unicode). */ 152*cdf0e10cSrcweir void SaveString8( SvStream& rStrm, const String& rValue ) const; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir /** Loads a Unicode string from the passed stream, ignores own encoding. */ 155*cdf0e10cSrcweir String LoadString16( SvStream& rStrm ) const; 156*cdf0e10cSrcweir /** Saves a Unicode string to the passed stream, ignores own encoding. */ 157*cdf0e10cSrcweir void SaveString16( SvStream& rStrm, const String& rValue ) const; 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir private: 160*cdf0e10cSrcweir String ImplLoadString8( SvStream& rStrm ) const; 161*cdf0e10cSrcweir String ImplLoadString16( SvStream& rStrm ) const; 162*cdf0e10cSrcweir void ImplSaveString8( SvStream& rStrm, const String& rValue ) const; 163*cdf0e10cSrcweir void ImplSaveString16( SvStream& rStrm, const String& rValue ) const; 164*cdf0e10cSrcweir }; 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir // ============================================================================ 168*cdf0e10cSrcweir // ============================================================================ 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir /** Base class for all classes related to OLE property sets. 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir Derived calsses have to implement the pure virtual functions ImplLoad() and 173*cdf0e10cSrcweir ImplSave(). 174*cdf0e10cSrcweir */ 175*cdf0e10cSrcweir class SfxOleObjectBase 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir public: 178*cdf0e10cSrcweir inline explicit SfxOleObjectBase() : mnErrCode( ERRCODE_NONE ) {} 179*cdf0e10cSrcweir virtual ~SfxOleObjectBase(); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir /** Returns true, if an error code (other than ERRCODE_NONE) is set. */ 182*cdf0e10cSrcweir inline bool HasError() const { return mnErrCode != ERRCODE_NONE; } 183*cdf0e10cSrcweir /** Returns the current error code. */ 184*cdf0e10cSrcweir inline ErrCode GetError() const { return mnErrCode; } 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir /** Loads this object from the passed stream. Calls virtual ImplLoad(). */ 187*cdf0e10cSrcweir ErrCode Load( SvStream& rStrm ); 188*cdf0e10cSrcweir /** Saves this object to the passed stream. Calls virtual ImplSave(). */ 189*cdf0e10cSrcweir ErrCode Save( SvStream& rStrm ); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir protected: 192*cdf0e10cSrcweir /** Sets the passed error code. Will be returned by Load() and Save() functions. 193*cdf0e10cSrcweir Always the first error code is stored. Multiple calls have no effect. */ 194*cdf0e10cSrcweir inline void SetError( ErrCode nErrCode ) { if( !HasError() ) mnErrCode = nErrCode; } 195*cdf0e10cSrcweir /** Loads the passed object from the stream. Sets returned error code as own error. */ 196*cdf0e10cSrcweir void LoadObject( SvStream& rStrm, SfxOleObjectBase& rObj ); 197*cdf0e10cSrcweir /** Saves the passed object to the stream. Sets returned error code as own error. */ 198*cdf0e10cSrcweir void SaveObject( SvStream& rStrm, SfxOleObjectBase& rObj ); 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir private: 201*cdf0e10cSrcweir /** Derived classes implement loading the object from the passed steam. */ 202*cdf0e10cSrcweir virtual void ImplLoad( SvStream& rStrm ) = 0; 203*cdf0e10cSrcweir /** Derived classes implement saving the object to the passed steam. */ 204*cdf0e10cSrcweir virtual void ImplSave( SvStream& rStrm ) = 0; 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir private: 207*cdf0e10cSrcweir ErrCode mnErrCode; /// Current error code. 208*cdf0e10cSrcweir }; 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir // ============================================================================ 211*cdf0e10cSrcweir // ============================================================================ 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir /** Base class for all OLE property objects. */ 214*cdf0e10cSrcweir class SfxOlePropertyBase : public SfxOleObjectBase 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir public: 217*cdf0e10cSrcweir inline explicit SfxOlePropertyBase( sal_Int32 nPropId, sal_Int32 nPropType ) : 218*cdf0e10cSrcweir mnPropId( nPropId ), mnPropType( nPropType ) {} 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir inline sal_Int32 GetPropId() const { return mnPropId; } 221*cdf0e10cSrcweir inline sal_Int32 GetPropType() const { return mnPropType; } 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir protected: 224*cdf0e10cSrcweir inline void SetPropId( sal_Int32 nPropId ) { mnPropId = nPropId; } 225*cdf0e10cSrcweir inline void SetPropType( sal_Int32 nPropType ) { mnPropType = nPropType; } 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir private: 228*cdf0e10cSrcweir sal_Int32 mnPropId; 229*cdf0e10cSrcweir sal_Int32 mnPropType; 230*cdf0e10cSrcweir }; 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir typedef ::boost::shared_ptr< SfxOlePropertyBase > SfxOlePropertyRef; 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir // ============================================================================ 235*cdf0e10cSrcweir /** Property representing the codepage used to encode bytestrings in the entire property set. */ 236*cdf0e10cSrcweir class SfxOleCodePageProperty : public SfxOlePropertyBase, public SfxOleTextEncoding 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir public: 239*cdf0e10cSrcweir explicit SfxOleCodePageProperty(); 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir private: 242*cdf0e10cSrcweir virtual void ImplLoad( SvStream& rStrm ); 243*cdf0e10cSrcweir virtual void ImplSave( SvStream& rStrm ); 244*cdf0e10cSrcweir }; 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir // ============================================================================ 247*cdf0e10cSrcweir // ============================================================================ 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir /** Property containing custom names for other properties in the property set. */ 250*cdf0e10cSrcweir class SfxOleDictionaryProperty : public SfxOlePropertyBase, public SfxOleStringHelper 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir public: 253*cdf0e10cSrcweir explicit SfxOleDictionaryProperty( const SfxOleTextEncoding& rTextEnc ); 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir /** Returns true, if the property contains at least one custom property name. */ 256*cdf0e10cSrcweir inline bool HasPropertyNames() const { return !maPropNameMap.empty(); } 257*cdf0e10cSrcweir /** Prepares the property for loading. Does not affect contained names for its own. */ 258*cdf0e10cSrcweir inline void SetNameCount( sal_Int32 nNameCount ) { SetPropType( nNameCount ); } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir /** Returns the custom name for the passed property ID, or an empty string, if name not found. */ 261*cdf0e10cSrcweir const String& GetPropertyName( sal_Int32 nPropId ) const; 262*cdf0e10cSrcweir /** Sets a custom name for the passed property ID. */ 263*cdf0e10cSrcweir void SetPropertyName( sal_Int32 nPropId, const String& rPropName ); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir private: 266*cdf0e10cSrcweir virtual void ImplLoad( SvStream& rStrm ); 267*cdf0e10cSrcweir virtual void ImplSave( SvStream& rStrm ); 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir private: 270*cdf0e10cSrcweir typedef ::std::map< sal_Int32, String > SfxOlePropNameMap; 271*cdf0e10cSrcweir SfxOlePropNameMap maPropNameMap; 272*cdf0e10cSrcweir }; 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir // ============================================================================ 275*cdf0e10cSrcweir // ============================================================================ 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir /** A section in a property set. Contains properties with unique identifiers. */ 278*cdf0e10cSrcweir class SfxOleSection : public SfxOleObjectBase 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir private: 281*cdf0e10cSrcweir typedef ::std::map< sal_Int32, SfxOlePropertyRef > SfxOlePropMap; 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir public: 284*cdf0e10cSrcweir explicit SfxOleSection( bool bSupportsDict ); 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir /** Returns the property with the passed ID, or an empty reference, if nothing found. */ 287*cdf0e10cSrcweir SfxOlePropertyRef GetProperty( sal_Int32 nPropId ) const; 288*cdf0e10cSrcweir /** Returns the value of a signed int32 property with the passed ID in rnValue. 289*cdf0e10cSrcweir @return true = Property found, rnValue is valid; false = Property not found. */ 290*cdf0e10cSrcweir bool GetInt32Value( sal_Int32& rnValue, sal_Int32 nPropId ) const; 291*cdf0e10cSrcweir /** Returns the value of a floating-point property with the passed ID in rfValue. 292*cdf0e10cSrcweir @return true = Property found, rfValue is valid; false = Property not found. */ 293*cdf0e10cSrcweir bool GetDoubleValue( double& rfValue, sal_Int32 nPropId ) const; 294*cdf0e10cSrcweir /** Returns the value of a boolean property with the passed ID in rbValue. 295*cdf0e10cSrcweir @return true = Property found, rbValue is valid; false = Property not found. */ 296*cdf0e10cSrcweir bool GetBoolValue( bool& rbValue, sal_Int32 nPropId ) const; 297*cdf0e10cSrcweir /** Returns the value of a string property with the passed ID in rValue. 298*cdf0e10cSrcweir @return true = Property found, rValue is valid; false = Property not found. */ 299*cdf0e10cSrcweir bool GetStringValue( String& rValue, sal_Int32 nPropId ) const; 300*cdf0e10cSrcweir /** Returns the value of a time stamp property with the passed ID in rValue. 301*cdf0e10cSrcweir @return true = Property found, rValue is valid; false = Property not found. */ 302*cdf0e10cSrcweir bool GetFileTimeValue( ::com::sun::star::util::DateTime& rValue, sal_Int32 nPropId ) const; 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir /** Adds the passed property to the property set. Drops an existing old property. */ 305*cdf0e10cSrcweir void SetProperty( SfxOlePropertyRef xProp ); 306*cdf0e10cSrcweir /** Inserts a signed int32 property with the passed value. */ 307*cdf0e10cSrcweir void SetInt32Value( sal_Int32 nPropId, sal_Int32 nValue ); 308*cdf0e10cSrcweir /** Inserts a foating-point property with the passed value. */ 309*cdf0e10cSrcweir void SetDoubleValue( sal_Int32 nPropId, double fValue ); 310*cdf0e10cSrcweir /** Inserts a boolean property with the passed value. */ 311*cdf0e10cSrcweir void SetBoolValue( sal_Int32 nPropId, bool bValue ); 312*cdf0e10cSrcweir /** Inserts a string property with the passed value. 313*cdf0e10cSrcweir @return true = Property inserted; false = String was empty, property not inserted. */ 314*cdf0e10cSrcweir bool SetStringValue( sal_Int32 nPropId, const String& rValue, bool bSkipEmpty = true ); 315*cdf0e10cSrcweir /** Inserts a time stamp property with the passed value. */ 316*cdf0e10cSrcweir void SetFileTimeValue( sal_Int32 nPropId, const ::com::sun::star::util::DateTime& rValue ); 317*cdf0e10cSrcweir /** Inserts a thumbnail property from the passed meta file. */ 318*cdf0e10cSrcweir void SetThumbnailValue( sal_Int32 nPropId, 319*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence<sal_uInt8> & i_rData); 320*cdf0e10cSrcweir /** Inserts a BLOB property with the passed data. */ 321*cdf0e10cSrcweir void SetBlobValue( sal_Int32 nPropId, 322*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence<sal_uInt8> & i_rData); 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir /** Returns the value of the property with the passed ID in a UNO any. */ 325*cdf0e10cSrcweir com::sun::star::uno::Any GetAnyValue( sal_Int32 nPropId ) const; 326*cdf0e10cSrcweir /** Inserts a property created from the passed any. 327*cdf0e10cSrcweir @return true = Property converted and inserted; false = Property type not supported. */ 328*cdf0e10cSrcweir bool SetAnyValue( sal_Int32 nPropId, const com::sun::star::uno::Any& rValue ); 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir /** Returns the custom name for the passed property ID, or an empty string, if name not found. */ 331*cdf0e10cSrcweir const String& GetPropertyName( sal_Int32 nPropId ) const; 332*cdf0e10cSrcweir /** Sets a custom name for the passed property ID. */ 333*cdf0e10cSrcweir void SetPropertyName( sal_Int32 nPropId, const String& rPropName ); 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir /** Returns the identifiers of all existing properties in the passed vector. */ 336*cdf0e10cSrcweir void GetPropertyIds( ::std::vector< sal_Int32 >& rPropIds ) const; 337*cdf0e10cSrcweir /** Returns a property identifier not used in this section. */ 338*cdf0e10cSrcweir sal_Int32 GetFreePropertyId() const; 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir private: 341*cdf0e10cSrcweir virtual void ImplLoad( SvStream& rStrm ); 342*cdf0e10cSrcweir virtual void ImplSave( SvStream& rStrm ); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir bool SeekToPropertyPos( SvStream& rStrm, sal_uInt32 nPropPos ) const; 345*cdf0e10cSrcweir void LoadProperty( SvStream& rStrm, sal_Int32 nPropId ); 346*cdf0e10cSrcweir void SaveProperty( SvStream& rStrm, SfxOlePropertyBase& rProp, sal_Size& rnPropPosPos ); 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir private: 349*cdf0e10cSrcweir SfxOlePropMap maPropMap; /// All properties in this section, by identifier. 350*cdf0e10cSrcweir SfxOleCodePageProperty maCodePageProp; /// The codepage property. 351*cdf0e10cSrcweir SfxOleDictionaryProperty maDictProp; /// The dictionary property. 352*cdf0e10cSrcweir sal_Size mnStartPos; /// Start stream position of the section. 353*cdf0e10cSrcweir bool mbSupportsDict; /// true = section supports dictionary. 354*cdf0e10cSrcweir }; 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir typedef ::boost::shared_ptr< SfxOleSection > SfxOleSectionRef; 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir // ============================================================================ 359*cdf0e10cSrcweir // ============================================================================ 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir /** Enumerates different section types in OLE property sets. */ 362*cdf0e10cSrcweir enum SfxOleSectionType 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir SECTION_GLOBAL, /// Globally defined properties. 365*cdf0e10cSrcweir SECTION_BUILTIN, /// Properties built into MS Office. 366*cdf0e10cSrcweir SECTION_CUSTOM /// Custom properties. 367*cdf0e10cSrcweir }; 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir // ============================================================================ 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir /** Represents a complete property set, may consist of several property sections. */ 372*cdf0e10cSrcweir class SfxOlePropertySet : public SfxOleObjectBase 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir public: 375*cdf0e10cSrcweir inline explicit SfxOlePropertySet() {} 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir /** Loads this object from the passed storage. */ 378*cdf0e10cSrcweir ErrCode LoadPropertySet( SotStorage* pStrg, const String& rStrmName ); 379*cdf0e10cSrcweir /** Saves this object to the passed storage. */ 380*cdf0e10cSrcweir ErrCode SavePropertySet( SotStorage* pStrg, const String& rStrmName ); 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir /** Returns the specified section, or an empty reference, if nothing found. */ 383*cdf0e10cSrcweir SfxOleSectionRef GetSection( SfxOleSectionType eSection ) const; 384*cdf0e10cSrcweir /** Returns the specified section, or an empty reference, if nothing found. */ 385*cdf0e10cSrcweir SfxOleSectionRef GetSection( const SvGlobalName& rSectionGuid ) const; 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir /** Creates and returns the specified section, or just returns it if it already exists. */ 388*cdf0e10cSrcweir SfxOleSection& AddSection( SfxOleSectionType eSection ); 389*cdf0e10cSrcweir /** Creates and returns the specified section, or just returns it if it already exists. */ 390*cdf0e10cSrcweir SfxOleSection& AddSection( const SvGlobalName& rSectionGuid ); 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir private: 393*cdf0e10cSrcweir virtual void ImplLoad( SvStream& rStrm ); 394*cdf0e10cSrcweir virtual void ImplSave( SvStream& rStrm ); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir /** Returns the GUID for the specified section. */ 397*cdf0e10cSrcweir static const SvGlobalName& GetSectionGuid( SfxOleSectionType eSection ); 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir private: 400*cdf0e10cSrcweir typedef ::std::map< SvGlobalName, SfxOleSectionRef > SfxOleSectionMap; 401*cdf0e10cSrcweir SfxOleSectionMap maSectionMap; 402*cdf0e10cSrcweir }; 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir //}; 405