sc/inc/strings.hrc                             |   10 +++
 sc/source/ui/sidebar/CellLineStyleControl.cxx  |   72 ++++++++++++++++---------
 sc/source/ui/sidebar/CellLineStyleValueSet.cxx |   30 +++++++---
 sc/source/ui/sidebar/CellLineStyleValueSet.hxx |    4 +
 4 files changed, 82 insertions(+), 34 deletions(-)

New commits:
commit d52b2831ba5ef1475ca148c298ae69291d273255
Author:     Samuel Mehrbrodt <[email protected]>
AuthorDate: Thu Nov 4 11:34:22 2021 +0100
Commit:     Thorsten Behrens <[email protected]>
CommitDate: Sun Dec 5 12:03:32 2021 +0100

    tdf#48622 Adapt sidebar line styles to new defaults
    
    Change-Id: I81287d90c2250838391fa79d2f6455219ea822c8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124680
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <[email protected]>
    (cherry picked from commit cd116a1b6775777f393990cc3419733164dee52f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126057
    Tested-by: Thorsten Behrens <[email protected]>
    Reviewed-by: Thorsten Behrens <[email protected]>

diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index ea550b491521..2b3f278a2ee1 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -374,6 +374,16 @@
 #define STR_NO_USER_DATA_AVAILABLE                  
NC_("sharedocumentdlg|nouserdata", "No user data available.")
 #define STR_EXCLUSIVE_ACCESS                        
NC_("sharedocumentdlg|exclusive", "(exclusive access)")
 #define STR_NO_NAMED_RANGES_AVAILABLE               
NC_("STR_NO_NAMED_RANGES_AVAILABLE", "No named ranges available in the selected 
document")
+#define STR_BORDER_HAIRLINE                         NC_("STR_BORDER_HAIRLINE", 
"Hairline (%s pt)")
+#define STR_BORDER_VERY_THIN                        
NC_("STR_BORDER_VERY_THIN", "Very thin (%s pt)")
+#define STR_BORDER_THIN                             NC_("STR_BORDER_THIN", 
"Thin (%s pt)")
+#define STR_BORDER_MEDIUM                           NC_("STR_BORDER_MEDIUM", 
"Medium (%s pt)")
+#define STR_BORDER_THICK                            NC_("STR_BORDER_THICK", 
"Thick (%s pt)")
+#define STR_BORDER_EXTRA_THICK                      
NC_("STR_BORDER_EXTRA_THICK", "Extra thick (%s pt)")
+#define STR_BORDER_DOUBLE_1                         NC_("STR_BORDER_DOUBLE_1", 
"Double Hairline (%s pt)")
+#define STR_BORDER_DOUBLE_2                         NC_("STR_BORDER_DOUBLE_2", 
"Thin/Medium (%s pt)")
+#define STR_BORDER_DOUBLE_3                         NC_("STR_BORDER_DOUBLE_3", 
"Medium/Hairline (%s pt)")
+#define STR_BORDER_DOUBLE_4                         NC_("STR_BORDER_DOUBLE_4", 
"Medium/Medium (%s pt)")
 
 #endif
 
diff --git a/sc/source/ui/sidebar/CellLineStyleControl.cxx 
b/sc/source/ui/sidebar/CellLineStyleControl.cxx
index c5da14c298d4..3caca9521b84 100644
--- a/sc/source/ui/sidebar/CellLineStyleControl.cxx
+++ b/sc/source/ui/sidebar/CellLineStyleControl.cxx
@@ -19,6 +19,7 @@
 
 #include "CellLineStyleControl.hxx"
 #include "CellLineStyleValueSet.hxx"
+#include <vcl/svapp.hxx>
 #include <vcl/i18nhelp.hxx>
 #include <vcl/settings.hxx>
 #include <editeng/borderline.hxx>
@@ -27,6 +28,8 @@
 #include <sfx2/bindings.hxx>
 #include <sfx2/dispatch.hxx>
 #include <svx/svxids.hrc>
