/src/libreoffice/editeng/inc/ParagraphPortion.hxx
Line | Count | Source |
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 "ContentNode.hxx" |
23 | | #include "EditLineList.hxx" |
24 | | #include "TextPortionList.hxx" |
25 | | |
26 | | struct ScriptTypePosInfo |
27 | | { |
28 | | short nScriptType; |
29 | | sal_Int32 nStartPos; |
30 | | sal_Int32 nEndPos; |
31 | | |
32 | | ScriptTypePosInfo(short Type, sal_Int32 Start, sal_Int32 End) |
33 | 46.5M | : nScriptType(Type) |
34 | 46.5M | , nStartPos(Start) |
35 | 46.5M | , nEndPos(End) |
36 | 46.5M | { |
37 | 46.5M | } |
38 | | }; |
39 | | |
40 | | typedef std::vector<ScriptTypePosInfo> ScriptTypePosInfos; |
41 | | |
42 | | struct WritingDirectionInfo |
43 | | { |
44 | | sal_uInt8 nType; |
45 | | sal_Int32 nStartPos; |
46 | | sal_Int32 nEndPos; |
47 | | |
48 | | WritingDirectionInfo(sal_uInt8 Type, sal_Int32 Start, sal_Int32 End) |
49 | 7.04M | : nType(Type) |
50 | 7.04M | , nStartPos(Start) |
51 | 7.04M | , nEndPos(End) |
52 | 7.04M | { |
53 | 7.04M | } |
54 | | }; |
55 | | |
56 | | typedef std::vector<WritingDirectionInfo> WritingDirectionInfos; |
57 | | |
58 | | class ParaPortion |
59 | | { |
60 | | friend class ImpEditEngine; // to adjust the height |
61 | | private: |
62 | | EditLineList maLineList; |
63 | | TextPortionList maTextPortionList; |
64 | | ContentNode* mpNode = nullptr; |
65 | | tools::Long mnHeight = 0; |
66 | | |
67 | | ScriptTypePosInfos maScriptInfos; |
68 | | WritingDirectionInfos maWritingDirectionInfos; |
69 | | |
70 | | sal_Int32 mnInvalidPosStart = 0; |
71 | | sal_Int32 mnFirstLineOffset = 0; // For Writer-LineSpacing-Interpretation |
72 | | sal_Int32 mnBulletX = 0; |
73 | | sal_Int32 mnInvalidDiff = 0; |
74 | | |
75 | | bool mbInvalid : 1 = true; |
76 | | bool mbSimple : 1 = false; // only linear Tap |
77 | | bool mbVisible : 1 = true; // Belongs to the node! |
78 | | bool mbForceRepaint : 1 = false; |
79 | | |
80 | | ParaPortion(const ParaPortion&) = delete; |
81 | | |
82 | | public: |
83 | | ParaPortion(ContentNode* pNode) |
84 | 12.4M | : mpNode(pNode) |
85 | 12.4M | { |
86 | 12.4M | } |
87 | | |
88 | | sal_Int32 GetLineNumber(sal_Int32 nIndex) const; |
89 | | |
90 | 89.9M | EditLineList& GetLines() { return maLineList; } |
91 | 7.79M | const EditLineList& GetLines() const { return maLineList; } |
92 | | |
93 | 38.6M | bool IsInvalid() const { return mbInvalid; } |
94 | 7.54M | bool IsSimpleInvalid() const { return mbSimple; } |
95 | | void SetValid() |
96 | 4.12M | { |
97 | 4.12M | mbInvalid = false; |
98 | 4.12M | mbSimple = true; |
99 | 4.12M | } |
100 | | |
101 | 11.4M | bool MustRepaint() const { return mbForceRepaint; } |
102 | 2.17M | void SetMustRepaint(bool bRP) { mbForceRepaint = bRP; } |
103 | | |
104 | 4.29M | sal_Int32 GetBulletX() const { return mnBulletX; } |
105 | 4.12M | void SetBulletX(sal_Int32 nBulletX) { mnBulletX = nBulletX; } |
106 | | |
107 | | void MarkInvalid(sal_Int32 nStart, sal_Int32 nDiff); |
108 | | void MarkSelectionInvalid(sal_Int32 nStart); |
109 | | |
110 | 0 | void SetVisible(bool bVisible) { mbVisible = bVisible; } |
111 | 30.9M | bool IsVisible() const { return mbVisible; } |
112 | | |
113 | 176M | bool IsEmpty() { return GetTextPortions().isEmpty(); } |
114 | | |
115 | 23.2M | tools::Long GetHeight() const { return mbVisible ? mnHeight : 0; } |
116 | 46.4M | sal_Int32 GetFirstLineOffset() const { return mbVisible ? mnFirstLineOffset : 0; } |
117 | | void ResetHeight() |
118 | 0 | { |
119 | 0 | mnHeight = 0; |
120 | 0 | mnFirstLineOffset = 0; |
121 | 0 | } |
122 | | |
123 | 18.6M | ScriptTypePosInfos& getScriptTypePosInfos() { return maScriptInfos; } |
124 | 46.2M | ScriptTypePosInfos const& getScriptTypePosInfos() const { return maScriptInfos; } |
125 | | |
126 | 22.7M | WritingDirectionInfos& getWritingDirectionInfos() { return maWritingDirectionInfos; } |
127 | | |
128 | 150M | ContentNode* GetNode() const { return mpNode; } |
129 | 470M | TextPortionList& GetTextPortions() { return maTextPortionList; } |
130 | 9.58M | const TextPortionList& GetTextPortions() const { return maTextPortionList; } |
131 | | |
132 | 1.88M | sal_Int32 GetInvalidPosStart() const { return mnInvalidPosStart; } |
133 | 1.88M | short GetInvalidDiff() const { return mnInvalidDiff; } |
134 | | |
135 | | void CorrectValuesBehindLastFormattedLine(sal_Int32 nLastFormattedLine); |
136 | | #if OSL_DEBUG_LEVEL > 0 |
137 | | static bool DbgCheckTextPortions(ParaPortion const&); |
138 | | #endif |
139 | | }; |
140 | | |
141 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |