tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / include / svx / framelink.hxx
blobfdd20c5994bff7f86123ecbc5fb3e24c7862529d
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 namespace svx::frame {
31 // Enums
34 /** Specifies how the reference points for frame borders are used.
36 enum class RefMode : sal_uInt8
38 /** Frame borders are drawn centered to the reference points. */
39 Centered,
41 /** The reference points specify the begin of the frame border width.
43 The result is that horizontal lines are drawn below, and vertical lines
44 are drawn right of the reference points.
46 Begin,
48 /** The reference points specify the end of the frame border width.
50 The result is that horizontal lines are drawn above, and vertical lines
51 are drawn left of the reference points.
53 End
57 // Classes
60 /** Contains the widths of primary and secondary line of a frame style.
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.
66 The following states of the members of this struct are valid:
68 mnPrim mnDist mnSecn frame style
69 -------------------------------------------------
70 0 0 0 invisible
71 >0 0 0 single
72 >0 >0 >0 double
74 The behaviour of the member functions for other states is not defined.
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.
82 The following picture shows the upper end of a vertical double frame
83 border.
85 |<---------------- GetWidth() ----------------->|
86 | |
87 |<----- mnPrim ----->||<- mnDist ->||<- mnSecn >|
88 | || || |
89 ###################### #############
90 ###################### #############
91 ###################### #############
92 ###################### #############
93 ###################### | #############
94 ###################### | #############
96 |<- middle of the frame border
98 class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC Style
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;
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 );
123 RefMode GetRefMode() const { return meRefMode; }
124 Color GetColorPrim() const { return maColorPrim; }
125 Color GetColorSecn() const { return maColorSecn; }
126 Color GetColorGap() const { return maColorGap; }
127 bool UseGapColor() const { return mbUseGapColor; }
128 double Prim() const { return mfPrim; }
129 double Dist() const { return mfDist; }
130 double Secn() const { return mfSecn; }
131 double PatternScale() const { return mfPatternScale;}
132 SvxBorderLineStyle Type() const { return mnType; }
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 bool IsUsed() const { return 0.0 != mfPrim; }
138 /** Returns the total width of this frame style. */
139 double GetWidth() const { return mfPrim + mfDist + mfSecn; }
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 );
150 /** Sets a new reference point handling mode, does not modify other settings. */
151 void SetRefMode( RefMode eRefMode ) { meRefMode = eRefMode; }
152 /** Sets a new color, does not modify other settings. */
153 void SetColorPrim( const Color& rColor ) { maColorPrim = rColor; }
154 void SetColorSecn( const Color& rColor ) { maColorSecn = rColor; }
155 /** Sets whether to use dotted style for single hair lines. */
156 void SetType( SvxBorderLineStyle nType ) { mnType = nType; }
158 /** Mirrors this style (exchanges primary and secondary), if it is a double frame style. */
159 void MirrorSelf();
161 /** Enables the Word-compatible Style comparison code. */
162 void SetWordTableCell(bool bWordTableCell) { mbWordTableCell = bWordTableCell; }
164 bool operator==( const Style& rOther) const;
165 bool operator<( const Style& rOther) const;
166 size_t hashCode() const;
169 inline bool operator>( const Style& rL, const Style& rR ) { return rR.operator<(rL); }
171 inline Style::Style()
172 : mfPrim(0)
173 , mfDist(0)
174 , mfSecn(0)
175 , mfPatternScale(1.0)
176 , mnType(SvxBorderLineStyle::SOLID)
177 , meRefMode(RefMode::Centered)
178 , mbWordTableCell(false)
179 , mbUseGapColor(false)
185 #endif
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */