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