1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: macropg.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #define ITEMID_MACRO 0
35 #include <svtools/macitem.hxx>
38 #include "macroass.hxx"
40 #include <basic/basmgr.hxx>
41 #include <svx/dialmgr.hxx>
43 #define _SVSTDARR_STRINGSDTOR
44 #include <svtools/svstdarr.hxx>
46 #include <svtools/svmedit.hxx>
47 #include "cfgutil.hxx"
48 #include <sfx2/app.hxx>
49 #include <sfx2/objsh.hxx>
50 #include "macroass.hrc"
51 #include "svx/dialogs.hrc"
52 #include <sfx2/macrconf.hxx>
53 #include "headertablistbox.hxx"
55 using ::com::sun::star::uno::Reference
;
56 using ::com::sun::star::frame::XFrame
;
58 class _SfxMacroTabPage_Impl
61 _SfxMacroTabPage_Impl( void );
62 ~_SfxMacroTabPage_Impl();
64 String maStaticMacroLBLabel
;
65 PushButton
* pAssignPB
;
66 PushButton
* pDeletePB
;
68 String
* pAssignedMacro
;
69 ListBox
* pScriptTypeLB
;
70 _HeaderTabListBox
* pEventLB
;
71 SfxConfigGroupListBox_Impl
* pGroupLB
;
72 FixedText
* pFT_MacroLBLabel
;
73 SfxConfigFunctionListBox_Impl
* pMacroLB
;
77 FNGetRangeHdl fnGetRange
;
78 FNGetMacrosOfRangeHdl fnGetMacroOfRange
;
81 Timer maFillGroupTimer
;
85 _SfxMacroTabPage_Impl::_SfxMacroTabPage_Impl( void ) :
89 pAssignedMacro( NULL
),
90 pScriptTypeLB( NULL
),
93 pFT_MacroLBLabel( NULL
),
98 fnGetMacroOfRange( NULL
),
104 _SfxMacroTabPage_Impl::~_SfxMacroTabPage_Impl()
109 delete pAssignedMacro
;
110 delete pScriptTypeLB
;
114 delete pFT_MacroLBLabel
;
120 SvStringsDtor
* _ImpGetRangeHdl( _SfxMacroTabPage
*, const String
& rLanguage
);
121 SvStringsDtor
* _ImpGetMacrosOfRangeHdl( _SfxMacroTabPage
*, const String
& rLanguage
, const String
& rRange
);
123 static USHORT __FAR_DATA aPageRg
[] = {
124 SID_ATTR_MACROITEM
, SID_ATTR_MACROITEM
,
128 // Achtung im Code wird dieses Array direkt (0, 1, ...) indiziert
129 static long nTabs
[] =
135 #define TAB_WIDTH_MIN 10
137 // IDs for items in HeaderBar of EventLB
138 #define ITEMID_EVENT 1
139 #define ITMEID_ASSMACRO 2
142 #define LB_EVENTS_ITEMPOS 1
143 #define LB_MACROS_ITEMPOS 2
145 String
ConvertToUIName_Impl( SvxMacro
*pMacro
, const String
& /*rLanguage*/ )
147 String
aName( pMacro
->GetMacName() );
149 if ( ! pMacro
->GetLanguage().EqualsAscii("JavaScript") )
151 USHORT nCount
= aName
.GetTokenCount('.');
152 aEntry
= aName
.GetToken( nCount
-1, '.' );
156 aEntry
+= aName
.GetToken( 0, '.' );
158 aEntry
+= aName
.GetToken( nCount
-2, '.' );
167 void _SfxMacroTabPage::EnableButtons( const String
& rLangName
)
169 // Solange die Eventbox leer ist, nichts tun
170 const SvLBoxEntry
* pE
= mpImpl
->pEventLB
->GetListBox().FirstSelected();
173 // Gebundenes Macro holen
174 const SvxMacro
* pM
= aTbl
.Get( (USHORT
)(ULONG
) pE
->GetUserData() );
175 mpImpl
->pDeletePB
->Enable( 0 != pM
&& !mpImpl
->bReadOnly
);
177 // Bei gleichem ScriptType Zuweisung nur, wenn Macro sich
178 // ge"andert hat; bei verschiedenem ScriptType, wenn Script nicht leer
180 sEventMacro
= ((SvLBoxString
*)pE
->GetItem( LB_MACROS_ITEMPOS
))->GetText();
181 if ( rLangName
.EqualsAscii("JavaScript") )
183 DBG_ERROR( "_SfxMacroTabPage::EnableButtons(): this is not an up to date usage!" );
187 SfxMacroInfo
* pInfo
= mpImpl
->pMacroLB
->GetMacroInfo();
190 sSelMacro
= pInfo
->GetMacroName();
191 if( pM
&& rLangName
!= pM
->GetLanguage() )
192 mpImpl
->pAssignPB
->Enable( pInfo
!= 0 && !mpImpl
->bReadOnly
);
194 mpImpl
->pAssignPB
->Enable( pInfo
&& !mpImpl
->bReadOnly
&& !sSelMacro
.EqualsIgnoreCaseAscii( sEventMacro
) );
199 _SfxMacroTabPage::_SfxMacroTabPage( Window
* pParent
, const ResId
& rResId
, const SfxItemSet
& rAttrSet
)
200 : SfxTabPage( pParent
, rResId
, rAttrSet
)
203 mpImpl
= new _SfxMacroTabPage_Impl
;
204 mpImpl
->fnGetRange
= &_ImpGetRangeHdl
;
205 mpImpl
->fnGetMacroOfRange
= &_ImpGetMacrosOfRangeHdl
;
208 _SfxMacroTabPage::~_SfxMacroTabPage()
213 void _SfxMacroTabPage::AddEvent( const String
& rEventName
, USHORT nEventId
)
215 String
sTmp( rEventName
);
218 // falls die Tabelle schon gueltig ist
219 SvxMacro
* pM
= aTbl
.Get( nEventId
);
222 String
sNew( ConvertToUIName_Impl( pM
, mpImpl
->pScriptTypeLB
->GetSelectEntry() ) );
226 SvLBoxEntry
* pE
= mpImpl
->pEventLB
->GetListBox().InsertEntry( sTmp
);
227 pE
->SetUserData( reinterpret_cast< void* >( sal::static_int_cast
< sal_IntPtr
>( nEventId
)) );
230 void _SfxMacroTabPage::ScriptChanged( const String
& aLangName
)
232 // neue Bereiche und deren Funktionen besorgen
234 mpImpl
->pGroupLB
->SetScriptType( aLangName
);
235 mpImpl
->pGroupLB
->Show();
236 mpImpl
->pMacroLB
->Show();
237 mpImpl
->pMacroFT
->SetText( *mpImpl
->pMacroStr
);
240 EnableButtons( aLangName
);
243 void _SfxMacroTabPage::SetGetRangeLink( FNGetRangeHdl pFn
)
245 mpImpl
->fnGetRange
= pFn
;
248 FNGetRangeHdl
_SfxMacroTabPage::GetGetRangeLink() const
250 return mpImpl
->fnGetRange
;
253 void _SfxMacroTabPage::SetGetMacrosOfRangeLink( FNGetMacrosOfRangeHdl pFn
)
255 mpImpl
->fnGetMacroOfRange
= pFn
;
258 FNGetMacrosOfRangeHdl
_SfxMacroTabPage::GetGetMacrosOfRangeLink() const
260 return mpImpl
->fnGetMacroOfRange
;
263 BOOL
_SfxMacroTabPage::FillItemSet( SfxItemSet
& rSet
)
265 SvxMacroItem
aItem( GetWhich( aPageRg
[0] ) );
266 ((SvxMacroTableDtor
&)aItem
.GetMacroTable()) = aTbl
;
268 const SfxPoolItem
* pItem
;
269 if( SFX_ITEM_SET
!= GetItemSet().GetItemState( aItem
.Which(), TRUE
, &pItem
)
270 || aItem
!= *(SvxMacroItem
*)pItem
)
278 void _SfxMacroTabPage::PageCreated (SfxAllItemSet aSet
)
280 const SfxPoolItem
* pEventsItem
;
281 if( !mpImpl
->bGotEvents
&& SFX_ITEM_SET
== aSet
.GetItemState( SID_EVENTCONFIG
, TRUE
, &pEventsItem
) )
283 mpImpl
->bGotEvents
= TRUE
;
284 const SfxEventNamesList
& rList
= ((SfxEventNamesItem
*)pEventsItem
)->GetEvents();
285 for ( USHORT nNo
= 0; nNo
< rList
.Count(); ++nNo
)
287 const SfxEventName
*pOwn
= rList
.GetObject(nNo
);
288 AddEvent( pOwn
->maUIName
, pOwn
->mnId
);
293 void _SfxMacroTabPage::Reset( const SfxItemSet
& rSet
)
295 const SfxPoolItem
* pItem
;
296 if( SFX_ITEM_SET
== rSet
.GetItemState( GetWhich( aPageRg
[0] ), TRUE
, &pItem
))
297 aTbl
= ((SvxMacroItem
*)pItem
)->GetMacroTable();
299 const SfxPoolItem
* pEventsItem
;
300 if( !mpImpl
->bGotEvents
&& SFX_ITEM_SET
== rSet
.GetItemState( SID_EVENTCONFIG
, TRUE
, &pEventsItem
) )
302 mpImpl
->bGotEvents
= TRUE
;
303 const SfxEventNamesList
& rList
= ((SfxEventNamesItem
*)pEventsItem
)->GetEvents();
304 for ( USHORT nNo
= 0; nNo
< rList
.Count(); ++nNo
)
306 const SfxEventName
*pOwn
= rList
.GetObject(nNo
);
307 AddEvent( pOwn
->maUIName
, pOwn
->mnId
);
313 SvHeaderTabListBox
& rListBox
= mpImpl
->pEventLB
->GetListBox();
314 SvLBoxEntry
* pE
= rListBox
.GetEntry( 0 );
316 rListBox
.SetCurEntry( pE
);
319 void _SfxMacroTabPage::SetReadOnly( BOOL bSet
)
321 mpImpl
->bReadOnly
= bSet
;
324 BOOL
_SfxMacroTabPage::IsReadOnly() const
326 return mpImpl
->bReadOnly
;
329 IMPL_STATIC_LINK( _SfxMacroTabPage
, SelectEvent_Impl
, SvTabListBox
*, EMPTYARG
)
331 _SfxMacroTabPage_Impl
* pImpl
= pThis
->mpImpl
;
332 SvHeaderTabListBox
& rListBox
= pImpl
->pEventLB
->GetListBox();
333 SvLBoxEntry
* pE
= rListBox
.FirstSelected();
335 if( !pE
|| LISTBOX_ENTRY_NOTFOUND
==
336 ( nPos
= rListBox
.GetModel()->GetAbsPos( pE
) ) )
338 DBG_ASSERT( pE
, "wo kommt der leere Eintrag her?" );
342 USHORT nEventId
= (USHORT
)(ULONG
)pE
->GetUserData();
343 String aLanguage
= pImpl
->pScriptTypeLB
->GetSelectEntry();
345 const SvxMacro
* pM
= pThis
->aTbl
.Get( nEventId
);
348 if( aLanguage
!= pM
->GetLanguage() )
350 pImpl
->pScriptTypeLB
->SelectEntry( pM
->GetLanguage() );
351 pThis
->ScriptChanged( pM
->GetLanguage() );
355 DBG_ASSERT( !aLanguage
.EqualsAscii("JavaScript"), "_SfxMacroTabPage, SelectEvent_Impl(): outdated use!" );
359 pThis
->EnableButtons( aLanguage
);
363 IMPL_STATIC_LINK( _SfxMacroTabPage
, SelectGroup_Impl
, ListBox
*, EMPTYARG
)
365 _SfxMacroTabPage_Impl
* pImpl
= pThis
->mpImpl
;
366 String
sSel( pImpl
->pGroupLB
->GetGroup() );
367 String aLanguage
= pImpl
->pScriptTypeLB
->GetSelectEntry();
368 if( !aLanguage
.EqualsAscii( "JavaScript" ) )
370 pImpl
->pGroupLB
->GroupSelected();
371 SfxMacroInfo
* pMacro
= pImpl
->pMacroLB
->GetMacroInfo();
375 aLabelText
= pImpl
->maStaticMacroLBLabel
;
376 aLabelText
+= pMacro
->GetModuleName();
380 // Wenn dort ein Macro drin ist, wurde es selektiert und der
381 // AssignButton schon in SelectMacro richtig enabled
382 pImpl
->pAssignPB
->Enable( FALSE
);
385 pImpl
->pFT_MacroLBLabel
->SetText( aLabelText
);
390 IMPL_STATIC_LINK( _SfxMacroTabPage
, SelectMacro_Impl
, ListBox
*, EMPTYARG
)
392 _SfxMacroTabPage_Impl
* pImpl
= pThis
->mpImpl
;
393 pImpl
->pMacroLB
->FunctionSelected();
394 pThis
->EnableButtons( pImpl
->pScriptTypeLB
->GetSelectEntry() );
398 IMPL_STATIC_LINK( _SfxMacroTabPage
, GetFocus_Impl
, Edit
*, EMPTYARG
)
400 pThis
->EnableButtons( DEFINE_CONST_UNICODE("JavaScript") );
404 IMPL_STATIC_LINK( _SfxMacroTabPage
, AssignDeleteHdl_Impl
, PushButton
*, pBtn
)
406 _SfxMacroTabPage_Impl
* pImpl
= pThis
->mpImpl
;
407 SvHeaderTabListBox
& rListBox
= pImpl
->pEventLB
->GetListBox();
408 SvLBoxEntry
* pE
= rListBox
.FirstSelected();
410 if( !pE
|| LISTBOX_ENTRY_NOTFOUND
==
411 ( nPos
= rListBox
.GetModel()->GetAbsPos( pE
) ) )
413 DBG_ASSERT( pE
, "wo kommt der leere Eintrag her?" );
417 const BOOL bAssEnabled
= pBtn
!= pImpl
->pDeletePB
&& pImpl
->pAssignPB
->IsEnabled();
419 // aus der Tabelle entfernen
420 USHORT nEvent
= (USHORT
)(ULONG
)pE
->GetUserData();
421 SvxMacro
*pRemoveMacro
= pThis
->aTbl
.Remove( nEvent
);
424 String aLanguage
= pImpl
->pScriptTypeLB
->GetSelectEntry();
430 String
aEntryText( sNew
);
431 DBG_ASSERT( !aLanguage
.EqualsAscii("JavaScript"), "_SfxMacroTabPage, AssignDeleteHdl_Impl(): outdated use!" );
433 SfxMacroInfo
* pMacro
= pImpl
->pMacroLB
->GetMacroInfo();
434 sMacro
= pMacro
->GetQualifiedName();
435 sGroup
= pImpl
->pGroupLB
->GetGroup();
436 sNew
= pMacro
->GetMacroName();
438 if( sMacro
.CompareToAscii( "vnd.sun.star.script:", 20 ) == COMPARE_EQUAL
)
440 OSL_TRACE("ASSIGN_DELETE: Its a script");
442 nEvent
, new SvxMacro( sMacro
, String::CreateFromAscii("Script") ) );
446 OSL_TRACE("ASSIGN_DELETE: Its a basic macro");
447 String sBasicName
/*(SfxResId(STR_BASICNAME))*/;
448 if ( aLanguage
== sBasicName
)
449 pThis
->aTbl
.Insert( nEvent
, new SvxMacro( sMacro
, sGroup
, STARBASIC
) );
451 pThis
->aTbl
.Insert( nEvent
, new SvxMacro( sMacro
, aLanguage
) );
455 pImpl
->pEventLB
->SetUpdateMode( FALSE
);
456 pE
->ReplaceItem( new SvLBoxString( pE
, 0, sNew
), LB_MACROS_ITEMPOS
);
457 rListBox
.GetModel()->InvalidateEntry( pE
);
458 rListBox
.Select( pE
);
459 rListBox
.MakeVisible( pE
);
460 rListBox
.SetUpdateMode( TRUE
);
462 pThis
->EnableButtons( aLanguage
);
466 IMPL_STATIC_LINK( _SfxMacroTabPage
, ChangeScriptHdl_Impl
, RadioButton
*, EMPTYARG
)
468 pThis
->ScriptChanged( pThis
->mpImpl
->pScriptTypeLB
->GetSelectEntry() );
472 IMPL_STATIC_LINK( _SfxMacroTabPage
, TimeOut_Impl
, Timer
*, EMPTYARG
)
474 // FillMacroList() can take a long time -> show wait cursor and disable input
475 SfxTabDialog
* pTabDlg
= pThis
->GetTabDialog();
476 // perhaps the tabpage is part of a SingleTabDialog then pTabDlg == NULL
479 pTabDlg
->EnterWait();
480 pTabDlg
->EnableInput( FALSE
);
482 pThis
->FillMacroList();
485 pTabDlg
->EnableInput( TRUE
);
486 pTabDlg
->LeaveWait();
491 void _SfxMacroTabPage::InitAndSetHandler()
493 // Handler installieren
494 SvHeaderTabListBox
& rListBox
= mpImpl
->pEventLB
->GetListBox();
495 HeaderBar
& rHeaderBar
= mpImpl
->pEventLB
->GetHeaderBar();
496 Link
aLnk(STATIC_LINK(this, _SfxMacroTabPage
, AssignDeleteHdl_Impl
));
497 mpImpl
->pMacroLB
->SetDoubleClickHdl( aLnk
);
498 mpImpl
->pDeletePB
->SetClickHdl( aLnk
);
499 mpImpl
->pAssignPB
->SetClickHdl( aLnk
);
500 rListBox
.SetDoubleClickHdl( aLnk
);
502 rListBox
.SetSelectHdl( STATIC_LINK( this, _SfxMacroTabPage
, SelectEvent_Impl
));
503 mpImpl
->pGroupLB
->SetSelectHdl( STATIC_LINK( this, _SfxMacroTabPage
, SelectGroup_Impl
));
504 mpImpl
->pMacroLB
->SetSelectHdl( STATIC_LINK( this, _SfxMacroTabPage
, SelectMacro_Impl
));
506 mpImpl
->pScriptTypeLB
->SetSelectHdl( STATIC_LINK( this, _SfxMacroTabPage
, ChangeScriptHdl_Impl
));
508 rListBox
.SetSelectionMode( SINGLE_SELECTION
);
509 rListBox
.SetTabs( &nTabs
[0], MAP_APPFONT
);
510 Size
aSize( nTabs
[ 2 ], 0 );
511 rHeaderBar
.InsertItem( ITEMID_EVENT
, *mpImpl
->pStrEvent
, LogicToPixel( aSize
, MapMode( MAP_APPFONT
) ).Width() );
512 aSize
.Width() = 1764; // don't know what, so 42^2 is best to use...
513 rHeaderBar
.InsertItem( ITMEID_ASSMACRO
, *mpImpl
->pAssignedMacro
, LogicToPixel( aSize
, MapMode( MAP_APPFONT
) ).Width() );
514 rListBox
.SetSpaceBetweenEntries( 0 );
516 mpImpl
->pEventLB
->Show();
517 mpImpl
->pEventLB
->ConnectElements();
519 mpImpl
->pEventLB
->Enable( TRUE
);
520 mpImpl
->pGroupLB
->Enable( TRUE
);
521 mpImpl
->pMacroLB
->Enable( TRUE
);
523 mpImpl
->pScriptTypeLB
->SetDropDownLineCount( 3 );
524 String sBasicName
/*(SfxResId(STR_BASICNAME))*/;
525 mpImpl
->pScriptTypeLB
->InsertEntry( sBasicName
);
526 mpImpl
->pScriptTypeLB
->SelectEntry( sBasicName
);
528 mpImpl
->pGroupLB
->SetFunctionListBox( mpImpl
->pMacroLB
);
530 mpImpl
->maFillGroupTimer
.SetTimeoutHdl( STATIC_LINK( this, _SfxMacroTabPage
, TimeOut_Impl
) );
531 mpImpl
->maFillGroupTimer
.SetTimeout( 0 );
532 mpImpl
->maFillGroupTimer
.Start();
535 void _SfxMacroTabPage::FillMacroList()
537 String aLanguage
= mpImpl
->pScriptTypeLB
->GetSelectEntry();
538 if( ! aLanguage
.EqualsAscii("JavaScript") )
541 SvStringsDtor
* pArr
= (*mpImpl
->fnGetRange
)( this, String(/*SfxResId(STR_BASICNAME)*/) );
544 mpImpl
->pGroupLB
->Init(
545 ::com::sun::star::uno::Reference
<
546 ::com::sun::star::lang::XMultiServiceFactory
>(),
555 void _SfxMacroTabPage::FillEvents()
557 SvHeaderTabListBox
& rListBox
= mpImpl
->pEventLB
->GetListBox();
559 String aLanguage
= mpImpl
->pScriptTypeLB
->GetSelectEntry();
560 ULONG nEntryCnt
= rListBox
.GetEntryCount();
562 // Events aus der Tabelle holen und die EventListBox entsprechen fuellen
563 for( ULONG n
= 0 ; n
< nEntryCnt
; ++n
)
565 SvLBoxEntry
* pE
= rListBox
.GetEntry( n
);
568 SvLBoxString
* pLItem
= ( SvLBoxString
* ) pE
->GetItem( LB_MACROS_ITEMPOS
);
569 DBG_ASSERT( pLItem
&& SV_ITEM_ID_LBOXSTRING
== pLItem
->IsA(), "_SfxMacroTabPage::FillEvents(): no LBoxString" );
571 String
sOld( pLItem
->GetText() );
573 USHORT nEventId
= ( USHORT
) ( ULONG
) pE
->GetUserData();
574 if( aTbl
.IsKeyValid( nEventId
) )
575 sNew
= ConvertToUIName_Impl( aTbl
.Get( nEventId
), aLanguage
);
579 pE
->ReplaceItem( new SvLBoxString( pE
, 0, sNew
), LB_MACROS_ITEMPOS
);
580 rListBox
.GetModel()->InvalidateEntry( pE
);
586 void _SfxMacroTabPage::SelectEvent( const String
& /*rEventName*/, USHORT nEventId
)
588 SvHeaderTabListBox
& rListBox
= mpImpl
->pEventLB
->GetListBox();
589 ULONG nEntryCnt
= rListBox
.GetEntryCount();
591 for( ULONG n
= 0 ; n
< nEntryCnt
; ++n
)
593 SvLBoxEntry
* pE
= rListBox
.GetEntry( n
);
594 if( pE
&& ( USHORT
) ( ULONG
) pE
->GetUserData() == nEventId
)
596 rListBox
.SetCurEntry( pE
);
597 rListBox
.MakeVisible( pE
);
604 SvStringsDtor
* __EXPORT
_ImpGetRangeHdl( _SfxMacroTabPage
* /*pTbPg*/, const String
& rLanguage
)
606 SvStringsDtor
* pNew
= new SvStringsDtor
;
607 SfxApplication
* pSfxApp
= SFX_APP();
609 if ( !rLanguage
.EqualsAscii("JavaScript") )
611 pSfxApp
->EnterBasicCall();
613 // AppBasic einf"ugen
614 String
* pNewEntry
= new String( pSfxApp
->GetName() );
615 pNew
->Insert( pNewEntry
, pNew
->Count() );
617 // Aktuelles Dokument
618 SfxObjectShell
* pDoc
= SfxObjectShell::Current();
621 String aTitle
= pDoc
->GetTitle();
623 // Hack f"ur Aufruf aus der Basic-IDE : das Basic ermitteln, das
624 // gerade bearbeitet wird
626 String
aAppName(DEFINE_CONST_UNICODE("BASIC - "));
627 USHORT nLen
= aAppName
.Len();
628 if ( aTitle
.CompareIgnoreCaseToAscii( aAppName
, nLen
) == COMPARE_EQUAL
)
630 // Basic-Namensprefix entfernen
631 aTitle
.Erase( 0, nLen
);
632 USHORT nIndex
=0, nCount
=aTitle
.GetTokenCount('.');
635 // Namen der Library entfernen
636 aTitle
.GetToken( nCount
-2, '.', nIndex
);
637 aTitle
.Erase( nIndex
-1 );
640 // Wenn das App-Basic gerade in der Basic-IDE bearbeitet wird, kein
641 // Dokument verwenden
642 pDoc
= SfxObjectShell::GetFirst();
645 if ( aTitle
== pDoc
->GetTitle() )
647 pDoc
= SfxObjectShell::GetNext( *pDoc
);
651 if ( pDoc
&& pDoc
->GetBasicManager() != SFX_APP()->GetBasicManager() &&
652 pDoc
->GetBasicManager()->GetLibCount() )
654 pNewEntry
= new String( aTitle
);
655 pNew
->Insert( pNewEntry
, pNew
->Count() );
659 pSfxApp
->LeaveBasicCall();
665 // besorgen der Funktionen eines Bereiches
666 SvStringsDtor
* __EXPORT
_ImpGetMacrosOfRangeHdl(
667 _SfxMacroTabPage
* /*pTbPg*/,
668 const String
& /*rLanguage*/,
669 const String
& /*rRange*/ )
671 SvStringsDtor
* pNew
= new SvStringsDtor
;
676 SfxMacroTabPage::SfxMacroTabPage( Window
* pParent
, const ResId
& rResId
, const Reference
< XFrame
>& rxDocumentFrame
, const SfxItemSet
& rSet
)
677 : _SfxMacroTabPage( pParent
, rResId
, rSet
)
679 mpImpl
->pStrEvent
= new String( SVX_RES( STR_EVENT
) );
680 mpImpl
->pAssignedMacro
= new String( SVX_RES( STR_ASSMACRO
) );
681 mpImpl
->pEventLB
= new _HeaderTabListBox( this, SVX_RES( LB_EVENT
) );
682 mpImpl
->pAssignPB
= new PushButton( this, SVX_RES( PB_ASSIGN
) );
683 mpImpl
->pDeletePB
= new PushButton( this, SVX_RES( PB_DELETE
) );
684 mpImpl
->pScriptTypeLB
= new ListBox(this, SVX_RES( LB_SCRIPTTYPE
) );
685 mpImpl
->pScriptTypeLB
->Hide();
686 mpImpl
->pMacroFT
= new FixedText( this, SVX_RES( FT_MACRO
) );
687 mpImpl
->pGroupLB
= new SfxConfigGroupListBox_Impl( this, SVX_RES( LB_GROUP
) );
688 mpImpl
->pFT_MacroLBLabel
= new FixedText( this, SVX_RES( FT_LABEL4LB_MACROS
) );
689 mpImpl
->maStaticMacroLBLabel
= mpImpl
->pFT_MacroLBLabel
->GetText();
690 mpImpl
->pMacroLB
= new SfxConfigFunctionListBox_Impl( this, SVX_RES( LB_MACROS
) );
691 mpImpl
->pMacroStr
= new String( SVX_RES( STR_MACROS
) );
695 SetFrame( rxDocumentFrame
);
699 ScriptChanged( String( /*SfxResId(STR_BASICNAME)*/ ) );
702 SfxTabPage
* SfxMacroTabPage::Create( Window
* pParent
, const SfxItemSet
& rAttrSet
)
704 return new SfxMacroTabPage( pParent
, SVX_RES( RID_SVXPAGE_EVENTASSIGN
), NULL
, rAttrSet
);
707 SfxMacroAssignDlg::SfxMacroAssignDlg( Window
* pParent
, const Reference
< XFrame
>& rxDocumentFrame
, const SfxItemSet
& rSet
)
708 : SfxSingleTabDialog( pParent
, rSet
, 0 )
710 SfxTabPage
* pPage
= SfxMacroTabPage::Create( this, rSet
);
711 pPage
->SetFrame( rxDocumentFrame
);
715 SfxMacroAssignDlg::~SfxMacroAssignDlg()