1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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>
42 #include "formulacell.hxx"
43 #include "document.hxx"
44 #include "rangenam.hxx"
45 #include "compiler.hxx"
46 #include "patattr.hxx"
48 #include "globstr.hrc"
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"
64 #include "fapihelper.hxx"
65 #include "xltools.hxx"
66 #include "xltable.hxx"
68 #include "xltracer.hxx"
69 #include "xihelper.hxx"
73 #include "xiescher.hxx"
74 #include "xicontent.hxx"
76 #include "excimp8.hxx"
77 #include "excform.hxx"
78 #include "documentimport.hxx"
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
)
97 ImportTyp::~ImportTyp()
101 FltError
ImportTyp::Read()
106 ImportExcel::ImportExcel( XclImpRootData
& rImpData
, SvStream
& rStrm
):
107 ImportTyp( &rImpData
.mrDoc
, rImpData
.meTextEnc
),
108 XclImpRoot( rImpData
),
109 maStrm( rStrm
, GetRoot() ),
111 maScOleSize( ScAddress::INITIALIZE_INVALID
),
112 pColOutlineBuff(NULL
),
113 pRowOutlineBuff(NULL
),
119 mbBiff2HasXfs(false),
120 mbBiff2HasXfsValid(false)
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( );
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() );
161 delete pOutlineListBuffer
;
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()));
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;
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. */
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). */
234 nXFIdx
= mnIxfeIndex
;
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
);
245 nXFIdx
= aIn
.ReaduInt16();
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
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
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()
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()
311 ScAddress
aScPos( ScAddress::UNINITIALIZED
);
312 if( GetAddressConverter().ConvertAddress( aScPos
, aXclPos
, GetCurrScTab(), true ) )
314 sal_uInt16 nXFIdx
= ReadXFIndex( aScPos
, true );
316 nValue
= maStrm
.ReaduInt16();
318 GetXFRangeBuffer().SetXF( aScPos
, nXFIdx
);
319 GetDocImport().setNumericCell(aScPos
, nValue
);
323 void ImportExcel::ReadNumber()
328 ScAddress
aScPos( ScAddress::UNINITIALIZED
);
329 if( GetAddressConverter().ConvertAddress( aScPos
, aXclPos
, GetCurrScTab(), true ) )
331 sal_uInt16 nXFIdx
= ReadXFIndex( aScPos
, maStrm
.GetRecId() == EXC_ID2_NUMBER
);
333 fValue
= maStrm
.ReadDouble();
335 GetXFRangeBuffer().SetXF( aScPos
, nXFIdx
);
336 GetDocImport().setNumericCell(aScPos
, fValue
);
340 void ImportExcel::ReadLabel()
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()
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
);
386 GetXFRangeBuffer().SetXF( aScPos
, nXFIdx
);
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()
401 ScAddress
aScPos( ScAddress::UNINITIALIZED
);
402 if( GetAddressConverter().ConvertAddress( aScPos
, aXclPos
, GetCurrScTab(), true ) )
404 sal_uInt16 nXFIdx
= ReadXFIndex( aScPos
, false );
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();
425 if( ValidRow( nRow
) )
427 nRowHeight
= aIn
.ReaduInt16(); // specify direct in Twips
430 if( GetBiff() == EXC_BIFF2
)
431 {// -------------------- BIFF2
432 pColRowBuff
->SetHeight( nRow
, nRowHeight
);
435 {// -------------------- BIFF5
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()
451 maStrm
.DisableDecryption();
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!
470 void ImportExcel::SheetPassword()
472 if (GetRoot().GetBiff() != EXC_BIFF8
)
475 GetRoot().GetSheetProtectBuffer().ReadPasswordHash( aIn
, GetCurrScTab() );
478 void ImportExcel::Externsheet()
480 OUString aUrl
, aTabName
;
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
)
492 GetRoot().GetDocProtectBuffer().ReadWinProtect( aIn
);
495 void ImportExcel::Columndefault()
496 {// Default Cell Attributes
497 sal_uInt16 nColMic
, nColMac
;
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" );
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()
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
)
532 nFormLen
= aIn
.ReaduInt8();
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!");
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()
565 n1904
= aIn
.ReaduInt16();
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()
581 nOpt
= aIn
.ReaduInt16();
582 nRes
= aIn
.ReaduInt32();
584 OUString
aName( aIn
.ReadByteString( false ) );
586 if( ( nOpt
& 0x0001 ) || ( ( nOpt
& 0xFFFE ) == 0x0000 ) )
588 aName
= ScfTools::ConvertToScDefinedName( aName
);
589 pExcRoot
->pExtNameBuff
->AddName( aName
, mnLastRefIdx
);
591 else if( nOpt
& 0x0010 )
593 pExcRoot
->pExtNameBuff
->AddOLE( aName
, mnLastRefIdx
, nRes
); // nRes is storage ID
597 pExcRoot
->pExtNameBuff
->AddDDE( aName
, mnLastRefIdx
);
601 void ImportExcel::Colwidth()
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
)
631 GetRoot().GetSheetProtectBuffer().ReadProtect( aIn
, GetCurrScTab() );
634 void ImportExcel::DocProtect()
636 if (GetRoot().GetBiff() != EXC_BIFF8
)
639 GetRoot().GetDocProtectBuffer().ReadDocProtect( aIn
);
642 void ImportExcel::DocPasssword()
644 if (GetRoot().GetBiff() != EXC_BIFF8
)
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();
667 SAL_WARN("sc", "*ImportExcel::DefColWidth(): pColRowBuff is NULL!");
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
;
684 nColFirst
= aIn
.ReaduInt16();
685 nColLast
= aIn
.ReaduInt16();
686 nColWidth
= aIn
.ReaduInt16();
687 nXF
= aIn
.ReaduInt16();
688 nOpt
= aIn
.ReaduInt16();
690 if( nColFirst
> MAXCOL
)
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
);
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()
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
);
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
);
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()
783 ScVObjMode eOle
, eChart
, eDraw
;
785 nHide
= aIn
.ReaduInt16();
787 ScViewOptions
aOpts( pD
->GetViewOptions() );
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
;
797 eOle
= VOBJ_MODE_HIDE
;
798 eChart
= VOBJ_MODE_HIDE
;
799 eDraw
= VOBJ_MODE_HIDE
;
802 eOle
= VOBJ_MODE_SHOW
;
803 eChart
= VOBJ_MODE_SHOW
;
804 eDraw
= VOBJ_MODE_SHOW
;
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() );
820 SAL_WARN("sc", "*ImportExcel::Standardwidth(): pColRowBuff is NULL!");
823 pColRowBuff
->SetDefWidth( nScWidth
, true );
826 void ImportExcel::Shrfmla()
830 case EXC_ID2_FORMULA
:
831 case EXC_ID3_FORMULA
:
832 case EXC_ID4_FORMULA
:
833 // This record MUST immediately follow a FORMULA record.
840 // The last FORMULA record should have left this data.
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()
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()
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()
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();
953 nCount
= maStrm
.ReaduInt16();
954 for( sal_uInt16 nIdx
= 0; (nIdx
< nCount
) && (maStrm
.GetRecLeft() >= 8); ++nIdx
)
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
);
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();
981 SCROW nScRow
= static_cast< SCROW
>( nRow
);
983 if( ValidRow( nScRow
) )
985 nRowHeight
= aIn
.ReaduInt16(); // specify direct in Twips
988 nRowHeight
= nRowHeight
& 0x7FFF; // Bit 15: Row Height not changed manually
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();
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!");
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();
1063 SAL_WARN("sc", "*ImportExcel::Defrowheight345(): pColRowBuff is NULL!");
1067 pColRowBuff
->SetDefHeight( nDefHeight
, nFlags
);
1070 void ImportExcel::TableOp()
1072 sal_uInt16 nFirstRow
, nLastRow
;
1073 sal_uInt8 nFirstCol
, nLastCol
;
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,
1103 aTabOpParam
.aRefFormulaEnd
.Set(
1104 static_cast<SCCOL
>(nLastCol
),
1105 static_cast<SCROW
>(nFirstRow
- 1), nTab
, false,
1107 aTabOpParam
.aRefColCell
.Set( static_cast<SCCOL
>(nInpCol
),
1108 static_cast<SCROW
>(nInpRow
), nTab
, false, false,
1112 case ScTabOpParam::Row
:
1113 aTabOpParam
.aRefFormulaCell
.Set(
1114 static_cast<SCCOL
>(nFirstCol
- 1),
1115 static_cast<SCROW
>(nFirstRow
), nTab
, false, false,
1117 aTabOpParam
.aRefFormulaEnd
.Set(
1118 static_cast<SCCOL
>(nFirstCol
- 1),
1119 static_cast<SCROW
>(nLastRow
), nTab
, false, false,
1121 aTabOpParam
.aRefRowCell
.Set( static_cast<SCCOL
>(nInpCol
),
1122 static_cast<SCROW
>(nInpRow
), nTab
, false, false,
1126 case ScTabOpParam::Both
: // TWO-INPUT
1127 aTabOpParam
.aRefFormulaCell
.Set(
1128 static_cast<SCCOL
>(nFirstCol
- 1),
1129 static_cast<SCROW
>(nFirstRow
- 1), nTab
, false,
1131 aTabOpParam
.aRefRowCell
.Set( static_cast<SCCOL
>(nInpCol
),
1132 static_cast<SCROW
>(nInpRow
), nTab
, false, false,
1134 aTabOpParam
.aRefColCell
.Set( static_cast<SCCOL
>(nInpCol2
),
1135 static_cast<SCROW
>(nInpRow2
), nTab
, false, false,
1140 ScDocumentImport
& rDoc
= GetDocImport();
1141 ScRange
aTabOpRange(nCol
, nRow
, nTab
, nLastCol
, nLastRow
, nTab
);
1142 rDoc
.setTableOpCells(aTabOpRange
, aTabOpParam
);
1147 bTabTruncated
= true;
1148 GetTracer().TraceInvalidRow(nLastRow
, MAXROW
);
1152 void ImportExcel::Bof4()
1154 sal_uInt16 nSubType
;
1155 maStrm
.DisableDecryption();
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
;
1175 maStrm
.DisableDecryption();
1176 nVers
= maStrm
.ReaduInt16();
1177 nSubType
= maStrm
.ReaduInt16( );
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
1187 pExcRoot
->eDateiTyp
= BiffX
;
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();
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
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();
1314 if( pExcRoot
->pPrintRanges
->HasRanges() )
1316 for( SCTAB n
= 0 ; n
< nLast
; n
++ )
1318 p
= pExcRoot
->pPrintRanges
->First(n
);
1321 pD
->ClearPrintRanges( n
);
1324 pD
->AddPrintRange( n
, *p
);
1325 p
= pExcRoot
->pPrintRanges
->Next();
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
);
1344 bool bRowVirgin
= true;
1345 bool bColVirgin
= true;
1349 if( p
->aStart
.Col() == 0 && p
->aEnd
.Col() == MAXCOL
&& bRowVirgin
)
1351 pD
->SetRepeatRowRange( n
, p
);
1355 if( p
->aStart
.Row() == 0 && p
->aEnd
.Row() == MAXROW
&& bColVirgin
)
1357 pD
->SetRepeatColRange( n
, p
);
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
) ),
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: */