xref: /aoo41x/main/sw/source/core/text/porglue.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 _PORGLUE_HXX
24 #define _PORGLUE_HXX
25 
26 //#include <stdlib.h>
27 
28 #include "porlin.hxx"
29 
30 class SwRect;
31 class SwLineLayout;
32 
33 /*************************************************************************
34  *						class SwGluePortion
35  *************************************************************************/
36 
37 class SwGluePortion : public SwLinePortion
38 {
39 private:
40 	KSHORT nFixWidth;
41 public:
42 				SwGluePortion( const KSHORT nInitFixWidth );
43 
44 	void Join( SwGluePortion *pVictim );
45 
46 	inline short GetPrtGlue() const;
GetFixWidth() const47 	inline KSHORT GetFixWidth() const { return nFixWidth; }
SetFixWidth(const KSHORT nNew)48 	inline void SetFixWidth( const KSHORT nNew ) { nFixWidth = nNew; }
49 	void MoveGlue( SwGluePortion *pTarget, const short nPrtGlue );
50 	inline void MoveAllGlue( SwGluePortion *pTarget );
51 	inline void MoveHalfGlue( SwGluePortion *pTarget );
52 	inline void AdjFixWidth();
53 	virtual void Paint( const SwTxtPaintInfo &rInf ) const;
54 	virtual xub_StrLen GetCrsrOfst( const KSHORT nOfst ) const;
55 	virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const;
56 	virtual sal_Bool GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) const;
57 
58 	OUTPUT_OPERATOR
59 };
60 
61 /*************************************************************************
62  *						class SwFixPortion
63  *************************************************************************/
64 
65 class SwFixPortion : public SwGluePortion
66 {
67 	KSHORT nFix;		// der Width-Offset in der Zeile
68 public:
69 		SwFixPortion( const SwRect &rFlyRect );
70 		SwFixPortion( const KSHORT nFixWidth, const KSHORT nFixPos );
Fix(const KSHORT nNewFix)71 	inline void   Fix( const KSHORT nNewFix ) { nFix = nNewFix; }
Fix() const72 	inline KSHORT Fix() const { return nFix; }
73 	OUTPUT_OPERATOR
74 };
75 
76 /*************************************************************************
77  *				  class SwMarginPortion
78  *************************************************************************/
79 
80 class SwMarginPortion : public SwGluePortion
81 {
82 public:
83 		SwMarginPortion( const KSHORT nFixWidth );
84 		void AdjustRight( const SwLineLayout* pCurr );
85 	OUTPUT_OPERATOR
86 };
87 
88 /*************************************************************************
89  *				  inline SwGluePortion::GetPrtGlue()
90  *************************************************************************/
91 
GetPrtGlue() const92 inline short SwGluePortion::GetPrtGlue() const
93 { return Width() - nFixWidth; }
94 
95 /*************************************************************************
96  *				inline SwGluePortion::AdjFixWidth()
97  * Die FixWidth darf niemals groesser sein als die Gesamtbreite !
98  *************************************************************************/
99 
AdjFixWidth()100 inline void SwGluePortion::AdjFixWidth()
101 {
102 	if( nFixWidth > PrtWidth() )
103 		nFixWidth = PrtWidth();
104 }
105 
106 /*************************************************************************
107  *				   inline SwGluePortion::MoveGlue()
108  *************************************************************************/
109 
MoveAllGlue(SwGluePortion * pTarget)110 inline void SwGluePortion::MoveAllGlue( SwGluePortion *pTarget )
111 {
112 	MoveGlue( pTarget, GetPrtGlue() );
113 }
114 
115 /*************************************************************************
116  *				  inline SwGluePortion::MoveHalfGlue()
117  *************************************************************************/
118 
MoveHalfGlue(SwGluePortion * pTarget)119 inline void SwGluePortion::MoveHalfGlue( SwGluePortion *pTarget )
120 {
121 	MoveGlue( pTarget, GetPrtGlue() / 2 );
122 }
123 
124 CLASSIO( SwGluePortion )
125 CLASSIO( SwFixPortion )
126 CLASSIO( SwMarginPortion )
127 
128 
129 #endif
130 
131