[Libreoffice-commits] core.git: cui/source include/svx svx/source

Caolán McNamara caolanm at redhat.com
Thu Mar 30 07:54:09 UTC 2017


 cui/source/inc/chardlg.hxx       |    3 +
 cui/source/tabpages/chardlg.cxx  |   33 +++++++++---
 include/svx/colorwindow.hxx      |    1 
 svx/source/tbxctrls/tbcontrl.cxx |  107 ++++++++++++++++++++-------------------
 4 files changed, 85 insertions(+), 59 deletions(-)

New commits:
commit 84f78392249c3749801acf238a99fda95311e01f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 29 17:18:53 2017 +0100

    Related: tdf#106080 support a 'none' color in search by format
    
    so we can show the initial no-color selected state differently
    than the automatic color default color
    
    Change-Id: Ib3020e507b1555cb446c2b501f60b67222dc115c
    Reviewed-on: https://gerrit.libreoffice.org/35863
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx
index b24a431e2ce5..1b99b60cc5ff 100644
--- a/cui/source/inc/chardlg.hxx
+++ b/cui/source/inc/chardlg.hxx
@@ -175,6 +175,7 @@ private:
     static const sal_uInt16 pEffectsRanges[];
     bool                       m_bOrigFontColor;
     bool                       m_bNewFontColor;
+    bool                       m_bEnableNoneFontColor;
     Color                      m_aOrigFontColor;
     VclPtr<FixedText>          m_pFontColorFT;
     VclPtr<SvxColorListBox>    m_pFontColorLB;
@@ -219,6 +220,8 @@ private:
     void                SetCaseMap_Impl( SvxCaseMap eCaseMap );
     void                ResetColor_Impl( const SfxItemSet& rSet );
     bool                FillItemSetColor_Impl( SfxItemSet& rSet );
