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