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 .
19 #ifndef INCLUDED_SW_INC_FMTCLDS_HXX
20 #define INCLUDED_SW_INC_FMTCLDS_HXX
22 #include <editeng/borderline.hxx>
23 #include <tools/color.hxx>
24 #include <svl/poolitem.hxx>
26 #include <hintids.hxx>
34 sal_uInt16 m_nWish
; /**< Desired width, borders included.
35 It is inversely proportional to the ratio of
36 desired width environment / current width column. */
37 sal_uInt16 m_nLeft
; ///< Left border.
38 sal_uInt16 m_nRight
; ///< Right border.
43 bool operator==( const SwColumn
& ) const;
45 void SetWishWidth( sal_uInt16 nNew
) { m_nWish
= nNew
; }
46 void SetLeft ( sal_uInt16 nNew
) { m_nLeft
= nNew
; }
47 void SetRight( sal_uInt16 nNew
) { m_nRight
= nNew
; }
49 sal_uInt16
GetWishWidth() const { return m_nWish
; }
50 sal_uInt16
GetLeft () const { return m_nLeft
; }
51 sal_uInt16
GetRight() const { return m_nRight
; }
53 void dumpAsXml(struct _xmlTextWriter
* pWriter
) const;
56 typedef std::vector
<SwColumn
> SwColumns
;
66 class SW_DLLPUBLIC SwFormatCol
: public SfxPoolItem
68 SvxBorderLineStyle m_eLineStyle
; ///< style of the separator line
69 sal_uLong m_nLineWidth
; ///< Width of the separator line.
70 Color m_aLineColor
; ///< Color of the separator line.
72 sal_uInt16 m_nLineHeight
; /**< Percentile height of lines.
73 (Based on height of columns including UL). */
75 SwColLineAdj m_eAdj
; ///< Line will be adjusted top, centered or bottom.
77 SwColumns m_aColumns
; ///< Information concerning the columns.
78 sal_uInt16 m_nWidth
; ///< Total desired width of all columns.
79 sal_Int16 m_aWidthAdjustValue
;
81 bool m_bOrtho
; /**< Only if this flag is set, the setting of GutterWidth will
82 be accompanied by a "visual rearrangement".
83 The flag must be reset if widths of columns or borders are changed.
84 When it is set (again) the visual arrangement is recalculated.
85 The flag is initially set. */
87 SAL_DLLPRIVATE
void Calc( sal_uInt16 nGutterWidth
, sal_uInt16 nAct
);
91 SwFormatCol( const SwFormatCol
& );
92 virtual ~SwFormatCol() override
;
94 sal_Int16
GetAdjustValue() const { return m_aWidthAdjustValue
; }
95 void SetAdjustValue( sal_Int16 n
) { m_aWidthAdjustValue
= n
; }
97 SwFormatCol
& operator=( const SwFormatCol
& );
99 /// "pure virtual methods" of SfxPoolItem
100 virtual bool operator==( const SfxPoolItem
& ) const override
;
101 virtual SfxPoolItem
* Clone( SfxItemPool
* pPool
= nullptr ) const override
;
102 virtual bool GetPresentation( SfxItemPresentation ePres
,
106 const IntlWrapper
* pIntl
= nullptr ) const override
;
108 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
109 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
111 const SwColumns
&GetColumns() const { return m_aColumns
; }
112 SwColumns
&GetColumns() { return m_aColumns
; }
113 sal_uInt16
GetNumCols() const { return m_aColumns
.size(); }
115 SvxBorderLineStyle
GetLineStyle() const { return m_eLineStyle
;}
116 sal_uLong
GetLineWidth() const { return m_nLineWidth
;}
117 const Color
& GetLineColor() const { return m_aLineColor
;}
119 SwColLineAdj
GetLineAdj() const { return m_eAdj
; }
120 bool IsOrtho() const { return m_bOrtho
; }
121 sal_uInt16
GetWishWidth() const { return m_nWidth
; }
122 sal_uInt8
GetLineHeight()const { return m_nLineHeight
; }
124 /** @return USHRT_MAX if ambiguous.
125 @return smallest width if bMin is true. */
126 sal_uInt16
GetGutterWidth( bool bMin
= false ) const;
128 void SetLineStyle(SvxBorderLineStyle eStyle
) { m_eLineStyle
= eStyle
;}
129 void SetLineWidth(sal_uLong nLWidth
) { m_nLineWidth
= nLWidth
;}
130 void SetLineColor(const Color
& rCol
) { m_aLineColor
= rCol
;}
131 void SetLineHeight( sal_uInt8 nNew
) { m_nLineHeight
= nNew
; }
132 void SetLineAdj( SwColLineAdj eNew
){ m_eAdj
= eNew
; }
133 void SetWishWidth( sal_uInt16 nNew
) { m_nWidth
= nNew
; }
135 /** This function allows to (repeatedly) initialize the columns.
136 The Ortho flag is set automatically. */
137 void Init( sal_uInt16 nNumCols
, sal_uInt16 nGutterWidth
, sal_uInt16 nAct
);
139 /** Adjusts borders for columns in aColumns.
140 If flag m_bOrtho is set, columns are visually re-arranged.
141 If the flag is not set, columns widths are not changed and
142 borders are adjusted. */
143 void SetGutterWidth( sal_uInt16 nNew
, sal_uInt16 nAct
);
145 /** This too re-arranges columns automatically if flag is set.
146 Only in this case the second parameter is needed and evaluated. */
147 void SetOrtho( bool bNew
, sal_uInt16 nGutterWidth
, sal_uInt16 nAct
);
150 void SetOrtho_( bool bNew
) { m_bOrtho
= bNew
; }
152 /** Calculates current width of column nCol.
153 The ratio of desired width of this column to return value is
154 proportional to ratio of total desired value to nAct. */
155 sal_uInt16
CalcColWidth( sal_uInt16 nCol
, sal_uInt16 nAct
) const;
157 /** As above except that it @return the width of PrtArea -
158 that corresponds to what constitutes the column for the user. */
159 sal_uInt16
CalcPrtColWidth( sal_uInt16 nCol
, sal_uInt16 nAct
) const;
161 void dumpAsXml(struct _xmlTextWriter
* pWriter
) const override
;
164 inline const SwFormatCol
&SwAttrSet::GetCol(bool bInP
) const
165 { return static_cast<const SwFormatCol
&>(Get( RES_COL
,bInP
)); }
167 inline const SwFormatCol
&SwFormat::GetCol(bool bInP
) const
168 { return m_aSet
.GetCol(bInP
); }
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */