update dev300-m58
[ooovba.git] / sw / source / core / unocore / unosect.cxx
blobfc5c8984c399d2e75dac32be66109e46813f090b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unosect.cxx,v $
10 * $Revision: 1.60 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <com/sun/star/text/SectionFileLink.hpp>
37 #include <cmdid.h>
38 #include <hintids.hxx>
39 #include <svtools/urihelper.hxx>
40 #include <svx/brshitem.hxx>
41 #ifndef _SVX_XMLCNITEM_HXX
42 #include <svx/xmlcnitm.hxx>
43 #endif
44 #include <sfx2/linkmgr.hxx>
45 #include <sfx2/lnkbase.hxx>
46 #include <vos/mutex.hxx>
47 #include <vcl/svapp.hxx>
48 #include <fmtclds.hxx>
49 #include <unoobj.hxx>
50 #include <unoredline.hxx>
51 #include <redline.hxx>
52 #include <unomap.hxx>
53 #include <unocrsr.hxx>
54 #include <section.hxx>
55 #include <doc.hxx>
56 #ifndef _DOCSH_HXX
57 #include <docsh.hxx>
58 #endif
59 #include <sfx2/docfile.hxx>
60 #include <docary.hxx>
61 #include <swundo.hxx>
62 #include <hints.hxx>
63 #include <tox.hxx>
64 #include <unoidx.hxx>
65 #include <doctxm.hxx>
66 #include <fmtftntx.hxx>
67 #include <fmtclbl.hxx>
68 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_
69 #include <com/sun/star/beans/PropertyAttribute.hpp>
70 #endif
71 #include <svx/frmdiritem.hxx>
72 /* #109700# */
73 #include <svx/lrspitem.hxx>
75 using namespace ::com::sun::star;
76 using namespace ::com::sun::star::lang;
77 using namespace ::com::sun::star::uno;
78 using namespace ::com::sun::star::text;
79 using namespace ::com::sun::star::container;
80 using namespace ::com::sun::star::beans;
81 using ::rtl::OUString;
83 TYPEINIT1(SwXTextSectionClient, SwClient);
84 /*-- 20.12.2005 09:56:33---------------------------------------------------
86 -----------------------------------------------------------------------*/
87 SwXTextSectionClient::SwXTextSectionClient(
88 SwSectionFmt& rFmt,
89 SwXTextSection& rTextSection,
90 uno::Reference< text::XTextSection > xSection ) :
91 SwClient(&rFmt),
92 m_pSection( &rTextSection ),
93 m_xReference( xSection )
96 m_pSection->SetClient( this );
98 /*-- 20.12.2005 09:56:33---------------------------------------------------
100 -----------------------------------------------------------------------*/
101 SwXTextSectionClient::~SwXTextSectionClient()
103 uno::Reference< text::XTextSection > xSection( m_xReference );
104 if(xSection.is())
106 m_pSection->SetClient( 0 );
109 /*-- 20.12.2005 09:56:35---------------------------------------------------
111 -----------------------------------------------------------------------*/
112 uno::Reference< text::XTextSection > SwXTextSectionClient::GetXTextSection()
114 return uno::Reference< text::XTextSection >( m_xReference );
117 /*-- 29.12.2005 11:29:30---------------------------------------------------
119 -----------------------------------------------------------------------*/
120 /*SwXTextSection* SwXTextSectionClient::GetSwTextSection()
122 if( m_xReference.is() )
123 return m_pSection;;
124 } */
126 /*-- 10.12.98 14:42:52---------------------------------------------------
128 -----------------------------------------------------------------------*/
129 void SwXTextSectionClient::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
131 if(pOld && pOld->Which() == RES_REMOVE_UNO_OBJECT &&
132 (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject )
133 ((SwModify*)GetRegisteredIn())->Remove(this);
134 else
135 ClientModify(this, pOld, pNew);
136 if(!GetRegisteredIn())
138 uno::Reference< text::XTextSection > xSection( m_xReference );
139 if(xSection.is())
141 m_pSection->SetClient( 0 );
142 m_pSection->aLstnrCntnr.Disposing();
143 m_xReference = uno::Reference< text::XTextSection >();
145 Application::PostUserEvent(
146 STATIC_LINK( this, SwXTextSectionClient, RemoveSectionClient_Impl ), this );
151 /*-- 29.12.2005 13:04:57---------------------------------------------------
153 -----------------------------------------------------------------------*/
154 IMPL_STATIC_LINK_NOINSTANCE( SwXTextSectionClient, RemoveSectionClient_Impl,
155 SwXTextSectionClient*, pClient )
157 delete pClient;
158 return 0;
161 /*-- 20.12.2005 09:56:36---------------------------------------------------
163 -----------------------------------------------------------------------*/
164 uno::Reference< text::XTextSection > SwXTextSectionClient::CreateXTextSection(
165 SwSectionFmt* pFmt, BOOL bIndexHeader )
167 SwXTextSection* pNew;
168 uno::Reference< text::XTextSection > xSection = pNew = new SwXTextSection( pFmt != 0, bIndexHeader );
169 if(pFmt)
170 new SwXTextSectionClient( *pFmt, *pNew, xSection );
171 return xSection;
174 /*-- 29.12.2005 10:23:37---------------------------------------------------
176 -----------------------------------------------------------------------*/
177 SwXTextSectionClient* SwXTextSectionClient::Create(SwXTextSection& rSection,
178 uno::Reference< text::XTextSection >xSection, SwSectionFmt& rFmt )
180 return new SwXTextSectionClient( rFmt, rSection, xSection );
182 /******************************************************************
184 ******************************************************************/
185 struct SwTextSectionProperties_Impl
188 String sCondition;
189 String sLinkFileName;
190 String sSectionFilter;
191 String sSectionRegion;
192 uno::Sequence<sal_Int8> aPassword;
194 SwFmtCol* pColItem;
195 SvxBrushItem* pBrushItem;
196 SwFmtFtnAtTxtEnd* pFtnItem;
197 SwFmtEndAtTxtEnd* pEndItem;
198 SvXMLAttrContainerItem *pXMLAttr;
199 SwFmtNoBalancedColumns *pNoBalanceItem;
200 SvxFrameDirectionItem *pFrameDirItem;
201 SvxLRSpaceItem *pLRSpaceItem; // #109700#
202 sal_Bool bDDE;
203 sal_Bool bHidden;
204 sal_Bool bCondHidden;
205 sal_Bool bProtect;
206 // --> FME 2004-06-22 #114856# edit in readonly sections
207 sal_Bool bEditInReadonly;
208 // <--
209 sal_Bool bUpdateType;
211 SwTextSectionProperties_Impl() :
212 pColItem(0),
213 pBrushItem(0),
214 pFtnItem(0),
215 pEndItem(0),
216 pXMLAttr(0),
217 pNoBalanceItem(0),
218 pFrameDirItem(0),
219 pLRSpaceItem(0), // #109700#
220 bDDE(0),
221 bHidden(0),
222 bCondHidden(0),
223 bProtect(0),
224 // --> FME 2004-06-22 #114856# edit in readonly sections
225 bEditInReadonly(0),
226 // <--
227 bUpdateType(sal_True){}
229 ~SwTextSectionProperties_Impl()
231 delete pColItem;
232 delete pBrushItem;
233 delete pFtnItem;
234 delete pEndItem;
235 delete pXMLAttr;
236 delete pNoBalanceItem;
237 delete pFrameDirItem;
238 delete pLRSpaceItem; // #109700#
241 /* -----------------------------11.07.00 12:10--------------------------------
243 ---------------------------------------------------------------------------*/
244 SwXTextSection* SwXTextSection::GetImplementation(uno::Reference< XInterface> xRef )
246 uno::Reference<lang::XUnoTunnel> xTunnel( xRef, uno::UNO_QUERY);
247 if(xTunnel.is())
248 return reinterpret_cast< SwXTextSection * >(
249 sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXTextSection::getUnoTunnelId()) ));
250 return 0;
253 /* -----------------------------13.03.00 12:15--------------------------------
255 ---------------------------------------------------------------------------*/
256 const uno::Sequence< sal_Int8 > & SwXTextSection::getUnoTunnelId()
258 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
259 return aSeq;
261 /* -----------------------------10.03.00 18:04--------------------------------
263 ---------------------------------------------------------------------------*/
264 sal_Int64 SAL_CALL SwXTextSection::getSomething( const uno::Sequence< sal_Int8 >& rId )
265 throw(uno::RuntimeException)
267 if( rId.getLength() == 16
268 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
269 rId.getConstArray(), 16 ) )
271 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) );
273 return 0;
275 /*-- 10.12.98 14:47:05---------------------------------------------------
277 -----------------------------------------------------------------------*/
278 SwXTextSection::SwXTextSection(sal_Bool bWithFormat, sal_Bool bIndexHeader) :
279 // SwClient(pFmt),
280 aLstnrCntnr( (text::XTextContent*)this),
281 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_SECTION)),
282 m_bIsDescriptor(!bWithFormat),
283 m_bIndexHeader(bIndexHeader),
284 pProps(bWithFormat ? 0 : new SwTextSectionProperties_Impl()),
285 m_pClient( 0 )
289 /*-- 10.12.98 14:47:07---------------------------------------------------
291 -----------------------------------------------------------------------*/
292 SwXTextSection::~SwXTextSection()
294 vos::OGuard aGuard(Application::GetSolarMutex());
295 delete m_pClient;
296 delete pProps;
298 /*-- 10.12.98 14:47:08---------------------------------------------------
300 -----------------------------------------------------------------------*/
301 uno::Reference< text::XTextSection > SwXTextSection::getParentSection(void) throw( uno::RuntimeException )
303 vos::OGuard aGuard(Application::GetSolarMutex());
304 uno::Reference< text::XTextSection > aRef;
305 SwSectionFmt* pSectFmt = GetFmt();
306 if(pSectFmt)
308 SwSectionFmt* pParentFmt = pSectFmt->GetParent();
309 if(pParentFmt)
311 SwXTextSectionClient* pClient = (SwXTextSectionClient*)SwClientIter(*pParentFmt).
312 First(TYPE(SwXTextSectionClient));
313 if(pClient)
314 aRef = pClient->GetXTextSection();
315 else
316 aRef = SwXTextSectionClient::CreateXTextSection(pParentFmt);
319 else
320 throw uno::RuntimeException();
321 return aRef;
323 /*-- 10.12.98 14:47:08---------------------------------------------------
325 -----------------------------------------------------------------------*/
326 uno::Sequence< uno::Reference< text::XTextSection > > SwXTextSection::getChildSections(void)
327 throw( uno::RuntimeException )
329 vos::OGuard aGuard(Application::GetSolarMutex());
330 uno::Sequence<uno::Reference< text::XTextSection > > aSeq;
331 SwSectionFmt* pSectFmt = GetFmt();
332 if(pSectFmt)
334 SwSections aChildren;
335 pSectFmt->GetChildSections(aChildren, SORTSECT_NOT, sal_False);
336 aSeq.realloc(aChildren.Count());
337 uno::Reference< text::XTextSection > * pArray = aSeq.getArray();
338 for(sal_uInt16 i = 0; i < aChildren.Count(); i++)
340 SwSectionFmt* pChild = aChildren.GetObject(i)->GetFmt();
341 SwXTextSectionClient* pClient = (SwXTextSectionClient*)SwClientIter(*pChild).
342 First(TYPE(SwXTextSectionClient));
344 if(pClient)
345 pArray[i] = pClient->GetXTextSection();
346 else
347 pArray[i] = SwXTextSectionClient::CreateXTextSection(pChild);
350 return aSeq;
353 /* -----------------18.02.99 13:31-------------------
355 * --------------------------------------------------*/
356 void SwXTextSection::attachToRange(const uno::Reference< text::XTextRange > & xTextRange)
357 throw( lang::IllegalArgumentException, uno::RuntimeException )
359 if(!m_bIsDescriptor)
360 throw uno::RuntimeException();
362 uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
363 SwXTextRange* pRange = 0;
364 OTextCursorHelper* pCursor = 0;
365 if(xRangeTunnel.is())
367 pRange = reinterpret_cast< SwXTextRange * >(
368 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
369 pCursor = reinterpret_cast< OTextCursorHelper * >(
370 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
373 SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0;
374 if(pDoc)
376 SwUnoInternalPaM aPam(*pDoc);
377 //das muss jetzt sal_True liefern
378 SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange);
379 UnoActionContext aCont(pDoc);
380 pDoc->StartUndo( UNDO_INSSECTION, NULL );
382 SwSection* pRet = 0;
383 if(!m_sName.Len())
384 m_sName = C2S("TextSection");
385 SectionType eType = pProps->bDDE ? DDE_LINK_SECTION :
386 pProps->sLinkFileName.Len() || pProps->sSectionRegion.Len() ? FILE_LINK_SECTION :
387 CONTENT_SECTION;
388 // index header section?
389 if(m_bIndexHeader)
391 // caller wants an index header section, but will only
392 // give him one if a) we are inside an index, and b) said
393 // index doesn't yet have a header section.
394 const SwTOXBase* pBase = aPam.GetDoc()->GetCurTOX(
395 *aPam.Start() );
397 // are we inside an index?
398 if (pBase)
400 // get all child sections
401 SwSections aSectionsArr;
402 ((SwTOXBaseSection*)pBase)->GetFmt()->
403 GetChildSections(aSectionsArr);
405 // and search for current header section
406 sal_uInt16 nCount = aSectionsArr.Count();
407 sal_Bool bHeaderPresent = sal_False;
408 for(sal_uInt16 i = 0; i < nCount; i++)
410 bHeaderPresent |=
411 (aSectionsArr[i]->GetType() == TOX_HEADER_SECTION);
413 if (! bHeaderPresent)
415 eType = TOX_HEADER_SECTION;
420 SwSection aSect(eType, pDoc->GetUniqueSectionName(&m_sName));
421 aSect.SetCondition(pProps->sCondition);
422 String sLinkName(pProps->sLinkFileName);
423 sLinkName += sfx2::cTokenSeperator;
424 sLinkName += pProps->sSectionFilter;
425 sLinkName += sfx2::cTokenSeperator;
426 sLinkName += pProps->sSectionRegion;
427 aSect.SetLinkFileName(sLinkName);
429 aSect.SetHidden(pProps->bHidden);
430 aSect.SetProtect(pProps->bProtect);
431 // --> FME 2004-06-22 #114856# edit in readonly sections
432 aSect.SetEditInReadonly(pProps->bEditInReadonly);
433 // <--
435 SfxItemSet aSet(pDoc->GetAttrPool(),
436 RES_COL, RES_COL,
437 RES_BACKGROUND, RES_BACKGROUND,
438 RES_FTN_AT_TXTEND, RES_FRAMEDIR,
439 RES_LR_SPACE, RES_LR_SPACE, // #109700#
440 RES_UNKNOWNATR_CONTAINER,RES_UNKNOWNATR_CONTAINER,
442 if(pProps->pBrushItem)
443 aSet.Put(*pProps->pBrushItem);
444 if(pProps->pColItem)
445 aSet.Put(*pProps->pColItem);
446 if(pProps->pFtnItem)
447 aSet.Put(*pProps->pFtnItem);
448 if(pProps->pEndItem)
449 aSet.Put(*pProps->pEndItem);
450 if(pProps->pXMLAttr)
451 aSet.Put(*pProps->pXMLAttr);
452 if(pProps->pNoBalanceItem)
453 aSet.Put(*pProps->pNoBalanceItem);
454 if(pProps->pFrameDirItem)
455 aSet.Put(*pProps->pFrameDirItem);
456 /* #109700# */
457 if(pProps->pLRSpaceItem)
458 aSet.Put(*pProps->pLRSpaceItem);
460 // section password
461 if (pProps->aPassword.getLength() > 0)
462 aSect.SetPasswd(pProps->aPassword);
464 pRet = pDoc->Insert( aPam, aSect, aSet.Count() ? &aSet : 0 );
465 // now create the client
466 m_refCount++;
467 // keep block to remove Reference before the refcount is decremented
469 uno::Reference< text::XTextSection> xSection( this );
470 m_pClient = SwXTextSectionClient::Create(*this, xSection, *pRet->GetFmt());
472 m_refCount--;
474 // #97450# XML import must hide sections depending on their old
475 // condition status
476 if( pProps->sCondition.Len() != 0 )
477 pRet->SetCondHidden(pProps->bCondHidden);
479 // set update type if DDE link (and connect, if necessary)
480 if (pProps->bDDE)
482 if (! pRet->IsConnected())
484 pRet->CreateLink(CREATE_CONNECT);
486 pRet->SetUpdateType( static_cast< USHORT >(pProps->bUpdateType ?
487 sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) );
490 // Undo-Klammerung hier beenden
491 pDoc->EndUndo( UNDO_INSSECTION, NULL );
492 DELETEZ(pProps);
493 m_bIsDescriptor = sal_False;
495 else
496 throw lang::IllegalArgumentException();
498 /*-- 10.12.98 14:47:09---------------------------------------------------
500 -----------------------------------------------------------------------*/
501 void SwXTextSection::attach(const uno::Reference< text::XTextRange > & xTextRange)
502 throw( lang::IllegalArgumentException, uno::RuntimeException )
504 vos::OGuard aGuard(Application::GetSolarMutex());
505 attachToRange( xTextRange );
508 /*-- 10.12.98 14:47:09---------------------------------------------------
510 -----------------------------------------------------------------------*/
511 uno::Reference< text::XTextRange > SwXTextSection::getAnchor(void) throw( uno::RuntimeException )
513 vos::OGuard aGuard(Application::GetSolarMutex());
514 uno::Reference< text::XTextRange > xRet;
515 SwSectionFmt* pSectFmt = GetFmt();
516 if(pSectFmt)
518 const SwSection* pSect;
519 const SwNodeIndex* pIdx;
520 if( 0 != ( pSect = pSectFmt->GetSection() ) &&
521 0 != ( pIdx = pSectFmt->GetCntnt().GetCntntIdx() ) &&
522 pIdx->GetNode().GetNodes().IsDocNodes() )
524 SwPaM aPaM(*pIdx);
525 aPaM.Move( fnMoveForward, fnGoCntnt );
527 const SwEndNode* pEndNode = pIdx->GetNode().EndOfSectionNode();
528 SwPaM aEnd(*pEndNode);
529 aEnd.Move( fnMoveBackward, fnGoCntnt );
530 xRet = SwXTextRange::CreateTextRangeFromPosition(pSectFmt->GetDoc(),
531 *aPaM.Start(), aEnd.Start());
534 return xRet;
536 /*-- 10.12.98 14:47:09---------------------------------------------------
538 -----------------------------------------------------------------------*/
539 void SwXTextSection::dispose(void) throw( uno::RuntimeException )
541 vos::OGuard aGuard(Application::GetSolarMutex());
542 SwSectionFmt* pSectFmt = GetFmt();
543 if(pSectFmt)
544 pSectFmt->GetDoc()->DelSectionFmt( pSectFmt );
545 else
546 throw uno::RuntimeException();
548 /*-- 10.12.98 14:47:10---------------------------------------------------
550 -----------------------------------------------------------------------*/
551 void SwXTextSection::addEventListener(const uno::Reference< lang::XEventListener > & aListener)
552 throw( uno::RuntimeException )
554 if(!GetFmt())
555 throw uno::RuntimeException();
556 aLstnrCntnr.AddListener(aListener);
558 /*-- 10.12.98 14:47:10---------------------------------------------------
560 -----------------------------------------------------------------------*/
561 void SwXTextSection::removeEventListener(const uno::Reference< lang::XEventListener > & aListener)
562 throw( uno::RuntimeException )
564 if(!GetFmt() || !aLstnrCntnr.RemoveListener(aListener))
565 throw uno::RuntimeException();
567 /*-- 10.12.98 14:47:11---------------------------------------------------
569 -----------------------------------------------------------------------*/
570 uno::Reference< beans::XPropertySetInfo > SwXTextSection::getPropertySetInfo(void) throw( uno::RuntimeException )
572 static uno::Reference< beans::XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo();
573 return aRef;
575 /* -----------------------------12.02.01 10:29--------------------------------
577 ---------------------------------------------------------------------------*/
578 struct SwSectItemSet_Impl
581 SfxItemSet* pItemSet;
582 SwSectItemSet_Impl() :
583 pItemSet(0){}
584 ~SwSectItemSet_Impl()
585 {delete pItemSet;}
587 /* -----------------------------12.02.01 10:45--------------------------------
589 ---------------------------------------------------------------------------*/
590 void SAL_CALL SwXTextSection::SetPropertyValues_Impl(
591 const uno::Sequence< OUString >& rPropertyNames,
592 const uno::Sequence< Any >& rValues )
593 throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException,
594 WrappedTargetException, RuntimeException)
596 SwSectionFmt* pFmt = GetFmt();
597 if(rPropertyNames.getLength() != rValues.getLength())
598 throw IllegalArgumentException();
599 if(pFmt || m_bIsDescriptor)
601 SwSection aSection(CONTENT_SECTION, aEmptyStr);
602 SwSection* pSect = pFmt ? pFmt->GetSection() : 0;
603 if(pFmt)
604 aSection = *pSect;
605 const OUString* pPropertyNames = rPropertyNames.getConstArray();
606 const Any* pValues = rValues.getConstArray();
607 SwSectItemSet_Impl aItemSet;
609 sal_Bool bLinkModeChanged = sal_False;
610 sal_Bool bLinkMode = sal_False;
611 for(sal_Int16 nProperty = 0; nProperty < rPropertyNames.getLength(); nProperty++)
613 const SfxItemPropertySimpleEntry* pEntry =
614 m_pPropSet->getPropertyMap()->getByName( pPropertyNames[nProperty] );
615 if(!pEntry)
616 throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProperty], static_cast < cppu::OWeakObject * > ( this ) );
617 else
619 if ( pEntry->nFlags & PropertyAttribute::READONLY)
620 throw PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProperty], static_cast < cppu::OWeakObject * > ( this ) );
621 switch(pEntry->nWID)
623 case WID_SECT_CONDITION:
625 OUString uTmp;
626 pValues[nProperty] >>= uTmp;
627 if(m_bIsDescriptor)
628 pProps->sCondition = String(uTmp);
629 else
630 aSection.SetCondition(uTmp);
632 break;
633 case WID_SECT_DDE_TYPE :
634 case WID_SECT_DDE_FILE :
635 case WID_SECT_DDE_ELEMENT :
637 OUString uTmp;
638 pValues[nProperty] >>= uTmp;
639 String sTmp(uTmp);
640 if(m_bIsDescriptor)
642 if(!pProps->bDDE)
644 pProps->sLinkFileName = sfx2::cTokenSeperator;
645 pProps->sLinkFileName += sfx2::cTokenSeperator;
646 pProps->bDDE = sal_True;
648 pProps->sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE,sfx2::cTokenSeperator,sTmp);
650 else
652 String sLinkFileName(aSection.GetLinkFileName());
653 if(aSection.GetType() != DDE_LINK_SECTION)
655 sLinkFileName = sfx2::cTokenSeperator;
656 sLinkFileName += sfx2::cTokenSeperator;
657 aSection.SetType(DDE_LINK_SECTION);
659 sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE,sfx2::cTokenSeperator, sTmp);
660 aSection.SetLinkFileName(sLinkFileName);
663 break;
664 case WID_SECT_DDE_AUTOUPDATE:
666 sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue();
667 if(m_bIsDescriptor)
669 pProps->bUpdateType = bVal;
671 else
673 bLinkModeChanged = sal_True;
674 bLinkMode = bVal;
677 break;
678 case WID_SECT_LINK :
680 text::SectionFileLink aLink;
681 if(pValues[nProperty] >>= aLink)
683 if(m_bIsDescriptor)
685 pProps->bDDE = sal_False;
686 pProps->sLinkFileName = String(aLink.FileURL);
687 pProps->sSectionFilter = String(aLink.FilterName);
689 else
691 if(aSection.GetType() != FILE_LINK_SECTION &&
692 aLink.FileURL.getLength())
693 aSection.SetType(FILE_LINK_SECTION);
694 String sFileName;
695 if(aLink.FileURL.getLength())
697 sFileName += URIHelper::SmartRel2Abs(
698 pFmt->GetDoc()->GetDocShell()->GetMedium()->GetURLObject(),
699 aLink.FileURL,
700 URIHelper::GetMaybeFileHdl());
702 sFileName += sfx2::cTokenSeperator;
703 sFileName += String(aLink.FilterName);
704 sFileName += sfx2::cTokenSeperator;
705 sFileName += aSection.GetLinkFileName().GetToken( 2, sfx2::cTokenSeperator );
706 aSection.SetLinkFileName(sFileName);
707 if(sFileName.Len() < 3)
708 aSection.SetType(CONTENT_SECTION);
711 else
712 throw lang::IllegalArgumentException();
714 break;
715 case WID_SECT_REGION :
717 OUString uTmp;
718 pValues[nProperty] >>= uTmp;
719 String sLink(uTmp);
720 if(m_bIsDescriptor)
722 pProps->bDDE = sal_False;
723 pProps->sSectionRegion = sLink;
725 else
727 if(aSection.GetType() != FILE_LINK_SECTION &&
728 sLink.Len())
729 aSection.SetType(FILE_LINK_SECTION);
730 String sSectLink(aSection.GetLinkFileName());
731 while( 3 < sSectLink.GetTokenCount( sfx2::cTokenSeperator ))
733 sSectLink += sfx2::cTokenSeperator;
735 sSectLink.SetToken(2, sfx2::cTokenSeperator, sLink);
736 aSection.SetLinkFileName(sSectLink);
737 if(sSectLink.Len() < 3)
738 aSection.SetType(CONTENT_SECTION);
741 break;
742 case WID_SECT_VISIBLE :
744 sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue();
745 if(m_bIsDescriptor)
746 pProps->bHidden = !bVal;
747 else
748 aSection.SetHidden(!bVal);
750 break;
751 case WID_SECT_CURRENTLY_VISIBLE:
753 sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue();
754 if(m_bIsDescriptor)
755 pProps->bCondHidden = !bVal;
756 else
757 if( aSection.GetCondition().Len() != 0 )
758 aSection.SetCondHidden(!bVal);
760 break;
761 case WID_SECT_PROTECTED:
763 sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue();
764 if(m_bIsDescriptor)
765 pProps->bProtect = bVal;
766 else
767 aSection.SetProtect(bVal);
769 break;
770 // --> FME 2004-06-22 #114856# edit in readonly sections
771 case WID_SECT_EDIT_IN_READONLY:
773 sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue();
774 if(m_bIsDescriptor)
775 pProps->bEditInReadonly = bVal;
776 else
777 aSection.SetEditInReadonly(bVal);
779 // <--
780 break;
781 case WID_SECT_PASSWORD:
783 uno::Sequence<sal_Int8> aSeq;
784 pValues[nProperty] >>= aSeq;
785 if (m_bIsDescriptor)
786 pProps->aPassword = aSeq;
787 else
788 aSection.SetPasswd(aSeq);
790 break;
791 default:
792 if(pFmt)
794 const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet();
795 aItemSet.pItemSet = new SfxItemSet(*rOldAttrSet.GetPool(),
796 pEntry->nWID, pEntry->nWID, 0);
797 aItemSet.pItemSet->Put(rOldAttrSet);
798 m_pPropSet->setPropertyValue(*pEntry, pValues[nProperty], *aItemSet.pItemSet);
800 else
802 SfxPoolItem* pPutItem = 0;
803 if(RES_COL == pEntry->nWID)
805 if(!pProps->pColItem)
806 pProps->pColItem = new SwFmtCol;
807 pPutItem = pProps->pColItem;
809 else if(RES_BACKGROUND == pEntry->nWID)
811 if(!pProps->pBrushItem)
812 pProps->pBrushItem = new SvxBrushItem(RES_BACKGROUND);
813 pPutItem = pProps->pBrushItem;
815 else if(RES_FTN_AT_TXTEND == pEntry->nWID)
817 if(!pProps->pFtnItem)
818 pProps->pFtnItem = new SwFmtFtnAtTxtEnd;
819 pPutItem = pProps->pFtnItem;
821 else if(RES_END_AT_TXTEND == pEntry->nWID)
823 if(!pProps->pEndItem)
824 pProps->pEndItem = new SwFmtEndAtTxtEnd;
825 pPutItem = pProps->pEndItem;
827 else if(RES_UNKNOWNATR_CONTAINER== pEntry->nWID)
829 if(!pProps->pXMLAttr)
830 pProps->pXMLAttr= new SvXMLAttrContainerItem( RES_UNKNOWNATR_CONTAINER );
831 pPutItem = pProps->pXMLAttr;
833 else if(RES_COLUMNBALANCE== pEntry->nWID)
835 if(!pProps->pNoBalanceItem)
836 pProps->pNoBalanceItem= new SwFmtNoBalancedColumns( RES_COLUMNBALANCE );
837 pPutItem = pProps->pNoBalanceItem;
839 else if(RES_FRAMEDIR == pEntry->nWID)
841 if(!pProps->pFrameDirItem)
842 pProps->pFrameDirItem = new SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR );
843 pPutItem = pProps->pFrameDirItem;
845 else if(RES_LR_SPACE == pEntry->nWID)
847 // #109700#
848 if(!pProps->pLRSpaceItem)
849 pProps->pLRSpaceItem = new SvxLRSpaceItem( RES_LR_SPACE );
850 pPutItem = pProps->pLRSpaceItem;
852 if(pPutItem)
853 pPutItem->PutValue(pValues[nProperty], pEntry->nMemberId);
858 if(pFmt)
860 SwDoc* pDoc = pFmt->GetDoc();
861 const SwSectionFmts& rFmts = pDoc->GetSections();
862 UnoActionContext aContext(pDoc);
863 for( sal_uInt16 i = 0; i < rFmts.Count(); i++ )
865 if(rFmts[i]->GetSection()->GetName() == pSect->GetName())
867 pDoc->ChgSection( i, aSection, aItemSet.pItemSet, pDoc->IsInReading());
870 // temporarily remove actions to allow cursor update
871 UnoActionRemoveContext aRemoveContext( pDoc );
874 //SwSection* pSect = pFmt->GetSection();
875 if( bLinkModeChanged && pSect->GetType() == DDE_LINK_SECTION)
877 // set update type; needs an established link
878 if(!pSect->IsConnected())
880 pSect->CreateLink(CREATE_CONNECT);
882 pSect->SetUpdateType( static_cast< USHORT >(bLinkMode ?
883 sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) );
885 // section found and processed: break from loop
886 break;
891 else
892 throw uno::RuntimeException();
895 void SwXTextSection::setPropertyValues(
896 const Sequence< ::rtl::OUString >& rPropertyNames,
897 const Sequence< Any >& rValues )
898 throw(PropertyVetoException, lang::IllegalArgumentException,
899 lang::WrappedTargetException, RuntimeException)
901 vos::OGuard aGuard(Application::GetSolarMutex());
903 // workaround for bad designed API
906 SetPropertyValues_Impl( rPropertyNames, rValues );
908 catch (UnknownPropertyException &rException)
910 // wrap the original (here not allowed) exception in
911 // a WrappedTargetException that gets thrown instead.
912 WrappedTargetException aWExc;
913 aWExc.TargetException <<= rException;
914 throw aWExc;
917 /*-- 10.12.98 14:47:11---------------------------------------------------
919 -----------------------------------------------------------------------*/
920 void SwXTextSection::setPropertyValue(
921 const OUString& rPropertyName, const uno::Any& aValue)
922 throw( beans::UnknownPropertyException, beans::PropertyVetoException,
923 lang::IllegalArgumentException, lang::WrappedTargetException,
924 uno::RuntimeException )
926 vos::OGuard aGuard(Application::GetSolarMutex());
927 Sequence< ::rtl::OUString > aPropertyNames(1);
928 aPropertyNames.getArray()[0] = rPropertyName;
929 Sequence< Any > aValues(1);
930 aValues.getArray()[0] = aValue;
931 SetPropertyValues_Impl( aPropertyNames, aValues );
933 /* -----------------------------12.02.01 10:43--------------------------------
935 ---------------------------------------------------------------------------*/
936 uno::Sequence< Any > SAL_CALL SwXTextSection::GetPropertyValues_Impl(
937 const uno::Sequence< OUString > & rPropertyNames )
938 throw( UnknownPropertyException, WrappedTargetException, RuntimeException)
940 Sequence< Any > aRet(rPropertyNames.getLength());
941 Any* pRet = aRet.getArray();
942 SwSectionFmt* pFmt = GetFmt();
943 if(pFmt||m_bIsDescriptor)
945 SwSection* pSect = pFmt ? pFmt->GetSection() : 0;
946 const OUString* pPropertyNames = rPropertyNames.getConstArray();
947 for(sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength(); nProperty++)
949 const SfxItemPropertySimpleEntry* pEntry =
950 m_pPropSet->getPropertyMap()->getByName( pPropertyNames[nProperty]);
951 if(pEntry)
953 switch(pEntry->nWID)
955 case WID_SECT_CONDITION:
957 OUString uTmp(
958 m_bIsDescriptor ? pProps->sCondition : pSect->GetCondition());
959 pRet[nProperty] <<= uTmp;
961 break;
962 case WID_SECT_DDE_TYPE :
963 case WID_SECT_DDE_FILE :
964 case WID_SECT_DDE_ELEMENT :
966 String sRet;
967 if(m_bIsDescriptor)
969 if(pProps->bDDE)
970 sRet = pProps->sLinkFileName;
972 else if( DDE_LINK_SECTION == pSect->GetType() )
974 sRet = pSect->GetLinkFileName();
976 sRet = sRet.GetToken(pEntry->nWID - WID_SECT_DDE_TYPE, sfx2::cTokenSeperator);
977 pRet[nProperty] <<= OUString(sRet);
979 break;
980 case WID_SECT_DDE_AUTOUPDATE:
982 // GetUpdateType() returns .._ALWAYS or .._ONCALL
983 if ( pSect && pSect->IsLinkType() && pSect->IsConnected() ) // lijian i73247
985 sal_Bool bTemp =
986 (pSect->GetUpdateType() == sfx2::LINKUPDATE_ALWAYS);
987 pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType());
990 break;
991 case WID_SECT_LINK :
993 text::SectionFileLink aLink;
994 if(m_bIsDescriptor)
996 if(!pProps->bDDE)
998 aLink.FileURL = pProps->sLinkFileName;
999 aLink.FilterName = pProps->sSectionFilter;
1002 else if( FILE_LINK_SECTION == pSect->GetType() )
1004 String sRet( pSect->GetLinkFileName() );
1005 aLink.FileURL = sRet.GetToken(0, sfx2::cTokenSeperator );
1006 aLink.FilterName = sRet.GetToken(1, sfx2::cTokenSeperator );
1008 pRet[nProperty].setValue(&aLink, ::getCppuType((text::SectionFileLink*)0));
1010 break;
1011 case WID_SECT_REGION :
1013 String sRet;
1014 if(m_bIsDescriptor)
1016 sRet = pProps->sSectionRegion;
1018 else if( FILE_LINK_SECTION == pSect->GetType() )
1019 sRet = pSect->GetLinkFileName().GetToken(2, sfx2::cTokenSeperator);
1020 pRet[nProperty] <<= OUString(sRet);
1022 break;
1023 case WID_SECT_VISIBLE :
1025 sal_Bool bTemp = m_bIsDescriptor ? !pProps->bHidden : !pSect->IsHidden();
1026 pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType());
1028 break;
1029 case WID_SECT_CURRENTLY_VISIBLE:
1031 sal_Bool bTmp = m_bIsDescriptor ? !pProps->bCondHidden : !pSect->IsCondHidden();
1032 pRet[nProperty].setValue( &bTmp, ::getCppuBooleanType());
1034 break;
1035 case WID_SECT_PROTECTED:
1037 sal_Bool bTemp = m_bIsDescriptor ? pProps->bProtect : pSect->IsProtect();
1038 pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType());
1040 break;
1041 // --> FME 2004-06-22 #114856# edit in readonly sections
1042 case WID_SECT_EDIT_IN_READONLY:
1044 sal_Bool bTemp = m_bIsDescriptor ? pProps->bEditInReadonly : pSect->IsEditInReadonly();
1045 pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType());
1047 break;
1048 // <--
1049 case FN_PARAM_LINK_DISPLAY_NAME:
1051 if(pFmt)
1052 pRet[nProperty] <<= OUString(pFmt->GetSection()->GetName());
1054 break;
1055 case WID_SECT_DOCUMENT_INDEX:
1057 // search enclosing index
1058 SwSection* pEnclosingSection = pSect;
1059 while ( (pEnclosingSection != NULL) &&
1060 (TOX_CONTENT_SECTION !=
1061 pEnclosingSection->GetType()) )
1063 pEnclosingSection = pEnclosingSection->GetParent();
1065 if (pEnclosingSection)
1067 // convert section to TOXBase and get SwXDocumentIndex
1068 SwTOXBaseSection* pTOXBaseSect =
1069 PTR_CAST(SwTOXBaseSection, pEnclosingSection);
1070 uno::Reference<XDocumentIndex> xIndex =
1071 SwXDocumentIndexes::GetObject(pTOXBaseSect);
1072 pRet[nProperty] <<= xIndex;
1074 // else: no enclosing index found -> empty return value
1076 break;
1077 case WID_SECT_IS_GLOBAL_DOC_SECTION:
1079 sal_Bool bRet = (NULL == pFmt) ? sal_False :
1080 static_cast< sal_Bool >(NULL != pFmt->GetGlobalDocSection());
1081 pRet[nProperty].setValue( &bRet, ::getCppuBooleanType());
1083 break;
1084 case FN_UNO_ANCHOR_TYPES:
1085 case FN_UNO_TEXT_WRAP:
1086 case FN_UNO_ANCHOR_TYPE:
1087 SwXParagraph::getDefaultTextContentValue(pRet[nProperty], OUString(), pEntry->nWID);
1088 break;
1089 case FN_UNO_REDLINE_NODE_START:
1090 case FN_UNO_REDLINE_NODE_END:
1092 if(!pFmt)
1093 break; // lijian i73247
1094 SwNode* pSectNode = pFmt->GetSectionNode();
1095 if(FN_UNO_REDLINE_NODE_END == pEntry->nWID)
1096 pSectNode = pSectNode->EndOfSectionNode();
1097 const SwRedlineTbl& rRedTbl = pFmt->GetDoc()->GetRedlineTbl();
1098 for(USHORT nRed = 0; nRed < rRedTbl.Count(); nRed++)
1100 const SwRedline* pRedline = rRedTbl[nRed];
1101 const SwNode* pRedPointNode = pRedline->GetNode(TRUE);
1102 const SwNode* pRedMarkNode = pRedline->GetNode(FALSE);
1103 if(pRedPointNode == pSectNode || pRedMarkNode == pSectNode)
1105 const SwNode* pStartOfRedline = SwNodeIndex(*pRedPointNode) <= SwNodeIndex(*pRedMarkNode) ?
1106 pRedPointNode : pRedMarkNode;
1107 BOOL bIsStart = pStartOfRedline == pSectNode;
1108 pRet[nProperty] <<= SwXRedlinePortion::CreateRedlineProperties(*pRedline, bIsStart);
1109 break;
1113 break;
1114 case WID_SECT_PASSWORD:
1116 pRet[nProperty] <<= m_bIsDescriptor ? pProps->aPassword : pSect->GetPasswd();
1118 break;
1119 default:
1120 if(pFmt)
1121 m_pPropSet->getPropertyValue(*pEntry, pFmt->GetAttrSet(), pRet[nProperty]);
1122 else
1124 const SfxPoolItem* pQueryItem = 0;
1125 if(RES_COL == pEntry->nWID)
1127 if(!pProps->pColItem)
1128 pProps->pColItem = new SwFmtCol;
1129 pQueryItem = pProps->pColItem;
1131 else if(RES_BACKGROUND == pEntry->nWID)
1133 if(!pProps->pBrushItem)
1134 pProps->pBrushItem = new SvxBrushItem(RES_BACKGROUND);
1135 pQueryItem = pProps->pBrushItem;
1137 else if(RES_FTN_AT_TXTEND == pEntry->nWID)
1139 if(!pProps->pFtnItem)
1140 pProps->pFtnItem = new SwFmtFtnAtTxtEnd;
1141 pQueryItem = pProps->pFtnItem;
1143 else if(RES_END_AT_TXTEND == pEntry->nWID)
1145 if(!pProps->pEndItem)
1146 pProps->pEndItem = new SwFmtEndAtTxtEnd;
1147 pQueryItem = pProps->pEndItem;
1149 else if(RES_UNKNOWNATR_CONTAINER== pEntry->nWID)
1151 if(!pProps->pXMLAttr)
1152 pProps->pXMLAttr= new SvXMLAttrContainerItem ;
1153 pQueryItem = pProps->pXMLAttr;
1155 else if(RES_COLUMNBALANCE== pEntry->nWID)
1157 if(!pProps->pNoBalanceItem)
1158 pProps->pNoBalanceItem= new SwFmtNoBalancedColumns;
1159 pQueryItem = pProps->pNoBalanceItem;
1161 else if(RES_FRAMEDIR == pEntry->nWID)
1163 if(!pProps->pFrameDirItem)
1164 pProps->pFrameDirItem = new SvxFrameDirectionItem(FRMDIR_ENVIRONMENT, RES_FRAMEDIR);
1165 pQueryItem = pProps->pFrameDirItem;
1167 /* -> #109700# */
1168 else if(RES_LR_SPACE == pEntry->nWID)
1170 if(!pProps->pLRSpaceItem)
1171 pProps->pLRSpaceItem = new SvxLRSpaceItem( RES_LR_SPACE );
1172 pQueryItem = pProps->pLRSpaceItem;
1174 /* <- #109700# */
1175 if(pQueryItem)
1176 pQueryItem->QueryValue(pRet[nProperty], pEntry->nMemberId);
1180 else
1181 throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProperty], static_cast < cppu::OWeakObject * > ( this ) );
1184 else
1185 throw uno::RuntimeException();
1186 return aRet;
1188 /* -----------------------------04.11.03 10:43--------------------------------
1190 ---------------------------------------------------------------------------*/
1191 Sequence< Any > SwXTextSection::getPropertyValues(
1192 const Sequence< ::rtl::OUString >& rPropertyNames )
1193 throw(RuntimeException)
1195 vos::OGuard aGuard(Application::GetSolarMutex());
1196 Sequence< Any > aValues;
1198 // workaround for bad designed API
1201 aValues = GetPropertyValues_Impl( rPropertyNames );
1203 catch (UnknownPropertyException &)
1205 throw RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1207 catch (WrappedTargetException &)
1209 throw RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
1212 return aValues;
1214 /*-- 10.12.98 14:47:12---------------------------------------------------
1216 -----------------------------------------------------------------------*/
1217 uno::Any SwXTextSection::getPropertyValue(const OUString& rPropertyName)
1218 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1220 vos::OGuard aGuard(Application::GetSolarMutex());
1221 Sequence< ::rtl::OUString > aPropertyNames(1);
1222 aPropertyNames.getArray()[0] = rPropertyName;
1223 return GetPropertyValues_Impl(aPropertyNames).getConstArray()[0];
1225 /* -----------------------------12.02.01 10:30--------------------------------
1227 ---------------------------------------------------------------------------*/
1228 void SwXTextSection::addPropertiesChangeListener(
1229 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/,
1230 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) throw(RuntimeException)
1232 DBG_WARNING("not implemented");
1234 /* -----------------------------12.02.01 10:30--------------------------------
1236 ---------------------------------------------------------------------------*/
1237 void SwXTextSection::removePropertiesChangeListener(
1238 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
1239 throw(RuntimeException)
1241 DBG_WARNING("not implemented");
1243 /* -----------------------------12.02.01 10:30--------------------------------
1245 ---------------------------------------------------------------------------*/
1246 void SwXTextSection::firePropertiesChangeEvent(
1247 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/,
1248 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
1249 throw(RuntimeException)
1251 DBG_WARNING("not implemented");
1253 /*-- 10.12.98 14:47:13---------------------------------------------------
1255 -----------------------------------------------------------------------*/
1256 void SwXTextSection::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1258 DBG_WARNING("not implemented");
1260 /*-- 10.12.98 14:47:13---------------------------------------------------
1262 -----------------------------------------------------------------------*/
1263 void SwXTextSection::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1265 DBG_WARNING("not implemented");
1267 /*-- 10.12.98 14:47:14---------------------------------------------------
1269 -----------------------------------------------------------------------*/
1270 void SwXTextSection::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1272 DBG_WARNING("not implemented");
1274 /*-- 10.12.98 14:47:14---------------------------------------------------
1276 -----------------------------------------------------------------------*/
1277 void SwXTextSection::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
1279 DBG_WARNING("not implemented");
1282 /*-- 08.11.00 10:47:55---------------------------------------------------
1284 -----------------------------------------------------------------------*/
1285 PropertyState SwXTextSection::getPropertyState( const OUString& rPropertyName )
1286 throw(UnknownPropertyException, RuntimeException)
1288 vos::OGuard aGuard(Application::GetSolarMutex());
1289 Sequence< OUString > aNames(1);
1290 aNames.getArray()[0] = rPropertyName;
1291 return getPropertyStates(aNames).getConstArray()[0];
1293 /*-- 08.11.00 10:47:55---------------------------------------------------
1295 -----------------------------------------------------------------------*/
1296 Sequence< PropertyState > SwXTextSection::getPropertyStates(
1297 const Sequence< OUString >& rPropertyNames )
1298 throw(UnknownPropertyException, RuntimeException)
1300 vos::OGuard aGuard(Application::GetSolarMutex());
1301 Sequence< PropertyState > aStates(rPropertyNames.getLength());
1302 SwSectionFmt* pFmt = GetFmt();
1303 if(pFmt||m_bIsDescriptor)
1305 PropertyState* pStates = aStates.getArray();
1306 const OUString* pNames = rPropertyNames.getConstArray();
1307 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
1309 pStates[i] = PropertyState_DEFAULT_VALUE;
1310 const SfxItemPropertySimpleEntry* pEntry =
1311 m_pPropSet->getPropertyMap()->getByName( pNames[i]);
1312 if(!pEntry)
1313 throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) );
1314 switch(pEntry->nWID)
1316 case WID_SECT_CONDITION:
1317 case WID_SECT_DDE_TYPE :
1318 case WID_SECT_DDE_FILE :
1319 case WID_SECT_DDE_ELEMENT :
1320 case WID_SECT_DDE_AUTOUPDATE:
1321 case WID_SECT_LINK :
1322 case WID_SECT_REGION :
1323 case WID_SECT_VISIBLE :
1324 case WID_SECT_PROTECTED:
1325 // --> FME 2004-06-22 #114856# edit in readonly sections
1326 case WID_SECT_EDIT_IN_READONLY:
1327 // <--
1328 case FN_PARAM_LINK_DISPLAY_NAME:
1329 case FN_UNO_ANCHOR_TYPES:
1330 case FN_UNO_TEXT_WRAP:
1331 case FN_UNO_ANCHOR_TYPE:
1332 pStates[i] = PropertyState_DIRECT_VALUE;
1333 break;
1334 default:
1335 if(pFmt)
1336 pStates[i] = m_pPropSet->getPropertyState(pNames[i], pFmt->GetAttrSet());
1337 else
1339 if(RES_COL == pEntry->nWID)
1341 if(!pProps->pColItem)
1342 pStates[i] = PropertyState_DEFAULT_VALUE;
1343 else
1344 pStates[i] = PropertyState_DIRECT_VALUE;
1346 else //if(RES_BACKGROUND == pEntry->nWID)
1348 if(!pProps->pBrushItem)
1349 pStates[i] = PropertyState_DEFAULT_VALUE;
1350 else
1351 pStates[i] = PropertyState_DIRECT_VALUE;
1357 else
1358 throw RuntimeException();
1359 return aStates;
1361 /*-- 08.11.00 10:47:55---------------------------------------------------
1363 -----------------------------------------------------------------------*/
1364 void SwXTextSection::setPropertyToDefault( const OUString& rPropertyName )
1365 throw(UnknownPropertyException, RuntimeException)
1367 vos::OGuard aGuard(Application::GetSolarMutex());
1368 SwSectionFmt* pFmt = GetFmt();
1369 if(pFmt||m_bIsDescriptor)
1371 SwSection aSection(CONTENT_SECTION, aEmptyStr);
1372 SwSection* pSect = pFmt ? pFmt->GetSection() : 0;
1373 if(pFmt)
1374 aSection = *pSect;
1375 const SfxItemPropertySimpleEntry* pEntry =
1376 m_pPropSet->getPropertyMap()->getByName( rPropertyName );
1377 if(!pEntry)
1378 throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1379 if ( pEntry->nFlags & PropertyAttribute::READONLY)
1380 throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertyToDefault: property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1381 SfxItemSet* pNewAttrSet = 0;
1382 switch(pEntry->nWID)
1384 case WID_SECT_CONDITION:
1386 if(m_bIsDescriptor)
1387 pProps->sCondition = aEmptyStr;
1388 else
1389 aSection.SetCondition(aEmptyStr);
1391 break;
1392 case WID_SECT_DDE_TYPE :
1393 case WID_SECT_DDE_FILE :
1394 case WID_SECT_DDE_ELEMENT :
1395 case WID_SECT_LINK :
1396 case WID_SECT_REGION :
1397 aSection.SetType(CONTENT_SECTION);
1398 break;
1399 case WID_SECT_DDE_AUTOUPDATE:
1400 aSection.SetUpdateType(sfx2::LINKUPDATE_ALWAYS);
1401 break;
1402 case WID_SECT_VISIBLE :
1404 if(m_bIsDescriptor)
1405 pProps->bHidden = FALSE;
1406 else
1407 aSection.SetHidden(FALSE);
1409 break;
1410 case WID_SECT_PROTECTED:
1412 if(m_bIsDescriptor)
1413 pProps->bProtect = FALSE;
1414 else
1415 aSection.SetProtect(FALSE);
1417 break;
1418 // --> FME 2004-06-22 #114856# edit in readonly sections
1419 case WID_SECT_EDIT_IN_READONLY:
1421 if(m_bIsDescriptor)
1422 pProps->bEditInReadonly = FALSE;
1423 else
1424 aSection.SetEditInReadonly(FALSE);
1426 break;
1427 // <--
1429 case FN_UNO_ANCHOR_TYPES:
1430 case FN_UNO_TEXT_WRAP:
1431 case FN_UNO_ANCHOR_TYPE:
1432 break;
1433 default:
1434 if(pEntry->nWID <= SFX_WHICH_MAX)
1436 if(pFmt)
1438 const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet();
1439 pNewAttrSet = new SfxItemSet(*rOldAttrSet.GetPool(),
1440 pEntry->nWID, pEntry->nWID, 0);
1441 pNewAttrSet->ClearItem(pEntry->nWID);
1443 else
1445 if(RES_COL == pEntry->nWID)
1446 DELETEZ(pProps->pColItem);
1447 else if(RES_BACKGROUND == pEntry->nWID)
1448 DELETEZ(pProps->pBrushItem);
1452 if(pFmt)
1454 SwDoc* pDoc = pFmt->GetDoc();
1455 const SwSectionFmts& rFmts = pDoc->GetSections();
1456 UnoActionContext aContext(pDoc);
1457 for( sal_uInt16 i = 0; i < rFmts.Count(); i++ )
1459 if(rFmts[i]->GetSection()->GetName() == pSect->GetName())
1461 pDoc->ChgSection( i, aSection, pNewAttrSet, pDoc->IsInReading());
1464 // temporarily remove actions to allow cursor update
1465 UnoActionRemoveContext aRemoveContext( pDoc );
1468 break;
1471 delete pNewAttrSet;
1474 else
1475 throw RuntimeException();
1477 /*-- 08.11.00 10:47:56---------------------------------------------------
1479 -----------------------------------------------------------------------*/
1480 Any SwXTextSection::getPropertyDefault( const OUString& rPropertyName )
1481 throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
1483 vos::OGuard aGuard(Application::GetSolarMutex());
1484 uno::Any aRet;
1485 SwSectionFmt* pFmt = GetFmt();
1486 const SfxItemPropertySimpleEntry* pEntry =
1487 m_pPropSet->getPropertyMap()->getByName( rPropertyName );
1488 if (!pEntry)
1489 throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1491 switch(pEntry->nWID)
1493 case WID_SECT_CONDITION:
1494 case WID_SECT_DDE_TYPE :
1495 case WID_SECT_DDE_FILE :
1496 case WID_SECT_DDE_ELEMENT :
1497 case WID_SECT_REGION :
1498 case FN_PARAM_LINK_DISPLAY_NAME:
1499 aRet <<= OUString();
1500 break;
1501 case WID_SECT_LINK :
1502 aRet <<= SectionFileLink();
1503 break;
1504 case WID_SECT_DDE_AUTOUPDATE:
1505 case WID_SECT_VISIBLE :
1507 sal_Bool bTemp = TRUE;
1508 aRet.setValue( &bTemp, ::getCppuBooleanType());
1510 break;
1511 case WID_SECT_PROTECTED:
1512 // --> FME 2004-06-22 #114856# edit in readonly sections
1513 case WID_SECT_EDIT_IN_READONLY:
1514 // <--
1516 sal_Bool bTemp = FALSE;
1517 aRet.setValue( &bTemp, ::getCppuBooleanType());
1519 break;
1520 case FN_UNO_ANCHOR_TYPES:
1521 case FN_UNO_TEXT_WRAP:
1522 case FN_UNO_ANCHOR_TYPE:
1523 SwXParagraph::getDefaultTextContentValue(aRet, OUString(), pEntry->nWID);
1524 break;
1525 default:
1526 if(pFmt && pEntry->nWID <= SFX_WHICH_MAX)
1528 SwDoc* pDoc = pFmt->GetDoc();
1529 const SfxPoolItem& rDefItem =
1530 pDoc->GetAttrPool().GetDefaultItem(pEntry->nWID);
1531 rDefItem.QueryValue(aRet, pEntry->nMemberId);
1534 return aRet;
1536 /*-- 10.12.98 14:47:15---------------------------------------------------
1538 -----------------------------------------------------------------------*/
1539 OUString SwXTextSection::getName(void) throw( uno::RuntimeException )
1541 vos::OGuard aGuard(Application::GetSolarMutex());
1542 String sRet;
1543 const SwSectionFmt* pFmt = GetFmt();
1544 if(pFmt)
1545 sRet = pFmt->GetSection()->GetName();
1546 else if(m_bIsDescriptor)
1547 sRet = m_sName;
1548 else
1549 throw uno::RuntimeException();
1550 return sRet;
1552 /*-- 10.12.98 14:47:16---------------------------------------------------
1554 -----------------------------------------------------------------------*/
1555 void SwXTextSection::setName(const OUString& rName) throw( uno::RuntimeException )
1557 vos::OGuard aGuard(Application::GetSolarMutex());
1558 SwSectionFmt* pFmt = GetFmt();
1559 if(pFmt)
1561 SwSection aSection(CONTENT_SECTION, aEmptyStr);
1562 SwSection* pSect = pFmt->GetSection();
1563 aSection = *pSect;
1564 String sNewName(rName);
1565 aSection.SetName(sNewName);
1567 const SwSectionFmts& rFmts = pFmt->GetDoc()->GetSections();
1568 sal_uInt16 nApplyPos = USHRT_MAX;
1569 for( sal_uInt16 i = 0; i < rFmts.Count(); i++ )
1571 if(rFmts[i]->GetSection() == pSect)
1572 nApplyPos = i;
1573 else if(sNewName == rFmts[i]->GetSection()->GetName())
1574 throw uno::RuntimeException();
1576 if(nApplyPos != USHRT_MAX)
1579 UnoActionContext aContext(pFmt->GetDoc());
1580 pFmt->GetDoc()->ChgSection( nApplyPos, aSection);
1583 // temporarily remove actions to allow cursor update
1584 UnoActionRemoveContext aRemoveContext( pFmt->GetDoc() );
1588 else if(m_bIsDescriptor)
1589 m_sName = String(rName);
1590 else
1591 throw uno::RuntimeException();
1593 /* -----------------02.11.99 11:30-------------------
1595 --------------------------------------------------*/
1596 OUString SwXTextSection::getImplementationName(void) throw( uno::RuntimeException )
1598 return C2U("SwXTextSection");
1600 /* -----------------02.11.99 11:30-------------------
1602 --------------------------------------------------*/
1603 sal_Bool SwXTextSection::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
1605 return !rServiceName.compareToAscii("com.sun.star.text.TextSection") ||
1606 !rServiceName.compareToAscii("com.sun.star.document.LinkTarget") ||
1607 !rServiceName.compareToAscii("com.sun.star.text.TextContent");
1609 /* -----------------02.11.99 11:30-------------------
1611 --------------------------------------------------*/
1612 uno::Sequence< OUString > SwXTextSection::getSupportedServiceNames(void) throw( uno::RuntimeException )
1614 uno::Sequence< OUString > aRet(3);
1615 OUString* pArr = aRet.getArray();
1616 pArr[0] = C2U("com.sun.star.text.TextSection");
1617 pArr[1] = C2U("com.sun.star.document.LinkTarget");
1618 pArr[2] = C2U("com.sun.star.text.TextContent");
1619 return aRet;
1622 /*-- 20.12.2005 10:27:33---------------------------------------------------
1624 -----------------------------------------------------------------------*/
1625 SwSectionFmt* SwXTextSection::GetFmt()const
1627 return m_pClient ?
1628 const_cast<SwSectionFmt*>(static_cast< const SwSectionFmt* >(m_pClient->GetRegisteredIn()))
1629 : 0;