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