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 #include <stdio.h>
25 #include <rtl/ustring.hxx>
26 #include <resourcemodel/ResourceModelHelper.hxx>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <SettingsTable.hxx>
29 #include <resourcemodel/ResourceModelHelper.hxx>
30 #include <doctok/resourceids.hxx>
31 #include <ooxml/resourceids.hxx>
32 #include <ConversionHelper.hxx>
33
34 #include "dmapperLoggers.hxx"
35
36 namespace writerfilter {
37
38 using resourcemodel::resolveSprmProps;
39
40 namespace dmapper
41 {
42
43 struct SettingsTable_Impl
44 {
45 DomainMapper& m_rDMapper;
46 const uno::Reference< lang::XMultiServiceFactory > m_xTextFactory;
47
48 ::rtl::OUString m_sCharacterSpacing;
49 ::rtl::OUString m_sDecimalSymbol;
50 ::rtl::OUString m_sListSeparatorForFields; //2.15.1.56 listSeparator (List Separator for Field Code Evaluation)
51
52 int m_nDefaultTabStop;
53 int m_nHyphenationZone;
54
55 bool m_bNoPunctuationKerning;
56 bool m_doNotIncludeSubdocsInStats; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics)
57 bool m_bRecordChanges;
58 int m_nEdit;
59 bool m_bFormatting;
60 bool m_bEnforcement;
61 int m_nCryptProviderType;
62 int m_nCryptAlgorithmClass;
63 int m_nCryptAlgorithmType;
64 ::rtl::OUString m_sCryptAlgorithmSid;
65 int m_nCryptSpinCount;
66 ::rtl::OUString m_sCryptProvider;
67 ::rtl::OUString m_sAlgIdExt;
68 ::rtl::OUString m_sAlgIdExtSource;
69 ::rtl::OUString m_sCryptProviderTypeExt;
70 ::rtl::OUString m_sCryptProviderTypeExtSource;
71 ::rtl::OUString m_sHash;
72 ::rtl::OUString m_sSalt;
73
SettingsTable_Implwriterfilter::dmapper::SettingsTable_Impl74 SettingsTable_Impl( DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory ) :
75 m_rDMapper( rDMapper )
76 , m_xTextFactory( xTextFactory )
77 , m_nDefaultTabStop( 720 ) //default is 1/2 in
78 , m_nHyphenationZone(0)
79 , m_bNoPunctuationKerning(false)
80 , m_doNotIncludeSubdocsInStats(false)
81 , m_bRecordChanges(false)
82 , m_nEdit(NS_ooxml::LN_Value_wordprocessingml_ST_DocProtect_none)
83 , m_bFormatting(false)
84 , m_bEnforcement(false)
85 , m_nCryptProviderType(NS_ooxml::LN_Value_wordprocessingml_ST_CryptProv_rsaAES)
86 , m_nCryptAlgorithmClass(NS_ooxml::LN_Value_wordprocessingml_ST_AlgClass_hash)
87 , m_nCryptAlgorithmType(NS_ooxml::LN_Value_wordprocessingml_ST_AlgType_typeAny)
88 , m_nCryptSpinCount(0)
89 {}
90
91 };
92
SettingsTable(DomainMapper & rDMapper,const uno::Reference<lang::XMultiServiceFactory> xTextFactory)93 SettingsTable::SettingsTable(DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory)
94 : LoggedProperties(dmapper_logger, "SettingsTable")
95 , LoggedTable(dmapper_logger, "SettingsTable")
96 , m_pImpl( new SettingsTable_Impl(rDMapper, xTextFactory) )
97 {
98 }
99
~SettingsTable()100 SettingsTable::~SettingsTable()
101 {
102 delete m_pImpl;
103 }
104
lcl_attribute(Id nName,Value & val)105 void SettingsTable::lcl_attribute(Id nName, Value & val)
106 {
107 (void) nName;
108 int nIntValue = val.getInt();
109 (void)nIntValue;
110 ::rtl::OUString sValue = val.getString();
111 (void)sValue;
112 /* WRITERFILTERSTATUS: table: SettingsTable_attributedata */
113 #if 0 //no values known, yet
114
115 switch(Name)
116 {
117 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
118 case NS_ooxml:::
119 break;
120 default:
121 {
122 }
123 }
124 #endif
125 }
126
lcl_sprm(Sprm & rSprm)127 void SettingsTable::lcl_sprm(Sprm& rSprm)
128 {
129 sal_uInt32 nSprmId = rSprm.getId();
130
131 Value::Pointer_t pValue = rSprm.getValue();
132 sal_Int32 nIntValue = pValue->getInt();
133 (void)nIntValue;
134 rtl::OUString sStringValue = pValue->getString();
135
136 /* WRITERFILTERSTATUS: table: SettingsTable_sprm */
137 switch(nSprmId)
138 {
139 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
140 case NS_ooxml::LN_CT_Settings_zoom: // 92469;
141 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
142 case NS_ooxml::LN_CT_Settings_proofState: // 92489;
143 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
144 case NS_ooxml::LN_CT_Settings_attachedTemplate: // 92491;
145 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
146 case NS_ooxml::LN_CT_Settings_hdrShapeDefaults: // 92544;
147 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
148 case NS_ooxml::LN_CT_Settings_footnotePr: // 92545;
149 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
150 case NS_ooxml::LN_CT_Settings_endnotePr: // 92546;
151 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
152 case NS_ooxml::LN_CT_Settings_compat: // 92547;
153 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
154 case NS_ooxml::LN_CT_Settings_themeFontLang: // 92552;
155 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
156 case NS_ooxml::LN_CT_Settings_shapeDefaults: // 92560;
157
158 //PropertySetValues - need to be resolved
159 {
160 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
161 if( pProperties.get())
162 pProperties->resolve(*this);
163 }
164 break;
165 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
166 case NS_ooxml::LN_CT_Settings_stylePaneFormatFilter: // 92493;
167 break;
168 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
169 case NS_ooxml::LN_CT_Settings_defaultTabStop: // 92505;
170 m_pImpl->m_nDefaultTabStop = nIntValue;
171 break;
172 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
173 case NS_ooxml::LN_CT_Settings_noPunctuationKerning: // 92526;
174 m_pImpl->m_bNoPunctuationKerning = nIntValue ? true : false;
175 break;
176 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
177 case NS_ooxml::LN_CT_Settings_characterSpacingControl: // 92527;
178 m_pImpl->m_sCharacterSpacing = sStringValue; // doNotCompress, compressPunctuation, compressPunctuationAndJapaneseKana
179 break;
180 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
181 case NS_ooxml::LN_CT_Settings_doNotIncludeSubdocsInStats: // 92554; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics)
182 m_pImpl->m_doNotIncludeSubdocsInStats = nIntValue? true : false;
183 break;
184 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
185 case NS_ooxml::LN_CT_Settings_decimalSymbol: // 92562;
186 m_pImpl->m_sDecimalSymbol = sStringValue;
187 break;
188 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
189 case NS_ooxml::LN_CT_Settings_listSeparator: // 92563;
190 m_pImpl->m_sListSeparatorForFields = sStringValue;
191 break;
192 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
193 case NS_ooxml::LN_CT_Settings_rsids: // 92549; revision save Ids - probably not necessary
194 break;
195 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
196 case NS_ooxml::LN_CT_Settings_hyphenationZone: // 92508;
197 m_pImpl->m_nHyphenationZone = nIntValue;
198 break;
199 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
200 case NS_ooxml::LN_CT_Compat_useFELayout: // 92422;
201 // useFELayout (Do Not Bypass East Asian/Complex Script Layout Code - support of old versions of Word - ignored)
202 break;
203 case NS_ooxml::LN_CT_Settings_trackRevisions:
204 {
205 m_pImpl->m_bRecordChanges = bool(rSprm.getValue( )->getInt( ) );
206 }
207 break;
208 case NS_ooxml::LN_CT_Settings_documentProtection:
209 {
210 resolveSprmProps(*this, rSprm);
211 }
212 break;
213 default:
214 {
215 #ifdef DEBUG_DOMAINMAPPER
216 dmapper_logger->element("SettingsTable.unhandled");
217 #endif
218 }
219 }
220 }
221
lcl_entry(int,writerfilter::Reference<Properties>::Pointer_t ref)222 void SettingsTable::lcl_entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t ref)
223 {
224 ref->resolve(*this);
225 }
226 //returns default TabStop in 1/100th mm
227
228 /*-- 22.09.2009 10:29:32---------------------------------------------------
229
230 -----------------------------------------------------------------------*/
GetDefaultTabStop() const231 int SettingsTable::GetDefaultTabStop() const
232 {
233 return ConversionHelper::convertTwipToMM100( m_pImpl->m_nDefaultTabStop );
234 }
235
ApplyProperties(uno::Reference<text::XTextDocument> xDoc)236 void SettingsTable::ApplyProperties( uno::Reference< text::XTextDocument > xDoc )
237 {
238 uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
239
240 // Record changes value
241 xDocProps->setPropertyValue( ::rtl::OUString::createFromAscii( "RecordChanges" ), uno::makeAny( m_pImpl->m_bRecordChanges ) );
242 }
243
244
245 }//namespace dmapper
246 } //namespace writerfilter
247