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