LCOV - code coverage report
Current view: top level - libreoffice/editeng/source/uno - unotext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 750 1238 60.6 %
Date: 2012-12-17 Functions: 90 185 48.6 %
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 <com/sun/star/style/LineSpacing.hpp>
      22             : #include <com/sun/star/text/ControlCharacter.hpp>
      23             : #include <com/sun/star/text/XTextField.hpp>
      24             : #include <com/sun/star/text/TextRangeSelection.hpp>
      25             : 
      26             : #include <osl/mutex.hxx>
      27             : #include <svl/itemset.hxx>
      28             : #include <svl/itempool.hxx>
      29             : #include <svl/intitem.hxx>
      30             : #include <svl/eitem.hxx>
      31             : #include <rtl/instance.hxx>
      32             : 
      33             : #include <editeng/fontitem.hxx>
      34             : #include <editeng/tstpitem.hxx>
      35             : #include <editeng/unoprnms.hxx>
      36             : #include <editeng/unotext.hxx>
      37             : #include <editeng/unoedsrc.hxx>
      38             : #include <editeng/unonrule.hxx>
      39             : #include <editeng/unofdesc.hxx>
      40             : #include <editeng/unofield.hxx>
      41             : #include <editeng/flditem.hxx>
      42             : #include <editeng/numitem.hxx>
      43             : #include <editeng/editeng.hxx>
      44             : #include <editeng/outliner.hxx>
      45             : #include <editeng/unoipset.hxx>
      46             : #include <comphelper/serviceinfohelper.hxx>
      47             : #include <comphelper/servicehelper.hxx>
      48             : 
      49             : #include "editeng/unonames.hxx"
      50             : 
      51             : #include <boost/scoped_ptr.hpp>
      52             : 
      53             : using namespace ::rtl;
      54             : using namespace ::cppu;
      55             : using namespace ::com::sun::star;
      56             : 
      57             : namespace {
      58             : 
      59          64 : ESelection toESelection(const text::TextRangeSelection& rSel)
      60             : {
      61          64 :     ESelection aESel;
      62          64 :     aESel.nStartPara = rSel.Start.Paragraph;
      63          64 :     aESel.nStartPos = rSel.Start.PositionInParagraph;
      64          64 :     aESel.nEndPara = rSel.End.Paragraph;
      65          64 :     aESel.nEndPos = rSel.End.PositionInParagraph;
      66          64 :     return aESel;
      67             : }
      68             : 
      69             : }
      70             : 
      71             : #define QUERYINT( xint ) \
      72             :     if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \
      73             :         return uno::makeAny(uno::Reference< xint >(this))
      74             : 
      75       16986 : const SvxItemPropertySet* ImplGetSvxUnoOutlinerTextCursorSvxPropertySet()
      76             : {
      77       16986 :     static SvxItemPropertySet aTextCursorSvxPropertySet( ImplGetSvxUnoOutlinerTextCursorPropertyMap(), EditEngine::GetGlobalItemPool() );
      78       16986 :     return &aTextCursorSvxPropertySet;
      79             : }
      80             : 
      81          10 : const SfxItemPropertyMapEntry* ImplGetSvxTextPortionPropertyMap()
      82             : {
      83             :     // Propertymap for an Outliner Text
      84             :     static const SfxItemPropertyMapEntry aSvxTextPortionPropertyMap[] =
      85             :     {
      86         460 :         SVX_UNOEDIT_CHAR_PROPERTIES,
      87          10 :         SVX_UNOEDIT_FONT_PROPERTIES,
      88          50 :         SVX_UNOEDIT_OUTLINER_PROPERTIES,
      89         140 :         SVX_UNOEDIT_PARA_PROPERTIES,
      90          10 :         {MAP_CHAR_LEN("TextField"),                     EE_FEATURE_FIELD,   &::getCppuType((const uno::Reference< text::XTextField >*)0),   beans::PropertyAttribute::READONLY, 0 },
      91          10 :         {MAP_CHAR_LEN("TextPortionType"),               WID_PORTIONTYPE,    &::getCppuType((const ::rtl::OUString*)0), beans::PropertyAttribute::READONLY, 0 },
      92          10 :         {MAP_CHAR_LEN("TextUserDefinedAttributes"),         EE_CHAR_XMLATTRIBS,     &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0)  ,        0,     0},
      93          10 :         {MAP_CHAR_LEN("ParaUserDefinedAttributes"),         EE_PARA_XMLATTRIBS,     &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0)  ,        0,     0},
      94             :         {0,0,0,0,0,0}
      95         710 :     };
      96          10 :     return aSvxTextPortionPropertyMap;
      97             : }
      98         194 : const SvxItemPropertySet* ImplGetSvxTextPortionSvxPropertySet()
      99             : {
     100         194 :     static SvxItemPropertySet aSvxTextPortionPropertySet( ImplGetSvxTextPortionPropertyMap(), EditEngine::GetGlobalItemPool() );
     101         194 :     return &aSvxTextPortionPropertySet;
     102             : }
     103             : 
     104          10 : const SfxItemPropertySet* ImplGetSvxTextPortionSfxPropertySet()
     105             : {
     106          10 :     static SfxItemPropertySet aSvxTextPortionSfxPropertySet( ImplGetSvxTextPortionPropertyMap() );
     107          10 :     return &aSvxTextPortionSfxPropertySet;
     108             : }
     109             : 
     110          33 : const SfxItemPropertyMapEntry* ImplGetSvxUnoOutlinerTextCursorPropertyMap()
     111             : {
     112             :     // Propertymap for an Outliner Text
     113             :     static const SfxItemPropertyMapEntry aSvxUnoOutlinerTextCursorPropertyMap[] =
     114             :     {
     115        1242 :         SVX_UNOEDIT_CHAR_PROPERTIES,
     116          27 :         SVX_UNOEDIT_FONT_PROPERTIES,
     117         135 :         SVX_UNOEDIT_OUTLINER_PROPERTIES,
     118         378 :         SVX_UNOEDIT_PARA_PROPERTIES,
     119          27 :         {MAP_CHAR_LEN("TextUserDefinedAttributes"),         EE_CHAR_XMLATTRIBS,     &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0)  ,        0,     0},
     120          27 :         {MAP_CHAR_LEN("ParaUserDefinedAttributes"),         EE_PARA_XMLATTRIBS,     &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0)  ,        0,     0},
     121             :         {0,0,0,0,0,0}
     122        1869 :     };
     123             : 
     124          33 :     return aSvxUnoOutlinerTextCursorPropertyMap;
     125             : }
     126          10 : const SfxItemPropertySet* ImplGetSvxUnoOutlinerTextCursorSfxPropertySet()
     127             : {
     128          10 :     static SfxItemPropertySet aTextCursorSfxPropertySet( ImplGetSvxUnoOutlinerTextCursorPropertyMap() );
     129          10 :     return &aTextCursorSfxPropertySet;
     130             : }
     131             : 
     132             : // ====================================================================
     133             : // helper for Item/Property conversion
     134             : // ====================================================================
     135             : 
     136       49044 : void GetSelection( struct ESelection& rSel, SvxTextForwarder* pForwarder ) throw()
     137             : {
     138             :     DBG_ASSERT( pForwarder, "I need a valid SvxTextForwarder!" );
     139       49044 :     if( pForwarder )
     140             :     {
     141       49044 :         sal_Int16 nParaCount = pForwarder->GetParagraphCount();
     142       49044 :         if(nParaCount>0)
     143       49044 :             nParaCount--;
     144             : 
     145       49044 :         rSel = ESelection( 0,0, nParaCount, pForwarder->GetTextLen( nParaCount ));
     146             :     }
     147       49044 : }
     148             : 
     149       42806 : void CheckSelection( struct ESelection& rSel, SvxTextForwarder* pForwarder ) throw()
     150             : {
     151             :     DBG_ASSERT( pForwarder, "I need a valid SvxTextForwarder!" );
     152       42806 :     if( pForwarder )
     153             :     {
     154       42806 :         if( rSel.nStartPara == 0xffff )
     155             :         {
     156         264 :             ::GetSelection( rSel, pForwarder );
     157             :         }
     158             :         else
     159             :         {
     160       42542 :             ESelection aMaxSelection;
     161       42542 :             GetSelection( aMaxSelection, pForwarder );
     162             : 
     163             :             // check start position
     164       42542 :             if( rSel.nStartPara < aMaxSelection.nStartPara )
     165             :             {
     166           0 :                 rSel.nStartPara = aMaxSelection.nStartPara;
     167           0 :                 rSel.nStartPos = aMaxSelection.nStartPos;
     168             :             }
     169       42542 :             else if( rSel.nStartPara > aMaxSelection.nEndPara )
     170             :             {
     171           0 :                 rSel.nStartPara = aMaxSelection.nEndPara;
     172           0 :                 rSel.nStartPos = aMaxSelection.nEndPos;
     173             :             }
     174       42542 :             else if( rSel.nStartPos  > pForwarder->GetTextLen( rSel.nStartPara ) )
     175             :             {
     176           0 :                 rSel.nStartPos = pForwarder->GetTextLen( rSel.nStartPara );
     177             :             }
     178             : 
     179             :             // check end position
     180       42542 :             if( rSel.nEndPara < aMaxSelection.nStartPara )
     181             :             {
     182           0 :                 rSel.nEndPara = aMaxSelection.nStartPara;
     183           0 :                 rSel.nEndPos = aMaxSelection.nStartPos;
     184             :             }
     185       42542 :             else if( rSel.nEndPara > aMaxSelection.nEndPara )
     186             :             {
     187         566 :                 rSel.nEndPara = aMaxSelection.nEndPara;
     188         566 :                 rSel.nEndPos = aMaxSelection.nEndPos;
     189             :             }
     190       41976 :             else if( rSel.nEndPos > pForwarder->GetTextLen( rSel.nEndPara ) )
     191             :             {
     192          36 :                 rSel.nEndPos = pForwarder->GetTextLen( rSel.nEndPara );
     193             :             }
     194             :         }
     195             :     }
     196       42806 : }
     197             : 
     198       17416 : void CheckSelection( struct ESelection& rSel, SvxEditSource *pEdit ) throw()
     199             : {
     200       17416 :     if (!pEdit)
     201       17416 :         return;
     202       17416 :     CheckSelection( rSel, pEdit->GetTextForwarder() );
     203             : }
     204             : 
     205             : // ====================================================================
     206             : // class SvxUnoTextRangeBase
     207             : // ====================================================================
     208             : 
     209       15748 : UNO3_GETIMPLEMENTATION_IMPL( SvxUnoTextRangeBase );
     210             : 
     211       16990 : SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxItemPropertySet* _pSet ) throw()
     212       16990 : : mpEditSource(NULL) , mpPropSet(_pSet)
     213             : {
     214       16990 : }
     215             : 
     216        1614 : SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet ) throw()
     217        1614 : : mpPropSet(_pSet)
     218             : {
     219        1614 :     SolarMutexGuard aGuard;
     220             : 
     221             :     DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
     222             : 
     223        1614 :     mpEditSource = pSource->Clone();
     224        1614 :     if (mpEditSource != NULL)
     225             :     {
     226        1614 :         ESelection aSelection;
     227        1614 :         ::GetSelection( aSelection, mpEditSource->GetTextForwarder() );
     228        1614 :         SetSelection( aSelection );
     229             : 
     230        1614 :         mpEditSource->addRange( this );
     231        1614 :     }
     232        1614 : }
     233             : 
     234        2650 : SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxUnoTextRangeBase& rRange ) throw()
     235             : :   text::XTextRange()
     236             : ,   beans::XPropertySet()
     237             : ,   beans::XMultiPropertySet()
     238             : ,   beans::XMultiPropertyStates()
     239             : ,   beans::XPropertyState()
     240             : ,   lang::XServiceInfo()
     241             : ,   text::XTextRangeCompare()
     242             : ,   lang::XUnoTunnel()
     243             : ,   osl::DebugBase<SvxUnoTextRangeBase>()
     244        2650 : ,   mpPropSet(rRange.getPropertySet())
     245             : {
     246        2650 :     SolarMutexGuard aGuard;
     247             : 
     248        2650 :     mpEditSource = rRange.mpEditSource ? rRange.mpEditSource->Clone() : NULL;
     249             : 
     250        2650 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     251        2650 :     if( pForwarder )
     252             :     {
     253        2650 :         maSelection  = rRange.maSelection;
     254        2650 :         CheckSelection( maSelection, pForwarder );
     255             :     }
     256             : 
     257        2650 :     if( mpEditSource )
     258        2650 :         mpEditSource->addRange( this );
     259        2650 : }
     260             : 
     261       42496 : SvxUnoTextRangeBase::~SvxUnoTextRangeBase() throw()
     262             : {
     263       21248 :     if( mpEditSource )
     264       21220 :         mpEditSource->removeRange( this );
     265             : 
     266       21248 :     delete mpEditSource;
     267       21248 : }
     268             : 
     269       16962 : void SvxUnoTextRangeBase::SetEditSource( SvxEditSource* pSource ) throw()
     270             : {
     271             :     DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
     272             :     DBG_ASSERT(mpEditSource==NULL,"SvxUnoTextRangeBase::SetEditSource called while SvxEditSource already set" );
     273             : 
     274       16962 :     mpEditSource = pSource;
     275             : 
     276       16962 :     maSelection.nStartPara = 0xffff;
     277             : 
     278       16962 :     if( mpEditSource )
     279       16962 :         mpEditSource->addRange( this );
     280       16962 : }
     281             : 
     282             : /** puts a field item with a copy of the given FieldData into the itemset
     283             :     corresponding with this range */
     284           0 : void SvxUnoTextRangeBase::attachField( const SvxFieldData* pData ) throw()
     285             : {
     286           0 :     SolarMutexGuard aGuard;
     287             : 
     288           0 :     if( pData )
     289             :     {
     290           0 :         SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     291           0 :         if( pForwarder )
     292             :         {
     293           0 :             SvxFieldItem aField( *pData, EE_FEATURE_FIELD );
     294           0 :             pForwarder->QuickInsertField( aField, maSelection );
     295             :         }
     296           0 :     }
     297           0 : }
     298             : 
     299        9576 : void SvxUnoTextRangeBase::SetSelection( const ESelection& rSelection ) throw()
     300             : {
     301        9576 :     SolarMutexGuard aGuard;
     302             : 
     303        9576 :     maSelection = rSelection;
     304        9576 :     CheckSelection( maSelection, mpEditSource );
     305        9576 : }
     306             : 
     307             : // Interface XTextRange ( XText )
     308             : 
     309         672 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getStart(void)
     310             :     throw( uno::RuntimeException )
     311             : {
     312         672 :     SolarMutexGuard aGuard;
     313             : 
     314         672 :     uno::Reference< text::XTextRange > xRange;
     315             : 
     316         672 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     317         672 :     if( pForwarder )
     318             :     {
     319         672 :         CheckSelection( maSelection, pForwarder );
     320             : 
     321         672 :         SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( getText() );
     322             : 
     323         672 :         if(pText == NULL)
     324           0 :             throw uno::RuntimeException();
     325             : 
     326         672 :         SvxUnoTextRange* pRange = new SvxUnoTextRange( *pText );
     327         672 :         xRange = pRange;
     328             : 
     329         672 :         ESelection aNewSel = maSelection;
     330         672 :         aNewSel.nEndPara = aNewSel.nStartPara;
     331         672 :         aNewSel.nEndPos  = aNewSel.nStartPos;
     332         672 :         pRange->SetSelection( aNewSel );
     333             :     }
     334             : 
     335         672 :     return xRange;
     336             : }
     337             : 
     338           8 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getEnd(void)
     339             :     throw( uno::RuntimeException )
     340             : {
     341           8 :     SolarMutexGuard aGuard;
     342             : 
     343           8 :     uno::Reference< text::XTextRange > xRet;
     344             : 
     345           8 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     346           8 :     if( pForwarder )
     347             :     {
     348           8 :         CheckSelection( maSelection, pForwarder );
     349             : 
     350           8 :         SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( getText() );
     351             : 
     352           8 :         if(pText == NULL)
     353           0 :             throw uno::RuntimeException();
     354             : 
     355           8 :         SvxUnoTextRange* pNew = new SvxUnoTextRange( *pText );
     356           8 :         xRet = pNew;
     357             : 
     358           8 :         ESelection aNewSel = maSelection;
     359           8 :         aNewSel.nStartPara = aNewSel.nEndPara;
     360           8 :         aNewSel.nStartPos  = aNewSel.nEndPos;
     361           8 :         pNew->SetSelection( aNewSel );
     362             :     }
     363           8 :     return xRet;
     364             : }
     365             : 
     366         188 : OUString SAL_CALL SvxUnoTextRangeBase::getString(void)
     367             :     throw( uno::RuntimeException )
     368             : {
     369         188 :     SolarMutexGuard aGuard;
     370             : 
     371         188 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     372         188 :     if( pForwarder )
     373             :     {
     374         188 :         CheckSelection( maSelection, pForwarder );
     375             : 
     376         188 :         return pForwarder->GetText( maSelection );
     377             :     }
     378             :     else
     379             :     {
     380           0 :         const OUString aEmpty;
     381           0 :         return aEmpty;
     382         188 :     }
     383             : }
     384             : 
     385        3902 : void SAL_CALL SvxUnoTextRangeBase::setString(const OUString& aString)
     386             :     throw( uno::RuntimeException )
     387             : {
     388        3902 :     SolarMutexGuard aGuard;
     389             : 
     390        3902 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     391        3902 :     if( pForwarder )
     392             :     {
     393        3902 :         CheckSelection( maSelection, pForwarder );
     394             : 
     395        3902 :         String aConverted(convertLineEnd(aString, LINEEND_LF));  // Simply count the number of line endings
     396             : 
     397        3902 :         pForwarder->QuickInsertText( aConverted, maSelection );
     398        3902 :         mpEditSource->UpdateData();
     399             : 
     400             :         //  Adapt selection
     401             :         //! It would be easier if the EditEngine would return the selection
     402             :         //! on QuickInsertText...
     403        3902 :         CollapseToStart();
     404             : 
     405        3902 :         sal_uInt16 nLen = aConverted.Len();
     406        3902 :         if (nLen)
     407        3234 :             GoRight( nLen, sal_True );
     408        3902 :     }
     409        3902 : }
     410             : 
     411             : // Interface beans::XPropertySet
     412        2128 : uno::Reference< beans::XPropertySetInfo > SAL_CALL SvxUnoTextRangeBase::getPropertySetInfo(void)
     413             :     throw( uno::RuntimeException )
     414             : {
     415        2128 :     return mpPropSet->getPropertySetInfo();
     416             : }
     417             : 
     418        1032 : void SAL_CALL SvxUnoTextRangeBase::setPropertyValue(const OUString& PropertyName, const uno::Any& aValue)
     419             :     throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException )
     420             : {
     421        1032 :     if (PropertyName == UNO_TR_PROP_SELECTION)
     422             :     {
     423          32 :         text::TextRangeSelection aSel = aValue.get<text::TextRangeSelection>();
     424          32 :         SetSelection(toESelection(aSel));
     425             : 
     426        1028 :         return;
     427             :     }
     428             : 
     429        1000 :     _setPropertyValue( PropertyName, aValue, -1 );
     430             : }
     431             : 
     432        1000 : void SAL_CALL SvxUnoTextRangeBase::_setPropertyValue( const OUString& PropertyName, const uno::Any& aValue, sal_Int32 nPara )
     433             :     throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException )
     434             : {
     435        1000 :     SolarMutexGuard aGuard;
     436             : 
     437        1000 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     438        1000 :     if( pForwarder )
     439             :     {
     440        1000 :         CheckSelection( maSelection, pForwarder );
     441             : 
     442        1000 :         const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName );
     443        1000 :         if ( pMap )
     444             :         {
     445         996 :             ESelection aSel( GetSelection() );
     446         996 :             sal_Bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END );
     447             : 
     448         996 :             if( nPara == -1 && !bParaAttrib )
     449             :             {
     450          78 :                 SfxItemSet aOldSet( pForwarder->GetAttribs( aSel ) );
     451             :                 // we have a selection and no para attribute
     452          78 :                 SfxItemSet aNewSet( *aOldSet.GetPool(), aOldSet.GetRanges() );
     453             : 
     454          78 :                 setPropertyValue( pMap, aValue, maSelection, aOldSet, aNewSet );
     455             : 
     456             : 
     457          78 :                 pForwarder->QuickSetAttribs( aNewSet, GetSelection() );
     458             :             }
     459             :             else
     460             :             {
     461             :                 sal_Int32 nEndPara;
     462             : 
     463         918 :                 if( nPara == -1 )
     464             :                 {
     465         918 :                     nPara = aSel.nStartPara;
     466         918 :                     nEndPara = aSel.nEndPara;
     467             :                 }
     468             :                 else
     469             :                 {
     470             :                     // only one paragraph
     471           0 :                     nEndPara = nPara;
     472             :                 }
     473             : 
     474        2754 :                 while( nPara <= nEndPara )
     475             :                 {
     476             :                     // we have a paragraph
     477         918 :                     SfxItemSet aSet( pForwarder->GetParaAttribs( (sal_uInt16)nPara ) );
     478         918 :                     setPropertyValue( pMap, aValue, maSelection, aSet, aSet );
     479         918 :                     pForwarder->SetParaAttribs( (sal_uInt16)nPara, aSet );
     480         918 :                     nPara++;
     481         918 :                 }
     482             :             }
     483             : 
     484         996 :             GetEditSource()->UpdateData();
     485         996 :             return;
     486             :         }
     487             :     }
     488             : 
     489         996 :     throw beans::UnknownPropertyException();
     490             : }
     491             : 
     492        6232 : void SvxUnoTextRangeBase::setPropertyValue( const SfxItemPropertySimpleEntry* pMap, const uno::Any& rValue, const ESelection& rSelection, const SfxItemSet& rOldSet, SfxItemSet& rNewSet ) throw( beans::UnknownPropertyException, lang::IllegalArgumentException )
     493             : {
     494        6232 :     if(!SetPropertyValueHelper( rOldSet, pMap, rValue, rNewSet, &rSelection, GetEditSource() ))
     495             :     {
     496             :         // For parts of composite items with multiple properties (eg background)
     497             :         // must be taken from the document before the old item.
     498        5410 :         rNewSet.Put(rOldSet.Get(pMap->nWID));  // Old Item in new Set
     499        5410 :         mpPropSet->setPropertyValue(pMap, rValue, rNewSet, false );
     500             :     }
     501        6232 : }
     502             : 
     503      133786 : sal_Bool SvxUnoTextRangeBase::SetPropertyValueHelper( const SfxItemSet&, const SfxItemPropertySimpleEntry* pMap, const uno::Any& aValue, SfxItemSet& rNewSet, const ESelection* pSelection /* = NULL */, SvxEditSource* pEditSource /* = NULL*/ )
     504             : {
     505      133786 :     switch( pMap->nWID )
     506             :     {
     507             :     case WID_FONTDESC:
     508             :         {
     509           0 :             awt::FontDescriptor aDesc;
     510           0 :             if(aValue >>= aDesc)
     511             :             {
     512           0 :                 SvxUnoFontDescriptor::FillItemSet( aDesc, rNewSet );
     513           0 :                 return sal_True;
     514           0 :             }
     515             :         }
     516           0 :         break;
     517             : 
     518             :     case EE_PARA_NUMBULLET:
     519             :         {
     520         682 :             uno::Reference< container::XIndexReplace > xRule;
     521         682 :             if( !aValue.hasValue() || ((aValue >>= xRule) && !xRule.is()) )
     522         592 :                 return sal_True;
     523             : 
     524          90 :             return sal_False;
     525             :         }
     526             : 
     527             :     case WID_NUMLEVEL:
     528             :         {
     529         148 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     530         148 :             if(pForwarder && pSelection)
     531             :             {
     532         148 :                 sal_Int16 nLevel = sal_Int16();
     533         148 :                 if( aValue >>= nLevel )
     534             :                 {
     535             :                     // #101004# Call interface method instead of unsafe cast
     536         148 :                     if(! pForwarder->SetDepth( pSelection->nStartPara, nLevel ) )
     537           0 :                         throw lang::IllegalArgumentException();
     538             : 
     539         148 :                     return sal_True;
     540             :                 }
     541             :             }
     542             :         }
     543           0 :         break;
     544             :     case WID_NUMBERINGSTARTVALUE:
     545             :         {
     546           0 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     547           0 :             if(pForwarder && pSelection)
     548             :             {
     549           0 :                 sal_Int16 nStartValue = -1;
     550           0 :                 if( aValue >>= nStartValue )
     551             :                 {
     552           0 :                     pForwarder->SetNumberingStartValue( pSelection->nStartPara, nStartValue );
     553           0 :                     return sal_True;
     554             :                 }
     555             :             }
     556             :         }
     557           0 :         break;
     558             :     case WID_PARAISNUMBERINGRESTART:
     559             :         {
     560           0 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     561           0 :             if(pForwarder && pSelection)
     562             :             {
     563           0 :                 sal_Bool bParaIsNumberingRestart = sal_False;
     564           0 :                 if( aValue >>= bParaIsNumberingRestart )
     565             :                 {
     566           0 :                     pForwarder->SetParaIsNumberingRestart( pSelection->nStartPara, bParaIsNumberingRestart );
     567           0 :                     return sal_True;
     568             :                 }
     569             :             }
     570             :         }
     571           0 :         break;
     572             :     case EE_PARA_BULLETSTATE:
     573             :         {
     574         172 :             sal_Bool bBullet = sal_True;
     575         172 :             if( aValue >>= bBullet )
     576             :             {
     577         172 :                 SfxBoolItem aItem( EE_PARA_BULLETSTATE, bBullet );
     578         172 :                 rNewSet.Put(aItem);
     579         172 :                 return sal_True;
     580             :             }
     581             :         }
     582           0 :         break;
     583             : 
     584             :     default:
     585      132784 :         return sal_False;
     586             :     }
     587             : 
     588           0 :     throw lang::IllegalArgumentException();
     589             : }
     590             : 
     591        1334 : uno::Any SAL_CALL SvxUnoTextRangeBase::getPropertyValue(const OUString& PropertyName)
     592             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
     593             : {
     594        1334 :     if (PropertyName == UNO_TR_PROP_SELECTION)
     595             :     {
     596          32 :         const ESelection& rSel = GetSelection();
     597          32 :         text::TextRangeSelection aSel;
     598          32 :         aSel.Start.Paragraph = static_cast<sal_Int32>(rSel.nStartPara);
     599          32 :         aSel.Start.PositionInParagraph = static_cast<sal_Int32>(rSel.nStartPos);
     600          32 :         aSel.End.Paragraph = static_cast<sal_Int32>(rSel.nEndPara);
     601          32 :         aSel.End.PositionInParagraph = static_cast<sal_Int32>(rSel.nEndPos);
     602          32 :         return uno::makeAny(aSel);
     603             :     }
     604             : 
     605        1302 :     return _getPropertyValue( PropertyName, -1 );
     606             : }
     607             : 
     608        1308 : uno::Any SAL_CALL SvxUnoTextRangeBase::_getPropertyValue(const OUString& PropertyName, sal_Int32 nPara )
     609             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
     610             : {
     611        1308 :     SolarMutexGuard aGuard;
     612             : 
     613        1308 :     uno::Any aAny;
     614             : 
     615        1308 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     616        1308 :     if( pForwarder )
     617             :     {
     618        1308 :         const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName );
     619        1308 :         if( pMap )
     620             :         {
     621        1304 :             SfxItemSet* pAttribs = NULL;
     622        1304 :             if( nPara != -1 )
     623           6 :                 pAttribs = pForwarder->GetParaAttribs( (sal_uInt16)nPara ).Clone();
     624             :             else
     625        1298 :                 pAttribs = pForwarder->GetAttribs( GetSelection() ).Clone();
     626             : 
     627             :             //  Replace Dontcare with Default, so that one always has a mirror
     628        1304 :             pAttribs->ClearInvalidItems();
     629             : 
     630        1304 :             getPropertyValue( pMap, aAny, *pAttribs );
     631             : 
     632        1304 :             delete pAttribs;
     633        1304 :             return aAny;
     634             :         }
     635             :     }
     636             : 
     637           4 :     throw beans::UnknownPropertyException();
     638             : }
     639             : 
     640        1306 : void SvxUnoTextRangeBase::getPropertyValue( const SfxItemPropertySimpleEntry* pMap, uno::Any& rAny, const SfxItemSet& rSet ) throw( beans::UnknownPropertyException )
     641             : {
     642        1306 :     switch( pMap->nWID )
     643             :     {
     644             :     case EE_FEATURE_FIELD:
     645          64 :         if ( rSet.GetItemState( EE_FEATURE_FIELD, sal_False ) == SFX_ITEM_SET )
     646             :         {
     647          64 :             SvxFieldItem* pItem = (SvxFieldItem*)rSet.GetItem( EE_FEATURE_FIELD );
     648          64 :             const SvxFieldData* pData = pItem->GetField();
     649          64 :             uno::Reference< text::XTextRange > xAnchor( this );
     650             : 
     651             :             // get presentation string for field
     652          64 :             Color* pTColor = NULL;
     653          64 :             Color* pFColor = NULL;
     654             : 
     655          64 :             SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder();
     656          64 :             OUString aPresentation( pForwarder->CalcFieldValue( SvxFieldItem(*pData, EE_FEATURE_FIELD), maSelection.nStartPara, maSelection.nStartPos, pTColor, pFColor ) );
     657             : 
     658          64 :             delete pTColor;
     659          64 :             delete pFColor;
     660             : 
     661          64 :             uno::Reference< text::XTextField > xField( new SvxUnoTextField( xAnchor, aPresentation, pData ) );
     662          64 :             rAny <<= xField;
     663             :         }
     664          64 :         break;
     665             : 
     666             :     case WID_PORTIONTYPE:
     667         194 :         if ( rSet.GetItemState( EE_FEATURE_FIELD, sal_False ) == SFX_ITEM_SET )
     668             :         {
     669          64 :             OUString aType( RTL_CONSTASCII_USTRINGPARAM("TextField") );
     670          64 :             rAny <<= aType;
     671             :         }
     672             :         else
     673             :         {
     674         130 :             OUString aType( RTL_CONSTASCII_USTRINGPARAM("Text") );
     675         130 :             rAny <<= aType;
     676             :         }
     677         194 :         break;
     678             : 
     679             :     default:
     680        1048 :         if(!GetPropertyValueHelper( *((SfxItemSet*)(&rSet)), pMap, rAny, &maSelection, GetEditSource() ))
     681         368 :             rAny = mpPropSet->getPropertyValue(pMap, rSet, true, false );
     682             :     }
     683        1306 : }
     684             : 
     685       10648 : sal_Bool SvxUnoTextRangeBase::GetPropertyValueHelper(  SfxItemSet& rSet, const SfxItemPropertySimpleEntry* pMap, uno::Any& aAny, const ESelection* pSelection /* = NULL */, SvxEditSource* pEditSource /* = NULL */ )
     686             :     throw( uno::RuntimeException )
     687             : {
     688       10648 :     switch( pMap->nWID )
     689             :     {
     690             :     case WID_FONTDESC:
     691             :         {
     692           0 :             awt::FontDescriptor aDesc;
     693           0 :             SvxUnoFontDescriptor::FillFromItemSet( rSet, aDesc );
     694           0 :             aAny <<= aDesc;
     695             :         }
     696           0 :         break;
     697             : 
     698             :     case EE_PARA_NUMBULLET:
     699             :         {
     700         678 :             if((rSet.GetItemState( EE_PARA_NUMBULLET, sal_True ) & (SFX_ITEM_SET|SFX_ITEM_DEFAULT)) == 0)
     701           0 :                 throw uno::RuntimeException();
     702             : 
     703         678 :             SvxNumBulletItem* pBulletItem = (SvxNumBulletItem*)rSet.GetItem( EE_PARA_NUMBULLET, sal_True );
     704             : 
     705         678 :             if( pBulletItem == NULL )
     706           0 :                 throw uno::RuntimeException();
     707             : 
     708         678 :             aAny <<= SvxCreateNumRule( pBulletItem->GetNumRule() );
     709             :         }
     710         678 :         break;
     711             : 
     712             :     case WID_NUMLEVEL:
     713             :         {
     714           2 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     715           2 :             if(pForwarder && pSelection)
     716             :             {
     717           2 :                 sal_Int16 nLevel = pForwarder->GetDepth( pSelection->nStartPara );
     718           2 :                 if( nLevel >= 0 )
     719           2 :                     aAny <<= nLevel;
     720             :             }
     721             :         }
     722           2 :         break;
     723             :     case WID_NUMBERINGSTARTVALUE:
     724             :         {
     725           0 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     726           0 :             if(pForwarder && pSelection)
     727           0 :                 aAny <<= pForwarder->GetNumberingStartValue( pSelection->nStartPara );
     728             :         }
     729           0 :         break;
     730             :     case WID_PARAISNUMBERINGRESTART:
     731             :         {
     732           0 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     733           0 :             if(pForwarder && pSelection)
     734           0 :                 aAny <<= pForwarder->IsParaIsNumberingRestart( pSelection->nStartPara );
     735             :         }
     736           0 :         break;
     737             : 
     738             :     case EE_PARA_BULLETSTATE:
     739             :         {
     740           0 :             sal_Bool bState = sal_False;
     741           0 :             if( rSet.GetItemState( EE_PARA_BULLETSTATE, sal_True ) & (SFX_ITEM_SET|SFX_ITEM_DEFAULT))
     742             :             {
     743           0 :                 SfxBoolItem* pItem = (SfxBoolItem*)rSet.GetItem( EE_PARA_BULLETSTATE, sal_True );
     744           0 :                 bState = pItem->GetValue() ? sal_True : sal_False;
     745             :             }
     746             : 
     747           0 :             aAny <<= bState;
     748             :         }
     749           0 :         break;
     750             :     default:
     751             : 
     752        9968 :         return sal_False;
     753             :     }
     754             : 
     755         680 :     return sal_True;
     756             : }
     757             : 
     758             : // is not (yet) supported
     759           0 : void SAL_CALL SvxUnoTextRangeBase::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
     760           0 : void SAL_CALL SvxUnoTextRangeBase::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
     761           4 : void SAL_CALL SvxUnoTextRangeBase::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
     762           0 : void SAL_CALL SvxUnoTextRangeBase::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
     763             : 
     764             : // XMultiPropertySet
     765         464 : void SAL_CALL SvxUnoTextRangeBase::setPropertyValues( const uno::Sequence< ::rtl::OUString >& aPropertyNames, const uno::Sequence< uno::Any >& aValues ) throw (beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
     766             : {
     767         464 :     _setPropertyValues( aPropertyNames, aValues, -1 );
     768         464 : }
     769             : 
     770         464 : void SAL_CALL SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< ::rtl::OUString >& aPropertyNames, const uno::Sequence< uno::Any >& aValues, sal_Int32 nPara ) throw (beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
     771             : {
     772         464 :     SolarMutexGuard aGuard;
     773             : 
     774         464 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     775         464 :     if( pForwarder )
     776             :     {
     777         464 :         CheckSelection( maSelection, pForwarder );
     778             : 
     779         464 :         ESelection aSel( GetSelection() );
     780             : 
     781         464 :         const OUString* pPropertyNames = aPropertyNames.getConstArray();
     782         464 :         const uno::Any* pValues = aValues.getConstArray();
     783         464 :         sal_Int32 nCount = aPropertyNames.getLength();
     784             : 
     785         464 :         sal_Int32 nEndPara = nPara;
     786         464 :         sal_Int32 nTempPara = nPara;
     787             : 
     788         464 :         if( nTempPara == -1 )
     789             :         {
     790         464 :             nTempPara = aSel.nStartPara;
     791         464 :             nEndPara = aSel.nEndPara;
     792             :         }
     793             : 
     794         464 :         SfxItemSet* pOldAttrSet = NULL;
     795         464 :         SfxItemSet* pNewAttrSet = NULL;
     796             : 
     797         464 :         SfxItemSet* pOldParaSet = NULL;
     798         464 :         SfxItemSet* pNewParaSet = NULL;
     799             : 
     800        5896 :         for( ; nCount; nCount--, pPropertyNames++, pValues++ )
     801             :         {
     802        5432 :             const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames );
     803             : 
     804        5432 :             if( pMap )
     805             :             {
     806        5236 :                 sal_Bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END );
     807             : 
     808        5236 :                 if( (nPara == -1) && !bParaAttrib )
     809             :                 {
     810        4720 :                     if( NULL == pNewAttrSet )
     811             :                     {
     812         450 :                         const SfxItemSet aSet( pForwarder->GetAttribs( aSel ) );
     813         450 :                         pOldAttrSet = new SfxItemSet( aSet );
     814         450 :                         pNewAttrSet = new SfxItemSet( *pOldAttrSet->GetPool(), pOldAttrSet->GetRanges() );
     815             :                     }
     816             : 
     817        4720 :                     setPropertyValue( pMap, *pValues, GetSelection(), *pOldAttrSet, *pNewAttrSet );
     818             : 
     819        4720 :                     if( pMap->nWID >= EE_ITEMS_START && pMap->nWID <= EE_ITEMS_END )
     820             :                     {
     821             :                         const SfxPoolItem* pItem;
     822        4638 :                         if( pNewAttrSet->GetItemState( pMap->nWID, sal_True, &pItem ) == SFX_ITEM_SET )
     823             :                         {
     824        4638 :                             pOldAttrSet->Put( *pItem );
     825             :                         }
     826        4720 :                     }
     827             :                 }
     828             :                 else
     829             :                 {
     830         516 :                     if( NULL == pNewParaSet )
     831             :                     {
     832         142 :                         const SfxItemSet aSet( pForwarder->GetParaAttribs( (sal_uInt16)nTempPara ) );
     833         142 :                         pOldParaSet = new SfxItemSet( aSet );
     834         142 :                         pNewParaSet = new SfxItemSet( *pOldParaSet->GetPool(), pOldParaSet->GetRanges() );
     835             :                     }
     836             : 
     837         516 :                     setPropertyValue( pMap, *pValues, GetSelection(), *pOldParaSet, *pNewParaSet );
     838             : 
     839         516 :                     if( pMap->nWID >= EE_ITEMS_START && pMap->nWID <= EE_ITEMS_END )
     840             :                     {
     841             :                         const SfxPoolItem* pItem;
     842         516 :                         if( pNewParaSet->GetItemState( pMap->nWID, sal_True, &pItem ) == SFX_ITEM_SET )
     843             :                         {
     844         516 :                             pOldParaSet->Put( *pItem );
     845             :                         }
     846             :                     }
     847             : 
     848             :                 }
     849             :             }
     850             :         }
     851             : 
     852         464 :         sal_Bool bNeedsUpdate = sal_False;
     853             : 
     854         464 :         if( pNewParaSet )
     855             :         {
     856         142 :             if( pNewParaSet->Count() )
     857             :             {
     858         426 :                 while( nTempPara <= nEndPara )
     859             :                 {
     860         142 :                     SfxItemSet aSet( pForwarder->GetParaAttribs( (sal_uInt16)nTempPara ) );
     861         142 :                     aSet.Put( *pNewParaSet );
     862         142 :                     pForwarder->SetParaAttribs( (sal_uInt16)nTempPara, aSet );
     863         142 :                     nTempPara++;
     864         142 :                 }
     865         142 :                 bNeedsUpdate = sal_True;
     866             :             }
     867             : 
     868         142 :             delete pNewParaSet;
     869         142 :             delete pOldParaSet;
     870             :         }
     871             : 
     872         464 :         if( pNewAttrSet )
     873             :         {
     874         450 :             if( pNewAttrSet->Count() )
     875             :             {
     876         368 :                 pForwarder->QuickSetAttribs( *pNewAttrSet, GetSelection() );
     877         368 :                 bNeedsUpdate = sal_True;
     878             :             }
     879         450 :             delete pNewAttrSet;
     880         450 :             delete pOldAttrSet;
     881             : 
     882             :         }
     883             : 
     884         464 :         if( bNeedsUpdate )
     885         464 :             GetEditSource()->UpdateData();
     886         464 :     }
     887         464 : }
     888             : 
     889           0 : uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyValues( const uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (uno::RuntimeException)
     890             : {
     891           0 :     return _getPropertyValues( aPropertyNames, -1 );
     892             : }
     893             : 
     894           2 : uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::_getPropertyValues( const uno::Sequence< ::rtl::OUString >& aPropertyNames, sal_Int32 nPara ) throw (uno::RuntimeException)
     895             : {
     896           2 :     SolarMutexGuard aGuard;
     897             : 
     898           2 :     sal_Int32 nCount = aPropertyNames.getLength();
     899             : 
     900             : 
     901           2 :     uno::Sequence< uno::Any > aValues( nCount );
     902             : 
     903           2 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     904           2 :     if( pForwarder )
     905             :     {
     906           2 :         SfxItemSet* pAttribs = NULL;
     907           2 :         if( nPara != -1 )
     908           2 :             pAttribs = pForwarder->GetParaAttribs( (sal_uInt16)nPara ).Clone();
     909             :         else
     910           0 :             pAttribs = pForwarder->GetAttribs( GetSelection() ).Clone();
     911             : 
     912           2 :         pAttribs->ClearInvalidItems();
     913             : 
     914           2 :         const OUString* pPropertyNames = aPropertyNames.getConstArray();
     915           2 :         uno::Any* pValues = aValues.getArray();
     916             : 
     917           4 :         for( ; nCount; nCount--, pPropertyNames++, pValues++ )
     918             :         {
     919           2 :             const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames );
     920           2 :             if( pMap )
     921             :             {
     922           2 :                 getPropertyValue( pMap, *pValues, *pAttribs );
     923             :             }
     924             :         }
     925             : 
     926           2 :         delete pAttribs;
     927             : 
     928             :     }
     929             : 
     930           2 :     return aValues;
     931             : }
     932             : 
     933           4 : void SAL_CALL SvxUnoTextRangeBase::addPropertiesChangeListener( const uno::Sequence< ::rtl::OUString >& , const uno::Reference< beans::XPropertiesChangeListener >& ) throw (uno::RuntimeException)
     934             : {
     935           4 : }
     936             : 
     937           0 : void SAL_CALL SvxUnoTextRangeBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& ) throw (uno::RuntimeException)
     938             : {
     939           0 : }
     940             : 
     941           0 : void SAL_CALL SvxUnoTextRangeBase::firePropertiesChangeEvent( const uno::Sequence< ::rtl::OUString >& , const uno::Reference< beans::XPropertiesChangeListener >& ) throw (uno::RuntimeException)
     942             : {
     943           0 : }
     944             : 
     945             : // beans::XPropertyState
     946           0 : beans::PropertyState SAL_CALL SvxUnoTextRangeBase::getPropertyState( const OUString& PropertyName )
     947             :     throw(beans::UnknownPropertyException, uno::RuntimeException)
     948             : {
     949           0 :     return _getPropertyState( PropertyName, -1 );
     950             : }
     951             : 
     952             : static sal_uInt16 aSvxUnoFontDescriptorWhichMap[] = { EE_CHAR_FONTINFO, EE_CHAR_FONTHEIGHT, EE_CHAR_ITALIC,
     953             :                                                   EE_CHAR_UNDERLINE, EE_CHAR_WEIGHT, EE_CHAR_STRIKEOUT,
     954             :                                                   EE_CHAR_WLM, 0 };
     955             : 
     956           0 : beans::PropertyState SAL_CALL SvxUnoTextRangeBase::_getPropertyState(const SfxItemPropertySimpleEntry* pMap, sal_Int32 nPara)
     957             :     throw( beans::UnknownPropertyException, uno::RuntimeException )
     958             : {
     959           0 :     if ( pMap )
     960             :     {
     961           0 :         SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     962           0 :         if( pForwarder )
     963             :         {
     964           0 :             SfxItemState eItemState = SFX_ITEM_UNKNOWN;
     965           0 :             sal_uInt16 nWID = 0;
     966             : 
     967           0 :             switch( pMap->nWID )
     968             :             {
     969             :             case WID_FONTDESC:
     970             :                 {
     971           0 :                     sal_uInt16* pWhichId = aSvxUnoFontDescriptorWhichMap;
     972             :                     SfxItemState eTempItemState;
     973           0 :                     while( *pWhichId )
     974             :                     {
     975           0 :                         if(nPara != -1)
     976           0 :                             eTempItemState = pForwarder->GetItemState( (sal_uInt16)nPara, *pWhichId );
     977             :                         else
     978           0 :                             eTempItemState = pForwarder->GetItemState( GetSelection(), *pWhichId );
     979             : 
     980           0 :                         switch( eTempItemState )
     981             :                         {
     982             :                         case SFX_ITEM_DISABLED:
     983             :                         case SFX_ITEM_DONTCARE:
     984           0 :                             eItemState = SFX_ITEM_DONTCARE;
     985           0 :                             break;
     986             : 
     987             :                         case SFX_ITEM_DEFAULT:
     988           0 :                             if( eItemState != SFX_ITEM_DEFAULT )
     989             :                             {
     990           0 :                                 if( eItemState == SFX_ITEM_UNKNOWN )
     991           0 :                                     eItemState = SFX_ITEM_DEFAULT;
     992             :                             }
     993           0 :                             break;
     994             : 
     995             :                         case SFX_ITEM_READONLY:
     996             :                         case SFX_ITEM_SET:
     997           0 :                             if( eItemState != SFX_ITEM_SET )
     998             :                             {
     999           0 :                                 if( eItemState == SFX_ITEM_UNKNOWN )
    1000           0 :                                     eItemState = SFX_ITEM_SET;
    1001             :                             }
    1002           0 :                             break;
    1003             :                         default:
    1004           0 :                             throw beans::UnknownPropertyException();
    1005             :                         }
    1006             : 
    1007           0 :                         pWhichId++;
    1008             :                     }
    1009             :                 }
    1010           0 :                 break;
    1011             : 
    1012             :             case WID_NUMLEVEL:
    1013             :             case WID_NUMBERINGSTARTVALUE:
    1014             :             case WID_PARAISNUMBERINGRESTART:
    1015           0 :                 eItemState = SFX_ITEM_SET;
    1016           0 :                 break;
    1017             : 
    1018             :             default:
    1019           0 :                 nWID = pMap->nWID;
    1020             :             }
    1021             : 
    1022           0 :             if( nWID != 0 )
    1023             :             {
    1024           0 :                 if( nPara != -1 )
    1025           0 :                     eItemState = pForwarder->GetItemState( (sal_uInt16)nPara, nWID );
    1026             :                 else
    1027           0 :                     eItemState = pForwarder->GetItemState( GetSelection(), nWID );
    1028             :             }
    1029             : 
    1030           0 :             switch( eItemState )
    1031             :             {
    1032             :             case SFX_ITEM_DONTCARE:
    1033             :             case SFX_ITEM_DISABLED:
    1034           0 :                 return beans::PropertyState_AMBIGUOUS_VALUE;
    1035             :             case SFX_ITEM_READONLY:
    1036             :             case SFX_ITEM_SET:
    1037           0 :                 return beans::PropertyState_DIRECT_VALUE;
    1038             :             case SFX_ITEM_DEFAULT:
    1039           0 :                 return beans::PropertyState_DEFAULT_VALUE;
    1040             : //              case SFX_ITEM_UNKNOWN:
    1041             :             }
    1042             :         }
    1043             :     }
    1044           0 :     throw beans::UnknownPropertyException();
    1045             : }
    1046             : 
    1047           0 : beans::PropertyState SAL_CALL SvxUnoTextRangeBase::_getPropertyState(const OUString& PropertyName, sal_Int32 nPara /* = -1 */)
    1048             :     throw( beans::UnknownPropertyException, uno::RuntimeException )
    1049             : {
    1050           0 :     SolarMutexGuard aGuard;
    1051             : 
    1052           0 :     return _getPropertyState( mpPropSet->getPropertyMapEntry( PropertyName ), nPara);
    1053             : }
    1054             : 
    1055         194 : uno::Sequence< beans::PropertyState > SAL_CALL SvxUnoTextRangeBase::getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
    1056             :     throw(beans::UnknownPropertyException, uno::RuntimeException)
    1057             : {
    1058         194 :     return _getPropertyStates( aPropertyName, -1 );
    1059             : }
    1060             : 
    1061         198 : uno::Sequence< beans::PropertyState > SvxUnoTextRangeBase::_getPropertyStates(const uno::Sequence< OUString >& PropertyName, sal_Int32 nPara /* = -1 */)
    1062             :     throw( beans::UnknownPropertyException, uno::RuntimeException )
    1063             : {
    1064         198 :     const sal_Int32 nCount = PropertyName.getLength();
    1065         198 :     const OUString* pNames = PropertyName.getConstArray();
    1066             : 
    1067         198 :     uno::Sequence< beans::PropertyState > aRet( nCount );
    1068         198 :     beans::PropertyState* pState = aRet.getArray();
    1069             : 
    1070         198 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1071         198 :     if( pForwarder )
    1072             :     {
    1073         198 :         SfxItemSet* pSet = NULL;
    1074         198 :         if( nPara != -1 )
    1075             :         {
    1076           4 :             pSet = new SfxItemSet( pForwarder->GetParaAttribs( (sal_uInt16)nPara ) );
    1077             :         }
    1078             :         else
    1079             :         {
    1080         194 :             ESelection aSel( GetSelection() );
    1081         194 :             CheckSelection( aSel, pForwarder );
    1082         194 :             pSet = new SfxItemSet( pForwarder->GetAttribs( aSel, EditEngineAttribs_OnlyHard ) );
    1083             :         }
    1084             : 
    1085         198 :         sal_Bool bUnknownPropertyFound = sal_False;
    1086        9944 :         for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
    1087             :         {
    1088        9746 :             const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( *pNames++ );
    1089        9746 :             if( NULL == pMap )
    1090             :             {
    1091           0 :                 bUnknownPropertyFound = sal_True;
    1092           0 :                 break;
    1093             :             }
    1094        9746 :             bUnknownPropertyFound = !_getOnePropertyStates(pSet, pMap, *pState++);
    1095             :         }
    1096             : 
    1097         198 :         delete pSet;
    1098             : 
    1099         198 :         if( bUnknownPropertyFound )
    1100           0 :             throw beans::UnknownPropertyException();
    1101             :     }
    1102             : 
    1103         198 :     return aRet;
    1104             : }
    1105             : 
    1106        9746 : sal_Bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const SfxItemPropertySimpleEntry* pMap, beans::PropertyState& rState)
    1107             : {
    1108        9746 :     sal_Bool bUnknownPropertyFound = sal_False;
    1109        9746 :     if(pSet && pMap)
    1110             :     {
    1111        9746 :         SfxItemState eItemState = SFX_ITEM_UNKNOWN;
    1112        9746 :         sal_uInt16 nWID = 0;
    1113             : 
    1114        9746 :         switch( pMap->nWID )
    1115             :         {
    1116             :             case WID_FONTDESC:
    1117             :                 {
    1118           0 :                     sal_uInt16* pWhichId = aSvxUnoFontDescriptorWhichMap;
    1119             :                     SfxItemState eTempItemState;
    1120           0 :                     while( *pWhichId )
    1121             :                     {
    1122           0 :                         eTempItemState = pSet->GetItemState( *pWhichId );
    1123             : 
    1124           0 :                         switch( eTempItemState )
    1125             :                         {
    1126             :                         case SFX_ITEM_DISABLED:
    1127             :                         case SFX_ITEM_DONTCARE:
    1128           0 :                             eItemState = SFX_ITEM_DONTCARE;
    1129           0 :                             break;
    1130             : 
    1131             :                         case SFX_ITEM_DEFAULT:
    1132           0 :                             if( eItemState != SFX_ITEM_DEFAULT )
    1133             :                             {
    1134           0 :                                 if( eItemState == SFX_ITEM_UNKNOWN )
    1135           0 :                                     eItemState = SFX_ITEM_DEFAULT;
    1136             :                             }
    1137           0 :                             break;
    1138             : 
    1139             :                         case SFX_ITEM_READONLY:
    1140             :                         case SFX_ITEM_SET:
    1141           0 :                             if( eItemState != SFX_ITEM_SET )
    1142             :                             {
    1143           0 :                                 if( eItemState == SFX_ITEM_UNKNOWN )
    1144           0 :                                     eItemState = SFX_ITEM_SET;
    1145             :                             }
    1146           0 :                             break;
    1147             :                         default:
    1148           0 :                             bUnknownPropertyFound = sal_True;
    1149           0 :                             break;
    1150             :                         }
    1151             : 
    1152           0 :                         pWhichId++;
    1153             :                     }
    1154             :                 }
    1155           0 :                 break;
    1156             : 
    1157             :             case WID_NUMLEVEL:
    1158             :             case WID_NUMBERINGSTARTVALUE:
    1159             :             case WID_PARAISNUMBERINGRESTART:
    1160           0 :                 eItemState = SFX_ITEM_SET;
    1161           0 :                 break;
    1162             : 
    1163             :             default:
    1164        9746 :                 nWID = pMap->nWID;
    1165             :         }
    1166             : 
    1167        9746 :         if( bUnknownPropertyFound )
    1168           0 :             return !bUnknownPropertyFound;
    1169             : 
    1170        9746 :         if( nWID != 0 )
    1171        9746 :             eItemState = pSet->GetItemState( nWID, sal_False );
    1172             : 
    1173        9746 :         switch( eItemState )
    1174             :         {
    1175             :                 case SFX_ITEM_READONLY:
    1176             :                 case SFX_ITEM_SET:
    1177           0 :                     rState = beans::PropertyState_DIRECT_VALUE;
    1178           0 :                     break;
    1179             :                 case SFX_ITEM_DEFAULT:
    1180        9746 :                     rState = beans::PropertyState_DEFAULT_VALUE;
    1181        9746 :                     break;
    1182             : //                  case SFX_ITEM_UNKNOWN:
    1183             : //                  case SFX_ITEM_DONTCARE:
    1184             : //                  case SFX_ITEM_DISABLED:
    1185             :                 default:
    1186           0 :                     rState = beans::PropertyState_AMBIGUOUS_VALUE;
    1187             :         }
    1188             :     }
    1189        9746 :     return !bUnknownPropertyFound;
    1190             : }
    1191             : 
    1192           0 : void SAL_CALL SvxUnoTextRangeBase::setPropertyToDefault( const OUString& PropertyName )
    1193             :     throw(beans::UnknownPropertyException, uno::RuntimeException)
    1194             : {
    1195           0 :     _setPropertyToDefault( PropertyName, -1 );
    1196           0 : }
    1197             : 
    1198           0 : void SvxUnoTextRangeBase::_setPropertyToDefault(const OUString& PropertyName, sal_Int32 nPara /* = -1 */)
    1199             :     throw( beans::UnknownPropertyException, uno::RuntimeException )
    1200             : {
    1201           0 :     SolarMutexGuard aGuard;
    1202             : 
    1203           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1204             : 
    1205           0 :     if( pForwarder )
    1206             :     {
    1207           0 :         const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( PropertyName );
    1208           0 :         if ( pMap )
    1209             :         {
    1210           0 :             CheckSelection( maSelection, mpEditSource->GetTextForwarder() );
    1211           0 :             _setPropertyToDefault( pForwarder, pMap, nPara );
    1212           0 :             return;
    1213             :         }
    1214             :     }
    1215             : 
    1216           0 :     throw beans::UnknownPropertyException();
    1217             : }
    1218             : 
    1219           0 : void SvxUnoTextRangeBase::_setPropertyToDefault(SvxTextForwarder* pForwarder, const SfxItemPropertySimpleEntry* pMap, sal_Int32 nPara )
    1220             :     throw( beans::UnknownPropertyException, uno::RuntimeException )
    1221             : {
    1222             :     do
    1223             :     {
    1224           0 :         SfxItemSet aSet( *pForwarder->GetPool(), sal_True );
    1225             : 
    1226           0 :         if( pMap->nWID == WID_FONTDESC )
    1227             :         {
    1228           0 :             SvxUnoFontDescriptor::setPropertyToDefault( aSet );
    1229             :         }
    1230           0 :         else if( pMap->nWID == WID_NUMLEVEL )
    1231             :         {
    1232             :             // #101004# Call interface method instead of unsafe cast
    1233           0 :             pForwarder->SetDepth( maSelection.nStartPara, -1 );
    1234             :             return;
    1235             :         }
    1236           0 :         else if( pMap->nWID == WID_NUMBERINGSTARTVALUE )
    1237             :         {
    1238           0 :             pForwarder->SetNumberingStartValue( maSelection.nStartPara, -1 );
    1239             :         }
    1240           0 :         else if( pMap->nWID == WID_PARAISNUMBERINGRESTART )
    1241             :         {
    1242           0 :             pForwarder->SetParaIsNumberingRestart( maSelection.nStartPara, sal_False );
    1243             :         }
    1244             :         else
    1245             :         {
    1246           0 :             aSet.InvalidateItem( pMap->nWID );
    1247             :         }
    1248             : 
    1249           0 :         if(nPara != -1)
    1250           0 :             pForwarder->SetParaAttribs( (sal_uInt16)nPara, aSet );
    1251             :         else
    1252           0 :             pForwarder->QuickSetAttribs( aSet, GetSelection() );
    1253             : 
    1254           0 :         GetEditSource()->UpdateData();
    1255             : 
    1256           0 :         return;
    1257             :     }
    1258             :     while(0);
    1259             : }
    1260             : 
    1261           0 : uno::Any SAL_CALL SvxUnoTextRangeBase::getPropertyDefault( const OUString& aPropertyName )
    1262             :     throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
    1263             : {
    1264           0 :     SolarMutexGuard aGuard;
    1265             : 
    1266           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1267           0 :     if( pForwarder )
    1268             :     {
    1269           0 :         const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( aPropertyName );
    1270           0 :         if( pMap )
    1271             :         {
    1272           0 :             SfxItemPool* pPool = pForwarder->GetPool();
    1273             : 
    1274           0 :             switch( pMap->nWID )
    1275             :             {
    1276             :             case WID_FONTDESC:
    1277           0 :                 return SvxUnoFontDescriptor::getPropertyDefault( pPool );
    1278             : 
    1279             :             case WID_NUMLEVEL:
    1280             :                 {
    1281           0 :                     uno::Any aAny;
    1282           0 :                     return aAny;
    1283             :                 }
    1284             : 
    1285             :             case WID_NUMBERINGSTARTVALUE:
    1286           0 :                 return uno::Any( (sal_Int16)-1 );
    1287             : 
    1288             :             case WID_PARAISNUMBERINGRESTART:
    1289           0 :                 return uno::Any( (sal_Bool)sal_False );
    1290             : 
    1291             :             default:
    1292             :                 {
    1293             :                     // Get Default from ItemPool
    1294           0 :                     if(pPool->IsWhich(pMap->nWID))
    1295             :                     {
    1296           0 :                         SfxItemSet aSet( *pPool,    pMap->nWID, pMap->nWID);
    1297           0 :                         aSet.Put(pPool->GetDefaultItem(pMap->nWID));
    1298           0 :                         return mpPropSet->getPropertyValue(pMap, aSet, true, false );
    1299             :                     }
    1300             :                 }
    1301             :             }
    1302             :         }
    1303             :     }
    1304           0 :     throw beans::UnknownPropertyException();
    1305             : }
    1306             : 
    1307             : // beans::XMultiPropertyStates
    1308           0 : void SAL_CALL SvxUnoTextRangeBase::setAllPropertiesToDefault(  ) throw (uno::RuntimeException)
    1309             : {
    1310           0 :     SolarMutexGuard aGuard;
    1311             : 
    1312           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1313             : 
    1314           0 :     if( pForwarder )
    1315             :     {
    1316           0 :         PropertyEntryVector_t aEntries = mpPropSet->getPropertyMap()->getPropertyEntries();
    1317           0 :         PropertyEntryVector_t::const_iterator aIt = aEntries.begin();
    1318           0 :         while( aIt != aEntries.end() )
    1319             :         {
    1320           0 :             _setPropertyToDefault( pForwarder, &(*aIt), -1 );
    1321           0 :             ++aIt;
    1322           0 :         }
    1323           0 :     }
    1324           0 : }
    1325             : 
    1326           0 : void SAL_CALL SvxUnoTextRangeBase::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, uno::RuntimeException)
    1327             : {
    1328           0 :     sal_Int32 nCount = aPropertyNames.getLength();
    1329           0 :     for( const OUString* pName = aPropertyNames.getConstArray(); nCount; pName++, nCount-- )
    1330             :     {
    1331           0 :         setPropertyToDefault( *pName );
    1332             :     }
    1333           0 : }
    1334             : 
    1335           0 : uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
    1336             : {
    1337           0 :     sal_Int32 nCount = aPropertyNames.getLength();
    1338           0 :     uno::Sequence< uno::Any > ret( nCount );
    1339           0 :     uno::Any* pDefaults = ret.getArray();
    1340             : 
    1341           0 :     for( const OUString* pName = aPropertyNames.getConstArray(); nCount; pName++, nCount--, pDefaults++ )
    1342             :     {
    1343           0 :         *pDefaults = getPropertyDefault( *pName );
    1344             :     }
    1345             : 
    1346           0 :     return ret;
    1347             : }
    1348             : 
    1349             : // internal
    1350        3902 : void SvxUnoTextRangeBase::CollapseToStart(void) throw()
    1351             : {
    1352        3902 :     CheckSelection( maSelection, mpEditSource );
    1353             : 
    1354        3902 :     maSelection.nEndPara = maSelection.nStartPara;
    1355        3902 :     maSelection.nEndPos  = maSelection.nStartPos;
    1356        3902 : }
    1357             : 
    1358        2414 : void SvxUnoTextRangeBase::CollapseToEnd(void) throw()
    1359             : {
    1360        2414 :     CheckSelection( maSelection, mpEditSource );
    1361             : 
    1362        2414 :     maSelection.nStartPara = maSelection.nEndPara;
    1363        2414 :     maSelection.nStartPos  = maSelection.nEndPos;
    1364        2414 : }
    1365             : 
    1366         124 : sal_Bool SvxUnoTextRangeBase::IsCollapsed(void) throw()
    1367             : {
    1368         124 :     CheckSelection( maSelection, mpEditSource );
    1369             : 
    1370             :     return ( maSelection.nStartPara == maSelection.nEndPara &&
    1371         124 :              maSelection.nStartPos  == maSelection.nEndPos );
    1372             : }
    1373             : 
    1374         628 : sal_Bool SvxUnoTextRangeBase::GoLeft(sal_Int16 nCount, sal_Bool Expand) throw()
    1375             : {
    1376         628 :     CheckSelection( maSelection, mpEditSource );
    1377             : 
    1378             :     //  #75098# use end position, as in Writer (start is anchor, end is cursor)
    1379         628 :     sal_uInt16 nNewPos = maSelection.nEndPos;
    1380         628 :     sal_uInt16 nNewPar = maSelection.nEndPara;
    1381             : 
    1382         628 :     sal_Bool bOk = sal_True;
    1383         628 :     SvxTextForwarder* pForwarder = NULL;
    1384        1884 :     while ( nCount > nNewPos && bOk )
    1385             :     {
    1386         628 :         if ( nNewPar == 0 )
    1387          62 :             bOk = sal_False;
    1388             :         else
    1389             :         {
    1390         566 :             if ( !pForwarder )
    1391         566 :                 pForwarder = mpEditSource->GetTextForwarder();  // first here, it it is necessary...
    1392             : 
    1393         566 :             --nNewPar;
    1394         566 :             nCount -= nNewPos + 1;
    1395         566 :             nNewPos = pForwarder->GetTextLen( nNewPar );
    1396             :         }
    1397             :     }
    1398             : 
    1399         628 :     if ( bOk )
    1400             :     {
    1401         566 :         nNewPos = nNewPos - nCount;
    1402         566 :         maSelection.nStartPara = nNewPar;
    1403         566 :         maSelection.nStartPos  = nNewPos;
    1404             :     }
    1405             : 
    1406         628 :     if (!Expand)
    1407           0 :         CollapseToStart();
    1408             : 
    1409         628 :     return bOk;
    1410             : }
    1411             : 
    1412        3234 : sal_Bool SvxUnoTextRangeBase::GoRight(sal_Int16 nCount, sal_Bool Expand)  throw()
    1413             : {
    1414        3234 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1415        3234 :     if( pForwarder )
    1416             :     {
    1417        3234 :         CheckSelection( maSelection, pForwarder );
    1418             : 
    1419        3234 :         sal_uInt16 nNewPos = maSelection.nEndPos + nCount; //! Overflow???
    1420        3234 :         sal_uInt16 nNewPar = maSelection.nEndPara;
    1421             : 
    1422        3234 :         sal_Bool bOk = sal_True;
    1423        3234 :         sal_uInt16 nParCount = pForwarder->GetParagraphCount();
    1424        3234 :         sal_uInt16 nThisLen = pForwarder->GetTextLen( nNewPar );
    1425        7098 :         while ( nNewPos > nThisLen && bOk )
    1426             :         {
    1427         630 :             if ( nNewPar + 1 >= nParCount )
    1428           0 :                 bOk = sal_False;
    1429             :             else
    1430             :             {
    1431         630 :                 nNewPos -= nThisLen+1;
    1432         630 :                 ++nNewPar;
    1433         630 :                 nThisLen = pForwarder->GetTextLen( nNewPar );
    1434             :             }
    1435             :         }
    1436             : 
    1437        3234 :         if (bOk)
    1438             :         {
    1439        3234 :             maSelection.nEndPara = nNewPar;
    1440        3234 :             maSelection.nEndPos  = nNewPos;
    1441             :         }
    1442             : 
    1443        3234 :         if (!Expand)
    1444           0 :             CollapseToEnd();
    1445             : 
    1446        3234 :         return bOk;
    1447             :     }
    1448           0 :     return sal_False;
    1449             : }
    1450             : 
    1451           0 : void SvxUnoTextRangeBase::GotoStart(sal_Bool Expand) throw()
    1452             : {
    1453           0 :     maSelection.nStartPara = 0;
    1454           0 :     maSelection.nStartPos  = 0;
    1455             : 
    1456           0 :     if (!Expand)
    1457           0 :         CollapseToStart();
    1458           0 : }
    1459             : 
    1460         772 : void SvxUnoTextRangeBase::GotoEnd(sal_Bool Expand) throw()
    1461             : {
    1462         772 :     CheckSelection( maSelection, mpEditSource );
    1463             : 
    1464         772 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1465         772 :     if( pForwarder )
    1466             :     {
    1467             : 
    1468         772 :         sal_uInt16 nPar = pForwarder->GetParagraphCount();
    1469         772 :         if (nPar)
    1470         772 :             --nPar;
    1471             : 
    1472         772 :         maSelection.nEndPara = nPar;
    1473         772 :         maSelection.nEndPos  = pForwarder->GetTextLen( nPar );
    1474             : 
    1475         772 :         if (!Expand)
    1476         540 :             CollapseToEnd();
    1477             :     }
    1478         772 : }
    1479             : 
    1480             : // lang::XServiceInfo
    1481         122 : sal_Bool SAL_CALL SvxUnoTextRangeBase::supportsService( const OUString& ServiceName )
    1482             :     throw(uno::RuntimeException)
    1483             : {
    1484         122 :     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
    1485             : }
    1486             : 
    1487         122 : uno::Sequence< OUString > SAL_CALL SvxUnoTextRangeBase::getSupportedServiceNames()
    1488             :     throw(uno::RuntimeException)
    1489             : {
    1490         122 :     return getSupportedServiceNames_Static();
    1491             : }
    1492             : 
    1493         124 : uno::Sequence< OUString > SAL_CALL SvxUnoTextRangeBase::getSupportedServiceNames_Static()
    1494             :     SAL_THROW(())
    1495             : {
    1496         124 :     uno::Sequence< OUString >   aSeq;
    1497             :     comphelper::ServiceInfoHelper::addToSequence( aSeq, 3, "com.sun.star.style.CharacterProperties",
    1498             :                                                   "com.sun.star.style.CharacterPropertiesComplex",
    1499         124 :                                                   "com.sun.star.style.CharacterPropertiesAsian");
    1500         124 :     return aSeq;
    1501             : }
    1502             : 
    1503             : // XTextRangeCompare
    1504           0 : sal_Int16 SAL_CALL SvxUnoTextRangeBase::compareRegionStarts( const uno::Reference< text::XTextRange >& xR1, const uno::Reference< text::XTextRange >& xR2 ) throw (lang::IllegalArgumentException, uno::RuntimeException)
    1505             : {
    1506           0 :     SvxUnoTextRangeBase* pR1 = SvxUnoTextRangeBase::getImplementation( xR1 );
    1507           0 :     SvxUnoTextRangeBase* pR2 = SvxUnoTextRangeBase::getImplementation( xR2 );
    1508             : 
    1509           0 :     if( (pR1 == 0) || (pR2 == 0) )
    1510           0 :         throw lang::IllegalArgumentException();
    1511             : 
    1512           0 :     const ESelection& r1 = pR1->maSelection;
    1513           0 :     const ESelection& r2 = pR2->maSelection;
    1514             : 
    1515           0 :     if( r1.nStartPara == r2.nStartPara )
    1516             :     {
    1517           0 :         if( r1.nStartPos == r2.nStartPos )
    1518           0 :             return 0;
    1519             :         else
    1520           0 :             return r1.nStartPos < r2.nStartPos ? 1 : -1;
    1521             :     }
    1522             :     else
    1523             :     {
    1524           0 :         return r1.nStartPara < r2.nStartPara ? 1 : -1;
    1525             :     }
    1526             : }
    1527             : 
    1528           0 : sal_Int16 SAL_CALL SvxUnoTextRangeBase::compareRegionEnds( const uno::Reference< text::XTextRange >& xR1, const uno::Reference< text::XTextRange >& xR2 ) throw (lang::IllegalArgumentException, uno::RuntimeException)
    1529             : {
    1530           0 :     SvxUnoTextRangeBase* pR1 = SvxUnoTextRangeBase::getImplementation( xR1 );
    1531           0 :     SvxUnoTextRangeBase* pR2 = SvxUnoTextRangeBase::getImplementation( xR2 );
    1532             : 
    1533           0 :     if( (pR1 == 0) || (pR2 == 0) )
    1534           0 :         throw lang::IllegalArgumentException();
    1535             : 
    1536           0 :     const ESelection& r1 = pR1->maSelection;
    1537           0 :     const ESelection& r2 = pR2->maSelection;
    1538             : 
    1539           0 :     if( r1.nEndPara == r2.nEndPara )
    1540             :     {
    1541           0 :         if( r1.nEndPos == r2.nEndPos )
    1542           0 :             return 0;
    1543             :         else
    1544           0 :             return r1.nEndPos < r2.nEndPos ? 1 : -1;
    1545             :     }
    1546             :     else
    1547             :     {
    1548           0 :         return r1.nEndPara < r2.nEndPara ? 1 : -1;
    1549             :     }
    1550             : }
    1551             : 
    1552             : // ====================================================================
    1553             : // class SvxUnoTextRange
    1554             : // ====================================================================
    1555             : 
    1556           0 : uno::Reference< uno::XInterface > SvxUnoTextRange_NewInstance()
    1557             : {
    1558           0 :     SvxUnoText aText;
    1559           0 :     uno::Reference< text::XTextRange > xRange( new SvxUnoTextRange( aText ) );
    1560             : #ifndef _MSC_VER
    1561           0 :     return xRange;
    1562             : #else
    1563             :     return (uno::Reference< uno::XInterface >)xRange;
    1564             : #endif
    1565             : }
    1566             : 
    1567         884 : SvxUnoTextRange::SvxUnoTextRange( const SvxUnoTextBase& rParent, sal_Bool bPortion /* = sal_False */ ) throw()
    1568        1574 : :SvxUnoTextRangeBase( rParent.GetEditSource(), bPortion ? ImplGetSvxTextPortionSvxPropertySet() : rParent.getPropertySet() ),
    1569        2458 :  mbPortion( bPortion )
    1570             : {
    1571         884 :     xParentText =  (text::XText*)&rParent;
    1572         884 : }
    1573             : 
    1574        1768 : SvxUnoTextRange::~SvxUnoTextRange() throw()
    1575             : {
    1576        1768 : }
    1577             : 
    1578        2102 : uno::Any SAL_CALL SvxUnoTextRange::queryAggregation( const uno::Type & rType )
    1579             :     throw(uno::RuntimeException)
    1580             : {
    1581        2102 :     QUERYINT( text::XTextRange );
    1582        1908 :     else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertyStates >*)0) )
    1583           0 :         return uno::makeAny(uno::Reference< beans::XMultiPropertyStates >(this));
    1584        1908 :     else if( rType == ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) )
    1585         458 :         return uno::makeAny(uno::Reference< beans::XPropertySet >(this));
    1586        1450 :     else QUERYINT( beans::XPropertyState );
    1587        1256 :     else QUERYINT( text::XTextRangeCompare );
    1588        1256 :     else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0) )
    1589         196 :         return uno::makeAny(uno::Reference< beans::XMultiPropertySet >(this));
    1590        1060 :     else QUERYINT( lang::XServiceInfo );
    1591        1060 :     else QUERYINT( lang::XTypeProvider );
    1592         866 :     else QUERYINT( lang::XUnoTunnel );
    1593             :     else
    1594         194 :         return OWeakAggObject::queryAggregation( rType );
    1595             : }
    1596             : 
    1597        2102 : uno::Any SAL_CALL SvxUnoTextRange::queryInterface( const uno::Type & rType )
    1598             :     throw(uno::RuntimeException)
    1599             : {
    1600        2102 :     return OWeakAggObject::queryInterface(rType);
    1601             : }
    1602             : 
    1603        5900 : void SAL_CALL SvxUnoTextRange::acquire()
    1604             :     throw( )
    1605             : {
    1606        5900 :     OWeakAggObject::acquire();
    1607        5900 : }
    1608             : 
    1609        5900 : void SAL_CALL SvxUnoTextRange::release()
    1610             :     throw( )
    1611             : {
    1612        5900 :     OWeakAggObject::release();
    1613        5900 : }
    1614             : 
    1615             : // XTypeProvider
    1616             : 
    1617             : namespace
    1618             : {
    1619             :     struct theSvxUnoTextRangeTypes :
    1620             :         public rtl::StaticWithInit<uno::Sequence<uno::Type>, theSvxUnoTextRangeTypes>
    1621             :     {
    1622           0 :         uno::Sequence<uno::Type> operator () ()
    1623             :         {
    1624           0 :             uno::Sequence< uno::Type > aTypeSequence;
    1625             : 
    1626           0 :             aTypeSequence.realloc( 9 ); // !DANGER! keep this updated
    1627           0 :             uno::Type* pTypes = aTypeSequence.getArray();
    1628             : 
    1629           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0);
    1630           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
    1631           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
    1632           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
    1633           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
    1634           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
    1635           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
    1636           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
    1637           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
    1638             : 
    1639           0 :             return aTypeSequence;
    1640             :         }
    1641             :     };
    1642             : }
    1643             : 
    1644           0 : uno::Sequence< uno::Type > SAL_CALL SvxUnoTextRange::getTypes()
    1645             :     throw (uno::RuntimeException)
    1646             : {
    1647           0 :     return theSvxUnoTextRangeTypes::get();
    1648             : }
    1649             : 
    1650             : namespace
    1651             : {
    1652             :     class theSvxUnoTextRangeImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxUnoTextRangeImplementationId > {};
    1653             : }
    1654             : 
    1655         194 : uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextRange::getImplementationId()
    1656             :     throw (uno::RuntimeException)
    1657             : {
    1658         194 :     return theSvxUnoTextRangeImplementationId::get().getSeq();
    1659             : }
    1660             : 
    1661             : // XTextRange
    1662           0 : uno::Reference< text::XText > SAL_CALL SvxUnoTextRange::getText()
    1663             :     throw(uno::RuntimeException)
    1664             : {
    1665           0 :     return xParentText;
    1666             : }
    1667             : 
    1668             : // lang::XServiceInfo
    1669           0 : OUString SAL_CALL SvxUnoTextRange::getImplementationName()
    1670             :     throw(uno::RuntimeException)
    1671             : {
    1672           0 :     return OUString(RTL_CONSTASCII_USTRINGPARAM("SvxUnoTextRange"));
    1673             : }
    1674             : 
    1675             : // ====================================================================
    1676             : // class SvxUnoText
    1677             : // ====================================================================
    1678             : 
    1679           0 : SvxUnoTextBase::SvxUnoTextBase() throw()
    1680           0 : : SvxUnoTextRangeBase( NULL )
    1681             : {
    1682             : 
    1683           0 : }
    1684             : 
    1685       16990 : SvxUnoTextBase::SvxUnoTextBase( const SvxItemPropertySet* _pSet  ) throw()
    1686       16990 : : SvxUnoTextRangeBase( _pSet )
    1687             : {
    1688       16990 : }
    1689             : 
    1690         730 : SvxUnoTextBase::SvxUnoTextBase( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet, uno::Reference < text::XText > xParent ) throw()
    1691         730 : : SvxUnoTextRangeBase( pSource, _pSet )
    1692             : {
    1693         730 :     xParentText = xParent;
    1694         730 :     ESelection aSelection;
    1695         730 :     ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
    1696         730 :     SetSelection( aSelection );
    1697         730 : }
    1698             : 
    1699           0 : SvxUnoTextBase::SvxUnoTextBase( const SvxUnoTextBase& rText ) throw()
    1700             : :   SvxUnoTextRangeBase( rText )
    1701             : , text::XTextAppend()
    1702             : ,   text::XTextCopy()
    1703             : ,   container::XEnumerationAccess()
    1704             : ,   text::XTextRangeMover()
    1705           0 : ,   lang::XTypeProvider()
    1706             : {
    1707           0 :     xParentText = rText.xParentText;
    1708           0 : }
    1709             : 
    1710       17714 : SvxUnoTextBase::~SvxUnoTextBase() throw()
    1711             : {
    1712       17714 : }
    1713             : 
    1714             : // XInterface
    1715       10432 : uno::Any SAL_CALL SvxUnoTextBase::queryAggregation( const uno::Type & rType )
    1716             :     throw(uno::RuntimeException)
    1717             : {
    1718       10432 :     QUERYINT( text::XText );
    1719       10014 :     QUERYINT( text::XSimpleText );
    1720       10006 :     if( rType == ::getCppuType((const uno::Reference< text::XTextRange >*)0) )
    1721        1874 :         return uno::makeAny(uno::Reference< text::XTextRange >((text::XText*)(this)));
    1722        8132 :     QUERYINT(container::XEnumerationAccess );
    1723        8116 :     QUERYINT( container::XElementAccess );
    1724        8116 :     QUERYINT( beans::XMultiPropertyStates );
    1725        8116 :     QUERYINT( beans::XPropertySet );
    1726        4274 :     QUERYINT( beans::XMultiPropertySet );
    1727        4238 :     QUERYINT( beans::XPropertyState );
    1728        4234 :     QUERYINT( text::XTextRangeCompare );
    1729        4234 :     QUERYINT( lang::XServiceInfo );
    1730        4232 :     QUERYINT( text::XTextRangeMover );
    1731        4232 :     QUERYINT( text::XTextCopy );
    1732        4232 :     QUERYINT( text::XTextAppend );
    1733        4160 :     QUERYINT( text::XParagraphAppend );
    1734        4160 :     QUERYINT( text::XTextPortionAppend );
    1735        4160 :     QUERYINT( lang::XTypeProvider );
    1736        4160 :     QUERYINT( lang::XUnoTunnel );
    1737             : 
    1738        4144 :     return uno::Any();
    1739             : }
    1740             : 
    1741             : // XTypeProvider
    1742             : 
    1743             : namespace
    1744             : {
    1745             :     struct theSvxUnoTextBaseTypes :
    1746             :         public rtl::StaticWithInit<uno::Sequence<uno::Type>, theSvxUnoTextBaseTypes>
    1747             :     {
    1748           0 :         uno::Sequence<uno::Type> operator () ()
    1749             :         {
    1750           0 :             uno::Sequence< uno::Type > aTypeSequence;
    1751             : 
    1752           0 :             aTypeSequence.realloc( 15 ); // !DANGER! keep this updated
    1753           0 :             uno::Type* pTypes = aTypeSequence.getArray();
    1754             : 
    1755           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XText >*)0);
    1756           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0);
    1757           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
    1758           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
    1759           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
    1760           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
    1761           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0);
    1762           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0);
    1763           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0);
    1764           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XParagraphAppend >*)0);
    1765           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextPortionAppend >*)0);
    1766           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
    1767           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
    1768           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
    1769           0 :             *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
    1770             : 
    1771           0 :             return aTypeSequence;
    1772             :         }
    1773             :     };
    1774             : }
    1775           0 : uno::Sequence< uno::Type > SAL_CALL SvxUnoTextBase::getStaticTypes() throw()
    1776             : {
    1777           0 :     return theSvxUnoTextBaseTypes::get();
    1778             : }
    1779             : 
    1780           0 : uno::Sequence< uno::Type > SAL_CALL SvxUnoTextBase::getTypes()
    1781             :     throw (uno::RuntimeException)
    1782             : {
    1783           0 :     return getStaticTypes();
    1784             : }
    1785             : 
    1786             : namespace
    1787             : {
    1788             :     class theSvxUnoTextBaseImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxUnoTextBaseImplementationId > {};
    1789             : }
    1790             : 
    1791           0 : uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextBase::getImplementationId()
    1792             :     throw (uno::RuntimeException)
    1793             : {
    1794           0 :     return theSvxUnoTextBaseImplementationId::get().getSeq();
    1795             : }
    1796             : 
    1797         582 : uno::Reference< text::XTextCursor > SvxUnoTextBase::createTextCursorBySelection( const ESelection& rSel )
    1798             : {
    1799         582 :     SvxUnoTextCursor* pCursor = new SvxUnoTextCursor( *this );
    1800         582 :     uno::Reference< text::XTextCursor >  xCursor( pCursor );
    1801         582 :     pCursor->SetSelection( rSel );
    1802         582 :     return xCursor;
    1803             : }
    1804             : 
    1805             : // XSimpleText
    1806             : 
    1807         300 : uno::Reference< text::XTextCursor > SAL_CALL SvxUnoTextBase::createTextCursor()
    1808             :     throw(uno::RuntimeException)
    1809             : {
    1810         300 :     SolarMutexGuard aGuard;
    1811         300 :     return new SvxUnoTextCursor( *this );
    1812             : }
    1813             : 
    1814         582 : uno::Reference< text::XTextCursor > SAL_CALL SvxUnoTextBase::createTextCursorByRange( const uno::Reference< text::XTextRange >& aTextPosition )
    1815             :     throw(uno::RuntimeException)
    1816             : {
    1817         582 :     SolarMutexGuard aGuard;
    1818             : 
    1819         582 :     uno::Reference< text::XTextCursor >  xCursor;
    1820             : 
    1821         582 :     if( aTextPosition.is() )
    1822             :     {
    1823         582 :         SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
    1824         582 :         if(pRange)
    1825         582 :             xCursor = createTextCursorBySelection( pRange->GetSelection() );
    1826             :     }
    1827             : 
    1828         582 :     return xCursor;
    1829             : }
    1830             : 
    1831        1116 : void SAL_CALL SvxUnoTextBase::insertString( const uno::Reference< text::XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb )
    1832             :     throw(uno::RuntimeException)
    1833             : {
    1834        1116 :     SolarMutexGuard aGuard;
    1835             : 
    1836        1116 :     if( !xRange.is() )
    1837        1116 :         return;
    1838             : 
    1839        1116 :     ESelection aSelection;
    1840        1116 :     if (GetEditSource())
    1841             :     {
    1842        1116 :         ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
    1843        1116 :         SetSelection( aSelection );
    1844             :     }
    1845             : 
    1846        1116 :     SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange );
    1847        1116 :     if(pRange)
    1848             :     {
    1849             :         // setString on SvxUnoTextRangeBase instead of itself QuickInsertText
    1850             :         // and UpdateData, so that the selection will be adjusted to
    1851             :         // SvxUnoTextRangeBase. Actually all cursor objects of this Text must
    1852             :         // to be statement to be adapted!
    1853             : 
    1854        1116 :         if (!bAbsorb)                   // do not replace -> append on tail
    1855         758 :             pRange->CollapseToEnd();
    1856             : 
    1857        1116 :         pRange->setString( aString );
    1858             : 
    1859        1116 :         pRange->CollapseToEnd();
    1860        1116 :     }
    1861             : }
    1862             : 
    1863         634 : void SAL_CALL SvxUnoTextBase::insertControlCharacter( const uno::Reference< text::XTextRange >& xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb )
    1864             :     throw(lang::IllegalArgumentException, uno::RuntimeException)
    1865             : {
    1866         634 :     SolarMutexGuard aGuard;
    1867             : 
    1868         634 :     SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL;
    1869             : 
    1870         634 :     if( pForwarder )
    1871             :     {
    1872         634 :         ESelection aSelection;
    1873         634 :         ::GetSelection( aSelection, pForwarder );
    1874         634 :         SetSelection( aSelection );
    1875             : 
    1876         634 :         switch( nControlCharacter )
    1877             :         {
    1878             :         case text::ControlCharacter::PARAGRAPH_BREAK:
    1879             :         {
    1880           2 :             const rtl::OUString aText( (sal_Unicode)13 );  // '\r' does not work on Mac
    1881           2 :             insertString( xRange, aText, bAbsorb );
    1882             : 
    1883           2 :             return;
    1884             :         }
    1885             :         case text::ControlCharacter::LINE_BREAK:
    1886             :         {
    1887           4 :             SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange );
    1888           4 :             if(pRange)
    1889             :             {
    1890           4 :                 ESelection aRange = pRange->GetSelection();
    1891             : 
    1892           4 :                 if( bAbsorb )
    1893             :                 {
    1894           0 :                     const String aEmpty;
    1895           0 :                     pForwarder->QuickInsertText( aEmpty, aRange );
    1896             : 
    1897           0 :                     aRange.nEndPos = aRange.nStartPos;
    1898           0 :                     aRange.nEndPara = aRange.nStartPara;
    1899             :                 }
    1900             :                 else
    1901             :                 {
    1902           4 :                     aRange.nStartPos = aRange.nEndPos;
    1903           4 :                     aRange.nStartPara = aRange.nStartPara;
    1904             :                 }
    1905             : 
    1906           4 :                 pForwarder->QuickInsertLineBreak( aRange );
    1907           4 :                 GetEditSource()->UpdateData();
    1908             : 
    1909           4 :                 aRange.nEndPos += 1;
    1910           4 :                 if( !bAbsorb )
    1911           4 :                     aRange.nStartPos += 1;
    1912             : 
    1913           4 :                 pRange->SetSelection( aRange );
    1914             :             }
    1915             :             return;
    1916             :         }
    1917             :         case text::ControlCharacter::APPEND_PARAGRAPH:
    1918             :         {
    1919         628 :             SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange );
    1920         628 :             if(pRange)
    1921             :             {
    1922         628 :                 ESelection aRange = pRange->GetSelection();
    1923             : //              ESelection aOldSelection = aRange;
    1924             : 
    1925         628 :                 aRange.nStartPos  = pForwarder->GetTextLen( aRange.nStartPara );
    1926             : 
    1927         628 :                 aRange.nEndPara = aRange.nStartPara;
    1928         628 :                 aRange.nEndPos  = aRange.nStartPos;
    1929             : 
    1930         628 :                 pRange->SetSelection( aRange );
    1931         628 :                 const rtl::OUString aText( (sal_Unicode)13 );  // '\r' geht auf'm Mac nicht
    1932         628 :                 pRange->setString( aText );
    1933             : 
    1934         628 :                 aRange.nStartPos = 0;
    1935         628 :                 aRange.nStartPara += 1;
    1936         628 :                 aRange.nEndPos = 0;
    1937         628 :                 aRange.nEndPara += 1;
    1938             : 
    1939         628 :                 pRange->SetSelection( aRange );
    1940             : 
    1941         628 :                 return;
    1942             :             }
    1943             :         }
    1944             :         default:
    1945           0 :             throw lang::IllegalArgumentException();
    1946             :         }
    1947         634 :     }
    1948             : }
    1949             : 
    1950             : // XText
    1951          34 : void SAL_CALL SvxUnoTextBase::insertTextContent( const uno::Reference< text::XTextRange >& xRange, const uno::Reference< text::XTextContent >& xContent, sal_Bool bAbsorb )
    1952             :     throw(lang::IllegalArgumentException, uno::RuntimeException)
    1953             : {
    1954          34 :     SolarMutexGuard aGuard;
    1955             : 
    1956          34 :     SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL;
    1957          34 :     if (!pForwarder)
    1958          32 :         return;
    1959             : 
    1960          34 :     uno::Reference<beans::XPropertySet> xPropSet(xRange, uno::UNO_QUERY);
    1961          34 :     if (!xPropSet.is())
    1962           2 :         throw lang::IllegalArgumentException();
    1963             : 
    1964          32 :     uno::Any aAny = xPropSet->getPropertyValue(UNO_TR_PROP_SELECTION);
    1965          32 :     text::TextRangeSelection aSel = aAny.get<text::TextRangeSelection>();
    1966          32 :     if (!bAbsorb)
    1967          32 :         aSel.Start = aSel.End;
    1968             : 
    1969          32 :     boost::scoped_ptr<SvxFieldData> pFieldData(SvxFieldData::Create(xContent));
    1970          32 :     if (!pFieldData)
    1971           0 :         throw lang::IllegalArgumentException();
    1972             : 
    1973          32 :     SvxFieldItem aField( *pFieldData, EE_FEATURE_FIELD );
    1974          32 :     pForwarder->QuickInsertField(aField, toESelection(aSel));
    1975          32 :     GetEditSource()->UpdateData();
    1976             : 
    1977          32 :     uno::Reference<beans::XPropertySet> xPropSetContent(xContent, uno::UNO_QUERY);
    1978          32 :     if (!xContent.is())
    1979           0 :         throw lang::IllegalArgumentException();
    1980             : 
    1981          32 :     xPropSetContent->setPropertyValue(UNO_TC_PROP_ANCHOR, uno::makeAny(xRange));
    1982             : 
    1983          32 :     aSel.End.PositionInParagraph += 1;
    1984          32 :     aSel.Start.PositionInParagraph = aSel.End.PositionInParagraph;
    1985          32 :     xPropSet->setPropertyValue(UNO_TR_PROP_SELECTION, uno::makeAny(aSel));
    1986             : }
    1987             : 
    1988           0 : void SAL_CALL SvxUnoTextBase::removeTextContent( const uno::Reference< text::XTextContent >& ) throw(container::NoSuchElementException, uno::RuntimeException)
    1989             : {
    1990           0 : }
    1991             : 
    1992             : // XTextRange
    1993             : 
    1994          12 : uno::Reference< text::XText > SAL_CALL SvxUnoTextBase::getText()
    1995             :     throw(uno::RuntimeException)
    1996             : {
    1997          12 :     SolarMutexGuard aGuard;
    1998             : 
    1999          12 :     if (GetEditSource())
    2000             :     {
    2001          12 :         ESelection aSelection;
    2002          12 :         ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
    2003          12 :         ((SvxUnoTextBase*)this)->SetSelection( aSelection );
    2004             :     }
    2005             : 
    2006          12 :     return (text::XText*)this;
    2007             : }
    2008             : 
    2009           0 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::getStart()
    2010             :     throw(uno::RuntimeException)
    2011             : {
    2012           0 :     return SvxUnoTextRangeBase::getStart();
    2013             : }
    2014             : 
    2015           8 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::getEnd()
    2016             :     throw(uno::RuntimeException)
    2017             : {
    2018           8 :     return SvxUnoTextRangeBase::getEnd();
    2019             : }
    2020             : 
    2021         162 : OUString SAL_CALL SvxUnoTextBase::getString() throw( uno::RuntimeException )
    2022             : {
    2023         162 :     return SvxUnoTextRangeBase::getString();
    2024             : }
    2025             : 
    2026        1842 : void SAL_CALL SvxUnoTextBase::setString( const OUString& aString ) throw(uno::RuntimeException)
    2027             : {
    2028        1842 :     SvxUnoTextRangeBase::setString(aString);
    2029        1842 : }
    2030             : 
    2031             : 
    2032             : // XEnumerationAccess
    2033         128 : uno::Reference< container::XEnumeration > SAL_CALL SvxUnoTextBase::createEnumeration()
    2034             :     throw(uno::RuntimeException)
    2035             : {
    2036         128 :     SolarMutexGuard aGuard;
    2037             : 
    2038         128 :     ESelection aSelection;
    2039         128 :     ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
    2040         128 :     SetSelection( aSelection );
    2041             : 
    2042         128 :     uno::Reference< container::XEnumeration > xEnum( (container::XEnumeration*) new SvxUnoTextContentEnumeration( *this ) );
    2043         128 :     return xEnum;
    2044             : }
    2045             : 
    2046             : // XElementAccess ( container::XEnumerationAccess )
    2047           0 : uno::Type SAL_CALL SvxUnoTextBase::getElementType(  ) throw(uno::RuntimeException)
    2048             : {
    2049           0 :     return ::getCppuType((const uno::Reference< text::XTextRange >*)0 );
    2050             : }
    2051             : 
    2052           0 : sal_Bool SAL_CALL SvxUnoTextBase::hasElements(  ) throw(uno::RuntimeException)
    2053             : {
    2054           0 :     SolarMutexGuard aGuard;
    2055             : 
    2056           0 :     if(GetEditSource())
    2057             :     {
    2058           0 :         SvxTextForwarder* pForwarder = GetEditSource()->GetTextForwarder();
    2059           0 :         if(pForwarder)
    2060           0 :             return pForwarder->GetParagraphCount() != 0;
    2061             :     }
    2062             : 
    2063           0 :     return sal_False;
    2064             : }
    2065             : 
    2066             : // text::XTextRangeMover
    2067           0 : void SAL_CALL SvxUnoTextBase::moveTextRange( const uno::Reference< text::XTextRange >&, sal_Int16 )
    2068             :     throw(uno::RuntimeException)
    2069             : {
    2070           0 : }
    2071             : 
    2072          20 : void SvxPropertyValuesToItemSet(
    2073             :         SfxItemSet &rItemSet,
    2074             :         const uno::Sequence< beans::PropertyValue > rPropertyVaules,
    2075             :         const SfxItemPropertySet *pPropSet,
    2076             :         SvxTextForwarder *pForwarder /*needed for WID_NUMLEVEL*/,
    2077             :         sal_uInt16 nPara /*needed for WID_NUMLEVEL*/)
    2078             :     throw(lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
    2079             : {
    2080          20 :     sal_Int32 nProps = rPropertyVaules.getLength();
    2081          20 :     const beans::PropertyValue *pProps = rPropertyVaules.getConstArray();
    2082          36 :     for (sal_Int32 i = 0;  i < nProps;  ++i)
    2083             :     {
    2084          26 :         const SfxItemPropertySimpleEntry *pEntry = pPropSet->getPropertyMap().getByName( pProps[i].Name );
    2085          26 :         if (pEntry)
    2086             :         {
    2087             :             // Note: there is no need to take special care of the properties
    2088             :             //      TextField (EE_FEATURE_FIELD) and
    2089             :             //      TextPortionType (WID_PORTIONTYPE)
    2090             :             //  since they are read-only and thus are already taken care of below.
    2091             : 
    2092          18 :             if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
    2093             :                 // should be PropertyVetoException which is not yet defined for the new import API's functions
    2094           0 :                 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pProps[i].Name, static_cast < cppu::OWeakObject * > ( 0 ) );
    2095             :                 //throw PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pProps[i].Name, static_cast < cppu::OWeakObject * > ( 0 ) );
    2096             : 
    2097          18 :             if (pEntry->nWID == WID_FONTDESC)
    2098             :             {
    2099           0 :                 awt::FontDescriptor aDesc;
    2100           0 :                 if (pProps[i].Value >>= aDesc)
    2101           0 :                     SvxUnoFontDescriptor::FillItemSet( aDesc, rItemSet );
    2102             :             }
    2103          18 :             else if (pEntry->nWID == WID_NUMLEVEL)
    2104             :             {
    2105           0 :                 if (pForwarder)
    2106             :                 {
    2107           0 :                     sal_Int16 nLevel = -1;
    2108           0 :                     pProps[i].Value >>= nLevel;
    2109             : 
    2110             :                     // #101004# Call interface method instead of unsafe cast
    2111           0 :                     if (!pForwarder->SetDepth( nPara, nLevel ))
    2112           0 :                         throw lang::IllegalArgumentException();
    2113             :                 }
    2114             :             }
    2115          18 :             else if (pEntry->nWID == WID_NUMBERINGSTARTVALUE )
    2116             :             {
    2117           0 :                 if( pForwarder )
    2118             :                 {
    2119           0 :                     sal_Int16 nStartValue = -1;
    2120           0 :                     if( !(pProps[i].Value >>= nStartValue) )
    2121           0 :                         throw lang::IllegalArgumentException();
    2122             : 
    2123           0 :                     pForwarder->SetNumberingStartValue( nPara, nStartValue );
    2124             :                 }
    2125             :             }
    2126          18 :             else if (pEntry->nWID == WID_PARAISNUMBERINGRESTART )
    2127             :             {
    2128           0 :                 if( pForwarder )
    2129             :                 {
    2130           0 :                     sal_Bool bParaIsNumberingRestart = sal_False;
    2131           0 :                     if( !(pProps[i].Value >>= bParaIsNumberingRestart) )
    2132           0 :                         throw lang::IllegalArgumentException();
    2133             : 
    2134           0 :                     pForwarder->SetParaIsNumberingRestart( nPara, bParaIsNumberingRestart );
    2135             :                 }
    2136             :             }
    2137             :             else
    2138          18 :                 pPropSet->setPropertyValue( pProps[i].Name, pProps[i].Value, rItemSet );
    2139             :         }
    2140             :         else
    2141           8 :             throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pProps[i].Name, static_cast < cppu::OWeakObject * > ( 0 ) );
    2142             :     }
    2143          10 : }
    2144             : 
    2145           0 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::finishParagraphInsert(
    2146             :         const uno::Sequence< beans::PropertyValue >& /*rCharAndParaProps*/,
    2147             :         const uno::Reference< text::XTextRange >& /*rTextRange*/ )
    2148             :     throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
    2149             : {
    2150           0 :     uno::Reference< text::XTextRange > xRet;
    2151           0 :     return xRet;
    2152             : }
    2153             : 
    2154          10 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::finishParagraph(
    2155             :         const uno::Sequence< beans::PropertyValue >& rCharAndParaProps )
    2156             :     throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
    2157             : {
    2158          10 :     SolarMutexGuard aGuard;
    2159             : 
    2160          10 :     uno::Reference< text::XTextRange > xRet;
    2161          10 :     SvxEditSource *pEditSource = GetEditSource();
    2162          10 :     SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : 0;
    2163          10 :     if (pTextForwarder)
    2164             :     {
    2165          10 :         sal_uInt16 nParaCount = pTextForwarder->GetParagraphCount();
    2166             :         DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" );
    2167          10 :         pTextForwarder->AppendParagraph();
    2168             : 
    2169             :         // set properties for the previously last paragraph
    2170          10 :         sal_uInt16 nPara = nParaCount - 1;
    2171          10 :         ESelection aSel( nPara, 0, nPara, 0 );
    2172          10 :         SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
    2173             :         SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
    2174          20 :                 ImplGetSvxUnoOutlinerTextCursorSfxPropertySet(), pTextForwarder, nPara );
    2175           0 :         pTextForwarder->QuickSetAttribs( aItemSet, aSel );
    2176           0 :         pEditSource->UpdateData();
    2177           0 :         SvxUnoTextRange* pRange = new SvxUnoTextRange( *this );
    2178           0 :         xRet = pRange;
    2179          10 :         pRange->SetSelection( aSel );
    2180             :     }
    2181          10 :     return xRet;
    2182             : }
    2183             : 
    2184           0 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::insertTextPortion(
    2185             :         const ::rtl::OUString& /*rText*/,
    2186             :         const uno::Sequence< beans::PropertyValue >& /*rCharAndParaProps*/,
    2187             :         const uno::Reference< text::XTextRange>& /*rTextRange*/ )
    2188             :     throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
    2189             : {
    2190           0 :     uno::Reference< text::XTextRange > xRet;
    2191           0 :     return xRet;
    2192             : }
    2193             : 
    2194             : // com::sun::star::text::XTextPortionAppend (new import API)
    2195          10 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::appendTextPortion(
    2196             :         const ::rtl::OUString& rText,
    2197             :         const uno::Sequence< beans::PropertyValue >& rCharAndParaProps )
    2198             :     throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException)
    2199             : {
    2200          10 :     SolarMutexGuard aGuard;
    2201             : 
    2202          10 :     SvxEditSource *pEditSource = GetEditSource();
    2203          10 :     SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : 0;
    2204          10 :     uno::Reference< text::XTextRange > xRet;
    2205          10 :     if (pTextForwarder)
    2206             :     {
    2207          10 :         sal_uInt16 nParaCount = pTextForwarder->GetParagraphCount();
    2208             :         DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" );
    2209          10 :         sal_uInt16 nPara = nParaCount - 1;
    2210          10 :         SfxItemSet aSet( pTextForwarder->GetParaAttribs( nPara ) );
    2211          10 :         xub_StrLen nStart = pTextForwarder->AppendTextPortion( nPara, rText, aSet );
    2212          10 :         pEditSource->UpdateData();
    2213          10 :         xub_StrLen nEnd   = pTextForwarder->GetTextLen( nPara );
    2214             : 
    2215             :         // set properties for the new text portion
    2216          10 :         ESelection aSel( nPara, nStart, nPara, nEnd );
    2217          10 :         pTextForwarder->RemoveAttribs( aSel, sal_False, 0 );
    2218          10 :         pEditSource->UpdateData();
    2219             : 
    2220          10 :         SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
    2221             :         SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
    2222          10 :                 ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, nPara );
    2223          10 :         pTextForwarder->QuickSetAttribs( aItemSet, aSel );
    2224          10 :         SvxUnoTextRange* pRange = new SvxUnoTextRange( *this );
    2225          10 :         xRet = pRange;
    2226          10 :         pRange->SetSelection( aSel );
    2227          10 :         const beans::PropertyValue* pProps = rCharAndParaProps.getConstArray();
    2228          22 :         for( sal_Int32 nProp = 0; nProp < rCharAndParaProps.getLength(); ++nProp )
    2229          22 :             pRange->setPropertyValue( pProps[nProp].Name, pProps[nProp].Value );
    2230             :     }
    2231          10 :     return xRet;
    2232             : }
    2233             : 
    2234           0 : void SvxUnoTextBase::copyText(
    2235             :     const uno::Reference< text::XTextCopy >& xSource ) throw ( uno::RuntimeException )
    2236             : {
    2237           0 :     SolarMutexGuard aGuard;
    2238           0 :     uno::Reference< lang::XUnoTunnel > xUT( xSource, uno::UNO_QUERY );
    2239           0 :     SvxEditSource *pEditSource = GetEditSource();
    2240           0 :     SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : 0;
    2241           0 :     if( !pTextForwarder )
    2242           0 :         return;
    2243           0 :     if( xUT.is() )
    2244             :     {
    2245             :         SvxUnoTextBase* pSource = reinterpret_cast<SvxUnoTextBase*>(sal::static_int_cast<sal_uIntPtr>(
    2246           0 :                                                                     xUT->getSomething( SvxUnoTextBase::getUnoTunnelId())));
    2247           0 :         SvxEditSource *pSourceEditSource = pSource->GetEditSource();
    2248           0 :         SvxTextForwarder *pSourceTextForwarder = pSourceEditSource ? pSourceEditSource->GetTextForwarder() : 0;
    2249           0 :         if( pSourceTextForwarder )
    2250             :         {
    2251           0 :             pTextForwarder->CopyText( *pSourceTextForwarder );
    2252           0 :             pEditSource->UpdateData();
    2253             :         }
    2254             :     }
    2255             :     else
    2256             :     {
    2257           0 :         uno::Reference< text::XText > xSourceText( xSource, uno::UNO_QUERY );
    2258           0 :         if( xSourceText.is() )
    2259             :         {
    2260           0 :             setString( xSourceText->getString() );
    2261           0 :         }
    2262           0 :     }
    2263             : }
    2264             : 
    2265             : // lang::XServiceInfo
    2266           0 : OUString SAL_CALL SvxUnoTextBase::getImplementationName()
    2267             :     throw(uno::RuntimeException)
    2268             : {
    2269           0 :     return OUString(RTL_CONSTASCII_USTRINGPARAM("SvxUnoTextBase"));
    2270             : }
    2271             : 
    2272           2 : uno::Sequence< OUString > SAL_CALL SvxUnoTextBase::getSupportedServiceNames(  )
    2273             :     throw(uno::RuntimeException)
    2274             : {
    2275           2 :     return getSupportedServiceNames_Static();
    2276             : }
    2277             : 
    2278           2 : uno::Sequence< OUString > SAL_CALL SvxUnoTextBase::getSupportedServiceNames_Static(  )
    2279             :     SAL_THROW(())
    2280             : {
    2281           2 :     uno::Sequence< OUString > aSeq( SvxUnoTextRangeBase::getSupportedServiceNames_Static() );
    2282           2 :     comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.text.Text" );
    2283           2 :     return aSeq;
    2284             : }
    2285             : 
    2286             : namespace
    2287             : {
    2288             :     class theSvxUnoTextBaseUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSvxUnoTextBaseUnoTunnelId > {};
    2289             : }
    2290             : 
    2291        2592 : const uno::Sequence< sal_Int8 > & SvxUnoTextBase::getUnoTunnelId() throw()
    2292             : {
    2293        2592 :     return theSvxUnoTextBaseUnoTunnelId::get().getSeq();
    2294             : }
    2295             : 
    2296         744 : SvxUnoTextBase* SvxUnoTextBase::getImplementation( const uno::Reference< uno::XInterface >& xInt )
    2297             : {
    2298         744 :     uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY );
    2299         744 :     if( xUT.is() )
    2300         744 :         return reinterpret_cast<SvxUnoTextBase*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( SvxUnoTextBase::getUnoTunnelId())));
    2301             :     else
    2302           0 :         return NULL;
    2303             : }
    2304             : 
    2305        1848 : sal_Int64 SAL_CALL SvxUnoTextBase::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw(uno::RuntimeException) \
    2306             : {
    2307        5544 :     if( rId.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(),
    2308        3696 :                                                          rId.getConstArray(), 16 ) )
    2309             :     {
    2310         744 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
    2311             :     }
    2312             :     else
    2313             :     {
    2314        1104 :         return SvxUnoTextRangeBase::getSomething( rId );
    2315             :     }
    2316             : }
    2317             : 
    2318             : // --------------------------------------------------------------------
    2319             : 
    2320           0 : SvxUnoText::SvxUnoText( ) throw()
    2321             : {
    2322           0 : }
    2323             : 
    2324           4 : SvxUnoText::SvxUnoText( const SvxItemPropertySet* _pSet ) throw()
    2325           4 : : SvxUnoTextBase( _pSet )
    2326             : {
    2327           4 : }
    2328             : 
    2329         730 : SvxUnoText::SvxUnoText( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet, uno::Reference < text::XText > xParent ) throw()
    2330         730 : : SvxUnoTextBase( pSource, _pSet, xParent )
    2331             : {
    2332         730 : }
    2333             : 
    2334           0 : SvxUnoText::SvxUnoText( const SvxUnoText& rText ) throw()
    2335             : : SvxUnoTextBase( rText )
    2336           0 : , cppu::OWeakAggObject()
    2337             : {
    2338           0 : }
    2339             : 
    2340        1430 : SvxUnoText::~SvxUnoText() throw()
    2341             : {
    2342        1430 : }
    2343             : 
    2344           0 : uno::Sequence< uno::Type > SAL_CALL getStaticTypes() throw()
    2345             : {
    2346           0 :     return SvxUnoTextBase::getStaticTypes();
    2347             : }
    2348             : 
    2349             : // uno::XInterface
    2350          90 : uno::Any SAL_CALL SvxUnoText::queryAggregation( const uno::Type & rType ) throw( uno::RuntimeException )
    2351             : {
    2352          90 :     uno::Any aAny( SvxUnoTextBase::queryAggregation( rType ) );
    2353          90 :     if( !aAny.hasValue() )
    2354          32 :         aAny = OWeakAggObject::queryAggregation( rType );
    2355             : 
    2356          90 :     return aAny;
    2357             : }
    2358             : 
    2359          60 : uno::Any SAL_CALL SvxUnoText::queryInterface( const uno::Type & rType ) throw( uno::RuntimeException )
    2360             : {
    2361          60 :     return OWeakAggObject::queryInterface( rType );
    2362             : }
    2363             : 
    2364        3568 : void SAL_CALL SvxUnoText::acquire() throw( )
    2365             : {
    2366        3568 :     OWeakAggObject::acquire();
    2367        3568 : }
    2368             : 
    2369        3550 : void SAL_CALL SvxUnoText::release() throw( )
    2370             : {
    2371        3550 :     OWeakAggObject::release();
    2372        3550 : }
    2373             : 
    2374             : // lang::XTypeProvider
    2375           0 : uno::Sequence< uno::Type > SAL_CALL SvxUnoText::getTypes(  ) throw( uno::RuntimeException )
    2376             : {
    2377           0 :     return SvxUnoTextBase::getTypes();
    2378             : }
    2379             : 
    2380             : namespace
    2381             : {
    2382             :     class theSvxUnoTextImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxUnoTextImplementationId > {};
    2383             : }
    2384             : 
    2385           0 : uno::Sequence< sal_Int8 > SAL_CALL SvxUnoText::getImplementationId(  ) throw( uno::RuntimeException )
    2386             : {
    2387           0 :     return theSvxUnoTextImplementationId::get().getSeq();
    2388             : }
    2389             : 
    2390             : namespace
    2391             : {
    2392             :     class theSvxUnoTextUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSvxUnoTextUnoTunnelId > {};
    2393             : }
    2394             : 
    2395          16 : const uno::Sequence< sal_Int8 > & SvxUnoText::getUnoTunnelId() throw()
    2396             : {
    2397          16 :     return theSvxUnoTextUnoTunnelId::get().getSeq();
    2398             : }
    2399             : 
    2400          16 : sal_Int64 SAL_CALL SvxUnoText::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw(uno::RuntimeException) \
    2401             : {
    2402          48 :     if( rId.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(),
    2403          32 :                                                          rId.getConstArray(), 16 ) )
    2404             :     {
    2405           0 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
    2406             :     }
    2407             :     else
    2408             :     {
    2409          16 :         return SvxUnoTextBase::getSomething( rId );
    2410             :     }
    2411             : }
    2412             : 
    2413             : 
    2414             : // --------------------------------------------------------------------
    2415             : 
    2416           0 : SvxDummyTextSource::~SvxDummyTextSource()
    2417             : {
    2418           0 : };
    2419             : 
    2420           0 : SvxEditSource* SvxDummyTextSource::Clone() const
    2421             : {
    2422           0 :     return new SvxDummyTextSource();
    2423             : }
    2424             : 
    2425           0 : SvxTextForwarder* SvxDummyTextSource::GetTextForwarder()
    2426             : {
    2427           0 :     return this;
    2428             : }
    2429             : 
    2430           0 : void SvxDummyTextSource::UpdateData()
    2431             : {
    2432           0 : }
    2433             : 
    2434           0 : sal_uInt16 SvxDummyTextSource::GetParagraphCount() const
    2435             : {
    2436           0 :     return 0;
    2437             : }
    2438             : 
    2439           0 : sal_uInt16 SvxDummyTextSource::GetTextLen( sal_uInt16 ) const
    2440             : {
    2441           0 :     return 0;
    2442             : }
    2443             : 
    2444           0 : String SvxDummyTextSource::GetText( const ESelection& ) const
    2445             : {
    2446           0 :     return String();
    2447             : }
    2448             : 
    2449           0 : SfxItemSet SvxDummyTextSource::GetAttribs( const ESelection&, sal_Bool ) const
    2450             : {
    2451             :     // Very dangerous: The former implementation used a SfxItemPool created on the
    2452             :     // fly which of course was deleted again ASAP. Thus, the returned SfxItemSet was using
    2453             :     // a deleted Pool by design.
    2454           0 :     return SfxItemSet(EditEngine::GetGlobalItemPool());
    2455             : }
    2456             : 
    2457           0 : SfxItemSet SvxDummyTextSource::GetParaAttribs( sal_uInt16 ) const
    2458             : {
    2459           0 :     return GetAttribs(ESelection());
    2460             : }
    2461             : 
    2462           0 : void SvxDummyTextSource::SetParaAttribs( sal_uInt16, const SfxItemSet& )
    2463             : {
    2464           0 : }
    2465             : 
    2466           0 : void SvxDummyTextSource::RemoveAttribs( const ESelection& , sal_Bool , sal_uInt16 )
    2467             : {
    2468           0 : }
    2469             : 
    2470           0 : void SvxDummyTextSource::GetPortions( sal_uInt16, std::vector<sal_uInt16>& ) const
    2471             : {
    2472           0 : }
    2473             : 
    2474           0 : sal_uInt16 SvxDummyTextSource::GetItemState( const ESelection&, sal_uInt16 ) const
    2475             : {
    2476           0 :     return 0;
    2477             : }
    2478             : 
    2479           0 : sal_uInt16 SvxDummyTextSource::GetItemState( sal_uInt16, sal_uInt16 ) const
    2480             : {
    2481           0 :     return 0;
    2482             : }
    2483             : 
    2484           0 : SfxItemPool* SvxDummyTextSource::GetPool() const
    2485             : {
    2486           0 :     return NULL;
    2487             : }
    2488             : 
    2489           0 : void SvxDummyTextSource::QuickInsertText( const String&, const ESelection& )
    2490             : {
    2491           0 : }
    2492             : 
    2493           0 : void SvxDummyTextSource::QuickInsertField( const SvxFieldItem&, const ESelection& )
    2494             : {
    2495           0 : }
    2496             : 
    2497           0 : void SvxDummyTextSource::QuickSetAttribs( const SfxItemSet&, const ESelection& )
    2498             : {
    2499           0 : }
    2500             : 
    2501           0 : void SvxDummyTextSource::QuickInsertLineBreak( const ESelection& )
    2502             : {
    2503           0 : };
    2504             : 
    2505           0 : XubString SvxDummyTextSource::CalcFieldValue( const SvxFieldItem&, sal_uInt16, sal_uInt16, Color*&, Color*& )
    2506             : {
    2507           0 :     return XubString();
    2508             : }
    2509             : 
    2510           0 : void SvxDummyTextSource::FieldClicked( const SvxFieldItem&, sal_uInt16, xub_StrLen )
    2511             : {
    2512           0 : }
    2513             : 
    2514           0 : sal_Bool SvxDummyTextSource::IsValid() const
    2515             : {
    2516           0 :     return sal_False;
    2517             : }
    2518             : 
    2519           0 : void SvxDummyTextSource::SetNotifyHdl( const Link& )
    2520             : {
    2521           0 : }
    2522             : 
    2523           0 : LanguageType SvxDummyTextSource::GetLanguage( sal_uInt16, sal_uInt16 ) const
    2524             : {
    2525           0 :     return LANGUAGE_DONTKNOW;
    2526             : }
    2527             : 
    2528           0 : sal_uInt16 SvxDummyTextSource::GetFieldCount( sal_uInt16 ) const
    2529             : {
    2530           0 :     return 0;
    2531             : }
    2532             : 
    2533           0 : EFieldInfo SvxDummyTextSource::GetFieldInfo( sal_uInt16, sal_uInt16 ) const
    2534             : {
    2535           0 :     return EFieldInfo();
    2536             : }
    2537             : 
    2538           0 : EBulletInfo SvxDummyTextSource::GetBulletInfo( sal_uInt16 ) const
    2539             : {
    2540           0 :     return EBulletInfo();
    2541             : }
    2542             : 
    2543           0 : Rectangle SvxDummyTextSource::GetCharBounds( sal_uInt16, sal_uInt16 ) const
    2544             : {
    2545           0 :     return Rectangle();
    2546             : }
    2547             : 
    2548           0 : Rectangle SvxDummyTextSource::GetParaBounds( sal_uInt16 ) const
    2549             : {
    2550           0 :     return Rectangle();
    2551             : }
    2552             : 
    2553           0 : MapMode SvxDummyTextSource::GetMapMode() const
    2554             : {
    2555           0 :     return MapMode();
    2556             : }
    2557             : 
    2558           0 : OutputDevice* SvxDummyTextSource::GetRefDevice() const
    2559             : {
    2560           0 :     return NULL;
    2561             : }
    2562             : 
    2563           0 : sal_Bool SvxDummyTextSource::GetIndexAtPoint( const Point&, sal_uInt16&, sal_uInt16& ) const
    2564             : {
    2565           0 :     return sal_False;
    2566             : }
    2567             : 
    2568           0 : sal_Bool SvxDummyTextSource::GetWordIndices( sal_uInt16, sal_uInt16, sal_uInt16&, sal_uInt16& ) const
    2569             : {
    2570           0 :     return sal_False;
    2571             : }
    2572             : 
    2573           0 : sal_Bool SvxDummyTextSource::GetAttributeRun( sal_uInt16&, sal_uInt16&, sal_uInt16, sal_uInt16 ) const
    2574             : {
    2575           0 :     return sal_False;
    2576             : }
    2577             : 
    2578           0 : sal_uInt16 SvxDummyTextSource::GetLineCount( sal_uInt16 ) const
    2579             : {
    2580           0 :     return 0;
    2581             : }
    2582             : 
    2583           0 : sal_uInt16 SvxDummyTextSource::GetLineLen( sal_uInt16, sal_uInt16 ) const
    2584             : {
    2585           0 :     return 0;
    2586             : }
    2587             : 
    2588           0 : void SvxDummyTextSource::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_uInt16 /*nParagraph*/, sal_uInt16 /*nLine*/ ) const
    2589             : {
    2590           0 :     rStart = rEnd = 0;
    2591           0 : }
    2592             : 
    2593           0 : sal_uInt16 SvxDummyTextSource::GetLineNumberAtIndex( sal_uInt16 /*nPara*/, sal_uInt16 /*nIndex*/ ) const
    2594             : {
    2595           0 :     return 0;
    2596             : }
    2597             : 
    2598           0 : sal_Bool SvxDummyTextSource::QuickFormatDoc( sal_Bool )
    2599             : {
    2600           0 :     return sal_False;
    2601             : }
    2602             : 
    2603           0 : sal_Int16 SvxDummyTextSource::GetDepth( sal_uInt16 ) const
    2604             : {
    2605           0 :     return -1;
    2606             : }
    2607             : 
    2608           0 : sal_Bool SvxDummyTextSource::SetDepth( sal_uInt16, sal_Int16 nNewDepth )
    2609             : {
    2610           0 :     return nNewDepth == 0 ? sal_True : sal_False;
    2611             : }
    2612             : 
    2613           0 : sal_Bool SvxDummyTextSource::Delete( const ESelection& )
    2614             : {
    2615           0 :     return sal_False;
    2616             : }
    2617             : 
    2618           0 : sal_Bool SvxDummyTextSource::InsertText( const String&, const ESelection& )
    2619             : {
    2620           0 :     return sal_False;
    2621             : }
    2622             : 
    2623           0 : const SfxItemSet * SvxDummyTextSource::GetEmptyItemSetPtr()
    2624             : {
    2625           0 :     return 0;
    2626             : }
    2627             : 
    2628           0 : void SvxDummyTextSource::AppendParagraph()
    2629             : {
    2630           0 : }
    2631             : 
    2632           0 : xub_StrLen SvxDummyTextSource::AppendTextPortion( sal_uInt16, const String &, const SfxItemSet & )
    2633             : {
    2634           0 :     return 0;
    2635             : }
    2636             : 
    2637           0 : void  SvxDummyTextSource::CopyText(const SvxTextForwarder& )
    2638             : {
    2639           0 : }
    2640             : 
    2641             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10