xref: /AOO41X/main/oox/source/xls/worksheetfragment.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include "oox/xls/worksheetfragment.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "oox/core/filterbase.hxx"
31*cdf0e10cSrcweir #include "oox/core/relations.hxx"
32*cdf0e10cSrcweir #include "oox/helper/attributelist.hxx"
33*cdf0e10cSrcweir #include "oox/xls/addressconverter.hxx"
34*cdf0e10cSrcweir #include "oox/xls/autofilterbuffer.hxx"
35*cdf0e10cSrcweir #include "oox/xls/autofiltercontext.hxx"
36*cdf0e10cSrcweir #include "oox/xls/biffinputstream.hxx"
37*cdf0e10cSrcweir #include "oox/xls/commentsfragment.hxx"
38*cdf0e10cSrcweir #include "oox/xls/condformatcontext.hxx"
39*cdf0e10cSrcweir #include "oox/xls/drawingfragment.hxx"
40*cdf0e10cSrcweir #include "oox/xls/drawingmanager.hxx"
41*cdf0e10cSrcweir #include "oox/xls/externallinkbuffer.hxx"
42*cdf0e10cSrcweir #include "oox/xls/pagesettings.hxx"
43*cdf0e10cSrcweir #include "oox/xls/pivottablefragment.hxx"
44*cdf0e10cSrcweir #include "oox/xls/querytablefragment.hxx"
45*cdf0e10cSrcweir #include "oox/xls/scenariobuffer.hxx"
46*cdf0e10cSrcweir #include "oox/xls/scenariocontext.hxx"
47*cdf0e10cSrcweir #include "oox/xls/sheetdatabuffer.hxx"
48*cdf0e10cSrcweir #include "oox/xls/sheetdatacontext.hxx"
49*cdf0e10cSrcweir #include "oox/xls/tablefragment.hxx"
50*cdf0e10cSrcweir #include "oox/xls/viewsettings.hxx"
51*cdf0e10cSrcweir #include "oox/xls/workbooksettings.hxx"
52*cdf0e10cSrcweir #include "oox/xls/worksheetsettings.hxx"
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir namespace oox {
55*cdf0e10cSrcweir namespace xls {
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir // ============================================================================
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir using namespace ::com::sun::star::table;
60*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
61*cdf0e10cSrcweir using namespace ::oox::core;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir using ::rtl::OUString;
64*cdf0e10cSrcweir using ::rtl::OUStringBuffer;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir // ============================================================================
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir namespace {
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir const sal_uInt16 BIFF_COLINFO_HIDDEN        = 0x0001;
71*cdf0e10cSrcweir const sal_uInt16 BIFF_COLINFO_SHOWPHONETIC  = 0x0008;
72*cdf0e10cSrcweir const sal_uInt16 BIFF_COLINFO_COLLAPSED     = 0x1000;
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir const sal_uInt16 BIFF_DEFROW_CUSTOMHEIGHT   = 0x0001;
75*cdf0e10cSrcweir const sal_uInt16 BIFF_DEFROW_HIDDEN         = 0x0002;
76*cdf0e10cSrcweir const sal_uInt16 BIFF_DEFROW_THICKTOP       = 0x0004;
77*cdf0e10cSrcweir const sal_uInt16 BIFF_DEFROW_THICKBOTTOM    = 0x0008;
78*cdf0e10cSrcweir const sal_uInt16 BIFF2_DEFROW_DEFHEIGHT     = 0x8000;
79*cdf0e10cSrcweir const sal_uInt16 BIFF2_DEFROW_MASK          = 0x7FFF;
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir const sal_uInt32 BIFF_DATAVAL_STRINGLIST    = 0x00000080;
82*cdf0e10cSrcweir const sal_uInt32 BIFF_DATAVAL_ALLOWBLANK    = 0x00000100;
83*cdf0e10cSrcweir const sal_uInt32 BIFF_DATAVAL_NODROPDOWN    = 0x00000200;
84*cdf0e10cSrcweir const sal_uInt32 BIFF_DATAVAL_SHOWINPUT     = 0x00040000;
85*cdf0e10cSrcweir const sal_uInt32 BIFF_DATAVAL_SHOWERROR     = 0x00080000;
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir const sal_uInt32 BIFF_SHRFEATHEAD_SHEETPROT = 2;
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir const sal_Int32 BIFF12_OLEOBJECT_CONTENT    = 1;
90*cdf0e10cSrcweir const sal_Int32 BIFF12_OLEOBJECT_ICON       = 4;
91*cdf0e10cSrcweir const sal_Int32 BIFF12_OLEOBJECT_ALWAYS     = 1;
92*cdf0e10cSrcweir const sal_Int32 BIFF12_OLEOBJECT_ONCALL     = 3;
93*cdf0e10cSrcweir const sal_uInt16 BIFF12_OLEOBJECT_LINKED    = 0x0001;
94*cdf0e10cSrcweir const sal_uInt16 BIFF12_OLEOBJECT_AUTOLOAD  = 0x0002;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir } // namespace
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir // ============================================================================
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir DataValidationsContext::DataValidationsContext( WorksheetFragmentBase& rFragment ) :
101*cdf0e10cSrcweir     WorksheetContextBase( rFragment )
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir }
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir ContextHandlerRef DataValidationsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir     switch( getCurrentElement() )
108*cdf0e10cSrcweir     {
109*cdf0e10cSrcweir         case XLS_TOKEN( dataValidations ):
110*cdf0e10cSrcweir             if( nElement == XLS_TOKEN( dataValidation ) )
111*cdf0e10cSrcweir             {
112*cdf0e10cSrcweir                 importDataValidation( rAttribs );
113*cdf0e10cSrcweir                 return this;
114*cdf0e10cSrcweir             }
115*cdf0e10cSrcweir         break;
116*cdf0e10cSrcweir         case XLS_TOKEN( dataValidation ):
117*cdf0e10cSrcweir             switch( nElement )
118*cdf0e10cSrcweir             {
119*cdf0e10cSrcweir                 case XLS_TOKEN( formula1 ):
120*cdf0e10cSrcweir                 case XLS_TOKEN( formula2 ):
121*cdf0e10cSrcweir                     return this;    // collect formulas in onCharacters()
122*cdf0e10cSrcweir             }
123*cdf0e10cSrcweir         break;
124*cdf0e10cSrcweir     }
125*cdf0e10cSrcweir     return 0;
126*cdf0e10cSrcweir }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir void DataValidationsContext::onCharacters( const OUString& rChars )
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir     if( mxValModel.get() ) switch( getCurrentElement() )
131*cdf0e10cSrcweir     {
132*cdf0e10cSrcweir         case XLS_TOKEN( formula1 ):
133*cdf0e10cSrcweir             mxValModel->maTokens1 = getFormulaParser().importFormula( mxValModel->maRanges.getBaseAddress(), rChars );
134*cdf0e10cSrcweir             // process string list of a list validation (convert to list of string tokens)
135*cdf0e10cSrcweir             if( mxValModel->mnType == XML_list )
136*cdf0e10cSrcweir                 getFormulaParser().convertStringToStringList( mxValModel->maTokens1, ',', true );
137*cdf0e10cSrcweir         break;
138*cdf0e10cSrcweir         case XLS_TOKEN( formula2 ):
139*cdf0e10cSrcweir             mxValModel->maTokens2 = getFormulaParser().importFormula( mxValModel->maRanges.getBaseAddress(), rChars );
140*cdf0e10cSrcweir         break;
141*cdf0e10cSrcweir     }
142*cdf0e10cSrcweir }
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir void DataValidationsContext::onEndElement()
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir     if( isCurrentElement( XLS_TOKEN( dataValidation ) ) && mxValModel.get() )
147*cdf0e10cSrcweir     {
148*cdf0e10cSrcweir         setValidation( *mxValModel );
149*cdf0e10cSrcweir         mxValModel.reset();
150*cdf0e10cSrcweir     }
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir ContextHandlerRef DataValidationsContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir     if( nRecId == BIFF12_ID_DATAVALIDATION )
157*cdf0e10cSrcweir         importDataValidation( rStrm );
158*cdf0e10cSrcweir     return 0;
159*cdf0e10cSrcweir }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir void DataValidationsContext::importDataValidation( const AttributeList& rAttribs )
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir     mxValModel.reset( new ValidationModel );
164*cdf0e10cSrcweir     getAddressConverter().convertToCellRangeList( mxValModel->maRanges, rAttribs.getString( XML_sqref, OUString() ), getSheetIndex(), true );
165*cdf0e10cSrcweir     mxValModel->maInputTitle   = rAttribs.getXString( XML_promptTitle, OUString() );
166*cdf0e10cSrcweir     mxValModel->maInputMessage = rAttribs.getXString( XML_prompt, OUString() );
167*cdf0e10cSrcweir     mxValModel->maErrorTitle   = rAttribs.getXString( XML_errorTitle, OUString() );
168*cdf0e10cSrcweir     mxValModel->maErrorMessage = rAttribs.getXString( XML_error, OUString() );
169*cdf0e10cSrcweir     mxValModel->mnType         = rAttribs.getToken( XML_type, XML_none );
170*cdf0e10cSrcweir     mxValModel->mnOperator     = rAttribs.getToken( XML_operator, XML_between );
171*cdf0e10cSrcweir     mxValModel->mnErrorStyle   = rAttribs.getToken( XML_errorStyle, XML_stop );
172*cdf0e10cSrcweir     mxValModel->mbShowInputMsg = rAttribs.getBool( XML_showInputMessage, false );
173*cdf0e10cSrcweir     mxValModel->mbShowErrorMsg = rAttribs.getBool( XML_showErrorMessage, false );
174*cdf0e10cSrcweir     /*  The attribute showDropDown@dataValidation is in fact a "suppress
175*cdf0e10cSrcweir         dropdown" flag, as it was in the BIFF format! ECMA specification
176*cdf0e10cSrcweir         and attribute name are plain wrong! */
177*cdf0e10cSrcweir     mxValModel->mbNoDropDown   = rAttribs.getBool( XML_showDropDown, false );
178*cdf0e10cSrcweir     mxValModel->mbAllowBlank   = rAttribs.getBool( XML_allowBlank, false );
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir void DataValidationsContext::importDataValidation( SequenceInputStream& rStrm )
182*cdf0e10cSrcweir {
183*cdf0e10cSrcweir     ValidationModel aModel;
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     sal_uInt32 nFlags;
186*cdf0e10cSrcweir     BinRangeList aRanges;
187*cdf0e10cSrcweir     rStrm >> nFlags >> aRanges >> aModel.maErrorTitle >> aModel.maErrorMessage >> aModel.maInputTitle >> aModel.maInputMessage;
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir     // equal flags in all BIFFs
190*cdf0e10cSrcweir     aModel.setBiffType( extractValue< sal_uInt8 >( nFlags, 0, 4 ) );
191*cdf0e10cSrcweir     aModel.setBiffOperator( extractValue< sal_uInt8 >( nFlags, 20, 4 ) );
192*cdf0e10cSrcweir     aModel.setBiffErrorStyle( extractValue< sal_uInt8 >( nFlags, 4, 3 ) );
193*cdf0e10cSrcweir     aModel.mbAllowBlank   = getFlag( nFlags, BIFF_DATAVAL_ALLOWBLANK );
194*cdf0e10cSrcweir     aModel.mbNoDropDown   = getFlag( nFlags, BIFF_DATAVAL_NODROPDOWN );
195*cdf0e10cSrcweir     aModel.mbShowInputMsg = getFlag( nFlags, BIFF_DATAVAL_SHOWINPUT );
196*cdf0e10cSrcweir     aModel.mbShowErrorMsg = getFlag( nFlags, BIFF_DATAVAL_SHOWERROR );
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     // cell range list
199*cdf0e10cSrcweir     getAddressConverter().convertToCellRangeList( aModel.maRanges, aRanges, getSheetIndex(), true );
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir     // condition formula(s)
202*cdf0e10cSrcweir     FormulaParser& rParser = getFormulaParser();
203*cdf0e10cSrcweir     CellAddress aBaseAddr = aModel.maRanges.getBaseAddress();
204*cdf0e10cSrcweir     aModel.maTokens1 = rParser.importFormula( aBaseAddr, FORMULATYPE_VALIDATION, rStrm );
205*cdf0e10cSrcweir     aModel.maTokens2 = rParser.importFormula( aBaseAddr, FORMULATYPE_VALIDATION, rStrm );
206*cdf0e10cSrcweir     // process string list of a list validation (convert to list of string tokens)
207*cdf0e10cSrcweir     if( (aModel.mnType == XML_list) && getFlag( nFlags, BIFF_DATAVAL_STRINGLIST ) )
208*cdf0e10cSrcweir         rParser.convertStringToStringList( aModel.maTokens1, ',', true );
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir     // set validation data
211*cdf0e10cSrcweir     setValidation( aModel );
212*cdf0e10cSrcweir }
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir // ============================================================================
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir WorksheetFragment::WorksheetFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
217*cdf0e10cSrcweir     WorksheetFragmentBase( rHelper, rFragmentPath )
218*cdf0e10cSrcweir {
219*cdf0e10cSrcweir     // import data tables related to this worksheet
220*cdf0e10cSrcweir     RelationsRef xTableRels = getRelations().getRelationsFromType( CREATE_OFFICEDOC_RELATION_TYPE( "table" ) );
221*cdf0e10cSrcweir     for( Relations::const_iterator aIt = xTableRels->begin(), aEnd = xTableRels->end(); aIt != aEnd; ++aIt )
222*cdf0e10cSrcweir         importOoxFragment( new TableFragment( *this, getFragmentPathFromRelation( aIt->second ) ) );
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir     // import comments related to this worksheet
225*cdf0e10cSrcweir     OUString aCommentsFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "comments" ) );
226*cdf0e10cSrcweir     if( aCommentsFragmentPath.getLength() > 0 )
227*cdf0e10cSrcweir         importOoxFragment( new CommentsFragment( *this, aCommentsFragmentPath ) );
228*cdf0e10cSrcweir }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir ContextHandlerRef WorksheetFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
231*cdf0e10cSrcweir {
232*cdf0e10cSrcweir     switch( getCurrentElement() )
233*cdf0e10cSrcweir     {
234*cdf0e10cSrcweir         case XML_ROOT_CONTEXT: switch( getSheetType() )
235*cdf0e10cSrcweir         {
236*cdf0e10cSrcweir             case SHEETTYPE_WORKSHEET:   return (nElement == XLS_TOKEN( worksheet )) ? this : 0;
237*cdf0e10cSrcweir             case SHEETTYPE_CHARTSHEET:  return 0;
238*cdf0e10cSrcweir             case SHEETTYPE_MACROSHEET:  return (nElement == XM_TOKEN( macrosheet )) ? this : 0;
239*cdf0e10cSrcweir             case SHEETTYPE_DIALOGSHEET: return (nElement == XLS_TOKEN( dialogsheet )) ? this : 0;
240*cdf0e10cSrcweir             case SHEETTYPE_MODULESHEET: return 0;
241*cdf0e10cSrcweir             case SHEETTYPE_EMPTYSHEET:  return 0;
242*cdf0e10cSrcweir         }
243*cdf0e10cSrcweir         break;
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir         case XLS_TOKEN( worksheet ):
246*cdf0e10cSrcweir         case XM_TOKEN( macrosheet ):
247*cdf0e10cSrcweir         case XLS_TOKEN( dialogsheet ):
248*cdf0e10cSrcweir             switch( nElement )
249*cdf0e10cSrcweir             {
250*cdf0e10cSrcweir                 case XLS_TOKEN( sheetData ):                return new SheetDataContext( *this );
251*cdf0e10cSrcweir                 case XLS_TOKEN( conditionalFormatting ):    return new CondFormatContext( *this );
252*cdf0e10cSrcweir                 case XLS_TOKEN( dataValidations ):          return new DataValidationsContext( *this );
253*cdf0e10cSrcweir                 case XLS_TOKEN( autoFilter ):               return new AutoFilterContext( *this, getAutoFilters().createAutoFilter() );
254*cdf0e10cSrcweir                 case XLS_TOKEN( scenarios ):                return new ScenariosContext( *this );
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir                 case XLS_TOKEN( sheetViews ):
257*cdf0e10cSrcweir                 case XLS_TOKEN( cols ):
258*cdf0e10cSrcweir                 case XLS_TOKEN( mergeCells ):
259*cdf0e10cSrcweir                 case XLS_TOKEN( hyperlinks ):
260*cdf0e10cSrcweir                 case XLS_TOKEN( rowBreaks ):
261*cdf0e10cSrcweir                 case XLS_TOKEN( colBreaks ):
262*cdf0e10cSrcweir                 case XLS_TOKEN( oleObjects ):
263*cdf0e10cSrcweir                 case XLS_TOKEN( controls ):         return this;
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir                 case XLS_TOKEN( sheetPr ):          getWorksheetSettings().importSheetPr( rAttribs );               return this;
266*cdf0e10cSrcweir                 case XLS_TOKEN( dimension ):        importDimension( rAttribs );                                    break;
267*cdf0e10cSrcweir                 case XLS_TOKEN( sheetFormatPr ):    importSheetFormatPr( rAttribs );                                break;
268*cdf0e10cSrcweir                 case XLS_TOKEN( sheetProtection ):  getWorksheetSettings().importSheetProtection( rAttribs );       break;
269*cdf0e10cSrcweir                 case XLS_TOKEN( phoneticPr ):       getWorksheetSettings().importPhoneticPr( rAttribs );            break;
270*cdf0e10cSrcweir                 case XLS_TOKEN( printOptions ):     getPageSettings().importPrintOptions( rAttribs );               break;
271*cdf0e10cSrcweir                 case XLS_TOKEN( pageMargins ):      getPageSettings().importPageMargins( rAttribs );                break;
272*cdf0e10cSrcweir                 case XLS_TOKEN( pageSetup ):        getPageSettings().importPageSetup( getRelations(), rAttribs );  break;
273*cdf0e10cSrcweir                 case XLS_TOKEN( headerFooter ):     getPageSettings().importHeaderFooter( rAttribs );               return this;
274*cdf0e10cSrcweir                 case XLS_TOKEN( picture ):          getPageSettings().importPicture( getRelations(), rAttribs );    break;
275*cdf0e10cSrcweir                 case XLS_TOKEN( drawing ):          importDrawing( rAttribs );                                      break;
276*cdf0e10cSrcweir                 case XLS_TOKEN( legacyDrawing ):    importLegacyDrawing( rAttribs );                                break;
277*cdf0e10cSrcweir             }
278*cdf0e10cSrcweir         break;
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir         case XLS_TOKEN( sheetPr ):
281*cdf0e10cSrcweir             switch( nElement )
282*cdf0e10cSrcweir             {
283*cdf0e10cSrcweir                 case XLS_TOKEN( tabColor ):         getWorksheetSettings().importTabColor( rAttribs );              break;
284*cdf0e10cSrcweir                 case XLS_TOKEN( outlinePr ):        getWorksheetSettings().importOutlinePr( rAttribs );             break;
285*cdf0e10cSrcweir                 case XLS_TOKEN( pageSetUpPr ):      importPageSetUpPr( rAttribs );                                  break;
286*cdf0e10cSrcweir             }
287*cdf0e10cSrcweir         break;
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir         case XLS_TOKEN( sheetViews ):
290*cdf0e10cSrcweir             switch( nElement )
291*cdf0e10cSrcweir             {
292*cdf0e10cSrcweir                 case XLS_TOKEN( sheetView ):        getSheetViewSettings().importSheetView( rAttribs );             return this;
293*cdf0e10cSrcweir             }
294*cdf0e10cSrcweir         break;
295*cdf0e10cSrcweir         case XLS_TOKEN( sheetView ):
296*cdf0e10cSrcweir             switch( nElement )
297*cdf0e10cSrcweir             {
298*cdf0e10cSrcweir                 case XLS_TOKEN( pane ):             getSheetViewSettings().importPane( rAttribs );                  break;
299*cdf0e10cSrcweir                 case XLS_TOKEN( selection ):        getSheetViewSettings().importSelection( rAttribs );             break;
300*cdf0e10cSrcweir             }
301*cdf0e10cSrcweir         break;
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir         case XLS_TOKEN( cols ):
304*cdf0e10cSrcweir             if( nElement == XLS_TOKEN( col ) ) importCol( rAttribs );
305*cdf0e10cSrcweir         break;
306*cdf0e10cSrcweir         case XLS_TOKEN( mergeCells ):
307*cdf0e10cSrcweir             if( nElement == XLS_TOKEN( mergeCell ) ) importMergeCell( rAttribs );
308*cdf0e10cSrcweir         break;
309*cdf0e10cSrcweir         case XLS_TOKEN( hyperlinks ):
310*cdf0e10cSrcweir             if( nElement == XLS_TOKEN( hyperlink ) ) importHyperlink( rAttribs );
311*cdf0e10cSrcweir         break;
312*cdf0e10cSrcweir         case XLS_TOKEN( rowBreaks ):
313*cdf0e10cSrcweir             if( nElement == XLS_TOKEN( brk ) ) importBrk( rAttribs, true );
314*cdf0e10cSrcweir         break;
315*cdf0e10cSrcweir         case XLS_TOKEN( colBreaks ):
316*cdf0e10cSrcweir             if( nElement == XLS_TOKEN( brk ) ) importBrk( rAttribs, false );
317*cdf0e10cSrcweir         break;
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir         case XLS_TOKEN( headerFooter ):
320*cdf0e10cSrcweir             switch( nElement )
321*cdf0e10cSrcweir             {
322*cdf0e10cSrcweir                 case XLS_TOKEN( firstHeader ):
323*cdf0e10cSrcweir                 case XLS_TOKEN( firstFooter ):
324*cdf0e10cSrcweir                 case XLS_TOKEN( oddHeader ):
325*cdf0e10cSrcweir                 case XLS_TOKEN( oddFooter ):
326*cdf0e10cSrcweir                 case XLS_TOKEN( evenHeader ):
327*cdf0e10cSrcweir                 case XLS_TOKEN( evenFooter ):       return this;    // collect h/f contents in onCharacters()
328*cdf0e10cSrcweir             }
329*cdf0e10cSrcweir         break;
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir         case XLS_TOKEN( oleObjects ):
332*cdf0e10cSrcweir             if( nElement == XLS_TOKEN( oleObject ) ) importOleObject( rAttribs );
333*cdf0e10cSrcweir         break;
334*cdf0e10cSrcweir         case XLS_TOKEN( controls ):
335*cdf0e10cSrcweir             if( nElement == XLS_TOKEN( control ) ) importControl( rAttribs );
336*cdf0e10cSrcweir         break;
337*cdf0e10cSrcweir     }
338*cdf0e10cSrcweir     return 0;
339*cdf0e10cSrcweir }
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir void WorksheetFragment::onCharacters( const OUString& rChars )
342*cdf0e10cSrcweir {
343*cdf0e10cSrcweir     switch( getCurrentElement() )
344*cdf0e10cSrcweir     {
345*cdf0e10cSrcweir         case XLS_TOKEN( firstHeader ):
346*cdf0e10cSrcweir         case XLS_TOKEN( firstFooter ):
347*cdf0e10cSrcweir         case XLS_TOKEN( oddHeader ):
348*cdf0e10cSrcweir         case XLS_TOKEN( oddFooter ):
349*cdf0e10cSrcweir         case XLS_TOKEN( evenHeader ):
350*cdf0e10cSrcweir         case XLS_TOKEN( evenFooter ):
351*cdf0e10cSrcweir             getPageSettings().importHeaderFooterCharacters( rChars, getCurrentElement() );
352*cdf0e10cSrcweir         break;
353*cdf0e10cSrcweir     }
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir ContextHandlerRef WorksheetFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
357*cdf0e10cSrcweir {
358*cdf0e10cSrcweir     switch( getCurrentElement() )
359*cdf0e10cSrcweir     {
360*cdf0e10cSrcweir         case XML_ROOT_CONTEXT:
361*cdf0e10cSrcweir             if( nRecId == BIFF12_ID_WORKSHEET ) return this;
362*cdf0e10cSrcweir         break;
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir         case BIFF12_ID_WORKSHEET:
365*cdf0e10cSrcweir             switch( nRecId )
366*cdf0e10cSrcweir             {
367*cdf0e10cSrcweir                 case BIFF12_ID_SHEETDATA:       return new SheetDataContext( *this );
368*cdf0e10cSrcweir                 case BIFF12_ID_CONDFORMATTING:  return new CondFormatContext( *this );
369*cdf0e10cSrcweir                 case BIFF12_ID_DATAVALIDATIONS: return new DataValidationsContext( *this );
370*cdf0e10cSrcweir                 case BIFF12_ID_AUTOFILTER:      return new AutoFilterContext( *this, getAutoFilters().createAutoFilter() );
371*cdf0e10cSrcweir                 case BIFF12_ID_SCENARIOS:       return new ScenariosContext( *this );
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir                 case BIFF12_ID_SHEETVIEWS:
374*cdf0e10cSrcweir                 case BIFF12_ID_COLS:
375*cdf0e10cSrcweir                 case BIFF12_ID_MERGECELLS:
376*cdf0e10cSrcweir                 case BIFF12_ID_ROWBREAKS:
377*cdf0e10cSrcweir                 case BIFF12_ID_COLBREAKS:
378*cdf0e10cSrcweir                 case BIFF12_ID_OLEOBJECTS:
379*cdf0e10cSrcweir                 case BIFF12_ID_CONTROLS:        return this;
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir                 case BIFF12_ID_SHEETPR:         getWorksheetSettings().importSheetPr( rStrm );              break;
382*cdf0e10cSrcweir                 case BIFF12_ID_DIMENSION:       importDimension( rStrm );                                   break;
383*cdf0e10cSrcweir                 case BIFF12_ID_SHEETFORMATPR:   importSheetFormatPr( rStrm );                               break;
384*cdf0e10cSrcweir                 case BIFF12_ID_HYPERLINK:       importHyperlink( rStrm );                                   break;
385*cdf0e10cSrcweir                 case BIFF12_ID_PAGEMARGINS:     getPageSettings().importPageMargins( rStrm );               break;
386*cdf0e10cSrcweir                 case BIFF12_ID_PAGESETUP:       getPageSettings().importPageSetup( getRelations(), rStrm ); break;
387*cdf0e10cSrcweir                 case BIFF12_ID_PRINTOPTIONS:    getPageSettings().importPrintOptions( rStrm );              break;
388*cdf0e10cSrcweir                 case BIFF12_ID_HEADERFOOTER:    getPageSettings().importHeaderFooter( rStrm );              break;
389*cdf0e10cSrcweir                 case BIFF12_ID_PICTURE:         getPageSettings().importPicture( getRelations(), rStrm );   break;
390*cdf0e10cSrcweir                 case BIFF12_ID_SHEETPROTECTION: getWorksheetSettings().importSheetProtection( rStrm );      break;
391*cdf0e10cSrcweir                 case BIFF12_ID_PHONETICPR:      getWorksheetSettings().importPhoneticPr( rStrm );           break;
392*cdf0e10cSrcweir                 case BIFF12_ID_DRAWING:         importDrawing( rStrm );                                     break;
393*cdf0e10cSrcweir                 case BIFF12_ID_LEGACYDRAWING:   importLegacyDrawing( rStrm );                               break;
394*cdf0e10cSrcweir             }
395*cdf0e10cSrcweir         break;
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir         case BIFF12_ID_SHEETVIEWS:
398*cdf0e10cSrcweir             switch( nRecId )
399*cdf0e10cSrcweir             {
400*cdf0e10cSrcweir                 case BIFF12_ID_SHEETVIEW:       getSheetViewSettings().importSheetView( rStrm );            return this;
401*cdf0e10cSrcweir             }
402*cdf0e10cSrcweir         break;
403*cdf0e10cSrcweir         case BIFF12_ID_SHEETVIEW:
404*cdf0e10cSrcweir             switch( nRecId )
405*cdf0e10cSrcweir             {
406*cdf0e10cSrcweir                 case BIFF12_ID_PANE:            getSheetViewSettings().importPane( rStrm );                 break;
407*cdf0e10cSrcweir                 case BIFF12_ID_SELECTION:       getSheetViewSettings().importSelection( rStrm );            break;
408*cdf0e10cSrcweir             }
409*cdf0e10cSrcweir         break;
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir         case BIFF12_ID_COLS:
412*cdf0e10cSrcweir             if( nRecId == BIFF12_ID_COL ) importCol( rStrm );
413*cdf0e10cSrcweir         break;
414*cdf0e10cSrcweir         case BIFF12_ID_MERGECELLS:
415*cdf0e10cSrcweir             if( nRecId == BIFF12_ID_MERGECELL ) importMergeCell( rStrm );
416*cdf0e10cSrcweir         break;
417*cdf0e10cSrcweir         case BIFF12_ID_ROWBREAKS:
418*cdf0e10cSrcweir             if( nRecId == BIFF12_ID_BRK ) importBrk( rStrm, true );
419*cdf0e10cSrcweir         break;
420*cdf0e10cSrcweir         case BIFF12_ID_COLBREAKS:
421*cdf0e10cSrcweir             if( nRecId == BIFF12_ID_BRK ) importBrk( rStrm, false );
422*cdf0e10cSrcweir         break;
423*cdf0e10cSrcweir         case BIFF12_ID_OLEOBJECTS:
424*cdf0e10cSrcweir             if( nRecId == BIFF12_ID_OLEOBJECT ) importOleObject( rStrm );
425*cdf0e10cSrcweir         break;
426*cdf0e10cSrcweir         case BIFF12_ID_CONTROLS:
427*cdf0e10cSrcweir             if( nRecId == BIFF12_ID_CONTROL ) importControl( rStrm );
428*cdf0e10cSrcweir         break;
429*cdf0e10cSrcweir     }
430*cdf0e10cSrcweir     return 0;
431*cdf0e10cSrcweir }
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir const RecordInfo* WorksheetFragment::getRecordInfos() const
434*cdf0e10cSrcweir {
435*cdf0e10cSrcweir     static const RecordInfo spRecInfos[] =
436*cdf0e10cSrcweir     {
437*cdf0e10cSrcweir         { BIFF12_ID_AUTOFILTER,         BIFF12_ID_AUTOFILTER + 1        },
438*cdf0e10cSrcweir         { BIFF12_ID_CFRULE,             BIFF12_ID_CFRULE + 1            },
439*cdf0e10cSrcweir         { BIFF12_ID_COLBREAKS,          BIFF12_ID_COLBREAKS + 1         },
440*cdf0e10cSrcweir         { BIFF12_ID_COLORSCALE,         BIFF12_ID_COLORSCALE + 1        },
441*cdf0e10cSrcweir         { BIFF12_ID_COLS,               BIFF12_ID_COLS + 1              },
442*cdf0e10cSrcweir         { BIFF12_ID_CONDFORMATTING,     BIFF12_ID_CONDFORMATTING + 1    },
443*cdf0e10cSrcweir         { BIFF12_ID_CONTROLS,           BIFF12_ID_CONTROLS + 2          },
444*cdf0e10cSrcweir         { BIFF12_ID_CUSTOMFILTERS,      BIFF12_ID_CUSTOMFILTERS + 1     },
445*cdf0e10cSrcweir         { BIFF12_ID_CUSTOMSHEETVIEW,    BIFF12_ID_CUSTOMSHEETVIEW + 1   },
446*cdf0e10cSrcweir         { BIFF12_ID_CUSTOMSHEETVIEWS,   BIFF12_ID_CUSTOMSHEETVIEWS + 3  },
447*cdf0e10cSrcweir         { BIFF12_ID_DATABAR,            BIFF12_ID_DATABAR + 1           },
448*cdf0e10cSrcweir         { BIFF12_ID_DATAVALIDATIONS,    BIFF12_ID_DATAVALIDATIONS + 1   },
449*cdf0e10cSrcweir         { BIFF12_ID_DISCRETEFILTERS,    BIFF12_ID_DISCRETEFILTERS + 1   },
450*cdf0e10cSrcweir         { BIFF12_ID_FILTERCOLUMN,       BIFF12_ID_FILTERCOLUMN + 1      },
451*cdf0e10cSrcweir         { BIFF12_ID_HEADERFOOTER,       BIFF12_ID_HEADERFOOTER + 1      },
452*cdf0e10cSrcweir         { BIFF12_ID_ICONSET,            BIFF12_ID_ICONSET + 1           },
453*cdf0e10cSrcweir         { BIFF12_ID_MERGECELLS,         BIFF12_ID_MERGECELLS + 1        },
454*cdf0e10cSrcweir         { BIFF12_ID_OLEOBJECTS,         BIFF12_ID_OLEOBJECTS + 2        },
455*cdf0e10cSrcweir         { BIFF12_ID_ROW,                -1                              },
456*cdf0e10cSrcweir         { BIFF12_ID_ROWBREAKS,          BIFF12_ID_ROWBREAKS + 1         },
457*cdf0e10cSrcweir         { BIFF12_ID_SCENARIO,           BIFF12_ID_SCENARIO + 1          },
458*cdf0e10cSrcweir         { BIFF12_ID_SCENARIOS,          BIFF12_ID_SCENARIOS + 1         },
459*cdf0e10cSrcweir         { BIFF12_ID_SHEETDATA,          BIFF12_ID_SHEETDATA + 1         },
460*cdf0e10cSrcweir         { BIFF12_ID_SHEETVIEW,          BIFF12_ID_SHEETVIEW + 1         },
461*cdf0e10cSrcweir         { BIFF12_ID_SHEETVIEWS,         BIFF12_ID_SHEETVIEWS + 1        },
462*cdf0e10cSrcweir         { BIFF12_ID_TABLEPARTS,         BIFF12_ID_TABLEPARTS + 2        },
463*cdf0e10cSrcweir         { BIFF12_ID_WORKSHEET,          BIFF12_ID_WORKSHEET + 1         },
464*cdf0e10cSrcweir         { -1,                           -1                              }
465*cdf0e10cSrcweir     };
466*cdf0e10cSrcweir     return spRecInfos;
467*cdf0e10cSrcweir }
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir void WorksheetFragment::initializeImport()
470*cdf0e10cSrcweir {
471*cdf0e10cSrcweir     // initial processing in base class WorksheetHelper
472*cdf0e10cSrcweir     initializeWorksheetImport();
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir     // import query table fragments related to this worksheet
475*cdf0e10cSrcweir     RelationsRef xQueryRels = getRelations().getRelationsFromType( CREATE_OFFICEDOC_RELATION_TYPE( "queryTable" ) );
476*cdf0e10cSrcweir     for( Relations::const_iterator aIt = xQueryRels->begin(), aEnd = xQueryRels->end(); aIt != aEnd; ++aIt )
477*cdf0e10cSrcweir         importOoxFragment( new QueryTableFragment( *this, getFragmentPathFromRelation( aIt->second ) ) );
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir     // import pivot table fragments related to this worksheet
480*cdf0e10cSrcweir     RelationsRef xPivotRels = getRelations().getRelationsFromType( CREATE_OFFICEDOC_RELATION_TYPE( "pivotTable" ) );
481*cdf0e10cSrcweir     for( Relations::const_iterator aIt = xPivotRels->begin(), aEnd = xPivotRels->end(); aIt != aEnd; ++aIt )
482*cdf0e10cSrcweir         importOoxFragment( new PivotTableFragment( *this, getFragmentPathFromRelation( aIt->second ) ) );
483*cdf0e10cSrcweir }
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir void WorksheetFragment::finalizeImport()
486*cdf0e10cSrcweir {
487*cdf0e10cSrcweir     // final processing in base class WorksheetHelper
488*cdf0e10cSrcweir     finalizeWorksheetImport();
489*cdf0e10cSrcweir }
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir // private --------------------------------------------------------------------
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir void WorksheetFragment::importPageSetUpPr( const AttributeList& rAttribs )
494*cdf0e10cSrcweir {
495*cdf0e10cSrcweir     // for whatever reason, this flag is still stored separated from the page settings
496*cdf0e10cSrcweir     getPageSettings().setFitToPagesMode( rAttribs.getBool( XML_fitToPage, false ) );
497*cdf0e10cSrcweir }
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir void WorksheetFragment::importDimension( const AttributeList& rAttribs )
500*cdf0e10cSrcweir {
501*cdf0e10cSrcweir     CellRangeAddress aRange;
502*cdf0e10cSrcweir     getAddressConverter().convertToCellRangeUnchecked( aRange, rAttribs.getString( XML_ref, OUString() ), getSheetIndex() );
503*cdf0e10cSrcweir     /*  OOXML stores the used area, if existing, or "A1" if the sheet is empty.
504*cdf0e10cSrcweir         In case of "A1", the dimension at the WorksheetHelper object will not
505*cdf0e10cSrcweir         be set. If the cell A1 exists, the used area will be updated while
506*cdf0e10cSrcweir         importing the cell. */
507*cdf0e10cSrcweir     if( (aRange.EndColumn > 0) || (aRange.EndRow > 0) )
508*cdf0e10cSrcweir         extendUsedArea( aRange );
509*cdf0e10cSrcweir }
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir void WorksheetFragment::importSheetFormatPr( const AttributeList& rAttribs )
512*cdf0e10cSrcweir {
513*cdf0e10cSrcweir     // default column settings
514*cdf0e10cSrcweir     setBaseColumnWidth( rAttribs.getInteger( XML_baseColWidth, 8 ) );
515*cdf0e10cSrcweir     setDefaultColumnWidth( rAttribs.getDouble( XML_defaultColWidth, 0.0 ) );
516*cdf0e10cSrcweir     // default row settings
517*cdf0e10cSrcweir     setDefaultRowSettings(
518*cdf0e10cSrcweir         rAttribs.getDouble( XML_defaultRowHeight, 0.0 ),
519*cdf0e10cSrcweir         rAttribs.getBool( XML_customHeight, false ),
520*cdf0e10cSrcweir         rAttribs.getBool( XML_zeroHeight, false ),
521*cdf0e10cSrcweir         rAttribs.getBool( XML_thickTop, false ),
522*cdf0e10cSrcweir         rAttribs.getBool( XML_thickBottom, false ) );
523*cdf0e10cSrcweir }
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir void WorksheetFragment::importCol( const AttributeList& rAttribs )
526*cdf0e10cSrcweir {
527*cdf0e10cSrcweir     ColumnModel aModel;
528*cdf0e10cSrcweir     aModel.maRange.mnFirst = rAttribs.getInteger( XML_min, -1 );
529*cdf0e10cSrcweir     aModel.maRange.mnLast  = rAttribs.getInteger( XML_max, -1 );
530*cdf0e10cSrcweir     aModel.mfWidth         = rAttribs.getDouble( XML_width, 0.0 );
531*cdf0e10cSrcweir     aModel.mnXfId          = rAttribs.getInteger( XML_style, -1 );
532*cdf0e10cSrcweir     aModel.mnLevel         = rAttribs.getInteger( XML_outlineLevel, 0 );
533*cdf0e10cSrcweir     aModel.mbShowPhonetic  = rAttribs.getBool( XML_phonetic, false );
534*cdf0e10cSrcweir     aModel.mbHidden        = rAttribs.getBool( XML_hidden, false );
535*cdf0e10cSrcweir     aModel.mbCollapsed     = rAttribs.getBool( XML_collapsed, false );
536*cdf0e10cSrcweir     // set column properties in the current sheet
537*cdf0e10cSrcweir     setColumnModel( aModel );
538*cdf0e10cSrcweir }
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir void WorksheetFragment::importMergeCell( const AttributeList& rAttribs )
541*cdf0e10cSrcweir {
542*cdf0e10cSrcweir     CellRangeAddress aRange;
543*cdf0e10cSrcweir     if( getAddressConverter().convertToCellRange( aRange, rAttribs.getString( XML_ref, OUString() ), getSheetIndex(), true, true ) )
544*cdf0e10cSrcweir         getSheetData().setMergedRange( aRange );
545*cdf0e10cSrcweir }
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir void WorksheetFragment::importHyperlink( const AttributeList& rAttribs )
548*cdf0e10cSrcweir {
549*cdf0e10cSrcweir     HyperlinkModel aModel;
550*cdf0e10cSrcweir     if( getAddressConverter().convertToCellRange( aModel.maRange, rAttribs.getString( XML_ref, OUString() ), getSheetIndex(), true, true ) )
551*cdf0e10cSrcweir     {
552*cdf0e10cSrcweir         aModel.maTarget   = getRelations().getExternalTargetFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) );
553*cdf0e10cSrcweir         aModel.maLocation = rAttribs.getXString( XML_location, OUString() );
554*cdf0e10cSrcweir         aModel.maDisplay  = rAttribs.getXString( XML_display, OUString() );
555*cdf0e10cSrcweir         aModel.maTooltip  = rAttribs.getXString( XML_tooltip, OUString() );
556*cdf0e10cSrcweir         setHyperlink( aModel );
557*cdf0e10cSrcweir     }
558*cdf0e10cSrcweir }
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir void WorksheetFragment::importBrk( const AttributeList& rAttribs, bool bRowBreak )
561*cdf0e10cSrcweir {
562*cdf0e10cSrcweir     PageBreakModel aModel;
563*cdf0e10cSrcweir     aModel.mnColRow = rAttribs.getInteger( XML_id, 0 );
564*cdf0e10cSrcweir     aModel.mnMin    = rAttribs.getInteger( XML_id, 0 );
565*cdf0e10cSrcweir     aModel.mnMax    = rAttribs.getInteger( XML_id, 0 );
566*cdf0e10cSrcweir     aModel.mbManual = rAttribs.getBool( XML_man, false );
567*cdf0e10cSrcweir     setPageBreak( aModel, bRowBreak );
568*cdf0e10cSrcweir }
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir void WorksheetFragment::importDrawing( const AttributeList& rAttribs )
571*cdf0e10cSrcweir {
572*cdf0e10cSrcweir     setDrawingPath( getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ) );
573*cdf0e10cSrcweir }
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir void WorksheetFragment::importLegacyDrawing( const AttributeList& rAttribs )
576*cdf0e10cSrcweir {
577*cdf0e10cSrcweir     setVmlDrawingPath( getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ) );
578*cdf0e10cSrcweir }
579*cdf0e10cSrcweir 
580*cdf0e10cSrcweir void WorksheetFragment::importOleObject( const AttributeList& rAttribs )
581*cdf0e10cSrcweir {
582*cdf0e10cSrcweir     ::oox::vml::OleObjectInfo aInfo;
583*cdf0e10cSrcweir     aInfo.setShapeId( rAttribs.getInteger( XML_shapeId, 0 ) );
584*cdf0e10cSrcweir     OSL_ENSURE( rAttribs.hasAttribute( XML_link ) != rAttribs.hasAttribute( R_TOKEN( id ) ),
585*cdf0e10cSrcweir         "WorksheetFragment::importOleObject - OLE object must be either linked or embedded" );
586*cdf0e10cSrcweir     aInfo.mbLinked = rAttribs.hasAttribute( XML_link );
587*cdf0e10cSrcweir     if( aInfo.mbLinked )
588*cdf0e10cSrcweir         aInfo.maTargetLink = getFormulaParser().importOleTargetLink( rAttribs.getString( XML_link, OUString() ) );
589*cdf0e10cSrcweir     else if( rAttribs.hasAttribute( R_TOKEN( id ) ) )
590*cdf0e10cSrcweir         importEmbeddedOleData( aInfo.maEmbeddedData, rAttribs.getString( R_TOKEN( id ), OUString() ) );
591*cdf0e10cSrcweir     aInfo.maProgId = rAttribs.getString( XML_progId, OUString() );
592*cdf0e10cSrcweir     aInfo.mbShowAsIcon = rAttribs.getToken( XML_dvAspect, XML_DVASPECT_CONTENT ) == XML_DVASPECT_ICON;
593*cdf0e10cSrcweir     aInfo.mbAutoUpdate = rAttribs.getToken( XML_oleUpdate, XML_OLEUPDATE_ONCALL ) == XML_OLEUPDATE_ALWAYS;
594*cdf0e10cSrcweir     aInfo.mbAutoLoad = rAttribs.getBool( XML_autoLoad, false );
595*cdf0e10cSrcweir     getVmlDrawing().registerOleObject( aInfo );
596*cdf0e10cSrcweir }
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir void WorksheetFragment::importControl( const AttributeList& rAttribs )
599*cdf0e10cSrcweir {
600*cdf0e10cSrcweir     ::oox::vml::ControlInfo aInfo;
601*cdf0e10cSrcweir     aInfo.setShapeId( rAttribs.getInteger( XML_shapeId, 0 ) );
602*cdf0e10cSrcweir     aInfo.maFragmentPath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) );
603*cdf0e10cSrcweir     aInfo.maName = rAttribs.getString( XML_name, OUString() );
604*cdf0e10cSrcweir     getVmlDrawing().registerControl( aInfo );
605*cdf0e10cSrcweir }
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir void WorksheetFragment::importDimension( SequenceInputStream& rStrm )
608*cdf0e10cSrcweir {
609*cdf0e10cSrcweir     BinRange aBinRange;
610*cdf0e10cSrcweir     aBinRange.read( rStrm );
611*cdf0e10cSrcweir     CellRangeAddress aRange;
612*cdf0e10cSrcweir     getAddressConverter().convertToCellRangeUnchecked( aRange, aBinRange, getSheetIndex() );
613*cdf0e10cSrcweir     /*  BIFF12 stores the used area, if existing, or "A1" if the sheet is
614*cdf0e10cSrcweir         empty. In case of "A1", the dimension at the WorksheetHelper object
615*cdf0e10cSrcweir         will not be set. If the cell A1 exists, the used area will be updated
616*cdf0e10cSrcweir         while importing the cell. */
617*cdf0e10cSrcweir     if( (aRange.EndColumn > 0) || (aRange.EndRow > 0) )
618*cdf0e10cSrcweir         extendUsedArea( aRange );
619*cdf0e10cSrcweir }
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir void WorksheetFragment::importSheetFormatPr( SequenceInputStream& rStrm )
622*cdf0e10cSrcweir {
623*cdf0e10cSrcweir     sal_Int32 nDefaultWidth;
624*cdf0e10cSrcweir     sal_uInt16 nBaseWidth, nDefaultHeight, nFlags;
625*cdf0e10cSrcweir     rStrm >> nDefaultWidth >> nBaseWidth >> nDefaultHeight >> nFlags;
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir     // base column with
628*cdf0e10cSrcweir     setBaseColumnWidth( nBaseWidth );
629*cdf0e10cSrcweir     // default width is stored as 1/256th of a character in BIFF12, convert to entire character
630*cdf0e10cSrcweir     setDefaultColumnWidth( static_cast< double >( nDefaultWidth ) / 256.0 );
631*cdf0e10cSrcweir     // row height is in twips in BIFF12, convert to points; equal flags in all BIFFs
632*cdf0e10cSrcweir     setDefaultRowSettings(
633*cdf0e10cSrcweir         nDefaultHeight / 20.0,
634*cdf0e10cSrcweir         getFlag( nFlags, BIFF_DEFROW_CUSTOMHEIGHT ),
635*cdf0e10cSrcweir         getFlag( nFlags, BIFF_DEFROW_HIDDEN ),
636*cdf0e10cSrcweir         getFlag( nFlags, BIFF_DEFROW_THICKTOP ),
637*cdf0e10cSrcweir         getFlag( nFlags, BIFF_DEFROW_THICKBOTTOM ) );
638*cdf0e10cSrcweir }
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir void WorksheetFragment::importCol( SequenceInputStream& rStrm )
641*cdf0e10cSrcweir {
642*cdf0e10cSrcweir     ColumnModel aModel;
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir     sal_Int32 nWidth;
645*cdf0e10cSrcweir     sal_uInt16 nFlags;
646*cdf0e10cSrcweir     rStrm >> aModel.maRange.mnFirst >> aModel.maRange.mnLast >> nWidth >> aModel.mnXfId >> nFlags;
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir     // column indexes are 0-based in BIFF12, but ColumnModel expects 1-based
649*cdf0e10cSrcweir     ++aModel.maRange.mnFirst;
650*cdf0e10cSrcweir     ++aModel.maRange.mnLast;
651*cdf0e10cSrcweir     // width is stored as 1/256th of a character in BIFF12, convert to entire character
652*cdf0e10cSrcweir     aModel.mfWidth        = static_cast< double >( nWidth ) / 256.0;
653*cdf0e10cSrcweir     // equal flags in all BIFFs
654*cdf0e10cSrcweir     aModel.mnLevel        = extractValue< sal_Int32 >( nFlags, 8, 3 );
655*cdf0e10cSrcweir     aModel.mbShowPhonetic = getFlag( nFlags, BIFF_COLINFO_SHOWPHONETIC );
656*cdf0e10cSrcweir     aModel.mbHidden       = getFlag( nFlags, BIFF_COLINFO_HIDDEN );
657*cdf0e10cSrcweir     aModel.mbCollapsed    = getFlag( nFlags, BIFF_COLINFO_COLLAPSED );
658*cdf0e10cSrcweir     // set column properties in the current sheet
659*cdf0e10cSrcweir     setColumnModel( aModel );
660*cdf0e10cSrcweir }
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir void WorksheetFragment::importMergeCell( SequenceInputStream& rStrm )
663*cdf0e10cSrcweir {
664*cdf0e10cSrcweir     BinRange aBinRange;
665*cdf0e10cSrcweir     rStrm >> aBinRange;
666*cdf0e10cSrcweir     CellRangeAddress aRange;
667*cdf0e10cSrcweir     if( getAddressConverter().convertToCellRange( aRange, aBinRange, getSheetIndex(), true, true ) )
668*cdf0e10cSrcweir         getSheetData().setMergedRange( aRange );
669*cdf0e10cSrcweir }
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir void WorksheetFragment::importHyperlink( SequenceInputStream& rStrm )
672*cdf0e10cSrcweir {
673*cdf0e10cSrcweir     BinRange aBinRange;
674*cdf0e10cSrcweir     rStrm >> aBinRange;
675*cdf0e10cSrcweir     HyperlinkModel aModel;
676*cdf0e10cSrcweir     if( getAddressConverter().convertToCellRange( aModel.maRange, aBinRange, getSheetIndex(), true, true ) )
677*cdf0e10cSrcweir     {
678*cdf0e10cSrcweir         aModel.maTarget = getRelations().getExternalTargetFromRelId( BiffHelper::readString( rStrm ) );
679*cdf0e10cSrcweir         rStrm >> aModel.maLocation >> aModel.maTooltip >> aModel.maDisplay;
680*cdf0e10cSrcweir         setHyperlink( aModel );
681*cdf0e10cSrcweir     }
682*cdf0e10cSrcweir }
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir void WorksheetFragment::importBrk( SequenceInputStream& rStrm, bool bRowBreak )
685*cdf0e10cSrcweir {
686*cdf0e10cSrcweir     PageBreakModel aModel;
687*cdf0e10cSrcweir     sal_Int32 nManual;
688*cdf0e10cSrcweir     rStrm >> aModel.mnColRow >> aModel.mnMin >> aModel.mnMax >> nManual;
689*cdf0e10cSrcweir     aModel.mbManual = nManual != 0;
690*cdf0e10cSrcweir     setPageBreak( aModel, bRowBreak );
691*cdf0e10cSrcweir }
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir void WorksheetFragment::importDrawing( SequenceInputStream& rStrm )
694*cdf0e10cSrcweir {
695*cdf0e10cSrcweir     setDrawingPath( getFragmentPathFromRelId( BiffHelper::readString( rStrm ) ) );
696*cdf0e10cSrcweir }
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir void WorksheetFragment::importLegacyDrawing( SequenceInputStream& rStrm )
699*cdf0e10cSrcweir {
700*cdf0e10cSrcweir     setVmlDrawingPath( getFragmentPathFromRelId( BiffHelper::readString( rStrm ) ) );
701*cdf0e10cSrcweir }
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir void WorksheetFragment::importOleObject( SequenceInputStream& rStrm )
704*cdf0e10cSrcweir {
705*cdf0e10cSrcweir     ::oox::vml::OleObjectInfo aInfo;
706*cdf0e10cSrcweir     sal_Int32 nAspect, nUpdateMode, nShapeId;
707*cdf0e10cSrcweir     sal_uInt16 nFlags;
708*cdf0e10cSrcweir     rStrm >> nAspect >> nUpdateMode >> nShapeId >> nFlags >> aInfo.maProgId;
709*cdf0e10cSrcweir     aInfo.mbLinked = getFlag( nFlags, BIFF12_OLEOBJECT_LINKED );
710*cdf0e10cSrcweir     if( aInfo.mbLinked )
711*cdf0e10cSrcweir         aInfo.maTargetLink = getFormulaParser().importOleTargetLink( rStrm );
712*cdf0e10cSrcweir     else
713*cdf0e10cSrcweir         importEmbeddedOleData( aInfo.maEmbeddedData, BiffHelper::readString( rStrm ) );
714*cdf0e10cSrcweir     aInfo.setShapeId( nShapeId );
715*cdf0e10cSrcweir     aInfo.mbShowAsIcon = nAspect == BIFF12_OLEOBJECT_ICON;
716*cdf0e10cSrcweir     aInfo.mbAutoUpdate = nUpdateMode == BIFF12_OLEOBJECT_ALWAYS;
717*cdf0e10cSrcweir     aInfo.mbAutoLoad = getFlag( nFlags, BIFF12_OLEOBJECT_AUTOLOAD );
718*cdf0e10cSrcweir     getVmlDrawing().registerOleObject( aInfo );
719*cdf0e10cSrcweir }
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir void WorksheetFragment::importControl( SequenceInputStream& rStrm )
722*cdf0e10cSrcweir {
723*cdf0e10cSrcweir     ::oox::vml::ControlInfo aInfo;
724*cdf0e10cSrcweir     aInfo.setShapeId( rStrm.readInt32() );
725*cdf0e10cSrcweir     aInfo.maFragmentPath = getFragmentPathFromRelId( BiffHelper::readString( rStrm ) );
726*cdf0e10cSrcweir     rStrm >> aInfo.maName;
727*cdf0e10cSrcweir     getVmlDrawing().registerControl( aInfo );
728*cdf0e10cSrcweir }
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir void WorksheetFragment::importEmbeddedOleData( StreamDataSequence& orEmbeddedData, const OUString& rRelId )
731*cdf0e10cSrcweir {
732*cdf0e10cSrcweir     OUString aFragmentPath = getFragmentPathFromRelId( rRelId );
733*cdf0e10cSrcweir     if( aFragmentPath.getLength() > 0 )
734*cdf0e10cSrcweir         getBaseFilter().importBinaryData( orEmbeddedData, aFragmentPath );
735*cdf0e10cSrcweir }
736*cdf0e10cSrcweir 
737*cdf0e10cSrcweir // ============================================================================
738*cdf0e10cSrcweir 
739*cdf0e10cSrcweir BiffWorksheetFragment::BiffWorksheetFragment( const WorksheetHelper& rHelper, const BiffWorkbookFragmentBase& rParent ) :
740*cdf0e10cSrcweir     BiffWorksheetFragmentBase( rHelper, rParent )
741*cdf0e10cSrcweir {
742*cdf0e10cSrcweir }
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir BiffWorksheetFragment::~BiffWorksheetFragment()
745*cdf0e10cSrcweir {
746*cdf0e10cSrcweir }
747*cdf0e10cSrcweir 
748*cdf0e10cSrcweir bool BiffWorksheetFragment::importFragment()
749*cdf0e10cSrcweir {
750*cdf0e10cSrcweir     // initial processing in base class WorksheetHelper
751*cdf0e10cSrcweir     initializeWorksheetImport();
752*cdf0e10cSrcweir 
753*cdf0e10cSrcweir     // create a SheetDataContext object that implements cell import
754*cdf0e10cSrcweir     BiffSheetDataContext aSheetData( *this );
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir     WorkbookSettings& rWorkbookSett   = getWorkbookSettings();
757*cdf0e10cSrcweir     WorksheetSettings& rWorksheetSett = getWorksheetSettings();
758*cdf0e10cSrcweir     SheetViewSettings& rSheetViewSett = getSheetViewSettings();
759*cdf0e10cSrcweir     CondFormatBuffer& rCondFormats    = getCondFormats();
760*cdf0e10cSrcweir     PageSettings& rPageSett           = getPageSettings();
761*cdf0e10cSrcweir     BiffSheetDrawing& rDrawing        = getBiffDrawing();
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir     // process all record in this sheet fragment
764*cdf0e10cSrcweir     BiffInputStream& rStrm = getInputStream();
765*cdf0e10cSrcweir     while( rStrm.startNextRecord() && (rStrm.getRecId() != BIFF_ID_EOF) )
766*cdf0e10cSrcweir     {
767*cdf0e10cSrcweir         if( BiffHelper::isBofRecord( rStrm ) )
768*cdf0e10cSrcweir         {
769*cdf0e10cSrcweir             // skip unknown embedded fragments (BOF/EOF blocks)
770*cdf0e10cSrcweir             skipFragment();
771*cdf0e10cSrcweir         }
772*cdf0e10cSrcweir         else
773*cdf0e10cSrcweir         {
774*cdf0e10cSrcweir             // cache base stream position to detect if record is already processed
775*cdf0e10cSrcweir             sal_Int64 nStrmPos = rStrm.tellBase();
776*cdf0e10cSrcweir             sal_uInt16 nRecId = rStrm.getRecId();
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir             switch( nRecId )
779*cdf0e10cSrcweir             {
780*cdf0e10cSrcweir                 // records in all BIFF versions
781*cdf0e10cSrcweir                 case BIFF_ID_BOTTOMMARGIN:      rPageSett.importBottomMargin( rStrm );      break;
782*cdf0e10cSrcweir                 case BIFF_ID_CALCCOUNT:         rWorkbookSett.importCalcCount( rStrm );     break;
783*cdf0e10cSrcweir                 case BIFF_ID_CALCMODE:          rWorkbookSett.importCalcMode( rStrm );      break;
784*cdf0e10cSrcweir                 case BIFF_ID_DEFCOLWIDTH:       importDefColWidth( rStrm );                 break;
785*cdf0e10cSrcweir                 case BIFF_ID_DELTA:             rWorkbookSett.importDelta( rStrm );         break;
786*cdf0e10cSrcweir                 case BIFF2_ID_DIMENSION:        importDimension( rStrm );                   break;
787*cdf0e10cSrcweir                 case BIFF3_ID_DIMENSION:        importDimension( rStrm );                   break;
788*cdf0e10cSrcweir                 case BIFF_ID_FOOTER:            rPageSett.importFooter( rStrm );            break;
789*cdf0e10cSrcweir                 case BIFF_ID_HEADER:            rPageSett.importHeader( rStrm );            break;
790*cdf0e10cSrcweir                 case BIFF_ID_HORPAGEBREAKS:     importPageBreaks( rStrm, true );            break;
791*cdf0e10cSrcweir                 case BIFF_ID_ITERATION:         rWorkbookSett.importIteration( rStrm );     break;
792*cdf0e10cSrcweir                 case BIFF_ID_LEFTMARGIN:        rPageSett.importLeftMargin( rStrm );        break;
793*cdf0e10cSrcweir                 case BIFF_ID_NOTE:              importNote( rStrm );                        break;
794*cdf0e10cSrcweir                 case BIFF_ID_PANE:              rSheetViewSett.importPane( rStrm );         break;
795*cdf0e10cSrcweir                 case BIFF_ID_PASSWORD:          rWorksheetSett.importPassword( rStrm );     break;
796*cdf0e10cSrcweir                 case BIFF_ID_PRINTGRIDLINES:    rPageSett.importPrintGridLines( rStrm );    break;
797*cdf0e10cSrcweir                 case BIFF_ID_PRINTHEADERS:      rPageSett.importPrintHeaders( rStrm );      break;
798*cdf0e10cSrcweir                 case BIFF_ID_PROTECT:           rWorksheetSett.importProtect( rStrm );      break;
799*cdf0e10cSrcweir                 case BIFF_ID_REFMODE:           rWorkbookSett.importRefMode( rStrm );       break;
800*cdf0e10cSrcweir                 case BIFF_ID_RIGHTMARGIN:       rPageSett.importRightMargin( rStrm );       break;
801*cdf0e10cSrcweir                 case BIFF_ID_SELECTION:         rSheetViewSett.importSelection( rStrm );    break;
802*cdf0e10cSrcweir                 case BIFF_ID_TOPMARGIN:         rPageSett.importTopMargin( rStrm );         break;
803*cdf0e10cSrcweir                 case BIFF_ID_VERPAGEBREAKS:     importPageBreaks( rStrm, false );           break;
804*cdf0e10cSrcweir 
805*cdf0e10cSrcweir                 // BIFF specific records
806*cdf0e10cSrcweir                 default: switch( getBiff() )
807*cdf0e10cSrcweir                 {
808*cdf0e10cSrcweir                     case BIFF2: switch( nRecId )
809*cdf0e10cSrcweir                     {
810*cdf0e10cSrcweir                         case BIFF_ID_COLUMNDEFAULT: importColumnDefault( rStrm );           break;
811*cdf0e10cSrcweir                         case BIFF_ID_COLWIDTH:      importColWidth( rStrm );                break;
812*cdf0e10cSrcweir                         case BIFF2_ID_DEFROWHEIGHT: importDefRowHeight( rStrm );            break;
813*cdf0e10cSrcweir                         case BIFF2_ID_WINDOW2:      rSheetViewSett.importWindow2( rStrm );  break;
814*cdf0e10cSrcweir                     }
815*cdf0e10cSrcweir                     break;
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir                     case BIFF3: switch( nRecId )
818*cdf0e10cSrcweir                     {
819*cdf0e10cSrcweir                         case BIFF_ID_COLINFO:       importColInfo( rStrm );                         break;
820*cdf0e10cSrcweir                         case BIFF_ID_DEFCOLWIDTH:   importDefColWidth( rStrm );                     break;
821*cdf0e10cSrcweir                         case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight( rStrm );                    break;
822*cdf0e10cSrcweir                         case BIFF_ID_HCENTER:       rPageSett.importHorCenter( rStrm );             break;
823*cdf0e10cSrcweir                         case BIFF_ID_OBJ:           rDrawing.importObj( rStrm );                    break;
824*cdf0e10cSrcweir                         case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( rStrm );    break;
825*cdf0e10cSrcweir                         case BIFF_ID_SAVERECALC:    rWorkbookSett.importSaveRecalc( rStrm );        break;
826*cdf0e10cSrcweir                         case BIFF_ID_SHEETPR:       rWorksheetSett.importSheetPr( rStrm );          break;
827*cdf0e10cSrcweir                         case BIFF_ID_UNCALCED:      rWorkbookSett.importUncalced( rStrm );          break;
828*cdf0e10cSrcweir                         case BIFF_ID_VCENTER:       rPageSett.importVerCenter( rStrm );             break;
829*cdf0e10cSrcweir                         case BIFF3_ID_WINDOW2:      rSheetViewSett.importWindow2( rStrm );          break;
830*cdf0e10cSrcweir                     }
831*cdf0e10cSrcweir                     break;
832*cdf0e10cSrcweir 
833*cdf0e10cSrcweir                     case BIFF4: switch( nRecId )
834*cdf0e10cSrcweir                     {
835*cdf0e10cSrcweir                         case BIFF_ID_COLINFO:       importColInfo( rStrm );                         break;
836*cdf0e10cSrcweir                         case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight( rStrm );                    break;
837*cdf0e10cSrcweir                         case BIFF_ID_HCENTER:       rPageSett.importHorCenter( rStrm );             break;
838*cdf0e10cSrcweir                         case BIFF_ID_OBJ:           rDrawing.importObj( rStrm );                    break;
839*cdf0e10cSrcweir                         case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( rStrm );    break;
840*cdf0e10cSrcweir                         case BIFF_ID_PAGESETUP:     rPageSett.importPageSetup( rStrm );             break;
841*cdf0e10cSrcweir                         case BIFF_ID_SAVERECALC:    rWorkbookSett.importSaveRecalc( rStrm );        break;
842*cdf0e10cSrcweir                         case BIFF_ID_SHEETPR:       rWorksheetSett.importSheetPr( rStrm );          break;
843*cdf0e10cSrcweir                         case BIFF_ID_STANDARDWIDTH: importStandardWidth( rStrm );                   break;
844*cdf0e10cSrcweir                         case BIFF_ID_UNCALCED:      rWorkbookSett.importUncalced( rStrm );          break;
845*cdf0e10cSrcweir                         case BIFF_ID_VCENTER:       rPageSett.importVerCenter( rStrm );             break;
846*cdf0e10cSrcweir                         case BIFF3_ID_WINDOW2:      rSheetViewSett.importWindow2( rStrm );          break;
847*cdf0e10cSrcweir                     }
848*cdf0e10cSrcweir                     break;
849*cdf0e10cSrcweir 
850*cdf0e10cSrcweir                     case BIFF5: switch( nRecId )
851*cdf0e10cSrcweir                     {
852*cdf0e10cSrcweir                         case BIFF_ID_AUTOFILTER:    importAutoFilter( rStrm );                      break;
853*cdf0e10cSrcweir                         case BIFF_ID_COLINFO:       importColInfo( rStrm );                         break;
854*cdf0e10cSrcweir                         case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight( rStrm );                    break;
855*cdf0e10cSrcweir                         case BIFF_ID_HCENTER:       rPageSett.importHorCenter( rStrm );             break;
856*cdf0e10cSrcweir                         case BIFF_ID_MERGEDCELLS:   importMergedCells( rStrm );                     break;  // #i62300# also in BIFF5
857*cdf0e10cSrcweir                         case BIFF_ID_OBJ:           rDrawing.importObj( rStrm );                    break;
858*cdf0e10cSrcweir                         case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( rStrm );    break;
859*cdf0e10cSrcweir                         case BIFF_ID_PAGESETUP:     rPageSett.importPageSetup( rStrm );             break;
860*cdf0e10cSrcweir                         case BIFF_ID_PTDEFINITION:  importPTDefinition( rStrm );                    break;
861*cdf0e10cSrcweir                         case BIFF_ID_SAVERECALC:    rWorkbookSett.importSaveRecalc( rStrm );        break;
862*cdf0e10cSrcweir                         case BIFF_ID_SCENPROTECT:   rWorksheetSett.importScenProtect( rStrm );      break;
863*cdf0e10cSrcweir                         case BIFF_ID_SCL:           rSheetViewSett.importScl( rStrm );              break;
864*cdf0e10cSrcweir                         case BIFF_ID_SHEETPR:       rWorksheetSett.importSheetPr( rStrm );          break;
865*cdf0e10cSrcweir                         case BIFF_ID_STANDARDWIDTH: importStandardWidth( rStrm );                   break;
866*cdf0e10cSrcweir                         case BIFF_ID_UNCALCED:      rWorkbookSett.importUncalced( rStrm );          break;
867*cdf0e10cSrcweir                         case BIFF_ID_VCENTER:       rPageSett.importVerCenter( rStrm );             break;
868*cdf0e10cSrcweir                         case BIFF3_ID_WINDOW2:      rSheetViewSett.importWindow2( rStrm );          break;
869*cdf0e10cSrcweir                     }
870*cdf0e10cSrcweir                     break;
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir                     case BIFF8: switch( nRecId )
873*cdf0e10cSrcweir                     {
874*cdf0e10cSrcweir                         case BIFF_ID_AUTOFILTER:        importAutoFilter( rStrm );                      break;
875*cdf0e10cSrcweir                         case BIFF_ID_CFHEADER:          rCondFormats.importCfHeader( rStrm );           break;
876*cdf0e10cSrcweir                         case BIFF_ID_CODENAME:          rWorksheetSett.importCodeName( rStrm );         break;
877*cdf0e10cSrcweir                         case BIFF_ID_COLINFO:           importColInfo( rStrm );                         break;
878*cdf0e10cSrcweir                         case BIFF_ID_DATAVALIDATION:    importDataValidation( rStrm );                  break;
879*cdf0e10cSrcweir                         case BIFF_ID_DATAVALIDATIONS:   importDataValidations( rStrm );                 break;
880*cdf0e10cSrcweir                         case BIFF3_ID_DEFROWHEIGHT:     importDefRowHeight( rStrm );                    break;
881*cdf0e10cSrcweir                         case BIFF_ID_HCENTER:           rPageSett.importHorCenter( rStrm );             break;
882*cdf0e10cSrcweir                         case BIFF_ID_HYPERLINK:         importHyperlink( rStrm );                       break;
883*cdf0e10cSrcweir                         case BIFF_ID_LABELRANGES:       importLabelRanges( rStrm );                     break;
884*cdf0e10cSrcweir                         case BIFF_ID_MERGEDCELLS:       importMergedCells( rStrm );                     break;
885*cdf0e10cSrcweir                         case BIFF_ID_OBJ:               rDrawing.importObj( rStrm );                    break;
886*cdf0e10cSrcweir                         case BIFF_ID_OBJECTPROTECT:     rWorksheetSett.importObjectProtect( rStrm );    break;
887*cdf0e10cSrcweir                         case BIFF_ID_PAGESETUP:         rPageSett.importPageSetup( rStrm );             break;
888*cdf0e10cSrcweir                         case BIFF_ID_PHONETICPR:        rWorksheetSett.importPhoneticPr( rStrm );       break;
889*cdf0e10cSrcweir                         case BIFF_ID_PICTURE:           rPageSett.importPicture( rStrm );               break;
890*cdf0e10cSrcweir                         case BIFF_ID_PTDEFINITION:      importPTDefinition( rStrm );                    break;
891*cdf0e10cSrcweir                         case BIFF_ID_QUERYTABLE:        importQueryTable( rStrm );                      break;
892*cdf0e10cSrcweir                         case BIFF_ID_SAVERECALC:        rWorkbookSett.importSaveRecalc( rStrm );        break;
893*cdf0e10cSrcweir                         case BIFF_ID_SCENARIOS:         importScenarios( rStrm );                       break;
894*cdf0e10cSrcweir                         case BIFF_ID_SCENPROTECT:       rWorksheetSett.importScenProtect( rStrm );      break;
895*cdf0e10cSrcweir                         case BIFF_ID_SCL:               rSheetViewSett.importScl( rStrm );              break;
896*cdf0e10cSrcweir                         case BIFF_ID_SHEETEXT:          rWorksheetSett.importSheetExt( rStrm );         break;
897*cdf0e10cSrcweir                         case BIFF_ID_SHEETPR:           rWorksheetSett.importSheetPr( rStrm );          break;
898*cdf0e10cSrcweir                         case BIFF_ID_SHAREDFEATHEAD:    importSharedFeatHead( rStrm );                  break;
899*cdf0e10cSrcweir                         case BIFF_ID_STANDARDWIDTH:     importStandardWidth( rStrm );                   break;
900*cdf0e10cSrcweir                         case BIFF_ID_UNCALCED:          rWorkbookSett.importUncalced( rStrm );          break;
901*cdf0e10cSrcweir                         case BIFF_ID_VCENTER:           rPageSett.importVerCenter( rStrm );             break;
902*cdf0e10cSrcweir                         case BIFF3_ID_WINDOW2:          rSheetViewSett.importWindow2( rStrm );          break;
903*cdf0e10cSrcweir                     }
904*cdf0e10cSrcweir                     break;
905*cdf0e10cSrcweir 
906*cdf0e10cSrcweir                     case BIFF_UNKNOWN: break;
907*cdf0e10cSrcweir                 }
908*cdf0e10cSrcweir             }
909*cdf0e10cSrcweir 
910*cdf0e10cSrcweir             // record not processed, try record context objects
911*cdf0e10cSrcweir             if( rStrm.tellBase() == nStrmPos )
912*cdf0e10cSrcweir             {
913*cdf0e10cSrcweir                 // first, try cell table records
914*cdf0e10cSrcweir                 aSheetData.importRecord( rStrm );
915*cdf0e10cSrcweir                 // handle another open record context
916*cdf0e10cSrcweir                 if( mxContext.get() )
917*cdf0e10cSrcweir                 {
918*cdf0e10cSrcweir                     // if it was a cell table record, forget the other record context
919*cdf0e10cSrcweir                     if( rStrm.tellBase() == nStrmPos )
920*cdf0e10cSrcweir                         mxContext->importRecord( rStrm );
921*cdf0e10cSrcweir                     else
922*cdf0e10cSrcweir                         mxContext.reset();
923*cdf0e10cSrcweir                 }
924*cdf0e10cSrcweir             }
925*cdf0e10cSrcweir         }
926*cdf0e10cSrcweir     }
927*cdf0e10cSrcweir 
928*cdf0e10cSrcweir     // final processing in base class WorksheetHelper
929*cdf0e10cSrcweir     finalizeWorksheetImport();
930*cdf0e10cSrcweir     return rStrm.getRecId() == BIFF_ID_EOF;
931*cdf0e10cSrcweir }
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir // private --------------------------------------------------------------------
934*cdf0e10cSrcweir 
935*cdf0e10cSrcweir void BiffWorksheetFragment::importAutoFilter( BiffInputStream& rStrm )
936*cdf0e10cSrcweir {
937*cdf0e10cSrcweir     mxContext.reset( new BiffAutoFilterContext( *this, getAutoFilters().createAutoFilter() ) );
938*cdf0e10cSrcweir     mxContext->importRecord( rStrm );
939*cdf0e10cSrcweir }
940*cdf0e10cSrcweir 
941*cdf0e10cSrcweir void BiffWorksheetFragment::importColInfo( BiffInputStream& rStrm )
942*cdf0e10cSrcweir {
943*cdf0e10cSrcweir     sal_uInt16 nFirstCol, nLastCol, nWidth, nXfId, nFlags;
944*cdf0e10cSrcweir     rStrm >> nFirstCol >> nLastCol >> nWidth >> nXfId >> nFlags;
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir     ColumnModel aModel;
947*cdf0e10cSrcweir     // column indexes are 0-based in BIFF, but ColumnModel expects 1-based
948*cdf0e10cSrcweir     aModel.maRange.mnFirst = static_cast< sal_Int32 >( nFirstCol ) + 1;
949*cdf0e10cSrcweir     aModel.maRange.mnLast  = static_cast< sal_Int32 >( nLastCol ) + 1;
950*cdf0e10cSrcweir     // width is stored as 1/256th of a character in BIFF, convert to entire character
951*cdf0e10cSrcweir     aModel.mfWidth         = static_cast< double >( nWidth ) / 256.0;
952*cdf0e10cSrcweir     aModel.mnXfId          = nXfId;
953*cdf0e10cSrcweir     aModel.mnLevel         = extractValue< sal_Int32 >( nFlags, 8, 3 );
954*cdf0e10cSrcweir     aModel.mbShowPhonetic  = getFlag( nFlags, BIFF_COLINFO_SHOWPHONETIC );
955*cdf0e10cSrcweir     aModel.mbHidden        = getFlag( nFlags, BIFF_COLINFO_HIDDEN );
956*cdf0e10cSrcweir     aModel.mbCollapsed     = getFlag( nFlags, BIFF_COLINFO_COLLAPSED );
957*cdf0e10cSrcweir     // set column properties in the current sheet
958*cdf0e10cSrcweir     setColumnModel( aModel );
959*cdf0e10cSrcweir }
960*cdf0e10cSrcweir 
961*cdf0e10cSrcweir void BiffWorksheetFragment::importColumnDefault( BiffInputStream& rStrm )
962*cdf0e10cSrcweir {
963*cdf0e10cSrcweir     sal_uInt16 nFirstCol, nLastCol, nXfId;
964*cdf0e10cSrcweir     rStrm >> nFirstCol >> nLastCol >> nXfId;
965*cdf0e10cSrcweir     setDefaultColumnFormat( nFirstCol, nLastCol, nXfId );
966*cdf0e10cSrcweir }
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir void BiffWorksheetFragment::importColWidth( BiffInputStream& rStrm )
969*cdf0e10cSrcweir {
970*cdf0e10cSrcweir     sal_uInt8 nFirstCol, nLastCol;
971*cdf0e10cSrcweir     sal_uInt16 nWidth;
972*cdf0e10cSrcweir     rStrm >> nFirstCol >> nLastCol >> nWidth;
973*cdf0e10cSrcweir 
974*cdf0e10cSrcweir     ColumnModel aModel;
975*cdf0e10cSrcweir     // column indexes are 0-based in BIFF, but ColumnModel expects 1-based
976*cdf0e10cSrcweir     aModel.maRange.mnFirst = static_cast< sal_Int32 >( nFirstCol ) + 1;
977*cdf0e10cSrcweir     aModel.maRange.mnLast = static_cast< sal_Int32 >( nLastCol ) + 1;
978*cdf0e10cSrcweir     // width is stored as 1/256th of a character in BIFF, convert to entire character
979*cdf0e10cSrcweir     aModel.mfWidth = static_cast< double >( nWidth ) / 256.0;
980*cdf0e10cSrcweir     // set column properties in the current sheet
981*cdf0e10cSrcweir     setColumnModel( aModel );
982*cdf0e10cSrcweir }
983*cdf0e10cSrcweir 
984*cdf0e10cSrcweir void BiffWorksheetFragment::importDefColWidth( BiffInputStream& rStrm )
985*cdf0e10cSrcweir {
986*cdf0e10cSrcweir     /*  Stored as entire number of characters without padding pixels, which
987*cdf0e10cSrcweir         will be added in setBaseColumnWidth(). Call has no effect, if a
988*cdf0e10cSrcweir         width has already been set from the STANDARDWIDTH record. */
989*cdf0e10cSrcweir     setBaseColumnWidth( rStrm.readuInt16() );
990*cdf0e10cSrcweir }
991*cdf0e10cSrcweir 
992*cdf0e10cSrcweir void BiffWorksheetFragment::importDefRowHeight( BiffInputStream& rStrm )
993*cdf0e10cSrcweir {
994*cdf0e10cSrcweir     sal_uInt16 nFlags = BIFF_DEFROW_CUSTOMHEIGHT, nHeight;
995*cdf0e10cSrcweir     if( getBiff() != BIFF2 )
996*cdf0e10cSrcweir         rStrm >> nFlags;
997*cdf0e10cSrcweir     rStrm >> nHeight;
998*cdf0e10cSrcweir     if( getBiff() == BIFF2 )
999*cdf0e10cSrcweir         nHeight &= BIFF2_DEFROW_MASK;
1000*cdf0e10cSrcweir     // row height is in twips in BIFF, convert to points
1001*cdf0e10cSrcweir     setDefaultRowSettings(
1002*cdf0e10cSrcweir         nHeight / 20.0,
1003*cdf0e10cSrcweir         getFlag( nFlags, BIFF_DEFROW_CUSTOMHEIGHT ),
1004*cdf0e10cSrcweir         getFlag( nFlags, BIFF_DEFROW_HIDDEN ),
1005*cdf0e10cSrcweir         getFlag( nFlags, BIFF_DEFROW_THICKTOP ),
1006*cdf0e10cSrcweir         getFlag( nFlags, BIFF_DEFROW_THICKBOTTOM ) );
1007*cdf0e10cSrcweir }
1008*cdf0e10cSrcweir 
1009*cdf0e10cSrcweir void BiffWorksheetFragment::importDataValidations( BiffInputStream& rStrm )
1010*cdf0e10cSrcweir {
1011*cdf0e10cSrcweir     sal_Int32 nObjId;
1012*cdf0e10cSrcweir     rStrm.skip( 10 );
1013*cdf0e10cSrcweir     rStrm >> nObjId;
1014*cdf0e10cSrcweir     //! TODO: invalidate object id in drawing object manager
1015*cdf0e10cSrcweir }
1016*cdf0e10cSrcweir 
1017*cdf0e10cSrcweir namespace {
1018*cdf0e10cSrcweir 
1019*cdf0e10cSrcweir OUString lclReadDataValMessage( BiffInputStream& rStrm )
1020*cdf0e10cSrcweir {
1021*cdf0e10cSrcweir     // empty strings are single NUL characters (string length is 1)
1022*cdf0e10cSrcweir     OUString aMessage = rStrm.readUniString( true );
1023*cdf0e10cSrcweir     if( (aMessage.getLength() == 1) && (aMessage[ 0 ] == 0) )
1024*cdf0e10cSrcweir         aMessage = OUString();
1025*cdf0e10cSrcweir     return aMessage;
1026*cdf0e10cSrcweir }
1027*cdf0e10cSrcweir 
1028*cdf0e10cSrcweir ApiTokenSequence lclReadDataValFormula( BiffInputStream& rStrm, FormulaParser& rParser )
1029*cdf0e10cSrcweir {
1030*cdf0e10cSrcweir     sal_uInt16 nFmlaSize = rStrm.readuInt16();
1031*cdf0e10cSrcweir     rStrm.skip( 2 );
1032*cdf0e10cSrcweir     return rParser.importFormula( CellAddress(), FORMULATYPE_VALIDATION, rStrm, &nFmlaSize );
1033*cdf0e10cSrcweir }
1034*cdf0e10cSrcweir 
1035*cdf0e10cSrcweir } // namespace
1036*cdf0e10cSrcweir 
1037*cdf0e10cSrcweir void BiffWorksheetFragment::importDataValidation( BiffInputStream& rStrm )
1038*cdf0e10cSrcweir {
1039*cdf0e10cSrcweir     ValidationModel aModel;
1040*cdf0e10cSrcweir 
1041*cdf0e10cSrcweir     // flags
1042*cdf0e10cSrcweir     sal_uInt32 nFlags;
1043*cdf0e10cSrcweir     rStrm >> nFlags;
1044*cdf0e10cSrcweir     aModel.setBiffType( extractValue< sal_uInt8 >( nFlags, 0, 4 ) );
1045*cdf0e10cSrcweir     aModel.setBiffOperator( extractValue< sal_uInt8 >( nFlags, 20, 4 ) );
1046*cdf0e10cSrcweir     aModel.setBiffErrorStyle( extractValue< sal_uInt8 >( nFlags, 4, 3 ) );
1047*cdf0e10cSrcweir     aModel.mbAllowBlank   = getFlag( nFlags, BIFF_DATAVAL_ALLOWBLANK );
1048*cdf0e10cSrcweir     aModel.mbNoDropDown   = getFlag( nFlags, BIFF_DATAVAL_NODROPDOWN );
1049*cdf0e10cSrcweir     aModel.mbShowInputMsg = getFlag( nFlags, BIFF_DATAVAL_SHOWINPUT );
1050*cdf0e10cSrcweir     aModel.mbShowErrorMsg = getFlag( nFlags, BIFF_DATAVAL_SHOWERROR );
1051*cdf0e10cSrcweir 
1052*cdf0e10cSrcweir     // message strings
1053*cdf0e10cSrcweir     aModel.maInputTitle   = lclReadDataValMessage( rStrm );
1054*cdf0e10cSrcweir     aModel.maErrorTitle   = lclReadDataValMessage( rStrm );
1055*cdf0e10cSrcweir     aModel.maInputMessage = lclReadDataValMessage( rStrm );
1056*cdf0e10cSrcweir     aModel.maErrorMessage = lclReadDataValMessage( rStrm );
1057*cdf0e10cSrcweir 
1058*cdf0e10cSrcweir     // condition formula(s)
1059*cdf0e10cSrcweir     FormulaParser& rParser = getFormulaParser();
1060*cdf0e10cSrcweir     aModel.maTokens1 = lclReadDataValFormula( rStrm, rParser );
1061*cdf0e10cSrcweir     aModel.maTokens2 = lclReadDataValFormula( rStrm, rParser );
1062*cdf0e10cSrcweir     // process string list of a list validation (convert to list of string tokens)
1063*cdf0e10cSrcweir     if( (aModel.mnType == XML_list) && getFlag( nFlags, BIFF_DATAVAL_STRINGLIST ) )
1064*cdf0e10cSrcweir         rParser.convertStringToStringList( aModel.maTokens1, '\0', true );
1065*cdf0e10cSrcweir 
1066*cdf0e10cSrcweir     // cell range list
1067*cdf0e10cSrcweir     BinRangeList aRanges;
1068*cdf0e10cSrcweir     rStrm >> aRanges;
1069*cdf0e10cSrcweir     getAddressConverter().convertToCellRangeList( aModel.maRanges, aRanges, getSheetIndex(), true );
1070*cdf0e10cSrcweir 
1071*cdf0e10cSrcweir     // set validation data
1072*cdf0e10cSrcweir     setValidation( aModel );
1073*cdf0e10cSrcweir }
1074*cdf0e10cSrcweir 
1075*cdf0e10cSrcweir void BiffWorksheetFragment::importDimension( BiffInputStream& rStrm )
1076*cdf0e10cSrcweir {
1077*cdf0e10cSrcweir     // 32-bit row indexes in BIFF8
1078*cdf0e10cSrcweir     bool bInt32Rows = (rStrm.getRecId() == BIFF3_ID_DIMENSION) && (getBiff() == BIFF8);
1079*cdf0e10cSrcweir     BinRange aBinRange;
1080*cdf0e10cSrcweir     aBinRange.read( rStrm, true, bInt32Rows );
1081*cdf0e10cSrcweir     /*  BIFF stores the used area with end column and end row increased by 1
1082*cdf0e10cSrcweir         (first unused column and row). */
1083*cdf0e10cSrcweir     if( (aBinRange.maFirst.mnCol < aBinRange.maLast.mnCol) && (aBinRange.maFirst.mnRow < aBinRange.maLast.mnRow) )
1084*cdf0e10cSrcweir     {
1085*cdf0e10cSrcweir         // reduce range to used area
1086*cdf0e10cSrcweir         --aBinRange.maLast.mnCol;
1087*cdf0e10cSrcweir         --aBinRange.maLast.mnRow;
1088*cdf0e10cSrcweir         CellRangeAddress aRange;
1089*cdf0e10cSrcweir         getAddressConverter().convertToCellRangeUnchecked( aRange, aBinRange, getSheetIndex() );
1090*cdf0e10cSrcweir         extendUsedArea( aRange );
1091*cdf0e10cSrcweir     }
1092*cdf0e10cSrcweir }
1093*cdf0e10cSrcweir 
1094*cdf0e10cSrcweir void BiffWorksheetFragment::importHyperlink( BiffInputStream& rStrm )
1095*cdf0e10cSrcweir {
1096*cdf0e10cSrcweir     HyperlinkModel aModel;
1097*cdf0e10cSrcweir 
1098*cdf0e10cSrcweir     // read cell range for the hyperlink
1099*cdf0e10cSrcweir     BinRange aBiffRange;
1100*cdf0e10cSrcweir     rStrm >> aBiffRange;
1101*cdf0e10cSrcweir     // #i80006# Excel silently ignores invalid hi-byte of column index (TODO: everywhere?)
1102*cdf0e10cSrcweir     aBiffRange.maFirst.mnCol &= 0xFF;
1103*cdf0e10cSrcweir     aBiffRange.maLast.mnCol &= 0xFF;
1104*cdf0e10cSrcweir     if( !getAddressConverter().convertToCellRange( aModel.maRange, aBiffRange, getSheetIndex(), true, true ) )
1105*cdf0e10cSrcweir         return;
1106*cdf0e10cSrcweir 
1107*cdf0e10cSrcweir     // try to read the StdHlink data
1108*cdf0e10cSrcweir     if( !::oox::ole::OleHelper::importStdHlink( aModel, rStrm, true ) )
1109*cdf0e10cSrcweir         return;
1110*cdf0e10cSrcweir 
1111*cdf0e10cSrcweir     // try to read the optional following SCREENTIP record
1112*cdf0e10cSrcweir     if( (rStrm.getNextRecId() == BIFF_ID_SCREENTIP) && rStrm.startNextRecord() )
1113*cdf0e10cSrcweir     {
1114*cdf0e10cSrcweir         rStrm.skip( 2 );      // repeated record id
1115*cdf0e10cSrcweir         // the cell range, again
1116*cdf0e10cSrcweir         rStrm >> aBiffRange;
1117*cdf0e10cSrcweir         CellRangeAddress aRange;
1118*cdf0e10cSrcweir         if( getAddressConverter().convertToCellRange( aRange, aBiffRange, getSheetIndex(), true, true ) &&
1119*cdf0e10cSrcweir             (aRange.StartColumn == aModel.maRange.StartColumn) &&
1120*cdf0e10cSrcweir             (aRange.StartRow == aModel.maRange.StartRow) &&
1121*cdf0e10cSrcweir             (aRange.EndColumn == aModel.maRange.EndColumn) &&
1122*cdf0e10cSrcweir             (aRange.EndRow == aModel.maRange.EndRow) )
1123*cdf0e10cSrcweir         {
1124*cdf0e10cSrcweir             /*  This time, we have no string length, no flag field, and a
1125*cdf0e10cSrcweir                 null-terminated 16-bit character array. */
1126*cdf0e10cSrcweir             aModel.maTooltip = rStrm.readNulUnicodeArray();
1127*cdf0e10cSrcweir         }
1128*cdf0e10cSrcweir     }
1129*cdf0e10cSrcweir 
1130*cdf0e10cSrcweir     // store the hyperlink settings
1131*cdf0e10cSrcweir     setHyperlink( aModel );
1132*cdf0e10cSrcweir }
1133*cdf0e10cSrcweir 
1134*cdf0e10cSrcweir void BiffWorksheetFragment::importLabelRanges( BiffInputStream& rStrm )
1135*cdf0e10cSrcweir {
1136*cdf0e10cSrcweir     BinRangeList aBiffRowRanges, aBiffColRanges;
1137*cdf0e10cSrcweir     rStrm >> aBiffRowRanges >> aBiffColRanges;
1138*cdf0e10cSrcweir     ApiCellRangeList aColRanges, aRowRanges;
1139*cdf0e10cSrcweir     getAddressConverter().convertToCellRangeList( aColRanges, aBiffColRanges, getSheetIndex(), true );
1140*cdf0e10cSrcweir     getAddressConverter().convertToCellRangeList( aRowRanges, aBiffRowRanges, getSheetIndex(), true );
1141*cdf0e10cSrcweir     setLabelRanges( aColRanges, aRowRanges );
1142*cdf0e10cSrcweir }
1143*cdf0e10cSrcweir 
1144*cdf0e10cSrcweir void BiffWorksheetFragment::importMergedCells( BiffInputStream& rStrm )
1145*cdf0e10cSrcweir {
1146*cdf0e10cSrcweir     BinRangeList aBiffRanges;
1147*cdf0e10cSrcweir     rStrm >> aBiffRanges;
1148*cdf0e10cSrcweir     ApiCellRangeList aRanges;
1149*cdf0e10cSrcweir     getAddressConverter().convertToCellRangeList( aRanges, aBiffRanges, getSheetIndex(), true );
1150*cdf0e10cSrcweir     for( ApiCellRangeList::const_iterator aIt = aRanges.begin(), aEnd = aRanges.end(); aIt != aEnd; ++aIt )
1151*cdf0e10cSrcweir         getSheetData().setMergedRange( *aIt );
1152*cdf0e10cSrcweir }
1153*cdf0e10cSrcweir 
1154*cdf0e10cSrcweir void BiffWorksheetFragment::importNote( BiffInputStream& rStrm )
1155*cdf0e10cSrcweir {
1156*cdf0e10cSrcweir     getComments().createComment()->importNote( rStrm );
1157*cdf0e10cSrcweir }
1158*cdf0e10cSrcweir 
1159*cdf0e10cSrcweir void BiffWorksheetFragment::importPageBreaks( BiffInputStream& rStrm, bool bRowBreak )
1160*cdf0e10cSrcweir {
1161*cdf0e10cSrcweir     PageBreakModel aModel;
1162*cdf0e10cSrcweir     aModel.mbManual = true;             // only manual breaks stored in BIFF
1163*cdf0e10cSrcweir     bool bBiff8 = getBiff() == BIFF8;   // skip start/end columns or rows in BIFF8
1164*cdf0e10cSrcweir 
1165*cdf0e10cSrcweir     sal_uInt16 nCount;
1166*cdf0e10cSrcweir     rStrm >> nCount;
1167*cdf0e10cSrcweir     for( sal_uInt16 nIndex = 0; !rStrm.isEof() && (nIndex < nCount); ++nIndex )
1168*cdf0e10cSrcweir     {
1169*cdf0e10cSrcweir         aModel.mnColRow = rStrm.readuInt16();
1170*cdf0e10cSrcweir         setPageBreak( aModel, bRowBreak );
1171*cdf0e10cSrcweir         if( bBiff8 )
1172*cdf0e10cSrcweir             rStrm.skip( 4 );
1173*cdf0e10cSrcweir     }
1174*cdf0e10cSrcweir }
1175*cdf0e10cSrcweir 
1176*cdf0e10cSrcweir void BiffWorksheetFragment::importPTDefinition( BiffInputStream& rStrm )
1177*cdf0e10cSrcweir {
1178*cdf0e10cSrcweir     mxContext.reset( new BiffPivotTableContext( *this ) );
1179*cdf0e10cSrcweir     mxContext->importRecord( rStrm );
1180*cdf0e10cSrcweir }
1181*cdf0e10cSrcweir 
1182*cdf0e10cSrcweir void BiffWorksheetFragment::importQueryTable( BiffInputStream& rStrm )
1183*cdf0e10cSrcweir {
1184*cdf0e10cSrcweir     mxContext.reset( new BiffQueryTableContext( *this ) );
1185*cdf0e10cSrcweir     mxContext->importRecord( rStrm );
1186*cdf0e10cSrcweir }
1187*cdf0e10cSrcweir 
1188*cdf0e10cSrcweir void BiffWorksheetFragment::importScenarios( BiffInputStream& rStrm )
1189*cdf0e10cSrcweir {
1190*cdf0e10cSrcweir     getScenarios().createSheetScenarios( getSheetIndex() ).importScenarios( rStrm );
1191*cdf0e10cSrcweir }
1192*cdf0e10cSrcweir 
1193*cdf0e10cSrcweir void BiffWorksheetFragment::importSharedFeatHead( BiffInputStream& rStrm )
1194*cdf0e10cSrcweir {
1195*cdf0e10cSrcweir     rStrm.skip( 12 );
1196*cdf0e10cSrcweir     sal_uInt16 nType = rStrm.readuInt16();
1197*cdf0e10cSrcweir     rStrm.skip( 5 );
1198*cdf0e10cSrcweir     switch( nType )
1199*cdf0e10cSrcweir     {
1200*cdf0e10cSrcweir         case BIFF_SHRFEATHEAD_SHEETPROT:
1201*cdf0e10cSrcweir             if( rStrm.getRemaining() >= 4 )
1202*cdf0e10cSrcweir                 getWorksheetSettings().importSheetProtection( rStrm );
1203*cdf0e10cSrcweir         break;
1204*cdf0e10cSrcweir     }
1205*cdf0e10cSrcweir }
1206*cdf0e10cSrcweir 
1207*cdf0e10cSrcweir void BiffWorksheetFragment::importStandardWidth( BiffInputStream& rStrm )
1208*cdf0e10cSrcweir {
1209*cdf0e10cSrcweir     sal_uInt16 nWidth;
1210*cdf0e10cSrcweir     rStrm >> nWidth;
1211*cdf0e10cSrcweir     // width is stored as 1/256th of a character in BIFF, convert to entire character
1212*cdf0e10cSrcweir     double fWidth = static_cast< double >( nWidth ) / 256.0;
1213*cdf0e10cSrcweir     // set as default width, will override the width from DEFCOLWIDTH record
1214*cdf0e10cSrcweir     setDefaultColumnWidth( fWidth );
1215*cdf0e10cSrcweir }
1216*cdf0e10cSrcweir 
1217*cdf0e10cSrcweir // ============================================================================
1218*cdf0e10cSrcweir 
1219*cdf0e10cSrcweir } // namespace xls
1220*cdf0e10cSrcweir } // namespace oox
1221