1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef OOX_XLS_WORKSHEETSETTINGS_HXX
25 #define OOX_XLS_WORKSHEETSETTINGS_HXX
26 
27 #include "oox/xls/richstring.hxx"
28 #include "oox/xls/worksheethelper.hxx"
29 
30 namespace oox {
31 namespace xls {
32 
33 // ============================================================================
34 
35 /** Sheet and outline settings. */
36 struct SheetSettingsModel
37 {
38     ::rtl::OUString     maCodeName;             /// VBA module codename.
39     Color               maTabColor;             /// Sheet tab color.
40     bool                mbFilterMode;           /// True = sheet contains active filter.
41     bool                mbApplyStyles;          /// True = automatic styles when creating outlines.
42     bool                mbSummaryBelow;         /// True = row outline symbols below group.
43     bool                mbSummaryRight;         /// True = column outline symbols right of group.
44 
45     explicit            SheetSettingsModel();
46 };
47 
48 // ============================================================================
49 
50 /** Sheet protection settings. */
51 struct SheetProtectionModel
52 {
53     sal_uInt16          mnPasswordHash;         /// Hash value from sheet protection password.
54     bool                mbSheet;                /// True = sheet protection enabled, locked cells are protcted.
55     bool                mbObjects;              /// True = objects locked.
56     bool                mbScenarios;            /// True = scenarios locked.
57     bool                mbFormatCells;          /// True = format cells locked.
58     bool                mbFormatColumns;        /// True = format columns locked.
59     bool                mbFormatRows;           /// True = format rows locked.
60     bool                mbInsertColumns;        /// True = insert columns locked.
61     bool                mbInsertRows;           /// True = insert rows locked.
62     bool                mbInsertHyperlinks;     /// True = insert hyperlinks locked.
63     bool                mbDeleteColumns;        /// True = delete columns locked.
64     bool                mbDeleteRows;           /// True = delete rows locked.
65     bool                mbSelectLocked;         /// True = select locked cells locked.
66     bool                mbSort;                 /// True = sorting locked.
67     bool                mbAutoFilter;           /// True = autofilters locked.
68     bool                mbPivotTables;          /// True = pivot tables locked.
69     bool                mbSelectUnlocked;       /// True = select unlocked cells locked.
70 
71     explicit            SheetProtectionModel();
72 };
73 
74 // ============================================================================
75 
76 class WorksheetSettings : public WorksheetHelper
77 {
78 public:
79     explicit            WorksheetSettings( const WorksheetHelper& rHelper );
80 
81     /** Imports sheet settings from the sheetPr element. */
82     void                importSheetPr( const AttributeList& rAttribs );
83     /** Imports chart sheet settings from the sheetPr element. */
84     void                importChartSheetPr( const AttributeList& rAttribs );
85     /** Imports the sheet tab color from the tabColor element. */
86     void                importTabColor( const AttributeList& rAttribs );
87     /** Imports outline settings from the outlinePr element. */
88     void                importOutlinePr( const AttributeList& rAttribs );
89     /** Imports protection settings from the sheetProtection element. */
90     void                importSheetProtection( const AttributeList& rAttribs );
91     /** Imports protection settings from the sheetProtection element of a chart sheet. */
92     void                importChartProtection( const AttributeList& rAttribs );
93     /** Imports phonetic settings from the phoneticPr element. */
94     void                importPhoneticPr( const AttributeList& rAttribs );
95 
96     /** Imports sheet properties from the SHEETPR record. */
97     void                importSheetPr( SequenceInputStream& rStrm );
98     /** Imports sheet properties from the CHARTSHEETPR record. */
99     void                importChartSheetPr( SequenceInputStream& rStrm );
100     /** Imports sheet protection settings from the SHEETPROTECTION record. */
101     void                importSheetProtection( SequenceInputStream& rStrm );
102     /** Imports chart sheet protection settings from the CHARTPROTECTION record. */
103     void                importChartProtection( SequenceInputStream& rStrm );
104     /** Imports phonetic settings from the PHONETICPR record. */
105     void                importPhoneticPr( SequenceInputStream& rStrm );
106 
107     /** Imports sheet properties from a SHEETEXT record. */
108     void                importSheetExt( BiffInputStream& rStrm );
109     /** Imports sheet properties from a SHEETPR record. */
110     void                importSheetPr( BiffInputStream& rStrm );
111     /** Imports protection status from the PROTECT record. */
112     void                importProtect( BiffInputStream& rStrm );
113     /** Imports object protection status from the OBJECTPROTECT record. */
114     void                importObjectProtect( BiffInputStream& rStrm );
115     /** Imports scenario protection status from the SCENPROTECT record. */
116     void                importScenProtect( BiffInputStream& rStrm );
117     /** Imports sheet password hash from the PASSWORD record. */
118     void                importPassword( BiffInputStream& rStrm );
119     /** Imports protection settings from the SHEETPROTECTION record. */
120     void                importSheetProtection( BiffInputStream& rStrm );
121     /** Imports the VBA code module name from the CODENAME record. */
122     void                importCodeName( BiffInputStream& rStrm );
123     /** Imports phonetic settings from the PHONETICPR record. */
124     void                importPhoneticPr( BiffInputStream& rStrm );
125 
126     /** Converts the imported worksheet settings. */
127     void                finalizeImport();
128 
129 private:
130     PhoneticSettings    maPhoneticSett;
131     SheetSettingsModel  maSheetSettings;
132     SheetProtectionModel maSheetProt;
133 };
134 
135 // ============================================================================
136 
137 } // namespace xls
138 } // namespace oox
139 
140 #endif
141