Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Attached patch addresses the first fix for fdo45671, the rest will follow one by one.

This patch is a bit more elaborate than I expect the rest to be as I prepared the code
for the patches to follow, i.e. for the split buttons that I will be adding.

I have renamed class SvxFontColorExtToolBoxControl to SvxColorExtToolBoxControl
as the class now handles not only font and font background, but also cell background
and paragraph background ( and will handle borders too, I think).
The working principle is the same as used for fdo34425.

Winfried
From b7766b469e15cdf4313b6ee05ad2b5622d6e4c81 Mon Sep 17 00:00:00 2001
From: Winfried Donkers <osc@dci-electronics.nl>
Date: Mon, 20 Feb 2012 17:41:43 +0100
Subject: [PATCH] fdo44611 writer: paragraph background color picker with
 split button

---
 reportdesign/source/ui/misc/toolboxcontroller.cxx |    4 +-
 sc/source/ui/app/scdll.cxx                        |    2 +-
 sc/source/ui/view/formatsh.cxx                    |    2 +-
 svx/inc/svx/tbcontrl.hxx                          |   29 +++---
 svx/source/tbxctrls/tbcontrl.cxx                  |  115 ++++++++++++--------
 sw/source/ui/app/swmodule.cxx                     |    6 +-
 sw/source/ui/inc/basesh.hxx                       |    5 +-
 sw/source/ui/shells/basesh.cxx                    |   12 ++-
 8 files changed, 102 insertions(+), 73 deletions(-)
 mode change 100755 => 100644 svx/inc/svx/svxids.hrc

