LibreOffice Module basctl (master) 1
moduldlg.cxx
Go to the documentation of this file.
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 <sal/config.h>
21
22#include <strings.hrc>
23#include <iderid.hxx>
24#include <bitmaps.hlst>
25
26#include "moduldlg.hxx"
27#include <localizationmgr.hxx>
28#include <basidesh.hxx>
29#include <basobj.hxx>
30
31#include <basic/basmgr.hxx>
32#include <com/sun/star/script/XLibraryContainerPassword.hpp>
33#include <com/sun/star/script/XLibraryContainer2.hpp>
34#include <com/sun/star/frame/XController.hpp>
36#include <sfx2/app.hxx>
37#include <sfx2/dispatch.hxx>
38#include <sfx2/frame.hxx>
39#include <sfx2/request.hxx>
40#include <sfx2/sfxsids.hrc>
41#include <svl/stritem.hxx>
42#include <vcl/transfer.hxx>
43#include <vcl/svapp.hxx>
44#include <vcl/weld.hxx>
45#include <tools/debug.hxx>
48#include <com/sun/star/uno/XComponentContext.hpp>
49
50namespace basctl
51{
52
53using namespace ::com::sun::star;
54using namespace ::com::sun::star::uno;
55using namespace ::com::sun::star::resource;
56
57IMPL_LINK(ObjectPage, EditingEntryHdl, const weld::TreeIter&, rEntry, bool)
58{
59 bool bRet = false;
60
61 sal_uInt16 nDepth = m_xBasicBox->get_iter_depth(rEntry);
62 if (nDepth >= 2)
63 {
64 EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(&rEntry);
65 const ScriptDocument& aDocument( aDesc.GetDocument() );
66 const OUString& aLibName( aDesc.GetLibName() );
69 if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
70 ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) )
71 {
72 // allow editing only for libraries, which are not readonly
73 bRet = true;
74 }
75 }
76
77 return bRet;
78}
79
80IMPL_LINK(ObjectPage, EditedEntryHdl, const IterString&, rIterString, bool)
81{
82 const weld::TreeIter& rEntry = rIterString.first;
83 OUString sNewText = rIterString.second;
84
85 if ( !IsValidSbxName(sNewText) )
86 {
87 std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(m_pDialog->getDialog(),
88 VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_BADSBXNAME)));
89 xError->run();
90 return false;
91 }
92
93 OUString aCurText(m_xBasicBox->get_text(rEntry));
94 if ( aCurText == sNewText )
95 // nothing to do
96 return true;
97
98 EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(&rEntry);
99 const ScriptDocument& aDocument( aDesc.GetDocument() );
100 DBG_ASSERT( aDocument.isValid(), "ExtTreeListBox::EditedEntry: no document!" );
101 if ( !aDocument.isValid() )
102 return false;
103 const OUString& aLibName( aDesc.GetLibName() );
104 EntryType eType = aDesc.GetType();
105
106 bool bSuccess = eType == OBJ_TYPE_MODULE ?
107 RenameModule(m_pDialog->getDialog(), aDocument, aLibName, aCurText, sNewText) :
108 RenameDialog(m_pDialog->getDialog(), aDocument, aLibName, aCurText, sNewText);
109
110 if ( !bSuccess )
111 return false;
112
114
115 if (SfxDispatcher* pDispatcher = GetDispatcher())
116 {
117 SbxItem aSbxItem(SID_BASICIDE_ARG_SBX, aDocument, aLibName, sNewText, SbTreeListBox::ConvertType(eType));
118 pDispatcher->ExecuteList( SID_BASICIDE_SBXRENAMED,
119 SfxCallMode::SYNCHRON, { &aSbxItem });
120 }
121
122 // OV-Bug?!
123 m_xBasicBox->set_text(rEntry, sNewText);
124 m_xBasicBox->set_cursor(rEntry);
125 m_xBasicBox->unselect(rEntry);
126 m_xBasicBox->select(rEntry); // so that handler is called => update edit
127
128 return true;
129}
130
133 ScriptDocument const& rSourceDoc,
134 OUString const& rSourceLibName,
135 ScriptDocument const& rDestDoc,
136 OUString const& rDestLibName,
137 std::u16string_view rDlgName
138)
139{
140 if ( !io_xISP.is() )
141 return;
142
143 // Get StringResourceManager
144 Reference< container::XNameContainer > xSourceDialogLib( rSourceDoc.getLibrary( E_DIALOGS, rSourceLibName, true ) );
147 if( !xSourceMgr.is() )
148 return;
149 bool bSourceLocalized = xSourceMgr->getLocales().hasElements();
150
151 Reference< container::XNameContainer > xDestDialogLib( rDestDoc.getLibrary( E_DIALOGS, rDestLibName, true ) );
154 if( !xDestMgr.is() )
155 return;
156 bool bDestLocalized = xDestMgr->getLocales().hasElements();
157
158 if( !bSourceLocalized && !bDestLocalized )
159 return;
160
161 // create dialog model
163 Reference< container::XNameContainer > xDialogModel( xContext->getServiceManager()->createInstanceWithContext
164 ( "com.sun.star.awt.UnoControlDialogModel", xContext ), UNO_QUERY );
165 Reference< io::XInputStream > xInput( io_xISP->createInputStream() );
166 ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rSourceDoc.isDocument() ? rSourceDoc.getDocument() : Reference< frame::XModel >() );
167
168 if( !xDialogModel.is() )
169 return;
170
171 if( bSourceLocalized && bDestLocalized )
172 {
173 LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, rDlgName, xDestMgr, xSourceMgr );
174 }
175 else if( bSourceLocalized )
176 {
177 LocalizationMgr::resetResourceForDialog( xDialogModel, xSourceMgr );
178 }
179 else if( bDestLocalized )
180 {
181 LocalizationMgr::setResourceIDsForDialog( xDialogModel, xDestMgr );
182 }
183 io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.isDocument() ? rDestDoc.getDocument() : Reference< frame::XModel >() );
184}
185
186void OrganizeDialog::SetCurrentEntry(const css::uno::Reference<css::frame::XFrame>& xDocFrame)
187{
188 if (!xDocFrame)
189 return;
190 Reference<css::frame::XController> xController(xDocFrame->getController());
191 if (!xController)
192 return;
194 if (!xModel)
195 return;
196 ScriptDocument aScriptDocument(xModel);
197 EntryDescriptor aDesc(aScriptDocument, LIBRARY_LOCATION_DOCUMENT, OUString(), OUString(), OUString(), OBJ_TYPE_DOCUMENT);
198 m_xModulePage->SetCurrentEntry(aDesc);
199 m_xDialogPage->SetCurrentEntry(aDesc);
200}
201
202// OrganizeDialog
203OrganizeDialog::OrganizeDialog(weld::Window* pParent, const css::uno::Reference<css::frame::XFrame>& xDocFrame, sal_Int16 tabId)
204 : GenericDialogController(pParent, "modules/BasicIDE/ui/organizedialog.ui", "OrganizeDialog")
205 , m_xTabCtrl(m_xBuilder->weld_notebook("tabcontrol"))
206 , m_xModulePage(new ObjectPage(m_xTabCtrl->get_page("modules"), "ModulePage", BrowseMode::Modules, this))
207 , m_xDialogPage(new ObjectPage(m_xTabCtrl->get_page("dialogs"), "DialogPage", BrowseMode::Dialogs, this))
208 , m_xLibPage(new LibPage(m_xTabCtrl->get_page("libraries"), this))
209{
210 m_xTabCtrl->connect_enter_page(LINK(this, OrganizeDialog, ActivatePageHdl));
211
212 SetCurrentEntry(xDocFrame);
213
214 OUString sPage;
215 if (tabId == 0)
216 sPage = "modules";
217 else if (tabId == 1)
218 sPage = "dialogs";
219 else
220 sPage = "libraries";
221 m_xTabCtrl->set_current_page(sPage);
222 ActivatePageHdl(sPage);
223
224 if (SfxDispatcher* pDispatcher = GetDispatcher())
225 pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
226}
227
228IMPL_LINK(OrganizeDialog, ActivatePageHdl, const OUString&, rPage, void)
229{
230 if (rPage == "modules")
231 m_xModulePage->ActivatePage();
232 else if (rPage == "dialogs")
233 m_xDialogPage->ActivatePage();
234 else if (rPage == "libraries")
235 m_xLibPage->ActivatePage();
236}
237
239{
240}
241
242OrganizePage::OrganizePage(weld::Container* pParent, const OUString& rUIFile, const OUString &rName, OrganizeDialog* pDialog)
243 : m_pDialog(pDialog)
244 , m_xBuilder(Application::CreateBuilder(pParent, rUIFile))
245 , m_xContainer(m_xBuilder->weld_container(rName))
246{
247}
248
250{
251}
252
253class SbTreeListBoxDropTarget : public DropTargetHelper
254{
255private:
257
258 virtual sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt) override
259 {
260 // to enable the autoscroll when we're close to the edges
262 rWidget.get_dest_row_at_pos(rEvt.maPosPixel, nullptr, true);
263
264 weld::TreeView* pSource = rWidget.get_drag_source();
265 if (!pSource)
266 return DND_ACTION_NONE;
267
268 // tdf#145722 only return a DND_ACTION_MOVE possibility if that
269 // is requested as an option
270 const bool bCheckForMove = rEvt.mnAction & DND_ACTION_MOVE;
271
273
274 std::unique_ptr<weld::TreeIter> xEntry(pSource->make_iterator());
275 if (pSource->get_selected(xEntry.get()))
276 {
277 sal_uInt16 nDepth = pSource->get_iter_depth(*xEntry);
278 if (nDepth >= 2)
279 {
280 nMode = DND_ACTION_COPY;
281 if (bCheckForMove)
282 {
283 EntryDescriptor aDesc = m_rTreeView.GetEntryDescriptor(xEntry.get());
284 const ScriptDocument& aDocument( aDesc.GetDocument() );
285 const OUString& aLibName( aDesc.GetLibName() );
286 // allow MOVE mode only for libraries, which are not readonly
287 Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
288 Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
289 if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
290 ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) )
291 {
292 // Only allow copy for localized libraries
293 bool bAllowMove = true;
294 if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
295 {
296 // Get StringResourceManager
297 Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, aLibName, true ) );
300 if( xSourceMgr.is() )
301 bAllowMove = ( xSourceMgr->getLocales().getLength() == 0 );
302 }
303 if( bAllowMove )
304 nMode |= DND_ACTION_MOVE;
305 }
306 }
307 }
308 }
309 return nMode;
310 }
311
312 virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt) override
313 {
315 weld::TreeView* pSource = rWidget.get_drag_source();
316 if (!pSource)
317 return DND_ACTION_NONE;
318
319 std::unique_ptr<weld::TreeIter> xEntry(rWidget.make_iterator());
320 bool bEntry = rWidget.get_dest_row_at_pos(rEvt.maPosPixel, xEntry.get(), true);
321
322 // don't drop on a BasicManager (nDepth == 0)
323 sal_uInt16 nDepth = bEntry ? m_rTreeView.get_iter_depth(*xEntry) : 0;
324 bool bValid = nDepth != 0;
325 // don't drop in the same library
326 std::unique_ptr<weld::TreeIter> xSelected(pSource->make_iterator());
327 bool bSelected = pSource->get_selected(xSelected.get());
328 if (!bSelected)
329 bValid = false;
330 else if (nDepth == 1)
331 {
332 std::unique_ptr<weld::TreeIter> xSelParent(pSource->make_iterator(xSelected.get()));
333 if (pSource->iter_parent(*xSelParent) && pSource->iter_compare(*xEntry, *xSelParent) == 0)
334 bValid = false;
335 }
336 else if (nDepth == 2)
337 {
338 std::unique_ptr<weld::TreeIter> xParent(pSource->make_iterator(xEntry.get()));
339 std::unique_ptr<weld::TreeIter> xSelParent(pSource->make_iterator(xSelected.get()));
340 if (pSource->iter_parent(*xParent) && pSource->iter_parent(*xSelParent) && pSource->iter_compare(*xParent, *xSelParent) == 0)
341 bValid = false;
342 }
343
344 // don't drop on a library, which is not loaded, readonly or password protected
345 // or which already has a module/dialog with this name
346 if ( bValid && ( nDepth > 0 ) )
347 {
348 // get source module/dialog name
349 EntryDescriptor aSourceDesc = m_rTreeView.GetEntryDescriptor(xSelected.get());
350 const OUString& aSourceName = aSourceDesc.GetName();
351 EntryType eSourceType = aSourceDesc.GetType();
352
353 // get target shell and target library name
354 EntryDescriptor aDestDesc = m_rTreeView.GetEntryDescriptor(xEntry.get());
355 ScriptDocument const& rDestDoc = aDestDesc.GetDocument();
356 const OUString& aDestLibName = aDestDesc.GetLibName();
357
358 // check if module library is not loaded, readonly or password protected
359 Reference< script::XLibraryContainer2 > xModLibContainer( rDestDoc.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
360 if ( xModLibContainer.is() && xModLibContainer->hasByName( aDestLibName ) )
361 {
362 if ( !xModLibContainer->isLibraryLoaded( aDestLibName ) )
363 bValid = false;
364
365 if ( xModLibContainer->isLibraryReadOnly( aDestLibName ) )
366 bValid = false;
367
368 Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
369 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aDestLibName ) && !xPasswd->isLibraryPasswordVerified( aDestLibName ) )
370 bValid = false;
371 }
372
373 // check if dialog library is not loaded or readonly
374 Reference< script::XLibraryContainer2 > xDlgLibContainer( rDestDoc.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
375 if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aDestLibName ) )
376 {
377 if ( !xDlgLibContainer->isLibraryLoaded( aDestLibName ) )
378 bValid = false;
379
380 if ( xDlgLibContainer->isLibraryReadOnly( aDestLibName ) )
381 bValid = false;
382 }
383
384 // check, if module/dialog with this name is already existing in target library
385 if ( ( eSourceType == OBJ_TYPE_MODULE && rDestDoc.hasModule( aDestLibName, aSourceName ) ) ||
386 ( eSourceType == OBJ_TYPE_DIALOG && rDestDoc.hasDialog( aDestLibName, aSourceName ) ) )
387 {
388 bValid = false;
389 }
390 }
391
392 if (bValid)
394
395 return DND_ACTION_NONE;
396 }
397
398 void NotifyCopyingMoving(const weld::TreeIter& rTarget, bool bMove)
399 {
400 sal_uInt16 nDepth = m_rTreeView.get_iter_depth(rTarget);
401 std::unique_ptr<weld::TreeIter> xNewParent(m_rTreeView.make_iterator(&rTarget));
402 int nNewChildPos = 0;
403 DBG_ASSERT( nDepth, "Depth?" );
404 if ( nDepth >= 2 )
405 {
406 // Target = module/dialog => put module/dialog under the superordinate Basic
407 m_rTreeView.iter_parent(*xNewParent);
408 nNewChildPos = m_rTreeView.get_iter_index_in_parent(rTarget) + 1;
409 }
410
411 // get target shell and target library name
412 EntryDescriptor aDestDesc = m_rTreeView.GetEntryDescriptor(xNewParent.get());
413 const ScriptDocument& rDestDoc( aDestDesc.GetDocument() );
414 const OUString& aDestLibName( aDestDesc.GetLibName() );
415
416 // get source shell, library name and module/dialog name
417 std::unique_ptr<weld::TreeIter> xSelected(m_rTreeView.make_iterator());
418 if (!m_rTreeView.get_selected(xSelected.get()))
419 return;
420 EntryDescriptor aSourceDesc = m_rTreeView.GetEntryDescriptor(xSelected.get());
421 const ScriptDocument& rSourceDoc( aSourceDesc.GetDocument() );
422 const OUString& aSourceLibName( aSourceDesc.GetLibName() );
423 const OUString& aSourceName( aSourceDesc.GetName() );
424 EntryType eType = aSourceDesc.GetType();
425
426 // get dispatcher
427 SfxDispatcher* pDispatcher = GetDispatcher();
428
429 if ( bMove ) // move
430 {
431 // remove source module/dialog window
432 if ( rSourceDoc != rDestDoc || aSourceLibName != aDestLibName )
433 {
434 if( pDispatcher )
435 {
436 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rSourceDoc, aSourceLibName, aSourceName, SbTreeListBox::ConvertType(eType) );
437 pDispatcher->ExecuteList( SID_BASICIDE_SBXDELETED,
438 SfxCallMode::SYNCHRON, { &aSbxItem });
439 }
440 }
441
442 try
443 {
444 if ( eType == OBJ_TYPE_MODULE ) // module
445 {
446 // get module
447 OUString aModule;
448 if ( rSourceDoc.getModule( aSourceLibName, aSourceName, aModule ) )
449 {
450 // remove module from source library
451 if ( rSourceDoc.removeModule( aSourceLibName, aSourceName ) )
452 {
453 MarkDocumentModified( rSourceDoc );
454
455 // insert module into target library
456 if ( rDestDoc.insertModule( aDestLibName, aSourceName, aModule ) )
457 MarkDocumentModified( rDestDoc );
458 }
459 }
460 }
461 else if ( eType == OBJ_TYPE_DIALOG ) // dialog
462 {
463 // get dialog
465 if ( rSourceDoc.getDialog( aSourceLibName, aSourceName, xISP ) )
466 {
467 Shell::CopyDialogResources( xISP, rSourceDoc,
468 aSourceLibName, rDestDoc, aDestLibName, aSourceName );
469
470 // remove dialog from source library
471 if (RemoveDialog(rSourceDoc, aSourceLibName, aSourceName))
472 {
473 MarkDocumentModified(rSourceDoc);
474
475 // insert dialog into target library
476 if ( rDestDoc.insertDialog( aDestLibName, aSourceName, xISP ) )
477 MarkDocumentModified(rDestDoc);
478 }
479 }
480 }
481 }
482 catch (const uno::Exception& )
483 {
484 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
485 }
486 }
487 else // copy
488 {
489 try
490 {
491 if ( eType == OBJ_TYPE_MODULE ) // module
492 {
493 // get module
494 OUString aModule;
495 if ( rSourceDoc.getModule( aSourceLibName, aSourceName, aModule ) )
496 {
497 // insert module into target library
498 if ( rDestDoc.insertModule( aDestLibName, aSourceName, aModule ) )
499 MarkDocumentModified( rDestDoc );
500 }
501 }
502 else if ( eType == OBJ_TYPE_DIALOG ) // dialog
503 {
504 // get dialog
506 if ( rSourceDoc.getDialog( aSourceLibName, aSourceName, xISP ) )
507 {
508 Shell::CopyDialogResources( xISP, rSourceDoc,
509 aSourceLibName, rDestDoc, aDestLibName, aSourceName );
510
511 // insert dialog into target library
512 if ( rDestDoc.insertDialog( aDestLibName, aSourceName, xISP ) )
513 MarkDocumentModified( rDestDoc );
514 }
515 }
516 }
517 catch ( const Exception& )
518 {
519 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
520 }
521 }
522
523 OUString sText(m_rTreeView.get_text(*xSelected));
524 OUString sId(m_rTreeView.get_id(*xSelected));
526 if (Entry* pEntry = bMove ? nullptr : weld::fromId<Entry*>(sId))
527 {
528 assert(pEntry->GetType() != OBJ_TYPE_DOCUMENT);
529 std::unique_ptr<Entry> xNewUserData(std::make_unique<Entry>(*pEntry));
530 sId = weld::toId(xNewUserData.release());
531 }
532 std::unique_ptr<weld::TreeIter> xRet(m_rTreeView.make_iterator());
533 m_rTreeView.get_widget().insert(xNewParent.get(), nNewChildPos, &sText, &sId, nullptr, nullptr, false, xRet.get());
534 if (eType == OBJ_TYPE_MODULE)
535 m_rTreeView.get_widget().set_image(*xRet, RID_BMP_MODULE);
536 else if (eType == OBJ_TYPE_DIALOG)
537 m_rTreeView.get_widget().set_image(*xRet, RID_BMP_DIALOG);
538 if (!m_rTreeView.get_row_expanded(*xNewParent))
539 m_rTreeView.expand_row(*xNewParent);
540 m_rTreeView.select(*xRet);
541
542 if (bMove)
543 m_rTreeView.remove(*xSelected);
544
545 // create target module/dialog window
546 if ( rSourceDoc != rDestDoc || aSourceLibName != aDestLibName )
547 {
548 if( pDispatcher )
549 {
550 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDestDoc, aDestLibName, aSourceName, SbTreeListBox::ConvertType(eType) );
551 pDispatcher->ExecuteList( SID_BASICIDE_SBXINSERTED,
552 SfxCallMode::SYNCHRON, { &aSbxItem });
553 }
554 }
555 }
556
557public:
559 : DropTargetHelper(rTreeView.get_widget().get_drop_target())
560 , m_rTreeView(rTreeView)
561 {
562 }
563};
564
565// ObjectPage
566ObjectPage::ObjectPage(weld::Container* pParent, const OUString &rName, BrowseMode nMode, OrganizeDialog* pDialog)
567 : OrganizePage(pParent, "modules/BasicIDE/ui/" + rName.toAsciiLowerCase() + ".ui",
568 rName, pDialog)
569 , m_xBasicBox(new SbTreeListBox(m_xBuilder->weld_tree_view("library"), pDialog->getDialog()))
570 , m_xEditButton(m_xBuilder->weld_button("edit"))
571 , m_xNewModButton(m_xBuilder->weld_button("newmodule"))
572 , m_xNewDlgButton(m_xBuilder->weld_button("newdialog"))
573 , m_xDelButton(m_xBuilder->weld_button("delete"))
574{
575 Size aSize(m_xBasicBox->get_approximate_digit_width() * 40,
576 m_xBasicBox->get_height_rows(14));
577 m_xBasicBox->set_size_request(aSize.Width(), aSize.Height());
578
579 // tdf#93476 The dialogs should be listed alphabetically
580 m_xBasicBox->make_sorted();
581
582 m_xEditButton->connect_clicked( LINK( this, ObjectPage, ButtonHdl ) );
583 m_xDelButton->connect_clicked( LINK( this, ObjectPage, ButtonHdl ) );
584 m_xBasicBox->connect_changed( LINK( this, ObjectPage, BasicBoxHighlightHdl ) );
585
586 if( nMode & BrowseMode::Modules )
587 {
588 m_xNewModButton->connect_clicked( LINK( this, ObjectPage, ButtonHdl ) );
589 m_xNewDlgButton->hide();
590 }
591 else if ( nMode & BrowseMode::Dialogs )
592 {
593 m_xNewDlgButton->connect_clicked( LINK( this, ObjectPage, ButtonHdl ) );
594 m_xNewModButton->hide();
595 }
596
598 // tdf#145722 explicitly claim COPY and MOVE are options
600 m_xBasicBox->get_widget().enable_drag_source(xHelper, DND_ACTION_COPYMOVE);
601
602 m_xBasicBox->connect_editing(LINK(this, ObjectPage, EditingEntryHdl),
603 LINK(this, ObjectPage, EditedEntryHdl));
604
605 m_xBasicBox->SetMode( nMode );
606 m_xBasicBox->ScanAllEntries();
607
608 m_xEditButton->grab_focus();
609 CheckButtons();
610}
611
613{
614}
615
617{
618 m_xBasicBox->UpdateEntries();
619 CheckButtons();
620}
621
623{
624 // enable/disable edit button
625 std::unique_ptr<weld::TreeIter> xCurEntry(m_xBasicBox->make_iterator());
626 if (!m_xBasicBox->get_cursor(xCurEntry.get()))
627 xCurEntry.reset();
628 EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(xCurEntry.get());
629 const ScriptDocument& aDocument( aDesc.GetDocument() );
630 const OUString& aLibName( aDesc.GetLibName() );
631 const OUString& aLibSubName( aDesc.GetLibSubName() );
632 bool bVBAEnabled = aDocument.isInVBAMode();
633 BrowseMode nMode = m_xBasicBox->GetMode();
634
635 sal_uInt16 nDepth = xCurEntry ? m_xBasicBox->get_iter_depth(*xCurEntry) : 0;
636 if ( nDepth >= 2 )
637 {
638 if( bVBAEnabled && ( nMode & BrowseMode::Modules ) && ( nDepth == 2 ) )
639 m_xEditButton->set_sensitive(false);
640 else
641 m_xEditButton->set_sensitive(true);
642 }
643 else
644 m_xEditButton->set_sensitive(false);
645
646 // enable/disable new module/dialog buttons
647 LibraryLocation eLocation( aDesc.GetLocation() );
648 bool bReadOnly = false;
649 if ( nDepth > 0 )
650 {
651 Reference< script::XLibraryContainer2 > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
652 Reference< script::XLibraryContainer2 > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
653 if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
654 ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) )
655 {
656 bReadOnly = true;
657 }
658 }
659 if ( bReadOnly || eLocation == LIBRARY_LOCATION_SHARE )
660 {
661 m_xNewModButton->set_sensitive(false);
662 m_xNewDlgButton->set_sensitive(false);
663 }
664 else
665 {
666 m_xNewModButton->set_sensitive(true);
667 m_xNewDlgButton->set_sensitive(true);
668 }
669
670 // enable/disable delete button
671 if ( nDepth >= 2 && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE )
672 {
673 if( bVBAEnabled && ( nMode & BrowseMode::Modules ) && ( ( nDepth == 2 ) || aLibSubName == IDEResId(RID_STR_DOCUMENT_OBJECTS) ) )
674 m_xDelButton->set_sensitive(false);
675 else
676 m_xDelButton->set_sensitive(true);
677 }
678 else
679 m_xDelButton->set_sensitive(false);
680}
681
682IMPL_LINK_NOARG(ObjectPage, BasicBoxHighlightHdl, weld::TreeView&, void)
683{
684 CheckButtons();
685}
686
687IMPL_LINK(ObjectPage, ButtonHdl, weld::Button&, rButton, void)
688{
689 if (&rButton == m_xEditButton.get())
690 {
691 SfxAllItemSet aArgs( SfxGetpApp()->GetPool() );
692 SfxRequest aRequest( SID_BASICIDE_APPEAR, SfxCallMode::SYNCHRON, aArgs );
693 SfxGetpApp()->ExecuteSlot( aRequest );
694
695 SfxDispatcher* pDispatcher = GetDispatcher();
696
697 std::unique_ptr<weld::TreeIter> xCurEntry(m_xBasicBox->make_iterator());
698 if (!m_xBasicBox->get_cursor(xCurEntry.get()))
699 return;
700 if (m_xBasicBox->get_iter_depth(*xCurEntry) >= 2)
701 {
702 EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(xCurEntry.get());
703 if ( pDispatcher )
704 {
705 OUString aModName( aDesc.GetName() );
706 // extract the module name from the string like "Sheet1 (Example1)"
707 if( aDesc.GetLibSubName() == IDEResId(RID_STR_DOCUMENT_OBJECTS) )
708 {
709 aModName = aModName.getToken( 0, ' ' );
710 }
711 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), aDesc.GetLibName(),
712 aModName, SbTreeListBox::ConvertType( aDesc.GetType() ) );
713 pDispatcher->ExecuteList(SID_BASICIDE_SHOWSBX,
714 SfxCallMode::SYNCHRON, { &aSbxItem });
715 }
716 }
717 else // only Lib selected
718 {
719 DBG_ASSERT( m_xBasicBox->get_iter_depth(*xCurEntry) == 1, "No LibEntry?!" );
721 std::unique_ptr<weld::TreeIter> xParentEntry(m_xBasicBox->make_iterator(xCurEntry.get()));
722 if (m_xBasicBox->iter_parent(*xParentEntry))
723 {
724 DocumentEntry* pDocumentEntry = weld::fromId<DocumentEntry*>(m_xBasicBox->get_id(*xParentEntry));
725 if (pDocumentEntry)
726 aDocument = pDocumentEntry->GetDocument();
727 }
728 SfxUnoAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, Any( aDocument.getDocumentOrNull() ) );
729 OUString aLibName(m_xBasicBox->get_text(*xCurEntry));
730 SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
731 if ( pDispatcher )
732 {
733 pDispatcher->ExecuteList(SID_BASICIDE_LIBSELECTED,
734 SfxCallMode::ASYNCHRON, { &aDocItem, &aLibNameItem });
735 }
736 }
737 EndTabDialog();
738 }
739 else if (&rButton == m_xNewModButton.get())
740 NewModule();
741 else if (&rButton == m_xNewDlgButton.get())
742 NewDialog();
743 else if (&rButton == m_xDelButton.get())
744 DeleteCurrent();
745}
746
747bool ObjectPage::GetSelection( ScriptDocument& rDocument, OUString& rLibName )
748{
749 bool bRet = false;
750
751 std::unique_ptr<weld::TreeIter> xCurEntry(m_xBasicBox->make_iterator());
752 if (!m_xBasicBox->get_cursor(xCurEntry.get()))
753 xCurEntry.reset();
754 EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(xCurEntry.get());
755 rDocument = aDesc.GetDocument();
756 rLibName = aDesc.GetLibName();
757 if ( rLibName.isEmpty() )
758 rLibName = "Standard" ;
759
760 DBG_ASSERT( rDocument.isAlive(), "ObjectPage::GetSelection: no or dead ScriptDocument in the selection!" );
761 if ( !rDocument.isAlive() )
762 return false;
763
764 // check if the module library is loaded
765 bool bOK = true;
766 OUString aLibName( rLibName );
768 if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && !xModLibContainer->isLibraryLoaded( aLibName ) )
769 {
770 // check password
771 Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
772 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
773 {
774 OUString aPassword;
775 bOK = QueryPassword(m_pDialog->getDialog(), xModLibContainer, rLibName, aPassword);
776 }
777
778 // load library
779 if ( bOK )
780 xModLibContainer->loadLibrary( aLibName );
781 }
782
783 // check if the dialog library is loaded
785 if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && !xDlgLibContainer->isLibraryLoaded( aLibName ) )
786 {
787 // load library
788 if ( bOK )
789 xDlgLibContainer->loadLibrary( aLibName );
790 }
791
792 if ( bOK )
793 bRet = true;
794
795 return bRet;
796}
797
799{
801 OUString aLibName;
802
803 if ( GetSelection( aDocument, aLibName ) )
804 {
806 *m_xBasicBox, aLibName, OUString(), true);
807 }
808}
809
811{
813 OUString aLibName;
814
815 if ( !GetSelection( aDocument, aLibName ) )
816 return;
817
818 aDocument.getOrCreateLibrary( E_DIALOGS, aLibName );
819
821 aNewDlg.SetObjectName(aDocument.createObjectName(E_DIALOGS, aLibName));
822
823 if (aNewDlg.run() == RET_CANCEL)
824 return;
825
826 OUString aDlgName = aNewDlg.GetObjectName();
827 if (aDlgName.isEmpty())
828 aDlgName = aDocument.createObjectName( E_DIALOGS, aLibName);
829
830 if ( aDocument.hasDialog( aLibName, aDlgName ) )
831 {
832 std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(m_pDialog->getDialog(),
833 VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_SBXNAMEALLREADYUSED2)));
834 xError->run();
835 }
836 else
837 {
839 if ( !aDocument.createDialog( aLibName, aDlgName, xISP ) )
840 return;
841
842 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aDlgName, TYPE_DIALOG );
843 if (SfxDispatcher* pDispatcher = GetDispatcher())
844 {
845 pDispatcher->ExecuteList( SID_BASICIDE_SBXINSERTED,
846 SfxCallMode::SYNCHRON, { &aSbxItem });
847 }
848 LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
849 std::unique_ptr<weld::TreeIter> xIter(m_xBasicBox->make_iterator());
850 bool bRootEntry = m_xBasicBox->FindRootEntry(aDocument, eLocation, *xIter);
851 if (bRootEntry)
852 {
853 if (!m_xBasicBox->get_row_expanded(*xIter))
854 m_xBasicBox->expand_row(*xIter);
855 bool bLibEntry = m_xBasicBox->FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xIter);
856 DBG_ASSERT( bLibEntry, "LibEntry not found!" );
857 if (bLibEntry)
858 {
859 if (!m_xBasicBox->get_row_expanded(*xIter))
860 m_xBasicBox->expand_row(*xIter);
861 std::unique_ptr<weld::TreeIter> xSubRootEntry(m_xBasicBox->make_iterator(xIter.get()));
862 bool bDlgEntry = m_xBasicBox->FindEntry(aDlgName, OBJ_TYPE_DIALOG, *xIter);
863 if (!bDlgEntry)
864 {
865 m_xBasicBox->AddEntry(aDlgName, RID_BMP_DIALOG, xSubRootEntry.get(), false,
866 std::make_unique<Entry>(OBJ_TYPE_DIALOG), xIter.get());
867 assert(xIter && "Insert entry failed!");
868 }
869 m_xBasicBox->set_cursor(*xIter);
870 m_xBasicBox->select(*xIter);
871 }
872 }
873 }
874}
875
877{
878 std::unique_ptr<weld::TreeIter> xCurEntry(m_xBasicBox->make_iterator());
879 if (!m_xBasicBox->get_cursor(xCurEntry.get()))
880 xCurEntry.reset();
881 DBG_ASSERT( xCurEntry, "No current entry!" );
882 if (!xCurEntry)
883 return;
884 EntryDescriptor aDesc( m_xBasicBox->GetEntryDescriptor( xCurEntry.get() ) );
885 const ScriptDocument& aDocument( aDesc.GetDocument() );
886 DBG_ASSERT( aDocument.isAlive(), "ObjectPage::DeleteCurrent: no document!" );
887 if ( !aDocument.isAlive() )
888 return;
889 const OUString& aLibName( aDesc.GetLibName() );
890 const OUString& aName( aDesc.GetName() );
891 EntryType eType = aDesc.GetType();
892
895 return;
896
897 m_xBasicBox->remove(*xCurEntry);
898 if (m_xBasicBox->get_cursor(xCurEntry.get()))
899 m_xBasicBox->select(*xCurEntry);
900 if (SfxDispatcher* pDispatcher = GetDispatcher())
901 {
902 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aName, SbTreeListBox::ConvertType( eType ) );
903 pDispatcher->ExecuteList( SID_BASICIDE_SBXDELETED,
904 SfxCallMode::SYNCHRON, { &aSbxItem });
905 }
906
907 try
908 {
909 bool bSuccess = false;
910 if ( eType == OBJ_TYPE_MODULE )
911 bSuccess = aDocument.removeModule( aLibName, aName );
912 else if ( eType == OBJ_TYPE_DIALOG )
913 bSuccess = RemoveDialog( aDocument, aLibName, aName );
914
915 if ( bSuccess )
917 }
918 catch (const container::NoSuchElementException& )
919 {
920 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
921 }
922}
923
925{
927}
928
930 : GenericDialogController(pParent, "modules/BasicIDE/ui/importlibdialog.ui", "ImportLibDialog")
931 , m_xStorageFrame(m_xBuilder->weld_frame("storageframe"))
932 , m_xLibBox(m_xBuilder->weld_tree_view("entries"))
933 , m_xReferenceBox(m_xBuilder->weld_check_button("ref"))
934 , m_xReplaceBox(m_xBuilder->weld_check_button("replace"))
935{
936 m_xLibBox->set_size_request(m_xLibBox->get_approximate_digit_width() * 28,
937 m_xLibBox->get_height_rows(8));
938 m_xLibBox->enable_toggle_buttons(weld::ColumnToggleType::Check);
939 // tdf#93476 The libraries should be listed alphabetically
940 m_xLibBox->make_sorted();
941}
942
944{
945}
946
947void LibDialog::SetStorageName( std::u16string_view rName )
948{
949 OUString aName = IDEResId(RID_STR_FILENAME) + rName;
950 m_xStorageFrame->set_label(aName);
951}
952
953// Helper function
955 SbTreeListBox& rBasicBox, const OUString& rLibName, const OUString& _aModName, bool bMain )
956{
957 OSL_ENSURE( rDocument.isAlive(), "createModImpl: invalid document!" );
958 if ( !rDocument.isAlive() )
959 return nullptr;
960
961 SbModule* pModule = nullptr;
962
963 OUString aLibName( rLibName );
964 if ( aLibName.isEmpty() )
965 aLibName = "Standard" ;
966 rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
967 OUString aModName = _aModName;
968 if ( aModName.isEmpty() )
969 aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
970
971 NewObjectDialog aNewDlg(pWin, ObjectMode::Module, true);
972 aNewDlg.SetObjectName(aModName);
973
974 if (aNewDlg.run() != RET_CANCEL)
975 {
976 if (!aNewDlg.GetObjectName().isEmpty())
977 aModName = aNewDlg.GetObjectName();
978
979 try
980 {
981 OUString sModuleCode;
982 // the module has existed
983 if( rDocument.hasModule( aLibName, aModName ) )
984 return nullptr;
985 rDocument.createModule( aLibName, aModName, bMain, sModuleCode );
986 BasicManager* pBasMgr = rDocument.getBasicManager();
987 StarBASIC* pBasic = pBasMgr? pBasMgr->GetLib( aLibName ) : nullptr;
988 if ( pBasic )
989 pModule = pBasic->FindModule( aModName );
990 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, TYPE_MODULE );
991 if (SfxDispatcher* pDispatcher = GetDispatcher())
992 {
993 pDispatcher->ExecuteList( SID_BASICIDE_SBXINSERTED,
994 SfxCallMode::SYNCHRON, { &aSbxItem });
995 }
996 LibraryLocation eLocation = rDocument.getLibraryLocation( aLibName );
997 std::unique_ptr<weld::TreeIter> xIter(rBasicBox.make_iterator());
998 bool bRootEntry = rBasicBox.FindRootEntry(rDocument, eLocation, *xIter);
999 if (bRootEntry)
1000 {
1001 if (!rBasicBox.get_row_expanded(*xIter))
1002 rBasicBox.expand_row(*xIter);
1003 bool bLibEntry = rBasicBox.FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xIter);
1004 DBG_ASSERT( bLibEntry, "LibEntry not found!" );
1005 if (bLibEntry)
1006 {
1007 if (!rBasicBox.get_row_expanded(*xIter))
1008 rBasicBox.expand_row(*xIter);
1009 std::unique_ptr<weld::TreeIter> xSubRootEntry(rBasicBox.make_iterator(xIter.get()));
1010 if (pBasic && rDocument.isInVBAMode())
1011 {
1012 // add the new module in the "Modules" entry
1013 std::unique_ptr<weld::TreeIter> xLibSubEntry(rBasicBox.make_iterator(xIter.get()));
1014 bool bLibSubEntry = rBasicBox.FindEntry(IDEResId(RID_STR_NORMAL_MODULES) , OBJ_TYPE_NORMAL_MODULES, *xLibSubEntry);
1015 if (bLibSubEntry)
1016 {
1017 if (!rBasicBox.get_row_expanded(*xLibSubEntry))
1018 rBasicBox.expand_row(*xLibSubEntry);
1019 rBasicBox.copy_iterator(*xLibSubEntry, *xSubRootEntry);
1020 }
1021 }
1022
1023 std::unique_ptr<weld::TreeIter> xEntry(rBasicBox.make_iterator(xSubRootEntry.get()));
1024 bool bEntry = rBasicBox.FindEntry(aModName, OBJ_TYPE_MODULE, *xEntry);
1025 if (!bEntry)
1026 {
1027 rBasicBox.AddEntry(aModName, RID_BMP_MODULE, xSubRootEntry.get(), false,
1028 std::make_unique<Entry>(OBJ_TYPE_MODULE), xEntry.get());
1029 }
1030 rBasicBox.set_cursor(*xEntry);
1031 rBasicBox.select(*xEntry);
1032 }
1033 }
1034 }
1035 catch (const container::ElementExistException& )
1036 {
1037 std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(pWin,
1038 VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_SBXNAMEALLREADYUSED2)));
1039 xError->run();
1040 }
1041 catch (const container::NoSuchElementException& )
1042 {
1043 DBG_UNHANDLED_EXCEPTION("basctl.basicide");
1044 }
1045 }
1046 return pModule;
1047}
1048
1049
1050} // namespace basctl
1051
1052/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxApplication * SfxGetpApp()
ScriptDocument aDocument
Definition: basobj2.cxx:194
BrowseMode
Definition: bastype2.hxx:36
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
StarBASIC * GetLib(sal_uInt16 nLib) const
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
SbModule * FindModule(std::u16string_view)
ScriptDocument const & GetDocument() const
Definition: bastype2.hxx:99
LibraryLocation GetLocation() const
Definition: bastype2.hxx:150
ScriptDocument const & GetDocument() const
Definition: bastype2.hxx:149
EntryType GetType() const
Definition: bastype2.hxx:158
const OUString & GetLibName() const
Definition: bastype2.hxx:152
const OUString & GetName() const
Definition: bastype2.hxx:154
const OUString & GetLibSubName() const
Definition: bastype2.hxx:153
std::unique_ptr< weld::TreeView > m_xLibBox
Definition: moduldlg.hxx:92
void SetStorageName(std::u16string_view rName)
Definition: moduldlg.cxx:947
std::unique_ptr< weld::Frame > m_xStorageFrame
Definition: moduldlg.hxx:91
virtual ~LibDialog() override
Definition: moduldlg.cxx:943
LibDialog(weld::Window *pParent)
Definition: moduldlg.cxx:929
static css::uno::Reference< css::resource::XStringResourceManager > getStringResourceFromDialogLibrary(const css::uno::Reference< css::container::XNameContainer > &xDialogLib)
static void resetResourceForDialog(const css::uno::Reference< css::container::XNameContainer > &xDialogModel, const css::uno::Reference< css::resource::XStringResourceManager > &xStringResourceManager)
static void setResourceIDsForDialog(const css::uno::Reference< css::container::XNameContainer > &xDialogModel, const css::uno::Reference< css::resource::XStringResourceManager > &xStringResourceManager)
static void copyResourceForDroppedDialog(const css::uno::Reference< css::container::XNameContainer > &xDialogModel, std::u16string_view aDialogName, const css::uno::Reference< css::resource::XStringResourceManager > &xStringResourceManager, const css::uno::Reference< css::resource::XStringResourceResolver > &xSourceStringResolver)
OUString GetObjectName() const
Definition: moduldlg.hxx:52
void SetObjectName(const OUString &rName)
Definition: moduldlg.hxx:53
bool GetSelection(ScriptDocument &rDocument, OUString &rLibName)
Definition: moduldlg.cxx:747
std::unique_ptr< SbTreeListBox > m_xBasicBox
Definition: moduldlg.hxx:129
std::unique_ptr< SbTreeListBoxDropTarget > m_xDropTarget
Definition: moduldlg.hxx:134
std::unique_ptr< weld::Button > m_xNewModButton
Definition: moduldlg.hxx:131
ObjectPage(weld::Container *pParent, const OUString &rName, BrowseMode nMode, OrganizeDialog *pDialog)
Definition: moduldlg.cxx:566
virtual void ActivatePage() override
Definition: moduldlg.cxx:616
std::unique_ptr< weld::Button > m_xNewDlgButton
Definition: moduldlg.hxx:132
std::unique_ptr< weld::Button > m_xDelButton
Definition: moduldlg.hxx:133
virtual ~ObjectPage() override
Definition: moduldlg.cxx:612
std::unique_ptr< weld::Button > m_xEditButton
Definition: moduldlg.hxx:130
std::unique_ptr< ObjectPage > m_xDialogPage
Definition: moduldlg.hxx:206
std::unique_ptr< weld::Notebook > m_xTabCtrl
Definition: moduldlg.hxx:204
std::unique_ptr< ObjectPage > m_xModulePage
Definition: moduldlg.hxx:205
OrganizeDialog(weld::Window *pParent, const css::uno::Reference< css::frame::XFrame > &xDocFrame, sal_Int16 tabId)
Definition: moduldlg.cxx:203
virtual ~OrganizeDialog() override
Definition: moduldlg.cxx:238
void SetCurrentEntry(const css::uno::Reference< css::frame::XFrame > &xDocFrame)
Definition: moduldlg.cxx:186
virtual ~OrganizePage()
Definition: moduldlg.cxx:249
OrganizeDialog * m_pDialog
Definition: moduldlg.hxx:114
OrganizePage(weld::Container *pParent, const OUString &rUIFile, const OUString &rName, OrganizeDialog *pDialog)
Definition: moduldlg.cxx:242
void NotifyCopyingMoving(const weld::TreeIter &rTarget, bool bMove)
Definition: moduldlg.cxx:398
SbTreeListBoxDropTarget(SbTreeListBox &rTreeView)
Definition: moduldlg.cxx:558
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
Definition: moduldlg.cxx:258
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
Definition: moduldlg.cxx:312
EntryDescriptor GetEntryDescriptor(const weld::TreeIter *pEntry)
Definition: bastype3.cxx:240
bool FindRootEntry(const ScriptDocument &rDocument, LibraryLocation eLocation, weld::TreeIter &rIter)
Definition: bastype3.cxx:418
OUString get_text(const weld::TreeIter &rIter) const
Definition: bastype2.hxx:240
OUString get_id(const weld::TreeIter &rIter) const
Definition: bastype2.hxx:242
int get_iter_index_in_parent(const weld::TreeIter &rIter) const
Definition: bastype2.hxx:253
bool get_selected(weld::TreeIter *pIter) const
Definition: bastype2.hxx:234
void set_cursor(const weld::TreeIter &rIter)
Definition: bastype2.hxx:239
bool get_row_expanded(const weld::TreeIter &rIter) const
Definition: bastype2.hxx:248
void remove(const weld::TreeIter &rIter)
Definition: bastype2.hxx:237
std::unique_ptr< weld::TreeIter > make_iterator(const weld::TreeIter *pIter=nullptr) const
Definition: bastype2.hxx:232
void select(const weld::TreeIter &rIter)
Definition: bastype2.hxx:235
weld::TreeView & get_widget()
Definition: bastype2.hxx:270
void AddEntry(const OUString &rText, const OUString &rImage, const weld::TreeIter *pParent, bool bChildrenOnDemand, std::unique_ptr< Entry > &&rUserData, weld::TreeIter *pRet=nullptr)
Definition: bastype2.cxx:642
bool FindEntry(std::u16string_view rText, EntryType eType, weld::TreeIter &rIter)
Definition: bastype2.cxx:603
static ItemType ConvertType(EntryType eType)
Definition: bastype3.cxx:344
int get_iter_depth(const weld::TreeIter &rIter) const
Definition: bastype2.hxx:247
void expand_row(const weld::TreeIter &rIter)
Definition: bastype2.hxx:249
bool iter_parent(weld::TreeIter &rIter) const
Definition: bastype2.hxx:246
void copy_iterator(const weld::TreeIter &rSource, weld::TreeIter &rDest) const
Definition: bastype2.hxx:233
encapsulates a document which contains Basic scripts and dialogs
css::uno::Reference< css::container::XNameContainer > getOrCreateLibrary(LibraryContainerType _eType, const OUString &_rLibName) const
creates a script or dialog library in the document, or returns an existing one
bool getModule(const OUString &_rLibName, const OUString &_rModName, OUString &_rModuleSource) const
retrieves a module's source
bool insertModule(const OUString &_rLibName, const OUString &_rModName, const OUString &_rModuleCode) const
inserts a given piece as code as module
css::uno::Reference< css::script::XLibraryContainer > getLibraryContainer(LibraryContainerType _eType) const
returns the Basic or Dialog library container of the document
bool removeModule(const OUString &_rLibName, const OUString &_rModuleName) const
removes a given script module from the document
css::uno::Reference< css::frame::XModel > getDocumentOrNull() const
returns the UNO component representing the document which the instance operates on
bool getDialog(const OUString &_rLibName, const OUString &_rDialogName, css::uno::Reference< css::io::XInputStreamProvider > &_out_rDialogProvider) const
retrieves a dialog
css::uno::Reference< css::frame::XModel > getDocument() const
returns the UNO component representing the document which the instance operates on
bool isDocument() const
determines whether the ScriptDocument instance operates on a real document, as opposed to the whole a...
BasicManager * getBasicManager() const
returns the BasicManager associated with this instance
static const ScriptDocument & getApplicationScriptDocument()
returns a reference to a shared ScriptDocument instance which operates on the application-wide script...
css::uno::Reference< css::container::XNameContainer > getLibrary(LibraryContainerType _eType, const OUString &_rLibName, bool _bLoadLibrary) const
returns a script or dialog library given by name
bool createModule(const OUString &_rLibName, const OUString &_rModName, bool _bCreateMain, OUString &_out_rNewModuleCode) const
creates a module with the given name in the given library
bool isAlive() const
determines whether the document instance is alive
bool insertDialog(const OUString &_rLibName, const OUString &_rDialogName, const css::uno::Reference< css::io::XInputStreamProvider > &_rDialogProvider) const
inserts a given dialog into a given library
bool hasDialog(const OUString &_rLibName, const OUString &_rDialogName) const
determines whether a dialog with the given name exists in the given library
bool hasModule(const OUString &_rLibName, const OUString &_rModName) const
determines whether a module with the given name exists in the given library
LibraryLocation getLibraryLocation(const OUString &_rLibName) const
returns the location of a library given by name
bool isValid() const
determines whether the document is actually able to contain Basic/Dialog libraries
OUString createObjectName(LibraryContainerType _eType, const OUString &_rLibName) const
retrieves a name for a newly to be created module or dialog
static void CopyDialogResources(css::uno::Reference< css::io::XInputStreamProvider > &io_xISP, const ScriptDocument &rSourceDoc, const OUString &rSourceLibName, const ScriptDocument &rDestDoc, const OUString &rDestLibName, std::u16string_view rDlgName)
Definition: moduldlg.cxx:131
virtual short run()
void response(int nResponse)
virtual Dialog * getDialog() override
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const=0
virtual bool get_selected(TreeIter *pIter) const=0
virtual void insert(const TreeIter *pParent, int pos, const OUString *pStr, const OUString *pId, const OUString *pIconName, VirtualDevice *pImageSurface, bool bChildrenOnDemand, TreeIter *pRet)=0
virtual TreeView * get_drag_source() const=0
virtual bool get_dest_row_at_pos(const Point &rPos, weld::TreeIter *pResult, bool bDnDMode, bool bAutoScroll=true)=0
virtual void set_image(int row, const OUString &rImage, int col=-1)=0
virtual bool iter_parent(TreeIter &rIter) const=0
virtual int iter_compare(const TreeIter &a, const TreeIter &b) const=0
virtual int get_iter_depth(const TreeIter &rIter) const=0
#define DBG_ASSERT(sCon, aError)
#define DBG_UNHANDLED_EXCEPTION(...)
FilterGroup & rTarget
DocumentType eType
bool bReadOnly
OUString aName
bool IsValidSbxName(std::u16string_view rName)
Definition: basobj2.cxx:81
bool QueryPassword(weld::Widget *pDialogParent, const Reference< script::XLibraryContainer > &xLibContainer, const OUString &rLibName, OUString &rPassword, bool bRepeat, bool bNewTitle)
Definition: bastypes.cxx:779
@ LIBRARY_LOCATION_SHARE
@ LIBRARY_LOCATION_DOCUMENT
bool RemoveDialog(const ScriptDocument &rDocument, const OUString &rLibName, const OUString &rDlgName)
Definition: basobj3.cxx:203
SbModule * createModImpl(weld::Window *pWin, const ScriptDocument &rDocument, SbTreeListBox &rBasicBox, const OUString &rLibName, const OUString &_aModName, bool bMain)
Definition: moduldlg.cxx:954
SfxDispatcher * GetDispatcher()
Definition: basobj3.cxx:454
void MarkDocumentModified(const ScriptDocument &rDocument)
Definition: basobj3.cxx:249
IMPL_LINK(AccessibleDialogWindow, WindowEventListener, VclWindowEvent &, rEvent, void)
bool RenameDialog(weld::Widget *pErrorParent, ScriptDocument const &rDocument, OUString const &rLibName, OUString const &rOldName, OUString const &rNewName)
renames a dialog
Definition: basobj3.cxx:138
bool RenameModule(weld::Widget *pErrorParent, const ScriptDocument &rDocument, const OUString &rLibName, const OUString &rOldName, const OUString &rNewName)
renames a module
Definition: basobj2.cxx:130
bool QueryDelDialog(std::u16string_view rName, weld::Widget *pParent)
Definition: bastypes.cxx:764
@ OBJ_TYPE_LIBRARY
Definition: bastype2.hxx:54
@ OBJ_TYPE_NORMAL_MODULES
Definition: bastype2.hxx:60
@ OBJ_TYPE_DIALOG
Definition: bastype2.hxx:56
@ OBJ_TYPE_DOCUMENT
Definition: bastype2.hxx:53
@ OBJ_TYPE_MODULE
Definition: bastype2.hxx:55
IMPL_LINK_NOARG(EditorWindow, SetSourceInBasicHdl, void *, void)
Definition: baside2b.cxx:987
@ TYPE_MODULE
Definition: sbxitem.hxx:32
@ TYPE_DIALOG
Definition: sbxitem.hxx:33
OUString IDEResId(TranslateId aId)
Definition: iderdll.cxx:108
bool QueryDelModule(std::u16string_view rName, weld::Widget *pParent)
Definition: bastypes.cxx:774
@ Exception
Reference< XComponentContext > getProcessComponentContext()
OUString toId(const void *pValue)
Reference< XNameAccess > m_xContainer
sal_Int8 mnAction
Reference< XController > xController
Reference< XModel > xModel
#define DND_ACTION_COPYMOVE
#define DND_ACTION_MOVE
#define DND_ACTION_COPY
#define DND_ACTION_NONE
signed char sal_Int8
OUString sId
RET_OK
RET_CANCEL