LCOV - code coverage report
Current view: top level - sw/source/core/tox - ToxLinkProcessor.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 24 25 96.0 %
Date: 2015-06-13 12:38:46 Functions: 6 6 100.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             : 
      10             : #include "ToxLinkProcessor.hxx"
      11             : 
      12             : #include "SwStyleNameMapper.hxx"
      13             : #include "ndtxt.hxx"
      14             : #include <poolfmt.hrc>
      15             : 
      16             : #include <stdexcept>
      17             : 
      18             : namespace sw {
      19             : 
      20             : void
      21           9 : ToxLinkProcessor::StartNewLink(sal_Int32 startPosition, const OUString& characterStyle)
      22             : {
      23           9 :     mStartedLinks.push_back(new StartedLink(startPosition, characterStyle));
      24           9 : }
      25             : 
      26             : void
      27          10 : ToxLinkProcessor::CloseLink(sal_Int32 endPosition, const OUString& url)
      28             : {
      29          10 :     StartedLink const startedLink( (mStartedLinks.empty())
      30             :         ? StartedLink(0, SW_RES(STR_POOLCHR_TOXJUMP))
      31          10 :         : mStartedLinks.back() );
      32          10 :     if (!mStartedLinks.empty())
      33             :     {
      34           9 :         mStartedLinks.pop_back();
      35             :     }
      36             : 
      37          10 :     if (url.isEmpty()) {
      38          10 :         return;
      39             :     }
      40             : 
      41          10 :     ClosedLink* closedLink = new ClosedLink(url, startedLink.mStartPosition, endPosition);
      42             : 
      43          10 :     const OUString& characterStyle = startedLink.mCharacterStyle;
      44          10 :     sal_uInt16 poolId = ObtainPoolId(characterStyle);
      45          10 :     closedLink->mINetFormat.SetVisitedFormatAndId(characterStyle, poolId);
      46          10 :     closedLink->mINetFormat.SetINetFormatAndId(characterStyle, poolId);
      47             : 
      48          10 :     mClosedLinks.push_back(closedLink);
      49             : }
      50             : 
      51             : sal_uInt16
      52           7 : ToxLinkProcessor::ObtainPoolId(const OUString& characterStyle) const
      53             : {
      54           7 :     if (characterStyle.isEmpty()) {
      55           0 :         return USHRT_MAX;
      56             :     }
      57             :     else {
      58           7 :         return SwStyleNameMapper::GetPoolIdFromUIName(characterStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
      59             :     }
      60             : }
      61             : 
      62             : 
      63             : void
      64           4 : ToxLinkProcessor::InsertLinkAttributes(SwTextNode& node)
      65             : {
      66           7 :     for (ClosedLink& clink : mClosedLinks) {
      67           3 :         node.InsertItem(clink.mINetFormat, clink.mStartTextPos, clink.mEndTextPos);
      68             :     }
      69           4 : }
      70             : 
      71         177 : }
      72             : 
      73             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11