update dev300-m58
[ooovba.git] / sw / source / core / text / porglue.hxx
blob8c31c035265590d9d981b2ac68f10474edb970fe
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: porglue.hxx,v $
10 * $Revision: 1.8 $
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 ************************************************************************/
30 #ifndef _PORGLUE_HXX
31 #define _PORGLUE_HXX
33 //#include <stdlib.h>
35 #include "porlin.hxx"
37 class SwRect;
38 class SwLineLayout;
40 /*************************************************************************
41 * class SwGluePortion
42 *************************************************************************/
44 class SwGluePortion : public SwLinePortion
46 private:
47 KSHORT nFixWidth;
48 public:
49 SwGluePortion( const KSHORT nInitFixWidth );
51 void Join( SwGluePortion *pVictim );
53 inline short GetPrtGlue() const;
54 inline KSHORT GetFixWidth() const { return nFixWidth; }
55 inline void SetFixWidth( const KSHORT nNew ) { nFixWidth = nNew; }
56 void MoveGlue( SwGluePortion *pTarget, const short nPrtGlue );
57 inline void MoveAllGlue( SwGluePortion *pTarget );
58 inline void MoveHalfGlue( SwGluePortion *pTarget );
59 inline void AdjFixWidth();
60 virtual void Paint( const SwTxtPaintInfo &rInf ) const;
61 virtual xub_StrLen GetCrsrOfst( const KSHORT nOfst ) const;
62 virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const;
63 virtual sal_Bool GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) const;
65 OUTPUT_OPERATOR
68 /*************************************************************************
69 * class SwFixPortion
70 *************************************************************************/
72 class SwFixPortion : public SwGluePortion
74 KSHORT nFix; // der Width-Offset in der Zeile
75 public:
76 SwFixPortion( const SwRect &rFlyRect );
77 SwFixPortion( const KSHORT nFixWidth, const KSHORT nFixPos );
78 inline void Fix( const KSHORT nNewFix ) { nFix = nNewFix; }
79 inline KSHORT Fix() const { return nFix; }
80 OUTPUT_OPERATOR
83 /*************************************************************************
84 * class SwMarginPortion
85 *************************************************************************/
87 class SwMarginPortion : public SwGluePortion
89 public:
90 SwMarginPortion( const KSHORT nFixWidth );
91 void AdjustRight( const SwLineLayout* pCurr );
92 OUTPUT_OPERATOR
95 /*************************************************************************
96 * inline SwGluePortion::GetPrtGlue()
97 *************************************************************************/
99 inline short SwGluePortion::GetPrtGlue() const
100 { return Width() - nFixWidth; }
102 /*************************************************************************
103 * inline SwGluePortion::AdjFixWidth()
104 * Die FixWidth darf niemals groesser sein als die Gesamtbreite !
105 *************************************************************************/
107 inline void SwGluePortion::AdjFixWidth()
109 if( nFixWidth > PrtWidth() )
110 nFixWidth = PrtWidth();
113 /*************************************************************************
114 * inline SwGluePortion::MoveGlue()
115 *************************************************************************/
117 inline void SwGluePortion::MoveAllGlue( SwGluePortion *pTarget )
119 MoveGlue( pTarget, GetPrtGlue() );
122 /*************************************************************************
123 * inline SwGluePortion::MoveHalfGlue()
124 *************************************************************************/
126 inline void SwGluePortion::MoveHalfGlue( SwGluePortion *pTarget )
128 MoveGlue( pTarget, GetPrtGlue() / 2 );
131 CLASSIO( SwGluePortion )
132 CLASSIO( SwFixPortion )
133 CLASSIO( SwMarginPortion )
136 #endif