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>
28 #include <boost/ptr_container/ptr_vector.hpp>
33 sal_uInt16 nWish
; /**< Desired width, borders included.
34 It is inversely proportional to the ratio of
35 desired width environment / current width column. */
36 sal_uInt16 nUpper
; ///< Top border.
37 sal_uInt16 nLower
; ///< Bottom border.
38 sal_uInt16 nLeft
; ///< Left border.
39 sal_uInt16 nRight
; ///< Right border.
44 bool operator==( const SwColumn
& ) const;
46 void SetWishWidth( sal_uInt16 nNew
) { nWish
= nNew
; }
47 void SetUpper( sal_uInt16 nNew
) { nUpper
= nNew
; }
48 void SetLower( sal_uInt16 nNew
) { nLower
= nNew
; }
49 void SetLeft ( sal_uInt16 nNew
) { nLeft
= nNew
; }
50 void SetRight( sal_uInt16 nNew
) { nRight
= nNew
; }
52 sal_uInt16
GetWishWidth() const { return nWish
; }
53 sal_uInt16
GetUpper() const { return nUpper
; }
54 sal_uInt16
GetLower() const { return nLower
; }
55 sal_uInt16
GetLeft () const { return nLeft
; }
56 sal_uInt16
GetRight() const { return nRight
; }
58 void dumpAsXml(struct _xmlTextWriter
* pWriter
) const;
61 typedef boost::ptr_vector
<SwColumn
> SwColumns
;
71 class SW_DLLPUBLIC SwFormatCol
: public SfxPoolItem
73 editeng::SvxBorderStyle m_eLineStyle
; ///< style of the separator line
74 sal_uLong m_nLineWidth
; ///< Width of the separator line.
75 Color m_aLineColor
; ///< Color of the separator line.
77 sal_uInt16 m_nLineHeight
; /**< Percentile height of lines.
78 (Based on height of columns including UL). */
80 SwColLineAdj m_eAdj
; ///< Line will be adjusted top, centered or bottom.
82 SwColumns m_aColumns
; ///< Information concerning the columns.
83 sal_uInt16 m_nWidth
; ///< Total desired width of all columns.
84 sal_Int16 m_aWidthAdjustValue
;
86 bool m_bOrtho
; /**< Only if this flag is set, the setting of GutterWidth will
87 be accompanied by a "visual rearrangement".
88 The flag must be reset if widths of columns or borders are changed.
89 When it is set (again) the visual arrangement is recalculated.
90 The flag is initially set. */
92 SAL_DLLPRIVATE
void Calc( sal_uInt16 nGutterWidth
, sal_uInt16 nAct
);
96 SwFormatCol( const SwFormatCol
& );
97 virtual ~SwFormatCol();
99 sal_Int16
GetAdjustValue() const { return m_aWidthAdjustValue
; }
100 void SetAdjustValue( const sal_Int16
& n
) { m_aWidthAdjustValue
= n
; }
102 SwFormatCol
& operator=( const SwFormatCol
& );
104 /// "pure virtual methods" of SfxPoolItem
105 virtual bool operator==( const SfxPoolItem
& ) const SAL_OVERRIDE
;
106 virtual SfxPoolItem
* Clone( SfxItemPool
* pPool
= 0 ) const SAL_OVERRIDE
;
107 virtual bool GetPresentation( SfxItemPresentation ePres
,
108 SfxMapUnit eCoreMetric
,
109 SfxMapUnit ePresMetric
,
111 const IntlWrapper
* pIntl
= 0 ) const SAL_OVERRIDE
;
113 virtual bool QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const SAL_OVERRIDE
;
114 virtual bool PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) SAL_OVERRIDE
;
116 const SwColumns
&GetColumns() const { return m_aColumns
; }
117 SwColumns
&GetColumns() { return m_aColumns
; }
118 sal_uInt16
GetNumCols() const { return m_aColumns
.size(); }
120 editeng::SvxBorderStyle
GetLineStyle() const { return m_eLineStyle
;}
121 sal_uLong
GetLineWidth() const { return m_nLineWidth
;}
122 const Color
& GetLineColor() const { return m_aLineColor
;}
124 SwColLineAdj
GetLineAdj() const { return m_eAdj
; }
125 bool IsOrtho() const { return m_bOrtho
; }
126 sal_uInt16
GetWishWidth() const { return m_nWidth
; }
127 sal_uInt8
GetLineHeight()const { return m_nLineHeight
; }
129 /** @return USHRT_MAX if ambiguous.
130 @return smallest width if bMin is true. */
131 sal_uInt16
GetGutterWidth( bool bMin
= false ) const;
133 void SetLineStyle(editeng::SvxBorderStyle eStyle
) { m_eLineStyle
= eStyle
;}
134 void SetLineWidth(sal_uLong nLWidth
) { m_nLineWidth
= nLWidth
;}
135 void SetLineColor(const Color
& rCol
) { m_aLineColor
= rCol
;}
136 void SetLineHeight( sal_uInt8 nNew
) { m_nLineHeight
= nNew
; }
137 void SetLineAdj( SwColLineAdj eNew
){ m_eAdj
= eNew
; }
138 void SetWishWidth( sal_uInt16 nNew
) { m_nWidth
= nNew
; }
140 /** This function allows to (repeatedly) initialize the columns.
141 The Ortho flag is set automatically. */
142 void Init( sal_uInt16 nNumCols
, sal_uInt16 nGutterWidth
, sal_uInt16 nAct
);
144 /** Adjusts borders for columns in aColumns.
145 If flag m_bOrtho is set, columns are visually re-arranged.
146 If the flag is not set, columns widths are not changed and
147 borders are adjusted. */
148 void SetGutterWidth( sal_uInt16 nNew
, sal_uInt16 nAct
);
150 /** This too re-arranges columns automatically if flag is set.
151 Only in this case the second parameter is needed and evaluated. */
152 void SetOrtho( bool bNew
, sal_uInt16 nGutterWidth
, sal_uInt16 nAct
);
155 void _SetOrtho( bool bNew
) { m_bOrtho
= bNew
; }
157 /** Calculates current width of column nCol.
158 The ratio of desired width of this column to return value is
159 proportional to ratio of total desired value to nAct. */
160 sal_uInt16
CalcColWidth( sal_uInt16 nCol
, sal_uInt16 nAct
) const;
162 /** As above except that it @return the width of PrtArea -
163 that corresponds to what constitutes the column for the user. */
164 sal_uInt16
CalcPrtColWidth( sal_uInt16 nCol
, sal_uInt16 nAct
) const;
166 void dumpAsXml(struct _xmlTextWriter
* pWriter
) const SAL_OVERRIDE
;
169 inline const SwFormatCol
&SwAttrSet::GetCol(bool bInP
) const
170 { return static_cast<const SwFormatCol
&>(Get( RES_COL
,bInP
)); }
172 inline const SwFormatCol
&SwFormat::GetCol(bool bInP
) const
173 { return m_aSet
.GetCol(bInP
); }
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */