LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/sidebar/insert - InsertPropertyPanel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 63 1.6 %
Date: 2013-07-09 Functions: 2 7 28.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * This file is part of the LibreOffice project.
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * This file incorporates work covered by the following license notice:
       9             :  *
      10             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      11             :  *   contributor license agreements. See the NOTICE file distributed
      12             :  *   with this work for additional information regarding copyright
      13             :  *   ownership. The ASF licenses this file to you under the Apache
      14             :  *   License, Version 2.0 (the "License"); you may not use this file
      15             :  *   except in compliance with the License. You may obtain a copy of
      16             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      17             :  */
      18             : #include "InsertPropertyPanel.hxx"
      19             : #include "InsertPropertyPanel.hrc"
      20             : #include "sfx2/sidebar/CommandInfoProvider.hxx"
      21             : 
      22             : #include <sfx2/sidebar/Theme.hxx>
      23             : #include <sfx2/sidebar/Tools.hxx>
      24             : #include <sfx2/sidebar/ControlFactory.hxx>
      25             : #include <sfx2/sidebar/ControllerFactory.hxx>
      26             : 
      27             : #include <svx/dialmgr.hxx>
      28             : #include <svtools/miscopt.hxx>
      29             : #include <svtools/generictoolboxcontroller.hxx>
      30             : #include <vcl/toolbox.hxx>
      31             : #include <sfx2/tbxctrl.hxx>
      32             : #include <framework/sfxhelperfunctions.hxx>
      33             : #include <framework/imageproducer.hxx>
      34             : #include <comphelper/processfactory.hxx>
      35             : #include <cppuhelper/compbase1.hxx>
      36             : #include <cppuhelper/basemutex.hxx>
      37             : 
      38             : #include <com/sun/star/frame/XStatusListener.hpp>
      39             : 
      40             : using namespace css;
      41             : using namespace cssu;
      42             : using ::rtl::OUString;
      43             : using ::sfx2::sidebar::SidebarToolBox;
      44             : 
      45             : 
      46             : namespace svx { namespace sidebar {
      47             : 
      48             : 
      49           0 : InsertPropertyPanel::InsertPropertyPanel (
      50             :     Window* pParent,
      51             :     const cssu::Reference<css::frame::XFrame>& rxFrame)
      52           0 :     :   Control(pParent, SVX_RES(RID_SIDEBAR_INSERT_PANEL)),
      53             :         mpStandardShapesBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)),
      54             :         mpStandardShapesToolBox(sfx2::sidebar::ControlFactory::CreateToolBox(
      55             :                 mpStandardShapesBackground.get(),
      56           0 :                 SVX_RES(TB_INSERT_STANDARD),
      57           0 :                 rxFrame)),
      58             :         mpCustomShapesBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)),
      59             :         mpCustomShapesToolBox(sfx2::sidebar::ControlFactory::CreateToolBox(
      60             :                 mpCustomShapesBackground.get(),
      61           0 :                 SVX_RES(TB_INSERT_CUSTOM),
      62           0 :                 rxFrame)),
      63           0 :         mxFrame(rxFrame)
      64             : {
      65           0 :     FreeResource();
      66             : 
      67           0 :     mpStandardShapesToolBox->Show();
      68           0 :     mpCustomShapesToolBox->Show();
      69             : 
      70             :     // Listen to all tool box selection events.
      71           0 :     Window* pTopWindow = pParent;
      72           0 :     while (pTopWindow->GetParent() != NULL)
      73           0 :         pTopWindow = pTopWindow->GetParent();
      74           0 :     pTopWindow->AddChildEventListener(LINK(this, InsertPropertyPanel, WindowEventListener));
      75           0 : }
      76             : 
      77             : 
      78             : 
      79             : 
      80           0 : InsertPropertyPanel::~InsertPropertyPanel (void)
      81             : {
      82             :     // Remove window child listener.
      83           0 :     Window* pTopWindow = this;
      84           0 :     while (pTopWindow->GetParent() != NULL)
      85           0 :         pTopWindow = pTopWindow->GetParent();
      86           0 :     pTopWindow->RemoveChildEventListener(LINK(this, InsertPropertyPanel, WindowEventListener));
      87             : 
      88           0 :     mpStandardShapesToolBox.reset();
      89           0 :     mpCustomShapesToolBox.reset();
      90           0 :     mpStandardShapesBackground.reset();
      91           0 :     mpCustomShapesBackground.reset();
      92           0 : }
      93             : 
      94             : 
      95             : 
      96             : 
      97           0 : IMPL_LINK(InsertPropertyPanel, WindowEventListener, VclSimpleEvent*, pEvent)
      98             : {
      99             :     // We will be getting a lot of window events (well, basically all
     100             :     // of them), so reject early everything that is not connected to
     101             :     // toolbox selection.
     102           0 :     if (pEvent == NULL)
     103           0 :         return 1;
     104           0 :     if ( ! pEvent->ISA(VclWindowEvent))
     105           0 :         return 1;
     106           0 :     if (pEvent->GetId() != VCLEVENT_TOOLBOX_SELECT)
     107           0 :         return 1;
     108             : 
     109           0 :     Window* pWindow = dynamic_cast<VclWindowEvent*>(pEvent)->GetWindow();
     110           0 :     ToolBox* pToolBox = dynamic_cast<ToolBox*>(pWindow);
     111           0 :     if (pToolBox == NULL)
     112           0 :         return 1;
     113             : 
     114             :     // Extract name of (sub)toolbar from help id.
     115           0 :     OUString sToolbarName (rtl::OStringToOUString(pToolBox->GetHelpId(), RTL_TEXTENCODING_UTF8));
     116           0 :     if (sToolbarName.getLength() == 0)
     117           0 :         return 1;
     118           0 :     const util::URL aURL (sfx2::sidebar::Tools::GetURL(sToolbarName));
     119           0 :     if (aURL.Path.getLength() == 0)
     120           0 :         return 1;
     121             : 
     122             :     // Get item id.
     123           0 :     sal_uInt16 nId = pToolBox->GetCurItemId();
     124           0 :     if (nId == 0)
     125           0 :         return 1;
     126             : 
     127           0 :     SidebarToolBox* pSidebarToolBox = dynamic_cast<SidebarToolBox*>(mpStandardShapesToolBox.get());
     128           0 :     if (pSidebarToolBox == NULL)
     129           0 :         return 1;
     130           0 :     sal_uInt16 nItemId (pSidebarToolBox->GetItemIdForSubToolbarName(aURL.Path));
     131           0 :     if (nItemId == 0)
     132             :     {
     133           0 :         pSidebarToolBox = dynamic_cast<SidebarToolBox*>(mpCustomShapesToolBox.get());
     134           0 :         if (pSidebarToolBox == NULL)
     135           0 :             return 1;
     136           0 :         nItemId = pSidebarToolBox->GetItemIdForSubToolbarName(aURL.Path);
     137           0 :         if (nItemId == 0)
     138           0 :             return 1;
     139             :     }
     140             : 
     141           0 :     Reference<frame::XSubToolbarController> xController (pSidebarToolBox->GetControllerForItemId(nItemId), UNO_QUERY);
     142           0 :     if ( ! xController.is())
     143           0 :         return 1;
     144             : 
     145           0 :     const OUString sCommand (pToolBox->GetItemCommand(nId));
     146           0 :     xController->functionSelected(sCommand);
     147             : 
     148           0 :     return 1;
     149             : }
     150             : 
     151             : 
     152         216 : } } // end of namespace svx::sidebar

Generated by: LCOV version 1.10