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