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 "ConversionHelper.hxx"
20 : #include "NumberingManager.hxx"
21 : #include "StyleSheetTable.hxx"
22 : #include "PropertyIds.hxx"
23 :
24 : #include <doctok/resourceids.hxx>
25 : #include <doctok/sprmids.hxx>
26 : #include <ooxml/resourceids.hxx>
27 :
28 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 : #include <com/sun/star/container/XNameContainer.hpp>
30 : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
31 : #include <com/sun/star/style/NumberingType.hpp>
32 : #include <com/sun/star/text/HoriOrientation.hpp>
33 : #include <com/sun/star/text/PositionAndSpaceMode.hpp>
34 : #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
35 :
36 : #include <rtl/ustring.hxx>
37 :
38 : #include "dmapperLoggers.hxx"
39 :
40 : using namespace com::sun::star;
41 :
42 : #define MAKE_PROPVAL(NameId, Value) \
43 : beans::PropertyValue(aPropNameSupplier.GetName(NameId), 0, uno::makeAny(Value), beans::PropertyState_DIRECT_VALUE )
44 :
45 : #define NUMBERING_MAX_LEVELS 10
46 :
47 :
48 : namespace writerfilter {
49 : namespace dmapper {
50 :
51 : //--------------------------------------------------- Utility functions
52 :
53 0 : void lcl_printProperties( uno::Sequence< beans::PropertyValue > aProps )
54 : {
55 0 : sal_Int32 nLen = aProps.getLength( );
56 0 : for ( sal_Int32 i = 0; i < nLen; i++ )
57 : {
58 0 : uno::Any aValue = aProps[i].Value;
59 0 : sal_Int32 nValue = 0;
60 0 : OUString sValue;
61 :
62 0 : if ( !( aValue >>= sValue ) && ( aValue >>= nValue ) )
63 0 : sValue = OUString::valueOf( nValue );
64 :
65 : SAL_INFO("writerfilter", "Property " << aProps[i].Name << ": " << sValue);
66 0 : }
67 0 : }
68 :
69 213 : sal_Int32 lcl_findProperty( uno::Sequence< beans::PropertyValue > aProps, OUString sName )
70 : {
71 213 : sal_Int32 i = 0;
72 213 : sal_Int32 nLen = aProps.getLength( );
73 213 : sal_Int32 nPos = -1;
74 :
75 1759 : while ( nPos == -1 && i < nLen )
76 : {
77 1333 : if ( aProps[i].Name.equals( sName ) )
78 191 : nPos = i;
79 : else
80 1142 : i++;
81 : }
82 :
83 213 : return nPos;
84 : }
85 :
86 28 : void lcl_mergeProperties( uno::Sequence< beans::PropertyValue >& aSrc,
87 : uno::Sequence< beans::PropertyValue >& aDst )
88 : {
89 117 : for ( sal_Int32 i = 0, nSrcLen = aSrc.getLength( ); i < nSrcLen; i++ )
90 : {
91 : // Look for the same property in aDst
92 89 : sal_Int32 nPos = lcl_findProperty( aDst, aSrc[i].Name );
93 89 : if ( nPos >= 0 )
94 : {
95 : // Replace the property value by the one in aSrc
96 67 : aDst[nPos] = aSrc[i];
97 : }
98 : else
99 : {
100 : // Simply add the new value
101 22 : aDst.realloc( aDst.getLength( ) + 1 );
102 22 : aDst[ aDst.getLength( ) - 1 ] = aSrc[i];
103 : }
104 : }
105 28 : }
106 :
107 : //-------------------------------------------- ListLevel implementation
108 2191 : void ListLevel::SetValue( Id nId, sal_Int32 nValue )
109 : {
110 2191 : switch( nId )
111 : {
112 : case NS_rtf::LN_ISTARTAT:
113 777 : m_nIStartAt = nValue;
114 777 : break;
115 : case NS_rtf::LN_NFC:
116 782 : m_nNFC = nValue;
117 782 : break;
118 : case NS_rtf::LN_JC:
119 0 : m_nJC = nValue;
120 0 : break;
121 : case NS_rtf::LN_FLEGAL:
122 0 : m_nFLegal = nValue;
123 0 : break;
124 : case NS_rtf::LN_FNORESTART:
125 0 : m_nFNoRestart = nValue;
126 0 : break;
127 : case NS_rtf::LN_FIDENTSAV:
128 0 : m_nFPrev = nValue;
129 0 : break;
130 : case NS_rtf::LN_FCONVERTED:
131 10 : m_nFPrevSpace = nValue;
132 10 : break;
133 : case NS_rtf::LN_IXCHFOLLOW:
134 : case NS_ooxml::LN_CT_Lvl_suff:
135 96 : m_nXChFollow = nValue;
136 96 : break;
137 : case NS_ooxml::LN_CT_TabStop_pos:
138 526 : if (nValue < 0)
139 : {
140 : SAL_INFO("writerfilter",
141 : "unsupported list tab stop position " << nValue);
142 : }
143 : else
144 526 : m_nTabstop = nValue;
145 526 : break;
146 : default:
147 : OSL_FAIL( "this line should never be reached");
148 : }
149 2191 : }
150 :
151 25 : void ListLevel::SetParaStyle( boost::shared_ptr< StyleSheetEntry > pStyle )
152 : {
153 25 : if (!pStyle)
154 25 : return;
155 25 : m_pParaStyle = pStyle;
156 : // AFAICT .docx spec does not identify which numberings or paragraph
157 : // styles are actually the ones to be used for outlines (chapter numbering),
158 : // it only kind of says somewhere that they should be named Heading1 to Heading9.
159 25 : const OUString styleId = pStyle->sStyleIdentifierD;
160 25 : m_outline = ( styleId.getLength() == RTL_CONSTASCII_LENGTH( "Heading1" )
161 3 : && styleId.match( "Heading", 0 )
162 3 : && styleId[ RTL_CONSTASCII_LENGTH( "Heading" ) ] >= '1'
163 28 : && styleId[ RTL_CONSTASCII_LENGTH( "Heading" ) ] <= '9' );
164 : }
165 :
166 945 : sal_Int16 ListLevel::GetParentNumbering( OUString sText, sal_Int16 nLevel,
167 : OUString& rPrefix, OUString& rSuffix )
168 : {
169 945 : sal_Int16 nParentNumbering = 1;
170 :
171 : //now parse the text to find %n from %1 to %nLevel+1
172 : //everything before the first % and the last %x is prefix and suffix
173 945 : OUString sLevelText( sText );
174 945 : sal_Int32 nCurrentIndex = 0;
175 945 : sal_Int32 nFound = sLevelText.indexOf( '%', nCurrentIndex );
176 945 : if( nFound > 0 )
177 : {
178 15 : rPrefix = sLevelText.copy( 0, nFound );
179 15 : sLevelText = sLevelText.copy( nFound );
180 : }
181 945 : sal_Int32 nMinLevel = nLevel;
182 : //now the text should either be empty or start with %
183 945 : nFound = sLevelText.getLength( ) > 1 ? 0 : -1;
184 3838 : while( nFound >= 0 )
185 : {
186 1948 : if( sLevelText.getLength() > 1 )
187 : {
188 1948 : sal_Unicode cLevel = sLevelText.getStr()[1];
189 1948 : if( cLevel >= '1' && cLevel <= '9' )
190 : {
191 1258 : if( cLevel - '1' < nMinLevel )
192 155 : nMinLevel = cLevel - '1';
193 : //remove first char - next char is removed later
194 1258 : sLevelText = sLevelText.copy( 1 );
195 : }
196 : }
197 : //remove old '%' or number
198 1948 : sLevelText = sLevelText.copy( 1 );
199 1948 : nCurrentIndex = 0;
200 1948 : nFound = sLevelText.indexOf( '%', nCurrentIndex );
201 : //remove the text before the next %
202 1948 : if(nFound > 0)
203 690 : sLevelText = sLevelText.copy( nFound -1 );
204 : }
205 945 : if( nMinLevel < nLevel )
206 : {
207 155 : nParentNumbering = sal_Int16( nLevel - nMinLevel + 1);
208 : }
209 :
210 945 : rSuffix = sLevelText;
211 :
212 945 : return nParentNumbering;
213 : }
214 :
215 959 : uno::Sequence< beans::PropertyValue > ListLevel::GetProperties( )
216 : {
217 959 : uno::Sequence< beans::PropertyValue > aLevelProps = GetLevelProperties( );
218 959 : if ( m_pParaStyle.get( ) )
219 62 : AddParaProperties( &aLevelProps );
220 959 : return aLevelProps;
221 : }
222 :
223 959 : uno::Sequence< beans::PropertyValue > ListLevel::GetCharStyleProperties( )
224 : {
225 959 : PropertyValueVector_t rProperties;
226 959 : PropertyNameSupplier& aPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
227 :
228 959 : _PropertyMap::const_iterator aMapIter = begin();
229 959 : _PropertyMap::const_iterator aEndIter = end();
230 4532 : for( ; aMapIter != aEndIter; ++aMapIter )
231 : {
232 3573 : switch( aMapIter->first.eId )
233 : {
234 : case PROP_ADJUST:
235 : case PROP_INDENT_AT:
236 : case PROP_FIRST_LINE_INDENT:
237 : case PROP_FIRST_LINE_OFFSET:
238 : case PROP_LEFT_MARGIN:
239 : case PROP_CHAR_FONT_NAME:
240 : // Do nothing: handled in the GetPropertyValues method
241 3088 : break;
242 : default:
243 : {
244 : rProperties.push_back(
245 : beans::PropertyValue(
246 485 : aPropNameSupplier.GetName( aMapIter->first.eId ), 0,
247 970 : aMapIter->second, beans::PropertyState_DIRECT_VALUE ));
248 : }
249 : }
250 : }
251 :
252 959 : uno::Sequence< beans::PropertyValue > aRet( rProperties.size() );
253 959 : beans::PropertyValue* pValues = aRet.getArray();
254 959 : PropertyValueVector_t::const_iterator aIt = rProperties.begin();
255 959 : PropertyValueVector_t::const_iterator aEndIt = rProperties.end();
256 1444 : for(sal_uInt32 nIndex = 0; aIt != aEndIt; ++aIt,++nIndex)
257 : {
258 485 : pValues[nIndex] = *aIt;
259 : }
260 959 : return aRet;
261 : }
262 :
263 959 : uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( )
264 : {
265 : const sal_Int16 aWWToUnoAdjust[] =
266 : {
267 : text::HoriOrientation::LEFT,
268 : text::HoriOrientation::CENTER,
269 : text::HoriOrientation::RIGHT,
270 959 : };
271 :
272 959 : PropertyNameSupplier& aPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
273 959 : PropertyValueVector_t aNumberingProperties;
274 :
275 959 : if( m_nIStartAt >= 0)
276 952 : aNumberingProperties.push_back( MAKE_PROPVAL(PROP_START_WITH, (sal_Int16)m_nIStartAt) );
277 :
278 959 : sal_Int16 nNumberFormat = ConversionHelper::ConvertNumberingType(m_nNFC);
279 959 : if( m_nNFC >= 0)
280 : {
281 959 : if (!m_sGraphicURL.isEmpty() || m_sGraphicBitmap.is())
282 9 : nNumberFormat = style::NumberingType::BITMAP;
283 959 : aNumberingProperties.push_back( MAKE_PROPVAL(PROP_NUMBERING_TYPE, nNumberFormat ));
284 : }
285 :
286 959 : if( m_nJC >= 0 && m_nJC <= sal::static_int_cast<sal_Int32>(sizeof(aWWToUnoAdjust) / sizeof(sal_Int16)) )
287 0 : aNumberingProperties.push_back( MAKE_PROPVAL(PROP_ADJUST, aWWToUnoAdjust[m_nJC]));
288 :
289 959 : if( !isOutlineNumbering())
290 : {
291 : // todo: this is not the bullet char
292 956 : if( nNumberFormat == style::NumberingType::CHAR_SPECIAL && !m_sBulletChar.isEmpty() )
293 324 : aNumberingProperties.push_back( MAKE_PROPVAL(PROP_BULLET_CHAR, m_sBulletChar.copy(0,1)));
294 956 : if (!m_sGraphicURL.isEmpty())
295 5 : aNumberingProperties.push_back(MAKE_PROPVAL(PROP_GRAPHIC_URL, m_sGraphicURL));
296 956 : if (m_sGraphicBitmap.is())
297 9 : aNumberingProperties.push_back(MAKE_PROPVAL(PROP_GRAPHIC_BITMAP, m_sGraphicBitmap));
298 : }
299 :
300 959 : aNumberingProperties.push_back( MAKE_PROPVAL( PROP_LISTTAB_STOP_POSITION, m_nTabstop ) );
301 :
302 : //TODO: handling of nFLegal?
303 : //TODO: nFNoRestart lower levels do not restart when higher levels are incremented, like:
304 : //1.
305 : //1.1
306 : //2.2
307 : //2.3
308 : //3.4
309 : //
310 :
311 959 : if( m_nFWord6 > 0) //Word 6 compatibility
312 : {
313 0 : if( m_nFPrev == 1)
314 0 : aNumberingProperties.push_back( MAKE_PROPVAL( PROP_PARENT_NUMBERING, (sal_Int16) NUMBERING_MAX_LEVELS ));
315 : //TODO: prefixing space nFPrevSpace; - has not been used in WW8 filter
316 : }
317 :
318 : // TODO: sRGBXchNums; array of inherited numbers
319 :
320 : // nXChFollow; following character 0 - tab, 1 - space, 2 - nothing
321 959 : aNumberingProperties.push_back( MAKE_PROPVAL( PROP_LEVEL_FOLLOW, m_nXChFollow ));
322 :
323 :
324 959 : _PropertyMap::const_iterator aMapIter = begin();
325 959 : _PropertyMap::const_iterator aEndIter = end();
326 4532 : for( ; aMapIter != aEndIter; ++aMapIter )
327 : {
328 3573 : switch( aMapIter->first.eId )
329 : {
330 : case PROP_ADJUST:
331 : case PROP_INDENT_AT:
332 : case PROP_FIRST_LINE_INDENT:
333 : case PROP_FIRST_LINE_OFFSET:
334 : case PROP_LEFT_MARGIN:
335 : aNumberingProperties.push_back(
336 2751 : beans::PropertyValue( aPropNameSupplier.GetName( aMapIter->first.eId ), 0, aMapIter->second, beans::PropertyState_DIRECT_VALUE ));
337 2751 : break;
338 : case PROP_CHAR_FONT_NAME:
339 337 : if( !isOutlineNumbering())
340 : {
341 : aNumberingProperties.push_back(
342 337 : beans::PropertyValue( aPropNameSupplier.GetName( PROP_BULLET_FONT_NAME ), 0, aMapIter->second, beans::PropertyState_DIRECT_VALUE ));
343 : }
344 337 : break;
345 : default:
346 : {
347 : // Handled in GetCharStyleProperties method
348 : }
349 :
350 : }
351 : }
352 :
353 959 : uno::Sequence< beans::PropertyValue > aRet(aNumberingProperties.size());
354 959 : beans::PropertyValue* pValues = aRet.getArray();
355 959 : PropertyValueVector_t::const_iterator aIt = aNumberingProperties.begin();
356 959 : PropertyValueVector_t::const_iterator aEndIt = aNumberingProperties.end();
357 8214 : for(sal_uInt32 nIndex = 0; aIt != aEndIt; ++aIt,++nIndex)
358 : {
359 7255 : pValues[nIndex] = *aIt;
360 : }
361 959 : return aRet;
362 : }
363 :
364 : // Add the properties only if they do not already exist in the sequence.
365 62 : void ListLevel::AddParaProperties( uno::Sequence< beans::PropertyValue >* props )
366 : {
367 62 : uno::Sequence< beans::PropertyValue >& aProps = *props;
368 62 : PropertyNameSupplier& aPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
369 :
370 : OUString sFirstLineIndent = aPropNameSupplier.GetName(
371 62 : PROP_FIRST_LINE_INDENT );
372 : OUString sIndentAt = aPropNameSupplier.GetName(
373 62 : PROP_INDENT_AT );
374 :
375 62 : bool hasFirstLineIndent = lcl_findProperty( aProps, sFirstLineIndent );
376 62 : bool hasIndentAt = lcl_findProperty( aProps, sIndentAt );
377 :
378 62 : if( hasFirstLineIndent && hasIndentAt )
379 124 : return; // has them all, nothing to add
380 :
381 0 : uno::Sequence< beans::PropertyValue > aParaProps = m_pParaStyle->pProperties->GetPropertyValues( );
382 :
383 : // ParaFirstLineIndent -> FirstLineIndent
384 : // ParaLeftMargin -> IndentAt
385 :
386 : OUString sParaIndent = aPropNameSupplier.GetName(
387 0 : PROP_PARA_FIRST_LINE_INDENT );
388 : OUString sParaLeftMargin = aPropNameSupplier.GetName(
389 0 : PROP_PARA_LEFT_MARGIN );
390 :
391 0 : sal_Int32 nLen = aParaProps.getLength( );
392 0 : for ( sal_Int32 i = 0; i < nLen; i++ )
393 : {
394 0 : if ( !hasFirstLineIndent && aParaProps[i].Name.equals( sParaIndent ) )
395 : {
396 0 : aProps.realloc( aProps.getLength() + 1 );
397 0 : aProps[aProps.getLength( ) - 1] = aParaProps[i];
398 0 : aProps[aProps.getLength( ) - 1].Name = sFirstLineIndent;
399 : }
400 0 : else if ( !hasIndentAt && aParaProps[i].Name.equals( sParaLeftMargin ) )
401 : {
402 0 : aProps.realloc( aProps.getLength() + 1 );
403 0 : aProps[aProps.getLength( ) - 1] = aParaProps[i];
404 0 : aProps[aProps.getLength( ) - 1].Name = sIndentAt;
405 : }
406 :
407 0 : }
408 : }
409 :
410 9 : NumPicBullet::NumPicBullet()
411 9 : : m_nId(0)
412 : {
413 9 : }
414 :
415 18 : NumPicBullet::~NumPicBullet()
416 : {
417 18 : }
418 :
419 9 : void NumPicBullet::SetId(sal_Int32 nId)
420 : {
421 9 : m_nId = nId;
422 9 : }
423 :
424 9 : void NumPicBullet::SetShape(uno::Reference<drawing::XShape> xShape)
425 : {
426 9 : m_xShape = xShape;
427 9 : }
428 :
429 23 : sal_Int32 NumPicBullet::GetId()
430 : {
431 23 : return m_nId;
432 : }
433 :
434 17 : uno::Reference<drawing::XShape> NumPicBullet::GetShape()
435 : {
436 17 : return m_xShape;
437 : }
438 :
439 : //--------------------------------------- AbstractListDef implementation
440 :
441 279 : AbstractListDef::AbstractListDef( ) :
442 : m_nTPLC( -1 )
443 : ,m_nSimpleList( -1 )
444 : ,m_nRestart( -1 )
445 : ,m_nUnsigned( -1 )
446 279 : ,m_nId( -1 )
447 : {
448 279 : }
449 :
450 396 : AbstractListDef::~AbstractListDef( )
451 : {
452 396 : }
453 :
454 95 : void AbstractListDef::SetValue( sal_uInt32 nSprmId, sal_Int32 nValue )
455 : {
456 95 : switch( nSprmId )
457 : {
458 : case NS_rtf::LN_TPLC:
459 95 : m_nTPLC = nValue;
460 95 : break;
461 : case NS_rtf::LN_FSIMPLELIST:
462 0 : m_nSimpleList = nValue;
463 0 : break;
464 : case NS_rtf::LN_fAutoNum:
465 0 : m_nRestart = nValue;
466 0 : break;
467 : case NS_rtf::LN_fHybrid:
468 0 : m_nUnsigned = nValue;
469 0 : break;
470 : default:
471 : OSL_FAIL( "this line should never be reached");
472 : }
473 95 : }
474 :
475 1890 : ListLevel::Pointer AbstractListDef::GetLevel( sal_uInt16 nLvl )
476 : {
477 1890 : ListLevel::Pointer pLevel;
478 1890 : if ( m_aLevels.size( ) > nLvl )
479 959 : pLevel = m_aLevels[ nLvl ];
480 1890 : return pLevel;
481 : }
482 :
483 782 : void AbstractListDef::AddLevel( )
484 : {
485 782 : ListLevel::Pointer pLevel( new ListLevel );
486 782 : m_pCurrentLevel = pLevel;
487 782 : m_aLevels.push_back( pLevel );
488 782 : }
489 :
490 316 : uno::Sequence< uno::Sequence< beans::PropertyValue > > AbstractListDef::GetPropertyValues( )
491 : {
492 316 : uno::Sequence< uno::Sequence< beans::PropertyValue > > result( sal_Int32( m_aLevels.size( ) ) );
493 316 : uno::Sequence< beans::PropertyValue >* aResult = result.getArray( );
494 :
495 316 : int nLevels = m_aLevels.size( );
496 1275 : for ( int i = 0; i < nLevels; i++ )
497 : {
498 959 : aResult[i] = m_aLevels[i]->GetProperties( );
499 : }
500 :
501 316 : return result;
502 : }
503 :
504 : //---------------------------------------------- ListDef implementation
505 :
506 162 : ListDef::ListDef( ) : AbstractListDef( )
507 : {
508 162 : }
509 :
510 324 : ListDef::~ListDef( )
511 : {
512 324 : }
513 :
514 171 : OUString ListDef::GetStyleName( sal_Int32 nId )
515 : {
516 171 : OUString sStyleName( "WWNum" );
517 171 : sStyleName += OUString::valueOf( nId );
518 :
519 171 : return sStyleName;
520 : }
521 :
522 158 : uno::Sequence< uno::Sequence< beans::PropertyValue > > ListDef::GetPropertyValues( )
523 : {
524 : // [1] Call the same method on the abstract list
525 158 : uno::Sequence< uno::Sequence< beans::PropertyValue > > aAbstract = m_pAbstractDef->GetPropertyValues( );
526 :
527 : // [2] Call the upper class method
528 316 : uno::Sequence< uno::Sequence< beans::PropertyValue > > aThis = AbstractListDef::GetPropertyValues( );
529 :
530 : // Merge the results of [2] in [1]
531 158 : sal_Int32 nThisCount = aThis.getLength( );
532 158 : sal_Int32 nAbstractCount = aAbstract.getLength( );
533 172 : for ( sal_Int32 i = 0; i < nThisCount && i < nAbstractCount; i++ )
534 : {
535 14 : uno::Sequence< beans::PropertyValue > level = aThis[i];
536 14 : if ( level.hasElements() )
537 : {
538 : // If the element contains something, merge it
539 14 : lcl_mergeProperties( level, aAbstract[i] );
540 : }
541 14 : }
542 :
543 316 : return aAbstract;
544 : }
545 :
546 165 : uno::Reference< container::XNameContainer > lcl_getUnoNumberingStyles(
547 : uno::Reference< lang::XMultiServiceFactory > xFactory )
548 : {
549 165 : uno::Reference< container::XNameContainer > xStyles;
550 :
551 : try
552 : {
553 165 : uno::Reference< style::XStyleFamiliesSupplier > xFamilies( xFactory, uno::UNO_QUERY_THROW );
554 318 : uno::Any oFamily = xFamilies->getStyleFamilies( )->getByName("NumberingStyles");
555 :
556 318 : oFamily >>= xStyles;
557 : }
558 6 : catch ( const uno::Exception & )
559 : {
560 : }
561 :
562 165 : return xStyles;
563 : }
564 :
565 165 : void ListDef::CreateNumberingRules( DomainMapper& rDMapper,
566 : uno::Reference< lang::XMultiServiceFactory> xFactory )
567 : {
568 : // Get the UNO Numbering styles
569 165 : uno::Reference< container::XNameContainer > xStyles = lcl_getUnoNumberingStyles( xFactory );
570 :
571 : // Do the whole thing
572 165 : if( !m_xNumRules.is() && xFactory.is() && xStyles.is( ) )
573 : {
574 : try
575 : {
576 : // Create the numbering style
577 : uno::Reference< beans::XPropertySet > xStyle (
578 158 : xFactory->createInstance("com.sun.star.style.NumberingStyle"),
579 158 : uno::UNO_QUERY_THROW );
580 :
581 316 : OUString sStyleName = GetStyleName( GetId( ) );
582 :
583 158 : xStyles->insertByName( sStyleName, makeAny( xStyle ) );
584 :
585 316 : uno::Any oStyle = xStyles->getByName( sStyleName );
586 158 : xStyle.set( oStyle, uno::UNO_QUERY_THROW );
587 :
588 158 : PropertyNameSupplier& aPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
589 :
590 : // Get the default OOo Numbering style rules
591 316 : uno::Any aRules = xStyle->getPropertyValue( aPropNameSupplier.GetName( PROP_NUMBERING_RULES ) );
592 158 : aRules >>= m_xNumRules;
593 :
594 316 : uno::Sequence< uno::Sequence< beans::PropertyValue > > aProps = GetPropertyValues( );
595 :
596 158 : sal_Int32 nAbstLevels = m_pAbstractDef->Size( );
597 158 : sal_Int16 nLevel = 0;
598 1261 : while ( nLevel < nAbstLevels )
599 : {
600 945 : ListLevel::Pointer pAbsLevel = m_pAbstractDef->GetLevel( nLevel );
601 1890 : ListLevel::Pointer pLevel = GetLevel( nLevel );
602 :
603 : // Get the merged level properties
604 1890 : uno::Sequence< beans::PropertyValue > aLvlProps = aProps[sal_Int32( nLevel )];
605 :
606 : #if OSL_DEBUG_LEVEL > 1
607 : lcl_printProperties( aLvlProps );
608 : #endif
609 :
610 : // Get the char style
611 1890 : uno::Sequence< beans::PropertyValue > aAbsCharStyleProps = pAbsLevel->GetCharStyleProperties( );
612 945 : uno::Sequence< beans::PropertyValue >& rAbsCharStyleProps = aAbsCharStyleProps;
613 945 : if ( pLevel.get( ) )
614 : {
615 : uno::Sequence< beans::PropertyValue > aCharStyleProps =
616 14 : pLevel->GetCharStyleProperties( );
617 14 : uno::Sequence< beans::PropertyValue >& rCharStyleProps = aCharStyleProps;
618 14 : lcl_mergeProperties( rAbsCharStyleProps, rCharStyleProps );
619 : }
620 :
621 945 : if( aAbsCharStyleProps.getLength() )
622 : {
623 : // Change the sequence into a vector
624 267 : PropertyValueVector_t aStyleProps;
625 750 : for ( sal_Int32 i = 0, nLen = aAbsCharStyleProps.getLength() ; i < nLen; i++ )
626 : {
627 483 : aStyleProps.push_back( aAbsCharStyleProps[i] );
628 : }
629 :
630 : //create (or find) a character style containing the character
631 : // attributes of the symbol and apply it to the numbering level
632 534 : OUString sStyle = rDMapper.getOrCreateCharStyle( aStyleProps );
633 267 : aLvlProps.realloc( aLvlProps.getLength() + 1);
634 267 : aLvlProps[sal::static_int_cast<sal_uInt32>(aLvlProps.getLength()) - 1].Name = aPropNameSupplier.GetName( PROP_CHAR_STYLE_NAME );
635 534 : aLvlProps[sal::static_int_cast<sal_uInt32>(aLvlProps.getLength()) - 1].Value <<= sStyle;
636 : }
637 :
638 : // Get the prefix / suffix / Parent numbering
639 : // and add them to the level properties
640 1890 : OUString sText = pAbsLevel->GetBulletChar( );
641 945 : if ( pLevel.get( ) )
642 14 : sText = pLevel->GetBulletChar( );
643 :
644 1890 : OUString sPrefix;
645 1890 : OUString sSuffix;
646 945 : OUString& rPrefix = sPrefix;
647 945 : OUString& rSuffix = sSuffix;
648 : sal_Int16 nParentNum = ListLevel::GetParentNumbering(
649 945 : sText, nLevel, rPrefix, rSuffix );
650 :
651 945 : aLvlProps.realloc( aLvlProps.getLength( ) + 4 );
652 945 : aLvlProps[sal::static_int_cast<sal_uInt32>(aLvlProps.getLength()) - 4] = MAKE_PROPVAL( PROP_PREFIX, rPrefix );
653 945 : aLvlProps[sal::static_int_cast<sal_uInt32>(aLvlProps.getLength()) - 3] = MAKE_PROPVAL( PROP_SUFFIX, rSuffix );
654 945 : aLvlProps[sal::static_int_cast<sal_uInt32>(aLvlProps.getLength()) - 2] = MAKE_PROPVAL( PROP_PARENT_NUMBERING, nParentNum );
655 :
656 1890 : aLvlProps[sal::static_int_cast<sal_uInt32>(aLvlProps.getLength()) - 1] = MAKE_PROPVAL( PROP_POSITION_AND_SPACE_MODE,
657 945 : sal_Int16( text::PositionAndSpaceMode::LABEL_ALIGNMENT ) );
658 :
659 1890 : StyleSheetEntryPtr pParaStyle = pAbsLevel->GetParaStyle( );
660 945 : if( pParaStyle.get())
661 : {
662 62 : aLvlProps.realloc( aLvlProps.getLength() + 1 );
663 124 : aLvlProps[sal::static_int_cast<sal_uInt32>(aLvlProps.getLength()) - 1] = MAKE_PROPVAL( PROP_PARAGRAPH_STYLE_NAME,
664 62 : pParaStyle->sConvertedStyleName );
665 : }
666 :
667 : // Replace the numbering rules for the level
668 945 : m_xNumRules->replaceByIndex( nLevel, uno::makeAny( aLvlProps ) );
669 :
670 : // Handle the outline level here
671 945 : if ( pAbsLevel->isOutlineNumbering())
672 : {
673 : uno::Reference< text::XChapterNumberingSupplier > xOutlines (
674 3 : xFactory, uno::UNO_QUERY_THROW );
675 : uno::Reference< container::XIndexReplace > xOutlineRules =
676 6 : xOutlines->getChapterNumberingRules( );
677 :
678 3 : aLvlProps.realloc( aLvlProps.getLength() + 1 );
679 6 : aLvlProps[sal::static_int_cast<sal_uInt32>(aLvlProps.getLength()) - 1] = MAKE_PROPVAL( PROP_HEADING_STYLE_NAME,
680 3 : pParaStyle->sConvertedStyleName );
681 :
682 6 : xOutlineRules->replaceByIndex( nLevel, uno::makeAny( aLvlProps ) );
683 : }
684 :
685 945 : nLevel++;
686 945 : }
687 :
688 : // Create the numbering style for these rules
689 316 : OUString sNumRulesName = aPropNameSupplier.GetName( PROP_NUMBERING_RULES );
690 316 : xStyle->setPropertyValue( sNumRulesName, uno::makeAny( m_xNumRules ) );
691 : }
692 0 : catch( const lang::IllegalArgumentException& e )
693 : {
694 : SAL_WARN( "writerfilter", "Exception: " << e.Message );
695 : assert( !"Incorrect argument to UNO call" );
696 : }
697 0 : catch( const uno::RuntimeException& e )
698 : {
699 : SAL_WARN( "writerfilter", "Exception: " << e.Message );
700 : assert( !"Incorrect argument to UNO call" );
701 : }
702 0 : catch( const uno::Exception& e )
703 : {
704 : SAL_WARN( "writerfilter", "Exception: " << e.Message );
705 : }
706 165 : }
707 :
708 165 : }
709 :
710 : //------------------------------------- NumberingManager implementation
711 :
712 :
713 33 : ListsManager::ListsManager(DomainMapper& rDMapper,
714 : const uno::Reference< lang::XMultiServiceFactory > xFactory) :
715 : LoggedProperties(dmapper_logger, "ListsManager"),
716 : LoggedTable(dmapper_logger, "ListsManager"),
717 : m_rDMapper( rDMapper ),
718 33 : m_xFactory( xFactory )
719 : {
720 33 : }
721 :
722 66 : ListsManager::~ListsManager( )
723 : {
724 66 : }
725 :
726 5236 : void ListsManager::lcl_attribute( Id nName, Value& rVal )
727 : {
728 5236 : ListLevel::Pointer pCurrentLvl;
729 :
730 5236 : if (nName != NS_ooxml::LN_CT_NumPicBullet_numPicBulletId)
731 : {
732 : OSL_ENSURE( m_pCurrentDefinition.get(), "current entry has to be set here");
733 5227 : if(!m_pCurrentDefinition.get())
734 0 : return ;
735 5227 : pCurrentLvl = m_pCurrentDefinition->GetCurrentLevel( );
736 : }
737 : else
738 : {
739 : SAL_WARN_IF(!m_pCurrentNumPicBullet.get(), "writerfilter", "current entry has to be set here");
740 9 : if (!m_pCurrentNumPicBullet.get())
741 0 : return;
742 : }
743 5236 : int nIntValue = rVal.getInt();
744 :
745 :
746 :
747 5236 : switch(nName)
748 : {
749 : case NS_rtf::LN_RGBXCHNUMS:
750 0 : if(pCurrentLvl.get())
751 0 : pCurrentLvl->AddRGBXchNums( rVal.getString( ) );
752 0 : break;
753 : case NS_ooxml::LN_CT_LevelText_val:
754 : {
755 : //this strings contains the definition of the level
756 : //the level number is marked as %n
757 : //these numbers can be mixed randomly toghether with separators pre- and suffixes
758 : //the Writer supports only a number of upper levels to show, separators is always a dot
759 : //and each level can have a prefix and a suffix
760 784 : if(pCurrentLvl.get())
761 782 : pCurrentLvl->SetBulletChar( rVal.getString() );
762 : }
763 784 : break;
764 : case NS_rtf::LN_ISTARTAT:
765 : case NS_rtf::LN_NFC:
766 : case NS_rtf::LN_JC:
767 : case NS_rtf::LN_FLEGAL:
768 : case NS_rtf::LN_FNORESTART:
769 : case NS_rtf::LN_FIDENTSAV:
770 : case NS_rtf::LN_FCONVERTED:
771 : case NS_rtf::LN_IXCHFOLLOW:
772 64 : if ( pCurrentLvl.get( ) )
773 60 : pCurrentLvl->SetValue( nName, sal_Int32( nIntValue ) );
774 64 : break;
775 : case NS_rtf::LN_RGISTD:
776 0 : m_pCurrentDefinition->AddRGISTD( rVal.getString() );
777 0 : break;
778 : case NS_ooxml::LN_CT_Num_numId:
779 148 : m_pCurrentDefinition->SetId( rVal.getString().toInt32( ) );
780 148 : break;
781 : case NS_rtf::LN_LSID:
782 14 : m_pCurrentDefinition->SetId( nIntValue );
783 14 : break;
784 : case NS_rtf::LN_TPLC:
785 : case NS_rtf::LN_FSIMPLELIST:
786 : case NS_rtf::LN_fAutoNum:
787 : case NS_rtf::LN_fHybrid:
788 0 : m_pCurrentDefinition->SetValue( nName, nIntValue );
789 0 : break;
790 : case NS_ooxml::LN_CT_NumLvl_ilvl:
791 : case NS_rtf::LN_LISTLEVEL:
792 : {
793 : //add a new level to the level vector and make it the current one
794 14 : m_pCurrentDefinition->AddLevel();
795 :
796 14 : writerfilter::Reference<Properties>::Pointer_t pProperties;
797 14 : if((pProperties = rVal.getProperties()).get())
798 1 : pProperties->resolve(*this);
799 : }
800 14 : break;
801 : case NS_ooxml::LN_CT_AbstractNum_abstractNumId:
802 : {
803 : // This one corresponds to the AbstractNum Id definition
804 : // The reference to the abstract num is in the sprm method
805 117 : sal_Int32 nVal = rVal.getString().toInt32();
806 117 : m_pCurrentDefinition->SetId( nVal );
807 : }
808 117 : break;
809 : case NS_ooxml::LN_CT_Ind_left:
810 701 : pCurrentLvl->Insert(
811 1402 : PROP_INDENT_AT, uno::makeAny( ConversionHelper::convertTwipToMM100( nIntValue ) ));
812 701 : break;
813 : case NS_ooxml::LN_CT_Ind_hanging:
814 709 : pCurrentLvl->Insert(
815 1418 : PROP_FIRST_LINE_INDENT, uno::makeAny( - ConversionHelper::convertTwipToMM100( nIntValue ) ));
816 709 : break;
817 : case NS_ooxml::LN_CT_Ind_firstLine:
818 10 : pCurrentLvl->Insert(
819 20 : PROP_FIRST_LINE_INDENT, uno::makeAny( ConversionHelper::convertTwipToMM100( nIntValue ) ));
820 10 : break;
821 : case NS_ooxml::LN_CT_Lvl_ilvl: //overrides previous level - unsupported
822 : case NS_ooxml::LN_CT_Lvl_tplc: //template code - unsupported
823 : case NS_ooxml::LN_CT_Lvl_tentative: //marks level as unused in the document - unsupported
824 1596 : break;
825 : case NS_ooxml::LN_CT_TabStop_pos:
826 : {
827 : //no paragraph attributes in ListTable char style sheets
828 526 : if ( pCurrentLvl.get( ) )
829 : pCurrentLvl->SetValue( nName,
830 526 : ConversionHelper::convertTwipToMM100( nIntValue ) );
831 : }
832 526 : break;
833 : case NS_ooxml::LN_CT_TabStop_val:
834 : {
835 : // TODO Do something of that
836 : }
837 526 : break;
838 : case NS_ooxml::LN_CT_NumPicBullet_numPicBulletId:
839 9 : m_pCurrentNumPicBullet->SetId(rVal.getString().toInt32());
840 9 : break;
841 : default:
842 : {
843 : #if OSL_DEBUG_LEVEL > 0
844 : OString sMessage( "ListTable::attribute() - Id: ");
845 : sMessage += OString::valueOf( sal_Int32( nName ), 10 );
846 : sMessage += " / 0x";
847 : sMessage += OString::valueOf( sal_Int32( nName ), 16 );
848 : sMessage += " value: ";
849 : sMessage += OString::valueOf( sal_Int32( nIntValue ), 10 );
850 : sMessage += " / 0x";
851 : sMessage += OString::valueOf( sal_Int32( nIntValue ), 16 );
852 : SAL_WARN("writerfilter", sMessage.getStr());
853 : #endif
854 : }
855 5236 : }
856 : }
857 :
858 8035 : void ListsManager::lcl_sprm( Sprm& rSprm )
859 : {
860 : //fill the attributes of the style sheet
861 8035 : sal_uInt32 nSprmId = rSprm.getId();
862 16367 : if( m_pCurrentDefinition.get() ||
863 180 : nSprmId == NS_ooxml::LN_CT_Numbering_abstractNum ||
864 18 : nSprmId == NS_ooxml::LN_CT_Numbering_num ||
865 8044 : (nSprmId == NS_ooxml::LN_CT_NumPicBullet_pict && m_pCurrentNumPicBullet.get()) ||
866 : nSprmId == NS_ooxml::LN_CT_Numbering_numPicBullet)
867 : {
868 8035 : sal_Int32 nIntValue = rSprm.getValue()->getInt();
869 8035 : switch( nSprmId )
870 : {
871 : case NS_ooxml::LN_CT_Numbering_abstractNum:
872 : {
873 117 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
874 117 : if(pProperties.get())
875 : {
876 : //create a new Abstract list entry
877 : OSL_ENSURE( !m_pCurrentDefinition.get(), "current entry has to be NULL here");
878 117 : m_pCurrentDefinition.reset( new AbstractListDef );
879 117 : pProperties->resolve( *this );
880 : //append it to the table
881 117 : m_aAbstractLists.push_back( m_pCurrentDefinition );
882 117 : m_pCurrentDefinition = AbstractListDef::Pointer();
883 117 : }
884 : }
885 117 : break;
886 : case NS_ooxml::LN_CT_Numbering_num:
887 : {
888 162 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
889 162 : if(pProperties.get())
890 : {
891 : // Create a new list entry
892 : OSL_ENSURE( !m_pCurrentDefinition.get(), "current entry has to be NULL here");
893 162 : ListDef::Pointer listDef( new ListDef );
894 162 : m_pCurrentDefinition = listDef;
895 162 : pProperties->resolve( *this );
896 : //append it to the table
897 162 : m_aLists.push_back( listDef );
898 :
899 162 : m_pCurrentDefinition = AbstractListDef::Pointer();
900 162 : }
901 : }
902 162 : break;
903 : case NS_ooxml::LN_CT_Numbering_numPicBullet:
904 : {
905 9 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
906 9 : if (pProperties.get())
907 : {
908 9 : NumPicBullet::Pointer numPicBullet(new NumPicBullet());
909 9 : m_pCurrentNumPicBullet = numPicBullet;
910 9 : pProperties->resolve(*this);
911 9 : m_aNumPicBullets.push_back(numPicBullet);
912 9 : m_pCurrentNumPicBullet = NumPicBullet::Pointer();
913 9 : }
914 : }
915 9 : break;
916 : case NS_ooxml::LN_CT_NumPicBullet_pict:
917 : {
918 9 : uno::Reference<drawing::XShape> xShape = m_rDMapper.PopPendingShape();
919 9 : m_pCurrentNumPicBullet->SetShape(xShape);
920 : }
921 9 : break;
922 : case NS_ooxml::LN_CT_Lvl_lvlPicBulletId:
923 : {
924 17 : uno::Reference<drawing::XShape> xShape;
925 23 : for (std::vector<NumPicBullet::Pointer>::iterator it = m_aNumPicBullets.begin(); it != m_aNumPicBullets.end(); ++it)
926 : {
927 23 : if ((*it)->GetId() == nIntValue)
928 : {
929 17 : xShape = (*it)->GetShape();
930 17 : break;
931 : }
932 : }
933 17 : if (xShape.is())
934 : {
935 17 : uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
936 34 : uno::Reference<beans::XPropertySetInfo> info = xPropertySet->getPropertySetInfo();
937 34 : uno::Sequence<beans::Property> properties = info->getProperties();
938 : try
939 : {
940 21 : uno::Any aAny = xPropertySet->getPropertyValue("GraphicURL");
941 13 : if (aAny.has<OUString>())
942 5 : m_pCurrentDefinition->GetCurrentLevel()->SetGraphicURL(aAny.get<OUString>());
943 4 : } catch(const beans::UnknownPropertyException&)
944 : {}
945 : try
946 : {
947 17 : uno::Reference< graphic::XGraphic > gr;
948 17 : xPropertySet->getPropertyValue("Bitmap") >>= gr;
949 17 : m_pCurrentDefinition->GetCurrentLevel()->SetGraphicBitmap( gr );
950 0 : } catch(const beans::UnknownPropertyException&)
951 : {}
952 :
953 : // Now that we saved the URL of the graphic, remove it from the document.
954 34 : uno::Reference<lang::XComponent> xShapeComponent(xShape, uno::UNO_QUERY);
955 34 : xShapeComponent->dispose();
956 17 : }
957 : }
958 17 : break;
959 : case NS_ooxml::LN_CT_Num_abstractNumId:
960 : {
961 162 : sal_Int32 nAbstractNumId = rSprm.getValue()->getInt();
962 162 : ListDef* pListDef = dynamic_cast< ListDef* >( m_pCurrentDefinition.get( ) );
963 162 : if ( pListDef != NULL )
964 : {
965 : // The current def should be a ListDef
966 : pListDef->SetAbstractDefinition(
967 162 : GetAbstractList( nAbstractNumId ) );
968 : }
969 : }
970 162 : break;
971 : case NS_ooxml::LN_CT_AbstractNum_multiLevelType:
972 96 : break;
973 : case NS_rtf::LN_TPLC:
974 95 : m_pCurrentDefinition->SetValue( nSprmId, nIntValue );
975 95 : break;
976 : case NS_ooxml::LN_CT_AbstractNum_lvl:
977 : {
978 768 : m_pCurrentDefinition->AddLevel();
979 768 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
980 768 : if(pProperties.get())
981 768 : pProperties->resolve(*this);
982 : }
983 768 : break;
984 0 : case NS_rtf::LN_RGBXCHNUMS: break;
985 : case NS_rtf::LN_ISTARTAT:
986 : case NS_rtf::LN_NFC:
987 : case NS_rtf::LN_JC:
988 : case NS_rtf::LN_FLEGAL:
989 : case NS_rtf::LN_FNORESTART:
990 : case NS_rtf::LN_FIDENTSAV:
991 : case NS_rtf::LN_FCONVERTED:
992 : case NS_rtf::LN_IXCHFOLLOW:
993 1573 : if (m_pCurrentDefinition->GetCurrentLevel().get())
994 1569 : m_pCurrentDefinition->GetCurrentLevel( )->SetValue( nSprmId, nIntValue );
995 1573 : break;
996 : case NS_ooxml::LN_CT_Lvl_suff:
997 : {
998 36 : if (m_pCurrentDefinition->GetCurrentLevel().get())
999 : {
1000 36 : SvxNumberFormat::LabelFollowedBy value = SvxNumberFormat::LISTTAB;
1001 36 : if( rSprm.getValue()->getString() == "tab" )
1002 0 : value = SvxNumberFormat::LISTTAB;
1003 36 : else if( rSprm.getValue()->getString() == "space" )
1004 0 : value = SvxNumberFormat::SPACE;
1005 36 : else if( rSprm.getValue()->getString() == "nothing" )
1006 36 : value = SvxNumberFormat::NOTHING;
1007 : else
1008 : SAL_WARN( "writerfilter", "Unknown ST_LevelSuffix value "
1009 : << rSprm.getValue()->getString());
1010 36 : m_pCurrentDefinition->GetCurrentLevel()->SetValue( nSprmId, value );
1011 : }
1012 : }
1013 36 : break;
1014 : case NS_ooxml::LN_CT_Lvl_lvlText:
1015 : case NS_ooxml::LN_CT_Lvl_rPr : //contains LN_EG_RPrBase_rFonts
1016 : {
1017 1123 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1018 1123 : if(pProperties.get())
1019 1123 : pProperties->resolve(*this);
1020 : }
1021 1123 : break;
1022 : case NS_ooxml::LN_CT_NumLvl_lvl:
1023 : {
1024 : // overwrite level
1025 14 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1026 14 : if(pProperties.get())
1027 14 : pProperties->resolve(*this);
1028 : }
1029 14 : break;
1030 : case NS_ooxml::LN_CT_Lvl_lvlJc:
1031 : {
1032 : static sal_Int16 aWWAlignments[ ] =
1033 : {
1034 : text::HoriOrientation::LEFT,
1035 : text::HoriOrientation::CENTER,
1036 : text::HoriOrientation::RIGHT
1037 : };
1038 1552 : m_pCurrentDefinition->GetCurrentLevel( )->Insert(
1039 2328 : PROP_ADJUST, uno::makeAny( aWWAlignments[ nIntValue ] ) );
1040 776 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1041 : }
1042 776 : break;
1043 : case NS_ooxml::LN_CT_Lvl_pPr:
1044 : case NS_ooxml::LN_CT_PPrBase_ind:
1045 : {
1046 : //todo: how to handle paragraph properties within numbering levels (except LeftIndent and FirstLineIndent)?
1047 1438 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1048 1438 : if(pProperties.get())
1049 1438 : pProperties->resolve(*this);
1050 : }
1051 1438 : break;
1052 : case NS_ooxml::LN_CT_PPrBase_tabs:
1053 : case NS_ooxml::LN_CT_Tabs_tab:
1054 : {
1055 1052 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1056 1052 : if(pProperties.get())
1057 1052 : pProperties->resolve(*this);
1058 : }
1059 1052 : break;
1060 : case NS_ooxml::LN_CT_Lvl_pStyle:
1061 : {
1062 25 : OUString sStyleName = rSprm.getValue( )->getString( );
1063 50 : ListLevel::Pointer pLevel = m_pCurrentDefinition->GetCurrentLevel( );
1064 50 : StyleSheetTablePtr pStylesTable = m_rDMapper.GetStyleSheetTable( );
1065 50 : const StyleSheetEntryPtr pStyle = pStylesTable->FindStyleSheetByISTD( sStyleName );
1066 50 : pLevel->SetParaStyle( pStyle );
1067 : }
1068 25 : break;
1069 : case NS_ooxml::LN_CT_Num_lvlOverride:
1070 : {
1071 14 : writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
1072 14 : if (pProperties.get())
1073 14 : pProperties->resolve(*this);
1074 : }
1075 14 : break;
1076 : case NS_ooxml::LN_CT_AbstractNum_numStyleLink:
1077 : {
1078 0 : OUString sStyleName = rSprm.getValue( )->getString( );
1079 0 : AbstractListDef* pAbstractListDef = dynamic_cast< AbstractListDef* >( m_pCurrentDefinition.get( ) );
1080 0 : pAbstractListDef->SetNumStyleLink(sStyleName);
1081 : }
1082 0 : break;
1083 : case NS_ooxml::LN_EG_RPrBase_rFonts: //contains font properties
1084 : case NS_ooxml::LN_EG_RPrBase_color:
1085 : case NS_ooxml::LN_EG_RPrBase_u:
1086 : case NS_sprm::LN_CHps: // sprmCHps
1087 : case NS_ooxml::LN_EG_RPrBase_lang:
1088 : case NS_ooxml::LN_EG_RPrBase_eastAsianLayout:
1089 : //no break!
1090 : default:
1091 549 : if( m_pCurrentDefinition->GetCurrentLevel( ).get())
1092 : {
1093 449 : m_rDMapper.PushListProperties( m_pCurrentDefinition->GetCurrentLevel( ) );
1094 449 : m_rDMapper.sprm( rSprm );
1095 449 : m_rDMapper.PopListProperties();
1096 : }
1097 : }
1098 : }
1099 8035 : }
1100 :
1101 36 : void ListsManager::lcl_entry( int /* pos */,
1102 : writerfilter::Reference<Properties>::Pointer_t ref )
1103 : {
1104 36 : if( m_rDMapper.IsOOXMLImport() || m_rDMapper.IsRTFImport() )
1105 : {
1106 36 : ref->resolve(*this);
1107 : }
1108 : else
1109 : {
1110 0 : if ( m_bIsLFOImport )
1111 : {
1112 : // Create ListDef's
1113 : OSL_ENSURE( !m_pCurrentDefinition.get(), "current entry has to be NULL here");
1114 0 : ListDef::Pointer pList( new ListDef() );
1115 0 : m_pCurrentDefinition = pList;
1116 0 : ref->resolve(*this);
1117 : //append it to the table
1118 0 : m_aLists.push_back( pList );
1119 0 : m_pCurrentDefinition = AbstractListDef::Pointer();
1120 : }
1121 : else
1122 : {
1123 : // Create AbstractListDef's
1124 : OSL_ENSURE( !m_pCurrentDefinition.get(), "current entry has to be NULL here");
1125 0 : m_pCurrentDefinition.reset( new AbstractListDef( ) );
1126 0 : ref->resolve(*this);
1127 : //append it to the table
1128 0 : m_aAbstractLists.push_back( m_pCurrentDefinition );
1129 0 : m_pCurrentDefinition = AbstractListDef::Pointer();
1130 : }
1131 : }
1132 36 : }
1133 :
1134 162 : AbstractListDef::Pointer ListsManager::GetAbstractList( sal_Int32 nId )
1135 : {
1136 162 : AbstractListDef::Pointer pAbstractList;
1137 :
1138 162 : int nLen = m_aAbstractLists.size( );
1139 162 : int i = 0;
1140 1091 : while ( !pAbstractList.get( ) && i < nLen )
1141 : {
1142 767 : if ( m_aAbstractLists[i]->GetId( ) == nId )
1143 : {
1144 162 : if ( m_aAbstractLists[i]->GetNumStyleLink().getLength() > 0 )
1145 : {
1146 : // If the abstract num has a style linked, check the linked style's number id.
1147 0 : StyleSheetTablePtr pStylesTable = m_rDMapper.GetStyleSheetTable( );
1148 :
1149 : const StyleSheetEntryPtr pStyleSheetEntry =
1150 0 : pStylesTable->FindStyleSheetByISTD( m_aAbstractLists[i]->GetNumStyleLink() );
1151 :
1152 : const StyleSheetPropertyMap* pStyleSheetProperties =
1153 0 : dynamic_cast<const StyleSheetPropertyMap*>(pStyleSheetEntry ? pStyleSheetEntry->pProperties.get() : 0);
1154 :
1155 0 : if( pStyleSheetProperties && pStyleSheetProperties->GetNumId() >= 0 )
1156 : {
1157 0 : ListDef::Pointer pList = GetList( pStyleSheetProperties->GetNumId() );
1158 0 : if ( pList!=0 )
1159 0 : return pList->GetAbstractDefinition();
1160 : else
1161 0 : pAbstractList = m_aAbstractLists[i];
1162 0 : }
1163 :
1164 : }
1165 : else
1166 : {
1167 162 : pAbstractList = m_aAbstractLists[i];
1168 : }
1169 : }
1170 767 : i++;
1171 : }
1172 :
1173 162 : return pAbstractList;
1174 : }
1175 :
1176 75 : ListDef::Pointer ListsManager::GetList( sal_Int32 nId )
1177 : {
1178 75 : ListDef::Pointer pList;
1179 :
1180 75 : int nLen = m_aLists.size( );
1181 75 : int i = 0;
1182 229 : while ( !pList.get( ) && i < nLen )
1183 : {
1184 79 : if ( m_aLists[i]->GetId( ) == nId )
1185 40 : pList = m_aLists[i];
1186 79 : i++;
1187 : }
1188 :
1189 75 : return pList;
1190 : }
1191 :
1192 36 : void ListsManager::CreateNumberingRules( )
1193 : {
1194 : // Loop over the definitions
1195 36 : std::vector< ListDef::Pointer >::iterator listIt = m_aLists.begin( );
1196 201 : for ( ; listIt != m_aLists.end( ); ++listIt )
1197 : {
1198 165 : (*listIt)->CreateNumberingRules( m_rDMapper, m_xFactory );
1199 : }
1200 36 : }
1201 :
1202 24 : } }
1203 :
1204 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|