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

Generated by: LCOV version 1.10