1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
27 /// A glue portion is either a base class for other portions that want to have a certain width to
28 /// push text out (e.g. tab portions) or used to align SwQuoVadisPortion instances on the right for
30 class SwGluePortion
: public SwLinePortion
33 sal_uInt16 m_nFixWidth
;
35 explicit SwGluePortion( const sal_uInt16 nInitFixWidth
);
37 void Join( SwGluePortion
*pVictim
);
39 inline tools::Long
GetPrtGlue() const;
40 sal_uInt16
GetFixWidth() const { return m_nFixWidth
; }
41 void SetFixWidth( const sal_uInt16 nNew
) { m_nFixWidth
= nNew
; }
42 void MoveGlue( SwGluePortion
*pTarget
, const tools::Long nPrtGlue
);
43 inline void MoveAllGlue( SwGluePortion
*pTarget
);
44 inline void MoveHalfGlue( SwGluePortion
*pTarget
);
45 inline void AdjFixWidth();
46 virtual void Paint( const SwTextPaintInfo
&rInf
) const override
;
47 virtual TextFrameIndex
GetModelPositionForViewPoint(sal_uInt16 nOfst
) const override
;
48 virtual SwPosSize
GetTextSize( const SwTextSizeInfo
&rInfo
) const override
;
49 virtual bool GetExpText( const SwTextSizeInfo
&rInf
, OUString
&rText
) const override
;
51 void dumpAsXml(xmlTextWriterPtr pWriter
, const OUString
& rText
, TextFrameIndex
& nOffset
) const override
;
54 class SwFixPortion
: public SwGluePortion
56 sal_uInt16 m_nFix
; // The width offset in the line
58 explicit SwFixPortion( const SwRect
&rFlyRect
);
60 void SetFix( const sal_uInt16 nNewFix
) { m_nFix
= nNewFix
; }
61 sal_uInt16
GetFix() const { return m_nFix
; }
63 void dumpAsXml(xmlTextWriterPtr pWriter
, const OUString
& rText
, TextFrameIndex
& nOffset
) const override
;
66 class SwMarginPortion
: public SwGluePortion
69 explicit SwMarginPortion();
70 void AdjustRight( const SwLineLayout
* pCurr
);
73 inline tools::Long
SwGluePortion::GetPrtGlue() const
74 { return Width() - m_nFixWidth
; }
76 // The FixWidth MUST NEVER be larger than the accumulated width!
77 inline void SwGluePortion::AdjFixWidth()
79 if( m_nFixWidth
> PrtWidth() )
80 m_nFixWidth
= PrtWidth();
83 inline void SwGluePortion::MoveAllGlue( SwGluePortion
*pTarget
)
85 MoveGlue( pTarget
, GetPrtGlue() );
88 inline void SwGluePortion::MoveHalfGlue( SwGluePortion
*pTarget
)
90 MoveGlue( pTarget
, GetPrtGlue() / 2 );
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */