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