+    Color               GetPreviewFontColor(const Color& rColor) const;
+    void                EnableNoneFontColor();
 
     void SelectHdl_Impl(ListBox*);
     DECL_LINK(SelectListBoxHdl_Impl, ListBox&, void);
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index a126b3234d08..b8448130ed87 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -1336,6 +1336,7 @@ SvxCharEffectsPage::SvxCharEffectsPage( vcl::Window* pParent, const SfxItemSet&
     : SvxCharBasePage(pParent, "EffectsPage", "cui/ui/effectspage.ui", rInSet)
     , m_bOrigFontColor(false)
     , m_bNewFontColor(false)
+    , m_bEnableNoneFontColor(false)
 {
     get(m_pFontColorFT, "fontcolorft");
     get(m_pFontColorLB, "fontcolorlb");
@@ -1368,6 +1369,21 @@ SvxCharEffectsPage::SvxCharEffectsPage( vcl::Window* pParent, const SfxItemSet&
     Initialize();
 }
 
+void SvxCharEffectsPage::EnableNoneFontColor()
+{
+    m_pFontColorLB->SetSlotId(SID_ATTR_CHAR_COLOR, true);
+    m_bEnableNoneFontColor = true;
+}
+
+Color SvxCharEffectsPage::GetPreviewFontColor(const Color& rColor) const
+{
+    if (rColor.GetColor() == COL_AUTO)
+        return Color(COL_BLACK);
+    if (m_bEnableNoneFontColor && rColor.GetColor() == COL_NONE_COLOR)
+        return Color(COL_BLACK);
+    return rColor;
+}
+
 SvxCharEffectsPage::~SvxCharEffectsPage()
 {
     disposeOnce();
@@ -1468,9 +1484,9 @@ void SvxCharEffectsPage::UpdatePreview_Impl()
     SvxFont& rCTLFont = GetPreviewCTLFont();
 
     const Color& rSelectedColor = m_pFontColorLB->GetSelectEntryColor();
-    rFont.SetColor(rSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : rSelectedColor);
-    rCJKFont.SetColor(rSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : rSelectedColor);
-    rCTLFont.SetColor(rSelectedColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : rSelectedColor);
+    rFont.SetColor(GetPreviewFontColor(rSelectedColor));
+    rCJKFont.SetColor(GetPreviewFontColor(rSelectedColor));
+    rCTLFont.SetColor(GetPreviewFontColor(rSelectedColor));
 
     sal_Int32 nPos = m_pUnderlineLB->GetSelectEntryPos();
     FontLineStyle eUnderline = (FontLineStyle)reinterpret_cast<sal_uLong>(m_pUnderlineLB->GetEntryData( nPos ));
@@ -1572,6 +1588,9 @@ void SvxCharEffectsPage::ResetColor_Impl( const SfxItemSet& rSet )
             break;
 
         case SfxItemState::DONTCARE:
+            //Related: tdf#106080 if there is no font color, then allow "none"
+            //as a color so the listbox can display that state.
+            EnableNoneFontColor();
             m_pFontColorLB->SetNoSelection();
             break;
 
@@ -1584,9 +1603,9 @@ void SvxCharEffectsPage::ResetColor_Impl( const SfxItemSet& rSet )
 
             const SvxColorItem& rItem = static_cast<const SvxColorItem&>(rSet.Get( nWhich ));
             Color aColor = rItem.GetValue();
-            rFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
-            rCJKFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
-            rCTLFont.SetColor( aColor.GetColor() == COL_AUTO ? Color(COL_BLACK) : aColor );
+            rFont.SetColor(GetPreviewFontColor(aColor));
+            rCJKFont.SetColor(GetPreviewFontColor(aColor));
+            rCTLFont.SetColor(GetPreviewFontColor(aColor));
 
             m_pPreviewWin->Invalidate();
 
@@ -1613,6 +1632,8 @@ bool SvxCharEffectsPage::FillItemSetColor_Impl( SfxItemSet& rSet )
         aSelectedColor = m_pFontColorLB->GetSelectEntryColor();
         if (m_bOrigFontColor)
             bChanged = aSelectedColor != m_aOrigFontColor;
+        if (m_bEnableNoneFontColor && bChanged && aSelectedColor == COL_NONE_COLOR)
+            bChanged = false;
     }
 
     if (bChanged)
diff --git a/include/svx/colorwindow.hxx b/include/svx/colorwindow.hxx
index 1e417130effb..520a560880d1 100644
--- a/include/svx/colorwindow.hxx
+++ b/include/svx/colorwindow.hxx
@@ -76,7 +76,6 @@ private:
     static bool SelectValueSetEntry(SvxColorValueSet* pColorSet, const Color& rColor);
     static NamedColor GetSelectEntryColor(ValueSet* pColorSet);
     NamedColor GetAutoColor() const;
-    NamedColor GetNoneColor() const;
 
 public:
     SvxColorWindow(const OUString& rCommand,
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index ede046e23de0..a4725bc0d533 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1391,6 +1391,46 @@ NamedColor SvxColorWindow::GetSelectEntryColor(ValueSet* pColorSet)
     return std::make_pair(aColor, sColorName);
 }
 
+namespace
+{
+    NamedColor GetAutoColor(sal_uInt16 nSlotId)
+    {
+        Color aColor;
+        OUString sColorName;
+        switch (nSlotId)
+        {
+            case SID_ATTR_CHAR_COLOR_BACKGROUND:
+            case SID_BACKGROUND_COLOR:
+            case SID_ATTR_CHAR_BACK_COLOR:
+                aColor = COL_TRANSPARENT;
+                sColorName = SVX_RESSTR(RID_SVXSTR_NOFILL);
+                break;
+            case SID_AUTHOR_COLOR:
+                aColor = COL_TRANSPARENT;
+                sColorName = SVX_RESSTR(RID_SVXSTR_BY_AUTHOR);
+                break;
+            case SID_BMPMASK_COLOR:
+                aColor = COL_TRANSPARENT;
+                sColorName = SVX_RESSTR(RID_SVXSTR_TRANSPARENT);
+                break;
+            case SID_ATTR_CHAR_COLOR:
+            case SID_ATTR_CHAR_COLOR2:
+            case SID_EXTRUSION_3D_COLOR:
+            default:
+                aColor = COL_AUTO;
+                sColorName = EditResId::GetString(RID_SVXSTR_AUTOMATIC);
+                break;
+        }
+
+        return std::make_pair(aColor, sColorName);
+    }
+
+    NamedColor GetNoneColor()
+    {
+        return std::make_pair(Color(COL_NONE_COLOR), SVX_RESSTR(RID_SVXSTR_NONE));
+    }
+}
+
 NamedColor SvxColorWindow::GetSelectEntryColor() const
 {
     if (!mpColorSet->IsNoSelection())
@@ -1435,54 +1475,6 @@ IMPL_LINK_NOARG(SvxColorWindow, SelectPaletteHdl, ListBox&, void)
     mpColorSet->layoutToGivenHeight(mpColorSet->GetSizePixel().Height(), mrPaletteManager.GetColorCount());
 }
 
-NamedColor SvxColorWindow::GetNoneColor() const
-{
-    Color aColor;
-    OUString sColorName;
-    if (theSlotId == SID_AUTHOR_COLOR)
-    {
-        aColor = COL_NONE_COLOR;
-        sColorName = SVX_RESSTR(RID_SVXSTR_NONE);
-    }
-
-    return std::make_pair(aColor, sColorName);
-}
-
-namespace
-{
-    NamedColor GetAutoColor(sal_uInt16 nSlotId)
-    {
-        Color aColor;
-        OUString sColorName;
-        switch (nSlotId)
-        {
-            case SID_ATTR_CHAR_COLOR_BACKGROUND:
-            case SID_BACKGROUND_COLOR:
-            case SID_ATTR_CHAR_BACK_COLOR:
-                aColor = COL_TRANSPARENT;
-                sColorName = SVX_RESSTR(RID_SVXSTR_NOFILL);
-                break;
-            case SID_AUTHOR_COLOR:
-                aColor = COL_TRANSPARENT;
-                sColorName = SVX_RESSTR(RID_SVXSTR_BY_AUTHOR);
-                break;
-            case SID_BMPMASK_COLOR:
-                aColor = COL_TRANSPARENT;
-                sColorName = SVX_RESSTR(RID_SVXSTR_TRANSPARENT);
-                break;
-            case SID_ATTR_CHAR_COLOR:
-            case SID_ATTR_CHAR_COLOR2:
-            case SID_EXTRUSION_3D_COLOR:
-            default:
-                aColor = COL_AUTO;
-                sColorName = EditResId::GetString(RID_SVXSTR_AUTOMATIC);
-                break;
-        }
-
-        return std::make_pair(aColor, sColorName);
-    }
-}
-
 NamedColor SvxColorWindow::GetAutoColor() const
 {
     return ::GetAutoColor(theSlotId);
@@ -3234,6 +3226,8 @@ void SvxColorListBox::SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton)
     m_nSlotId = nSlotId;
     m_bShowNoneButton = bShowNoneButton;
     m_xColorWindow.disposeAndClear();
+    m_aSelectedColor = bShowNoneButton ? GetNoneColor() : GetAutoColor(m_nSlotId);
+    ShowPreview(m_aSelectedColor);
     createColorWindow();
 }
 
@@ -3270,11 +3264,20 @@ void SvxColorListBox::ShowPreview(const NamedColor &rColor)
     xDevice->SetOutputSize(aImageSize);
     const Rectangle aRect(Point(0, 0), aImageSize);
     if (m_bShowNoneButton && rColor.first == COL_NONE_COLOR)
-        xDevice->SetFillColor(COL_BLACK);
-    else if (rColor.first == COL_AUTO)
-        xDevice->SetFillColor(m_aAutoDisplayColor);
+    {
+        const Color aW(COL_WHITE);
+        const Color aG(0xef, 0xef, 0xef);
+        xDevice->DrawCheckered(aRect.TopLeft(), aRect.GetSize(), 8, aW, aG);
+        xDevice->SetFillColor();
+    }
     else
-        xDevice->SetFillColor(rColor.first);
+    {
+        if (rColor.first == COL_AUTO)
+            xDevice->SetFillColor(m_aAutoDisplayColor);
+        else
+            xDevice->SetFillColor(rColor.first);
+    }
+
     xDevice->SetLineColor(rStyleSettings.GetDisableColor());
     xDevice->DrawRect(aRect);
 


More information about the Libreoffice-commits mailing list