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