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
32class SwTextNode;
33class SwDoc;
34class SfxItemSet;
35class SwAttrHandler;
36
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, SwNodeOffset 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 );
51public:
52 SwExtend(const std::vector<ExtTextInputAttr> &rArr,
53 SwNodeOffset const nNode, sal_Int32 const nStart)
54 : m_rArr(rArr)
55 , m_nNode(nNode)
56 , m_nStart(nStart)
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, SwNodeOffset const nNode, sal_Int32 const nNew)
63 { return m_pFont && Leave_(rFnt, nNode, nNew); }
64 short Enter(SwFont& rFnt, SwNodeOffset nNode, sal_Int32 nNew);
65 sal_Int32 Next(SwNodeOffset 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;
84public:
85 enum class Mode { Show, Ignore, Hide };
86private:
88
89 void Clear_( SwFont* pFnt );
90 bool ChkSpecialUnderline_() const;
91 void FillHints( std::size_t nAuthor, RedlineType eType );
92 short EnterExtend(SwFont& rFnt, SwNodeOffset 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(SwNodeOffset const nNode, sal_Int32 const nNext) {
98 if (m_pExt) return m_pExt->Next(nNode, nNext);
99 return nNext;
100 }
101public:
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, SwNodeOffset nNode, sal_Int32 nNew, sal_Int32 nOld);
112 void Reset() {
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);
119 { return IsOn() && ChkSpecialUnderline_(); }
120 bool CheckLine(SwNodeOffset nStartNode, sal_Int32 nChkStart, SwNodeOffset nEndNode,
121 sal_Int32 nChkEnd, OUString& rRedlineText, bool& bRedlineEnd,
122 RedlineType& eRedlineEnd, size_t* pAuthorAtPos = nullptr);
123 bool LeaveExtend(SwFont& rFnt, SwNodeOffset 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: */
Used by Attribute Iterators to organize attributes on stacks to find the valid attribute in each cate...
Definition: atrhndl.hxx:38
Definition: doc.hxx:197
sal_Int32 Next(SwNodeOffset nNode, sal_Int32 nNext)
Definition: redlnitr.cxx:1179
const std::vector< ExtTextInputAttr > & m_rArr
Definition: redlnitr.hxx:40
short Enter(SwFont &rFnt, SwNodeOffset nNode, sal_Int32 nNew)
Definition: redlnitr.cxx:1138
std::unique_ptr< SwFont > m_pFont
Definition: redlnitr.hxx:39
void UpdateFont(SwFont &rFont)
Definition: redlnitr.hxx:67
sal_Int32 const m_nStart
Definition: redlnitr.hxx:43
SwNodeOffset const m_nNode
position of start of SwExtTextInput
Definition: redlnitr.hxx:42
SwFont * GetFont()
Definition: redlnitr.hxx:66
SwExtend(const std::vector< ExtTextInputAttr > &rArr, SwNodeOffset const nNode, sal_Int32 const nStart)
Definition: redlnitr.hxx:52
bool Leave_(SwFont &rFnt, SwNodeOffset nNode, sal_Int32 nNew)
Definition: redlnitr.cxx:1154
sal_Int32 m_nPos
current position (inside)
Definition: redlnitr.hxx:45
sal_Int32 const m_nEnd
position of end of SwExtTextInput (in same node as start)
Definition: redlnitr.hxx:47
bool Leave(SwFont &rFnt, SwNodeOffset const nNode, sal_Int32 const nNew)
Definition: redlnitr.hxx:62
bool IsOn() const
Definition: redlnitr.hxx:60
void Reset()
Definition: redlnitr.hxx:61
bool Inside() const
Definition: redlnitr.hxx:49
static void ActualizeFont(SwFont &rFnt, ExtTextInputAttr nAttr)
Definition: redlnitr.cxx:1112
To take Asian or other languages into consideration, an SwFont object consists of 3 SwSubFonts (Latin...
Definition: swfont.hxx:135
std::unique_ptr< SfxItemSet > m_pSet
Definition: redlnitr.hxx:75
void Clear_(SwFont *pFnt)
Definition: redlnitr.cxx:909
void ChangeTextAttr(SwFont *pFnt, SwTextAttr const &rHt, bool bChg)
Definition: redlnitr.cxx:888
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:929
sal_Int32 NextExtend(SwNodeOffset const nNode, sal_Int32 const nNext)
Definition: redlnitr.hxx:97
bool LeaveExtend(SwFont &rFnt, SwNodeOffset const nNode, sal_Int32 const nNew)
Definition: redlnitr.hxx:123
bool ChkSpecialUnderline() const
Definition: redlnitr.hxx:118
sal_Int32 m_nEnd
Definition: redlnitr.hxx:82
Mode const m_eMode
Definition: redlnitr.hxx:87
SwRedlineTable::size_type GetAct() const
Definition: redlnitr.hxx:107
bool CheckLine(SwNodeOffset nStartNode, sal_Int32 nChkStart, SwNodeOffset nEndNode, sal_Int32 nChkEnd, OUString &rRedlineText, bool &bRedlineEnd, RedlineType &eRedlineEnd, size_t *pAuthorAtPos=nullptr)
Definition: redlnitr.cxx:1020
SwNodeOffset const m_nNdIdx
Definition: redlnitr.hxx:78
short EnterExtend(SwFont &rFnt, SwNodeOffset const nNode, sal_Int32 const nNew)
Definition: redlnitr.hxx:92
bool ExtOn()
Definition: redlnitr.hxx:125
void Reset()
Definition: redlnitr.hxx:112
SwRedlineTable::size_type m_nAct
Definition: redlnitr.hxx:80
bool ChkSpecialUnderline_() const
Definition: redlnitr.cxx:1005
void Clear(SwFont *pFnt)
Definition: redlnitr.hxx:109
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:704
short Seek(SwFont &rFnt, SwNodeOffset nNode, sal_Int32 nNew, sal_Int32 nOld)
Definition: redlnitr.cxx:739
SwAttrHandler & m_rAttrHandler
Definition: redlnitr.hxx:74
sal_Int32 m_nStart
Definition: redlnitr.hxx:81
const SwDoc & m_rDoc
Definition: redlnitr.hxx:73
std::unique_ptr< SwExtend > m_pExt
Definition: redlnitr.hxx:76
std::deque< SwTextAttr * > m_Hints
Definition: redlnitr.hxx:72
void UpdateExtFont(SwFont &rFnt)
Definition: redlnitr.hxx:129
SwRedlineTable::size_type const m_nFirst
Definition: redlnitr.hxx:79
bool IsOn() const
Definition: redlnitr.hxx:108
void FillHints(std::size_t nAuthor, RedlineType eType)
Definition: redlnitr.cxx:869
~SwRedlineItr() COVERITY_NOEXCEPT_FALSE
Definition: redlnitr.cxx:731
static constexpr size_type npos
Definition: docary.hxx:224
vector_type::size_type size_type
Definition: docary.hxx:223
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
ExtTextInputAttr
RedlineType
size
Mode
Marks a position in the document model.
Definition: pam.hxx:38
constexpr sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:57