LibreOffice Module cui (master) 1
scriptdlg.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 <memory>
21#include <string_view>
22#include <utility>
23
24#include <sfx2/objsh.hxx>
25#include <vcl/svapp.hxx>
26#include <vcl/weld.hxx>
27
28#include <strings.hrc>
29#include <bitmaps.hlst>
30#include <scriptdlg.hxx>
31#include <dialmgr.hxx>
32
33#include <com/sun/star/uno/XComponentContext.hpp>
34#include <com/sun/star/script/provider/ScriptFrameworkErrorException.hpp>
35#include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
36#include <com/sun/star/script/provider/XScriptProvider.hpp>
37#include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
38#include <com/sun/star/script/browse/XBrowseNodeFactory.hpp>
39#include <com/sun/star/script/browse/BrowseNodeFactoryViewTypes.hpp>
40#include <com/sun/star/script/browse/theBrowseNodeFactory.hpp>
41#include <com/sun/star/script/provider/ScriptErrorRaisedException.hpp>
42#include <com/sun/star/script/provider/ScriptExceptionRaisedException.hpp>
43#include <com/sun/star/script/provider/ScriptFrameworkErrorType.hpp>
44#include <com/sun/star/frame/Desktop.hpp>
45#include <com/sun/star/frame/ModuleManager.hpp>
46#include <com/sun/star/script/XInvocation.hpp>
47#include <com/sun/star/document/XEmbeddedScripts.hpp>
48
49#include <comphelper/lok.hxx>
53#include <o3tl/string_view.hxx>
54
55#include <svtools/imagemgr.hxx>
56#include <tools/urlobj.hxx>
58
59using namespace ::com::sun::star;
60using namespace css::uno;
61using namespace css::script;
62using namespace css::frame;
63using namespace css::document;
64
66{
67 SFEntry* pUserData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(rIter));
68 if (pUserData)
69 {
70 delete pUserData;
71 // TBD seem to get a Select event on node that is remove ( below )
72 // so need to be able to detect that this node is not to be
73 // processed in order to do this, setting userData to NULL ( must
74 // be a better way to do this )
75 m_xScriptsBox->set_id(rIter, OUString());
76 }
77}
78
80{
81 delUserData(rIter);
82 std::unique_ptr<weld::TreeIter> xIter = m_xScriptsBox->make_iterator(&rIter);
83 if (!m_xScriptsBox->iter_children(*xIter))
84 return;
85
86 std::unique_ptr<weld::TreeIter> xAltIter = m_xScriptsBox->make_iterator();
87 bool bNextEntry;
88 do
89 {
90 m_xScriptsBox->copy_iterator(*xIter, *xAltIter);
91 bNextEntry = m_xScriptsBox->iter_next_sibling(*xAltIter);
92 deleteTree(*xIter);
93 m_xScriptsBox->remove(*xIter);
94 m_xScriptsBox->copy_iterator(*xAltIter, *xIter);
95 }
96 while (bNextEntry);
97}
98
100{
101 std::unique_ptr<weld::TreeIter> xIter = m_xScriptsBox->make_iterator();
102 if (!m_xScriptsBox->get_iter_first(*xIter))
103 return;
104
105 std::unique_ptr<weld::TreeIter> xAltIter = m_xScriptsBox->make_iterator();
106 // TBD - below is a candidate for a destroyAllTrees method
107 bool bNextEntry;
108 do
109 {
110 m_xScriptsBox->copy_iterator(*xIter, *xAltIter);
111 bNextEntry = m_xScriptsBox->iter_next_sibling(*xAltIter);
112 deleteTree(*xIter);
113 m_xScriptsBox->remove(*xIter);
114 m_xScriptsBox->copy_iterator(*xAltIter, *xIter);
115 }
116 while (bNextEntry);
117}
118
119void SvxScriptOrgDialog::Init( std::u16string_view language )
120{
121 m_xScriptsBox->freeze();
122
124
125 Reference< browse::XBrowseNode > rootNode;
126 Reference< XComponentContext > xCtx(
128
129 Sequence< Reference< browse::XBrowseNode > > children;
130
131 try
132 {
133 Reference< browse::XBrowseNodeFactory > xFac = browse::theBrowseNodeFactory::get(xCtx);
134
135 rootNode.set( xFac->createView(
136 browse::BrowseNodeFactoryViewTypes::MACROORGANIZER ) );
137
138 if ( rootNode.is() && rootNode->hasChildNodes() )
139 {
140 children = rootNode->getChildNodes();
141 }
142 }
143 catch( const Exception& )
144 {
145 TOOLS_WARN_EXCEPTION("cui.dialogs", "Exception getting root browse node from factory");
146 // TODO exception handling
147 }
148
149 Reference<XModel> xDocumentModel;
150 for ( const Reference< browse::XBrowseNode >& childNode : std::as_const(children) )
151 {
152 bool app = false;
153 OUString uiName = childNode->getName();
154 OUString factoryURL;
155 if (uiName == "user")
156 {
157 app = true;
158 uiName = m_sMyMacros;
159 }
160 else if (uiName == "share")
161 {
162 app = true;
163 uiName = m_sProdMacros;
164 }
165 else
166 {
167 xDocumentModel.set(getDocumentModel(xCtx, uiName ), UNO_QUERY);
168
169 if ( xDocumentModel.is() )
170 {
171 Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xCtx) );
172
173 // get the long name of the document:
174 Sequence<beans::PropertyValue> moduleDescr;
175 try{
176 OUString appModule = xModuleManager->identify( xDocumentModel );
177 xModuleManager->getByName(appModule) >>= moduleDescr;
178 } catch(const uno::Exception&)
179 {}
180
181 for ( const beans::PropertyValue& prop : std::as_const(moduleDescr))
182 {
183 if ( prop.Name == "ooSetupFactoryEmptyDocumentURL" )
184 {
185 prop.Value >>= factoryURL;
186 break;
187 }
188 }
189 }
190 }
191
192 Reference< browse::XBrowseNode > langEntries =
193 getLangNodeFromRootNode( childNode, language );
194
195 insertEntry( uiName, app ? OUString(RID_CUIBMP_HARDDISK) : OUString(RID_CUIBMP_DOC),
196 nullptr, true, std::make_unique< SFEntry >( langEntries, xDocumentModel ), factoryURL, false );
197 }
198
199 m_xScriptsBox->thaw();
200}
201
202Reference< XInterface >
203SvxScriptOrgDialog::getDocumentModel( Reference< XComponentContext > const & xCtx, std::u16string_view docName )
204{
205 Reference< XInterface > xModel;
206 Reference< frame::XDesktop2 > desktop = frame::Desktop::create(xCtx);
207
208 Reference< container::XEnumerationAccess > componentsAccess =
209 desktop->getComponents();
210 Reference< container::XEnumeration > components =
211 componentsAccess->createEnumeration();
212 while (components->hasMoreElements())
213 {
215 components->nextElement(), UNO_QUERY );
216 if ( model.is() )
217 {
218 OUString sTdocUrl = ::comphelper::DocumentInfo::getDocumentTitle( model );
219 if( sTdocUrl == docName )
220 {
221 xModel = model;
222 break;
223 }
224 }
225 }
226 return xModel;
227}
228
229Reference< browse::XBrowseNode >
230SvxScriptOrgDialog::getLangNodeFromRootNode( Reference< browse::XBrowseNode > const & rootNode, std::u16string_view language )
231{
232 Reference< browse::XBrowseNode > langNode;
233
234 try
235 {
236 auto tryFind = [&] {
237 const Sequence<Reference<browse::XBrowseNode>> children = rootNode->getChildNodes();
238 const auto it = std::find_if(children.begin(), children.end(),
239 [&](const Reference<browse::XBrowseNode>& child) {
240 return child->getName() == language;
241 });
242 return (it != children.end()) ? *it : nullptr;
243 };
244 {
245 // First try without Java interaction, to avoid warnings for non-JRE-dependent providers
246 css::uno::ContextLayer layer(comphelper::NoEnableJavaInteractionContext());
247 langNode = tryFind();
248 }
249 if (!langNode)
250 {
251 // Now try with Java interaction enabled
252 langNode = tryFind();
253 }
254 }
255 catch ( Exception& )
256 {
257 // if getChildNodes() throws an exception we just return
258 // the empty Reference
259 }
260 return langNode;
261}
262
263void SvxScriptOrgDialog::RequestSubEntries(const weld::TreeIter& rRootEntry, Reference< css::script::browse::XBrowseNode > const & node,
264 Reference< XModel >& model)
265{
266 if (!node.is())
267 {
268 return;
269 }
270
271 Sequence< Reference< browse::XBrowseNode > > children;
272 try
273 {
274 children = node->getChildNodes();
275 }
276 catch ( Exception& )
277 {
278 // if we catch an exception in getChildNodes then no entries are added
279 }
280
281 for ( const Reference< browse::XBrowseNode >& childNode : std::as_const(children) )
282 {
283 OUString name( childNode->getName() );
284 if ( childNode->getType() != browse::BrowseNodeTypes::SCRIPT)
285 {
286 insertEntry(name, RID_CUIBMP_LIB, &rRootEntry, true, std::make_unique<SFEntry>(childNode, model), false);
287 }
288 else
289 {
290 insertEntry(name, RID_CUIBMP_MACRO, &rRootEntry, false, std::make_unique<SFEntry>(childNode, model), false);
291 }
292 }
293}
294
295void SvxScriptOrgDialog::insertEntry(const OUString& rText, const OUString& rBitmap,
296 const weld::TreeIter* pParent, bool bChildrenOnDemand, std::unique_ptr<SFEntry> && aUserData,
297 std::u16string_view factoryURL, bool bSelect)
298{
299 if (rBitmap == RID_CUIBMP_DOC && !factoryURL.empty())
300 {
301 OUString aImage = SvFileInformationManager::GetFileImageId(INetURLObject(factoryURL));
302 insertEntry(rText, aImage, pParent, bChildrenOnDemand, std::move(aUserData), bSelect);
303 return;
304 }
305 insertEntry(rText, rBitmap, pParent, bChildrenOnDemand, std::move(aUserData), bSelect);
306}
307
309 const OUString& rText, const OUString& rBitmap, const weld::TreeIter* pParent,
310 bool bChildrenOnDemand, std::unique_ptr<SFEntry> && aUserData, bool bSelect)
311{
312 OUString sId(weld::toId(aUserData.release())); // XXX possible leak
313 m_xScriptsBox->insert(pParent, -1, &rText, &sId, nullptr, nullptr,
314 bChildrenOnDemand, m_xScratchIter.get());
315 m_xScriptsBox->set_image(*m_xScratchIter, rBitmap);
316 if (bSelect)
317 {
318 m_xScriptsBox->set_cursor(*m_xScratchIter);
320 }
321}
322
323IMPL_LINK(SvxScriptOrgDialog, ExpandingHdl, const weld::TreeIter&, rIter, bool)
324{
325 SFEntry* userData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(rIter));
326
327 Reference< browse::XBrowseNode > node;
328 Reference< XModel > model;
329 if ( userData && !userData->isLoaded() )
330 {
331 node = userData->GetNode();
332 model = userData->GetModel();
333 RequestSubEntries(rIter, node, model);
334 userData->setLoaded();
335 }
336
337 return true;
338}
339
340// CuiInputDialog ------------------------------------------------------------
342 : GenericDialogController(pParent, "cui/ui/newlibdialog.ui", "NewLibDialog")
343 , m_xEdit(m_xBuilder->weld_entry("entry"))
344{
345 m_xEdit->grab_focus();
346
347 std::unique_ptr<weld::Label> xNewLibFT(m_xBuilder->weld_label("newlibft"));
348
349 if ( nMode == InputDialogMode::NEWMACRO )
350 {
351 xNewLibFT->hide();
352 std::unique_ptr<weld::Label> xNewMacroFT(m_xBuilder->weld_label("newmacroft"));
353 xNewMacroFT->show();
354 std::unique_ptr<weld::Label> xAltTitle(m_xBuilder->weld_label("altmacrotitle"));
355 m_xDialog->set_title(xAltTitle->get_label());
356 }
357 else if ( nMode == InputDialogMode::RENAME )
358 {
359 xNewLibFT->hide();
360 std::unique_ptr<weld::Label> xRenameFT(m_xBuilder->weld_label("renameft"));
361 xRenameFT->show();
362 std::unique_ptr<weld::Label> xAltTitle(m_xBuilder->weld_label("altrenametitle"));
363 m_xDialog->set_title(xAltTitle->get_label());
364 }
365}
366
367// ScriptOrgDialog ------------------------------------------------------------
368
370 : SfxDialogController(pParent, "cui/ui/scriptorganizer.ui", "ScriptOrganizerDialog")
371 , m_pParent(pParent)
372 , m_sLanguage(std::move(language))
373 , m_delErrStr(CuiResId(RID_CUISTR_DELFAILED))
374 , m_delErrTitleStr(CuiResId(RID_CUISTR_DELFAILED_TITLE))
375 , m_delQueryStr(CuiResId(RID_CUISTR_DELQUERY))
376 , m_delQueryTitleStr(CuiResId(RID_CUISTR_DELQUERY_TITLE))
377 , m_createErrStr(CuiResId(RID_CUISTR_CREATEFAILED))
378 , m_createDupStr(CuiResId(RID_CUISTR_CREATEFAILEDDUP))
379 , m_createErrTitleStr(CuiResId(RID_CUISTR_CREATEFAILED_TITLE))
380 , m_renameErrStr(CuiResId(RID_CUISTR_RENAMEFAILED))
381 , m_renameErrTitleStr(CuiResId(RID_CUISTR_RENAMEFAILED_TITLE))
382 , m_sMyMacros(CuiResId(RID_CUISTR_MYMACROS))
383 , m_sProdMacros(CuiResId(RID_CUISTR_PRODMACROS))
384 , m_xScriptsBox(m_xBuilder->weld_tree_view("scripts"))
385 , m_xScratchIter(m_xScriptsBox->make_iterator())
386 , m_xRunButton(m_xBuilder->weld_button("ok"))
387 , m_xCloseButton(m_xBuilder->weld_button("close"))
388 , m_xCreateButton(m_xBuilder->weld_button("create"))
389 , m_xEditButton(m_xBuilder->weld_button("edit"))
390 , m_xRenameButton(m_xBuilder->weld_button("rename"))
391 , m_xDelButton(m_xBuilder->weld_button("delete"))
392{
393 // must be a neater way to deal with the strings than as above
394 // append the language to the dialog title
395 OUString winTitle(m_xDialog->get_title());
396 winTitle = winTitle.replaceFirst( "%MACROLANG", m_sLanguage );
397 m_xDialog->set_title(winTitle);
398
399 m_xScriptsBox->set_size_request(m_xScriptsBox->get_approximate_digit_width() * 45,
400 m_xScriptsBox->get_height_rows(12));
401
402 m_xScriptsBox->connect_changed( LINK( this, SvxScriptOrgDialog, ScriptSelectHdl ) );
403 m_xScriptsBox->connect_expanding(LINK( this, SvxScriptOrgDialog, ExpandingHdl ) );
404 m_xRunButton->connect_clicked( LINK( this, SvxScriptOrgDialog, ButtonHdl ) );
405 m_xCloseButton->connect_clicked( LINK( this, SvxScriptOrgDialog, ButtonHdl ) );
406 m_xRenameButton->connect_clicked( LINK( this, SvxScriptOrgDialog, ButtonHdl ) );
407 m_xEditButton->connect_clicked( LINK( this, SvxScriptOrgDialog, ButtonHdl ) );
408 m_xDelButton->connect_clicked( LINK( this, SvxScriptOrgDialog, ButtonHdl ) );
409 m_xCreateButton->connect_clicked( LINK( this, SvxScriptOrgDialog, ButtonHdl ) );
410
411 m_xRunButton->set_sensitive(false);
412 m_xRenameButton->set_sensitive(false);
413 m_xEditButton->set_sensitive(false);
414 m_xDelButton->set_sensitive(false);
415 m_xCreateButton->set_sensitive(false);
416
419}
420
422{
424}
425
427{
429
430 // force load of MSPs for all documents
431 while ( pDoc )
432 {
433 Reference< provider::XScriptProviderSupplier > xSPS( pDoc->GetModel(), UNO_QUERY );
434 if ( xSPS.is() )
435 {
436 xSPS->getScriptProvider();
437 }
438
439 pDoc = SfxObjectShell::GetNext(*pDoc);
440 }
441
442 return SfxDialogController::run();
443}
444
445void SvxScriptOrgDialog::CheckButtons( Reference< browse::XBrowseNode > const & node )
446{
447 if ( node.is() )
448 {
449 if ( node->getType() == browse::BrowseNodeTypes::SCRIPT)
450 {
451 m_xRunButton->set_sensitive(true);
452 }
453 else
454 {
455 m_xRunButton->set_sensitive(false);
456 }
457 Reference< beans::XPropertySet > xProps( node, UNO_QUERY );
458
459 if ( !xProps.is() )
460 {
461 m_xEditButton->set_sensitive(false);
462 m_xDelButton->set_sensitive(false);
463 m_xCreateButton->set_sensitive(false);
464 m_xRunButton->set_sensitive(false);
465 return;
466 }
467
468 OUString sName("Editable");
469
470 if ( getBoolProperty( xProps, sName ) )
471 {
472 m_xEditButton->set_sensitive(true);
473 }
474 else
475 {
476 m_xEditButton->set_sensitive(false);
477 }
478
479 sName = "Deletable";
480
481 if ( getBoolProperty( xProps, sName ) )
482 {
483 m_xDelButton->set_sensitive(true);
484 }
485 else
486 {
487 m_xDelButton->set_sensitive(false);
488 }
489
490 sName = "Creatable";
491
492 if ( getBoolProperty( xProps, sName ) )
493 {
494 m_xCreateButton->set_sensitive(true);
495 }
496 else
497 {
498 m_xCreateButton->set_sensitive(false);
499 }
500
501 sName = "Renamable";
502
503 if ( getBoolProperty( xProps, sName ) )
504 {
505 m_xRenameButton->set_sensitive(true);
506 }
507 else
508 {
509 m_xRenameButton->set_sensitive(false);
510 }
511 }
512 else
513 {
514 // no node info available, disable all configurable actions
515 m_xDelButton->set_sensitive(false);
516 m_xCreateButton->set_sensitive(false);
517 m_xEditButton->set_sensitive(false);
518 m_xRunButton->set_sensitive(false);
519 m_xRenameButton->set_sensitive(false);
520 }
521}
522
524{
525 std::unique_ptr<weld::TreeIter> xIter = m_xScriptsBox->make_iterator();
526 if (!m_xScriptsBox->get_selected(xIter.get()))
527 return;
528
529 SFEntry* userData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(*xIter));
530
531 Reference< browse::XBrowseNode > node;
532 if (userData)
533 {
534 node = userData->GetNode();
535 CheckButtons(node);
536 }
537}
538
539IMPL_LINK(SvxScriptOrgDialog, ButtonHdl, weld::Button&, rButton, void)
540{
541 if ( &rButton == m_xCloseButton.get() )
542 {
543 StoreCurrentSelection();
544 m_xDialog->response(RET_CANCEL);
545 }
546 if (!(&rButton == m_xEditButton.get() ||
547 &rButton == m_xCreateButton.get() ||
548 &rButton == m_xDelButton.get() ||
549 &rButton == m_xRunButton.get() ||
550 &rButton == m_xRenameButton.get()))
551
552 return;
553
554 std::unique_ptr<weld::TreeIter> xIter = m_xScriptsBox->make_iterator();
555 if (!m_xScriptsBox->get_selected(xIter.get()))
556 return;
557 SFEntry* userData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(*xIter));
558 if (!userData)
559 return;
560
561 Reference< browse::XBrowseNode > node;
562 Reference< XModel > xModel;
563
564 node = userData->GetNode();
565 xModel = userData->GetModel();
566
567 if ( !node.is() )
568 {
569 return;
570 }
571
572 if (&rButton == m_xRunButton.get())
573 {
574 OUString tmpString;
575 Reference< beans::XPropertySet > xProp( node, UNO_QUERY );
576 Reference< provider::XScriptProvider > mspNode;
577 if( !xProp.is() )
578 {
579 return;
580 }
581
582 if ( xModel.is() )
583 {
584 Reference< XEmbeddedScripts > xEmbeddedScripts( xModel, UNO_QUERY);
585 if( !xEmbeddedScripts.is() )
586 {
587 return;
588 }
589
590 if (!xEmbeddedScripts->getAllowMacroExecution())
591 {
592 // Please FIXME: Show a message box if AllowMacroExecution is false
593 return;
594 }
595 }
596
597 std::unique_ptr<weld::TreeIter> xParentIter = m_xScriptsBox->make_iterator(xIter.get());
598 bool bParent = m_xScriptsBox->iter_parent(*xParentIter);
599 while (bParent && !mspNode.is() )
600 {
601 SFEntry* mspUserData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(*xParentIter));
602 mspNode.set( mspUserData->GetNode() , UNO_QUERY );
603 bParent = m_xScriptsBox->iter_parent(*xParentIter);
604 }
605 xProp->getPropertyValue("URI") >>= tmpString;
606 const OUString scriptURL( tmpString );
607
608 if ( mspNode.is() )
609 {
610 try
611 {
612 Reference< provider::XScript > xScript(
613 mspNode->getScript( scriptURL ), UNO_SET_THROW );
614
615 const Sequence< Any > args(0);
616 Sequence< sal_Int16 > outIndex;
617 Sequence< Any > outArgs( 0 );
618 xScript->invoke( args, outIndex, outArgs );
619 }
620 catch ( reflection::InvocationTargetException& ite )
621 {
622 SvxScriptErrorDialog::ShowAsyncErrorDialog(m_pParent, css::uno::Any(ite));
623 }
624 catch ( provider::ScriptFrameworkErrorException& ite )
625 {
626 SvxScriptErrorDialog::ShowAsyncErrorDialog(m_pParent, css::uno::Any(ite));
627 }
628 catch ( RuntimeException& re )
629 {
630 SvxScriptErrorDialog::ShowAsyncErrorDialog(m_pParent, css::uno::Any(re));
631 }
632 catch ( Exception& e )
633 {
634 SvxScriptErrorDialog::ShowAsyncErrorDialog(m_pParent, css::uno::Any(e));
635 }
636 }
637 StoreCurrentSelection();
638 m_xDialog->response(RET_CANCEL);
639 }
640 else if ( &rButton == m_xEditButton.get() )
641 {
642 Reference< script::XInvocation > xInv( node, UNO_QUERY );
643 if ( xInv.is() )
644 {
645 StoreCurrentSelection();
646 m_xDialog->response(RET_CANCEL);
647 Sequence< Any > args(0);
648 Sequence< Any > outArgs( 0 );
649 Sequence< sal_Int16 > outIndex;
650 try
651 {
652 // ISSUE need code to run script here
653 xInv->invoke( "Editable", args, outIndex, outArgs );
654 }
655 catch( Exception const & )
656 {
657 TOOLS_WARN_EXCEPTION("cui.dialogs", "Caught exception trying to invoke" );
658 }
659 }
660 }
661 else if ( &rButton == m_xCreateButton.get() )
662 {
663 createEntry(*xIter);
664 }
665 else if ( &rButton == m_xDelButton.get() )
666 {
667 deleteEntry(*xIter);
668 }
669 else if ( &rButton == m_xRenameButton.get() )
670 {
671 renameEntry(*xIter);
672 }
673}
674
675Reference< browse::XBrowseNode > SvxScriptOrgDialog::getBrowseNode(const weld::TreeIter& rEntry)
676{
677 Reference< browse::XBrowseNode > node;
678 SFEntry* userData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(rEntry));
679 if (userData)
680 {
681 node = userData->GetNode();
682 }
683 return node;
684}
685
686Reference< XModel > SvxScriptOrgDialog::getModel(const weld::TreeIter& rEntry)
687{
688 Reference< XModel > model;
689 SFEntry* userData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(rEntry));
690 if ( userData )
691 {
692 model = userData->GetModel();
693 }
694 return model;
695}
696
698{
699
700 Reference< browse::XBrowseNode > aChildNode;
701 Reference< browse::XBrowseNode > node = getBrowseNode( rEntry );
702 Reference< script::XInvocation > xInv( node, UNO_QUERY );
703
704 if ( xInv.is() )
705 {
706 OUString aNewName;
707 OUString aNewStdName;
709 if (m_xScriptsBox->get_iter_depth(rEntry) == 0)
710 {
711 aNewStdName = "Library" ;
712 }
713 else
714 {
715 aNewStdName = "Macro" ;
717 }
718 //do we need L10N for this? ie something like:
719 //String aNewStdName( ResId( STR_STDMODULENAME ) );
720 bool bValid = false;
721 sal_Int32 i = 1;
722
723 Sequence< Reference< browse::XBrowseNode > > childNodes;
724 // no children => ok to create Parcel1 or Script1 without checking
725 try
726 {
727 if( !node->hasChildNodes() )
728 {
729 aNewName = aNewStdName + OUString::number(i);
730 bValid = true;
731 }
732 else
733 {
734 childNodes = node->getChildNodes();
735 }
736 }
737 catch ( Exception& )
738 {
739 // ignore, will continue on with empty sequence
740 }
741
742 OUString extn;
743 while ( !bValid )
744 {
745 aNewName = aNewStdName + OUString::number(i);
746 bool bFound = false;
747 if(childNodes.hasElements() )
748 {
749 OUString nodeName = childNodes[0]->getName();
750 sal_Int32 extnPos = nodeName.lastIndexOf( '.' );
751 if(extnPos>0)
752 extn = nodeName.copy(extnPos);
753 }
754 for( const Reference< browse::XBrowseNode >& n : std::as_const(childNodes) )
755 {
756 if (Concat2View(aNewName+extn) == n->getName())
757 {
758 bFound = true;
759 break;
760 }
761 }
762 if( bFound )
763 {
764 i++;
765 }
766 else
767 {
768 bValid = true;
769 }
770 }
771
772 CuiInputDialog aNewDlg(m_xDialog.get(), nMode);
773 aNewDlg.SetObjectName(aNewName);
774
775 do
776 {
777 if (aNewDlg.run() && !aNewDlg.GetObjectName().isEmpty())
778 {
779 OUString aUserSuppliedName = aNewDlg.GetObjectName();
780 bValid = true;
781 for( const Reference< browse::XBrowseNode >& n : std::as_const(childNodes) )
782 {
783 if (Concat2View(aUserSuppliedName+extn) == n->getName())
784 {
785 bValid = false;
786 OUString aError = m_createErrStr + m_createDupStr;
787
788 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(),
789 VclMessageType::Warning, VclButtonsType::Ok, aError));
790 xErrorBox->set_title(m_createErrTitleStr);
791 xErrorBox->run();
792 aNewDlg.SetObjectName(aNewName);
793 break;
794 }
795 }
796 if( bValid )
797 aNewName = aUserSuppliedName;
798 }
799 else
800 {
801 // user hit cancel or hit OK with nothing in the editbox
802
803 return;
804 }
805 }
806 while ( !bValid );
807
808 // open up parent node (which ensures it's loaded)
809 m_xScriptsBox->expand_row(rEntry);
810
811 Sequence< Any > args{ Any(aNewName) };
812 Sequence< Any > outArgs;
813 Sequence< sal_Int16 > outIndex;
814 try
815 {
816 Any aResult = xInv->invoke( "Creatable", args, outIndex, outArgs );
817 Reference< browse::XBrowseNode > newNode( aResult, UNO_QUERY );
818 aChildNode = newNode;
819
820 }
821 catch( Exception const & )
822 {
823 TOOLS_WARN_EXCEPTION("cui.dialogs", "Caught exception trying to Create" );
824 }
825 }
826 if ( aChildNode.is() )
827 {
828 OUString aChildName = aChildNode->getName();
829
830 Reference<XModel> xDocumentModel = getModel( rEntry );
831
832 // ISSUE do we need to remove all entries for parent
833 // to achieve sort? Just need to determine position
834 // -- Basic doesn't do this on create.
835 // Suppose we could avoid this too. -> created nodes are
836 // not in alphabetical order
837 if ( aChildNode->getType() == browse::BrowseNodeTypes::SCRIPT )
838 {
839 insertEntry(aChildName, RID_CUIBMP_MACRO, &rEntry, false,
840 std::make_unique<SFEntry>(aChildNode,xDocumentModel), true);
841 }
842 else
843 {
844 insertEntry(aChildName, RID_CUIBMP_LIB, &rEntry, false,
845 std::make_unique<SFEntry>(aChildNode,xDocumentModel), true);
846
847 // If the Parent is not loaded then set to
848 // loaded, this will prevent RequestingChildren ( called
849 // from vcl via RequestingChildren ) from
850 // creating new ( duplicate ) children
851 SFEntry* userData = weld::fromId<SFEntry*>(m_xScriptsBox->get_id(rEntry));
852 if ( userData && !userData->isLoaded() )
853 {
854 userData->setLoaded();
855 }
856 }
857 }
858 else
859 {
860 //ISSUE L10N & message from exception?
861 OUString aError( m_createErrStr );
862 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(),
863 VclMessageType::Warning, VclButtonsType::Ok, aError));
864 xErrorBox->set_title(m_createErrTitleStr);
865 xErrorBox->run();
866 }
867}
868
870{
871
872 Reference< browse::XBrowseNode > aChildNode;
873 Reference< browse::XBrowseNode > node = getBrowseNode(rEntry);
874 Reference< script::XInvocation > xInv( node, UNO_QUERY );
875
876 if ( xInv.is() )
877 {
878 OUString aNewName = node->getName();
879 sal_Int32 extnPos = aNewName.lastIndexOf( '.' );
880 if(extnPos>0)
881 {
882 aNewName = aNewName.copy(0,extnPos);
883 }
885 aNewDlg.SetObjectName(aNewName);
886
887 if (!aNewDlg.run() || aNewDlg.GetObjectName().isEmpty())
888 return; // user hit cancel or hit OK with nothing in the editbox
889
890 aNewName = aNewDlg.GetObjectName();
891
892 Sequence< Any > args{ Any(aNewName) };
893 Sequence< Any > outArgs;
894 Sequence< sal_Int16 > outIndex;
895 try
896 {
897 Any aResult = xInv->invoke( "Renamable", args, outIndex, outArgs );
898 Reference< browse::XBrowseNode > newNode( aResult, UNO_QUERY );
899 aChildNode = newNode;
900
901 }
902 catch( Exception const & )
903 {
904 TOOLS_WARN_EXCEPTION("cui.dialogs", "Caught exception trying to Rename" );
905 }
906 }
907 if ( aChildNode.is() )
908 {
909 m_xScriptsBox->set_text(rEntry, aChildNode->getName());
910 m_xScriptsBox->set_cursor(rEntry);
911 m_xScriptsBox->select(rEntry);
912
913 }
914 else
915 {
916 //ISSUE L10N & message from exception?
917 OUString aError( m_renameErrStr );
918 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(),
919 VclMessageType::Warning, VclButtonsType::Ok, aError));
920 xErrorBox->set_title(m_renameErrTitleStr);
921 xErrorBox->run();
922 }
923}
924
926{
927 bool result = false;
928 Reference< browse::XBrowseNode > node = getBrowseNode(rEntry);
929 // ISSUE L10N string & can we center list?
930 OUString aQuery = m_delQueryStr + getListOfChildren( node, 0 );
931 std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
932 VclMessageType::Question, VclButtonsType::YesNo, aQuery));
933 xQueryBox->set_title(m_delQueryTitleStr);
934 if (xQueryBox->run() == RET_NO)
935 {
936 return;
937 }
938
939 Reference< script::XInvocation > xInv( node, UNO_QUERY );
940 if ( xInv.is() )
941 {
942 Sequence< Any > args( 0 );
943 Sequence< Any > outArgs( 0 );
944 Sequence< sal_Int16 > outIndex;
945 try
946 {
947 Any aResult = xInv->invoke( "Deletable", args, outIndex, outArgs );
948 aResult >>= result; // or do we just assume true if no exception ?
949 }
950 catch( Exception const & )
951 {
952 TOOLS_WARN_EXCEPTION("cui.dialogs", "Caught exception trying to delete" );
953 }
954 }
955
956 if ( result )
957 {
958 deleteTree(rEntry);
959 m_xScriptsBox->remove(rEntry);
960 }
961 else
962 {
963 //ISSUE L10N & message from exception?
964 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(),
965 VclMessageType::Warning, VclButtonsType::Ok, m_delErrStr));
966 xErrorBox->set_title(m_delErrTitleStr);
967 xErrorBox->run();
968 }
969
970}
971
973 OUString const & propName )
974{
975 bool result = false;
976 try
977 {
978 xProps->getPropertyValue( propName ) >>= result;
979 }
980 catch ( Exception& )
981 {
982 return result;
983 }
984 return result;
985}
986
987OUString SvxScriptOrgDialog::getListOfChildren( const Reference< browse::XBrowseNode >& node, int depth )
988{
989 OUStringBuffer result = "\n";
990 for( int i=0;i<=depth;i++ )
991 {
992 result.append("\t");
993 }
994 result.append(node->getName());
995
996 try
997 {
998 if ( node->hasChildNodes() )
999 {
1000 const Sequence< Reference< browse::XBrowseNode > > children
1001 = node->getChildNodes();
1002 for( const Reference< browse::XBrowseNode >& n : children )
1003 {
1004 result.append( getListOfChildren( n , depth+1 ) );
1005 }
1006 }
1007 }
1008 catch ( Exception& )
1009 {
1010 // ignore, will return an empty string
1011 }
1012
1013 return result.makeStringAndClear();
1014}
1015
1017
1019{
1020 std::unique_ptr<weld::TreeIter> xIter = m_xScriptsBox->make_iterator();
1021 if (!m_xScriptsBox->get_selected(xIter.get()))
1022 return;
1023 OUString aDescription;
1024 bool bEntry;
1025 do
1026 {
1027 aDescription = m_xScriptsBox->get_text(*xIter) + aDescription;
1028 bEntry = m_xScriptsBox->iter_parent(*xIter);
1029 if (bEntry)
1030 aDescription = ";" + aDescription;
1031 }
1032 while (bEntry);
1033 OUString sDesc( aDescription );
1034 m_lastSelection[ m_sLanguage ] = sDesc;
1035}
1036
1038{
1039 OUString aStoredEntry = m_lastSelection[ m_sLanguage ];
1040 if( aStoredEntry.isEmpty() )
1041 return;
1042 std::unique_ptr<weld::TreeIter> xEntry;
1043 std::unique_ptr<weld::TreeIter> xTmpEntry(m_xScriptsBox->make_iterator());
1044 sal_Int32 nIndex = 0;
1045 while (nIndex != -1)
1046 {
1047 std::u16string_view aTmp( o3tl::getToken(aStoredEntry, 0, ';', nIndex ) );
1048
1049 bool bTmpEntry;
1050 if (!xEntry)
1051 {
1052 xEntry = m_xScriptsBox->make_iterator();
1053 bTmpEntry = m_xScriptsBox->get_iter_first(*xEntry);
1054 m_xScriptsBox->copy_iterator(*xEntry, *xTmpEntry);
1055 }
1056 else
1057 {
1058 m_xScriptsBox->copy_iterator(*xEntry, *xTmpEntry);
1059 bTmpEntry = m_xScriptsBox->iter_children(*xTmpEntry);
1060 }
1061
1062 while (bTmpEntry)
1063 {
1064 if (m_xScriptsBox->get_text(*xTmpEntry) == aTmp)
1065 {
1066 m_xScriptsBox->copy_iterator(*xTmpEntry, *xEntry);
1067 break;
1068 }
1069 bTmpEntry = m_xScriptsBox->iter_next_sibling(*xTmpEntry);
1070 }
1071
1072 if (!bTmpEntry)
1073 break;
1074
1075 m_xScriptsBox->expand_row(*xEntry);
1076 }
1077
1078 if (xEntry)
1079 {
1080 m_xScriptsBox->set_cursor(*xEntry);
1081 ScriptSelectHdl(*m_xScriptsBox);
1082 }
1083}
1084
1085namespace {
1086
1087OUString ReplaceString(
1088 const OUString& source,
1089 std::u16string_view token,
1090 std::u16string_view value )
1091{
1092 sal_Int32 pos = source.indexOf( token );
1093
1094 if ( pos != -1 && !value.empty() )
1095 {
1096 return source.replaceAt( pos, token.size(), value );
1097 }
1098 else
1099 {
1100 return source;
1101 }
1102}
1103
1104OUString FormatErrorString(
1105 const OUString& unformatted,
1106 std::u16string_view language,
1107 std::u16string_view script,
1108 std::u16string_view line,
1109 std::u16string_view type,
1110 std::u16string_view message )
1111{
1112 OUString result = unformatted;
1113
1114 result = ReplaceString(result, u"%LANGUAGENAME", language );
1115 result = ReplaceString(result, u"%SCRIPTNAME", script );
1116 result = ReplaceString(result, u"%LINENUMBER", line );
1117
1118 if ( !type.empty() )
1119 {
1120 result += "\n\n" + CuiResId(RID_CUISTR_ERROR_TYPE_LABEL) + " " + type;
1121 }
1122
1123 if ( !message.empty() )
1124 {
1125 result += "\n\n" + CuiResId(RID_CUISTR_ERROR_MESSAGE_LABEL) + " " + message;
1126 }
1127
1128 return result;
1129}
1130
1131OUString GetErrorMessage(
1132 const provider::ScriptErrorRaisedException& eScriptError )
1133{
1134 OUString unformatted = CuiResId( RID_CUISTR_ERROR_AT_LINE );
1135
1136 OUString unknown("UNKNOWN");
1137 OUString language = unknown;
1138 OUString script = unknown;
1139 OUString line = unknown;
1140 OUString message = eScriptError.Message;
1141
1142 if ( !eScriptError.language.isEmpty() )
1143 {
1144 language = eScriptError.language;
1145 }
1146
1147 if ( !eScriptError.scriptName.isEmpty() )
1148 {
1149 script = eScriptError.scriptName;
1150 }
1151
1152 if ( !eScriptError.Message.isEmpty() )
1153 {
1154 message = eScriptError.Message;
1155 }
1156 if ( eScriptError.lineNum != -1 )
1157 {
1158 line = OUString::number( eScriptError.lineNum );
1159 unformatted = CuiResId( RID_CUISTR_ERROR_AT_LINE );
1160 }
1161 else
1162 {
1163 unformatted = CuiResId( RID_CUISTR_ERROR_RUNNING );
1164 }
1165
1166 return FormatErrorString(
1167 unformatted, language, script, line, u"", message );
1168}
1169
1170OUString GetErrorMessage(
1171 const provider::ScriptExceptionRaisedException& eScriptException )
1172{
1173 OUString unformatted = CuiResId( RID_CUISTR_EXCEPTION_AT_LINE );
1174
1175 OUString unknown("UNKNOWN");
1176 OUString language = unknown;
1177 OUString script = unknown;
1178 OUString line = unknown;
1179 OUString type = unknown;
1180 OUString message = eScriptException.Message;
1181
1182 if ( !eScriptException.language.isEmpty() )
1183 {
1184 language = eScriptException.language;
1185 }
1186 if ( !eScriptException.scriptName.isEmpty() )
1187 {
1188 script = eScriptException.scriptName;
1189 }
1190
1191 if ( !eScriptException.Message.isEmpty() )
1192 {
1193 message = eScriptException.Message;
1194 }
1195
1196 if ( eScriptException.lineNum != -1 )
1197 {
1198 line = OUString::number( eScriptException.lineNum );
1199 unformatted = CuiResId( RID_CUISTR_EXCEPTION_AT_LINE );
1200 }
1201 else
1202 {
1203 unformatted = CuiResId( RID_CUISTR_EXCEPTION_RUNNING );
1204 }
1205
1206 if ( !eScriptException.exceptionType.isEmpty() )
1207 {
1208 type = eScriptException.exceptionType;
1209 }
1210
1211 return FormatErrorString(
1212 unformatted, language, script, line, type, message );
1213
1214}
1215OUString GetErrorMessage(
1216 const provider::ScriptFrameworkErrorException& sError )
1217{
1218 OUString unformatted = CuiResId( RID_CUISTR_FRAMEWORK_ERROR_RUNNING );
1219
1220 OUString language("UNKNOWN");
1221
1222 OUString script("UNKNOWN");
1223
1224 OUString message;
1225
1226 if ( !sError.scriptName.isEmpty() )
1227 {
1228 script = sError.scriptName;
1229 }
1230 if ( !sError.language.isEmpty() )
1231 {
1232 language = sError.language;
1233 }
1234 if ( sError.errorType == provider::ScriptFrameworkErrorType::NOTSUPPORTED )
1235 {
1236 message = CuiResId(RID_CUISTR_ERROR_LANG_NOT_SUPPORTED);
1237 message = ReplaceString(message, u"%LANGUAGENAME", language );
1238
1239 }
1240 else
1241 {
1242 message = sError.Message;
1243 }
1244 return FormatErrorString(
1245 unformatted, language, script, u"", std::u16string_view(), message );
1246}
1247
1248OUString GetErrorMessage( const css::uno::Any& aException )
1249{
1250 if ( aException.getValueType() ==
1252 {
1253 reflection::InvocationTargetException ite;
1254 aException >>= ite;
1255 if ( ite.TargetException.getValueType() == cppu::UnoType<provider::ScriptErrorRaisedException>::get())
1256 {
1257 // Error raised by script
1258 provider::ScriptErrorRaisedException scriptError;
1259 ite.TargetException >>= scriptError;
1260 return GetErrorMessage( scriptError );
1261 }
1262 else if ( ite.TargetException.getValueType() == cppu::UnoType<provider::ScriptExceptionRaisedException>::get())
1263 {
1264 // Exception raised by script
1265 provider::ScriptExceptionRaisedException scriptException;
1266 ite.TargetException >>= scriptException;
1267 return GetErrorMessage( scriptException );
1268 }
1269 else
1270 {
1271 // Unknown error, shouldn't happen
1272 // OSL_ASSERT(...)
1273 }
1274
1275 }
1276 else if ( aException.getValueType() == cppu::UnoType<provider::ScriptFrameworkErrorException>::get())
1277 {
1278 // A Script Framework error has occurred
1279 provider::ScriptFrameworkErrorException sfe;
1280 aException >>= sfe;
1281 return GetErrorMessage( sfe );
1282
1283 }
1284 // unknown exception
1285 auto msg = aException.getValueTypeName();
1286 Exception e;
1287 if ( (aException >>= e) && !e.Message.isEmpty() )
1288 {
1289 msg += ": " + e.Message;
1290 }
1291 return msg;
1292}
1293
1294}
1295
1296// Show Error dialog asynchronously
1297void SvxScriptErrorDialog::ShowAsyncErrorDialog( weld::Window* pParent, css::uno::Any const & aException )
1298{
1299 SolarMutexGuard aGuard;
1300 OUString sMessage = GetErrorMessage( aException );
1301
1302 // Pass a copy of the message to the ShowDialog method as the
1303 // SvxScriptErrorDialog may be deleted before ShowDialog is called
1305 pData->sMessage = sMessage;
1306 pData->pParent = pParent;
1309 pData );
1310}
1311
1312IMPL_STATIC_LINK( SvxScriptErrorDialog, ShowDialog, void*, p, void )
1313{
1314 std::unique_ptr<DialogData> xData(static_cast<DialogData*>(p));
1315 OUString message = xData->sMessage;
1316
1317 if ( message.isEmpty() )
1318 message = CuiResId( RID_CUISTR_ERROR_TITLE );
1319
1320 std::shared_ptr<weld::MessageDialog> xBox;
1322 xData->pParent,
1323 VclMessageType::Warning,
1324 VclButtonsType::Ok,
1325 message));
1326
1327 xBox->set_title(CuiResId(RID_CUISTR_ERROR_TITLE));
1328
1329 xBox->runAsync(xBox, [](sal_Int32 /*nResult*/) {});
1330}
1331
1332/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
sal_Int16 script
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
std::unique_ptr< weld::Entry > m_xEdit
Definition: scriptdlg.hxx:50
OUString GetObjectName() const
Definition: scriptdlg.hxx:53
CuiInputDialog(weld::Window *pParent, InputDialogMode nMode)
Definition: scriptdlg.cxx:341
void SetObjectName(const OUString &rName)
Definition: scriptdlg.hxx:54
const css::uno::Reference< css::script::browse::XBrowseNode > & GetNode() const
Definition: scriptdlg.hxx:71
void setLoaded()
Definition: scriptdlg.hxx:74
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: scriptdlg.hxx:72
bool isLoaded() const
Definition: scriptdlg.hxx:73
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
css::uno::Reference< css::frame::XModel3 > GetModel() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
static SVT_DLLPUBLIC OUString GetFileImageId(const INetURLObject &rURL)
static void ShowAsyncErrorDialog(weld::Window *pParent, css::uno::Any const &aException)
Definition: scriptdlg.cxx:1297
void delUserData(const weld::TreeIter &rIter)
Definition: scriptdlg.cxx:65
void deleteTree(const weld::TreeIter &rIter)
Definition: scriptdlg.cxx:79
static css::uno::Reference< css::script::browse::XBrowseNode > getLangNodeFromRootNode(css::uno::Reference< css::script::browse::XBrowseNode > const &root, std::u16string_view language)
Definition: scriptdlg.cxx:230
const OUString m_delErrTitleStr
Definition: scriptdlg.hxx:83
css::uno::Reference< css::frame::XModel > getModel(const weld::TreeIter &rEntry)
Definition: scriptdlg.cxx:686
const OUString m_sMyMacros
Definition: scriptdlg.hxx:91
std::unique_ptr< weld::TreeIter > m_xScratchIter
Definition: scriptdlg.hxx:95
std::unique_ptr< weld::Button > m_xDelButton
Definition: scriptdlg.hxx:101
const OUString m_delQueryStr
Definition: scriptdlg.hxx:84
void insertEntry(OUString const &rText, OUString const &rBitmap, const weld::TreeIter *pParent, bool bChildrenOnDemand, std::unique_ptr< SFEntry > &&aUserData, std::u16string_view factoryURL, bool bSelect)
Definition: scriptdlg.cxx:295
virtual short run() override
Definition: scriptdlg.cxx:426
static css::uno::Reference< css::uno::XInterface > getDocumentModel(css::uno::Reference< css::uno::XComponentContext > const &xCtx, std::u16string_view docName)
Definition: scriptdlg.cxx:203
void deleteEntry(const weld::TreeIter &rEntry)
Definition: scriptdlg.cxx:925
std::unique_ptr< weld::Button > m_xRenameButton
Definition: scriptdlg.hxx:100
std::unique_ptr< weld::TreeView > m_xScriptsBox
Definition: scriptdlg.hxx:94
SvxScriptOrgDialog(weld::Window *pParent, OUString language)
Definition: scriptdlg.cxx:369
const OUString m_createDupStr
Definition: scriptdlg.hxx:87
const OUString m_renameErrStr
Definition: scriptdlg.hxx:89
const OUString m_renameErrTitleStr
Definition: scriptdlg.hxx:90
void CheckButtons(css::uno::Reference< css::script::browse::XBrowseNode > const &node)
Definition: scriptdlg.cxx:445
virtual ~SvxScriptOrgDialog() override
Definition: scriptdlg.cxx:421
OUString getListOfChildren(const css::uno::Reference< css::script::browse::XBrowseNode > &node, int depth)
Definition: scriptdlg.cxx:987
void Init(std::u16string_view language)
Definition: scriptdlg.cxx:119
void renameEntry(const weld::TreeIter &rEntry)
Definition: scriptdlg.cxx:869
const OUString m_createErrTitleStr
Definition: scriptdlg.hxx:88
std::unique_ptr< weld::Button > m_xCloseButton
Definition: scriptdlg.hxx:97
const OUString m_delErrStr
Definition: scriptdlg.hxx:82
void RequestSubEntries(const weld::TreeIter &rRootEntry, css::uno::Reference< css::script::browse::XBrowseNode > const &node, css::uno::Reference< css::frame::XModel > &model)
Definition: scriptdlg.cxx:263
std::unique_ptr< weld::Button > m_xEditButton
Definition: scriptdlg.hxx:99
const OUString m_createErrStr
Definition: scriptdlg.hxx:86
css::uno::Reference< css::script::browse::XBrowseNode > getBrowseNode(const weld::TreeIter &rEntry)
Definition: scriptdlg.cxx:675
static bool getBoolProperty(css::uno::Reference< css::beans::XPropertySet > const &xProps, OUString const &propName)
Definition: scriptdlg.cxx:972
OUString m_sLanguage
Definition: scriptdlg.hxx:80
const OUString m_sProdMacros
Definition: scriptdlg.hxx:92
const OUString m_delQueryTitleStr
Definition: scriptdlg.hxx:85
void StoreCurrentSelection()
Definition: scriptdlg.cxx:1018
std::unique_ptr< weld::Button > m_xCreateButton
Definition: scriptdlg.hxx:98
static Selection_hash m_lastSelection
Definition: scriptdlg.hxx:81
std::unique_ptr< weld::Button > m_xRunButton
Definition: scriptdlg.hxx:96
void createEntry(const weld::TreeIter &rEntry)
Definition: scriptdlg.cxx:697
void RestorePreviousSelection()
Definition: scriptdlg.cxx:1037
virtual short run()
std::shared_ptr< weld::Dialog > m_xDialog
std::unique_ptr< weld::Builder > m_xBuilder
Any value
OUString CuiResId(TranslateId aKey)
Definition: cuiresmgr.cxx:23
#define TOOLS_WARN_EXCEPTION(area, stream)
OUString sName
const char * name
sal_Int32 nIndex
void * p
sal_Int64 n
std::unique_ptr< sal_Int32[]> pData
@ Exception
css::uno::Reference< css::uno::XCurrentContext > NoEnableJavaInteractionContext()
Reference< XComponentContext > getProcessComponentContext()
int i
line
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
args
OUString toId(const void *pValue)
IMPL_LINK(SvxScriptOrgDialog, ExpandingHdl, const weld::TreeIter &, rIter, bool)
Definition: scriptdlg.cxx:323
IMPL_STATIC_LINK(SvxScriptErrorDialog, ShowDialog, void *, p, void)
Definition: scriptdlg.cxx:1312
IMPL_LINK_NOARG(SvxScriptOrgDialog, ScriptSelectHdl, weld::TreeView &, void)
Definition: scriptdlg.cxx:523
std::unordered_map< OUString, OUString > Selection_hash
Definition: scriptdlg.hxx:37
InputDialogMode
Definition: scriptdlg.hxx:41
OUString sMessage
Reference< XModel > xModel
Any result
ResultType type
OUString sId
RET_CANCEL
RET_NO
size_t pos