LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbacomments.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 30 3.3 %
Date: 2014-11-03 Functions: 2 13 15.4 %
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 "vbacomments.hxx"
      20             : 
      21             : #include <com/sun/star/container/XChild.hpp>
      22             : #include <com/sun/star/sheet/XSheetAnnotation.hpp>
      23             : 
      24             : #include "vbaglobals.hxx"
      25             : 
      26             : using namespace ::ooo::vba;
      27             : using namespace ::com::sun::star;
      28             : 
      29           0 : uno::Any AnnotationToComment( const uno::Any& aSource, uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel )
      30             : {
      31           0 :     uno::Reference< sheet::XSheetAnnotation > xAnno( aSource, uno::UNO_QUERY_THROW );
      32           0 :     uno::Reference< container::XChild > xChild( xAnno, uno::UNO_QUERY_THROW );
      33           0 :     uno::Reference< table::XCellRange > xCellRange( xChild->getParent(), uno::UNO_QUERY_THROW );
      34             : 
      35             :     // #FIXME needs to find the correct Parent
      36             :     return uno::makeAny( uno::Reference< excel::XComment > (
      37           0 :         new ScVbaComment( uno::Reference< XHelperInterface >(), xContext, xModel, xCellRange ) ) );
      38             : }
      39             : 
      40           0 : class CommentEnumeration : public EnumerationHelperImpl
      41             : {
      42             :     css::uno::Reference< css::frame::XModel > mxModel;
      43             : public:
      44           0 :     CommentEnumeration(
      45             :             const uno::Reference< XHelperInterface >& xParent,
      46             :             const uno::Reference< uno::XComponentContext >& xContext,
      47             :             const uno::Reference< container::XEnumeration >& xEnumeration,
      48             :             const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) :
      49             :         EnumerationHelperImpl( xParent, xContext, xEnumeration ),
      50           0 :         mxModel( xModel, uno::UNO_SET_THROW )
      51           0 :     {}
      52             : 
      53           0 :     virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
      54             :     {
      55           0 :         return AnnotationToComment( m_xEnumeration->nextElement(), m_xContext, mxModel );
      56             :     }
      57             : 
      58             : };
      59             : 
      60           0 : ScVbaComments::ScVbaComments(
      61             :         const uno::Reference< XHelperInterface >& xParent,
      62             :         const uno::Reference< uno::XComponentContext > & xContext,
      63             :         const uno::Reference< frame::XModel >& xModel,
      64             :         const uno::Reference< container::XIndexAccess >& xIndexAccess  ) :
      65             :     ScVbaComments_BASE( xParent, xContext, xIndexAccess ),
      66           0 :     mxModel( xModel, uno::UNO_SET_THROW )
      67             : {
      68           0 : }
      69             : 
      70             : // public helper functions
      71             : 
      72             : uno::Reference< container::XEnumeration >
      73           0 : ScVbaComments::createEnumeration() throw (uno::RuntimeException)
      74             : {
      75           0 :     uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
      76           0 :     return new CommentEnumeration( mxParent, mxContext, xEnumAccess->createEnumeration(), mxModel );
      77             : }
      78             : 
      79             : uno::Any
      80           0 : ScVbaComments::createCollectionObject( const css::uno::Any& aSource )
      81             : {
      82           0 :     return AnnotationToComment( aSource,  mxContext, mxModel );
      83             : }
      84             : 
      85             : uno::Type
      86           0 : ScVbaComments::getElementType() throw (uno::RuntimeException)
      87             : {
      88           0 :     return cppu::UnoType<excel::XComment>::get();
      89             : }
      90             : 
      91             : OUString
      92           0 : ScVbaComments::getServiceImplName()
      93             : {
      94           0 :     return OUString("ScVbaComments");
      95             : }
      96             : 
      97             : css::uno::Sequence<OUString>
      98           0 : ScVbaComments::getServiceNames()
      99             : {
     100           0 :     static uno::Sequence< OUString > sNames;
     101           0 :     if ( sNames.getLength() == 0 )
     102             :     {
     103           0 :         sNames.realloc( 1 );
     104           0 :         sNames[0] = "ooo.vba.excel.Comments";
     105             :     }
     106           0 :     return sNames;
     107          12 : }
     108             : 
     109             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10