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