fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / editeng / borderline.hxx
bloba7713b7edffbb7177d309592a927811d18f8b116
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 SVX_BORDERLINE_HXX
21 #define SVX_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
39 // ============================================================================
41 namespace editeng {
43 // values from ::com::sun::star::table::BorderLineStyle
44 typedef sal_Int16 SvxBorderStyle;
46 // convert border style between Word formats and LO
47 SvxBorderStyle EDITENG_DLLPUBLIC ConvertBorderStyleFromWord(int);
48 /// convert border width in twips between Word formats and LO
49 double EDITENG_DLLPUBLIC ConvertBorderWidthToWord(SvxBorderStyle, double);
50 double EDITENG_DLLPUBLIC ConvertBorderWidthFromWord(SvxBorderStyle,
51 double, int);
53 class EDITENG_DLLPUBLIC SvxBorderLine
55 protected:
56 Color aColor;
58 long m_nWidth;
59 bool m_bMirrorWidths;
60 BorderWidthImpl m_aWidthImpl;
61 long m_nMult;
62 long m_nDiv;
64 SvxBorderStyle m_nStyle;
65 sal_uInt16 nOutWidth;
66 sal_uInt16 nInWidth;
67 sal_uInt16 nDistance;
69 bool m_bUseLeftTop;
70 Color (*m_pColorOutFn)( Color );
71 Color (*m_pColorInFn)( Color );
72 Color (*m_pColorGapFn)( Color );
74 public:
75 SvxBorderLine( const Color *pCol = 0,
76 long nWidth = 0, SvxBorderStyle nStyle =
77 ::com::sun::star::table::BorderLineStyle::SOLID,
78 bool bUseLeftTop = false,
79 Color (*pColorOutFn)( Color ) = &darkColor,
80 Color (*pColorInFn)( Color ) = &darkColor,
81 Color (*pColorGapFn)( Color ) = NULL );
82 SvxBorderLine( const SvxBorderLine& r );
84 SvxBorderLine& operator=( const SvxBorderLine& r );
86 const Color& GetColor() const { return aColor; }
87 Color GetColorOut( bool bLeftOrTop = true ) const;
88 Color GetColorIn( bool bLeftOrTop = true ) const;
89 bool HasGapColor() const { return m_pColorGapFn != NULL; }
90 Color GetColorGap() const;
92 void SetWidth( long nWidth = 0 ) { m_nWidth = nWidth; }
93 /** Guess the style and width from the three lines widths values.
95 When the value of nStyle is SvxBorderLine::DOUBLE, the style set will be guessed
96 using the three values to match the best possible style among the following:
97 - SvxBorderLine::DOUBLE
98 - SvxBorderLine::THINTHICK_SMALLGAP
99 - SvxBorderLine::THINTHICK_MEDIUMGAP
100 - SvxBorderLine::THINTHICK_LARGEGAP
101 - SvxBorderLine::THICKTHIN_SMALLGAP
102 - SvxBorderLine::THICKTHIN_MEDIUMGAP
103 - SvxBorderLine::THICKTHIN_LARGEGAP
105 If no styles matches the width, then the width is set to 0.
107 There is one known case that could fit several styles: \a nIn = \a nDist = 0.75 pt,
108 \a nOut = 1.5 pt. This case fits SvxBorderLine::THINTHICK_SMALLGAP and
109 SvxBorderLine::THINTHICK_MEDIUMGAP with a 1.5 pt width and
110 SvxBorderLine::THINTHICK_LARGEGAP with a 0.75 pt width. The same case happens
111 also for thick-thin styles.
113 \param nStyle the border style used to guess the width.
114 \param nIn the width of the inner line in 1th pt
115 \param nOut the width of the outer line in 1th pt
116 \param nDist the width of the gap between the lines in 1th pt
118 void GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn = 0, sal_uInt16 nDist = 0 );
120 // TODO Hacky method to mirror lines in only a few cases
121 void SetMirrorWidths( bool bMirror = true ) { m_bMirrorWidths = bMirror; }
122 long GetWidth( ) const { return m_nWidth; }
123 sal_uInt16 GetOutWidth() const;
124 sal_uInt16 GetInWidth() const;
125 sal_uInt16 GetDistance() const;
127 SvxBorderStyle GetBorderLineStyle() const { return m_nStyle; }
129 void SetColor( const Color &rColor ) { aColor = rColor; }
130 void SetColorOutFn( Color (*pColorOutFn)( Color ) ) { m_pColorOutFn = pColorOutFn; }
131 void SetColorInFn( Color (*pColorInFn)( Color ) ) { m_pColorInFn = pColorInFn; }
132 void SetColorGapFn( Color (*pColorGapFn)( Color ) ) { m_pColorGapFn = pColorGapFn; }
133 void SetUseLeftTop( bool bUseLeftTop ) { m_bUseLeftTop = bUseLeftTop; }
134 void SetBorderLineStyle( SvxBorderStyle nNew );
135 void ScaleMetrics( long nMult, long nDiv );
137 sal_Bool operator==( const SvxBorderLine &rCmp ) const;
139 String GetValueString( SfxMapUnit eSrcUnit, SfxMapUnit eDestUnit,
140 const IntlWrapper* pIntl,
141 sal_Bool bMetricStr = sal_False ) const;
143 bool HasPriority( const SvxBorderLine& rOtherLine ) const;
145 bool isEmpty() const {
146 return m_aWidthImpl.IsEmpty()
147 || m_nStyle == ::com::sun::star::table::BorderLineStyle::NONE
148 || m_nWidth == 0;
150 bool isDouble() const { return m_aWidthImpl.IsDouble(); }
151 sal_uInt16 GetScaledWidth() const { return GetOutWidth() + GetInWidth() + GetDistance(); }
153 static Color darkColor( Color aMain );
154 static Color lightColor( Color aMain );
156 static Color threeDLightColor( Color aMain );
157 static Color threeDMediumColor( Color aMain );
158 static Color threeDDarkColor( Color aMain );
160 static BorderWidthImpl getWidthImpl( SvxBorderStyle nStyle );
163 EDITENG_DLLPUBLIC bool operator!=( const SvxBorderLine& rLeft, const SvxBorderLine& rRight );
165 } // namespace editeng
167 #endif
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */