1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
37 /** Specifies how the reference points for frame borders are used.
41 /** Frame borders are drawn centered to the reference points. */
44 /** The reference points specify the begin of the frame border width.
46 The result is that horizontal lines are drawn below, and vertical lines
47 are drawn right of the reference points.
51 /** The reference points specify the end of the frame border width.
53 The result is that horizontal lines are drawn above, and vertical lines
54 are drawn left of the reference points.
63 /** Contains the widths of primary and secondary line of a frame style.
65 In the following, "frame style" is a complete style of one frame border,
66 i.e. the double line at the left side of the frame. A "line" is always a
67 trivial single line, i.e. the first line of a double frame style.
69 The following states of the members of this struct are valid:
71 mnPrim mnDist mnSecn frame style
72 -------------------------------------------------
77 The behaviour of the member functions for other states is not defined.
79 Per definition the primary line in double frame styles is:
80 - The top line for horizontal frame borders.
81 - The left line for vertical frame borders.
82 - The bottom-left line for top-left to bottom-right diagonal frame borders.
83 - The top-left line for bottom-left to top-right diagonal frame borders.
85 The following picture shows the upper end of a vertical double frame
88 |<---------------- GetWidth() ----------------->|
90 |<----- mnPrim ----->||<- mnDist ->||<- mnSecn >|
92 ###################### #############
93 ###################### #############
94 ###################### #############
95 ###################### #############
96 ###################### | #############
97 ###################### | #############
99 |<- middle of the frame border
101 class SAL_WARN_UNUSED SVX_DLLPUBLIC Style
113 RefMode meRefMode
; /// Reference point handling for this frame border.
114 double mfPrim
; /// Width of primary (single, left, or top) line.
115 double mfDist
; /// Distance between primary and secondary line.
116 double mfSecn
; /// Width of secondary (right or bottom) line.
117 double mfPatternScale
; /// Scale used for line pattern spacing.
118 SvxBorderLineStyle mnType
;
119 bool mbWordTableCell
;
122 /** Constructs an invisible frame style. */
123 explicit implStyle() :
127 mbUseGapColor(false),
128 meRefMode(RefMode::Centered
),
133 mnType(SvxBorderLineStyle::SOLID
),
134 mbWordTableCell(false)
138 /// the impl class holding the data
139 std::shared_ptr
< implStyle
> maImplStyle
;
141 /// call to set maImplStyle on demand
142 void implEnsureImplStyle();
145 /** Constructs an invisible frame style. */
147 /** Constructs a frame style with passed line widths. */
148 explicit Style( double nP
, double nD
, double nS
, SvxBorderLineStyle nType
, double fScale
);
149 /** Constructs a frame style with passed color and line widths. */
150 explicit Style( const Color
& rColorPrim
, const Color
& rColorSecn
, const Color
& rColorGap
, bool bUseGapColor
, double nP
, double nD
, double nS
, SvxBorderLineStyle nType
, double fScale
);
151 /** Constructs a frame style from the passed SvxBorderLine struct. */
152 explicit Style( const editeng::SvxBorderLine
* pBorder
, double fScale
);
154 RefMode
GetRefMode() const { if(!maImplStyle
) return RefMode::Centered
; return maImplStyle
->meRefMode
; }
155 Color
GetColorPrim() const { if(!maImplStyle
) return Color(); return maImplStyle
->maColorPrim
; }
156 Color
GetColorSecn() const { if(!maImplStyle
) return Color(); return maImplStyle
->maColorSecn
; }
157 Color
GetColorGap() const { if(!maImplStyle
) return Color(); return maImplStyle
->maColorGap
; }
158 bool UseGapColor() const { if(!maImplStyle
) return false; return maImplStyle
->mbUseGapColor
; }
159 double Prim() const { if(!maImplStyle
) return 0.0; return maImplStyle
->mfPrim
; }
160 double Dist() const { if(!maImplStyle
) return 0.0; return maImplStyle
->mfDist
; }
161 double Secn() const { if(!maImplStyle
) return 0.0; return maImplStyle
->mfSecn
; }
162 double PatternScale() const { if(!maImplStyle
) return 1.0; return maImplStyle
->mfPatternScale
;}
163 SvxBorderLineStyle
Type() const { if(!maImplStyle
) return SvxBorderLineStyle::SOLID
; return maImplStyle
->mnType
; }
165 /// Check if this style is used - this depends on it having any width definition.
166 /// As can be seen in the definition comment above, Prim() *must* be non zero to have a width
167 bool IsUsed() const { if(!maImplStyle
) return false; return 0.0 != maImplStyle
->mfPrim
; }
169 /** Returns the total width of this frame style. */
170 double GetWidth() const { if(!maImplStyle
) return 0.0; implStyle
* pTarget
= maImplStyle
.get(); return pTarget
->mfPrim
+ pTarget
->mfDist
+ pTarget
->mfSecn
; }
172 /** Sets the frame style to invisible state. */
174 /** Sets the frame style to the passed line widths. */
175 void Set( double nP
, double nD
, double nS
);
176 /** Sets the frame style to the passed line widths. */
177 void Set( const Color
& rColorPrim
, const Color
& rColorSecn
, const Color
& rColorGap
, bool bUseGapColor
, double nP
, double nD
, double nS
);
178 /** Sets the frame style to the passed SvxBorderLine struct. If nullptr, resets the style */
179 void Set( const editeng::SvxBorderLine
* pBorder
, double fScale
, sal_uInt16 nMaxWidth
= SAL_MAX_UINT16
);
181 /** Sets a new reference point handling mode, does not modify other settings. */
182 void SetRefMode( RefMode eRefMode
);
183 /** Sets a new color, does not modify other settings. */
184 void SetColorPrim( const Color
& rColor
);
185 void SetColorSecn( const Color
& rColor
);
186 /** Sets whether to use dotted style for single hair lines. */
187 void SetType( SvxBorderLineStyle nType
);
189 /** Mirrors this style (exchanges primary and secondary), if it is a double frame style. */
192 /** Enables the Word-compatible Style comparison code. */
193 void SetWordTableCell(bool bWordTableCell
);
195 bool operator==( const Style
& rOther
) const;
196 bool operator<( const Style
& rOther
) const;
199 inline bool operator>( const Style
& rL
, const Style
& rR
) { return rR
.operator<(rL
); }
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */