LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbavariables.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 35 2.9 %
Date: 2014-11-03 Functions: 2 10 20.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 "vbavariables.hxx"
      20             : #include "vbavariable.hxx"
      21             : #include <com/sun/star/beans/XPropertyContainer.hpp>
      22             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      23             : 
      24             : using namespace ::ooo::vba;
      25             : using namespace ::com::sun::star;
      26             : 
      27           0 : uno::Reference< container::XIndexAccess > createVariablesAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< beans::XPropertyAccess >& xUserDefined ) throw ( uno::RuntimeException )
      28             : {
      29             :     // FIXME: the performance is poor?
      30           0 :     XNamedObjectCollectionHelper< word::XVariable >::XNamedVec mVariables;
      31           0 :     const uno::Sequence< beans::PropertyValue > props = xUserDefined->getPropertyValues();
      32           0 :     sal_Int32 nCount = props.getLength();
      33           0 :     mVariables.reserve( nCount );
      34           0 :     for( sal_Int32 i=0; i < nCount; i++ )
      35           0 :         mVariables.push_back( uno::Reference< word::XVariable > ( new SwVbaVariable( xParent, xContext, xUserDefined, props[i].Name ) ) );
      36             : 
      37           0 :     uno::Reference< container::XIndexAccess > xVariables( new XNamedObjectCollectionHelper< word::XVariable >( mVariables ) );
      38           0 :     return xVariables;
      39             : }
      40             : 
      41           0 : SwVbaVariables::SwVbaVariables( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertyAccess >& rUserDefined ): SwVbaVariables_BASE( xParent, xContext, createVariablesAccess( xParent, xContext, rUserDefined ) ),  mxUserDefined( rUserDefined )
      42             : {
      43           0 : }
      44             : // XEnumerationAccess
      45             : uno::Type
      46           0 : SwVbaVariables::getElementType() throw (uno::RuntimeException)
      47             : {
      48           0 :     return cppu::UnoType<word::XVariable>::get();
      49             : }
      50             : uno::Reference< container::XEnumeration >
      51           0 : SwVbaVariables::createEnumeration() throw (uno::RuntimeException)
      52             : {
      53           0 :     uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
      54           0 :     return xEnumerationAccess->createEnumeration();
      55             : }
      56             : 
      57             : uno::Any
      58           0 : SwVbaVariables::createCollectionObject( const css::uno::Any& aSource )
      59             : {
      60           0 :     return aSource;
      61             : }
      62             : 
      63             : uno::Any SAL_CALL
      64           0 : SwVbaVariables::Add( const OUString& rName, const uno::Any& rValue ) throw (uno::RuntimeException, std::exception)
      65             : {
      66           0 :     uno::Any aValue;
      67           0 :     if( rValue.hasValue() )
      68           0 :         aValue = rValue;
      69             :     else
      70           0 :         aValue <<= OUString();
      71           0 :     uno::Reference< beans::XPropertyContainer > xPropertyContainer( mxUserDefined, uno::UNO_QUERY_THROW );
      72           0 :     xPropertyContainer->addProperty( rName, beans::PropertyAttribute::MAYBEVOID | beans::PropertyAttribute::REMOVABLE, aValue );
      73             : 
      74           0 :     return uno::makeAny( uno::Reference< word::XVariable >( new SwVbaVariable( getParent(), mxContext, mxUserDefined, rName ) ) );
      75             : }
      76             : 
      77             : OUString
      78           0 : SwVbaVariables::getServiceImplName()
      79             : {
      80           0 :     return OUString("SwVbaVariables");
      81             : }
      82             : 
      83             : css::uno::Sequence<OUString>
      84           0 : SwVbaVariables::getServiceNames()
      85             : {
      86           0 :     static uno::Sequence< OUString > sNames;
      87           0 :     if ( sNames.getLength() == 0 )
      88             :     {
      89           0 :         sNames.realloc( 1 );
      90           0 :         sNames[0] = "ooo.vba.word.Variables";
      91             :     }
      92           0 :     return sNames;
      93           6 : }
      94             : 
      95             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10