nss: upgrade to release 3.73
[LibreOffice.git] / include / editeng / borderline.hxx
blobe48b461a8b022050432f6bbb15e96191347dda16
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_EDITENG_BORDERLINE_HXX
21 #define INCLUDED_EDITENG_BORDERLINE_HXX
23 #include <com/sun/star/table/BorderLineStyle.hpp>
25 #include <tools/color.hxx>
26 #include <tools/long.hxx>
27 #include <tools/mapunit.hxx>
28 #include <editeng/editengdllapi.h>
29 #include <svtools/borderline.hxx>
31 class IntlWrapper;
33 // Line defaults in twips (former Writer defaults):
35 #define DEF_LINE_WIDTH_0 1
36 #define DEF_LINE_WIDTH_1 20
37 #define DEF_LINE_WIDTH_2 50
38 #define DEF_LINE_WIDTH_3 80
39 #define DEF_LINE_WIDTH_4 100
40 #define DEF_LINE_WIDTH_5 10
41 #define DEF_LINE_WIDTH_6 5 // 0.25pt
44 // Abstracts over values from css::table::BorderLineStyle
45 enum class SvxBorderLineStyle : sal_Int16
47 /** No border line
49 NONE = css::table::BorderLineStyle::NONE,
51 /** Solid border line.
53 SOLID = css::table::BorderLineStyle::SOLID,
55 /** Dotted border line.
57 DOTTED = css::table::BorderLineStyle::DOTTED,
59 /** Dashed border line.
61 DASHED = css::table::BorderLineStyle::DASHED,
63 /** Double border line. Widths of the lines and the gap are all equal,
64 and vary equally with the total width.
66 DOUBLE = css::table::BorderLineStyle::DOUBLE,
68 /** Double border line with a thin line outside and a thick line
69 inside separated by a small gap.
71 THINTHICK_SMALLGAP = css::table::BorderLineStyle::THINTHICK_SMALLGAP,
73 /** Double border line with a thin line outside and a thick line
74 inside separated by a medium gap.
76 THINTHICK_MEDIUMGAP = css::table::BorderLineStyle::THINTHICK_MEDIUMGAP,
78 /** Double border line with a thin line outside and a thick line
79 inside separated by a large gap.
81 THINTHICK_LARGEGAP = css::table::BorderLineStyle::THINTHICK_LARGEGAP,
83 /** Double border line with a thick line outside and a thin line
84 inside separated by a small gap.
86 THICKTHIN_SMALLGAP = css::table::BorderLineStyle::THICKTHIN_SMALLGAP,
88 /** Double border line with a thick line outside and a thin line
89 inside separated by a medium gap.
91 THICKTHIN_MEDIUMGAP = css::table::BorderLineStyle::THICKTHIN_MEDIUMGAP,
93 /** Double border line with a thick line outside and a thin line
94 inside separated by a large gap.
96 THICKTHIN_LARGEGAP = css::table::BorderLineStyle::THICKTHIN_LARGEGAP,
98 /** 3D embossed border line.
100 EMBOSSED = css::table::BorderLineStyle::EMBOSSED,
102 /** 3D engraved border line.
104 ENGRAVED = css::table::BorderLineStyle::ENGRAVED,
106 /** Outset border line.
108 OUTSET = css::table::BorderLineStyle::OUTSET,
110 /** Inset border line.
112 INSET = css::table::BorderLineStyle::INSET,
114 /** Finely dashed border line.
116 FINE_DASHED = css::table::BorderLineStyle::FINE_DASHED,
118 /** Double border line consisting of two fixed thin lines separated by a
119 variable gap.
121 DOUBLE_THIN = css::table::BorderLineStyle::DOUBLE_THIN,
123 /** Line consisting of a repetition of one dash and one dot. */
124 DASH_DOT = css::table::BorderLineStyle::DASH_DOT,
126 /** Line consisting of a repetition of one dash and 2 dots. */
127 DASH_DOT_DOT = css::table::BorderLineStyle::DASH_DOT_DOT,
129 /** Maximum valid border line style value.
131 BORDER_LINE_STYLE_MAX = css::table::BorderLineStyle::BORDER_LINE_STYLE_MAX,
134 namespace editeng
137 // convert border style between Word formats and LO
138 SvxBorderLineStyle EDITENG_DLLPUBLIC ConvertBorderStyleFromWord(int);
139 /// convert border width in twips between Word formats and LO
140 double EDITENG_DLLPUBLIC ConvertBorderWidthToWord(SvxBorderLineStyle, double);
141 double EDITENG_DLLPUBLIC ConvertBorderWidthFromWord(SvxBorderLineStyle,
142 double, int);
144 class EDITENG_DLLPUBLIC SvxBorderLine final
146 Color aColor;
148 tools::Long m_nWidth;
149 bool m_bMirrorWidths;
150 BorderWidthImpl m_aWidthImpl;
151 tools::Long m_nMult;
152 tools::Long m_nDiv;
154 SvxBorderLineStyle m_nStyle;
156 bool m_bUseLeftTop;
157 Color (*m_pColorOutFn)( Color );
158 Color (*m_pColorInFn)( Color );
159 Color (*m_pColorGapFn)( Color );
161 public:
162 SvxBorderLine( const Color *pCol = nullptr,
163 tools::Long nWidth = 0,
164 SvxBorderLineStyle nStyle = SvxBorderLineStyle::SOLID,
165 Color (*pColorOutFn)( Color ) = &darkColor,
166 Color (*pColorInFn)( Color ) = &darkColor );
168 const Color& GetColor() const { return aColor; }
169 Color GetColorOut( bool bLeftOrTop = true ) const;
170 Color GetColorIn( bool bLeftOrTop = true ) const;
171 bool HasGapColor() const { return m_pColorGapFn != nullptr; }
172 Color GetColorGap() const;
174 void SetWidth( tools::Long nWidth );
175 /** Guess the style and width from the three lines widths values.
177 When the value of nStyle is SvxBorderLine::DOUBLE, the style set will be guessed
178 using the three values to match the best possible style among the following:
179 - SvxBorderLine::DOUBLE
180 - SvxBorderLine::THINTHICK_SMALLGAP
181 - SvxBorderLine::THINTHICK_MEDIUMGAP
182 - SvxBorderLine::THINTHICK_LARGEGAP
183 - SvxBorderLine::THICKTHIN_SMALLGAP
184 - SvxBorderLine::THICKTHIN_MEDIUMGAP
185 - SvxBorderLine::THICKTHIN_LARGEGAP
187 If no styles matches the width, then the width is set to 0.
189 There is one known case that could fit several styles: \a nIn = \a nDist = 0.75 pt,
190 \a nOut = 1.5 pt. This case fits SvxBorderLine::THINTHICK_SMALLGAP and
191 SvxBorderLine::THINTHICK_MEDIUMGAP with a 1.5 pt width and
192 SvxBorderLine::THINTHICK_LARGEGAP with a 0.75 pt width. The same case happens
193 also for thick-thin styles.
195 \param nStyle the border style used to guess the width.
196 \param nIn the width of the inner line in 1th pt
197 \param nOut the width of the outer line in 1th pt
198 \param nDist the width of the gap between the lines in 1th pt
200 void GuessLinesWidths( SvxBorderLineStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn = 0, sal_uInt16 nDist = 0 );
202 // TODO Hacky method to mirror lines in only a few cases
203 void SetMirrorWidths() { m_bMirrorWidths = true; }
204 tools::Long GetWidth( ) const { return m_nWidth; }
205 sal_uInt16 GetOutWidth() const;
206 sal_uInt16 GetInWidth() const;
207 sal_uInt16 GetDistance() const;
209 SvxBorderLineStyle GetBorderLineStyle() const { return m_nStyle; }
211 void SetColor( const Color &rColor ) { aColor = rColor; }
212 void SetBorderLineStyle( SvxBorderLineStyle nNew );
213 void ScaleMetrics( tools::Long nMult, tools::Long nDiv );
215 bool operator==( const SvxBorderLine &rCmp ) const;
217 OUString GetValueString( MapUnit eSrcUnit, MapUnit eDestUnit,
218 const IntlWrapper* pIntl,
219 bool bMetricStr = false ) const;
221 bool HasPriority( const SvxBorderLine& rOtherLine ) const;
223 bool isEmpty() const {
224 return m_aWidthImpl.IsEmpty()
225 || m_nStyle == SvxBorderLineStyle::NONE
226 || m_nWidth == 0;
228 bool isDouble() const { return m_aWidthImpl.IsDouble(); }
229 sal_uInt16 GetScaledWidth() const { return GetOutWidth() + GetInWidth() + GetDistance(); }
231 static Color darkColor( Color aMain );
232 static Color lightColor( Color aMain );
234 static Color threeDLightColor( Color aMain );
235 static Color threeDMediumColor( Color aMain );
236 static Color threeDDarkColor( Color aMain );
238 static BorderWidthImpl getWidthImpl( SvxBorderLineStyle nStyle );
241 EDITENG_DLLPUBLIC bool operator!=( const SvxBorderLine& rLeft, const SvxBorderLine& rRight );
243 } // namespace editeng
245 #endif