lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / writerfilter / source / dmapper / SettingsTable.cxx
blob2216e69b78baab85a4e67983ceda42e9fec83af2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include "SettingsTable.hxx"
22 #include <vector>
24 #include <rtl/ustring.hxx>
25 #include <sfx2/zoomitem.hxx>
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/beans/XPropertyState.hpp>
28 #include <com/sun/star/container/XNameContainer.hpp>
29 #include <com/sun/star/style/XStyle.hpp>
30 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
31 #include <comphelper/sequence.hxx>
32 #include <ooxml/resourceids.hxx>
33 #include "ConversionHelper.hxx"
34 #include "DomainMapper.hxx"
35 #include "util.hxx"
37 using namespace com::sun::star;
39 namespace writerfilter {
40 namespace
42 /// Maps OOXML <w:zoom w:val="..."> to SvxZoomType.
43 sal_Int16 lcl_GetZoomType(Id nType)
45 switch (nType)
47 case NS_ooxml::LN_Value_doc_ST_Zoom_fullPage:
48 return sal_Int16(SvxZoomType::WHOLEPAGE);
49 case NS_ooxml::LN_Value_doc_ST_Zoom_bestFit:
50 return sal_Int16(SvxZoomType::PAGEWIDTH);
51 case NS_ooxml::LN_Value_doc_ST_Zoom_textFit:
52 return sal_Int16(SvxZoomType::OPTIMAL);
55 return sal_Int16(SvxZoomType::PERCENT);
59 namespace dmapper
61 /** Document protection restrictions
63 * This element specifies the set of document protection restrictions which have been applied to the contents of a
64 * WordprocessingML document.These restrictions should be enforced by applications editing this document
65 * when the enforcement attribute is turned on, and ignored(but persisted) otherwise.Document protection is a
66 * set of restrictions used to prevent unintentional changes to all or part of a WordprocessingML document.
68 struct DocumentProtection_Impl
70 /** Document Editing Restrictions
72 * Possible values:
73 * - NS_ooxml::LN_Value_doc_ST_DocProtect_none
74 * - NS_ooxml::LN_Value_doc_ST_DocProtect_readOnly
75 * - NS_ooxml::LN_Value_doc_ST_DocProtect_comments
76 * - NS_ooxml::LN_Value_doc_ST_DocProtect_trackedChanges
77 * - NS_ooxml::LN_Value_doc_ST_DocProtect_forms
79 sal_Int32 m_nEdit;
80 bool m_bEnforcement;
81 bool m_bFormatting;
83 /** Provider type
85 * Possible values:
86 * "rsaAES" - NS_ooxml::LN_Value_doc_ST_CryptProv_rsaAES
87 * "rsaFull" - NS_ooxml::LN_Value_doc_ST_CryptProv_rsaFull
89 sal_Int32 m_nCryptProviderType;
90 OUString m_sCryptAlgorithmClass;
91 OUString m_sCryptAlgorithmType;
92 OUString m_sCryptAlgorithmSid;
93 sal_Int32 m_CryptSpinCount;
94 OUString m_sHash;
95 OUString m_sSalt;
97 DocumentProtection_Impl()
98 : m_nEdit(NS_ooxml::LN_Value_doc_ST_DocProtect_none) // Specifies that no editing restrictions have been applied to the document
99 , m_bEnforcement(false)
100 , m_bFormatting(false)
101 , m_nCryptProviderType(NS_ooxml::LN_Value_doc_ST_CryptProv_rsaAES)
102 , m_sCryptAlgorithmClass("hash")
103 , m_sCryptAlgorithmType("typeAny")
104 , m_CryptSpinCount(0)
108 css::uno::Sequence<css::beans::PropertyValue> toSequence() const;
110 bool enabled() const
112 return ! isNone();
115 bool isNone() const { return m_nEdit == NS_ooxml::LN_Value_doc_ST_DocProtect_none; };
116 // bool isReadOnly() const { return m_nEdit == NS_ooxml::LN_Value_doc_ST_DocProtect_readOnly; };
117 // bool isComments() const { return m_nEdit == NS_ooxml::LN_Value_doc_ST_DocProtect_comments; };
118 // bool isTrackChanges() const { return m_nEdit == NS_ooxml::LN_Value_doc_ST_DocProtect_trackedChanges; };
119 bool isForms() const { return m_nEdit == NS_ooxml::LN_Value_doc_ST_DocProtect_forms; };
122 css::uno::Sequence<css::beans::PropertyValue> DocumentProtection_Impl::toSequence() const
124 std::vector<beans::PropertyValue> documentProtection;
126 if (enabled())
128 // w:edit
130 beans::PropertyValue aValue;
131 aValue.Name = "edit";
133 switch (m_nEdit)
135 case NS_ooxml::LN_Value_doc_ST_DocProtect_none: aValue.Value <<= OUString("none"); break;
136 case NS_ooxml::LN_Value_doc_ST_DocProtect_readOnly: aValue.Value <<= OUString("readOnly"); break;
137 case NS_ooxml::LN_Value_doc_ST_DocProtect_comments: aValue.Value <<= OUString("comments"); break;
138 case NS_ooxml::LN_Value_doc_ST_DocProtect_trackedChanges: aValue.Value <<= OUString("trackedChanges"); break;
139 case NS_ooxml::LN_Value_doc_ST_DocProtect_forms: aValue.Value <<= OUString("forms"); break;
140 default:
142 #ifdef DEBUG_WRITERFILTER
143 TagLogger::getInstance().element("unhandled");
144 #endif
148 documentProtection.push_back(aValue);
151 // w:enforcement
152 if (m_bEnforcement)
154 beans::PropertyValue aValue;
155 aValue.Name = "enforcement";
156 aValue.Value <<= OUString("1");
157 documentProtection.push_back(aValue);
160 // w:formatting
161 if (m_bFormatting)
163 beans::PropertyValue aValue;
164 aValue.Name = "formatting";
165 aValue.Value <<= OUString("1");
166 documentProtection.push_back(aValue);
169 // w:cryptProviderType
171 beans::PropertyValue aValue;
172 aValue.Name = "cryptProviderType";
173 if (m_nCryptProviderType == NS_ooxml::LN_Value_doc_ST_CryptProv_rsaAES)
174 aValue.Value <<= OUString("rsaAES");
175 else if (m_nCryptProviderType == NS_ooxml::LN_Value_doc_ST_CryptProv_rsaFull)
176 aValue.Value <<= OUString("rsaFull");
177 documentProtection.push_back(aValue);
180 // w:cryptAlgorithmClass
182 beans::PropertyValue aValue;
183 aValue.Name = "cryptAlgorithmClass";
184 aValue.Value <<= m_sCryptAlgorithmClass;
185 documentProtection.push_back(aValue);
188 // w:cryptAlgorithmType
190 beans::PropertyValue aValue;
191 aValue.Name = "cryptAlgorithmType";
192 aValue.Value <<= m_sCryptAlgorithmType;
193 documentProtection.push_back(aValue);
196 // w:cryptAlgorithmSid
198 beans::PropertyValue aValue;
199 aValue.Name = "cryptAlgorithmSid";
200 aValue.Value <<= m_sCryptAlgorithmSid;
201 documentProtection.push_back(aValue);
204 // w:cryptSpinCount
206 beans::PropertyValue aValue;
207 aValue.Name = "cryptSpinCount";
208 aValue.Value <<= OUString::number(m_CryptSpinCount);
209 documentProtection.push_back(aValue);
212 // w:hash
214 beans::PropertyValue aValue;
215 aValue.Name = "hash";
216 aValue.Value <<= m_sHash;
217 documentProtection.push_back(aValue);
220 // w:salt
222 beans::PropertyValue aValue;
223 aValue.Name = "salt";
224 aValue.Value <<= m_sSalt;
225 documentProtection.push_back(aValue);
229 return comphelper::containerToSequence(documentProtection);
232 struct SettingsTable_Impl
234 OUString m_sCharacterSpacing;
235 OUString m_sDecimalSymbol;
236 OUString m_sListSeparatorForFields; //2.15.1.56 listSeparator (List Separator for Field Code Evaluation)
238 int m_nDefaultTabStop;
240 bool m_bRecordChanges;
241 bool m_bLinkStyles;
242 sal_Int16 m_nZoomFactor;
243 sal_Int16 m_nZoomType = 0;
244 Id m_nView;
245 bool m_bEvenAndOddHeaders;
246 bool m_bUsePrinterMetrics;
247 bool embedTrueTypeFonts;
248 bool embedSystemFonts;
249 bool m_bDoNotUseHTMLParagraphAutoSpacing;
250 bool m_bNoColumnBalance;
251 bool m_bAutoHyphenation;
252 bool m_bWidowControl;
253 bool m_bSplitPgBreakAndParaMark;
254 bool m_bMirrorMargin;
255 bool m_bDoNotExpandShiftReturn;
256 bool m_bProtectForm;
257 bool m_bDisplayBackgroundShape;
259 uno::Sequence<beans::PropertyValue> m_pThemeFontLangProps;
261 std::vector<beans::PropertyValue> m_aCompatSettings;
262 uno::Sequence<beans::PropertyValue> m_pCurrentCompatSetting;
264 DocumentProtection_Impl m_DocumentProtection;
266 SettingsTable_Impl() :
267 m_nDefaultTabStop( 720 ) //default is 1/2 in
268 , m_bRecordChanges(false)
269 , m_bLinkStyles(false)
270 , m_nZoomFactor(0)
271 , m_nView(0)
272 , m_bEvenAndOddHeaders(false)
273 , m_bUsePrinterMetrics(false)
274 , embedTrueTypeFonts(false)
275 , embedSystemFonts(false)
276 , m_bDoNotUseHTMLParagraphAutoSpacing(false)
277 , m_bNoColumnBalance(false)
278 , m_bAutoHyphenation(false)
279 , m_bWidowControl(false)
280 , m_bSplitPgBreakAndParaMark(false)
281 , m_bMirrorMargin(false)
282 , m_bDoNotExpandShiftReturn(false)
283 , m_bProtectForm(false)
284 , m_bDisplayBackgroundShape(false)
285 , m_pThemeFontLangProps(3)
286 , m_pCurrentCompatSetting(3)
291 SettingsTable::SettingsTable(const DomainMapper& rDomainMapper)
292 : LoggedProperties("SettingsTable")
293 , LoggedTable("SettingsTable")
294 , m_pImpl( new SettingsTable_Impl )
296 // HTML paragraph auto-spacing is opt-in for RTF, opt-out for OOXML.
297 if (rDomainMapper.IsRTFImport())
298 m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing = true;
301 SettingsTable::~SettingsTable()
305 void SettingsTable::lcl_attribute(Id nName, Value & val)
307 int nIntValue = val.getInt();
308 OUString sStringValue = val.getString();
310 switch(nName)
312 case NS_ooxml::LN_CT_Zoom_percent:
313 m_pImpl->m_nZoomFactor = nIntValue;
314 break;
315 case NS_ooxml::LN_CT_Zoom_val:
316 m_pImpl->m_nZoomType = lcl_GetZoomType(nIntValue);
317 break;
318 case NS_ooxml::LN_CT_Language_val:
319 m_pImpl->m_pThemeFontLangProps[0].Name = "val";
320 m_pImpl->m_pThemeFontLangProps[0].Value <<= sStringValue;
321 break;
322 case NS_ooxml::LN_CT_Language_eastAsia:
323 m_pImpl->m_pThemeFontLangProps[1].Name = "eastAsia";
324 m_pImpl->m_pThemeFontLangProps[1].Value <<= sStringValue;
325 break;
326 case NS_ooxml::LN_CT_Language_bidi:
327 m_pImpl->m_pThemeFontLangProps[2].Name = "bidi";
328 m_pImpl->m_pThemeFontLangProps[2].Value <<= sStringValue;
329 break;
330 case NS_ooxml::LN_CT_View_val:
331 m_pImpl->m_nView = nIntValue;
332 break;
333 case NS_ooxml::LN_CT_CompatSetting_name:
334 m_pImpl->m_pCurrentCompatSetting[0].Name = "name";
335 m_pImpl->m_pCurrentCompatSetting[0].Value <<= sStringValue;
336 break;
337 case NS_ooxml::LN_CT_CompatSetting_uri:
338 m_pImpl->m_pCurrentCompatSetting[1].Name = "uri";
339 m_pImpl->m_pCurrentCompatSetting[1].Value <<= sStringValue;
340 break;
341 case NS_ooxml::LN_CT_CompatSetting_val:
342 m_pImpl->m_pCurrentCompatSetting[2].Name = "val";
343 m_pImpl->m_pCurrentCompatSetting[2].Value <<= sStringValue;
344 break;
345 case NS_ooxml::LN_CT_DocProtect_edit: // 92037
346 m_pImpl->m_DocumentProtection.m_nEdit = nIntValue;
347 m_pImpl->m_bProtectForm = m_pImpl->m_DocumentProtection.isForms();
348 break;
349 case NS_ooxml::LN_CT_DocProtect_enforcement: // 92039
350 m_pImpl->m_DocumentProtection.m_bEnforcement = (nIntValue != 0);
351 m_pImpl->m_bProtectForm &= static_cast<bool>(nIntValue);
352 break;
353 case NS_ooxml::LN_CT_DocProtect_formatting: // 92038
354 m_pImpl->m_DocumentProtection.m_bFormatting = (nIntValue != 0);
355 break;
356 case NS_ooxml::LN_AG_Password_cryptProviderType: // 92025
357 m_pImpl->m_DocumentProtection.m_nCryptProviderType = nIntValue;
358 break;
359 case NS_ooxml::LN_AG_Password_cryptAlgorithmClass: // 92026
360 if (nIntValue == NS_ooxml::LN_Value_doc_ST_AlgClass_hash) // 92023
361 m_pImpl->m_DocumentProtection.m_sCryptAlgorithmClass = "hash";
362 break;
363 case NS_ooxml::LN_AG_Password_cryptAlgorithmType: // 92027
364 if (nIntValue == NS_ooxml::LN_Value_doc_ST_AlgType_typeAny) // 92024
365 m_pImpl->m_DocumentProtection.m_sCryptAlgorithmType = "typeAny";
366 break;
367 case NS_ooxml::LN_AG_Password_cryptAlgorithmSid: // 92028
368 m_pImpl->m_DocumentProtection.m_sCryptAlgorithmSid = sStringValue;
369 break;
370 case NS_ooxml::LN_AG_Password_cryptSpinCount: // 92029
371 m_pImpl->m_DocumentProtection.m_CryptSpinCount = nIntValue;
372 break;
373 case NS_ooxml::LN_AG_Password_hash: // 92035
374 m_pImpl->m_DocumentProtection.m_sHash = sStringValue;
375 break;
376 case NS_ooxml::LN_AG_Password_salt: // 92036
377 m_pImpl->m_DocumentProtection.m_sSalt = sStringValue;
378 break;
379 default:
381 #ifdef DEBUG_WRITERFILTER
382 TagLogger::getInstance().element("unhandled");
383 #endif
388 void SettingsTable::lcl_sprm(Sprm& rSprm)
390 sal_uInt32 nSprmId = rSprm.getId();
392 Value::Pointer_t pValue = rSprm.getValue();
393 sal_Int32 nIntValue = pValue->getInt();
394 OUString sStringValue = pValue->getString();
396 switch(nSprmId)
398 case NS_ooxml::LN_CT_Settings_zoom: // 92469;
399 case NS_ooxml::LN_CT_Settings_proofState: // 92489;
400 case NS_ooxml::LN_CT_Settings_attachedTemplate: // 92491;
401 case NS_ooxml::LN_CT_Settings_hdrShapeDefaults: // 92544;
402 case NS_ooxml::LN_CT_Settings_footnotePr: // 92545;
403 case NS_ooxml::LN_CT_Settings_endnotePr: // 92546;
404 case NS_ooxml::LN_CT_Settings_compat: // 92547;
405 case NS_ooxml::LN_CT_Settings_themeFontLang: // 92552;
406 case NS_ooxml::LN_CT_Settings_shapeDefaults: // 92560;
407 case NS_ooxml::LN_CT_Settings_view:
408 //PropertySetValues - need to be resolved
410 resolveSprmProps(*this, rSprm);
412 break;
413 case NS_ooxml::LN_CT_Settings_stylePaneFormatFilter: // 92493;
414 break;
415 case NS_ooxml::LN_CT_Settings_defaultTabStop: // 92505;
416 m_pImpl->m_nDefaultTabStop = nIntValue;
417 break;
418 case NS_ooxml::LN_CT_Settings_linkStyles: // 92663;
419 m_pImpl->m_bLinkStyles = nIntValue;
420 break;
421 case NS_ooxml::LN_CT_Settings_evenAndOddHeaders:
422 m_pImpl->m_bEvenAndOddHeaders = nIntValue;
423 break;
424 case NS_ooxml::LN_CT_Settings_noPunctuationKerning: // 92526;
425 break;
426 case NS_ooxml::LN_CT_Settings_characterSpacingControl: // 92527;
427 m_pImpl->m_sCharacterSpacing = sStringValue; // doNotCompress, compressPunctuation, compressPunctuationAndJapaneseKana
428 break;
429 case NS_ooxml::LN_CT_Settings_doNotIncludeSubdocsInStats: // 92554; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics)
430 break;
431 case NS_ooxml::LN_CT_Settings_decimalSymbol: // 92562;
432 m_pImpl->m_sDecimalSymbol = sStringValue;
433 break;
434 case NS_ooxml::LN_CT_Settings_listSeparator: // 92563;
435 m_pImpl->m_sListSeparatorForFields = sStringValue;
436 break;
437 case NS_ooxml::LN_CT_Settings_rsids: // 92549; revision save Ids - probably not necessary
438 break;
439 case NS_ooxml::LN_CT_Settings_hyphenationZone: // 92508;
440 break;
441 case NS_ooxml::LN_CT_Compat_useFELayout: // 92422;
442 // useFELayout (Do Not Bypass East Asian/Complex Script Layout Code - support of old versions of Word - ignored)
443 break;
444 case NS_ooxml::LN_CT_Settings_trackRevisions:
446 m_pImpl->m_bRecordChanges = bool(rSprm.getValue( )->getInt( ) );
448 break;
449 case NS_ooxml::LN_CT_Settings_documentProtection:
450 resolveSprmProps(*this, rSprm);
451 break;
452 case NS_ooxml::LN_CT_Compat_usePrinterMetrics:
453 m_pImpl->m_bUsePrinterMetrics = nIntValue;
454 break;
455 case NS_ooxml::LN_CT_Settings_embedTrueTypeFonts:
456 m_pImpl->embedTrueTypeFonts = nIntValue != 0;
457 break;
458 case NS_ooxml::LN_CT_Settings_embedSystemFonts:
459 m_pImpl->embedSystemFonts = nIntValue != 0;
460 break;
461 case NS_ooxml::LN_CT_Compat_doNotUseHTMLParagraphAutoSpacing:
462 m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing = nIntValue;
463 break;
464 case NS_ooxml::LN_CT_Compat_splitPgBreakAndParaMark:
465 m_pImpl->m_bSplitPgBreakAndParaMark = nIntValue;
466 break;
467 case NS_ooxml::LN_CT_Settings_mirrorMargins:
468 m_pImpl->m_bMirrorMargin = nIntValue;
469 break;
470 case NS_ooxml::LN_CT_Compat_compatSetting:
472 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
473 if (pProperties.get())
475 pProperties->resolve(*this);
477 beans::PropertyValue aValue;
478 aValue.Name = "compatSetting";
479 aValue.Value <<= m_pImpl->m_pCurrentCompatSetting;
480 m_pImpl->m_aCompatSettings.push_back(aValue);
483 break;
484 case NS_ooxml::LN_CT_Compat_noColumnBalance:
485 m_pImpl->m_bNoColumnBalance = nIntValue;
486 break;
487 case NS_ooxml::LN_CT_Settings_autoHyphenation:
488 m_pImpl->m_bAutoHyphenation = nIntValue;
489 break;
490 case NS_ooxml::LN_CT_Settings_widowControl:
491 m_pImpl->m_bWidowControl = nIntValue;
492 break;
493 case NS_ooxml::LN_CT_Compat_doNotExpandShiftReturn:
494 m_pImpl->m_bDoNotExpandShiftReturn = true;
495 break;
496 case NS_ooxml::LN_CT_Settings_displayBackgroundShape:
497 m_pImpl->m_bDisplayBackgroundShape = nIntValue;
498 break;
499 default:
501 #ifdef DEBUG_WRITERFILTER
502 TagLogger::getInstance().element("unhandled");
503 #endif
508 void SettingsTable::lcl_entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t ref)
510 ref->resolve(*this);
513 //returns default TabStop in 1/100th mm
514 int SettingsTable::GetDefaultTabStop() const
516 return ConversionHelper::convertTwipToMM100( m_pImpl->m_nDefaultTabStop );
519 bool SettingsTable::GetLinkStyles() const
521 return m_pImpl->m_bLinkStyles;
524 sal_Int16 SettingsTable::GetZoomFactor() const
526 return m_pImpl->m_nZoomFactor;
529 sal_Int16 SettingsTable::GetZoomType() const { return m_pImpl->m_nZoomType; }
531 Id SettingsTable::GetView() const
533 return m_pImpl->m_nView;
536 bool SettingsTable::GetUsePrinterMetrics() const
538 return m_pImpl->m_bUsePrinterMetrics;
541 bool SettingsTable::GetEvenAndOddHeaders() const
543 return m_pImpl->m_bEvenAndOddHeaders;
546 bool SettingsTable::GetEmbedTrueTypeFonts() const
548 return m_pImpl->embedTrueTypeFonts;
551 bool SettingsTable::GetEmbedSystemFonts() const
553 return m_pImpl->embedSystemFonts;
556 bool SettingsTable::GetDoNotUseHTMLParagraphAutoSpacing() const
558 return m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing;
561 bool SettingsTable::GetNoColumnBalance() const
563 return m_pImpl->m_bNoColumnBalance;
566 bool SettingsTable::GetSplitPgBreakAndParaMark() const
568 return m_pImpl->m_bSplitPgBreakAndParaMark;
571 bool SettingsTable::GetMirrorMarginSettings() const
573 return m_pImpl->m_bMirrorMargin;
576 bool SettingsTable::GetDisplayBackgroundShape() const
578 return m_pImpl->m_bDisplayBackgroundShape;
581 bool SettingsTable::GetDoNotExpandShiftReturn() const
583 return m_pImpl->m_bDoNotExpandShiftReturn;
586 bool SettingsTable::GetProtectForm() const
588 return m_pImpl->m_bProtectForm;
590 uno::Sequence<beans::PropertyValue> const & SettingsTable::GetThemeFontLangProperties() const
592 return m_pImpl->m_pThemeFontLangProps;
595 uno::Sequence<beans::PropertyValue> SettingsTable::GetCompatSettings() const
597 return comphelper::containerToSequence(m_pImpl->m_aCompatSettings);
600 css::uno::Sequence<css::beans::PropertyValue> SettingsTable::GetDocumentProtectionSettings() const
602 return m_pImpl->m_DocumentProtection.toSequence();
605 static bool lcl_isDefault(const uno::Reference<beans::XPropertyState>& xPropertyState, const OUString& rPropertyName)
607 return xPropertyState->getPropertyState(rPropertyName) == beans::PropertyState_DEFAULT_VALUE;
610 void SettingsTable::ApplyProperties(uno::Reference<text::XTextDocument> const& xDoc)
612 uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
614 // Record changes value
615 if (xDocProps.is())
616 xDocProps->setPropertyValue("RecordChanges", uno::makeAny( m_pImpl->m_bRecordChanges ) );
618 // Auto hyphenation: turns on hyphenation by default, <w:suppressAutoHyphens/> may still disable it at a paragraph level.
619 // Situation is similar for RTF_WIDOWCTRL, which turns on widow / orphan control by default.
620 if (m_pImpl->m_bAutoHyphenation || m_pImpl->m_bWidowControl)
622 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xDoc, uno::UNO_QUERY);
623 if (!xStyleFamiliesSupplier.is())
624 return;
626 uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
627 uno::Reference<container::XNameContainer> xParagraphStyles = xStyleFamilies->getByName("ParagraphStyles").get< uno::Reference<container::XNameContainer> >();
628 uno::Reference<style::XStyle> xDefault = xParagraphStyles->getByName("Standard").get< uno::Reference<style::XStyle> >();
629 uno::Reference<beans::XPropertyState> xPropertyState(xDefault, uno::UNO_QUERY);
630 if (m_pImpl->m_bAutoHyphenation && lcl_isDefault(xPropertyState, "ParaIsHyphenation"))
632 uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY);
633 xPropertySet->setPropertyValue("ParaIsHyphenation", uno::makeAny(true));
635 if (m_pImpl->m_bWidowControl && lcl_isDefault(xPropertyState, "ParaWidows") && lcl_isDefault(xPropertyState, "ParaOrphans"))
637 uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY);
638 uno::Any aAny = uno::makeAny(static_cast<sal_Int8>(2));
639 xPropertySet->setPropertyValue("ParaWidows", aAny);
640 xPropertySet->setPropertyValue("ParaOrphans", aAny);
645 sal_Int32 SettingsTable::GetWordCompatibilityMode() const
647 for (const auto& rProp : m_pImpl->m_aCompatSettings)
649 if (rProp.Name == "compatSetting")
651 css::uno::Sequence<css::beans::PropertyValue> aCurrentCompatSettings;
652 rProp.Value >>= aCurrentCompatSettings;
654 OUString sName;
655 OUString sUri;
656 OUString sVal;
658 aCurrentCompatSettings[0].Value >>= sName;
659 aCurrentCompatSettings[1].Value >>= sUri;
660 aCurrentCompatSettings[2].Value >>= sVal;
662 if (sName == "compatibilityMode" && sUri == "http://schemas.microsoft.com/office/word")
664 return sVal.toInt32();
669 return -1; // Word compatibility mode not found
672 }//namespace dmapper
673 } //namespace writerfilter
675 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */