1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23 #include <PropertyMap.hxx>
24 #include <ooxml/resourceids.hxx>
25 #include <DomainMapper_Impl.hxx>
26 #include <ConversionHelper.hxx>
27 #include <i18npool/paper.hxx>
28 #include <com/sun/star/beans/PropertyValue.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/table/BorderLine.hpp>
31 #include <com/sun/star/container/XEnumeration.hpp>
32 #include <com/sun/star/container/XEnumerationAccess.hpp>
33 #include <com/sun/star/container/XNameContainer.hpp>
34 #include <com/sun/star/style/BreakType.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 /*-- 21.06.2006 09:30:56---------------------------------------------------
50
51 -----------------------------------------------------------------------*/
PropertyMap()52 PropertyMap::PropertyMap() :
53 m_cFootnoteSymbol( 0 ),
54 m_nFootnoteFontId( -1 )
55 {
56 }
57 /*-- 21.06.2006 09:30:56---------------------------------------------------
58
59 -----------------------------------------------------------------------*/
~PropertyMap()60 PropertyMap::~PropertyMap()
61 {
62 }
63 /*-- 20.06.2006 10:23:55---------------------------------------------------
64
65 -----------------------------------------------------------------------*/
GetPropertyValues()66 uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues()
67 {
68 if(!m_aValues.getLength() && size())
69 {
70 m_aValues.realloc( size() );
71 ::com::sun::star::beans::PropertyValue* pValues = m_aValues.getArray();
72 //style names have to be the first elements within the property sequence
73 //otherwise they will overwrite 'hard' attributes
74 sal_Int32 nValue = 0;
75 PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
76 PropertyMap::iterator aParaStyleIter = find(PropertyDefinition( PROP_PARA_STYLE_NAME, false ) );
77 if( aParaStyleIter != end())
78 {
79 pValues[nValue].Name = rPropNameSupplier.GetName( aParaStyleIter->first.eId );
80 pValues[nValue].Value = aParaStyleIter->second;
81 ++nValue;
82 }
83
84 PropertyMap::iterator aCharStyleIter = find(PropertyDefinition( PROP_CHAR_STYLE_NAME, false ));
85 if( aCharStyleIter != end())
86 {
87 pValues[nValue].Name = rPropNameSupplier.GetName( aCharStyleIter->first.eId );
88 pValues[nValue].Value = aCharStyleIter->second;
89 ++nValue;
90 }
91 PropertyMap::iterator aNumRuleIter = find(PropertyDefinition( PROP_NUMBERING_RULES, false ) );
92 if( aNumRuleIter != end())
93 {
94 pValues[nValue].Name = rPropNameSupplier.GetName( aNumRuleIter->first.eId );
95 pValues[nValue].Value = aNumRuleIter->second;
96 ++nValue;
97 }
98 PropertyMap::iterator aMapIter = begin();
99 for( ; nValue < m_aValues.getLength(); ++aMapIter )
100 {
101 if( aMapIter != aParaStyleIter && aMapIter != aCharStyleIter && aMapIter != aNumRuleIter )
102 {
103 pValues[nValue].Name = rPropNameSupplier.GetName( aMapIter->first.eId );
104 pValues[nValue].Value = aMapIter->second;
105 ++nValue;
106 }
107 }
108 }
109 return m_aValues;
110 }
111
lcl_AnyToTag(XMLTag::Pointer_t pTag,const uno::Any & rAny)112 void lcl_AnyToTag(XMLTag::Pointer_t pTag, const uno::Any & rAny)
113 {
114 try {
115 sal_Int32 aInt = 0;
116 rAny >>= aInt;
117 pTag->addAttr("value", aInt);
118
119 sal_uInt32 auInt = 0;
120 rAny >>= auInt;
121 pTag->addAttr("unsignedValue", auInt);
122
123 float aFloat = 0.0f;
124 rAny >>= aFloat;
125 pTag->addAttr("floatValue", aFloat);
126
127 ::rtl::OUString aStr;
128 rAny >>= aStr;
129 pTag->addAttr("stringValue", aStr);
130 }
131 catch (...) {
132 }
133 }
134
Insert(PropertyIds eId,bool bIsTextProperty,const uno::Any & rAny,bool bOverwrite)135 void PropertyMap::Insert( PropertyIds eId, bool bIsTextProperty, const uno::Any& rAny, bool bOverwrite )
136 {
137 #ifdef DEBUG_DMAPPER_PROPERTY_MAP
138 const ::rtl::OUString& rInsert = PropertyNameSupplier::
139 GetPropertyNameSupplier().GetName(eId);
140
141 XMLTag::Pointer_t pTag(new XMLTag("propertyMap.insert"));
142 pTag->addAttr("name", rInsert);
143 lcl_AnyToTag(pTag, rAny);
144
145 dmapper_logger->addTag(pTag);
146 #endif
147
148 PropertyMap::iterator aElement = find(PropertyDefinition( eId, bIsTextProperty ) );
149 if( aElement != end())
150 {
151 if(!bOverwrite)
152 return;
153 erase( aElement );
154 }
155 _PropertyMap::insert( PropertyMap::value_type
156 (PropertyDefinition( eId, bIsTextProperty),
157 rAny ));
158 Invalidate();
159 }
160
toTag() const161 XMLTag::Pointer_t PropertyMap::toTag() const
162 {
163 XMLTag::Pointer_t pResult(new XMLTag("PropertyMap"));
164
165 PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
166 PropertyMap::const_iterator aMapIter = begin();
167 while (aMapIter != end())
168 {
169 XMLTag::Pointer_t pTag(new XMLTag("property"));
170
171 pTag->addAttr("name", rPropNameSupplier.GetName( aMapIter->first.eId ));
172
173 switch (aMapIter->first.eId)
174 {
175 case PROP_TABLE_COLUMN_SEPARATORS:
176 pTag->addTag(lcl_TableColumnSeparatorsToTag(aMapIter->second));
177 break;
178 default:
179 {
180 try {
181 sal_Int32 aInt = 0;
182 aMapIter->second >>= aInt;
183 pTag->addAttr("value", aInt);
184
185 sal_uInt32 auInt = 0;
186 aMapIter->second >>= auInt;
187 pTag->addAttr("unsignedValue", auInt);
188
189 float aFloat = 0.0;
190 aMapIter->second >>= aFloat;
191 pTag->addAttr("floatValue", aFloat);
192
193 ::rtl::OUString aStr;
194 aMapIter->second >>= auInt;
195 pTag->addAttr("stringValue", aStr);
196 }
197 catch (...) {
198 }
199 }
200 break;
201 }
202
203 pResult->addTag(pTag);
204
205 ++aMapIter;
206 }
207
208 return pResult;
209 }
210
211 /*-- 13.12.2006 10:46:42---------------------------------------------------
212
213 -----------------------------------------------------------------------*/
214 template<class T>
215 struct removeExistingElements : public ::std::unary_function<T, void>
216 {
217 PropertyMap& rMap;
218
removeExistingElementswriterfilter::dmapper::removeExistingElements219 removeExistingElements(PropertyMap& _rMap ) : rMap(_rMap) {}
operator ()writerfilter::dmapper::removeExistingElements220 void operator() (T x)
221 {
222 PropertyMap::iterator aElement = rMap.find(x.first);
223 if( aElement != rMap.end())
224 rMap.erase( aElement );
225 }
226 };
227 /*-- 13.12.2006 10:46:42---------------------------------------------------
228
229 -----------------------------------------------------------------------*/
insert(const PropertyMapPtr pMap,bool bOverwrite)230 void PropertyMap::insert( const PropertyMapPtr pMap, bool bOverwrite )
231 {
232 if( pMap.get() )
233 {
234 if( bOverwrite )
235 ::std::for_each( pMap->begin(), pMap->end(), removeExistingElements<PropertyMap::value_type>(*this) );
236 _PropertyMap::insert(pMap->begin(), pMap->end());
237 insertTableProperties(pMap.get());
238
239 Invalidate();
240 }
241 }
242 /*-- 06.06.2007 15:49:09---------------------------------------------------
243
244 -----------------------------------------------------------------------*/
GetFootnote() const245 const uno::Reference< text::XFootnote>& PropertyMap::GetFootnote() const
246 {
247 return m_xFootnote;
248 }
249 /*-- 18.02.2008 11:23:28---------------------------------------------------
250
251 -----------------------------------------------------------------------*/
insertTableProperties(const PropertyMap *)252 void PropertyMap::insertTableProperties( const PropertyMap* )
253 {
254 #ifdef DEBUG_DOMAINMAPPER
255 dmapper_logger->element("PropertyMap.insertTableProperties");
256 #endif
257 }
258 /*-- 24.07.2006 08:29:01---------------------------------------------------
259
260 -----------------------------------------------------------------------*/
SectionPropertyMap(bool bIsFirstSection)261 SectionPropertyMap::SectionPropertyMap(bool bIsFirstSection) :
262 m_bIsFirstSection( bIsFirstSection )
263 ,m_nBorderParams( 0 )
264 ,m_bTitlePage( false )
265 ,m_nColumnCount( 0 )
266 ,m_nColumnDistance( 1249 )
267 ,m_bSeparatorLineIsOn( false )
268 ,m_bEvenlySpaced( false )
269 ,m_bIsLandscape( false )
270 ,m_bPageNoRestart( false )
271 ,m_nPageNumber( -1 )
272 ,m_nBreakType( -1 )
273 ,m_nPaperBin( -1 )
274 ,m_nFirstPaperBin( -1 )
275 ,m_nLeftMargin( 3175 ) //page left margin, default 0x708 (1800) twip -> 3175 1/100 mm
276 ,m_nRightMargin( 3175 )//page right margin, default 0x708 (1800) twip -> 3175 1/100 mm
277 ,m_nTopMargin( 2540 )
278 ,m_nBottomMargin( 2540 )
279 ,m_nHeaderTop( 1270 ) //720 twip
280 ,m_nHeaderBottom( 1270 )//720 twip
281 ,m_nDzaGutter( 0 )
282 ,m_bGutterRTL( false )
283 ,m_bSFBiDi( false )
284 ,m_nGridType(0)
285 ,m_nGridLinePitch( 1 )
286 ,m_nDxtCharSpace( 0 )
287 ,m_nLnnMod( 0 )
288 ,m_nLnc( 0 )
289 ,m_ndxaLnn( 0 )
290 ,m_nLnnMin( 0 )
291 {
292 static sal_Int32 nNumber = 0;
293 nSectionNumber = nNumber++;
294 memset(&m_pBorderLines, 0x00, sizeof(m_pBorderLines));
295 for( sal_Int32 nBorder = 0; nBorder < 4; ++nBorder )
296 m_nBorderDistances[ nBorder ] = -1;
297 //todo: set defaults in ApplyPropertiesToPageStyles
298 //initialize defaults
299 PaperInfo aLetter(PAPER_LETTER);
300 //page height, 1/100mm
301 Insert( PROP_HEIGHT, false, uno::makeAny( (sal_Int32) aLetter.getHeight() ) );
302 //page width, 1/100mm
303 Insert( PROP_WIDTH, false, uno::makeAny( (sal_Int32) aLetter.getWidth() ) );
304 //page left margin, default 0x708 (1800) twip -> 3175 1/100 mm
305 Insert( PROP_LEFT_MARGIN, false, uno::makeAny( (sal_Int32) 3175 ) );
306 //page right margin, default 0x708 (1800) twip -> 3175 1/100 mm
307 Insert( PROP_RIGHT_MARGIN, false, uno::makeAny( (sal_Int32) 3175 ) );
308 //page top margin, default 0x5a0 (1440) twip -> 2540 1/100 mm
309 Insert( PROP_TOP_MARGIN, false, uno::makeAny( (sal_Int32)2540 ) );
310 //page bottom margin, default 0x5a0 (1440) twip -> 2540 1/100 mm
311 Insert( PROP_BOTTOM_MARGIN, false, uno::makeAny( (sal_Int32) 2540 ) );
312 uno::Any aFalse( ::uno::makeAny( false ) );
313 Insert( PROP_GRID_DISPLAY, false, aFalse);
314 Insert( PROP_GRID_PRINT, false, aFalse);
315 Insert( PROP_GRID_MODE, false, uno::makeAny(text::TextGridMode::NONE));
316
317
318 if( m_bIsFirstSection )
319 {
320 PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
321 m_sFirstPageStyleName = rPropNameSupplier.GetName( PROP_FIRST_PAGE );
322 m_sFollowPageStyleName = rPropNameSupplier.GetName( PROP_STANDARD );
323 }
324 }
325 /*-- 24.07.2006 08:29:02---------------------------------------------------
326
327 -----------------------------------------------------------------------*/
~SectionPropertyMap()328 SectionPropertyMap::~SectionPropertyMap()
329 {
330 for( sal_Int16 ePos = BORDER_LEFT; ePos <= BORDER_BOTTOM; ++ePos)
331 delete m_pBorderLines[ePos];
332 }
333 /*-- 24.07.2006 08:31:07---------------------------------------------------
334
335 -----------------------------------------------------------------------*/
GetPageStyleName(bool bFirst)336 const ::rtl::OUString& SectionPropertyMap::GetPageStyleName( bool bFirst )
337 {
338 return bFirst ? m_sFirstPageStyleName : m_sFollowPageStyleName;
339 }
340 /*-- 24.07.2006 08:31:07---------------------------------------------------
341
342 -----------------------------------------------------------------------*/
SetPageStyleName(bool bFirst,const::rtl::OUString & rName)343 void SectionPropertyMap::SetPageStyleName( bool bFirst, const ::rtl::OUString& rName)
344 {
345 if( bFirst )
346 m_sFirstPageStyleName = rName;
347 else
348 m_sFollowPageStyleName = rName;
349 }
350 /*-- 24.07.2006 09:41:20---------------------------------------------------
351
352 -----------------------------------------------------------------------*/
lcl_FindUnusedPageStyleName(const uno::Sequence<::rtl::OUString> & rPageStyleNames)353 ::rtl::OUString lcl_FindUnusedPageStyleName(const uno::Sequence< ::rtl::OUString >& rPageStyleNames)
354 {
355 static const sal_Char cDefaultStyle[] = "Converted";
356 //find the hightest number x in each style with the name "cDefaultStyle+x" and
357 //return an incremented name
358 sal_Int32 nMaxIndex = 0;
359 const sal_Int32 nDefaultLength = sizeof(cDefaultStyle)/sizeof(sal_Char) - 1;
360 const ::rtl::OUString sDefaultStyle( cDefaultStyle, nDefaultLength, RTL_TEXTENCODING_ASCII_US );
361
362 const ::rtl::OUString* pStyleNames = rPageStyleNames.getConstArray();
363 for( sal_Int32 nStyle = 0; nStyle < rPageStyleNames.getLength(); ++nStyle)
364 {
365 if( pStyleNames[nStyle].getLength() > nDefaultLength &&
366 !rtl_ustr_compare_WithLength( sDefaultStyle.getStr(), nDefaultLength, pStyleNames[nStyle].getStr(), nDefaultLength))
367 {
368 sal_Int32 nIndex = pStyleNames[nStyle].copy( nDefaultLength ).toInt32();
369 if( nIndex > nMaxIndex)
370 nMaxIndex = nIndex;
371 }
372 }
373 ::rtl::OUString sRet( sDefaultStyle );
374 sRet += rtl::OUString::valueOf( nMaxIndex + 1);
375 return sRet;
376 }
377
378 /*-- 28.07.2006 13:00:43---------------------------------------------------
379
380 -----------------------------------------------------------------------*/
GetPageStyle(const uno::Reference<container::XNameContainer> & xPageStyles,const uno::Reference<lang::XMultiServiceFactory> & xTextFactory,bool bFirst)381 uno::Reference< beans::XPropertySet > SectionPropertyMap::GetPageStyle(
382 const uno::Reference< container::XNameContainer >& xPageStyles,
383 const uno::Reference < lang::XMultiServiceFactory >& xTextFactory,
384 bool bFirst )
385 {
386 uno::Reference< beans::XPropertySet > xRet;
387 try
388 {
389 if( bFirst )
390 {
391 if( !m_sFirstPageStyleName.getLength() )
392 {
393 uno::Sequence< ::rtl::OUString > aPageStyleNames = xPageStyles->getElementNames();
394 m_sFirstPageStyleName = lcl_FindUnusedPageStyleName(aPageStyleNames);
395 m_aFirstPageStyle = uno::Reference< beans::XPropertySet > (
396 xTextFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.PageStyle") )),
397 uno::UNO_QUERY);
398 xPageStyles->insertByName( m_sFirstPageStyleName, uno::makeAny(m_aFirstPageStyle) );
399 }
400 else if( !m_aFirstPageStyle.is() )
401 {
402 xPageStyles->getByName(m_sFirstPageStyleName) >>= m_aFirstPageStyle;
403 }
404 xRet = m_aFirstPageStyle;
405 }
406 else
407 {
408 if( !m_sFollowPageStyleName.getLength() )
409 {
410 uno::Sequence< ::rtl::OUString > aPageStyleNames = xPageStyles->getElementNames();
411 m_sFollowPageStyleName = lcl_FindUnusedPageStyleName(aPageStyleNames);
412 m_aFollowPageStyle = uno::Reference< beans::XPropertySet > (
413 xTextFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.PageStyle") )),
414 uno::UNO_QUERY);
415 xPageStyles->insertByName( m_sFollowPageStyleName, uno::makeAny(m_aFollowPageStyle) );
416 }
417 else if(!m_aFollowPageStyle.is() )
418 {
419 xPageStyles->getByName(m_sFollowPageStyleName) >>= m_aFollowPageStyle;
420 }
421 xRet = m_aFollowPageStyle;
422 }
423
424 }
425 catch( const uno::Exception& )
426 {
427 }
428
429 return xRet;
430 }
431 /*-- 28.07.2006 10:56:26---------------------------------------------------
432
433 -----------------------------------------------------------------------*/
SetBorder(BorderPosition ePos,sal_Int32 nLineDistance,const table::BorderLine & rBorderLine)434 void SectionPropertyMap::SetBorder( BorderPosition ePos, sal_Int32 nLineDistance, const table::BorderLine& rBorderLine )
435 {
436 delete m_pBorderLines[ePos];
437 m_pBorderLines[ePos] = new table::BorderLine( rBorderLine );
438 m_nBorderDistances[ePos] = nLineDistance;
439 }
440 /*-- 28.07.2006 10:56:27---------------------------------------------------
441
442 -----------------------------------------------------------------------*/
ApplyBorderToPageStyles(const uno::Reference<container::XNameContainer> & xPageStyles,const uno::Reference<lang::XMultiServiceFactory> & xTextFactory,sal_Int32 nValue)443 void SectionPropertyMap::ApplyBorderToPageStyles(
444 const uno::Reference< container::XNameContainer >& xPageStyles,
445 const uno::Reference < lang::XMultiServiceFactory >& xTextFactory,
446 sal_Int32 nValue )
447 {
448 /*
449 page border applies to:
450 nIntValue & 0x07 ->
451 0 all pages in this section
452 1 first page in this section
453 2 all pages in this section but first
454 3 whole document (all sections)
455 nIntValue & 0x18 -> page border depth 0 - in front 1- in back
456 nIntValue & 0xe0 ->
457 page border offset from:
458 0 offset from text
459 1 offset from edge of page
460 */
461 uno::Reference< beans::XPropertySet > xFirst;
462 uno::Reference< beans::XPropertySet > xSecond;
463 sal_Int32 nOffsetFrom = (nValue & 0x00E0) >> 5;
464 //sal_Int32 bPageDepth = (nValue & 0x0018) >> 3; //unused infromation: 0 - in front 1 - in back
465 //todo: negative spacing (from ww8par6.cxx)
466 switch( nValue & 0x07)
467 {
468 case 0: /*all styles*/
469 if ( m_sFollowPageStyleName.getLength( ) > 0 )
470 xFirst = GetPageStyle( xPageStyles, xTextFactory, false );
471 if ( m_sFirstPageStyleName.getLength( ) > 0 )
472 xSecond = GetPageStyle( xPageStyles, xTextFactory, true );
473 break;
474 case 1: /*first page*/
475 if ( m_sFirstPageStyleName.getLength( ) > 0 )
476 xFirst = GetPageStyle( xPageStyles, xTextFactory, true );
477 break;
478 case 2: /*left and right*/
479 if ( m_sFollowPageStyleName.getLength( ) > 0 )
480 xFirst = GetPageStyle( xPageStyles, xTextFactory, false );
481 break;
482 case 3: //whole document?
483 //todo: how to apply a border to the whole document - find all sections or access all page styles?
484 default:
485 return;
486 }
487 //has to be sorted like enum BorderPosition: l-r-t-b
488 static const PropertyIds aBorderIds[4] =
489 {
490 PROP_LEFT_BORDER,
491 PROP_RIGHT_BORDER,
492 PROP_TOP_BORDER,
493 PROP_BOTTOM_BORDER
494 };
495 static const PropertyIds aBorderDistanceIds[4] =
496 {
497 PROP_LEFT_BORDER_DISTANCE,
498 PROP_RIGHT_BORDER_DISTANCE,
499 PROP_TOP_BORDER_DISTANCE,
500 PROP_BOTTOM_BORDER_DISTANCE
501 };
502 static const PropertyIds aMarginIds[4] =
503 {
504 PROP_LEFT_MARGIN,
505 PROP_RIGHT_MARGIN,
506 PROP_TOP_MARGIN,
507 PROP_BOTTOM_MARGIN
508 };
509
510 PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
511 for( sal_Int32 nBorder = 0; nBorder < 4; ++nBorder)
512 {
513 if( m_pBorderLines[nBorder] )
514 {
515 const ::rtl::OUString sBorderName = rPropNameSupplier.GetName( aBorderIds[nBorder] );
516 xFirst->setPropertyValue( sBorderName, uno::makeAny( *m_pBorderLines[nBorder] ));
517 if(xSecond.is())
518 xSecond->setPropertyValue( sBorderName, uno::makeAny( *m_pBorderLines[nBorder] ));
519 }
520 if( m_nBorderDistances[nBorder] >= 0 )
521 {
522 SetBorderDistance( xFirst, aMarginIds[nBorder], aBorderDistanceIds[nBorder],
523 m_nBorderDistances[nBorder], nOffsetFrom );
524 if(xSecond.is())
525 SetBorderDistance( xSecond, aMarginIds[nBorder], aBorderDistanceIds[nBorder],
526 m_nBorderDistances[nBorder], nOffsetFrom );
527 }
528 }
529 }
530
SetBorderDistance(uno::Reference<beans::XPropertySet> xStyle,PropertyIds eMarginId,PropertyIds eDistId,sal_Int32 nDistance,sal_Int32 nOffsetFrom)531 void SectionPropertyMap::SetBorderDistance( uno::Reference< beans::XPropertySet > xStyle,
532 PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, sal_Int32 nOffsetFrom )
533 {
534 PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
535
536 sal_Int32 nDist = nDistance;
537 if( nOffsetFrom == 1 )
538 {
539 const ::rtl::OUString sMarginName = rPropNameSupplier.GetName( eMarginId );
540 uno::Any aMargin = xStyle->getPropertyValue( sMarginName );
541 sal_Int32 nMargin = 0;
542 aMargin >>= nMargin;
543
544 // Change the margins with the border distance
545 xStyle->setPropertyValue( sMarginName, uno::makeAny( nDistance ) );
546
547 // Set the distance to ( Margin - distance )
548 nDist = nMargin - nDistance;
549 }
550 const ::rtl::OUString sBorderDistanceName = rPropNameSupplier.GetName( eDistId );
551 xStyle->setPropertyValue( sBorderDistanceName, uno::makeAny( nDist ));
552 }
553
554 /*-- 14.12.2006 12:50:06---------------------------------------------------
555
556 -----------------------------------------------------------------------*/
ApplyColumnProperties(uno::Reference<beans::XPropertySet> xColumnContainer)557 uno::Reference< text::XTextColumns > SectionPropertyMap::ApplyColumnProperties(
558 uno::Reference< beans::XPropertySet > xColumnContainer )
559 {
560 uno::Reference< text::XTextColumns > xColumns;
561 try
562 {
563 PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
564 const ::rtl::OUString sTextColumns = rPropNameSupplier.GetName( PROP_TEXT_COLUMNS );
565 xColumnContainer->getPropertyValue(sTextColumns) >>= xColumns;
566 uno::Reference< beans::XPropertySet > xColumnPropSet( xColumns, uno::UNO_QUERY_THROW );
567 if( !m_bEvenlySpaced &&
568 (sal_Int32(m_aColWidth.size()) == (m_nColumnCount + 1 )) &&
569 ((sal_Int32(m_aColDistance.size()) == m_nColumnCount) || (sal_Int32(m_aColDistance.size()) == m_nColumnCount + 1)) )
570 {
571 //the column width in word is an absolute value, in OOo it's relative
572 //the distances are both absolute
573 sal_Int32 nColSum = 0;
574 for( sal_Int32 nCol = 0; nCol <= m_nColumnCount; ++nCol)
575 {
576 nColSum += m_aColWidth[nCol];
577 if(nCol)
578 nColSum += m_aColDistance[nCol -1];
579 }
580
581 sal_Int32 nRefValue = xColumns->getReferenceValue();
582 double fRel = double( nRefValue ) / double( nColSum );
583 uno::Sequence< text::TextColumn > aColumns( m_nColumnCount + 1 );
584 text::TextColumn* pColumn = aColumns.getArray();
585
586 nColSum = 0;
587 for( sal_Int32 nCol = 0; nCol <= m_nColumnCount; ++nCol)
588 {
589 //nColSum : nRefValue == (nAbsColWidth + colDist /2) : nRelColWidth;
590 pColumn[nCol].LeftMargin = nCol ? m_aColDistance[nCol - 1 ] / 2 : 0;
591 pColumn[nCol].RightMargin = nCol == m_nColumnCount ? 0 : m_aColDistance[nCol] / 2;
592 pColumn[nCol].Width = sal_Int32((double( m_aColWidth[nCol] + pColumn[nCol].RightMargin + pColumn[nCol].LeftMargin ) + 0.5 ) * fRel );
593 nColSum += pColumn[nCol].Width;
594 }
595 if( nColSum != nRefValue )
596 pColumn[m_nColumnCount].Width -= ( nColSum - nRefValue );
597 xColumns->setColumns( aColumns );
598 }
599 else
600 {
601 xColumns->setColumnCount( m_nColumnCount + 1 );
602 xColumnPropSet->setPropertyValue( rPropNameSupplier.GetName( PROP_AUTOMATIC_DISTANCE ), uno::makeAny( m_nColumnDistance ));
603 }
604
605 if(m_bSeparatorLineIsOn)
606 xColumnPropSet->setPropertyValue(
607 rPropNameSupplier.GetName( PROP_SEPARATOR_LINE_IS_ON ),
608 uno::makeAny( m_bSeparatorLineIsOn ));
609 xColumnContainer->setPropertyValue( sTextColumns, uno::makeAny( xColumns ) );
610 }
611 catch( const uno::Exception& )
612 {
613 OSL_ENSURE( false, "Exception in SectionPropertyMap::ApplyColumnProperties");
614 }
615 return xColumns;
616 }
617
618 /*-- 20.12.2006 09:44:16---------------------------------------------------
619
620 -----------------------------------------------------------------------*/
HasHeader(bool bFirstPage) const621 bool SectionPropertyMap::HasHeader(bool bFirstPage) const
622 {
623 bool bRet = false;
624 if( (bFirstPage && m_aFirstPageStyle.is()) ||( !bFirstPage && m_aFollowPageStyle.is()) )
625 {
626 if( bFirstPage )
627 m_aFirstPageStyle->getPropertyValue(
628 PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_HEADER_IS_ON) ) >>= bRet;
629 else
630 m_aFollowPageStyle->getPropertyValue(
631 PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_HEADER_IS_ON) ) >>= bRet;
632 }
633 return bRet;
634 }
635 /*-- 20.12.2006 09:44:16---------------------------------------------------
636
637 -----------------------------------------------------------------------*/
HasFooter(bool bFirstPage) const638 bool SectionPropertyMap::HasFooter(bool bFirstPage) const
639 {
640 bool bRet = false;
641 if( (bFirstPage && m_aFirstPageStyle.is()) ||( !bFirstPage && m_aFollowPageStyle.is()) )
642 {
643 if( bFirstPage )
644 m_aFirstPageStyle->getPropertyValue(
645 PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_FOOTER_IS_ON) ) >>= bRet;
646 else
647 m_aFollowPageStyle->getPropertyValue(
648 PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_FOOTER_IS_ON) ) >>= bRet;
649 }
650 return bRet;
651 }
652 /*-- 20.12.2006 09:41:56---------------------------------------------------
653
654 -----------------------------------------------------------------------*/
655 #define MIN_HEAD_FOOT_HEIGHT 100 //minimum header/footer height
656
CopyLastHeaderFooter(bool bFirstPage,DomainMapper_Impl & rDM_Impl)657 void SectionPropertyMap::CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Impl& rDM_Impl )
658 {
659 #if DEBUG
660 clog << "START>>> SectionPropertyMap::CopyLastHeaderFooter()" << endl;
661 #endif
662 SectionPropertyMap* pLastContext = rDM_Impl.GetLastSectionContext( );
663 if ( pLastContext )
664 {
665 uno::Reference< beans::XPropertySet > xPrevStyle = pLastContext->GetPageStyle(
666 rDM_Impl.GetPageStyles(),
667 rDM_Impl.GetTextFactory(),
668 bFirstPage );
669 uno::Reference< beans::XPropertySet > xStyle = GetPageStyle(
670 rDM_Impl.GetPageStyles(),
671 rDM_Impl.GetTextFactory(),
672 bFirstPage );
673
674 PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
675
676 try {
677 // Loop over the Header and Footer properties to copy them
678 static PropertyIds aProperties[] =
679 {
680 PROP_HEADER_TEXT,
681 PROP_FOOTER_TEXT,
682 };
683
684 bool bHasPrevHeader = false;
685 bool bHasHeader = false;
686
687 rtl::OUString sHeaderIsOn = rPropNameSupplier.GetName( PROP_HEADER_IS_ON );
688 xPrevStyle->getPropertyValue( sHeaderIsOn ) >>= bHasPrevHeader;
689 xStyle->getPropertyValue( sHeaderIsOn ) >>= bHasHeader;
690 bool bCopyHeader = bHasPrevHeader && !bHasHeader;
691
692 if ( bCopyHeader )
693 xStyle->setPropertyValue( sHeaderIsOn, uno::makeAny( sal_True ) );
694
695 bool bHasPrevFooter = false;
696 bool bHasFooter = false;
697
698 rtl::OUString sFooterIsOn = rPropNameSupplier.GetName( PROP_FOOTER_IS_ON );
699 xPrevStyle->getPropertyValue( sFooterIsOn ) >>= bHasPrevFooter;
700 xStyle->getPropertyValue( sFooterIsOn ) >>= bHasFooter;
701 bool bCopyFooter = bHasPrevFooter && !bHasFooter;
702
703 if ( bCopyFooter )
704 xStyle->setPropertyValue( sFooterIsOn, uno::makeAny( sal_True ) );
705
706 // Copying the text properties
707 for ( int i = 0, nNbProps = 2; i < nNbProps; i++ )
708 {
709 bool bIsHeader = ( i < nNbProps / 2 );
710 PropertyIds aPropId = aProperties[i];
711 rtl::OUString sName = rPropNameSupplier.GetName( aPropId );
712
713 if ( ( bIsHeader && bCopyHeader ) || ( !bIsHeader && bCopyFooter ) )
714 {
715 #if DEBUG
716 clog << "Copying ";
717 clog << rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr( ) << endl;
718 #endif
719 // TODO has to be copied
720 uno::Reference< text::XTextCopy > xTxt(
721 xStyle->getPropertyValue( sName ), uno::UNO_QUERY_THROW );
722
723 uno::Reference< text::XTextCopy > xPrevTxt(
724 xPrevStyle->getPropertyValue( sName ), uno::UNO_QUERY_THROW );
725
726 xTxt->copyText( xPrevTxt );
727 }
728 }
729 }
730 catch ( const uno::Exception& e )
731 {
732 #if DEBUG
733 clog << "An exception occured in SectionPropertyMap::CopyLastHeaderFooter( ) - ";
734 clog << rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr( ) << endl;
735 #endif
736 }
737 }
738 #if DEBUG
739 clog << "END>>> SectionPropertyMap::CopyLastHeaderFooter()" << endl;
740 #endif
741 }
742
PrepareHeaderFooterProperties(bool bFirstPage)743 void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage )
744 {
745 sal_Int32 nTopMargin = m_nTopMargin;
746 if(HasHeader(bFirstPage))
747 {
748 m_nTopMargin = m_nHeaderTop;
749 if( nTopMargin > 0 && nTopMargin > m_nHeaderTop )
750 m_nHeaderTop = nTopMargin - m_nHeaderTop;
751 else
752 m_nHeaderTop = 0;
753
754 //minimum header height 1mm
755 if( m_nHeaderTop < MIN_HEAD_FOOT_HEIGHT )
756 m_nHeaderTop = MIN_HEAD_FOOT_HEIGHT;
757 }
758
759
760 if( nTopMargin >= 0 ) //fixed height header -> see WW8Par6.hxx
761 {
762 operator[]( PropertyDefinition( PROP_HEADER_IS_DYNAMIC_HEIGHT, false )) = uno::makeAny( true );
763 operator[]( PropertyDefinition( PROP_HEADER_DYNAMIC_SPACING, false )) = uno::makeAny( true );
764 operator[]( PropertyDefinition( PROP_HEADER_BODY_DISTANCE, false )) = uno::makeAny( m_nHeaderTop - MIN_HEAD_FOOT_HEIGHT );// ULSpace.Top()
765 operator[]( PropertyDefinition( PROP_HEADER_HEIGHT, false )) = uno::makeAny( m_nHeaderTop );
766
767 }
768 else
769 {
770 //todo: old filter fakes a frame into the header/footer to support overlapping
771 //current setting is completely wrong!
772 operator[]( PropertyDefinition( PROP_HEADER_HEIGHT, false )) = uno::makeAny( m_nHeaderTop );
773 operator[]( PropertyDefinition( PROP_HEADER_BODY_DISTANCE, false )) = uno::makeAny( nTopMargin - m_nHeaderTop );
774 operator[]( PropertyDefinition( PROP_HEADER_IS_DYNAMIC_HEIGHT, false)) = uno::makeAny( false );
775 operator[]( PropertyDefinition( PROP_HEADER_DYNAMIC_SPACING, false)) = uno::makeAny( false );
776 }
777
778 sal_Int32 nBottomMargin = m_nBottomMargin;
779 if( HasFooter( bFirstPage ) )
780 {
781 m_nBottomMargin = m_nHeaderBottom;
782 if( nBottomMargin > 0 && nBottomMargin > m_nHeaderBottom )
783 m_nHeaderBottom = nBottomMargin - m_nHeaderBottom;
784 else
785 m_nHeaderBottom = 0;
786 if( m_nHeaderBottom < MIN_HEAD_FOOT_HEIGHT )
787 m_nHeaderBottom = MIN_HEAD_FOOT_HEIGHT;
788 }
789
790 if( nBottomMargin >= 0 ) //fixed height footer -> see WW8Par6.hxx
791 {
792 operator[]( PropertyDefinition( PROP_FOOTER_IS_DYNAMIC_HEIGHT, false )) = uno::makeAny( true );
793 operator[]( PropertyDefinition( PROP_FOOTER_DYNAMIC_SPACING, false )) = uno::makeAny( true );
794 operator[]( PropertyDefinition( PROP_FOOTER_BODY_DISTANCE, false )) = uno::makeAny( m_nHeaderBottom - MIN_HEAD_FOOT_HEIGHT);
795 operator[]( PropertyDefinition( PROP_FOOTER_HEIGHT, false )) = uno::makeAny( m_nHeaderBottom );
796 }
797 else
798 {
799 //todo: old filter fakes a frame into the header/footer to support overlapping
800 //current setting is completely wrong!
801 operator[]( PropertyDefinition( PROP_FOOTER_IS_DYNAMIC_HEIGHT, false)) = uno::makeAny( false );
802 operator[]( PropertyDefinition( PROP_FOOTER_DYNAMIC_SPACING, false)) = uno::makeAny( false );
803 operator[]( PropertyDefinition( PROP_FOOTER_HEIGHT, false )) = uno::makeAny( nBottomMargin - m_nHeaderBottom );
804 operator[]( PropertyDefinition( PROP_FOOTER_BODY_DISTANCE, false )) = uno::makeAny( m_nHeaderBottom );
805 }
806
807 //now set the top/bottom margin for the follow page style
808 operator[]( PropertyDefinition( PROP_TOP_MARGIN, false )) = uno::makeAny( m_nTopMargin );
809 operator[]( PropertyDefinition( PROP_BOTTOM_MARGIN, false )) = uno::makeAny( m_nBottomMargin );
810 }
811 /*-- 11.12.2006 08:31:46---------------------------------------------------
812
813 -----------------------------------------------------------------------*/
CloseSectionGroup(DomainMapper_Impl & rDM_Impl)814 void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
815 {
816 PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
817 if( m_nLnnMod )
818 {
819 bool bFirst = rDM_Impl.IsLineNumberingSet();
820 rDM_Impl.SetLineNumbering( m_nLnnMod, m_nLnc, m_ndxaLnn );
821 if( m_nLnnMin > 0 || (bFirst && m_nLnc == 1))
822 {
823 //set the starting value at the beginning of the section
824 try
825 {
826 uno::Reference< beans::XPropertySet > xRangeProperties;
827 if( m_xStartingRange.is() )
828 {
829 xRangeProperties = uno::Reference< beans::XPropertySet >( m_xStartingRange, uno::UNO_QUERY_THROW );
830 }
831 else
832 {
833 //set the start value at the beginning of the document
834 xRangeProperties = uno::Reference< beans::XPropertySet >( rDM_Impl.GetTextDocument()->getText()->getStart(), uno::UNO_QUERY_THROW );
835 }
836 xRangeProperties->setPropertyValue( rPropNameSupplier.GetName( PROP_PARA_LINE_NUMBER_START_VALUE ), uno::makeAny( m_nLnnMin + 1 ));
837 }
838 catch( const uno::Exception& )
839 {
840 OSL_ENSURE( false, "Exception in SectionPropertyMap::CloseSectionGroup");
841 }
842 }
843 }
844
845 //depending on the break type no page styles should be created
846 if(m_nBreakType == 0)
847 {
848 //todo: insert a section or access the already inserted section
849 //-->debug
850 // ::rtl::OUString sSelection = m_xStartingRange->getString();
851 // sSelection.getLength();
852 //-->debug
853 uno::Reference< beans::XPropertySet > xSection =
854 rDM_Impl.appendTextSectionAfter( m_xStartingRange );
855 if( m_nColumnCount > 0 && xSection.is())
856 ApplyColumnProperties( xSection );
857 }
858 else
859 {
860 //get the properties and create appropriate page styles
861 uno::Reference< beans::XPropertySet > xFollowPageStyle = GetPageStyle( rDM_Impl.GetPageStyles(), rDM_Impl.GetTextFactory(), false );
862
863 if( m_nDzaGutter > 0 )
864 {
865 //todo: iGutterPos from DocProperties are missing
866 // if( m_iGutterPos > 0 ) m_nTopMargin += m_nDzaGutter; else
867 if( m_bGutterRTL )
868 m_nRightMargin += m_nDzaGutter;
869 else
870 m_nLeftMargin += m_nDzaGutter;
871 }
872 operator[]( PropertyDefinition( PROP_LEFT_MARGIN, false )) = uno::makeAny( m_nLeftMargin );
873 operator[]( PropertyDefinition( PROP_RIGHT_MARGIN, false )) = uno::makeAny( m_nRightMargin );
874
875 // if( iGutterPos && fRTLGutter )
876 // m_nTopMargin += nGutter
877
878 /*** if headers/footers are available then the top/bottom margins of the
879 header/footer are copied to the top/bottom margin of the page
880 */
881 CopyLastHeaderFooter( false, rDM_Impl );
882 PrepareHeaderFooterProperties( false );
883
884 const ::rtl::OUString sTrayIndex = rPropNameSupplier.GetName( PROP_PRINTER_PAPER_TRAY_INDEX );
885 if( m_nPaperBin >= 0 )
886 xFollowPageStyle->setPropertyValue( sTrayIndex, uno::makeAny( m_nPaperBin ) );
887 uno::Reference< text::XTextColumns > xColumns;
888 if( m_nColumnCount > 0 )
889 xColumns = ApplyColumnProperties( xFollowPageStyle );
890
891 //prepare text grid properties
892 sal_Int32 nHeight = 1;
893 PropertyMap::iterator aElement = find(PropertyDefinition( PROP_HEIGHT, false ));
894 if( aElement != end())
895 aElement->second >>= nHeight;
896
897 sal_Int32 nWidth = 1;
898 aElement = find(PropertyDefinition( PROP_WIDTH, false ));
899 if( aElement != end())
900 aElement->second >>= nWidth;
901
902 text::WritingMode eWritingMode = text::WritingMode_LR_TB;
903 aElement = find(PropertyDefinition( PROP_WRITING_MODE, false ));
904 if( aElement != end())
905 aElement->second >>= eWritingMode;
906
907
908
909 sal_Int32 nTextAreaHeight = eWritingMode == text::WritingMode_LR_TB ?
910 nHeight - m_nTopMargin - m_nBottomMargin :
911 nWidth - m_nLeftMargin - m_nRightMargin;
912
913 operator[]( PropertyDefinition( PROP_GRID_LINES, false )) =
914 uno::makeAny( static_cast<sal_Int16>(nTextAreaHeight/m_nGridLinePitch));
915
916 sal_Int32 nCharWidth = 423; //240 twip/ 12 pt
917 //todo: is '0' the right index here?
918 const StyleSheetEntryPtr pEntry = rDM_Impl.GetStyleSheetTable()->FindStyleSheetByISTD(::rtl::OUString::valueOf(static_cast<sal_Int32>(0), 16));
919 if( pEntry.get( ) )
920 {
921 PropertyMap::iterator aElement_ = pEntry->pProperties->find(PropertyDefinition( PROP_CHAR_HEIGHT_ASIAN, false ));
922 if( aElement_ != pEntry->pProperties->end())
923 {
924 double fHeight = 0;
925 if( aElement_->second >>= fHeight )
926 nCharWidth = ConversionHelper::convertTwipToMM100( (long)( fHeight * 20.0 + 0.5 ));
927 }
928 }
929
930 //dxtCharSpace
931 if(m_nDxtCharSpace)
932 {
933 sal_Int32 nCharSpace = m_nDxtCharSpace;
934 //main lives in top 20 bits, and is signed.
935 sal_Int32 nMain = (nCharSpace & 0xFFFFF000);
936 nMain /= 0x1000;
937 nCharWidth += ConversionHelper::convertTwipToMM100( nMain * 20 );
938
939 sal_Int32 nFraction = (nCharSpace & 0x00000FFF);
940 nFraction = (nFraction * 20)/0xFFF;
941 nCharWidth += ConversionHelper::convertTwipToMM100( nFraction );
942 }
943 operator[]( PropertyDefinition( PROP_GRID_BASE_HEIGHT, false )) = uno::makeAny( nCharWidth );
944 sal_Int32 nRubyHeight = m_nGridLinePitch - nCharWidth;
945 if(nRubyHeight < 0 )
946 nRubyHeight = 0;
947 operator[]( PropertyDefinition( PROP_GRID_RUBY_HEIGHT, false )) = uno::makeAny( nRubyHeight );
948
949 // #i119558#, force to set document as standard page mode,
950 // refer to ww8 import process function "SwWW8ImplReader::SetDocumentGrid"
951 try
952 {
953 uno::Reference< beans::XPropertySet > xDocProperties;
954 xDocProperties = uno::Reference< beans::XPropertySet >( rDM_Impl.GetTextDocument(), uno::UNO_QUERY_THROW );
955 sal_Bool bSquaredPageMode = sal_False;
956 operator[]( PropertyDefinition( PROP_GRID_STANDARD_MODE, false )) = uno::makeAny( !bSquaredPageMode );
957 xDocProperties->setPropertyValue( rtl::OUString::createFromAscii("DefaultPageMode"), uno::makeAny( bSquaredPageMode ));
958 }
959 catch (const uno::Exception& rEx)
960 {
961 OSL_ENSURE( false, "Exception in SectionPropertyMap::CloseSectionGroup");
962 (void)rEx;
963 }
964
965 _ApplyProperties( xFollowPageStyle );
966
967 //todo: creating a "First Page" style depends on HasTitlePage und _fFacingPage_
968 if( m_bTitlePage )
969 {
970 CopyLastHeaderFooter( true, rDM_Impl );
971 PrepareHeaderFooterProperties( true );
972 uno::Reference< beans::XPropertySet > xFirstPageStyle = GetPageStyle(
973 rDM_Impl.GetPageStyles(), rDM_Impl.GetTextFactory(), true );
974 _ApplyProperties( xFirstPageStyle );
975
976 sal_Int32 nPaperBin = m_nFirstPaperBin >= 0 ? m_nFirstPaperBin : m_nPaperBin >= 0 ? m_nPaperBin : 0;
977 if( nPaperBin )
978 xFollowPageStyle->setPropertyValue( sTrayIndex, uno::makeAny( nPaperBin ) );
979 if( xColumns.is() )
980 xFollowPageStyle->setPropertyValue(
981 rPropNameSupplier.GetName( PROP_TEXT_COLUMNS ), uno::makeAny( xColumns ));
982 }
983
984 ApplyBorderToPageStyles( rDM_Impl.GetPageStyles( ), rDM_Impl.GetTextFactory( ), m_nBorderParams );
985
986 try
987 {
988 // if( m_xStartingRange.is() )
989 {
990 //now apply this break at the first paragraph of this section
991 uno::Reference< beans::XPropertySet > xRangeProperties;
992 if( m_bIsFirstSection )
993 {
994 uno::Reference< container::XEnumerationAccess > xEnumAccess( rDM_Impl.GetBodyText( ), uno::UNO_QUERY_THROW );
995 uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration( );
996 xRangeProperties = uno::Reference< beans::XPropertySet >( xEnum->nextElement( ), uno::UNO_QUERY_THROW );
997 }
998 else if( m_xStartingRange.is() )
999 {
1000 xRangeProperties = uno::Reference< beans::XPropertySet >( m_xStartingRange, uno::UNO_QUERY_THROW );
1001 }
1002 if ( xRangeProperties.is() )
1003 {
1004 /* break type: 0 - No break 1 - New Column 2 - New page 3 - Even page 4 - odd page */
1005 uno::Reference< beans::XPropertySetInfo > xRangePropertiesInfo = xRangeProperties->getPropertySetInfo();
1006 if ( xRangePropertiesInfo->hasPropertyByName( rPropNameSupplier.GetName( PROP_PAGE_DESC_NAME ) ) )
1007 {
1008 xRangeProperties->setPropertyValue(
1009 rPropNameSupplier.GetName( PROP_PAGE_DESC_NAME ),
1010 uno::makeAny( m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName ) );
1011 // todo: page breaks with odd/even page numbering are not available - find out current page number to check how to change the number
1012 // or add even/odd page break types
1013 if ( m_bPageNoRestart || m_nPageNumber >= 0 )
1014 {
1015 sal_Int16 nPageNumber = m_nPageNumber >= 0 ? static_cast< sal_Int16 >(m_nPageNumber) : 1;
1016 xRangeProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_PAGE_NUMBER_OFFSET ),
1017 uno::makeAny( nPageNumber ));
1018 }
1019 }
1020 }
1021 }
1022 }
1023 catch( const uno::Exception& rEx)
1024 {
1025 OSL_ENSURE( false, "Exception in SectionPropertyMap::CloseSectionGroup");
1026 (void)rEx;
1027 }
1028 }
1029 }
1030 /*-- 11.12.2006 08:31:46---------------------------------------------------
1031
1032 -----------------------------------------------------------------------*/
_ApplyProperties(uno::Reference<beans::XPropertySet> xStyle)1033 void SectionPropertyMap::_ApplyProperties( uno::Reference< beans::XPropertySet > xStyle )
1034 {
1035 PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
1036 PropertyMap::iterator aMapIter = begin();
1037 while( aMapIter != end())
1038 {
1039 try
1040 {
1041 xStyle->setPropertyValue( rPropNameSupplier.GetName( aMapIter->first.eId ), aMapIter->second );
1042 }
1043 catch( const uno::Exception& )
1044 {
1045 OSL_ENSURE( false, "Exception in <PageStyle>::setPropertyValue");
1046 }
1047 ++aMapIter;
1048 }
1049 }
lcl_AlignPaperBin(sal_Int32 nSet)1050 sal_Int32 lcl_AlignPaperBin( sal_Int32 nSet )
1051 {
1052 //default tray numbers are above 0xff
1053 if( nSet > 0xff )
1054 nSet = nSet >> 8;
1055 //there are some special numbers which can't be handled easily
1056 //1, 4, 15, manual tray, upper tray, auto select? see ww8atr.cxx
1057 //todo: find out appropriate conversion
1058 return nSet;
1059 }
1060 /*-- 13.12.2006 15:34:01---------------------------------------------------
1061
1062 -----------------------------------------------------------------------*/
SetPaperBin(sal_Int32 nSet)1063 void SectionPropertyMap::SetPaperBin( sal_Int32 nSet )
1064 {
1065 m_nPaperBin = lcl_AlignPaperBin( nSet );
1066 }
1067 /*-- 13.12.2006 15:34:01---------------------------------------------------
1068
1069 -----------------------------------------------------------------------*/
SetFirstPaperBin(sal_Int32 nSet)1070 void SectionPropertyMap::SetFirstPaperBin( sal_Int32 nSet )
1071 {
1072 m_nFirstPaperBin = lcl_AlignPaperBin( nSet );
1073 }
1074 /*-- 14.06.2007 13:57:42---------------------------------------------------
1075
1076 -----------------------------------------------------------------------*/
StyleSheetPropertyMap()1077 StyleSheetPropertyMap::StyleSheetPropertyMap() :
1078 // mnCT_Spacing_after( 0 ),
1079 mnCT_Spacing_line( 0 ),
1080 mnCT_Spacing_lineRule( 0 ),
1081 mbCT_TrPrBase_tblHeader( false ),
1082 mnCT_TrPrBase_jc( 0 ),
1083 mnCT_TcPrBase_vAlign( 0 ),
1084 mnCT_TblWidth_w( 0 ),
1085 mnCT_TblWidth_type( 0 ),
1086 // mbCT_Spacing_afterSet( false ),
1087 mbCT_Spacing_lineSet( false ),
1088 mbCT_Spacing_lineRuleSet( false ),
1089 mbCT_TrPrBase_tblHeaderSet( false ),
1090 mbCT_TrPrBase_jcSet( false ),
1091 mbCT_TcPrBase_vAlignSet( false ),
1092 mbCT_TblWidth_wSet( false ),
1093 mbCT_TblWidth_typeSet( false ),
1094 mnListId( -1 ),
1095 mnListLevel( -1 ),
1096 mnOutlineLevel( 0 )
1097 {
1098 }
1099 /*-- 14.06.2007 13:57:43---------------------------------------------------
1100
1101 -----------------------------------------------------------------------*/
~StyleSheetPropertyMap()1102 StyleSheetPropertyMap::~StyleSheetPropertyMap()
1103 {
1104 }
1105 /*-- 28.12.2007 08:19:00---------------------------------------------------
1106
1107 -----------------------------------------------------------------------*/
ParagraphProperties()1108 ParagraphProperties::ParagraphProperties() :
1109 m_bFrameMode( false ),
1110 m_nDropCap(NS_ooxml::LN_Value_wordprocessingml_ST_DropCap_none),
1111 m_nLines(0),
1112 m_w(-1),
1113 m_h(-1),
1114 m_nWrap(-1),
1115 m_hAnchor(-1),
1116 m_vAnchor(text::RelOrientation::FRAME),
1117 m_x(-1),
1118 m_bxValid( false ),
1119 m_y(-1),
1120 m_byValid( false ),
1121 m_hSpace(-1),
1122 m_vSpace(-1),
1123 m_hRule(-1),
1124 m_xAlign(-1),
1125 m_yAlign(-1),
1126 m_bAnchorLock(false),
1127 m_nDropCapLength(0)
1128 {
1129 }
1130 /*-- 28.12.2007 08:28:24---------------------------------------------------
1131
1132 -----------------------------------------------------------------------*/
ParagraphProperties(const ParagraphProperties & rCopy)1133 ParagraphProperties::ParagraphProperties(const ParagraphProperties& rCopy) :
1134 m_bFrameMode ( rCopy.m_bFrameMode),
1135 m_nDropCap ( rCopy.m_nDropCap),
1136 m_nLines ( rCopy.m_nLines),
1137 m_w ( rCopy.m_w),
1138 m_h ( rCopy.m_h),
1139 m_nWrap ( rCopy.m_nWrap),
1140 m_hAnchor ( rCopy.m_hAnchor),
1141 m_vAnchor ( rCopy.m_vAnchor),
1142 m_x ( rCopy.m_x),
1143 m_bxValid ( rCopy.m_bxValid),
1144 m_y ( rCopy.m_y),
1145 m_byValid ( rCopy.m_byValid),
1146 m_hSpace ( rCopy.m_hSpace),
1147 m_vSpace ( rCopy.m_vSpace),
1148 m_hRule ( rCopy.m_hRule),
1149 m_xAlign ( rCopy.m_xAlign),
1150 m_yAlign ( rCopy.m_yAlign),
1151 m_bAnchorLock( rCopy.m_bAnchorLock),
1152 m_nDropCapLength( rCopy.m_nDropCapLength ),
1153 m_sParaStyleName( rCopy.m_sParaStyleName),
1154 m_xStartingRange( rCopy.m_xStartingRange ),
1155 m_xEndingRange( rCopy.m_xEndingRange)
1156 {
1157 }
1158 /*-- 28.12.2007 11:29:18---------------------------------------------------
1159
1160 -----------------------------------------------------------------------*/
~ParagraphProperties()1161 ParagraphProperties::~ParagraphProperties()
1162 {
1163 }
1164 /*-- 28.12.2007 09:05:45---------------------------------------------------
1165
1166 -----------------------------------------------------------------------*/
operator ==(const ParagraphProperties & rCompare)1167 int ParagraphProperties::operator==(const ParagraphProperties& rCompare)
1168 {
1169 return
1170 m_bFrameMode == rCompare.m_bFrameMode &&
1171 m_nDropCap == rCompare.m_nDropCap &&
1172 m_nLines == rCompare.m_nLines &&
1173 m_w == rCompare.m_w &&
1174 m_h == rCompare.m_h &&
1175 m_nWrap == rCompare.m_nWrap &&
1176 m_hAnchor == rCompare.m_hAnchor &&
1177 m_vAnchor == rCompare.m_vAnchor &&
1178 m_x == rCompare.m_x &&
1179 m_bxValid == rCompare.m_bxValid &&
1180 m_y == rCompare.m_y &&
1181 m_byValid == rCompare.m_byValid &&
1182 m_hSpace == rCompare.m_hSpace &&
1183 m_vSpace == rCompare.m_vSpace &&
1184 m_hRule == rCompare.m_hRule &&
1185 m_xAlign == rCompare.m_xAlign &&
1186 m_yAlign == rCompare.m_yAlign &&
1187 m_bAnchorLock== rCompare.m_bAnchorLock;
1188 }
1189 /*-- 27.12.2007 13:32:36---------------------------------------------------
1190
1191 -----------------------------------------------------------------------*/
ParagraphPropertyMap()1192 ParagraphPropertyMap::ParagraphPropertyMap()
1193 {
1194 }
1195 /*-- 27.12.2007 13:32:36---------------------------------------------------
1196
1197 -----------------------------------------------------------------------*/
~ParagraphPropertyMap()1198 ParagraphPropertyMap::~ParagraphPropertyMap()
1199 {
1200 }
1201 /*-- 15.02.2008 16:10:39---------------------------------------------------
1202
1203 -----------------------------------------------------------------------*/
TablePropertyMap()1204 TablePropertyMap::TablePropertyMap()
1205 {
1206 }
1207 /*-- 15.02.2008 16:10:39---------------------------------------------------
1208
1209 -----------------------------------------------------------------------*/
~TablePropertyMap()1210 TablePropertyMap::~TablePropertyMap()
1211 {
1212 }
1213 /*-- 18.02.2008 10:06:30---------------------------------------------------
1214
1215 -----------------------------------------------------------------------*/
getValue(TablePropertyMapTarget eWhich,sal_Int32 & nFill)1216 bool TablePropertyMap::getValue( TablePropertyMapTarget eWhich, sal_Int32& nFill )
1217 {
1218 if( eWhich < TablePropertyMapTarget_MAX )
1219 {
1220 if(m_aValidValues[eWhich].bValid)
1221 nFill = m_aValidValues[eWhich].nValue;
1222 return m_aValidValues[eWhich].bValid;
1223 }
1224 else
1225 {
1226 OSL_ENSURE( false, "invalid TablePropertyMapTarget");
1227 return false;
1228 }
1229 }
1230 /*-- 18.02.2008 10:07:11---------------------------------------------------
1231
1232 -----------------------------------------------------------------------*/
setValue(TablePropertyMapTarget eWhich,sal_Int32 nSet)1233 void TablePropertyMap::setValue( TablePropertyMapTarget eWhich, sal_Int32 nSet )
1234 {
1235 if( eWhich < TablePropertyMapTarget_MAX )
1236 {
1237 m_aValidValues[eWhich].bValid = true;
1238 m_aValidValues[eWhich].nValue = nSet;
1239 }
1240 else
1241 OSL_ENSURE( false, "invalid TablePropertyMapTarget");
1242 }
1243 /*-- 18.02.2008 11:23:28---------------------------------------------------
1244
1245 -----------------------------------------------------------------------*/
insertTableProperties(const PropertyMap * pMap)1246 void TablePropertyMap::insertTableProperties( const PropertyMap* pMap )
1247 {
1248 #ifdef DEBUG_DOMAINMAPPER
1249 dmapper_logger->startElement("TablePropertyMap.insertTableProperties");
1250 dmapper_logger->addTag(pMap->toTag());
1251 #endif
1252
1253 const TablePropertyMap* pSource = dynamic_cast< const TablePropertyMap* >(pMap);
1254 if( pSource )
1255 {
1256 for( sal_Int32 eTarget = TablePropertyMapTarget_START;
1257 eTarget < TablePropertyMapTarget_MAX; ++eTarget )
1258 {
1259 if( pSource->m_aValidValues[eTarget].bValid )
1260 {
1261 m_aValidValues[eTarget].bValid = true;
1262 m_aValidValues[eTarget].nValue = pSource->m_aValidValues[eTarget].nValue;
1263 }
1264 }
1265 }
1266 #ifdef DEBUG_DOMAINMAPPER
1267 dmapper_logger->addTag(toTag());
1268 dmapper_logger->endElement("TablePropertyMap.insertTableProperties");
1269 #endif
1270 }
1271
1272
1273 }//namespace dmapper
1274 }//namespace writerfilter
1275