Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #include "PageBordersHandler.hxx"
20 :
21 : #include <resourcemodel/QNameToString.hxx>
22 : #include <resourcemodel/ResourceModelHelper.hxx>
23 : #include <SdtHelper.hxx>
24 : #include <TDefTableHandler.hxx>
25 : #include <DomainMapper_Impl.hxx>
26 : #include <ConversionHelper.hxx>
27 : #include <ModelEventListener.hxx>
28 : #include <MeasureHandler.hxx>
29 : #include <i18nlangtag/languagetag.hxx>
30 : #include <i18nutil/paper.hxx>
31 : #include <ooxml/OOXMLFastTokens.hxx>
32 : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
33 : #include <com/sun/star/document/XOOXMLDocumentPropertiesImporter.hpp>
34 : #include <com/sun/star/table/ShadowFormat.hpp>
35 : #include <com/sun/star/text/HoriOrientation.hpp>
36 : #include <com/sun/star/text/RelOrientation.hpp>
37 : #include <com/sun/star/text/VertOrientation.hpp>
38 : #include <com/sun/star/text/WrapTextMode.hpp>
39 : #include <com/sun/star/text/SizeType.hpp>
40 : #include <com/sun/star/text/XEndnotesSupplier.hpp>
41 : #include <com/sun/star/text/XFootnotesSupplier.hpp>
42 : #include <com/sun/star/text/XLineNumberingProperties.hpp>
43 : #include <com/sun/star/awt/FontRelief.hpp>
44 : #include <com/sun/star/awt/FontWeight.hpp>
45 : #include <com/sun/star/awt/FontUnderline.hpp>
46 : #include <com/sun/star/awt/FontStrikeout.hpp>
47 : #include <com/sun/star/awt/FontSlant.hpp>
48 : #include <com/sun/star/document/XEventBroadcaster.hpp>
49 : #include <com/sun/star/style/ParagraphAdjust.hpp>
50 : #include <com/sun/star/style/BreakType.hpp>
51 : #include <com/sun/star/style/CaseMap.hpp>
52 : #include <com/sun/star/style/LineSpacing.hpp>
53 : #include <com/sun/star/style/LineSpacingMode.hpp>
54 : #include <com/sun/star/text/FootnoteNumbering.hpp>
55 : #include <com/sun/star/text/TextGridMode.hpp>
56 : #include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
57 : #include <com/sun/star/text/XTextFieldsSupplier.hpp>
58 : #include <com/sun/star/text/WritingMode.hpp>
59 : #include <com/sun/star/text/WritingMode2.hpp>
60 : #include <com/sun/star/text/XFootnote.hpp>
61 : #include <com/sun/star/text/XTextColumns.hpp>
62 : #include <com/sun/star/uno/XComponentContext.hpp>
63 : #include <comphelper/types.hxx>
64 : #include <comphelper/storagehelper.hxx>
65 : #include <filter/msfilter/util.hxx>
66 :
67 : #include <TextEffectsHandler.hxx>
68 : #include <CellColorHandler.hxx>
69 : #include <SectionColumnHandler.hxx>
70 : #include <GraphicHelpers.hxx>
71 :
72 : using namespace ::com::sun::star;
73 : using namespace ::rtl;
74 :
75 : namespace writerfilter {
76 :
77 : using resourcemodel::resolveSprmProps;
78 :
79 : namespace dmapper{
80 :
81 0 : TagLogger::Pointer_t dmapper_logger(TagLogger::getInstance("DOMAINMAPPER"));
82 :
83 : struct _PageSz
84 : {
85 : sal_Int32 code;
86 : sal_Int32 h;
87 : bool orient;
88 : sal_Int32 w;
89 : } CT_PageSz;
90 :
91 :
92 0 : DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xContext,
93 : uno::Reference< io::XInputStream > xInputStream,
94 : uno::Reference< lang::XComponent > xModel,
95 : bool bRepairStorage,
96 : SourceDocumentType eDocumentType,
97 : uno::Reference< text::XTextRange > xInsertTextRange,
98 : bool bIsNewDoc ) :
99 : LoggedProperties(dmapper_logger, "DomainMapper"),
100 : LoggedTable(dmapper_logger, "DomainMapper"),
101 : LoggedStream(dmapper_logger, "DomainMapper"),
102 0 : m_pImpl( new DomainMapper_Impl( *this, xContext, xModel, eDocumentType, xInsertTextRange, bIsNewDoc )),
103 0 : mnBackgroundColor(0), mbIsHighlightSet(false), mbIsSplitPara(false)
104 : {
105 : // #i24363# tab stops relative to indent
106 : m_pImpl->SetDocumentSettingsProperty(
107 0 : PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_TABS_RELATIVE_TO_INDENT ),
108 0 : uno::makeAny( false ) );
109 : m_pImpl->SetDocumentSettingsProperty(
110 0 : PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_SURROUND_TEXT_WRAP_SMALL ),
111 0 : uno::makeAny( true ) );
112 :
113 : //import document properties
114 : try
115 : {
116 : uno::Reference< embed::XStorage > xDocumentStorage =
117 0 : (comphelper::OStorageHelper::GetStorageOfFormatFromInputStream(OFOPXML_STORAGE_FORMAT_STRING, xInputStream, xContext, bRepairStorage ));
118 :
119 0 : uno::Reference< uno::XInterface > xTemp = xContext->getServiceManager()->createInstanceWithContext(
120 : "com.sun.star.document.OOXMLDocumentPropertiesImporter",
121 0 : xContext);
122 :
123 0 : uno::Reference< document::XOOXMLDocumentPropertiesImporter > xImporter( xTemp, uno::UNO_QUERY_THROW );
124 0 : uno::Reference< document::XDocumentPropertiesSupplier > xPropSupplier( xModel, uno::UNO_QUERY_THROW);
125 0 : xImporter->importProperties( xDocumentStorage, xPropSupplier->getDocumentProperties() );
126 : }
127 0 : catch( const uno::Exception& rEx )
128 : {
129 : (void)rEx;
130 : }
131 0 : }
132 :
133 0 : DomainMapper::~DomainMapper()
134 : {
135 : try
136 : {
137 0 : uno::Reference< text::XDocumentIndexesSupplier> xIndexesSupplier( m_pImpl->GetTextDocument(), uno::UNO_QUERY );
138 0 : sal_Int32 nIndexes = 0;
139 0 : if( xIndexesSupplier.is() )
140 : {
141 0 : uno::Reference< container::XIndexAccess > xIndexes = xIndexesSupplier->getDocumentIndexes();
142 0 : nIndexes = xIndexes->getCount();
143 : }
144 : // If we have page references, those need updating as well, similar to the indexes.
145 0 : uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(m_pImpl->GetTextDocument(), uno::UNO_QUERY);
146 0 : if(xTextFieldsSupplier.is())
147 : {
148 0 : uno::Reference<container::XEnumeration> xEnumeration = xTextFieldsSupplier->getTextFields()->createEnumeration();
149 0 : while(xEnumeration->hasMoreElements())
150 : {
151 0 : ++nIndexes;
152 0 : xEnumeration->nextElement();
153 0 : }
154 : }
155 0 : if( nIndexes || m_pImpl->m_pSdtHelper->hasElements())
156 : {
157 : //index update has to wait until first view is created
158 0 : uno::Reference< document::XEventBroadcaster > xBroadcaster(xIndexesSupplier, uno::UNO_QUERY);
159 0 : if (xBroadcaster.is())
160 0 : xBroadcaster->addEventListener(uno::Reference< document::XEventListener >(new ModelEventListener(nIndexes, m_pImpl->m_pSdtHelper->hasElements())));
161 : }
162 :
163 :
164 : // Apply the document settings after everything else
165 0 : m_pImpl->GetSettingsTable()->ApplyProperties( m_pImpl->GetTextDocument( ) );
166 : }
167 0 : catch( const uno::Exception& rEx )
168 : {
169 : (void)rEx;
170 : }
171 :
172 0 : delete m_pImpl;
173 0 : }
174 :
175 0 : void DomainMapper::lcl_attribute(Id nName, Value & val)
176 : {
177 0 : static OUString sLocalBookmarkName;
178 0 : sal_Int32 nIntValue = val.getInt();
179 0 : OUString sStringValue = val.getString();
180 :
181 0 : SectionPropertyMap * pSectionContext = m_pImpl->GetSectionContext();
182 0 : PropertyMap::iterator oldPropValue;
183 0 : switch( nName )
184 : {
185 : case NS_ooxml::LN_CT_Lvl_start:
186 0 : break;
187 : case NS_ooxml::LN_CT_Lvl_numFmt:
188 0 : break;
189 : case NS_ooxml::LN_CT_Lvl_isLgl:
190 0 : break;
191 : case NS_ooxml::LN_CT_Lvl_legacy:
192 0 : break;
193 : case NS_ooxml::LN_CT_AbstractNum_nsid:
194 0 : break;
195 : case NS_ooxml::LN_CT_AbstractNum_tmpl:
196 0 : break;
197 : case NS_ooxml::LN_CT_Border_sz:
198 0 : break;
199 : case NS_ooxml::LN_CT_Border_val:
200 0 : break;
201 : case NS_ooxml::LN_CT_Border_space:
202 0 : break;
203 : case NS_ooxml::LN_CT_Border_shadow:
204 0 : break;
205 : case NS_ooxml::LN_CT_Border_frame:
206 0 : break;
207 : case NS_ooxml::LN_headerr:
208 0 : break;
209 : case NS_ooxml::LN_footerr:
210 0 : break;
211 : case NS_ooxml::LN_endnote:
212 0 : break;
213 : case NS_ooxml::LN_CT_Bookmark_name:
214 : // sStringValue contains the bookmark name
215 0 : sLocalBookmarkName = sStringValue;
216 0 : break;
217 : case NS_ooxml::LN_CT_MarkupRangeBookmark_id:
218 : //contains the bookmark identifier - has to be added to the bookmark name imported before
219 : //if it is already available then the bookmark should be inserted
220 0 : m_pImpl->AddBookmark( sLocalBookmarkName, sStringValue );
221 0 : sLocalBookmarkName = OUString();
222 0 : break;
223 : case NS_ooxml::LN_CT_MarkupRange_displacedByCustomXml:
224 0 : break;
225 : case NS_ooxml::LN_NUMBERING:
226 0 : break;
227 : case NS_ooxml::LN_FONTTABLE:
228 0 : break;
229 : case NS_ooxml::LN_STYLESHEET:
230 0 : break;
231 :
232 : case NS_ooxml::LN_CT_Sym_char:
233 0 : if( m_pImpl->GetTopContext() && m_pImpl->GetTopContext()->GetFootnote().is())
234 : {
235 0 : m_pImpl->GetTopContext()->GetFootnote()->setLabel(OUString( sal_Unicode(nIntValue)));
236 0 : break;
237 : }
238 : else //it's a _real_ symbol
239 : {
240 0 : utext( reinterpret_cast < const sal_uInt8 * >( &nIntValue ), 1 );
241 : }
242 0 : break;
243 : case NS_ooxml::LN_CT_Sym_font:
244 : //the footnote symbol and font are provided after the footnote is already inserted
245 0 : if( m_pImpl->GetTopContext() && m_pImpl->GetTopContext()->GetFootnote().is())
246 : {
247 0 : uno::Reference< beans::XPropertySet > xAnchorProps( m_pImpl->GetTopContext()->GetFootnote()->getAnchor(), uno::UNO_QUERY );
248 0 : xAnchorProps->setPropertyValue(
249 0 : PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_CHAR_FONT_NAME),
250 0 : uno::makeAny( sStringValue ));
251 : }
252 : else //a real symbol
253 0 : if (m_pImpl->GetTopContext())
254 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME, uno::makeAny( sStringValue ));
255 0 : break;
256 : case NS_ooxml::LN_CT_Underline_val:
257 0 : handleUnderlineType(nIntValue, m_pImpl->GetTopContext());
258 0 : break;
259 : case NS_ooxml::LN_CT_Color_val:
260 0 : if (m_pImpl->GetTopContext())
261 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_COLOR, uno::makeAny( nIntValue ) );
262 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "val", OStringToOUString(msfilter::util::ConvertColor(nIntValue, /*bAutoColor=*/true), RTL_TEXTENCODING_UTF8));
263 0 : break;
264 : case NS_ooxml::LN_CT_Underline_color:
265 0 : if (m_pImpl->GetTopContext())
266 : {
267 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_UNDERLINE_HAS_COLOR, uno::makeAny( true ) );
268 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_UNDERLINE_COLOR, uno::makeAny( nIntValue ) );
269 : }
270 0 : break;
271 :
272 : case NS_ooxml::LN_CT_TabStop_val:
273 0 : if (sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_ST_TabJc_clear)
274 : {
275 0 : m_pImpl->m_aCurrentTabStop.bDeleted = true;
276 : }
277 : else
278 : {
279 0 : m_pImpl->m_aCurrentTabStop.bDeleted = false;
280 0 : m_pImpl->m_aCurrentTabStop.Alignment = getTabAlignFromValue(nIntValue);
281 : }
282 0 : break;
283 : case NS_ooxml::LN_CT_TabStop_leader:
284 0 : m_pImpl->m_aCurrentTabStop.FillChar = getFillCharFromValue(nIntValue);
285 0 : break;
286 : case NS_ooxml::LN_CT_TabStop_pos:
287 0 : m_pImpl->m_aCurrentTabStop.Position = ConversionHelper::convertTwipToMM100(nIntValue);
288 0 : break;
289 :
290 : case NS_ooxml::LN_CT_Fonts_ascii:
291 0 : if (m_pImpl->GetTopContext())
292 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME, uno::makeAny( sStringValue ));
293 0 : break;
294 : case NS_ooxml::LN_CT_Fonts_asciiTheme:
295 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "asciiTheme", ThemeTable::getStringForTheme(nIntValue));
296 0 : if (m_pImpl->GetTopContext())
297 : {
298 0 : uno::Any aPropValue = uno::makeAny( m_pImpl->GetThemeTable()->getFontNameForTheme( nIntValue ) );
299 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME, aPropValue );
300 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_FONT_NAME_ASCII, aPropValue, true, CHAR_GRAB_BAG );
301 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_NAME_ASCII, uno::makeAny( ThemeTable::getStringForTheme(nIntValue) ), true, CHAR_GRAB_BAG);
302 : }
303 0 : break;
304 : case NS_ooxml::LN_CT_Fonts_hAnsi:
305 0 : break;//unsupported
306 : case NS_ooxml::LN_CT_Fonts_hAnsiTheme:
307 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "hAnsiTheme", ThemeTable::getStringForTheme(nIntValue));
308 0 : if (m_pImpl->GetTopContext())
309 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_NAME_H_ANSI, uno::makeAny( ThemeTable::getStringForTheme(nIntValue) ), true, CHAR_GRAB_BAG);
310 0 : break;
311 : case NS_ooxml::LN_CT_Fonts_eastAsia:
312 0 : if (m_pImpl->GetTopContext())
313 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME_ASIAN, uno::makeAny( sStringValue ));
314 0 : break;
315 : case NS_ooxml::LN_CT_Fonts_eastAsiaTheme:
316 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "eastAsiaTheme", ThemeTable::getStringForTheme(nIntValue));
317 0 : if (m_pImpl->GetTopContext())
318 : {
319 0 : uno::Any aPropValue = uno::makeAny( m_pImpl->GetThemeTable()->getFontNameForTheme( nIntValue ) );
320 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME_ASIAN, aPropValue );
321 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_FONT_NAME_EAST_ASIA, aPropValue, true, CHAR_GRAB_BAG );
322 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_NAME_EAST_ASIA, uno::makeAny( ThemeTable::getStringForTheme(nIntValue) ), true, CHAR_GRAB_BAG);
323 : }
324 0 : break;
325 : case NS_ooxml::LN_CT_Fonts_cs:
326 0 : if (m_pImpl->GetTopContext())
327 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME_COMPLEX, uno::makeAny( sStringValue ));
328 0 : break;
329 : case NS_ooxml::LN_CT_Fonts_cstheme:
330 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "cstheme", ThemeTable::getStringForTheme(nIntValue));
331 0 : if (m_pImpl->GetTopContext())
332 : {
333 0 : uno::Any aPropValue = uno::makeAny( m_pImpl->GetThemeTable()->getFontNameForTheme( nIntValue ) );
334 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME_COMPLEX, aPropValue );
335 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_FONT_NAME_CS, aPropValue, true, CHAR_GRAB_BAG );
336 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_NAME_CS, uno::makeAny( ThemeTable::getStringForTheme(nIntValue) ), true, CHAR_GRAB_BAG);
337 : }
338 0 : break;
339 : case NS_ooxml::LN_CT_Spacing_before:
340 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "before", OUString::number(nIntValue));
341 0 : if (m_pImpl->GetTopContext())
342 : // Don't overwrite NS_ooxml::LN_CT_Spacing_beforeAutospacing.
343 0 : m_pImpl->GetTopContext()->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100( nIntValue ) ), false);
344 0 : break;
345 : case NS_ooxml::LN_CT_Spacing_beforeLines:
346 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "beforeLines", OUString::number(nIntValue));
347 0 : break;
348 : case NS_ooxml::LN_CT_Spacing_after:
349 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "after", OUString::number(nIntValue));
350 0 : if (m_pImpl->GetTopContext())
351 : // Don't overwrite NS_ooxml::LN_CT_Spacing_afterAutospacing.
352 0 : m_pImpl->GetTopContext()->Insert(PROP_PARA_BOTTOM_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100( nIntValue ) ), false);
353 0 : break;
354 : case NS_ooxml::LN_CT_Spacing_afterLines:
355 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "afterLines", OUString::number(nIntValue));
356 0 : break;
357 : case NS_ooxml::LN_CT_Spacing_line: //91434
358 : case NS_ooxml::LN_CT_Spacing_lineRule: //91435
359 : {
360 : #define SINGLE_LINE_SPACING 240
361 0 : style::LineSpacing aSpacing;
362 0 : PropertyMapPtr pTopContext = m_pImpl->GetTopContext();
363 0 : bool bFound = false;
364 0 : PropertyMap::iterator aLineSpacingIter;
365 0 : if (pTopContext)
366 : {
367 0 : aLineSpacingIter = pTopContext->find(PROP_PARA_LINE_SPACING);
368 0 : bFound = aLineSpacingIter != pTopContext->end();
369 : }
370 0 : if (bFound)
371 : {
372 0 : aLineSpacingIter->second.getValue() >>= aSpacing;
373 : }
374 : else
375 : {
376 : //default to single line spacing
377 0 : aSpacing.Mode = style::LineSpacingMode::FIX;
378 0 : aSpacing.Height = sal_Int16(ConversionHelper::convertTwipToMM100( SINGLE_LINE_SPACING ));
379 : }
380 0 : if( nName == NS_ooxml::LN_CT_Spacing_line )
381 : {
382 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "line", OUString::number(nIntValue));
383 : //now set the value depending on the Mode
384 0 : if( aSpacing.Mode == style::LineSpacingMode::PROP )
385 0 : aSpacing.Height = sal_Int16(sal_Int32(nIntValue) * 100 / SINGLE_LINE_SPACING );
386 : else
387 0 : aSpacing.Height = sal_Int16(ConversionHelper::convertTwipToMM100( nIntValue ));
388 : }
389 : else //NS_ooxml::LN_CT_Spacing_lineRule:
390 : {
391 : // exactly, atLeast, auto
392 0 : if( sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_wordprocessingml_ST_LineSpacingRule_auto)
393 : {
394 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "lineRule", "auto");
395 0 : aSpacing.Mode = style::LineSpacingMode::PROP;
396 : //reinterpret the already set value
397 0 : aSpacing.Height = sal_Int16( aSpacing.Height * 100 / ConversionHelper::convertTwipToMM100( SINGLE_LINE_SPACING ));
398 : }
399 0 : else if( sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_wordprocessingml_ST_LineSpacingRule_atLeast)
400 : {
401 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "lineRule", "atLeast");
402 0 : aSpacing.Mode = style::LineSpacingMode::MINIMUM;
403 : }
404 : else // NS_ooxml::LN_Value_wordprocessingml_ST_LineSpacingRule_exact
405 : {
406 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "lineRule", "exact");
407 0 : aSpacing.Mode = style::LineSpacingMode::FIX;
408 : }
409 : }
410 0 : if (pTopContext)
411 0 : pTopContext->Insert(PROP_PARA_LINE_SPACING, uno::makeAny( aSpacing ));
412 : }
413 0 : break;
414 : case NS_ooxml::LN_CT_Ind_start:
415 : case NS_ooxml::LN_CT_Ind_left:
416 0 : if (m_pImpl->GetTopContext())
417 : {
418 : // Word inherits FirstLineIndent property of the numbering, even if ParaLeftMargin is set, Writer does not.
419 : // So copy it explicitly, if necessary.
420 0 : sal_Int32 nFirstLineIndent = m_pImpl->getCurrentNumberingProperty("FirstLineIndent");
421 :
422 0 : if (nFirstLineIndent != 0)
423 0 : m_pImpl->GetTopContext()->Insert(PROP_PARA_FIRST_LINE_INDENT, uno::makeAny(nFirstLineIndent));
424 :
425 : m_pImpl->GetTopContext()->Insert(
426 0 : PROP_PARA_LEFT_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(nIntValue ) ));
427 : }
428 0 : break;
429 : case NS_ooxml::LN_CT_Ind_end:
430 : case NS_ooxml::LN_CT_Ind_right:
431 0 : if (m_pImpl->GetTopContext())
432 : {
433 : // Word inherits FirstLineIndent/ParaLeftMargin property of the numbering, even if ParaRightMargin is set, Writer does not.
434 : // So copy it explicitly, if necessary.
435 0 : sal_Int32 nFirstLineIndent = m_pImpl->getCurrentNumberingProperty("FirstLineIndent");
436 0 : sal_Int32 nParaLeftMargin = m_pImpl->getCurrentNumberingProperty("IndentAt");
437 :
438 0 : if (nFirstLineIndent != 0)
439 0 : m_pImpl->GetTopContext()->Insert(PROP_PARA_FIRST_LINE_INDENT, uno::makeAny(nFirstLineIndent));
440 0 : if (nParaLeftMargin != 0)
441 0 : m_pImpl->GetTopContext()->Insert(PROP_PARA_LEFT_MARGIN, uno::makeAny(nParaLeftMargin));
442 :
443 : m_pImpl->GetTopContext()->Insert(
444 0 : PROP_PARA_RIGHT_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(nIntValue ) ));
445 : }
446 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "right", OUString::number(nIntValue));
447 0 : break;
448 : case NS_ooxml::LN_CT_Ind_hanging:
449 0 : if (m_pImpl->GetTopContext())
450 : {
451 0 : sal_Int32 nValue = ConversionHelper::convertTwipToMM100( nIntValue );
452 : m_pImpl->GetTopContext()->Insert(
453 0 : PROP_PARA_FIRST_LINE_INDENT, uno::makeAny( - nValue ));
454 : }
455 0 : break;
456 : case NS_ooxml::LN_CT_Ind_firstLine:
457 0 : if (m_pImpl->GetTopContext())
458 : m_pImpl->GetTopContext()->Insert(
459 0 : PROP_PARA_FIRST_LINE_INDENT, uno::makeAny( ConversionHelper::convertTwipToMM100(nIntValue ) ));
460 0 : break;
461 : case NS_ooxml::LN_CT_Ind_rightChars:
462 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "rightChars", OUString::number(nIntValue));
463 0 : break;
464 :
465 : case NS_ooxml::LN_CT_EastAsianLayout_id:
466 0 : break;
467 : case NS_ooxml::LN_CT_EastAsianLayout_combine:
468 0 : if (m_pImpl->GetTopContext())
469 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_COMBINE_IS_ON, uno::makeAny ( nIntValue ? true : false ));
470 0 : break;
471 : case NS_ooxml::LN_CT_EastAsianLayout_combineBrackets:
472 0 : if (m_pImpl->GetTopContext())
473 : {
474 0 : OUString sCombinePrefix = getBracketStringFromEnum(nIntValue);
475 0 : OUString sCombineSuffix = getBracketStringFromEnum(nIntValue, false);
476 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_COMBINE_PREFIX, uno::makeAny ( sCombinePrefix ));
477 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_COMBINE_SUFFIX, uno::makeAny ( sCombineSuffix ));
478 : }
479 0 : break;
480 : case NS_ooxml::LN_CT_EastAsianLayout_vert:
481 0 : if (m_pImpl->GetTopContext())
482 : {
483 0 : sal_Int16 nRotationAngle = (nIntValue ? 900 : 0);
484 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_ROTATION, uno::makeAny ( nRotationAngle ));
485 : }
486 0 : break;
487 : case NS_ooxml::LN_CT_EastAsianLayout_vertCompress:
488 0 : if (m_pImpl->GetTopContext())
489 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_ROTATION_IS_FIT_TO_LINE, uno::makeAny ( nIntValue ? true : false));
490 0 : break;
491 :
492 : case NS_ooxml::LN_CT_PageSz_code:
493 0 : CT_PageSz.code = nIntValue;
494 0 : break;
495 : case NS_ooxml::LN_CT_PageSz_h:
496 : {
497 0 : sal_Int32 nHeight = ConversionHelper::convertTwipToMM100(nIntValue);
498 0 : CT_PageSz.h = PaperInfo::sloppyFitPageDimension(nHeight);
499 : }
500 0 : break;
501 : case NS_ooxml::LN_CT_PageSz_orient:
502 0 : CT_PageSz.orient = (nIntValue != 0);
503 0 : break;
504 : case NS_ooxml::LN_CT_PageSz_w:
505 : {
506 0 : sal_Int32 nWidth = ConversionHelper::convertTwipToMM100(nIntValue);
507 0 : CT_PageSz.w = PaperInfo::sloppyFitPageDimension(nWidth);
508 : }
509 0 : break;
510 :
511 : case NS_ooxml::LN_CT_PageMar_top:
512 0 : m_pImpl->SetPageMarginTwip( PAGE_MAR_TOP, nIntValue );
513 0 : break;
514 : case NS_ooxml::LN_CT_PageMar_right:
515 0 : m_pImpl->SetPageMarginTwip( PAGE_MAR_RIGHT, nIntValue );
516 0 : break;
517 : case NS_ooxml::LN_CT_PageMar_bottom:
518 0 : m_pImpl->SetPageMarginTwip( PAGE_MAR_BOTTOM, nIntValue );
519 0 : break;
520 : case NS_ooxml::LN_CT_PageMar_left:
521 0 : m_pImpl->SetPageMarginTwip( PAGE_MAR_LEFT, nIntValue );
522 0 : break;
523 : case NS_ooxml::LN_CT_PageMar_header:
524 0 : m_pImpl->SetPageMarginTwip( PAGE_MAR_HEADER, nIntValue );
525 0 : break;
526 : case NS_ooxml::LN_CT_PageMar_footer:
527 0 : m_pImpl->SetPageMarginTwip( PAGE_MAR_FOOTER, nIntValue );
528 0 : break;
529 : case NS_ooxml::LN_CT_PageMar_gutter:
530 0 : m_pImpl->SetPageMarginTwip( PAGE_MAR_GUTTER, nIntValue );
531 0 : break;
532 : case NS_ooxml::LN_CT_Language_val: //90314
533 : case NS_ooxml::LN_CT_Language_eastAsia: //90315
534 : case NS_ooxml::LN_CT_Language_bidi: //90316
535 : {
536 0 : if (nName == NS_ooxml::LN_CT_Language_eastAsia)
537 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "eastAsia", sStringValue);
538 0 : else if (nName == NS_ooxml::LN_CT_Language_val)
539 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "val", sStringValue);
540 0 : else if (nName == NS_ooxml::LN_CT_Language_bidi)
541 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "bidi", sStringValue);
542 0 : lang::Locale aLocale( LanguageTag::convertToLocale( sStringValue));
543 0 : if (m_pImpl->GetTopContext())
544 : m_pImpl->GetTopContext()->Insert(NS_ooxml::LN_CT_Language_val== nName ? PROP_CHAR_LOCALE :
545 : NS_ooxml::LN_CT_Language_eastAsia == nName ? PROP_CHAR_LOCALE_ASIAN : PROP_CHAR_LOCALE_COMPLEX,
546 0 : uno::makeAny( aLocale ) );
547 : }
548 0 : break;
549 : // See SwWW8ImplReader::GetParagraphAutoSpace() on why these are 100 and 280
550 : case NS_ooxml::LN_CT_Spacing_beforeAutospacing:
551 : {
552 0 : sal_Int32 default_spacing = 100;
553 0 : if (!m_pImpl->GetSettingsTable()->GetDoNotUseHTMLParagraphAutoSpacing())
554 : {
555 : // 49 is just the old value that should be removed, once the
556 : // root cause in SwTabFrm::MakeAll() is fixed.
557 0 : if (m_pImpl->GetSettingsTable()->GetView() == NS_ooxml::LN_Value_wordprocessingml_ST_View_web)
558 0 : default_spacing = 49;
559 : else
560 0 : default_spacing = 280;
561 : }
562 0 : if (nIntValue) // If auto spacing is set, then only store set value in InteropGrabBag
563 : {
564 0 : m_pImpl->GetTopContext()->Insert( PROP_PARA_TOP_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ) );
565 : }
566 : else
567 : {
568 0 : default_spacing = -1;
569 : }
570 0 : m_pImpl->GetTopContext()->Insert( PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ),true, PARA_GRAB_BAG );
571 : }
572 0 : break;
573 : case NS_ooxml::LN_CT_Spacing_afterAutospacing:
574 : {
575 0 : sal_Int32 default_spacing = 100;
576 :
577 0 : if (!m_pImpl->GetSettingsTable()->GetDoNotUseHTMLParagraphAutoSpacing())
578 : {
579 0 : if (m_pImpl->GetSettingsTable()->GetView() == NS_ooxml::LN_Value_wordprocessingml_ST_View_web)
580 0 : default_spacing = 49;
581 : else
582 0 : default_spacing = 280;
583 : }
584 0 : if (nIntValue) // If auto spacing is set, then only store set value in InteropGrabBag
585 : {
586 0 : m_pImpl->GetTopContext()->Insert( PROP_PARA_BOTTOM_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ) );
587 : }
588 : else
589 : {
590 0 : default_spacing = -1;
591 : }
592 0 : m_pImpl->GetTopContext()->Insert( PROP_PARA_BOTTOM_MARGIN_AFTER_AUTO_SPACING, uno::makeAny( ConversionHelper::convertTwipToMM100(default_spacing) ),true, PARA_GRAB_BAG );
593 : }
594 0 : break;
595 : case NS_ooxml::LN_CT_SmartTagRun_uri:
596 : case NS_ooxml::LN_CT_SmartTagRun_element:
597 : //TODO: add handling of SmartTags
598 0 : break;
599 : case NS_ooxml::LN_CT_Br_type :
600 : //TODO: attributes for break (0x12) are not supported
601 0 : break;
602 : case NS_ooxml::LN_CT_Fonts_hint :
603 : /* assigns script type to ambigous characters, values can be:
604 : NS_ooxml::LN_Value_ST_Hint_default
605 : NS_ooxml::LN_Value_ST_Hint_eastAsia
606 : NS_ooxml::LN_Value_ST_Hint_cs
607 : */
608 : //TODO: unsupported?
609 0 : break;
610 : case NS_ooxml::LN_CT_TblCellMar_right: // 92375;
611 : case NS_ooxml::LN_CT_TblBorders_top: // 92377;
612 : case NS_ooxml::LN_CT_TblBorders_left: // 92378;
613 : case NS_ooxml::LN_CT_TblBorders_bottom: // 92379;
614 : //todo: handle cell mar
615 0 : break;
616 : case NS_ooxml::LN_blip: // contains the binary graphic
617 : case NS_ooxml::LN_shape:
618 : {
619 : //looks a bit like a hack - and it is. The graphic import is split into the inline_inline part and
620 : //afterwards the adding of the binary data.
621 0 : m_pImpl->GetGraphicImport( IMPORT_AS_DETECTED_INLINE )->attribute(nName, val);
622 0 : m_pImpl->ImportGraphic( val.getProperties(), IMPORT_AS_DETECTED_INLINE );
623 : }
624 0 : break;
625 : case NS_ooxml::LN_starmath:
626 0 : m_pImpl->appendStarMath( val );
627 0 : break;
628 : case NS_ooxml::LN_CT_FramePr_dropCap:
629 : case NS_ooxml::LN_CT_FramePr_lines:
630 : case NS_ooxml::LN_CT_FramePr_hAnchor:
631 : case NS_ooxml::LN_CT_FramePr_vAnchor:
632 : case NS_ooxml::LN_CT_FramePr_x:
633 : case NS_ooxml::LN_CT_FramePr_xAlign:
634 : case NS_ooxml::LN_CT_FramePr_y:
635 : case NS_ooxml::LN_CT_FramePr_yAlign:
636 : case NS_ooxml::LN_CT_FramePr_hRule:
637 : case NS_ooxml::LN_CT_FramePr_w:
638 : case NS_ooxml::LN_CT_FramePr_h:
639 : case NS_ooxml::LN_CT_FramePr_wrap:
640 : case NS_ooxml::LN_CT_FramePr_hSpace:
641 : case NS_ooxml::LN_CT_FramePr_vSpace:
642 : {
643 : ParagraphProperties* pParaProperties = dynamic_cast< ParagraphProperties*>(
644 0 : m_pImpl->GetTopContextOfType( CONTEXT_PARAGRAPH ).get() );
645 0 : if( pParaProperties )
646 : {
647 0 : switch( nName )
648 : {
649 : case NS_ooxml::LN_CT_FramePr_dropCap:
650 0 : pParaProperties->SetDropCap( nIntValue );
651 0 : break;
652 : case NS_ooxml::LN_CT_FramePr_lines:
653 0 : pParaProperties->SetLines( nIntValue );
654 0 : break;
655 : case NS_ooxml::LN_CT_FramePr_hAnchor:
656 0 : switch(nIntValue)
657 : {
658 : case NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_text: //relative to column
659 0 : nIntValue = text::RelOrientation::FRAME; break;
660 0 : case NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_margin: nIntValue = text::RelOrientation::PAGE_PRINT_AREA; break;
661 0 : case NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_page: nIntValue = text::RelOrientation::PAGE_FRAME; break;
662 : default:;
663 : }
664 0 : pParaProperties->SethAnchor( nIntValue );
665 0 : break;
666 : case NS_ooxml::LN_CT_FramePr_vAnchor:
667 0 : switch(nIntValue)
668 : {
669 : case NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_text: //relative to paragraph
670 0 : nIntValue = text::RelOrientation::FRAME; break;
671 0 : case NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_margin:nIntValue = text::RelOrientation::PAGE_PRINT_AREA ; break;
672 0 : case NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_page: nIntValue = text::RelOrientation::PAGE_FRAME; break;
673 : default:;
674 : }
675 0 : pParaProperties->SetvAnchor( nIntValue );
676 0 : break;
677 : case NS_ooxml::LN_CT_FramePr_x:
678 0 : pParaProperties->Setx( ConversionHelper::convertTwipToMM100(nIntValue ));
679 0 : break;
680 : case NS_ooxml::LN_CT_FramePr_xAlign:
681 0 : switch( nIntValue )
682 : {
683 0 : case NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_center : nIntValue = text::HoriOrientation::CENTER; break;
684 0 : case NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_right : nIntValue = text::HoriOrientation::RIGHT; break;
685 0 : case NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_inside : nIntValue = text::HoriOrientation::INSIDE; break;
686 0 : case NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_outside : nIntValue = text::HoriOrientation::OUTSIDE; break;
687 0 : case NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_left : nIntValue = text::HoriOrientation::LEFT; break;
688 0 : default: nIntValue = text::HoriOrientation::NONE;
689 : }
690 0 : pParaProperties->SetxAlign( nIntValue );
691 0 : break;
692 : case NS_ooxml::LN_CT_FramePr_y:
693 0 : pParaProperties->Sety( ConversionHelper::convertTwipToMM100(nIntValue ));
694 0 : break;
695 : case NS_ooxml::LN_CT_FramePr_yAlign:
696 0 : switch( nIntValue )
697 : {
698 : case NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_top :
699 0 : case NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_inside :nIntValue = text::VertOrientation::TOP; break;
700 0 : case NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_center :nIntValue = text::VertOrientation::CENTER;break;
701 : case NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_bottom :
702 0 : case NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_outside :nIntValue = text::VertOrientation::BOTTOM;break;
703 : case NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_inline :
704 : {
705 : // HACK: This is for bnc#780851, where a table has one cell that has w:framePr,
706 : // which causes that paragraph to be converted to a text frame, and the original
707 : // paragraph object no longer exists, which makes table creation fail and futhermore
708 : // it would be missing in the table layout anyway. So actually no letting that paragraph
709 : // be a text frame "fixes" it. I'm not sure what "inline" is supposed to mean in practice
710 : // anyway, so as long as this doesn't cause trouble elsewhere ...
711 0 : PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
712 0 : if( pContext.get() )
713 : {
714 0 : ParagraphPropertyMap* pParaContext = dynamic_cast< ParagraphPropertyMap* >( pContext.get() );
715 0 : if (pParaContext)
716 0 : pParaContext->SetFrameMode(false);
717 : }
718 0 : nIntValue = text::VertOrientation::NONE;
719 0 : break;
720 : }
721 : default:
722 0 : nIntValue = text::VertOrientation::NONE;
723 0 : break;
724 : }
725 0 : pParaProperties->SetyAlign( nIntValue );
726 0 : break;
727 : case NS_ooxml::LN_CT_FramePr_hRule:
728 0 : switch( nIntValue )
729 : {
730 : case NS_ooxml::LN_Value_wordprocessingml_ST_HeightRule_exact:
731 0 : nIntValue = text::SizeType::FIX;
732 0 : break;
733 : case NS_ooxml::LN_Value_wordprocessingml_ST_HeightRule_atLeast:
734 0 : nIntValue = text::SizeType::MIN;
735 0 : break;
736 : case NS_ooxml::LN_Value_wordprocessingml_ST_HeightRule_auto:
737 : //no break;
738 : default:;
739 0 : nIntValue = text::SizeType::VARIABLE;
740 : }
741 0 : pParaProperties->SethRule( nIntValue );
742 0 : break;
743 : case NS_ooxml::LN_CT_FramePr_wrap:
744 : {
745 : //should be either LN_Value_wordprocessingml_ST_Wrap_notBeside or LN_Value_wordprocessingml_ST_Wrap_around or LN_Value_wordprocessingml_ST_Wrap_auto
746 : OSL_ENSURE( sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_wordprocessingml_ST_Wrap_around ||
747 : sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_wordprocessingml_ST_Wrap_notBeside ||
748 : sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_wordprocessingml_ST_Wrap_auto,
749 : "wrap not around, not_Beside or auto?");
750 0 : if( sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_wordprocessingml_ST_Wrap_around ||
751 0 : sal::static_int_cast<Id>(nIntValue) == NS_ooxml::LN_Value_wordprocessingml_ST_Wrap_auto )
752 0 : pParaProperties->SetWrap ( text::WrapTextMode_DYNAMIC ) ;
753 : else
754 0 : pParaProperties->SetWrap ( text::WrapTextMode_NONE ) ;
755 : }
756 0 : break;
757 : case NS_ooxml::LN_CT_FramePr_w:
758 0 : pParaProperties->Setw(ConversionHelper::convertTwipToMM100(nIntValue));
759 0 : break;
760 : case NS_ooxml::LN_CT_FramePr_h:
761 0 : pParaProperties->Seth(ConversionHelper::convertTwipToMM100(nIntValue));
762 0 : break;
763 : case NS_ooxml::LN_CT_FramePr_hSpace:
764 0 : pParaProperties->SethSpace( ConversionHelper::convertTwipToMM100(nIntValue ));
765 0 : break;
766 : case NS_ooxml::LN_CT_FramePr_vSpace:
767 0 : pParaProperties->SetvSpace( ConversionHelper::convertTwipToMM100(nIntValue ));
768 0 : break;
769 : default:;
770 : }
771 : }
772 : else
773 : {
774 : //TODO: how to handle frame properties at styles
775 : }
776 : }
777 0 : break;
778 : case NS_ooxml::LN_CT_TrackChange_author:
779 0 : m_pImpl->SetCurrentRedlineAuthor( sStringValue );
780 0 : break;
781 : case NS_ooxml::LN_CT_TrackChange_date:
782 0 : m_pImpl->SetCurrentRedlineDate( sStringValue );
783 0 : break;
784 : case NS_ooxml::LN_CT_Markup_id:
785 0 : m_pImpl->SetCurrentRedlineId( nIntValue );
786 0 : break;
787 : case NS_ooxml::LN_EG_RangeMarkupElements_commentRangeStart:
788 0 : m_pImpl->AddAnnotationPosition( true, nIntValue );
789 0 : break;
790 : case NS_ooxml::LN_EG_RangeMarkupElements_commentRangeEnd:
791 0 : m_pImpl->AddAnnotationPosition( false, nIntValue );
792 0 : break;
793 : case NS_ooxml::LN_CT_Comment_initials:
794 0 : m_pImpl->SetCurrentRedlineInitials(sStringValue);
795 0 : break;
796 : case NS_ooxml::LN_token:
797 0 : m_pImpl->SetCurrentRedlineToken( nIntValue );
798 0 : break;
799 : case NS_ooxml::LN_CT_LineNumber_start:
800 : case NS_ooxml::LN_CT_LineNumber_distance:
801 : case NS_ooxml::LN_CT_LineNumber_countBy:
802 : case NS_ooxml::LN_CT_LineNumber_restart:
803 : {
804 : //line numbering in Writer is a global document setting
805 : //in Word is a section setting
806 : //if line numbering is switched on anywhere in the document it's set at the global settings
807 0 : LineNumberSettings aSettings = m_pImpl->GetLineNumberSettings();
808 0 : switch( nName )
809 : {
810 : case NS_ooxml::LN_CT_LineNumber_countBy:
811 0 : aSettings.nInterval = nIntValue;
812 : OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
813 0 : if( pSectionContext )
814 0 : pSectionContext->SetLnnMod( nIntValue );
815 0 : break;
816 : case NS_ooxml::LN_CT_LineNumber_start:
817 0 : aSettings.nStartValue = nIntValue; // todo: has to be set at (each) first paragraph
818 : OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
819 0 : if( pSectionContext )
820 0 : pSectionContext->SetLnnMin( nIntValue );
821 0 : break;
822 : case NS_ooxml::LN_CT_LineNumber_distance:
823 0 : aSettings.nDistance = ConversionHelper::convertTwipToMM100( nIntValue );
824 : OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
825 0 : if( pSectionContext )
826 0 : pSectionContext->SetdxaLnn( nIntValue );
827 0 : break;
828 : case NS_ooxml::LN_CT_LineNumber_restart:
829 : //page:empty, probably 0,section:1,continuous:2;
830 0 : aSettings.bRestartAtEachPage = nIntValue < 1;
831 : OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
832 0 : if( pSectionContext )
833 0 : pSectionContext->SetLnc( nIntValue );
834 0 : break;
835 : default:;
836 : }
837 0 : m_pImpl->SetLineNumberSettings( aSettings );
838 : }
839 0 : break;
840 : case NS_ooxml::LN_CT_FtnEdnRef_customMarkFollows:
841 0 : m_pImpl->SetCustomFtnMark( true );
842 0 : break;
843 : case NS_ooxml::LN_CT_FtnEdnRef_id:
844 : // footnote or endnote reference id - not needed
845 : case NS_ooxml::LN_CT_Color_themeColor:
846 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "themeColor", TDefTableHandler::getThemeColorTypeString(nIntValue));
847 0 : break;
848 : case NS_ooxml::LN_CT_Color_themeTint:
849 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "themeTint", OUString::number(nIntValue, 16));
850 0 : break;
851 : case NS_ooxml::LN_CT_Color_themeShade:
852 0 : m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "themeShade", OUString::number(nIntValue, 16));
853 0 : break;
854 : case NS_ooxml::LN_CT_DocGrid_linePitch:
855 : {
856 : //see SwWW8ImplReader::SetDocumentGrid
857 : OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
858 0 : if(pSectionContext)
859 : {
860 0 : pSectionContext->SetGridLinePitch( ConversionHelper::convertTwipToMM100( nIntValue ) );
861 : }
862 : }
863 0 : break;
864 : case NS_ooxml::LN_CT_DocGrid_charSpace:
865 : {
866 : OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
867 0 : if(pSectionContext)
868 : {
869 0 : pSectionContext->SetDxtCharSpace( nIntValue );
870 : }
871 : }
872 0 : break;
873 : case NS_ooxml::LN_CT_DocGrid_type:
874 : {
875 0 : if (pSectionContext != NULL)
876 : {
877 0 : pSectionContext->SetGridType(nIntValue);
878 : }
879 : }
880 0 : break;
881 : case NS_ooxml::LN_CT_SdtBlock_sdtContent:
882 0 : m_pImpl->SetSdt(true);
883 0 : break;
884 : case NS_ooxml::LN_CT_SdtBlock_sdtEndContent:
885 0 : m_pImpl->SetSdt(false);
886 0 : if (!m_pImpl->m_pSdtHelper->getDropDownItems().empty())
887 0 : m_pImpl->m_pSdtHelper->createDropDownControl();
888 0 : break;
889 : case NS_ooxml::LN_CT_SdtListItem_displayText:
890 : // TODO handle when this is != value
891 0 : break;
892 : case NS_ooxml::LN_CT_SdtListItem_value:
893 0 : m_pImpl->m_pSdtHelper->getDropDownItems().push_back(sStringValue);
894 0 : break;
895 : case NS_ooxml::LN_CT_SdtDate_fullDate:
896 0 : m_pImpl->m_pSdtHelper->getDate().append(sStringValue);
897 0 : break;
898 : case NS_ooxml::LN_CT_Background_color:
899 0 : m_pImpl->m_oBackgroundColor.reset(nIntValue);
900 0 : break;
901 : case NS_ooxml::LN_CT_PageNumber_start:
902 0 : if (pSectionContext != NULL)
903 0 : pSectionContext->SetPageNumber(nIntValue);
904 0 : break;
905 : case NS_ooxml::LN_CT_FtnEdn_type:
906 : // This is the "separator" footnote, ignore its linebreak.
907 0 : if (static_cast<sal_uInt32>(nIntValue) == NS_ooxml::LN_Value_wordprocessingml_ST_FtnEdn_separator)
908 0 : m_pImpl->m_bIgnoreNextPara = true;
909 0 : break;
910 : case NS_ooxml::LN_CT_DataBinding_prefixMappings:
911 : case NS_ooxml::LN_CT_DataBinding_xpath:
912 : case NS_ooxml::LN_CT_DataBinding_storeItemID:
913 : {
914 0 : OUString sName = OUString::createFromAscii((*QNameToString::Instance())(nName).c_str());
915 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, sName, sStringValue);
916 : }
917 0 : break;
918 : default:
919 : {
920 : #if OSL_DEBUG_LEVEL > 0
921 : OString sMessage("DomainMapper::attribute() - Id: ");
922 : sMessage += OString::number( nName, 10 );
923 : sMessage += " / 0x";
924 : sMessage += OString::number( nName, 16 );
925 : sMessage += " value: ";
926 : sMessage += OString::number( nIntValue, 10 );
927 : sMessage += " / 0x";
928 : sMessage += OString::number( nIntValue, 16 );
929 : SAL_WARN("writerfilter", sMessage.getStr());
930 : #endif
931 : }
932 0 : }
933 0 : }
934 :
935 0 : void DomainMapper::lcl_sprm(Sprm & rSprm)
936 : {
937 0 : if( !m_pImpl->getTableManager().sprm(rSprm))
938 0 : sprmWithProps( rSprm, m_pImpl->GetTopContext() );
939 0 : }
940 :
941 0 : sal_Int32 lcl_getCurrentNumberingProperty(uno::Reference<container::XIndexAccess> xNumberingRules, sal_Int32 nNumberingLevel, const OUString& aProp)
942 : {
943 0 : sal_Int32 nRet = 0;
944 :
945 : try
946 : {
947 0 : if (nNumberingLevel < 0) // It seems it's valid to omit numbering level, and in that case it means zero.
948 0 : nNumberingLevel = 0;
949 0 : if (xNumberingRules.is())
950 : {
951 0 : uno::Sequence<beans::PropertyValue> aProps;
952 0 : xNumberingRules->getByIndex(nNumberingLevel) >>= aProps;
953 0 : for (int i = 0; i < aProps.getLength(); ++i)
954 : {
955 0 : const beans::PropertyValue& rProp = aProps[i];
956 :
957 0 : if (rProp.Name == aProp)
958 : {
959 0 : rProp.Value >>= nRet;
960 0 : break;
961 : }
962 0 : }
963 : }
964 : }
965 0 : catch( const uno::Exception& )
966 : {
967 : // This can happen when the doc contains some hand-crafted invalid list level.
968 : }
969 :
970 0 : return nRet;
971 : }
972 :
973 : // In rtl-paragraphs the meaning of left/right are to be exchanged
974 0 : static bool ExchangeLeftRight( const PropertyMapPtr rContext, DomainMapper_Impl* m_pImpl )
975 : {
976 0 : bool bExchangeLeftRight = false;
977 0 : PropertyMap::const_iterator aPropParaIte = rContext->find(PROP_WRITING_MODE);
978 0 : if( aPropParaIte != rContext->end())
979 : {
980 : sal_Int32 aAdjust ;
981 0 : if( (aPropParaIte->second.getValue() >>= aAdjust) && aAdjust == text::WritingMode2::RL_TB )
982 0 : bExchangeLeftRight = true;
983 : }
984 : else
985 : {
986 : // check if there RTL <bidi> in default style for the paragraph
987 0 : StyleSheetEntryPtr pTable = m_pImpl->GetStyleSheetTable()->FindDefaultParaStyle();
988 0 : if ( pTable )
989 : {
990 0 : PropertyMap::const_iterator aPropStyle = pTable->pProperties->find(PROP_WRITING_MODE);
991 0 : if( aPropStyle != pTable->pProperties->end())
992 : {
993 : sal_Int32 aDirect;
994 0 : if( (aPropStyle->second.getValue() >>= aDirect) && aDirect == text::WritingMode2::RL_TB )
995 0 : bExchangeLeftRight = true;
996 : }
997 0 : }
998 : }
999 0 : return bExchangeLeftRight;
1000 : }
1001 :
1002 0 : void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
1003 : {
1004 : OSL_ENSURE(rContext.get(), "PropertyMap has to be valid!");
1005 0 : if(!rContext.get())
1006 0 : return ;
1007 :
1008 0 : sal_uInt32 nSprmId = rSprm.getId();
1009 : //needed for page properties
1010 0 : SectionPropertyMap * pSectionContext = m_pImpl->GetSectionContext();
1011 0 : Value::Pointer_t pValue = rSprm.getValue();
1012 0 : sal_Int32 nIntValue = pValue->getInt();
1013 0 : const OUString sStringValue = pValue->getString();
1014 0 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
1015 :
1016 0 : switch(nSprmId)
1017 : {
1018 : case 2: // sprmPIstd
1019 : case 0x4600:
1020 0 : break; // sprmPIstd - style code
1021 : case NS_ooxml::LN_CT_PPrBase_jc:
1022 0 : handleParaJustification(nIntValue, rContext, ExchangeLeftRight( rContext, m_pImpl ));
1023 0 : break;
1024 : case NS_ooxml::LN_CT_PPrBase_keepLines:
1025 0 : rContext->Insert(PROP_PARA_SPLIT, uno::makeAny(nIntValue ? false : true));
1026 0 : break;
1027 : case NS_ooxml::LN_CT_PPrBase_keepNext:
1028 0 : rContext->Insert(PROP_PARA_KEEP_TOGETHER, uno::makeAny( nIntValue ? true : false) );
1029 0 : break;
1030 : case NS_ooxml::LN_CT_PPrBase_pageBreakBefore:
1031 0 : if ( nIntValue == 1 )
1032 : {
1033 0 : rContext->Insert(PROP_BREAK_TYPE, uno::makeAny( com::sun::star::style::BreakType_PAGE_BEFORE ) );
1034 : }
1035 0 : break;
1036 : case NS_ooxml::LN_CT_NumPr_ilvl:
1037 0 : if (nIntValue < 0 || 10 <= nIntValue) // Writer can't do everything
1038 : {
1039 : SAL_INFO("writerfilter",
1040 : "unsupported numbering level " << nIntValue);
1041 0 : break;
1042 : }
1043 0 : if( m_pImpl->IsStyleSheetImport() )
1044 : {
1045 : //style sheets cannot have a numbering rule attached
1046 0 : StyleSheetPropertyMap* pStyleSheetPropertyMap = dynamic_cast< StyleSheetPropertyMap* >( rContext.get() );
1047 0 : if (pStyleSheetPropertyMap)
1048 0 : pStyleSheetPropertyMap->SetListLevel( (sal_Int16)nIntValue );
1049 : }
1050 : else
1051 0 : rContext->Insert( PROP_NUMBERING_LEVEL, uno::makeAny( (sal_Int16)nIntValue ));
1052 0 : break;
1053 : case NS_ooxml::LN_CT_NumPr_numId:
1054 : {
1055 : //convert the ListTable entry to a NumberingRules propery and apply it
1056 0 : ListsManager::Pointer pListTable = m_pImpl->GetListTable();
1057 0 : ListDef::Pointer pList = pListTable->GetList( nIntValue );
1058 0 : if( m_pImpl->IsStyleSheetImport() )
1059 : {
1060 : //style sheets cannot have a numbering rule attached
1061 0 : StyleSheetPropertyMap* pStyleSheetPropertyMap = dynamic_cast< StyleSheetPropertyMap* >( rContext.get() );
1062 0 : if (pStyleSheetPropertyMap)
1063 0 : pStyleSheetPropertyMap->SetListId( nIntValue );
1064 : }
1065 0 : if( pList.get( ) )
1066 : {
1067 0 : if( !m_pImpl->IsStyleSheetImport() )
1068 : {
1069 0 : uno::Any aRules = uno::makeAny( pList->GetNumberingRules( ) );
1070 0 : rContext->Insert( PROP_NUMBERING_RULES, aRules );
1071 : // erase numbering from pStyle if already set
1072 0 : rContext->erase(PROP_NUMBERING_STYLE_NAME);
1073 : }
1074 : }
1075 : else
1076 : {
1077 0 : if( m_pImpl->IsStyleSheetImport() )
1078 : {
1079 : // set the number id for AbstractNum references
1080 0 : StyleSheetPropertyMap* pStyleSheetPropertyMap = dynamic_cast< StyleSheetPropertyMap* >( rContext.get() );
1081 0 : if (pStyleSheetPropertyMap)
1082 0 : pStyleSheetPropertyMap->SetNumId( nIntValue );
1083 : }
1084 : else
1085 : {
1086 0 : rContext->Insert( PROP_NUMBERING_STYLE_NAME, uno::makeAny( OUString() ) );
1087 : }
1088 0 : }
1089 : }
1090 0 : break;
1091 : case NS_ooxml::LN_CT_PPrBase_suppressLineNumbers:
1092 0 : rContext->Insert(PROP_PARA_LINE_NUMBER_COUNT, uno::makeAny( nIntValue ? false : true) );
1093 0 : break;
1094 : case NS_ooxml::LN_inTbl:
1095 0 : break;
1096 : case NS_ooxml::LN_tblDepth:
1097 : //not handled via sprm but via text( 0x07 )
1098 0 : break;
1099 : case NS_ooxml::LN_CT_FramePr_w:
1100 0 : break;
1101 : case NS_ooxml::LN_CT_FramePr_wrap:
1102 0 : break;
1103 :
1104 : case NS_ooxml::LN_CT_PrBase_pBdr: //paragraph border
1105 0 : resolveSprmProps(*this, rSprm);
1106 0 : break;
1107 : case NS_ooxml::LN_CT_PBdr_top:
1108 : case NS_ooxml::LN_CT_PBdr_left:
1109 : case NS_ooxml::LN_CT_PBdr_bottom:
1110 : case NS_ooxml::LN_CT_PBdr_right:
1111 : case NS_ooxml::LN_CT_PBdr_between:
1112 : {
1113 : //in binary format the borders are directly provided in OOXML they are inside of properties
1114 0 : if( IsOOXMLImport() || IsRTFImport() )
1115 : {
1116 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1117 0 : if( pProperties.get())
1118 : {
1119 0 : BorderHandlerPtr pBorderHandler( new BorderHandler( true ) );
1120 0 : pProperties->resolve(*pBorderHandler);
1121 0 : PropertyIds eBorderId = PropertyIds( 0 );
1122 0 : PropertyIds eBorderDistId = PropertyIds( 0 );
1123 0 : switch( nSprmId )
1124 : {
1125 : case NS_ooxml::LN_CT_PBdr_top:
1126 0 : eBorderId = PROP_TOP_BORDER;
1127 0 : eBorderDistId = PROP_TOP_BORDER_DISTANCE;
1128 0 : break;
1129 : case NS_ooxml::LN_CT_PBdr_left:
1130 0 : eBorderId = PROP_LEFT_BORDER;
1131 0 : eBorderDistId = PROP_LEFT_BORDER_DISTANCE;
1132 0 : break;
1133 : case NS_ooxml::LN_CT_PBdr_bottom:
1134 0 : eBorderId = PROP_BOTTOM_BORDER ;
1135 0 : eBorderDistId = PROP_BOTTOM_BORDER_DISTANCE;
1136 0 : break;
1137 : case NS_ooxml::LN_CT_PBdr_right:
1138 0 : eBorderId = PROP_RIGHT_BORDER;
1139 0 : eBorderDistId = PROP_RIGHT_BORDER_DISTANCE ;
1140 0 : break;
1141 : case NS_ooxml::LN_CT_PBdr_between:
1142 : //not supported
1143 0 : break;
1144 : default:;
1145 : }
1146 0 : if( eBorderId )
1147 0 : rContext->Insert( eBorderId, uno::makeAny( pBorderHandler->getBorderLine()) , true);
1148 0 : if(eBorderDistId)
1149 0 : rContext->Insert(eBorderDistId, uno::makeAny( pBorderHandler->getLineDistance()), true);
1150 0 : if (nSprmId == NS_ooxml::LN_CT_PBdr_right && pBorderHandler->getShadow())
1151 : {
1152 0 : table::ShadowFormat aFormat = rContext->getShadowFromBorder(pBorderHandler->getBorderLine());
1153 0 : rContext->Insert(PROP_PARA_SHADOW_FORMAT, uno::makeAny(aFormat));
1154 0 : }
1155 0 : }
1156 : }
1157 : else
1158 : {
1159 0 : table::BorderLine2 aBorderLine;
1160 0 : sal_Int32 nLineDistance = ConversionHelper::MakeBorderLine( nIntValue, aBorderLine );
1161 0 : PropertyIds eBorderId = PROP_LEFT_BORDER;
1162 0 : PropertyIds eBorderDistId = PROP_LEFT_BORDER_DISTANCE ;
1163 0 : switch( nSprmId )
1164 : {
1165 : case NS_ooxml::LN_CT_PBdr_between:
1166 : OSL_FAIL( "TODO: inner border is not handled");
1167 0 : break;
1168 : case NS_ooxml::LN_CT_PBdr_left:
1169 0 : eBorderId = PROP_LEFT_BORDER;
1170 0 : eBorderDistId = PROP_LEFT_BORDER_DISTANCE ;
1171 0 : break;
1172 : case NS_ooxml::LN_CT_PBdr_right:
1173 0 : eBorderId = PROP_RIGHT_BORDER ;
1174 0 : eBorderDistId = PROP_RIGHT_BORDER_DISTANCE ;
1175 0 : break;
1176 : case NS_ooxml::LN_CT_PBdr_top:
1177 0 : eBorderId = PROP_TOP_BORDER ;
1178 0 : eBorderDistId = PROP_TOP_BORDER_DISTANCE;
1179 0 : break;
1180 : case NS_ooxml::LN_CT_PBdr_bottom:
1181 : default:
1182 0 : eBorderId = PROP_BOTTOM_BORDER ;
1183 0 : eBorderDistId = PROP_BOTTOM_BORDER_DISTANCE;
1184 : }
1185 0 : rContext->Insert(eBorderId, uno::makeAny( aBorderLine ));
1186 0 : rContext->Insert(eBorderDistId, uno::makeAny( nLineDistance ));
1187 : }
1188 : }
1189 0 : break;
1190 : case NS_ooxml::LN_CT_PBdr_bar:
1191 0 : break;
1192 : case NS_ooxml::LN_CT_PPrBase_suppressAutoHyphens:
1193 0 : rContext->Insert(PROP_PARA_IS_HYPHENATION, uno::makeAny( nIntValue ? false : true ));
1194 0 : break;
1195 : case NS_ooxml::LN_CT_FramePr_h:
1196 0 : break;
1197 : case NS_ooxml::LN_CT_PrBase_shd:
1198 : {
1199 : //contains fore color, back color and shadow percentage, results in a brush
1200 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1201 0 : if( pProperties.get())
1202 : {
1203 0 : CellColorHandlerPtr pCellColorHandler( new CellColorHandler );
1204 0 : pCellColorHandler->setOutputFormat( CellColorHandler::Paragraph );
1205 0 : sal_Bool bEnableTempGrabBag = !pCellColorHandler->isInteropGrabBagEnabled();
1206 0 : if( bEnableTempGrabBag )
1207 0 : pCellColorHandler->enableInteropGrabBag( "TempShdPropsGrabBag" );
1208 :
1209 0 : pProperties->resolve(*pCellColorHandler);
1210 0 : rContext->InsertProps(pCellColorHandler->getProperties());
1211 :
1212 0 : rContext->Insert(PROP_CHAR_THEME_FILL, pCellColorHandler->getInteropGrabBag().Value, true, PARA_GRAB_BAG);
1213 0 : if(bEnableTempGrabBag)
1214 0 : pCellColorHandler->disableInteropGrabBag();
1215 0 : }
1216 : }
1217 0 : break;
1218 : case NS_ooxml::LN_CT_FramePr_vSpace:
1219 0 : break; // sprmPDyaFromText
1220 : case NS_ooxml::LN_CT_FramePr_hSpace:
1221 0 : break; // sprmPDxaFromText
1222 : case NS_ooxml::LN_CT_FramePr_anchorLock:
1223 0 : break;
1224 : case NS_ooxml::LN_CT_PPrBase_widowControl:
1225 : {
1226 0 : uno::Any aVal( uno::makeAny( sal_Int8(nIntValue ? 2 : 0 )));
1227 0 : rContext->Insert( PROP_PARA_WIDOWS, aVal );
1228 0 : rContext->Insert( PROP_PARA_ORPHANS, aVal );
1229 : }
1230 0 : break; // sprmPFWidowControl
1231 : case NS_ooxml::LN_CT_PPrBase_overflowPunct:
1232 0 : rContext->Insert(PROP_PARA_IS_HANGING_PUNCTUATION, uno::makeAny( nIntValue ? false : true ));
1233 0 : break;
1234 : case NS_ooxml::LN_CT_PPrBase_topLinePunct:
1235 0 : break;
1236 : case NS_ooxml::LN_CT_PPrBase_autoSpaceDE:
1237 0 : break;
1238 : case NS_ooxml::LN_CT_PPrBase_autoSpaceDN:
1239 0 : break;
1240 : case NS_ooxml::LN_CT_PPrBase_textAlignment:
1241 : {
1242 0 : sal_Int16 nAlignment = 0;
1243 0 : switch (nIntValue)
1244 : {
1245 : case NS_ooxml::LN_Value_wordprocessingml_ST_TextAlignment_top:
1246 0 : nAlignment = 2;
1247 0 : break;
1248 : case NS_ooxml::LN_Value_wordprocessingml_ST_TextAlignment_center:
1249 0 : nAlignment = 3;
1250 0 : break;
1251 : case NS_ooxml::LN_Value_wordprocessingml_ST_TextAlignment_baseline:
1252 0 : nAlignment = 1;
1253 0 : break;
1254 : case NS_ooxml::LN_Value_wordprocessingml_ST_TextAlignment_bottom:
1255 0 : nAlignment = 4;
1256 0 : break;
1257 : case NS_ooxml::LN_Value_wordprocessingml_ST_TextAlignment_auto:
1258 : default:
1259 0 : break;
1260 : }
1261 0 : rContext->Insert( PROP_PARA_VERT_ALIGNMENT, uno::makeAny( nAlignment) );
1262 : }
1263 0 : break;
1264 : case NS_ooxml::LN_CT_PPrBase_textDirection:
1265 0 : break;
1266 : case NS_ooxml::LN_CT_PPrBase_outlineLvl:
1267 : {
1268 0 : sal_Int16 nLvl = static_cast< sal_Int16 >( nIntValue );
1269 0 : if( m_pImpl->IsStyleSheetImport() )
1270 : {
1271 :
1272 0 : StyleSheetPropertyMap* pStyleSheetPropertyMap = dynamic_cast< StyleSheetPropertyMap* >( rContext.get() );
1273 0 : if (pStyleSheetPropertyMap)
1274 0 : pStyleSheetPropertyMap->SetOutlineLevel( nLvl );
1275 : }
1276 : else
1277 : {
1278 0 : nLvl = nLvl >= WW_OUTLINE_MIN && nLvl < WW_OUTLINE_MAX? nLvl+1 : 0; //0 means no outline level set on
1279 0 : rContext->Insert(PROP_OUTLINE_LEVEL, uno::makeAny ( nLvl ));
1280 : }
1281 : }
1282 0 : break;
1283 : case NS_ooxml::LN_CT_PPrBase_bidi:
1284 : {
1285 0 : if (nIntValue != 0)
1286 : {
1287 0 : rContext->Insert(PROP_WRITING_MODE, uno::makeAny( text::WritingMode2::RL_TB ));
1288 0 : rContext->Insert(PROP_PARA_ADJUST, uno::makeAny( style::ParagraphAdjust_RIGHT ));
1289 : }
1290 : else
1291 : {
1292 0 : rContext->Insert(PROP_WRITING_MODE, uno::makeAny( text::WritingMode2::LR_TB ));
1293 0 : rContext->Insert(PROP_PARA_ADJUST, uno::makeAny( style::ParagraphAdjust_LEFT ));
1294 : }
1295 : }
1296 :
1297 0 : break;
1298 : case NS_ooxml::LN_EG_SectPrContents_bidi:
1299 0 : if (pSectionContext != NULL)
1300 0 : pSectionContext->Insert(PROP_WRITING_MODE, uno::makeAny( text::WritingMode2::RL_TB));
1301 0 : break;
1302 : case NS_ooxml::LN_EG_RPrBase_highlight:
1303 : {
1304 0 : sal_Int32 nColor = 0;
1305 0 : if( (mbIsHighlightSet = getColorFromIndex(nIntValue, nColor)) )
1306 0 : rContext->Insert(PROP_CHAR_HIGHLIGHT, uno::makeAny( nColor ));
1307 0 : else if (mnBackgroundColor)
1308 0 : rContext->Insert(PROP_CHAR_BACK_COLOR, uno::makeAny( mnBackgroundColor ));
1309 : }
1310 0 : break;
1311 : case NS_ooxml::LN_EG_RPrBase_em:
1312 0 : rContext->Insert(PROP_CHAR_EMPHASIS, uno::makeAny ( getEmphasisValue (nIntValue)));
1313 0 : break;
1314 : case NS_ooxml::LN_EG_RPrBase_emboss:
1315 : case NS_ooxml::LN_EG_RPrBase_b:
1316 : case NS_ooxml::LN_EG_RPrBase_bCs:
1317 : case NS_ooxml::LN_EG_RPrBase_i:
1318 : case NS_ooxml::LN_EG_RPrBase_iCs:
1319 : case NS_ooxml::LN_EG_RPrBase_strike:
1320 : case NS_ooxml::LN_EG_RPrBase_dstrike:
1321 : case NS_ooxml::LN_EG_RPrBase_outline:
1322 : case NS_ooxml::LN_EG_RPrBase_shadow:
1323 : case NS_ooxml::LN_EG_RPrBase_caps:
1324 : case NS_ooxml::LN_EG_RPrBase_smallCaps:
1325 : case NS_ooxml::LN_EG_RPrBase_vanish:
1326 : case NS_ooxml::LN_EG_RPrBase_webHidden:
1327 : {
1328 0 : PropertyIds ePropertyId = PROP_CHAR_WEIGHT; //initialized to prevent warning!
1329 0 : switch( nSprmId )
1330 : {
1331 : case NS_ooxml::LN_EG_RPrBase_b:
1332 : case NS_ooxml::LN_EG_RPrBase_bCs:
1333 0 : ePropertyId = nSprmId != NS_ooxml::LN_EG_RPrBase_bCs ? PROP_CHAR_WEIGHT : PROP_CHAR_WEIGHT_COMPLEX;
1334 0 : break;
1335 : case NS_ooxml::LN_EG_RPrBase_i:
1336 : case NS_ooxml::LN_EG_RPrBase_iCs:
1337 0 : ePropertyId = nSprmId == NS_ooxml::LN_EG_RPrBase_i ? PROP_CHAR_POSTURE : PROP_CHAR_POSTURE_COMPLEX;
1338 0 : break;
1339 : case NS_ooxml::LN_EG_RPrBase_strike:
1340 : case NS_ooxml::LN_EG_RPrBase_dstrike:
1341 0 : ePropertyId = PROP_CHAR_STRIKEOUT;
1342 0 : break;
1343 : case NS_ooxml::LN_EG_RPrBase_outline:
1344 0 : ePropertyId = PROP_CHAR_CONTOURED;
1345 0 : break;
1346 : case NS_ooxml::LN_EG_RPrBase_shadow:
1347 0 : ePropertyId = PROP_CHAR_SHADOWED;
1348 0 : break;
1349 : case NS_ooxml::LN_EG_RPrBase_caps:
1350 : case NS_ooxml::LN_EG_RPrBase_smallCaps:
1351 0 : ePropertyId = PROP_CHAR_CASE_MAP;
1352 0 : break;
1353 : case NS_ooxml::LN_EG_RPrBase_vanish:
1354 : case NS_ooxml::LN_EG_RPrBase_webHidden:
1355 0 : ePropertyId = PROP_CHAR_HIDDEN;
1356 0 : break;
1357 : case NS_ooxml::LN_EG_RPrBase_emboss:
1358 0 : ePropertyId = PROP_CHAR_RELIEF;
1359 0 : break;
1360 : }
1361 : //expected: 0,1,128,129
1362 0 : if(nIntValue != 128) //inherited from paragraph - ignore
1363 : {
1364 0 : if( nIntValue == 129) //inverted style sheet value
1365 : {
1366 : //get value from style sheet and invert it
1367 0 : sal_Int16 nStyleValue = 0;
1368 0 : uno::Any aStyleVal = m_pImpl->GetPropertyFromStyleSheet(ePropertyId);
1369 0 : if( !aStyleVal.hasValue() )
1370 : {
1371 : nIntValue = 0x83a == nSprmId ?
1372 0 : 4 : 1;
1373 : }
1374 0 : else if(aStyleVal.getValueTypeClass() == uno::TypeClass_FLOAT )
1375 : {
1376 0 : double fDoubleValue = 0;
1377 : //only in case of awt::FontWeight
1378 0 : aStyleVal >>= fDoubleValue;
1379 0 : nIntValue = fDoubleValue > 100. ? 0 : 1;
1380 : }
1381 0 : else if((aStyleVal >>= nStyleValue) ||
1382 0 : (nStyleValue = (sal_Int16)comphelper::getEnumAsINT32(aStyleVal)) >= 0 )
1383 : {
1384 : nIntValue = 0x83a == nSprmId ?
1385 : nStyleValue ? 0 : 4 :
1386 0 : nStyleValue ? 0 : 1;
1387 : }
1388 : else
1389 : {
1390 : OSL_FAIL( "what type was it");
1391 0 : }
1392 : }
1393 :
1394 0 : switch( nSprmId )
1395 : {
1396 : case NS_ooxml::LN_EG_RPrBase_b:
1397 : case NS_ooxml::LN_EG_RPrBase_bCs:
1398 : {
1399 0 : uno::Any aBold( uno::makeAny( nIntValue ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL ) );
1400 :
1401 0 : rContext->Insert(ePropertyId, aBold );
1402 0 : if( nSprmId != NS_ooxml::LN_EG_RPrBase_bCs )
1403 0 : rContext->Insert(PROP_CHAR_WEIGHT_ASIAN, aBold );
1404 :
1405 0 : uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
1406 0 : if (xCharStyle.is())
1407 0 : xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_WEIGHT), aBold);
1408 0 : if (nSprmId == NS_ooxml::LN_EG_RPrBase_b)
1409 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "b", OUString::number(nIntValue));
1410 0 : else if (nSprmId == NS_ooxml::LN_EG_RPrBase_bCs)
1411 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "bCs", OUString::number(nIntValue));
1412 : }
1413 0 : break;
1414 : case NS_ooxml::LN_EG_RPrBase_i:
1415 : case NS_ooxml::LN_EG_RPrBase_iCs:
1416 : {
1417 0 : uno::Any aPosture( uno::makeAny( nIntValue ? awt::FontSlant_ITALIC : awt::FontSlant_NONE ) );
1418 0 : rContext->Insert( ePropertyId, aPosture );
1419 0 : if (nSprmId != NS_ooxml::LN_EG_RPrBase_iCs)
1420 0 : rContext->Insert(PROP_CHAR_POSTURE_ASIAN, aPosture );
1421 0 : if (nSprmId == NS_ooxml::LN_EG_RPrBase_i)
1422 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "i", OUString::number(nIntValue));
1423 : }
1424 0 : break;
1425 : case NS_ooxml::LN_EG_RPrBase_strike:
1426 : rContext->Insert(ePropertyId,
1427 0 : uno::makeAny( nIntValue ? awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE ) );
1428 0 : break;
1429 : case NS_ooxml::LN_EG_RPrBase_dstrike:
1430 : rContext->Insert(ePropertyId,
1431 0 : uno::makeAny( nIntValue ? awt::FontStrikeout::DOUBLE : awt::FontStrikeout::NONE ) );
1432 0 : break;
1433 : case NS_ooxml::LN_EG_RPrBase_outline:
1434 : case NS_ooxml::LN_EG_RPrBase_shadow:
1435 : case NS_ooxml::LN_EG_RPrBase_vanish:
1436 : case NS_ooxml::LN_EG_RPrBase_webHidden:
1437 0 : rContext->Insert(ePropertyId, uno::makeAny( nIntValue ? true : false ));
1438 0 : break;
1439 : case NS_ooxml::LN_EG_RPrBase_smallCaps:
1440 : // If smallcaps would be just disabled and an other casemap is already inserted, don't do anything.
1441 0 : if (nIntValue || rContext->find(ePropertyId) == rContext->end())
1442 0 : rContext->Insert(ePropertyId, uno::makeAny( nIntValue ? style::CaseMap::SMALLCAPS : style::CaseMap::NONE));
1443 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "smallCaps", OUString::number(nIntValue));
1444 0 : break;
1445 : case NS_ooxml::LN_EG_RPrBase_caps:
1446 : rContext->Insert(ePropertyId,
1447 0 : uno::makeAny( nIntValue ? style::CaseMap::UPPERCASE : style::CaseMap::NONE));
1448 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "caps", OUString::number(nIntValue));
1449 0 : break;
1450 : case NS_ooxml::LN_EG_RPrBase_emboss:
1451 : rContext->Insert(ePropertyId,
1452 0 : uno::makeAny( nIntValue ? awt::FontRelief::EMBOSSED : awt::FontRelief::NONE ));
1453 0 : break;
1454 :
1455 : }
1456 : }
1457 : }
1458 0 : break;
1459 : case NS_ooxml::LN_EG_RPrBase_sz:
1460 : case NS_ooxml::LN_EG_RPrBase_szCs:
1461 : {
1462 : //multiples of half points (12pt == 24)
1463 0 : double fVal = double(nIntValue) / 2.;
1464 0 : uno::Any aVal = uno::makeAny( fVal );
1465 0 : if( NS_ooxml::LN_EG_RPrBase_szCs == nSprmId )
1466 : {
1467 0 : rContext->Insert( PROP_CHAR_HEIGHT_COMPLEX, aVal );
1468 : }
1469 : else
1470 : {
1471 0 : bool bIgnore = false;
1472 0 : if (m_pImpl->m_bInTableStyleRunProps)
1473 : {
1474 : // If the default para style contains PROP_CHAR_HEIGHT, that should have priority over the table style.
1475 0 : StyleSheetEntryPtr pTable = m_pImpl->GetStyleSheetTable()->FindDefaultParaStyle();
1476 0 : if (pTable && pTable->pProperties->find(PROP_CHAR_HEIGHT) != pTable->pProperties->end())
1477 0 : bIgnore = true;
1478 : }
1479 0 : if (!bIgnore)
1480 : {
1481 : //Asian get the same value as Western
1482 0 : rContext->Insert( PROP_CHAR_HEIGHT, aVal );
1483 0 : rContext->Insert( PROP_CHAR_HEIGHT_ASIAN, aVal );
1484 :
1485 0 : uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
1486 0 : if (xCharStyle.is())
1487 0 : xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_HEIGHT), aVal);
1488 : }
1489 : }
1490 : // Make sure char sizes defined in the stylesheets don't affect char props from direct formatting.
1491 0 : if (!m_pImpl->IsStyleSheetImport())
1492 0 : m_pImpl->deferCharacterProperty( nSprmId, uno::makeAny( nIntValue ));
1493 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, (nSprmId == NS_ooxml::LN_EG_RPrBase_sz ? OUString("sz") : OUString("szCs")), OUString::number(nIntValue));
1494 : }
1495 0 : break;
1496 : case NS_ooxml::LN_EG_RPrBase_position:
1497 : // The spec says 0 is the same as the lack of the value, so don't parse that.
1498 0 : if (nIntValue)
1499 0 : m_pImpl->deferCharacterProperty( nSprmId, uno::makeAny( nIntValue ));
1500 0 : break;
1501 : case NS_ooxml::LN_EG_RPrBase_spacing:
1502 : {
1503 : //Kerning half point values
1504 : //TODO: there are two kerning values -
1505 : // in ww8par6.cxx NS_sprm::LN_CHpsKern is used as boolean AutoKerning
1506 0 : sal_Int16 nResult = static_cast<sal_Int16>(ConversionHelper::convertTwipToMM100(nIntValue));
1507 0 : if (m_pImpl->IsInComments())
1508 : {
1509 0 : nResult = static_cast<sal_Int16>(nIntValue);
1510 : }
1511 0 : rContext->Insert(PROP_CHAR_CHAR_KERNING, uno::makeAny(nResult));
1512 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "spacing", OUString::number(nIntValue));
1513 : }
1514 0 : break;
1515 : case NS_ooxml::LN_EG_RPrBase_kern: // auto kerning is bound to a minimum font size in Word - but not in Writer :-(
1516 0 : rContext->Insert(PROP_CHAR_AUTO_KERNING, uno::makeAny( sal_Bool(nIntValue) ) );
1517 0 : break;
1518 : case NS_ooxml::LN_EG_RPrBase_w:
1519 : rContext->Insert(PROP_CHAR_SCALE_WIDTH,
1520 0 : uno::makeAny( sal_Int16(nIntValue) ));
1521 0 : break;
1522 : case NS_ooxml::LN_EG_RPrBase_imprint:
1523 : // FontRelief: NONE, EMBOSSED, ENGRAVED
1524 : rContext->Insert(PROP_CHAR_RELIEF,
1525 0 : uno::makeAny( nIntValue ? awt::FontRelief::ENGRAVED : awt::FontRelief::NONE ));
1526 0 : break;
1527 : case NS_ooxml::LN_EG_RPrBase_effect:
1528 : // The file-format has many character animations. We have only
1529 : // one, so we use it always. Suboptimal solution though.
1530 0 : if (nIntValue)
1531 0 : rContext->Insert(PROP_CHAR_FLASH, uno::makeAny( true ));
1532 : else
1533 0 : rContext->Insert(PROP_CHAR_FLASH, uno::makeAny( false ));
1534 0 : break;
1535 : case NS_ooxml::LN_EG_RPrBase_rtl:
1536 0 : break;
1537 : case NS_ooxml::LN_EG_RPrBase_shd:
1538 : {
1539 : //contains fore color, back color and shadow percentage, results in a brush
1540 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1541 0 : if( pProperties.get())
1542 : {
1543 0 : CellColorHandlerPtr pCellColorHandler( new CellColorHandler );
1544 0 : pCellColorHandler->setOutputFormat( CellColorHandler::Character );
1545 0 : pProperties->resolve(*pCellColorHandler);
1546 0 : rContext->InsertProps(pCellColorHandler->getProperties());
1547 : }
1548 0 : break;
1549 : }
1550 : case NS_ooxml::LN_EG_SectPrContents_type:
1551 : /* break type
1552 : 0 - No break
1553 : 1 - New Column
1554 : 2 - New page
1555 : 3 - Even page
1556 : 4 - odd page
1557 : */
1558 : OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
1559 0 : if(pSectionContext)
1560 : {
1561 : // Ignore continuous section break at the end of the document, if the previous section had the same type as well
1562 : // It makes the importer loose margin settings with no benefit
1563 0 : SectionPropertyMap* pLastContext = m_pImpl->GetLastSectionContext();
1564 0 : int nPrevBreakType = 0;
1565 0 : bool bHasPrevSection = false;
1566 0 : if (pLastContext)
1567 : {
1568 0 : bHasPrevSection = true;
1569 0 : nPrevBreakType = pLastContext->GetBreakType();
1570 : }
1571 0 : if (m_pImpl->GetParaSectpr() || nIntValue != 0 || (bHasPrevSection && nPrevBreakType != nIntValue))
1572 0 : pSectionContext->SetBreakType( nIntValue );
1573 : }
1574 0 : break;
1575 : case NS_ooxml::LN_EG_SectPrContents_titlePg:
1576 : {
1577 : OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
1578 0 : if(pSectionContext)
1579 0 : pSectionContext->SetTitlePage( nIntValue > 0 ? true : false );//section has title page
1580 : }
1581 0 : break;
1582 : case 165:
1583 : {
1584 : //page height, rounded to default values, default: 0x3dc0 twip
1585 0 : sal_Int32 nHeight = ConversionHelper::convertTwipToMM100( nIntValue );
1586 0 : rContext->Insert( PROP_HEIGHT, uno::makeAny( PaperInfo::sloppyFitPageDimension( nHeight ) ) );
1587 : }
1588 0 : break;
1589 : case 0x703a: //undocumented, grid related?
1590 : OSL_FAIL( "TODO: not handled yet"); //nIntValue like 0x008a2373 ?
1591 0 : break;
1592 : case NS_ooxml::LN_EG_SectPrContents_textDirection:
1593 : {
1594 : /* 0 HoriLR 1 Vert TR 2 Vert TR 3 Vert TT 4 HoriLT
1595 : only 0 and 1 can be imported correctly
1596 : */
1597 0 : sal_Int16 nDirection = text::WritingMode_LR_TB;
1598 0 : switch( nIntValue )
1599 : {
1600 : case 0:
1601 : case 4:
1602 0 : nDirection = text::WritingMode_LR_TB;
1603 0 : break;
1604 : case 1:
1605 : case 2:
1606 : case 3:
1607 0 : nDirection = text::WritingMode_TB_RL;
1608 0 : break;
1609 : default:;
1610 : }
1611 :
1612 0 : PropertyMap * pTargetContext = rContext.get();
1613 :
1614 0 : if (pSectionContext != NULL &&
1615 : nSprmId == NS_ooxml::LN_EG_SectPrContents_textDirection)
1616 : {
1617 0 : pTargetContext = pSectionContext;
1618 : }
1619 :
1620 0 : pTargetContext->Insert(PROP_WRITING_MODE, uno::makeAny( nDirection ) );
1621 : }
1622 0 : break; // sprmSTextFlow
1623 : // the following are not part of the official documentation
1624 : case 0x6870: //TxtForeColor
1625 : {
1626 0 : sal_Int32 nColor = msfilter::util::BGRToRGB(nIntValue);
1627 0 : rContext->Insert(PROP_CHAR_COLOR, uno::makeAny( nColor ) );
1628 : }
1629 0 : break;
1630 : case 0x6877: //underlining color
1631 : {
1632 0 : rContext->Insert(PROP_CHAR_UNDERLINE_HAS_COLOR, uno::makeAny( true ) );
1633 0 : rContext->Insert(PROP_CHAR_UNDERLINE_COLOR, uno::makeAny( nIntValue ) );
1634 : }
1635 0 : break;
1636 : case 0x6815:
1637 0 : break; //undocumented
1638 : case 0x6467:
1639 0 : break; //undocumented
1640 : case 0xF617:
1641 0 : break; //undocumented
1642 : case 0xd634: // sprmTNewSpacing - table spacing ( see WW8TabBandDesc::ProcessSpacing() )
1643 0 : break;
1644 : case 0x4888:
1645 : case 0x6887:
1646 : //properties of list levels - undocumented
1647 0 : break;
1648 : case 0xd234:
1649 : case 0xd235:
1650 : case 0xd236:
1651 : case 0xd237:
1652 0 : break;//undocumented section properties
1653 : case NS_ooxml::LN_CT_Tabs_tab:
1654 0 : resolveSprmProps(*this, rSprm);
1655 0 : m_pImpl->IncorporateTabStop(m_pImpl->m_aCurrentTabStop);
1656 0 : m_pImpl->m_aCurrentTabStop = DeletableTabStop();
1657 0 : break;
1658 : case NS_ooxml::LN_CT_PPrBase_tabs:
1659 : {
1660 : // Initialize tab stop vector from style sheet
1661 0 : if( !m_pImpl->IsStyleSheetImport() )
1662 : {
1663 0 : uno::Any aValue = m_pImpl->GetPropertyFromStyleSheet(PROP_PARA_TAB_STOPS);
1664 0 : uno::Sequence< style::TabStop > aStyleTabStops;
1665 0 : if(aValue >>= aStyleTabStops)
1666 : {
1667 0 : m_pImpl->InitTabStopFromStyle( aStyleTabStops );
1668 0 : }
1669 : }
1670 0 : resolveSprmProps(*this, rSprm);
1671 0 : rContext->Insert(PROP_PARA_TAB_STOPS, uno::makeAny( m_pImpl->GetCurrentTabStopAndClear()));
1672 : }
1673 0 : break;
1674 :
1675 : case NS_ooxml::LN_CT_DocDefaults_pPrDefault:
1676 : case NS_ooxml::LN_CT_DocDefaults_rPrDefault:
1677 0 : GetStyleSheetTable()->sprm( rSprm );
1678 0 : break;
1679 : case NS_ooxml::LN_EG_RPrBase_bdr:
1680 : {
1681 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1682 0 : if( pProperties.get())
1683 : {
1684 0 : BorderHandlerPtr pBorderHandler( new BorderHandler( true ) );
1685 0 : pProperties->resolve(*pBorderHandler);
1686 :
1687 0 : rContext->Insert( PROP_CHAR_TOP_BORDER, uno::makeAny( pBorderHandler->getBorderLine()));
1688 0 : rContext->Insert( PROP_CHAR_BOTTOM_BORDER, uno::makeAny( pBorderHandler->getBorderLine()));
1689 0 : rContext->Insert( PROP_CHAR_LEFT_BORDER, uno::makeAny( pBorderHandler->getBorderLine()));
1690 0 : rContext->Insert( PROP_CHAR_RIGHT_BORDER, uno::makeAny( pBorderHandler->getBorderLine()));
1691 :
1692 0 : rContext->Insert( PROP_CHAR_TOP_BORDER_DISTANCE, uno::makeAny( pBorderHandler->getLineDistance()));
1693 0 : rContext->Insert( PROP_CHAR_BOTTOM_BORDER_DISTANCE, uno::makeAny( pBorderHandler->getLineDistance()));
1694 0 : rContext->Insert( PROP_CHAR_LEFT_BORDER_DISTANCE, uno::makeAny( pBorderHandler->getLineDistance()));
1695 0 : rContext->Insert( PROP_CHAR_RIGHT_BORDER_DISTANCE, uno::makeAny( pBorderHandler->getLineDistance()));
1696 :
1697 0 : if( pBorderHandler->getShadow() )
1698 : {
1699 0 : table::ShadowFormat aFormat = rContext->getShadowFromBorder(pBorderHandler->getBorderLine());
1700 0 : rContext->Insert(PROP_CHAR_SHADOW_FORMAT, uno::makeAny(aFormat));
1701 0 : }
1702 0 : }
1703 : }
1704 0 : break;
1705 : case NS_ooxml::LN_CT_PPr_sectPr:
1706 : case NS_ooxml::LN_EG_RPrBase_color:
1707 : case NS_ooxml::LN_EG_RPrBase_rFonts:
1708 : case NS_ooxml::LN_EG_RPrBase_eastAsianLayout:
1709 : case NS_ooxml::LN_EG_RPrBase_u:
1710 : case NS_ooxml::LN_EG_RPrBase_lang:
1711 : case NS_ooxml::LN_CT_PPrBase_spacing:
1712 : case NS_ooxml::LN_CT_PPrBase_ind:
1713 : case NS_ooxml::LN_CT_RPrDefault_rPr:
1714 : case NS_ooxml::LN_CT_PPrDefault_pPr:
1715 : case NS_ooxml::LN_CT_Style_pPr:
1716 : case NS_ooxml::LN_CT_Style_rPr:
1717 : case NS_ooxml::LN_CT_PPr_rPr:
1718 : case NS_ooxml::LN_CT_PPrBase_numPr:
1719 : {
1720 0 : bool bTempGrabBag = !m_pImpl->isInteropGrabBagEnabled();
1721 0 : if (nSprmId == NS_ooxml::LN_CT_PPr_sectPr)
1722 0 : m_pImpl->SetParaSectpr(true);
1723 0 : else if (nSprmId == NS_ooxml::LN_EG_RPrBase_color && bTempGrabBag)
1724 : // if DomainMapper grab bag is not enabled, enable it temporarily
1725 0 : m_pImpl->enableInteropGrabBag("TempColorPropsGrabBag");
1726 0 : resolveSprmProps(*this, rSprm);
1727 0 : if (nSprmId == NS_ooxml::LN_CT_PPrBase_spacing)
1728 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "spacing", m_pImpl->m_aSubInteropGrabBag);
1729 0 : else if (nSprmId == NS_ooxml::LN_EG_RPrBase_rFonts)
1730 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "rFonts", m_pImpl->m_aSubInteropGrabBag);
1731 0 : else if (nSprmId == NS_ooxml::LN_EG_RPrBase_lang)
1732 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lang", m_pImpl->m_aSubInteropGrabBag);
1733 0 : else if (nSprmId == NS_ooxml::LN_EG_RPrBase_color)
1734 : {
1735 0 : std::vector<beans::PropertyValue>::iterator aIter = m_pImpl->m_aSubInteropGrabBag.begin();
1736 0 : for (; aIter != m_pImpl->m_aSubInteropGrabBag.end(); ++aIter)
1737 : {
1738 0 : if (aIter->Name == "val")
1739 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_ORIGINAL_COLOR, aIter->Value, true, CHAR_GRAB_BAG);
1740 0 : else if (aIter->Name == "themeColor")
1741 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR, aIter->Value, true, CHAR_GRAB_BAG);
1742 0 : else if (aIter->Name == "themeShade")
1743 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR_SHADE, aIter->Value, true, CHAR_GRAB_BAG);
1744 0 : else if (aIter->Name == "themeTint")
1745 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR_TINT, aIter->Value, true, CHAR_GRAB_BAG);
1746 : }
1747 0 : if (bTempGrabBag)
1748 : //disable and clear DomainMapper grab bag if it wasn't enabled before
1749 0 : m_pImpl->disableInteropGrabBag();
1750 :
1751 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "color", m_pImpl->m_aSubInteropGrabBag);
1752 : }
1753 0 : else if (nSprmId == NS_ooxml::LN_CT_PPrBase_ind)
1754 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ind", m_pImpl->m_aSubInteropGrabBag);
1755 : }
1756 0 : break;
1757 : case NS_ooxml::LN_CT_PPrBase_wordWrap:
1758 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "wordWrap", "");
1759 0 : break;
1760 : case NS_ooxml::LN_EG_SectPrContents_footnotePr:
1761 : case NS_ooxml::LN_EG_SectPrContents_endnotePr:
1762 0 : m_pImpl->SetInFootnoteProperties( NS_ooxml::LN_EG_SectPrContents_footnotePr == nSprmId );
1763 0 : resolveSprmProps(*this, rSprm);
1764 0 : break;
1765 : case NS_ooxml::LN_EG_SectPrContents_lnNumType:
1766 : {
1767 0 : resolveSprmProps(*this, rSprm);
1768 0 : LineNumberSettings aSettings = m_pImpl->GetLineNumberSettings();
1769 0 : aSettings.bIsOn = true;
1770 0 : m_pImpl->SetLineNumberSettings( aSettings );
1771 : //apply settings at XLineNumberingProperties
1772 : try
1773 : {
1774 0 : uno::Reference< text::XLineNumberingProperties > xLineNumberingProperties( m_pImpl->GetTextDocument(), uno::UNO_QUERY_THROW );
1775 0 : uno::Reference< beans::XPropertySet > xLineNumberingPropSet = xLineNumberingProperties->getLineNumberingProperties();
1776 0 : PropertyNameSupplier& rNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
1777 0 : xLineNumberingPropSet->setPropertyValue(rNameSupplier.GetName( PROP_IS_ON ), uno::makeAny(true) );
1778 0 : if( aSettings.nInterval )
1779 0 : xLineNumberingPropSet->setPropertyValue(rNameSupplier.GetName( PROP_INTERVAL ), uno::makeAny((sal_Int16)aSettings.nInterval) );
1780 0 : if( aSettings.nDistance )
1781 0 : xLineNumberingPropSet->setPropertyValue(rNameSupplier.GetName( PROP_DISTANCE ), uno::makeAny(aSettings.nDistance) );
1782 0 : xLineNumberingPropSet->setPropertyValue(rNameSupplier.GetName( PROP_RESTART_AT_EACH_PAGE ), uno::makeAny(aSettings.bRestartAtEachPage) );
1783 : }
1784 0 : catch( const uno::Exception& )
1785 : {
1786 : }
1787 :
1788 : }
1789 0 : break;
1790 : case NS_ooxml::LN_CT_PPrBase_framePr:
1791 : // Avoid frames if we're inside a structured document tag, would just cause outer tables fail to create.
1792 0 : if (!m_pImpl->GetSdt())
1793 : {
1794 0 : PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
1795 0 : if( pContext.get() )
1796 : {
1797 0 : ParagraphPropertyMap* pParaContext = dynamic_cast< ParagraphPropertyMap* >( pContext.get() );
1798 0 : if (pParaContext)
1799 0 : pParaContext->SetFrameMode();
1800 : }
1801 : else
1802 : {
1803 : //TODO: What about style sheet import of frame properties
1804 : }
1805 0 : resolveSprmProps(*this, rSprm);
1806 : }
1807 0 : break;
1808 : case NS_ooxml::LN_EG_SectPrContents_pgSz:
1809 0 : CT_PageSz.code = 0;
1810 : {
1811 0 : PaperInfo aLetter(PAPER_LETTER);
1812 0 : CT_PageSz.w = aLetter.getWidth();
1813 0 : CT_PageSz.h = aLetter.getHeight();
1814 : }
1815 0 : CT_PageSz.orient = false;
1816 0 : resolveSprmProps(*this, rSprm);
1817 : OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
1818 0 : if(pSectionContext)
1819 : {
1820 0 : pSectionContext->Insert( PROP_HEIGHT, uno::makeAny( CT_PageSz.h ) );
1821 0 : pSectionContext->Insert( PROP_IS_LANDSCAPE, uno::makeAny( CT_PageSz.orient ));
1822 0 : pSectionContext->Insert( PROP_WIDTH, uno::makeAny( CT_PageSz.w ) );
1823 0 : pSectionContext->SetLandscape( CT_PageSz.orient );
1824 : }
1825 0 : break;
1826 :
1827 : case NS_ooxml::LN_EG_SectPrContents_pgMar:
1828 0 : m_pImpl->InitPageMargins();
1829 0 : resolveSprmProps(*this, rSprm);
1830 : OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
1831 0 : if(pSectionContext)
1832 : {
1833 0 : const _PageMar& rPageMar = m_pImpl->GetPageMargins();
1834 0 : pSectionContext->SetTopMargin( rPageMar.top );
1835 0 : pSectionContext->SetRightMargin( rPageMar.right );
1836 0 : pSectionContext->SetBottomMargin( rPageMar.bottom );
1837 0 : pSectionContext->SetLeftMargin( rPageMar.left );
1838 0 : pSectionContext->SetHeaderTop( rPageMar.header );
1839 0 : pSectionContext->SetHeaderBottom( rPageMar.footer );
1840 : }
1841 0 : break;
1842 :
1843 : case NS_ooxml::LN_EG_SectPrContents_cols:
1844 : {
1845 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1846 0 : if( pProperties.get())
1847 : {
1848 :
1849 0 : SectionColumnHandlerPtr pSectHdl( new SectionColumnHandler );
1850 0 : pProperties->resolve(*pSectHdl);
1851 0 : if(pSectionContext && !m_pImpl->isInIndexContext())
1852 : {
1853 0 : if( pSectHdl->IsEqualWidth() )
1854 : {
1855 0 : pSectionContext->SetEvenlySpaced( true );
1856 0 : pSectionContext->SetColumnCount( (sal_Int16) (pSectHdl->GetNum() - 1) );
1857 0 : pSectionContext->SetColumnDistance( pSectHdl->GetSpace() );
1858 0 : pSectionContext->SetSeparatorLine( pSectHdl->IsSeparator() );
1859 : }
1860 0 : else if( !pSectHdl->GetColumns().empty() )
1861 : {
1862 0 : pSectionContext->SetEvenlySpaced( false );
1863 0 : pSectionContext->SetColumnDistance( pSectHdl->GetSpace() );
1864 0 : pSectionContext->SetColumnCount( (sal_Int16)(pSectHdl->GetColumns().size() -1));
1865 0 : std::vector<_Column>::const_iterator tmpIter = pSectHdl->GetColumns().begin();
1866 0 : for (; tmpIter != pSectHdl->GetColumns().end(); ++tmpIter)
1867 : {
1868 0 : pSectionContext->AppendColumnWidth( tmpIter->nWidth );
1869 0 : if ((tmpIter != pSectHdl->GetColumns().end() - 1) || (tmpIter->nSpace > 0))
1870 0 : pSectionContext->AppendColumnSpacing( tmpIter->nSpace );
1871 : }
1872 0 : pSectionContext->SetSeparatorLine( pSectHdl->IsSeparator() );
1873 : }
1874 0 : else if( pSectHdl->GetNum() > 0 )
1875 : {
1876 0 : pSectionContext->SetColumnCount( (sal_Int16)pSectHdl->GetNum() - 1 );
1877 0 : pSectionContext->SetColumnDistance( pSectHdl->GetSpace() );
1878 0 : pSectionContext->SetSeparatorLine( pSectHdl->IsSeparator() );
1879 : }
1880 : }
1881 :
1882 0 : else if ( pSectionContext )
1883 : {
1884 0 : FieldContextPtr pContext = m_pImpl->GetTopFieldContext();
1885 0 : uno::Reference< beans::XPropertySet > xTOC = pContext->GetTOC();
1886 0 : if( xTOC.is() )
1887 : {
1888 0 : uno::Reference<text::XTextColumns> xTextColumns;
1889 0 : xTOC->getPropertyValue(rPropNameSupplier.GetName( PROP_TEXT_COLUMNS )) >>= xTextColumns;
1890 0 : if (xTextColumns.is())
1891 : {
1892 0 : uno::Reference< beans::XPropertySet > xColumnPropSet( xTextColumns, uno::UNO_QUERY_THROW );
1893 0 : if ( xColumnPropSet.is() )
1894 0 : xColumnPropSet->setPropertyValue( rPropNameSupplier.GetName( PROP_AUTOMATIC_DISTANCE ), uno::makeAny( pSectHdl->GetSpace() ));
1895 0 : xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_TEXT_COLUMNS ), uno::makeAny( xTextColumns ) );
1896 0 : }
1897 0 : }
1898 0 : }
1899 0 : }
1900 : }
1901 0 : break;
1902 : case NS_ooxml::LN_EG_SectPrContents_docGrid:
1903 0 : resolveSprmProps(*this, rSprm);
1904 0 : break;
1905 : case NS_ooxml::LN_EG_SectPrContents_pgBorders:
1906 : {
1907 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1908 0 : if( pProperties.get( ) && pSectionContext )
1909 : {
1910 0 : PageBordersHandlerPtr pHandler( new PageBordersHandler );
1911 0 : pProperties->resolve( *pHandler );
1912 :
1913 : // Set the borders to the context and apply them to the styles
1914 0 : pHandler->SetBorders( pSectionContext );
1915 0 : pSectionContext->SetBorderParams( pHandler->GetDisplayOffset( ) );
1916 0 : }
1917 : }
1918 0 : break;
1919 :
1920 : case NS_ooxml::LN_CT_PPrBase_snapToGrid:
1921 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "snapToGrid", OUString::number(nIntValue));
1922 0 : break;
1923 : case NS_ooxml::LN_CT_PPrBase_pStyle:
1924 : {
1925 0 : m_pImpl->SetCurrentParaStyleId( sStringValue );
1926 0 : StyleSheetTablePtr pStyleTable = m_pImpl->GetStyleSheetTable();
1927 0 : const OUString sConvertedStyleName = pStyleTable->ConvertStyleName( sStringValue, true );
1928 0 : if (m_pImpl->GetTopContext() && m_pImpl->GetTopContextType() != CONTEXT_SECTION)
1929 0 : m_pImpl->GetTopContext()->Insert( PROP_PARA_STYLE_NAME, uno::makeAny( sConvertedStyleName ));
1930 : //apply numbering to paragraph if it was set at the style, but only if the paragraph itself
1931 : //does not specify the numbering
1932 0 : if( rContext->find(PROP_NUMBERING_RULES) == rContext->end()) // !contains
1933 : {
1934 0 : const StyleSheetEntryPtr pEntry = pStyleTable->FindStyleSheetByISTD(sStringValue);
1935 : OSL_ENSURE( pEntry.get(), "no style sheet found" );
1936 0 : const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : 0);
1937 :
1938 0 : if( pStyleSheetProperties && pStyleSheetProperties->GetListId() >= 0 )
1939 : {
1940 : rContext->Insert( PROP_NUMBERING_STYLE_NAME, uno::makeAny(
1941 0 : ListDef::GetStyleName( pStyleSheetProperties->GetListId( ) ) ), false);
1942 :
1943 : // We're inheriting properties from a numbering style. Make sure a possible right margin is inherited from the base style.
1944 0 : sal_Int32 nParaRightMargin = 0;
1945 0 : if (!pEntry->sBaseStyleIdentifier.isEmpty())
1946 : {
1947 0 : const StyleSheetEntryPtr pParent = pStyleTable->FindStyleSheetByISTD(pEntry->sBaseStyleIdentifier);
1948 0 : const StyleSheetPropertyMap* pParentProperties = dynamic_cast<const StyleSheetPropertyMap*>(pParent ? pParent->pProperties.get() : 0);
1949 0 : if (pParentProperties && pParentProperties->find(PROP_PARA_RIGHT_MARGIN) != pParentProperties->end())
1950 0 : nParaRightMargin = pParentProperties->find(PROP_PARA_RIGHT_MARGIN)->second.getValue().get<sal_Int32>();
1951 : }
1952 0 : if (nParaRightMargin != 0)
1953 : {
1954 : // If we're setting the right margin, we should set the first / left margin as well from the numbering style.
1955 0 : sal_Int32 nFirstLineIndent = lcl_getCurrentNumberingProperty(m_pImpl->GetCurrentNumberingRules(), pStyleSheetProperties->GetListLevel(), "FirstLineIndent");
1956 0 : sal_Int32 nParaLeftMargin = lcl_getCurrentNumberingProperty(m_pImpl->GetCurrentNumberingRules(), pStyleSheetProperties->GetListLevel(), "IndentAt");
1957 0 : if (nFirstLineIndent != 0)
1958 0 : rContext->Insert(PROP_PARA_FIRST_LINE_INDENT, uno::makeAny(nFirstLineIndent));
1959 0 : if (nParaLeftMargin != 0)
1960 0 : rContext->Insert(PROP_PARA_LEFT_MARGIN, uno::makeAny(nParaLeftMargin));
1961 :
1962 0 : rContext->Insert(PROP_PARA_RIGHT_MARGIN, uno::makeAny(nParaRightMargin));
1963 : }
1964 : }
1965 :
1966 0 : if( pStyleSheetProperties && pStyleSheetProperties->GetListLevel() >= 0 )
1967 0 : rContext->Insert( PROP_NUMBERING_LEVEL, uno::makeAny(pStyleSheetProperties->GetListLevel()), false);
1968 0 : }
1969 : }
1970 0 : break;
1971 : case NS_ooxml::LN_EG_RPrBase_rStyle:
1972 : {
1973 0 : OUString sConvertedName( m_pImpl->GetStyleSheetTable()->ConvertStyleName( sStringValue, true ) );
1974 : // First check if the style exists in the document.
1975 0 : StyleSheetEntryPtr pEntry = m_pImpl->GetStyleSheetTable( )->FindStyleSheetByStyleName( sConvertedName );
1976 0 : bool bExists = pEntry.get( ) && ( pEntry->nStyleTypeCode == STYLE_TYPE_CHAR );
1977 :
1978 : // Add the property if the style exists
1979 0 : if ( bExists && m_pImpl->GetTopContext() )
1980 0 : m_pImpl->GetTopContext()->Insert( PROP_CHAR_STYLE_NAME, uno::makeAny( sConvertedName ) );
1981 : }
1982 0 : break;
1983 : case NS_ooxml::LN_CT_TblPrBase_tblCellMar: //cell margins
1984 : {
1985 0 : resolveSprmProps(*this, rSprm);//contains LN_CT_TblCellMar_top, LN_CT_TblCellMar_left, LN_CT_TblCellMar_bottom, LN_CT_TblCellMar_right
1986 : }
1987 0 : break;
1988 : case NS_ooxml::LN_CT_TblCellMar_top:
1989 : case NS_ooxml::LN_CT_TblCellMar_start:
1990 : case NS_ooxml::LN_CT_TblCellMar_left:
1991 : case NS_ooxml::LN_CT_TblCellMar_bottom:
1992 : case NS_ooxml::LN_CT_TblCellMar_end:
1993 : case NS_ooxml::LN_CT_TblCellMar_right:
1994 : {
1995 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1996 0 : if( pProperties.get())
1997 : {
1998 0 : MeasureHandlerPtr pMeasureHandler( new MeasureHandler );
1999 0 : pProperties->resolve(*pMeasureHandler);
2000 0 : sal_Int32 nMeasureValue = pMeasureHandler->getMeasureValue();
2001 0 : PropertyIds eId = META_PROP_CELL_MAR_TOP;
2002 0 : bool rtl = false; // TODO
2003 0 : switch(nSprmId)
2004 : {
2005 : case NS_ooxml::LN_CT_TblCellMar_top:
2006 0 : break;
2007 : case NS_ooxml::LN_CT_TblCellMar_start:
2008 0 : eId = rtl ? META_PROP_CELL_MAR_RIGHT : META_PROP_CELL_MAR_LEFT;
2009 0 : break;
2010 : case NS_ooxml::LN_CT_TblCellMar_left:
2011 0 : eId = META_PROP_CELL_MAR_LEFT;
2012 0 : break;
2013 : case NS_ooxml::LN_CT_TblCellMar_bottom:
2014 0 : eId = META_PROP_CELL_MAR_BOTTOM;
2015 0 : break;
2016 : case NS_ooxml::LN_CT_TblCellMar_end:
2017 0 : eId = rtl ? META_PROP_CELL_MAR_LEFT : META_PROP_CELL_MAR_RIGHT;
2018 0 : break;
2019 : case NS_ooxml::LN_CT_TblCellMar_right:
2020 0 : eId = META_PROP_CELL_MAR_RIGHT;
2021 0 : break;
2022 : default:;
2023 : }
2024 0 : rContext->Insert( eId, uno::makeAny(nMeasureValue), false);
2025 0 : }
2026 : }
2027 0 : break;
2028 : case NS_ooxml::LN_EG_RPrBase_noProof: // no grammar and spell checking, unsupported
2029 0 : break;
2030 : case NS_ooxml::LN_anchor_anchor: // at_character drawing
2031 : case NS_ooxml::LN_inline_inline: // as_character drawing
2032 : {
2033 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2034 0 : if( pProperties.get())
2035 : {
2036 : GraphicImportType eGraphicType =
2037 : (NS_ooxml::LN_anchor_anchor ==
2038 0 : sal::static_int_cast<Id>(nSprmId)) ?
2039 : IMPORT_AS_DETECTED_ANCHOR :
2040 0 : IMPORT_AS_DETECTED_INLINE;
2041 : GraphicImportPtr pGraphicImport =
2042 0 : m_pImpl->GetGraphicImport(eGraphicType);
2043 0 : pProperties->resolve(*pGraphicImport);
2044 0 : m_pImpl->ImportGraphic(pProperties, eGraphicType);
2045 0 : if( !pGraphicImport->IsGraphic() )
2046 : {
2047 0 : m_pImpl->ResetGraphicImport();
2048 : // todo: It's a shape, now start shape import
2049 0 : }
2050 0 : }
2051 : }
2052 0 : break;
2053 : case NS_ooxml::LN_EG_RPrBase_vertAlign:
2054 : {
2055 0 : sal_Int16 nEscapement = 0;
2056 0 : sal_Int8 nProp = 58;
2057 0 : if ( sStringValue == "superscript" )
2058 0 : nEscapement = 101;
2059 0 : else if ( sStringValue == "subscript" )
2060 0 : nEscapement = -101;
2061 : else
2062 0 : nProp = 100;
2063 :
2064 0 : rContext->Insert(PROP_CHAR_ESCAPEMENT, uno::makeAny( nEscapement ) );
2065 0 : rContext->Insert(PROP_CHAR_ESCAPEMENT_HEIGHT, uno::makeAny( nProp ) );
2066 : }
2067 0 : break;
2068 : case NS_ooxml::LN_CT_FtnProps_pos:
2069 : //footnotes in word can be at page end or beneath text - writer supports only the first
2070 : //endnotes in word can be at section end or document end - writer supports only the latter
2071 : // -> so this property can be ignored
2072 0 : break;
2073 : case NS_ooxml::LN_EG_FtnEdnNumProps_numStart:
2074 : case NS_ooxml::LN_EG_FtnEdnNumProps_numRestart:
2075 : case NS_ooxml::LN_CT_FtnProps_numFmt:
2076 : case NS_ooxml::LN_CT_EdnProps_numFmt:
2077 : {
2078 : try
2079 : {
2080 0 : uno::Reference< beans::XPropertySet > xFtnEdnSettings;
2081 0 : if( m_pImpl->IsInFootnoteProperties() )
2082 : {
2083 0 : uno::Reference< text::XFootnotesSupplier> xFootnotesSupplier( m_pImpl->GetTextDocument(), uno::UNO_QUERY );
2084 0 : if (xFootnotesSupplier.is())
2085 0 : xFtnEdnSettings = xFootnotesSupplier->getFootnoteSettings();
2086 : }
2087 : else
2088 : {
2089 0 : uno::Reference< text::XEndnotesSupplier> xEndnotesSupplier( m_pImpl->GetTextDocument(), uno::UNO_QUERY );
2090 0 : if (xEndnotesSupplier.is())
2091 0 : xFtnEdnSettings = xEndnotesSupplier->getEndnoteSettings();
2092 : }
2093 0 : if( NS_ooxml::LN_EG_FtnEdnNumProps_numStart == nSprmId && xFtnEdnSettings.is())
2094 : {
2095 0 : xFtnEdnSettings->setPropertyValue(
2096 0 : PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_START_AT),
2097 0 : uno::makeAny( sal_Int16( nIntValue - 1 )));
2098 : }
2099 0 : else if( NS_ooxml::LN_EG_FtnEdnNumProps_numRestart == nSprmId && xFtnEdnSettings.is())
2100 : {
2101 0 : sal_Int16 nFootnoteCounting = 0;
2102 0 : switch (nIntValue)
2103 : {
2104 0 : case NS_ooxml::LN_Value_ST_RestartNumber_continuous: nFootnoteCounting = text::FootnoteNumbering::PER_DOCUMENT; break;
2105 0 : case NS_ooxml::LN_Value_ST_RestartNumber_eachPage: nFootnoteCounting = text::FootnoteNumbering::PER_PAGE; break;
2106 0 : case NS_ooxml::LN_Value_ST_RestartNumber_eachSect: nFootnoteCounting = text::FootnoteNumbering::PER_CHAPTER; break;
2107 0 : default: break;
2108 : }
2109 0 : xFtnEdnSettings->setPropertyValue(
2110 0 : PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_FOOTNOTE_COUNTING ),
2111 0 : uno::makeAny( nFootnoteCounting ));
2112 : }
2113 0 : else if (xFtnEdnSettings.is())
2114 : {
2115 0 : sal_Int16 nNumType = ConversionHelper::ConvertNumberingType( nIntValue );
2116 0 : xFtnEdnSettings->setPropertyValue(
2117 0 : PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_NUMBERING_TYPE),
2118 0 : uno::makeAny( nNumType ));
2119 0 : }
2120 : }
2121 0 : catch( const uno::Exception& )
2122 : {
2123 : }
2124 : }
2125 0 : break;
2126 : case NS_ooxml::LN_paratrackchange:
2127 0 : m_pImpl->StartParaMarkerChange( );
2128 : /* fallthrough */
2129 : case NS_ooxml::LN_CT_PPr_pPrChange:
2130 : case NS_ooxml::LN_trackchange:
2131 : case NS_ooxml::LN_EG_RPrContent_rPrChange:
2132 : {
2133 0 : HandleRedline( rSprm );
2134 : }
2135 0 : break;
2136 : case NS_ooxml::LN_endtrackchange:
2137 0 : m_pImpl->RemoveCurrentRedline( );
2138 0 : break;
2139 : case NS_ooxml::LN_CT_RPrChange_rPr:
2140 : // Push all the current 'Character' properties to the stack, so that we don't store them
2141 : // as 'tracked changes' by mistake
2142 0 : m_pImpl->PushProperties(CONTEXT_CHARACTER);
2143 :
2144 : // Resolve all the properties that are under the 'rPrChange'->'rPr' XML node
2145 0 : resolveSprmProps(*this, rSprm );
2146 :
2147 0 : if (m_pImpl->GetTopContext())
2148 : {
2149 : // Get all the properties that were processed in the 'rPrChange'->'rPr' XML node
2150 0 : uno::Sequence< beans::PropertyValue > currentRedlineRevertProperties = m_pImpl->GetTopContext()->GetPropertyValues();
2151 :
2152 : // Store these properties in the current redline object
2153 0 : m_pImpl->SetCurrentRedlineRevertProperties( currentRedlineRevertProperties );
2154 : }
2155 :
2156 : // Pop back out the character properties that were on the run
2157 0 : m_pImpl->PopProperties(CONTEXT_CHARACTER);
2158 0 : break;
2159 : case NS_ooxml::LN_CT_PPrChange_pPr:
2160 : // Push all the current 'Paragraph' properties to the stack, so that we don't store them
2161 : // as 'tracked changes' by mistake
2162 0 : m_pImpl->PushProperties(CONTEXT_PARAGRAPH);
2163 :
2164 : // Resolve all the properties that are under the 'pPrChange'->'pPr' XML node
2165 0 : resolveSprmProps(*this, rSprm );
2166 :
2167 0 : if (m_pImpl->GetTopContext())
2168 : {
2169 : // Get all the properties that were processed in the 'pPrChange'->'pPr' XML node
2170 0 : uno::Sequence< beans::PropertyValue > currentRedlineRevertProperties = m_pImpl->GetTopContext()->GetPropertyValues();
2171 :
2172 : // Store these properties in the current redline object
2173 0 : m_pImpl->SetCurrentRedlineRevertProperties( currentRedlineRevertProperties );
2174 : }
2175 :
2176 : // Pop back out the character properties that were on the run
2177 0 : m_pImpl->PopProperties(CONTEXT_PARAGRAPH);
2178 0 : break;
2179 : case NS_ooxml::LN_object:
2180 : {
2181 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2182 0 : if( pProperties.get( ) )
2183 : {
2184 0 : OLEHandlerPtr pOLEHandler( new OLEHandler );
2185 0 : pProperties->resolve(*pOLEHandler);
2186 0 : if ( pOLEHandler->isOLEObject( ) )
2187 : {
2188 0 : OUString sStreamName = pOLEHandler->copyOLEOStream( m_pImpl->GetTextDocument() );
2189 0 : if( !sStreamName.isEmpty() )
2190 : {
2191 0 : m_pImpl->appendOLE( sStreamName, pOLEHandler );
2192 0 : }
2193 0 : }
2194 0 : }
2195 : }
2196 0 : break;
2197 : case NS_ooxml::LN_EG_HdrFtrReferences_headerReference: // header reference - not needed
2198 : case NS_ooxml::LN_EG_HdrFtrReferences_footerReference: // footer reference - not needed
2199 0 : break;
2200 : case NS_ooxml::LN_EG_RPrBase_snapToGrid: // "Use document grid settings for inter-paragraph spacing"
2201 0 : break;
2202 : case NS_ooxml::LN_CT_PPrBase_contextualSpacing:
2203 0 : rContext->Insert(PROP_PARA_CONTEXT_MARGIN, uno::makeAny( sal_Bool( nIntValue ) ));
2204 0 : break;
2205 : case NS_ooxml::LN_CT_PPrBase_mirrorIndents: // mirrorIndents
2206 0 : rContext->Insert(PROP_MIRROR_INDENTS, uno::makeAny(sal_Bool(nIntValue)), true, PARA_GRAB_BAG);
2207 0 : break;
2208 : case NS_ooxml::LN_EG_SectPrContents_formProt: //section protection, only form editing is enabled - unsupported
2209 : case NS_ooxml::LN_EG_SectPrContents_vAlign:
2210 : case NS_ooxml::LN_EG_RPrBase_fitText:
2211 0 : break;
2212 : case NS_ooxml::LN_ffdata:
2213 : {
2214 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2215 0 : if (pProperties.get() != NULL)
2216 : {
2217 0 : FFDataHandler::Pointer_t pFFDataHandler(new FFDataHandler());
2218 :
2219 0 : pProperties->resolve(*pFFDataHandler);
2220 0 : m_pImpl->SetFieldFFData(pFFDataHandler);
2221 0 : }
2222 : }
2223 0 : break;
2224 : case NS_ooxml::LN_CT_SdtPr_dropDownList:
2225 : case NS_ooxml::LN_CT_SdtPr_comboBox:
2226 : {
2227 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2228 0 : if (pProperties.get() != NULL)
2229 0 : pProperties->resolve(*this);
2230 : }
2231 0 : break;
2232 : case NS_ooxml::LN_CT_SdtDropDownList_listItem:
2233 : {
2234 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2235 0 : if (pProperties.get() != NULL)
2236 0 : pProperties->resolve(*this);
2237 : }
2238 0 : break;
2239 : case NS_ooxml::LN_CT_SdtPr_date:
2240 : {
2241 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2242 0 : if (pProperties.get() != NULL)
2243 0 : pProperties->resolve(*this);
2244 : }
2245 0 : break;
2246 : case NS_ooxml::LN_CT_SdtDate_dateFormat:
2247 : {
2248 0 : m_pImpl->m_pSdtHelper->getDateFormat().append(sStringValue);
2249 : }
2250 0 : break;
2251 : case NS_ooxml::LN_CT_SdtDate_lid:
2252 : {
2253 0 : m_pImpl->m_pSdtHelper->getLocale().append(sStringValue);
2254 : }
2255 0 : break;
2256 : case NS_ooxml::LN_CT_SdtPr_dataBinding:
2257 : case NS_ooxml::LN_CT_SdtPr_equation:
2258 : case NS_ooxml::LN_CT_SdtPr_checkbox:
2259 : case NS_ooxml::LN_CT_SdtPr_docPartObj:
2260 : case NS_ooxml::LN_CT_SdtPr_docPartList:
2261 : case NS_ooxml::LN_CT_SdtPr_picture:
2262 : case NS_ooxml::LN_CT_SdtPr_citation:
2263 : case NS_ooxml::LN_CT_SdtPr_group:
2264 : case NS_ooxml::LN_CT_SdtPr_text:
2265 : case NS_ooxml::LN_CT_SdtPr_id:
2266 : {
2267 : // this is an unsupported SDT property, create a grab bag for it
2268 0 : OUString sName = OUString::createFromAscii((*QNameToString::Instance())(nSprmId).c_str());
2269 0 : enableInteropGrabBag(sName);
2270 :
2271 : // process subitems
2272 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2273 0 : if (pProperties.get() != NULL)
2274 0 : pProperties->resolve(*this);
2275 :
2276 0 : m_pImpl->m_pSdtHelper->appendToInteropGrabBag(getInteropGrabBag());
2277 0 : m_pImpl->disableInteropGrabBag();
2278 : }
2279 0 : break;
2280 : case NS_ooxml::LN_CT_SdtCheckbox_checked:
2281 : case NS_ooxml::LN_CT_SdtCheckbox_checkedState:
2282 : case NS_ooxml::LN_CT_SdtCheckbox_uncheckedState:
2283 : case NS_ooxml::LN_CT_SdtDocPart_docPartGallery:
2284 : case NS_ooxml::LN_CT_SdtDocPart_docPartCategory:
2285 : case NS_ooxml::LN_CT_SdtDocPart_docPartUnique:
2286 : {
2287 : // this is a child of an unsupported SDT property, store in the grab bag
2288 0 : OUString sName = OUString::createFromAscii((*QNameToString::Instance())(nSprmId).c_str());
2289 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, sName, sStringValue);
2290 : }
2291 0 : break;
2292 : case NS_ooxml::LN_EG_SectPrContents_pgNumType:
2293 : {
2294 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2295 0 : if( pProperties.get())
2296 : {
2297 0 : pProperties->resolve(*this);
2298 0 : }
2299 : }
2300 0 : break;
2301 : case NS_ooxml::LN_tblStart:
2302 0 : m_pImpl->m_nTableDepth++;
2303 0 : break;
2304 : case NS_ooxml::LN_tblEnd:
2305 0 : m_pImpl->m_nTableDepth--;
2306 0 : break;
2307 : case NS_ooxml::LN_glow_glow:
2308 : case NS_ooxml::LN_shadow_shadow:
2309 : case NS_ooxml::LN_reflection_reflection:
2310 : case NS_ooxml::LN_textOutline_textOutline:
2311 : case NS_ooxml::LN_textFill_textFill:
2312 : case NS_ooxml::LN_scene3d_scene3d:
2313 : case NS_ooxml::LN_props3d_props3d:
2314 : case NS_ooxml::LN_ligatures_ligatures:
2315 : case NS_ooxml::LN_numForm_numForm:
2316 : case NS_ooxml::LN_numSpacing_numSpacing:
2317 : case NS_ooxml::LN_stylisticSets_stylisticSets:
2318 : case NS_ooxml::LN_cntxtAlts_cntxtAlts:
2319 : {
2320 0 : TextEffectsHandlerPtr pTextEffectsHandlerPtr( new TextEffectsHandler(nSprmId) );
2321 0 : boost::optional<PropertyIds> aPropertyId = pTextEffectsHandlerPtr->getGrabBagPropertyId();
2322 0 : if(aPropertyId)
2323 : {
2324 0 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
2325 0 : if( pProperties.get())
2326 : {
2327 0 : pProperties->resolve(*pTextEffectsHandlerPtr);
2328 :
2329 0 : rContext->Insert(*aPropertyId, uno::makeAny(pTextEffectsHandlerPtr->getInteropGrabBag()), true, CHAR_GRAB_BAG);
2330 0 : }
2331 0 : }
2332 : }
2333 0 : break;
2334 : default:
2335 : {
2336 : #ifdef DEBUG_DOMAINMAPPER
2337 : dmapper_logger->startElement("unhandled");
2338 : dmapper_logger->attribute("id", nSprmId);
2339 : dmapper_logger->attribute("name", rSprm.getName());
2340 : dmapper_logger->endElement();
2341 : #endif
2342 : }
2343 0 : }
2344 : }
2345 :
2346 0 : void DomainMapper::setInTableStyleRunProps(bool bInTableStyleRunProps)
2347 : {
2348 0 : m_pImpl->m_bInTableStyleRunProps = bInTableStyleRunProps;
2349 0 : }
2350 :
2351 0 : void DomainMapper::processDeferredCharacterProperties( const std::map< sal_Int32, uno::Any >& deferredCharacterProperties )
2352 : {
2353 : assert( m_pImpl->GetTopContextType() == CONTEXT_CHARACTER );
2354 0 : PropertyMapPtr rContext = m_pImpl->GetTopContext();
2355 0 : for( std::map< sal_Int32, uno::Any >::const_iterator it = deferredCharacterProperties.begin();
2356 0 : it != deferredCharacterProperties.end();
2357 : ++it )
2358 : {
2359 0 : sal_Int32 Id = it->first;
2360 0 : sal_Int32 nIntValue = 0;
2361 0 : OUString sStringValue;
2362 0 : it->second >>= nIntValue;
2363 0 : it->second >>= sStringValue;
2364 0 : switch( Id )
2365 : {
2366 : case NS_ooxml::LN_EG_RPrBase_sz:
2367 : case NS_ooxml::LN_EG_RPrBase_szCs:
2368 0 : break; // only for use by other properties, ignore here
2369 : case NS_ooxml::LN_EG_RPrBase_position:
2370 : {
2371 0 : sal_Int16 nEscapement = 0;
2372 0 : sal_Int8 nProp = 100;
2373 0 : if(nIntValue == 0)
2374 0 : nProp = 0;
2375 : else
2376 : {
2377 0 : std::map< sal_Int32, uno::Any >::const_iterator font = deferredCharacterProperties.find( NS_ooxml::LN_EG_RPrBase_sz );
2378 0 : PropertyMapPtr pDefaultCharProps = m_pImpl->GetStyleSheetTable()->GetDefaultCharProps();
2379 0 : PropertyMap::iterator aDefaultFont = pDefaultCharProps->find(PROP_CHAR_HEIGHT);
2380 0 : if( font != deferredCharacterProperties.end())
2381 : {
2382 0 : double fontSize = 0;
2383 0 : font->second >>= fontSize;
2384 0 : nEscapement = nIntValue * 100 / fontSize;
2385 : }
2386 : // TODO if not direct formatting, check the style first, not directly the default char props.
2387 0 : else if (aDefaultFont != pDefaultCharProps->end())
2388 : {
2389 0 : double fHeight = 0;
2390 0 : aDefaultFont->second.getValue() >>= fHeight;
2391 : // fHeight is in points, nIntValue is in half points, nEscapement is in percents.
2392 0 : nEscapement = nIntValue * 100 / fHeight / 2;
2393 : }
2394 : else
2395 : { // TODO: Find out the font size. The 58/-58 values were here previous, but I have
2396 : // no idea what they are (they are probably some random guess that did fit whatever
2397 : // specific case somebody was trying to fix).
2398 0 : nEscapement = ( nIntValue > 0 ) ? 58: -58;
2399 0 : }
2400 : }
2401 0 : rContext->Insert(PROP_CHAR_ESCAPEMENT, uno::makeAny( nEscapement ) );
2402 0 : rContext->Insert(PROP_CHAR_ESCAPEMENT_HEIGHT, uno::makeAny( nProp ) );
2403 : }
2404 0 : break;
2405 : default:
2406 : SAL_WARN( "writerfilter", "Unhandled property in processDeferredCharacterProperty()" );
2407 0 : break;
2408 : }
2409 0 : }
2410 0 : }
2411 :
2412 0 : void DomainMapper::lcl_entry(int /*pos*/,
2413 : writerfilter::Reference<Properties>::Pointer_t ref)
2414 : {
2415 0 : ref->resolve(*this);
2416 0 : }
2417 :
2418 0 : void DomainMapper::data(const sal_uInt8* /*buf*/, size_t /*len*/,
2419 : writerfilter::Reference<Properties>::Pointer_t /*ref*/)
2420 : {
2421 0 : }
2422 :
2423 0 : void DomainMapper::lcl_startSectionGroup()
2424 : {
2425 0 : if (!m_pImpl->isInIndexContext() && !m_pImpl->isInBibliographyContext())
2426 : {
2427 0 : m_pImpl->PushProperties(CONTEXT_SECTION);
2428 : }
2429 0 : }
2430 :
2431 0 : void DomainMapper::lcl_endSectionGroup()
2432 : {
2433 0 : if (!m_pImpl->isInIndexContext() && !m_pImpl->isInBibliographyContext())
2434 : {
2435 0 : m_pImpl->CheckUnregisteredFrameConversion();
2436 0 : m_pImpl->ExecuteFrameConversion();
2437 0 : PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_SECTION);
2438 0 : SectionPropertyMap* pSectionContext = dynamic_cast< SectionPropertyMap* >( pContext.get() );
2439 : OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
2440 0 : if(pSectionContext)
2441 0 : pSectionContext->CloseSectionGroup( *m_pImpl );
2442 0 : m_pImpl->PopProperties(CONTEXT_SECTION);
2443 : }
2444 0 : }
2445 :
2446 0 : void DomainMapper::lcl_startParagraphGroup()
2447 : {
2448 0 : m_pImpl->getTableManager().startParagraphGroup();
2449 : /*
2450 : * Add new para properties only if paragraph is not split
2451 : * or the top context is not of paragraph properties
2452 : * Set mbIsSplitPara to false as it has been handled
2453 : */
2454 0 : if (!mbIsSplitPara)
2455 0 : m_pImpl->PushProperties(CONTEXT_PARAGRAPH);
2456 0 : mbIsSplitPara = false;
2457 0 : if (!(m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH) == m_pImpl->GetTopContext()))
2458 0 : m_pImpl->PushProperties(CONTEXT_PARAGRAPH);
2459 :
2460 0 : static OUString sDefault("Standard");
2461 0 : if (m_pImpl->GetTopContext())
2462 : {
2463 0 : if (!m_pImpl->IsInShape())
2464 : {
2465 0 : m_pImpl->GetTopContext()->Insert( PROP_PARA_STYLE_NAME, uno::makeAny( sDefault ) );
2466 0 : m_pImpl->SetCurrentParaStyleId(sDefault);
2467 : }
2468 0 : if (m_pImpl->isBreakDeferred(PAGE_BREAK))
2469 0 : m_pImpl->GetTopContext()->Insert( PROP_BREAK_TYPE, uno::makeAny( com::sun::star::style::BreakType_PAGE_BEFORE) );
2470 0 : else if (m_pImpl->isBreakDeferred(COLUMN_BREAK))
2471 0 : m_pImpl->GetTopContext()->Insert( PROP_BREAK_TYPE, uno::makeAny( com::sun::star::style::BreakType_COLUMN_BEFORE) );
2472 : }
2473 0 : m_pImpl->SetIsFirstRun(true);
2474 0 : m_pImpl->clearDeferredBreaks();
2475 0 : }
2476 :
2477 0 : void DomainMapper::lcl_endParagraphGroup()
2478 : {
2479 0 : m_pImpl->PopProperties(CONTEXT_PARAGRAPH);
2480 0 : m_pImpl->getTableManager().endParagraphGroup();
2481 : //frame conversion has to be executed after table conversion
2482 0 : m_pImpl->ExecuteFrameConversion();
2483 0 : }
2484 :
2485 0 : void DomainMapper::markLastParagraphInSection( )
2486 : {
2487 0 : m_pImpl->SetIsLastParagraphInSection( true );
2488 0 : }
2489 :
2490 0 : void DomainMapper::lcl_startShape( uno::Reference< drawing::XShape > xShape )
2491 : {
2492 0 : if (m_pImpl->GetTopContext())
2493 : {
2494 : // If there is a deferred page break, handle it now, so that the
2495 : // started shape will be on the correct page.
2496 0 : if (m_pImpl->isBreakDeferred(PAGE_BREAK))
2497 : {
2498 0 : m_pImpl->clearDeferredBreak(PAGE_BREAK);
2499 0 : lcl_startCharacterGroup();
2500 0 : sal_uInt8 sBreak[] = { 0xd };
2501 0 : lcl_text(sBreak, 1);
2502 0 : lcl_endCharacterGroup();
2503 0 : lcl_endParagraphGroup();
2504 0 : lcl_startParagraphGroup();
2505 0 : m_pImpl->GetTopContext()->Insert(PROP_BREAK_TYPE, uno::makeAny( com::sun::star::style::BreakType_PAGE_BEFORE));
2506 : }
2507 0 : m_pImpl->PushShapeContext( xShape );
2508 0 : lcl_startParagraphGroup();
2509 : }
2510 : else
2511 : // No context? Then this image should not appear directly inside the
2512 : // document, just save it for later usage.
2513 0 : m_pImpl->PushPendingShape(xShape);
2514 0 : }
2515 :
2516 0 : void DomainMapper::lcl_endShape( )
2517 : {
2518 0 : if (m_pImpl->GetTopContext())
2519 : {
2520 : // End the current table, if there are any. Otherwise the unavoidable
2521 : // empty paragraph at the end of the shape text will cause problems: if
2522 : // the shape text ends with a table, the extra paragraph will be
2523 : // handled as an additional row of the ending table.
2524 0 : m_pImpl->getTableManager().endTable();
2525 :
2526 0 : lcl_endParagraphGroup();
2527 0 : m_pImpl->PopShapeContext( );
2528 : }
2529 0 : }
2530 :
2531 0 : void DomainMapper::PushStyleSheetProperties( PropertyMapPtr pStyleProperties, bool bAffectTableMngr )
2532 : {
2533 0 : m_pImpl->PushStyleProperties( pStyleProperties );
2534 0 : if ( bAffectTableMngr )
2535 0 : m_pImpl->getTableManager( ).SetStyleProperties( pStyleProperties );
2536 0 : }
2537 :
2538 0 : void DomainMapper::PopStyleSheetProperties( bool bAffectTableMngr )
2539 : {
2540 0 : m_pImpl->PopProperties( CONTEXT_STYLESHEET );
2541 0 : if ( bAffectTableMngr )
2542 : {
2543 0 : PropertyMapPtr emptyPtr;
2544 0 : m_pImpl->getTableManager( ).SetStyleProperties( emptyPtr );
2545 : }
2546 0 : }
2547 :
2548 0 : void DomainMapper::PushListProperties( ::boost::shared_ptr<PropertyMap> pListProperties )
2549 : {
2550 0 : m_pImpl->PushListProperties( pListProperties );
2551 0 : }
2552 :
2553 0 : void DomainMapper::PopListProperties()
2554 : {
2555 0 : m_pImpl->PopProperties( CONTEXT_LIST );
2556 0 : }
2557 :
2558 0 : void DomainMapper::lcl_startCharacterGroup()
2559 : {
2560 0 : m_pImpl->PushProperties(CONTEXT_CHARACTER);
2561 0 : if (m_pImpl->m_bFrameBtLr)
2562 : // No support for this in core, work around by char rotation, as we do so for table cells already.
2563 0 : m_pImpl->GetTopContext()->Insert(PROP_CHAR_ROTATION, uno::makeAny(sal_Int16(900)));
2564 0 : }
2565 :
2566 0 : void DomainMapper::lcl_endCharacterGroup()
2567 : {
2568 0 : m_pImpl->PopProperties(CONTEXT_CHARACTER);
2569 0 : }
2570 :
2571 0 : void DomainMapper::lcl_text(const sal_uInt8 * data_, size_t len)
2572 : {
2573 : //TODO: Determine the right text encoding (FIB?)
2574 0 : OUString sText( (const sal_Char*) data_, len, RTL_TEXTENCODING_MS_1252 );
2575 : #ifdef DEBUG_DOMAINMAPPER
2576 : dmapper_logger->startElement("text");
2577 : dmapper_logger->chars(sText);
2578 : dmapper_logger->endElement();
2579 : #endif
2580 :
2581 : try
2582 : {
2583 0 : if(len == 1)
2584 : {
2585 0 : switch(*data_)
2586 : {
2587 0 : case 0x02: return; //footnote character
2588 : case 0x0c: //page break
2589 0 : m_pImpl->deferBreak(PAGE_BREAK);
2590 0 : return;
2591 : case 0x0e: //column break
2592 0 : m_pImpl->deferBreak(COLUMN_BREAK);
2593 0 : return;
2594 : case 0x07:
2595 0 : m_pImpl->getTableManager().text(data_, len);
2596 : case 0x0d:
2597 0 : m_pImpl->finishParagraph(m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH));
2598 0 : return;
2599 : case 0x13:
2600 0 : m_pImpl->PushFieldContext();
2601 0 : return;
2602 : case 0x14:
2603 : // delimiter not necessarily available
2604 : // appears only if field contains further content
2605 0 : m_pImpl->CloseFieldCommand();
2606 0 : return;
2607 : case 0x15: /* end of field */
2608 0 : m_pImpl->PopFieldContext();
2609 0 : return;
2610 : default:
2611 0 : break;
2612 : }
2613 : }
2614 :
2615 0 : PropertyMapPtr pContext = m_pImpl->GetTopContext();
2616 0 : if ( pContext && !pContext->GetFootnote().is() )
2617 : {
2618 0 : if (m_pImpl->isBreakDeferred(PAGE_BREAK))
2619 0 : m_pImpl->GetTopContext()->Insert( PROP_BREAK_TYPE, uno::makeAny( com::sun::star::style::BreakType_PAGE_BEFORE) );
2620 0 : else if (m_pImpl->isBreakDeferred(COLUMN_BREAK))
2621 0 : m_pImpl->GetTopContext()->Insert( PROP_BREAK_TYPE, uno::makeAny( com::sun::star::style::BreakType_COLUMN_BEFORE) );
2622 0 : m_pImpl->clearDeferredBreaks();
2623 : }
2624 :
2625 0 : if( pContext->GetFootnote().is() && m_pImpl->IsCustomFtnMark() )
2626 : {
2627 0 : pContext->GetFootnote()->setLabel( sText );
2628 0 : m_pImpl->SetCustomFtnMark( false );
2629 : //otherwise ignore sText
2630 : }
2631 0 : else if( m_pImpl->IsOpenFieldCommand() )
2632 0 : m_pImpl->AppendFieldCommand(sText);
2633 0 : else if( m_pImpl->IsOpenField() && m_pImpl->IsFieldResultAsString())
2634 : /*depending on the success of the field insert operation this result will be
2635 : set at the field or directly inserted into the text*/
2636 0 : m_pImpl->AppendFieldResult(sText);
2637 : else
2638 : {
2639 0 : if (pContext == 0)
2640 0 : pContext.reset(new PropertyMap());
2641 :
2642 0 : m_pImpl->appendTextPortion( sText, pContext );
2643 0 : }
2644 : }
2645 0 : catch( const uno::RuntimeException& e )
2646 : {
2647 : SAL_WARN("writerfilter", "failed. Message :" << e.Message);
2648 0 : }
2649 : }
2650 :
2651 0 : void DomainMapper::lcl_positivePercentage(const OUString& rText)
2652 : {
2653 0 : m_pImpl->m_aPositivePercentages.push(rText);
2654 0 : }
2655 :
2656 0 : void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
2657 : {
2658 0 : OUString sText;
2659 0 : OUStringBuffer aBuffer = OUStringBuffer(len);
2660 0 : aBuffer.append( (const sal_Unicode *) data_, len);
2661 0 : sText = aBuffer.makeStringAndClear();
2662 :
2663 0 : if (!m_pImpl->m_pSdtHelper->getDropDownItems().empty())
2664 : {
2665 0 : m_pImpl->m_pSdtHelper->getSdtTexts().append(sText);
2666 0 : return;
2667 : }
2668 0 : else if (!m_pImpl->m_pSdtHelper->getDateFormat().isEmpty())
2669 : {
2670 : /*
2671 : * Here we assume w:sdt only contains a single text token. We need to
2672 : * create the control early, as in Writer, it's part of the cell, but
2673 : * in OOXML, the sdt contains the cell.
2674 : */
2675 0 : m_pImpl->m_pSdtHelper->createDateControl(sText);
2676 0 : return;
2677 : }
2678 0 : else if (!m_pImpl->m_pSdtHelper->isInteropGrabBagEmpty())
2679 : {
2680 : // there are unsupported SDT properties in the document
2681 : // save them in the paragraph interop grab bag
2682 0 : if(m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_checkbox") ||
2683 0 : m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_text") ||
2684 0 : m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_dataBinding") ||
2685 0 : (m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_id") &&
2686 0 : m_pImpl->m_pSdtHelper->getInteropGrabBagSize() == 1))
2687 : m_pImpl->GetTopContextOfType(CONTEXT_CHARACTER)->Insert(PROP_SDTPR,
2688 0 : uno::makeAny(m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear()), true, CHAR_GRAB_BAG);
2689 : else
2690 : m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)->Insert(PROP_SDTPR,
2691 0 : uno::makeAny(m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear()), true, PARA_GRAB_BAG);
2692 : }
2693 0 : else if (len == 1 && sText[0] == 0x03)
2694 : {
2695 : // This is the uFtnEdnSep, remember that the document has a separator.
2696 0 : m_pImpl->m_bHasFtnSep = true;
2697 0 : return;
2698 : }
2699 0 : else if (len == 1 && sText[0] == '\t' && m_pImpl->m_bIgnoreNextTab)
2700 : {
2701 0 : m_pImpl->m_bIgnoreNextTab = false;
2702 0 : return;
2703 : }
2704 :
2705 : try
2706 : {
2707 0 : m_pImpl->getTableManager().utext(data_, len);
2708 :
2709 0 : if(len == 1 && (sText[0] == 0x0d || sText[0] == 0x07))
2710 : {
2711 0 : if (m_pImpl->m_bIgnoreNextPara)
2712 : {
2713 0 : m_pImpl->m_bIgnoreNextPara = false;
2714 0 : return;
2715 : }
2716 0 : PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH);
2717 0 : if (pContext && m_pImpl->GetSettingsTable()->GetSplitPgBreakAndParaMark())
2718 : {
2719 0 : if (m_pImpl->isBreakDeferred(PAGE_BREAK))
2720 0 : pContext->Insert(PROP_BREAK_TYPE, uno::makeAny( com::sun::star::style::BreakType_PAGE_BEFORE));
2721 0 : else if (m_pImpl->isBreakDeferred(COLUMN_BREAK))
2722 0 : pContext->Insert(PROP_BREAK_TYPE, uno::makeAny( com::sun::star::style::BreakType_COLUMN_BEFORE));
2723 0 : m_pImpl->clearDeferredBreaks();
2724 : }
2725 :
2726 0 : bool bSingleParagraph = m_pImpl->GetIsFirstParagraphInSection() && m_pImpl->GetIsLastParagraphInSection();
2727 : // If the paragraph contains only the section properties and it has
2728 : // no runs, we should not create a paragraph for it in Writer, unless that would remove the whole section.
2729 0 : bool bRemove = !m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr() && !bSingleParagraph;
2730 0 : m_pImpl->SetParaSectpr(false);
2731 0 : m_pImpl->finishParagraph(m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH));
2732 0 : if (bRemove)
2733 0 : m_pImpl->RemoveLastParagraph();
2734 : }
2735 : else
2736 : {
2737 :
2738 0 : PropertyMapPtr pContext = m_pImpl->GetTopContext();
2739 0 : if ( pContext && !pContext->GetFootnote().is() )
2740 : {
2741 0 : if (m_pImpl->isBreakDeferred(PAGE_BREAK))
2742 0 : m_pImpl->GetTopContext()->Insert( PROP_BREAK_TYPE, uno::makeAny( com::sun::star::style::BreakType_PAGE_BEFORE) );
2743 0 : else if (m_pImpl->isBreakDeferred(COLUMN_BREAK))
2744 : {
2745 0 : if (!m_pImpl->IsFirstRun())
2746 : {
2747 0 : mbIsSplitPara = true;
2748 0 : m_pImpl->finishParagraph(m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH));
2749 0 : lcl_startParagraphGroup();
2750 : }
2751 0 : m_pImpl->GetTopContext()->Insert( PROP_BREAK_TYPE, uno::makeAny( com::sun::star::style::BreakType_COLUMN_BEFORE) );
2752 : }
2753 0 : m_pImpl->clearDeferredBreaks();
2754 : }
2755 :
2756 0 : if( pContext && pContext->GetFootnote().is() )
2757 : {
2758 0 : if( !pContext->GetFootnoteSymbol() )
2759 0 : pContext->GetFootnote()->setLabel( sText );
2760 : //otherwise ignore sText
2761 : }
2762 0 : else if( m_pImpl->IsOpenFieldCommand() )
2763 0 : m_pImpl->AppendFieldCommand(sText);
2764 0 : else if( m_pImpl->IsOpenField() && m_pImpl->IsFieldResultAsString())
2765 : /*depending on the success of the field insert operation this result will be
2766 : set at the field or directly inserted into the text*/
2767 0 : m_pImpl->AppendFieldResult(sText);
2768 : else
2769 : {
2770 0 : if (pContext == 0)
2771 0 : pContext.reset(new PropertyMap());
2772 :
2773 0 : m_pImpl->appendTextPortion( sText, pContext );
2774 0 : }
2775 :
2776 : }
2777 0 : m_pImpl->SetIsFirstRun(false);
2778 : }
2779 0 : catch( const uno::RuntimeException& )
2780 : {
2781 0 : }
2782 : }
2783 :
2784 0 : void DomainMapper::lcl_props(writerfilter::Reference<Properties>::Pointer_t ref)
2785 : {
2786 0 : string sType = ref->getType();
2787 0 : if( sType == "PICF" )
2788 : {
2789 0 : m_pImpl->ImportGraphic(ref, IMPORT_AS_GRAPHIC);
2790 : }
2791 0 : else if( sType == "FSPA" )
2792 : {
2793 0 : m_pImpl->ImportGraphic(ref, IMPORT_AS_SHAPE);
2794 : }
2795 : else
2796 0 : ref->resolve(*this);
2797 0 : }
2798 :
2799 0 : void DomainMapper::lcl_table(Id name, writerfilter::Reference<Table>::Pointer_t ref)
2800 : {
2801 0 : m_pImpl->SetAnyTableImport(true);
2802 0 : switch(name)
2803 : {
2804 : case NS_ooxml::LN_FONTTABLE:
2805 :
2806 : // create a font table object that listens to the attributes
2807 : // each entry call inserts a new font entry
2808 0 : ref->resolve( *m_pImpl->GetFontTable() );
2809 0 : break;
2810 : case NS_ooxml::LN_STYLESHEET:
2811 : //same as above to import style sheets
2812 0 : m_pImpl->SetStyleSheetImport( true );
2813 0 : ref->resolve( *m_pImpl->GetStyleSheetTable() );
2814 0 : m_pImpl->GetStyleSheetTable()->ApplyStyleSheets(m_pImpl->GetFontTable());
2815 0 : m_pImpl->SetStyleSheetImport( false );
2816 0 : break;
2817 : case NS_ooxml::LN_NUMBERING:
2818 : {
2819 :
2820 : //the same for list tables
2821 0 : ref->resolve( *m_pImpl->GetListTable() );
2822 0 : m_pImpl->GetListTable( )->CreateNumberingRules( );
2823 : }
2824 0 : break;
2825 : case NS_ooxml::LN_THEMETABLE:
2826 : m_pImpl->GetThemeTable()->setThemeFontLangProperties(
2827 0 : m_pImpl->GetSettingsTable()->GetThemeFontLangProperties() );
2828 0 : ref->resolve ( *m_pImpl->GetThemeTable() );
2829 0 : break;
2830 : case NS_ooxml::LN_settings_settings:
2831 0 : ref->resolve ( *m_pImpl->GetSettingsTable() );
2832 0 : m_pImpl->ApplySettingsTable();
2833 0 : break;
2834 : default:
2835 : OSL_FAIL( "which table is to be filled here?");
2836 : }
2837 0 : m_pImpl->SetAnyTableImport(false);
2838 0 : }
2839 :
2840 0 : void DomainMapper::lcl_substream(Id rName, ::writerfilter::Reference<Stream>::Pointer_t ref)
2841 : {
2842 0 : m_pImpl->substream(rName, ref);
2843 0 : }
2844 :
2845 0 : void DomainMapper_Impl::substream(Id rName,
2846 : ::writerfilter::Reference<Stream>::Pointer_t const& ref)
2847 : {
2848 : #ifndef NDEBUG
2849 : size_t contextSize(m_aContextStack.size());
2850 : size_t propSize[NUMBER_OF_CONTEXTS];
2851 : for (int i = 0; i < NUMBER_OF_CONTEXTS; ++i) {
2852 : propSize[i] = m_aPropertyStacks[i].size();
2853 : }
2854 : #endif
2855 :
2856 0 : appendTableManager();
2857 : // Appending a TableManager resets its TableHandler, so we need to append
2858 : // that as well, or tables won't be imported properly in headers/footers.
2859 0 : appendTableHandler();
2860 0 : getTableManager().startLevel();
2861 :
2862 : //import of page header/footer
2863 :
2864 0 : switch( rName )
2865 : {
2866 : case NS_ooxml::LN_headerl:
2867 :
2868 0 : PushPageHeader(SectionPropertyMap::PAGE_LEFT);
2869 0 : break;
2870 : case NS_ooxml::LN_headerr:
2871 :
2872 0 : PushPageHeader(SectionPropertyMap::PAGE_RIGHT);
2873 0 : break;
2874 : case NS_ooxml::LN_headerf:
2875 :
2876 0 : PushPageHeader(SectionPropertyMap::PAGE_FIRST);
2877 0 : break;
2878 : case NS_ooxml::LN_footerl:
2879 :
2880 0 : PushPageFooter(SectionPropertyMap::PAGE_LEFT);
2881 0 : break;
2882 : case NS_ooxml::LN_footerr:
2883 :
2884 0 : PushPageFooter(SectionPropertyMap::PAGE_RIGHT);
2885 0 : break;
2886 : case NS_ooxml::LN_footerf:
2887 :
2888 0 : PushPageFooter(SectionPropertyMap::PAGE_FIRST);
2889 0 : break;
2890 : case NS_ooxml::LN_footnote:
2891 : case NS_ooxml::LN_endnote:
2892 0 : PushFootOrEndnote( NS_ooxml::LN_footnote == rName );
2893 0 : break;
2894 : case NS_ooxml::LN_annotation :
2895 0 : PushAnnotation();
2896 0 : break;
2897 : }
2898 0 : ref->resolve(m_rDMapper);
2899 0 : switch( rName )
2900 : {
2901 : case NS_ooxml::LN_headerl:
2902 : case NS_ooxml::LN_headerr:
2903 : case NS_ooxml::LN_headerf:
2904 : case NS_ooxml::LN_footerl:
2905 : case NS_ooxml::LN_footerr:
2906 : case NS_ooxml::LN_footerf:
2907 0 : PopPageHeaderFooter();
2908 0 : break;
2909 : case NS_ooxml::LN_footnote:
2910 : case NS_ooxml::LN_endnote:
2911 0 : PopFootOrEndnote();
2912 0 : break;
2913 : case NS_ooxml::LN_annotation :
2914 0 : PopAnnotation();
2915 0 : break;
2916 : }
2917 :
2918 0 : getTableManager().endLevel();
2919 0 : popTableManager();
2920 :
2921 : // check that stacks are the same as before substream
2922 : assert(m_aContextStack.size() == contextSize);
2923 0 : for (int i = 0; i < NUMBER_OF_CONTEXTS; ++i) {
2924 : assert(m_aPropertyStacks[i].size() == propSize[i]);
2925 : }
2926 0 : }
2927 :
2928 0 : void DomainMapper::lcl_info(const string & /*info_*/)
2929 : {
2930 0 : }
2931 :
2932 0 : void DomainMapper::handleUnderlineType(const sal_Int32 nIntValue, const ::boost::shared_ptr<PropertyMap> pContext)
2933 : {
2934 0 : sal_Int16 eUnderline = awt::FontUnderline::NONE;
2935 :
2936 0 : switch(nIntValue)
2937 : {
2938 0 : case 0: eUnderline = awt::FontUnderline::NONE; break;
2939 0 : case 2: pContext->Insert(PROP_CHAR_WORD_MODE, uno::makeAny( true ) ); // TODO: how to get rid of it?
2940 0 : case 1: eUnderline = awt::FontUnderline::SINGLE; break;
2941 0 : case 3: eUnderline = awt::FontUnderline::DOUBLE; break;
2942 0 : case 4: eUnderline = awt::FontUnderline::DOTTED; break;
2943 0 : case 7: eUnderline = awt::FontUnderline::DASH; break;
2944 0 : case 9: eUnderline = awt::FontUnderline::DASHDOT; break;
2945 0 : case 10:eUnderline = awt::FontUnderline::DASHDOTDOT; break;
2946 0 : case 6: eUnderline = awt::FontUnderline::BOLD; break;
2947 0 : case 11:eUnderline = awt::FontUnderline::WAVE; break;
2948 0 : case 20:eUnderline = awt::FontUnderline::BOLDDOTTED; break;
2949 0 : case 23:eUnderline = awt::FontUnderline::BOLDDASH; break;
2950 0 : case 39:eUnderline = awt::FontUnderline::LONGDASH; break;
2951 0 : case 55:eUnderline = awt::FontUnderline::BOLDLONGDASH; break;
2952 0 : case 25:eUnderline = awt::FontUnderline::BOLDDASHDOT; break;
2953 0 : case 26:eUnderline = awt::FontUnderline::BOLDDASHDOTDOT;break;
2954 0 : case 27:eUnderline = awt::FontUnderline::BOLDWAVE; break;
2955 0 : case 43:eUnderline = awt::FontUnderline::DOUBLEWAVE; break;
2956 : default: ;
2957 : }
2958 0 : pContext->Insert(PROP_CHAR_UNDERLINE, uno::makeAny( eUnderline ) );
2959 0 : }
2960 :
2961 0 : void DomainMapper::handleParaJustification(const sal_Int32 nIntValue, const ::boost::shared_ptr<PropertyMap> pContext, const bool bExchangeLeftRight)
2962 : {
2963 0 : sal_Int16 nAdjust = 0;
2964 0 : sal_Int16 nLastLineAdjust = 0;
2965 0 : OUString aStringValue = "left";
2966 0 : switch(nIntValue)
2967 : {
2968 : case 1:
2969 0 : nAdjust = style::ParagraphAdjust_CENTER;
2970 0 : aStringValue = "center";
2971 0 : break;
2972 : case 2:
2973 0 : nAdjust = static_cast< sal_Int16 > (bExchangeLeftRight ? style::ParagraphAdjust_LEFT : style::ParagraphAdjust_RIGHT);
2974 0 : aStringValue = "right";
2975 0 : break;
2976 : case 4:
2977 0 : nLastLineAdjust = style::ParagraphAdjust_BLOCK;
2978 : //no break;
2979 : case 3:
2980 0 : nAdjust = style::ParagraphAdjust_BLOCK;
2981 0 : aStringValue = "both";
2982 0 : break;
2983 : case 0:
2984 : default:
2985 0 : nAdjust = static_cast< sal_Int16 > (bExchangeLeftRight ? style::ParagraphAdjust_RIGHT : style::ParagraphAdjust_LEFT);
2986 0 : break;
2987 : }
2988 0 : pContext->Insert( PROP_PARA_ADJUST, uno::makeAny( nAdjust ) );
2989 0 : pContext->Insert( PROP_PARA_LAST_LINE_ADJUST, uno::makeAny( nLastLineAdjust ) );
2990 0 : m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "jc", aStringValue);
2991 0 : }
2992 :
2993 0 : bool DomainMapper::getColorFromIndex(const sal_Int32 nIndex, sal_Int32 &nColor)
2994 : {
2995 0 : nColor = 0;
2996 0 : if ((nIndex < 1) || (nIndex > 16))
2997 0 : return false;
2998 :
2999 0 : switch (nIndex)
3000 : {
3001 0 : case 1: nColor=0x000000; break; //black
3002 0 : case 2: nColor=0x0000ff; break; //blue
3003 0 : case 3: nColor=0x00ffff; break; //cyan
3004 0 : case 4: nColor=0x00ff00; break; //green
3005 0 : case 5: nColor=0xff00ff; break; //magenta
3006 0 : case 6: nColor=0xff0000; break; //red
3007 0 : case 7: nColor=0xffff00; break; //yellow
3008 0 : case 8: nColor=0xffffff; break; //white
3009 0 : case 9: nColor=0x000080; break;//dark blue
3010 0 : case 10: nColor=0x008080; break; //dark cyan
3011 0 : case 11: nColor=0x008000; break; //dark green
3012 0 : case 12: nColor=0x800080; break; //dark magenta
3013 0 : case 13: nColor=0x800000; break; //dark red
3014 0 : case 14: nColor=0x808000; break; //dark yellow
3015 0 : case 15: nColor=0x808080; break; //dark gray
3016 0 : case 16: nColor=0xC0C0C0; break; //light gray
3017 : default:
3018 0 : return false;
3019 : }
3020 0 : return true;
3021 : }
3022 :
3023 0 : sal_Int16 DomainMapper::getEmphasisValue(const sal_Int32 nIntValue)
3024 : {
3025 0 : switch (nIntValue)
3026 : {
3027 : case 1:
3028 0 : return com::sun::star::text::FontEmphasis::DOT_ABOVE;
3029 : case 2:
3030 0 : return com::sun::star::text::FontEmphasis::ACCENT_ABOVE;
3031 : case 3:
3032 0 : return com::sun::star::text::FontEmphasis::CIRCLE_ABOVE;
3033 : case 4:
3034 0 : return com::sun::star::text::FontEmphasis::DOT_BELOW;
3035 : default:
3036 0 : return com::sun::star::text::FontEmphasis::NONE;
3037 : }
3038 : }
3039 :
3040 0 : OUString DomainMapper::getBracketStringFromEnum(const sal_Int32 nIntValue, const bool bIsPrefix)
3041 : {
3042 0 : switch(nIntValue)
3043 : {
3044 : case 1:
3045 0 : if (bIsPrefix)
3046 0 : return OUString( "(" );
3047 0 : return OUString( ")" );
3048 :
3049 : case 2:
3050 0 : if (bIsPrefix)
3051 0 : return OUString( "[" );
3052 0 : return OUString( "]" );
3053 :
3054 : case 3:
3055 0 : if (bIsPrefix)
3056 0 : return OUString( "<" );
3057 0 : return OUString( ">" );
3058 :
3059 : case 4:
3060 0 : if (bIsPrefix)
3061 0 : return OUString( "{" );
3062 0 : return OUString( "}" );
3063 :
3064 : case 0:
3065 : default:
3066 0 : return OUString();
3067 : }
3068 : }
3069 :
3070 0 : com::sun::star::style::TabAlign DomainMapper::getTabAlignFromValue(const sal_Int32 nIntValue)
3071 : {
3072 0 : switch (nIntValue)
3073 : {
3074 : case 0:
3075 : case 4: // bar not supported
3076 : case 5: // num not supported
3077 0 : return com::sun::star::style::TabAlign_LEFT;
3078 : case 1:
3079 0 : return com::sun::star::style::TabAlign_CENTER;
3080 : case 2:
3081 0 : return com::sun::star::style::TabAlign_RIGHT;
3082 : case 3:
3083 0 : return com::sun::star::style::TabAlign_DECIMAL;
3084 : }
3085 0 : return com::sun::star::style::TabAlign_LEFT;
3086 : }
3087 :
3088 0 : sal_Unicode DomainMapper::getFillCharFromValue(const sal_Int32 nIntValue)
3089 : {
3090 0 : switch (nIntValue)
3091 : {
3092 : case 1: // dot
3093 0 : return sal_Unicode(0x002e);
3094 : case 2: // hyphen
3095 0 : return sal_Unicode(0x002d);
3096 : case 3: // underscore
3097 : case 4: // heavy FIXME ???
3098 0 : return sal_Unicode(0x005f);
3099 : case NS_ooxml::LN_Value_ST_TabTlc_middleDot: // middleDot
3100 0 : return sal_Unicode(0x00b7);
3101 : case 0: // none
3102 : default:
3103 0 : return sal_Unicode(0x0020); // blank space
3104 : }
3105 : }
3106 :
3107 0 : bool DomainMapper::IsOOXMLImport() const
3108 : {
3109 0 : return m_pImpl->IsOOXMLImport();
3110 : }
3111 :
3112 0 : bool DomainMapper::IsRTFImport() const
3113 : {
3114 0 : return m_pImpl->IsRTFImport();
3115 : }
3116 :
3117 0 : uno::Reference < lang::XMultiServiceFactory > DomainMapper::GetTextFactory() const
3118 : {
3119 0 : return m_pImpl->GetTextFactory();
3120 : }
3121 :
3122 0 : uno::Reference< text::XTextRange > DomainMapper::GetCurrentTextRange()
3123 : {
3124 0 : return m_pImpl->GetTopTextAppend()->getEnd();
3125 : }
3126 :
3127 0 : OUString DomainMapper::getOrCreateCharStyle( PropertyValueVector_t& rCharProperties )
3128 : {
3129 0 : StyleSheetTablePtr pStyleSheets = m_pImpl->GetStyleSheetTable();
3130 0 : return pStyleSheets->getOrCreateCharStyle( rCharProperties );
3131 : }
3132 :
3133 0 : StyleSheetTablePtr DomainMapper::GetStyleSheetTable( )
3134 : {
3135 0 : return m_pImpl->GetStyleSheetTable( );
3136 : }
3137 :
3138 0 : GraphicZOrderHelper* DomainMapper::graphicZOrderHelper()
3139 : {
3140 0 : if( zOrderHelper.get() == NULL )
3141 0 : zOrderHelper.reset( new GraphicZOrderHelper );
3142 0 : return zOrderHelper.get();
3143 : }
3144 :
3145 0 : uno::Reference<drawing::XShape> DomainMapper::PopPendingShape()
3146 : {
3147 0 : return m_pImpl->PopPendingShape();
3148 : }
3149 :
3150 0 : bool DomainMapper::IsInHeaderFooter() const
3151 : {
3152 0 : return m_pImpl->IsInHeaderFooter();
3153 : }
3154 :
3155 0 : void DomainMapper::enableInteropGrabBag(const OUString& aName)
3156 : {
3157 0 : m_pImpl->m_aInteropGrabBagName = aName;
3158 0 : }
3159 :
3160 0 : beans::PropertyValue DomainMapper::getInteropGrabBag()
3161 : {
3162 0 : beans::PropertyValue aRet;
3163 0 : aRet.Name = m_pImpl->m_aInteropGrabBagName;
3164 :
3165 0 : uno::Sequence<beans::PropertyValue> aSeq(m_pImpl->m_aInteropGrabBag.size());
3166 0 : beans::PropertyValue* pSeq = aSeq.getArray();
3167 0 : for (std::vector<beans::PropertyValue>::iterator i = m_pImpl->m_aInteropGrabBag.begin(); i != m_pImpl->m_aInteropGrabBag.end(); ++i)
3168 0 : *pSeq++ = *i;
3169 :
3170 0 : m_pImpl->m_aInteropGrabBag.clear();
3171 0 : m_pImpl->m_aInteropGrabBagName = "";
3172 0 : aRet.Value = uno::makeAny(aSeq);
3173 0 : return aRet;
3174 : }
3175 :
3176 0 : uno::Sequence<beans::PropertyValue> DomainMapper::GetThemeFontLangProperties() const
3177 : {
3178 0 : return m_pImpl->GetSettingsTable()->GetThemeFontLangProperties();
3179 : }
3180 :
3181 0 : uno::Sequence<beans::PropertyValue> DomainMapper::GetCompatSettings() const
3182 : {
3183 0 : return m_pImpl->GetSettingsTable()->GetCompatSettings();
3184 : }
3185 :
3186 0 : void DomainMapper::HandleRedline( Sprm& rSprm )
3187 : {
3188 0 : sal_uInt32 nSprmId = rSprm.getId();
3189 :
3190 0 : m_pImpl->AddNewRedline( );
3191 :
3192 0 : if (nSprmId == NS_ooxml::LN_CT_PPr_pPrChange)
3193 : {
3194 0 : m_pImpl->SetCurrentRedlineToken(OOXML_ParagraphFormat);
3195 : }
3196 0 : else if (nSprmId == NS_ooxml::LN_CT_TrPr_ins)
3197 : {
3198 0 : m_pImpl->SetCurrentRedlineToken(OOXML_tableRowInsert);
3199 : }
3200 0 : else if (nSprmId == NS_ooxml::LN_CT_TrPr_del)
3201 : {
3202 0 : m_pImpl->SetCurrentRedlineToken(OOXML_tableRowDelete);
3203 : }
3204 0 : else if (nSprmId == NS_ooxml::LN_CT_TcPrBase_cellIns)
3205 : {
3206 0 : m_pImpl->SetCurrentRedlineToken(OOXML_tableCellInsert);
3207 : }
3208 0 : else if (nSprmId == NS_ooxml::LN_CT_TcPrBase_cellDel)
3209 : {
3210 0 : m_pImpl->SetCurrentRedlineToken(OOXML_tableCellDelete);
3211 : }
3212 :
3213 0 : resolveSprmProps(*this, rSprm );
3214 : // now the properties author, date and id should be available
3215 0 : sal_Int32 nToken = m_pImpl->GetCurrentRedlineToken();
3216 0 : switch( nToken & 0xffff )
3217 : {
3218 : case OOXML_mod:
3219 : case OOXML_ins:
3220 : case OOXML_del:
3221 : case OOXML_ParagraphFormat:
3222 : case OOXML_tableRowInsert:
3223 : case OOXML_tableRowDelete:
3224 : case OOXML_tableCellInsert:
3225 : case OOXML_tableCellDelete:
3226 0 : break;
3227 0 : default: OSL_FAIL( "redline token other than mod, ins, del or table row" ); break;
3228 : }
3229 0 : m_pImpl->EndParaMarkerChange( );
3230 0 : }
3231 :
3232 : } //namespace dmapper
3233 0 : } //namespace writerfilter
3234 :
3235 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|