LCOV - code coverage report
Current view: top level - sw/source/core/crsr - crossrefbookmark.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 19 21 90.5 %
Date: 2014-04-11 Functions: 6 10 60.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <IDocumentMarkAccess.hxx>
      21             : #include <crossrefbookmark.hxx>
      22             : #include <ndtxt.hxx>
      23             : 
      24             : namespace
      25             : {
      26             :     const char CrossRefNumItemBookmark_NamePrefix[] = "__RefNumPara__";
      27             : }
      28             : 
      29             : namespace sw { namespace mark
      30             : {
      31          11 :     CrossRefBookmark::CrossRefBookmark(const SwPaM& rPaM,
      32             :         const KeyCode& rCode,
      33             :         const OUString& rName,
      34             :         const OUString& rShortName,
      35             :         const OUString& rPrefix)
      36          11 :         : Bookmark(rPaM, rCode, rName, rShortName)
      37             :     {
      38             :         OSL_ENSURE( IDocumentMarkAccess::IsLegalPaMForCrossRefHeadingBookmark( rPaM ),
      39             :                     "<CrossRefBookmark::CrossRefBookmark(..)>"
      40             :                     "- creation of cross-reference bookmark with an illegal PaM that does not expand over exactly one whole paragraph.");
      41          11 :         SetMarkPos(*rPaM.Start());
      42          11 :         if(rName.isEmpty())
      43           2 :             m_aName = MarkBase::GenerateNewName(rPrefix);
      44          11 :     }
      45             : 
      46          12 :     void CrossRefBookmark::SetMarkPos(const SwPosition& rNewPos)
      47             :     {
      48             :         OSL_PRECOND(rNewPos.nNode.GetNode().GetTxtNode(),
      49             :             "<sw::mark::CrossRefBookmark::SetMarkPos(..)>"
      50             :             " - new bookmark position for cross-reference bookmark doesn't mark text node");
      51             :         OSL_PRECOND(rNewPos.nContent.GetIndex() == 0,
      52             :             "<sw::mark::CrossRefBookmark::SetMarkPos(..)>"
      53             :             " - new bookmark position for cross-reference bookmark doesn't mark start of text node");
      54          12 :         MarkBase::SetMarkPos(rNewPos);
      55          12 :     }
      56             : 
      57           0 :     SwPosition& CrossRefBookmark::GetOtherMarkPos() const
      58             :     {
      59             :         OSL_PRECOND(false,
      60             :             "<sw::mark::CrossRefBookmark::GetOtherMarkPos(..)>"
      61             :             " - this should never be called!");
      62           0 :         return *static_cast<SwPosition*>(NULL);
      63             :     }
      64             : 
      65           2 :     CrossRefHeadingBookmark::CrossRefHeadingBookmark(const SwPaM& rPaM,
      66             :         const KeyCode& rCode,
      67             :         const OUString& rName,
      68             :         const OUString& rShortName)
      69           2 :         : CrossRefBookmark(rPaM, rCode, rName, rShortName, IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix())
      70           2 :     { }
      71             : 
      72        3492 :     bool CrossRefHeadingBookmark::IsLegalName(const OUString& rName)
      73             :     {
      74        3492 :         return rName.match(IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix());
      75             :     }
      76             : 
      77           9 :     CrossRefNumItemBookmark::CrossRefNumItemBookmark(const SwPaM& rPaM,
      78             :         const KeyCode& rCode,
      79             :         const OUString& rName,
      80             :         const OUString& rShortName)
      81           9 :         : CrossRefBookmark(rPaM, rCode, rName, rShortName, IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix())
      82           9 :     { }
      83             : 
      84        3501 :     bool CrossRefNumItemBookmark::IsLegalName(const OUString& rName)
      85             :     {
      86        3501 :         return rName.match(CrossRefNumItemBookmark_NamePrefix);
      87             :     }
      88             : }}
      89             : 
      90             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10