1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
29 #include "dmapperLoggers.hxx"
31 namespace writerfilter
{
33 using resourcemodel::resolveSprmProps
;
38 struct SettingsTable_Impl
40 DomainMapper
& m_rDMapper
;
41 const uno::Reference
< lang::XMultiServiceFactory
> m_xTextFactory
;
43 OUString m_sCharacterSpacing
;
44 OUString m_sDecimalSymbol
;
45 OUString m_sListSeparatorForFields
; //2.15.1.56 listSeparator (List Separator for Field Code Evaluation)
47 int m_nDefaultTabStop
;
48 int m_nHyphenationZone
;
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
;
56 int m_nCryptProviderType
;
57 int m_nCryptAlgorithmClass
;
58 int m_nCryptAlgorithmType
;
59 OUString m_sCryptAlgorithmSid
;
60 int m_nCryptSpinCount
;
61 OUString m_sCryptProvider
;
63 OUString m_sAlgIdExtSource
;
64 OUString m_sCryptProviderTypeExt
;
65 OUString m_sCryptProviderTypeExtSource
;
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
;
77 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)
94 , m_bEvenAndOddHeaders(false)
95 , m_bUsePrinterMetrics(false)
96 , embedTrueTypeFonts(false)
97 , embedSystemFonts(false)
98 , m_bDoNotUseHTMLParagraphAutoSpacing(false)
99 , m_bSplitPgBreakAndParaMark(false)
104 SettingsTable::SettingsTable(DomainMapper
& rDMapper
, const uno::Reference
< lang::XMultiServiceFactory
> xTextFactory
)
105 : LoggedProperties(dmapper_logger
, "SettingsTable")
106 , LoggedTable(dmapper_logger
, "SettingsTable")
107 , m_pImpl( new SettingsTable_Impl(rDMapper
, xTextFactory
) )
112 SettingsTable::~SettingsTable()
117 void SettingsTable::lcl_attribute(Id nName
, Value
& val
)
119 int nIntValue
= val
.getInt();
123 case NS_ooxml::LN_CT_Zoom_percent
:
124 m_pImpl
->m_nZoomFactor
= nIntValue
;
128 #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
129 dmapper_logger
->element("unhandled");
135 void SettingsTable::lcl_sprm(Sprm
& rSprm
)
137 sal_uInt32 nSprmId
= rSprm
.getId();
139 Value::Pointer_t pValue
= rSprm
.getValue();
140 sal_Int32 nIntValue
= pValue
->getInt();
142 OUString sStringValue
= pValue
->getString();
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;
156 //PropertySetValues - need to be resolved
158 writerfilter::Reference
<Properties
>::Pointer_t pProperties
= rSprm
.getProps();
159 if( pProperties
.get())
160 pProperties
->resolve(*this);
163 case NS_ooxml::LN_CT_Settings_stylePaneFormatFilter
: // 92493;
165 case NS_ooxml::LN_CT_Settings_defaultTabStop
: // 92505;
166 m_pImpl
->m_nDefaultTabStop
= nIntValue
;
168 case NS_ooxml::LN_CT_Settings_linkStyles
: // 92663;
169 m_pImpl
->m_bLinkStyles
= nIntValue
;
171 case NS_ooxml::LN_CT_Settings_evenAndOddHeaders
:
172 m_pImpl
->m_bEvenAndOddHeaders
= nIntValue
;
174 case NS_ooxml::LN_CT_Settings_noPunctuationKerning
: // 92526;
175 m_pImpl
->m_bNoPunctuationKerning
= nIntValue
? true : false;
177 case NS_ooxml::LN_CT_Settings_characterSpacingControl
: // 92527;
178 m_pImpl
->m_sCharacterSpacing
= sStringValue
; // doNotCompress, compressPunctuation, compressPunctuationAndJapaneseKana
180 case NS_ooxml::LN_CT_Settings_doNotIncludeSubdocsInStats
: // 92554; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics)
181 m_pImpl
->m_doNotIncludeSubdocsInStats
= nIntValue
? true : false;
183 case NS_ooxml::LN_CT_Settings_decimalSymbol
: // 92562;
184 m_pImpl
->m_sDecimalSymbol
= sStringValue
;
186 case NS_ooxml::LN_CT_Settings_listSeparator
: // 92563;
187 m_pImpl
->m_sListSeparatorForFields
= sStringValue
;
189 case NS_ooxml::LN_CT_Settings_rsids
: // 92549; revision save Ids - probably not necessary
191 case NS_ooxml::LN_CT_Settings_hyphenationZone
: // 92508;
192 m_pImpl
->m_nHyphenationZone
= nIntValue
;
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)
197 case NS_ooxml::LN_CT_Settings_trackRevisions
:
199 m_pImpl
->m_bRecordChanges
= bool(rSprm
.getValue( )->getInt( ) );
202 case NS_ooxml::LN_CT_Settings_documentProtection
:
204 resolveSprmProps(*this, rSprm
);
207 case NS_ooxml::LN_CT_Compat_usePrinterMetrics
:
208 m_pImpl
->m_bUsePrinterMetrics
= nIntValue
;
210 case NS_ooxml::LN_CT_Settings_embedTrueTypeFonts
:
211 m_pImpl
->embedTrueTypeFonts
= nIntValue
!= 0;
213 case NS_ooxml::LN_CT_Settings_embedSystemFonts
:
214 m_pImpl
->embedSystemFonts
= nIntValue
!= 0;
216 case NS_ooxml::LN_CT_Compat_doNotUseHTMLParagraphAutoSpacing
:
217 m_pImpl
->m_bDoNotUseHTMLParagraphAutoSpacing
= nIntValue
;
219 case NS_ooxml::LN_CT_Compat_splitPgBreakAndParaMark
:
220 m_pImpl
->m_bSplitPgBreakAndParaMark
= nIntValue
;
224 #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
225 dmapper_logger
->element("unhandled");
231 void SettingsTable::lcl_entry(int /*pos*/, writerfilter::Reference
<Properties
>::Pointer_t ref
)
235 //returns default TabStop in 1/100th mm
239 int SettingsTable::GetDefaultTabStop() const
241 return ConversionHelper::convertTwipToMM100( m_pImpl
->m_nDefaultTabStop
);
244 bool SettingsTable::GetLinkStyles() const
246 return m_pImpl
->m_bLinkStyles
;
249 sal_Int16
SettingsTable::GetZoomFactor() const
251 return m_pImpl
->m_nZoomFactor
;
254 bool SettingsTable::GetUsePrinterMetrics() const
256 return m_pImpl
->m_bUsePrinterMetrics
;
259 bool SettingsTable::GetEvenAndOddHeaders() const
261 return m_pImpl
->m_bEvenAndOddHeaders
;
264 bool SettingsTable::GetEmbedTrueTypeFonts() const
266 return m_pImpl
->embedTrueTypeFonts
;
269 bool SettingsTable::GetEmbedSystemFonts() const
271 return m_pImpl
->embedSystemFonts
;
274 bool SettingsTable::GetDoNotUseHTMLParagraphAutoSpacing() const
276 return m_pImpl
->m_bDoNotUseHTMLParagraphAutoSpacing
;
279 bool SettingsTable::GetSplitPgBreakAndParaMark() const
281 return m_pImpl
->m_bSplitPgBreakAndParaMark
;
284 void SettingsTable::ApplyProperties( uno::Reference
< text::XTextDocument
> xDoc
)
286 uno::Reference
< beans::XPropertySet
> xDocProps( xDoc
, uno::UNO_QUERY
);
288 // Record changes value
290 xDocProps
->setPropertyValue("RecordChanges", uno::makeAny( m_pImpl
->m_bRecordChanges
) );
295 } //namespace writerfilter
297 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */