LCOV - code coverage report
Current view: top level - writerfilter/source/dmapper - NumberingManager.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 480 530 90.6 %
Date: 2014-04-11 Functions: 39 40 97.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10