xref: /trunk/main/sw/source/core/unocore/unoftn.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include <rtl/uuid.h>
28 
29 #include <vos/mutex.hxx>
30 #include <vcl/svapp.hxx>
31 #include <comphelper/sequence.hxx>
32 
33 #include <unomid.h>
34 #include <unofootnote.hxx>
35 #include <unotextrange.hxx>
36 #include <unotextcursor.hxx>
37 #include <unoparagraph.hxx>
38 #include <unomap.hxx>
39 #include <unoprnms.hxx>
40 #include <unoevtlstnr.hxx>
41 #include <doc.hxx>
42 #include <ftnidx.hxx>
43 #include <fmtftn.hxx>
44 #include <txtftn.hxx>
45 #include <ndtxt.hxx>
46 #include <unocrsr.hxx>
47 #include <hints.hxx>
48 
49 
50 using namespace ::com::sun::star;
51 using ::rtl::OUString;
52 
53 /******************************************************************
54  * SwXFootnote
55  ******************************************************************/
56 
57 class SwXFootnote::Impl
58     : public SwClient
59 {
60 
61 public:
62 
63     SwXFootnote &               m_rThis;
64     const bool                  m_bIsEndnote;
65     SwEventListenerContainer    m_ListenerContainer;
66     bool                        m_bIsDescriptor;
67     const SwFmtFtn *            m_pFmtFtn;
68     ::rtl::OUString             m_sLabel;
69 
Impl(SwXFootnote & rThis,SwDoc * const pDoc,SwFmtFtn const * const pFootnote,const bool bIsEndnote)70     Impl(   SwXFootnote & rThis,
71             SwDoc *const pDoc, SwFmtFtn const*const pFootnote,
72             const bool bIsEndnote)
73         : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0)
74         , m_rThis(rThis)
75         , m_bIsEndnote(bIsEndnote)
76         , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis))
77 // #i111177#: unxsols4 (Sun C++ 5.9 SunOS_sparc) generates wrong code for this
78 //        , m_bIsDescriptor(0 == pFootnote)
79         , m_bIsDescriptor((0 == pFootnote) ? true : false)
80         , m_pFmtFtn(pFootnote)
81     {
82     }
83 
GetFootnoteFormat() const84     const SwFmtFtn* GetFootnoteFormat() const {
85         return m_rThis.GetDoc() ? m_pFmtFtn : 0;
86     }
87 
GetFootnoteFormatOrThrow()88     SwFmtFtn const& GetFootnoteFormatOrThrow() {
89         SwFmtFtn const*const pFootnote( GetFootnoteFormat() );
90         if (!pFootnote) {
91             throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
92                         "SwXFootnote: disposed or invalid")), 0);
93         }
94         return *pFootnote;
95     }
96 
97     void    Invalidate();
98 protected:
99     // SwClient
100     virtual void Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew);
101 
102 };
103 
104 /* -----------------------------07.01.00 12:39--------------------------------
105 
106  ---------------------------------------------------------------------------*/
Invalidate()107 void SwXFootnote::Impl::Invalidate()
108 {
109     if (GetRegisteredIn())
110     {
111         const_cast<SwModify*>(GetRegisteredIn())->Remove(this);
112     }
113     m_ListenerContainer.Disposing();
114     m_pFmtFtn = 0;
115     m_rThis.SetDoc(0);
116 }
117 
118 /* -----------------18.01.99 09:12-------------------
119  *
120  * --------------------------------------------------*/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)121 void SwXFootnote::Impl::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew)
122 {
123     ClientModify(this, pOld, pNew);
124 
125     if (!GetRegisteredIn()) // removed => dispose
126     {
127         Invalidate();
128     }
129     else if (pOld)
130     {
131         switch (pOld->Which())
132         {
133             case RES_FOOTNOTE_DELETED:
134                 if (static_cast<const void*>(m_pFmtFtn) ==
135                         static_cast<const SwPtrMsgPoolItem *>(pOld)->pObject)
136                 {
137                     Invalidate();
138                 }
139                 break;
140         }
141     }
142 }
143 
144 /*-- 10.12.98 15:31:44---------------------------------------------------
145 
146   -----------------------------------------------------------------------*/
SwXFootnote(const bool bEndnote)147 SwXFootnote::SwXFootnote(const bool bEndnote)
148     : SwXText(0, CURSOR_FOOTNOTE)
149     , m_pImpl( new SwXFootnote::Impl(*this, 0, 0, bEndnote) )
150 {
151 }
152 /*-- 10.12.98 15:31:45---------------------------------------------------
153 
154   -----------------------------------------------------------------------*/
SwXFootnote(SwDoc & rDoc,const SwFmtFtn & rFmt)155 SwXFootnote::SwXFootnote(SwDoc & rDoc, const SwFmtFtn& rFmt)
156     : SwXText(& rDoc, CURSOR_FOOTNOTE)
157     , m_pImpl( new SwXFootnote::Impl(*this, &rDoc, &rFmt, rFmt.IsEndNote()) )
158 {
159 }
160 /*-- 10.12.98 15:31:45---------------------------------------------------
161 
162   -----------------------------------------------------------------------*/
~SwXFootnote()163 SwXFootnote::~SwXFootnote()
164 {
165 }
166 
167 SwXFootnote *
GetXFootnote(SwModify const &,SwFmtFtn const &)168 SwXFootnote::GetXFootnote(
169         SwModify const& /*rUnoCB*/, SwFmtFtn const& /*rFootnoteFmt*/)
170 {
171     // re-use existing SwXFootnote
172     // #i105557#: do not iterate over the registered clients: race condition
173     // to do this properly requires the SwXFootnote to register at the
174     // SwFmtFtn directly, not at the unocallback
175     // also this function must return a uno Reference!
176     return 0;
177 }
178 
179 SwXFootnote *
CreateXFootnote(SwDoc & rDoc,SwFmtFtn const & rFootnoteFmt)180 SwXFootnote::CreateXFootnote(SwDoc & rDoc, SwFmtFtn const& rFootnoteFmt)
181 {
182     SwXFootnote *const pXFootnote(
183         GetXFootnote(*rDoc.GetUnoCallBack(), rFootnoteFmt));
184     return (pXFootnote)
185         ?   pXFootnote
186         :   new SwXFootnote(rDoc, rFootnoteFmt);
187 }
188 
189 /* -----------------------------13.03.00 12:15--------------------------------
190 
191  ---------------------------------------------------------------------------*/
getUnoTunnelId()192 const uno::Sequence< sal_Int8 > & SwXFootnote::getUnoTunnelId()
193 {
194     static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
195     return aSeq;
196 }
197 /* -----------------------------10.03.00 18:04--------------------------------
198 
199  ---------------------------------------------------------------------------*/
200 sal_Int64 SAL_CALL
getSomething(const uno::Sequence<sal_Int8> & rId)201 SwXFootnote::getSomething(const uno::Sequence< sal_Int8 >& rId)
202 {
203     const sal_Int64 nRet( ::sw::UnoTunnelImpl<SwXFootnote>(rId, this) );
204     return (nRet) ? nRet : SwXText::getSomething(rId);
205 }
206 
207 /* -----------------------------06.04.00 16:36--------------------------------
208 
209  ---------------------------------------------------------------------------*/
210 OUString SAL_CALL
getImplementationName()211 SwXFootnote::getImplementationName()
212 {
213     return C2U("SwXFootnote");
214 }
215 
216 /* -----------------------------06.04.00 16:36--------------------------------
217 
218  ---------------------------------------------------------------------------*/
219 static char const*const g_ServicesFootnote[] =
220 {
221     "com.sun.star.text.TextContent",
222     "com.sun.star.text.Footnote",
223     "com.sun.star.text.Text",
224     "com.sun.star.text.Endnote", // NB: only supported for endnotes!
225 };
226 static const size_t g_nServicesEndnote(
227     sizeof(g_ServicesFootnote)/sizeof(g_ServicesFootnote[0]));
228 static const size_t g_nServicesFootnote( g_nServicesEndnote - 1 ); // NB: omit!
229 
supportsService(const OUString & rServiceName)230 sal_Bool SAL_CALL SwXFootnote::supportsService(const OUString& rServiceName)
231 {
232     vos::OGuard g(Application::GetSolarMutex());
233     return ::sw::SupportsServiceImpl(
234             (m_pImpl->m_bIsEndnote) ? g_nServicesEndnote : g_nServicesFootnote,
235             g_ServicesFootnote, rServiceName);
236 }
237 
238 uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames()239 SwXFootnote::getSupportedServiceNames()
240 {
241     vos::OGuard g(Application::GetSolarMutex());
242     return ::sw::GetSupportedServiceNamesImpl(
243             (m_pImpl->m_bIsEndnote) ? g_nServicesEndnote : g_nServicesFootnote,
244             g_ServicesFootnote);
245 }
246 
247 /* -----------------------------21.03.00 15:39--------------------------------
248 
249  ---------------------------------------------------------------------------*/
250 uno::Sequence< uno::Type > SAL_CALL
getTypes()251 SwXFootnote::getTypes()
252 {
253     const uno::Sequence< uno::Type > aTypes = SwXFootnote_Base::getTypes();
254     const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes();
255     return ::comphelper::concatSequences(aTypes, aTextTypes);
256 }
257 
258 /* -----------------------------21.03.00 15:39--------------------------------
259 
260  ---------------------------------------------------------------------------*/
261 uno::Sequence< sal_Int8 > SAL_CALL
getImplementationId()262 SwXFootnote::getImplementationId()
263 {
264     vos::OGuard aGuard(Application::GetSolarMutex());
265     static uno::Sequence< sal_Int8 > aId( 16 );
266     static sal_Bool bInit = sal_False;
267     if(!bInit)
268     {
269         rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
270         bInit = sal_True;
271     }
272     return aId;
273 }
274 /* -----------------------------21.03.00 15:46--------------------------------
275 
276  ---------------------------------------------------------------------------*/
277 uno::Any SAL_CALL
queryInterface(const uno::Type & rType)278 SwXFootnote::queryInterface(const uno::Type& rType)
279 {
280     const uno::Any ret = SwXFootnote_Base::queryInterface(rType);
281     return (ret.getValueType() == ::getCppuVoidType())
282         ?   SwXText::queryInterface(rType)
283         :   ret;
284 }
285 
286 /*-- 10.12.98 15:31:47---------------------------------------------------
287 
288   -----------------------------------------------------------------------*/
getLabel()289 OUString SAL_CALL SwXFootnote::getLabel()
290 {
291     vos::OGuard aGuard(Application::GetSolarMutex());
292 
293     ::rtl::OUString sRet;
294     SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat();
295     if(pFmt)
296     {
297         sRet = pFmt->GetNumStr();
298     }
299     else if (m_pImpl->m_bIsDescriptor)
300     {
301         sRet = m_pImpl->m_sLabel;
302     }
303     else
304     {
305         throw uno::RuntimeException();
306     }
307     return sRet;
308 }
309 
310 /*-- 10.12.98 15:31:48---------------------------------------------------
311 
312   -----------------------------------------------------------------------*/
313 void SAL_CALL
setLabel(const OUString & aLabel)314 SwXFootnote::setLabel(const OUString& aLabel)
315 {
316     vos::OGuard aGuard(Application::GetSolarMutex());
317 
318     SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat();
319     if(pFmt)
320     {
321         const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn();
322         DBG_ASSERT(pTxtFtn, "kein TextNode?");
323         SwTxtNode& rTxtNode = (SwTxtNode&)pTxtFtn->GetTxtNode();
324 
325         SwPaM aPam(rTxtNode, *pTxtFtn->GetStart());
326         GetDoc()->SetCurFtn(aPam, aLabel, pFmt->GetNumber(), pFmt->IsEndNote());
327     }
328     else if (m_pImpl->m_bIsDescriptor)
329     {
330         m_pImpl->m_sLabel = String(aLabel);
331     }
332     else
333     {
334         throw uno::RuntimeException();
335     }
336 }
337 
338 /* -----------------18.02.99 13:32-------------------
339  *
340  * --------------------------------------------------*/
341 void SAL_CALL
attach(const uno::Reference<text::XTextRange> & xTextRange)342 SwXFootnote::attach(const uno::Reference< text::XTextRange > & xTextRange)
343 {
344     vos::OGuard aGuard(Application::GetSolarMutex());
345 
346     if (!m_pImpl->m_bIsDescriptor)
347     {
348         throw uno::RuntimeException();
349     }
350     const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
351             xTextRange, uno::UNO_QUERY);
352     SwXTextRange *const pRange =
353         ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
354     OTextCursorHelper *const pCursor =
355         ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
356     SwDoc *const pNewDoc =
357         (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0);
358     if (!pNewDoc)
359     {
360         throw lang::IllegalArgumentException();
361     }
362 
363     SwUnoInternalPaM aPam(*pNewDoc);
364     //das muss jetzt sal_True liefern
365     ::sw::XTextRangeToSwPaM(aPam, xTextRange);
366 
367     UnoActionContext aCont(pNewDoc);
368     pNewDoc->DeleteAndJoin(aPam);
369     aPam.DeleteMark();
370     SwFmtFtn aFootNote(m_pImpl->m_bIsEndnote);
371     if (m_pImpl->m_sLabel.getLength())
372     {
373         aFootNote.SetNumStr(m_pImpl->m_sLabel);
374     }
375 
376     SwXTextCursor const*const pTextCursor(
377             dynamic_cast<SwXTextCursor*>(pCursor));
378     const bool bForceExpandHints( (pTextCursor)
379             ? pTextCursor->IsAtEndOfMeta() : false );
380     const SetAttrMode nInsertFlags = (bForceExpandHints)
381         ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND
382         : nsSetAttrMode::SETATTR_DEFAULT;
383 
384     pNewDoc->InsertPoolItem(aPam, aFootNote, nInsertFlags);
385 
386     SwTxtFtn *const pTxtAttr = static_cast<SwTxtFtn*>(
387         aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
388                 aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FTN ));
389 
390     if (pTxtAttr)
391     {
392         const SwFmtFtn& rFtn = pTxtAttr->GetFtn();
393         m_pImpl->m_pFmtFtn = &rFtn;
394         pNewDoc->GetUnoCallBack()->Add(m_pImpl.get());
395         // force creation of sequence id - is used for references
396         if (pNewDoc->IsInReading())
397         {
398             pTxtAttr->SetSeqNo(pNewDoc->GetFtnIdxs().Count());
399         }
400         else
401         {
402             pTxtAttr->SetSeqRefNo();
403         }
404     }
405     m_pImpl->m_bIsDescriptor = sal_False;
406     SetDoc(pNewDoc);
407 }
408 
409 /*-- 10.12.98 15:31:48---------------------------------------------------
410 
411   -----------------------------------------------------------------------*/
412 uno::Reference< text::XTextRange > SAL_CALL
getAnchor()413 SwXFootnote::getAnchor()
414 {
415     vos::OGuard aGuard(Application::GetSolarMutex());
416 
417     SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() );
418 
419     SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn();
420     SwPaM aPam( pTxtFtn->GetTxtNode(), *pTxtFtn->GetStart() );
421     SwPosition aMark( *aPam.Start() );
422     aPam.SetMark();
423     aPam.GetMark()->nContent++;
424     const uno::Reference< text::XTextRange > xRet =
425         SwXTextRange::CreateXTextRange(*GetDoc(), *aPam.Start(), aPam.End());
426     return xRet;
427 }
428 /*-- 10.12.98 15:31:49---------------------------------------------------
429 
430   -----------------------------------------------------------------------*/
dispose()431 void SAL_CALL SwXFootnote::dispose()
432 {
433     vos::OGuard aGuard(Application::GetSolarMutex());
434 
435     SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() );
436 
437     SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn();
438     DBG_ASSERT(pTxtFtn, "no TextNode?");
439     SwTxtNode& rTxtNode = const_cast<SwTxtNode&>(pTxtFtn->GetTxtNode());
440     const xub_StrLen nPos = *pTxtFtn->GetStart();
441     SwPaM aPam(rTxtNode, nPos, rTxtNode, nPos+1);
442     GetDoc()->DeleteAndJoin( aPam );
443 }
444 
445 /*-- 10.12.98 15:31:49---------------------------------------------------
446 
447   -----------------------------------------------------------------------*/
448 void SAL_CALL
addEventListener(const uno::Reference<lang::XEventListener> & xListener)449 SwXFootnote::addEventListener(
450     const uno::Reference< lang::XEventListener > & xListener)
451 {
452     vos::OGuard g(Application::GetSolarMutex());
453 
454     if (!m_pImpl->GetFootnoteFormat())
455     {
456         throw uno::RuntimeException();
457     }
458     m_pImpl->m_ListenerContainer.AddListener(xListener);
459 }
460 /*-- 10.12.98 15:31:50---------------------------------------------------
461 
462   -----------------------------------------------------------------------*/
463 void SAL_CALL
removeEventListener(const uno::Reference<lang::XEventListener> & xListener)464 SwXFootnote::removeEventListener(
465     const uno::Reference< lang::XEventListener > & xListener)
466 {
467     vos::OGuard g(Application::GetSolarMutex());
468 
469     if (!m_pImpl->GetFootnoteFormat() ||
470         !m_pImpl->m_ListenerContainer.RemoveListener(xListener))
471     {
472         throw uno::RuntimeException();
473     }
474 }
475 
476 /* -----------------06.05.99 15:31-------------------
477  *
478  * --------------------------------------------------*/
GetStartNode() const479 const SwStartNode *SwXFootnote::GetStartNode() const
480 {
481     SwFmtFtn const*const   pFmt = m_pImpl->GetFootnoteFormat();
482     if(pFmt)
483     {
484         const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn();
485         if( pTxtFtn )
486         {
487             return pTxtFtn->GetStartNode()->GetNode().GetStartNode();
488         }
489     }
490     return 0;
491 }
492 
493 uno::Reference< text::XTextCursor >
CreateCursor()494 SwXFootnote::CreateCursor()
495 {
496     return createTextCursor();
497 }
498 
499 /*-- 10.12.98 15:31:50---------------------------------------------------
500 
501   -----------------------------------------------------------------------*/
502 uno::Reference< text::XTextCursor > SAL_CALL
createTextCursor()503 SwXFootnote::createTextCursor()
504 {
505     vos::OGuard aGuard(Application::GetSolarMutex());
506 
507     SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() );
508 
509     SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn();
510     SwPosition aPos( *pTxtFtn->GetStartNode() );
511     SwXTextCursor *const pXCursor =
512         new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, aPos);
513     SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor();
514     pUnoCrsr->Move(fnMoveForward, fnGoNode);
515     const uno::Reference< text::XTextCursor > xRet =
516         static_cast<text::XWordCursor*>(pXCursor);
517     return xRet;
518 }
519 
520 /*-- 10.12.98 15:31:51---------------------------------------------------
521 
522   -----------------------------------------------------------------------*/
523 uno::Reference< text::XTextCursor > SAL_CALL
createTextCursorByRange(const uno::Reference<text::XTextRange> & xTextPosition)524 SwXFootnote::createTextCursorByRange(
525     const uno::Reference< text::XTextRange > & xTextPosition)
526 {
527     vos::OGuard aGuard(Application::GetSolarMutex());
528 
529     SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() );
530 
531     SwUnoInternalPaM aPam(*GetDoc());
532     if (!::sw::XTextRangeToSwPaM(aPam, xTextPosition))
533     {
534         throw uno::RuntimeException();
535     }
536 
537     SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn();
538     SwNode const*const pFtnStartNode = &pTxtFtn->GetStartNode()->GetNode();
539 
540     const SwNode* pStart = aPam.GetNode()->FindFootnoteStartNode();
541     if (pStart != pFtnStartNode)
542     {
543         throw uno::RuntimeException();
544     }
545 
546     const uno::Reference< text::XTextCursor > xRet =
547         static_cast<text::XWordCursor*>(
548                 new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE,
549                     *aPam.GetPoint(), aPam.GetMark()));
550     return xRet;
551 }
552 
553 /*-- 13.06.00 14:28:23---------------------------------------------------
554 
555   -----------------------------------------------------------------------*/
556 uno::Reference< container::XEnumeration > SAL_CALL
createEnumeration()557 SwXFootnote::createEnumeration()
558 {
559     vos::OGuard aGuard(Application::GetSolarMutex());
560 
561     SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() );
562 
563     SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn();
564     SwPosition aPos( *pTxtFtn->GetStartNode() );
565     ::std::auto_ptr<SwUnoCrsr> pUnoCursor(
566         GetDoc()->CreateUnoCrsr(aPos, sal_False));
567     pUnoCursor->Move(fnMoveForward, fnGoNode);
568     const uno::Reference< container::XEnumeration >  xRet =
569         new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FOOTNOTE);
570     return xRet;
571 }
572 
573 /*-- 13.06.00 14:28:24---------------------------------------------------
574 
575   -----------------------------------------------------------------------*/
getElementType()576 uno::Type SAL_CALL SwXFootnote::getElementType()
577 {
578     return text::XTextRange::static_type();
579 }
580 /*-- 13.06.00 14:28:24---------------------------------------------------
581 
582   -----------------------------------------------------------------------*/
hasElements()583 sal_Bool SAL_CALL SwXFootnote::hasElements()
584 {
585     return sal_True;
586 }
587 
588 /*-- 11.09.00 13:12:03---------------------------------------------------
589 
590   -----------------------------------------------------------------------*/
591 uno::Reference< beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo()592 SwXFootnote::getPropertySetInfo()
593 {
594     vos::OGuard g(Application::GetSolarMutex());
595     static uno::Reference< beans::XPropertySetInfo > xRet =
596         aSwMapProvider.GetPropertySet(PROPERTY_MAP_FOOTNOTE)
597             ->getPropertySetInfo();
598     return xRet;
599 }
600 
601 /*-- 11.09.00 13:12:04---------------------------------------------------
602 
603   -----------------------------------------------------------------------*/
604 void SAL_CALL
setPropertyValue(const::rtl::OUString &,const uno::Any &)605 SwXFootnote::setPropertyValue(const ::rtl::OUString&, const uno::Any&)
606 {
607     //no values to be set
608     throw lang::IllegalArgumentException();
609 }
610 /*-- 11.09.00 13:12:04---------------------------------------------------
611 
612   -----------------------------------------------------------------------*/
613 uno::Any SAL_CALL
getPropertyValue(const OUString & rPropertyName)614 SwXFootnote::getPropertyValue(const OUString& rPropertyName)
615 {
616     vos::OGuard aGuard(Application::GetSolarMutex());
617 
618     uno::Any aRet;
619     if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName))
620     {
621         if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE)) ||
622             rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE)))
623         {
624             //redline can only be returned if it's a living object
625             if (!m_pImpl->m_bIsDescriptor)
626             {
627                 aRet = SwXText::getPropertyValue(rPropertyName);
628             }
629         }
630         else if (rPropertyName.equalsAsciiL(
631                     SW_PROP_NAME(UNO_NAME_REFERENCE_ID)))
632         {
633             SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat();
634             if (pFmt)
635             {
636                 SwTxtFtn const*const pTxtFtn = pFmt->GetTxtFtn();
637                 DBG_ASSERT(pTxtFtn, "no TextNode?");
638                 aRet <<= static_cast<sal_Int16>(pTxtFtn->GetSeqRefNo());
639             }
640         }
641         else
642         {
643             beans::UnknownPropertyException aExcept;
644             aExcept.Message = rPropertyName;
645             throw aExcept;
646         }
647     }
648     return aRet;
649 }
650 
651 /*-- 11.09.00 13:12:04---------------------------------------------------
652 
653   -----------------------------------------------------------------------*/
654 void SAL_CALL
addPropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)655 SwXFootnote::addPropertyChangeListener(
656         const ::rtl::OUString& /*rPropertyName*/,
657         const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
658 {
659     OSL_ENSURE(false,
660         "SwXFootnote::addPropertyChangeListener(): not implemented");
661 }
662 
663 void SAL_CALL
removePropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)664 SwXFootnote::removePropertyChangeListener(
665         const ::rtl::OUString& /*rPropertyName*/,
666         const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
667 {
668     OSL_ENSURE(false,
669         "SwXFootnote::removePropertyChangeListener(): not implemented");
670 }
671 
672 void SAL_CALL
addVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)673 SwXFootnote::addVetoableChangeListener(
674         const ::rtl::OUString& /*rPropertyName*/,
675         const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
676 {
677     OSL_ENSURE(false,
678         "SwXFootnote::addVetoableChangeListener(): not implemented");
679 }
680 
681 void SAL_CALL
removeVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)682 SwXFootnote::removeVetoableChangeListener(
683         const ::rtl::OUString& /*rPropertyName*/,
684         const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
685 {
686     OSL_ENSURE(false,
687         "SwXFootnote::removeVetoableChangeListener(): not implemented");
688 }
689