LibreOffice Module sw (master)  1
ToxLinkProcessor.cxx
Go to the documentation of this file.
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 <memory>
11 #include <ToxLinkProcessor.hxx>
12 
13 #include <SwStyleNameMapper.hxx>
14 #include <ndtxt.hxx>
15 #include <sal/log.hxx>
16 
17 namespace sw {
18 
19 void
20 ToxLinkProcessor::StartNewLink(sal_Int32 startPosition, const OUString& characterStyle)
21 {
22  SAL_INFO_IF(m_pStartedLink, "sw.core", "ToxLinkProcessor: LS without LE");
23  m_pStartedLink = std::make_unique<StartedLink>(
24  startPosition, characterStyle);
25 }
26 
27 void
28 ToxLinkProcessor::CloseLink(sal_Int32 endPosition, const OUString& url)
29 {
30  if (m_pStartedLink == nullptr)
31  {
32  SAL_INFO("sw.core", "ToxLinkProcessor: LE without LS");
33  return;
34  }
35 
36  if (url.isEmpty()) {
37  return;
38  }
39 
40  std::unique_ptr<ClosedLink> pClosedLink(
41  new ClosedLink(url, m_pStartedLink->mStartPosition, endPosition));
42 
43  const OUString& characterStyle = m_pStartedLink->mCharacterStyle;
44  sal_uInt16 poolId = ObtainPoolId(characterStyle);
45  pClosedLink->mINetFormat.SetVisitedFormatAndId(characterStyle, poolId);
46  pClosedLink->mINetFormat.SetINetFormatAndId(characterStyle, poolId);
47 
48  m_ClosedLinks.push_back(std::move(pClosedLink));
49  m_pStartedLink.reset();
50 }
51 
52 sal_uInt16
53 ToxLinkProcessor::ObtainPoolId(const OUString& characterStyle) const
54 {
55  if (characterStyle.isEmpty()) {
56  return USHRT_MAX;
57  }
58  else {
60  }
61 }
62 
63 
64 void
66 {
67  for (auto const& clink : m_ClosedLinks)
68  {
69  node.InsertItem(clink->mINetFormat, clink->mStartTextPos, clink->mEndTextPos);
70  }
71 }
72 
73 }
74 
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SAL_INFO_IF(condition, area, stream)
Dialog to specify the properties of date form field.
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
SwTextAttr * InsertItem(SfxPoolItem &rAttr, const sal_Int32 nStart, const sal_Int32 nEnd, const SetAttrMode nMode=SetAttrMode::DEFAULT)
create new text attribute from rAttr and insert it
Definition: thints.cxx:1270
virtual sal_uInt16 ObtainPoolId(const OUString &characterStyle) const
Obtain the pool id which belongs to a character style.
void CloseLink(sal_Int32 endPosition, const OUString &url)
Close a link which has been found during processing.
std::vector< std::unique_ptr< ClosedLink > > m_ClosedLinks
std::unique_ptr< StartedLink > m_pStartedLink
void InsertLinkAttributes(SwTextNode &node)
Insert the found links as attributes to a text node.
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
#define SAL_INFO(area, stream)
void StartNewLink(sal_Int32 startPosition, const OUString &characterStyle)