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