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

Generated by: LCOV version 1.10