Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "xerecord.hxx"
30 : : #include "xeroot.hxx"
31 : :
32 : : using namespace ::oox;
33 : :
34 : : // Base classes to export Excel records =======================================
35 : :
36 : 0 : XclExpRecordBase::~XclExpRecordBase()
37 : : {
38 [ # # ]: 0 : }
39 : :
40 : 0 : void XclExpRecordBase::Save( XclExpStream& /*rStrm*/ )
41 : : {
42 : 0 : }
43 : :
44 : 0 : void XclExpRecordBase::SaveXml( XclExpXmlStream& /*rStrm*/ )
45 : : {
46 : 0 : }
47 : :
48 : : // ----------------------------------------------------------------------------
49 : :
50 : 0 : XclExpDelegatingRecord::XclExpDelegatingRecord( XclExpRecordBase* pRecord ) :
51 : 0 : mpRecord( pRecord )
52 : : {
53 : 0 : }
54 : :
55 : 0 : XclExpDelegatingRecord::~XclExpDelegatingRecord()
56 : : {
57 : : // Do Nothing; we use Delegating Record for other objects we "know" will
58 : : // survive...
59 [ # # ]: 0 : }
60 : :
61 : 0 : void XclExpDelegatingRecord::SaveXml( XclExpXmlStream& rStrm )
62 : : {
63 [ # # ]: 0 : if( mpRecord )
64 : 0 : mpRecord->SaveXml( rStrm );
65 : 0 : }
66 : :
67 : : // ----------------------------------------------------------------------------
68 : :
69 : 0 : XclExpXmlElementRecord::XclExpXmlElementRecord( sal_Int32 nElement, void (*pAttributes)( XclExpXmlStream& rStrm) )
70 : 0 : : mnElement( nElement ), mpAttributes( pAttributes )
71 : : {
72 : 0 : }
73 : :
74 : 0 : XclExpXmlElementRecord::~XclExpXmlElementRecord()
75 : : {
76 [ # # ]: 0 : }
77 : :
78 : : // ----------------------------------------------------------------------------
79 : :
80 : 0 : XclExpXmlStartElementRecord::XclExpXmlStartElementRecord( sal_Int32 nElement, void (*pAttributes)( XclExpXmlStream& rStrm) )
81 : 0 : : XclExpXmlElementRecord( nElement, pAttributes )
82 : : {
83 : 0 : }
84 : :
85 : 0 : XclExpXmlStartElementRecord::~XclExpXmlStartElementRecord()
86 : : {
87 [ # # ]: 0 : }
88 : :
89 : 0 : void XclExpXmlStartElementRecord::SaveXml( XclExpXmlStream& rStrm )
90 : : {
91 : 0 : sax_fastparser::FSHelperPtr& rStream = rStrm.GetCurrentStream();
92 [ # # ]: 0 : if( ! mpAttributes )
93 : : {
94 : 0 : rStream->startElement( mnElement, FSEND );
95 : : }
96 : : else
97 : : {
98 : 0 : rStream->write( "<" )->writeId( mnElement );
99 : 0 : (*mpAttributes)( rStrm );
100 : : }
101 : 0 : }
102 : :
103 : : // ----------------------------------------------------------------------------
104 : :
105 : 0 : XclExpXmlEndElementRecord::XclExpXmlEndElementRecord( sal_Int32 nElement )
106 : 0 : : XclExpXmlElementRecord( nElement )
107 : : {
108 : 0 : }
109 : :
110 : 0 : XclExpXmlEndElementRecord::~XclExpXmlEndElementRecord()
111 : : {
112 [ # # ]: 0 : }
113 : :
114 : 0 : void XclExpXmlEndElementRecord::SaveXml( XclExpXmlStream& rStrm )
115 : : {
116 : 0 : rStrm.GetCurrentStream()->endElement( mnElement );
117 : 0 : }
118 : :
119 : : // ----------------------------------------------------------------------------
120 : :
121 : 0 : XclExpXmlStartSingleElementRecord::XclExpXmlStartSingleElementRecord( sal_Int32 nElement, void (*pAttributes)( XclExpXmlStream& rStrm) )
122 : 0 : : XclExpXmlElementRecord( nElement, pAttributes )
123 : : {
124 : 0 : }
125 : :
126 : 0 : XclExpXmlStartSingleElementRecord::~XclExpXmlStartSingleElementRecord()
127 : : {
128 [ # # ]: 0 : }
129 : :
130 : 0 : void XclExpXmlStartSingleElementRecord::SaveXml( XclExpXmlStream& rStrm )
131 : : {
132 : 0 : sax_fastparser::FSHelperPtr& rStream = rStrm.GetCurrentStream();
133 : 0 : rStream->write( "<" )->writeId( mnElement );
134 [ # # ]: 0 : if( mpAttributes )
135 : 0 : (*mpAttributes)( rStrm );
136 : 0 : }
137 : :
138 : : // ----------------------------------------------------------------------------
139 : :
140 : 0 : XclExpXmlEndSingleElementRecord::XclExpXmlEndSingleElementRecord()
141 : : {
142 : 0 : }
143 : :
144 : 0 : XclExpXmlEndSingleElementRecord::~XclExpXmlEndSingleElementRecord()
145 : : {
146 [ # # ]: 0 : }
147 : :
148 : 0 : void XclExpXmlEndSingleElementRecord::SaveXml( XclExpXmlStream& rStrm )
149 : : {
150 : 0 : rStrm.GetCurrentStream()->write( "/>" );
151 : 0 : }
152 : :
153 : : // ----------------------------------------------------------------------------
154 : :
155 : 0 : XclExpRecord::XclExpRecord( sal_uInt16 nRecId, sal_Size nRecSize ) :
156 : : mnRecSize( nRecSize ),
157 : 0 : mnRecId( nRecId )
158 : : {
159 : 0 : }
160 : :
161 : 0 : XclExpRecord::~XclExpRecord()
162 : : {
163 [ # # ]: 0 : }
164 : :
165 : 0 : void XclExpRecord::SetRecHeader( sal_uInt16 nRecId, sal_Size nRecSize )
166 : : {
167 : 0 : SetRecId( nRecId );
168 : 0 : SetRecSize( nRecSize );
169 : 0 : }
170 : :
171 : 0 : void XclExpRecord::WriteBody( XclExpStream& /*rStrm*/ )
172 : : {
173 : 0 : }
174 : :
175 : 0 : void XclExpRecord::Save( XclExpStream& rStrm )
176 : : {
177 : : OSL_ENSURE( mnRecId != EXC_ID_UNKNOWN, "XclExpRecord::Save - record ID uninitialized" );
178 : 0 : rStrm.StartRecord( mnRecId, mnRecSize );
179 : 0 : WriteBody( rStrm );
180 : 0 : rStrm.EndRecord();
181 : 0 : }
182 : :
183 : : // ----------------------------------------------------------------------------
184 : :
185 : : template<>
186 : 0 : void XclExpValueRecord<double>::SaveXml( XclExpXmlStream& rStrm )
187 : : {
188 [ # # ]: 0 : if( mnAttribute == -1 )
189 : 0 : return;
190 : : rStrm.WriteAttributes(
191 : : mnAttribute, rtl::OString::valueOf( maValue ).getStr(),
192 [ # # ]: 0 : FSEND );
193 : : }
194 : :
195 : : // ----------------------------------------------------------------------------
196 : :
197 : 0 : void XclExpBoolRecord::WriteBody( XclExpStream& rStrm )
198 : : {
199 [ # # ]: 0 : rStrm << static_cast< sal_uInt16 >( mbValue ? 1 : 0 );
200 : 0 : }
201 : :
202 : 0 : void XclExpBoolRecord::SaveXml( XclExpXmlStream& rStrm )
203 : : {
204 [ # # ]: 0 : if( mnAttribute == -1 )
205 : 0 : return;
206 : :
207 : : rStrm.WriteAttributes(
208 : : // HACK: HIDEOBJ (excdoc.cxx) should be its own object to handle XML_showObjects
209 : 0 : mnAttribute, mnAttribute == XML_showObjects ? "all" : XclXmlUtils::ToPsz( mbValue ),
210 [ # # ]: 0 : FSEND );
211 : : }
212 : :
213 : : // ----------------------------------------------------------------------------
214 : :
215 : 0 : XclExpDummyRecord::XclExpDummyRecord( sal_uInt16 nRecId, const void* pRecData, sal_Size nRecSize ) :
216 : 0 : XclExpRecord( nRecId )
217 : : {
218 : 0 : SetData( pRecData, nRecSize );
219 : 0 : }
220 : :
221 : 0 : void XclExpDummyRecord::SetData( const void* pRecData, sal_Size nRecSize )
222 : : {
223 : 0 : mpData = pRecData;
224 [ # # ]: 0 : SetRecSize( pRecData ? nRecSize : 0 );
225 : 0 : }
226 : :
227 : 0 : void XclExpDummyRecord::WriteBody( XclExpStream& rStrm )
228 : : {
229 : 0 : rStrm.Write( mpData, GetRecSize() );
230 : 0 : }
231 : :
232 : : // Future records =============================================================
233 : :
234 : 0 : XclExpFutureRecord::XclExpFutureRecord( XclFutureRecType eRecType, sal_uInt16 nRecId, sal_Size nRecSize ) :
235 : : XclExpRecord( nRecId, nRecSize ),
236 : 0 : meRecType( eRecType )
237 : : {
238 : 0 : }
239 : :
240 : 0 : void XclExpFutureRecord::Save( XclExpStream& rStrm )
241 : : {
242 [ # # ]: 0 : rStrm.StartRecord( GetRecId(), GetRecSize() + ((meRecType == EXC_FUTUREREC_UNUSEDREF) ? 12 : 4) );
243 : 0 : rStrm << GetRecId() << sal_uInt16( 0 );
244 [ # # ]: 0 : if( meRecType == EXC_FUTUREREC_UNUSEDREF )
245 : 0 : rStrm.WriteZeroBytes( 8 );
246 : 0 : WriteBody( rStrm );
247 : 0 : rStrm.EndRecord();
248 : 0 : }
249 : :
250 : : // ============================================================================
251 : :
252 : 0 : XclExpSubStream::XclExpSubStream( sal_uInt16 nSubStrmType ) :
253 : 0 : mnSubStrmType( nSubStrmType )
254 : : {
255 : 0 : }
256 : :
257 : 0 : void XclExpSubStream::Save( XclExpStream& rStrm )
258 : : {
259 : : // BOF record
260 [ # # # # : 0 : switch( rStrm.GetRoot().GetBiff() )
# # ]
261 : : {
262 : : case EXC_BIFF2:
263 : 0 : rStrm.StartRecord( EXC_ID2_BOF, 4 );
264 : 0 : rStrm << sal_uInt16( 7 ) << mnSubStrmType;
265 : 0 : rStrm.EndRecord();
266 : 0 : break;
267 : : case EXC_BIFF3:
268 : 0 : rStrm.StartRecord( EXC_ID3_BOF, 6 );
269 : 0 : rStrm << sal_uInt16( 0 ) << mnSubStrmType << sal_uInt16( 2104 );
270 : 0 : rStrm.EndRecord();
271 : 0 : break;
272 : : case EXC_BIFF4:
273 : 0 : rStrm.StartRecord( EXC_ID4_BOF, 6 );
274 : 0 : rStrm << sal_uInt16( 0 ) << mnSubStrmType << sal_uInt16( 1705 );
275 : 0 : rStrm.EndRecord();
276 : 0 : break;
277 : : case EXC_BIFF5:
278 : 0 : rStrm.StartRecord( EXC_ID5_BOF, 8 );
279 : 0 : rStrm << EXC_BOF_BIFF5 << mnSubStrmType << sal_uInt16( 4915 ) << sal_uInt16( 1994 );
280 : 0 : rStrm.EndRecord();
281 : 0 : break;
282 : : case EXC_BIFF8:
283 : 0 : rStrm.StartRecord( EXC_ID5_BOF, 16 );
284 : 0 : rStrm << EXC_BOF_BIFF8 << mnSubStrmType << sal_uInt16( 3612 ) << sal_uInt16( 1996 );
285 : 0 : rStrm << sal_uInt32( 1 ) << sal_uInt32( 6 );
286 : 0 : rStrm.EndRecord();
287 : 0 : break;
288 : : default:
289 : : DBG_ERROR_BIFF();
290 : : }
291 : :
292 : : // substream records
293 : 0 : XclExpRecordList<>::Save( rStrm );
294 : :
295 : : // EOF record
296 : 0 : rStrm.StartRecord( EXC_ID_EOF, 0 );
297 : 0 : rStrm.EndRecord();
298 [ + - ][ + - ]: 24 : }
299 : :
300 : : // ============================================================================
301 : :
302 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|