oox/source/drawingml/color.cxx | 33 ++++++++++++--------------------- sc/inc/patattr.hxx | 16 ++++++++-------- sc/qa/unit/helper/qahelper.cxx | 4 ++-- sc/source/core/data/patattr.cxx | 18 +++++++++--------- sc/source/filter/excel/xecontent.cxx | 2 +- sc/source/filter/excel/xehelper.cxx | 6 +++--- sc/source/filter/excel/xestyle.cxx | 2 +- sc/source/ui/view/output2.cxx | 6 +++--- sc/source/ui/view/printfun.cxx | 4 ++-- 9 files changed, 41 insertions(+), 50 deletions(-)
New commits: commit 9e7ac82396304be0a4d7d9d8836de20690c76b69 Author: Noel Grandin <[email protected]> AuthorDate: Sun Jun 25 15:41:37 2023 +0200 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Jun 30 22:50:14 2023 +0200 convert ScAutoFontColorMode to scoped enum Change-Id: Id34bac78719943bd4c4cbfa60e0cb86b4ca570f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153562 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153795 diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx index ba15cfb1dd27..8269a36cb985 100644 --- a/sc/inc/patattr.hxx +++ b/sc/inc/patattr.hxx @@ -39,15 +39,15 @@ enum class ScRotateDir : sal_uInt8; /// how to treat COL_AUTO in GetFont: -enum ScAutoFontColorMode +enum class ScAutoFontColorMode { - SC_AUTOCOL_RAW, ///< COL_AUTO is returned - SC_AUTOCOL_BLACK, ///< always use black - SC_AUTOCOL_PRINT, ///< black or white, depending on background - SC_AUTOCOL_DISPLAY, ///< from style settings, or black/white if needed - SC_AUTOCOL_IGNOREFONT, ///< like DISPLAY, but ignore stored font color (assume COL_AUTO) - SC_AUTOCOL_IGNOREBACK, ///< like DISPLAY, but ignore stored background color (use configured color) - SC_AUTOCOL_IGNOREALL ///< like DISPLAY, but ignore stored font and background colors + Raw, ///< COL_AUTO is returned + Black, ///< always use black + Print, ///< black or white, depending on background + Display, ///< from style settings, or black/white if needed + IgnoreFont, ///< like DISPLAY, but ignore stored font color (assume COL_AUTO) + IgnoreBack, ///< like DISPLAY, but ignore stored background color (use configured color) + IgnoreAll ///< like DISPLAY, but ignore stored font and background colors }; class SC_DLLPUBLIC ScPatternAttr final : public SfxSetItem diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index 82227ec12006..eff2c62d9aeb 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -180,7 +180,7 @@ void ScModelTestBase::testFormats(ScDocument* pDoc,std::u16string_view sFormat) Color aColor; pPattern->fillFontOnly(aFont); - pPattern->fillColor(aColor, SC_AUTOCOL_RAW); + pPattern->fillColor(aColor, ScAutoFontColorMode::Raw); CPPUNIT_ASSERT_EQUAL_MESSAGE("font size should be 10", tools::Long(200), aFont.GetFontSize().getHeight()); CPPUNIT_ASSERT_EQUAL_MESSAGE("font color should be black", COL_AUTO, aColor); pPattern = pDoc->GetPattern(0,1,1); @@ -194,7 +194,7 @@ void ScModelTestBase::testFormats(ScDocument* pDoc,std::u16string_view sFormat) CPPUNIT_ASSERT_EQUAL_MESSAGE("font should be bold", WEIGHT_BOLD, aFont.GetWeight()); pPattern = pDoc->GetPattern(1,0,1); pPattern->fillFontOnly(aFont); - pPattern->fillColor(aColor, SC_AUTOCOL_RAW); + pPattern->fillColor(aColor, ScAutoFontColorMode::Raw); CPPUNIT_ASSERT_EQUAL_MESSAGE("font should be blue", COL_BLUE, aColor); pPattern = pDoc->GetPattern(1,1,1); pPattern->fillFontOnly(aFont); diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 25900b7ac099..a8319639dddf 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -447,11 +447,11 @@ void ScPatternAttr::fillColor(Color& rColor, const SfxItemSet& rItemSet, ScAutoF aColor = pColorItem->GetValue(); - if ((aColor == COL_AUTO && eAutoMode != SC_AUTOCOL_RAW) - || eAutoMode == SC_AUTOCOL_IGNOREFONT - || eAutoMode == SC_AUTOCOL_IGNOREALL) + if ((aColor == COL_AUTO && eAutoMode != ScAutoFontColorMode::Raw) + || eAutoMode == ScAutoFontColorMode::IgnoreFont + || eAutoMode == ScAutoFontColorMode::IgnoreAll) { - if ( eAutoMode == SC_AUTOCOL_BLACK ) + if ( eAutoMode == ScAutoFontColorMode::Black ) aColor = COL_BLACK; else { @@ -471,12 +471,12 @@ void ScPatternAttr::fillColor(Color& rColor, const SfxItemSet& rItemSet, ScAutoF // if background color attribute is transparent, use window color for brightness comparisons if (aBackColor == COL_TRANSPARENT - || eAutoMode == SC_AUTOCOL_IGNOREBACK - || eAutoMode == SC_AUTOCOL_IGNOREALL) + || eAutoMode == ScAutoFontColorMode::IgnoreBack + || eAutoMode == ScAutoFontColorMode::IgnoreAll) { if (!comphelper::LibreOfficeKit::isActive()) { - if ( eAutoMode == SC_AUTOCOL_PRINT ) + if ( eAutoMode == ScAutoFontColorMode::Print ) aBackColor = COL_WHITE; else if ( pBackConfigColor ) { @@ -502,7 +502,7 @@ void ScPatternAttr::fillColor(Color& rColor, const SfxItemSet& rItemSet, ScAutoF // get system text color for comparison Color aSysTextColor; - if ( eAutoMode == SC_AUTOCOL_PRINT ) + if ( eAutoMode == ScAutoFontColorMode::Print ) aSysTextColor = COL_BLACK; else if ( pTextConfigColor ) { @@ -527,7 +527,7 @@ void ScPatternAttr::fillColor(Color& rColor, const SfxItemSet& rItemSet, ScAutoF } else { - // use aSysTextColor (black for SC_AUTOCOL_PRINT, from style settings otherwise) + // use aSysTextColor (black for ScAutoFontColorMode::Print, from style settings otherwise) aColor = aSysTextColor; } } diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 15141c161628..47114264a50e 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -670,7 +670,7 @@ XclExpCFImpl::XclExpCFImpl( const XclExpRoot& rRoot, const ScCondFormatEntry& rF vcl::Font aFont; ::Color aColor; ScPatternAttr::fillFontOnly(aFont, rItemSet); - ScPatternAttr::fillColor(aColor, rItemSet, SC_AUTOCOL_RAW); + ScPatternAttr::fillColor(aColor, rItemSet, ScAutoFontColorMode::Raw); maFontData.FillFromVclFont(aFont, aColor); mnFontColorId = GetPalette().InsertColor(maFontData.maColor, EXC_COLOR_CELLTEXT); } diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx index 14fafd8a42ba..e9390f8ce6f5 100644 --- a/sc/source/filter/excel/xehelper.cxx +++ b/sc/source/filter/excel/xehelper.cxx @@ -390,7 +390,7 @@ XclExpStringRef lclCreateFormattedString( // construct font from current text portion SvxFont aFont(XclExpFontHelper::GetFontFromItemSet(rRoot, rItemSet, nScript)); Color aColor; - ScPatternAttr::fillColor(aColor, rItemSet, SC_AUTOCOL_RAW); + ScPatternAttr::fillColor(aColor, rItemSet, ScAutoFontColorMode::Raw); // Excel start position of this portion sal_Int32 nXclPortionStart = xString->Len(); @@ -504,7 +504,7 @@ XclExpStringRef lclCreateFormattedString( nScript = nLastScript; SvxFont aFont( XclExpFontHelper::GetFontFromItemSet(rRoot, aItemSet, nScript)); Color aColor; - ScPatternAttr::fillColor(aColor, aItemSet, SC_AUTOCOL_RAW); + ScPatternAttr::fillColor(aColor, aItemSet, ScAutoFontColorMode::Raw); nLastScript = nScript; @@ -736,7 +736,7 @@ void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unico SfxItemSet aEditSet( mrEE.GetAttribs( aSel ) ); ScPatternAttr::GetFromEditItemSet( aItemSet, aEditSet ); ScPatternAttr::fillFontOnly(aFont, aItemSet); - ScPatternAttr::fillColor(aColor, aItemSet, SC_AUTOCOL_RAW); + ScPatternAttr::fillColor(aColor, aItemSet, ScAutoFontColorMode::Raw); // font name and style aNewData.maName = XclTools::GetXclFontName( aFont.GetFamilyName() ); diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 998cad5bb723..43b9ac5e23c2 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -1232,7 +1232,7 @@ sal_uInt16 XclExpFontBuffer::Insert(const SfxItemSet& rItemSet, sal_Int16 nScrip // #i17050# script type now provided by caller vcl::Font aFont = XclExpFontHelper::GetFontFromItemSet(GetRoot(), rItemSet, nScript); Color aColor; - ScPatternAttr::fillColor(aColor, rItemSet, SC_AUTOCOL_RAW); + ScPatternAttr::fillColor(aColor, rItemSet, ScAutoFontColorMode::Raw); return Insert(XclFontData(aFont, aColor), eColorType, bAppFont ); } diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index d8dfb064e605..07876568cb9a 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -325,12 +325,12 @@ void ScDrawStringsVars::SetPattern( if ( pOutput->mbUseStyleColor ) { if ( pOutput->mbForceAutoColor ) - eColorMode = bCellContrast ? SC_AUTOCOL_IGNOREALL : SC_AUTOCOL_IGNOREFONT; + eColorMode = bCellContrast ? ScAutoFontColorMode::IgnoreAll : ScAutoFontColorMode::IgnoreFont; else - eColorMode = bCellContrast ? SC_AUTOCOL_IGNOREBACK : SC_AUTOCOL_DISPLAY; + eColorMode = bCellContrast ? ScAutoFontColorMode::IgnoreBack : ScAutoFontColorMode::Display; } else - eColorMode = SC_AUTOCOL_PRINT; + eColorMode = ScAutoFontColorMode::Print; if (bPixelToLogic) pPattern->fillFont(aFont, eColorMode, pFmtDevice, nullptr, pCondSet, nScript, &aBackConfigColor, &aTextConfigColor); diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 9eb44e02c70b..a61520875238 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -1907,7 +1907,7 @@ tools::Long ScPrintFunc::DoNotes( tools::Long nNoteStart, bool bDoPrint, ScPrevi pEditEngine->SetDefaults( *pEditDefaults ); vcl::Font aMarkFont; - ScAutoFontColorMode eColorMode = bUseStyleColor ? SC_AUTOCOL_DISPLAY : SC_AUTOCOL_PRINT; + ScAutoFontColorMode eColorMode = bUseStyleColor ? ScAutoFontColorMode::Display : ScAutoFontColorMode::Print; rDoc.GetPool()->GetDefaultItem(ATTR_PATTERN).fillFont(aMarkFont, eColorMode); pDev->SetFont(aMarkFont); tools::Long nMarkLen = pDev->GetTextWidth("GW99999:"); @@ -2322,7 +2322,7 @@ void ScPrintFunc::PrintPage( tools::Long nPageNo, SCCOL nX1, SCROW nY1, SCCOL nX ScPatternAttr aPattern( rDoc.GetPool() ); vcl::Font aFont; - ScAutoFontColorMode eColorMode = bUseStyleColor ? SC_AUTOCOL_DISPLAY : SC_AUTOCOL_PRINT; + ScAutoFontColorMode eColorMode = bUseStyleColor ? ScAutoFontColorMode::Display : ScAutoFontColorMode::Print; aPattern.fillFont(aFont, eColorMode, pDev); pDev->SetFont(aFont); commit 1d7f60e0fe318f2fcada81611f9b2a0acc88413f Author: Tomaž Vajngerl <[email protected]> AuthorDate: Wed Jun 28 22:55:22 2023 +0900 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Jun 30 22:50:03 2023 +0200 oox: convert Excel tint value into LumOff and LumMod tint value can be converted into LumOff and LumMod values, so we don't need a special Excel case for calculating the final color. Change-Id: I0725c06f9df6a37a309ea5d17b183e4100a228f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153716 Tested-by: Tomaž Vajngerl <[email protected]> Reviewed-by: Tomaž Vajngerl <[email protected]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153794 Tested-by: Jenkins diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index b653458300f4..1ed2e57b6242 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -434,10 +434,18 @@ void Color::addChartTintTransformation( double fTint ) maTransforms.emplace_back( XML_tint, MAX_PERCENT - nValue ); } -void Color::addExcelTintTransformation( double fTint ) +void Color::addExcelTintTransformation(double fTint) { - sal_Int32 nValue = getLimitedValue< sal_Int32, double >( fTint * MAX_PERCENT + 0.5, -MAX_PERCENT, MAX_PERCENT ); - maTransforms.emplace_back( XLS_TOKEN( tint ), nValue ); + sal_Int32 nValue = std::round(std::abs(fTint) * 100'000.0); + if (fTint > 0.0) + { + maTransforms.emplace_back(XML_lumMod, 100'000 - nValue); + maTransforms.emplace_back(XML_lumOff, nValue); + } + else if (fTint < 0.0) + { + maTransforms.emplace_back(XML_lumMod, 100'000 - nValue); + } } void Color::clearTransformations() @@ -723,23 +731,6 @@ model::ComplexColor Color::getComplexColor() const mnC3 = static_cast< sal_Int32 >( MAX_PERCENT - (MAX_PERCENT - mnC3) * fFactor ); } break; - case XLS_TOKEN( tint ): - // Excel tint: move luminance relative to current value - toHsl(); - OSL_ENSURE( (-MAX_PERCENT <= transform.mnValue) && (transform.mnValue <= MAX_PERCENT), "Color::getColor - invalid tint value" ); - if( (-MAX_PERCENT <= transform.mnValue) && (transform.mnValue < 0) ) - { - // negative: luminance towards 0% (black) - lclModValue( mnC3, transform.mnValue + MAX_PERCENT ); - } - else if( (0 < transform.mnValue) && (transform.mnValue <= MAX_PERCENT) ) - { - // positive: luminance towards 100% (white) - mnC3 = MAX_PERCENT - mnC3; - lclModValue( mnC3, MAX_PERCENT - transform.mnValue ); - mnC3 = MAX_PERCENT - mnC3; - } - break; case XML_gray: // change color to gray, weighted RGB: 22% red, 72% green, 6% blue @@ -844,7 +835,7 @@ model::ComplexColor Color::createComplexColor(const GraphicHelper& /*rGraphicHel { sal_Int16 nValue = sal_Int16(aTransform.mnValue / 10); - switch(aTransform.mnToken) + switch (aTransform.mnToken) { case XML_lumMod: if (nValue != 10'000)
