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 $
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>
38 #include <hintids.hxx>
39 #include <svtools/urihelper.hxx>
40 #include <svx/brshitem.hxx>
41 #ifndef _SVX_XMLCNITEM_HXX
42 #include <svx/xmlcnitm.hxx>
44 #include <sfx2/linkmgr.hxx>
45 #include <sfx2/lnkbase.hxx>
46 #include <vos/mutex.hxx>
47 #include <vcl/svapp.hxx>
48 #include <fmtclds.hxx>
50 #include <unoredline.hxx>
51 #include <redline.hxx>
53 #include <unocrsr.hxx>
54 #include <section.hxx>
59 #include <sfx2/docfile.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>
71 #include <svx/frmdiritem.hxx>
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(
89 SwXTextSection
& rTextSection
,
90 uno::Reference
< text::XTextSection
> xSection
) :
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
);
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() )
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);
135 ClientModify(this, pOld
, pNew
);
136 if(!GetRegisteredIn())
138 uno::Reference
< text::XTextSection
> xSection( m_xReference
);
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
)
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
);
170 new SwXTextSectionClient( *pFmt
, *pNew
, 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
189 String sLinkFileName
;
190 String sSectionFilter
;
191 String sSectionRegion
;
192 uno::Sequence
<sal_Int8
> aPassword
;
195 SvxBrushItem
* pBrushItem
;
196 SwFmtFtnAtTxtEnd
* pFtnItem
;
197 SwFmtEndAtTxtEnd
* pEndItem
;
198 SvXMLAttrContainerItem
*pXMLAttr
;
199 SwFmtNoBalancedColumns
*pNoBalanceItem
;
200 SvxFrameDirectionItem
*pFrameDirItem
;
201 SvxLRSpaceItem
*pLRSpaceItem
; // #109700#
204 sal_Bool bCondHidden
;
206 // --> FME 2004-06-22 #114856# edit in readonly sections
207 sal_Bool bEditInReadonly
;
209 sal_Bool bUpdateType
;
211 SwTextSectionProperties_Impl() :
219 pLRSpaceItem(0), // #109700#
224 // --> FME 2004-06-22 #114856# edit in readonly sections
227 bUpdateType(sal_True
){}
229 ~SwTextSectionProperties_Impl()
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
);
248 return reinterpret_cast< SwXTextSection
* >(
249 sal::static_int_cast
< sal_IntPtr
>( xTunnel
->getSomething(SwXTextSection::getUnoTunnelId()) ));
253 /* -----------------------------13.03.00 12:15--------------------------------
255 ---------------------------------------------------------------------------*/
256 const uno::Sequence
< sal_Int8
> & SwXTextSection::getUnoTunnelId()
258 static uno::Sequence
< sal_Int8
> aSeq
= ::CreateUnoTunnelId();
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 ) );
275 /*-- 10.12.98 14:47:05---------------------------------------------------
277 -----------------------------------------------------------------------*/
278 SwXTextSection::SwXTextSection(sal_Bool bWithFormat
, sal_Bool bIndexHeader
) :
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()),
289 /*-- 10.12.98 14:47:07---------------------------------------------------
291 -----------------------------------------------------------------------*/
292 SwXTextSection::~SwXTextSection()
294 vos::OGuard
aGuard(Application::GetSolarMutex());
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();
308 SwSectionFmt
* pParentFmt
= pSectFmt
->GetParent();
311 SwXTextSectionClient
* pClient
= (SwXTextSectionClient
*)SwClientIter(*pParentFmt
).
312 First(TYPE(SwXTextSectionClient
));
314 aRef
= pClient
->GetXTextSection();
316 aRef
= SwXTextSectionClient::CreateXTextSection(pParentFmt
);
320 throw uno::RuntimeException();
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();
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
));
345 pArray
[i
] = pClient
->GetXTextSection();
347 pArray
[i
] = SwXTextSectionClient::CreateXTextSection(pChild
);
353 /* -----------------18.02.99 13:31-------------------
355 * --------------------------------------------------*/
356 void SwXTextSection::attachToRange(const uno::Reference
< text::XTextRange
> & xTextRange
)
357 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
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;
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
);
384 m_sName
= C2S("TextSection");
385 SectionType eType
= pProps
->bDDE
? DDE_LINK_SECTION
:
386 pProps
->sLinkFileName
.Len() || pProps
->sSectionRegion
.Len() ? FILE_LINK_SECTION
:
388 // index header section?
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(
397 // are we inside an index?
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
++)
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
);
435 SfxItemSet
aSet(pDoc
->GetAttrPool(),
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
);
445 aSet
.Put(*pProps
->pColItem
);
447 aSet
.Put(*pProps
->pFtnItem
);
449 aSet
.Put(*pProps
->pEndItem
);
451 aSet
.Put(*pProps
->pXMLAttr
);
452 if(pProps
->pNoBalanceItem
)
453 aSet
.Put(*pProps
->pNoBalanceItem
);
454 if(pProps
->pFrameDirItem
)
455 aSet
.Put(*pProps
->pFrameDirItem
);
457 if(pProps
->pLRSpaceItem
)
458 aSet
.Put(*pProps
->pLRSpaceItem
);
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
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());
474 // #97450# XML import must hide sections depending on their old
476 if( pProps
->sCondition
.Len() != 0 )
477 pRet
->SetCondHidden(pProps
->bCondHidden
);
479 // set update type if DDE link (and connect, if necessary)
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
);
493 m_bIsDescriptor
= sal_False
;
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();
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() )
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());
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();
544 pSectFmt
->GetDoc()->DelSectionFmt( pSectFmt
);
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
)
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();
575 /* -----------------------------12.02.01 10:29--------------------------------
577 ---------------------------------------------------------------------------*/
578 struct SwSectItemSet_Impl
581 SfxItemSet
* pItemSet
;
582 SwSectItemSet_Impl() :
584 ~SwSectItemSet_Impl()
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;
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
] );
616 throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames
[nProperty
], static_cast < cppu::OWeakObject
* > ( this ) );
619 if ( pEntry
->nFlags
& PropertyAttribute::READONLY
)
620 throw PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames
[nProperty
], static_cast < cppu::OWeakObject
* > ( this ) );
623 case WID_SECT_CONDITION
:
626 pValues
[nProperty
] >>= uTmp
;
628 pProps
->sCondition
= String(uTmp
);
630 aSection
.SetCondition(uTmp
);
633 case WID_SECT_DDE_TYPE
:
634 case WID_SECT_DDE_FILE
:
635 case WID_SECT_DDE_ELEMENT
:
638 pValues
[nProperty
] >>= uTmp
;
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
);
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
);
664 case WID_SECT_DDE_AUTOUPDATE
:
666 sal_Bool bVal
= *(sal_Bool
*)pValues
[nProperty
].getValue();
669 pProps
->bUpdateType
= bVal
;
673 bLinkModeChanged
= sal_True
;
680 text::SectionFileLink aLink
;
681 if(pValues
[nProperty
] >>= aLink
)
685 pProps
->bDDE
= sal_False
;
686 pProps
->sLinkFileName
= String(aLink
.FileURL
);
687 pProps
->sSectionFilter
= String(aLink
.FilterName
);
691 if(aSection
.GetType() != FILE_LINK_SECTION
&&
692 aLink
.FileURL
.getLength())
693 aSection
.SetType(FILE_LINK_SECTION
);
695 if(aLink
.FileURL
.getLength())
697 sFileName
+= URIHelper::SmartRel2Abs(
698 pFmt
->GetDoc()->GetDocShell()->GetMedium()->GetURLObject(),
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
);
712 throw lang::IllegalArgumentException();
715 case WID_SECT_REGION
:
718 pValues
[nProperty
] >>= uTmp
;
722 pProps
->bDDE
= sal_False
;
723 pProps
->sSectionRegion
= sLink
;
727 if(aSection
.GetType() != FILE_LINK_SECTION
&&
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
);
742 case WID_SECT_VISIBLE
:
744 sal_Bool bVal
= *(sal_Bool
*)pValues
[nProperty
].getValue();
746 pProps
->bHidden
= !bVal
;
748 aSection
.SetHidden(!bVal
);
751 case WID_SECT_CURRENTLY_VISIBLE
:
753 sal_Bool bVal
= *(sal_Bool
*)pValues
[nProperty
].getValue();
755 pProps
->bCondHidden
= !bVal
;
757 if( aSection
.GetCondition().Len() != 0 )
758 aSection
.SetCondHidden(!bVal
);
761 case WID_SECT_PROTECTED
:
763 sal_Bool bVal
= *(sal_Bool
*)pValues
[nProperty
].getValue();
765 pProps
->bProtect
= bVal
;
767 aSection
.SetProtect(bVal
);
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();
775 pProps
->bEditInReadonly
= bVal
;
777 aSection
.SetEditInReadonly(bVal
);
781 case WID_SECT_PASSWORD
:
783 uno::Sequence
<sal_Int8
> aSeq
;
784 pValues
[nProperty
] >>= aSeq
;
786 pProps
->aPassword
= aSeq
;
788 aSection
.SetPasswd(aSeq
);
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
);
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
)
848 if(!pProps
->pLRSpaceItem
)
849 pProps
->pLRSpaceItem
= new SvxLRSpaceItem( RES_LR_SPACE
);
850 pPutItem
= pProps
->pLRSpaceItem
;
853 pPutItem
->PutValue(pValues
[nProperty
], pEntry
->nMemberId
);
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
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
;
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
]);
955 case WID_SECT_CONDITION
:
958 m_bIsDescriptor
? pProps
->sCondition
: pSect
->GetCondition());
959 pRet
[nProperty
] <<= uTmp
;
962 case WID_SECT_DDE_TYPE
:
963 case WID_SECT_DDE_FILE
:
964 case WID_SECT_DDE_ELEMENT
:
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
);
980 case WID_SECT_DDE_AUTOUPDATE
:
982 // GetUpdateType() returns .._ALWAYS or .._ONCALL
983 if ( pSect
&& pSect
->IsLinkType() && pSect
->IsConnected() ) // lijian i73247
986 (pSect
->GetUpdateType() == sfx2::LINKUPDATE_ALWAYS
);
987 pRet
[nProperty
].setValue( &bTemp
, ::getCppuBooleanType());
993 text::SectionFileLink aLink
;
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));
1011 case WID_SECT_REGION
:
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
);
1023 case WID_SECT_VISIBLE
:
1025 sal_Bool bTemp
= m_bIsDescriptor
? !pProps
->bHidden
: !pSect
->IsHidden();
1026 pRet
[nProperty
].setValue( &bTemp
, ::getCppuBooleanType());
1029 case WID_SECT_CURRENTLY_VISIBLE
:
1031 sal_Bool bTmp
= m_bIsDescriptor
? !pProps
->bCondHidden
: !pSect
->IsCondHidden();
1032 pRet
[nProperty
].setValue( &bTmp
, ::getCppuBooleanType());
1035 case WID_SECT_PROTECTED
:
1037 sal_Bool bTemp
= m_bIsDescriptor
? pProps
->bProtect
: pSect
->IsProtect();
1038 pRet
[nProperty
].setValue( &bTemp
, ::getCppuBooleanType());
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());
1049 case FN_PARAM_LINK_DISPLAY_NAME
:
1052 pRet
[nProperty
] <<= OUString(pFmt
->GetSection()->GetName());
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
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());
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
);
1089 case FN_UNO_REDLINE_NODE_START
:
1090 case FN_UNO_REDLINE_NODE_END
:
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
);
1114 case WID_SECT_PASSWORD
:
1116 pRet
[nProperty
] <<= m_bIsDescriptor
? pProps
->aPassword
: pSect
->GetPasswd();
1121 m_pPropSet
->getPropertyValue(*pEntry
, pFmt
->GetAttrSet(), pRet
[nProperty
]);
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
;
1168 else if(RES_LR_SPACE
== pEntry
->nWID
)
1170 if(!pProps
->pLRSpaceItem
)
1171 pProps
->pLRSpaceItem
= new SvxLRSpaceItem( RES_LR_SPACE
);
1172 pQueryItem
= pProps
->pLRSpaceItem
;
1176 pQueryItem
->QueryValue(pRet
[nProperty
], pEntry
->nMemberId
);
1181 throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames
[nProperty
], static_cast < cppu::OWeakObject
* > ( this ) );
1185 throw uno::RuntimeException();
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 ) );
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
]);
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
:
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
;
1336 pStates
[i
] = m_pPropSet
->getPropertyState(pNames
[i
], pFmt
->GetAttrSet());
1339 if(RES_COL
== pEntry
->nWID
)
1341 if(!pProps
->pColItem
)
1342 pStates
[i
] = PropertyState_DEFAULT_VALUE
;
1344 pStates
[i
] = PropertyState_DIRECT_VALUE
;
1346 else //if(RES_BACKGROUND == pEntry->nWID)
1348 if(!pProps
->pBrushItem
)
1349 pStates
[i
] = PropertyState_DEFAULT_VALUE
;
1351 pStates
[i
] = PropertyState_DIRECT_VALUE
;
1358 throw RuntimeException();
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;
1375 const SfxItemPropertySimpleEntry
* pEntry
=
1376 m_pPropSet
->getPropertyMap()->getByName( rPropertyName
);
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
:
1387 pProps
->sCondition
= aEmptyStr
;
1389 aSection
.SetCondition(aEmptyStr
);
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
);
1399 case WID_SECT_DDE_AUTOUPDATE
:
1400 aSection
.SetUpdateType(sfx2::LINKUPDATE_ALWAYS
);
1402 case WID_SECT_VISIBLE
:
1405 pProps
->bHidden
= FALSE
;
1407 aSection
.SetHidden(FALSE
);
1410 case WID_SECT_PROTECTED
:
1413 pProps
->bProtect
= FALSE
;
1415 aSection
.SetProtect(FALSE
);
1418 // --> FME 2004-06-22 #114856# edit in readonly sections
1419 case WID_SECT_EDIT_IN_READONLY
:
1422 pProps
->bEditInReadonly
= FALSE
;
1424 aSection
.SetEditInReadonly(FALSE
);
1429 case FN_UNO_ANCHOR_TYPES
:
1430 case FN_UNO_TEXT_WRAP
:
1431 case FN_UNO_ANCHOR_TYPE
:
1434 if(pEntry
->nWID
<= SFX_WHICH_MAX
)
1438 const SfxItemSet
& rOldAttrSet
= pFmt
->GetAttrSet();
1439 pNewAttrSet
= new SfxItemSet(*rOldAttrSet
.GetPool(),
1440 pEntry
->nWID
, pEntry
->nWID
, 0);
1441 pNewAttrSet
->ClearItem(pEntry
->nWID
);
1445 if(RES_COL
== pEntry
->nWID
)
1446 DELETEZ(pProps
->pColItem
);
1447 else if(RES_BACKGROUND
== pEntry
->nWID
)
1448 DELETEZ(pProps
->pBrushItem
);
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
);
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());
1485 SwSectionFmt
* pFmt
= GetFmt();
1486 const SfxItemPropertySimpleEntry
* pEntry
=
1487 m_pPropSet
->getPropertyMap()->getByName( rPropertyName
);
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();
1501 case WID_SECT_LINK
:
1502 aRet
<<= SectionFileLink();
1504 case WID_SECT_DDE_AUTOUPDATE
:
1505 case WID_SECT_VISIBLE
:
1507 sal_Bool bTemp
= TRUE
;
1508 aRet
.setValue( &bTemp
, ::getCppuBooleanType());
1511 case WID_SECT_PROTECTED
:
1512 // --> FME 2004-06-22 #114856# edit in readonly sections
1513 case WID_SECT_EDIT_IN_READONLY
:
1516 sal_Bool bTemp
= FALSE
;
1517 aRet
.setValue( &bTemp
, ::getCppuBooleanType());
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
);
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
);
1536 /*-- 10.12.98 14:47:15---------------------------------------------------
1538 -----------------------------------------------------------------------*/
1539 OUString
SwXTextSection::getName(void) throw( uno::RuntimeException
)
1541 vos::OGuard
aGuard(Application::GetSolarMutex());
1543 const SwSectionFmt
* pFmt
= GetFmt();
1545 sRet
= pFmt
->GetSection()->GetName();
1546 else if(m_bIsDescriptor
)
1549 throw uno::RuntimeException();
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();
1561 SwSection
aSection(CONTENT_SECTION
, aEmptyStr
);
1562 SwSection
* pSect
= pFmt
->GetSection();
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
)
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
);
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");
1622 /*-- 20.12.2005 10:27:33---------------------------------------------------
1624 -----------------------------------------------------------------------*/
1625 SwSectionFmt
* SwXTextSection::GetFmt()const
1628 const_cast<SwSectionFmt
*>(static_cast< const SwSectionFmt
* >(m_pClient
->GetRegisteredIn()))