LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unoparagraph.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 319 586 54.4 %
Date: 2015-06-13 12:38:46 Functions: 45 67 67.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <unoparagraph.hxx>
      21             : 
      22             : #include <cppuhelper/interfacecontainer.h>
      23             : #include <cppuhelper/supportsservice.hxx>
      24             : 
      25             : #include <cmdid.h>
      26             : #include <unomid.h>
      27             : #include <unoparaframeenum.hxx>
      28             : #include <unotext.hxx>
      29             : #include <unotextrange.hxx>
      30             : #include <unoport.hxx>
      31             : #include <unomap.hxx>
      32             : #include <unocrsr.hxx>
      33             : #include <unoprnms.hxx>
      34             : #include <unocrsrhelper.hxx>
      35             : #include <doc.hxx>
      36             : #include <ndtxt.hxx>
      37             : #include <osl/mutex.hxx>
      38             : #include <vcl/svapp.hxx>
      39             : #include <docsh.hxx>
      40             : 
      41             : #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
      42             : #include <com/sun/star/beans/GetPropertyTolerantResult.hpp>
      43             : #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
      44             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      45             : #include <com/sun/star/text/WrapTextMode.hpp>
      46             : #include <com/sun/star/text/TextContentAnchorType.hpp>
      47             : #include <comphelper/servicehelper.hxx>
      48             : #include <boost/scoped_ptr.hpp>
      49             : 
      50             : //UUUU
      51             : #include <swunohelper.hxx>
      52             : #include <svx/unobrushitemhelper.hxx>
      53             : #include <editeng/unoipset.hxx>
      54             : #include <svx/xflbstit.hxx>
      55             : #include <svx/xflbmtit.hxx>
      56             : #include <com/sun/star/drawing/BitmapMode.hpp>
      57             : 
      58             : using namespace ::com::sun::star;
      59             : 
      60             : 
      61             : class SwParaSelection
      62             : {
      63             :     SwCursor & m_rCursor;
      64             : public:
      65             :     explicit SwParaSelection(SwCursor & rCursor);
      66             :     ~SwParaSelection();
      67             : };
      68             : 
      69       18704 : SwParaSelection::SwParaSelection(SwCursor & rCursor)
      70       18704 :     : m_rCursor(rCursor)
      71             : {
      72       18704 :     if (m_rCursor.HasMark())
      73             :     {
      74           0 :         m_rCursor.DeleteMark();
      75             :     }
      76             :     // is it at the start?
      77       18704 :     if (m_rCursor.GetPoint()->nContent != 0)
      78             :     {
      79           0 :         m_rCursor.MovePara(fnParaCurr, fnParaStart);
      80             :     }
      81             :     // or at the end already?
      82       18704 :     if (m_rCursor.GetPoint()->nContent != m_rCursor.GetContentNode()->Len())
      83             :     {
      84       12379 :         m_rCursor.SetMark();
      85       12379 :         m_rCursor.MovePara(fnParaCurr, fnParaEnd);
      86             :     }
      87       18704 : }
      88             : 
      89       18704 : SwParaSelection::~SwParaSelection()
      90             : {
      91       18704 :     if (m_rCursor.GetPoint()->nContent != 0)
      92             :     {
      93       12379 :         m_rCursor.DeleteMark();
      94       12379 :         m_rCursor.MovePara(fnParaCurr, fnParaStart);
      95             :     }
      96       18704 : }
      97             : 
      98             : static beans::PropertyState lcl_SwXParagraph_getPropertyState(
      99             :                             const SwTextNode& rTextNode,
     100             :                             const SwAttrSet** ppSet,
     101             :                             const SfxItemPropertySimpleEntry& rEntry,
     102             :                             bool &rAttrSetFetched )
     103             :     throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception);
     104             : 
     105       73000 : class SwXParagraph::Impl
     106             :     : public SwClient
     107             : {
     108             : private:
     109             :     ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper
     110             : 
     111             : public:
     112             :     SwXParagraph &              m_rThis;
     113             :     uno::WeakReference<uno::XInterface> m_wThis;
     114             :     ::cppu::OInterfaceContainerHelper m_EventListeners;
     115             :     SfxItemPropertySet const&   m_rPropSet;
     116             :     bool                        m_bIsDescriptor;
     117             :     sal_Int32                   m_nSelectionStartPos;
     118             :     sal_Int32                   m_nSelectionEndPos;
     119             :     OUString             m_sText;
     120             :     uno::Reference<text::XText> m_xParentText;
     121             : 
     122       36500 :     Impl(   SwXParagraph & rThis,
     123             :             SwTextNode *const pTextNode = 0,
     124             :             uno::Reference< text::XText > const & xParent = 0,
     125             :             const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = -1)
     126             :         : SwClient(pTextNode)
     127             :         , m_rThis(rThis)
     128             :         , m_EventListeners(m_Mutex)
     129       36500 :         , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH))
     130       36500 :         , m_bIsDescriptor(0 == pTextNode)
     131             :         , m_nSelectionStartPos(nSelStart)
     132             :         , m_nSelectionEndPos(nSelEnd)
     133      109500 :         , m_xParentText(xParent)
     134             :     {
     135       36500 :     }
     136             : 
     137       34051 :     SwTextNode* GetTextNode() {
     138       34051 :         return static_cast<SwTextNode*>(GetRegisteredInNonConst());
     139             :     }
     140             : 
     141       28963 :     SwTextNode & GetTextNodeOrThrow() {
     142       28963 :         SwTextNode *const pTextNode( GetTextNode() );
     143       28963 :         if (!pTextNode) {
     144           2 :             throw uno::RuntimeException("SwXParagraph: disposed or invalid", 0);
     145             :         }
     146       28961 :         return *pTextNode;
     147             :     }
     148             : 
     149           8 :     bool IsDescriptor() const { return m_bIsDescriptor; }
     150             : 
     151             :     void SetPropertyValues_Impl(
     152             :             const uno::Sequence< OUString >& rPropertyNames,
     153             :             const uno::Sequence< uno::Any >& rValues)
     154             :         throw (beans::UnknownPropertyException, beans::PropertyVetoException,
     155             :                 lang::IllegalArgumentException, lang::WrappedTargetException,
     156             :                 uno::RuntimeException);
     157             : 
     158             :     uno::Sequence< uno::Any >
     159             :         GetPropertyValues_Impl(
     160             :             const uno::Sequence< OUString >& rPropertyNames)
     161             :         throw (beans::UnknownPropertyException, lang::WrappedTargetException,
     162             :                 uno::RuntimeException);
     163             : 
     164             :     //UUUU
     165             :     void GetSinglePropertyValue_Impl(
     166             :         const SfxItemPropertySimpleEntry& rEntry,
     167             :         const SfxItemSet& rSet,
     168             :         uno::Any& rAny ) const
     169             :     throw(uno::RuntimeException);
     170             : 
     171             :     uno::Sequence< beans::GetDirectPropertyTolerantResult >
     172             :         GetPropertyValuesTolerant_Impl(
     173             :             const uno::Sequence< OUString >& rPropertyNames,
     174             :             bool bDirectValuesOnly)
     175             :         throw (uno::RuntimeException);
     176             : protected:
     177             :     // SwClient
     178             :     virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
     179             : 
     180             : };
     181             : 
     182       21373 : void SwXParagraph::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew )
     183             : {
     184       21373 :     ClientModify(this, pOld, pNew);
     185       21373 :     if (GetRegisteredIn())
     186             :     {
     187       36630 :         return; // core object still alive
     188             :     }
     189             : 
     190        3058 :     uno::Reference<uno::XInterface> const xThis(m_wThis);
     191        3058 :     if (!xThis.is())
     192             :     {   // fdo#72695: if UNO object is already dead, don't revive it with event
     193           0 :         return;
     194             :     }
     195        6116 :     lang::EventObject const ev(xThis);
     196        6116 :     m_EventListeners.disposeAndClear(ev);
     197             : }
     198             : 
     199          12 : SwXParagraph::SwXParagraph()
     200          12 :     : m_pImpl( new SwXParagraph::Impl(*this) )
     201             : {
     202          12 : }
     203             : 
     204       36488 : SwXParagraph::SwXParagraph(
     205             :         uno::Reference< text::XText > const & xParent,
     206             :         SwTextNode & rTextNode,
     207             :         const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
     208             :     : m_pImpl(
     209       36488 :         new SwXParagraph::Impl(*this, &rTextNode, xParent, nSelStart, nSelEnd))
     210             : {
     211       36488 : }
     212             : 
     213       73000 : SwXParagraph::~SwXParagraph()
     214             : {
     215       73000 : }
     216             : 
     217         116 : const SwTextNode * SwXParagraph::GetTextNode() const
     218             : {
     219         116 :     return m_pImpl->GetTextNode();
     220             : }
     221             : 
     222           8 : bool SwXParagraph::IsDescriptor() const
     223             : {
     224           8 :     return m_pImpl->IsDescriptor();
     225             : }
     226             : 
     227             : uno::Reference<text::XTextContent>
     228       40979 : SwXParagraph::CreateXParagraph(SwDoc & rDoc, SwTextNode *const pTextNode,
     229             :         uno::Reference< text::XText> const& i_xParent,
     230             :         const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
     231             : {
     232             :     // re-use existing SwXParagraph
     233             :     // #i105557#: do not iterate over the registered clients: race condition
     234       40979 :     uno::Reference<text::XTextContent> xParagraph;
     235       40979 :     if (pTextNode && (-1 == nSelStart) && (-1 == nSelEnd))
     236             :     {   // only use cache if no selection!
     237       38025 :         xParagraph.set(pTextNode->GetXParagraph());
     238             :     }
     239       40979 :     if (xParagraph.is())
     240             :     {
     241        4479 :         return xParagraph;
     242             :     }
     243             : 
     244             :     // create new SwXParagraph
     245       73000 :     uno::Reference<text::XText> xParentText(i_xParent);
     246       36500 :     if (!xParentText.is() && pTextNode)
     247             :     {
     248           0 :         SwPosition Pos(*pTextNode);
     249           0 :         xParentText.set(::sw::CreateParentXText( rDoc, Pos ));
     250             :     }
     251             :     SwXParagraph *const pXPara( (pTextNode)
     252       36488 :             ? new SwXParagraph(xParentText, *pTextNode, nSelStart, nSelEnd)
     253       72988 :             : new SwXParagraph);
     254             :     // this is why the constructor is private: need to acquire pXPara here
     255       36500 :     xParagraph.set(pXPara);
     256             :     // in order to initialize the weak pointer cache in the core object
     257       36500 :     if (pTextNode && (-1 == nSelStart) && (-1 == nSelEnd))
     258             :     {
     259       33546 :         pTextNode->SetXParagraph(xParagraph);
     260             :     }
     261             :     // need a permanent Reference to initialize m_wThis
     262       36500 :     pXPara->m_pImpl->m_wThis = xParagraph;
     263       36500 :     return xParagraph;
     264             : }
     265             : 
     266           2 : bool SwXParagraph::SelectPaM(SwPaM & rPaM)
     267             : {
     268           2 :     SwTextNode const*const pTextNode( GetTextNode() );
     269             : 
     270           2 :     if (!pTextNode)
     271             :     {
     272           0 :         return false;
     273             :     }
     274             : 
     275           2 :     *rPaM.GetPoint() = SwPosition( *pTextNode );
     276             :     // set selection to the whole paragraph
     277           2 :     rPaM.SetMark();
     278           2 :     rPaM.GetMark()->nContent = pTextNode->GetText().getLength();
     279           2 :     return true;
     280             : }
     281             : 
     282             : namespace
     283             : {
     284             :     class theSwXParagraphUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXParagraphUnoTunnelId > {};
     285             : }
     286             : 
     287       66245 : const uno::Sequence< sal_Int8 > & SwXParagraph::getUnoTunnelId()
     288             : {
     289       66245 :     return theSwXParagraphUnoTunnelId::get().getSeq();
     290             : }
     291             : 
     292             : sal_Int64 SAL_CALL
     293          18 : SwXParagraph::getSomething(const uno::Sequence< sal_Int8 >& rId)
     294             : throw (uno::RuntimeException, std::exception)
     295             : {
     296          18 :     return ::sw::UnoTunnelImpl<SwXParagraph>(rId, this);
     297             : }
     298             : 
     299             : OUString SAL_CALL
     300           0 : SwXParagraph::getImplementationName() throw (uno::RuntimeException, std::exception)
     301             : {
     302           0 :     return OUString("SwXParagraph");
     303             : }
     304             : 
     305             : static char const*const g_ServicesParagraph[] =
     306             : {
     307             :     "com.sun.star.text.TextContent",
     308             :     "com.sun.star.text.Paragraph",
     309             :     "com.sun.star.style.CharacterProperties",
     310             :     "com.sun.star.style.CharacterPropertiesAsian",
     311             :     "com.sun.star.style.CharacterPropertiesComplex",
     312             :     "com.sun.star.style.ParagraphProperties",
     313             :     "com.sun.star.style.ParagraphPropertiesAsian",
     314             :     "com.sun.star.style.ParagraphPropertiesComplex",
     315             : };
     316             : 
     317             : static const size_t g_nServicesParagraph(
     318             :     sizeof(g_ServicesParagraph)/sizeof(g_ServicesParagraph[0]));
     319             : 
     320             : sal_Bool SAL_CALL
     321        1108 : SwXParagraph::supportsService(const OUString& rServiceName)
     322             : throw (uno::RuntimeException, std::exception)
     323             : {
     324        1108 :     return cppu::supportsService(this, rServiceName);
     325             : }
     326             : 
     327             : uno::Sequence< OUString > SAL_CALL
     328        1108 : SwXParagraph::getSupportedServiceNames() throw (uno::RuntimeException, std::exception)
     329             : {
     330             :     return ::sw::GetSupportedServiceNamesImpl(
     331        1108 :             g_nServicesParagraph, g_ServicesParagraph);
     332             : }
     333             : 
     334             : void
     335           8 : SwXParagraph::attachToText(SwXText & rParent, SwTextNode & rTextNode)
     336             : {
     337             :     OSL_ENSURE(m_pImpl->m_bIsDescriptor, "Paragraph is not a descriptor");
     338           8 :     if (m_pImpl->m_bIsDescriptor)
     339             :     {
     340           8 :         m_pImpl->m_bIsDescriptor = false;
     341           8 :         rTextNode.Add(m_pImpl.get());
     342           8 :         rTextNode.SetXParagraph(uno::Reference<text::XTextContent>(this));
     343           8 :         m_pImpl->m_xParentText = &rParent;
     344           8 :         if (!m_pImpl->m_sText.isEmpty())
     345             :         {
     346           0 :             try { setString(m_pImpl->m_sText); }
     347           0 :             catch(...){}
     348           0 :             (m_pImpl->m_sText).clear();
     349             :         }
     350             :     }
     351           8 : }
     352             : 
     353             : uno::Reference< beans::XPropertySetInfo > SAL_CALL
     354        2353 : SwXParagraph::getPropertySetInfo()
     355             : throw (uno::RuntimeException, std::exception)
     356             : {
     357        2353 :     SolarMutexGuard g;
     358             : 
     359             :     static uno::Reference< beans::XPropertySetInfo > xRef =
     360        2353 :         m_pImpl->m_rPropSet.getPropertySetInfo();
     361        2353 :     return xRef;
     362             : }
     363             : 
     364             : void SAL_CALL
     365        2059 : SwXParagraph::setPropertyValue(const OUString& rPropertyName,
     366             :         const uno::Any& rValue)
     367             : throw (beans::UnknownPropertyException, beans::PropertyVetoException,
     368             :     lang::IllegalArgumentException, lang::WrappedTargetException,
     369             :     uno::RuntimeException, std::exception )
     370             : {
     371        2059 :     SolarMutexGuard aGuard;
     372        4118 :     uno::Sequence<OUString> aPropertyNames(1);
     373        2059 :     aPropertyNames.getArray()[0] = rPropertyName;
     374        4118 :     uno::Sequence<uno::Any> aValues(1);
     375        2059 :     aValues.getArray()[0] = rValue;
     376        4118 :     m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues );
     377        2059 : }
     378             : 
     379             : uno::Any
     380        2396 : SwXParagraph::getPropertyValue(const OUString& rPropertyName)
     381             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
     382             :     uno::RuntimeException, std::exception )
     383             : {
     384        2396 :     SolarMutexGuard aGuard;
     385        4792 :     uno::Sequence<OUString> aPropertyNames(1);
     386        2396 :     aPropertyNames.getArray()[0] = rPropertyName;
     387             :     const uno::Sequence< uno::Any > aRet =
     388        4792 :         m_pImpl->GetPropertyValues_Impl(aPropertyNames);
     389        4792 :     return aRet.getConstArray()[0];
     390             : }
     391             : 
     392        2059 : void SwXParagraph::Impl::SetPropertyValues_Impl(
     393             :     const uno::Sequence< OUString >& rPropertyNames,
     394             :     const uno::Sequence< uno::Any >& rValues )
     395             : throw (beans::UnknownPropertyException, beans::PropertyVetoException,
     396             :     lang::IllegalArgumentException, lang::WrappedTargetException,
     397             :     uno::RuntimeException)
     398             : {
     399        2059 :     SwTextNode & rTextNode(GetTextNodeOrThrow());
     400             : 
     401        2059 :     SwPosition aPos( rTextNode );
     402        4118 :     SwCursor aCursor( aPos, 0, false );
     403        2059 :     const OUString* pPropertyNames = rPropertyNames.getConstArray();
     404        2059 :     const uno::Any* pValues = rValues.getConstArray();
     405        2059 :     const SfxItemPropertyMap &rMap = m_rPropSet.getPropertyMap();
     406        4118 :     SwParaSelection aParaSel( aCursor );
     407             : 
     408        4118 :     uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
     409        4118 :     for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
     410             :     {
     411             :         SfxItemPropertySimpleEntry const*const pEntry =
     412        2059 :             rMap.getByName( pPropertyNames[nProp] );
     413        2059 :         if (!pEntry)
     414             :         {
     415             :             throw beans::UnknownPropertyException(
     416           0 :                 "Unknown property: " + pPropertyNames[nProp],
     417           0 :                 static_cast< cppu::OWeakObject * >(&m_rThis));
     418             :         }
     419        2059 :         if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
     420             :         {
     421             :             throw beans::PropertyVetoException(
     422           0 :                 "Property is read-only: " + pPropertyNames[nProp],
     423           0 :                 static_cast< cppu::OWeakObject * >(&m_rThis));
     424             :         }
     425        2059 :         aValues[nProp].Name = pPropertyNames[nProp];
     426        2059 :         aValues[nProp].Value = pValues[nProp];
     427             :     }
     428        4118 :     SwUnoCursorHelper::SetPropertyValues(aCursor, m_rPropSet, aValues);
     429        2059 : }
     430             : 
     431           0 : void SAL_CALL SwXParagraph::setPropertyValues(
     432             :     const uno::Sequence< OUString >& rPropertyNames,
     433             :     const uno::Sequence< uno::Any >& rValues )
     434             : throw (beans::PropertyVetoException, lang::IllegalArgumentException,
     435             :     lang::WrappedTargetException, uno::RuntimeException, std::exception)
     436             : {
     437           0 :     SolarMutexGuard aGuard;
     438             : 
     439             :     // workaround for bad designed API
     440             :     try
     441             :     {
     442           0 :         m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues );
     443             :     }
     444           0 :     catch (const beans::UnknownPropertyException &rException)
     445             :     {
     446             :         // wrap the original (here not allowed) exception in
     447             :         // a lang::WrappedTargetException that gets thrown instead.
     448           0 :         lang::WrappedTargetException aWExc;
     449           0 :         aWExc.TargetException <<= rException;
     450           0 :         throw aWExc;
     451           0 :     }
     452           0 : }
     453             : 
     454             : //UUUU Support for DrawingLayer FillStyles for GetPropertyValue() usages
     455        3640 : void SwXParagraph::Impl::GetSinglePropertyValue_Impl(
     456             :     const SfxItemPropertySimpleEntry& rEntry,
     457             :     const SfxItemSet& rSet,
     458             :     uno::Any& rAny ) const
     459             : throw(uno::RuntimeException)
     460             : {
     461        3640 :     bool bDone(false);
     462             : 
     463        3640 :     switch(rEntry.nWID)
     464             :     {
     465             :         case RES_BACKGROUND:
     466             :         {
     467           6 :             const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
     468           6 :             const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM));
     469             : 
     470           6 :             if(!aOriginalBrushItem.QueryValue(rAny, nMemberId))
     471             :             {
     472             :                 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
     473             :             }
     474             : 
     475           6 :             bDone = true;
     476           6 :             break;
     477             :         }
     478             :         case OWN_ATTR_FILLBMP_MODE:
     479             :         {
     480           0 :             const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&rSet.Get(XATTR_FILLBMP_STRETCH));
     481           0 :             const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&rSet.Get(XATTR_FILLBMP_TILE));
     482             : 
     483           0 :             if( pTileItem && pTileItem->GetValue() )
     484             :             {
     485           0 :                 rAny <<= drawing::BitmapMode_REPEAT;
     486             :             }
     487           0 :             else if( pStretchItem && pStretchItem->GetValue() )
     488             :             {
     489           0 :                 rAny <<= drawing::BitmapMode_STRETCH;
     490             :             }
     491             :             else
     492             :             {
     493           0 :                 rAny <<= drawing::BitmapMode_NO_REPEAT;
     494             :             }
     495             : 
     496           0 :             bDone = true;
     497           0 :             break;
     498             :         }
     499        3634 :         default: break;
     500             :     }
     501             : 
     502        3640 :     if(!bDone)
     503             :     {
     504             :         // fallback to standard get value implementation used before this helper was created
     505        3634 :         m_rPropSet.getPropertyValue(rEntry, rSet, rAny);
     506             : 
     507        3634 :         if(rEntry.aType == cppu::UnoType<sal_Int16>::get() && rEntry.aType != rAny.getValueType())
     508             :         {
     509             :             // since the sfx uInt16 item now exports a sal_Int32, we may have to fix this here
     510          22 :             sal_Int32 nValue(0);
     511             : 
     512          22 :             rAny >>= nValue;
     513          22 :             rAny <<= static_cast< sal_Int16 >(nValue);
     514             :         }
     515             : 
     516             :         //UUUU check for needed metric translation
     517        3634 :         if(rEntry.nMemberId & SFX_METRIC_ITEM)
     518             :         {
     519           0 :             bool bDoIt(true);
     520             : 
     521           0 :             if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
     522             :             {
     523             :                 // exception: If these ItemTypes are used, do not convert when these are negative
     524             :                 // since this means they are intended as percent values
     525           0 :                 sal_Int32 nValue = 0;
     526             : 
     527           0 :                 if(rAny >>= nValue)
     528             :                 {
     529           0 :                     bDoIt = nValue > 0;
     530             :                 }
     531             :             }
     532             : 
     533           0 :             if(bDoIt)
     534             :             {
     535           0 :                 const SfxMapUnit eMapUnit(rSet.GetPool()->GetMetric(rEntry.nWID));
     536             : 
     537           0 :                 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
     538             :                 {
     539           0 :                     SvxUnoConvertToMM(eMapUnit, rAny);
     540             :                 }
     541             :             }
     542             :         }
     543             :     }
     544        3640 : }
     545             : 
     546        3386 : uno::Sequence< uno::Any > SwXParagraph::Impl::GetPropertyValues_Impl(
     547             :         const uno::Sequence< OUString > & rPropertyNames )
     548             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
     549             :     uno::RuntimeException)
     550             : {
     551        3386 :     SwTextNode & rTextNode(GetTextNodeOrThrow());
     552             : 
     553        3386 :     uno::Sequence< uno::Any > aValues(rPropertyNames.getLength());
     554        6772 :     SwPosition aPos( rTextNode );
     555        6772 :     SwPaM aPam( aPos );
     556        3386 :     uno::Any* pValues = aValues.getArray();
     557        3386 :     const OUString* pPropertyNames = rPropertyNames.getConstArray();
     558        3386 :     const SfxItemPropertyMap &rMap = m_rPropSet.getPropertyMap();
     559        3386 :     const SwAttrSet& rAttrSet( rTextNode.GetSwAttrSet() );
     560       11548 :     for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
     561             :     {
     562             :         SfxItemPropertySimpleEntry const*const pEntry =
     563        8162 :             rMap.getByName( pPropertyNames[nProp] );
     564        8162 :         if (!pEntry)
     565             :         {
     566             :             throw beans::UnknownPropertyException(
     567           0 :                 "Unknown property: " + pPropertyNames[nProp],
     568           0 :                 static_cast< cppu::OWeakObject * >(&m_rThis));
     569             :         }
     570        8162 :         if (! ::sw::GetDefaultTextContentValue(
     571        8162 :                 pValues[nProp], pPropertyNames[nProp], pEntry->nWID))
     572             :         {
     573             :             beans::PropertyState eTemp;
     574             :             const bool bDone = SwUnoCursorHelper::getCrsrPropertyValue(
     575        8162 :                 *pEntry, aPam, &(pValues[nProp]), eTemp, &rTextNode );
     576        8162 :             if (!bDone)
     577             :             {
     578             :                 //UUUU
     579        1124 :                 GetSinglePropertyValue_Impl(*pEntry, rAttrSet, pValues[nProp]);
     580             :             }
     581             :         }
     582             :     }
     583        6772 :     return aValues;
     584             : }
     585             : 
     586             : uno::Sequence< uno::Any > SAL_CALL
     587         990 : SwXParagraph::getPropertyValues(const uno::Sequence< OUString >& rPropertyNames)
     588             : throw (uno::RuntimeException, std::exception)
     589             : {
     590         990 :     SolarMutexGuard aGuard;
     591         990 :     uno::Sequence< uno::Any > aValues;
     592             : 
     593             :     // workaround for bad designed API
     594             :     try
     595             :     {
     596         990 :         aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames );
     597             :     }
     598           0 :     catch (beans::UnknownPropertyException &)
     599             :     {
     600             :         throw uno::RuntimeException("Unknown property exception caught",
     601           0 :             static_cast<cppu::OWeakObject *>(this));
     602             :     }
     603           0 :     catch (lang::WrappedTargetException &)
     604             :     {
     605             :         throw uno::RuntimeException("WrappedTargetException caught",
     606           0 :             static_cast<cppu::OWeakObject *>(this));
     607             :     }
     608             : 
     609         990 :     return aValues;
     610             : }
     611             : 
     612           0 : void SAL_CALL SwXParagraph::addPropertiesChangeListener(
     613             :     const uno::Sequence< OUString >& /*aPropertyNames*/,
     614             :     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
     615             : throw (uno::RuntimeException, std::exception)
     616             : {
     617             :     OSL_FAIL("SwXParagraph::addPropertiesChangeListener(): not implemented");
     618           0 : }
     619             : 
     620           0 : void SAL_CALL SwXParagraph::removePropertiesChangeListener(
     621             :     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
     622             : throw (uno::RuntimeException, std::exception)
     623             : {
     624             :     OSL_FAIL("SwXParagraph::removePropertiesChangeListener(): not implemented");
     625           0 : }
     626             : 
     627           0 : void SAL_CALL SwXParagraph::firePropertiesChangeEvent(
     628             :     const uno::Sequence< OUString >& /*aPropertyNames*/,
     629             :     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
     630             :         throw(uno::RuntimeException, std::exception)
     631             : {
     632             :     OSL_FAIL("SwXParagraph::firePropertiesChangeEvent(): not implemented");
     633           0 : }
     634             : 
     635             : /* disabled for #i46921# */
     636             : 
     637             : uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL
     638           0 : SwXParagraph::setPropertyValuesTolerant(
     639             :         const uno::Sequence< OUString >& rPropertyNames,
     640             :         const uno::Sequence< uno::Any >& rValues )
     641             : throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
     642             : {
     643           0 :     SolarMutexGuard aGuard;
     644             : 
     645           0 :     if (rPropertyNames.getLength() != rValues.getLength())
     646             :     {
     647           0 :         throw lang::IllegalArgumentException();
     648             :     }
     649             : 
     650           0 :     SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
     651             : 
     652             :     //SwNode& rTextNode = pUnoCrsr->GetPoint()->nNode.GetNode();
     653             :     //const SwAttrSet& rAttrSet = static_cast<SwTextNode&>(rTextNode).GetSwAttrSet();
     654             :     //sal_uInt16 nAttrCount = rAttrSet.Count();
     655             : 
     656           0 :     const sal_Int32 nProps = rPropertyNames.getLength();
     657           0 :     const OUString *pProp = rPropertyNames.getConstArray();
     658             : 
     659             :     //sal_Int32 nVals = rValues.getLength();
     660           0 :     const uno::Any *pValue = rValues.getConstArray();
     661             : 
     662           0 :     sal_Int32 nFailed = 0;
     663           0 :     uno::Sequence< beans::SetPropertyTolerantFailed > aFailed( nProps );
     664           0 :     beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray();
     665             : 
     666             :     // get entry to start with
     667             :     const SfxItemPropertyMap &rPropMap =
     668           0 :         m_pImpl->m_rPropSet.getPropertyMap();
     669             : 
     670           0 :     SwPosition aPos( rTextNode );
     671           0 :     SwCursor aCursor( aPos, 0, false );
     672           0 :     SwParaSelection aParaSel( aCursor );
     673           0 :     for (sal_Int32 i = 0;  i < nProps;  ++i)
     674             :     {
     675             :         try
     676             :         {
     677           0 :             pFailed[ nFailed ].Name = pProp[i];
     678             : 
     679             :             SfxItemPropertySimpleEntry const*const pEntry =
     680           0 :                 rPropMap.getByName( pProp[i] );
     681           0 :             if (!pEntry)
     682             :             {
     683           0 :                 pFailed[ nFailed++ ].Result  =
     684           0 :                     beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
     685             :             }
     686             :             else
     687             :             {
     688             :                 // set property value
     689             :                 // (compare to SwXParagraph::setPropertyValues)
     690           0 :                 if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
     691             :                 {
     692           0 :                     pFailed[ nFailed++ ].Result  =
     693           0 :                         beans::TolerantPropertySetResultType::PROPERTY_VETO;
     694             :                 }
     695             :                 else
     696             :                 {
     697             :                     SwUnoCursorHelper::SetPropertyValue(
     698           0 :                         aCursor, m_pImpl->m_rPropSet, pProp[i], pValue[i]);
     699             :                 }
     700             :             }
     701             :         }
     702           0 :         catch (beans::UnknownPropertyException &)
     703             :         {
     704             :             // should not occur because property was searched for before
     705             :             OSL_FAIL( "unexpected exception caught" );
     706           0 :             pFailed[ nFailed++ ].Result =
     707           0 :                 beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
     708             :         }
     709           0 :         catch (lang::IllegalArgumentException &)
     710             :         {
     711           0 :             pFailed[ nFailed++ ].Result =
     712           0 :                 beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
     713             :         }
     714           0 :         catch (beans::PropertyVetoException &)
     715             :         {
     716           0 :             pFailed[ nFailed++ ].Result =
     717           0 :                 beans::TolerantPropertySetResultType::PROPERTY_VETO;
     718             :         }
     719           0 :         catch (lang::WrappedTargetException &)
     720             :         {
     721           0 :             pFailed[ nFailed++ ].Result =
     722           0 :                 beans::TolerantPropertySetResultType::WRAPPED_TARGET;
     723             :         }
     724             :     }
     725             : 
     726           0 :     aFailed.realloc( nFailed );
     727           0 :     return aFailed;
     728             : }
     729             : 
     730             : uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL
     731           0 : SwXParagraph::getPropertyValuesTolerant(
     732             :         const uno::Sequence< OUString >& rPropertyNames )
     733             : throw (uno::RuntimeException, std::exception)
     734             : {
     735           0 :     SolarMutexGuard aGuard;
     736             : 
     737             :     uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes(
     738           0 :         m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, false ) );
     739             :     const beans::GetDirectPropertyTolerantResult *pTmpRes =
     740           0 :         aTmpRes.getConstArray();
     741             : 
     742             :     // copy temporary result to final result type
     743           0 :     const sal_Int32 nLen = aTmpRes.getLength();
     744           0 :     uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen );
     745           0 :     beans::GetPropertyTolerantResult *pRes = aRes.getArray();
     746           0 :     for (sal_Int32 i = 0;  i < nLen;  i++)
     747             :     {
     748           0 :         *pRes++ = *pTmpRes++;
     749             :     }
     750           0 :     return aRes;
     751             : }
     752             : 
     753             : uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL
     754         990 : SwXParagraph::getDirectPropertyValuesTolerant(
     755             :         const uno::Sequence< OUString >& rPropertyNames )
     756             : throw (uno::RuntimeException, std::exception)
     757             : {
     758         990 :     SolarMutexGuard aGuard;
     759             : 
     760         990 :     return m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, true );
     761             : }
     762             : 
     763             : uno::Sequence< beans::GetDirectPropertyTolerantResult >
     764         990 : SwXParagraph::Impl::GetPropertyValuesTolerant_Impl(
     765             :         const uno::Sequence< OUString >& rPropertyNames,
     766             :         bool bDirectValuesOnly )
     767             : throw (uno::RuntimeException)
     768             : {
     769         990 :     SolarMutexGuard aGuard;
     770             : 
     771         990 :     SwTextNode & rTextNode(GetTextNodeOrThrow());
     772             : 
     773             :     // #i46786# Use SwAttrSet pointer for determining the state.
     774             :     //          Use the value SwAttrSet (from the paragraph OR the style)
     775             :     //          for determining the actual value(s).
     776         990 :     const SwAttrSet* pAttrSet = rTextNode.GetpSwAttrSet();
     777         990 :     const SwAttrSet& rValueAttrSet = rTextNode.GetSwAttrSet();
     778             : 
     779         990 :     sal_Int32 nProps = rPropertyNames.getLength();
     780         990 :     const OUString *pProp = rPropertyNames.getConstArray();
     781             : 
     782         990 :     uno::Sequence< beans::GetDirectPropertyTolerantResult > aResult( nProps );
     783         990 :     beans::GetDirectPropertyTolerantResult *pResult = aResult.getArray();
     784         990 :     sal_Int32 nIdx = 0;
     785             : 
     786             :     // get entry to start with
     787         990 :     const SfxItemPropertyMap &rPropMap = m_rPropSet.getPropertyMap();
     788             : 
     789      137610 :     for (sal_Int32 i = 0;  i < nProps;  ++i)
     790             :     {
     791             :         OSL_ENSURE( nIdx < nProps, "index out ouf bounds" );
     792      136620 :         beans::GetDirectPropertyTolerantResult &rResult = pResult[nIdx];
     793             : 
     794             :         try
     795             :         {
     796      136620 :             rResult.Name = pProp[i];
     797             : 
     798             :             SfxItemPropertySimpleEntry const*const pEntry =
     799      136620 :                 rPropMap.getByName( pProp[i] );
     800      136620 :             if (!pEntry)  // property available?
     801             :             {
     802             :                 rResult.Result =
     803           0 :                     beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
     804             :             }
     805             :             else
     806             :             {
     807             :                 // get property state
     808             :                 // (compare to SwXParagraph::getPropertyState)
     809      136620 :                 bool bAttrSetFetched = true;
     810             :                 beans::PropertyState eState = lcl_SwXParagraph_getPropertyState(
     811      136620 :                             rTextNode, &pAttrSet, *pEntry, bAttrSetFetched );
     812      136620 :                 rResult.State  = eState;
     813             : 
     814      136620 :                 rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
     815      136620 :                 if (!bDirectValuesOnly ||
     816             :                     (beans::PropertyState_DIRECT_VALUE == eState))
     817             :                 {
     818             :                     // get property value
     819             :                     // (compare to SwXParagraph::getPropertyValue(s))
     820        2516 :                     uno::Any aValue;
     821        2516 :                     if (! ::sw::GetDefaultTextContentValue(
     822        2516 :                                 aValue, pProp[i], pEntry->nWID ) )
     823             :                     {
     824        2516 :                         SwPosition aPos( rTextNode );
     825        5032 :                         SwPaM aPam( aPos );
     826             :                         // handle properties that are not part of the attribute
     827             :                         // and thus only pretendend to be paragraph attributes
     828             :                         beans::PropertyState eTemp;
     829             :                         const bool bDone =
     830             :                             SwUnoCursorHelper::getCrsrPropertyValue(
     831        2516 :                                     *pEntry, aPam, &aValue, eTemp, &rTextNode );
     832             : 
     833             :                         // if not found try the real paragraph attributes...
     834        2516 :                         if (!bDone)
     835             :                         {
     836             :                             //UUUU
     837        2516 :                             GetSinglePropertyValue_Impl(*pEntry, rValueAttrSet, aValue);
     838        2516 :                         }
     839             :                     }
     840             : 
     841        2516 :                     rResult.Value  = aValue;
     842        2516 :                     rResult.Result = beans::TolerantPropertySetResultType::SUCCESS;
     843             : 
     844        2516 :                     nIdx++;
     845             :                 }
     846             :                 // this assertion should never occur!
     847             :                 OSL_ENSURE( nIdx < 1  ||  pResult[nIdx - 1].Result != beans::TolerantPropertySetResultType::UNKNOWN_FAILURE,
     848             :                         "unknown failure while retrieving property" );
     849             : 
     850             :             }
     851             :         }
     852           0 :         catch (beans::UnknownPropertyException &)
     853             :         {
     854             :             // should not occur because property was searched for before
     855             :             OSL_FAIL( "unexpected exception caught" );
     856           0 :             rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
     857             :         }
     858           0 :         catch (lang::IllegalArgumentException &)
     859             :         {
     860           0 :             rResult.Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
     861             :         }
     862           0 :         catch (beans::PropertyVetoException &)
     863             :         {
     864           0 :             rResult.Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
     865             :         }
     866           0 :         catch (lang::WrappedTargetException &)
     867             :         {
     868           0 :             rResult.Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
     869             :         }
     870             :     }
     871             : 
     872             :     // resize to actually used size
     873         990 :     aResult.realloc( nIdx );
     874             : 
     875         990 :     return aResult;
     876             : }
     877             : 
     878       10777 : bool ::sw::GetDefaultTextContentValue(
     879             :         uno::Any& rAny, const OUString& rPropertyName, sal_uInt16 nWID)
     880             : {
     881       10777 :     if(!nWID)
     882             :     {
     883          35 :         if(rPropertyName == UNO_NAME_ANCHOR_TYPE)
     884           2 :             nWID = FN_UNO_ANCHOR_TYPE;
     885          33 :         else if(rPropertyName == UNO_NAME_ANCHOR_TYPES)
     886           2 :             nWID = FN_UNO_ANCHOR_TYPES;
     887          31 :         else if(rPropertyName == UNO_NAME_TEXT_WRAP)
     888           2 :             nWID = FN_UNO_TEXT_WRAP;
     889             :         else
     890          29 :             return false;
     891             :     }
     892             : 
     893       10748 :     switch(nWID)
     894             :     {
     895           6 :         case FN_UNO_TEXT_WRAP:  rAny <<= text::WrapTextMode_NONE; break;
     896           6 :         case FN_UNO_ANCHOR_TYPE: rAny <<= text::TextContentAnchorType_AT_PARAGRAPH; break;
     897             :         case FN_UNO_ANCHOR_TYPES:
     898           4 :         {   uno::Sequence<text::TextContentAnchorType> aTypes(1);
     899           4 :             text::TextContentAnchorType* pArray = aTypes.getArray();
     900           4 :             pArray[0] = text::TextContentAnchorType_AT_PARAGRAPH;
     901           4 :             rAny.setValue(&aTypes, cppu::UnoType<uno::Sequence<text::TextContentAnchorType>>::get());
     902             :         }
     903           4 :         break;
     904             :         default:
     905       10732 :             return false;
     906             :     }
     907          16 :     return true;
     908             : }
     909             : 
     910             : void SAL_CALL
     911           0 : SwXParagraph::addPropertyChangeListener(
     912             :         const OUString& /*rPropertyName*/,
     913             :         const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
     914             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
     915             :     uno::RuntimeException, std::exception)
     916             : {
     917             :     OSL_FAIL("SwXParagraph::addPropertyChangeListener(): not implemented");
     918           0 : }
     919             : 
     920             : void SAL_CALL
     921           0 : SwXParagraph::removePropertyChangeListener(
     922             :         const OUString& /*rPropertyName*/,
     923             :         const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
     924             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
     925             :     uno::RuntimeException, std::exception)
     926             : {
     927             :     OSL_FAIL("SwXParagraph::removePropertyChangeListener(): not implemented");
     928           0 : }
     929             : 
     930             : void SAL_CALL
     931           0 : SwXParagraph::addVetoableChangeListener(
     932             :         const OUString& /*rPropertyName*/,
     933             :         const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
     934             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
     935             :     uno::RuntimeException, std::exception)
     936             : {
     937             :     OSL_FAIL("SwXParagraph::addVetoableChangeListener(): not implemented");
     938           0 : }
     939             : 
     940             : void SAL_CALL
     941           0 : SwXParagraph::removeVetoableChangeListener(
     942             :         const OUString& /*rPropertyName*/,
     943             :         const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
     944             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
     945             :         uno::RuntimeException, std::exception)
     946             : {
     947             :     OSL_FAIL("SwXParagraph::removeVetoableChangeListener(): not implemented");
     948           0 : }
     949             : 
     950      139677 : static beans::PropertyState lcl_SwXParagraph_getPropertyState(
     951             :     const SwTextNode& rTextNode,
     952             :     const SwAttrSet** ppSet,
     953             :     const SfxItemPropertySimpleEntry& rEntry,
     954             :     bool &rAttrSetFetched)
     955             :     throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
     956             : {
     957      139677 :     beans::PropertyState eRet(beans::PropertyState_DEFAULT_VALUE);
     958             : 
     959      139677 :     if(!(*ppSet) && !rAttrSetFetched)
     960             :     {
     961        3057 :         (*ppSet) = rTextNode.GetpSwAttrSet();
     962        3057 :         rAttrSetFetched = true;
     963             :     }
     964             : 
     965      139677 :     SwPosition aPos(rTextNode);
     966      279354 :     SwPaM aPam(aPos);
     967      139677 :     bool bDone(false);
     968             : 
     969      139677 :     switch(rEntry.nWID)
     970             :     {
     971             :         case FN_UNO_NUM_RULES:
     972             :         {
     973             :             // if numbering is set, return it; else do nothing
     974           0 :             SwUnoCursorHelper::getNumberingProperty(aPam,eRet,NULL);
     975           0 :             bDone = true;
     976           0 :             break;
     977             :         }
     978             :         case FN_UNO_ANCHOR_TYPES:
     979             :         {
     980           0 :             bDone = true;
     981           0 :             break;
     982             :         }
     983             :         case RES_ANCHOR:
     984             :         {
     985           0 :             bDone = (MID_SURROUND_SURROUNDTYPE == rEntry.nMemberId);
     986           0 :             break;
     987             :         }
     988             :         case RES_SURROUND:
     989             :         {
     990           0 :             bDone = (MID_ANCHOR_ANCHORTYPE == rEntry.nMemberId);
     991           0 :             break;
     992             :         }
     993             :         case FN_UNO_PARA_STYLE:
     994             :         case FN_UNO_PARA_CONDITIONAL_STYLE_NAME:
     995             :         {
     996           0 :             SwFormatColl* pFormat = SwUnoCursorHelper::GetCurTextFormatColl(aPam,rEntry.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME);
     997           0 :             eRet = pFormat ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE;
     998           0 :             bDone = true;
     999           0 :             break;
    1000             :         }
    1001             :         case FN_UNO_PAGE_STYLE:
    1002             :         {
    1003           0 :             OUString sVal;
    1004           0 :             SwUnoCursorHelper::GetCurPageStyle( aPam, sVal );
    1005           0 :             eRet = !sVal.isEmpty() ? beans::PropertyState_DIRECT_VALUE
    1006           0 :                               : beans::PropertyState_AMBIGUOUS_VALUE;
    1007           0 :             bDone = true;
    1008           0 :             break;
    1009             :         }
    1010             : 
    1011             :         //UUUU DrawingLayer PropertyStyle support
    1012             :         case OWN_ATTR_FILLBMP_MODE:
    1013             :         {
    1014         990 :             if(*ppSet)
    1015             :             {
    1016        1354 :                 if(SfxItemState::SET == (*ppSet)->GetItemState(XATTR_FILLBMP_STRETCH, false)
    1017         677 :                     || SfxItemState::SET == (*ppSet)->GetItemState(XATTR_FILLBMP_TILE, false))
    1018             :                 {
    1019           0 :                     eRet = beans::PropertyState_DIRECT_VALUE;
    1020             :                 }
    1021             :                 else
    1022             :                 {
    1023         677 :                     eRet = beans::PropertyState_AMBIGUOUS_VALUE;
    1024             :                 }
    1025             : 
    1026         677 :                 bDone = true;
    1027             :             }
    1028         990 :             break;
    1029             :         }
    1030             :         case RES_BACKGROUND:
    1031             :         {
    1032        4950 :             if(*ppSet)
    1033             :             {
    1034        3385 :                 if (SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(**ppSet,
    1035        3385 :                         rEntry.nMemberId))
    1036             :                 {
    1037           5 :                     eRet = beans::PropertyState_DIRECT_VALUE;
    1038             :                 }
    1039        3385 :                 bDone = true;
    1040             :             }
    1041        4950 :             break;
    1042             :         }
    1043             :     }
    1044             : 
    1045      139677 :     if(!bDone)
    1046             :     {
    1047      135615 :         if((*ppSet) && SfxItemState::SET == (*ppSet)->GetItemState(rEntry.nWID, false))
    1048             :         {
    1049        5521 :             eRet = beans::PropertyState_DIRECT_VALUE;
    1050             :         }
    1051             :     }
    1052             : 
    1053      279354 :     return eRet;
    1054             : }
    1055             : 
    1056             : beans::PropertyState SAL_CALL
    1057        3057 : SwXParagraph::getPropertyState(const OUString& rPropertyName)
    1058             : throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1059             : {
    1060        3057 :     SolarMutexGuard aGuard;
    1061             : 
    1062        3057 :     SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
    1063             : 
    1064        3057 :     const SwAttrSet* pSet = 0;
    1065             :     SfxItemPropertySimpleEntry const*const pEntry =
    1066        3057 :         m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
    1067        3057 :     if (!pEntry)
    1068             :     {
    1069             :         throw beans::UnknownPropertyException(
    1070           0 :             "Unknown property: " + rPropertyName,
    1071           0 :             static_cast<cppu::OWeakObject *>(this));
    1072             :     }
    1073        3057 :     bool bDummy = false;
    1074             :     const beans::PropertyState eRet =
    1075        3057 :         lcl_SwXParagraph_getPropertyState(rTextNode, &pSet, *pEntry, bDummy);
    1076        3057 :     return eRet;
    1077             : }
    1078             : 
    1079             : uno::Sequence< beans::PropertyState > SAL_CALL
    1080           0 : SwXParagraph::getPropertyStates(
    1081             :         const uno::Sequence< OUString >& PropertyNames)
    1082             : throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1083             : {
    1084           0 :     SolarMutexGuard aGuard;
    1085             : 
    1086           0 :     SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
    1087             : 
    1088           0 :     const OUString* pNames = PropertyNames.getConstArray();
    1089           0 :     uno::Sequence< beans::PropertyState > aRet(PropertyNames.getLength());
    1090           0 :     beans::PropertyState* pStates = aRet.getArray();
    1091           0 :     const SfxItemPropertyMap &rMap = m_pImpl->m_rPropSet.getPropertyMap();
    1092           0 :     const SwAttrSet* pSet = 0;
    1093           0 :     bool bAttrSetFetched = false;
    1094             : 
    1095           0 :     for (sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd;
    1096             :             ++i, ++pStates, ++pNames)
    1097             :     {
    1098             :         SfxItemPropertySimpleEntry const*const pEntry =
    1099           0 :             rMap.getByName( *pNames );
    1100           0 :         if (!pEntry)
    1101             :         {
    1102             :             throw beans::UnknownPropertyException(
    1103           0 :                 "Unknown property: " + *pNames,
    1104           0 :                 static_cast<cppu::OWeakObject *>(this));
    1105             :         }
    1106             : 
    1107           0 :         if (bAttrSetFetched && !pSet && isATR(pEntry->nWID))
    1108             :         {
    1109           0 :             *pStates = beans::PropertyState_DEFAULT_VALUE;
    1110             :         }
    1111             :         else
    1112             :         {
    1113             :             *pStates = lcl_SwXParagraph_getPropertyState(
    1114           0 :                 rTextNode, &pSet, *pEntry, bAttrSetFetched );
    1115             :         }
    1116             :     }
    1117             : 
    1118           0 :     return aRet;
    1119             : }
    1120             : 
    1121             : void SAL_CALL
    1122           0 : SwXParagraph::setPropertyToDefault(const OUString& rPropertyName)
    1123             : throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1124             : {
    1125           0 :     SolarMutexGuard aGuard;
    1126             : 
    1127           0 :     SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
    1128             : 
    1129           0 :     SwPosition aPos( rTextNode );
    1130           0 :     SwCursor aCursor( aPos, 0, false );
    1131           0 :     if (rPropertyName == UNO_NAME_ANCHOR_TYPE  ||
    1132           0 :         rPropertyName == UNO_NAME_ANCHOR_TYPES ||
    1133           0 :         rPropertyName == UNO_NAME_TEXT_WRAP)
    1134             :     {
    1135           0 :         return;
    1136             :     }
    1137             : 
    1138             :     // select paragraph
    1139           0 :     SwParaSelection aParaSel( aCursor );
    1140             :     SfxItemPropertySimpleEntry const*const pEntry =
    1141           0 :         m_pImpl->m_rPropSet.getPropertyMap().getByName( rPropertyName );
    1142           0 :     if (!pEntry)
    1143             :     {
    1144             :         throw beans::UnknownPropertyException(
    1145           0 :             "Unknown property: " + rPropertyName,
    1146           0 :             static_cast<cppu::OWeakObject *>(this));
    1147             :     }
    1148             : 
    1149           0 :     if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
    1150             :     {
    1151             :         throw uno::RuntimeException(
    1152           0 :             "Property is read-only: " + rPropertyName,
    1153           0 :             static_cast<cppu::OWeakObject *>(this));
    1154             :     }
    1155             : 
    1156           0 :     const bool bBelowFrmAtrEnd(pEntry->nWID < RES_FRMATR_END);
    1157           0 :     const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID);
    1158             : 
    1159           0 :     if(bBelowFrmAtrEnd || bDrawingLayerRange)
    1160             :     {
    1161           0 :         std::set<sal_uInt16> aWhichIds;
    1162             : 
    1163             :         //UUUU For FillBitmapMode two IDs have to be reset (!)
    1164           0 :         if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
    1165             :         {
    1166           0 :             aWhichIds.insert(XATTR_FILLBMP_STRETCH);
    1167           0 :             aWhichIds.insert(XATTR_FILLBMP_TILE);
    1168             :         }
    1169             :         else
    1170             :         {
    1171           0 :             aWhichIds.insert(pEntry->nWID);
    1172             :         }
    1173             : 
    1174           0 :         if (pEntry->nWID < RES_PARATR_BEGIN)
    1175             :         {
    1176           0 :             aCursor.GetDoc()->ResetAttrs(aCursor, true, aWhichIds);
    1177             :         }
    1178             :         else
    1179             :         {
    1180             :             // for paragraph attributes the selection must be extended
    1181             :             // to paragraph boundaries
    1182           0 :             SwPosition aStart( *aCursor.Start() );
    1183           0 :             SwPosition aEnd  ( *aCursor.End()   );
    1184           0 :             auto pTemp( aCursor.GetDoc()->CreateUnoCrsr(aStart, false) );
    1185           0 :             if(!SwUnoCursorHelper::IsStartOfPara(*pTemp))
    1186             :             {
    1187           0 :                 pTemp->MovePara(fnParaCurr, fnParaStart);
    1188             :             }
    1189             : 
    1190           0 :             pTemp->SetMark();
    1191           0 :             *pTemp->GetPoint() = aEnd;
    1192             : 
    1193           0 :             SwUnoCursorHelper::SelectPam(*pTemp, true);
    1194             : 
    1195           0 :             if (!SwUnoCursorHelper::IsEndOfPara(*pTemp))
    1196             :             {
    1197           0 :                 pTemp->MovePara(fnParaCurr, fnParaEnd);
    1198             :             }
    1199             : 
    1200             : 
    1201           0 :             pTemp->GetDoc()->ResetAttrs(*pTemp, true, aWhichIds);
    1202           0 :         }
    1203             :     }
    1204             :     else
    1205             :     {
    1206           0 :         SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, aCursor);
    1207           0 :     }
    1208             : }
    1209             : 
    1210             : uno::Any SAL_CALL
    1211           0 : SwXParagraph::getPropertyDefault(const OUString& rPropertyName)
    1212             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
    1213             :     uno::RuntimeException, std::exception)
    1214             : {
    1215           0 :     SolarMutexGuard g;
    1216             : 
    1217           0 :     SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
    1218             : 
    1219           0 :     uno::Any aRet;
    1220           0 :     if (::sw::GetDefaultTextContentValue(aRet, rPropertyName))
    1221             :     {
    1222           0 :         return aRet;
    1223             :     }
    1224             : 
    1225             :     SfxItemPropertySimpleEntry const*const pEntry =
    1226           0 :         m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
    1227           0 :     if (!pEntry)
    1228             :     {
    1229             :         throw beans::UnknownPropertyException(
    1230           0 :             "Unknown property: " + rPropertyName,
    1231           0 :             static_cast<cppu::OWeakObject *>(this));
    1232             :     }
    1233             : 
    1234           0 :     const bool bBelowFrmAtrEnd(pEntry->nWID < RES_FRMATR_END);
    1235           0 :     const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID);
    1236             : 
    1237           0 :     if(bBelowFrmAtrEnd || bDrawingLayerRange)
    1238             :     {
    1239           0 :         const SfxPoolItem& rDefItem = rTextNode.GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID);
    1240             : 
    1241           0 :         rDefItem.QueryValue(aRet, pEntry->nMemberId);
    1242             :     }
    1243             : 
    1244           0 :     return aRet;
    1245             : }
    1246             : 
    1247             : void SAL_CALL
    1248           0 : SwXParagraph::attach(const uno::Reference< text::XTextRange > & /*xTextRange*/)
    1249             : throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
    1250             : {
    1251           0 :     SolarMutexGuard aGuard;
    1252             :     // SwXParagraph will only created in order to be inserted by
    1253             :     // 'insertTextContentBefore' or 'insertTextContentAfter' therefore
    1254             :     // they cannot be attached
    1255           0 :     throw uno::RuntimeException();
    1256             : }
    1257             : 
    1258             : uno::Reference< text::XTextRange > SAL_CALL
    1259           0 : SwXParagraph::getAnchor() throw (uno::RuntimeException, std::exception)
    1260             : {
    1261           0 :     SolarMutexGuard aGuard;
    1262             : 
    1263           0 :     SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
    1264             : 
    1265           0 :     SwPosition aPos( rTextNode );
    1266           0 :     SwCursor aCursor( aPos, 0, false );
    1267             :     // select paragraph
    1268           0 :     SwParaSelection aParaSel( aCursor );
    1269             :     const uno::Reference< text::XTextRange >  xRet =
    1270           0 :         new SwXTextRange(aCursor, m_pImpl->m_xParentText);
    1271           0 :     return xRet;
    1272             : }
    1273             : 
    1274        2946 : void SAL_CALL SwXParagraph::dispose() throw (uno::RuntimeException, std::exception)
    1275             : {
    1276        2946 :     SolarMutexGuard aGuard;
    1277             : 
    1278        2946 :     SwTextNode *const pTextNode( m_pImpl->GetTextNode() );
    1279        2946 :     if (pTextNode)
    1280             :     {
    1281        2946 :         SwCursor aCursor( SwPosition( *pTextNode ), 0, false );
    1282        2946 :         pTextNode->GetDoc()->getIDocumentContentOperations().DelFullPara(aCursor);
    1283        5892 :         lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
    1284        5892 :         m_pImpl->m_EventListeners.disposeAndClear(ev);
    1285        2946 :     }
    1286        2946 : }
    1287             : 
    1288           0 : void SAL_CALL SwXParagraph::addEventListener(
    1289             :         const uno::Reference< lang::XEventListener > & xListener)
    1290             : throw (uno::RuntimeException, std::exception)
    1291             : {
    1292             :     // no need to lock here as m_pImpl is const and container threadsafe
    1293           0 :     m_pImpl->m_EventListeners.addInterface(xListener);
    1294           0 : }
    1295             : 
    1296           0 : void SAL_CALL SwXParagraph::removeEventListener(
    1297             :         const uno::Reference< lang::XEventListener > & xListener)
    1298             : throw (uno::RuntimeException, std::exception)
    1299             : {
    1300             :     // no need to lock here as m_pImpl is const and container threadsafe
    1301           0 :     m_pImpl->m_EventListeners.removeInterface(xListener);
    1302           0 : }
    1303             : 
    1304             : uno::Reference< container::XEnumeration >  SAL_CALL
    1305        1948 : SwXParagraph::createEnumeration() throw (uno::RuntimeException, std::exception)
    1306             : {
    1307        1948 :     SolarMutexGuard aGuard;
    1308             : 
    1309        1948 :     SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
    1310             : 
    1311        3896 :     SwPosition aPos( rTextNode );
    1312        3896 :     SwPaM aPam ( aPos );
    1313             :     const uno::Reference< container::XEnumeration > xRef =
    1314        1948 :         new SwXTextPortionEnumeration(aPam, m_pImpl->m_xParentText,
    1315        1948 :             m_pImpl->m_nSelectionStartPos, m_pImpl->m_nSelectionEndPos);
    1316        3896 :     return xRef;
    1317             : }
    1318             : 
    1319           0 : uno::Type SAL_CALL SwXParagraph::getElementType() throw (uno::RuntimeException, std::exception)
    1320             : {
    1321           0 :     return cppu::UnoType<text::XTextRange>::get();
    1322             : }
    1323             : 
    1324           0 : sal_Bool SAL_CALL SwXParagraph::hasElements() throw (uno::RuntimeException, std::exception)
    1325             : {
    1326           0 :     SolarMutexGuard aGuard;
    1327           0 :     return GetTextNode() != nullptr;
    1328             : }
    1329             : 
    1330             : uno::Reference< text::XText > SAL_CALL
    1331       44155 : SwXParagraph::getText() throw (uno::RuntimeException, std::exception)
    1332             : {
    1333       44155 :     SolarMutexGuard g;
    1334             : 
    1335       44155 :     return m_pImpl->m_xParentText;
    1336             : }
    1337             : 
    1338             : uno::Reference< text::XTextRange > SAL_CALL
    1339        8268 : SwXParagraph::getStart() throw (uno::RuntimeException, std::exception)
    1340             : {
    1341        8268 :     SolarMutexGuard aGuard;
    1342             : 
    1343        8268 :     SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
    1344             : 
    1345       16532 :     SwPosition aPos( rTextNode );
    1346       16532 :     SwCursor aCursor( aPos, 0, false );
    1347       16532 :     SwParaSelection aParaSel( aCursor );
    1348       16532 :     SwPaM aPam( *aCursor.Start() );
    1349       16532 :     uno::Reference< text::XText >  xParent = getText();
    1350             :     const uno::Reference< text::XTextRange > xRet =
    1351        8266 :         new SwXTextRange(aPam, xParent);
    1352       16534 :     return xRet;
    1353             : }
    1354             : 
    1355             : uno::Reference< text::XTextRange > SAL_CALL
    1356        8265 : SwXParagraph::getEnd() throw (uno::RuntimeException, std::exception)
    1357             : {
    1358        8265 :     SolarMutexGuard aGuard;
    1359             : 
    1360        8265 :     SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
    1361             : 
    1362       16530 :     SwPosition aPos( rTextNode );
    1363       16530 :     SwCursor aCursor( aPos, 0, false );
    1364       16530 :     SwParaSelection aParaSel( aCursor );
    1365       16530 :     SwPaM aPam( *aCursor.End() );
    1366       16530 :     uno::Reference< text::XText >  xParent = getText();
    1367             :     const uno::Reference< text::XTextRange > xRet =
    1368        8265 :         new SwXTextRange(aPam, xParent);
    1369       16530 :     return xRet;
    1370             : }
    1371             : 
    1372         114 : OUString SAL_CALL SwXParagraph::getString() throw (uno::RuntimeException, std::exception)
    1373             : {
    1374         114 :     SolarMutexGuard aGuard;
    1375         114 :     OUString aRet;
    1376         114 :     SwTextNode const*const pTextNode( GetTextNode() );
    1377         114 :     if (pTextNode)
    1378             :     {
    1379         114 :         SwPosition aPos( *pTextNode );
    1380         228 :         SwCursor aCursor( aPos, 0, false );
    1381         228 :         SwParaSelection aParaSel( aCursor );
    1382         228 :         SwUnoCursorHelper::GetTextFromPam(aCursor, aRet);
    1383             :     }
    1384           0 :     else if (m_pImpl->IsDescriptor())
    1385             :     {
    1386           0 :         aRet = m_pImpl->m_sText;
    1387             :     }
    1388             :     else
    1389             :     {
    1390           0 :         throw uno::RuntimeException();
    1391             :     }
    1392         114 :     return aRet;
    1393             : }
    1394             : 
    1395           0 : void SAL_CALL SwXParagraph::setString(const OUString& aString)
    1396             : throw (uno::RuntimeException, std::exception)
    1397             : {
    1398           0 :     SolarMutexGuard aGuard;
    1399             : 
    1400           0 :     SwTextNode const*const pTextNode( GetTextNode() );
    1401           0 :     if (pTextNode)
    1402             :     {
    1403           0 :         SwPosition aPos( *pTextNode );
    1404           0 :         SwCursor aCursor( aPos, 0, false );
    1405           0 :         if (!SwUnoCursorHelper::IsStartOfPara(aCursor)) {
    1406           0 :             aCursor.MovePara(fnParaCurr, fnParaStart);
    1407             :         }
    1408           0 :         SwUnoCursorHelper::SelectPam(aCursor, true);
    1409           0 :         if (pTextNode->GetText().getLength()) {
    1410           0 :             aCursor.MovePara(fnParaCurr, fnParaEnd);
    1411             :         }
    1412           0 :         SwUnoCursorHelper::SetString(aCursor, aString);
    1413           0 :         SwUnoCursorHelper::SelectPam(aCursor, false);
    1414             :     }
    1415           0 :     else if (m_pImpl->IsDescriptor())
    1416             :     {
    1417           0 :         m_pImpl->m_sText = aString;
    1418             :     }
    1419             :     else
    1420             :     {
    1421           0 :         throw uno::RuntimeException();
    1422           0 :     }
    1423           0 : }
    1424             : 
    1425             : uno::Reference< container::XEnumeration > SAL_CALL
    1426         990 : SwXParagraph::createContentEnumeration(const OUString& rServiceName)
    1427             : throw (uno::RuntimeException, std::exception)
    1428             : {
    1429         990 :     SolarMutexGuard g;
    1430             : 
    1431         990 :     if ( rServiceName != "com.sun.star.text.TextContent" )
    1432             :     {
    1433           0 :         throw uno::RuntimeException();
    1434             :     }
    1435             : 
    1436         990 :     SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
    1437             : 
    1438        1980 :     SwPosition aPos( rTextNode );
    1439        1980 :     SwPaM aPam( aPos );
    1440             :     uno::Reference< container::XEnumeration > xRet =
    1441         990 :         SwXParaFrameEnumeration::Create(aPam, PARAFRAME_PORTION_PARAGRAPH);
    1442        1980 :     return xRet;
    1443             : }
    1444             : 
    1445             : uno::Sequence< OUString > SAL_CALL
    1446           0 : SwXParagraph::getAvailableServiceNames() throw (uno::RuntimeException, std::exception)
    1447             : {
    1448           0 :     uno::Sequence< OUString > aRet(1);
    1449           0 :     OUString* pArray = aRet.getArray();
    1450           0 :     pArray[0] = "com.sun.star.text.TextContent";
    1451           0 :     return aRet;
    1452             : }
    1453             : 
    1454             : // MetadatableMixin
    1455        2025 : ::sfx2::Metadatable* SwXParagraph::GetCoreObject()
    1456             : {
    1457        2025 :     SwTextNode *const pTextNode( m_pImpl->GetTextNode() );
    1458        2025 :     return pTextNode;
    1459             : }
    1460             : 
    1461           1 : uno::Reference<frame::XModel> SwXParagraph::GetModel()
    1462             : {
    1463           1 :     SwTextNode *const pTextNode( m_pImpl->GetTextNode() );
    1464           1 :     if (pTextNode)
    1465             :     {
    1466           1 :         SwDocShell const*const pShell( pTextNode->GetDoc()->GetDocShell() );
    1467           1 :         return (pShell) ? pShell->GetModel() : 0;
    1468             :     }
    1469           0 :     return 0;
    1470         177 : }
    1471             : 
    1472             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11