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 // printf("SettingsTable::SettingsTable()\n");
99 }
100
~SettingsTable()101 SettingsTable::~SettingsTable()
102 {
103 delete m_pImpl;
104 }
105
lcl_attribute(Id nName,Value & val)106 void SettingsTable::lcl_attribute(Id nName, Value & val)
107 {
108 (void) nName;
109 int nIntValue = val.getInt();
110 (void)nIntValue;
111 ::rtl::OUString sValue = val.getString();
112 (void)sValue;
113 //printf ( "SettingsTable::attribute(0x%.4x, 0x%.4x) [%s]\n", (unsigned int)Name, (unsigned int)nIntValue, ::rtl::OUStringToOString(sValue, RTL_TEXTENCODING_DONTKNOW).getStr());
114 /* WRITERFILTERSTATUS: table: SettingsTable_attributedata */
115 #if 0 //no values known, yet
116
117 switch(Name)
118 {
119 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
120 case NS_ooxml:::
121 break;
122 default:
123 {
124 }
125 }
126 #endif
127 }
128
lcl_sprm(Sprm & rSprm)129 void SettingsTable::lcl_sprm(Sprm& rSprm)
130 {
131 sal_uInt32 nSprmId = rSprm.getId();
132
133 Value::Pointer_t pValue = rSprm.getValue();
134 sal_Int32 nIntValue = pValue->getInt();
135 (void)nIntValue;
136 rtl::OUString sStringValue = pValue->getString();
137
138 //printf ( "SettingsTable::sprm(0x%.4x, 0x%.4x) [%s]\n", (unsigned int)nSprmId, (unsigned int)nIntValue, ::rtl::OUStringToOString(sStringValue, RTL_TEXTENCODING_DONTKNOW).getStr());
139
140 /* WRITERFILTERSTATUS: table: SettingsTable_sprm */
141 switch(nSprmId)
142 {
143 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
144 case NS_ooxml::LN_CT_Settings_zoom: // 92469;
145 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
146 case NS_ooxml::LN_CT_Settings_proofState: // 92489;
147 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
148 case NS_ooxml::LN_CT_Settings_attachedTemplate: // 92491;
149 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
150 case NS_ooxml::LN_CT_Settings_hdrShapeDefaults: // 92544;
151 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
152 case NS_ooxml::LN_CT_Settings_footnotePr: // 92545;
153 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
154 case NS_ooxml::LN_CT_Settings_endnotePr: // 92546;
155 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
156 case NS_ooxml::LN_CT_Settings_compat: // 92547;
157 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
158 case NS_ooxml::LN_CT_Settings_themeFontLang: // 92552;
159 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
160 case NS_ooxml::LN_CT_Settings_shapeDefaults: // 92560;
161
162 //PropertySetValues - need to be resolved
163 {
164 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
165 if( pProperties.get())
166 pProperties->resolve(*this);
167 }
168 break;
169 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
170 case NS_ooxml::LN_CT_Settings_stylePaneFormatFilter: // 92493;
171 break;
172 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
173 case NS_ooxml::LN_CT_Settings_defaultTabStop: // 92505;
174 m_pImpl->m_nDefaultTabStop = nIntValue;
175 break;
176 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
177 case NS_ooxml::LN_CT_Settings_noPunctuationKerning: // 92526;
178 m_pImpl->m_bNoPunctuationKerning = nIntValue ? true : false;
179 break;
180 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
181 case NS_ooxml::LN_CT_Settings_characterSpacingControl: // 92527;
182 m_pImpl->m_sCharacterSpacing = sStringValue; // doNotCompress, compressPunctuation, compressPunctuationAndJapaneseKana
183 break;
184 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
185 case NS_ooxml::LN_CT_Settings_doNotIncludeSubdocsInStats: // 92554; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics)
186 m_pImpl->m_doNotIncludeSubdocsInStats = nIntValue? true : false;
187 break;
188 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
189 case NS_ooxml::LN_CT_Settings_decimalSymbol: // 92562;
190 m_pImpl->m_sDecimalSymbol = sStringValue;
191 break;
192 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
193 case NS_ooxml::LN_CT_Settings_listSeparator: // 92563;
194 m_pImpl->m_sListSeparatorForFields = sStringValue;
195 break;
196 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
197 case NS_ooxml::LN_CT_Settings_rsids: // 92549; revision save Ids - probably not necessary
198 break;
199 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
200 case NS_ooxml::LN_CT_Settings_hyphenationZone: // 92508;
201 m_pImpl->m_nHyphenationZone = nIntValue;
202 break;
203 /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */
204 case NS_ooxml::LN_CT_Compat_useFELayout: // 92422;
205 // useFELayout (Do Not Bypass East Asian/Complex Script Layout Code - support of old versions of Word - ignored)
206 break;
207 case NS_ooxml::LN_CT_Settings_trackRevisions:
208 {
209 m_pImpl->m_bRecordChanges = bool(rSprm.getValue( )->getInt( ) );
210 }
211 break;
212 case NS_ooxml::LN_CT_Settings_documentProtection:
213 {
214 resolveSprmProps(*this, rSprm);
215 }
216 break;
217 default:
218 {
219 #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
220 dmapper_logger->element("unhandled");
221 #endif
222 }
223 }
224 }
225
lcl_entry(int,writerfilter::Reference<Properties>::Pointer_t ref)226 void SettingsTable::lcl_entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t ref)
227 {
228 // printf ( "SettingsTable::entry\n");
229 ref->resolve(*this);
230 }
231 //returns default TabStop in 1/100th mm
232
233 /*-- 22.09.2009 10:29:32---------------------------------------------------
234
235 -----------------------------------------------------------------------*/
GetDefaultTabStop() const236 int SettingsTable::GetDefaultTabStop() const
237 {
238 return ConversionHelper::convertTwipToMM100( m_pImpl->m_nDefaultTabStop );
239 }
240
ApplyProperties(uno::Reference<text::XTextDocument> xDoc)241 void SettingsTable::ApplyProperties( uno::Reference< text::XTextDocument > xDoc )
242 {
243 uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
244
245 // Record changes value
246 xDocProps->setPropertyValue( ::rtl::OUString::createFromAscii( "RecordChanges" ), uno::makeAny( m_pImpl->m_bRecordChanges ) );
247 }
248
249
250 }//namespace dmapper
251 } //namespace writerfilter
252