LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbaautotextentry.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 59 0.0 %
Date: 2012-08-25 Functions: 0 12 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 158 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #include "vbaautotextentry.hxx"
      29                 :            : #include <vbahelper/vbahelper.hxx>
      30                 :            : #include <com/sun/star/text/XParagraphCursor.hpp>
      31                 :            : #include <tools/diagnose_ex.h>
      32                 :            : #include "wordvbahelper.hxx"
      33                 :            : #include "vbarange.hxx"
      34                 :            : 
      35                 :            : using namespace ::ooo::vba;
      36                 :            : using namespace ::com::sun::star;
      37                 :            : 
      38                 :          0 : SwVbaAutoTextEntry::SwVbaAutoTextEntry( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XAutoTextEntry >& xEntry ) throw ( uno::RuntimeException ) :
      39                 :          0 :     SwVbaAutoTextEntry_BASE( rParent, rContext ), mxEntry( xEntry )
      40                 :            : {
      41                 :          0 : }
      42                 :            : 
      43                 :          0 : SwVbaAutoTextEntry::~SwVbaAutoTextEntry()
      44                 :            : {
      45         [ #  # ]:          0 : }
      46                 :            : 
      47                 :          0 : uno::Reference< word::XRange > SAL_CALL SwVbaAutoTextEntry::Insert( const uno::Reference< word::XRange >& _where, const uno::Any& _richtext ) throw ( uno::RuntimeException )
      48                 :            : {
      49         [ #  # ]:          0 :     SwVbaRange* pWhere = dynamic_cast<SwVbaRange*>( _where.get() );
      50         [ #  # ]:          0 :     if( pWhere )
      51                 :            :     {
      52         [ #  # ]:          0 :         uno::Reference< text::XTextRange > xTextRange = pWhere->getXTextRange();
      53 [ #  # ][ #  # ]:          0 :         xTextRange->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("x") ) ); // set marker
                 [ #  # ]
      54 [ #  # ][ #  # ]:          0 :         uno::Reference< text::XTextRange > xEndMarker = xTextRange->getEnd();
      55 [ #  # ][ #  # ]:          0 :         xEndMarker->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("x") ) ); // set marker
                 [ #  # ]
      56         [ #  # ]:          0 :         uno::Reference< text::XText > xText = pWhere->getXText();
      57 [ #  # ][ #  # ]:          0 :         mxEntry->applyTo( xEndMarker->getStart() );
         [ #  # ][ #  # ]
      58 [ #  # ][ #  # ]:          0 :         uno::Reference< text::XTextCursor > xTC = xText->createTextCursorByRange( xTextRange->getStart() );
         [ #  # ][ #  # ]
      59 [ #  # ][ #  # ]:          0 :         xTC->goRight( 1, sal_True );
      60 [ #  # ][ #  # ]:          0 :         xTC->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("") ) ); // remove marker
                 [ #  # ]
      61                 :            :         // remove the blank paragraph if it is a rich text
      62                 :          0 :         sal_Bool bRich = sal_False;
      63                 :          0 :         _richtext >>= bRich;
      64         [ #  # ]:          0 :         if( bRich )
      65                 :            :         {
      66                 :            :             // check if it is a blank paragraph
      67         [ #  # ]:          0 :             uno::Reference< text::XParagraphCursor > xParaCursor( xTC, uno::UNO_QUERY_THROW );
      68 [ #  # ][ #  # ]:          0 :             if( xParaCursor->isStartOfParagraph() && xParaCursor->isEndOfParagraph() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      69                 :            :             {
      70                 :            :                 //remove the blank paragraph
      71 [ #  # ][ #  # ]:          0 :                 uno::Reference< frame::XModel > xModel( getCurrentWordDoc( mxContext ), uno::UNO_QUERY_THROW );
      72         [ #  # ]:          0 :                 uno::Reference< text::XTextViewCursor > xTVCursor = word::getXTextViewCursor( xModel );
      73 [ #  # ][ #  # ]:          0 :                 uno::Reference< text::XTextRange > xCurrentRange( xTC->getEnd(), uno::UNO_QUERY_THROW );
                 [ #  # ]
      74 [ #  # ][ #  # ]:          0 :                 xTVCursor->gotoRange( xCurrentRange, sal_False );
      75         [ #  # ]:          0 :                 rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Delete"));
      76         [ #  # ]:          0 :                 dispatchRequests( xModel,url );
      77 [ #  # ][ #  # ]:          0 :                 xTVCursor->gotoRange( xEndMarker->getEnd(), sal_False );
         [ #  # ][ #  # ]
      78                 :          0 :             }
      79                 :            :         }
      80 [ #  # ][ #  # ]:          0 :         xEndMarker->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("") ) ); // remove marker
                 [ #  # ]
      81 [ #  # ][ #  # ]:          0 :         xTC = xText->createTextCursorByRange( xEndMarker->getEnd() );
         [ #  # ][ #  # ]
                 [ #  # ]
      82         [ #  # ]:          0 :         pWhere->setXTextCursor( xTC );
      83                 :            :     }
      84         [ #  # ]:          0 :     return uno::Reference< word::XRange >( pWhere );
      85                 :            : }
      86                 :            : 
      87                 :            : rtl::OUString
      88                 :          0 : SwVbaAutoTextEntry::getServiceImplName()
      89                 :            : {
      90                 :          0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaAutoTextEntry"));
      91                 :            : }
      92                 :            : 
      93                 :            : uno::Sequence< rtl::OUString >
      94                 :          0 : SwVbaAutoTextEntry::getServiceNames()
      95                 :            : {
      96 [ #  # ][ #  # ]:          0 :     static uno::Sequence< rtl::OUString > aServiceNames;
         [ #  # ][ #  # ]
      97         [ #  # ]:          0 :     if ( aServiceNames.getLength() == 0 )
      98                 :            :     {
      99                 :          0 :         aServiceNames.realloc( 1 );
     100         [ #  # ]:          0 :         aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.AutoTextEntry" ) );
     101                 :            :     }
     102                 :          0 :     return aServiceNames;
     103                 :            : }
     104                 :            : 
     105                 :            : 
     106                 :          0 : SwVbaAutoTextEntries::SwVbaAutoTextEntries( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess ) throw (uno::RuntimeException) : SwVbaAutoTextEntries_BASE( xParent, xContext, xIndexAccess ), mxAutoTextEntryAccess( xIndexAccess )
     107                 :            : {
     108                 :          0 : }
     109                 :            : 
     110                 :            : // XEnumerationAccess
     111                 :            : uno::Type
     112                 :          0 : SwVbaAutoTextEntries::getElementType() throw (uno::RuntimeException)
     113                 :            : {
     114                 :          0 :     return word::XAutoTextEntry::static_type(0);
     115                 :            : }
     116                 :            : uno::Reference< container::XEnumeration >
     117                 :          0 : SwVbaAutoTextEntries::createEnumeration() throw (uno::RuntimeException)
     118                 :            : {
     119 [ #  # ][ #  # ]:          0 :     throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
     120                 :            : }
     121                 :            : 
     122                 :            : uno::Any
     123                 :          0 : SwVbaAutoTextEntries::createCollectionObject( const css::uno::Any& aSource )
     124                 :            : {
     125         [ #  # ]:          0 :     uno::Reference< text::XAutoTextEntry > xEntry( aSource, uno::UNO_QUERY_THROW );
     126 [ #  # ][ #  # ]:          0 :     return uno::makeAny( uno::Reference< word::XAutoTextEntry >( new SwVbaAutoTextEntry( this, mxContext, xEntry ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     127                 :            : }
     128                 :            : 
     129                 :            : rtl::OUString
     130                 :          0 : SwVbaAutoTextEntries::getServiceImplName()
     131                 :            : {
     132                 :          0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaAutoTextEntries"));
     133                 :            : }
     134                 :            : 
     135                 :            : css::uno::Sequence<rtl::OUString>
     136                 :          0 : SwVbaAutoTextEntries::getServiceNames()
     137                 :            : {
     138 [ #  # ][ #  # ]:          0 :     static uno::Sequence< rtl::OUString > sNames;
         [ #  # ][ #  # ]
     139         [ #  # ]:          0 :     if ( sNames.getLength() == 0 )
     140                 :            :     {
     141                 :          0 :         sNames.realloc( 1 );
     142         [ #  # ]:          0 :         sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.AutoTextEntries") );
     143                 :            :     }
     144                 :          0 :     return sNames;
     145                 :            : }
     146                 :            : 
     147                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10