xref: /aoo42x/main/sw/source/core/text/porrst.hxx (revision 1d2dbeb0)
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 _PORRST_HXX
24 #define _PORRST_HXX
25 #include "porlay.hxx"
26 #include "porexp.hxx"
27 
28 #define LINE_BREAK_WIDTH        150
29 #define SPECIAL_FONT_HEIGHT     200
30 
31 class SwTxtFormatInfo;
32 
33 /*************************************************************************
34  *						class SwTmpEndPortion
35  *************************************************************************/
36 
37 class SwTmpEndPortion : public SwLinePortion
38 {
39 public:
40 			SwTmpEndPortion( const SwLinePortion &rPortion );
41 	virtual void Paint( const SwTxtPaintInfo &rInf ) const;
42 	OUTPUT_OPERATOR
43 };
44 
45 /*************************************************************************
46  *						class SwBreakPortion
47  *************************************************************************/
48 
49 class SwBreakPortion : public SwLinePortion
50 {
51 public:
52 			SwBreakPortion( const SwLinePortion &rPortion );
53 	// liefert 0 zurueck, wenn keine Nutzdaten enthalten sind.
54 	virtual SwLinePortion *Compress();
55 	virtual void Paint( const SwTxtPaintInfo &rInf ) const;
56 	virtual sal_Bool Format( SwTxtFormatInfo &rInf );
57 	virtual KSHORT GetViewWidth( const SwTxtSizeInfo &rInf ) const;
58     virtual xub_StrLen GetCrsrOfst( const MSHORT nOfst ) const;
59 
60     // Accessibility: pass information about this portion to the PortionHandler
61     virtual void HandlePortion( SwPortionHandler& rPH ) const;
62 
63 	OUTPUT_OPERATOR
64 };
65 
66 /*************************************************************************
67  *						class SwKernPortion
68  *************************************************************************/
69 
70 class SwKernPortion : public SwLinePortion
71 {
72 	short nKern;
73     sal_Bool bBackground;
74     sal_Bool bGridKern;
75 
76 public:
77 
78     // This constructor automatically appends the portion to rPortion
79     // bBG indicates, that the background of the kerning portion has to
80     // be painted, e.g., if the portion if positioned between to fields.
81     // bGridKern indicates, that the kerning portion is used to provide
82     // additional space in grid mode.
83     SwKernPortion( SwLinePortion &rPortion, short nKrn,
84                    sal_Bool bBG = sal_False, sal_Bool bGridKern = sal_False );
85 
86     // This constructor only sets the height and ascent to the values
87     // of rPortion. It is only used for kerning portions for grid mode
88     SwKernPortion( const SwLinePortion &rPortion );
89 
90 	virtual void FormatEOL( SwTxtFormatInfo &rInf );
91 	virtual void Paint( const SwTxtPaintInfo &rInf ) const;
92 
93 	OUTPUT_OPERATOR
94 };
95 
96 /*************************************************************************
97  *						class SwArrowPortion
98  *************************************************************************/
99 
100 class SwArrowPortion : public SwLinePortion
101 {
102 	Point aPos;
103 	sal_Bool bLeft;
104 public:
105 			SwArrowPortion( const SwLinePortion &rPortion );
106 			SwArrowPortion( const SwTxtPaintInfo &rInf );
107 	virtual void Paint( const SwTxtPaintInfo &rInf ) const;
108 	virtual SwLinePortion *Compress();
IsLeft() const109 	inline sal_Bool IsLeft() const { return bLeft; }
GetPos() const110 	inline const Point& GetPos() const { return aPos; }
111 	OUTPUT_OPERATOR
112 };
113 
114 /*************************************************************************
115  *						class SwHangingPortion
116  * The characters which are forbidden at the start of a line like the dot and
117  * other punctuation marks are allowed to display in the margin of the page
118  * by a user option.
119  * The SwHangingPortion is the corresponding textportion to do that.
120  *************************************************************************/
121 
122 class SwHangingPortion : public SwTxtPortion
123 {
124 	KSHORT nInnerWidth;
125 public:
SwHangingPortion(SwPosSize aSize)126 	inline SwHangingPortion( SwPosSize aSize ) : nInnerWidth( aSize.Width() )
127 		{ SetWhichPor( POR_HNG );  SetLen( 1 ); Height( aSize.Height() ); }
128 
GetInnerWidth() const129 	inline KSHORT GetInnerWidth() const { return nInnerWidth; }
130 };
131 
132 /*************************************************************************
133  *                      class SwHiddenTextPortion
134  * Is used to hide text
135  *************************************************************************/
136 
137 class SwHiddenTextPortion : public SwLinePortion
138 {
139 public:
SwHiddenTextPortion(xub_StrLen nLen)140     inline SwHiddenTextPortion( xub_StrLen nLen )
141         { SetWhichPor( POR_HIDDEN_TXT );  SetLen( nLen ); }
142 
143     virtual void Paint( const SwTxtPaintInfo &rInf ) const;
144     virtual sal_Bool Format( SwTxtFormatInfo &rInf );
145 };
146 
147 /*************************************************************************
148  *                      class SwControlCharPortion
149  *************************************************************************/
150 
151 class SwControlCharPortion : public SwLinePortion
152 {
153 
154 private:
155     mutable sal_uInt16 mnViewWidth;            // used to cache a calculated value
156     mutable sal_uInt16 mnHalfCharWidth;        // used to cache a calculated value
157     sal_Unicode mcChar;
158 
159 public:
160 
SwControlCharPortion(sal_Unicode cChar)161     inline SwControlCharPortion( sal_Unicode cChar )
162         : mnViewWidth( 0 ), mnHalfCharWidth( 0 ), mcChar( cChar )
163     {
164         SetWhichPor( POR_CONTROLCHAR ); SetLen( 1 );
165     }
166 
167     virtual void Paint( const SwTxtPaintInfo &rInf ) const;
168     virtual sal_Bool Format( SwTxtFormatInfo &rInf );
169     virtual KSHORT GetViewWidth( const SwTxtSizeInfo& rInf ) const;
170 };
171 
172 
173 
174 /*************************************************************************
175  *					inline - Implementations
176  *************************************************************************/
177 
178 CLASSIO( SwBreakPortion )
179 CLASSIO( SwEndPortion )
180 CLASSIO( SwKernPortion )
181 CLASSIO( SwArrowPortion )
182 
183 #endif
184