LCOV - code coverage report
Current view: top level - libreoffice/editeng/source/uno - unotext2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 165 294 56.1 %
Date: 2012-12-27 Functions: 38 67 56.7 %
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             : 
      20             : #include <vcl/svapp.hxx>
      21             : #include <osl/mutex.hxx>
      22             : #include <rtl/instance.hxx>
      23             : 
      24             : #include <editeng/eeitem.hxx>
      25             : #include <editeng/flditem.hxx>
      26             : #include <editeng/unofield.hxx>
      27             : #include <editeng/unotext.hxx>
      28             : #include <comphelper/serviceinfohelper.hxx>
      29             : #include <comphelper/servicehelper.hxx>
      30             : 
      31             : using namespace ::rtl;
      32             : using namespace ::cppu;
      33             : using namespace ::com::sun::star;
      34             : 
      35             : #define QUERYINT( xint ) \
      36             :     if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \
      37             :         return uno::makeAny(uno::Reference< xint >(this))
      38             : 
      39             : // ====================================================================
      40             : // SvxUnoTextContentEnumeration
      41             : // ====================================================================
      42             : 
      43          64 : SvxUnoTextContentEnumeration::SvxUnoTextContentEnumeration( const SvxUnoTextBase& _rText ) throw()
      44          64 : : mrText( _rText )
      45             : {
      46          64 :     mxParentText = const_cast<SvxUnoTextBase*>(&_rText);
      47          64 :     if( mrText.GetEditSource() )
      48          64 :         mpEditSource = mrText.GetEditSource()->Clone();
      49             :     else
      50           0 :         mpEditSource = NULL;
      51          64 :     mnNextParagraph = 0;
      52          64 : }
      53             : 
      54         192 : SvxUnoTextContentEnumeration::~SvxUnoTextContentEnumeration() throw()
      55             : {
      56          64 :     delete mpEditSource;
      57         128 : }
      58             : 
      59             : // container::XEnumeration
      60         188 : sal_Bool SAL_CALL SvxUnoTextContentEnumeration::hasMoreElements(void)
      61             :     throw( uno::RuntimeException )
      62             : {
      63         188 :     SolarMutexGuard aGuard;
      64         188 :     if( mpEditSource && mpEditSource->GetTextForwarder() )
      65         188 :         return mnNextParagraph < mpEditSource->GetTextForwarder()->GetParagraphCount();
      66             :     else
      67           0 :         return sal_False;
      68             : }
      69             : 
      70          66 : uno::Any SvxUnoTextContentEnumeration::nextElement(void) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
      71             : {
      72          66 :     SolarMutexGuard aGuard;
      73             : 
      74          66 :     if(!hasMoreElements())
      75           2 :         throw container::NoSuchElementException();
      76             : 
      77          64 :     SvxUnoTextContent* pContent = 0;
      78             : 
      79          64 :     const SvxUnoTextRangeBaseList& rRanges( mpEditSource->getRanges() );
      80          64 :     SvxUnoTextRangeBaseList::const_iterator aIter;
      81          65 :     for( aIter = rRanges.begin(); (aIter != rRanges.end()) && (pContent == 0); ++aIter )
      82             :     {
      83           1 :         SvxUnoTextContent* pIterContent = dynamic_cast< SvxUnoTextContent* >( (*aIter ) );
      84           1 :         if( pIterContent && (pIterContent->mnParagraph == mnNextParagraph) )
      85           0 :             pContent = pIterContent;
      86             :     }
      87             : 
      88          64 :     if( pContent == 0 )
      89          64 :      pContent = new SvxUnoTextContent( mrText, mnNextParagraph );
      90             : 
      91          64 :     mnNextParagraph++;
      92             : 
      93          64 :     uno::Reference< text::XTextContent > xRef( pContent );
      94          64 :     return uno::makeAny( xRef );
      95             : }
      96             : 
      97             : // ====================================================================
      98             : // class SvxUnoTextContent
      99             : // ====================================================================
     100             : 
     101          64 : SvxUnoTextContent::SvxUnoTextContent( const SvxUnoTextBase& rText, sal_uInt16 nPara ) throw()
     102             : :   SvxUnoTextRangeBase(rText)
     103             : ,   mnParagraph(nPara)
     104             : ,   mrParentText(rText)
     105             : ,   maDisposeListeners(maDisposeContainerMutex)
     106          64 : ,   mbDisposing( false )
     107             : {
     108          64 :     mxParentText = const_cast<SvxUnoTextBase*>(&rText);
     109          64 :     if( GetEditSource() && GetEditSource()->GetTextForwarder() )
     110          64 :         SetSelection( ESelection( mnParagraph,0, mnParagraph, GetEditSource()->GetTextForwarder()->GetTextLen( mnParagraph ) ) );
     111          64 : }
     112             : 
     113           0 : SvxUnoTextContent::SvxUnoTextContent( const SvxUnoTextContent& rContent ) throw()
     114             : :   SvxUnoTextRangeBase(rContent)
     115             : ,   text::XTextContent()
     116             : ,   container::XEnumerationAccess()
     117             : ,   lang::XTypeProvider()
     118             : ,   cppu::OWeakAggObject()
     119             : ,   mrParentText(rContent.mrParentText)
     120             : ,   maDisposeListeners(maDisposeContainerMutex)
     121           0 : ,   mbDisposing( false )
     122             : {
     123           0 :     mxParentText = rContent.mxParentText;
     124           0 :     mnParagraph  = rContent.mnParagraph;
     125           0 :     SetSelection( rContent.GetSelection() );
     126           0 : }
     127             : 
     128         128 : SvxUnoTextContent::~SvxUnoTextContent() throw()
     129             : {
     130         128 : }
     131             : 
     132             : // uno::XInterface
     133         452 : uno::Any SAL_CALL SvxUnoTextContent::queryAggregation( const uno::Type & rType ) throw( uno::RuntimeException )
     134             : {
     135         452 :     QUERYINT( text::XTextRange );
     136         452 :     else QUERYINT( beans::XMultiPropertyStates );
     137         452 :     else QUERYINT( beans::XPropertySet );
     138         318 :     else QUERYINT( beans::XMultiPropertySet );
     139         254 :     else QUERYINT( beans::XPropertyState );
     140         252 :     else QUERYINT( text::XTextContent );
     141         191 :     else QUERYINT( text::XTextRangeCompare );
     142         191 :     else QUERYINT( lang::XComponent );
     143         191 :     else QUERYINT( container::XEnumerationAccess );
     144         130 :     else QUERYINT( container::XElementAccess );
     145         130 :     else QUERYINT( lang::XServiceInfo );
     146          69 :     else QUERYINT( lang::XTypeProvider );
     147          67 :     else QUERYINT( lang::XUnoTunnel );
     148             :     else
     149          67 :         return OWeakAggObject::queryAggregation( rType );
     150             : }
     151             : 
     152         452 : uno::Any SAL_CALL SvxUnoTextContent::queryInterface( const uno::Type & rType ) throw( uno::RuntimeException )
     153             : {
     154         452 :     return OWeakAggObject::queryInterface(rType);
     155             : }
     156             : 
     157         904 : void SAL_CALL SvxUnoTextContent::acquire() throw( )
     158             : {
     159         904 :     OWeakAggObject::acquire();
     160         904 : }
     161             : 
     162         904 : void SAL_CALL SvxUnoTextContent::release() throw( )
     163             : {
     164         904 :     OWeakAggObject::release();
     165         904 : }
     166             : 
     167             : // XTypeProvider
     168             : 
     169             : namespace
     170             : {
     171             :     struct theSvxUnoTextContentTypes :
     172             :         public rtl::StaticWithInit<uno::Sequence<uno::Type>, theSvxUnoTextContentTypes>
     173             :     {
     174           0 :         uno::Sequence<uno::Type> operator () ()
     175             :         {
     176           0 :             uno::Sequence< uno::Type > aTypeSequence;
     177             : 
     178           0 :             aTypeSequence.realloc( 11 ); // !DANGER! keep this updated
     179           0 :             uno::Type* pTypes = aTypeSequence.getArray();
     180             : 
     181           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0);
     182           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
     183           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
     184           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
     185           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
     186           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
     187           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextContent >*)0);
     188           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0);
     189           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
     190           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
     191           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
     192             : 
     193           0 :             return aTypeSequence;
     194             :         }
     195             :     };
     196             : }
     197             : 
     198           0 : uno::Sequence< uno::Type > SAL_CALL SvxUnoTextContent::getTypes()
     199             :     throw (uno::RuntimeException)
     200             : {
     201           0 :     return theSvxUnoTextContentTypes::get();
     202             : }
     203             : 
     204             : namespace
     205             : {
     206             :     class theSvxUnoTextContentImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxUnoTextContentImplementationId > {};
     207             : }
     208             : 
     209           2 : uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextContent::getImplementationId()
     210             :     throw (uno::RuntimeException)
     211             : {
     212           2 :     return theSvxUnoTextContentImplementationId::get().getSeq();
     213             : }
     214             : 
     215             : // text::XTextRange
     216             : 
     217           0 : uno::Reference< text::XText > SAL_CALL SvxUnoTextContent::getText()
     218             :     throw(uno::RuntimeException)
     219             : {
     220           0 :     return mxParentText;
     221             : }
     222             : 
     223             : // text::XTextContent
     224           0 : void SAL_CALL SvxUnoTextContent::attach( const uno::Reference< text::XTextRange >& )
     225             :     throw(lang::IllegalArgumentException, uno::RuntimeException)
     226             : {
     227           0 : }
     228             : 
     229           0 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextContent::getAnchor() throw( uno::RuntimeException )
     230             : {
     231           0 :     return uno::Reference< text::XTextRange >::query( mxParentText );
     232             : }
     233             : 
     234             : // XComponent
     235             : 
     236           0 : void SAL_CALL SvxUnoTextContent::dispose()
     237             :     throw(uno::RuntimeException)
     238             : {
     239           0 :     SolarMutexGuard aGuard;
     240             : 
     241           0 :     if( mbDisposing )
     242           0 :         return; // catched a recursion
     243             : 
     244           0 :     mbDisposing = true;
     245             : 
     246           0 :     lang::EventObject aEvt;
     247           0 :     aEvt.Source = *(OWeakAggObject*) this;
     248           0 :     maDisposeListeners.disposeAndClear(aEvt);
     249             : 
     250           0 :     if( mxParentText.is() )
     251           0 :         mxParentText->removeTextContent( this );
     252             : }
     253             : 
     254           0 : void SAL_CALL SvxUnoTextContent::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
     255             :     throw(uno::RuntimeException)
     256             : {
     257           0 :     maDisposeListeners.addInterface(xListener);
     258           0 : }
     259             : 
     260           0 : void SAL_CALL SvxUnoTextContent::removeEventListener( const uno::Reference< lang::XEventListener >& aListener )
     261             :     throw(uno::RuntimeException)
     262             : {
     263           0 :    maDisposeListeners.removeInterface(aListener);
     264           0 : }
     265             : 
     266             : // XEnumerationAccess
     267             : 
     268          61 : uno::Reference< container::XEnumeration > SAL_CALL SvxUnoTextContent::createEnumeration(  )
     269             :     throw(uno::RuntimeException)
     270             : {
     271          61 :     SolarMutexGuard aGuard;
     272             : 
     273          61 :     return new SvxUnoTextRangeEnumeration( mrParentText, mnParagraph );
     274             : }
     275             : 
     276             : // XElementAccess ( container::XEnumerationAccess )
     277             : 
     278           0 : uno::Type SAL_CALL SvxUnoTextContent::getElementType()
     279             :     throw(uno::RuntimeException)
     280             : {
     281           0 :     return ::getCppuType((const uno::Reference< text::XTextRange >*)0);
     282             : }
     283             : 
     284           0 : sal_Bool SAL_CALL SvxUnoTextContent::hasElements()
     285             :     throw(uno::RuntimeException)
     286             : {
     287           0 :     SolarMutexGuard aGuard;
     288             : 
     289           0 :     SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL;
     290           0 :     if( pForwarder )
     291             :     {
     292           0 :         std::vector<sal_uInt16> aPortions;
     293           0 :         pForwarder->GetPortions( mnParagraph, aPortions );
     294           0 :         return !aPortions.empty();
     295             :     }
     296             :     else
     297             :     {
     298           0 :         return 0;
     299           0 :     }
     300             : }
     301             : 
     302             : // XPropertySet
     303             : 
     304           0 : void SAL_CALL SvxUnoTextContent::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
     305             :     throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
     306             : {
     307           0 :     _setPropertyValue( aPropertyName, aValue, mnParagraph );
     308           0 : }
     309             : 
     310           3 : uno::Any SAL_CALL SvxUnoTextContent::getPropertyValue( const OUString& PropertyName )
     311             :     throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
     312             : {
     313           3 :     return _getPropertyValue( PropertyName, mnParagraph );
     314             : }
     315             : 
     316             : // XMultiPropertySet
     317           0 : void SAL_CALL SvxUnoTextContent::setPropertyValues( const uno::Sequence< ::rtl::OUString >& aPropertyNames, const uno::Sequence< uno::Any >& aValues ) throw (beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
     318             : {
     319           0 :     _setPropertyValues( aPropertyNames, aValues, mnParagraph );
     320           0 : }
     321             : 
     322           1 : uno::Sequence< uno::Any > SAL_CALL SvxUnoTextContent::getPropertyValues( const uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (uno::RuntimeException)
     323             : {
     324           1 :     return _getPropertyValues( aPropertyNames, mnParagraph );
     325             : }
     326             : 
     327             : /*// XTolerantMultiPropertySet
     328             : uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SvxUnoTextContent::setPropertyValuesTolerant( const uno::Sequence< ::rtl::OUString >& aPropertyNames, const uno::Sequence< uno::Any >& aValues ) throw (lang::IllegalArgumentException, uno::RuntimeException)
     329             : {
     330             :     return _setPropertyValuesTolerant(aPropertyNames, aValues, mnParagraph);
     331             : }
     332             : 
     333             : uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL SvxUnoTextContent::getPropertyValuesTolerant( const uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (uno::RuntimeException)
     334             : {
     335             :     return _getPropertyValuesTolerant(aPropertyNames, mnParagraph);
     336             : }
     337             : 
     338             : uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SvxUnoTextContent::getDirectPropertyValuesTolerant( const uno::Sequence< ::rtl::OUString >& aPropertyNames )
     339             :     throw (uno::RuntimeException)
     340             : {
     341             :     return _getDirectPropertyValuesTolerant(aPropertyNames, mnParagraph);
     342             : }*/
     343             : 
     344             : // beans::XPropertyState
     345           0 : beans::PropertyState SAL_CALL SvxUnoTextContent::getPropertyState( const OUString& PropertyName )
     346             :     throw(beans::UnknownPropertyException, uno::RuntimeException)
     347             : {
     348           0 :     return _getPropertyState( PropertyName, mnParagraph );
     349             : }
     350             : 
     351           2 : uno::Sequence< beans::PropertyState > SAL_CALL SvxUnoTextContent::getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
     352             :     throw(beans::UnknownPropertyException, uno::RuntimeException)
     353             : {
     354           2 :     return _getPropertyStates( aPropertyName, mnParagraph );
     355             : }
     356             : 
     357           0 : void SAL_CALL SvxUnoTextContent::setPropertyToDefault( const OUString& PropertyName )
     358             :     throw(beans::UnknownPropertyException, uno::RuntimeException)
     359             : {
     360           0 :     _setPropertyToDefault( PropertyName, mnParagraph );
     361           0 : }
     362             : 
     363             : // lang::XServiceInfo
     364             : 
     365           0 : OUString SAL_CALL SvxUnoTextContent::getImplementationName()
     366             :     throw(uno::RuntimeException)
     367             : {
     368           0 :     return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoTextContent") );
     369             : }
     370             : 
     371          61 : uno::Sequence< OUString > SAL_CALL SvxUnoTextContent::getSupportedServiceNames()
     372             :     throw(uno::RuntimeException)
     373             : {
     374          61 :     uno::Sequence< OUString > aSeq( SvxUnoTextRangeBase::getSupportedServiceNames() );
     375             :     comphelper::ServiceInfoHelper::addToSequence( aSeq, 5, "com.sun.star.style.ParagraphProperties",
     376             :                                                   "com.sun.star.style.ParagraphPropertiesComplex",
     377             :                                                   "com.sun.star.style.ParagraphPropertiesAsian",
     378             :                                                   "com.sun.star.text.TextContent",
     379          61 :                                                   "com.sun.star.text.Paragraph");
     380          61 :     return aSeq;
     381             : }
     382             : 
     383             : // ====================================================================
     384             : //  class SvxUnoTextRangeEnumeration
     385             : // ====================================================================
     386             : 
     387          61 : SvxUnoTextRangeEnumeration::SvxUnoTextRangeEnumeration( const SvxUnoTextBase& rText, sal_uInt16 nPara ) throw()
     388             : :   mxParentText(  const_cast<SvxUnoTextBase*>(&rText) ),
     389             :     mrParentText( rText ),
     390             :     mnParagraph( nPara ),
     391          61 :     mnNextPortion( 0 )
     392             : {
     393          61 :     mpEditSource = rText.GetEditSource() ? rText.GetEditSource()->Clone() : NULL;
     394             : 
     395          61 :     if( mpEditSource && mpEditSource->GetTextForwarder() )
     396             :     {
     397          61 :         mpPortions = new std::vector<sal_uInt16>;
     398          61 :         mpEditSource->GetTextForwarder()->GetPortions( nPara, *mpPortions );
     399             :     }
     400             :     else
     401             :     {
     402           0 :         mpPortions = NULL;
     403             :     }
     404          61 : }
     405             : 
     406         183 : SvxUnoTextRangeEnumeration::~SvxUnoTextRangeEnumeration() throw()
     407             : {
     408          61 :     delete mpEditSource;
     409          61 :     delete mpPortions;
     410         122 : }
     411             : 
     412             : // container::XEnumeration
     413             : 
     414         158 : sal_Bool SAL_CALL SvxUnoTextRangeEnumeration::hasMoreElements()
     415             :     throw(uno::RuntimeException)
     416             : {
     417         158 :     SolarMutexGuard aGuard;
     418             : 
     419         158 :     return mpPortions && mnNextPortion < mpPortions->size();
     420             : }
     421             : 
     422          97 : uno::Any SAL_CALL SvxUnoTextRangeEnumeration::nextElement()
     423             :     throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
     424             : {
     425          97 :     SolarMutexGuard aGuard;
     426             : 
     427          97 :     if( mpPortions == NULL || mnNextPortion >= mpPortions->size() )
     428           0 :         throw container::NoSuchElementException();
     429             : 
     430          97 :     sal_uInt16 nStartPos = 0;
     431          97 :     if (mnNextPortion > 0)
     432          36 :         nStartPos = mpPortions->at(mnNextPortion-1);
     433          97 :     sal_uInt16 nEndPos = mpPortions->at(mnNextPortion);
     434          97 :     ESelection aSel( mnParagraph, nStartPos, mnParagraph, nEndPos );
     435             : 
     436          97 :     uno::Reference< text::XTextRange > xRange;
     437             : 
     438          97 :     const SvxUnoTextRangeBaseList& rRanges( mpEditSource->getRanges() );
     439             : 
     440          97 :     SvxUnoTextRange* pRange = 0;
     441             : 
     442          97 :     SvxUnoTextRangeBaseList::const_iterator aIter;
     443          97 :     for( aIter = rRanges.begin(); (aIter != rRanges.end()) && (pRange == 0); ++aIter )
     444             :     {
     445           0 :         SvxUnoTextRange* pIterRange = dynamic_cast< SvxUnoTextRange* >( (*aIter ) );
     446           0 :         if( pIterRange && pIterRange->mbPortion && (aSel.IsEqual( pIterRange->maSelection ) ) )
     447           0 :             pRange = pIterRange;
     448             :     }
     449             : 
     450          97 :     if( pRange == 0 )
     451             :     {
     452          97 :         pRange = new SvxUnoTextRange( mrParentText, sal_True );
     453          97 :         pRange->SetSelection(aSel);
     454             :     }
     455             : 
     456          97 :     xRange = pRange;
     457             : 
     458          97 :     mnNextPortion++;
     459             : 
     460          97 :     return uno::makeAny( xRange );
     461             : }
     462             : 
     463             : // ====================================================================
     464             : // class SvxUnoTextCursor
     465             : // ====================================================================
     466             : 
     467           0 : uno::Reference< uno::XInterface > SvxUnoTextCursor_NewInstance()
     468             : {
     469           0 :     SvxUnoText aText;
     470           0 :     uno::Reference< text::XText > xText( (text::XText*)new SvxUnoTextCursor( aText ) );
     471           0 :     uno::Reference< uno::XInterface > xInt( xText, uno::UNO_QUERY );
     472           0 :     return xInt;
     473             : }
     474             : 
     475         721 : SvxUnoTextCursor::SvxUnoTextCursor( const SvxUnoTextBase& rText ) throw()
     476             : :   SvxUnoTextRangeBase(rText),
     477         721 :     mxParentText( const_cast<SvxUnoTextBase*>(&rText) )
     478             : {
     479         721 : }
     480             : 
     481         232 : SvxUnoTextCursor::SvxUnoTextCursor( const SvxUnoTextCursor& rCursor ) throw()
     482             : :   SvxUnoTextRangeBase(rCursor)
     483             : ,   text::XTextCursor()
     484             : ,   lang::XTypeProvider()
     485             : ,   cppu::OWeakAggObject()
     486         232 : ,   mxParentText(rCursor.mxParentText)
     487             : {
     488         232 : }
     489             : 
     490        1326 : SvxUnoTextCursor::~SvxUnoTextCursor() throw()
     491             : {
     492        1326 : }
     493             : 
     494             : // Comment out automatically - [getIdlClass(es) or queryInterface]
     495             : // Please use the XTypeProvider!
     496             : //sal_Bool SvxUnoTextCursor::queryInterface( uno::Uik aUIK, Reference< uno::XInterface > & xRef)
     497        2291 : uno::Any SAL_CALL SvxUnoTextCursor::queryAggregation( const uno::Type & rType )
     498             :     throw(uno::RuntimeException)
     499             : {
     500        2291 :     if( rType == ::getCppuType((const uno::Reference< text::XTextRange >*)0) )
     501         391 :         return uno::makeAny(uno::Reference< text::XTextRange >((text::XText*)(this)));
     502        1900 :     else QUERYINT( text::XTextCursor );
     503        1900 :     else QUERYINT( beans::XMultiPropertyStates );
     504        1900 :     else QUERYINT( beans::XPropertySet );
     505        1482 :     else QUERYINT( beans::XMultiPropertySet );
     506        1269 :     else QUERYINT( beans::XPropertyState );
     507        1269 :     else QUERYINT( text::XTextRangeCompare );
     508        1269 :     else QUERYINT( lang::XServiceInfo );
     509        1269 :     else QUERYINT( lang::XTypeProvider );
     510        1269 :     else QUERYINT( lang::XUnoTunnel );
     511             :     else
     512          90 :         return OWeakAggObject::queryAggregation( rType );
     513             : }
     514             : 
     515        2291 : uno::Any SAL_CALL SvxUnoTextCursor::queryInterface( const uno::Type & rType )
     516             :     throw(uno::RuntimeException)
     517             : {
     518        2291 :     return OWeakAggObject::queryInterface(rType);
     519             : }
     520             : 
     521        7145 : void SAL_CALL SvxUnoTextCursor::acquire() throw ( )
     522             : {
     523        7145 :     OWeakAggObject::acquire();
     524        7145 : }
     525             : 
     526        7145 : void SAL_CALL SvxUnoTextCursor::release() throw ( )
     527             : {
     528        7145 :     OWeakAggObject::release();
     529        7145 : }
     530             : 
     531             : namespace
     532             : {
     533             :     struct theSvxUnoTextCursorTypes :
     534             :         public rtl::StaticWithInit<uno::Sequence<uno::Type>, theSvxUnoTextCursorTypes>
     535             :     {
     536           0 :         uno::Sequence<uno::Type> operator () ()
     537             :         {
     538           0 :             uno::Sequence< uno::Type > aTypeSequence;
     539             : 
     540           0 :             aTypeSequence.realloc( 10 ); // !DANGER! keep this updated
     541           0 :             uno::Type* pTypes = aTypeSequence.getArray();
     542             : 
     543           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0);
     544           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCursor >*)0);
     545           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
     546           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
     547           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
     548           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
     549           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
     550           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
     551           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
     552           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
     553             : 
     554           0 :             return aTypeSequence;
     555             :         }
     556             :     };
     557             : }
     558             : 
     559             : // XTypeProvider
     560           0 : uno::Sequence< uno::Type > SAL_CALL SvxUnoTextCursor::getTypes()
     561             :     throw(uno::RuntimeException)
     562             : {
     563           0 :     return theSvxUnoTextCursorTypes::get();
     564             : }
     565             : 
     566             : namespace
     567             : {
     568             :     class theSvxUnoTextCursorImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxUnoTextCursorImplementationId > {};
     569             : }
     570             : 
     571           0 : uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextCursor::getImplementationId()
     572             :     throw (uno::RuntimeException)
     573             : {
     574           0 :     return theSvxUnoTextCursorImplementationId::get().getSeq();
     575             : }
     576             : 
     577             : // text::XTextCursor
     578           0 : void SAL_CALL SvxUnoTextCursor::collapseToStart()
     579             :     throw(uno::RuntimeException)
     580             : {
     581           0 :     SolarMutexGuard aGuard;
     582           0 :     CollapseToStart();
     583           0 : }
     584             : 
     585           0 : void SAL_CALL SvxUnoTextCursor::collapseToEnd()
     586             :     throw(uno::RuntimeException)
     587             : {
     588           0 :     SolarMutexGuard aGuard;
     589           0 :     CollapseToEnd();
     590           0 : }
     591             : 
     592          62 : sal_Bool SAL_CALL SvxUnoTextCursor::isCollapsed()
     593             :     throw(uno::RuntimeException)
     594             : {
     595          62 :     SolarMutexGuard aGuard;
     596          62 :     return IsCollapsed();
     597             : }
     598             : 
     599         246 : sal_Bool SAL_CALL SvxUnoTextCursor::goLeft( sal_Int16 nCount, sal_Bool bExpand )
     600             :     throw(uno::RuntimeException)
     601             : {
     602         246 :     SolarMutexGuard aGuard;
     603         246 :     return GoLeft( nCount, bExpand );
     604             : }
     605             : 
     606           0 : sal_Bool SAL_CALL SvxUnoTextCursor::goRight( sal_Int16 nCount, sal_Bool bExpand )
     607             :     throw(uno::RuntimeException)
     608             : {
     609           0 :     SolarMutexGuard aGuard;
     610           0 :     return GoRight( nCount, bExpand );
     611             : }
     612             : 
     613           0 : void SAL_CALL SvxUnoTextCursor::gotoStart( sal_Bool bExpand )
     614             :     throw(uno::RuntimeException)
     615             : {
     616           0 :     SolarMutexGuard aGuard;
     617           0 :     GotoStart( bExpand );
     618           0 : }
     619             : 
     620         385 : void SAL_CALL SvxUnoTextCursor::gotoEnd( sal_Bool bExpand )
     621             :     throw(uno::RuntimeException)
     622             : {
     623         385 :     SolarMutexGuard aGuard;
     624         385 :     GotoEnd( bExpand );
     625         385 : }
     626             : 
     627         401 : void SAL_CALL SvxUnoTextCursor::gotoRange( const uno::Reference< text::XTextRange >& xRange, sal_Bool bExpand )
     628             :     throw(uno::RuntimeException)
     629             : {
     630         401 :     if( !xRange.is() )
     631         401 :         return;
     632             : 
     633         401 :     SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( xRange );
     634             : 
     635         401 :     if( pRange )
     636             :     {
     637         401 :         ESelection aNewSel = pRange->GetSelection();
     638             : 
     639         401 :         if( bExpand )
     640             :         {
     641         284 :             const ESelection& rOldSel = GetSelection();
     642         284 :             aNewSel.nStartPara = rOldSel.nStartPara;
     643         284 :             aNewSel.nStartPos  = rOldSel.nStartPos;
     644             :         }
     645             : 
     646         401 :         SetSelection( aNewSel );
     647             :     }
     648             : }
     649             : 
     650             : // text::XTextRange (rest in SvxTextRange)
     651         432 : uno::Reference< text::XText > SAL_CALL SvxUnoTextCursor::getText(void) throw( uno::RuntimeException )
     652             : {
     653         432 :     return mxParentText;
     654             : }
     655             : 
     656         336 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextCursor::getStart()
     657             :     throw(uno::RuntimeException)
     658             : {
     659         336 :     return SvxUnoTextRangeBase::getStart();
     660             : }
     661             : 
     662           0 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextCursor::getEnd()
     663             :     throw(uno::RuntimeException)
     664             : {
     665           0 :     return SvxUnoTextRangeBase::getEnd();
     666             : }
     667             : 
     668           0 : OUString SAL_CALL SvxUnoTextCursor::getString() throw( uno::RuntimeException )
     669             : {
     670           0 :     return SvxUnoTextRangeBase::getString();
     671             : }
     672             : 
     673         821 : void SAL_CALL SvxUnoTextCursor::setString( const OUString& aString ) throw(uno::RuntimeException)
     674             : {
     675         821 :     SvxUnoTextRangeBase::setString(aString);
     676         821 : }
     677             : // lang::XServiceInfo
     678           0 : OUString SAL_CALL SvxUnoTextCursor::getImplementationName() throw(uno::RuntimeException)
     679             : {
     680           0 :     return OUString(RTL_CONSTASCII_USTRINGPARAM("SvxUnoTextCursor"));
     681             : }
     682             : 
     683           0 : sal_Bool SAL_CALL SvxUnoTextCursor::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
     684             : {
     685           0 :     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
     686             : }
     687             : 
     688           0 : uno::Sequence< OUString > SAL_CALL SvxUnoTextCursor::getSupportedServiceNames() throw(uno::RuntimeException)
     689             : {
     690           0 :     uno::Sequence< OUString > aSeq( SvxUnoTextRangeBase::getSupportedServiceNames() );
     691             :     comphelper::ServiceInfoHelper::addToSequence( aSeq, 4,"com.sun.star.style.ParagraphProperties",
     692             :                                                   "com.sun.star.style.ParagraphPropertiesComplex",
     693             :                                                   "com.sun.star.style.ParagraphPropertiesAsian",
     694           0 :                                                  "com.sun.star.text.TextCursor");
     695           0 :     return aSeq;
     696             : }
     697             : 
     698             : 
     699             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10