LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unosect.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 521 744 70.0 %
Date: 2014-04-11 Functions: 40 49 81.6 %
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 <unosection.hxx>
      21             : 
      22             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      23             : #include <com/sun/star/text/SectionFileLink.hpp>
      24             : 
      25             : #include <cppuhelper/interfacecontainer.h>
      26             : #include <cppuhelper/supportsservice.hxx>
      27             : 
      28             : #include <cmdid.h>
      29             : #include <hintids.hxx>
      30             : #include <svl/urihelper.hxx>
      31             : #include <editeng/brushitem.hxx>
      32             : #include <editeng/xmlcnitm.hxx>
      33             : #include <sfx2/linkmgr.hxx>
      34             : #include <sfx2/lnkbase.hxx>
      35             : #include <osl/mutex.hxx>
      36             : #include <vcl/svapp.hxx>
      37             : #include <fmtclds.hxx>
      38             : #include <unotextrange.hxx>
      39             : #include <TextCursorHelper.hxx>
      40             : #include <unoport.hxx>
      41             : #include <redline.hxx>
      42             : #include <unomap.hxx>
      43             : #include <unocrsr.hxx>
      44             : #include <section.hxx>
      45             : #include <doc.hxx>
      46             : #include <IDocumentUndoRedo.hxx>
      47             : #include <docsh.hxx>
      48             : #include <sfx2/docfile.hxx>
      49             : #include <docary.hxx>
      50             : #include <swundo.hxx>
      51             : #include <hints.hxx>
      52             : #include <tox.hxx>
      53             : #include <unoidx.hxx>
      54             : #include <doctxm.hxx>
      55             : #include <fmtftntx.hxx>
      56             : #include <fmtclbl.hxx>
      57             : #include <editeng/frmdiritem.hxx>
      58             : #include <fmtcntnt.hxx>
      59             : #include <editeng/lrspitem.hxx>
      60             : #include <comphelper/servicehelper.hxx>
      61             : #include <comphelper/string.hxx>
      62             : 
      63             : using namespace ::com::sun::star;
      64             : 
      65         109 : struct SwTextSectionProperties_Impl
      66             : {
      67             :     uno::Sequence<sal_Int8> m_Password;
      68             :     OUString  m_sCondition;
      69             :     OUString  m_sLinkFileName;
      70             :     OUString  m_sSectionFilter;
      71             :     OUString  m_sSectionRegion;
      72             : 
      73             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
      74             :     ::std::auto_ptr<SwFmtCol>               m_pColItem;
      75             :     ::std::auto_ptr<SvxBrushItem>           m_pBrushItem;
      76             :     ::std::auto_ptr<SwFmtFtnAtTxtEnd>       m_pFtnItem;
      77             :     ::std::auto_ptr<SwFmtEndAtTxtEnd>       m_pEndItem;
      78             :     ::std::auto_ptr<SvXMLAttrContainerItem> m_pXMLAttr;
      79             :     ::std::auto_ptr<SwFmtNoBalancedColumns> m_pNoBalanceItem;
      80             :     ::std::auto_ptr<SvxFrameDirectionItem>  m_pFrameDirItem;
      81             :     ::std::auto_ptr<SvxLRSpaceItem>         m_pLRSpaceItem;
      82             :     SAL_WNODEPRECATED_DECLARATIONS_POP
      83             : 
      84             :     bool m_bDDE;
      85             :     bool m_bHidden;
      86             :     bool m_bCondHidden;
      87             :     bool m_bProtect;
      88             :     bool m_bEditInReadonly;
      89             :     bool m_bUpdateType;
      90             : 
      91         109 :     SwTextSectionProperties_Impl()
      92             :         : m_bDDE(false)
      93             :         , m_bHidden(false)
      94             :         , m_bCondHidden(false)
      95             :         , m_bProtect(false)
      96             :         , m_bEditInReadonly(false)
      97         109 :         , m_bUpdateType(true)
      98             :     {
      99         109 :     }
     100             : 
     101             : };
     102             : 
     103         316 : class SwXTextSection::Impl
     104             :     : public SwClient
     105             : {
     106             : private:
     107             :     ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper
     108             : 
     109             : public:
     110             :     SwXTextSection &            m_rThis;
     111             :     const SfxItemPropertySet &  m_rPropSet;
     112             :     ::cppu::OInterfaceContainerHelper m_EventListeners;
     113             :     const bool                  m_bIndexHeader;
     114             :     bool                        m_bIsDescriptor;
     115             :     OUString             m_sName;
     116             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     117             :     ::std::auto_ptr<SwTextSectionProperties_Impl> m_pProps;
     118             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     119             : 
     120         158 :     Impl(   SwXTextSection & rThis,
     121             :             SwSectionFmt *const pFmt, const bool bIndexHeader)
     122             :         : SwClient(pFmt)
     123             :         , m_rThis(rThis)
     124         158 :         , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_SECTION))
     125             :         , m_EventListeners(m_Mutex)
     126             :         , m_bIndexHeader(bIndexHeader)
     127             :         // #i111177# unxsols4 (Sun C++ 5.9 SunOS_sparc) may generate wrong code
     128             :         , m_bIsDescriptor((0 == pFmt) ? true : false)
     129         316 :         , m_pProps((pFmt) ? 0 : new SwTextSectionProperties_Impl())
     130             :     {
     131         158 :     }
     132             : 
     133         683 :     SwSectionFmt * GetSectionFmt() const
     134             :     {
     135             :         return static_cast<SwSectionFmt*>(const_cast<SwModify*>(
     136         683 :                     GetRegisteredIn()));
     137             :     }
     138             : 
     139          36 :     SwSectionFmt & GetSectionFmtOrThrow() const {
     140          36 :         SwSectionFmt *const pFmt( GetSectionFmt() );
     141          36 :         if (!pFmt) {
     142             :             throw uno::RuntimeException(OUString(
     143           0 :                     "SwXTextSection: disposed or invalid"), 0);
     144             :         }
     145          36 :         return *pFmt;
     146             :     }
     147             : 
     148             :     void SAL_CALL SetPropertyValues_Impl(
     149             :             const uno::Sequence< OUString >& rPropertyNames,
     150             :             const uno::Sequence< uno::Any >& aValues)
     151             :         throw (beans::UnknownPropertyException, beans::PropertyVetoException,
     152             :                 lang::IllegalArgumentException, lang::WrappedTargetException,
     153             :                 uno::RuntimeException);
     154             :     uno::Sequence< uno::Any > SAL_CALL
     155             :         GetPropertyValues_Impl(
     156             :             const uno::Sequence< OUString >& rPropertyNames)
     157             :         throw (beans::UnknownPropertyException, lang::WrappedTargetException,
     158             :                 uno::RuntimeException);
     159             : protected:
     160             :     // SwClient
     161             :     virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
     162             : 
     163             : };
     164             : 
     165         193 : void SwXTextSection::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew)
     166             : {
     167         193 :     ClientModify(this, pOld, pNew);
     168         193 :     if (!GetRegisteredIn())
     169             :     {
     170          60 :         lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(m_rThis));
     171          60 :         m_EventListeners.disposeAndClear(ev);
     172             :     }
     173         193 : }
     174             : 
     175          12 : SwSectionFmt * SwXTextSection::GetFmt() const
     176             : {
     177          12 :     return m_pImpl->GetSectionFmt();
     178             : }
     179             : 
     180             : uno::Reference< text::XTextSection >
     181         259 : SwXTextSection::CreateXTextSection(
     182             :         SwSectionFmt *const pFmt, const bool bIndexHeader)
     183             : {
     184             :     // re-use existing SwXTextSection
     185             :     // #i105557#: do not iterate over the registered clients: race condition
     186         259 :     uno::Reference< text::XTextSection > xSection;
     187         259 :     if (pFmt)
     188             :     {
     189         150 :         xSection.set(pFmt->GetXTextSection());
     190             :     }
     191         259 :     if ( !xSection.is() )
     192             :     {
     193         158 :         SwXTextSection *const pNew = new SwXTextSection(pFmt, bIndexHeader);
     194         158 :         xSection.set(pNew);
     195         158 :         if (pFmt)
     196             :         {
     197          49 :             pFmt->SetXTextSection(xSection);
     198             :         }
     199             :     }
     200         259 :     return xSection;
     201             : }
     202             : 
     203         158 : SwXTextSection::SwXTextSection(
     204             :         SwSectionFmt *const pFmt, const bool bIndexHeader)
     205         158 :     : m_pImpl( new SwXTextSection::Impl(*this, pFmt, bIndexHeader) )
     206             : {
     207         158 : }
     208             : 
     209         316 : SwXTextSection::~SwXTextSection()
     210             : {
     211         316 : }
     212             : 
     213             : namespace
     214             : {
     215             :     class theSwXTextSectionUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextSectionUnoTunnelId > {};
     216             : }
     217             : 
     218        7509 : const uno::Sequence< sal_Int8 > & SwXTextSection::getUnoTunnelId()
     219             : {
     220        7509 :     return theSwXTextSectionUnoTunnelId::get().getSeq();
     221             : }
     222             : 
     223             : sal_Int64 SAL_CALL
     224         286 : SwXTextSection::getSomething(const uno::Sequence< sal_Int8 >& rId)
     225             : throw (uno::RuntimeException, std::exception)
     226             : {
     227         286 :     return ::sw::UnoTunnelImpl<SwXTextSection>(rId, this);
     228             : }
     229             : 
     230             : uno::Reference< text::XTextSection > SAL_CALL
     231          35 : SwXTextSection::getParentSection() throw (uno::RuntimeException, std::exception)
     232             : {
     233          35 :     SolarMutexGuard aGuard;
     234             : 
     235          35 :     SwSectionFmt & rSectionFmt( m_pImpl->GetSectionFmtOrThrow() );
     236             : 
     237          35 :     SwSectionFmt *const pParentFmt = rSectionFmt.GetParent();
     238             :     const uno::Reference< text::XTextSection > xRet =
     239          35 :         (pParentFmt) ? CreateXTextSection(pParentFmt) : 0;
     240          35 :     return xRet;
     241             : }
     242             : 
     243             : uno::Sequence< uno::Reference< text::XTextSection > > SAL_CALL
     244           1 : SwXTextSection::getChildSections() throw (uno::RuntimeException, std::exception)
     245             : {
     246           1 :     SolarMutexGuard aGuard;
     247             : 
     248           1 :     SwSectionFmt & rSectionFmt( m_pImpl->GetSectionFmtOrThrow() );
     249             : 
     250           2 :     SwSections aChildren;
     251           1 :     rSectionFmt.GetChildSections(aChildren, SORTSECT_NOT, sal_False);
     252           1 :     uno::Sequence<uno::Reference<text::XTextSection> > aSeq(aChildren.size());
     253           1 :     uno::Reference< text::XTextSection > * pArray = aSeq.getArray();
     254           2 :     for (sal_uInt16 i = 0; i < aChildren.size(); i++)
     255             :     {
     256           1 :         SwSectionFmt *const pChild = aChildren[i]->GetFmt();
     257           1 :         pArray[i] = CreateXTextSection(pChild);
     258             :     }
     259           2 :     return aSeq;
     260             : }
     261             : 
     262             : void SAL_CALL
     263         101 : SwXTextSection::attach(const uno::Reference< text::XTextRange > & xTextRange)
     264             : throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
     265             : {
     266         101 :     SolarMutexGuard g;
     267             : 
     268         101 :     if (!m_pImpl->m_bIsDescriptor)
     269             :     {
     270           0 :         throw uno::RuntimeException();
     271             :     }
     272             : 
     273         202 :     uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
     274         101 :     SwXTextRange* pRange = 0;
     275         101 :     OTextCursorHelper* pCursor = 0;
     276         101 :     if(xRangeTunnel.is())
     277             :     {
     278         101 :         pRange  = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
     279             :         pCursor =
     280         101 :             ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
     281             :     }
     282             : 
     283             :     SwDoc *const pDoc =
     284         101 :         (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0);
     285         101 :     if (!pDoc)
     286             :     {
     287           0 :         throw lang::IllegalArgumentException();
     288             :     }
     289             : 
     290         202 :     SwUnoInternalPaM aPam(*pDoc);
     291             :     //das muss jetzt sal_True liefern
     292         101 :     ::sw::XTextRangeToSwPaM(aPam, xTextRange);
     293         202 :     UnoActionContext aCont(pDoc);
     294         101 :     pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_INSSECTION, NULL );
     295             : 
     296         101 :     if (m_pImpl->m_sName.isEmpty())
     297             :     {
     298          72 :         m_pImpl->m_sName = "TextSection";
     299             :     }
     300         101 :     SectionType eType = (m_pImpl->m_pProps->m_bDDE)
     301             :         ? DDE_LINK_SECTION
     302         202 :         : ((!m_pImpl->m_pProps->m_sLinkFileName.isEmpty() ||
     303         101 :             !m_pImpl->m_pProps->m_sSectionRegion.isEmpty())
     304         202 :                 ?  FILE_LINK_SECTION : CONTENT_SECTION);
     305             :     // index header section?
     306         101 :     if (m_pImpl->m_bIndexHeader)
     307             :     {
     308             :         // caller wants an index header section, but will only
     309             :         // give him one if a) we are inside an index, and b) said
     310             :         // index doesn't yet have a header section.
     311          15 :         const SwTOXBase* pBase = aPam.GetDoc()->GetCurTOX(*aPam.Start());
     312             : 
     313             :         // are we inside an index?
     314          15 :         if (pBase)
     315             :         {
     316             :             // get all child sections
     317          15 :             SwSections aSectionsArr;
     318             :             static_cast<const SwTOXBaseSection*>(pBase)->GetFmt()->
     319          15 :                 GetChildSections(aSectionsArr);
     320             : 
     321             :             // and search for current header section
     322          15 :             const sal_uInt16 nCount = aSectionsArr.size();
     323          15 :             bool bHeaderPresent = false;
     324          15 :             for(sal_uInt16 i = 0; i < nCount; i++)
     325             :             {
     326           0 :                 if (aSectionsArr[i]->GetType() == TOX_HEADER_SECTION)
     327           0 :                     bHeaderPresent = true;
     328             :             }
     329          15 :             if (! bHeaderPresent)
     330             :             {
     331          15 :                 eType = TOX_HEADER_SECTION;
     332          15 :             }
     333             :         }
     334             :     }
     335             : 
     336         202 :     SwSectionData aSect(eType, pDoc->GetUniqueSectionName(&m_pImpl->m_sName));
     337         101 :     aSect.SetCondition(m_pImpl->m_pProps->m_sCondition);
     338         202 :     OUStringBuffer sLinkNameBuf(m_pImpl->m_pProps->m_sLinkFileName);
     339         101 :     sLinkNameBuf.append(sfx2::cTokenSeparator);
     340         101 :     sLinkNameBuf.append(m_pImpl->m_pProps->m_sSectionFilter);
     341         101 :     sLinkNameBuf.append(sfx2::cTokenSeparator);
     342         101 :     sLinkNameBuf.append(m_pImpl->m_pProps->m_sSectionRegion);
     343         101 :     aSect.SetLinkFileName(sLinkNameBuf.makeStringAndClear());
     344             : 
     345         101 :     aSect.SetHidden(m_pImpl->m_pProps->m_bHidden);
     346         101 :     aSect.SetProtectFlag(m_pImpl->m_pProps->m_bProtect);
     347         101 :     aSect.SetEditInReadonlyFlag(m_pImpl->m_pProps->m_bEditInReadonly);
     348             : 
     349         101 :     SfxItemSet aSet(pDoc->GetAttrPool(),
     350             :                 RES_COL, RES_COL,
     351             :                 RES_BACKGROUND, RES_BACKGROUND,
     352             :                 RES_FTN_AT_TXTEND, RES_FRAMEDIR,
     353             :                 RES_LR_SPACE, RES_LR_SPACE,
     354             :                 RES_UNKNOWNATR_CONTAINER,RES_UNKNOWNATR_CONTAINER,
     355         202 :                 0);
     356         101 :     if (m_pImpl->m_pProps->m_pBrushItem.get())
     357             :     {
     358           1 :         aSet.Put(*m_pImpl->m_pProps->m_pBrushItem);
     359             :     }
     360         101 :     if (m_pImpl->m_pProps->m_pColItem.get())
     361             :     {
     362          29 :         aSet.Put(*m_pImpl->m_pProps->m_pColItem);
     363             :     }
     364         101 :     if (m_pImpl->m_pProps->m_pFtnItem.get())
     365             :     {
     366           0 :         aSet.Put(*m_pImpl->m_pProps->m_pFtnItem);
     367             :     }
     368         101 :     if (m_pImpl->m_pProps->m_pEndItem.get())
     369             :     {
     370           0 :         aSet.Put(*m_pImpl->m_pProps->m_pEndItem);
     371             :     }
     372         101 :     if (m_pImpl->m_pProps->m_pXMLAttr.get())
     373             :     {
     374           0 :         aSet.Put(*m_pImpl->m_pProps->m_pXMLAttr);
     375             :     }
     376         101 :     if (m_pImpl->m_pProps->m_pNoBalanceItem.get())
     377             :     {
     378           8 :         aSet.Put(*m_pImpl->m_pProps->m_pNoBalanceItem);
     379             :     }
     380         101 :     if (m_pImpl->m_pProps->m_pFrameDirItem.get())
     381             :     {
     382           0 :         aSet.Put(*m_pImpl->m_pProps->m_pFrameDirItem);
     383             :     }
     384         101 :     if (m_pImpl->m_pProps->m_pLRSpaceItem.get())
     385             :     {
     386           8 :         aSet.Put(*m_pImpl->m_pProps->m_pLRSpaceItem);
     387             :     }
     388             :     // section password
     389         101 :     if (m_pImpl->m_pProps->m_Password.getLength() > 0)
     390             :     {
     391           2 :         aSect.SetPassword(m_pImpl->m_pProps->m_Password);
     392             :     }
     393             : 
     394             :     SwSection *const pRet =
     395         101 :         pDoc->InsertSwSection( aPam, aSect, 0, aSet.Count() ? &aSet : 0 );
     396         101 :     if (!pRet) // fdo#42450 text range could parially overlap existing section
     397             :     {
     398             :         // shouldn't have created an undo object yet
     399           0 :         pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_INSSECTION, NULL );
     400             :         throw lang::IllegalArgumentException(
     401             :                 "SwXTextSection::attach(): invalid TextRange",
     402           0 :                 static_cast< ::cppu::OWeakObject*>(this), 0);
     403             :     }
     404         101 :     pRet->GetFmt()->Add(m_pImpl.get());
     405         101 :     pRet->GetFmt()->SetXObject(static_cast< ::cppu::OWeakObject*>(this));
     406             : 
     407             :     // XML import must hide sections depending on their old
     408             :     //         condition status
     409         101 :     if (!m_pImpl->m_pProps->m_sCondition.isEmpty())
     410             :     {
     411           3 :         pRet->SetCondHidden(m_pImpl->m_pProps->m_bCondHidden);
     412             :     }
     413             : 
     414             :     // set update type if DDE link (and connect, if necessary)
     415         101 :     if (m_pImpl->m_pProps->m_bDDE)
     416             :     {
     417           0 :         if (! pRet->IsConnected())
     418             :         {
     419           0 :             pRet->CreateLink(CREATE_CONNECT);
     420             :         }
     421             :         pRet->SetUpdateType( static_cast< sal_uInt16 >(
     422           0 :             (m_pImpl->m_pProps->m_bUpdateType) ?
     423           0 :                 sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) );
     424             :     }
     425             : 
     426             :     // Undo-Klammerung hier beenden
     427         101 :     pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_INSSECTION, NULL );
     428         101 :     m_pImpl->m_pProps.reset();
     429         202 :     m_pImpl->m_bIsDescriptor = false;
     430         101 : }
     431             : 
     432             : uno::Reference< text::XTextRange > SAL_CALL
     433           1 : SwXTextSection::getAnchor() throw (uno::RuntimeException, std::exception)
     434             : {
     435           1 :     SolarMutexGuard aGuard;
     436             : 
     437           1 :     uno::Reference< text::XTextRange >  xRet;
     438           1 :     SwSectionFmt *const pSectFmt = m_pImpl->GetSectionFmt();
     439           1 :     if(pSectFmt)
     440             :     {
     441             :         const SwNodeIndex* pIdx;
     442           3 :         if( 0 != ( pSectFmt->GetSection() ) &&
     443           2 :             0 != ( pIdx = pSectFmt->GetCntnt().GetCntntIdx() ) &&
     444           1 :             pIdx->GetNode().GetNodes().IsDocNodes() )
     445             :         {
     446           1 :             SwPaM aPaM(*pIdx);
     447           1 :             aPaM.Move( fnMoveForward, fnGoCntnt );
     448             : 
     449           1 :             const SwEndNode* pEndNode = pIdx->GetNode().EndOfSectionNode();
     450           2 :             SwPaM aEnd(*pEndNode);
     451           1 :             aEnd.Move( fnMoveBackward, fnGoCntnt );
     452           2 :             xRet = SwXTextRange::CreateXTextRange(*pSectFmt->GetDoc(),
     453           3 :                 *aPaM.Start(), aEnd.Start());
     454             :         }
     455             :     }
     456           1 :     return xRet;
     457             : }
     458             : 
     459           3 : void SAL_CALL SwXTextSection::dispose() throw (uno::RuntimeException, std::exception)
     460             : {
     461           3 :     SolarMutexGuard aGuard;
     462             : 
     463           3 :     SwSectionFmt *const pSectFmt = m_pImpl->GetSectionFmt();
     464           3 :     if (pSectFmt)
     465             :     {
     466           3 :         pSectFmt->GetDoc()->DelSectionFmt( pSectFmt );
     467           3 :     }
     468           3 : }
     469             : 
     470           2 : void SAL_CALL SwXTextSection::addEventListener(
     471             :         const uno::Reference< lang::XEventListener > & xListener)
     472             : throw (uno::RuntimeException, std::exception)
     473             : {
     474             :     // no need to lock here as m_pImpl is const and container threadsafe
     475           2 :     m_pImpl->m_EventListeners.addInterface(xListener);
     476           2 : }
     477             : 
     478           1 : void SAL_CALL SwXTextSection::removeEventListener(
     479             :         const uno::Reference< lang::XEventListener > & xListener)
     480             : throw (uno::RuntimeException, std::exception)
     481             : {
     482             :     // no need to lock here as m_pImpl is const and container threadsafe
     483           1 :     m_pImpl->m_EventListeners.removeInterface(xListener);
     484           1 : }
     485             : 
     486             : uno::Reference< beans::XPropertySetInfo > SAL_CALL
     487         156 : SwXTextSection::getPropertySetInfo() throw (uno::RuntimeException, std::exception)
     488             : {
     489         156 :     SolarMutexGuard g;
     490             : 
     491             :     static const uno::Reference< beans::XPropertySetInfo >  aRef =
     492         156 :         m_pImpl->m_rPropSet.getPropertySetInfo();
     493         156 :     return aRef;
     494             : }
     495             : 
     496             : static void
     497           2 : lcl_UpdateLinkType(SwSection & rSection, bool const bLinkUpdateAlways = true)
     498             : {
     499           2 :     if (rSection.GetType() == DDE_LINK_SECTION)
     500             :     {
     501             :         // set update type; needs an established link
     502           2 :         if (!rSection.IsConnected())
     503             :         {
     504           0 :             rSection.CreateLink(CREATE_CONNECT);
     505             :         }
     506             :         rSection.SetUpdateType( static_cast< sal_uInt16 >((bLinkUpdateAlways)
     507           2 :             ? sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) );
     508             :     }
     509           2 : }
     510             : 
     511             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
     512             : static void
     513         158 : lcl_UpdateSection(SwSectionFmt *const pFmt,
     514             :     ::std::auto_ptr<SwSectionData> const& pSectionData,
     515             :     ::std::auto_ptr<SfxItemSet> const& pItemSet,
     516             :     bool const bLinkModeChanged, bool const bLinkUpdateAlways = true)
     517             : {
     518         158 :     if (pFmt)
     519             :     {
     520          80 :         SwSection & rSection = *pFmt->GetSection();
     521          80 :         SwDoc *const pDoc = pFmt->GetDoc();
     522          80 :         SwSectionFmts const& rFmts = pDoc->GetSections();
     523          80 :         UnoActionContext aContext(pDoc);
     524          85 :         for (sal_uInt16 i = 0; i < rFmts.size(); i++)
     525             :         {
     526         255 :             if (rFmts[i]->GetSection()->GetSectionName()
     527         255 :                     == rSection.GetSectionName())
     528             :             {
     529          80 :                 pDoc->UpdateSection(i, *pSectionData, pItemSet.get(),
     530         160 :                         pDoc->IsInReading());
     531             :                 {
     532             :                     // temporarily remove actions to allow cursor update
     533          80 :                     UnoActionRemoveContext aRemoveContext( pDoc );
     534             :                 }
     535             : 
     536          80 :                 if (bLinkModeChanged)
     537             :                 {
     538           2 :                     lcl_UpdateLinkType(rSection, bLinkUpdateAlways);
     539             :                 }
     540             :                 // section found and processed: break from loop
     541          80 :                 break;
     542             :             }
     543          80 :         }
     544             :     }
     545         158 : }
     546             : SAL_WNODEPRECATED_DECLARATIONS_POP
     547             : 
     548         163 : void SwXTextSection::Impl::SetPropertyValues_Impl(
     549             :     const uno::Sequence< OUString >& rPropertyNames,
     550             :     const uno::Sequence< uno::Any >& rValues)
     551             : throw (beans::UnknownPropertyException, beans::PropertyVetoException,
     552             :         lang::IllegalArgumentException, lang::WrappedTargetException,
     553             :         uno::RuntimeException)
     554             : {
     555         163 :     if(rPropertyNames.getLength() != rValues.getLength())
     556             :     {
     557           0 :         throw lang::IllegalArgumentException();
     558             :     }
     559         163 :     SwSectionFmt *const pFmt = GetSectionFmt();
     560         163 :     if (!pFmt && !m_bIsDescriptor)
     561             :     {
     562           0 :         throw uno::RuntimeException();
     563             :     }
     564             : 
     565             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     566             :     ::std::auto_ptr<SwSectionData> const pSectionData(
     567         163 :         (pFmt) ? new SwSectionData(*pFmt->GetSection()) : 0);
     568             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     569             : 
     570         163 :     OUString const*const pPropertyNames = rPropertyNames.getConstArray();
     571         163 :     uno::Any const*const pValues = rValues.getConstArray();
     572             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     573         326 :     ::std::auto_ptr<SfxItemSet> pItemSet;
     574             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     575         163 :     bool bLinkModeChanged = false;
     576         163 :     sal_Bool bLinkMode = sal_False;
     577             : 
     578         370 :     for (sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength();
     579             :          nProperty++)
     580             :     {
     581             :         SfxItemPropertySimpleEntry const*const pEntry =
     582         213 :             m_rPropSet.getPropertyMap().getByName(pPropertyNames[nProperty]);
     583         213 :         if (!pEntry)
     584             :         {
     585             :             throw beans::UnknownPropertyException(
     586             :                 OUString("Unknown property: ")
     587           0 :                     + pPropertyNames[nProperty],
     588           0 :                 static_cast<cppu::OWeakObject *>(& m_rThis));
     589             :         }
     590         213 :         if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
     591             :         {
     592             :             throw beans::PropertyVetoException(
     593             :                 OUString("Property is read-only: ")
     594           6 :                     + pPropertyNames[nProperty],
     595           9 :                 static_cast<cppu::OWeakObject *>(& m_rThis));
     596             :         }
     597         210 :         switch (pEntry->nWID)
     598             :         {
     599             :             case WID_SECT_CONDITION:
     600             :             {
     601           5 :                 OUString uTmp;
     602           5 :                 pValues[nProperty] >>= uTmp;
     603           5 :                 if (m_bIsDescriptor)
     604             :                 {
     605           3 :                     m_pProps->m_sCondition = uTmp;
     606             :                 }
     607             :                 else
     608             :                 {
     609           2 :                     pSectionData->SetCondition(uTmp);
     610           5 :                 }
     611             :             }
     612           5 :             break;
     613             :             case WID_SECT_DDE_TYPE:
     614             :             case WID_SECT_DDE_FILE:
     615             :             case WID_SECT_DDE_ELEMENT:
     616             :             {
     617           6 :                 OUString sTmp;
     618           6 :                 pValues[nProperty] >>= sTmp;
     619           6 :                 if (m_bIsDescriptor)
     620             :                 {
     621           0 :                     if (!m_pProps->m_bDDE)
     622             :                     {
     623           0 :                         OUStringBuffer buf;
     624           0 :                         buf.append(sfx2::cTokenSeparator);
     625           0 :                         buf.append(sfx2::cTokenSeparator);
     626           0 :                         m_pProps->m_sLinkFileName = buf.makeStringAndClear();
     627           0 :                         m_pProps->m_bDDE = true;
     628             :                     }
     629           0 :                     OUString sLinkFileName(m_pProps->m_sLinkFileName);
     630           0 :                     sLinkFileName = comphelper::string::setToken(sLinkFileName,
     631           0 :                         pEntry->nWID - WID_SECT_DDE_TYPE, sfx2::cTokenSeparator, sTmp);
     632           0 :                     m_pProps->m_sLinkFileName = sLinkFileName;
     633             :                 }
     634             :                 else
     635             :                 {
     636           6 :                     OUString sLinkFileName(pSectionData->GetLinkFileName());
     637           6 :                     if (pSectionData->GetType() != DDE_LINK_SECTION)
     638             :                     {
     639           5 :                         sLinkFileName = OUString(sfx2::cTokenSeparator) + OUString(sfx2::cTokenSeparator);
     640           5 :                         pSectionData->SetType(DDE_LINK_SECTION);
     641             :                     }
     642          18 :                     sLinkFileName = comphelper::string::setToken(sLinkFileName,
     643           6 :                         pEntry->nWID - WID_SECT_DDE_TYPE,
     644           6 :                             sfx2::cTokenSeparator, sTmp);
     645           6 :                     pSectionData->SetLinkFileName(sLinkFileName);
     646           6 :                 }
     647             :             }
     648           6 :             break;
     649             :             case WID_SECT_DDE_AUTOUPDATE:
     650             :             {
     651           2 :                 sal_Bool bVal(sal_False);
     652           2 :                 if (!(pValues[nProperty] >>= bVal))
     653             :                 {
     654           0 :                     throw lang::IllegalArgumentException();
     655             :                 }
     656           2 :                 if (m_bIsDescriptor)
     657             :                 {
     658           0 :                     m_pProps->m_bUpdateType = bVal;
     659             :                 }
     660             :                 else
     661             :                 {
     662           2 :                     bLinkModeChanged = true;
     663           2 :                     bLinkMode = bVal;
     664             :                 }
     665             :             }
     666           2 :             break;
     667             :             case WID_SECT_LINK:
     668             :             {
     669           2 :                 text::SectionFileLink aLink;
     670           2 :                 if (!(pValues[nProperty] >>= aLink))
     671             :                 {
     672           0 :                     throw lang::IllegalArgumentException();
     673             :                 }
     674           2 :                 if (m_bIsDescriptor)
     675             :                 {
     676           0 :                     m_pProps->m_bDDE = false;
     677           0 :                     m_pProps->m_sLinkFileName = aLink.FileURL;
     678           0 :                     m_pProps->m_sSectionFilter = aLink.FilterName;
     679             :                 }
     680             :                 else
     681             :                 {
     682           4 :                     if (pSectionData->GetType() != FILE_LINK_SECTION &&
     683           2 :                         !aLink.FileURL.isEmpty())
     684             :                     {
     685           2 :                         pSectionData->SetType(FILE_LINK_SECTION);
     686             :                     }
     687           2 :                     OUStringBuffer sFileNameBuf;
     688           2 :                     if (!aLink.FileURL.isEmpty())
     689             :                     {
     690             :                         sFileNameBuf.append( URIHelper::SmartRel2Abs(
     691           2 :                             pFmt->GetDoc()->GetDocShell()->GetMedium()
     692           2 :                                 ->GetURLObject(),
     693           4 :                             aLink.FileURL, URIHelper::GetMaybeFileHdl()));
     694             :                     }
     695           2 :                     sFileNameBuf.append(sfx2::cTokenSeparator);
     696           2 :                     sFileNameBuf.append(aLink.FilterName);
     697           2 :                     sFileNameBuf.append(sfx2::cTokenSeparator);
     698             :                     sFileNameBuf.append(
     699             :                         pSectionData->GetLinkFileName().getToken(2,
     700           2 :                             sfx2::cTokenSeparator));
     701             :                     const OUString sFileName(
     702           4 :                             sFileNameBuf.makeStringAndClear());
     703           2 :                     pSectionData->SetLinkFileName(sFileName);
     704           2 :                     if (sFileName.getLength() < 3)
     705             :                     {
     706           0 :                         pSectionData->SetType(CONTENT_SECTION);
     707           2 :                     }
     708           2 :                 }
     709             :             }
     710           2 :             break;
     711             :             case WID_SECT_REGION:
     712             :             {
     713           2 :                 OUString sLink;
     714           2 :                 pValues[nProperty] >>= sLink;
     715           2 :                 if (m_bIsDescriptor)
     716             :                 {
     717           0 :                     m_pProps->m_bDDE = false;
     718           0 :                     m_pProps->m_sSectionRegion = sLink;
     719             :                 }
     720             :                 else
     721             :                 {
     722           4 :                     if (pSectionData->GetType() != FILE_LINK_SECTION &&
     723           2 :                         !sLink.isEmpty())
     724             :                     {
     725           2 :                         pSectionData->SetType(FILE_LINK_SECTION);
     726             :                     }
     727           2 :                     OUString sSectLink(pSectionData->GetLinkFileName());
     728           4 :                     while (3 < comphelper::string::getTokenCount(sSectLink, sfx2::cTokenSeparator))
     729             :                     {
     730           0 :                         sSectLink += OUString(sfx2::cTokenSeparator);
     731             :                     }
     732           2 :                     sSectLink = comphelper::string::setToken(sSectLink, 2, sfx2::cTokenSeparator, sLink);
     733           2 :                     pSectionData->SetLinkFileName(sSectLink);
     734           2 :                     if (sSectLink.getLength() < 3)
     735             :                     {
     736           0 :                         pSectionData->SetType(CONTENT_SECTION);
     737           2 :                     }
     738           2 :                 }
     739             :             }
     740           2 :             break;
     741             :             case WID_SECT_VISIBLE:
     742             :             {
     743          17 :                 sal_Bool bVal(sal_False);
     744          17 :                 if (!(pValues[nProperty] >>= bVal))
     745             :                 {
     746           0 :                     throw lang::IllegalArgumentException();
     747             :                 }
     748          17 :                 if (m_bIsDescriptor)
     749             :                 {
     750          15 :                     m_pProps->m_bHidden = !bVal;
     751             :                 }
     752             :                 else
     753             :                 {
     754           2 :                     pSectionData->SetHidden(!bVal);
     755             :                 }
     756             :             }
     757          17 :             break;
     758             :             case WID_SECT_CURRENTLY_VISIBLE:
     759             :             {
     760           1 :                 sal_Bool bVal(sal_False);
     761           1 :                 if (!(pValues[nProperty] >>= bVal))
     762             :                 {
     763           0 :                     throw lang::IllegalArgumentException();
     764             :                 }
     765           1 :                 if (m_bIsDescriptor)
     766             :                 {
     767           0 :                     m_pProps->m_bCondHidden = !bVal;
     768             :                 }
     769             :                 else
     770             :                 {
     771           1 :                     if (!pSectionData->GetCondition().isEmpty())
     772             :                     {
     773           0 :                         pSectionData->SetCondHidden(!bVal);
     774             :                     }
     775             :                 }
     776             :             }
     777           1 :             break;
     778             :             case WID_SECT_PROTECTED:
     779             :             {
     780          31 :                 sal_Bool bVal(sal_False);
     781          31 :                 if (!(pValues[nProperty] >>= bVal))
     782             :                 {
     783           0 :                     throw lang::IllegalArgumentException();
     784             :                 }
     785          31 :                 if (m_bIsDescriptor)
     786             :                 {
     787          29 :                     m_pProps->m_bProtect = bVal;
     788             :                 }
     789             :                 else
     790             :                 {
     791           2 :                     pSectionData->SetProtectFlag(bVal);
     792             :                 }
     793             :             }
     794          31 :             break;
     795             :             case WID_SECT_EDIT_IN_READONLY:
     796             :             {
     797          23 :                 sal_Bool bVal(sal_False);
     798          23 :                 if (!(pValues[nProperty] >>= bVal))
     799             :                 {
     800           0 :                     throw lang::IllegalArgumentException();
     801             :                 }
     802          23 :                 if (m_bIsDescriptor)
     803             :                 {
     804          21 :                     m_pProps->m_bEditInReadonly = bVal;
     805             :                 }
     806             :                 else
     807             :                 {
     808           2 :                     pSectionData->SetEditInReadonlyFlag(bVal);
     809             :                 }
     810             :             }
     811          23 :             break;
     812             :             case WID_SECT_PASSWORD:
     813             :             {
     814           4 :                 uno::Sequence<sal_Int8> aSeq;
     815           4 :                 pValues[nProperty] >>= aSeq;
     816           4 :                 if (m_bIsDescriptor)
     817             :                 {
     818           2 :                     m_pProps->m_Password = aSeq;
     819             :                 }
     820             :                 else
     821             :                 {
     822           2 :                     pSectionData->SetPassword(aSeq);
     823           4 :                 }
     824             :             }
     825           4 :             break;
     826             :             default:
     827             :             {
     828         117 :                 if (pFmt)
     829             :                 {
     830          59 :                     const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet();
     831          59 :                     pItemSet.reset( new SfxItemSet(*rOldAttrSet.GetPool(), pEntry->nWID, pEntry->nWID));
     832          59 :                     pItemSet->Put(rOldAttrSet);
     833             :                     m_rPropSet.setPropertyValue(*pEntry,
     834          59 :                             pValues[nProperty], *pItemSet);
     835             :                 }
     836             :                 else
     837             :                 {
     838          58 :                     SfxPoolItem* pPutItem = 0;
     839          58 :                     if (RES_COL == pEntry->nWID)
     840             :                     {
     841          29 :                         if (!m_pProps->m_pColItem.get())
     842             :                         {
     843          29 :                             m_pProps->m_pColItem.reset(new SwFmtCol);
     844             :                         }
     845          29 :                         pPutItem = m_pProps->m_pColItem.get();
     846             :                     }
     847          29 :                     else if (RES_BACKGROUND == pEntry->nWID)
     848             :                     {
     849           5 :                         if (!m_pProps->m_pBrushItem.get())
     850             :                         {
     851           1 :                             m_pProps->m_pBrushItem.reset(
     852           2 :                                 new SvxBrushItem(RES_BACKGROUND));
     853             :                         }
     854           5 :                         pPutItem = m_pProps->m_pBrushItem.get();
     855             :                     }
     856          24 :                     else if (RES_FTN_AT_TXTEND == pEntry->nWID)
     857             :                     {
     858           0 :                         if (!m_pProps->m_pFtnItem.get())
     859             :                         {
     860           0 :                             m_pProps->m_pFtnItem.reset(new SwFmtFtnAtTxtEnd);
     861             :                         }
     862           0 :                         pPutItem = m_pProps->m_pFtnItem.get();
     863             :                     }
     864          24 :                     else if (RES_END_AT_TXTEND == pEntry->nWID)
     865             :                     {
     866           0 :                         if (!m_pProps->m_pEndItem.get())
     867             :                         {
     868           0 :                             m_pProps->m_pEndItem.reset(new SwFmtEndAtTxtEnd);
     869             :                         }
     870           0 :                         pPutItem = m_pProps->m_pEndItem.get();
     871             :                     }
     872          24 :                     else if (RES_UNKNOWNATR_CONTAINER== pEntry->nWID)
     873             :                     {
     874           0 :                         if (!m_pProps->m_pXMLAttr.get())
     875             :                         {
     876           0 :                             m_pProps->m_pXMLAttr.reset(
     877             :                                 new SvXMLAttrContainerItem(
     878           0 :                                     RES_UNKNOWNATR_CONTAINER));
     879             :                         }
     880           0 :                         pPutItem = m_pProps->m_pXMLAttr.get();
     881             :                     }
     882          24 :                     else if (RES_COLUMNBALANCE== pEntry->nWID)
     883             :                     {
     884           8 :                         if (!m_pProps->m_pNoBalanceItem.get())
     885             :                         {
     886           8 :                             m_pProps->m_pNoBalanceItem.reset(
     887          16 :                                 new SwFmtNoBalancedColumns(RES_COLUMNBALANCE));
     888             :                         }
     889           8 :                         pPutItem = m_pProps->m_pNoBalanceItem.get();
     890             :                     }
     891          16 :                     else if (RES_FRAMEDIR == pEntry->nWID)
     892             :                     {
     893           0 :                         if (!m_pProps->m_pFrameDirItem.get())
     894             :                         {
     895           0 :                             m_pProps->m_pFrameDirItem.reset(
     896             :                                 new SvxFrameDirectionItem(
     897           0 :                                 FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR));
     898             :                         }
     899           0 :                         pPutItem = m_pProps->m_pFrameDirItem.get();
     900             :                     }
     901          16 :                     else if (RES_LR_SPACE == pEntry->nWID)
     902             :                     {
     903          16 :                         if (!m_pProps->m_pLRSpaceItem.get())
     904             :                         {
     905           8 :                             m_pProps->m_pLRSpaceItem.reset(
     906          16 :                                 new SvxLRSpaceItem( RES_LR_SPACE ));
     907             :                         }
     908          16 :                         pPutItem = m_pProps->m_pLRSpaceItem.get();
     909             :                     }
     910          58 :                     if (pPutItem)
     911             :                     {
     912          58 :                         pPutItem->PutValue(pValues[nProperty],
     913         116 :                                 pEntry->nMemberId);
     914             :                     }
     915             :                 }
     916             :             }
     917             :         }
     918             :     }
     919             : 
     920             :     lcl_UpdateSection(pFmt, pSectionData, pItemSet, bLinkModeChanged,
     921         320 :         bLinkMode);
     922         157 : }
     923             : 
     924             : void SAL_CALL
     925          29 : SwXTextSection::setPropertyValues(
     926             :     const uno::Sequence< OUString >& rPropertyNames,
     927             :     const uno::Sequence< uno::Any >& rValues)
     928             : throw (beans::PropertyVetoException, lang::IllegalArgumentException,
     929             :         lang::WrappedTargetException, uno::RuntimeException, std::exception)
     930             : {
     931          29 :     SolarMutexGuard aGuard;
     932             : 
     933             :     // workaround for bad designed API
     934             :     try
     935             :     {
     936          29 :         m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues );
     937             :     }
     938           0 :     catch (const beans::UnknownPropertyException &rException)
     939             :     {
     940             :         // wrap the original (here not allowed) exception in
     941             :         // a WrappedTargetException that gets thrown instead.
     942           0 :         lang::WrappedTargetException aWExc;
     943           0 :         aWExc.TargetException <<= rException;
     944           0 :         throw aWExc;
     945          29 :     }
     946          29 : }
     947             : 
     948         134 : void SwXTextSection::setPropertyValue(
     949             :     const OUString& rPropertyName, const uno::Any& rValue)
     950             : throw (beans::UnknownPropertyException, beans::PropertyVetoException,
     951             :         lang::IllegalArgumentException, lang::WrappedTargetException,
     952             :         uno::RuntimeException, std::exception )
     953             : {
     954         134 :     SolarMutexGuard aGuard;
     955             : 
     956         268 :     uno::Sequence< OUString > aPropertyNames(1);
     957         134 :     aPropertyNames.getArray()[0] = rPropertyName;
     958         268 :     uno::Sequence< uno::Any > aValues(1);
     959         134 :     aValues.getArray()[0] = rValue;
     960         268 :     m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues );
     961         128 : }
     962             : 
     963             : uno::Sequence< uno::Any >
     964         314 : SwXTextSection::Impl::GetPropertyValues_Impl(
     965             :         const uno::Sequence< OUString > & rPropertyNames )
     966             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
     967             :         uno::RuntimeException)
     968             : {
     969         314 :     SwSectionFmt *const pFmt = GetSectionFmt();
     970         314 :     if (!pFmt && !m_bIsDescriptor)
     971             :     {
     972           0 :         throw uno::RuntimeException();
     973             :     }
     974             : 
     975         314 :     uno::Sequence< uno::Any > aRet(rPropertyNames.getLength());
     976         314 :     uno::Any* pRet = aRet.getArray();
     977         314 :     SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0;
     978         314 :     const OUString* pPropertyNames = rPropertyNames.getConstArray();
     979             : 
     980         692 :     for (sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength();
     981             :         nProperty++)
     982             :     {
     983             :         SfxItemPropertySimpleEntry const*const pEntry =
     984         378 :             m_rPropSet.getPropertyMap().getByName(pPropertyNames[nProperty]);
     985         378 :         if (!pEntry)
     986             :         {
     987             :             throw beans::UnknownPropertyException(
     988             :                 OUString("Unknown property: ")
     989           0 :                     + pPropertyNames[nProperty],
     990           0 :                 static_cast<cppu::OWeakObject *>(& m_rThis));
     991             :         }
     992         378 :         switch(pEntry->nWID)
     993             :         {
     994             :             case WID_SECT_CONDITION:
     995             :             {
     996             :                 OUString uTmp( (m_bIsDescriptor)
     997           1 :                     ? m_pProps->m_sCondition
     998          12 :                     : OUString(pSect->GetCondition()));
     999          11 :                 pRet[nProperty] <<= uTmp;
    1000             :             }
    1001          11 :             break;
    1002             :             case WID_SECT_DDE_TYPE:
    1003             :             case WID_SECT_DDE_FILE:
    1004             :             case WID_SECT_DDE_ELEMENT:
    1005             :             {
    1006          24 :                 OUString sRet;
    1007          24 :                 if (m_bIsDescriptor)
    1008             :                 {
    1009           0 :                     if (m_pProps->m_bDDE)
    1010             :                     {
    1011           0 :                         sRet = m_pProps->m_sLinkFileName;
    1012             :                     }
    1013             :                 }
    1014          24 :                 else if (DDE_LINK_SECTION == pSect->GetType())
    1015             :                 {
    1016          10 :                     sRet = pSect->GetLinkFileName();
    1017             :                 }
    1018          24 :                 sal_Int32 nDummy(0);
    1019          48 :                 sRet = sRet.getToken(pEntry->nWID - WID_SECT_DDE_TYPE,
    1020          24 :                             sfx2::cTokenSeparator, nDummy);
    1021          24 :                 pRet[nProperty] <<= sRet;
    1022             :             }
    1023          24 :             break;
    1024             :             case WID_SECT_DDE_AUTOUPDATE:
    1025             :             {
    1026             :                 // GetUpdateType() returns .._ALWAYS or .._ONCALL
    1027           5 :                 if (pSect && pSect->IsLinkType() && pSect->IsConnected())  // #i73247#
    1028             :                 {
    1029             :                     const sal_Bool bTemp =
    1030           5 :                         (pSect->GetUpdateType() == sfx2::LINKUPDATE_ALWAYS);
    1031           5 :                     pRet[nProperty] <<= bTemp;
    1032             :                 }
    1033             :             }
    1034           5 :             break;
    1035             :             case WID_SECT_LINK     :
    1036             :             {
    1037           8 :                 text::SectionFileLink aLink;
    1038           8 :                 if (m_bIsDescriptor)
    1039             :                 {
    1040           0 :                     if (!m_pProps->m_bDDE)
    1041             :                     {
    1042           0 :                         aLink.FileURL = m_pProps->m_sLinkFileName;
    1043           0 :                         aLink.FilterName = m_pProps->m_sSectionFilter;
    1044             :                     }
    1045             :                 }
    1046           8 :                 else if (FILE_LINK_SECTION == pSect->GetType())
    1047             :                 {
    1048           2 :                     OUString sRet( pSect->GetLinkFileName() );
    1049           2 :                     sal_Int32 nIndex(0);
    1050           4 :                     aLink.FileURL =
    1051           2 :                         sRet.getToken(0, sfx2::cTokenSeparator, nIndex);
    1052           4 :                     aLink.FilterName =
    1053           4 :                         sRet.getToken(0, sfx2::cTokenSeparator, nIndex);
    1054             :                 }
    1055           8 :                 pRet[nProperty] <<= aLink;
    1056             :             }
    1057           8 :             break;
    1058             :             case WID_SECT_REGION :
    1059             :             {
    1060           8 :                 OUString sRet;
    1061           8 :                 if (m_bIsDescriptor)
    1062             :                 {
    1063           0 :                     sRet = m_pProps->m_sSectionRegion;
    1064             :                 }
    1065           8 :                 else if (FILE_LINK_SECTION == pSect->GetType())
    1066             :                 {
    1067           4 :                     sRet = pSect->GetLinkFileName().getToken(2,
    1068           2 :                             sfx2::cTokenSeparator);
    1069             :                 }
    1070           8 :                 pRet[nProperty] <<= sRet;
    1071             :             }
    1072           8 :             break;
    1073             :             case WID_SECT_VISIBLE   :
    1074             :             {
    1075             :                 const sal_Bool bTemp = (m_bIsDescriptor)
    1076           9 :                     ? !m_pProps->m_bHidden : !pSect->IsHidden();
    1077           9 :                 pRet[nProperty] <<= bTemp;
    1078             :             }
    1079           9 :             break;
    1080             :             case WID_SECT_CURRENTLY_VISIBLE:
    1081             :             {
    1082             :                 const sal_Bool bTemp = (m_bIsDescriptor)
    1083           3 :                     ? !m_pProps->m_bCondHidden : !pSect->IsCondHidden();
    1084           3 :                 pRet[nProperty] <<= bTemp;
    1085             :             }
    1086           3 :             break;
    1087             :             case WID_SECT_PROTECTED:
    1088             :             {
    1089             :                 const sal_Bool bTemp = (m_bIsDescriptor)
    1090           8 :                     ? m_pProps->m_bProtect : pSect->IsProtect();
    1091           8 :                 pRet[nProperty] <<= bTemp;
    1092             :             }
    1093           8 :             break;
    1094             :             case WID_SECT_EDIT_IN_READONLY:
    1095             :             {
    1096             :                 const sal_Bool bTemp = (m_bIsDescriptor)
    1097          39 :                     ? m_pProps->m_bEditInReadonly : pSect->IsEditInReadonly();
    1098          39 :                 pRet[nProperty] <<= bTemp;
    1099             :             }
    1100          39 :             break;
    1101             :             case  FN_PARAM_LINK_DISPLAY_NAME:
    1102             :             {
    1103           0 :                 if (pFmt)
    1104             :                 {
    1105           0 :                     pRet[nProperty] <<=
    1106           0 :                         OUString(pFmt->GetSection()->GetSectionName());
    1107             :                 }
    1108             :             }
    1109           0 :             break;
    1110             :             case WID_SECT_DOCUMENT_INDEX:
    1111             :             {
    1112             :                 // search enclosing index
    1113          34 :                 SwSection* pEnclosingSection = pSect;
    1114         136 :                 while ((pEnclosingSection != NULL) &&
    1115          48 :                        (TOX_CONTENT_SECTION != pEnclosingSection->GetType()))
    1116             :                 {
    1117          20 :                     pEnclosingSection = pEnclosingSection->GetParent();
    1118             :                 }
    1119          34 :                 if (pEnclosingSection)
    1120             :                 {
    1121             :                     // convert section to TOXBase and get SwXDocumentIndex
    1122             :                     SwTOXBaseSection *const pTOXBaseSect =
    1123          28 :                         PTR_CAST(SwTOXBaseSection, pEnclosingSection);
    1124             :                     const uno::Reference<text::XDocumentIndex> xIndex =
    1125             :                         SwXDocumentIndex::CreateXDocumentIndex(
    1126          28 :                             *pTOXBaseSect->GetFmt()->GetDoc(), *pTOXBaseSect);
    1127          28 :                     pRet[nProperty] <<= xIndex;
    1128             :                 }
    1129             :                 // else: no enclosing index found -> empty return value
    1130             :             }
    1131          34 :             break;
    1132             :             case WID_SECT_IS_GLOBAL_DOC_SECTION:
    1133             :             {
    1134             :                 const sal_Bool bRet = (NULL == pFmt) ? sal_False :
    1135           0 :                     static_cast<sal_Bool>(NULL != pFmt->GetGlobalDocSection());
    1136           0 :                 pRet[nProperty] <<= bRet;
    1137             :             }
    1138           0 :             break;
    1139             :             case  FN_UNO_ANCHOR_TYPES:
    1140             :             case  FN_UNO_TEXT_WRAP:
    1141             :             case  FN_UNO_ANCHOR_TYPE:
    1142             :                 ::sw::GetDefaultTextContentValue(
    1143           6 :                         pRet[nProperty], OUString(), pEntry->nWID);
    1144           6 :             break;
    1145             :             case FN_UNO_REDLINE_NODE_START:
    1146             :             case FN_UNO_REDLINE_NODE_END:
    1147             :             {
    1148          34 :                 if (!pFmt)
    1149           0 :                     break;      // #i73247#
    1150          34 :                 SwNode* pSectNode = pFmt->GetSectionNode();
    1151          34 :                 if (FN_UNO_REDLINE_NODE_END == pEntry->nWID)
    1152             :                 {
    1153          17 :                     pSectNode = pSectNode->EndOfSectionNode();
    1154             :                 }
    1155             :                 const SwRedlineTbl& rRedTbl =
    1156          34 :                     pFmt->GetDoc()->GetRedlineTbl();
    1157          34 :                 for (sal_uInt16 nRed = 0; nRed < rRedTbl.size(); nRed++)
    1158             :                 {
    1159           0 :                     const SwRangeRedline* pRedline = rRedTbl[nRed];
    1160           0 :                     SwNode const*const pRedPointNode = pRedline->GetNode(true);
    1161           0 :                     SwNode const*const pRedMarkNode = pRedline->GetNode(false);
    1162           0 :                     if ((pRedPointNode == pSectNode) ||
    1163             :                         (pRedMarkNode == pSectNode))
    1164             :                     {
    1165             :                         SwNode const*const pStartOfRedline =
    1166           0 :                             (SwNodeIndex(*pRedPointNode) <=
    1167             :                              SwNodeIndex(*pRedMarkNode))
    1168           0 :                                  ? pRedPointNode : pRedMarkNode;
    1169           0 :                         const bool bIsStart = (pStartOfRedline == pSectNode);
    1170           0 :                         pRet[nProperty] <<=
    1171             :                             SwXRedlinePortion::CreateRedlineProperties(
    1172           0 :                                     *pRedline, bIsStart);
    1173           0 :                         break;
    1174             :                     }
    1175             :                 }
    1176             :             }
    1177          34 :             break;
    1178             :             case WID_SECT_PASSWORD:
    1179             :             {
    1180           8 :                 pRet[nProperty] <<= (m_bIsDescriptor)
    1181           8 :                     ? m_pProps->m_Password : pSect->GetPassword();
    1182             :             }
    1183           8 :             break;
    1184             :             default:
    1185             :             {
    1186         181 :                 if (pFmt)
    1187             :                 {
    1188             :                     m_rPropSet.getPropertyValue(*pEntry,
    1189         181 :                             pFmt->GetAttrSet(), pRet[nProperty]);
    1190             :                 }
    1191             :                 else
    1192             :                 {
    1193           0 :                     const SfxPoolItem* pQueryItem = 0;
    1194           0 :                     if (RES_COL == pEntry->nWID)
    1195             :                     {
    1196           0 :                         if (!m_pProps->m_pColItem.get())
    1197             :                         {
    1198           0 :                             m_pProps->m_pColItem.reset(new SwFmtCol);
    1199             :                         }
    1200           0 :                         pQueryItem = m_pProps->m_pColItem.get();
    1201             :                     }
    1202           0 :                     else if (RES_BACKGROUND == pEntry->nWID)
    1203             :                     {
    1204           0 :                         if (!m_pProps->m_pBrushItem.get())
    1205             :                         {
    1206           0 :                             m_pProps->m_pBrushItem.reset(
    1207           0 :                                 new SvxBrushItem(RES_BACKGROUND));
    1208             :                         }
    1209           0 :                         pQueryItem = m_pProps->m_pBrushItem.get();
    1210             :                     }
    1211           0 :                     else if (RES_FTN_AT_TXTEND == pEntry->nWID)
    1212             :                     {
    1213           0 :                         if (!m_pProps->m_pFtnItem.get())
    1214             :                         {
    1215           0 :                             m_pProps->m_pFtnItem.reset(new SwFmtFtnAtTxtEnd);
    1216             :                         }
    1217           0 :                         pQueryItem = m_pProps->m_pFtnItem.get();
    1218             :                     }
    1219           0 :                     else if (RES_END_AT_TXTEND == pEntry->nWID)
    1220             :                     {
    1221           0 :                         if (!m_pProps->m_pEndItem.get())
    1222             :                         {
    1223           0 :                             m_pProps->m_pEndItem.reset(new SwFmtEndAtTxtEnd);
    1224             :                         }
    1225           0 :                         pQueryItem = m_pProps->m_pEndItem.get();
    1226             :                     }
    1227           0 :                     else if (RES_UNKNOWNATR_CONTAINER== pEntry->nWID)
    1228             :                     {
    1229           0 :                         if (!m_pProps->m_pXMLAttr.get())
    1230             :                         {
    1231           0 :                             m_pProps->m_pXMLAttr.reset(
    1232           0 :                                 new SvXMLAttrContainerItem);
    1233             :                         }
    1234           0 :                         pQueryItem = m_pProps->m_pXMLAttr.get();
    1235             :                     }
    1236           0 :                     else if (RES_COLUMNBALANCE== pEntry->nWID)
    1237             :                     {
    1238           0 :                         if (!m_pProps->m_pNoBalanceItem.get())
    1239             :                         {
    1240           0 :                             m_pProps->m_pNoBalanceItem.reset(
    1241           0 :                                 new SwFmtNoBalancedColumns);
    1242             :                         }
    1243           0 :                         pQueryItem = m_pProps->m_pNoBalanceItem.get();
    1244             :                     }
    1245           0 :                     else if (RES_FRAMEDIR == pEntry->nWID)
    1246             :                     {
    1247           0 :                         if (!m_pProps->m_pFrameDirItem.get())
    1248             :                         {
    1249           0 :                             m_pProps->m_pFrameDirItem.reset(
    1250             :                                 new SvxFrameDirectionItem(
    1251           0 :                                     FRMDIR_ENVIRONMENT, RES_FRAMEDIR));
    1252             :                         }
    1253           0 :                         pQueryItem = m_pProps->m_pFrameDirItem.get();
    1254             :                     }
    1255           0 :                     else if (RES_LR_SPACE == pEntry->nWID)
    1256             :                     {
    1257           0 :                         if (!m_pProps->m_pLRSpaceItem.get())
    1258             :                         {
    1259           0 :                             m_pProps->m_pLRSpaceItem.reset(
    1260           0 :                                 new SvxLRSpaceItem( RES_LR_SPACE ));
    1261             :                         }
    1262           0 :                         pQueryItem = m_pProps->m_pLRSpaceItem.get();
    1263             :                     }
    1264           0 :                     if (pQueryItem)
    1265             :                     {
    1266           0 :                         pQueryItem->QueryValue(pRet[nProperty],
    1267           0 :                                 pEntry->nMemberId);
    1268             :                     }
    1269             :                 }
    1270             :             }
    1271             :         }
    1272             :     }
    1273         314 :     return aRet;
    1274             : }
    1275             : 
    1276             : uno::Sequence< uno::Any > SAL_CALL
    1277          34 : SwXTextSection::getPropertyValues(
    1278             :     const uno::Sequence< OUString >& rPropertyNames)
    1279             : throw (uno::RuntimeException, std::exception)
    1280             : {
    1281          34 :     SolarMutexGuard aGuard;
    1282          34 :     uno::Sequence< uno::Any > aValues;
    1283             : 
    1284             :     // workaround for bad designed API
    1285             :     try
    1286             :     {
    1287          34 :         aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames );
    1288             :     }
    1289           0 :     catch (beans::UnknownPropertyException &)
    1290             :     {
    1291             :         throw uno::RuntimeException("Unknown property exception caught",
    1292           0 :             static_cast<cppu::OWeakObject *>(this));
    1293             :     }
    1294           0 :     catch (lang::WrappedTargetException &)
    1295             :     {
    1296             :         throw uno::RuntimeException("WrappedTargetException caught",
    1297           0 :             static_cast<cppu::OWeakObject *>(this));
    1298             :     }
    1299             : 
    1300          34 :     return aValues;
    1301             : }
    1302             : 
    1303             : uno::Any SAL_CALL
    1304         280 : SwXTextSection::getPropertyValue(const OUString& rPropertyName)
    1305             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
    1306             :         uno::RuntimeException, std::exception)
    1307             : {
    1308         280 :     SolarMutexGuard aGuard;
    1309             : 
    1310         560 :     uno::Sequence< OUString > aPropertyNames(1);
    1311         280 :     aPropertyNames.getArray()[0] = rPropertyName;
    1312         560 :     return m_pImpl->GetPropertyValues_Impl(aPropertyNames).getConstArray()[0];
    1313             : }
    1314             : 
    1315           0 : void SAL_CALL SwXTextSection::addPropertiesChangeListener(
    1316             :     const uno::Sequence< OUString >& /*aPropertyNames*/,
    1317             :     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
    1318             : throw (uno::RuntimeException, std::exception)
    1319             : {
    1320             :     OSL_FAIL("SwXTextSection::addPropertiesChangeListener(): not implemented");
    1321           0 : }
    1322             : 
    1323           0 : void SAL_CALL SwXTextSection::removePropertiesChangeListener(
    1324             :     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
    1325             : throw (uno::RuntimeException, std::exception)
    1326             : {
    1327             :     OSL_FAIL("SwXTextSection::removePropertiesChangeListener(): not implemented");
    1328           0 : }
    1329             : 
    1330           0 : void SAL_CALL SwXTextSection::firePropertiesChangeEvent(
    1331             :     const uno::Sequence< OUString >& /*aPropertyNames*/,
    1332             :     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
    1333             :         throw(uno::RuntimeException, std::exception)
    1334             : {
    1335             :     OSL_FAIL("SwXTextSection::firePropertiesChangeEvent(): not implemented");
    1336           0 : }
    1337             : 
    1338             : void SAL_CALL
    1339           0 : SwXTextSection::addPropertyChangeListener(
    1340             :         const OUString& /*rPropertyName*/,
    1341             :         const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
    1342             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
    1343             :     uno::RuntimeException, std::exception)
    1344             : {
    1345             :     OSL_FAIL("SwXTextSection::addPropertyChangeListener(): not implemented");
    1346           0 : }
    1347             : 
    1348             : void SAL_CALL
    1349           0 : SwXTextSection::removePropertyChangeListener(
    1350             :         const OUString& /*rPropertyName*/,
    1351             :         const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
    1352             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
    1353             :     uno::RuntimeException, std::exception)
    1354             : {
    1355             :     OSL_FAIL("SwXTextSection::removePropertyChangeListener(): not implemented");
    1356           0 : }
    1357             : 
    1358             : void SAL_CALL
    1359           0 : SwXTextSection::addVetoableChangeListener(
    1360             :         const OUString& /*rPropertyName*/,
    1361             :         const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
    1362             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
    1363             :     uno::RuntimeException, std::exception)
    1364             : {
    1365             :     OSL_FAIL("SwXTextSection::addVetoableChangeListener(): not implemented");
    1366           0 : }
    1367             : 
    1368             : void SAL_CALL
    1369           0 : SwXTextSection::removeVetoableChangeListener(
    1370             :         const OUString& /*rPropertyName*/,
    1371             :         const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
    1372             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
    1373             :         uno::RuntimeException, std::exception)
    1374             : {
    1375             :     OSL_FAIL("SwXTextSection::removeVetoableChangeListener(): not implemented");
    1376           0 : }
    1377             : 
    1378             : beans::PropertyState SAL_CALL
    1379           1 : SwXTextSection::getPropertyState(const OUString& rPropertyName)
    1380             : throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1381             : {
    1382           1 :     SolarMutexGuard aGuard;
    1383             : 
    1384           2 :     uno::Sequence< OUString > aNames(1);
    1385           1 :     aNames.getArray()[0] = rPropertyName;
    1386           2 :     return getPropertyStates(aNames).getConstArray()[0];
    1387             : }
    1388             : 
    1389             : uno::Sequence< beans::PropertyState > SAL_CALL
    1390          36 : SwXTextSection::getPropertyStates(
    1391             :         const uno::Sequence< OUString >& rPropertyNames)
    1392             : throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1393             : {
    1394          36 :     SolarMutexGuard aGuard;
    1395             : 
    1396          36 :     SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt();
    1397          36 :     if (!pFmt && !m_pImpl->m_bIsDescriptor)
    1398             :     {
    1399           0 :         throw uno::RuntimeException();
    1400             :     }
    1401             : 
    1402          36 :     uno::Sequence< beans::PropertyState > aStates(rPropertyNames.getLength());
    1403          36 :     beans::PropertyState *const pStates = aStates.getArray();
    1404          36 :     const OUString* pNames = rPropertyNames.getConstArray();
    1405         922 :     for (sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
    1406             :     {
    1407         886 :         pStates[i] = beans::PropertyState_DEFAULT_VALUE;
    1408             :         SfxItemPropertySimpleEntry const*const pEntry =
    1409         886 :             m_pImpl->m_rPropSet.getPropertyMap().getByName( pNames[i]);
    1410         886 :         if (!pEntry)
    1411             :         {
    1412             :             throw beans::UnknownPropertyException(
    1413             :                 OUString("Unknown property: ")
    1414           0 :                     + pNames[i], static_cast< cppu::OWeakObject* >(this));
    1415             :         }
    1416         886 :         switch (pEntry->nWID)
    1417             :         {
    1418             :             case WID_SECT_CONDITION:
    1419             :             case WID_SECT_DDE_TYPE:
    1420             :             case WID_SECT_DDE_FILE:
    1421             :             case WID_SECT_DDE_ELEMENT:
    1422             :             case WID_SECT_DDE_AUTOUPDATE:
    1423             :             case WID_SECT_LINK:
    1424             :             case WID_SECT_REGION :
    1425             :             case WID_SECT_VISIBLE:
    1426             :             case WID_SECT_PROTECTED:
    1427             :             case WID_SECT_EDIT_IN_READONLY:
    1428             :             case  FN_PARAM_LINK_DISPLAY_NAME:
    1429             :             case  FN_UNO_ANCHOR_TYPES:
    1430             :             case  FN_UNO_TEXT_WRAP:
    1431             :             case  FN_UNO_ANCHOR_TYPE:
    1432          34 :                 pStates[i] = beans::PropertyState_DIRECT_VALUE;
    1433          34 :             break;
    1434             :             default:
    1435             :             {
    1436         852 :                 if (pFmt)
    1437             :                 {
    1438        1704 :                     pStates[i] = m_pImpl->m_rPropSet.getPropertyState(
    1439        1704 :                                     pNames[i], pFmt->GetAttrSet());
    1440             :                 }
    1441             :                 else
    1442             :                 {
    1443           0 :                     if (RES_COL == pEntry->nWID)
    1444             :                     {
    1445           0 :                         if (!m_pImpl->m_pProps->m_pColItem.get())
    1446             :                         {
    1447           0 :                             pStates[i] = beans::PropertyState_DEFAULT_VALUE;
    1448             :                         }
    1449             :                         else
    1450             :                         {
    1451           0 :                             pStates[i] = beans::PropertyState_DIRECT_VALUE;
    1452             :                         }
    1453             :                     }
    1454             :                     else //if(RES_BACKGROUND == pEntry->nWID)
    1455             :                     {
    1456           0 :                         if (!m_pImpl->m_pProps->m_pBrushItem.get())
    1457             :                         {
    1458           0 :                             pStates[i] = beans::PropertyState_DEFAULT_VALUE;
    1459             :                         }
    1460             :                         else
    1461             :                         {
    1462           0 :                             pStates[i] = beans::PropertyState_DIRECT_VALUE;
    1463             :                         }
    1464             :                     }
    1465             :                 }
    1466             :             }
    1467             :         }
    1468             :     }
    1469          36 :     return aStates;
    1470             : }
    1471             : 
    1472             : void SAL_CALL
    1473           1 : SwXTextSection::setPropertyToDefault(const OUString& rPropertyName)
    1474             : throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    1475             : {
    1476           1 :     SolarMutexGuard aGuard;
    1477             : 
    1478           1 :     SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt();
    1479           1 :     if (!pFmt && !m_pImpl->m_bIsDescriptor)
    1480             :     {
    1481           0 :         throw uno::RuntimeException();
    1482             :     }
    1483             : 
    1484             :     SfxItemPropertySimpleEntry const*const pEntry =
    1485           1 :         m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
    1486           1 :     if (!pEntry)
    1487             :     {
    1488             :         throw beans::UnknownPropertyException(
    1489             :             OUString("Unknown property: ")
    1490           0 :                 + rPropertyName, static_cast< cppu::OWeakObject* >(this));
    1491             :     }
    1492           1 :     if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
    1493             :     {
    1494             :         throw uno::RuntimeException(OUString(
    1495             :                     "setPropertyToDefault: property is read-only: ")
    1496           0 :                 + rPropertyName,
    1497           0 :             static_cast<cppu::OWeakObject *>(this));
    1498             :     }
    1499             : 
    1500             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1501             :     ::std::auto_ptr<SwSectionData> const pSectionData(
    1502           2 :         (pFmt) ? new SwSectionData(*pFmt->GetSection()) : 0);
    1503             : 
    1504           2 :     ::std::auto_ptr<SfxItemSet> pNewAttrSet;
    1505             :     SAL_WNODEPRECATED_DECLARATIONS_POP
    1506           1 :     bool bLinkModeChanged = false;
    1507             : 
    1508           1 :     switch (pEntry->nWID)
    1509             :     {
    1510             :         case WID_SECT_CONDITION:
    1511             :         {
    1512           0 :             if (m_pImpl->m_bIsDescriptor)
    1513             :             {
    1514           0 :                 m_pImpl->m_pProps->m_sCondition = OUString();
    1515             :             }
    1516             :             else
    1517             :             {
    1518           0 :                 pSectionData->SetCondition(OUString());
    1519             :             }
    1520             :         }
    1521           0 :         break;
    1522             :         case WID_SECT_DDE_TYPE      :
    1523             :         case WID_SECT_DDE_FILE      :
    1524             :         case WID_SECT_DDE_ELEMENT   :
    1525             :         case WID_SECT_LINK     :
    1526             :         case WID_SECT_REGION :
    1527           0 :             if (m_pImpl->m_bIsDescriptor)
    1528             :             {
    1529           0 :                 m_pImpl->m_pProps->m_bDDE = false;
    1530           0 :                 m_pImpl->m_pProps->m_sLinkFileName = OUString();
    1531           0 :                 m_pImpl->m_pProps->m_sSectionRegion = OUString();
    1532           0 :                 m_pImpl->m_pProps->m_sSectionFilter = OUString();
    1533             :             }
    1534             :             else
    1535             :             {
    1536           0 :                 pSectionData->SetType(CONTENT_SECTION);
    1537             :             }
    1538           0 :         break;
    1539             :         case WID_SECT_DDE_AUTOUPDATE:
    1540           0 :             if (m_pImpl->m_bIsDescriptor)
    1541             :             {
    1542           0 :                 m_pImpl->m_pProps->m_bUpdateType = true;
    1543             :             }
    1544             :             else
    1545             :             {
    1546           0 :                 bLinkModeChanged = true;
    1547             :             }
    1548           0 :         break;
    1549             :         case WID_SECT_VISIBLE   :
    1550             :         {
    1551           0 :             if (m_pImpl->m_bIsDescriptor)
    1552             :             {
    1553           0 :                 m_pImpl->m_pProps->m_bHidden = false;
    1554             :             }
    1555             :             else
    1556             :             {
    1557           0 :                 pSectionData->SetHidden(false);
    1558             :             }
    1559             :         }
    1560           0 :         break;
    1561             :         case WID_SECT_PROTECTED:
    1562             :         {
    1563           0 :             if (m_pImpl->m_bIsDescriptor)
    1564             :             {
    1565           0 :                 m_pImpl->m_pProps->m_bProtect = false;
    1566             :             }
    1567             :             else
    1568             :             {
    1569           0 :                 pSectionData->SetProtectFlag(false);
    1570             :             }
    1571             :         }
    1572           0 :         break;
    1573             :         case WID_SECT_EDIT_IN_READONLY:
    1574             :         {
    1575           0 :             if (m_pImpl->m_bIsDescriptor)
    1576             :             {
    1577           0 :                 m_pImpl->m_pProps->m_bEditInReadonly = false;
    1578             :             }
    1579             :             else
    1580             :             {
    1581           0 :                 pSectionData->SetEditInReadonlyFlag(false);
    1582             :             }
    1583             :         }
    1584           0 :         break;
    1585             : 
    1586             :         case  FN_UNO_ANCHOR_TYPES:
    1587             :         case  FN_UNO_TEXT_WRAP:
    1588             :         case  FN_UNO_ANCHOR_TYPE:
    1589           0 :         break;
    1590             :         default:
    1591             :         {
    1592           1 :             if (pEntry->nWID <= SFX_WHICH_MAX)
    1593             :             {
    1594           1 :                 if (pFmt)
    1595             :                 {
    1596           1 :                     const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet();
    1597           1 :                     pNewAttrSet.reset( new SfxItemSet(*rOldAttrSet.GetPool(), pEntry->nWID, pEntry->nWID));
    1598           1 :                     pNewAttrSet->ClearItem(pEntry->nWID);
    1599             :                 }
    1600             :                 else
    1601             :                 {
    1602           0 :                     if (RES_COL == pEntry->nWID)
    1603             :                     {
    1604           0 :                         m_pImpl->m_pProps->m_pColItem.reset();
    1605             :                     }
    1606           0 :                     else if (RES_BACKGROUND == pEntry->nWID)
    1607             :                     {
    1608           0 :                         m_pImpl->m_pProps->m_pBrushItem.reset();
    1609             :                     }
    1610             :                 }
    1611             :             }
    1612             :         }
    1613             :     }
    1614             : 
    1615           2 :     lcl_UpdateSection(pFmt, pSectionData, pNewAttrSet, bLinkModeChanged);
    1616           1 : }
    1617             : 
    1618             : uno::Any SAL_CALL
    1619           1 : SwXTextSection::getPropertyDefault(const OUString& rPropertyName)
    1620             : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
    1621             :         uno::RuntimeException, std::exception)
    1622             : {
    1623           1 :     SolarMutexGuard aGuard;
    1624             : 
    1625           1 :     uno::Any aRet;
    1626           1 :     SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt();
    1627             :     SfxItemPropertySimpleEntry const*const pEntry =
    1628           1 :         m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
    1629           1 :     if (!pEntry)
    1630             :     {
    1631             :         throw beans::UnknownPropertyException(
    1632             :             OUString("Unknown property: ")
    1633           0 :                 + rPropertyName,
    1634           0 :             static_cast<cppu::OWeakObject *>(this));
    1635             :     }
    1636             : 
    1637           1 :     switch(pEntry->nWID)
    1638             :     {
    1639             :         case WID_SECT_CONDITION:
    1640             :         case WID_SECT_DDE_TYPE      :
    1641             :         case WID_SECT_DDE_FILE      :
    1642             :         case WID_SECT_DDE_ELEMENT   :
    1643             :         case WID_SECT_REGION :
    1644             :         case FN_PARAM_LINK_DISPLAY_NAME:
    1645           0 :             aRet <<= OUString();
    1646           0 :         break;
    1647             :         case WID_SECT_LINK     :
    1648           0 :             aRet <<= text::SectionFileLink();
    1649           0 :         break;
    1650             :         case WID_SECT_DDE_AUTOUPDATE:
    1651             :         case WID_SECT_VISIBLE   :
    1652             :         {
    1653           0 :             sal_Bool bTemp = sal_True;
    1654           0 :             aRet.setValue( &bTemp, ::getCppuBooleanType());
    1655             :         }
    1656           0 :         break;
    1657             :         case WID_SECT_PROTECTED:
    1658             :         case WID_SECT_EDIT_IN_READONLY:
    1659             :         {
    1660           0 :             sal_Bool bTemp = sal_False;
    1661           0 :             aRet.setValue( &bTemp, ::getCppuBooleanType());
    1662             :         }
    1663           0 :         break;
    1664             :         case  FN_UNO_ANCHOR_TYPES:
    1665             :         case  FN_UNO_TEXT_WRAP:
    1666             :         case  FN_UNO_ANCHOR_TYPE:
    1667           0 :             ::sw::GetDefaultTextContentValue(aRet, OUString(), pEntry->nWID);
    1668           0 :         break;
    1669             :         default:
    1670           1 :         if(pFmt && pEntry->nWID <= SFX_WHICH_MAX)
    1671             :         {
    1672           1 :             SwDoc *const pDoc = pFmt->GetDoc();
    1673             :             const SfxPoolItem& rDefItem =
    1674           1 :                 pDoc->GetAttrPool().GetDefaultItem(pEntry->nWID);
    1675           1 :             rDefItem.QueryValue(aRet, pEntry->nMemberId);
    1676             :         }
    1677             :     }
    1678           1 :     return aRet;
    1679             : }
    1680             : 
    1681          13 : OUString SAL_CALL SwXTextSection::getName() throw (uno::RuntimeException, std::exception)
    1682             : {
    1683          13 :     SolarMutexGuard aGuard;
    1684             : 
    1685          13 :     OUString sRet;
    1686          13 :     SwSectionFmt const*const pFmt = m_pImpl->GetSectionFmt();
    1687          13 :     if(pFmt)
    1688             :     {
    1689          13 :         sRet = pFmt->GetSection()->GetSectionName();
    1690             :     }
    1691           0 :     else if (m_pImpl->m_bIsDescriptor)
    1692             :     {
    1693           0 :         sRet = m_pImpl->m_sName;
    1694             :     }
    1695             :     else
    1696             :     {
    1697           0 :         throw uno::RuntimeException();
    1698             :     }
    1699          13 :     return sRet;
    1700             : }
    1701             : 
    1702          36 : void SAL_CALL SwXTextSection::setName(const OUString& rName)
    1703             : throw (uno::RuntimeException, std::exception)
    1704             : {
    1705          36 :     SolarMutexGuard aGuard;
    1706             : 
    1707          36 :     SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt();
    1708          36 :     if(pFmt)
    1709             :     {
    1710           7 :         SwSection *const pSect = pFmt->GetSection();
    1711           7 :         SwSectionData aSection(*pSect);
    1712          14 :         OUString sNewName(rName);
    1713           7 :         aSection.SetSectionName(sNewName);
    1714             : 
    1715           7 :         const SwSectionFmts& rFmts = pFmt->GetDoc()->GetSections();
    1716           7 :         sal_uInt16 nApplyPos = USHRT_MAX;
    1717          21 :         for( sal_uInt16 i = 0; i < rFmts.size(); i++ )
    1718             :         {
    1719          14 :             if(rFmts[i]->GetSection() == pSect)
    1720             :             {
    1721           7 :                 nApplyPos = i;
    1722             :             }
    1723           7 :             else if (sNewName == rFmts[i]->GetSection()->GetSectionName())
    1724             :             {
    1725           0 :                 throw uno::RuntimeException();
    1726             :             }
    1727             :         }
    1728           7 :         if(nApplyPos != USHRT_MAX)
    1729             :         {
    1730             :             {
    1731           7 :                 UnoActionContext aContext(pFmt->GetDoc());
    1732           7 :                 pFmt->GetDoc()->UpdateSection(nApplyPos, aSection);
    1733             :             }
    1734             :             {
    1735             :                 // temporarily remove actions to allow cursor update
    1736           7 :                 UnoActionRemoveContext aRemoveContext( pFmt->GetDoc() );
    1737             :             }
    1738           7 :         }
    1739             :     }
    1740          29 :     else if (m_pImpl->m_bIsDescriptor)
    1741             :     {
    1742          29 :         m_pImpl->m_sName = rName;
    1743             :     }
    1744             :     else
    1745             :     {
    1746           0 :         throw uno::RuntimeException();
    1747          36 :     }
    1748          36 : }
    1749             : 
    1750             : OUString SAL_CALL
    1751           0 : SwXTextSection::getImplementationName() throw (uno::RuntimeException, std::exception)
    1752             : {
    1753           0 :     return OUString("SwXTextSection");
    1754             : }
    1755             : 
    1756             : static char const*const g_ServicesTextSection[] =
    1757             : {
    1758             :     "com.sun.star.text.TextContent",
    1759             :     "com.sun.star.text.TextSection",
    1760             :     "com.sun.star.document.LinkTarget",
    1761             : };
    1762             : 
    1763           1 : sal_Bool SAL_CALL SwXTextSection::supportsService(const OUString& rServiceName)
    1764             : throw (uno::RuntimeException, std::exception)
    1765             : {
    1766           1 :     return cppu::supportsService(this, rServiceName);
    1767             : }
    1768             : 
    1769             : uno::Sequence< OUString > SAL_CALL
    1770           1 : SwXTextSection::getSupportedServiceNames() throw (uno::RuntimeException, std::exception)
    1771             : {
    1772             :     return ::sw::GetSupportedServiceNamesImpl(
    1773             :                 SAL_N_ELEMENTS(g_ServicesTextSection),
    1774           1 :                 g_ServicesTextSection);
    1775             : }
    1776             : 
    1777             : // MetadatableMixin
    1778          67 : ::sfx2::Metadatable* SwXTextSection::GetCoreObject()
    1779             : {
    1780          67 :     SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() );
    1781          67 :     return pSectionFmt;
    1782             : }
    1783             : 
    1784           0 : uno::Reference<frame::XModel> SwXTextSection::GetModel()
    1785             : {
    1786           0 :     SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() );
    1787           0 :     if (pSectionFmt)
    1788             :     {
    1789           0 :         SwDocShell const*const pShell( pSectionFmt->GetDoc()->GetDocShell() );
    1790           0 :         return (pShell) ? pShell->GetModel() : 0;
    1791             :     }
    1792           0 :     return 0;
    1793             : }
    1794             : 
    1795             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10