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

Generated by: LCOV version 1.10