LCOV - code coverage report
Current view: top level - basic/source/classes - errobject.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 41 74 55.4 %
Date: 2015-06-13 12:38:46 Functions: 12 25 48.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 "errobject.hxx"
      21             : 
      22             : #include <cppuhelper/implbase2.hxx>
      23             : #include <com/sun/star/script/XDefaultProperty.hpp>
      24             : #include "sbintern.hxx"
      25             : #include "runtime.hxx"
      26             : 
      27             : using namespace ::com::sun::star;
      28             : using namespace ::ooo;
      29             : 
      30             : typedef ::cppu::WeakImplHelper2< vba::XErrObject, script::XDefaultProperty > ErrObjectImpl_BASE;
      31             : 
      32             : class ErrObject : public ErrObjectImpl_BASE
      33             : {
      34             :     OUString m_sHelpFile;
      35             :     OUString m_sSource;
      36             :     OUString m_sDescription;
      37             :     sal_Int32 m_nNumber;
      38             :     sal_Int32 m_nHelpContext;
      39             : 
      40             : public:
      41             :     ErrObject();
      42             :     virtual ~ErrObject();
      43             :     // Attributes
      44             :     virtual ::sal_Int32 SAL_CALL getNumber() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      45             :     virtual void SAL_CALL setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      46             :     virtual ::sal_Int32 SAL_CALL getHelpContext() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      47             :     virtual void SAL_CALL setHelpContext( ::sal_Int32 _helpcontext ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      48             :     virtual OUString SAL_CALL getHelpFile() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      49             :     virtual void SAL_CALL setHelpFile( const OUString& _helpfile ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      50             :     virtual OUString SAL_CALL getDescription() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      51             :     virtual void SAL_CALL setDescription( const OUString& _description ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      52             :     virtual OUString SAL_CALL getSource() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      53             :     virtual void SAL_CALL setSource( const OUString& _source ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      54             : 
      55             :     // Methods
      56             :     virtual void SAL_CALL Clear(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      57             :     virtual void SAL_CALL Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      58             :     // XDefaultProperty
      59             :     virtual OUString SAL_CALL getDefaultPropertyName(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      60             : 
      61             :     // Helper method
      62             :     void setData( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description,
      63             :         const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException);
      64             : };
      65             : 
      66             : 
      67           6 : ErrObject::~ErrObject()
      68             : {
      69           6 : }
      70             : 
      71           3 : ErrObject::ErrObject() : m_nNumber(0), m_nHelpContext(0)
      72             : {
      73           3 : }
      74             : 
      75             : sal_Int32 SAL_CALL
      76           0 : ErrObject::getNumber() throw (uno::RuntimeException, std::exception)
      77             : {
      78           0 :     return m_nNumber;
      79             : }
      80             : 
      81             : void SAL_CALL
      82           0 : ErrObject::setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException, std::exception)
      83             : {
      84           0 :     GetSbData()->pInst->setErrorVB( _number, OUString() );
      85           0 :     OUString _description = GetSbData()->pInst->GetErrorMsg();
      86           0 :     setData( uno::makeAny( _number ), uno::Any(), uno::makeAny( _description ), uno::Any(), uno::Any() );
      87           0 : }
      88             : 
      89             : ::sal_Int32 SAL_CALL
      90           0 : ErrObject::getHelpContext() throw (uno::RuntimeException, std::exception)
      91             : {
      92           0 :     return m_nHelpContext;
      93             : }
      94             : void SAL_CALL
      95           0 : ErrObject::setHelpContext( ::sal_Int32 _helpcontext ) throw (uno::RuntimeException, std::exception)
      96             : {
      97           0 :     m_nHelpContext = _helpcontext;
      98           0 : }
      99             : 
     100             : OUString SAL_CALL
     101           0 : ErrObject::getHelpFile() throw (uno::RuntimeException, std::exception)
     102             : {
     103           0 :     return m_sHelpFile;
     104             : }
     105             : 
     106             : void SAL_CALL
     107           0 : ErrObject::setHelpFile( const OUString& _helpfile ) throw (uno::RuntimeException, std::exception)
     108             : {
     109           0 :     m_sHelpFile = _helpfile;
     110           0 : }
     111             : 
     112             : OUString SAL_CALL
     113           0 : ErrObject::getDescription() throw (uno::RuntimeException, std::exception)
     114             : {
     115           0 :     return m_sDescription;
     116             : }
     117             : 
     118             : void SAL_CALL
     119           0 : ErrObject::setDescription( const OUString& _description ) throw (uno::RuntimeException, std::exception)
     120             : {
     121           0 :     m_sDescription = _description;
     122           0 : }
     123             : 
     124             : OUString SAL_CALL
     125           0 : ErrObject::getSource() throw (uno::RuntimeException, std::exception)
     126             : {
     127           0 :     return m_sSource;
     128             : }
     129             : 
     130             : void SAL_CALL
     131           0 : ErrObject::setSource( const OUString& _source ) throw (uno::RuntimeException, std::exception)
     132             : {
     133           0 :     m_sSource = _source;
     134           0 : }
     135             : 
     136             : // Methods
     137             : void SAL_CALL
     138          95 : ErrObject::Clear(  ) throw (uno::RuntimeException, std::exception)
     139             : {
     140          95 :     m_sHelpFile.clear();
     141          95 :     m_sSource = m_sHelpFile;
     142          95 :     m_sDescription = m_sSource;
     143          95 :     m_nNumber = 0;
     144          95 :     m_nHelpContext = 0;
     145          95 : }
     146             : 
     147             : void SAL_CALL
     148           0 : ErrObject::Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) throw (uno::RuntimeException, std::exception)
     149             : {
     150           0 :     setData( Number, Source, Description, HelpFile, HelpContext );
     151           0 :     if ( m_nNumber )
     152           0 :         GetSbData()->pInst->ErrorVB( m_nNumber, m_sDescription );
     153           0 : }
     154             : 
     155             : // XDefaultProperty
     156             : OUString SAL_CALL
     157           3 : ErrObject::getDefaultPropertyName(  ) throw (uno::RuntimeException, std::exception)
     158             : {
     159           3 :     return OUString( "Number" );
     160             : }
     161             : 
     162          23 : void ErrObject::setData( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext )
     163             :     throw (uno::RuntimeException)
     164             : {
     165          23 :     if ( !Number.hasValue() )
     166           0 :         throw uno::RuntimeException("Missing Required Parameter" );
     167          23 :     Number >>= m_nNumber;
     168          23 :     Description >>= m_sDescription;
     169          23 :     Source >>= m_sSource;
     170          23 :     HelpFile >>= m_sHelpFile;
     171          23 :     HelpContext >>= m_nHelpContext;
     172          23 : }
     173             : 
     174             : // SbxErrObject
     175           3 : SbxErrObject::SbxErrObject( const OUString& rName, const uno::Any& rUnoObj )
     176             :     : SbUnoObject( rName, rUnoObj )
     177           3 :     , m_pErrObject( NULL )
     178             : {
     179             :     OSL_TRACE("SbxErrObject::SbxErrObject ctor");
     180           3 :     rUnoObj >>= m_xErr;
     181           3 :     if ( m_xErr.is() )
     182             :     {
     183           3 :         SetDfltProperty( uno::Reference< script::XDefaultProperty >( m_xErr, uno::UNO_QUERY_THROW )->getDefaultPropertyName() ) ;
     184           3 :         m_pErrObject = static_cast< ErrObject* >( m_xErr.get() );
     185             :     }
     186           3 : }
     187             : 
     188           9 : SbxErrObject::~SbxErrObject()
     189             : {
     190             :     OSL_TRACE("SbxErrObject::~SbxErrObject dtor");
     191           9 : }
     192             : 
     193             : uno::Reference< vba::XErrObject >
     194          95 : SbxErrObject::getUnoErrObject()
     195             : {
     196          95 :     SbxVariable* pVar = getErrObject();
     197          95 :     SbxErrObject* pGlobErr = static_cast< SbxErrObject* >(  pVar );
     198          95 :     return pGlobErr->m_xErr;
     199             : }
     200             : 
     201             : SbxVariableRef
     202         118 : SbxErrObject::getErrObject()
     203             : {
     204         118 :     static SbxVariableRef pGlobErr = new SbxErrObject( OUString("Err"), uno::makeAny( uno::Reference< vba::XErrObject >( new ErrObject() ) ) );
     205         118 :     return pGlobErr;
     206             : }
     207             : 
     208          23 : void SbxErrObject::setNumberAndDescription( ::sal_Int32 _number, const OUString& _description )
     209             :     throw (uno::RuntimeException)
     210             : {
     211          23 :     if( m_pErrObject != NULL )
     212             :     {
     213          23 :         m_pErrObject->setData( uno::makeAny( _number ), uno::Any(), uno::makeAny( _description ), uno::Any(), uno::Any() );
     214             :     }
     215          23 : }
     216             : 
     217             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11