LibreOffice Module writerfilter (master) 1
SettingsTable.cxx
Go to the documentation of this file.
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 "SettingsTable.hxx"
22#include "TagLogger.hxx"
23#include "WriteProtection.hxx"
24
25#include <vector>
26
27#include <rtl/ustring.hxx>
28#include <sfx2/zoomitem.hxx>
29#include <com/sun/star/text/XDependentTextField.hpp>
30#include <com/sun/star/text/XTextFieldsSupplier.hpp>
31#include <com/sun/star/lang/XMultiServiceFactory.hpp>
32#include <com/sun/star/beans/XPropertySet.hpp>
33#include <com/sun/star/beans/XPropertyState.hpp>
34#include <com/sun/star/container/XNameContainer.hpp>
35#include <com/sun/star/style/XStyle.hpp>
36#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
40#include "ConversionHelper.hxx"
41#include "DomainMapper.hxx"
42#include "util.hxx"
43
44using namespace com::sun::star;
45
46namespace writerfilter {
47namespace
48{
50sal_Int16 lcl_GetZoomType(Id nType)
51{
52 switch (nType)
53 {
54 case NS_ooxml::LN_Value_doc_ST_Zoom_fullPage:
55 return sal_Int16(SvxZoomType::WHOLEPAGE);
56 case NS_ooxml::LN_Value_doc_ST_Zoom_bestFit:
57 return sal_Int16(SvxZoomType::PAGEWIDTH);
58 case NS_ooxml::LN_Value_doc_ST_Zoom_textFit:
59 return sal_Int16(SvxZoomType::OPTIMAL);
60 }
61
62 return sal_Int16(SvxZoomType::PERCENT);
63}
64}
65
66namespace dmapper
67{
68
70{
72
78 sal_Int16 m_nZoomFactor;
79 sal_Int16 m_nZoomType = 0;
97 bool m_bNoLeading = false;
100 std::vector<std::pair<OUString, OUString>> m_aDocVars;
101
103
104 std::vector<beans::PropertyValue> m_aCompatSettings;
107
108 std::shared_ptr<DocumentProtection> m_pDocumentProtection;
109 std::shared_ptr<WriteProtection> m_pWriteProtection;
110 bool m_bGutterAtTop = false;
112
114 m_nDefaultTabStop( 720 ) //default is 1/2 in
115 , m_bRecordChanges(false)
119 , m_bLinkStyles(false)
120 , m_nZoomFactor(0)
122 , m_nView(0)
123 , m_bEvenAndOddHeaders(false)
124 , m_bUsePrinterMetrics(false)
125 , embedTrueTypeFonts(false)
126 , embedSystemFonts(false)
128 , m_bNoColumnBalance(false)
129 , m_bAutoHyphenation(false)
130 , m_bNoHyphenateCaps(false)
132 , m_bWidowControl(false)
135 , m_bMirrorMargin(false)
138 , m_sDecimalSymbol(".")
139 , m_sListSeparator(",")
142 {}
143};
144
146: LoggedProperties("SettingsTable")
147, LoggedTable("SettingsTable")
149{
150 if (rDomainMapper.IsRTFImport())
151 {
152 // HTML paragraph auto-spacing is opt-in for RTF, opt-out for OOXML.
153 m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing = true;
154 // Longer space sequence is opt-in for RTF, and not in OOXML.
155 m_pImpl->m_bLongerSpaceSequence = true;
156 m_pImpl->m_bDoNotBreakWrappedTables = true;
157 }
158 m_pImpl->m_pDocumentProtection = std::make_shared<DocumentProtection>();
159 m_pImpl->m_pWriteProtection = std::make_shared<WriteProtection>();
160}
161
163{
164}
165
167{
168 int nIntValue = val.getInt();
169 OUString sStringValue = val.getString();
170
171 switch(nName)
172 {
173 case NS_ooxml::LN_CT_Zoom_percent:
174 m_pImpl->m_nZoomFactor = nIntValue;
175 break;
176 case NS_ooxml::LN_CT_Zoom_val:
177 m_pImpl->m_nZoomType = lcl_GetZoomType(nIntValue);
178 break;
179 case NS_ooxml::LN_CT_Language_val:
180 m_pImpl->m_pThemeFontLangProps.getArray()[0]
181 = comphelper::makePropertyValue("val", sStringValue);
182 break;
183 case NS_ooxml::LN_CT_Language_eastAsia:
184 m_pImpl->m_pThemeFontLangProps.getArray()[1]
185 = comphelper::makePropertyValue("eastAsia", sStringValue);
186 break;
187 case NS_ooxml::LN_CT_Language_bidi:
188 m_pImpl->m_pThemeFontLangProps.getArray()[2]
189 = comphelper::makePropertyValue("bidi", sStringValue);
190 break;
191 case NS_ooxml::LN_CT_View_val:
192 m_pImpl->m_nView = nIntValue;
193 break;
194 case NS_ooxml::LN_CT_DocVar_name:
195 m_pImpl->m_aDocVars.back().first = sStringValue;
196 break;
197 case NS_ooxml::LN_CT_DocVar_val:
198 m_pImpl->m_aDocVars.back().second = sStringValue;
199 break;
200 case NS_ooxml::LN_CT_CompatSetting_name:
201 m_pImpl->m_pCurrentCompatSetting.getArray()[0]
202 = comphelper::makePropertyValue("name", sStringValue);
203 break;
204 case NS_ooxml::LN_CT_CompatSetting_uri:
205 m_pImpl->m_pCurrentCompatSetting.getArray()[1]
206 = comphelper::makePropertyValue("uri", sStringValue);
207 break;
208 case NS_ooxml::LN_CT_CompatSetting_val:
209 m_pImpl->m_pCurrentCompatSetting.getArray()[2]
210 = comphelper::makePropertyValue("val", sStringValue);
211 break;
212 case NS_ooxml::LN_CT_TrackChangesView_insDel:
213 m_pImpl->m_bShowInsDelChanges = (nIntValue != 0);
214 break;
215 case NS_ooxml::LN_CT_TrackChangesView_formatting:
216 m_pImpl->m_bShowFormattingChanges = (nIntValue != 0);
217 break;
218 case NS_ooxml::LN_CT_TrackChangesView_markup:
219 m_pImpl->m_bShowMarkupChanges = (nIntValue != 0);
220 break;
221 default:
222 {
223#ifdef DBG_UTIL
224 TagLogger::getInstance().element("unhandled");
225#endif
226 }
227 }
228}
229
231{
232 sal_uInt32 nSprmId = rSprm.getId();
233
234 Value::Pointer_t pValue = rSprm.getValue();
235 sal_Int32 nIntValue = pValue->getInt();
236
237 switch(nSprmId)
238 {
239 case NS_ooxml::LN_CT_Settings_zoom: // 92469;
240 case NS_ooxml::LN_CT_Settings_proofState: // 92489;
241 case NS_ooxml::LN_CT_Settings_attachedTemplate: // 92491;
242 case NS_ooxml::LN_CT_Settings_hdrShapeDefaults: // 92544;
243 case NS_ooxml::LN_CT_Settings_footnotePr: // 92545;
244 case NS_ooxml::LN_CT_Settings_endnotePr: // 92546;
245 case NS_ooxml::LN_CT_Settings_compat: // 92547;
246 case NS_ooxml::LN_CT_Settings_themeFontLang: // 92552;
247 case NS_ooxml::LN_CT_Settings_shapeDefaults: // 92560;
248 case NS_ooxml::LN_CT_Settings_view:
249 //PropertySetValues - need to be resolved
250 {
251 resolveSprmProps(*this, rSprm);
252 }
253 break;
254 case NS_ooxml::LN_CT_Settings_stylePaneFormatFilter: // 92493;
255 break;
256 case NS_ooxml::LN_CT_Settings_defaultTabStop: // 92505;
257 m_pImpl->m_nDefaultTabStop = nIntValue;
258 break;
259 case NS_ooxml::LN_CT_Settings_linkStyles: // 92663;
260 m_pImpl->m_bLinkStyles = nIntValue;
261 break;
262 case NS_ooxml::LN_CT_Settings_evenAndOddHeaders:
263 m_pImpl->m_bEvenAndOddHeaders = nIntValue;
264 break;
265 case NS_ooxml::LN_CT_Settings_noPunctuationKerning: // 92526;
266 break;
267 case NS_ooxml::LN_CT_Settings_characterSpacingControl: // 92527;
268 // doNotCompress, compressPunctuation, compressPunctuationAndJapaneseKana
269 break;
270 case NS_ooxml::LN_CT_Settings_doNotIncludeSubdocsInStats: // 92554; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics)
271 break;
272 case NS_ooxml::LN_CT_Settings_decimalSymbol: // 92562;
273 m_pImpl->m_sDecimalSymbol = pValue->getString();
274 break;
275 case NS_ooxml::LN_CT_Settings_listSeparator: // 92563;
276 m_pImpl->m_sListSeparator = pValue->getString();
277 break;
278 case NS_ooxml::LN_CT_Settings_rsids: // 92549; revision save Ids - probably not necessary
279 break;
280 case NS_ooxml::LN_CT_Settings_hyphenationZone: // 92508;
281 m_pImpl->m_nHyphenationZone = nIntValue;
282 break;
283 case NS_ooxml::LN_CT_Compat_useFELayout: // 92422;
284 // useFELayout (Do Not Bypass East Asian/Complex Script Layout Code - support of old versions of Word - ignored)
285 break;
286 case NS_ooxml::LN_CT_Settings_trackRevisions:
287 {
288 m_pImpl->m_bRecordChanges = bool(rSprm.getValue( )->getInt( ) );
289 }
290 break;
291 case NS_ooxml::LN_CT_Settings_revisionView:
292 resolveSprmProps(*this, rSprm);
293 break;
294 case NS_ooxml::LN_CT_Settings_documentProtection:
295 resolveSprmProps(*(m_pImpl->m_pDocumentProtection), rSprm);
296 break;
297 case NS_ooxml::LN_CT_Settings_writeProtection:
298 resolveSprmProps(*(m_pImpl->m_pWriteProtection), rSprm);
299 break;
300 case NS_ooxml::LN_CT_Compat_usePrinterMetrics:
301 m_pImpl->m_bUsePrinterMetrics = nIntValue;
302 break;
303 case NS_ooxml::LN_CT_Settings_embedTrueTypeFonts:
304 m_pImpl->embedTrueTypeFonts = nIntValue != 0;
305 break;
306 case NS_ooxml::LN_CT_Settings_embedSystemFonts:
307 m_pImpl->embedSystemFonts = nIntValue != 0;
308 break;
309 case NS_ooxml::LN_CT_Compat_doNotUseHTMLParagraphAutoSpacing:
310 m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing = nIntValue;
311 break;
312 case NS_ooxml::LN_CT_Compat_splitPgBreakAndParaMark:
313 m_pImpl->m_bSplitPgBreakAndParaMark = nIntValue;
314 break;
315 case NS_ooxml::LN_CT_Settings_mirrorMargins:
316 m_pImpl->m_bMirrorMargin = nIntValue;
317 break;
318 case NS_ooxml::LN_CT_Settings_mailMerge:
319 {
321 if (pProperties)
322 pProperties->resolve(*this);
323 }
324 break;
325 case NS_ooxml::LN_CT_MailMerge_query:
326 {
327 // try to get the "database.table" name from the query saved previously
328 OUString sVal = pValue->getString();
329 if ( sVal.endsWith("$") && sVal.indexOf(".dbo.") > 0 )
330 {
331 sal_Int32 nSpace = sVal.lastIndexOf(' ');
332 sal_Int32 nDbo = sVal.lastIndexOf(".dbo.");
333 if ( nSpace > 0 && nSpace < nDbo - 1 )
334 {
335 m_pImpl->m_sCurrentDatabaseDataSource = OUString::Concat(sVal.subView(nSpace + 1, nDbo - nSpace - 1)) +
336 sVal.subView(nDbo + 4, sVal.getLength() - nDbo - 5);
337 }
338 }
339 }
340 break;
341 case NS_ooxml::LN_CT_Compat_compatSetting:
342 {
344 if (pProperties)
345 {
346 pProperties->resolve(*this);
347
348 beans::PropertyValue aValue;
349 aValue.Name = "compatSetting";
350 aValue.Value <<= m_pImpl->m_pCurrentCompatSetting;
351 m_pImpl->m_aCompatSettings.push_back(aValue);
352 }
353 }
354 break;
355 case NS_ooxml::LN_CT_Settings_docVars:
356 {
358 if (pProperties)
359 {
360 pProperties->resolve(*this);
361 }
362 }
363 break;
364 case NS_ooxml::LN_CT_DocVar:
365 {
367 if (pProperties)
368 {
369 m_pImpl->m_aDocVars.push_back(std::make_pair(OUString(), OUString()));
370 pProperties->resolve(*this);
371 }
372 }
373 break;
374 case NS_ooxml::LN_CT_Compat_noColumnBalance:
375 m_pImpl->m_bNoColumnBalance = nIntValue;
376 break;
377 case NS_ooxml::LN_CT_Settings_autoHyphenation:
378 m_pImpl->m_bAutoHyphenation = nIntValue;
379 break;
380 case NS_ooxml::LN_CT_Settings_doNotHyphenateCaps:
381 m_pImpl->m_bNoHyphenateCaps = nIntValue;
382 break;
383 case NS_ooxml::LN_CT_Settings_widowControl:
384 m_pImpl->m_bWidowControl = nIntValue;
385 break;
386 case NS_ooxml::LN_CT_Settings_longerSpaceSequence:
387 m_pImpl->m_bLongerSpaceSequence = nIntValue;
388 break;
389 case NS_ooxml::LN_CT_Compat_doNotExpandShiftReturn:
390 m_pImpl->m_bDoNotExpandShiftReturn = true;
391 break;
392 case NS_ooxml::LN_CT_Settings_displayBackgroundShape:
393 m_pImpl->m_bDisplayBackgroundShape = nIntValue;
394 break;
395 case NS_ooxml::LN_CT_Compat_noLeading:
396 m_pImpl->m_bNoLeading = nIntValue != 0;
397 break;
398 case NS_ooxml::LN_CT_Settings_gutterAtTop:
399 m_pImpl->m_bGutterAtTop = nIntValue != 0;
400 break;
401 case NS_ooxml::LN_CT_Compat_doNotBreakWrappedTables:
402 m_pImpl->m_bDoNotBreakWrappedTables = nIntValue != 0;
403 break;
404 default:
405 {
406#ifdef DBG_UTIL
407 TagLogger::getInstance().element("unhandled");
408#endif
409 }
410 }
411}
412
414{
415 ref->resolve(*this);
416}
417
418//returns default TabStop in 1/100th mm
420{
421 return ConversionHelper::convertTwipToMM100( m_pImpl->m_nDefaultTabStop );
422}
423
425{
426 return m_pImpl->m_bLinkStyles;
427}
428
430{
431 return m_pImpl->m_nZoomFactor;
432}
433
434sal_Int16 SettingsTable::GetZoomType() const { return m_pImpl->m_nZoomType; }
435
437{
438 return m_pImpl->m_nView;
439}
440
442{
443 return m_pImpl->m_bUsePrinterMetrics;
444}
445
447{
448 return m_pImpl->m_bEvenAndOddHeaders;
449}
450
452{
453 return m_pImpl->embedTrueTypeFonts;
454}
455
457{
458 return m_pImpl->embedSystemFonts;
459}
460
462{
463 return m_pImpl->m_bDoNotUseHTMLParagraphAutoSpacing;
464}
465
467{
468 return m_pImpl->m_bNoColumnBalance;
469}
470
472{
473 return m_pImpl->m_bSplitPgBreakAndParaMark;
474}
475
477{
478 return m_pImpl->m_bMirrorMargin;
479}
480
482{
483 return m_pImpl->m_bDisplayBackgroundShape;
484}
485
487{
488 return m_pImpl->m_bDoNotExpandShiftReturn;
489}
490
492{
493 return m_pImpl->m_pDocumentProtection->getProtectForm()
494 && m_pImpl->m_pDocumentProtection->getEnforcement();
495}
496
498{
499 return m_pImpl->m_pWriteProtection->getRecommended()
500 || (m_pImpl->m_pDocumentProtection->getReadOnly()
501 && m_pImpl->m_pDocumentProtection->getEnforcement());
502}
503
505{
506 return m_pImpl->m_bNoHyphenateCaps;
507}
508
510{
511 return m_pImpl->m_nHyphenationZone;
512}
513
514const OUString & SettingsTable::GetDecimalSymbol() const
515{
516 return m_pImpl->m_sDecimalSymbol;
517}
518
519const OUString & SettingsTable::GetListSeparator() const
520{
521 return m_pImpl->m_sListSeparator;
522}
523
524
526{
527 return m_pImpl->m_pThemeFontLangProps;
528}
529
531{
532 if ( GetWordCompatibilityMode() == -1 )
533 {
534 // the default value for an undefined compatibilityMode is 12 (Word 2007)
536 { "name", uno::Any(OUString("compatibilityMode")) },
537 { "uri", uno::Any(OUString("http://schemas.microsoft.com/office/word")) },
538 { "val", uno::Any(OUString("12")) } //12: Use word processing features specified in ECMA-376. This is the default.
539 }));
540
541 beans::PropertyValue aValue;
542 aValue.Name = "compatSetting";
543 aValue.Value <<= aCompatSetting;
544
545 m_pImpl->m_aCompatSettings.push_back(aValue);
546 }
547
548 return comphelper::containerToSequence(m_pImpl->m_aCompatSettings);
549}
550
552{
553 return m_pImpl->m_pDocumentProtection->toSequence();
554}
555
557{
558 return m_pImpl->m_pWriteProtection->toSequence();
559}
560
562{
563 return m_pImpl->m_sCurrentDatabaseDataSource;
564}
565
566static bool lcl_isDefault(const uno::Reference<beans::XPropertyState>& xPropertyState, const OUString& rPropertyName)
567{
568 return xPropertyState->getPropertyState(rPropertyName) == beans::PropertyState_DEFAULT_VALUE;
569}
570
572{
573 uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
574 uno::Reference<lang::XMultiServiceFactory> xTextFactory(xDoc, uno::UNO_QUERY_THROW);
575 uno::Reference<beans::XPropertySet> xDocumentSettings(xTextFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY_THROW);
576
577 xDocumentSettings->setPropertyValue("TableRowKeep", uno::Any(true));
578
579 if (GetWordCompatibilityMode() <= 14)
580 {
581 xDocumentSettings->setPropertyValue("MsWordCompMinLineHeightByFly", uno::Any(true));
582 xDocumentSettings->setPropertyValue("TabOverMargin", uno::Any(true));
583 }
584
585 // Show changes value
586 if (xDocProps.is())
587 {
588 bool bHideChanges = !m_pImpl->m_bShowInsDelChanges || !m_pImpl->m_bShowMarkupChanges;
589 xDocProps->setPropertyValue("ShowChanges", uno::Any( !bHideChanges || m_pImpl->m_bShowFormattingChanges ) );
590 }
591
592 // Record changes value
593 if (xDocProps.is())
594 {
595 xDocProps->setPropertyValue("RecordChanges", uno::Any( m_pImpl->m_bRecordChanges ) );
596 // Password protected Record changes
597 if (m_pImpl->m_bRecordChanges && m_pImpl->m_pDocumentProtection->getRedlineProtection()
598 && m_pImpl->m_pDocumentProtection->getEnforcement())
599 {
600 // use dummy protection key to forbid disabling of Record changes without a notice
601 // (extending the recent GrabBag support) TODO support password verification...
602 css::uno::Sequence<sal_Int8> aDummyKey { 1 };
603 xDocProps->setPropertyValue("RedlineProtectionKey", uno::Any( aDummyKey ));
604 }
605 }
606
607 // Create or overwrite DocVars based on found in settings
608 if (m_pImpl->m_aDocVars.size())
609 {
610 uno::Reference< text::XTextFieldsSupplier > xFieldsSupplier(xDoc, uno::UNO_QUERY_THROW);
611 uno::Reference< container::XNameAccess > xFieldMasterAccess = xFieldsSupplier->getTextFieldMasters();
612 for (const auto& docVar : m_pImpl->m_aDocVars)
613 {
615 OUString sFieldMasterService("com.sun.star.text.FieldMaster.User." + docVar.first);
616
617 // Find or create Field Master
618 if (xFieldMasterAccess->hasByName(sFieldMasterService))
619 {
620 xMaster.set(xFieldMasterAccess->getByName(sFieldMasterService), uno::UNO_QUERY_THROW);
621 }
622 else
623 {
624 xMaster.set(xTextFactory->createInstance("com.sun.star.text.FieldMaster.User"), uno::UNO_QUERY_THROW);
625 xMaster->setPropertyValue(getPropertyName(PROP_NAME), uno::Any(docVar.first));
627 xTextFactory->createInstance("com.sun.star.text.TextField.User"),
628 uno::UNO_QUERY);
629 xField->attachTextFieldMaster(xMaster);
630 }
631
632 xMaster->setPropertyValue(getPropertyName(PROP_CONTENT), uno::Any(docVar.second));
633 }
634 }
635
636 if (m_pImpl->m_bDoNotBreakWrappedTables)
637 {
638 // Map <w:doNotBreakWrappedTables> to the DoNotBreakWrappedTables compat flag.
639 xDocumentSettings->setPropertyValue("DoNotBreakWrappedTables", uno::Any(true));
640 }
641
642 // Auto hyphenation: turns on hyphenation by default, <w:suppressAutoHyphens/> may still disable it at a paragraph level.
643 // Situation is similar for RTF_WIDOWCTRL, which turns on widow / orphan control by default.
644 if (!(m_pImpl->m_bAutoHyphenation || m_pImpl->m_bNoHyphenateCaps || m_pImpl->m_bWidowControl))
645 return;
646
647 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xDoc, uno::UNO_QUERY);
648 if (!xStyleFamiliesSupplier.is())
649 return;
650
651 uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
652 uno::Reference<container::XNameContainer> xParagraphStyles = xStyleFamilies->getByName("ParagraphStyles").get< uno::Reference<container::XNameContainer> >();
653 uno::Reference<style::XStyle> xDefault = xParagraphStyles->getByName("Standard").get< uno::Reference<style::XStyle> >();
654 uno::Reference<beans::XPropertyState> xPropertyState(xDefault, uno::UNO_QUERY);
655 if (m_pImpl->m_bAutoHyphenation && lcl_isDefault(xPropertyState, "ParaIsHyphenation"))
656 {
657 uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY);
658 xPropertySet->setPropertyValue("ParaIsHyphenation", uno::Any(true));
659 }
660 if (m_pImpl->m_bNoHyphenateCaps)
661 {
662 uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY);
663 xPropertySet->setPropertyValue("ParaHyphenationNoCaps", uno::Any(true));
664 }
665 if (m_pImpl->m_nHyphenationZone)
666 {
667 uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY);
668 xPropertySet->setPropertyValue("ParaHyphenationZone", uno::Any(GetHyphenationZone()));
669 }
670 if (m_pImpl->m_bWidowControl && lcl_isDefault(xPropertyState, "ParaWidows") && lcl_isDefault(xPropertyState, "ParaOrphans"))
671 {
672 uno::Reference<beans::XPropertySet> xPropertySet(xDefault, uno::UNO_QUERY);
673 uno::Any aAny(static_cast<sal_Int8>(2));
674 xPropertySet->setPropertyValue("ParaWidows", aAny);
675 xPropertySet->setPropertyValue("ParaOrphans", aAny);
676 }
677}
678
679bool SettingsTable::GetCompatSettingValue( std::u16string_view sCompatName ) const
680{
681 bool bRet = false;
682 for (const auto& rProp : m_pImpl->m_aCompatSettings)
683 {
684 if (rProp.Name == "compatSetting") //always true
685 {
686 css::uno::Sequence<css::beans::PropertyValue> aCurrentCompatSettings;
687 rProp.Value >>= aCurrentCompatSettings;
688
689 OUString sName;
690 aCurrentCompatSettings[0].Value >>= sName;
691 if ( sName != sCompatName )
692 continue;
693
694 OUString sUri;
695 aCurrentCompatSettings[1].Value >>= sUri;
696 if ( sUri != "http://schemas.microsoft.com/office/word" )
697 continue;
698
699 OUString sVal;
700 aCurrentCompatSettings[2].Value >>= sVal;
701 // if repeated, what happens? Last one wins
702 bRet = sVal.toBoolean();
703 }
704 }
705
706 return bRet;
707}
708
709//Keep this function in-sync with the one in sw/.../docxattributeoutput.cxx
711{
712 if ( m_pImpl->m_nWordCompatibilityMode != -1 )
713 return m_pImpl->m_nWordCompatibilityMode;
714
715 for (const auto& rProp : m_pImpl->m_aCompatSettings)
716 {
717 if (rProp.Name == "compatSetting") //always true
718 {
719 css::uno::Sequence<css::beans::PropertyValue> aCurrentCompatSettings;
720 rProp.Value >>= aCurrentCompatSettings;
721
722 OUString sName;
723 aCurrentCompatSettings[0].Value >>= sName;
724 if ( sName != "compatibilityMode" )
725 continue;
726
727 OUString sUri;
728 aCurrentCompatSettings[1].Value >>= sUri;
729 if ( sUri != "http://schemas.microsoft.com/office/word" )
730 continue;
731
732 OUString sVal;
733 aCurrentCompatSettings[2].Value >>= sVal;
734 const sal_Int32 nValidMode = sVal.toInt32();
735 // if repeated, highest mode wins in MS Word. 11 is the first valid mode.
736 if ( nValidMode > 10 && nValidMode > m_pImpl->m_nWordCompatibilityMode )
737 m_pImpl->m_nWordCompatibilityMode = nValidMode;
738 }
739 }
740
741 return m_pImpl->m_nWordCompatibilityMode;
742}
743
745{
746 return m_pImpl->m_bLongerSpaceSequence;
747}
748
750{
751 return m_pImpl->m_bNoLeading;
752}
753
754bool SettingsTable::GetGutterAtTop() const { return m_pImpl->m_bGutterAtTop; }
755
756}//namespace dmapper
757} //namespace writerfilter
758
759/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
An SPRM: Section, Paragraph and Run Modifier.
virtual sal_uInt32 getId() const =0
Returns id of the SPRM.
virtual writerfilter::Reference< Properties >::Pointer_t getProps()=0
Returns reference to properties contained in the SPRM.
virtual Value::Pointer_t getValue()=0
Returns value of the SPRM.
static TagLogger & getInstance()
Definition: TagLogger.cxx:95
void element(const std::string &name)
Definition: TagLogger.cxx:102
virtual int getInt() const =0
Returns integer representation of the value.
virtual OUString getString() const =0
Returns string representation of the value.
css::uno::Sequence< css::beans::PropertyValue > GetWriteProtectionSettings() const
SettingsTable(const DomainMapper &rDomainMapper)
css::uno::Sequence< css::beans::PropertyValue > GetCompatSettings() const
const OUString & GetListSeparator() const
const OUString & GetCurrentDatabaseDataSource() const
sal_Int16 GetZoomType() const
Gets the type of the zoom.
void ApplyProperties(css::uno::Reference< css::text::XTextDocument > const &xDoc)
std::unique_ptr< SettingsTable_Impl > m_pImpl
bool GetCompatSettingValue(std::u16string_view sCompatName) const
css::uno::Sequence< css::beans::PropertyValue > GetDocumentProtectionSettings() const
css::uno::Sequence< css::beans::PropertyValue > const & GetThemeFontLangProperties() const
sal_Int16 GetZoomFactor() const
What's the zoom factor set in percents?
bool GetLinkStyles() const
Automatically update styles from document template?
const OUString & GetDecimalSymbol() const
virtual void lcl_sprm(Sprm &sprm) override
virtual void lcl_entry(writerfilter::Reference< Properties >::Pointer_t ref) override
virtual void lcl_attribute(Id Name, Value &val) override
Id GetView() const
What's the requested view? E.g. "web".
OUString sName
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
OUString getPropertyName(PropertyIds eId)
static bool lcl_isDefault(const uno::Reference< beans::XPropertyState > &xPropertyState, const OUString &rPropertyName)
void resolveSprmProps(Properties &rHandler, Sprm &rSprm)
Definition: util.cxx:62
sal_uInt32 Id
uno::Sequence< beans::PropertyValue > m_pCurrentCompatSetting
std::vector< beans::PropertyValue > m_aCompatSettings
uno::Sequence< beans::PropertyValue > m_pThemeFontLangProps
std::shared_ptr< WriteProtection > m_pWriteProtection
std::shared_ptr< DocumentProtection > m_pDocumentProtection
std::vector< std::pair< OUString, OUString > > m_aDocVars
signed char sal_Int8