1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: porrst.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #define LINE_BREAK_WIDTH 150
36 #define SPECIAL_FONT_HEIGHT 200
38 class SwTxtFormatInfo
;
40 /*************************************************************************
41 * class SwTmpEndPortion
42 *************************************************************************/
44 class SwTmpEndPortion
: public SwLinePortion
47 SwTmpEndPortion( const SwLinePortion
&rPortion
);
48 virtual void Paint( const SwTxtPaintInfo
&rInf
) const;
52 /*************************************************************************
53 * class SwBreakPortion
54 *************************************************************************/
56 class SwBreakPortion
: public SwLinePortion
59 SwBreakPortion( const SwLinePortion
&rPortion
);
60 // liefert 0 zurueck, wenn keine Nutzdaten enthalten sind.
61 virtual SwLinePortion
*Compress();
62 virtual void Paint( const SwTxtPaintInfo
&rInf
) const;
63 virtual sal_Bool
Format( SwTxtFormatInfo
&rInf
);
64 virtual KSHORT
GetViewWidth( const SwTxtSizeInfo
&rInf
) const;
65 virtual xub_StrLen
GetCrsrOfst( const MSHORT nOfst
) const;
67 // Accessibility: pass information about this portion to the PortionHandler
68 virtual void HandlePortion( SwPortionHandler
& rPH
) const;
73 /*************************************************************************
75 *************************************************************************/
77 class SwKernPortion
: public SwLinePortion
85 // This constructor automatically appends the portion to rPortion
86 // bBG indicates, that the background of the kerning portion has to
87 // be painted, e.g., if the portion if positioned between to fields.
88 // bGridKern indicates, that the kerning portion is used to provide
89 // additional space in grid mode.
90 SwKernPortion( SwLinePortion
&rPortion
, short nKrn
,
91 sal_Bool bBG
= sal_False
, sal_Bool bGridKern
= sal_False
);
93 // This constructor only sets the height and ascent to the values
94 // of rPortion. It is only used for kerning portions for grid mode
95 SwKernPortion( const SwLinePortion
&rPortion
);
97 virtual void FormatEOL( SwTxtFormatInfo
&rInf
);
98 virtual void Paint( const SwTxtPaintInfo
&rInf
) const;
103 /*************************************************************************
104 * class SwArrowPortion
105 *************************************************************************/
107 class SwArrowPortion
: public SwLinePortion
112 SwArrowPortion( const SwLinePortion
&rPortion
);
113 SwArrowPortion( const SwTxtPaintInfo
&rInf
);
114 virtual void Paint( const SwTxtPaintInfo
&rInf
) const;
115 virtual SwLinePortion
*Compress();
116 inline sal_Bool
IsLeft() const { return bLeft
; }
117 inline const Point
& GetPos() const { return aPos
; }
121 /*************************************************************************
122 * class SwHangingPortion
123 * The characters which are forbidden at the start of a line like the dot and
124 * other punctuation marks are allowed to display in the margin of the page
126 * The SwHangingPortion is the corresponding textportion to do that.
127 *************************************************************************/
129 class SwHangingPortion
: public SwTxtPortion
133 inline SwHangingPortion( SwPosSize aSize
) : nInnerWidth( aSize
.Width() )
134 { SetWhichPor( POR_HNG
); SetLen( 1 ); Height( aSize
.Height() ); }
136 inline KSHORT
GetInnerWidth() const { return nInnerWidth
; }
139 /*************************************************************************
140 * class SwHiddenTextPortion
141 * Is used to hide text
142 *************************************************************************/
144 class SwHiddenTextPortion
: public SwLinePortion
147 inline SwHiddenTextPortion( xub_StrLen nLen
)
148 { SetWhichPor( POR_HIDDEN_TXT
); SetLen( nLen
); }
150 virtual void Paint( const SwTxtPaintInfo
&rInf
) const;
151 virtual sal_Bool
Format( SwTxtFormatInfo
&rInf
);
154 /*************************************************************************
155 * class SwControlCharPortion
156 *************************************************************************/
158 class SwControlCharPortion
: public SwLinePortion
162 mutable USHORT mnViewWidth
; // used to cache a calculated value
163 mutable USHORT mnHalfCharWidth
; // used to cache a calculated value
168 inline SwControlCharPortion( sal_Unicode cChar
)
169 : mnViewWidth( 0 ), mnHalfCharWidth( 0 ), mcChar( cChar
)
171 SetWhichPor( POR_CONTROLCHAR
); SetLen( 1 );
174 virtual void Paint( const SwTxtPaintInfo
&rInf
) const;
175 virtual sal_Bool
Format( SwTxtFormatInfo
&rInf
);
176 virtual KSHORT
GetViewWidth( const SwTxtSizeInfo
& rInf
) const;
181 /*************************************************************************
182 * inline - Implementations
183 *************************************************************************/
185 CLASSIO( SwBreakPortion
)
186 CLASSIO( SwEndPortion
)
187 CLASSIO( SwKernPortion
)
188 CLASSIO( SwArrowPortion
)