LCOV - code coverage report
Current view: top level - sw/source/core/crsr - bookmrk.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 117 206 56.8 %
Date: 2012-08-25 Functions: 28 51 54.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 122 512 23.8 %

           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                 :            : #include <bookmrk.hxx>
      30                 :            : #include <IDocumentMarkAccess.hxx>
      31                 :            : #include <IDocumentUndoRedo.hxx>
      32                 :            : #include <doc.hxx>
      33                 :            : #include <ndtxt.hxx>
      34                 :            : #include <pam.hxx>
      35                 :            : #include <swserv.hxx>
      36                 :            : #include <sfx2/linkmgr.hxx>
      37                 :            : #include <swtypes.hxx>
      38                 :            : #include <UndoBookmark.hxx>
      39                 :            : #include <unobookmark.hxx>
      40                 :            : #include <rtl/random.h>
      41                 :            : #include <xmloff/odffields.hxx>
      42                 :            : 
      43                 :            : 
      44 [ #  # ][ #  # ]:       8402 : SV_IMPL_REF( SwServerObject )
         [ #  # ][ -  + ]
                 [ -  + ]
      45                 :            : 
      46                 :            : using namespace ::sw::mark;
      47                 :            : using namespace ::com::sun::star;
      48                 :            : using namespace ::com::sun::star::uno;
      49                 :            : 
      50                 :            : namespace
      51                 :            : {
      52                 :      39608 :     static void lcl_FixPosition(SwPosition& rPos)
      53                 :            :     {
      54                 :            :         // make sure the position has 1) the proper node, and 2) a proper index
      55                 :      39608 :         SwTxtNode* pTxtNode = rPos.nNode.GetNode().GetTxtNode();
      56 [ -  + ][ -  + ]:      39608 :         if(pTxtNode == NULL && rPos.nContent.GetIndex() > 0)
                 [ +  + ]
      57                 :            :         {
      58                 :            :             OSL_TRACE(
      59                 :            :                 "bookmrk.cxx::lcl_FixPosition"
      60                 :            :                 " - illegal position: %d without proper TxtNode", rPos.nContent.GetIndex());
      61                 :          0 :             rPos.nContent.Assign(NULL, 0);
      62                 :            :         }
      63 [ +  + ][ -  + ]:      39608 :         else if(pTxtNode != NULL && rPos.nContent.GetIndex() > pTxtNode->Len())
                 [ -  + ]
      64                 :            :         {
      65                 :            :             OSL_TRACE(
      66                 :            :                 "bookmrk.cxx::lcl_FixPosition"
      67                 :            :                 " - illegal position: %d is beyond %d", rPos.nContent.GetIndex(), pTxtNode->Len());
      68         [ #  # ]:          0 :             rPos.nContent.Assign(pTxtNode, pTxtNode->Len());
      69                 :            :         }
      70                 :      39608 :     }
      71                 :            : 
      72                 :         21 :     static void lcl_AssureFieldMarksSet(Fieldmark* const pField,
      73                 :            :         SwDoc* const io_pDoc,
      74                 :            :         const sal_Unicode aStartMark,
      75                 :            :         const sal_Unicode aEndMark)
      76                 :            :     {
      77         [ +  - ]:         21 :         SwPosition& rStart = pField->GetMarkStart();
      78         [ +  - ]:         21 :         SwPosition& rEnd = pField->GetMarkEnd();
      79                 :            :         SwTxtNode const*const pStartTxtNode =
      80                 :         21 :             rStart.nNode.GetNode().GetTxtNode();
      81                 :         21 :         SwTxtNode const*const pEndTxtNode = rEnd.nNode.GetNode().GetTxtNode();
      82                 :         21 :         const sal_Unicode ch_start=pStartTxtNode->GetTxt().GetChar(rStart.nContent.GetIndex());
      83         [ +  - ]:         39 :         xub_StrLen nEndPos = ( rEnd == rStart ||  rEnd.nContent.GetIndex() == 0 ) ?
      84   [ +  +  -  + ]:         39 :             rEnd.nContent.GetIndex() : rEnd.nContent.GetIndex() - 1;
      85                 :         21 :         const sal_Unicode ch_end=pEndTxtNode->GetTxt().GetChar( nEndPos );
      86         [ +  - ]:         21 :         SwPaM aStartPaM(rStart);
      87         [ +  - ]:         21 :         SwPaM aEndPaM(rEnd);
      88 [ +  - ][ +  - ]:         21 :         io_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_UI_REPLACE, NULL);
      89 [ +  - ][ +  + ]:         21 :         if( ( ch_start != aStartMark ) && ( aEndMark != CH_TXT_ATR_FORMELEMENT ) )
      90                 :            :         {
      91 [ +  - ][ +  - ]:         18 :             io_pDoc->InsertString(aStartPaM, rtl::OUString(aStartMark));
                 [ +  - ]
      92         [ +  - ]:         18 :             rStart.nContent--;
      93                 :            :         }
      94 [ +  - ][ +  - ]:         21 :         if ( aEndMark && ( ch_end != aEndMark ) )
      95                 :            :         {
      96 [ +  - ][ +  - ]:         21 :             io_pDoc->InsertString(aEndPaM, rtl::OUString(aEndMark));
                 [ +  - ]
      97         [ +  - ]:         21 :             rEnd.nContent++;
      98                 :            :         }
      99 [ +  - ][ +  - ]:         21 :         io_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_UI_REPLACE, NULL);
         [ +  - ][ +  - ]
     100                 :         21 :     };
     101                 :            : 
     102                 :          0 :     static void lcl_RemoveFieldMarks(Fieldmark* const pField,
     103                 :            :         SwDoc* const io_pDoc,
     104                 :            :         const sal_Unicode aStartMark,
     105                 :            :         const sal_Unicode aEndMark)
     106                 :            :     {
     107         [ #  # ]:          0 :         SwPosition& rStart = pField->GetMarkStart();
     108         [ #  # ]:          0 :         SwPosition& rEnd = pField->GetMarkEnd();
     109                 :            :         SwTxtNode const*const pStartTxtNode =
     110                 :          0 :             rStart.nNode.GetNode().GetTxtNode();
     111                 :          0 :         SwTxtNode const*const pEndTxtNode = rEnd.nNode.GetNode().GetTxtNode();
     112                 :          0 :         const sal_Unicode ch_start=pStartTxtNode->GetTxt().GetChar(rStart.nContent.GetIndex());
     113         [ #  # ]:          0 :         xub_StrLen nEndPos = ( rEnd == rStart ||  rEnd.nContent.GetIndex() == 0 ) ?
     114   [ #  #  #  # ]:          0 :             rEnd.nContent.GetIndex() : rEnd.nContent.GetIndex() - 1;
     115                 :          0 :         const sal_Unicode ch_end=pEndTxtNode->GetTxt().GetChar( nEndPos );
     116         [ #  # ]:          0 :         SwPaM aStartPaM(rStart);
     117         [ #  # ]:          0 :         SwPaM aEndPaM(rEnd);
     118 [ #  # ][ #  # ]:          0 :         io_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_UI_REPLACE, NULL);
     119         [ #  # ]:          0 :         if( ch_start == aStartMark )
     120                 :            :         {
     121         [ #  # ]:          0 :             SwPaM aStart(rStart, rStart);
     122 [ #  # ][ #  # ]:          0 :             aStart.End()->nContent++;
     123 [ #  # ][ #  # ]:          0 :             io_pDoc->DeleteRange(aStart);
     124                 :            :         }
     125         [ #  # ]:          0 :         if ( ch_end == aEndMark )
     126                 :            :         {
     127         [ #  # ]:          0 :             SwPaM aEnd(rEnd, rEnd);
     128 [ #  # ][ #  # ]:          0 :             aEnd.Start()->nContent--;
     129 [ #  # ][ #  # ]:          0 :             io_pDoc->DeleteRange(aEnd);
     130                 :            :         }
     131 [ #  # ][ #  # ]:          0 :         io_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_UI_REPLACE, NULL);
         [ #  # ][ #  # ]
     132                 :          0 :     };
     133                 :            : }
     134                 :            : 
     135                 :            : namespace sw { namespace mark
     136                 :            : {
     137                 :      24357 :     MarkBase::MarkBase(const SwPaM& aPaM,
     138                 :            :         const ::rtl::OUString& rName)
     139                 :            :         : SwModify(0)
     140 [ #  # ][ +  - ]:      24357 :         , m_pPos1(new SwPosition(*(aPaM.GetPoint())))
     141 [ #  # ][ #  # ]:      48714 :         , m_aName(rName)
         [ #  # ][ +  - ]
                 [ +  - ]
     142                 :            :     {
     143 [ #  # ][ +  - ]:      24357 :         lcl_FixPosition(*m_pPos1);
     144 [ #  # ][ #  # ]:      24357 :         if (aPaM.HasMark() && (*aPaM.GetMark() != *aPaM.GetPoint()))
         [ #  # ][ #  # ]
         [ +  + ][ +  - ]
         [ +  + ][ +  + ]
     145                 :            :         {
     146 [ #  # ][ +  - ]:      15251 :             MarkBase::SetOtherMarkPos(*(aPaM.GetMark()));
     147 [ #  # ][ +  - ]:      15251 :             lcl_FixPosition(*m_pPos2);
     148                 :            :         }
     149                 :      24357 :     }
     150                 :            : 
     151                 :            :     // For fieldmarks, the CH_TXT_ATR_FIELDSTART and CH_TXT_ATR_FIELDEND
     152                 :            :     // themselves are part of the covered range. This is guaranteed by
     153                 :            :     // TextFieldmark::InitDoc/lcl_AssureFieldMarksSet.
     154                 :        195 :     bool MarkBase::IsCoveringPosition(const SwPosition& rPos) const
     155                 :            :     {
     156 [ +  + ][ +  + ]:        195 :         return GetMarkStart() <= rPos && rPos < GetMarkEnd();
     157                 :            :     }
     158                 :            : 
     159                 :       1614 :     void MarkBase::SetMarkPos(const SwPosition& rNewPos)
     160                 :            :     {
     161         [ +  - ]:       1614 :         ::boost::scoped_ptr<SwPosition>(new SwPosition(rNewPos)).swap(m_pPos1);
     162                 :       1614 :     }
     163                 :            : 
     164                 :      16854 :     void MarkBase::SetOtherMarkPos(const SwPosition& rNewPos)
     165                 :            :     {
     166         [ +  - ]:      16854 :         ::boost::scoped_ptr<SwPosition>(new SwPosition(rNewPos)).swap(m_pPos2);
     167                 :      16854 :     }
     168                 :            : 
     169                 :          0 :     rtl::OUString MarkBase::ToString( ) const
     170                 :            :     {
     171                 :          0 :         rtl::OUStringBuffer buf;
     172         [ #  # ]:          0 :         buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("Mark: ( Name, [ Node1, Index1 ] ): ( "));
     173 [ #  # ][ #  # ]:          0 :         buf.append( m_aName ).appendAscii(RTL_CONSTASCII_STRINGPARAM(", [ "));
     174 [ #  # ][ #  # ]:          0 :         buf.append( sal_Int32( GetMarkPos().nNode.GetIndex( ) ) )
     175         [ #  # ]:          0 :             .appendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
     176 [ #  # ][ #  # ]:          0 :         buf.append( sal_Int32( GetMarkPos().nContent.GetIndex( ) ) )
     177         [ #  # ]:          0 :             .appendAscii(RTL_CONSTASCII_STRINGPARAM(" ] )") );
     178                 :            : 
     179         [ #  # ]:          0 :         return buf.makeStringAndClear( );
     180                 :            :     }
     181                 :            : 
     182 [ #  # ][ #  # ]:      24348 :     MarkBase::~MarkBase()
         [ #  # ][ #  # ]
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
     183 [ #  # ][ #  # ]:      24348 :     { }
                 [ #  # ]
           [ #  #  #  # ]
         [ -  + ][ -  + ]
                 [ -  + ]
           [ #  #  #  # ]
     184                 :            : 
     185                 :      24357 :     ::rtl::OUString MarkBase::GenerateNewName(const ::rtl::OUString& rPrefix)
     186                 :            :     {
     187 [ +  + ][ +  - ]:      24357 :         static rtlRandomPool aPool = rtl_random_createPool();
     188 [ +  + ][ +  - ]:      24357 :         static ::rtl::OUString sUniquePostfix;
     189                 :            :         static sal_Int32 nCount = SAL_MAX_INT32;
     190         [ +  - ]:      24357 :         ::rtl::OUStringBuffer aResult(rPrefix);
     191         [ +  + ]:      24357 :         if(nCount == SAL_MAX_INT32)
     192                 :            :         {
     193                 :            :             sal_Int32 nRandom;
     194                 :         45 :             ::rtl::OUStringBuffer sUniquePostfixBuffer;
     195                 :         45 :             rtl_random_getBytes(aPool, &nRandom, sizeof(nRandom));
     196 [ +  - ][ +  - ]:         45 :             sUniquePostfix = ::rtl::OUStringBuffer(13).append('_').append(static_cast<sal_Int32>(abs(nRandom))).makeStringAndClear();
                 [ +  - ]
     197                 :         45 :             nCount = 0;
     198                 :            :         }
     199                 :            :         // putting the counter in front of the random parts will speed up string comparisons
     200 [ +  - ][ +  - ]:      24357 :         return aResult.append(nCount++).append(sUniquePostfix).makeStringAndClear();
                 [ +  - ]
     201                 :            :     }
     202                 :            : 
     203                 :            : 
     204                 :          0 :     void MarkBase::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew )
     205                 :            :     {
     206                 :          0 :         NotifyClients(pOld, pNew);
     207 [ #  # ][ #  # ]:          0 :         if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
                 [ #  # ]
     208                 :            :         {   // invalidate cached uno object
     209         [ #  # ]:          0 :             SetXBookmark(uno::Reference<text::XTextContent>(0));
     210                 :            :         }
     211                 :          0 :     }
     212                 :            : 
     213                 :            :     // TODO: everything else uses MarkBase::GenerateNewName ?
     214                 :          0 :     NavigatorReminder::NavigatorReminder(const SwPaM& rPaM)
     215 [ #  # ][ #  # ]:          0 :         : MarkBase(rPaM, rtl::OUString("__NavigatorReminder__"))
                 [ #  # ]
     216                 :          0 :     { }
     217                 :            : 
     218                 :      20318 :     UnoMark::UnoMark(const SwPaM& aPaM)
     219 [ +  - ][ +  - ]:      20318 :         : MarkBase(aPaM, MarkBase::GenerateNewName(rtl::OUString("__UnoMark__")))
         [ +  - ][ #  # ]
                 [ #  # ]
     220                 :      20318 :     { }
     221                 :            : 
     222                 :       4018 :     DdeBookmark::DdeBookmark(const SwPaM& aPaM)
     223                 :            :         : MarkBase(aPaM, MarkBase::GenerateNewName(rtl::OUString("__DdeLink__")))
     224 [ #  # ][ #  # ]:       4018 :         , m_aRefObj(NULL)
         [ #  # ][ +  - ]
                 [ +  - ]
     225                 :       4018 :     { }
     226                 :            : 
     227                 :          0 :     void DdeBookmark::SetRefObject(SwServerObject* pObj)
     228                 :            :     {
     229                 :          0 :         m_aRefObj = pObj;
     230                 :          0 :     }
     231                 :            : 
     232                 :        119 :     void DdeBookmark::DeregisterFromDoc(SwDoc* const pDoc)
     233                 :            :     {
     234         [ -  + ]:        119 :         if(m_aRefObj.Is())
     235                 :          0 :             pDoc->GetLinkManager().RemoveServer(m_aRefObj);
     236                 :        119 :     }
     237                 :            : 
     238 [ #  # ][ #  # ]:       4012 :     DdeBookmark::~DdeBookmark()
         [ #  # ][ +  - ]
         [ +  - ][ #  # ]
     239                 :            :     {
     240 [ #  # ][ -  + ]:       4012 :         if( m_aRefObj.Is() )
     241                 :            :         {
     242 [ #  # ][ #  # ]:          0 :             if(m_aRefObj->HasDataLinks())
         [ #  # ][ #  # ]
     243                 :            :             {
     244                 :          0 :                 ::sfx2::SvLinkSource* p = &m_aRefObj;
     245   [ #  #  #  # ]:          0 :                 p->SendDataChanged();
     246                 :            :             }
     247 [ #  # ][ #  # ]:          0 :             m_aRefObj->SetNoServer();
     248                 :            :         }
     249 [ #  # ][ #  # ]:       4012 :     }
                 [ #  # ]
           [ #  #  #  # ]
         [ -  + ][ -  + ]
                 [ -  + ]
           [ #  #  #  # ]
     250                 :            : 
     251                 :       4018 :     Bookmark::Bookmark(const SwPaM& aPaM,
     252                 :            :         const KeyCode& rCode,
     253                 :            :         const ::rtl::OUString& rName,
     254                 :            :         const ::rtl::OUString& rShortName)
     255                 :            :         : DdeBookmark(aPaM)
     256                 :            :         , ::sfx2::Metadatable()
     257                 :            :         , m_aCode(rCode)
     258 [ +  - ][ +  - ]:       4018 :         , m_sShortName(rShortName)
         [ +  - ][ +  - ]
     259                 :            :     {
     260                 :       4018 :         m_aName = rName;
     261                 :       4018 :     }
     262                 :            : 
     263                 :       4018 :     void Bookmark::InitDoc(SwDoc* const io_pDoc)
     264                 :            :     {
     265         [ +  + ]:       4018 :         if (io_pDoc->GetIDocumentUndoRedo().DoesUndo())
     266                 :            :         {
     267                 :       2068 :             io_pDoc->GetIDocumentUndoRedo().AppendUndo(
     268         [ +  - ]:       2068 :                     new SwUndoInsBookmark(*this));
     269                 :            :         }
     270                 :       4018 :         io_pDoc->SetModified();
     271                 :       4018 :     }
     272                 :            : 
     273                 :         28 :     ::sfx2::IXmlIdRegistry& Bookmark::GetRegistry()
     274                 :            :     {
     275                 :         28 :         SwDoc *const pDoc( GetMarkPos().GetDoc() );
     276                 :            :         OSL_ENSURE(pDoc, "Bookmark::MakeUnoObject: no doc?");
     277                 :         28 :         return pDoc->GetXmlIdRegistry();
     278                 :            :     }
     279                 :            : 
     280                 :       2606 :     bool Bookmark::IsInClipboard() const
     281                 :            :     {
     282                 :       2606 :         SwDoc *const pDoc( GetMarkPos().GetDoc() );
     283                 :            :         OSL_ENSURE(pDoc, "Bookmark::IsInClipboard: no doc?");
     284                 :       2606 :         return pDoc->IsClipBoard();
     285                 :            :     }
     286                 :            : 
     287                 :       2606 :     bool Bookmark::IsInUndo() const
     288                 :            :     {
     289                 :       2606 :         return false;
     290                 :            :     }
     291                 :            : 
     292                 :         32 :     bool Bookmark::IsInContent() const
     293                 :            :     {
     294                 :         32 :         SwDoc *const pDoc( GetMarkPos().GetDoc() );
     295                 :            :         OSL_ENSURE(pDoc, "Bookmark::IsInContent: no doc?");
     296         [ +  - ]:         32 :         return !pDoc->IsInHeaderFooter( SwNodeIndex(GetMarkPos().nNode) );
     297                 :            :     }
     298                 :            : 
     299                 :          0 :     uno::Reference< rdf::XMetadatable > Bookmark::MakeUnoObject()
     300                 :            :     {
     301                 :          0 :         SwDoc *const pDoc( GetMarkPos().GetDoc() );
     302                 :            :         OSL_ENSURE(pDoc, "Bookmark::MakeUnoObject: no doc?");
     303                 :            :         const uno::Reference< rdf::XMetadatable> xMeta(
     304         [ #  # ]:          0 :                 SwXBookmark::CreateXBookmark(*pDoc, *this), uno::UNO_QUERY);
     305                 :          0 :         return xMeta;
     306                 :            :     }
     307                 :            : 
     308                 :         21 :     Fieldmark::Fieldmark(const SwPaM& rPaM)
     309 [ #  # ][ #  # ]:         21 :         : MarkBase(rPaM, MarkBase::GenerateNewName(rtl::OUString("__Fieldmark__")))
         [ #  # ][ #  # ]
         [ #  # ][ +  - ]
         [ +  - ][ +  - ]
     310                 :            :     {
     311 [ #  # ][ #  # ]:         21 :         if(!IsExpanded())
         [ +  - ][ +  + ]
     312 [ #  # ][ #  # ]:          3 :             SetOtherMarkPos(GetMarkPos());
         [ +  - ][ +  - ]
     313                 :         21 :     }
     314                 :            : 
     315                 :          0 :     rtl::OUString Fieldmark::ToString( ) const
     316                 :            :     {
     317                 :          0 :         rtl::OUStringBuffer buf;
     318                 :            :         buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(
     319         [ #  # ]:          0 :             "Fieldmark: ( Name, Type, [ Nd1, Id1 ], [ Nd2, Id2 ] ): ( "));
     320 [ #  # ][ #  # ]:          0 :         buf.append( m_aName ).appendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
     321 [ #  # ][ #  # ]:          0 :         buf.append( m_aFieldname ).appendAscii(RTL_CONSTASCII_STRINGPARAM(", [ "));
     322 [ #  # ][ #  # ]:          0 :         buf.append( sal_Int32( GetMarkPos().nNode.GetIndex( ) ) )
     323         [ #  # ]:          0 :             .appendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
     324 [ #  # ][ #  # ]:          0 :         buf.append( sal_Int32( GetMarkPos( ).nContent.GetIndex( ) ) )
     325         [ #  # ]:          0 :             .appendAscii(RTL_CONSTASCII_STRINGPARAM(" ], ["));
     326 [ #  # ][ #  # ]:          0 :         buf.append( sal_Int32( GetOtherMarkPos().nNode.GetIndex( ) ) )
     327         [ #  # ]:          0 :             .appendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
     328 [ #  # ][ #  # ]:          0 :         buf.append( sal_Int32( GetOtherMarkPos( ).nContent.GetIndex( ) ) )
     329         [ #  # ]:          0 :             .appendAscii(RTL_CONSTASCII_STRINGPARAM(" ] ) "));
     330                 :            : 
     331         [ #  # ]:          0 :         return buf.makeStringAndClear( );
     332                 :            :     }
     333                 :            : 
     334                 :          0 :     void Fieldmark::Invalidate( )
     335                 :            :     {
     336                 :            :         // TODO: Does exist a better solution to trigger a format of the
     337                 :            :         //       fieldmark portion? If yes, please use it.
     338 [ #  # ][ #  # ]:          0 :         SwPaM aPaM( this->GetMarkPos(), this->GetOtherMarkPos() );
                 [ #  # ]
     339 [ #  # ][ #  # ]:          0 :         aPaM.InvalidatePaM();
     340                 :          0 :     }
     341                 :            : 
     342                 :         18 :     TextFieldmark::TextFieldmark(const SwPaM& rPaM)
     343 [ +  - ][ +  - ]:         18 :         : Fieldmark(rPaM)
         [ +  - ][ #  # ]
     344                 :         18 :     { }
     345                 :            : 
     346                 :         18 :     void TextFieldmark::InitDoc(SwDoc* const io_pDoc)
     347                 :            :     {
     348                 :         18 :         lcl_AssureFieldMarksSet(this, io_pDoc, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND);
     349                 :         18 :     }
     350                 :            : 
     351                 :          0 :     void TextFieldmark::ReleaseDoc(SwDoc* const pDoc)
     352                 :            :     {
     353                 :          0 :         lcl_RemoveFieldMarks(this, pDoc, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND);
     354                 :          0 :     }
     355                 :            : 
     356                 :          3 :     CheckboxFieldmark::CheckboxFieldmark(const SwPaM& rPaM)
     357 [ +  - ][ +  - ]:          3 :         : Fieldmark(rPaM)
         [ +  - ][ +  - ]
                 [ #  # ]
     358                 :          3 :     { }
     359                 :            : 
     360                 :          3 :     void CheckboxFieldmark::InitDoc(SwDoc* const io_pDoc)
     361                 :            :     {
     362                 :          3 :         lcl_AssureFieldMarksSet(this, io_pDoc, CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FORMELEMENT);
     363                 :            : 
     364                 :            :         // For some reason the end mark is moved from 1 by the Insert: we don't
     365                 :            :         // want this for checkboxes
     366                 :          3 :         this->GetMarkEnd( ).nContent--;
     367                 :          3 :     }
     368                 :          3 :     void CheckboxFieldmark::SetChecked(bool checked)
     369                 :            :     {
     370         [ +  - ]:          3 :         if ( IsChecked() != checked )
     371                 :            :         {
     372 [ +  - ][ +  - ]:          3 :             (*GetParameters())[::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_FORMCHECKBOX_RESULT))] = makeAny(checked);
                 [ +  - ]
     373                 :            :             // mark document as modified
     374                 :          3 :             SwDoc *const pDoc( GetMarkPos().GetDoc() );
     375         [ +  - ]:          3 :             if ( pDoc )
     376                 :          3 :                 pDoc->SetModified();
     377                 :            :         }
     378                 :          3 :     }
     379                 :            : 
     380                 :          3 :     bool CheckboxFieldmark::IsChecked() const
     381                 :            :     {
     382                 :          3 :         bool bResult = false;
     383 [ +  - ][ +  - ]:          3 :         parameter_map_t::const_iterator pResult = GetParameters()->find(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ODF_FORMCHECKBOX_RESULT)));
                 [ +  - ]
     384 [ -  + ][ +  - ]:          3 :         if(pResult != GetParameters()->end())
     385                 :          0 :             pResult->second >>= bResult;
     386                 :          3 :         return bResult;
     387                 :            :     }
     388                 :            : 
     389                 :          0 :     rtl::OUString CheckboxFieldmark::toString( ) const
     390                 :            :     {
     391                 :          0 :         rtl::OUStringBuffer buf;
     392                 :            :         buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(
     393         [ #  # ]:          0 :             "CheckboxFieldmark: ( Name, Type, [ Nd1, Id1 ], [ Nd2, Id2 ] ): ( "));
     394 [ #  # ][ #  # ]:          0 :         buf.append( m_aName ).appendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
     395 [ #  # ][ #  # ]:          0 :         buf.append( GetFieldname() ).appendAscii(RTL_CONSTASCII_STRINGPARAM(", [ "));
                 [ #  # ]
     396 [ #  # ][ #  # ]:          0 :         buf.append( sal_Int32( GetMarkPos().nNode.GetIndex( ) ) )
     397         [ #  # ]:          0 :             .appendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
     398 [ #  # ][ #  # ]:          0 :         buf.append( sal_Int32( GetMarkPos( ).nContent.GetIndex( ) ) )
     399         [ #  # ]:          0 :             .appendAscii(RTL_CONSTASCII_STRINGPARAM(" ], ["));
     400 [ #  # ][ #  # ]:          0 :         buf.append( sal_Int32( GetOtherMarkPos().nNode.GetIndex( ) ) )
     401         [ #  # ]:          0 :             .appendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
     402 [ #  # ][ #  # ]:          0 :         buf.append( sal_Int32( GetOtherMarkPos( ).nContent.GetIndex( ) ) )
     403         [ #  # ]:          0 :             .appendAscii(RTL_CONSTASCII_STRINGPARAM(" ] ) "));
     404                 :            : 
     405         [ #  # ]:          0 :         return buf.makeStringAndClear( );
     406                 :            :     }
     407                 :            : }}
     408                 :            : 
     409                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10