diff --git a/reportdesign/source/ui/misc/toolboxcontroller.cxx 
b/reportdesign/source/ui/misc/toolboxcontroller.cxx
index bee4a39..74e670a 100644
--- a/reportdesign/source/ui/misc/toolboxcontroller.cxx
+++ b/reportdesign/source/ui/misc/toolboxcontroller.cxx
@@ -197,7 +197,7 @@ void SAL_CALL OToolboxController::initialize( const Sequence< Any >& _rArguments
         {
             
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FontColor")),sal_True));
             
m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Color")),sal_True));
-            m_pToolbarController = TToolbarHelper::createFromQuery(new 
SvxFontColorExtToolBoxControl/*SvxFontColorToolBoxControl*/(m_nSlotId = 
SID_ATTR_CHAR_COLOR2,m_nToolBoxId,*pToolBox));
+            m_pToolbarController = TToolbarHelper::createFromQuery(new 
SvxColorExtToolBoxControl(m_nSlotId = SID_ATTR_CHAR_COLOR2,m_nToolBoxId,*pToolBox));
         }
         else
         {
@@ -268,7 +268,7 @@ void SAL_CALL OToolboxController::statusChanged( const FeatureStateEvent& Event
                         ::Color aGcc3WorkaroundTemporary( nColor);
                         SvxColorItem aColorItem(aGcc3WorkaroundTemporary,1);
                         if ( SID_ATTR_CHAR_COLOR2 == m_nSlotId )
-                            
static_cast<SvxFontColorExtToolBoxControl*>(m_pToolbarController.get())->StateChanged(m_nSlotId,Event.IsEnabled
 ? SFX_ITEM_SET : SFX_ITEM_DISABLED,&aColorItem);
+                            
static_cast<SvxColorExtToolBoxControl*>(m_pToolbarController.get())->StateChanged(m_nSlotId,Event.IsEnabled
 ? SFX_ITEM_SET : SFX_ITEM_DISABLED,&aColorItem);
                         else
                             
static_cast<SvxColorToolBoxControl*>(m_pToolbarController.get())->StateChanged(m_nSlotId,Event.IsEnabled
 ? SFX_ITEM_SET : SFX_ITEM_DISABLED,&aColorItem);
                     }
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index 4675a2e..cb98122 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -204,7 +204,7 @@ void ScDLL::Init()
     SvxFontNameToolBoxControl       ::RegisterControl(SID_ATTR_CHAR_FONT,       pMod);
 //  SvxFontHeightToolBoxControl     ::RegisterControl(SID_ATTR_CHAR_FONTHEIGHT, pMod);
     SvxFontColorToolBoxControl      ::RegisterControl(SID_ATTR_CHAR_COLOR,      pMod);
-    SvxFontColorExtToolBoxControl   ::RegisterControl(SID_BACKGROUND_COLOR,     pMod);
+    SvxColorExtToolBoxControl       ::RegisterControl(SID_BACKGROUND_COLOR,     pMod);
     SvxFrameToolBoxControl          ::RegisterControl(SID_ATTR_BORDER,          pMod);
     SvxFrameLineStyleToolBoxControl ::RegisterControl(SID_FRAME_LINESTYLE,      pMod);
     SvxFrameLineColorToolBoxControl ::RegisterControl(SID_FRAME_LINECOLOR,      pMod);
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index bbb44ae..8a91f36 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -1453,10 +1453,10 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
             case SID_BACKGROUND_COLOR:
                 {
                     //  SID_BACKGROUND_COLOR without arguments -> set background to last used color
+
                     SvxBrushItem        aBrushItem( (const SvxBrushItem&)
                                             pTabViewShell->GetSelectionPattern()->
                                                 GetItem( ATTR_BACKGROUND ) );
-
                     aBrushItem.SetColor( pTabViewShell->GetBackgroundColor()  );
 
                     pTabViewShell->ApplyAttr( aBrushItem );
diff --git a/svx/inc/svx/svxids.hrc b/svx/inc/svx/svxids.hrc
old mode 100755
new mode 100644
diff --git a/svx/inc/svx/tbcontrl.hxx b/svx/inc/svx/tbcontrl.hxx
index 32f218d..c2fdbe3 100644
--- a/svx/inc/svx/tbcontrl.hxx
+++ b/svx/inc/svx/tbcontrl.hxx
@@ -65,23 +65,23 @@
         from DocShell:  presently none
                         in future: color palette
 
-        class SvxFontColorExtToolBoxControl
+        class SvxColorExtToolBoxControl
         -----------------------------------
-        for font color
         Item type:      SvxColorItem
-                    und SfxBoolItem
+                    and SfxBoolItem
+
+        for font color (writer, ...)
         Execute-Id      SID_ATTR_CHAR_COLOR2
-                    und SID_ATTR_CHAR_COLOR_EXT
+                    and SID_ATTR_CHAR_COLOR_EXT
 
         for character background color (writer)
-        Item-Typ        SvxColorItem
-                    und SfxBoolItem
         Execute-Id      SID_ATTR_CHAR_COLOR_BACKGROUND
-                    und SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
+                    and SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
+
+        for paragraph background color (writer)
+        Execute-Id      SID_BACKGROUND_COLOR
 
         for  cell background color (calc)
-        Item-Typ        SvxColorItem
-                    und SfxBoolItem
         Execute-Id      SID_ATTR_CHAR_COLOR_BACKGROUND
 
         SvxColorToolBoxControl
@@ -89,9 +89,6 @@
         Item type:      SvxBrushItem
         Execute-Id:     SID_BACKGROUND_COLOR
                         -> SvxColorItem
-        Additional information
-        from DocShell:   presently none
-                        in future: color palette
 
         SvxPatternToolBoxControl
         ------------------------
@@ -306,12 +303,12 @@ public:
 
 
 //========================================================================
-// class SvxFontColorExtToolBoxControl --------------------------------------
+// class SvxColorExtToolBoxControl --------------------------------------
 //========================================================================
 
 
 
-class SVX_DLLPUBLIC SvxFontColorExtToolBoxControl : public SfxToolBoxControl
+class SVX_DLLPUBLIC SvxColorExtToolBoxControl : public SfxToolBoxControl
 {
     using SfxToolBoxControl::StateChanged;
     using SfxToolBoxControl::Select;
@@ -323,8 +320,8 @@ class SVX_DLLPUBLIC SvxFontColorExtToolBoxControl : public SfxToolBoxControl
 
 public:
     SFX_DECL_TOOLBOX_CONTROL();
-    SvxFontColorExtToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
-    ~SvxFontColorExtToolBoxControl();
+    SvxColorExtToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
+    ~SvxColorExtToolBoxControl();
 
     virtual void                StateChanged( sal_uInt16 nSID, SfxItemState eState,
                                               const SfxPoolItem* pState );
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 067a0ca..5fdcd18 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -122,7 +122,7 @@ using namespace ::com::sun::star::lang;
 SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl, SfxTemplateItem );
 SFX_IMPL_TOOLBOX_CONTROL( SvxFontNameToolBoxControl, SvxFontItem );
 SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorToolBoxControl, SvxColorItem );
-SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorExtToolBoxControl, SvxColorItem );
+SFX_IMPL_TOOLBOX_CONTROL( SvxColorExtToolBoxControl, SvxColorItem );
 SFX_IMPL_TOOLBOX_CONTROL( SvxColorToolBoxControl, SvxColorItem );
 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameToolBoxControl, SvxBoxItem );
 SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineStyleToolBoxControl, SvxLineItem );
