Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _PORGLUE_HXX
29 : : #define _PORGLUE_HXX
30 : :
31 : : #include "porlin.hxx"
32 : :
33 : : class SwRect;
34 : : class SwLineLayout;
35 : :
36 : : /*************************************************************************
37 : : * class SwGluePortion
38 : : *************************************************************************/
39 : :
40 [ - + ]: 2854 : class SwGluePortion : public SwLinePortion
41 : : {
42 : : private:
43 : : KSHORT nFixWidth;
44 : : public:
45 : : SwGluePortion( const KSHORT nInitFixWidth );
46 : :
47 : : void Join( SwGluePortion *pVictim );
48 : :
49 : : inline short GetPrtGlue() const;
50 : 123 : inline KSHORT GetFixWidth() const { return nFixWidth; }
51 : 209 : inline void SetFixWidth( const KSHORT nNew ) { nFixWidth = nNew; }
52 : : void MoveGlue( SwGluePortion *pTarget, const short nPrtGlue );
53 : : inline void MoveAllGlue( SwGluePortion *pTarget );
54 : : inline void MoveHalfGlue( SwGluePortion *pTarget );
55 : : inline void AdjFixWidth();
56 : : virtual void Paint( const SwTxtPaintInfo &rInf ) const;
57 : : virtual xub_StrLen GetCrsrOfst( const KSHORT nOfst ) const;
58 : : virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const;
59 : : virtual sal_Bool GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) const;
60 : :
61 : : OUTPUT_OPERATOR
62 : : };
63 : :
64 : : /*************************************************************************
65 : : * class SwFixPortion
66 : : *************************************************************************/
67 : :
68 [ - + ]: 936 : class SwFixPortion : public SwGluePortion
69 : : {
70 : : KSHORT nFix; // The width offset in the line
71 : : public:
72 : : SwFixPortion( const SwRect &rFlyRect );
73 : : SwFixPortion( const KSHORT nFixWidth, const KSHORT nFixPos );
74 : 207 : inline void Fix( const KSHORT nNewFix ) { nFix = nNewFix; }
75 : 1617 : inline KSHORT Fix() const { return nFix; }
76 : : OUTPUT_OPERATOR
77 : : };
78 : :
79 : : /*************************************************************************
80 : : * class SwMarginPortion
81 : : *************************************************************************/
82 : :
83 [ - + ]: 3836 : class SwMarginPortion : public SwGluePortion
84 : : {
85 : : public:
86 : : SwMarginPortion( const KSHORT nFixWidth );
87 : : void AdjustRight( const SwLineLayout* pCurr );
88 : : OUTPUT_OPERATOR
89 : : };
90 : :
91 : : /*************************************************************************
92 : : * inline SwGluePortion::GetPrtGlue()
93 : : *************************************************************************/
94 : :
95 : 1790 : inline short SwGluePortion::GetPrtGlue() const
96 : 1790 : { return Width() - nFixWidth; }
97 : :
98 : : /*************************************************************************
99 : : * inline SwGluePortion::AdjFixWidth()
100 : : * The FixWidth MUST NEVER be larger than the accumulated width!
101 : : *************************************************************************/
102 : :
103 : 3 : inline void SwGluePortion::AdjFixWidth()
104 : : {
105 [ - + ]: 3 : if( nFixWidth > PrtWidth() )
106 : 0 : nFixWidth = PrtWidth();
107 : 3 : }
108 : :
109 : : /*************************************************************************
110 : : * inline SwGluePortion::MoveGlue()
111 : : *************************************************************************/
112 : :
113 : 3 : inline void SwGluePortion::MoveAllGlue( SwGluePortion *pTarget )
114 : : {
115 : 3 : MoveGlue( pTarget, GetPrtGlue() );
116 : 3 : }
117 : :
118 : : /*************************************************************************
119 : : * inline SwGluePortion::MoveHalfGlue()
120 : : *************************************************************************/
121 : :
122 : 882 : inline void SwGluePortion::MoveHalfGlue( SwGluePortion *pTarget )
123 : : {
124 : 882 : MoveGlue( pTarget, GetPrtGlue() / 2 );
125 : 882 : }
126 : :
127 : : CLASSIO( SwGluePortion )
128 : : CLASSIO( SwFixPortion )
129 : : CLASSIO( SwMarginPortion )
130 : :
131 : :
132 : : #endif
133 : :
134 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|