Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef _PORGLUE_HXX
20 : #define _PORGLUE_HXX
21 :
22 : #include "porlin.hxx"
23 :
24 : class SwRect;
25 : class SwLineLayout;
26 :
27 : /*************************************************************************
28 : * class SwGluePortion
29 : *************************************************************************/
30 :
31 184 : class SwGluePortion : public SwLinePortion
32 : {
33 : private:
34 : KSHORT nFixWidth;
35 : public:
36 : SwGluePortion( const KSHORT nInitFixWidth );
37 :
38 : void Join( SwGluePortion *pVictim );
39 :
40 : inline short GetPrtGlue() const;
41 10 : inline KSHORT GetFixWidth() const { return nFixWidth; }
42 69 : inline void SetFixWidth( const KSHORT nNew ) { nFixWidth = nNew; }
43 : void MoveGlue( SwGluePortion *pTarget, const short nPrtGlue );
44 : inline void MoveAllGlue( SwGluePortion *pTarget );
45 : inline void MoveHalfGlue( SwGluePortion *pTarget );
46 : inline void AdjFixWidth();
47 : virtual void Paint( const SwTxtPaintInfo &rInf ) const;
48 : virtual xub_StrLen GetCrsrOfst( const KSHORT nOfst ) const;
49 : virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const;
50 : virtual sal_Bool GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) const;
51 :
52 : OUTPUT_OPERATOR
53 : };
54 :
55 : /*************************************************************************
56 : * class SwFixPortion
57 : *************************************************************************/
58 :
59 144 : class SwFixPortion : public SwGluePortion
60 : {
61 : KSHORT nFix; // The width offset in the line
62 : public:
63 : SwFixPortion( const SwRect &rFlyRect );
64 : SwFixPortion( const KSHORT nFixWidth, const KSHORT nFixPos );
65 69 : inline void Fix( const KSHORT nNewFix ) { nFix = nNewFix; }
66 166 : inline KSHORT Fix() const { return nFix; }
67 : OUTPUT_OPERATOR
68 : };
69 :
70 : /*************************************************************************
71 : * class SwMarginPortion
72 : *************************************************************************/
73 :
74 80 : class SwMarginPortion : public SwGluePortion
75 : {
76 : public:
77 : SwMarginPortion( const KSHORT nFixWidth );
78 : void AdjustRight( const SwLineLayout* pCurr );
79 : OUTPUT_OPERATOR
80 : };
81 :
82 : /*************************************************************************
83 : * inline SwGluePortion::GetPrtGlue()
84 : *************************************************************************/
85 :
86 40 : inline short SwGluePortion::GetPrtGlue() const
87 40 : { return Width() - nFixWidth; }
88 :
89 : /*************************************************************************
90 : * inline SwGluePortion::AdjFixWidth()
91 : * The FixWidth MUST NEVER be larger than the accumulated width!
92 : *************************************************************************/
93 :
94 1 : inline void SwGluePortion::AdjFixWidth()
95 : {
96 1 : if( nFixWidth > PrtWidth() )
97 0 : nFixWidth = PrtWidth();
98 1 : }
99 :
100 : /*************************************************************************
101 : * inline SwGluePortion::MoveGlue()
102 : *************************************************************************/
103 :
104 2 : inline void SwGluePortion::MoveAllGlue( SwGluePortion *pTarget )
105 : {
106 2 : MoveGlue( pTarget, GetPrtGlue() );
107 2 : }
108 :
109 : /*************************************************************************
110 : * inline SwGluePortion::MoveHalfGlue()
111 : *************************************************************************/
112 :
113 17 : inline void SwGluePortion::MoveHalfGlue( SwGluePortion *pTarget )
114 : {
115 17 : MoveGlue( pTarget, GetPrtGlue() / 2 );
116 17 : }
117 :
118 : CLASSIO( SwGluePortion )
119 : CLASSIO( SwFixPortion )
120 : CLASSIO( SwMarginPortion )
121 :
122 :
123 : #endif
124 :
125 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|