include/svx/sidebar/PanelLayout.hxx | 4 ++ include/vcl/builder.hxx | 5 ++- svx/source/sidebar/PanelLayout.cxx | 21 ++++++++++++ svx/source/sidebar/text/TextPropertyPanel.cxx | 43 +------------------------- 4 files changed, 32 insertions(+), 41 deletions(-)
New commits: commit a0fdc73984d0eb89eacbcd858db938ad5cf1157d Author: Caolán McNamara <[email protected]> Date: Thu Jan 16 20:36:25 2014 +0000 Related: fdo#73414 use frame::XDispatch::dispatch directly This hopefully is a model which we can build in further to remove the rest of the direct SID... stuff and the fragile mapping from the known .uno: commands to SIDS to dispatch, and instead just dispatch the .uno: command directly Change-Id: Iec0f92123fa4c2dae15e0ac716d5ef687e67da79 diff --git a/svx/source/sidebar/text/TextPropertyPanel.cxx b/svx/source/sidebar/text/TextPropertyPanel.cxx index 8f29d2f..2ed39fc 100644 --- a/svx/source/sidebar/text/TextPropertyPanel.cxx +++ b/svx/source/sidebar/text/TextPropertyPanel.cxx @@ -81,9 +81,6 @@ namespace svx { namespace sidebar { #undef HAS_IA2 -#define FN_GROW_FONT_SIZE (FN_FORMAT + 3 ) -#define FN_SHRINK_FONT_SIZE (FN_FORMAT + 4 ) - PopupControl* TextPropertyPanel::CreateCharacterSpacingControl (PopupContainer* pParent) { return new TextCharacterSpacingControl(pParent, *this, mpBindings); @@ -553,44 +550,10 @@ IMPL_LINK(TextPropertyPanel, ToolboxIncDecSelectHdl, ToolBox*, pToolBox) const sal_uInt16 nId = pToolBox->GetCurItemId(); const OUString aCommand(pToolBox->GetItemCommand(nId)); - // font size +/- enhancement in sd - switch (maContext.GetCombinedContext_DI()) - { - case CombinedEnumContext(Application_DrawImpress, Context_DrawText): - case CombinedEnumContext(Application_DrawImpress, Context_Text): - case CombinedEnumContext(Application_DrawImpress, Context_Table): - case CombinedEnumContext(Application_DrawImpress, Context_OutlineText): - case CombinedEnumContext(Application_DrawImpress, Context_Draw): - case CombinedEnumContext(Application_DrawImpress, Context_TextObject): - case CombinedEnumContext(Application_DrawImpress, Context_Graphic): - if(aCommand == UNO_GROW) - { - EndTracking(); - SfxVoidItem aItem(SID_GROW_FONT_SIZE); - mpBindings->GetDispatcher()->Execute( SID_GROW_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L ); - } - else if(aCommand == UNO_SHRINK) - { - EndTracking(); - SfxVoidItem aItem(SID_SHRINK_FONT_SIZE); - mpBindings->GetDispatcher()->Execute( SID_SHRINK_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L ); - } - break; + EndTracking(); + + dispatch(aCommand); - default: - if(aCommand == UNO_GROW) - { - EndTracking(); - SfxVoidItem aItem(FN_GROW_FONT_SIZE); - mpBindings->GetDispatcher()->Execute( FN_GROW_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L ); - } - else if(aCommand == UNO_SHRINK) - { - EndTracking(); - SfxVoidItem aItem(FN_SHRINK_FONT_SIZE); - mpBindings->GetDispatcher()->Execute( FN_SHRINK_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L ); - } - } UpdateItem(SID_ATTR_CHAR_FONTHEIGHT); return 0; commit 36e590ee00affc89b26055c748b862cf79f56247 Author: Caolán McNamara <[email protected]> Date: Thu Jan 16 20:33:54 2014 +0000 make use that these VclBuilders have an XFrame to expose its dispatch the sidebar widget-layout enabled panels could use frame::XDispatch::dispatch to send their commands directly rather than mapping back to SIDS and Executing those, which would allow removing piles of weird-ass stuff Change-Id: Ibbff56d4fb96820d3bdbf4b1cb582d25337fe48b diff --git a/include/svx/sidebar/PanelLayout.hxx b/include/svx/sidebar/PanelLayout.hxx index 5275ced..fe55f11 100644 --- a/include/svx/sidebar/PanelLayout.hxx +++ b/include/svx/sidebar/PanelLayout.hxx @@ -16,6 +16,7 @@ #include <vcl/ctrl.hxx> #include <vcl/timer.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/frame/XFrame.hpp> /// This class is the base for the Widget Layout-based sidebar panels. @@ -36,6 +37,9 @@ public: virtual Size GetOptimalSize() const; virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL); virtual void queue_resize(); + + void dispatch(const OUString& rCommand, const css::uno::Sequence<css::beans::PropertyValue>& rArgs = + css::uno::Sequence<css::beans::PropertyValue>()); }; #endif diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index 8cd25a0..2719aba 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -242,7 +242,7 @@ private: }; /// XFrame to be able to extract labels and other properties of the UNO commands (like of .uno:Bold). - com::sun::star::uno::Reference<com::sun::star::frame::XFrame> m_xFrame; + css::uno::Reference<css::frame::XFrame> m_xFrame; public: VclBuilder(::Window *pParent, OUString sUIRootDir, OUString sUIFile, @@ -308,6 +308,8 @@ public: //Helpers to retrofit all the existing code to the builder static void reorderWithinParent(std::vector< ::Window*>& rChilds, bool bIsButtonBox); static void reorderWithinParent(::Window &rWindow, sal_uInt16 nNewPosition); + + css::uno::Reference<css::frame::XFrame> getFrame() { return m_xFrame; } private: ::Window *insertObject(::Window *pParent, const OString &rClass, const OString &rID, @@ -390,6 +392,7 @@ public: virtual ~VclBuilderContainer(); static OUString getUIRootDir(); bool hasBuilder() const { return m_pUIBuilder != NULL; } + css::uno::Reference<css::frame::XFrame> getFrame() { return m_pUIBuilder->getFrame(); } template <typename T> T* get(T*& ret, OString sID) { return m_pUIBuilder->get<T>(ret, sID); diff --git a/svx/source/sidebar/PanelLayout.cxx b/svx/source/sidebar/PanelLayout.cxx index e31c75b..72bdfc2 100644 --- a/svx/source/sidebar/PanelLayout.cxx +++ b/svx/source/sidebar/PanelLayout.cxx @@ -7,6 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/util/URLTransformer.hpp> +#include <comphelper/processfactory.hxx> #include <svx/sidebar/PanelLayout.hxx> #include <vcl/layout.hxx> @@ -87,4 +91,21 @@ void PanelLayout::setPosSizePixel(long nX, long nY, long nWidth, long nHeight, s VclContainer::setLayoutAllocation(*pChild, Point(0, 0), Size(nWidth, nHeight)); } +void PanelLayout::dispatch(const OUString& rCommand, const css::uno::Sequence<css::beans::PropertyValue>& rArgs) +{ + assert(getFrame().is()); + + css::util::URL aURL; + aURL.Complete = rCommand; + + css::uno::Reference<css::util::XURLTransformer > xURLTransformer( + css::util::URLTransformer::create(comphelper::getProcessComponentContext())); + + xURLTransformer->parseStrict(aURL); + + css::uno::Reference<css::frame::XDispatchProvider> xProvider(getFrame(), css::uno::UNO_QUERY_THROW); + css::uno::Reference<css::frame::XDispatch > xDispatch(xProvider->queryDispatch(aURL, OUString(), 0)); + xDispatch->dispatch(aURL, rArgs); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
