android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / text / redlnitr.hxx
blob5c301312640e6a1036d497417f1aa33fd8783b09
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <docary.hxx>
23 #include <swfont.hxx>
25 #include <vcl/commandevent.hxx>
27 #include <cstddef>
28 #include <deque>
29 #include <memory>
30 #include <vector>
32 class SwTextNode;
33 class SwDoc;
34 class SfxItemSet;
35 class SwAttrHandler;
37 class SwExtend
39 std::unique_ptr<SwFont> m_pFont;
40 const std::vector<ExtTextInputAttr> &m_rArr;
41 /// position of start of SwExtTextInput
42 SwNodeOffset const m_nNode;
43 sal_Int32 const m_nStart;
44 /// current position (inside)
45 sal_Int32 m_nPos;
46 /// position of end of SwExtTextInput (in same node as start)
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 );
51 public:
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)
57 , m_nPos(COMPLETE_STRING)
58 , m_nEnd(m_nStart + rArr.size())
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]); }
70 class SwRedlineItr
72 std::deque<SwTextAttr *> m_Hints;
73 const SwDoc& m_rDoc;
74 SwAttrHandler& m_rAttrHandler;
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
78 SwNodeOffset const m_nNdIdx;
79 SwRedlineTable::size_type const m_nFirst;
80 SwRedlineTable::size_type m_nAct;
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;
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)
94 if (m_pExt) return m_pExt->Enter(rFnt, nNode, nNew);
95 return 0;
97 sal_Int32 NextExtend(SwNodeOffset const nNode, sal_Int32 const nNext) {
98 if (m_pExt) return m_pExt->Next(nNode, nNext);
99 return nNext;
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, SwNodeOffset 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();
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(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;
129 void UpdateExtFont( SwFont &rFnt ) {
130 OSL_ENSURE( ExtOn(), "UpdateExtFont without ExtOn" );
131 m_pExt->UpdateFont( rFnt );
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */