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 <tools/solar.h>
25 #include <svl/poolitem.hxx>
27 #include "hintids.hxx"
35 sal_uInt16 m_nWish
; /**< Desired width, borders included.
36 It is inversely proportional to the ratio of
37 desired width environment / current width column. */
38 sal_uInt16 m_nLeft
; ///< Left border.
39 sal_uInt16 m_nRight
; ///< Right border.
44 bool operator==( const SwColumn
& ) const;
46 void SetWishWidth( sal_uInt16 nNew
) { m_nWish
= nNew
; }
47 void SetLeft ( sal_uInt16 nNew
) { m_nLeft
= nNew
; }
48 void SetRight( sal_uInt16 nNew
) { m_nRight
= nNew
; }
50 sal_uInt16
GetWishWidth() const { return m_nWish
; }
51 sal_uInt16
GetLeft () const { return m_nLeft
; }
52 sal_uInt16
GetRight() const { return m_nRight
; }
54 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
57 typedef std::vector
<SwColumn
> SwColumns
;
67 class SW_DLLPUBLIC SwFormatCol
: public SfxPoolItem
69 SvxBorderLineStyle m_eLineStyle
; ///< style of the separator line
70 sal_uLong m_nLineWidth
; ///< Width of the separator line.
71 Color m_aLineColor
; ///< Color of the separator line.
73 sal_uInt16 m_nLineHeight
; /**< Percentile height of lines.
74 (Based on height of columns including UL). */
76 SwColLineAdj m_eAdj
; ///< Line will be adjusted top, centered or bottom.
78 SwColumns m_aColumns
; ///< Information concerning the columns.
79 sal_uInt16 m_nWidth
; ///< Total desired width of all columns.
80 sal_Int16 m_aWidthAdjustValue
;
82 bool m_bOrtho
; /**< Only if this flag is set, the setting of GutterWidth will
83 be accompanied by a "visual rearrangement".
84 The flag must be reset if widths of columns or borders are changed.
85 When it is set (again) the visual arrangement is recalculated.
86 The flag is initially set. */
88 SAL_DLLPRIVATE
void Calc( sal_uInt16 nGutterWidth
, sal_uInt16 nAct
);
92 SwFormatCol( const SwFormatCol
& );
93 virtual ~SwFormatCol() override
;
95 sal_Int16
GetAdjustValue() const { return m_aWidthAdjustValue
; }
96 void SetAdjustValue( sal_Int16 n
) { m_aWidthAdjustValue
= n
; }
98 SwFormatCol
& operator=( const SwFormatCol
& );
100 /// "pure virtual methods" of SfxPoolItem
101 virtual bool operator==( const SfxPoolItem
& ) const override
;
102 virtual SwFormatCol
* Clone( SfxItemPool
* pPool
= nullptr ) const override
;
103 virtual bool GetPresentation( SfxItemPresentation ePres
,
107 const IntlWrapper
& rIntl
) const override
;
109 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
110 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
112 const SwColumns
&GetColumns() const { return m_aColumns
; }
113 SwColumns
&GetColumns() { return m_aColumns
; }
114 sal_uInt16
GetNumCols() const { return m_aColumns
.size(); }
116 SvxBorderLineStyle
GetLineStyle() const { return m_eLineStyle
;}
117 sal_uLong
GetLineWidth() const { return m_nLineWidth
;}
118 const Color
& GetLineColor() const { return m_aLineColor
;}
120 SwColLineAdj
GetLineAdj() const { return m_eAdj
; }
121 bool IsOrtho() const { return m_bOrtho
; }
122 sal_uInt16
GetWishWidth() const { return m_nWidth
; }
123 sal_uInt8
GetLineHeight()const { return m_nLineHeight
; }
125 /** @return USHRT_MAX if ambiguous.
126 @return smallest width if bMin is true. */
127 sal_uInt16
GetGutterWidth( bool bMin
= false ) const;
129 void SetLineStyle(SvxBorderLineStyle eStyle
) { m_eLineStyle
= eStyle
;}
130 void SetLineWidth(sal_uLong nLWidth
) { m_nLineWidth
= nLWidth
;}
131 void SetLineColor(const Color
& rCol
) { m_aLineColor
= rCol
;}
132 void SetLineHeight( sal_uInt8 nNew
) { m_nLineHeight
= nNew
; }
133 void SetLineAdj( SwColLineAdj eNew
){ m_eAdj
= eNew
; }
134 void SetWishWidth( sal_uInt16 nNew
) { m_nWidth
= nNew
; }
136 /** This function allows to (repeatedly) initialize the columns.
137 The Ortho flag is set automatically. */
138 void Init( sal_uInt16 nNumCols
, sal_uInt16 nGutterWidth
, sal_uInt16 nAct
);
140 /** Adjusts borders for columns in aColumns.
141 If flag m_bOrtho is set, columns are visually re-arranged.
142 If the flag is not set, columns widths are not changed and
143 borders are adjusted. */
144 void SetGutterWidth( sal_uInt16 nNew
, sal_uInt16 nAct
);
146 /** This too re-arranges columns automatically if flag is set.
147 Only in this case the second parameter is needed and evaluated. */
148 void SetOrtho( bool bNew
, sal_uInt16 nGutterWidth
, sal_uInt16 nAct
);
151 void SetOrtho_( bool bNew
) { m_bOrtho
= bNew
; }
153 /** Calculates current width of column nCol.
154 The ratio of desired width of this column to return value is
155 proportional to ratio of total desired value to nAct. */
156 sal_uInt16
CalcColWidth( sal_uInt16 nCol
, sal_uInt16 nAct
) const;
158 /** As above except that it @return the width of PrtArea -
159 that corresponds to what constitutes the column for the user. */
160 sal_uInt16
CalcPrtColWidth( sal_uInt16 nCol
, sal_uInt16 nAct
) const;
162 void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
165 inline const SwFormatCol
&SwAttrSet::GetCol(bool bInP
) const
166 { return Get( RES_COL
,bInP
); }
168 inline const SwFormatCol
&SwFormat::GetCol(bool bInP
) const
169 { return m_aSet
.GetCol(bInP
); }
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */