LCOV - code coverage report
Current view: top level - libreoffice/editeng/source/uno - unotext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 736 1238 59.5 %
Date: 2012-12-27 Functions: 85 185 45.9 %
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          32 : ESelection toESelection(const text::TextRangeSelection& rSel)
      60             : {
      61          32 :     ESelection aESel;
      62          32 :     aESel.nStartPara = rSel.Start.Paragraph;
      63          32 :     aESel.nStartPos = rSel.Start.PositionInParagraph;
      64          32 :     aESel.nEndPara = rSel.End.Paragraph;
      65          32 :     aESel.nEndPos = rSel.End.PositionInParagraph;
      66          32 :     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        8482 : const SvxItemPropertySet* ImplGetSvxUnoOutlinerTextCursorSvxPropertySet()
      76             : {
      77        8482 :     static SvxItemPropertySet aTextCursorSvxPropertySet( ImplGetSvxUnoOutlinerTextCursorPropertyMap(), EditEngine::GetGlobalItemPool() );
      78        8482 :     return &aTextCursorSvxPropertySet;
      79             : }
      80             : 
      81           6 : const SfxItemPropertyMapEntry* ImplGetSvxTextPortionPropertyMap()
      82             : {
      83             :     // Propertymap for an Outliner Text
      84             :     static const SfxItemPropertyMapEntry aSvxTextPortionPropertyMap[] =
      85             :     {
      86         276 :         SVX_UNOEDIT_CHAR_PROPERTIES,
      87           6 :         SVX_UNOEDIT_FONT_PROPERTIES,
      88          30 :         SVX_UNOEDIT_OUTLINER_PROPERTIES,
      89          84 :         SVX_UNOEDIT_PARA_PROPERTIES,
      90           6 :         {MAP_CHAR_LEN("TextField"),                     EE_FEATURE_FIELD,   &::getCppuType((const uno::Reference< text::XTextField >*)0),   beans::PropertyAttribute::READONLY, 0 },
      91           6 :         {MAP_CHAR_LEN("TextPortionType"),               WID_PORTIONTYPE,    &::getCppuType((const ::rtl::OUString*)0), beans::PropertyAttribute::READONLY, 0 },
      92           6 :         {MAP_CHAR_LEN("TextUserDefinedAttributes"),         EE_CHAR_XMLATTRIBS,     &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0)  ,        0,     0},
      93           6 :         {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         426 :     };
      96           6 :     return aSvxTextPortionPropertyMap;
      97             : }
      98          97 : const SvxItemPropertySet* ImplGetSvxTextPortionSvxPropertySet()
      99             : {
     100          97 :     static SvxItemPropertySet aSvxTextPortionPropertySet( ImplGetSvxTextPortionPropertyMap(), EditEngine::GetGlobalItemPool() );
     101          97 :     return &aSvxTextPortionPropertySet;
     102             : }
     103             : 
     104          14 : const SfxItemPropertySet* ImplGetSvxTextPortionSfxPropertySet()
     105             : {
     106          14 :     static SfxItemPropertySet aSvxTextPortionSfxPropertySet( ImplGetSvxTextPortionPropertyMap() );
     107          14 :     return &aSvxTextPortionSfxPropertySet;
     108             : }
     109             : 
     110          14 : const SfxItemPropertyMapEntry* ImplGetSvxUnoOutlinerTextCursorPropertyMap()
     111             : {
     112             :     // Propertymap for an Outliner Text
     113             :     static const SfxItemPropertyMapEntry aSvxUnoOutlinerTextCursorPropertyMap[] =
     114             :     {
     115         506 :         SVX_UNOEDIT_CHAR_PROPERTIES,
     116          11 :         SVX_UNOEDIT_FONT_PROPERTIES,
     117          55 :         SVX_UNOEDIT_OUTLINER_PROPERTIES,
     118         154 :         SVX_UNOEDIT_PARA_PROPERTIES,
     119          11 :         {MAP_CHAR_LEN("TextUserDefinedAttributes"),         EE_CHAR_XMLATTRIBS,     &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0)  ,        0,     0},
     120          11 :         {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         762 :     };
     123             : 
     124          14 :     return aSvxUnoOutlinerTextCursorPropertyMap;
     125             : }
     126           5 : const SfxItemPropertySet* ImplGetSvxUnoOutlinerTextCursorSfxPropertySet()
     127             : {
     128           5 :     static SfxItemPropertySet aTextCursorSfxPropertySet( ImplGetSvxUnoOutlinerTextCursorPropertyMap() );
     129           5 :     return &aTextCursorSfxPropertySet;
     130             : }
     131             : 
     132             : // ====================================================================
     133             : // helper for Item/Property conversion
     134             : // ====================================================================
     135             : 
     136       20774 : void GetSelection( struct ESelection& rSel, SvxTextForwarder* pForwarder ) throw()
     137             : {
     138             :     DBG_ASSERT( pForwarder, "I need a valid SvxTextForwarder!" );
     139       20774 :     if( pForwarder )
     140             :     {
     141       20774 :         sal_Int16 nParaCount = pForwarder->GetParagraphCount();
     142       20774 :         if(nParaCount>0)
     143       20774 :             nParaCount--;
     144             : 
     145       20774 :         rSel = ESelection( 0,0, nParaCount, pForwarder->GetTextLen( nParaCount ));
     146             :     }
     147       20774 : }
     148             : 
     149       17994 : void CheckSelection( struct ESelection& rSel, SvxTextForwarder* pForwarder ) throw()
     150             : {
     151             :     DBG_ASSERT( pForwarder, "I need a valid SvxTextForwarder!" );
     152       17994 :     if( pForwarder )
     153             :     {
     154       17994 :         if( rSel.nStartPara == 0xffff )
     155             :         {
     156         129 :             ::GetSelection( rSel, pForwarder );
     157             :         }
     158             :         else
     159             :         {
     160       17865 :             ESelection aMaxSelection;
     161       17865 :             GetSelection( aMaxSelection, pForwarder );
     162             : 
     163             :             // check start position
     164       17865 :             if( rSel.nStartPara < aMaxSelection.nStartPara )
     165             :             {
     166           0 :                 rSel.nStartPara = aMaxSelection.nStartPara;
     167           0 :                 rSel.nStartPos = aMaxSelection.nStartPos;
     168             :             }
     169       17865 :             else if( rSel.nStartPara > aMaxSelection.nEndPara )
     170             :             {
     171           0 :                 rSel.nStartPara = aMaxSelection.nEndPara;
     172           0 :                 rSel.nStartPos = aMaxSelection.nEndPos;
     173             :             }
     174       17865 :             else if( rSel.nStartPos  > pForwarder->GetTextLen( rSel.nStartPara ) )
     175             :             {
     176           0 :                 rSel.nStartPos = pForwarder->GetTextLen( rSel.nStartPara );
     177             :             }
     178             : 
     179             :             // check end position
     180       17865 :             if( rSel.nEndPara < aMaxSelection.nStartPara )
     181             :             {
     182           0 :                 rSel.nEndPara = aMaxSelection.nStartPara;
     183           0 :                 rSel.nEndPos = aMaxSelection.nStartPos;
     184             :             }
     185       17865 :             else if( rSel.nEndPara > aMaxSelection.nEndPara )
     186             :             {
     187         216 :                 rSel.nEndPara = aMaxSelection.nEndPara;
     188         216 :                 rSel.nEndPos = aMaxSelection.nEndPos;
     189             :             }
     190       17649 :             else if( rSel.nEndPos > pForwarder->GetTextLen( rSel.nEndPara ) )
     191             :             {
     192          18 :                 rSel.nEndPos = pForwarder->GetTextLen( rSel.nEndPara );
     193             :             }
     194             :         }
     195             :     }
     196       17994 : }
     197             : 
     198        7312 : void CheckSelection( struct ESelection& rSel, SvxEditSource *pEdit ) throw()
     199             : {
     200        7312 :     if (!pEdit)
     201        7312 :         return;
     202        7312 :     CheckSelection( rSel, pEdit->GetTextForwarder() );
     203             : }
     204             : 
     205             : // ====================================================================
     206             : // class SvxUnoTextRangeBase
     207             : // ====================================================================
     208             : 
     209        6252 : UNO3_GETIMPLEMENTATION_IMPL( SvxUnoTextRangeBase );
     210             : 
     211        8482 : SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxItemPropertySet* _pSet ) throw()
     212        8482 : : mpEditSource(NULL) , mpPropSet(_pSet)
     213             : {
     214        8482 : }
     215             : 
     216         745 : SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet ) throw()
     217         745 : : mpPropSet(_pSet)
     218             : {
     219         745 :     SolarMutexGuard aGuard;
     220             : 
     221             :     DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
     222             : 
     223         745 :     mpEditSource = pSource->Clone();
     224         745 :     if (mpEditSource != NULL)
     225             :     {
     226         745 :         ESelection aSelection;
     227         745 :         ::GetSelection( aSelection, mpEditSource->GetTextForwarder() );
     228         745 :         SetSelection( aSelection );
     229             : 
     230         745 :         mpEditSource->addRange( this );
     231         745 :     }
     232         745 : }
     233             : 
     234        1017 : 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        1017 : ,   mpPropSet(rRange.getPropertySet())
     245             : {
     246        1017 :     SolarMutexGuard aGuard;
     247             : 
     248        1017 :     mpEditSource = rRange.mpEditSource ? rRange.mpEditSource->Clone() : NULL;
     249             : 
     250        1017 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     251        1017 :     if( pForwarder )
     252             :     {
     253        1017 :         maSelection  = rRange.maSelection;
     254        1017 :         CheckSelection( maSelection, pForwarder );
     255             :     }
     256             : 
     257        1017 :     if( mpEditSource )
     258        1017 :         mpEditSource->addRange( this );
     259        1017 : }
     260             : 
     261       20486 : SvxUnoTextRangeBase::~SvxUnoTextRangeBase() throw()
     262             : {
     263       10243 :     if( mpEditSource )
     264       10231 :         mpEditSource->removeRange( this );
     265             : 
     266       10243 :     delete mpEditSource;
     267       10243 : }
     268             : 
     269        8470 : 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        8470 :     mpEditSource = pSource;
     275             : 
     276        8470 :     maSelection.nStartPara = 0xffff;
     277             : 
     278        8470 :     if( mpEditSource )
     279        8470 :         mpEditSource->addRange( this );
     280        8470 : }
     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        3880 : void SvxUnoTextRangeBase::SetSelection( const ESelection& rSelection ) throw()
     300             : {
     301        3880 :     SolarMutexGuard aGuard;
     302             : 
     303        3880 :     maSelection = rSelection;
     304        3880 :     CheckSelection( maSelection, mpEditSource );
     305        3880 : }
     306             : 
     307             : // Interface XTextRange ( XText )
     308             : 
     309         336 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getStart(void)
     310             :     throw( uno::RuntimeException )
     311             : {
     312         336 :     SolarMutexGuard aGuard;
     313             : 
     314         336 :     uno::Reference< text::XTextRange > xRange;
     315             : 
     316         336 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     317         336 :     if( pForwarder )
     318             :     {
     319         336 :         CheckSelection( maSelection, pForwarder );
     320             : 
     321         336 :         SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( getText() );
     322             : 
     323         336 :         if(pText == NULL)
     324           0 :             throw uno::RuntimeException();
     325             : 
     326         336 :         SvxUnoTextRange* pRange = new SvxUnoTextRange( *pText );
     327         336 :         xRange = pRange;
     328             : 
     329         336 :         ESelection aNewSel = maSelection;
     330         336 :         aNewSel.nEndPara = aNewSel.nStartPara;
     331         336 :         aNewSel.nEndPos  = aNewSel.nStartPos;
     332         336 :         pRange->SetSelection( aNewSel );
     333             :     }
     334             : 
     335         336 :     return xRange;
     336             : }
     337             : 
     338           4 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getEnd(void)
     339             :     throw( uno::RuntimeException )
     340             : {
     341           4 :     SolarMutexGuard aGuard;
     342             : 
     343           4 :     uno::Reference< text::XTextRange > xRet;
     344             : 
     345           4 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     346           4 :     if( pForwarder )
     347             :     {
     348           4 :         CheckSelection( maSelection, pForwarder );
     349             : 
     350           4 :         SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( getText() );
     351             : 
     352           4 :         if(pText == NULL)
     353           0 :             throw uno::RuntimeException();
     354             : 
     355           4 :         SvxUnoTextRange* pNew = new SvxUnoTextRange( *pText );
     356           4 :         xRet = pNew;
     357             : 
     358           4 :         ESelection aNewSel = maSelection;
     359           4 :         aNewSel.nStartPara = aNewSel.nEndPara;
     360           4 :         aNewSel.nStartPos  = aNewSel.nEndPos;
     361           4 :         pNew->SetSelection( aNewSel );
     362             :     }
     363           4 :     return xRet;
     364             : }
     365             : 
     366          95 : OUString SAL_CALL SvxUnoTextRangeBase::getString(void)
     367             :     throw( uno::RuntimeException )
     368             : {
     369          95 :     SolarMutexGuard aGuard;
     370             : 
     371          95 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     372          95 :     if( pForwarder )
     373             :     {
     374          95 :         CheckSelection( maSelection, pForwarder );
     375             : 
     376          95 :         return pForwarder->GetText( maSelection );
     377             :     }
     378             :     else
     379             :     {
     380           0 :         const OUString aEmpty;
     381           0 :         return aEmpty;
     382          95 :     }
     383             : }
     384             : 
     385        1744 : void SAL_CALL SvxUnoTextRangeBase::setString(const OUString& aString)
     386             :     throw( uno::RuntimeException )
     387             : {
     388        1744 :     SolarMutexGuard aGuard;
     389             : 
     390        1744 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     391        1744 :     if( pForwarder )
     392             :     {
     393        1744 :         CheckSelection( maSelection, pForwarder );
     394             : 
     395        1744 :         String aConverted(convertLineEnd(aString, LINEEND_LF));  // Simply count the number of line endings
     396             : 
     397        1744 :         pForwarder->QuickInsertText( aConverted, maSelection );
     398        1744 :         mpEditSource->UpdateData();
     399             : 
     400             :         //  Adapt selection
     401             :         //! It would be easier if the EditEngine would return the selection
     402             :         //! on QuickInsertText...
     403        1744 :         CollapseToStart();
     404             : 
     405        1744 :         sal_uInt16 nLen = aConverted.Len();
     406        1744 :         if (nLen)
     407        1478 :             GoRight( nLen, sal_True );
     408        1744 :     }
     409        1744 : }
     410             : 
     411             : // Interface beans::XPropertySet
     412         941 : uno::Reference< beans::XPropertySetInfo > SAL_CALL SvxUnoTextRangeBase::getPropertySetInfo(void)
     413             :     throw( uno::RuntimeException )
     414             : {
     415         941 :     return mpPropSet->getPropertySetInfo();
     416             : }
     417             : 
     418         466 : 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         466 :     if (PropertyName == UNO_TR_PROP_SELECTION)
     422             :     {
     423          16 :         text::TextRangeSelection aSel = aValue.get<text::TextRangeSelection>();
     424          16 :         SetSelection(toESelection(aSel));
     425             : 
     426         464 :         return;
     427             :     }
     428             : 
     429         450 :     _setPropertyValue( PropertyName, aValue, -1 );
     430             : }
     431             : 
     432         450 : 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         450 :     SolarMutexGuard aGuard;
     436             : 
     437         450 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     438         450 :     if( pForwarder )
     439             :     {
     440         450 :         CheckSelection( maSelection, pForwarder );
     441             : 
     442         450 :         const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName );
     443         450 :         if ( pMap )
     444             :         {
     445         448 :             ESelection aSel( GetSelection() );
     446         448 :             sal_Bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END );
     447             : 
     448         448 :             if( nPara == -1 && !bParaAttrib )
     449             :             {
     450          56 :                 SfxItemSet aOldSet( pForwarder->GetAttribs( aSel ) );
     451             :                 // we have a selection and no para attribute
     452          56 :                 SfxItemSet aNewSet( *aOldSet.GetPool(), aOldSet.GetRanges() );
     453             : 
     454          56 :                 setPropertyValue( pMap, aValue, maSelection, aOldSet, aNewSet );
     455             : 
     456             : 
     457          56 :                 pForwarder->QuickSetAttribs( aNewSet, GetSelection() );
     458             :             }
     459             :             else
     460             :             {
     461             :                 sal_Int32 nEndPara;
     462             : 
     463         392 :                 if( nPara == -1 )
     464             :                 {
     465         392 :                     nPara = aSel.nStartPara;
     466         392 :                     nEndPara = aSel.nEndPara;
     467             :                 }
     468             :                 else
     469             :                 {
     470             :                     // only one paragraph
     471           0 :                     nEndPara = nPara;
     472             :                 }
     473             : 
     474        1176 :                 while( nPara <= nEndPara )
     475             :                 {
     476             :                     // we have a paragraph
     477         392 :                     SfxItemSet aSet( pForwarder->GetParaAttribs( (sal_uInt16)nPara ) );
     478         392 :                     setPropertyValue( pMap, aValue, maSelection, aSet, aSet );
     479         392 :                     pForwarder->SetParaAttribs( (sal_uInt16)nPara, aSet );
     480         392 :                     nPara++;
     481         392 :                 }
     482             :             }
     483             : 
     484         448 :             GetEditSource()->UpdateData();
     485         448 :             return;
     486             :         }
     487             :     }
     488             : 
     489         448 :     throw beans::UnknownPropertyException();
     490             : }
     491             : 
     492        2688 : 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        2688 :     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        2344 :         rNewSet.Put(rOldSet.Get(pMap->nWID));  // Old Item in new Set
     499        2344 :         mpPropSet->setPropertyValue(pMap, rValue, rNewSet, false );
     500             :     }
     501        2688 : }
     502             : 
     503       66474 : sal_Bool SvxUnoTextRangeBase::SetPropertyValueHelper( const SfxItemSet&, const SfxItemPropertySimpleEntry* pMap, const uno::Any& aValue, SfxItemSet& rNewSet, const ESelection* pSelection /* = NULL */, SvxEditSource* pEditSource /* = NULL*/ )
     504             : {
     505       66474 :     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         274 :             uno::Reference< container::XIndexReplace > xRule;
     521         274 :             if( !aValue.hasValue() || ((aValue >>= xRule) && !xRule.is()) )
     522         229 :                 return sal_True;
     523             : 
     524          45 :             return sal_False;
     525             :         }
     526             : 
     527             :     case WID_NUMLEVEL:
     528             :         {
     529          74 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     530          74 :             if(pForwarder && pSelection)
     531             :             {
     532          74 :                 sal_Int16 nLevel = sal_Int16();
     533          74 :                 if( aValue >>= nLevel )
     534             :                 {
     535             :                     // #101004# Call interface method instead of unsafe cast
     536          74 :                     if(! pForwarder->SetDepth( pSelection->nStartPara, nLevel ) )
     537           0 :                         throw lang::IllegalArgumentException();
     538             : 
     539          74 :                     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          86 :             sal_Bool bBullet = sal_True;
     575          86 :             if( aValue >>= bBullet )
     576             :             {
     577          86 :                 SfxBoolItem aItem( EE_PARA_BULLETSTATE, bBullet );
     578          86 :                 rNewSet.Put(aItem);
     579          86 :                 return sal_True;
     580             :             }
     581             :         }
     582           0 :         break;
     583             : 
     584             :     default:
     585       66040 :         return sal_False;
     586             :     }
     587             : 
     588           0 :     throw lang::IllegalArgumentException();
     589             : }
     590             : 
     591         417 : uno::Any SAL_CALL SvxUnoTextRangeBase::getPropertyValue(const OUString& PropertyName)
     592             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
     593             : {
     594         417 :     if (PropertyName == UNO_TR_PROP_SELECTION)
     595             :     {
     596          16 :         const ESelection& rSel = GetSelection();
     597          16 :         text::TextRangeSelection aSel;
     598          16 :         aSel.Start.Paragraph = static_cast<sal_Int32>(rSel.nStartPara);
     599          16 :         aSel.Start.PositionInParagraph = static_cast<sal_Int32>(rSel.nStartPos);
     600          16 :         aSel.End.Paragraph = static_cast<sal_Int32>(rSel.nEndPara);
     601          16 :         aSel.End.PositionInParagraph = static_cast<sal_Int32>(rSel.nEndPos);
     602          16 :         return uno::makeAny(aSel);
     603             :     }
     604             : 
     605         401 :     return _getPropertyValue( PropertyName, -1 );
     606             : }
     607             : 
     608         404 : uno::Any SAL_CALL SvxUnoTextRangeBase::_getPropertyValue(const OUString& PropertyName, sal_Int32 nPara )
     609             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
     610             : {
     611         404 :     SolarMutexGuard aGuard;
     612             : 
     613         404 :     uno::Any aAny;
     614             : 
     615         404 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     616         404 :     if( pForwarder )
     617             :     {
     618         404 :         const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName );
     619         404 :         if( pMap )
     620             :         {
     621         402 :             SfxItemSet* pAttribs = NULL;
     622         402 :             if( nPara != -1 )
     623           3 :                 pAttribs = pForwarder->GetParaAttribs( (sal_uInt16)nPara ).Clone();
     624             :             else
     625         399 :                 pAttribs = pForwarder->GetAttribs( GetSelection() ).Clone();
     626             : 
     627             :             //  Replace Dontcare with Default, so that one always has a mirror
     628         402 :             pAttribs->ClearInvalidItems();
     629             : 
     630         402 :             getPropertyValue( pMap, aAny, *pAttribs );
     631             : 
     632         402 :             delete pAttribs;
     633         402 :             return aAny;
     634             :         }
     635             :     }
     636             : 
     637           2 :     throw beans::UnknownPropertyException();
     638             : }
     639             : 
     640         403 : void SvxUnoTextRangeBase::getPropertyValue( const SfxItemPropertySimpleEntry* pMap, uno::Any& rAny, const SfxItemSet& rSet ) throw( beans::UnknownPropertyException )
     641             : {
     642         403 :     switch( pMap->nWID )
     643             :     {
     644             :     case EE_FEATURE_FIELD:
     645          32 :         if ( rSet.GetItemState( EE_FEATURE_FIELD, sal_False ) == SFX_ITEM_SET )
     646             :         {
     647          32 :             SvxFieldItem* pItem = (SvxFieldItem*)rSet.GetItem( EE_FEATURE_FIELD );
     648          32 :             const SvxFieldData* pData = pItem->GetField();
     649          32 :             uno::Reference< text::XTextRange > xAnchor( this );
     650             : 
     651             :             // get presentation string for field
     652          32 :             Color* pTColor = NULL;
     653          32 :             Color* pFColor = NULL;
     654             : 
     655          32 :             SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder();
     656          32 :             OUString aPresentation( pForwarder->CalcFieldValue( SvxFieldItem(*pData, EE_FEATURE_FIELD), maSelection.nStartPara, maSelection.nStartPos, pTColor, pFColor ) );
     657             : 
     658          32 :             delete pTColor;
     659          32 :             delete pFColor;
     660             : 
     661          32 :             uno::Reference< text::XTextField > xField( new SvxUnoTextField( xAnchor, aPresentation, pData ) );
     662          32 :             rAny <<= xField;
     663             :         }
     664          32 :         break;
     665             : 
     666             :     case WID_PORTIONTYPE:
     667          97 :         if ( rSet.GetItemState( EE_FEATURE_FIELD, sal_False ) == SFX_ITEM_SET )
     668             :         {
     669          32 :             OUString aType( RTL_CONSTASCII_USTRINGPARAM("TextField") );
     670          32 :             rAny <<= aType;
     671             :         }
     672             :         else
     673             :         {
     674          65 :             OUString aType( RTL_CONSTASCII_USTRINGPARAM("Text") );
     675          65 :             rAny <<= aType;
     676             :         }
     677          97 :         break;
     678             : 
     679             :     default:
     680         274 :         if(!GetPropertyValueHelper( *((SfxItemSet*)(&rSet)), pMap, rAny, &maSelection, GetEditSource() ))
     681           1 :             rAny = mpPropSet->getPropertyValue(pMap, rSet, true, false );
     682             :     }
     683         403 : }
     684             : 
     685        5074 : 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        5074 :     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         272 :             if((rSet.GetItemState( EE_PARA_NUMBULLET, sal_True ) & (SFX_ITEM_SET|SFX_ITEM_DEFAULT)) == 0)
     701           0 :                 throw uno::RuntimeException();
     702             : 
     703         272 :             SvxNumBulletItem* pBulletItem = (SvxNumBulletItem*)rSet.GetItem( EE_PARA_NUMBULLET, sal_True );
     704             : 
     705         272 :             if( pBulletItem == NULL )
     706           0 :                 throw uno::RuntimeException();
     707             : 
     708         272 :             aAny <<= SvxCreateNumRule( pBulletItem->GetNumRule() );
     709             :         }
     710         272 :         break;
     711             : 
     712             :     case WID_NUMLEVEL:
     713             :         {
     714           1 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     715           1 :             if(pForwarder && pSelection)
     716             :             {
     717           1 :                 sal_Int16 nLevel = pForwarder->GetDepth( pSelection->nStartPara );
     718           1 :                 if( nLevel >= 0 )
     719           1 :                     aAny <<= nLevel;
     720             :             }
     721             :         }
     722           1 :         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        4801 :         return sal_False;
     753             :     }
     754             : 
     755         273 :     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           0 : 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         214 : 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         214 :     _setPropertyValues( aPropertyNames, aValues, -1 );
     768         214 : }
     769             : 
     770         214 : 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         214 :     SolarMutexGuard aGuard;
     773             : 
     774         214 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     775         214 :     if( pForwarder )
     776             :     {
     777         214 :         CheckSelection( maSelection, pForwarder );
     778             : 
     779         214 :         ESelection aSel( GetSelection() );
     780             : 
     781         214 :         const OUString* pPropertyNames = aPropertyNames.getConstArray();
     782         214 :         const uno::Any* pValues = aValues.getConstArray();
     783         214 :         sal_Int32 nCount = aPropertyNames.getLength();
     784             : 
     785         214 :         sal_Int32 nEndPara = nPara;
     786         214 :         sal_Int32 nTempPara = nPara;
     787             : 
     788         214 :         if( nTempPara == -1 )
     789             :         {
     790         214 :             nTempPara = aSel.nStartPara;
     791         214 :             nEndPara = aSel.nEndPara;
     792             :         }
     793             : 
     794         214 :         SfxItemSet* pOldAttrSet = NULL;
     795         214 :         SfxItemSet* pNewAttrSet = NULL;
     796             : 
     797         214 :         SfxItemSet* pOldParaSet = NULL;
     798         214 :         SfxItemSet* pNewParaSet = NULL;
     799             : 
     800        2552 :         for( ; nCount; nCount--, pPropertyNames++, pValues++ )
     801             :         {
     802        2338 :             const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames );
     803             : 
     804        2338 :             if( pMap )
     805             :             {
     806        2240 :                 sal_Bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END );
     807             : 
     808        2240 :                 if( (nPara == -1) && !bParaAttrib )
     809             :                 {
     810        1982 :                     if( NULL == pNewAttrSet )
     811             :                     {
     812         207 :                         const SfxItemSet aSet( pForwarder->GetAttribs( aSel ) );
     813         207 :                         pOldAttrSet = new SfxItemSet( aSet );
     814         207 :                         pNewAttrSet = new SfxItemSet( *pOldAttrSet->GetPool(), pOldAttrSet->GetRanges() );
     815             :                     }
     816             : 
     817        1982 :                     setPropertyValue( pMap, *pValues, GetSelection(), *pOldAttrSet, *pNewAttrSet );
     818             : 
     819        1982 :                     if( pMap->nWID >= EE_ITEMS_START && pMap->nWID <= EE_ITEMS_END )
     820             :                     {
     821             :                         const SfxPoolItem* pItem;
     822        1941 :                         if( pNewAttrSet->GetItemState( pMap->nWID, sal_True, &pItem ) == SFX_ITEM_SET )
     823             :                         {
     824        1941 :                             pOldAttrSet->Put( *pItem );
     825             :                         }
     826        1982 :                     }
     827             :                 }
     828             :                 else
     829             :                 {
     830         258 :                     if( NULL == pNewParaSet )
     831             :                     {
     832          71 :                         const SfxItemSet aSet( pForwarder->GetParaAttribs( (sal_uInt16)nTempPara ) );
     833          71 :                         pOldParaSet = new SfxItemSet( aSet );
     834          71 :                         pNewParaSet = new SfxItemSet( *pOldParaSet->GetPool(), pOldParaSet->GetRanges() );
     835             :                     }
     836             : 
     837         258 :                     setPropertyValue( pMap, *pValues, GetSelection(), *pOldParaSet, *pNewParaSet );
     838             : 
     839         258 :                     if( pMap->nWID >= EE_ITEMS_START && pMap->nWID <= EE_ITEMS_END )
     840             :                     {
     841             :                         const SfxPoolItem* pItem;
     842         258 :                         if( pNewParaSet->GetItemState( pMap->nWID, sal_True, &pItem ) == SFX_ITEM_SET )
     843             :                         {
     844         258 :                             pOldParaSet->Put( *pItem );
     845             :                         }
     846             :                     }
     847             : 
     848             :                 }
     849             :             }
     850             :         }
     851             : 
     852         214 :         sal_Bool bNeedsUpdate = sal_False;
     853             : 
     854         214 :         if( pNewParaSet )
     855             :         {
     856          71 :             if( pNewParaSet->Count() )
     857             :             {
     858         213 :                 while( nTempPara <= nEndPara )
     859             :                 {
     860          71 :                     SfxItemSet aSet( pForwarder->GetParaAttribs( (sal_uInt16)nTempPara ) );
     861          71 :                     aSet.Put( *pNewParaSet );
     862          71 :                     pForwarder->SetParaAttribs( (sal_uInt16)nTempPara, aSet );
     863          71 :                     nTempPara++;
     864          71 :                 }
     865          71 :                 bNeedsUpdate = sal_True;
     866             :             }
     867             : 
     868          71 :             delete pNewParaSet;
     869          71 :             delete pOldParaSet;
     870             :         }
     871             : 
     872         214 :         if( pNewAttrSet )
     873             :         {
     874         207 :             if( pNewAttrSet->Count() )
     875             :             {
     876         166 :                 pForwarder->QuickSetAttribs( *pNewAttrSet, GetSelection() );
     877         166 :                 bNeedsUpdate = sal_True;
     878             :             }
     879         207 :             delete pNewAttrSet;
     880         207 :             delete pOldAttrSet;
     881             : 
     882             :         }
     883             : 
     884         214 :         if( bNeedsUpdate )
     885         214 :             GetEditSource()->UpdateData();
     886         214 :     }
     887         214 : }
     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           1 : uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::_getPropertyValues( const uno::Sequence< ::rtl::OUString >& aPropertyNames, sal_Int32 nPara ) throw (uno::RuntimeException)
     895             : {
     896           1 :     SolarMutexGuard aGuard;
     897             : 
     898           1 :     sal_Int32 nCount = aPropertyNames.getLength();
     899             : 
     900             : 
     901           1 :     uno::Sequence< uno::Any > aValues( nCount );
     902             : 
     903           1 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     904           1 :     if( pForwarder )
     905             :     {
     906           1 :         SfxItemSet* pAttribs = NULL;
     907           1 :         if( nPara != -1 )
     908           1 :             pAttribs = pForwarder->GetParaAttribs( (sal_uInt16)nPara ).Clone();
     909             :         else
     910           0 :             pAttribs = pForwarder->GetAttribs( GetSelection() ).Clone();
     911             : 
     912           1 :         pAttribs->ClearInvalidItems();
     913             : 
     914           1 :         const OUString* pPropertyNames = aPropertyNames.getConstArray();
     915           1 :         uno::Any* pValues = aValues.getArray();
     916             : 
     917           2 :         for( ; nCount; nCount--, pPropertyNames++, pValues++ )
     918             :         {
     919           1 :             const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames );
     920           1 :             if( pMap )
     921             :             {
     922           1 :                 getPropertyValue( pMap, *pValues, *pAttribs );
     923             :             }
     924             :         }
     925             : 
     926           1 :         delete pAttribs;
     927             : 
     928             :     }
     929             : 
     930           1 :     return aValues;
     931             : }
     932             : 
     933           0 : void SAL_CALL SvxUnoTextRangeBase::addPropertiesChangeListener( const uno::Sequence< ::rtl::OUString >& , const uno::Reference< beans::XPropertiesChangeListener >& ) throw (uno::RuntimeException)
     934             : {
     935           0 : }
     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          97 : uno::Sequence< beans::PropertyState > SAL_CALL SvxUnoTextRangeBase::getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
    1056             :     throw(beans::UnknownPropertyException, uno::RuntimeException)
    1057             : {
    1058          97 :     return _getPropertyStates( aPropertyName, -1 );
    1059             : }
    1060             : 
    1061          99 : uno::Sequence< beans::PropertyState > SvxUnoTextRangeBase::_getPropertyStates(const uno::Sequence< OUString >& PropertyName, sal_Int32 nPara /* = -1 */)
    1062             :     throw( beans::UnknownPropertyException, uno::RuntimeException )
    1063             : {
    1064          99 :     const sal_Int32 nCount = PropertyName.getLength();
    1065          99 :     const OUString* pNames = PropertyName.getConstArray();
    1066             : 
    1067          99 :     uno::Sequence< beans::PropertyState > aRet( nCount );
    1068          99 :     beans::PropertyState* pState = aRet.getArray();
    1069             : 
    1070          99 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1071          99 :     if( pForwarder )
    1072             :     {
    1073          99 :         SfxItemSet* pSet = NULL;
    1074          99 :         if( nPara != -1 )
    1075             :         {
    1076           2 :             pSet = new SfxItemSet( pForwarder->GetParaAttribs( (sal_uInt16)nPara ) );
    1077             :         }
    1078             :         else
    1079             :         {
    1080          97 :             ESelection aSel( GetSelection() );
    1081          97 :             CheckSelection( aSel, pForwarder );
    1082          97 :             pSet = new SfxItemSet( pForwarder->GetAttribs( aSel, EditEngineAttribs_OnlyHard ) );
    1083             :         }
    1084             : 
    1085          99 :         sal_Bool bUnknownPropertyFound = sal_False;
    1086        4972 :         for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
    1087             :         {
    1088        4873 :             const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( *pNames++ );
    1089        4873 :             if( NULL == pMap )
    1090             :             {
    1091           0 :                 bUnknownPropertyFound = sal_True;
    1092           0 :                 break;
    1093             :             }
    1094        4873 :             bUnknownPropertyFound = !_getOnePropertyStates(pSet, pMap, *pState++);
    1095             :         }
    1096             : 
    1097          99 :         delete pSet;
    1098             : 
    1099          99 :         if( bUnknownPropertyFound )
    1100           0 :             throw beans::UnknownPropertyException();
    1101             :     }
    1102             : 
    1103          99 :     return aRet;
    1104             : }
    1105             : 
    1106        4873 : sal_Bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const SfxItemPropertySimpleEntry* pMap, beans::PropertyState& rState)
    1107             : {
    1108        4873 :     sal_Bool bUnknownPropertyFound = sal_False;
    1109        4873 :     if(pSet && pMap)
    1110             :     {
    1111        4873 :         SfxItemState eItemState = SFX_ITEM_UNKNOWN;
    1112        4873 :         sal_uInt16 nWID = 0;
    1113             : 
    1114        4873 :         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        4873 :                 nWID = pMap->nWID;
    1165             :         }
    1166             : 
    1167        4873 :         if( bUnknownPropertyFound )
    1168           0 :             return !bUnknownPropertyFound;
    1169             : 
    1170        4873 :         if( nWID != 0 )
    1171        4873 :             eItemState = pSet->GetItemState( nWID, sal_False );
    1172             : 
    1173        4873 :         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        4873 :                     rState = beans::PropertyState_DEFAULT_VALUE;
    1181        4873 :                     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        4873 :     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        1744 : void SvxUnoTextRangeBase::CollapseToStart(void) throw()
    1351             : {
    1352        1744 :     CheckSelection( maSelection, mpEditSource );
    1353             : 
    1354        1744 :     maSelection.nEndPara = maSelection.nStartPara;
    1355        1744 :     maSelection.nEndPos  = maSelection.nStartPos;
    1356        1744 : }
    1357             : 
    1358         995 : void SvxUnoTextRangeBase::CollapseToEnd(void) throw()
    1359             : {
    1360         995 :     CheckSelection( maSelection, mpEditSource );
    1361             : 
    1362         995 :     maSelection.nStartPara = maSelection.nEndPara;
    1363         995 :     maSelection.nStartPos  = maSelection.nEndPos;
    1364         995 : }
    1365             : 
    1366          62 : sal_Bool SvxUnoTextRangeBase::IsCollapsed(void) throw()
    1367             : {
    1368          62 :     CheckSelection( maSelection, mpEditSource );
    1369             : 
    1370             :     return ( maSelection.nStartPara == maSelection.nEndPara &&
    1371          62 :              maSelection.nStartPos  == maSelection.nEndPos );
    1372             : }
    1373             : 
    1374         246 : sal_Bool SvxUnoTextRangeBase::GoLeft(sal_Int16 nCount, sal_Bool Expand) throw()
    1375             : {
    1376         246 :     CheckSelection( maSelection, mpEditSource );
    1377             : 
    1378             :     //  #75098# use end position, as in Writer (start is anchor, end is cursor)
    1379         246 :     sal_uInt16 nNewPos = maSelection.nEndPos;
    1380         246 :     sal_uInt16 nNewPar = maSelection.nEndPara;
    1381             : 
    1382         246 :     sal_Bool bOk = sal_True;
    1383         246 :     SvxTextForwarder* pForwarder = NULL;
    1384         738 :     while ( nCount > nNewPos && bOk )
    1385             :     {
    1386         246 :         if ( nNewPar == 0 )
    1387          30 :             bOk = sal_False;
    1388             :         else
    1389             :         {
    1390         216 :             if ( !pForwarder )
    1391         216 :                 pForwarder = mpEditSource->GetTextForwarder();  // first here, it it is necessary...
    1392             : 
    1393         216 :             --nNewPar;
    1394         216 :             nCount -= nNewPos + 1;
    1395         216 :             nNewPos = pForwarder->GetTextLen( nNewPar );
    1396             :         }
    1397             :     }
    1398             : 
    1399         246 :     if ( bOk )
    1400             :     {
    1401         216 :         nNewPos = nNewPos - nCount;
    1402         216 :         maSelection.nStartPara = nNewPar;
    1403         216 :         maSelection.nStartPos  = nNewPos;
    1404             :     }
    1405             : 
    1406         246 :     if (!Expand)
    1407           0 :         CollapseToStart();
    1408             : 
    1409         246 :     return bOk;
    1410             : }
    1411             : 
    1412        1478 : sal_Bool SvxUnoTextRangeBase::GoRight(sal_Int16 nCount, sal_Bool Expand)  throw()
    1413             : {
    1414        1478 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1415        1478 :     if( pForwarder )
    1416             :     {
    1417        1478 :         CheckSelection( maSelection, pForwarder );
    1418             : 
    1419        1478 :         sal_uInt16 nNewPos = maSelection.nEndPos + nCount; //! Overflow???
    1420        1478 :         sal_uInt16 nNewPar = maSelection.nEndPara;
    1421             : 
    1422        1478 :         sal_Bool bOk = sal_True;
    1423        1478 :         sal_uInt16 nParCount = pForwarder->GetParagraphCount();
    1424        1478 :         sal_uInt16 nThisLen = pForwarder->GetTextLen( nNewPar );
    1425        3204 :         while ( nNewPos > nThisLen && bOk )
    1426             :         {
    1427         248 :             if ( nNewPar + 1 >= nParCount )
    1428           0 :                 bOk = sal_False;
    1429             :             else
    1430             :             {
    1431         248 :                 nNewPos -= nThisLen+1;
    1432         248 :                 ++nNewPar;
    1433         248 :                 nThisLen = pForwarder->GetTextLen( nNewPar );
    1434             :             }
    1435             :         }
    1436             : 
    1437        1478 :         if (bOk)
    1438             :         {
    1439        1478 :             maSelection.nEndPara = nNewPar;
    1440        1478 :             maSelection.nEndPos  = nNewPos;
    1441             :         }
    1442             : 
    1443        1478 :         if (!Expand)
    1444           0 :             CollapseToEnd();
    1445             : 
    1446        1478 :         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         385 : void SvxUnoTextRangeBase::GotoEnd(sal_Bool Expand) throw()
    1461             : {
    1462         385 :     CheckSelection( maSelection, mpEditSource );
    1463             : 
    1464         385 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1465         385 :     if( pForwarder )
    1466             :     {
    1467             : 
    1468         385 :         sal_uInt16 nPar = pForwarder->GetParagraphCount();
    1469         385 :         if (nPar)
    1470         385 :             --nPar;
    1471             : 
    1472         385 :         maSelection.nEndPara = nPar;
    1473         385 :         maSelection.nEndPos  = pForwarder->GetTextLen( nPar );
    1474             : 
    1475         385 :         if (!Expand)
    1476         269 :             CollapseToEnd();
    1477             :     }
    1478         385 : }
    1479             : 
    1480             : // lang::XServiceInfo
    1481          61 : sal_Bool SAL_CALL SvxUnoTextRangeBase::supportsService( const OUString& ServiceName )
    1482             :     throw(uno::RuntimeException)
    1483             : {
    1484          61 :     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
    1485             : }
    1486             : 
    1487          61 : uno::Sequence< OUString > SAL_CALL SvxUnoTextRangeBase::getSupportedServiceNames()
    1488             :     throw(uno::RuntimeException)
    1489             : {
    1490          61 :     return getSupportedServiceNames_Static();
    1491             : }
    1492             : 
    1493          61 : uno::Sequence< OUString > SAL_CALL SvxUnoTextRangeBase::getSupportedServiceNames_Static()
    1494             :     SAL_THROW(())
    1495             : {
    1496          61 :     uno::Sequence< OUString >   aSeq;
    1497             :     comphelper::ServiceInfoHelper::addToSequence( aSeq, 3, "com.sun.star.style.CharacterProperties",
    1498             :                                                   "com.sun.star.style.CharacterPropertiesComplex",
    1499          61 :                                                   "com.sun.star.style.CharacterPropertiesAsian");
    1500          61 :     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         451 : SvxUnoTextRange::SvxUnoTextRange( const SvxUnoTextBase& rParent, sal_Bool bPortion /* = sal_False */ ) throw()
    1568         805 : :SvxUnoTextRangeBase( rParent.GetEditSource(), bPortion ? ImplGetSvxTextPortionSvxPropertySet() : rParent.getPropertySet() ),
    1569        1256 :  mbPortion( bPortion )
    1570             : {
    1571         451 :     xParentText =  (text::XText*)&rParent;
    1572         451 : }
    1573             : 
    1574         902 : SvxUnoTextRange::~SvxUnoTextRange() throw()
    1575             : {
    1576         902 : }
    1577             : 
    1578        1051 : uno::Any SAL_CALL SvxUnoTextRange::queryAggregation( const uno::Type & rType )
    1579             :     throw(uno::RuntimeException)
    1580             : {
    1581        1051 :     QUERYINT( text::XTextRange );
    1582         954 :     else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertyStates >*)0) )
    1583           0 :         return uno::makeAny(uno::Reference< beans::XMultiPropertyStates >(this));
    1584         954 :     else if( rType == ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) )
    1585         229 :         return uno::makeAny(uno::Reference< beans::XPropertySet >(this));
    1586         725 :     else QUERYINT( beans::XPropertyState );
    1587         628 :     else QUERYINT( text::XTextRangeCompare );
    1588         628 :     else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0) )
    1589          98 :         return uno::makeAny(uno::Reference< beans::XMultiPropertySet >(this));
    1590         530 :     else QUERYINT( lang::XServiceInfo );
    1591         530 :     else QUERYINT( lang::XTypeProvider );
    1592         433 :     else QUERYINT( lang::XUnoTunnel );
    1593             :     else
    1594          97 :         return OWeakAggObject::queryAggregation( rType );
    1595             : }
    1596             : 
    1597        1051 : uno::Any SAL_CALL SvxUnoTextRange::queryInterface( const uno::Type & rType )
    1598             :     throw(uno::RuntimeException)
    1599             : {
    1600        1051 :     return OWeakAggObject::queryInterface(rType);
    1601             : }
    1602             : 
    1603        2959 : void SAL_CALL SvxUnoTextRange::acquire()
    1604             :     throw( )
    1605             : {
    1606        2959 :     OWeakAggObject::acquire();
    1607        2959 : }
    1608             : 
    1609        2959 : void SAL_CALL SvxUnoTextRange::release()
    1610             :     throw( )
    1611             : {
    1612        2959 :     OWeakAggObject::release();
    1613        2959 : }
    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          97 : uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextRange::getImplementationId()
    1656             :     throw (uno::RuntimeException)
    1657             : {
    1658          97 :     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        8482 : SvxUnoTextBase::SvxUnoTextBase( const SvxItemPropertySet* _pSet  ) throw()
    1686        8482 : : SvxUnoTextRangeBase( _pSet )
    1687             : {
    1688        8482 : }
    1689             : 
    1690         294 : SvxUnoTextBase::SvxUnoTextBase( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet, uno::Reference < text::XText > xParent ) throw()
    1691         294 : : SvxUnoTextRangeBase( pSource, _pSet )
    1692             : {
    1693         294 :     xParentText = xParent;
    1694         294 :     ESelection aSelection;
    1695         294 :     ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
    1696         294 :     SetSelection( aSelection );
    1697         294 : }
    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        8775 : SvxUnoTextBase::~SvxUnoTextBase() throw()
    1711             : {
    1712        8775 : }
    1713             : 
    1714             : // XInterface
    1715        5194 : uno::Any SAL_CALL SvxUnoTextBase::queryAggregation( const uno::Type & rType )
    1716             :     throw(uno::RuntimeException)
    1717             : {
    1718        5194 :     QUERYINT( text::XText );
    1719        4985 :     QUERYINT( text::XSimpleText );
    1720        4981 :     if( rType == ::getCppuType((const uno::Reference< text::XTextRange >*)0) )
    1721         937 :         return uno::makeAny(uno::Reference< text::XTextRange >((text::XText*)(this)));
    1722        4044 :     QUERYINT(container::XEnumerationAccess );
    1723        4036 :     QUERYINT( container::XElementAccess );
    1724        4036 :     QUERYINT( beans::XMultiPropertyStates );
    1725        4036 :     QUERYINT( beans::XPropertySet );
    1726        2117 :     QUERYINT( beans::XMultiPropertySet );
    1727        2101 :     QUERYINT( beans::XPropertyState );
    1728        2101 :     QUERYINT( text::XTextRangeCompare );
    1729        2101 :     QUERYINT( lang::XServiceInfo );
    1730        2101 :     QUERYINT( text::XTextRangeMover );
    1731        2101 :     QUERYINT( text::XTextCopy );
    1732        2101 :     QUERYINT( text::XTextAppend );
    1733        2063 :     QUERYINT( text::XParagraphAppend );
    1734        2063 :     QUERYINT( text::XTextPortionAppend );
    1735        2063 :     QUERYINT( lang::XTypeProvider );
    1736        2063 :     QUERYINT( lang::XUnoTunnel );
    1737             : 
    1738        2055 :     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         224 : uno::Reference< text::XTextCursor > SvxUnoTextBase::createTextCursorBySelection( const ESelection& rSel )
    1798             : {
    1799         224 :     SvxUnoTextCursor* pCursor = new SvxUnoTextCursor( *this );
    1800         224 :     uno::Reference< text::XTextCursor >  xCursor( pCursor );
    1801         224 :     pCursor->SetSelection( rSel );
    1802         224 :     return xCursor;
    1803             : }
    1804             : 
    1805             : // XSimpleText
    1806             : 
    1807         149 : uno::Reference< text::XTextCursor > SAL_CALL SvxUnoTextBase::createTextCursor()
    1808             :     throw(uno::RuntimeException)
    1809             : {
    1810         149 :     SolarMutexGuard aGuard;
    1811         149 :     return new SvxUnoTextCursor( *this );
    1812             : }
    1813             : 
    1814         224 : uno::Reference< text::XTextCursor > SAL_CALL SvxUnoTextBase::createTextCursorByRange( const uno::Reference< text::XTextRange >& aTextPosition )
    1815             :     throw(uno::RuntimeException)
    1816             : {
    1817         224 :     SolarMutexGuard aGuard;
    1818             : 
    1819         224 :     uno::Reference< text::XTextCursor >  xCursor;
    1820             : 
    1821         224 :     if( aTextPosition.is() )
    1822             :     {
    1823         224 :         SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
    1824         224 :         if(pRange)
    1825         224 :             xCursor = createTextCursorBySelection( pRange->GetSelection() );
    1826             :     }
    1827             : 
    1828         224 :     return xCursor;
    1829             : }
    1830             : 
    1831         419 : void SAL_CALL SvxUnoTextBase::insertString( const uno::Reference< text::XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb )
    1832             :     throw(uno::RuntimeException)
    1833             : {
    1834         419 :     SolarMutexGuard aGuard;
    1835             : 
    1836         419 :     if( !xRange.is() )
    1837         419 :         return;
    1838             : 
    1839         419 :     ESelection aSelection;
    1840         419 :     if (GetEditSource())
    1841             :     {
    1842         419 :         ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
    1843         419 :         SetSelection( aSelection );
    1844             :     }
    1845             : 
    1846         419 :     SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange );
    1847         419 :     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         419 :         if (!bAbsorb)                   // do not replace -> append on tail
    1855         307 :             pRange->CollapseToEnd();
    1856             : 
    1857         419 :         pRange->setString( aString );
    1858             : 
    1859         419 :         pRange->CollapseToEnd();
    1860         419 :     }
    1861             : }
    1862             : 
    1863         250 : 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         250 :     SolarMutexGuard aGuard;
    1867             : 
    1868         250 :     SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL;
    1869             : 
    1870         250 :     if( pForwarder )
    1871             :     {
    1872         250 :         ESelection aSelection;
    1873         250 :         ::GetSelection( aSelection, pForwarder );
    1874         250 :         SetSelection( aSelection );
    1875             : 
    1876         250 :         switch( nControlCharacter )
    1877             :         {
    1878             :         case text::ControlCharacter::PARAGRAPH_BREAK:
    1879             :         {
    1880           1 :             const rtl::OUString aText( (sal_Unicode)13 );  // '\r' does not work on Mac
    1881           1 :             insertString( xRange, aText, bAbsorb );
    1882             : 
    1883           1 :             return;
    1884             :         }
    1885             :         case text::ControlCharacter::LINE_BREAK:
    1886             :         {
    1887           2 :             SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange );
    1888           2 :             if(pRange)
    1889             :             {
    1890           2 :                 ESelection aRange = pRange->GetSelection();
    1891             : 
    1892           2 :                 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           2 :                     aRange.nStartPos = aRange.nEndPos;
    1903           2 :                     aRange.nStartPara = aRange.nStartPara;
    1904             :                 }
    1905             : 
    1906           2 :                 pForwarder->QuickInsertLineBreak( aRange );
    1907           2 :                 GetEditSource()->UpdateData();
    1908             : 
    1909           2 :                 aRange.nEndPos += 1;
    1910           2 :                 if( !bAbsorb )
    1911           2 :                     aRange.nStartPos += 1;
    1912             : 
    1913           2 :                 pRange->SetSelection( aRange );
    1914             :             }
    1915             :             return;
    1916             :         }
    1917             :         case text::ControlCharacter::APPEND_PARAGRAPH:
    1918             :         {
    1919         247 :             SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange );
    1920         247 :             if(pRange)
    1921             :             {
    1922         247 :                 ESelection aRange = pRange->GetSelection();
    1923             : //              ESelection aOldSelection = aRange;
    1924             : 
    1925         247 :                 aRange.nStartPos  = pForwarder->GetTextLen( aRange.nStartPara );
    1926             : 
    1927         247 :                 aRange.nEndPara = aRange.nStartPara;
    1928         247 :                 aRange.nEndPos  = aRange.nStartPos;
    1929             : 
    1930         247 :                 pRange->SetSelection( aRange );
    1931         247 :                 const rtl::OUString aText( (sal_Unicode)13 );  // '\r' geht auf'm Mac nicht
    1932         247 :                 pRange->setString( aText );
    1933             : 
    1934         247 :                 aRange.nStartPos = 0;
    1935         247 :                 aRange.nStartPara += 1;
    1936         247 :                 aRange.nEndPos = 0;
    1937         247 :                 aRange.nEndPara += 1;
    1938             : 
    1939         247 :                 pRange->SetSelection( aRange );
    1940             : 
    1941         247 :                 return;
    1942             :             }
    1943             :         }
    1944             :         default:
    1945           0 :             throw lang::IllegalArgumentException();
    1946             :         }
    1947         250 :     }
    1948             : }
    1949             : 
    1950             : // XText
    1951          16 : 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          16 :     SolarMutexGuard aGuard;
    1955             : 
    1956          16 :     SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL;
    1957          16 :     if (!pForwarder)
    1958          16 :         return;
    1959             : 
    1960          16 :     uno::Reference<beans::XPropertySet> xPropSet(xRange, uno::UNO_QUERY);
    1961          16 :     if (!xPropSet.is())
    1962           0 :         throw lang::IllegalArgumentException();
    1963             : 
    1964          16 :     uno::Any aAny = xPropSet->getPropertyValue(UNO_TR_PROP_SELECTION);
    1965          16 :     text::TextRangeSelection aSel = aAny.get<text::TextRangeSelection>();
    1966          16 :     if (!bAbsorb)
    1967          16 :         aSel.Start = aSel.End;
    1968             : 
    1969          16 :     boost::scoped_ptr<SvxFieldData> pFieldData(SvxFieldData::Create(xContent));
    1970          16 :     if (!pFieldData)
    1971           0 :         throw lang::IllegalArgumentException();
    1972             : 
    1973          16 :     SvxFieldItem aField( *pFieldData, EE_FEATURE_FIELD );
    1974          16 :     pForwarder->QuickInsertField(aField, toESelection(aSel));
    1975          16 :     GetEditSource()->UpdateData();
    1976             : 
    1977          16 :     uno::Reference<beans::XPropertySet> xPropSetContent(xContent, uno::UNO_QUERY);
    1978          16 :     if (!xContent.is())
    1979           0 :         throw lang::IllegalArgumentException();
    1980             : 
    1981          16 :     xPropSetContent->setPropertyValue(UNO_TC_PROP_ANCHOR, uno::makeAny(xRange));
    1982             : 
    1983          16 :     aSel.End.PositionInParagraph += 1;
    1984          16 :     aSel.Start.PositionInParagraph = aSel.End.PositionInParagraph;
    1985          16 :     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           5 : uno::Reference< text::XText > SAL_CALL SvxUnoTextBase::getText()
    1995             :     throw(uno::RuntimeException)
    1996             : {
    1997           5 :     SolarMutexGuard aGuard;
    1998             : 
    1999           5 :     if (GetEditSource())
    2000             :     {
    2001           5 :         ESelection aSelection;
    2002           5 :         ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
    2003           5 :         ((SvxUnoTextBase*)this)->SetSelection( aSelection );
    2004             :     }
    2005             : 
    2006           5 :     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           4 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::getEnd()
    2016             :     throw(uno::RuntimeException)
    2017             : {
    2018           4 :     return SvxUnoTextRangeBase::getEnd();
    2019             : }
    2020             : 
    2021          82 : OUString SAL_CALL SvxUnoTextBase::getString() throw( uno::RuntimeException )
    2022             : {
    2023          82 :     return SvxUnoTextRangeBase::getString();
    2024             : }
    2025             : 
    2026         921 : void SAL_CALL SvxUnoTextBase::setString( const OUString& aString ) throw(uno::RuntimeException)
    2027             : {
    2028         921 :     SvxUnoTextRangeBase::setString(aString);
    2029         921 : }
    2030             : 
    2031             : 
    2032             : // XEnumerationAccess
    2033          64 : uno::Reference< container::XEnumeration > SAL_CALL SvxUnoTextBase::createEnumeration()
    2034             :     throw(uno::RuntimeException)
    2035             : {
    2036          64 :     SolarMutexGuard aGuard;
    2037             : 
    2038          64 :     ESelection aSelection;
    2039          64 :     ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
    2040          64 :     SetSelection( aSelection );
    2041             : 
    2042          64 :     uno::Reference< container::XEnumeration > xEnum( (container::XEnumeration*) new SvxUnoTextContentEnumeration( *this ) );
    2043          64 :     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          19 : 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          19 :     sal_Int32 nProps = rPropertyVaules.getLength();
    2081          19 :     const beans::PropertyValue *pProps = rPropertyVaules.getConstArray();
    2082          44 :     for (sal_Int32 i = 0;  i < nProps;  ++i)
    2083             :     {
    2084          30 :         const SfxItemPropertySimpleEntry *pEntry = pPropSet->getPropertyMap().getByName( pProps[i].Name );
    2085          30 :         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          26 :             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          26 :             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          26 :             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          26 :             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          26 :             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          26 :                 pPropSet->setPropertyValue( pProps[i].Name, pProps[i].Value, rItemSet );
    2139             :         }
    2140             :         else
    2141           4 :             throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pProps[i].Name, static_cast < cppu::OWeakObject * > ( 0 ) );
    2142             :     }
    2143          14 : }
    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           5 : 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           5 :     SolarMutexGuard aGuard;
    2159             : 
    2160           5 :     uno::Reference< text::XTextRange > xRet;
    2161           5 :     SvxEditSource *pEditSource = GetEditSource();
    2162           5 :     SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : 0;
    2163           5 :     if (pTextForwarder)
    2164             :     {
    2165           5 :         sal_uInt16 nParaCount = pTextForwarder->GetParagraphCount();
    2166             :         DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" );
    2167           5 :         pTextForwarder->AppendParagraph();
    2168             : 
    2169             :         // set properties for the previously last paragraph
    2170           5 :         sal_uInt16 nPara = nParaCount - 1;
    2171           5 :         ESelection aSel( nPara, 0, nPara, 0 );
    2172           5 :         SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
    2173             :         SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
    2174          10 :                 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           5 :         pRange->SetSelection( aSel );
    2180             :     }
    2181           5 :     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          14 : 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          14 :     SolarMutexGuard aGuard;
    2201             : 
    2202          14 :     SvxEditSource *pEditSource = GetEditSource();
    2203          14 :     SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : 0;
    2204          14 :     uno::Reference< text::XTextRange > xRet;
    2205          14 :     if (pTextForwarder)
    2206             :     {
    2207          14 :         sal_uInt16 nParaCount = pTextForwarder->GetParagraphCount();
    2208             :         DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" );
    2209          14 :         sal_uInt16 nPara = nParaCount - 1;
    2210          14 :         SfxItemSet aSet( pTextForwarder->GetParaAttribs( nPara ) );
    2211          14 :         xub_StrLen nStart = pTextForwarder->AppendTextPortion( nPara, rText, aSet );
    2212          14 :         pEditSource->UpdateData();
    2213          14 :         xub_StrLen nEnd   = pTextForwarder->GetTextLen( nPara );
    2214             : 
    2215             :         // set properties for the new text portion
    2216          14 :         ESelection aSel( nPara, nStart, nPara, nEnd );
    2217          14 :         pTextForwarder->RemoveAttribs( aSel, sal_False, 0 );
    2218          14 :         pEditSource->UpdateData();
    2219             : 
    2220          14 :         SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
    2221             :         SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
    2222          14 :                 ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, nPara );
    2223          14 :         pTextForwarder->QuickSetAttribs( aItemSet, aSel );
    2224          14 :         SvxUnoTextRange* pRange = new SvxUnoTextRange( *this );
    2225          14 :         xRet = pRange;
    2226          14 :         pRange->SetSelection( aSel );
    2227          14 :         const beans::PropertyValue* pProps = rCharAndParaProps.getConstArray();
    2228          37 :         for( sal_Int32 nProp = 0; nProp < rCharAndParaProps.getLength(); ++nProp )
    2229          37 :             pRange->setPropertyValue( pProps[nProp].Name, pProps[nProp].Value );
    2230             :     }
    2231          14 :     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           0 : uno::Sequence< OUString > SAL_CALL SvxUnoTextBase::getSupportedServiceNames(  )
    2273             :     throw(uno::RuntimeException)
    2274             : {
    2275           0 :     return getSupportedServiceNames_Static();
    2276             : }
    2277             : 
    2278           0 : uno::Sequence< OUString > SAL_CALL SvxUnoTextBase::getSupportedServiceNames_Static(  )
    2279             :     SAL_THROW(())
    2280             : {
    2281           0 :     uno::Sequence< OUString > aSeq( SvxUnoTextRangeBase::getSupportedServiceNames_Static() );
    2282           0 :     comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.text.Text" );
    2283           0 :     return aSeq;
    2284             : }
    2285             : 
    2286             : namespace
    2287             : {
    2288             :     class theSvxUnoTextBaseUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSvxUnoTextBaseUnoTunnelId > {};
    2289             : }
    2290             : 
    2291        1271 : const uno::Sequence< sal_Int8 > & SvxUnoTextBase::getUnoTunnelId() throw()
    2292             : {
    2293        1271 :     return theSvxUnoTextBaseUnoTunnelId::get().getSeq();
    2294             : }
    2295             : 
    2296         371 : SvxUnoTextBase* SvxUnoTextBase::getImplementation( const uno::Reference< uno::XInterface >& xInt )
    2297             : {
    2298         371 :     uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY );
    2299         371 :     if( xUT.is() )
    2300         371 :         return reinterpret_cast<SvxUnoTextBase*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( SvxUnoTextBase::getUnoTunnelId())));
    2301             :     else
    2302           0 :         return NULL;
    2303             : }
    2304             : 
    2305         900 : sal_Int64 SAL_CALL SvxUnoTextBase::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw(uno::RuntimeException) \
    2306             : {
    2307        2700 :     if( rId.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(),
    2308        1800 :                                                          rId.getConstArray(), 16 ) )
    2309             :     {
    2310         371 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
    2311             :     }
    2312             :     else
    2313             :     {
    2314         529 :         return SvxUnoTextRangeBase::getSomething( rId );
    2315             :     }
    2316             : }
    2317             : 
    2318             : // --------------------------------------------------------------------
    2319             : 
    2320           0 : SvxUnoText::SvxUnoText( ) throw()
    2321             : {
    2322           0 : }
    2323             : 
    2324           0 : SvxUnoText::SvxUnoText( const SvxItemPropertySet* _pSet ) throw()
    2325           0 : : SvxUnoTextBase( _pSet )
    2326             : {
    2327           0 : }
    2328             : 
    2329         294 : SvxUnoText::SvxUnoText( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet, uno::Reference < text::XText > xParent ) throw()
    2330         294 : : SvxUnoTextBase( pSource, _pSet, xParent )
    2331             : {
    2332         294 : }
    2333             : 
    2334           0 : SvxUnoText::SvxUnoText( const SvxUnoText& rText ) throw()
    2335             : : SvxUnoTextBase( rText )
    2336           0 : , cppu::OWeakAggObject()
    2337             : {
    2338           0 : }
    2339             : 
    2340         575 : SvxUnoText::~SvxUnoText() throw()
    2341             : {
    2342         575 : }
    2343             : 
    2344           0 : uno::Sequence< uno::Type > SAL_CALL getStaticTypes() throw()
    2345             : {
    2346           0 :     return SvxUnoTextBase::getStaticTypes();
    2347             : }
    2348             : 
    2349             : // uno::XInterface
    2350          22 : uno::Any SAL_CALL SvxUnoText::queryAggregation( const uno::Type & rType ) throw( uno::RuntimeException )
    2351             : {
    2352          22 :     uno::Any aAny( SvxUnoTextBase::queryAggregation( rType ) );
    2353          22 :     if( !aAny.hasValue() )
    2354           0 :         aAny = OWeakAggObject::queryAggregation( rType );
    2355             : 
    2356          22 :     return aAny;
    2357             : }
    2358             : 
    2359          22 : uno::Any SAL_CALL SvxUnoText::queryInterface( const uno::Type & rType ) throw( uno::RuntimeException )
    2360             : {
    2361          22 :     return OWeakAggObject::queryInterface( rType );
    2362             : }
    2363             : 
    2364        1382 : void SAL_CALL SvxUnoText::acquire() throw( )
    2365             : {
    2366        1382 :     OWeakAggObject::acquire();
    2367        1382 : }
    2368             : 
    2369        1381 : void SAL_CALL SvxUnoText::release() throw( )
    2370             : {
    2371        1381 :     OWeakAggObject::release();
    2372        1381 : }
    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           8 : const uno::Sequence< sal_Int8 > & SvxUnoText::getUnoTunnelId() throw()
    2396             : {
    2397           8 :     return theSvxUnoTextUnoTunnelId::get().getSeq();
    2398             : }
    2399             : 
    2400           8 : sal_Int64 SAL_CALL SvxUnoText::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw(uno::RuntimeException) \
    2401             : {
    2402          24 :     if( rId.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(),
    2403          16 :                                                          rId.getConstArray(), 16 ) )
    2404             :     {
    2405           0 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
    2406             :     }
    2407             :     else
    2408             :     {
    2409           8 :         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