[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - include/svx reportdesign/source svx/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Nov 19 23:11:20 UTC 2018


 include/svx/colorbox.hxx                 |    4 
 include/svx/colorwindow.hxx              |   16 +--
 include/svx/tbcontrl.hxx                 |    2 
 reportdesign/source/ui/dlg/Condition.cxx |    2 
 reportdesign/source/ui/dlg/Condition.hxx |    2 
 svx/source/tbxctrls/tbcontrl.cxx         |  144 ++++++++-----------------------
 6 files changed, 51 insertions(+), 119 deletions(-)

New commits:
commit 05a8d3ce837f6fe488a099fc599b1fe3090d0b23
Author:     Maxim Monastirsky <momonasmon at gmail.com>
AuthorDate: Sun Nov 11 00:28:36 2018 +0200
Commit:     Maxim Monastirsky <momonasmon at gmail.com>
CommitDate: Tue Nov 20 00:10:58 2018 +0100

    Simplify color status handling
    
    (cherry picked from commit eb5b353b523ec4d7d6588e2fae5b8b4117bfc2b1)
    
    Rename BorderColorStatus to ColorStatus
    
    (cherry picked from commit 57f33bfd0c69a4568d1d5840391ab9901d4f4f66)
    
    Change-Id: I9335fa2ab94f69853b45f070499d7e18aac458c3
    Reviewed-on: https://gerrit.libreoffice.org/63607
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>

diff --git a/include/svx/colorbox.hxx b/include/svx/colorbox.hxx
index 67e26e652576..0a62fafceacc 100644
--- a/include/svx/colorbox.hxx
+++ b/include/svx/colorbox.hxx
@@ -42,7 +42,7 @@ private:
     sal_uInt16 m_nSlotId;
     bool m_bShowNoneButton;
     std::shared_ptr<PaletteManager> m_xPaletteManager;
-    BorderColorStatus m_aBorderColorStatus;
+    ColorStatus m_aColorStatus;
 
     DECL_LINK(MenuActivateHdl, MenuButton *, void);
     void Selected(const NamedColor& rNamedColor);
@@ -104,7 +104,7 @@ private:
     sal_uInt16 m_nSlotId;
     bool m_bShowNoneButton;
     std::shared_ptr<PaletteManager> m_xPaletteManager;
-    BorderColorStatus m_aBorderColorStatus;
+    ColorStatus m_aColorStatus;
 
     void Selected(const NamedColor& rNamedColor);
     void createColorWindow();
diff --git a/include/svx/colorwindow.hxx b/include/svx/colorwindow.hxx
index f5de49f7fd9a..53605eb9ca12 100644
--- a/include/svx/colorwindow.hxx
+++ b/include/svx/colorwindow.hxx
@@ -32,15 +32,15 @@
 
 #include <functional>
 
-class SVX_DLLPUBLIC BorderColorStatus
+class SVX_DLLPUBLIC ColorStatus
 {
     Color maColor;
     Color maTLBRColor;
     Color maBLTRColor;
 public:
-    BorderColorStatus();
-    ~BorderColorStatus();
-    bool statusChanged( const css::frame::FeatureStateEvent& rEvent );
+    ColorStatus();
+    ~ColorStatus();
+    void statusChanged( const css::frame::FeatureStateEvent& rEvent );
     Color GetColor();
 };
 
@@ -66,7 +66,7 @@ private:
 
     VclPtr<vcl::Window> mxParentWindow;
     std::shared_ptr<PaletteManager> mxPaletteManager;
-    BorderColorStatus&  mrBorderColorStatus;
+    ColorStatus&  mrColorStatus;
 
     ColorSelectFunction const maColorSelectFunction;
     bool const mbReuseParentForPicker;
@@ -83,7 +83,7 @@ private:
 public:
     SvxColorWindow(const OUString& rCommand,
                    std::shared_ptr<PaletteManager> const & rPaletteManager,
-                   BorderColorStatus& rBorderColorStatus,
+                   ColorStatus& rColorStatus,
                    sal_uInt16 nSlotId,
                    const css::uno::Reference< css::frame::XFrame >& rFrame,
                    vcl::Window* pParentWindow,
@@ -118,7 +118,7 @@ private:
     weld::Window* const mpParentWindow;
     weld::MenuButton* mpMenuButton;
     std::shared_ptr<PaletteManager> mxPaletteManager;
-    BorderColorStatus&  mrBorderColorStatus;
+    ColorStatus&  mrColorStatus;
     ColorSelectFunction const maColorSelectFunction;
 
     std::unique_ptr<ColorValueSet> mxColorSet;
@@ -144,7 +144,7 @@ private:
 
 public:
     ColorWindow(std::shared_ptr<PaletteManager> const & rPaletteManager,
-                BorderColorStatus& rBorderColorStatus,
+                ColorStatus& rColorStatus,
                 sal_uInt16 nSlotId,
                 const css::uno::Reference< css::frame::XFrame >& rFrame,
                 weld::Window* pParentWindow, weld::MenuButton* pMenuButton,
diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index ded664983f21..afa61b9b38b1 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -210,7 +210,7 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public cppu::ImplInheritanceHelper<
 {
     std::unique_ptr<svx::ToolboxButtonColorUpdater> m_xBtnUpdater;
     std::shared_ptr<PaletteManager> m_xPaletteManager;
-    BorderColorStatus m_aBorderColorStatus;
+    ColorStatus m_aColorStatus;
     bool m_bSplitButton;
     sal_uInt16 m_nSlotId;
     ColorSelectFunction m_aColorSelectFunction;
diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx
index 5e8194fd7214..48f2a5c3c26c 100644
--- a/reportdesign/source/ui/dlg/Condition.cxx
+++ b/reportdesign/source/ui/dlg/Condition.cxx
@@ -227,7 +227,7 @@ IMPL_LINK(Condition, DropdownClick, ToolBox*, pToolBox, void)
     m_pColorFloat = VclPtr<SvxColorWindow>::Create(
                            OUString() /*m_aCommandURL*/,
                            m_xPaletteManager,
-                           m_aBorderColorStatus,
+                           m_aColorStatus,
                            nSlotId,
                            nullptr,
                            pToolBox,
diff --git a/reportdesign/source/ui/dlg/Condition.hxx b/reportdesign/source/ui/dlg/Condition.hxx
index ceca03281ecc..d94804d35c24 100644
--- a/reportdesign/source/ui/dlg/Condition.hxx
+++ b/reportdesign/source/ui/dlg/Condition.hxx
@@ -88,7 +88,7 @@ namespace rptui
         sal_uInt16                  m_nFontColorId;
         sal_uInt16                  m_nFontDialogId;
         std::shared_ptr<PaletteManager> m_xPaletteManager;
-        BorderColorStatus           m_aBorderColorStatus;
+        ColorStatus                 m_aColorStatus;
         ConditionColorWrapper       m_aColorWrapper;
 
         ::rptui::OReportController& m_rController;
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index f4d85d734526..a379d919f268 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1255,7 +1255,7 @@ void SvxFontNameBox_Impl::Select()
 
 SvxColorWindow::SvxColorWindow(const OUString&            rCommand,
                                std::shared_ptr<PaletteManager> const & rPaletteManager,
-                               BorderColorStatus&         rBorderColorStatus,
+                               ColorStatus&               rColorStatus,
                                sal_uInt16                 nSlotId,
                                const Reference< XFrame >& rFrame,
                                vcl::Window*               pParentWindow,
@@ -1267,7 +1267,7 @@ SvxColorWindow::SvxColorWindow(const OUString&            rCommand,
     maCommand( rCommand ),
     mxParentWindow(pParentWindow),
     mxPaletteManager( rPaletteManager ),
-    mrBorderColorStatus( rBorderColorStatus ),
+    mrColorStatus( rColorStatus ),
     maColorSelectFunction(aFunction),
     mbReuseParentForPicker(bReuseParentForPicker)
 {
@@ -1367,7 +1367,7 @@ SvxColorWindow::SvxColorWindow(const OUString&            rCommand,
 }
 
 ColorWindow::ColorWindow(std::shared_ptr<PaletteManager> const & rPaletteManager,
-                         BorderColorStatus&         rBorderColorStatus,
+                         ColorStatus&               rColorStatus,
                          sal_uInt16                 nSlotId,
                          const Reference< XFrame >& rFrame,
                          weld::Window*              pParentWindow,
@@ -1381,7 +1381,7 @@ ColorWindow::ColorWindow(std::shared_ptr<PaletteManager> const & rPaletteManager
     , mpParentWindow(pParentWindow)
     , mpMenuButton(pMenuButton)
     , mxPaletteManager(rPaletteManager)
-    , mrBorderColorStatus(rBorderColorStatus)
+    , mrColorStatus(rColorStatus)
     , maColorSelectFunction(aFunction)
     , mxColorSet(new ColorValueSet(m_xBuilder->weld_scrolled_window("colorsetwin")))
     , mxRecentColorSet(new ColorValueSet(nullptr))
@@ -1772,20 +1772,8 @@ void SvxColorWindow::statusChanged( const css::frame::FeatureStateEvent& rEvent
     }
     else
     {
-        Color aColor(COL_TRANSPARENT);
-
-        if (mrBorderColorStatus.statusChanged(rEvent))
-        {
-            aColor = mrBorderColorStatus.GetColor();
-        }
-        else if (rEvent.IsEnabled)
-        {
-            sal_Int32 nValue;
-            if (rEvent.State >>= nValue)
-                aColor = Color(nValue);
-        }
-
-        SelectEntry(aColor);
+        mrColorStatus.statusChanged(rEvent);
+        SelectEntry(mrColorStatus.GetColor());
     }
 }
 
@@ -1801,20 +1789,8 @@ void ColorWindow::statusChanged( const css::frame::FeatureStateEvent& rEvent )
     }
     else
     {
-        Color aColor(COL_TRANSPARENT);
-
-        if (mrBorderColorStatus.statusChanged(rEvent))
-        {
-            aColor = mrBorderColorStatus.GetColor();
-        }
-        else if (rEvent.IsEnabled)
-        {
-            sal_Int32 nValue;
-            if (rEvent.State >>= nValue)
-                aColor = Color(nValue);
-        }
-
-        SelectEntry(aColor);
+        mrColorStatus.statusChanged(rEvent);
+        SelectEntry(mrColorStatus.GetColor());
     }
 }
 
@@ -1926,94 +1902,59 @@ void ColorWindow::SelectEntry(const Color& rColor)
     ColorWindow::SelectEntry(std::make_pair(rColor, sColorName));
 }
 
-BorderColorStatus::BorderColorStatus() :
+ColorStatus::ColorStatus() :
     maColor( COL_TRANSPARENT ),
     maTLBRColor( COL_TRANSPARENT ),
     maBLTRColor( COL_TRANSPARENT )
 {
 }
 
-BorderColorStatus::~BorderColorStatus()
+ColorStatus::~ColorStatus()
 {
 }
 
-bool BorderColorStatus::statusChanged( const css::frame::FeatureStateEvent& rEvent )
+void ColorStatus::statusChanged( const css::frame::FeatureStateEvent& rEvent )
 {
     Color aColor( COL_TRANSPARENT );
+    css::table::BorderLine2 aTable;
 
-    if ( rEvent.FeatureURL.Complete == ".uno:FrameLineColor" )
+    if ( rEvent.State >>= aTable )
     {
-        if ( rEvent.IsEnabled )
-            rEvent.State >>= aColor;
-
-        maColor = aColor;
-        return true;
-    }
-    else
-    {
-        css::table::BorderLine2 aTable;
-        if ( rEvent.IsEnabled )
-            rEvent.State >>= aTable;
-
         SvxBorderLine aLine;
         SvxBoxItem::LineToSvxLine( aTable, aLine, false );
         if ( !aLine.isEmpty() )
             aColor = aLine.GetColor();
-
-        if ( rEvent.FeatureURL.Complete == ".uno:BorderTLBR" )
-        {
-            maTLBRColor = aColor;
-            return true;
-        }
-        else if ( rEvent.FeatureURL.Complete == ".uno:BorderBLTR" )
-        {
-            maBLTRColor = aColor;
-            return true;
-        }
     }
+    else
+        rEvent.State >>= aColor;
 
-    return false;
+    if ( rEvent.FeatureURL.Path == "BorderTLBR" )
+        maTLBRColor = aColor;
+    else if ( rEvent.FeatureURL.Path == "BorderBLTR" )
+        maBLTRColor = aColor;
+    else
+        maColor = aColor;
 }
 
-Color BorderColorStatus::GetColor()
+Color ColorStatus::GetColor()
 {
-    bool bHasColor = maColor != COL_TRANSPARENT;
-    bool bHasTLBRColor = maTLBRColor != COL_TRANSPARENT;
-    bool bHasBLTRColor = maBLTRColor != COL_TRANSPARENT;
+    Color aColor( maColor );
 
-    if ( !bHasColor && bHasTLBRColor && !bHasBLTRColor )
-        return maTLBRColor;
-    else if ( !bHasColor && !bHasTLBRColor && bHasBLTRColor )
-        return maBLTRColor;
-    else if ( bHasColor && bHasTLBRColor && !bHasBLTRColor )
-    {
-        if ( maColor == maTLBRColor )
-            return maColor;
-        else
-            return maBLTRColor;
-    }
-    else if ( bHasColor && !bHasTLBRColor && bHasBLTRColor )
-    {
-        if ( maColor == maBLTRColor )
-            return maColor;
-        else
-            return maTLBRColor;
-    }
-    else if ( !bHasColor && bHasTLBRColor && bHasBLTRColor )
+    if ( maTLBRColor != COL_TRANSPARENT )
     {
-        if ( maTLBRColor == maBLTRColor )
-            return maTLBRColor;
-        else
-            return maColor;
+        if ( aColor != maTLBRColor && aColor != COL_TRANSPARENT )
+            return COL_TRANSPARENT;
+        aColor = maTLBRColor;
     }
-    else if ( bHasColor && bHasTLBRColor && bHasBLTRColor )
+
+    if ( maBLTRColor != COL_TRANSPARENT )
     {
-        if ( maColor == maTLBRColor && maColor == maBLTRColor )
-            return maColor;
-        else
+        if ( aColor != maBLTRColor && aColor != COL_TRANSPARENT )
             return COL_TRANSPARENT;
+        return maBLTRColor;
     }
-    return maColor;
+
+    return aColor;
 }
 
 
@@ -3172,7 +3113,7 @@ VclPtr<vcl::Window> SvxColorToolBoxControl::createPopupWindow( vcl::Window* pPar
     VclPtrInstance<SvxColorWindow> pColorWin(
                             m_aCommandURL,
                             m_xPaletteManager,
-                            m_aBorderColorStatus,
+                            m_aColorStatus,
                             m_nSlotId,
                             m_xFrame,
                             pParent,
@@ -3205,17 +3146,8 @@ void SvxColorToolBoxControl::statusChanged( const css::frame::FeatureStateEvent&
     bool bValue;
     if ( !m_bSplitButton )
     {
-        Color aColor( COL_TRANSPARENT );
-
-        if ( m_aBorderColorStatus.statusChanged( rEvent ) )
-        {
-            aColor = m_aBorderColorStatus.GetColor();
-        }
-        else if ( rEvent.IsEnabled )
-        {
-            rEvent.State >>= aColor;
-        }
-        m_xBtnUpdater->Update( aColor );
+        m_aColorStatus.statusChanged( rEvent );
+        m_xBtnUpdater->Update( m_aColorStatus.GetColor() );
     }
     else if ( rEvent.State >>= bValue )
         pToolBox->CheckItem( nId, bValue );
@@ -3710,7 +3642,7 @@ void SvxColorListBox::createColorWindow()
     m_xColorWindow = VclPtr<SvxColorWindow>::Create(
                             OUString() /*m_aCommandURL*/,
                             m_xPaletteManager,
-                            m_aBorderColorStatus,
+                            m_aColorStatus,
                             m_nSlotId,
                             xFrame,
                             this,
@@ -3810,7 +3742,7 @@ void ColorListBox::createColorWindow()
 
     m_xColorWindow.reset(new ColorWindow(
                             m_xPaletteManager,
-                            m_aBorderColorStatus,
+                            m_aColorStatus,
                             m_nSlotId,
                             xFrame,
                             m_pTopLevel,


More information about the Libreoffice-commits mailing list