xref: /aoo4110/main/sw/inc/crstate.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _CRSTATE_HXX
24 #define _CRSTATE_HXX
25 
26 #include <com/sun/star/text/HoriOrientation.hpp>
27 #include <tools/gen.hxx>
28 #include <swtypes.hxx>
29 #include <swrect.hxx>
30 
31 
32 enum SwFillMode
33 {
34 	FILL_TAB,		// default, Auffuellen mit Tabulatoren
35 	FILL_SPACE,		// ... mit Tabulatoren und Spaces
36 	FILL_MARGIN,	// nur links, zentriert, rechts Ausrichten
37 	FILL_INDENT     // durch linken Absatzeinzug
38 };
39 
40 struct SwFillCrsrPos
41 {
42 	SwRect aCrsr;			// Position und Groesse des Shadowcursors
43 	sal_uInt16 nParaCnt;		// Anzahl der einzufuegenden Absaetze
44 	sal_uInt16 nTabCnt;			// Anzahl der Tabs bzw. Groesse des Einzugs
45 	sal_uInt16 nSpaceCnt;		// Anzahl der einzufuegenden Leerzeichen
46 	sal_uInt16 nColumnCnt;		// Anzahl der notwendigen Spaltenumbrueche
47     sal_Int16 eOrient;      // Absatzausrichtung
48 	SwFillMode eMode;		// Gewuenschte Auffuellregel
SwFillCrsrPosSwFillCrsrPos49 	SwFillCrsrPos( SwFillMode eMd = FILL_TAB ) :
50 		nParaCnt( 0 ), nTabCnt( 0 ), nSpaceCnt( 0 ), nColumnCnt( 0 ),
51         eOrient( com::sun::star::text::HoriOrientation::NONE ), eMode( eMd )
52 	{}
53 };
54 
55 // Multiportion types: two lines, bidirectional, 270 degrees rotation,
56 //                     ruby portion and 90 degrees rotation
57 #define MT_TWOLINE  0
58 #define MT_BIDI     1
59 #define MT_ROT_270  3
60 #define MT_RUBY     4
61 #define MT_ROT_90   7
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     sal_uInt8 nMultiType;        // Multiportion type
69 };
70 
71 /**
72  *  SwSpecialPos. This structure is used to pass some additional information
73  *  during the call of SwTxtFrm::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 SwTxtFrm:::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 SwTxtFrm:::GetCharRect with core string position 33.
100  */
101 
102 #define SP_EXTEND_RANGE_NONE    0
103 #define SP_EXTEND_RANGE_BEFORE  1
104 #define SP_EXTEND_RANGE_BEHIND  2
105 
106 struct SwSpecialPos
107 {
108     xub_StrLen nCharOfst;
109     sal_uInt16 nLineOfst;
110     sal_uInt8 nExtendRange;
111 
112     // #i27615#
SwSpecialPosSwSpecialPos113     SwSpecialPos() : nCharOfst(0), nLineOfst(0),
114                      nExtendRange(SP_EXTEND_RANGE_NONE)
115     {}
116 };
117 
118 // CrsrTravelling-Staties (fuer GetCrsrOfst)
119 enum CrsrMoveState
120 {
121 	MV_NONE,			// default
122 	MV_UPDOWN,			// Crsr Up/Down
123 	MV_RIGHTMARGIN, 	// an rechten Rand
124 	MV_LEFTMARGIN,		// an linken Rand
125 	MV_SETONLYTEXT,		// mit dem Cursr nur im Text bleiben
126 	MV_TBLSEL			// nicht in wiederholte Headlines
127 };
128 
129 // struct fuer spaetere Erweiterungen
130 struct SwCrsrMoveState
131 {
132 	SwFillCrsrPos	*pFill;		// fuer das automatische Auffuellen mit Tabs etc.
133 	Sw2LinesPos		*p2Lines; 	// for selections inside/around 2line portions
134     SwSpecialPos*   pSpecialPos; // for positions inside fields
135 	Point aRealHeight;			// enthaelt dann die Position/Hoehe des Cursors
136 	CrsrMoveState eState;
137     sal_uInt8            nCursorBidiLevel;
138 	sal_Bool bStop			:1;
139 	sal_Bool bRealHeight	:1;		// Soll die reale Hoehe berechnet werden?
140 	sal_Bool bFieldInfo		:1;		// Sollen Felder erkannt werden?
141 	sal_Bool bPosCorr		:1;		// Point musste korrigiert werden
142 	sal_Bool bFtnNoInfo		:1;		// Fussnotennumerierung erkannt
143 	sal_Bool bExactOnly		:1;		// GetCrsrOfst nur nach Exakten Treffern
144 								// suchen lassen, sprich niemals in das
145 								// GetCntntPos laufen.
146 	sal_Bool bFillRet		:1;		// wird nur im FillModus temp. genutzt
147 	sal_Bool bSetInReadOnly :1;		// ReadOnlyBereiche duerfen betreten werden
148 	sal_Bool bRealWidth		:1;		// Calculation of the width required
149 	sal_Bool b2Lines		:1;		// Check 2line portions and fill p2Lines
150     sal_Bool bNoScroll      :1;     // No scrolling of undersized textframes
151     sal_Bool bPosMatchesBounds :1;  // GetCrsrOfst should not return the next
152                                 // position if screen position is inside second
153                                 // have of bound rect
154 
155     sal_Bool bCntntCheck :1; // --> FME 2005-05-13 #i43742# Cursor position over content? <--
156 
157     // #i27615#
158     /**
159        cursor in front of label
160      */
161     sal_Bool bInFrontOfLabel :1;
162     sal_Bool bInNumPortion   :1;     // point is in number portion #i23726#
163     int nInNumPostionOffset;     // distance from number portion's start
164 
SwCrsrMoveStateSwCrsrMoveState165 	SwCrsrMoveState( CrsrMoveState eSt = MV_NONE ) :
166 		pFill( NULL ),
167 		p2Lines( NULL ),
168         pSpecialPos( NULL ),
169 		eState( eSt ),
170         nCursorBidiLevel( 0 ),
171 		bStop( sal_False ),
172 		bRealHeight( sal_False ),
173 		bFieldInfo( sal_False ),
174 		bPosCorr( sal_False ),
175 		bFtnNoInfo( sal_False ),
176 		bExactOnly( sal_False ),
177 		bSetInReadOnly( sal_False ),
178 		bRealWidth( sal_False ),
179         b2Lines( sal_False ),
180         bNoScroll( sal_False ),
181         bPosMatchesBounds( sal_False ),
182         bCntntCheck( sal_False ), // --> FME 2005-05-13 #i43742# <--
183         bInFrontOfLabel( sal_False ), // #i27615#
184         bInNumPortion(sal_False), // #i26726#
185         nInNumPostionOffset(0) // #i26726#
186 	{}
SwCrsrMoveStateSwCrsrMoveState187 	SwCrsrMoveState( SwFillCrsrPos *pInitFill ) :
188 		pFill( pInitFill ),
189         pSpecialPos( NULL ),
190 		eState( MV_SETONLYTEXT ),
191         nCursorBidiLevel( 0 ),
192 		bStop( sal_False ),
193 		bRealHeight( sal_False ),
194 		bFieldInfo( sal_False ),
195 		bPosCorr( sal_False ),
196 		bFtnNoInfo( sal_False ),
197 		bExactOnly( sal_False ),
198 		bSetInReadOnly( sal_False ),
199 		bRealWidth( sal_False ),
200         b2Lines( sal_False ),
201         bNoScroll( sal_False ),
202         bPosMatchesBounds( sal_False ),
203         bCntntCheck( sal_False ), // --> FME 2005-05-13 #i43742# <--
204         bInFrontOfLabel( sal_False ), // #i27615#
205         bInNumPortion(sal_False), // #i23726#
206         nInNumPostionOffset(0) // #i23726#
207 	{}
208 };
209 
210 
211 #endif
212 
213 
214