LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/vba - vbaautotextentry.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 59 0.0 %
Date: 2012-12-27 Functions: 0 12 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 "vbaautotextentry.hxx"
      20             : #include <vbahelper/vbahelper.hxx>
      21             : #include <com/sun/star/text/XParagraphCursor.hpp>
      22             : #include <tools/diagnose_ex.h>
      23             : #include "wordvbahelper.hxx"
      24             : #include "vbarange.hxx"
      25             : 
      26             : using namespace ::ooo::vba;
      27             : using namespace ::com::sun::star;
      28             : 
      29           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 ) :
      30           0 :     SwVbaAutoTextEntry_BASE( rParent, rContext ), mxEntry( xEntry )
      31             : {
      32           0 : }
      33             : 
      34           0 : SwVbaAutoTextEntry::~SwVbaAutoTextEntry()
      35             : {
      36           0 : }
      37             : 
      38           0 : uno::Reference< word::XRange > SAL_CALL SwVbaAutoTextEntry::Insert( const uno::Reference< word::XRange >& _where, const uno::Any& _richtext ) throw ( uno::RuntimeException )
      39             : {
      40           0 :     SwVbaRange* pWhere = dynamic_cast<SwVbaRange*>( _where.get() );
      41           0 :     if( pWhere )
      42             :     {
      43           0 :         uno::Reference< text::XTextRange > xTextRange = pWhere->getXTextRange();
      44           0 :         xTextRange->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("x") ) ); // set marker
      45           0 :         uno::Reference< text::XTextRange > xEndMarker = xTextRange->getEnd();
      46           0 :         xEndMarker->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("x") ) ); // set marker
      47           0 :         uno::Reference< text::XText > xText = pWhere->getXText();
      48           0 :         mxEntry->applyTo( xEndMarker->getStart() );
      49           0 :         uno::Reference< text::XTextCursor > xTC = xText->createTextCursorByRange( xTextRange->getStart() );
      50           0 :         xTC->goRight( 1, sal_True );
      51           0 :         xTC->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("") ) ); // remove marker
      52             :         // remove the blank paragraph if it is a rich text
      53           0 :         sal_Bool bRich = sal_False;
      54           0 :         _richtext >>= bRich;
      55           0 :         if( bRich )
      56             :         {
      57             :             // check if it is a blank paragraph
      58           0 :             uno::Reference< text::XParagraphCursor > xParaCursor( xTC, uno::UNO_QUERY_THROW );
      59           0 :             if( xParaCursor->isStartOfParagraph() && xParaCursor->isEndOfParagraph() )
      60             :             {
      61             :                 //remove the blank paragraph
      62           0 :                 uno::Reference< frame::XModel > xModel( getCurrentWordDoc( mxContext ), uno::UNO_QUERY_THROW );
      63           0 :                 uno::Reference< text::XTextViewCursor > xTVCursor = word::getXTextViewCursor( xModel );
      64           0 :                 uno::Reference< text::XTextRange > xCurrentRange( xTC->getEnd(), uno::UNO_QUERY_THROW );
      65           0 :                 xTVCursor->gotoRange( xCurrentRange, sal_False );
      66           0 :                 rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Delete"));
      67           0 :                 dispatchRequests( xModel,url );
      68           0 :                 xTVCursor->gotoRange( xEndMarker->getEnd(), sal_False );
      69           0 :             }
      70             :         }
      71           0 :         xEndMarker->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("") ) ); // remove marker
      72           0 :         xTC = xText->createTextCursorByRange( xEndMarker->getEnd() );
      73           0 :         pWhere->setXTextCursor( xTC );
      74             :     }
      75           0 :     return uno::Reference< word::XRange >( pWhere );
      76             : }
      77             : 
      78             : rtl::OUString
      79           0 : SwVbaAutoTextEntry::getServiceImplName()
      80             : {
      81           0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaAutoTextEntry"));
      82             : }
      83             : 
      84             : uno::Sequence< rtl::OUString >
      85           0 : SwVbaAutoTextEntry::getServiceNames()
      86             : {
      87           0 :     static uno::Sequence< rtl::OUString > aServiceNames;
      88           0 :     if ( aServiceNames.getLength() == 0 )
      89             :     {
      90           0 :         aServiceNames.realloc( 1 );
      91           0 :         aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.AutoTextEntry" ) );
      92             :     }
      93           0 :     return aServiceNames;
      94             : }
      95             : 
      96             : 
      97           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 )
      98             : {
      99           0 : }
     100             : 
     101             : // XEnumerationAccess
     102             : uno::Type
     103           0 : SwVbaAutoTextEntries::getElementType() throw (uno::RuntimeException)
     104             : {
     105           0 :     return word::XAutoTextEntry::static_type(0);
     106             : }
     107             : uno::Reference< container::XEnumeration >
     108           0 : SwVbaAutoTextEntries::createEnumeration() throw (uno::RuntimeException)
     109             : {
     110           0 :     throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
     111             : }
     112             : 
     113             : uno::Any
     114           0 : SwVbaAutoTextEntries::createCollectionObject( const css::uno::Any& aSource )
     115             : {
     116           0 :     uno::Reference< text::XAutoTextEntry > xEntry( aSource, uno::UNO_QUERY_THROW );
     117           0 :     return uno::makeAny( uno::Reference< word::XAutoTextEntry >( new SwVbaAutoTextEntry( this, mxContext, xEntry ) ) );
     118             : }
     119             : 
     120             : rtl::OUString
     121           0 : SwVbaAutoTextEntries::getServiceImplName()
     122             : {
     123           0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaAutoTextEntries"));
     124             : }
     125             : 
     126             : css::uno::Sequence<rtl::OUString>
     127           0 : SwVbaAutoTextEntries::getServiceNames()
     128             : {
     129           0 :     static uno::Sequence< rtl::OUString > sNames;
     130           0 :     if ( sNames.getLength() == 0 )
     131             :     {
     132           0 :         sNames.realloc( 1 );
     133           0 :         sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.AutoTextEntries") );
     134             :     }
     135           0 :     return sNames;
     136             : }
     137             : 
     138             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10