Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #define ITEMID_MACRO 0
30 : : #include <svl/macitem.hxx>
31 : : #undef ITEMID_MACRO
32 : :
33 : : #include "macroass.hxx"
34 : :
35 : : #include <basic/basmgr.hxx>
36 : : #include <comphelper/string.hxx>
37 : : #include <dialmgr.hxx>
38 : : #include <svx/dialogs.hrc>
39 : : #include <svtools/svmedit.hxx>
40 : : #include "cfgutil.hxx"
41 : : #include <sfx2/app.hxx>
42 : : #include <sfx2/evntconf.hxx>
43 : : #include <sfx2/objsh.hxx>
44 : : #include "macroass.hrc"
45 : : #include "cuires.hrc"
46 : : #include <vcl/fixed.hxx>
47 : : #include "headertablistbox.hxx"
48 : :
49 : : using ::com::sun::star::uno::Reference;
50 : : using ::com::sun::star::frame::XFrame;
51 : :
52 : : class _SfxMacroTabPage_Impl
53 : : {
54 : : public:
55 : : _SfxMacroTabPage_Impl( void );
56 : : ~_SfxMacroTabPage_Impl();
57 : :
58 : : String maStaticMacroLBLabel;
59 : : PushButton* pAssignPB;
60 : : PushButton* pDeletePB;
61 : : String* pStrEvent;
62 : : String* pAssignedMacro;
63 : : _HeaderTabListBox* pEventLB;
64 : : SfxConfigGroupListBox_Impl* pGroupLB;
65 : : FixedText* pFT_MacroLBLabel;
66 : : SfxConfigFunctionListBox_Impl* pMacroLB;
67 : :
68 : : FixedText* pMacroFT;
69 : : String* pMacroStr;
70 : :
71 : : sal_Bool bReadOnly;
72 : : Timer maFillGroupTimer;
73 : : sal_Bool bGotEvents;
74 : : };
75 : :
76 : 0 : _SfxMacroTabPage_Impl::_SfxMacroTabPage_Impl( void ) :
77 : : pAssignPB( NULL ),
78 : : pDeletePB( NULL ),
79 : : pStrEvent( NULL ),
80 : : pAssignedMacro( NULL ),
81 : : pEventLB( NULL ),
82 : : pGroupLB( NULL ),
83 : : pFT_MacroLBLabel( NULL ),
84 : : pMacroLB( NULL ),
85 : : pMacroFT( NULL ),
86 : : pMacroStr( NULL ),
87 : : bReadOnly( sal_False ),
88 [ # # ]: 0 : bGotEvents( sal_False )
89 : : {
90 : 0 : }
91 : :
92 [ # # ]: 0 : _SfxMacroTabPage_Impl::~_SfxMacroTabPage_Impl()
93 : : {
94 [ # # ][ # # ]: 0 : delete pAssignPB;
95 [ # # ][ # # ]: 0 : delete pDeletePB;
96 [ # # ][ # # ]: 0 : delete pStrEvent;
97 [ # # ][ # # ]: 0 : delete pAssignedMacro;
98 [ # # ][ # # ]: 0 : delete pEventLB;
99 [ # # ][ # # ]: 0 : delete pGroupLB;
100 [ # # ][ # # ]: 0 : delete pMacroLB;
101 [ # # ][ # # ]: 0 : delete pFT_MacroLBLabel;
102 [ # # ][ # # ]: 0 : delete pMacroFT;
103 [ # # ][ # # ]: 0 : delete pMacroStr;
104 : 0 : }
105 : :
106 : :
107 : : static sal_uInt16 aPageRg[] = {
108 : : SID_ATTR_MACROITEM, SID_ATTR_MACROITEM,
109 : : 0
110 : : };
111 : :
112 : : // attention, this array is indexed directly (0, 1, ...) in the code
113 : : static long nTabs[] =
114 : : {
115 : : 2, // Number of Tabs
116 : : 0, 90
117 : : };
118 : :
119 : : // IDs for items in HeaderBar of EventLB
120 : : #define ITEMID_EVENT 1
121 : : #define ITMEID_ASSMACRO 2
122 : :
123 : :
124 : : #define LB_MACROS_ITEMPOS 2
125 : :
126 : 0 : String ConvertToUIName_Impl( SvxMacro *pMacro )
127 : : {
128 [ # # ]: 0 : String aName( pMacro->GetMacName() );
129 [ # # ]: 0 : String aEntry;
130 [ # # ][ # # ]: 0 : if ( pMacro->GetLanguage() != "JavaScript" )
131 : : {
132 [ # # ][ # # ]: 0 : sal_uInt16 nCount = comphelper::string::getTokenCount(aName, '.');
133 [ # # ][ # # ]: 0 : aEntry = aName.GetToken( nCount-1, '.' );
[ # # ]
134 [ # # ]: 0 : if ( nCount > 2 )
135 : : {
136 [ # # ]: 0 : aEntry += '(';
137 [ # # ][ # # ]: 0 : aEntry += aName.GetToken( 0, '.' );
[ # # ]
138 [ # # ]: 0 : aEntry += '.';
139 [ # # ][ # # ]: 0 : aEntry += aName.GetToken( nCount-2, '.' );
[ # # ]
140 [ # # ]: 0 : aEntry += ')';
141 : : }
142 [ # # ]: 0 : return aEntry;
143 : : }
144 : : else
145 [ # # ][ # # ]: 0 : return aName;
[ # # ]
146 : : }
147 : :
148 : 0 : void _SfxMacroTabPage::EnableButtons()
149 : : {
150 : : // don't do anything as long as the eventbox is empty
151 : 0 : const SvLBoxEntry* pE = mpImpl->pEventLB->GetListBox().FirstSelected();
152 [ # # ]: 0 : if ( pE )
153 : : {
154 : : // get bound macro
155 [ # # ]: 0 : const SvxMacro* pM = aTbl.Get( (sal_uInt16)(sal_uLong) pE->GetUserData() );
156 [ # # ][ # # ]: 0 : mpImpl->pDeletePB->Enable( 0 != pM && !mpImpl->bReadOnly );
[ # # ]
157 : :
158 [ # # ]: 0 : String sEventMacro;
159 [ # # ][ # # ]: 0 : sEventMacro = ((SvLBoxString*)pE->GetItem( LB_MACROS_ITEMPOS ))->GetText();
160 : :
161 [ # # ]: 0 : String sScriptURI = mpImpl->pMacroLB->GetSelectedScriptURI();
162 [ # # ][ # # ]: 0 : mpImpl->pAssignPB->Enable( !mpImpl->bReadOnly && !sScriptURI.EqualsIgnoreCaseAscii( sEventMacro ) );
[ # # ][ # # ]
[ # # ][ # # ]
163 : : }
164 : : else
165 : 0 : mpImpl->pAssignPB->Enable( sal_False );
166 : 0 : }
167 : :
168 : 0 : _SfxMacroTabPage::_SfxMacroTabPage( Window* pParent, const ResId& rResId, const SfxItemSet& rAttrSet )
169 [ # # ]: 0 : : SfxTabPage( pParent, rResId, rAttrSet )
170 : :
171 : : {
172 [ # # ][ # # ]: 0 : mpImpl = new _SfxMacroTabPage_Impl;
173 : 0 : }
174 : :
175 : 0 : _SfxMacroTabPage::~_SfxMacroTabPage()
176 : : {
177 [ # # ][ # # ]: 0 : DELETEZ( mpImpl );
178 [ # # ]: 0 : }
179 : :
180 : 0 : void _SfxMacroTabPage::AddEvent( const String & rEventName, sal_uInt16 nEventId )
181 : : {
182 [ # # ]: 0 : String sTmp( rEventName );
183 [ # # ]: 0 : sTmp += '\t';
184 : :
185 : : // if the table is valid already
186 [ # # ]: 0 : SvxMacro* pM = aTbl.Get( nEventId );
187 [ # # ]: 0 : if( pM )
188 : : {
189 [ # # ]: 0 : String sNew( ConvertToUIName_Impl( pM ) );
190 [ # # ][ # # ]: 0 : sTmp += sNew;
191 : : }
192 : :
193 [ # # ]: 0 : SvLBoxEntry* pE = mpImpl->pEventLB->GetListBox().InsertEntry( sTmp );
194 [ # # ]: 0 : pE->SetUserData( reinterpret_cast< void* >( sal::static_int_cast< sal_IntPtr >( nEventId )) );
195 : 0 : }
196 : :
197 : 0 : void _SfxMacroTabPage::ScriptChanged()
198 : : {
199 : : // get new areas and their functions
200 : : {
201 : 0 : mpImpl->pGroupLB->Show();
202 : 0 : mpImpl->pMacroLB->Show();
203 : 0 : mpImpl->pMacroFT->SetText( *mpImpl->pMacroStr );
204 : : }
205 : :
206 : 0 : EnableButtons();
207 : 0 : }
208 : :
209 : 0 : sal_Bool _SfxMacroTabPage::FillItemSet( SfxItemSet& rSet )
210 : : {
211 [ # # ][ # # ]: 0 : SvxMacroItem aItem( GetWhich( aPageRg[0] ) );
212 [ # # ]: 0 : ((SvxMacroTableDtor&)aItem.GetMacroTable()) = aTbl;
213 : :
214 : : const SfxPoolItem* pItem;
215 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET != GetItemSet().GetItemState( aItem.Which(), sal_True, &pItem )
[ # # ][ # # ]
216 [ # # ]: 0 : || aItem != *(SvxMacroItem*)pItem )
217 : : {
218 [ # # ]: 0 : rSet.Put( aItem );
219 : 0 : return sal_True;
220 : : }
221 [ # # ]: 0 : return sal_False;
222 : : }
223 : :
224 : 0 : void _SfxMacroTabPage::PageCreated (SfxAllItemSet aSet)
225 : : {
226 : : const SfxPoolItem* pEventsItem;
227 [ # # ][ # # ]: 0 : if( !mpImpl->bGotEvents && SFX_ITEM_SET == aSet.GetItemState( SID_EVENTCONFIG, sal_True, &pEventsItem ) )
[ # # ][ # # ]
228 : : {
229 : 0 : mpImpl->bGotEvents = sal_True;
230 : 0 : const SfxEventNamesList& rList = ((SfxEventNamesItem*)pEventsItem)->GetEvents();
231 [ # # ]: 0 : for ( size_t nNo = 0, nCnt = rList.size(); nNo < nCnt; ++nNo )
232 : : {
233 [ # # ]: 0 : const SfxEventName *pOwn = rList.at(nNo);
234 [ # # ]: 0 : AddEvent( pOwn->maUIName, pOwn->mnId );
235 : : }
236 : : }
237 : 0 : }
238 : :
239 : 0 : void _SfxMacroTabPage::Reset( const SfxItemSet& rSet )
240 : : {
241 : : const SfxPoolItem* pItem;
242 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET == rSet.GetItemState( GetWhich( aPageRg[0] ), sal_True, &pItem ))
[ # # ]
243 [ # # ]: 0 : aTbl = ((SvxMacroItem*)pItem)->GetMacroTable();
244 : :
245 : : const SfxPoolItem* pEventsItem;
246 [ # # ][ # # ]: 0 : if( !mpImpl->bGotEvents && SFX_ITEM_SET == rSet.GetItemState( SID_EVENTCONFIG, sal_True, &pEventsItem ) )
[ # # ][ # # ]
247 : : {
248 : 0 : mpImpl->bGotEvents = sal_True;
249 : 0 : const SfxEventNamesList& rList = ((SfxEventNamesItem*)pEventsItem)->GetEvents();
250 [ # # ]: 0 : for ( size_t nNo = 0, nCnt = rList.size(); nNo < nCnt; ++nNo )
251 : : {
252 [ # # ]: 0 : const SfxEventName *pOwn = rList.at(nNo);
253 [ # # ]: 0 : AddEvent( pOwn->maUIName, pOwn->mnId );
254 : : }
255 : : }
256 : :
257 [ # # ]: 0 : FillEvents();
258 : :
259 : 0 : SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
260 [ # # ]: 0 : SvLBoxEntry* pE = rListBox.GetEntry( 0 );
261 [ # # ]: 0 : if( pE )
262 [ # # ]: 0 : rListBox.SetCurEntry( pE );
263 : 0 : }
264 : :
265 : 0 : sal_Bool _SfxMacroTabPage::IsReadOnly() const
266 : : {
267 : 0 : return mpImpl->bReadOnly;
268 : : }
269 : :
270 : 0 : IMPL_STATIC_LINK( _SfxMacroTabPage, SelectEvent_Impl, SvTabListBox*, EMPTYARG )
271 : : {
272 : 0 : _SfxMacroTabPage_Impl* pImpl = pThis->mpImpl;
273 : 0 : SvHeaderTabListBox& rListBox = pImpl->pEventLB->GetListBox();
274 : 0 : SvLBoxEntry* pE = rListBox.FirstSelected();
275 : : sal_uLong nPos;
276 [ # # ]: 0 : if( !pE || LISTBOX_ENTRY_NOTFOUND ==
[ # # # # ]
277 : 0 : ( nPos = rListBox.GetModel()->GetAbsPos( pE ) ) )
278 : : {
279 : : DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" );
280 : 0 : return 0;
281 : : }
282 : :
283 : 0 : pThis->ScriptChanged();
284 : 0 : pThis->EnableButtons();
285 : 0 : return 0;
286 : : }
287 : :
288 : 0 : IMPL_STATIC_LINK( _SfxMacroTabPage, SelectGroup_Impl, ListBox*, EMPTYARG )
289 : : {
290 : 0 : _SfxMacroTabPage_Impl* pImpl = pThis->mpImpl;
291 [ # # ]: 0 : String sSel( pImpl->pGroupLB->GetGroup() );
292 [ # # ]: 0 : pImpl->pGroupLB->GroupSelected();
293 [ # # ]: 0 : const String sScriptURI = pImpl->pMacroLB->GetSelectedScriptURI();
294 [ # # ]: 0 : String aLabelText;
295 [ # # ]: 0 : if( sScriptURI.Len() > 0 )
296 [ # # ]: 0 : aLabelText = pImpl->maStaticMacroLBLabel;
297 [ # # ]: 0 : pImpl->pFT_MacroLBLabel->SetText( aLabelText );
298 : :
299 [ # # ]: 0 : pThis->EnableButtons();
300 [ # # ][ # # ]: 0 : return 0;
[ # # ]
301 : : }
302 : :
303 : 0 : IMPL_STATIC_LINK( _SfxMacroTabPage, SelectMacro_Impl, ListBox*, EMPTYARG )
304 : : {
305 : 0 : _SfxMacroTabPage_Impl* pImpl = pThis->mpImpl;
306 : 0 : pImpl->pMacroLB->FunctionSelected();
307 : 0 : pThis->EnableButtons();
308 : 0 : return 0;
309 : : }
310 : :
311 : 0 : IMPL_STATIC_LINK( _SfxMacroTabPage, AssignDeleteHdl_Impl, PushButton*, pBtn )
312 : : {
313 : 0 : _SfxMacroTabPage_Impl* pImpl = pThis->mpImpl;
314 : 0 : SvHeaderTabListBox& rListBox = pImpl->pEventLB->GetListBox();
315 [ # # ]: 0 : SvLBoxEntry* pE = rListBox.FirstSelected();
316 : : sal_uLong nPos;
317 [ # # # # ]: 0 : if( !pE || LISTBOX_ENTRY_NOTFOUND ==
[ # # ][ # # ]
318 : 0 : ( nPos = rListBox.GetModel()->GetAbsPos( pE ) ) )
319 : : {
320 : : DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" );
321 : 0 : return 0;
322 : : }
323 : :
324 [ # # ][ # # ]: 0 : const sal_Bool bAssEnabled = pBtn != pImpl->pDeletePB && pImpl->pAssignPB->IsEnabled();
[ # # ]
325 : :
326 : : // remove from the table
327 : 0 : sal_uInt16 nEvent = (sal_uInt16)(sal_uLong)pE->GetUserData();
328 [ # # ]: 0 : pThis->aTbl.Erase( nEvent );
329 : :
330 [ # # ]: 0 : String sScriptURI;
331 [ # # ]: 0 : if( bAssEnabled )
332 : : {
333 [ # # ][ # # ]: 0 : sScriptURI = pImpl->pMacroLB->GetSelectedScriptURI();
[ # # ]
334 [ # # ][ # # ]: 0 : if( sScriptURI.CompareToAscii( "vnd.sun.star.script:", 20 ) == COMPARE_EQUAL )
335 : : {
336 : : pThis->aTbl.Insert(
337 [ # # ][ # # ]: 0 : nEvent, SvxMacro( sScriptURI, rtl::OUString( SVX_MACRO_LANGUAGE_SF ) ) );
[ # # ][ # # ]
338 : : }
339 : : else
340 : : {
341 : : OSL_ENSURE( false, "_SfxMacroTabPage::AssignDeleteHdl_Impl: this branch is *not* dead? (out of interest: tell fs, please!)" );
342 : : pThis->aTbl.Insert(
343 [ # # ][ # # ]: 0 : nEvent, SvxMacro( sScriptURI, rtl::OUString( SVX_MACRO_LANGUAGE_STARBASIC ) ) );
[ # # ][ # # ]
344 : : }
345 : : }
346 : :
347 [ # # ]: 0 : pImpl->pEventLB->SetUpdateMode( sal_False );
348 [ # # ][ # # ]: 0 : pE->ReplaceItem( new SvLBoxString( pE, 0, sScriptURI ), LB_MACROS_ITEMPOS );
[ # # ][ # # ]
349 [ # # ]: 0 : rListBox.GetModel()->InvalidateEntry( pE );
350 [ # # ]: 0 : rListBox.Select( pE );
351 [ # # ]: 0 : rListBox.MakeVisible( pE );
352 [ # # ]: 0 : rListBox.SetUpdateMode( sal_True );
353 : :
354 [ # # ]: 0 : pThis->EnableButtons();
355 [ # # ]: 0 : return 0;
356 : : }
357 : :
358 : 0 : IMPL_STATIC_LINK( _SfxMacroTabPage, TimeOut_Impl, Timer*, EMPTYARG )
359 : : {
360 : : // FillMacroList() can take a long time -> show wait cursor and disable input
361 : 0 : SfxTabDialog* pTabDlg = pThis->GetTabDialog();
362 : : // perhaps the tabpage is part of a SingleTabDialog then pTabDlg == NULL
363 [ # # ]: 0 : if ( pTabDlg )
364 : : {
365 : 0 : pTabDlg->EnterWait();
366 : 0 : pTabDlg->EnableInput( sal_False );
367 : : }
368 : 0 : pThis->FillMacroList();
369 [ # # ]: 0 : if ( pTabDlg )
370 : : {
371 : 0 : pTabDlg->EnableInput( sal_True );
372 : 0 : pTabDlg->LeaveWait();
373 : : }
374 : 0 : return 0;
375 : : }
376 : :
377 : 0 : void _SfxMacroTabPage::InitAndSetHandler()
378 : : {
379 : 0 : SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
380 : 0 : HeaderBar& rHeaderBar = mpImpl->pEventLB->GetHeaderBar();
381 [ # # ]: 0 : Link aLnk(STATIC_LINK(this, _SfxMacroTabPage, AssignDeleteHdl_Impl ));
382 : 0 : mpImpl->pMacroLB->SetDoubleClickHdl( aLnk );
383 : 0 : mpImpl->pDeletePB->SetClickHdl( aLnk );
384 : 0 : mpImpl->pAssignPB->SetClickHdl( aLnk );
385 : 0 : rListBox.SetDoubleClickHdl( aLnk );
386 : :
387 [ # # ]: 0 : rListBox.SetSelectHdl( STATIC_LINK( this, _SfxMacroTabPage, SelectEvent_Impl ));
388 [ # # ]: 0 : mpImpl->pGroupLB->SetSelectHdl( STATIC_LINK( this, _SfxMacroTabPage, SelectGroup_Impl ));
389 [ # # ]: 0 : mpImpl->pMacroLB->SetSelectHdl( STATIC_LINK( this, _SfxMacroTabPage, SelectMacro_Impl ));
390 : :
391 [ # # ]: 0 : rListBox.SetSelectionMode( SINGLE_SELECTION );
392 [ # # ]: 0 : rListBox.SetTabs( &nTabs[0], MAP_APPFONT );
393 : 0 : Size aSize( nTabs[ 2 ], 0 );
394 [ # # ][ # # ]: 0 : rHeaderBar.InsertItem( ITEMID_EVENT, *mpImpl->pStrEvent, LogicToPixel( aSize, MapMode( MAP_APPFONT ) ).Width() );
[ # # ][ # # ]
395 : 0 : aSize.Width() = 1764; // don't know what, so 42^2 is best to use...
396 [ # # ][ # # ]: 0 : rHeaderBar.InsertItem( ITMEID_ASSMACRO, *mpImpl->pAssignedMacro, LogicToPixel( aSize, MapMode( MAP_APPFONT ) ).Width() );
[ # # ][ # # ]
397 [ # # ]: 0 : rListBox.SetSpaceBetweenEntries( 0 );
398 : :
399 [ # # ]: 0 : mpImpl->pEventLB->Show();
400 [ # # ]: 0 : mpImpl->pEventLB->ConnectElements();
401 : :
402 [ # # ]: 0 : mpImpl->pEventLB->Enable( sal_True );
403 [ # # ]: 0 : mpImpl->pGroupLB->Enable( sal_True );
404 [ # # ]: 0 : mpImpl->pMacroLB->Enable( sal_True );
405 : :
406 : 0 : mpImpl->pGroupLB->SetFunctionListBox( mpImpl->pMacroLB );
407 : :
408 [ # # ]: 0 : mpImpl->maFillGroupTimer.SetTimeoutHdl( STATIC_LINK( this, _SfxMacroTabPage, TimeOut_Impl ) );
409 [ # # ]: 0 : mpImpl->maFillGroupTimer.SetTimeout( 0 );
410 [ # # ]: 0 : mpImpl->maFillGroupTimer.Start();
411 : 0 : }
412 : :
413 : 0 : void _SfxMacroTabPage::FillMacroList()
414 : : {
415 : : mpImpl->pGroupLB->Init(
416 : : ::com::sun::star::uno::Reference<
417 : : ::com::sun::star::lang::XMultiServiceFactory >(),
418 : : GetFrame(),
419 [ # # ][ # # ]: 0 : ::rtl::OUString() );
420 : 0 : }
421 : :
422 : 0 : void _SfxMacroTabPage::FillEvents()
423 : : {
424 : 0 : SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
425 : :
426 : 0 : sal_uLong nEntryCnt = rListBox.GetEntryCount();
427 : :
428 : : // get events from the table and fill the EventListBox respectively
429 [ # # ]: 0 : for( sal_uLong n = 0 ; n < nEntryCnt ; ++n )
430 : : {
431 : 0 : SvLBoxEntry* pE = rListBox.GetEntry( n );
432 [ # # ]: 0 : if( pE )
433 : : {
434 [ # # ]: 0 : SvLBoxString* pLItem = ( SvLBoxString* ) pE->GetItem( LB_MACROS_ITEMPOS );
435 : : DBG_ASSERT( pLItem && SV_ITEM_ID_LBOXSTRING == pLItem->IsA(), "_SfxMacroTabPage::FillEvents(): no LBoxString" );
436 : :
437 [ # # ]: 0 : String sOld( pLItem->GetText() );
438 [ # # ]: 0 : String sNew;
439 : 0 : sal_uInt16 nEventId = ( sal_uInt16 ) ( sal_uLong ) pE->GetUserData();
440 [ # # ][ # # ]: 0 : if( aTbl.IsKeyValid( nEventId ) )
441 [ # # ][ # # ]: 0 : sNew = ConvertToUIName_Impl( aTbl.Get( nEventId ) );
[ # # ][ # # ]
442 : :
443 [ # # ][ # # ]: 0 : if( sOld != sNew )
444 : : {
445 [ # # ][ # # ]: 0 : pE->ReplaceItem( new SvLBoxString( pE, 0, sNew ), LB_MACROS_ITEMPOS );
[ # # ][ # # ]
446 [ # # ]: 0 : rListBox.GetModel()->InvalidateEntry( pE );
447 [ # # ][ # # ]: 0 : }
448 : : }
449 : : }
450 : 0 : }
451 : :
452 : 0 : SfxMacroTabPage::SfxMacroTabPage( Window* pParent, const ResId& rResId, const Reference< XFrame >& rxDocumentFrame, const SfxItemSet& rSet )
453 : 0 : : _SfxMacroTabPage( pParent, rResId, rSet )
454 : : {
455 [ # # ][ # # ]: 0 : mpImpl->pStrEvent = new String( CUI_RES( STR_EVENT ) );
[ # # ]
456 [ # # ][ # # ]: 0 : mpImpl->pAssignedMacro = new String( CUI_RES( STR_ASSMACRO ) );
[ # # ]
457 [ # # ][ # # ]: 0 : mpImpl->pEventLB = new _HeaderTabListBox( this, CUI_RES( LB_EVENT ) );
[ # # ]
458 [ # # ][ # # ]: 0 : mpImpl->pAssignPB = new PushButton( this, CUI_RES( PB_ASSIGN ) );
[ # # ]
459 [ # # ][ # # ]: 0 : mpImpl->pDeletePB = new PushButton( this, CUI_RES( PB_DELETE ) );
[ # # ]
460 [ # # ][ # # ]: 0 : mpImpl->pMacroFT = new FixedText( this, CUI_RES( FT_MACRO ) );
[ # # ]
461 [ # # ][ # # ]: 0 : mpImpl->pGroupLB = new SfxConfigGroupListBox_Impl( this, CUI_RES( LB_GROUP ) );
[ # # ]
462 [ # # ][ # # ]: 0 : mpImpl->pFT_MacroLBLabel = new FixedText( this, CUI_RES( FT_LABEL4LB_MACROS ) );
[ # # ]
463 [ # # ][ # # ]: 0 : mpImpl->maStaticMacroLBLabel= mpImpl->pFT_MacroLBLabel->GetText();
[ # # ]
464 [ # # ][ # # ]: 0 : mpImpl->pMacroLB = new SfxConfigFunctionListBox_Impl( this, CUI_RES( LB_MACROS ) );
[ # # ]
465 [ # # ][ # # ]: 0 : mpImpl->pMacroStr = new String( CUI_RES( STR_MACROS ) );
[ # # ]
466 : :
467 [ # # ]: 0 : FreeResource();
468 : :
469 [ # # ]: 0 : SetFrame( rxDocumentFrame );
470 : :
471 [ # # ]: 0 : InitAndSetHandler();
472 : :
473 [ # # ]: 0 : ScriptChanged();
474 : 0 : }
475 : :
476 : 0 : SfxTabPage* SfxMacroTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
477 : : {
478 [ # # ][ # # ]: 0 : return new SfxMacroTabPage( pParent, CUI_RES( RID_SVXPAGE_EVENTASSIGN ), NULL, rAttrSet );
[ # # ]
479 : : }
480 : :
481 : 0 : SfxMacroAssignDlg::SfxMacroAssignDlg( Window* pParent, const Reference< XFrame >& rxDocumentFrame, const SfxItemSet& rSet )
482 : 0 : : SfxSingleTabDialog( pParent, rSet, 0 )
483 : : {
484 [ # # ]: 0 : SfxTabPage* pPage = SfxMacroTabPage::Create( this, rSet );
485 [ # # ]: 0 : pPage->SetFrame( rxDocumentFrame );
486 [ # # ]: 0 : SetTabPage( pPage );
487 : 0 : }
488 : :
489 : 0 : SfxMacroAssignDlg::~SfxMacroAssignDlg()
490 : : {
491 [ # # ]: 0 : }
492 : :
493 : :
494 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|