LCOV - code coverage report
Current view: top level - sw/inc - ToxLinkProcessor.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 10 10 100.0 %
Date: 2015-06-13 12:38:46 Functions: 8 8 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             : #ifndef SW_TOXLINKPROCESSOR_HXX_
      11             : #define SW_TOXLINKPROCESSOR_HXX_
      12             : 
      13             : #include "fmtinfmt.hxx"
      14             : #include "rtl/ustring.hxx"
      15             : 
      16             : #include <boost/ptr_container/ptr_vector.hpp>
      17             : 
      18             : class SwTextNode;
      19             : 
      20             : class ToxLinkProcessorTest;
      21             : 
      22             : namespace sw {
      23             : 
      24             : /** A helper class for ToxTextGenerator.
      25             :  * It collects information about encountered link tokens and allows access in a processed form.
      26             :  */
      27             : class ToxLinkProcessor {
      28             : public:
      29          10 :     ToxLinkProcessor() {}
      30          16 :     virtual ~ToxLinkProcessor() {}
      31             : 
      32             :     void
      33             :     StartNewLink(sal_Int32 startPosition, const OUString& characterStyle);
      34             : 
      35             :     /** Close a link which has been found during processing.
      36             :      *
      37             :      * @throw std::runtime_error If there are no open links.
      38             :      */
      39             :     void
      40             :     CloseLink(sal_Int32 endPosition, const OUString& url);
      41             : 
      42             :     /** Insert the found links as attributes to a text node */
      43             :     void
      44             :     InsertLinkAttributes(SwTextNode& node);
      45             : 
      46             : private:
      47             :     /** Obtain the pool id which belongs to a character style.
      48             :      *
      49             :      * @internal
      50             :      * This method is overridden in the unittests. You should not override it yourself.
      51             :      */
      52             :     virtual sal_uInt16
      53             :     ObtainPoolId(const OUString& characterStyle) const;
      54             : 
      55             :     /** Information about a started link */
      56          28 :     struct StartedLink {
      57          10 :         StartedLink(sal_Int32 startPosition, const OUString& characterStyle) :
      58          10 :                 mStartPosition(startPosition), mCharacterStyle(characterStyle) {
      59          10 :         }
      60             :         sal_Int32 mStartPosition;
      61             :         OUString mCharacterStyle;
      62             :     };
      63             : 
      64             :     /** A link that has been encountered while parsing a tox.
      65             :      * A link is closed if it has both a start and an end token.
      66             :      */
      67          10 :     struct ClosedLink {
      68          10 :         ClosedLink(const OUString& url, sal_Int32 startPosition, sal_Int32 endPosition) :
      69          10 :                 mINetFormat(url, OUString()), mStartTextPos(endPosition), mEndTextPos(startPosition) {
      70          10 :         }
      71             :         SwFormatINetFormat mINetFormat;
      72             :         sal_Int32 mStartTextPos;
      73             :         sal_Int32 mEndTextPos;
      74             :     };
      75             : 
      76             :     boost::ptr_vector<ClosedLink> mClosedLinks;
      77             : 
      78             :     boost::ptr_vector<StartedLink> mStartedLinks;
      79             : 
      80             :     friend class ::ToxLinkProcessorTest;
      81             : };
      82             : 
      83             : }
      84             : 
      85             : #endif /* SW_TOXLINKPROCESSOR_HXX_ */
      86             : 
      87             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11