LCOV - code coverage report
Current view: top level - framework/source/uielement - addonstoolbarwrapper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 69 0.0 %
Date: 2014-04-14 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <uielement/addonstoolbarwrapper.hxx>
      21             : #include <framework/actiontriggerhelper.hxx>
      22             : #include <uielement/constitemcontainer.hxx>
      23             : #include <uielement/rootitemcontainer.hxx>
      24             : #include <uielement/addonstoolbarmanager.hxx>
      25             : 
      26             : #include <com/sun/star/lang/XServiceInfo.hpp>
      27             : #include <com/sun/star/lang/DisposedException.hpp>
      28             : #include <com/sun/star/beans/XPropertySet.hpp>
      29             : #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp>
      30             : #include <com/sun/star/awt/XMenuBar.hpp>
      31             : #include <com/sun/star/container/XIndexContainer.hpp>
      32             : #include <com/sun/star/container/XNameAccess.hpp>
      33             : #include <com/sun/star/ui/UIElementType.hpp>
      34             : 
      35             : #include <toolkit/helper/vclunohelper.hxx>
      36             : #include <toolkit/awt/vclxwindow.hxx>
      37             : #include <comphelper/processfactory.hxx>
      38             : 
      39             : #include <svtools/miscopt.hxx>
      40             : #include <vcl/svapp.hxx>
      41             : #include <vcl/toolbox.hxx>
      42             : 
      43             : using namespace com::sun::star::uno;
      44             : using namespace com::sun::star::beans;
      45             : using namespace com::sun::star::frame;
      46             : using namespace com::sun::star::lang;
      47             : using namespace com::sun::star::container;
      48             : using namespace com::sun::star::awt;
      49             : using namespace ::com::sun::star::ui;
      50             : 
      51             : namespace framework
      52             : {
      53             : 
      54           0 : AddonsToolBarWrapper::AddonsToolBarWrapper( const Reference< XComponentContext >& xContext ) :
      55             :     UIElementWrapperBase( UIElementType::TOOLBAR ),
      56             :     m_xContext( xContext ),
      57           0 :     m_bCreatedImages( false )
      58             : {
      59           0 : }
      60             : 
      61           0 : AddonsToolBarWrapper::~AddonsToolBarWrapper()
      62             : {
      63           0 : }
      64             : 
      65             : // XComponent
      66           0 : void SAL_CALL AddonsToolBarWrapper::dispose() throw ( RuntimeException, std::exception )
      67             : {
      68           0 :     Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
      69             : 
      70           0 :     com::sun::star::lang::EventObject aEvent( xThis );
      71           0 :     m_aListenerContainer.disposeAndClear( aEvent );
      72             : 
      73           0 :     SolarMutexGuard g;
      74             : 
      75           0 :     if ( m_xToolBarManager.is() )
      76           0 :         m_xToolBarManager->dispose();
      77           0 :     m_xToolBarManager.clear();
      78             : 
      79           0 :     m_bDisposed = true;
      80           0 : }
      81             : 
      82             : // XInitialization
      83           0 : void SAL_CALL AddonsToolBarWrapper::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException, std::exception )
      84             : {
      85           0 :     SolarMutexGuard g;
      86             : 
      87           0 :     if ( m_bDisposed )
      88           0 :         throw DisposedException();
      89             : 
      90           0 :     if ( !m_bInitialized )
      91             :     {
      92           0 :         UIElementWrapperBase::initialize( aArguments );
      93             : 
      94           0 :         for ( sal_Int32 n = 0; n < aArguments.getLength(); n++ )
      95             :         {
      96           0 :             PropertyValue aPropValue;
      97           0 :             if ( aArguments[n] >>= aPropValue )
      98             :             {
      99           0 :                 if ( aPropValue.Name == "ConfigurationData" )
     100           0 :                     aPropValue.Value >>= m_aConfigData;
     101             :             }
     102           0 :         }
     103             : 
     104           0 :         Reference< XFrame > xFrame( m_xWeakFrame );
     105           0 :         if ( xFrame.is() && m_aConfigData.getLength() > 0 )
     106             :         {
     107             :             // Create VCL based toolbar which will be filled with settings data
     108           0 :             ToolBox* pToolBar = 0;
     109           0 :             AddonsToolBarManager* pToolBarManager = 0;
     110             :             {
     111           0 :                 SolarMutexGuard aSolarMutexGuard;
     112           0 :                 Window* pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
     113           0 :                 if ( pWindow )
     114             :                 {
     115           0 :                     sal_uLong nStyles = WB_LINESPACING | WB_BORDER | WB_SCROLL | WB_MOVEABLE | WB_3DLOOK | WB_DOCKABLE | WB_SIZEABLE | WB_CLOSEABLE;
     116             : 
     117           0 :                     pToolBar = new ToolBox( pWindow, nStyles );
     118           0 :                     pToolBarManager = new AddonsToolBarManager( m_xContext, xFrame, m_aResourceURL, pToolBar );
     119           0 :                     m_xToolBarManager = Reference< XComponent >( static_cast< OWeakObject *>( pToolBarManager ), UNO_QUERY );
     120           0 :                 }
     121             :             }
     122             : 
     123             :             try
     124             :             {
     125           0 :                 if (( m_aConfigData.getLength() > 0 ) && pToolBar && pToolBarManager )
     126             :                 {
     127             :                     // Fill toolbar with container contents
     128           0 :                     pToolBarManager->FillToolbar( m_aConfigData );
     129           0 :                     pToolBar->SetOutStyle( SvtMiscOptions().GetToolboxStyle() );
     130           0 :                     pToolBar->EnableCustomize( true );
     131           0 :                     ::Size aActSize( pToolBar->GetSizePixel() );
     132           0 :                     ::Size aSize( pToolBar->CalcWindowSizePixel() );
     133           0 :                     aSize.Width() = aActSize.Width();
     134           0 :                     pToolBar->SetSizePixel( aSize );
     135             :                 }
     136             :             }
     137           0 :             catch ( const NoSuchElementException& )
     138             :             {
     139             :             }
     140           0 :         }
     141           0 :     }
     142           0 : }
     143             : 
     144             : // XUIElement interface
     145           0 : Reference< XInterface > SAL_CALL AddonsToolBarWrapper::getRealInterface() throw (::com::sun::star::uno::RuntimeException, std::exception)
     146             : {
     147           0 :     SolarMutexGuard g;
     148             : 
     149           0 :     if ( m_xToolBarManager.is() )
     150             :     {
     151           0 :         AddonsToolBarManager* pToolBarManager = static_cast< AddonsToolBarManager *>( m_xToolBarManager.get() );
     152           0 :         if ( pToolBarManager )
     153             :         {
     154           0 :             Window* pWindow = (Window *)pToolBarManager->GetToolBar();
     155           0 :             return Reference< XInterface >( VCLUnoHelper::GetInterface( pWindow ), UNO_QUERY );
     156             :         }
     157             :     }
     158             : 
     159           0 :     return Reference< XInterface >();
     160             : }
     161             : 
     162             : // allow late population of images for add-on toolbars
     163           0 : void AddonsToolBarWrapper::populateImages()
     164             : {
     165           0 :     SolarMutexGuard g;
     166             : 
     167           0 :     if (m_bCreatedImages)
     168           0 :         return;
     169             : 
     170           0 :     if ( m_xToolBarManager.is() )
     171             :     {
     172           0 :         AddonsToolBarManager* pToolBarManager = static_cast< AddonsToolBarManager *>( m_xToolBarManager.get() );
     173           0 :         if (pToolBarManager)
     174             :         {
     175           0 :             pToolBarManager->RefreshImages();
     176           0 :             m_bCreatedImages = true;
     177             :         }
     178           0 :     }
     179             : }
     180             : 
     181             : } // namespace framework
     182             : 
     183             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10