LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/vba - vbalisthelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 340 0.0 %
Date: 2012-12-17 Functions: 0 15 0.0 %
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 "vbalisthelper.hxx"
      20             : #include <tools/diagnose_ex.h>
      21             : #include <ooo/vba/word/WdListGalleryType.hpp>
      22             : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      23             : #include <com/sun/star/style/NumberingType.hpp>
      24             : #include <com/sun/star/container/XIndexReplace.hpp>
      25             : 
      26             : using namespace ::ooo::vba;
      27             : using namespace ::com::sun::star;
      28             : 
      29             : static const sal_Int32 LIST_LEVEL_COUNT = 9;
      30             : 
      31             : static const char WORD_BULLET_GALLERY[] = "WdBullet";
      32             : static const char WORD_NUMBER_GALLERY[] = "WdNumber";
      33             : static const char WORD_OUTLINE_NUMBER_GALLERY[] = "WdOutlineNumber";
      34             : 
      35             : static const char UNO_NAME_PARENT_NUMBERING[] = "ParentNumbering";
      36             : static const char UNO_NAME_PREFIX[] = "Prefix";
      37             : static const char UNO_NAME_SUFFIX[] = "Suffix";
      38             : static const char UNO_NAME_CHAR_STYLE_NAME[] = "CharStyleName";
      39             : static const char UNO_NAME_NUMBERING_TYPE[] = "NumberingType";
      40             : static const char UNO_NAME_BULLET_CHAR[] = "BulletChar";
      41             : 
      42             : static const sal_Int16 CHAR_CLOSED_DOT = 8226;
      43             : static const sal_Int16 CHAR_EMPTY_DOT = 111;
      44             : static const sal_Int16 CHAR_SQUARE = 9632;
      45             : static const sal_Int16 CHAR_STAR_SYMBOL = 10026;
      46             : static const sal_Int16 CHAR_FOUR_DIAMONDS = 10070;
      47             : static const sal_Int16 CHAR_DIAMOND = 10022;
      48             : static const sal_Int16 CHAR_ARROW = 10146;
      49             : static const sal_Int16 CHAR_CHECK_MARK = 10003;
      50             : 
      51           0 : SwVbaListHelper::SwVbaListHelper( const css::uno::Reference< css::text::XTextDocument >& xTextDoc, sal_Int32 nGalleryType, sal_Int32 nTemplateType ) throw( css::uno::RuntimeException ) : mxTextDocument( xTextDoc ), mnGalleryType( nGalleryType ), mnTemplateType( nTemplateType )
      52             : {
      53           0 :     Init();
      54           0 : }
      55             : 
      56           0 : void SwVbaListHelper::Init() throw( css::uno::RuntimeException )
      57             : {
      58             :     // set the numbering style name
      59           0 :     switch( mnGalleryType )
      60             :     {
      61             :         case word::WdListGalleryType::wdBulletGallery:
      62             :         {
      63           0 :             msStyleName = rtl::OUString(WORD_BULLET_GALLERY );
      64           0 :             break;
      65             :         }
      66             :         case word::WdListGalleryType::wdNumberGallery:
      67             :         {
      68           0 :             msStyleName = rtl::OUString(WORD_NUMBER_GALLERY );
      69           0 :             break;
      70             :         }
      71             :         case word::WdListGalleryType::wdOutlineNumberGallery:
      72             :         {
      73           0 :             msStyleName = rtl::OUString(WORD_OUTLINE_NUMBER_GALLERY );
      74           0 :             break;
      75             :         }
      76             :         default:
      77             :         {
      78           0 :             throw uno::RuntimeException();
      79             :         }
      80             :     }
      81           0 :     msStyleName += rtl::OUString::valueOf( mnTemplateType );
      82             : 
      83             :     // get the numbering style
      84           0 :     uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxTextDocument, uno::UNO_QUERY_THROW );
      85           0 :     mxStyleFamily.set( xStyleSupplier->getStyleFamilies()->getByName(rtl::OUString( "NumberingStyles" ) ), uno::UNO_QUERY_THROW );
      86             :     OSL_TRACE("SwVbaListHelper::Init: numbering style name: %s", rtl::OUStringToOString( msStyleName, RTL_TEXTENCODING_UTF8 ).getStr() );
      87           0 :     if( mxStyleFamily->hasByName( msStyleName ) )
      88             :     {
      89           0 :         mxStyleProps.set( mxStyleFamily->getByName( msStyleName ), uno::UNO_QUERY_THROW );
      90           0 :         mxNumberingRules.set( mxStyleProps->getPropertyValue( rtl::OUString( "NumberingRules" ) ), uno::UNO_QUERY_THROW );
      91             :     }
      92             :     else
      93             :     {
      94             :         // create new numbering style
      95           0 :         uno::Reference< lang::XMultiServiceFactory > xDocMSF( mxTextDocument, uno::UNO_QUERY_THROW );
      96           0 :         mxStyleProps.set( xDocMSF->createInstance(  rtl::OUString( "com.sun.star.style.NumberingStyle" ) ), uno::UNO_QUERY_THROW );
      97             :         // insert this style into style family, or the property NumberingRules doesn't exist.
      98           0 :         mxStyleFamily->insertByName( msStyleName, uno::makeAny( mxStyleProps ) );
      99           0 :         mxStyleProps->getPropertyValue( rtl::OUString( "NumberingRules" ) ) >>= mxNumberingRules;
     100             : 
     101           0 :         CreateListTemplate();
     102             : 
     103           0 :         mxStyleProps->setPropertyValue( rtl::OUString( "NumberingRules" ) , uno::makeAny( mxNumberingRules ) );
     104           0 :     }
     105           0 : }
     106             : 
     107           0 : void SwVbaListHelper::CreateListTemplate() throw( css::uno::RuntimeException )
     108             : {
     109           0 :     switch( mnGalleryType )
     110             :     {
     111             :         case word::WdListGalleryType::wdBulletGallery:
     112             :         {
     113           0 :             CreateBulletListTemplate();
     114           0 :             break;
     115             :         }
     116             :         case word::WdListGalleryType::wdNumberGallery:
     117             :         {
     118           0 :             CreateNumberListTemplate();
     119           0 :             break;
     120             :         }
     121             :         case word::WdListGalleryType::wdOutlineNumberGallery:
     122             :         {
     123           0 :             CreateOutlineNumberListTemplate();
     124           0 :             break;
     125             :         }
     126             :         default:
     127             :         {
     128           0 :             throw uno::RuntimeException();
     129             :         }
     130             :     }
     131           0 : }
     132             : 
     133           0 : void SwVbaListHelper::CreateBulletListTemplate() throw( css::uno::RuntimeException )
     134             : {
     135             :     // there is only 1 level for each bullet list in MSWord
     136           0 :     sal_Int32 nLevel = 0;
     137           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     138           0 :     mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     139           0 :     rtl::OUString sCharStyleName( "Bullet Symbols" );
     140           0 :     setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_CHAR_STYLE_NAME ), uno::makeAny( sCharStyleName ) );
     141           0 :     sal_Int16 nNumberingType = style::NumberingType::CHAR_SPECIAL;
     142           0 :     setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     143             : 
     144           0 :     rtl::OUString aBulletChar;
     145           0 :     switch( mnTemplateType )
     146             :     {
     147             :         case 1:
     148             :         {
     149           0 :             aBulletChar = rtl::OUString( sal_Unicode( CHAR_CLOSED_DOT ) );
     150           0 :             break;
     151             :         }
     152             :         case 2:
     153             :         {
     154           0 :             aBulletChar = rtl::OUString( sal_Unicode( CHAR_EMPTY_DOT ) );
     155           0 :             break;
     156             :         }
     157             :         case 3:
     158             :         {
     159           0 :             aBulletChar = rtl::OUString( sal_Unicode( CHAR_SQUARE ) );
     160           0 :             break;
     161             :         }
     162             :         case 4:
     163             :         {
     164           0 :             aBulletChar = rtl::OUString( sal_Unicode( CHAR_STAR_SYMBOL ) );
     165           0 :             break;
     166             :         }
     167             :         case 5:
     168             :         {
     169           0 :             aBulletChar = rtl::OUString( sal_Unicode( CHAR_FOUR_DIAMONDS ) );
     170           0 :             break;
     171             :         }
     172             :         case 6:
     173             :         {
     174           0 :             aBulletChar = rtl::OUString( sal_Unicode( CHAR_ARROW ) );
     175           0 :             break;
     176             :         }
     177             :         case 7:
     178             :         {
     179           0 :             aBulletChar = rtl::OUString( sal_Unicode( CHAR_CHECK_MARK ) );
     180           0 :             break;
     181             :         }
     182             :         default:
     183             :         {
     184             :             // we only support 7 types template now
     185           0 :             throw css::uno::RuntimeException();
     186             :         }
     187             :     }
     188           0 :     setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_BULLET_CHAR ), uno::makeAny( aBulletChar ) );
     189             : 
     190           0 :     mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     191           0 : }
     192             : 
     193           0 : void SwVbaListHelper::CreateNumberListTemplate() throw( css::uno::RuntimeException )
     194             : {
     195             :     // there is only 1 level for each bullet list in MSWord
     196           0 :     sal_Int32 nLevel = 0;
     197           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     198           0 :     mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     199             : 
     200           0 :     sal_Int16 nNumberingType = 0;
     201           0 :     rtl::OUString sSuffix;
     202           0 :     switch( mnTemplateType )
     203             :     {
     204             :         case 1:
     205             :         {
     206           0 :             nNumberingType = style::NumberingType::ARABIC;
     207           0 :             sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     208           0 :             break;
     209             :         }
     210             :         case 2:
     211             :         {
     212           0 :             nNumberingType = style::NumberingType::ARABIC;
     213           0 :             sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     214           0 :             break;
     215             :         }
     216             :         case 3:
     217             :         {
     218           0 :             nNumberingType = style::NumberingType::ROMAN_UPPER;
     219           0 :             sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     220           0 :             break;
     221             :         }
     222             :         case 4:
     223             :         {
     224           0 :             nNumberingType = style::NumberingType::CHARS_UPPER_LETTER;
     225           0 :             sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     226           0 :             break;
     227             :         }
     228             :         case 5:
     229             :         {
     230           0 :             nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     231           0 :             sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     232           0 :             break;
     233             :         }
     234             :         case 6:
     235             :         {
     236           0 :             nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     237           0 :             sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     238           0 :             break;
     239             :         }
     240             :         case 7:
     241             :         {
     242           0 :             nNumberingType = style::NumberingType::ROMAN_LOWER;
     243           0 :             sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     244           0 :             break;
     245             :         }
     246             :         default:
     247             :         {
     248             :             // we only support 7 types template now
     249           0 :             throw css::uno::RuntimeException();
     250             :         }
     251             :     }
     252           0 :     setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     253           0 :     setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
     254             : 
     255           0 :     mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     256           0 : }
     257             : 
     258           0 : void SwVbaListHelper::CreateOutlineNumberListTemplate() throw( css::uno::RuntimeException )
     259             : {
     260           0 :     switch( mnTemplateType )
     261             :     {
     262             :         case 1:
     263             :         {
     264           0 :             CreateOutlineNumberForType1();
     265           0 :             break;
     266             :         }
     267             :         case 2:
     268             :         {
     269           0 :             CreateOutlineNumberForType2();
     270           0 :             break;
     271             :         }
     272             :         case 3:
     273             :         {
     274           0 :             CreateOutlineNumberForType3();
     275           0 :             break;
     276             :         }
     277             :         case 4:
     278             :         {
     279           0 :             CreateOutlineNumberForType4();
     280           0 :             break;
     281             :         }
     282             :         case 5:
     283             :         {
     284           0 :             CreateOutlineNumberForType5();
     285           0 :             break;
     286             :         }
     287             :         case 6:
     288             :         {
     289           0 :             CreateOutlineNumberForType6();
     290           0 :             break;
     291             :         }
     292             :         case 7:
     293             :         {
     294           0 :             CreateOutlineNumberForType7();
     295           0 :             break;
     296             :         }
     297             :         default:
     298             :         {
     299             :             // we only support 7 types template now
     300           0 :             throw css::uno::RuntimeException();
     301             :         }
     302             :     }
     303           0 : }
     304             : 
     305           0 : void SwVbaListHelper::CreateOutlineNumberForType1() throw( css::uno::RuntimeException )
     306             : {
     307           0 :     sal_Int16 nNumberingType = 0;
     308           0 :     rtl::OUString sPrefix;
     309           0 :     rtl::OUString sSuffix;
     310           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     311             : 
     312           0 :     for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
     313             :     {
     314           0 :         mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     315           0 :         switch( nLevel )
     316             :         {
     317             :             case 0:
     318             :             case 1:
     319             :             {
     320           0 :                 nNumberingType = style::NumberingType::ARABIC;
     321           0 :                 sPrefix = rtl::OUString();
     322           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     323           0 :                 break;
     324             :             }
     325             :             case 2:
     326             :             {
     327           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     328           0 :                 sPrefix = rtl::OUString();
     329           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     330           0 :                 break;
     331             :             }
     332             :             case 3:
     333             :             {
     334           0 :                 nNumberingType = style::NumberingType::ARABIC;
     335           0 :                 sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
     336           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     337           0 :                 break;
     338             :             }
     339             :             case 4:
     340             :             {
     341           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     342           0 :                 sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
     343           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     344           0 :                 break;
     345             :             }
     346             :             case 5:
     347             :             {
     348           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     349           0 :                 sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
     350           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     351           0 :                 break;
     352             :             }
     353             :             case 6:
     354             :             {
     355           0 :                 nNumberingType = style::NumberingType::ARABIC;
     356           0 :                 sPrefix = rtl::OUString();
     357           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     358           0 :                 break;
     359             :             }
     360             :             case 7:
     361             :             {
     362           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     363           0 :                 sPrefix = rtl::OUString();
     364           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     365           0 :                 break;
     366             :             }
     367             :             case 8:
     368             :             {
     369           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     370           0 :                 sPrefix = rtl::OUString();
     371           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     372           0 :                 break;
     373             :             }
     374             :             default:
     375             :             {
     376           0 :                 throw uno::RuntimeException();
     377             :             }
     378             :         }
     379           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     380           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_PREFIX ), uno::makeAny( sPrefix ) );
     381           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
     382           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     383           0 :     }
     384           0 : }
     385             : 
     386           0 : void SwVbaListHelper::CreateOutlineNumberForType2() throw( css::uno::RuntimeException )
     387             : {
     388           0 :     sal_Int16 nNumberingType = style::NumberingType::ARABIC;
     389           0 :     sal_Int16 nParentNumbering = 0;
     390           0 :     rtl::OUString sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     391           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     392             : 
     393           0 :     for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
     394             :     {
     395           0 :         mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     396           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     397           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
     398           0 :         if( nLevel != 0 )
     399             :         {
     400           0 :             nParentNumbering = sal_Int16( nLevel - 1 );
     401           0 :             setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_PARENT_NUMBERING ), uno::makeAny( nParentNumbering ) );
     402             :         }
     403           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     404           0 :     }
     405           0 : }
     406             : 
     407           0 : void SwVbaListHelper::CreateOutlineNumberForType3() throw( css::uno::RuntimeException )
     408             : {
     409           0 :     sal_Int16 nNumberingType = style::NumberingType::CHAR_SPECIAL;
     410           0 :     rtl::OUString sCharStyleName( "Bullet Symbols" );
     411           0 :     rtl::OUString aBulletChar;
     412           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     413             : 
     414           0 :     for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
     415             :     {
     416           0 :         mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     417           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     418           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_CHAR_STYLE_NAME ), uno::makeAny( sCharStyleName ) );
     419           0 :         switch( nLevel )
     420             :         {
     421             :             case 0:
     422             :             {
     423           0 :                 aBulletChar = rtl::OUString( sal_Unicode( CHAR_FOUR_DIAMONDS ) );
     424           0 :                 break;
     425             :             }
     426             :             case 1:
     427             :             case 5:
     428             :             {
     429           0 :                 aBulletChar = rtl::OUString( sal_Unicode( CHAR_ARROW ) );
     430           0 :                 break;
     431             :             }
     432             :             case 2:
     433             :             case 6:
     434             :             {
     435           0 :                 aBulletChar = rtl::OUString( sal_Unicode( CHAR_SQUARE ) );
     436           0 :                 break;
     437             :             }
     438             :             case 3:
     439             :             case 7:
     440             :             {
     441           0 :                 aBulletChar = rtl::OUString( sal_Unicode( CHAR_CLOSED_DOT ) );
     442           0 :                 break;
     443             :             }
     444             :             case 4:
     445             :             case 8:
     446             :             {
     447           0 :                 aBulletChar = rtl::OUString( sal_Unicode( CHAR_DIAMOND ) );
     448           0 :                 break;
     449             :             }
     450             :             default:
     451             :             {
     452           0 :                 throw uno::RuntimeException();
     453             :             }
     454             :         }
     455           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_BULLET_CHAR ), uno::makeAny( aBulletChar ) );
     456           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     457           0 :     }
     458           0 : }
     459             : 
     460           0 : void SwVbaListHelper::CreateOutlineNumberForType4() throw( css::uno::RuntimeException )
     461             : {
     462           0 :     sal_Int16 nNumberingType = 0;
     463           0 :     rtl::OUString sPrefix;
     464           0 :     rtl::OUString sSuffix;
     465           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     466             : 
     467           0 :     for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
     468             :     {
     469           0 :         mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     470           0 :         switch( nLevel )
     471             :         {
     472             :             case 0:
     473             :             {
     474           0 :                 nNumberingType = style::NumberingType::ROMAN_UPPER;
     475           0 :                 sPrefix = rtl::OUString();
     476           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     477           0 :                 break;
     478             :             }
     479             :             case 1:
     480             :             {
     481           0 :                 nNumberingType = style::NumberingType::ARABIC;
     482           0 :                 sPrefix = rtl::OUString();
     483           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     484           0 :                 sal_Int16 nParentNumbering = 0;
     485           0 :                 setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_PARENT_NUMBERING ), uno::makeAny( nParentNumbering ) );
     486             :                 break;
     487             :             }
     488             :             case 2:
     489             :             {
     490           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     491           0 :                 sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
     492           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     493           0 :                 break;
     494             :             }
     495             :             case 3:
     496             :             {
     497           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     498           0 :                 sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
     499           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     500           0 :                 break;
     501             :             }
     502             :             case 4:
     503             :             {
     504           0 :                 nNumberingType = style::NumberingType::ARABIC;
     505           0 :                 sPrefix = rtl::OUString();
     506           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     507           0 :                 break;
     508             :             }
     509             :             case 5:
     510             :             {
     511           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     512           0 :                 sPrefix = rtl::OUString();
     513           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     514           0 :                 break;
     515             :             }
     516             :             case 6:
     517             :             {
     518           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     519           0 :                 sPrefix = rtl::OUString();
     520           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     521           0 :                 break;
     522             :             }
     523             :             case 7:
     524             :             {
     525           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     526           0 :                 sPrefix = rtl::OUString();
     527           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     528           0 :                 break;
     529             :             }
     530             :             case 8:
     531             :             {
     532           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     533           0 :                 sPrefix = rtl::OUString();
     534           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     535           0 :                 break;
     536             :             }
     537             :             default:
     538             :             {
     539           0 :                 throw uno::RuntimeException();
     540             :             }
     541             :         }
     542           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     543           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_PREFIX ), uno::makeAny( sPrefix ) );
     544           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
     545           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     546           0 :     }
     547           0 : }
     548             : 
     549           0 : void SwVbaListHelper::CreateOutlineNumberForType5() throw( css::uno::RuntimeException )
     550             : {
     551           0 :     sal_Int16 nNumberingType = style::NumberingType::ARABIC;
     552           0 :     sal_Int16 nParentNumbering = 0;
     553           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     554             : 
     555           0 :     for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
     556             :     {
     557           0 :         mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     558           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     559           0 :         if( nLevel != 0 )
     560             :         {
     561           0 :             nParentNumbering = sal_Int16( nLevel - 1 );
     562           0 :             setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_PARENT_NUMBERING ), uno::makeAny( nParentNumbering ) );
     563             :         }
     564           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     565           0 :     }
     566           0 : }
     567             : 
     568           0 : void SwVbaListHelper::CreateOutlineNumberForType6() throw( css::uno::RuntimeException )
     569             : {
     570           0 :     sal_Int16 nNumberingType = 0;
     571           0 :     rtl::OUString sPrefix;
     572           0 :     rtl::OUString sSuffix;
     573           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     574             : 
     575           0 :     for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
     576             :     {
     577           0 :         mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     578           0 :         switch( nLevel )
     579             :         {
     580             :             case 0:
     581             :             {
     582           0 :                 nNumberingType = style::NumberingType::ROMAN_UPPER;
     583           0 :                 sPrefix = rtl::OUString();
     584           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     585           0 :                 break;
     586             :             }
     587             :             case 1:
     588             :             {
     589           0 :                 nNumberingType = style::NumberingType::CHARS_UPPER_LETTER;
     590           0 :                 sPrefix = rtl::OUString();
     591           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     592           0 :                 break;
     593             :             }
     594             :             case 2:
     595             :             {
     596           0 :                 nNumberingType = style::NumberingType::ARABIC;
     597           0 :                 sPrefix = rtl::OUString();
     598           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     599           0 :                 break;
     600             :             }
     601             :             case 3:
     602             :             {
     603           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     604           0 :                 sPrefix = rtl::OUString();
     605           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     606           0 :                 break;
     607             :             }
     608             :             case 4:
     609             :             {
     610           0 :                 nNumberingType = style::NumberingType::ARABIC;
     611           0 :                 sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
     612           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     613           0 :                 break;
     614             :             }
     615             :             case 5:
     616             :             {
     617           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     618           0 :                 sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
     619           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     620           0 :                 break;
     621             :             }
     622             :             case 6:
     623             :             {
     624           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     625           0 :                 sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
     626           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
     627           0 :                 break;
     628             :             }
     629             :             case 7:
     630             :             {
     631           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     632           0 :                 sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
     633           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     634           0 :                 break;
     635             :             }
     636             :             case 8:
     637             :             {
     638           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     639           0 :                 sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
     640           0 :                 sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
     641           0 :                 break;
     642             :             }
     643             :             default:
     644             :             {
     645           0 :                 throw uno::RuntimeException();
     646             :             }
     647             :         }
     648           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     649           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_PREFIX ), uno::makeAny( sPrefix ) );
     650           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
     651           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     652           0 :     }
     653           0 : }
     654             : 
     655           0 : void SwVbaListHelper::CreateOutlineNumberForType7() throw( css::uno::RuntimeException )
     656             : {
     657           0 :     sal_Int16 nNumberingType = style::NumberingType::ARABIC;
     658           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     659           0 :     rtl::OUString sPrefix("Chapter ");
     660             : 
     661           0 :     for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
     662             :     {
     663           0 :         mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     664           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     665           0 :         setOrAppendPropertyValue( aPropertyValues, rtl::OUString(UNO_NAME_PREFIX ), uno::makeAny( sPrefix ) );
     666           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     667           0 :     }
     668           0 : }
     669             : 
     670           0 : uno::Any SwVbaListHelper::getPropertyValueWithNameAndLevel( sal_Int32 nLevel, const rtl::OUString& sName ) throw( css::uno::RuntimeException )
     671             : {
     672           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     673           0 :     mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     674           0 :     return getPropertyValue( aPropertyValues, sName );
     675             : }
     676             : 
     677           0 : void SwVbaListHelper::setPropertyValueWithNameAndLevel( sal_Int32 nLevel, const rtl::OUString& sName, const css::uno::Any& aValue ) throw( css::uno::RuntimeException )
     678             : {
     679           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     680           0 :     mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     681           0 :     setOrAppendPropertyValue( aPropertyValues, sName, aValue );
     682           0 :     mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     683           0 :     mxStyleProps->setPropertyValue( rtl::OUString( "NumberingRules" ) , uno::makeAny( mxNumberingRules ) );
     684           0 : }
     685             : 
     686             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10