+#include <scresid.hxx>
+#include <strings.hrc>
 
 namespace sc { namespace sidebar {
 
@@ -60,20 +63,25 @@ void CellLineStylePopup::Initialize()
     
maCellLineStyleValueSet->SetControlBackground(GetSettings().GetStyleSettings().GetMenuColor());
     
maCellLineStyleValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor());
 
-    for(sal_uInt16 i = 1 ; i <= 9 ; i++)
+    for(sal_uInt16 i = 1 ; i <= CELL_LINE_STYLE_ENTRIES ; i++)
     {
         maCellLineStyleValueSet->InsertItem(i);
     }
 
-    maStr[0] = GetSettings().GetLocaleI18nHelper().GetNum( 5, 2 ) + "pt";
-    maStr[1] = GetSettings().GetLocaleI18nHelper().GetNum( 250, 2 ) + "pt";
-    maStr[2] = GetSettings().GetLocaleI18nHelper().GetNum( 400, 2 ) + "pt";
-    maStr[3] = GetSettings().GetLocaleI18nHelper().GetNum( 500, 2 ) + "pt";
-    maStr[4] = GetSettings().GetLocaleI18nHelper().GetNum( 110, 2 ) + "pt";
-    maStr[5] = GetSettings().GetLocaleI18nHelper().GetNum( 260, 2 ) + "pt";
-    maStr[6] = GetSettings().GetLocaleI18nHelper().GetNum( 450, 2 ) + "pt";
-    maStr[7] = GetSettings().GetLocaleI18nHelper().GetNum( 505, 2 ) + "pt";
-    maStr[8] = GetSettings().GetLocaleI18nHelper().GetNum( 750, 2 ) + "pt";
+    const vcl::I18nHelper& rI18nHelper = 
Application::GetSettings().GetLocaleI18nHelper();
+    maStr[0] = ScResId(STR_BORDER_HAIRLINE).replaceFirst("%s", 
rI18nHelper.GetNum(5, 2));
+    maStr[1] = ScResId(STR_BORDER_VERY_THIN).replaceFirst("%s", 
rI18nHelper.GetNum(50, 2));
+    maStr[2] = ScResId(STR_BORDER_THIN).replaceFirst("%s", 
rI18nHelper.GetNum(75, 2));
+    maStr[3] = ScResId(STR_BORDER_MEDIUM).replaceFirst("%s", 
rI18nHelper.GetNum(150, 2));
+    maStr[4] = ScResId(STR_BORDER_THICK).replaceFirst("%s", 
rI18nHelper.GetNum(225, 2));
+    maStr[5] = ScResId(STR_BORDER_EXTRA_THICK).replaceFirst("%s", 
rI18nHelper.GetNum(450, 2));
+
+    // Numbers in pt are the total width of the double line (inner + outer + 
distance)
+    maStr[6] = ScResId(STR_BORDER_DOUBLE_1).replaceFirst("%s", 
rI18nHelper.GetNum(110, 2));
+    maStr[7] = ScResId(STR_BORDER_DOUBLE_1).replaceFirst("%s", 
rI18nHelper.GetNum(235, 2));
+    maStr[8] = ScResId(STR_BORDER_DOUBLE_2).replaceFirst("%s", 
rI18nHelper.GetNum(300, 2));
+    maStr[9] = ScResId(STR_BORDER_DOUBLE_3).replaceFirst("%s", 
rI18nHelper.GetNum(305, 2));
+    maStr[10] = ScResId(STR_BORDER_DOUBLE_4).replaceFirst("%s", 
rI18nHelper.GetNum(450, 2));
     maCellLineStyleValueSet->SetUnit(&maStr[0]);
 
     for (sal_uInt16 i = 1; i <= CELL_LINE_STYLE_ENTRIES; ++i)
@@ -116,39 +124,45 @@ IMPL_LINK(CellLineStylePopup, VSSelectHdl, ValueSet*, 
pControl, void)
                 n1 = SvxBorderLineWidth::Hairline;
                 break;
             case 2:
-                n1 = SvxBorderLineWidth::Medium;
+                n1 = SvxBorderLineWidth::VeryThin;
                 break;
             case 3:
-                n1 = SvxBorderLineWidth::Thick;
+                n1 = SvxBorderLineWidth::Thin;
                 break;
             case 4:
-                n1 = SvxBorderLineWidth::ExtraThick;
+                n1 = SvxBorderLineWidth::Medium;
                 break;
             case 5:
+                n1 = SvxBorderLineWidth::Thick;
+                break;
+            case 6:
+                n1 = SvxBorderLineWidth::ExtraThick;
+                break;
+            case 7:
                 n1 = SvxBorderLineWidth::Hairline;
                 n2 = SvxBorderLineWidth::Hairline;
                 n3 = SvxBorderLineWidth::Medium;
                 nStyle = SvxBorderLineStyle::DOUBLE;
                 break;
-            case 6:
+            case 8:
                 n1 = SvxBorderLineWidth::Hairline;
                 n2 = SvxBorderLineWidth::Hairline;
                 n3 = SvxBorderLineWidth::Thick;
                 nStyle = SvxBorderLineStyle::DOUBLE;
                 break;
