10d4dbf8bSAndre Fischer /************************************************************** 20d4dbf8bSAndre Fischer * 30d4dbf8bSAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 40d4dbf8bSAndre Fischer * or more contributor license agreements. See the NOTICE file 50d4dbf8bSAndre Fischer * distributed with this work for additional information 60d4dbf8bSAndre Fischer * regarding copyright ownership. The ASF licenses this file 70d4dbf8bSAndre Fischer * to you under the Apache License, Version 2.0 (the 80d4dbf8bSAndre Fischer * "License"); you may not use this file except in compliance 90d4dbf8bSAndre Fischer * with the License. You may obtain a copy of the License at 100d4dbf8bSAndre Fischer * 110d4dbf8bSAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 120d4dbf8bSAndre Fischer * 130d4dbf8bSAndre Fischer * Unless required by applicable law or agreed to in writing, 140d4dbf8bSAndre Fischer * software distributed under the License is distributed on an 150d4dbf8bSAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 160d4dbf8bSAndre Fischer * KIND, either express or implied. See the License for the 170d4dbf8bSAndre Fischer * specific language governing permissions and limitations 180d4dbf8bSAndre Fischer * under the License. 190d4dbf8bSAndre Fischer * 200d4dbf8bSAndre Fischer *************************************************************/ 210d4dbf8bSAndre Fischer 220d4dbf8bSAndre Fischer #include "precompiled_svx.hxx" 230d4dbf8bSAndre Fischer 240d4dbf8bSAndre Fischer #include "InsertPropertyPanel.hxx" 250d4dbf8bSAndre Fischer #include "InsertPropertyPanel.hrc" 260d4dbf8bSAndre Fischer #include "sfx2/sidebar/CommandInfoProvider.hxx" 270d4dbf8bSAndre Fischer 280d4dbf8bSAndre Fischer #include <sfx2/sidebar/Theme.hxx> 290d4dbf8bSAndre Fischer #include <sfx2/sidebar/Tools.hxx> 300d4dbf8bSAndre Fischer #include <sfx2/sidebar/ControlFactory.hxx> 310d4dbf8bSAndre Fischer 320d4dbf8bSAndre Fischer #include <svx/dialmgr.hxx> 330d4dbf8bSAndre Fischer #include <svtools/miscopt.hxx> 34*1d5c86bfSAndre Fischer #include <svtools/generictoolboxcontroller.hxx> 350d4dbf8bSAndre Fischer #include <vcl/toolbox.hxx> 360d4dbf8bSAndre Fischer #include <sfx2/tbxctrl.hxx> 370d4dbf8bSAndre Fischer #include <framework/sfxhelperfunctions.hxx> 380d4dbf8bSAndre Fischer #include <framework/imageproducer.hxx> 390d4dbf8bSAndre Fischer #include <comphelper/processfactory.hxx> 400d4dbf8bSAndre Fischer #include <cppuhelper/compbase1.hxx> 410d4dbf8bSAndre Fischer #include <cppuhelper/basemutex.hxx> 420d4dbf8bSAndre Fischer 430d4dbf8bSAndre Fischer #include <com/sun/star/frame/XStatusListener.hpp> 440d4dbf8bSAndre Fischer 450d4dbf8bSAndre Fischer using namespace css; 460d4dbf8bSAndre Fischer using namespace cssu; 470d4dbf8bSAndre Fischer using ::rtl::OUString; 480d4dbf8bSAndre Fischer 490d4dbf8bSAndre Fischer namespace svx { namespace sidebar { 500d4dbf8bSAndre Fischer 510d4dbf8bSAndre Fischer 520d4dbf8bSAndre Fischer InsertPropertyPanel::InsertPropertyPanel ( 530d4dbf8bSAndre Fischer Window* pParent, 540d4dbf8bSAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame) 550d4dbf8bSAndre Fischer : Control(pParent, SVX_RES(RID_SIDEBAR_INSERT_PANEL)), 560d4dbf8bSAndre Fischer mpStandardShapesBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)), 570d4dbf8bSAndre Fischer mpStandardShapesToolBox(sfx2::sidebar::ControlFactory::CreateToolBox( 580d4dbf8bSAndre Fischer mpStandardShapesBackground.get(), 590d4dbf8bSAndre Fischer SVX_RES(TB_INSERT_STANDARD))), 600d4dbf8bSAndre Fischer mpCustomShapesBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)), 610d4dbf8bSAndre Fischer mpCustomShapesToolBox(sfx2::sidebar::ControlFactory::CreateToolBox( 620d4dbf8bSAndre Fischer mpCustomShapesBackground.get(), 630d4dbf8bSAndre Fischer SVX_RES(TB_INSERT_CUSTOM))), 640d4dbf8bSAndre Fischer maControllers(), 650d4dbf8bSAndre Fischer mxFrame(rxFrame) 660d4dbf8bSAndre Fischer { 670d4dbf8bSAndre Fischer SetupToolBox(*mpStandardShapesToolBox); 680d4dbf8bSAndre Fischer SetupToolBox(*mpCustomShapesToolBox); 690d4dbf8bSAndre Fischer FreeResource(); 700d4dbf8bSAndre Fischer 710d4dbf8bSAndre Fischer UpdateIcons(); 720d4dbf8bSAndre Fischer 730d4dbf8bSAndre Fischer mpStandardShapesToolBox->Show(); 740d4dbf8bSAndre Fischer mpCustomShapesToolBox->Show(); 750d4dbf8bSAndre Fischer 760d4dbf8bSAndre Fischer // Listen to all tool box selection events. 770d4dbf8bSAndre Fischer Window* pTopWindow = pParent; 780d4dbf8bSAndre Fischer while (pTopWindow->GetParent() != NULL) 790d4dbf8bSAndre Fischer pTopWindow = pTopWindow->GetParent(); 800d4dbf8bSAndre Fischer pTopWindow->AddChildEventListener(LINK(this, InsertPropertyPanel, WindowEventListener)); 810d4dbf8bSAndre Fischer } 820d4dbf8bSAndre Fischer 830d4dbf8bSAndre Fischer 840d4dbf8bSAndre Fischer 850d4dbf8bSAndre Fischer 860d4dbf8bSAndre Fischer InsertPropertyPanel::~InsertPropertyPanel (void) 870d4dbf8bSAndre Fischer { 880d4dbf8bSAndre Fischer ControllerContainer aControllers; 890d4dbf8bSAndre Fischer aControllers.swap(maControllers); 900d4dbf8bSAndre Fischer for (ControllerContainer::iterator iController(aControllers.begin()), iEnd(aControllers.end()); 910d4dbf8bSAndre Fischer iController!=iEnd; 920d4dbf8bSAndre Fischer ++iController) 930d4dbf8bSAndre Fischer { 940d4dbf8bSAndre Fischer Reference<lang::XComponent> xComponent (iController->second.mxController, UNO_QUERY); 950d4dbf8bSAndre Fischer if (xComponent.is()) 960d4dbf8bSAndre Fischer xComponent->dispose(); 970d4dbf8bSAndre Fischer } 980d4dbf8bSAndre Fischer 990d4dbf8bSAndre Fischer // Remove window child listener. 1000d4dbf8bSAndre Fischer Window* pTopWindow = this; 1010d4dbf8bSAndre Fischer while (pTopWindow->GetParent() != NULL) 1020d4dbf8bSAndre Fischer pTopWindow = pTopWindow->GetParent(); 1030d4dbf8bSAndre Fischer pTopWindow->RemoveChildEventListener(LINK(this, InsertPropertyPanel, WindowEventListener)); 1040d4dbf8bSAndre Fischer 1050d4dbf8bSAndre Fischer mpStandardShapesToolBox.reset(); 1060d4dbf8bSAndre Fischer mpCustomShapesToolBox.reset(); 1070d4dbf8bSAndre Fischer mpStandardShapesBackground.reset(); 1080d4dbf8bSAndre Fischer mpCustomShapesBackground.reset(); 1090d4dbf8bSAndre Fischer } 1100d4dbf8bSAndre Fischer 1110d4dbf8bSAndre Fischer 1120d4dbf8bSAndre Fischer 1130d4dbf8bSAndre Fischer 1140d4dbf8bSAndre Fischer void InsertPropertyPanel::SetupToolBox (ToolBox& rToolBox) 1150d4dbf8bSAndre Fischer { 1160d4dbf8bSAndre Fischer const sal_uInt16 nItemCount (rToolBox.GetItemCount()); 1170d4dbf8bSAndre Fischer for (sal_uInt16 nItemIndex=0; nItemIndex<nItemCount; ++nItemIndex) 1180d4dbf8bSAndre Fischer CreateController(rToolBox.GetItemId(nItemIndex)); 1190d4dbf8bSAndre Fischer 1200d4dbf8bSAndre Fischer rToolBox.SetDropdownClickHdl(LINK(this, InsertPropertyPanel, DropDownClickHandler)); 1210d4dbf8bSAndre Fischer rToolBox.SetClickHdl(LINK(this, InsertPropertyPanel, ClickHandler)); 1220d4dbf8bSAndre Fischer rToolBox.SetDoubleClickHdl(LINK(this, InsertPropertyPanel, DoubleClickHandler)); 1230d4dbf8bSAndre Fischer rToolBox.SetSelectHdl(LINK(this, InsertPropertyPanel, SelectHandler)); 1240d4dbf8bSAndre Fischer rToolBox.SetActivateHdl(LINK(this, InsertPropertyPanel, Activate)); 1250d4dbf8bSAndre Fischer rToolBox.SetDeactivateHdl(LINK(this, InsertPropertyPanel, Deactivate)); 1260d4dbf8bSAndre Fischer 1270d4dbf8bSAndre Fischer rToolBox.SetSizePixel(rToolBox.CalcWindowSizePixel()); 1280d4dbf8bSAndre Fischer } 1290d4dbf8bSAndre Fischer 1300d4dbf8bSAndre Fischer 1310d4dbf8bSAndre Fischer 1320d4dbf8bSAndre Fischer 1330d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, DropDownClickHandler, ToolBox*, pToolBox) 1340d4dbf8bSAndre Fischer { 1350d4dbf8bSAndre Fischer if (pToolBox != NULL) 1360d4dbf8bSAndre Fischer { 1370d4dbf8bSAndre Fischer Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); 1380d4dbf8bSAndre Fischer if (xController.is()) 1390d4dbf8bSAndre Fischer { 1400d4dbf8bSAndre Fischer Reference<awt::XWindow> xWindow = xController->createPopupWindow(); 1410d4dbf8bSAndre Fischer if (xWindow.is() ) 1420d4dbf8bSAndre Fischer xWindow->setFocus(); 1430d4dbf8bSAndre Fischer } 1440d4dbf8bSAndre Fischer } 1450d4dbf8bSAndre Fischer return 1; 1460d4dbf8bSAndre Fischer } 1470d4dbf8bSAndre Fischer 1480d4dbf8bSAndre Fischer 1490d4dbf8bSAndre Fischer 1500d4dbf8bSAndre Fischer 1510d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, ClickHandler, ToolBox*, pToolBox) 1520d4dbf8bSAndre Fischer { 1530d4dbf8bSAndre Fischer if (pToolBox == NULL) 1540d4dbf8bSAndre Fischer return 0; 1550d4dbf8bSAndre Fischer 1560d4dbf8bSAndre Fischer Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); 1570d4dbf8bSAndre Fischer if (xController.is()) 1580d4dbf8bSAndre Fischer xController->click(); 1590d4dbf8bSAndre Fischer 1600d4dbf8bSAndre Fischer return 1; 1610d4dbf8bSAndre Fischer } 1620d4dbf8bSAndre Fischer 1630d4dbf8bSAndre Fischer 1640d4dbf8bSAndre Fischer 1650d4dbf8bSAndre Fischer 1660d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, DoubleClickHandler, ToolBox*, pToolBox) 1670d4dbf8bSAndre Fischer { 1680d4dbf8bSAndre Fischer if (pToolBox == NULL) 1690d4dbf8bSAndre Fischer return 0; 1700d4dbf8bSAndre Fischer 1710d4dbf8bSAndre Fischer Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); 1720d4dbf8bSAndre Fischer if (xController.is()) 1730d4dbf8bSAndre Fischer xController->doubleClick(); 1740d4dbf8bSAndre Fischer 1750d4dbf8bSAndre Fischer return 1; 1760d4dbf8bSAndre Fischer } 1770d4dbf8bSAndre Fischer 1780d4dbf8bSAndre Fischer 1790d4dbf8bSAndre Fischer 1800d4dbf8bSAndre Fischer 1810d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, SelectHandler, ToolBox*, pToolBox) 1820d4dbf8bSAndre Fischer { 1830d4dbf8bSAndre Fischer if (pToolBox == NULL) 1840d4dbf8bSAndre Fischer return 0; 1850d4dbf8bSAndre Fischer 1860d4dbf8bSAndre Fischer Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); 1870d4dbf8bSAndre Fischer if (xController.is()) 1880d4dbf8bSAndre Fischer xController->execute((sal_Int16)pToolBox->GetModifier()); 1890d4dbf8bSAndre Fischer 1900d4dbf8bSAndre Fischer return 1; 1910d4dbf8bSAndre Fischer } 1920d4dbf8bSAndre Fischer 1930d4dbf8bSAndre Fischer 1940d4dbf8bSAndre Fischer 1950d4dbf8bSAndre Fischer 1960d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, WindowEventListener, VclSimpleEvent*, pEvent) 1970d4dbf8bSAndre Fischer { 1980d4dbf8bSAndre Fischer // We will be getting a lot of window events (well, basically all 1990d4dbf8bSAndre Fischer // of them), so reject early everything that is not connected to 2000d4dbf8bSAndre Fischer // toolbox selection. 2010d4dbf8bSAndre Fischer if (pEvent == NULL) 2020d4dbf8bSAndre Fischer return 1; 2030d4dbf8bSAndre Fischer if ( ! pEvent->ISA(VclWindowEvent)) 2040d4dbf8bSAndre Fischer return 1; 2050d4dbf8bSAndre Fischer if (pEvent->GetId() != VCLEVENT_TOOLBOX_SELECT) 2060d4dbf8bSAndre Fischer return 1; 2070d4dbf8bSAndre Fischer 2080d4dbf8bSAndre Fischer ToolBox* pToolBox = dynamic_cast<ToolBox*>(dynamic_cast<VclWindowEvent*>(pEvent)->GetWindow()); 2090d4dbf8bSAndre Fischer if (pToolBox == NULL) 2100d4dbf8bSAndre Fischer return 1; 2110d4dbf8bSAndre Fischer 2120d4dbf8bSAndre Fischer // Extract name of (sub)toolbar from help id. 2130d4dbf8bSAndre Fischer OUString sToolbarName (rtl::OStringToOUString(pToolBox->GetHelpId(), RTL_TEXTENCODING_UTF8)); 2140d4dbf8bSAndre Fischer if (sToolbarName.getLength() == 0) 2150d4dbf8bSAndre Fischer return 1; 2160d4dbf8bSAndre Fischer const util::URL aURL (sfx2::sidebar::Tools::GetURL(sToolbarName)); 2170d4dbf8bSAndre Fischer if (aURL.Path.getLength() == 0) 2180d4dbf8bSAndre Fischer return 1; 2190d4dbf8bSAndre Fischer 2200d4dbf8bSAndre Fischer // Get item id. 2210d4dbf8bSAndre Fischer sal_uInt16 nId = pToolBox->GetCurItemId(); 2220d4dbf8bSAndre Fischer if (nId == 0) 2230d4dbf8bSAndre Fischer return 1; 2240d4dbf8bSAndre Fischer 2250d4dbf8bSAndre Fischer // Get toolbar controller. 2260d4dbf8bSAndre Fischer const sal_uInt16 nItemId (GetItemIdForSubToolbarName(aURL.Path)); 2270d4dbf8bSAndre Fischer Reference<frame::XSubToolbarController> xController (GetControllerForItemId(nItemId), UNO_QUERY); 2280d4dbf8bSAndre Fischer if ( ! xController.is()) 2290d4dbf8bSAndre Fischer return 1; 2300d4dbf8bSAndre Fischer 2310d4dbf8bSAndre Fischer const OUString sCommand (pToolBox->GetItemCommand(nId)); 2320d4dbf8bSAndre Fischer ControllerContainer::iterator iController (maControllers.find(nItemId)); 2330d4dbf8bSAndre Fischer if (iController != maControllers.end()) 2340d4dbf8bSAndre Fischer iController->second.msCurrentCommand = sCommand; 2350d4dbf8bSAndre Fischer xController->functionSelected(sCommand); 2360d4dbf8bSAndre Fischer 2370d4dbf8bSAndre Fischer const sal_Bool bBigImages (SvtMiscOptions().AreCurrentSymbolsLarge()); 2380d4dbf8bSAndre Fischer const bool bIsHighContrastActive (sfx2::sidebar::Theme::IsHighContrastMode()); 2390d4dbf8bSAndre Fischer Image aImage (framework::GetImageFromURL(mxFrame, sCommand, bBigImages, bIsHighContrastActive)); 2400d4dbf8bSAndre Fischer pToolBox->SetItemImage(iController->first, aImage); 2410d4dbf8bSAndre Fischer 2420d4dbf8bSAndre Fischer return 1; 2430d4dbf8bSAndre Fischer } 2440d4dbf8bSAndre Fischer 2450d4dbf8bSAndre Fischer 2460d4dbf8bSAndre Fischer 2470d4dbf8bSAndre Fischer 2480d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, Activate, ToolBox*, EMPTYARG) 2490d4dbf8bSAndre Fischer { 2500d4dbf8bSAndre Fischer return 1; 2510d4dbf8bSAndre Fischer } 2520d4dbf8bSAndre Fischer 2530d4dbf8bSAndre Fischer 2540d4dbf8bSAndre Fischer 2550d4dbf8bSAndre Fischer 2560d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, Deactivate, ToolBox*, EMPTYARG) 2570d4dbf8bSAndre Fischer { 2580d4dbf8bSAndre Fischer return 1; 2590d4dbf8bSAndre Fischer } 2600d4dbf8bSAndre Fischer 2610d4dbf8bSAndre Fischer 2620d4dbf8bSAndre Fischer 2630d4dbf8bSAndre Fischer 2640d4dbf8bSAndre Fischer void InsertPropertyPanel::CreateController ( 2650d4dbf8bSAndre Fischer const sal_uInt16 nItemId) 2660d4dbf8bSAndre Fischer { 2670d4dbf8bSAndre Fischer ToolBox* pToolBox = GetToolBoxForItemId(nItemId); 2680d4dbf8bSAndre Fischer if (pToolBox != NULL) 2690d4dbf8bSAndre Fischer { 2700d4dbf8bSAndre Fischer ItemDescriptor aDescriptor; 2710d4dbf8bSAndre Fischer 2720d4dbf8bSAndre Fischer const OUString sCommandName (pToolBox->GetItemCommand(nItemId)); 2730d4dbf8bSAndre Fischer 2740d4dbf8bSAndre Fischer // Create a controller for the new item. 2750d4dbf8bSAndre Fischer aDescriptor.mxController.set( 2760d4dbf8bSAndre Fischer static_cast<XWeak*>(::framework::CreateToolBoxController( 2770d4dbf8bSAndre Fischer mxFrame, 2780d4dbf8bSAndre Fischer pToolBox, 2790d4dbf8bSAndre Fischer nItemId, 2800d4dbf8bSAndre Fischer sCommandName)), 2810d4dbf8bSAndre Fischer UNO_QUERY); 2820d4dbf8bSAndre Fischer if ( ! aDescriptor.mxController.is()) 2830d4dbf8bSAndre Fischer aDescriptor.mxController.set( 284*1d5c86bfSAndre Fischer static_cast<XWeak*>(new svt::GenericToolboxController( 285*1d5c86bfSAndre Fischer ::comphelper::getProcessServiceFactory(), 286*1d5c86bfSAndre Fischer mxFrame, 287*1d5c86bfSAndre Fischer pToolBox, 288*1d5c86bfSAndre Fischer nItemId, 289*1d5c86bfSAndre Fischer sCommandName)), 2900d4dbf8bSAndre Fischer UNO_QUERY); 2910d4dbf8bSAndre Fischer if ( ! aDescriptor.mxController.is()) 2920d4dbf8bSAndre Fischer return; 2930d4dbf8bSAndre Fischer 2940d4dbf8bSAndre Fischer // Get dispatch object for the command. 2950d4dbf8bSAndre Fischer aDescriptor.maURL = sfx2::sidebar::Tools::GetURL(sCommandName); 2960d4dbf8bSAndre Fischer aDescriptor.msCurrentCommand = sCommandName; 2970d4dbf8bSAndre Fischer aDescriptor.mxDispatch = sfx2::sidebar::Tools::GetDispatch(mxFrame, aDescriptor.maURL); 2980d4dbf8bSAndre Fischer if ( ! aDescriptor.mxDispatch.is()) 2990d4dbf8bSAndre Fischer return; 3000d4dbf8bSAndre Fischer 3010d4dbf8bSAndre Fischer // Initialize the controller with eg a service factory. 3020d4dbf8bSAndre Fischer Reference<lang::XInitialization> xInitialization (aDescriptor.mxController, UNO_QUERY); 3030d4dbf8bSAndre Fischer if (xInitialization.is()) 3040d4dbf8bSAndre Fischer { 3050d4dbf8bSAndre Fischer beans::PropertyValue aPropValue; 3060d4dbf8bSAndre Fischer std::vector<Any> aPropertyVector; 3070d4dbf8bSAndre Fischer 3080d4dbf8bSAndre Fischer aPropValue.Name = A2S("Frame"); 3090d4dbf8bSAndre Fischer aPropValue.Value <<= mxFrame; 3100d4dbf8bSAndre Fischer aPropertyVector.push_back(makeAny(aPropValue)); 3110d4dbf8bSAndre Fischer 3120d4dbf8bSAndre Fischer aPropValue.Name = A2S("ServiceManager"); 3130d4dbf8bSAndre Fischer aPropValue.Value <<= ::comphelper::getProcessServiceFactory(); 3140d4dbf8bSAndre Fischer aPropertyVector.push_back(makeAny(aPropValue)); 3150d4dbf8bSAndre Fischer 3160d4dbf8bSAndre Fischer aPropValue.Name = A2S("CommandURL"); 3170d4dbf8bSAndre Fischer aPropValue.Value <<= sCommandName; 3180d4dbf8bSAndre Fischer aPropertyVector.push_back(makeAny(aPropValue)); 3190d4dbf8bSAndre Fischer 3200d4dbf8bSAndre Fischer Sequence<Any> aArgs (comphelper::containerToSequence(aPropertyVector)); 3210d4dbf8bSAndre Fischer xInitialization->initialize(aArgs); 3220d4dbf8bSAndre Fischer } 3230d4dbf8bSAndre Fischer 3240d4dbf8bSAndre Fischer Reference<util::XUpdatable> xUpdatable (aDescriptor.mxController, UNO_QUERY); 3250d4dbf8bSAndre Fischer if (xUpdatable.is()) 3260d4dbf8bSAndre Fischer xUpdatable->update(); 3270d4dbf8bSAndre Fischer 3280d4dbf8bSAndre Fischer // Add label. 3290d4dbf8bSAndre Fischer const OUString sLabel (sfx2::sidebar::CommandInfoProvider::Instance().GetLabelForCommand( 3300d4dbf8bSAndre Fischer sCommandName, 3310d4dbf8bSAndre Fischer mxFrame)); 3320d4dbf8bSAndre Fischer pToolBox->SetQuickHelpText(nItemId, sLabel); 3330d4dbf8bSAndre Fischer 3340d4dbf8bSAndre Fischer // Add item to toolbox. 3350d4dbf8bSAndre Fischer pToolBox->EnableItem(nItemId); 3360d4dbf8bSAndre Fischer maControllers.insert(::std::make_pair(nItemId, aDescriptor)); 3370d4dbf8bSAndre Fischer } 3380d4dbf8bSAndre Fischer } 3390d4dbf8bSAndre Fischer 3400d4dbf8bSAndre Fischer 3410d4dbf8bSAndre Fischer 3420d4dbf8bSAndre Fischer 3430d4dbf8bSAndre Fischer ToolBox* InsertPropertyPanel::GetToolBoxForItemId (const sal_uInt16 nItemId) const 3440d4dbf8bSAndre Fischer { 3450d4dbf8bSAndre Fischer switch(nItemId) 3460d4dbf8bSAndre Fischer { 3470d4dbf8bSAndre Fischer case TBI_STANDARD_LINE: 3480d4dbf8bSAndre Fischer case TBI_STANDARD_ARROW: 3490d4dbf8bSAndre Fischer case TBI_STANDARD_RECTANGLE: 3500d4dbf8bSAndre Fischer case TBI_STANDARD_ELLIPSE: 3510d4dbf8bSAndre Fischer case TBI_STANDARD_TEXT: 3520d4dbf8bSAndre Fischer case TBI_STANDARD_LINES: 3530d4dbf8bSAndre Fischer case TBI_STANDARD_CONNECTORS: 3540d4dbf8bSAndre Fischer case TBI_STANDARD_ARROWS: 3550d4dbf8bSAndre Fischer return mpStandardShapesToolBox.get(); 3560d4dbf8bSAndre Fischer 3570d4dbf8bSAndre Fischer case TBI_CUSTOM_BASICS: 3580d4dbf8bSAndre Fischer case TBI_CUSTOM_SYMBOLS: 3590d4dbf8bSAndre Fischer case TBI_CUSTOM_ARROWS: 3600d4dbf8bSAndre Fischer case TBI_CUSTOM_FLOWCHARTS: 3610d4dbf8bSAndre Fischer case TBI_CUSTOM_CALLOUTS: 3620d4dbf8bSAndre Fischer case TBI_CUSTOM_STARS: 3630d4dbf8bSAndre Fischer return mpCustomShapesToolBox.get(); 3640d4dbf8bSAndre Fischer 3650d4dbf8bSAndre Fischer default: 3660d4dbf8bSAndre Fischer return NULL; 3670d4dbf8bSAndre Fischer } 3680d4dbf8bSAndre Fischer } 3690d4dbf8bSAndre Fischer 3700d4dbf8bSAndre Fischer 3710d4dbf8bSAndre Fischer 3720d4dbf8bSAndre Fischer 3730d4dbf8bSAndre Fischer Reference<frame::XToolbarController> InsertPropertyPanel::GetControllerForItemId (const sal_uInt16 nItemId) const 3740d4dbf8bSAndre Fischer { 3750d4dbf8bSAndre Fischer ControllerContainer::const_iterator iController (maControllers.find(nItemId)); 3760d4dbf8bSAndre Fischer if (iController != maControllers.end()) 3770d4dbf8bSAndre Fischer return iController->second.mxController; 3780d4dbf8bSAndre Fischer else 3790d4dbf8bSAndre Fischer return NULL; 3800d4dbf8bSAndre Fischer } 3810d4dbf8bSAndre Fischer 3820d4dbf8bSAndre Fischer 3830d4dbf8bSAndre Fischer 3840d4dbf8bSAndre Fischer 3850d4dbf8bSAndre Fischer sal_uInt16 InsertPropertyPanel::GetItemIdForSubToolbarName (const OUString& rsSubToolbarName) const 3860d4dbf8bSAndre Fischer { 3870d4dbf8bSAndre Fischer for (ControllerContainer::const_iterator iController(maControllers.begin()), iEnd(maControllers.end()); 3880d4dbf8bSAndre Fischer iController!=iEnd; 3890d4dbf8bSAndre Fischer ++iController) 3900d4dbf8bSAndre Fischer { 3910d4dbf8bSAndre Fischer Reference<frame::XSubToolbarController> xSubToolbarController (iController->second.mxController, UNO_QUERY); 3920d4dbf8bSAndre Fischer if (xSubToolbarController.is()) 3930d4dbf8bSAndre Fischer if (xSubToolbarController->getSubToolbarName().equals(rsSubToolbarName)) 3940d4dbf8bSAndre Fischer return iController->first; 3950d4dbf8bSAndre Fischer } 3960d4dbf8bSAndre Fischer return NULL; 3970d4dbf8bSAndre Fischer } 3980d4dbf8bSAndre Fischer 3990d4dbf8bSAndre Fischer 4000d4dbf8bSAndre Fischer 4010d4dbf8bSAndre Fischer 4020d4dbf8bSAndre Fischer void InsertPropertyPanel::UpdateIcons (void) 4030d4dbf8bSAndre Fischer { 4040d4dbf8bSAndre Fischer const sal_Bool bBigImages (SvtMiscOptions().AreCurrentSymbolsLarge()); 4050d4dbf8bSAndre Fischer const bool bIsHighContrastActive (sfx2::sidebar::Theme::IsHighContrastMode()); 4060d4dbf8bSAndre Fischer 4070d4dbf8bSAndre Fischer for (ControllerContainer::iterator iController(maControllers.begin()), iEnd(maControllers.end()); 4080d4dbf8bSAndre Fischer iController!=iEnd; 4090d4dbf8bSAndre Fischer ++iController) 4100d4dbf8bSAndre Fischer { 4110d4dbf8bSAndre Fischer const ::rtl::OUString sCommandURL (iController->second.msCurrentCommand); 4120d4dbf8bSAndre Fischer Image aImage (framework::GetImageFromURL(mxFrame, sCommandURL, bBigImages, bIsHighContrastActive)); 4130d4dbf8bSAndre Fischer ToolBox* pToolBox = GetToolBoxForItemId(iController->first); 4140d4dbf8bSAndre Fischer if (pToolBox != NULL) 4150d4dbf8bSAndre Fischer pToolBox->SetItemImage(iController->first, aImage); 4160d4dbf8bSAndre Fischer } 4170d4dbf8bSAndre Fischer } 4180d4dbf8bSAndre Fischer 4190d4dbf8bSAndre Fischer 4200d4dbf8bSAndre Fischer 4210d4dbf8bSAndre Fischer 4220d4dbf8bSAndre Fischer } } // end of namespace svx::sidebar 423