summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2014-10-22 21:44:45 +0300
committerMaxim Monastirsky <momonasmon@gmail.com>2014-10-22 23:25:52 +0300
commite2b84636b3baf344cbc8f709478714ddea7caced (patch)
treed2d22ffc0c90a9e217c610369604e35755d87153 /svx
parentaf24b627370f2eecc9222b555fc5c1ef393f5850 (diff)
Related: fdo#84844 Support of Sidebar wide buttons in SvxColorToolBoxControl
The end goal is to convert the Sidebar to use SvxColorToolBoxControl, and get rid of the Sidebar specific color popup, so we don't need to maintain two popups. Change-Id: I42e5bcb611acae25f16dfe9623d19727fc39ea07
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx32
1 files changed, 31 insertions, 1 deletions
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 83d36093736f..293d8a050991 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -59,6 +59,7 @@
#include "helpid.hrc"
#include <sfx2/htmlmode.hxx>
#include <sfx2/sidebar/Sidebar.hxx>
+#include <sfx2/sidebar/SidebarToolBox.hxx>
#include <svx/xtable.hxx>
#include <editeng/fontitem.hxx>
#include <editeng/fhgtitem.hxx>
@@ -2330,7 +2331,10 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
ToolBox& rTbx ) :
SfxToolBoxControl( nSlotId, nId, rTbx )
{
- rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) );
+ if ( dynamic_cast< sfx2::sidebar::SidebarToolBox* >(&rTbx) )
+ bSidebarType = true;
+ else
+ bSidebarType = false;
// The following commands are available at the various modules
switch( nSlotId )
@@ -2338,11 +2342,13 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
case SID_ATTR_CHAR_COLOR:
addStatusListener( OUString( ".uno:Color" ));
mPaletteManager.SetLastColor( COL_RED );
+ bSidebarType = false;
break;
case SID_ATTR_CHAR_COLOR2:
addStatusListener( OUString( ".uno:CharColorExt" ));
mPaletteManager.SetLastColor( COL_RED );
+ bSidebarType = false;
break;
case SID_BACKGROUND_COLOR:
@@ -2353,6 +2359,7 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
case SID_ATTR_CHAR_COLOR_BACKGROUND:
addStatusListener( OUString( ".uno:CharBackgroundExt" ));
mPaletteManager.SetLastColor( COL_YELLOW );
+ bSidebarType = false;
break;
case SID_FRAME_LINECOLOR:
@@ -2370,6 +2377,11 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
break;
}
+ if ( bSidebarType )
+ rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWNONLY | rTbx.GetItemBits( nId ) );
+ else
+ rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) );
+
pBtnUpdater.reset( new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) );
mPaletteManager.SetBtnUpdater( pBtnUpdater.get() );
}
@@ -2448,10 +2460,28 @@ void SvxColorToolBoxControl::StateChanged(
rTbx.CheckItem( nId, pBool && pBool->GetValue() );
}
}
+ else if ( bSidebarType && SfxItemState::DEFAULT <= eState )
+ {
+ Color aColor;
+ if ( pState->ISA( SvxColorItem ) )
+ aColor = static_cast< const SvxColorItem* >(pState)->GetValue();
+ else if ( pState->ISA( XLineColorItem ) )
+ aColor = static_cast< const XLineColorItem* >(pState)->GetColorValue();
+ pBtnUpdater->Update( aColor );
+ }
}
void SvxColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/)
{
+ if ( bSidebarType )
+ {
+ // Open the popup also when Enter key is pressed.
+ css::uno::Reference< css::awt::XWindow > xWin = createPopupWindow();
+ if ( xWin.is() )
+ xWin->setFocus();
+ return;
+ }
+
OUString aCommand;
OUString aParamName;