-            case 7:
+            case 9:
                 n1 = SvxBorderLineWidth::Thin;
                 n2 = SvxBorderLineWidth::Medium;
                 n3 = SvxBorderLineWidth::Thin;
                 nStyle = SvxBorderLineStyle::DOUBLE;
                 break;
-            case 8:
+            case 10:
                 n1 = SvxBorderLineWidth::Medium;
                 n2 = SvxBorderLineWidth::Hairline;
                 n3 = SvxBorderLineWidth::Medium;
                 nStyle = SvxBorderLineStyle::DOUBLE;
                 break;
-            case 9:
+            case 11:
                 n1 = SvxBorderLineWidth::Medium;
                 n2 = SvxBorderLineWidth::Medium;
                 n3 = SvxBorderLineWidth::Medium;
@@ -188,38 +202,46 @@ void CellLineStylePopup::SetLineStyleSelect(sal_uInt16 
out, sal_uInt16 in, sal_u
     {
         maCellLineStyleValueSet->SetSelItem(1);
     }
-    else if(out == SvxBorderLineWidth::Medium && in == 0 && dis == 0) //2
+    else if(out == SvxBorderLineWidth::VeryThin && in == 0 && dis == 0) //2
     {
         maCellLineStyleValueSet->SetSelItem(2);
     }
-    else if(out == SvxBorderLineWidth::Thick && in == 0 && dis == 0) //3
+    else if(out == SvxBorderLineWidth::Thin && in == 0 && dis == 0) //3
     {
         maCellLineStyleValueSet->SetSelItem(3);
     }
-    else if(out == SvxBorderLineWidth::ExtraThick && in == 0 && dis == 0) //4
+    else if(out == SvxBorderLineWidth::Medium && in == 0 && dis == 0) //4
     {
         maCellLineStyleValueSet->SetSelItem(4);
     }
-    else if(out == SvxBorderLineWidth::Hairline && in == 
SvxBorderLineWidth::Hairline && dis == SvxBorderLineWidth::Thin) //5
+    else if(out == SvxBorderLineWidth::Thick && in == 0 && dis == 0) //5
     {
         maCellLineStyleValueSet->SetSelItem(5);
     }
-    else if(out == SvxBorderLineWidth::Hairline && in == 
SvxBorderLineWidth::Hairline && dis == SvxBorderLineWidth::Medium) //6
+    else if(out == SvxBorderLineWidth::ExtraThick && in == 0 && dis == 0) //6
     {
         maCellLineStyleValueSet->SetSelItem(6);
     }
-    else if(out == SvxBorderLineWidth::Thin && in == 
SvxBorderLineWidth::Medium && dis == SvxBorderLineWidth::Thin) //7
+    else if(out == SvxBorderLineWidth::Hairline && in == 
SvxBorderLineWidth::Hairline && dis == SvxBorderLineWidth::Thin) //7
     {
         maCellLineStyleValueSet->SetSelItem(7);
     }
-    else if(out == SvxBorderLineWidth::Medium && in == 
SvxBorderLineWidth::Hairline && dis == SvxBorderLineWidth::Medium) //8
+    else if(out == SvxBorderLineWidth::Hairline && in == 
SvxBorderLineWidth::Hairline && dis == SvxBorderLineWidth::Medium) //8
     {
         maCellLineStyleValueSet->SetSelItem(8);
     }
-    else if(out == SvxBorderLineWidth::Medium && in == 
SvxBorderLineWidth::Medium && dis == SvxBorderLineWidth::Medium) //9
+    else if(out == SvxBorderLineWidth::Thin && in == 
SvxBorderLineWidth::Medium && dis == SvxBorderLineWidth::Thin) //9
     {
         maCellLineStyleValueSet->SetSelItem(9);
     }
+    else if(out == SvxBorderLineWidth::Medium && in == 
SvxBorderLineWidth::Hairline && dis == SvxBorderLineWidth::Medium) //10
+    {
+        maCellLineStyleValueSet->SetSelItem(10);
+    }
+    else if(out == SvxBorderLineWidth::Medium && in == 
SvxBorderLineWidth::Medium && dis == SvxBorderLineWidth::Medium) //11
+    {
+        maCellLineStyleValueSet->SetSelItem(11);
+    }
 
     else
     {
diff --git a/sc/source/ui/sidebar/CellLineStyleValueSet.cxx 
b/sc/source/ui/sidebar/CellLineStyleValueSet.cxx
index 5bd9e11c5fae..127e7379d0a5 100644
--- a/sc/source/ui/sidebar/CellLineStyleValueSet.cxx
+++ b/sc/source/ui/sidebar/CellLineStyleValueSet.cxx
@@ -29,7 +29,7 @@ CellLineStyleValueSet::CellLineStyleValueSet(vcl::Window* 
pParent)
     , nSelItem(0)
 {
     SetColCount();
-    SetLineCount( 9);
+    SetLineCount(CELL_LINE_STYLE_ENTRIES);
 }
 
 CellLineStyleValueSet::~CellLineStyleValueSet()
@@ -39,7 +39,7 @@ CellLineStyleValueSet::~CellLineStyleValueSet()
 
 Size CellLineStyleValueSet::GetOptimalSize() const
 {
-    return LogicToPixel(Size(80, 12 * 9), MapMode(MapUnit::MapAppFont));
+    return LogicToPixel(Size(120, 12 * CELL_LINE_STYLE_ENTRIES), 
MapMode(MapUnit::MapAppFont));
 }
 
 void CellLineStyleValueSet::SetUnit(const OUString* str)
@@ -65,6 +65,18 @@ void CellLineStyleValueSet::SetSelItem(sal_uInt16 nSel)
     }
 }
 
