fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / excel / impop.cxx
blob904209d2bb1b4a345fc731602d01bd1d1d144c3f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "imp_op.hxx"
22 #include <filter/msfilter/countryid.hxx>
24 #include "scitems.hxx"
25 #include <editeng/eeitem.hxx>
27 #include <editeng/editdata.hxx>
28 #include <editeng/editeng.hxx>
29 #include <editeng/editobj.hxx>
30 #include <editeng/editstat.hxx>
31 #include <editeng/flditem.hxx>
32 #include <svx/pageitem.hxx>
33 #include <editeng/colritem.hxx>
34 #include <sfx2/printer.hxx>
35 #include <sfx2/docfile.hxx>
36 #include <svl/zforlist.hxx>
38 #include <sfx2/objsh.hxx>
39 #include <tools/urlobj.hxx>
40 #include "docuno.hxx"
42 #include "formulacell.hxx"
43 #include "document.hxx"
44 #include "rangenam.hxx"
45 #include "compiler.hxx"
46 #include "patattr.hxx"
47 #include "attrib.hxx"
48 #include "globstr.hrc"
49 #include "global.hxx"
50 #include "markdata.hxx"
51 #include "olinetab.hxx"
52 #include "stlsheet.hxx"
53 #include "stlpool.hxx"
54 #include "viewopti.hxx"
55 #include "docoptio.hxx"
56 #include "scextopt.hxx"
57 #include "editutil.hxx"
58 #include "filtopt.hxx"
59 #include "scerrors.hxx"
60 #include "unonames.hxx"
61 #include "paramisc.hxx"
62 #include "postit.hxx"
64 #include "fapihelper.hxx"
65 #include "xltools.hxx"
66 #include "xltable.hxx"
67 #include "xlview.hxx"
68 #include "xltracer.hxx"
69 #include "xihelper.hxx"
70 #include "xipage.hxx"
71 #include "xiview.hxx"
72 #include "xilink.hxx"
73 #include "xiescher.hxx"
74 #include "xicontent.hxx"
76 #include "excimp8.hxx"
77 #include "excform.hxx"
78 #include "documentimport.hxx"
80 #if defined( WNT )
81 #include <math.h>
82 #else
83 #include <stdlib.h>
84 #endif
86 using namespace ::com::sun::star;
88 const double ImportExcel::fExcToTwips =
89 ( double ) TWIPS_PER_CHAR / 256.0;
91 ImportTyp::ImportTyp( ScDocument* pDoc, rtl_TextEncoding eQ )
93 eQuellChar = eQ;
94 pD = pDoc;
97 ImportTyp::~ImportTyp()
101 FltError ImportTyp::Read()
103 return eERR_INTERN;
106 ImportExcel::ImportExcel( XclImpRootData& rImpData, SvStream& rStrm ):
107 ImportTyp( &rImpData.mrDoc, rImpData.meTextEnc ),
108 XclImpRoot( rImpData ),
109 maStrm( rStrm, GetRoot() ),
110 aIn( maStrm ),
111 maScOleSize( ScAddress::INITIALIZE_INVALID ),
112 pColOutlineBuff(NULL),
113 pRowOutlineBuff(NULL),
114 pColRowBuff(NULL),
115 mpLastFormula(NULL),
116 mnLastRefIdx( 0 ),
117 mnIxfeIndex( 0 ),
118 mnLastRecId(0),
119 mbBiff2HasXfs(false),
120 mbBiff2HasXfsValid(false)
122 nBdshtTab = 0;
124 // fill in root data - after new's without root as parameter
125 pExcRoot = &GetOldRoot();
126 pExcRoot->pIR = this; // ExcRoot -> XclImpRoot
127 pExcRoot->eDateiTyp = BiffX;
128 pExcRoot->pExtSheetBuff = new ExtSheetBuffer( pExcRoot ); //&aExtSheetBuff;
129 pExcRoot->pShrfmlaBuff = new SharedFormulaBuffer( pExcRoot ); //&aShrfrmlaBuff;
130 pExcRoot->pExtNameBuff = new ExtNameBuff ( *this );
132 pExtNameBuff = new NameBuffer( pExcRoot ); //prevent empty rootdata
133 pExtNameBuff->SetBase( 1 );
135 pOutlineListBuffer = new XclImpOutlineListBuffer( );
137 // ab Biff8
138 pFormConv = pExcRoot->pFmlaConverter = new ExcelToSc( GetRoot() );
140 bTabTruncated = false;
142 // Excel document per Default on 31.12.1899, accords to Excel settings with 1.1.1900
143 ScDocOptions aOpt = pD->GetDocOptions();
144 aOpt.SetDate( 30, 12, 1899 );
145 pD->SetDocOptions( aOpt );
146 pD->GetFormatTable()->ChangeNullDate( 30, 12, 1899 );
148 ScDocOptions aDocOpt( pD->GetDocOptions() );
149 aDocOpt.SetIgnoreCase( true ); // always in Excel
150 aDocOpt.SetFormulaRegexEnabled( false ); // regular expressions? what's that?
151 aDocOpt.SetLookUpColRowNames( false ); // default: no natural language refs
152 pD->SetDocOptions( aDocOpt );
155 ImportExcel::~ImportExcel()
157 GetDoc().SetSrcCharSet( GetTextEncoding() );
159 delete pExtNameBuff;
161 delete pOutlineListBuffer;
163 delete pFormConv;
166 void ImportExcel::SetLastFormula( SCCOL nCol, SCROW nRow, double fVal, sal_uInt16 nXF, ScFormulaCell* pCell )
168 LastFormulaMapType::iterator it = maLastFormulaCells.find(nCol);
169 if (it == maLastFormulaCells.end())
171 std::pair<LastFormulaMapType::iterator, bool> r =
172 maLastFormulaCells.insert(
173 LastFormulaMapType::value_type(nCol, LastFormula()));
174 it = r.first;
177 it->second.mnCol = nCol;
178 it->second.mnRow = nRow;
179 it->second.mpCell = pCell;
180 it->second.mfValue = fVal;
181 it->second.mnXF = nXF;
183 mpLastFormula = &it->second;
186 void ImportExcel::ReadFileSharing()
188 sal_uInt16 nRecommendReadOnly, nPasswordHash;
189 nRecommendReadOnly = maStrm.ReaduInt16();
190 nPasswordHash = maStrm.ReaduInt16();
192 if( (nRecommendReadOnly != 0) || (nPasswordHash != 0) )
194 if( SfxItemSet* pItemSet = GetMedium().GetItemSet() )
195 pItemSet->Put( SfxBoolItem( SID_DOC_READONLY, true ) );
197 if( SfxObjectShell* pShell = GetDocShell() )
199 if( nRecommendReadOnly != 0 )
200 pShell->SetLoadReadonly( true );
201 if( nPasswordHash != 0 )
202 pShell->SetModifyPasswordHash( nPasswordHash );
207 sal_uInt16 ImportExcel::ReadXFIndex( const ScAddress& rScPos, bool bBiff2 )
209 sal_uInt16 nXFIdx = 0;
210 if( bBiff2 )
212 /* #i71453# On first call, check if the file contains XF records (by
213 trying to access the first XF with index 0). If there are no XFs,
214 the explicit formatting information contained in each cell record
215 will be used instead. */
216 if( !mbBiff2HasXfsValid )
218 mbBiff2HasXfsValid = true;
219 mbBiff2HasXfs = GetXFBuffer().GetXF( 0 ) != 0;
221 // read formatting information (includes the XF identifier)
222 sal_uInt8 nFlags1, nFlags2, nFlags3;
223 nFlags1 = maStrm.ReaduInt8();
224 nFlags2 = maStrm.ReaduInt8();
225 nFlags3 = maStrm.ReaduInt8();
226 /* If the file contains XFs, extract and set the XF identifier,
227 otherwise get the explicit formatting. */
228 if( mbBiff2HasXfs )
230 nXFIdx = ::extract_value< sal_uInt16 >( nFlags1, 0, 6 );
231 /* If the identifier is equal to 63, then the real identifier is
232 contained in the preceding IXFE record (stored in mnBiff2XfId). */
233 if( nXFIdx == 63 )
234 nXFIdx = mnIxfeIndex;
236 else
238 /* Let the XclImpXF class do the conversion of the imported
239 formatting. The XF buffer is empty, therefore will not do any
240 conversion based on the XF index later on. */
241 XclImpXF::ApplyPatternForBiff2CellFormat( GetRoot(), rScPos, nFlags1, nFlags2, nFlags3 );
244 else
245 nXFIdx = aIn.ReaduInt16();
246 return nXFIdx;
249 void ImportExcel::ReadDimensions()
251 XclRange aXclUsedArea( ScAddress::UNINITIALIZED );
252 if( (maStrm.GetRecId() == EXC_ID2_DIMENSIONS) || (GetBiff() <= EXC_BIFF5) )
254 maStrm >> aXclUsedArea;
255 if( (aXclUsedArea.GetColCount() > 1) && (aXclUsedArea.GetRowCount() > 1) )
257 // Excel stores first unused row/column index
258 --aXclUsedArea.maLast.mnCol;
259 --aXclUsedArea.maLast.mnRow;
260 // create the Calc range
261 SCTAB nScTab = GetCurrScTab();
262 ScRange& rScUsedArea = GetExtDocOptions().GetOrCreateTabSettings( nScTab ).maUsedArea;
263 GetAddressConverter().ConvertRange( rScUsedArea, aXclUsedArea, nScTab, nScTab, false );
264 // if any error occurs in ConvertRange(), rScUsedArea keeps untouched
267 else
269 sal_uInt32 nXclRow1, nXclRow2;
270 nXclRow1 = maStrm.ReaduInt32();
271 nXclRow2 = maStrm.ReaduInt32();
272 aXclUsedArea.maFirst.mnCol = maStrm.ReaduInt16();
273 aXclUsedArea.maLast.mnCol = maStrm.ReaduInt16();
274 if( (nXclRow1 < nXclRow2) && (aXclUsedArea.GetColCount() > 1) &&
275 (nXclRow1 <= static_cast< sal_uInt32 >( GetScMaxPos().Row() )) )
277 // Excel stores first unused row/column index
278 --nXclRow2;
279 --aXclUsedArea.maLast.mnCol;
280 // convert row indexes to 16-bit values
281 aXclUsedArea.maFirst.mnRow = static_cast< sal_uInt16 >( nXclRow1 );
282 aXclUsedArea.maLast.mnRow = limit_cast< sal_uInt16 >( nXclRow2, aXclUsedArea.maFirst.mnRow, SAL_MAX_UINT16 );
283 // create the Calc range
284 SCTAB nScTab = GetCurrScTab();
285 ScRange& rScUsedArea = GetExtDocOptions().GetOrCreateTabSettings( nScTab ).maUsedArea;
286 GetAddressConverter().ConvertRange( rScUsedArea, aXclUsedArea, nScTab, nScTab, false );
287 // if any error occurs in ConvertRange(), rScUsedArea keeps untouched
292 void ImportExcel::ReadBlank()
294 XclAddress aXclPos;
295 aIn >> aXclPos;
297 ScAddress aScPos( ScAddress::UNINITIALIZED );
298 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
300 sal_uInt16 nXFIdx = ReadXFIndex( aScPos, maStrm.GetRecId() == EXC_ID2_BLANK );
302 GetXFRangeBuffer().SetBlankXF( aScPos, nXFIdx );
306 void ImportExcel::ReadInteger()
308 XclAddress aXclPos;
309 maStrm >> aXclPos;
311 ScAddress aScPos( ScAddress::UNINITIALIZED );
312 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
314 sal_uInt16 nXFIdx = ReadXFIndex( aScPos, true );
315 sal_uInt16 nValue;
316 nValue = maStrm.ReaduInt16();
318 GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
319 GetDocImport().setNumericCell(aScPos, nValue);
323 void ImportExcel::ReadNumber()
325 XclAddress aXclPos;
326 maStrm >> aXclPos;
328 ScAddress aScPos( ScAddress::UNINITIALIZED );
329 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
331 sal_uInt16 nXFIdx = ReadXFIndex( aScPos, maStrm.GetRecId() == EXC_ID2_NUMBER );
332 double fValue;
333 fValue = maStrm.ReadDouble();
335 GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
336 GetDocImport().setNumericCell(aScPos, fValue);
340 void ImportExcel::ReadLabel()
342 XclAddress aXclPos;
343 maStrm >> aXclPos;
345 ScAddress aScPos( ScAddress::UNINITIALIZED );
346 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
348 /* Record ID BIFF XF type String type
349 0x0004 2-7 3 byte 8-bit length, byte string
350 0x0004 8 3 byte 16-bit length, unicode string
351 0x0204 2-7 2 byte 16-bit length, byte string
352 0x0204 8 2 byte 16-bit length, unicode string */
353 bool bBiff2 = maStrm.GetRecId() == EXC_ID2_LABEL;
354 sal_uInt16 nXFIdx = ReadXFIndex( aScPos, bBiff2 );
355 XclStrFlags nFlags = (bBiff2 && (GetBiff() <= EXC_BIFF5)) ? EXC_STR_8BITLENGTH : EXC_STR_DEFAULT;
356 XclImpString aString;
358 // #i63105# use text encoding from FONT record
359 rtl_TextEncoding eOldTextEnc = GetTextEncoding();
360 if( const XclImpFont* pFont = GetXFBuffer().GetFont( nXFIdx ) )
361 SetTextEncoding( pFont->GetFontEncoding() );
362 aString.Read( maStrm, nFlags );
363 SetTextEncoding( eOldTextEnc );
365 GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
366 XclImpStringHelper::SetToDocument(GetDocImport(), aScPos, GetRoot(), aString, nXFIdx);
370 void ImportExcel::ReadBoolErr()
372 XclAddress aXclPos;
373 maStrm >> aXclPos;
375 ScAddress aScPos( ScAddress::UNINITIALIZED );
376 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
378 sal_uInt16 nXFIdx = ReadXFIndex( aScPos, maStrm.GetRecId() == EXC_ID2_BOOLERR );
379 sal_uInt8 nValue, nType;
380 nValue = maStrm.ReaduInt8();
381 nType = maStrm.ReaduInt8();
383 if( nType == EXC_BOOLERR_BOOL )
384 GetXFRangeBuffer().SetBoolXF( aScPos, nXFIdx );
385 else
386 GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
388 double fValue;
389 const ScTokenArray* pScTokArr = ErrorToFormula( nType, nValue, fValue );
390 ScFormulaCell* pCell = pScTokArr ? new ScFormulaCell(pD, aScPos, *pScTokArr) : new ScFormulaCell(pD, aScPos);
391 pCell->SetHybridDouble( fValue );
392 GetDocImport().setFormulaCell(aScPos, pCell);
396 void ImportExcel::ReadRk()
398 XclAddress aXclPos;
399 maStrm >> aXclPos;
401 ScAddress aScPos( ScAddress::UNINITIALIZED );
402 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
404 sal_uInt16 nXFIdx = ReadXFIndex( aScPos, false );
405 sal_Int32 nRk;
406 nRk = maStrm.ReadInt32();
408 GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
409 GetDocImport().setNumericCell(aScPos, XclTools::GetDoubleFromRK(nRk));
413 void ImportExcel::Window1()
415 GetDocViewSettings().ReadWindow1( maStrm );
418 void ImportExcel::Row25()
420 sal_uInt16 nRow, nRowHeight;
422 nRow = aIn.ReaduInt16();
423 aIn.Ignore( 4 );
425 if( ValidRow( nRow ) )
427 nRowHeight = aIn.ReaduInt16(); // specify direct in Twips
428 aIn.Ignore( 2 );
430 if( GetBiff() == EXC_BIFF2 )
431 {// -------------------- BIFF2
432 pColRowBuff->SetHeight( nRow, nRowHeight );
434 else
435 {// -------------------- BIFF5
436 sal_uInt16 nGrbit;
438 aIn.Ignore( 2 ); // reserved
439 nGrbit = aIn.ReaduInt16();
441 sal_uInt8 nLevel = ::extract_value< sal_uInt8 >( nGrbit, 0, 3 );
442 pRowOutlineBuff->SetLevel( nRow, nLevel, ::get_flag( nGrbit, EXC_ROW_COLLAPSED ) );
443 pColRowBuff->SetRowSettings( nRow, nRowHeight, nGrbit );
448 void ImportExcel::Bof2()
450 sal_uInt16 nSubType;
451 maStrm.DisableDecryption();
452 maStrm.Ignore( 2 );
453 nSubType = maStrm.ReaduInt16();
455 if( nSubType == 0x0020 ) // Chart
456 pExcRoot->eDateiTyp = Biff2C;
457 else if( nSubType == 0x0040 ) // Macro
458 pExcRoot->eDateiTyp = Biff2M;
459 else // #i51490# Excel interprets invalid indexes as worksheet
460 pExcRoot->eDateiTyp = Biff2;
463 void ImportExcel::Eof()
465 // POST: cannot be called after an invalid table!
466 EndSheet();
467 IncCurrScTab();
470 void ImportExcel::SheetPassword()
472 if (GetRoot().GetBiff() != EXC_BIFF8)
473 return;
475 GetRoot().GetSheetProtectBuffer().ReadPasswordHash( aIn, GetCurrScTab() );
478 void ImportExcel::Externsheet()
480 OUString aUrl, aTabName;
481 bool bSameWorkBook;
482 OUString aEncodedUrl( aIn.ReadByteString( false ) );
483 XclImpUrlHelper::DecodeUrl( aUrl, aTabName, bSameWorkBook, *pExcRoot->pIR, aEncodedUrl );
484 mnLastRefIdx = pExcRoot->pExtSheetBuff->Add( aUrl, aTabName, bSameWorkBook );
487 void ImportExcel:: WinProtection()
489 if (GetRoot().GetBiff() != EXC_BIFF8)
490 return;
492 GetRoot().GetDocProtectBuffer().ReadWinProtect( aIn );
495 void ImportExcel::Columndefault()
496 {// Default Cell Attributes
497 sal_uInt16 nColMic, nColMac;
498 sal_uInt8 nOpt0;
500 nColMic = aIn.ReaduInt16();
501 nColMac = aIn.ReaduInt16();
503 OSL_ENSURE( aIn.GetRecLeft() == (sal_Size)(nColMac - nColMic) * 3 + 2,
504 "ImportExcel::Columndefault - wrong record size" );
506 nColMac--;
508 if( nColMac > MAXCOL )
509 nColMac = static_cast<sal_uInt16>(MAXCOL);
511 for( sal_uInt16 nCol = nColMic ; nCol <= nColMac ; nCol++ )
513 nOpt0 = aIn.ReaduInt8();
514 aIn.Ignore( 2 ); // only 0. Attribut-Byte used
516 if( nOpt0 & 0x80 ) // Col hidden?
517 pColRowBuff->HideCol( nCol );
521 void ImportExcel::Array25()
523 sal_uInt16 nFormLen;
524 sal_uInt16 nFirstRow = aIn.ReaduInt16();
525 sal_uInt16 nLastRow = aIn.ReaduInt16();
526 sal_uInt8 nFirstCol = aIn.ReaduInt8();
527 sal_uInt8 nLastCol = aIn.ReaduInt8();
529 if( GetBiff() == EXC_BIFF2 )
530 {// BIFF2
531 aIn.Ignore( 1 );
532 nFormLen = aIn.ReaduInt8();
534 else
535 {// BIFF5
536 aIn.Ignore( 6 );
537 nFormLen = aIn.ReaduInt16();
540 const ScTokenArray* pErgebnis = nullptr;
542 if (ValidColRow(nLastCol, nLastRow))
544 // the read mark is now on the formula, length in nFormLen
546 pFormConv->Reset( ScAddress( static_cast<SCCOL>(nFirstCol),
547 static_cast<SCROW>(nFirstRow), GetCurrScTab() ) );
548 pFormConv->Convert(pErgebnis, maStrm, nFormLen, true, FT_CellFormula);
550 SAL_WARN_IF(!pErgebnis, "sc", "*ImportExcel::Array25(): ScTokenArray is NULL!");
553 if (pErgebnis)
555 ScDocumentImport& rDoc = GetDocImport();
556 ScRange aArrayRange(nFirstCol, nFirstRow, GetCurrScTab(), nLastCol, nLastRow, GetCurrScTab());
557 rDoc.setMatrixCells(aArrayRange, *pErgebnis, formula::FormulaGrammar::GRAM_ENGLISH_XL_A1);
561 void ImportExcel::Rec1904()
563 sal_uInt16 n1904;
565 n1904 = aIn.ReaduInt16();
567 if( n1904 )
568 {// 1904 date system
569 ScDocOptions aOpt = pD->GetDocOptions();
570 aOpt.SetDate( 1, 1, 1904 );
571 pD->SetDocOptions( aOpt );
572 pD->GetFormatTable()->ChangeNullDate( 1, 1, 1904 );
576 void ImportExcel::Externname25()
578 sal_uInt32 nRes;
579 sal_uInt16 nOpt;
581 nOpt = aIn.ReaduInt16();
582 nRes = aIn.ReaduInt32();
584 OUString aName( aIn.ReadByteString( false ) );
586 if( ( nOpt & 0x0001 ) || ( ( nOpt & 0xFFFE ) == 0x0000 ) )
587 {// external name
588 aName = ScfTools::ConvertToScDefinedName( aName );
589 pExcRoot->pExtNameBuff->AddName( aName, mnLastRefIdx );
591 else if( nOpt & 0x0010 )
592 {// ole link
593 pExcRoot->pExtNameBuff->AddOLE( aName, mnLastRefIdx, nRes ); // nRes is storage ID
595 else
596 {// dde link
597 pExcRoot->pExtNameBuff->AddDDE( aName, mnLastRefIdx );
601 void ImportExcel::Colwidth()
602 {// Column Width
603 sal_uInt8 nColFirst, nColLast;
604 sal_uInt16 nColWidth;
606 nColFirst = aIn.ReaduInt8();
607 nColLast = aIn.ReaduInt8();
608 nColWidth = aIn.ReaduInt16();
610 //TODO: add a check for the unlikely case of changed MAXCOL (-> XclImpAddressConverter)
611 // if( nColLast > MAXCOL )
612 // nColLast = static_cast<sal_uInt16>(MAXCOL);
614 sal_uInt16 nScWidth = XclTools::GetScColumnWidth( nColWidth, GetCharWidth() );
615 pColRowBuff->SetWidthRange( nColFirst, nColLast, nScWidth );
618 void ImportExcel::Defrowheight2()
620 sal_uInt16 nDefHeight;
621 nDefHeight = maStrm.ReaduInt16();
622 nDefHeight &= 0x7FFF;
623 pColRowBuff->SetDefHeight( nDefHeight, EXC_DEFROW_UNSYNCED );
626 void ImportExcel::SheetProtect()
628 if (GetRoot().GetBiff() != EXC_BIFF8)
629 return;
631 GetRoot().GetSheetProtectBuffer().ReadProtect( aIn, GetCurrScTab() );
634 void ImportExcel::DocProtect()
636 if (GetRoot().GetBiff() != EXC_BIFF8)
637 return;
639 GetRoot().GetDocProtectBuffer().ReadDocProtect( aIn );
642 void ImportExcel::DocPasssword()
644 if (GetRoot().GetBiff() != EXC_BIFF8)
645 return;
647 GetRoot().GetDocProtectBuffer().ReadPasswordHash( aIn );
650 void ImportExcel::Codepage()
652 SetCodePage( maStrm.ReaduInt16() );
655 void ImportExcel::Ixfe()
657 mnIxfeIndex = maStrm.ReaduInt16();
660 void ImportExcel::DefColWidth()
662 // stored as entire characters -> convert to 1/256 of characters (as in COLINFO)
663 double fDefWidth = 256.0 * maStrm.ReaduInt16();
665 if (!pColRowBuff)
667 SAL_WARN("sc", "*ImportExcel::DefColWidth(): pColRowBuff is NULL!");
668 return;
671 // #i3006# additional space for default width - Excel adds space depending on font size
672 long nFontHt = GetFontBuffer().GetAppFontData().mnHeight;
673 fDefWidth += XclTools::GetXclDefColWidthCorrection( nFontHt );
675 sal_uInt16 nScWidth = XclTools::GetScColumnWidth( limit_cast< sal_uInt16 >( fDefWidth ), GetCharWidth() );
676 pColRowBuff->SetDefWidth( nScWidth );
679 void ImportExcel::Colinfo()
680 {// Column Formatting Information
681 sal_uInt16 nColFirst, nColLast, nColWidth, nXF;
682 sal_uInt16 nOpt;
684 nColFirst = aIn.ReaduInt16();
685 nColLast = aIn.ReaduInt16();
686 nColWidth = aIn.ReaduInt16();
687 nXF = aIn.ReaduInt16();
688 nOpt = aIn.ReaduInt16();
690 if( nColFirst > MAXCOL )
691 return;
693 if( nColLast > MAXCOL )
694 nColLast = static_cast<sal_uInt16>(MAXCOL);
696 bool bHidden = ::get_flag( nOpt, EXC_COLINFO_HIDDEN );
697 bool bCollapsed = ::get_flag( nOpt, EXC_COLINFO_COLLAPSED );
698 sal_uInt8 nLevel = ::extract_value< sal_uInt8 >( nOpt, 8, 3 );
699 pColOutlineBuff->SetLevelRange( nColFirst, nColLast, nLevel, bCollapsed );
701 if( bHidden )
702 pColRowBuff->HideColRange( nColFirst, nColLast );
704 sal_uInt16 nScWidth = XclTools::GetScColumnWidth( nColWidth, GetCharWidth() );
705 pColRowBuff->SetWidthRange( nColFirst, nColLast, nScWidth );
706 pColRowBuff->SetDefaultXF( nColFirst, nColLast, nXF );
709 void ImportExcel::Wsbool()
711 sal_uInt16 nFlags;
712 nFlags = aIn.ReaduInt16();
714 pRowOutlineBuff->SetButtonMode( ::get_flag( nFlags, EXC_WSBOOL_ROWBELOW ) );
715 pColOutlineBuff->SetButtonMode( ::get_flag( nFlags, EXC_WSBOOL_COLBELOW ) );
717 GetPageSettings().SetFitToPages( ::get_flag( nFlags, EXC_WSBOOL_FITTOPAGE ) );
720 void ImportExcel::Boundsheet()
722 sal_uInt16 nGrbit = 0;
724 if( GetBiff() == EXC_BIFF5 )
726 aIn.DisableDecryption();
727 maSheetOffsets.push_back( aIn.ReaduInt32() );
728 aIn.EnableDecryption();
729 nGrbit = aIn.ReaduInt16();
732 OUString aName( aIn.ReadByteString( false ) );
734 SCTAB nScTab = static_cast< SCTAB >( nBdshtTab );
735 if( nScTab > 0 )
737 OSL_ENSURE( !pD->HasTable( nScTab ), "ImportExcel::Boundsheet - sheet exists already" );
738 pD->MakeTable( nScTab );
741 if( ( nGrbit & 0x0001 ) || ( nGrbit & 0x0002 ) )
742 pD->SetVisible( nScTab, false );
744 if( !pD->RenameTab( nScTab, aName ) )
746 pD->CreateValidTabName( aName );
747 pD->RenameTab( nScTab, aName );
750 nBdshtTab++;
753 void ImportExcel::Country()
755 sal_uInt16 nUICountry, nDocCountry;
756 nUICountry = maStrm.ReaduInt16();
757 nDocCountry = maStrm.ReaduInt16();
759 // Store system language in XclRoot
760 LanguageType eLanguage = ::msfilter::ConvertCountryToLanguage( static_cast< ::msfilter::CountryId >( nDocCountry ) );
761 if( eLanguage != LANGUAGE_DONTKNOW )
762 SetDocLanguage( eLanguage );
764 // Set Excel UI language in add-in name translator
765 eLanguage = ::msfilter::ConvertCountryToLanguage( static_cast< ::msfilter::CountryId >( nUICountry ) );
766 if( eLanguage != LANGUAGE_DONTKNOW )
767 SetUILanguage( eLanguage );
770 void ImportExcel::ReadUsesElfs()
772 if( maStrm.ReaduInt16() != 0 )
774 ScDocOptions aDocOpt = GetDoc().GetDocOptions();
775 aDocOpt.SetLookUpColRowNames( true );
776 GetDoc().SetDocOptions( aDocOpt );
780 void ImportExcel::Hideobj()
782 sal_uInt16 nHide;
783 ScVObjMode eOle, eChart, eDraw;
785 nHide = aIn.ReaduInt16();
787 ScViewOptions aOpts( pD->GetViewOptions() );
789 switch( nHide )
791 case 1: // Placeholders
792 eOle = VOBJ_MODE_SHOW; // in Excel 97 only charts as place holder are displayed
793 eChart = VOBJ_MODE_SHOW; //#i80528# VOBJ_MODE_DUMMY replaced by VOBJ_MODE_SHOW now
794 eDraw = VOBJ_MODE_SHOW;
795 break;
796 case 2: // Hide all
797 eOle = VOBJ_MODE_HIDE;
798 eChart = VOBJ_MODE_HIDE;
799 eDraw = VOBJ_MODE_HIDE;
800 break;
801 default: // Show all
802 eOle = VOBJ_MODE_SHOW;
803 eChart = VOBJ_MODE_SHOW;
804 eDraw = VOBJ_MODE_SHOW;
805 break;
808 aOpts.SetObjMode( VOBJ_TYPE_OLE, eOle );
809 aOpts.SetObjMode( VOBJ_TYPE_CHART, eChart );
810 aOpts.SetObjMode( VOBJ_TYPE_DRAW, eDraw );
812 pD->SetViewOptions( aOpts );
815 void ImportExcel::Standardwidth()
817 sal_uInt16 nScWidth = XclTools::GetScColumnWidth( maStrm.ReaduInt16(), GetCharWidth() );
818 if (!pColRowBuff)
820 SAL_WARN("sc", "*ImportExcel::Standardwidth(): pColRowBuff is NULL!");
821 return;
823 pColRowBuff->SetDefWidth( nScWidth, true );
826 void ImportExcel::Shrfmla()
828 switch (mnLastRecId)
830 case EXC_ID2_FORMULA:
831 case EXC_ID3_FORMULA:
832 case EXC_ID4_FORMULA:
833 // This record MUST immediately follow a FORMULA record.
834 break;
835 default:
836 return;
839 if (!mpLastFormula)
840 // The last FORMULA record should have left this data.
841 return;
843 aIn.Ignore( 8 );
844 sal_uInt16 nLenExpr = aIn.ReaduInt16();
846 // read mark is now on the formula
848 const ScTokenArray* pErgebnis;
850 // The shared range in this record is erroneous more than half the time.
851 // Don't ever rely on it. Use the one from the formula cell above.
852 SCCOL nCol1 = mpLastFormula->mnCol;
853 SCROW nRow1 = mpLastFormula->mnRow;
855 ScAddress aPos(nCol1, nRow1, GetCurrScTab());
856 pFormConv->Reset(aPos);
857 pFormConv->Convert( pErgebnis, maStrm, nLenExpr, true, FT_SharedFormula );
859 OSL_ENSURE( pErgebnis, "+ImportExcel::Shrfmla(): ScTokenArray is NULL!" );
861 pExcRoot->pShrfmlaBuff->Store(aPos, *pErgebnis);
863 // Create formula cell for the last formula record.
865 ScDocumentImport& rDoc = GetDocImport();
867 ScFormulaCell* pCell = new ScFormulaCell(pD, aPos, *pErgebnis);
868 pCell->GetCode()->WrapReference(aPos, EXC_MAXCOL8, EXC_MAXROW8);
869 rDoc.getDoc().EnsureTable(aPos.Tab());
870 rDoc.setFormulaCell(aPos, pCell);
871 pCell->SetNeedNumberFormat(false);
872 if (!rtl::math::isNan(mpLastFormula->mfValue))
873 pCell->SetResultDouble(mpLastFormula->mfValue);
875 GetXFRangeBuffer().SetXF(aPos, mpLastFormula->mnXF);
876 mpLastFormula->mpCell = pCell;
879 void ImportExcel::Mulrk()
881 XclAddress aXclPos;
882 sal_uInt16 nXF;
883 sal_Int32 nRkNum;
885 aIn >> aXclPos;
887 for( XclAddress aCurrXclPos( aXclPos ); (aXclPos.mnCol <= aCurrXclPos.mnCol) && (aIn.GetRecLeft() > 2); ++aCurrXclPos.mnCol )
889 nXF = aIn.ReaduInt16();
890 nRkNum = aIn.ReadInt32();
892 ScAddress aScPos( ScAddress::UNINITIALIZED );
893 if( GetAddressConverter().ConvertAddress( aScPos, aCurrXclPos, GetCurrScTab(), true ) )
895 GetXFRangeBuffer().SetXF( aScPos, nXF );
896 GetDocImport().setNumericCell(aScPos, XclTools::GetDoubleFromRK(nRkNum));
901 void ImportExcel::Mulblank()
903 XclAddress aXclPos;
904 sal_uInt16 nXF;
906 aIn >> aXclPos;
908 for( XclAddress aCurrXclPos( aXclPos ); (aXclPos.mnCol <= aCurrXclPos.mnCol) && (aIn.GetRecLeft() > 2); ++aCurrXclPos.mnCol )
910 nXF = aIn.ReaduInt16();
912 ScAddress aScPos( ScAddress::UNINITIALIZED );
913 if( GetAddressConverter().ConvertAddress( aScPos, aCurrXclPos, GetCurrScTab(), true ) )
914 GetXFRangeBuffer().SetBlankXF( aScPos, nXF );
918 void ImportExcel::Rstring()
920 XclAddress aXclPos;
921 sal_uInt16 nXFIdx;
922 aIn >> aXclPos;
923 nXFIdx = aIn.ReaduInt16();
925 ScAddress aScPos( ScAddress::UNINITIALIZED );
926 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
928 // unformatted Unicode string with separate formatting information
929 XclImpString aString;
931 // #i63105# use text encoding from FONT record
932 rtl_TextEncoding eOldTextEnc = GetTextEncoding();
933 if( const XclImpFont* pFont = GetXFBuffer().GetFont( nXFIdx ) )
934 SetTextEncoding( pFont->GetFontEncoding() );
935 aString.Read( maStrm );
936 SetTextEncoding( eOldTextEnc );
938 // character formatting runs
939 if( !aString.IsRich() )
940 aString.ReadFormats( maStrm );
942 GetXFRangeBuffer().SetXF( aScPos, nXFIdx );
943 XclImpStringHelper::SetToDocument(GetDocImport(), aScPos, *this, aString, nXFIdx);
947 void ImportExcel::Cellmerging()
949 XclImpAddressConverter& rAddrConv = GetAddressConverter();
950 SCTAB nScTab = GetCurrScTab();
952 sal_uInt16 nCount;
953 nCount = maStrm.ReaduInt16();
954 for( sal_uInt16 nIdx = 0; (nIdx < nCount) && (maStrm.GetRecLeft() >= 8); ++nIdx )
956 XclRange aXclRange;
957 maStrm >> aXclRange; // 16-bit rows and columns
958 ScRange aScRange( ScAddress::UNINITIALIZED );
959 if( rAddrConv.ConvertRange( aScRange, aXclRange, nScTab, nScTab, true ) )
960 GetXFRangeBuffer().SetMerge( aScRange.aStart.Col(), aScRange.aStart.Row(), aScRange.aEnd.Col(), aScRange.aEnd.Row() );
964 void ImportExcel::Olesize()
966 XclRange aXclOleSize( ScAddress::UNINITIALIZED );
967 maStrm.Ignore( 2 );
968 aXclOleSize.Read( maStrm, false );
970 SCTAB nScTab = GetCurrScTab();
971 GetAddressConverter().ConvertRange( maScOleSize, aXclOleSize, nScTab, nScTab, false );
974 void ImportExcel::Row34()
976 sal_uInt16 nRow, nRowHeight, nGrbit, nXF;
978 nRow = aIn.ReaduInt16();
979 aIn.Ignore( 4 );
981 SCROW nScRow = static_cast< SCROW >( nRow );
983 if( ValidRow( nScRow ) )
985 nRowHeight = aIn.ReaduInt16(); // specify direct in Twips
986 aIn.Ignore( 4 );
988 nRowHeight = nRowHeight & 0x7FFF; // Bit 15: Row Height not changed manually
989 if( !nRowHeight )
990 nRowHeight = (GetBiff() == EXC_BIFF2) ? 0x25 : 0x225;
992 nGrbit = aIn.ReaduInt16();
993 nXF = aIn.ReaduInt16();
995 sal_uInt8 nLevel = ::extract_value< sal_uInt8 >( nGrbit, 0, 3 );
996 pRowOutlineBuff->SetLevel( nScRow, nLevel, ::get_flag( nGrbit, EXC_ROW_COLLAPSED ) );
997 pColRowBuff->SetRowSettings( nScRow, nRowHeight, nGrbit );
999 if( nGrbit & EXC_ROW_USEDEFXF )
1000 GetXFRangeBuffer().SetRowDefXF( nScRow, nXF & EXC_ROW_XFMASK );
1004 void ImportExcel::Bof3()
1006 sal_uInt16 nSubType;
1007 maStrm.DisableDecryption();
1008 maStrm.Ignore( 2 );
1009 nSubType = maStrm.ReaduInt16();
1011 OSL_ENSURE( nSubType != 0x0100, "*ImportExcel::Bof3(): Biff3 as Workbook?!" );
1012 if( nSubType == 0x0100 ) // Book
1013 pExcRoot->eDateiTyp = Biff3W;
1014 else if( nSubType == 0x0020 ) // Chart
1015 pExcRoot->eDateiTyp = Biff3C;
1016 else if( nSubType == 0x0040 ) // Macro
1017 pExcRoot->eDateiTyp = Biff3M;
1018 else // #i51490# Excel interprets invalid indexes as worksheet
1019 pExcRoot->eDateiTyp = Biff3;
1022 void ImportExcel::Array34()
1024 sal_uInt16 nFirstRow, nLastRow, nFormLen;
1025 sal_uInt8 nFirstCol, nLastCol;
1027 nFirstRow = aIn.ReaduInt16();
1028 nLastRow = aIn.ReaduInt16();
1029 nFirstCol = aIn.ReaduInt8();
1030 nLastCol = aIn.ReaduInt8();
1031 aIn.Ignore( (GetBiff() >= EXC_BIFF5) ? 6 : 2 );
1032 nFormLen = aIn.ReaduInt16();
1034 const ScTokenArray* pErgebnis = nullptr;
1036 if( ValidColRow( nLastCol, nLastRow ) )
1038 // the read mark is now on the formula, length in nFormLen
1040 pFormConv->Reset( ScAddress( static_cast<SCCOL>(nFirstCol),
1041 static_cast<SCROW>(nFirstRow), GetCurrScTab() ) );
1042 pFormConv->Convert( pErgebnis, maStrm, nFormLen, true, FT_CellFormula);
1044 SAL_WARN_IF(!pErgebnis, "sc", "+ImportExcel::Array34(): ScTokenArray is NULL!");
1047 if (pErgebnis)
1049 ScDocumentImport& rDoc = GetDocImport();
1050 ScRange aArrayRange(nFirstCol, nFirstRow, GetCurrScTab(), nLastCol, nLastRow, GetCurrScTab());
1051 rDoc.setMatrixCells(aArrayRange, *pErgebnis, formula::FormulaGrammar::GRAM_ENGLISH_XL_A1);
1055 void ImportExcel::Defrowheight345()
1057 sal_uInt16 nFlags, nDefHeight;
1058 nFlags = maStrm.ReaduInt16();
1059 nDefHeight = maStrm.ReaduInt16();
1061 if (!pColRowBuff)
1063 SAL_WARN("sc", "*ImportExcel::Defrowheight345(): pColRowBuff is NULL!");
1064 return;
1067 pColRowBuff->SetDefHeight( nDefHeight, nFlags );
1070 void ImportExcel::TableOp()
1072 sal_uInt16 nFirstRow, nLastRow;
1073 sal_uInt8 nFirstCol, nLastCol;
1074 sal_uInt16 nGrbit;
1075 sal_uInt16 nInpRow, nInpCol, nInpRow2, nInpCol2;
1077 nFirstRow = aIn.ReaduInt16();
1078 nLastRow = aIn.ReaduInt16();
1079 nFirstCol = aIn.ReaduInt8();
1080 nLastCol = aIn.ReaduInt8();
1081 nGrbit = aIn.ReaduInt16();
1082 nInpRow = aIn.ReaduInt16();
1083 nInpCol = aIn.ReaduInt16();
1084 nInpRow2 = aIn.ReaduInt16();
1085 nInpCol2 = aIn.ReaduInt16();
1087 if( ValidColRow( nLastCol, nLastRow ) )
1089 if( nFirstCol && nFirstRow )
1091 ScTabOpParam aTabOpParam;
1092 aTabOpParam.meMode = (nGrbit & EXC_TABLEOP_BOTH) ? ScTabOpParam::Both : ((nGrbit & EXC_TABLEOP_ROW) ? ScTabOpParam::Row : ScTabOpParam::Column);
1093 sal_uInt16 nCol = nFirstCol - 1;
1094 sal_uInt16 nRow = nFirstRow - 1;
1095 SCTAB nTab = GetCurrScTab();
1096 switch (aTabOpParam.meMode)
1098 case ScTabOpParam::Column:
1099 aTabOpParam.aRefFormulaCell.Set(
1100 static_cast<SCCOL>(nFirstCol),
1101 static_cast<SCROW>(nFirstRow - 1), nTab, false,
1102 false, false );
1103 aTabOpParam.aRefFormulaEnd.Set(
1104 static_cast<SCCOL>(nLastCol),
1105 static_cast<SCROW>(nFirstRow - 1), nTab, false,
1106 false, false );
1107 aTabOpParam.aRefColCell.Set( static_cast<SCCOL>(nInpCol),
1108 static_cast<SCROW>(nInpRow), nTab, false, false,
1109 false );
1110 nRow++;
1111 break;
1112 case ScTabOpParam::Row:
1113 aTabOpParam.aRefFormulaCell.Set(
1114 static_cast<SCCOL>(nFirstCol - 1),
1115 static_cast<SCROW>(nFirstRow), nTab, false, false,
1116 false );
1117 aTabOpParam.aRefFormulaEnd.Set(
1118 static_cast<SCCOL>(nFirstCol - 1),
1119 static_cast<SCROW>(nLastRow), nTab, false, false,
1120 false );
1121 aTabOpParam.aRefRowCell.Set( static_cast<SCCOL>(nInpCol),
1122 static_cast<SCROW>(nInpRow), nTab, false, false,
1123 false );
1124 nCol++;
1125 break;
1126 case ScTabOpParam::Both: // TWO-INPUT
1127 aTabOpParam.aRefFormulaCell.Set(
1128 static_cast<SCCOL>(nFirstCol - 1),
1129 static_cast<SCROW>(nFirstRow - 1), nTab, false,
1130 false, false );
1131 aTabOpParam.aRefRowCell.Set( static_cast<SCCOL>(nInpCol),
1132 static_cast<SCROW>(nInpRow), nTab, false, false,
1133 false );
1134 aTabOpParam.aRefColCell.Set( static_cast<SCCOL>(nInpCol2),
1135 static_cast<SCROW>(nInpRow2), nTab, false, false,
1136 false );
1137 break;
1140 ScDocumentImport& rDoc = GetDocImport();
1141 ScRange aTabOpRange(nCol, nRow, nTab, nLastCol, nLastRow, nTab);
1142 rDoc.setTableOpCells(aTabOpRange, aTabOpParam);
1145 else
1147 bTabTruncated = true;
1148 GetTracer().TraceInvalidRow(nLastRow, MAXROW);
1152 void ImportExcel::Bof4()
1154 sal_uInt16 nSubType;
1155 maStrm.DisableDecryption();
1156 maStrm.Ignore( 2 );
1157 nSubType = maStrm.ReaduInt16();
1159 if( nSubType == 0x0100 ) // Book
1160 pExcRoot->eDateiTyp = Biff4W;
1161 else if( nSubType == 0x0020 ) // Chart
1162 pExcRoot->eDateiTyp = Biff4C;
1163 else if( nSubType == 0x0040 ) // Macro
1164 pExcRoot->eDateiTyp = Biff4M;
1165 else // #i51490# Excel interprets invalid indexes as worksheet
1166 pExcRoot->eDateiTyp = Biff4;
1169 void ImportExcel::Bof5()
1171 //POST: eDateiTyp = Type of the file to be read
1172 sal_uInt16 nSubType, nVers;
1173 BiffTyp eDatei;
1175 maStrm.DisableDecryption();
1176 nVers = maStrm.ReaduInt16();
1177 nSubType = maStrm.ReaduInt16( );
1179 switch( nSubType )
1181 case 0x0005: eDatei = Biff5W; break; // workbook globals
1182 case 0x0006: eDatei = Biff5V; break; // VB module
1183 case 0x0010: eDatei = Biff5; break; // worksheet
1184 case 0x0020: eDatei = Biff5C; break; // chart
1185 case 0x0040: eDatei = Biff5M4; break; // macro sheet
1186 default:
1187 pExcRoot->eDateiTyp = BiffX;
1188 return;
1191 if( nVers == 0x0600 && (GetBiff() == EXC_BIFF8) )
1192 eDatei = ( BiffTyp ) ( eDatei - Biff5 + Biff8 );
1194 pExcRoot->eDateiTyp = eDatei;
1197 void ImportExcel::EndSheet()
1199 pExcRoot->pExtSheetBuff->Reset();
1201 if( GetBiff() <= EXC_BIFF5 )
1203 pExcRoot->pExtNameBuff->Reset();
1204 mnLastRefIdx = 0;
1207 FinalizeTable();
1210 void ImportExcel::NewTable()
1212 SCTAB nTab = GetCurrScTab();
1213 if( nTab > 0 && !pD->HasTable( nTab ) )
1214 pD->MakeTable( nTab );
1216 if (nTab == 0 && GetBiff() == EXC_BIFF2)
1218 // For Excel 2.1 Worksheet file, we need to set the file name as the
1219 // sheet name.
1220 INetURLObject aURL(GetDocUrl());
1221 pD->RenameTab(0, aURL.getBase(), false);
1224 pExcRoot->pShrfmlaBuff->Clear();
1225 maLastFormulaCells.clear();
1226 mpLastFormula = NULL;
1228 InitializeTable( nTab );
1230 XclImpOutlineDataBuffer* pNewItem = new XclImpOutlineDataBuffer( GetRoot(), nTab );
1231 pOutlineListBuffer->push_back( pNewItem );
1232 pExcRoot->pColRowBuff = pColRowBuff = pNewItem->GetColRowBuff();
1233 pColOutlineBuff = pNewItem->GetColOutline();
1234 pRowOutlineBuff = pNewItem->GetRowOutline();
1237 const ScTokenArray* ImportExcel::ErrorToFormula( bool bErrOrVal, sal_uInt8 nError, double& rVal )
1239 return pFormConv->GetBoolErr( XclTools::ErrorToEnum( rVal, bErrOrVal, nError ) );
1242 void ImportExcel::AdjustRowHeight()
1244 /* Speed up chart import: import all sheets without charts, then
1245 update row heights (here), last load all charts -> do not any longer
1246 update inside of ScDocShell::ConvertFrom() (causes update of existing
1247 charts during each and every change of row height). */
1248 if( ScModelObj* pDocObj = GetDocModelObj() )
1249 pDocObj->UpdateAllRowHeights();
1252 void ImportExcel::PostDocLoad()
1254 /* Set automatic page numbering in Default page style (default is "page number = 1").
1255 Otherwise hidden tables (i.e. for scenarios) which have Default page style will
1256 break automatic page numbering. */
1257 if( SfxStyleSheetBase* pStyleSheet = GetStyleSheetPool().Find( ScGlobal::GetRscString( STR_STYLENAME_STANDARD ), SFX_STYLE_FAMILY_PAGE ) )
1258 pStyleSheet->GetItemSet().Put( SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO, 0 ) );
1260 // outlines for all sheets, sets hidden rows and columns (#i11776# after filtered ranges)
1261 for (XclImpOutlineListBuffer::iterator itBuffer = pOutlineListBuffer->begin(); itBuffer != pOutlineListBuffer->end(); ++itBuffer)
1262 itBuffer->Convert();
1264 // document view settings (before visible OLE area)
1265 GetDocViewSettings().Finalize();
1267 // process all drawing objects (including OLE, charts, controls; after hiding rows/columns; before visible OLE area)
1268 GetObjectManager().ConvertObjects();
1270 // visible area (used if this document is an embedded OLE object)
1271 if( SfxObjectShell* pDocShell = GetDocShell() )
1273 // visible area if embedded
1274 const ScExtDocSettings& rDocSett = GetExtDocOptions().GetDocSettings();
1275 SCTAB nDisplScTab = rDocSett.mnDisplTab;
1277 /* #i44077# If a new OLE object is inserted from file, there is no
1278 OLESIZE record in the Excel file. Calculate used area from file
1279 contents (used cells and drawing objects). */
1280 if( !maScOleSize.IsValid() )
1282 // used area of displayed sheet (cell contents)
1283 if( const ScExtTabSettings* pTabSett = GetExtDocOptions().GetTabSettings( nDisplScTab ) )
1284 maScOleSize = pTabSett->maUsedArea;
1285 // add all valid drawing objects
1286 ScRange aScObjArea = GetObjectManager().GetUsedArea( nDisplScTab );
1287 if( aScObjArea.IsValid() )
1288 maScOleSize.ExtendTo( aScObjArea );
1291 // valid size found - set it at the document
1292 if( maScOleSize.IsValid() )
1294 pDocShell->SetVisArea( GetDoc().GetMMRect(
1295 maScOleSize.aStart.Col(), maScOleSize.aStart.Row(),
1296 maScOleSize.aEnd.Col(), maScOleSize.aEnd.Row(), nDisplScTab ) );
1297 GetDoc().SetVisibleTab( nDisplScTab );
1301 // open forms in alive mode (has no effect, if no controls in document)
1302 if( ScModelObj* pDocObj = GetDocModelObj() )
1303 pDocObj->setPropertyValue( SC_UNO_APPLYFMDES, uno::Any( false ) );
1305 // enables extended options to be set to the view after import
1306 GetExtDocOptions().SetChanged( true );
1308 // root data owns the extended document options -> create a new object
1309 GetDoc().SetExtDocOptions( new ScExtDocOptions( GetExtDocOptions() ) );
1311 const SCTAB nLast = pD->GetTableCount();
1312 const ScRange* p;
1314 if( pExcRoot->pPrintRanges->HasRanges() )
1316 for( SCTAB n = 0 ; n < nLast ; n++ )
1318 p = pExcRoot->pPrintRanges->First(n);
1319 if( p )
1321 pD->ClearPrintRanges( n );
1322 while( p )
1324 pD->AddPrintRange( n, *p );
1325 p = pExcRoot->pPrintRanges->Next();
1328 else
1330 // #i4063# no print ranges -> print entire sheet
1331 pD->SetPrintEntireSheet( n );
1334 GetTracer().TracePrintRange();
1337 if( pExcRoot->pPrintTitles->HasRanges() )
1339 for( SCTAB n = 0 ; n < nLast ; n++ )
1341 p = pExcRoot->pPrintTitles->First(n);
1342 if( p )
1344 bool bRowVirgin = true;
1345 bool bColVirgin = true;
1347 while( p )
1349 if( p->aStart.Col() == 0 && p->aEnd.Col() == MAXCOL && bRowVirgin )
1351 pD->SetRepeatRowRange( n, p );
1352 bRowVirgin = false;
1355 if( p->aStart.Row() == 0 && p->aEnd.Row() == MAXROW && bColVirgin )
1357 pD->SetRepeatColRange( n, p );
1358 bColVirgin = false;
1361 p = pExcRoot->pPrintTitles->Next();
1368 XclImpOutlineDataBuffer::XclImpOutlineDataBuffer( const XclImpRoot& rRoot, SCTAB nScTab ) :
1369 XclImpRoot( rRoot ),
1370 mxColOutlineBuff( new XclImpOutlineBuffer( rRoot.GetXclMaxPos().Col() + 1 ) ),
1371 mxRowOutlineBuff( new XclImpOutlineBuffer( rRoot.GetXclMaxPos().Row() + 1 ) ),
1372 mxColRowBuff( new XclImpColRowSettings( rRoot ) ),
1373 mnScTab( nScTab )
1377 XclImpOutlineDataBuffer::~XclImpOutlineDataBuffer()
1381 void XclImpOutlineDataBuffer::Convert()
1383 mxColOutlineBuff->SetOutlineArray( &GetDoc().GetOutlineTable( mnScTab, true )->GetColArray() );
1384 mxColOutlineBuff->MakeScOutline();
1386 mxRowOutlineBuff->SetOutlineArray( &GetDoc().GetOutlineTable( mnScTab, true )->GetRowArray() );
1387 mxRowOutlineBuff->MakeScOutline();
1389 mxColRowBuff->ConvertHiddenFlags( mnScTab );
1392 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */