LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbaparagraph.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 71 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 23 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 "vbaparagraph.hxx"
      20             : #include <vbahelper/vbahelper.hxx>
      21             : #include <tools/diagnose_ex.h>
      22             : #include "vbarange.hxx"
      23             : #include <com/sun/star/lang/XServiceInfo.hpp>
      24             : #include <cppuhelper/implbase.hxx>
      25             : 
      26             : using namespace ::ooo::vba;
      27             : using namespace ::com::sun::star;
      28             : 
      29           0 : SwVbaParagraph::SwVbaParagraph( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& xDocument, const uno::Reference< text::XTextRange >& xTextRange ) throw ( uno::RuntimeException ) :
      30           0 :     SwVbaParagraph_BASE( rParent, rContext ), mxTextDocument( xDocument ), mxTextRange( xTextRange )
      31             : {
      32           0 : }
      33             : 
      34           0 : SwVbaParagraph::~SwVbaParagraph()
      35             : {
      36           0 : }
      37             : 
      38             : uno::Reference< word::XRange > SAL_CALL
      39           0 : SwVbaParagraph::getRange( ) throw ( uno::RuntimeException, std::exception )
      40             : {
      41           0 :     return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, mxTextDocument, mxTextRange->getStart(), mxTextRange->getEnd(), mxTextRange->getText(), true ) );
      42             : }
      43             : 
      44             : uno::Any SAL_CALL
      45           0 : SwVbaParagraph::getStyle( ) throw ( uno::RuntimeException, std::exception )
      46             : {
      47           0 :     uno::Reference< word::XRange > xRange = getRange();
      48           0 :     return xRange->getStyle();
      49             : }
      50             : 
      51             : void SAL_CALL
      52           0 : SwVbaParagraph::setStyle( const uno::Any& style ) throw ( uno::RuntimeException, std::exception )
      53             : {
      54           0 :     uno::Reference< word::XRange > xRange = getRange();
      55           0 :     xRange->setStyle( style );
      56           0 : }
      57             : 
      58             : OUString
      59           0 : SwVbaParagraph::getServiceImplName()
      60             : {
      61           0 :     return OUString("SwVbaParagraph");
      62             : }
      63             : 
      64             : uno::Sequence< OUString >
      65           0 : SwVbaParagraph::getServiceNames()
      66             : {
      67           0 :     static uno::Sequence< OUString > aServiceNames;
      68           0 :     if ( aServiceNames.getLength() == 0 )
      69             :     {
      70           0 :         aServiceNames.realloc( 1 );
      71           0 :         aServiceNames[ 0 ] = "ooo.vba.word.Paragraph";
      72             :     }
      73           0 :     return aServiceNames;
      74             : }
      75             : 
      76             : typedef ::cppu::WeakImplHelper< container::XIndexAccess, container::XEnumerationAccess > ParagraphCollectionHelper_BASE;
      77             : 
      78           0 : class ParagraphCollectionHelper : public ParagraphCollectionHelper_BASE
      79             : {
      80             : private:
      81             :     uno::Reference< text::XTextDocument > mxTextDocument;
      82             : 
      83           0 :     uno::Reference< container::XEnumeration > getEnumeration() throw (uno::RuntimeException)
      84             :     {
      85           0 :         uno::Reference< container::XEnumerationAccess > xParEnumAccess( mxTextDocument->getText(), uno::UNO_QUERY_THROW );
      86           0 :         return xParEnumAccess->createEnumeration();
      87             :     }
      88             : 
      89             : public:
      90           0 :     explicit ParagraphCollectionHelper( const uno::Reference< text::XTextDocument >& xDocument ) throw (uno::RuntimeException): mxTextDocument( xDocument )
      91             :     {
      92           0 :     }
      93             :     // XElementAccess
      94           0 :     virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE { return  cppu::UnoType<text::XTextRange>::get(); }
      95           0 :     virtual sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE { return sal_True; }
      96             :     // XIndexAccess
      97           0 :     virtual ::sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
      98             :     {
      99           0 :         sal_Int32 nCount = 0;
     100           0 :         uno::Reference< container::XEnumeration > xParEnum = getEnumeration();
     101           0 :         while( xParEnum->hasMoreElements() )
     102             :         {
     103           0 :             uno::Reference< lang::XServiceInfo > xServiceInfo( xParEnum->nextElement(), uno::UNO_QUERY_THROW );
     104           0 :             if( xServiceInfo->supportsService("com.sun.star.text.Paragraph") )
     105             :             {
     106           0 :                 nCount++;
     107             :             }
     108           0 :         }
     109           0 :         return nCount;
     110             :     }
     111           0 :     virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) SAL_OVERRIDE
     112             :     {
     113           0 :         if( Index < getCount() )
     114             :         {
     115           0 :             sal_Int32 nCount = 0;
     116           0 :             uno::Reference< container::XEnumeration > xParEnum = getEnumeration();
     117           0 :             while( xParEnum->hasMoreElements() )
     118             :             {
     119           0 :                 uno::Reference< lang::XServiceInfo > xServiceInfo( xParEnum->nextElement(), uno::UNO_QUERY_THROW );
     120           0 :                 if( xServiceInfo->supportsService("com.sun.star.text.Paragraph") )
     121             :                 {
     122           0 :                     if( Index == nCount )
     123           0 :                         return uno::makeAny( xServiceInfo );
     124           0 :                     nCount++;
     125             :                 }
     126           0 :             }
     127             :         }
     128           0 :         throw lang::IndexOutOfBoundsException();
     129             :     }
     130             :     // XEnumerationAccess
     131           0 :     virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     132             :     {
     133           0 :         return getEnumeration();
     134             :     }
     135             : };
     136             : 
     137           0 : SwVbaParagraphs::SwVbaParagraphs( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const uno::Reference< text::XTextDocument >& xDocument ) throw (uno::RuntimeException) : SwVbaParagraphs_BASE( xParent, xContext, new ParagraphCollectionHelper( xDocument ) ), mxTextDocument( xDocument )
     138             : {
     139           0 : }
     140             : 
     141             : // XEnumerationAccess
     142             : uno::Type
     143           0 : SwVbaParagraphs::getElementType() throw (uno::RuntimeException)
     144             : {
     145           0 :     return cppu::UnoType<word::XParagraph>::get();
     146             : }
     147             : uno::Reference< container::XEnumeration >
     148           0 : SwVbaParagraphs::createEnumeration() throw (uno::RuntimeException)
     149             : {
     150           0 :     uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
     151           0 :     return xEnumerationAccess->createEnumeration();
     152             : }
     153             : 
     154             : uno::Any
     155           0 : SwVbaParagraphs::createCollectionObject( const css::uno::Any& aSource )
     156             : {
     157           0 :     uno::Reference< text::XTextRange > xTextRange( aSource, uno::UNO_QUERY_THROW );
     158           0 :     return uno::makeAny( uno::Reference< word::XParagraph >( new SwVbaParagraph( this, mxContext, mxTextDocument, xTextRange ) ) );
     159             : }
     160             : 
     161             : OUString
     162           0 : SwVbaParagraphs::getServiceImplName()
     163             : {
     164           0 :     return OUString("SwVbaParagraphs");
     165             : }
     166             : 
     167             : css::uno::Sequence<OUString>
     168           0 : SwVbaParagraphs::getServiceNames()
     169             : {
     170           0 :     static uno::Sequence< OUString > sNames;
     171           0 :     if ( sNames.getLength() == 0 )
     172             :     {
     173           0 :         sNames.realloc( 1 );
     174           0 :         sNames[0] = "ooo.vba.word.Paragraphs";
     175             :     }
     176           0 :     return sNames;
     177             : }
     178             : 
     179             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11