// class SvxBorderLine --------------------------------------------------
namespace {
Color lcl_compute3DColor( Color aMain, int nLight, int nMedium, int nDark )
{
basegfx::BColor color = aMain.getBColor( );
basegfx::BColor hsl = basegfx::utils::rgb2hsl( color );
if (xComplexColor.is())
{ auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
setComplexColor(aComplexColor);
} returntrue;
}
Color SvxBorderLine::darkColor( Color aMain )
{ return aMain;
}
Color SvxBorderLine::lightColor( Color aMain )
{
// Divide Luminance by 2
basegfx::BColor color = aMain.getBColor( );
basegfx::BColor hsl = basegfx::utils::rgb2hsl( color );
hsl.setZ( hsl.getZ() * 0.5 );
color = basegfx::utils::hsl2rgb( hsl );
return Color( color );
}
Color SvxBorderLine::threeDLightColor( Color aMain )
{ // These values have been defined in an empirical way return lcl_compute3DColor( aMain, 3, 40, 83 );
}
Color SvxBorderLine::threeDDarkColor( Color aMain )
{ // These values have been defined in an empirical way return lcl_compute3DColor( aMain, -85, -43, -1 );
}
Color SvxBorderLine::threeDMediumColor( Color aMain )
{ // These values have been defined in an empirical way return lcl_compute3DColor( aMain, -42, -0, 42 );
}
SvxBorderLine::SvxBorderLine( const Color *pCol, tools::Long nWidth,
SvxBorderLineStyle nStyle,
Color (*pColorOutFn)( Color ), Color (*pColorInFn)( Color ) )
: m_nWidth(nWidth)
, m_nMult(1)
, m_nDiv(1)
, m_pColorOutFn(pColorOutFn)
, m_pColorInFn(pColorInFn)
, m_pColorGapFn(nullptr)
, m_aWidthImpl(SvxBorderLine::getWidthImpl(nStyle))
, m_nStyle(nStyle)
, m_bMirrorWidths(false)
, m_bUseLeftTop(false)
{ if (pCol)
m_aColor = *pCol;
}
SvxBorderLineStyle
ConvertBorderStyleFromWord(intconst nWordLineStyle)
{ switch (nWordLineStyle)
{ // First the single lines case1: case2: // thick line case5: // hairline // and the unsupported special cases which we map to a single line case20: return SvxBorderLineStyle::SOLID; case6: return SvxBorderLineStyle::DOTTED; case7: return SvxBorderLineStyle::DASHED; case22: return SvxBorderLineStyle::FINE_DASHED; case8: return SvxBorderLineStyle::DASH_DOT; case9: return SvxBorderLineStyle::DASH_DOT_DOT; // then the shading beams which we represent by a double line case23: return SvxBorderLineStyle::DOUBLE; // then the double lines, for which we have good matches case3: case10: // Don't have triple so use double case21: // Don't have double wave: use double instead return SvxBorderLineStyle::DOUBLE; case11: return SvxBorderLineStyle::THINTHICK_SMALLGAP; case12: case13: // Don't have thin thick thin, so use thick thin return SvxBorderLineStyle::THICKTHIN_SMALLGAP; case14: return SvxBorderLineStyle::THINTHICK_MEDIUMGAP; case15: case16: // Don't have thin thick thin, so use thick thin return SvxBorderLineStyle::THICKTHIN_MEDIUMGAP; case17: return SvxBorderLineStyle::THINTHICK_LARGEGAP; case18: case19: // Don't have thin thick thin, so use thick thin return SvxBorderLineStyle::THICKTHIN_LARGEGAP; case24: return SvxBorderLineStyle::EMBOSSED; case25: return SvxBorderLineStyle::ENGRAVED; case26: return SvxBorderLineStyle::OUTSET; case27: return SvxBorderLineStyle::INSET; default: return SvxBorderLineStyle::NONE;
}
}
double
ConvertBorderWidthFromWord(SvxBorderLineStyle const eStyle, doubleconst i_fWidth, intconst nWordLineStyle)
{ // fdo#68779: at least for RTF, 0.75pt is the default if width is missing doubleconst fWidth((i_fWidth == 0.0) ? 15.0 : i_fWidth); switch (eStyle)
{ // Single lines case SvxBorderLineStyle::SOLID: switch (nWordLineStyle)
{ case2: return (fWidth * 2.0); // thick case5: // fdo#55526: map 0 hairline width to > 0 return std::max(fWidth, 1.0); default: return fWidth;
} break;
case SvxBorderLineStyle::DOTTED: case SvxBorderLineStyle::DASHED: case SvxBorderLineStyle::DASH_DOT: case SvxBorderLineStyle::DASH_DOT_DOT: return fWidth;
// Display a minimum effective border width of 1pt case SvxBorderLineStyle::FINE_DASHED: return (fWidth > 0 && fWidth < 20) ? 20 : fWidth;
// Double lines case SvxBorderLineStyle::DOUBLE: return fWidth * 3.0;
case SvxBorderLineStyle::THINTHICK_MEDIUMGAP: case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP: case SvxBorderLineStyle::EMBOSSED: case SvxBorderLineStyle::ENGRAVED: return fWidth * 2.0;
case SvxBorderLineStyle::THINTHICK_SMALLGAP: return fWidth + THINTHICK_SMALLGAP_line2 + THINTHICK_SMALLGAP_gap;
case SvxBorderLineStyle::THINTHICK_LARGEGAP: return fWidth + THINTHICK_LARGEGAP_line1 + THINTHICK_LARGEGAP_line2;
case SvxBorderLineStyle::THICKTHIN_SMALLGAP: return fWidth + THICKTHIN_SMALLGAP_line1 + THICKTHIN_SMALLGAP_gap;
case SvxBorderLineStyle::THICKTHIN_LARGEGAP: return fWidth + THICKTHIN_LARGEGAP_line1 + THICKTHIN_LARGEGAP_line2;
case SvxBorderLineStyle::OUTSET: return (fWidth * 2.0) + OUTSET_line1;
case SvxBorderLineStyle::INSET: return (fWidth * 2.0) + INSET_line2;
default:
assert(false); // should only be called for known border style
} return0;
}
switch (eStyle)
{ // Single lines case SvxBorderLineStyle::SOLID: case SvxBorderLineStyle::DOTTED: case SvxBorderLineStyle::DASHED: case SvxBorderLineStyle::FINE_DASHED: case SvxBorderLineStyle::DASH_DOT: case SvxBorderLineStyle::DASH_DOT_DOT: return fWidth;
// Double lines case SvxBorderLineStyle::DOUBLE: case SvxBorderLineStyle::DOUBLE_THIN: return std::max(1.0, fWidth / 3.0);
case SvxBorderLineStyle::THINTHICK_MEDIUMGAP: case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP: case SvxBorderLineStyle::EMBOSSED: case SvxBorderLineStyle::ENGRAVED: return std::max(1.0, fWidth / 2.0);
case SvxBorderLineStyle::THINTHICK_SMALLGAP: return std::max(1.0, fWidth - THINTHICK_SMALLGAP_line2 - THINTHICK_SMALLGAP_gap);
case SvxBorderLineStyle::THINTHICK_LARGEGAP: return std::max(1.0, fWidth - THINTHICK_LARGEGAP_line1 - THINTHICK_LARGEGAP_line2);
case SvxBorderLineStyle::THICKTHIN_SMALLGAP: return std::max(1.0, fWidth - THICKTHIN_SMALLGAP_line1 - THICKTHIN_SMALLGAP_gap);
case SvxBorderLineStyle::THICKTHIN_LARGEGAP: return std::max(1.0, fWidth - THICKTHIN_LARGEGAP_line1 - THICKTHIN_LARGEGAP_line2);
case SvxBorderLineStyle::OUTSET: return std::max(1.0, (fWidth - OUTSET_line1) / 2.0);
case SvxBorderLineStyle::INSET: return std::max(1.0, (fWidth - INSET_line2) / 2.0);
case SvxBorderLineStyle::NONE: return0;
default:
assert(false); // should only be called for known border style return0;
}
}
/** Get the BorderWithImpl object corresponding to the given #nStyle, all the unitshandledbytheresultingobjectareTwipsandthe BorderWidthImpl::GetLine1()correspondstotheOuterLine.
*/
BorderWidthImpl SvxBorderLine::getWidthImpl( SvxBorderLineStyle nStyle )
{
BorderWidthImpl aImpl;
switch ( nStyle )
{ // No line: no width case SvxBorderLineStyle::NONE:
aImpl = BorderWidthImpl( BorderWidthImplFlags::FIXED, 0.0 ); break;
// Single lines case SvxBorderLineStyle::SOLID: case SvxBorderLineStyle::DOTTED: case SvxBorderLineStyle::DASHED: case SvxBorderLineStyle::FINE_DASHED: case SvxBorderLineStyle::DASH_DOT: case SvxBorderLineStyle::DASH_DOT_DOT:
aImpl = BorderWidthImpl( BorderWidthImplFlags::CHANGE_LINE1, 1.0 ); break;
// Double lines
case SvxBorderLineStyle::DOUBLE:
aImpl = BorderWidthImpl(
BorderWidthImplFlags::CHANGE_LINE1 | BorderWidthImplFlags::CHANGE_LINE2 | BorderWidthImplFlags::CHANGE_DIST, // fdo#46112 fdo#38542 fdo#43249: // non-constant widths must sum to 1 1.0/3.0, 1.0/3.0, 1.0/3.0 ); break;
case SvxBorderLineStyle::DOUBLE_THIN:
aImpl = BorderWidthImpl(BorderWidthImplFlags::CHANGE_DIST, 10.0, 10.0, 1.0); break;
tools::Long nWidth = 0; for (auto nTestStyle : aDoubleStyles)
{
BorderWidthImpl aWidthImpl = getWidthImpl( nTestStyle );
nWidth = aWidthImpl.GuessWidth( nOut, nIn, nDist ); if (nWidth != 0)
{ // If anything matched, then set it
nStyle = nTestStyle;
SetBorderLineStyle(nStyle);
m_nWidth = nWidth; break;
}
}
if (nWidth == 0)
{ // fdo#38542: not a known double, default to something custom...
SetBorderLineStyle(nStyle);
m_nWidth = nOut + nIn + nDist; if (m_nWidth)
{
m_aWidthImpl = BorderWidthImpl(
BorderWidthImplFlags::CHANGE_LINE1 | BorderWidthImplFlags::CHANGE_LINE2 | BorderWidthImplFlags::CHANGE_DIST, static_cast<double>(nOut ) / static_cast<double>(m_nWidth), static_cast<double>(nIn ) / static_cast<double>(m_nWidth), static_cast<double>(nDist) / static_cast<double>(m_nWidth));
}
}
} else
{
SetBorderLineStyle(nStyle); if (nOut == 0 && nIn > 0)
{ // If only inner width is given swap inner and outer widths for // single line styles, otherwise GuessWidth() marks this as invalid // and returns a 0 width. switch (nStyle)
{ case SvxBorderLineStyle::SOLID: case SvxBorderLineStyle::DOTTED: case SvxBorderLineStyle::DASHED: case SvxBorderLineStyle::FINE_DASHED: case SvxBorderLineStyle::DASH_DOT: case SvxBorderLineStyle::DASH_DOT_DOT:
std::swap( nOut, nIn); break; default:
; // nothing
}
}
m_nWidth = m_aWidthImpl.GuessWidth( nOut, nIn, nDist );
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.