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 .
21 #include "porglue.hxx"
23 class SwTabPortion
: public SwFixPortion
25 const sal_uInt16 m_nTabPos
;
26 const sal_Unicode m_cFill
;
27 const bool m_bAutoTabStop
;
29 // Format() branches either into PreFormat() or PostFormat()
30 bool PreFormat( SwTextFormatInfo
&rInf
);
32 SwTabPortion( const sal_uInt16 nTabPos
, const sal_Unicode cFill
, const bool bAutoTab
= true );
33 virtual void Paint( const SwTextPaintInfo
&rInf
) const override
;
34 virtual bool Format( SwTextFormatInfo
&rInf
) override
;
35 virtual void FormatEOL( SwTextFormatInfo
&rInf
) override
;
36 bool PostFormat( SwTextFormatInfo
&rInf
);
37 bool IsFilled() const { return 0 != m_cFill
; }
38 sal_uInt16
GetTabPos() const { return m_nTabPos
; }
40 // Accessibility: pass information about this portion to the PortionHandler
41 virtual void HandlePortion( SwPortionHandler
& rPH
) const override
;
44 class SwTabLeftPortion
: public SwTabPortion
47 SwTabLeftPortion( const sal_uInt16 nTabPosVal
, const sal_Unicode cFillChar
, bool bAutoTab
)
48 : SwTabPortion( nTabPosVal
, cFillChar
, bAutoTab
)
49 { SetWhichPor( PortionType::TabLeft
); }
52 class SwTabRightPortion
: public SwTabPortion
55 SwTabRightPortion( const sal_uInt16 nTabPosVal
, const sal_Unicode cFillChar
)
56 : SwTabPortion( nTabPosVal
, cFillChar
)
57 { SetWhichPor( PortionType::TabRight
); }
60 class SwTabCenterPortion
: public SwTabPortion
63 SwTabCenterPortion( const sal_uInt16 nTabPosVal
, const sal_Unicode cFillChar
)
64 : SwTabPortion( nTabPosVal
, cFillChar
)
65 { SetWhichPor( PortionType::TabCenter
); }
68 class SwTabDecimalPortion
: public SwTabPortion
70 const sal_Unicode mcTab
;
73 * During text formatting, we already store the width of the portions
74 * following the tab stop up to the decimal position. This value is
75 * evaluated during pLastTab->FormatEOL. FME 2006-01-06 #127428#.
77 sal_uInt16 mnWidthOfPortionsUpTpDecimalPosition
;
80 SwTabDecimalPortion( const sal_uInt16 nTabPosVal
, const sal_Unicode cTab
,
81 const sal_Unicode cFillChar
)
82 : SwTabPortion( nTabPosVal
, cFillChar
),
84 mnWidthOfPortionsUpTpDecimalPosition( USHRT_MAX
)
85 { SetWhichPor( PortionType::TabDecimal
); }
87 sal_Unicode
GetTabDecimal() const { return mcTab
; }
89 void SetWidthOfPortionsUpToDecimalPosition( sal_uInt16 nNew
)
91 mnWidthOfPortionsUpTpDecimalPosition
= nNew
;
93 sal_uInt16
GetWidthOfPortionsUpToDecimalPosition() const
95 return mnWidthOfPortionsUpTpDecimalPosition
;
99 class SwAutoTabDecimalPortion
: public SwTabDecimalPortion
102 SwAutoTabDecimalPortion( const sal_uInt16 nTabPosVal
, const sal_Unicode cTab
,
103 const sal_Unicode cFillChar
)
104 : SwTabDecimalPortion( nTabPosVal
, cTab
, cFillChar
)
106 SetLen(TextFrameIndex(0));
108 virtual void Paint( const SwTextPaintInfo
&rInf
) const override
;
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */