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