@@ -2231,10 +2231,10 @@ void SvxColorToolBoxControl::StateChanged(
 }
 
 //========================================================================
-// class SvxFontColorExtToolBoxControl --------------------------------------
+// class SvxColorExtToolBoxControl ----------------------------------------
 //========================================================================
 
-SvxFontColorExtToolBoxControl::SvxFontColorExtToolBoxControl(
+SvxColorExtToolBoxControl::SvxColorExtToolBoxControl(
     sal_uInt16 nSlotId,
     sal_uInt16 nId,
     ToolBox& rTbx ) :
@@ -2243,37 +2243,47 @@ SvxFontColorExtToolBoxControl::SvxFontColorExtToolBoxControl(
     pBtnUpdater(0),
     mLastColor( COL_AUTO )
 {
+    sal_uInt16 nMode;
+
     rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
     bChoiceFromPalette = sal_False;
 
-    // The following commands are available at the writer and the calc module.
-    if ( SID_ATTR_CHAR_COLOR2 == nSlotId || SID_ATTR_CHAR_COLOR == nSlotId )
-        addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" )));
-    else
-        addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" )));
+    // The following commands are available at the various modules
+    switch( nSlotId )
+    {
+        case SID_ATTR_CHAR_COLOR2 :
+        case SID_ATTR_CHAR_COLOR  :
+            addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" )));
+            nMode = TBX_UPDATER_MODE_CHAR_COLOR_NEW;
+            break;
 
-    sal_uInt16 nMode = TBX_UPDATER_MODE_CHAR_COLOR_NEW;
+        case SID_ATTR_CHAR_COLOR_BACKGROUND :
+        case SID_BACKGROUND_COLOR :
+            addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" )));
+            nMode = TBX_UPDATER_MODE_CHAR_COLOR_NEW;
+            break;
+    }
 
     pBtnUpdater = new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox(), nMode );
 }
 
 // -----------------------------------------------------------------------
 
-SvxFontColorExtToolBoxControl::~SvxFontColorExtToolBoxControl()
+SvxColorExtToolBoxControl::~SvxColorExtToolBoxControl()
 {
     delete pBtnUpdater;
 }
 
 // -----------------------------------------------------------------------
 
-SfxPopupWindowType SvxFontColorExtToolBoxControl::GetPopupWindowType() const
+SfxPopupWindowType SvxColorExtToolBoxControl::GetPopupWindowType() const
 {
     return SFX_POPUPWINDOW_ONTIMEOUT;
 }
 
 // -----------------------------------------------------------------------
 
-SfxPopupWindow* SvxFontColorExtToolBoxControl::CreatePopupWindow()
+SfxPopupWindow* SvxColorExtToolBoxControl::CreatePopupWindow()
 {
     SvxColorWindow_Impl* pColorWin =
         new SvxColorWindow_Impl(
@@ -2284,8 +2294,16 @@ SfxPopupWindow* SvxFontColorExtToolBoxControl::CreatePopupWindow()
                             &GetToolBox(),
                             mLastColor );
 
-    if ( GetSlotId() == SID_ATTR_CHAR_COLOR_BACKGROUND )
-        pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_EXTRAS_CHARBACKGROUND ) );
+    switch( GetSlotId() )
+    {
+        case SID_ATTR_CHAR_COLOR_BACKGROUND :
+            pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_EXTRAS_CHARBACKGROUND ) );
+            break;
+
+        case SID_BACKGROUND_COLOR :
+            pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_BACKGROUND ) );
+            break;
+    }
 
     pColorWin->StartPopupMode( &GetToolBox(),
         FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
@@ -2297,7 +2315,7 @@ SfxPopupWindow* SvxFontColorExtToolBoxControl::CreatePopupWindow()
 
 // -----------------------------------------------------------------------
 
-void SvxFontColorExtToolBoxControl::StateChanged(
+void SvxColorExtToolBoxControl::StateChanged(
 
     sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
 
@@ -2308,53 +2326,58 @@ void SvxFontColorExtToolBoxControl::StateChanged(
     if ( bChoiceFromPalette )
     {
         bChoiceFromPalette = sal_False;
-        if ( nSID == SID_ATTR_CHAR_COLOR_EXT ||
-                nSID == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT )
-        {
-            if ( SFX_ITEM_DONTCARE != eState )
-            {
-                const SfxBoolItem* pBool = PTR_CAST( SfxBoolItem, pState );
-                rTbx.CheckItem( nId, pBool && pBool->GetValue());
-            }
-            rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
-        }
-        else
+        switch( nSID )
         {
-            if ( SFX_ITEM_DONTCARE != eState )
-                pItem = PTR_CAST( SvxColorItem, pState );
+            case SID_ATTR_CHAR_COLOR_EXT :
+            case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT :
+                if ( SFX_ITEM_DONTCARE != eState )
+                {
+                    const SfxBoolItem* pBool = PTR_CAST( SfxBoolItem, pState );
+                    rTbx.CheckItem( nId, pBool && pBool->GetValue());
+                }
+                rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
+                break;
 
-            if ( pItem )
-            {
-                pBtnUpdater->Update( pItem->GetValue() );
-                mLastColor = pItem->GetValue();
-            }
+            case SID_ATTR_CHAR_COLOR2 :
+            case SID_ATTR_CHAR_COLOR_BACKGROUND :
+            case SID_BACKGROUND_COLOR :
+                if ( SFX_ITEM_DONTCARE != eState )
+                    pItem = PTR_CAST( SvxColorItem, pState );
+
+                if ( pItem )
+                {
+                    pBtnUpdater->Update( pItem->GetValue() );
+                    mLastColor = pItem->GetValue();
+                }
+                break;
         }
     }
 }
 
 // -----------------------------------------------------------------------
 
-void SvxFontColorExtToolBoxControl::Select( sal_Bool )
+void SvxColorExtToolBoxControl::Select( sal_Bool )
 {
     OUString aCommand;
     OUString aParamName;
-    if ( SID_ATTR_CHAR_COLOR2 == GetSlotId() || SID_ATTR_CHAR_COLOR == GetSlotId() )
-    {
-        aCommand    = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" ));
-        aParamName  = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColorExt" ));
-    }
-    else
+
+    switch( GetSlotId() )
     {
-        if ( SID_BACKGROUND_COLOR == GetSlotId() )
-        {
+        case SID_ATTR_CHAR_COLOR2 :
+        case SID_ATTR_CHAR_COLOR  :
+            aCommand    = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" ));
+            aParamName  = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColorExt" ));
+            break;
+
+        case SID_BACKGROUND_COLOR :
             aCommand    = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BackgroundColor" ));
             aParamName  = OUString( RTL_CONSTASCII_USTRINGPARAM( "BackgroundColor" ));
-        }
-        else
-        {
+            break;
+
+        case SID_ATTR_CHAR_COLOR_BACKGROUND :
             aCommand    = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" ));
             aParamName  = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharBackgroundExt" ));
-        }
+            break;
     }
 
     Sequence< PropertyValue > aArgs( 1 );
diff --git a/sw/source/ui/app/swmodule.cxx b/sw/source/ui/app/swmodule.cxx
index b37b86f..ab74737 100644
--- a/sw/source/ui/app/swmodule.cxx
+++ b/sw/source/ui/app/swmodule.cxx
@@ -349,10 +349,10 @@ void SwDLL::RegisterControls()
 
     SvxFontNameToolBoxControl::RegisterControl(SID_ATTR_CHAR_FONT, pMod );
     SvxFontColorToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR, pMod );
-    SvxFontColorExtToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR2, pMod );
-    SvxFontColorExtToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR_BACKGROUND, pMod );
+    SvxColorExtToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR2, pMod );
+    SvxColorExtToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR_BACKGROUND, pMod );
     SvxStyleToolBoxControl::RegisterControl(SID_STYLE_APPLY, pMod );
-    SvxColorToolBoxControl::RegisterControl(SID_BACKGROUND_COLOR, pMod );
+    SvxColorExtToolBoxControl::RegisterControl( SID_BACKGROUND_COLOR, pMod );
     SvxFrameToolBoxControl::RegisterControl(SID_ATTR_BORDER, pMod );
     SvxFrameLineStyleToolBoxControl::RegisterControl(SID_FRAME_LINESTYLE, pMod );
     SvxFrameLineColorToolBoxControl::RegisterControl(SID_FRAME_LINECOLOR, pMod );
diff --git a/sw/source/ui/inc/basesh.hxx b/sw/source/ui/inc/basesh.hxx
index 648af2b..26e48b2 100644
--- a/sw/source/ui/inc/basesh.hxx
+++ b/sw/source/ui/inc/basesh.hxx
@@ -35,6 +35,7 @@
 #include <sfx2/module.hxx>
 #include <sfx2/shell.hxx>
 #include <svl/svstdarr.hxx>
+#include <viewopt.hxx>
 
 #include <mdiexp.hxx>
 #include <set>
@@ -49,6 +50,7 @@ struct DBTextStruct_Impl;
 class SwBaseShell: public SfxShell
 {
     SwView      &rView;
+    static Color        mBackgroundColor;
 
     // DragMode
     static FlyMode eFrameMode;
@@ -119,7 +121,8 @@ public:
     static void    SetFrmMode( FlyMode eMode, SwWrtShell *pShell );  // with update!
     static void   _SetFrmMode( FlyMode eMode )   { eFrameMode = eMode; }
     static FlyMode  GetFrmMode()                 { return eFrameMode;  }
-
+    Color       GetBackgroundColor()                   { return  mBackgroundColor; }
+    void        SetBackgroundColor( const Color& clr ) { mBackgroundColor = clr;   }
 };
 
 
diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx
index d793595..c45a40d 100644
--- a/sw/source/ui/shells/basesh.cxx
+++ b/sw/source/ui/shells/basesh.cxx
@@ -1927,6 +1927,10 @@ void SwBaseShell::SetFrmMode(FlyMode eMode, SwWrtShell *pSh )
 /*--------------------------------------------------------------------
     Beschreibung:   Ctor
  --------------------------------------------------------------------*/
+// STATIC DATA -----------------------------------------------------------
+Color  SwBaseShell::mBackgroundColor = COL_TRANSPARENT;
+//             -----------------------------------------------------------
+
 SwBaseShell::SwBaseShell(SwView& rVw) :
     SfxShell( &rVw ),
     rView(rVw),
@@ -2260,13 +2264,15 @@ void SwBaseShell::ExecBckCol(SfxRequest& rReq)
                                             pArgs->Get(SID_BACKGROUND_COLOR);
                     const Color& rNewColor = rNewColorItem.GetValue();
                     aBrushItem.SetColor( rNewColor );
+                    SetBackgroundColor( rNewColor );
                     GetView().GetViewFrame()->GetBindings().SetState(rNewColorItem);
                 }
                 else
                 {
-                    aBrushItem.SetColor( COL_TRANSPARENT );
-                    rReq.AppendItem( SvxColorItem( Color( COL_TRANSPARENT ), nSlot ) );
-                }
+                    // call without arguments, use last used background color
+                    aBrushItem.SetColor( GetBackgroundColor() );
+                    rReq.AppendItem( SvxColorItem( GetBackgroundColor(), nSlot ) );
+                 }
             }
             break;
 
-- 
1.7.7


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.