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