LCOV - code coverage report
Current view: top level - sw/source/core/crsr - crossrefbookmark.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 19 21 90.5 %
Date: 2015-06-13 12:38:46 Functions: 8 12 66.7 %
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 <sal/config.h>
      21             : 
      22             : #include <cstdlib>
      23             : 
      24             : #include <IDocumentMarkAccess.hxx>
      25             : #include <crossrefbookmark.hxx>
      26             : #include <ndtxt.hxx>
      27             : 
      28             : namespace
      29             : {
      30             :     const char CrossRefNumItemBookmark_NamePrefix[] = "__RefNumPara__";
      31             : }
      32             : 
      33             : namespace sw { namespace mark
      34             : {
      35          94 :     CrossRefBookmark::CrossRefBookmark(const SwPaM& rPaM,
      36             :         const vcl::KeyCode& rCode,
      37             :         const OUString& rName,
      38             :         const OUString& rShortName,
      39             :         const OUString& rPrefix)
      40             :         : Bookmark(
      41             :                 // ensure that m_pPos2 is null by only passing start to super
      42          94 :                 SwPaM(*rPaM.Start()), rCode, rName, rShortName)
      43             :     {
      44             :         assert( IDocumentMarkAccess::IsLegalPaMForCrossRefHeadingBookmark(rPaM)
      45             :                  && "<CrossRefBookmark::CrossRefBookmark(..)>"
      46             :                     "- creation of cross-reference bookmark with an illegal PaM that does not expand over exactly one whole paragraph.");
      47          94 :         if(rName.isEmpty())
      48           2 :             m_aName = MarkBase::GenerateNewName(rPrefix);
      49             :         assert(!m_pPos2);
      50          94 :     }
      51             : 
      52           1 :     void CrossRefBookmark::SetMarkPos(const SwPosition& rNewPos)
      53             :     {
      54             :         assert(rNewPos.nNode.GetNode().GetTextNode() &&
      55             :             "<sw::mark::CrossRefBookmark::SetMarkPos(..)>"
      56             :             " - new bookmark position for cross-reference bookmark doesn't mark text node");
      57             :         assert(rNewPos.nContent.GetIndex() == 0 &&
      58             :             "<sw::mark::CrossRefBookmark::SetMarkPos(..)>"
      59             :             " - new bookmark position for cross-reference bookmark doesn't mark start of text node");
      60           1 :         MarkBase::SetMarkPos(rNewPos);
      61           1 :     }
      62             : 
      63           0 :     SwPosition& CrossRefBookmark::GetOtherMarkPos() const
      64             :     {
      65             :         assert(false &&
      66             :             "<sw::mark::CrossRefBookmark::GetOtherMarkPos(..)>"
      67             :             " - this should never be called!");
      68           0 :         for (;;) { std::abort(); } // avoid "must return a value" warnings
      69             :     }
      70             : 
      71          85 :     CrossRefHeadingBookmark::CrossRefHeadingBookmark(const SwPaM& rPaM,
      72             :         const vcl::KeyCode& rCode,
      73             :         const OUString& rName,
      74             :         const OUString& rShortName)
      75          85 :         : CrossRefBookmark(rPaM, rCode, rName, rShortName, IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()+"_Toc")
      76          85 :     { }
      77             : 
      78        4773 :     bool CrossRefHeadingBookmark::IsLegalName(const OUString& rName)
      79             :     {
      80        4773 :         return rName.match(IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix());
      81             :     }
      82             : 
      83           9 :     CrossRefNumItemBookmark::CrossRefNumItemBookmark(const SwPaM& rPaM,
      84             :         const vcl::KeyCode& rCode,
      85             :         const OUString& rName,
      86             :         const OUString& rShortName)
      87           9 :         : CrossRefBookmark(rPaM, rCode, rName, rShortName, IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix())
      88           9 :     { }
      89             : 
      90        4782 :     bool CrossRefNumItemBookmark::IsLegalName(const OUString& rName)
      91             :     {
      92        4782 :         return rName.match(CrossRefNumItemBookmark_NamePrefix);
      93             :     }
      94         177 : }}
      95             : 
      96             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11