1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <stdlib.h>
#include "document.hxx"
#include "scerrors.hxx"
#include "fprogressbar.hxx"
#include "xltracer.hxx"
#include "xltable.hxx"
#include "xihelper.hxx"
#include "xipage.hxx"
#include "xiview.hxx"
#include "xilink.hxx"
#include "xiname.hxx"
#include "xicontent.hxx"
#include "xiescher.hxx"
#include "xipivot.hxx"
#include "XclImpChangeTrack.hxx"
#include "documentimport.hxx"
#include "root.hxx"
#include "imp_op.hxx"
#include "excimp8.hxx"
#include <memory>
namespace
{
bool TryStartNextRecord(XclImpStream& rIn, sal_Size nProgressBasePos)
{
bool bValid = true;
// i#115255 fdo#40304 BOUNDSHEET doesn't point to a valid
// BOF record position. Scan the records manually (from
// the BOUNDSHEET position) until we find a BOF. Some 3rd
// party Russian programs generate invalid xls docs with
// this kind of silliness.
if (rIn.PeekRecId(nProgressBasePos) == EXC_ID5_BOF)
// BOUNDSHEET points to a valid BOF record. Good.
rIn.StartNextRecord(nProgressBasePos);
else
{
while (bValid && rIn.GetRecId() != EXC_ID5_BOF)
bValid = rIn.StartNextRecord();
}
return bValid;
}
}
FltError ImportExcel::Read()
{
XclImpPageSettings& rPageSett = GetPageSettings();
XclImpTabViewSettings& rTabViewSett = GetTabViewSettings();
XclImpPalette& rPal = GetPalette();
XclImpFontBuffer& rFontBfr = GetFontBuffer();
XclImpNumFmtBuffer& rNumFmtBfr = GetNumFmtBuffer();
XclImpXFBuffer& rXFBfr = GetXFBuffer();
XclImpNameManager& rNameMgr = GetNameManager();
XclImpObjectManager& rObjMgr = GetObjectManager();
(void)rObjMgr;
// call to GetCurrSheetDrawing() cannot be cached (changes in new sheets)
enum Zustand {
Z_BiffNull, // not a valid Biff-Format
Z_Biff2, // Biff2: only one table
Z_Biff3, // Biff3: only one table
Z_Biff4, // Biff4: only one table
Z_Biff4W, // Biff4 Workbook: Globals
Z_Biff4T, // Biff4 Workbook: a table itself
Z_Biff4E, // Biff4 Workbook: between tables
Z_Biff5WPre,// Biff5: Prefetch Workbook
Z_Biff5W, // Biff5: Globals
Z_Biff5TPre,// Biff5: Prefetch for Shrfmla/Array Formula
Z_Biff5T, // Biff5: a table itself
Z_Biff5E, // Biff5: between tables
Z_Biffn0, // all Biffs: skip table till next EOF
Z_Ende };
Zustand eAkt = Z_BiffNull, ePrev = Z_BiffNull;
FltError eLastErr = eERR_OK;
sal_uInt16 nOpcode;
sal_uInt16 nBofLevel = 0;
std::unique_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
/* #i104057# Need to track a base position for progress bar calculation,
because sheet substreams may not be in order of sheets. */
sal_Size nProgressBasePos = 0;
sal_Size nProgressBaseSize = 0;
for (; eAkt != Z_Ende; mnLastRecId = nOpcode)
{
if( eAkt == Z_Biff5E )
{
sal_uInt16 nScTab = GetCurrScTab();
if( nScTab < maSheetOffsets.size() )
{
nProgressBaseSize += (aIn.GetSvStreamPos() - nProgressBasePos);
nProgressBasePos = maSheetOffsets[ nScTab ];
bool bValid = TryStartNextRecord(aIn, nProgressBasePos);
if (!bValid)
{
// Safeguard ourselves from potential infinite loop.
eAkt = Z_Ende;
}
}
else
eAkt = Z_Ende;
}
else
aIn.StartNextRecord();
nOpcode = aIn.GetRecId();
if( !aIn.IsValid() )
{
// finalize table if EOF is missing
switch( eAkt )
{
case Z_Biff2:
case Z_Biff3:
case Z_Biff4:
case Z_Biff4T:
case Z_Biff5TPre:
case Z_Biff5T:
rNumFmtBfr.CreateScFormats();
Eof();
break;
default:;
}
break;
}
if( eAkt == Z_Ende )
break;
if( eAkt != Z_Biff5TPre && eAkt != Z_Biff5WPre )
pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
switch( eAkt )
{
case Z_BiffNull: // ------------------------------- Z_BiffNull -
{
switch( nOpcode )
{
case EXC_ID2_BOF:
case EXC_ID3_BOF:
case EXC_ID4_BOF:
case EXC_ID5_BOF:
{
// #i23425# don't rely on the record ID, but on the detected BIFF version
switch( GetBiff() )
{
case EXC_BIFF2:
Bof2();
if( pExcRoot->eDateiTyp == Biff2 )
{
eAkt = Z_Biff2;
NewTable();
}
break;
case EXC_BIFF3:
Bof3();
if( pExcRoot->eDateiTyp == Biff3 )
{
eAkt = Z_Biff3;
NewTable();
}
break;
case EXC_BIFF4:
Bof4();
if( pExcRoot->eDateiTyp == Biff4 )
{
eAkt = Z_Biff4;
NewTable();
}
else if( pExcRoot->eDateiTyp == Biff4W )
eAkt = Z_Biff4W;
break;
case EXC_BIFF5:
Bof5();
if( pExcRoot->eDateiTyp == Biff5W )
{
eAkt = Z_Biff5WPre;
nBdshtTab = 0;
aIn.StoreGlobalPosition(); // store position
}
else if( pExcRoot->eDateiTyp == Biff5 )
{
// #i62752# possible to have BIFF5 sheet without globals
NewTable();
eAkt = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch
nBofLevel = 0;
aIn.StoreGlobalPosition(); // store position
}
break;
default:
DBG_ERROR_BIFF();
}
}
break;
}
}
break;
case Z_Biff2: // ---------------------------------- Z_Biff2 -
{
switch( nOpcode )
{
case EXC_ID2_DIMENSIONS:
case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
case EXC_ID2_BLANK:
case EXC_ID3_BLANK: ReadBlank(); break;
case EXC_ID2_INTEGER: ReadInteger(); break;
case EXC_ID2_NUMBER:
case EXC_ID3_NUMBER: ReadNumber(); break;
case EXC_ID2_LABEL:
case EXC_ID3_LABEL: ReadLabel(); break;
case EXC_ID2_BOOLERR:
case EXC_ID3_BOOLERR: ReadBoolErr(); break;
case EXC_ID_RK: ReadRk(); break;
case 0x06: Formula25(); break; // FORMULA [ 2 5]
case 0x08: Row25(); break; // ROW [ 2 5]
case 0x0A: // EOF [ 2345]
rNumFmtBfr.CreateScFormats();
rNameMgr.ConvertAllTokens();
Eof();
eAkt = Z_Ende;
break;
case 0x14:
case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
case 0x18: rNameMgr.ReadName( maStrm ); break;
case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
case 0x20: Columndefault(); break; // COLUMNDEFAULT[ 2 ]
case 0x21: Array25(); break; // ARRAY [ 2 5]
case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
case 0x24: Colwidth(); break; // COLWIDTH [ 2 ]
case 0x25: Defrowheight2(); break; // DEFAULTROWHEI[ 2 ]
case 0x26:
case 0x27:
case 0x28:
case 0x29: rPageSett.ReadMargin( maStrm ); break;
case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
case 0x2F: // FILEPASS [ 2345]
eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
if( eLastErr != ERRCODE_NONE )
eAkt = Z_Ende;
break;
case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break;
case EXC_ID_EFONT: rFontBfr.ReadEfont( maStrm ); break;
case 0x3E: rTabViewSett.ReadWindow2( maStrm, false );break;
case 0x41: rTabViewSett.ReadPane( maStrm ); break;
case 0x42: Codepage(); break; // CODEPAGE [ 2345]
case 0x43: rXFBfr.ReadXF( maStrm ); break;
case 0x44: Ixfe(); break; // IXFE [ 2 ]
}
}
break;
case Z_Biff3: // ---------------------------------- Z_Biff3 -
{
switch( nOpcode )
{
// skip chart substream
case EXC_ID2_BOF:
case EXC_ID3_BOF:
case EXC_ID4_BOF:
case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
case EXC_ID2_DIMENSIONS:
case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
case EXC_ID2_BLANK:
case EXC_ID3_BLANK: ReadBlank(); break;
case EXC_ID2_INTEGER: ReadInteger(); break;
case EXC_ID2_NUMBER:
case EXC_ID3_NUMBER: ReadNumber(); break;
case EXC_ID2_LABEL:
case EXC_ID3_LABEL: ReadLabel(); break;
case EXC_ID2_BOOLERR:
case EXC_ID3_BOOLERR: ReadBoolErr(); break;
case EXC_ID_RK: ReadRk(); break;
case 0x0A: // EOF [ 2345]
rNumFmtBfr.CreateScFormats();
rNameMgr.ConvertAllTokens();
Eof();
eAkt = Z_Ende;
break;
case 0x14:
case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
case 0x1A:
case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
case 0x22: Rec1904(); break; // 1904 [ 2345]
case 0x26:
case 0x27:
case 0x28:
case 0x29: rPageSett.ReadMargin( maStrm ); break;
case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
case 0x2F: // FILEPASS [ 2345]
eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
if( eLastErr != ERRCODE_NONE )
eAkt = Z_Ende;
break;
case EXC_ID_FILESHARING: ReadFileSharing(); break;
case 0x41: rTabViewSett.ReadPane( maStrm ); break;
case 0x42: Codepage(); break; // CODEPAGE [ 2345]
case 0x56: break; // BUILTINFMTCNT[ 34 ]
case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
case 0x7D: Colinfo(); break; // COLINFO [ 345]
case 0x8C: Country(); break; // COUNTRY [ 345]
case 0x92: rPal.ReadPalette( maStrm ); break;
case 0x0206: Formula3(); break; // FORMULA [ 3 ]
case 0x0208: Row34(); break; // ROW [ 34 ]
case 0x0218: rNameMgr.ReadName( maStrm ); break;
case 0x0221: Array34(); break; // ARRAY [ 34 ]
case 0x0223: break; // EXTERNNAME [ 34 ]
case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
case 0x0231: rFontBfr.ReadFont( maStrm ); break;
case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
case 0x0243: rXFBfr.ReadXF( maStrm ); break;
case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
}
}
break;
case Z_Biff4: // ---------------------------------- Z_Biff4 -
{
switch( nOpcode )
{
// skip chart substream
case EXC_ID2_BOF:
case EXC_ID3_BOF:
case EXC_ID4_BOF:
case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
case EXC_ID2_DIMENSIONS:
case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
case EXC_ID2_BLANK:
case EXC_ID3_BLANK: ReadBlank(); break;
case EXC_ID2_INTEGER: ReadInteger(); break;
case EXC_ID2_NUMBER:
case EXC_ID3_NUMBER: ReadNumber(); break;
case EXC_ID2_LABEL:
case EXC_ID3_LABEL: ReadLabel(); break;
case EXC_ID2_BOOLERR:
case EXC_ID3_BOOLERR: ReadBoolErr(); break;
case EXC_ID_RK: ReadRk(); break;
case 0x0A: // EOF [ 2345]
rNumFmtBfr.CreateScFormats();
rNameMgr.ConvertAllTokens();
Eof();
eAkt = Z_Ende;
break;
case 0x12: SheetProtect(); break; // SHEET PROTECTION
case 0x14:
case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
case 0x1A:
case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
case 0x22: Rec1904(); break; // 1904 [ 2345]
case 0x26:
case 0x27:
case 0x28:
case 0x29: rPageSett.ReadMargin( maStrm ); break;
case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
case 0x2F: // FILEPASS [ 2345]
eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
if( eLastErr != ERRCODE_NONE )
eAkt = Z_Ende;
break;
case EXC_ID_FILESHARING: ReadFileSharing(); break;
case 0x41: rTabViewSett.ReadPane( maStrm ); break;
case 0x42: Codepage(); break; // CODEPAGE [ 2345]
case 0x55: DefColWidth(); break;
case 0x56: break; // BUILTINFMTCNT[ 34 ]
case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
case 0x7D: Colinfo(); break; // COLINFO [ 345]
case 0x8C: Country(); break; // COUNTRY [ 345]
case 0x92: rPal.ReadPalette( maStrm ); break;
case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
case 0xA1: rPageSett.ReadSetup( maStrm ); break;
case 0x0208: Row34(); break; // ROW [ 34 ]
case 0x0218: rNameMgr.ReadName( maStrm ); break;
case 0x0221: Array34(); break; // ARRAY [ 34 ]
case 0x0223: break; // EXTERNNAME [ 34 ]
case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
case 0x0231: rFontBfr.ReadFont( maStrm ); break;
case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
case 0x0406: Formula4(); break; // FORMULA [ 4 ]
case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
case 0x0443: rXFBfr.ReadXF( maStrm ); break;
case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
}
}
break;
case Z_Biff4W: // --------------------------------- Z_Biff4W -
{
switch( nOpcode )
{
case 0x0A: // EOF [ 2345]
rNameMgr.ConvertAllTokens();
eAkt = Z_Ende;
break;
case 0x12: DocProtect(); break; // PROTECT [ 5]
case 0x2F: // FILEPASS [ 2345]
eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
if( eLastErr != ERRCODE_NONE )
eAkt = Z_Ende;
break;
case EXC_ID_FILESHARING: ReadFileSharing(); break;
case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
case 0x42: Codepage(); break; // CODEPAGE [ 2345]
case 0x55: DefColWidth(); break;
case 0x56: break; // BUILTINFMTCNT[ 34 ]
case 0x8C: Country(); break; // COUNTRY [ 345]
case 0x8F: break; // BUNDLEHEADER [ 4 ]
case 0x92: rPal.ReadPalette( maStrm ); break;
case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
case 0x0218: rNameMgr.ReadName( maStrm ); break;
case 0x0223: break; // EXTERNNAME [ 34 ]
case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
case 0x0231: rFontBfr.ReadFont( maStrm ); break;
case EXC_ID4_BOF: // BOF [ 4 ]
Bof4();
if( pExcRoot->eDateiTyp == Biff4 )
{
eAkt = Z_Biff4T;
NewTable();
}
else
eAkt = Z_Ende;
break;
case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
case 0x0443: rXFBfr.ReadXF( maStrm ); break;
case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
}
}
break;
case Z_Biff4T: // --------------------------------- Z_Biff4T -
{
switch( nOpcode )
{
// skip chart substream
case EXC_ID2_BOF:
case EXC_ID3_BOF:
case EXC_ID4_BOF:
case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
case EXC_ID2_DIMENSIONS:
case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
case EXC_ID2_BLANK:
case EXC_ID3_BLANK: ReadBlank(); break;
case EXC_ID2_INTEGER: ReadInteger(); break;
case EXC_ID2_NUMBER:
case EXC_ID3_NUMBER: ReadNumber(); break;
case EXC_ID2_LABEL:
case EXC_ID3_LABEL: ReadLabel(); break;
case EXC_ID2_BOOLERR:
case EXC_ID3_BOOLERR: ReadBoolErr(); break;
case EXC_ID_RK: ReadRk(); break;
case 0x0A: // EOF [ 2345]
rNameMgr.ConvertAllTokens();
Eof();
eAkt = Z_Biff4E;
break;
case 0x12: SheetProtect(); break; // SHEET PROTECTION
case 0x14:
case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
case 0x1A:
case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
case 0x2F: // FILEPASS [ 2345]
eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
if( eLastErr != ERRCODE_NONE )
eAkt = Z_Ende;
break;
case 0x41: rTabViewSett.ReadPane( maStrm ); break;
case 0x42: Codepage(); break; // CODEPAGE [ 2345]
case 0x55: DefColWidth(); break;
case 0x56: break; // BUILTINFMTCNT[ 34 ]
case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
case 0x7D: Colinfo(); break; // COLINFO [ 345]
case 0x8C: Country(); break; // COUNTRY [ 345]
case 0x8F: break; // BUNDLEHEADER [ 4 ]
case 0x92: rPal.ReadPalette( maStrm ); break;
case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
case 0xA1: rPageSett.ReadSetup( maStrm ); break;
case 0x0208: Row34(); break; // ROW [ 34 ]
case 0x0218: rNameMgr.ReadName( maStrm ); break;
case 0x0221: Array34(); break;
case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
case 0x0231: rFontBfr.ReadFont( maStrm ); break;
case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
case 0x0406: Formula4(); break;
case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
case 0x0443: rXFBfr.ReadXF( maStrm ); break;
case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
}
}
break;
case Z_Biff4E: // --------------------------------- Z_Biff4E -
{
switch( nOpcode )
{
case 0x0A: // EOF [ 2345]
eAkt = Z_Ende;
break;
case 0x8F: break; // BUNDLEHEADER [ 4 ]
case EXC_ID4_BOF: // BOF [ 4 ]
Bof4();
NewTable();
if( pExcRoot->eDateiTyp == Biff4 )
{
eAkt = Z_Biff4T;
}
else
{
ePrev = eAkt;
eAkt = Z_Biffn0;
}
break;
}
}
break;
case Z_Biff5WPre: // ------------------------------ Z_Biff5WPre -
{
switch( nOpcode )
{
case 0x0A: // EOF [ 2345]
eAkt = Z_Biff5W;
aIn.SeekGlobalPosition(); // und zurueck an alte Position
break;
case 0x12: DocProtect(); break; // PROTECT [ 5]
case 0x2F: // FILEPASS [ 2345]
eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
if( eLastErr != ERRCODE_NONE )
eAkt = Z_Ende;
break;
case EXC_ID_FILESHARING: ReadFileSharing(); break;
case 0x3D: Window1(); break;
case 0x42: Codepage(); break; // CODEPAGE [ 2345]
case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5]
case 0x8C: Country(); break; // COUNTRY [ 345]
// PALETTE follows XFs, but already needed while reading the XFs
case 0x92: rPal.ReadPalette( maStrm ); break;
}
}
break;
case Z_Biff5W: // --------------------------------- Z_Biff5W -
{
switch( nOpcode )
{
case 0x0A: // EOF [ 2345]
rNumFmtBfr.CreateScFormats();
rXFBfr.CreateUserStyles();
rNameMgr.ConvertAllTokens();
eAkt = Z_Biff5E;
break;
case 0x18: rNameMgr.ReadName( maStrm ); break;
case 0x1E: rNumFmtBfr.ReadFormat( maStrm ); break;
case 0x22: Rec1904(); break; // 1904 [ 2345]
case 0x31: rFontBfr.ReadFont( maStrm ); break;
case 0x56: break; // BUILTINFMTCNT[ 34 ]
case 0x8D: Hideobj(); break; // HIDEOBJ [ 345]
case 0xDE: Olesize(); break;
case 0xE0: rXFBfr.ReadXF( maStrm ); break;
case 0x0293: rXFBfr.ReadStyle( maStrm ); break;
case 0x041E: rNumFmtBfr.ReadFormat( maStrm ); break;
}
}
break;
case Z_Biff5TPre: // ------------------------------- Z_Biff5Pre -
{
if (nOpcode == EXC_ID5_BOF)
nBofLevel++;
else if( (nOpcode == 0x000A) && nBofLevel )
nBofLevel--;
else if( !nBofLevel ) // don't read chart records
{
switch( nOpcode )
{
case EXC_ID2_DIMENSIONS:
case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
case 0x08: Row25(); break; // ROW [ 2 5]
case 0x0A: // EOF [ 2345]
eAkt = Z_Biff5T;
aIn.SeekGlobalPosition(); // und zurueck an alte Position
break;
case 0x12: SheetProtect(); break; // SHEET PROTECTION
case 0x1A:
case 0x1B: rPageSett.ReadPageBreaks( maStrm ); break;
case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
case 0x21: Array25(); break; // ARRAY [ 2 5]
case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
case 0x41: rTabViewSett.ReadPane( maStrm ); break;
case 0x42: Codepage(); break; // CODEPAGE [ 2345]
case 0x55: DefColWidth(); break;
case 0x7D: Colinfo(); break; // COLINFO [ 345]
case 0x81: Wsbool(); break; // WSBOOL [ 2345]
case 0x8C: Country(); break; // COUNTRY [ 345]
case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45]
case 0x0208: Row34(); break; // ROW [ 34 ]
case 0x0221: Array34(); break; // ARRAY [ 34 ]
case 0x0223: break; // EXTERNNAME [ 34 ]
case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345]
case 0x023E: rTabViewSett.ReadWindow2( maStrm, false );break;
}
}
}
break;
case Z_Biff5T: // --------------------------------- Z_Biff5T -
{
switch( nOpcode )
{
case EXC_ID2_BLANK:
case EXC_ID3_BLANK: ReadBlank(); break;
case EXC_ID2_INTEGER: ReadInteger(); break;
case EXC_ID2_NUMBER:
case EXC_ID3_NUMBER: ReadNumber(); break;
case EXC_ID2_LABEL:
case EXC_ID3_LABEL: ReadLabel(); break;
case EXC_ID2_BOOLERR:
case EXC_ID3_BOOLERR: ReadBoolErr(); break;
case EXC_ID_RK: ReadRk(); break;
case EXC_ID2_FORMULA:
case EXC_ID3_FORMULA:
case EXC_ID4_FORMULA: Formula25(); break;
case EXC_ID_SHRFMLA: Shrfmla(); break;
case 0x0A: Eof(); eAkt = Z_Biff5E; break;
case 0x14:
case 0x15: rPageSett.ReadHeaderFooter( maStrm ); break;
case 0x17: Externsheet(); break; // EXTERNSHEET [ 2345]
case 0x1C: GetCurrSheetDrawing().ReadNote( maStrm );break;
case 0x1D: rTabViewSett.ReadSelection( maStrm ); break;
case 0x23: Externname25(); break; // EXTERNNAME [ 2 5]
case 0x26:
case 0x27:
case 0x28:
case 0x29: rPageSett.ReadMargin( maStrm ); break;
case 0x2A: rPageSett.ReadPrintHeaders( maStrm ); break;
case 0x2B: rPageSett.ReadPrintGridLines( maStrm ); break;
case 0x2F: // FILEPASS [ 2345]
eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
if( eLastErr != ERRCODE_NONE )
eAkt = Z_Ende;
break;
case 0x5D: GetCurrSheetDrawing().ReadObj( maStrm );break;
case 0x83:
case 0x84: rPageSett.ReadCenter( maStrm ); break;
case 0xA0: rTabViewSett.ReadScl( maStrm ); break;
case 0xA1: rPageSett.ReadSetup( maStrm ); break;
case 0xBD: Mulrk(); break; // MULRK [ 5]
case 0xBE: Mulblank(); break; // MULBLANK [ 5]
case 0xD6: Rstring(); break; // RSTRING [ 5]
case 0x00E5: Cellmerging(); break; // #i62300#
case 0x0236: TableOp(); break; // TABLE [ 5]
case EXC_ID5_BOF: // BOF [ 5]
XclTools::SkipSubStream( maStrm );
break;
}
}
break;
case Z_Biff5E: // --------------------------------- Z_Biff5E -
{
switch( nOpcode )
{
case EXC_ID5_BOF: // BOF [ 5]
Bof5();
NewTable();
switch( pExcRoot->eDateiTyp )
{
case Biff5:
case Biff5M4:
eAkt = Z_Biff5TPre; // Shrfmla Prefetch, Row-Prefetch
nBofLevel = 0;
aIn.StoreGlobalPosition(); // store position
break;
case Biff5C: // chart sheet
GetCurrSheetDrawing().ReadTabChart( maStrm );
Eof();
GetTracer().TraceChartOnlySheet();
break;
case Biff5V:
default:
pD->SetVisible( GetCurrScTab(), false );
ePrev = eAkt;
eAkt = Z_Biffn0;
}
OSL_ENSURE( pExcRoot->eDateiTyp != Biff5W,
"+ImportExcel::Read(): Doppel-Whopper-Workbook!" );
break;
}
}
break;
case Z_Biffn0: // --------------------------------- Z_Biffn0 -
{
switch( nOpcode )
{
case 0x0A: // EOF [ 2345]
eAkt = ePrev;
IncCurrScTab();
break;
}
}
break;
case Z_Ende: // ----------------------------------- Z_Ende -
OSL_FAIL( "*ImportExcel::Read(): Not possible state!" );
break;
default: OSL_FAIL( "-ImportExcel::Read(): state forgotten!" );
}
}
if( eLastErr == eERR_OK )
{
pProgress.reset();
GetDocImport().finalize();
AdjustRowHeight();
PostDocLoad();
pD->CalcAfterLoad(false);
const XclImpAddressConverter& rAddrConv = GetAddressConverter();
if( rAddrConv.IsTabTruncated() )
eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
else if( bTabTruncated || rAddrConv.IsRowTruncated() )
eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
else if( rAddrConv.IsColTruncated() )
eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
}
return eLastErr;
}
FltError ImportExcel8::Read()
{
#ifdef EXC_INCL_DUMPER
{
Biff8RecDumper aDumper( GetRoot(), sal_True );
if( aDumper.Dump( aIn ) )
return ERRCODE_ABORT;
}
#endif
// read the entire BIFF8 stream
// don't look too close - this stuff seriously needs to be reworked
XclImpPageSettings& rPageSett = GetPageSettings();
XclImpTabViewSettings& rTabViewSett = GetTabViewSettings();
XclImpPalette& rPal = GetPalette();
XclImpFontBuffer& rFontBfr = GetFontBuffer();
XclImpNumFmtBuffer& rNumFmtBfr = GetNumFmtBuffer();
XclImpXFBuffer& rXFBfr = GetXFBuffer();
XclImpSst& rSst = GetSst();
XclImpTabInfo& rTabInfo = GetTabInfo();
XclImpNameManager& rNameMgr = GetNameManager();
XclImpLinkManager& rLinkMgr = GetLinkManager();
XclImpObjectManager& rObjMgr = GetObjectManager();
// call to GetCurrSheetDrawing() cannot be cached (changes in new sheets)
XclImpCondFormatManager& rCondFmtMgr = GetCondFormatManager();
XclImpValidationManager& rValidMgr = GetValidationManager();
XclImpPivotTableManager& rPTableMgr = GetPivotTableManager();
XclImpWebQueryBuffer& rWQBfr = GetWebQueryBuffer();
bool bInUserView = false; // true = In USERSVIEW(BEGIN|END) record block.
enum XclImpReadState
{
EXC_STATE_BEFORE_GLOBALS, /// Before workbook globals (wait for initial BOF).
EXC_STATE_GLOBALS_PRE, /// Prefetch for workbook globals.
EXC_STATE_GLOBALS, /// Workbook globals.
EXC_STATE_BEFORE_SHEET, /// Before worksheet (wait for new worksheet BOF).
EXC_STATE_SHEET_PRE, /// Prefetch for worksheet.
EXC_STATE_SHEET, /// Worksheet.
EXC_STATE_END /// Stop reading.
};
XclImpReadState eAkt = EXC_STATE_BEFORE_GLOBALS;
FltError eLastErr = eERR_OK;
std::unique_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
/* #i104057# Need to track a base position for progress bar calculation,
because sheet substreams may not be in order of sheets. */
sal_Size nProgressBasePos = 0;
sal_Size nProgressBaseSize = 0;
bool bSheetHasCodeName = false;
std::vector<OUString> aCodeNames;
std::vector < SCTAB > nTabsWithNoCodeName;
sal_uInt16 nRecId = 0;
for (; eAkt != EXC_STATE_END; mnLastRecId = nRecId)
{
if( eAkt == EXC_STATE_BEFORE_SHEET )
{
sal_uInt16 nScTab = GetCurrScTab();
if( nScTab < maSheetOffsets.size() )
{
nProgressBaseSize += (maStrm.GetSvStreamPos() - nProgressBasePos);
nProgressBasePos = maSheetOffsets[ nScTab ];
bool bValid = TryStartNextRecord(aIn, nProgressBasePos);
if (!bValid)
{
// Safeguard ourselves from potential infinite loop.
eAkt = EXC_STATE_END;
}
// import only 256 sheets
if( nScTab > GetScMaxPos().Tab() )
{
if( maStrm.GetRecId() != EXC_ID_EOF )
XclTools::SkipSubStream( maStrm );
// #i29930# show warning box
GetAddressConverter().CheckScTab( nScTab );
eAkt = EXC_STATE_END;
}
else
{
// #i109800# SHEET record may point to any record inside the
// sheet substream
bool bIsBof = maStrm.GetRecId() == EXC_ID5_BOF;
if( bIsBof )
Bof5(); // read the BOF record
else
pExcRoot->eDateiTyp = Biff8; // on missing BOF, assume a standard worksheet
NewTable();
switch( pExcRoot->eDateiTyp )
{
case Biff8: // worksheet
case Biff8M4: // macro sheet
eAkt = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch
// go to next record
if( bIsBof ) maStrm.StartNextRecord();
maStrm.StoreGlobalPosition();
break;
case Biff8C: // chart sheet
GetCurrSheetDrawing().ReadTabChart( maStrm );
Eof();
GetTracer().TraceChartOnlySheet();
break;
case Biff8W: // workbook
OSL_FAIL( "ImportExcel8::Read - double workbook globals" );
SAL_FALLTHROUGH;
case Biff8V: // VB module
default:
// TODO: do not create a sheet in the Calc document
pD->SetVisible( nScTab, false );
XclTools::SkipSubStream( maStrm );
IncCurrScTab();
}
}
}
else
eAkt = EXC_STATE_END;
}
else
aIn.StartNextRecord();
if( !aIn.IsValid() )
{
// #i63591# finalize table if EOF is missing
switch( eAkt )
{
case EXC_STATE_SHEET_PRE:
eAkt = EXC_STATE_SHEET;
aIn.SeekGlobalPosition();
continue; // next iteration in while loop
case EXC_STATE_SHEET:
Eof();
eAkt = EXC_STATE_END;
break;
default:
eAkt = EXC_STATE_END;
}
}
if( eAkt == EXC_STATE_END )
break;
if( eAkt != EXC_STATE_SHEET_PRE && eAkt != EXC_STATE_GLOBALS_PRE )
pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
nRecId = aIn.GetRecId();
/* #i39464# Ignore records between USERSVIEWBEGIN and USERSVIEWEND
completely (user specific view settings). Otherwise view settings
and filters are loaded multiple times, which at least causes
problems in auto-filters. */
switch( nRecId )
{
case EXC_ID_USERSVIEWBEGIN:
OSL_ENSURE( !bInUserView, "ImportExcel8::Read - nested user view settings" );
bInUserView = true;
break;
case EXC_ID_USERSVIEWEND:
OSL_ENSURE( bInUserView, "ImportExcel8::Read - not in user view settings" );
bInUserView = false;
break;
}
if( !bInUserView ) switch( eAkt )
{
// before workbook globals: wait for initial workbook globals BOF
case EXC_STATE_BEFORE_GLOBALS:
{
if( nRecId == EXC_ID5_BOF )
{
OSL_ENSURE( GetBiff() == EXC_BIFF8, "ImportExcel8::Read - wrong BIFF version" );
Bof5();
if( pExcRoot->eDateiTyp == Biff8W )
{
eAkt = EXC_STATE_GLOBALS_PRE;
maStrm.StoreGlobalPosition();
nBdshtTab = 0;
}
else if( pExcRoot->eDateiTyp == Biff8 )
{
// #i62752# possible to have BIFF8 sheet without globals
NewTable();
eAkt = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch
bSheetHasCodeName = false; // reset
aIn.StoreGlobalPosition();
}
}
}
break;
// prefetch for workbook globals
case EXC_STATE_GLOBALS_PRE:
{
switch( nRecId )
{
case EXC_ID_EOF:
case EXC_ID_EXTSST:
/* #i56376# evil hack: if EOF for globals is missing,
simulate it. This hack works only for the bugdoc
given in the issue, where the sheet substreams
start directly after the EXTSST record. A future
implementation should be more robust against
missing EOFs. */
if( (nRecId == EXC_ID_EOF) ||
((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) )
{
eAkt = EXC_STATE_GLOBALS;
aIn.SeekGlobalPosition();
}
break;
case 0x12: DocProtect(); break; // PROTECT [ 5678]
case 0x13: DocPasssword(); break;
case 0x19: WinProtection(); break;
case 0x2F: // FILEPASS [ 2345 ]
eLastErr = XclImpDecryptHelper::ReadFilepass( maStrm );
if( eLastErr != ERRCODE_NONE )
eAkt = EXC_STATE_END;
break;
case EXC_ID_FILESHARING: ReadFileSharing(); break;
case 0x3D: Window1(); break;
case 0x42: Codepage(); break; // CODEPAGE [ 2345 ]
case 0x85: Boundsheet(); break; // BOUNDSHEET [ 5 ]
case 0x8C: Country(); break; // COUNTRY [ 345 ]
// PALETTE follows XFs, but already needed while reading the XFs
case EXC_ID_PALETTE: rPal.ReadPalette( maStrm ); break;
}
}
break;
// workbook globals
case EXC_STATE_GLOBALS:
{
switch( nRecId )
{
case EXC_ID_EOF:
case EXC_ID_EXTSST:
/* #i56376# evil hack: if EOF for globals is missing,
simulate it. This hack works only for the bugdoc
given in the issue, where the sheet substreams
start directly after the EXTSST record. A future
implementation should be more robust against
missing EOFs. */
if( (nRecId == EXC_ID_EOF) ||
((nRecId == EXC_ID_EXTSST) && (maStrm.GetNextRecId() == EXC_ID5_BOF)) )
{
rNumFmtBfr.CreateScFormats();
rXFBfr.CreateUserStyles();
rPTableMgr.ReadPivotCaches( maStrm );
rNameMgr.ConvertAllTokens();
eAkt = EXC_STATE_BEFORE_SHEET;
}
break;
case 0x0E: Precision(); break; // PRECISION
case 0x22: Rec1904(); break; // 1904 [ 2345 ]
case 0x56: break; // BUILTINFMTCNT[ 34 ]
case 0x8D: Hideobj(); break; // HIDEOBJ [ 345 ]
case 0xD3: SetHasBasic(); break;
case 0xDE: Olesize(); break;
case EXC_ID_CODENAME: ReadCodeName( aIn, true ); break;
case EXC_ID_USESELFS: ReadUsesElfs(); break;
case EXC_ID2_FONT: rFontBfr.ReadFont( maStrm ); break;
case EXC_ID4_FORMAT: rNumFmtBfr.ReadFormat( maStrm ); break;
case EXC_ID5_XF: rXFBfr.ReadXF( maStrm ); break;
case EXC_ID_STYLE: rXFBfr.ReadStyle( maStrm ); break;
case EXC_ID_SST: rSst.ReadSst( maStrm ); break;
case EXC_ID_TABID: rTabInfo.ReadTabid( maStrm ); break;
case EXC_ID_NAME: rNameMgr.ReadName( maStrm ); break;
case EXC_ID_EXTERNSHEET: rLinkMgr.ReadExternsheet( maStrm ); break;
case EXC_ID_SUPBOOK: rLinkMgr.ReadSupbook( maStrm ); break;
case EXC_ID_XCT: rLinkMgr.ReadXct( maStrm ); break;
case EXC_ID_CRN: rLinkMgr.ReadCrn( maStrm ); break;
case EXC_ID_EXTERNNAME: rLinkMgr.ReadExternname( maStrm, pFormConv ); break;
case EXC_ID_MSODRAWINGGROUP:rObjMgr.ReadMsoDrawingGroup( maStrm ); break;
case EXC_ID_SXIDSTM: rPTableMgr.ReadSxidstm( maStrm ); break;
case EXC_ID_SXVS: rPTableMgr.ReadSxvs( maStrm ); break;
case EXC_ID_DCONREF: rPTableMgr.ReadDconref( maStrm ); break;
case EXC_ID_DCONNAME: rPTableMgr.ReadDConName( maStrm ); break;
}
}
break;
// prefetch for worksheet
case EXC_STATE_SHEET_PRE:
{
switch( nRecId )
{
// skip chart substream
case EXC_ID2_BOF:
case EXC_ID3_BOF:
case EXC_ID4_BOF:
case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
case EXC_ID_WINDOW2: rTabViewSett.ReadWindow2( maStrm, false );break;
case EXC_ID_SCL: rTabViewSett.ReadScl( maStrm ); break;
case EXC_ID_PANE: rTabViewSett.ReadPane( maStrm ); break;
case EXC_ID_SELECTION: rTabViewSett.ReadSelection( maStrm ); break;
case EXC_ID2_DIMENSIONS:
case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
case EXC_ID_CODENAME: ReadCodeName( aIn, false ); bSheetHasCodeName = true; break;
case 0x0A: // EOF [ 2345 ]
{
eAkt = EXC_STATE_SHEET;
OUString sName;
GetDoc().GetName( GetCurrScTab(), sName );
if ( !bSheetHasCodeName )
{
nTabsWithNoCodeName.push_back( GetCurrScTab() );
OSL_TRACE("No Codename for %d", GetCurrScTab() );
}
else
{
OUString sCodeName;
GetDoc().GetCodeName( GetCurrScTab(), sCodeName );
OSL_TRACE("Have CodeName %s for SheetName %s",
OUStringToOString( sCodeName, RTL_TEXTENCODING_UTF8 ).getStr(), OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() );
aCodeNames.push_back( sCodeName );
}
bSheetHasCodeName = false; // reset
aIn.SeekGlobalPosition(); // and back to old position
break;
}
case 0x12: SheetProtect(); break;
case 0x13: SheetPassword(); break;
case 0x42: Codepage(); break; // CODEPAGE [ 2345 ]
case 0x55: DefColWidth(); break;
case 0x7D: Colinfo(); break; // COLINFO [ 345 ]
case 0x81: Wsbool(); break; // WSBOOL [ 2345 ]
case 0x8C: Country(); break; // COUNTRY [ 345 ]
case 0x99: Standardwidth(); break; // STANDARDWIDTH[ 45 ]
case 0x9B: FilterMode(); break; // FILTERMODE
case EXC_ID_AUTOFILTERINFO: AutoFilterInfo(); break;// AUTOFILTERINFO
case EXC_ID_AUTOFILTER: AutoFilter(); break; // AUTOFILTER
case 0x0208: Row34(); break; // ROW [ 34 ]
case EXC_ID2_ARRAY:
case EXC_ID3_ARRAY: Array34(); break; // ARRAY [ 34 ]
case 0x0225: Defrowheight345();break;//DEFAULTROWHEI[ 345 ]
case 0x0867: FeatHdr(); break; // FEATHDR
case 0x0868: Feat(); break; // FEAT
}
}
break;
// worksheet
case EXC_STATE_SHEET:
{
switch( nRecId )
{
// skip unknown substreams
case EXC_ID2_BOF:
case EXC_ID3_BOF:
case EXC_ID4_BOF:
case EXC_ID5_BOF: XclTools::SkipSubStream( maStrm ); break;
case EXC_ID_EOF: Eof(); eAkt = EXC_STATE_BEFORE_SHEET; break;
case EXC_ID2_BLANK:
case EXC_ID3_BLANK: ReadBlank(); break;
case EXC_ID2_INTEGER: ReadInteger(); break;
case EXC_ID2_NUMBER:
case EXC_ID3_NUMBER: ReadNumber(); break;
case EXC_ID2_LABEL:
case EXC_ID3_LABEL: ReadLabel(); break;
case EXC_ID2_BOOLERR:
case EXC_ID3_BOOLERR: ReadBoolErr(); break;
case EXC_ID_RK: ReadRk(); break;
case EXC_ID2_FORMULA:
case EXC_ID3_FORMULA:
case EXC_ID4_FORMULA: Formula25(); break;
case EXC_ID_SHRFMLA: Shrfmla(); break;
case 0x000C: Calccount(); break; // CALCCOUNT
case 0x0010: Delta(); break; // DELTA
case 0x0011: Iteration(); break; // ITERATION
case 0x007E:
case 0x00AE: Scenman(); break; // SCENMAN
case 0x00AF: Scenario(); break; // SCENARIO
case 0x00BD: Mulrk(); break; // MULRK [ 5 ]
case 0x00BE: Mulblank(); break; // MULBLANK [ 5 ]
case 0x00D6: Rstring(); break; // RSTRING [ 5 ]
case 0x00E5: Cellmerging(); break; // CELLMERGING
case 0x00FD: Labelsst(); break; // LABELSST [ 8 ]
case 0x0236: TableOp(); break; // TABLE
case EXC_ID_HORPAGEBREAKS:
case EXC_ID_VERPAGEBREAKS: rPageSett.ReadPageBreaks( maStrm ); break;
case EXC_ID_HEADER:
case EXC_ID_FOOTER: rPageSett.ReadHeaderFooter( maStrm ); break;
case EXC_ID_LEFTMARGIN:
case EXC_ID_RIGHTMARGIN:
case EXC_ID_TOPMARGIN:
case EXC_ID_BOTTOMMARGIN: rPageSett.ReadMargin( maStrm ); break;
case EXC_ID_PRINTHEADERS: rPageSett.ReadPrintHeaders( maStrm ); break;
case EXC_ID_PRINTGRIDLINES: rPageSett.ReadPrintGridLines( maStrm ); break;
case EXC_ID_HCENTER:
case EXC_ID_VCENTER: rPageSett.ReadCenter( maStrm ); break;
case EXC_ID_SETUP: rPageSett.ReadSetup( maStrm ); break;
case EXC_ID8_IMGDATA: rPageSett.ReadImgData( maStrm ); break;
case EXC_ID_MSODRAWING: GetCurrSheetDrawing().ReadMsoDrawing( maStrm ); break;
// #i61786# weird documents: OBJ without MSODRAWING -> read in BIFF5 format
case EXC_ID_OBJ: GetCurrSheetDrawing().ReadObj( maStrm ); break;
case EXC_ID_NOTE: GetCurrSheetDrawing().ReadNote( maStrm ); break;
case EXC_ID_HLINK: XclImpHyperlink::ReadHlink( maStrm ); break;
case EXC_ID_LABELRANGES: XclImpLabelranges::ReadLabelranges( maStrm ); break;
case EXC_ID_CONDFMT: rCondFmtMgr.ReadCondfmt( maStrm ); break;
case EXC_ID_CF: rCondFmtMgr.ReadCF( maStrm ); break;
case EXC_ID_DVAL: XclImpValidationManager::ReadDval( maStrm ); break;
case EXC_ID_DV: rValidMgr.ReadDV( maStrm ); break;
case EXC_ID_QSI: rWQBfr.ReadQsi( maStrm ); break;
case EXC_ID_WQSTRING: rWQBfr.ReadWqstring( maStrm ); break;
case EXC_ID_PQRY: rWQBfr.ReadParamqry( maStrm ); break;
case EXC_ID_WQSETT: rWQBfr.ReadWqsettings( maStrm ); break;
case EXC_ID_WQTABLES: rWQBfr.ReadWqtables( maStrm ); break;
case EXC_ID_SXVIEW: rPTableMgr.ReadSxview( maStrm ); break;
case EXC_ID_SXVD: rPTableMgr.ReadSxvd( maStrm ); break;
case EXC_ID_SXVI: rPTableMgr.ReadSxvi( maStrm ); break;
case EXC_ID_SXIVD: rPTableMgr.ReadSxivd( maStrm ); break;
case EXC_ID_SXPI: rPTableMgr.ReadSxpi( maStrm ); break;
case EXC_ID_SXDI: rPTableMgr.ReadSxdi( maStrm ); break;
case EXC_ID_SXVDEX: rPTableMgr.ReadSxvdex( maStrm ); break;
case EXC_ID_SXEX: rPTableMgr.ReadSxex( maStrm ); break;
case EXC_ID_SHEETEXT: rTabViewSett.ReadTabBgColor( maStrm, rPal ); break;
case EXC_ID_SXVIEWEX9: rPTableMgr.ReadSxViewEx9( maStrm ); break;
}
}
break;
default:;
}
}
if( eLastErr == eERR_OK )
{
// In some strange circumstances a the codename might be missing
// # Create any missing Sheet CodeNames
std::vector < SCTAB >::iterator it_end = nTabsWithNoCodeName.end();
for ( std::vector < SCTAB >::iterator it = nTabsWithNoCodeName.begin(); it != it_end; ++it )
{
SCTAB nTab = 1;
OSL_TRACE("Trying to find suitable codename for %d", *it );
while ( true )
{
OUStringBuffer aBuf;
aBuf.append("Sheet");
aBuf.append(static_cast<sal_Int32>(nTab++));
OUString sTmpName = aBuf.makeStringAndClear();
std::vector<OUString>::iterator codeName_It = aCodeNames.begin();
std::vector<OUString>::iterator codeName_It_end = aCodeNames.end();
// search for codename
for ( ; codeName_It != codeName_It_end; ++codeName_It )
{
if ( *codeName_It == sTmpName )
break;
}
if ( codeName_It == codeName_It_end ) // generated codename not found
{
OSL_TRACE("Using generated codename %s", OUStringToOString( sTmpName, RTL_TEXTENCODING_UTF8 ).getStr() );
// Set new codename
GetDoc().SetCodeName( *it, sTmpName );
// Record newly used codename
aCodeNames.push_back(sTmpName);
// Record those we have created so they can be created in
// basic
maAutoGeneratedCodeNames.push_back( sTmpName );
break;
}
}
}
// #i45843# Convert pivot tables before calculation, so they are available
// for the GETPIVOTDATA function.
if( GetBiff() == EXC_BIFF8 )
GetPivotTableManager().ConvertPivotTables();
ScDocumentImport& rDoc = GetDocImport();
rDoc.finalize();
pProgress.reset();
#if 0
// Excel documents look much better without this call; better in the
// sense that the row heights are identical to the original heights in
// Excel.
if (pD->IsAdjustHeightEnabled())
AdjustRowHeight();
#endif
PostDocLoad();
pD->CalcAfterLoad(false);
// import change tracking data
XclImpChangeTrack aImpChTr( GetRoot(), maStrm );
aImpChTr.Apply();
const XclImpAddressConverter& rAddrConv = GetAddressConverter();
if( rAddrConv.IsTabTruncated() )
eLastErr = SCWARN_IMPORT_SHEET_OVERFLOW;
else if( bTabTruncated || rAddrConv.IsRowTruncated() )
eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
else if( rAddrConv.IsColTruncated() )
eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
if( GetBiff() == EXC_BIFF8 )
GetPivotTableManager().MaybeRefreshPivotTables();
}
return eLastErr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|