LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbastyle.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 108 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 22 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             : 
      20             : #include "vbastyle.hxx"
      21             : #include <ooo/vba/word/WdStyleType.hpp>
      22             : #include <com/sun/star/lang/Locale.hpp>
      23             : #include <com/sun/star/text/XTextDocument.hpp>
      24             : #include <i18nlangtag/languagetag.hxx>
      25             : #include "vbafont.hxx"
      26             : #include "vbapalette.hxx"
      27             : #include "vbaparagraphformat.hxx"
      28             : #include "vbastyles.hxx"
      29             : 
      30             : using namespace ::ooo::vba;
      31             : using namespace ::com::sun::star;
      32             : 
      33           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 )
      34             : {
      35           0 :     mxStyle.set( _xPropertySet, uno::UNO_QUERY_THROW );
      36           0 : }
      37             : 
      38             : void SAL_CALL
      39           0 : SwVbaStyle::setName( const OUString& Name ) throw (uno::RuntimeException, std::exception)
      40             : {
      41           0 :     mxStyle->setName(Name);
      42           0 : }
      43             : 
      44             : OUString SAL_CALL
      45           0 : SwVbaStyle::getName() throw (uno::RuntimeException, std::exception)
      46             : {
      47           0 :     return mxStyle->getName();
      48             : }
      49             : 
      50           0 : sal_Int32 SwVbaStyle::getLanguageID( const uno::Reference< beans::XPropertySet >& xTCProps ) throw (uno::RuntimeException)
      51             : {
      52           0 :     lang::Locale aLocale;
      53           0 :     xTCProps->getPropertyValue("CharLocale") >>= aLocale;
      54           0 :     return LanguageTag::convertToLanguageType( aLocale, false);
      55             : }
      56             : 
      57           0 : void SwVbaStyle::setLanguageID( const uno::Reference< beans::XPropertySet >& xTCProps, sal_Int32 _languageid ) throw (uno::RuntimeException)
      58             : {
      59           0 :     lang::Locale aLocale = LanguageTag( static_cast<LanguageType>(_languageid) ).getLocale();
      60           0 :     xTCProps->setPropertyValue("CharLocale", uno::makeAny( aLocale ) ) ;
      61           0 : }
      62             : 
      63           0 : ::sal_Int32 SAL_CALL SwVbaStyle::getLanguageID() throw (uno::RuntimeException, std::exception)
      64             : {
      65           0 :     return getLanguageID( mxStyleProps );
      66             : }
      67             : 
      68           0 : void SAL_CALL SwVbaStyle::setLanguageID( ::sal_Int32 _languageid ) throw (uno::RuntimeException, std::exception)
      69             : {
      70           0 :     setLanguageID( mxStyleProps, _languageid );
      71           0 : }
      72             : 
      73           0 : ::sal_Int32 SAL_CALL SwVbaStyle::getType() throw (uno::RuntimeException, std::exception)
      74             : {
      75           0 :     sal_Int32 nType = word::WdStyleType::wdStyleTypeParagraph;
      76           0 :     uno::Reference< lang::XServiceInfo > xServiceInfo( mxStyle, uno::UNO_QUERY_THROW );
      77           0 :     if( xServiceInfo->supportsService("com.sun.star.style.ParagraphStyle") )
      78           0 :         nType = word::WdStyleType::wdStyleTypeParagraph;
      79           0 :     else if( xServiceInfo->supportsService("com.sun.star.style.CharacterStyle") )
      80           0 :         nType = word::WdStyleType::wdStyleTypeCharacter;
      81             :     else
      82           0 :         nType = word::WdStyleType::wdStyleTypeList;
      83           0 :     return nType;
      84             : }
      85             : 
      86             : uno::Reference< word::XFont > SAL_CALL
      87           0 : SwVbaStyle::getFont() throw ( uno::RuntimeException, std::exception )
      88             : {
      89           0 :     VbaPalette aColors;
      90           0 :     return new SwVbaFont( mxParent, mxContext, aColors.getPalette(), mxStyleProps );
      91             : }
      92             : 
      93           0 : void SwVbaStyle::setStyle( const uno::Reference< beans::XPropertySet >& xParaProps, const uno::Any& rStyle )throw (uno::RuntimeException)
      94             : {
      95           0 :     OUString sStyle;
      96           0 :     uno::Reference< word::XStyle > xStyle;
      97           0 :     if( rStyle >>= xStyle )
      98             :     {
      99           0 :         sStyle = xStyle->getName();
     100             :     }
     101             :     else
     102             :     {
     103           0 :         rStyle >>= sStyle;
     104             :     }
     105             : 
     106           0 :     if( !sStyle.isEmpty() )
     107             :     {
     108           0 :         xParaProps->setPropertyValue("ParaStyleName", uno::makeAny( sStyle ) );
     109           0 :         return;
     110             :     }
     111             : 
     112           0 :     throw uno::RuntimeException();
     113             : }
     114             : 
     115           0 : OUString SAL_CALL SwVbaStyle::getNameLocal() throw (uno::RuntimeException, std::exception)
     116             : {
     117           0 :     OUString sNameLocal;
     118           0 :     mxStyleProps->getPropertyValue("DisplayName") >>= sNameLocal;
     119           0 :     return sNameLocal;
     120             : }
     121             : 
     122           0 : void SAL_CALL SwVbaStyle::setNameLocal( const OUString& _namelocal ) throw (uno::RuntimeException, std::exception)
     123             : {
     124           0 :     mxStyleProps->setPropertyValue("DisplayName", uno::makeAny( _namelocal ) );
     125           0 : }
     126             : 
     127           0 : uno::Reference< word::XParagraphFormat > SAL_CALL SwVbaStyle::getParagraphFormat() throw (uno::RuntimeException, std::exception)
     128             : {
     129           0 :     if( word::WdStyleType::wdStyleTypeParagraph == getType() )
     130             :     {
     131           0 :         uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW );
     132           0 :         return uno::Reference< word::XParagraphFormat >( new SwVbaParagraphFormat( this, mxContext, xTextDocument, mxStyleProps ) );
     133             :     }
     134             :     else
     135             :     {
     136           0 :         throw uno::RuntimeException();
     137             :     }
     138             : }
     139             : 
     140           0 : sal_Bool SAL_CALL SwVbaStyle::getAutomaticallyUpdate() throw (uno::RuntimeException, std::exception)
     141             : {
     142           0 :     bool isAutoUpdate = false;
     143           0 :     mxStyleProps->getPropertyValue("IsAutoUpdate") >>= isAutoUpdate;
     144           0 :     return isAutoUpdate;
     145             : }
     146             : 
     147           0 : void SAL_CALL SwVbaStyle::setAutomaticallyUpdate( sal_Bool _automaticallyupdate ) throw (uno::RuntimeException, std::exception)
     148             : {
     149           0 :     mxStyleProps->setPropertyValue("IsAutoUpdate", uno::makeAny( _automaticallyupdate ) );
     150           0 : }
     151             : 
     152           0 : uno::Any SAL_CALL SwVbaStyle::getBaseStyle() throw (uno::RuntimeException, std::exception)
     153             : {
     154             :     // ParentStyle
     155           0 :     OUString sBaseStyle;
     156           0 :     mxStyleProps->getPropertyValue("ParentStyle") >>= sBaseStyle;
     157           0 :     if( !sBaseStyle.isEmpty() )
     158             :     {
     159           0 :         uno::Reference< XCollection > xCol( new SwVbaStyles( this, mxContext, mxModel ) );
     160           0 :         return xCol->Item( uno::makeAny( sBaseStyle ), uno::Any() );
     161             :     }
     162             :     else
     163             :     {
     164           0 :         throw uno::RuntimeException();
     165           0 :     }
     166             : }
     167             : 
     168           0 : void SAL_CALL SwVbaStyle::setBaseStyle( const uno::Any& _basestyle ) throw (uno::RuntimeException, std::exception)
     169             : {
     170           0 :     uno::Reference< word::XStyle > xStyle;
     171           0 :     _basestyle >>= xStyle;
     172           0 :     if( xStyle.is() )
     173             :     {
     174           0 :         OUString sBaseStyle = xStyle->getName();
     175           0 :         mxStyleProps->setPropertyValue("ParentStyle", uno::makeAny( sBaseStyle ) );
     176             :     }
     177             :     else
     178             :     {
     179           0 :         throw uno::RuntimeException();
     180           0 :     }
     181           0 : }
     182             : 
     183           0 : uno::Any SAL_CALL SwVbaStyle::getNextParagraphStyle() throw (uno::RuntimeException, std::exception)
     184             : {
     185             :     //FollowStyle
     186           0 :     OUString sFollowStyle;
     187           0 :     mxStyleProps->getPropertyValue("FollowStyle") >>= sFollowStyle;
     188           0 :     if( !sFollowStyle.isEmpty() )
     189             :     {
     190           0 :         uno::Reference< XCollection > xCol( new SwVbaStyles( this, mxContext, mxModel ) );
     191           0 :         return xCol->Item( uno::makeAny( sFollowStyle ), uno::Any() );
     192             :     }
     193             :     else
     194             :     {
     195           0 :         throw uno::RuntimeException();
     196           0 :     }
     197             : }
     198             : 
     199           0 : void SAL_CALL SwVbaStyle::setNextParagraphStyle( const uno::Any& _nextparagraphstyle ) throw (uno::RuntimeException, std::exception)
     200             : {
     201           0 :     uno::Reference< word::XStyle > xStyle;
     202           0 :     _nextparagraphstyle >>= xStyle;
     203           0 :     if( xStyle.is() )
     204             :     {
     205           0 :         OUString sFollowStyle = xStyle->getName();
     206           0 :         mxStyleProps->setPropertyValue("FollowStyle", uno::makeAny( sFollowStyle ) );
     207             :     }
     208             :     else
     209             :     {
     210           0 :         throw uno::RuntimeException();
     211           0 :     }
     212           0 : }
     213             : 
     214           0 : ::sal_Int32 SAL_CALL SwVbaStyle::getListLevelNumber() throw (uno::RuntimeException, std::exception)
     215             : {
     216           0 :     sal_Int16 nNumberingLevel = 0;
     217           0 :     mxStyleProps->getPropertyValue("NumberingLevel") >>= nNumberingLevel;
     218           0 :     return nNumberingLevel;
     219             : }
     220             : 
     221             : OUString
     222           0 : SwVbaStyle::getServiceImplName()
     223             : {
     224           0 :     return OUString("SwVbaStyle");
     225             : }
     226             : 
     227             : uno::Sequence< OUString >
     228           0 : SwVbaStyle::getServiceNames()
     229             : {
     230           0 :     static uno::Sequence< OUString > aServiceNames;
     231           0 :     if ( aServiceNames.getLength() == 0 )
     232             :     {
     233           0 :         aServiceNames.realloc( 1 );
     234           0 :         aServiceNames[ 0 ] = "ooo.vba.word.XStyle";
     235             :     }
     236           0 :     return aServiceNames;
     237             : }
     238             : 
     239             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11