[Libreoffice-commits] .: reportdesign/source sc/source svx/inc svx/source sw/source

Michael Meeks michael at kemper.freedesktop.org
Tue Feb 21 06:51:59 PST 2012


 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(-)

New commits:
commit 836d98646203e0d9d3916571ed55d6572c2cb3dc
Author: Winfried Donkers <osc at dci-electronics.nl>
Date:   Tue Feb 21 14:50:04 2012 +0000

    fdo#44611 writer: paragraph background color picker with split button

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 e0f0bdd..35806e5 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 6e1421e..5965dd4 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 );
@@ -2235,10 +2235,10 @@ void SvxColorToolBoxControl::StateChanged(
 }
 
 //========================================================================
-// class SvxFontColorExtToolBoxControl --------------------------------------
+// class SvxColorExtToolBoxControl ----------------------------------------
 //========================================================================
 
-SvxFontColorExtToolBoxControl::SvxFontColorExtToolBoxControl(
+SvxColorExtToolBoxControl::SvxColorExtToolBoxControl(
     sal_uInt16 nSlotId,
     sal_uInt16 nId,
     ToolBox& rTbx ) :
@@ -2247,37 +2247,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(
@@ -2288,8 +2298,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 );
@@ -2301,7 +2319,7 @@ SfxPopupWindow* SvxFontColorExtToolBoxControl::CreatePopupWindow()
 
 // -----------------------------------------------------------------------
 
-void SvxFontColorExtToolBoxControl::StateChanged(
+void SvxColorExtToolBoxControl::StateChanged(
 
     sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
 
@@ -2312,53 +2330,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;
 


More information about the Libreoffice-commits mailing list