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