LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unoftn.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 198 232 85.3 %
Date: 2012-08-25 Functions: 34 42 81.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 205 424 48.3 %

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

Generated by: LCOV version 1.10