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 093c98dcb4be1c124871468f73be4b59ec99af1f
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sun Jan 9 13:04:18 2022 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Mon Jan 10 05:09:42 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/+/128185
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sc/inc/fillinfo.hxx b/sc/inc/fillinfo.hxx
index c4f995c21c1d..9c8681d8f43e 100644
--- a/sc/inc/fillinfo.hxx
+++ b/sc/inc/fillinfo.hxx
@@ -92,6 +92,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 9d4e27b47b51..48d2ec5ad05f 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>
@@ -1055,6 +1057,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 fe6b3c278884..3bfd86e671ff 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -38,6 +38,7 @@
 #include <svx/unoapi.hxx>
 #include <sal/log.hxx>
 #include <comphelper/lok.hxx>
+#include <o3tl/unit_conversion.hxx>
 
 #include <output.hxx>
 #include <document.hxx>
@@ -909,12 +910,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 = o3tl::convert(10, o3tl::Length::pt, 
o3tl::Length::mm100);
+
+    if (pOldIconSetInfo->mnHeight)
+        aHeight = o3tl::convert(pOldIconSetInfo->mnHeight, o3tl::Length::twip, 
o3tl::Length::mm100);
+
+    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,

Reply via email to