/************************************************************************* * * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: eventdlg.cxx,v $ * * $Revision: 1.14 $ * * last change: $Author: hr $ $Date: 2007-06-27 17:04:36 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. * * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2005 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ************************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" // include *************************************************************** #ifndef _SVEDIT_HXX //autogen #include #endif #ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP_ #include #endif #ifndef _COM_SUN_STAR_FRAME_XMODULEMANAGER_HPP_ #include #endif #include #ifndef _UNOTOOLS_CONFIGMGR_HXX_ #include #endif #include #include "eventdlg.hxx" #include #include #include #include #include #include #include #include #include #ifndef _HEADERTABLISTBOX_HXX #include "headertablistbox.hxx" #endif #ifndef _MACROPG_IMPL_HXX #include "macropg_impl.hxx" #endif #include #include #include "eventdlg.hrc" #include "helpid.hrc" #include "selector.hxx" #include "cfg.hxx" using ::rtl::OUString; using namespace ::com::sun::star; // ----------------------------------------------------------------------- SvxEventConfigPage::SvxEventConfigPage( Window* pParent, const SfxItemSet& rSet ) : _SvxMacroTabPage( pParent, SVX_RES(RID_SVXPAGE_EVENTS), rSet ), aSaveInText( this, SVX_RES( TXT_SAVEIN ) ), aSaveInListBox( this, SVX_RES( LB_SAVEIN ) ), bAppConfig ( TRUE ) { mpImpl->pStrEvent = new String( SVX_RES( STR_EVENT )); mpImpl->pAssignedMacro = new String( SVX_RES( STR_ASSMACRO )); mpImpl->pEventLB = new _HeaderTabListBox( this, SVX_RES( LB_EVENT )); mpImpl->pAssignFT = new FixedText( this, SVX_RES( FT_ASSIGN )); mpImpl->pAssignPB = new PushButton( this, SVX_RES( PB_ASSIGN )); mpImpl->pDeletePB = new PushButton( this, SVX_RES( PB_DELETE )); mpImpl->pMacroImg = new Image( SVX_RES( IMG_MACRO) ); mpImpl->pComponentImg = new Image( SVX_RES( IMG_COMPONENT) ); mpImpl->pMacroImg_h = new Image( SVX_RES( IMG_MACRO_H) ); mpImpl->pComponentImg_h = new Image( SVX_RES( IMG_COMPONENT_H) ); FreeResource(); // must be done after FreeResource is called InitResources(); mpImpl->pEventLB->GetListBox().SetHelpId( HID_SVX_MACRO_LB_EVENT ); aSaveInListBox.SetSelectHdl( LINK( this, SvxEventConfigPage, SelectHdl_Impl ) ); uno::Reference< document::XEventsSupplier > xSupplier; // xSupplier = uno::Reference< document::XEventsSupplier >( new GlobalEventConfig()); xSupplier = uno::Reference< document::XEventsSupplier > ( ::comphelper::getProcessServiceFactory()->createInstance( OUString::createFromAscii( "com.sun.star.frame.GlobalEventBroadcaster" ) ), uno::UNO_QUERY ); uno::Reference< container::XNameReplace > xEvents_app, xEvents_doc; USHORT nPos; if ( xSupplier.is() ) { xEvents_app = xSupplier->getEvents(); OUString label; utl::ConfigManager::GetDirectConfigProperty( utl::ConfigManager::PRODUCTNAME ) >>= label; nPos = aSaveInListBox.InsertEntry( label ); aSaveInListBox.SetEntryData( nPos, new bool(true) ); aSaveInListBox.SelectEntryPos( nPos, TRUE ); } uno::Reference< frame::XFramesSupplier > xFramesSupplier( ::comphelper::getProcessServiceFactory()->createInstance( OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ), uno::UNO_QUERY ); uno::Reference< frame::XModel > xModel; uno::Reference< frame::XFrame > xFrame = xFramesSupplier->getActiveFrame(); if ( xFrame.is() ) { // first establish if this type of application module // supports document configuration uno::Reference< ::com::sun::star::frame::XModuleManager > xModuleManager( ::comphelper::getProcessServiceFactory()->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" ) ) ), uno::UNO_QUERY ); OUString aModuleId; try{ aModuleId = xModuleManager->identify( xFrame ); } catch(const uno::Exception&) { aModuleId = ::rtl::OUString(); } if ( SvxConfigPage::CanConfig( aModuleId ) ) { uno::Reference< frame::XController > xController = xFrame->getController(); if ( xController.is() ) { xModel = xController->getModel(); } } } uno::Reference< util::XModifiable > xModifiable_doc; if ( xModel.is() ) { xSupplier = uno::Reference< document::XEventsSupplier >( xModel, uno::UNO_QUERY ); if ( xSupplier.is() ) { xEvents_doc = xSupplier->getEvents(); xModifiable_doc = uno::Reference< util::XModifiable >( xModel, uno::UNO_QUERY ); OUString aTitle; SvxScriptSelectorDialog::GetDocTitle( xModel, aTitle ); nPos = aSaveInListBox.InsertEntry( aTitle ); aSaveInListBox.SetEntryData( nPos, new bool(false) ); aSaveInListBox.SelectEntryPos( nPos, TRUE ); bAppConfig = false; } } InitAndSetHandler( xEvents_app, xEvents_doc, xModifiable_doc ); SelectHdl_Impl( NULL ); } // ----------------------------------------------------------------------- SvxEventConfigPage::~SvxEventConfigPage() { //DF Do I need to delete bools? } // ----------------------------------------------------------------------- IMPL_LINK( SvxEventConfigPage, SelectHdl_Impl, ListBox *, pBox ) { (void)pBox; bool* bApp = (bool*) aSaveInListBox.GetEntryData( aSaveInListBox.GetSelectEntryPos()); mpImpl->pEventLB->SetUpdateMode( FALSE ); bAppConfig = *bApp; if ( *bApp ) { SetReadOnly( FALSE ); _SvxMacroTabPage::DisplayAppEvents( true ); } else { bool isReadonly = FALSE; uno::Reference< frame::XFramesSupplier > xFramesSupplier( ::comphelper::getProcessServiceFactory()->createInstance( OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ), uno::UNO_QUERY ); uno::Reference< frame::XFrame > xFrame = xFramesSupplier->getActiveFrame(); if ( xFrame.is() ) { uno::Reference< frame::XController > xController = xFrame->getController(); if ( xController.is() ) { uno::Reference< frame::XStorable > xStorable( xController->getModel(), uno::UNO_QUERY ); isReadonly = xStorable->isReadonly(); } } SetReadOnly( isReadonly ); _SvxMacroTabPage::DisplayAppEvents( false ); } mpImpl->pEventLB->SetUpdateMode( TRUE ); return TRUE; } // ----------------------------------------------------------------------- BOOL SvxEventConfigPage::FillItemSet( SfxItemSet& rSet ) { return _SvxMacroTabPage::FillItemSet( rSet ); } // ----------------------------------------------------------------------- void SvxEventConfigPage::Reset( const SfxItemSet& ) { _SvxMacroTabPage::Reset(); }