sc/inc/fillinfo.hxx | 1 + sc/source/core/data/colorscale.cxx | 6 ++++++ sc/source/ui/view/output.cxx | 18 +++++++++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-)
New commits: commit 204409386483cfb369e8fe2ed79b6560a1a52d8f Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sun Jan 9 13:04:18 2022 +0900 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Tue Jan 11 13:38:18 2022 +0100 sc: make icon size of cond. formatting same as font size This makes the behavior of the Calc te same as other spreadsheet programs, where the icon size of the conditional formatting is the same as the font size and not the actual cell height (as it is the behaviour now). Change-Id: I00c96ad83458cd31f67c0b6f566e3d01dd8cd47b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128186 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/sc/inc/fillinfo.hxx b/sc/inc/fillinfo.hxx index 0e17f179cc58..ebde70abcdcc 100644 --- a/sc/inc/fillinfo.hxx +++ b/sc/inc/fillinfo.hxx @@ -93,6 +93,7 @@ struct ScIconSetInfo { sal_Int32 nIconIndex; ScIconSetType eIconSetType; + tools::Long mnHeight = 0; bool mbShowValue; }; diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 52496653ab1b..361e51bd3c01 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -16,6 +16,8 @@ #include <tokenarray.hxx> #include <refupdatecontext.hxx> #include <refdata.hxx> +#include <editeng/fhgtitem.hxx> +#include <scitems.hxx> #include <formula/token.hxx> #include <vcl/bitmapex.hxx> @@ -1057,6 +1059,10 @@ std::unique_ptr<ScIconSetInfo> ScIconSetFormat::GetIconSetInfo(const ScAddress& std::unique_ptr<ScIconSetInfo> pInfo(new ScIconSetInfo); + const SfxPoolItem& rPoolItem = mpDoc->GetPattern(rAddr)->GetItem(ATTR_FONT_HEIGHT); + tools::Long aFontHeight = static_cast<const SvxFontHeightItem&>(rPoolItem).GetHeight(); + pInfo->mnHeight = aFontHeight; + if(mpFormatData->mbReverse) { sal_Int32 nMaxIndex = mpFormatData->m_Entries.size() - 1; diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 0b715dfc21d3..59beff1a9c83 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -39,6 +39,7 @@ #include <sal/log.hxx> #include <comphelper/lok.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <tools/UnitConversion.hxx> #include <output.hxx> #include <document.hxx> @@ -907,12 +908,23 @@ const BitmapEx& getIcon(sc::IconSetBitmapMap & rIconSetBitmapMap, ScIconSetType void drawIconSets(vcl::RenderContext& rRenderContext, const ScIconSetInfo* pOldIconSetInfo, const tools::Rectangle& rRect, tools::Long nOneX, tools::Long nOneY, sc::IconSetBitmapMap & rIconSetBitmapMap) { - //long nSize = 16; ScIconSetType eType = pOldIconSetInfo->eIconSetType; sal_Int32 nIndex = pOldIconSetInfo->nIconIndex; const BitmapEx& rIcon = getIcon(rIconSetBitmapMap, eType, nIndex); - tools::Long aOrigSize = std::max<tools::Long>(0,std::min(rRect.GetSize().getWidth() - 4 * nOneX, rRect.GetSize().getHeight() -4 * nOneY)); - rRenderContext.DrawBitmapEx( Point( rRect.Left() + 2 * nOneX, rRect.Top() + 2 * nOneY), Size(aOrigSize, aOrigSize), rIcon ); + + tools::Long aHeight = 300; + + if (pOldIconSetInfo->mnHeight) + aHeight = convertTwipToMm100(pOldIconSetInfo->mnHeight); + + Size aSize = rIcon.GetSizePixel(); + double fRatio = aSize.Width() / aSize.Height(); + tools::Long aWidth = fRatio * aHeight; + + rRenderContext.Push(); + rRenderContext.SetClipRegion(vcl::Region(rRect)); + rRenderContext.DrawBitmapEx(Point(rRect.Left() + 2 * nOneX, rRect.Bottom() - 2 * nOneY - aHeight), Size(aWidth, aHeight), rIcon); + rRenderContext.Pop(); } void drawCells(vcl::RenderContext& rRenderContext, std::optional<Color> const & pColor, const SvxBrushItem* pBackground, std::optional<Color>& pOldColor, const SvxBrushItem*& pOldBackground,