LCOV - code coverage report
Current view: top level - editeng/source/uno - unotext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1235 0.0 %
Date: 2014-04-14 Functions: 0 184 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      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           0 : ESelection toESelection(const text::TextRangeSelection& rSel)
      61             : {
      62           0 :     ESelection aESel;
      63           0 :     aESel.nStartPara = rSel.Start.Paragraph;
      64           0 :     aESel.nStartPos = rSel.Start.PositionInParagraph;
      65           0 :     aESel.nEndPara = rSel.End.Paragraph;
      66           0 :     aESel.nEndPos = rSel.End.PositionInParagraph;
      67           0 :     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           0 : const SvxItemPropertySet* ImplGetSvxUnoOutlinerTextCursorSvxPropertySet()
      77             : {
      78           0 :     static SvxItemPropertySet aTextCursorSvxPropertySet( ImplGetSvxUnoOutlinerTextCursorPropertyMap(), EditEngine::GetGlobalItemPool() );
      79           0 :     return &aTextCursorSvxPropertySet;
      80             : }
      81             : 
      82           0 : const SfxItemPropertyMapEntry* ImplGetSvxTextPortionPropertyMap()
      83             : {
      84             :     // Propertymap for an Outliner Text
      85             :     static const SfxItemPropertyMapEntry aSvxTextPortionPropertyMap[] =
      86             :     {
      87           0 :         SVX_UNOEDIT_CHAR_PROPERTIES,
      88           0 :         SVX_UNOEDIT_FONT_PROPERTIES,
      89           0 :         SVX_UNOEDIT_OUTLINER_PROPERTIES,
      90           0 :         SVX_UNOEDIT_PARA_PROPERTIES,
      91           0 :         {OUString("TextField"),                     EE_FEATURE_FIELD,   ::getCppuType((const uno::Reference< text::XTextField >*)0),   beans::PropertyAttribute::READONLY, 0 },
      92           0 :         {OUString("TextPortionType"),               WID_PORTIONTYPE,    ::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0 },
      93           0 :         {OUString("TextUserDefinedAttributes"),         EE_CHAR_XMLATTRIBS,     ::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0)  ,        0,     0},
      94           0 :         {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           0 :     };
      97           0 :     return aSvxTextPortionPropertyMap;
      98             : }
      99           0 : const SvxItemPropertySet* ImplGetSvxTextPortionSvxPropertySet()
     100             : {
     101           0 :     static SvxItemPropertySet aSvxTextPortionPropertySet( ImplGetSvxTextPortionPropertyMap(), EditEngine::GetGlobalItemPool() );
     102           0 :     return &aSvxTextPortionPropertySet;
     103             : }
     104             : 
     105           0 : const SfxItemPropertySet* ImplGetSvxTextPortionSfxPropertySet()
     106             : {
     107           0 :     static SfxItemPropertySet aSvxTextPortionSfxPropertySet( ImplGetSvxTextPortionPropertyMap() );
     108           0 :     return &aSvxTextPortionSfxPropertySet;
     109             : }
     110             : 
     111           0 : const SfxItemPropertyMapEntry* ImplGetSvxUnoOutlinerTextCursorPropertyMap()
     112             : {
     113             :     // Propertymap for an Outliner Text
     114             :     static const SfxItemPropertyMapEntry aSvxUnoOutlinerTextCursorPropertyMap[] =
     115             :     {
     116           0 :         SVX_UNOEDIT_CHAR_PROPERTIES,
     117           0 :         SVX_UNOEDIT_FONT_PROPERTIES,
     118           0 :         SVX_UNOEDIT_OUTLINER_PROPERTIES,
     119           0 :         SVX_UNOEDIT_PARA_PROPERTIES,
     120           0 :         {OUString("TextUserDefinedAttributes"),         EE_CHAR_XMLATTRIBS,     ::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0)  ,        0,     0},
     121           0 :         {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           0 :     };
     124             : 
     125           0 :     return aSvxUnoOutlinerTextCursorPropertyMap;
     126             : }
     127           0 : const SfxItemPropertySet* ImplGetSvxUnoOutlinerTextCursorSfxPropertySet()
     128             : {
     129           0 :     static SfxItemPropertySet aTextCursorSfxPropertySet( ImplGetSvxUnoOutlinerTextCursorPropertyMap() );
     130           0 :     return &aTextCursorSfxPropertySet;
     131             : }
     132             : 
     133             : 
     134             : // helper for Item/Property conversion
     135             : 
     136             : 
     137           0 : void GetSelection( struct ESelection& rSel, SvxTextForwarder* pForwarder ) throw()
     138             : {
     139             :     DBG_ASSERT( pForwarder, "I need a valid SvxTextForwarder!" );
     140           0 :     if( pForwarder )
     141             :     {
     142           0 :         sal_Int32 nParaCount = pForwarder->GetParagraphCount();
     143           0 :         if(nParaCount>0)
     144           0 :             nParaCount--;
     145             : 
     146           0 :         rSel = ESelection( 0,0, nParaCount, pForwarder->GetTextLen( nParaCount ));
     147             :     }
     148           0 : }
     149             : 
     150           0 : void CheckSelection( struct ESelection& rSel, SvxTextForwarder* pForwarder ) throw()
     151             : {
     152             :     DBG_ASSERT( pForwarder, "I need a valid SvxTextForwarder!" );
     153           0 :     if( pForwarder )
     154             :     {
     155           0 :         if( rSel.nStartPara == EE_PARA_MAX_COUNT )
     156             :         {
     157           0 :             ::GetSelection( rSel, pForwarder );
     158             :         }
     159             :         else
     160             :         {
     161           0 :             ESelection aMaxSelection;
     162           0 :             GetSelection( aMaxSelection, pForwarder );
     163             : 
     164             :             // check start position
     165           0 :             if( rSel.nStartPara < aMaxSelection.nStartPara )
     166             :             {
     167           0 :                 rSel.nStartPara = aMaxSelection.nStartPara;
     168           0 :                 rSel.nStartPos = aMaxSelection.nStartPos;
     169             :             }
     170           0 :             else if( rSel.nStartPara > aMaxSelection.nEndPara )
     171             :             {
     172           0 :                 rSel.nStartPara = aMaxSelection.nEndPara;
     173           0 :                 rSel.nStartPos = aMaxSelection.nEndPos;
     174             :             }
     175           0 :             else if( rSel.nStartPos  > pForwarder->GetTextLen( rSel.nStartPara ) )
     176             :             {
     177           0 :                 rSel.nStartPos = pForwarder->GetTextLen( rSel.nStartPara );
     178             :             }
     179             : 
     180             :             // check end position
     181           0 :             if( rSel.nEndPara < aMaxSelection.nStartPara )
     182             :             {
     183           0 :                 rSel.nEndPara = aMaxSelection.nStartPara;
     184           0 :                 rSel.nEndPos = aMaxSelection.nStartPos;
     185             :             }
     186           0 :             else if( rSel.nEndPara > aMaxSelection.nEndPara )
     187             :             {
     188           0 :                 rSel.nEndPara = aMaxSelection.nEndPara;
     189           0 :                 rSel.nEndPos = aMaxSelection.nEndPos;
     190             :             }
     191           0 :             else if( rSel.nEndPos > pForwarder->GetTextLen( rSel.nEndPara ) )
     192             :             {
     193           0 :                 rSel.nEndPos = pForwarder->GetTextLen( rSel.nEndPara );
     194             :             }
     195             :         }
     196             :     }
     197           0 : }
     198             : 
     199           0 : void CheckSelection( struct ESelection& rSel, SvxEditSource *pEdit ) throw()
     200             : {
     201           0 :     if (!pEdit)
     202           0 :         return;
     203           0 :     CheckSelection( rSel, pEdit->GetTextForwarder() );
     204             : }
     205             : 
     206             : 
     207             : // class SvxUnoTextRangeBase
     208             : 
     209             : 
     210           0 : UNO3_GETIMPLEMENTATION_IMPL( SvxUnoTextRangeBase );
     211             : 
     212           0 : SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxItemPropertySet* _pSet ) throw()
     213           0 : : mpEditSource(NULL) , mpPropSet(_pSet)
     214             : {
     215           0 : }
     216             : 
     217           0 : SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet ) throw()
     218           0 : : mpPropSet(_pSet)
     219             : {
     220           0 :     SolarMutexGuard aGuard;
     221             : 
     222             :     DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
     223             : 
     224           0 :     mpEditSource = pSource->Clone();
     225           0 :     if (mpEditSource != NULL)
     226             :     {
     227           0 :         ESelection aSelection;
     228           0 :         ::GetSelection( aSelection, mpEditSource->GetTextForwarder() );
     229           0 :         SetSelection( aSelection );
     230             : 
     231           0 :         mpEditSource->addRange( this );
     232           0 :     }
     233           0 : }
     234             : 
     235           0 : 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           0 : ,   mpPropSet(rRange.getPropertySet())
     246             : {
     247           0 :     SolarMutexGuard aGuard;
     248             : 
     249           0 :     mpEditSource = rRange.mpEditSource ? rRange.mpEditSource->Clone() : NULL;
     250             : 
     251           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     252           0 :     if( pForwarder )
     253             :     {
     254           0 :         maSelection  = rRange.maSelection;
     255           0 :         CheckSelection( maSelection, pForwarder );
     256             :     }
     257             : 
     258           0 :     if( mpEditSource )
     259           0 :         mpEditSource->addRange( this );
     260           0 : }
     261             : 
     262           0 : SvxUnoTextRangeBase::~SvxUnoTextRangeBase() throw()
     263             : {
     264           0 :     if( mpEditSource )
     265           0 :         mpEditSource->removeRange( this );
     266             : 
     267           0 :     delete mpEditSource;
     268           0 : }
     269             : 
     270           0 : 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           0 :     mpEditSource = pSource;
     276             : 
     277           0 :     maSelection.nStartPara = EE_PARA_MAX_COUNT;
     278             : 
     279           0 :     if( mpEditSource )
     280           0 :         mpEditSource->addRange( this );
     281           0 : }
     282             : 
     283             : /** puts a field item with a copy of the given FieldData into the itemset
     284             :     corresponding with this range */
     285           0 : void SvxUnoTextRangeBase::attachField( const SvxFieldData* pData ) throw()
     286             : {
     287           0 :     SolarMutexGuard aGuard;
     288             : 
     289           0 :     if( pData )
     290             :     {
     291           0 :         SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     292           0 :         if( pForwarder )
     293             :         {
     294           0 :             SvxFieldItem aField( *pData, EE_FEATURE_FIELD );
     295           0 :             pForwarder->QuickInsertField( aField, maSelection );
     296             :         }
     297           0 :     }
     298           0 : }
     299             : 
     300           0 : void SvxUnoTextRangeBase::SetSelection( const ESelection& rSelection ) throw()
     301             : {
     302           0 :     SolarMutexGuard aGuard;
     303             : 
     304           0 :     maSelection = rSelection;
     305           0 :     CheckSelection( maSelection, mpEditSource );
     306           0 : }
     307             : 
     308             : // Interface XTextRange ( XText )
     309             : 
     310           0 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getStart(void)
     311             :     throw( uno::RuntimeException, std::exception )
     312             : {
     313           0 :     SolarMutexGuard aGuard;
     314             : 
     315           0 :     uno::Reference< text::XTextRange > xRange;
     316             : 
     317           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     318           0 :     if( pForwarder )
     319             :     {
     320           0 :         CheckSelection( maSelection, pForwarder );
     321             : 
     322           0 :         SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( getText() );
     323             : 
     324           0 :         if(pText == NULL)
     325           0 :             throw uno::RuntimeException();
     326             : 
     327           0 :         SvxUnoTextRange* pRange = new SvxUnoTextRange( *pText );
     328           0 :         xRange = pRange;
     329             : 
     330           0 :         ESelection aNewSel = maSelection;
     331           0 :         aNewSel.nEndPara = aNewSel.nStartPara;
     332           0 :         aNewSel.nEndPos  = aNewSel.nStartPos;
     333           0 :         pRange->SetSelection( aNewSel );
     334             :     }
     335             : 
     336           0 :     return xRange;
     337             : }
     338             : 
     339           0 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getEnd(void)
     340             :     throw( uno::RuntimeException, std::exception )
     341             : {
     342           0 :     SolarMutexGuard aGuard;
     343             : 
     344           0 :     uno::Reference< text::XTextRange > xRet;
     345             : 
     346           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     347           0 :     if( pForwarder )
     348             :     {
     349           0 :         CheckSelection( maSelection, pForwarder );
     350             : 
     351           0 :         SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( getText() );
     352             : 
     353           0 :         if(pText == NULL)
     354           0 :             throw uno::RuntimeException();
     355             : 
     356           0 :         SvxUnoTextRange* pNew = new SvxUnoTextRange( *pText );
     357           0 :         xRet = pNew;
     358             : 
     359           0 :         ESelection aNewSel = maSelection;
     360           0 :         aNewSel.nStartPara = aNewSel.nEndPara;
     361           0 :         aNewSel.nStartPos  = aNewSel.nEndPos;
     362           0 :         pNew->SetSelection( aNewSel );
     363             :     }
     364           0 :     return xRet;
     365             : }
     366             : 
     367           0 : OUString SAL_CALL SvxUnoTextRangeBase::getString(void)
     368             :     throw( uno::RuntimeException, std::exception )
     369             : {
     370           0 :     SolarMutexGuard aGuard;
     371             : 
     372           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     373           0 :     if( pForwarder )
     374             :     {
     375           0 :         CheckSelection( maSelection, pForwarder );
     376             : 
     377           0 :         return pForwarder->GetText( maSelection );
     378             :     }
     379             :     else
     380             :     {
     381           0 :         const OUString aEmpty;
     382           0 :         return aEmpty;
     383           0 :     }
     384             : }
     385             : 
     386           0 : void SAL_CALL SvxUnoTextRangeBase::setString(const OUString& aString)
     387             :     throw( uno::RuntimeException, std::exception )
     388             : {
     389           0 :     SolarMutexGuard aGuard;
     390             : 
     391           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     392           0 :     if( pForwarder )
     393             :     {
     394           0 :         CheckSelection( maSelection, pForwarder );
     395             : 
     396           0 :         OUString aConverted(convertLineEnd(aString, LINEEND_LF));  // Simply count the number of line endings
     397             : 
     398           0 :         pForwarder->QuickInsertText( aConverted, maSelection );
     399           0 :         mpEditSource->UpdateData();
     400             : 
     401             :         //  Adapt selection
     402             :         //! It would be easier if the EditEngine would return the selection
     403             :         //! on QuickInsertText...
     404           0 :         CollapseToStart();
     405             : 
     406           0 :         sal_Int32 nLen = aConverted.getLength();
     407           0 :         if (nLen)
     408           0 :             GoRight( nLen, true );
     409           0 :     }
     410           0 : }
     411             : 
     412             : // Interface beans::XPropertySet
     413           0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL SvxUnoTextRangeBase::getPropertySetInfo(void)
     414             :     throw( uno::RuntimeException, std::exception )
     415             : {
     416           0 :     return mpPropSet->getPropertySetInfo();
     417             : }
     418             : 
     419           0 : 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           0 :     if (PropertyName == UNO_TR_PROP_SELECTION)
     423             :     {
     424           0 :         text::TextRangeSelection aSel = aValue.get<text::TextRangeSelection>();
     425           0 :         SetSelection(toESelection(aSel));
     426             : 
     427           0 :         return;
     428             :     }
     429             : 
     430           0 :     _setPropertyValue( PropertyName, aValue, -1 );
     431             : }
     432             : 
     433           0 : 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           0 :     SolarMutexGuard aGuard;
     437             : 
     438           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     439           0 :     if( pForwarder )
     440             :     {
     441           0 :         CheckSelection( maSelection, pForwarder );
     442             : 
     443           0 :         const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName );
     444           0 :         if ( pMap )
     445             :         {
     446           0 :             ESelection aSel( GetSelection() );
     447           0 :             sal_Bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END );
     448             : 
     449           0 :             if( nPara == -1 && !bParaAttrib )
     450             :             {
     451           0 :                 SfxItemSet aOldSet( pForwarder->GetAttribs( aSel ) );
     452             :                 // we have a selection and no para attribute
     453           0 :                 SfxItemSet aNewSet( *aOldSet.GetPool(), aOldSet.GetRanges() );
     454             : 
     455           0 :                 setPropertyValue( pMap, aValue, maSelection, aOldSet, aNewSet );
     456             : 
     457             : 
     458           0 :                 pForwarder->QuickSetAttribs( aNewSet, GetSelection() );
     459             :             }
     460             :             else
     461             :             {
     462             :                 sal_Int32 nEndPara;
     463             : 
     464           0 :                 if( nPara == -1 )
     465             :                 {
     466           0 :                     nPara = aSel.nStartPara;
     467           0 :                     nEndPara = aSel.nEndPara;
     468             :                 }
     469             :                 else
     470             :                 {
     471             :                     // only one paragraph
     472           0 :                     nEndPara = nPara;
     473             :                 }
     474             : 
     475           0 :                 while( nPara <= nEndPara )
     476             :                 {
     477             :                     // we have a paragraph
     478           0 :                     SfxItemSet aSet( pForwarder->GetParaAttribs( nPara ) );
     479           0 :                     setPropertyValue( pMap, aValue, maSelection, aSet, aSet );
     480           0 :                     pForwarder->SetParaAttribs( nPara, aSet );
     481           0 :                     nPara++;
     482           0 :                 }
     483             :             }
     484             : 
     485           0 :             GetEditSource()->UpdateData();
     486           0 :             return;
     487             :         }
     488             :     }
     489             : 
     490           0 :     throw beans::UnknownPropertyException();
     491             : }
     492             : 
     493           0 : 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           0 :     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           0 :         rNewSet.Put(rOldSet.Get(pMap->nWID));  // Old Item in new Set
     500           0 :         mpPropSet->setPropertyValue(pMap, rValue, rNewSet, false );
     501             :     }
     502           0 : }
     503             : 
     504           0 : bool SvxUnoTextRangeBase::SetPropertyValueHelper( const SfxItemSet&, const SfxItemPropertySimpleEntry* pMap, const uno::Any& aValue, SfxItemSet& rNewSet, const ESelection* pSelection /* = NULL */, SvxEditSource* pEditSource /* = NULL*/ )
     505             : {
     506           0 :     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           0 :             uno::Reference< container::XIndexReplace > xRule;
     522           0 :             if( !aValue.hasValue() || ((aValue >>= xRule) && !xRule.is()) )
     523           0 :                 return true;
     524             : 
     525           0 :             return false;
     526             :         }
     527             : 
     528             :     case WID_NUMLEVEL:
     529             :         {
     530           0 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     531           0 :             if(pForwarder && pSelection)
     532             :             {
     533           0 :                 sal_Int16 nLevel = sal_Int16();
     534           0 :                 if( aValue >>= nLevel )
     535             :                 {
     536             :                     // #101004# Call interface method instead of unsafe cast
     537           0 :                     if(! pForwarder->SetDepth( pSelection->nStartPara, nLevel ) )
     538           0 :                         throw lang::IllegalArgumentException();
     539             : 
     540           0 :                     return true;
     541             :                 }
     542             :             }
     543             :         }
     544           0 :         break;
     545             :     case WID_NUMBERINGSTARTVALUE:
     546             :         {
     547           0 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     548           0 :             if(pForwarder && pSelection)
     549             :             {
     550           0 :                 sal_Int16 nStartValue = -1;
     551           0 :                 if( aValue >>= nStartValue )
     552             :                 {
     553           0 :                     pForwarder->SetNumberingStartValue( pSelection->nStartPara, nStartValue );
     554           0 :                     return true;
     555             :                 }
     556             :             }
     557             :         }
     558           0 :         break;
     559             :     case WID_PARAISNUMBERINGRESTART:
     560             :         {
     561           0 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     562           0 :             if(pForwarder && pSelection)
     563             :             {
     564           0 :                 sal_Bool bParaIsNumberingRestart = sal_False;
     565           0 :                 if( aValue >>= bParaIsNumberingRestart )
     566             :                 {
     567           0 :                     pForwarder->SetParaIsNumberingRestart( pSelection->nStartPara, bParaIsNumberingRestart );
     568           0 :                     return true;
     569             :                 }
     570             :             }
     571             :         }
     572           0 :         break;
     573             :     case EE_PARA_BULLETSTATE:
     574             :         {
     575           0 :             sal_Bool bBullet = sal_True;
     576           0 :             if( aValue >>= bBullet )
     577             :             {
     578           0 :                 SfxBoolItem aItem( EE_PARA_BULLETSTATE, bBullet );
     579           0 :                 rNewSet.Put(aItem);
     580           0 :                 return true;
     581             :             }
     582             :         }
     583           0 :         break;
     584             : 
     585             :     default:
     586           0 :         return false;
     587             :     }
     588             : 
     589           0 :     throw lang::IllegalArgumentException();
     590             : }
     591             : 
     592           0 : uno::Any SAL_CALL SvxUnoTextRangeBase::getPropertyValue(const OUString& PropertyName)
     593             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     594             : {
     595           0 :     if (PropertyName == UNO_TR_PROP_SELECTION)
     596             :     {
     597           0 :         const ESelection& rSel = GetSelection();
     598           0 :         text::TextRangeSelection aSel;
     599           0 :         aSel.Start.Paragraph = rSel.nStartPara;
     600           0 :         aSel.Start.PositionInParagraph = static_cast<sal_Int32>(rSel.nStartPos);
     601           0 :         aSel.End.Paragraph = rSel.nEndPara;
     602           0 :         aSel.End.PositionInParagraph = static_cast<sal_Int32>(rSel.nEndPos);
     603           0 :         return uno::makeAny(aSel);
     604             :     }
     605             : 
     606           0 :     return _getPropertyValue( PropertyName, -1 );
     607             : }
     608             : 
     609           0 : uno::Any SAL_CALL SvxUnoTextRangeBase::_getPropertyValue(const OUString& PropertyName, sal_Int32 nPara )
     610             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
     611             : {
     612           0 :     SolarMutexGuard aGuard;
     613             : 
     614           0 :     uno::Any aAny;
     615             : 
     616           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     617           0 :     if( pForwarder )
     618             :     {
     619           0 :         const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName );
     620           0 :         if( pMap )
     621             :         {
     622           0 :             SfxItemSet* pAttribs = NULL;
     623           0 :             if( nPara != -1 )
     624           0 :                 pAttribs = pForwarder->GetParaAttribs( nPara ).Clone();
     625             :             else
     626           0 :                 pAttribs = pForwarder->GetAttribs( GetSelection() ).Clone();
     627             : 
     628             :             //  Replace Dontcare with Default, so that one always has a mirror
     629           0 :             pAttribs->ClearInvalidItems();
     630             : 
     631           0 :             getPropertyValue( pMap, aAny, *pAttribs );
     632             : 
     633           0 :             delete pAttribs;
     634           0 :             return aAny;
     635             :         }
     636             :     }
     637             : 
     638           0 :     throw beans::UnknownPropertyException();
     639             : }
     640             : 
     641           0 : void SvxUnoTextRangeBase::getPropertyValue( const SfxItemPropertySimpleEntry* pMap, uno::Any& rAny, const SfxItemSet& rSet ) throw( beans::UnknownPropertyException )
     642             : {
     643           0 :     switch( pMap->nWID )
     644             :     {
     645             :     case EE_FEATURE_FIELD:
     646           0 :         if ( rSet.GetItemState( EE_FEATURE_FIELD, false ) == SFX_ITEM_SET )
     647             :         {
     648           0 :             SvxFieldItem* pItem = (SvxFieldItem*)rSet.GetItem( EE_FEATURE_FIELD );
     649           0 :             const SvxFieldData* pData = pItem->GetField();
     650           0 :             uno::Reference< text::XTextRange > xAnchor( this );
     651             : 
     652             :             // get presentation string for field
     653           0 :             Color* pTColor = NULL;
     654           0 :             Color* pFColor = NULL;
     655             : 
     656           0 :             SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder();
     657           0 :             OUString aPresentation( pForwarder->CalcFieldValue( SvxFieldItem(*pData, EE_FEATURE_FIELD), maSelection.nStartPara, maSelection.nStartPos, pTColor, pFColor ) );
     658             : 
     659           0 :             delete pTColor;
     660           0 :             delete pFColor;
     661             : 
     662           0 :             uno::Reference< text::XTextField > xField( new SvxUnoTextField( xAnchor, aPresentation, pData ) );
     663           0 :             rAny <<= xField;
     664             :         }
     665           0 :         break;
     666             : 
     667             :     case WID_PORTIONTYPE:
     668           0 :         if ( rSet.GetItemState( EE_FEATURE_FIELD, false ) == SFX_ITEM_SET )
     669             :         {
     670           0 :             OUString aType("TextField");
     671           0 :             rAny <<= aType;
     672             :         }
     673             :         else
     674             :         {
     675           0 :             OUString aType("Text");
     676           0 :             rAny <<= aType;
     677             :         }
     678           0 :         break;
     679             : 
     680             :     default:
     681           0 :         if(!GetPropertyValueHelper( *((SfxItemSet*)(&rSet)), pMap, rAny, &maSelection, GetEditSource() ))
     682           0 :             rAny = mpPropSet->getPropertyValue(pMap, rSet, true, false );
     683             :     }
     684           0 : }
     685             : 
     686           0 : bool SvxUnoTextRangeBase::GetPropertyValueHelper(  SfxItemSet& rSet, const SfxItemPropertySimpleEntry* pMap, uno::Any& aAny, const ESelection* pSelection /* = NULL */, SvxEditSource* pEditSource /* = NULL */ )
     687             :     throw( uno::RuntimeException )
     688             : {
     689           0 :     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           0 :             if((rSet.GetItemState( EE_PARA_NUMBULLET, true ) & (SFX_ITEM_SET|SFX_ITEM_DEFAULT)) == 0)
     702           0 :                 throw uno::RuntimeException();
     703             : 
     704           0 :             SvxNumBulletItem* pBulletItem = (SvxNumBulletItem*)rSet.GetItem( EE_PARA_NUMBULLET, true );
     705             : 
     706           0 :             if( pBulletItem == NULL )
     707           0 :                 throw uno::RuntimeException();
     708             : 
     709           0 :             aAny <<= SvxCreateNumRule( pBulletItem->GetNumRule() );
     710             :         }
     711           0 :         break;
     712             : 
     713             :     case WID_NUMLEVEL:
     714             :         {
     715           0 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     716           0 :             if(pForwarder && pSelection)
     717             :             {
     718           0 :                 sal_Int16 nLevel = pForwarder->GetDepth( pSelection->nStartPara );
     719           0 :                 if( nLevel >= 0 )
     720           0 :                     aAny <<= nLevel;
     721             :             }
     722             :         }
     723           0 :         break;
     724             :     case WID_NUMBERINGSTARTVALUE:
     725             :         {
     726           0 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     727           0 :             if(pForwarder && pSelection)
     728           0 :                 aAny <<= pForwarder->GetNumberingStartValue( pSelection->nStartPara );
     729             :         }
     730           0 :         break;
     731             :     case WID_PARAISNUMBERINGRESTART:
     732             :         {
     733           0 :             SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL;
     734           0 :             if(pForwarder && pSelection)
     735           0 :                 aAny <<= pForwarder->IsParaIsNumberingRestart( pSelection->nStartPara );
     736             :         }
     737           0 :         break;
     738             : 
     739             :     case EE_PARA_BULLETSTATE:
     740             :         {
     741           0 :             sal_Bool bState = sal_False;
     742           0 :             if( rSet.GetItemState( EE_PARA_BULLETSTATE, true ) & (SFX_ITEM_SET|SFX_ITEM_DEFAULT))
     743             :             {
     744           0 :                 SfxBoolItem* pItem = (SfxBoolItem*)rSet.GetItem( EE_PARA_BULLETSTATE, true );
     745           0 :                 bState = pItem->GetValue() ? sal_True : sal_False;
     746             :             }
     747             : 
     748           0 :             aAny <<= bState;
     749             :         }
     750           0 :         break;
     751             :     default:
     752             : 
     753           0 :         return false;
     754             :     }
     755             : 
     756           0 :     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           0 : void SAL_CALL SvxUnoTextRangeBase::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) {}
     763           0 : 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           0 : 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           0 :     _setPropertyValues( aPropertyNames, aValues, -1 );
     769           0 : }
     770             : 
     771           0 : 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           0 :     SolarMutexGuard aGuard;
     774             : 
     775           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     776           0 :     if( pForwarder )
     777             :     {
     778           0 :         CheckSelection( maSelection, pForwarder );
     779             : 
     780           0 :         ESelection aSel( GetSelection() );
     781             : 
     782           0 :         const OUString* pPropertyNames = aPropertyNames.getConstArray();
     783           0 :         const uno::Any* pValues = aValues.getConstArray();
     784           0 :         sal_Int32 nCount = aPropertyNames.getLength();
     785             : 
     786           0 :         sal_Int32 nEndPara = nPara;
     787           0 :         sal_Int32 nTempPara = nPara;
     788             : 
     789           0 :         if( nTempPara == -1 )
     790             :         {
     791           0 :             nTempPara = aSel.nStartPara;
     792           0 :             nEndPara = aSel.nEndPara;
     793             :         }
     794             : 
     795           0 :         SfxItemSet* pOldAttrSet = NULL;
     796           0 :         SfxItemSet* pNewAttrSet = NULL;
     797             : 
     798           0 :         SfxItemSet* pOldParaSet = NULL;
     799           0 :         SfxItemSet* pNewParaSet = NULL;
     800             : 
     801           0 :         for( ; nCount; nCount--, pPropertyNames++, pValues++ )
     802             :         {
     803           0 :             const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames );
     804             : 
     805           0 :             if( pMap )
     806             :             {
     807           0 :                 sal_Bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END );
     808             : 
     809           0 :                 if( (nPara == -1) && !bParaAttrib )
     810             :                 {
     811           0 :                     if( NULL == pNewAttrSet )
     812             :                     {
     813           0 :                         const SfxItemSet aSet( pForwarder->GetAttribs( aSel ) );
     814           0 :                         pOldAttrSet = new SfxItemSet( aSet );
     815           0 :                         pNewAttrSet = new SfxItemSet( *pOldAttrSet->GetPool(), pOldAttrSet->GetRanges() );
     816             :                     }
     817             : 
     818           0 :                     setPropertyValue( pMap, *pValues, GetSelection(), *pOldAttrSet, *pNewAttrSet );
     819             : 
     820           0 :                     if( pMap->nWID >= EE_ITEMS_START && pMap->nWID <= EE_ITEMS_END )
     821             :                     {
     822             :                         const SfxPoolItem* pItem;
     823           0 :                         if( pNewAttrSet->GetItemState( pMap->nWID, true, &pItem ) == SFX_ITEM_SET )
     824             :                         {
     825           0 :                             pOldAttrSet->Put( *pItem );
     826             :                         }
     827           0 :                     }
     828             :                 }
     829             :                 else
     830             :                 {
     831           0 :                     if( NULL == pNewParaSet )
     832             :                     {
     833           0 :                         const SfxItemSet aSet( pForwarder->GetParaAttribs( nTempPara ) );
     834           0 :                         pOldParaSet = new SfxItemSet( aSet );
     835           0 :                         pNewParaSet = new SfxItemSet( *pOldParaSet->GetPool(), pOldParaSet->GetRanges() );
     836             :                     }
     837             : 
     838           0 :                     setPropertyValue( pMap, *pValues, GetSelection(), *pOldParaSet, *pNewParaSet );
     839             : 
     840           0 :                     if( pMap->nWID >= EE_ITEMS_START && pMap->nWID <= EE_ITEMS_END )
     841             :                     {
     842             :                         const SfxPoolItem* pItem;
     843           0 :                         if( pNewParaSet->GetItemState( pMap->nWID, true, &pItem ) == SFX_ITEM_SET )
     844             :                         {
     845           0 :                             pOldParaSet->Put( *pItem );
     846             :                         }
     847             :                     }
     848             : 
     849             :                 }
     850             :             }
     851             :         }
     852             : 
     853           0 :         sal_Bool bNeedsUpdate = sal_False;
     854             : 
     855           0 :         if( pNewParaSet )
     856             :         {
     857           0 :             if( pNewParaSet->Count() )
     858             :             {
     859           0 :                 while( nTempPara <= nEndPara )
     860             :                 {
     861           0 :                     SfxItemSet aSet( pForwarder->GetParaAttribs( nTempPara ) );
     862           0 :                     aSet.Put( *pNewParaSet );
     863           0 :                     pForwarder->SetParaAttribs( nTempPara, aSet );
     864           0 :                     nTempPara++;
     865           0 :                 }
     866           0 :                 bNeedsUpdate = sal_True;
     867             :             }
     868             : 
     869           0 :             delete pNewParaSet;
     870           0 :             delete pOldParaSet;
     871             :         }
     872             : 
     873           0 :         if( pNewAttrSet )
     874             :         {
     875           0 :             if( pNewAttrSet->Count() )
     876             :             {
     877           0 :                 pForwarder->QuickSetAttribs( *pNewAttrSet, GetSelection() );
     878           0 :                 bNeedsUpdate = sal_True;
     879             :             }
     880           0 :             delete pNewAttrSet;
     881           0 :             delete pOldAttrSet;
     882             : 
     883             :         }
     884             : 
     885           0 :         if( bNeedsUpdate )
     886           0 :             GetEditSource()->UpdateData();
     887           0 :     }
     888           0 : }
     889             : 
     890           0 : uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyValues( const uno::Sequence< OUString >& aPropertyNames ) throw (uno::RuntimeException, std::exception)
     891             : {
     892           0 :     return _getPropertyValues( aPropertyNames, -1 );
     893             : }
     894             : 
     895           0 : uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::_getPropertyValues( const uno::Sequence< OUString >& aPropertyNames, sal_Int32 nPara ) throw (uno::RuntimeException)
     896             : {
     897           0 :     SolarMutexGuard aGuard;
     898             : 
     899           0 :     sal_Int32 nCount = aPropertyNames.getLength();
     900             : 
     901             : 
     902           0 :     uno::Sequence< uno::Any > aValues( nCount );
     903             : 
     904           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     905           0 :     if( pForwarder )
     906             :     {
     907           0 :         SfxItemSet* pAttribs = NULL;
     908           0 :         if( nPara != -1 )
     909           0 :             pAttribs = pForwarder->GetParaAttribs( nPara ).Clone();
     910             :         else
     911           0 :             pAttribs = pForwarder->GetAttribs( GetSelection() ).Clone();
     912             : 
     913           0 :         pAttribs->ClearInvalidItems();
     914             : 
     915           0 :         const OUString* pPropertyNames = aPropertyNames.getConstArray();
     916           0 :         uno::Any* pValues = aValues.getArray();
     917             : 
     918           0 :         for( ; nCount; nCount--, pPropertyNames++, pValues++ )
     919             :         {
     920           0 :             const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames );
     921           0 :             if( pMap )
     922             :             {
     923           0 :                 getPropertyValue( pMap, *pValues, *pAttribs );
     924             :             }
     925             :         }
     926             : 
     927           0 :         delete pAttribs;
     928             : 
     929             :     }
     930             : 
     931           0 :     return aValues;
     932             : }
     933             : 
     934           0 : void SAL_CALL SvxUnoTextRangeBase::addPropertiesChangeListener( const uno::Sequence< OUString >& , const uno::Reference< beans::XPropertiesChangeListener >& ) throw (uno::RuntimeException, std::exception)
     935             : {
     936           0 : }
     937             : 
     938           0 : void SAL_CALL SvxUnoTextRangeBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& ) throw (uno::RuntimeException, std::exception)
     939             : {
     940           0 : }
     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           0 : beans::PropertyState SAL_CALL SvxUnoTextRangeBase::getPropertyState( const OUString& PropertyName )
     948             :     throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
     949             : {
     950           0 :     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           0 : beans::PropertyState SAL_CALL SvxUnoTextRangeBase::_getPropertyState(const SfxItemPropertySimpleEntry* pMap, sal_Int32 nPara)
     958             :     throw( beans::UnknownPropertyException, uno::RuntimeException )
     959             : {
     960           0 :     if ( pMap )
     961             :     {
     962           0 :         SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
     963           0 :         if( pForwarder )
     964             :         {
     965           0 :             SfxItemState eItemState = SFX_ITEM_UNKNOWN;
     966           0 :             sal_uInt16 nWID = 0;
     967             : 
     968           0 :             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           0 :                 nWID = pMap->nWID;
    1021             :             }
    1022             : 
    1023           0 :             if( nWID != 0 )
    1024             :             {
    1025           0 :                 if( nPara != -1 )
    1026           0 :                     eItemState = pForwarder->GetItemState( nPara, nWID );
    1027             :                 else
    1028           0 :                     eItemState = pForwarder->GetItemState( GetSelection(), nWID );
    1029             :             }
    1030             : 
    1031           0 :             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           0 :                 return beans::PropertyState_DIRECT_VALUE;
    1039             :             case SFX_ITEM_DEFAULT:
    1040           0 :                 return beans::PropertyState_DEFAULT_VALUE;
    1041             : //              case SFX_ITEM_UNKNOWN:
    1042             :             }
    1043             :         }
    1044             :     }
    1045           0 :     throw beans::UnknownPropertyException();
    1046             : }
    1047             : 
    1048           0 : beans::PropertyState SAL_CALL SvxUnoTextRangeBase::_getPropertyState(const OUString& PropertyName, sal_Int32 nPara /* = -1 */)
    1049             :     throw( beans::UnknownPropertyException, uno::RuntimeException )
    1050             : {
    1051           0 :     SolarMutexGuard aGuard;
    1052             : 
    1053           0 :     return _getPropertyState( mpPropSet->getPropertyMapEntry( PropertyName ), nPara);
    1054             : }
    1055             : 
    1056           0 : uno::Sequence< beans::PropertyState > SAL_CALL SvxUnoTextRangeBase::getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
    1057             :     throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1058             : {
    1059           0 :     return _getPropertyStates( aPropertyName, -1 );
    1060             : }
    1061             : 
    1062           0 : uno::Sequence< beans::PropertyState > SvxUnoTextRangeBase::_getPropertyStates(const uno::Sequence< OUString >& PropertyName, sal_Int32 nPara /* = -1 */)
    1063             :     throw( beans::UnknownPropertyException, uno::RuntimeException )
    1064             : {
    1065           0 :     const sal_Int32 nCount = PropertyName.getLength();
    1066           0 :     const OUString* pNames = PropertyName.getConstArray();
    1067             : 
    1068           0 :     uno::Sequence< beans::PropertyState > aRet( nCount );
    1069           0 :     beans::PropertyState* pState = aRet.getArray();
    1070             : 
    1071           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1072           0 :     if( pForwarder )
    1073             :     {
    1074           0 :         SfxItemSet* pSet = NULL;
    1075           0 :         if( nPara != -1 )
    1076             :         {
    1077           0 :             pSet = new SfxItemSet( pForwarder->GetParaAttribs( nPara ) );
    1078             :         }
    1079             :         else
    1080             :         {
    1081           0 :             ESelection aSel( GetSelection() );
    1082           0 :             CheckSelection( aSel, pForwarder );
    1083           0 :             pSet = new SfxItemSet( pForwarder->GetAttribs( aSel, EditEngineAttribs_OnlyHard ) );
    1084             :         }
    1085             : 
    1086           0 :         sal_Bool bUnknownPropertyFound = sal_False;
    1087           0 :         for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
    1088             :         {
    1089           0 :             const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( *pNames++ );
    1090           0 :             if( NULL == pMap )
    1091             :             {
    1092           0 :                 bUnknownPropertyFound = sal_True;
    1093           0 :                 break;
    1094             :             }
    1095           0 :             bUnknownPropertyFound = !_getOnePropertyStates(pSet, pMap, *pState++);
    1096             :         }
    1097             : 
    1098           0 :         delete pSet;
    1099             : 
    1100           0 :         if( bUnknownPropertyFound )
    1101           0 :             throw beans::UnknownPropertyException();
    1102             :     }
    1103             : 
    1104           0 :     return aRet;
    1105             : }
    1106             : 
    1107           0 : bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const SfxItemPropertySimpleEntry* pMap, beans::PropertyState& rState)
    1108             : {
    1109           0 :     bool bUnknownPropertyFound = false;
    1110           0 :     if(pSet && pMap)
    1111             :     {
    1112           0 :         SfxItemState eItemState = SFX_ITEM_UNKNOWN;
    1113           0 :         sal_uInt16 nWID = 0;
    1114             : 
    1115           0 :         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           0 :                 nWID = pMap->nWID;
    1166             :         }
    1167             : 
    1168           0 :         if( bUnknownPropertyFound )
    1169           0 :             return !bUnknownPropertyFound;
    1170             : 
    1171           0 :         if( nWID != 0 )
    1172           0 :             eItemState = pSet->GetItemState( nWID, false );
    1173             : 
    1174           0 :         switch( eItemState )
    1175             :         {
    1176             :                 case SFX_ITEM_READONLY:
    1177             :                 case SFX_ITEM_SET:
    1178           0 :                     rState = beans::PropertyState_DIRECT_VALUE;
    1179           0 :                     break;
    1180             :                 case SFX_ITEM_DEFAULT:
    1181           0 :                     rState = beans::PropertyState_DEFAULT_VALUE;
    1182           0 :                     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           0 :     return !bUnknownPropertyFound;
    1191             : }
    1192             : 
    1193           0 : void SAL_CALL SvxUnoTextRangeBase::setPropertyToDefault( const OUString& PropertyName )
    1194             :     throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1195             : {
    1196           0 :     _setPropertyToDefault( PropertyName, -1 );
    1197           0 : }
    1198             : 
    1199           0 : void SvxUnoTextRangeBase::_setPropertyToDefault(const OUString& PropertyName, sal_Int32 nPara /* = -1 */)
    1200             :     throw( beans::UnknownPropertyException, uno::RuntimeException )
    1201             : {
    1202           0 :     SolarMutexGuard aGuard;
    1203             : 
    1204           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1205             : 
    1206           0 :     if( pForwarder )
    1207             :     {
    1208           0 :         const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( PropertyName );
    1209           0 :         if ( pMap )
    1210             :         {
    1211           0 :             CheckSelection( maSelection, mpEditSource->GetTextForwarder() );
    1212           0 :             _setPropertyToDefault( pForwarder, pMap, nPara );
    1213           0 :             return;
    1214             :         }
    1215             :     }
    1216             : 
    1217           0 :     throw beans::UnknownPropertyException();
    1218             : }
    1219             : 
    1220           0 : void SvxUnoTextRangeBase::_setPropertyToDefault(SvxTextForwarder* pForwarder, const SfxItemPropertySimpleEntry* pMap, sal_Int32 nPara )
    1221             :     throw( beans::UnknownPropertyException, uno::RuntimeException )
    1222             : {
    1223             :     do
    1224             :     {
    1225           0 :         SfxItemSet aSet( *pForwarder->GetPool(), true );
    1226             : 
    1227           0 :         if( pMap->nWID == WID_FONTDESC )
    1228             :         {
    1229           0 :             SvxUnoFontDescriptor::setPropertyToDefault( aSet );
    1230             :         }
    1231           0 :         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           0 :         else if( pMap->nWID == WID_NUMBERINGSTARTVALUE )
    1238             :         {
    1239           0 :             pForwarder->SetNumberingStartValue( maSelection.nStartPara, -1 );
    1240             :         }
    1241           0 :         else if( pMap->nWID == WID_PARAISNUMBERINGRESTART )
    1242             :         {
    1243           0 :             pForwarder->SetParaIsNumberingRestart( maSelection.nStartPara, false );
    1244             :         }
    1245             :         else
    1246             :         {
    1247           0 :             aSet.InvalidateItem( pMap->nWID );
    1248             :         }
    1249             : 
    1250           0 :         if(nPara != -1)
    1251           0 :             pForwarder->SetParaAttribs( nPara, aSet );
    1252             :         else
    1253           0 :             pForwarder->QuickSetAttribs( aSet, GetSelection() );
    1254             : 
    1255           0 :         GetEditSource()->UpdateData();
    1256             : 
    1257           0 :         return;
    1258             :     }
    1259             :     while(false);
    1260             : }
    1261             : 
    1262           0 : uno::Any SAL_CALL SvxUnoTextRangeBase::getPropertyDefault( const OUString& aPropertyName )
    1263             :     throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1264             : {
    1265           0 :     SolarMutexGuard aGuard;
    1266             : 
    1267           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1268           0 :     if( pForwarder )
    1269             :     {
    1270           0 :         const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( aPropertyName );
    1271           0 :         if( pMap )
    1272             :         {
    1273           0 :             SfxItemPool* pPool = pForwarder->GetPool();
    1274             : 
    1275           0 :             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           0 :                     if(pPool->IsWhich(pMap->nWID))
    1296             :                     {
    1297           0 :                         SfxItemSet aSet( *pPool,    pMap->nWID, pMap->nWID);
    1298           0 :                         aSet.Put(pPool->GetDefaultItem(pMap->nWID));
    1299           0 :                         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           0 : void SvxUnoTextRangeBase::CollapseToStart(void) throw()
    1353             : {
    1354           0 :     CheckSelection( maSelection, mpEditSource );
    1355             : 
    1356           0 :     maSelection.nEndPara = maSelection.nStartPara;
    1357           0 :     maSelection.nEndPos  = maSelection.nStartPos;
    1358           0 : }
    1359             : 
    1360           0 : void SvxUnoTextRangeBase::CollapseToEnd(void) throw()
    1361             : {
    1362           0 :     CheckSelection( maSelection, mpEditSource );
    1363             : 
    1364           0 :     maSelection.nStartPara = maSelection.nEndPara;
    1365           0 :     maSelection.nStartPos  = maSelection.nEndPos;
    1366           0 : }
    1367             : 
    1368           0 : bool SvxUnoTextRangeBase::IsCollapsed(void) throw()
    1369             : {
    1370           0 :     CheckSelection( maSelection, mpEditSource );
    1371             : 
    1372           0 :     return ( maSelection.nStartPara == maSelection.nEndPara &&
    1373           0 :              maSelection.nStartPos  == maSelection.nEndPos );
    1374             : }
    1375             : 
    1376           0 : bool SvxUnoTextRangeBase::GoLeft(sal_Int16 nCount, bool Expand) throw()
    1377             : {
    1378           0 :     CheckSelection( maSelection, mpEditSource );
    1379             : 
    1380             :     //  #75098# use end position, as in Writer (start is anchor, end is cursor)
    1381           0 :     sal_uInt16 nNewPos = maSelection.nEndPos;
    1382           0 :     sal_Int32  nNewPar = maSelection.nEndPara;
    1383             : 
    1384           0 :     bool bOk = true;
    1385           0 :     SvxTextForwarder* pForwarder = NULL;
    1386           0 :     while ( nCount > nNewPos && bOk )
    1387             :     {
    1388           0 :         if ( nNewPar == 0 )
    1389           0 :             bOk = false;
    1390             :         else
    1391             :         {
    1392           0 :             if ( !pForwarder )
    1393           0 :                 pForwarder = mpEditSource->GetTextForwarder();  // first here, it it is necessary...
    1394             : 
    1395           0 :             --nNewPar;
    1396           0 :             nCount -= nNewPos + 1;
    1397           0 :             nNewPos = pForwarder->GetTextLen( nNewPar );
    1398             :         }
    1399             :     }
    1400             : 
    1401           0 :     if ( bOk )
    1402             :     {
    1403           0 :         nNewPos = nNewPos - nCount;
    1404           0 :         maSelection.nStartPara = nNewPar;
    1405           0 :         maSelection.nStartPos  = nNewPos;
    1406             :     }
    1407             : 
    1408           0 :     if (!Expand)
    1409           0 :         CollapseToStart();
    1410             : 
    1411           0 :     return bOk;
    1412             : }
    1413             : 
    1414           0 : bool SvxUnoTextRangeBase::GoRight(sal_Int16 nCount, bool Expand)  throw()
    1415             : {
    1416           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1417           0 :     if( pForwarder )
    1418             :     {
    1419           0 :         CheckSelection( maSelection, pForwarder );
    1420             : 
    1421           0 :         sal_Int32 nNewPos = maSelection.nEndPos + nCount; //! Overflow???
    1422           0 :         sal_Int32  nNewPar = maSelection.nEndPara;
    1423             : 
    1424           0 :         bool bOk = true;
    1425           0 :         sal_Int32 nParCount = pForwarder->GetParagraphCount();
    1426           0 :         sal_Int32 nThisLen = pForwarder->GetTextLen( nNewPar );
    1427           0 :         while ( nNewPos > nThisLen && bOk )
    1428             :         {
    1429           0 :             if ( nNewPar + 1 >= nParCount )
    1430           0 :                 bOk = false;
    1431             :             else
    1432             :             {
    1433           0 :                 nNewPos -= nThisLen+1;
    1434           0 :                 ++nNewPar;
    1435           0 :                 nThisLen = pForwarder->GetTextLen( nNewPar );
    1436             :             }
    1437             :         }
    1438             : 
    1439           0 :         if (bOk)
    1440             :         {
    1441           0 :             maSelection.nEndPara = nNewPar;
    1442           0 :             maSelection.nEndPos  = nNewPos;
    1443             :         }
    1444             : 
    1445           0 :         if (!Expand)
    1446           0 :             CollapseToEnd();
    1447             : 
    1448           0 :         return bOk;
    1449             :     }
    1450           0 :     return false;
    1451             : }
    1452             : 
    1453           0 : void SvxUnoTextRangeBase::GotoStart(bool Expand) throw()
    1454             : {
    1455           0 :     maSelection.nStartPara = 0;
    1456           0 :     maSelection.nStartPos  = 0;
    1457             : 
    1458           0 :     if (!Expand)
    1459           0 :         CollapseToStart();
    1460           0 : }
    1461             : 
    1462           0 : void SvxUnoTextRangeBase::GotoEnd(bool Expand) throw()
    1463             : {
    1464           0 :     CheckSelection( maSelection, mpEditSource );
    1465             : 
    1466           0 :     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
    1467           0 :     if( pForwarder )
    1468             :     {
    1469             : 
    1470           0 :         sal_Int32 nPar = pForwarder->GetParagraphCount();
    1471           0 :         if (nPar)
    1472           0 :             --nPar;
    1473             : 
    1474           0 :         maSelection.nEndPara = nPar;
    1475           0 :         maSelection.nEndPos  = pForwarder->GetTextLen( nPar );
    1476             : 
    1477           0 :         if (!Expand)
    1478           0 :             CollapseToEnd();
    1479             :     }
    1480           0 : }
    1481             : 
    1482             : // lang::XServiceInfo
    1483           0 : sal_Bool SAL_CALL SvxUnoTextRangeBase::supportsService( const OUString& ServiceName )
    1484             :     throw(uno::RuntimeException, std::exception)
    1485             : {
    1486           0 :     return cppu::supportsService( this, ServiceName );
    1487             : }
    1488             : 
    1489           0 : uno::Sequence< OUString > SAL_CALL SvxUnoTextRangeBase::getSupportedServiceNames()
    1490             :     throw(uno::RuntimeException, std::exception)
    1491             : {
    1492           0 :     return getSupportedServiceNames_Static();
    1493             : }
    1494             : 
    1495           0 : uno::Sequence< OUString > SAL_CALL SvxUnoTextRangeBase::getSupportedServiceNames_Static()
    1496             :     SAL_THROW(())
    1497             : {
    1498           0 :     uno::Sequence< OUString > aSeq(3);
    1499           0 :     aSeq[0] = "com.sun.star.style.CharacterProperties";
    1500           0 :     aSeq[1] = "com.sun.star.style.CharacterPropertiesComplex";
    1501           0 :     aSeq[2] = "com.sun.star.style.CharacterPropertiesAsian";
    1502           0 :     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           0 : SvxUnoTextRange::SvxUnoTextRange( const SvxUnoTextBase& rParent, bool bPortion /* = false */ ) throw()
    1555           0 : :SvxUnoTextRangeBase( rParent.GetEditSource(), bPortion ? ImplGetSvxTextPortionSvxPropertySet() : rParent.getPropertySet() ),
    1556           0 :  mbPortion( bPortion )
    1557             : {
    1558           0 :     xParentText =  (text::XText*)&rParent;
    1559           0 : }
    1560             : 
    1561           0 : SvxUnoTextRange::~SvxUnoTextRange() throw()
    1562             : {
    1563           0 : }
    1564             : 
    1565           0 : uno::Any SAL_CALL SvxUnoTextRange::queryAggregation( const uno::Type & rType )
    1566             :     throw(uno::RuntimeException, std::exception)
    1567             : {
    1568           0 :     QUERYINT( text::XTextRange );
    1569           0 :     else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertyStates >*)0) )
    1570           0 :         return uno::makeAny(uno::Reference< beans::XMultiPropertyStates >(this));
    1571           0 :     else if( rType == ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) )
    1572           0 :         return uno::makeAny(uno::Reference< beans::XPropertySet >(this));
    1573           0 :     else QUERYINT( beans::XPropertyState );
    1574           0 :     else QUERYINT( text::XTextRangeCompare );
    1575           0 :     else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0) )
    1576           0 :         return uno::makeAny(uno::Reference< beans::XMultiPropertySet >(this));
    1577           0 :     else QUERYINT( lang::XServiceInfo );
    1578           0 :     else QUERYINT( lang::XTypeProvider );
    1579           0 :     else QUERYINT( lang::XUnoTunnel );
    1580             :     else
    1581           0 :         return OWeakAggObject::queryAggregation( rType );
    1582             : }
    1583             : 
    1584           0 : uno::Any SAL_CALL SvxUnoTextRange::queryInterface( const uno::Type & rType )
    1585             :     throw(uno::RuntimeException, std::exception)
    1586             : {
    1587           0 :     return OWeakAggObject::queryInterface(rType);
    1588             : }
    1589             : 
    1590           0 : void SAL_CALL SvxUnoTextRange::acquire()
    1591             :     throw( )
    1592             : {
    1593           0 :     OWeakAggObject::acquire();
    1594           0 : }
    1595             : 
    1596           0 : void SAL_CALL SvxUnoTextRange::release()
    1597             :     throw( )
    1598             : {
    1599           0 :     OWeakAggObject::release();
    1600           0 : }
    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           0 : SvxUnoTextBase::SvxUnoTextBase( const SvxItemPropertySet* _pSet  ) throw()
    1668           0 : : SvxUnoTextRangeBase( _pSet )
    1669             : {
    1670           0 : }
    1671             : 
    1672           0 : SvxUnoTextBase::SvxUnoTextBase( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet, uno::Reference < text::XText > xParent ) throw()
    1673           0 : : SvxUnoTextRangeBase( pSource, _pSet )
    1674             : {
    1675           0 :     xParentText = xParent;
    1676           0 :     ESelection aSelection;
    1677           0 :     ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
    1678           0 :     SetSelection( aSelection );
    1679           0 : }
    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           0 : SvxUnoTextBase::~SvxUnoTextBase() throw()
    1693             : {
    1694           0 : }
    1695             : 
    1696             : // XInterface
    1697           0 : uno::Any SAL_CALL SvxUnoTextBase::queryAggregation( const uno::Type & rType )
    1698             :     throw(uno::RuntimeException, std::exception)
    1699             : {
    1700           0 :     QUERYINT( text::XText );
    1701           0 :     QUERYINT( text::XSimpleText );
    1702           0 :     if( rType == ::getCppuType((const uno::Reference< text::XTextRange >*)0) )
    1703           0 :         return uno::makeAny(uno::Reference< text::XTextRange >((text::XText*)(this)));
    1704           0 :     QUERYINT(container::XEnumerationAccess );
    1705           0 :     QUERYINT( container::XElementAccess );
    1706           0 :     QUERYINT( beans::XMultiPropertyStates );
    1707           0 :     QUERYINT( beans::XPropertySet );
    1708           0 :     QUERYINT( beans::XMultiPropertySet );
    1709           0 :     QUERYINT( beans::XPropertyState );
    1710           0 :     QUERYINT( text::XTextRangeCompare );
    1711           0 :     QUERYINT( lang::XServiceInfo );
    1712           0 :     QUERYINT( text::XTextRangeMover );
    1713           0 :     QUERYINT( text::XTextCopy );
    1714           0 :     QUERYINT( text::XTextAppend );
    1715           0 :     QUERYINT( text::XParagraphAppend );
    1716           0 :     QUERYINT( text::XTextPortionAppend );
    1717           0 :     QUERYINT( lang::XTypeProvider );
    1718           0 :     QUERYINT( lang::XUnoTunnel );
    1719             : 
    1720           0 :     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           0 : uno::Reference< text::XTextCursor > SvxUnoTextBase::createTextCursorBySelection( const ESelection& rSel )
    1775             : {
    1776           0 :     SvxUnoTextCursor* pCursor = new SvxUnoTextCursor( *this );
    1777           0 :     uno::Reference< text::XTextCursor >  xCursor( pCursor );
    1778           0 :     pCursor->SetSelection( rSel );
    1779           0 :     return xCursor;
    1780             : }
    1781             : 
    1782             : // XSimpleText
    1783             : 
    1784           0 : uno::Reference< text::XTextCursor > SAL_CALL SvxUnoTextBase::createTextCursor()
    1785             :     throw(uno::RuntimeException, std::exception)
    1786             : {
    1787           0 :     SolarMutexGuard aGuard;
    1788           0 :     return new SvxUnoTextCursor( *this );
    1789             : }
    1790             : 
    1791           0 : uno::Reference< text::XTextCursor > SAL_CALL SvxUnoTextBase::createTextCursorByRange( const uno::Reference< text::XTextRange >& aTextPosition )
    1792             :     throw(uno::RuntimeException, std::exception)
    1793             : {
    1794           0 :     SolarMutexGuard aGuard;
    1795             : 
    1796           0 :     uno::Reference< text::XTextCursor >  xCursor;
    1797             : 
    1798           0 :     if( aTextPosition.is() )
    1799             :     {
    1800           0 :         SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
    1801           0 :         if(pRange)
    1802           0 :             xCursor = createTextCursorBySelection( pRange->GetSelection() );
    1803             :     }
    1804             : 
    1805           0 :     return xCursor;
    1806             : }
    1807             : 
    1808           0 : 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           0 :     SolarMutexGuard aGuard;
    1812             : 
    1813           0 :     if( !xRange.is() )
    1814           0 :         return;
    1815             : 
    1816           0 :     ESelection aSelection;
    1817           0 :     if (GetEditSource())
    1818             :     {
    1819           0 :         ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
    1820           0 :         SetSelection( aSelection );
    1821             :     }
    1822             : 
    1823           0 :     SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange );
    1824           0 :     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           0 :         if (!bAbsorb)                   // do not replace -> append on tail
    1832           0 :             pRange->CollapseToEnd();
    1833             : 
    1834           0 :         pRange->setString( aString );
    1835             : 
    1836           0 :         pRange->CollapseToEnd();
    1837           0 :     }
    1838             : }
    1839             : 
    1840           0 : 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           0 :     SolarMutexGuard aGuard;
    1844             : 
    1845           0 :     SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL;
    1846             : 
    1847           0 :     if( pForwarder )
    1848             :     {
    1849           0 :         ESelection aSelection;
    1850           0 :         ::GetSelection( aSelection, pForwarder );
    1851           0 :         SetSelection( aSelection );
    1852             : 
    1853           0 :         switch( nControlCharacter )
    1854             :         {
    1855             :         case text::ControlCharacter::PARAGRAPH_BREAK:
    1856             :         {
    1857           0 :             const OUString aText( (sal_Unicode)13 );  // '\r' does not work on Mac
    1858           0 :             insertString( xRange, aText, bAbsorb );
    1859             : 
    1860           0 :             return;
    1861             :         }
    1862             :         case text::ControlCharacter::LINE_BREAK:
    1863             :         {
    1864           0 :             SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange );
    1865           0 :             if(pRange)
    1866             :             {
    1867           0 :                 ESelection aRange = pRange->GetSelection();
    1868             : 
    1869           0 :                 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           0 :                     aRange.nStartPara = aRange.nEndPara;
    1880           0 :                     aRange.nStartPos = aRange.nEndPos;
    1881             :                 }
    1882             : 
    1883           0 :                 pForwarder->QuickInsertLineBreak( aRange );
    1884           0 :                 GetEditSource()->UpdateData();
    1885             : 
    1886           0 :                 aRange.nEndPos += 1;
    1887           0 :                 if( !bAbsorb )
    1888           0 :                     aRange.nStartPos += 1;
    1889             : 
    1890           0 :                 pRange->SetSelection( aRange );
    1891             :             }
    1892           0 :             return;
    1893             :         }
    1894             :         case text::ControlCharacter::APPEND_PARAGRAPH:
    1895             :         {
    1896           0 :             SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange );
    1897           0 :             if(pRange)
    1898             :             {
    1899           0 :                 ESelection aRange = pRange->GetSelection();
    1900             : //              ESelection aOldSelection = aRange;
    1901             : 
    1902           0 :                 aRange.nStartPos  = pForwarder->GetTextLen( aRange.nStartPara );
    1903             : 
    1904           0 :                 aRange.nEndPara = aRange.nStartPara;
    1905           0 :                 aRange.nEndPos  = aRange.nStartPos;
    1906             : 
    1907           0 :                 pRange->SetSelection( aRange );
    1908           0 :                 const OUString aText( (sal_Unicode)13 );  // '\r' geht auf'm Mac nicht
    1909           0 :                 pRange->setString( aText );
    1910             : 
    1911           0 :                 aRange.nStartPos = 0;
    1912           0 :                 aRange.nStartPara += 1;
    1913           0 :                 aRange.nEndPos = 0;
    1914           0 :                 aRange.nEndPara += 1;
    1915             : 
    1916           0 :                 pRange->SetSelection( aRange );
    1917             : 
    1918           0 :                 return;
    1919             :             }
    1920             :         }
    1921             :         default:
    1922           0 :             throw lang::IllegalArgumentException();
    1923             :         }
    1924           0 :     }
    1925             : }
    1926             : 
    1927             : // XText
    1928           0 : 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           0 :     SolarMutexGuard aGuard;
    1932             : 
    1933           0 :     SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL;
    1934           0 :     if (!pForwarder)
    1935           0 :         return;
    1936             : 
    1937           0 :     uno::Reference<beans::XPropertySet> xPropSet(xRange, uno::UNO_QUERY);
    1938           0 :     if (!xPropSet.is())
    1939           0 :         throw lang::IllegalArgumentException();
    1940             : 
    1941           0 :     uno::Any aAny = xPropSet->getPropertyValue(UNO_TR_PROP_SELECTION);
    1942           0 :     text::TextRangeSelection aSel = aAny.get<text::TextRangeSelection>();
    1943           0 :     if (!bAbsorb)
    1944           0 :         aSel.Start = aSel.End;
    1945             : 
    1946           0 :     boost::scoped_ptr<SvxFieldData> pFieldData(SvxFieldData::Create(xContent));
    1947           0 :     if (!pFieldData)
    1948           0 :         throw lang::IllegalArgumentException();
    1949             : 
    1950           0 :     SvxFieldItem aField( *pFieldData, EE_FEATURE_FIELD );
    1951           0 :     pForwarder->QuickInsertField(aField, toESelection(aSel));
    1952           0 :     GetEditSource()->UpdateData();
    1953             : 
    1954           0 :     uno::Reference<beans::XPropertySet> xPropSetContent(xContent, uno::UNO_QUERY);
    1955           0 :     if (!xContent.is())
    1956           0 :         throw lang::IllegalArgumentException();
    1957             : 
    1958           0 :     xPropSetContent->setPropertyValue(UNO_TC_PROP_ANCHOR, uno::makeAny(xRange));
    1959             : 
    1960           0 :     aSel.End.PositionInParagraph += 1;
    1961           0 :     aSel.Start.PositionInParagraph = aSel.End.PositionInParagraph;
    1962           0 :     xPropSet->setPropertyValue(UNO_TR_PROP_SELECTION, uno::makeAny(aSel));
    1963             : }
    1964             : 
    1965           0 : void SAL_CALL SvxUnoTextBase::removeTextContent( const uno::Reference< text::XTextContent >& ) throw(container::NoSuchElementException, uno::RuntimeException, std::exception)
    1966             : {
    1967           0 : }
    1968             : 
    1969             : // XTextRange
    1970             : 
    1971           0 : uno::Reference< text::XText > SAL_CALL SvxUnoTextBase::getText()
    1972             :     throw(uno::RuntimeException, std::exception)
    1973             : {
    1974           0 :     SolarMutexGuard aGuard;
    1975             : 
    1976           0 :     if (GetEditSource())
    1977             :     {
    1978           0 :         ESelection aSelection;
    1979           0 :         ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
    1980           0 :         ((SvxUnoTextBase*)this)->SetSelection( aSelection );
    1981             :     }
    1982             : 
    1983           0 :     return (text::XText*)this;
    1984             : }
    1985             : 
    1986           0 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::getStart()
    1987             :     throw(uno::RuntimeException, std::exception)
    1988             : {
    1989           0 :     return SvxUnoTextRangeBase::getStart();
    1990             : }
    1991             : 
    1992           0 : uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::getEnd()
    1993             :     throw(uno::RuntimeException, std::exception)
    1994             : {
    1995           0 :     return SvxUnoTextRangeBase::getEnd();
    1996             : }
    1997             : 
    1998           0 : OUString SAL_CALL SvxUnoTextBase::getString() throw( uno::RuntimeException, std::exception )
    1999             : {
    2000           0 :     return SvxUnoTextRangeBase::getString();
    2001             : }
    2002             : 
    2003           0 : void SAL_CALL SvxUnoTextBase::setString( const OUString& aString ) throw(uno::RuntimeException, std::exception)
    2004             : {
    2005           0 :     SvxUnoTextRangeBase::setString(aString);
    2006           0 : }
    2007             : 
    2008             : 
    2009             : // XEnumerationAccess
    2010           0 : uno::Reference< container::XEnumeration > SAL_CALL SvxUnoTextBase::createEnumeration()
    2011             :     throw(uno::RuntimeException, std::exception)
    2012             : {
    2013           0 :     SolarMutexGuard aGuard;
    2014             : 
    2015           0 :     ESelection aSelection;
    2016           0 :     ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
    2017           0 :     SetSelection( aSelection );
    2018             : 
    2019           0 :     uno::Reference< container::XEnumeration > xEnum( (container::XEnumeration*) new SvxUnoTextContentEnumeration( *this ) );
    2020           0 :     return xEnum;
    2021             : }
    2022             : 
    2023             : // XElementAccess ( container::XEnumerationAccess )
    2024           0 : uno::Type SAL_CALL SvxUnoTextBase::getElementType(  ) throw(uno::RuntimeException, std::exception)
    2025             : {
    2026           0 :     return ::getCppuType((const uno::Reference< text::XTextRange >*)0 );
    2027             : }
    2028             : 
    2029           0 : sal_Bool SAL_CALL SvxUnoTextBase::hasElements(  ) throw(uno::RuntimeException, std::exception)
    2030             : {
    2031           0 :     SolarMutexGuard aGuard;
    2032             : 
    2033           0 :     if(GetEditSource())
    2034             :     {
    2035           0 :         SvxTextForwarder* pForwarder = GetEditSource()->GetTextForwarder();
    2036           0 :         if(pForwarder)
    2037           0 :             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           0 : 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           0 :     sal_Int32 nProps = rPropertyVaules.getLength();
    2058           0 :     const beans::PropertyValue *pProps = rPropertyVaules.getConstArray();
    2059           0 :     for (sal_Int32 i = 0;  i < nProps;  ++i)
    2060             :     {
    2061           0 :         const SfxItemPropertySimpleEntry *pEntry = pPropSet->getPropertyMap().getByName( pProps[i].Name );
    2062           0 :         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           0 :             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           0 :             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           0 :             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           0 :             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           0 :             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           0 :                 pPropSet->setPropertyValue( pProps[i].Name, pProps[i].Value, rItemSet );
    2116             :         }
    2117             :         else
    2118           0 :             throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + pProps[i].Name, static_cast < cppu::OWeakObject * > ( 0 ) );
    2119             :     }
    2120           0 : }
    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           0 : 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           0 :     SolarMutexGuard aGuard;
    2136             : 
    2137           0 :     uno::Reference< text::XTextRange > xRet;
    2138           0 :     SvxEditSource *pEditSource = GetEditSource();
    2139           0 :     SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : 0;
    2140           0 :     if (pTextForwarder)
    2141             :     {
    2142           0 :         sal_Int32 nParaCount = pTextForwarder->GetParagraphCount();
    2143             :         DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" );
    2144           0 :         pTextForwarder->AppendParagraph();
    2145             : 
    2146             :         // set properties for the previously last paragraph
    2147           0 :         sal_Int32 nPara = nParaCount - 1;
    2148           0 :         ESelection aSel( nPara, 0, nPara, 0 );
    2149           0 :         SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
    2150             :         SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
    2151           0 :                 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           0 :         pRange->SetSelection( aSel );
    2157             :     }
    2158           0 :     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           0 : 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           0 :     SolarMutexGuard aGuard;
    2178             : 
    2179           0 :     SvxEditSource *pEditSource = GetEditSource();
    2180           0 :     SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : 0;
    2181           0 :     uno::Reference< text::XTextRange > xRet;
    2182           0 :     if (pTextForwarder)
    2183             :     {
    2184           0 :         sal_Int32 nParaCount = pTextForwarder->GetParagraphCount();
    2185             :         DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" );
    2186           0 :         sal_Int32 nPara = nParaCount - 1;
    2187           0 :         SfxItemSet aSet( pTextForwarder->GetParaAttribs( nPara ) );
    2188           0 :         sal_Int32 nStart = pTextForwarder->AppendTextPortion( nPara, rText, aSet );
    2189           0 :         pEditSource->UpdateData();
    2190           0 :         sal_Int32 nEnd   = pTextForwarder->GetTextLen( nPara );
    2191             : 
    2192             :         // set properties for the new text portion
    2193           0 :         ESelection aSel( nPara, nStart, nPara, nEnd );
    2194           0 :         pTextForwarder->RemoveAttribs( aSel, false, 0 );
    2195           0 :         pEditSource->UpdateData();
    2196             : 
    2197           0 :         SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
    2198             :         SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
    2199           0 :                 ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, nPara );
    2200           0 :         pTextForwarder->QuickSetAttribs( aItemSet, aSel );
    2201           0 :         SvxUnoTextRange* pRange = new SvxUnoTextRange( *this );
    2202           0 :         xRet = pRange;
    2203           0 :         pRange->SetSelection( aSel );
    2204           0 :         const beans::PropertyValue* pProps = rCharAndParaProps.getConstArray();
    2205           0 :         for( sal_Int32 nProp = 0; nProp < rCharAndParaProps.getLength(); ++nProp )
    2206           0 :             pRange->setPropertyValue( pProps[nProp].Name, pProps[nProp].Value );
    2207             :     }
    2208           0 :     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           0 : uno::Sequence< OUString > SAL_CALL SvxUnoTextBase::getSupportedServiceNames(  )
    2250             :     throw(uno::RuntimeException, std::exception)
    2251             : {
    2252           0 :     return getSupportedServiceNames_Static();
    2253             : }
    2254             : 
    2255           0 : uno::Sequence< OUString > SAL_CALL SvxUnoTextBase::getSupportedServiceNames_Static(  )
    2256             :     SAL_THROW(())
    2257             : {
    2258           0 :     uno::Sequence< OUString > aSeq( SvxUnoTextRangeBase::getSupportedServiceNames_Static() );
    2259           0 :     comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.text.Text" );
    2260           0 :     return aSeq;
    2261             : }
    2262             : 
    2263             : namespace
    2264             : {
    2265             :     class theSvxUnoTextBaseUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSvxUnoTextBaseUnoTunnelId > {};
    2266             : }
    2267             : 
    2268           0 : const uno::Sequence< sal_Int8 > & SvxUnoTextBase::getUnoTunnelId() throw()
    2269             : {
    2270           0 :     return theSvxUnoTextBaseUnoTunnelId::get().getSeq();
    2271             : }
    2272             : 
    2273           0 : SvxUnoTextBase* SvxUnoTextBase::getImplementation( const uno::Reference< uno::XInterface >& xInt )
    2274             : {
    2275           0 :     uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY );
    2276           0 :     if( xUT.is() )
    2277           0 :         return reinterpret_cast<SvxUnoTextBase*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( SvxUnoTextBase::getUnoTunnelId())));
    2278             :     else
    2279           0 :         return NULL;
    2280             : }
    2281             : 
    2282           0 : sal_Int64 SAL_CALL SvxUnoTextBase::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception) \
    2283             : {
    2284           0 :     if( rId.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(),
    2285           0 :                                                          rId.getConstArray(), 16 ) )
    2286             :     {
    2287           0 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
    2288             :     }
    2289             :     else
    2290             :     {
    2291           0 :         return SvxUnoTextRangeBase::getSomething( rId );
    2292             :     }
    2293             : }
    2294             : 
    2295           0 : SvxUnoText::SvxUnoText( const SvxItemPropertySet* _pSet ) throw()
    2296           0 : : SvxUnoTextBase( _pSet )
    2297             : {
    2298           0 : }
    2299             : 
    2300           0 : SvxUnoText::SvxUnoText( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet, uno::Reference < text::XText > xParent ) throw()
    2301           0 : : SvxUnoTextBase( pSource, _pSet, xParent )
    2302             : {
    2303           0 : }
    2304             : 
    2305           0 : SvxUnoText::SvxUnoText( const SvxUnoText& rText ) throw()
    2306             : : SvxUnoTextBase( rText )
    2307           0 : , cppu::OWeakAggObject()
    2308             : {
    2309           0 : }
    2310             : 
    2311           0 : SvxUnoText::~SvxUnoText() throw()
    2312             : {
    2313           0 : }
    2314             : 
    2315             : // uno::XInterface
    2316           0 : uno::Any SAL_CALL SvxUnoText::queryAggregation( const uno::Type & rType ) throw( uno::RuntimeException, std::exception )
    2317             : {
    2318           0 :     uno::Any aAny( SvxUnoTextBase::queryAggregation( rType ) );
    2319           0 :     if( !aAny.hasValue() )
    2320           0 :         aAny = OWeakAggObject::queryAggregation( rType );
    2321             : 
    2322           0 :     return aAny;
    2323             : }
    2324             : 
    2325           0 : uno::Any SAL_CALL SvxUnoText::queryInterface( const uno::Type & rType ) throw( uno::RuntimeException, std::exception )
    2326             : {
    2327           0 :     return OWeakAggObject::queryInterface( rType );
    2328             : }
    2329             : 
    2330           0 : void SAL_CALL SvxUnoText::acquire() throw( )
    2331             : {
    2332           0 :     OWeakAggObject::acquire();
    2333           0 : }
    2334             : 
    2335           0 : void SAL_CALL SvxUnoText::release() throw( )
    2336             : {
    2337           0 :     OWeakAggObject::release();
    2338           0 : }
    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           0 : const uno::Sequence< sal_Int8 > & SvxUnoText::getUnoTunnelId() throw()
    2357             : {
    2358           0 :     return theSvxUnoTextUnoTunnelId::get().getSeq();
    2359             : }
    2360             : 
    2361           0 : sal_Int64 SAL_CALL SvxUnoText::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception) \
    2362             : {
    2363           0 :     if( rId.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(),
    2364           0 :                                                          rId.getConstArray(), 16 ) )
    2365             :     {
    2366           0 :         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
    2367             :     }
    2368             :     else
    2369             :     {
    2370           0 :         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