1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #ifndef SW_TOXLINKPROCESSOR_HXX_
11 #define SW_TOXLINKPROCESSOR_HXX_
13 #include "fmtinfmt.hxx"
14 #include <rtl/ustring.hxx>
21 class ToxLinkProcessorTest
;
25 /** A helper class for ToxTextGenerator.
26 * It collects information about encountered link tokens and allows access in a processed form.
28 class ToxLinkProcessor
{
31 virtual ~ToxLinkProcessor() {}
34 StartNewLink(sal_Int32 startPosition
, const OUString
& characterStyle
);
36 /** Close a link which has been found during processing.
39 * If you close more links than were opened, then the method will behave
40 * as if a start link was opened at position 0 with the character style
41 * STR_POOLCHR_TOXJUMP.
44 CloseLink(sal_Int32 endPosition
, const OUString
& url
, bool bRelative
);
46 /** Insert the found links as attributes to a text node */
48 InsertLinkAttributes(SwTextNode
& node
);
51 /** Obtain the pool id which belongs to a character style.
54 * This method is overridden in the unittests. You should not override it yourself.
57 ObtainPoolId(const OUString
& characterStyle
) const;
59 /** Information about a started link */
61 StartedLink(sal_Int32 startPosition
, const OUString
& characterStyle
) :
62 mStartPosition(startPosition
), mCharacterStyle(characterStyle
) {
64 sal_Int32 mStartPosition
;
65 OUString mCharacterStyle
;
68 /** A link that has been encountered while parsing a tox.
69 * A link is closed if it has both a start and an end token.
72 ClosedLink(const OUString
& url
, sal_Int32 startPosition
, sal_Int32 endPosition
)
73 : mINetFormat(url
, OUString())
74 , mStartTextPos(startPosition
)
75 , mEndTextPos(endPosition
)
78 SwFormatINetFormat mINetFormat
;
79 sal_Int32 mStartTextPos
;
80 sal_Int32 mEndTextPos
;
83 std::vector
<std::unique_ptr
<ClosedLink
>> m_ClosedLinks
;
85 std::unique_ptr
<StartedLink
> m_pStartedLink
;
87 friend class ::ToxLinkProcessorTest
;
92 #endif /* SW_TOXLINKPROCESSOR_HXX_ */
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */