Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "baside2.hrc"
21 : #include "basidesh.hrc"
22 :
23 : #include "moduldlg.hxx"
24 : #include "localizationmgr.hxx"
25 : #include "basidesh.hxx"
26 : #include "baside3.hxx"
27 : #include "iderdll.hxx"
28 :
29 : #include <basic/basmgr.hxx>
30 : #include <com/sun/star/script/XLibraryContainerPassword.hpp>
31 : #include <comphelper/processfactory.hxx>
32 : #include <sfx2/app.hxx>
33 : #include <sfx2/dispatch.hxx>
34 : #include <sfx2/request.hxx>
35 : #include <sfx2/viewfrm.hxx>
36 : #include <svl/itemset.hxx>
37 : #include <svl/stritem.hxx>
38 : #include <vcl/msgbox.hxx>
39 : #include <tools/diagnose_ex.h>
40 : #include <xmlscript/xmldlg_imexp.hxx>
41 : #include <svtools/treelistentry.hxx>
42 :
43 : namespace basctl
44 : {
45 :
46 : using namespace ::com::sun::star;
47 : using namespace ::com::sun::star::uno;
48 : using namespace ::com::sun::star::resource;
49 :
50 :
51 : // ExtTreeListBox
52 :
53 :
54 :
55 0 : ExtTreeListBox::ExtTreeListBox(Window* pParent, WinBits nStyle)
56 0 : : TreeListBox(pParent, nStyle)
57 : {
58 0 : }
59 :
60 0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeExtTreeListBox(Window *pParent, VclBuilder::stringmap &rMap)
61 : {
62 0 : WinBits nWinBits = WB_TABSTOP;
63 0 : OString sBorder = VclBuilder::extractCustomProperty(rMap);
64 0 : if (!sBorder.isEmpty())
65 0 : nWinBits |= WB_BORDER;
66 0 : return new ExtTreeListBox(pParent, nWinBits);
67 : }
68 :
69 0 : ExtTreeListBox::~ExtTreeListBox ()
70 0 : { }
71 :
72 0 : bool ExtTreeListBox::EditingEntry( SvTreeListEntry* pEntry, Selection& )
73 : {
74 0 : bool bRet = false;
75 :
76 0 : if ( pEntry )
77 : {
78 0 : sal_uInt16 nDepth = GetModel()->GetDepth( pEntry );
79 0 : if ( nDepth >= 2 )
80 : {
81 0 : EntryDescriptor aDesc = GetEntryDescriptor(pEntry);
82 0 : ScriptDocument aDocument( aDesc.GetDocument() );
83 0 : OUString aLibName( aDesc.GetLibName() );
84 0 : Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
85 0 : Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
86 0 : if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
87 0 : ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) )
88 : {
89 : // allow editing only for libraries, which are not readonly
90 0 : bRet = true;
91 0 : }
92 : }
93 : }
94 :
95 0 : return bRet;
96 : }
97 :
98 0 : bool ExtTreeListBox::EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText )
99 : {
100 0 : if ( !IsValidSbxName(rNewText) )
101 : {
102 0 : ErrorBox( this, WB_OK | WB_DEF_OK, IDE_RESSTR(RID_STR_BADSBXNAME) ).Execute();
103 0 : return false;
104 : }
105 :
106 0 : OUString aCurText( GetEntryText( pEntry ) );
107 0 : if ( aCurText == rNewText )
108 : // nothing to do
109 0 : return true;
110 :
111 0 : EntryDescriptor aDesc = GetEntryDescriptor(pEntry);
112 0 : ScriptDocument aDocument( aDesc.GetDocument() );
113 : DBG_ASSERT( aDocument.isValid(), "ExtTreeListBox::EditedEntry: no document!" );
114 0 : if ( !aDocument.isValid() )
115 0 : return false;
116 0 : OUString aLibName( aDesc.GetLibName() );
117 0 : EntryType eType = aDesc.GetType();
118 :
119 : bool bSuccess = eType == OBJ_TYPE_MODULE ?
120 0 : RenameModule(this, aDocument, aLibName, aCurText, rNewText) :
121 0 : RenameDialog(this, aDocument, aLibName, aCurText, rNewText);
122 :
123 0 : if ( !bSuccess )
124 0 : return false;
125 :
126 0 : MarkDocumentModified( aDocument );
127 :
128 0 : if (SfxDispatcher* pDispatcher = GetDispatcher())
129 : {
130 0 : SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, rNewText, ConvertType( eType ) );
131 : pDispatcher->Execute( SID_BASICIDE_SBXRENAMED,
132 0 : SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
133 : }
134 :
135 : // OV-Bug?!
136 0 : SetEntryText( pEntry, rNewText );
137 0 : SetCurEntry( pEntry );
138 0 : SetCurEntry( pEntry );
139 0 : Select( pEntry, false );
140 0 : Select( pEntry ); // so that handler is called => update edit
141 :
142 0 : return true;
143 : }
144 :
145 :
146 0 : DragDropMode ExtTreeListBox::NotifyStartDrag( TransferDataContainer&, SvTreeListEntry* pEntry )
147 : {
148 0 : DragDropMode nMode_ = SV_DRAGDROP_NONE;
149 :
150 0 : if ( pEntry )
151 : {
152 0 : sal_uInt16 nDepth = GetModel()->GetDepth( pEntry );
153 0 : if ( nDepth >= 2 )
154 : {
155 0 : nMode_ = SV_DRAGDROP_CTRL_COPY;
156 0 : EntryDescriptor aDesc = GetEntryDescriptor(pEntry);
157 0 : ScriptDocument aDocument( aDesc.GetDocument() );
158 0 : OUString aLibName( aDesc.GetLibName() );
159 : // allow MOVE mode only for libraries, which are not readonly
160 0 : Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
161 0 : Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
162 0 : if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
163 0 : ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) )
164 : {
165 : // Only allow copy for localized libraries
166 0 : bool bAllowMove = true;
167 0 : if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
168 : {
169 : // Get StringResourceManager
170 0 : Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, aLibName, true ) );
171 : Reference< XStringResourceManager > xSourceMgr =
172 0 : LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
173 0 : if( xSourceMgr.is() )
174 0 : bAllowMove = ( xSourceMgr->getLocales().getLength() == 0 );
175 : }
176 0 : if( bAllowMove )
177 0 : nMode_ |= SV_DRAGDROP_CTRL_MOVE;
178 0 : }
179 : }
180 : }
181 :
182 0 : return nMode_;
183 : }
184 :
185 :
186 0 : bool ExtTreeListBox::NotifyAcceptDrop( SvTreeListEntry* pEntry )
187 : {
188 : // don't drop on a BasicManager (nDepth == 0)
189 0 : sal_uInt16 nDepth = pEntry ? GetModel()->GetDepth( pEntry ) : 0;
190 0 : bool bValid = nDepth != 0;
191 :
192 : // don't drop in the same library
193 0 : SvTreeListEntry* pSelected = FirstSelected();
194 0 : if ( ( nDepth == 1 ) && ( pEntry == GetParent( pSelected ) ) )
195 0 : bValid = false;
196 0 : else if ( ( nDepth == 2 ) && ( GetParent( pEntry ) == GetParent( pSelected ) ) )
197 0 : bValid = false;
198 :
199 : // don't drop on a library, which is not loaded, readonly or password protected
200 : // or which already has a module/dialog with this name
201 0 : if ( bValid && ( nDepth > 0 ) )
202 : {
203 : // get source module/dialog name
204 0 : EntryDescriptor aSourceDesc = GetEntryDescriptor(pSelected);
205 0 : OUString aSourceName = aSourceDesc.GetName();
206 0 : EntryType eSourceType = aSourceDesc.GetType();
207 :
208 : // get target shell and target library name
209 0 : EntryDescriptor aDestDesc = GetEntryDescriptor(pEntry);
210 0 : ScriptDocument const& rDestDoc = aDestDesc.GetDocument();
211 0 : OUString aDestLibName = aDestDesc.GetLibName();
212 :
213 : // check if module library is not loaded, readonly or password protected
214 0 : Reference< script::XLibraryContainer2 > xModLibContainer( rDestDoc.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
215 0 : if ( xModLibContainer.is() && xModLibContainer->hasByName( aDestLibName ) )
216 : {
217 0 : if ( !xModLibContainer->isLibraryLoaded( aDestLibName ) )
218 0 : bValid = false;
219 :
220 0 : if ( xModLibContainer->isLibraryReadOnly( aDestLibName ) )
221 0 : bValid = false;
222 :
223 0 : Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
224 0 : if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aDestLibName ) && !xPasswd->isLibraryPasswordVerified( aDestLibName ) )
225 0 : bValid = false;
226 : }
227 :
228 : // check if dialog library is not loaded or readonly
229 0 : Reference< script::XLibraryContainer2 > xDlgLibContainer( rDestDoc.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
230 0 : if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aDestLibName ) )
231 : {
232 0 : if ( !xDlgLibContainer->isLibraryLoaded( aDestLibName ) )
233 0 : bValid = false;
234 :
235 0 : if ( xDlgLibContainer->isLibraryReadOnly( aDestLibName ) )
236 0 : bValid = false;
237 : }
238 :
239 : // check, if module/dialog with this name is already existing in target library
240 0 : if ( ( eSourceType == OBJ_TYPE_MODULE && rDestDoc.hasModule( aDestLibName, aSourceName ) ) ||
241 0 : ( eSourceType == OBJ_TYPE_DIALOG && rDestDoc.hasDialog( aDestLibName, aSourceName ) ) )
242 : {
243 0 : bValid = false;
244 0 : }
245 : }
246 :
247 0 : return bValid;
248 : }
249 :
250 0 : TriState ExtTreeListBox::NotifyMoving( SvTreeListEntry* pTarget, SvTreeListEntry* pEntry,
251 : SvTreeListEntry*& rpNewParent, sal_uLong& rNewChildPos )
252 : {
253 : return NotifyCopyingMoving( pTarget, pEntry,
254 0 : rpNewParent, rNewChildPos, true );
255 : }
256 :
257 0 : TriState ExtTreeListBox::NotifyCopying( SvTreeListEntry* pTarget, SvTreeListEntry* pEntry,
258 : SvTreeListEntry*& rpNewParent, sal_uLong& rNewChildPos )
259 : {
260 : return NotifyCopyingMoving( pTarget, pEntry,
261 0 : rpNewParent, rNewChildPos, false );
262 : }
263 :
264 0 : void Shell::CopyDialogResources(
265 : Reference< io::XInputStreamProvider >& io_xISP,
266 : ScriptDocument const& rSourceDoc,
267 : OUString const& rSourceLibName,
268 : ScriptDocument const& rDestDoc,
269 : OUString const& rDestLibName,
270 : OUString const& rDlgName
271 : )
272 : {
273 0 : if ( !io_xISP.is() )
274 0 : return;
275 :
276 : // Get StringResourceManager
277 0 : Reference< container::XNameContainer > xSourceDialogLib( rSourceDoc.getLibrary( E_DIALOGS, rSourceLibName, true ) );
278 : Reference< XStringResourceManager > xSourceMgr =
279 0 : LocalizationMgr::getStringResourceFromDialogLibrary( xSourceDialogLib );
280 0 : if( !xSourceMgr.is() )
281 0 : return;
282 0 : bool bSourceLocalized = ( xSourceMgr->getLocales().getLength() > 0 );
283 :
284 0 : Reference< container::XNameContainer > xDestDialogLib( rDestDoc.getLibrary( E_DIALOGS, rDestLibName, true ) );
285 : Reference< XStringResourceManager > xDestMgr =
286 0 : LocalizationMgr::getStringResourceFromDialogLibrary( xDestDialogLib );
287 0 : if( !xDestMgr.is() )
288 0 : return;
289 0 : bool bDestLocalized = ( xDestMgr->getLocales().getLength() > 0 );
290 :
291 0 : if( !bSourceLocalized && !bDestLocalized )
292 0 : return;
293 :
294 : // create dialog model
295 0 : Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
296 0 : Reference< container::XNameContainer > xDialogModel = Reference< container::XNameContainer >( xContext->getServiceManager()->createInstanceWithContext
297 0 : ( "com.sun.star.awt.UnoControlDialogModel", xContext ), UNO_QUERY );
298 0 : Reference< io::XInputStream > xInput( io_xISP->createInputStream() );
299 0 : ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rSourceDoc.isDocument() ? rSourceDoc.getDocument() : Reference< frame::XModel >() );
300 :
301 0 : if( xDialogModel.is() )
302 : {
303 0 : if( bSourceLocalized && bDestLocalized )
304 : {
305 0 : Reference< resource::XStringResourceResolver > xSourceStringResolver( xSourceMgr, UNO_QUERY );
306 0 : LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, rDlgName, xDestMgr, xSourceStringResolver );
307 : }
308 0 : else if( bSourceLocalized )
309 : {
310 0 : LocalizationMgr::resetResourceForDialog( xDialogModel, xSourceMgr );
311 : }
312 0 : else if( bDestLocalized )
313 : {
314 0 : LocalizationMgr::setResourceIDsForDialog( xDialogModel, xDestMgr );
315 : }
316 0 : io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.isDocument() ? rDestDoc.getDocument() : Reference< frame::XModel >() );
317 0 : }
318 : }
319 :
320 0 : TriState ExtTreeListBox::NotifyCopyingMoving( SvTreeListEntry* pTarget, SvTreeListEntry* pEntry,
321 : SvTreeListEntry*& rpNewParent, sal_uLong& rNewChildPos, sal_Bool bMove )
322 : {
323 : (void)pEntry;
324 : DBG_ASSERT( pEntry, "Kein Eintrag?" ); // ASS is ok here, should not be reached
325 : DBG_ASSERT( pTarget, "Kein Ziel?" ); // with NULL (right at the beginning)
326 0 : sal_uInt16 nDepth = GetModel()->GetDepth( pTarget );
327 : DBG_ASSERT( nDepth, "Tiefe?" );
328 0 : if ( nDepth == 1 )
329 : {
330 : // Target = Basic => put module/dialog under the Basic
331 0 : rpNewParent = pTarget;
332 0 : rNewChildPos = 0;
333 : }
334 0 : else if ( nDepth >= 2 )
335 : {
336 : // Target = module/dialog => put module/dialog under the superordinate Basic
337 0 : rpNewParent = GetParent( pTarget );
338 0 : rNewChildPos = GetModel()->GetRelPos( pTarget ) + 1;
339 : }
340 :
341 : // get target shell and target library name
342 0 : EntryDescriptor aDestDesc = GetEntryDescriptor(rpNewParent);
343 0 : const ScriptDocument& rDestDoc( aDestDesc.GetDocument() );
344 0 : OUString aDestLibName( aDestDesc.GetLibName() );
345 :
346 : // get source shell, library name and module/dialog name
347 0 : EntryDescriptor aSourceDesc = GetEntryDescriptor(FirstSelected());
348 0 : const ScriptDocument rSourceDoc( aSourceDesc.GetDocument() );
349 0 : OUString aSourceLibName( aSourceDesc.GetLibName() );
350 0 : OUString aSourceName( aSourceDesc.GetName() );
351 0 : EntryType eType = aSourceDesc.GetType();
352 :
353 : // get dispatcher
354 0 : SfxDispatcher* pDispatcher = GetDispatcher();
355 :
356 0 : if ( bMove ) // move
357 : {
358 : // remove source module/dialog window
359 0 : if ( rSourceDoc != rDestDoc || aSourceLibName != aDestLibName )
360 : {
361 0 : if( pDispatcher )
362 : {
363 0 : SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rSourceDoc, aSourceLibName, aSourceName, ConvertType( eType ) );
364 : pDispatcher->Execute( SID_BASICIDE_SBXDELETED,
365 0 : SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
366 : }
367 : }
368 :
369 : try
370 : {
371 0 : if ( eType == OBJ_TYPE_MODULE ) // module
372 : {
373 : // get module
374 0 : OUString aModule;
375 0 : if ( rSourceDoc.getModule( aSourceLibName, aSourceName, aModule ) )
376 : {
377 : // remove module from source library
378 0 : if ( rSourceDoc.removeModule( aSourceLibName, aSourceName ) )
379 : {
380 0 : MarkDocumentModified( rSourceDoc );
381 :
382 : // insert module into target library
383 0 : if ( rDestDoc.insertModule( aDestLibName, aSourceName, aModule ) )
384 0 : MarkDocumentModified( rDestDoc );
385 : }
386 0 : }
387 : }
388 0 : else if ( eType == OBJ_TYPE_DIALOG ) // dialog
389 : {
390 : // get dialog
391 0 : Reference< io::XInputStreamProvider > xISP;
392 0 : if ( rSourceDoc.getDialog( aSourceLibName, aSourceName, xISP ) )
393 : {
394 : Shell::CopyDialogResources( xISP, rSourceDoc,
395 0 : aSourceLibName, rDestDoc, aDestLibName, aSourceName );
396 :
397 : // remove dialog from source library
398 0 : if (RemoveDialog(rSourceDoc, aSourceLibName, aSourceName))
399 : {
400 0 : MarkDocumentModified(rSourceDoc);
401 :
402 : // insert dialog into target library
403 0 : if ( rDestDoc.insertDialog( aDestLibName, aSourceName, xISP ) )
404 0 : MarkDocumentModified(rDestDoc);
405 : }
406 0 : }
407 : }
408 : }
409 0 : catch (const uno::Exception& )
410 : {
411 : DBG_UNHANDLED_EXCEPTION();
412 : }
413 : }
414 : else // copy
415 : {
416 : try
417 : {
418 0 : if ( eType == OBJ_TYPE_MODULE ) // module
419 : {
420 : // get module
421 0 : OUString aModule;
422 0 : if ( rSourceDoc.getModule( aSourceLibName, aSourceName, aModule ) )
423 : {
424 : // insert module into target library
425 0 : if ( rDestDoc.insertModule( aDestLibName, aSourceName, aModule ) )
426 0 : MarkDocumentModified( rDestDoc );
427 0 : }
428 : }
429 0 : else if ( eType == OBJ_TYPE_DIALOG ) // dialog
430 : {
431 : // get dialog
432 0 : Reference< io::XInputStreamProvider > xISP;
433 0 : if ( rSourceDoc.getDialog( aSourceLibName, aSourceName, xISP ) )
434 : {
435 : Shell::CopyDialogResources( xISP, rSourceDoc,
436 0 : aSourceLibName, rDestDoc, aDestLibName, aSourceName );
437 :
438 : // insert dialog into target library
439 0 : if ( rDestDoc.insertDialog( aDestLibName, aSourceName, xISP ) )
440 0 : MarkDocumentModified( rDestDoc );
441 0 : }
442 : }
443 : }
444 0 : catch ( const Exception& )
445 : {
446 : DBG_UNHANDLED_EXCEPTION();
447 : }
448 : }
449 :
450 : // create target module/dialog window
451 0 : if ( rSourceDoc != rDestDoc || aSourceLibName != aDestLibName )
452 : {
453 0 : if( pDispatcher )
454 : {
455 0 : SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDestDoc, aDestLibName, aSourceName, ConvertType( eType ) );
456 : pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
457 0 : SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
458 : }
459 : }
460 :
461 0 : return TRISTATE_INDET; // open...
462 : }
463 :
464 : // OrganizeDialog
465 0 : OrganizeDialog::OrganizeDialog(Window* pParent, sal_Int16 tabId,
466 : EntryDescriptor& rDesc )
467 : : TabDialog( pParent, "OrganizeDialog",
468 : "modules/BasicIDE/ui/organizedialog.ui" )
469 0 : , m_aCurEntry( rDesc )
470 : {
471 0 : get(m_pTabCtrl, "tabcontrol");
472 :
473 0 : m_pTabCtrl->SetActivatePageHdl(LINK(this, OrganizeDialog, ActivatePageHdl));
474 :
475 0 : if( tabId == 0 )
476 : {
477 0 : m_pTabCtrl->SetCurPageId(m_pTabCtrl->GetPageId("modules"));
478 : }
479 0 : else if ( tabId == 1 )
480 : {
481 0 : m_pTabCtrl->SetCurPageId(m_pTabCtrl->GetPageId("dialogs"));
482 : }
483 : else
484 : {
485 0 : m_pTabCtrl->SetCurPageId(m_pTabCtrl->GetPageId("libraries"));
486 : }
487 :
488 0 : ActivatePageHdl(m_pTabCtrl);
489 :
490 0 : if (SfxDispatcher* pDispatcher = GetDispatcher())
491 0 : pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
492 0 : }
493 :
494 0 : OrganizeDialog::~OrganizeDialog()
495 : {
496 0 : for ( sal_uInt16 i = 0; i < m_pTabCtrl->GetPageCount(); i++ )
497 0 : delete m_pTabCtrl->GetTabPage( m_pTabCtrl->GetPageId( i ) );
498 0 : };
499 :
500 0 : short OrganizeDialog::Execute()
501 : {
502 0 : Window* pPrevDlgParent = Application::GetDefDialogParent();
503 0 : Application::SetDefDialogParent( this );
504 0 : short nRet = TabDialog::Execute();
505 0 : Application::SetDefDialogParent( pPrevDlgParent );
506 0 : return nRet;
507 : }
508 :
509 :
510 0 : IMPL_LINK( OrganizeDialog, ActivatePageHdl, TabControl *, pTabCtrl )
511 : {
512 0 : sal_uInt16 nId = pTabCtrl->GetCurPageId();
513 :
514 0 : if ( !pTabCtrl->GetTabPage( nId ) )
515 : {
516 0 : OString sPageName(pTabCtrl->GetPageName(nId));
517 0 : TabPage* pNewTabPage = 0;
518 0 : if (sPageName == "modules")
519 : {
520 0 : ObjectPage* pObjectPage = new ObjectPage(pTabCtrl, "ModulePage", BROWSEMODE_MODULES);
521 0 : pNewTabPage = pObjectPage;
522 0 : pObjectPage->SetTabDlg(this);
523 0 : pObjectPage->SetCurrentEntry(m_aCurEntry);
524 : }
525 0 : else if (sPageName == "dialogs")
526 : {
527 0 : ObjectPage* pObjectPage = new ObjectPage( pTabCtrl, "DialogPage", BROWSEMODE_DIALOGS );
528 0 : pNewTabPage = pObjectPage;
529 0 : pObjectPage->SetTabDlg(this);
530 0 : pObjectPage->SetCurrentEntry(m_aCurEntry);
531 : }
532 0 : else if (sPageName == "libraries")
533 : {
534 0 : LibPage* pLibPage = new LibPage( pTabCtrl );
535 0 : pNewTabPage = pLibPage;
536 0 : pLibPage->SetTabDlg( this );
537 : }
538 : else
539 : {
540 : OSL_FAIL( "PageHdl: Unbekannte ID!" );
541 : }
542 : DBG_ASSERT( pNewTabPage, "Keine Page!" );
543 0 : pTabCtrl->SetTabPage( nId, pNewTabPage );
544 : }
545 0 : return 0;
546 : }
547 :
548 :
549 : // ObjectPage
550 :
551 :
552 :
553 0 : ObjectPage::ObjectPage(Window *pParent, const OString &rName, sal_uInt16 nMode)
554 0 : : TabPage(pParent, rName, OUString("modules/BasicIDE/ui/") +
555 0 : OStringToOUString(rName, RTL_TEXTENCODING_UTF8).toAsciiLowerCase() +
556 0 : OUString(".ui"))
557 : {
558 0 : get(m_pBasicBox, "library");
559 0 : Size aSize(m_pBasicBox->LogicToPixel(Size(130, 117), MAP_APPFONT));
560 0 : m_pBasicBox->set_height_request(aSize.Height());
561 0 : m_pBasicBox->set_width_request(aSize.Width());
562 0 : get(m_pEditButton, "edit");
563 0 : get(m_pNewModButton, "newmodule");
564 0 : get(m_pNewDlgButton, "newdialog");
565 0 : get(m_pDelButton, "delete");
566 :
567 0 : pTabDlg = 0;
568 :
569 0 : m_pEditButton->SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
570 0 : m_pDelButton->SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
571 0 : m_pBasicBox->SetSelectHdl( LINK( this, ObjectPage, BasicBoxHighlightHdl ) );
572 :
573 0 : if( nMode & BROWSEMODE_MODULES )
574 : {
575 0 : m_pNewModButton->SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
576 0 : m_pNewDlgButton->Hide();
577 : }
578 0 : else if ( nMode & BROWSEMODE_DIALOGS )
579 : {
580 0 : m_pNewDlgButton->SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
581 0 : m_pNewModButton->Hide();
582 : }
583 :
584 0 : m_pBasicBox->SetDragDropMode( SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY );
585 0 : m_pBasicBox->EnableInplaceEditing(true);
586 0 : m_pBasicBox->SetMode( nMode );
587 : m_pBasicBox->SetStyle( WB_BORDER | WB_TABSTOP |
588 : WB_HASLINES | WB_HASLINESATROOT |
589 : WB_HASBUTTONS | WB_HASBUTTONSATROOT |
590 0 : WB_HSCROLL );
591 0 : m_pBasicBox->ScanAllEntries();
592 :
593 0 : m_pEditButton->GrabFocus();
594 0 : CheckButtons();
595 0 : }
596 :
597 0 : void ObjectPage::SetCurrentEntry (EntryDescriptor& rDesc)
598 : {
599 0 : m_pBasicBox->SetCurrentEntry( rDesc );
600 0 : }
601 :
602 0 : void ObjectPage::ActivatePage()
603 : {
604 0 : m_pBasicBox->UpdateEntries();
605 0 : }
606 :
607 0 : void ObjectPage::DeactivatePage()
608 : {
609 0 : }
610 :
611 0 : void ObjectPage::CheckButtons()
612 : {
613 : // enable/disable edit button
614 0 : SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
615 0 : EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(pCurEntry);
616 0 : ScriptDocument aDocument( aDesc.GetDocument() );
617 0 : OUString aLibName( aDesc.GetLibName() );
618 0 : OUString aLibSubName( aDesc.GetLibSubName() );
619 0 : bool bVBAEnabled = aDocument.isInVBAMode();
620 0 : sal_uInt16 nMode = m_pBasicBox->GetMode();
621 :
622 0 : sal_uInt16 nDepth = pCurEntry ? m_pBasicBox->GetModel()->GetDepth( pCurEntry ) : 0;
623 0 : if ( nDepth >= 2 )
624 : {
625 0 : if( bVBAEnabled && ( nMode & BROWSEMODE_MODULES ) && ( nDepth == 2 ) )
626 0 : m_pEditButton->Disable();
627 : else
628 0 : m_pEditButton->Enable();
629 : }
630 : else
631 0 : m_pEditButton->Disable();
632 :
633 : // enable/disable new module/dialog buttons
634 0 : LibraryLocation eLocation( aDesc.GetLocation() );
635 0 : bool bReadOnly = false;
636 0 : if ( nDepth > 0 )
637 : {
638 0 : Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
639 0 : Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
640 0 : if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
641 0 : ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) )
642 : {
643 0 : bReadOnly = true;
644 0 : }
645 : }
646 0 : if ( bReadOnly || eLocation == LIBRARY_LOCATION_SHARE )
647 : {
648 0 : m_pNewModButton->Disable();
649 0 : m_pNewDlgButton->Disable();
650 : }
651 : else
652 : {
653 0 : m_pNewModButton->Enable();
654 0 : m_pNewDlgButton->Enable();
655 : }
656 :
657 : // enable/disable delete button
658 0 : if ( nDepth >= 2 && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE )
659 : {
660 0 : if( bVBAEnabled && ( nMode & BROWSEMODE_MODULES ) && ( ( nDepth == 2 ) || aLibSubName == IDE_RESSTR(RID_STR_DOCUMENT_OBJECTS) ) )
661 0 : m_pDelButton->Disable();
662 : else
663 0 : m_pDelButton->Enable();
664 : }
665 : else
666 0 : m_pDelButton->Disable();
667 0 : }
668 :
669 0 : IMPL_LINK( ObjectPage, BasicBoxHighlightHdl, TreeListBox *, pBox )
670 : {
671 0 : if ( !pBox->IsSelected( pBox->GetHdlEntry() ) )
672 0 : return 0;
673 :
674 0 : CheckButtons();
675 0 : return 0;
676 : }
677 :
678 0 : IMPL_LINK( ObjectPage, ButtonHdl, Button *, pButton )
679 : {
680 0 : if (pButton == m_pEditButton)
681 : {
682 0 : SfxAllItemSet aArgs( SFX_APP()->GetPool() );
683 0 : SfxRequest aRequest( SID_BASICIDE_APPEAR, SFX_CALLMODE_SYNCHRON, aArgs );
684 0 : SFX_APP()->ExecuteSlot( aRequest );
685 :
686 0 : SfxDispatcher* pDispatcher = GetDispatcher();
687 0 : SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
688 : DBG_ASSERT( pCurEntry, "Entry?!" );
689 0 : if ( m_pBasicBox->GetModel()->GetDepth( pCurEntry ) >= 2 )
690 : {
691 0 : EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(pCurEntry);
692 0 : if ( pDispatcher )
693 : {
694 0 : OUString aModName( aDesc.GetName() );
695 : // extract the module name from the string like "Sheet1 (Example1)"
696 0 : if( aDesc.GetLibSubName() == IDE_RESSTR(RID_STR_DOCUMENT_OBJECTS) )
697 : {
698 0 : sal_Int32 nIndex = 0;
699 0 : aModName = aModName.getToken( 0, ' ', nIndex );
700 : }
701 0 : SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(),
702 0 : aModName, m_pBasicBox->ConvertType( aDesc.GetType() ) );
703 0 : pDispatcher->Execute( SID_BASICIDE_SHOWSBX, SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
704 0 : }
705 : }
706 : else // Nur Lib selektiert
707 : {
708 : DBG_ASSERT( m_pBasicBox->GetModel()->GetDepth( pCurEntry ) == 1, "Kein LibEntry?!" );
709 0 : ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
710 0 : SvTreeListEntry* pParentEntry = m_pBasicBox->GetParent( pCurEntry );
711 0 : if ( pParentEntry )
712 : {
713 0 : DocumentEntry* pDocumentEntry = (DocumentEntry*)pParentEntry->GetUserData();
714 0 : if (pDocumentEntry)
715 0 : aDocument = pDocumentEntry->GetDocument();
716 : }
717 0 : SfxUsrAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( aDocument.getDocumentOrNull() ) );
718 0 : OUString aLibName( m_pBasicBox->GetEntryText( pCurEntry ) );
719 0 : SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
720 0 : if ( pDispatcher )
721 : {
722 0 : pDispatcher->Execute( SID_BASICIDE_LIBSELECTED, SFX_CALLMODE_ASYNCHRON, &aDocItem, &aLibNameItem, 0L );
723 0 : }
724 : }
725 0 : EndTabDialog( 1 );
726 : }
727 0 : else if (pButton == m_pNewModButton)
728 0 : NewModule();
729 0 : else if (pButton == m_pNewDlgButton)
730 0 : NewDialog();
731 0 : else if (pButton == m_pDelButton)
732 0 : DeleteCurrent();
733 :
734 0 : return 0;
735 : }
736 :
737 0 : bool ObjectPage::GetSelection( ScriptDocument& rDocument, OUString& rLibName )
738 : {
739 0 : bool bRet = false;
740 :
741 0 : SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
742 0 : EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(pCurEntry);
743 0 : rDocument = aDesc.GetDocument();
744 0 : rLibName = aDesc.GetLibName();
745 0 : if ( rLibName.isEmpty() )
746 0 : rLibName = "Standard" ;
747 :
748 : DBG_ASSERT( rDocument.isAlive(), "ObjectPage::GetSelection: no or dead ScriptDocument in the selection!" );
749 0 : if ( !rDocument.isAlive() )
750 0 : return false;
751 :
752 : // check if the module library is loaded
753 0 : bool bOK = true;
754 0 : OUString aLibName( rLibName );
755 0 : Reference< script::XLibraryContainer > xModLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) );
756 0 : if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && !xModLibContainer->isLibraryLoaded( aLibName ) )
757 : {
758 : // check password
759 0 : Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
760 0 : if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
761 : {
762 0 : OUString aPassword;
763 0 : bOK = QueryPassword( xModLibContainer, rLibName, aPassword );
764 : }
765 :
766 : // load library
767 0 : if ( bOK )
768 0 : xModLibContainer->loadLibrary( aLibName );
769 : }
770 :
771 : // check if the dialog library is loaded
772 0 : Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_DIALOGS ) );
773 0 : if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && !xDlgLibContainer->isLibraryLoaded( aLibName ) )
774 : {
775 : // load library
776 0 : if ( bOK )
777 0 : xDlgLibContainer->loadLibrary( aLibName );
778 : }
779 :
780 0 : if ( bOK )
781 0 : bRet = true;
782 :
783 0 : return bRet;
784 : }
785 :
786 0 : void ObjectPage::NewModule()
787 : {
788 0 : ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
789 0 : OUString aLibName;
790 :
791 0 : if ( GetSelection( aDocument, aLibName ) )
792 : {
793 0 : OUString aModName;
794 : createModImpl( static_cast<Window*>( this ), aDocument,
795 0 : *m_pBasicBox, aLibName, aModName, true );
796 0 : }
797 0 : }
798 :
799 0 : void ObjectPage::NewDialog()
800 : {
801 0 : ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
802 0 : OUString aLibName;
803 :
804 0 : if ( GetSelection( aDocument, aLibName ) )
805 : {
806 0 : aDocument.getOrCreateLibrary( E_DIALOGS, aLibName );
807 :
808 0 : NewObjectDialog aNewDlg(this, ObjectMode::Dialog, true);
809 0 : aNewDlg.SetObjectName( aDocument.createObjectName( E_DIALOGS, aLibName ) );
810 :
811 0 : if (aNewDlg.Execute() != 0)
812 : {
813 0 : OUString aDlgName = aNewDlg.GetObjectName();
814 0 : if (aDlgName.isEmpty())
815 0 : aDlgName = aDocument.createObjectName( E_DIALOGS, aLibName);
816 :
817 0 : if ( aDocument.hasDialog( aLibName, aDlgName ) )
818 : {
819 : ErrorBox( this, WB_OK | WB_DEF_OK,
820 0 : IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED2) ).Execute();
821 : }
822 : else
823 : {
824 0 : Reference< io::XInputStreamProvider > xISP;
825 0 : if ( !aDocument.createDialog( aLibName, aDlgName, xISP ) )
826 0 : return;
827 :
828 0 : SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aDlgName, TYPE_DIALOG );
829 0 : if (SfxDispatcher* pDispatcher = GetDispatcher())
830 : pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
831 0 : SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
832 0 : LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
833 0 : SvTreeListEntry* pRootEntry = m_pBasicBox->FindRootEntry( aDocument, eLocation );
834 0 : if ( pRootEntry )
835 : {
836 0 : if ( !m_pBasicBox->IsExpanded( pRootEntry ) )
837 0 : m_pBasicBox->Expand( pRootEntry );
838 0 : SvTreeListEntry* pLibEntry = m_pBasicBox->FindEntry( pRootEntry, aLibName, OBJ_TYPE_LIBRARY );
839 : DBG_ASSERT( pLibEntry, "Libeintrag nicht gefunden!" );
840 0 : if ( pLibEntry )
841 : {
842 0 : if ( !m_pBasicBox->IsExpanded( pLibEntry ) )
843 0 : m_pBasicBox->Expand( pLibEntry );
844 0 : SvTreeListEntry* pEntry = m_pBasicBox->FindEntry( pLibEntry, aDlgName, OBJ_TYPE_DIALOG );
845 0 : if ( !pEntry )
846 : {
847 0 : o3tl::heap_ptr<Entry> e(new Entry(OBJ_TYPE_DIALOG));
848 : pEntry = m_pBasicBox->AddEntry(
849 : aDlgName,
850 : Image( IDEResId( RID_IMG_DIALOG ) ),
851 0 : pLibEntry, false, &e);
852 0 : DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" );
853 : }
854 0 : m_pBasicBox->SetCurEntry( pEntry );
855 0 : m_pBasicBox->Select( m_pBasicBox->GetCurEntry() ); // OV-Bug?!
856 : }
857 0 : }
858 0 : }
859 0 : }
860 0 : }
861 : }
862 :
863 0 : void ObjectPage::DeleteCurrent()
864 : {
865 0 : SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
866 : DBG_ASSERT( pCurEntry, "Kein aktueller Eintrag!" );
867 0 : EntryDescriptor aDesc( m_pBasicBox->GetEntryDescriptor( pCurEntry ) );
868 0 : ScriptDocument aDocument( aDesc.GetDocument() );
869 : DBG_ASSERT( aDocument.isAlive(), "ObjectPage::DeleteCurrent: no document!" );
870 0 : if ( !aDocument.isAlive() )
871 0 : return;
872 0 : OUString aLibName( aDesc.GetLibName() );
873 0 : OUString aName( aDesc.GetName() );
874 0 : EntryType eType = aDesc.GetType();
875 :
876 0 : if ( ( eType == OBJ_TYPE_MODULE && QueryDelModule( aName, this ) ) ||
877 0 : ( eType == OBJ_TYPE_DIALOG && QueryDelDialog( aName, this ) ) )
878 : {
879 0 : m_pBasicBox->GetModel()->Remove( pCurEntry );
880 0 : if ( m_pBasicBox->GetCurEntry() ) // OV-Bug ?
881 0 : m_pBasicBox->Select( m_pBasicBox->GetCurEntry() );
882 0 : if (SfxDispatcher* pDispatcher = GetDispatcher())
883 : {
884 0 : SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aName, m_pBasicBox->ConvertType( eType ) );
885 : pDispatcher->Execute( SID_BASICIDE_SBXDELETED,
886 0 : SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
887 : }
888 :
889 : try
890 : {
891 0 : bool bSuccess = false;
892 0 : if ( eType == OBJ_TYPE_MODULE )
893 0 : bSuccess = aDocument.removeModule( aLibName, aName );
894 0 : else if ( eType == OBJ_TYPE_DIALOG )
895 0 : bSuccess = RemoveDialog( aDocument, aLibName, aName );
896 :
897 0 : if ( bSuccess )
898 0 : MarkDocumentModified( aDocument );
899 : }
900 0 : catch (const container::NoSuchElementException& )
901 : {
902 : DBG_UNHANDLED_EXCEPTION();
903 : }
904 0 : }
905 : }
906 :
907 :
908 :
909 0 : void ObjectPage::EndTabDialog( sal_uInt16 nRet )
910 : {
911 : DBG_ASSERT( pTabDlg, "TabDlg nicht gesetzt!" );
912 0 : if ( pTabDlg )
913 0 : pTabDlg->EndDialog( nRet );
914 0 : }
915 :
916 0 : LibDialog::LibDialog( Window* pParent )
917 0 : : ModalDialog(pParent, "ImportLibDialog", "modules/BasicIDE/ui/importlibdialog.ui")
918 : {
919 0 : get(m_pStorageFrame, "storageframe");
920 0 : get(m_pReferenceBox, "ref");
921 0 : get(m_pReplaceBox, "replace");
922 0 : get(m_pLibBox, "entries");
923 0 : m_pLibBox->set_height_request(m_pLibBox->GetTextHeight() * 8);
924 0 : m_pLibBox->set_width_request(m_pLibBox->approximate_char_width() * 32);
925 0 : }
926 :
927 0 : void LibDialog::SetStorageName( const OUString& rName )
928 : {
929 0 : OUString aName( IDE_RESSTR(RID_STR_FILENAME) );
930 0 : aName += rName;
931 0 : m_pStorageFrame->set_label(aName);
932 0 : }
933 :
934 : // Helper function
935 0 : SbModule* createModImpl( Window* pWin, const ScriptDocument& rDocument,
936 : TreeListBox& rBasicBox, const OUString& rLibName, const OUString& _aModName, bool bMain )
937 : {
938 : OSL_ENSURE( rDocument.isAlive(), "createModImpl: invalid document!" );
939 0 : if ( !rDocument.isAlive() )
940 0 : return NULL;
941 :
942 0 : SbModule* pModule = NULL;
943 :
944 0 : OUString aLibName( rLibName );
945 0 : if ( aLibName.isEmpty() )
946 0 : aLibName = "Standard" ;
947 0 : rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
948 0 : OUString aModName = _aModName;
949 0 : if ( aModName.isEmpty() )
950 0 : aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
951 :
952 0 : NewObjectDialog aNewDlg(pWin, ObjectMode::Module, true);
953 0 : aNewDlg.SetObjectName( aModName );
954 :
955 0 : if (aNewDlg.Execute() != 0)
956 : {
957 0 : if (!aNewDlg.GetObjectName().isEmpty() )
958 0 : aModName = aNewDlg.GetObjectName();
959 :
960 : try
961 : {
962 0 : OUString sModuleCode;
963 : // the module has existed
964 0 : if( rDocument.hasModule( aLibName, aModName ) )
965 0 : return NULL;
966 0 : rDocument.createModule( aLibName, aModName, bMain, sModuleCode );
967 0 : BasicManager* pBasMgr = rDocument.getBasicManager();
968 0 : StarBASIC* pBasic = pBasMgr? pBasMgr->GetLib( aLibName ) : 0;
969 0 : if ( pBasic )
970 0 : pModule = pBasic->FindModule( aModName );
971 0 : SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, TYPE_MODULE );
972 0 : if (SfxDispatcher* pDispatcher = GetDispatcher())
973 : pDispatcher->Execute( SID_BASICIDE_SBXINSERTED,
974 0 : SFX_CALLMODE_SYNCHRON, &aSbxItem, 0L );
975 0 : LibraryLocation eLocation = rDocument.getLibraryLocation( aLibName );
976 0 : SvTreeListEntry* pRootEntry = rBasicBox.FindRootEntry( rDocument, eLocation );
977 0 : if ( pRootEntry )
978 : {
979 0 : if ( !rBasicBox.IsExpanded( pRootEntry ) )
980 0 : rBasicBox.Expand( pRootEntry );
981 0 : SvTreeListEntry* pLibEntry = rBasicBox.FindEntry( pRootEntry, aLibName, OBJ_TYPE_LIBRARY );
982 : DBG_ASSERT( pLibEntry, "Libeintrag nicht gefunden!" );
983 0 : if ( pLibEntry )
984 : {
985 0 : if ( !rBasicBox.IsExpanded( pLibEntry ) )
986 0 : rBasicBox.Expand( pLibEntry );
987 0 : SvTreeListEntry* pSubRootEntry = pLibEntry;
988 0 : if( pBasic && rDocument.isInVBAMode() )
989 : {
990 : // add the new module in the "Modules" entry
991 0 : SvTreeListEntry* pLibSubEntry = rBasicBox.FindEntry( pLibEntry, IDE_RESSTR(RID_STR_NORMAL_MODULES) , OBJ_TYPE_NORMAL_MODULES );
992 0 : if( pLibSubEntry )
993 : {
994 0 : if( !rBasicBox.IsExpanded( pLibSubEntry ) )
995 0 : rBasicBox.Expand( pLibSubEntry );
996 0 : pSubRootEntry = pLibSubEntry;
997 : }
998 : }
999 :
1000 0 : SvTreeListEntry* pEntry = rBasicBox.FindEntry( pSubRootEntry, aModName, OBJ_TYPE_MODULE );
1001 0 : if ( !pEntry )
1002 : {
1003 0 : o3tl::heap_ptr<Entry> e(new Entry(OBJ_TYPE_MODULE));
1004 : pEntry = rBasicBox.AddEntry(
1005 : aModName,
1006 : Image( IDEResId( RID_IMG_MODULE ) ),
1007 0 : pSubRootEntry, false, &e);
1008 0 : DBG_ASSERT( pEntry, "InsertEntry fehlgeschlagen!" );
1009 : }
1010 0 : rBasicBox.SetCurEntry( pEntry );
1011 0 : rBasicBox.Select( rBasicBox.GetCurEntry() ); // OV-Bug?!
1012 : }
1013 0 : }
1014 : }
1015 0 : catch (const container::ElementExistException& )
1016 : {
1017 : ErrorBox( pWin, WB_OK | WB_DEF_OK,
1018 0 : IDE_RESSTR(RID_STR_SBXNAMEALLREADYUSED2) ).Execute();
1019 : }
1020 0 : catch (const container::NoSuchElementException& )
1021 : {
1022 : DBG_UNHANDLED_EXCEPTION();
1023 : }
1024 : }
1025 0 : return pModule;
1026 : }
1027 :
1028 :
1029 0 : } // namespace basctl
1030 :
1031 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|