From a9626f143a1466591764b03baa2d15905487b692 Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Tue, 14 May 2013 15:21:57 +0000 Subject: 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 --- include/sfx2/sidebar/ControlFactory.hxx | 19 +- include/sfx2/sidebar/ControllerFactory.hxx | 47 ++++ include/sfx2/sidebar/EnumContext.hxx | 3 + include/sfx2/sidebar/SidebarToolBox.hxx | 101 +++++++ sfx2/Library_sfx.mk | 1 + sfx2/source/sidebar/ControlFactory.cxx | 22 +- sfx2/source/sidebar/ControllerFactory.cxx | 104 ++++++++ sfx2/source/sidebar/EnumContext.cxx | 50 ++-- sfx2/source/sidebar/SidebarController.cxx | 14 +- sfx2/source/sidebar/SidebarController.hxx | 6 +- sfx2/source/sidebar/SidebarToolBox.cxx | 201 +++++++++++++- sfx2/source/sidebar/SidebarToolBox.hxx | 53 ---- sfx2/source/sidebar/ToolBoxBackground.cxx | 4 - svx/source/sidebar/PanelFactory.cxx | 5 +- svx/source/sidebar/insert/InsertPropertyPanel.cxx | 309 ++-------------------- svx/source/sidebar/insert/InsertPropertyPanel.hxx | 32 --- svx/source/sidebar/text/TextPropertyPanel.cxx | 190 ++----------- svx/source/sidebar/text/TextPropertyPanel.hrc | 4 +- svx/source/sidebar/text/TextPropertyPanel.hxx | 24 +- svx/source/sidebar/text/TextPropertyPanel.src | 21 +- 20 files changed, 607 insertions(+), 603 deletions(-) create mode 100644 include/sfx2/sidebar/ControllerFactory.hxx create mode 100644 include/sfx2/sidebar/SidebarToolBox.hxx create mode 100644 sfx2/source/sidebar/ControllerFactory.cxx delete mode 100644 sfx2/source/sidebar/SidebarToolBox.hxx diff --git a/include/sfx2/sidebar/ControlFactory.hxx b/include/sfx2/sidebar/ControlFactory.hxx index 594c36c5fd91..3b286e927975 100644 --- a/include/sfx2/sidebar/ControlFactory.hxx +++ b/include/sfx2/sidebar/ControlFactory.hxx @@ -19,21 +19,34 @@ #define SFX_SIDEBAR_CONTROL_FACTORY_HXX #include +#include #include - +#include class ToolBox; namespace sfx2 { namespace sidebar { class ToolBoxBackground; - class SFX2_DLLPUBLIC ControlFactory { public: static CheckBox* CreateMenuButton (Window* pParentWindow); static ImageRadioButton* CreateTabItem (Window* pParentWindow); - static ToolBox* CreateToolBox (Window* pParentWindow, const ResId& rResId); + + /** Create a tool box that does *not* handle its items. + */ + static SidebarToolBox* CreateToolBox ( + Window* pParentWindow, + const ResId& rResId); + + /** Create a tool box that *does* handle its items. + */ + static SidebarToolBox* CreateToolBox ( + Window* pParentWindow, + const ResId& rResId, + const ::com::sun::star::uno::Reference& rxFrame); + static Window* CreateToolBoxBackground (Window* pParentWindow); static ImageRadioButton* CreateCustomImageRadionButton( Window* pParentWindow, diff --git a/include/sfx2/sidebar/ControllerFactory.hxx b/include/sfx2/sidebar/ControllerFactory.hxx new file mode 100644 index 000000000000..030b050adfb9 --- /dev/null +++ b/include/sfx2/sidebar/ControllerFactory.hxx @@ -0,0 +1,47 @@ +/* + * 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_CONTROLLER_FACTORY_HXX +#define SFX_SIDEBAR_CONTROLLER_FACTORY_HXX + +#include "sfx2/dllapi.h" +#include +#include + +namespace css = ::com::sun::star; +namespace cssu = ::com::sun::star::uno; + +class ToolBox; + +namespace sfx2 { namespace sidebar { + +/** Convenience class for easy creation of toolbox controllers. +*/ +class SFX2_DLLPUBLIC ControllerFactory +{ +public: + static cssu::Reference CreateToolBoxController( + ToolBox* pToolBox, + const sal_uInt16 nItemId, + const ::rtl::OUString& rsCommandName, + const cssu::Reference& rxFrame); +}; + + +} } // end of namespace sfx2::sidebar + +#endif diff --git a/include/sfx2/sidebar/EnumContext.hxx b/include/sfx2/sidebar/EnumContext.hxx index b11f3bfa7d28..f45ecd9b27d8 100644 --- a/include/sfx2/sidebar/EnumContext.hxx +++ b/include/sfx2/sidebar/EnumContext.hxx @@ -125,6 +125,9 @@ public: sal_Int32 GetCombinedContext_DI(void) const; const ::rtl::OUString& GetApplicationName (void) const; + Application GetApplication (void) const; + Application GetApplication_DI (void) const; + const ::rtl::OUString& GetContextName (void) const; bool operator == (const EnumContext aOther); diff --git a/include/sfx2/sidebar/SidebarToolBox.hxx b/include/sfx2/sidebar/SidebarToolBox.hxx new file mode 100644 index 000000000000..37717ad1b3b4 --- /dev/null +++ b/include/sfx2/sidebar/SidebarToolBox.hxx @@ -0,0 +1,101 @@ +/* + * 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 "sfx2/dllapi.h" +#include "vcl/toolbox.hxx" +#include +#include +#include +#include +#include + +namespace css = ::com::sun::star; +namespace cssu = ::com::sun::star::uno; + +namespace sfx2 { namespace sidebar { + +/** The sidebar tool box has two responsibilities: + 1. Coordinated location, size, and other states with its parent + background window. + 2. Create and handle tool bar controller for its items. +*/ +class SFX2_DLLPUBLIC SidebarToolBox + : public ToolBox +{ +public: + /** Create a new tool box. + When a valid XFrame is given then the tool box will handle its + buttons and drop-downs. Otherwise the caller has to do that. + */ + SidebarToolBox ( + Window* pParentWindow, + const ResId& rResId, + const cssu::Reference& rxFrame); + 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); + + cssu::Reference GetControllerForItemId ( + const sal_uInt16 nItemId) const; + sal_uInt16 GetItemIdForSubToolbarName ( + const ::rtl::OUString& rsCOmmandName) const; + +private: + bool mbParentIsBorder; + Image maItemSeparator; + class ItemDescriptor + { + public: + cssu::Reference mxController; + css::util::URL maURL; + rtl::OUString msCurrentCommand; + cssu::Reference mxDispatch; + }; + typedef ::std::map ControllerContainer; + ControllerContainer maControllers; + + DECL_LINK(DropDownClickHandler, ToolBox*); + DECL_LINK(ClickHandler, ToolBox*); + DECL_LINK(DoubleClickHandler, ToolBox*); + DECL_LINK(SelectHandler, ToolBox*); + DECL_LINK(Activate, ToolBox*); + DECL_LINK(Deactivate, ToolBox*); + + void CreateController ( + const sal_uInt16 nItemId, + const cssu::Reference& rxFrame); + void UpdateIcons ( + const cssu::Reference& rxFrame); +}; + + +} } // end of namespace sfx2::sidebar + +#endif 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 @@ -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& 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 +#include + +#include +#include +#include + + +using namespace css; +using namespace cssu; +using ::rtl::OUString; + + +namespace sfx2 { namespace sidebar { + +Reference ControllerFactory::CreateToolBoxController( + ToolBox* pToolBox, + const sal_uInt16 nItemId, + const OUString& rsCommandName, + const Reference& rxFrame) +{ + // Create a controller for the new item. + Reference xController( + static_cast(::framework::CreateToolBoxController( + rxFrame, + pToolBox, + nItemId, + rsCommandName)), + UNO_QUERY); + if ( ! xController.is()) + xController.set( + static_cast(new svt::GenericToolboxController( + ::comphelper::getProcessServiceFactory(), + rxFrame, + pToolBox, + nItemId, + rsCommandName)), + UNO_QUERY); + + // Initialize the controller with eg a service factory. + Reference xInitialization (xController, UNO_QUERY); + if (xInitialization.is()) + { + beans::PropertyValue aPropValue; + std::vector 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 aArgs (comphelper::containerToSequence(aPropertyVector)); + xInitialization->initialize(aArgs); + } + + Reference 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 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 SidebarController::CreateUIElement ( const Reference& rxWindow, const ::rtl::OUString& rsImplementationURL, - const bool bWantsCanvas) + const bool bWantsCanvas, + const Context& rContext) { try { @@ -702,6 +706,8 @@ Reference SidebarController::CreateUIElement ( Reference xCanvas (VCLUnoHelper::GetWindow(rxWindow)->GetSpriteCanvas()); aCreationArguments.put("Canvas", makeAny(xCanvas)); } + aCreationArguments.put("ApplicationName", makeAny(rContext.msApplication)); + aCreationArguments.put("ContextName", makeAny(rContext.msContext)); Reference 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 CreateUIElement ( const cssu::Reference& 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 +#include +#include +#include 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& 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 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& 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 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& 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 xController (iController->second.mxController); + Reference 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 xController (GetControllerForItemId(pToolBox->GetCurItemId())); + if (xController.is()) + { + Reference xWindow = xController->createPopupWindow(); + if (xWindow.is() ) + xWindow->setFocus(); + } + } + return 1; +} + + + + +IMPL_LINK(SidebarToolBox, ClickHandler, ToolBox*, pToolBox) +{ + if (pToolBox == NULL) + return 0; + + Reference xController (GetControllerForItemId(pToolBox->GetCurItemId())); + if (xController.is()) + xController->click(); + + return 1; +} + + + + +IMPL_LINK(SidebarToolBox, DoubleClickHandler, ToolBox*, pToolBox) +{ + if (pToolBox == NULL) + return 0; + + Reference xController (GetControllerForItemId(pToolBox->GetCurItemId())); + if (xController.is()) + xController->doubleClick(); + + return 1; +} + + + + +IMPL_LINK(SidebarToolBox, SelectHandler, ToolBox*, pToolBox) +{ + if (pToolBox == NULL) + return 0; + + Reference 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; } diff --git a/svx/source/sidebar/PanelFactory.cxx b/svx/source/sidebar/PanelFactory.cxx index 7b75844cc16e..4ac410df6e8d 100644 --- a/svx/source/sidebar/PanelFactory.cxx +++ b/svx/source/sidebar/PanelFactory.cxx @@ -114,6 +114,9 @@ Reference SAL_CALL PanelFactory::createUIElement ( Reference xSidebar (aArguments.getOrDefault("Sidebar", Reference())); const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0))); SfxBindings* pBindings = reinterpret_cast(nBindingsValue); + ::sfx2::sidebar::EnumContext aContext ( + aArguments.getOrDefault("ApplicationName", OUString()), + aArguments.getOrDefault("ContextName", OUString())); ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow); if ( ! xParentWindow.is() || pParentWindow==NULL) @@ -135,7 +138,7 @@ Reference SAL_CALL PanelFactory::createUIElement ( #define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s)) if (DoesResourceEndWith("/TextPropertyPanel")) { - pControl = TextPropertyPanel::Create(pParentWindow, xFrame, pBindings); + pControl = TextPropertyPanel::Create(pParentWindow, xFrame, pBindings, aContext); } else if (DoesResourceEndWith("/ParaPropertyPanel")) { diff --git a/svx/source/sidebar/insert/InsertPropertyPanel.cxx b/svx/source/sidebar/insert/InsertPropertyPanel.cxx index 1207ebb378a1..cbaca0266bec 100644 --- a/svx/source/sidebar/insert/InsertPropertyPanel.cxx +++ b/svx/source/sidebar/insert/InsertPropertyPanel.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,7 @@ using namespace css; using namespace cssu; using ::rtl::OUString; +using ::sfx2::sidebar::SidebarToolBox; namespace svx { namespace sidebar { @@ -51,20 +53,17 @@ InsertPropertyPanel::InsertPropertyPanel ( mpStandardShapesBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)), mpStandardShapesToolBox(sfx2::sidebar::ControlFactory::CreateToolBox( mpStandardShapesBackground.get(), - SVX_RES(TB_INSERT_STANDARD))), + SVX_RES(TB_INSERT_STANDARD), + rxFrame)), mpCustomShapesBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)), mpCustomShapesToolBox(sfx2::sidebar::ControlFactory::CreateToolBox( mpCustomShapesBackground.get(), - SVX_RES(TB_INSERT_CUSTOM))), - maControllers(), + SVX_RES(TB_INSERT_CUSTOM), + rxFrame)), mxFrame(rxFrame) { - SetupToolBox(*mpStandardShapesToolBox); - SetupToolBox(*mpCustomShapesToolBox); FreeResource(); - UpdateIcons(); - mpStandardShapesToolBox->Show(); mpCustomShapesToolBox->Show(); @@ -80,17 +79,6 @@ InsertPropertyPanel::InsertPropertyPanel ( InsertPropertyPanel::~InsertPropertyPanel (void) { - ControllerContainer aControllers; - aControllers.swap(maControllers); - for (ControllerContainer::iterator iController(aControllers.begin()), iEnd(aControllers.end()); - iController!=iEnd; - ++iController) - { - Reference xComponent (iController->second.mxController, UNO_QUERY); - if (xComponent.is()) - xComponent->dispose(); - } - // Remove window child listener. Window* pTopWindow = this; while (pTopWindow->GetParent() != NULL) @@ -106,88 +94,6 @@ InsertPropertyPanel::~InsertPropertyPanel (void) -void InsertPropertyPanel::SetupToolBox (ToolBox& rToolBox) -{ - const sal_uInt16 nItemCount (rToolBox.GetItemCount()); - for (sal_uInt16 nItemIndex=0; nItemIndex xController (GetControllerForItemId(pToolBox->GetCurItemId())); - if (xController.is()) - { - Reference xWindow = xController->createPopupWindow(); - if (xWindow.is() ) - xWindow->setFocus(); - } - } - return 1; -} - - - - -IMPL_LINK(InsertPropertyPanel, ClickHandler, ToolBox*, pToolBox) -{ - if (pToolBox == NULL) - return 0; - - Reference xController (GetControllerForItemId(pToolBox->GetCurItemId())); - if (xController.is()) - xController->click(); - - return 1; -} - - - - -IMPL_LINK(InsertPropertyPanel, DoubleClickHandler, ToolBox*, pToolBox) -{ - if (pToolBox == NULL) - return 0; - - Reference xController (GetControllerForItemId(pToolBox->GetCurItemId())); - if (xController.is()) - xController->doubleClick(); - - return 1; -} - - - - -IMPL_LINK(InsertPropertyPanel, SelectHandler, ToolBox*, pToolBox) -{ - if (pToolBox == NULL) - return 0; - - Reference xController (GetControllerForItemId(pToolBox->GetCurItemId())); - if (xController.is()) - xController->execute((sal_Int16)pToolBox->GetModifier()); - - return 1; -} - - - - IMPL_LINK(InsertPropertyPanel, WindowEventListener, VclSimpleEvent*, pEvent) { // We will be getting a lot of window events (well, basically all @@ -200,7 +106,8 @@ IMPL_LINK(InsertPropertyPanel, WindowEventListener, VclSimpleEvent*, pEvent) if (pEvent->GetId() != VCLEVENT_TOOLBOX_SELECT) return 1; - ToolBox* pToolBox = dynamic_cast(dynamic_cast(pEvent)->GetWindow()); + Window* pWindow = dynamic_cast(pEvent)->GetWindow(); + ToolBox* pToolBox = dynamic_cast(pWindow); if (pToolBox == NULL) return 1; @@ -217,199 +124,29 @@ IMPL_LINK(InsertPropertyPanel, WindowEventListener, VclSimpleEvent*, pEvent) if (nId == 0) return 1; - // Get toolbar controller. - const sal_uInt16 nItemId (GetItemIdForSubToolbarName(aURL.Path)); - Reference xController (GetControllerForItemId(nItemId), UNO_QUERY); + SidebarToolBox* pSidebarToolBox = dynamic_cast(mpStandardShapesToolBox.get()); + if (pSidebarToolBox == NULL) + return 1; + sal_uInt16 nItemId (pSidebarToolBox->GetItemIdForSubToolbarName(aURL.Path)); + if (nItemId == 0) + { + pSidebarToolBox = dynamic_cast(mpCustomShapesToolBox.get()); + if (pSidebarToolBox == NULL) + return 1; + nItemId = pSidebarToolBox->GetItemIdForSubToolbarName(aURL.Path); + if (nItemId == 0) + return 1; + } + + Reference xController (pSidebarToolBox->GetControllerForItemId(nItemId), UNO_QUERY); if ( ! xController.is()) return 1; const OUString sCommand (pToolBox->GetItemCommand(nId)); - ControllerContainer::iterator iController (maControllers.find(nItemId)); - if (iController != maControllers.end()) - iController->second.msCurrentCommand = sCommand; xController->functionSelected(sCommand); - const sal_Bool bBigImages (SvtMiscOptions().AreCurrentSymbolsLarge()); - Image aImage (framework::GetImageFromURL(mxFrame, sCommand, bBigImages)); - pToolBox->SetItemImage(iController->first, aImage); - - return 1; -} - - - - -IMPL_LINK(InsertPropertyPanel, ActivateToolBox, ToolBox*, EMPTYARG) -{ - return 1; -} - - - - -IMPL_LINK(InsertPropertyPanel, DeactivateToolBox, ToolBox*, EMPTYARG) -{ return 1; } - - -void InsertPropertyPanel::CreateController ( - const sal_uInt16 nItemId) -{ - ToolBox* pToolBox = GetToolBoxForItemId(nItemId); - if (pToolBox != NULL) - { - ItemDescriptor aDescriptor; - - const OUString sCommandName (pToolBox->GetItemCommand(nItemId)); - - // Create a controller for the new item. - aDescriptor.mxController.set( - static_cast(::framework::CreateToolBoxController( - mxFrame, - pToolBox, - nItemId, - sCommandName)), - UNO_QUERY); - if ( ! aDescriptor.mxController.is()) - aDescriptor.mxController.set( - static_cast(new svt::GenericToolboxController( - ::comphelper::getProcessComponentContext(), - mxFrame, - pToolBox, - nItemId, - sCommandName)), - UNO_QUERY); - if ( ! aDescriptor.mxController.is()) - return; - - // Get dispatch object for the command. - aDescriptor.maURL = sfx2::sidebar::Tools::GetURL(sCommandName); - aDescriptor.msCurrentCommand = sCommandName; - aDescriptor.mxDispatch = sfx2::sidebar::Tools::GetDispatch(mxFrame, aDescriptor.maURL); - if ( ! aDescriptor.mxDispatch.is()) - return; - - // Initialize the controller with eg a service factory. - Reference xInitialization (aDescriptor.mxController, UNO_QUERY); - if (xInitialization.is()) - { - beans::PropertyValue aPropValue; - std::vector aPropertyVector; - - aPropValue.Name = A2S("Frame"); - aPropValue.Value <<= mxFrame; - aPropertyVector.push_back(makeAny(aPropValue)); - - aPropValue.Name = A2S("ServiceManager"); - aPropValue.Value <<= ::comphelper::getProcessServiceFactory(); - aPropertyVector.push_back(makeAny(aPropValue)); - - aPropValue.Name = A2S("CommandURL"); - aPropValue.Value <<= sCommandName; - aPropertyVector.push_back(makeAny(aPropValue)); - - Sequence aArgs (comphelper::containerToSequence(aPropertyVector)); - xInitialization->initialize(aArgs); - } - - Reference xUpdatable (aDescriptor.mxController, UNO_QUERY); - if (xUpdatable.is()) - xUpdatable->update(); - - // Add label. - const OUString sLabel (sfx2::sidebar::CommandInfoProvider::Instance().GetLabelForCommand( - sCommandName, - mxFrame)); - pToolBox->SetQuickHelpText(nItemId, sLabel); - - // Add item to toolbox. - pToolBox->EnableItem(nItemId); - maControllers.insert(::std::make_pair(nItemId, aDescriptor)); - } -} - - - - -ToolBox* InsertPropertyPanel::GetToolBoxForItemId (const sal_uInt16 nItemId) const -{ - switch(nItemId) - { - case TBI_STANDARD_LINE: - case TBI_STANDARD_ARROW: - case TBI_STANDARD_RECTANGLE: - case TBI_STANDARD_ELLIPSE: - case TBI_STANDARD_TEXT: - case TBI_STANDARD_LINES: - case TBI_STANDARD_CONNECTORS: - case TBI_STANDARD_ARROWS: - return mpStandardShapesToolBox.get(); - - case TBI_CUSTOM_BASICS: - case TBI_CUSTOM_SYMBOLS: - case TBI_CUSTOM_ARROWS: - case TBI_CUSTOM_FLOWCHARTS: - case TBI_CUSTOM_CALLOUTS: - case TBI_CUSTOM_STARS: - return mpCustomShapesToolBox.get(); - - default: - return NULL; - } -} - - - - -Reference InsertPropertyPanel::GetControllerForItemId (const sal_uInt16 nItemId) const -{ - ControllerContainer::const_iterator iController (maControllers.find(nItemId)); - if (iController != maControllers.end()) - return iController->second.mxController; - else - return NULL; -} - - - - -sal_uInt16 InsertPropertyPanel::GetItemIdForSubToolbarName (const OUString& rsSubToolbarName) const -{ - for (ControllerContainer::const_iterator iController(maControllers.begin()), iEnd(maControllers.end()); - iController!=iEnd; - ++iController) - { - Reference xSubToolbarController (iController->second.mxController, UNO_QUERY); - if (xSubToolbarController.is()) - if (xSubToolbarController->getSubToolbarName().equals(rsSubToolbarName)) - return iController->first; - } - return 0; -} - - - - -void InsertPropertyPanel::UpdateIcons (void) -{ - const sal_Bool bBigImages (SvtMiscOptions().AreCurrentSymbolsLarge()); - - for (ControllerContainer::iterator iController(maControllers.begin()), iEnd(maControllers.end()); - iController!=iEnd; - ++iController) - { - const ::rtl::OUString sCommandURL (iController->second.msCurrentCommand); - Image aImage (framework::GetImageFromURL(mxFrame, sCommandURL, bBigImages)); - ToolBox* pToolBox = GetToolBoxForItemId(iController->first); - if (pToolBox != NULL) - pToolBox->SetItemImage(iController->first, aImage); - } -} - - - - } } // end of namespace svx::sidebar diff --git a/svx/source/sidebar/insert/InsertPropertyPanel.hxx b/svx/source/sidebar/insert/InsertPropertyPanel.hxx index a84bf1d96972..6f50d9308e0f 100644 --- a/svx/source/sidebar/insert/InsertPropertyPanel.hxx +++ b/svx/source/sidebar/insert/InsertPropertyPanel.hxx @@ -49,41 +49,9 @@ private: ::boost::scoped_ptr mpStandardShapesToolBox; ::boost::scoped_ptr mpCustomShapesBackground; ::boost::scoped_ptr mpCustomShapesToolBox; - class ItemDescriptor - { - public: - cssu::Reference mxController; - css::util::URL maURL; - rtl::OUString msCurrentCommand; - cssu::Reference mxDispatch; - }; - typedef ::std::map ControllerContainer; - ControllerContainer maControllers; const cssu::Reference mxFrame; - /** Add listeners to toolbox and update its size to match its - content. - */ - void SetupToolBox (ToolBox& rToolBox); - cssu::Reference GetControllerForItemId ( - const sal_uInt16 nItemId) const; - ToolBox* GetToolBoxForItemId (const sal_uInt16 nItemId) const; - sal_uInt16 GetItemIdForSubToolbarName ( - const ::rtl::OUString& rsCOmmandName) const; - - /** Create toolbox controller for one item. - */ - void CreateController ( - const sal_uInt16 nItemId); - void UpdateIcons (void); - - DECL_LINK(DropDownClickHandler, ToolBox*); - DECL_LINK(ClickHandler, ToolBox*); - DECL_LINK(DoubleClickHandler, ToolBox*); - DECL_LINK(SelectHandler, ToolBox*); DECL_LINK(WindowEventListener, VclSimpleEvent*); - DECL_LINK(ActivateToolBox, ToolBox*); - DECL_LINK(DeactivateToolBox, ToolBox*); }; diff --git a/svx/source/sidebar/text/TextPropertyPanel.cxx b/svx/source/sidebar/text/TextPropertyPanel.cxx index 3a671937ff68..53ec527ca6c4 100644 --- a/svx/source/sidebar/text/TextPropertyPanel.cxx +++ b/svx/source/sidebar/text/TextPropertyPanel.cxx @@ -39,7 +39,9 @@ #include #include #include +#include #include +#include #include "sfx2/imagemgr.hxx" #include #include @@ -86,36 +88,6 @@ namespace } } // end of anonymous namespace -PopupControl* TextPropertyPanel::CreateFontColorPopupControl (PopupContainer* pParent) -{ - const ResId aResId(SVX_RES(STR_AUTOMATICE)); - - return new ColorControl( - pParent, - mpBindings, - SVX_RES(RID_POPUPPANEL_TEXTPAGE_FONT_COLOR), - SVX_RES(VS_FONT_COLOR), - ::boost::bind(GetAutomaticColor), - ::boost::bind(&TextPropertyPanel::SetFontColor, this, _1,_2), - pParent, - &aResId); -} - -PopupControl* TextPropertyPanel::CreateBrushColorPopupControl (PopupContainer* pParent) -{ - const ResId aResId(SVX_RES(STR_AUTOMATICE)); - - return new ColorControl( - pParent, - mpBindings, - SVX_RES(RID_POPUPPANEL_TEXTPAGE_FONT_COLOR), - SVX_RES(VS_FONT_COLOR), - ::boost::bind(GetAutomaticColor), - ::boost::bind(&TextPropertyPanel::SetBrushColor, this, _1,_2), - pParent, - &aResId); -} - long TextPropertyPanel::GetSelFontSize() { long nH = 240; @@ -129,7 +101,8 @@ long TextPropertyPanel::GetSelFontSize() TextPropertyPanel* TextPropertyPanel::Create ( Window* pParent, const cssu::Reference& rxFrame, - SfxBindings* pBindings) + SfxBindings* pBindings, + const ::sfx2::sidebar::EnumContext& rContext) { if (pParent == NULL) throw lang::IllegalArgumentException(A2S("no parent Window given to TextPropertyPanel::Create"), NULL, 0); @@ -141,7 +114,8 @@ TextPropertyPanel* TextPropertyPanel::Create ( return new TextPropertyPanel( pParent, rxFrame, - pBindings); + pBindings, + rContext); } @@ -153,7 +127,8 @@ TextPropertyPanel* TextPropertyPanel::Create ( TextPropertyPanel::TextPropertyPanel ( Window* pParent, const cssu::Reference& rxFrame, - SfxBindings* pBindings) + SfxBindings* pBindings, + const ::sfx2::sidebar::EnumContext& rContext) : Control(pParent, SVX_RES(RID_SIDEBAR_TEXT_PANEL)), mpFontNameBox (new SvxSBFontNameBox(this, SVX_RES(CB_SBFONT_FONT))), maFontSizeBox (this, SVX_RES(MB_SBFONT_FONTSIZE)), @@ -180,12 +155,15 @@ TextPropertyPanel::TextPropertyPanel ( mpToolBoxFontColorBackground(ControlFactory::CreateToolBoxBackground(this)), mpToolBoxFontColor(ControlFactory::CreateToolBox( mpToolBoxFontColorBackground.get(), - SVX_RES(TB_FONTCOLOR))), + rContext.GetApplication_DI() == sfx2::sidebar::EnumContext::Application_WriterVariants + ? SVX_RES(TB_FONTCOLOR_SW) + : SVX_RES(TB_FONTCOLOR), + rxFrame)), mpToolBoxHighlightBackground(ControlFactory::CreateToolBoxBackground(this)), mpToolBoxHighlight(ControlFactory::CreateToolBox( mpToolBoxHighlightBackground.get(), - SVX_RES(TB_HIGHLIGHT))), - + SVX_RES(TB_HIGHLIGHT), + rxFrame)), mpFontColorUpdater(), mpHighlightUpdater(), @@ -196,12 +174,10 @@ TextPropertyPanel::TextPropertyPanel ( maUnderlineControl (SID_ATTR_CHAR_UNDERLINE, *pBindings, *this, A2S("Underline"), rxFrame), maStrikeControl (SID_ATTR_CHAR_STRIKEOUT, *pBindings, *this, A2S("Strikeout"), rxFrame), maShadowControl (SID_ATTR_CHAR_SHADOWED, *pBindings, *this, A2S("Shadowed"), rxFrame), - maFontColorControl (SID_ATTR_CHAR_COLOR, *pBindings, *this, A2S("Color"), rxFrame), maScriptControlSw (SID_ATTR_CHAR_ESCAPEMENT, *pBindings, *this, A2S("Escapement"), rxFrame), maSuperScriptControl(SID_SET_SUPER_SCRIPT, *pBindings, *this, A2S("SuperScript"), rxFrame), maSubScriptControl (SID_SET_SUB_SCRIPT, *pBindings, *this, A2S("SubScript"), rxFrame), maSpacingControl (SID_ATTR_CHAR_KERNING, *pBindings, *this, A2S("Spacing"), rxFrame), - maHighlightControl (SID_ATTR_BRUSH_CHAR, *pBindings, *this, A2S("CharacterBackgroundPattern"),rxFrame), maSDFontGrow (SID_GROW_FONT_SIZE, *pBindings, *this, A2S("Grow"), rxFrame), maSDFontShrink (SID_SHRINK_FONT_SIZE, *pBindings, *this, A2S("Shrink"), rxFrame), @@ -211,14 +187,12 @@ TextPropertyPanel::TextPropertyPanel ( maCharSpacePopup(this, ::boost::bind(&TextPropertyPanel::CreateCharacterSpacingControl, this, _1)), maUnderlinePopup(this, ::boost::bind(&TextPropertyPanel::CreateUnderlinePopupControl, this, _1)), - maFontColorPopup(this, ::boost::bind(&TextPropertyPanel::CreateFontColorPopupControl, this, _1)), - maBrushColorPopup(this, ::boost::bind(&TextPropertyPanel::CreateBrushColorPopupControl, this, _1)), - mxFrame(rxFrame), maContext(), mpBindings(pBindings) { Initialize(); + FreeResource(); } @@ -358,10 +332,8 @@ void TextPropertyPanel::Initialize (void) SetupToolboxItems(); InitToolBoxIncDec(); InitToolBoxFont(); - InitToolBoxFontColor(); InitToolBoxScript(); InitToolBoxSpacing(); - InitToolBoxHighlight(); #ifdef HAS_IA2 mpFontNameBox->SetAccRelationLabeledBy(&mpFontNameBox); @@ -386,27 +358,13 @@ void TextPropertyPanel::Initialize (void) mbPostureAvailable = true; mbWeightAvailable = true; meUnderline = UNDERLINE_NONE; - meUnderlineColor = COL_AUTO; // - maColor = COL_BLACK; - mbColorAvailable = true; - maBackColor = COL_AUTO; - mbBackColorAvailable = true; + meUnderlineColor = COL_AUTO; meEscape = SVX_ESCAPEMENT_OFF; mbSuper = false; mbSub = false; mbKernAvailable = true; mbKernLBAvailable = true; mlKerning = 0; - mpFontColorUpdater.reset(new ToolboxButtonColorUpdater( - SID_ATTR_CHAR_COLOR, - TBI_FONTCOLOR, - mpToolBoxFontColor.get(), - TBX_UPDATER_MODE_CHAR_COLOR_NEW)); - mpHighlightUpdater.reset(new ToolboxButtonColorUpdater( - SID_ATTR_BRUSH_CHAR, - TBI_HIGHLIGHT, - mpToolBoxHighlight.get(), - TBX_UPDATER_MODE_CHAR_COLOR_NEW)); //set handler mpFontNameBox->SetBindings(mpBindings); @@ -460,17 +418,6 @@ void TextPropertyPanel::InitToolBoxIncDec() -void TextPropertyPanel::InitToolBoxFontColor() -{ - Size aTbxSize( mpToolBoxFontColor->CalcWindowSizePixel() ); - mpToolBoxFontColor->SetOutputSizePixel( aTbxSize ); - mpToolBoxFontColor->SetItemBits( TBI_FONTCOLOR, mpToolBoxFontColor->GetItemBits( TBI_FONTCOLOR ) | TIB_DROPDOWNONLY ); - - Link aLink = LINK(this, TextPropertyPanel, ToolBoxFontColorDropHdl); - mpToolBoxFontColor->SetDropdownClickHdl ( aLink ); - mpToolBoxFontColor->SetSelectHdl ( aLink ); - -} void TextPropertyPanel::InitToolBoxScript() { Size aTbxSize( mpToolBoxScriptSw->CalcWindowSizePixel() ); @@ -495,16 +442,6 @@ void TextPropertyPanel::InitToolBoxSpacing() mpToolBoxSpacing->SetDropdownClickHdl ( aLink ); mpToolBoxSpacing->SetSelectHdl( aLink ); } -void TextPropertyPanel::InitToolBoxHighlight() -{ - Size aTbxSize( mpToolBoxHighlight->CalcWindowSizePixel() ); - mpToolBoxHighlight->SetOutputSizePixel( aTbxSize ); - mpToolBoxHighlight->SetItemBits( TBI_HIGHLIGHT, mpToolBoxHighlight->GetItemBits( TBI_HIGHLIGHT ) | TIB_DROPDOWNONLY ); - - Link aLink = LINK(this, TextPropertyPanel, ToolBoxHighlightDropHdl); - mpToolBoxHighlight->SetDropdownClickHdl ( aLink ); - mpToolBoxHighlight->SetSelectHdl( aLink ); -} @@ -520,7 +457,6 @@ void TextPropertyPanel::SetupToolboxItems (void) maStrikeControl.SetupToolBoxItem(*mpToolBoxFont, TBI_STRIKEOUT); maShadowControl.SetupToolBoxItem(*mpToolBoxFont, TBI_SHADOWED); - maFontColorControl.SetupToolBoxItem(*mpToolBoxFontColor, TBI_FONTCOLOR); //for sw maSuperScriptControl.SetupToolBoxItem(*mpToolBoxScriptSw, TBI_SUPER_SW); maSubScriptControl.SetupToolBoxItem(*mpToolBoxScriptSw, TBI_SUB_SW); @@ -528,7 +464,6 @@ void TextPropertyPanel::SetupToolboxItems (void) maSuperScriptControl.SetupToolBoxItem(*mpToolBoxScript, TBI_SUPER); maSubScriptControl.SetupToolBoxItem(*mpToolBoxScript, TBI_SUB); maSpacingControl.SetupToolBoxItem(*mpToolBoxSpacing, TBI_SPACING); - maHighlightControl.SetupToolBoxItem(*mpToolBoxHighlight, TBI_HIGHLIGHT); } @@ -792,22 +727,6 @@ IMPL_LINK(TextPropertyPanel, ToolBoxUnderlineClickHdl, ToolBox*, pToolBox) -IMPL_LINK(TextPropertyPanel, ToolBoxFontColorDropHdl,ToolBox*, pToolBox) -{ - const sal_uInt16 nId = pToolBox->GetCurItemId(); - if(nId == TBI_FONTCOLOR) - { - pToolBox->SetItemDown( nId, true ); - - maFontColorPopup.Show(*pToolBox); - maFontColorPopup.SetCurrentColor(maColor, mbColorAvailable); - } - return 0; -} - - - - IMPL_LINK(TextPropertyPanel, ToolBoxSwScriptSelectHdl, ToolBox*, pToolBox) { const sal_uInt16 nId = pToolBox->GetCurItemId(); @@ -873,21 +792,6 @@ IMPL_LINK(TextPropertyPanel, ToolBoxScriptSelectHdl, ToolBox*, pToolBox) -IMPL_LINK(TextPropertyPanel, ToolBoxHighlightDropHdl, ToolBox*, pToolBox) -{ - const sal_uInt16 nId = pToolBox->GetCurItemId(); - if(nId == TBI_HIGHLIGHT) - { - pToolBox->SetItemDown( nId, true ); - maBrushColorPopup.Show(*pToolBox); - maBrushColorPopup.SetCurrentColor(maBackColor, mbBackColorAvailable); - - } - return 0; -} - - - IMPL_LINK(TextPropertyPanel, SpacingClickHdl, ToolBox*, pToolBox) { const sal_uInt16 nId = pToolBox->GetCurItemId(); @@ -1081,44 +985,6 @@ void TextPropertyPanel::NotifyItemUpdate ( : STATE_NOCHECK); break; - case SID_ATTR_CHAR_COLOR: - if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxColorItem)) - { - const SvxColorItem* pItem = (const SvxColorItem*)pState; - maColor = pItem->GetValue(); - mbColorAvailable = true; - if (mpFontColorUpdater) - mpFontColorUpdater->Update(maColor); - } - else - { - mbColorAvailable = false; - maColor.SetColor(COL_AUTO); - if (mpFontColorUpdater) - mpFontColorUpdater->Update(maColor); - } - mpToolBoxFontColor->EnableItem(TBI_FONTCOLOR, bIsEnabled); - break; - - case SID_ATTR_BRUSH_CHAR: - if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxBrushItem)) - { - const SvxBrushItem* pItem = (const SvxBrushItem*)pState; - maBackColor = pItem->GetColor(); - mbBackColorAvailable = true; - if (mpHighlightUpdater) - mpHighlightUpdater->Update(maBackColor); - } - else - { - mbBackColorAvailable = false; - maBackColor.SetColor(COL_AUTO); - if (mpHighlightUpdater) - mpHighlightUpdater->Update(maBackColor); - } - mpToolBoxHighlight->EnableItem(TBI_HIGHLIGHT, bIsEnabled); - break; - case SID_ATTR_CHAR_ESCAPEMENT: { bool bIsItemEnabled (true); @@ -1292,9 +1158,6 @@ void TextPropertyPanel::UpdateItem (const sal_uInt16 nSlotId) case SID_ATTR_CHAR_SHADOWED: maShadowControl.RequestUpdate(); break; - case SID_ATTR_CHAR_COLOR: - maFontColorControl.RequestUpdate(); - break; case SID_ATTR_CHAR_ESCAPEMENT: maScriptControlSw.RequestUpdate(); break; @@ -1307,9 +1170,6 @@ void TextPropertyPanel::UpdateItem (const sal_uInt16 nSlotId) case SID_ATTR_CHAR_KERNING: maSpacingControl.RequestUpdate(); break; - case SID_ATTR_BRUSH_CHAR: - maHighlightControl.RequestUpdate(); - break; case SID_GROW_FONT_SIZE: maSDFontGrow.RequestUpdate(); break; @@ -1323,24 +1183,6 @@ void TextPropertyPanel::UpdateItem (const sal_uInt16 nSlotId) -void TextPropertyPanel::SetFontColor ( - const String& /*rsColorName*/, - const Color aColor) -{ - SvxColorItem aColorItem(aColor, SID_ATTR_CHAR_COLOR); - mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR, SFX_CALLMODE_RECORD, &aColorItem, 0L); - maColor = aColor; -} - -void TextPropertyPanel::SetBrushColor ( - const String& /*rsColorName*/, - const Color aColor) -{ - SvxBrushItem aBrushItem(aColor, SID_ATTR_BRUSH_CHAR); - mpBindings->GetDispatcher()->Execute(SID_ATTR_BRUSH_CHAR, SFX_CALLMODE_RECORD, &aBrushItem, 0L); - maBackColor = aColor; -} - Color& TextPropertyPanel::GetUnderlineColor() { return meUnderlineColor; diff --git a/svx/source/sidebar/text/TextPropertyPanel.hrc b/svx/source/sidebar/text/TextPropertyPanel.hrc index 0244ee5029e7..36fc2503a656 100644 --- a/svx/source/sidebar/text/TextPropertyPanel.hrc +++ b/svx/source/sidebar/text/TextPropertyPanel.hrc @@ -30,11 +30,11 @@ #define TB_FONT 4 #define TB_INCREASE_DECREASE 5 #define TB_FONTCOLOR 6 -#define TB_SCRIPT_SW 7 +#define TB_FONTCOLOR_SW 7 #define TB_HIGHLIGHT 8 #define TB_SPACING 9 #define TB_SCRIPT 10 - +#define TB_SCRIPT_SW 11 #define TBI_FONTCOLOR 50 #define TBI_BOLD 51 diff --git a/svx/source/sidebar/text/TextPropertyPanel.hxx b/svx/source/sidebar/text/TextPropertyPanel.hxx index e2f4dac2124c..a7cc0ddb21ce 100644 --- a/svx/source/sidebar/text/TextPropertyPanel.hxx +++ b/svx/source/sidebar/text/TextPropertyPanel.hxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -29,6 +30,7 @@ #include #include +#include #include #include "TextCharacterSpacingPopup.hxx" @@ -54,7 +56,8 @@ public: static TextPropertyPanel* Create ( Window* pParent, const cssu::Reference& rxFrame, - SfxBindings* pBindings); + SfxBindings* pBindings, + const ::sfx2::sidebar::EnumContext& rContext); virtual void DataChanged (const DataChangedEvent& rEvent); @@ -63,8 +66,6 @@ public: void SetSpacing(long nKern); void EndSpacingPopupMode (void); void EndUnderlinePopupMode (void); - void SetFontColor (const String& rsColorName,const Color aColor); - void SetBrushColor (const String& rsColorName,const Color aColor); void SetUnderline(FontUnderline eUnderline); Color& GetUnderlineColor(); void SetDefaultUnderline(FontUnderline eUnderline); @@ -109,12 +110,10 @@ private: ::sfx2::sidebar::ControllerItem maUnderlineControl; ::sfx2::sidebar::ControllerItem maStrikeControl; ::sfx2::sidebar::ControllerItem maShadowControl; - ::sfx2::sidebar::ControllerItem maFontColorControl; ::sfx2::sidebar::ControllerItem maScriptControlSw; ::sfx2::sidebar::ControllerItem maSuperScriptControl; ::sfx2::sidebar::ControllerItem maSubScriptControl; ::sfx2::sidebar::ControllerItem maSpacingControl; - ::sfx2::sidebar::ControllerItem maHighlightControl; ::sfx2::sidebar::ControllerItem maSDFontGrow; ::sfx2::sidebar::ControllerItem maSDFontShrink; @@ -126,10 +125,6 @@ private: FontStrikeout meStrike; bool mbWeightAvailable; bool mbPostureAvailable; - Color maColor; - bool mbColorAvailable; - Color maBackColor; - bool mbBackColorAvailable; SvxEscapement meEscape; //for sw bool mbSuper; bool mbSub; @@ -143,8 +138,6 @@ private: bool mbFocusOnFontSizeCtrl; TextCharacterSpacingPopup maCharSpacePopup; TextUnderlinePopup maUnderlinePopup; - ColorPopup maFontColorPopup; - ColorPopup maBrushColorPopup; cssu::Reference mxFrame; ::sfx2::sidebar::EnumContext maContext; @@ -153,26 +146,21 @@ private: TextPropertyPanel ( Window* pParent, const cssu::Reference& rxFrame, - SfxBindings* pBindings); + SfxBindings* pBindings, + const ::sfx2::sidebar::EnumContext& rContext); virtual ~TextPropertyPanel (void); PopupControl* CreateCharacterSpacingControl (PopupContainer* pParent); - PopupControl* CreateFontColorPopupControl (PopupContainer* pParent); - PopupControl* CreateBrushColorPopupControl (PopupContainer* pParent); PopupControl* CreateUnderlinePopupControl (PopupContainer* pParent); DECL_LINK(SpacingClickHdl, ToolBox*); - DECL_LINK(ToolBoxFontColorDropHdl, ToolBox *); //for new color picker - DECL_LINK(ToolBoxHighlightDropHdl, ToolBox *); DECL_LINK(ToolBoxUnderlineClickHdl, ToolBox* ); void Initialize (void); void SetupToolboxItems (void); void InitToolBoxFont(); void InitToolBoxIncDec(); - void InitToolBoxFontColor(); void InitToolBoxScript(); - void InitToolBoxHighlight(); void InitToolBoxSpacing(); DECL_LINK(FontSelHdl, FontNameBox *); diff --git a/svx/source/sidebar/text/TextPropertyPanel.src b/svx/source/sidebar/text/TextPropertyPanel.src index f4038fe65a1c..fcd10dab3e15 100644 --- a/svx/source/sidebar/text/TextPropertyPanel.src +++ b/svx/source/sidebar/text/TextPropertyPanel.src @@ -149,7 +149,6 @@ Control RID_SIDEBAR_TEXT_PANEL Pos = MAP_APPFONT (X3, THIRD_LINE_Y) ; Size = MAP_APPFONT (TOOLBOX_ITEM_DD_WIDTH ,TOOLBOX_ITEM_HEIGHT ) ; TabStop = TRUE ; - Text = "Font Color" ; ItemList = { ToolBoxItem @@ -161,6 +160,24 @@ Control RID_SIDEBAR_TEXT_PANEL }; }; }; + ToolBox TB_FONTCOLOR_SW + { + HelpID = HID_PPROPERTYPANEL_TEXT_TBX_FONT_COLOR; + SVLook = TRUE ; + Pos = MAP_APPFONT (X3, THIRD_LINE_Y) ; + Size = MAP_APPFONT (TOOLBOX_ITEM_DD_WIDTH ,TOOLBOX_ITEM_HEIGHT ) ; + TabStop = TRUE ; + ItemList = + { + ToolBoxItem + { + Identifier = TBI_FONTCOLOR ; + HelpID = HID_PPROPERTYPANEL_TEXT_TBI_FONT_COLOR; + DropDown = TRUE ; + Command = ".uno:FontColor"; + }; + }; + }; ToolBox TB_HIGHLIGHT { @@ -177,7 +194,7 @@ Control RID_SIDEBAR_TEXT_PANEL Identifier = TBI_HIGHLIGHT ; HelpID = HID_PPROPERTYPANEL_TEXT_TBI_HIGHLIGHT_COLOR; DropDown = TRUE ; - Command = ".uno:CharacterBackgroundPattern"; + Command = ".uno:BackColor"; }; }; }; -- cgit v1.2.3