xref: /trunk/main/sw/inc/crstate.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _CRSTATE_HXX
28 #define _CRSTATE_HXX
29 
30 #include <com/sun/star/text/HoriOrientation.hpp>
31 #include <tools/gen.hxx>
32 #include <swtypes.hxx>
33 #include <swrect.hxx>
34 
35 
36 enum SwFillMode
37 {
38     FILL_TAB,       // default, Auffuellen mit Tabulatoren
39     FILL_SPACE,     // ... mit Tabulatoren und Spaces
40     FILL_MARGIN,    // nur links, zentriert, rechts Ausrichten
41     FILL_INDENT     // durch linken Absatzeinzug
42 };
43 
44 struct SwFillCrsrPos
45 {
46     SwRect aCrsr;           // Position und Groesse des Shadowcursors
47     sal_uInt16 nParaCnt;        // Anzahl der einzufuegenden Absaetze
48     sal_uInt16 nTabCnt;         // Anzahl der Tabs bzw. Groesse des Einzugs
49     sal_uInt16 nSpaceCnt;       // Anzahl der einzufuegenden Leerzeichen
50     sal_uInt16 nColumnCnt;      // Anzahl der notwendigen Spaltenumbrueche
51     sal_Int16 eOrient;      // Absatzausrichtung
52     SwFillMode eMode;       // Gewuenschte Auffuellregel
53     SwFillCrsrPos( SwFillMode eMd = FILL_TAB ) :
54         nParaCnt( 0 ), nTabCnt( 0 ), nSpaceCnt( 0 ), nColumnCnt( 0 ),
55         eOrient( com::sun::star::text::HoriOrientation::NONE ), eMode( eMd )
56     {}
57 };
58 
59 // Multiportion types: two lines, bidirectional, 270 degrees rotation,
60 //                     ruby portion and 90 degrees rotation
61 #define MT_TWOLINE  0
62 #define MT_BIDI     1
63 #define MT_ROT_270  3
64 #define MT_RUBY     4
65 #define MT_ROT_90   7
66 
67 struct Sw2LinesPos
68 {
69     SwRect aLine;           // Position and size of the line
70     SwRect aPortion;        // Position and size of the multi portion
71     SwRect aPortion2;       // needed for nested multi portions
72     sal_uInt8 nMultiType;        // Multiportion type
73 };
74 
75 /**
76  *  SwSpecialPos. This structure is used to pass some additional information
77  *  during the call of SwTxtFrm::GetCharRect(). An SwSpecialPos defines a position
78  *  inside a portion which does not have a representation in the core string or
79  *  which is only represented by one position,  e.g., field portions,
80  *  number portions, ergo sum and quo vadis portions.
81  *
82  *  nCharOfst       - The offset inside the special portion. Fields and its
83  *                    follow fields are treated as one long special portion.
84  *  nLineOfst       - The number of lines between the beginning of the special
85  *                    portion and nCharOfst. A line offset required to be
86  *                    nCharOfst relative to the beginning of the line.
87  *  nExtendRange    - Setting this identifies portions which are in front or
88  *                    behind the core string (number portion, quo vadis)
89  *
90  *  Examples 1)
91  *
92  *      Get the position of the second character inside a number portion:
93  *          nCharOfst = 2; nLineOfst = 0; nExtendRange = SP_EXTEND_RANGE_BEFORE;
94  *          Call SwTxtFrm:::GetCharRect with core string position 0.
95  *
96  *  Example 2)
97  *
98  *      Field A - Length = 5
99  *      Follow field B - Length = 9
100  *      Get the position of the third character in follow field B, core position
101  *      of field A is 33.
102  *          nCharOfst = 7; nLineOfst = 0; nExtendRange = SP_EXTEND_RANGE_NONE;
103  *          Call SwTxtFrm:::GetCharRect with core string position 33.
104  */
105 
106 #define SP_EXTEND_RANGE_NONE    0
107 #define SP_EXTEND_RANGE_BEFORE  1
108 #define SP_EXTEND_RANGE_BEHIND  2
109 
110 struct SwSpecialPos
111 {
112     xub_StrLen nCharOfst;
113     sal_uInt16 nLineOfst;
114     sal_uInt8 nExtendRange;
115 
116     // #i27615#
117     SwSpecialPos() : nCharOfst(0), nLineOfst(0),
118                      nExtendRange(SP_EXTEND_RANGE_NONE)
119     {}
120 };
121 
122 // CrsrTravelling-Staties (fuer GetCrsrOfst)
123 enum CrsrMoveState
124 {
125     MV_NONE,            // default
126     MV_UPDOWN,          // Crsr Up/Down
127     MV_RIGHTMARGIN,     // an rechten Rand
128     MV_LEFTMARGIN,      // an linken Rand
129     MV_SETONLYTEXT,     // mit dem Cursr nur im Text bleiben
130     MV_TBLSEL           // nicht in wiederholte Headlines
131 };
132 
133 // struct fuer spaetere Erweiterungen
134 struct SwCrsrMoveState
135 {
136     SwFillCrsrPos   *pFill;     // fuer das automatische Auffuellen mit Tabs etc.
137     Sw2LinesPos     *p2Lines;   // for selections inside/around 2line portions
138     SwSpecialPos*   pSpecialPos; // for positions inside fields
139     Point aRealHeight;          // enthaelt dann die Position/Hoehe des Cursors
140     CrsrMoveState eState;
141     sal_uInt8            nCursorBidiLevel;
142     sal_Bool bStop          :1;
143     sal_Bool bRealHeight    :1;     // Soll die reale Hoehe berechnet werden?
144     sal_Bool bFieldInfo     :1;     // Sollen Felder erkannt werden?
145     sal_Bool bPosCorr       :1;     // Point musste korrigiert werden
146     sal_Bool bFtnNoInfo     :1;     // Fussnotennumerierung erkannt
147     sal_Bool bExactOnly     :1;     // GetCrsrOfst nur nach Exakten Treffern
148                                 // suchen lassen, sprich niemals in das
149                                 // GetCntntPos laufen.
150     sal_Bool bFillRet       :1;     // wird nur im FillModus temp. genutzt
151     sal_Bool bSetInReadOnly :1;     // ReadOnlyBereiche duerfen betreten werden
152     sal_Bool bRealWidth     :1;     // Calculation of the width required
153     sal_Bool b2Lines        :1;     // Check 2line portions and fill p2Lines
154     sal_Bool bNoScroll      :1;     // No scrolling of undersized textframes
155     sal_Bool bPosMatchesBounds :1;  // GetCrsrOfst should not return the next
156                                 // position if screen position is inside second
157                                 // have of bound rect
158 
159     sal_Bool bCntntCheck :1; // --> FME 2005-05-13 #i43742# Cursor position over content? <--
160 
161     // #i27615#
162     /**
163        cursor in front of label
164      */
165     sal_Bool bInFrontOfLabel :1;
166     sal_Bool bInNumPortion   :1;     // point is in number portion #i23726#
167     int nInNumPostionOffset;     // distance from number portion's start
168 
169     SwCrsrMoveState( CrsrMoveState eSt = MV_NONE ) :
170         pFill( NULL ),
171         p2Lines( NULL ),
172         pSpecialPos( NULL ),
173         eState( eSt ),
174         nCursorBidiLevel( 0 ),
175         bStop( sal_False ),
176         bRealHeight( sal_False ),
177         bFieldInfo( sal_False ),
178         bPosCorr( sal_False ),
179         bFtnNoInfo( sal_False ),
180         bExactOnly( sal_False ),
181         bSetInReadOnly( sal_False ),
182         bRealWidth( sal_False ),
183         b2Lines( sal_False ),
184         bNoScroll( sal_False ),
185         bPosMatchesBounds( sal_False ),
186         bCntntCheck( sal_False ), // --> FME 2005-05-13 #i43742# <--
187         bInFrontOfLabel( sal_False ), // #i27615#
188         bInNumPortion(sal_False), // #i26726#
189         nInNumPostionOffset(0) // #i26726#
190     {}
191     SwCrsrMoveState( SwFillCrsrPos *pInitFill ) :
192         pFill( pInitFill ),
193         pSpecialPos( NULL ),
194         eState( MV_SETONLYTEXT ),
195         nCursorBidiLevel( 0 ),
196         bStop( sal_False ),
197         bRealHeight( sal_False ),
198         bFieldInfo( sal_False ),
199         bPosCorr( sal_False ),
200         bFtnNoInfo( sal_False ),
201         bExactOnly( sal_False ),
202         bSetInReadOnly( sal_False ),
203         bRealWidth( sal_False ),
204         b2Lines( sal_False ),
205         bNoScroll( sal_False ),
206         bPosMatchesBounds( sal_False ),
207         bCntntCheck( sal_False ), // --> FME 2005-05-13 #i43742# <--
208         bInFrontOfLabel( sal_False ), // #i27615#
209         bInNumPortion(sal_False), // #i23726#
210         nInNumPostionOffset(0) // #i23726#
211     {}
212 };
213 
214 
215 #endif
216 
217 
218