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

Generated by: LCOV version 1.10