1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*38d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*38d50f7bSAndrew Rist * distributed with this work for additional information
6*38d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*38d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at
10*38d50f7bSAndrew Rist *
11*38d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*38d50f7bSAndrew Rist *
13*38d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist * KIND, either express or implied. See the License for the
17*38d50f7bSAndrew Rist * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist * under the License.
19*38d50f7bSAndrew Rist *
20*38d50f7bSAndrew Rist *************************************************************/
21*38d50f7bSAndrew Rist
22*38d50f7bSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef SC_XERECORD_HXX
25cdf0e10cSrcweir #define SC_XERECORD_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "xlconst.hxx"
28cdf0e10cSrcweir #include "xestream.hxx"
29cdf0e10cSrcweir
30cdf0e10cSrcweir // Base classes to export Excel records =======================================
31cdf0e10cSrcweir
32cdf0e10cSrcweir /** Base class for all Excel records.
33cdf0e10cSrcweir
34cdf0e10cSrcweir Derive from this class to implement any functionality performed during
35cdf0e10cSrcweir saving the records - except really writing a record (i.e. write a list of
36cdf0e10cSrcweir records contained in the class). Derive from XclExpRecord (instead from
37cdf0e10cSrcweir this class) to write common records.
38cdf0e10cSrcweir */
39cdf0e10cSrcweir class XclExpRecordBase
40cdf0e10cSrcweir {
41cdf0e10cSrcweir public:
42cdf0e10cSrcweir virtual ~XclExpRecordBase();
43cdf0e10cSrcweir
44cdf0e10cSrcweir /** Overwrite this method to do any operation while saving the record. */
45cdf0e10cSrcweir virtual void Save( XclExpStream& rStrm );
46cdf0e10cSrcweir virtual void SaveXml( XclExpXmlStream& rStrm );
47cdf0e10cSrcweir };
48cdf0e10cSrcweir
49cdf0e10cSrcweir // ----------------------------------------------------------------------------
50cdf0e10cSrcweir
51cdf0e10cSrcweir class XclExpDelegatingRecord : public XclExpRecordBase
52cdf0e10cSrcweir {
53cdf0e10cSrcweir public:
54cdf0e10cSrcweir XclExpDelegatingRecord( XclExpRecordBase* pRecord );
55cdf0e10cSrcweir ~XclExpDelegatingRecord();
56cdf0e10cSrcweir
57cdf0e10cSrcweir virtual void SaveXml( XclExpXmlStream& rStrm );
58cdf0e10cSrcweir private:
59cdf0e10cSrcweir XclExpRecordBase* mpRecord;
60cdf0e10cSrcweir };
61cdf0e10cSrcweir
62cdf0e10cSrcweir // ----------------------------------------------------------------------------
63cdf0e10cSrcweir
64cdf0e10cSrcweir class XclExpXmlElementRecord : public XclExpRecordBase
65cdf0e10cSrcweir {
66cdf0e10cSrcweir public:
67cdf0e10cSrcweir XclExpXmlElementRecord( sal_Int32 nElement, void (*pAttributes)( XclExpXmlStream& rStrm) = NULL );
68cdf0e10cSrcweir virtual ~XclExpXmlElementRecord();
69cdf0e10cSrcweir
70cdf0e10cSrcweir protected:
71cdf0e10cSrcweir sal_Int32 mnElement;
72cdf0e10cSrcweir void (*mpAttributes)( XclExpXmlStream& rStrm );
73cdf0e10cSrcweir };
74cdf0e10cSrcweir
75cdf0e10cSrcweir // ----------------------------------------------------------------------------
76cdf0e10cSrcweir
77cdf0e10cSrcweir class XclExpXmlStartElementRecord : public XclExpXmlElementRecord
78cdf0e10cSrcweir {
79cdf0e10cSrcweir public:
80cdf0e10cSrcweir XclExpXmlStartElementRecord( sal_Int32 nElement, void (*pAttributes)( XclExpXmlStream& rStrm) = NULL );
81cdf0e10cSrcweir virtual ~XclExpXmlStartElementRecord();
82cdf0e10cSrcweir
83cdf0e10cSrcweir /** Starts the element nElement */
84cdf0e10cSrcweir virtual void SaveXml( XclExpXmlStream& rStrm );
85cdf0e10cSrcweir };
86cdf0e10cSrcweir
87cdf0e10cSrcweir // ----------------------------------------------------------------------------
88cdf0e10cSrcweir
89cdf0e10cSrcweir class XclExpXmlEndElementRecord : public XclExpXmlElementRecord
90cdf0e10cSrcweir {
91cdf0e10cSrcweir public:
92cdf0e10cSrcweir XclExpXmlEndElementRecord( sal_Int32 nElement );
93cdf0e10cSrcweir virtual ~XclExpXmlEndElementRecord();
94cdf0e10cSrcweir
95cdf0e10cSrcweir /** Ends the element nElement */
96cdf0e10cSrcweir virtual void SaveXml( XclExpXmlStream& rStrm );
97cdf0e10cSrcweir };
98cdf0e10cSrcweir
99cdf0e10cSrcweir // ----------------------------------------------------------------------------
100cdf0e10cSrcweir
101cdf0e10cSrcweir class XclExpXmlStartSingleElementRecord : public XclExpXmlElementRecord
102cdf0e10cSrcweir {
103cdf0e10cSrcweir public:
104cdf0e10cSrcweir XclExpXmlStartSingleElementRecord( sal_Int32 nElement, void (*pAttributes)( XclExpXmlStream& rStrm) = NULL );
105cdf0e10cSrcweir virtual ~XclExpXmlStartSingleElementRecord();
106cdf0e10cSrcweir
107cdf0e10cSrcweir /** Starts the single element nElement */
108cdf0e10cSrcweir virtual void SaveXml( XclExpXmlStream& rStrm );
109cdf0e10cSrcweir };
110cdf0e10cSrcweir
111cdf0e10cSrcweir // ----------------------------------------------------------------------------
112cdf0e10cSrcweir
113cdf0e10cSrcweir class XclExpXmlEndSingleElementRecord : public XclExpRecordBase
114cdf0e10cSrcweir {
115cdf0e10cSrcweir public:
116cdf0e10cSrcweir XclExpXmlEndSingleElementRecord();
117cdf0e10cSrcweir virtual ~XclExpXmlEndSingleElementRecord();
118cdf0e10cSrcweir
119cdf0e10cSrcweir /** Ends the single element nElement */
120cdf0e10cSrcweir virtual void SaveXml( XclExpXmlStream& rStrm );
121cdf0e10cSrcweir };
122cdf0e10cSrcweir
123cdf0e10cSrcweir // ----------------------------------------------------------------------------
124cdf0e10cSrcweir
125cdf0e10cSrcweir /** Base class for single records with any content.
126cdf0e10cSrcweir
127cdf0e10cSrcweir This class handles writing the record header. Derived classes only have to
128cdf0e10cSrcweir write the record body. Calculating the record size before saving optimizes
129cdf0e10cSrcweir the write process (the stream does not have to seek back and update the
130cdf0e10cSrcweir written record size). But it is not required to calculate a valid size
131cdf0e10cSrcweir (maybe it would be too complex or just impossible until the record is
132cdf0e10cSrcweir really written).
133cdf0e10cSrcweir */
134cdf0e10cSrcweir class XclExpRecord : public XclExpRecordBase
135cdf0e10cSrcweir {
136cdf0e10cSrcweir public:
137cdf0e10cSrcweir /** @param nRecId The record ID of this record. May be set later with SetRecId().
138cdf0e10cSrcweir @param nRecSize The predicted record size. May be set later with SetRecSize(). */
139cdf0e10cSrcweir explicit XclExpRecord(
140cdf0e10cSrcweir sal_uInt16 nRecId = EXC_ID_UNKNOWN,
141cdf0e10cSrcweir sal_Size nRecSize = 0 );
142cdf0e10cSrcweir
143cdf0e10cSrcweir virtual ~XclExpRecord();
144cdf0e10cSrcweir
145cdf0e10cSrcweir /** Returns the current record ID. */
GetRecId() const146cdf0e10cSrcweir inline sal_uInt16 GetRecId() const { return mnRecId; }
147cdf0e10cSrcweir /** Returns the current record size prediction. */
GetRecSize() const148cdf0e10cSrcweir inline sal_Size GetRecSize() const { return mnRecSize; }
149cdf0e10cSrcweir
150cdf0e10cSrcweir /** Sets a new record ID. */
SetRecId(sal_uInt16 nRecId)151cdf0e10cSrcweir inline void SetRecId( sal_uInt16 nRecId ) { mnRecId = nRecId; }
152cdf0e10cSrcweir /** Sets a new record size prediction. */
SetRecSize(sal_Size nRecSize)153cdf0e10cSrcweir inline void SetRecSize( sal_Size nRecSize ) { mnRecSize = nRecSize; }
154cdf0e10cSrcweir /** Adds a size value to the record size prediction. */
AddRecSize(sal_Size nRecSize)155cdf0e10cSrcweir inline void AddRecSize( sal_Size nRecSize ) { mnRecSize += nRecSize; }
156cdf0e10cSrcweir /** Sets record ID and size with one call. */
157cdf0e10cSrcweir void SetRecHeader( sal_uInt16 nRecId, sal_Size nRecSize );
158cdf0e10cSrcweir
159cdf0e10cSrcweir /** Writes the record header and calls WriteBody(). */
160cdf0e10cSrcweir virtual void Save( XclExpStream& rStrm );
161cdf0e10cSrcweir
162cdf0e10cSrcweir protected:
163cdf0e10cSrcweir /** Writes the body of the record (without record header).
164cdf0e10cSrcweir @descr Usually this method will be overwritten by derived classes. */
165cdf0e10cSrcweir virtual void WriteBody( XclExpStream& rStrm );
166cdf0e10cSrcweir
167cdf0e10cSrcweir private:
168cdf0e10cSrcweir sal_Size mnRecSize; /// The predicted record size.
169cdf0e10cSrcweir sal_uInt16 mnRecId; /// The record ID.
170cdf0e10cSrcweir };
171cdf0e10cSrcweir
172cdf0e10cSrcweir // ----------------------------------------------------------------------------
173cdf0e10cSrcweir
174cdf0e10cSrcweir /** A record without body. Only the record ID and the size 0 will be written. */
175cdf0e10cSrcweir class XclExpEmptyRecord : public XclExpRecord
176cdf0e10cSrcweir {
177cdf0e10cSrcweir public:
178cdf0e10cSrcweir /** @param nRecId The record ID of this record. */
179cdf0e10cSrcweir inline explicit XclExpEmptyRecord( sal_uInt16 nRecId );
180cdf0e10cSrcweir };
181cdf0e10cSrcweir
XclExpEmptyRecord(sal_uInt16 nRecId)182cdf0e10cSrcweir inline XclExpEmptyRecord::XclExpEmptyRecord( sal_uInt16 nRecId ) :
183cdf0e10cSrcweir XclExpRecord( nRecId, 0 )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir }
186cdf0e10cSrcweir
187cdf0e10cSrcweir // ============================================================================
188cdf0e10cSrcweir
189cdf0e10cSrcweir /** A record with a single value of type Type.
190cdf0e10cSrcweir @descr Requires operator<<( XclExpStream&, const Type& ). */
191cdf0e10cSrcweir template< typename Type >
192cdf0e10cSrcweir class XclExpValueRecord : public XclExpRecord
193cdf0e10cSrcweir {
194cdf0e10cSrcweir public:
195cdf0e10cSrcweir /** @param nRecId The record ID of this record.
196cdf0e10cSrcweir @param rValue The value for the record body.
197cdf0e10cSrcweir @param nSize Record size. Uses sizeof( Type ), if this parameter is omitted. */
XclExpValueRecord(sal_uInt16 nRecId,const Type & rValue,sal_Size nSize=sizeof (Type))198cdf0e10cSrcweir inline explicit XclExpValueRecord( sal_uInt16 nRecId, const Type& rValue, sal_Size nSize = sizeof( Type ) ) :
199cdf0e10cSrcweir XclExpRecord( nRecId, nSize ), maValue( rValue ), mnAttribute( -1 ) {}
200cdf0e10cSrcweir
201cdf0e10cSrcweir /** Returns the value of the record. */
GetValue() const202cdf0e10cSrcweir inline const Type& GetValue() const { return maValue; }
203cdf0e10cSrcweir /** Sets a new record value. */
SetValue(const Type & rValue)204cdf0e10cSrcweir inline void SetValue( const Type& rValue ) { maValue = rValue; }
205cdf0e10cSrcweir
206cdf0e10cSrcweir /** Sets the OOXML attribute this record corresponds to */
207cdf0e10cSrcweir XclExpValueRecord* SetAttribute( sal_Int32 nId );
208cdf0e10cSrcweir
209cdf0e10cSrcweir /** Write the OOXML attribute and its value */
210cdf0e10cSrcweir void SaveXml( XclExpXmlStream& rStrm );
211cdf0e10cSrcweir
212cdf0e10cSrcweir private:
213cdf0e10cSrcweir /** Writes the body of the record. */
WriteBody(XclExpStream & rStrm)214cdf0e10cSrcweir inline virtual void WriteBody( XclExpStream& rStrm ) { rStrm << maValue; }
215cdf0e10cSrcweir // inlining prevents warning in wntmsci10
216cdf0e10cSrcweir
217cdf0e10cSrcweir private:
218cdf0e10cSrcweir Type maValue; /// The record data.
219cdf0e10cSrcweir sal_Int32 mnAttribute; /// The OOXML attribute Id
220cdf0e10cSrcweir };
221cdf0e10cSrcweir
222cdf0e10cSrcweir template< typename Type >
SaveXml(XclExpXmlStream & rStrm)223cdf0e10cSrcweir void XclExpValueRecord< Type >::SaveXml( XclExpXmlStream& rStrm )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir if( mnAttribute == -1 )
226cdf0e10cSrcweir return;
227cdf0e10cSrcweir rStrm.WriteAttributes(
228cdf0e10cSrcweir mnAttribute, rtl::OString::valueOf( (sal_Int32) maValue ).getStr(),
229cdf0e10cSrcweir FSEND );
230cdf0e10cSrcweir }
231cdf0e10cSrcweir
232cdf0e10cSrcweir template<>
233cdf0e10cSrcweir void XclExpValueRecord<double>::SaveXml( XclExpXmlStream& rStrm );
234cdf0e10cSrcweir
235cdf0e10cSrcweir template< typename Type >
SetAttribute(sal_Int32 nId)236cdf0e10cSrcweir XclExpValueRecord< Type >* XclExpValueRecord< Type >::SetAttribute( sal_Int32 nId )
237cdf0e10cSrcweir {
238cdf0e10cSrcweir mnAttribute = nId;
239cdf0e10cSrcweir return this;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir
242cdf0e10cSrcweir // ----------------------------------------------------------------------------
243cdf0e10cSrcweir
244cdf0e10cSrcweir /** A record containing an unsigned 16-bit value. */
245cdf0e10cSrcweir typedef XclExpValueRecord< sal_uInt16 > XclExpUInt16Record;
246cdf0e10cSrcweir
247cdf0e10cSrcweir /** A record containing an unsigned 32-bit value. */
248cdf0e10cSrcweir typedef XclExpValueRecord< sal_uInt32 > XclExpUInt32Record;
249cdf0e10cSrcweir
250cdf0e10cSrcweir /** A record containing a double value. */
251cdf0e10cSrcweir typedef XclExpValueRecord< double > XclExpDoubleRecord;
252cdf0e10cSrcweir
253cdf0e10cSrcweir // ----------------------------------------------------------------------------
254cdf0e10cSrcweir
255cdf0e10cSrcweir /** Record which contains a Boolean value.
256cdf0e10cSrcweir @descr The value is stored as 16-bit value: 0x0000 = sal_False, 0x0001 = TRUE. */
257cdf0e10cSrcweir class XclExpBoolRecord : public XclExpRecord
258cdf0e10cSrcweir {
259cdf0e10cSrcweir public:
260cdf0e10cSrcweir /** @param nRecId The record ID of this record.
261cdf0e10cSrcweir @param nValue The value for the record body. */
XclExpBoolRecord(sal_uInt16 nRecId,bool bValue,sal_Int32 nAttribute=-1)262cdf0e10cSrcweir inline explicit XclExpBoolRecord( sal_uInt16 nRecId, bool bValue, sal_Int32 nAttribute = -1 ) :
263cdf0e10cSrcweir XclExpRecord( nRecId, 2 ), mbValue( bValue ), mnAttribute( nAttribute ) {}
264cdf0e10cSrcweir
265cdf0e10cSrcweir /** Returns the Boolean value of the record. */
GetBool() const266cdf0e10cSrcweir inline bool GetBool() const { return mbValue; }
267cdf0e10cSrcweir /** Sets a new Boolean record value. */
SetBool(bool bValue)268cdf0e10cSrcweir inline void SetBool( bool bValue ) { mbValue = bValue; }
269cdf0e10cSrcweir
270cdf0e10cSrcweir virtual void SaveXml( XclExpXmlStream& rStrm );
271cdf0e10cSrcweir
272cdf0e10cSrcweir private:
273cdf0e10cSrcweir /** Writes the body of the record. */
274cdf0e10cSrcweir virtual void WriteBody( XclExpStream& rStrm );
275cdf0e10cSrcweir
276cdf0e10cSrcweir private:
277cdf0e10cSrcweir bool mbValue; /// The record data.
278cdf0e10cSrcweir sal_Int32 mnAttribute; /// The attribute to generate within SaveXml()
279cdf0e10cSrcweir };
280cdf0e10cSrcweir
281cdf0e10cSrcweir // ----------------------------------------------------------------------------
282cdf0e10cSrcweir
283cdf0e10cSrcweir /** Record which exports a memory data array. */
284cdf0e10cSrcweir class XclExpDummyRecord : public XclExpRecord
285cdf0e10cSrcweir {
286cdf0e10cSrcweir public:
287cdf0e10cSrcweir /** @param nRecId The record ID of this record.
288cdf0e10cSrcweir @param pRecData Pointer to the data array representing the record body.
289cdf0e10cSrcweir @param nRecSize Size of the data array. */
290cdf0e10cSrcweir explicit XclExpDummyRecord(
291cdf0e10cSrcweir sal_uInt16 nRecId, const void* pRecData, sal_Size nRecSize );
292cdf0e10cSrcweir
293cdf0e10cSrcweir /** Sets a data array. */
294cdf0e10cSrcweir void SetData( const void* pRecData, sal_Size nRecSize );
295cdf0e10cSrcweir
296cdf0e10cSrcweir private:
297cdf0e10cSrcweir /** Writes the body of the record. */
298cdf0e10cSrcweir virtual void WriteBody( XclExpStream& rStrm );
299cdf0e10cSrcweir
300cdf0e10cSrcweir private:
301cdf0e10cSrcweir const void* mpData; /// The record data.
302cdf0e10cSrcweir };
303cdf0e10cSrcweir
304cdf0e10cSrcweir // Future records =============================================================
305cdf0e10cSrcweir
306cdf0e10cSrcweir class XclExpFutureRecord : public XclExpRecord
307cdf0e10cSrcweir {
308cdf0e10cSrcweir public:
309cdf0e10cSrcweir explicit XclExpFutureRecord( XclFutureRecType eRecType,
310cdf0e10cSrcweir sal_uInt16 nRecId, sal_Size nRecSize = 0 );
311cdf0e10cSrcweir
312cdf0e10cSrcweir /** Writes the extended record header and calls WriteBody(). */
313cdf0e10cSrcweir virtual void Save( XclExpStream& rStrm );
314cdf0e10cSrcweir
315cdf0e10cSrcweir private:
316cdf0e10cSrcweir XclFutureRecType meRecType;
317cdf0e10cSrcweir };
318cdf0e10cSrcweir
319cdf0e10cSrcweir // List of records ============================================================
320cdf0e10cSrcweir
321cdf0e10cSrcweir /** A list of Excel record objects.
322cdf0e10cSrcweir
323cdf0e10cSrcweir Provides saving the compete list. This class is derived from
324cdf0e10cSrcweir XclExpRecordBase, so it can be used as record in another record list.
325cdf0e10cSrcweir Requires RecType::Save( XclExpStream& ).
326cdf0e10cSrcweir */
327cdf0e10cSrcweir template< typename RecType = XclExpRecordBase >
328cdf0e10cSrcweir class XclExpRecordList : public XclExpRecordBase
329cdf0e10cSrcweir {
330cdf0e10cSrcweir public:
331cdf0e10cSrcweir typedef ScfRef< RecType > RecordRefType;
332cdf0e10cSrcweir
333cdf0e10cSrcweir /** Returns pointer to an existing record or 0 on error. */
IsEmpty() const334cdf0e10cSrcweir inline bool IsEmpty() const { return maRecs.empty(); }
335cdf0e10cSrcweir /** Returns pointer to an existing record or 0 on error. */
GetSize() const336cdf0e10cSrcweir inline size_t GetSize() const { return maRecs.size(); }
337cdf0e10cSrcweir
338cdf0e10cSrcweir /** Returns true, if the passed index points to an exiting record. */
HasRecord(size_t nPos) const339cdf0e10cSrcweir inline bool HasRecord( size_t nPos ) const
340cdf0e10cSrcweir { return nPos < maRecs.size(); }
341cdf0e10cSrcweir /** Returns reference to an existing record or empty reference on error. */
GetRecord(size_t nPos) const342cdf0e10cSrcweir inline RecordRefType GetRecord( size_t nPos ) const
343cdf0e10cSrcweir { return (nPos < maRecs.size()) ? maRecs[ nPos ] : RecordRefType(); }
344cdf0e10cSrcweir /** Returns reference to the first existing record or empty reference, if list is empty. */
GetFirstRecord() const345cdf0e10cSrcweir inline RecordRefType GetFirstRecord() const
346cdf0e10cSrcweir { return maRecs.empty() ? RecordRefType() : maRecs.front(); }
347cdf0e10cSrcweir /** Returns reference to the last existing record or empty reference, if list is empty. */
GetLastRecord() const348cdf0e10cSrcweir inline RecordRefType GetLastRecord() const
349cdf0e10cSrcweir { return maRecs.empty() ? RecordRefType() : maRecs.back(); }
350cdf0e10cSrcweir
351cdf0e10cSrcweir /** Inserts a record at the specified position into the list. */
InsertRecord(RecordRefType xRec,size_t nPos)352cdf0e10cSrcweir inline void InsertRecord( RecordRefType xRec, size_t nPos )
353cdf0e10cSrcweir { if( xRec.get() ) maRecs.insert( maRecs.begin() + ::std::min( nPos, maRecs.size() ), xRec ); }
354cdf0e10cSrcweir /** Appends a record to the list. */
AppendRecord(RecordRefType xRec)355cdf0e10cSrcweir inline void AppendRecord( RecordRefType xRec )
356cdf0e10cSrcweir { if( xRec.get() ) maRecs.push_back( xRec ); }
357cdf0e10cSrcweir /** Replaces the record at the specified position from the list with the passed record. */
ReplaceRecord(RecordRefType xRec,size_t nPos)358cdf0e10cSrcweir inline void ReplaceRecord( RecordRefType xRec, size_t nPos )
359cdf0e10cSrcweir { RemoveRecord( nPos ); InsertRecord( xRec, nPos ); }
360cdf0e10cSrcweir
361cdf0e10cSrcweir /** Inserts a newly created record at the specified position into the list. */
InsertNewRecord(RecType * pRec,size_t nPos)362cdf0e10cSrcweir inline void InsertNewRecord( RecType* pRec, size_t nPos )
363cdf0e10cSrcweir { if( pRec ) InsertRecord( RecordRefType( pRec ), nPos ); }
364cdf0e10cSrcweir /** Appends a newly created record to the list. */
AppendNewRecord(RecType * pRec)365cdf0e10cSrcweir inline void AppendNewRecord( RecType* pRec )
366cdf0e10cSrcweir { if( pRec ) AppendRecord( RecordRefType( pRec ) ); }
367cdf0e10cSrcweir /** Replaces the record at the specified position from the list with the passed newly created record. */
ReplaceNewRecord(RecType * pRec,size_t nPos)368cdf0e10cSrcweir inline void ReplaceNewRecord( RecType* pRec, size_t nPos )
369cdf0e10cSrcweir { RemoveRecord( nPos ); InsertNewRecord( pRec, nPos ); }
370cdf0e10cSrcweir
371cdf0e10cSrcweir /** Removes the record at the specified position from the list. */
RemoveRecord(size_t nPos)372cdf0e10cSrcweir inline void RemoveRecord( size_t nPos )
373cdf0e10cSrcweir { if( nPos < maRecs.size() ) maRecs.erase( maRecs.begin() + nPos ); }
374cdf0e10cSrcweir /** Removes all records from the list. */
RemoveAllRecords()375cdf0e10cSrcweir inline void RemoveAllRecords() { maRecs.clear(); }
376cdf0e10cSrcweir
377cdf0e10cSrcweir /** Writes the complete record list. */
Save(XclExpStream & rStrm)378cdf0e10cSrcweir inline virtual void Save( XclExpStream& rStrm )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir // inlining prevents warning in wntmsci10
381cdf0e10cSrcweir for( typename RecordVec::iterator aIt = maRecs.begin(), aEnd = maRecs.end(); aIt != aEnd; ++aIt )
382cdf0e10cSrcweir (*aIt)->Save( rStrm );
383cdf0e10cSrcweir }
384cdf0e10cSrcweir
SaveXml(XclExpXmlStream & rStrm)385cdf0e10cSrcweir inline virtual void SaveXml( XclExpXmlStream& rStrm )
386cdf0e10cSrcweir {
387cdf0e10cSrcweir // inlining prevents warning in wntmsci10
388cdf0e10cSrcweir for( typename RecordVec::iterator aIt = maRecs.begin(), aEnd = maRecs.end(); aIt != aEnd; ++aIt )
389cdf0e10cSrcweir (*aIt)->SaveXml( rStrm );
390cdf0e10cSrcweir }
391cdf0e10cSrcweir
392cdf0e10cSrcweir private:
393cdf0e10cSrcweir typedef ::std::vector< RecordRefType > RecordVec;
394cdf0e10cSrcweir RecordVec maRecs;
395cdf0e10cSrcweir };
396cdf0e10cSrcweir
397cdf0e10cSrcweir // ============================================================================
398cdf0e10cSrcweir
399cdf0e10cSrcweir /** Represents a complete substream of records enclosed into a pair of BOF/EOF records. */
400cdf0e10cSrcweir class XclExpSubStream : public XclExpRecordList<>
401cdf0e10cSrcweir {
402cdf0e10cSrcweir public:
403cdf0e10cSrcweir explicit XclExpSubStream( sal_uInt16 nSubStrmType );
404cdf0e10cSrcweir
405cdf0e10cSrcweir /** Writes the complete substream, including leading BOF and trailing EOF. */
406cdf0e10cSrcweir virtual void Save( XclExpStream& rStrm );
407cdf0e10cSrcweir
408cdf0e10cSrcweir private:
409cdf0e10cSrcweir sal_uInt16 mnSubStrmType; /// Substream type, stored in leading BOF record.
410cdf0e10cSrcweir };
411cdf0e10cSrcweir
412cdf0e10cSrcweir // ============================================================================
413cdf0e10cSrcweir
414cdf0e10cSrcweir #endif
415cdf0e10cSrcweir
416