Bug Summary

File:home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx
Warning:line 783, column 25
Use of memory after it is freed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name DomainMapper.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -isystem /usr/include/libxml2 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D SYSTEM_LIBXML -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/common -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/oox/generated -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/writerfilter/source -I /home/maarten/src/libreoffice/core/writerfilter/inc -I /home/maarten/src/libreoffice/core/writerfilter/source -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx

/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx

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#include "BorderHandler.hxx"
20#include "PageBordersHandler.hxx"
21
22#include "util.hxx"
23#include "SdtHelper.hxx"
24#include "TagLogger.hxx"
25#include "TDefTableHandler.hxx"
26#include "DomainMapper_Impl.hxx"
27#include "ConversionHelper.hxx"
28#include "ModelEventListener.hxx"
29#include "MeasureHandler.hxx"
30#include <i18nlangtag/languagetag.hxx>
31#include <i18nutil/paper.hxx>
32#include <ooxml/resourceids.hxx>
33#include <oox/token/tokens.hxx>
34#include <oox/drawingml/drawingmltypes.hxx>
35#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
36#include <com/sun/star/document/XOOXMLDocumentPropertiesImporter.hpp>
37#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
38#include <com/sun/star/table/BorderLineStyle.hpp>
39#include <com/sun/star/table/ShadowFormat.hpp>
40#include <com/sun/star/text/HoriOrientation.hpp>
41#include <com/sun/star/text/RelOrientation.hpp>
42#include <com/sun/star/text/VertOrientation.hpp>
43#include <com/sun/star/text/WrapTextMode.hpp>
44#include <com/sun/star/text/SizeType.hpp>
45#include <com/sun/star/text/XEndnotesSupplier.hpp>
46#include <com/sun/star/text/XFootnotesSupplier.hpp>
47#include <com/sun/star/text/XLineNumberingProperties.hpp>
48#include <com/sun/star/awt/FontRelief.hpp>
49#include <com/sun/star/awt/FontWeight.hpp>
50#include <com/sun/star/awt/FontUnderline.hpp>
51#include <com/sun/star/awt/FontStrikeout.hpp>
52#include <com/sun/star/awt/FontSlant.hpp>
53#include <com/sun/star/document/XEventBroadcaster.hpp>
54#include <com/sun/star/style/ParagraphAdjust.hpp>
55#include <com/sun/star/style/BreakType.hpp>
56#include <com/sun/star/style/CaseMap.hpp>
57#include <com/sun/star/style/LineSpacing.hpp>
58#include <com/sun/star/style/LineSpacingMode.hpp>
59#include <com/sun/star/text/FootnoteNumbering.hpp>
60#include <com/sun/star/text/TextGridMode.hpp>
61#include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
62#include <com/sun/star/text/XTextFieldsSupplier.hpp>
63#include <com/sun/star/text/WritingMode.hpp>
64#include <com/sun/star/text/WritingMode2.hpp>
65#include <com/sun/star/text/XFootnote.hpp>
66#include <com/sun/star/text/XTextColumns.hpp>
67#include <com/sun/star/text/RubyPosition.hpp>
68#include <com/sun/star/uno/XComponentContext.hpp>
69#include <com/sun/star/text/FontEmphasis.hpp>
70#include <com/sun/star/awt/CharSet.hpp>
71#include <com/sun/star/lang/XMultiServiceFactory.hpp>
72#include <comphelper/types.hxx>
73#include <comphelper/storagehelper.hxx>
74#include <comphelper/sequence.hxx>
75#include <editeng/escapementitem.hxx>
76#include <filter/msfilter/util.hxx>
77#include <sfx2/DocumentMetadataAccess.hxx>
78#include <unotools/mediadescriptor.hxx>
79
80#include "TextEffectsHandler.hxx"
81#include "CellColorHandler.hxx"
82#include "SectionColumnHandler.hxx"
83#include "GraphicHelpers.hxx"
84#include <dmapper/GraphicZOrderHelper.hxx>
85#include <tools/diagnose_ex.h>
86#include <sal/log.hxx>
87
88using namespace ::com::sun::star;
89using namespace oox;
90
91namespace writerfilter::dmapper{
92
93struct
94{
95 sal_Int32 h;
96 bool orient;
97 sal_Int32 w;
98} CT_PageSz;
99
100
101DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xContext,
102 uno::Reference<io::XInputStream> const& xInputStream,
103 uno::Reference<lang::XComponent> const& xModel,
104 bool bRepairStorage,
105 SourceDocumentType eDocumentType,
106 utl::MediaDescriptor const & rMediaDesc) :
107 LoggedProperties("DomainMapper"),
108 LoggedTable("DomainMapper"),
109 LoggedStream("DomainMapper"),
110 m_pImpl(new DomainMapper_Impl(*this, xContext, xModel, eDocumentType, rMediaDesc)),
111 mbIsSplitPara(false)
112 ,mbHasControls(false)
113{
114 // #i24363# tab stops relative to indent
115 m_pImpl->SetDocumentSettingsProperty(
116 getPropertyName( PROP_TABS_RELATIVE_TO_INDENT ),
117 uno::makeAny( false ) );
118 m_pImpl->SetDocumentSettingsProperty(
119 getPropertyName( PROP_SURROUND_TEXT_WRAP_SMALL ),
120 uno::makeAny( true ) );
121 m_pImpl->SetDocumentSettingsProperty(
122 getPropertyName( PROP_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING ),
123 uno::makeAny( true ) );
124
125 // Don't load the default style definitions to avoid weird mix
126 m_pImpl->SetDocumentSettingsProperty("StylesNoDefault", uno::makeAny(true));
127 m_pImpl->SetDocumentSettingsProperty("MsWordCompTrailingBlanks", uno::makeAny(true));
128 m_pImpl->SetDocumentSettingsProperty("HeaderSpacingBelowLastPara",
129 uno::makeAny(true));
130 m_pImpl->SetDocumentSettingsProperty("FrameAutowidthWithMorePara", uno::makeAny(true));
131
132 m_pImpl->SetDocumentSettingsProperty("TabAtLeftIndentForParagraphsInList", uno::makeAny(true));
133
134 // Initialize RDF metadata, to be able to add statements during the import.
135 try
136 {
137 uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(xModel, uno::UNO_QUERY_THROW);
138 uno::Reference<embed::XStorage> xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
139 OUString aBaseURL = rMediaDesc.getUnpackedValueOrDefault("URL", OUString());
140 const uno::Reference<frame::XModel> xModel_(xModel,
141 uno::UNO_QUERY_THROW);
142 const uno::Reference<rdf::XURI> xBaseURI(sfx2::createBaseURI(xContext, xModel_, aBaseURL, OUString()));
143 const uno::Reference<task::XInteractionHandler> xHandler;
144 xDocumentMetadataAccess->loadMetadataFromStorage(xStorage, xBaseURI, xHandler);
145 }
146 catch (const uno::Exception&)
147 {
148 DBG_UNHANDLED_EXCEPTION("writerfilter", "failed to initialize RDF metadata")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "148" ": ", "writerfilter", "failed to initialize RDF metadata"
);
;
149 }
150
151 if (eDocumentType == SourceDocumentType::OOXML) {
152 // tdf#108350
153 // In Word since version 2007, the default document font is Calibri 11 pt.
154 // If a DOCX document doesn't contain font information, we should assume
155 // the intended font to provide best layout match.
156 try
157 {
158 uno::Reference< beans::XPropertySet > xDefProps(GetTextFactory()->createInstance("com.sun.star.text.Defaults"),
159 uno::UNO_QUERY_THROW);
160 xDefProps->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME), css::uno::Any(OUString("Calibri")));
161 xDefProps->setPropertyValue(getPropertyName(PROP_CHAR_HEIGHT), css::uno::Any(double(11)));
162 }
163 catch (const uno::Exception&)
164 {
165 DBG_UNHANDLED_EXCEPTION("writerfilter", "failed to initialize default font")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "165" ": ", "writerfilter", "failed to initialize default font"
);
;
166 }
167 }
168
169 //import document properties
170 try
171 {
172 uno::Reference< embed::XStorage > xDocumentStorage =
173 comphelper::OStorageHelper::GetStorageOfFormatFromInputStream(OFOPXML_STORAGE_FORMAT_STRING"OFOPXMLFormat", xInputStream, xContext, bRepairStorage );
174
175 uno::Reference< uno::XInterface > xTemp = xContext->getServiceManager()->createInstanceWithContext(
176 "com.sun.star.document.OOXMLDocumentPropertiesImporter",
177 xContext);
178
179 uno::Reference< document::XOOXMLDocumentPropertiesImporter > xImporter( xTemp, uno::UNO_QUERY_THROW );
180 uno::Reference< document::XDocumentPropertiesSupplier > xPropSupplier( xModel, uno::UNO_QUERY_THROW);
181 xImporter->importProperties( xDocumentStorage, xPropSupplier->getDocumentProperties() );
182 }
183 catch( const uno::Exception& ) {}
184}
185
186DomainMapper::~DomainMapper()
187{
188 try
189 {
190 uno::Reference< text::XDocumentIndexesSupplier> xIndexesSupplier( m_pImpl->GetTextDocument(), uno::UNO_QUERY );
191 sal_Int32 nIndexes = 0;
192 if( xIndexesSupplier.is() )
193 {
194 uno::Reference< container::XIndexAccess > xIndexes = xIndexesSupplier->getDocumentIndexes();
195 nIndexes = xIndexes->getCount();
196 }
197 // If we have page references, those need updating as well, similar to the indexes.
198 uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(m_pImpl->GetTextDocument(), uno::UNO_QUERY);
199 if(xTextFieldsSupplier.is())
200 {
201 uno::Reference<container::XEnumeration> xEnumeration = xTextFieldsSupplier->getTextFields()->createEnumeration();
202 while(xEnumeration->hasMoreElements())
203 {
204 ++nIndexes;
205 xEnumeration->nextElement();
206 }
207 }
208
209 mbHasControls |= m_pImpl->m_pSdtHelper->hasElements();
210 if ( nIndexes || mbHasControls )
211 {
212 //index update has to wait until first view is created
213 uno::Reference< document::XEventBroadcaster > xBroadcaster(xIndexesSupplier, uno::UNO_QUERY);
214 if (xBroadcaster.is())
215 xBroadcaster->addEventListener(uno::Reference< document::XEventListener >(new ModelEventListener(nIndexes, mbHasControls)));
216 }
217
218
219 // Apply the document settings after everything else
220 m_pImpl->GetSettingsTable()->ApplyProperties( m_pImpl->GetTextDocument( ) );
221
222 // now that importing is finished, re-enable default styles for any that were never defined/imported.
223 m_pImpl->SetDocumentSettingsProperty("StylesNoDefault", uno::makeAny(false));
224
225 // Grab-bag handling
226 comphelper::SequenceAsHashMap aProperties;
227
228 // Add the saved w:themeFontLang setting
229 aProperties["ThemeFontLangProps"] <<= m_pImpl->GetSettingsTable()->GetThemeFontLangProperties();
230
231 // Add the saved compat settings
232 aProperties["CompatSettings"] <<= m_pImpl->GetSettingsTable()->GetCompatSettings();
233
234 // Add the saved DocumentProtection settings
235 aProperties["DocumentProtection"] <<= m_pImpl->GetSettingsTable()->GetDocumentProtectionSettings();
236
237 // Add the saved w:hyphenationZone setting
238 aProperties["HyphenationZone"] <<= m_pImpl->GetSettingsTable()->GetHyphenationZone();
239
240 // Add the saved w:doNotHyphenateCaps setting
241 aProperties["NoHyphenateCaps"] <<= m_pImpl->GetSettingsTable()->GetNoHyphenateCaps();
242
243 uno::Reference<beans::XPropertySet> xDocProps(m_pImpl->GetTextDocument(), uno::UNO_QUERY);
244 if (xDocProps.is())
245 {
246 comphelper::SequenceAsHashMap aGrabBag(xDocProps->getPropertyValue("InteropGrabBag"));
247 aGrabBag.update(aProperties);
248 xDocProps->setPropertyValue("InteropGrabBag", uno::Any(aGrabBag.getAsConstPropertyValueList()));
249 }
250 }
251 catch( const uno::Exception& ) {}
252
253#ifdef DBG_UTIL
254 TagLogger::getInstance().endDocument();
255#endif
256}
257
258void DomainMapper::lcl_attribute(Id nName, Value & val)
259{
260 if (m_pImpl->hasTableManager() && m_pImpl->getTableManager().attribute(nName, val))
261 return;
262
263 static const int nSingleLineSpacing = 240;
264 sal_Int32 nIntValue = val.getInt();
265 OUString sStringValue = val.getString();
266
267 SectionPropertyMap * pSectionContext = m_pImpl->GetSectionContext();
268 switch( nName )
1
Control jumps to 'case 91923:' at line 756
269 {
270 case NS_ooxml::LN_CT_Lvl_start:
271 break;
272 case NS_ooxml::LN_CT_Lvl_numFmt:
273 break;
274 case NS_ooxml::LN_CT_Lvl_isLgl:
275 break;
276 case NS_ooxml::LN_CT_Lvl_legacy:
277 break;
278 case NS_ooxml::LN_CT_AbstractNum_nsid:
279 break;
280 case NS_ooxml::LN_CT_AbstractNum_tmpl:
281 break;
282 case NS_ooxml::LN_CT_Border_sz:
283 break;
284 case NS_ooxml::LN_CT_Border_val:
285 break;
286 case NS_ooxml::LN_CT_Border_space:
287 break;
288 case NS_ooxml::LN_CT_Border_shadow:
289 break;
290 case NS_ooxml::LN_CT_Border_frame:
291 break;
292 case NS_ooxml::LN_headerr:
293 break;
294 case NS_ooxml::LN_footerr:
295 break;
296 case NS_ooxml::LN_endnote:
297 break;
298 case NS_ooxml::LN_CT_Bookmark_name:
299 m_pImpl->SetBookmarkName( sStringValue );
300 break;
301 case NS_ooxml::LN_CT_MarkupRangeBookmark_id:
302 // add a bookmark range -- this remembers a bookmark starting here
303 // or, if the bookmark was already started or, if the bookmark was
304 // already started before, writes out the bookmark
305 m_pImpl->StartOrEndBookmark( sStringValue );
306 break;
307 case NS_ooxml::LN_CT_MarkupRange_displacedByCustomXml:
308 break;
309 case NS_ooxml::LN_NUMBERING:
310 break;
311 case NS_ooxml::LN_FONTTABLE:
312 break;
313 case NS_ooxml::LN_STYLESHEET:
314 break;
315
316 case NS_ooxml::LN_CT_Sym_char:
317 m_pImpl->SetSymbolChar(nIntValue);
318 break;
319 case NS_ooxml::LN_CT_Sym_font:
320 m_pImpl->SetSymbolFont(sStringValue);
321 break;
322 case NS_ooxml::LN_CT_Underline_val:
323 if (m_pImpl->GetTopContext())
324 handleUnderlineType(nIntValue, m_pImpl->GetTopContext());
325 break;
326 case NS_ooxml::LN_CT_Color_val:
327 if (m_pImpl->GetTopContext())
328 m_pImpl->GetTopContext()->Insert(PROP_CHAR_COLOR, uno::makeAny( nIntValue ) );
329 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "val", OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue)));
330 break;
331 case NS_ooxml::LN_CT_Underline_color:
332 if (m_pImpl->GetTopContext())
333 {
334 m_pImpl->GetTopContext()->Insert(PROP_CHAR_UNDERLINE_HAS_COLOR, uno::makeAny( true ) );
335 m_pImpl->GetTopContext()->Insert(PROP_CHAR_UNDERLINE_COLOR, uno::makeAny( nIntValue ) );
336 }
337 break;
338
339 case NS_ooxml::LN_CT_TabStop_val:
340 if (sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_ST_TabJc_clear)
341 {
342 m_pImpl->m_aCurrentTabStop.bDeleted = true;
343 }
344 else
345 {
346 m_pImpl->m_aCurrentTabStop.bDeleted = false;
347 m_pImpl->m_aCurrentTabStop.Alignment = getTabAlignFromValue(nIntValue);
348 }
349 break;
350 case NS_ooxml::LN_CT_TabStop_leader:
351 m_pImpl->m_aCurrentTabStop.FillChar = getFillCharFromValue(nIntValue);
352 break;
353 case NS_ooxml::LN_CT_TabStop_pos:
354 m_pImpl->m_aCurrentTabStop.Position = ConversionHelper::convertTwipToMM100(nIntValue);
355 break;
356
357 case NS_ooxml::LN_CT_Fonts_ascii:
358 if (m_pImpl->GetTopContext())
359 {
360 m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME, uno::makeAny( sStringValue ));
361 if (m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH) && m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)->isSet(PROP_NUMBERING_RULES))
362 {
363 // Font of the paragraph mark should be used for the numbering as well.
364 uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
365 if (xCharStyle.is())
366 xCharStyle->setPropertyValue("CharFontName", uno::makeAny(sStringValue));
367 }
368 }
369 break;
370 case NS_ooxml::LN_CT_Fonts_asciiTheme:
371 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "asciiTheme", ThemeTable::getStringForTheme(nIntValue));
372 if (m_pImpl->GetTopContext())
373 {
374 uno::Any aPropValue = uno::makeAny( m_pImpl->GetThemeTable()->getFontNameForTheme( nIntValue ) );
375 m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME, aPropValue );
376 m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_FONT_NAME_ASCII, aPropValue, true, CHAR_GRAB_BAG );
377 m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_NAME_ASCII, uno::makeAny( ThemeTable::getStringForTheme(nIntValue) ), true, CHAR_GRAB_BAG);
378 }
379 break;
380 case NS_ooxml::LN_CT_Fonts_hAnsi:
381 break;//unsupported
382 case NS_ooxml::LN_CT_Fonts_hAnsiTheme:
383 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "hAnsiTheme", ThemeTable::getStringForTheme(nIntValue));
384 if (m_pImpl->GetTopContext())
385 m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_NAME_H_ANSI, uno::makeAny( ThemeTable::getStringForTheme(nIntValue) ), true, CHAR_GRAB_BAG);
386 break;
387 case NS_ooxml::LN_CT_Fonts_eastAsia:
388 if (m_pImpl->GetTopContext())
389 m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME_ASIAN, uno::makeAny( sStringValue ));
390 break;
391 case NS_ooxml::LN_CT_Fonts_eastAsiaTheme:
392 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "eastAsiaTheme", ThemeTable::getStringForTheme(nIntValue));
393 if (m_pImpl->GetTopContext())
394 {
395 uno::Any aPropValue = uno::makeAny( m_pImpl->GetThemeTable()->getFontNameForTheme( nIntValue ) );
396 m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME_ASIAN, aPropValue );
397 m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_FONT_NAME_EAST_ASIA, aPropValue, true, CHAR_GRAB_BAG );
398 m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_NAME_EAST_ASIA, uno::makeAny( ThemeTable::getStringForTheme(nIntValue) ), true, CHAR_GRAB_BAG);
399 }
400 break;
401 case NS_ooxml::LN_CT_Fonts_cs:
402 if (m_pImpl->GetTopContext())
403 m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME_COMPLEX, uno::makeAny( sStringValue ));
404 break;
405 case NS_ooxml::LN_CT_Fonts_cstheme:
406 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "cstheme", ThemeTable::getStringForTheme(nIntValue));
407 if (m_pImpl->GetTopContext())
408 {
409 uno::Any aPropValue = uno::makeAny( m_pImpl->GetThemeTable()->getFontNameForTheme( nIntValue ) );
410 m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME_COMPLEX, aPropValue );
411 m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_FONT_NAME_CS, aPropValue, true, CHAR_GRAB_BAG );
412 m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_NAME_CS, uno::makeAny( ThemeTable::getStringForTheme(nIntValue) ), true, CHAR_GRAB_BAG);
413 }
414 break;
415 case NS_ooxml::LN_CT_Spacing_before:
416 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "before", OUString::number(nIntValue));
417 if (m_pImpl->GetTopContext())
418 // Don't overwrite NS_ooxml::LN_CT_Spacing_beforeAutospacing.
419 m_pImpl->GetTopContext()->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100( nIntValue ) ), false);
420 break;
421 case NS_ooxml::LN_CT_Spacing_beforeLines:
422 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "beforeLines", OUString::number(nIntValue));
423 // We would need to make sure that this doesn't overwrite any
424 // NS_ooxml::LN_CT_Spacing_before in parent styles before style
425 // sheet support can be enabled.
426 if (m_pImpl->GetTopContext() && !IsStyleSheetImport())
427 m_pImpl->GetTopContext()->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny(ConversionHelper::convertTwipToMM100(nIntValue * nSingleLineSpacing / 100)), false);
428 break;
429 case NS_ooxml::LN_CT_Spacing_after:
430 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "after", OUString::number(nIntValue));
431 if (m_pImpl->GetTopContext())
432 {
433 // Don't overwrite NS_ooxml::LN_CT_Spacing_afterAutospacing.
434 m_pImpl->GetTopContext()->Insert(PROP_PARA_BOTTOM_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100( nIntValue ) ), false);
435
436 uno::Any aContextualSpacingFromStyle = m_pImpl->GetPropertyFromParaStyleSheet(PROP_PARA_CONTEXT_MARGIN);
437 if (aContextualSpacingFromStyle.hasValue())
438 // Setting "after" spacing means Writer doesn't inherit
439 // contextual spacing anymore from style, but Word does.
440 m_pImpl->GetTopContext()->Insert(PROP_PARA_CONTEXT_MARGIN, aContextualSpacingFromStyle);
441 }
442 break;
443 case NS_ooxml::LN_CT_Spacing_afterLines:
444 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "afterLines", OUString::number(nIntValue));
445 // We would need to make sure that this doesn't overwrite any
446 // NS_ooxml::LN_CT_Spacing_after in parent styles before style
447 // sheet support can be enabled.
448 if (m_pImpl->GetTopContext() && !IsStyleSheetImport())
449 m_pImpl->GetTopContext()->Insert(PROP_PARA_BOTTOM_MARGIN, uno::makeAny(ConversionHelper::convertTwipToMM100(nIntValue * nSingleLineSpacing / 100)), false);
450 break;
451 case NS_ooxml::LN_CT_Spacing_line: //91434
452 case NS_ooxml::LN_CT_Spacing_lineRule: //91435
453 {
454 style::LineSpacing aSpacing;
455 PropertyMapPtr pTopContext = m_pImpl->GetTopContext();
456 std::optional<PropertyMap::Property> aLineSpacingVal;
457 if (pTopContext && (aLineSpacingVal = pTopContext->getProperty(PROP_PARA_LINE_SPACING)) )
458 {
459 aLineSpacingVal->second >>= aSpacing;
460 }
461 else
462 {
463 //default to single line spacing
464 aSpacing.Mode = style::LineSpacingMode::FIX;
465 aSpacing.Height = sal_Int16(ConversionHelper::convertTwipToMM100( nSingleLineSpacing ));
466 }
467 if( nName == NS_ooxml::LN_CT_Spacing_line )
468 {
469 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "line", OUString::number(nIntValue));
470 //now set the value depending on the Mode
471 if( aSpacing.Mode == style::LineSpacingMode::PROP )
472 aSpacing.Height = sal_Int16(nIntValue * 100 / nSingleLineSpacing );
473 else
474 aSpacing.Height = sal_Int16(ConversionHelper::convertTwipToMM100( nIntValue ));
475 }
476 else //NS_ooxml::LN_CT_Spacing_lineRule:
477 {
478 // exactly, atLeast, auto
479 if( sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_LineSpacingRule_auto)
480 {
481 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "lineRule", "auto");
482 if (aSpacing.Height >= 0)
483 {
484 aSpacing.Mode = style::LineSpacingMode::PROP;
485 //reinterpret the already set value
486 aSpacing.Height = sal_Int16( aSpacing.Height * 100 / ConversionHelper::convertTwipToMM100( nSingleLineSpacing ));
487 }
488 else
489 {
490 // Negative value still means a positive height,
491 // just the mode is "exact".
492 aSpacing.Mode = style::LineSpacingMode::FIX;
493 aSpacing.Height *= -1;
494 }
495 }
496 else if( sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_LineSpacingRule_atLeast)
497 {
498 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "lineRule", "atLeast");
499 aSpacing.Mode = style::LineSpacingMode::MINIMUM;
500 }
501 else // NS_ooxml::LN_Value_doc_ST_LineSpacingRule_exact
502 {
503 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "lineRule", "exact");
504 aSpacing.Mode = style::LineSpacingMode::FIX;
505 }
506 }
507 if (pTopContext)
508 pTopContext->Insert(PROP_PARA_LINE_SPACING, uno::makeAny( aSpacing ));
509 }
510 break;
511 case NS_ooxml::LN_CT_Ind_start:
512 case NS_ooxml::LN_CT_Ind_left:
513 if (m_pImpl->GetTopContext())
514 {
515 // Word inherits FirstLineIndent property of the numbering, even if ParaLeftMargin is set, Writer does not.
516 // So copy it explicitly, if necessary.
517 sal_Int32 nFirstLineIndent = m_pImpl->getCurrentNumberingProperty("FirstLineIndent");
518 sal_Int32 nIndentAt = m_pImpl->getCurrentNumberingProperty("IndentAt");
519
520 sal_Int32 nParaLeftMargin = ConversionHelper::convertTwipToMM100(nIntValue);
521 if (nParaLeftMargin != 0 && nIndentAt == nParaLeftMargin)
522 // Avoid direct left margin when it's the same as from the
523 // numbering.
524 break;
525
526 if (nFirstLineIndent != 0)
527 m_pImpl->GetTopContext()->Insert(PROP_PARA_FIRST_LINE_INDENT, uno::makeAny(nFirstLineIndent), /*bOverwrite=*/false);
528
529 m_pImpl->GetTopContext()->Insert(PROP_PARA_LEFT_MARGIN,
530 uno::makeAny(nParaLeftMargin));
531 }
532 break;
533 case NS_ooxml::LN_CT_Ind_end:
534 case NS_ooxml::LN_CT_Ind_right:
535 if (m_pImpl->GetTopContext())
536 {
537 // Word inherits FirstLineIndent/ParaLeftMargin property of the numbering, even if ParaRightMargin is set, Writer does not.
538 // So copy it explicitly, if necessary.
539 sal_Int32 nFirstLineIndent = m_pImpl->getCurrentNumberingProperty("FirstLineIndent");
540 sal_Int32 nParaLeftMargin = m_pImpl->getCurrentNumberingProperty("IndentAt");
541
542 if (nFirstLineIndent != 0)
543 m_pImpl->GetTopContext()->Insert(PROP_PARA_FIRST_LINE_INDENT, uno::makeAny(nFirstLineIndent), /*bOverwrite=*/false);
544 if (nParaLeftMargin != 0)
545 m_pImpl->GetTopContext()->Insert(PROP_PARA_LEFT_MARGIN, uno::makeAny(nParaLeftMargin), /*bOverwrite=*/false);
546
547 m_pImpl->GetTopContext()->Insert(
548 PROP_PARA_RIGHT_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(nIntValue ) ));
549 }
550 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "right", OUString::number(nIntValue));
551 break;
552 case NS_ooxml::LN_CT_Ind_hanging:
553 if (m_pImpl->GetTopContext())
554 {
555 sal_Int32 nValue = ConversionHelper::convertTwipToMM100( nIntValue );
556 m_pImpl->GetTopContext()->Insert(
557 PROP_PARA_FIRST_LINE_INDENT, uno::makeAny( - nValue ));
558
559 // See above, need to inherit left margin from list style when first is set.
560 sal_Int32 nParaLeftMargin = m_pImpl->getCurrentNumberingProperty("IndentAt");
561 if (nParaLeftMargin != 0)
562 m_pImpl->GetTopContext()->Insert(PROP_PARA_LEFT_MARGIN, uno::makeAny(nParaLeftMargin), /*bOverwrite=*/false);
563 }
564 break;
565 case NS_ooxml::LN_CT_Ind_firstLine:
566 if (m_pImpl->GetTopContext())
567 {
568 sal_Int32 nFirstLineIndent
569 = m_pImpl->getCurrentNumberingProperty("FirstLineIndent");
570 sal_Int32 nParaFirstLineIndent = ConversionHelper::convertTwipToMM100(nIntValue);
571 if (nParaFirstLineIndent != 0 && nFirstLineIndent == nParaFirstLineIndent)
572 // Avoid direct first margin when it's the same as from the
573 // numbering.
574 break;
575 m_pImpl->GetTopContext()->Insert(PROP_PARA_FIRST_LINE_INDENT,
576 uno::makeAny(nParaFirstLineIndent));
577 }
578 break;
579 case NS_ooxml::LN_CT_Ind_rightChars:
580 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "rightChars", OUString::number(nIntValue));
581 break;
582
583 case NS_ooxml::LN_CT_EastAsianLayout_id:
584 break;
585 case NS_ooxml::LN_CT_EastAsianLayout_combine:
586 if (m_pImpl->GetTopContext())
587 m_pImpl->GetTopContext()->Insert(PROP_CHAR_COMBINE_IS_ON, uno::makeAny ( nIntValue != 0 ));
588 break;
589 case NS_ooxml::LN_CT_EastAsianLayout_combineBrackets:
590 if (m_pImpl->GetTopContext())
591 {
592 OUString sCombinePrefix = getBracketStringFromEnum(nIntValue);
593 OUString sCombineSuffix = getBracketStringFromEnum(nIntValue, false);
594 m_pImpl->GetTopContext()->Insert(PROP_CHAR_COMBINE_PREFIX, uno::makeAny ( sCombinePrefix ));
595 m_pImpl->GetTopContext()->Insert(PROP_CHAR_COMBINE_SUFFIX, uno::makeAny ( sCombineSuffix ));
596 }
597 break;
598 case NS_ooxml::LN_CT_EastAsianLayout_vert:
599 if (m_pImpl->GetTopContext())
600 {
601 sal_Int16 nRotationAngle = (nIntValue ? 900 : 0);
602 m_pImpl->GetTopContext()->Insert(PROP_CHAR_ROTATION, uno::makeAny ( nRotationAngle ));
603 }
604 break;
605 case NS_ooxml::LN_CT_EastAsianLayout_vertCompress:
606 if (m_pImpl->GetTopContext())
607 m_pImpl->GetTopContext()->Insert(PROP_CHAR_ROTATION_IS_FIT_TO_LINE, uno::makeAny ( nIntValue != 0 ));
608 break;
609
610 case NS_ooxml::LN_CT_PageSz_code:
611 break;
612 case NS_ooxml::LN_CT_PageSz_h:
613 {
614 sal_Int32 nHeight = ConversionHelper::convertTwipToMM100(nIntValue);
615 CT_PageSz.h = PaperInfo::sloppyFitPageDimension(nHeight);
616 }
617 break;
618 case NS_ooxml::LN_CT_PageSz_orient:
619 CT_PageSz.orient = (nIntValue != static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_PageOrientation_portrait));
620 break;
621 case NS_ooxml::LN_CT_PageSz_w:
622 {
623 sal_Int32 nWidth = ConversionHelper::convertTwipToMM100(nIntValue);
624 CT_PageSz.w = PaperInfo::sloppyFitPageDimension(nWidth);
625 }
626 break;
627
628 case NS_ooxml::LN_CT_PageMar_top:
629 m_pImpl->SetPageMarginTwip( PAGE_MAR_TOP, nIntValue );
630 break;
631 case NS_ooxml::LN_CT_PageMar_right:
632 m_pImpl->SetPageMarginTwip( PAGE_MAR_RIGHT, nIntValue );
633 break;
634 case NS_ooxml::LN_CT_PageMar_bottom:
635 m_pImpl->SetPageMarginTwip( PAGE_MAR_BOTTOM, nIntValue );
636 break;
637 case NS_ooxml::LN_CT_PageMar_left:
638 m_pImpl->SetPageMarginTwip( PAGE_MAR_LEFT, nIntValue );
639 break;
640 case NS_ooxml::LN_CT_PageMar_header:
641 m_pImpl->SetPageMarginTwip( PAGE_MAR_HEADER, nIntValue );
642 break;
643 case NS_ooxml::LN_CT_PageMar_footer:
644 m_pImpl->SetPageMarginTwip( PAGE_MAR_FOOTER, nIntValue );
645 break;
646 case NS_ooxml::LN_CT_PageMar_gutter:
647 m_pImpl->SetPageMarginTwip( PAGE_MAR_GUTTER, nIntValue );
648 break;
649 case NS_ooxml::LN_CT_Language_val: //90314
650 case NS_ooxml::LN_CT_Language_eastAsia: //90315
651 case NS_ooxml::LN_CT_Language_bidi: //90316
652 {
653 if (nName == NS_ooxml::LN_CT_Language_eastAsia)
654 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "eastAsia", sStringValue);
655 else if (nName == NS_ooxml::LN_CT_Language_val)
656 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "val", sStringValue);
657 else if (nName == NS_ooxml::LN_CT_Language_bidi)
658 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "bidi", sStringValue);
659 lang::Locale aLocale( LanguageTag::convertToLocale( sStringValue));
660 if (m_pImpl->GetTopContext())
661 m_pImpl->GetTopContext()->Insert(NS_ooxml::LN_CT_Language_val== nName ? PROP_CHAR_LOCALE :
662 NS_ooxml::LN_CT_Language_eastAsia == nName ? PROP_CHAR_LOCALE_ASIAN : PROP_CHAR_LOCALE_COMPLEX,
663 uno::makeAny( aLocale ) );
664 }
665 break;
666 // See SwWW8ImplReader::GetParagraphAutoSpace() on why these are 100 and 280
667 case NS_ooxml::LN_CT_Spacing_beforeAutospacing:
668 {
669 sal_Int32 default_spacing = -1;
670 if (nIntValue)
671 {
672 m_pImpl->SetParaAutoBefore(true);
673
674 default_spacing = 100;
675 if (!m_pImpl->GetSettingsTable()->GetDoNotUseHTMLParagraphAutoSpacing())
676 {
677 // 49 is just the old value that should be removed, once the
678 // root cause in SwTabFrm::MakeAll() is fixed.
679 if (m_pImpl->GetSettingsTable()->GetView() == NS_ooxml::LN_Value_doc_ST_View_web)
680 default_spacing = 49;
681 else
682 default_spacing = 280;
683 }
684 // required at export (here mainly for StyleSheets) to determine if the setting has changed from grab_bag
685 m_pImpl->GetTopContext()->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny(ConversionHelper::convertTwipToMM100(default_spacing)));
686 }
687 m_pImpl->GetTopContext()->Insert( PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ),true, PARA_GRAB_BAG );
688 }
689 break;
690 case NS_ooxml::LN_CT_Spacing_afterAutospacing:
691 {
692 sal_Int32 default_spacing = -1;
693 if (nIntValue)
694 {
695 default_spacing = 100;
696 if (!m_pImpl->GetSettingsTable()->GetDoNotUseHTMLParagraphAutoSpacing())
697 {
698 if (m_pImpl->GetSettingsTable()->GetView() == NS_ooxml::LN_Value_doc_ST_View_web)
699 default_spacing = 49;
700 else
701 default_spacing = 280;
702 }
703 m_pImpl->GetTopContext()->Insert(PROP_PARA_BOTTOM_MARGIN, uno::makeAny(ConversionHelper::convertTwipToMM100(default_spacing)));
704 }
705 m_pImpl->GetTopContext()->Insert( PROP_PARA_BOTTOM_MARGIN_AFTER_AUTO_SPACING, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ),true, PARA_GRAB_BAG );
706 }
707 break;
708 case NS_ooxml::LN_CT_SmartTagRun_uri:
709 m_pImpl->getSmartTagHandler().setURI(val.getString());
710 break;
711 case NS_ooxml::LN_CT_SmartTagRun_element:
712 m_pImpl->getSmartTagHandler().setElement(val.getString());
713 break;
714 case NS_ooxml::LN_CT_Br_type :
715 //TODO: attributes for break (0x12) are not supported
716 break;
717 case NS_ooxml::LN_CT_Fonts_hint :
718 /* assigns script type to ambiguous characters, values can be:
719 NS_ooxml::LN_Value_ST_Hint_default
720 NS_ooxml::LN_Value_ST_Hint_eastAsia
721 NS_ooxml::LN_Value_ST_Hint_cs
722 */
723 //TODO: unsupported?
724 break;
725 case NS_ooxml::LN_CT_TblBorders_right:
726 case NS_ooxml::LN_CT_TblBorders_top:
727 case NS_ooxml::LN_CT_TblBorders_left:
728 case NS_ooxml::LN_CT_TblBorders_bottom:
729 //todo: handle cell mar
730 break;
731 case NS_ooxml::LN_blip: // contains the binary graphic
732 case NS_ooxml::LN_shape:
733 {
734 //looks a bit like a hack - and it is. The graphic import is split into the inline_inline part and
735 //afterwards the adding of the binary data.
736 m_pImpl->GetGraphicImport( IMPORT_AS_DETECTED_INLINE )->attribute(nName, val);
737 m_pImpl->ImportGraphic( val.getProperties(), IMPORT_AS_DETECTED_INLINE );
738 }
739 break;
740 case NS_ooxml::LN_Value_math_ST_Jc_centerGroup:
741 case NS_ooxml::LN_Value_math_ST_Jc_center:
742 m_pImpl->appendStarMath(val);
743 m_pImpl->adjustLastPara(sal_Int8(style::ParagraphAdjust::ParagraphAdjust_CENTER));
744 break;
745 case NS_ooxml::LN_Value_math_ST_Jc_left:
746 m_pImpl->appendStarMath(val);
747 m_pImpl->adjustLastPara(sal_Int8(style::ParagraphAdjust::ParagraphAdjust_LEFT));
748 break;
749 case NS_ooxml::LN_Value_math_ST_Jc_right:
750 m_pImpl->appendStarMath(val);
751 m_pImpl->adjustLastPara(sal_Int8(style::ParagraphAdjust::ParagraphAdjust_RIGHT));
752 break;
753 case NS_ooxml::LN_starmath:
754 m_pImpl->appendStarMath(val);
755 break;
756 case NS_ooxml::LN_CT_FramePr_dropCap:
757 case NS_ooxml::LN_CT_FramePr_lines:
758 case NS_ooxml::LN_CT_FramePr_hAnchor:
759 case NS_ooxml::LN_CT_FramePr_vAnchor:
760 case NS_ooxml::LN_CT_FramePr_x:
761 case NS_ooxml::LN_CT_FramePr_xAlign:
762 case NS_ooxml::LN_CT_FramePr_y:
763 case NS_ooxml::LN_CT_FramePr_yAlign:
764 case NS_ooxml::LN_CT_FramePr_hRule:
765 case NS_ooxml::LN_CT_FramePr_w:
766 case NS_ooxml::LN_CT_FramePr_h:
767 case NS_ooxml::LN_CT_FramePr_wrap:
768 case NS_ooxml::LN_CT_FramePr_hSpace:
769 case NS_ooxml::LN_CT_FramePr_vSpace:
770 {
771 ParagraphProperties* pParaProperties = nullptr;
772 // handle frame properties at styles
773 if( m_pImpl->GetTopContextType() == CONTEXT_STYLESHEET )
2
Assuming the condition is false
3
Taking false branch
774 pParaProperties = dynamic_cast< ParagraphProperties*>( m_pImpl->GetTopContextOfType( CONTEXT_STYLESHEET ).get() );
775 else
776 pParaProperties = dynamic_cast< ParagraphProperties*>( m_pImpl->GetTopContextOfType( CONTEXT_PARAGRAPH ).get() );
4
Calling '~SvRef'
15
Returning from '~SvRef'
777
778 if( pParaProperties
15.1
'pParaProperties' is non-null
15.1
'pParaProperties' is non-null
)
16
Taking true branch
779 {
780 switch( nName )
17
Control jumps to 'case 91923:' at line 782
781 {
782 case NS_ooxml::LN_CT_FramePr_dropCap:
783 pParaProperties->SetDropCap( nIntValue );
18
Use of memory after it is freed
784 break;
785 case NS_ooxml::LN_CT_FramePr_lines:
786 pParaProperties->SetLines( nIntValue );
787 break;
788 case NS_ooxml::LN_CT_FramePr_hAnchor:
789 switch(nIntValue)
790 {
791 case NS_ooxml::LN_Value_doc_ST_HAnchor_text: //relative to column
792 nIntValue = text::RelOrientation::FRAME; break;
793 case NS_ooxml::LN_Value_doc_ST_HAnchor_margin: nIntValue = text::RelOrientation::PAGE_PRINT_AREA; break;
794 case NS_ooxml::LN_Value_doc_ST_HAnchor_page: nIntValue = text::RelOrientation::PAGE_FRAME; break;
795 default:;
796 }
797 pParaProperties->SethAnchor( nIntValue );
798 break;
799 case NS_ooxml::LN_CT_FramePr_vAnchor:
800 switch(nIntValue)
801 {
802 case NS_ooxml::LN_Value_doc_ST_VAnchor_text: //relative to paragraph
803 nIntValue = text::RelOrientation::FRAME; break;
804 case NS_ooxml::LN_Value_doc_ST_VAnchor_margin:nIntValue = text::RelOrientation::PAGE_PRINT_AREA ; break;
805 case NS_ooxml::LN_Value_doc_ST_VAnchor_page: nIntValue = text::RelOrientation::PAGE_FRAME; break;
806 default:;
807 }
808 pParaProperties->SetvAnchor( nIntValue );
809 break;
810 case NS_ooxml::LN_CT_FramePr_x:
811 pParaProperties->Setx( ConversionHelper::convertTwipToMM100(nIntValue ));
812 pParaProperties->SetxAlign( text::HoriOrientation::NONE );
813 break;
814 case NS_ooxml::LN_CT_FramePr_xAlign:
815 switch( nIntValue )
816 {
817 case NS_ooxml::LN_Value_doc_ST_XAlign_center : nIntValue = text::HoriOrientation::CENTER; break;
818 case NS_ooxml::LN_Value_doc_ST_XAlign_right : nIntValue = text::HoriOrientation::RIGHT; break;
819 case NS_ooxml::LN_Value_doc_ST_XAlign_inside : nIntValue = text::HoriOrientation::INSIDE; break;
820 case NS_ooxml::LN_Value_doc_ST_XAlign_outside : nIntValue = text::HoriOrientation::OUTSIDE; break;
821 case NS_ooxml::LN_Value_doc_ST_XAlign_left : nIntValue = text::HoriOrientation::LEFT; break;
822 default: nIntValue = text::HoriOrientation::NONE;
823 }
824 pParaProperties->SetxAlign( nIntValue );
825 break;
826 case NS_ooxml::LN_CT_FramePr_y:
827 pParaProperties->Sety( ConversionHelper::convertTwipToMM100(nIntValue ));
828 pParaProperties->SetyAlign( text::VertOrientation::NONE );
829 break;
830 case NS_ooxml::LN_CT_FramePr_yAlign:
831 switch( nIntValue )
832 {
833 case NS_ooxml::LN_Value_doc_ST_YAlign_top :
834 case NS_ooxml::LN_Value_doc_ST_YAlign_inside :nIntValue = text::VertOrientation::TOP; break;
835 case NS_ooxml::LN_Value_doc_ST_YAlign_center :nIntValue = text::VertOrientation::CENTER;break;
836 case NS_ooxml::LN_Value_doc_ST_YAlign_bottom :
837 case NS_ooxml::LN_Value_doc_ST_YAlign_outside :nIntValue = text::VertOrientation::BOTTOM;break;
838 case NS_ooxml::LN_Value_doc_ST_YAlign_inline :
839 {
840 // HACK: This is for bnc#780851, where a table has one cell that has w:framePr,
841 // which causes that paragraph to be converted to a text frame, and the original
842 // paragraph object no longer exists, which makes table creation fail and furthermore
843 // it would be missing in the table layout anyway. So actually no letting that paragraph
844 // be a text frame "fixes" it. I'm not sure what "inline" is supposed to mean in practice
845 // anyway, so as long as this doesn't cause trouble elsewhere ...
846 PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
847 if( pContext )
848 {
849 ParagraphPropertyMap* pParaContext = dynamic_cast< ParagraphPropertyMap* >( pContext.get() );
850 if (pParaContext)
851 pParaContext->SetFrameMode(false);
852 }
853 nIntValue = text::VertOrientation::NONE;
854 break;
855 }
856 default:
857 nIntValue = text::VertOrientation::NONE;
858 break;
859 }
860 pParaProperties->SetyAlign( nIntValue );
861 break;
862 case NS_ooxml::LN_CT_FramePr_hRule:
863 switch( nIntValue )
864 {
865 case NS_ooxml::LN_Value_doc_ST_HeightRule_exact:
866 nIntValue = text::SizeType::FIX;
867 break;
868 case NS_ooxml::LN_Value_doc_ST_HeightRule_atLeast:
869 nIntValue = text::SizeType::MIN;
870 break;
871 case NS_ooxml::LN_Value_doc_ST_HeightRule_auto:
872 //no break;
873 default:;
874 nIntValue = text::SizeType::VARIABLE;
875 }
876 pParaProperties->SethRule( nIntValue );
877 break;
878 case NS_ooxml::LN_CT_FramePr_wrap:
879 {
880 //should be either LN_Value_doc_ST_Wrap_notBeside or LN_Value_doc_ST_Wrap_around or LN_Value_doc_ST_Wrap_auto
881 OSL_ENSURE( sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_around ||do { if (true && (!(sal::static_int_cast<Id>(nIntValue
) == NS_ooxml::LN_Value_doc_ST_Wrap_around || sal::static_int_cast
<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_notBeside
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_through
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_none
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_auto
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "886" ": "), "%s", "wrap not around, not_Beside, through, none or auto?"
); } } while (false)
882 sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_notBeside ||do { if (true && (!(sal::static_int_cast<Id>(nIntValue
) == NS_ooxml::LN_Value_doc_ST_Wrap_around || sal::static_int_cast
<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_notBeside
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_through
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_none
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_auto
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "886" ": "), "%s", "wrap not around, not_Beside, through, none or auto?"
); } } while (false)
883 sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_through ||do { if (true && (!(sal::static_int_cast<Id>(nIntValue
) == NS_ooxml::LN_Value_doc_ST_Wrap_around || sal::static_int_cast
<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_notBeside
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_through
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_none
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_auto
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "886" ": "), "%s", "wrap not around, not_Beside, through, none or auto?"
); } } while (false)
884 sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_none ||do { if (true && (!(sal::static_int_cast<Id>(nIntValue
) == NS_ooxml::LN_Value_doc_ST_Wrap_around || sal::static_int_cast
<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_notBeside
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_through
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_none
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_auto
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "886" ": "), "%s", "wrap not around, not_Beside, through, none or auto?"
); } } while (false)
885 sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_auto,do { if (true && (!(sal::static_int_cast<Id>(nIntValue
) == NS_ooxml::LN_Value_doc_ST_Wrap_around || sal::static_int_cast
<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_notBeside
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_through
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_none
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_auto
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "886" ": "), "%s", "wrap not around, not_Beside, through, none or auto?"
); } } while (false)
886 "wrap not around, not_Beside, through, none or auto?")do { if (true && (!(sal::static_int_cast<Id>(nIntValue
) == NS_ooxml::LN_Value_doc_ST_Wrap_around || sal::static_int_cast
<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_notBeside
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_through
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_none
|| sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_auto
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "886" ": "), "%s", "wrap not around, not_Beside, through, none or auto?"
); } } while (false)
;
887 if( sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_through ||
888 sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_auto )
889 pParaProperties->SetWrap ( text::WrapTextMode_DYNAMIC ) ;
890 else if (sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_around)
891 pParaProperties->SetWrap(text::WrapTextMode_PARALLEL);
892 else if (sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_doc_ST_Wrap_none)
893 pParaProperties->SetWrap ( text::WrapTextMode_THROUGH ) ;
894 else
895 pParaProperties->SetWrap ( text::WrapTextMode_NONE ) ;
896 }
897 break;
898 case NS_ooxml::LN_CT_FramePr_w:
899 pParaProperties->Setw(ConversionHelper::convertTwipToMM100(nIntValue));
900 break;
901 case NS_ooxml::LN_CT_FramePr_h:
902 pParaProperties->Seth(ConversionHelper::convertTwipToMM100(nIntValue));
903 break;
904 case NS_ooxml::LN_CT_FramePr_hSpace:
905 pParaProperties->SethSpace( ConversionHelper::convertTwipToMM100(nIntValue ));
906 break;
907 case NS_ooxml::LN_CT_FramePr_vSpace:
908 pParaProperties->SetvSpace( ConversionHelper::convertTwipToMM100(nIntValue ));
909 break;
910 default:;
911 }
912 }
913 }
914 break;
915 case NS_ooxml::LN_CT_TrackChange_author:
916 m_pImpl->SetCurrentRedlineAuthor( sStringValue );
917 break;
918 case NS_ooxml::LN_CT_TrackChange_date:
919 m_pImpl->SetCurrentRedlineDate( sStringValue );
920 break;
921 case NS_ooxml::LN_CT_Markup_id:
922 m_pImpl->SetCurrentRedlineId( nIntValue );
923 break;
924 case NS_ooxml::LN_EG_RangeMarkupElements_commentRangeStart:
925 m_pImpl->AddAnnotationPosition( true, nIntValue );
926 break;
927 case NS_ooxml::LN_EG_RangeMarkupElements_commentRangeEnd:
928 m_pImpl->AddAnnotationPosition( false, nIntValue );
929 break;
930 case NS_ooxml::LN_CT_Comment_initials:
931 m_pImpl->SetCurrentRedlineInitials(sStringValue);
932 break;
933 case NS_ooxml::LN_token:
934 m_pImpl->SetCurrentRedlineToken( nIntValue );
935 break;
936 case NS_ooxml::LN_CT_LineNumber_start:
937 case NS_ooxml::LN_CT_LineNumber_distance:
938 case NS_ooxml::LN_CT_LineNumber_countBy:
939 case NS_ooxml::LN_CT_LineNumber_restart:
940 {
941 //line numbering in Writer is a global document setting
942 //in Word is a section setting
943 //if line numbering is switched on anywhere in the document it's set at the global settings
944 LineNumberSettings aSettings = m_pImpl->GetLineNumberSettings();
945 switch( nName )
946 {
947 case NS_ooxml::LN_CT_LineNumber_countBy:
948 aSettings.nInterval = nIntValue;
949 OSL_ENSURE(pSectionContext, "SectionContext unavailable!")do { if (true && (!(pSectionContext))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "949" ": "), "%s", "SectionContext unavailable!"); } } while
(false)
;
950 if( pSectionContext )
951 pSectionContext->SetLnnMod( nIntValue );
952 break;
953 case NS_ooxml::LN_CT_LineNumber_start:
954 OSL_ENSURE(pSectionContext, "SectionContext unavailable!")do { if (true && (!(pSectionContext))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "954" ": "), "%s", "SectionContext unavailable!"); } } while
(false)
;
955 if( pSectionContext )
956 pSectionContext->SetLnnMin( nIntValue );
957 break;
958 case NS_ooxml::LN_CT_LineNumber_distance:
959 aSettings.nDistance = ConversionHelper::convertTwipToMM100( nIntValue );
960 OSL_ENSURE(pSectionContext, "SectionContext unavailable!")do { if (true && (!(pSectionContext))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "960" ": "), "%s", "SectionContext unavailable!"); } } while
(false)
;
961 if( pSectionContext )
962 pSectionContext->SetdxaLnn( nIntValue );
963 break;
964 case NS_ooxml::LN_CT_LineNumber_restart:
965 aSettings.bRestartAtEachPage = nIntValue == static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_LineNumberRestart_newPage);
966 OSL_ENSURE(pSectionContext, "SectionContext unavailable!")do { if (true && (!(pSectionContext))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "966" ": "), "%s", "SectionContext unavailable!"); } } while
(false)
;
967 if( pSectionContext )
968 pSectionContext->SetLnc( nIntValue );
969 break;
970 default:;
971 }
972 m_pImpl->SetLineNumberSettings( aSettings );
973 }
974 break;
975 case NS_ooxml::LN_CT_FtnEdnRef_customMarkFollows:
976 m_pImpl->StartCustomFootnote(m_pImpl->GetTopContext());
977 break;
978 case NS_ooxml::LN_CT_FtnEdnRef_id:
979 // footnote or endnote reference id - not needed
980 break;
981 case NS_ooxml::LN_CT_Color_themeColor:
982 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "themeColor", TDefTableHandler::getThemeColorTypeString(nIntValue));
983 break;
984 case NS_ooxml::LN_CT_Color_themeTint:
985 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "themeTint", OUString::number(nIntValue, 16));
986 break;
987 case NS_ooxml::LN_CT_Color_themeShade:
988 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "themeShade", OUString::number(nIntValue, 16));
989 break;
990 case NS_ooxml::LN_CT_DocGrid_linePitch:
991 {
992 //see SwWW8ImplReader::SetDocumentGrid
993 OSL_ENSURE(pSectionContext, "SectionContext unavailable!")do { if (true && (!(pSectionContext))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "993" ": "), "%s", "SectionContext unavailable!"); } } while
(false)
;
994 if(pSectionContext)
995 {
996 pSectionContext->SetGridLinePitch( ConversionHelper::convertTwipToMM100( nIntValue ) );
997 }
998 }
999 break;
1000 case NS_ooxml::LN_CT_DocGrid_charSpace:
1001 {
1002 OSL_ENSURE(pSectionContext, "SectionContext unavailable!")do { if (true && (!(pSectionContext))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1002" ": "), "%s", "SectionContext unavailable!"); } } while
(false)
;
1003 if(pSectionContext)
1004 {
1005 pSectionContext->SetDxtCharSpace( nIntValue );
1006 }
1007 }
1008 break;
1009 case NS_ooxml::LN_CT_DocGrid_type:
1010 {
1011 if (pSectionContext != nullptr)
1012 {
1013 switch( nIntValue )
1014 {
1015 case NS_ooxml::LN_Value_doc_ST_DocGrid_default:
1016 pSectionContext->SetGridType(text::TextGridMode::NONE);
1017 break;
1018 case NS_ooxml::LN_Value_doc_ST_DocGrid_lines:
1019 pSectionContext->SetGridType(text::TextGridMode::LINES);
1020 break;
1021 case NS_ooxml::LN_Value_doc_ST_DocGrid_linesAndChars:
1022 pSectionContext->SetGridType(text::TextGridMode::LINES_AND_CHARS);
1023 pSectionContext->SetGridSnapToChars( false );
1024 break;
1025 case NS_ooxml::LN_Value_doc_ST_DocGrid_snapToChars:
1026 pSectionContext->SetGridType(text::TextGridMode::LINES_AND_CHARS);
1027 pSectionContext->SetGridSnapToChars( true );
1028 break;
1029 default :
1030 OSL_FAIL("unknown SwTextGrid value")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1030" ": "), "%s", "unknown SwTextGrid value"); } } while
(false)
;
1031 }
1032 }
1033 }
1034 break;
1035 case NS_ooxml::LN_CT_SdtBlock_sdtContent:
1036 m_pImpl->SetSdt(true);
1037 break;
1038 case NS_ooxml::LN_CT_SdtBlock_sdtEndContent:
1039 m_pImpl->SetSdt(false);
1040
1041 // It's not possible to insert the relevant property to the character context here:
1042 // the previous, already sent character context may be still active, so the property would be lost.
1043 if (m_pImpl->m_pSdtHelper->isOutsideAParagraph())
1044 m_pImpl->setParaSdtEndDeferred(true);
1045 else
1046 m_pImpl->setSdtEndDeferred(true);
1047
1048 if (m_pImpl->m_pSdtHelper->isInsideDropDownControl())
1049 m_pImpl->m_pSdtHelper->createDropDownControl();
1050 else if (m_pImpl->m_pSdtHelper->validateDateFormat())
1051 m_pImpl->m_pSdtHelper->createDateContentControl();
1052 break;
1053 case NS_ooxml::LN_CT_SdtListItem_displayText:
1054 // TODO handle when this is != value
1055 break;
1056 case NS_ooxml::LN_CT_SdtListItem_value:
1057 m_pImpl->m_pSdtHelper->getDropDownItems().push_back(sStringValue);
1058 break;
1059 case NS_ooxml::LN_CT_SdtDate_fullDate:
1060 m_pImpl->m_pSdtHelper->getDate().append(sStringValue);
1061 break;
1062 case NS_ooxml::LN_CT_Background_color:
1063 if (m_pImpl->GetSettingsTable()->GetDisplayBackgroundShape())
1064 m_pImpl->m_oBackgroundColor = nIntValue;
1065 break;
1066 case NS_ooxml::LN_CT_PageNumber_start:
1067 if (pSectionContext != nullptr)
1068 pSectionContext->SetPageNumber(nIntValue);
1069 break;
1070 case NS_ooxml::LN_CT_PageNumber_fmt:
1071 if (pSectionContext)
1072 {
1073 switch (nIntValue)
1074 {
1075 case NS_ooxml::LN_Value_ST_NumberFormat_decimal:
1076 // 1, 2, ...
1077 pSectionContext->SetPageNumberType(style::NumberingType::ARABIC);
1078 break;
1079 case NS_ooxml::LN_Value_ST_NumberFormat_upperLetter:
1080 // A, B, ...
1081 pSectionContext->SetPageNumberType(style::NumberingType::CHARS_UPPER_LETTER_N);
1082 break;
1083 case NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter:
1084 // a, b, ...
1085 pSectionContext->SetPageNumberType(style::NumberingType::CHARS_LOWER_LETTER_N);
1086 break;
1087 case NS_ooxml::LN_Value_ST_NumberFormat_upperRoman:
1088 // I, II, ...
1089 pSectionContext->SetPageNumberType(style::NumberingType::ROMAN_UPPER);
1090 break;
1091 case NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman:
1092 // i, ii, ...
1093 pSectionContext->SetPageNumberType(style::NumberingType::ROMAN_LOWER);
1094 break;
1095 }
1096 }
1097 break;
1098 case NS_ooxml::LN_CT_FtnEdn_type:
1099 // This is the "separator" footnote, ignore its linebreaks/text.
1100 if (static_cast<sal_uInt32>(nIntValue) == NS_ooxml::LN_Value_doc_ST_FtnEdn_separator)
1101 m_pImpl->SetSkipFootnoteState( SkipFootnoteSeparator::ON );
1102 else
1103 m_pImpl->SetSkipFootnoteState( SkipFootnoteSeparator::OFF );
1104 break;
1105 case NS_ooxml::LN_CT_FtnEdn_id:
1106 {
1107 SkipFootnoteSeparator eSkip = m_pImpl->GetSkipFootnoteState();
1108 if ( eSkip == SkipFootnoteSeparator::ON )
1109 m_pImpl->SetSkipFootnoteState( SkipFootnoteSeparator::SKIPPING );
1110 else if ( eSkip == SkipFootnoteSeparator::SKIPPING )
1111 m_pImpl->SetSkipFootnoteState( SkipFootnoteSeparator::OFF );
1112 }
1113 break;
1114 case NS_ooxml::LN_CT_DataBinding_prefixMappings:
1115 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ooxml:CT_DataBinding_prefixMappings", sStringValue);
1116 break;
1117 case NS_ooxml::LN_CT_DataBinding_xpath:
1118 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ooxml:CT_DataBinding_xpath", sStringValue);
1119 break;
1120 case NS_ooxml::LN_CT_DataBinding_storeItemID:
1121 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ooxml:CT_DataBinding_storeItemID", sStringValue);
1122 break;
1123 case NS_ooxml::LN_CT_PTab_leader:
1124 case NS_ooxml::LN_CT_PTab_relativeTo:
1125 case NS_ooxml::LN_CT_PTab_alignment:
1126 break;
1127 case NS_ooxml::LN_CT_Cnf_lastRowLastColumn:
1128 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lastRowLastColumn", OUString::number(nIntValue));
1129 break;
1130 case NS_ooxml::LN_CT_Cnf_lastRowFirstColumn:
1131 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lastRowFirstColumn", OUString::number(nIntValue));
1132 break;
1133 case NS_ooxml::LN_CT_Cnf_firstRowLastColumn:
1134 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "firstRowLastColumn", OUString::number(nIntValue));
1135 break;
1136 case NS_ooxml::LN_CT_Cnf_oddHBand:
1137 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "oddHBand", OUString::number(nIntValue));
1138 break;
1139 case NS_ooxml::LN_CT_Cnf_firstRowFirstColumn:
1140 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "firstRowFirstColumn", OUString::number(nIntValue));
1141 break;
1142 case NS_ooxml::LN_CT_Cnf_evenVBand:
1143 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "evenVBand", OUString::number(nIntValue));
1144 break;
1145 case NS_ooxml::LN_CT_Cnf_evenHBand:
1146 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "evenHBand", OUString::number(nIntValue));
1147 break;
1148 case NS_ooxml::LN_CT_Cnf_lastColumn:
1149 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lastColumn", OUString::number(nIntValue));
1150 break;
1151 case NS_ooxml::LN_CT_Cnf_firstColumn:
1152 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "firstColumn", OUString::number(nIntValue));
1153 break;
1154 case NS_ooxml::LN_CT_Cnf_oddVBand:
1155 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "oddVBand", OUString::number(nIntValue));
1156 break;
1157 case NS_ooxml::LN_CT_Cnf_lastRow:
1158 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lastRow", OUString::number(nIntValue));
1159 break;
1160 case NS_ooxml::LN_CT_Cnf_firstRow:
1161 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "firstRow", OUString::number(nIntValue));
1162 break;
1163 case NS_ooxml::LN_CT_Cnf_val:
1164 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "val", sStringValue);
1165 break;
1166 case NS_ooxml::LN_CT_DocPartName_val:
1167 {
1168 m_sGlossaryEntryName = sStringValue;
1169 break;
1170 }
1171 case NS_ooxml::LN_CT_DocPartGallery_val:
1172 {
1173 const OUString& sGlossaryEntryGallery = sStringValue;
1174 if(m_pImpl->GetTopContext())
1175 {
1176 OUString sName = sGlossaryEntryGallery + ":" + m_sGlossaryEntryName;
1177 // Add glossary entry name as a first paragraph in section
1178 m_pImpl->appendTextPortion(sName, m_pImpl->GetTopContext());
1179 }
1180 break;
1181 }
1182 case NS_ooxml::LN_CT_PermStart_ed:
1183 {
1184 m_pImpl->setPermissionRangeEd(sStringValue);
1185 break;
1186 }
1187 case NS_ooxml::LN_CT_PermStart_edGrp:
1188 {
1189 m_pImpl->setPermissionRangeEdGrp(sStringValue);
1190 break;
1191 }
1192 case NS_ooxml::LN_CT_PermStart_id:
1193 {
1194 m_pImpl->startOrEndPermissionRange(nIntValue);
1195 break;
1196 }
1197 case NS_ooxml::LN_CT_PermEnd_id:
1198 {
1199 m_pImpl->startOrEndPermissionRange(nIntValue);
1200 break;
1201 }
1202 case NS_ooxml::LN_CT_NumFmt_val:
1203 {
1204 try
1205 {
1206 uno::Reference<beans::XPropertySet> xFtnEdnSettings;
1207 if (m_pImpl->IsInFootnoteProperties())
1208 {
1209 uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(
1210 m_pImpl->GetTextDocument(), uno::UNO_QUERY);
1211 if (xFootnotesSupplier.is())
1212 xFtnEdnSettings = xFootnotesSupplier->getFootnoteSettings();
1213 }
1214 else
1215 {
1216 uno::Reference<text::XEndnotesSupplier> xEndnotesSupplier(
1217 m_pImpl->GetTextDocument(), uno::UNO_QUERY);
1218 if (xEndnotesSupplier.is())
1219 xFtnEdnSettings = xEndnotesSupplier->getEndnoteSettings();
1220 }
1221 if (xFtnEdnSettings.is())
1222 {
1223 sal_Int16 nNumType = ConversionHelper::ConvertNumberingType(nIntValue);
1224 xFtnEdnSettings->setPropertyValue(getPropertyName(PROP_NUMBERING_TYPE),
1225 uno::makeAny(nNumType));
1226 }
1227 }
1228 catch (const uno::Exception&)
1229 {
1230 }
1231 }
1232 break;
1233 default:
1234 SAL_WARN("writerfilter", "DomainMapper::lcl_attribute: unhandled token: " << nName)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "writerfilter")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "DomainMapper::lcl_attribute: unhandled token: "
<< nName) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1234" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "DomainMapper::lcl_attribute: unhandled token: "
<< nName), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "DomainMapper::lcl_attribute: unhandled token: "
<< nName; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1234" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "DomainMapper::lcl_attribute: unhandled token: " <<
nName) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1234" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "DomainMapper::lcl_attribute: unhandled token: "
<< nName), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "DomainMapper::lcl_attribute: unhandled token: "
<< nName; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1234" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1235 }
1236}
1237
1238void DomainMapper::lcl_sprm(Sprm & rSprm)
1239{
1240 if (!m_pImpl->hasTableManager() || !m_pImpl->getTableManager().sprm(rSprm))
1241 sprmWithProps(rSprm, m_pImpl->GetTopContext());
1242}
1243
1244// In rtl-paragraphs the meaning of left/right are to be exchanged
1245static bool ExchangeLeftRight(const PropertyMapPtr& rContext, DomainMapper_Impl& rImpl)
1246{
1247 bool bExchangeLeftRight = false;
1248 sal_Int32 aAdjust;
1249 uno::Any aPropPara = rImpl.GetAnyProperty(PROP_WRITING_MODE, rContext);
1250 if( (aPropPara >>= aAdjust) && aAdjust == text::WritingMode2::RL_TB )
1251 bExchangeLeftRight = true;
1252 return bExchangeLeftRight;
1253}
1254
1255void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
1256{
1257 // These SPRM's are not specific to any section, so it's expected that there is no context yet.
1258 switch (rSprm.getId())
1259 {
1260 case NS_ooxml::LN_background_background:
1261 return;
1262 break;
1263 default:
1264 break;
1265 }
1266
1267 OSL_ENSURE(rContext, "PropertyMap has to be valid!")do { if (true && (!(rContext))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1267" ": "), "%s", "PropertyMap has to be valid!"); } }
while (false)
;
1268 if(!rContext)
1269 return ;
1270
1271 sal_uInt32 nSprmId = rSprm.getId();
1272 //needed for page properties
1273 SectionPropertyMap * pSectionContext = m_pImpl->GetSectionContext();
1274 Value::Pointer_t pValue = rSprm.getValue();
1275 sal_Int32 nIntValue = pValue->getInt();
1276 const OUString sStringValue = pValue->getString();
1277
1278 switch(nSprmId)
1279 {
1280 case NS_ooxml::LN_CT_PPrBase_jc:
1281 {
1282 bool bExchangeLeftRight = !IsRTFImport() && ExchangeLeftRight(rContext, *m_pImpl);
1283 handleParaJustification(nIntValue, rContext, bExchangeLeftRight);
1284 break;
1285 }
1286 case NS_ooxml::LN_CT_PPrBase_keepLines:
1287 rContext->Insert(PROP_PARA_SPLIT, uno::makeAny(nIntValue == 0));
1288 break;
1289 case NS_ooxml::LN_CT_PPrBase_keepNext:
1290 rContext->Insert(PROP_PARA_KEEP_TOGETHER, uno::makeAny( nIntValue != 0 ) );
1291 break;
1292 case NS_ooxml::LN_CT_PPrBase_pageBreakBefore:
1293 rContext->Insert(PROP_BREAK_TYPE, uno::makeAny(nIntValue ? style::BreakType_PAGE_BEFORE : style::BreakType_NONE));
1294 break;
1295 case NS_ooxml::LN_CT_NumPr_ilvl:
1296 if (nIntValue < 0 || 10 <= nIntValue) // Writer can't do everything
1297 {
1298 SAL_INFO("writerfilter",do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "writerfilter")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "unsupported numbering level "
<< nIntValue) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1299" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "unsupported numbering level " <<
nIntValue), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unsupported numbering level " <<
nIntValue; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO)
, ("writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1299" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "unsupported numbering level " << nIntValue
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("writerfilter"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1299" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "unsupported numbering level " <<
nIntValue), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unsupported numbering level " <<
nIntValue; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO)
, ("writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1299" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
1299 "unsupported numbering level " << nIntValue)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "writerfilter")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "unsupported numbering level "
<< nIntValue) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1299" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "unsupported numbering level " <<
nIntValue), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unsupported numbering level " <<
nIntValue; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO)
, ("writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1299" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "unsupported numbering level " << nIntValue
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("writerfilter"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1299" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "unsupported numbering level " <<
nIntValue), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "unsupported numbering level " <<
nIntValue; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO)
, ("writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1299" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1300 break;
1301 }
1302 if( IsStyleSheetImport() )
1303 {
1304 //style sheets cannot have a numbering rule attached
1305 StyleSheetPropertyMap* pStyleSheetPropertyMap = dynamic_cast< StyleSheetPropertyMap* >( rContext.get() );
1306 if (pStyleSheetPropertyMap)
1307 pStyleSheetPropertyMap->SetListLevel( static_cast<sal_Int16>(nIntValue) );
1308 }
1309 else
1310 rContext->Insert( PROP_NUMBERING_LEVEL, uno::makeAny( static_cast<sal_Int16>(nIntValue) ));
1311 break;
1312 case NS_ooxml::LN_CT_NumPr_numId:
1313 {
1314 //convert the ListTable entry to a NumberingRules property and apply it
1315 ListsManager::Pointer pListTable = m_pImpl->GetListTable();
1316 ListDef::Pointer pList = pListTable->GetList( nIntValue );
1317 if( IsStyleSheetImport() )
1318 {
1319 //style sheets cannot have a numbering rule attached
1320 StyleSheetPropertyMap* pStyleSheetPropertyMap = dynamic_cast< StyleSheetPropertyMap* >( rContext.get() );
1321 if (pStyleSheetPropertyMap)
1322 pStyleSheetPropertyMap->SetListId( nIntValue );
1323 }
1324 if( pList )
1325 {
1326 if( !IsStyleSheetImport() )
1327 {
1328 uno::Any aRules = uno::makeAny( pList->GetNumberingRules( ) );
1329 rContext->Insert( PROP_NUMBERING_RULES, aRules );
1330 PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
1331 if (pContext)
1332 {
1333 assert(dynamic_cast<ParagraphPropertyMap*>(pContext.get()))(static_cast <bool> (dynamic_cast<ParagraphPropertyMap
*>(pContext.get())) ? void (0) : __assert_fail ("dynamic_cast<ParagraphPropertyMap*>(pContext.get())"
, "/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
, 1333, __extension__ __PRETTY_FUNCTION__))
;
1334 static_cast<ParagraphPropertyMap*>(pContext.get())->SetListId(pList->GetId());
1335 }
1336
1337 // Indentation can came from:
1338 // 1) Paragraph style's numbering's indentation: the current non-style numId has priority over it.
1339 // 2) Numbering's indentation: Writer handles that natively, so it should not be set on rContext.
1340 // 3) Paragraph style's indentation: ditto.
1341 // 4) Direct paragraph formatting: that will came later.
1342 // So no situation where keeping indentation at this point would make sense -> erase.
1343 rContext->Erase(PROP_PARA_FIRST_LINE_INDENT);
1344 rContext->Erase(PROP_PARA_LEFT_MARGIN);
1345 rContext->Erase(PROP_PARA_RIGHT_MARGIN);
1346 }
1347 }
1348 else
1349 {
1350 if( !IsStyleSheetImport() )
1351 {
1352 // eg. disabled numbering using non-existent numId "0"
1353 rContext->Insert( PROP_NUMBERING_STYLE_NAME, uno::makeAny( OUString() ) );
1354 // disable inheritance of indentation of parent styles
1355 rContext->Insert( PROP_PARA_LEFT_MARGIN, uno::makeAny( sal_Int32(0) ), /*bOverwrite=*/false);
1356 rContext->Insert( PROP_PARA_FIRST_LINE_INDENT,
1357 uno::makeAny( sal_Int32(0) ), /*bOverwrite=*/false);
1358 }
1359 }
1360 }
1361 break;
1362 case NS_ooxml::LN_CT_PPrBase_suppressLineNumbers:
1363 rContext->Insert(PROP_PARA_LINE_NUMBER_COUNT, uno::makeAny( nIntValue == 0 ) );
1364 break;
1365 case NS_ooxml::LN_inTbl:
1366 break;
1367 case NS_ooxml::LN_tblDepth:
1368 //not handled via sprm but via text( 0x07 )
1369 break;
1370 case NS_ooxml::LN_CT_FramePr_w:
1371 break;
1372 case NS_ooxml::LN_CT_FramePr_wrap:
1373 break;
1374
1375 case NS_ooxml::LN_CT_PrBase_pBdr: //paragraph border
1376 resolveSprmProps(*this, rSprm);
1377 break;
1378 case NS_ooxml::LN_CT_PBdr_top:
1379 case NS_ooxml::LN_CT_PBdr_left:
1380 case NS_ooxml::LN_CT_PBdr_bottom:
1381 case NS_ooxml::LN_CT_PBdr_right:
1382 case NS_ooxml::LN_CT_PBdr_between:
1383 {
1384 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1385 if( pProperties )
1386 {
1387 auto pBorderHandler = std::make_shared<BorderHandler>( true );
1388 pProperties->resolve(*pBorderHandler);
1389 PropertyIds eBorderId = PropertyIds( 0 );
1390 PropertyIds eBorderDistId = PropertyIds( 0 );
1391 switch( nSprmId )
1392 {
1393 case NS_ooxml::LN_CT_PBdr_top:
1394 eBorderId = PROP_TOP_BORDER;
1395 eBorderDistId = PROP_TOP_BORDER_DISTANCE;
1396 break;
1397 case NS_ooxml::LN_CT_PBdr_left:
1398 eBorderId = PROP_LEFT_BORDER;
1399 eBorderDistId = PROP_LEFT_BORDER_DISTANCE;
1400 break;
1401 case NS_ooxml::LN_CT_PBdr_bottom:
1402 eBorderId = PROP_BOTTOM_BORDER ;
1403 eBorderDistId = PROP_BOTTOM_BORDER_DISTANCE;
1404 break;
1405 case NS_ooxml::LN_CT_PBdr_right:
1406 eBorderId = PROP_RIGHT_BORDER;
1407 eBorderDistId = PROP_RIGHT_BORDER_DISTANCE ;
1408 break;
1409 case NS_ooxml::LN_CT_PBdr_between:
1410 //not supported
1411 break;
1412 default:;
1413 }
1414 if( eBorderId )
1415 rContext->Insert( eBorderId, uno::makeAny( pBorderHandler->getBorderLine()) );
1416 if(eBorderDistId)
1417 rContext->Insert(eBorderDistId, uno::makeAny( pBorderHandler->getLineDistance()));
1418 if ( nSprmId == NS_ooxml::LN_CT_PBdr_right )
1419 {
1420 table::ShadowFormat aFormat;
1421 // Word only allows shadows on visible borders
1422 if ( pBorderHandler->getShadow() && pBorderHandler->getBorderLine().LineStyle != table::BorderLineStyle::NONE )
1423 aFormat = writerfilter::dmapper::PropertyMap::getShadowFromBorder(pBorderHandler->getBorderLine());
1424 rContext->Insert(PROP_PARA_SHADOW_FORMAT, uno::makeAny(aFormat));
1425 }
1426 }
1427 }
1428 break;
1429 case NS_ooxml::LN_CT_PBdr_bar:
1430 break;
1431 case NS_ooxml::LN_CT_PPrBase_suppressAutoHyphens:
1432 rContext->Insert(PROP_PARA_IS_HYPHENATION, uno::makeAny( nIntValue == 0 ));
1433 break;
1434 case NS_ooxml::LN_CT_FramePr_h:
1435 break;
1436 case NS_ooxml::LN_CT_PrBase_shd:
1437 {
1438 //contains fore color, back color and shadow percentage, results in a brush
1439 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1440 if( pProperties )
1441 {
1442 auto pCellColorHandler = std::make_shared<CellColorHandler>();
1443 pCellColorHandler->setOutputFormat( CellColorHandler::Paragraph );
1444 bool bEnableTempGrabBag = !pCellColorHandler->isInteropGrabBagEnabled();
1445 if( bEnableTempGrabBag )
1446 pCellColorHandler->enableInteropGrabBag( "TempShdPropsGrabBag" );
1447
1448 pProperties->resolve(*pCellColorHandler);
1449 rContext->InsertProps(pCellColorHandler->getProperties().get());
1450
1451 rContext->Insert(PROP_CHAR_THEME_FILL, pCellColorHandler->getInteropGrabBag().Value, true, PARA_GRAB_BAG);
1452 if(bEnableTempGrabBag)
1453 pCellColorHandler->disableInteropGrabBag();
1454 }
1455 }
1456 break;
1457 case NS_ooxml::LN_CT_FramePr_vSpace:
1458 break; // sprmPDyaFromText
1459 case NS_ooxml::LN_CT_FramePr_hSpace:
1460 break; // sprmPDxaFromText
1461 case NS_ooxml::LN_CT_FramePr_anchorLock:
1462 break;
1463 case NS_ooxml::LN_CT_PPrBase_widowControl:
1464 {
1465 uno::Any aVal( uno::makeAny( sal_Int8(nIntValue ? 2 : 0 )));
1466 rContext->Insert( PROP_PARA_WIDOWS, aVal );
1467 rContext->Insert( PROP_PARA_ORPHANS, aVal );
1468 }
1469 break; // sprmPFWidowControl
1470 case NS_ooxml::LN_CT_PPrBase_overflowPunct:
1471 rContext->Insert(PROP_PARA_IS_HANGING_PUNCTUATION, uno::makeAny( nIntValue == 0 ));
1472 break;
1473 case NS_ooxml::LN_CT_PPrBase_topLinePunct:
1474 break;
1475 case NS_ooxml::LN_CT_PPrBase_autoSpaceDE:
1476 break;
1477 case NS_ooxml::LN_CT_PPrBase_autoSpaceDN:
1478 break;
1479 case NS_ooxml::LN_CT_PPrBase_textAlignment:
1480 {
1481 sal_Int16 nAlignment = 0;
1482 switch (nIntValue)
1483 {
1484 case NS_ooxml::LN_Value_doc_ST_TextAlignment_top:
1485 nAlignment = 2;
1486 break;
1487 case NS_ooxml::LN_Value_doc_ST_TextAlignment_center:
1488 nAlignment = 3;
1489 break;
1490 case NS_ooxml::LN_Value_doc_ST_TextAlignment_baseline:
1491 nAlignment = 1;
1492 break;
1493 case NS_ooxml::LN_Value_doc_ST_TextAlignment_bottom:
1494 nAlignment = 4;
1495 break;
1496 case NS_ooxml::LN_Value_doc_ST_TextAlignment_auto:
1497 default:
1498 break;
1499 }
1500 rContext->Insert( PROP_PARA_VERT_ALIGNMENT, uno::makeAny( nAlignment) );
1501 }
1502 break;
1503 case NS_ooxml::LN_CT_PPrBase_textDirection:
1504 {
1505 switch (nIntValue)
1506 {
1507 case NS_ooxml::LN_Value_ST_TextDirection_tbRl:
1508 {
1509 m_pImpl->SetFrameDirection(text::WritingMode2::TB_RL);
1510 break;
1511 }
1512 case NS_ooxml::LN_Value_ST_TextDirection_btLr:
1513 {
1514 m_pImpl->SetFrameDirection(text::WritingMode2::BT_LR);
1515 break;
1516 }
1517 case NS_ooxml::LN_Value_ST_TextDirection_lrTbV:
1518 {
1519 m_pImpl->SetFrameDirection(text::WritingMode2::LR_TB);
1520 break;
1521 }
1522 case NS_ooxml::LN_Value_ST_TextDirection_tbRlV:
1523 {
1524 m_pImpl->SetFrameDirection(text::WritingMode2::TB_RL);
1525 break;
1526 }
1527 case NS_ooxml::LN_Value_ST_TextDirection_lrTb:
1528 case NS_ooxml::LN_Value_ST_TextDirection_tbLrV:
1529 default:
1530 SAL_WARN("writerfilter", "DomainMapper::sprmWithProps: unhandled textDirection")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "writerfilter")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "DomainMapper::sprmWithProps: unhandled textDirection"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("writerfilter"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1530" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "DomainMapper::sprmWithProps: unhandled textDirection"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "DomainMapper::sprmWithProps: unhandled textDirection"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("writerfilter"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1530" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "DomainMapper::sprmWithProps: unhandled textDirection"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("writerfilter"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1530" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "DomainMapper::sprmWithProps: unhandled textDirection"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "DomainMapper::sprmWithProps: unhandled textDirection"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("writerfilter"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1530" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1531 }
1532 }
1533 break;
1534 case NS_ooxml::LN_CT_PPrBase_outlineLvl:
1535 {
1536 sal_Int16 nLvl = static_cast< sal_Int16 >( nIntValue );
1537 if( IsStyleSheetImport() )
1538 {
1539
1540 StyleSheetPropertyMap* pStyleSheetPropertyMap = dynamic_cast< StyleSheetPropertyMap* >( rContext.get() );
1541 if (pStyleSheetPropertyMap)
1542 pStyleSheetPropertyMap->SetOutlineLevel( nLvl );
1543 }
1544 else
1545 {
1546 nLvl = nLvl >= WW_OUTLINE_MINsal_Int16( 0 ) && nLvl < WW_OUTLINE_MAXsal_Int16( 9 )? nLvl+1 : 0; //0 means no outline level set on
1547 rContext->Insert(PROP_OUTLINE_LEVEL, uno::makeAny ( nLvl ));
1548 }
1549 }
1550 break;
1551 case NS_ooxml::LN_CT_PPrBase_bidi:
1552 {
1553 // Four situations to handle:
1554 // 1.) bidi same as previous setting: no adjust change
1555 // 2.) no previous adjust: set appropriate default for this bidi
1556 // 3.) previous adjust and bidi different from previous: swap adjusts
1557 // 4.) previous adjust and no previous bidi: RTL swaps adjust
1558
1559 const sal_Int16 nWritingMode = nIntValue ? text::WritingMode2::RL_TB : text::WritingMode2::LR_TB;
1560 sal_Int16 nParentBidi = -1;
1561 m_pImpl->GetPropertyFromParaStyleSheet(PROP_WRITING_MODE) >>= nParentBidi;
1562 // Paragraph justification reverses its meaning in an RTL context.
1563 // 1. Only make adjustments if the BiDi changes.
1564 if ( nParentBidi != nWritingMode && !IsRTFImport() )
1565 {
1566 style::ParagraphAdjust eAdjust = style::ParagraphAdjust(-1);
1567 // 2. no adjust property exists yet
1568 if ( !(m_pImpl->GetAnyProperty(PROP_PARA_ADJUST, rContext) >>= eAdjust) )
1569 {
1570 // RTL defaults to right adjust
1571 eAdjust = nIntValue ? style::ParagraphAdjust_RIGHT : style::ParagraphAdjust_LEFT;
1572 rContext->Insert(PROP_PARA_ADJUST, uno::makeAny( eAdjust ), /*bOverwrite=*/false);
1573 }
1574 // 3,4. existing adjust: if RTL, then swap. If LTR, but previous was RTL, also swap.
1575 else if ( nIntValue || nParentBidi == sal_Int16(text::WritingMode2::RL_TB) )
1576 {
1577 if ( eAdjust == style::ParagraphAdjust_RIGHT )
1578 rContext->Insert(PROP_PARA_ADJUST, uno::makeAny( style::ParagraphAdjust_LEFT ));
1579 else if ( eAdjust == style::ParagraphAdjust_LEFT )
1580 rContext->Insert(PROP_PARA_ADJUST, uno::makeAny( style::ParagraphAdjust_RIGHT ));
1581 }
1582 }
1583 rContext->Insert(PROP_WRITING_MODE, uno::makeAny( nWritingMode ));
1584 }
1585
1586 break;
1587 case NS_ooxml::LN_EG_SectPrContents_bidi:
1588 if (pSectionContext != nullptr)
1589 {
1590 const sal_Int16 writingMode = (nIntValue != 0) ? sal_Int16(text::WritingMode2::RL_TB) : sal_Int16(text::WritingMode2::LR_TB);
1591 pSectionContext->Insert(PROP_WRITING_MODE, uno::makeAny(writingMode));
1592 }
1593 break;
1594 case NS_ooxml::LN_EG_RPrBase_highlight:
1595 {
1596 // OOXML import uses an ID
1597 if( IsOOXMLImport() )
1598 {
1599 sal_Int32 nColor = 0;
1600 if( getColorFromId(nIntValue, nColor) )
1601 rContext->Insert(PROP_CHAR_HIGHLIGHT, uno::makeAny( nColor ));
1602 }
1603 // RTF import uses the actual color value
1604 else if( IsRTFImport() )
1605 {
1606 rContext->Insert(PROP_CHAR_HIGHLIGHT, uno::makeAny( nIntValue ));
1607 }
1608 }
1609 break;
1610 case NS_ooxml::LN_EG_RPrBase_em:
1611 rContext->Insert(PROP_CHAR_EMPHASIS, uno::makeAny ( getEmphasisValue (nIntValue)));
1612 break;
1613 case NS_ooxml::LN_EG_RPrBase_emboss:
1614 case NS_ooxml::LN_EG_RPrBase_b:
1615 case NS_ooxml::LN_EG_RPrBase_bCs:
1616 case NS_ooxml::LN_EG_RPrBase_i:
1617 case NS_ooxml::LN_EG_RPrBase_iCs:
1618 case NS_ooxml::LN_EG_RPrBase_strike:
1619 case NS_ooxml::LN_EG_RPrBase_dstrike:
1620 case NS_ooxml::LN_EG_RPrBase_outline:
1621 case NS_ooxml::LN_EG_RPrBase_shadow:
1622 case NS_ooxml::LN_EG_RPrBase_caps:
1623 case NS_ooxml::LN_EG_RPrBase_smallCaps:
1624 case NS_ooxml::LN_EG_RPrBase_vanish:
1625 case NS_ooxml::LN_EG_RPrBase_webHidden:
1626 {
1627 PropertyIds ePropertyId = PROP_CHAR_WEIGHT; //initialized to prevent warning!
1628 switch( nSprmId )
1629 {
1630 case NS_ooxml::LN_EG_RPrBase_b:
1631 case NS_ooxml::LN_EG_RPrBase_bCs:
1632 ePropertyId = nSprmId != NS_ooxml::LN_EG_RPrBase_bCs ? PROP_CHAR_WEIGHT : PROP_CHAR_WEIGHT_COMPLEX;
1633 break;
1634 case NS_ooxml::LN_EG_RPrBase_i:
1635 case NS_ooxml::LN_EG_RPrBase_iCs:
1636 ePropertyId = nSprmId == NS_ooxml::LN_EG_RPrBase_i ? PROP_CHAR_POSTURE : PROP_CHAR_POSTURE_COMPLEX;
1637 break;
1638 case NS_ooxml::LN_EG_RPrBase_strike:
1639 case NS_ooxml::LN_EG_RPrBase_dstrike:
1640 ePropertyId = PROP_CHAR_STRIKEOUT;
1641 break;
1642 case NS_ooxml::LN_EG_RPrBase_outline:
1643 ePropertyId = PROP_CHAR_CONTOURED;
1644 break;
1645 case NS_ooxml::LN_EG_RPrBase_shadow:
1646 ePropertyId = PROP_CHAR_SHADOWED;
1647 break;
1648 case NS_ooxml::LN_EG_RPrBase_caps:
1649 case NS_ooxml::LN_EG_RPrBase_smallCaps:
1650 ePropertyId = PROP_CHAR_CASE_MAP;
1651 break;
1652 case NS_ooxml::LN_EG_RPrBase_vanish:
1653 case NS_ooxml::LN_EG_RPrBase_webHidden:
1654 ePropertyId = PROP_CHAR_HIDDEN;
1655 break;
1656 case NS_ooxml::LN_EG_RPrBase_emboss:
1657 ePropertyId = PROP_CHAR_RELIEF;
1658 break;
1659 }
1660 //expected: 0,1,128,129
1661 if(nIntValue != 128) //inherited from paragraph - ignore
1662 {
1663 if( nIntValue == 129) //inverted style sheet value
1664 {
1665 //get value from style sheet and invert it
1666 sal_Int16 nStyleValue = 0;
1667 uno::Any aStyleVal = m_pImpl->GetPropertyFromParaStyleSheet(ePropertyId);
1668 if( !aStyleVal.hasValue() )
1669 {
1670 nIntValue = NS_ooxml::LN_EG_RPrBase_smallCaps == nSprmId ?
1671 4 : 1;
1672 }
1673 else if(aStyleVal.getValueTypeClass() == uno::TypeClass_FLOAT )
1674 {
1675 double fDoubleValue = 0;
1676 //only in case of awt::FontWeight
1677 aStyleVal >>= fDoubleValue;
1678 nIntValue = fDoubleValue > 100. ? 0 : 1;
1679 }
1680 else if((aStyleVal >>= nStyleValue) ||
1681 (nStyleValue = static_cast<sal_Int16>(comphelper::getEnumAsINT32(aStyleVal))) >= 0 )
1682 {
1683 nIntValue = NS_ooxml::LN_EG_RPrBase_smallCaps == nSprmId ?
1684 nStyleValue ? 0 : 4 :
1685 nStyleValue ? 0 : 1;
1686 }
1687 else
1688 {
1689 OSL_FAIL( "what type was it")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1689" ": "), "%s", "what type was it"); } } while (false
)
;
1690 }
1691 }
1692
1693 switch( nSprmId )
1694 {
1695 case NS_ooxml::LN_EG_RPrBase_b:
1696 case NS_ooxml::LN_EG_RPrBase_bCs:
1697 {
1698 uno::Any aBold( uno::makeAny( nIntValue ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL ) );
1699
1700 rContext->Insert(ePropertyId, aBold );
1701 if( nSprmId != NS_ooxml::LN_EG_RPrBase_bCs )
1702 rContext->Insert(PROP_CHAR_WEIGHT_ASIAN, aBold );
1703
1704 uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
1705 if (xCharStyle.is())
1706 xCharStyle->setPropertyValue(getPropertyName(PROP_CHAR_WEIGHT), aBold);
1707 if (nSprmId == NS_ooxml::LN_EG_RPrBase_b)
1708 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "b", OUString::number(nIntValue));
1709 else if (nSprmId == NS_ooxml::LN_EG_RPrBase_bCs)
1710 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "bCs", OUString::number(nIntValue));
1711 }
1712 break;
1713 case NS_ooxml::LN_EG_RPrBase_i:
1714 case NS_ooxml::LN_EG_RPrBase_iCs:
1715 {
1716 uno::Any aPosture( uno::makeAny( nIntValue ? awt::FontSlant_ITALIC : awt::FontSlant_NONE ) );
1717 rContext->Insert( ePropertyId, aPosture );
1718 if (nSprmId != NS_ooxml::LN_EG_RPrBase_iCs)
1719 rContext->Insert(PROP_CHAR_POSTURE_ASIAN, aPosture );
1720 if (nSprmId == NS_ooxml::LN_EG_RPrBase_i)
1721 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "i", OUString::number(nIntValue));
1722 }
1723 break;
1724 case NS_ooxml::LN_EG_RPrBase_strike:
1725 rContext->Insert(ePropertyId,
1726 uno::makeAny( nIntValue ? awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE ) );
1727 break;
1728 case NS_ooxml::LN_EG_RPrBase_dstrike:
1729 rContext->Insert(ePropertyId,
1730 uno::makeAny( nIntValue ? awt::FontStrikeout::DOUBLE : awt::FontStrikeout::NONE ) );
1731 break;
1732 case NS_ooxml::LN_EG_RPrBase_outline:
1733 case NS_ooxml::LN_EG_RPrBase_shadow:
1734 case NS_ooxml::LN_EG_RPrBase_vanish:
1735 case NS_ooxml::LN_EG_RPrBase_webHidden:
1736 rContext->Insert(ePropertyId, uno::makeAny( nIntValue != 0 ));
1737 break;
1738 case NS_ooxml::LN_EG_RPrBase_smallCaps:
1739 // If smallcaps would be just disabled and another casemap is already inserted, don't do anything.
1740 if (nIntValue || !rContext->isSet(ePropertyId) )
1741 rContext->Insert(ePropertyId, uno::makeAny( nIntValue ? style::CaseMap::SMALLCAPS : style::CaseMap::NONE));
1742 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "smallCaps", OUString::number(nIntValue));
1743 break;
1744 case NS_ooxml::LN_EG_RPrBase_caps:
1745 rContext->Insert(ePropertyId,
1746 uno::makeAny( nIntValue ? style::CaseMap::UPPERCASE : style::CaseMap::NONE));
1747 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "caps", OUString::number(nIntValue));
1748 break;
1749 case NS_ooxml::LN_EG_RPrBase_emboss:
1750 rContext->Insert(ePropertyId,
1751 uno::makeAny( nIntValue ? awt::FontRelief::EMBOSSED : awt::FontRelief::NONE ));
1752 break;
1753
1754 }
1755 }
1756 }
1757 break;
1758 case NS_ooxml::LN_EG_RPrBase_sz:
1759 case NS_ooxml::LN_EG_RPrBase_szCs:
1760 {
1761 //multiples of half points (12pt == 24)
1762 double fVal = double(nIntValue) / 2.;
1763 uno::Any aVal = uno::makeAny( fVal );
1764 if( NS_ooxml::LN_EG_RPrBase_szCs == nSprmId )
1765 {
1766 rContext->Insert( PROP_CHAR_HEIGHT_COMPLEX, aVal );
1767 }
1768 else
1769 {
1770 const RubyInfo &aInfo = m_pImpl->GetRubyInfo();
1771 if (aInfo.nSprmId == NS_ooxml::LN_CT_Ruby_rt && aInfo.nHps > 0 )
1772 {
1773 fVal = double(aInfo.nHps) / 2.;
1774 aVal <<= fVal;
1775 }
1776 else if (aInfo.nSprmId == NS_ooxml::LN_CT_Ruby_rubyBase && aInfo.nHpsBaseText > 0 )
1777 {
1778 fVal = double(aInfo.nHpsBaseText) / 2.;
1779 aVal <<= fVal;
1780 }
1781 //Asian get the same value as Western
1782 rContext->Insert( PROP_CHAR_HEIGHT, aVal );
1783 rContext->Insert( PROP_CHAR_HEIGHT_ASIAN, aVal );
1784
1785 uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
1786 if (xCharStyle.is())
1787 xCharStyle->setPropertyValue(getPropertyName(PROP_CHAR_HEIGHT), aVal);
1788 }
1789 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, (nSprmId == NS_ooxml::LN_EG_RPrBase_sz ? OUString("sz") : OUString("szCs")), OUString::number(nIntValue));
1790 }
1791 break;
1792 case NS_ooxml::LN_EG_RPrBase_position:
1793 // The spec says 0 is the same as the lack of the value, so don't parse that.
1794 if ( nIntValue )
1795 {
1796 if ( !IsStyleSheetImport() )
1797 m_pImpl->deferCharacterProperty( nSprmId, uno::makeAny( nIntValue ));
1798 else
1799 {
1800 // DON'T FIXME: Truly calculating this for Character Styles will be tricky,
1801 // because it depends on the final fontsize - regardless of
1802 // where it is set. So at the style level,
1803 // the escapement value would need to be grabbagged.
1804 // At appendText time the final fontsize needs to be determined, and then
1805 // the escapement can be calculated from the grabbag'd half-point value
1806 // and directly applied. Yuck.
1807 // It seems best to just treat charstyle escapement like
1808 // pre-commit e70df84352d3670508a4666c97df44f82c1ce934
1809 // which just assigned default values and ignored the actual/given escapement.
1810 sal_Int16 nEscapement = nIntValue > 0 ? DFLT_ESC_AUTO_SUPER(13999 +1) : DFLT_ESC_AUTO_SUB-(13999 +1);
1811 sal_Int8 nProp = DFLT_ESC_PROP58;
1812 rContext->Insert(PROP_CHAR_ESCAPEMENT, uno::makeAny( nEscapement ) );
1813 rContext->Insert(PROP_CHAR_ESCAPEMENT_HEIGHT, uno::makeAny( nProp ) );
1814 }
1815 }
1816 break;
1817 case NS_ooxml::LN_EG_RPrBase_spacing:
1818 {
1819 //Kerning half point values
1820 //TODO: there are two kerning values -
1821 // in ww8par6.cxx NS_sprm::LN_CHpsKern is used as boolean AutoKerning
1822 sal_Int16 nResult = static_cast<sal_Int16>(ConversionHelper::convertTwipToMM100(nIntValue));
1823 if (m_pImpl->IsInComments())
1824 {
1825 nResult = static_cast<sal_Int16>(nIntValue);
1826 }
1827 rContext->Insert(PROP_CHAR_CHAR_KERNING, uno::makeAny(nResult));
1828 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "spacing", OUString::number(nIntValue));
1829 }
1830 break;
1831 case NS_ooxml::LN_EG_RPrBase_kern: // auto kerning is bound to a minimum font size in Word - but not in Writer :-(
1832 rContext->Insert(PROP_CHAR_AUTO_KERNING, uno::makeAny( nIntValue != 0 ) );
1833 break;
1834 case NS_ooxml::LN_EG_RPrBase_w:
1835 // ST_TextScale must fall between 1% and 600% according to spec, otherwise resets to 100% according to experience
1836 if ((1 <= nIntValue) && (nIntValue <= 600))
1837 {
1838 rContext->Insert(PROP_CHAR_SCALE_WIDTH,
1839 uno::makeAny( sal_Int16(nIntValue) ));
1840 }
1841 else
1842 {
1843 rContext->Insert(PROP_CHAR_SCALE_WIDTH,
1844 uno::makeAny( sal_Int16(100) ));
1845 }
1846 break;
1847 case NS_ooxml::LN_EG_RPrBase_imprint:
1848 // FontRelief: NONE, EMBOSSED, ENGRAVED
1849 rContext->Insert(PROP_CHAR_RELIEF,
1850 uno::makeAny( nIntValue ? awt::FontRelief::ENGRAVED : awt::FontRelief::NONE ));
1851 break;
1852 case NS_ooxml::LN_EG_RPrBase_effect:
1853 // The file-format has many character animations. We have only
1854 // one, so we use it always. Suboptimal solution though.
1855 if (nIntValue != NS_ooxml::LN_Value_ST_TextEffect_none)
1856 rContext->Insert(PROP_CHAR_FLASH, uno::makeAny( true ));
1857 else
1858 rContext->Insert(PROP_CHAR_FLASH, uno::makeAny( false ));
1859 break;
1860 case NS_ooxml::LN_EG_RPrBase_rtl:
1861 break;
1862 case NS_ooxml::LN_EG_RPrBase_shd:
1863 {
1864 //contains fore color, back color and shadow percentage, results in a brush
1865 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1866 if( pProperties )
1867 {
1868 auto pCellColorHandler = std::make_shared<CellColorHandler>();
1869 pCellColorHandler->setOutputFormat( CellColorHandler::Character );
1870 pProperties->resolve(*pCellColorHandler);
1871 rContext->InsertProps(pCellColorHandler->getProperties().get());
1872 m_pImpl->GetTopContext()->Insert(PROP_CHAR_SHADING_MARKER, uno::makeAny(true), true, CHAR_GRAB_BAG );
1873 }
1874 break;
1875 }
1876 case NS_ooxml::LN_EG_SectPrContents_type:
1877 /* break type
1878 0 - No break
1879 1 - New Column
1880 2 - New page
1881 3 - Even page
1882 4 - odd page
1883 */
1884 OSL_ENSURE(pSectionContext, "SectionContext unavailable!")do { if (true && (!(pSectionContext))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1884" ": "), "%s", "SectionContext unavailable!"); } } while
(false)
;
1885 if(pSectionContext)
1886 {
1887 //continuous break only allowed if it is not the only section break
1888 SectionPropertyMap* pLastContext = m_pImpl->GetLastSectionContext();
1889 if ( nIntValue != static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_continuous) || pLastContext || m_pImpl->GetParaSectpr() )
1890 pSectionContext->SetBreakType( nIntValue );
1891 }
1892 break;
1893 case NS_ooxml::LN_EG_SectPrContents_titlePg:
1894 {
1895 OSL_ENSURE(pSectionContext, "SectionContext unavailable!")do { if (true && (!(pSectionContext))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "1895" ": "), "%s", "SectionContext unavailable!"); } } while
(false)
;
1896 if(pSectionContext)
1897 pSectionContext->SetTitlePage( nIntValue > 0 );//section has title page
1898 }
1899 break;
1900 case 165:
1901 {
1902 //page height, rounded to default values, default: 0x3dc0 twip
1903 sal_Int32 nHeight = ConversionHelper::convertTwipToMM100( nIntValue );
1904 rContext->Insert( PROP_HEIGHT, uno::makeAny( PaperInfo::sloppyFitPageDimension( nHeight ) ) );
1905 }
1906 break;
1907 case NS_ooxml::LN_EG_SectPrContents_textDirection:
1908 {
1909 /* 0 HoriLR 1 Vert TR 2 Vert TR 3 Vert TT 4 HoriLT
1910 only 0 and 1 can be imported correctly
1911 */
1912 text::WritingMode nDirection = text::WritingMode_LR_TB;
1913 switch( nIntValue )
1914 {
1915 case NS_ooxml::LN_Value_ST_TextDirection_lrTb:
1916 case NS_ooxml::LN_Value_ST_TextDirection_lrTbV:
1917 nDirection = text::WritingMode_LR_TB;
1918 break;
1919 case NS_ooxml::LN_Value_ST_TextDirection_tbRl:
1920 case NS_ooxml::LN_Value_ST_TextDirection_btLr:
1921 nDirection = text::WritingMode_TB_RL;
1922 break;
1923 default:;
1924 }
1925
1926 PropertyMap * pTargetContext = rContext.get();
1927
1928 if (pSectionContext)
1929 {
1930 pTargetContext = pSectionContext;
1931 }
1932
1933 pTargetContext->Insert(PROP_WRITING_MODE, uno::makeAny( sal_Int16(nDirection) ) );
1934 }
1935 break; // sprmSTextFlow
1936 // the following are not part of the official documentation
1937 case NS_ooxml::LN_CT_Tabs_tab:
1938 resolveSprmProps(*this, rSprm);
1939 m_pImpl->IncorporateTabStop(m_pImpl->m_aCurrentTabStop);
1940 m_pImpl->m_aCurrentTabStop = DeletableTabStop();
1941 break;
1942 case NS_ooxml::LN_CT_PPrBase_tabs:
1943 {
1944 // Initialize tab stop vector from style sheet
1945 // fdo#81033: for RTF, a tab stop is inherited from the style if it
1946 // is also applied to the paragraph directly, and cleared if it is
1947 // not applied to the paragraph directly => don't InitTabStopFromStyle
1948 if ( !IsRTFImport() )
1949 {
1950 uno::Any aValue = m_pImpl->GetPropertyFromParaStyleSheet(PROP_PARA_TAB_STOPS);
1951 uno::Sequence< style::TabStop > aStyleTabStops;
1952 if(aValue >>= aStyleTabStops)
1953 {
1954 m_pImpl->InitTabStopFromStyle( aStyleTabStops );
1955 }
1956 }
1957 resolveSprmProps(*this, rSprm);
1958 rContext->Insert(PROP_PARA_TAB_STOPS, uno::makeAny( m_pImpl->GetCurrentTabStopAndClear()));
1959 }
1960 break;
1961
1962 case NS_ooxml::LN_CT_DocDefaults_pPrDefault:
1963 case NS_ooxml::LN_CT_DocDefaults_rPrDefault:
1964 GetStyleSheetTable()->sprm( rSprm );
1965 break;
1966 case NS_ooxml::LN_EG_RPrBase_bdr:
1967 {
1968 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1969 if( pProperties )
1970 {
1971 auto pBorderHandler = std::make_shared<BorderHandler>( true );
1972 pProperties->resolve(*pBorderHandler);
1973
1974 rContext->Insert( PROP_CHAR_TOP_BORDER, uno::makeAny( pBorderHandler->getBorderLine()));
1975 rContext->Insert( PROP_CHAR_BOTTOM_BORDER, uno::makeAny( pBorderHandler->getBorderLine()));
1976 rContext->Insert( PROP_CHAR_LEFT_BORDER, uno::makeAny( pBorderHandler->getBorderLine()));
1977 rContext->Insert( PROP_CHAR_RIGHT_BORDER, uno::makeAny( pBorderHandler->getBorderLine()));
1978
1979 rContext->Insert( PROP_CHAR_TOP_BORDER_DISTANCE, uno::makeAny( pBorderHandler->getLineDistance()));
1980 rContext->Insert( PROP_CHAR_BOTTOM_BORDER_DISTANCE, uno::makeAny( pBorderHandler->getLineDistance()));
1981 rContext->Insert( PROP_CHAR_LEFT_BORDER_DISTANCE, uno::makeAny( pBorderHandler->getLineDistance()));
1982 rContext->Insert( PROP_CHAR_RIGHT_BORDER_DISTANCE, uno::makeAny( pBorderHandler->getLineDistance()));
1983
1984 table::ShadowFormat aFormat;
1985 // Word only allows shadows on visible borders
1986 if ( pBorderHandler->getShadow() && pBorderHandler->getBorderLine().LineStyle != table::BorderLineStyle::NONE )
1987 aFormat = writerfilter::dmapper::PropertyMap::getShadowFromBorder(pBorderHandler->getBorderLine());
1988 rContext->Insert(PROP_CHAR_SHADOW_FORMAT, uno::makeAny(aFormat));
1989 }
1990 }
1991 break;
1992 case NS_ooxml::LN_CT_PPr_sectPr:
1993 case NS_ooxml::LN_EG_RPrBase_color:
1994 case NS_ooxml::LN_EG_RPrBase_rFonts:
1995 case NS_ooxml::LN_EG_RPrBase_eastAsianLayout:
1996 case NS_ooxml::LN_EG_RPrBase_u:
1997 case NS_ooxml::LN_EG_RPrBase_lang:
1998 case NS_ooxml::LN_CT_PPrBase_spacing:
1999 case NS_ooxml::LN_CT_PPrBase_ind:
2000 case NS_ooxml::LN_CT_RPrDefault_rPr:
2001 case NS_ooxml::LN_CT_PPrDefault_pPr:
2002 case NS_ooxml::LN_CT_Style_pPr:
2003 case NS_ooxml::LN_CT_Style_rPr:
2004 case NS_ooxml::LN_CT_PPr_rPr:
2005 case NS_ooxml::LN_CT_PPrBase_numPr:
2006 {
2007 bool bTempGrabBag = !m_pImpl->isInteropGrabBagEnabled();
2008 if (nSprmId == NS_ooxml::LN_CT_PPr_sectPr)
2009 m_pImpl->SetParaSectpr(true);
2010 else if (nSprmId == NS_ooxml::LN_EG_RPrBase_color && bTempGrabBag)
2011 // if DomainMapper grab bag is not enabled, enable it temporarily
2012 m_pImpl->enableInteropGrabBag("TempColorPropsGrabBag");
2013 resolveSprmProps(*this, rSprm);
2014 if (nSprmId == NS_ooxml::LN_CT_PPrBase_spacing)
2015 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "spacing", m_pImpl->m_aSubInteropGrabBag);
2016 else if (nSprmId == NS_ooxml::LN_EG_RPrBase_rFonts)
2017 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "rFonts", m_pImpl->m_aSubInteropGrabBag);
2018 else if (nSprmId == NS_ooxml::LN_EG_RPrBase_lang)
2019 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lang", m_pImpl->m_aSubInteropGrabBag);
2020 else if (nSprmId == NS_ooxml::LN_EG_RPrBase_color)
2021 {
2022 for (const auto& rItem : m_pImpl->m_aSubInteropGrabBag)
2023 {
2024 if (rItem.Name == "val")
2025 m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_ORIGINAL_COLOR, rItem.Value, true, CHAR_GRAB_BAG);
2026 else if (rItem.Name == "themeColor")
2027 m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR, rItem.Value, true, CHAR_GRAB_BAG);
2028 else if (rItem.Name == "themeShade")
2029 m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR_SHADE, rItem.Value, true, CHAR_GRAB_BAG);
2030 else if (rItem.Name == "themeTint")
2031 m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR_TINT, rItem.Value, true, CHAR_GRAB_BAG);
2032 }
2033 if (bTempGrabBag)
2034 //disable and clear DomainMapper grab bag if it wasn't enabled before
2035 m_pImpl->disableInteropGrabBag();
2036
2037 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "color", m_pImpl->m_aSubInteropGrabBag);
2038 }
2039 else if (nSprmId == NS_ooxml::LN_CT_PPrBase_ind)
2040 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ind", m_pImpl->m_aSubInteropGrabBag);
2041 }
2042 break;
2043 case NS_ooxml::LN_CT_PPrBase_wordWrap:
2044 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "wordWrap", "");
2045 break;
2046 case NS_ooxml::LN_EG_SectPrContents_footnotePr:
2047 case NS_ooxml::LN_EG_SectPrContents_endnotePr:
2048 m_pImpl->SetInFootnoteProperties( NS_ooxml::LN_EG_SectPrContents_footnotePr == nSprmId );
2049 resolveSprmProps(*this, rSprm);
2050 break;
2051 case NS_ooxml::LN_EG_SectPrContents_lnNumType:
2052 {
2053 resolveSprmProps(*this, rSprm);
2054 LineNumberSettings aSettings = m_pImpl->GetLineNumberSettings();
2055 m_pImpl->SetLineNumberSettings( aSettings );
2056 //apply settings at XLineNumberingProperties
2057 try
2058 {
2059 uno::Reference< text::XLineNumberingProperties > xLineNumberingProperties( m_pImpl->GetTextDocument(), uno::UNO_QUERY_THROW );
2060 uno::Reference< beans::XPropertySet > xLineNumberingPropSet = xLineNumberingProperties->getLineNumberingProperties();
2061 if( aSettings.nInterval == 0 )
2062 xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_IS_ON ), uno::makeAny(false) );
2063 else
2064 {
2065 xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_IS_ON ), uno::makeAny(true) );
2066 if( aSettings.nInterval )
2067 xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_INTERVAL ), uno::makeAny(static_cast<sal_Int16>(aSettings.nInterval)) );
2068 if( aSettings.nDistance != -1 )
2069 xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_DISTANCE ), uno::makeAny(aSettings.nDistance) );
2070 else
2071 {
2072 // set Auto value (0.5 cm)
2073 xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_DISTANCE ), uno::makeAny(static_cast<sal_Int32>(500)) );
2074 if( pSectionContext )
2075 pSectionContext->SetdxaLnn( static_cast<sal_Int32>(283) );
2076 }
2077 xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_RESTART_AT_EACH_PAGE ), uno::makeAny(aSettings.bRestartAtEachPage) );
2078 }
2079 }
2080 catch( const uno::Exception& )
2081 {
2082 }
2083
2084 }
2085 break;
2086 case NS_ooxml::LN_CT_PPrBase_framePr:
2087 // Avoid frames if we're inside a structured document tag, would just cause outer tables fail to create.
2088 if (!m_pImpl->GetSdt())
2089 {
2090 PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
2091 if( pContext )
2092 {
2093 // If there is a deferred page break applied to this framed paragraph,
2094 // create a dummy paragraph without extra properties,
2095 // so that the anchored frame will be on the correct page (similar to shapes).
2096 if (pContext->isSet(PROP_BREAK_TYPE))
2097 {
2098 pContext->Erase(PROP_BREAK_TYPE);
2099
2100 lcl_startParagraphGroup();
2101 m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE));
2102 lcl_startCharacterGroup();
2103 sal_uInt8 const sBreak[] = { 0xd };
2104 lcl_text(sBreak, 1);
2105 lcl_endCharacterGroup();
2106 lcl_endParagraphGroup();
2107 }
2108
2109 ParagraphPropertyMap* pParaContext = dynamic_cast< ParagraphPropertyMap* >( pContext.get() );
2110 if (pParaContext)
2111 pParaContext->SetFrameMode();
2112
2113 if (!IsInHeaderFooter())
2114 m_pImpl->m_bIsActualParagraphFramed = true;
2115 }
2116 else
2117 {
2118 //TODO: What about style sheet import of frame properties
2119 }
2120 m_pImpl->NewFrameDirection();
2121 resolveSprmProps(*this, rSprm);
2122 }
2123 break;
2124 case NS_ooxml::LN_EG_SectPrContents_pgSz:
2125 {
2126 PaperInfo aLetter(PAPER_LETTER);
2127 CT_PageSz.w = aLetter.getWidth();
2128 CT_PageSz.h = aLetter.getHeight();
2129 }
2130 CT_PageSz.orient = false;
2131 resolveSprmProps(*this, rSprm);
2132 OSL_ENSURE(pSectionContext, "SectionContext unavailable!")do { if (true && (!(pSectionContext))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "2132" ": "), "%s", "SectionContext unavailable!"); } } while
(false)
;
2133 if(pSectionContext)
2134 {
2135 pSectionContext->Insert( PROP_HEIGHT, uno::makeAny( CT_PageSz.h ) );
2136 pSectionContext->Insert( PROP_IS_LANDSCAPE, uno::makeAny( CT_PageSz.orient ));
2137 pSectionContext->Insert( PROP_WIDTH, uno::makeAny( CT_PageSz.w ) );
2138 }
2139 break;
2140
2141 case NS_ooxml::LN_EG_SectPrContents_pgMar:
2142 m_pImpl->InitPageMargins();
2143 resolveSprmProps(*this, rSprm);
2144 OSL_ENSURE(pSectionContext, "SectionContext unavailable!")do { if (true && (!(pSectionContext))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "2144" ": "), "%s", "SectionContext unavailable!"); } } while
(false)
;
2145 if(pSectionContext)
2146 {
2147 const PageMar& rPageMar = m_pImpl->GetPageMargins();
2148 pSectionContext->SetTopMargin( rPageMar.top );
2149 pSectionContext->SetRightMargin( rPageMar.right );
2150 pSectionContext->SetBottomMargin( rPageMar.bottom );
2151 pSectionContext->SetLeftMargin( rPageMar.left );
2152 pSectionContext->SetHeaderTop( rPageMar.header );
2153 pSectionContext->SetHeaderBottom( rPageMar.footer );
2154 }
2155 break;
2156
2157 case NS_ooxml::LN_EG_SectPrContents_cols:
2158 {
2159 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2160 if( pProperties )
2161 {
2162
2163 tools::SvRef< SectionColumnHandler > pSectHdl( new SectionColumnHandler );
2164 pProperties->resolve(*pSectHdl);
2165 if(pSectionContext && !m_pImpl->isInIndexContext())
2166 {
2167 sal_Int16 nColumnCount = pSectHdl->GetNum() == 1 ? 0 : pSectHdl->GetNum();
2168 if( pSectHdl->IsEqualWidth() )
2169 {
2170 pSectionContext->SetEvenlySpaced( true );
2171 pSectionContext->SetColumnCount( nColumnCount );
2172 pSectionContext->SetColumnDistance( pSectHdl->GetSpace() );
2173 pSectionContext->SetSeparatorLine( pSectHdl->IsSeparator() );
2174 }
2175 else if( !pSectHdl->GetColumns().empty() )
2176 {
2177 pSectionContext->SetEvenlySpaced( false );
2178 pSectionContext->SetColumnDistance( pSectHdl->GetSpace() );
2179 nColumnCount = pSectHdl->GetColumns().size();
2180 pSectionContext->SetColumnCount( nColumnCount == 1 ? 0 : nColumnCount );
2181 std::vector<Column_>::const_iterator tmpIter = pSectHdl->GetColumns().begin();
2182 for (; tmpIter != pSectHdl->GetColumns().end(); ++tmpIter)
2183 {
2184 pSectionContext->AppendColumnWidth( tmpIter->nWidth );
2185 if ((tmpIter != pSectHdl->GetColumns().end() - 1) || (tmpIter->nSpace > 0))
2186 pSectionContext->AppendColumnSpacing( tmpIter->nSpace );
2187 }
2188 pSectionContext->SetSeparatorLine( pSectHdl->IsSeparator() );
2189 }
2190 else if( nColumnCount )
2191 {
2192 pSectionContext->SetColumnCount( nColumnCount );
2193 pSectionContext->SetColumnDistance( pSectHdl->GetSpace() );
2194 pSectionContext->SetSeparatorLine( pSectHdl->IsSeparator() );
2195 }
2196 }
2197
2198 else if ( pSectionContext )
2199 {
2200 FieldContextPtr pContext = m_pImpl->GetTopFieldContext();
2201 uno::Reference< beans::XPropertySet > xTOC = pContext->GetTOC();
2202 if( xTOC.is() )
2203 {
2204 uno::Reference<text::XTextColumns> xTextColumns;
2205 xTOC->getPropertyValue(getPropertyName( PROP_TEXT_COLUMNS )) >>= xTextColumns;
2206 if (xTextColumns.is())
2207 {
2208 uno::Reference< beans::XPropertySet > xColumnPropSet( xTextColumns, uno::UNO_QUERY_THROW );
2209 xColumnPropSet->setPropertyValue( getPropertyName( PROP_AUTOMATIC_DISTANCE ), uno::makeAny( pSectHdl->GetSpace() ));
2210 xTOC->setPropertyValue( getPropertyName( PROP_TEXT_COLUMNS ), uno::makeAny( xTextColumns ) );
2211 }
2212 }
2213 }
2214 }
2215 }
2216 break;
2217 case NS_ooxml::LN_EG_SectPrContents_docGrid:
2218 resolveSprmProps(*this, rSprm);
2219 break;
2220 case NS_ooxml::LN_EG_SectPrContents_pgBorders:
2221 {
2222 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2223 if( pProperties && pSectionContext )
2224 {
2225 tools::SvRef< PageBordersHandler > pHandler( new PageBordersHandler );
2226 pProperties->resolve( *pHandler );
2227
2228 // Set the borders to the context and apply them to the styles
2229 pHandler->SetBorders( pSectionContext );
2230 }
2231 }
2232 break;
2233
2234 case NS_ooxml::LN_CT_PPrBase_snapToGrid:
2235 if (!IsStyleSheetImport()||!m_pImpl->isInteropGrabBagEnabled())
2236 {
2237 rContext->Insert( PROP_SNAP_TO_GRID, uno::makeAny(bool(nIntValue)));
2238 }
2239 else
2240 {
2241 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "snapToGrid", OUString::number(nIntValue));
2242 }
2243 break;
2244 case NS_ooxml::LN_CT_PPrBase_pStyle:
2245 {
2246 StyleSheetTablePtr pStyleTable = m_pImpl->GetStyleSheetTable();
2247 const OUString sConvertedStyleName = pStyleTable->ConvertStyleName( sStringValue, true );
2248 m_pImpl->SetCurrentParaStyleName( sConvertedStyleName );
2249 if (m_pImpl->GetTopContext() && m_pImpl->GetTopContextType() != CONTEXT_SECTION)
2250 m_pImpl->GetTopContext()->Insert( PROP_PARA_STYLE_NAME, uno::makeAny( sConvertedStyleName ));
2251 }
2252 break;
2253 case NS_ooxml::LN_EG_RPrBase_rStyle:
2254 {
2255 OUString sConvertedName( m_pImpl->GetStyleSheetTable()->ConvertStyleName( sStringValue, true ) );
2256 if (m_pImpl->CheckFootnoteStyle())
2257 m_pImpl->SetHasFootnoteStyle(m_pImpl->GetFootnoteContext()->GetFootnoteStyle() == sConvertedName);
2258
2259 // First check if the style exists in the document.
2260 StyleSheetEntryPtr pEntry = m_pImpl->GetStyleSheetTable( )->FindStyleSheetByConvertedStyleName( sConvertedName );
2261 bool bExists = pEntry && ( pEntry->nStyleTypeCode == STYLE_TYPE_CHAR );
2262 // Add the property if the style exists, but do not add it elements in TOC:
2263 // they will receive later another style references from TOC
2264 if ( bExists && m_pImpl->GetTopContext() && !m_pImpl->IsInTOC())
2265 m_pImpl->GetTopContext()->Insert( PROP_CHAR_STYLE_NAME, uno::makeAny( sConvertedName ) );
2266 }
2267 break;
2268 case NS_ooxml::LN_CT_TblPrBase_tblCellMar: //cell margins
2269 {
2270 resolveSprmProps(*this, rSprm);//contains LN_CT_TblCellMar_top, LN_CT_TblCellMar_left, LN_CT_TblCellMar_bottom, LN_CT_TblCellMar_right
2271 }
2272 break;
2273 case NS_ooxml::LN_CT_TblCellMar_top:
2274 case NS_ooxml::LN_CT_TblCellMar_start:
2275 case NS_ooxml::LN_CT_TblCellMar_left:
2276 case NS_ooxml::LN_CT_TblCellMar_bottom:
2277 case NS_ooxml::LN_CT_TblCellMar_end:
2278 case NS_ooxml::LN_CT_TblCellMar_right:
2279 {
2280 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2281 if( pProperties )
2282 {
2283 MeasureHandlerPtr pMeasureHandler( new MeasureHandler );
2284 pProperties->resolve(*pMeasureHandler);
2285 sal_Int32 nMeasureValue = pMeasureHandler->getMeasureValue();
2286 PropertyIds eId = META_PROP_CELL_MAR_TOP;
2287 bool rtl = false; // TODO
2288 switch(nSprmId)
2289 {
2290 case NS_ooxml::LN_CT_TblCellMar_top:
2291 break;
2292 case NS_ooxml::LN_CT_TblCellMar_start:
2293 eId = rtl ? META_PROP_CELL_MAR_RIGHT : META_PROP_CELL_MAR_LEFT;
2294 break;
2295 case NS_ooxml::LN_CT_TblCellMar_left:
2296 eId = META_PROP_CELL_MAR_LEFT;
2297 break;
2298 case NS_ooxml::LN_CT_TblCellMar_bottom:
2299 eId = META_PROP_CELL_MAR_BOTTOM;
2300 break;
2301 case NS_ooxml::LN_CT_TblCellMar_end:
2302 eId = rtl ? META_PROP_CELL_MAR_LEFT : META_PROP_CELL_MAR_RIGHT;
2303 break;
2304 case NS_ooxml::LN_CT_TblCellMar_right:
2305 eId = META_PROP_CELL_MAR_RIGHT;
2306 break;
2307 default:;
2308 }
2309 rContext->Insert( eId, uno::makeAny(nMeasureValue), false);
2310 }
2311 }
2312 break;
2313 case NS_ooxml::LN_EG_RPrBase_noProof: // no grammar and spell checking, unsupported
2314 break;
2315 case NS_ooxml::LN_anchor_anchor: // at_character drawing
2316 case NS_ooxml::LN_inline_inline: // as_character drawing
2317 {
2318 if ( m_pImpl->IsDiscardHeaderFooter() )
2319 break;
2320 //tdf112342: Break before images as well, if there are page break
2321 if (m_pImpl->isBreakDeferred(BreakType::PAGE_BREAK))
2322 {
2323 m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)
2324 ->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE));
2325 m_pImpl->clearDeferredBreak(PAGE_BREAK);
2326 }
2327 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2328 if( pProperties )
2329 {
2330 GraphicImportType eGraphicType =
2331 (NS_ooxml::LN_anchor_anchor ==
2332 sal::static_int_cast<Id>(nSprmId)) ?
2333 IMPORT_AS_DETECTED_ANCHOR :
2334 IMPORT_AS_DETECTED_INLINE;
2335 GraphicImportPtr pGraphicImport =
2336 m_pImpl->GetGraphicImport(eGraphicType);
2337 pProperties->resolve(*pGraphicImport);
2338 m_pImpl->ImportGraphic(pProperties, eGraphicType);
2339 if( !pGraphicImport->IsGraphic() )
2340 {
2341 m_pImpl->ResetGraphicImport();
2342 // todo: It's a shape, now start shape import
2343 }
2344 }
2345 }
2346 break;
2347 case NS_ooxml::LN_EG_RPrBase_vertAlign:
2348 {
2349 sal_Int16 nEscapement = 0;
2350 sal_Int8 nProp = DFLT_ESC_PROP58;
2351 if ( sStringValue == "superscript" )
2352 nEscapement = DFLT_ESC_AUTO_SUPER(13999 +1);
2353 else if ( sStringValue == "subscript" )
2354 nEscapement = DFLT_ESC_AUTO_SUB-(13999 +1);
2355 else
2356 nProp = 100;
2357
2358 rContext->Insert(PROP_CHAR_ESCAPEMENT, uno::makeAny( nEscapement ) );
2359 rContext->Insert(PROP_CHAR_ESCAPEMENT_HEIGHT, uno::makeAny( nProp ) );
2360 }
2361 break;
2362 case NS_ooxml::LN_CT_FtnProps_pos:
2363 //footnotes in word can be at page end or beneath text - writer supports only the first
2364 //endnotes in word can be at section end or document end - writer supports only the latter
2365 // -> so this property can be ignored
2366 break;
2367 case NS_ooxml::LN_CT_FtnProps_numFmt:
2368 case NS_ooxml::LN_CT_EdnProps_numFmt:
2369 {
2370 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2371 if (pProperties)
2372 {
2373 pProperties->resolve(*this);
2374 }
2375 }
2376 break;
2377 case NS_ooxml::LN_EG_FtnEdnNumProps_numStart:
2378 case NS_ooxml::LN_EG_FtnEdnNumProps_numRestart:
2379 {
2380 try
2381 {
2382 uno::Reference< beans::XPropertySet > xFtnEdnSettings;
2383 if( m_pImpl->IsInFootnoteProperties() )
2384 {
2385 uno::Reference< text::XFootnotesSupplier> xFootnotesSupplier( m_pImpl->GetTextDocument(), uno::UNO_QUERY );
2386 if (xFootnotesSupplier.is())
2387 xFtnEdnSettings = xFootnotesSupplier->getFootnoteSettings();
2388 }
2389 else
2390 {
2391 uno::Reference< text::XEndnotesSupplier> xEndnotesSupplier( m_pImpl->GetTextDocument(), uno::UNO_QUERY );
2392 if (xEndnotesSupplier.is())
2393 xFtnEdnSettings = xEndnotesSupplier->getEndnoteSettings();
2394 }
2395 if( NS_ooxml::LN_EG_FtnEdnNumProps_numStart == nSprmId && xFtnEdnSettings.is())
2396 {
2397 xFtnEdnSettings->setPropertyValue(
2398 getPropertyName( PROP_START_AT),
2399 uno::makeAny( sal_Int16( nIntValue - 1 )));
2400 }
2401 else if( NS_ooxml::LN_EG_FtnEdnNumProps_numRestart == nSprmId && xFtnEdnSettings.is())
2402 {
2403 sal_Int16 nFootnoteCounting = 0;
2404 switch (nIntValue)
2405 {
2406 case NS_ooxml::LN_Value_ST_RestartNumber_continuous: nFootnoteCounting = text::FootnoteNumbering::PER_DOCUMENT; break;
2407 case NS_ooxml::LN_Value_ST_RestartNumber_eachPage: nFootnoteCounting = text::FootnoteNumbering::PER_PAGE; break;
2408 case NS_ooxml::LN_Value_ST_RestartNumber_eachSect: nFootnoteCounting = text::FootnoteNumbering::PER_CHAPTER; break;
2409 default: break;
2410 }
2411 xFtnEdnSettings->setPropertyValue(
2412 getPropertyName( PROP_FOOTNOTE_COUNTING ),
2413 uno::makeAny( nFootnoteCounting ));
2414 }
2415 else if (xFtnEdnSettings.is())
2416 {
2417 sal_Int16 nNumType = ConversionHelper::ConvertNumberingType( nIntValue );
2418 xFtnEdnSettings->setPropertyValue(
2419 getPropertyName( PROP_NUMBERING_TYPE),
2420 uno::makeAny( nNumType ));
2421 }
2422 }
2423 catch( const uno::Exception& )
2424 {
2425 }
2426 }
2427 break;
2428 case NS_ooxml::LN_paratrackchange:
2429 m_pImpl->StartParaMarkerChange( );
2430 [[fallthrough]];
2431 case NS_ooxml::LN_CT_PPr_pPrChange:
2432 case NS_ooxml::LN_CT_ParaRPr_rPrChange:
2433 case NS_ooxml::LN_trackchange:
2434 case NS_ooxml::LN_EG_RPrContent_rPrChange:
2435 case NS_ooxml::LN_EG_RangeMarkupElements_customXmlDelRangeStart:
2436 case NS_ooxml::LN_EG_RangeMarkupElements_customXmlDelRangeEnd:
2437 case NS_ooxml::LN_EG_RangeMarkupElements_customXmlMoveFromRangeStart:
2438 case NS_ooxml::LN_EG_RangeMarkupElements_customXmlMoveFromRangeEnd:
2439 case NS_ooxml::LN_EG_RangeMarkupElements_customXmlMoveToRangeStart:
2440 case NS_ooxml::LN_EG_RangeMarkupElements_customXmlMoveToRangeEnd:
2441 {
2442 HandleRedline( rSprm );
2443 }
2444 break;
2445 case NS_ooxml::LN_endtrackchange:
2446 m_pImpl->RemoveTopRedline();
2447 break;
2448 case NS_ooxml::LN_CT_RPrChange_rPr:
2449 {
2450 // Push all the current 'Character' properties to the stack, so that we don't store them
2451 // as 'tracked changes' by mistake
2452 m_pImpl->PushProperties(CONTEXT_CHARACTER);
2453
2454 // Resolve all the properties that are under the 'rPrChange'->'rPr' XML node
2455 resolveSprmProps(*this, rSprm );
2456
2457 // Get all the properties that were processed in the 'rPrChange'->'rPr' XML node
2458 uno::Sequence< beans::PropertyValue > currentRedlineRevertProperties = m_pImpl->GetTopContext()->GetPropertyValues();
2459
2460 // Pop back out the character properties that were on the run
2461 m_pImpl->PopProperties(CONTEXT_CHARACTER);
2462
2463 // Store these properties in the current redline object (do it after the PopProperties() above, since
2464 // otherwise it'd be stored in the content dropped there).
2465 m_pImpl->SetCurrentRedlineRevertProperties( currentRedlineRevertProperties );
2466 }
2467 break;
2468 case NS_ooxml::LN_CT_PPrChange_pPr:
2469 {
2470 // Push all the current 'Paragraph' properties to the stack, so that we don't store them
2471 // as 'tracked changes' by mistake
2472 m_pImpl->PushProperties(CONTEXT_PARAGRAPH);
2473
2474 // Resolve all the properties that are under the 'pPrChange'->'pPr' XML node
2475 resolveSprmProps(*this, rSprm );
2476
2477 // Get all the properties that were processed in the 'pPrChange'->'pPr' XML node
2478 uno::Sequence< beans::PropertyValue > currentRedlineRevertProperties = m_pImpl->GetTopContext()->GetPropertyValues();
2479
2480 // Pop back out the character properties that were on the run
2481 m_pImpl->PopProperties(CONTEXT_PARAGRAPH);
2482
2483 // Store these properties in the current redline object (do it after the PopProperties() above, since
2484 // otherwise it'd be stored in the content dropped there).
2485 m_pImpl->SetCurrentRedlineRevertProperties( currentRedlineRevertProperties );
2486 }
2487 break;
2488 case NS_ooxml::LN_object:
2489 {
2490 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2491 if( pProperties )
2492 {
2493 auto pOLEHandler = std::make_shared<OLEHandler>(*this);
2494 pProperties->resolve(*pOLEHandler);
2495 if ( pOLEHandler->isOLEObject( ) )
2496 {
2497 OUString sStreamName = pOLEHandler->copyOLEOStream( m_pImpl->GetTextDocument() );
2498 if( !sStreamName.isEmpty() )
2499 {
2500 m_pImpl->appendOLE( sStreamName, pOLEHandler );
2501 }
2502 }
2503 }
2504 }
2505 break;
2506 case NS_ooxml::LN_EG_HdrFtrReferences_headerReference: // header reference - not needed
2507 case NS_ooxml::LN_EG_HdrFtrReferences_footerReference: // footer reference - not needed
2508 break;
2509 case NS_ooxml::LN_EG_RPrBase_snapToGrid: // "Use document grid settings for inter-paragraph spacing"
2510 break;
2511 case NS_ooxml::LN_CT_PPrBase_contextualSpacing:
2512 rContext->Insert(PROP_PARA_CONTEXT_MARGIN, uno::makeAny( nIntValue != 0 ));
2513 break;
2514 case NS_ooxml::LN_CT_PPrBase_mirrorIndents: // mirrorIndents
2515 rContext->Insert(PROP_MIRROR_INDENTS, uno::makeAny( nIntValue != 0 ), true, PARA_GRAB_BAG);
2516 break;
2517 case NS_ooxml::LN_EG_SectPrContents_formProt: //section protection
2518 {
2519 if( pSectionContext )
2520 pSectionContext->Insert( PROP_IS_PROTECTED, uno::makeAny( bool(nIntValue) ) );
2521 }
2522 break;
2523 case NS_ooxml::LN_EG_SectPrContents_vAlign:
2524 {
2525 OSL_ENSURE(pSectionContext, "SectionContext unavailable!")do { if (true && (!(pSectionContext))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "2525" ": "), "%s", "SectionContext unavailable!"); } } while
(false)
;
2526 if( pSectionContext )
2527 {
2528 drawing::TextVerticalAdjust nVA = drawing::TextVerticalAdjust_TOP;
2529 switch( nIntValue )
2530 {
2531 case NS_ooxml::LN_Value_ST_VerticalJc_center: //92367
2532 nVA = drawing::TextVerticalAdjust_CENTER;
2533 break;
2534 case NS_ooxml::LN_Value_ST_VerticalJc_both: //92368 - justify
2535 nVA = drawing::TextVerticalAdjust_BLOCK;
2536 break;
2537 case NS_ooxml::LN_Value_ST_VerticalJc_bottom: //92369
2538 nVA = drawing::TextVerticalAdjust_BOTTOM;
2539 break;
2540 default:
2541 break;
2542 }
2543 pSectionContext->Insert( PROP_TEXT_VERTICAL_ADJUST, uno::makeAny( nVA ), true, PARA_GRAB_BAG );
2544 }
2545 }
2546 break;
2547 case NS_ooxml::LN_EG_RPrBase_fitText:
2548 break;
2549 case NS_ooxml::LN_ffdata:
2550 {
2551 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2552 if (pProperties)
2553 {
2554 FFDataHandler::Pointer_t pFFDataHandler(new FFDataHandler());
2555
2556 pProperties->resolve(*pFFDataHandler);
2557 m_pImpl->SetFieldFFData(pFFDataHandler);
2558 }
2559 }
2560 break;
2561 case NS_ooxml::LN_CT_SdtPr_dropDownList:
2562 case NS_ooxml::LN_CT_SdtPr_comboBox:
2563 {
2564 m_pImpl->m_pSdtHelper->setInsideDropDownControl(true);
2565 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2566 if (pProperties)
2567 pProperties->resolve(*this);
2568 }
2569 break;
2570 case NS_ooxml::LN_CT_SdtDropDownList_listItem:
2571 {
2572 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2573 if (pProperties)
2574 pProperties->resolve(*this);
2575 }
2576 break;
2577 case NS_ooxml::LN_CT_SdtPr_date:
2578 {
2579 resolveSprmProps(*this, rSprm);
2580 m_pImpl->m_pSdtHelper->setDateFieldStartRange(GetCurrentTextRange()->getEnd());
2581 }
2582 break;
2583 case NS_ooxml::LN_CT_SdtDate_dateFormat:
2584 {
2585 m_pImpl->m_pSdtHelper->getDateFormat().append(sStringValue);
2586 }
2587 break;
2588 case NS_ooxml::LN_CT_SdtDate_storeMappedDataAs:
2589 {
2590 }
2591 break;
2592 case NS_ooxml::LN_CT_SdtDate_calendar:
2593 {
2594 }
2595 break;
2596 case NS_ooxml::LN_CT_SdtDate_lid:
2597 {
2598 m_pImpl->m_pSdtHelper->getLocale().append(sStringValue);
2599 }
2600 break;
2601 case NS_ooxml::LN_CT_SdtPr_dataBinding:
2602 case NS_ooxml::LN_CT_SdtPr_equation:
2603 case NS_ooxml::LN_CT_SdtPr_checkbox:
2604 case NS_ooxml::LN_CT_SdtPr_docPartObj:
2605 case NS_ooxml::LN_CT_SdtPr_docPartList:
2606 case NS_ooxml::LN_CT_SdtPr_picture:
2607 case NS_ooxml::LN_CT_SdtPr_citation:
2608 case NS_ooxml::LN_CT_SdtPr_group:
2609 case NS_ooxml::LN_CT_SdtPr_text:
2610 case NS_ooxml::LN_CT_SdtPr_id:
2611 case NS_ooxml::LN_CT_SdtPr_alias:
2612 {
2613 // this is an unsupported SDT property, create a grab bag for it
2614 OUString sName;
2615 switch (nSprmId)
2616 {
2617 case NS_ooxml::LN_CT_SdtPr_dataBinding: sName = "ooxml:CT_SdtPr_dataBinding"; break;
2618 case NS_ooxml::LN_CT_SdtPr_equation: sName = "ooxml:CT_SdtPr_equation"; break;
2619 case NS_ooxml::LN_CT_SdtPr_checkbox: sName = "ooxml:CT_SdtPr_checkbox"; break;
2620 case NS_ooxml::LN_CT_SdtPr_docPartObj: sName = "ooxml:CT_SdtPr_docPartObj"; break;
2621 case NS_ooxml::LN_CT_SdtPr_docPartList: sName = "ooxml:CT_SdtPr_docPartList"; break;
2622 case NS_ooxml::LN_CT_SdtPr_picture: sName = "ooxml:CT_SdtPr_picture"; break;
2623 case NS_ooxml::LN_CT_SdtPr_citation: sName = "ooxml:CT_SdtPr_citation"; break;
2624 case NS_ooxml::LN_CT_SdtPr_group: sName = "ooxml:CT_SdtPr_group"; break;
2625 case NS_ooxml::LN_CT_SdtPr_text: sName = "ooxml:CT_SdtPr_text"; break;
2626 case NS_ooxml::LN_CT_SdtPr_id: sName = "ooxml:CT_SdtPr_id"; break;
2627 case NS_ooxml::LN_CT_SdtPr_alias: sName = "ooxml:CT_SdtPr_alias"; break;
2628 default: assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail (
"false", "/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
, 2628, __extension__ __PRETTY_FUNCTION__))
;
2629 };
2630 enableInteropGrabBag(sName);
2631
2632 // process subitems
2633 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2634 if (pProperties)
2635 pProperties->resolve(*this);
2636
2637 if (nSprmId == NS_ooxml::LN_CT_SdtPr_alias)
2638 {
2639 beans::PropertyValue aValue;
2640 aValue.Name = sName;
2641 aValue.Value <<= sStringValue;
2642 m_pImpl->m_pSdtHelper->appendToInteropGrabBag(aValue);
2643 }
2644 else
2645 m_pImpl->m_pSdtHelper->appendToInteropGrabBag(getInteropGrabBag());
2646 m_pImpl->m_pSdtHelper->setOutsideAParagraph(m_pImpl->IsOutsideAParagraph());
2647 m_pImpl->disableInteropGrabBag();
2648 }
2649 break;
2650 case NS_ooxml::LN_CT_SdtCheckbox_checked:
2651 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ooxml:CT_SdtCheckbox_checked", sStringValue);
2652 break;
2653 case NS_ooxml::LN_CT_SdtCheckbox_checkedState:
2654 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ooxml:CT_SdtCheckbox_checkedState", sStringValue);
2655 break;
2656 case NS_ooxml::LN_CT_SdtCheckbox_uncheckedState:
2657 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ooxml:CT_SdtCheckbox_uncheckedState", sStringValue);
2658 break;
2659 case NS_ooxml::LN_CT_SdtDocPart_docPartGallery:
2660 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ooxml:CT_SdtDocPart_docPartGallery", sStringValue);
2661 break;
2662 case NS_ooxml::LN_CT_SdtDocPart_docPartCategory:
2663 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ooxml:CT_SdtDocPart_docPartCategory", sStringValue);
2664 break;
2665 case NS_ooxml::LN_CT_SdtDocPart_docPartUnique:
2666 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ooxml:CT_SdtDocPart_docPartUnique", sStringValue);
2667 break;
2668 case NS_ooxml::LN_EG_SectPrContents_pgNumType:
2669 {
2670 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2671 if( pProperties )
2672 {
2673 pProperties->resolve(*this);
2674 }
2675 }
2676 break;
2677 case NS_ooxml::LN_tblStart:
2678 {
2679 if (m_pImpl->hasTableManager())
2680 {
2681 bool bTableStartsAtCellStart = m_pImpl->m_nTableDepth > 0 && m_pImpl->m_nTableCellDepth > m_pImpl->m_nLastTableCellParagraphDepth + 1;
2682 m_pImpl->getTableManager().setTableStartsAtCellStart(bTableStartsAtCellStart);
2683 }
2684 /*
2685 * Hack for Importing Section Properties
2686 * LO is not able to import section properties if first element in the
2687 * section is a table. So in case first element is a table add a dummy para
2688 * and remove it again when lcl_endSectionGroup is called
2689 */
2690 if(m_pImpl->m_nTableDepth == 0 && m_pImpl->GetIsFirstParagraphInSection()
2691 && !m_pImpl->GetIsDummyParaAddedForTableInSection() && !m_pImpl->GetIsTextFrameInserted()
2692 && !IsInHeaderFooter())
2693 {
2694 m_pImpl->AddDummyParaForTableInSection();
2695 }
2696
2697 // if first paragraph style in table has break-before-page, transfer that setting to the table itself.
2698 if( m_pImpl->m_nTableDepth == 0 )
2699 {
2700 const uno::Any aBreakType = uno::makeAny(style::BreakType_PAGE_BEFORE);
2701 const PropertyMapPtr pParagraphProps = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
2702 if( pParagraphProps && pParagraphProps->isSet(PROP_PARA_STYLE_NAME) )
2703 {
2704 StyleSheetEntryPtr pStyle;
2705 OUString sStyleName;
2706 pParagraphProps->getProperty(PROP_PARA_STYLE_NAME)->second >>= sStyleName;
2707 if( !sStyleName.isEmpty() && GetStyleSheetTable() )
2708 pStyle = GetStyleSheetTable()->FindStyleSheetByConvertedStyleName( sStyleName );
2709
2710 if( pStyle && pStyle->pProperties
2711 && pStyle->pProperties->isSet(PROP_BREAK_TYPE)
2712 && pStyle->pProperties->getProperty(PROP_BREAK_TYPE)->second == aBreakType )
2713 {
2714 pParagraphProps->Insert(PROP_BREAK_TYPE, aBreakType);
2715 }
2716 }
2717 }
2718
2719 m_pImpl->m_nTableDepth++;
2720 }
2721 break;
2722 case NS_ooxml::LN_tblEnd:
2723 m_pImpl->m_nTableDepth--;
2724 break;
2725 case NS_ooxml::LN_tcStart:
2726 m_pImpl->m_nTableCellDepth++;
2727 break;
2728 case NS_ooxml::LN_tcEnd:
2729 m_pImpl->m_nTableCellDepth--;
2730 m_pImpl->m_nLastTableCellParagraphDepth = 0;
2731 break;
2732 case NS_ooxml::LN_glow_glow:
2733 case NS_ooxml::LN_shadow_shadow:
2734 case NS_ooxml::LN_reflection_reflection:
2735 case NS_ooxml::LN_textOutline_textOutline:
2736 case NS_ooxml::LN_textFill_textFill:
2737 case NS_ooxml::LN_scene3d_scene3d:
2738 case NS_ooxml::LN_props3d_props3d:
2739 case NS_ooxml::LN_ligatures_ligatures:
2740 case NS_ooxml::LN_numForm_numForm:
2741 case NS_ooxml::LN_numSpacing_numSpacing:
2742 case NS_ooxml::LN_stylisticSets_stylisticSets:
2743 case NS_ooxml::LN_cntxtAlts_cntxtAlts:
2744 {
2745 tools::SvRef<TextEffectsHandler> pTextEffectsHandlerPtr( new TextEffectsHandler(nSprmId) );
2746 std::optional<PropertyIds> aPropertyId = pTextEffectsHandlerPtr->getGrabBagPropertyId();
2747 if(aPropertyId)
2748 {
2749 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2750 if( pProperties )
2751 {
2752 pProperties->resolve(*pTextEffectsHandlerPtr);
2753
2754 beans::PropertyValue aGrabBag = pTextEffectsHandlerPtr->getInteropGrabBag();
2755 rContext->Insert(*aPropertyId, uno::makeAny(aGrabBag), true, CHAR_GRAB_BAG);
2756
2757 sal_Int16 nTransparency = TextEffectsHandler::GetTextFillSolidFillAlpha(aGrabBag);
2758 if (nTransparency != 0)
2759 {
2760 rContext->Insert(PROP_CHAR_TRANSPARENCE, uno::makeAny(nTransparency));
2761 }
2762 }
2763 }
2764 }
2765 break;
2766 case NS_ooxml::LN_CT_SdtPr_rPr:
2767 {
2768 // Make sure properties from a previous SDT are not merged with the current ones.
2769 m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear();
2770 }
2771 break;
2772 case NS_ooxml::LN_CT_TblPrBase_tblLook:
2773 {
2774 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2775 if (pProperties)
2776 {
2777 pProperties->resolve(*this);
2778 m_pImpl->getTableManager().finishTableLook();
2779 }
2780 }
2781 break;
2782 case NS_ooxml::LN_CT_TrPrBase_cnfStyle:
2783 {
2784 m_pImpl->enableInteropGrabBag("cnfStyle");
2785 resolveSprmProps(*this, rSprm);
2786
2787 TablePropertyMapPtr pPropMap(new TablePropertyMap());
2788 pPropMap->Insert(PROP_ROW_CNF_STYLE, uno::makeAny(comphelper::containerToSequence(m_pImpl->m_aInteropGrabBag)), true, ROW_GRAB_BAG);
2789 m_pImpl->getTableManager().insertRowProps(pPropMap);
2790
2791 m_pImpl->disableInteropGrabBag();
2792 }
2793 break;
2794 case NS_ooxml::LN_CT_TcPrBase_cnfStyle:
2795 {
2796 m_pImpl->enableInteropGrabBag("cnfStyle");
2797 resolveSprmProps(*this, rSprm);
2798
2799 TablePropertyMapPtr pPropMap(new TablePropertyMap());
2800 pPropMap->Insert(PROP_CELL_CNF_STYLE, uno::makeAny(comphelper::containerToSequence(m_pImpl->m_aInteropGrabBag)), true, CELL_GRAB_BAG);
2801 m_pImpl->getTableManager().cellProps(pPropMap);
2802
2803 m_pImpl->disableInteropGrabBag();
2804 }
2805 break;
2806 case NS_ooxml::LN_CT_PPrBase_cnfStyle:
2807 {
2808 m_pImpl->enableInteropGrabBag("cnfStyle");
2809 resolveSprmProps(*this, rSprm);
2810 rContext->Insert(PROP_PARA_CNF_STYLE, uno::makeAny(comphelper::containerToSequence(m_pImpl->m_aInteropGrabBag)), true, PARA_GRAB_BAG);
2811 m_pImpl->disableInteropGrabBag();
2812 }
2813 break;
2814 case NS_ooxml::LN_EG_RunInnerContent_sym:
2815 {
2816 resolveSprmProps(*this, rSprm);
2817 SymbolData aSymbolData = m_pImpl->GetSymbolData();
2818 uno::Any aVal = uno::makeAny( aSymbolData.sFont );
2819 auto xFootnote = rContext->GetFootnote();
2820 if (!xFootnote.is() && m_pImpl->IsInCustomFootnote())
2821 xFootnote = m_pImpl->GetFootnoteContext()->GetFootnote();
2822 if (xFootnote.is())
2823 {
2824 // DOCX can have different labels for the footnote reference and the footnote area.
2825 // This skips the one from the footnote area and just uses the reference one.
2826 if (!m_pImpl->IsInFootOrEndnote())
2827 {
2828 auto xAnchorRange = xFootnote->getAnchor();
2829 auto xAnchorCursor(xAnchorRange->getText()->createTextCursorByRange(xAnchorRange));
2830
2831 // append a dummy character, so the following properties will be set as
2832 // as SwpHints::SwTextAttr instead of the SwAttrSet of the paragraph,
2833 // which would be removed by SwXText::Impl::finishOrAppendParagraph
2834 xAnchorCursor->collapseToEnd();
2835 uno::Reference<text::XTextRange> xHackRange(xAnchorCursor, uno::UNO_QUERY);
2836 xHackRange->setString("x");
2837
2838 uno::Reference<beans::XPropertySet> xAnchorProps(xAnchorRange, uno::UNO_QUERY);
2839 xAnchorProps->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME), aVal);
2840 xAnchorProps->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME_ASIAN), aVal);
2841 xAnchorProps->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME_COMPLEX), aVal);
2842 xAnchorProps->setPropertyValue(getPropertyName(PROP_CHAR_FONT_CHAR_SET), uno::makeAny(awt::CharSet::SYMBOL));
2843
2844 // remove the dummy char
2845 xHackRange->setString("");
2846
2847 OUString sLabel = xFootnote->getLabel() + OUStringChar(aSymbolData.cSymbol);
2848 xFootnote->setLabel(sLabel);
2849 }
2850 }
2851 else //it's a _real_ symbol
2852 {
2853 rContext->Insert(PROP_CHAR_FONT_NAME, aVal);
2854 rContext->Insert(PROP_CHAR_FONT_NAME_ASIAN, aVal);
2855 rContext->Insert(PROP_CHAR_FONT_NAME_COMPLEX, aVal);
2856 rContext->Insert(PROP_CHAR_FONT_CHAR_SET, uno::makeAny(awt::CharSet::SYMBOL));
2857 utext( reinterpret_cast < const sal_uInt8 * >( &(aSymbolData.cSymbol) ), 1 );
2858 }
2859 }
2860 break;
2861 case NS_ooxml::LN_EG_RunInnerContent_ruby:
2862 {
2863 RubyInfo aInfo ;
2864 m_pImpl->SetRubyInfo(aInfo);
2865 }
2866 break;
2867 case NS_ooxml::LN_CT_RubyPr:
2868 case NS_ooxml::LN_CT_Ruby_rt:
2869 case NS_ooxml::LN_CT_Ruby_rubyBase:
2870 {
2871 m_pImpl->SetRubySprmId(nSprmId);
2872 if (nSprmId == NS_ooxml::LN_CT_RubyPr)
2873 {
2874 resolveSprmProps(*this, rSprm);
2875 }
2876 }
2877 break;
2878 case NS_ooxml::LN_EG_RubyContent_r:
2879 {
2880 const RubyInfo & aInfo = m_pImpl->GetRubyInfo();
2881 if (aInfo.nSprmId == NS_ooxml::LN_CT_Ruby_rubyBase)
2882 {
2883 rContext->Insert(PROP_RUBY_TEXT, uno::makeAny(aInfo.sRubyText));
2884 rContext->Insert(PROP_RUBY_STYLE, uno::makeAny(aInfo.sRubyStyle));
2885 rContext->Insert(PROP_RUBY_ADJUST, uno::makeAny(static_cast<sal_Int16>(ConversionHelper::convertRubyAlign(aInfo.nRubyAlign))));
2886 if ( aInfo.nRubyAlign == NS_ooxml::LN_Value_ST_RubyAlign_rightVertical )
2887 rContext->Insert(PROP_RUBY_POSITION, uno::makeAny(css::text::RubyPosition::INTER_CHARACTER));
2888
2889 m_pImpl->SetRubySprmId(0);
2890 }
2891 }
2892 break;
2893 case NS_ooxml::LN_CT_RubyPr_rubyAlign:
2894 case NS_ooxml::LN_CT_RubyPr_hps:
2895 case NS_ooxml::LN_CT_RubyPr_hpsBaseText:
2896 {
2897 RubyInfo aInfo = m_pImpl->GetRubyInfo();
2898 switch(nSprmId)
2899 {
2900 case NS_ooxml::LN_CT_RubyPr_rubyAlign:
2901 aInfo.nRubyAlign = nIntValue;
2902 break;
2903 case NS_ooxml::LN_CT_RubyPr_hps:
2904 aInfo.nHps= nIntValue;
2905 break;
2906 case NS_ooxml::LN_CT_RubyPr_hpsBaseText:
2907 aInfo.nHpsBaseText = nIntValue;
2908 break;
2909 }
2910 m_pImpl->SetRubyInfo(aInfo);
2911 }
2912 break;
2913 case NS_ooxml::LN_CT_SmartTagRun_smartTagPr:
2914 {
2915 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2916 if (pProperties && m_pImpl->GetTopContextType() == CONTEXT_PARAGRAPH)
2917 pProperties->resolve(m_pImpl->getSmartTagHandler());
2918 }
2919 break;
2920 case NS_ooxml::LN_CT_DocPartPr_name:
2921 {
2922 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2923 if (pProperties)
2924 pProperties->resolve(*this);
2925 }
2926 break;
2927 case NS_ooxml::LN_CT_DocPartPr_category:
2928 {
2929 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2930 if (pProperties)
2931 pProperties->resolve(*this);
2932 }
2933 break;
2934 case NS_ooxml::LN_CT_DocPartCategory_gallery:
2935 {
2936 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2937 if (pProperties)
2938 pProperties->resolve(*this);
2939 }
2940 break;
2941 default:
2942 {
2943#ifdef DBG_UTIL
2944 TagLogger::getInstance().startElement("unhandled");
2945 TagLogger::getInstance().attribute("id", nSprmId);
2946 TagLogger::getInstance().attribute("name", rSprm.getName());
2947 TagLogger::getInstance().endElement();
2948#endif
2949 }
2950 }
2951}
2952
2953void DomainMapper::processDeferredCharacterProperties( const std::map< sal_Int32, uno::Any >& deferredCharacterProperties )
2954{
2955 assert( m_pImpl->GetTopContextType() == CONTEXT_CHARACTER )(static_cast <bool> (m_pImpl->GetTopContextType() ==
CONTEXT_CHARACTER) ? void (0) : __assert_fail ("m_pImpl->GetTopContextType() == CONTEXT_CHARACTER"
, "/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
, 2955, __extension__ __PRETTY_FUNCTION__))
;
2956 PropertyMapPtr rContext = m_pImpl->GetTopContext();
2957 for( const auto& rProp : deferredCharacterProperties )
2958 {
2959 sal_Int32 Id = rProp.first;
2960 sal_Int32 nIntValue = 0;
2961 OUString sStringValue;
2962 rProp.second >>= nIntValue;
2963 rProp.second >>= sStringValue;
2964 switch( Id )
2965 {
2966 case NS_ooxml::LN_EG_RPrBase_position:
2967 {
2968 double nEscapement = 0;
2969 sal_Int8 nProp = 0;
2970 if ( nIntValue )
2971 {
2972 nProp = 100;
2973 double fFontSize = 0;
2974 m_pImpl->GetAnyProperty(PROP_CHAR_HEIGHT, rContext) >>= fFontSize;
2975 if ( fFontSize )
2976 // nIntValue is in half-points, fontsize is in points, escapement is a percentage.
2977 nEscapement = round( nIntValue/2.0 / fFontSize * 100 );
2978 else
2979 nEscapement = nIntValue > 0 ? DFLT_ESC_SUPER33 : DFLT_ESC_SUB-8;
2980 }
2981 if ( nEscapement > MAX_ESC_POS13999 )
2982 nEscapement = MAX_ESC_POS13999;
2983 else if ( nEscapement < -MAX_ESC_POS13999 )
2984 nEscapement = -MAX_ESC_POS13999;
2985
2986 rContext->Insert(PROP_CHAR_ESCAPEMENT, uno::makeAny( sal_Int16(nEscapement) ) );
2987 rContext->Insert(PROP_CHAR_ESCAPEMENT_HEIGHT, uno::makeAny( nProp ) );
2988 }
2989 break;
2990 default:
2991 SAL_WARN( "writerfilter", "Unhandled property in processDeferredCharacterProperty()" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "writerfilter")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Unhandled property in processDeferredCharacterProperty()"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("writerfilter"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "2991" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Unhandled property in processDeferredCharacterProperty()"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Unhandled property in processDeferredCharacterProperty()"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("writerfilter"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "2991" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Unhandled property in processDeferredCharacterProperty()"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("writerfilter"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "2991" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "Unhandled property in processDeferredCharacterProperty()"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Unhandled property in processDeferredCharacterProperty()"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("writerfilter"
), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "2991" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2992 break;
2993 }
2994 }
2995}
2996
2997void DomainMapper::lcl_entry(writerfilter::Reference<Properties>::Pointer_t ref)
2998{
2999 ref->resolve(*this);
3000}
3001
3002void DomainMapper::data(const sal_uInt8* /*buf*/, size_t /*len*/)
3003{
3004}
3005
3006void DomainMapper::lcl_startSectionGroup()
3007{
3008 if (!m_pImpl->isInIndexContext() && !m_pImpl->isInBibliographyContext())
3009 {
3010 m_pImpl->PushProperties(CONTEXT_SECTION);
3011 }
3012 m_pImpl->SetIsFirstParagraphInSection(true);
3013 m_pImpl->SetIsFirstParagraphInSectionAfterRedline(true);
3014}
3015
3016void DomainMapper::lcl_endSectionGroup()
3017{
3018 if (m_pImpl->isInIndexContext() || m_pImpl->isInBibliographyContext())
3019 return;
3020
3021 m_pImpl->CheckUnregisteredFrameConversion();
3022 m_pImpl->ExecuteFrameConversion();
3023 // When pasting, it's fine to not have any paragraph inside the document at all.
3024 if (m_pImpl->GetIsFirstParagraphInSection() && m_pImpl->IsNewDoc())
3025 {
3026 // This section has no paragraph at all (e.g. they are all actually in a frame).
3027 // If this section has a page break, there would be nothing to apply to the page
3028 // style, so force a dummy paragraph.
3029 lcl_startParagraphGroup();
3030 lcl_startCharacterGroup();
3031 sal_uInt8 const sBreak[] = { 0xd };
3032 lcl_text(sBreak, 1);
3033 lcl_endCharacterGroup();
3034 lcl_endParagraphGroup();
3035 }
3036 PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_SECTION);
3037 SectionPropertyMap* pSectionContext = dynamic_cast< SectionPropertyMap* >( pContext.get() );
3038 OSL_ENSURE(pSectionContext, "SectionContext unavailable!")do { if (true && (!(pSectionContext))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "3038" ": "), "%s", "SectionContext unavailable!"); } } while
(false)
;
3039 if(pSectionContext)
3040 {
3041 pSectionContext->CloseSectionGroup( *m_pImpl );
3042 // Remove the dummy paragraph if added for
3043 // handling the section properties if section starts with a table
3044 if (m_pImpl->GetIsDummyParaAddedForTableInSection())
3045 m_pImpl->RemoveDummyParaForTableInSection();
3046 }
3047 m_pImpl->SetIsTextFrameInserted( false );
3048 m_pImpl->PopProperties(CONTEXT_SECTION);
3049}
3050
3051void DomainMapper::lcl_startParagraphGroup()
3052{
3053 if (m_pImpl->hasTableManager())
3054 m_pImpl->getTableManager().startParagraphGroup();
3055 /*
3056 * Add new para properties only if paragraph is not split
3057 * or the top context is not of paragraph properties
3058 * Set mbIsSplitPara to false as it has been handled
3059 */
3060 if (!mbIsSplitPara)
3061 m_pImpl->PushProperties(CONTEXT_PARAGRAPH);
3062 mbIsSplitPara = false;
3063 if (m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH) != m_pImpl->GetTopContext())
3064 m_pImpl->PushProperties(CONTEXT_PARAGRAPH);
3065
3066 if (m_pImpl->GetTopContext())
3067 {
3068 if (!m_pImpl->IsInShape())
3069 {
3070 const OUString& sDefaultParaStyle = m_pImpl->GetDefaultParaStyleName();
3071 m_pImpl->GetTopContext()->Insert( PROP_PARA_STYLE_NAME, uno::makeAny( sDefaultParaStyle ) );
3072 m_pImpl->SetCurrentParaStyleName( sDefaultParaStyle );
3073 }
3074 if (m_pImpl->isBreakDeferred(PAGE_BREAK))
3075 m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE));
3076 else if (m_pImpl->isBreakDeferred(COLUMN_BREAK))
3077 m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_COLUMN_BEFORE));
3078
3079 if (m_pImpl->isParaSdtEndDeferred())
3080 m_pImpl->GetTopContext()->Insert(PROP_PARA_SDT_END_BEFORE, uno::makeAny(true), true, PARA_GRAB_BAG);
3081 }
3082 m_pImpl->SetIsFirstRun(true);
3083 m_pImpl->SetIsOutsideAParagraph(false);
3084 m_pImpl->clearDeferredBreaks();
3085 m_pImpl->setParaSdtEndDeferred(false);
3086}
3087
3088void DomainMapper::lcl_endParagraphGroup()
3089{
3090 m_pImpl->PopProperties(CONTEXT_PARAGRAPH);
3091 if (m_pImpl->hasTableManager())
3092 m_pImpl->getTableManager().endParagraphGroup();
3093 //frame conversion has to be executed after table conversion
3094 m_pImpl->ExecuteFrameConversion();
3095 m_pImpl->SetIsOutsideAParagraph(true);
3096}
3097
3098void DomainMapper::markLastParagraphInSection( )
3099{
3100 m_pImpl->SetIsLastParagraphInSection( true );
3101}
3102
3103void DomainMapper::markLastSectionGroup( )
3104{
3105 m_pImpl->SetIsLastSectionGroup( true );
3106}
3107
3108void DomainMapper::lcl_startShape(uno::Reference<drawing::XShape> const& xShape)
3109{
3110 assert(xShape.is())(static_cast <bool> (xShape.is()) ? void (0) : __assert_fail
("xShape.is()", "/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
, 3110, __extension__ __PRETTY_FUNCTION__))
;
3111
3112 if (m_pImpl->GetTopContext())
3113 {
3114 // If there is a deferred page break, handle it now, so that the
3115 // started shape will be on the correct page.
3116 if (m_pImpl->isBreakDeferred(PAGE_BREAK))
3117 {
3118 m_pImpl->clearDeferredBreak(PAGE_BREAK);
3119 lcl_startCharacterGroup();
3120 sal_uInt8 const sBreak[] = { 0xd };
3121 lcl_text(sBreak, 1);
3122 lcl_endCharacterGroup();
3123 lcl_endParagraphGroup();
3124 lcl_startParagraphGroup();
3125 m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE));
3126 }
3127 m_pImpl->PushShapeContext( xShape );
3128 lcl_startParagraphGroup();
3129 }
3130 else
3131 {
3132 // No context? Then this image should not appear directly inside the
3133 // document, just save it for later usage.
3134 m_pImpl->PushPendingShape(xShape);
3135 }
3136
3137 m_pImpl->SetIsFirstParagraphInShape(true);
3138
3139}
3140
3141void DomainMapper::lcl_endShape( )
3142{
3143 if (!m_pImpl->GetTopContext())
3144 return;
3145
3146 // End the current table, if there are any. Otherwise the unavoidable
3147 // empty paragraph at the end of the shape text will cause problems: if
3148 // the shape text ends with a table, the extra paragraph will be
3149 // handled as an additional row of the ending table.
3150 if (m_pImpl->hasTableManager())
3151 m_pImpl->getTableManager().endTable();
3152
3153 lcl_endParagraphGroup();
3154 m_pImpl->PopShapeContext( );
3155 // A shape is always inside a paragraph (anchored or inline).
3156 m_pImpl->SetIsOutsideAParagraph(false);
3157}
3158
3159void DomainMapper::PushStyleSheetProperties( const PropertyMapPtr& pStyleProperties, bool bAffectTableMngr )
3160{
3161 m_pImpl->PushStyleProperties( pStyleProperties );
3162 if ( bAffectTableMngr )
3163 m_pImpl->getTableManager( ).SetStyleProperties( pStyleProperties );
3164}
3165
3166void DomainMapper::PopStyleSheetProperties( bool bAffectTableMngr )
3167{
3168 m_pImpl->PopProperties( CONTEXT_STYLESHEET );
3169 if ( bAffectTableMngr )
3170 {
3171 PropertyMapPtr emptyPtr;
3172 m_pImpl->getTableManager( ).SetStyleProperties( emptyPtr );
3173 }
3174}
3175
3176void DomainMapper::PushListProperties( const ::tools::SvRef<PropertyMap>& pListProperties )
3177{
3178 m_pImpl->PushListProperties( pListProperties );
3179}
3180
3181void DomainMapper::PopListProperties()
3182{
3183 m_pImpl->PopProperties( CONTEXT_LIST );
3184}
3185
3186void DomainMapper::lcl_startCharacterGroup()
3187{
3188 m_pImpl->PushProperties(CONTEXT_CHARACTER);
3189 if (m_pImpl->isSdtEndDeferred())
3190 {
3191 // Fields have an empty character group before the real one, so don't
3192 // call setSdtEndDeferred(false) here, that will happen only in lcl_utext().
3193 m_pImpl->GetTopContext()->Insert(PROP_SDT_END_BEFORE, uno::makeAny(true), true, CHAR_GRAB_BAG);
3194 }
3195}
3196
3197void DomainMapper::lcl_endCharacterGroup()
3198{
3199 if (m_pImpl->CheckFootnoteStyle())
3200 {
3201 m_pImpl->SetCheckFootnoteStyle(m_pImpl->IsInCustomFootnote());
3202 m_pImpl->SetHasFootnoteStyle(false);
3203 }
3204 m_pImpl->PopProperties(CONTEXT_CHARACTER);
3205}
3206
3207void DomainMapper::lcl_text(const sal_uInt8 * data_, size_t len)
3208{
3209 //TODO: Determine the right text encoding (FIB?)
3210 OUString sText( reinterpret_cast<const char*>(data_), len, RTL_TEXTENCODING_MS_1252(((rtl_TextEncoding) 1)) );
3211#ifdef DBG_UTIL
3212 TagLogger::getInstance().startElement("text");
3213 TagLogger::getInstance().chars(sText);
3214 TagLogger::getInstance().endElement();
3215#endif
3216
3217 try
3218 {
3219 if(len == 1)
3220 {
3221 switch(*data_)
3222 {
3223 case 0x02: return; //footnote character
3224 case 0x08: // Lock field if in field context
3225 if (m_pImpl->IsOpenField())
3226 m_pImpl->SetFieldLocked();
3227 return;
3228 case 0x0c: //page break
3229 m_pImpl->deferBreak(PAGE_BREAK);
3230 return;
3231 case 0x0e: //column break
3232 m_pImpl->deferBreak(COLUMN_BREAK);
3233 return;
3234 case 0x07:
3235 m_pImpl->getTableManager().text(data_, len);
3236 return;
3237 case 0x0d:
3238 {
3239 PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
3240 if (pContext && m_pImpl->isBreakDeferred(COLUMN_BREAK))
3241 {
3242 pContext->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_COLUMN_BEFORE));
3243 m_pImpl->clearDeferredBreak(COLUMN_BREAK);
3244 }
3245 finishParagraph();
3246 return;
3247 }
3248 case cFieldStart:
3249 m_pImpl->PushFieldContext();
3250 return;
3251 case cFieldSep:
3252 // delimiter not necessarily available
3253 // appears only if field contains further content
3254 m_pImpl->CloseFieldCommand();
3255 return;
3256 case cFieldEnd:
3257 m_pImpl->PopFieldContext();
3258 return;
3259 default:
3260 break;
3261 }
3262 }
3263
3264 // GetTopContext() is changed by inserted breaks, but we want to keep the current context
3265 PropertyMapPtr pContext = m_pImpl->GetTopContext();
3266 if (!m_pImpl->GetFootnoteContext())
3267 {
3268 if (m_pImpl->isBreakDeferred(PAGE_BREAK))
3269 m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE));
3270 else if (m_pImpl->isBreakDeferred(COLUMN_BREAK))
3271 m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_COLUMN_BEFORE));
3272 m_pImpl->clearDeferredBreaks();
3273 }
3274
3275 if (pContext && pContext->GetFootnote().is() && m_pImpl->IsInCustomFootnote())
3276 {
3277 pContext->GetFootnote()->setLabel(sText);
3278 m_pImpl->EndCustomFootnote();
3279 //otherwise ignore sText
3280 }
3281 else if (m_pImpl->IsOpenFieldCommand() && !m_pImpl->IsForceGenericFields())
3282 {
3283 m_pImpl->AppendFieldCommand(sText);
3284 }
3285 else if( m_pImpl->IsOpenField() && m_pImpl->IsFieldResultAsString())
3286 /*depending on the success of the field insert operation this result will be
3287 set at the field or directly inserted into the text*/
3288 m_pImpl->AppendFieldResult(sText);
3289 else
3290 {
3291 if (pContext == nullptr)
3292 pContext = new PropertyMap();
3293
3294 m_pImpl->appendTextPortion( sText, pContext );
3295 }
3296 }
3297 catch( const uno::RuntimeException& )
3298 {
3299 TOOLS_WARN_EXCEPTION("writerfilter", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "writerfilter")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break
; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "3299" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "3299" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "3299" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("writerfilter"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "3299" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
3300 }
3301}
3302
3303void DomainMapper::lcl_positionOffset(const OUString& rText, bool bVertical)
3304{
3305 if (bVertical)
3306 m_pImpl->m_aPositionOffsets.second = rText;
3307 else
3308 m_pImpl->m_aPositionOffsets.first = rText;
3309}
3310
3311awt::Point DomainMapper::getPositionOffset()
3312{
3313 awt::Point aRet;
3314 aRet.X = oox::drawingml::convertEmuToHmm(m_pImpl->m_aPositionOffsets.first.toInt32());
3315 aRet.Y = oox::drawingml::convertEmuToHmm(m_pImpl->m_aPositionOffsets.second.toInt32());
3316 return aRet;
3317}
3318
3319void DomainMapper::lcl_align(const OUString& rText, bool bVertical)
3320{
3321 if (bVertical)
3322 m_pImpl->m_aAligns.second = rText;
3323 else
3324 m_pImpl->m_aAligns.first = rText;
3325}
3326
3327void DomainMapper::lcl_positivePercentage(const OUString& rText)
3328{
3329 m_pImpl->m_aPositivePercentages.push(rText);
3330}
3331
3332void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
3333{
3334 // All these fixed values are defined as static const sal_Unicode codepoints in the fast parser,
3335 // like uFtnEdnRef = 0x2, uFtnEdnSep = 0x3, ... and have a len of 1, if they aren't valid unicode.
3336
3337 OUString sText(reinterpret_cast<const sal_Unicode *>(data_), len);
3338 const RubyInfo & aInfo = m_pImpl->GetRubyInfo();
3339 if (aInfo.nSprmId == NS_ooxml::LN_CT_Ruby_rt)
3340 {
3341 PropertyMapPtr pContext = m_pImpl->GetTopContext();
3342 PropertyValueVector_t aProps = comphelper::sequenceToContainer< PropertyValueVector_t >(pContext->GetPropertyValues());
3343 OUString sStyle = getOrCreateCharStyle(aProps, /*bAlwaysCreate=*/false);
3344 m_pImpl->SetRubyText(sText,sStyle);
3345 return;
3346 }
3347
3348 if (len == 1)
3349 {
3350 // If the footnote contains a Footnote Reference Mark, it can't be a custom footnote
3351 // ******
3352 // This code block is wrong, as it should also be in m_pImpl->IsInFootOrEndnote().
3353 // The main problem is that
3354 //
3355 // assert(len != 1 || sText[0] != 0x2)
3356 //
3357 // is triggered by the unit test SwLayoutWriter::testForcepoint75, so all these pseudo
3358 // value handling is broken.
3359 // But this is just a symptom, as I guess it's possible to generate broken DOCX documents,
3360 // which might be problematic, triggering *funny* code paths left and right.
3361 // ******
3362 if (sText[0] == 0x2)
3363 {
3364 m_pImpl->EndCustomFootnote();
3365 return;
3366 }
3367
3368 if (m_pImpl->IsInCustomFootnote())
3369 {
3370 if (sText[0] != 0xd && sText[0] != 0x3)
3371 {
3372 // DOCX can have different labels for the footnote reference and the footnote area.
3373 // This skips the one from the footnote area and just uses the reference one.
3374 if (!m_pImpl->IsInFootOrEndnote())
3375 {
3376 if (PropertyMapPtr pFootnoteContext = m_pImpl->GetFootnoteContext())
3377 {
3378 auto xFootnote = pFootnoteContext->GetFootnote();
3379 xFootnote->setLabel(xFootnote->getLabel() + sText);
3380 }
3381 }
3382 return;
3383 }
3384 else
3385 m_pImpl->SetHasFootnoteStyle(true);
3386 }
3387 }
3388
3389 if (m_pImpl->isSdtEndDeferred())
3390 {
3391 // In case we have a field context, then save the property there, so
3392 // SDT's ending right before a field start are handled as well.
3393 PropertyMapPtr pContext = m_pImpl->GetTopContext();
3394 if (m_pImpl->IsOpenField())
3395 pContext = m_pImpl->GetTopFieldContext()->getProperties();
3396 pContext->Insert(PROP_SDT_END_BEFORE, uno::makeAny(true), true, CHAR_GRAB_BAG);
3397 m_pImpl->setSdtEndDeferred(false);
3398 }
3399
3400 bool bNewLine = len == 1 && (sText[0] == 0x0d || sText[0] == 0x07);
3401 if (m_pImpl->m_pSdtHelper->isInsideDropDownControl())
3402 {
3403 if (bNewLine)
3404 // Dropdown control has single-line texts, so in case of newline, create the control.
3405 m_pImpl->m_pSdtHelper->createDropDownControl();
3406 else
3407 {
3408 m_pImpl->m_pSdtHelper->getSdtTexts().append(sText);
3409 return;
3410 }
3411 }
3412 else if (!m_pImpl->m_pSdtHelper->isInteropGrabBagEmpty())
3413 {
3414 // Ignore grabbag when we have a date field, it can conflict during export
3415 if(m_pImpl->m_pSdtHelper->validateDateFormat())
3416 {
3417 m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear();
3418 }
3419 else
3420 {
3421
3422 // there are unsupported SDT properties in the document
3423 // save them in the paragraph interop grab bag
3424 if (m_pImpl->IsDiscardHeaderFooter())
3425 {
3426 // Unless we're supposed to ignore this header/footer.
3427 m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear();
3428 return;
3429 }
3430 if((m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_checkbox") ||
3431 m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_text") ||
3432 m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_dataBinding") ||
3433 m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_citation") ||
3434 (m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_id") &&
3435 m_pImpl->m_pSdtHelper->getInteropGrabBagSize() == 1)) && !m_pImpl->m_pSdtHelper->isOutsideAParagraph())
3436 {
3437 PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_CHARACTER);
3438
3439 if (m_pImpl->IsOpenField())
3440 // We have a field, insert the SDT properties to the field's grab-bag, so they won't be lost.
3441 pContext = m_pImpl->GetTopFieldContext()->getProperties();
3442
3443 pContext->Insert(PROP_SDTPR, uno::makeAny(m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear()), true, CHAR_GRAB_BAG);
3444 }
3445 else
3446 m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)->Insert(PROP_SDTPR,
3447 uno::makeAny(m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear()), true, PARA_GRAB_BAG);
3448 }
3449 }
3450 else if (len == 1 && sText[0] == 0x03)
3451 {
3452 // This is the uFtnEdnSep, remember that the document has a separator.
3453 m_pImpl->m_bHasFtnSep = true;
3454 return;
3455 }
3456 else if (len == 1 && sText[0] == '\t' )
3457 {
3458 if ( m_pImpl->m_bCheckFirstFootnoteTab && m_pImpl->IsInFootOrEndnote() )
3459 {
3460 // Allow MSO to emulate LO footnote text starting at left margin - only meaningful with hanging indent
3461 m_pImpl->m_bCheckFirstFootnoteTab = false;
3462 sal_Int32 nFirstLineIndent = 0;
3463 m_pImpl->GetAnyProperty(PROP_PARA_FIRST_LINE_INDENT, m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)) >>= nFirstLineIndent;
3464 if ( nFirstLineIndent < 0 )
3465 m_pImpl->m_bIgnoreNextTab = true;
3466 }
3467
3468 if ( m_pImpl->m_bIgnoreNextTab )
3469 {
3470 m_pImpl->m_bIgnoreNextTab = false;
3471 return;
3472 }
3473 }
3474 else if (m_pImpl->m_pSdtHelper->validateDateFormat())
3475 {
3476 if(IsInHeaderFooter() && m_pImpl->IsDiscardHeaderFooter())
3477 {
3478 m_pImpl->m_pSdtHelper->getDateFormat().truncate();
3479 m_pImpl->m_pSdtHelper->getLocale().truncate();
3480 return;
3481 }
3482 }
3483 if (!m_pImpl->hasTableManager())
3484 return;
3485
3486 SkipFootnoteSeparator eSkip = m_pImpl->GetSkipFootnoteState();
3487 if ( eSkip == SkipFootnoteSeparator::ON || eSkip == SkipFootnoteSeparator::SKIPPING )
3488 {
3489 m_pImpl->SetSkipFootnoteState( SkipFootnoteSeparator::SKIPPING );
3490 return;
3491 }
3492
3493 try
3494 {
3495 m_pImpl->getTableManager().utext(data_, len);
3496
3497 if (bNewLine)
3498 {
3499 const bool bSingleParagraph = m_pImpl->GetIsFirstParagraphInSection() && m_pImpl->GetIsLastParagraphInSection();
3500 const bool bSingleParagraphAfterRedline = m_pImpl->GetIsFirstParagraphInSection(true) && m_pImpl->GetIsLastParagraphInSection();
3501 PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
3502 if (!m_pImpl->GetFootnoteContext())
3503 {
3504 if (m_pImpl->isBreakDeferred(PAGE_BREAK))
3505 {
3506 if (m_pImpl->GetSettingsTable()->GetSplitPgBreakAndParaMark())
3507 {
3508 if ( m_pImpl->GetIsFirstParagraphInSection() || !m_pImpl->IsFirstRun() )
3509 {
3510 m_pImpl->m_bIsSplitPara = true;
3511 finishParagraph();
3512 lcl_startParagraphGroup();
3513 }
3514
3515
3516 pContext->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE));
3517 m_pImpl->clearDeferredBreaks();
3518 }
3519 }
3520 else if (m_pImpl->isBreakDeferred(COLUMN_BREAK))
3521 {
3522 if ( m_pImpl->GetIsFirstParagraphInSection() || !m_pImpl->IsFirstRun() )
3523 {
3524 mbIsSplitPara = true;
3525 finishParagraph();
3526 lcl_startParagraphGroup();
3527 }
3528
3529 pContext->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_COLUMN_BEFORE));
3530 m_pImpl->clearDeferredBreaks();
3531 }
3532 }
3533
3534 // If the paragraph contains only the section properties and it has
3535 // no runs, we should not create a paragraph for it in Writer, unless that would remove the whole section.
3536 SectionPropertyMap* pSectionContext = m_pImpl->GetSectionContext();
3537 bool bRemove = (!m_pImpl->GetParaChanged() && m_pImpl->GetRemoveThisPara()) ||
3538 (!m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr()
3539 && !bSingleParagraphAfterRedline
3540 && !m_pImpl->GetParaHadField()
3541 && !m_pImpl->GetIsDummyParaAddedForTableInSection()
3542 && !( pSectionContext && pSectionContext->GetBreakType() != -1 && pContext && pContext->isSet(PROP_BREAK_TYPE) )
3543 && !m_pImpl->GetIsPreviousParagraphFramed()
3544 && !m_pImpl->HasTopAnchoredObjects()
3545 && !m_pImpl->IsParaWithInlineObject());
3546
3547 const bool bNoNumbering = bRemove || (!m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr() && bSingleParagraph);
3548 PropertyMapPtr xContext = bNoNumbering ? m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH) : PropertyMapPtr();
3549 if (xContext)
3550 {
3551 // tdf#97417 delete numbering of the paragraph
3552 // it will be deleted anyway, and the numbering would be copied
3553 // to the next paragraph in sw SplitNode and then be applied to
3554 // every following paragraph
3555 xContext->Erase(PROP_NUMBERING_RULES);
3556 static_cast<ParagraphPropertyMap*>(xContext.get())->SetListId(-1);;
3557 xContext->Erase(PROP_NUMBERING_LEVEL);
3558 }
3559 m_pImpl->SetParaSectpr(false);
3560 finishParagraph(bRemove);
3561 if (bRemove)
3562 m_pImpl->RemoveLastParagraph();
3563 }
3564 else
3565 {
3566 // GetTopContext() is changed by inserted breaks, but we want to keep the current context
3567 PropertyMapPtr pContext = m_pImpl->GetTopContext();
3568 if (!m_pImpl->GetFootnoteContext())
3569 {
3570 if (m_pImpl->isBreakDeferred(PAGE_BREAK))
3571 {
3572 /* If PAGEBREAK appears in first paragraph of the section or
3573 * after first run of any paragraph then need to split paragraph
3574 * to handle it properly.
3575 */
3576 if (m_pImpl->GetIsFirstParagraphInSection() || !m_pImpl->IsFirstRun())
3577 {
3578 m_pImpl->m_bIsSplitPara = true;
3579 finishParagraph();
3580 lcl_startParagraphGroup();
3581 }
3582 m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_PAGE_BEFORE));
3583 }
3584 else if (m_pImpl->isBreakDeferred(COLUMN_BREAK))
3585 {
3586 if (m_pImpl->GetIsFirstParagraphInSection() || !m_pImpl->IsFirstRun())
3587 {
3588 mbIsSplitPara = true;
3589 finishParagraph();
3590 lcl_startParagraphGroup();
3591 }
3592 m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, uno::makeAny(style::BreakType_COLUMN_BEFORE));
3593 }
3594 m_pImpl->clearDeferredBreaks();
3595 }
3596
3597 if (pContext && pContext->GetFootnote().is())
3598 {
3599 pContext->GetFootnote()->setLabel( sText );
3600 //otherwise ignore sText
3601 }
3602 else if (m_pImpl->IsOpenFieldCommand() && !m_pImpl->IsForceGenericFields())
3603 {
3604 m_pImpl->AppendFieldCommand(sText);
3605 }
3606 else if( m_pImpl->IsOpenField() && m_pImpl->IsFieldResultAsString())
3607 /*depending on the success of the field insert operation this result will be
3608 set at the field or directly inserted into the text*/
3609 m_pImpl->AppendFieldResult(sText);
3610 else
3611 {
3612 if (pContext == nullptr)
3613 pContext = new PropertyMap();
3614
3615 m_pImpl->appendTextPortion( sText, pContext );
3616 }
3617
3618 }
3619 m_pImpl->SetIsFirstRun(false);
3620 }
3621 catch( const uno::RuntimeException& )
3622 {
3623 }
3624}
3625
3626void DomainMapper::lcl_props(writerfilter::Reference<Properties>::Pointer_t ref)
3627{
3628 ref->resolve(*this);
3629}
3630
3631void DomainMapper::lcl_table(Id name, writerfilter::Reference<Table>::Pointer_t ref)
3632{
3633 m_pImpl->SetAnyTableImport(true);
3634 switch(name)
3635 {
3636 case NS_ooxml::LN_FONTTABLE:
3637
3638 // create a font table object that listens to the attributes
3639 // each entry call inserts a new font entry
3640 ref->resolve( *m_pImpl->GetFontTable() );
3641 break;
3642 case NS_ooxml::LN_STYLESHEET:
3643 //same as above to import style sheets
3644 m_pImpl->SetStyleSheetImport( true );
3645 ref->resolve( *m_pImpl->GetStyleSheetTable() );
3646 m_pImpl->GetStyleSheetTable()->ApplyStyleSheets(m_pImpl->GetFontTable());
3647 m_pImpl->SetStyleSheetImport( false );
3648 break;
3649 case NS_ooxml::LN_NUMBERING:
3650 {
3651
3652 //the same for list tables
3653 ref->resolve( *m_pImpl->GetListTable() );
3654 m_pImpl->GetListTable( )->CreateNumberingRules( );
3655 }
3656 break;
3657 case NS_ooxml::LN_THEMETABLE:
3658 m_pImpl->GetThemeTable()->setThemeFontLangProperties(
3659 m_pImpl->GetSettingsTable()->GetThemeFontLangProperties() );
3660 ref->resolve ( *m_pImpl->GetThemeTable() );
3661 break;
3662 case NS_ooxml::LN_settings_settings:
3663 ref->resolve ( *m_pImpl->GetSettingsTable() );
3664 m_pImpl->ApplySettingsTable();
3665 break;
3666 default:
3667 OSL_FAIL( "which table is to be filled here?")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "3667" ": "), "%s", "which table is to be filled here?")
; } } while (false)
;
3668 }
3669 m_pImpl->SetAnyTableImport(false);
3670}
3671
3672void DomainMapper::lcl_substream(Id rName, ::writerfilter::Reference<Stream>::Pointer_t ref)
3673{
3674 m_pImpl->substream(rName, ref);
3675}
3676
3677void DomainMapper::lcl_startGlossaryEntry()
3678{
3679 uno::Reference< text::XTextRange > xTextRange = GetCurrentTextRange();
3680 m_pImpl->setGlossaryEntryStart(xTextRange);
3681}
3682
3683void DomainMapper::lcl_endGlossaryEntry()
3684{
3685 m_pImpl->appendGlossaryEntry();
3686}
3687
3688void DomainMapper::handleUnderlineType(const Id nId, const ::tools::SvRef<PropertyMap>& rContext)
3689{
3690 sal_Int16 nUnderline = awt::FontUnderline::NONE;
3691
3692 switch (nId)
3693 {
3694 case NS_ooxml::LN_Value_ST_Underline_none:
3695 nUnderline = awt::FontUnderline::NONE;
3696 break;
3697 case NS_ooxml::LN_Value_ST_Underline_words:
3698 rContext->Insert(PROP_CHAR_WORD_MODE, uno::makeAny(true));
3699 [[fallthrough]];
3700 case NS_ooxml::LN_Value_ST_Underline_single:
3701 nUnderline = awt::FontUnderline::SINGLE;
3702 break;
3703 case NS_ooxml::LN_Value_ST_Underline_double:
3704 nUnderline = awt::FontUnderline::DOUBLE;
3705 break;
3706 case NS_ooxml::LN_Value_ST_Underline_dotted:
3707 nUnderline = awt::FontUnderline::DOTTED;
3708 break;
3709 case NS_ooxml::LN_Value_ST_Underline_dash:
3710 nUnderline = awt::FontUnderline::DASH;
3711 break;
3712 case NS_ooxml::LN_Value_ST_Underline_dotDash:
3713 nUnderline = awt::FontUnderline::DASHDOT;
3714 break;
3715 case NS_ooxml::LN_Value_ST_Underline_dotDotDash:
3716 nUnderline = awt::FontUnderline::DASHDOTDOT;
3717 break;
3718 case NS_ooxml::LN_Value_ST_Underline_thick:
3719 nUnderline = awt::FontUnderline::BOLD;
3720 break;
3721 case NS_ooxml::LN_Value_ST_Underline_wave:
3722 nUnderline = awt::FontUnderline::WAVE;
3723 break;
3724 case NS_ooxml::LN_Value_ST_Underline_dottedHeavy:
3725 nUnderline = awt::FontUnderline::BOLDDOTTED;
3726 break;
3727 case NS_ooxml::LN_Value_ST_Underline_dashedHeavy:
3728 nUnderline = awt::FontUnderline::BOLDDASH;
3729 break;
3730 case NS_ooxml::LN_Value_ST_Underline_dashLong:
3731 nUnderline = awt::FontUnderline::LONGDASH;
3732 break;
3733 case NS_ooxml::LN_Value_ST_Underline_dashLongHeavy:
3734 nUnderline = awt::FontUnderline::BOLDLONGDASH;
3735 break;
3736 case NS_ooxml::LN_Value_ST_Underline_dashDotHeavy:
3737 nUnderline = awt::FontUnderline::BOLDDASHDOT;
3738 break;
3739 case NS_ooxml::LN_Value_ST_Underline_dashDotDotHeavy:
3740 nUnderline = awt::FontUnderline::BOLDDASHDOTDOT;
3741 break;
3742 case NS_ooxml::LN_Value_ST_Underline_wavyHeavy:
3743 nUnderline = awt::FontUnderline::BOLDWAVE;
3744 break;
3745 case NS_ooxml::LN_Value_ST_Underline_wavyDouble:
3746 nUnderline = awt::FontUnderline::DOUBLEWAVE;
3747 break;
3748 }
3749 rContext->Insert(PROP_CHAR_UNDERLINE, uno::makeAny(nUnderline));
3750}
3751
3752void DomainMapper::handleParaJustification(const sal_Int32 nIntValue, const ::tools::SvRef<PropertyMap>& rContext, const bool bExchangeLeftRight)
3753{
3754 style::ParagraphAdjust nAdjust = style::ParagraphAdjust_LEFT;
3755 style::ParagraphAdjust nLastLineAdjust = style::ParagraphAdjust_LEFT;
3756 OUString aStringValue = "left";
3757 switch(nIntValue)
3758 {
3759 case NS_ooxml::LN_Value_ST_Jc_center:
3760 nAdjust = style::ParagraphAdjust_CENTER;
3761 aStringValue = "center";
3762 break;
3763 case NS_ooxml::LN_Value_ST_Jc_right:
3764 case NS_ooxml::LN_Value_ST_Jc_end:
3765 nAdjust = bExchangeLeftRight ? style::ParagraphAdjust_LEFT : style::ParagraphAdjust_RIGHT;
3766 aStringValue = "right";
3767 break;
3768 case NS_ooxml::LN_Value_ST_Jc_distribute:
3769 nLastLineAdjust = style::ParagraphAdjust_BLOCK;
3770 [[fallthrough]];
3771 case NS_ooxml::LN_Value_ST_Jc_both:
3772 nAdjust = style::ParagraphAdjust_BLOCK;
3773 aStringValue = "both";
3774 break;
3775 case NS_ooxml::LN_Value_ST_Jc_left:
3776 case NS_ooxml::LN_Value_ST_Jc_start:
3777 default:
3778 nAdjust = bExchangeLeftRight ? style::ParagraphAdjust_RIGHT : style::ParagraphAdjust_LEFT;
3779 break;
3780 }
3781 rContext->Insert( PROP_PARA_ADJUST, uno::makeAny( nAdjust ) );
3782 rContext->Insert( PROP_PARA_LAST_LINE_ADJUST, uno::makeAny( nLastLineAdjust ) );
3783 m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "jc", aStringValue);
3784}
3785
3786bool DomainMapper::getColorFromId(const Id nId, sal_Int32 &nColor)
3787{
3788 nColor = 0;
3789 if ((nId < NS_ooxml::LN_Value_ST_HighlightColor_black) || (nId > NS_ooxml::LN_Value_ST_HighlightColor_lightGray))
3790 return false;
3791
3792 switch (nId)
3793 {
3794 case NS_ooxml::LN_Value_ST_HighlightColor_black: nColor=0x000000; break;
3795 case NS_ooxml::LN_Value_ST_HighlightColor_blue: nColor=0x0000ff; break;
3796 case NS_ooxml::LN_Value_ST_HighlightColor_cyan: nColor=0x00ffff; break;
3797 case NS_ooxml::LN_Value_ST_HighlightColor_green: nColor=0x00ff00; break;
3798 case NS_ooxml::LN_Value_ST_HighlightColor_magenta: nColor=0xff00ff; break;
3799 case NS_ooxml::LN_Value_ST_HighlightColor_red: nColor=0xff0000; break;
3800 case NS_ooxml::LN_Value_ST_HighlightColor_yellow: nColor=0xffff00; break;
3801 case NS_ooxml::LN_Value_ST_HighlightColor_white: nColor=0xffffff; break;
3802 case NS_ooxml::LN_Value_ST_HighlightColor_darkBlue: nColor=0x000080; break;
3803 case NS_ooxml::LN_Value_ST_HighlightColor_darkCyan: nColor=0x008080; break;
3804 case NS_ooxml::LN_Value_ST_HighlightColor_darkGreen: nColor=0x008000; break;
3805 case NS_ooxml::LN_Value_ST_HighlightColor_darkMagenta: nColor=0x800080; break;
3806 case NS_ooxml::LN_Value_ST_HighlightColor_darkRed: nColor=0x800000; break;
3807 case NS_ooxml::LN_Value_ST_HighlightColor_darkYellow: nColor=0x808000; break;
3808 case NS_ooxml::LN_Value_ST_HighlightColor_darkGray: nColor=0x808080; break;
3809 case NS_ooxml::LN_Value_ST_HighlightColor_lightGray: nColor=0xC0C0C0; break;
3810 default:
3811 return false;
3812 }
3813 return true;
3814}
3815
3816sal_Int16 DomainMapper::getEmphasisValue(const sal_Int32 nIntValue)
3817{
3818 switch (nIntValue)
3819 {
3820 case NS_ooxml::LN_Value_ST_Em_dot:
3821 return text::FontEmphasis::DOT_ABOVE;
3822 case NS_ooxml::LN_Value_ST_Em_comma:
3823 return text::FontEmphasis::ACCENT_ABOVE;
3824 case NS_ooxml::LN_Value_ST_Em_circle:
3825 return text::FontEmphasis::CIRCLE_ABOVE;
3826 case NS_ooxml::LN_Value_ST_Em_underDot:
3827 return text::FontEmphasis::DOT_BELOW;
3828 default:
3829 return text::FontEmphasis::NONE;
3830 }
3831}
3832
3833OUString DomainMapper::getBracketStringFromEnum(const sal_Int32 nIntValue, const bool bIsPrefix)
3834{
3835 switch(nIntValue)
3836 {
3837 case NS_ooxml::LN_Value_ST_CombineBrackets_round:
3838 if (bIsPrefix)
3839 return "(";
3840 return ")";
3841
3842 case NS_ooxml::LN_Value_ST_CombineBrackets_square:
3843 if (bIsPrefix)
3844 return "[";
3845 return "]";
3846
3847 case NS_ooxml::LN_Value_ST_CombineBrackets_angle:
3848 if (bIsPrefix)
3849 return "<";
3850 return ">";
3851
3852 case NS_ooxml::LN_Value_ST_CombineBrackets_curly:
3853 if (bIsPrefix)
3854 return "{";
3855 return "}";
3856
3857 case NS_ooxml::LN_Value_ST_CombineBrackets_none:
3858 default:
3859 return OUString();
3860 }
3861}
3862
3863style::TabAlign DomainMapper::getTabAlignFromValue(const sal_Int32 nIntValue)
3864{
3865 switch (nIntValue)
3866 {
3867 case NS_ooxml::LN_Value_ST_TabJc_start:
3868 case NS_ooxml::LN_Value_ST_TabJc_left:
3869 case NS_ooxml::LN_Value_ST_TabJc_bar: // bar not supported
3870 case NS_ooxml::LN_Value_ST_TabJc_num: // num not supported
3871 return style::TabAlign_LEFT;
3872 case NS_ooxml::LN_Value_ST_TabJc_center:
3873 return style::TabAlign_CENTER;
3874 case NS_ooxml::LN_Value_ST_TabJc_end:
3875 case NS_ooxml::LN_Value_ST_TabJc_right:
3876 return style::TabAlign_RIGHT;
3877 case NS_ooxml::LN_Value_ST_TabJc_decimal:
3878 return style::TabAlign_DECIMAL;
3879 }
3880 return style::TabAlign_LEFT;
3881}
3882
3883sal_Unicode DomainMapper::getFillCharFromValue(const sal_Int32 nIntValue)
3884{
3885 switch (nIntValue)
3886 {
3887 case NS_ooxml::LN_Value_ST_TabTlc_dot:
3888 return u'.';
3889 case NS_ooxml::LN_Value_ST_TabTlc_hyphen:
3890 return u'-';
3891 case NS_ooxml::LN_Value_ST_TabTlc_underscore:
3892 case NS_ooxml::LN_Value_ST_TabTlc_heavy: // FIXME ???
3893 return u'_';
3894 case NS_ooxml::LN_Value_ST_TabTlc_middleDot: // middleDot
3895 return u'\x00b7';
3896 case NS_ooxml::LN_Value_ST_TabTlc_none:
3897 default:
3898 return u' '; // blank space
3899 }
3900}
3901
3902bool DomainMapper::IsOOXMLImport() const
3903{
3904 return m_pImpl->IsOOXMLImport();
3905}
3906
3907bool DomainMapper::IsRTFImport() const
3908{
3909 return m_pImpl->IsRTFImport();
3910}
3911
3912uno::Reference < lang::XMultiServiceFactory > const & DomainMapper::GetTextFactory() const
3913{
3914 return m_pImpl->GetTextFactory();
3915}
3916
3917uno::Reference< text::XTextRange > DomainMapper::GetCurrentTextRange()
3918{
3919 if (m_pImpl->HasTopText())
3920 return m_pImpl->GetTopTextAppend()->getEnd();
3921 return m_pImpl->m_xInsertTextRange;
3922}
3923
3924OUString DomainMapper::getOrCreateCharStyle( PropertyValueVector_t& rCharProperties, bool bAlwaysCreate )
3925{
3926 StyleSheetTablePtr pStyleSheets = m_pImpl->GetStyleSheetTable();
3927 return pStyleSheets->getOrCreateCharStyle( rCharProperties, bAlwaysCreate );
3928}
3929
3930StyleSheetTablePtr const & DomainMapper::GetStyleSheetTable( )
3931{
3932 return m_pImpl->GetStyleSheetTable( );
3933}
3934
3935SettingsTablePtr const & DomainMapper::GetSettingsTable()
3936{
3937 return m_pImpl->GetSettingsTable();
3938}
3939
3940GraphicZOrderHelper* DomainMapper::graphicZOrderHelper()
3941{
3942 if (zOrderHelper == nullptr)
3943 zOrderHelper.reset( new GraphicZOrderHelper );
3944 return zOrderHelper.get();
3945}
3946
3947GraphicNamingHelper& DomainMapper::GetGraphicNamingHelper()
3948{
3949 if (m_pGraphicNamingHelper == nullptr)
3950 m_pGraphicNamingHelper.reset(new GraphicNamingHelper());
3951 return *m_pGraphicNamingHelper;
3952}
3953
3954uno::Reference<drawing::XShape> DomainMapper::PopPendingShape()
3955{
3956 return m_pImpl->PopPendingShape();
3957}
3958
3959bool DomainMapper::IsInHeaderFooter() const
3960{
3961 return m_pImpl->IsInHeaderFooter();
3962}
3963
3964bool DomainMapper::IsInShape() const { return m_pImpl->IsInShape(); }
3965
3966bool DomainMapper::IsInTable() const
3967{
3968 return m_pImpl->hasTableManager() && m_pImpl->getTableManager().isInCell();
3969}
3970
3971OUString DomainMapper::GetListStyleName(sal_Int32 nListId) const
3972{
3973 return m_pImpl->GetListStyleName( nListId );
3974}
3975
3976bool DomainMapper::IsStyleSheetImport() const
3977{
3978 return m_pImpl->IsStyleSheetImport();
3979}
3980
3981void DomainMapper::enableInteropGrabBag(const OUString& aName)
3982{
3983 m_pImpl->m_aInteropGrabBagName = aName;
3984}
3985
3986beans::PropertyValue DomainMapper::getInteropGrabBag()
3987{
3988 beans::PropertyValue aRet;
3989 aRet.Name = m_pImpl->m_aInteropGrabBagName;
3990 aRet.Value <<= comphelper::containerToSequence(m_pImpl->m_aInteropGrabBag);
3991
3992 m_pImpl->m_aInteropGrabBag.clear();
3993 m_pImpl->m_aInteropGrabBagName.clear();
3994 return aRet;
3995}
3996
3997void DomainMapper::HandleRedline( Sprm& rSprm )
3998{
3999 sal_uInt32 nSprmId = rSprm.getId();
4000
4001 m_pImpl->AddNewRedline( nSprmId );
4002
4003 if (nSprmId == NS_ooxml::LN_CT_PPr_pPrChange)
4004 {
4005 m_pImpl->SetCurrentRedlineToken(XML_ParagraphFormat);
4006 }
4007 else if (nSprmId == NS_ooxml::LN_CT_TrPr_ins)
4008 {
4009 m_pImpl->SetCurrentRedlineToken(XML_tableRowInsert);
4010 }
4011 else if (nSprmId == NS_ooxml::LN_CT_TrPr_del)
4012 {
4013 m_pImpl->SetCurrentRedlineToken(XML_tableRowDelete);
4014 }
4015 else if (nSprmId == NS_ooxml::LN_CT_TcPrBase_cellIns)
4016 {
4017 m_pImpl->SetCurrentRedlineToken(XML_tableCellInsert);
4018 }
4019 else if (nSprmId == NS_ooxml::LN_CT_TcPrBase_cellDel)
4020 {
4021 m_pImpl->SetCurrentRedlineToken(XML_tableCellDelete);
4022 }
4023
4024 resolveSprmProps(*this, rSprm );
4025 // now the properties author, date and id should be available
4026 sal_Int32 nToken = m_pImpl->GetCurrentRedlineToken();
4027 switch( nToken & 0xffff )
4028 {
4029 case XML_mod:
4030 case XML_ins:
4031 case XML_del:
4032 case XML_moveTo:
4033 case XML_moveFrom:
4034 case XML_ParagraphFormat:
4035 case XML_tableRowInsert:
4036 case XML_tableRowDelete:
4037 case XML_tableCellInsert:
4038 case XML_tableCellDelete:
4039 break;
4040 default: OSL_FAIL( "redline token other than mod, ins, del, moveTo, moveFrom or table row" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/writerfilter/source/dmapper/DomainMapper.cxx"
":" "4040" ": "), "%s", "redline token other than mod, ins, del, moveTo, moveFrom or table row"
); } } while (false)
; break;
4041 }
4042 m_pImpl->EndParaMarkerChange( );
4043 m_pImpl->SetCurrentRedlineIsRead();
4044}
4045
4046void DomainMapper::finishParagraph(const bool bRemove)
4047{
4048 if (m_pImpl->m_pSdtHelper->validateDateFormat())
4049 m_pImpl->m_pSdtHelper->createDateContentControl();
4050 m_pImpl->finishParagraph(m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH), bRemove);
4051}
4052
4053} //namespace writerfilter
4054
4055/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/tools/ref.hxx

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#ifndef INCLUDED_TOOLS_REF_HXX
20#define INCLUDED_TOOLS_REF_HXX
21
22#include <sal/config.h>
23#include <cassert>
24#include <tools/toolsdllapi.h>
25#include <utility>
26
27/**
28 This implements similar functionality to boost::intrusive_ptr
29*/
30
31namespace tools {
32
33/** T must be a class that extends SvRefBase */
34template<typename T> class SAL_DLLPUBLIC_RTTI__attribute__ ((type_visibility("default"))) SvRef final {
35public:
36 SvRef(): pObj(nullptr) {}
37
38 SvRef(SvRef&& rObj) noexcept
39 {
40 pObj = rObj.pObj;
41 rObj.pObj = nullptr;
42 }
43
44 SvRef(SvRef const & rObj): pObj(rObj.pObj)
45 {
46 if (pObj != nullptr) pObj->AddNextRef();
47 }
48
49 SvRef(T * pObjP): pObj(pObjP)
50 {
51 if (pObj != nullptr) pObj->AddFirstRef();
52 }
53
54 ~SvRef()
55 {
56 if (pObj != nullptr) pObj->ReleaseRef();
5
Assuming the condition is true
6
Taking true branch
7
Calling 'SvRefBase::ReleaseRef'
14
Returning; memory was released
57 }
58
59 void clear()
60 {
61 if (pObj != nullptr) {
62 T * pRefObj = pObj;
63 pObj = nullptr;
64 pRefObj->ReleaseRef();
65 }
66 }
67
68 SvRef & operator =(SvRef const & rObj)
69 {
70 if (rObj.pObj != nullptr) {
71 rObj.pObj->AddNextRef();
72 }
73 T * pRefObj = pObj;
74 pObj = rObj.pObj;
75 if (pRefObj != nullptr) {
76 pRefObj->ReleaseRef();
77 }
78 return *this;
79 }
80
81 SvRef & operator =(SvRef && rObj)
82 {
83 if (pObj != nullptr) {
84 pObj->ReleaseRef();
85 }
86 pObj = rObj.pObj;
87 rObj.pObj = nullptr;
88 return *this;
89 }
90
91 bool is() const { return pObj != nullptr; }
92
93 explicit operator bool() const { return is(); }
94
95 T * get() const { return pObj; }
96
97 T * operator ->() const { assert(pObj != nullptr)(static_cast <bool> (pObj != nullptr) ? void (0) : __assert_fail
("pObj != nullptr", "/home/maarten/src/libreoffice/core/include/tools/ref.hxx"
, 97, __extension__ __PRETTY_FUNCTION__))
; return pObj; }
98
99 T & operator *() const { assert(pObj != nullptr)(static_cast <bool> (pObj != nullptr) ? void (0) : __assert_fail
("pObj != nullptr", "/home/maarten/src/libreoffice/core/include/tools/ref.hxx"
, 99, __extension__ __PRETTY_FUNCTION__))
; return *pObj; }
100
101 bool operator ==(const SvRef<T> &rhs) const { return pObj == rhs.pObj; }
102 bool operator !=(const SvRef<T> &rhs) const { return !(*this == rhs); }
103
104private:
105 T * pObj;
106};
107
108/**
109 * This implements similar functionality to std::make_shared.
110 */
111template<typename T, typename... Args>
112SvRef<T> make_ref(Args&& ... args)
113{
114 return SvRef<T>(new T(std::forward<Args>(args)...));
115}
116
117}
118
119/** Classes that want to be referenced-counted via SvRef<T>, should extend this base class */
120class TOOLS_DLLPUBLIC__attribute__ ((visibility("default"))) SvRefBase
121{
122 // work around a clang 3.5 optimization bug: if the bNoDelete is *first*
123 // it mis-compiles "if (--nRefCount == 0)" and never deletes any object
124 unsigned int nRefCount : 31;
125 // the only reason this is not bool is because MSVC cannot handle mixed type bitfields
126 unsigned int bNoDelete : 1;
127
128protected:
129 virtual ~SvRefBase() COVERITY_NOEXCEPT_FALSE;
130
131public:
132 SvRefBase() : nRefCount(0), bNoDelete(1) {}
133 SvRefBase(const SvRefBase &) : nRefCount(0), bNoDelete(1) {}
134
135 SvRefBase & operator=(const SvRefBase &) { return *this; }
136
137 void RestoreNoDelete()
138 { bNoDelete = 1; }
139
140 void AddNextRef()
141 {
142 assert( nRefCount < (1 << 30) && "Do not add refs to dead objects" )(static_cast <bool> (nRefCount < (1 << 30) &&
"Do not add refs to dead objects") ? void (0) : __assert_fail
("nRefCount < (1 << 30) && \"Do not add refs to dead objects\""
, "/home/maarten/src/libreoffice/core/include/tools/ref.hxx",
142, __extension__ __PRETTY_FUNCTION__))
;
143 ++nRefCount;
144 }
145
146 void AddFirstRef()
147 {
148 assert( nRefCount < (1 << 30) && "Do not add refs to dead objects" )(static_cast <bool> (nRefCount < (1 << 30) &&
"Do not add refs to dead objects") ? void (0) : __assert_fail
("nRefCount < (1 << 30) && \"Do not add refs to dead objects\""
, "/home/maarten/src/libreoffice/core/include/tools/ref.hxx",
148, __extension__ __PRETTY_FUNCTION__))
;
149 if( bNoDelete )
150 bNoDelete = 0;
151 ++nRefCount;
152 }
153
154 void ReleaseRef()
155 {
156 assert( nRefCount >= 1)(static_cast <bool> (nRefCount >= 1) ? void (0) : __assert_fail
("nRefCount >= 1", "/home/maarten/src/libreoffice/core/include/tools/ref.hxx"
, 156, __extension__ __PRETTY_FUNCTION__))
;
8
Assuming field 'nRefCount' is >= 1
9
'?' condition is true
157 if( --nRefCount == 0 && !bNoDelete)
10
Assuming the condition is true
11
Assuming field 'bNoDelete' is 0
12
Taking true branch
158 {
159 // I'm not sure about the original purpose of this line, but right now
160 // it serves the purpose that anything that attempts to do an AddRef()
161 // after an object is deleted will trip an assert.
162 nRefCount = 1 << 30;
163 delete this;
13
Memory is released
164 }
165 }
166
167 unsigned int GetRefCount() const
168 { return nRefCount; }
169};
170
171template<typename T>
172class SvCompatWeakBase;
173
174/** SvCompatWeakHdl acts as an intermediary between SvCompatWeakRef<T> and T.
175*/
176template<typename T>
177class SvCompatWeakHdl final : public SvRefBase
178{
179 friend class SvCompatWeakBase<T>;
180 T* _pObj;
181
182 SvCompatWeakHdl( T* pObj ) : _pObj( pObj ) {}
183
184public:
185 void ResetWeakBase( ) { _pObj = nullptr; }
186 T* GetObj() { return _pObj; }
187};
188
189/** We only have one place that extends this, in include/sfx2/frame.hxx, class SfxFrame.
190 Its function is to notify the SvCompatWeakHdl when an SfxFrame object is deleted.
191*/
192template<typename T>
193class SvCompatWeakBase
194{
195 tools::SvRef< SvCompatWeakHdl<T> > _xHdl;
196
197public:
198 /** Does not use initializer due to compiler warnings,
199 because the lifetime of the _xHdl object can exceed the lifetime of this class.
200 */
201 SvCompatWeakBase( T* pObj ) { _xHdl = new SvCompatWeakHdl<T>( pObj ); }
202
203 ~SvCompatWeakBase() { _xHdl->ResetWeakBase(); }
204
205 SvCompatWeakHdl<T>* GetHdl() { return _xHdl.get(); }
206};
207
208/** We only have one weak reference in LO, in include/sfx2/frame.hxx, class SfxFrameWeak.
209*/
210template<typename T>
211class SAL_WARN_UNUSED__attribute__((warn_unused)) SvCompatWeakRef
212{
213 tools::SvRef< SvCompatWeakHdl<T> > _xHdl;
214public:
215 SvCompatWeakRef( ) {}
216 SvCompatWeakRef( T* pObj )
217 { if( pObj ) _xHdl = pObj->GetHdl(); }
218#if defined(__COVERITY__)
219 ~SvCompatWeakRef() COVERITY_NOEXCEPT_FALSE {}
220#endif
221 SvCompatWeakRef& operator = ( T * pObj )
222 { _xHdl = pObj ? pObj->GetHdl() : nullptr; return *this; }
223 bool is() const
224 { return _xHdl.is() && _xHdl->GetObj(); }
225 explicit operator bool() const { return is(); }
226 T* operator -> () const
227 { return _xHdl.is() ? _xHdl->GetObj() : nullptr; }
228 operator T* () const
229 { return _xHdl.is() ? _xHdl->GetObj() : nullptr; }
230};
231
232#endif
233
234/* vim:set shiftwidth=4 softtabstop=4 expandtab: */