LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbalisthelper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 337 0.0 %
Date: 2015-06-13 12:38:46 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 = WORD_BULLET_GALLERY;
      64           0 :             break;
      65             :         }
      66             :         case word::WdListGalleryType::wdNumberGallery:
      67             :         {
      68           0 :             msStyleName = WORD_NUMBER_GALLERY;
      69           0 :             break;
      70             :         }
      71             :         case word::WdListGalleryType::wdOutlineNumberGallery:
      72             :         {
      73           0 :             msStyleName = WORD_OUTLINE_NUMBER_GALLERY;
      74           0 :             break;
      75             :         }
      76             :         default:
      77             :         {
      78           0 :             throw uno::RuntimeException();
      79             :         }
      80             :     }
      81           0 :     msStyleName += OUString::number( 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("NumberingStyles"), uno::UNO_QUERY_THROW );
      86             :     OSL_TRACE("SwVbaListHelper::Init: numbering style name: %s", 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("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("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("NumberingRules") >>= mxNumberingRules;
     100             : 
     101           0 :         CreateListTemplate();
     102             : 
     103           0 :         mxStyleProps->setPropertyValue("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 :     OUString sCharStyleName( "Bullet Symbols" );
     140           0 :     setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_CHAR_STYLE_NAME ), uno::makeAny( sCharStyleName ) );
     141           0 :     sal_Int16 nNumberingType = style::NumberingType::CHAR_SPECIAL;
     142           0 :     setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     143             : 
     144           0 :     OUString aBulletChar;
     145           0 :     switch( mnTemplateType )
     146             :     {
     147             :         case 1:
     148             :         {
     149           0 :             aBulletChar = OUString( sal_Unicode( CHAR_CLOSED_DOT ) );
     150           0 :             break;
     151             :         }
     152             :         case 2:
     153             :         {
     154           0 :             aBulletChar = OUStringLiteral1<CHAR_EMPTY_DOT>();
     155           0 :             break;
     156             :         }
     157             :         case 3:
     158             :         {
     159           0 :             aBulletChar = OUString( sal_Unicode( CHAR_SQUARE ) );
     160           0 :             break;
     161             :         }
     162             :         case 4:
     163             :         {
     164           0 :             aBulletChar = OUString( sal_Unicode( CHAR_STAR_SYMBOL ) );
     165           0 :             break;
     166             :         }
     167             :         case 5:
     168             :         {
     169           0 :             aBulletChar = OUString( sal_Unicode( CHAR_FOUR_DIAMONDS ) );
     170           0 :             break;
     171             :         }
     172             :         case 6:
     173             :         {
     174           0 :             aBulletChar = OUString( sal_Unicode( CHAR_ARROW ) );
     175           0 :             break;
     176             :         }
     177             :         case 7:
     178             :         {
     179           0 :             aBulletChar = 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, 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 :     OUString sSuffix;
     202           0 :     switch( mnTemplateType )
     203             :     {
     204             :         case 1:
     205             :         {
     206           0 :             nNumberingType = style::NumberingType::ARABIC;
     207           0 :             sSuffix = ".";
     208           0 :             break;
     209             :         }
     210             :         case 2:
     211             :         {
     212           0 :             nNumberingType = style::NumberingType::ARABIC;
     213           0 :             sSuffix = ")";
     214           0 :             break;
     215             :         }
     216             :         case 3:
     217             :         {
     218           0 :             nNumberingType = style::NumberingType::ROMAN_UPPER;
     219           0 :             sSuffix = ".";
     220           0 :             break;
     221             :         }
     222             :         case 4:
     223             :         {
     224           0 :             nNumberingType = style::NumberingType::CHARS_UPPER_LETTER;
     225           0 :             sSuffix = ".";
     226           0 :             break;
     227             :         }
     228             :         case 5:
     229             :         {
     230           0 :             nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     231           0 :             sSuffix = ")";
     232           0 :             break;
     233             :         }
     234             :         case 6:
     235             :         {
     236           0 :             nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     237           0 :             sSuffix = ".";
     238           0 :             break;
     239             :         }
     240             :         case 7:
     241             :         {
     242           0 :             nNumberingType = style::NumberingType::ROMAN_LOWER;
     243           0 :             sSuffix = ".";
     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, OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     253           0 :     setOrAppendPropertyValue( aPropertyValues, 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 :     OUString sPrefix;
     309           0 :     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.clear();
     322           0 :                 sSuffix = ")";
     323           0 :                 break;
     324             :             }
     325             :             case 2:
     326             :             {
     327           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     328           0 :                 sPrefix.clear();
     329           0 :                 sSuffix = ")";
     330           0 :                 break;
     331             :             }
     332             :             case 3:
     333             :             {
     334           0 :                 nNumberingType = style::NumberingType::ARABIC;
     335           0 :                 sPrefix = "(";
     336           0 :                 sSuffix = ")";
     337           0 :                 break;
     338             :             }
     339             :             case 4:
     340             :             {
     341           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     342           0 :                 sPrefix = "(";
     343           0 :                 sSuffix = ")";
     344           0 :                 break;
     345             :             }
     346             :             case 5:
     347             :             {
     348           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     349           0 :                 sPrefix = "(";
     350           0 :                 sSuffix = ")";
     351           0 :                 break;
     352             :             }
     353             :             case 6:
     354             :             {
     355           0 :                 nNumberingType = style::NumberingType::ARABIC;
     356           0 :                 sPrefix.clear();
     357           0 :                 sSuffix = ".";
     358           0 :                 break;
     359             :             }
     360             :             case 7:
     361             :             {
     362           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     363           0 :                 sPrefix.clear();
     364           0 :                 sSuffix = ".";
     365           0 :                 break;
     366             :             }
     367             :             case 8:
     368             :             {
     369           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     370           0 :                 sPrefix.clear();
     371           0 :                 sSuffix = ".";
     372           0 :                 break;
     373             :             }
     374             :         }
     375           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     376           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_PREFIX ), uno::makeAny( sPrefix ) );
     377           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
     378           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     379           0 :     }
     380           0 : }
     381             : 
     382           0 : void SwVbaListHelper::CreateOutlineNumberForType2() throw( css::uno::RuntimeException )
     383             : {
     384           0 :     sal_Int16 nNumberingType = style::NumberingType::ARABIC;
     385           0 :     sal_Int16 nParentNumbering = 0;
     386           0 :     OUString sSuffix = OUString( '.' );
     387           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     388             : 
     389           0 :     for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
     390             :     {
     391           0 :         mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     392           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     393           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
     394           0 :         if( nLevel != 0 )
     395             :         {
     396           0 :             nParentNumbering = sal_Int16( nLevel - 1 );
     397           0 :             setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_PARENT_NUMBERING ), uno::makeAny( nParentNumbering ) );
     398             :         }
     399           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     400           0 :     }
     401           0 : }
     402             : 
     403           0 : void SwVbaListHelper::CreateOutlineNumberForType3() throw( css::uno::RuntimeException )
     404             : {
     405           0 :     sal_Int16 nNumberingType = style::NumberingType::CHAR_SPECIAL;
     406           0 :     OUString sCharStyleName( "Bullet Symbols" );
     407           0 :     OUString aBulletChar;
     408           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     409             : 
     410           0 :     for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
     411             :     {
     412           0 :         mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     413           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     414           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_CHAR_STYLE_NAME ), uno::makeAny( sCharStyleName ) );
     415           0 :         switch( nLevel )
     416             :         {
     417             :             case 0:
     418             :             {
     419           0 :                 aBulletChar = OUString( sal_Unicode( CHAR_FOUR_DIAMONDS ) );
     420           0 :                 break;
     421             :             }
     422             :             case 1:
     423             :             case 5:
     424             :             {
     425           0 :                 aBulletChar = OUString( sal_Unicode( CHAR_ARROW ) );
     426           0 :                 break;
     427             :             }
     428             :             case 2:
     429             :             case 6:
     430             :             {
     431           0 :                 aBulletChar = OUString( sal_Unicode( CHAR_SQUARE ) );
     432           0 :                 break;
     433             :             }
     434             :             case 3:
     435             :             case 7:
     436             :             {
     437           0 :                 aBulletChar = OUString( sal_Unicode( CHAR_CLOSED_DOT ) );
     438           0 :                 break;
     439             :             }
     440             :             case 4:
     441             :             case 8:
     442             :             {
     443           0 :                 aBulletChar = OUString( sal_Unicode( CHAR_DIAMOND ) );
     444           0 :                 break;
     445             :             }
     446             :         }
     447           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_BULLET_CHAR ), uno::makeAny( aBulletChar ) );
     448           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     449           0 :     }
     450           0 : }
     451             : 
     452           0 : void SwVbaListHelper::CreateOutlineNumberForType4() throw( css::uno::RuntimeException )
     453             : {
     454           0 :     sal_Int16 nNumberingType = 0;
     455           0 :     OUString sPrefix;
     456           0 :     OUString sSuffix;
     457           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     458             : 
     459           0 :     for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
     460             :     {
     461           0 :         mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     462           0 :         switch( nLevel )
     463             :         {
     464             :             case 0:
     465             :             {
     466           0 :                 nNumberingType = style::NumberingType::ROMAN_UPPER;
     467           0 :                 sPrefix.clear();
     468           0 :                 sSuffix = ".";
     469           0 :                 break;
     470             :             }
     471             :             case 1:
     472             :             {
     473           0 :                 nNumberingType = style::NumberingType::ARABIC;
     474           0 :                 sPrefix.clear();
     475           0 :                 sSuffix = ".";
     476           0 :                 sal_Int16 nParentNumbering = 0;
     477           0 :                 setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_PARENT_NUMBERING ), uno::makeAny( nParentNumbering ) );
     478           0 :                 break;
     479             :             }
     480             :             case 2:
     481             :             {
     482           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     483           0 :                 sPrefix = "(";
     484           0 :                 sSuffix = ")";
     485           0 :                 break;
     486             :             }
     487             :             case 3:
     488             :             {
     489           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     490           0 :                 sPrefix = "(";
     491           0 :                 sSuffix = ")";
     492           0 :                 break;
     493             :             }
     494             :             case 4:
     495             :             {
     496           0 :                 nNumberingType = style::NumberingType::ARABIC;
     497           0 :                 sPrefix.clear();
     498           0 :                 sSuffix = ")";
     499           0 :                 break;
     500             :             }
     501             :             case 5:
     502             :             {
     503           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     504           0 :                 sPrefix.clear();
     505           0 :                 sSuffix = ")";
     506           0 :                 break;
     507             :             }
     508             :             case 6:
     509             :             {
     510           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     511           0 :                 sPrefix.clear();
     512           0 :                 sSuffix = ")";
     513           0 :                 break;
     514             :             }
     515             :             case 7:
     516             :             {
     517           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     518           0 :                 sPrefix.clear();
     519           0 :                 sSuffix = ".";
     520           0 :                 break;
     521             :             }
     522             :             case 8:
     523             :             {
     524           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     525           0 :                 sPrefix.clear();
     526           0 :                 sSuffix = ".";
     527           0 :                 break;
     528             :             }
     529             :         }
     530           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     531           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_PREFIX ), uno::makeAny( sPrefix ) );
     532           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
     533           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     534           0 :     }
     535           0 : }
     536             : 
     537           0 : void SwVbaListHelper::CreateOutlineNumberForType5() throw( css::uno::RuntimeException )
     538             : {
     539           0 :     sal_Int16 nNumberingType = style::NumberingType::ARABIC;
     540           0 :     sal_Int16 nParentNumbering = 0;
     541           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     542             : 
     543           0 :     for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
     544             :     {
     545           0 :         mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     546           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     547           0 :         if( nLevel != 0 )
     548             :         {
     549           0 :             nParentNumbering = sal_Int16( nLevel - 1 );
     550           0 :             setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_PARENT_NUMBERING ), uno::makeAny( nParentNumbering ) );
     551             :         }
     552           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     553           0 :     }
     554           0 : }
     555             : 
     556           0 : void SwVbaListHelper::CreateOutlineNumberForType6() throw( css::uno::RuntimeException )
     557             : {
     558           0 :     sal_Int16 nNumberingType = 0;
     559           0 :     OUString sPrefix;
     560           0 :     OUString sSuffix;
     561           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     562             : 
     563           0 :     for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
     564             :     {
     565           0 :         mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     566           0 :         switch( nLevel )
     567             :         {
     568             :             case 0:
     569             :             {
     570           0 :                 nNumberingType = style::NumberingType::ROMAN_UPPER;
     571           0 :                 sPrefix.clear();
     572           0 :                 sSuffix = ".";
     573           0 :                 break;
     574             :             }
     575             :             case 1:
     576             :             {
     577           0 :                 nNumberingType = style::NumberingType::CHARS_UPPER_LETTER;
     578           0 :                 sPrefix.clear();
     579           0 :                 sSuffix = ".";
     580           0 :                 break;
     581             :             }
     582             :             case 2:
     583             :             {
     584           0 :                 nNumberingType = style::NumberingType::ARABIC;
     585           0 :                 sPrefix.clear();
     586           0 :                 sSuffix = ")";
     587           0 :                 break;
     588             :             }
     589             :             case 3:
     590             :             {
     591           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     592           0 :                 sPrefix.clear();
     593           0 :                 sSuffix = ")";
     594           0 :                 break;
     595             :             }
     596             :             case 4:
     597             :             {
     598           0 :                 nNumberingType = style::NumberingType::ARABIC;
     599           0 :                 sPrefix = "(";
     600           0 :                 sSuffix = ")";
     601           0 :                 break;
     602             :             }
     603             :             case 5:
     604             :             {
     605           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     606           0 :                 sPrefix = "(";
     607           0 :                 sSuffix = ")";
     608           0 :                 break;
     609             :             }
     610             :             case 6:
     611             :             {
     612           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     613           0 :                 sPrefix = "(";
     614           0 :                 sSuffix = ")";
     615           0 :                 break;
     616             :             }
     617             :             case 7:
     618             :             {
     619           0 :                 nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
     620           0 :                 sPrefix = "(";
     621           0 :                 sSuffix = ".";
     622           0 :                 break;
     623             :             }
     624             :             case 8:
     625             :             {
     626           0 :                 nNumberingType = style::NumberingType::ROMAN_LOWER;
     627           0 :                 sPrefix = "(";
     628           0 :                 sSuffix = ".";
     629           0 :                 break;
     630             :             }
     631             :         }
     632           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     633           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_PREFIX ), uno::makeAny( sPrefix ) );
     634           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
     635           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     636           0 :     }
     637           0 : }
     638             : 
     639           0 : void SwVbaListHelper::CreateOutlineNumberForType7() throw( css::uno::RuntimeException )
     640             : {
     641           0 :     sal_Int16 nNumberingType = style::NumberingType::ARABIC;
     642           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     643           0 :     OUString sPrefix("Chapter ");
     644             : 
     645           0 :     for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
     646             :     {
     647           0 :         mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     648           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
     649           0 :         setOrAppendPropertyValue( aPropertyValues, OUString(UNO_NAME_PREFIX ), uno::makeAny( sPrefix ) );
     650           0 :         mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     651           0 :     }
     652           0 : }
     653             : 
     654           0 : uno::Any SwVbaListHelper::getPropertyValueWithNameAndLevel( sal_Int32 nLevel, const OUString& sName ) throw( css::uno::RuntimeException )
     655             : {
     656           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     657           0 :     mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     658           0 :     return getPropertyValue( aPropertyValues, sName );
     659             : }
     660             : 
     661           0 : void SwVbaListHelper::setPropertyValueWithNameAndLevel( sal_Int32 nLevel, const OUString& sName, const css::uno::Any& aValue ) throw( css::uno::RuntimeException )
     662             : {
     663           0 :     uno::Sequence< beans::PropertyValue > aPropertyValues;
     664           0 :     mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
     665           0 :     setOrAppendPropertyValue( aPropertyValues, sName, aValue );
     666           0 :     mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
     667           0 :     mxStyleProps->setPropertyValue("NumberingRules", uno::makeAny( mxNumberingRules ) );
     668           0 : }
     669             : 
     670             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11