+long CellLineStyleValueSet::GetMaxTextWidth(vcl::RenderContext* pDev)
+{
+    if (mnMaxTextWidth > 0)
+        return mnMaxTextWidth;
+
+    for (int i = 0; i < CELL_LINE_STYLE_ENTRIES; ++i)
+    {
+        mnMaxTextWidth = std::max(pDev->GetTextWidth(maStrUnit[i]), 
mnMaxTextWidth);
+    }
+    return mnMaxTextWidth;
+}
+
 void CellLineStyleValueSet::UserDraw( const UserDrawEvent& rUDEvt )
 {
     tools::Rectangle aRect = rUDEvt.GetRect();
@@ -105,7 +117,7 @@ void CellLineStyleValueSet::UserDraw( const UserDrawEvent& 
rUDEvt )
         aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor()); 
//high contrast
 
     pDev->SetFont(aFont);
-    long nTextWidth = pDev->GetTextWidth(maStrUnit[nItemId - 1]);
+    long nTextWidth = GetMaxTextWidth(pDev);
     long nTLX = aBLPos.X() + 5,  nTLY = aBLPos.Y() + ( nRectHeight - nItemId 
)/2;
     long nTRX = aBLPos.X() + nRectWidth - nTextWidth - 15, nTRY = aBLPos.Y() + 
( nRectHeight - nItemId )/2;
     Point aStart(aBLPos.X() + nRectWidth - nTextWidth - 5 , aBLPos.Y() + 
nRectHeight/6);
@@ -129,25 +141,27 @@ void CellLineStyleValueSet::UserDraw( const 
UserDrawEvent& rUDEvt )
         case 2:
         case 3:
         case 4:
+        case 5:
+        case 6:
             pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + nItemId 
* 2 - 1 ));
             break;
-        case 5:
+        case 7:
             pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 1 ));
             pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 3 , nTRX, nTRY + 4 ));
             break;
-        case 6:
+        case 8:
             pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 1 ));
             pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 6 ));
             break;
-        case 7:
+        case 9:
             pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 1 ));
             pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 3 , nTRX, nTRY + 6 ));
             break;
-        case 8:
+        case 10:
             pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 3 ));
             pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 6 ));
             break;
-        case 9:
+        case 11:
             pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 3 ));
             pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 8 ));
             break;
diff --git a/sc/source/ui/sidebar/CellLineStyleValueSet.hxx 
b/sc/source/ui/sidebar/CellLineStyleValueSet.hxx
index 2e45622d8812..78a4332fa1a3 100644
--- a/sc/source/ui/sidebar/CellLineStyleValueSet.hxx
+++ b/sc/source/ui/sidebar/CellLineStyleValueSet.hxx
@@ -21,13 +21,14 @@
 
 #include <svtools/valueset.hxx>
 
-#define CELL_LINE_STYLE_ENTRIES 9
+#define CELL_LINE_STYLE_ENTRIES 11
 
 namespace sc { namespace sidebar {
 
 class CellLineStyleValueSet : public ValueSet
 {
 private:
+    long mnMaxTextWidth;
     sal_uInt16      nSelItem;
     OUString        maStrUnit[CELL_LINE_STYLE_ENTRIES];
 public:
@@ -36,6 +37,7 @@ public:
 
     void SetUnit(const OUString* str);
     void SetSelItem(sal_uInt16 nSel);
+    long GetMaxTextWidth(vcl::RenderContext* pDev);
     virtual Size GetOptimalSize() const override;
     virtual void UserDraw( const UserDrawEvent& rUDEvt ) override;
 };

Reply via email to