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 INCLUDED_SW_SOURCE_CORE_TEXT_PORGLUE_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_TEXT_PORGLUE_HXX
21 :
22 : #include "porlin.hxx"
23 :
24 : class SwRect;
25 : class SwLineLayout;
26 :
27 : /*************************************************************************
28 : * class SwGluePortion
29 : *************************************************************************/
30 :
31 0 : 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 0 : inline KSHORT GetFixWidth() const { return nFixWidth; }
42 0 : 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 SAL_OVERRIDE;
48 : virtual sal_Int32 GetCrsrOfst( const KSHORT nOfst ) const SAL_OVERRIDE;
49 : virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const SAL_OVERRIDE;
50 : virtual bool GetExpTxt( const SwTxtSizeInfo &rInf, OUString &rTxt ) const SAL_OVERRIDE;
51 :
52 : OUTPUT_OPERATOR_OVERRIDE
53 : };
54 :
55 : /*************************************************************************
56 : * class SwFixPortion
57 : *************************************************************************/
58 :
59 0 : 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 0 : inline void Fix( const KSHORT nNewFix ) { nFix = nNewFix; }
66 0 : inline KSHORT Fix() const { return nFix; }
67 : OUTPUT_OPERATOR_OVERRIDE
68 : };
69 :
70 : /*************************************************************************
71 : * class SwMarginPortion
72 : *************************************************************************/
73 :
74 0 : class SwMarginPortion : public SwGluePortion
75 : {
76 : public:
77 : SwMarginPortion( const KSHORT nFixWidth );
78 : void AdjustRight( const SwLineLayout* pCurr );
79 : OUTPUT_OPERATOR_OVERRIDE
80 : };
81 :
82 : /*************************************************************************
83 : * inline SwGluePortion::GetPrtGlue()
84 : *************************************************************************/
85 :
86 0 : inline short SwGluePortion::GetPrtGlue() const
87 0 : { return Width() - nFixWidth; }
88 :
89 : /*************************************************************************
90 : * inline SwGluePortion::AdjFixWidth()
91 : * The FixWidth MUST NEVER be larger than the accumulated width!
92 : *************************************************************************/
93 :
94 0 : inline void SwGluePortion::AdjFixWidth()
95 : {
96 0 : if( nFixWidth > PrtWidth() )
97 0 : nFixWidth = PrtWidth();
98 0 : }
99 :
100 : /*************************************************************************
101 : * inline SwGluePortion::MoveGlue()
102 : *************************************************************************/
103 :
104 0 : inline void SwGluePortion::MoveAllGlue( SwGluePortion *pTarget )
105 : {
106 0 : MoveGlue( pTarget, GetPrtGlue() );
107 0 : }
108 :
109 : /*************************************************************************
110 : * inline SwGluePortion::MoveHalfGlue()
111 : *************************************************************************/
112 :
113 0 : inline void SwGluePortion::MoveHalfGlue( SwGluePortion *pTarget )
114 : {
115 0 : MoveGlue( pTarget, GetPrtGlue() / 2 );
116 0 : }
117 :
118 : #endif
119 :
120 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|