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 <PropertyMap.hxx>
20 : #include <ooxml/resourceids.hxx>
21 : #include <DomainMapper_Impl.hxx>
22 : #include <ConversionHelper.hxx>
23 : #include <i18nutil/paper.hxx>
24 : #include <rtl/ustring.hxx>
25 : #include <com/sun/star/beans/PropertyValue.hpp>
26 : #include <com/sun/star/beans/XMultiPropertySet.hpp>
27 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 : #include <com/sun/star/table/BorderLine2.hpp>
29 : #include <com/sun/star/container/XEnumeration.hpp>
30 : #include <com/sun/star/container/XEnumerationAccess.hpp>
31 : #include <com/sun/star/container/XNameContainer.hpp>
32 : #include <com/sun/star/style/BreakType.hpp>
33 : #include <com/sun/star/style/PageStyleLayout.hpp>
34 : #include <com/sun/star/table/ShadowFormat.hpp>
35 : #include <com/sun/star/text/RelOrientation.hpp>
36 : #include <com/sun/star/text/WritingMode.hpp>
37 : #include <com/sun/star/text/XTextColumns.hpp>
38 : #include <com/sun/star/text/XText.hpp>
39 : #include <com/sun/star/text/TextGridMode.hpp>
40 : #include <com/sun/star/text/XTextCopy.hpp>
41 : #include "dmapperLoggers.hxx"
42 : #include "PropertyMapHelper.hxx"
43 :
44 : using namespace ::com::sun::star;
45 :
46 : namespace writerfilter {
47 : namespace dmapper{
48 :
49 :
50 :
51 202661 : PropertyMap::PropertyMap() :
52 : m_cFootnoteSymbol( 0 ),
53 202661 : m_nFootnoteFontId( -1 )
54 : {
55 202661 : }
56 :
57 :
58 304161 : PropertyMap::~PropertyMap()
59 : {
60 304161 : }
61 :
62 :
63 88038 : uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharGrabBag)
64 : {
65 88038 : if(!m_aValues.getLength() && size())
66 : {
67 62055 : size_t nCharGrabBag = 0;
68 62055 : size_t nParaGrabBag = 0;
69 445131 : for (PropertyMap::iterator i = begin(); i != end(); ++i)
70 : {
71 383076 : if ( i->second.getGrabBagType() == CHAR_GRAB_BAG )
72 37925 : nCharGrabBag++;
73 345151 : else if ( i->second.getGrabBagType() == PARA_GRAB_BAG )
74 800 : nParaGrabBag++;
75 : }
76 :
77 : // In case there are properties to be grab-bagged and we can have a char grab-bag, allocate one slot for it.
78 62055 : size_t nCharGrabBagSize = 0;
79 62055 : if (bCharGrabBag)
80 62052 : nCharGrabBagSize = nCharGrabBag ? 1 : 0;
81 :
82 : // If there are any grab bag properties, we need one slot for them.
83 62055 : m_aValues.realloc( size() - nCharGrabBag + nCharGrabBagSize
84 62055 : - nParaGrabBag + (nParaGrabBag ? 1 : 0));
85 62055 : ::com::sun::star::beans::PropertyValue* pValues = m_aValues.getArray();
86 62055 : uno::Sequence<beans::PropertyValue> aCharGrabBagValues(nCharGrabBag);
87 124110 : uno::Sequence<beans::PropertyValue> aParaGrabBagValues(nParaGrabBag);
88 62055 : beans::PropertyValue* pCharGrabBagValues = aCharGrabBagValues.getArray();
89 62055 : beans::PropertyValue* pParaGrabBagValues = aParaGrabBagValues.getArray();
90 : //style names have to be the first elements within the property sequence
91 : //otherwise they will overwrite 'hard' attributes
92 62055 : sal_Int32 nValue = 0;
93 62055 : sal_Int32 nParaGrabBagValue = 0;
94 62055 : sal_Int32 nCharGrabBagValue = 0;
95 62055 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
96 62055 : PropertyMap::iterator aParaStyleIter = find(PROP_PARA_STYLE_NAME);
97 62055 : if( aParaStyleIter != end())
98 : {
99 18363 : pValues[nValue].Name = rPropNameSupplier.GetName( aParaStyleIter->first );
100 18363 : pValues[nValue].Value = aParaStyleIter->second.getValue();
101 18363 : ++nValue;
102 : }
103 :
104 62055 : PropertyMap::iterator aCharStyleIter = find(PROP_CHAR_STYLE_NAME);
105 62055 : if( aCharStyleIter != end())
106 : {
107 664 : pValues[nValue].Name = rPropNameSupplier.GetName( aCharStyleIter->first );
108 664 : pValues[nValue].Value = aCharStyleIter->second.getValue();
109 664 : ++nValue;
110 : }
111 62055 : PropertyMap::iterator aNumRuleIter = find(PROP_NUMBERING_RULES);
112 62055 : if( aNumRuleIter != end())
113 : {
114 1162 : pValues[nValue].Name = rPropNameSupplier.GetName( aNumRuleIter->first );
115 1162 : pValues[nValue].Value = aNumRuleIter->second.getValue();
116 1162 : ++nValue;
117 : }
118 62055 : PropertyMap::iterator aMapIter = begin();
119 445131 : for( ; aMapIter != end(); ++aMapIter )
120 : {
121 383076 : if( aMapIter != aParaStyleIter && aMapIter != aCharStyleIter && aMapIter != aNumRuleIter )
122 : {
123 362887 : if ( aMapIter->second.getGrabBagType() == CHAR_GRAB_BAG )
124 : {
125 37925 : if (bCharGrabBag)
126 : {
127 37923 : pCharGrabBagValues[nCharGrabBagValue].Name = rPropNameSupplier.GetName( aMapIter->first );
128 37923 : pCharGrabBagValues[nCharGrabBagValue].Value = aMapIter->second.getValue();
129 37923 : ++nCharGrabBagValue;
130 : }
131 : }
132 324962 : else if ( aMapIter->second.getGrabBagType() == PARA_GRAB_BAG )
133 : {
134 800 : pParaGrabBagValues[nParaGrabBagValue].Name = rPropNameSupplier.GetName( aMapIter->first );
135 800 : pParaGrabBagValues[nParaGrabBagValue].Value = aMapIter->second.getValue();
136 800 : ++nParaGrabBagValue;
137 : }
138 : else
139 : {
140 324162 : pValues[nValue].Name = rPropNameSupplier.GetName( aMapIter->first );
141 324162 : pValues[nValue].Value = aMapIter->second.getValue();
142 324162 : ++nValue;
143 : }
144 : }
145 : }
146 62055 : if (nCharGrabBag && bCharGrabBag)
147 : {
148 16616 : pValues[nValue].Name = "CharInteropGrabBag";
149 16616 : pValues[nValue].Value = uno::makeAny(aCharGrabBagValues);
150 16616 : ++nValue;
151 : }
152 62055 : if (nParaGrabBag)
153 : {
154 503 : pValues[nValue].Name = "ParaInteropGrabBag";
155 503 : pValues[nValue].Value = uno::makeAny(aParaGrabBagValues);
156 503 : ++nValue;
157 62055 : }
158 : }
159 88038 : return m_aValues;
160 : }
161 :
162 : #ifdef DEBUG_DMAPPER_PROPERTY_MAP
163 : static void lcl_AnyToTag(const uno::Any & rAny)
164 : {
165 : try {
166 : sal_Int32 aInt = 0;
167 : rAny >>= aInt;
168 : dmapper_logger->attribute("value", aInt);
169 :
170 : sal_uInt32 auInt = 0;
171 : rAny >>= auInt;
172 : dmapper_logger->attribute("unsignedValue", auInt);
173 :
174 : float aFloat = 0.0f;
175 : rAny >>= aFloat;
176 : dmapper_logger->attribute("floatValue", aFloat);
177 :
178 : OUString aStr;
179 : rAny >>= aStr;
180 : dmapper_logger->attribute("stringValue", aStr);
181 : }
182 : catch (...) {
183 : }
184 : }
185 : #endif
186 :
187 521288 : void PropertyMap::Insert( PropertyIds eId, const uno::Any& rAny, bool bOverwrite, GrabBagType rGrabBagType )
188 : {
189 : #ifdef DEBUG_DMAPPER_PROPERTY_MAP
190 : const OUString& rInsert = PropertyNameSupplier::
191 : GetPropertyNameSupplier().GetName(eId);
192 :
193 : dmapper_logger->startElement("propertyMap.insert");
194 : dmapper_logger->attribute("name", rInsert);
195 : lcl_AnyToTag(rAny);
196 : dmapper_logger->endElement();
197 : #endif
198 :
199 521288 : PropertyMap::iterator aElement = find(eId);
200 521288 : if (aElement != end())
201 : {
202 38259 : if (bOverwrite)
203 29797 : aElement->second = PropValue(rAny, rGrabBagType);
204 :
205 559547 : return;
206 : }
207 483029 : _PropertyMap::insert(_PropertyMap::value_type(eId, PropValue(rAny, rGrabBagType)));
208 :
209 483029 : Invalidate();
210 : }
211 :
212 : #if OSL_DEBUG_LEVEL > 1
213 : void PropertyMap::dumpXml( const TagLogger::Pointer_t pLogger ) const
214 : {
215 : pLogger->startElement("PropertyMap");
216 :
217 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
218 : PropertyMap::const_iterator aMapIter = begin();
219 : while (aMapIter != end())
220 : {
221 : pLogger->startElement("property");
222 :
223 : pLogger->attribute("name", rPropNameSupplier.GetName( aMapIter->first ));
224 :
225 : switch (aMapIter->first)
226 : {
227 : case PROP_TABLE_COLUMN_SEPARATORS:
228 : lcl_DumpTableColumnSeparators(pLogger, aMapIter->second.getValue());
229 : break;
230 : default:
231 : {
232 : try {
233 : sal_Int32 aInt = 0;
234 : aMapIter->second.getValue() >>= aInt;
235 : pLogger->attribute("value", aInt);
236 :
237 : sal_uInt32 auInt = 0;
238 : aMapIter->second.getValue() >>= auInt;
239 : pLogger->attribute("unsignedValue", auInt);
240 :
241 : float aFloat = 0.0;
242 : aMapIter->second.getValue() >>= aFloat;
243 : pLogger->attribute("floatValue", aFloat);
244 :
245 : OUString aStr;
246 : aMapIter->second.getValue() >>= auInt;
247 : pLogger->attribute("stringValue", aStr);
248 : }
249 : catch (...) {
250 : }
251 : }
252 : break;
253 : }
254 :
255 : pLogger->endElement();
256 :
257 : ++aMapIter;
258 : }
259 :
260 : pLogger->endElement();
261 : }
262 : #endif
263 :
264 :
265 :
266 : template<class T>
267 : struct removeExistingElements : public ::std::unary_function<T, void>
268 : {
269 : PropertyMap& rMap;
270 :
271 63846 : removeExistingElements(PropertyMap& _rMap ) : rMap(_rMap) {}
272 85473 : void operator() (T x)
273 : {
274 85473 : PropertyMap::iterator aElement = rMap.find(x.first);
275 85473 : if( aElement != rMap.end())
276 6551 : rMap.erase( aElement );
277 85473 : }
278 : };
279 :
280 63846 : void PropertyMap::InsertProps(const PropertyMapPtr pMap)
281 : {
282 63846 : if( pMap.get() )
283 : {
284 127692 : ::std::for_each( pMap->begin(), pMap->end(),
285 191538 : removeExistingElements<PropertyMap::value_type>(*this) );
286 63846 : _PropertyMap::insert(pMap->begin(), pMap->end());
287 63846 : insertTableProperties(pMap.get());
288 :
289 63846 : Invalidate();
290 : }
291 63846 : }
292 :
293 75742 : const uno::Reference< text::XFootnote>& PropertyMap::GetFootnote() const
294 : {
295 75742 : return m_xFootnote;
296 : }
297 :
298 :
299 45840 : void PropertyMap::insertTableProperties( const PropertyMap* )
300 : {
301 : #ifdef DEBUG_DOMAINMAPPER
302 : dmapper_logger->element("PropertyMap.insertTableProperties");
303 : #endif
304 45840 : }
305 :
306 :
307 1336 : SectionPropertyMap::SectionPropertyMap(bool bIsFirstSection) :
308 : m_bIsFirstSection( bIsFirstSection )
309 : ,m_nBorderParams( 0 )
310 : ,m_bTitlePage( false )
311 : ,m_nColumnCount( 0 )
312 : ,m_nColumnDistance( 1249 )
313 : ,m_bSeparatorLineIsOn( false )
314 : ,m_bEvenlySpaced( false )
315 : ,m_bIsLandscape( false )
316 : ,m_bPageNoRestart( false )
317 : ,m_nPageNumber( -1 )
318 : ,m_nBreakType( -1 )
319 : ,m_nPaperBin( -1 )
320 : ,m_nFirstPaperBin( -1 )
321 : ,m_nLeftMargin( 3175 ) //page left margin, default 0x708 (1800) twip -> 3175 1/100 mm
322 : ,m_nRightMargin( 3175 )//page right margin, default 0x708 (1800) twip -> 3175 1/100 mm
323 : ,m_nTopMargin( 2540 )
324 : ,m_nBottomMargin( 2540 )
325 : ,m_nHeaderTop( 1270 ) //720 twip
326 : ,m_nHeaderBottom( 1270 )//720 twip
327 : ,m_nDzaGutter( 0 )
328 : ,m_bGutterRTL( false )
329 : ,m_bSFBiDi( false )
330 : ,m_nGridType(0)
331 : ,m_nGridLinePitch( 1 )
332 : ,m_nDxtCharSpace( 0 )
333 : ,m_nLnnMod( 0 )
334 : ,m_nLnc( 0 )
335 : ,m_ndxaLnn( 0 )
336 1336 : ,m_nLnnMin( 0 )
337 : {
338 : static sal_Int32 nNumber = 0;
339 1336 : nSectionNumber = nNumber++;
340 1336 : memset(&m_pBorderLines, 0x00, sizeof(m_pBorderLines));
341 6680 : for( sal_Int32 nBorder = 0; nBorder < 4; ++nBorder )
342 : {
343 5344 : m_nBorderDistances[ nBorder ] = -1;
344 5344 : m_bBorderShadows[nBorder] = false;
345 : }
346 : //todo: set defaults in ApplyPropertiesToPageStyles
347 : //initialize defaults
348 1336 : PaperInfo aLetter(PAPER_LETTER);
349 : //page height, 1/100mm
350 1336 : Insert( PROP_HEIGHT, uno::makeAny( (sal_Int32) aLetter.getHeight() ) );
351 : //page width, 1/100mm
352 1336 : Insert( PROP_WIDTH, uno::makeAny( (sal_Int32) aLetter.getWidth() ) );
353 : //page left margin, default 0x708 (1800) twip -> 3175 1/100 mm
354 1336 : Insert( PROP_LEFT_MARGIN, uno::makeAny( (sal_Int32) 3175 ) );
355 : //page right margin, default 0x708 (1800) twip -> 3175 1/100 mm
356 1336 : Insert( PROP_RIGHT_MARGIN, uno::makeAny( (sal_Int32) 3175 ) );
357 : //page top margin, default 0x5a0 (1440) twip -> 2540 1/100 mm
358 1336 : Insert( PROP_TOP_MARGIN, uno::makeAny( (sal_Int32)2540 ) );
359 : //page bottom margin, default 0x5a0 (1440) twip -> 2540 1/100 mm
360 1336 : Insert( PROP_BOTTOM_MARGIN, uno::makeAny( (sal_Int32) 2540 ) );
361 : //page style layout
362 1336 : Insert(PROP_PAGE_STYLE_LAYOUT, uno::makeAny(style::PageStyleLayout_ALL));
363 1336 : uno::Any aFalse( ::uno::makeAny( false ) );
364 1336 : Insert( PROP_GRID_DISPLAY, aFalse);
365 1336 : Insert( PROP_GRID_PRINT, aFalse);
366 1336 : Insert( PROP_GRID_MODE, uno::makeAny(text::TextGridMode::NONE));
367 :
368 :
369 1336 : if( m_bIsFirstSection )
370 : {
371 1184 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
372 1184 : m_sFirstPageStyleName = rPropNameSupplier.GetName( PROP_FIRST_PAGE );
373 1184 : m_sFollowPageStyleName = rPropNameSupplier.GetName( PROP_STANDARD );
374 1336 : }
375 1336 : }
376 :
377 :
378 4008 : SectionPropertyMap::~SectionPropertyMap()
379 : {
380 6680 : for( sal_Int16 ePos = BORDER_LEFT; ePos <= BORDER_BOTTOM; ++ePos)
381 5344 : delete m_pBorderLines[ePos];
382 2672 : }
383 :
384 :
385 137 : OUString lcl_FindUnusedPageStyleName(const uno::Sequence< OUString >& rPageStyleNames)
386 : {
387 : static const sal_Char cDefaultStyle[] = "Converted";
388 : //find the hightest number x in each style with the name "cDefaultStyle+x" and
389 : //return an incremented name
390 137 : sal_Int32 nMaxIndex = 0;
391 137 : const sal_Int32 nDefaultLength = sizeof(cDefaultStyle)/sizeof(sal_Char) - 1;
392 137 : const OUString sDefaultStyle( cDefaultStyle, nDefaultLength, RTL_TEXTENCODING_ASCII_US );
393 :
394 137 : const OUString* pStyleNames = rPageStyleNames.getConstArray();
395 2361 : for( sal_Int32 nStyle = 0; nStyle < rPageStyleNames.getLength(); ++nStyle)
396 : {
397 3352 : if( pStyleNames[nStyle].getLength() > nDefaultLength &&
398 1128 : !rtl_ustr_compare_WithLength( sDefaultStyle.getStr(), nDefaultLength, pStyleNames[nStyle].getStr(), nDefaultLength))
399 : {
400 854 : sal_Int32 nIndex = pStyleNames[nStyle].copy( nDefaultLength ).toInt32();
401 854 : if( nIndex > nMaxIndex)
402 854 : nMaxIndex = nIndex;
403 : }
404 : }
405 137 : OUString sRet( sDefaultStyle );
406 137 : sRet += OUString::number( nMaxIndex + 1);
407 137 : return sRet;
408 : }
409 :
410 :
411 :
412 4866 : uno::Reference< beans::XPropertySet > SectionPropertyMap::GetPageStyle(
413 : const uno::Reference< container::XNameContainer >& xPageStyles,
414 : const uno::Reference < lang::XMultiServiceFactory >& xTextFactory,
415 : bool bFirst )
416 : {
417 4866 : uno::Reference< beans::XPropertySet > xRet;
418 : try
419 : {
420 4866 : if( bFirst )
421 : {
422 1485 : if( m_sFirstPageStyleName.isEmpty() && xPageStyles.is() )
423 : {
424 9 : uno::Sequence< OUString > aPageStyleNames = xPageStyles->getElementNames();
425 9 : m_sFirstPageStyleName = lcl_FindUnusedPageStyleName(aPageStyleNames);
426 18 : m_aFirstPageStyle = uno::Reference< beans::XPropertySet > (
427 9 : xTextFactory->createInstance("com.sun.star.style.PageStyle"),
428 9 : uno::UNO_QUERY);
429 9 : if (xPageStyles.is())
430 9 : xPageStyles->insertByName( m_sFirstPageStyleName, uno::makeAny(m_aFirstPageStyle) );
431 : }
432 1476 : else if( !m_aFirstPageStyle.is() && xPageStyles.is() )
433 : {
434 1142 : xPageStyles->getByName(m_sFirstPageStyleName) >>= m_aFirstPageStyle;
435 : }
436 1485 : xRet = m_aFirstPageStyle;
437 : }
438 : else
439 : {
440 3381 : if( m_sFollowPageStyleName.isEmpty() && xPageStyles.is() )
441 : {
442 128 : uno::Sequence< OUString > aPageStyleNames = xPageStyles->getElementNames();
443 128 : m_sFollowPageStyleName = lcl_FindUnusedPageStyleName(aPageStyleNames);
444 256 : m_aFollowPageStyle = uno::Reference< beans::XPropertySet > (
445 128 : xTextFactory->createInstance("com.sun.star.style.PageStyle"),
446 128 : uno::UNO_QUERY);
447 128 : xPageStyles->insertByName( m_sFollowPageStyleName, uno::makeAny(m_aFollowPageStyle) );
448 : }
449 3253 : else if(!m_aFollowPageStyle.is() && xPageStyles.is() )
450 : {
451 1148 : xPageStyles->getByName(m_sFollowPageStyleName) >>= m_aFollowPageStyle;
452 : }
453 3381 : xRet = m_aFollowPageStyle;
454 : }
455 :
456 : }
457 0 : catch( const uno::Exception& )
458 : {
459 : }
460 :
461 4866 : return xRet;
462 : }
463 :
464 :
465 60 : void SectionPropertyMap::SetBorder( BorderPosition ePos, sal_Int32 nLineDistance, const table::BorderLine2& rBorderLine, bool bShadow )
466 : {
467 60 : delete m_pBorderLines[ePos];
468 60 : m_pBorderLines[ePos] = new table::BorderLine2( rBorderLine );
469 60 : m_nBorderDistances[ePos] = nLineDistance;
470 60 : m_bBorderShadows[ePos] = bShadow;
471 60 : }
472 :
473 :
474 1272 : void SectionPropertyMap::ApplyBorderToPageStyles(
475 : const uno::Reference< container::XNameContainer >& xPageStyles,
476 : const uno::Reference < lang::XMultiServiceFactory >& xTextFactory,
477 : sal_Int32 nValue )
478 : {
479 : /*
480 : page border applies to:
481 : nIntValue & 0x07 ->
482 : 0 all pages in this section
483 : 1 first page in this section
484 : 2 all pages in this section but first
485 : 3 whole document (all sections)
486 : nIntValue & 0x18 -> page border depth 0 - in front 1- in back
487 : nIntValue & 0xe0 ->
488 : page border offset from:
489 : 0 offset from text
490 : 1 offset from edge of page
491 : */
492 1272 : uno::Reference< beans::XPropertySet > xFirst;
493 2544 : uno::Reference< beans::XPropertySet > xSecond;
494 1272 : sal_Int32 nOffsetFrom = (nValue & 0x00E0) >> 5;
495 : //todo: negative spacing (from ww8par6.cxx)
496 1272 : switch( nValue & 0x07)
497 : {
498 : case 0: /*all styles*/
499 1272 : if ( !m_sFollowPageStyleName.isEmpty() )
500 1272 : xFirst = GetPageStyle( xPageStyles, xTextFactory, false );
501 1272 : if ( !m_sFirstPageStyleName.isEmpty() )
502 1161 : xSecond = GetPageStyle( xPageStyles, xTextFactory, true );
503 1272 : break;
504 : case 1: /*first page*/
505 0 : if ( !m_sFirstPageStyleName.isEmpty() )
506 0 : xFirst = GetPageStyle( xPageStyles, xTextFactory, true );
507 0 : break;
508 : case 2: /*left and right*/
509 0 : if ( !m_sFollowPageStyleName.isEmpty() )
510 0 : xFirst = GetPageStyle( xPageStyles, xTextFactory, false );
511 0 : break;
512 : case 3: //whole document?
513 : //todo: how to apply a border to the whole document - find all sections or access all page styles?
514 : default:
515 1272 : return;
516 : }
517 : //has to be sorted like enum BorderPosition: l-r-t-b
518 : static const PropertyIds aBorderIds[4] =
519 : {
520 : PROP_LEFT_BORDER,
521 : PROP_RIGHT_BORDER,
522 : PROP_TOP_BORDER,
523 : PROP_BOTTOM_BORDER
524 : };
525 : static const PropertyIds aBorderDistanceIds[4] =
526 : {
527 : PROP_LEFT_BORDER_DISTANCE,
528 : PROP_RIGHT_BORDER_DISTANCE,
529 : PROP_TOP_BORDER_DISTANCE,
530 : PROP_BOTTOM_BORDER_DISTANCE
531 : };
532 : static const PropertyIds aMarginIds[4] =
533 : {
534 : PROP_LEFT_MARGIN,
535 : PROP_RIGHT_MARGIN,
536 : PROP_TOP_MARGIN,
537 : PROP_BOTTOM_MARGIN
538 : };
539 :
540 1272 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
541 6360 : for( sal_Int32 nBorder = 0; nBorder < 4; ++nBorder)
542 : {
543 5088 : if( m_pBorderLines[nBorder] )
544 : {
545 60 : const OUString sBorderName = rPropNameSupplier.GetName( aBorderIds[nBorder] );
546 60 : if (xFirst.is())
547 60 : xFirst->setPropertyValue( sBorderName, uno::makeAny( *m_pBorderLines[nBorder] ));
548 60 : if(xSecond.is())
549 60 : xSecond->setPropertyValue( sBorderName, uno::makeAny( *m_pBorderLines[nBorder] ));
550 : }
551 5088 : if( m_nBorderDistances[nBorder] >= 0 )
552 : {
553 60 : sal_uInt32 nLineWidth = 0;
554 60 : if (m_pBorderLines[nBorder])
555 60 : nLineWidth = m_pBorderLines[nBorder]->LineWidth;
556 60 : SetBorderDistance( xFirst, aMarginIds[nBorder], aBorderDistanceIds[nBorder],
557 120 : m_nBorderDistances[nBorder], nOffsetFrom, nLineWidth );
558 60 : if(xSecond.is())
559 60 : SetBorderDistance( xSecond, aMarginIds[nBorder], aBorderDistanceIds[nBorder],
560 120 : m_nBorderDistances[nBorder], nOffsetFrom, nLineWidth );
561 : }
562 : }
563 :
564 1272 : if (m_bBorderShadows[BORDER_RIGHT])
565 : {
566 7 : table::ShadowFormat aFormat = getShadowFromBorder(*m_pBorderLines[BORDER_RIGHT]);
567 7 : if (xFirst.is())
568 7 : xFirst->setPropertyValue(rPropNameSupplier.GetName(PROP_SHADOW_FORMAT), uno::makeAny(aFormat));
569 7 : if (xSecond.is())
570 7 : xSecond->setPropertyValue(rPropNameSupplier.GetName(PROP_SHADOW_FORMAT), uno::makeAny(aFormat));
571 1272 : }
572 : }
573 :
574 20 : table::ShadowFormat PropertyMap::getShadowFromBorder(table::BorderLine2 aBorder)
575 : {
576 : // In Word UI, shadow is a boolean property, in OOXML, it's a boolean
577 : // property of each 4 border type, finally in Writer the border is a
578 : // property of the page style, with shadow location, distance and
579 : // color. See SwWW8ImplReader::SetShadow().
580 20 : table::ShadowFormat aFormat;
581 20 : aFormat.Color = COL_BLACK;
582 20 : aFormat.Location = table::ShadowLocation_BOTTOM_RIGHT;
583 20 : aFormat.ShadowWidth = aBorder.LineWidth;
584 20 : return aFormat;
585 : }
586 :
587 120 : void SectionPropertyMap::SetBorderDistance( uno::Reference< beans::XPropertySet > xStyle,
588 : PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, sal_Int32 nOffsetFrom, sal_uInt32 nLineWidth )
589 : {
590 120 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
591 :
592 120 : sal_Int32 nDist = nDistance;
593 120 : if( nOffsetFrom == 1 )
594 : {
595 120 : const OUString sMarginName = rPropNameSupplier.GetName( eMarginId );
596 240 : uno::Any aMargin = xStyle->getPropertyValue( sMarginName );
597 120 : sal_Int32 nMargin = 0;
598 120 : aMargin >>= nMargin;
599 :
600 : // Change the margins with the ( border distance - line width )
601 120 : xStyle->setPropertyValue( sMarginName, uno::makeAny( nDistance - nLineWidth ) );
602 :
603 : // Set the distance to ( Margin - distance )
604 240 : nDist = nMargin - nDistance;
605 : }
606 120 : const OUString sBorderDistanceName = rPropNameSupplier.GetName( eDistId );
607 120 : if (xStyle.is())
608 120 : xStyle->setPropertyValue( sBorderDistanceName, uno::makeAny( nDist ));
609 120 : }
610 :
611 :
612 :
613 22 : uno::Reference< text::XTextColumns > SectionPropertyMap::ApplyColumnProperties(
614 : uno::Reference< beans::XPropertySet > xColumnContainer )
615 : {
616 22 : uno::Reference< text::XTextColumns > xColumns;
617 : try
618 : {
619 22 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
620 22 : const OUString sTextColumns = rPropNameSupplier.GetName( PROP_TEXT_COLUMNS );
621 22 : if (xColumnContainer.is())
622 22 : xColumnContainer->getPropertyValue(sTextColumns) >>= xColumns;
623 44 : uno::Reference< beans::XPropertySet > xColumnPropSet( xColumns, uno::UNO_QUERY_THROW );
624 57 : if( !m_bEvenlySpaced &&
625 32 : (sal_Int32(m_aColWidth.size()) == (m_nColumnCount + 1 )) &&
626 5 : ((sal_Int32(m_aColDistance.size()) == m_nColumnCount) || (sal_Int32(m_aColDistance.size()) == m_nColumnCount + 1)) )
627 : {
628 : //the column width in word is an absolute value, in OOo it's relative
629 : //the distances are both absolute
630 5 : sal_Int32 nColSum = 0;
631 15 : for( sal_Int32 nCol = 0; nCol <= m_nColumnCount; ++nCol)
632 : {
633 10 : nColSum += m_aColWidth[nCol];
634 10 : if(nCol)
635 5 : nColSum += m_aColDistance[nCol -1];
636 : }
637 :
638 5 : sal_Int32 nRefValue = xColumns->getReferenceValue();
639 5 : double fRel = double( nRefValue ) / double( nColSum );
640 5 : uno::Sequence< text::TextColumn > aColumns( m_nColumnCount + 1 );
641 5 : text::TextColumn* pColumn = aColumns.getArray();
642 :
643 5 : nColSum = 0;
644 15 : for( sal_Int32 nCol = 0; nCol <= m_nColumnCount; ++nCol)
645 : {
646 10 : pColumn[nCol].LeftMargin = nCol ? m_aColDistance[nCol - 1 ] / 2 : 0;
647 10 : pColumn[nCol].RightMargin = nCol == m_nColumnCount ? 0 : m_aColDistance[nCol] / 2;
648 10 : pColumn[nCol].Width = sal_Int32((double( m_aColWidth[nCol] + pColumn[nCol].RightMargin + pColumn[nCol].LeftMargin ) + 0.5 ) * fRel );
649 10 : nColSum += pColumn[nCol].Width;
650 : }
651 5 : if( nColSum != nRefValue )
652 5 : pColumn[m_nColumnCount].Width -= ( nColSum - nRefValue );
653 5 : xColumns->setColumns( aColumns );
654 : }
655 : else
656 : {
657 17 : xColumns->setColumnCount( m_nColumnCount + 1 );
658 17 : xColumnPropSet->setPropertyValue( rPropNameSupplier.GetName( PROP_AUTOMATIC_DISTANCE ), uno::makeAny( m_nColumnDistance ));
659 : }
660 :
661 22 : if(m_bSeparatorLineIsOn)
662 1 : xColumnPropSet->setPropertyValue(
663 : rPropNameSupplier.GetName( PROP_SEPARATOR_LINE_IS_ON ),
664 1 : uno::makeAny( m_bSeparatorLineIsOn ));
665 44 : xColumnContainer->setPropertyValue( sTextColumns, uno::makeAny( xColumns ) );
666 : }
667 0 : catch( const uno::Exception& )
668 : {
669 : OSL_FAIL( "Exception in SectionPropertyMap::ApplyColumnProperties");
670 : }
671 22 : return xColumns;
672 : }
673 :
674 :
675 :
676 1400 : bool SectionPropertyMap::HasHeader(bool bFirstPage) const
677 : {
678 1400 : bool bRet = false;
679 1400 : if( (bFirstPage && m_aFirstPageStyle.is()) ||( !bFirstPage && m_aFollowPageStyle.is()) )
680 : {
681 1308 : if( bFirstPage )
682 43 : m_aFirstPageStyle->getPropertyValue(
683 43 : PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_HEADER_IS_ON) ) >>= bRet;
684 : else
685 1265 : m_aFollowPageStyle->getPropertyValue(
686 1265 : PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_HEADER_IS_ON) ) >>= bRet;
687 : }
688 1400 : return bRet;
689 : }
690 :
691 :
692 1400 : bool SectionPropertyMap::HasFooter(bool bFirstPage) const
693 : {
694 1400 : bool bRet = false;
695 1400 : if( (bFirstPage && m_aFirstPageStyle.is()) ||( !bFirstPage && m_aFollowPageStyle.is()) )
696 : {
697 1308 : if( bFirstPage )
698 43 : m_aFirstPageStyle->getPropertyValue(
699 43 : PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_FOOTER_IS_ON) ) >>= bRet;
700 : else
701 1265 : m_aFollowPageStyle->getPropertyValue(
702 1265 : PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_FOOTER_IS_ON) ) >>= bRet;
703 : }
704 1400 : return bRet;
705 : }
706 :
707 :
708 : #define MIN_HEAD_FOOT_HEIGHT 100 //minimum header/footer height
709 :
710 1400 : void SectionPropertyMap::CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Impl& rDM_Impl )
711 : {
712 : SAL_INFO("writerfilter", "START>>> SectionPropertyMap::CopyLastHeaderFooter()");
713 1400 : SectionPropertyMap* pLastContext = rDM_Impl.GetLastSectionContext( );
714 1400 : if ( pLastContext )
715 : {
716 : uno::Reference< beans::XPropertySet > xPrevStyle = pLastContext->GetPageStyle(
717 : rDM_Impl.GetPageStyles(),
718 : rDM_Impl.GetTextFactory(),
719 127 : bFirstPage );
720 : uno::Reference< beans::XPropertySet > xStyle = GetPageStyle(
721 : rDM_Impl.GetPageStyles(),
722 : rDM_Impl.GetTextFactory(),
723 254 : bFirstPage );
724 :
725 127 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
726 :
727 : try {
728 : // Loop over the Header and Footer properties to copy them
729 : static const PropertyIds aProperties[] =
730 : {
731 : PROP_HEADER_TEXT,
732 : PROP_FOOTER_TEXT,
733 : };
734 :
735 127 : bool bHasPrevHeader = false;
736 127 : bool bHasHeader = false;
737 :
738 127 : OUString sHeaderIsOn = rPropNameSupplier.GetName( PROP_HEADER_IS_ON );
739 127 : if (xPrevStyle.is())
740 127 : xPrevStyle->getPropertyValue( sHeaderIsOn ) >>= bHasPrevHeader;
741 127 : if (xStyle.is())
742 127 : xStyle->getPropertyValue( sHeaderIsOn ) >>= bHasHeader;
743 127 : bool bCopyHeader = bHasPrevHeader && !bHasHeader;
744 :
745 127 : if ( bCopyHeader )
746 24 : xStyle->setPropertyValue( sHeaderIsOn, uno::makeAny( sal_True ) );
747 :
748 127 : bool bHasPrevFooter = false;
749 127 : bool bHasFooter = false;
750 :
751 254 : OUString sFooterIsOn = rPropNameSupplier.GetName( PROP_FOOTER_IS_ON );
752 127 : if (xPrevStyle.is())
753 127 : xPrevStyle->getPropertyValue( sFooterIsOn ) >>= bHasPrevFooter;
754 127 : if (xStyle.is())
755 127 : xStyle->getPropertyValue( sFooterIsOn ) >>= bHasFooter;
756 127 : bool bCopyFooter = bHasPrevFooter && !bHasFooter;
757 :
758 127 : if ( bCopyFooter && xStyle.is() )
759 28 : xStyle->setPropertyValue( sFooterIsOn, uno::makeAny( sal_True ) );
760 :
761 : // Copying the text properties
762 381 : for ( int i = 0, nNbProps = 2; i < nNbProps; i++ )
763 : {
764 254 : bool bIsHeader = ( i < nNbProps / 2 );
765 254 : PropertyIds aPropId = aProperties[i];
766 254 : OUString sName = rPropNameSupplier.GetName( aPropId );
767 :
768 254 : if ( ( bIsHeader && bCopyHeader ) || ( !bIsHeader && bCopyFooter ) )
769 : {
770 : SAL_INFO("writerfilter", "Copying " << sName);
771 : // TODO has to be copied
772 52 : uno::Reference< text::XTextCopy > xTxt;
773 52 : if (xStyle.is())
774 52 : xTxt.set(xStyle->getPropertyValue( sName ), uno::UNO_QUERY_THROW );
775 :
776 104 : uno::Reference< text::XTextCopy > xPrevTxt;
777 52 : if (xPrevStyle.is())
778 52 : xPrevTxt.set(xPrevStyle->getPropertyValue( sName ), uno::UNO_QUERY_THROW );
779 :
780 104 : xTxt->copyText( xPrevTxt );
781 : }
782 381 : }
783 : }
784 0 : catch ( const uno::Exception& e )
785 : {
786 : SAL_INFO("writerfilter", "An exception occurred in SectionPropertyMap::CopyLastHeaderFooter( ) - " << e.Message);
787 127 : }
788 : }
789 : SAL_INFO("writerfilter", "END>>> SectionPropertyMap::CopyLastHeaderFooter()");
790 1400 : }
791 :
792 1400 : void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
793 : {
794 1400 : sal_Int32 nTopMargin = m_nTopMargin;
795 1400 : sal_Int32 nHeaderTop = m_nHeaderTop;
796 1400 : if(HasHeader(bFirstPage))
797 : {
798 251 : m_nTopMargin = m_nHeaderTop;
799 251 : if( nTopMargin > 0 && nTopMargin > m_nHeaderTop )
800 232 : m_nHeaderTop = nTopMargin - m_nHeaderTop;
801 : else
802 19 : m_nHeaderTop = 0;
803 :
804 : //minimum header height 1mm
805 251 : if( m_nHeaderTop < MIN_HEAD_FOOT_HEIGHT )
806 21 : m_nHeaderTop = MIN_HEAD_FOOT_HEIGHT;
807 : }
808 :
809 :
810 1400 : if( nTopMargin >= 0 ) //fixed height header -> see WW8Par6.hxx
811 : {
812 1400 : operator[](PROP_HEADER_IS_DYNAMIC_HEIGHT) = uno::makeAny( true );
813 1400 : operator[](PROP_HEADER_DYNAMIC_SPACING) = uno::makeAny( true );
814 1400 : operator[](PROP_HEADER_BODY_DISTANCE) = uno::makeAny( m_nHeaderTop - MIN_HEAD_FOOT_HEIGHT );// ULSpace.Top()
815 1400 : operator[](PROP_HEADER_HEIGHT) = uno::makeAny( m_nHeaderTop );
816 :
817 : }
818 : else
819 : {
820 : //todo: old filter fakes a frame into the header/footer to support overlapping
821 : //current setting is completely wrong!
822 0 : operator[](PROP_HEADER_HEIGHT) = uno::makeAny( m_nHeaderTop );
823 0 : operator[](PROP_HEADER_BODY_DISTANCE) = uno::makeAny( nTopMargin - m_nHeaderTop );
824 0 : operator[](PROP_HEADER_IS_DYNAMIC_HEIGHT) = uno::makeAny( false );
825 0 : operator[](PROP_HEADER_DYNAMIC_SPACING) = uno::makeAny( false );
826 : }
827 :
828 1400 : sal_Int32 nBottomMargin = m_nBottomMargin;
829 1400 : sal_Int32 nHeaderBottom = m_nHeaderBottom;
830 1400 : if( HasFooter( bFirstPage ) )
831 : {
832 269 : m_nBottomMargin = m_nHeaderBottom;
833 269 : if( nBottomMargin > 0 && nBottomMargin > m_nHeaderBottom )
834 235 : m_nHeaderBottom = nBottomMargin - m_nHeaderBottom;
835 : else
836 34 : m_nHeaderBottom = 0;
837 269 : if( m_nHeaderBottom < MIN_HEAD_FOOT_HEIGHT )
838 34 : m_nHeaderBottom = MIN_HEAD_FOOT_HEIGHT;
839 : }
840 :
841 1400 : if( nBottomMargin >= 0 ) //fixed height footer -> see WW8Par6.hxx
842 : {
843 1400 : operator[](PROP_FOOTER_IS_DYNAMIC_HEIGHT) = uno::makeAny( true );
844 1400 : operator[](PROP_FOOTER_DYNAMIC_SPACING) = uno::makeAny( true );
845 1400 : operator[](PROP_FOOTER_BODY_DISTANCE) = uno::makeAny( m_nHeaderBottom - MIN_HEAD_FOOT_HEIGHT);
846 1400 : operator[](PROP_FOOTER_HEIGHT) = uno::makeAny( m_nHeaderBottom );
847 : }
848 : else
849 : {
850 : //todo: old filter fakes a frame into the header/footer to support overlapping
851 : //current setting is completely wrong!
852 0 : operator[](PROP_FOOTER_IS_DYNAMIC_HEIGHT) = uno::makeAny( false );
853 0 : operator[](PROP_FOOTER_DYNAMIC_SPACING) = uno::makeAny( false );
854 0 : operator[](PROP_FOOTER_HEIGHT) = uno::makeAny( nBottomMargin - m_nHeaderBottom );
855 0 : operator[](PROP_FOOTER_BODY_DISTANCE) = uno::makeAny( m_nHeaderBottom );
856 : }
857 :
858 : //now set the top/bottom margin for the follow page style
859 1400 : operator[](PROP_TOP_MARGIN) = uno::makeAny( m_nTopMargin );
860 1400 : operator[](PROP_BOTTOM_MARGIN) = uno::makeAny( m_nBottomMargin );
861 :
862 : // Restore original top margin, so we don't end up with a smaller margin in case we have to produce two page styles from one Word section.
863 1400 : m_nTopMargin = nTopMargin;
864 1400 : m_nHeaderTop = nHeaderTop;
865 1400 : m_nHeaderBottom = nHeaderBottom;
866 1400 : }
867 :
868 1330 : uno::Reference<beans::XPropertySet> lcl_GetRangeProperties(bool bIsFirstSection, DomainMapper_Impl& rDM_Impl, uno::Reference<text::XTextRange> xStartingRange)
869 : {
870 1330 : uno::Reference< beans::XPropertySet > xRangeProperties;
871 1330 : if (bIsFirstSection && rDM_Impl.GetBodyText().is())
872 : {
873 1170 : uno::Reference<container::XEnumerationAccess> xEnumAccess(rDM_Impl.GetBodyText(), uno::UNO_QUERY_THROW);
874 2340 : uno::Reference<container::XEnumeration> xEnum = xEnumAccess->createEnumeration();
875 2340 : xRangeProperties = uno::Reference<beans::XPropertySet>(xEnum->nextElement(), uno::UNO_QUERY_THROW);
876 : }
877 160 : else if (xStartingRange.is())
878 149 : xRangeProperties = uno::Reference<beans::XPropertySet>(xStartingRange, uno::UNO_QUERY_THROW);
879 1330 : return xRangeProperties;
880 : }
881 :
882 1302 : void SectionPropertyMap::HandleMarginsHeaderFooter(DomainMapper_Impl& rDM_Impl)
883 : {
884 1302 : if( m_nDzaGutter > 0 )
885 : {
886 : //todo: iGutterPos from DocProperties are missing
887 0 : if( m_bGutterRTL )
888 0 : m_nRightMargin += m_nDzaGutter;
889 : else
890 0 : m_nLeftMargin += m_nDzaGutter;
891 : }
892 1302 : operator[](PROP_LEFT_MARGIN) = uno::makeAny( m_nLeftMargin );
893 1302 : operator[](PROP_RIGHT_MARGIN) = uno::makeAny( m_nRightMargin );
894 :
895 1302 : if (rDM_Impl.m_oBackgroundColor)
896 15 : operator[](PROP_BACK_COLOR) = uno::makeAny(*rDM_Impl.m_oBackgroundColor);
897 1302 : if (!rDM_Impl.m_bHasFtnSep)
898 : // Set footnote line width to zero, document has no footnote separator.
899 1226 : operator[](PROP_FOOTNOTE_LINE_RELATIVE_WIDTH) = uno::makeAny(sal_Int32(0));
900 :
901 : /*** if headers/footers are available then the top/bottom margins of the
902 : header/footer are copied to the top/bottom margin of the page
903 : */
904 1302 : CopyLastHeaderFooter( false, rDM_Impl );
905 1302 : PrepareHeaderFooterProperties( false );
906 1302 : }
907 :
908 1331 : void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
909 : {
910 : // Text area width is known at the end of a section: decide if tables should be converted or not.
911 1331 : std::vector<FloatingTableInfo>& rPendingFloatingTables = rDM_Impl.m_aPendingFloatingTables;
912 1331 : sal_Int32 nTextAreaWidth = GetPageWidth() - GetLeftMargin() - GetRightMargin();
913 1331 : uno::Reference<text::XTextAppendAndConvert> xBodyText( rDM_Impl.GetBodyText(), uno::UNO_QUERY );
914 1360 : for (size_t i = 0; i < rPendingFloatingTables.size(); ++i)
915 : {
916 29 : FloatingTableInfo& rInfo = rPendingFloatingTables[i];
917 : // If the table is wider than the text area, then don't create a fly
918 : // for the table: no wrapping will be performed anyway, but multi-page
919 : // tables will be broken.
920 : // If the position is relative to the edge of the page, then we always
921 : // create the fly.
922 55 : if ( ( rInfo.getPropertyValue("HoriOrientRelation") == text::RelOrientation::PAGE_FRAME ) ||
923 26 : ( rInfo.m_nTableWidth < nTextAreaWidth ) )
924 25 : xBodyText->convertToTextFrame(rInfo.m_xStart, rInfo.m_xEnd, rInfo.m_aFrameProperties);
925 : }
926 1331 : rPendingFloatingTables.clear();
927 :
928 1331 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
929 1331 : if( m_nLnnMod )
930 : {
931 7 : bool bFirst = rDM_Impl.IsLineNumberingSet();
932 7 : rDM_Impl.SetLineNumbering( m_nLnnMod, m_nLnc, m_ndxaLnn );
933 7 : if( m_nLnnMin > 0 || (bFirst && m_nLnc == 1))
934 : {
935 : //set the starting value at the beginning of the section
936 : try
937 : {
938 3 : uno::Reference< beans::XPropertySet > xRangeProperties;
939 3 : if( m_xStartingRange.is() )
940 : {
941 3 : xRangeProperties = uno::Reference< beans::XPropertySet >( m_xStartingRange, uno::UNO_QUERY_THROW );
942 : }
943 : else
944 : {
945 : //set the start value at the beginning of the document
946 0 : xRangeProperties = uno::Reference< beans::XPropertySet >( rDM_Impl.GetTextDocument()->getText()->getStart(), uno::UNO_QUERY_THROW );
947 : }
948 3 : xRangeProperties->setPropertyValue( rPropNameSupplier.GetName( PROP_PARA_LINE_NUMBER_START_VALUE ), uno::makeAny( m_nLnnMin ));
949 : }
950 0 : catch( const uno::Exception& )
951 : {
952 : OSL_FAIL( "Exception in SectionPropertyMap::CloseSectionGroup");
953 : }
954 : }
955 : }
956 :
957 : //depending on the break type no page styles should be created
958 : // If the section type is missing, but we have columns, then this should be
959 : // handled as a continuous section break.
960 1331 : if(m_nBreakType == 0 || (m_nBreakType == -1 && m_nColumnCount > 0))
961 : {
962 : //todo: insert a section or access the already inserted section
963 : uno::Reference< beans::XPropertySet > xSection =
964 58 : rDM_Impl.appendTextSectionAfter( m_xStartingRange );
965 58 : if( m_nColumnCount > 0 && xSection.is())
966 19 : ApplyColumnProperties( xSection );
967 116 : uno::Reference<beans::XPropertySet> xRangeProperties(lcl_GetRangeProperties(m_bIsFirstSection, rDM_Impl, m_xStartingRange));
968 58 : if (xRangeProperties.is())
969 : {
970 58 : OUString aName = m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName;
971 58 : if (!aName.isEmpty())
972 : {
973 : try
974 : {
975 30 : xRangeProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_PAGE_DESC_NAME), uno::makeAny(aName));
976 30 : uno::Reference<beans::XPropertySet> xPageStyle (rDM_Impl.GetPageStyles()->getByName(aName), uno::UNO_QUERY_THROW);
977 30 : HandleMarginsHeaderFooter(rDM_Impl);
978 30 : if (rDM_Impl.IsNewDoc())
979 30 : _ApplyProperties(xPageStyle);
980 : }
981 0 : catch( const uno::Exception& )
982 : {
983 : SAL_WARN("writerfilter", "failed to set PageDescName!");
984 : }
985 58 : }
986 58 : }
987 : }
988 : // If the section is of type "New column" (0x01), then simply insert a column break.
989 : // But only if there actually are columns on the page, otherwise a column break
990 : // seems to be handled like a page break by MSO.
991 1273 : else if(m_nBreakType == 1 && m_nColumnCount > 0 )
992 : {
993 1 : uno::Reference< beans::XPropertySet > xRangeProperties;
994 1 : if( m_xStartingRange.is() )
995 : {
996 1 : xRangeProperties = uno::Reference< beans::XPropertySet >( m_xStartingRange, uno::UNO_QUERY_THROW );
997 : }
998 : else
999 : {
1000 : //set the start value at the beginning of the document
1001 0 : xRangeProperties = uno::Reference< beans::XPropertySet >( rDM_Impl.GetTextDocument()->getText()->getStart(), uno::UNO_QUERY_THROW );
1002 : }
1003 1 : xRangeProperties->setPropertyValue( rPropNameSupplier.GetName( PROP_BREAK_TYPE ),
1004 1 : uno::makeAny( com::sun::star::style::BreakType_COLUMN_BEFORE));
1005 : }
1006 : else
1007 : {
1008 : //get the properties and create appropriate page styles
1009 1272 : uno::Reference< beans::XPropertySet > xFollowPageStyle = GetPageStyle( rDM_Impl.GetPageStyles(), rDM_Impl.GetTextFactory(), false );
1010 :
1011 1272 : HandleMarginsHeaderFooter(rDM_Impl);
1012 :
1013 2544 : const OUString sTrayIndex = rPropNameSupplier.GetName( PROP_PRINTER_PAPER_TRAY_INDEX );
1014 1272 : if( m_nPaperBin >= 0 )
1015 0 : xFollowPageStyle->setPropertyValue( sTrayIndex, uno::makeAny( m_nPaperBin ) );
1016 1272 : if ( rDM_Impl.GetSettingsTable()->GetMirrorMarginSettings() )
1017 : {
1018 5 : Insert(PROP_PAGE_STYLE_LAYOUT, uno::makeAny(style::PageStyleLayout_MIRRORED));
1019 : }
1020 2544 : uno::Reference< text::XTextColumns > xColumns;
1021 1272 : if( m_nColumnCount > 0 )
1022 3 : xColumns = ApplyColumnProperties( xFollowPageStyle );
1023 :
1024 : //prepare text grid properties
1025 1272 : sal_Int32 nHeight = 1;
1026 1272 : PropertyMap::iterator aElement = find(PROP_HEIGHT);
1027 1272 : if( aElement != end())
1028 1272 : aElement->second.getValue() >>= nHeight;
1029 :
1030 1272 : sal_Int32 nWidth = 1;
1031 1272 : aElement = find(PROP_WIDTH);
1032 1272 : if( aElement != end())
1033 1272 : aElement->second.getValue() >>= nWidth;
1034 :
1035 1272 : text::WritingMode eWritingMode = text::WritingMode_LR_TB;
1036 1272 : aElement = find(PROP_WRITING_MODE);
1037 1272 : if( aElement != end())
1038 350 : aElement->second.getValue() >>= eWritingMode;
1039 :
1040 1272 : sal_Int32 nTextAreaHeight = eWritingMode == text::WritingMode_LR_TB ?
1041 1272 : nHeight - m_nTopMargin - m_nBottomMargin :
1042 2544 : nWidth - m_nLeftMargin - m_nRightMargin;
1043 :
1044 1272 : sal_Int32 nGridLinePitch = m_nGridLinePitch;
1045 : //sep.dyaLinePitch
1046 1272 : if (nGridLinePitch < 1 || nGridLinePitch > 31680)
1047 : {
1048 : SAL_WARN("writerfilter", "sep.dyaLinePitch outside legal range: " << nGridLinePitch);
1049 0 : nGridLinePitch = 1;
1050 : }
1051 :
1052 2544 : operator[](PROP_GRID_LINES) =
1053 2544 : uno::makeAny( static_cast<sal_Int16>(nTextAreaHeight/nGridLinePitch));
1054 :
1055 1272 : sal_Int32 nCharWidth = 423; //240 twip/ 12 pt
1056 : //todo: is '0' the right index here?
1057 2544 : const StyleSheetEntryPtr pEntry = rDM_Impl.GetStyleSheetTable()->FindStyleSheetByISTD(OUString::number(0, 16));
1058 1272 : if( pEntry.get( ) )
1059 : {
1060 6 : PropertyMap::iterator aElement_ = pEntry->pProperties->find(PROP_CHAR_HEIGHT_ASIAN);
1061 6 : if( aElement_ != pEntry->pProperties->end())
1062 : {
1063 4 : double fHeight = 0;
1064 4 : if( aElement_->second.getValue() >>= fHeight )
1065 4 : nCharWidth = ConversionHelper::convertTwipToMM100( (long)( fHeight * 20.0 + 0.5 ));
1066 : }
1067 : }
1068 :
1069 : //dxtCharSpace
1070 1272 : if(m_nDxtCharSpace)
1071 : {
1072 36 : sal_Int32 nCharSpace = m_nDxtCharSpace;
1073 : //main lives in top 20 bits, and is signed.
1074 36 : sal_Int32 nMain = (nCharSpace & 0xFFFFF000);
1075 36 : nMain /= 0x1000;
1076 36 : nCharWidth += ConversionHelper::convertTwipToMM100( nMain * 20 );
1077 :
1078 36 : sal_Int32 nFraction = (nCharSpace & 0x00000FFF);
1079 36 : nFraction = (nFraction * 20)/0xFFF;
1080 36 : nCharWidth += ConversionHelper::convertTwipToMM100( nFraction );
1081 : }
1082 1272 : operator[](PROP_GRID_BASE_HEIGHT) = uno::makeAny( nCharWidth );
1083 1272 : sal_Int32 nRubyHeight = nGridLinePitch - nCharWidth;
1084 1272 : if(nRubyHeight < 0 )
1085 453 : nRubyHeight = 0;
1086 1272 : operator[](PROP_GRID_RUBY_HEIGHT) = uno::makeAny( nRubyHeight );
1087 :
1088 : // #i119558#, force to set document as standard page mode,
1089 : // refer to ww8 import process function "SwWW8ImplReader::SetDocumentGrid"
1090 : try
1091 : {
1092 1272 : uno::Reference< beans::XPropertySet > xDocProperties;
1093 1272 : xDocProperties = uno::Reference< beans::XPropertySet >( rDM_Impl.GetTextDocument(), uno::UNO_QUERY_THROW );
1094 1261 : sal_Bool bSquaredPageMode = sal_False;
1095 1261 : operator[](PROP_GRID_STANDARD_MODE) = uno::makeAny( !bSquaredPageMode );
1096 1261 : xDocProperties->setPropertyValue("DefaultPageMode", uno::makeAny( bSquaredPageMode ));
1097 : }
1098 11 : catch (const uno::Exception& rEx)
1099 : {
1100 : OSL_ENSURE( false, "Exception in SectionPropertyMap::CloseSectionGroup");
1101 : (void)rEx;
1102 : }
1103 :
1104 1272 : if (rDM_Impl.IsNewDoc())
1105 1265 : _ApplyProperties( xFollowPageStyle );
1106 :
1107 : //todo: creating a "First Page" style depends on HasTitlePage und _fFacingPage_
1108 1272 : if( m_bTitlePage )
1109 : {
1110 98 : CopyLastHeaderFooter( true, rDM_Impl );
1111 98 : PrepareHeaderFooterProperties( true );
1112 : uno::Reference< beans::XPropertySet > xFirstPageStyle = GetPageStyle(
1113 98 : rDM_Impl.GetPageStyles(), rDM_Impl.GetTextFactory(), true );
1114 98 : if (rDM_Impl.IsNewDoc())
1115 98 : _ApplyProperties( xFirstPageStyle );
1116 :
1117 98 : sal_Int32 nPaperBin = m_nFirstPaperBin >= 0 ? m_nFirstPaperBin : m_nPaperBin >= 0 ? m_nPaperBin : 0;
1118 98 : if( nPaperBin )
1119 0 : xFirstPageStyle->setPropertyValue( sTrayIndex, uno::makeAny( nPaperBin ) );
1120 98 : if( xColumns.is() )
1121 0 : xFirstPageStyle->setPropertyValue(
1122 0 : rPropNameSupplier.GetName( PROP_TEXT_COLUMNS ), uno::makeAny( xColumns ));
1123 :
1124 : // If the 'Different First Page' flag is turned on - do not ignore it
1125 : // If the 'Diffferent First Page' is non-checked, it must be checked - the flag should be imported (so it would look in LO like in Word)
1126 98 : xFirstPageStyle->setPropertyValue(rPropNameSupplier.GetName( PROP_FIRST_IS_SHARED ), uno::makeAny( false ));
1127 98 : xFollowPageStyle->setPropertyValue(rPropNameSupplier.GetName( PROP_FIRST_IS_SHARED ), uno::makeAny( false ));
1128 : }
1129 :
1130 1272 : ApplyBorderToPageStyles( rDM_Impl.GetPageStyles( ), rDM_Impl.GetTextFactory( ), m_nBorderParams );
1131 :
1132 : try
1133 : {
1134 : {
1135 : //now apply this break at the first paragraph of this section
1136 1272 : uno::Reference<beans::XPropertySet> xRangeProperties(lcl_GetRangeProperties(m_bIsFirstSection, rDM_Impl, m_xStartingRange));
1137 : /* break type
1138 : 0 - No break 1 - New Column 2 - New page 3 - Even page 4 - odd page */
1139 1272 : if ((m_bTitlePage && m_bIsFirstSection) || !m_bTitlePage)
1140 : {
1141 2521 : if (xRangeProperties.is() && rDM_Impl.IsNewDoc())
1142 1248 : xRangeProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_PAGE_DESC_NAME ),
1143 1259 : uno::makeAny( m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName ));
1144 : }
1145 : else
1146 : {
1147 : // In this miserable situation (second or later section on a title page), make sure that the header / footer is not lost.
1148 6 : uno::Reference< container::XNameAccess > xPageStyles(rDM_Impl.GetPageStyles(), uno::UNO_QUERY);
1149 6 : if (xPageStyles->hasByName(m_sFollowPageStyleName))
1150 : {
1151 6 : uno::Reference<beans::XPropertySet> xCurrent(xPageStyles->getByName(rPropNameSupplier.GetName(PROP_STANDARD)), uno::UNO_QUERY);
1152 12 : uno::Reference<beans::XPropertySet> xFollow(xPageStyles->getByName(m_sFollowPageStyleName), uno::UNO_QUERY);
1153 :
1154 6 : if (xFollow->getPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_IS_ON)).get<sal_Bool>())
1155 : {
1156 4 : xCurrent->setPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_IS_ON), uno::makeAny(sal_True));
1157 4 : uno::Reference<text::XTextRange> xCurrentRange(xCurrent->getPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_TEXT)), uno::UNO_QUERY_THROW);
1158 4 : xCurrentRange->setString("");
1159 8 : uno::Reference<text::XTextCopy> xCurrentTxt(xCurrentRange, uno::UNO_QUERY_THROW);
1160 8 : uno::Reference<text::XTextCopy> xFollowTxt(xFollow->getPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_TEXT)), uno::UNO_QUERY_THROW);
1161 8 : xCurrentTxt->copyText(xFollowTxt);
1162 : }
1163 6 : if (xFollow->getPropertyValue(rPropNameSupplier.GetName(PROP_FOOTER_IS_ON)).get<sal_Bool>())
1164 : {
1165 4 : xCurrent->setPropertyValue(rPropNameSupplier.GetName(PROP_FOOTER_IS_ON), uno::makeAny(sal_True));
1166 4 : uno::Reference<text::XTextRange> xCurrentRange(xCurrent->getPropertyValue(rPropNameSupplier.GetName(PROP_FOOTER_TEXT)), uno::UNO_QUERY_THROW);
1167 4 : xCurrentRange->setString("");
1168 8 : uno::Reference<text::XTextCopy> xCurrentTxt(xCurrentRange, uno::UNO_QUERY_THROW);
1169 8 : uno::Reference<text::XTextCopy> xFollowTxt(xFollow->getPropertyValue(rPropNameSupplier.GetName(PROP_FOOTER_TEXT)), uno::UNO_QUERY_THROW);
1170 8 : xCurrentTxt->copyText(xFollowTxt);
1171 6 : }
1172 6 : }
1173 : }
1174 : // handle page breaks with odd/even page numbering
1175 1261 : style::PageStyleLayout nPageStyleLayout(style::PageStyleLayout_ALL);
1176 1261 : if (m_nBreakType == 3)
1177 1 : nPageStyleLayout = style::PageStyleLayout_LEFT;
1178 1260 : else if (m_nBreakType == 4)
1179 1 : nPageStyleLayout = style::PageStyleLayout_RIGHT;
1180 1261 : if (nPageStyleLayout)
1181 2 : xFollowPageStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_PAGE_STYLE_LAYOUT), uno::makeAny(nPageStyleLayout));
1182 1261 : if(m_bPageNoRestart || m_nPageNumber >= 0)
1183 : {
1184 72 : sal_Int16 nPageNumber = m_nPageNumber >= 0 ? static_cast< sal_Int16 >(m_nPageNumber) : 1;
1185 72 : xRangeProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_PAGE_NUMBER_OFFSET ),
1186 72 : uno::makeAny( nPageNumber ));
1187 1272 : }
1188 : }
1189 : }
1190 11 : catch (const uno::Exception&)
1191 : {
1192 : OSL_FAIL( "Exception in SectionPropertyMap::CloseSectionGroup");
1193 1272 : }
1194 : }
1195 1331 : rDM_Impl.SetIsFirstParagraphInSection(true);
1196 1331 : }
1197 :
1198 :
1199 1393 : void SectionPropertyMap::_ApplyProperties( uno::Reference< beans::XPropertySet > xStyle )
1200 : {
1201 1393 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
1202 : uno::Reference<beans::XMultiPropertySet> const xMultiSet(xStyle,
1203 1393 : uno::UNO_QUERY);
1204 1393 : if (xMultiSet.is())
1205 : { // FIXME why is "this" a STL container???
1206 1382 : uno::Sequence<OUString> names(this->size());
1207 2764 : uno::Sequence<uno::Any> values(this->size());
1208 1382 : PropertyMap::iterator it = this->begin();
1209 34519 : for (size_t i = 0; it != this->end(); ++it, ++i)
1210 : {
1211 33137 : names[i] = rPropNameSupplier.GetName(it->first);
1212 33137 : values[i] = it->second.getValue();
1213 : }
1214 : try
1215 : {
1216 1382 : xMultiSet->setPropertyValues(names, values);
1217 : }
1218 0 : catch( const uno::Exception& )
1219 : {
1220 : OSL_FAIL( "Exception in <PageStyle>::setPropertyValue");
1221 : }
1222 4157 : return;
1223 : }
1224 11 : PropertyMap::iterator aMapIter = begin();
1225 267 : while( aMapIter != end())
1226 : {
1227 : try
1228 : {
1229 245 : if (xStyle.is())
1230 0 : xStyle->setPropertyValue( rPropNameSupplier.GetName( aMapIter->first ), aMapIter->second.getValue() );
1231 : }
1232 0 : catch( const uno::Exception& )
1233 : {
1234 : OSL_FAIL( "Exception in <PageStyle>::setPropertyValue");
1235 : }
1236 245 : ++aMapIter;
1237 11 : }
1238 : }
1239 0 : sal_Int32 lcl_AlignPaperBin( sal_Int32 nSet )
1240 : {
1241 : //default tray numbers are above 0xff
1242 0 : if( nSet > 0xff )
1243 0 : nSet = nSet >> 8;
1244 : //there are some special numbers which can't be handled easily
1245 : //1, 4, 15, manual tray, upper tray, auto select? see ww8atr.cxx
1246 : //todo: find out appropriate conversion
1247 0 : return nSet;
1248 : }
1249 :
1250 :
1251 0 : void SectionPropertyMap::SetPaperBin( sal_Int32 nSet )
1252 : {
1253 0 : m_nPaperBin = lcl_AlignPaperBin( nSet );
1254 0 : }
1255 :
1256 :
1257 0 : void SectionPropertyMap::SetFirstPaperBin( sal_Int32 nSet )
1258 : {
1259 0 : m_nFirstPaperBin = lcl_AlignPaperBin( nSet );
1260 0 : }
1261 :
1262 :
1263 1331 : sal_Int32 SectionPropertyMap::GetPageWidth()
1264 : {
1265 1331 : return operator[](PROP_WIDTH).getValue().get<sal_Int32>();
1266 : }
1267 :
1268 30243 : StyleSheetPropertyMap::StyleSheetPropertyMap() :
1269 : mnCT_Spacing_line( 0 ),
1270 : mnCT_Spacing_lineRule( 0 ),
1271 : mbCT_TrPrBase_tblHeader( false ),
1272 : mnCT_TrPrBase_jc( 0 ),
1273 : mnCT_TcPrBase_vAlign( 0 ),
1274 : mnCT_TblWidth_w( 0 ),
1275 : mnCT_TblWidth_type( 0 ),
1276 : mbCT_Spacing_lineSet( false ),
1277 : mbCT_Spacing_lineRuleSet( false ),
1278 : mbCT_TrPrBase_tblHeaderSet( false ),
1279 : mbCT_TrPrBase_jcSet( false ),
1280 : mbCT_TcPrBase_vAlignSet( false ),
1281 : mbCT_TblWidth_wSet( false ),
1282 : mbCT_TblWidth_typeSet( false ),
1283 : mnListId( -1 ),
1284 : mnListLevel( -1 ),
1285 : mnOutlineLevel( -1 ),
1286 30243 : mnNumId( -1 )
1287 : {
1288 30243 : }
1289 :
1290 :
1291 60486 : StyleSheetPropertyMap::~StyleSheetPropertyMap()
1292 : {
1293 60486 : }
1294 :
1295 :
1296 53064 : ParagraphProperties::ParagraphProperties() :
1297 : m_bFrameMode( false ),
1298 : m_nDropCap(NS_ooxml::LN_Value_wordprocessingml_ST_DropCap_none),
1299 : m_nLines(0),
1300 : m_w(-1),
1301 : m_h(-1),
1302 : m_nWrap(-1),
1303 : m_hAnchor(-1),
1304 : m_vAnchor(text::RelOrientation::FRAME),
1305 : m_x(-1),
1306 : m_bxValid( false ),
1307 : m_y(-1),
1308 : m_byValid( false ),
1309 : m_hSpace(-1),
1310 : m_vSpace(-1),
1311 : m_hRule(-1),
1312 : m_xAlign(-1),
1313 : m_yAlign(-1),
1314 : m_bAnchorLock(false),
1315 53064 : m_nDropCapLength(0)
1316 : {
1317 53064 : }
1318 :
1319 :
1320 36 : ParagraphProperties::ParagraphProperties(const ParagraphProperties& rCopy) :
1321 : m_bFrameMode ( rCopy.m_bFrameMode),
1322 : m_nDropCap ( rCopy.m_nDropCap),
1323 : m_nLines ( rCopy.m_nLines),
1324 : m_w ( rCopy.m_w),
1325 : m_h ( rCopy.m_h),
1326 : m_nWrap ( rCopy.m_nWrap),
1327 : m_hAnchor ( rCopy.m_hAnchor),
1328 : m_vAnchor ( rCopy.m_vAnchor),
1329 : m_x ( rCopy.m_x),
1330 : m_bxValid ( rCopy.m_bxValid),
1331 : m_y ( rCopy.m_y),
1332 : m_byValid ( rCopy.m_byValid),
1333 : m_hSpace ( rCopy.m_hSpace),
1334 : m_vSpace ( rCopy.m_vSpace),
1335 : m_hRule ( rCopy.m_hRule),
1336 : m_xAlign ( rCopy.m_xAlign),
1337 : m_yAlign ( rCopy.m_yAlign),
1338 : m_bAnchorLock( rCopy.m_bAnchorLock),
1339 : m_nDropCapLength( rCopy.m_nDropCapLength ),
1340 : m_sParaStyleName( rCopy.m_sParaStyleName),
1341 : m_xStartingRange( rCopy.m_xStartingRange ),
1342 36 : m_xEndingRange( rCopy.m_xEndingRange)
1343 : {
1344 36 : }
1345 :
1346 :
1347 53100 : ParagraphProperties::~ParagraphProperties()
1348 : {
1349 53100 : }
1350 :
1351 :
1352 50 : bool ParagraphProperties::operator==(const ParagraphProperties& rCompare)
1353 : {
1354 : return
1355 71 : m_bFrameMode == rCompare.m_bFrameMode &&
1356 42 : m_nDropCap == rCompare.m_nDropCap &&
1357 42 : m_nLines == rCompare.m_nLines &&
1358 40 : m_w == rCompare.m_w &&
1359 38 : m_h == rCompare.m_h &&
1360 38 : m_nWrap == rCompare.m_nWrap &&
1361 38 : m_hAnchor == rCompare.m_hAnchor &&
1362 38 : m_vAnchor == rCompare.m_vAnchor &&
1363 38 : m_x == rCompare.m_x &&
1364 38 : m_bxValid == rCompare.m_bxValid &&
1365 38 : m_y == rCompare.m_y &&
1366 38 : m_byValid == rCompare.m_byValid &&
1367 38 : m_hSpace == rCompare.m_hSpace &&
1368 38 : m_vSpace == rCompare.m_vSpace &&
1369 38 : m_hRule == rCompare.m_hRule &&
1370 38 : m_xAlign == rCompare.m_xAlign &&
1371 88 : m_yAlign == rCompare.m_yAlign &&
1372 69 : m_bAnchorLock== rCompare.m_bAnchorLock;
1373 : }
1374 :
1375 19738 : void ParagraphProperties::ResetFrameProperties()
1376 : {
1377 19738 : m_bFrameMode = false;
1378 19738 : m_nDropCap = NS_ooxml::LN_Value_wordprocessingml_ST_DropCap_none;
1379 19738 : m_nLines = 0;
1380 19738 : m_w = -1;
1381 19738 : m_h = -1;
1382 19738 : m_nWrap = -1;
1383 19738 : m_hAnchor = -1;
1384 19738 : m_vAnchor = text::RelOrientation::FRAME;
1385 19738 : m_x = -1;
1386 19738 : m_bxValid = false;
1387 19738 : m_y = -1;
1388 19738 : m_byValid = false;
1389 19738 : m_hSpace = -1;
1390 19738 : m_vSpace = -1;
1391 19738 : m_hRule = -1;
1392 19738 : m_xAlign = -1;
1393 19738 : m_yAlign = -1;
1394 19738 : m_bAnchorLock = false;
1395 19738 : m_nDropCapLength = 0;
1396 19738 : }
1397 :
1398 :
1399 22821 : ParagraphPropertyMap::ParagraphPropertyMap()
1400 : {
1401 22821 : }
1402 :
1403 :
1404 45642 : ParagraphPropertyMap::~ParagraphPropertyMap()
1405 : {
1406 45642 : }
1407 :
1408 :
1409 33583 : TablePropertyMap::TablePropertyMap()
1410 : {
1411 33583 : }
1412 :
1413 :
1414 67166 : TablePropertyMap::~TablePropertyMap()
1415 : {
1416 67166 : }
1417 :
1418 :
1419 7941 : bool TablePropertyMap::getValue( TablePropertyMapTarget eWhich, sal_Int32& nFill )
1420 : {
1421 7941 : if( eWhich < TablePropertyMapTarget_MAX )
1422 : {
1423 7941 : if(m_aValidValues[eWhich].bValid)
1424 6009 : nFill = m_aValidValues[eWhich].nValue;
1425 7941 : return m_aValidValues[eWhich].bValid;
1426 : }
1427 : else
1428 : {
1429 : OSL_FAIL( "invalid TablePropertyMapTarget");
1430 0 : return false;
1431 : }
1432 : }
1433 :
1434 :
1435 14430 : void TablePropertyMap::setValue( TablePropertyMapTarget eWhich, sal_Int32 nSet )
1436 : {
1437 14430 : if( eWhich < TablePropertyMapTarget_MAX )
1438 : {
1439 14430 : m_aValidValues[eWhich].bValid = true;
1440 14430 : m_aValidValues[eWhich].nValue = nSet;
1441 : }
1442 : else
1443 : OSL_FAIL( "invalid TablePropertyMapTarget");
1444 14430 : }
1445 :
1446 :
1447 18006 : void TablePropertyMap::insertTableProperties( const PropertyMap* pMap )
1448 : {
1449 : #ifdef DEBUG_DOMAINMAPPER
1450 : dmapper_logger->startElement("TablePropertyMap.insertTableProperties");
1451 : pMap->dumpXml(dmapper_logger);
1452 : #endif
1453 :
1454 18006 : const TablePropertyMap* pSource = dynamic_cast< const TablePropertyMap* >(pMap);
1455 18006 : if( pSource )
1456 : {
1457 164830 : for( sal_Int32 eTarget = TablePropertyMapTarget_START;
1458 : eTarget < TablePropertyMapTarget_MAX; ++eTarget )
1459 : {
1460 148347 : if( pSource->m_aValidValues[eTarget].bValid )
1461 : {
1462 15375 : m_aValidValues[eTarget].bValid = true;
1463 15375 : m_aValidValues[eTarget].nValue = pSource->m_aValidValues[eTarget].nValue;
1464 : }
1465 : }
1466 : }
1467 : #ifdef DEBUG_DOMAINMAPPER
1468 : dumpXml( dmapper_logger );
1469 : dmapper_logger->endElement();
1470 : #endif
1471 18006 : }
1472 :
1473 :
1474 : }//namespace dmapper
1475 : }//namespace writerfilter
1476 :
1477 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|