LCOV - code coverage report
Current view: top level - libreoffice/cui/source/customize - eventdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 80 1.2 %
Date: 2012-12-27 Functions: 2 11 18.2 %
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 <svtools/svmedit.hxx>
      21             : #include <tools/diagnose_ex.h>
      22             : #include <com/sun/star/document/XEventsSupplier.hpp>
      23             : #include <com/sun/star/frame/Desktop.hpp>
      24             : #include <com/sun/star/frame/GlobalEventBroadcaster.hpp>
      25             : #include <com/sun/star/frame/XModuleManager.hpp>
      26             : 
      27             : #include <comphelper/processfactory.hxx>
      28             : #include <comphelper/documentinfo.hxx>
      29             : #include <unotools/configmgr.hxx>
      30             : #include <rtl/ustring.hxx>
      31             : 
      32             : #include "eventdlg.hxx"
      33             : 
      34             : #include <sfx2/viewfrm.hxx>
      35             : #include <sfx2/evntconf.hxx>
      36             : #include <sfx2/minfitem.hxx>
      37             : #include <sfx2/app.hxx>
      38             : #include <sfx2/objsh.hxx>
      39             : #include <sfx2/docfac.hxx>
      40             : #include <sfx2/fcontnr.hxx>
      41             : #include <unotools/eventcfg.hxx>
      42             : 
      43             : #include "headertablistbox.hxx"
      44             : #include "macropg_impl.hxx"
      45             : 
      46             : #include <dialmgr.hxx>
      47             : #include <cuires.hrc>
      48             : #include "eventdlg.hrc"
      49             : #include "helpid.hrc"
      50             : #include "selector.hxx"
      51             : #include "cfg.hxx"
      52             : 
      53             : 
      54             : using ::rtl::OUString;
      55             : using namespace ::com::sun::star;
      56             : // -----------------------------------------------------------------------
      57             : 
      58           0 : SvxEventConfigPage::SvxEventConfigPage( Window *pParent, const SfxItemSet& rSet, SvxEventConfigPage::EarlyInit ) :
      59             : 
      60           0 :     _SvxMacroTabPage( pParent, CUI_RES(RID_SVXPAGE_EVENTS), rSet ),
      61           0 :     aSaveInText( this, CUI_RES( TXT_SAVEIN ) ),
      62           0 :     aSaveInListBox( this, CUI_RES( LB_SAVEIN ) ),
      63           0 :     bAppConfig  ( sal_True )
      64             : {
      65           0 :     mpImpl->pStrEvent           = new String( CUI_RES( STR_EVENT ));
      66           0 :     mpImpl->pAssignedMacro      = new String( CUI_RES( STR_ASSMACRO ));
      67           0 :     mpImpl->pEventLB            = new _HeaderTabListBox( this, CUI_RES( LB_EVENT ));
      68           0 :     mpImpl->pAssignFT           = new FixedText( this,  CUI_RES( FT_ASSIGN ));
      69           0 :     mpImpl->pAssignPB           = new PushButton( this, CUI_RES( PB_ASSIGN ));
      70           0 :     mpImpl->pDeletePB           = new PushButton( this, CUI_RES( PB_DELETE ));
      71           0 :     mpImpl->pMacroImg           = new Image( CUI_RES( IMG_MACRO) );
      72           0 :     mpImpl->pComponentImg       = new Image( CUI_RES( IMG_COMPONENT) );
      73             : 
      74           0 :     FreeResource();
      75             : 
      76             :     // must be done after FreeResource is called
      77           0 :     InitResources();
      78             : 
      79           0 :     mpImpl->pEventLB->GetListBox().SetHelpId( HID_SVX_MACRO_LB_EVENT );
      80             : 
      81             :     aSaveInListBox.SetSelectHdl( LINK( this, SvxEventConfigPage,
      82           0 :                 SelectHdl_Impl ) );
      83             : 
      84           0 :     uno::Reference< frame::XGlobalEventBroadcaster > xSupplier;
      85             : 
      86             :     xSupplier =
      87           0 :         frame::GlobalEventBroadcaster::create(::comphelper::getProcessComponentContext());
      88             : 
      89           0 :     sal_uInt16 nPos(0);
      90           0 :     m_xAppEvents = xSupplier->getEvents();
      91             :     nPos = aSaveInListBox.InsertEntry(
      92           0 :         utl::ConfigManager::getProductName() );
      93           0 :     aSaveInListBox.SetEntryData( nPos, new bool(true) );
      94           0 :     aSaveInListBox.SelectEntryPos( nPos, sal_True );
      95           0 : }
      96             : 
      97             : // -----------------------------------------------------------------------
      98           0 : void SvxEventConfigPage::LateInit( const uno::Reference< frame::XFrame >& _rxFrame  )
      99             : {
     100           0 :     SetFrame( _rxFrame );
     101           0 :     ImplInitDocument();
     102             : 
     103           0 :     InitAndSetHandler( m_xAppEvents, m_xDocumentEvents, m_xDocumentModifiable );
     104             : 
     105           0 :     SelectHdl_Impl( NULL );
     106           0 : }
     107             : 
     108             : // -----------------------------------------------------------------------
     109             : 
     110           0 : SvxEventConfigPage::~SvxEventConfigPage()
     111             : {
     112             :     //DF Do I need to delete bools?
     113           0 : }
     114             : 
     115             : // -----------------------------------------------------------------------
     116             : 
     117           0 : void SvxEventConfigPage::ImplInitDocument()
     118             : {
     119           0 :     uno::Reference< frame::XFrame > xFrame( GetFrame() );
     120           0 :     OUString aModuleId = SvxConfigPage::GetFrameWithDefaultAndIdentify( xFrame );
     121           0 :     if ( !xFrame.is() )
     122             :         return;
     123             : 
     124             :     try
     125             :     {
     126           0 :         uno::Reference< frame::XModel > xModel;
     127           0 :         if ( !SvxConfigPage::CanConfig( aModuleId ) )
     128             :             return;
     129             : 
     130             :         uno::Reference< frame::XController > xController =
     131           0 :             xFrame->getController();
     132             : 
     133           0 :         if ( xController.is() )
     134             :         {
     135           0 :             xModel = xController->getModel();
     136             :         }
     137             : 
     138           0 :         if ( !xModel.is() )
     139             :             return;
     140             : 
     141           0 :         uno::Reference< document::XEventsSupplier > xSupplier( xModel, uno::UNO_QUERY );
     142             : 
     143           0 :         if ( xSupplier.is() )
     144             :         {
     145           0 :             m_xDocumentEvents = xSupplier->getEvents();
     146           0 :             m_xDocumentModifiable = m_xDocumentModifiable.query( xModel );
     147             : 
     148           0 :             OUString aTitle = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
     149           0 :             sal_uInt16 nPos = aSaveInListBox.InsertEntry( aTitle );
     150             : 
     151           0 :             aSaveInListBox.SetEntryData( nPos, new bool(false) );
     152           0 :             aSaveInListBox.SelectEntryPos( nPos, sal_True );
     153             : 
     154           0 :             bAppConfig = false;
     155           0 :         }
     156             :     }
     157           0 :     catch( const uno::Exception& )
     158             :     {
     159             :         DBG_UNHANDLED_EXCEPTION();
     160           0 :     }
     161             : }
     162             : 
     163             : // -----------------------------------------------------------------------
     164             : 
     165           0 : IMPL_LINK( SvxEventConfigPage, SelectHdl_Impl, ListBox *, pBox )
     166             : {
     167             :     (void)pBox;
     168             : 
     169             :     bool* bApp = (bool*) aSaveInListBox.GetEntryData(
     170           0 :             aSaveInListBox.GetSelectEntryPos());
     171             : 
     172           0 :     mpImpl->pEventLB->SetUpdateMode( sal_False );
     173           0 :     bAppConfig = *bApp;
     174           0 :     if ( *bApp )
     175             :     {
     176           0 :         SetReadOnly( sal_False );
     177           0 :         _SvxMacroTabPage::DisplayAppEvents( true );
     178             :     }
     179             :     else
     180             :     {
     181           0 :         bool isReadonly = sal_False;
     182             : 
     183             :         uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create(
     184           0 :             ::comphelper::getProcessComponentContext() );
     185             : 
     186             :         uno::Reference< frame::XFrame > xFrame =
     187           0 :             xFramesSupplier->getActiveFrame();
     188             : 
     189           0 :         if ( xFrame.is() )
     190             :         {
     191             :             uno::Reference< frame::XController > xController =
     192           0 :                 xFrame->getController();
     193             : 
     194           0 :             if ( xController.is() )
     195             :             {
     196             :                 uno::Reference< frame::XStorable > xStorable(
     197           0 :                     xController->getModel(), uno::UNO_QUERY );
     198           0 :                 isReadonly = xStorable->isReadonly();
     199           0 :             }
     200             :         }
     201             : 
     202           0 :         SetReadOnly( isReadonly );
     203           0 :         _SvxMacroTabPage::DisplayAppEvents( false );
     204             :     }
     205             : 
     206           0 :     mpImpl->pEventLB->SetUpdateMode( sal_True );
     207           0 :     return sal_True;
     208             : }
     209             : 
     210             : // -----------------------------------------------------------------------
     211             : 
     212           0 : sal_Bool SvxEventConfigPage::FillItemSet( SfxItemSet& rSet )
     213             : {
     214           0 :     return _SvxMacroTabPage::FillItemSet( rSet );
     215             : }
     216             : 
     217             : // -----------------------------------------------------------------------
     218             : 
     219           0 : void SvxEventConfigPage::Reset( const SfxItemSet& )
     220             : {
     221           0 :     _SvxMacroTabPage::Reset();
     222           3 : }
     223             : 
     224             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10