LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/vba - vbavariable.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 30 0.0 %
Date: 2012-12-17 Functions: 0 10 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 "vbavariable.hxx"
      20             : #include <vbahelper/vbahelper.hxx>
      21             : #include <tools/diagnose_ex.h>
      22             : #include <com/sun/star/beans/XPropertySet.hpp>
      23             : #include <com/sun/star/beans/PropertyValue.hpp>
      24             : 
      25             : using namespace ::ooo::vba;
      26             : using namespace ::com::sun::star;
      27             : 
      28           0 : SwVbaVariable::SwVbaVariable( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,
      29             :     const uno::Reference< beans::XPropertyAccess >& rUserDefined, const rtl::OUString& rName ) throw ( uno::RuntimeException ) :
      30           0 :     SwVbaVariable_BASE( rParent, rContext ), mxUserDefined( rUserDefined ), maName( rName )
      31             : {
      32           0 : }
      33             : 
      34           0 : SwVbaVariable::~SwVbaVariable()
      35             : {
      36           0 : }
      37             : 
      38             : rtl::OUString SAL_CALL
      39           0 : SwVbaVariable::getName() throw ( css::uno::RuntimeException )
      40             : {
      41           0 :     return maName;
      42             : }
      43             : 
      44             : void SAL_CALL
      45           0 : SwVbaVariable::setName( const rtl::OUString& ) throw ( css::uno::RuntimeException )
      46             : {
      47             :     throw uno::RuntimeException( rtl::OUString(
      48           0 :             RTL_CONSTASCII_USTRINGPARAM(" Fail to set name")), uno::Reference< uno::XInterface >() );
      49             : }
      50             : 
      51             : uno::Any SAL_CALL
      52           0 : SwVbaVariable::getValue() throw ( css::uno::RuntimeException )
      53             : {
      54           0 :     uno::Reference< beans::XPropertySet > xProp( mxUserDefined, uno::UNO_QUERY_THROW );
      55           0 :     return xProp->getPropertyValue( maName );
      56             : }
      57             : 
      58             : void SAL_CALL
      59           0 : SwVbaVariable::setValue( const uno::Any& rValue ) throw ( css::uno::RuntimeException )
      60             : {
      61             :     // FIXME: fail to set the value if the new type of vaue is differenct from the original one.
      62           0 :     uno::Reference< beans::XPropertySet > xProp( mxUserDefined, uno::UNO_QUERY_THROW );
      63           0 :     xProp->setPropertyValue( maName, rValue );
      64           0 : }
      65             : 
      66             : sal_Int32 SAL_CALL
      67           0 : SwVbaVariable::getIndex() throw ( css::uno::RuntimeException )
      68             : {
      69           0 :     const uno::Sequence< beans::PropertyValue > props = mxUserDefined->getPropertyValues();
      70           0 :     for (sal_Int32 i = 0; i < props.getLength(); ++i)
      71             :     {
      72           0 :         if( maName.equals( props[i].Name ) )
      73           0 :             return i+1;
      74             :     }
      75             : 
      76           0 :     return 0;
      77             : }
      78             : 
      79             : rtl::OUString
      80           0 : SwVbaVariable::getServiceImplName()
      81             : {
      82           0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaVariable"));
      83             : }
      84             : 
      85             : uno::Sequence< rtl::OUString >
      86           0 : SwVbaVariable::getServiceNames()
      87             : {
      88           0 :     static uno::Sequence< rtl::OUString > aServiceNames;
      89           0 :     if ( aServiceNames.getLength() == 0 )
      90             :     {
      91           0 :         aServiceNames.realloc( 1 );
      92           0 :         aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Variable" ) );
      93             :     }
      94           0 :     return aServiceNames;
      95             : }
      96             : 
      97             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10