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