cc5db648bc
* commit 'ooo/DEV300_m101': (185 commits) masterfix DEV300: #i10000# usage of L10N build_type masterfix: #i10000# INT16 -> sal_Int16 fixed compile errors after resync to m100, part2 gridsort: post-rebase fixes CWS gnumake3: found another tools integer type removetooltypes01: Fix build problems after rebase to DEV300m99 in basctl, cui, reportdesign, sw native359: #i114398# changing mac langpack icon native359: #i115669# fixing package description for solaris packages gnumake3: remove comphelper version; fix including extract.hxx locales34: #i106785# add Haitian_Haiti [ht-HT] to language list and locale data; locale data contributed by <jcpoulard> sb138: #i116659# timely termination of OnLogRotateThread accfixes: removed include of obsolete header file accfixes: removed obsolete file removetooltypes01: #i112600# Fix build problems on non-pro accfixes: moved some shared strings to svx part2 accfixes: moved some shared strings to svx accfixes: added more accessibility information and fixed tab orders in multiple dialogs (cui module) removetooltypes01: #i112600# Remove tools types for Mac specific parts fixed tab order in BasicIDE, Library dialog tab page added some accessible names in BasicIDE ... Conflicts: UnoControls/source/base/registercontrols.cxx accessibility/inc/accessibility/standard/vclxaccessiblelistboxlist.hxx automation/inc/automation/communi.hxx automation/inc/automation/simplecm.hxx automation/source/communi/communi.cxx automation/source/inc/rcontrol.hxx automation/source/miniapp/servuid.hxx automation/source/server/XMLParser.cxx automation/source/server/cmdbasestream.cxx automation/source/server/profiler.hxx automation/source/server/recorder.cxx automation/source/server/retstrm.hxx automation/source/server/server.cxx automation/source/server/sta_list.cxx automation/source/server/statemnt.cxx automation/source/server/statemnt.hxx automation/source/simplecm/packethandler.cxx automation/source/simplecm/simplecm.cxx automation/source/simplecm/tcpio.cxx automation/source/simplecm/tcpio.hxx automation/source/testtool/comm_bas.hxx automation/source/testtool/cretstrm.hxx automation/source/testtool/httprequest.cxx automation/source/testtool/httprequest.hxx automation/source/testtool/objtest.cxx automation/source/testtool/objtest.hxx basctl/source/basicide/baside2.cxx basctl/source/basicide/baside2.hxx basctl/source/basicide/baside2b.cxx basctl/source/basicide/baside3.cxx basctl/source/basicide/basides1.cxx basctl/source/basicide/basides2.cxx basctl/source/basicide/basidesh.cxx basctl/source/basicide/basidesh.src basctl/source/basicide/basobj3.cxx basctl/source/basicide/bastype2.cxx basctl/source/basicide/bastype3.cxx basctl/source/basicide/bastypes.cxx basctl/source/basicide/brkdlg.cxx basctl/source/basicide/iderdll.cxx basctl/source/basicide/macrodlg.cxx basctl/source/basicide/moduldl2.cxx basctl/source/basicide/moduldlg.cxx basctl/source/basicide/objdlg.cxx basctl/source/basicide/scriptdocument.cxx basctl/source/basicide/tbxctl.cxx basctl/source/basicide/tbxctl.hxx basctl/source/basicide/tbxctl.src basctl/source/dlged/dlged.cxx basctl/source/dlged/dlgedfunc.cxx basctl/source/dlged/dlgedobj.cxx basctl/source/inc/basidesh.hxx basctl/source/inc/bastypes.hxx basctl/source/inc/dlgedmod.hxx basctl/source/inc/dlgedpage.hxx crashrep/prj/build.lst cui/inc/pch/precompiled_cui.hxx cui/source/customize/acccfg.cxx cui/source/customize/acccfg.hrc cui/source/customize/acccfg.src cui/source/customize/cfg.cxx cui/source/customize/cfgutil.cxx cui/source/customize/macropg.cxx cui/source/customize/macropg.src cui/source/customize/selector.cxx cui/source/dialogs/SpellDialog.cxx cui/source/dialogs/commonlingui.cxx cui/source/dialogs/cuicharmap.cxx cui/source/dialogs/cuifmsearch.cxx cui/source/dialogs/cuigaldlg.cxx cui/source/dialogs/cuigrfflt.cxx cui/source/dialogs/hldocntp.cxx cui/source/dialogs/hldoctp.cxx cui/source/dialogs/hlinettp.cxx cui/source/dialogs/hlmailtp.cxx cui/source/dialogs/hlmarkwn.cxx cui/source/dialogs/hlmarkwn.src cui/source/dialogs/hltpbase.cxx cui/source/dialogs/iconcdlg.cxx cui/source/dialogs/passwdomdlg.cxx cui/source/dialogs/pastedlg.cxx cui/source/dialogs/scriptdlg.cxx cui/source/dialogs/thesdlg.cxx cui/source/dialogs/zoom.cxx cui/source/factory/dlgfact.hxx cui/source/inc/SpellDialog.hxx cui/source/inc/autocdlg.hxx cui/source/inc/backgrnd.hxx cui/source/inc/bbdlg.hxx cui/source/inc/cfg.hxx cui/source/inc/cfgutil.hxx cui/source/inc/cuigaldlg.hxx cui/source/inc/cuigrfflt.hxx cui/source/inc/cuitabarea.hxx cui/source/inc/cuitabline.hxx cui/source/inc/hldocntp.hxx cui/source/inc/hltpbase.hxx cui/source/inc/iconcdlg.hxx cui/source/inc/numpages.hxx cui/source/inc/page.hxx cui/source/inc/postdlg.hxx cui/source/inc/scriptdlg.hxx cui/source/inc/transfrm.hxx cui/source/inc/zoom.hxx cui/source/options/cfgchart.cxx cui/source/options/cuisrchdlg.cxx cui/source/options/dbregister.cxx cui/source/options/dbregister.src cui/source/options/fontsubs.cxx cui/source/options/internationaloptions.cxx cui/source/options/optasian.cxx cui/source/options/optchart.cxx cui/source/options/optcolor.cxx cui/source/options/optcolor.src cui/source/options/optfltr.cxx cui/source/options/optfltr.src cui/source/options/optgdlg.cxx cui/source/options/optgdlg.src cui/source/options/optgenrl.cxx cui/source/options/opthtml.cxx cui/source/options/optimprove.cxx cui/source/options/optinet2.cxx cui/source/options/optinet2.hxx cui/source/options/optjava.cxx cui/source/options/optlingu.cxx cui/source/options/optsave.cxx cui/source/options/optsave.hxx cui/source/options/treeopt.cxx cui/source/options/webconninfo.cxx cui/source/tabpages/autocdlg.cxx cui/source/tabpages/backgrnd.cxx cui/source/tabpages/border.cxx cui/source/tabpages/chardlg.cxx cui/source/tabpages/dstribut.cxx cui/source/tabpages/grfpage.cxx cui/source/tabpages/macroass.cxx cui/source/tabpages/measure.cxx cui/source/tabpages/numfmt.cxx cui/source/tabpages/numpages.cxx cui/source/tabpages/page.cxx cui/source/tabpages/paragrph.cxx cui/source/tabpages/swpossizetabpage.cxx cui/source/tabpages/tabarea.src cui/source/tabpages/textanim.cxx cui/source/tabpages/textattr.cxx cui/source/tabpages/tparea.cxx cui/source/tabpages/tpbitmap.cxx cui/source/tabpages/tpcolor.cxx cui/source/tabpages/tpgradnt.cxx cui/source/tabpages/tphatch.cxx cui/source/tabpages/tpline.cxx cui/source/tabpages/tplnedef.cxx cui/source/tabpages/tplneend.cxx cui/source/tabpages/tpshadow.cxx cui/source/tabpages/transfrm.cxx embedserv/source/embed/register.cxx extensions/inc/pch/precompiled_extensions.hxx extensions/inc/propctrlr.hrc extensions/source/abpilot/abpservices.cxx extensions/source/bibliography/bibload.cxx extensions/source/bibliography/datman.cxx extensions/source/bibliography/general.cxx extensions/source/dbpilots/dbpservices.cxx extensions/source/inc/componentmodule.cxx extensions/source/nsplugin/source/so_env.cxx extensions/source/ole/oleobjw.cxx extensions/source/ole/oleobjw.hxx extensions/source/oooimprovement/invite_job.cxx extensions/source/oooimprovement/onlogrotate_job.cxx extensions/source/plugin/base/service.cxx extensions/source/plugin/inc/plugin/unx/mediator.hxx extensions/source/plugin/inc/plugin/unx/plugcon.hxx extensions/source/plugin/unx/mediator.cxx extensions/source/plugin/unx/nppapi.cxx extensions/source/plugin/unx/plugcon.cxx extensions/source/preload/services.cxx extensions/source/propctrlr/formmetadata.cxx extensions/source/propctrlr/pcrservices.cxx extensions/source/resource/resource.cxx extensions/source/scanner/sane.hxx extensions/source/scanner/sanedlg.cxx extensions/source/scanner/scanunx.cxx extensions/source/scanner/scanwin.cxx extensions/source/scanner/twain.cxx extensions/source/scanner/twain.hxx extensions/source/update/check/updatecheckconfig.cxx extensions/test/stm/datatest.cxx extensions/test/stm/marktest.cxx extensions/test/stm/pipetest.cxx extensions/test/stm/testfactreg.cxx extensions/workben/testpgp.cxx forms/qa/complex/forms/CheckOGroupBoxModel.java forms/qa/makefile.mk forms/source/component/Button.cxx forms/source/component/Button.hxx forms/source/component/ListBox.cxx forms/source/inc/forms_module_impl.hxx forms/source/misc/services.cxx forms/source/solar/control/navtoolbar.cxx javainstaller2/prj/build.lst javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java lingucomponent/prj/build.lst lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx lingucomponent/source/spellcheck/spell/sreg.cxx lingucomponent/source/spellcheck/spell/sspellimp.cxx package/source/manifest/ManifestExport.cxx package/source/manifest/UnoRegister.cxx package/source/xstor/owriteablestream.cxx package/source/xstor/owriteablestream.hxx package/source/xstor/xstorage.hxx package/source/zippackage/ZipPackageFolder.cxx package/source/zippackage/ZipPackageStream.cxx setup_native/source/mac/ooo/DS_Store setup_native/source/win32/customactions/shellextensions/registerextensions.cxx xmlsecurity/prj/build.lst xmlsecurity/source/component/registerservices.cxx xmlsecurity/source/dialogs/stbcontrl.cxx xmlsecurity/source/framework/xsec_framework.cxx xmlsecurity/source/xmlsec/xsec_xmlsec.cxx xmlsecurity/tools/demo/util.hxx xmlsecurity/workben/signaturetest.cxx
501 lines
16 KiB
C++
501 lines
16 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*************************************************************************
|
|
*
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
*
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
|
*
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
*
|
|
* This file is part of OpenOffice.org.
|
|
*
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
* only, as published by the Free Software Foundation.
|
|
*
|
|
* OpenOffice.org 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 version 3 for more details
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
* <http://www.openoffice.org/license.html>
|
|
* for a copy of the LGPLv3 License.
|
|
*
|
|
************************************************************************/
|
|
|
|
#define ITEMID_MACRO 0
|
|
#include <svl/macitem.hxx>
|
|
#undef ITEMID_MACRO
|
|
|
|
#include "macroass.hxx"
|
|
|
|
#include <basic/basmgr.hxx>
|
|
#include <dialmgr.hxx>
|
|
#include <svx/dialogs.hrc>
|
|
#define _SVSTDARR_STRINGSDTOR
|
|
#include <svl/svstdarr.hxx>
|
|
|
|
#include <svtools/svmedit.hxx>
|
|
#include "cfgutil.hxx"
|
|
#include <sfx2/app.hxx>
|
|
#include <sfx2/evntconf.hxx>
|
|
#include <sfx2/objsh.hxx>
|
|
#include "macroass.hrc"
|
|
#include "cuires.hrc"
|
|
#include <vcl/fixed.hxx>
|
|
#include "headertablistbox.hxx"
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
using ::com::sun::star::frame::XFrame;
|
|
|
|
class _SfxMacroTabPage_Impl
|
|
{
|
|
public:
|
|
_SfxMacroTabPage_Impl( void );
|
|
~_SfxMacroTabPage_Impl();
|
|
|
|
String maStaticMacroLBLabel;
|
|
PushButton* pAssignPB;
|
|
PushButton* pDeletePB;
|
|
String* pStrEvent;
|
|
String* pAssignedMacro;
|
|
_HeaderTabListBox* pEventLB;
|
|
SfxConfigGroupListBox_Impl* pGroupLB;
|
|
FixedText* pFT_MacroLBLabel;
|
|
SfxConfigFunctionListBox_Impl* pMacroLB;
|
|
|
|
FixedText* pMacroFT;
|
|
String* pMacroStr;
|
|
|
|
sal_Bool bReadOnly;
|
|
Timer maFillGroupTimer;
|
|
sal_Bool bGotEvents;
|
|
};
|
|
|
|
_SfxMacroTabPage_Impl::_SfxMacroTabPage_Impl( void ) :
|
|
pAssignPB( NULL ),
|
|
pDeletePB( NULL ),
|
|
pStrEvent( NULL ),
|
|
pAssignedMacro( NULL ),
|
|
pEventLB( NULL ),
|
|
pGroupLB( NULL ),
|
|
pFT_MacroLBLabel( NULL ),
|
|
pMacroLB( NULL ),
|
|
pMacroFT( NULL ),
|
|
pMacroStr( NULL ),
|
|
bReadOnly( sal_False ),
|
|
bGotEvents( sal_False )
|
|
{
|
|
}
|
|
|
|
_SfxMacroTabPage_Impl::~_SfxMacroTabPage_Impl()
|
|
{
|
|
delete pAssignPB;
|
|
delete pDeletePB;
|
|
delete pStrEvent;
|
|
delete pAssignedMacro;
|
|
delete pEventLB;
|
|
delete pGroupLB;
|
|
delete pMacroLB;
|
|
delete pFT_MacroLBLabel;
|
|
delete pMacroFT;
|
|
delete pMacroStr;
|
|
}
|
|
|
|
|
|
static sal_uInt16 aPageRg[] = {
|
|
SID_ATTR_MACROITEM, SID_ATTR_MACROITEM,
|
|
0
|
|
};
|
|
|
|
// Achtung im Code wird dieses Array direkt (0, 1, ...) indiziert
|
|
static long nTabs[] =
|
|
{
|
|
2, // Number of Tabs
|
|
0, 90
|
|
};
|
|
|
|
#define TAB_WIDTH_MIN 10
|
|
|
|
// IDs for items in HeaderBar of EventLB
|
|
#define ITEMID_EVENT 1
|
|
#define ITMEID_ASSMACRO 2
|
|
|
|
|
|
#define LB_EVENTS_ITEMPOS 1
|
|
#define LB_MACROS_ITEMPOS 2
|
|
|
|
String ConvertToUIName_Impl( SvxMacro *pMacro )
|
|
{
|
|
String aName( pMacro->GetMacName() );
|
|
String aEntry;
|
|
if ( ! pMacro->GetLanguage().EqualsAscii("JavaScript") )
|
|
{
|
|
sal_uInt16 nCount = aName.GetTokenCount('.');
|
|
aEntry = aName.GetToken( nCount-1, '.' );
|
|
if ( nCount > 2 )
|
|
{
|
|
aEntry += '(';
|
|
aEntry += aName.GetToken( 0, '.' );
|
|
aEntry += '.';
|
|
aEntry += aName.GetToken( nCount-2, '.' );
|
|
aEntry += ')';
|
|
}
|
|
return aEntry;
|
|
}
|
|
else
|
|
return aName;
|
|
}
|
|
|
|
void _SfxMacroTabPage::EnableButtons()
|
|
{
|
|
// Solange die Eventbox leer ist, nichts tun
|
|
const SvLBoxEntry* pE = mpImpl->pEventLB->GetListBox().FirstSelected();
|
|
if ( pE )
|
|
{
|
|
// Gebundenes Macro holen
|
|
const SvxMacro* pM = aTbl.Get( (sal_uInt16)(sal_uLong) pE->GetUserData() );
|
|
mpImpl->pDeletePB->Enable( 0 != pM && !mpImpl->bReadOnly );
|
|
|
|
String sEventMacro;
|
|
sEventMacro = ((SvLBoxString*)pE->GetItem( LB_MACROS_ITEMPOS ))->GetText();
|
|
|
|
String sScriptURI = mpImpl->pMacroLB->GetSelectedScriptURI();
|
|
mpImpl->pAssignPB->Enable( !mpImpl->bReadOnly && !sScriptURI.EqualsIgnoreCaseAscii( sEventMacro ) );
|
|
}
|
|
else
|
|
mpImpl->pAssignPB->Enable( sal_False );
|
|
}
|
|
|
|
_SfxMacroTabPage::_SfxMacroTabPage( Window* pParent, const ResId& rResId, const SfxItemSet& rAttrSet )
|
|
: SfxTabPage( pParent, rResId, rAttrSet )
|
|
|
|
{
|
|
mpImpl = new _SfxMacroTabPage_Impl;
|
|
}
|
|
|
|
_SfxMacroTabPage::~_SfxMacroTabPage()
|
|
{
|
|
DELETEZ( mpImpl );
|
|
}
|
|
|
|
void _SfxMacroTabPage::AddEvent( const String & rEventName, sal_uInt16 nEventId )
|
|
{
|
|
String sTmp( rEventName );
|
|
sTmp += '\t';
|
|
|
|
// falls die Tabelle schon gueltig ist
|
|
SvxMacro* pM = aTbl.Get( nEventId );
|
|
if( pM )
|
|
{
|
|
String sNew( ConvertToUIName_Impl( pM ) );
|
|
sTmp += sNew;
|
|
}
|
|
|
|
SvLBoxEntry* pE = mpImpl->pEventLB->GetListBox().InsertEntry( sTmp );
|
|
pE->SetUserData( reinterpret_cast< void* >( sal::static_int_cast< sal_IntPtr >( nEventId )) );
|
|
}
|
|
|
|
void _SfxMacroTabPage::ScriptChanged()
|
|
{
|
|
// neue Bereiche und deren Funktionen besorgen
|
|
{
|
|
mpImpl->pGroupLB->Show();
|
|
mpImpl->pMacroLB->Show();
|
|
mpImpl->pMacroFT->SetText( *mpImpl->pMacroStr );
|
|
}
|
|
|
|
EnableButtons();
|
|
}
|
|
|
|
sal_Bool _SfxMacroTabPage::FillItemSet( SfxItemSet& rSet )
|
|
{
|
|
SvxMacroItem aItem( GetWhich( aPageRg[0] ) );
|
|
((SvxMacroTableDtor&)aItem.GetMacroTable()) = aTbl;
|
|
|
|
const SfxPoolItem* pItem;
|
|
if( SFX_ITEM_SET != GetItemSet().GetItemState( aItem.Which(), sal_True, &pItem )
|
|
|| aItem != *(SvxMacroItem*)pItem )
|
|
{
|
|
rSet.Put( aItem );
|
|
return sal_True;
|
|
}
|
|
return sal_False;
|
|
}
|
|
|
|
void _SfxMacroTabPage::PageCreated (SfxAllItemSet aSet)
|
|
{
|
|
const SfxPoolItem* pEventsItem;
|
|
if( !mpImpl->bGotEvents && SFX_ITEM_SET == aSet.GetItemState( SID_EVENTCONFIG, sal_True, &pEventsItem ) )
|
|
{
|
|
mpImpl->bGotEvents = sal_True;
|
|
const SfxEventNamesList& rList = ((SfxEventNamesItem*)pEventsItem)->GetEvents();
|
|
for ( size_t nNo = 0, nCnt = rList.size(); nNo < nCnt; ++nNo )
|
|
{
|
|
const SfxEventName *pOwn = rList.at(nNo);
|
|
AddEvent( pOwn->maUIName, pOwn->mnId );
|
|
}
|
|
}
|
|
}
|
|
|
|
void _SfxMacroTabPage::Reset( const SfxItemSet& rSet )
|
|
{
|
|
const SfxPoolItem* pItem;
|
|
if( SFX_ITEM_SET == rSet.GetItemState( GetWhich( aPageRg[0] ), sal_True, &pItem ))
|
|
aTbl = ((SvxMacroItem*)pItem)->GetMacroTable();
|
|
|
|
const SfxPoolItem* pEventsItem;
|
|
if( !mpImpl->bGotEvents && SFX_ITEM_SET == rSet.GetItemState( SID_EVENTCONFIG, sal_True, &pEventsItem ) )
|
|
{
|
|
mpImpl->bGotEvents = sal_True;
|
|
const SfxEventNamesList& rList = ((SfxEventNamesItem*)pEventsItem)->GetEvents();
|
|
for ( size_t nNo = 0, nCnt = rList.size(); nNo < nCnt; ++nNo )
|
|
{
|
|
const SfxEventName *pOwn = rList.at(nNo);
|
|
AddEvent( pOwn->maUIName, pOwn->mnId );
|
|
}
|
|
}
|
|
|
|
FillEvents();
|
|
|
|
SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
|
|
SvLBoxEntry* pE = rListBox.GetEntry( 0 );
|
|
if( pE )
|
|
rListBox.SetCurEntry( pE );
|
|
}
|
|
|
|
sal_Bool _SfxMacroTabPage::IsReadOnly() const
|
|
{
|
|
return mpImpl->bReadOnly;
|
|
}
|
|
|
|
IMPL_STATIC_LINK( _SfxMacroTabPage, SelectEvent_Impl, SvTabListBox*, EMPTYARG )
|
|
{
|
|
_SfxMacroTabPage_Impl* pImpl = pThis->mpImpl;
|
|
SvHeaderTabListBox& rListBox = pImpl->pEventLB->GetListBox();
|
|
SvLBoxEntry* pE = rListBox.FirstSelected();
|
|
sal_uLong nPos;
|
|
if( !pE || LISTBOX_ENTRY_NOTFOUND ==
|
|
( nPos = rListBox.GetModel()->GetAbsPos( pE ) ) )
|
|
{
|
|
DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" );
|
|
return 0;
|
|
}
|
|
|
|
pThis->ScriptChanged();
|
|
pThis->EnableButtons();
|
|
return 0;
|
|
}
|
|
|
|
IMPL_STATIC_LINK( _SfxMacroTabPage, SelectGroup_Impl, ListBox*, EMPTYARG )
|
|
{
|
|
_SfxMacroTabPage_Impl* pImpl = pThis->mpImpl;
|
|
String sSel( pImpl->pGroupLB->GetGroup() );
|
|
pImpl->pGroupLB->GroupSelected();
|
|
const String sScriptURI = pImpl->pMacroLB->GetSelectedScriptURI();
|
|
String aLabelText;
|
|
if( sScriptURI.Len() > 0 )
|
|
aLabelText = pImpl->maStaticMacroLBLabel;
|
|
pImpl->pFT_MacroLBLabel->SetText( aLabelText );
|
|
|
|
pThis->EnableButtons();
|
|
return 0;
|
|
}
|
|
|
|
IMPL_STATIC_LINK( _SfxMacroTabPage, SelectMacro_Impl, ListBox*, EMPTYARG )
|
|
{
|
|
_SfxMacroTabPage_Impl* pImpl = pThis->mpImpl;
|
|
pImpl->pMacroLB->FunctionSelected();
|
|
pThis->EnableButtons();
|
|
return 0;
|
|
}
|
|
|
|
IMPL_STATIC_LINK( _SfxMacroTabPage, AssignDeleteHdl_Impl, PushButton*, pBtn )
|
|
{
|
|
_SfxMacroTabPage_Impl* pImpl = pThis->mpImpl;
|
|
SvHeaderTabListBox& rListBox = pImpl->pEventLB->GetListBox();
|
|
SvLBoxEntry* pE = rListBox.FirstSelected();
|
|
sal_uLong nPos;
|
|
if( !pE || LISTBOX_ENTRY_NOTFOUND ==
|
|
( nPos = rListBox.GetModel()->GetAbsPos( pE ) ) )
|
|
{
|
|
DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" );
|
|
return 0;
|
|
}
|
|
|
|
const sal_Bool bAssEnabled = pBtn != pImpl->pDeletePB && pImpl->pAssignPB->IsEnabled();
|
|
|
|
// aus der Tabelle entfernen
|
|
sal_uInt16 nEvent = (sal_uInt16)(sal_uLong)pE->GetUserData();
|
|
SvxMacro *pRemoveMacro = pThis->aTbl.Remove( nEvent );
|
|
delete pRemoveMacro;
|
|
|
|
String sScriptURI;
|
|
if( bAssEnabled )
|
|
{
|
|
sScriptURI = pImpl->pMacroLB->GetSelectedScriptURI();
|
|
if( sScriptURI.CompareToAscii( "vnd.sun.star.script:", 20 ) == COMPARE_EQUAL )
|
|
{
|
|
pThis->aTbl.Insert(
|
|
nEvent, new SvxMacro( sScriptURI, String::CreateFromAscii( SVX_MACRO_LANGUAGE_SF ) ) );
|
|
}
|
|
else
|
|
{
|
|
OSL_ENSURE( false, "_SfxMacroTabPage::AssignDeleteHdl_Impl: this branch is *not* dead? (out of interest: tell fs, please!)" );
|
|
pThis->aTbl.Insert(
|
|
nEvent, new SvxMacro( sScriptURI, String::CreateFromAscii( SVX_MACRO_LANGUAGE_STARBASIC ) ) );
|
|
}
|
|
}
|
|
|
|
pImpl->pEventLB->SetUpdateMode( sal_False );
|
|
pE->ReplaceItem( new SvLBoxString( pE, 0, sScriptURI ), LB_MACROS_ITEMPOS );
|
|
rListBox.GetModel()->InvalidateEntry( pE );
|
|
rListBox.Select( pE );
|
|
rListBox.MakeVisible( pE );
|
|
rListBox.SetUpdateMode( sal_True );
|
|
|
|
pThis->EnableButtons();
|
|
return 0;
|
|
}
|
|
|
|
IMPL_STATIC_LINK( _SfxMacroTabPage, TimeOut_Impl, Timer*, EMPTYARG )
|
|
{
|
|
// FillMacroList() can take a long time -> show wait cursor and disable input
|
|
SfxTabDialog* pTabDlg = pThis->GetTabDialog();
|
|
// perhaps the tabpage is part of a SingleTabDialog then pTabDlg == NULL
|
|
if ( pTabDlg )
|
|
{
|
|
pTabDlg->EnterWait();
|
|
pTabDlg->EnableInput( sal_False );
|
|
}
|
|
pThis->FillMacroList();
|
|
if ( pTabDlg )
|
|
{
|
|
pTabDlg->EnableInput( sal_True );
|
|
pTabDlg->LeaveWait();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void _SfxMacroTabPage::InitAndSetHandler()
|
|
{
|
|
// Handler installieren
|
|
SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
|
|
HeaderBar& rHeaderBar = mpImpl->pEventLB->GetHeaderBar();
|
|
Link aLnk(STATIC_LINK(this, _SfxMacroTabPage, AssignDeleteHdl_Impl ));
|
|
mpImpl->pMacroLB->SetDoubleClickHdl( aLnk );
|
|
mpImpl->pDeletePB->SetClickHdl( aLnk );
|
|
mpImpl->pAssignPB->SetClickHdl( aLnk );
|
|
rListBox.SetDoubleClickHdl( aLnk );
|
|
|
|
rListBox.SetSelectHdl( STATIC_LINK( this, _SfxMacroTabPage, SelectEvent_Impl ));
|
|
mpImpl->pGroupLB->SetSelectHdl( STATIC_LINK( this, _SfxMacroTabPage, SelectGroup_Impl ));
|
|
mpImpl->pMacroLB->SetSelectHdl( STATIC_LINK( this, _SfxMacroTabPage, SelectMacro_Impl ));
|
|
|
|
rListBox.SetSelectionMode( SINGLE_SELECTION );
|
|
rListBox.SetTabs( &nTabs[0], MAP_APPFONT );
|
|
Size aSize( nTabs[ 2 ], 0 );
|
|
rHeaderBar.InsertItem( ITEMID_EVENT, *mpImpl->pStrEvent, LogicToPixel( aSize, MapMode( MAP_APPFONT ) ).Width() );
|
|
aSize.Width() = 1764; // don't know what, so 42^2 is best to use...
|
|
rHeaderBar.InsertItem( ITMEID_ASSMACRO, *mpImpl->pAssignedMacro, LogicToPixel( aSize, MapMode( MAP_APPFONT ) ).Width() );
|
|
rListBox.SetSpaceBetweenEntries( 0 );
|
|
|
|
mpImpl->pEventLB->Show();
|
|
mpImpl->pEventLB->ConnectElements();
|
|
|
|
mpImpl->pEventLB->Enable( sal_True );
|
|
mpImpl->pGroupLB->Enable( sal_True );
|
|
mpImpl->pMacroLB->Enable( sal_True );
|
|
|
|
mpImpl->pGroupLB->SetFunctionListBox( mpImpl->pMacroLB );
|
|
|
|
mpImpl->maFillGroupTimer.SetTimeoutHdl( STATIC_LINK( this, _SfxMacroTabPage, TimeOut_Impl ) );
|
|
mpImpl->maFillGroupTimer.SetTimeout( 0 );
|
|
mpImpl->maFillGroupTimer.Start();
|
|
}
|
|
|
|
void _SfxMacroTabPage::FillMacroList()
|
|
{
|
|
mpImpl->pGroupLB->Init(
|
|
::com::sun::star::uno::Reference<
|
|
::com::sun::star::lang::XMultiServiceFactory >(),
|
|
GetFrame(),
|
|
::rtl::OUString() );
|
|
}
|
|
|
|
void _SfxMacroTabPage::FillEvents()
|
|
{
|
|
SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
|
|
|
|
sal_uLong nEntryCnt = rListBox.GetEntryCount();
|
|
|
|
// Events aus der Tabelle holen und die EventListBox entsprechen fuellen
|
|
for( sal_uLong n = 0 ; n < nEntryCnt ; ++n )
|
|
{
|
|
SvLBoxEntry* pE = rListBox.GetEntry( n );
|
|
if( pE )
|
|
{
|
|
SvLBoxString* pLItem = ( SvLBoxString* ) pE->GetItem( LB_MACROS_ITEMPOS );
|
|
DBG_ASSERT( pLItem && SV_ITEM_ID_LBOXSTRING == pLItem->IsA(), "_SfxMacroTabPage::FillEvents(): no LBoxString" );
|
|
|
|
String sOld( pLItem->GetText() );
|
|
String sNew;
|
|
sal_uInt16 nEventId = ( sal_uInt16 ) ( sal_uLong ) pE->GetUserData();
|
|
if( aTbl.IsKeyValid( nEventId ) )
|
|
sNew = ConvertToUIName_Impl( aTbl.Get( nEventId ) );
|
|
|
|
if( sOld != sNew )
|
|
{
|
|
pE->ReplaceItem( new SvLBoxString( pE, 0, sNew ), LB_MACROS_ITEMPOS );
|
|
rListBox.GetModel()->InvalidateEntry( pE );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SfxMacroTabPage::SfxMacroTabPage( Window* pParent, const ResId& rResId, const Reference< XFrame >& rxDocumentFrame, const SfxItemSet& rSet )
|
|
: _SfxMacroTabPage( pParent, rResId, rSet )
|
|
{
|
|
mpImpl->pStrEvent = new String( CUI_RES( STR_EVENT ) );
|
|
mpImpl->pAssignedMacro = new String( CUI_RES( STR_ASSMACRO ) );
|
|
mpImpl->pEventLB = new _HeaderTabListBox( this, CUI_RES( LB_EVENT ) );
|
|
mpImpl->pAssignPB = new PushButton( this, CUI_RES( PB_ASSIGN ) );
|
|
mpImpl->pDeletePB = new PushButton( this, CUI_RES( PB_DELETE ) );
|
|
mpImpl->pMacroFT = new FixedText( this, CUI_RES( FT_MACRO ) );
|
|
mpImpl->pGroupLB = new SfxConfigGroupListBox_Impl( this, CUI_RES( LB_GROUP ) );
|
|
mpImpl->pFT_MacroLBLabel = new FixedText( this, CUI_RES( FT_LABEL4LB_MACROS ) );
|
|
mpImpl->maStaticMacroLBLabel= mpImpl->pFT_MacroLBLabel->GetText();
|
|
mpImpl->pMacroLB = new SfxConfigFunctionListBox_Impl( this, CUI_RES( LB_MACROS ) );
|
|
mpImpl->pMacroStr = new String( CUI_RES( STR_MACROS ) );
|
|
|
|
FreeResource();
|
|
|
|
SetFrame( rxDocumentFrame );
|
|
|
|
InitAndSetHandler();
|
|
|
|
ScriptChanged();
|
|
}
|
|
|
|
SfxTabPage* SfxMacroTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
|
|
{
|
|
return new SfxMacroTabPage( pParent, CUI_RES( RID_SVXPAGE_EVENTASSIGN ), NULL, rAttrSet );
|
|
}
|
|
|
|
SfxMacroAssignDlg::SfxMacroAssignDlg( Window* pParent, const Reference< XFrame >& rxDocumentFrame, const SfxItemSet& rSet )
|
|
: SfxSingleTabDialog( pParent, rSet, 0 )
|
|
{
|
|
SfxTabPage* pPage = SfxMacroTabPage::Create( this, rSet );
|
|
pPage->SetFrame( rxDocumentFrame );
|
|
SetTabPage( pPage );
|
|
}
|
|
|
|
SfxMacroAssignDlg::~SfxMacroAssignDlg()
|
|
{
|
|
}
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|