Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "scitems.hxx"
21 : #include <editeng/eeitem.hxx>
22 :
23 : #include <svx/algitem.hxx>
24 : #include <editeng/boxitem.hxx>
25 : #include <editeng/brushitem.hxx>
26 : #include <editeng/colritem.hxx>
27 : #include <editeng/crossedoutitem.hxx>
28 : #include <editeng/editdata.hxx>
29 : #include <editeng/editeng.hxx>
30 : #include <editeng/editobj.hxx>
31 : #include <editeng/fhgtitem.hxx>
32 : #include <editeng/fontitem.hxx>
33 : #include <editeng/lrspitem.hxx>
34 : #include <svx/pageitem.hxx>
35 : #include <editeng/postitem.hxx>
36 : #include <editeng/sizeitem.hxx>
37 : #include <editeng/udlnitem.hxx>
38 : #include <editeng/ulspitem.hxx>
39 : #include <editeng/wghtitem.hxx>
40 : #include <editeng/justifyitem.hxx>
41 : #include <svl/zforlist.hxx>
42 : #include <svl/PasswordHelper.hxx>
43 : #include <cassert>
44 : #include <math.h>
45 : #include <string.h>
46 :
47 : #include "global.hxx"
48 : #include "sc.hrc"
49 : #include "attrib.hxx"
50 : #include "patattr.hxx"
51 : #include "docpool.hxx"
52 : #include "document.hxx"
53 : #include "collect.hxx"
54 : #include "rangenam.hxx"
55 : #include "dbdata.hxx"
56 : #include "stlsheet.hxx"
57 : #include "stlpool.hxx"
58 : #include "filter.hxx"
59 : #include "scflt.hxx"
60 : #include "formulacell.hxx"
61 : #include "scfobj.hxx"
62 : #include "docoptio.hxx"
63 : #include "viewopti.hxx"
64 : #include "postit.hxx"
65 : #include "globstr.hrc"
66 : #include "ftools.hxx"
67 : #include "tabprotection.hxx"
68 :
69 : #include "fprogressbar.hxx"
70 : #include <boost/scoped_array.hpp>
71 :
72 : using namespace com::sun::star;
73 :
74 : #define DEFCHARSET RTL_TEXTENCODING_MS_1252
75 :
76 : #define SC10TOSTRING(p) OUString((p), strlen(p), DEFCHARSET)
77 :
78 : const SCCOL SC10MAXCOL = 255; // #i85906# don't try to load more columns than there are in the file
79 :
80 : /** Those strings are used with SC10TOSTRING() and strcmp() and such, hence
81 : need to be 0-terminated. */
82 0 : static void lcl_ReadFixedString( SvStream& rStream, void* pData, size_t nLen )
83 : {
84 0 : sal_Char* pBuf = static_cast<sal_Char*>(pData);
85 0 : if (!nLen)
86 0 : pBuf[0] = 0;
87 : else
88 : {
89 0 : rStream.Read( pBuf, nLen);
90 0 : pBuf[nLen-1] = 0;
91 : }
92 0 : }
93 :
94 0 : static void lcl_ReadFileHeader(SvStream& rStream, Sc10FileHeader& rFileHeader)
95 : {
96 0 : lcl_ReadFixedString( rStream, &rFileHeader.CopyRight, sizeof(rFileHeader.CopyRight));
97 0 : rStream.ReadUInt16( rFileHeader.Version );
98 0 : rStream.Read(&rFileHeader.Reserved, sizeof(rFileHeader.Reserved));
99 0 : }
100 :
101 0 : static void lcl_ReadTabProtect(SvStream& rStream, Sc10TableProtect& rProtect)
102 : {
103 0 : lcl_ReadFixedString( rStream, &rProtect.PassWord, sizeof(rProtect.PassWord));
104 0 : rStream.ReadUInt16( rProtect.Flags );
105 0 : rStream.ReadUChar( rProtect.Protect );
106 0 : }
107 :
108 0 : static void lcl_ReadSheetProtect(SvStream& rStream, Sc10SheetProtect& rProtect)
109 : {
110 0 : lcl_ReadFixedString( rStream, &rProtect.PassWord, sizeof(rProtect.PassWord));
111 0 : rStream.ReadUInt16( rProtect.Flags );
112 0 : rStream.ReadUChar( rProtect.Protect );
113 0 : }
114 :
115 0 : static void lcl_ReadRGB(SvStream& rStream, Sc10Color& rColor)
116 : {
117 0 : rStream.ReadUChar( rColor.Dummy );
118 0 : rStream.ReadUChar( rColor.Blue );
119 0 : rStream.ReadUChar( rColor.Green );
120 0 : rStream.ReadUChar( rColor.Red );
121 0 : }
122 :
123 0 : static void lcl_ReadPalette(SvStream& rStream, Sc10Color* pPalette)
124 : {
125 0 : for (sal_uInt16 i = 0; i < 16; i++)
126 0 : lcl_ReadRGB(rStream, pPalette[i]);
127 0 : }
128 :
129 0 : static void lcl_ReadValueFormat(SvStream& rStream, Sc10ValueFormat& rFormat)
130 : {
131 0 : rStream.ReadUChar( rFormat.Format );
132 0 : rStream.ReadUChar( rFormat.Info );
133 0 : }
134 :
135 0 : static void lcl_ReadLogFont(SvStream& rStream, Sc10LogFont& rFont)
136 : {
137 0 : rStream.ReadInt16( rFont.lfHeight );
138 0 : rStream.ReadInt16( rFont.lfWidth );
139 0 : rStream.ReadInt16( rFont.lfEscapement );
140 0 : rStream.ReadInt16( rFont.lfOrientation );
141 0 : rStream.ReadInt16( rFont.lfWeight );
142 0 : rStream.ReadUChar( rFont.lfItalic );
143 0 : rStream.ReadUChar( rFont.lfUnderline );
144 0 : rStream.ReadUChar( rFont.lfStrikeOut );
145 0 : rStream.ReadUChar( rFont.lfCharSet );
146 0 : rStream.ReadUChar( rFont.lfOutPrecision );
147 0 : rStream.ReadUChar( rFont.lfClipPrecision );
148 0 : rStream.ReadUChar( rFont.lfQuality );
149 0 : rStream.ReadUChar( rFont.lfPitchAndFamily );
150 0 : lcl_ReadFixedString( rStream, &rFont.lfFaceName, sizeof(rFont.lfFaceName));
151 0 : }
152 :
153 0 : static void lcl_ReadBlockRect(SvStream& rStream, Sc10BlockRect& rBlock)
154 : {
155 0 : rStream.ReadInt16( rBlock.x1 );
156 0 : rStream.ReadInt16( rBlock.y1 );
157 0 : rStream.ReadInt16( rBlock.x2 );
158 0 : rStream.ReadInt16( rBlock.y2 );
159 0 : }
160 :
161 0 : static void lcl_ReadHeadFootLine(SvStream& rStream, Sc10HeadFootLine& rLine)
162 : {
163 0 : lcl_ReadFixedString( rStream, &rLine.Title, sizeof(rLine.Title));
164 0 : lcl_ReadLogFont(rStream, rLine.LogFont);
165 0 : rStream.ReadUChar( rLine.HorJustify );
166 0 : rStream.ReadUChar( rLine.VerJustify );
167 0 : rStream.ReadUInt16( rLine.Raster );
168 0 : rStream.ReadUInt16( rLine.Frame );
169 0 : lcl_ReadRGB(rStream, rLine.TextColor);
170 0 : lcl_ReadRGB(rStream, rLine.BackColor);
171 0 : lcl_ReadRGB(rStream, rLine.RasterColor);
172 0 : rStream.ReadUInt16( rLine.FrameColor );
173 0 : rStream.ReadUInt16( rLine.Reserved );
174 0 : }
175 :
176 0 : static void lcl_ReadPageFormat(SvStream& rStream, Sc10PageFormat& rFormat)
177 : {
178 0 : lcl_ReadHeadFootLine(rStream, rFormat.HeadLine);
179 0 : lcl_ReadHeadFootLine(rStream, rFormat.FootLine);
180 0 : rStream.ReadInt16( rFormat.Orientation );
181 0 : rStream.ReadInt16( rFormat.Width );
182 0 : rStream.ReadInt16( rFormat.Height );
183 0 : rStream.ReadInt16( rFormat.NonPrintableX );
184 0 : rStream.ReadInt16( rFormat.NonPrintableY );
185 0 : rStream.ReadInt16( rFormat.Left );
186 0 : rStream.ReadInt16( rFormat.Top );
187 0 : rStream.ReadInt16( rFormat.Right );
188 0 : rStream.ReadInt16( rFormat.Bottom );
189 0 : rStream.ReadInt16( rFormat.Head );
190 0 : rStream.ReadInt16( rFormat.Foot );
191 0 : rStream.ReadUChar( rFormat.HorCenter );
192 0 : rStream.ReadUChar( rFormat.VerCenter );
193 0 : rStream.ReadUChar( rFormat.PrintGrid );
194 0 : rStream.ReadUChar( rFormat.PrintColRow );
195 0 : rStream.ReadUChar( rFormat.PrintNote );
196 0 : rStream.ReadUChar( rFormat.TopBottomDir );
197 0 : lcl_ReadFixedString( rStream, &rFormat.PrintAreaName, sizeof(rFormat.PrintAreaName));
198 0 : lcl_ReadBlockRect(rStream, rFormat.PrintArea);
199 0 : rStream.Read(&rFormat.PrnZoom, sizeof(rFormat.PrnZoom));
200 0 : rStream.ReadInt16( rFormat.FirstPageNo );
201 0 : rStream.ReadInt16( rFormat.RowRepeatStart );
202 0 : rStream.ReadInt16( rFormat.RowRepeatEnd );
203 0 : rStream.ReadInt16( rFormat.ColRepeatStart );
204 0 : rStream.ReadInt16( rFormat.ColRepeatEnd );
205 0 : rStream.Read(&rFormat.Reserved, sizeof(rFormat.Reserved));
206 0 : }
207 :
208 0 : static void lcl_ReadGraphHeader(SvStream& rStream, Sc10GraphHeader& rHeader)
209 : {
210 0 : rStream.ReadUChar( rHeader.Typ );
211 0 : rStream.ReadInt16( rHeader.CarretX );
212 0 : rStream.ReadInt16( rHeader.CarretY );
213 0 : rStream.ReadInt16( rHeader.CarretZ );
214 0 : rStream.ReadInt32( rHeader.x );
215 0 : rStream.ReadInt32( rHeader.y );
216 0 : rStream.ReadInt32( rHeader.w );
217 0 : rStream.ReadInt32( rHeader.h );
218 0 : rStream.ReadUChar( rHeader.IsRelPos );
219 0 : rStream.ReadUChar( rHeader.DoPrint );
220 0 : rStream.ReadUInt16( rHeader.FrameType );
221 0 : rStream.ReadUChar( rHeader.IsTransparent );
222 0 : lcl_ReadRGB(rStream, rHeader.FrameColor);
223 0 : lcl_ReadRGB(rStream, rHeader.BackColor);
224 0 : rStream.Read(&rHeader.Reserved, sizeof(rHeader.Reserved));
225 0 : }
226 :
227 0 : static void lcl_ReadImageHeaer(SvStream& rStream, Sc10ImageHeader& rHeader)
228 : {
229 0 : lcl_ReadFixedString( rStream, &rHeader.FileName, sizeof(rHeader.FileName));
230 0 : rStream.ReadInt16( rHeader.Typ );
231 0 : rStream.ReadUChar( rHeader.Linked );
232 0 : rStream.ReadInt16( rHeader.x1 );
233 0 : rStream.ReadInt16( rHeader.y1 );
234 0 : rStream.ReadInt16( rHeader.x2 );
235 0 : rStream.ReadInt16( rHeader.y2 );
236 0 : rStream.ReadUInt32( rHeader.Size );
237 0 : }
238 :
239 0 : static void lcl_ReadChartHeader(SvStream& rStream, Sc10ChartHeader& rHeader)
240 : {
241 0 : rStream.ReadInt16( rHeader.MM );
242 0 : rStream.ReadInt16( rHeader.xExt );
243 0 : rStream.ReadInt16( rHeader.yExt );
244 0 : rStream.ReadUInt32( rHeader.Size );
245 0 : }
246 :
247 0 : static void lcl_ReadChartSheetData(SvStream& rStream, Sc10ChartSheetData& rSheetData)
248 : {
249 0 : rStream.ReadUChar( rSheetData.HasTitle );
250 0 : rStream.ReadInt16( rSheetData.TitleX );
251 0 : rStream.ReadInt16( rSheetData.TitleY );
252 0 : rStream.ReadUChar( rSheetData.HasSubTitle );
253 0 : rStream.ReadInt16( rSheetData.SubTitleX );
254 0 : rStream.ReadInt16( rSheetData.SubTitleY );
255 0 : rStream.ReadUChar( rSheetData.HasLeftTitle );
256 0 : rStream.ReadInt16( rSheetData.LeftTitleX );
257 0 : rStream.ReadInt16( rSheetData.LeftTitleY );
258 0 : rStream.ReadUChar( rSheetData.HasLegend );
259 0 : rStream.ReadInt16( rSheetData.LegendX1 );
260 0 : rStream.ReadInt16( rSheetData.LegendY1 );
261 0 : rStream.ReadInt16( rSheetData.LegendX2 );
262 0 : rStream.ReadInt16( rSheetData.LegendY2 );
263 0 : rStream.ReadUChar( rSheetData.HasLabel );
264 0 : rStream.ReadInt16( rSheetData.LabelX1 );
265 0 : rStream.ReadInt16( rSheetData.LabelY1 );
266 0 : rStream.ReadInt16( rSheetData.LabelX2 );
267 0 : rStream.ReadInt16( rSheetData.LabelY2 );
268 0 : rStream.ReadInt16( rSheetData.DataX1 );
269 0 : rStream.ReadInt16( rSheetData.DataY1 );
270 0 : rStream.ReadInt16( rSheetData.DataX2 );
271 0 : rStream.ReadInt16( rSheetData.DataY2 );
272 0 : rStream.Read(&rSheetData.Reserved, sizeof(rSheetData.Reserved));
273 0 : }
274 :
275 0 : static void lcl_ReadChartTypeData(SvStream& rStream, Sc10ChartTypeData& rTypeData)
276 : {
277 0 : rStream.ReadInt16( rTypeData.NumSets );
278 0 : rStream.ReadInt16( rTypeData.NumPoints );
279 0 : rStream.ReadInt16( rTypeData.DrawMode );
280 0 : rStream.ReadInt16( rTypeData.GraphType );
281 0 : rStream.ReadInt16( rTypeData.GraphStyle );
282 0 : lcl_ReadFixedString( rStream, &rTypeData.GraphTitle, sizeof(rTypeData.GraphTitle));
283 0 : lcl_ReadFixedString( rStream, &rTypeData.BottomTitle, sizeof(rTypeData.BottomTitle));
284 : sal_uInt16 i;
285 0 : for (i = 0; i < 256; i++)
286 0 : rStream.ReadInt16( rTypeData.SymbolData[i] );
287 0 : for (i = 0; i < 256; i++)
288 0 : rStream.ReadInt16( rTypeData.ColorData[i] );
289 0 : for (i = 0; i < 256; i++)
290 0 : rStream.ReadInt16( rTypeData.ThickLines[i] );
291 0 : for (i = 0; i < 256; i++)
292 0 : rStream.ReadInt16( rTypeData.PatternData[i] );
293 0 : for (i = 0; i < 256; i++)
294 0 : rStream.ReadInt16( rTypeData.LinePatternData[i] );
295 0 : for (i = 0; i < 11; i++)
296 0 : rStream.ReadInt16( rTypeData.NumGraphStyles[i] );
297 0 : rStream.ReadInt16( rTypeData.ShowLegend );
298 0 : for (i = 0; i < 256; i++)
299 0 : lcl_ReadFixedString( rStream, &rTypeData.LegendText[i], sizeof(Sc10ChartText));
300 0 : rStream.ReadInt16( rTypeData.ExplodePie );
301 0 : rStream.ReadInt16( rTypeData.FontUse );
302 0 : for (i = 0; i < 5; i++)
303 0 : rStream.ReadInt16( rTypeData.FontFamily[i] );
304 0 : for (i = 0; i < 5; i++)
305 0 : rStream.ReadInt16( rTypeData.FontStyle[i] );
306 0 : for (i = 0; i < 5; i++)
307 0 : rStream.ReadInt16( rTypeData.FontSize[i] );
308 0 : rStream.ReadInt16( rTypeData.GridStyle );
309 0 : rStream.ReadInt16( rTypeData.Labels );
310 0 : rStream.ReadInt16( rTypeData.LabelEvery );
311 0 : for (i = 0; i < 50; i++)
312 0 : lcl_ReadFixedString( rStream, &rTypeData.LabelText[i], sizeof(Sc10ChartText));
313 0 : lcl_ReadFixedString( rStream, &rTypeData.LeftTitle, sizeof(rTypeData.LeftTitle));
314 0 : rStream.Read(&rTypeData.Reserved, sizeof(rTypeData.Reserved));
315 0 : }
316 :
317 0 : static double lcl_PascalToDouble(sal_Char* tp6)
318 : {
319 0 : sal_uInt8* pnUnsigned = reinterpret_cast< sal_uInt8* >( tp6 );
320 : // biased exponent
321 0 : sal_uInt8 be = pnUnsigned[ 0 ];
322 : // lower 16 bits of mantissa
323 0 : sal_uInt16 v1 = static_cast< sal_uInt16 >( pnUnsigned[ 2 ] * 256 + pnUnsigned[ 1 ] );
324 : // next 16 bits of mantissa
325 0 : sal_uInt16 v2 = static_cast< sal_uInt16 >( pnUnsigned[ 4 ] * 256 + pnUnsigned[ 3 ] );
326 : // upper 7 bits of mantissa
327 0 : sal_uInt8 v3 = static_cast< sal_uInt8 >( pnUnsigned[ 5 ] & 0x7F );
328 : // sign bit
329 0 : bool s = (pnUnsigned[ 5 ] & 0x80) != 0;
330 :
331 0 : if (be == 0)
332 0 : return 0.0;
333 0 : return (((((128 + v3) * 65536.0) + v2) * 65536.0 + v1) *
334 0 : ldexp ((s ? -1.0 : 1.0), be - (129+39)));
335 : }
336 :
337 0 : static void lcl_ChangeColor( sal_uInt16 nIndex, Color& rColor )
338 : {
339 : ColorData aCol;
340 :
341 0 : switch( nIndex )
342 : {
343 0 : case 1: aCol = COL_RED; break;
344 0 : case 2: aCol = COL_GREEN; break;
345 0 : case 3: aCol = COL_BROWN; break;
346 0 : case 4: aCol = COL_BLUE; break;
347 0 : case 5: aCol = COL_MAGENTA; break;
348 0 : case 6: aCol = COL_CYAN; break;
349 0 : case 7: aCol = COL_GRAY; break;
350 0 : case 8: aCol = COL_LIGHTGRAY; break;
351 0 : case 9: aCol = COL_LIGHTRED; break;
352 0 : case 10: aCol = COL_LIGHTGREEN; break;
353 0 : case 11: aCol = COL_YELLOW; break;
354 0 : case 12: aCol = COL_LIGHTBLUE; break;
355 0 : case 13: aCol = COL_LIGHTMAGENTA; break;
356 0 : case 14: aCol = COL_LIGHTCYAN; break;
357 0 : case 15: aCol = COL_WHITE; break;
358 0 : default: aCol = COL_BLACK;
359 : }
360 :
361 0 : rColor.SetColor( aCol );
362 0 : }
363 :
364 0 : static OUString lcl_MakeOldPageStyleFormatName( sal_uInt16 i )
365 : {
366 0 : OUString aName = ScGlobal::GetRscString( STR_PAGESTYLE ) + " " + OUString::number( i + 1 );
367 0 : return aName;
368 : }
369 :
370 0 : template < typename T > sal_uLong insert_new( ScCollection* pCollection, SvStream& rStream )
371 : {
372 0 : T* pData = new (::std::nothrow) T( rStream);
373 0 : sal_uLong nError = rStream.GetError();
374 0 : if (pData)
375 : {
376 0 : if (nError)
377 0 : delete pData;
378 : else
379 0 : pCollection->Insert( pData);
380 : }
381 : else
382 0 : nError = errOutOfMemory;
383 0 : return nError;
384 : }
385 :
386 : // Font
387 :
388 0 : Sc10FontData::Sc10FontData(SvStream& rStream)
389 : : Height(0)
390 : , CharSet(0)
391 0 : , PitchAndFamily(0)
392 : {
393 0 : rStream.ReadInt16( Height );
394 0 : rStream.ReadUChar( CharSet );
395 0 : rStream.ReadUChar( PitchAndFamily );
396 0 : sal_uInt16 nLen(0);
397 0 : rStream.ReadUInt16( nLen );
398 0 : if (nLen < sizeof(FaceName))
399 0 : rStream.Read(FaceName, nLen);
400 : else
401 0 : rStream.SetError(ERRCODE_IO_WRONGFORMAT);
402 0 : }
403 :
404 0 : Sc10FontCollection::Sc10FontCollection(SvStream& rStream)
405 : : ScCollection(4, 4)
406 0 : , nError(0)
407 : {
408 0 : sal_uInt16 ID(0);
409 0 : rStream.ReadUInt16( ID );
410 0 : if (ID == FontID)
411 : {
412 0 : sal_uInt16 nAnz(0);
413 0 : rStream.ReadUInt16( nAnz );
414 0 : for (sal_uInt16 i=0; (i < nAnz) && (nError == 0); i++)
415 : {
416 0 : nError = insert_new<Sc10FontData>( this, rStream);
417 : }
418 : }
419 : else
420 : {
421 : OSL_FAIL( "FontID" );
422 0 : nError = errUnknownID;
423 : }
424 0 : }
425 :
426 : // named regions
427 :
428 0 : Sc10NameData::Sc10NameData(SvStream& rStream)
429 : {
430 : sal_uInt8 nLen;
431 0 : rStream.ReadUChar( nLen );
432 0 : rStream.Read(Name, sizeof(Name) - 1);
433 0 : if (nLen >= sizeof(Name))
434 0 : nLen = sizeof(Name) - 1;
435 0 : Name[nLen] = 0;
436 :
437 0 : rStream.ReadUChar( nLen );
438 0 : rStream.Read(Reference, sizeof(Reference) - 1);
439 0 : if (nLen >= sizeof(Reference))
440 0 : nLen = sizeof(Reference) - 1;
441 0 : Reference[nLen] = 0;
442 0 : rStream.Read(Reserved, sizeof(Reserved));
443 0 : }
444 :
445 0 : Sc10NameCollection::Sc10NameCollection(SvStream& rStream) :
446 : ScCollection (4, 4),
447 0 : nError (0)
448 : {
449 : sal_uInt16 ID;
450 0 : rStream.ReadUInt16( ID );
451 0 : if (ID == NameID)
452 : {
453 : sal_uInt16 nAnz;
454 0 : rStream.ReadUInt16( nAnz );
455 0 : for (sal_uInt16 i=0; (i < nAnz) && (nError == 0); i++)
456 : {
457 0 : nError = insert_new<Sc10NameData>( this, rStream);
458 : }
459 : }
460 : else
461 : {
462 : OSL_FAIL( "NameID" );
463 0 : nError = errUnknownID;
464 : }
465 0 : }
466 :
467 : // templates
468 0 : Sc10PatternData::Sc10PatternData(SvStream& rStream)
469 : : Attr(0)
470 : , Justify(0)
471 : , Frame(0)
472 : , Raster(0)
473 : , nColor(0)
474 : , FrameColor(0)
475 : , Flags(0)
476 0 : , FormatFlags(0)
477 : {
478 0 : memset(Name, 0, sizeof(Name));
479 0 : memset(Reserved, 0, sizeof(Reserved));
480 0 : lcl_ReadFixedString( rStream, Name, sizeof(Name));
481 0 : lcl_ReadValueFormat(rStream, ValueFormat);
482 0 : lcl_ReadLogFont(rStream, LogFont);
483 :
484 0 : rStream.ReadUInt16( Attr );
485 0 : rStream.ReadUInt16( Justify );
486 0 : rStream.ReadUInt16( Frame );
487 0 : rStream.ReadUInt16( Raster );
488 0 : rStream.ReadUInt16( nColor );
489 0 : rStream.ReadUInt16( FrameColor );
490 0 : rStream.ReadUInt16( Flags );
491 0 : rStream.ReadUInt16( FormatFlags );
492 0 : rStream.Read(Reserved, sizeof(Reserved));
493 0 : }
494 :
495 0 : Sc10PatternCollection::Sc10PatternCollection(SvStream& rStream) :
496 : ScCollection (4, 4),
497 0 : nError (0)
498 : {
499 : sal_uInt16 ID;
500 0 : rStream.ReadUInt16( ID );
501 0 : if (ID == PatternID)
502 : {
503 : sal_uInt16 nAnz;
504 0 : rStream.ReadUInt16( nAnz );
505 0 : for (sal_uInt16 i=0; (i < nAnz) && (nError == 0); i++)
506 : {
507 0 : nError = insert_new<Sc10PatternData>( this, rStream);
508 : }
509 : }
510 : else
511 : {
512 : OSL_FAIL( "PatternID" );
513 0 : nError = errUnknownID;
514 : }
515 0 : }
516 :
517 : // database
518 :
519 0 : Sc10DataBaseData::Sc10DataBaseData(SvStream& rStream)
520 : {
521 0 : lcl_ReadFixedString( rStream, &DataBaseRec.Name, sizeof(DataBaseRec.Name));
522 0 : rStream.ReadInt16( DataBaseRec.Tab );
523 0 : lcl_ReadBlockRect(rStream, DataBaseRec.Block);
524 0 : rStream.ReadUChar( DataBaseRec.RowHeader );
525 0 : rStream.ReadInt16( DataBaseRec.SortField0 );
526 0 : rStream.ReadUChar( DataBaseRec.SortUpOrder0 );
527 0 : rStream.ReadInt16( DataBaseRec.SortField1 );
528 0 : rStream.ReadUChar( DataBaseRec.SortUpOrder1 );
529 0 : rStream.ReadInt16( DataBaseRec.SortField2 );
530 0 : rStream.ReadUChar( DataBaseRec.SortUpOrder2 );
531 0 : rStream.ReadUChar( DataBaseRec.IncludeFormat );
532 :
533 0 : rStream.ReadInt16( DataBaseRec.QueryField0 );
534 0 : rStream.ReadInt16( DataBaseRec.QueryOp0 );
535 0 : rStream.ReadUChar( DataBaseRec.QueryByString0 );
536 0 : lcl_ReadFixedString( rStream, &DataBaseRec.QueryString0, sizeof(DataBaseRec.QueryString0));
537 0 : DataBaseRec.QueryValue0 = ScfTools::ReadLongDouble(rStream);
538 :
539 0 : rStream.ReadInt16( DataBaseRec.QueryConnect1 );
540 0 : rStream.ReadInt16( DataBaseRec.QueryField1 );
541 0 : rStream.ReadInt16( DataBaseRec.QueryOp1 );
542 0 : rStream.ReadUChar( DataBaseRec.QueryByString1 );
543 0 : lcl_ReadFixedString( rStream, &DataBaseRec.QueryString1, sizeof(DataBaseRec.QueryString1));
544 0 : DataBaseRec.QueryValue1 = ScfTools::ReadLongDouble(rStream);
545 :
546 0 : rStream.ReadInt16( DataBaseRec.QueryConnect2 );
547 0 : rStream.ReadInt16( DataBaseRec.QueryField2 );
548 0 : rStream.ReadInt16( DataBaseRec.QueryOp2 );
549 0 : rStream.ReadUChar( DataBaseRec.QueryByString2 );
550 0 : lcl_ReadFixedString( rStream, &DataBaseRec.QueryString2, sizeof(DataBaseRec.QueryString2));
551 0 : DataBaseRec.QueryValue2 = ScfTools::ReadLongDouble(rStream);
552 0 : }
553 :
554 0 : Sc10DataBaseCollection::Sc10DataBaseCollection(SvStream& rStream) :
555 : ScCollection (4, 4),
556 0 : nError (0)
557 : {
558 : sal_uInt16 ID;
559 0 : rStream.ReadUInt16( ID );
560 0 : if (ID == DataBaseID)
561 : {
562 0 : lcl_ReadFixedString( rStream, ActName, sizeof(ActName));
563 : sal_uInt16 nAnz;
564 0 : rStream.ReadUInt16( nAnz );
565 0 : for (sal_uInt16 i=0; (i < nAnz) && (nError == 0); i++)
566 : {
567 0 : nError = insert_new<Sc10DataBaseData>( this, rStream);
568 : }
569 : }
570 : else
571 : {
572 : OSL_FAIL( "DataBaseID" );
573 0 : nError = errUnknownID;
574 : }
575 0 : }
576 :
577 0 : bool Sc10LogFont::operator==( const Sc10LogFont& rData ) const
578 : {
579 0 : return !strcmp( lfFaceName, rData.lfFaceName )
580 0 : && lfHeight == rData.lfHeight
581 0 : && lfWidth == rData.lfWidth
582 0 : && lfEscapement == rData.lfEscapement
583 0 : && lfOrientation == rData.lfOrientation
584 0 : && lfWeight == rData.lfWeight
585 0 : && lfItalic == rData.lfItalic
586 0 : && lfUnderline == rData.lfUnderline
587 0 : && lfStrikeOut == rData.lfStrikeOut
588 0 : && lfCharSet == rData.lfCharSet
589 0 : && lfOutPrecision == rData.lfOutPrecision
590 0 : && lfClipPrecision == rData.lfClipPrecision
591 0 : && lfQuality == rData.lfQuality
592 0 : && lfPitchAndFamily == rData.lfPitchAndFamily;
593 : }
594 :
595 0 : bool Sc10Color::operator==( const Sc10Color& rColor ) const
596 : {
597 0 : return ((Red == rColor.Red) && (Green == rColor.Green) && (Blue == rColor.Blue));
598 : }
599 :
600 0 : bool Sc10HeadFootLine::operator==( const Sc10HeadFootLine& rData ) const
601 : {
602 0 : return !strcmp(Title, rData.Title)
603 0 : && LogFont == rData.LogFont
604 0 : && HorJustify == rData.HorJustify
605 0 : && VerJustify == rData.VerJustify
606 0 : && Raster == rData.Raster
607 0 : && Frame == rData.Frame
608 0 : && TextColor == rData.TextColor
609 0 : && BackColor == rData.BackColor
610 0 : && RasterColor == rData.RasterColor
611 0 : && FrameColor == rData.FrameColor
612 0 : && Reserved == rData.Reserved;
613 : }
614 :
615 0 : bool Sc10PageFormat::operator==( const Sc10PageFormat& rData ) const
616 : {
617 0 : return !strcmp(PrintAreaName, rData.PrintAreaName)
618 0 : && HeadLine == rData.HeadLine
619 0 : && FootLine == rData.FootLine
620 0 : && Orientation == rData.Orientation
621 0 : && Width == rData.Width
622 0 : && Height == rData.Height
623 0 : && NonPrintableX == rData.NonPrintableX
624 0 : && NonPrintableY == rData.NonPrintableY
625 0 : && Left == rData.Left
626 0 : && Top == rData.Top
627 0 : && Right == rData.Right
628 0 : && Bottom == rData.Bottom
629 0 : && Head == rData.Head
630 0 : && Foot == rData.Foot
631 0 : && HorCenter == rData.HorCenter
632 0 : && VerCenter == rData.VerCenter
633 0 : && PrintGrid == rData.PrintGrid
634 0 : && PrintColRow == rData.PrintColRow
635 0 : && PrintNote == rData.PrintNote
636 0 : && TopBottomDir == rData.TopBottomDir
637 0 : && FirstPageNo == rData.FirstPageNo
638 0 : && RowRepeatStart == rData.RowRepeatStart
639 0 : && RowRepeatEnd == rData.RowRepeatEnd
640 0 : && ColRepeatStart == rData.ColRepeatStart
641 0 : && ColRepeatEnd == rData.ColRepeatEnd
642 0 : && !memcmp( PrnZoom, rData.PrnZoom, sizeof(PrnZoom) )
643 0 : && !memcmp( &PrintArea, &rData.PrintArea, sizeof(PrintArea) );
644 : }
645 :
646 0 : sal_uInt16 Sc10PageCollection::InsertFormat( const Sc10PageFormat& rData )
647 : {
648 0 : for (sal_uInt16 i=0; i<nCount; i++)
649 0 : if (At(i)->aPageFormat == rData)
650 0 : return i;
651 :
652 0 : Insert( new Sc10PageData(rData) );
653 :
654 0 : return nCount-1;
655 : }
656 :
657 0 : static inline sal_uInt8 GetMixedCol( const sal_uInt8 nB, const sal_uInt8 nF, const sal_uInt16 nFak )
658 : {
659 0 : sal_Int32 nT = nB - nF;
660 0 : nT *= ( sal_Int32 ) nFak;
661 0 : nT /= 0xFFFF;
662 0 : nT += nF;
663 0 : return ( sal_uInt8 ) nT;
664 : }
665 0 : static inline Color GetMixedColor( const Color& rFore, const Color& rBack, sal_uInt16 nFact )
666 : {
667 0 : return Color( GetMixedCol( rBack.GetRed(), rFore.GetRed(), nFact ),
668 0 : GetMixedCol( rBack.GetGreen(), rFore.GetGreen(), nFact ),
669 0 : GetMixedCol( rBack.GetBlue(), rFore.GetBlue(), nFact ) );
670 : }
671 :
672 0 : void Sc10PageCollection::PutToDoc( ScDocument* pDoc )
673 : {
674 0 : ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
675 0 : EditEngine aEditEngine( pDoc->GetEnginePool() );
676 0 : EditTextObject* pEmptyObject = aEditEngine.CreateTextObject();
677 :
678 0 : for (sal_uInt16 i=0; i<nCount; i++)
679 : {
680 0 : Sc10PageFormat* pPage = &At(i)->aPageFormat;
681 :
682 0 : pPage->Width = (short) ( pPage->Width * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
683 0 : pPage->Height = (short) ( pPage->Height * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
684 0 : pPage->Top = (short) ( pPage->Top * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
685 0 : pPage->Bottom = (short) ( pPage->Bottom * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
686 0 : pPage->Left = (short) ( pPage->Left * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
687 0 : pPage->Right = (short) ( pPage->Right * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
688 0 : pPage->Head = (short) ( pPage->Head * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
689 0 : pPage->Foot = (short) ( pPage->Foot * ( PS_POINTS_PER_INCH / POINTS_PER_INCH ) + 0.5 );
690 :
691 0 : OUString aName = lcl_MakeOldPageStyleFormatName( i );
692 :
693 : ScStyleSheet* pSheet = static_cast<ScStyleSheet*>( &pStylePool->Make( aName,
694 : SFX_STYLE_FAMILY_PAGE,
695 0 : SFXSTYLEBIT_USERDEF | SCSTYLEBIT_STANDARD ) );
696 : // #i68483# set page style name at sheet...
697 0 : pDoc->SetPageStyle( static_cast< SCTAB >( i ), aName );
698 :
699 0 : SfxItemSet* pSet = &pSheet->GetItemSet();
700 :
701 0 : for (sal_uInt16 nHeadFoot=0; nHeadFoot<2; nHeadFoot++)
702 : {
703 0 : Sc10HeadFootLine* pHeadFootLine = nHeadFoot ? &pPage->FootLine : &pPage->HeadLine;
704 :
705 0 : SfxItemSet aEditAttribs(aEditEngine.GetEmptyItemSet());
706 0 : FontFamily eFam = FAMILY_DONTKNOW;
707 0 : switch (pPage->HeadLine.LogFont.lfPitchAndFamily & 0xF0)
708 : {
709 0 : case ffDontCare: eFam = FAMILY_DONTKNOW; break;
710 0 : case ffRoman: eFam = FAMILY_ROMAN; break;
711 0 : case ffSwiss: eFam = FAMILY_SWISS; break;
712 0 : case ffModern: eFam = FAMILY_MODERN; break;
713 0 : case ffScript: eFam = FAMILY_SCRIPT; break;
714 0 : case ffDecorative: eFam = FAMILY_DECORATIVE; break;
715 0 : default: eFam = FAMILY_DONTKNOW; break;
716 : }
717 : aEditAttribs.Put( SvxFontItem(
718 : eFam,
719 0 : SC10TOSTRING( pHeadFootLine->LogFont.lfFaceName ), EMPTY_OUSTRING,
720 : PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, EE_CHAR_FONTINFO ),
721 0 : EE_CHAR_FONTINFO );
722 0 : aEditAttribs.Put( SvxFontHeightItem( std::abs( pHeadFootLine->LogFont.lfHeight ), 100, EE_CHAR_FONTHEIGHT ),
723 0 : EE_CHAR_FONTHEIGHT);
724 :
725 0 : Sc10Color nColor = pHeadFootLine->TextColor;
726 0 : Color TextColor( nColor.Red, nColor.Green, nColor.Blue );
727 0 : aEditAttribs.Put(SvxColorItem(TextColor, EE_CHAR_COLOR), EE_CHAR_COLOR);
728 : // FontAttr
729 0 : if (pHeadFootLine->LogFont.lfWeight != fwNormal)
730 0 : aEditAttribs.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT), EE_CHAR_WEIGHT);
731 0 : if (pHeadFootLine->LogFont.lfItalic != 0)
732 0 : aEditAttribs.Put(SvxPostureItem(ITALIC_NORMAL, EE_CHAR_ITALIC), EE_CHAR_ITALIC);
733 0 : if (pHeadFootLine->LogFont.lfUnderline != 0)
734 0 : aEditAttribs.Put(SvxUnderlineItem(UNDERLINE_SINGLE, EE_CHAR_UNDERLINE), EE_CHAR_UNDERLINE);
735 0 : if (pHeadFootLine->LogFont.lfStrikeOut != 0)
736 0 : aEditAttribs.Put(SvxCrossedOutItem(STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT), EE_CHAR_STRIKEOUT);
737 0 : OUString aText( pHeadFootLine->Title, strlen(pHeadFootLine->Title), DEFCHARSET );
738 0 : aEditEngine.SetText( aText );
739 0 : aEditEngine.QuickSetAttribs( aEditAttribs, ESelection( 0, 0, 0, aText.getLength() ) );
740 :
741 0 : EditTextObject* pObject = aEditEngine.CreateTextObject();
742 0 : ScPageHFItem aHeaderItem(nHeadFoot ? ATTR_PAGE_FOOTERRIGHT : ATTR_PAGE_HEADERRIGHT);
743 0 : switch (pHeadFootLine->HorJustify)
744 : {
745 : case hjCenter:
746 0 : aHeaderItem.SetLeftArea(*pEmptyObject);
747 0 : aHeaderItem.SetCenterArea(*pObject);
748 0 : aHeaderItem.SetRightArea(*pEmptyObject);
749 0 : break;
750 : case hjRight:
751 0 : aHeaderItem.SetLeftArea(*pEmptyObject);
752 0 : aHeaderItem.SetCenterArea(*pEmptyObject);
753 0 : aHeaderItem.SetRightArea(*pObject);
754 0 : break;
755 : default:
756 0 : aHeaderItem.SetLeftArea(*pObject);
757 0 : aHeaderItem.SetCenterArea(*pEmptyObject);
758 0 : aHeaderItem.SetRightArea(*pEmptyObject);
759 0 : break;
760 : }
761 0 : delete pObject;
762 0 : pSet->Put( aHeaderItem );
763 :
764 0 : SfxItemSet aSetItemItemSet( *pDoc->GetPool(),
765 : ATTR_BACKGROUND, ATTR_BACKGROUND,
766 : ATTR_BORDER, ATTR_SHADOW,
767 : ATTR_PAGE_SIZE, ATTR_PAGE_SIZE,
768 : ATTR_LRSPACE, ATTR_ULSPACE,
769 : ATTR_PAGE_ON, ATTR_PAGE_SHARED,
770 0 : 0 );
771 0 : nColor = pHeadFootLine->BackColor;
772 0 : Color aBColor( nColor.Red, nColor.Green, nColor.Blue );
773 0 : nColor = pHeadFootLine->RasterColor;
774 0 : Color aRColor( nColor.Red, nColor.Green, nColor.Blue );
775 :
776 : sal_uInt16 nFact;
777 0 : bool bSwapCol = false;
778 0 : switch (pHeadFootLine->Raster)
779 : {
780 0 : case raNone: nFact = 0xffff; bSwapCol = true; break;
781 0 : case raGray12: nFact = (0xffff / 100) * 12; break;
782 0 : case raGray25: nFact = (0xffff / 100) * 25; break;
783 0 : case raGray50: nFact = (0xffff / 100) * 50; break;
784 0 : case raGray75: nFact = (0xffff / 100) * 75; break;
785 0 : default: nFact = 0xffff;
786 : }
787 0 : if( bSwapCol )
788 0 : aSetItemItemSet.Put( SvxBrushItem( GetMixedColor( aBColor, aRColor, nFact ), ATTR_BACKGROUND ) );
789 : else
790 0 : aSetItemItemSet.Put( SvxBrushItem( GetMixedColor( aRColor, aBColor, nFact ), ATTR_BACKGROUND ) );
791 :
792 0 : if (pHeadFootLine->Frame != 0)
793 : {
794 0 : sal_uInt16 nLeft = 0;
795 0 : sal_uInt16 nTop = 0;
796 0 : sal_uInt16 nRight = 0;
797 0 : sal_uInt16 nBottom = 0;
798 0 : sal_uInt16 fLeft = (pHeadFootLine->Frame & 0x000F);
799 0 : sal_uInt16 fTop = (pHeadFootLine->Frame & 0x00F0) / 0x0010;
800 0 : sal_uInt16 fRight = (pHeadFootLine->Frame & 0x0F00) / 0x0100;
801 0 : sal_uInt16 fBottom = (pHeadFootLine->Frame & 0xF000) / 0x1000;
802 0 : if (fLeft > 1)
803 0 : nLeft = 50;
804 0 : else if (fLeft > 0)
805 0 : nLeft = 20;
806 0 : if (fTop > 1)
807 0 : nTop = 50;
808 0 : else if (fTop > 0)
809 0 : nTop = 20;
810 0 : if (fRight > 1)
811 0 : nRight = 50;
812 0 : else if (fRight > 0)
813 0 : nRight = 20;
814 0 : if (fBottom > 1)
815 0 : nBottom = 50;
816 0 : else if (fBottom > 0)
817 0 : nBottom = 20;
818 0 : Color ColorLeft(COL_BLACK);
819 0 : Color ColorTop(COL_BLACK);
820 0 : Color ColorRight(COL_BLACK);
821 0 : Color ColorBottom(COL_BLACK);
822 0 : sal_uInt16 cLeft = (pHeadFootLine->FrameColor & 0x000F);
823 0 : sal_uInt16 cTop = (pHeadFootLine->FrameColor & 0x00F0) >> 4;
824 0 : sal_uInt16 cRight = (pHeadFootLine->FrameColor & 0x0F00) >> 8;
825 0 : sal_uInt16 cBottom = (pHeadFootLine->FrameColor & 0xF000) >> 12;
826 0 : lcl_ChangeColor(cLeft, ColorLeft);
827 0 : lcl_ChangeColor(cTop, ColorTop);
828 0 : lcl_ChangeColor(cRight, ColorRight);
829 0 : lcl_ChangeColor(cBottom, ColorBottom);
830 0 : ::editeng::SvxBorderLine aLine;
831 0 : SvxBoxItem aBox( ATTR_BORDER );
832 0 : aLine.SetWidth(nLeft);
833 0 : aLine.SetColor(ColorLeft);
834 0 : aBox.SetLine(&aLine, SvxBoxItemLine::LEFT);
835 0 : aLine.SetWidth(nTop);
836 0 : aLine.SetColor(ColorTop);
837 0 : aBox.SetLine(&aLine, SvxBoxItemLine::TOP);
838 0 : aLine.SetWidth(nRight);
839 0 : aLine.SetColor(ColorRight);
840 0 : aBox.SetLine(&aLine, SvxBoxItemLine::RIGHT);
841 0 : aLine.SetWidth(nBottom);
842 0 : aLine.SetColor(ColorBottom);
843 0 : aBox.SetLine(&aLine, SvxBoxItemLine::BOTTOM);
844 :
845 0 : aSetItemItemSet.Put(aBox);
846 : }
847 :
848 0 : pSet->Put( SvxULSpaceItem( 0, 0, ATTR_ULSPACE ) );
849 :
850 0 : if (nHeadFoot==0)
851 0 : aSetItemItemSet.Put( SvxSizeItem( ATTR_PAGE_SIZE, Size( 0, pPage->Top - pPage->Head ) ) );
852 : else
853 0 : aSetItemItemSet.Put( SvxSizeItem( ATTR_PAGE_SIZE, Size( 0, pPage->Bottom - pPage->Foot ) ) );
854 :
855 0 : aSetItemItemSet.Put(SfxBoolItem( ATTR_PAGE_ON, true ));
856 0 : aSetItemItemSet.Put(SfxBoolItem( ATTR_PAGE_DYNAMIC, false ));
857 0 : aSetItemItemSet.Put(SfxBoolItem( ATTR_PAGE_SHARED, true ));
858 :
859 : pSet->Put( SvxSetItem( nHeadFoot ? ATTR_PAGE_FOOTERSET : ATTR_PAGE_HEADERSET,
860 0 : aSetItemItemSet ) );
861 0 : }
862 :
863 0 : SvxPageItem aPageItem(ATTR_PAGE);
864 0 : aPageItem.SetPageUsage( SVX_PAGE_ALL );
865 0 : aPageItem.SetLandscape( pPage->Orientation != 1 );
866 0 : aPageItem.SetNumType( SVX_ARABIC );
867 0 : pSet->Put(aPageItem);
868 :
869 0 : pSet->Put(SvxLRSpaceItem( pPage->Left, pPage->Right, 0,0, ATTR_LRSPACE ));
870 0 : pSet->Put(SvxULSpaceItem( pPage->Top, pPage->Bottom, ATTR_ULSPACE ));
871 :
872 0 : pSet->Put(SfxBoolItem( ATTR_PAGE_HORCENTER, pPage->HorCenter ));
873 0 : pSet->Put(SfxBoolItem( ATTR_PAGE_VERCENTER, pPage->VerCenter ));
874 :
875 : // Area-Parameter:
876 :
877 : {
878 0 : ScRange* pRepeatRow = NULL;
879 0 : ScRange* pRepeatCol = NULL;
880 :
881 0 : if ( pPage->ColRepeatStart >= 0 )
882 0 : pRepeatCol = new ScRange( static_cast<SCCOL> (pPage->ColRepeatStart), 0, 0 );
883 0 : if ( pPage->RowRepeatStart >= 0 )
884 0 : pRepeatRow = new ScRange( 0, static_cast<SCROW> (pPage->RowRepeatStart), 0 );
885 :
886 0 : if ( pRepeatRow || pRepeatCol )
887 : {
888 :
889 : // set for all tables
890 :
891 0 : for ( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab )
892 : {
893 0 : pDoc->SetRepeatColRange( nTab, pRepeatCol );
894 0 : pDoc->SetRepeatRowRange( nTab, pRepeatRow );
895 : }
896 : }
897 :
898 0 : delete pRepeatRow;
899 0 : delete pRepeatCol;
900 : }
901 :
902 : // Table-Parameter:
903 :
904 0 : pSet->Put( SfxBoolItem( ATTR_PAGE_NOTES, pPage->PrintNote ) );
905 0 : pSet->Put( SfxBoolItem( ATTR_PAGE_GRID, pPage->PrintGrid ) );
906 0 : pSet->Put( SfxBoolItem( ATTR_PAGE_HEADERS, pPage->PrintColRow ) );
907 0 : pSet->Put( SfxBoolItem( ATTR_PAGE_TOPDOWN, pPage->TopBottomDir ) );
908 0 : pSet->Put( ScViewObjectModeItem( ATTR_PAGE_CHARTS, VOBJ_MODE_SHOW ) );
909 0 : pSet->Put( ScViewObjectModeItem( ATTR_PAGE_OBJECTS, VOBJ_MODE_SHOW ) );
910 0 : pSet->Put( ScViewObjectModeItem( ATTR_PAGE_DRAWINGS, VOBJ_MODE_SHOW ) );
911 : pSet->Put( SfxUInt16Item( ATTR_PAGE_SCALE,
912 0 : (sal_uInt16)( lcl_PascalToDouble( pPage->PrnZoom ) * 100 ) ) );
913 0 : pSet->Put( SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO, 1 ) );
914 :
915 0 : pSet->Put( SvxSizeItem( ATTR_PAGE_SIZE, Size( pPage->Width, pPage->Height ) ) );
916 0 : }
917 :
918 0 : delete pEmptyObject;
919 0 : }
920 :
921 0 : ScDataObject* Sc10PageData::Clone() const
922 : {
923 0 : return new Sc10PageData(aPageFormat);
924 : }
925 :
926 : // Import
927 :
928 0 : Sc10Import::Sc10Import(SvStream& rStr, ScDocument* pDocument ) :
929 : rStream (rStr),
930 : pDoc (pDocument),
931 : pFontCollection (NULL),
932 : pNameCollection (NULL),
933 : pPatternCollection (NULL),
934 : pDataBaseCollection (NULL),
935 : nError (0),
936 0 : nShowTab (0)
937 : {
938 0 : pPrgrsBar = NULL;
939 0 : }
940 :
941 0 : Sc10Import::~Sc10Import()
942 : {
943 0 : pDoc->CalcAfterLoad();
944 0 : pDoc->UpdateAllCharts();
945 :
946 0 : delete pFontCollection;
947 0 : delete pNameCollection;
948 0 : delete pPatternCollection;
949 0 : delete pDataBaseCollection;
950 :
951 : OSL_ENSURE( pPrgrsBar == NULL,
952 : "*Sc10Import::Sc10Import(): Progressbar lebt noch!?" );
953 0 : }
954 :
955 0 : sal_uLong Sc10Import::Import()
956 : {
957 0 : pPrgrsBar = new ScfStreamProgressBar( rStream, pDoc->GetDocumentShell() );
958 :
959 0 : ScDocOptions aOpt = pDoc->GetDocOptions();
960 0 : aOpt.SetDate( 1, 1, 1900 );
961 0 : aOpt.SetYear2000( 18 + 1901 ); // 4-digit since SO51 src513e
962 0 : pDoc->SetDocOptions( aOpt );
963 0 : pDoc->GetFormatTable()->ChangeNullDate( 1, 1, 1900 );
964 :
965 0 : LoadFileHeader(); pPrgrsBar->Progress();
966 0 : if (!nError) { LoadFileInfo(); pPrgrsBar->Progress(); }
967 0 : if (!nError) { LoadEditStateInfo(); pPrgrsBar->Progress(); }
968 0 : if (!nError) { LoadProtect(); pPrgrsBar->Progress(); }
969 0 : if (!nError) { LoadViewColRowBar(); pPrgrsBar->Progress(); }
970 0 : if (!nError) { LoadScrZoom(); pPrgrsBar->Progress(); }
971 0 : if (!nError) { LoadPalette(); pPrgrsBar->Progress(); }
972 0 : if (!nError) { LoadFontCollection(); pPrgrsBar->Progress(); }
973 0 : if (!nError) { LoadNameCollection(); pPrgrsBar->Progress(); }
974 0 : if (!nError) { LoadPatternCollection(); pPrgrsBar->Progress(); }
975 0 : if (!nError) { LoadDataBaseCollection(); pPrgrsBar->Progress(); }
976 0 : if (!nError) { LoadTables(); pPrgrsBar->Progress(); }
977 0 : if (!nError) { LoadObjects(); pPrgrsBar->Progress(); }
978 0 : if (!nError) { ImportNameCollection(); pPrgrsBar->Progress(); }
979 0 : pDoc->SetViewOptions( aSc30ViewOpt );
980 :
981 : #if OSL_DEBUG_LEVEL > 0
982 : if (nError)
983 : {
984 : OSL_FAIL( OString::number(nError).getStr());
985 : }
986 : #endif
987 :
988 0 : delete pPrgrsBar;
989 : #if OSL_DEBUG_LEVEL > 0
990 : pPrgrsBar = NULL;
991 : #endif
992 :
993 0 : return nError;
994 : }
995 :
996 0 : void Sc10Import::LoadFileHeader()
997 : {
998 : Sc10FileHeader FileHeader;
999 0 : lcl_ReadFileHeader(rStream, FileHeader);
1000 :
1001 0 : nError = rStream.GetError();
1002 0 : if ( nError == 0 )
1003 : {
1004 : sal_Char Sc10CopyRight[32];
1005 0 : strcpy(Sc10CopyRight, "Blaise-Tabelle");
1006 0 : Sc10CopyRight[14] = 10;
1007 0 : Sc10CopyRight[15] = 13;
1008 0 : Sc10CopyRight[16] = 0;
1009 0 : if ((strcmp(FileHeader.CopyRight, Sc10CopyRight) != 0)
1010 0 : || (FileHeader.Version < 101)
1011 0 : || (FileHeader.Version > 102))
1012 0 : nError = errUnknownFormat;
1013 : }
1014 0 : }
1015 :
1016 0 : void Sc10Import::LoadFileInfo()
1017 : {
1018 : Sc10FileInfo FileInfo;
1019 0 : rStream.Read(&FileInfo, sizeof(FileInfo));
1020 :
1021 0 : nError = rStream.GetError();
1022 : // TODO: ? copy info
1023 0 : }
1024 :
1025 0 : void Sc10Import::LoadEditStateInfo()
1026 : {
1027 : Sc10EditStateInfo EditStateInfo;
1028 0 : rStream.Read(&EditStateInfo, sizeof(EditStateInfo));
1029 :
1030 0 : nError = rStream.GetError();
1031 0 : nShowTab = static_cast<SCTAB>(EditStateInfo.DeltaZ);
1032 : // TODO: ? copy cursor position and offset of the table (shall we do that??)
1033 :
1034 0 : }
1035 :
1036 0 : void Sc10Import::LoadProtect()
1037 : {
1038 0 : lcl_ReadSheetProtect(rStream, SheetProtect);
1039 0 : nError = rStream.GetError();
1040 :
1041 0 : ScDocProtection aProtection;
1042 0 : aProtection.setProtected(static_cast<bool>(SheetProtect.Protect));
1043 0 : aProtection.setPassword(SC10TOSTRING(SheetProtect.PassWord));
1044 0 : pDoc->SetDocProtection(&aProtection);
1045 0 : }
1046 :
1047 0 : void Sc10Import::LoadViewColRowBar()
1048 : {
1049 : bool bViewColRowBar;
1050 0 : rStream.ReadCharAsBool( bViewColRowBar );
1051 0 : nError = rStream.GetError();
1052 0 : aSc30ViewOpt.SetOption( VOPT_HEADER, bViewColRowBar );
1053 0 : }
1054 :
1055 0 : void Sc10Import::LoadScrZoom()
1056 : {
1057 : // TODO: unfortunately Zoom is a 6-byte TP real number (don't know how to translate that)
1058 : sal_Char cZoom[6];
1059 0 : rStream.Read(cZoom, sizeof(cZoom));
1060 0 : nError = rStream.GetError();
1061 0 : }
1062 :
1063 0 : void Sc10Import::LoadPalette()
1064 : {
1065 0 : lcl_ReadPalette(rStream, TextPalette);
1066 0 : lcl_ReadPalette(rStream, BackPalette);
1067 0 : lcl_ReadPalette(rStream, RasterPalette);
1068 0 : lcl_ReadPalette(rStream, FramePalette);
1069 :
1070 0 : nError = rStream.GetError();
1071 0 : }
1072 :
1073 0 : void Sc10Import::LoadFontCollection()
1074 : {
1075 0 : pFontCollection = new Sc10FontCollection(rStream);
1076 0 : if (!nError)
1077 0 : nError = pFontCollection->GetError();
1078 0 : }
1079 :
1080 0 : void Sc10Import::LoadNameCollection()
1081 : {
1082 0 : pNameCollection = new Sc10NameCollection(rStream);
1083 0 : if (!nError)
1084 0 : nError = pNameCollection->GetError();
1085 0 : }
1086 :
1087 0 : void Sc10Import::ImportNameCollection()
1088 : {
1089 0 : ScRangeName* pRN = pDoc->GetRangeName();
1090 :
1091 0 : for (sal_uInt16 i = 0; i < pNameCollection->GetCount(); i++)
1092 : {
1093 0 : Sc10NameData* pName = pNameCollection->At( i );
1094 : pRN->insert(
1095 : new ScRangeData(
1096 0 : pDoc, SC10TOSTRING(pName->Name), SC10TOSTRING(pName->Reference)));
1097 : }
1098 0 : }
1099 :
1100 0 : void Sc10Import::LoadPatternCollection()
1101 : {
1102 0 : pPatternCollection = new Sc10PatternCollection( rStream );
1103 0 : if (!nError)
1104 0 : nError = pPatternCollection->GetError();
1105 0 : if (nError == errOutOfMemory)
1106 0 : return; // hopeless
1107 0 : ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
1108 0 : for( sal_uInt16 i = 0 ; i < pPatternCollection->GetCount() ; i++ )
1109 : {
1110 0 : Sc10PatternData* pPattern = pPatternCollection->At( i );
1111 0 : OUString aName( pPattern->Name, strlen(pPattern->Name), DEFCHARSET );
1112 0 : SfxStyleSheetBase* pStyle = pStylePool->Find( aName, SFX_STYLE_FAMILY_PARA );
1113 0 : if( pStyle == NULL )
1114 0 : pStylePool->Make( aName, SFX_STYLE_FAMILY_PARA );
1115 : else
1116 : {
1117 0 : pPattern->Name[ 27 ] = 0;
1118 0 : strcat( pPattern->Name, "_Old" );
1119 0 : aName = SC10TOSTRING( pPattern->Name );
1120 0 : pStylePool->Make( aName, SFX_STYLE_FAMILY_PARA );
1121 : }
1122 0 : pStyle = pStylePool->Find( aName, SFX_STYLE_FAMILY_PARA );
1123 0 : if( pStyle != NULL )
1124 : {
1125 0 : SfxItemSet &rItemSet = pStyle->GetItemSet();
1126 : // Font
1127 0 : if( ( pPattern->FormatFlags & pfFont ) == pfFont )
1128 : {
1129 0 : FontFamily eFam = FAMILY_DONTKNOW;
1130 0 : switch( pPattern->LogFont.lfPitchAndFamily & 0xF0 )
1131 : {
1132 0 : case ffDontCare : eFam = FAMILY_DONTKNOW; break;
1133 0 : case ffRoman : eFam = FAMILY_ROMAN; break;
1134 0 : case ffSwiss : eFam = FAMILY_SWISS; break;
1135 0 : case ffModern : eFam = FAMILY_MODERN; break;
1136 0 : case ffScript : eFam = FAMILY_SCRIPT; break;
1137 0 : case ffDecorative : eFam = FAMILY_DECORATIVE; break;
1138 0 : default: eFam = FAMILY_DONTKNOW; break;
1139 : }
1140 0 : rItemSet.Put( SvxFontItem( eFam, SC10TOSTRING( pPattern->LogFont.lfFaceName ), EMPTY_OUSTRING,
1141 0 : PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT ) );
1142 0 : rItemSet.Put( SvxFontHeightItem( std::abs( pPattern->LogFont.lfHeight ), 100, ATTR_FONT_HEIGHT ) );
1143 0 : Color TextColor( COL_BLACK );
1144 0 : lcl_ChangeColor( ( pPattern->nColor & 0x000F ), TextColor );
1145 0 : rItemSet.Put( SvxColorItem( TextColor, ATTR_FONT_COLOR ) );
1146 : // FontAttr
1147 0 : if( pPattern->LogFont.lfWeight != fwNormal )
1148 0 : rItemSet.Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) );
1149 0 : if( pPattern->LogFont.lfItalic != 0 )
1150 0 : rItemSet.Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
1151 0 : if( pPattern->LogFont.lfUnderline != 0 )
1152 0 : rItemSet.Put( SvxUnderlineItem( UNDERLINE_SINGLE, ATTR_FONT_UNDERLINE ) );
1153 0 : if( pPattern->LogFont.lfStrikeOut != 0 )
1154 0 : rItemSet.Put( SvxCrossedOutItem( STRIKEOUT_SINGLE, ATTR_FONT_CROSSEDOUT ) );
1155 : }
1156 : // alignment
1157 0 : if( ( pPattern->FormatFlags & pfJustify ) == pfJustify )
1158 : {
1159 0 : sal_uInt16 HorJustify = ( pPattern->Justify & 0x000F );
1160 0 : sal_uInt16 VerJustify = ( pPattern->Justify & 0x00F0 ) >> 4;
1161 0 : sal_uInt16 OJustify = ( pPattern->Justify & 0x0F00 ) >> 8;
1162 0 : sal_uInt16 EJustify = ( pPattern->Justify & 0xF000 ) >> 12;
1163 0 : if( HorJustify != 0 )
1164 0 : switch( HorJustify )
1165 : {
1166 : case hjLeft:
1167 0 : rItemSet.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_LEFT, ATTR_HOR_JUSTIFY ) );
1168 0 : break;
1169 : case hjCenter:
1170 0 : rItemSet.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY ) );
1171 0 : break;
1172 : case hjRight:
1173 0 : rItemSet.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_RIGHT, ATTR_HOR_JUSTIFY ) );
1174 0 : break;
1175 : }
1176 0 : if( VerJustify != 0 )
1177 0 : switch( VerJustify )
1178 : {
1179 : case vjTop:
1180 0 : rItemSet.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_TOP, ATTR_VER_JUSTIFY ) );
1181 0 : break;
1182 : case vjCenter:
1183 0 : rItemSet.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_CENTER, ATTR_VER_JUSTIFY ) );
1184 0 : break;
1185 : case vjBottom:
1186 0 : rItemSet.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_BOTTOM, ATTR_VER_JUSTIFY ) );
1187 0 : break;
1188 : }
1189 :
1190 0 : if( ( OJustify & ojWordBreak ) == ojWordBreak )
1191 0 : rItemSet.Put( SfxBoolItem( ATTR_LINEBREAK, true ) );
1192 0 : if( ( OJustify & ojBottomTop ) == ojBottomTop )
1193 0 : rItemSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
1194 0 : else if( ( OJustify & ojTopBottom ) == ojTopBottom )
1195 0 : rItemSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
1196 :
1197 0 : sal_Int16 Margin = std::max( ( sal_uInt16 ) 20, ( sal_uInt16 ) ( EJustify * 20 ) );
1198 0 : if( ( ( OJustify & ojBottomTop ) == ojBottomTop ) )
1199 0 : rItemSet.Put( SvxMarginItem( 20, Margin, 20, Margin, ATTR_MARGIN ) );
1200 : else
1201 0 : rItemSet.Put( SvxMarginItem( Margin, 20, Margin, 20, ATTR_MARGIN ) );
1202 : }
1203 :
1204 : // Frame
1205 0 : if( ( pPattern->FormatFlags & pfFrame ) == pfFrame )
1206 : {
1207 0 : if( pPattern->Frame != 0 )
1208 : {
1209 0 : sal_uInt16 nLeft = 0;
1210 0 : sal_uInt16 nTop = 0;
1211 0 : sal_uInt16 nRight = 0;
1212 0 : sal_uInt16 nBottom = 0;
1213 0 : sal_uInt16 fLeft = ( pPattern->Frame & 0x000F );
1214 0 : sal_uInt16 fTop = ( pPattern->Frame & 0x00F0 ) / 0x0010;
1215 0 : sal_uInt16 fRight = ( pPattern->Frame & 0x0F00 ) / 0x0100;
1216 0 : sal_uInt16 fBottom = ( pPattern->Frame & 0xF000 ) / 0x1000;
1217 :
1218 0 : if( fLeft > 1 )
1219 0 : nLeft = 50;
1220 0 : else if( fLeft > 0 )
1221 0 : nLeft = 20;
1222 :
1223 0 : if( fTop > 1 )
1224 0 : nTop = 50;
1225 0 : else if( fTop > 0 )
1226 0 : nTop = 20;
1227 :
1228 0 : if( fRight > 1 )
1229 0 : nRight = 50;
1230 0 : else if( fRight > 0 )
1231 0 : nRight = 20;
1232 :
1233 0 : if( fBottom > 1 )
1234 0 : nBottom = 50;
1235 0 : else if( fBottom > 0 )
1236 0 : nBottom = 20;
1237 :
1238 0 : Color ColorLeft( COL_BLACK );
1239 0 : Color ColorTop( COL_BLACK );
1240 0 : Color ColorRight( COL_BLACK );
1241 0 : Color ColorBottom( COL_BLACK );
1242 :
1243 0 : sal_uInt16 cLeft = ( pPattern->FrameColor & 0x000F );
1244 0 : sal_uInt16 cTop = ( pPattern->FrameColor & 0x00F0 ) >> 4;
1245 0 : sal_uInt16 cRight = ( pPattern->FrameColor & 0x0F00 ) >> 8;
1246 0 : sal_uInt16 cBottom = ( pPattern->FrameColor & 0xF000 ) >> 12;
1247 :
1248 0 : lcl_ChangeColor( cLeft, ColorLeft );
1249 0 : lcl_ChangeColor( cTop, ColorTop );
1250 0 : lcl_ChangeColor( cRight, ColorRight );
1251 0 : lcl_ChangeColor( cBottom, ColorBottom );
1252 :
1253 0 : ::editeng::SvxBorderLine aLine;
1254 0 : SvxBoxItem aBox( ATTR_BORDER );
1255 :
1256 0 : aLine.SetWidth( nLeft );
1257 0 : aLine.SetColor( ColorLeft );
1258 0 : aBox.SetLine( &aLine, SvxBoxItemLine::LEFT );
1259 0 : aLine.SetWidth( nTop );
1260 0 : aLine.SetColor( ColorTop );
1261 0 : aBox.SetLine( &aLine, SvxBoxItemLine::TOP );
1262 0 : aLine.SetWidth( nRight );
1263 0 : aLine.SetColor( ColorRight );
1264 0 : aBox.SetLine( &aLine, SvxBoxItemLine::RIGHT );
1265 0 : aLine.SetWidth( nBottom );
1266 0 : aLine.SetColor( ColorBottom );
1267 0 : aBox.SetLine( &aLine, SvxBoxItemLine::BOTTOM );
1268 0 : rItemSet.Put( aBox );
1269 : }
1270 : }
1271 : // grid
1272 0 : if( ( pPattern->FormatFlags & pfRaster ) == pfRaster )
1273 : {
1274 0 : if( pPattern->Raster != 0 )
1275 : {
1276 0 : sal_uInt16 nBColor = ( pPattern->nColor & 0x00F0 ) >> 4;
1277 0 : sal_uInt16 nRColor = ( pPattern->nColor & 0x0F00 ) >> 8;
1278 0 : Color aBColor( COL_BLACK );
1279 :
1280 0 : lcl_ChangeColor( nBColor, aBColor );
1281 :
1282 0 : if( nBColor == 0 )
1283 0 : aBColor.SetColor( COL_WHITE );
1284 0 : else if( nBColor == 15 )
1285 0 : aBColor.SetColor( COL_BLACK );
1286 :
1287 0 : Color aRColor( COL_BLACK );
1288 0 : lcl_ChangeColor( nRColor, aRColor );
1289 : sal_uInt16 nFact;
1290 0 : bool bSwapCol = false;
1291 0 : bool bSetItem = true;
1292 0 : switch (pPattern->Raster)
1293 : {
1294 0 : case raNone: nFact = 0xffff; bSwapCol = true; bSetItem = (nBColor > 0); break;
1295 0 : case raGray12: nFact = (0xffff / 100) * 12; break;
1296 0 : case raGray25: nFact = (0xffff / 100) * 25; break;
1297 0 : case raGray50: nFact = (0xffff / 100) * 50; break;
1298 0 : case raGray75: nFact = (0xffff / 100) * 75; break;
1299 0 : default: nFact = 0xffff; bSetItem = (nRColor < 15);
1300 : }
1301 0 : if ( bSetItem )
1302 : {
1303 0 : if( bSwapCol )
1304 0 : rItemSet.Put( SvxBrushItem( GetMixedColor( aBColor, aRColor, nFact ), ATTR_BACKGROUND ) );
1305 : else
1306 0 : rItemSet.Put( SvxBrushItem( GetMixedColor( aRColor, aBColor, nFact ), ATTR_BACKGROUND ) );
1307 : }
1308 : }
1309 : }
1310 : // number formats
1311 0 : if( ( pPattern->ValueFormat.Format != 0 ) &&
1312 0 : ( ( pPattern->FormatFlags & pfValue ) == pfValue ) )
1313 : {
1314 0 : sal_uLong nKey = 0;
1315 0 : ChangeFormat( pPattern->ValueFormat.Format, pPattern->ValueFormat.Info, nKey );
1316 0 : rItemSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, ( sal_uInt32 ) nKey ) );
1317 : }
1318 :
1319 : // cell attributes (protected, hidden...)
1320 0 : if( ( pPattern->Flags != 0 ) &&
1321 0 : ( ( pPattern->FormatFlags & pfProtection ) == pfProtection ) )
1322 : {
1323 0 : bool bProtect = ( ( pPattern->Flags & paProtect ) == paProtect );
1324 0 : bool bHFormula = ( ( pPattern->Flags & paHideFormula ) == paHideFormula );
1325 0 : bool bHCell = ( ( pPattern->Flags & paHideAll ) == paHideAll );
1326 0 : bool bHPrint = ( ( pPattern->Flags & paHidePrint ) == paHidePrint );
1327 0 : rItemSet.Put( ScProtectionAttr( bProtect, bHFormula, bHCell, bHPrint ) );
1328 : }
1329 : } // if Style != 0
1330 0 : } // for (i = 0; i < GetCount()
1331 : }
1332 :
1333 0 : void Sc10Import::LoadDataBaseCollection()
1334 : {
1335 0 : pDataBaseCollection = new Sc10DataBaseCollection(rStream);
1336 0 : if (!nError)
1337 0 : nError = pDataBaseCollection->GetError();
1338 0 : if (nError == errOutOfMemory)
1339 0 : return; // hopeless
1340 0 : for( sal_uInt16 i = 0 ; i < pDataBaseCollection->GetCount() ; i++ )
1341 : {
1342 0 : Sc10DataBaseData* pOldData = pDataBaseCollection->At(i);
1343 0 : ScDBData* pNewData = new ScDBData( SC10TOSTRING( pOldData->DataBaseRec.Name ),
1344 : ( SCTAB ) pOldData->DataBaseRec.Tab,
1345 : ( SCCOL ) pOldData->DataBaseRec.Block.x1,
1346 : ( SCROW ) pOldData->DataBaseRec.Block.y1,
1347 : ( SCCOL ) pOldData->DataBaseRec.Block.x2,
1348 : ( SCROW ) pOldData->DataBaseRec.Block.y2,
1349 : true,
1350 0 : (bool) pOldData->DataBaseRec.RowHeader );
1351 0 : bool ins = pDoc->GetDBCollection()->getNamedDBs().insert(pNewData);
1352 : assert(ins); (void)ins;
1353 : //TODO: or can this fail (and need delete pNewData)?
1354 : }
1355 : }
1356 :
1357 : namespace
1358 : {
1359 0 : sal_uInt16 ReadAndSanitizeDataCount(SvStream &rStream)
1360 : {
1361 0 : sal_uInt16 nDataCount(0);
1362 0 : rStream.ReadUInt16(nDataCount);
1363 0 : const size_t nMinRecordSize = sizeof(sal_uInt16)*2;
1364 0 : const size_t nMaxRecords = rStream.remainingSize() / nMinRecordSize;
1365 0 : if (nDataCount > nMaxRecords)
1366 : {
1367 : SAL_WARN("sc", "Parsing error: " << nMaxRecords <<
1368 : " max possible entries, but " << nDataCount << " claimed, truncating");
1369 0 : nDataCount = nMaxRecords;
1370 : }
1371 0 : return nDataCount;
1372 : }
1373 : }
1374 :
1375 0 : void Sc10Import::LoadTables()
1376 : {
1377 0 : Sc10PageCollection aPageCollection;
1378 :
1379 : sal_Int16 nTabCount;
1380 0 : rStream.ReadInt16( nTabCount );
1381 0 : for (sal_Int16 Tab = 0; (Tab < nTabCount) && (nError == 0); Tab++)
1382 : {
1383 0 : Sc10PageFormat PageFormat;
1384 : sal_Int16 DataBaseIndex;
1385 : Sc10TableProtect TabProtect;
1386 : sal_Int16 TabNo;
1387 : sal_Char TabName[128];
1388 : sal_uInt16 Display;
1389 : sal_uInt8 Visible;
1390 : sal_uInt16 ID;
1391 : sal_uInt16 DataCount;
1392 : sal_uInt16 DataStart;
1393 : sal_uInt16 DataEnd;
1394 : sal_uInt16 DataValue;
1395 : sal_uInt16 Count;
1396 : sal_uInt16 i;
1397 :
1398 0 : lcl_ReadPageFormat(rStream, PageFormat);
1399 :
1400 0 : sal_uInt16 nAt = aPageCollection.InsertFormat(PageFormat);
1401 0 : OUString aPageName = lcl_MakeOldPageStyleFormatName( nAt );
1402 :
1403 0 : pPrgrsBar->Progress();
1404 :
1405 0 : rStream.ReadInt16( DataBaseIndex );
1406 :
1407 0 : lcl_ReadTabProtect(rStream, TabProtect);
1408 :
1409 0 : ScTableProtection aProtection;
1410 0 : aProtection.setProtected(static_cast<bool>(TabProtect.Protect));
1411 0 : aProtection.setPassword(SC10TOSTRING(TabProtect.PassWord));
1412 0 : pDoc->SetTabProtection(static_cast<SCTAB>(Tab), &aProtection);
1413 :
1414 0 : rStream.ReadInt16( TabNo );
1415 :
1416 : sal_uInt8 nLen;
1417 0 : rStream.ReadUChar( nLen );
1418 0 : rStream.Read(TabName, sizeof(TabName) - 1);
1419 0 : if (nLen >= sizeof(TabName))
1420 0 : nLen = sizeof(TabName) - 1;
1421 0 : TabName[nLen] = 0;
1422 :
1423 0 : rStream.ReadUInt16( Display );
1424 :
1425 0 : if ( Tab == (sal_Int16)nShowTab )
1426 : {
1427 0 : ScVObjMode eObjMode = VOBJ_MODE_SHOW;
1428 :
1429 0 : aSc30ViewOpt.SetOption( VOPT_FORMULAS, IS_SET(dfFormula,Display) );
1430 0 : aSc30ViewOpt.SetOption( VOPT_NULLVALS, IS_SET(dfZerro,Display) );
1431 0 : aSc30ViewOpt.SetOption( VOPT_SYNTAX, IS_SET(dfSyntax,Display) );
1432 0 : aSc30ViewOpt.SetOption( VOPT_NOTES, IS_SET(dfNoteMark,Display) );
1433 0 : aSc30ViewOpt.SetOption( VOPT_VSCROLL, true );
1434 0 : aSc30ViewOpt.SetOption( VOPT_HSCROLL, true );
1435 0 : aSc30ViewOpt.SetOption( VOPT_TABCONTROLS, true );
1436 0 : aSc30ViewOpt.SetOption( VOPT_OUTLINER, true );
1437 0 : aSc30ViewOpt.SetOption( VOPT_GRID, IS_SET(dfGrid,Display) );
1438 :
1439 : // VOPT_HEADER is set in LoadViewColRowBar()
1440 :
1441 0 : if ( IS_SET(dfObjectAll,Display) ) // show objects
1442 0 : eObjMode = VOBJ_MODE_SHOW;
1443 0 : else if ( IS_SET(dfObjectFrame,Display) ) // object as placeholder
1444 0 : eObjMode = VOBJ_MODE_SHOW;
1445 0 : else if ( IS_SET(dfObjectNone,Display) ) // don't show objects
1446 0 : eObjMode = VOBJ_MODE_HIDE;
1447 :
1448 0 : aSc30ViewOpt.SetObjMode( VOBJ_TYPE_OLE, eObjMode );
1449 0 : aSc30ViewOpt.SetObjMode( VOBJ_TYPE_CHART, eObjMode );
1450 0 : aSc30ViewOpt.SetObjMode( VOBJ_TYPE_DRAW, eObjMode );
1451 : }
1452 :
1453 0 : rStream.ReadUChar( Visible );
1454 :
1455 0 : nError = rStream.GetError();
1456 0 : if (nError != 0) return;
1457 :
1458 0 : if (TabNo == 0)
1459 0 : pDoc->RenameTab(static_cast<SCTAB> (TabNo), SC10TOSTRING( TabName ), false);
1460 : else
1461 0 : pDoc->InsertTab(SC_TAB_APPEND, SC10TOSTRING( TabName ) );
1462 :
1463 0 : pDoc->SetPageStyle( static_cast<SCTAB>(Tab), aPageName );
1464 :
1465 0 : if (Visible == 0) pDoc->SetVisible(static_cast<SCTAB> (TabNo), false);
1466 :
1467 : // ColWidth
1468 0 : rStream.ReadUInt16( ID );
1469 0 : if (ID != ColWidthID)
1470 : {
1471 : OSL_FAIL( "ColWidthID" );
1472 0 : nError = errUnknownID;
1473 0 : return;
1474 : }
1475 0 : DataCount = ReadAndSanitizeDataCount(rStream);
1476 0 : DataStart = 0;
1477 0 : for (i=0; i < DataCount; i++)
1478 : {
1479 0 : rStream.ReadUInt16( DataEnd );
1480 0 : DataEnd = SanitizeCol(DataEnd);
1481 0 : rStream.ReadUInt16( DataValue );
1482 0 : for (SCCOL j = static_cast<SCCOL>(DataStart); j <= static_cast<SCCOL>(DataEnd); j++)
1483 0 : pDoc->SetColWidth(j, static_cast<SCTAB> (TabNo), DataValue);
1484 0 : DataStart = DataEnd + 1;
1485 : }
1486 0 : pPrgrsBar->Progress();
1487 :
1488 : // ColAttr
1489 0 : rStream.ReadUInt16( ID );
1490 0 : if (ID != ColAttrID)
1491 : {
1492 : OSL_FAIL( "ColAttrID" );
1493 0 : nError = errUnknownID;
1494 0 : return;
1495 : }
1496 :
1497 0 : DataCount = ReadAndSanitizeDataCount(rStream);
1498 0 : DataStart = 0;
1499 0 : for (i=0; i < DataCount; i++)
1500 : {
1501 0 : rStream.ReadUInt16( DataEnd );
1502 0 : rStream.ReadUInt16( DataValue );
1503 0 : if (DataValue != 0)
1504 : {
1505 0 : bool bPageBreak = ((DataValue & crfSoftBreak) == crfSoftBreak);
1506 0 : bool bManualBreak = ((DataValue & crfHardBreak) == crfHardBreak);
1507 0 : bool bHidden = ((DataValue & crfHidden) == crfHidden);
1508 0 : for (SCCOL k = SanitizeCol(static_cast<SCCOL>(DataStart)); k <= SanitizeCol(static_cast<SCCOL>(DataEnd)); k++)
1509 : {
1510 0 : pDoc->SetColHidden(k, k, static_cast<SCTAB>(TabNo), bHidden);
1511 0 : pDoc->SetColBreak(k, static_cast<SCTAB> (TabNo), bPageBreak, bManualBreak);
1512 : }
1513 : }
1514 0 : DataStart = DataEnd + 1;
1515 : }
1516 0 : pPrgrsBar->Progress();
1517 :
1518 : // RowHeight
1519 0 : rStream.ReadUInt16( ID );
1520 0 : if (ID != RowHeightID)
1521 : {
1522 : OSL_FAIL( "RowHeightID" );
1523 0 : nError = errUnknownID;
1524 0 : return;
1525 : }
1526 :
1527 0 : DataCount = ReadAndSanitizeDataCount(rStream);
1528 0 : DataStart = 0;
1529 0 : for (i=0; i < DataCount; i++)
1530 : {
1531 0 : rStream.ReadUInt16( DataEnd );
1532 0 : rStream.ReadUInt16( DataValue );
1533 0 : pDoc->SetRowHeightRange(static_cast<SCROW> (DataStart), static_cast<SCROW> (DataEnd), static_cast<SCTAB> (TabNo), DataValue);
1534 0 : DataStart = DataEnd + 1;
1535 : }
1536 0 : pPrgrsBar->Progress();
1537 :
1538 : // RowAttr
1539 0 : rStream.ReadUInt16( ID );
1540 0 : if (ID != RowAttrID)
1541 : {
1542 : OSL_FAIL( "RowAttrID" );
1543 0 : nError = errUnknownID;
1544 0 : return;
1545 : }
1546 :
1547 0 : DataCount = ReadAndSanitizeDataCount(rStream);
1548 0 : DataStart = 0;
1549 0 : for (i=0; i < DataCount; i++)
1550 : {
1551 0 : rStream.ReadUInt16( DataEnd );
1552 0 : rStream.ReadUInt16( DataValue );
1553 0 : if (DataValue != 0)
1554 : {
1555 0 : bool bPageBreak = ((DataValue & crfSoftBreak) == crfSoftBreak);
1556 0 : bool bManualBreak = ((DataValue & crfHardBreak) == crfHardBreak);
1557 0 : bool bHidden = ((DataValue & crfHidden) == crfHidden);
1558 0 : for (SCROW l = SanitizeRow(static_cast<SCROW>(DataStart)); l <= SanitizeRow(static_cast<SCROW>(DataEnd)); ++l)
1559 : {
1560 0 : pDoc->SetRowHidden(l, l, static_cast<SCTAB> (TabNo), bHidden);
1561 0 : pDoc->SetRowBreak(l, static_cast<SCTAB> (TabNo), bPageBreak, bManualBreak);
1562 : }
1563 : }
1564 0 : DataStart = DataEnd + 1;
1565 : }
1566 0 : pPrgrsBar->Progress();
1567 :
1568 : // Data table
1569 0 : rStream.ReadUInt16( ID );
1570 0 : if (ID != TableID)
1571 : {
1572 : OSL_FAIL( "TableID" );
1573 0 : nError = errUnknownID;
1574 0 : return;
1575 : }
1576 0 : for (SCCOL Col = 0; (Col <= SC10MAXCOL) && (nError == 0); Col++)
1577 : {
1578 0 : rStream.ReadUInt16( Count );
1579 0 : nError = rStream.GetError();
1580 0 : if ((Count != 0) && (nError == 0))
1581 0 : LoadCol(Col, static_cast<SCTAB> (TabNo));
1582 : }
1583 : OSL_ENSURE( nError == 0, "Stream" );
1584 0 : }
1585 0 : pPrgrsBar->Progress();
1586 :
1587 0 : aPageCollection.PutToDoc( pDoc );
1588 : }
1589 :
1590 0 : void Sc10Import::LoadCol(SCCOL Col, SCTAB Tab)
1591 : {
1592 0 : LoadColAttr(Col, Tab);
1593 :
1594 : sal_uInt16 CellCount;
1595 : sal_uInt8 CellType;
1596 : sal_uInt16 Row;
1597 0 : rStream.ReadUInt16( CellCount );
1598 0 : SCROW nScCount = static_cast< SCROW >( CellCount );
1599 0 : if (nScCount > MAXROW) nError = errUnknownFormat;
1600 0 : for (sal_uInt16 i = 0; (i < CellCount) && (nError == 0); i++)
1601 : {
1602 0 : rStream.ReadUChar( CellType );
1603 0 : rStream.ReadUInt16( Row );
1604 0 : nError = rStream.GetError();
1605 0 : if (nError == 0)
1606 : {
1607 0 : switch (CellType)
1608 : {
1609 : case ctValue :
1610 : {
1611 0 : const SfxPoolItem* pValueFormat = pDoc->GetAttr(Col, static_cast<SCROW> (Row), Tab, ATTR_VALUE_FORMAT);
1612 0 : sal_uLong nFormat = static_cast<const SfxUInt32Item*>(pValueFormat)->GetValue();
1613 0 : double Value = ScfTools::ReadLongDouble(rStream);
1614 : //rStream.Read(&Value, sizeof(Value));
1615 :
1616 : // TODO: adjustment is needed if we change the Basis Date
1617 : // StarCalc 1.0: 01.01.1900
1618 : // if ((nFormat >= 30) && (nFormat <= 35))
1619 : // Value += 0;
1620 0 : if ((nFormat >= 40) && (nFormat <= 45))
1621 0 : Value /= 86400.0;
1622 0 : pDoc->SetValue(Col, static_cast<SCROW> (Row), Tab, Value);
1623 0 : break;
1624 : }
1625 : case ctString :
1626 : {
1627 : sal_uInt8 Len;
1628 : sal_Char s[256];
1629 0 : rStream.ReadUChar( Len );
1630 0 : rStream.Read(s, Len);
1631 0 : s[Len] = 0;
1632 :
1633 0 : pDoc->SetString( Col, static_cast<SCROW> (Row), Tab, SC10TOSTRING( s ) );
1634 0 : break;
1635 : }
1636 : case ctFormula :
1637 : {
1638 0 : /*double Value =*/ ScfTools::ReadLongDouble(rStream);
1639 : sal_uInt8 Len;
1640 : sal_Char s[256+1];
1641 0 : rStream.ReadUChar( Len );
1642 0 : rStream.Read(&s[1], Len);
1643 0 : s[0] = '=';
1644 0 : s[Len + 1] = 0;
1645 0 : ScFormulaCell* pCell = new ScFormulaCell( pDoc, ScAddress( Col, static_cast<SCROW> (Row), Tab ) );
1646 0 : pCell->SetHybridFormula( SC10TOSTRING( s ),formula::FormulaGrammar::GRAM_NATIVE );
1647 0 : pDoc->EnsureTable(Tab);
1648 0 : pDoc->SetFormulaCell(ScAddress(Col,Row,Tab), pCell);
1649 0 : break;
1650 : }
1651 : case ctNote :
1652 0 : break;
1653 : default :
1654 0 : nError = errUnknownFormat;
1655 0 : break;
1656 : }
1657 0 : sal_uInt16 nNoteLen(0);
1658 0 : rStream.ReadUInt16(nNoteLen);
1659 0 : size_t nAvailable = rStream.remainingSize();
1660 0 : if (nNoteLen > nAvailable)
1661 0 : nNoteLen = nAvailable;
1662 0 : if (nNoteLen != 0)
1663 : {
1664 0 : boost::scoped_array<sal_Char> xNote(new sal_Char[nNoteLen+1]);
1665 0 : nNoteLen = rStream.Read(xNote.get(), nNoteLen);
1666 0 : xNote[nNoteLen] = 0;
1667 0 : OUString aNoteText( SC10TOSTRING(xNote.get()));
1668 0 : xNote.reset();
1669 0 : ScAddress aPos( Col, static_cast<SCROW>(Row), Tab );
1670 0 : ScNoteUtil::CreateNoteFromString( *pDoc, aPos, aNoteText, false, false );
1671 : }
1672 : }
1673 0 : pPrgrsBar->Progress();
1674 : }
1675 0 : }
1676 :
1677 0 : void Sc10Import::LoadColAttr(SCCOL Col, SCTAB Tab)
1678 : {
1679 0 : Sc10ColAttr aFont;
1680 0 : Sc10ColAttr aAttr;
1681 0 : Sc10ColAttr aJustify;
1682 0 : Sc10ColAttr aFrame;
1683 0 : Sc10ColAttr aRaster;
1684 0 : Sc10ColAttr aValue;
1685 0 : Sc10ColAttr aColor;
1686 0 : Sc10ColAttr aFrameColor;
1687 0 : Sc10ColAttr aFlag;
1688 0 : Sc10ColAttr aPattern;
1689 :
1690 0 : if (nError == 0) LoadAttr(aFont);
1691 0 : if (nError == 0) LoadAttr(aAttr);
1692 0 : if (nError == 0) LoadAttr(aJustify);
1693 0 : if (nError == 0) LoadAttr(aFrame);
1694 0 : if (nError == 0) LoadAttr(aRaster);
1695 0 : if (nError == 0) LoadAttr(aValue);
1696 0 : if (nError == 0) LoadAttr(aColor);
1697 0 : if (nError == 0) LoadAttr(aFrameColor);
1698 0 : if (nError == 0) LoadAttr(aFlag);
1699 0 : if (nError == 0) LoadAttr(aPattern);
1700 :
1701 0 : if (nError == 0)
1702 : {
1703 : SCROW nStart;
1704 : SCROW nEnd;
1705 : sal_uInt16 i;
1706 : sal_uInt16 nLimit;
1707 : sal_uInt16 nValue1;
1708 : Sc10ColData *pColData;
1709 :
1710 : // Font (Name, Size)
1711 0 : nStart = 0;
1712 0 : nEnd = 0;
1713 0 : nLimit = aFont.Count;
1714 0 : pColData = aFont.pData;
1715 0 : for( i = 0 ; i < nLimit ; i++, pColData++ )
1716 : {
1717 0 : nEnd = static_cast<SCROW>(pColData->Row);
1718 0 : if ((nStart <= nEnd) && (pColData->Value))
1719 : {
1720 0 : FontFamily eFam = FAMILY_DONTKNOW;
1721 0 : Sc10FontData* pFont = pFontCollection->At(pColData->Value);
1722 0 : if (pFont)
1723 : {
1724 0 : switch (pFont->PitchAndFamily & 0xF0)
1725 : {
1726 0 : case ffDontCare : eFam = FAMILY_DONTKNOW; break;
1727 0 : case ffRoman : eFam = FAMILY_ROMAN; break;
1728 0 : case ffSwiss : eFam = FAMILY_SWISS; break;
1729 0 : case ffModern : eFam = FAMILY_MODERN; break;
1730 0 : case ffScript : eFam = FAMILY_SCRIPT; break;
1731 0 : case ffDecorative : eFam = FAMILY_DECORATIVE; break;
1732 0 : default: eFam = FAMILY_DONTKNOW; break;
1733 : }
1734 0 : ScPatternAttr aScPattern(pDoc->GetPool());
1735 0 : aScPattern.GetItemSet().Put(SvxFontItem(eFam, SC10TOSTRING( pFont->FaceName ), EMPTY_OUSTRING,
1736 0 : PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT ));
1737 0 : aScPattern.GetItemSet().Put(SvxFontHeightItem(std::abs(pFont->Height), 100, ATTR_FONT_HEIGHT ));
1738 0 : pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
1739 : }
1740 : }
1741 0 : nStart = nEnd + 1;
1742 : }
1743 :
1744 : // Font color
1745 0 : nStart = 0;
1746 0 : nEnd = 0;
1747 0 : nLimit = aColor.Count;
1748 0 : pColData = aColor.pData;
1749 0 : for( i = 0 ; i < nLimit ; i++, pColData++ )
1750 : {
1751 0 : nEnd = static_cast<SCROW>(pColData->Row);
1752 0 : if ((nStart <= nEnd) && (pColData->Value))
1753 : {
1754 0 : Color TextColor(COL_BLACK);
1755 0 : lcl_ChangeColor((pColData->Value & 0x000F), TextColor);
1756 0 : ScPatternAttr aScPattern(pDoc->GetPool());
1757 0 : aScPattern.GetItemSet().Put(SvxColorItem(TextColor, ATTR_FONT_COLOR ));
1758 0 : pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
1759 : }
1760 0 : nStart = nEnd + 1;
1761 : }
1762 :
1763 : // Font attributes (Bold, Italic...)
1764 0 : nStart = 0;
1765 0 : nEnd = 0;
1766 0 : nLimit = aAttr.Count;
1767 0 : pColData = aAttr.pData;
1768 0 : for( i = 0 ; i < nLimit ; i++, pColData++ )
1769 : {
1770 0 : nEnd = static_cast<SCROW>(pColData->Row);
1771 0 : nValue1 = pColData->Value;
1772 0 : if ((nStart <= nEnd) && (nValue1))
1773 : {
1774 0 : ScPatternAttr aScPattern(pDoc->GetPool());
1775 0 : if ((nValue1 & atBold) == atBold)
1776 0 : aScPattern.GetItemSet().Put(SvxWeightItem(WEIGHT_BOLD, ATTR_FONT_WEIGHT));
1777 0 : if ((nValue1 & atItalic) == atItalic)
1778 0 : aScPattern.GetItemSet().Put(SvxPostureItem(ITALIC_NORMAL, ATTR_FONT_POSTURE));
1779 0 : if ((nValue1 & atUnderline) == atUnderline)
1780 0 : aScPattern.GetItemSet().Put(SvxUnderlineItem(UNDERLINE_SINGLE, ATTR_FONT_UNDERLINE));
1781 0 : if ((nValue1 & atStrikeOut) == atStrikeOut)
1782 0 : aScPattern.GetItemSet().Put(SvxCrossedOutItem(STRIKEOUT_SINGLE, ATTR_FONT_CROSSEDOUT));
1783 0 : pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
1784 : }
1785 0 : nStart = nEnd + 1;
1786 : }
1787 :
1788 : // Cell alignment
1789 0 : nStart = 0;
1790 0 : nEnd = 0;
1791 0 : nLimit = aJustify.Count;
1792 0 : pColData = aJustify.pData;
1793 0 : for( i = 0 ; i < nLimit ; i++, pColData++ )
1794 : {
1795 0 : nEnd = static_cast<SCROW>(pColData->Row);
1796 0 : nValue1 = pColData->Value;
1797 0 : if ((nStart <= nEnd) && (nValue1))
1798 : {
1799 0 : ScPatternAttr aScPattern(pDoc->GetPool());
1800 0 : sal_uInt16 HorJustify = (nValue1 & 0x000F);
1801 0 : sal_uInt16 VerJustify = (nValue1 & 0x00F0) >> 4;
1802 0 : sal_uInt16 OJustify = (nValue1 & 0x0F00) >> 8;
1803 0 : sal_uInt16 EJustify = (nValue1 & 0xF000) >> 12;
1804 :
1805 0 : switch (HorJustify)
1806 : {
1807 : case hjLeft:
1808 0 : aScPattern.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_LEFT, ATTR_HOR_JUSTIFY));
1809 0 : break;
1810 : case hjCenter:
1811 0 : aScPattern.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY));
1812 0 : break;
1813 : case hjRight:
1814 0 : aScPattern.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_RIGHT, ATTR_HOR_JUSTIFY));
1815 0 : break;
1816 : }
1817 :
1818 0 : switch (VerJustify)
1819 : {
1820 : case vjTop:
1821 0 : aScPattern.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_TOP, ATTR_VER_JUSTIFY));
1822 0 : break;
1823 : case vjCenter:
1824 0 : aScPattern.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_CENTER, ATTR_VER_JUSTIFY));
1825 0 : break;
1826 : case vjBottom:
1827 0 : aScPattern.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_BOTTOM, ATTR_VER_JUSTIFY));
1828 0 : break;
1829 : }
1830 :
1831 0 : if (OJustify & ojWordBreak)
1832 0 : aScPattern.GetItemSet().Put(SfxBoolItem(ATTR_LINEBREAK, true));
1833 0 : if (OJustify & ojBottomTop)
1834 0 : aScPattern.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE,9000));
1835 0 : else if (OJustify & ojTopBottom)
1836 0 : aScPattern.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE,27000));
1837 :
1838 0 : sal_Int16 Margin = std::max((sal_uInt16)20, (sal_uInt16)(EJustify * 20));
1839 0 : if (OJustify & ojBottomTop)
1840 0 : aScPattern.GetItemSet().Put(SvxMarginItem(20, Margin, 20, Margin, ATTR_MARGIN));
1841 : else
1842 0 : aScPattern.GetItemSet().Put(SvxMarginItem(Margin, 20, Margin, 20, ATTR_MARGIN));
1843 0 : pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
1844 : }
1845 0 : nStart = nEnd + 1;
1846 : }
1847 : // Border
1848 0 : bool bEnd = false;
1849 0 : sal_uInt16 nColorIndex = 0;
1850 0 : sal_uInt16 nFrameIndex = 0;
1851 :
1852 : // Special Fix...
1853 0 : const sal_uInt32 nHelpMeStart = 100;
1854 0 : sal_uInt32 nHelpMe = nHelpMeStart;
1855 0 : sal_uInt16 nColorIndexOld = nColorIndex;
1856 0 : sal_uInt16 nFrameIndexOld = nColorIndex;
1857 :
1858 0 : nEnd = 0;
1859 0 : nStart = 0;
1860 0 : while( !bEnd && nHelpMe )
1861 : {
1862 0 : pColData = &aFrame.pData[ nFrameIndex ];
1863 :
1864 0 : sal_uInt16 nValue = pColData->Value;
1865 0 : sal_uInt16 nLeft = 0;
1866 0 : sal_uInt16 nTop = 0;
1867 0 : sal_uInt16 nRight = 0;
1868 0 : sal_uInt16 nBottom = 0;
1869 0 : sal_uInt16 fLeft = ( nValue & 0x000F );
1870 0 : sal_uInt16 fTop = ( nValue & 0x00F0 ) >> 4;
1871 0 : sal_uInt16 fRight = ( nValue & 0x0F00 ) >> 8;
1872 0 : sal_uInt16 fBottom = ( nValue & 0xF000 ) >> 12;
1873 :
1874 0 : if( fLeft > 1 )
1875 0 : nLeft = 50;
1876 0 : else if( fLeft > 0 )
1877 0 : nLeft = 20;
1878 :
1879 0 : if( fTop > 1 )
1880 0 : nTop = 50;
1881 0 : else if( fTop > 0 )
1882 0 : nTop = 20;
1883 :
1884 0 : if( fRight > 1 )
1885 0 : nRight = 50;
1886 0 : else if( fRight > 0 )
1887 0 : nRight = 20;
1888 :
1889 0 : if( fBottom > 1 )
1890 0 : nBottom = 50;
1891 0 : else if( fBottom > 0 )
1892 0 : nBottom = 20;
1893 :
1894 0 : Color ColorLeft( COL_BLACK );
1895 0 : Color ColorTop( COL_BLACK );
1896 0 : Color ColorRight( COL_BLACK );
1897 0 : Color ColorBottom( COL_BLACK );
1898 0 : sal_uInt16 nFrmColVal = aFrameColor.pData[ nColorIndex ].Value;
1899 0 : SCROW nFrmColRow = static_cast<SCROW>(aFrameColor.pData[ nColorIndex ].Row);
1900 0 : sal_uInt16 cLeft = ( nFrmColVal & 0x000F );
1901 0 : sal_uInt16 cTop = ( nFrmColVal & 0x00F0 ) >> 4;
1902 0 : sal_uInt16 cRight = ( nFrmColVal & 0x0F00 ) >> 8;
1903 0 : sal_uInt16 cBottom = ( nFrmColVal & 0xF000 ) >> 12;
1904 :
1905 0 : lcl_ChangeColor( cLeft, ColorLeft );
1906 0 : lcl_ChangeColor( cTop, ColorTop );
1907 0 : lcl_ChangeColor( cRight, ColorRight );
1908 0 : lcl_ChangeColor( cBottom, ColorBottom );
1909 :
1910 0 : if( static_cast<SCROW>(pColData->Row) < nFrmColRow )
1911 : {
1912 0 : nEnd = static_cast<SCROW>(pColData->Row);
1913 0 : if( nFrameIndex < ( aFrame.Count - 1 ) )
1914 0 : nFrameIndex++;
1915 : }
1916 0 : else if( static_cast<SCROW>(pColData->Row) > nFrmColRow )
1917 : {
1918 0 : nEnd = static_cast<SCROW>(aFrameColor.pData[ nColorIndex ].Row);
1919 0 : if( nColorIndex < ( aFrameColor.Count - 1 ) )
1920 0 : nColorIndex++;
1921 : }
1922 : else
1923 : {
1924 0 : nEnd = nFrmColRow;
1925 0 : if( nFrameIndex < (aFrame.Count - 1 ) )
1926 0 : nFrameIndex++;
1927 0 : if( nColorIndex < ( aFrameColor.Count - 1 ) )
1928 0 : nColorIndex++;
1929 : }
1930 0 : if( ( nStart <= nEnd ) && ( nValue != 0 ) )
1931 : {
1932 0 : ScPatternAttr aScPattern(pDoc->GetPool());
1933 0 : ::editeng::SvxBorderLine aLine;
1934 0 : SvxBoxItem aBox( ATTR_BORDER );
1935 :
1936 0 : aLine.SetWidth( nLeft );
1937 0 : aLine.SetColor( ColorLeft );
1938 0 : aBox.SetLine( &aLine, SvxBoxItemLine::LEFT );
1939 :
1940 0 : aLine.SetWidth( nTop );
1941 0 : aLine.SetColor( ColorTop );
1942 0 : aBox.SetLine( &aLine, SvxBoxItemLine::TOP );
1943 :
1944 0 : aLine.SetWidth( nRight );
1945 0 : aLine.SetColor( ColorRight );
1946 0 : aBox.SetLine( &aLine, SvxBoxItemLine::RIGHT );
1947 :
1948 0 : aLine.SetWidth( nBottom );
1949 0 : aLine.SetColor( ColorBottom );
1950 0 : aBox.SetLine( &aLine, SvxBoxItemLine::BOTTOM );
1951 :
1952 0 : aScPattern.GetItemSet().Put( aBox );
1953 0 : pDoc->ApplyPatternAreaTab( Col, nStart, Col, nEnd, Tab, aScPattern );
1954 : }
1955 0 : nStart = nEnd + 1;
1956 :
1957 0 : bEnd = ( nFrameIndex == ( aFrame.Count - 1 ) ) && ( nColorIndex == ( aFrameColor.Count - 1 ) );
1958 :
1959 0 : if( nColorIndexOld != nColorIndex || nFrameIndexOld != nFrameIndex )
1960 : {
1961 0 : nColorIndexOld = nColorIndex;
1962 0 : nFrameIndexOld = nFrameIndex;
1963 0 : nHelpMe = nHelpMeStart;
1964 : }
1965 : else
1966 0 : nHelpMe--;
1967 :
1968 0 : pColData++;
1969 : }
1970 :
1971 : // TODO: Code up to here works more or less ... from here I've had enough ! (GT)
1972 :
1973 : // Background (Color, Raster)
1974 0 : sal_uInt16 nRasterIndex = 0;
1975 0 : bEnd = false;
1976 0 : nColorIndex = 0;
1977 0 : nEnd = 0;
1978 0 : nStart = 0;
1979 :
1980 : // Special Fix...
1981 0 : nHelpMe = nHelpMeStart;
1982 0 : sal_uInt16 nRasterIndexOld = nRasterIndex;
1983 :
1984 0 : while( !bEnd && nHelpMe )
1985 : {
1986 0 : sal_uInt16 nBColor = ( aColor.pData[ nColorIndex ].Value & 0x00F0 ) >> 4;
1987 0 : sal_uInt16 nRColor = ( aColor.pData[ nColorIndex ].Value & 0x0F00 ) >> 8;
1988 0 : Color aBColor( COL_BLACK );
1989 :
1990 0 : lcl_ChangeColor( nBColor, aBColor );
1991 :
1992 0 : if( nBColor == 0 )
1993 0 : aBColor.SetColor( COL_WHITE );
1994 0 : else if( nBColor == 15 )
1995 0 : aBColor.SetColor( COL_BLACK );
1996 :
1997 0 : Color aRColor( COL_BLACK );
1998 :
1999 0 : lcl_ChangeColor( nRColor, aRColor );
2000 :
2001 0 : ScPatternAttr aScPattern( pDoc->GetPool() );
2002 :
2003 : sal_uInt16 nFact;
2004 0 : bool bSwapCol = false;
2005 0 : bool bSetItem = true;
2006 0 : switch ( aRaster.pData[ nRasterIndex ].Value )
2007 : {
2008 0 : case raNone: nFact = 0xffff; bSwapCol = true; bSetItem = (nBColor > 0); break;
2009 0 : case raGray12: nFact = (0xffff / 100) * 12; break;
2010 0 : case raGray25: nFact = (0xffff / 100) * 25; break;
2011 0 : case raGray50: nFact = (0xffff / 100) * 50; break;
2012 0 : case raGray75: nFact = (0xffff / 100) * 75; break;
2013 0 : default: nFact = 0xffff; bSetItem = (nRColor < 15);
2014 : }
2015 0 : if ( bSetItem )
2016 : {
2017 0 : if( bSwapCol )
2018 0 : aScPattern.GetItemSet().Put( SvxBrushItem( GetMixedColor( aBColor, aRColor, nFact ), ATTR_BACKGROUND ) );
2019 : else
2020 0 : aScPattern.GetItemSet().Put( SvxBrushItem( GetMixedColor( aRColor, aBColor, nFact ), ATTR_BACKGROUND ) );
2021 : }
2022 0 : if( aRaster.pData[ nRasterIndex ].Row < aColor.pData[ nColorIndex ].Row )
2023 : {
2024 0 : nEnd = static_cast<SCROW>(aRaster.pData[ nRasterIndex ].Row);
2025 0 : if( nRasterIndex < ( aRaster.Count - 1 ) )
2026 0 : nRasterIndex++;
2027 : }
2028 0 : else if( aRaster.pData[ nRasterIndex ].Row > aColor.pData[ nColorIndex ].Row )
2029 : {
2030 0 : nEnd = static_cast<SCROW>(aColor.pData[ nColorIndex ].Row);
2031 0 : if( nColorIndex < ( aColor.Count - 1 ) )
2032 0 : nColorIndex++;
2033 : }
2034 : else
2035 : {
2036 0 : nEnd = static_cast<SCROW>(aColor.pData[ nColorIndex ].Row);
2037 0 : if( nRasterIndex < ( aRaster.Count - 1 ) )
2038 0 : nRasterIndex++;
2039 0 : if( nColorIndex < ( aColor.Count - 1 ) )
2040 0 : nColorIndex++;
2041 : }
2042 0 : if( nStart <= nEnd )
2043 0 : pDoc->ApplyPatternAreaTab( Col, nStart, Col, nEnd, Tab, aScPattern );
2044 :
2045 0 : nStart = nEnd + 1;
2046 :
2047 0 : bEnd = ( nRasterIndex == ( aRaster.Count - 1 ) ) && ( nColorIndex == ( aColor.Count - 1 ) );
2048 :
2049 0 : if( nColorIndexOld != nColorIndex || nRasterIndexOld != nRasterIndex )
2050 : {
2051 0 : nColorIndexOld = nColorIndex;
2052 0 : nRasterIndexOld = nRasterIndex;
2053 0 : nHelpMe = nHelpMeStart;
2054 : }
2055 : else
2056 0 : nHelpMe--;
2057 :
2058 0 : nHelpMe--;
2059 0 : }
2060 :
2061 : // Number format
2062 0 : nStart = 0;
2063 0 : nEnd = 0;
2064 0 : nLimit = aValue.Count;
2065 0 : pColData = aValue.pData;
2066 0 : for (i=0; i<nLimit; i++, pColData++)
2067 : {
2068 0 : nEnd = static_cast<SCROW>(pColData->Row);
2069 0 : nValue1 = pColData->Value;
2070 0 : if ((nStart <= nEnd) && (nValue1))
2071 : {
2072 0 : sal_uLong nKey = 0;
2073 0 : sal_uInt16 nFormat = (nValue1 & 0x00FF);
2074 0 : sal_uInt16 nInfo = (nValue1 & 0xFF00) >> 8;
2075 0 : ChangeFormat(nFormat, nInfo, nKey);
2076 0 : ScPatternAttr aScPattern(pDoc->GetPool());
2077 0 : aScPattern.GetItemSet().Put(SfxUInt32Item(ATTR_VALUE_FORMAT, (sal_uInt32)nKey));
2078 0 : pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
2079 : }
2080 0 : nStart = nEnd + 1;
2081 : }
2082 :
2083 : // Cell attributes (protected, hidden...)
2084 0 : nStart = 0;
2085 0 : nEnd = 0;
2086 0 : for (i=0; i<aFlag.Count; i++)
2087 : {
2088 0 : nEnd = static_cast<SCROW>(aFlag.pData[i].Row);
2089 0 : if ((nStart <= nEnd) && (aFlag.pData[i].Value != 0))
2090 : {
2091 0 : bool bProtect = ((aFlag.pData[i].Value & paProtect) == paProtect);
2092 0 : bool bHFormula = ((aFlag.pData[i].Value & paHideFormula) == paHideFormula);
2093 0 : bool bHCell = ((aFlag.pData[i].Value & paHideAll) == paHideAll);
2094 0 : bool bHPrint = ((aFlag.pData[i].Value & paHidePrint) == paHidePrint);
2095 0 : ScPatternAttr aScPattern(pDoc->GetPool());
2096 0 : aScPattern.GetItemSet().Put(ScProtectionAttr(bProtect, bHFormula, bHCell, bHPrint));
2097 0 : pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
2098 : }
2099 0 : nStart = nEnd + 1;
2100 : }
2101 :
2102 : // Cell style
2103 0 : nStart = 0;
2104 0 : nEnd = 0;
2105 0 : ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
2106 0 : for (i=0; i<aPattern.Count; i++)
2107 : {
2108 0 : nEnd = static_cast<SCROW>(aPattern.pData[i].Row);
2109 0 : if ((nStart <= nEnd) && (aPattern.pData[i].Value != 0))
2110 : {
2111 0 : sal_uInt16 nPatternIndex = (aPattern.pData[i].Value & 0x00FF) - 1;
2112 0 : Sc10PatternData* pPattern = pPatternCollection->At(nPatternIndex);
2113 0 : if (pPattern != NULL)
2114 : {
2115 : ScStyleSheet* pStyle = static_cast<ScStyleSheet*>( pStylePool->Find(
2116 0 : SC10TOSTRING( pPattern->Name ), SFX_STYLE_FAMILY_PARA) );
2117 :
2118 0 : if (pStyle != NULL)
2119 0 : pDoc->ApplyStyleAreaTab(Col, nStart, Col, nEnd, Tab, *pStyle);
2120 : }
2121 : }
2122 0 : nStart = nEnd + 1;
2123 : }
2124 0 : }
2125 0 : }
2126 :
2127 0 : void Sc10Import::LoadAttr(Sc10ColAttr& rAttr)
2128 : {
2129 : // rAttr is not reused, otherwise we'd have to delete [] rAttr.pData;
2130 0 : rStream.ReadUInt16(rAttr.Count);
2131 :
2132 0 : const size_t nMaxEntries = rStream.remainingSize() / (sizeof(sal_uInt16) * 2);
2133 0 : if (rAttr.Count > nMaxEntries)
2134 0 : rAttr.Count = nMaxEntries;
2135 :
2136 0 : if (!rAttr.Count)
2137 0 : return;
2138 :
2139 0 : rAttr.pData = new (::std::nothrow) Sc10ColData[rAttr.Count];
2140 0 : if (rAttr.pData == NULL)
2141 : {
2142 0 : nError = errOutOfMemory;
2143 0 : rAttr.Count = 0;
2144 0 : return;
2145 : }
2146 :
2147 0 : for (sal_uInt16 i = 0; i < rAttr.Count; ++i)
2148 : {
2149 0 : rStream.ReadUInt16( rAttr.pData[i].Row );
2150 0 : rStream.ReadUInt16( rAttr.pData[i].Value );
2151 : }
2152 :
2153 0 : nError = rStream.GetError();
2154 : }
2155 :
2156 0 : void Sc10Import::ChangeFormat(sal_uInt16 nFormat, sal_uInt16 nInfo, sal_uLong& nKey)
2157 : {
2158 : // TODO: formats are mapped only for StarCalc 3.0 internal formats
2159 : // more correctly, at times new formats need to be created (Stephan: please check!)
2160 0 : nKey = 0;
2161 0 : switch (nFormat)
2162 : {
2163 : case vfStandard :
2164 0 : if (nInfo > 0)
2165 0 : nKey = 2;
2166 0 : break;
2167 : case vfMoney :
2168 0 : if (nInfo > 0)
2169 0 : nKey = 21;
2170 : else
2171 0 : nKey = 20;
2172 0 : break;
2173 : case vfThousend :
2174 0 : if (nInfo > 0)
2175 0 : nKey = 4;
2176 : else
2177 0 : nKey = 5;
2178 0 : break;
2179 : case vfPercent :
2180 0 : if (nInfo > 0)
2181 0 : nKey = 11;
2182 : else
2183 0 : nKey = 10;
2184 0 : break;
2185 : case vfExponent :
2186 0 : nKey = 60;
2187 0 : break;
2188 : case vfZerro :
2189 : // TODO: no equivalent
2190 0 : break;
2191 : case vfDate :
2192 0 : switch (nInfo)
2193 : {
2194 : case df_NDMY_Long :
2195 0 : nKey = 31;
2196 0 : break;
2197 : case df_DMY_Long :
2198 0 : nKey = 30;
2199 0 : break;
2200 : case df_MY_Long :
2201 0 : nKey = 32;
2202 0 : break;
2203 : case df_NDM_Long :
2204 0 : nKey = 31;
2205 0 : break;
2206 : case df_DM_Long :
2207 0 : nKey = 33;
2208 0 : break;
2209 : case df_M_Long :
2210 0 : nKey = 34;
2211 0 : break;
2212 : case df_NDMY_Short :
2213 0 : nKey = 31;
2214 0 : break;
2215 : case df_DMY_Short :
2216 0 : nKey = 30;
2217 0 : break;
2218 : case df_MY_Short :
2219 0 : nKey = 32;
2220 0 : break;
2221 : case df_NDM_Short :
2222 0 : nKey = 31;
2223 0 : break;
2224 : case df_DM_Short :
2225 0 : nKey = 33;
2226 0 : break;
2227 : case df_M_Short :
2228 0 : nKey = 34;
2229 0 : break;
2230 : case df_Q_Long :
2231 0 : nKey = 35;
2232 0 : break;
2233 : case df_Q_Short :
2234 0 : nKey = 35;
2235 0 : break;
2236 : default :
2237 0 : nKey = 30;
2238 0 : break;
2239 : }
2240 0 : break;
2241 : case vfTime :
2242 0 : switch (nInfo)
2243 : {
2244 : case tf_HMS_Long :
2245 0 : nKey = 41;
2246 0 : break;
2247 : case tf_HM_Long :
2248 0 : nKey = 40;
2249 0 : break;
2250 : case tf_HMS_Short :
2251 0 : nKey = 43;
2252 0 : break;
2253 : case tf_HM_Short :
2254 0 : nKey = 42;
2255 0 : break;
2256 : default :
2257 0 : nKey = 41;
2258 0 : break;
2259 : }
2260 0 : break;
2261 : case vfBoolean :
2262 0 : nKey = 99;
2263 0 : break;
2264 : case vfStandardRed :
2265 0 : if (nInfo > 0)
2266 0 : nKey = 2;
2267 0 : break;
2268 : case vfMoneyRed :
2269 0 : if (nInfo > 0)
2270 0 : nKey = 23;
2271 : else
2272 0 : nKey = 22;
2273 0 : break;
2274 : case vfThousendRed :
2275 0 : if (nInfo > 0)
2276 0 : nKey = 4;
2277 : else
2278 0 : nKey = 5;
2279 0 : break;
2280 : case vfPercentRed :
2281 0 : if (nInfo > 0)
2282 0 : nKey = 11;
2283 : else
2284 0 : nKey = 10;
2285 0 : break;
2286 : case vfExponentRed :
2287 0 : nKey = 60;
2288 0 : break;
2289 : case vfFormula :
2290 0 : break;
2291 : case vfString :
2292 0 : break;
2293 : default :
2294 0 : break;
2295 : }
2296 0 : }
2297 :
2298 0 : void Sc10Import::LoadObjects()
2299 : {
2300 : sal_uInt16 ID;
2301 0 : rStream.ReadUInt16( ID );
2302 0 : if (rStream.IsEof()) return;
2303 0 : if (ID == ObjectID)
2304 : {
2305 : sal_uInt16 nAnz;
2306 0 : rStream.ReadUInt16( nAnz );
2307 : sal_Char Reserved[32];
2308 0 : rStream.Read(Reserved, sizeof(Reserved));
2309 0 : nError = rStream.GetError();
2310 0 : if ((nAnz > 0) && (nError == 0))
2311 : {
2312 : sal_uInt8 ObjectType;
2313 0 : Sc10GraphHeader GraphHeader;
2314 0 : bool IsOleObject = false; // TODO: this is only a bandaid
2315 0 : for (sal_uInt16 i = 0; (i < nAnz) && (nError == 0) && !rStream.IsEof() && !IsOleObject; i++)
2316 : {
2317 0 : rStream.ReadUChar( ObjectType );
2318 0 : lcl_ReadGraphHeader(rStream, GraphHeader);
2319 :
2320 0 : double nPPTX = ScGlobal::nScreenPPTX;
2321 0 : double nPPTY = ScGlobal::nScreenPPTY;
2322 :
2323 0 : long nStartX = 0;
2324 0 : SCCOL nMaxCol = SanitizeCol(GraphHeader.CarretX);
2325 0 : for (SCCOL nX = 0; nX < nMaxCol; ++nX)
2326 0 : nStartX += pDoc->GetColWidth(nX, static_cast<SCTAB>(GraphHeader.CarretZ));
2327 0 : nStartX = (long) ( nStartX * HMM_PER_TWIPS );
2328 0 : nStartX += (long) ( GraphHeader.x / nPPTX * HMM_PER_TWIPS );
2329 0 : long nSizeX = (long) ( GraphHeader.w / nPPTX * HMM_PER_TWIPS );
2330 : long nStartY = pDoc->GetRowHeight( 0,
2331 : SanitizeRow(static_cast<SCsROW>(GraphHeader.CarretY) - 1),
2332 0 : SanitizeTab(static_cast<SCTAB>(GraphHeader.CarretZ)));
2333 0 : nStartY = (long) ( nStartY * HMM_PER_TWIPS );
2334 0 : nStartY += (long) ( GraphHeader.y / nPPTY * HMM_PER_TWIPS );
2335 0 : long nSizeY = (long) ( GraphHeader.h / nPPTY * HMM_PER_TWIPS );
2336 :
2337 0 : switch (ObjectType)
2338 : {
2339 : case otOle :
2340 : // TODO: here we need to do something like OleLoadFromStream
2341 0 : IsOleObject = true;
2342 0 : break;
2343 : case otImage :
2344 : {
2345 : Sc10ImageHeader ImageHeader;
2346 0 : lcl_ReadImageHeaer(rStream, ImageHeader);
2347 :
2348 : // Attention: here come the data (Bitmap oder Metafile)
2349 : // Typ = 1 Device-dependend Bitmap DIB
2350 : // Typ = 2 MetaFile
2351 0 : rStream.SeekRel(ImageHeader.Size);
2352 :
2353 0 : if( ImageHeader.Typ != 1 && ImageHeader.Typ != 2 )
2354 0 : nError = errUnknownFormat;
2355 0 : break;
2356 : }
2357 : case otChart :
2358 : {
2359 : Sc10ChartHeader ChartHeader;
2360 : Sc10ChartSheetData ChartSheetData;
2361 0 : Sc10ChartTypeData* pTypeData = new (::std::nothrow) Sc10ChartTypeData;
2362 0 : if (!pTypeData)
2363 0 : nError = errOutOfMemory;
2364 : else
2365 : {
2366 0 : lcl_ReadChartHeader(rStream, ChartHeader);
2367 :
2368 : // TODO: use old Metafile ??
2369 0 : rStream.SeekRel(ChartHeader.Size);
2370 :
2371 0 : lcl_ReadChartSheetData(rStream, ChartSheetData);
2372 :
2373 0 : lcl_ReadChartTypeData(rStream, *pTypeData);
2374 :
2375 0 : Rectangle aRect( Point(nStartX,nStartY), Size(nSizeX,nSizeY) );
2376 : Sc10InsertObject::InsertChart( pDoc, static_cast<SCTAB>(GraphHeader.CarretZ), aRect,
2377 : static_cast<SCTAB>(GraphHeader.CarretZ),
2378 : ChartSheetData.DataX1, ChartSheetData.DataY1,
2379 0 : ChartSheetData.DataX2, ChartSheetData.DataY2 );
2380 :
2381 0 : delete pTypeData;
2382 : }
2383 : }
2384 0 : break;
2385 : default :
2386 0 : nError = errUnknownFormat;
2387 0 : break;
2388 : }
2389 0 : nError = rStream.GetError();
2390 : }
2391 : }
2392 : }
2393 : else
2394 : {
2395 : OSL_FAIL( "ObjectID" );
2396 0 : nError = errUnknownID;
2397 : }
2398 : }
2399 :
2400 0 : FltError ScFormatFilterPluginImpl::ScImportStarCalc10( SvStream& rStream, ScDocument* pDocument )
2401 : {
2402 0 : rStream.Seek( 0UL );
2403 0 : Sc10Import aImport( rStream, pDocument );
2404 0 : return ( FltError ) aImport.Import();
2405 30 : }
2406 :
2407 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|