1*0d4dbf8bSAndre Fischer /************************************************************** 2*0d4dbf8bSAndre Fischer * 3*0d4dbf8bSAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 4*0d4dbf8bSAndre Fischer * or more contributor license agreements. See the NOTICE file 5*0d4dbf8bSAndre Fischer * distributed with this work for additional information 6*0d4dbf8bSAndre Fischer * regarding copyright ownership. The ASF licenses this file 7*0d4dbf8bSAndre Fischer * to you under the Apache License, Version 2.0 (the 8*0d4dbf8bSAndre Fischer * "License"); you may not use this file except in compliance 9*0d4dbf8bSAndre Fischer * with the License. You may obtain a copy of the License at 10*0d4dbf8bSAndre Fischer * 11*0d4dbf8bSAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 12*0d4dbf8bSAndre Fischer * 13*0d4dbf8bSAndre Fischer * Unless required by applicable law or agreed to in writing, 14*0d4dbf8bSAndre Fischer * software distributed under the License is distributed on an 15*0d4dbf8bSAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*0d4dbf8bSAndre Fischer * KIND, either express or implied. See the License for the 17*0d4dbf8bSAndre Fischer * specific language governing permissions and limitations 18*0d4dbf8bSAndre Fischer * under the License. 19*0d4dbf8bSAndre Fischer * 20*0d4dbf8bSAndre Fischer *************************************************************/ 21*0d4dbf8bSAndre Fischer 22*0d4dbf8bSAndre Fischer #include "precompiled_svx.hxx" 23*0d4dbf8bSAndre Fischer 24*0d4dbf8bSAndre Fischer #include "InsertPropertyPanel.hxx" 25*0d4dbf8bSAndre Fischer #include "InsertPropertyPanel.hrc" 26*0d4dbf8bSAndre Fischer #include "SimpleToolBoxController.hxx" 27*0d4dbf8bSAndre Fischer #include "sfx2/sidebar/CommandInfoProvider.hxx" 28*0d4dbf8bSAndre Fischer 29*0d4dbf8bSAndre Fischer #include <sfx2/sidebar/Theme.hxx> 30*0d4dbf8bSAndre Fischer #include <sfx2/sidebar/Tools.hxx> 31*0d4dbf8bSAndre Fischer #include <sfx2/sidebar/ControlFactory.hxx> 32*0d4dbf8bSAndre Fischer 33*0d4dbf8bSAndre Fischer #include <svx/dialmgr.hxx> 34*0d4dbf8bSAndre Fischer #include <svtools/miscopt.hxx> 35*0d4dbf8bSAndre Fischer #include <vcl/toolbox.hxx> 36*0d4dbf8bSAndre Fischer #include <sfx2/tbxctrl.hxx> 37*0d4dbf8bSAndre Fischer #include <framework/sfxhelperfunctions.hxx> 38*0d4dbf8bSAndre Fischer #include <framework/imageproducer.hxx> 39*0d4dbf8bSAndre Fischer #include <comphelper/processfactory.hxx> 40*0d4dbf8bSAndre Fischer #include <cppuhelper/compbase1.hxx> 41*0d4dbf8bSAndre Fischer #include <cppuhelper/basemutex.hxx> 42*0d4dbf8bSAndre Fischer 43*0d4dbf8bSAndre Fischer #include <com/sun/star/frame/XStatusListener.hpp> 44*0d4dbf8bSAndre Fischer 45*0d4dbf8bSAndre Fischer using namespace css; 46*0d4dbf8bSAndre Fischer using namespace cssu; 47*0d4dbf8bSAndre Fischer using ::rtl::OUString; 48*0d4dbf8bSAndre Fischer 49*0d4dbf8bSAndre Fischer #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 50*0d4dbf8bSAndre Fischer 51*0d4dbf8bSAndre Fischer namespace svx { namespace sidebar { 52*0d4dbf8bSAndre Fischer 53*0d4dbf8bSAndre Fischer 54*0d4dbf8bSAndre Fischer InsertPropertyPanel::InsertPropertyPanel ( 55*0d4dbf8bSAndre Fischer Window* pParent, 56*0d4dbf8bSAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame) 57*0d4dbf8bSAndre Fischer : Control(pParent, SVX_RES(RID_SIDEBAR_INSERT_PANEL)), 58*0d4dbf8bSAndre Fischer mpStandardShapesBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)), 59*0d4dbf8bSAndre Fischer mpStandardShapesToolBox(sfx2::sidebar::ControlFactory::CreateToolBox( 60*0d4dbf8bSAndre Fischer mpStandardShapesBackground.get(), 61*0d4dbf8bSAndre Fischer SVX_RES(TB_INSERT_STANDARD))), 62*0d4dbf8bSAndre Fischer mpCustomShapesBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)), 63*0d4dbf8bSAndre Fischer mpCustomShapesToolBox(sfx2::sidebar::ControlFactory::CreateToolBox( 64*0d4dbf8bSAndre Fischer mpCustomShapesBackground.get(), 65*0d4dbf8bSAndre Fischer SVX_RES(TB_INSERT_CUSTOM))), 66*0d4dbf8bSAndre Fischer maControllers(), 67*0d4dbf8bSAndre Fischer mxFrame(rxFrame) 68*0d4dbf8bSAndre Fischer { 69*0d4dbf8bSAndre Fischer SetupToolBox(*mpStandardShapesToolBox); 70*0d4dbf8bSAndre Fischer SetupToolBox(*mpCustomShapesToolBox); 71*0d4dbf8bSAndre Fischer FreeResource(); 72*0d4dbf8bSAndre Fischer 73*0d4dbf8bSAndre Fischer UpdateIcons(); 74*0d4dbf8bSAndre Fischer 75*0d4dbf8bSAndre Fischer mpStandardShapesToolBox->Show(); 76*0d4dbf8bSAndre Fischer mpCustomShapesToolBox->Show(); 77*0d4dbf8bSAndre Fischer 78*0d4dbf8bSAndre Fischer // Listen to all tool box selection events. 79*0d4dbf8bSAndre Fischer Window* pTopWindow = pParent; 80*0d4dbf8bSAndre Fischer while (pTopWindow->GetParent() != NULL) 81*0d4dbf8bSAndre Fischer pTopWindow = pTopWindow->GetParent(); 82*0d4dbf8bSAndre Fischer pTopWindow->AddChildEventListener(LINK(this, InsertPropertyPanel, WindowEventListener)); 83*0d4dbf8bSAndre Fischer } 84*0d4dbf8bSAndre Fischer 85*0d4dbf8bSAndre Fischer 86*0d4dbf8bSAndre Fischer 87*0d4dbf8bSAndre Fischer 88*0d4dbf8bSAndre Fischer InsertPropertyPanel::~InsertPropertyPanel (void) 89*0d4dbf8bSAndre Fischer { 90*0d4dbf8bSAndre Fischer ControllerContainer aControllers; 91*0d4dbf8bSAndre Fischer aControllers.swap(maControllers); 92*0d4dbf8bSAndre Fischer for (ControllerContainer::iterator iController(aControllers.begin()), iEnd(aControllers.end()); 93*0d4dbf8bSAndre Fischer iController!=iEnd; 94*0d4dbf8bSAndre Fischer ++iController) 95*0d4dbf8bSAndre Fischer { 96*0d4dbf8bSAndre Fischer Reference<lang::XComponent> xComponent (iController->second.mxController, UNO_QUERY); 97*0d4dbf8bSAndre Fischer if (xComponent.is()) 98*0d4dbf8bSAndre Fischer xComponent->dispose(); 99*0d4dbf8bSAndre Fischer } 100*0d4dbf8bSAndre Fischer 101*0d4dbf8bSAndre Fischer // Remove window child listener. 102*0d4dbf8bSAndre Fischer Window* pTopWindow = this; 103*0d4dbf8bSAndre Fischer while (pTopWindow->GetParent() != NULL) 104*0d4dbf8bSAndre Fischer pTopWindow = pTopWindow->GetParent(); 105*0d4dbf8bSAndre Fischer pTopWindow->RemoveChildEventListener(LINK(this, InsertPropertyPanel, WindowEventListener)); 106*0d4dbf8bSAndre Fischer 107*0d4dbf8bSAndre Fischer mpStandardShapesToolBox.reset(); 108*0d4dbf8bSAndre Fischer mpCustomShapesToolBox.reset(); 109*0d4dbf8bSAndre Fischer mpStandardShapesBackground.reset(); 110*0d4dbf8bSAndre Fischer mpCustomShapesBackground.reset(); 111*0d4dbf8bSAndre Fischer } 112*0d4dbf8bSAndre Fischer 113*0d4dbf8bSAndre Fischer 114*0d4dbf8bSAndre Fischer 115*0d4dbf8bSAndre Fischer 116*0d4dbf8bSAndre Fischer void InsertPropertyPanel::SetupToolBox (ToolBox& rToolBox) 117*0d4dbf8bSAndre Fischer { 118*0d4dbf8bSAndre Fischer const sal_uInt16 nItemCount (rToolBox.GetItemCount()); 119*0d4dbf8bSAndre Fischer for (sal_uInt16 nItemIndex=0; nItemIndex<nItemCount; ++nItemIndex) 120*0d4dbf8bSAndre Fischer CreateController(rToolBox.GetItemId(nItemIndex)); 121*0d4dbf8bSAndre Fischer 122*0d4dbf8bSAndre Fischer rToolBox.SetDropdownClickHdl(LINK(this, InsertPropertyPanel, DropDownClickHandler)); 123*0d4dbf8bSAndre Fischer rToolBox.SetClickHdl(LINK(this, InsertPropertyPanel, ClickHandler)); 124*0d4dbf8bSAndre Fischer rToolBox.SetDoubleClickHdl(LINK(this, InsertPropertyPanel, DoubleClickHandler)); 125*0d4dbf8bSAndre Fischer rToolBox.SetSelectHdl(LINK(this, InsertPropertyPanel, SelectHandler)); 126*0d4dbf8bSAndre Fischer rToolBox.SetActivateHdl(LINK(this, InsertPropertyPanel, Activate)); 127*0d4dbf8bSAndre Fischer rToolBox.SetDeactivateHdl(LINK(this, InsertPropertyPanel, Deactivate)); 128*0d4dbf8bSAndre Fischer 129*0d4dbf8bSAndre Fischer rToolBox.SetSizePixel(rToolBox.CalcWindowSizePixel()); 130*0d4dbf8bSAndre Fischer } 131*0d4dbf8bSAndre Fischer 132*0d4dbf8bSAndre Fischer 133*0d4dbf8bSAndre Fischer 134*0d4dbf8bSAndre Fischer 135*0d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, DropDownClickHandler, ToolBox*, pToolBox) 136*0d4dbf8bSAndre Fischer { 137*0d4dbf8bSAndre Fischer if (pToolBox != NULL) 138*0d4dbf8bSAndre Fischer { 139*0d4dbf8bSAndre Fischer Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); 140*0d4dbf8bSAndre Fischer if (xController.is()) 141*0d4dbf8bSAndre Fischer { 142*0d4dbf8bSAndre Fischer Reference<awt::XWindow> xWindow = xController->createPopupWindow(); 143*0d4dbf8bSAndre Fischer if (xWindow.is() ) 144*0d4dbf8bSAndre Fischer xWindow->setFocus(); 145*0d4dbf8bSAndre Fischer } 146*0d4dbf8bSAndre Fischer } 147*0d4dbf8bSAndre Fischer return 1; 148*0d4dbf8bSAndre Fischer } 149*0d4dbf8bSAndre Fischer 150*0d4dbf8bSAndre Fischer 151*0d4dbf8bSAndre Fischer 152*0d4dbf8bSAndre Fischer 153*0d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, ClickHandler, ToolBox*, pToolBox) 154*0d4dbf8bSAndre Fischer { 155*0d4dbf8bSAndre Fischer if (pToolBox == NULL) 156*0d4dbf8bSAndre Fischer return 0; 157*0d4dbf8bSAndre Fischer 158*0d4dbf8bSAndre Fischer Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); 159*0d4dbf8bSAndre Fischer if (xController.is()) 160*0d4dbf8bSAndre Fischer xController->click(); 161*0d4dbf8bSAndre Fischer 162*0d4dbf8bSAndre Fischer return 1; 163*0d4dbf8bSAndre Fischer } 164*0d4dbf8bSAndre Fischer 165*0d4dbf8bSAndre Fischer 166*0d4dbf8bSAndre Fischer 167*0d4dbf8bSAndre Fischer 168*0d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, DoubleClickHandler, ToolBox*, pToolBox) 169*0d4dbf8bSAndre Fischer { 170*0d4dbf8bSAndre Fischer if (pToolBox == NULL) 171*0d4dbf8bSAndre Fischer return 0; 172*0d4dbf8bSAndre Fischer 173*0d4dbf8bSAndre Fischer Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); 174*0d4dbf8bSAndre Fischer if (xController.is()) 175*0d4dbf8bSAndre Fischer xController->doubleClick(); 176*0d4dbf8bSAndre Fischer 177*0d4dbf8bSAndre Fischer return 1; 178*0d4dbf8bSAndre Fischer } 179*0d4dbf8bSAndre Fischer 180*0d4dbf8bSAndre Fischer 181*0d4dbf8bSAndre Fischer 182*0d4dbf8bSAndre Fischer 183*0d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, SelectHandler, ToolBox*, pToolBox) 184*0d4dbf8bSAndre Fischer { 185*0d4dbf8bSAndre Fischer if (pToolBox == NULL) 186*0d4dbf8bSAndre Fischer return 0; 187*0d4dbf8bSAndre Fischer 188*0d4dbf8bSAndre Fischer Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); 189*0d4dbf8bSAndre Fischer if (xController.is()) 190*0d4dbf8bSAndre Fischer xController->execute((sal_Int16)pToolBox->GetModifier()); 191*0d4dbf8bSAndre Fischer 192*0d4dbf8bSAndre Fischer return 1; 193*0d4dbf8bSAndre Fischer } 194*0d4dbf8bSAndre Fischer 195*0d4dbf8bSAndre Fischer 196*0d4dbf8bSAndre Fischer 197*0d4dbf8bSAndre Fischer 198*0d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, WindowEventListener, VclSimpleEvent*, pEvent) 199*0d4dbf8bSAndre Fischer { 200*0d4dbf8bSAndre Fischer // We will be getting a lot of window events (well, basically all 201*0d4dbf8bSAndre Fischer // of them), so reject early everything that is not connected to 202*0d4dbf8bSAndre Fischer // toolbox selection. 203*0d4dbf8bSAndre Fischer if (pEvent == NULL) 204*0d4dbf8bSAndre Fischer return 1; 205*0d4dbf8bSAndre Fischer if ( ! pEvent->ISA(VclWindowEvent)) 206*0d4dbf8bSAndre Fischer return 1; 207*0d4dbf8bSAndre Fischer if (pEvent->GetId() != VCLEVENT_TOOLBOX_SELECT) 208*0d4dbf8bSAndre Fischer return 1; 209*0d4dbf8bSAndre Fischer 210*0d4dbf8bSAndre Fischer ToolBox* pToolBox = dynamic_cast<ToolBox*>(dynamic_cast<VclWindowEvent*>(pEvent)->GetWindow()); 211*0d4dbf8bSAndre Fischer if (pToolBox == NULL) 212*0d4dbf8bSAndre Fischer return 1; 213*0d4dbf8bSAndre Fischer 214*0d4dbf8bSAndre Fischer // Extract name of (sub)toolbar from help id. 215*0d4dbf8bSAndre Fischer OUString sToolbarName (rtl::OStringToOUString(pToolBox->GetHelpId(), RTL_TEXTENCODING_UTF8)); 216*0d4dbf8bSAndre Fischer if (sToolbarName.getLength() == 0) 217*0d4dbf8bSAndre Fischer return 1; 218*0d4dbf8bSAndre Fischer const util::URL aURL (sfx2::sidebar::Tools::GetURL(sToolbarName)); 219*0d4dbf8bSAndre Fischer if (aURL.Path.getLength() == 0) 220*0d4dbf8bSAndre Fischer return 1; 221*0d4dbf8bSAndre Fischer 222*0d4dbf8bSAndre Fischer // Get item id. 223*0d4dbf8bSAndre Fischer sal_uInt16 nId = pToolBox->GetCurItemId(); 224*0d4dbf8bSAndre Fischer if (nId == 0) 225*0d4dbf8bSAndre Fischer return 1; 226*0d4dbf8bSAndre Fischer 227*0d4dbf8bSAndre Fischer // Get toolbar controller. 228*0d4dbf8bSAndre Fischer const sal_uInt16 nItemId (GetItemIdForSubToolbarName(aURL.Path)); 229*0d4dbf8bSAndre Fischer Reference<frame::XSubToolbarController> xController (GetControllerForItemId(nItemId), UNO_QUERY); 230*0d4dbf8bSAndre Fischer if ( ! xController.is()) 231*0d4dbf8bSAndre Fischer return 1; 232*0d4dbf8bSAndre Fischer 233*0d4dbf8bSAndre Fischer const OUString sCommand (pToolBox->GetItemCommand(nId)); 234*0d4dbf8bSAndre Fischer ControllerContainer::iterator iController (maControllers.find(nItemId)); 235*0d4dbf8bSAndre Fischer if (iController != maControllers.end()) 236*0d4dbf8bSAndre Fischer iController->second.msCurrentCommand = sCommand; 237*0d4dbf8bSAndre Fischer xController->functionSelected(sCommand); 238*0d4dbf8bSAndre Fischer 239*0d4dbf8bSAndre Fischer const sal_Bool bBigImages (SvtMiscOptions().AreCurrentSymbolsLarge()); 240*0d4dbf8bSAndre Fischer const bool bIsHighContrastActive (sfx2::sidebar::Theme::IsHighContrastMode()); 241*0d4dbf8bSAndre Fischer Image aImage (framework::GetImageFromURL(mxFrame, sCommand, bBigImages, bIsHighContrastActive)); 242*0d4dbf8bSAndre Fischer pToolBox->SetItemImage(iController->first, aImage); 243*0d4dbf8bSAndre Fischer 244*0d4dbf8bSAndre Fischer return 1; 245*0d4dbf8bSAndre Fischer } 246*0d4dbf8bSAndre Fischer 247*0d4dbf8bSAndre Fischer 248*0d4dbf8bSAndre Fischer 249*0d4dbf8bSAndre Fischer 250*0d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, Activate, ToolBox*, EMPTYARG) 251*0d4dbf8bSAndre Fischer { 252*0d4dbf8bSAndre Fischer return 1; 253*0d4dbf8bSAndre Fischer } 254*0d4dbf8bSAndre Fischer 255*0d4dbf8bSAndre Fischer 256*0d4dbf8bSAndre Fischer 257*0d4dbf8bSAndre Fischer 258*0d4dbf8bSAndre Fischer IMPL_LINK(InsertPropertyPanel, Deactivate, ToolBox*, EMPTYARG) 259*0d4dbf8bSAndre Fischer { 260*0d4dbf8bSAndre Fischer return 1; 261*0d4dbf8bSAndre Fischer } 262*0d4dbf8bSAndre Fischer 263*0d4dbf8bSAndre Fischer 264*0d4dbf8bSAndre Fischer 265*0d4dbf8bSAndre Fischer 266*0d4dbf8bSAndre Fischer void InsertPropertyPanel::CreateController ( 267*0d4dbf8bSAndre Fischer const sal_uInt16 nItemId) 268*0d4dbf8bSAndre Fischer { 269*0d4dbf8bSAndre Fischer ToolBox* pToolBox = GetToolBoxForItemId(nItemId); 270*0d4dbf8bSAndre Fischer if (pToolBox != NULL) 271*0d4dbf8bSAndre Fischer { 272*0d4dbf8bSAndre Fischer ItemDescriptor aDescriptor; 273*0d4dbf8bSAndre Fischer 274*0d4dbf8bSAndre Fischer const OUString sCommandName (pToolBox->GetItemCommand(nItemId)); 275*0d4dbf8bSAndre Fischer 276*0d4dbf8bSAndre Fischer // Create a controller for the new item. 277*0d4dbf8bSAndre Fischer aDescriptor.mxController.set( 278*0d4dbf8bSAndre Fischer static_cast<XWeak*>(::framework::CreateToolBoxController( 279*0d4dbf8bSAndre Fischer mxFrame, 280*0d4dbf8bSAndre Fischer pToolBox, 281*0d4dbf8bSAndre Fischer nItemId, 282*0d4dbf8bSAndre Fischer sCommandName)), 283*0d4dbf8bSAndre Fischer UNO_QUERY); 284*0d4dbf8bSAndre Fischer if ( ! aDescriptor.mxController.is()) 285*0d4dbf8bSAndre Fischer aDescriptor.mxController.set( 286*0d4dbf8bSAndre Fischer static_cast<XWeak*>(new SimpleToolBoxController(mxFrame, *pToolBox, nItemId, sCommandName)), 287*0d4dbf8bSAndre Fischer UNO_QUERY); 288*0d4dbf8bSAndre Fischer if ( ! aDescriptor.mxController.is()) 289*0d4dbf8bSAndre Fischer return; 290*0d4dbf8bSAndre Fischer 291*0d4dbf8bSAndre Fischer // Get dispatch object for the command. 292*0d4dbf8bSAndre Fischer aDescriptor.maURL = sfx2::sidebar::Tools::GetURL(sCommandName); 293*0d4dbf8bSAndre Fischer aDescriptor.msCurrentCommand = sCommandName; 294*0d4dbf8bSAndre Fischer aDescriptor.mxDispatch = sfx2::sidebar::Tools::GetDispatch(mxFrame, aDescriptor.maURL); 295*0d4dbf8bSAndre Fischer if ( ! aDescriptor.mxDispatch.is()) 296*0d4dbf8bSAndre Fischer return; 297*0d4dbf8bSAndre Fischer 298*0d4dbf8bSAndre Fischer // Initialize the controller with eg a service factory. 299*0d4dbf8bSAndre Fischer Reference<lang::XInitialization> xInitialization (aDescriptor.mxController, UNO_QUERY); 300*0d4dbf8bSAndre Fischer if (xInitialization.is()) 301*0d4dbf8bSAndre Fischer { 302*0d4dbf8bSAndre Fischer beans::PropertyValue aPropValue; 303*0d4dbf8bSAndre Fischer std::vector<Any> aPropertyVector; 304*0d4dbf8bSAndre Fischer 305*0d4dbf8bSAndre Fischer aPropValue.Name = A2S("Frame"); 306*0d4dbf8bSAndre Fischer aPropValue.Value <<= mxFrame; 307*0d4dbf8bSAndre Fischer aPropertyVector.push_back(makeAny(aPropValue)); 308*0d4dbf8bSAndre Fischer 309*0d4dbf8bSAndre Fischer aPropValue.Name = A2S("ServiceManager"); 310*0d4dbf8bSAndre Fischer aPropValue.Value <<= ::comphelper::getProcessServiceFactory(); 311*0d4dbf8bSAndre Fischer aPropertyVector.push_back(makeAny(aPropValue)); 312*0d4dbf8bSAndre Fischer 313*0d4dbf8bSAndre Fischer aPropValue.Name = A2S("CommandURL"); 314*0d4dbf8bSAndre Fischer aPropValue.Value <<= sCommandName; 315*0d4dbf8bSAndre Fischer aPropertyVector.push_back(makeAny(aPropValue)); 316*0d4dbf8bSAndre Fischer 317*0d4dbf8bSAndre Fischer Sequence<Any> aArgs (comphelper::containerToSequence(aPropertyVector)); 318*0d4dbf8bSAndre Fischer xInitialization->initialize(aArgs); 319*0d4dbf8bSAndre Fischer } 320*0d4dbf8bSAndre Fischer 321*0d4dbf8bSAndre Fischer Reference<util::XUpdatable> xUpdatable (aDescriptor.mxController, UNO_QUERY); 322*0d4dbf8bSAndre Fischer if (xUpdatable.is()) 323*0d4dbf8bSAndre Fischer xUpdatable->update(); 324*0d4dbf8bSAndre Fischer 325*0d4dbf8bSAndre Fischer // Add label. 326*0d4dbf8bSAndre Fischer const OUString sLabel (sfx2::sidebar::CommandInfoProvider::Instance().GetLabelForCommand( 327*0d4dbf8bSAndre Fischer sCommandName, 328*0d4dbf8bSAndre Fischer mxFrame)); 329*0d4dbf8bSAndre Fischer pToolBox->SetQuickHelpText(nItemId, sLabel); 330*0d4dbf8bSAndre Fischer 331*0d4dbf8bSAndre Fischer // Add item to toolbox. 332*0d4dbf8bSAndre Fischer pToolBox->EnableItem(nItemId); 333*0d4dbf8bSAndre Fischer maControllers.insert(::std::make_pair(nItemId, aDescriptor)); 334*0d4dbf8bSAndre Fischer } 335*0d4dbf8bSAndre Fischer } 336*0d4dbf8bSAndre Fischer 337*0d4dbf8bSAndre Fischer 338*0d4dbf8bSAndre Fischer 339*0d4dbf8bSAndre Fischer 340*0d4dbf8bSAndre Fischer ToolBox* InsertPropertyPanel::GetToolBoxForItemId (const sal_uInt16 nItemId) const 341*0d4dbf8bSAndre Fischer { 342*0d4dbf8bSAndre Fischer switch(nItemId) 343*0d4dbf8bSAndre Fischer { 344*0d4dbf8bSAndre Fischer case TBI_STANDARD_LINE: 345*0d4dbf8bSAndre Fischer case TBI_STANDARD_ARROW: 346*0d4dbf8bSAndre Fischer case TBI_STANDARD_RECTANGLE: 347*0d4dbf8bSAndre Fischer case TBI_STANDARD_ELLIPSE: 348*0d4dbf8bSAndre Fischer case TBI_STANDARD_TEXT: 349*0d4dbf8bSAndre Fischer case TBI_STANDARD_LINES: 350*0d4dbf8bSAndre Fischer case TBI_STANDARD_CONNECTORS: 351*0d4dbf8bSAndre Fischer case TBI_STANDARD_ARROWS: 352*0d4dbf8bSAndre Fischer return mpStandardShapesToolBox.get(); 353*0d4dbf8bSAndre Fischer 354*0d4dbf8bSAndre Fischer case TBI_CUSTOM_BASICS: 355*0d4dbf8bSAndre Fischer case TBI_CUSTOM_SYMBOLS: 356*0d4dbf8bSAndre Fischer case TBI_CUSTOM_ARROWS: 357*0d4dbf8bSAndre Fischer case TBI_CUSTOM_FLOWCHARTS: 358*0d4dbf8bSAndre Fischer case TBI_CUSTOM_CALLOUTS: 359*0d4dbf8bSAndre Fischer case TBI_CUSTOM_STARS: 360*0d4dbf8bSAndre Fischer return mpCustomShapesToolBox.get(); 361*0d4dbf8bSAndre Fischer 362*0d4dbf8bSAndre Fischer default: 363*0d4dbf8bSAndre Fischer return NULL; 364*0d4dbf8bSAndre Fischer } 365*0d4dbf8bSAndre Fischer } 366*0d4dbf8bSAndre Fischer 367*0d4dbf8bSAndre Fischer 368*0d4dbf8bSAndre Fischer 369*0d4dbf8bSAndre Fischer 370*0d4dbf8bSAndre Fischer Reference<frame::XToolbarController> InsertPropertyPanel::GetControllerForItemId (const sal_uInt16 nItemId) const 371*0d4dbf8bSAndre Fischer { 372*0d4dbf8bSAndre Fischer ControllerContainer::const_iterator iController (maControllers.find(nItemId)); 373*0d4dbf8bSAndre Fischer if (iController != maControllers.end()) 374*0d4dbf8bSAndre Fischer return iController->second.mxController; 375*0d4dbf8bSAndre Fischer else 376*0d4dbf8bSAndre Fischer return NULL; 377*0d4dbf8bSAndre Fischer } 378*0d4dbf8bSAndre Fischer 379*0d4dbf8bSAndre Fischer 380*0d4dbf8bSAndre Fischer 381*0d4dbf8bSAndre Fischer 382*0d4dbf8bSAndre Fischer sal_uInt16 InsertPropertyPanel::GetItemIdForSubToolbarName (const OUString& rsSubToolbarName) const 383*0d4dbf8bSAndre Fischer { 384*0d4dbf8bSAndre Fischer for (ControllerContainer::const_iterator iController(maControllers.begin()), iEnd(maControllers.end()); 385*0d4dbf8bSAndre Fischer iController!=iEnd; 386*0d4dbf8bSAndre Fischer ++iController) 387*0d4dbf8bSAndre Fischer { 388*0d4dbf8bSAndre Fischer Reference<frame::XSubToolbarController> xSubToolbarController (iController->second.mxController, UNO_QUERY); 389*0d4dbf8bSAndre Fischer if (xSubToolbarController.is()) 390*0d4dbf8bSAndre Fischer if (xSubToolbarController->getSubToolbarName().equals(rsSubToolbarName)) 391*0d4dbf8bSAndre Fischer return iController->first; 392*0d4dbf8bSAndre Fischer } 393*0d4dbf8bSAndre Fischer return NULL; 394*0d4dbf8bSAndre Fischer } 395*0d4dbf8bSAndre Fischer 396*0d4dbf8bSAndre Fischer 397*0d4dbf8bSAndre Fischer 398*0d4dbf8bSAndre Fischer 399*0d4dbf8bSAndre Fischer void InsertPropertyPanel::UpdateIcons (void) 400*0d4dbf8bSAndre Fischer { 401*0d4dbf8bSAndre Fischer const sal_Bool bBigImages (SvtMiscOptions().AreCurrentSymbolsLarge()); 402*0d4dbf8bSAndre Fischer const bool bIsHighContrastActive (sfx2::sidebar::Theme::IsHighContrastMode()); 403*0d4dbf8bSAndre Fischer 404*0d4dbf8bSAndre Fischer for (ControllerContainer::iterator iController(maControllers.begin()), iEnd(maControllers.end()); 405*0d4dbf8bSAndre Fischer iController!=iEnd; 406*0d4dbf8bSAndre Fischer ++iController) 407*0d4dbf8bSAndre Fischer { 408*0d4dbf8bSAndre Fischer const ::rtl::OUString sCommandURL (iController->second.msCurrentCommand); 409*0d4dbf8bSAndre Fischer Image aImage (framework::GetImageFromURL(mxFrame, sCommandURL, bBigImages, bIsHighContrastActive)); 410*0d4dbf8bSAndre Fischer ToolBox* pToolBox = GetToolBoxForItemId(iController->first); 411*0d4dbf8bSAndre Fischer if (pToolBox != NULL) 412*0d4dbf8bSAndre Fischer pToolBox->SetItemImage(iController->first, aImage); 413*0d4dbf8bSAndre Fischer } 414*0d4dbf8bSAndre Fischer } 415*0d4dbf8bSAndre Fischer 416*0d4dbf8bSAndre Fischer 417*0d4dbf8bSAndre Fischer 418*0d4dbf8bSAndre Fischer 419*0d4dbf8bSAndre Fischer } } // end of namespace svx::sidebar 420