diff options
-rw-r--r-- | include/svx/PaletteManager.hxx | 11 | ||||
-rw-r--r-- | svx/source/tbxctrls/PaletteManager.cxx | 34 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 17 |
3 files changed, 46 insertions, 16 deletions
diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx index 1bd0bd1fd39d..9d40d48426be 100644 --- a/include/svx/PaletteManager.hxx +++ b/include/svx/PaletteManager.hxx @@ -24,6 +24,14 @@ #include <rtl/ustring.hxx> #include <svx/tbxcolorupdate.hxx> +#include <tools/urlobj.hxx> +#include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/util/URLTransformer.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <comphelper/processfactory.hxx> + class PaletteManager { sal_uInt16 mnNumOfPalettes; @@ -48,7 +56,8 @@ public: const Color& GetLastColor(); void SetLastColor(const Color& rLastColor); void SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater); - void PopupColorPicker(); + void PopupColorPicker(const OUString aCommand); + static void DispatchColorCommand(const OUString aCommand, const Color aColor); }; #endif // INCLUDED_SVX_PALETTEMANAGER_HXX diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index 95485ced1a03..da80f23db37d 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -21,7 +21,7 @@ #include <osl/file.hxx> #include <unotools/pathoptions.hxx> #include <sfx2/objsh.hxx> -#include "svx/drawitem.hxx" +#include <svx/drawitem.hxx> #include <svx/dialogs.hrc> #include <svtools/colrdlg.hxx> @@ -179,7 +179,7 @@ void PaletteManager::SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater) mpBtnUpdater = pBtnUpdater; } -void PaletteManager::PopupColorPicker() +void PaletteManager::PopupColorPicker(const OUString aCommand) { SvColorDialog aColorDlg( 0 ); aColorDlg.SetColor ( mLastColor ); @@ -188,6 +188,36 @@ void PaletteManager::PopupColorPicker() { mpBtnUpdater->Update( aColorDlg.GetColor() ); mLastColor = aColorDlg.GetColor(); + DispatchColorCommand(aCommand, mLastColor); + } +} + +void PaletteManager::DispatchColorCommand(const OUString aCommand, const Color aColor) +{ + using namespace css::uno; + using namespace css::frame; + using namespace css::beans; + using namespace css::util; + + Reference<XComponentContext> xContext(comphelper::getProcessComponentContext()); + Reference<XDesktop2> xDesktop = Desktop::create(xContext); + Reference<XDispatchProvider> xDispatchProvider(xDesktop->getCurrentFrame(), UNO_QUERY ); + if (xDispatchProvider.is()) + { + INetURLObject aObj( aCommand ); + + Sequence<PropertyValue> aArgs(1); + aArgs[0].Name = aObj.GetURLPath(); + aArgs[0].Value = makeAny(sal_Int32(aColor.GetColor())); + + URL aTargetURL; + aTargetURL.Complete = aCommand; + Reference<XURLTransformer> xURLTransformer(URLTransformer::create(comphelper::getProcessComponentContext())); + xURLTransformer->parseStrict(aTargetURL); + + Reference<XDispatch> xDispatch = xDispatchProvider->queryDispatch(aTargetURL, OUString(), 0); + if (xDispatch.is()) + xDispatch->dispatch(aTargetURL, aArgs); } } diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index f55fc294cb90..64e00e7d8bd2 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -1102,7 +1102,6 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl) else aColor = mpColorSet->GetItemColor( nItemId ); - SvxColorItem aColorItem( aColor, theSlotId ); /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() calls. This instance may be deleted in the meantime (i.e. when a dialog is opened while in Dispatch()), accessing members will crash in this case. */ @@ -1111,20 +1110,10 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl) if ( IsInPopupMode() ) EndPopupMode(); - INetURLObject aObj( maCommand ); - - Any a; - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = aObj.GetURLPath(); - aColorItem.QueryValue( a ); - aArgs[0].Value = a; - SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ), - maCommand, - aArgs ); - if ( maSelectedLink.IsSet() ) maSelectedLink.Call(&aColor); + PaletteManager::DispatchColorCommand(maCommand, aColor); return 0; } @@ -1138,7 +1127,9 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectPaletteHdl) IMPL_LINK_NOARG(SvxColorWindow_Impl, OpenPickerClickHdl) { - mrPaletteManager.PopupColorPicker(); + if ( IsInPopupMode() ) + EndPopupMode(); + mrPaletteManager.PopupColorPicker(maCommand); return 0; } |