xref: /aoo41x/main/sw/source/core/text/portab.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 _PORTAB_HXX
24 #define _PORTAB_HXX
25 
26 #include "porglue.hxx"
27 
28 /*************************************************************************
29  *                      class SwTabPortion
30  *************************************************************************/
31 
32 class SwTabPortion : public SwFixPortion
33 {
34 	const KSHORT nTabPos;
35 	const xub_Unicode cFill;
36 
37 	// Das Format() verzweigt entweder in Pre- oder PostFormat()
38 	sal_Bool PreFormat( SwTxtFormatInfo &rInf );
39 public:
40 	SwTabPortion( const KSHORT nTabPos, const xub_Unicode cFill = '\0' );
41 	virtual void Paint( const SwTxtPaintInfo &rInf ) const;
42 	virtual sal_Bool Format( SwTxtFormatInfo &rInf );
43 	virtual void FormatEOL( SwTxtFormatInfo &rInf );
44 	sal_Bool PostFormat( SwTxtFormatInfo &rInf );
IsFilled() const45 	inline  sal_Bool IsFilled() const { return 0 != cFill; }
GetTabPos() const46 	inline  KSHORT GetTabPos() const { return nTabPos; }
47 
48     // Accessibility: pass information about this portion to the PortionHandler
49     virtual void HandlePortion( SwPortionHandler& rPH ) const;
50 
51 	OUTPUT_OPERATOR
52 };
53 
54 /*************************************************************************
55  *                  class SwTabLeftPortion
56  *************************************************************************/
57 
58 class SwTabLeftPortion : public SwTabPortion
59 {
60 public:
SwTabLeftPortion(const KSHORT nTabPosVal,const xub_Unicode cFillChar='\\0')61     inline SwTabLeftPortion( const KSHORT nTabPosVal, const xub_Unicode cFillChar='\0' )
62          : SwTabPortion( nTabPosVal, cFillChar )
63 	{ SetWhichPor( POR_TABLEFT ); }
64 	OUTPUT_OPERATOR
65 };
66 
67 /*************************************************************************
68  *                  class SwTabRightPortion
69  *************************************************************************/
70 
71 class SwTabRightPortion : public SwTabPortion
72 {
73 public:
SwTabRightPortion(const KSHORT nTabPosVal,const xub_Unicode cFillChar='\\0')74     inline SwTabRightPortion( const KSHORT nTabPosVal, const xub_Unicode cFillChar='\0' )
75          : SwTabPortion( nTabPosVal, cFillChar )
76 	{ SetWhichPor( POR_TABRIGHT ); }
77 	OUTPUT_OPERATOR
78 };
79 
80 /*************************************************************************
81  *                  class SwTabCenterPortion
82  *************************************************************************/
83 
84 class SwTabCenterPortion : public SwTabPortion
85 {
86 public:
SwTabCenterPortion(const KSHORT nTabPosVal,const xub_Unicode cFillChar='\\0')87     inline SwTabCenterPortion( const KSHORT nTabPosVal, const xub_Unicode cFillChar='\0' )
88          : SwTabPortion( nTabPosVal, cFillChar )
89 	{ SetWhichPor( POR_TABCENTER );	}
90 	OUTPUT_OPERATOR
91 };
92 
93 /*************************************************************************
94  *                  class SwTabDecimalPortion
95  *************************************************************************/
96 
97 class SwTabDecimalPortion : public SwTabPortion
98 {
99     const xub_Unicode mcTab;
100 
101     /*
102      * During text formatting, we already store the width of the portions
103      * following the tab stop up to the decimal position. This value is
104      * evaluated during pLastTab->FormatEOL. FME 2006-01-06 #127428#.
105      */
106     sal_uInt16 mnWidthOfPortionsUpTpDecimalPosition;
107 
108 public:
SwTabDecimalPortion(const KSHORT nTabPosVal,const xub_Unicode cTab,const xub_Unicode cFillChar='\\0')109     inline SwTabDecimalPortion( const KSHORT nTabPosVal, const xub_Unicode cTab,
110                                 const xub_Unicode cFillChar = '\0' )
111          : SwTabPortion( nTabPosVal, cFillChar ),
112            mcTab(cTab),
113            mnWidthOfPortionsUpTpDecimalPosition( USHRT_MAX )
114 	{ SetWhichPor( POR_TABDECIMAL ); }
115 
GetTabDecimal() const116     inline xub_Unicode GetTabDecimal() const { return mcTab; }
117 
SetWidthOfPortionsUpToDecimalPosition(sal_uInt16 nNew)118     inline void SetWidthOfPortionsUpToDecimalPosition( sal_uInt16 nNew )
119     {
120         mnWidthOfPortionsUpTpDecimalPosition = nNew;
121     }
GetWidthOfPortionsUpToDecimalPosition() const122     inline sal_uInt16 GetWidthOfPortionsUpToDecimalPosition() const
123     {
124         return mnWidthOfPortionsUpTpDecimalPosition;
125     }
126 
127 	OUTPUT_OPERATOR
128 };
129 
130 
131 /*************************************************************************
132  *                  class SwAutoTabDecimalPortion
133  *************************************************************************/
134 
135 class SwAutoTabDecimalPortion : public SwTabDecimalPortion
136 {
137 public:
SwAutoTabDecimalPortion(const KSHORT nTabPosVal,const xub_Unicode cTab,const xub_Unicode cFillChar='\\0')138     inline SwAutoTabDecimalPortion( const KSHORT nTabPosVal, const xub_Unicode cTab,
139                                     const xub_Unicode cFillChar = '\0' )
140          : SwTabDecimalPortion( nTabPosVal, cTab, cFillChar )
141     { SetLen( 0 ); }
142     virtual void Paint( const SwTxtPaintInfo &rInf ) const;
143 };
144 
145 
146 CLASSIO( SwTabPortion )
147 CLASSIO( SwTabLeftPortion )
148 CLASSIO( SwTabRightPortion )
149 CLASSIO( SwTabCenterPortion )
150 CLASSIO( SwTabDecimalPortion )
151 
152 
153 #endif
154