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