/src/libreoffice/sw/inc/crstate.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 | | #pragma once |
20 | | |
21 | | #include <com/sun/star/text/HoriOrientation.hpp> |
22 | | #include <tools/gen.hxx> |
23 | | #include "swrect.hxx" |
24 | | |
25 | | #include <memory> |
26 | | |
27 | | enum class SwFillMode |
28 | | { |
29 | | Tab, ///< default, fill with tabs |
30 | | TabSpace, ///< fill with spaces and tabs |
31 | | Space, ///< fill with spaces |
32 | | Margin, ///< only align left, center, right |
33 | | Indent ///< by left paragraph indentation |
34 | | }; |
35 | | |
36 | | struct SwFillCursorPos |
37 | | { |
38 | | SwRect aCursor; ///< position and size of the ShadowCursor |
39 | | sal_uInt16 nParaCnt; ///< number of paragraphs to insert |
40 | | sal_uInt16 nTabCnt; ///< number of tabs respectively size of indentation |
41 | | sal_uInt16 nSpaceCnt; ///< number of spaces to insert |
42 | | sal_uInt16 nSpaceOnlyCnt; ///< number of spaces to insert ("only spaces, no tabs" mode) |
43 | | sal_uInt16 nColumnCnt; ///< number of necessary column breaks |
44 | | sal_Int16 eOrient; ///< paragraph alignment |
45 | | SwFillMode eMode; ///< desired fill-up rule |
46 | | SwFillCursorPos( SwFillMode eMd ) : |
47 | 0 | nParaCnt( 0 ), nTabCnt( 0 ), nSpaceCnt( 0 ), nSpaceOnlyCnt(0), nColumnCnt( 0 ), |
48 | 0 | eOrient( css::text::HoriOrientation::NONE ), eMode( eMd ) |
49 | 0 | {} |
50 | | }; |
51 | | |
52 | | // Multiportion types: two lines, bidirectional, 270 degrees rotation, |
53 | | // ruby portion and 90 degrees rotation |
54 | | enum class MultiPortionType : sal_uInt8 |
55 | | { |
56 | | TWOLINE = 0, |
57 | | BIDI = 1, |
58 | | ROT_270 = 3, |
59 | | RUBY = 4, |
60 | | ROT_90 = 7, |
61 | | }; |
62 | | |
63 | | struct Sw2LinesPos |
64 | | { |
65 | | SwRect aLine; ///< Position and size of the line |
66 | | SwRect aPortion; ///< Position and size of the multi portion |
67 | | SwRect aPortion2; ///< needed for nested multi portions |
68 | | MultiPortionType nMultiType; ///< Multiportion type |
69 | | }; |
70 | | |
71 | | /** |
72 | | * SwSpecialPos. This structure is used to pass some additional information |
73 | | * during the call of SwTextFrame::GetCharRect(). An SwSpecialPos defines a position |
74 | | * inside a portion which does not have a representation in the core string or |
75 | | * which is only represented by one position, e.g., field portions, |
76 | | * number portions, ergo sum and quo vadis portions. |
77 | | * |
78 | | * nCharOfst - The offset inside the special portion. Fields and its |
79 | | * follow fields are treated as one long special portion. |
80 | | * nLineOfst - The number of lines between the beginning of the special |
81 | | * portion and nCharOfst. A line offset required to be |
82 | | * nCharOfst relative to the beginning of the line. |
83 | | * nExtendRange - Setting this identifies portions which are in front or |
84 | | * behind the core string (number portion, quo vadis) |
85 | | * |
86 | | * Examples 1) |
87 | | * |
88 | | * Get the position of the second character inside a number portion: |
89 | | * nCharOfst = 2; nLineOfst = 0; nExtendRange = SP_EXTEND_RANGE_BEFORE; |
90 | | * Call SwTextFrame:::GetCharRect with core string position 0. |
91 | | * |
92 | | * Example 2) |
93 | | * |
94 | | * Field A - Length = 5 |
95 | | * Follow field B - Length = 9 |
96 | | * Get the position of the third character in follow field B, core position |
97 | | * of field A is 33. |
98 | | * nCharOfst = 7; nLineOfst = 0; nExtendRange = SP_EXTEND_RANGE_NONE; |
99 | | * Call SwTextFrame:::GetCharRect with core string position 33. |
100 | | */ |
101 | | |
102 | | enum class SwSPExtendRange : sal_uInt8 |
103 | | { |
104 | | NONE, BEFORE, BEHIND |
105 | | }; |
106 | | |
107 | | struct SwSpecialPos |
108 | | { |
109 | | sal_Int32 nCharOfst; |
110 | | sal_Int32 nLineOfst; |
111 | | SwSPExtendRange nExtendRange; |
112 | | |
113 | | // #i27615# |
114 | 58.9k | SwSpecialPos() : nCharOfst(0), nLineOfst(0), |
115 | 58.9k | nExtendRange(SwSPExtendRange::NONE) |
116 | 58.9k | {} |
117 | | }; |
118 | | |
119 | | // CursorTravelling-States (for GetModelPositionForViewPoint) |
120 | | enum class CursorMoveState |
121 | | { |
122 | | NONE, ///< default |
123 | | UpDown, ///< Cursor Up/Down |
124 | | RightMargin, ///< at right margin |
125 | | LeftMargin, ///< at left margin |
126 | | SetOnlyText, ///< stay with the cursor inside text |
127 | | TableSel ///< not in repeated headlines |
128 | | }; |
129 | | |
130 | | // struct for later extensions |
131 | | struct SwCursorMoveState |
132 | | { |
133 | | SwFillCursorPos *m_pFill; ///< for automatic filling with tabs etc |
134 | | std::unique_ptr<Sw2LinesPos> m_p2Lines; ///< for selections inside/around 2line portions |
135 | | SwSpecialPos* m_pSpecialPos; ///< for positions inside fields |
136 | | Point m_aRealHeight; ///< contains then the position/height of the cursor |
137 | | CursorMoveState m_eState; |
138 | | sal_uInt8 m_nCursorBidiLevel; |
139 | | bool m_bStop; |
140 | | bool m_bRealHeight; ///< should the real height be calculated? |
141 | | bool m_bFieldInfo; ///< should fields be recognized? (get position of field start) |
142 | | bool m_bPosCorr; ///< Point had to be corrected |
143 | | bool m_bFootnoteNoInfo; ///< recognized footnote numbering |
144 | | bool m_bExactOnly; /**< let GetModelPositionForViewPoint look for exact matches only, |
145 | | i.e. never let it run into GetContentPos */ |
146 | | bool m_bFillRet; ///< only used temporary in FillMode |
147 | | bool m_bSetInReadOnly; ///< ReadOnly areas may be entered |
148 | | bool m_bRealWidth; ///< Calculation of the width required |
149 | | bool m_b2Lines; ///< Check 2line portions and fill p2Lines |
150 | | bool m_bNoScroll; ///< No scrolling of undersized textframes |
151 | | bool m_bPosMatchesBounds; /**< GetModelPositionForViewPoint should not return the next |
152 | | position if screen position is inside second |
153 | | half of bound rect */ |
154 | | |
155 | | bool m_bContentCheck; // #i43742# Cursor position over content? |
156 | | |
157 | | // #i27615# |
158 | | /** |
159 | | cursor in front of label |
160 | | */ |
161 | | bool m_bInFrontOfLabel; |
162 | | bool m_bInNumPortion; ///< point is in number portion #i23726# |
163 | | int m_nInNumPortionOffset; ///< distance from number portion's start |
164 | | |
165 | | SwCursorMoveState( CursorMoveState eSt = CursorMoveState::NONE ) : |
166 | 59.5k | m_pFill( nullptr ), |
167 | 59.5k | m_pSpecialPos( nullptr ), |
168 | 59.5k | m_eState( eSt ), |
169 | 59.5k | m_nCursorBidiLevel( 0 ), |
170 | 59.5k | m_bStop( false ), |
171 | 59.5k | m_bRealHeight( false ), |
172 | 59.5k | m_bFieldInfo( false ), |
173 | 59.5k | m_bPosCorr( false ), |
174 | 59.5k | m_bFootnoteNoInfo( false ), |
175 | 59.5k | m_bExactOnly( false ), |
176 | 59.5k | m_bFillRet( false ), |
177 | 59.5k | m_bSetInReadOnly( false ), |
178 | 59.5k | m_bRealWidth( false ), |
179 | 59.5k | m_b2Lines( false ), |
180 | 59.5k | m_bNoScroll( false ), |
181 | 59.5k | m_bPosMatchesBounds( false ), |
182 | 59.5k | m_bContentCheck( false ), // #i43742# |
183 | 59.5k | m_bInFrontOfLabel( false ), // #i27615# |
184 | 59.5k | m_bInNumPortion(false), // #i26726# |
185 | 59.5k | m_nInNumPortionOffset(0) // #i26726# |
186 | 59.5k | {} |
187 | | SwCursorMoveState( SwFillCursorPos *pInitFill ) : |
188 | 0 | m_pFill( pInitFill ), |
189 | 0 | m_pSpecialPos( nullptr ), |
190 | 0 | m_eState( CursorMoveState::SetOnlyText ), |
191 | 0 | m_nCursorBidiLevel( 0 ), |
192 | 0 | m_bStop( false ), |
193 | 0 | m_bRealHeight( false ), |
194 | 0 | m_bFieldInfo( false ), |
195 | 0 | m_bPosCorr( false ), |
196 | 0 | m_bFootnoteNoInfo( false ), |
197 | 0 | m_bExactOnly( false ), |
198 | 0 | m_bFillRet( false ), |
199 | 0 | m_bSetInReadOnly( false ), |
200 | 0 | m_bRealWidth( false ), |
201 | 0 | m_b2Lines( false ), |
202 | 0 | m_bNoScroll( false ), |
203 | 0 | m_bPosMatchesBounds( false ), |
204 | 0 | m_bContentCheck( false ), // #i43742# |
205 | 0 | m_bInFrontOfLabel( false ), // #i27615# |
206 | 0 | m_bInNumPortion(false), // #i23726# |
207 | 0 | m_nInNumPortionOffset(0) // #i23726# |
208 | 0 | {} |
209 | | }; |
210 | | |
211 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |