LCOV - code coverage report
Current view: top level - cui/source/customize - eventdlg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 92 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 11 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 <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/theGlobalEventBroadcaster.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             : #include <svtools/treelistentry.hxx>
      43             : 
      44             : #include "headertablistbox.hxx"
      45             : #include "macropg_impl.hxx"
      46             : 
      47             : #include <dialmgr.hxx>
      48             : #include <cuires.hrc>
      49             : #include "helpid.hrc"
      50             : #include "selector.hxx"
      51             : #include "cfg.hxx"
      52             : 
      53             : 
      54             : using namespace ::com::sun::star;
      55             : 
      56             : 
      57           0 : SvxEventConfigPage::SvxEventConfigPage(vcl::Window *pParent, const SfxItemSet& rSet,
      58             :     SvxEventConfigPage::EarlyInit)
      59             :     : _SvxMacroTabPage(pParent, "EventsConfigPage",
      60             :         "cui/ui/eventsconfigpage.ui", rSet)
      61           0 :     , bAppConfig(true)
      62             : {
      63           0 :     get(m_pSaveInListBox, "savein");
      64             : 
      65           0 :     mpImpl->sStrEvent = get<FixedText>("eventft")->GetText();
      66           0 :     mpImpl->sAssignedMacro = get<FixedText>("actionft")->GetText();
      67           0 :     get(mpImpl->pEventLB, "events");
      68           0 :     Size aSize(LogicToPixel(Size(205, 229), MAP_APPFONT));
      69           0 :     mpImpl->pEventLB->set_width_request(aSize.Width());
      70           0 :     mpImpl->pEventLB->set_height_request(aSize.Height());
      71           0 :     get(mpImpl->pAssignPB, "macro");
      72           0 :     get(mpImpl->pDeletePB, "delete");
      73           0 :     mpImpl->aMacroImg = get<FixedImage>("macroimg")->GetImage();
      74           0 :     mpImpl->aComponentImg = get<FixedImage>("componentimg")->GetImage();
      75             : 
      76           0 :     InitResources();
      77             : 
      78             :     m_pSaveInListBox->SetSelectHdl( LINK( this, SvxEventConfigPage,
      79           0 :                 SelectHdl_Impl ) );
      80             : 
      81           0 :     uno::Reference< frame::XGlobalEventBroadcaster > xSupplier;
      82             : 
      83           0 :     xSupplier =
      84           0 :         frame::theGlobalEventBroadcaster::get(::comphelper::getProcessComponentContext());
      85             : 
      86           0 :     sal_uInt16 nPos(0);
      87           0 :     m_xAppEvents = xSupplier->getEvents();
      88             :     nPos = m_pSaveInListBox->InsertEntry(
      89           0 :         utl::ConfigManager::getProductName() );
      90           0 :     m_pSaveInListBox->SetEntryData( nPos, new bool(true) );
      91           0 :     m_pSaveInListBox->SelectEntryPos( nPos, true );
      92           0 : }
      93             : 
      94           0 : void SvxEventConfigPage::LateInit( const uno::Reference< frame::XFrame >& _rxFrame  )
      95             : {
      96           0 :     SetFrame( _rxFrame );
      97           0 :     ImplInitDocument();
      98             : 
      99           0 :     InitAndSetHandler( m_xAppEvents, m_xDocumentEvents, m_xDocumentModifiable );
     100             : 
     101           0 :     SelectHdl_Impl( NULL );
     102           0 : }
     103             : 
     104           0 : SvxEventConfigPage::~SvxEventConfigPage()
     105             : {
     106           0 :     disposeOnce();
     107           0 : }
     108             : 
     109           0 : void SvxEventConfigPage::dispose()
     110             : {
     111             :     // need to delete the user data
     112           0 :     SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
     113           0 :     SvTreeListEntry* pE = rListBox.GetEntry( 0 );
     114           0 :     while( pE )
     115             :     {
     116           0 :         OUString const * pEventName = static_cast<OUString const *>(pE->GetUserData());
     117           0 :         delete pEventName;
     118           0 :         pE->SetUserData(nullptr);
     119           0 :         pE = SvTreeListBox::NextSibling( pE );
     120             :     }
     121           0 :     m_pSaveInListBox.clear();
     122           0 :     _SvxMacroTabPage::dispose();
     123           0 : }
     124             : 
     125           0 : void SvxEventConfigPage::ImplInitDocument()
     126             : {
     127           0 :     uno::Reference< frame::XFrame > xFrame( GetFrame() );
     128           0 :     OUString aModuleId = SvxConfigPage::GetFrameWithDefaultAndIdentify( xFrame );
     129           0 :     if ( !xFrame.is() )
     130           0 :         return;
     131             : 
     132             :     try
     133             :     {
     134           0 :         uno::Reference< frame::XModel > xModel;
     135           0 :         if ( !SvxConfigPage::CanConfig( aModuleId ) )
     136           0 :             return;
     137             : 
     138             :         uno::Reference< frame::XController > xController =
     139           0 :             xFrame->getController();
     140             : 
     141           0 :         if ( xController.is() )
     142             :         {
     143           0 :             xModel = xController->getModel();
     144             :         }
     145             : 
     146           0 :         if ( !xModel.is() )
     147           0 :             return;
     148             : 
     149           0 :         uno::Reference< document::XEventsSupplier > xSupplier( xModel, uno::UNO_QUERY );
     150             : 
     151           0 :         if ( xSupplier.is() )
     152             :         {
     153           0 :             m_xDocumentEvents = xSupplier->getEvents();
     154           0 :             m_xDocumentModifiable.set(xModel, css::uno::UNO_QUERY);
     155             : 
     156           0 :             OUString aTitle = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
     157           0 :             sal_uInt16 nPos = m_pSaveInListBox->InsertEntry( aTitle );
     158             : 
     159           0 :             m_pSaveInListBox->SetEntryData( nPos, new bool(false) );
     160           0 :             m_pSaveInListBox->SelectEntryPos( nPos, true );
     161             : 
     162           0 :             bAppConfig = false;
     163           0 :         }
     164             :     }
     165           0 :     catch( const uno::Exception& )
     166             :     {
     167             :         DBG_UNHANDLED_EXCEPTION();
     168           0 :     }
     169             : }
     170             : 
     171           0 : IMPL_LINK( SvxEventConfigPage, SelectHdl_Impl, ListBox *, pBox )
     172             : {
     173             :     (void)pBox;
     174             : 
     175             :     bool* bApp = static_cast<bool*>(m_pSaveInListBox->GetEntryData(
     176           0 :             m_pSaveInListBox->GetSelectEntryPos()));
     177             : 
     178           0 :     mpImpl->pEventLB->SetUpdateMode( false );
     179           0 :     bAppConfig = *bApp;
     180           0 :     if ( *bApp )
     181             :     {
     182           0 :         SetReadOnly( false );
     183           0 :         _SvxMacroTabPage::DisplayAppEvents( true );
     184             :     }
     185             :     else
     186             :     {
     187           0 :         bool isReadonly = false;
     188             : 
     189             :         uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create(
     190           0 :             ::comphelper::getProcessComponentContext() );
     191             : 
     192             :         uno::Reference< frame::XFrame > xFrame =
     193           0 :             xFramesSupplier->getActiveFrame();
     194             : 
     195           0 :         if ( xFrame.is() )
     196             :         {
     197             :             uno::Reference< frame::XController > xController =
     198           0 :                 xFrame->getController();
     199             : 
     200           0 :             if ( xController.is() )
     201             :             {
     202             :                 uno::Reference< frame::XStorable > xStorable(
     203           0 :                     xController->getModel(), uno::UNO_QUERY );
     204           0 :                 isReadonly = xStorable->isReadonly();
     205           0 :             }
     206             :         }
     207             : 
     208           0 :         SetReadOnly( isReadonly );
     209           0 :         _SvxMacroTabPage::DisplayAppEvents( false );
     210             :     }
     211             : 
     212           0 :     mpImpl->pEventLB->SetUpdateMode( true );
     213           0 :     return sal_IntPtr(true);
     214             : }
     215             : 
     216           0 : bool SvxEventConfigPage::FillItemSet( SfxItemSet* rSet )
     217             : {
     218           0 :     return _SvxMacroTabPage::FillItemSet( rSet );
     219           0 : }
     220             : 
     221             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11