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