/src/libreoffice/include/svx/framelink.hxx
Line | Count | Source |
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_SVX_FRAMELINK_HXX |
21 | | #define INCLUDED_SVX_FRAMELINK_HXX |
22 | | |
23 | | #include <sal/types.h> |
24 | | #include <tools/color.hxx> |
25 | | #include <svx/svxdllapi.h> |
26 | | #include <editeng/borderline.hxx> |
27 | | |
28 | | namespace svx::frame { |
29 | | |
30 | | |
31 | | // Enums |
32 | | |
33 | | |
34 | | /** Specifies how the reference points for frame borders are used. |
35 | | */ |
36 | | enum class RefMode : sal_uInt8 |
37 | | { |
38 | | /** Frame borders are drawn centered to the reference points. */ |
39 | | Centered, |
40 | | |
41 | | /** The reference points specify the begin of the frame border width. |
42 | | |
43 | | The result is that horizontal lines are drawn below, and vertical lines |
44 | | are drawn right of the reference points. |
45 | | */ |
46 | | Begin, |
47 | | |
48 | | /** The reference points specify the end of the frame border width. |
49 | | |
50 | | The result is that horizontal lines are drawn above, and vertical lines |
51 | | are drawn left of the reference points. |
52 | | */ |
53 | | End |
54 | | }; |
55 | | |
56 | | |
57 | | // Classes |
58 | | |
59 | | |
60 | | /** Contains the widths of primary and secondary line of a frame style. |
61 | | |
62 | | In the following, "frame style" is a complete style of one frame border, |
63 | | i.e. the double line at the left side of the frame. A "line" is always a |
64 | | trivial single line, i.e. the first line of a double frame style. |
65 | | |
66 | | The following states of the members of this struct are valid: |
67 | | |
68 | | mnPrim mnDist mnSecn frame style |
69 | | ------------------------------------------------- |
70 | | 0 0 0 invisible |
71 | | >0 0 0 single |
72 | | >0 >0 >0 double |
73 | | |
74 | | The behaviour of the member functions for other states is not defined. |
75 | | |
76 | | Per definition the primary line in double frame styles is: |
77 | | - The top line for horizontal frame borders. |
78 | | - The left line for vertical frame borders. |
79 | | - The bottom-left line for top-left to bottom-right diagonal frame borders. |
80 | | - The top-left line for bottom-left to top-right diagonal frame borders. |
81 | | |
82 | | The following picture shows the upper end of a vertical double frame |
83 | | border. |
84 | | |
85 | | |<---------------- GetWidth() ----------------->| |
86 | | | | |
87 | | |<----- mnPrim ----->||<- mnDist ->||<- mnSecn >| |
88 | | | || || | |
89 | | ###################### ############# |
90 | | ###################### ############# |
91 | | ###################### ############# |
92 | | ###################### ############# |
93 | | ###################### | ############# |
94 | | ###################### | ############# |
95 | | | |
96 | | |<- middle of the frame border |
97 | | */ |
98 | | class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC Style |
99 | | { |
100 | | private: |
101 | | Color maColorPrim; |
102 | | Color maColorSecn; |
103 | | Color maColorGap; |
104 | | double mfPrim; /// Width of primary (single, left, or top) line. |
105 | | double mfDist; /// Distance between primary and secondary line. |
106 | | double mfSecn; /// Width of secondary (right or bottom) line. |
107 | | double mfPatternScale; /// Scale used for line pattern spacing. |
108 | | SvxBorderLineStyle mnType; |
109 | | RefMode meRefMode; /// Reference point handling for this frame border. |
110 | | bool mbWordTableCell : 1; |
111 | | bool mbUseGapColor : 1; |
112 | | |
113 | | public: |
114 | | /** Constructs an invisible frame style. */ |
115 | | explicit Style(); |
116 | | /** Constructs a frame style with passed line widths. */ |
117 | | explicit Style( double nP, double nD, double nS, SvxBorderLineStyle nType, double fScale ); |
118 | | /** Constructs a frame style with passed color and line widths. */ |
119 | | explicit Style( const Color& rColorPrim, const Color& rColorSecn, const Color& rColorGap, bool bUseGapColor, double nP, double nD, double nS, SvxBorderLineStyle nType, double fScale ); |
120 | | /** Constructs a frame style from the passed SvxBorderLine struct. */ |
121 | | explicit Style( const editeng::SvxBorderLine* pBorder, double fScale ); |
122 | | |
123 | 9.48k | RefMode GetRefMode() const { return meRefMode; } |
124 | 18.9k | Color GetColorPrim() const { return maColorPrim; } |
125 | 9.48k | Color GetColorSecn() const { return maColorSecn; } |
126 | 0 | Color GetColorGap() const { return maColorGap; } |
127 | 18 | bool UseGapColor() const { return mbUseGapColor; } |
128 | 16.9k | double Prim() const { return mfPrim; } |
129 | 16.9k | double Dist() const { return mfDist; } |
130 | 29.3k | double Secn() const { return mfSecn; } |
131 | 2.95k | double PatternScale() const { return mfPatternScale;} |
132 | 5.01k | SvxBorderLineStyle Type() const { return mnType; } |
133 | | |
134 | | /// Check if this style is used - this depends on it having any width definition. |
135 | | /// As can be seen in the definition comment above, Prim() *must* be non zero to have a width |
136 | 2.71M | bool IsUsed() const { return 0.0 != mfPrim; } |
137 | | |
138 | | /** Returns the total width of this frame style. */ |
139 | 8.55k | double GetWidth() const { return mfPrim + mfDist + mfSecn; } |
140 | | |
141 | | /** Sets the frame style to invisible state. */ |
142 | | void Clear(); |
143 | | /** Sets the frame style to the passed line widths. */ |
144 | | void Set( double nP, double nD, double nS ); |
145 | | /** Sets the frame style to the passed line widths. */ |
146 | | void Set( const Color& rColorPrim, const Color& rColorSecn, const Color& rColorGap, bool bUseGapColor, double nP, double nD, double nS ); |
147 | | /** Sets the frame style to the passed SvxBorderLine struct. If nullptr, resets the style */ |
148 | | void Set( const editeng::SvxBorderLine* pBorder, double fScale, sal_uInt16 nMaxWidth = SAL_MAX_UINT16 ); |
149 | | |
150 | | /** Sets a new reference point handling mode, does not modify other settings. */ |
151 | 544 | void SetRefMode( RefMode eRefMode ) { meRefMode = eRefMode; } |
152 | | /** Sets a new color, does not modify other settings. */ |
153 | 0 | void SetColorPrim( const Color& rColor ) { maColorPrim = rColor; } |
154 | 0 | void SetColorSecn( const Color& rColor ) { maColorSecn = rColor; } |
155 | | /** Sets whether to use dotted style for single hair lines. */ |
156 | 266 | void SetType( SvxBorderLineStyle nType ) { mnType = nType; } |
157 | | |
158 | | /** Mirrors this style (exchanges primary and secondary), if it is a double frame style. */ |
159 | | void MirrorSelf(); |
160 | | |
161 | | /** Enables the Word-compatible Style comparison code. */ |
162 | 544 | void SetWordTableCell(bool bWordTableCell) { mbWordTableCell = bWordTableCell; } |
163 | | |
164 | | bool operator==( const Style& rOther) const; |
165 | | bool operator<( const Style& rOther) const; |
166 | | size_t hashCode() const; |
167 | | }; |
168 | | |
169 | 0 | inline bool operator>( const Style& rL, const Style& rR ) { return rR.operator<(rL); } |
170 | | |
171 | | inline Style::Style() |
172 | 2.87k | : mfPrim(0) |
173 | 2.87k | , mfDist(0) |
174 | 2.87k | , mfSecn(0) |
175 | 2.87k | , mfPatternScale(1.0) |
176 | 2.87k | , mnType(SvxBorderLineStyle::SOLID) |
177 | 2.87k | , meRefMode(RefMode::Centered) |
178 | 2.87k | , mbWordTableCell(false) |
179 | 2.87k | , mbUseGapColor(false) |
180 | 2.87k | {} |
181 | | |
182 | | } |
183 | | |
184 | | |
185 | | #endif |
186 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |