LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/vba - vbastyles.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 94 0.0 %
Date: 2012-12-27 Functions: 0 23 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 "vbastyles.hxx"
      20             : #include "vbastyle.hxx"
      21             : #include <cppuhelper/implbase3.hxx>
      22             : #include <com/sun/star/container/XEnumerationAccess.hpp>
      23             : #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
      24             : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      25             : #include <com/sun/star/style/XStyle.hpp>
      26             : #include <ooo/vba/word/WdBuiltinStyle.hpp>
      27             : #include <ooo/vba/word/WdStyleType.hpp>
      28             : 
      29             : using namespace ::ooo::vba;
      30             : using namespace ::com::sun::star;
      31             : 
      32             : struct BuiltinStyleTable
      33             : {
      34             :     sal_Int32 wdBuiltinStyle;
      35             :     const sal_Char* pOOoStyleName;
      36             :     sal_Int32 wdStyleType;
      37             : };
      38             : 
      39             : static const BuiltinStyleTable aBuiltinStyleTable[] =
      40             : {
      41             :     { word::WdBuiltinStyle::wdStyleBlockQuotation, "", word::WdStyleType::wdStyleTypeParagraph },
      42             :     { word::WdBuiltinStyle::wdStyleBodyText, "Text body", word::WdStyleType::wdStyleTypeParagraph },
      43             :     { word::WdBuiltinStyle::wdStyleBodyText2, "", word::WdStyleType::wdStyleTypeParagraph },
      44             :     { word::WdBuiltinStyle::wdStyleBodyText3, "", word::WdStyleType::wdStyleTypeParagraph },
      45             :     { word::WdBuiltinStyle::wdStyleBodyTextFirstIndent, "First line indent", word::WdStyleType::wdStyleTypeParagraph },
      46             :     { word::WdBuiltinStyle::wdStyleBodyTextFirstIndent2, "", word::WdStyleType::wdStyleTypeParagraph },
      47             :     { word::WdBuiltinStyle::wdStyleBodyTextIndent, "Text body indent", word::WdStyleType::wdStyleTypeParagraph },
      48             :     { word::WdBuiltinStyle::wdStyleBodyTextIndent2, "", word::WdStyleType::wdStyleTypeParagraph },
      49             :     { word::WdBuiltinStyle::wdStyleBodyTextIndent3, "", word::WdStyleType::wdStyleTypeParagraph },
      50             :     { word::WdBuiltinStyle::wdStyleCaption, "", word::WdStyleType::wdStyleTypeParagraph },
      51             :     { word::WdBuiltinStyle::wdStyleClosing, "", word::WdStyleType::wdStyleTypeParagraph },
      52             :     { word::WdBuiltinStyle::wdStyleCommentReference, "", word::WdStyleType::wdStyleTypeParagraph },
      53             :     { word::WdBuiltinStyle::wdStyleCommentText, "", word::WdStyleType::wdStyleTypeParagraph },
      54             :     { word::WdBuiltinStyle::wdStyleDate, "", word::WdStyleType::wdStyleTypeParagraph },
      55             :     { word::WdBuiltinStyle::wdStyleDefaultParagraphFont, "", word::WdStyleType::wdStyleTypeParagraph },
      56             :     { word::WdBuiltinStyle::wdStyleEmphasis, "", word::WdStyleType::wdStyleTypeParagraph },
      57             :     { word::WdBuiltinStyle::wdStyleEndnoteReference, "", word::WdStyleType::wdStyleTypeParagraph },
      58             :     { word::WdBuiltinStyle::wdStyleEndnoteText, "Endnote", word::WdStyleType::wdStyleTypeParagraph },
      59             :     { word::WdBuiltinStyle::wdStyleEnvelopeAddress, "", word::WdStyleType::wdStyleTypeParagraph },
      60             :     { word::WdBuiltinStyle::wdStyleEnvelopeReturn, "", word::WdStyleType::wdStyleTypeParagraph },
      61             :     { word::WdBuiltinStyle::wdStyleFooter, "", word::WdStyleType::wdStyleTypeParagraph },
      62             :     { word::WdBuiltinStyle::wdStyleFootnoteReference, "", word::WdStyleType::wdStyleTypeParagraph },
      63             :     { word::WdBuiltinStyle::wdStyleFootnoteText, "Footnote", word::WdStyleType::wdStyleTypeParagraph },
      64             :     { word::WdBuiltinStyle::wdStyleHeader, "Header", word::WdStyleType::wdStyleTypeParagraph },
      65             :     { word::WdBuiltinStyle::wdStyleHeading1, "Heading 1", word::WdStyleType::wdStyleTypeParagraph },
      66             :     { word::WdBuiltinStyle::wdStyleHeading2, "Heading 2", word::WdStyleType::wdStyleTypeParagraph },
      67             :     { word::WdBuiltinStyle::wdStyleHeading3, "Heading 3", word::WdStyleType::wdStyleTypeParagraph },
      68             :     { word::WdBuiltinStyle::wdStyleHeading4, "Heading 4", word::WdStyleType::wdStyleTypeParagraph },
      69             :     { word::WdBuiltinStyle::wdStyleHeading5, "Heading 5", word::WdStyleType::wdStyleTypeParagraph },
      70             :     { word::WdBuiltinStyle::wdStyleHeading6, "Heading 6", word::WdStyleType::wdStyleTypeParagraph },
      71             :     { word::WdBuiltinStyle::wdStyleHeading7, "Heading 7", word::WdStyleType::wdStyleTypeParagraph },
      72             :     { word::WdBuiltinStyle::wdStyleHeading8, "Heading 8", word::WdStyleType::wdStyleTypeParagraph },
      73             :     { word::WdBuiltinStyle::wdStyleHeading9, "Heading 9", word::WdStyleType::wdStyleTypeParagraph },
      74             :     { word::WdBuiltinStyle::wdStyleHtmlAcronym, "", word::WdStyleType::wdStyleTypeParagraph },
      75             :     { word::WdBuiltinStyle::wdStyleHtmlAddress, "", word::WdStyleType::wdStyleTypeParagraph },
      76             :     { word::WdBuiltinStyle::wdStyleHtmlCite, "", word::WdStyleType::wdStyleTypeParagraph },
      77             :     { word::WdBuiltinStyle::wdStyleHtmlCode, "", word::WdStyleType::wdStyleTypeParagraph },
      78             :     { word::WdBuiltinStyle::wdStyleHtmlDfn, "", word::WdStyleType::wdStyleTypeParagraph },
      79             :     { word::WdBuiltinStyle::wdStyleHtmlKbd, "", word::WdStyleType::wdStyleTypeParagraph },
      80             :     { word::WdBuiltinStyle::wdStyleHtmlNormal, "", word::WdStyleType::wdStyleTypeParagraph },
      81             :     { word::WdBuiltinStyle::wdStyleHtmlPre, "", word::WdStyleType::wdStyleTypeParagraph },
      82             :     { word::WdBuiltinStyle::wdStyleHtmlSamp, "", word::WdStyleType::wdStyleTypeParagraph },
      83             :     { word::WdBuiltinStyle::wdStyleHtmlTt, "", word::WdStyleType::wdStyleTypeParagraph },
      84             :     { word::WdBuiltinStyle::wdStyleHtmlVar, "", word::WdStyleType::wdStyleTypeParagraph },
      85             :     { word::WdBuiltinStyle::wdStyleHyperlink, "", word::WdStyleType::wdStyleTypeParagraph },
      86             :     { word::WdBuiltinStyle::wdStyleHyperlinkFollowed, "", word::WdStyleType::wdStyleTypeParagraph },
      87             :     { word::WdBuiltinStyle::wdStyleIndex1, "Index 1", word::WdStyleType::wdStyleTypeParagraph },
      88             :     { word::WdBuiltinStyle::wdStyleIndex2, "Index 2", word::WdStyleType::wdStyleTypeParagraph },
      89             :     { word::WdBuiltinStyle::wdStyleIndex3, "Index 3", word::WdStyleType::wdStyleTypeParagraph },
      90             :     { word::WdBuiltinStyle::wdStyleIndex4, "", word::WdStyleType::wdStyleTypeParagraph },
      91             :     { word::WdBuiltinStyle::wdStyleIndex5, "", word::WdStyleType::wdStyleTypeParagraph },
      92             :     { word::WdBuiltinStyle::wdStyleIndex6, "", word::WdStyleType::wdStyleTypeParagraph },
      93             :     { word::WdBuiltinStyle::wdStyleIndex7, "", word::WdStyleType::wdStyleTypeParagraph },
      94             :     { word::WdBuiltinStyle::wdStyleIndex8, "", word::WdStyleType::wdStyleTypeParagraph },
      95             :     { word::WdBuiltinStyle::wdStyleIndex9, "", word::WdStyleType::wdStyleTypeParagraph },
      96             :     { word::WdBuiltinStyle::wdStyleIndexHeading, "Index Heading", word::WdStyleType::wdStyleTypeParagraph },
      97             :     { word::WdBuiltinStyle::wdStyleLineNumber, "", word::WdStyleType::wdStyleTypeParagraph },
      98             :     { word::WdBuiltinStyle::wdStyleList, "List", word::WdStyleType::wdStyleTypeParagraph },
      99             :     { word::WdBuiltinStyle::wdStyleList2, "List 2", word::WdStyleType::wdStyleTypeParagraph },
     100             :     { word::WdBuiltinStyle::wdStyleList3, "List 3", word::WdStyleType::wdStyleTypeParagraph },
     101             :     { word::WdBuiltinStyle::wdStyleList4, "List 4", word::WdStyleType::wdStyleTypeParagraph },
     102             :     { word::WdBuiltinStyle::wdStyleList5, "List 5", word::WdStyleType::wdStyleTypeParagraph },
     103             :     { word::WdBuiltinStyle::wdStyleListBullet, "List 1", word::WdStyleType::wdStyleTypeList },
     104             :     { word::WdBuiltinStyle::wdStyleListBullet2, "List 2", word::WdStyleType::wdStyleTypeList },
     105             :     { word::WdBuiltinStyle::wdStyleListBullet3, "List 3", word::WdStyleType::wdStyleTypeList },
     106             :     { word::WdBuiltinStyle::wdStyleListBullet4, "List 4", word::WdStyleType::wdStyleTypeList },
     107             :     { word::WdBuiltinStyle::wdStyleListBullet5, "List 5", word::WdStyleType::wdStyleTypeList },
     108             :     { word::WdBuiltinStyle::wdStyleListContinue, "", word::WdStyleType::wdStyleTypeParagraph },
     109             :     { word::WdBuiltinStyle::wdStyleListContinue2, "", word::WdStyleType::wdStyleTypeParagraph },
     110             :     { word::WdBuiltinStyle::wdStyleListContinue3, "", word::WdStyleType::wdStyleTypeParagraph },
     111             :     { word::WdBuiltinStyle::wdStyleListContinue4, "", word::WdStyleType::wdStyleTypeParagraph },
     112             :     { word::WdBuiltinStyle::wdStyleListContinue5, "", word::WdStyleType::wdStyleTypeParagraph },
     113             :     { word::WdBuiltinStyle::wdStyleListNumber, "Numbering 1", word::WdStyleType::wdStyleTypeList },
     114             :     { word::WdBuiltinStyle::wdStyleListNumber2, "Numbering 2", word::WdStyleType::wdStyleTypeList },
     115             :     { word::WdBuiltinStyle::wdStyleListNumber3, "Numbering 3", word::WdStyleType::wdStyleTypeList },
     116             :     { word::WdBuiltinStyle::wdStyleListNumber4, "Numbering 4", word::WdStyleType::wdStyleTypeList },
     117             :     { word::WdBuiltinStyle::wdStyleListNumber5, "Numbering 5", word::WdStyleType::wdStyleTypeList },
     118             :     { word::WdBuiltinStyle::wdStyleMacroText, "", word::WdStyleType::wdStyleTypeParagraph },
     119             :     { word::WdBuiltinStyle::wdStyleMessageHeader, "", word::WdStyleType::wdStyleTypeParagraph },
     120             :     { word::WdBuiltinStyle::wdStyleNavPane, "", word::WdStyleType::wdStyleTypeParagraph },
     121             :     { word::WdBuiltinStyle::wdStyleNormal, "Default", word::WdStyleType::wdStyleTypeParagraph },
     122             :     { word::WdBuiltinStyle::wdStyleNormalIndent, "", word::WdStyleType::wdStyleTypeParagraph },
     123             :     { word::WdBuiltinStyle::wdStyleNormalTable, "Table", word::WdStyleType::wdStyleTypeParagraph },
     124             :     { word::WdBuiltinStyle::wdStyleNoteHeading, "", word::WdStyleType::wdStyleTypeParagraph },
     125             :     { word::WdBuiltinStyle::wdStylePageNumber, "", word::WdStyleType::wdStyleTypeParagraph },
     126             :     { word::WdBuiltinStyle::wdStylePlainText, "", word::WdStyleType::wdStyleTypeParagraph },
     127             :     { word::WdBuiltinStyle::wdStyleSalutation, "", word::WdStyleType::wdStyleTypeParagraph },
     128             :     { word::WdBuiltinStyle::wdStyleSignature, "", word::WdStyleType::wdStyleTypeParagraph },
     129             :     { word::WdBuiltinStyle::wdStyleStrong, "", word::WdStyleType::wdStyleTypeParagraph },
     130             :     { word::WdBuiltinStyle::wdStyleSubtitle, "", word::WdStyleType::wdStyleTypeParagraph },
     131             :     { word::WdBuiltinStyle::wdStyleTableOfAuthorities, "", word::WdStyleType::wdStyleTypeParagraph },
     132             :     { word::WdBuiltinStyle::wdStyleTableOfFigures, "", word::WdStyleType::wdStyleTypeParagraph },
     133             :     { word::WdBuiltinStyle::wdStyleTitle, "Title", word::WdStyleType::wdStyleTypeParagraph },
     134             :     { word::WdBuiltinStyle::wdStyleTOAHeading, "Contents Heading", word::WdStyleType::wdStyleTypeParagraph },
     135             :     { word::WdBuiltinStyle::wdStyleTOC1, "Contents 1", word::WdStyleType::wdStyleTypeParagraph },
     136             :     { word::WdBuiltinStyle::wdStyleTOC2, "Contents 2", word::WdStyleType::wdStyleTypeParagraph },
     137             :     { word::WdBuiltinStyle::wdStyleTOC3, "Contents 3", word::WdStyleType::wdStyleTypeParagraph },
     138             :     { word::WdBuiltinStyle::wdStyleTOC4, "Contents 4", word::WdStyleType::wdStyleTypeParagraph },
     139             :     { word::WdBuiltinStyle::wdStyleTOC5, "Contents 5", word::WdStyleType::wdStyleTypeParagraph },
     140             :     { word::WdBuiltinStyle::wdStyleTOC6, "Contents 6", word::WdStyleType::wdStyleTypeParagraph },
     141             :     { word::WdBuiltinStyle::wdStyleTOC7, "Contents 7", word::WdStyleType::wdStyleTypeParagraph },
     142             :     { word::WdBuiltinStyle::wdStyleTOC8, "Contents 8", word::WdStyleType::wdStyleTypeParagraph },
     143             :     { word::WdBuiltinStyle::wdStyleTOC9, "Contents 9", word::WdStyleType::wdStyleTypeParagraph },
     144             :     { 0, 0, 0 }
     145             : };
     146             : 
     147             : struct MSOStyleNameTable
     148             : {
     149             :     const sal_Char* pMSOStyleName;
     150             :     const sal_Char* pOOoStyleName;
     151             :     const sal_Char* pOOoStyleType;
     152             : };
     153             : 
     154             : static const MSOStyleNameTable aMSOStyleNameTable[] =
     155             : {
     156             :     { "Normal", "Default", "ParagraphStyles" },
     157             :     { 0, 0, 0 }
     158             : };
     159             : 
     160             : typedef ::cppu::WeakImplHelper3< container::XNameAccess, container::XIndexAccess, container::XEnumerationAccess > StyleCollectionHelper_BASE;
     161             : 
     162           0 : class StyleCollectionHelper : public StyleCollectionHelper_BASE
     163             : {
     164             : private:
     165             :     uno::Reference< frame::XModel > mxModel;
     166             :     uno::Reference< container::XNameAccess > mxParaStyles;
     167             :     uno::Any cachePos;
     168             : public:
     169           0 :     StyleCollectionHelper( const uno::Reference< frame::XModel >& _xModel ) : mxModel( _xModel )
     170             :     {
     171             :         // we only concern about the Paragraph styles
     172           0 :         uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( _xModel, uno::UNO_QUERY_THROW);
     173           0 :         uno::Reference< container::XNameAccess > xStyleFamilies = xStyleSupplier->getStyleFamilies();
     174           0 :         mxParaStyles.set( xStyleFamilies->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") ) ), uno::UNO_QUERY_THROW  );
     175           0 :     }
     176             :     // XElementAccess
     177           0 :     virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException) { return  style::XStyle::static_type(0); }
     178           0 :     virtual ::sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException) { return getCount() > 0; }
     179             :     // XNameAcess
     180           0 :     virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
     181             :     {
     182           0 :         if ( !hasByName(aName) )
     183           0 :             throw container::NoSuchElementException();
     184           0 :         return cachePos;
     185             :     }
     186           0 :     virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException)
     187             :     {
     188           0 :         return mxParaStyles->getElementNames();
     189             :     }
     190           0 :     virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
     191             :     {
     192             :         // search in the MSOStyleName table first
     193           0 :         for( const MSOStyleNameTable* pTable = aMSOStyleNameTable; pTable->pMSOStyleName != NULL; pTable++ )
     194             :         {
     195           0 :             if( aName.equalsIgnoreAsciiCaseAscii( pTable->pMSOStyleName ) )
     196             :             {
     197             :                 //Found it
     198           0 :                 rtl::OUString sStyleName = rtl::OUString::createFromAscii( pTable->pOOoStyleName );
     199           0 :                 if( mxParaStyles->hasByName( sStyleName ) )
     200             :                 {
     201           0 :                     cachePos = mxParaStyles->getByName( sStyleName );
     202           0 :                     return sal_True;
     203             :                 }
     204           0 :                 return sal_False;
     205             :             }
     206             :         }
     207             : 
     208           0 :         if( mxParaStyles->hasByName( aName ) )
     209             :         {
     210           0 :             cachePos = mxParaStyles->getByName( aName );
     211           0 :             return sal_True;
     212             :         }
     213             :         else
     214             :         {
     215           0 :             uno::Sequence< rtl::OUString > sElementNames = mxParaStyles->getElementNames();
     216           0 :             for( sal_Int32 j = 0; j < sElementNames.getLength(); j++ )
     217             :             {
     218           0 :                 rtl::OUString aStyleName = sElementNames[j];
     219           0 :                 if( aStyleName.equalsIgnoreAsciiCase( aName ) )
     220             :                 {
     221           0 :                     cachePos = mxParaStyles->getByName( aStyleName );
     222           0 :                     return sal_True;
     223             :                 }
     224           0 :             }
     225             :         }
     226           0 :         return sal_False;
     227             :     }
     228             : 
     229             :     // XIndexAccess
     230           0 :     virtual ::sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException)
     231             :     {
     232           0 :         uno::Reference< container::XIndexAccess > xIndexAccess( mxParaStyles, uno::UNO_QUERY_THROW );
     233           0 :         return xIndexAccess->getCount();
     234             :     }
     235           0 :     virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
     236             :     {
     237           0 :         if ( Index < 0 || Index >= getCount() )
     238           0 :             throw lang::IndexOutOfBoundsException();
     239             : 
     240           0 :         uno::Reference< container::XIndexAccess > xIndexAccess( mxParaStyles, uno::UNO_QUERY_THROW );
     241           0 :         return xIndexAccess->getByIndex( Index );
     242             :     }
     243             :     // XEnumerationAccess
     244           0 :     virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration(  ) throw (uno::RuntimeException)
     245             :     {
     246           0 :         throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
     247             :     }
     248             : };
     249             : 
     250           0 : class StylesEnumWrapper : public EnumerationHelper_BASE
     251             : {
     252             :     SwVbaStyles* pStyles;
     253             :     sal_Int32 nIndex;
     254             : public:
     255           0 :     StylesEnumWrapper( SwVbaStyles* _pStyles ) : pStyles( _pStyles ), nIndex( 1 ) {}
     256           0 :     virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException)
     257             :     {
     258           0 :         return ( nIndex <= pStyles->getCount() );
     259             :     }
     260             : 
     261           0 :     virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
     262             :     {
     263           0 :         if ( nIndex <= pStyles->getCount() )
     264           0 :             return pStyles->Item( uno::makeAny( nIndex++ ), uno::Any() );
     265           0 :         throw container::NoSuchElementException();
     266             :     }
     267             : };
     268             : 
     269           0 : SwVbaStyles::SwVbaStyles( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ) throw ( script::BasicErrorException ) : SwVbaStyles_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new StyleCollectionHelper( xModel )  ) ), mxModel( xModel )
     270             : {
     271           0 :     mxMSF.set( mxModel, uno::UNO_QUERY_THROW );
     272           0 : }
     273             : 
     274             : uno::Any
     275           0 : SwVbaStyles::createCollectionObject(const uno::Any& aObject)
     276             : {
     277           0 :     uno::Reference< beans::XPropertySet > xStyleProp( aObject, uno::UNO_QUERY_THROW );
     278           0 :     return uno::makeAny( uno::Reference< word::XStyle >( new SwVbaStyle( this, mxContext, mxModel, xStyleProp ) ) );
     279             : }
     280             : 
     281             : uno::Type SAL_CALL
     282           0 : SwVbaStyles::getElementType() throw (uno::RuntimeException)
     283             : {
     284           0 :     return word::XStyle::static_type(0);
     285             : }
     286             : 
     287             : uno::Reference< container::XEnumeration > SAL_CALL
     288           0 : SwVbaStyles::createEnumeration() throw (uno::RuntimeException)
     289             : {
     290           0 :     return new StylesEnumWrapper( this );
     291             : }
     292             : 
     293             : uno::Any SAL_CALL
     294           0 : SwVbaStyles::Item( const uno::Any& Index1, const uno::Any& Index2 ) throw (uno::RuntimeException)
     295             : {
     296             :     //handle WdBuiltinStyle
     297           0 :     sal_Int32 nIndex = 0;
     298           0 :     if( ( Index1 >>= nIndex ) && ( nIndex < 0 ) )
     299             :     {
     300           0 :         for( const BuiltinStyleTable* pTable = aBuiltinStyleTable; pTable != NULL; pTable++ )
     301             :         {
     302           0 :             if( nIndex == pTable->wdBuiltinStyle )
     303             :             {
     304           0 :                 rtl::OUString aStyleName = rtl::OUString::createFromAscii( pTable->pOOoStyleName );
     305           0 :                 if( !aStyleName.isEmpty() )
     306             :                 {
     307           0 :                     rtl::OUString aStyleType;
     308           0 :                     switch( pTable->wdStyleType )
     309             :                     {
     310             :                         case word::WdStyleType::wdStyleTypeParagraph:
     311             :                         case word::WdStyleType::wdStyleTypeTable:
     312             :                         {
     313           0 :                             aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") );
     314           0 :                             break;
     315             :                         }
     316             :                         case word::WdStyleType::wdStyleTypeCharacter:
     317             :                         {
     318           0 :                             aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharacterStyles") );
     319           0 :                             break;
     320             :                         }
     321             :                         case word::WdStyleType::wdStyleTypeList:
     322             :                         {
     323             :                             // should use Paragraph style and set the property "NumberingStyleName"
     324           0 :                             aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") );
     325           0 :                             break;
     326             :                         }
     327             :                         default:
     328           0 :                             DebugHelper::exception( SbERR_INTERNAL_ERROR, rtl::OUString() );
     329             :                     }
     330           0 :                     uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxModel, uno::UNO_QUERY_THROW);
     331           0 :                     uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName( aStyleType ), uno::UNO_QUERY_THROW );
     332           0 :                     uno::Reference< beans::XPropertySet > xStyleProps( xStylesAccess->getByName( aStyleName ), uno::UNO_QUERY_THROW );
     333             :                     // set the property "NumberingStyleName" if it is a listbullet
     334           0 :                     if( pTable->wdStyleType == word::WdStyleType::wdStyleTypeList )
     335             :                     {
     336           0 :                         xStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingStyleName") ), uno::makeAny( aStyleName ) );
     337             :                     }
     338           0 :                     return uno::makeAny( uno::Reference< word::XStyle >( new SwVbaStyle( this, mxContext, mxModel, xStyleProps ) ) );
     339             :                 }
     340             :                 else
     341             :                 {
     342             :                     OSL_TRACE("SwVbaStyles::Item: the builtin style type is not implemented");
     343           0 :                     throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
     344           0 :                 }
     345             :             }
     346             :         }
     347             :     }
     348           0 :     return SwVbaStyles_BASE::Item( Index1, Index2 );
     349             : }
     350             : 
     351             : rtl::OUString
     352           0 : SwVbaStyles::getServiceImplName()
     353             : {
     354           0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaStyles"));
     355             : }
     356             : 
     357             : uno::Sequence< rtl::OUString >
     358           0 : SwVbaStyles::getServiceNames()
     359             : {
     360           0 :     static uno::Sequence< rtl::OUString > aServiceNames;
     361           0 :     if ( aServiceNames.getLength() == 0 )
     362             :     {
     363           0 :         aServiceNames.realloc( 1 );
     364           0 :         aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.XStyles" ) );
     365             :     }
     366           0 :     return aServiceNames;
     367             : }
     368             : 
     369             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10