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