22 #include <rtl/math.hxx>
43 mfPatternScale = fScale;
47 Style::Style(
const Color& rColorPrim,
const Color& rColorSecn,
const Color& rColorGap,
bool bUseGapColor,
double nP,
double nD,
double nS,
SvxBorderLineStyle nType,
double fScale )
51 mfPatternScale = fScale;
52 Set( rColorPrim, rColorSecn, rColorGap, bUseGapColor, nP, nD, nS );
58 if(
nullptr != pBorder)
60 mfPatternScale = fScale;
61 Set( pBorder, fScale );
67 maColorPrim =
Color();
68 maColorSecn =
Color();
70 mbUseGapColor =
false;
71 meRefMode = RefMode::Centered;
76 mnType = SvxBorderLineStyle::SOLID;
77 mbWordTableCell =
false;
80 void Style::Set(
double nP,
double nD,
double nS )
89 mfPrim = rtl::math::round(nP ? nP : nS, 2);
90 mfDist = rtl::math::round((nP && nS) ? nD : 0, 2);
91 mfSecn = rtl::math::round((nP && nD) ? nS : 0, 2);
94 void Style::Set(
const Color& rColorPrim,
const Color& rColorSecn,
const Color& rColorGap,
bool bUseGapColor,
double nP,
double nD,
double nS )
96 maColorPrim = rColorPrim;
97 maColorSecn = rColorSecn;
98 maColorGap = rColorGap;
99 mbUseGapColor = bUseGapColor;
103 void Style::Set(
const SvxBorderLine* pBorder,
double fScale, sal_uInt16 nMaxWidth )
105 if(
nullptr == pBorder)
118 const sal_uInt16 nSecn(pBorder->
GetInWidth());
121 mfPatternScale = fScale;
125 Set( std::min<double>(nPrim * fScale, nMaxWidth), 0, 0 );
129 Set(std::min<double>(nPrim * fScale, nMaxWidth), std::min<double>(nDist * fScale, nMaxWidth), std::min<double>(nSecn * fScale, nMaxWidth));
131 double nPixWidth = std::min<double>((nPrim + nDist + nSecn) * fScale, nMaxWidth);
133 if( nPixWidth > GetWidth() )
135 mfDist = nPixWidth - mfPrim - mfSecn;
139 while( GetWidth() > nMaxWidth )
149 if (mfPrim != 0.0 && rtl::math::approxEqual(mfPrim, mfSecn))
161 if ((GetWidth() > nMaxWidth) && mfSecn != 0.0)
171 std::swap( mfPrim, mfSecn );
173 std::swap( maColorPrim, maColorSecn );
176 if( meRefMode != RefMode::Centered )
178 meRefMode = (meRefMode == RefMode::Begin) ? RefMode::End : RefMode::Begin;
184 bool Style::operator==(
const Style& rOther)
const
186 return (Prim() == rOther.
Prim()
187 && Dist() == rOther.
Dist()
188 && Secn() == rOther.
Secn()
203 double GetWordTableCellBorderWeight(
const Style& rStyle)
206 int nBorderNumber = 0;
210 switch (rStyle.
Type())
212 case SvxBorderLineStyle::NONE:
214 case SvxBorderLineStyle::DOTTED:
215 case SvxBorderLineStyle::DASHED:
217 case SvxBorderLineStyle::SOLID:
223 case SvxBorderLineStyle::DOUBLE:
224 case SvxBorderLineStyle::DOUBLE_THIN:
231 case SvxBorderLineStyle::DASH_DOT:
235 case SvxBorderLineStyle::DASH_DOT_DOT:
239 case SvxBorderLineStyle::THINTHICK_SMALLGAP:
243 case SvxBorderLineStyle::THICKTHIN_SMALLGAP:
248 case SvxBorderLineStyle::THINTHICK_MEDIUMGAP:
252 case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP:
257 case SvxBorderLineStyle::THINTHICK_LARGEGAP:
261 case SvxBorderLineStyle::THICKTHIN_LARGEGAP:
266 case SvxBorderLineStyle::FINE_DASHED:
270 case SvxBorderLineStyle::EMBOSSED:
274 case SvxBorderLineStyle::ENGRAVED:
278 case SvxBorderLineStyle::OUTSET:
282 case SvxBorderLineStyle::INSET:
288 return nBorderNumber * fWidth;
298 double fLW = GetWordTableCellBorderWeight(*
this);
299 double fRW = GetWordTableCellBorderWeight(rOther);
300 if (!rtl::math::approxEqual(fLW, fRW))
307 double nLW = GetWidth();
309 if( !rtl::math::approxEqual(nLW, nRW) )
return nLW < nRW;
312 if( (Secn() == 0) != (rOther.
Secn() == 0) )
return Secn() == 0;
315 if( (Secn() && rOther.
Secn()) && !rtl::math::approxEqual(Dist(), rOther.
Dist()) )
return Dist() > rOther.
Dist();
318 if ((nLW == 1) && !Secn() && !rOther.
Secn() && (
Type() != rOther.
Type()))
return Type() > rOther.
Type();
RefMode GetRefMode() const
SvxBorderLineStyle Type() const
Color GetColorSecn() const
double GetWidth() const
Returns the total width of this frame style.
Color GetColorGap() const
sal_uInt16 GetOutWidth() const
sal_uInt16 GetDistance() const
Color GetColorOut(bool bLeftOrTop=true) const
Color GetColorIn(bool bLeftOrTop=true) const
Color GetColorPrim() const
bool operator<(const Subset &rLHS, const Subset &rRHS)
Contains the widths of primary and secondary line of a frame style.
SvxBorderLineStyle GetBorderLineStyle() const
Color GetColorGap() const
sal_uInt16 GetInWidth() const