LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unoport.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 212 421 50.4 %
Date: 2015-06-13 12:38:46 Functions: 23 46 50.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 <unoport.hxx>
      21             : 
      22             : #include <cmdid.h>
      23             : #include <osl/mutex.hxx>
      24             : #include <cppuhelper/exc_hlp.hxx>
      25             : #include <cppuhelper/interfacecontainer.h>
      26             : #include <vcl/svapp.hxx>
      27             : #include <svl/itemprop.hxx>
      28             : 
      29             : #include <unocrsrhelper.hxx>
      30             : #include <unoparaframeenum.hxx>
      31             : #include <unotextrange.hxx>
      32             : #include <unomap.hxx>
      33             : #include <unoprnms.hxx>
      34             : #include <unomid.h>
      35             : #include <txtatr.hxx>
      36             : #include <txtfld.hxx>
      37             : #include <ndtxt.hxx>
      38             : #include <doc.hxx>
      39             : #include <fmtflcnt.hxx>
      40             : #include <fmtfld.hxx>
      41             : #include <frmfmt.hxx>
      42             : 
      43             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      44             : #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
      45             : #include <com/sun/star/beans/GetPropertyTolerantResult.hpp>
      46             : #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
      47             : #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
      48             : #include <comphelper/servicehelper.hxx>
      49             : #include <cppuhelper/supportsservice.hxx>
      50             : 
      51             : using namespace ::com::sun::star;
      52             : 
      53       12486 : class SwXTextPortion::Impl
      54             : {
      55             : private:
      56             :     ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper
      57             : 
      58             : public:
      59             :     ::cppu::OInterfaceContainerHelper m_EventListeners;
      60             : 
      61       12486 :     Impl() : m_EventListeners(m_Mutex) { }
      62             : };
      63             : 
      64       12486 : void SwXTextPortion::init(const SwUnoCrsr* pPortionCursor)
      65             : {
      66       12486 :     m_pUnoCursor = pPortionCursor->GetDoc()->CreateUnoCrsr(*pPortionCursor->GetPoint());
      67       12486 :     if (pPortionCursor->HasMark())
      68             :     {
      69       12486 :         m_pUnoCursor->SetMark();
      70       12486 :         *m_pUnoCursor->GetMark() = *pPortionCursor->GetMark();
      71             :     }
      72       12486 : }
      73             : 
      74       12210 : SwXTextPortion::SwXTextPortion(
      75             :     const SwUnoCrsr* pPortionCrsr,
      76             :         uno::Reference< text::XText > const& rParent,
      77             :         SwTextPortionType eType)
      78       12210 :     : m_pImpl(new Impl)
      79             :     , m_pPropSet(aSwMapProvider.GetPropertySet(
      80       12023 :         (PORTION_REDLINE_START == eType ||
      81             :          PORTION_REDLINE_END   == eType)
      82             :             ?  PROPERTY_MAP_REDLINE_PORTION
      83       12585 :             :  PROPERTY_MAP_TEXTPORTION_EXTENSIONS))
      84             :     , m_xParentText(rParent)
      85             :     , m_FrameDepend(this, 0)
      86             :     , m_pFrameFormat(0)
      87             :     , m_ePortionType(eType)
      88       36630 :     , m_bIsCollapsed(false)
      89             : {
      90       12210 :     init( pPortionCrsr);
      91       12210 : }
      92             : 
      93          32 : SwXTextPortion::SwXTextPortion(
      94             :     const SwUnoCrsr* pPortionCrsr,
      95             :     uno::Reference< text::XText > const& rParent,
      96             :     SwFrameFormat& rFormat )
      97          32 :     : m_pImpl(new Impl)
      98             :     , m_pPropSet(aSwMapProvider.GetPropertySet(
      99          32 :                     PROPERTY_MAP_TEXTPORTION_EXTENSIONS))
     100             :     , m_xParentText(rParent)
     101             :     , m_FrameDepend(this, &rFormat)
     102             :     , m_pFrameFormat(&rFormat)
     103             :     , m_ePortionType(PORTION_FRAME)
     104          96 :     , m_bIsCollapsed(false)
     105             : {
     106          32 :     init( pPortionCrsr);
     107          32 : }
     108             : 
     109         244 : SwXTextPortion::SwXTextPortion(
     110             :     const SwUnoCrsr* pPortionCrsr,
     111             :     SwTextRuby const& rAttr,
     112             :     uno::Reference< text::XText > const& xParent,
     113             :     bool bIsEnd )
     114         244 :     : m_pImpl(new Impl)
     115             :     , m_pPropSet(aSwMapProvider.GetPropertySet(
     116         244 :                     PROPERTY_MAP_TEXTPORTION_EXTENSIONS))
     117             :     , m_xParentText(xParent)
     118         122 :     , m_pRubyText   ( bIsEnd ? 0 : new uno::Any )
     119         122 :     , m_pRubyStyle  ( bIsEnd ? 0 : new uno::Any )
     120         122 :     , m_pRubyAdjust ( bIsEnd ? 0 : new uno::Any )
     121         122 :     , m_pRubyIsAbove( bIsEnd ? 0 : new uno::Any )
     122             :     , m_FrameDepend(this, 0)
     123             :     , m_pFrameFormat(0)
     124             :     , m_ePortionType( bIsEnd ? PORTION_RUBY_END : PORTION_RUBY_START )
     125        1220 :     , m_bIsCollapsed(false)
     126             : {
     127         244 :     init( pPortionCrsr);
     128             : 
     129         244 :     if (!bIsEnd)
     130             :     {
     131         122 :         const SfxPoolItem& rItem = rAttr.GetAttr();
     132         122 :         rItem.QueryValue(*m_pRubyText, MID_RUBY_TEXT);
     133         122 :         rItem.QueryValue(*m_pRubyStyle, MID_RUBY_CHARSTYLE);
     134         122 :         rItem.QueryValue(*m_pRubyAdjust, MID_RUBY_ADJUST);
     135         122 :         rItem.QueryValue(*m_pRubyIsAbove, MID_RUBY_ABOVE);
     136             :     }
     137         244 : }
     138             : 
     139       24597 : SwXTextPortion::~SwXTextPortion()
     140       24597 : { }
     141             : 
     142           0 : uno::Reference< text::XText >  SwXTextPortion::getText()
     143             : throw( uno::RuntimeException, std::exception )
     144             : {
     145           0 :     return m_xParentText;
     146             : }
     147             : 
     148           0 : uno::Reference< text::XTextRange >  SwXTextPortion::getStart()
     149             : throw( uno::RuntimeException, std::exception )
     150             : {
     151           0 :     SolarMutexGuard aGuard;
     152           0 :     uno::Reference< text::XTextRange >  xRet;
     153           0 :     SwUnoCrsr* pUnoCrsr = GetCursor();
     154           0 :     if (!pUnoCrsr)
     155           0 :         throw uno::RuntimeException();
     156             : 
     157           0 :     SwPaM aPam(*pUnoCrsr->Start());
     158           0 :     uno::Reference< text::XText > xParent = getText();
     159           0 :     xRet = new SwXTextRange(aPam, xParent);
     160           0 :     return xRet;
     161             : }
     162             : 
     163           0 : uno::Reference< text::XTextRange >  SwXTextPortion::getEnd()
     164             : throw( uno::RuntimeException, std::exception )
     165             : {
     166           0 :     SolarMutexGuard aGuard;
     167           0 :     uno::Reference< text::XTextRange >  xRet;
     168           0 :     SwUnoCrsr* pUnoCrsr = GetCursor();
     169           0 :     if (!pUnoCrsr)
     170           0 :         throw uno::RuntimeException();
     171             : 
     172           0 :     SwPaM aPam(*pUnoCrsr->End());
     173           0 :     uno::Reference< text::XText > xParent = getText();
     174           0 :     xRet = new SwXTextRange(aPam, xParent);
     175           0 :     return xRet;
     176             : }
     177             : 
     178        3460 : OUString SwXTextPortion::getString()
     179             : throw( uno::RuntimeException, std::exception )
     180             : {
     181        3460 :     SolarMutexGuard aGuard;
     182        3460 :     OUString aText;
     183        3460 :     SwUnoCrsr* pUnoCrsr = GetCursor();
     184        3460 :     if (!pUnoCrsr)
     185           0 :         throw uno::RuntimeException();
     186             : 
     187             :     // TextPortions are always within a paragraph
     188        3460 :     SwTextNode* pTextNd = pUnoCrsr->GetNode().GetTextNode();
     189        3460 :     if ( pTextNd )
     190             :     {
     191        3460 :         const sal_Int32 nStt = pUnoCrsr->Start()->nContent.GetIndex();
     192        6920 :         aText = pTextNd->GetExpandText( nStt,
     193        6920 :                 pUnoCrsr->End()->nContent.GetIndex() - nStt );
     194             :     }
     195        3460 :     return aText;
     196             : }
     197             : 
     198           1 : void SwXTextPortion::setString(const OUString& aString) throw( uno::RuntimeException, std::exception )
     199             : {
     200           1 :     SolarMutexGuard aGuard;
     201           1 :     SwUnoCrsr* pUnoCrsr = GetCursor();
     202           1 :     if (!pUnoCrsr)
     203           0 :         throw uno::RuntimeException();
     204             : 
     205           1 :     SwUnoCursorHelper::SetString(*pUnoCrsr, aString);
     206           1 : }
     207             : 
     208        8129 : uno::Reference< beans::XPropertySetInfo >  SwXTextPortion::getPropertySetInfo()
     209             : throw( uno::RuntimeException, std::exception )
     210             : {
     211        8129 :     SolarMutexGuard aGuard;
     212             :     //! PropertySetInfo for text portion extensions
     213             :     static uno::Reference< beans::XPropertySetInfo >
     214             :             xTextPorExtRef = aSwMapProvider.GetPropertySet(
     215        8129 :                     PROPERTY_MAP_TEXTPORTION_EXTENSIONS)->getPropertySetInfo();
     216             :     //! PropertySetInfo for redline portions
     217             :     static uno::Reference< beans::XPropertySetInfo >
     218             :             xRedlPorRef = aSwMapProvider.GetPropertySet(
     219        8129 :                     PROPERTY_MAP_REDLINE_PORTION)->getPropertySetInfo();
     220             : 
     221       16256 :     return (PORTION_REDLINE_START == m_ePortionType ||
     222        8133 :             PORTION_REDLINE_END   == m_ePortionType) ? xRedlPorRef : xTextPorExtRef;
     223             : }
     224             : 
     225          49 : void SwXTextPortion::setPropertyValue(const OUString& rPropertyName,
     226             :     const uno::Any& aValue)
     227             :     throw( beans::UnknownPropertyException,
     228             :         beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     229             : {
     230          49 :     SolarMutexGuard aGuard;
     231          49 :     SwUnoCrsr* pUnoCrsr = GetCursor();
     232          49 :     if (!pUnoCrsr)
     233           0 :         throw uno::RuntimeException();
     234             : 
     235             :     SwUnoCursorHelper::SetPropertyValue(*pUnoCrsr, *m_pPropSet,
     236          49 :             rPropertyName, aValue);
     237          49 : }
     238             : 
     239       15773 : void SwXTextPortion::GetPropertyValue(
     240             :         uno::Any &rVal,
     241             :         const SfxItemPropertySimpleEntry& rEntry,
     242             :         SwUnoCrsr *pUnoCrsr,
     243             :         SfxItemSet *&pSet )
     244             : {
     245             :     OSL_ENSURE( pUnoCrsr, "UNO cursor missing" );
     246       15773 :     if (!pUnoCrsr)
     247       15773 :         return;
     248       15773 :     if(pUnoCrsr)
     249             :     {
     250       15773 :         switch(rEntry.nWID)
     251             :         {
     252             :             case FN_UNO_TEXT_PORTION_TYPE:
     253             :             {
     254             :                 const char* pRet;
     255        6240 :                 switch (m_ePortionType)
     256             :                 {
     257        3385 :                 case PORTION_TEXT:          pRet = "Text";break;
     258         179 :                 case PORTION_FIELD:         pRet = "TextField";break;
     259          50 :                 case PORTION_FRAME:         pRet = "Frame";break;
     260          18 :                 case PORTION_FOOTNOTE:      pRet = "Footnote";break;
     261             :                 case PORTION_REFMARK_START:
     262          46 :                 case PORTION_REFMARK_END:   pRet = UNO_NAME_REFERENCE_MARK;break;
     263             :                 case PORTION_TOXMARK_START:
     264          45 :                 case PORTION_TOXMARK_END:   pRet = UNO_NAME_DOCUMENT_INDEX_MARK;break;
     265             :                 case PORTION_BOOKMARK_START :
     266        2059 :                 case PORTION_BOOKMARK_END : pRet = UNO_NAME_BOOKMARK;break;
     267             :                 case PORTION_REDLINE_START:
     268           0 :                 case PORTION_REDLINE_END:   pRet = "Redline";break;
     269             :                 case PORTION_RUBY_START:
     270         244 :                 case PORTION_RUBY_END:      pRet = "Ruby";break;
     271          12 :                 case PORTION_SOFT_PAGEBREAK:pRet = "SoftPageBreak";break;
     272         145 :                 case PORTION_META:          pRet = UNO_NAME_META; break;
     273           2 :                 case PORTION_FIELD_START:pRet = "TextFieldStart";break;
     274           0 :                 case PORTION_FIELD_END:pRet = "TextFieldEnd";break;
     275           1 :                 case PORTION_FIELD_START_END:pRet = "TextFieldStartEnd";break;
     276             :                 case PORTION_ANNOTATION:
     277          36 :                     pRet = "Annotation";
     278          36 :                     break;
     279             :                 case PORTION_ANNOTATION_END:
     280          18 :                     pRet = "AnnotationEnd";
     281          18 :                     break;
     282             :                 default:
     283           0 :                     pRet = 0;
     284             :                 }
     285             : 
     286        6240 :                 OUString sRet;
     287        6240 :                 if( pRet )
     288        6240 :                     sRet = OUString::createFromAscii( pRet );
     289        6240 :                 rVal <<= sRet;
     290             :             }
     291       19609 :             break;
     292             :             case FN_UNO_CONTROL_CHARACTER: // obsolete!
     293           0 :             break;
     294             :             case FN_UNO_DOCUMENT_INDEX_MARK:
     295          47 :                 rVal <<= m_xTOXMark;
     296          47 :             break;
     297             :             case FN_UNO_REFERENCE_MARK:
     298          46 :                 rVal <<= m_xRefMark;
     299          46 :             break;
     300             :             case FN_UNO_BOOKMARK:
     301        2054 :                 rVal <<= m_xBookmark;
     302        2054 :             break;
     303             :             case FN_UNO_FOOTNOTE:
     304          18 :                 rVal <<= m_xFootnote;
     305          18 :             break;
     306             :             case FN_UNO_TEXT_FIELD:
     307         210 :                 rVal <<= m_xTextField;
     308         210 :             break;
     309             :             case FN_UNO_META:
     310         145 :                 rVal <<= m_xMeta;
     311         145 :             break;
     312             :             case FN_UNO_IS_COLLAPSED:
     313             :             {
     314        2147 :                 switch (m_ePortionType)
     315             :                 {
     316             :                     case PORTION_REFMARK_START:
     317             :                     case PORTION_BOOKMARK_START :
     318             :                     case PORTION_TOXMARK_START:
     319             :                     case PORTION_REFMARK_END:
     320             :                     case PORTION_TOXMARK_END:
     321             :                     case PORTION_BOOKMARK_END :
     322             :                     case PORTION_REDLINE_START :
     323             :                     case PORTION_REDLINE_END :
     324             :                     case PORTION_RUBY_START:
     325             :                     case PORTION_RUBY_END:
     326             :                     case PORTION_FIELD_START:
     327             :                     case PORTION_FIELD_END:
     328        2147 :                         rVal <<= m_bIsCollapsed;
     329        2147 :                     break;
     330             :                     default:
     331           0 :                     break;
     332             :                 }
     333             :             }
     334        2147 :             break;
     335             :             case FN_UNO_IS_START:
     336             :             {
     337        2322 :                 bool bStart = true, bPut = true;
     338        2322 :                 switch (m_ePortionType)
     339             :                 {
     340             :                     case PORTION_REFMARK_START:
     341             :                     case PORTION_BOOKMARK_START:
     342             :                     case PORTION_TOXMARK_START:
     343             :                     case PORTION_REDLINE_START:
     344             :                     case PORTION_RUBY_START:
     345             :                     case PORTION_FIELD_START:
     346        1161 :                     break;
     347             : 
     348             :                     case PORTION_REFMARK_END:
     349             :                     case PORTION_TOXMARK_END:
     350             :                     case PORTION_BOOKMARK_END:
     351             :                     case PORTION_REDLINE_END:
     352             :                     case PORTION_RUBY_END:
     353             :                     case PORTION_FIELD_END:
     354        1161 :                         bStart = false;
     355        1161 :                     break;
     356             :                     default:
     357           0 :                         bPut = false;
     358             :                 }
     359        2322 :                 if(bPut)
     360        2322 :                     rVal <<= bStart;
     361             :             }
     362        2322 :             break;
     363             :             case RES_TXTATR_CJK_RUBY:
     364             :             {
     365         140 :                 const uno::Any* pToSet = 0;
     366         140 :                 switch(rEntry.nMemberId)
     367             :                 {
     368         122 :                     case MID_RUBY_TEXT :    pToSet = m_pRubyText.get();   break;
     369           6 :                     case MID_RUBY_ADJUST :  pToSet = m_pRubyAdjust.get(); break;
     370           6 :                     case MID_RUBY_CHARSTYLE:pToSet = m_pRubyStyle.get();  break;
     371           6 :                     case MID_RUBY_ABOVE :   pToSet = m_pRubyIsAbove.get();break;
     372             :                 }
     373         140 :                 if(pToSet)
     374         140 :                     rVal = *pToSet;
     375             :             }
     376         140 :             break;
     377             :             default:
     378             :                 beans::PropertyState eTemp;
     379             :                 bool bDone = SwUnoCursorHelper::getCrsrPropertyValue(
     380        2404 :                                     rEntry, *pUnoCrsr, &(rVal), eTemp );
     381        2404 :                 if(!bDone)
     382             :                 {
     383        2305 :                     if(!pSet)
     384             :                     {
     385        1460 :                         pSet = new SfxItemSet(pUnoCrsr->GetDoc()->GetAttrPool(),
     386             :                             RES_CHRATR_BEGIN, RES_FRMATR_END - 1,
     387             :                             RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
     388             :                             RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
     389        1460 :                             0L);
     390        1460 :                         SwUnoCursorHelper::GetCrsrAttr(*pUnoCrsr, *pSet);
     391             :                     }
     392        2305 :                     m_pPropSet->getPropertyValue(rEntry, *pSet, rVal);
     393             :                 }
     394             :         }
     395             :     }
     396             : }
     397             : 
     398       14662 : uno::Sequence< uno::Any > SAL_CALL SwXTextPortion::GetPropertyValues_Impl(
     399             :         const uno::Sequence< OUString >& rPropertyNames )
     400             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
     401             : {
     402       14662 :     sal_Int32 nLength = rPropertyNames.getLength();
     403       14662 :     const OUString *pPropertyNames = rPropertyNames.getConstArray();
     404       14662 :     uno::Sequence< uno::Any > aValues(rPropertyNames.getLength());
     405       14662 :     uno::Any *pValues = aValues.getArray();
     406       14662 :     SwUnoCrsr* pUnoCrsr = GetCursor();
     407       14662 :     if (!pUnoCrsr)
     408           0 :         throw uno::RuntimeException();
     409             : 
     410             :     {
     411       14662 :         SfxItemSet *pSet = 0;
     412             :         // get startting pount fo the look-up, either the provided one or else
     413             :         // from the beginning of the map
     414       14662 :         const SfxItemPropertyMap& rMap = m_pPropSet->getPropertyMap();
     415       29324 :         for(sal_Int32 nProp = 0; nProp < nLength; nProp++)
     416             :         {
     417       14662 :             const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pPropertyNames[nProp]);
     418       14662 :             if(pEntry)
     419             :             {
     420       14662 :                 GetPropertyValue( pValues[nProp], *pEntry, pUnoCrsr, pSet );
     421             :             }
     422             :             else
     423           0 :                 throw beans::UnknownPropertyException( "Unknown property: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
     424             :         }
     425       14662 :         delete pSet;
     426             :     }
     427       14662 :     return aValues;
     428             : }
     429             : 
     430       14662 : uno::Any SwXTextPortion::getPropertyValue(
     431             :     const OUString& rPropertyName)
     432             :         throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     433             : {
     434       14662 :     SolarMutexGuard aGuard;
     435       29324 :     uno::Sequence< OUString > aPropertyNames(1);
     436       14662 :     aPropertyNames.getArray()[0] = rPropertyName;
     437       29324 :     return GetPropertyValues_Impl(aPropertyNames).getConstArray()[0];
     438             : }
     439             : 
     440           0 : void SAL_CALL SwXTextPortion::SetPropertyValues_Impl(
     441             :     const uno::Sequence< OUString >& rPropertyNames,
     442             :     const uno::Sequence< uno::Any >& rValues )
     443             :     throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
     444             :             lang::WrappedTargetException, uno::RuntimeException)
     445             : {
     446           0 :     SwUnoCrsr* pUnoCrsr = GetCursor();
     447           0 :     if (!pUnoCrsr)
     448           0 :         throw uno::RuntimeException();
     449             : 
     450             :     {
     451           0 :         const OUString* pPropertyNames = rPropertyNames.getConstArray();
     452           0 :         const uno::Any* pValues = rValues.getConstArray();
     453           0 :         const SfxItemPropertyMap& rMap = m_pPropSet->getPropertyMap();
     454           0 :         uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
     455           0 :         for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
     456             :         {
     457           0 :             const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pPropertyNames[nProp]);
     458           0 :             if (!pEntry)
     459           0 :                 throw beans::UnknownPropertyException( "Unknown property: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
     460           0 :             if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
     461           0 :                 throw beans::PropertyVetoException ("Property is read-only: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
     462             : 
     463           0 :             aValues[nProp].Name = pPropertyNames[nProp];
     464           0 :             aValues[nProp].Value = pValues[nProp];
     465             :         }
     466           0 :         SwUnoCursorHelper::SetPropertyValues( *pUnoCrsr, *m_pPropSet, aValues );
     467             :     }
     468           0 : }
     469             : 
     470           0 : void SwXTextPortion::setPropertyValues(
     471             :     const uno::Sequence< OUString >& rPropertyNames,
     472             :     const uno::Sequence< uno::Any >& rValues )
     473             :         throw(beans::PropertyVetoException, lang::IllegalArgumentException,
     474             :             lang::WrappedTargetException, uno::RuntimeException, std::exception)
     475             : {
     476           0 :     SolarMutexGuard aGuard;
     477             : 
     478             :     // workaround for bad designed API
     479             :     try
     480             :     {
     481           0 :         SetPropertyValues_Impl( rPropertyNames, rValues );
     482             :     }
     483           0 :     catch (const beans::UnknownPropertyException &rException)
     484             :     {
     485             :         // wrap the original (here not allowed) exception in
     486             :         // a lang::WrappedTargetException that gets thrown instead.
     487           0 :         lang::WrappedTargetException aWExc;
     488           0 :         aWExc.TargetException <<= rException;
     489           0 :         throw aWExc;
     490           0 :     }
     491           0 : }
     492             : 
     493           0 : uno::Sequence< uno::Any > SwXTextPortion::getPropertyValues(
     494             :     const uno::Sequence< OUString >& rPropertyNames )
     495             :         throw(uno::RuntimeException, std::exception)
     496             : {
     497           0 :     SolarMutexGuard aGuard;
     498           0 :     uno::Sequence< uno::Any > aValues;
     499             : 
     500             :     // workaround for bad designed API
     501             :     try
     502             :     {
     503           0 :         aValues = GetPropertyValues_Impl( rPropertyNames );
     504             :     }
     505           0 :     catch (beans::UnknownPropertyException &)
     506             :     {
     507           0 :         throw uno::RuntimeException("Unknown property exception caught", static_cast < cppu::OWeakObject * > ( this ) );
     508             :     }
     509           0 :     catch (lang::WrappedTargetException &)
     510             :     {
     511           0 :         throw uno::RuntimeException("WrappedTargetException caught", static_cast < cppu::OWeakObject * > ( this ) );
     512             :     }
     513             : 
     514           0 :     return aValues;
     515             : }
     516             : 
     517             : /* disabled for #i46921# */
     518           0 : uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXTextPortion::setPropertyValuesTolerant(
     519             :         const uno::Sequence< OUString >& rPropertyNames,
     520             :         const uno::Sequence< uno::Any >& rValues )
     521             :     throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
     522             : {
     523           0 :     SolarMutexGuard aGuard;
     524             : 
     525           0 :     if (rPropertyNames.getLength() != rValues.getLength())
     526           0 :         throw lang::IllegalArgumentException();
     527           0 :     SwUnoCrsr* pUnoCrsr = this->GetCursor();
     528           0 :     if (!pUnoCrsr)
     529           0 :         throw uno::RuntimeException();
     530             : 
     531           0 :     sal_Int32 nProps = rPropertyNames.getLength();
     532           0 :     const OUString *pProp = rPropertyNames.getConstArray();
     533             : 
     534             :     //sal_Int32 nVals = rValues.getLength();
     535           0 :     const uno::Any *pValue = rValues.getConstArray();
     536             : 
     537           0 :     sal_Int32 nFailed = 0;
     538           0 :     uno::Sequence< beans::SetPropertyTolerantFailed > aFailed( nProps );
     539           0 :     beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray();
     540             : 
     541           0 :     const SfxItemPropertyMap& rPropMap = m_pPropSet->getPropertyMap();
     542             : 
     543           0 :     for (sal_Int32 i = 0;  i < nProps;  ++i)
     544             :     {
     545             :         try
     546             :         {
     547           0 :             pFailed[ nFailed ].Name    = pProp[i];
     548             : 
     549           0 :             const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName( pProp[i] );
     550           0 :             if (!pEntry)
     551           0 :                 pFailed[ nFailed++ ].Result  = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
     552             :             else
     553             :             {
     554             :                 // set property value
     555             :                 // (compare to SwXTextPortion::setPropertyValues)
     556           0 :                 if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
     557           0 :                     pFailed[ nFailed++ ].Result  = beans::TolerantPropertySetResultType::PROPERTY_VETO;
     558             :                 else
     559             :                 {
     560             :                     SwUnoCursorHelper::SetPropertyValue(
     561           0 :                                 *pUnoCrsr, *m_pPropSet, pProp[i], pValue[i] );
     562             :                 }
     563             :             }
     564             :         }
     565           0 :         catch (beans::UnknownPropertyException &)
     566             :         {
     567             :             // should not occur because property was searched for before
     568             :             OSL_FAIL( "unexpected exception caught" );
     569           0 :             pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
     570             :         }
     571           0 :         catch (lang::IllegalArgumentException &)
     572             :         {
     573           0 :             pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
     574             :         }
     575           0 :         catch (beans::PropertyVetoException &)
     576             :         {
     577           0 :             pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
     578             :         }
     579           0 :         catch (lang::WrappedTargetException &)
     580             :         {
     581           0 :             pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
     582             :         }
     583             :     }
     584             : 
     585           0 :     aFailed.realloc( nFailed );
     586           0 :     return aFailed;
     587             : }
     588             : 
     589           0 : uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL SwXTextPortion::getPropertyValuesTolerant(
     590             :         const uno::Sequence< OUString >& rPropertyNames )
     591             :     throw (uno::RuntimeException, std::exception)
     592             : {
     593           0 :     SolarMutexGuard aGuard;
     594             : 
     595             :     uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes(
     596           0 :             GetPropertyValuesTolerant_Impl( rPropertyNames, false ) );
     597           0 :     const beans::GetDirectPropertyTolerantResult *pTmpRes = aTmpRes.getConstArray();
     598             : 
     599             :     // copy temporary result to final result type
     600           0 :     sal_Int32 nLen = aTmpRes.getLength();
     601           0 :     uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen );
     602           0 :     beans::GetPropertyTolerantResult *pRes = aRes.getArray();
     603           0 :     for (sal_Int32 i = 0;  i < nLen;  i++)
     604           0 :         *pRes++ = *pTmpRes++;
     605           0 :     return aRes;
     606             : }
     607             : 
     608        2870 : uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion::getDirectPropertyValuesTolerant(
     609             :         const uno::Sequence< OUString >& rPropertyNames )
     610             :     throw (uno::RuntimeException, std::exception)
     611             : {
     612        2870 :     SolarMutexGuard aGuard;
     613        2870 :     return GetPropertyValuesTolerant_Impl( rPropertyNames, true );
     614             : }
     615             : 
     616        2870 : uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion::GetPropertyValuesTolerant_Impl(
     617             :         const uno::Sequence< OUString >& rPropertyNames,
     618             :         bool bDirectValuesOnly )
     619             :     throw (uno::RuntimeException, std::exception)
     620             : {
     621        2870 :     SolarMutexGuard aGuard;
     622             : 
     623        2870 :     SwUnoCrsr* pUnoCrsr = this->GetCursor();
     624        2870 :     if(!pUnoCrsr)
     625           0 :         throw uno::RuntimeException();
     626             : 
     627        5740 :     std::vector< beans::GetDirectPropertyTolerantResult > aResultVector;
     628             : 
     629             :     try
     630             :     {
     631        2870 :         sal_Int32 nProps = rPropertyNames.getLength();
     632        2870 :         const OUString *pProp = rPropertyNames.getConstArray();
     633             : 
     634        2870 :         SfxItemSet *pSet = 0;
     635             : 
     636        2870 :         const SfxItemPropertyMap& rPropMap = m_pPropSet->getPropertyMap();
     637             : 
     638             : 
     639             :         uno::Sequence< beans::PropertyState > aPropertyStates =
     640             :             SwUnoCursorHelper::GetPropertyStates(
     641             :                 *pUnoCrsr, *m_pPropSet,
     642             :                 rPropertyNames,
     643        2870 :                 SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT );
     644        2870 :         const beans::PropertyState* pPropertyStates = aPropertyStates.getConstArray();
     645             : 
     646      214818 :         for (sal_Int32 i = 0;  i < nProps;  ++i)
     647             :         {
     648      211948 :             beans::GetDirectPropertyTolerantResult aResult;
     649             :             try
     650             :             {
     651      211948 :                 aResult.Name = pProp[i];
     652      211948 :                 if(pPropertyStates[i] == beans::PropertyState_MAKE_FIXED_SIZE)     // property unknown?
     653             :                 {
     654           0 :                     if( bDirectValuesOnly )
     655           0 :                         continue;
     656             :                     else
     657           0 :                         aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
     658             :                 }
     659             :                 else
     660             :                 {
     661      211948 :                     const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName( pProp[i] );
     662      211948 :                     if (!pEntry)
     663           0 :                         throw beans::UnknownPropertyException( "Unknown property: " + pProp[i], static_cast < cppu::OWeakObject * > ( this ) );
     664      211948 :                     aResult.State  = pPropertyStates[i];
     665             : 
     666      211948 :                     aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
     667             :                     //#i104499# ruby portion attributes need special handling:
     668      211960 :                     if( pEntry->nWID == RES_TXTATR_CJK_RUBY &&
     669          12 :                         m_ePortionType == PORTION_RUBY_START )
     670             :                     {
     671          12 :                             aResult.State = beans::PropertyState_DIRECT_VALUE;
     672             :                     }
     673      211948 :                     if (!bDirectValuesOnly  ||  beans::PropertyState_DIRECT_VALUE == aResult.State)
     674             :                     {
     675             :                         // get property value
     676             :                         // (compare to SwXTextPortion::getPropertyValue(s))
     677        1111 :                         GetPropertyValue( aResult.Value, *pEntry, pUnoCrsr, pSet );
     678        1111 :                         aResult.Result = beans::TolerantPropertySetResultType::SUCCESS;
     679        1111 :                         aResultVector.push_back( aResult );
     680             :                     }
     681             :                 }
     682             :             }
     683           0 :             catch (const beans::UnknownPropertyException &)
     684             :             {
     685             :                 // should not occur because property was searched for before
     686             :                 OSL_FAIL( "unexpected exception caught" );
     687           0 :                 aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
     688             :             }
     689           0 :             catch (const lang::IllegalArgumentException &)
     690             :             {
     691           0 :                 aResult.Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
     692             :             }
     693           0 :             catch (const beans::PropertyVetoException &)
     694             :             {
     695           0 :                 aResult.Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
     696             :             }
     697           0 :             catch (const lang::WrappedTargetException &)
     698             :             {
     699           0 :                 aResult.Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
     700             :             }
     701      211948 :         }
     702        2870 :         delete pSet;
     703             :     }
     704           0 :     catch (const uno::RuntimeException&)
     705             :     {
     706           0 :         throw;
     707             :     }
     708           0 :     catch (const uno::Exception& e)
     709             :     {
     710           0 :         css::uno::Any a(cppu::getCaughtException());
     711             :         throw css::lang::WrappedTargetRuntimeException(
     712           0 :             "wrapped Exception " + e.Message,
     713           0 :             css::uno::Reference<css::uno::XInterface>(), a);
     714             :     }
     715             : 
     716        2870 :     uno::Sequence< beans::GetDirectPropertyTolerantResult > aResult( aResultVector.size() );
     717        2870 :     std::vector< beans::GetDirectPropertyTolerantResult >::const_iterator aIt = aResultVector.begin();
     718        2870 :     beans::GetDirectPropertyTolerantResult *pResult = aResult.getArray();
     719        3981 :     for( sal_Int32 nResult = 0; nResult < aResult.getLength(); ++nResult )
     720             :     {
     721        1111 :         pResult[nResult] = *aIt;
     722        1111 :         ++aIt;
     723             :     }
     724             : 
     725        5740 :     return aResult;
     726             : }
     727             : 
     728           0 : void SwXTextPortion::addPropertiesChangeListener(
     729             :     const uno::Sequence< OUString >& /*aPropertyNames*/,
     730             :     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
     731             :         throw(uno::RuntimeException, std::exception)
     732           0 : {}
     733             : 
     734           0 : void SwXTextPortion::removePropertiesChangeListener(
     735             :     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
     736             :         throw(uno::RuntimeException, std::exception)
     737           0 : {}
     738             : 
     739           0 : void SwXTextPortion::firePropertiesChangeEvent(
     740             :     const uno::Sequence< OUString >& /*aPropertyNames*/,
     741             :     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
     742             :         throw(uno::RuntimeException, std::exception)
     743           0 : {}
     744             : 
     745           0 : void SwXTextPortion::addPropertyChangeListener(
     746             :     const OUString& /*PropertyName*/,
     747             :     const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
     748             :         throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     749             : {
     750             :     OSL_FAIL("not implemented");
     751           0 : }
     752             : 
     753           0 : void SwXTextPortion::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     754             : {
     755             :     OSL_FAIL("not implemented");
     756           0 : }
     757             : 
     758           0 : void SwXTextPortion::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     759             : {
     760             :     OSL_FAIL("not implemented");
     761           0 : }
     762             : 
     763           0 : void SwXTextPortion::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     764             : {
     765             :     OSL_FAIL("not implemented");
     766           0 : }
     767             : 
     768          95 : beans::PropertyState SwXTextPortion::getPropertyState(const OUString& rPropertyName)
     769             :             throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception )
     770             : {
     771          95 :     SolarMutexGuard aGuard;
     772          95 :     beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE;
     773          95 :     SwUnoCrsr* pUnoCrsr = GetCursor();
     774          95 :     if (!pUnoCrsr)
     775           0 :         throw uno::RuntimeException();
     776             : 
     777          95 :     if (GetTextPortionType() == PORTION_RUBY_START &&
     778           0 :         rPropertyName.startsWith("Ruby"))
     779             :     {
     780           0 :         eRet = beans::PropertyState_DIRECT_VALUE;
     781             :     }
     782             :     else
     783             :     {
     784             :         eRet = SwUnoCursorHelper::GetPropertyState(*pUnoCrsr, *m_pPropSet,
     785          95 :                 rPropertyName);
     786             :     }
     787          95 :     return eRet;
     788             : }
     789             : 
     790           0 : uno::Sequence< beans::PropertyState > SwXTextPortion::getPropertyStates(
     791             :         const uno::Sequence< OUString >& rPropertyNames)
     792             :         throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception )
     793             : {
     794           0 :     SolarMutexGuard aGuard;
     795           0 :     SwUnoCrsr* pUnoCrsr = GetCursor();
     796           0 :     if(!pUnoCrsr)
     797           0 :         throw uno::RuntimeException();
     798             : 
     799             :     uno::Sequence< beans::PropertyState > aRet =
     800             :         SwUnoCursorHelper::GetPropertyStates(*pUnoCrsr, *m_pPropSet,
     801           0 :                 rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION);
     802             : 
     803           0 :     if(GetTextPortionType() == PORTION_RUBY_START)
     804             :     {
     805           0 :         const OUString* pNames = rPropertyNames.getConstArray();
     806           0 :         beans::PropertyState* pStates = aRet.getArray();
     807           0 :         for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength();nProp++)
     808             :         {
     809           0 :             if (pNames[nProp].startsWith("Ruby"))
     810           0 :                 pStates[nProp] = beans::PropertyState_DIRECT_VALUE;
     811             :         }
     812             :     }
     813           0 :     return aRet;
     814             : }
     815             : 
     816           0 : void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName)
     817             :                 throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception )
     818             : {
     819           0 :     SolarMutexGuard aGuard;
     820           0 :     SwUnoCrsr* pUnoCrsr = GetCursor();
     821           0 :     if (!pUnoCrsr)
     822           0 :         throw uno::RuntimeException();
     823             : 
     824             :     SwUnoCursorHelper::SetPropertyToDefault(
     825           0 :             *pUnoCrsr, *m_pPropSet, rPropertyName);
     826           0 : }
     827             : 
     828           0 : uno::Any SwXTextPortion::getPropertyDefault(const OUString& rPropertyName)
     829             :         throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     830             : {
     831           0 :     SolarMutexGuard aGuard;
     832           0 :     uno::Any aRet;
     833           0 :     SwUnoCrsr* pUnoCrsr = GetCursor();
     834           0 :     if (!pUnoCrsr)
     835           0 :         throw uno::RuntimeException();
     836             : 
     837           0 :     aRet = SwUnoCursorHelper::GetPropertyDefault(*pUnoCrsr, *m_pPropSet,
     838           0 :                 rPropertyName);
     839           0 :     return aRet;
     840             : }
     841             : 
     842         161 : uno::Reference< container::XEnumeration >  SwXTextPortion::createContentEnumeration(const OUString& /*aServiceName*/)
     843             :         throw( uno::RuntimeException, std::exception )
     844             : {
     845         161 :     SolarMutexGuard aGuard;
     846         161 :     SwUnoCrsr* pUnoCrsr = GetCursor();
     847         161 :     if(!pUnoCrsr)
     848           0 :         throw uno::RuntimeException();
     849             : 
     850         161 :     return SwXParaFrameEnumeration::Create(*pUnoCrsr, PARAFRAME_PORTION_CHAR, m_pFrameFormat);
     851             : }
     852             : 
     853             : namespace
     854             : {
     855             :     class theSwXTextPortionUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextPortionUnoTunnelId > {};
     856             : }
     857             : 
     858       66218 : const uno::Sequence< sal_Int8 > & SwXTextPortion::getUnoTunnelId()
     859             : {
     860       66218 :     return theSwXTextPortionUnoTunnelId::get().getSeq();
     861             : }
     862             : 
     863           0 : sal_Int64 SwXTextPortion::getSomething( const uno::Sequence< sal_Int8 >& rId )
     864             :     throw(uno::RuntimeException, std::exception)
     865             : {
     866           0 :     if( rId.getLength() == 16
     867           0 :         && 0 == memcmp( getUnoTunnelId().getConstArray(),
     868           0 :                                         rId.getConstArray(), 16 ) )
     869             :     {
     870           0 :         return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
     871             :     }
     872           0 :     return 0;
     873             : }
     874             : 
     875           0 : uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames()
     876             : throw( uno::RuntimeException, std::exception )
     877             : {
     878           0 :     SolarMutexGuard aGuard;
     879           0 :     uno::Sequence< OUString > aRet(1);
     880           0 :     OUString* pArray = aRet.getArray();
     881           0 :     pArray[0] = "com.sun.star.text.TextContent";
     882           0 :     return aRet;
     883             : }
     884             : 
     885           0 : OUString SwXTextPortion::getImplementationName()
     886             : throw( uno::RuntimeException, std::exception )
     887             : {
     888           0 :     return OUString("SwXTextPortion");
     889             : }
     890             : 
     891           0 : sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
     892             : {
     893           0 :     return cppu::supportsService(this, rServiceName);
     894             : }
     895             : 
     896           0 : uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames()
     897             : throw( uno::RuntimeException, std::exception )
     898             : {
     899           0 :     SolarMutexGuard aGuard;
     900           0 :     SwUnoCrsr* pUnoCrsr = GetCursor();
     901           0 :     if (!pUnoCrsr)
     902           0 :         throw uno::RuntimeException();
     903             : 
     904           0 :     uno::Sequence< OUString > aRet(7);
     905           0 :     OUString* pArray = aRet.getArray();
     906           0 :     pArray[0] = "com.sun.star.text.TextPortion";
     907           0 :     pArray[1] = "com.sun.star.style.CharacterProperties";
     908           0 :     pArray[2] = "com.sun.star.style.CharacterPropertiesAsian";
     909           0 :     pArray[3] = "com.sun.star.style.CharacterPropertiesComplex";
     910           0 :     pArray[4] = "com.sun.star.style.ParagraphProperties";
     911           0 :     pArray[5] = "com.sun.star.style.ParagraphPropertiesAsian";
     912           0 :     pArray[6] = "com.sun.star.style.ParagraphPropertiesComplex";
     913           0 :     return aRet;
     914             : }
     915             : 
     916         101 : void SwXTextPortion::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
     917             : {
     918         101 :     ClientModify(this, pOld, pNew);
     919         101 :     if (!m_FrameDepend.GetRegisteredIn())
     920             :     {
     921           0 :         m_pFrameFormat = nullptr;
     922             :     }
     923         278 : }
     924             : 
     925             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11