LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbastyle.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 108 0.0 %
Date: 2012-08-25 Functions: 0 22 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 210 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "vbastyle.hxx"
      30                 :            : #include <ooo/vba/word/WdStyleType.hpp>
      31                 :            : #include <com/sun/star/lang/Locale.hpp>
      32                 :            : #include <com/sun/star/text/XTextDocument.hpp>
      33                 :            : #include <i18npool/mslangid.hxx>
      34                 :            : #include "vbafont.hxx"
      35                 :            : #include "vbapalette.hxx"
      36                 :            : #include "vbaparagraphformat.hxx"
      37                 :            : #include "vbastyles.hxx"
      38                 :            : 
      39                 :            : using namespace ::ooo::vba;
      40                 :            : using namespace ::com::sun::star;
      41                 :            : 
      42                 :            : 
      43                 :          0 : SwVbaStyle::SwVbaStyle( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel>& xModel, const uno::Reference< beans::XPropertySet >& _xPropertySet ) throw ( script::BasicErrorException, uno::RuntimeException ) : SwVbaStyle_BASE( xParent, xContext ) , mxModel( xModel ), mxStyleProps( _xPropertySet )
      44                 :            : {
      45         [ #  # ]:          0 :     mxStyle.set( _xPropertySet, uno::UNO_QUERY_THROW );
      46                 :          0 : }
      47                 :            : 
      48                 :            : void SAL_CALL
      49                 :          0 : SwVbaStyle::setName( const ::rtl::OUString& Name ) throw (uno::RuntimeException)
      50                 :            : {
      51                 :          0 :     mxStyle->setName(Name);
      52                 :          0 : }
      53                 :            : 
      54                 :            : ::rtl::OUString SAL_CALL
      55                 :          0 : SwVbaStyle::getName() throw (uno::RuntimeException)
      56                 :            : {
      57                 :          0 :     return mxStyle->getName();
      58                 :            : }
      59                 :            : 
      60                 :          0 : sal_Int32 SwVbaStyle::getLanguageID( const uno::Reference< beans::XPropertySet >& xTCProps ) throw (uno::RuntimeException)
      61                 :            : {
      62                 :          0 :     lang::Locale aLocale;
      63 [ #  # ][ #  # ]:          0 :     xTCProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharLocale") ) ) >>= aLocale;
         [ #  # ][ #  # ]
      64         [ #  # ]:          0 :     return MsLangId::convertLocaleToLanguage( aLocale );
      65                 :            : }
      66                 :            : 
      67                 :          0 : void SwVbaStyle::setLanguageID( const uno::Reference< beans::XPropertySet >& xTCProps, sal_Int32 _languageid ) throw (uno::RuntimeException)
      68                 :            : {
      69         [ #  # ]:          0 :     lang::Locale aLocale = MsLangId::convertLanguageToLocale( static_cast<LanguageType>(_languageid) );
      70 [ #  # ][ #  # ]:          0 :     xTCProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharLocale") ), uno::makeAny( aLocale ) ) ;
         [ #  # ][ #  # ]
      71                 :          0 : }
      72                 :            : 
      73                 :          0 : ::sal_Int32 SAL_CALL SwVbaStyle::getLanguageID() throw (uno::RuntimeException)
      74                 :            : {
      75                 :          0 :     return getLanguageID( mxStyleProps );
      76                 :            : }
      77                 :            : 
      78                 :          0 : void SAL_CALL SwVbaStyle::setLanguageID( ::sal_Int32 _languageid ) throw (uno::RuntimeException)
      79                 :            : {
      80                 :          0 :     setLanguageID( mxStyleProps, _languageid );
      81                 :          0 : }
      82                 :            : 
      83                 :          0 : ::sal_Int32 SAL_CALL SwVbaStyle::getType() throw (uno::RuntimeException)
      84                 :            : {
      85                 :          0 :     sal_Int32 nType = word::WdStyleType::wdStyleTypeParagraph;
      86         [ #  # ]:          0 :     uno::Reference< lang::XServiceInfo > xServiceInfo( mxStyle, uno::UNO_QUERY_THROW );
      87 [ #  # ][ #  # ]:          0 :     if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.ParagraphStyle") ) ) )
         [ #  # ][ #  # ]
      88                 :          0 :         nType = word::WdStyleType::wdStyleTypeParagraph;
      89 [ #  # ][ #  # ]:          0 :     else if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.CharacterStyle") ) ) )
         [ #  # ][ #  # ]
      90                 :          0 :         nType = word::WdStyleType::wdStyleTypeCharacter;
      91                 :            :     else
      92                 :          0 :         nType = word::WdStyleType::wdStyleTypeList;
      93                 :          0 :     return nType;
      94                 :            : }
      95                 :            : 
      96                 :            : uno::Reference< word::XFont > SAL_CALL
      97                 :          0 : SwVbaStyle::getFont() throw ( uno::RuntimeException )
      98                 :            : {
      99         [ #  # ]:          0 :     VbaPalette aColors;
     100 [ #  # ][ #  # ]:          0 :     return new SwVbaFont( mxParent, mxContext, aColors.getPalette(), mxStyleProps );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     101                 :            : }
     102                 :            : 
     103                 :          0 : void SwVbaStyle::setStyle( const uno::Reference< beans::XPropertySet >& xParaProps, const uno::Any& rStyle )throw (uno::RuntimeException)
     104                 :            : {
     105                 :          0 :     rtl::OUString sStyle;
     106                 :          0 :     uno::Reference< word::XStyle > xStyle;
     107 [ #  # ][ #  # ]:          0 :     if( rStyle >>= xStyle )
     108                 :            :     {
     109 [ #  # ][ #  # ]:          0 :         sStyle = xStyle->getName();
     110                 :            :     }
     111                 :            :     else
     112                 :            :     {
     113                 :          0 :         rStyle >>= sStyle;
     114                 :            :     }
     115                 :            : 
     116         [ #  # ]:          0 :     if( !sStyle.isEmpty() )
     117                 :            :     {
     118 [ #  # ][ #  # ]:          0 :         xParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaStyleName") ), uno::makeAny( sStyle ) );
         [ #  # ][ #  # ]
     119                 :          0 :         return;
     120                 :            :     }
     121                 :            : 
     122         [ #  # ]:          0 :     throw uno::RuntimeException();
     123                 :            : }
     124                 :            : 
     125                 :          0 : ::rtl::OUString SAL_CALL SwVbaStyle::getNameLocal() throw (uno::RuntimeException)
     126                 :            : {
     127                 :          0 :     rtl::OUString sNameLocal;
     128 [ #  # ][ #  # ]:          0 :     mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DisplayName") ) ) >>= sNameLocal;
                 [ #  # ]
     129                 :          0 :     return sNameLocal;
     130                 :            : }
     131                 :            : 
     132                 :          0 : void SAL_CALL SwVbaStyle::setNameLocal( const ::rtl::OUString& _namelocal ) throw (uno::RuntimeException)
     133                 :            : {
     134 [ #  # ][ #  # ]:          0 :     mxStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DisplayName") ), uno::makeAny( _namelocal ) );
     135                 :          0 : }
     136                 :            : 
     137                 :          0 : uno::Reference< word::XParagraphFormat > SAL_CALL SwVbaStyle::getParagraphFormat() throw (uno::RuntimeException)
     138                 :            : {
     139         [ #  # ]:          0 :     if( word::WdStyleType::wdStyleTypeParagraph == getType() )
     140                 :            :     {
     141         [ #  # ]:          0 :         uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW );
     142 [ #  # ][ #  # ]:          0 :         return uno::Reference< word::XParagraphFormat >( new SwVbaParagraphFormat( this, mxContext, xTextDocument, mxStyleProps ) );
         [ #  # ][ #  # ]
     143                 :            :     }
     144                 :            :     else
     145                 :            :     {
     146         [ #  # ]:          0 :         throw uno::RuntimeException();
     147                 :            :     }
     148                 :            : }
     149                 :            : 
     150                 :          0 : ::sal_Bool SAL_CALL SwVbaStyle::getAutomaticallyUpdate() throw (uno::RuntimeException)
     151                 :            : {
     152                 :          0 :     sal_Bool isAutoUpdate = sal_False;
     153 [ #  # ][ #  # ]:          0 :     mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsAutoUpdate") ) ) >>= isAutoUpdate;
                 [ #  # ]
     154                 :          0 :     return isAutoUpdate;
     155                 :            : }
     156                 :            : 
     157                 :          0 : void SAL_CALL SwVbaStyle::setAutomaticallyUpdate( ::sal_Bool _automaticallyupdate ) throw (uno::RuntimeException)
     158                 :            : {
     159 [ #  # ][ #  # ]:          0 :     mxStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsAutoUpdate") ), uno::makeAny( _automaticallyupdate ) );
     160                 :          0 : }
     161                 :            : 
     162                 :          0 : uno::Any SAL_CALL SwVbaStyle::getBaseStyle() throw (uno::RuntimeException)
     163                 :            : {
     164                 :            :     // ParentStyle
     165                 :          0 :     rtl::OUString sBaseStyle;
     166 [ #  # ][ #  # ]:          0 :     mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParentStyle") ) ) >>= sBaseStyle;
                 [ #  # ]
     167         [ #  # ]:          0 :     if( !sBaseStyle.isEmpty() )
     168                 :            :     {
     169 [ #  # ][ #  # ]:          0 :         uno::Reference< XCollection > xCol( new SwVbaStyles( this, mxContext, mxModel ) );
         [ #  # ][ #  # ]
     170 [ #  # ][ #  # ]:          0 :         return xCol->Item( uno::makeAny( sBaseStyle ), uno::Any() );
                 [ #  # ]
     171                 :            :     }
     172                 :            :     else
     173                 :            :     {
     174         [ #  # ]:          0 :         throw uno::RuntimeException();
     175                 :          0 :     }
     176                 :            : }
     177                 :            : 
     178                 :          0 : void SAL_CALL SwVbaStyle::setBaseStyle( const uno::Any& _basestyle ) throw (uno::RuntimeException)
     179                 :            : {
     180                 :          0 :     uno::Reference< word::XStyle > xStyle;
     181         [ #  # ]:          0 :     _basestyle >>= xStyle;
     182         [ #  # ]:          0 :     if( xStyle.is() )
     183                 :            :     {
     184 [ #  # ][ #  # ]:          0 :         rtl::OUString sBaseStyle = xStyle->getName();
     185 [ #  # ][ #  # ]:          0 :         mxStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParentStyle") ), uno::makeAny( sBaseStyle ) );
         [ #  # ][ #  # ]
     186                 :            :     }
     187                 :            :     else
     188                 :            :     {
     189         [ #  # ]:          0 :         throw uno::RuntimeException();
     190                 :          0 :     }
     191                 :          0 : }
     192                 :            : 
     193                 :          0 : uno::Any SAL_CALL SwVbaStyle::getNextParagraphStyle() throw (uno::RuntimeException)
     194                 :            : {
     195                 :            :     //FollowStyle
     196                 :          0 :     rtl::OUString sFollowStyle;
     197 [ #  # ][ #  # ]:          0 :     mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FollowStyle") ) ) >>= sFollowStyle;
                 [ #  # ]
     198         [ #  # ]:          0 :     if( !sFollowStyle.isEmpty() )
     199                 :            :     {
     200 [ #  # ][ #  # ]:          0 :         uno::Reference< XCollection > xCol( new SwVbaStyles( this, mxContext, mxModel ) );
         [ #  # ][ #  # ]
     201 [ #  # ][ #  # ]:          0 :         return xCol->Item( uno::makeAny( sFollowStyle ), uno::Any() );
                 [ #  # ]
     202                 :            :     }
     203                 :            :     else
     204                 :            :     {
     205         [ #  # ]:          0 :         throw uno::RuntimeException();
     206                 :          0 :     }
     207                 :            : }
     208                 :            : 
     209                 :          0 : void SAL_CALL SwVbaStyle::setNextParagraphStyle( const uno::Any& _nextparagraphstyle ) throw (uno::RuntimeException)
     210                 :            : {
     211                 :          0 :     uno::Reference< word::XStyle > xStyle;
     212         [ #  # ]:          0 :     _nextparagraphstyle >>= xStyle;
     213         [ #  # ]:          0 :     if( xStyle.is() )
     214                 :            :     {
     215 [ #  # ][ #  # ]:          0 :         rtl::OUString sFollowStyle = xStyle->getName();
     216 [ #  # ][ #  # ]:          0 :         mxStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FollowStyle") ), uno::makeAny( sFollowStyle ) );
         [ #  # ][ #  # ]
     217                 :            :     }
     218                 :            :     else
     219                 :            :     {
     220         [ #  # ]:          0 :         throw uno::RuntimeException();
     221                 :          0 :     }
     222                 :          0 : }
     223                 :            : 
     224                 :          0 : ::sal_Int32 SAL_CALL SwVbaStyle::getListLevelNumber() throw (uno::RuntimeException)
     225                 :            : {
     226                 :          0 :     sal_Int16 nNumberingLevel = 0;
     227 [ #  # ][ #  # ]:          0 :     mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingLevel") ) ) >>= nNumberingLevel;
                 [ #  # ]
     228                 :          0 :     return nNumberingLevel;
     229                 :            : }
     230                 :            : 
     231                 :            : rtl::OUString
     232                 :          0 : SwVbaStyle::getServiceImplName()
     233                 :            : {
     234                 :          0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaStyle"));
     235                 :            : }
     236                 :            : 
     237                 :            : uno::Sequence< rtl::OUString >
     238                 :          0 : SwVbaStyle::getServiceNames()
     239                 :            : {
     240 [ #  # ][ #  # ]:          0 :     static uno::Sequence< rtl::OUString > aServiceNames;
         [ #  # ][ #  # ]
     241         [ #  # ]:          0 :     if ( aServiceNames.getLength() == 0 )
     242                 :            :     {
     243                 :          0 :         aServiceNames.realloc( 1 );
     244         [ #  # ]:          0 :         aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.XStyle" ) );
     245                 :            :     }
     246                 :          0 :     return aServiceNames;
     247                 :            : }
     248                 :            : 
     249                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10