LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unoparagraph.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 522 0.0 %
Date: 2014-04-14 Functions: 0 64 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10