xref: /AOO41X/main/oox/source/xls/worksheetsettings.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/worksheetsettings.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <com/sun/star/util/XProtectable.hpp>
31*cdf0e10cSrcweir #include "oox/core/filterbase.hxx"
32*cdf0e10cSrcweir #include "oox/helper/attributelist.hxx"
33*cdf0e10cSrcweir #include "oox/xls/biffinputstream.hxx"
34*cdf0e10cSrcweir #include "oox/xls/pagesettings.hxx"
35*cdf0e10cSrcweir #include "oox/xls/workbooksettings.hxx"
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir namespace oox {
38*cdf0e10cSrcweir namespace xls {
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir // ============================================================================
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
43*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
44*cdf0e10cSrcweir using namespace ::com::sun::star::util;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir using ::oox::core::CodecHelper;
47*cdf0e10cSrcweir using ::rtl::OUString;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir // ============================================================================
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir namespace {
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir const sal_uInt8 BIFF12_SHEETPR_FILTERMODE       = 0x01;
54*cdf0e10cSrcweir const sal_uInt8 BIFF12_SHEETPR_EVAL_CF          = 0x02;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETEXT_NOTABCOLOR       = 0x7F;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir const sal_uInt16 BIFF_SHEETPR_DIALOGSHEET       = 0x0010;
59*cdf0e10cSrcweir const sal_uInt16 BIFF_SHEETPR_APPLYSTYLES       = 0x0020;
60*cdf0e10cSrcweir const sal_uInt16 BIFF_SHEETPR_SYMBOLSBELOW      = 0x0040;
61*cdf0e10cSrcweir const sal_uInt16 BIFF_SHEETPR_SYMBOLSRIGHT      = 0x0080;
62*cdf0e10cSrcweir const sal_uInt16 BIFF_SHEETPR_FITTOPAGES        = 0x0100;
63*cdf0e10cSrcweir const sal_uInt16 BIFF_SHEETPR_SKIPEXT           = 0x0200;       // BIFF3-BIFF4
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_OBJECTS         = 0x00000001;
66*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_SCENARIOS       = 0x00000002;
67*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_FORMAT_CELLS    = 0x00000004;
68*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_FORMAT_COLUMNS  = 0x00000008;
69*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_FORMAT_ROWS     = 0x00000010;
70*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_INSERT_COLUMNS  = 0x00000020;
71*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_INSERT_ROWS     = 0x00000040;
72*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_INSERT_HLINKS   = 0x00000080;
73*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_DELETE_COLUMNS  = 0x00000100;
74*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_DELETE_ROWS     = 0x00000200;
75*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_SELECT_LOCKED   = 0x00000400;
76*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_SORT            = 0x00000800;
77*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_AUTOFILTER      = 0x00001000;
78*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_PIVOTTABLES     = 0x00002000;
79*cdf0e10cSrcweir const sal_uInt32 BIFF_SHEETPROT_SELECT_UNLOCKED = 0x00004000;
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir } // namespace
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir // ============================================================================
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir SheetSettingsModel::SheetSettingsModel() :
86*cdf0e10cSrcweir     mbFilterMode( false ),
87*cdf0e10cSrcweir     mbApplyStyles( false ),
88*cdf0e10cSrcweir     mbSummaryBelow( true ),
89*cdf0e10cSrcweir     mbSummaryRight( true )
90*cdf0e10cSrcweir {
91*cdf0e10cSrcweir }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir // ============================================================================
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir SheetProtectionModel::SheetProtectionModel() :
96*cdf0e10cSrcweir     mnPasswordHash( 0 ),
97*cdf0e10cSrcweir     mbSheet( false ),
98*cdf0e10cSrcweir     mbObjects( false ),
99*cdf0e10cSrcweir     mbScenarios( false ),
100*cdf0e10cSrcweir     mbFormatCells( true ),
101*cdf0e10cSrcweir     mbFormatColumns( true ),
102*cdf0e10cSrcweir     mbFormatRows( true ),
103*cdf0e10cSrcweir     mbInsertColumns( true ),
104*cdf0e10cSrcweir     mbInsertRows( true ),
105*cdf0e10cSrcweir     mbInsertHyperlinks( true ),
106*cdf0e10cSrcweir     mbDeleteColumns( true ),
107*cdf0e10cSrcweir     mbDeleteRows( true ),
108*cdf0e10cSrcweir     mbSelectLocked( false ),
109*cdf0e10cSrcweir     mbSort( true ),
110*cdf0e10cSrcweir     mbAutoFilter( true ),
111*cdf0e10cSrcweir     mbPivotTables( true ),
112*cdf0e10cSrcweir     mbSelectUnlocked( false )
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir }
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir // ============================================================================
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir WorksheetSettings::WorksheetSettings( const WorksheetHelper& rHelper ) :
119*cdf0e10cSrcweir     WorksheetHelper( rHelper ),
120*cdf0e10cSrcweir     maPhoneticSett( rHelper )
121*cdf0e10cSrcweir {
122*cdf0e10cSrcweir }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir void WorksheetSettings::importSheetPr( const AttributeList& rAttribs )
125*cdf0e10cSrcweir {
126*cdf0e10cSrcweir     maSheetSettings.maCodeName = rAttribs.getString( XML_codeName, OUString() );
127*cdf0e10cSrcweir     maSheetSettings.mbFilterMode = rAttribs.getBool( XML_filterMode, false );
128*cdf0e10cSrcweir }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir void WorksheetSettings::importChartSheetPr( const AttributeList& rAttribs )
131*cdf0e10cSrcweir {
132*cdf0e10cSrcweir     maSheetSettings.maCodeName = rAttribs.getString( XML_codeName, OUString() );
133*cdf0e10cSrcweir }
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir void WorksheetSettings::importTabColor( const AttributeList& rAttribs )
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir     maSheetSettings.maTabColor.importColor( rAttribs );
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir void WorksheetSettings::importOutlinePr( const AttributeList& rAttribs )
141*cdf0e10cSrcweir {
142*cdf0e10cSrcweir     maSheetSettings.mbApplyStyles  = rAttribs.getBool( XML_applyStyles, false );
143*cdf0e10cSrcweir     maSheetSettings.mbSummaryBelow = rAttribs.getBool( XML_summaryBelow, true );
144*cdf0e10cSrcweir     maSheetSettings.mbSummaryRight = rAttribs.getBool( XML_summaryRight, true );
145*cdf0e10cSrcweir }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir void WorksheetSettings::importSheetProtection( const AttributeList& rAttribs )
148*cdf0e10cSrcweir {
149*cdf0e10cSrcweir     maSheetProt.mnPasswordHash     = CodecHelper::getPasswordHash( rAttribs, XML_password );
150*cdf0e10cSrcweir     maSheetProt.mbSheet            = rAttribs.getBool( XML_sheet, false );
151*cdf0e10cSrcweir     maSheetProt.mbObjects          = rAttribs.getBool( XML_objects, false );
152*cdf0e10cSrcweir     maSheetProt.mbScenarios        = rAttribs.getBool( XML_scenarios, false );
153*cdf0e10cSrcweir     maSheetProt.mbFormatCells      = rAttribs.getBool( XML_formatCells, true );
154*cdf0e10cSrcweir     maSheetProt.mbFormatColumns    = rAttribs.getBool( XML_formatColumns, true );
155*cdf0e10cSrcweir     maSheetProt.mbFormatRows       = rAttribs.getBool( XML_formatRows, true );
156*cdf0e10cSrcweir     maSheetProt.mbInsertColumns    = rAttribs.getBool( XML_insertColumns, true );
157*cdf0e10cSrcweir     maSheetProt.mbInsertRows       = rAttribs.getBool( XML_insertRows, true );
158*cdf0e10cSrcweir     maSheetProt.mbInsertHyperlinks = rAttribs.getBool( XML_insertHyperlinks, true );
159*cdf0e10cSrcweir     maSheetProt.mbDeleteColumns    = rAttribs.getBool( XML_deleteColumns, true );
160*cdf0e10cSrcweir     maSheetProt.mbDeleteRows       = rAttribs.getBool( XML_deleteRows, true );
161*cdf0e10cSrcweir     maSheetProt.mbSelectLocked     = rAttribs.getBool( XML_selectLockedCells, false );
162*cdf0e10cSrcweir     maSheetProt.mbSort             = rAttribs.getBool( XML_sort, true );
163*cdf0e10cSrcweir     maSheetProt.mbAutoFilter       = rAttribs.getBool( XML_autoFilter, true );
164*cdf0e10cSrcweir     maSheetProt.mbPivotTables      = rAttribs.getBool( XML_pivotTables, true );
165*cdf0e10cSrcweir     maSheetProt.mbSelectUnlocked   = rAttribs.getBool( XML_selectUnlockedCells, false );
166*cdf0e10cSrcweir }
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir void WorksheetSettings::importChartProtection( const AttributeList& rAttribs )
169*cdf0e10cSrcweir {
170*cdf0e10cSrcweir     maSheetProt.mnPasswordHash = CodecHelper::getPasswordHash( rAttribs, XML_password );
171*cdf0e10cSrcweir     maSheetProt.mbSheet        = rAttribs.getBool( XML_content, false );
172*cdf0e10cSrcweir     maSheetProt.mbObjects      = rAttribs.getBool( XML_objects, false );
173*cdf0e10cSrcweir }
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir void WorksheetSettings::importPhoneticPr( const AttributeList& rAttribs )
176*cdf0e10cSrcweir {
177*cdf0e10cSrcweir     maPhoneticSett.importPhoneticPr( rAttribs );
178*cdf0e10cSrcweir }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir void WorksheetSettings::importSheetPr( SequenceInputStream& rStrm )
181*cdf0e10cSrcweir {
182*cdf0e10cSrcweir     sal_uInt16 nFlags1;
183*cdf0e10cSrcweir     sal_uInt8 nFlags2;
184*cdf0e10cSrcweir     rStrm >> nFlags1 >> nFlags2 >> maSheetSettings.maTabColor;
185*cdf0e10cSrcweir     rStrm.skip( 8 );    // sync anchor cell
186*cdf0e10cSrcweir     rStrm >> maSheetSettings.maCodeName;
187*cdf0e10cSrcweir     // sheet settings
188*cdf0e10cSrcweir     maSheetSettings.mbFilterMode = getFlag( nFlags2, BIFF12_SHEETPR_FILTERMODE );
189*cdf0e10cSrcweir     // outline settings, equal flags in all BIFFs
190*cdf0e10cSrcweir     maSheetSettings.mbApplyStyles  = getFlag( nFlags1, BIFF_SHEETPR_APPLYSTYLES );
191*cdf0e10cSrcweir     maSheetSettings.mbSummaryRight = getFlag( nFlags1, BIFF_SHEETPR_SYMBOLSRIGHT );
192*cdf0e10cSrcweir     maSheetSettings.mbSummaryBelow = getFlag( nFlags1, BIFF_SHEETPR_SYMBOLSBELOW );
193*cdf0e10cSrcweir     /*  Fit printout to width/height - for whatever reason, this flag is still
194*cdf0e10cSrcweir         stored separated from the page settings */
195*cdf0e10cSrcweir     getPageSettings().setFitToPagesMode( getFlag( nFlags1, BIFF_SHEETPR_FITTOPAGES ) );
196*cdf0e10cSrcweir }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir void WorksheetSettings::importChartSheetPr( SequenceInputStream& rStrm )
199*cdf0e10cSrcweir {
200*cdf0e10cSrcweir     rStrm.skip( 2 );    // flags, contains only the 'published' flag
201*cdf0e10cSrcweir     rStrm >> maSheetSettings.maTabColor >> maSheetSettings.maCodeName;
202*cdf0e10cSrcweir }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir void WorksheetSettings::importSheetProtection( SequenceInputStream& rStrm )
205*cdf0e10cSrcweir {
206*cdf0e10cSrcweir     rStrm >> maSheetProt.mnPasswordHash;
207*cdf0e10cSrcweir     // no flags field for all these boolean flags?!?
208*cdf0e10cSrcweir     maSheetProt.mbSheet            = rStrm.readInt32() != 0;
209*cdf0e10cSrcweir     maSheetProt.mbObjects          = rStrm.readInt32() != 0;
210*cdf0e10cSrcweir     maSheetProt.mbScenarios        = rStrm.readInt32() != 0;
211*cdf0e10cSrcweir     maSheetProt.mbFormatCells      = rStrm.readInt32() != 0;
212*cdf0e10cSrcweir     maSheetProt.mbFormatColumns    = rStrm.readInt32() != 0;
213*cdf0e10cSrcweir     maSheetProt.mbFormatRows       = rStrm.readInt32() != 0;
214*cdf0e10cSrcweir     maSheetProt.mbInsertColumns    = rStrm.readInt32() != 0;
215*cdf0e10cSrcweir     maSheetProt.mbInsertRows       = rStrm.readInt32() != 0;
216*cdf0e10cSrcweir     maSheetProt.mbInsertHyperlinks = rStrm.readInt32() != 0;
217*cdf0e10cSrcweir     maSheetProt.mbDeleteColumns    = rStrm.readInt32() != 0;
218*cdf0e10cSrcweir     maSheetProt.mbDeleteRows       = rStrm.readInt32() != 0;
219*cdf0e10cSrcweir     maSheetProt.mbSelectLocked     = rStrm.readInt32() != 0;
220*cdf0e10cSrcweir     maSheetProt.mbSort             = rStrm.readInt32() != 0;
221*cdf0e10cSrcweir     maSheetProt.mbAutoFilter       = rStrm.readInt32() != 0;
222*cdf0e10cSrcweir     maSheetProt.mbPivotTables      = rStrm.readInt32() != 0;
223*cdf0e10cSrcweir     maSheetProt.mbSelectUnlocked   = rStrm.readInt32() != 0;
224*cdf0e10cSrcweir }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir void WorksheetSettings::importChartProtection( SequenceInputStream& rStrm )
227*cdf0e10cSrcweir {
228*cdf0e10cSrcweir     rStrm >> maSheetProt.mnPasswordHash;
229*cdf0e10cSrcweir     // no flags field for all these boolean flags?!?
230*cdf0e10cSrcweir     maSheetProt.mbSheet            = rStrm.readInt32() != 0;
231*cdf0e10cSrcweir     maSheetProt.mbObjects          = rStrm.readInt32() != 0;
232*cdf0e10cSrcweir }
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir void WorksheetSettings::importPhoneticPr( SequenceInputStream& rStrm )
235*cdf0e10cSrcweir {
236*cdf0e10cSrcweir     maPhoneticSett.importPhoneticPr( rStrm );
237*cdf0e10cSrcweir }
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir void WorksheetSettings::importSheetExt( BiffInputStream& rStrm )
240*cdf0e10cSrcweir {
241*cdf0e10cSrcweir     rStrm.skip( 16 );
242*cdf0e10cSrcweir     sal_uInt32 nFlags;
243*cdf0e10cSrcweir     rStrm >> nFlags;
244*cdf0e10cSrcweir     sal_uInt8 nColorIdx = extractValue< sal_uInt8 >( nFlags, 0, 7 );
245*cdf0e10cSrcweir     if( nColorIdx != BIFF_SHEETEXT_NOTABCOLOR )
246*cdf0e10cSrcweir         maSheetSettings.maTabColor.setPaletteClr( nColorIdx );
247*cdf0e10cSrcweir }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir void WorksheetSettings::importSheetPr( BiffInputStream& rStrm )
250*cdf0e10cSrcweir {
251*cdf0e10cSrcweir     sal_uInt16 nFlags;
252*cdf0e10cSrcweir     rStrm >> nFlags;
253*cdf0e10cSrcweir     // worksheet vs. dialogsheet
254*cdf0e10cSrcweir     if( getFlag( nFlags, BIFF_SHEETPR_DIALOGSHEET ) )
255*cdf0e10cSrcweir     {
256*cdf0e10cSrcweir         OSL_ENSURE( getSheetType() == SHEETTYPE_WORKSHEET, "WorksheetSettings::importSheetPr - unexpected sheet type" );
257*cdf0e10cSrcweir         setSheetType( SHEETTYPE_DIALOGSHEET );
258*cdf0e10cSrcweir     }
259*cdf0e10cSrcweir     // outline settings
260*cdf0e10cSrcweir     maSheetSettings.mbApplyStyles  = getFlag( nFlags, BIFF_SHEETPR_APPLYSTYLES );
261*cdf0e10cSrcweir     maSheetSettings.mbSummaryRight = getFlag( nFlags, BIFF_SHEETPR_SYMBOLSRIGHT );
262*cdf0e10cSrcweir     maSheetSettings.mbSummaryBelow = getFlag( nFlags, BIFF_SHEETPR_SYMBOLSBELOW );
263*cdf0e10cSrcweir     // fit printout to width/height
264*cdf0e10cSrcweir     getPageSettings().setFitToPagesMode( getFlag( nFlags, BIFF_SHEETPR_FITTOPAGES ) );
265*cdf0e10cSrcweir     // save external linked values, in BIFF5-BIFF8 moved to BOOKBOOK record
266*cdf0e10cSrcweir     if( getBiff() <= BIFF4 )
267*cdf0e10cSrcweir         getWorkbookSettings().setSaveExtLinkValues( !getFlag( nFlags, BIFF_SHEETPR_SKIPEXT ) );
268*cdf0e10cSrcweir }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir void WorksheetSettings::importProtect( BiffInputStream& rStrm )
271*cdf0e10cSrcweir {
272*cdf0e10cSrcweir     maSheetProt.mbSheet = rStrm.readuInt16() != 0;
273*cdf0e10cSrcweir }
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir void WorksheetSettings::importObjectProtect( BiffInputStream& rStrm )
276*cdf0e10cSrcweir {
277*cdf0e10cSrcweir     maSheetProt.mbObjects = rStrm.readuInt16() != 0;
278*cdf0e10cSrcweir }
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir void WorksheetSettings::importScenProtect( BiffInputStream& rStrm )
281*cdf0e10cSrcweir {
282*cdf0e10cSrcweir     maSheetProt.mbScenarios = rStrm.readuInt16() != 0;
283*cdf0e10cSrcweir }
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir void WorksheetSettings::importPassword( BiffInputStream& rStrm )
286*cdf0e10cSrcweir {
287*cdf0e10cSrcweir     rStrm >> maSheetProt.mnPasswordHash;
288*cdf0e10cSrcweir }
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir void WorksheetSettings::importSheetProtection( BiffInputStream& rStrm )
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir     sal_uInt32 nFlags = rStrm.readuInt32();
293*cdf0e10cSrcweir     // set flag means protection is disabled
294*cdf0e10cSrcweir     maSheetProt.mbObjects          = !getFlag( nFlags, BIFF_SHEETPROT_OBJECTS );
295*cdf0e10cSrcweir     maSheetProt.mbScenarios        = !getFlag( nFlags, BIFF_SHEETPROT_SCENARIOS );
296*cdf0e10cSrcweir     maSheetProt.mbFormatCells      = !getFlag( nFlags, BIFF_SHEETPROT_FORMAT_CELLS );
297*cdf0e10cSrcweir     maSheetProt.mbFormatColumns    = !getFlag( nFlags, BIFF_SHEETPROT_FORMAT_COLUMNS );
298*cdf0e10cSrcweir     maSheetProt.mbFormatRows       = !getFlag( nFlags, BIFF_SHEETPROT_FORMAT_ROWS );
299*cdf0e10cSrcweir     maSheetProt.mbInsertColumns    = !getFlag( nFlags, BIFF_SHEETPROT_INSERT_COLUMNS );
300*cdf0e10cSrcweir     maSheetProt.mbInsertRows       = !getFlag( nFlags, BIFF_SHEETPROT_INSERT_ROWS );
301*cdf0e10cSrcweir     maSheetProt.mbInsertHyperlinks = !getFlag( nFlags, BIFF_SHEETPROT_INSERT_HLINKS );
302*cdf0e10cSrcweir     maSheetProt.mbDeleteColumns    = !getFlag( nFlags, BIFF_SHEETPROT_DELETE_COLUMNS );
303*cdf0e10cSrcweir     maSheetProt.mbDeleteRows       = !getFlag( nFlags, BIFF_SHEETPROT_DELETE_ROWS );
304*cdf0e10cSrcweir     maSheetProt.mbSelectLocked     = !getFlag( nFlags, BIFF_SHEETPROT_SELECT_LOCKED );
305*cdf0e10cSrcweir     maSheetProt.mbSort             = !getFlag( nFlags, BIFF_SHEETPROT_SORT );
306*cdf0e10cSrcweir     maSheetProt.mbAutoFilter       = !getFlag( nFlags, BIFF_SHEETPROT_AUTOFILTER );
307*cdf0e10cSrcweir     maSheetProt.mbPivotTables      = !getFlag( nFlags, BIFF_SHEETPROT_PIVOTTABLES );
308*cdf0e10cSrcweir     maSheetProt.mbSelectUnlocked   = !getFlag( nFlags, BIFF_SHEETPROT_SELECT_UNLOCKED );
309*cdf0e10cSrcweir }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir void WorksheetSettings::importCodeName( BiffInputStream& rStrm )
312*cdf0e10cSrcweir {
313*cdf0e10cSrcweir     maSheetSettings.maCodeName = rStrm.readUniString();
314*cdf0e10cSrcweir }
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir void WorksheetSettings::importPhoneticPr( BiffInputStream& rStrm )
317*cdf0e10cSrcweir {
318*cdf0e10cSrcweir     maPhoneticSett.importPhoneticPr( rStrm );
319*cdf0e10cSrcweir }
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir void WorksheetSettings::finalizeImport()
322*cdf0e10cSrcweir {
323*cdf0e10cSrcweir     // sheet protection
324*cdf0e10cSrcweir     if( maSheetProt.mbSheet ) try
325*cdf0e10cSrcweir     {
326*cdf0e10cSrcweir         Reference< XProtectable > xProtectable( getSheet(), UNO_QUERY_THROW );
327*cdf0e10cSrcweir         xProtectable->protect( OUString() );
328*cdf0e10cSrcweir     }
329*cdf0e10cSrcweir     catch( Exception& )
330*cdf0e10cSrcweir     {
331*cdf0e10cSrcweir     }
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir     // VBA code name
334*cdf0e10cSrcweir     PropertySet aPropSet( getSheet() );
335*cdf0e10cSrcweir     aPropSet.setProperty( PROP_CodeName, maSheetSettings.maCodeName );
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir     // sheet tab color
338*cdf0e10cSrcweir     if( !maSheetSettings.maTabColor.isAuto() )
339*cdf0e10cSrcweir     {
340*cdf0e10cSrcweir         sal_Int32 nColor = maSheetSettings.maTabColor.getColor( getBaseFilter().getGraphicHelper() );
341*cdf0e10cSrcweir         aPropSet.setProperty( PROP_TabColor, nColor );
342*cdf0e10cSrcweir     }
343*cdf0e10cSrcweir }
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir // ============================================================================
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir } // namespace xls
348*cdf0e10cSrcweir } // namespace oox
349