xref: /AOO41X/main/oox/source/xls/workbooksettings.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/workbooksettings.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <com/sun/star/sheet/XCalculatable.hpp>
31*cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
33*cdf0e10cSrcweir #include <comphelper/mediadescriptor.hxx>
34*cdf0e10cSrcweir #include "oox/core/filterbase.hxx"
35*cdf0e10cSrcweir #include "oox/helper/attributelist.hxx"
36*cdf0e10cSrcweir #include "oox/helper/propertyset.hxx"
37*cdf0e10cSrcweir #include "oox/xls/biffinputstream.hxx"
38*cdf0e10cSrcweir #include "oox/xls/unitconverter.hxx"
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir namespace oox {
41*cdf0e10cSrcweir namespace xls {
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir // ============================================================================
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
46*cdf0e10cSrcweir using namespace ::com::sun::star::sheet;
47*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
48*cdf0e10cSrcweir using namespace ::com::sun::star::util;
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir using ::comphelper::MediaDescriptor;
51*cdf0e10cSrcweir using ::oox::core::CodecHelper;
52*cdf0e10cSrcweir using ::rtl::OUString;
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir // ============================================================================
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir namespace {
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir const sal_uInt32 BIFF12_WORKBOOKPR_DATE1904     = 0x00000001;
59*cdf0e10cSrcweir const sal_uInt32 BIFF12_WORKBOOKPR_STRIPEXT     = 0x00000080;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir const sal_uInt16 BIFF12_CALCPR_A1               = 0x0002;
62*cdf0e10cSrcweir const sal_uInt16 BIFF12_CALCPR_ITERATE          = 0x0004;
63*cdf0e10cSrcweir const sal_uInt16 BIFF12_CALCPR_FULLPRECISION    = 0x0008;
64*cdf0e10cSrcweir const sal_uInt16 BIFF12_CALCPR_CALCCOMPLETED    = 0x0010;
65*cdf0e10cSrcweir const sal_uInt16 BIFF12_CALCPR_CALCONSAVE       = 0x0020;
66*cdf0e10cSrcweir const sal_uInt16 BIFF12_CALCPR_CONCURRENT       = 0x0040;
67*cdf0e10cSrcweir const sal_uInt16 BIFF12_CALCPR_MANUALPROC       = 0x0080;
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir // no predefined constants for show objects mode
70*cdf0e10cSrcweir const sal_Int16 API_SHOWMODE_SHOW               = 0;        /// Show drawing objects.
71*cdf0e10cSrcweir const sal_Int16 API_SHOWMODE_HIDE               = 1;        /// Hide drawing objects.
72*cdf0e10cSrcweir const sal_Int16 API_SHOWMODE_PLACEHOLDER        = 2;        /// Show placeholders for drawing objects.
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir } // namespace
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir // ============================================================================
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir FileSharingModel::FileSharingModel() :
79*cdf0e10cSrcweir     mnPasswordHash( 0 ),
80*cdf0e10cSrcweir     mbRecommendReadOnly( false )
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir }
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir // ============================================================================
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir WorkbookSettingsModel::WorkbookSettingsModel() :
87*cdf0e10cSrcweir     mnShowObjectMode( XML_all ),
88*cdf0e10cSrcweir     mnUpdateLinksMode( XML_userSet ),
89*cdf0e10cSrcweir     mnDefaultThemeVer( -1 ),
90*cdf0e10cSrcweir     mbDateMode1904( false ),
91*cdf0e10cSrcweir     mbSaveExtLinkValues( true )
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir }
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir void WorkbookSettingsModel::setBiffObjectMode( sal_uInt16 nObjMode )
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir     static const sal_Int32 spnObjModes[] = { XML_all, XML_placeholders, XML_none };
98*cdf0e10cSrcweir     mnShowObjectMode = STATIC_ARRAY_SELECT( spnObjModes, nObjMode, XML_all );
99*cdf0e10cSrcweir }
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir // ============================================================================
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir CalcSettingsModel::CalcSettingsModel() :
104*cdf0e10cSrcweir     mfIterateDelta( 0.001 ),
105*cdf0e10cSrcweir     mnCalcId( -1 ),
106*cdf0e10cSrcweir     mnRefMode( XML_A1 ),
107*cdf0e10cSrcweir     mnCalcMode( XML_auto ),
108*cdf0e10cSrcweir     mnIterateCount( 100 ),
109*cdf0e10cSrcweir     mnProcCount( -1 ),
110*cdf0e10cSrcweir     mbCalcOnSave( true ),
111*cdf0e10cSrcweir     mbCalcCompleted( true ),
112*cdf0e10cSrcweir     mbFullPrecision( true ),
113*cdf0e10cSrcweir     mbIterate( false ),
114*cdf0e10cSrcweir     mbConcurrent( true ),
115*cdf0e10cSrcweir     mbUseNlr( false )
116*cdf0e10cSrcweir {
117*cdf0e10cSrcweir }
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir // ============================================================================
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir WorkbookSettings::WorkbookSettings( const WorkbookHelper& rHelper ) :
122*cdf0e10cSrcweir     WorkbookHelper( rHelper )
123*cdf0e10cSrcweir {
124*cdf0e10cSrcweir }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir void WorkbookSettings::importFileSharing( const AttributeList& rAttribs )
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir     maFileSharing.maUserName          = rAttribs.getXString( XML_userName, OUString() );
129*cdf0e10cSrcweir     maFileSharing.mnPasswordHash      = CodecHelper::getPasswordHash( rAttribs, XML_reservationPassword );
130*cdf0e10cSrcweir     maFileSharing.mbRecommendReadOnly = rAttribs.getBool( XML_readOnlyRecommended, false );
131*cdf0e10cSrcweir }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir void WorkbookSettings::importWorkbookPr( const AttributeList& rAttribs )
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir     maBookSettings.maCodeName          = rAttribs.getString( XML_codeName, OUString() );
136*cdf0e10cSrcweir     maBookSettings.mnShowObjectMode    = rAttribs.getToken( XML_showObjects, XML_all );
137*cdf0e10cSrcweir     maBookSettings.mnUpdateLinksMode   = rAttribs.getToken( XML_updateLinks, XML_userSet );
138*cdf0e10cSrcweir     maBookSettings.mnDefaultThemeVer   = rAttribs.getInteger( XML_defaultThemeVersion, -1 );
139*cdf0e10cSrcweir     maBookSettings.mbSaveExtLinkValues = rAttribs.getBool( XML_saveExternalLinkValues, true );
140*cdf0e10cSrcweir     setDateMode( rAttribs.getBool( XML_date1904, false ) );
141*cdf0e10cSrcweir }
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir void WorkbookSettings::importCalcPr( const AttributeList& rAttribs )
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir     maCalcSettings.mfIterateDelta  = rAttribs.getDouble( XML_iterateDelta, 0.0001 );
146*cdf0e10cSrcweir     maCalcSettings.mnCalcId        = rAttribs.getInteger( XML_calcId, -1 );
147*cdf0e10cSrcweir     maCalcSettings.mnRefMode       = rAttribs.getToken( XML_refMode, XML_A1 );
148*cdf0e10cSrcweir     maCalcSettings.mnCalcMode      = rAttribs.getToken( XML_calcMode, XML_auto );
149*cdf0e10cSrcweir     maCalcSettings.mnIterateCount  = rAttribs.getInteger( XML_iterateCount, 100 );
150*cdf0e10cSrcweir     maCalcSettings.mnProcCount     = rAttribs.getInteger( XML_concurrentManualCount, -1 );
151*cdf0e10cSrcweir     maCalcSettings.mbCalcOnSave    = rAttribs.getBool( XML_calcOnSave, true );
152*cdf0e10cSrcweir     maCalcSettings.mbCalcCompleted = rAttribs.getBool( XML_calcCompleted, true );
153*cdf0e10cSrcweir     maCalcSettings.mbFullPrecision = rAttribs.getBool( XML_fullPrecision, true );
154*cdf0e10cSrcweir     maCalcSettings.mbIterate       = rAttribs.getBool( XML_iterate, false );
155*cdf0e10cSrcweir     maCalcSettings.mbConcurrent    = rAttribs.getBool( XML_concurrentCalc, true );
156*cdf0e10cSrcweir }
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir void WorkbookSettings::importFileSharing( SequenceInputStream& rStrm )
159*cdf0e10cSrcweir {
160*cdf0e10cSrcweir     maFileSharing.mbRecommendReadOnly = rStrm.readuInt16() != 0;
161*cdf0e10cSrcweir     rStrm >> maFileSharing.mnPasswordHash >> maFileSharing.maUserName;
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir void WorkbookSettings::importWorkbookPr( SequenceInputStream& rStrm )
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir     sal_uInt32 nFlags;
167*cdf0e10cSrcweir     rStrm >> nFlags >> maBookSettings.mnDefaultThemeVer >> maBookSettings.maCodeName;
168*cdf0e10cSrcweir     maBookSettings.setBiffObjectMode( extractValue< sal_uInt16 >( nFlags, 13, 2 ) );
169*cdf0e10cSrcweir     // set flag means: strip external link values
170*cdf0e10cSrcweir     maBookSettings.mbSaveExtLinkValues = !getFlag( nFlags, BIFF12_WORKBOOKPR_STRIPEXT );
171*cdf0e10cSrcweir     setDateMode( getFlag( nFlags, BIFF12_WORKBOOKPR_DATE1904 ) );
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir void WorkbookSettings::importCalcPr( SequenceInputStream& rStrm )
175*cdf0e10cSrcweir {
176*cdf0e10cSrcweir     sal_Int32 nCalcMode, nProcCount;
177*cdf0e10cSrcweir     sal_uInt16 nFlags;
178*cdf0e10cSrcweir     rStrm >> maCalcSettings.mnCalcId >> nCalcMode >> maCalcSettings.mnIterateCount >> maCalcSettings.mfIterateDelta >> nProcCount >> nFlags;
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir     static const sal_Int32 spnCalcModes[] = { XML_manual, XML_auto, XML_autoNoTable };
181*cdf0e10cSrcweir     maCalcSettings.mnRefMode       = getFlagValue( nFlags, BIFF12_CALCPR_A1, XML_A1, XML_R1C1 );
182*cdf0e10cSrcweir     maCalcSettings.mnCalcMode      = STATIC_ARRAY_SELECT( spnCalcModes, nCalcMode, XML_auto );
183*cdf0e10cSrcweir     maCalcSettings.mnProcCount     = getFlagValue< sal_Int32 >( nFlags, BIFF12_CALCPR_MANUALPROC, nProcCount, -1 );
184*cdf0e10cSrcweir     maCalcSettings.mbCalcOnSave    = getFlag( nFlags, BIFF12_CALCPR_CALCONSAVE );
185*cdf0e10cSrcweir     maCalcSettings.mbCalcCompleted = getFlag( nFlags, BIFF12_CALCPR_CALCCOMPLETED );
186*cdf0e10cSrcweir     maCalcSettings.mbFullPrecision = getFlag( nFlags, BIFF12_CALCPR_FULLPRECISION );
187*cdf0e10cSrcweir     maCalcSettings.mbIterate       = getFlag( nFlags, BIFF12_CALCPR_ITERATE );
188*cdf0e10cSrcweir     maCalcSettings.mbConcurrent    = getFlag( nFlags, BIFF12_CALCPR_CONCURRENT );
189*cdf0e10cSrcweir }
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir void WorkbookSettings::setSaveExtLinkValues( bool bSaveExtLinks )
192*cdf0e10cSrcweir {
193*cdf0e10cSrcweir     maBookSettings.mbSaveExtLinkValues = bSaveExtLinks;
194*cdf0e10cSrcweir }
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir void WorkbookSettings::importBookBool( BiffInputStream& rStrm )
197*cdf0e10cSrcweir {
198*cdf0e10cSrcweir     // value of 0 means save external values, value of 1 means strip external values
199*cdf0e10cSrcweir     maBookSettings.mbSaveExtLinkValues = rStrm.readuInt16() == 0;
200*cdf0e10cSrcweir }
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir void WorkbookSettings::importCalcCount( BiffInputStream& rStrm )
203*cdf0e10cSrcweir {
204*cdf0e10cSrcweir     maCalcSettings.mnIterateCount = rStrm.readuInt16();
205*cdf0e10cSrcweir }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir void WorkbookSettings::importCalcMode( BiffInputStream& rStrm )
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir     sal_Int16 nCalcMode = rStrm.readInt16() + 1;
210*cdf0e10cSrcweir     static const sal_Int32 spnCalcModes[] = { XML_autoNoTable, XML_manual, XML_auto };
211*cdf0e10cSrcweir     maCalcSettings.mnCalcMode = STATIC_ARRAY_SELECT( spnCalcModes, nCalcMode, XML_auto );
212*cdf0e10cSrcweir }
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir void WorkbookSettings::importCodeName( BiffInputStream& rStrm )
215*cdf0e10cSrcweir {
216*cdf0e10cSrcweir     maBookSettings.maCodeName = rStrm.readUniString();
217*cdf0e10cSrcweir }
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir void WorkbookSettings::importDateMode( BiffInputStream& rStrm )
220*cdf0e10cSrcweir {
221*cdf0e10cSrcweir     setDateMode( rStrm.readuInt16() != 0 );
222*cdf0e10cSrcweir }
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir void WorkbookSettings::importDelta( BiffInputStream& rStrm )
225*cdf0e10cSrcweir {
226*cdf0e10cSrcweir     rStrm >> maCalcSettings.mfIterateDelta;
227*cdf0e10cSrcweir }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir void WorkbookSettings::importFileSharing( BiffInputStream& rStrm )
230*cdf0e10cSrcweir {
231*cdf0e10cSrcweir     maFileSharing.mbRecommendReadOnly = rStrm.readuInt16() != 0;
232*cdf0e10cSrcweir     rStrm >> maFileSharing.mnPasswordHash;
233*cdf0e10cSrcweir     if( getBiff() == BIFF8 )
234*cdf0e10cSrcweir     {
235*cdf0e10cSrcweir         sal_uInt16 nStrLen = rStrm.readuInt16();
236*cdf0e10cSrcweir         // there is no string flags field if string is empty
237*cdf0e10cSrcweir         if( nStrLen > 0 )
238*cdf0e10cSrcweir             maFileSharing.maUserName = rStrm.readUniStringBody( nStrLen );
239*cdf0e10cSrcweir     }
240*cdf0e10cSrcweir     else
241*cdf0e10cSrcweir     {
242*cdf0e10cSrcweir         maFileSharing.maUserName = rStrm.readByteStringUC( false, getTextEncoding() );
243*cdf0e10cSrcweir     }
244*cdf0e10cSrcweir }
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir void WorkbookSettings::importHideObj( BiffInputStream& rStrm )
247*cdf0e10cSrcweir {
248*cdf0e10cSrcweir     maBookSettings.setBiffObjectMode( rStrm.readuInt16() );
249*cdf0e10cSrcweir }
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir void WorkbookSettings::importIteration( BiffInputStream& rStrm )
252*cdf0e10cSrcweir {
253*cdf0e10cSrcweir     maCalcSettings.mbIterate = rStrm.readuInt16() != 0;
254*cdf0e10cSrcweir }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir void WorkbookSettings::importPrecision( BiffInputStream& rStrm )
257*cdf0e10cSrcweir {
258*cdf0e10cSrcweir     maCalcSettings.mbFullPrecision = rStrm.readuInt16() != 0;
259*cdf0e10cSrcweir }
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir void WorkbookSettings::importRefMode( BiffInputStream& rStrm )
262*cdf0e10cSrcweir {
263*cdf0e10cSrcweir     maCalcSettings.mnRefMode = (rStrm.readuInt16() == 0) ? XML_R1C1 : XML_A1;
264*cdf0e10cSrcweir }
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir void WorkbookSettings::importSaveRecalc( BiffInputStream& rStrm )
267*cdf0e10cSrcweir {
268*cdf0e10cSrcweir     maCalcSettings.mbCalcOnSave = rStrm.readuInt16() != 0;
269*cdf0e10cSrcweir }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir void WorkbookSettings::importUncalced( BiffInputStream& )
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir     // existence of this record indicates incomplete recalc
274*cdf0e10cSrcweir     maCalcSettings.mbCalcCompleted = false;
275*cdf0e10cSrcweir }
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir void WorkbookSettings::importUsesElfs( BiffInputStream& rStrm )
278*cdf0e10cSrcweir {
279*cdf0e10cSrcweir     maCalcSettings.mbUseNlr = rStrm.readuInt16() != 0;
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir void WorkbookSettings::finalizeImport()
283*cdf0e10cSrcweir {
284*cdf0e10cSrcweir     // default settings
285*cdf0e10cSrcweir     PropertySet aPropSet( getDocument() );
286*cdf0e10cSrcweir     switch( getFilterType() )
287*cdf0e10cSrcweir     {
288*cdf0e10cSrcweir         case FILTER_OOXML:
289*cdf0e10cSrcweir         case FILTER_BIFF:
290*cdf0e10cSrcweir             aPropSet.setProperty( PROP_IgnoreCase,          true );     // always in Excel
291*cdf0e10cSrcweir             aPropSet.setProperty( PROP_RegularExpressions,  false );    // not supported in Excel
292*cdf0e10cSrcweir         break;
293*cdf0e10cSrcweir         case FILTER_UNKNOWN:
294*cdf0e10cSrcweir         break;
295*cdf0e10cSrcweir     }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir     // write protection
298*cdf0e10cSrcweir     if( maFileSharing.mbRecommendReadOnly || (maFileSharing.mnPasswordHash != 0) ) try
299*cdf0e10cSrcweir     {
300*cdf0e10cSrcweir         getBaseFilter().getMediaDescriptor()[ CREATE_OUSTRING( "ReadOnly" ) ] <<= true;
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir         Reference< XPropertySet > xDocumentSettings( getBaseFilter().getModelFactory()->createInstance(
303*cdf0e10cSrcweir             CREATE_OUSTRING( "com.sun.star.document.Settings" ) ), UNO_QUERY_THROW );
304*cdf0e10cSrcweir         PropertySet aSettingsProp( xDocumentSettings );
305*cdf0e10cSrcweir         if( maFileSharing.mbRecommendReadOnly )
306*cdf0e10cSrcweir             aSettingsProp.setProperty( PROP_LoadReadonly, true );
307*cdf0e10cSrcweir //        if( maFileSharing.mnPasswordHash != 0 )
308*cdf0e10cSrcweir //            aSettingsProp.setProperty( PROP_ModifyPasswordHash, static_cast< sal_Int32 >( maFileSharing.mnPasswordHash ) );
309*cdf0e10cSrcweir     }
310*cdf0e10cSrcweir     catch( Exception& )
311*cdf0e10cSrcweir     {
312*cdf0e10cSrcweir     }
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir     // calculation settings
315*cdf0e10cSrcweir     Date aNullDate = getNullDate();
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir     aPropSet.setProperty( PROP_NullDate,           aNullDate );
318*cdf0e10cSrcweir     aPropSet.setProperty( PROP_IsIterationEnabled, maCalcSettings.mbIterate );
319*cdf0e10cSrcweir     aPropSet.setProperty( PROP_IterationCount,     maCalcSettings.mnIterateCount );
320*cdf0e10cSrcweir     aPropSet.setProperty( PROP_IterationEpsilon,   maCalcSettings.mfIterateDelta );
321*cdf0e10cSrcweir     aPropSet.setProperty( PROP_CalcAsShown,        !maCalcSettings.mbFullPrecision );
322*cdf0e10cSrcweir     aPropSet.setProperty( PROP_LookUpLabels,       maCalcSettings.mbUseNlr );
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir     Reference< XNumberFormatsSupplier > xNumFmtsSupp( getDocument(), UNO_QUERY );
325*cdf0e10cSrcweir     if( xNumFmtsSupp.is() )
326*cdf0e10cSrcweir     {
327*cdf0e10cSrcweir         PropertySet aNumFmtProp( xNumFmtsSupp->getNumberFormatSettings() );
328*cdf0e10cSrcweir         aNumFmtProp.setProperty( PROP_NullDate, aNullDate );
329*cdf0e10cSrcweir     }
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir     Reference< XCalculatable > xCalculatable( getDocument(), UNO_QUERY );
332*cdf0e10cSrcweir     if( xCalculatable.is() )
333*cdf0e10cSrcweir         xCalculatable->enableAutomaticCalculation( (maCalcSettings.mnCalcMode == XML_auto) || (maCalcSettings.mnCalcMode == XML_autoNoTable) );
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir     // VBA code name
336*cdf0e10cSrcweir     aPropSet.setProperty( PROP_CodeName, maBookSettings.maCodeName );
337*cdf0e10cSrcweir }
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir sal_Int16 WorkbookSettings::getApiShowObjectMode() const
340*cdf0e10cSrcweir {
341*cdf0e10cSrcweir     switch( maBookSettings.mnShowObjectMode )
342*cdf0e10cSrcweir     {
343*cdf0e10cSrcweir         case XML_all:           return API_SHOWMODE_SHOW;
344*cdf0e10cSrcweir         case XML_none:          return API_SHOWMODE_HIDE;
345*cdf0e10cSrcweir         // #i80528# placeholders not supported anymore, but this is handled internally in Calc
346*cdf0e10cSrcweir         case XML_placeholders:  return API_SHOWMODE_PLACEHOLDER;
347*cdf0e10cSrcweir     }
348*cdf0e10cSrcweir     return API_SHOWMODE_SHOW;
349*cdf0e10cSrcweir }
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir Date WorkbookSettings::getNullDate() const
352*cdf0e10cSrcweir {
353*cdf0e10cSrcweir     static const Date saDate1900( 30, 12, 1899 ), saDate1904( 1, 1, 1904 );
354*cdf0e10cSrcweir     return maBookSettings.mbDateMode1904 ? saDate1904 : saDate1900;
355*cdf0e10cSrcweir }
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir void WorkbookSettings::setDateMode( bool bDateMode1904 )
358*cdf0e10cSrcweir {
359*cdf0e10cSrcweir     maBookSettings.mbDateMode1904 = bDateMode1904;
360*cdf0e10cSrcweir     getUnitConverter().finalizeNullDate( getNullDate() );
361*cdf0e10cSrcweir }
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir // ============================================================================
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir } // namespace xls
366*cdf0e10cSrcweir } // namespace oox
367