diff options
author | Andre Fischer <af@apache.org> | 2013-05-14 15:21:57 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-05-20 11:33:35 +0100 |
commit | a9626f143a1466591764b03baa2d15905487b692 (patch) | |
tree | 410958c92408356de4f510b022518be4a5e187d8 /sfx2 | |
parent | 6e6f8cb2b7f2173eafb988f78e9704ed1bbc4b0a (diff) |
Resolves: #i122302# Use tool bar controls for color controls...
in text property panel
(cherry picked from commit 3b252796e1126b5ec1216082f55b8d12017eaeb1)
Conflicts:
sfx2/Package_inc.mk
sfx2/inc/sfx2/sidebar/ControlFactory.hxx
sfx2/inc/sfx2/sidebar/ControllerFactory.hxx
sfx2/inc/sfx2/sidebar/EnumContext.hxx
sfx2/source/sidebar/SidebarToolBox.cxx
svx/source/sidebar/insert/InsertPropertyPanel.cxx
svx/source/sidebar/insert/InsertPropertyPanel.hxx
svx/source/sidebar/text/TextPropertyPanel.cxx
Change-Id: Ifa1947c9e9bfdc3635dbb5b0c7a79f8ead613a90
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/Library_sfx.mk | 1 | ||||
-rw-r--r-- | sfx2/source/sidebar/ControlFactory.cxx | 22 | ||||
-rw-r--r-- | sfx2/source/sidebar/ControllerFactory.cxx | 104 | ||||
-rw-r--r-- | sfx2/source/sidebar/EnumContext.cxx | 50 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarController.cxx | 14 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarController.hxx | 6 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarToolBox.cxx | 201 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarToolBox.hxx | 53 | ||||
-rw-r--r-- | sfx2/source/sidebar/ToolBoxBackground.cxx | 4 |
9 files changed, 370 insertions, 85 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 09ddbe1fd736..03775fda52a8 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -239,6 +239,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/sidebar/ContextChangeBroadcaster \ sfx2/source/sidebar/ContextList \ sfx2/source/sidebar/ControlFactory \ + sfx2/source/sidebar/ControllerFactory \ sfx2/source/sidebar/ControllerItem \ sfx2/source/sidebar/CustomImageRadioButton \ sfx2/source/sidebar/Deck \ diff --git a/sfx2/source/sidebar/ControlFactory.cxx b/sfx2/source/sidebar/ControlFactory.cxx index 43946e0cd061..1a6f9a5e159f 100644 --- a/sfx2/source/sidebar/ControlFactory.cxx +++ b/sfx2/source/sidebar/ControlFactory.cxx @@ -19,7 +19,7 @@ #include "MenuButton.hxx" #include "TabItem.hxx" -#include "SidebarToolBox.hxx" +#include "sfx2/sidebar/SidebarToolBox.hxx" #include "ToolBoxBackground.hxx" #include "CustomImageRadioButton.hxx" #include <vcl/toolbox.hxx> @@ -44,11 +44,27 @@ ImageRadioButton* ControlFactory::CreateTabItem (Window* pParentWindow) -ToolBox* ControlFactory::CreateToolBox ( +SidebarToolBox* ControlFactory::CreateToolBox ( Window* pParentWindow, const ResId& rResId) { - SidebarToolBox* pToolBox = new SidebarToolBox(pParentWindow, rResId); + SidebarToolBox* pToolBox = new SidebarToolBox(pParentWindow, rResId, NULL); + pToolBox->SetBorderWindow(pParentWindow); + + pToolBox->Invalidate(); + + return pToolBox; +} + + + + +SidebarToolBox* ControlFactory::CreateToolBox ( + Window* pParentWindow, + const ResId& rResId, + const cssu::Reference<css::frame::XFrame>& rxFrame) +{ + SidebarToolBox* pToolBox = new SidebarToolBox(pParentWindow, rResId, rxFrame); pToolBox->SetBorderWindow(pParentWindow); pToolBox->Invalidate(); diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx new file mode 100644 index 000000000000..e7463a896c0c --- /dev/null +++ b/sfx2/source/sidebar/ControllerFactory.cxx @@ -0,0 +1,104 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "precompiled_sfx2.hxx" + +#include "sfx2/sidebar/ControllerFactory.hxx" +#include "sfx2/sidebar/CommandInfoProvider.hxx" +#include "sfx2/sidebar/Tools.hxx" + +#include <com/sun/star/frame/XToolbarController.hpp> +#include <com/sun/star/frame/XFrame.hpp> + +#include <framework/sfxhelperfunctions.hxx> +#include <svtools/generictoolboxcontroller.hxx> +#include <comphelper/processfactory.hxx> + + +using namespace css; +using namespace cssu; +using ::rtl::OUString; + + +namespace sfx2 { namespace sidebar { + +Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController( + ToolBox* pToolBox, + const sal_uInt16 nItemId, + const OUString& rsCommandName, + const Reference<frame::XFrame>& rxFrame) +{ + // Create a controller for the new item. + Reference<frame::XToolbarController> xController( + static_cast<XWeak*>(::framework::CreateToolBoxController( + rxFrame, + pToolBox, + nItemId, + rsCommandName)), + UNO_QUERY); + if ( ! xController.is()) + xController.set( + static_cast<XWeak*>(new svt::GenericToolboxController( + ::comphelper::getProcessServiceFactory(), + rxFrame, + pToolBox, + nItemId, + rsCommandName)), + UNO_QUERY); + + // Initialize the controller with eg a service factory. + Reference<lang::XInitialization> xInitialization (xController, UNO_QUERY); + if (xInitialization.is()) + { + beans::PropertyValue aPropValue; + std::vector<Any> aPropertyVector; + + aPropValue.Name = A2S("Frame"); + aPropValue.Value <<= rxFrame; + aPropertyVector.push_back(makeAny(aPropValue)); + + aPropValue.Name = A2S("ServiceManager"); + aPropValue.Value <<= ::comphelper::getProcessServiceFactory(); + aPropertyVector.push_back(makeAny(aPropValue)); + + aPropValue.Name = A2S("CommandURL"); + aPropValue.Value <<= rsCommandName; + aPropertyVector.push_back(makeAny(aPropValue)); + + Sequence<Any> aArgs (comphelper::containerToSequence(aPropertyVector)); + xInitialization->initialize(aArgs); + } + + Reference<util::XUpdatable> xUpdatable (xController, UNO_QUERY); + if (xUpdatable.is()) + xUpdatable->update(); + + // Add label. + if (xController.is()) + { + const OUString sLabel (sfx2::sidebar::CommandInfoProvider::Instance().GetLabelForCommand( + rsCommandName, + rxFrame)); + pToolBox->SetQuickHelpText(nItemId, sLabel); + pToolBox->EnableItem(nItemId); + } + + return xController; +} + + +} } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/EnumContext.cxx b/sfx2/source/sidebar/EnumContext.cxx index 514cd13feb0c..d78d8cfbedda 100644 --- a/sfx2/source/sidebar/EnumContext.cxx +++ b/sfx2/source/sidebar/EnumContext.cxx @@ -82,23 +82,39 @@ sal_Int32 EnumContext::GetCombinedContext (void) const sal_Int32 EnumContext::GetCombinedContext_DI (void) const { - switch (meApplication) - { - case Application_Draw: - case Application_Impress: - return CombinedEnumContext(Application_DrawImpress, meContext); - - case Application_Writer: - case Application_WriterGlobal: - case Application_WriterWeb: - case Application_WriterXML: - case Application_WriterForm: - case Application_WriterReport: - return CombinedEnumContext(Application_WriterVariants, meContext); - - default: - return CombinedEnumContext(meApplication, meContext); - } + return CombinedEnumContext(GetApplication_DI(), meContext); +} + + + + +EnumContext::Application EnumContext::GetApplication_DI (void) const +{ + switch (meApplication) + { + case Application_Draw: + case Application_Impress: + return Application_DrawImpress; + + case Application_Writer: + case Application_WriterGlobal: + case Application_WriterWeb: + case Application_WriterXML: + case Application_WriterForm: + case Application_WriterReport: + return Application_WriterVariants; + + default: + return meApplication; + } +} + + + + +EnumContext::Application EnumContext::GetApplication (void) const +{ + return meApplication; } diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index b508cf456d67..c4ea5378afde 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -572,7 +572,8 @@ void SidebarController::SwitchToDeck ( aNewPanels[nWriteIndex] = CreatePanel( rPanelContexDescriptor.msId, mpCurrentDeck->GetPanelParentWindow(), - rPanelContexDescriptor.mbIsInitiallyVisible); + rPanelContexDescriptor.mbIsInitiallyVisible, + rContext); bHasPanelSetChanged = true; } if (aNewPanels[nWriteIndex] != NULL) @@ -641,7 +642,8 @@ bool SidebarController::ArePanelSetsEqual ( SharedPanel SidebarController::CreatePanel ( const OUString& rsPanelId, ::Window* pParentWindow, - const bool bIsInitiallyExpanded) + const bool bIsInitiallyExpanded, + const Context& rContext) { const PanelDescriptor* pPanelDescriptor = ResourceManager::Instance().GetPanelDescriptor(rsPanelId); if (pPanelDescriptor == NULL) @@ -659,7 +661,8 @@ SharedPanel SidebarController::CreatePanel ( Reference<ui::XUIElement> xUIElement (CreateUIElement( pPanel->GetComponentInterface(), pPanelDescriptor->msImplementationURL, - pPanelDescriptor->mbWantsCanvas)); + pPanelDescriptor->mbWantsCanvas, + rContext)); if (xUIElement.is()) { // Initialize the panel and add it to the active deck. @@ -679,7 +682,8 @@ SharedPanel SidebarController::CreatePanel ( Reference<ui::XUIElement> SidebarController::CreateUIElement ( const Reference<awt::XWindowPeer>& rxWindow, const ::rtl::OUString& rsImplementationURL, - const bool bWantsCanvas) + const bool bWantsCanvas, + const Context& rContext) { try { @@ -702,6 +706,8 @@ Reference<ui::XUIElement> SidebarController::CreateUIElement ( Reference<rendering::XSpriteCanvas> xCanvas (VCLUnoHelper::GetWindow(rxWindow)->GetSpriteCanvas()); aCreationArguments.put("Canvas", makeAny(xCanvas)); } + aCreationArguments.put("ApplicationName", makeAny(rContext.msApplication)); + aCreationArguments.put("ContextName", makeAny(rContext.msContext)); Reference<ui::XUIElement> xUIElement( xUIElementFactory->createUIElement( diff --git a/sfx2/source/sidebar/SidebarController.hxx b/sfx2/source/sidebar/SidebarController.hxx index 5a4923f16eb4..df288bf9ac88 100644 --- a/sfx2/source/sidebar/SidebarController.hxx +++ b/sfx2/source/sidebar/SidebarController.hxx @@ -165,11 +165,13 @@ private: cssu::Reference<css::ui::XUIElement> CreateUIElement ( const cssu::Reference<css::awt::XWindowPeer>& rxWindow, const ::rtl::OUString& rsImplementationURL, - const bool bWantsCanvas); + const bool bWantsCanvas, + const Context& rContext); SharedPanel CreatePanel ( const ::rtl::OUString& rsPanelId, ::Window* pParentWindow, - const bool bIsInitiallyExpanded); + const bool bIsInitiallyExpanded, + const Context& rContext); void SwitchToDeck ( const DeckDescriptor& rDeckDescriptor, const Context& rContext); diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx index bf07a30e93b6..ea4f910b9ec2 100644 --- a/sfx2/source/sidebar/SidebarToolBox.cxx +++ b/sfx2/source/sidebar/SidebarToolBox.cxx @@ -15,16 +15,22 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "SidebarToolBox.hxx" + +#include "sfx2/sidebar/SidebarToolBox.hxx" #include "ToolBoxBackground.hxx" +#include "sfx2/sidebar/ControllerFactory.hxx" #include "sfx2/sidebar/Theme.hxx" #include "sfx2/sidebar/Tools.hxx" #include <vcl/gradient.hxx> +#include <svtools/miscopt.hxx> +#include <framework/imageproducer.hxx> +#include <com/sun/star/frame/XSubToolbarController.hpp> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; +using ::rtl::OUString; namespace sfx2 { namespace sidebar { @@ -32,13 +38,32 @@ namespace sfx2 { namespace sidebar { SidebarToolBox::SidebarToolBox ( Window* pParentWindow, - const ResId& rResId) + const ResId& rResId, + const cssu::Reference<css::frame::XFrame>& rxFrame) : ToolBox(pParentWindow, rResId), mbParentIsBorder(false), maItemSeparator(Theme::GetImage(Theme::Image_ToolBoxItemSeparator)) { SetBackground(Wallpaper()); SetPaintTransparent(true); + + if (rxFrame.is()) + { + const sal_uInt16 nItemCount (GetItemCount()); + for (sal_uInt16 nItemIndex=0; nItemIndex<nItemCount; ++nItemIndex) + CreateController(GetItemId(nItemIndex), rxFrame); + UpdateIcons(rxFrame); + + SetSizePixel(CalcWindowSizePixel()); + + SetDropdownClickHdl(LINK(this, SidebarToolBox, DropDownClickHandler)); + SetClickHdl(LINK(this, SidebarToolBox, ClickHandler)); + SetDoubleClickHdl(LINK(this, SidebarToolBox, DoubleClickHandler)); + SetSelectHdl(LINK(this, SidebarToolBox, SelectHandler)); + SetActivateHdl(LINK(this, SidebarToolBox, Activate)); + SetDeactivateHdl(LINK(this, SidebarToolBox, Deactivate)); + } + #ifdef DEBUG SetText(A2S("SidebarToolBox")); #endif @@ -49,6 +74,24 @@ SidebarToolBox::SidebarToolBox ( SidebarToolBox::~SidebarToolBox (void) { + ControllerContainer aControllers; + aControllers.swap(maControllers); + for (ControllerContainer::iterator iController(aControllers.begin()), iEnd(aControllers.end()); + iController!=iEnd; + ++iController) + { + Reference<lang::XComponent> xComponent (iController->second.mxController, UNO_QUERY); + if (xComponent.is()) + xComponent->dispose(); + } + + SetDropdownClickHdl(Link()); + SetClickHdl(Link()); + SetDoubleClickHdl(Link()); + SetSelectHdl(Link()); + SetActivateHdl(Link()); + SetDeactivateHdl(Link()); + } @@ -167,4 +210,158 @@ long SidebarToolBox::Notify (NotifyEvent& rEvent) } + + +void SidebarToolBox::CreateController ( + const sal_uInt16 nItemId, + const cssu::Reference<css::frame::XFrame>& rxFrame) +{ + ItemDescriptor aDescriptor; + + const OUString sCommandName (GetItemCommand(nItemId)); + + aDescriptor.mxController = sfx2::sidebar::ControllerFactory::CreateToolBoxController( + this, + nItemId, + sCommandName, + rxFrame); + aDescriptor.maURL = sfx2::sidebar::Tools::GetURL(sCommandName); + aDescriptor.msCurrentCommand = sCommandName; + aDescriptor.mxDispatch = sfx2::sidebar::Tools::GetDispatch(rxFrame, aDescriptor.maURL); + + if (aDescriptor.mxController.is() && aDescriptor.mxDispatch.is()) + maControllers.insert(::std::make_pair(nItemId, aDescriptor)); +} + + + + +Reference<frame::XToolbarController> SidebarToolBox::GetControllerForItemId (const sal_uInt16 nItemId) const +{ + ControllerContainer::const_iterator iController (maControllers.find(nItemId)); + if (iController != maControllers.end()) + return iController->second.mxController; + else + return NULL; +} + + + + +void SidebarToolBox::UpdateIcons (const Reference<frame::XFrame>& rxFrame) +{ + const sal_Bool bBigImages (SvtMiscOptions().AreCurrentSymbolsLarge()); + const bool bIsHighContrastActive (sfx2::sidebar::Theme::IsHighContrastMode()); + + for (ControllerContainer::iterator iController(maControllers.begin()), iEnd(maControllers.end()); + iController!=iEnd; + ++iController) + { + const ::rtl::OUString sCommandURL (iController->second.msCurrentCommand); + Image aImage (framework::GetImageFromURL(rxFrame, sCommandURL, bBigImages, bIsHighContrastActive)); + SetItemImage(iController->first, aImage); + } +} + + + + +sal_uInt16 SidebarToolBox::GetItemIdForSubToolbarName (const OUString& rsSubToolbarName) const +{ + for (ControllerContainer::const_iterator iController(maControllers.begin()), iEnd(maControllers.end()); + iController!=iEnd; + ++iController) + { + Reference<frame::XToolbarController> xController (iController->second.mxController); + Reference<frame::XSubToolbarController> xSubToolbarController (xController, UNO_QUERY); + if (xSubToolbarController.is()) + { + const OUString sName (xSubToolbarController->getSubToolbarName()); + if (sName.equals(rsSubToolbarName)) + return iController->first; + } + } + return 0; +} + + + +IMPL_LINK(SidebarToolBox, DropDownClickHandler, ToolBox*, pToolBox) +{ + if (pToolBox != NULL) + { + Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); + if (xController.is()) + { + Reference<awt::XWindow> xWindow = xController->createPopupWindow(); + if (xWindow.is() ) + xWindow->setFocus(); + } + } + return 1; +} + + + + +IMPL_LINK(SidebarToolBox, ClickHandler, ToolBox*, pToolBox) +{ + if (pToolBox == NULL) + return 0; + + Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); + if (xController.is()) + xController->click(); + + return 1; +} + + + + +IMPL_LINK(SidebarToolBox, DoubleClickHandler, ToolBox*, pToolBox) +{ + if (pToolBox == NULL) + return 0; + + Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); + if (xController.is()) + xController->doubleClick(); + + return 1; +} + + + + +IMPL_LINK(SidebarToolBox, SelectHandler, ToolBox*, pToolBox) +{ + if (pToolBox == NULL) + return 0; + + Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); + if (xController.is()) + xController->execute((sal_Int16)pToolBox->GetModifier()); + + return 1; +} + + + + +IMPL_LINK(SidebarToolBox, Activate, ToolBox*, EMPTYARG) +{ + return 1; +} + + + + +IMPL_LINK(SidebarToolBox, Deactivate, ToolBox*, EMPTYARG) +{ + return 1; +} + + + } } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/SidebarToolBox.hxx b/sfx2/source/sidebar/SidebarToolBox.hxx deleted file mode 100644 index f76de464f8b2..000000000000 --- a/sfx2/source/sidebar/SidebarToolBox.hxx +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef SFX_SIDEBAR_TOOLBOX_HXX -#define SFX_SIDEBAR_TOOLBOX_HXX - -#include "vcl/toolbox.hxx" - - -namespace sfx2 { namespace sidebar { - -class SidebarToolBox - : public ToolBox -{ -public: - SidebarToolBox (Window* pParentWindow, const ResId& rResId); - virtual ~SidebarToolBox (void); - - void SetBorderWindow (const Window* pBorderWindow); - virtual void Paint (const Rectangle& rRect); - - virtual Point GetPosPixel (void) const; - virtual void setPosSizePixel ( - long nX, - long nY, - long nWidth, - long nHeight, - sal_uInt16 nFlags); - virtual long Notify (NotifyEvent& rEvent); - -private: - bool mbParentIsBorder; - Image maItemSeparator; -}; - - -} } // end of namespace sfx2::sidebar - -#endif diff --git a/sfx2/source/sidebar/ToolBoxBackground.cxx b/sfx2/source/sidebar/ToolBoxBackground.cxx index 42aebbe773d8..d98f709f1f77 100644 --- a/sfx2/source/sidebar/ToolBoxBackground.cxx +++ b/sfx2/source/sidebar/ToolBoxBackground.cxx @@ -132,10 +132,6 @@ IMPL_LINK(ToolBoxBackground, WindowEventHandler, VclWindowEvent*, pEvent) Hide(); break; - case SFX_HINT_DYING: - doLazyDelete(); - break; - default: break; } |