LCOV - code coverage report
Current view: top level - cui/source/customize - eventdlg.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 87 0.0 %
Date: 2014-11-03 Functions: 0 10 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             :     // need to delete the user data
     107           0 :     SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
     108           0 :     SvTreeListEntry* pE = rListBox.GetEntry( 0 );
     109           0 :     while( pE )
     110             :     {
     111           0 :         OUString* pEventName = (OUString*)pE->GetUserData();
     112           0 :         delete pEventName;
     113           0 :         pE->SetUserData((void*)0);
     114           0 :         pE = rListBox.NextSibling( pE );
     115             :     }
     116           0 : }
     117             : 
     118           0 : void SvxEventConfigPage::ImplInitDocument()
     119             : {
     120           0 :     uno::Reference< frame::XFrame > xFrame( GetFrame() );
     121           0 :     OUString aModuleId = SvxConfigPage::GetFrameWithDefaultAndIdentify( xFrame );
     122           0 :     if ( !xFrame.is() )
     123           0 :         return;
     124             : 
     125             :     try
     126             :     {
     127           0 :         uno::Reference< frame::XModel > xModel;
     128           0 :         if ( !SvxConfigPage::CanConfig( aModuleId ) )
     129           0 :             return;
     130             : 
     131             :         uno::Reference< frame::XController > xController =
     132           0 :             xFrame->getController();
     133             : 
     134           0 :         if ( xController.is() )
     135             :         {
     136           0 :             xModel = xController->getModel();
     137             :         }
     138             : 
     139           0 :         if ( !xModel.is() )
     140           0 :             return;
     141             : 
     142           0 :         uno::Reference< document::XEventsSupplier > xSupplier( xModel, uno::UNO_QUERY );
     143             : 
     144           0 :         if ( xSupplier.is() )
     145             :         {
     146           0 :             m_xDocumentEvents = xSupplier->getEvents();
     147           0 :             m_xDocumentModifiable.set(xModel, css::uno::UNO_QUERY);
     148             : 
     149           0 :             OUString aTitle = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
     150           0 :             sal_uInt16 nPos = m_pSaveInListBox->InsertEntry( aTitle );
     151             : 
     152           0 :             m_pSaveInListBox->SetEntryData( nPos, new bool(false) );
     153           0 :             m_pSaveInListBox->SelectEntryPos( nPos, true );
     154             : 
     155           0 :             bAppConfig = false;
     156           0 :         }
     157             :     }
     158           0 :     catch( const uno::Exception& )
     159             :     {
     160             :         DBG_UNHANDLED_EXCEPTION();
     161           0 :     }
     162             : }
     163             : 
     164           0 : IMPL_LINK( SvxEventConfigPage, SelectHdl_Impl, ListBox *, pBox )
     165             : {
     166             :     (void)pBox;
     167             : 
     168             :     bool* bApp = (bool*) m_pSaveInListBox->GetEntryData(
     169           0 :             m_pSaveInListBox->GetSelectEntryPos());
     170             : 
     171           0 :     mpImpl->pEventLB->SetUpdateMode( false );
     172           0 :     bAppConfig = *bApp;
     173           0 :     if ( *bApp )
     174             :     {
     175           0 :         SetReadOnly( false );
     176           0 :         _SvxMacroTabPage::DisplayAppEvents( true );
     177             :     }
     178             :     else
     179             :     {
     180           0 :         bool isReadonly = false;
     181             : 
     182             :         uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create(
     183           0 :             ::comphelper::getProcessComponentContext() );
     184             : 
     185             :         uno::Reference< frame::XFrame > xFrame =
     186           0 :             xFramesSupplier->getActiveFrame();
     187             : 
     188           0 :         if ( xFrame.is() )
     189             :         {
     190             :             uno::Reference< frame::XController > xController =
     191           0 :                 xFrame->getController();
     192             : 
     193           0 :             if ( xController.is() )
     194             :             {
     195             :                 uno::Reference< frame::XStorable > xStorable(
     196           0 :                     xController->getModel(), uno::UNO_QUERY );
     197           0 :                 isReadonly = xStorable->isReadonly();
     198           0 :             }
     199             :         }
     200             : 
     201           0 :         SetReadOnly( isReadonly );
     202           0 :         _SvxMacroTabPage::DisplayAppEvents( false );
     203             :     }
     204             : 
     205           0 :     mpImpl->pEventLB->SetUpdateMode( true );
     206           0 :     return sal_True;
     207             : }
     208             : 
     209           0 : bool SvxEventConfigPage::FillItemSet( SfxItemSet* rSet )
     210             : {
     211           0 :     return _SvxMacroTabPage::FillItemSet( rSet );
     212           0 : }
     213             : 
     214             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10