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 .
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 sal_Bool
operator==( const SwColumn
& ) const;
47 void SetWishWidth( sal_uInt16 nNew
) { nWish
= nNew
; }
48 void SetUpper( sal_uInt16 nNew
) { nUpper
= nNew
; }
49 void SetLower( sal_uInt16 nNew
) { nLower
= nNew
; }
50 void SetLeft ( sal_uInt16 nNew
) { nLeft
= nNew
; }
51 void SetRight( sal_uInt16 nNew
) { nRight
= nNew
; }
53 sal_uInt16
GetWishWidth() const { return nWish
; }
54 sal_uInt16
GetUpper() const { return nUpper
; }
55 sal_uInt16
GetLower() const { return nLower
; }
56 sal_uInt16
GetLeft () const { return nLeft
; }
57 sal_uInt16
GetRight() const { return nRight
; }
60 typedef boost::ptr_vector
<SwColumn
> SwColumns
;
70 class SW_DLLPUBLIC SwFmtCol
: public SfxPoolItem
72 editeng::SvxBorderStyle eLineStyle
; ///< style of the separator line
73 sal_uLong nLineWidth
; ///< Width of the separator line.
74 Color aLineColor
; ///< Color of the separator line.
76 sal_uInt16 nLineHeight
; /**< Percentile height of lines.
77 (Based on height of columns including UL). */
79 SwColLineAdj eAdj
; ///< Line will be adjusted top, centered or bottom.
81 SwColumns aColumns
; ///< Information concerning the columns.
82 sal_uInt16 nWidth
; ///< Total desired width of all columns.
84 sal_Bool bOrtho
; /**< Only if this flag is set, the setting of GutterWidth will
85 be accompanied by a "visual rearrangement".
86 The flag must be reset if widths of columns or borders are changed.
87 When it is set (again) the visual arrangement is recalculated.
88 The flag is initially set. */
90 SW_DLLPRIVATE
void Calc( sal_uInt16 nGutterWidth
, sal_uInt16 nAct
);
94 SwFmtCol( const SwFmtCol
& );
97 SwFmtCol
& operator=( const SwFmtCol
& );
99 /// "pure virtual methods" of SfxPoolItem
100 virtual int operator==( const SfxPoolItem
& ) const;
101 virtual SfxPoolItem
* Clone( SfxItemPool
* pPool
= 0 ) const;
102 virtual SfxItemPresentation
GetPresentation( SfxItemPresentation ePres
,
103 SfxMapUnit eCoreMetric
,
104 SfxMapUnit ePresMetric
,
106 const IntlWrapper
* pIntl
= 0 ) const;
108 virtual bool QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const;
109 virtual bool PutValue( const com::sun::star::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 );
111 const SwColumns
&GetColumns() const { return aColumns
; }
112 SwColumns
&GetColumns() { return aColumns
; }
113 sal_uInt16
GetNumCols() const { return aColumns
.size(); }
115 editeng::SvxBorderStyle
GetLineStyle() const { return eLineStyle
;}
116 sal_uLong
GetLineWidth() const { return nLineWidth
;}
117 const Color
& GetLineColor() const { return aLineColor
;}
120 SwColLineAdj
GetLineAdj() const { return eAdj
; }
121 sal_Bool
IsOrtho() const { return bOrtho
; }
122 sal_uInt16
GetWishWidth() const { return nWidth
; }
123 sal_uInt8
GetLineHeight()const { return nLineHeight
; }
125 /** @return USHRT_MAX if ambiguous.
126 @return smallest width if bMin is true. */
127 sal_uInt16
GetGutterWidth( sal_Bool bMin
= sal_False
) const;
129 void SetLineStyle(editeng::SvxBorderStyle eStyle
) { eLineStyle
= eStyle
;}
130 void SetLineWidth(sal_uLong nLWidth
) { nLineWidth
= nLWidth
;}
131 void SetLineColor(const Color
& rCol
) { aLineColor
= rCol
;}
132 void SetLineHeight( sal_uInt8 nNew
) { nLineHeight
= nNew
; }
133 void SetLineAdj( SwColLineAdj eNew
){ eAdj
= eNew
; }
134 void SetWishWidth( sal_uInt16 nNew
) { 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 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( sal_Bool bNew
, sal_uInt16 nGutterWidth
, sal_uInt16 nAct
);
151 void _SetOrtho( sal_Bool bNew
) { 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;
163 inline const SwFmtCol
&SwAttrSet::GetCol(sal_Bool bInP
) const
164 { return (const SwFmtCol
&)Get( RES_COL
,bInP
); }
166 inline const SwFmtCol
&SwFmt::GetCol(sal_Bool bInP
) const
167 { return aSet
.GetCol(bInP
); }
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */