build fix
[LibreOffice.git] / include / editeng / borderline.hxx
blob98e2245b072922e11764c4a8164a5add0536093f
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 <svl/poolitem.hxx>
27 #include <editeng/editengdllapi.h>
28 #include <svtools/ctrlbox.hxx>
30 // Line defaults in twips (former Writer defaults):
32 #define DEF_LINE_WIDTH_0 1
33 #define DEF_LINE_WIDTH_1 20
34 #define DEF_LINE_WIDTH_2 50
35 #define DEF_LINE_WIDTH_3 80
36 #define DEF_LINE_WIDTH_4 100
37 #define DEF_LINE_WIDTH_5 10
40 namespace editeng {
42 // values from css::table::BorderLineStyle
43 typedef sal_Int16 SvxBorderStyle;
45 // convert border style between Word formats and LO
46 SvxBorderStyle EDITENG_DLLPUBLIC ConvertBorderStyleFromWord(int);
47 /// convert border width in twips between Word formats and LO
48 double EDITENG_DLLPUBLIC ConvertBorderWidthToWord(SvxBorderStyle, double);
49 double EDITENG_DLLPUBLIC ConvertBorderWidthFromWord(SvxBorderStyle,
50 double, int);
52 class EDITENG_DLLPUBLIC SvxBorderLine
54 protected:
55 Color aColor;
57 long m_nWidth;
58 bool m_bMirrorWidths;
59 BorderWidthImpl m_aWidthImpl;
60 long m_nMult;
61 long m_nDiv;
63 SvxBorderStyle m_nStyle;
65 bool m_bUseLeftTop;
66 Color (*m_pColorOutFn)( Color );
67 Color (*m_pColorInFn)( Color );
68 Color (*m_pColorGapFn)( Color );
70 public:
71 SvxBorderLine( const Color *pCol = nullptr,
72 long nWidth = 0,
73 SvxBorderStyle nStyle = css::table::BorderLineStyle::SOLID,
74 Color (*pColorOutFn)( Color ) = &darkColor,
75 Color (*pColorInFn)( Color ) = &darkColor );
76 SvxBorderLine( const SvxBorderLine& r );
78 SvxBorderLine& operator=( const SvxBorderLine& r );
80 const Color& GetColor() const { return aColor; }
81 Color GetColorOut( bool bLeftOrTop = true ) const;
82 Color GetColorIn( bool bLeftOrTop = true ) const;
83 bool HasGapColor() const { return m_pColorGapFn != nullptr; }
84 Color GetColorGap() const;
86 void SetWidth( long nWidth );
87 /** Guess the style and width from the three lines widths values.
89 When the value of nStyle is SvxBorderLine::DOUBLE, the style set will be guessed
90 using the three values to match the best possible style among the following:
91 - SvxBorderLine::DOUBLE
92 - SvxBorderLine::THINTHICK_SMALLGAP
93 - SvxBorderLine::THINTHICK_MEDIUMGAP
94 - SvxBorderLine::THINTHICK_LARGEGAP
95 - SvxBorderLine::THICKTHIN_SMALLGAP
96 - SvxBorderLine::THICKTHIN_MEDIUMGAP
97 - SvxBorderLine::THICKTHIN_LARGEGAP
99 If no styles matches the width, then the width is set to 0.
101 There is one known case that could fit several styles: \a nIn = \a nDist = 0.75 pt,
102 \a nOut = 1.5 pt. This case fits SvxBorderLine::THINTHICK_SMALLGAP and
103 SvxBorderLine::THINTHICK_MEDIUMGAP with a 1.5 pt width and
104 SvxBorderLine::THINTHICK_LARGEGAP with a 0.75 pt width. The same case happens
105 also for thick-thin styles.
107 \param nStyle the border style used to guess the width.
108 \param nIn the width of the inner line in 1th pt
109 \param nOut the width of the outer line in 1th pt
110 \param nDist the width of the gap between the lines in 1th pt
112 void GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn = 0, sal_uInt16 nDist = 0 );
114 // TODO Hacky method to mirror lines in only a few cases
115 void SetMirrorWidths() { m_bMirrorWidths = true; }
116 long GetWidth( ) const { return m_nWidth; }
117 sal_uInt16 GetOutWidth() const;
118 sal_uInt16 GetInWidth() const;
119 sal_uInt16 GetDistance() const;
121 SvxBorderStyle GetBorderLineStyle() const { return m_nStyle; }
123 void SetColor( const Color &rColor ) { aColor = rColor; }
124 void SetBorderLineStyle( SvxBorderStyle nNew );
125 void ScaleMetrics( long nMult, long nDiv );
127 bool operator==( const SvxBorderLine &rCmp ) const;
129 OUString GetValueString( MapUnit eSrcUnit, MapUnit eDestUnit,
130 const IntlWrapper* pIntl,
131 bool bMetricStr = false ) const;
133 bool HasPriority( const SvxBorderLine& rOtherLine ) const;
135 bool isEmpty() const {
136 return m_aWidthImpl.IsEmpty()
137 || m_nStyle == css::table::BorderLineStyle::NONE
138 || m_nWidth == 0;
140 bool isDouble() const { return m_aWidthImpl.IsDouble(); }
141 sal_uInt16 GetScaledWidth() const { return GetOutWidth() + GetInWidth() + GetDistance(); }
143 static Color darkColor( Color aMain );
144 static Color lightColor( Color aMain );
146 static Color threeDLightColor( Color aMain );
147 static Color threeDMediumColor( Color aMain );
148 static Color threeDDarkColor( Color aMain );
150 static BorderWidthImpl getWidthImpl( SvxBorderStyle nStyle );
153 EDITENG_DLLPUBLIC bool operator!=( const SvxBorderLine& rLeft, const SvxBorderLine& rRight );
155 } // namespace editeng
157 #endif
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */