LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unoparagraph.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 310 586 52.9 %
Date: 2014-11-03 Functions: 44 67 65.7 %
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             :     SwParaSelection(SwCursor & rCursor);
      66             :     ~SwParaSelection();
      67             : };
      68             : 
      69       38368 : SwParaSelection::SwParaSelection(SwCursor & rCursor)
      70       38368 :     : m_rCursor(rCursor)
      71             : {
      72       38368 :     if (m_rCursor.HasMark())
      73             :     {
      74           0 :         m_rCursor.DeleteMark();
      75             :     }
      76             :     // is it at the start?
      77       38368 :     if (m_rCursor.GetPoint()->nContent != 0)
      78             :     {
      79           0 :         m_rCursor.MovePara(fnParaCurr, fnParaStart);
      80             :     }
      81             :     // or at the end already?
      82       38368 :     if (m_rCursor.GetPoint()->nContent != m_rCursor.GetCntntNode()->Len())
      83             :     {
      84       22168 :         m_rCursor.SetMark();
      85       22168 :         m_rCursor.MovePara(fnParaCurr, fnParaEnd);
      86             :     }
      87       38368 : }
      88             : 
      89       38368 : SwParaSelection::~SwParaSelection()
      90             : {
      91       38368 :     if (m_rCursor.GetPoint()->nContent != 0)
      92             :     {
      93       22168 :         m_rCursor.DeleteMark();
      94       22168 :         m_rCursor.MovePara(fnParaCurr, fnParaStart);
      95             :     }
      96       38368 : }
      97             : 
      98             : static beans::PropertyState lcl_SwXParagraph_getPropertyState(
      99             :                             const SwTxtNode& rTxtNode,
     100             :                             const SwAttrSet** ppSet,
     101             :                             const SfxItemPropertySimpleEntry& rEntry,
     102             :                             bool &rAttrSetFetched )
     103             :     throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception);
     104             : 
     105      123736 : 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       61868 :     Impl(   SwXParagraph & rThis,
     123             :             SwTxtNode *const pTxtNode = 0,
     124             :             uno::Reference< text::XText > const & xParent = 0,
     125             :             const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = -1)
     126             :         : SwClient(pTxtNode)
     127             :         , m_rThis(rThis)
     128             :         , m_EventListeners(m_Mutex)
     129       61868 :         , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH))
     130       61868 :         , m_bIsDescriptor(0 == pTxtNode)
     131             :         , m_nSelectionStartPos(nSelStart)
     132             :         , m_nSelectionEndPos(nSelEnd)
     133      185604 :         , m_xParentText(xParent)
     134             :     {
     135       61868 :     }
     136             : 
     137       49528 :     SwTxtNode* GetTxtNode() {
     138       49528 :         return static_cast<SwTxtNode*>(GetRegisteredInNonConst());
     139             :     }
     140             : 
     141       43628 :     SwTxtNode & GetTxtNodeOrThrow() {
     142       43628 :         SwTxtNode *const pTxtNode( GetTxtNode() );
     143       43628 :         if (!pTxtNode) {
     144           4 :             throw uno::RuntimeException("SwXParagraph: disposed or invalid", 0);
     145             :         }
     146       43624 :         return *pTxtNode;
     147             :     }
     148             : 
     149          20 :     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       35511 : void SwXParagraph::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew )
     183             : {
     184       35511 :     ClientModify(this, pOld, pNew);
     185       35511 :     if (GetRegisteredIn())
     186             :     {
     187       61396 :         return; // core object still alive
     188             :     }
     189             : 
     190        4813 :     uno::Reference<uno::XInterface> const xThis(m_wThis);
     191        4813 :     if (!xThis.is())
     192             :     {   // fdo#72695: if UNO object is already dead, don't revive it with event
     193           0 :         return;
     194             :     }
     195        9626 :     lang::EventObject const ev(xThis);
     196        9626 :     m_EventListeners.disposeAndClear(ev);
     197             : }
     198             : 
     199          30 : SwXParagraph::SwXParagraph()
     200          30 :     : m_pImpl( new SwXParagraph::Impl(*this) )
     201             : {
     202          30 : }
     203             : 
     204       61838 : SwXParagraph::SwXParagraph(
     205             :         uno::Reference< text::XText > const & xParent,
     206             :         SwTxtNode & rTxtNode,
     207             :         const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
     208             :     : m_pImpl(
     209       61838 :         new SwXParagraph::Impl(*this, &rTxtNode, xParent, nSelStart, nSelEnd))
     210             : {
     211       61838 : }
     212             : 
     213      123736 : SwXParagraph::~SwXParagraph()
     214             : {
     215      123736 : }
     216             : 
     217         216 : const SwTxtNode * SwXParagraph::GetTxtNode() const
     218             : {
     219         216 :     return m_pImpl->GetTxtNode();
     220             : }
     221             : 
     222          20 : bool SwXParagraph::IsDescriptor() const
     223             : {
     224          20 :     return m_pImpl->IsDescriptor();
     225             : }
     226             : 
     227             : uno::Reference<text::XTextContent>
     228       70508 : SwXParagraph::CreateXParagraph(SwDoc & rDoc, SwTxtNode *const pTxtNode,
     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       70508 :     uno::Reference<text::XTextContent> xParagraph;
     235       70508 :     if (pTxtNode && (-1 == nSelStart) && (-1 == nSelEnd))
     236             :     {   // only use cache if no selection!
     237       65872 :         xParagraph.set(pTxtNode->GetXParagraph());
     238             :     }
     239       70508 :     if (xParagraph.is())
     240             :     {
     241        8640 :         return xParagraph;
     242             :     }
     243             : 
     244             :     // create new SwXParagraph
     245      123736 :     uno::Reference<text::XText> xParentText(i_xParent);
     246       61868 :     if (!xParentText.is() && pTxtNode)
     247             :     {
     248           0 :         SwPosition Pos(*pTxtNode);
     249           0 :         xParentText.set(::sw::CreateParentXText( rDoc, Pos ));
     250             :     }
     251             :     SwXParagraph *const pXPara( (pTxtNode)
     252       61838 :             ? new SwXParagraph(xParentText, *pTxtNode, nSelStart, nSelEnd)
     253      123706 :             : new SwXParagraph);
     254             :     // this is why the constructor is private: need to acquire pXPara here
     255       61868 :     xParagraph.set(pXPara);
     256             :     // in order to initialize the weak pointer cache in the core object
     257       61868 :     if (pTxtNode && (-1 == nSelStart) && (-1 == nSelEnd))
     258             :     {
     259       57232 :         pTxtNode->SetXParagraph(xParagraph);
     260             :     }
     261             :     // need a permanent Reference to initialize m_wThis
     262       61868 :     pXPara->m_pImpl->m_wThis = xParagraph;
     263       61868 :     return xParagraph;
     264             : }
     265             : 
     266           0 : bool SwXParagraph::SelectPaM(SwPaM & rPaM)
     267             : {
     268           0 :     SwTxtNode const*const pTxtNode( GetTxtNode() );
     269             : 
     270           0 :     if (!pTxtNode)
     271             :     {
     272           0 :         return false;
     273             :     }
     274             : 
     275           0 :     *rPaM.GetPoint() = SwPosition( *pTxtNode );
     276             :     // set selection to the whole paragraph
     277           0 :     rPaM.SetMark();
     278           0 :     rPaM.GetMark()->nContent = pTxtNode->GetTxt().getLength();
     279           0 :     return true;
     280             : }
     281             : 
     282             : namespace
     283             : {
     284             :     class theSwXParagraphUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXParagraphUnoTunnelId > {};
     285             : }
     286             : 
     287      111516 : const uno::Sequence< sal_Int8 > & SwXParagraph::getUnoTunnelId()
     288             : {
     289      111516 :     return theSwXParagraphUnoTunnelId::get().getSeq();
     290             : }
     291             : 
     292             : sal_Int64 SAL_CALL
     293          20 : SwXParagraph::getSomething(const uno::Sequence< sal_Int8 >& rId)
     294             : throw (uno::RuntimeException, std::exception)
     295             : {
     296          20 :     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         648 : SwXParagraph::supportsService(const OUString& rServiceName)
     322             : throw (uno::RuntimeException, std::exception)
     323             : {
     324         648 :     return cppu::supportsService(this, rServiceName);
     325             : }
     326             : 
     327             : uno::Sequence< OUString > SAL_CALL
     328         648 : SwXParagraph::getSupportedServiceNames() throw (uno::RuntimeException, std::exception)
     329             : {
     330             :     return ::sw::GetSupportedServiceNamesImpl(
     331         648 :             g_nServicesParagraph, g_ServicesParagraph);
     332             : }
     333             : 
     334             : void
     335          20 : SwXParagraph::attachToText(SwXText & rParent, SwTxtNode & rTxtNode)
     336             : {
     337             :     OSL_ENSURE(m_pImpl->m_bIsDescriptor, "Paragraph is not a descriptor");
     338          20 :     if (m_pImpl->m_bIsDescriptor)
     339             :     {
     340          20 :         m_pImpl->m_bIsDescriptor = false;
     341          20 :         rTxtNode.Add(m_pImpl.get());
     342          20 :         rTxtNode.SetXParagraph(uno::Reference<text::XTextContent>(this));
     343          20 :         m_pImpl->m_xParentText = &rParent;
     344          20 :         if (!m_pImpl->m_sText.isEmpty())
     345             :         {
     346           0 :             try { setString(m_pImpl->m_sText); }
     347           0 :             catch(...){}
     348           0 :             m_pImpl->m_sText = OUString();
     349             :         }
     350             :     }
     351          20 : }
     352             : 
     353             : uno::Reference< beans::XPropertySetInfo > SAL_CALL
     354         986 : SwXParagraph::getPropertySetInfo()
     355             : throw (uno::RuntimeException, std::exception)
     356             : {
     357         986 :     SolarMutexGuard g;
     358             : 
     359             :     static uno::Reference< beans::XPropertySetInfo > xRef =
     360         986 :         m_pImpl->m_rPropSet.getPropertySetInfo();
     361         986 :     return xRef;
     362             : }
     363             : 
     364             : void SAL_CALL
     365        3666 : 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        3666 :     SolarMutexGuard aGuard;
     372        7332 :     uno::Sequence<OUString> aPropertyNames(1);
     373        3666 :     aPropertyNames.getArray()[0] = rPropertyName;
     374        7332 :     uno::Sequence<uno::Any> aValues(1);
     375        3666 :     aValues.getArray()[0] = rValue;
     376        7332 :     m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues );
     377        3666 : }
     378             : 
     379             : uno::Any
     380        1178 : SwXParagraph::getPropertyValue(const OUString& rPropertyName)
     381             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
     382             :     uno::RuntimeException, std::exception )
     383             : {
     384        1178 :     SolarMutexGuard aGuard;
     385        2356 :     uno::Sequence<OUString> aPropertyNames(1);
     386        1178 :     aPropertyNames.getArray()[0] = rPropertyName;
     387             :     const uno::Sequence< uno::Any > aRet =
     388        2356 :         m_pImpl->GetPropertyValues_Impl(aPropertyNames);
     389        2356 :     return aRet.getConstArray()[0];
     390             : }
     391             : 
     392        3666 : 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        3666 :     SwTxtNode & rTxtNode(GetTxtNodeOrThrow());
     400             : 
     401        3666 :     SwPosition aPos( rTxtNode );
     402        7332 :     SwCursor aCursor( aPos, 0, false );
     403        3666 :     const OUString* pPropertyNames = rPropertyNames.getConstArray();
     404        3666 :     const uno::Any* pValues = rValues.getConstArray();
     405        3666 :     const SfxItemPropertyMap &rMap = m_rPropSet.getPropertyMap();
     406        7332 :     SwParaSelection aParaSel( aCursor );
     407             : 
     408        7332 :     uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
     409        7332 :     for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
     410             :     {
     411             :         SfxItemPropertySimpleEntry const*const pEntry =
     412        3666 :             rMap.getByName( pPropertyNames[nProp] );
     413        3666 :         if (!pEntry)
     414             :         {
     415             :             throw beans::UnknownPropertyException(
     416           0 :                 "Unknown property: " + pPropertyNames[nProp],
     417           0 :                 static_cast< cppu::OWeakObject * >(&m_rThis));
     418             :         }
     419        3666 :         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        3666 :         aValues[nProp].Name = pPropertyNames[nProp];
     426        3666 :         aValues[nProp].Value = pValues[nProp];
     427             :     }
     428        7332 :     SwUnoCursorHelper::SetPropertyValues(aCursor, m_rPropSet, aValues);
     429        3666 : }
     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        1016 : void SwXParagraph::Impl::GetSinglePropertyValue_Impl(
     456             :     const SfxItemPropertySimpleEntry& rEntry,
     457             :     const SfxItemSet& rSet,
     458             :     uno::Any& rAny ) const
     459             : throw(uno::RuntimeException)
     460             : {
     461        1016 :     bool bDone(false);
     462             : 
     463        1016 :     switch(rEntry.nWID)
     464             :     {
     465             :         case RES_BACKGROUND:
     466             :         {
     467           2 :             const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
     468           2 :             const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM));
     469             : 
     470           2 :             if(!aOriginalBrushItem.QueryValue(rAny, nMemberId))
     471             :             {
     472             :                 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
     473             :             }
     474             : 
     475           2 :             bDone = true;
     476           2 :             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        1014 :         default: break;
     500             :     }
     501             : 
     502        1016 :     if(!bDone)
     503             :     {
     504             :         // fallback to standard get value implementation used before this helper was created
     505        1014 :         m_rPropSet.getPropertyValue(rEntry, rSet, rAny);
     506             : 
     507        1014 :         if(rEntry.aType == ::getCppuType((const sal_Int16*)0) && rEntry.aType != rAny.getValueType())
     508             :         {
     509             :             // since the sfx uInt16 item now exports a sal_Int32, we may have to fix this here
     510          24 :             sal_Int32 nValue(0);
     511             : 
     512          24 :             rAny >>= nValue;
     513          24 :             rAny <<= static_cast< sal_Int16 >(nValue);
     514             :         }
     515             : 
     516             :         //UUUU check for needed metric translation
     517        1014 :         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        1016 : }
     545             : 
     546        1590 : 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        1590 :     SwTxtNode & rTxtNode(GetTxtNodeOrThrow());
     552             : 
     553        1590 :     uno::Sequence< uno::Any > aValues(rPropertyNames.getLength());
     554        3180 :     SwPosition aPos( rTxtNode );
     555        3180 :     SwPaM aPam( aPos );
     556        1590 :     uno::Any* pValues = aValues.getArray();
     557        1590 :     const OUString* pPropertyNames = rPropertyNames.getConstArray();
     558        1590 :     const SfxItemPropertyMap &rMap = m_rPropSet.getPropertyMap();
     559        1590 :     const SwAttrSet& rAttrSet( rTxtNode.GetSwAttrSet() );
     560        5156 :     for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
     561             :     {
     562             :         SfxItemPropertySimpleEntry const*const pEntry =
     563        3566 :             rMap.getByName( pPropertyNames[nProp] );
     564        3566 :         if (!pEntry)
     565             :         {
     566             :             throw beans::UnknownPropertyException(
     567           0 :                 "Unknown property: " + pPropertyNames[nProp],
     568           0 :                 static_cast< cppu::OWeakObject * >(&m_rThis));
     569             :         }
     570        3566 :         if (! ::sw::GetDefaultTextContentValue(
     571        3566 :                 pValues[nProp], pPropertyNames[nProp], pEntry->nWID))
     572             :         {
     573             :             beans::PropertyState eTemp;
     574             :             const bool bDone = SwUnoCursorHelper::getCrsrPropertyValue(
     575        3566 :                 *pEntry, aPam, &(pValues[nProp]), eTemp, &rTxtNode );
     576        3566 :             if (!bDone)
     577             :             {
     578             :                 //UUUU
     579         734 :                 GetSinglePropertyValue_Impl(*pEntry, rAttrSet, pValues[nProp]);
     580             :             }
     581             :         }
     582             :     }
     583        3180 :     return aValues;
     584             : }
     585             : 
     586             : uno::Sequence< uno::Any > SAL_CALL
     587         412 : SwXParagraph::getPropertyValues(const uno::Sequence< OUString >& rPropertyNames)
     588             : throw (uno::RuntimeException, std::exception)
     589             : {
     590         412 :     SolarMutexGuard aGuard;
     591         412 :     uno::Sequence< uno::Any > aValues;
     592             : 
     593             :     // workaround for bad designed API
     594             :     try
     595             :     {
     596         412 :         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         412 :     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 :     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
     651             : 
     652             :     //SwNode& rTxtNode = pUnoCrsr->GetPoint()->nNode.GetNode();
     653             :     //const SwAttrSet& rAttrSet = ((SwTxtNode&)rTxtNode).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( rTxtNode );
     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         412 : SwXParagraph::getDirectPropertyValuesTolerant(
     755             :         const uno::Sequence< OUString >& rPropertyNames )
     756             : throw (uno::RuntimeException, std::exception)
     757             : {
     758         412 :     SolarMutexGuard aGuard;
     759             : 
     760         412 :     return m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, true );
     761             : }
     762             : 
     763             : uno::Sequence< beans::GetDirectPropertyTolerantResult >
     764         412 : SwXParagraph::Impl::GetPropertyValuesTolerant_Impl(
     765             :         const uno::Sequence< OUString >& rPropertyNames,
     766             :         bool bDirectValuesOnly )
     767             : throw (uno::RuntimeException)
     768             : {
     769         412 :     SolarMutexGuard aGuard;
     770             : 
     771         412 :     SwTxtNode & rTxtNode(GetTxtNodeOrThrow());
     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         412 :     const SwAttrSet* pAttrSet = rTxtNode.GetpSwAttrSet();
     777         412 :     const SwAttrSet& rValueAttrSet = rTxtNode.GetSwAttrSet();
     778             : 
     779         412 :     sal_Int32 nProps = rPropertyNames.getLength();
     780         412 :     const OUString *pProp = rPropertyNames.getConstArray();
     781             : 
     782         412 :     uno::Sequence< beans::GetDirectPropertyTolerantResult > aResult( nProps );
     783         412 :     beans::GetDirectPropertyTolerantResult *pResult = aResult.getArray();
     784         412 :     sal_Int32 nIdx = 0;
     785             : 
     786             :     // get entry to start with
     787         412 :     const SfxItemPropertyMap &rPropMap = m_rPropSet.getPropertyMap();
     788             : 
     789       56856 :     for (sal_Int32 i = 0;  i < nProps;  ++i)
     790             :     {
     791             :         OSL_ENSURE( nIdx < nProps, "index out ouf bounds" );
     792       56444 :         beans::GetDirectPropertyTolerantResult &rResult = pResult[nIdx];
     793             : 
     794             :         try
     795             :         {
     796       56444 :             rResult.Name = pProp[i];
     797             : 
     798             :             SfxItemPropertySimpleEntry const*const pEntry =
     799       56444 :                 rPropMap.getByName( pProp[i] );
     800       56444 :             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       56444 :                 bool bAttrSetFetched = true;
     810             :                 beans::PropertyState eState = lcl_SwXParagraph_getPropertyState(
     811       56444 :                             rTxtNode, &pAttrSet, *pEntry, bAttrSetFetched );
     812       56444 :                 rResult.State  = eState;
     813             : 
     814       56444 :                 rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
     815       56444 :                 if (!bDirectValuesOnly ||
     816             :                     (beans::PropertyState_DIRECT_VALUE == eState))
     817             :                 {
     818             :                     // get property value
     819             :                     // (compare to SwXParagraph::getPropertyValue(s))
     820         282 :                     uno::Any aValue;
     821         282 :                     if (! ::sw::GetDefaultTextContentValue(
     822         282 :                                 aValue, pProp[i], pEntry->nWID ) )
     823             :                     {
     824         282 :                         SwPosition aPos( rTxtNode );
     825         564 :                         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         282 :                                     *pEntry, aPam, &aValue, eTemp, &rTxtNode );
     832             : 
     833             :                         // if not found try the real paragraph attributes...
     834         282 :                         if (!bDone)
     835             :                         {
     836             :                             //UUUU
     837         282 :                             GetSinglePropertyValue_Impl(*pEntry, rValueAttrSet, aValue);
     838         282 :                         }
     839             :                     }
     840             : 
     841         282 :                     rResult.Value  = aValue;
     842         282 :                     rResult.Result = beans::TolerantPropertySetResultType::SUCCESS;
     843             : 
     844         282 :                     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         412 :     aResult.realloc( nIdx );
     874             : 
     875         412 :     return aResult;
     876             : }
     877             : 
     878        4046 : bool ::sw::GetDefaultTextContentValue(
     879             :         uno::Any& rAny, const OUString& rPropertyName, sal_uInt16 nWID)
     880             : {
     881        4046 :     if(!nWID)
     882             :     {
     883          60 :         if(rPropertyName == UNO_NAME_ANCHOR_TYPE)
     884           4 :             nWID = FN_UNO_ANCHOR_TYPE;
     885          56 :         else if(rPropertyName == UNO_NAME_ANCHOR_TYPES)
     886           4 :             nWID = FN_UNO_ANCHOR_TYPES;
     887          52 :         else if(rPropertyName == UNO_NAME_TEXT_WRAP)
     888           4 :             nWID = FN_UNO_TEXT_WRAP;
     889             :         else
     890          48 :             return false;
     891             :     }
     892             : 
     893        3998 :     switch(nWID)
     894             :     {
     895          16 :         case FN_UNO_TEXT_WRAP:  rAny <<= text::WrapTextMode_NONE; break;
     896          16 :         case FN_UNO_ANCHOR_TYPE: rAny <<= text::TextContentAnchorType_AT_PARAGRAPH; break;
     897             :         case FN_UNO_ANCHOR_TYPES:
     898          12 :         {   uno::Sequence<text::TextContentAnchorType> aTypes(1);
     899          12 :             text::TextContentAnchorType* pArray = aTypes.getArray();
     900          12 :             pArray[0] = text::TextContentAnchorType_AT_PARAGRAPH;
     901          12 :             rAny.setValue(&aTypes, ::getCppuType((uno::Sequence<text::TextContentAnchorType>*)0));
     902             :         }
     903          12 :         break;
     904             :         default:
     905        3954 :             return false;
     906             :     }
     907          44 :     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       62512 : static beans::PropertyState lcl_SwXParagraph_getPropertyState(
     951             :     const SwTxtNode& rTxtNode,
     952             :     const SwAttrSet** ppSet,
     953             :     const SfxItemPropertySimpleEntry& rEntry,
     954             :     bool &rAttrSetFetched)
     955             :     throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
     956             : {
     957       62512 :     beans::PropertyState eRet(beans::PropertyState_DEFAULT_VALUE);
     958             : 
     959       62512 :     if(!(*ppSet) && !rAttrSetFetched)
     960             :     {
     961        6068 :         (*ppSet) = rTxtNode.GetpSwAttrSet();
     962        6068 :         rAttrSetFetched = true;
     963             :     }
     964             : 
     965       62512 :     SwPosition aPos(rTxtNode);
     966      125024 :     SwPaM aPam(aPos);
     967       62512 :     bool bDone(false);
     968             : 
     969       62512 :     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 :             SwFmtColl* pFmt = SwUnoCursorHelper::GetCurTxtFmtColl(aPam,rEntry.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME);
     997           0 :             eRet = pFmt ? 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         412 :             if(*ppSet)
    1015             :             {
    1016         272 :                 if(SfxItemState::SET == (*ppSet)->GetItemState(XATTR_FILLBMP_STRETCH, false)
    1017         136 :                     || SfxItemState::SET == (*ppSet)->GetItemState(XATTR_FILLBMP_TILE, false))
    1018             :                 {
    1019           0 :                     eRet = beans::PropertyState_DIRECT_VALUE;
    1020             :                 }
    1021             :                 else
    1022             :                 {
    1023         136 :                     eRet = beans::PropertyState_AMBIGUOUS_VALUE;
    1024             :                 }
    1025             : 
    1026         136 :                 bDone = true;
    1027             :             }
    1028         412 :             break;
    1029             :         }
    1030             :         case RES_BACKGROUND:
    1031             :         {
    1032        2060 :             if(*ppSet)
    1033             :             {
    1034         680 :                 if(SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(**ppSet))
    1035             :                 {
    1036           0 :                     eRet = beans::PropertyState_DIRECT_VALUE;
    1037           0 :                     bDone = true;
    1038             :                 }
    1039             :             }
    1040        2060 :             break;
    1041             :         }
    1042             :     }
    1043             : 
    1044       62512 :     if(!bDone)
    1045             :     {
    1046       62376 :         if((*ppSet) && SfxItemState::SET == (*ppSet)->GetItemState(rEntry.nWID, false))
    1047             :         {
    1048        6256 :             eRet = beans::PropertyState_DIRECT_VALUE;
    1049             :         }
    1050             :     }
    1051             : 
    1052      125024 :     return eRet;
    1053             : }
    1054             : 
    1055             : beans::PropertyState SAL_CALL
    1056        6068 : SwXParagraph::getPropertyState(const OUString& rPropertyName)
    1057             : throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1058             : {
    1059        6068 :     SolarMutexGuard aGuard;
    1060             : 
    1061        6068 :     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
    1062             : 
    1063        6068 :     const SwAttrSet* pSet = 0;
    1064             :     SfxItemPropertySimpleEntry const*const pEntry =
    1065        6068 :         m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
    1066        6068 :     if (!pEntry)
    1067             :     {
    1068             :         throw beans::UnknownPropertyException(
    1069           0 :             "Unknown property: " + rPropertyName,
    1070           0 :             static_cast<cppu::OWeakObject *>(this));
    1071             :     }
    1072        6068 :     bool bDummy = false;
    1073             :     const beans::PropertyState eRet =
    1074        6068 :         lcl_SwXParagraph_getPropertyState(rTxtNode, &pSet, *pEntry, bDummy);
    1075        6068 :     return eRet;
    1076             : }
    1077             : 
    1078             : uno::Sequence< beans::PropertyState > SAL_CALL
    1079           0 : SwXParagraph::getPropertyStates(
    1080             :         const uno::Sequence< OUString >& PropertyNames)
    1081             : throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1082             : {
    1083           0 :     SolarMutexGuard aGuard;
    1084             : 
    1085           0 :     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
    1086             : 
    1087           0 :     const OUString* pNames = PropertyNames.getConstArray();
    1088           0 :     uno::Sequence< beans::PropertyState > aRet(PropertyNames.getLength());
    1089           0 :     beans::PropertyState* pStates = aRet.getArray();
    1090           0 :     const SfxItemPropertyMap &rMap = m_pImpl->m_rPropSet.getPropertyMap();
    1091           0 :     const SwAttrSet* pSet = 0;
    1092           0 :     bool bAttrSetFetched = false;
    1093             : 
    1094           0 :     for (sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd;
    1095             :             ++i, ++pStates, ++pNames)
    1096             :     {
    1097             :         SfxItemPropertySimpleEntry const*const pEntry =
    1098           0 :             rMap.getByName( *pNames );
    1099           0 :         if (!pEntry)
    1100             :         {
    1101             :             throw beans::UnknownPropertyException(
    1102           0 :                 "Unknown property: " + *pNames,
    1103           0 :                 static_cast<cppu::OWeakObject *>(this));
    1104             :         }
    1105             : 
    1106           0 :         if (bAttrSetFetched && !pSet && isATR(pEntry->nWID))
    1107             :         {
    1108           0 :             *pStates = beans::PropertyState_DEFAULT_VALUE;
    1109             :         }
    1110             :         else
    1111             :         {
    1112             :             *pStates = lcl_SwXParagraph_getPropertyState(
    1113           0 :                 rTxtNode, &pSet, *pEntry, bAttrSetFetched );
    1114             :         }
    1115             :     }
    1116             : 
    1117           0 :     return aRet;
    1118             : }
    1119             : 
    1120             : void SAL_CALL
    1121           0 : SwXParagraph::setPropertyToDefault(const OUString& rPropertyName)
    1122             : throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1123             : {
    1124           0 :     SolarMutexGuard aGuard;
    1125             : 
    1126           0 :     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
    1127             : 
    1128           0 :     SwPosition aPos( rTxtNode );
    1129           0 :     SwCursor aCursor( aPos, 0, false );
    1130           0 :     if (rPropertyName == UNO_NAME_ANCHOR_TYPE  ||
    1131           0 :         rPropertyName == UNO_NAME_ANCHOR_TYPES ||
    1132           0 :         rPropertyName == UNO_NAME_TEXT_WRAP)
    1133             :     {
    1134           0 :         return;
    1135             :     }
    1136             : 
    1137             :     // select paragraph
    1138           0 :     SwParaSelection aParaSel( aCursor );
    1139             :     SfxItemPropertySimpleEntry const*const pEntry =
    1140           0 :         m_pImpl->m_rPropSet.getPropertyMap().getByName( rPropertyName );
    1141           0 :     if (!pEntry)
    1142             :     {
    1143             :         throw beans::UnknownPropertyException(
    1144           0 :             "Unknown property: " + rPropertyName,
    1145           0 :             static_cast<cppu::OWeakObject *>(this));
    1146             :     }
    1147             : 
    1148           0 :     if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
    1149             :     {
    1150             :         throw uno::RuntimeException(
    1151           0 :             "Property is read-only: " + rPropertyName,
    1152           0 :             static_cast<cppu::OWeakObject *>(this));
    1153             :     }
    1154             : 
    1155           0 :     const bool bBelowFrmAtrEnd(pEntry->nWID < RES_FRMATR_END);
    1156           0 :     const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID);
    1157             : 
    1158           0 :     if(bBelowFrmAtrEnd || bDrawingLayerRange)
    1159             :     {
    1160           0 :         std::set<sal_uInt16> aWhichIds;
    1161             : 
    1162             :         //UUUU For FillBitmapMode two IDs have to be reset (!)
    1163           0 :         if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
    1164             :         {
    1165           0 :             aWhichIds.insert(XATTR_FILLBMP_STRETCH);
    1166           0 :             aWhichIds.insert(XATTR_FILLBMP_TILE);
    1167             :         }
    1168             :         else
    1169             :         {
    1170           0 :             aWhichIds.insert(pEntry->nWID);
    1171             :         }
    1172             : 
    1173           0 :         if (pEntry->nWID < RES_PARATR_BEGIN)
    1174             :         {
    1175           0 :             aCursor.GetDoc()->ResetAttrs(aCursor, true, aWhichIds);
    1176             :         }
    1177             :         else
    1178             :         {
    1179             :             // for paragraph attributes the selection must be extended
    1180             :             // to paragraph boundaries
    1181           0 :             SwPosition aStart( *aCursor.Start() );
    1182           0 :             SwPosition aEnd  ( *aCursor.End()   );
    1183             :             boost::scoped_ptr<SwUnoCrsr> pTemp(
    1184           0 :                 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 :     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
    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 = rTxtNode.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 :     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
    1264             : 
    1265           0 :     SwPosition aPos( rTxtNode );
    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        4592 : void SAL_CALL SwXParagraph::dispose() throw (uno::RuntimeException, std::exception)
    1275             : {
    1276        4592 :     SolarMutexGuard aGuard;
    1277             : 
    1278        4592 :     SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() );
    1279        4592 :     if (pTxtNode)
    1280             :     {
    1281        4592 :         SwCursor aCursor( SwPosition( *pTxtNode ), 0, false );
    1282             :         // select paragraph
    1283             :         {
    1284        4592 :             SwParaSelection aParaSel( aCursor );
    1285        4592 :             pTxtNode->GetDoc()->getIDocumentContentOperations().DelFullPara(aCursor);
    1286             :         }
    1287        9184 :         lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
    1288        9184 :         m_pImpl->m_EventListeners.disposeAndClear(ev);
    1289        4592 :     }
    1290        4592 : }
    1291             : 
    1292           0 : void SAL_CALL SwXParagraph::addEventListener(
    1293             :         const uno::Reference< lang::XEventListener > & xListener)
    1294             : throw (uno::RuntimeException, std::exception)
    1295             : {
    1296             :     // no need to lock here as m_pImpl is const and container threadsafe
    1297           0 :     m_pImpl->m_EventListeners.addInterface(xListener);
    1298           0 : }
    1299             : 
    1300           0 : void SAL_CALL SwXParagraph::removeEventListener(
    1301             :         const uno::Reference< lang::XEventListener > & xListener)
    1302             : throw (uno::RuntimeException, std::exception)
    1303             : {
    1304             :     // no need to lock here as m_pImpl is const and container threadsafe
    1305           0 :     m_pImpl->m_EventListeners.removeInterface(xListener);
    1306           0 : }
    1307             : 
    1308             : uno::Reference< container::XEnumeration >  SAL_CALL
    1309        1582 : SwXParagraph::createEnumeration() throw (uno::RuntimeException, std::exception)
    1310             : {
    1311        1582 :     SolarMutexGuard aGuard;
    1312             : 
    1313        1582 :     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
    1314             : 
    1315        3164 :     SwPosition aPos( rTxtNode );
    1316        3164 :     SwPaM aPam ( aPos );
    1317             :     const uno::Reference< container::XEnumeration > xRef =
    1318        1582 :         new SwXTextPortionEnumeration(aPam, m_pImpl->m_xParentText,
    1319        1582 :             m_pImpl->m_nSelectionStartPos, m_pImpl->m_nSelectionEndPos);
    1320        3164 :     return xRef;
    1321             : }
    1322             : 
    1323           0 : uno::Type SAL_CALL SwXParagraph::getElementType() throw (uno::RuntimeException, std::exception)
    1324             : {
    1325           0 :     return cppu::UnoType<text::XTextRange>::get();
    1326             : }
    1327             : 
    1328           0 : sal_Bool SAL_CALL SwXParagraph::hasElements() throw (uno::RuntimeException, std::exception)
    1329             : {
    1330           0 :     SolarMutexGuard aGuard;
    1331           0 :     return (GetTxtNode()) ? sal_True : sal_False;
    1332             : }
    1333             : 
    1334             : uno::Reference< text::XText > SAL_CALL
    1335       78420 : SwXParagraph::getText() throw (uno::RuntimeException, std::exception)
    1336             : {
    1337       78420 :     SolarMutexGuard g;
    1338             : 
    1339       78420 :     return m_pImpl->m_xParentText;
    1340             : }
    1341             : 
    1342             : uno::Reference< text::XTextRange > SAL_CALL
    1343       14952 : SwXParagraph::getStart() throw (uno::RuntimeException, std::exception)
    1344             : {
    1345       14952 :     SolarMutexGuard aGuard;
    1346             : 
    1347       14952 :     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
    1348             : 
    1349       29896 :     SwPosition aPos( rTxtNode );
    1350       29896 :     SwCursor aCursor( aPos, 0, false );
    1351       29896 :     SwParaSelection aParaSel( aCursor );
    1352       29896 :     SwPaM aPam( *aCursor.Start() );
    1353       29896 :     uno::Reference< text::XText >  xParent = getText();
    1354             :     const uno::Reference< text::XTextRange > xRet =
    1355       14948 :         new SwXTextRange(aPam, xParent);
    1356       29900 :     return xRet;
    1357             : }
    1358             : 
    1359             : uno::Reference< text::XTextRange > SAL_CALL
    1360       14946 : SwXParagraph::getEnd() throw (uno::RuntimeException, std::exception)
    1361             : {
    1362       14946 :     SolarMutexGuard aGuard;
    1363             : 
    1364       14946 :     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
    1365             : 
    1366       29892 :     SwPosition aPos( rTxtNode );
    1367       29892 :     SwCursor aCursor( aPos, 0, false );
    1368       29892 :     SwParaSelection aParaSel( aCursor );
    1369       29892 :     SwPaM aPam( *aCursor.End() );
    1370       29892 :     uno::Reference< text::XText >  xParent = getText();
    1371             :     const uno::Reference< text::XTextRange > xRet =
    1372       14946 :         new SwXTextRange(aPam, xParent);
    1373       29892 :     return xRet;
    1374             : }
    1375             : 
    1376         216 : OUString SAL_CALL SwXParagraph::getString() throw (uno::RuntimeException, std::exception)
    1377             : {
    1378         216 :     SolarMutexGuard aGuard;
    1379         216 :     OUString aRet;
    1380         216 :     SwTxtNode const*const pTxtNode( GetTxtNode() );
    1381         216 :     if (pTxtNode)
    1382             :     {
    1383         216 :         SwPosition aPos( *pTxtNode );
    1384         432 :         SwCursor aCursor( aPos, 0, false );
    1385         432 :         SwParaSelection aParaSel( aCursor );
    1386         432 :         SwUnoCursorHelper::GetTextFromPam(aCursor, aRet);
    1387             :     }
    1388           0 :     else if (m_pImpl->IsDescriptor())
    1389             :     {
    1390           0 :         aRet = m_pImpl->m_sText;
    1391             :     }
    1392             :     else
    1393             :     {
    1394           0 :         throw uno::RuntimeException();
    1395             :     }
    1396         216 :     return aRet;
    1397             : }
    1398             : 
    1399           0 : void SAL_CALL SwXParagraph::setString(const OUString& aString)
    1400             : throw (uno::RuntimeException, std::exception)
    1401             : {
    1402           0 :     SolarMutexGuard aGuard;
    1403             : 
    1404           0 :     SwTxtNode const*const pTxtNode( GetTxtNode() );
    1405           0 :     if (pTxtNode)
    1406             :     {
    1407           0 :         SwPosition aPos( *pTxtNode );
    1408           0 :         SwCursor aCursor( aPos, 0, false );
    1409           0 :         if (!SwUnoCursorHelper::IsStartOfPara(aCursor)) {
    1410           0 :             aCursor.MovePara(fnParaCurr, fnParaStart);
    1411             :         }
    1412           0 :         SwUnoCursorHelper::SelectPam(aCursor, true);
    1413           0 :         if (pTxtNode->GetTxt().getLength()) {
    1414           0 :             aCursor.MovePara(fnParaCurr, fnParaEnd);
    1415             :         }
    1416           0 :         SwUnoCursorHelper::SetString(aCursor, aString);
    1417           0 :         SwUnoCursorHelper::SelectPam(aCursor, false);
    1418             :     }
    1419           0 :     else if (m_pImpl->IsDescriptor())
    1420             :     {
    1421           0 :         m_pImpl->m_sText = aString;
    1422             :     }
    1423             :     else
    1424             :     {
    1425           0 :         throw uno::RuntimeException();
    1426           0 :     }
    1427           0 : }
    1428             : 
    1429             : uno::Reference< container::XEnumeration > SAL_CALL
    1430         412 : SwXParagraph::createContentEnumeration(const OUString& rServiceName)
    1431             : throw (uno::RuntimeException, std::exception)
    1432             : {
    1433         412 :     SolarMutexGuard g;
    1434             : 
    1435         412 :     if ( rServiceName != "com.sun.star.text.TextContent" )
    1436             :     {
    1437           0 :         throw uno::RuntimeException();
    1438             :     }
    1439             : 
    1440         412 :     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
    1441             : 
    1442         824 :     SwPosition aPos( rTxtNode );
    1443         824 :     SwPaM aPam( aPos );
    1444             :     uno::Reference< container::XEnumeration > xRet =
    1445         412 :         new SwXParaFrameEnumeration(aPam, PARAFRAME_PORTION_PARAGRAPH);
    1446         824 :     return xRet;
    1447             : }
    1448             : 
    1449             : uno::Sequence< OUString > SAL_CALL
    1450           0 : SwXParagraph::getAvailableServiceNames() throw (uno::RuntimeException, std::exception)
    1451             : {
    1452           0 :     uno::Sequence< OUString > aRet(1);
    1453           0 :     OUString* pArray = aRet.getArray();
    1454           0 :     pArray[0] = "com.sun.star.text.TextContent";
    1455           0 :     return aRet;
    1456             : }
    1457             : 
    1458             : // MetadatableMixin
    1459        1090 : ::sfx2::Metadatable* SwXParagraph::GetCoreObject()
    1460             : {
    1461        1090 :     SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() );
    1462        1090 :     return pTxtNode;
    1463             : }
    1464             : 
    1465           2 : uno::Reference<frame::XModel> SwXParagraph::GetModel()
    1466             : {
    1467           2 :     SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() );
    1468           2 :     if (pTxtNode)
    1469             :     {
    1470           2 :         SwDocShell const*const pShell( pTxtNode->GetDoc()->GetDocShell() );
    1471           2 :         return (pShell) ? pShell->GetModel() : 0;
    1472             :     }
    1473           0 :     return 0;
    1474         270 : }
    1475             : 
    1476             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10