LibreOffice Module editeng (master) 1
borderline.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_EDITENG_BORDERLINE_HXX
21#define INCLUDED_EDITENG_BORDERLINE_HXX
22
23#include <com/sun/star/table/BorderLineStyle.hpp>
24
25#include <tools/color.hxx>
26#include <tools/long.hxx>
27#include <tools/mapunit.hxx>
31
32class IntlWrapper;
33
34// Line width defaults in twips
35// Thin matches Excel's default values
36// See tdf#48622 for the discussion leading to these defaults.
38{
39public:
40 static const sal_Int16 Hairline = 1; // 0.05pt
41 static const sal_Int16 VeryThin = 10; // 0.5pt
42 static const sal_Int16 Thin = 15; // 0.75pt
43 static const sal_Int16 Medium = 30; // 1.5pt
44 static const sal_Int16 Thick = 45; // 2.25pt
45 static const sal_Int16 ExtraThick = 90; // 4.5pt
46};
47
48// Abstracts over values from css::table::BorderLineStyle
49enum class SvxBorderLineStyle : sal_Int16
50{
53 NONE = css::table::BorderLineStyle::NONE,
54
57 SOLID = css::table::BorderLineStyle::SOLID,
58
61 DOTTED = css::table::BorderLineStyle::DOTTED,
62
65 DASHED = css::table::BorderLineStyle::DASHED,
66
70 DOUBLE = css::table::BorderLineStyle::DOUBLE,
71
75 THINTHICK_SMALLGAP = css::table::BorderLineStyle::THINTHICK_SMALLGAP,
76
80 THINTHICK_MEDIUMGAP = css::table::BorderLineStyle::THINTHICK_MEDIUMGAP,
81
85 THINTHICK_LARGEGAP = css::table::BorderLineStyle::THINTHICK_LARGEGAP,
86
90 THICKTHIN_SMALLGAP = css::table::BorderLineStyle::THICKTHIN_SMALLGAP,
91
95 THICKTHIN_MEDIUMGAP = css::table::BorderLineStyle::THICKTHIN_MEDIUMGAP,
96
100 THICKTHIN_LARGEGAP = css::table::BorderLineStyle::THICKTHIN_LARGEGAP,
101
104 EMBOSSED = css::table::BorderLineStyle::EMBOSSED,
105
108 ENGRAVED = css::table::BorderLineStyle::ENGRAVED,
109
112 OUTSET = css::table::BorderLineStyle::OUTSET,
113
116 INSET = css::table::BorderLineStyle::INSET,
117
120 FINE_DASHED = css::table::BorderLineStyle::FINE_DASHED,
121
125 DOUBLE_THIN = css::table::BorderLineStyle::DOUBLE_THIN,
126
128 DASH_DOT = css::table::BorderLineStyle::DASH_DOT,
129
131 DASH_DOT_DOT = css::table::BorderLineStyle::DASH_DOT_DOT,
132
135 BORDER_LINE_STYLE_MAX = css::table::BorderLineStyle::BORDER_LINE_STYLE_MAX,
136};
137
138namespace editeng
139{
140
141// convert border style between Word formats and LO
146 double, int);
147
149{
153 Color (*m_pColorOutFn)(Color);
154 Color (*m_pColorInFn)(Color);
155 Color (*m_pColorGapFn)(Color);
162
163public:
164 SvxBorderLine( const Color *pCol = nullptr,
165 tools::Long nWidth = 0,
167 Color (*pColorOutFn)( Color ) = &darkColor,
168 Color (*pColorInFn)( Color ) = &darkColor );
169
170 const Color & GetColor() const { return m_aColor; }
171 void SetColor(const Color & rColor ) { m_aColor = rColor; }
172
174 {
175 return m_aComplexColor;
176 }
177 void setComplexColor(model::ComplexColor const& rComplexColor)
178 {
179 m_aComplexColor = rComplexColor;
180 }
181
182 bool setComplexColorFromAny(css::uno::Any const& rValue);
183
184
185 Color GetColorOut( bool bLeftOrTop = true ) const;
186 Color GetColorIn( bool bLeftOrTop = true ) const;
187 bool HasGapColor() const { return m_pColorGapFn != nullptr; }
188 Color GetColorGap() const;
189
190 void SetWidth( tools::Long nWidth );
216 void GuessLinesWidths( SvxBorderLineStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn = 0, sal_uInt16 nDist = 0 );
217
218 // TODO Hacky method to mirror lines in only a few cases
219 void SetMirrorWidths() { m_bMirrorWidths = true; }
220 tools::Long GetWidth( ) const { return m_nWidth; }
221 sal_uInt16 GetOutWidth() const;
222 sal_uInt16 GetInWidth() const;
223 sal_uInt16 GetDistance() const;
224
225 SvxBorderLineStyle GetBorderLineStyle() const { return m_nStyle; }
226
227 void SetBorderLineStyle( SvxBorderLineStyle nNew );
228 void ScaleMetrics( tools::Long nMult, tools::Long nDiv );
229
230 bool operator==( const SvxBorderLine &rCmp ) const;
231
232 OUString GetValueString( MapUnit eSrcUnit, MapUnit eDestUnit,
233 const IntlWrapper* pIntl,
234 bool bMetricStr = false ) const;
235
236 bool HasPriority( const SvxBorderLine& rOtherLine ) const;
237
238 bool isEmpty() const {
239 return m_aWidthImpl.IsEmpty()
240 || m_nStyle == SvxBorderLineStyle::NONE
241 || m_nWidth == 0;
242 }
243 bool isDouble() const { return m_aWidthImpl.IsDouble(); }
244 sal_uInt16 GetScaledWidth() const { return GetOutWidth() + GetInWidth() + GetDistance(); }
245
246 static Color darkColor( Color aMain );
247 static Color lightColor( Color aMain );
248
249 static Color threeDLightColor( Color aMain );
250 static Color threeDMediumColor( Color aMain );
251 static Color threeDDarkColor( Color aMain );
252
253 static BorderWidthImpl getWidthImpl( SvxBorderLineStyle nStyle );
254};
255
256EDITENG_DLLPUBLIC bool operator!=( const SvxBorderLine& rLeft, const SvxBorderLine& rRight );
257
258} // namespace editeng
259
260#endif
261
#define DOUBLE
SvxBorderLineStyle
Definition: borderline.hxx:50
@ FINE_DASHED
Finely dashed border line.
@ THICKTHIN_MEDIUMGAP
Double border line with a thick line outside and a thin line inside separated by a medium gap.
@ INSET
Inset border line.
@ EMBOSSED
3D embossed border line.
@ ENGRAVED
3D engraved border line.
@ THINTHICK_SMALLGAP
Double border line with a thin line outside and a thick line inside separated by a small gap.
@ DASHED
Dashed border line.
@ THICKTHIN_LARGEGAP
Double border line with a thick line outside and a thin line inside separated by a large gap.
@ DASH_DOT
Line consisting of a repetition of one dash and one dot.
@ OUTSET
Outset border line.
@ DOUBLE_THIN
Double border line consisting of two fixed thin lines separated by a variable gap.
@ NONE
No border line.
@ BORDER_LINE_STYLE_MAX
Maximum valid border line style value.
@ THINTHICK_MEDIUMGAP
Double border line with a thin line outside and a thick line inside separated by a medium gap.
@ SOLID
Solid border line.
@ DASH_DOT_DOT
Line consisting of a repetition of one dash and 2 dots.
@ THICKTHIN_SMALLGAP
Double border line with a thick line outside and a thin line inside separated by a small gap.
@ THINTHICK_LARGEGAP
Double border line with a thin line outside and a thick line inside separated by a large gap.
@ DOTTED
Dotted border line.
bool IsDouble() const
bool IsEmpty() const
static const sal_Int16 VeryThin
Definition: borderline.hxx:41
static const sal_Int16 ExtraThick
Definition: borderline.hxx:45
static const sal_Int16 Thin
Definition: borderline.hxx:42
static const sal_Int16 Medium
Definition: borderline.hxx:43
static const sal_Int16 Hairline
Definition: borderline.hxx:40
static const sal_Int16 Thick
Definition: borderline.hxx:44
void SetColor(const Color &rColor)
Definition: borderline.hxx:171
const Color & GetColor() const
Definition: borderline.hxx:170
SvxBorderLineStyle m_nStyle
Definition: borderline.hxx:159
BorderWidthImpl m_aWidthImpl
Definition: borderline.hxx:156
model::ComplexColor const & getComplexColor() const
Definition: borderline.hxx:173
sal_uInt16 GetScaledWidth() const
Definition: borderline.hxx:244
model::ComplexColor m_aComplexColor
Definition: borderline.hxx:158
void setComplexColor(model::ComplexColor const &rComplexColor)
Definition: borderline.hxx:177
tools::Long GetWidth() const
Definition: borderline.hxx:220
bool HasGapColor() const
Definition: borderline.hxx:187
SvxBorderLineStyle GetBorderLineStyle() const
Definition: borderline.hxx:225
Color m_aColor
bool operator==(const EditLine &r1, const EditLine &r2)
Definition: editdoc.cxx:978
#define EDITENG_DLLPUBLIC
Definition: editengdllapi.h:28
MapUnit
NONE
bool operator!=(const SvxBorderLine &rLeft, const SvxBorderLine &rRight)
Definition: borderline.cxx:712
double ConvertBorderWidthFromWord(SvxBorderLineStyle const eStyle, double const i_fWidth, int const nWordLineStyle)
Definition: borderline.cxx:205
SvxBorderLineStyle ConvertBorderStyleFromWord(int const nWordLineStyle)
Definition: borderline.cxx:136
double ConvertBorderWidthToWord(SvxBorderLineStyle const eStyle, double const fWidth)
convert border width in twips between Word formats and LO
Definition: borderline.cxx:270
long Long