LibreOffice Module svx (master)  1
framelink.hxx
Go to the documentation of this file.
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 #include <memory>
29 
30 namespace svx {
31 namespace frame {
32 
33 
34 // Enums
35 
36 
39 enum class RefMode
40 {
42  Centered,
43 
49  Begin,
50 
56  End
57 };
58 
59 
60 // Classes
61 
62 
102 {
103 private:
104  class implStyle
105  {
106  private:
107  friend class Style;
108 
114  double mfPrim;
115  double mfDist;
116  double mfSecn;
117  double mfPatternScale;
120 
121  public:
123  explicit implStyle() :
124  maColorPrim(),
125  maColorSecn(),
126  maColorGap(),
127  mbUseGapColor(false),
128  meRefMode(RefMode::Centered),
129  mfPrim(0.0),
130  mfDist(0.0),
131  mfSecn(0.0),
132  mfPatternScale(1.0),
133  mnType(SvxBorderLineStyle::SOLID),
134  mbWordTableCell(false)
135  {}
136  };
137 
139  std::shared_ptr< implStyle > maImplStyle;
140 
142  void implEnsureImplStyle();
143 
144 public:
146  explicit Style();
148  explicit Style( double nP, double nD, double nS, SvxBorderLineStyle nType, double fScale );
150  explicit Style( const Color& rColorPrim, const Color& rColorSecn, const Color& rColorGap, bool bUseGapColor, double nP, double nD, double nS, SvxBorderLineStyle nType, double fScale );
152  explicit Style( const editeng::SvxBorderLine* pBorder, double fScale );
153 
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; }
164 
167  bool IsUsed() const { if(!maImplStyle) return false; return 0.0 != maImplStyle->mfPrim; }
168 
170  double GetWidth() const { if(!maImplStyle) return 0.0; implStyle* pTarget = maImplStyle.get(); return pTarget->mfPrim + pTarget->mfDist + pTarget->mfSecn; }
171 
173  void Clear();
175  void Set( double nP, double nD, double nS );
177  void Set( const Color& rColorPrim, const Color& rColorSecn, const Color& rColorGap, bool bUseGapColor, double nP, double nD, double nS );
179  void Set( const editeng::SvxBorderLine* pBorder, double fScale, sal_uInt16 nMaxWidth = SAL_MAX_UINT16 );
180 
182  void SetRefMode( RefMode eRefMode );
184  void SetColorPrim( const Color& rColor );
185  void SetColorSecn( const Color& rColor );
187  void SetType( SvxBorderLineStyle nType );
188 
190  Style& MirrorSelf();
191 
193  void SetWordTableCell(bool bWordTableCell);
194 
195  bool operator==( const Style& rOther) const;
196  bool operator<( const Style& rOther) const;
197 };
198 
199 inline bool operator>( const Style& rL, const Style& rR ) { return rR.operator<(rL); }
200 
201 }
202 }
203 
204 #endif
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
double mfSecn
Distance between primary and secondary line.
Definition: framelink.hxx:116
double Dist() const
Definition: framelink.hxx:160
std::shared_ptr< implStyle > maImplStyle
the impl class holding the data
Definition: framelink.hxx:139
RefMode GetRefMode() const
Definition: framelink.hxx:154
SvxBorderLineStyle Type() const
Definition: framelink.hxx:163
Color GetColorSecn() const
Definition: framelink.hxx:156
The reference points specify the end of the frame border width.
double GetWidth() const
Returns the total width of this frame style.
Definition: framelink.hxx:170
Color GetColorGap() const
Definition: framelink.hxx:157
bool IsUsed() const
Check if this style is used - this depends on it having any width definition.
Definition: framelink.hxx:167
bool UseGapColor() const
Definition: framelink.hxx:158
SvxBorderLineStyle
bool operator>(const Style &rL, const Style &rR)
Definition: framelink.hxx:199
SvxBorderLineStyle mnType
Scale used for line pattern spacing.
Definition: framelink.hxx:118
double Secn() const
Definition: framelink.hxx:161
implStyle()
Constructs an invisible frame style.
Definition: framelink.hxx:123
double PatternScale() const
Definition: framelink.hxx:162
#define SAL_WARN_UNUSED
Color GetColorPrim() const
Definition: framelink.hxx:155
bool operator<(const Subset &rLHS, const Subset &rRHS)
Definition: ucsubset.hxx:49
Frame borders are drawn centered to the reference points.
double mfDist
Width of primary (single, left, or top) line.
Definition: framelink.hxx:115
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
Contains the widths of primary and secondary line of a frame style.
Definition: framelink.hxx:101
The reference points specify the begin of the frame border width.
double Prim() const
Definition: framelink.hxx:159
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)
double mfPatternScale
Width of secondary (right or bottom) line.
Definition: framelink.hxx:117
RefMode
Specifies how the reference points for frame borders are used.
Definition: framelink.hxx:39
double mfPrim
Reference point handling for this frame border.
Definition: framelink.hxx:114