LibreOffice Module sw (master)  1
redlnitr.hxx
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  * 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 #pragma once
21 
22 #include <docary.hxx>
23 #include <swfont.hxx>
24 
25 #include <vcl/commandevent.hxx>
26 
27 #include <cstddef>
28 #include <deque>
29 #include <memory>
30 #include <vector>
31 
32 class SwTextNode;
33 class SwDoc;
34 class SfxItemSet;
35 class SwAttrHandler;
36 
37 class SwExtend
38 {
39  std::unique_ptr<SwFont> m_pFont;
40  const std::vector<ExtTextInputAttr> &m_rArr;
43  sal_Int32 const m_nStart;
45  sal_Int32 m_nPos;
47  sal_Int32 const m_nEnd;
48  bool Leave_(SwFont& rFnt, sal_uLong nNode, sal_Int32 nNew);
49  bool Inside() const { return (m_nPos >= m_nStart && m_nPos < m_nEnd); }
50  static void ActualizeFont( SwFont &rFnt, ExtTextInputAttr nAttr );
51 public:
52  SwExtend(const std::vector<ExtTextInputAttr> &rArr,
53  sal_uLong const nNode, sal_Int32 const nStart)
54  : m_rArr(rArr)
55  , m_nNode(nNode)
56  , m_nStart(nStart)
57  , m_nPos(COMPLETE_STRING)
58  , m_nEnd(m_nStart + rArr.size())
59  {}
60  bool IsOn() const { return m_pFont != nullptr; }
61  void Reset() { m_pFont.reset(); m_nPos = COMPLETE_STRING; }
62  bool Leave(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
63  { return m_pFont && Leave_(rFnt, nNode, nNew); }
64  short Enter(SwFont& rFnt, sal_uLong nNode, sal_Int32 nNew);
65  sal_Int32 Next(sal_uLong nNode, sal_Int32 nNext);
66  SwFont* GetFont() { return m_pFont.get(); }
67  void UpdateFont(SwFont &rFont) { ActualizeFont(rFont, m_rArr[m_nPos - m_nStart]); }
68 };
69 
71 {
72  std::deque<SwTextAttr *> m_Hints;
73  const SwDoc& m_rDoc;
75  std::unique_ptr<SfxItemSet> m_pSet;
76  std::unique_ptr<SwExtend> m_pExt;
77  // note: this isn't actually used in the merged-para (Hide) case
81  sal_Int32 m_nStart;
82  sal_Int32 m_nEnd;
83  bool m_bOn;
84 public:
85  enum class Mode { Show, Ignore, Hide };
86 private:
87  Mode const m_eMode;
88 
89  void Clear_( SwFont* pFnt );
90  bool ChkSpecialUnderline_() const;
91  void FillHints( std::size_t nAuthor, RedlineType eType );
92  short EnterExtend(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
93  {
94  if (m_pExt) return m_pExt->Enter(rFnt, nNode, nNew);
95  return 0;
96  }
97  sal_Int32 NextExtend(sal_uLong const nNode, sal_Int32 const nNext) {
98  if (m_pExt) return m_pExt->Next(nNode, nNext);
99  return nNext;
100  }
101 public:
102  SwRedlineItr( const SwTextNode& rTextNd, SwFont& rFnt, SwAttrHandler& rAH,
103  sal_Int32 nRedlPos, Mode mode,
104  const std::vector<ExtTextInputAttr> *pArr = nullptr,
105  SwPosition const* pExtInputStart = nullptr);
106  ~SwRedlineItr() COVERITY_NOEXCEPT_FALSE;
107  SwRedlineTable::size_type GetAct() const { return m_nAct; }
108  bool IsOn() const { return m_bOn || (m_pExt && m_pExt->IsOn()); }
109  void Clear( SwFont* pFnt ) { if (m_bOn) Clear_( pFnt ); }
110  void ChangeTextAttr( SwFont* pFnt, SwTextAttr const &rHt, bool bChg );
111  short Seek(SwFont& rFnt, sal_uLong nNode, sal_Int32 nNew, sal_Int32 nOld);
112  void Reset() {
113  if (m_nAct != m_nFirst) m_nAct = SwRedlineTable::npos;
114  if (m_pExt) m_pExt->Reset();
115  }
116  std::pair<sal_Int32, std::pair<SwRangeRedline const*, size_t>> GetNextRedln(
117  sal_Int32 nNext, SwTextNode const* pNode, SwRedlineTable::size_type & rAct);
118  bool ChkSpecialUnderline() const
119  { return IsOn() && ChkSpecialUnderline_(); }
120  bool CheckLine(sal_uLong nStartNode, sal_Int32 nChkStart, sal_uLong nEndNode,
121  sal_Int32 nChkEnd, OUString& rRedlineText, bool& bRedlineEnd,
122  RedlineType& eRedlineEnd, size_t* pAuthorAtPos = nullptr);
123  bool LeaveExtend(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
124  { return m_pExt->Leave(rFnt, nNode, nNew); }
125  bool ExtOn() {
126  if (m_pExt) return m_pExt->IsOn();
127  return false;
128  }
129  void UpdateExtFont( SwFont &rFnt ) {
130  OSL_ENSURE( ExtOn(), "UpdateExtFont without ExtOn" );
131  m_pExt->UpdateFont( rFnt );
132  }
133 };
134 
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 m_nEnd
Definition: redlnitr.hxx:82
SwRedlineTable::size_type GetAct() const
Definition: redlnitr.hxx:107
std::deque< SwTextAttr * > m_Hints
Definition: redlnitr.hxx:72
void UpdateFont(SwFont &rFont)
Definition: redlnitr.hxx:67
Marks a position in the document model.
Definition: pam.hxx:35
bool ChkSpecialUnderline() const
Definition: redlnitr.hxx:118
bool LeaveExtend(SwFont &rFnt, sal_uLong const nNode, sal_Int32 const nNew)
Definition: redlnitr.hxx:123
std::unique_ptr< SwFont > m_pFont
Definition: redlnitr.hxx:39
void UpdateExtFont(SwFont &rFnt)
Definition: redlnitr.hxx:129
sal_uIntPtr sal_uLong
Definition: doc.hxx:188
short Seek(SwFont &rFnt, sal_uLong nNode, sal_Int32 nNew, sal_Int32 nOld)
Definition: redlnitr.cxx:672
sal_Int32 const m_nStart
Definition: redlnitr.hxx:43
Mode
SwFont * GetFont()
Definition: redlnitr.hxx:66
sal_Int32 m_nStart
Definition: redlnitr.hxx:81
bool CheckLine(sal_uLong nStartNode, sal_Int32 nChkStart, sal_uLong nEndNode, sal_Int32 nChkEnd, OUString &rRedlineText, bool &bRedlineEnd, RedlineType &eRedlineEnd, size_t *pAuthorAtPos=nullptr)
Definition: redlnitr.cxx:941
SwRedlineTable::size_type m_nAct
Definition: redlnitr.hxx:80
void FillHints(std::size_t nAuthor, RedlineType eType)
Definition: redlnitr.cxx:790
void Reset()
Definition: redlnitr.hxx:61
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
bool ExtOn()
Definition: redlnitr.hxx:125
bool Leave_(SwFont &rFnt, sal_uLong nNode, sal_Int32 nNew)
Definition: redlnitr.cxx:1073
bool IsOn() const
Definition: redlnitr.hxx:108
Used by Attribute Iterators to organize attributes on stacks to find the valid attribute in each cate...
Definition: atrhndl.hxx:38
sal_Int32 Next(sal_uLong nNode, sal_Int32 nNext)
Definition: redlnitr.cxx:1098
sal_Int32 m_nPos
current position (inside)
Definition: redlnitr.hxx:45
bool Inside() const
Definition: redlnitr.hxx:49
std::unique_ptr< SfxItemSet > m_pSet
Definition: redlnitr.hxx:75
bool IsOn() const
Definition: redlnitr.hxx:60
SwExtend(const std::vector< ExtTextInputAttr > &rArr, sal_uLong const nNode, sal_Int32 const nStart)
Definition: redlnitr.hxx:52
void Reset()
Definition: redlnitr.hxx:112
sal_uLong const m_nNdIdx
Definition: redlnitr.hxx:78
vector_type::size_type size_type
Definition: docary.hxx:223
std::unique_ptr< SwExtend > m_pExt
Definition: redlnitr.hxx:76
bool Leave(SwFont &rFnt, sal_uLong const nNode, sal_Int32 const nNew)
Definition: redlnitr.hxx:62
sal_Int32 const m_nEnd
position of end of SwExtTextInput (in same node as start)
Definition: redlnitr.hxx:47
~SwRedlineItr() COVERITY_NOEXCEPT_FALSE
Definition: redlnitr.cxx:664
size
sal_uLong const m_nNode
position of start of SwExtTextInput
Definition: redlnitr.hxx:42
const SwDoc & m_rDoc
Definition: redlnitr.hxx:73
SwRedlineTable::size_type const m_nFirst
Definition: redlnitr.hxx:79
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
Mode const m_eMode
Definition: redlnitr.hxx:87
void Clear_(SwFont *pFnt)
Definition: redlnitr.cxx:830
std::pair< sal_Int32, std::pair< SwRangeRedline const *, size_t > > GetNextRedln(sal_Int32 nNext, SwTextNode const *pNode, SwRedlineTable::size_type &rAct)
Ignore mode: does nothing.
Definition: redlnitr.cxx:850
bool ChkSpecialUnderline_() const
Definition: redlnitr.cxx:926
void ChangeTextAttr(SwFont *pFnt, SwTextAttr const &rHt, bool bChg)
Definition: redlnitr.cxx:809
constexpr sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:56
const std::vector< ExtTextInputAttr > & m_rArr
Definition: redlnitr.hxx:40
SwRedlineItr(const SwTextNode &rTextNd, SwFont &rFnt, SwAttrHandler &rAH, sal_Int32 nRedlPos, Mode mode, const std::vector< ExtTextInputAttr > *pArr=nullptr, SwPosition const *pExtInputStart=nullptr)
Definition: redlnitr.cxx:639
ExtTextInputAttr
RedlineType
short Enter(SwFont &rFnt, sal_uLong nNode, sal_Int32 nNew)
Definition: redlnitr.cxx:1057
SwAttrHandler & m_rAttrHandler
Definition: redlnitr.hxx:74
short EnterExtend(SwFont &rFnt, sal_uLong const nNode, sal_Int32 const nNew)
Definition: redlnitr.hxx:92
static constexpr size_type npos
Definition: docary.hxx:224
static void ActualizeFont(SwFont &rFnt, ExtTextInputAttr nAttr)
Definition: redlnitr.cxx:1033
void Clear(SwFont *pFnt)
Definition: redlnitr.hxx:109
sal_Int32 NextExtend(sal_uLong const nNode, sal_Int32 const nNext)
Definition: redlnitr.hxx:97