LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/vba - vbastyle.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 66 0.0 %
Date: 2012-12-27 Functions: 0 17 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 <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      22             : 
      23             : using namespace ::ooo::vba;
      24             : using namespace ::com::sun::star;
      25             : 
      26           0 : static rtl::OUString DISPLAYNAME( RTL_CONSTASCII_USTRINGPARAM("DisplayName") );
      27             : 
      28             : 
      29             : 
      30             : uno::Reference< container::XNameAccess >
      31           0 : ScVbaStyle::getStylesNameContainer( const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException )
      32             : {
      33           0 :     uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( xModel, uno::UNO_QUERY_THROW);
      34           0 :     uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CellStyles" ) ) ), uno::UNO_QUERY_THROW );
      35           0 :     return xStylesAccess;
      36             : }
      37             : 
      38             : static uno::Reference< beans::XPropertySet >
      39           0 : lcl_getStyleProps( const rtl::OUString& sStyleName, const uno::Reference< frame::XModel >& xModel ) throw ( script::BasicErrorException, uno::RuntimeException )
      40             : {
      41             : 
      42           0 :     uno::Reference< beans::XPropertySet > xStyleProps( ScVbaStyle::getStylesNameContainer( xModel )->getByName( sStyleName ), uno::UNO_QUERY_THROW );
      43           0 :     return xStyleProps;
      44             : }
      45             : 
      46             : 
      47           0 : void ScVbaStyle::initialise() throw ( uno::RuntimeException )
      48             : {
      49           0 :     if (!mxModel.is() )
      50           0 :         DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XModel Interface could not be retrieved")) );
      51           0 :     uno::Reference< lang::XServiceInfo > xServiceInfo( mxPropertySet, uno::UNO_QUERY_THROW );
      52           0 :     if ( !xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.CellStyle" ) ) ) )
      53             :     {
      54           0 :             DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
      55             :     }
      56           0 :     mxStyle.set( mxPropertySet, uno::UNO_QUERY_THROW );
      57             : 
      58           0 :     uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxModel, uno::UNO_QUERY_THROW );
      59           0 :     mxStyleFamilyNameContainer.set(  ScVbaStyle::getStylesNameContainer( mxModel ), uno::UNO_QUERY_THROW );
      60             : 
      61           0 : }
      62             : 
      63           0 : ScVbaStyle::ScVbaStyle( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const rtl::OUString& sStyleName, const uno::Reference< frame::XModel >& _xModel ) throw ( script::BasicErrorException, uno::RuntimeException ) :  ScVbaStyle_BASE( xParent, xContext, lcl_getStyleProps( sStyleName, _xModel ), _xModel, false ), mxModel( _xModel )
      64             : {
      65             :     try
      66             :     {
      67           0 :         initialise();
      68             :     }
      69           0 :     catch (const uno::Exception& )
      70             :     {
      71           0 :         DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
      72             :     }
      73           0 : }
      74             : 
      75           0 : ScVbaStyle::ScVbaStyle( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet, const uno::Reference< frame::XModel >& _xModel ) throw ( script::BasicErrorException, uno::RuntimeException ) : ScVbaStyle_BASE( xParent, xContext, _xPropertySet, _xModel, false ),  mxModel( _xModel )
      76             : {
      77             :     try
      78             :     {
      79           0 :         initialise();
      80             :     }
      81           0 :     catch (const uno::Exception& )
      82             :     {
      83           0 :         DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
      84             :     }
      85           0 : }
      86             : 
      87             : 
      88             : ::sal_Bool SAL_CALL
      89           0 : ScVbaStyle::BuiltIn() throw (script::BasicErrorException, uno::RuntimeException)
      90             : {
      91           0 :     return !mxStyle->isUserDefined();
      92             : 
      93             : }
      94             : void SAL_CALL
      95           0 : ScVbaStyle::setName( const ::rtl::OUString& Name ) throw (script::BasicErrorException, uno::RuntimeException)
      96             : {
      97           0 :     mxStyle->setName(Name);
      98           0 : }
      99             : 
     100             : ::rtl::OUString SAL_CALL
     101           0 : ScVbaStyle::getName() throw (script::BasicErrorException, uno::RuntimeException)
     102             : {
     103           0 :     return mxStyle->getName();
     104             : }
     105             : 
     106             : void SAL_CALL
     107           0 : ScVbaStyle::setNameLocal( const ::rtl::OUString& NameLocal ) throw (script::BasicErrorException, uno::RuntimeException)
     108             : {
     109             :     try
     110             :     {
     111           0 :         mxPropertySet->setPropertyValue(DISPLAYNAME, uno::makeAny( NameLocal ) );
     112             :     }
     113           0 :     catch (const uno::Exception& e)
     114             :     {
     115           0 :         DebugHelper::exception(e);
     116             :     }
     117           0 : }
     118             : 
     119             : ::rtl::OUString SAL_CALL
     120           0 : ScVbaStyle::getNameLocal() throw (script::BasicErrorException, uno::RuntimeException)
     121             : {
     122           0 :     rtl::OUString sName;
     123             :     try
     124             :     {
     125           0 :         mxPropertySet->getPropertyValue(DISPLAYNAME) >>= sName;
     126             :     }
     127           0 :     catch (const uno::Exception& )
     128             :     {
     129           0 :         DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
     130             :     }
     131           0 :     return sName;
     132             : }
     133             : 
     134             : void SAL_CALL
     135           0 : ScVbaStyle::Delete() throw (script::BasicErrorException, uno::RuntimeException)
     136             : {
     137             :     try
     138             :     {
     139           0 :         mxStyleFamilyNameContainer->removeByName(mxStyle->getName());
     140             :     }
     141           0 :     catch (const uno::Exception& )
     142             :     {
     143           0 :         DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
     144             :     }
     145           0 : }
     146             : 
     147             : void SAL_CALL
     148           0 : ScVbaStyle::setMergeCells( const uno::Any& /*MergeCells*/ ) throw (script::BasicErrorException, uno::RuntimeException)
     149             : {
     150           0 :     DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
     151           0 : }
     152             : 
     153             : uno::Any SAL_CALL
     154           0 : ScVbaStyle::getMergeCells(  ) throw (script::BasicErrorException, uno::RuntimeException)
     155             : {
     156           0 :     DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
     157           0 :     return uno::Any();
     158             : }
     159             : 
     160             : rtl::OUString
     161           0 : ScVbaStyle::getServiceImplName()
     162             : {
     163           0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaStyle"));
     164             : }
     165             : 
     166             : uno::Sequence< rtl::OUString >
     167           0 : ScVbaStyle::getServiceNames()
     168             : {
     169           0 :         static uno::Sequence< rtl::OUString > aServiceNames;
     170           0 :         if ( aServiceNames.getLength() == 0 )
     171             :         {
     172           0 :                 aServiceNames.realloc( 1 );
     173           0 :                 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.XStyle" ) );
     174             :         }
     175           0 :         return aServiceNames;
     176           0 : }
     177             : 
     178             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10