Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <stdio.h>
21 : #include <rtl/ustring.hxx>
22 : #include <resourcemodel/ResourceModelHelper.hxx>
23 : #include <com/sun/star/beans/XPropertySet.hpp>
24 : #include <SettingsTable.hxx>
25 : #include <doctok/resourceids.hxx>
26 : #include <ooxml/resourceids.hxx>
27 : #include <ConversionHelper.hxx>
28 :
29 : #include "dmapperLoggers.hxx"
30 :
31 : namespace writerfilter {
32 :
33 : using resourcemodel::resolveSprmProps;
34 :
35 : namespace dmapper
36 : {
37 :
38 223 : struct SettingsTable_Impl
39 : {
40 : DomainMapper& m_rDMapper;
41 : const uno::Reference< lang::XMultiServiceFactory > m_xTextFactory;
42 :
43 : OUString m_sCharacterSpacing;
44 : OUString m_sDecimalSymbol;
45 : OUString m_sListSeparatorForFields; //2.15.1.56 listSeparator (List Separator for Field Code Evaluation)
46 :
47 : int m_nDefaultTabStop;
48 : int m_nHyphenationZone;
49 :
50 : bool m_bNoPunctuationKerning;
51 : bool m_doNotIncludeSubdocsInStats; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics)
52 : bool m_bRecordChanges;
53 : int m_nEdit;
54 : bool m_bFormatting;
55 : bool m_bEnforcement;
56 : int m_nCryptProviderType;
57 : int m_nCryptAlgorithmClass;
58 : int m_nCryptAlgorithmType;
59 : OUString m_sCryptAlgorithmSid;
60 : int m_nCryptSpinCount;
61 : OUString m_sCryptProvider;
62 : OUString m_sAlgIdExt;
63 : OUString m_sAlgIdExtSource;
64 : OUString m_sCryptProviderTypeExt;
65 : OUString m_sCryptProviderTypeExtSource;
66 : OUString m_sHash;
67 : OUString m_sSalt;
68 : bool m_bLinkStyles;
69 : sal_Int16 m_nZoomFactor;
70 : bool m_bEvenAndOddHeaders;
71 : bool m_bUsePrinterMetrics;
72 : bool embedTrueTypeFonts;
73 : bool embedSystemFonts;
74 : bool m_bDoNotUseHTMLParagraphAutoSpacing;
75 : bool m_bSplitPgBreakAndParaMark;
76 :
77 223 : SettingsTable_Impl( DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory ) :
78 : m_rDMapper( rDMapper )
79 : , m_xTextFactory( xTextFactory )
80 : , m_nDefaultTabStop( 720 ) //default is 1/2 in
81 : , m_nHyphenationZone(0)
82 : , m_bNoPunctuationKerning(false)
83 : , m_doNotIncludeSubdocsInStats(false)
84 : , m_bRecordChanges(false)
85 : , m_nEdit(NS_ooxml::LN_Value_wordprocessingml_ST_DocProtect_none)
86 : , m_bFormatting(false)
87 : , m_bEnforcement(false)
88 : , m_nCryptProviderType(NS_ooxml::LN_Value_wordprocessingml_ST_CryptProv_rsaAES)
89 : , m_nCryptAlgorithmClass(NS_ooxml::LN_Value_wordprocessingml_ST_AlgClass_hash)
90 : , m_nCryptAlgorithmType(NS_ooxml::LN_Value_wordprocessingml_ST_AlgType_typeAny)
91 : , m_nCryptSpinCount(0)
92 : , m_bLinkStyles(false)
93 : , m_nZoomFactor(0)
94 : , m_bEvenAndOddHeaders(false)
95 : , m_bUsePrinterMetrics(false)
96 : , embedTrueTypeFonts(false)
97 : , embedSystemFonts(false)
98 : , m_bDoNotUseHTMLParagraphAutoSpacing(false)
99 223 : , m_bSplitPgBreakAndParaMark(false)
100 223 : {}
101 :
102 : };
103 :
104 223 : SettingsTable::SettingsTable(DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory)
105 : : LoggedProperties(dmapper_logger, "SettingsTable")
106 : , LoggedTable(dmapper_logger, "SettingsTable")
107 223 : , m_pImpl( new SettingsTable_Impl(rDMapper, xTextFactory) )
108 : {
109 :
110 223 : }
111 :
112 669 : SettingsTable::~SettingsTable()
113 : {
114 223 : delete m_pImpl;
115 446 : }
116 :
117 240 : void SettingsTable::lcl_attribute(Id nName, Value & val)
118 : {
119 240 : int nIntValue = val.getInt();
120 :
121 240 : switch(nName)
122 : {
123 : case NS_ooxml::LN_CT_Zoom_percent:
124 116 : m_pImpl->m_nZoomFactor = nIntValue;
125 116 : break;
126 : default:
127 : {
128 : #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
129 : dmapper_logger->element("unhandled");
130 : #endif
131 : }
132 : }
133 240 : }
134 :
135 833 : void SettingsTable::lcl_sprm(Sprm& rSprm)
136 : {
137 833 : sal_uInt32 nSprmId = rSprm.getId();
138 :
139 833 : Value::Pointer_t pValue = rSprm.getValue();
140 833 : sal_Int32 nIntValue = pValue->getInt();
141 : (void)nIntValue;
142 833 : OUString sStringValue = pValue->getString();
143 :
144 833 : switch(nSprmId)
145 : {
146 : case NS_ooxml::LN_CT_Settings_zoom: // 92469;
147 : case NS_ooxml::LN_CT_Settings_proofState: // 92489;
148 : case NS_ooxml::LN_CT_Settings_attachedTemplate: // 92491;
149 : case NS_ooxml::LN_CT_Settings_hdrShapeDefaults: // 92544;
150 : case NS_ooxml::LN_CT_Settings_footnotePr: // 92545;
151 : case NS_ooxml::LN_CT_Settings_endnotePr: // 92546;
152 : case NS_ooxml::LN_CT_Settings_compat: // 92547;
153 : case NS_ooxml::LN_CT_Settings_themeFontLang: // 92552;
154 : case NS_ooxml::LN_CT_Settings_shapeDefaults: // 92560;
155 :
156 : //PropertySetValues - need to be resolved
157 : {
158 289 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
159 289 : if( pProperties.get())
160 289 : pProperties->resolve(*this);
161 : }
162 289 : break;
163 : case NS_ooxml::LN_CT_Settings_stylePaneFormatFilter: // 92493;
164 2 : break;
165 : case NS_ooxml::LN_CT_Settings_defaultTabStop: // 92505;
166 96 : m_pImpl->m_nDefaultTabStop = nIntValue;
167 96 : break;
168 : case NS_ooxml::LN_CT_Settings_linkStyles: // 92663;
169 1 : m_pImpl->m_bLinkStyles = nIntValue;
170 1 : break;
171 : case NS_ooxml::LN_CT_Settings_evenAndOddHeaders:
172 2 : m_pImpl->m_bEvenAndOddHeaders = nIntValue;
173 2 : break;
174 : case NS_ooxml::LN_CT_Settings_noPunctuationKerning: // 92526;
175 1 : m_pImpl->m_bNoPunctuationKerning = nIntValue ? true : false;
176 1 : break;
177 : case NS_ooxml::LN_CT_Settings_characterSpacingControl: // 92527;
178 49 : m_pImpl->m_sCharacterSpacing = sStringValue; // doNotCompress, compressPunctuation, compressPunctuationAndJapaneseKana
179 49 : break;
180 : case NS_ooxml::LN_CT_Settings_doNotIncludeSubdocsInStats: // 92554; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics)
181 5 : m_pImpl->m_doNotIncludeSubdocsInStats = nIntValue? true : false;
182 5 : break;
183 : case NS_ooxml::LN_CT_Settings_decimalSymbol: // 92562;
184 49 : m_pImpl->m_sDecimalSymbol = sStringValue;
185 49 : break;
186 : case NS_ooxml::LN_CT_Settings_listSeparator: // 92563;
187 49 : m_pImpl->m_sListSeparatorForFields = sStringValue;
188 49 : break;
189 : case NS_ooxml::LN_CT_Settings_rsids: // 92549; revision save Ids - probably not necessary
190 49 : break;
191 : case NS_ooxml::LN_CT_Settings_hyphenationZone: // 92508;
192 7 : m_pImpl->m_nHyphenationZone = nIntValue;
193 7 : break;
194 : case NS_ooxml::LN_CT_Compat_useFELayout: // 92422;
195 : // useFELayout (Do Not Bypass East Asian/Complex Script Layout Code - support of old versions of Word - ignored)
196 9 : break;
197 : case NS_ooxml::LN_CT_Settings_trackRevisions:
198 : {
199 0 : m_pImpl->m_bRecordChanges = bool(rSprm.getValue( )->getInt( ) );
200 : }
201 0 : break;
202 : case NS_ooxml::LN_CT_Settings_documentProtection:
203 : {
204 0 : resolveSprmProps(*this, rSprm);
205 : }
206 0 : break;
207 : case NS_ooxml::LN_CT_Compat_usePrinterMetrics:
208 0 : m_pImpl->m_bUsePrinterMetrics = nIntValue;
209 0 : break;
210 : case NS_ooxml::LN_CT_Settings_embedTrueTypeFonts:
211 0 : m_pImpl->embedTrueTypeFonts = nIntValue != 0;
212 0 : break;
213 : case NS_ooxml::LN_CT_Settings_embedSystemFonts:
214 6 : m_pImpl->embedSystemFonts = nIntValue != 0;
215 6 : break;
216 : case NS_ooxml::LN_CT_Compat_doNotUseHTMLParagraphAutoSpacing:
217 2 : m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing = nIntValue;
218 2 : break;
219 : case NS_ooxml::LN_CT_Compat_splitPgBreakAndParaMark:
220 5 : m_pImpl->m_bSplitPgBreakAndParaMark = nIntValue;
221 5 : break;
222 : default:
223 : {
224 : #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
225 : dmapper_logger->element("unhandled");
226 : #endif
227 : }
228 833 : }
229 833 : }
230 :
231 213 : void SettingsTable::lcl_entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t ref)
232 : {
233 213 : ref->resolve(*this);
234 213 : }
235 : //returns default TabStop in 1/100th mm
236 :
237 :
238 :
239 205 : int SettingsTable::GetDefaultTabStop() const
240 : {
241 205 : return ConversionHelper::convertTwipToMM100( m_pImpl->m_nDefaultTabStop );
242 : }
243 :
244 205 : bool SettingsTable::GetLinkStyles() const
245 : {
246 205 : return m_pImpl->m_bLinkStyles;
247 : }
248 :
249 323 : sal_Int16 SettingsTable::GetZoomFactor() const
250 : {
251 323 : return m_pImpl->m_nZoomFactor;
252 : }
253 :
254 205 : bool SettingsTable::GetUsePrinterMetrics() const
255 : {
256 205 : return m_pImpl->m_bUsePrinterMetrics;
257 : }
258 :
259 5 : bool SettingsTable::GetEvenAndOddHeaders() const
260 : {
261 5 : return m_pImpl->m_bEvenAndOddHeaders;
262 : }
263 :
264 205 : bool SettingsTable::GetEmbedTrueTypeFonts() const
265 : {
266 205 : return m_pImpl->embedTrueTypeFonts;
267 : }
268 :
269 205 : bool SettingsTable::GetEmbedSystemFonts() const
270 : {
271 205 : return m_pImpl->embedSystemFonts;
272 : }
273 :
274 211 : bool SettingsTable::GetDoNotUseHTMLParagraphAutoSpacing() const
275 : {
276 211 : return m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing;
277 : }
278 :
279 481 : bool SettingsTable::GetSplitPgBreakAndParaMark() const
280 : {
281 481 : return m_pImpl->m_bSplitPgBreakAndParaMark;
282 : }
283 :
284 223 : void SettingsTable::ApplyProperties( uno::Reference< text::XTextDocument > xDoc )
285 : {
286 223 : uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
287 :
288 : // Record changes value
289 223 : if (xDocProps.is())
290 212 : xDocProps->setPropertyValue("RecordChanges", uno::makeAny( m_pImpl->m_bRecordChanges ) );
291 223 : }
292 :
293 :
294 : }//namespace dmapper
295 15 : } //namespace writerfilter
296 :
297 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|