1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26
27 #include "imp_op.hxx"
28
29 #include <filter/msfilter/countryid.hxx>
30
31 #include "scitems.hxx"
32 #include <editeng/eeitem.hxx>
33
34 #include <editeng/editdata.hxx>
35 #include <editeng/editeng.hxx>
36 #include <editeng/editobj.hxx>
37 #include <editeng/editstat.hxx>
38 #include <editeng/flditem.hxx>
39 #include <svx/pageitem.hxx>
40 #include <editeng/colritem.hxx>
41 #include <sfx2/printer.hxx>
42 #include <sfx2/docfile.hxx>
43 #include <svl/zforlist.hxx>
44
45 #include <sfx2/objsh.hxx>
46 #include "docuno.hxx"
47
48 #include "cell.hxx"
49 #include "document.hxx"
50 #include "rangenam.hxx"
51 #include "compiler.hxx"
52 #include "patattr.hxx"
53 #include "attrib.hxx"
54 #include "globstr.hrc"
55 #include "global.hxx"
56 #include "markdata.hxx"
57 #include "olinetab.hxx"
58 #include "stlsheet.hxx"
59 #include "stlpool.hxx"
60 #include "compiler.hxx"
61 #include "viewopti.hxx"
62 #include "docoptio.hxx"
63 #include "scextopt.hxx"
64 #include "editutil.hxx"
65 #include "filtopt.hxx"
66 #include "scerrors.hxx"
67 #include "unonames.hxx"
68 #include "paramisc.hxx"
69 #include "postit.hxx"
70
71 #include "fapihelper.hxx"
72 #include "xltools.hxx"
73 #include "xltable.hxx"
74 #include "xlview.hxx"
75 #include "xltracer.hxx"
76 #include "xihelper.hxx"
77 #include "xipage.hxx"
78 #include "xiview.hxx"
79 #include "xilink.hxx"
80 #include "xiescher.hxx"
81 #include "xicontent.hxx"
82
83 #include "excimp8.hxx"
84 #include "excform.hxx"
85
86 #if defined( WNT )
87 #include <math.h>
88 #else
89 #include <stdlib.h>
90 #endif
91
92 using namespace ::com::sun::star;
93
94
95 const double ImportExcel::fExcToTwips =
96 ( double ) TWIPS_PER_CHAR / 256.0;
97
98
ImportTyp(ScDocument * pDoc,CharSet eQ)99 ImportTyp::ImportTyp( ScDocument* pDoc, CharSet eQ )
100 {
101 eQuellChar = eQ;
102 pD = pDoc;
103 }
104
105
~ImportTyp()106 ImportTyp::~ImportTyp()
107 {
108 }
109
110
Read()111 FltError ImportTyp::Read()
112 {
113 return eERR_INTERN;
114 }
115
116
ImportExcel(XclImpRootData & rImpData,SvStream & rStrm)117 ImportExcel::ImportExcel( XclImpRootData& rImpData, SvStream& rStrm ):
118 ImportTyp( &rImpData.mrDoc, rImpData.meTextEnc ),
119 XclImpRoot( rImpData ),
120 maStrm( rStrm, GetRoot() ),
121 aIn( maStrm ),
122 maScOleSize( ScAddress::INITIALIZE_INVALID ),
123 mnLastRefIdx( 0 ),
124 mnIxfeIndex( 0 ),
125 mbBiff2HasXfs( false ),
126 mbBiff2HasXfsValid( false )
127 {
128 nBdshtTab = 0;
129
130 // Root-Daten fuellen - nach new's ohne Root als Parameter
131 pExcRoot = &GetOldRoot();
132 pExcRoot->pIR = this; // ExcRoot -> XclImpRoot
133 pExcRoot->eDateiTyp = BiffX;
134 pExcRoot->pExtSheetBuff = new ExtSheetBuffer( pExcRoot ); //&aExtSheetBuff;
135 pExcRoot->pShrfmlaBuff = new ShrfmlaBuffer( pExcRoot ); //&aShrfrmlaBuff;
136 pExcRoot->pExtNameBuff = new ExtNameBuff ( *this );
137
138 pExtNameBuff = new NameBuffer( pExcRoot ); //#94039# prevent empty rootdata
139 pExtNameBuff->SetBase( 1 );
140
141 pOutlineListBuffer = new XclImpOutlineListBuffer( );
142
143 // ab Biff8
144 pFormConv = pExcRoot->pFmlaConverter = new ExcelToSc( GetRoot() );
145
146 bTabTruncated = sal_False;
147
148 // Excel-Dokument per Default auf 31.12.1899, entspricht Excel-Einstellungen mit 1.1.1900
149 ScDocOptions aOpt = pD->GetDocOptions();
150 aOpt.SetDate( 30, 12, 1899 );
151 pD->SetDocOptions( aOpt );
152 pD->GetFormatTable()->ChangeNullDate( 30, 12, 1899 );
153
154 ScDocOptions aDocOpt( pD->GetDocOptions() );
155 aDocOpt.SetIgnoreCase( sal_True ); // always in Excel
156 aDocOpt.SetFormulaRegexEnabled( sal_False ); // regular expressions? what's that?
157 aDocOpt.SetLookUpColRowNames( sal_False ); // default: no natural language refs
158 pD->SetDocOptions( aDocOpt );
159 }
160
161
~ImportExcel(void)162 ImportExcel::~ImportExcel( void )
163 {
164 GetDoc().SetSrcCharSet( GetTextEncoding() );
165
166 delete pExtNameBuff;
167
168 delete pOutlineListBuffer;
169
170 delete pFormConv;
171 }
172
173
ReadFileSharing()174 void ImportExcel::ReadFileSharing()
175 {
176 sal_uInt16 nRecommendReadOnly, nPasswordHash;
177 maStrm >> nRecommendReadOnly >> nPasswordHash;
178
179 if( (nRecommendReadOnly != 0) || (nPasswordHash != 0) )
180 {
181 if( SfxItemSet* pItemSet = GetMedium().GetItemSet() )
182 pItemSet->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
183
184 if( SfxObjectShell* pShell = GetDocShell() )
185 {
186 if( nRecommendReadOnly != 0 )
187 pShell->SetLoadReadonly( sal_True );
188 if( nPasswordHash != 0 )
189 pShell->SetModifyPasswordHash( nPasswordHash );
190 }
191 }
192 }
193
ReadXFIndex(const ScAddress & rScPos,bool bBiff2)194 sal_uInt16 ImportExcel::ReadXFIndex( const ScAddress& rScPos, bool bBiff2 )
195 {
196 sal_uInt16 nXFIdx = 0;
197 if( bBiff2 )
198 {
199 /* #i71453# On first call, check if the file contains XF records (by
200 trying to access the first XF with index 0). If there are no XFs,
201 the explicit formatting information contained in each cell record
202 will be used instead. */
203 if( !mbBiff2HasXfsValid )
204 {
205 mbBiff2HasXfsValid = true;
206 mbBiff2HasXfs = GetXFBuffer().GetXF( 0 ) != 0;
207 }
208 // read formatting information (includes the XF identifier)
209 sal_uInt8 nFlags1, nFlags2, nFlags3;
210 maStrm >> nFlags1 >> nFlags2 >> nFlags3;
211 /* If the file contains XFs, extract and set the XF identifier,
212 otherwise get the explicit formatting. */
213 if( mbBiff2HasXfs )
214 {
215 nXFIdx = ::extract_value< sal_uInt16 >( nFlags1, 0, 6 );
216 /* If the identifier is equal to 63, then the real identifier is
217 contained in the preceding IXFE record (stored in mnBiff2XfId). */
218 if( nXFIdx == 63 )
219 nXFIdx = mnIxfeIndex;
220 }
221 else
222 {
223 /* Let the XclImpXF class do the conversion of the imported
224 formatting. The XF buffer is empty, therefore will not do any
225 conversion based on the XF index later on. */
226 XclImpXF::ApplyPatternForBiff2CellFormat( GetRoot(), rScPos, nFlags1, nFlags2, nFlags3 );
227 }
228 }
229 else
230 aIn >> nXFIdx;
231 return nXFIdx;
232 }
233
ReadDimensions()234 void ImportExcel::ReadDimensions()
235 {
236 XclRange aXclUsedArea( ScAddress::UNINITIALIZED );
237 if( (maStrm.GetRecId() == EXC_ID2_DIMENSIONS) || (GetBiff() <= EXC_BIFF5) )
238 {
239 maStrm >> aXclUsedArea;
240 if( (aXclUsedArea.GetColCount() > 1) && (aXclUsedArea.GetRowCount() > 1) )
241 {
242 // Excel stores first unused row/column index
243 --aXclUsedArea.maLast.mnCol;
244 --aXclUsedArea.maLast.mnRow;
245 // create the Calc range
246 SCTAB nScTab = GetCurrScTab();
247 ScRange& rScUsedArea = GetExtDocOptions().GetOrCreateTabSettings( nScTab ).maUsedArea;
248 GetAddressConverter().ConvertRange( rScUsedArea, aXclUsedArea, nScTab, nScTab, false );
249 // if any error occurs in ConvertRange(), rScUsedArea keeps untouched
250 }
251 }
252 else
253 {
254 sal_uInt32 nXclRow1, nXclRow2;
255 maStrm >> nXclRow1 >> nXclRow2 >> aXclUsedArea.maFirst.mnCol >> aXclUsedArea.maLast.mnCol;
256 if( (nXclRow1 < nXclRow2) && (aXclUsedArea.GetColCount() > 1) &&
257 (nXclRow1 <= static_cast< sal_uInt32 >( GetScMaxPos().Row() )) )
258 {
259 // Excel stores first unused row/column index
260 --nXclRow2;
261 --aXclUsedArea.maLast.mnCol;
262 // convert row indexes to 16-bit values
263 aXclUsedArea.maFirst.mnRow = static_cast< sal_uInt16 >( nXclRow1 );
264 aXclUsedArea.maLast.mnRow = limit_cast< sal_uInt16 >( nXclRow2, aXclUsedArea.maFirst.mnRow, SAL_MAX_UINT16 );
265 // create the Calc range
266 SCTAB nScTab = GetCurrScTab();
267 ScRange& rScUsedArea = GetExtDocOptions().GetOrCreateTabSettings( nScTab ).maUsedArea;
268 GetAddressConverter().ConvertRange( rScUsedArea, aXclUsedArea, nScTab, nScTab, false );
269 // if any error occurs in ConvertRange(), rScUsedArea keeps untouched
270 }
271 }
272 }
273
ReadBlank()274 void ImportExcel::ReadBlank()
275 {
276 XclAddress aXclPos;
277 aIn >> aXclPos;
278
279 ScAddress aScPos( ScAddress::UNINITIALIZED );
280 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
281 {
282 sal_uInt16 nXFIdx = ReadXFIndex( aScPos, maStrm.GetRecId() == EXC_ID2_BLANK );
283
284 GetXFRangeBuffer().SetBlankXF( aScPos, nXFIdx );
285 }
286 }
287
ReadInteger()288 void ImportExcel::ReadInteger()
289 {
290 XclAddress aXclPos;
291 maStrm >> aXclPos;
292
293 ScAddress aScPos( ScAddress::UNINITIALIZED );
294 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
295 {
296 sal_uInt16 nXFIdx = ReadXFIndex( aScPos, true );
297 sal_uInt16 nValue;
298 maStrm >> nValue;
299
300 GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
301 GetDoc().PutCell( aScPos, new ScValueCell( nValue ) );
302 }
303 }
304
ReadNumber()305 void ImportExcel::ReadNumber()
306 {
307 XclAddress aXclPos;
308 maStrm >> aXclPos;
309
310 ScAddress aScPos( ScAddress::UNINITIALIZED );
311 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
312 {
313 sal_uInt16 nXFIdx = ReadXFIndex( aScPos, maStrm.GetRecId() == EXC_ID2_NUMBER );
314 double fValue;
315 maStrm >> fValue;
316
317 GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
318 GetDoc().PutCell( aScPos, new ScValueCell( fValue ) );
319 }
320 }
321
ReadLabel()322 void ImportExcel::ReadLabel()
323 {
324 XclAddress aXclPos;
325 maStrm >> aXclPos;
326
327 ScAddress aScPos( ScAddress::UNINITIALIZED );
328 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
329 {
330 /* Record ID BIFF XF type String type
331 0x0004 2-7 3 byte 8-bit length, byte string
332 0x0004 8 3 byte 16-bit length, unicode string
333 0x0204 2-7 2 byte 16-bit length, byte string
334 0x0204 8 2 byte 16-bit length, unicode string */
335 bool bBiff2 = maStrm.GetRecId() == EXC_ID2_LABEL;
336 sal_uInt16 nXFIdx = ReadXFIndex( aScPos, bBiff2 );
337 XclStrFlags nFlags = (bBiff2 && (GetBiff() <= EXC_BIFF5)) ? EXC_STR_8BITLENGTH : EXC_STR_DEFAULT;
338 XclImpString aString;
339
340 // #i63105# use text encoding from FONT record
341 rtl_TextEncoding eOldTextEnc = GetTextEncoding();
342 if( const XclImpFont* pFont = GetXFBuffer().GetFont( nXFIdx ) )
343 SetTextEncoding( pFont->GetFontEncoding() );
344 aString.Read( maStrm, nFlags );
345 SetTextEncoding( eOldTextEnc );
346
347 GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
348 if( ScBaseCell* pCell = XclImpStringHelper::CreateCell( GetRoot(), aString, nXFIdx ) )
349 GetDoc().PutCell( aScPos, pCell );
350 }
351 }
352
ReadBoolErr()353 void ImportExcel::ReadBoolErr()
354 {
355 XclAddress aXclPos;
356 maStrm >> aXclPos;
357
358 ScAddress aScPos( ScAddress::UNINITIALIZED );
359 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
360 {
361 sal_uInt16 nXFIdx = ReadXFIndex( aScPos, maStrm.GetRecId() == EXC_ID2_BOOLERR );
362 sal_uInt8 nValue, nType;
363 maStrm >> nValue >> nType;
364
365 if( nType == EXC_BOOLERR_BOOL )
366 GetXFRangeBuffer().SetBoolXF( aScPos, nXFIdx );
367 else
368 GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
369
370 double fValue;
371 const ScTokenArray* pScTokArr = ErrorToFormula( nType, nValue, fValue );
372 ScFormulaCell* pCell = new ScFormulaCell( pD, aScPos, pScTokArr );
373 pCell->SetHybridDouble( fValue );
374 GetDoc().PutCell( aScPos, pCell );
375 }
376 }
377
ReadRk()378 void ImportExcel::ReadRk()
379 {
380 XclAddress aXclPos;
381 maStrm >> aXclPos;
382
383 ScAddress aScPos( ScAddress::UNINITIALIZED );
384 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
385 {
386 sal_uInt16 nXFIdx = ReadXFIndex( aScPos, false );
387 sal_Int32 nRk;
388 maStrm >> nRk;
389
390 GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
391 GetDoc().PutCell( aScPos, new ScValueCell( XclTools::GetDoubleFromRK( nRk ) ) );
392 }
393 }
394
395
Window1()396 void ImportExcel::Window1()
397 {
398 GetDocViewSettings().ReadWindow1( maStrm );
399 }
400
401
402
403
Row25(void)404 void ImportExcel::Row25( void )
405 {
406 sal_uInt16 nRow, nRowHeight;
407
408 aIn >> nRow;
409 aIn.Ignore( 4 ); // Mic und Mac ueberspringen
410
411 if( ValidRow( nRow ) )
412 {
413 aIn >> nRowHeight; // direkt in Twips angegeben
414 aIn.Ignore( 2 );
415
416 if( GetBiff() == EXC_BIFF2 )
417 {// -------------------- BIFF2
418 pColRowBuff->SetHeight( nRow, nRowHeight );
419 }
420 else
421 {// -------------------- BIFF5
422 sal_uInt16 nGrbit;
423
424 aIn.Ignore( 2 ); // reserved
425 aIn >> nGrbit;
426
427 sal_uInt8 nLevel = ::extract_value< sal_uInt8 >( nGrbit, 0, 3 );
428 pRowOutlineBuff->SetLevel( nRow, nLevel,
429 ::get_flag( nGrbit, EXC_ROW_COLLAPSED ), ::get_flag( nGrbit, EXC_ROW_HIDDEN ) );
430
431 pColRowBuff->SetRowSettings( nRow, nRowHeight, nGrbit );
432 }
433 }
434 }
435
436
Bof2(void)437 void ImportExcel::Bof2( void )
438 {
439 sal_uInt16 nSubType;
440 maStrm.DisableDecryption();
441 maStrm.Ignore( 2 );
442 maStrm >> nSubType;
443
444 if( nSubType == 0x0020 ) // Chart
445 pExcRoot->eDateiTyp = Biff2C;
446 else if( nSubType == 0x0040 ) // Macro
447 pExcRoot->eDateiTyp = Biff2M;
448 else // #i51490# Excel interprets invalid indexes as worksheet
449 pExcRoot->eDateiTyp = Biff2;
450 }
451
452
Eof(void)453 void ImportExcel::Eof( void )
454 {
455 // POST: darf nur nach einer GUELTIGEN Tabelle gerufen werden!
456 EndSheet();
457 IncCurrScTab();
458 }
459
460
SheetPassword(void)461 void ImportExcel::SheetPassword( void )
462 {
463 if (GetRoot().GetBiff() != EXC_BIFF8)
464 return;
465
466 GetRoot().GetSheetProtectBuffer().ReadPasswordHash( aIn, GetCurrScTab() );
467 }
468
469
Externsheet(void)470 void ImportExcel::Externsheet( void )
471 {
472 String aUrl, aTabName;
473 bool bSameWorkBook;
474 String aEncodedUrl( aIn.ReadByteString( false ) );
475 XclImpUrlHelper::DecodeUrl( aUrl, aTabName, bSameWorkBook, *pExcRoot->pIR, aEncodedUrl );
476 mnLastRefIdx = pExcRoot->pExtSheetBuff->Add( aUrl, aTabName, bSameWorkBook );
477 }
478
479
WinProtection(void)480 void ImportExcel:: WinProtection( void )
481 {
482 if (GetRoot().GetBiff() != EXC_BIFF8)
483 return;
484
485 GetRoot().GetDocProtectBuffer().ReadWinProtect( aIn );
486 }
487
488
Columndefault(void)489 void ImportExcel::Columndefault( void )
490 {// Default Cell Attributes
491 sal_uInt16 nColMic, nColMac;
492 sal_uInt8 nOpt0;
493
494 aIn >> nColMic >> nColMac;
495
496 DBG_ASSERT( aIn.GetRecLeft() == (sal_Size)(nColMac - nColMic) * 3 + 2,
497 "ImportExcel::Columndefault - wrong record size" );
498
499 nColMac--;
500
501 if( nColMac > MAXCOL )
502 nColMac = static_cast<sal_uInt16>(MAXCOL);
503
504 for( sal_uInt16 nCol = nColMic ; nCol <= nColMac ; nCol++ )
505 {
506 aIn >> nOpt0;
507 aIn.Ignore( 2 ); // nur 0. Attribut-Byte benutzt
508
509 if( nOpt0 & 0x80 ) // Col hidden?
510 pColRowBuff->HideCol( nCol );
511 }
512 }
513
514
Array25(void)515 void ImportExcel::Array25( void )
516 {
517 sal_uInt16 nFirstRow, nLastRow, nFormLen;
518 sal_uInt8 nFirstCol, nLastCol;
519
520 aIn >> nFirstRow >> nLastRow >> nFirstCol >> nLastCol;
521
522 if( GetBiff() == EXC_BIFF2 )
523 {// BIFF2
524 aIn.Ignore( 1 );
525 nFormLen = aIn.ReaduInt8();
526 }
527 else
528 {// BIFF5
529 aIn.Ignore( 6 );
530 aIn >> nFormLen;
531 }
532
533 if( ValidColRow( nLastCol, nLastRow ) )
534 {
535 // jetzt steht Lesemarke auf Formel, Laenge in nFormLen
536 const ScTokenArray* pErgebnis;
537
538 pFormConv->Reset( ScAddress( static_cast<SCCOL>(nFirstCol),
539 static_cast<SCROW>(nFirstRow), GetCurrScTab() ) );
540 pFormConv->Convert( pErgebnis, maStrm, nFormLen, true, FT_CellFormula);
541
542 DBG_ASSERT( pErgebnis, "*ImportExcel::Array25(): ScTokenArray ist NULL!" );
543
544 ScMarkData aMarkData;
545 aMarkData.SelectOneTable( GetCurrScTab() );
546 pD->InsertMatrixFormula( static_cast<SCCOL>(nFirstCol),
547 static_cast<SCROW>(nFirstRow), static_cast<SCCOL>(nLastCol),
548 static_cast<SCROW>(nLastRow), aMarkData, EMPTY_STRING,
549 pErgebnis );
550 }
551 }
552
553
Rec1904(void)554 void ImportExcel::Rec1904( void )
555 {
556 sal_uInt16 n1904;
557
558 aIn >> n1904;
559
560 if( n1904 )
561 {// 1904 date system
562 ScDocOptions aOpt = pD->GetDocOptions();
563 aOpt.SetDate( 1, 1, 1904 );
564 pD->SetDocOptions( aOpt );
565 pD->GetFormatTable()->ChangeNullDate( 1, 1, 1904 );
566 }
567 }
568
569
Externname25(void)570 void ImportExcel::Externname25( void )
571 {
572 sal_uInt32 nRes;
573 sal_uInt16 nOpt;
574
575 aIn >> nOpt >> nRes;
576
577 String aName( aIn.ReadByteString( sal_False ) );
578
579 if( ( nOpt & 0x0001 ) || ( ( nOpt & 0xFFFE ) == 0x0000 ) )
580 {// external name
581 ScfTools::ConvertToScDefinedName( aName );
582 pExcRoot->pExtNameBuff->AddName( aName, mnLastRefIdx );
583 }
584 else if( nOpt & 0x0010 )
585 {// ole link
586 pExcRoot->pExtNameBuff->AddOLE( aName, mnLastRefIdx, nRes ); // nRes is storage ID
587 }
588 else
589 {// dde link
590 pExcRoot->pExtNameBuff->AddDDE( aName, mnLastRefIdx );
591 }
592 }
593
594
Colwidth(void)595 void ImportExcel::Colwidth( void )
596 {// Column Width
597 sal_uInt8 nColFirst, nColLast;
598 sal_uInt16 nColWidth;
599
600 aIn >> nColFirst >> nColLast >> nColWidth;
601
602 //! TODO: add a check for the unlikely case of changed MAXCOL (-> XclImpAddressConverter)
603 // if( nColLast > MAXCOL )
604 // nColLast = static_cast<sal_uInt16>(MAXCOL);
605
606 sal_uInt16 nScWidth = XclTools::GetScColumnWidth( nColWidth, GetCharWidth() );
607 pColRowBuff->SetWidthRange( nColFirst, nColLast, nScWidth );
608 }
609
610
Defrowheight2(void)611 void ImportExcel::Defrowheight2( void )
612 {
613 sal_uInt16 nDefHeight;
614 maStrm >> nDefHeight;
615 nDefHeight &= 0x7FFF;
616 pColRowBuff->SetDefHeight( nDefHeight, EXC_DEFROW_UNSYNCED );
617 }
618
619
SheetProtect(void)620 void ImportExcel::SheetProtect( void )
621 {
622 if (GetRoot().GetBiff() != EXC_BIFF8)
623 return;
624
625 GetRoot().GetSheetProtectBuffer().ReadProtect( aIn, GetCurrScTab() );
626 }
627
DocProtect(void)628 void ImportExcel::DocProtect( void )
629 {
630 if (GetRoot().GetBiff() != EXC_BIFF8)
631 return;
632
633 GetRoot().GetDocProtectBuffer().ReadDocProtect( aIn );
634 }
635
DocPasssword(void)636 void ImportExcel::DocPasssword( void )
637 {
638 if (GetRoot().GetBiff() != EXC_BIFF8)
639 return;
640
641 GetRoot().GetDocProtectBuffer().ReadPasswordHash( aIn );
642 }
643
Codepage(void)644 void ImportExcel::Codepage( void )
645 {
646 SetCodePage( maStrm.ReaduInt16() );
647 }
648
649
Ixfe(void)650 void ImportExcel::Ixfe( void )
651 {
652 maStrm >> mnIxfeIndex;
653 }
654
655
DefColWidth(void)656 void ImportExcel::DefColWidth( void )
657 {
658 // stored as entire characters -> convert to 1/256 of characters (as in COLINFO)
659 double fDefWidth = 256.0 * maStrm.ReaduInt16();
660
661 // #i3006# additional space for default width - Excel adds space depending on font size
662 long nFontHt = GetFontBuffer().GetAppFontData().mnHeight;
663 fDefWidth += XclTools::GetXclDefColWidthCorrection( nFontHt );
664
665 sal_uInt16 nScWidth = XclTools::GetScColumnWidth( limit_cast< sal_uInt16 >( fDefWidth ), GetCharWidth() );
666 pColRowBuff->SetDefWidth( nScWidth );
667 }
668
669
Builtinfmtcnt(void)670 void ImportExcel::Builtinfmtcnt( void )
671 {
672 }
673
674
Colinfo(void)675 void ImportExcel::Colinfo( void )
676 {// Column Formatting Information
677 sal_uInt16 nColFirst, nColLast, nColWidth, nXF;
678 sal_uInt16 nOpt;
679
680 aIn >> nColFirst >> nColLast >> nColWidth >> nXF >> nOpt;
681
682 if( nColFirst > MAXCOL )
683 return;
684
685 if( nColLast > MAXCOL )
686 nColLast = static_cast<sal_uInt16>(MAXCOL);
687
688 bool bHidden = ::get_flag( nOpt, EXC_COLINFO_HIDDEN );
689 bool bCollapsed = ::get_flag( nOpt, EXC_COLINFO_COLLAPSED );
690 sal_uInt8 nLevel = ::extract_value< sal_uInt8 >( nOpt, 8, 3 );
691 pColOutlineBuff->SetLevelRange( nColFirst, nColLast, nLevel, bCollapsed, bHidden );
692
693 if( bHidden )
694 pColRowBuff->HideColRange( nColFirst, nColLast );
695
696 sal_uInt16 nScWidth = XclTools::GetScColumnWidth( nColWidth, GetCharWidth() );
697 pColRowBuff->SetWidthRange( nColFirst, nColLast, nScWidth );
698 pColRowBuff->SetDefaultXF( nColFirst, nColLast, nXF );
699 }
700
701
Wsbool(void)702 void ImportExcel::Wsbool( void )
703 {
704 sal_uInt16 nFlags;
705 aIn >> nFlags;
706
707 pRowOutlineBuff->SetButtonMode( ::get_flag( nFlags, EXC_WSBOOL_ROWBELOW ) );
708 pColOutlineBuff->SetButtonMode( ::get_flag( nFlags, EXC_WSBOOL_COLBELOW ) );
709
710 GetPageSettings().SetFitToPages( ::get_flag( nFlags, EXC_WSBOOL_FITTOPAGE ) );
711 }
712
713
Boundsheet(void)714 void ImportExcel::Boundsheet( void )
715 {
716 sal_uInt16 nGrbit = 0;
717
718 if( GetBiff() == EXC_BIFF5 )
719 {
720 aIn.DisableDecryption();
721 maSheetOffsets.push_back( aIn.ReaduInt32() );
722 aIn.EnableDecryption();
723 aIn >> nGrbit;
724 }
725
726 String aName( aIn.ReadByteString( sal_False ) );
727
728 SCTAB nScTab = static_cast< SCTAB >( nBdshtTab );
729 if( nScTab > 0 )
730 {
731 DBG_ASSERT( !pD->HasTable( nScTab ), "ImportExcel::Boundsheet - sheet exists already" );
732 pD->MakeTable( nScTab );
733 }
734
735 if( ( nGrbit & 0x0001 ) || ( nGrbit & 0x0002 ) )
736 pD->SetVisible( nScTab, sal_False );
737
738 if( !pD->RenameTab( nScTab, aName ) )
739 {
740 pD->CreateValidTabName( aName );
741 pD->RenameTab( nScTab, aName );
742 }
743
744 nBdshtTab++;
745 }
746
747
Country(void)748 void ImportExcel::Country( void )
749 {
750 sal_uInt16 nUICountry, nDocCountry;
751 maStrm >> nUICountry >> nDocCountry;
752
753 // Store system language in XclRoot
754 LanguageType eLanguage = ::msfilter::ConvertCountryToLanguage( static_cast< ::msfilter::CountryId >( nDocCountry ) );
755 if( eLanguage != LANGUAGE_DONTKNOW )
756 SetDocLanguage( eLanguage );
757
758 // Set Excel UI language in add-in name translator
759 eLanguage = ::msfilter::ConvertCountryToLanguage( static_cast< ::msfilter::CountryId >( nUICountry ) );
760 if( eLanguage != LANGUAGE_DONTKNOW )
761 SetUILanguage( eLanguage );
762 }
763
764
ReadUsesElfs()765 void ImportExcel::ReadUsesElfs()
766 {
767 if( maStrm.ReaduInt16() != 0 )
768 {
769 ScDocOptions aDocOpt = GetDoc().GetDocOptions();
770 aDocOpt.SetLookUpColRowNames( sal_True );
771 GetDoc().SetDocOptions( aDocOpt );
772 }
773 }
774
775
Hideobj(void)776 void ImportExcel::Hideobj( void )
777 {
778 sal_uInt16 nHide;
779 ScVObjMode eOle, eChart, eDraw;
780
781 aIn >> nHide;
782
783 ScViewOptions aOpts( pD->GetViewOptions() );
784
785 switch( nHide )
786 {
787 case 1: // Placeholders
788 eOle = VOBJ_MODE_SHOW; // in Excel 97 werden nur Charts als Platzhalter angezeigt
789 eChart = VOBJ_MODE_SHOW; //#i80528# VOBJ_MODE_DUMMY replaced by VOBJ_MODE_SHOW now
790 eDraw = VOBJ_MODE_SHOW;
791 break;
792 case 2: // Hide all
793 eOle = VOBJ_MODE_HIDE;
794 eChart = VOBJ_MODE_HIDE;
795 eDraw = VOBJ_MODE_HIDE;
796 break;
797 default: // Show all
798 eOle = VOBJ_MODE_SHOW;
799 eChart = VOBJ_MODE_SHOW;
800 eDraw = VOBJ_MODE_SHOW;
801 break;
802 }
803
804 aOpts.SetObjMode( VOBJ_TYPE_OLE, eOle );
805 aOpts.SetObjMode( VOBJ_TYPE_CHART, eChart );
806 aOpts.SetObjMode( VOBJ_TYPE_DRAW, eDraw );
807
808 pD->SetViewOptions( aOpts );
809 }
810
811
Bundleheader(void)812 void ImportExcel::Bundleheader( void )
813 {
814 }
815
816
Standardwidth(void)817 void ImportExcel::Standardwidth( void )
818 {
819 sal_uInt16 nScWidth = XclTools::GetScColumnWidth( maStrm.ReaduInt16(), GetCharWidth() );
820 pColRowBuff->SetDefWidth( nScWidth, sal_True );
821 }
822
823
Shrfmla(void)824 void ImportExcel::Shrfmla( void )
825 {
826 sal_uInt16 nFirstRow, nLastRow, nLenExpr;
827 sal_uInt8 nFirstCol, nLastCol;
828
829 aIn >> nFirstRow >> nLastRow >> nFirstCol >> nLastCol;
830 aIn.Ignore( 2 );
831 aIn >> nLenExpr;
832
833 // jetzt steht Lesemarke an der Formel
834
835 const ScTokenArray* pErgebnis;
836
837 pFormConv->Reset();
838 pFormConv->Convert( pErgebnis, maStrm, nLenExpr, true, FT_SharedFormula );
839
840
841 DBG_ASSERT( pErgebnis, "+ImportExcel::Shrfmla(): ScTokenArray ist NULL!" );
842
843 pExcRoot->pShrfmlaBuff->Store( ScRange( static_cast<SCCOL>(nFirstCol),
844 static_cast<SCROW>(nFirstRow), GetCurrScTab(),
845 static_cast<SCCOL>(nLastCol), static_cast<SCROW>(nLastRow),
846 GetCurrScTab()), *pErgebnis );
847 }
848
849
Mulrk(void)850 void ImportExcel::Mulrk( void )
851 {
852 XclAddress aXclPos;
853 sal_uInt16 nXF;
854 sal_Int32 nRkNum;
855
856 aIn >> aXclPos;
857
858 for( XclAddress aCurrXclPos( aXclPos ); (aXclPos.mnCol <= aCurrXclPos.mnCol) && (aIn.GetRecLeft() > 2); ++aCurrXclPos.mnCol )
859 {
860 aIn >> nXF >> nRkNum;
861
862 ScAddress aScPos( ScAddress::UNINITIALIZED );
863 if( GetAddressConverter().ConvertAddress( aScPos, aCurrXclPos, GetCurrScTab(), true ) )
864 {
865 GetXFRangeBuffer().SetXF( aScPos, nXF );
866 GetDoc().PutCell( aScPos, new ScValueCell( XclTools::GetDoubleFromRK( nRkNum ) ) );
867 }
868 }
869 }
870
871
Mulblank(void)872 void ImportExcel::Mulblank( void )
873 {
874 XclAddress aXclPos;
875 sal_uInt16 nXF;
876
877 aIn >> aXclPos;
878
879 for( XclAddress aCurrXclPos( aXclPos ); (aXclPos.mnCol <= aCurrXclPos.mnCol) && (aIn.GetRecLeft() > 2); ++aCurrXclPos.mnCol )
880 {
881 aIn >> nXF;
882
883 ScAddress aScPos( ScAddress::UNINITIALIZED );
884 if( GetAddressConverter().ConvertAddress( aScPos, aCurrXclPos, GetCurrScTab(), true ) )
885 GetXFRangeBuffer().SetBlankXF( aScPos, nXF );
886 }
887 }
888
889
Rstring(void)890 void ImportExcel::Rstring( void )
891 {
892 XclAddress aXclPos;
893 sal_uInt16 nXFIdx;
894 aIn >> aXclPos >> nXFIdx;
895
896 ScAddress aScPos( ScAddress::UNINITIALIZED );
897 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
898 {
899 // unformatted Unicode string with separate formatting information
900 XclImpString aString;
901
902 // #i63105# use text encoding from FONT record
903 rtl_TextEncoding eOldTextEnc = GetTextEncoding();
904 if( const XclImpFont* pFont = GetXFBuffer().GetFont( nXFIdx ) )
905 SetTextEncoding( pFont->GetFontEncoding() );
906 aString.Read( maStrm );
907 SetTextEncoding( eOldTextEnc );
908
909 // character formatting runs
910 if( !aString.IsRich() )
911 aString.ReadFormats( maStrm );
912
913 GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
914 if( ScBaseCell* pCell = XclImpStringHelper::CreateCell( *this, aString, nXFIdx ) )
915 GetDoc().PutCell( aScPos, pCell );
916 }
917 }
918
919
Cellmerging()920 void ImportExcel::Cellmerging()
921 {
922 XclImpAddressConverter& rAddrConv = GetAddressConverter();
923 SCTAB nScTab = GetCurrScTab();
924
925 sal_uInt16 nCount;
926 maStrm >> nCount;
927 for( sal_uInt16 nIdx = 0; (nIdx < nCount) && (maStrm.GetRecLeft() >= 8); ++nIdx )
928 {
929 XclRange aXclRange;
930 maStrm >> aXclRange; // 16-bit rows and columns
931 ScRange aScRange( ScAddress::UNINITIALIZED );
932 if( rAddrConv.ConvertRange( aScRange, aXclRange, nScTab, nScTab, true ) )
933 GetXFRangeBuffer().SetMerge( aScRange.aStart.Col(), aScRange.aStart.Row(), aScRange.aEnd.Col(), aScRange.aEnd.Row() );
934 }
935 }
936
937
Olesize(void)938 void ImportExcel::Olesize( void )
939 {
940 XclRange aXclOleSize( ScAddress::UNINITIALIZED );
941 maStrm.Ignore( 2 );
942 aXclOleSize.Read( maStrm, false );
943
944 SCTAB nScTab = GetCurrScTab();
945 GetAddressConverter().ConvertRange( maScOleSize, aXclOleSize, nScTab, nScTab, false );
946 }
947
948
Row34(void)949 void ImportExcel::Row34( void )
950 {
951 sal_uInt16 nRow, nRowHeight, nGrbit, nXF;
952
953 aIn >> nRow;
954 aIn.Ignore( 4 ); // Mic und Mac ueberspringen
955
956 SCROW nScRow = static_cast< SCROW >( nRow );
957
958 if( ValidRow( nScRow ) )
959 {
960 aIn >> nRowHeight; // direkt in Twips angegeben
961 aIn.Ignore( 4 );
962
963 aIn >> nGrbit >> nXF;
964
965 sal_uInt8 nLevel = ::extract_value< sal_uInt8 >( nGrbit, 0, 3 );
966 pRowOutlineBuff->SetLevel( nScRow, nLevel,
967 ::get_flag( nGrbit, EXC_ROW_COLLAPSED ), ::get_flag( nGrbit, EXC_ROW_HIDDEN ) );
968
969 pColRowBuff->SetRowSettings( nScRow, nRowHeight, nGrbit );
970
971 if( nGrbit & EXC_ROW_USEDEFXF )
972 GetXFRangeBuffer().SetRowDefXF( nScRow, nXF & EXC_ROW_XFMASK );
973 }
974 }
975
976
Bof3(void)977 void ImportExcel::Bof3( void )
978 {
979 sal_uInt16 nSubType;
980 maStrm.DisableDecryption();
981 maStrm.Ignore( 2 );
982 maStrm >> nSubType;
983
984 DBG_ASSERT( nSubType != 0x0100, "*ImportExcel::Bof3(): Biff3 als Workbook?!" );
985 if( nSubType == 0x0100 ) // Book
986 pExcRoot->eDateiTyp = Biff3W;
987 else if( nSubType == 0x0020 ) // Chart
988 pExcRoot->eDateiTyp = Biff3C;
989 else if( nSubType == 0x0040 ) // Macro
990 pExcRoot->eDateiTyp = Biff3M;
991 else // #i51490# Excel interprets invalid indexes as worksheet
992 pExcRoot->eDateiTyp = Biff3;
993 }
994
995
Array34(void)996 void ImportExcel::Array34( void )
997 {
998 sal_uInt16 nFirstRow, nLastRow, nFormLen;
999 sal_uInt8 nFirstCol, nLastCol;
1000
1001 aIn >> nFirstRow >> nLastRow >> nFirstCol >> nLastCol;
1002 aIn.Ignore( (GetBiff() >= EXC_BIFF5) ? 6 : 2 );
1003 aIn >> nFormLen;
1004
1005 if( ValidColRow( nLastCol, nLastRow ) )
1006 {
1007 // jetzt steht Lesemarke auf Formel, Laenge in nFormLen
1008 const ScTokenArray* pErgebnis;
1009
1010 pFormConv->Reset( ScAddress( static_cast<SCCOL>(nFirstCol),
1011 static_cast<SCROW>(nFirstRow), GetCurrScTab() ) );
1012 pFormConv->Convert( pErgebnis, maStrm, nFormLen, true, FT_CellFormula);
1013
1014 DBG_ASSERT( pErgebnis, "+ImportExcel::Array34(): ScTokenArray ist NULL!" );
1015
1016 ScMarkData aMarkData;
1017 aMarkData.SelectOneTable( GetCurrScTab() );
1018 pD->InsertMatrixFormula( static_cast<SCCOL>(nFirstCol),
1019 static_cast<SCROW>(nFirstRow), static_cast<SCCOL>(nLastCol),
1020 static_cast<SCROW>(nLastRow), aMarkData, EMPTY_STRING,
1021 pErgebnis);
1022 }
1023 }
1024
1025
Externname34(void)1026 void ImportExcel::Externname34( void )
1027 {
1028 }
1029
1030
Defrowheight345(void)1031 void ImportExcel::Defrowheight345( void )
1032 {
1033 sal_uInt16 nFlags, nDefHeight;
1034 maStrm >> nFlags >> nDefHeight;
1035 pColRowBuff->SetDefHeight( nDefHeight, nFlags );
1036 }
1037
1038
TableOp(void)1039 void ImportExcel::TableOp( void )
1040 {
1041 sal_uInt16 nFirstRow, nLastRow;
1042 sal_uInt8 nFirstCol, nLastCol;
1043 sal_uInt16 nGrbit;
1044 sal_uInt16 nInpRow, nInpCol, nInpRow2, nInpCol2;
1045
1046 aIn >> nFirstRow >> nLastRow >> nFirstCol >> nLastCol >> nGrbit
1047 >> nInpRow >> nInpCol >> nInpRow2 >> nInpCol2;
1048
1049 if( ValidColRow( nLastCol, nLastRow ) )
1050 {
1051 if( nFirstCol && nFirstRow )
1052 {
1053 ScTabOpParam aTabOpParam;
1054 aTabOpParam.nMode = (nGrbit & EXC_TABLEOP_BOTH) ? 2 : ((nGrbit & EXC_TABLEOP_ROW) ? 1 : 0 );
1055 sal_uInt16 nCol = nFirstCol - 1;
1056 sal_uInt16 nRow = nFirstRow - 1;
1057 SCTAB nTab = GetCurrScTab();
1058 switch( aTabOpParam.nMode )
1059 {
1060 case 0: // COL
1061 aTabOpParam.aRefFormulaCell.Set(
1062 static_cast<SCCOL>(nFirstCol),
1063 static_cast<SCROW>(nFirstRow - 1), nTab, sal_False,
1064 sal_False, sal_False );
1065 aTabOpParam.aRefFormulaEnd.Set(
1066 static_cast<SCCOL>(nLastCol),
1067 static_cast<SCROW>(nFirstRow - 1), nTab, sal_False,
1068 sal_False, sal_False );
1069 aTabOpParam.aRefColCell.Set( static_cast<SCCOL>(nInpCol),
1070 static_cast<SCROW>(nInpRow), nTab, sal_False, sal_False,
1071 sal_False );
1072 nRow++;
1073 break;
1074 case 1: // ROW
1075 aTabOpParam.aRefFormulaCell.Set(
1076 static_cast<SCCOL>(nFirstCol - 1),
1077 static_cast<SCROW>(nFirstRow), nTab, sal_False, sal_False,
1078 sal_False );
1079 aTabOpParam.aRefFormulaEnd.Set(
1080 static_cast<SCCOL>(nFirstCol - 1),
1081 static_cast<SCROW>(nLastRow), nTab, sal_False, sal_False,
1082 sal_False );
1083 aTabOpParam.aRefRowCell.Set( static_cast<SCCOL>(nInpCol),
1084 static_cast<SCROW>(nInpRow), nTab, sal_False, sal_False,
1085 sal_False );
1086 nCol++;
1087 break;
1088 case 2: // TWO-INPUT
1089 aTabOpParam.aRefFormulaCell.Set(
1090 static_cast<SCCOL>(nFirstCol - 1),
1091 static_cast<SCROW>(nFirstRow - 1), nTab, sal_False,
1092 sal_False, sal_False );
1093 aTabOpParam.aRefRowCell.Set( static_cast<SCCOL>(nInpCol),
1094 static_cast<SCROW>(nInpRow), nTab, sal_False, sal_False,
1095 sal_False );
1096 aTabOpParam.aRefColCell.Set( static_cast<SCCOL>(nInpCol2),
1097 static_cast<SCROW>(nInpRow2), nTab, sal_False, sal_False,
1098 sal_False );
1099 break;
1100 }
1101
1102 ScMarkData aMarkData;
1103 aMarkData.SelectOneTable( nTab );
1104 pD->InsertTableOp( aTabOpParam, static_cast<SCCOL>(nCol),
1105 static_cast<SCROW>(nRow), static_cast<SCCOL>(nLastCol),
1106 static_cast<SCROW>(nLastRow), aMarkData );
1107 }
1108 }
1109 else
1110 {
1111 bTabTruncated = sal_True;
1112 GetTracer().TraceInvalidRow(GetCurrScTab(), nLastRow, MAXROW);
1113 }
1114 }
1115
1116
Bof4(void)1117 void ImportExcel::Bof4( void )
1118 {
1119 sal_uInt16 nSubType;
1120 maStrm.DisableDecryption();
1121 maStrm.Ignore( 2 );
1122 maStrm >> nSubType;
1123
1124 if( nSubType == 0x0100 ) // Book
1125 pExcRoot->eDateiTyp = Biff4W;
1126 else if( nSubType == 0x0020 ) // Chart
1127 pExcRoot->eDateiTyp = Biff4C;
1128 else if( nSubType == 0x0040 ) // Macro
1129 pExcRoot->eDateiTyp = Biff4M;
1130 else // #i51490# Excel interprets invalid indexes as worksheet
1131 pExcRoot->eDateiTyp = Biff4;
1132 }
1133
1134
Bof5(void)1135 void ImportExcel::Bof5( void )
1136 {
1137 //POST: eDateiTyp = Typ der zu lesenden Datei
1138 sal_uInt16 nSubType, nVers;
1139 BiffTyp eDatei;
1140
1141 maStrm.DisableDecryption();
1142 maStrm >> nVers >> nSubType;
1143
1144 switch( nSubType )
1145 {
1146 case 0x0005: eDatei = Biff5W; break; // workbook globals
1147 case 0x0006: eDatei = Biff5V; break; // VB module
1148 case 0x0010: eDatei = Biff5; break; // worksheet
1149 case 0x0020: eDatei = Biff5C; break; // chart
1150 case 0x0040: eDatei = Biff5M4; break; // macro sheet
1151 default:
1152 pExcRoot->eDateiTyp = BiffX;
1153 return;
1154 }
1155
1156 if( nVers == 0x0600 && (GetBiff() == EXC_BIFF8) )
1157 eDatei = ( BiffTyp ) ( eDatei - Biff5 + Biff8 );
1158
1159 pExcRoot->eDateiTyp = eDatei;
1160 }
1161
EndSheet(void)1162 void ImportExcel::EndSheet( void )
1163 {
1164 pExcRoot->pExtSheetBuff->Reset();
1165
1166 if( GetBiff() <= EXC_BIFF5 )
1167 {
1168 pExcRoot->pExtNameBuff->Reset();
1169 mnLastRefIdx = 0;
1170 }
1171
1172 FinalizeTable();
1173 }
1174
1175
NeueTabelle(void)1176 void ImportExcel::NeueTabelle( void )
1177 {
1178 SCTAB nTab = GetCurrScTab();
1179 if( nTab > 0 && !pD->HasTable( nTab ) )
1180 pD->MakeTable( nTab );
1181
1182 pExcRoot->pShrfmlaBuff->Clear();
1183
1184 InitializeTable( nTab );
1185
1186 pOutlineListBuffer->Append( new XclImpOutlineDataBuffer( GetRoot(), nTab ) );
1187
1188 pExcRoot->pColRowBuff = pColRowBuff = pOutlineListBuffer->Last()->GetColRowBuff();
1189 pColOutlineBuff = pOutlineListBuffer->Last()->GetColOutline();
1190 pRowOutlineBuff = pOutlineListBuffer->Last()->GetRowOutline();
1191 }
1192
1193
ErrorToFormula(sal_uInt8 bErrOrVal,sal_uInt8 nError,double & rVal)1194 const ScTokenArray* ImportExcel::ErrorToFormula( sal_uInt8 bErrOrVal, sal_uInt8 nError, double& rVal )
1195 {
1196 return pFormConv->GetBoolErr( XclTools::ErrorToEnum( rVal, bErrOrVal, nError ) );
1197 }
1198
1199
AdjustRowHeight()1200 void ImportExcel::AdjustRowHeight()
1201 {
1202 /* #93255# Speed up chart import: import all sheets without charts, then
1203 update row heights (here), last load all charts -> do not any longer
1204 update inside of ScDocShell::ConvertFrom() (causes update of existing
1205 charts during each and every change of row height). */
1206 /*if( ScModelObj* pDocObj = GetDocModelObj() )
1207 pDocObj->UpdateAllRowHeights();*/
1208
1209 //just update row heights for : 1. visible sheet, 2. sheet containing sdrobject. i120586
1210 SCTAB nCount = GetDoc().GetTableCount();
1211 SCTAB nVisible = GetDocViewSettings().GetDisplScTab();
1212
1213 GetDoc().SetPendingRowHeights(nVisible, false);
1214
1215 ScMarkData aUpdateSheets;
1216 for (SCTAB nTab=0; nTab<nCount; ++nTab)
1217 {
1218 if ( false == GetDoc().IsPendingRowHeights(nTab))
1219 aUpdateSheets.SelectTable( nTab, true );
1220 }
1221
1222 ScModelObj* pDocObj = GetDocModelObj();
1223 if (pDocObj && (aUpdateSheets.GetSelectCount()))
1224 pDocObj->UpdateAllRowHeights(&aUpdateSheets);
1225 //end i120586
1226 }
1227
1228
PostDocLoad(void)1229 void ImportExcel::PostDocLoad( void )
1230 {
1231 /* Set automatic page numbering in Default page style (default is "page number = 1").
1232 Otherwise hidden tables (i.e. for scenarios) which have Default page style will
1233 break automatic page numbering. */
1234 if( SfxStyleSheetBase* pStyleSheet = GetStyleSheetPool().Find( ScGlobal::GetRscString( STR_STYLENAME_STANDARD ), SFX_STYLE_FAMILY_PAGE ) )
1235 pStyleSheet->GetItemSet().Put( SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO, 0 ) );
1236
1237 // outlines for all sheets, sets hidden rows and columns (#i11776# after filtered ranges)
1238 for( XclImpOutlineDataBuffer* pBuffer = pOutlineListBuffer->First(); pBuffer; pBuffer = pOutlineListBuffer->Next() )
1239 pBuffer->Convert();
1240
1241 // document view settings (before visible OLE area)
1242 GetDocViewSettings().Finalize();
1243
1244 // process all drawing objects (including OLE, charts, controls; after hiding rows/columns; before visible OLE area)
1245 GetObjectManager().ConvertObjects();
1246
1247 // visible area (used if this document is an embedded OLE object)
1248 if( SfxObjectShell* pDocShell = GetDocShell() )
1249 {
1250 // visible area if embedded
1251 const ScExtDocSettings& rDocSett = GetExtDocOptions().GetDocSettings();
1252 SCTAB nDisplScTab = rDocSett.mnDisplTab;
1253
1254 /* #i44077# If a new OLE object is inserted from file, there is no
1255 OLESIZE record in the Excel file. Calculate used area from file
1256 contents (used cells and drawing objects). */
1257 if( !maScOleSize.IsValid() )
1258 {
1259 // used area of displayed sheet (cell contents)
1260 if( const ScExtTabSettings* pTabSett = GetExtDocOptions().GetTabSettings( nDisplScTab ) )
1261 maScOleSize = pTabSett->maUsedArea;
1262 // add all valid drawing objects
1263 ScRange aScObjArea = GetObjectManager().GetUsedArea( nDisplScTab );
1264 if( aScObjArea.IsValid() )
1265 maScOleSize.ExtendTo( aScObjArea );
1266 }
1267
1268 // valid size found - set it at the document
1269 if( maScOleSize.IsValid() )
1270 {
1271 pDocShell->SetVisArea( GetDoc().GetMMRect(
1272 maScOleSize.aStart.Col(), maScOleSize.aStart.Row(),
1273 maScOleSize.aEnd.Col(), maScOleSize.aEnd.Row(), nDisplScTab ) );
1274 GetDoc().SetVisibleTab( nDisplScTab );
1275 }
1276 }
1277
1278 // #111099# open forms in alive mode (has no effect, if no controls in document)
1279 if( ScModelObj* pDocObj = GetDocModelObj() )
1280 pDocObj->setPropertyValue( CREATE_OUSTRING( SC_UNO_APPLYFMDES ), uno::Any( false ) );
1281
1282 // enables extended options to be set to the view after import
1283 GetExtDocOptions().SetChanged( true );
1284
1285 // root data owns the extended document options -> create a new object
1286 GetDoc().SetExtDocOptions( new ScExtDocOptions( GetExtDocOptions() ) );
1287
1288 const SCTAB nLast = pD->GetTableCount();
1289 const ScRange* p;
1290
1291 if( pExcRoot->pPrintRanges->HasRanges() )
1292 {
1293 for( SCTAB n = 0 ; n < nLast ; n++ )
1294 {
1295 p = pExcRoot->pPrintRanges->First( static_cast<sal_uInt16>(n) );
1296 if( p )
1297 {
1298 DBG_ASSERT( pExcRoot->pPrintRanges->GetActList(),
1299 "-ImportExcel::PostDocLoad(): Imaginaere Tabelle gefunden!" );
1300
1301 pD->ClearPrintRanges( n );
1302 while( p )
1303 {
1304 pD->AddPrintRange( n, *p );
1305 p = pExcRoot->pPrintRanges->Next();
1306 }
1307 }
1308 else
1309 {
1310 // #i4063# no print ranges -> print entire sheet
1311 pD->SetPrintEntireSheet( n );
1312 }
1313 }
1314 GetTracer().TracePrintRange();
1315 }
1316
1317 if( pExcRoot->pPrintTitles->HasRanges() )
1318 {
1319 for( SCTAB n = 0 ; n < nLast ; n++ )
1320 {
1321 p = pExcRoot->pPrintTitles->First( static_cast<sal_uInt16>(n) );
1322 if( p )
1323 {
1324 DBG_ASSERT( pExcRoot->pPrintTitles->GetActList(),
1325 "-ImportExcel::PostDocLoad(): Imaginaere Tabelle gefunden!" );
1326
1327 sal_Bool bRowVirgin = sal_True;
1328 sal_Bool bColVirgin = sal_True;
1329
1330 while( p )
1331 {
1332 if( p->aStart.Col() == 0 && p->aEnd.Col() == MAXCOL && bRowVirgin )
1333 {
1334 pD->SetRepeatRowRange( n, p );
1335 bRowVirgin = sal_False;
1336 }
1337
1338 if( p->aStart.Row() == 0 && p->aEnd.Row() == MAXROW && bColVirgin )
1339 {
1340 pD->SetRepeatColRange( n, p );
1341 bColVirgin = sal_False;
1342 }
1343
1344 p = pExcRoot->pPrintTitles->Next();
1345 }
1346 }
1347 }
1348 }
1349 }
1350
XclImpOutlineDataBuffer(const XclImpRoot & rRoot,SCTAB nScTab)1351 XclImpOutlineDataBuffer::XclImpOutlineDataBuffer( const XclImpRoot& rRoot, SCTAB nScTab ) :
1352 XclImpRoot( rRoot ),
1353 mxColOutlineBuff( new XclImpOutlineBuffer( rRoot.GetXclMaxPos().Col() + 1 ) ),
1354 mxRowOutlineBuff( new XclImpOutlineBuffer( rRoot.GetXclMaxPos().Row() + 1 ) ),
1355 mxColRowBuff( new XclImpColRowSettings( rRoot ) ),
1356 mnScTab( nScTab )
1357 {
1358 }
1359
~XclImpOutlineDataBuffer()1360 XclImpOutlineDataBuffer::~XclImpOutlineDataBuffer()
1361 {
1362 }
1363
Convert()1364 void XclImpOutlineDataBuffer::Convert()
1365 {
1366 mxColOutlineBuff->SetOutlineArray( GetDoc().GetOutlineTable( mnScTab, sal_True )->GetColArray() );
1367 mxColOutlineBuff->MakeScOutline();
1368
1369 mxRowOutlineBuff->SetOutlineArray( GetDoc().GetOutlineTable( mnScTab, sal_True )->GetRowArray() );
1370 mxRowOutlineBuff->MakeScOutline();
1371
1372 mxColRowBuff->ConvertHiddenFlags( mnScTab );
1373 }
1374