2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-10-04 11:25:41 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
#include <svtools/svmedit.hxx>
|
|
|
|
#include <tools/diagnose_ex.h>
|
|
|
|
#include <com/sun/star/document/XEventsSupplier.hpp>
|
2012-12-14 12:58:00 +02:00
|
|
|
#include <com/sun/star/frame/Desktop.hpp>
|
2014-01-16 16:06:33 +01:00
|
|
|
#include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
|
2009-10-31 00:36:06 +01:00
|
|
|
#include <com/sun/star/frame/XModuleManager.hpp>
|
|
|
|
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <comphelper/documentinfo.hxx>
|
|
|
|
#include <unotools/configmgr.hxx>
|
|
|
|
#include <rtl/ustring.hxx>
|
|
|
|
|
|
|
|
#include "eventdlg.hxx"
|
|
|
|
|
|
|
|
#include <sfx2/viewfrm.hxx>
|
|
|
|
#include <sfx2/evntconf.hxx>
|
|
|
|
#include <sfx2/minfitem.hxx>
|
|
|
|
#include <sfx2/app.hxx>
|
|
|
|
#include <sfx2/objsh.hxx>
|
|
|
|
#include <sfx2/docfac.hxx>
|
|
|
|
#include <sfx2/fcontnr.hxx>
|
|
|
|
#include <unotools/eventcfg.hxx>
|
2014-01-30 20:16:12 -05:00
|
|
|
#include <svtools/treelistentry.hxx>
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
#include "headertablistbox.hxx"
|
|
|
|
#include "macropg_impl.hxx"
|
|
|
|
|
2009-11-02 20:49:14 +01:00
|
|
|
#include <dialmgr.hxx>
|
|
|
|
#include <cuires.hrc>
|
2009-10-31 00:36:06 +01:00
|
|
|
#include "helpid.hrc"
|
|
|
|
#include "selector.hxx"
|
|
|
|
#include "cfg.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
SvxEventConfigPage::SvxEventConfigPage(vcl::Window *pParent, const SfxItemSet& rSet,
|
2014-03-07 10:48:02 +00:00
|
|
|
SvxEventConfigPage::EarlyInit)
|
|
|
|
: _SvxMacroTabPage(pParent, "EventsConfigPage",
|
|
|
|
"cui/ui/eventsconfigpage.ui", rSet)
|
|
|
|
, bAppConfig(true)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2014-03-07 10:48:02 +00:00
|
|
|
get(m_pSaveInListBox, "savein");
|
|
|
|
|
|
|
|
mpImpl->sStrEvent = get<FixedText>("eventft")->GetText();
|
|
|
|
mpImpl->sAssignedMacro = get<FixedText>("actionft")->GetText();
|
|
|
|
get(mpImpl->pEventLB, "events");
|
|
|
|
Size aSize(LogicToPixel(Size(205, 229), MAP_APPFONT));
|
|
|
|
mpImpl->pEventLB->set_width_request(aSize.Width());
|
|
|
|
mpImpl->pEventLB->set_height_request(aSize.Height());
|
|
|
|
get(mpImpl->pAssignPB, "macro");
|
|
|
|
get(mpImpl->pDeletePB, "delete");
|
|
|
|
mpImpl->aMacroImg = get<FixedImage>("macroimg")->GetImage();
|
|
|
|
mpImpl->aComponentImg = get<FixedImage>("componentimg")->GetImage();
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2014-03-07 10:48:02 +00:00
|
|
|
InitResources();
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2014-03-07 10:48:02 +00:00
|
|
|
m_pSaveInListBox->SetSelectHdl( LINK( this, SvxEventConfigPage,
|
2009-10-31 00:36:06 +01:00
|
|
|
SelectHdl_Impl ) );
|
|
|
|
|
2012-09-27 10:19:04 +02:00
|
|
|
uno::Reference< frame::XGlobalEventBroadcaster > xSupplier;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2012-09-27 10:19:04 +02:00
|
|
|
xSupplier =
|
2014-01-16 16:06:33 +01:00
|
|
|
frame::theGlobalEventBroadcaster::get(::comphelper::getProcessComponentContext());
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nPos(0);
|
2012-09-07 15:14:55 +02:00
|
|
|
m_xAppEvents = xSupplier->getEvents();
|
2014-03-07 10:48:02 +00:00
|
|
|
nPos = m_pSaveInListBox->InsertEntry(
|
2012-09-07 15:14:55 +02:00
|
|
|
utl::ConfigManager::getProductName() );
|
2014-03-07 10:48:02 +00:00
|
|
|
m_pSaveInListBox->SetEntryData( nPos, new bool(true) );
|
|
|
|
m_pSaveInListBox->SelectEntryPos( nPos, true );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvxEventConfigPage::LateInit( const uno::Reference< frame::XFrame >& _rxFrame )
|
|
|
|
{
|
|
|
|
SetFrame( _rxFrame );
|
|
|
|
ImplInitDocument();
|
|
|
|
|
|
|
|
InitAndSetHandler( m_xAppEvents, m_xDocumentEvents, m_xDocumentModifiable );
|
|
|
|
|
|
|
|
SelectHdl_Impl( NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
SvxEventConfigPage::~SvxEventConfigPage()
|
2015-01-15 15:47:39 +02:00
|
|
|
{
|
2015-03-10 09:07:06 +02:00
|
|
|
disposeOnce();
|
2015-01-15 15:47:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvxEventConfigPage::dispose()
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2014-01-30 20:16:12 -05:00
|
|
|
// need to delete the user data
|
|
|
|
SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
|
|
|
|
SvTreeListEntry* pE = rListBox.GetEntry( 0 );
|
|
|
|
while( pE )
|
|
|
|
{
|
2015-03-28 19:00:29 +01:00
|
|
|
OUString const * pEventName = static_cast<OUString const *>(pE->GetUserData());
|
2014-01-30 20:16:12 -05:00
|
|
|
delete pEventName;
|
|
|
|
pE->SetUserData((void*)0);
|
2015-04-07 16:18:28 +02:00
|
|
|
pE = SvTreeListBox::NextSibling( pE );
|
2014-01-30 20:16:12 -05:00
|
|
|
}
|
2015-03-09 14:29:30 +02:00
|
|
|
m_pSaveInListBox.clear();
|
2015-01-15 15:47:39 +02:00
|
|
|
_SvxMacroTabPage::dispose();
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SvxEventConfigPage::ImplInitDocument()
|
|
|
|
{
|
|
|
|
uno::Reference< frame::XFrame > xFrame( GetFrame() );
|
|
|
|
OUString aModuleId = SvxConfigPage::GetFrameWithDefaultAndIdentify( xFrame );
|
|
|
|
if ( !xFrame.is() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< frame::XModel > xModel;
|
|
|
|
if ( !SvxConfigPage::CanConfig( aModuleId ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
uno::Reference< frame::XController > xController =
|
|
|
|
xFrame->getController();
|
|
|
|
|
|
|
|
if ( xController.is() )
|
|
|
|
{
|
|
|
|
xModel = xController->getModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !xModel.is() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
uno::Reference< document::XEventsSupplier > xSupplier( xModel, uno::UNO_QUERY );
|
|
|
|
|
|
|
|
if ( xSupplier.is() )
|
|
|
|
{
|
|
|
|
m_xDocumentEvents = xSupplier->getEvents();
|
2014-06-13 17:49:24 +02:00
|
|
|
m_xDocumentModifiable.set(xModel, css::uno::UNO_QUERY);
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
OUString aTitle = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
|
2014-03-07 10:48:02 +00:00
|
|
|
sal_uInt16 nPos = m_pSaveInListBox->InsertEntry( aTitle );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2014-03-07 10:48:02 +00:00
|
|
|
m_pSaveInListBox->SetEntryData( nPos, new bool(false) );
|
|
|
|
m_pSaveInListBox->SelectEntryPos( nPos, true );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
bAppConfig = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const uno::Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( SvxEventConfigPage, SelectHdl_Impl, ListBox *, pBox )
|
|
|
|
{
|
|
|
|
(void)pBox;
|
|
|
|
|
2015-03-28 19:00:29 +01:00
|
|
|
bool* bApp = static_cast<bool*>(m_pSaveInListBox->GetEntryData(
|
|
|
|
m_pSaveInListBox->GetSelectEntryPos()));
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2014-02-21 12:53:51 +01:00
|
|
|
mpImpl->pEventLB->SetUpdateMode( false );
|
2009-10-31 00:36:06 +01:00
|
|
|
bAppConfig = *bApp;
|
|
|
|
if ( *bApp )
|
|
|
|
{
|
2014-04-16 11:39:08 +02:00
|
|
|
SetReadOnly( false );
|
2009-10-31 00:36:06 +01:00
|
|
|
_SvxMacroTabPage::DisplayAppEvents( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-28 20:02:43 +01:00
|
|
|
bool isReadonly = false;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2012-12-14 12:58:00 +02:00
|
|
|
uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create(
|
|
|
|
::comphelper::getProcessComponentContext() );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2014-02-21 12:53:51 +01:00
|
|
|
mpImpl->pEventLB->SetUpdateMode( true );
|
2015-05-08 09:36:09 +02:00
|
|
|
return sal_IntPtr(true);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2014-06-10 17:23:12 +02:00
|
|
|
bool SvxEventConfigPage::FillItemSet( SfxItemSet* rSet )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
return _SvxMacroTabPage::FillItemSet( rSet );
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|