update dev300-m58
[ooovba.git] / sc / source / filter / starcalc / scflt.cxx
bloba456235d6130ced1a635435fa23bc808217596bb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: scflt.cxx,v $
10 * $Revision: 1.25.124.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include "scitems.hxx"
39 #include <svx/eeitem.hxx>
41 #include <svx/algitem.hxx>
42 #include <svx/boxitem.hxx>
43 #include <svx/brshitem.hxx>
44 #include <svx/colritem.hxx>
45 #include <svx/crsditem.hxx>
46 #include <svx/editdata.hxx>
47 #include <svx/editeng.hxx>
48 #include <svx/editobj.hxx>
49 #include <svx/fhgtitem.hxx>
50 #include <svx/fontitem.hxx>
51 #include <svx/lrspitem.hxx>
52 #include <svx/pageitem.hxx>
53 #include <svx/postitem.hxx>
54 #include <svx/sizeitem.hxx>
55 #include <svx/udlnitem.hxx>
56 #include <svx/ulspitem.hxx>
57 #include <svx/wghtitem.hxx>
58 #include <svtools/zforlist.hxx>
59 #include <svtools/PasswordHelper.hxx>
60 #include <stdio.h>
61 #include <math.h>
62 #include <string.h>
64 #include "global.hxx"
65 #include "sc.hrc"
66 #include "attrib.hxx"
67 #include "patattr.hxx"
68 #include "docpool.hxx"
69 #include "document.hxx"
70 #include "collect.hxx"
71 #include "rangenam.hxx"
72 #include "dbcolect.hxx"
73 #include "stlsheet.hxx"
74 #include "stlpool.hxx"
75 #include "filter.hxx"
76 #include "scflt.hxx"
77 #include "cell.hxx"
78 #include "scfobj.hxx"
79 #include "docoptio.hxx"
80 #include "viewopti.hxx"
81 #include "postit.hxx"
82 #include "globstr.hrc"
83 #include "ftools.hxx"
84 #include "tabprotection.hxx"
86 #include "fprogressbar.hxx"
88 using namespace com::sun::star;
90 #define DEFCHARSET RTL_TEXTENCODING_MS_1252
92 #define SC10TOSTRING(p) String(p,DEFCHARSET)
94 const SCCOL SC10MAXCOL = 255; // #i85906# don't try to load more columns than there are in the file
97 void lcl_ReadFileHeader(SvStream& rStream, Sc10FileHeader& rFileHeader)
99 rStream.Read(&rFileHeader.CopyRight, sizeof(rFileHeader.CopyRight));
100 rStream >> rFileHeader.Version;
101 rStream.Read(&rFileHeader.Reserved, sizeof(rFileHeader.Reserved));
105 void lcl_ReadTabProtect(SvStream& rStream, Sc10TableProtect& rProtect)
107 rStream.Read(&rProtect.PassWord, sizeof(rProtect.PassWord));
108 rStream >> rProtect.Flags;
109 rStream >> rProtect.Protect;
113 void lcl_ReadSheetProtect(SvStream& rStream, Sc10SheetProtect& rProtect)
115 rStream.Read(&rProtect.PassWord, sizeof(rProtect.PassWord));
116 rStream >> rProtect.Flags;
117 rStream >> rProtect.Protect;
121 void lcl_ReadRGB(SvStream& rStream, Sc10Color& rColor)
123 rStream >> rColor.Dummy;
124 rStream >> rColor.Blue;
125 rStream >> rColor.Green;
126 rStream >> rColor.Red;
130 void lcl_ReadPalette(SvStream& rStream, Sc10Color* pPalette)
132 for (USHORT i = 0; i < 16; i++)
133 lcl_ReadRGB(rStream, pPalette[i]);
137 void lcl_ReadValueFormat(SvStream& rStream, Sc10ValueFormat& rFormat)
139 rStream >> rFormat.Format;
140 rStream >> rFormat.Info;
144 void lcl_ReadLogFont(SvStream& rStream, Sc10LogFont& rFont)
146 rStream >> rFont.lfHeight;
147 rStream >> rFont.lfWidth;
148 rStream >> rFont.lfEscapement;
149 rStream >> rFont.lfOrientation;
150 rStream >> rFont.lfWeight;
151 rStream >> rFont.lfItalic;
152 rStream >> rFont.lfUnderline;
153 rStream >> rFont.lfStrikeOut;
154 rStream >> rFont.lfCharSet;
155 rStream >> rFont.lfOutPrecision;
156 rStream >> rFont.lfClipPrecision;
157 rStream >> rFont.lfQuality;
158 rStream >> rFont.lfPitchAndFamily;
159 rStream.Read(&rFont.lfFaceName, sizeof(rFont.lfFaceName));
163 void lcl_ReadBlockRect(SvStream& rStream, Sc10BlockRect& rBlock)
165 rStream >> rBlock.x1;
166 rStream >> rBlock.y1;
167 rStream >> rBlock.x2;
168 rStream >> rBlock.y2;
172 void lcl_ReadHeadFootLine(SvStream& rStream, Sc10HeadFootLine& rLine)
174 rStream.Read(&rLine.Title, sizeof(rLine.Title));
175 lcl_ReadLogFont(rStream, rLine.LogFont);
176 rStream >> rLine.HorJustify;
177 rStream >> rLine.VerJustify;
178 rStream >> rLine.Raster;
179 rStream >> rLine.Frame;
180 lcl_ReadRGB(rStream, rLine.TextColor);
181 lcl_ReadRGB(rStream, rLine.BackColor);
182 lcl_ReadRGB(rStream, rLine.RasterColor);
183 rStream >> rLine.FrameColor;
184 rStream >> rLine.Reserved;
188 void lcl_ReadPageFormat(SvStream& rStream, Sc10PageFormat& rFormat)
190 lcl_ReadHeadFootLine(rStream, rFormat.HeadLine);
191 lcl_ReadHeadFootLine(rStream, rFormat.FootLine);
192 rStream >> rFormat.Orientation;
193 rStream >> rFormat.Width;
194 rStream >> rFormat.Height;
195 rStream >> rFormat.NonPrintableX;
196 rStream >> rFormat.NonPrintableY;
197 rStream >> rFormat.Left;
198 rStream >> rFormat.Top;
199 rStream >> rFormat.Right;
200 rStream >> rFormat.Bottom;
201 rStream >> rFormat.Head;
202 rStream >> rFormat.Foot;
203 rStream >> rFormat.HorCenter;
204 rStream >> rFormat.VerCenter;
205 rStream >> rFormat.PrintGrid;
206 rStream >> rFormat.PrintColRow;
207 rStream >> rFormat.PrintNote;
208 rStream >> rFormat.TopBottomDir;
209 rStream.Read(&rFormat.PrintAreaName, sizeof(rFormat.PrintAreaName));
210 lcl_ReadBlockRect(rStream, rFormat.PrintArea);
211 rStream.Read(&rFormat.PrnZoom, sizeof(rFormat.PrnZoom));
212 rStream >> rFormat.FirstPageNo;
213 rStream >> rFormat.RowRepeatStart;
214 rStream >> rFormat.RowRepeatEnd;
215 rStream >> rFormat.ColRepeatStart;
216 rStream >> rFormat.ColRepeatEnd;
217 rStream.Read(&rFormat.Reserved, sizeof(rFormat.Reserved));
221 void lcl_ReadGraphHeader(SvStream& rStream, Sc10GraphHeader& rHeader)
223 rStream >> rHeader.Typ;
224 rStream >> rHeader.CarretX;
225 rStream >> rHeader.CarretY;
226 rStream >> rHeader.CarretZ;
227 rStream >> rHeader.x;
228 rStream >> rHeader.y;
229 rStream >> rHeader.w;
230 rStream >> rHeader.h;
231 rStream >> rHeader.IsRelPos;
232 rStream >> rHeader.DoPrint;
233 rStream >> rHeader.FrameType;
234 rStream >> rHeader.IsTransparent;
235 lcl_ReadRGB(rStream, rHeader.FrameColor);
236 lcl_ReadRGB(rStream, rHeader.BackColor);
237 rStream.Read(&rHeader.Reserved, sizeof(rHeader.Reserved));
241 void lcl_ReadImageHeaer(SvStream& rStream, Sc10ImageHeader& rHeader)
243 rStream.Read(&rHeader.FileName, sizeof(rHeader.FileName));
244 rStream >> rHeader.Typ;
245 rStream >> rHeader.Linked;
246 rStream >> rHeader.x1;
247 rStream >> rHeader.y1;
248 rStream >> rHeader.x2;
249 rStream >> rHeader.y2;
250 rStream >> rHeader.Size;
254 void lcl_ReadChartHeader(SvStream& rStream, Sc10ChartHeader& rHeader)
256 rStream >> rHeader.MM;
257 rStream >> rHeader.xExt;
258 rStream >> rHeader.yExt;
259 rStream >> rHeader.Size;
263 void lcl_ReadChartSheetData(SvStream& rStream, Sc10ChartSheetData& rSheetData)
265 rStream >> rSheetData.HasTitle;
266 rStream >> rSheetData.TitleX;
267 rStream >> rSheetData.TitleY;
268 rStream >> rSheetData.HasSubTitle;
269 rStream >> rSheetData.SubTitleX;
270 rStream >> rSheetData.SubTitleY;
271 rStream >> rSheetData.HasLeftTitle;
272 rStream >> rSheetData.LeftTitleX;
273 rStream >> rSheetData.LeftTitleY;
274 rStream >> rSheetData.HasLegend;
275 rStream >> rSheetData.LegendX1;
276 rStream >> rSheetData.LegendY1;
277 rStream >> rSheetData.LegendX2;
278 rStream >> rSheetData.LegendY2;
279 rStream >> rSheetData.HasLabel;
280 rStream >> rSheetData.LabelX1;
281 rStream >> rSheetData.LabelY1;
282 rStream >> rSheetData.LabelX2;
283 rStream >> rSheetData.LabelY2;
284 rStream >> rSheetData.DataX1;
285 rStream >> rSheetData.DataY1;
286 rStream >> rSheetData.DataX2;
287 rStream >> rSheetData.DataY2;
288 rStream.Read(&rSheetData.Reserved, sizeof(rSheetData.Reserved));
292 void lcl_ReadChartTypeData(SvStream& rStream, Sc10ChartTypeData& rTypeData)
294 rStream >> rTypeData.NumSets;
295 rStream >> rTypeData.NumPoints;
296 rStream >> rTypeData.DrawMode;
297 rStream >> rTypeData.GraphType;
298 rStream >> rTypeData.GraphStyle;
299 rStream.Read(&rTypeData.GraphTitle, sizeof(rTypeData.GraphTitle));
300 rStream.Read(&rTypeData.BottomTitle, sizeof(rTypeData.BottomTitle));
301 USHORT i;
302 for (i = 0; i < 256; i++)
303 rStream >> rTypeData.SymbolData[i];
304 for (i = 0; i < 256; i++)
305 rStream >> rTypeData.ColorData[i];
306 for (i = 0; i < 256; i++)
307 rStream >> rTypeData.ThickLines[i];
308 for (i = 0; i < 256; i++)
309 rStream >> rTypeData.PatternData[i];
310 for (i = 0; i < 256; i++)
311 rStream >> rTypeData.LinePatternData[i];
312 for (i = 0; i < 11; i++)
313 rStream >> rTypeData.NumGraphStyles[i];
314 rStream >> rTypeData.ShowLegend;
315 for (i = 0; i < 256; i++)
316 rStream.Read(&rTypeData.LegendText[i], sizeof(Sc10ChartText));
317 rStream >> rTypeData.ExplodePie;
318 rStream >> rTypeData.FontUse;
319 for (i = 0; i < 5; i++)
320 rStream >> rTypeData.FontFamily[i];
321 for (i = 0; i < 5; i++)
322 rStream >> rTypeData.FontStyle[i];
323 for (i = 0; i < 5; i++)
324 rStream >> rTypeData.FontSize[i];
325 rStream >> rTypeData.GridStyle;
326 rStream >> rTypeData.Labels;
327 rStream >> rTypeData.LabelEvery;
328 for (i = 0; i < 50; i++)
329 rStream.Read(&rTypeData.LabelText[i], sizeof(Sc10ChartText));
330 rStream.Read(&rTypeData.LeftTitle, sizeof(rTypeData.LeftTitle));
331 rStream.Read(&rTypeData.Reserved, sizeof(rTypeData.Reserved));
332 //rStream.Read(&rTypeData, sizeof(rTypeData));
335 double lcl_PascalToDouble(sal_Char* tp6)
337 // #i68483# bah! this was broken forever...
338 // struct
339 // {
340 // sal_uInt8 be ; /* biased exponent */
341 // sal_uInt16 v1 ; /* lower 16 bits of mantissa */
342 // sal_uInt16 v2 ; /* next 16 bits of mantissa */
343 // sal_uInt8 v3:7; /* upper 7 bits of mantissa */
344 // sal_uInt8 s :1; /* sign bit */
345 // } real;
347 // memcpy (&real, tp6, 6);
348 // if (real.be == 0)
349 // return 0.0;
350 // return (((((128 +real.v3) * 65536.0) + real.v2) * 65536.0 + real.v1) *
351 // ldexp ((real.s? -1.0: 1.0), real.be - (129+39)));
353 sal_uInt8* pnUnsigned = reinterpret_cast< sal_uInt8* >( tp6 );
354 // biased exponent
355 sal_uInt8 be = pnUnsigned[ 0 ];
356 // lower 16 bits of mantissa
357 sal_uInt16 v1 = static_cast< sal_uInt16 >( pnUnsigned[ 2 ] * 256 + pnUnsigned[ 1 ] );
358 // next 16 bits of mantissa
359 sal_uInt16 v2 = static_cast< sal_uInt16 >( pnUnsigned[ 4 ] * 256 + pnUnsigned[ 3 ] );
360 // upper 7 bits of mantissa
361 sal_uInt8 v3 = static_cast< sal_uInt8 >( pnUnsigned[ 5 ] & 0x7F );
362 // sign bit
363 bool s = (pnUnsigned[ 5 ] & 0x80) != 0;
365 if (be == 0)
366 return 0.0;
367 return (((((128 + v3) * 65536.0) + v2) * 65536.0 + v1) *
368 ldexp ((s ? -1.0 : 1.0), be - (129+39)));
372 void lcl_ChangeColor( USHORT nIndex, Color& rColor )
374 ColorData aCol;
376 switch( nIndex )
378 case 1: aCol = COL_RED; break;
379 case 2: aCol = COL_GREEN; break;
380 case 3: aCol = COL_BROWN; break;
381 case 4: aCol = COL_BLUE; break;
382 case 5: aCol = COL_MAGENTA; break;
383 case 6: aCol = COL_CYAN; break;
384 case 7: aCol = COL_GRAY; break;
385 case 8: aCol = COL_LIGHTGRAY; break;
386 case 9: aCol = COL_LIGHTRED; break;
387 case 10: aCol = COL_LIGHTGREEN; break;
388 case 11: aCol = COL_YELLOW; break;
389 case 12: aCol = COL_LIGHTBLUE; break;
390 case 13: aCol = COL_LIGHTMAGENTA; break;
391 case 14: aCol = COL_LIGHTCYAN; break;
392 case 15: aCol = COL_WHITE; break;
393 default: aCol = COL_BLACK;
396 rColor.SetColor( aCol );
399 String lcl_MakeOldPageStyleFormatName( USHORT i )
401 String aName = ScGlobal::GetRscString( STR_PAGESTYLE );
402 aName.AppendAscii( " " );
403 aName += String::CreateFromInt32( i + 1 );
405 return aName;
408 //--------------------------------------------
409 // Font
410 //--------------------------------------------
413 Sc10FontData::Sc10FontData(SvStream& rStream)
415 rStream >> Height;
416 rStream >> CharSet;
417 rStream >> PitchAndFamily;
418 USHORT nLen;
419 rStream >> nLen;
420 rStream.Read(FaceName, nLen);
424 Sc10FontCollection::Sc10FontCollection(SvStream& rStream) :
425 ScCollection (4, 4),
426 nError (0)
428 USHORT ID;
429 rStream >> ID;
430 if (ID == FontID)
432 USHORT nAnz;
433 rStream >> nAnz;
434 for (USHORT i=0; (i < nAnz) && (nError == 0); i++)
436 Insert(new Sc10FontData(rStream));
437 nError = rStream.GetError();
440 else
442 DBG_ERROR( "FontID" );
443 nError = errUnknownID;
448 //--------------------------------------------
449 // Benannte-Bereiche
450 //--------------------------------------------
453 Sc10NameData::Sc10NameData(SvStream& rStream)
455 BYTE nLen;
456 rStream >> nLen;
457 rStream.Read(Name, sizeof(Name) - 1);
458 Name[nLen] = 0;
460 rStream >> nLen;
461 rStream.Read(Reference, sizeof(Reference) - 1);
462 Reference[nLen] = 0;
463 rStream.Read(Reserved, sizeof(Reserved));
467 Sc10NameCollection::Sc10NameCollection(SvStream& rStream) :
468 ScCollection (4, 4),
469 nError (0)
471 USHORT ID;
472 rStream >> ID;
473 if (ID == NameID)
475 USHORT nAnz;
476 rStream >> nAnz;
477 for (USHORT i=0; (i < nAnz) && (nError == 0); i++)
479 Insert(new Sc10NameData(rStream));
480 nError = rStream.GetError();
483 else
485 DBG_ERROR( "NameID" );
486 nError = errUnknownID;
490 //--------------------------------------------
491 // Vorlagen
492 //--------------------------------------------
495 Sc10PatternData::Sc10PatternData(SvStream& rStream)
497 rStream.Read(Name, sizeof(Name));
498 //rStream.Read(&ValueFormat, sizeof(ValueFormat));
499 //rStream.Read(&LogFont, sizeof(LogFont));
500 lcl_ReadValueFormat(rStream, ValueFormat);
501 lcl_ReadLogFont(rStream, LogFont);
503 rStream >> Attr;
504 rStream >> Justify;
505 rStream >> Frame;
506 rStream >> Raster;
507 rStream >> nColor;
508 rStream >> FrameColor;
509 rStream >> Flags;
510 rStream >> FormatFlags;
511 rStream.Read(Reserved, sizeof(Reserved));
515 Sc10PatternCollection::Sc10PatternCollection(SvStream& rStream) :
516 ScCollection (4, 4),
517 nError (0)
519 USHORT ID;
520 rStream >> ID;
521 if (ID == PatternID)
523 USHORT nAnz;
524 rStream >> nAnz;
525 for (USHORT i=0; (i < nAnz) && (nError == 0); i++)
527 Insert(new Sc10PatternData(rStream));
528 nError = rStream.GetError();
531 else
533 DBG_ERROR( "PatternID" );
534 nError = errUnknownID;
539 //--------------------------------------------
540 // Datenbank
541 //--------------------------------------------
544 Sc10DataBaseData::Sc10DataBaseData(SvStream& rStream)
546 //rStream.Read(&DataBaseRec, sizeof(DataBaseRec));
547 rStream.Read(&DataBaseRec.Name, sizeof(DataBaseRec.Name));
548 rStream >> DataBaseRec.Tab;
549 lcl_ReadBlockRect(rStream, DataBaseRec.Block);
550 rStream >> DataBaseRec.RowHeader;
551 rStream >> DataBaseRec.SortField0;
552 rStream >> DataBaseRec.SortUpOrder0;
553 rStream >> DataBaseRec.SortField1;
554 rStream >> DataBaseRec.SortUpOrder1;
555 rStream >> DataBaseRec.SortField2;
556 rStream >> DataBaseRec.SortUpOrder2;
557 rStream >> DataBaseRec.IncludeFormat;
559 rStream >> DataBaseRec.QueryField0;
560 rStream >> DataBaseRec.QueryOp0;
561 rStream >> DataBaseRec.QueryByString0;
562 rStream.Read(&DataBaseRec.QueryString0, sizeof(DataBaseRec.QueryString0));
563 DataBaseRec.QueryValue0 = ScfTools::ReadLongDouble(rStream);
565 rStream >> DataBaseRec.QueryConnect1;
566 rStream >> DataBaseRec.QueryField1;
567 rStream >> DataBaseRec.QueryOp1;
568 rStream >> DataBaseRec.QueryByString1;
569 rStream.Read(&DataBaseRec.QueryString1, sizeof(DataBaseRec.QueryString1));
570 DataBaseRec.QueryValue1 = ScfTools::ReadLongDouble(rStream);
572 rStream >> DataBaseRec.QueryConnect2;
573 rStream >> DataBaseRec.QueryField2;
574 rStream >> DataBaseRec.QueryOp2;
575 rStream >> DataBaseRec.QueryByString2;
576 rStream.Read(&DataBaseRec.QueryString2, sizeof(DataBaseRec.QueryString2));
577 DataBaseRec.QueryValue2 = ScfTools::ReadLongDouble(rStream);
581 Sc10DataBaseCollection::Sc10DataBaseCollection(SvStream& rStream) :
582 ScCollection (4, 4),
583 nError (0)
585 USHORT ID;
586 rStream >> ID;
587 if (ID == DataBaseID)
589 rStream.Read(ActName, sizeof(ActName));
590 USHORT nAnz;
591 rStream >> nAnz;
592 for (USHORT i=0; (i < nAnz) && (nError == 0); i++)
594 Insert(new Sc10DataBaseData(rStream));
595 nError = rStream.GetError();
598 else
600 DBG_ERROR( "DataBaseID" );
601 nError = errUnknownID;
606 int Sc10LogFont::operator==( const Sc10LogFont& rData ) const
608 return !strcmp( lfFaceName, rData.lfFaceName )
609 && lfHeight == rData.lfHeight
610 && lfWidth == rData.lfWidth
611 && lfEscapement == rData.lfEscapement
612 && lfOrientation == rData.lfOrientation
613 && lfWeight == rData.lfWeight
614 && lfItalic == rData.lfItalic
615 && lfUnderline == rData.lfUnderline
616 && lfStrikeOut == rData.lfStrikeOut
617 && lfCharSet == rData.lfCharSet
618 && lfOutPrecision == rData.lfOutPrecision
619 && lfClipPrecision == rData.lfClipPrecision
620 && lfQuality == rData.lfQuality
621 && lfPitchAndFamily == rData.lfPitchAndFamily;
625 int Sc10Color::operator==( const Sc10Color& rColor ) const
627 return ((Red == rColor.Red) && (Green == rColor.Green) && (Blue == rColor.Blue));
631 int Sc10HeadFootLine::operator==( const Sc10HeadFootLine& rData ) const
633 return !strcmp(Title, rData.Title)
634 && LogFont == rData.LogFont
635 && HorJustify == rData.HorJustify
636 && VerJustify == rData.VerJustify
637 && Raster == rData.Raster
638 && Frame == rData.Frame
639 && TextColor == rData.TextColor
640 && BackColor == rData.BackColor
641 && RasterColor == rData.RasterColor
642 && FrameColor == rData.FrameColor
643 && Reserved == rData.Reserved;
647 int Sc10PageFormat::operator==( const Sc10PageFormat& rData ) const
649 return !strcmp(PrintAreaName, rData.PrintAreaName)
650 && HeadLine == rData.HeadLine
651 && FootLine == rData.FootLine
652 && Orientation == rData.Orientation
653 && Width == rData.Width
654 && Height == rData.Height
655 && NonPrintableX == rData.NonPrintableX
656 && NonPrintableY == rData.NonPrintableY
657 && Left == rData.Left
658 && Top == rData.Top
659 && Right == rData.Right
660 && Bottom == rData.Bottom
661 && Head == rData.Head
662 && Foot == rData.Foot
663 && HorCenter == rData.HorCenter
664 && VerCenter == rData.VerCenter
665 && PrintGrid == rData.PrintGrid
666 && PrintColRow == rData.PrintColRow
667 && PrintNote == rData.PrintNote
668 && TopBottomDir == rData.TopBottomDir
669 && FirstPageNo == rData.FirstPageNo
670 && RowRepeatStart == rData.RowRepeatStart
671 && RowRepeatEnd == rData.RowRepeatEnd
672 && ColRepeatStart == rData.ColRepeatStart
673 && ColRepeatEnd == rData.ColRepeatEnd
674 && !memcmp( PrnZoom, rData.PrnZoom, sizeof(PrnZoom) )
675 && !memcmp( &PrintArea, &rData.PrintArea, sizeof(PrintArea) );
679 USHORT Sc10PageCollection::InsertFormat( const Sc10PageFormat& rData )
681 for (USHORT i=0; i<nCount; i++)
682 if (At(i)->aPageFormat == rData)
683 return i;
685 Insert( new Sc10PageData(rData) );
687 return nCount-1;
691 static inline UINT8 GetMixedCol( const UINT8 nB, const UINT8 nF, const UINT16 nFak )
693 INT32 nT = nB - nF;
694 nT *= ( INT32 ) nFak;
695 nT /= 0xFFFF;
696 nT += nF;
697 return ( UINT8 ) nT;
699 static inline Color GetMixedColor( const Color& rFore, const Color& rBack, UINT16 nFact )
701 return Color( GetMixedCol( rBack.GetRed(), rFore.GetRed(), nFact ),
702 GetMixedCol( rBack.GetGreen(), rFore.GetGreen(), nFact ),
703 GetMixedCol( rBack.GetBlue(), rFore.GetBlue(), nFact ) );
707 void Sc10PageCollection::PutToDoc( ScDocument* pDoc )
709 ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
710 EditEngine aEditEngine( pDoc->GetEnginePool() );
711 EditTextObject* pEmptyObject = aEditEngine.CreateTextObject();
713 for (USHORT i=0; i<nCount; i++)
715 Sc10PageFormat* pPage = &At(i)->aPageFormat;
717 pPage->Width = (short) ( pPage->Width * ( 72.0 / 72.27 ) + 0.5 );
718 pPage->Height = (short) ( pPage->Height * ( 72.0 / 72.27 ) + 0.5 );
719 pPage->Top = (short) ( pPage->Top * ( 72.0 / 72.27 ) + 0.5 );
720 pPage->Bottom = (short) ( pPage->Bottom * ( 72.0 / 72.27 ) + 0.5 );
721 pPage->Left = (short) ( pPage->Left * ( 72.0 / 72.27 ) + 0.5 );
722 pPage->Right = (short) ( pPage->Right * ( 72.0 / 72.27 ) + 0.5 );
723 pPage->Head = (short) ( pPage->Head * ( 72.0 / 72.27 ) + 0.5 );
724 pPage->Foot = (short) ( pPage->Foot * ( 72.0 / 72.27 ) + 0.5 );
726 String aName = lcl_MakeOldPageStyleFormatName( i );
728 ScStyleSheet* pSheet = (ScStyleSheet*) &pStylePool->Make( aName,
729 SFX_STYLE_FAMILY_PAGE,
730 SFXSTYLEBIT_USERDEF | SCSTYLEBIT_STANDARD );
731 // #i68483# set page style name at sheet...
732 pDoc->SetPageStyle( static_cast< SCTAB >( i ), aName );
734 SfxItemSet* pSet = &pSheet->GetItemSet();
736 for (USHORT nHeadFoot=0; nHeadFoot<2; nHeadFoot++)
738 Sc10HeadFootLine* pHeadFootLine = nHeadFoot ? &pPage->FootLine : &pPage->HeadLine;
740 SfxItemSet aEditAttribs(aEditEngine.GetEmptyItemSet());
741 FontFamily eFam = FAMILY_DONTKNOW;
742 switch (pPage->HeadLine.LogFont.lfPitchAndFamily & 0xF0)
744 case ffDontCare: eFam = FAMILY_DONTKNOW; break;
745 case ffRoman: eFam = FAMILY_ROMAN; break;
746 case ffSwiss: eFam = FAMILY_SWISS; break;
747 case ffModern: eFam = FAMILY_MODERN; break;
748 case ffScript: eFam = FAMILY_SCRIPT; break;
749 case ffDecorative: eFam = FAMILY_DECORATIVE; break;
750 default: eFam = FAMILY_DONTKNOW; break;
752 aEditAttribs.Put( SvxFontItem(
753 eFam,
754 SC10TOSTRING( pHeadFootLine->LogFont.lfFaceName ), EMPTY_STRING,
755 PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, EE_CHAR_FONTINFO ),
756 EE_CHAR_FONTINFO );
757 aEditAttribs.Put( SvxFontHeightItem( Abs( pHeadFootLine->LogFont.lfHeight ), 100, EE_CHAR_FONTHEIGHT ),
758 EE_CHAR_FONTHEIGHT);
760 Sc10Color nColor = pHeadFootLine->TextColor;
761 Color TextColor( nColor.Red, nColor.Green, nColor.Blue );
762 aEditAttribs.Put(SvxColorItem(TextColor, EE_CHAR_COLOR), EE_CHAR_COLOR);
763 // FontAttr
764 if (pHeadFootLine->LogFont.lfWeight != fwNormal)
765 aEditAttribs.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT), EE_CHAR_WEIGHT);
766 if (pHeadFootLine->LogFont.lfItalic != 0)
767 aEditAttribs.Put(SvxPostureItem(ITALIC_NORMAL, EE_CHAR_ITALIC), EE_CHAR_ITALIC);
768 if (pHeadFootLine->LogFont.lfUnderline != 0)
769 aEditAttribs.Put(SvxUnderlineItem(UNDERLINE_SINGLE, EE_CHAR_UNDERLINE), EE_CHAR_UNDERLINE);
770 if (pHeadFootLine->LogFont.lfStrikeOut != 0)
771 aEditAttribs.Put(SvxCrossedOutItem(STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT), EE_CHAR_STRIKEOUT);
772 String aText( pHeadFootLine->Title, DEFCHARSET );
773 aEditEngine.SetText( aText );
774 aEditEngine.QuickSetAttribs( aEditAttribs, ESelection( 0, 0, 0, aText.Len() ) );
776 EditTextObject* pObject = aEditEngine.CreateTextObject();
777 ScPageHFItem aHeaderItem(nHeadFoot ? ATTR_PAGE_FOOTERRIGHT : ATTR_PAGE_HEADERRIGHT);
778 switch (pHeadFootLine->HorJustify)
780 case hjCenter:
781 aHeaderItem.SetLeftArea(*pEmptyObject);
782 aHeaderItem.SetCenterArea(*pObject);
783 aHeaderItem.SetRightArea(*pEmptyObject);
784 break;
785 case hjRight:
786 aHeaderItem.SetLeftArea(*pEmptyObject);
787 aHeaderItem.SetCenterArea(*pEmptyObject);
788 aHeaderItem.SetRightArea(*pObject);
789 break;
790 default:
791 aHeaderItem.SetLeftArea(*pObject);
792 aHeaderItem.SetCenterArea(*pEmptyObject);
793 aHeaderItem.SetRightArea(*pEmptyObject);
794 break;
796 delete pObject;
797 pSet->Put( aHeaderItem );
799 SfxItemSet aSetItemItemSet( *pDoc->GetPool(),
800 ATTR_BACKGROUND, ATTR_BACKGROUND,
801 ATTR_BORDER, ATTR_SHADOW,
802 ATTR_PAGE_SIZE, ATTR_PAGE_SIZE,
803 ATTR_LRSPACE, ATTR_ULSPACE,
804 ATTR_PAGE_ON, ATTR_PAGE_SHARED,
805 0 );
806 nColor = pHeadFootLine->BackColor;
807 Color aBColor( nColor.Red, nColor.Green, nColor.Blue );
808 nColor = pHeadFootLine->RasterColor;
809 Color aRColor( nColor.Red, nColor.Green, nColor.Blue );
811 UINT16 nFact;
812 BOOL bSwapCol = FALSE;
813 switch (pHeadFootLine->Raster)
815 case raNone: nFact = 0xffff; bSwapCol = TRUE; break;
816 case raGray12: nFact = (0xffff / 100) * 12; break;
817 case raGray25: nFact = (0xffff / 100) * 25; break;
818 case raGray50: nFact = (0xffff / 100) * 50; break;
819 case raGray75: nFact = (0xffff / 100) * 75; break;
820 default: nFact = 0xffff;
822 if( bSwapCol )
823 aSetItemItemSet.Put( SvxBrushItem( GetMixedColor( aBColor, aRColor, nFact ), ATTR_BACKGROUND ) );
824 else
825 aSetItemItemSet.Put( SvxBrushItem( GetMixedColor( aRColor, aBColor, nFact ), ATTR_BACKGROUND ) );
827 if (pHeadFootLine->Frame != 0)
829 USHORT nLeft = 0;
830 USHORT nTop = 0;
831 USHORT nRight = 0;
832 USHORT nBottom = 0;
833 USHORT fLeft = (pHeadFootLine->Frame & 0x000F);
834 USHORT fTop = (pHeadFootLine->Frame & 0x00F0) / 0x0010;
835 USHORT fRight = (pHeadFootLine->Frame & 0x0F00) / 0x0100;
836 USHORT fBottom = (pHeadFootLine->Frame & 0xF000) / 0x1000;
837 if (fLeft > 1)
838 nLeft = 50;
839 else if (fLeft > 0)
840 nLeft = 20;
841 if (fTop > 1)
842 nTop = 50;
843 else if (fTop > 0)
844 nTop = 20;
845 if (fRight > 1)
846 nRight = 50;
847 else if (fRight > 0)
848 nRight = 20;
849 if (fBottom > 1)
850 nBottom = 50;
851 else if (fBottom > 0)
852 nBottom = 20;
853 Color ColorLeft(COL_BLACK);
854 Color ColorTop(COL_BLACK);
855 Color ColorRight(COL_BLACK);
856 Color ColorBottom(COL_BLACK);
857 USHORT cLeft = (pHeadFootLine->FrameColor & 0x000F);
858 USHORT cTop = (pHeadFootLine->FrameColor & 0x00F0) >> 4;
859 USHORT cRight = (pHeadFootLine->FrameColor & 0x0F00) >> 8;
860 USHORT cBottom = (pHeadFootLine->FrameColor & 0xF000) >> 12;
861 lcl_ChangeColor(cLeft, ColorLeft);
862 lcl_ChangeColor(cTop, ColorTop);
863 lcl_ChangeColor(cRight, ColorRight);
864 lcl_ChangeColor(cBottom, ColorBottom);
865 SvxBorderLine aLine;
866 SvxBoxItem aBox( ATTR_BORDER );
867 aLine.SetOutWidth(nLeft);
868 aLine.SetColor(ColorLeft);
869 aBox.SetLine(&aLine, BOX_LINE_LEFT);
870 aLine.SetOutWidth(nTop);
871 aLine.SetColor(ColorTop);
872 aBox.SetLine(&aLine, BOX_LINE_TOP);
873 aLine.SetOutWidth(nRight);
874 aLine.SetColor(ColorRight);
875 aBox.SetLine(&aLine, BOX_LINE_RIGHT);
876 aLine.SetOutWidth(nBottom);
877 aLine.SetColor(ColorBottom);
878 aBox.SetLine(&aLine, BOX_LINE_BOTTOM);
880 aSetItemItemSet.Put(aBox);
883 pSet->Put( SvxULSpaceItem( 0, 0, ATTR_ULSPACE ) );
885 if (nHeadFoot==0)
886 aSetItemItemSet.Put( SvxSizeItem( ATTR_PAGE_SIZE, Size( 0, pPage->Top - pPage->Head ) ) );
887 else
888 aSetItemItemSet.Put( SvxSizeItem( ATTR_PAGE_SIZE, Size( 0, pPage->Bottom - pPage->Foot ) ) );
890 aSetItemItemSet.Put(SfxBoolItem( ATTR_PAGE_ON, TRUE ));
891 aSetItemItemSet.Put(SfxBoolItem( ATTR_PAGE_DYNAMIC, FALSE ));
892 aSetItemItemSet.Put(SfxBoolItem( ATTR_PAGE_SHARED, TRUE ));
894 pSet->Put( SvxSetItem( nHeadFoot ? ATTR_PAGE_FOOTERSET : ATTR_PAGE_HEADERSET,
895 aSetItemItemSet ) );
898 SvxPageItem aPageItem(ATTR_PAGE);
899 aPageItem.SetPageUsage( SVX_PAGE_ALL );
900 aPageItem.SetLandscape( pPage->Orientation != 1 );
901 aPageItem.SetNumType( SVX_ARABIC );
902 pSet->Put(aPageItem);
904 pSet->Put(SvxLRSpaceItem( pPage->Left, pPage->Right, 0,0, ATTR_LRSPACE ));
905 pSet->Put(SvxULSpaceItem( pPage->Top, pPage->Bottom, ATTR_ULSPACE ));
907 pSet->Put(SfxBoolItem( ATTR_PAGE_HORCENTER, pPage->HorCenter ));
908 pSet->Put(SfxBoolItem( ATTR_PAGE_VERCENTER, pPage->VerCenter ));
910 //----------------
911 // Area-Parameter:
912 //----------------
914 ScRange* pRepeatRow = NULL;
915 ScRange* pRepeatCol = NULL;
917 if ( pPage->ColRepeatStart >= 0 )
918 pRepeatCol = new ScRange( static_cast<SCCOL> (pPage->ColRepeatStart), 0, 0 );
919 if ( pPage->RowRepeatStart >= 0 )
920 pRepeatRow = new ScRange( 0, static_cast<SCROW> (pPage->RowRepeatStart), 0 );
923 if ( pRepeatRow || pRepeatCol )
926 // an allen Tabellen setzen
928 for ( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab )
930 pDoc->SetRepeatColRange( nTab, pRepeatCol );
931 pDoc->SetRepeatRowRange( nTab, pRepeatRow );
935 delete pRepeatRow;
936 delete pRepeatCol;
939 //-----------------
940 // Table-Parameter:
941 //-----------------
942 pSet->Put( SfxBoolItem( ATTR_PAGE_NOTES, pPage->PrintNote ) );
943 pSet->Put( SfxBoolItem( ATTR_PAGE_GRID, pPage->PrintGrid ) );
944 pSet->Put( SfxBoolItem( ATTR_PAGE_HEADERS, pPage->PrintColRow ) );
945 pSet->Put( SfxBoolItem( ATTR_PAGE_TOPDOWN, pPage->TopBottomDir ) );
946 pSet->Put( ScViewObjectModeItem( ATTR_PAGE_CHARTS, VOBJ_MODE_SHOW ) );
947 pSet->Put( ScViewObjectModeItem( ATTR_PAGE_OBJECTS, VOBJ_MODE_SHOW ) );
948 pSet->Put( ScViewObjectModeItem( ATTR_PAGE_DRAWINGS, VOBJ_MODE_SHOW ) );
949 pSet->Put( SfxUInt16Item( ATTR_PAGE_SCALE,
950 (UINT16)( lcl_PascalToDouble( pPage->PrnZoom ) * 100 ) ) );
951 pSet->Put( SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO, 1 ) );
953 pSet->Put( SvxSizeItem( ATTR_PAGE_SIZE, Size( pPage->Width, pPage->Height ) ) );
956 delete pEmptyObject;
960 ScDataObject* Sc10PageData::Clone() const
962 return new Sc10PageData(aPageFormat);
966 //--------------------------------------------
967 // Import
968 //--------------------------------------------
971 Sc10Import::Sc10Import(SvStream& rStr, ScDocument* pDocument ) :
972 rStream (rStr),
973 pDoc (pDocument),
974 pFontCollection (NULL),
975 pNameCollection (NULL),
976 pPatternCollection (NULL),
977 pDataBaseCollection (NULL),
978 nError (0),
979 nShowTab (0)
981 pPrgrsBar = NULL;
985 Sc10Import::~Sc10Import()
987 pDoc->CalcAfterLoad();
988 pDoc->UpdateAllCharts();
990 delete pFontCollection;
991 delete pNameCollection;
992 delete pPatternCollection;
993 delete pDataBaseCollection;
995 DBG_ASSERT( pPrgrsBar == NULL,
996 "*Sc10Import::Sc10Import(): Progressbar lebt noch!?" );
1000 ULONG Sc10Import::Import()
1002 pPrgrsBar = new ScfStreamProgressBar( rStream, pDoc->GetDocumentShell() );
1004 ScDocOptions aOpt = pDoc->GetDocOptions();
1005 aOpt.SetDate( 1, 1, 1900 );
1006 aOpt.SetYear2000( 18 + 1901 ); // ab SO51 src513e vierstellig
1007 pDoc->SetDocOptions( aOpt );
1008 pDoc->GetFormatTable()->ChangeNullDate( 1, 1, 1900 );
1010 LoadFileHeader(); pPrgrsBar->Progress();
1011 if (!nError) { LoadFileInfo(); pPrgrsBar->Progress(); }
1012 if (!nError) { LoadEditStateInfo(); pPrgrsBar->Progress(); }
1013 if (!nError) { LoadProtect(); pPrgrsBar->Progress(); }
1014 if (!nError) { LoadViewColRowBar(); pPrgrsBar->Progress(); }
1015 if (!nError) { LoadScrZoom(); pPrgrsBar->Progress(); }
1016 if (!nError) { LoadPalette(); pPrgrsBar->Progress(); }
1017 if (!nError) { LoadFontCollection(); pPrgrsBar->Progress(); }
1018 if (!nError) { LoadNameCollection(); pPrgrsBar->Progress(); }
1019 if (!nError) { LoadPatternCollection(); pPrgrsBar->Progress(); }
1020 if (!nError) { LoadDataBaseCollection(); pPrgrsBar->Progress(); }
1021 if (!nError) { LoadTables(); pPrgrsBar->Progress(); }
1022 if (!nError) { LoadObjects(); pPrgrsBar->Progress(); }
1023 if (!nError) { ImportNameCollection(); pPrgrsBar->Progress(); }
1024 pDoc->SetViewOptions( aSc30ViewOpt );
1026 #ifdef DBG_UTIL
1027 if (nError)
1029 DBG_ERROR( ByteString::CreateFromInt32( nError ).GetBuffer() );
1031 #endif
1033 delete pPrgrsBar;
1034 #ifdef DBG_UTIL
1035 pPrgrsBar = NULL;
1036 #endif
1038 return nError;
1042 void Sc10Import::LoadFileHeader()
1044 Sc10FileHeader FileHeader;
1045 //rStream.Read(&FileHeader, sizeof(FileHeader));
1046 lcl_ReadFileHeader(rStream, FileHeader);
1048 nError = rStream.GetError();
1049 if ( nError == 0 )
1051 sal_Char Sc10CopyRight[32];
1052 strcpy(Sc10CopyRight, "Blaise-Tabelle"); // #100211# - checked
1053 Sc10CopyRight[14] = 10;
1054 Sc10CopyRight[15] = 13;
1055 Sc10CopyRight[16] = 0;
1056 if ((strcmp(FileHeader.CopyRight, Sc10CopyRight) != 0)
1057 || (FileHeader.Version < 101)
1058 || (FileHeader.Version > 102))
1059 nError = errUnknownFormat;
1064 void Sc10Import::LoadFileInfo()
1066 Sc10FileInfo FileInfo;
1067 rStream.Read(&FileInfo, sizeof(FileInfo));
1069 nError = rStream.GetError();
1070 // Achtung Info Uebertragen
1075 void Sc10Import::LoadEditStateInfo()
1077 Sc10EditStateInfo EditStateInfo;
1078 rStream.Read(&EditStateInfo, sizeof(EditStateInfo));
1080 nError = rStream.GetError();
1081 nShowTab = static_cast<SCTAB>(EditStateInfo.DeltaZ);
1082 // Achtung Cursorposition und Offset der Tabelle Uebertragen (soll man das machen??)
1086 void Sc10Import::LoadProtect()
1088 //rStream.Read(&SheetProtect, sizeof(SheetProtect));
1089 lcl_ReadSheetProtect(rStream, SheetProtect);
1090 nError = rStream.GetError();
1092 ScDocProtection aProtection;
1093 aProtection.setProtected(static_cast<bool>(SheetProtect.Protect));
1094 aProtection.setPassword(SC10TOSTRING(SheetProtect.PassWord));
1095 pDoc->SetDocProtection(&aProtection);
1099 void Sc10Import::LoadViewColRowBar()
1101 BYTE ViewColRowBar;
1102 rStream >> ViewColRowBar;
1103 nError = rStream.GetError();
1104 aSc30ViewOpt.SetOption( VOPT_HEADER, (BOOL)ViewColRowBar );
1108 void Sc10Import::LoadScrZoom()
1110 // Achtung Zoom ist leider eine 6Byte TP real Zahl (keine Ahnung wie die Umzusetzen ist)
1111 sal_Char cZoom[6];
1112 rStream.Read(cZoom, sizeof(cZoom));
1113 nError = rStream.GetError();
1117 void Sc10Import::LoadPalette()
1119 //rStream.Read(TextPalette, sizeof(TextPalette));
1120 //rStream.Read(BackPalette, sizeof(BackPalette));
1121 //rStream.Read(RasterPalette, sizeof(RasterPalette));
1122 //rStream.Read(FramePalette, sizeof(FramePalette));
1123 lcl_ReadPalette(rStream, TextPalette);
1124 lcl_ReadPalette(rStream, BackPalette);
1125 lcl_ReadPalette(rStream, RasterPalette);
1126 lcl_ReadPalette(rStream, FramePalette);
1128 nError = rStream.GetError();
1132 void Sc10Import::LoadFontCollection()
1134 pFontCollection = new Sc10FontCollection(rStream);
1138 void Sc10Import::LoadNameCollection()
1140 pNameCollection = new Sc10NameCollection(rStream);
1144 void Sc10Import::ImportNameCollection()
1146 ScRangeName* pRN = pDoc->GetRangeName();
1148 for (USHORT i = 0; i < pNameCollection->GetCount(); i++)
1150 Sc10NameData* pName = pNameCollection->At( i );
1151 pRN->Insert( new ScRangeData( pDoc,
1152 SC10TOSTRING( pName->Name ),
1153 SC10TOSTRING( pName->Reference ) ) );
1158 void Sc10Import::LoadPatternCollection()
1160 pPatternCollection = new Sc10PatternCollection( rStream );
1161 ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
1162 for( USHORT i = 0 ; i < pPatternCollection->GetCount() ; i++ )
1164 Sc10PatternData* pPattern = pPatternCollection->At( i );
1165 String aName( pPattern->Name, DEFCHARSET );
1166 SfxStyleSheetBase* pStyle = pStylePool->Find( aName, SFX_STYLE_FAMILY_PARA );
1167 if( pStyle == NULL )
1168 pStylePool->Make( aName, SFX_STYLE_FAMILY_PARA );
1169 else
1171 pPattern->Name[ 27 ] = 0;
1172 strcat( pPattern->Name, "_Old" ); // #100211# - checked
1173 aName = SC10TOSTRING( pPattern->Name );
1174 pStylePool->Make( aName, SFX_STYLE_FAMILY_PARA );
1176 pStyle = pStylePool->Find( aName, SFX_STYLE_FAMILY_PARA );
1177 if( pStyle != NULL )
1179 SfxItemSet &rItemSet = pStyle->GetItemSet();
1180 // Font
1181 if( ( pPattern->FormatFlags & pfFont ) == pfFont )
1183 FontFamily eFam = FAMILY_DONTKNOW;
1184 switch( pPattern->LogFont.lfPitchAndFamily & 0xF0 )
1186 case ffDontCare : eFam = FAMILY_DONTKNOW; break;
1187 case ffRoman : eFam = FAMILY_ROMAN; break;
1188 case ffSwiss : eFam = FAMILY_SWISS; break;
1189 case ffModern : eFam = FAMILY_MODERN; break;
1190 case ffScript : eFam = FAMILY_SCRIPT; break;
1191 case ffDecorative : eFam = FAMILY_DECORATIVE; break;
1192 default: eFam = FAMILY_DONTKNOW; break;
1194 rItemSet.Put( SvxFontItem( eFam, SC10TOSTRING( pPattern->LogFont.lfFaceName ), EMPTY_STRING,
1195 PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT ) );
1196 rItemSet.Put( SvxFontHeightItem( Abs( pPattern->LogFont.lfHeight ), 100, ATTR_FONT_HEIGHT ) );
1197 Color TextColor( COL_BLACK );
1198 lcl_ChangeColor( ( pPattern->nColor & 0x000F ), TextColor );
1199 rItemSet.Put( SvxColorItem( TextColor, ATTR_FONT_COLOR ) );
1200 // FontAttr
1201 if( pPattern->LogFont.lfWeight != fwNormal )
1202 rItemSet.Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) );
1203 if( pPattern->LogFont.lfItalic != 0 )
1204 rItemSet.Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
1205 if( pPattern->LogFont.lfUnderline != 0 )
1206 rItemSet.Put( SvxUnderlineItem( UNDERLINE_SINGLE, ATTR_FONT_UNDERLINE ) );
1207 if( pPattern->LogFont.lfStrikeOut != 0 )
1208 rItemSet.Put( SvxCrossedOutItem( STRIKEOUT_SINGLE, ATTR_FONT_CROSSEDOUT ) );
1210 // Ausrichtung
1211 if( ( pPattern->FormatFlags & pfJustify ) == pfJustify )
1213 USHORT HorJustify = ( pPattern->Justify & 0x000F );
1214 USHORT VerJustify = ( pPattern->Justify & 0x00F0 ) >> 4;
1215 USHORT OJustify = ( pPattern->Justify & 0x0F00 ) >> 8;
1216 USHORT EJustify = ( pPattern->Justify & 0xF000 ) >> 12;
1217 if( HorJustify != 0 )
1218 switch( HorJustify )
1220 case hjLeft:
1221 rItemSet.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_LEFT, ATTR_HOR_JUSTIFY ) );
1222 break;
1223 case hjCenter:
1224 rItemSet.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY ) );
1225 break;
1226 case hjRight:
1227 rItemSet.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_RIGHT, ATTR_HOR_JUSTIFY ) );
1228 break;
1230 if( VerJustify != 0 )
1231 switch( VerJustify )
1233 case vjTop:
1234 rItemSet.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_TOP, ATTR_VER_JUSTIFY ) );
1235 break;
1236 case vjCenter:
1237 rItemSet.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_CENTER, ATTR_VER_JUSTIFY ) );
1238 break;
1239 case vjBottom:
1240 rItemSet.Put( SvxVerJustifyItem( SVX_VER_JUSTIFY_BOTTOM, ATTR_VER_JUSTIFY ) );
1241 break;
1244 if( ( OJustify & ojWordBreak ) == ojWordBreak )
1245 rItemSet.Put( SfxBoolItem( TRUE ) );
1246 if( ( OJustify & ojBottomTop ) == ojBottomTop )
1247 rItemSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
1248 else if( ( OJustify & ojTopBottom ) == ojTopBottom )
1249 rItemSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
1251 INT16 Margin = Max( ( USHORT ) 20, ( USHORT ) ( EJustify * 20 ) );
1252 // if( ( ( OJustify & ojBottomTop ) == ojBottomTop ) ||
1253 // ( ( OJustify & ojBottomTop ) == ojBottomTop ) )
1254 // vielleicht so?
1255 if( ( ( OJustify & ojBottomTop ) == ojBottomTop ) )
1256 rItemSet.Put( SvxMarginItem( 20, Margin, 20, Margin, ATTR_MARGIN ) );
1257 else
1258 rItemSet.Put( SvxMarginItem( Margin, 20, Margin, 20, ATTR_MARGIN ) );
1261 // Frame
1262 if( ( pPattern->FormatFlags & pfFrame ) == pfFrame )
1264 if( pPattern->Frame != 0 )
1266 USHORT nLeft = 0;
1267 USHORT nTop = 0;
1268 USHORT nRight = 0;
1269 USHORT nBottom = 0;
1270 USHORT fLeft = ( pPattern->Frame & 0x000F );
1271 USHORT fTop = ( pPattern->Frame & 0x00F0 ) / 0x0010;
1272 USHORT fRight = ( pPattern->Frame & 0x0F00 ) / 0x0100;
1273 USHORT fBottom = ( pPattern->Frame & 0xF000 ) / 0x1000;
1275 if( fLeft > 1 )
1276 nLeft = 50;
1277 else if( fLeft > 0 )
1278 nLeft = 20;
1280 if( fTop > 1 )
1281 nTop = 50;
1282 else if( fTop > 0 )
1283 nTop = 20;
1285 if( fRight > 1 )
1286 nRight = 50;
1287 else if( fRight > 0 )
1288 nRight = 20;
1290 if( fBottom > 1 )
1291 nBottom = 50;
1292 else if( fBottom > 0 )
1293 nBottom = 20;
1295 Color ColorLeft( COL_BLACK );
1296 Color ColorTop( COL_BLACK );
1297 Color ColorRight( COL_BLACK );
1298 Color ColorBottom( COL_BLACK );
1300 USHORT cLeft = ( pPattern->FrameColor & 0x000F );
1301 USHORT cTop = ( pPattern->FrameColor & 0x00F0 ) >> 4;
1302 USHORT cRight = ( pPattern->FrameColor & 0x0F00 ) >> 8;
1303 USHORT cBottom = ( pPattern->FrameColor & 0xF000 ) >> 12;
1305 lcl_ChangeColor( cLeft, ColorLeft );
1306 lcl_ChangeColor( cTop, ColorTop );
1307 lcl_ChangeColor( cRight, ColorRight );
1308 lcl_ChangeColor( cBottom, ColorBottom );
1310 SvxBorderLine aLine;
1311 SvxBoxItem aBox( ATTR_BORDER );
1313 aLine.SetOutWidth( nLeft );
1314 aLine.SetColor( ColorLeft );
1315 aBox.SetLine( &aLine, BOX_LINE_LEFT );
1316 aLine.SetOutWidth( nTop );
1317 aLine.SetColor( ColorTop );
1318 aBox.SetLine( &aLine, BOX_LINE_TOP );
1319 aLine.SetOutWidth( nRight );
1320 aLine.SetColor( ColorRight );
1321 aBox.SetLine( &aLine, BOX_LINE_RIGHT );
1322 aLine.SetOutWidth( nBottom );
1323 aLine.SetColor( ColorBottom );
1324 aBox.SetLine( &aLine, BOX_LINE_BOTTOM );
1325 rItemSet.Put( aBox );
1328 // Raster
1329 if( ( pPattern->FormatFlags & pfRaster ) == pfRaster )
1331 if( pPattern->Raster != 0 )
1333 USHORT nBColor = ( pPattern->nColor & 0x00F0 ) >> 4;
1334 USHORT nRColor = ( pPattern->nColor & 0x0F00 ) >> 8;
1335 Color aBColor( COL_BLACK );
1337 lcl_ChangeColor( nBColor, aBColor );
1339 if( nBColor == 0 )
1340 aBColor.SetColor( COL_WHITE );
1341 else if( nBColor == 15 )
1342 aBColor.SetColor( COL_BLACK );
1344 Color aRColor( COL_BLACK );
1345 lcl_ChangeColor( nRColor, aRColor );
1346 UINT16 nFact;
1347 BOOL bSwapCol = FALSE;
1348 BOOL bSetItem = TRUE;
1349 switch (pPattern->Raster)
1351 case raNone: nFact = 0xffff; bSwapCol = TRUE; bSetItem = (nBColor > 0); break;
1352 case raGray12: nFact = (0xffff / 100) * 12; break;
1353 case raGray25: nFact = (0xffff / 100) * 25; break;
1354 case raGray50: nFact = (0xffff / 100) * 50; break;
1355 case raGray75: nFact = (0xffff / 100) * 75; break;
1356 default: nFact = 0xffff; bSetItem = (nRColor < 15);
1358 if ( bSetItem )
1360 if( bSwapCol )
1361 rItemSet.Put( SvxBrushItem( GetMixedColor( aBColor, aRColor, nFact ), ATTR_BACKGROUND ) );
1362 else
1363 rItemSet.Put( SvxBrushItem( GetMixedColor( aRColor, aBColor, nFact ), ATTR_BACKGROUND ) );
1367 // ZahlenFormate
1368 if( ( pPattern->ValueFormat.Format != 0 ) &&
1369 ( ( pPattern->FormatFlags & pfValue ) == pfValue ) )
1371 ULONG nKey = 0;
1372 ChangeFormat( pPattern->ValueFormat.Format, pPattern->ValueFormat.Info, nKey );
1373 rItemSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, ( UINT32 ) nKey ) );
1376 // Zellattribute (Schutz, Versteckt...)
1377 if( ( pPattern->Flags != 0 ) &&
1378 ( ( pPattern->FormatFlags & pfProtection ) == pfProtection ) )
1380 BOOL bProtect = ( ( pPattern->Flags & paProtect ) == paProtect );
1381 BOOL bHFormula = ( ( pPattern->Flags & paHideFormula ) == paHideFormula );
1382 BOOL bHCell = ( ( pPattern->Flags & paHideAll ) == paHideAll );
1383 BOOL bHPrint = ( ( pPattern->Flags & paHidePrint ) == paHidePrint );
1384 rItemSet.Put( ScProtectionAttr( bProtect, bHFormula, bHCell, bHPrint ) );
1386 } // if Style != 0
1387 } // for (i = 0; i < GetCount()
1391 void Sc10Import::LoadDataBaseCollection()
1393 pDataBaseCollection = new Sc10DataBaseCollection(rStream);
1394 for( USHORT i = 0 ; i < pDataBaseCollection->GetCount() ; i++ )
1396 Sc10DataBaseData* pOldData = pDataBaseCollection->At(i);
1397 ScDBData* pNewData = new ScDBData( SC10TOSTRING( pOldData->DataBaseRec.Name ),
1398 ( SCTAB ) pOldData->DataBaseRec.Tab,
1399 ( SCCOL ) pOldData->DataBaseRec.Block.x1,
1400 ( SCROW ) pOldData->DataBaseRec.Block.y1,
1401 ( SCCOL ) pOldData->DataBaseRec.Block.x2,
1402 ( SCROW ) pOldData->DataBaseRec.Block.y2,
1403 TRUE,
1404 ( BOOL) pOldData->DataBaseRec.RowHeader );
1405 pDoc->GetDBCollection()->Insert( pNewData );
1410 void Sc10Import::LoadTables()
1412 Sc10PageCollection aPageCollection;
1414 INT16 nTabCount;
1415 rStream >> nTabCount;
1416 for (INT16 Tab = 0; (Tab < nTabCount) && (nError == 0); Tab++)
1418 Sc10PageFormat PageFormat;
1419 INT16 DataBaseIndex;
1420 Sc10TableProtect TabProtect;
1421 INT16 TabNo;
1422 sal_Char TabName[128];
1423 USHORT Display;
1424 BYTE Visible;
1425 USHORT ID;
1426 USHORT DataCount;
1427 USHORT DataStart;
1428 USHORT DataEnd;
1429 USHORT DataValue;
1430 USHORT Count;
1431 USHORT i;
1432 String aStr; // Universal-Konvertierungs-String
1435 //rStream.Read(&PageFormat, sizeof(PageFormat));
1436 lcl_ReadPageFormat(rStream, PageFormat);
1438 USHORT nAt = aPageCollection.InsertFormat(PageFormat);
1439 String aPageName = lcl_MakeOldPageStyleFormatName( nAt );
1441 pPrgrsBar->Progress();
1443 rStream >> DataBaseIndex;
1445 //rStream.Read(&TabProtect, sizeof(TabProtect));
1446 lcl_ReadTabProtect(rStream, TabProtect);
1448 ScTableProtection aProtection;
1449 aProtection.setProtected(static_cast<bool>(TabProtect.Protect));
1450 aProtection.setPassword(SC10TOSTRING(TabProtect.PassWord));
1451 pDoc->SetTabProtection(static_cast<SCTAB>(Tab), &aProtection);
1453 rStream >> TabNo;
1455 BYTE nLen;
1456 rStream >> nLen;
1457 rStream.Read(TabName, sizeof(TabName) - 1);
1458 TabName[nLen] = 0;
1460 //----------------------------------------------------------
1461 rStream >> Display;
1463 if ( Tab == (INT16)nShowTab )
1465 ScVObjMode eObjMode = VOBJ_MODE_SHOW;
1467 aSc30ViewOpt.SetOption( VOPT_FORMULAS, IS_SET(dfFormula,Display) );
1468 aSc30ViewOpt.SetOption( VOPT_NULLVALS, IS_SET(dfZerro,Display) );
1469 aSc30ViewOpt.SetOption( VOPT_SYNTAX, IS_SET(dfSyntax,Display) );
1470 aSc30ViewOpt.SetOption( VOPT_NOTES, IS_SET(dfNoteMark,Display) );
1471 aSc30ViewOpt.SetOption( VOPT_VSCROLL, TRUE );
1472 aSc30ViewOpt.SetOption( VOPT_HSCROLL, TRUE );
1473 aSc30ViewOpt.SetOption( VOPT_TABCONTROLS, TRUE );
1474 aSc30ViewOpt.SetOption( VOPT_OUTLINER, TRUE );
1475 aSc30ViewOpt.SetOption( VOPT_GRID, IS_SET(dfGrid,Display) );
1477 // VOPT_HEADER wird in LoadViewColRowBar() gesetzt
1479 if ( IS_SET(dfObjectAll,Display) ) // Objekte anzeigen
1480 eObjMode = VOBJ_MODE_SHOW;
1481 else if ( IS_SET(dfObjectFrame,Display) ) // Objekte als Platzhalter
1482 eObjMode = VOBJ_MODE_SHOW;
1483 else if ( IS_SET(dfObjectNone,Display) ) // Objekte nicht anzeigen
1484 eObjMode = VOBJ_MODE_HIDE;
1486 aSc30ViewOpt.SetObjMode( VOBJ_TYPE_OLE, eObjMode );
1487 aSc30ViewOpt.SetObjMode( VOBJ_TYPE_CHART, eObjMode );
1488 aSc30ViewOpt.SetObjMode( VOBJ_TYPE_DRAW, eObjMode );
1491 /* wofuer wird das benoetigt? Da in SC 1.0 die Anzeigeflags pro Tabelle gelten und nicht pro View
1492 Dieses Flag in die ViewOptions eintragen bei Gelegenheit, Sollte der Stephan Olk machen
1493 USHORT nDisplayMask = 0xFFFF;
1494 USHORT nDisplayValue = 0;
1495 if (Tab == 0)
1496 nDisplayValue = Display;
1497 else
1499 USHORT nDiff = Display ^ nDisplayValue;
1500 nDisplayMask &= ~nDiff;
1503 //--------------------------------------------------------------------
1504 rStream >> Visible;
1506 nError = rStream.GetError();
1507 if (nError != 0) return;
1509 if (TabNo == 0)
1510 pDoc->RenameTab(static_cast<SCTAB> (TabNo), SC10TOSTRING( TabName ), FALSE);
1511 else
1512 pDoc->InsertTab(SC_TAB_APPEND, SC10TOSTRING( TabName ) );
1514 pDoc->SetPageStyle( static_cast<SCTAB>(Tab), aPageName );
1516 if (Visible == 0) pDoc->SetVisible(static_cast<SCTAB> (TabNo), FALSE);
1518 // ColWidth
1519 rStream >> ID;
1520 if (ID != ColWidthID)
1522 DBG_ERROR( "ColWidthID" );
1523 nError = errUnknownID;
1524 return;
1526 rStream >> DataCount;
1527 DataStart = 0;
1528 for (i=0; i < DataCount; i++)
1530 rStream >> DataEnd;
1531 rStream >> DataValue;
1532 for (SCCOL j = static_cast<SCCOL>(DataStart); j <= static_cast<SCCOL>(DataEnd); j++) pDoc->SetColWidth(j, static_cast<SCTAB> (TabNo), DataValue);
1533 DataStart = DataEnd + 1;
1535 pPrgrsBar->Progress();
1537 // ColAttr
1538 rStream >> ID;
1539 if (ID != ColAttrID)
1541 DBG_ERROR( "ColAttrID" );
1542 nError = errUnknownID;
1543 return;
1546 rStream >> DataCount;
1547 DataStart = 0;
1548 for (i=0; i < DataCount; i++)
1550 rStream >> DataEnd;
1551 rStream >> DataValue;
1552 if (DataValue != 0)
1554 bool bPageBreak = ((DataValue & crfSoftBreak) == crfSoftBreak);
1555 bool bManualBreak = ((DataValue & crfHardBreak) == crfHardBreak);
1556 bool bHidden = ((DataValue & crfHidden) == crfHidden);
1557 for (SCCOL k = static_cast<SCCOL>(DataStart); k <= static_cast<SCCOL>(DataEnd); k++)
1559 pDoc->SetColHidden(k, k, static_cast<SCTAB>(TabNo), bHidden);
1560 pDoc->SetColBreak(k, static_cast<SCTAB> (TabNo), bPageBreak, bManualBreak);
1563 DataStart = DataEnd + 1;
1565 pPrgrsBar->Progress();
1567 // RowHeight
1568 rStream >> ID;
1569 if (ID != RowHeightID)
1571 DBG_ERROR( "RowHeightID" );
1572 nError = errUnknownID;
1573 return;
1576 rStream >> DataCount;
1577 DataStart = 0;
1578 for (i=0; i < DataCount; i++)
1580 rStream >> DataEnd;
1581 rStream >> DataValue;
1582 pDoc->SetRowHeightRange(static_cast<SCROW> (DataStart), static_cast<SCROW> (DataEnd), static_cast<SCTAB> (TabNo), DataValue);
1583 DataStart = DataEnd + 1;
1585 pPrgrsBar->Progress();
1587 // RowAttr
1588 rStream >> ID;
1589 if (ID != RowAttrID)
1591 DBG_ERROR( "RowAttrID" );
1592 nError = errUnknownID;
1593 return;
1596 rStream >> DataCount;
1597 DataStart = 0;
1598 for (i=0; i < DataCount; i++)
1600 rStream >> DataEnd;
1601 rStream >> DataValue;
1602 if (DataValue != 0)
1604 bool bPageBreak = ((DataValue & crfSoftBreak) == crfSoftBreak);
1605 bool bManualBreak = ((DataValue & crfHardBreak) == crfHardBreak);
1606 bool bHidden = ((DataValue & crfHidden) == crfHidden);
1607 for (SCROW l = static_cast<SCROW>(DataStart); l <= static_cast<SCROW>(DataEnd); l++)
1609 pDoc->SetRowHidden(l, l, static_cast<SCTAB> (TabNo), bHidden);
1610 pDoc->SetRowBreak(l, static_cast<SCTAB> (TabNo), bPageBreak, bManualBreak);
1613 DataStart = DataEnd + 1;
1615 pPrgrsBar->Progress();
1617 // DataTable
1618 rStream >> ID;
1619 if (ID != TableID)
1621 DBG_ERROR( "TableID" );
1622 nError = errUnknownID;
1623 return;
1625 for (SCCOL Col = 0; (Col <= SC10MAXCOL) && (nError == 0); Col++)
1627 rStream >> Count;
1628 nError = rStream.GetError();
1629 if ((Count != 0) && (nError == 0))
1630 LoadCol(Col, static_cast<SCTAB> (TabNo));
1632 DBG_ASSERT( nError == 0, "Stream" );
1634 pPrgrsBar->Progress();
1636 aPageCollection.PutToDoc( pDoc );
1640 void Sc10Import::LoadCol(SCCOL Col, SCTAB Tab)
1642 LoadColAttr(Col, Tab);
1644 USHORT CellCount;
1645 BYTE CellType;
1646 USHORT Row;
1647 rStream >> CellCount;
1648 SCROW nScCount = static_cast< SCROW >( CellCount );
1649 if (nScCount > MAXROW) nError = errUnknownFormat;
1650 for (USHORT i = 0; (i < CellCount) && (nError == 0); i++)
1652 rStream >> CellType;
1653 rStream >> Row;
1654 nError = rStream.GetError();
1655 if (nError == 0)
1657 switch (CellType)
1659 case ctValue :
1661 const SfxPoolItem* pValueFormat = pDoc->GetAttr(Col, static_cast<SCROW> (Row), Tab, ATTR_VALUE_FORMAT);
1662 ULONG nFormat = ((SfxUInt32Item*)pValueFormat)->GetValue();
1663 double Value = ScfTools::ReadLongDouble(rStream);
1664 //rStream.Read(&Value, sizeof(Value));
1666 // Achtung hier ist eine Anpassung Notwendig wenn Ihr das Basisdatum aendert
1667 // In StarCalc 1.0 entspricht 0 dem 01.01.1900
1668 // if ((nFormat >= 30) && (nFormat <= 35))
1669 // Value += 0;
1670 if ((nFormat >= 40) && (nFormat <= 45))
1671 Value /= 86400.0;
1672 pDoc->SetValue(Col, static_cast<SCROW> (Row), Tab, Value);
1673 break;
1675 case ctString :
1677 BYTE Len;
1678 sal_Char s[256];
1679 rStream >> Len;
1680 rStream.Read(s, Len);
1681 s[Len] = 0;
1683 pDoc->SetString( Col, static_cast<SCROW> (Row), Tab, SC10TOSTRING( s ) );
1684 break;
1686 case ctFormula :
1688 /*double Value =*/ ScfTools::ReadLongDouble(rStream);
1689 BYTE Len;
1690 sal_Char s[256];
1691 //rStream.Read(&Value, sizeof(Value));
1692 rStream >> Len;
1693 rStream.Read(&s[1], Len);
1694 s[0] = '=';
1695 s[Len + 1] = 0;
1696 ScFormulaCell* pCell = new ScFormulaCell( pDoc, ScAddress( Col, static_cast<SCROW> (Row), Tab ) );
1697 pCell->SetHybridFormula( SC10TOSTRING( s ),formula::FormulaGrammar::GRAM_NATIVE );
1698 pDoc->PutCell( Col, static_cast<SCROW> (Row), Tab, pCell, (BOOL)TRUE );
1699 break;
1701 case ctNote :
1702 break;
1703 default :
1704 nError = errUnknownFormat;
1705 break;
1707 USHORT NoteLen;
1708 rStream >> NoteLen;
1709 if (NoteLen != 0)
1711 sal_Char* pNote = new sal_Char[NoteLen+1];
1712 rStream.Read(pNote, NoteLen);
1713 pNote[NoteLen] = 0;
1714 String aNoteText( SC10TOSTRING(pNote));
1715 delete [] pNote;
1716 ScAddress aPos( Col, static_cast<SCROW>(Row), Tab );
1717 ScNoteUtil::CreateNoteFromString( *pDoc, aPos, aNoteText, false, false );
1720 pPrgrsBar->Progress();
1725 void Sc10Import::LoadColAttr(SCCOL Col, SCTAB Tab)
1727 Sc10ColAttr aFont;
1728 Sc10ColAttr aAttr;
1729 Sc10ColAttr aJustify;
1730 Sc10ColAttr aFrame;
1731 Sc10ColAttr aRaster;
1732 Sc10ColAttr aValue;
1733 Sc10ColAttr aColor;
1734 Sc10ColAttr aFrameColor;
1735 Sc10ColAttr aFlag;
1736 Sc10ColAttr aPattern;
1738 if (nError == 0) LoadAttr(aFont);
1739 if (nError == 0) LoadAttr(aAttr);
1740 if (nError == 0) LoadAttr(aJustify);
1741 if (nError == 0) LoadAttr(aFrame);
1742 if (nError == 0) LoadAttr(aRaster);
1743 if (nError == 0) LoadAttr(aValue);
1744 if (nError == 0) LoadAttr(aColor);
1745 if (nError == 0) LoadAttr(aFrameColor);
1746 if (nError == 0) LoadAttr(aFlag);
1747 if (nError == 0) LoadAttr(aPattern);
1749 if (nError == 0)
1751 SCROW nStart;
1752 SCROW nEnd;
1753 USHORT i;
1754 UINT16 nLimit;
1755 UINT16 nValue1;
1756 Sc10ColData *pColData;
1758 // Font (Name, Groesse)
1759 nStart = 0;
1760 nEnd = 0;
1761 nLimit = aFont.Count;
1762 pColData = aFont.pData;
1763 for( i = 0 ; i < nLimit ; i++, pColData++ )
1765 //nEnd = aFont.pData[i].Row;
1766 nEnd = static_cast<SCROW>(pColData->Row);
1767 //if ((nStart <= nEnd) && (aFont.pData[i].Value != 0))
1768 if ((nStart <= nEnd) && (pColData->Value))
1770 FontFamily eFam = FAMILY_DONTKNOW;
1771 //Sc10FontData* pFont = pFontCollection->At(aFont.pData[i].Value);
1772 Sc10FontData* pFont = pFontCollection->At(pColData->Value);
1773 switch (pFont->PitchAndFamily & 0xF0)
1775 case ffDontCare : eFam = FAMILY_DONTKNOW; break;
1776 case ffRoman : eFam = FAMILY_ROMAN; break;
1777 case ffSwiss : eFam = FAMILY_SWISS; break;
1778 case ffModern : eFam = FAMILY_MODERN; break;
1779 case ffScript : eFam = FAMILY_SCRIPT; break;
1780 case ffDecorative : eFam = FAMILY_DECORATIVE; break;
1781 default: eFam = FAMILY_DONTKNOW; break;
1783 ScPatternAttr aScPattern(pDoc->GetPool());
1784 aScPattern.GetItemSet().Put(SvxFontItem(eFam, SC10TOSTRING( pFont->FaceName ), EMPTY_STRING,
1785 PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT ));
1786 aScPattern.GetItemSet().Put(SvxFontHeightItem(Abs(pFont->Height), 100, ATTR_FONT_HEIGHT ));
1787 pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
1789 nStart = nEnd + 1;
1792 // Fontfarbe
1793 nStart = 0;
1794 nEnd = 0;
1795 nLimit = aColor.Count;
1796 pColData = aColor.pData;
1797 for( i = 0 ; i < nLimit ; i++, pColData++ )
1799 //nEnd = aColor.pData[i].Row;
1800 nEnd = static_cast<SCROW>(pColData->Row);
1801 //if ((nStart <= nEnd) && (aColor.pData[i].Value != 0))
1802 if ((nStart <= nEnd) && (pColData->Value))
1804 Color TextColor(COL_BLACK);
1805 lcl_ChangeColor((pColData->Value & 0x000F), TextColor);
1806 ScPatternAttr aScPattern(pDoc->GetPool());
1807 aScPattern.GetItemSet().Put(SvxColorItem(TextColor, ATTR_FONT_COLOR ));
1808 pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
1810 nStart = nEnd + 1;
1813 // Fontattribute (Fett, Kursiv...)
1814 nStart = 0;
1815 nEnd = 0;
1816 nLimit = aAttr.Count;
1817 pColData = aAttr.pData;
1818 for( i = 0 ; i < nLimit ; i++, pColData++ )
1820 nEnd = static_cast<SCROW>(pColData->Row);
1821 nValue1 = pColData->Value;
1822 if ((nStart <= nEnd) && (nValue1))
1824 ScPatternAttr aScPattern(pDoc->GetPool());
1825 if ((nValue1 & atBold) == atBold)
1826 aScPattern.GetItemSet().Put(SvxWeightItem(WEIGHT_BOLD, ATTR_FONT_WEIGHT));
1827 if ((nValue1 & atItalic) == atItalic)
1828 aScPattern.GetItemSet().Put(SvxPostureItem(ITALIC_NORMAL, ATTR_FONT_POSTURE));
1829 if ((nValue1 & atUnderline) == atUnderline)
1830 aScPattern.GetItemSet().Put(SvxUnderlineItem(UNDERLINE_SINGLE, ATTR_FONT_UNDERLINE));
1831 if ((nValue1 & atStrikeOut) == atStrikeOut)
1832 aScPattern.GetItemSet().Put(SvxCrossedOutItem(STRIKEOUT_SINGLE, ATTR_FONT_CROSSEDOUT));
1833 pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
1835 nStart = nEnd + 1;
1838 // Zellausrichtung
1839 nStart = 0;
1840 nEnd = 0;
1841 nLimit = aJustify.Count;
1842 pColData = aJustify.pData;
1843 for( i = 0 ; i < nLimit ; i++, pColData++ )
1845 nEnd = static_cast<SCROW>(pColData->Row);
1846 nValue1 = pColData->Value;
1847 if ((nStart <= nEnd) && (nValue1))
1849 ScPatternAttr aScPattern(pDoc->GetPool());
1850 USHORT HorJustify = (nValue1 & 0x000F);
1851 USHORT VerJustify = (nValue1 & 0x00F0) >> 4;
1852 USHORT OJustify = (nValue1 & 0x0F00) >> 8;
1853 USHORT EJustify = (nValue1 & 0xF000) >> 12;
1855 switch (HorJustify)
1857 case hjLeft:
1858 aScPattern.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_LEFT, ATTR_HOR_JUSTIFY));
1859 break;
1860 case hjCenter:
1861 aScPattern.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY));
1862 break;
1863 case hjRight:
1864 aScPattern.GetItemSet().Put(SvxHorJustifyItem(SVX_HOR_JUSTIFY_RIGHT, ATTR_HOR_JUSTIFY));
1865 break;
1868 switch (VerJustify)
1870 case vjTop:
1871 aScPattern.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_TOP, ATTR_VER_JUSTIFY));
1872 break;
1873 case vjCenter:
1874 aScPattern.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_CENTER, ATTR_VER_JUSTIFY));
1875 break;
1876 case vjBottom:
1877 aScPattern.GetItemSet().Put(SvxVerJustifyItem(SVX_VER_JUSTIFY_BOTTOM, ATTR_VER_JUSTIFY));
1878 break;
1881 if (OJustify & ojWordBreak)
1882 aScPattern.GetItemSet().Put(SfxBoolItem(TRUE));
1883 if (OJustify & ojBottomTop)
1884 aScPattern.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE,9000));
1885 else if (OJustify & ojTopBottom)
1886 aScPattern.GetItemSet().Put(SfxInt32Item(ATTR_ROTATE_VALUE,27000));
1888 INT16 Margin = Max((USHORT)20, (USHORT)(EJustify * 20));
1889 if (((OJustify & ojBottomTop) == ojBottomTop) || ((OJustify & ojBottomTop) == ojBottomTop))
1890 aScPattern.GetItemSet().Put(SvxMarginItem(20, Margin, 20, Margin, ATTR_MARGIN));
1891 else
1892 aScPattern.GetItemSet().Put(SvxMarginItem(Margin, 20, Margin, 20, ATTR_MARGIN));
1893 pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
1895 nStart = nEnd + 1;
1897 // Umrandung
1898 BOOL bEnd = FALSE;
1899 USHORT nColorIndex = 0;
1900 USHORT nFrameIndex = 0;
1902 // Special Fix...
1903 const UINT32 nHelpMeStart = 100;
1904 UINT32 nHelpMe = nHelpMeStart;
1905 USHORT nColorIndexOld = nColorIndex;
1906 USHORT nFrameIndexOld = nColorIndex;
1908 nEnd = 0;
1909 nStart = 0;
1910 while( !bEnd && nHelpMe )
1912 pColData = &aFrame.pData[ nFrameIndex ];
1914 USHORT nValue = pColData->Value;
1915 USHORT nLeft = 0;
1916 USHORT nTop = 0;
1917 USHORT nRight = 0;
1918 USHORT nBottom = 0;
1919 USHORT fLeft = ( nValue & 0x000F );
1920 USHORT fTop = ( nValue & 0x00F0 ) >> 4;
1921 USHORT fRight = ( nValue & 0x0F00 ) >> 8;
1922 USHORT fBottom = ( nValue & 0xF000 ) >> 12;
1924 if( fLeft > 1 )
1925 nLeft = 50;
1926 else if( fLeft > 0 )
1927 nLeft = 20;
1929 if( fTop > 1 )
1930 nTop = 50;
1931 else if( fTop > 0 )
1932 nTop = 20;
1934 if( fRight > 1 )
1935 nRight = 50;
1936 else if( fRight > 0 )
1937 nRight = 20;
1939 if( fBottom > 1 )
1940 nBottom = 50;
1941 else if( fBottom > 0 )
1942 nBottom = 20;
1944 Color ColorLeft( COL_BLACK );
1945 Color ColorTop( COL_BLACK );
1946 Color ColorRight( COL_BLACK );
1947 Color ColorBottom( COL_BLACK );
1948 USHORT nFrmColVal = aFrameColor.pData[ nColorIndex ].Value;
1949 SCROW nFrmColRow = static_cast<SCROW>(aFrameColor.pData[ nColorIndex ].Row);
1950 USHORT cLeft = ( nFrmColVal & 0x000F );
1951 USHORT cTop = ( nFrmColVal & 0x00F0 ) >> 4;
1952 USHORT cRight = ( nFrmColVal & 0x0F00 ) >> 8;
1953 USHORT cBottom = ( nFrmColVal & 0xF000 ) >> 12;
1955 lcl_ChangeColor( cLeft, ColorLeft );
1956 lcl_ChangeColor( cTop, ColorTop );
1957 lcl_ChangeColor( cRight, ColorRight );
1958 lcl_ChangeColor( cBottom, ColorBottom );
1960 if( static_cast<SCROW>(pColData->Row) < nFrmColRow )
1962 nEnd = static_cast<SCROW>(pColData->Row);
1963 if( nFrameIndex < ( aFrame.Count - 1 ) )
1964 nFrameIndex++;
1966 else if( static_cast<SCROW>(pColData->Row) > nFrmColRow )
1968 nEnd = static_cast<SCROW>(aFrameColor.pData[ nColorIndex ].Row);
1969 if( nColorIndex < ( aFrameColor.Count - 1 ) )
1970 nColorIndex++;
1972 else
1974 nEnd = nFrmColRow;
1975 if( nFrameIndex < (aFrame.Count - 1 ) )
1976 nFrameIndex++;
1977 if( nColorIndex < ( aFrameColor.Count - 1 ) )
1978 nColorIndex++;
1980 if( ( nStart <= nEnd ) && ( nValue != 0 ) )
1982 ScPatternAttr aScPattern(pDoc->GetPool());
1983 SvxBorderLine aLine;
1984 SvxBoxItem aBox( ATTR_BORDER );
1986 aLine.SetOutWidth( nLeft );
1987 aLine.SetColor( ColorLeft );
1988 aBox.SetLine( &aLine, BOX_LINE_LEFT );
1990 aLine.SetOutWidth( nTop );
1991 aLine.SetColor( ColorTop );
1992 aBox.SetLine( &aLine, BOX_LINE_TOP );
1994 aLine.SetOutWidth( nRight );
1995 aLine.SetColor( ColorRight );
1996 aBox.SetLine( &aLine, BOX_LINE_RIGHT );
1998 aLine.SetOutWidth( nBottom );
1999 aLine.SetColor( ColorBottom );
2000 aBox.SetLine( &aLine, BOX_LINE_BOTTOM );
2002 aScPattern.GetItemSet().Put( aBox );
2003 pDoc->ApplyPatternAreaTab( Col, nStart, Col, nEnd, Tab, aScPattern );
2005 nStart = nEnd + 1;
2007 bEnd = ( nFrameIndex == ( aFrame.Count - 1 ) ) && ( nColorIndex == ( aFrameColor.Count - 1 ) );
2009 if( nColorIndexOld != nColorIndex || nFrameIndexOld != nFrameIndex )
2011 nColorIndexOld = nColorIndex;
2012 nFrameIndexOld = nFrameIndex;
2013 nHelpMe = nHelpMeStart;
2015 else
2016 nHelpMe--;
2018 pColData++;
2021 // ACHTUNG: Code bis hier ueberarbeitet ... jetzt hab' ich keinen Bock mehr! (GT)
2023 // Hintergrund (Farbe, Raster)
2024 USHORT nRasterIndex = 0;
2025 bEnd = FALSE;
2026 nColorIndex = 0;
2027 nEnd = 0;
2028 nStart = 0;
2030 // Special Fix...
2031 nHelpMe = nHelpMeStart;
2032 USHORT nRasterIndexOld = nRasterIndex;
2034 while( !bEnd && nHelpMe )
2036 USHORT nBColor = ( aColor.pData[ nColorIndex ].Value & 0x00F0 ) >> 4;
2037 USHORT nRColor = ( aColor.pData[ nColorIndex ].Value & 0x0F00 ) >> 8;
2038 Color aBColor( COL_BLACK );
2040 lcl_ChangeColor( nBColor, aBColor );
2042 if( nBColor == 0 )
2043 aBColor.SetColor( COL_WHITE );
2044 else if( nBColor == 15 )
2045 aBColor.SetColor( COL_BLACK );
2047 Color aRColor( COL_BLACK );
2049 lcl_ChangeColor( nRColor, aRColor );
2051 ScPatternAttr aScPattern( pDoc->GetPool() );
2053 UINT16 nFact;
2054 BOOL bSwapCol = FALSE;
2055 BOOL bSetItem = TRUE;
2056 switch ( aRaster.pData[ nRasterIndex ].Value )
2058 case raNone: nFact = 0xffff; bSwapCol = TRUE; bSetItem = (nBColor > 0); break;
2059 case raGray12: nFact = (0xffff / 100) * 12; break;
2060 case raGray25: nFact = (0xffff / 100) * 25; break;
2061 case raGray50: nFact = (0xffff / 100) * 50; break;
2062 case raGray75: nFact = (0xffff / 100) * 75; break;
2063 default: nFact = 0xffff; bSetItem = (nRColor < 15);
2065 if ( bSetItem )
2067 if( bSwapCol )
2068 aScPattern.GetItemSet().Put( SvxBrushItem( GetMixedColor( aBColor, aRColor, nFact ), ATTR_BACKGROUND ) );
2069 else
2070 aScPattern.GetItemSet().Put( SvxBrushItem( GetMixedColor( aRColor, aBColor, nFact ), ATTR_BACKGROUND ) );
2072 if( aRaster.pData[ nRasterIndex ].Row < aColor.pData[ nColorIndex ].Row )
2074 nEnd = static_cast<SCROW>(aRaster.pData[ nRasterIndex ].Row);
2075 if( nRasterIndex < ( aRaster.Count - 1 ) )
2076 nRasterIndex++;
2078 else if( aRaster.pData[ nRasterIndex ].Row > aColor.pData[ nColorIndex ].Row )
2080 nEnd = static_cast<SCROW>(aColor.pData[ nColorIndex ].Row);
2081 if( nColorIndex < ( aColor.Count - 1 ) )
2082 nColorIndex++;
2084 else
2086 nEnd = static_cast<SCROW>(aColor.pData[ nColorIndex ].Row);
2087 if( nRasterIndex < ( aRaster.Count - 1 ) )
2088 nRasterIndex++;
2089 if( nColorIndex < ( aColor.Count - 1 ) )
2090 nColorIndex++;
2092 if( nStart <= nEnd )
2093 pDoc->ApplyPatternAreaTab( Col, nStart, Col, nEnd, Tab, aScPattern );
2095 nStart = nEnd + 1;
2097 bEnd = ( nRasterIndex == ( aRaster.Count - 1 ) ) && ( nColorIndex == ( aColor.Count - 1 ) );
2099 if( nColorIndexOld != nColorIndex || nRasterIndexOld != nRasterIndex )
2101 nColorIndexOld = nColorIndex;
2102 nRasterIndexOld = nRasterIndex;
2103 nHelpMe = nHelpMeStart;
2105 else
2106 nHelpMe--;
2108 nHelpMe--;
2111 // Zahlenformate
2112 nStart = 0;
2113 nEnd = 0;
2114 nLimit = aValue.Count;
2115 pColData = aValue.pData;
2116 for (i=0; i<nLimit; i++, pColData++)
2118 nEnd = static_cast<SCROW>(pColData->Row);
2119 nValue1 = pColData->Value;
2120 if ((nStart <= nEnd) && (nValue1))
2122 ULONG nKey = 0;
2123 USHORT nFormat = (nValue1 & 0x00FF);
2124 USHORT nInfo = (nValue1 & 0xFF00) >> 8;
2125 ChangeFormat(nFormat, nInfo, nKey);
2126 ScPatternAttr aScPattern(pDoc->GetPool());
2127 aScPattern.GetItemSet().Put(SfxUInt32Item(ATTR_VALUE_FORMAT, (UINT32)nKey));
2128 pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
2130 nStart = nEnd + 1;
2133 // Zellattribute (Schutz, Versteckt...)
2134 nStart = 0;
2135 nEnd = 0;
2136 for (i=0; i<aFlag.Count; i++)
2138 nEnd = static_cast<SCROW>(aFlag.pData[i].Row);
2139 if ((nStart <= nEnd) && (aFlag.pData[i].Value != 0))
2141 BOOL bProtect = ((aFlag.pData[i].Value & paProtect) == paProtect);
2142 BOOL bHFormula = ((aFlag.pData[i].Value & paHideFormula) == paHideFormula);
2143 BOOL bHCell = ((aFlag.pData[i].Value & paHideAll) == paHideAll);
2144 BOOL bHPrint = ((aFlag.pData[i].Value & paHidePrint) == paHidePrint);
2145 ScPatternAttr aScPattern(pDoc->GetPool());
2146 aScPattern.GetItemSet().Put(ScProtectionAttr(bProtect, bHFormula, bHCell, bHPrint));
2147 pDoc->ApplyPatternAreaTab(Col, nStart, Col, nEnd, Tab, aScPattern);
2149 nStart = nEnd + 1;
2152 // ZellVorlagen
2153 nStart = 0;
2154 nEnd = 0;
2155 ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
2156 for (i=0; i<aPattern.Count; i++)
2158 nEnd = static_cast<SCROW>(aPattern.pData[i].Row);
2159 if ((nStart <= nEnd) && (aPattern.pData[i].Value != 0))
2161 USHORT nPatternIndex = (aPattern.pData[i].Value & 0x00FF) - 1;
2162 Sc10PatternData* pPattern = pPatternCollection->At(nPatternIndex);
2163 if (pPattern != NULL)
2165 ScStyleSheet* pStyle = (ScStyleSheet*) pStylePool->Find(
2166 SC10TOSTRING( pPattern->Name ), SFX_STYLE_FAMILY_PARA);
2168 if (pStyle != NULL)
2169 pDoc->ApplyStyleAreaTab(Col, nStart, Col, nEnd, Tab, *pStyle);
2172 nStart = nEnd + 1;
2176 delete[] aFont.pData;
2177 delete[] aAttr.pData;
2178 delete[] aJustify.pData;
2179 delete[] aFrame.pData;
2180 delete[] aRaster.pData;
2181 delete[] aValue.pData;
2182 delete[] aColor.pData;
2183 delete[] aFrameColor.pData;
2184 delete[] aFlag.pData;
2185 delete[] aPattern.pData;
2189 void Sc10Import::LoadAttr(Sc10ColAttr& rAttr)
2191 rStream >> rAttr.Count;
2192 rAttr.pData = new Sc10ColData[rAttr.Count];
2193 if (rAttr.pData != NULL)
2195 for (USHORT i = 0; i < rAttr.Count; i++)
2197 rStream >> rAttr.pData[i].Row;
2198 rStream >> rAttr.pData[i].Value;
2200 //rStream.Read(rAttr.pData, rAttr.Count * sizeof(Sc10ColData));
2201 nError = rStream.GetError();
2203 else
2204 nError = errOutOfMemory;
2208 void Sc10Import::ChangeFormat(USHORT nFormat, USHORT nInfo, ULONG& nKey)
2210 // Achtung: Die Formate werden nur auf die StarCalc 3.0 internen Formate gemappt
2211 // Korrekterweise muessten zum Teil neue Formate erzeugt werden (sollte Stephan sich ansehen)
2212 nKey = 0;
2213 switch (nFormat)
2215 case vfStandard :
2216 if (nInfo > 0)
2217 nKey = 2;
2218 break;
2219 case vfMoney :
2220 if (nInfo > 0)
2221 nKey = 21;
2222 else
2223 nKey = 20;
2224 break;
2225 case vfThousend :
2226 if (nInfo > 0)
2227 nKey = 4;
2228 else
2229 nKey = 5;
2230 break;
2231 case vfPercent :
2232 if (nInfo > 0)
2233 nKey = 11;
2234 else
2235 nKey = 10;
2236 break;
2237 case vfExponent :
2238 nKey = 60;
2239 break;
2240 case vfZerro :
2241 // Achtung kein Aequivalent
2242 break;
2243 case vfDate :
2244 switch (nInfo)
2246 case df_NDMY_Long :
2247 nKey = 31;
2248 break;
2249 case df_DMY_Long :
2250 nKey = 30;
2251 break;
2252 case df_MY_Long :
2253 nKey = 32;
2254 break;
2255 case df_NDM_Long :
2256 nKey = 31;
2257 break;
2258 case df_DM_Long :
2259 nKey = 33;
2260 break;
2261 case df_M_Long :
2262 nKey = 34;
2263 break;
2264 case df_NDMY_Short :
2265 nKey = 31;
2266 break;
2267 case df_DMY_Short :
2268 nKey = 30;
2269 break;
2270 case df_MY_Short :
2271 nKey = 32;
2272 break;
2273 case df_NDM_Short :
2274 nKey = 31;
2275 break;
2276 case df_DM_Short :
2277 nKey = 33;
2278 break;
2279 case df_M_Short :
2280 nKey = 34;
2281 break;
2282 case df_Q_Long :
2283 nKey = 35;
2284 break;
2285 case df_Q_Short :
2286 nKey = 35;
2287 break;
2288 default :
2289 nKey = 30;
2290 break;
2292 break;
2293 case vfTime :
2294 switch (nInfo)
2296 case tf_HMS_Long :
2297 nKey = 41;
2298 break;
2299 case tf_HM_Long :
2300 nKey = 40;
2301 break;
2302 case tf_HMS_Short :
2303 nKey = 43;
2304 break;
2305 case tf_HM_Short :
2306 nKey = 42;
2307 break;
2308 default :
2309 nKey = 41;
2310 break;
2312 break;
2313 case vfBoolean :
2314 nKey = 99;
2315 break;
2316 case vfStandardRed :
2317 if (nInfo > 0)
2318 nKey = 2;
2319 break;
2320 case vfMoneyRed :
2321 if (nInfo > 0)
2322 nKey = 23;
2323 else
2324 nKey = 22;
2325 break;
2326 case vfThousendRed :
2327 if (nInfo > 0)
2328 nKey = 4;
2329 else
2330 nKey = 5;
2331 break;
2332 case vfPercentRed :
2333 if (nInfo > 0)
2334 nKey = 11;
2335 else
2336 nKey = 10;
2337 break;
2338 case vfExponentRed :
2339 nKey = 60;
2340 break;
2341 case vfFormula :
2342 break;
2343 case vfString :
2344 break;
2345 default :
2346 break;
2351 void Sc10Import::LoadObjects()
2353 USHORT ID;
2354 rStream >> ID;
2355 if (rStream.IsEof()) return;
2356 if (ID == ObjectID)
2358 #ifdef SC10_SHOW_OBJECTS
2359 // Achtung nur zu Debugzwecken
2360 //-----------------------------------
2361 pDoc->InsertTab(SC_TAB_APPEND, "GraphObjects");
2362 SCCOL nCol = 0;
2363 SCROW nRow = 0;
2364 SCTAB nTab = 0;
2365 pDoc->GetTable("GraphObjects", nTab);
2366 pDoc->SetString(nCol++, nRow, nTab, "ObjectTyp");
2367 pDoc->SetString(nCol++, nRow, nTab, "Col");
2368 pDoc->SetString(nCol++, nRow, nTab, "Row");
2369 pDoc->SetString(nCol++, nRow, nTab, "Tab");
2370 pDoc->SetString(nCol++, nRow, nTab, "X");
2371 pDoc->SetString(nCol++, nRow, nTab, "Y");
2372 pDoc->SetString(nCol++, nRow, nTab, "W");
2373 pDoc->SetString(nCol++, nRow, nTab, "H");
2374 //-----------------------------------
2375 #endif
2377 USHORT nAnz;
2378 rStream >> nAnz;
2379 sal_Char Reserved[32];
2380 rStream.Read(Reserved, sizeof(Reserved));
2381 nError = rStream.GetError();
2382 if ((nAnz > 0) && (nError == 0))
2384 BYTE ObjectType;
2385 Sc10GraphHeader GraphHeader;
2386 BOOL IsOleObject = FALSE; // Achtung dies ist nur ein Notnagel
2387 for (USHORT i = 0; (i < nAnz) && (nError == 0) && !rStream.IsEof() && !IsOleObject; i++)
2389 rStream >> ObjectType;
2390 //rStream.Read(&GraphHeader, sizeof(GraphHeader));
2391 lcl_ReadGraphHeader(rStream, GraphHeader);
2393 double nPPTX = ScGlobal::nScreenPPTX;
2394 double nPPTY = ScGlobal::nScreenPPTY;
2396 long nStartX = 0;
2397 for (SCsCOL nX=0; nX<GraphHeader.CarretX; nX++)
2398 nStartX += pDoc->GetColWidth(nX, static_cast<SCTAB>(GraphHeader.CarretZ));
2399 nStartX = (long) ( nStartX * HMM_PER_TWIPS );
2400 nStartX += (long) ( GraphHeader.x / nPPTX * HMM_PER_TWIPS );
2401 long nSizeX = (long) ( GraphHeader.w / nPPTX * HMM_PER_TWIPS );
2402 long nStartY = pDoc->FastGetRowHeight( 0,
2403 static_cast<SCsROW>(GraphHeader.CarretY) - 1,
2404 static_cast<SCTAB>(GraphHeader.CarretZ));
2405 nStartY = (long) ( nStartY * HMM_PER_TWIPS );
2406 nStartY += (long) ( GraphHeader.y / nPPTY * HMM_PER_TWIPS );
2407 long nSizeY = (long) ( GraphHeader.h / nPPTY * HMM_PER_TWIPS );
2409 #ifdef SC10_SHOW_OBJECTS
2410 // Achtung nur zu Debugzwecken
2411 //-----------------------------------
2412 nCol = 0;
2413 nRow++;
2414 switch (ObjectType)
2416 case otOle :
2417 pDoc->SetString(nCol++, nRow, nTab, "Ole-Object");
2418 break;
2419 case otImage :
2420 pDoc->SetString(nCol++, nRow, nTab, "Image-Object");
2421 break;
2422 case otChart :
2423 pDoc->SetString(nCol++, nRow, nTab, "Chart-Object");
2424 break;
2425 default :
2426 pDoc->SetString(nCol++, nRow, nTab, "ERROR");
2427 break;
2429 pDoc->SetValue(nCol++, nRow, nTab, GraphHeader.CarretX);
2430 pDoc->SetValue(nCol++, nRow, nTab, GraphHeader.CarretY);
2431 pDoc->SetValue(nCol++, nRow, nTab, GraphHeader.CarretZ);
2432 pDoc->SetValue(nCol++, nRow, nTab, GraphHeader.x);
2433 pDoc->SetValue(nCol++, nRow, nTab, GraphHeader.y);
2434 pDoc->SetValue(nCol++, nRow, nTab, GraphHeader.w);
2435 pDoc->SetValue(nCol++, nRow, nTab, GraphHeader.h);
2436 //-----------------------------------
2437 #endif
2439 switch (ObjectType)
2441 case otOle :
2442 // Achtung hier muss sowas wie OleLoadFromStream passieren
2443 IsOleObject = TRUE;
2444 break;
2445 case otImage :
2447 Sc10ImageHeader ImageHeader;
2448 //rStream.Read(&ImageHeader, sizeof(ImageHeader));
2449 lcl_ReadImageHeaer(rStream, ImageHeader);
2451 // Achtung nun kommen die Daten (Bitmap oder Metafile)
2452 // Typ = 1 Device Dependend Bitmap DIB
2453 // Typ = 2 MetaFile
2454 rStream.SeekRel(ImageHeader.Size);
2456 if( ImageHeader.Typ != 1 && ImageHeader.Typ != 2 )
2457 nError = errUnknownFormat;
2458 break;
2460 case otChart :
2462 Sc10ChartHeader ChartHeader;
2463 Sc10ChartSheetData ChartSheetData;
2464 Sc10ChartTypeData* pTypeData = new Sc10ChartTypeData;
2465 //rStream.Read(&ChartHeader, sizeof(ChartHeader));
2466 lcl_ReadChartHeader(rStream, ChartHeader);
2468 //! altes Metafile verwenden ??
2469 rStream.SeekRel(ChartHeader.Size);
2471 //rStream.Read(&ChartSheetData, sizeof(ChartSheetData));
2472 lcl_ReadChartSheetData(rStream, ChartSheetData);
2474 //rStream.Read(pTypeData, sizeof(Sc10ChartTypeData));
2475 lcl_ReadChartTypeData(rStream, *pTypeData);
2477 Rectangle aRect( Point(nStartX,nStartY), Size(nSizeX,nSizeY) );
2478 Sc10InsertObject::InsertChart( pDoc, static_cast<SCTAB>(GraphHeader.CarretZ), aRect,
2479 static_cast<SCTAB>(GraphHeader.CarretZ),
2480 ChartSheetData.DataX1, ChartSheetData.DataY1,
2481 ChartSheetData.DataX2, ChartSheetData.DataY2 );
2483 delete pTypeData;
2485 break;
2486 default :
2487 nError = errUnknownFormat;
2488 break;
2490 nError = rStream.GetError();
2494 else
2496 DBG_ERROR( "ObjectID" );
2497 nError = errUnknownID;
2504 //-----------------------------------------------------------------------------------------------
2506 FltError ScFormatFilterPluginImpl::ScImportStarCalc10( SvStream& rStream, ScDocument* pDocument )
2508 rStream.Seek( 0UL );
2509 Sc10Import aImport( rStream, pDocument );
2510 return ( FltError ) aImport.Import();