LibreOffice Module cui (master)  1
cfgutil.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 <cfgutil.hxx>
21 
22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <com/sun/star/container/XEnumerationAccess.hpp>
24 #include <com/sun/star/container/XEnumeration.hpp>
25 #include <com/sun/star/document/XScriptInvocationContext.hpp>
26 #include <com/sun/star/frame/ModuleManager.hpp>
27 #include <com/sun/star/frame/Desktop.hpp>
28 #include <com/sun/star/frame/theUICommandDescription.hpp>
29 #include <com/sun/star/frame/XDispatchInformationProvider.hpp>
30 #include <com/sun/star/script/browse/XBrowseNode.hpp>
31 #include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
32 #include <com/sun/star/script/browse/theBrowseNodeFactory.hpp>
33 #include <com/sun/star/script/browse/BrowseNodeFactoryViewTypes.hpp>
34 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
35 #include <com/sun/star/uno/RuntimeException.hpp>
36 #include <com/sun/star/ui/theUICategoryDescription.hpp>
37 
38 #include <basic/basmgr.hxx>
39 #include <tools/urlobj.hxx>
40 #include <strings.hrc>
41 #include <bitmaps.hlst>
42 #include <sfx2/minfitem.hxx>
45 #include <comphelper/lok.hxx>
48 #include <svtools/imagemgr.hxx>
49 #include <sal/log.hxx>
50 #include <osl/diagnose.h>
51 #include <dialmgr.hxx>
52 #include <tools/diagnose_ex.h>
53 #include <vcl/commandevent.hxx>
55 #include <vcl/help.hxx>
56 #include <vcl/svapp.hxx>
57 
58 using namespace ::com::sun::star;
59 using namespace ::com::sun::star::uno;
60 using namespace ::com::sun::star::script;
61 using namespace ::com::sun::star::frame;
62 using namespace ::com::sun::star::document;
63 
65 {}
66 
67 void SfxStylesInfo_Impl::init(const OUString& rModuleName, const css::uno::Reference< css::frame::XModel >& xModel)
68 {
69  m_aModuleName = rModuleName;
70  m_xDoc = xModel;
71 }
72 
73 const char CMDURL_STYLEPROT_ONLY[] = ".uno:StyleApply?";
74 const char CMDURL_SPART_ONLY [] = "Style:string=";
75 const char CMDURL_FPART_ONLY [] = "FamilyName:string=";
76 
77 constexpr OUStringLiteral STYLEPROP_UINAME = u"DisplayName";
78 
80  std::u16string_view sFamily, std::u16string_view sStyle)
81 {
82  return OUString::Concat(".uno:StyleApply?Style:string=")
83  + sStyle
84  + "&FamilyName:string="
85  + sFamily;
86 }
87 
89 {
90  static const sal_Int32 LEN_STYLEPROT = strlen(CMDURL_STYLEPROT_ONLY);
91  static const sal_Int32 LEN_SPART = strlen(CMDURL_SPART_ONLY);
92  static const sal_Int32 LEN_FPART = strlen(CMDURL_FPART_ONLY);
93 
94  if (!aStyle.sCommand.startsWith(CMDURL_STYLEPROT_ONLY))
95  return false;
96 
97  aStyle.sFamily.clear();
98  aStyle.sStyle.clear();
99 
100  sal_Int32 nCmdLen = aStyle.sCommand.getLength();
101  OUString sCmdArgs = aStyle.sCommand.copy(LEN_STYLEPROT, nCmdLen-LEN_STYLEPROT);
102  sal_Int32 i = sCmdArgs.indexOf('&');
103  if (i<0)
104  return false;
105 
106  OUString sArg = sCmdArgs.copy(0, i);
107  if (sArg.startsWith(CMDURL_SPART_ONLY))
108  aStyle.sStyle = sArg.copy(LEN_SPART);
109  else if (sArg.startsWith(CMDURL_FPART_ONLY))
110  aStyle.sFamily = sArg.copy(LEN_FPART);
111 
112  sArg = sCmdArgs.copy(i+1, sCmdArgs.getLength()-i-1);
113  if (sArg.startsWith(CMDURL_SPART_ONLY))
114  aStyle.sStyle = sArg.copy(LEN_SPART);
115  else if (sArg.startsWith(CMDURL_FPART_ONLY))
116  aStyle.sFamily = sArg.copy(LEN_FPART);
117 
118  return !(aStyle.sFamily.isEmpty() || aStyle.sStyle.isEmpty());
119 }
120 
122 {
123  try
124  {
125  css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY);
126 
127  css::uno::Reference< css::container::XNameAccess > xFamilies;
128  if (xModel.is())
129  xFamilies = xModel->getStyleFamilies();
130 
131  css::uno::Reference< css::container::XNameAccess > xStyleSet;
132  if (xFamilies.is())
133  xFamilies->getByName(aStyle.sFamily) >>= xStyleSet;
134 
135  css::uno::Reference< css::beans::XPropertySet > xStyle;
136  if (xStyleSet.is())
137  xStyleSet->getByName(aStyle.sStyle) >>= xStyle;
138 
139  aStyle.sLabel.clear();
140  if (xStyle.is())
141  xStyle->getPropertyValue(STYLEPROP_UINAME) >>= aStyle.sLabel;
142  }
143  catch(const css::uno::RuntimeException&)
144  { throw; }
145  catch(const css::uno::Exception&)
146  { aStyle.sLabel.clear(); }
147 
148  if (aStyle.sLabel.isEmpty())
149  {
150  aStyle.sLabel = aStyle.sCommand;
151  }
152 }
153 
154 std::vector< SfxStyleInfo_Impl > SfxStylesInfo_Impl::getStyleFamilies() const
155 {
156  // It's an optional interface!
157  css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY);
158  if (!xModel.is())
159  return std::vector< SfxStyleInfo_Impl >();
160 
161  css::uno::Reference< css::container::XNameAccess > xCont = xModel->getStyleFamilies();
162  const css::uno::Sequence< OUString > lFamilyNames = xCont->getElementNames();
163  std::vector< SfxStyleInfo_Impl > lFamilies;
164  for (const auto& aFamily : lFamilyNames)
165  {
166  if ((aFamily == "CellStyles" && m_aModuleName != "com.sun.star.sheet.SpreadsheetDocument") ||
167  aFamily == "cell" || aFamily == "table" || aFamily == "Default")
168  continue;
169 
170  SfxStyleInfo_Impl aFamilyInfo;
171  aFamilyInfo.sFamily = aFamily;
172 
173  try
174  {
175  css::uno::Reference< css::beans::XPropertySet > xFamilyInfo;
176  xCont->getByName(aFamilyInfo.sFamily) >>= xFamilyInfo;
177  if (!xFamilyInfo.is())
178  {
179  // TODO_AS currently there is no support for an UIName property .. use internal family name instead
180  aFamilyInfo.sLabel = aFamilyInfo.sFamily;
181  }
182  else
183  xFamilyInfo->getPropertyValue(STYLEPROP_UINAME) >>= aFamilyInfo.sLabel;
184  }
185  catch(const css::uno::RuntimeException&)
186  { throw; }
187  catch(const css::uno::Exception&)
188  { return std::vector< SfxStyleInfo_Impl >(); }
189 
190  lFamilies.push_back(aFamilyInfo);
191  }
192 
193  return lFamilies;
194 }
195 
196 std::vector< SfxStyleInfo_Impl > SfxStylesInfo_Impl::getStyles(const OUString& sFamily)
197 {
198  css::uno::Sequence< OUString > lStyleNames;
199  css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY_THROW);
200  css::uno::Reference< css::container::XNameAccess > xFamilies = xModel->getStyleFamilies();
201  css::uno::Reference< css::container::XNameAccess > xStyleSet;
202  try
203  {
204  xFamilies->getByName(sFamily) >>= xStyleSet;
205  lStyleNames = xStyleSet->getElementNames();
206  }
207  catch(const css::uno::RuntimeException&)
208  { throw; }
209  catch(const css::uno::Exception&)
210  { return std::vector< SfxStyleInfo_Impl >(); }
211 
212  std::vector< SfxStyleInfo_Impl > lStyles;
213  sal_Int32 c = lStyleNames.getLength();
214  sal_Int32 i = 0;
215  for (i=0; i<c; ++i)
216  {
217  SfxStyleInfo_Impl aStyleInfo;
218  aStyleInfo.sFamily = sFamily;
219  aStyleInfo.sStyle = lStyleNames[i];
220  aStyleInfo.sCommand = SfxStylesInfo_Impl::generateCommand(aStyleInfo.sFamily, aStyleInfo.sStyle);
221 
222  try
223  {
224  css::uno::Reference< css::beans::XPropertySet > xStyle;
225  xStyleSet->getByName(aStyleInfo.sStyle) >>= xStyle;
226  if (!xStyle.is())
227  continue;
228  xStyle->getPropertyValue("DisplayName") >>= aStyleInfo.sLabel;
229  }
230  catch(const css::uno::RuntimeException&)
231  { throw; }
232  catch(const css::uno::Exception&)
233  { continue; }
234 
235  lStyles.push_back(aStyleInfo);
236  }
237  return lStyles;
238 }
239 
240 OUString CuiConfigFunctionListBox::GetHelpText( bool bConsiderParent )
241 {
242  SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(get_selected_id().toInt64());
243  if (pData)
244  {
245  if ( pData->nKind == SfxCfgKind::FUNCTION_SLOT )
246  {
247  if (bConsiderParent)
248  return Application::GetHelp()->GetHelpText(pData->sCommand, m_xTreeView.get());
249  else
250  return Application::GetHelp()->GetHelpText(pData->sCommand, static_cast<weld::Widget*>(nullptr));
251  }
252  else if ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT )
253  {
254  return pData->sHelpText;
255  }
256  }
257  return OUString();
258 }
259 
261 {
262  SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(get_selected_id().toInt64());
263  if (!pData)
264  return OUString();
265  return pData->sCommand;
266 }
267 
269 {
270  SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(get_selected_id().toInt64());
271  if (!pData)
272  return OUString();
273  if (!pData->sLabel.isEmpty())
274  return pData->sLabel;
275  return pData->sCommand;
276 }
277 
278 CuiConfigFunctionListBox::CuiConfigFunctionListBox(std::unique_ptr<weld::TreeView> xTreeView)
279  : m_xTreeView(std::move(xTreeView))
280  , m_xScratchIter(m_xTreeView->make_iterator())
281 {
282  m_xTreeView->make_sorted();
283  m_xTreeView->set_size_request(m_xTreeView->get_approximate_digit_width() * 35, m_xTreeView->get_height_rows(9));
284  m_xTreeView->connect_query_tooltip(LINK(this, CuiConfigFunctionListBox, QueryTooltip));
285 }
286 
288 {
289  ClearAll();
290 }
291 
292 IMPL_LINK(CuiConfigFunctionListBox, QueryTooltip, const weld::TreeIter&, rIter, OUString)
293 {
294  SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(rIter).toInt64());
295  if (!pData)
296  return OUString();
297  OUString aLabel = CuiResId(RID_SVXSTR_COMMANDLABEL) + ": ";
298  OUString aName = CuiResId(RID_SVXSTR_COMMANDNAME) + ": ";
299  OUString aTip = CuiResId(RID_SVXSTR_COMMANDTIP) + ": ";
300  return aLabel + pData->sLabel + "\n" + aName + pData->sCommand+ "\n" + aTip + pData->sTooltip;
301 }
302 
304 /* Description
305  Deletes all entries in the FunctionListBox, all UserData and all
306  possibly existing MacroInfo.
307 */
308 {
309  sal_uInt16 nCount = aArr.size();
310  for ( sal_uInt16 i=0; i<nCount; ++i )
311  {
312  SfxGroupInfo_Impl *pData = aArr[i].get();
313 
314  if ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT )
315  {
316  OUString* pScriptURI = static_cast<OUString*>(pData->pObject);
317  delete pScriptURI;
318  }
319 
321  {
322  XInterface* xi = static_cast<XInterface *>(pData->pObject);
323  if (xi != nullptr)
324  {
325  xi->release();
326  }
327  }
328  }
329 
330  aArr.clear();
331  m_xTreeView->clear();
332 }
333 
335 {
336  SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(get_selected_id().toInt64());
337  if (pData && pData->nKind == SfxCfgKind::FUNCTION_SCRIPT)
338  return *static_cast<OUString*>(pData->pObject);
339  return OUString();
340 }
341 
343 {
344  OUString m_sMyMacros;
345  OUString m_sProdMacros;
346  OUString m_sMacros;
347  OUString m_sDlgMacros;
349 
351 };
352 
354  m_sMyMacros(CuiResId(RID_SVXSTR_MYMACROS)),
355  m_sProdMacros(CuiResId(RID_SVXSTR_PRODMACROS)),
356  m_sMacros(CuiResId(RID_SVXSTR_BASICMACROS)),
357  m_sDlgMacros(CuiResId(RID_SVXSTR_PRODMACROS)),
358  m_aStrGroupStyles(CuiResId(RID_SVXSTR_GROUP_STYLES))
359 {
360 }
361 
363 {
364  m_pStylesInfo = pStyles;
365 }
366 
367 namespace
368 {
369 
376  Reference< XModel > lcl_getDocumentWithScripts_throw( const Reference< XInterface >& _rxComponent )
377  {
378  Reference< XEmbeddedScripts > xScripts( _rxComponent, UNO_QUERY );
379  if ( !xScripts.is() )
380  {
381  Reference< XScriptInvocationContext > xContext( _rxComponent, UNO_QUERY );
382  if ( xContext.is() )
383  xScripts = xContext->getScriptContainer();
384  }
385 
386  return Reference< XModel >( xScripts, UNO_QUERY );
387  }
388 
389 
390  Reference< XModel > lcl_getScriptableDocument_nothrow( const Reference< XFrame >& _rxFrame )
391  {
392  Reference< XModel > xDocument;
393 
394  // examine our associated frame
395  try
396  {
397  OSL_ENSURE( _rxFrame.is(), "lcl_getScriptableDocument_nothrow: you need to pass a frame to this dialog/tab page!" );
398  if ( _rxFrame.is() )
399  {
400  // first try the model in the frame
401  Reference< XController > xController( _rxFrame->getController(), UNO_SET_THROW );
402  xDocument = lcl_getDocumentWithScripts_throw( xController->getModel() );
403 
404  if ( !xDocument.is() )
405  {
406  // if there is no suitable document in the frame, try the controller
407  xDocument = lcl_getDocumentWithScripts_throw( _rxFrame->getController() );
408  }
409  }
410  }
411  catch( const Exception& )
412  {
413  }
414 
415  return xDocument;
416  }
417 }
418 
419 CuiConfigGroupListBox::CuiConfigGroupListBox(std::unique_ptr<weld::TreeView> xTreeView)
420  : xImp(new SvxConfigGroupBoxResource_Impl())
421  , m_pFunctionListBox(nullptr)
422  , m_pStylesInfo(nullptr)
423  , m_xTreeView(std::move(xTreeView))
424  , m_xScratchIter(m_xTreeView->make_iterator())
425 {
426  m_xTreeView->connect_expanding(LINK(this, CuiConfigGroupListBox, ExpandingHdl));
427  m_xTreeView->set_size_request(m_xTreeView->get_approximate_digit_width() * 35, m_xTreeView->get_height_rows(9));
428 }
429 
431 {
432  ClearAll();
433 }
434 
436 {
437  sal_uInt16 nCount = aArr.size();
438  for ( sal_uInt16 i=0; i<nCount; ++i )
439  {
440  SfxGroupInfo_Impl *pData = aArr[i].get();
441  if (pData->nKind == SfxCfgKind::GROUP_STYLES && pData->pObject)
442  {
443  SfxStyleInfo_Impl* pStyle = static_cast<SfxStyleInfo_Impl*>(pData->pObject);
444  delete pStyle;
445  }
446  else if (pData->nKind == SfxCfgKind::FUNCTION_SCRIPT && pData->pObject )
447  {
448  OUString* pScriptURI = static_cast<OUString*>(pData->pObject);
449  delete pScriptURI;
450  }
451  else if (pData->nKind == SfxCfgKind::GROUP_SCRIPTCONTAINER)
452  {
453  XInterface* xi = static_cast<XInterface *>(pData->pObject);
454  if (xi != nullptr)
455  {
456  xi->release();
457  }
458  }
459  }
460 
461  aArr.clear();
462  m_xTreeView->clear();
463 }
464 
466 {
467  try
468  {
469  css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider(m_xFrame, css::uno::UNO_QUERY_THROW);
470  css::uno::Sequence< sal_Int16 > lGroups = xProvider->getSupportedCommandGroups();
471  sal_Int32 c1 = lGroups.getLength();
472  sal_Int32 i1 = 0;
473 
474  if ( c1 )
475  {
476  // Add All Commands category
477  aArr.push_back(std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_ALLFUNCTIONS, 0));
478  m_xTreeView->append(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())),
479  CuiResId(RID_SVXSTR_ALLFUNCTIONS));
480  }
481 
482  for (i1=0; i1<c1; ++i1)
483  {
484  sal_Int16& rGroupID = lGroups[i1];
485  OUString sGroupID = OUString::number(rGroupID);
486  OUString sGroupName ;
487 
488  try
489  {
490  m_xModuleCategoryInfo->getByName(sGroupID) >>= sGroupName;
491  if (sGroupName.isEmpty())
492  continue;
493  }
494  catch(const css::container::NoSuchElementException&)
495  { continue; }
496 
497  aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_FUNCTION, rGroupID ) );
498  m_xTreeView->append(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())),
499  sGroupName);
500  }
501  }
502  catch(const css::uno::RuntimeException&)
503  { throw; }
504  catch(const css::uno::Exception&)
505  {}
506 }
507 
508 void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::script::browse::XBrowseNode >& xRootNode,
509  const weld::TreeIter* pParentEntry, bool bCheapChildrenOnDemand)
510 {
511  try {
512  if ( xRootNode->hasChildNodes() )
513  {
514  // tdf#120362: Don't ask to enable disabled Java when filling script list
515  css::uno::ContextLayer layer(comphelper::NoEnableJavaInteractionContext());
516 
517  const Sequence< Reference< browse::XBrowseNode > > children =
518  xRootNode->getChildNodes();
519  bool bIsRootNode = false;
520 
521  OUString user("user");
522  OUString share("share");
523  if ( xRootNode->getName() == "Root" )
524  {
525  bIsRootNode = true;
526  }
527 
528  //To mimic current starbasic behaviour we
529  //need to make sure that only the current document
530  //is displayed in the config tree. Tests below
531  //set the bDisplay flag to FALSE if the current
532  //node is a first level child of the Root and is NOT
533  //either the current document, user or share
534  OUString currentDocTitle;
535  Reference< XModel > xDocument( lcl_getScriptableDocument_nothrow( m_xFrame ) );
536  if ( xDocument.is() )
537  {
538  currentDocTitle = ::comphelper::DocumentInfo::getDocumentTitle( xDocument );
539  }
540 
541  for ( Reference< browse::XBrowseNode > const & theChild : children )
542  {
543  bool bDisplay = true;
544  OUString uiName = theChild->getName();
545  if ( bIsRootNode )
546  {
547  if ( ! (uiName == user || uiName == share ||
548  uiName == currentDocTitle ) )
549  {
550  bDisplay=false;
551  }
552  else
553  {
554  if ( uiName == user )
555  {
556  uiName = xImp->m_sMyMacros;
557  }
558  else if ( uiName == share )
559  {
560  uiName = xImp->m_sProdMacros;
561  }
562  }
563  }
564  if (theChild->getType() != browse::BrowseNodeTypes::SCRIPT && bDisplay )
565  {
566 // We call acquire on the XBrowseNode so that it does not
567 // get autodestructed and become invalid when accessed later.
568  theChild->acquire();
569 
570  bool bChildOnDemand = false;
571  if ( !bCheapChildrenOnDemand && theChild->hasChildNodes() )
572  {
573  const Sequence< Reference< browse::XBrowseNode > > grandchildren =
574  theChild->getChildNodes();
575 
576  for ( const auto& rxNode : grandchildren )
577  {
578  if ( rxNode->getType() == browse::BrowseNodeTypes::CONTAINER )
579  {
580  bChildOnDemand = true;
581  break;
582  }
583  }
584  }
585  else
586  {
587  /* i30923 - Would be nice if there was a better
588  * way to determine if a basic lib had children
589  * without having to ask for them (which forces
590  * the library to be loaded */
591  bChildOnDemand = true;
592  }
593 
594  OUString aImage = GetImage(theChild, m_xContext, bIsRootNode);
595 
596  aArr.push_back( std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_SCRIPTCONTAINER,
597  0, static_cast<void *>( theChild.get())));
598 
599  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())));
600  m_xTreeView->insert(pParentEntry, -1, &uiName, &sId, nullptr, nullptr, bChildOnDemand, m_xScratchIter.get());
601  m_xTreeView->set_image(*m_xScratchIter, aImage);
602  }
603  }
604  }
605  }
606  catch (RuntimeException&) {
607  // do nothing, the entry will not be displayed in the UI
608  }
609 }
610 
611 void CuiConfigGroupListBox::FillFunctionsList(const css::uno::Sequence<DispatchInformation>& xCommands)
612 {
614  for (const auto & rInfo : xCommands)
615  {
617 
618  OUString sUIName = MapCommand2UIName(rInfo.Command);
619  aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::FUNCTION_SLOT, 0 ) );
620  SfxGroupInfo_Impl* pGrpInfo = aArr.back().get();
621  pGrpInfo->sCommand = rInfo.Command;
622  pGrpInfo->sLabel = sUIName;
624  m_pFunctionListBox->append(OUString::number(reinterpret_cast<sal_Int64>(pGrpInfo)), sUIName);
625  }
627 }
628 
629 void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponentContext >& xContext,
630  const css::uno::Reference< css::frame::XFrame >& xFrame,
631  const OUString& sModuleLongName,
632  bool bEventMode)
633 {
634  m_xTreeView->freeze();
635  ClearAll(); // Remove all old entries from treelist box
636 
637  m_xContext = xContext;
638  m_xFrame = xFrame;
639  if( bEventMode )
640  {
641  m_sModuleLongName = sModuleLongName;
642  m_xGlobalCategoryInfo = css::ui::theUICategoryDescription::get( m_xContext );
643  m_xModuleCategoryInfo.set(m_xGlobalCategoryInfo->getByName(m_sModuleLongName), css::uno::UNO_QUERY_THROW);
644  m_xUICmdDescription = css::frame::theUICommandDescription::get( m_xContext );
645 
646  InitModule();
647  }
648 
649  SAL_INFO("cui.customize", "** ** About to initialise SF Scripts");
650  // Add Scripting Framework entries
651  Reference< browse::XBrowseNode > rootNode;
652  try
653  {
654  Reference< browse::XBrowseNodeFactory > xFac = browse::theBrowseNodeFactory::get( m_xContext );
655  rootNode.set( xFac->createView( browse::BrowseNodeFactoryViewTypes::MACROSELECTOR ) );
656  }
657  catch( const Exception& )
658  {
659  TOOLS_WARN_EXCEPTION("cui.customize", "Caught some exception whilst retrieving browse nodes from factory");
660  // TODO exception handling
661  }
662 
663 
664  if ( rootNode.is() )
665  {
666  if ( bEventMode )
667  {
668  //We call acquire on the XBrowseNode so that it does not
669  //get autodestructed and become invalid when accessed later.
670  rootNode->acquire();
671 
672  aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_SCRIPTCONTAINER, 0,
673  static_cast<void *>(rootNode.get())));
674  OUString aTitle(xImp->m_sDlgMacros);
675  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())));
676  m_xTreeView->insert(nullptr, -1, &aTitle, &sId, nullptr, nullptr, true, nullptr);
677  }
678  else
679  {
680  //We are only showing scripts not slot APIs so skip
681  //Root node and show location nodes
682  FillScriptList(rootNode, nullptr, false);
683  }
684  }
685 
686  // add styles
687  if ( bEventMode )
688  {
689  aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0, nullptr ) ); // TODO last parameter should contain user data
690  OUString sStyle(xImp->m_aStrGroupStyles);
691  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())));
692  m_xTreeView->insert(nullptr, -1, &sStyle, &sId, nullptr, nullptr, true, nullptr);
693  }
694 
695  m_xTreeView->thaw();
696  m_xTreeView->scroll_to_row(0);
697  m_xTreeView->select(0);
698 }
699 
701  const Reference< browse::XBrowseNode >& node,
702  Reference< XComponentContext > const & xCtx,
703  bool bIsRootNode)
704 {
705  OUString aImage;
706  if ( bIsRootNode )
707  {
708  if (node->getName() == "user" || node->getName() == "share" )
709  {
710  aImage = RID_CUIBMP_HARDDISK;
711  }
712  else
713  {
714  OUString factoryURL;
715  OUString nodeName = node->getName();
716  Reference<XInterface> xDocumentModel = getDocumentModel(xCtx, nodeName );
717  if ( xDocumentModel.is() )
718  {
719  Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xCtx) );
720  // get the long name of the document:
721  OUString appModule( xModuleManager->identify(
722  xDocumentModel ) );
723  Sequence<beans::PropertyValue> moduleDescr;
724  Any aAny = xModuleManager->getByName(appModule);
725  if( !( aAny >>= moduleDescr ) )
726  {
727  throw RuntimeException("SFTreeListBox::Init: failed to get PropertyValue");
728  }
729  beans::PropertyValue const * pmoduleDescr =
730  moduleDescr.getConstArray();
731  for ( sal_Int32 pos = moduleDescr.getLength(); pos--; )
732  {
733  if ( pmoduleDescr[ pos ].Name == "ooSetupFactoryEmptyDocumentURL" )
734  {
735  pmoduleDescr[ pos ].Value >>= factoryURL;
736  SAL_INFO("cui.customize", "factory url for doc images is " << factoryURL);
737  break;
738  }
739  }
740  }
741  if( !factoryURL.isEmpty() )
742  {
744  }
745  else
746  {
747  aImage = RID_CUIBMP_DOC;
748  }
749  }
750  }
751  else
752  {
753  if( node->getType() == browse::BrowseNodeTypes::SCRIPT )
754  aImage = RID_CUIBMP_MACRO;
755  else
756  aImage = RID_CUIBMP_LIB;
757  }
758  return aImage;
759 }
760 
761 Reference< XInterface >
763 {
764  Reference< XInterface > xModel;
765  Reference< frame::XDesktop2 > desktop = frame::Desktop::create( xCtx );
766 
767  Reference< container::XEnumerationAccess > componentsAccess =
768  desktop->getComponents();
769  Reference< container::XEnumeration > components =
770  componentsAccess->createEnumeration();
771  while (components->hasMoreElements())
772  {
774  components->nextElement(), UNO_QUERY );
775  if ( model.is() )
776  {
777  OUString sTdocUrl =
778  ::comphelper::DocumentInfo::getDocumentTitle( model );
779  if( sTdocUrl == docName )
780  {
781  xModel = model;
782  break;
783  }
784  }
785  }
786  return xModel;
787 }
788 
789 OUString CuiConfigGroupListBox::MapCommand2UIName(const OUString& sCommand)
790 {
791  OUString sUIName;
792  try
793  {
794  css::uno::Reference< css::container::XNameAccess > xModuleConf;
795  m_xUICmdDescription->getByName(m_sModuleLongName) >>= xModuleConf;
796  if (xModuleConf.is())
797  {
798  ::comphelper::SequenceAsHashMap lProps(xModuleConf->getByName(sCommand));
799  sUIName = lProps.getUnpackedValueOrDefault("Name", OUString());
800  }
801  }
802  catch(const css::uno::RuntimeException&)
803  { throw; }
804  catch(css::uno::Exception&)
805  { sUIName.clear(); }
806 
807  // fallback for missing UINames !?
808  if (sUIName.isEmpty())
809  {
810  sUIName = sCommand;
811  }
812 
813  return sUIName;
814 }
815 
817 /* Description
818  A function group or a basic module has been selected.
819  All functions/macros are displayed in the functionlistbox.
820 */
821 {
822  std::unique_ptr<weld::TreeIter> xIter(m_xTreeView->make_iterator());
823  if (!m_xTreeView->get_selected(xIter.get()))
824  return;
825 
826  SfxGroupInfo_Impl *pInfo = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(*xIter).toInt64());
829 
830  switch ( pInfo->nKind )
831  {
833  {
834  css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider( m_xFrame, UNO_QUERY );
835  bool bValidIter = m_xTreeView->get_iter_first(*xIter);
836  while (bValidIter)
837  {
838  SfxGroupInfo_Impl *pCurrentInfo = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(*xIter).toInt64());
839  if (pCurrentInfo->nKind == SfxCfgKind::GROUP_FUNCTION)
840  {
841  css::uno::Sequence< css::frame::DispatchInformation > lCommands;
842  try
843  {
844  lCommands = xProvider->getConfigurableDispatchInformation( pCurrentInfo->nUniqueID );
845  FillFunctionsList( lCommands );
846  }
847  catch ( container::NoSuchElementException& )
848  {
849  }
850  }
851  bValidIter = m_xTreeView->iter_next(*xIter);
852  }
853  break;
854  }
855 
857  {
858  sal_uInt16 nGroup = pInfo->nUniqueID;
859  css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider (m_xFrame, css::uno::UNO_QUERY_THROW);
860  css::uno::Sequence< css::frame::DispatchInformation > lCommands = xProvider->getConfigurableDispatchInformation(nGroup);
861  FillFunctionsList( lCommands );
862  break;
863  }
864 
866  {
867  if (!m_xTreeView->iter_has_child(*xIter))
868  {
869  Reference< browse::XBrowseNode > rootNode(
870  static_cast< browse::XBrowseNode* >( pInfo->pObject ) ) ;
871 
872  try {
873  if ( rootNode->hasChildNodes() )
874  {
875  const Sequence< Reference< browse::XBrowseNode > > children =
876  rootNode->getChildNodes();
877 
878  for ( const Reference< browse::XBrowseNode >& childNode : children )
879  {
880  if (childNode->getType() == browse::BrowseNodeTypes::SCRIPT)
881  {
882  OUString uri, description;
883 
884  Reference < beans::XPropertySet >xPropSet( childNode, UNO_QUERY );
885  if (!xPropSet.is())
886  {
887  continue;
888  }
889 
890  Any value =
891  xPropSet->getPropertyValue("URI");
892  value >>= uri;
893 
894  try
895  {
896  value = xPropSet->getPropertyValue("Description");
897  value >>= description;
898  }
899  catch (Exception &) {
900  // do nothing, the description will be empty
901  }
902 
903  OUString* pScriptURI = new OUString( uri );
904 
905  OUString aImage = GetImage(childNode, Reference< XComponentContext >(), false);
906  m_pFunctionListBox->aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::FUNCTION_SCRIPT, 0, pScriptURI ));
907  m_pFunctionListBox->aArr.back()->sCommand = uri;
908  m_pFunctionListBox->aArr.back()->sLabel = childNode->getName();
909  m_pFunctionListBox->aArr.back()->sHelpText = description;
910 
911  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(m_pFunctionListBox->aArr.back().get())));
912  m_pFunctionListBox->append(sId, childNode->getName(), aImage);
913  }
914  }
915  }
916  }
917  catch (RuntimeException&) {
918  // do nothing, the entry will not be displayed in the UI
919  }
920  }
921  break;
922  }
923 
925  {
926  SfxStyleInfo_Impl* pFamily = static_cast<SfxStyleInfo_Impl*>(pInfo->pObject);
927  if (pFamily)
928  {
929  const std::vector< SfxStyleInfo_Impl > lStyles = m_pStylesInfo->getStyles(pFamily->sFamily);
930  for (auto const& lStyle : lStyles)
931  {
932  SfxStyleInfo_Impl* pStyle = new SfxStyleInfo_Impl(lStyle);
933  m_pFunctionListBox->aArr.push_back(std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_STYLES, 0, pStyle));
934  m_pFunctionListBox->aArr.back()->sCommand = pStyle->sCommand;
935  m_pFunctionListBox->aArr.back()->sLabel = pStyle->sLabel;
936  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(m_pFunctionListBox->aArr.back().get())));
937  m_pFunctionListBox->append(sId, pStyle->sLabel);
938  }
939  }
940  break;
941  }
942 
943  default:
944  // Do nothing, the list box will stay empty
945  SAL_INFO( "cui.customize", "Ignoring unexpected SfxCfgKind: " << static_cast<int>(pInfo->nKind) );
946  break;
947  }
948 
950 
953 }
954 
955 /* Description
956  A basic or a library is opened.
957 */
958 IMPL_LINK(CuiConfigGroupListBox, ExpandingHdl, const weld::TreeIter&, rIter, bool)
959 {
960  SfxGroupInfo_Impl *pInfo = reinterpret_cast<SfxGroupInfo_Impl*>(m_xTreeView->get_id(rIter).toInt64());
961  switch ( pInfo->nKind )
962  {
964  {
965  if (!m_xTreeView->iter_has_child(rIter))
966  {
967  Reference< browse::XBrowseNode > rootNode(
968  static_cast< browse::XBrowseNode* >( pInfo->pObject ) ) ;
969  FillScriptList(rootNode, &rIter, true /* i30923 */ );
970  }
971  break;
972  }
973 
975  {
976  if (!m_xTreeView->iter_has_child(rIter))
977  {
978  const std::vector<SfxStyleInfo_Impl> lStyleFamilies = m_pStylesInfo->getStyleFamilies();
979  for (auto const& lStyleFamily : lStyleFamilies)
980  {
981  SfxStyleInfo_Impl* pFamily = new SfxStyleInfo_Impl(lStyleFamily);
982  aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0, pFamily ));
983  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(aArr.back().get())));
984  m_xTreeView->insert(&rIter, -1, &pFamily->sLabel, &sId, nullptr, nullptr, false, nullptr);
985  }
986  }
987  break;
988  }
989 
990  default:
991  OSL_FAIL( "Wrong group type!" );
992  break;
993  }
994  return true;
995 }
996 
998 {
999  SelectMacro( pItem->GetBasicManager()->GetName(),
1000  pItem->GetQualifiedName() );
1001 }
1002 
1003 void CuiConfigGroupListBox::SelectMacro( std::u16string_view rBasic,
1004  const OUString& rMacro )
1005 {
1006  const OUString aBasicName(OUString::Concat(rBasic) + " " + xImp->m_sMacros);
1007  sal_Int32 nIdx {rMacro.lastIndexOf('.')};
1008  const OUString aMethod( rMacro.copy(nIdx+1) );
1009  OUString aLib;
1010  OUString aModule;
1011  if ( nIdx>0 )
1012  {
1013  // string contains at least 2 tokens
1014  nIdx = rMacro.lastIndexOf('.', nIdx);
1015  if (nIdx>=0)
1016  {
1017  // string contains at least 3 tokens
1018  aLib = rMacro.getToken( 0, '.' );
1019  aModule = rMacro.getToken( 0, '.', ++nIdx );
1020  }
1021  }
1022 
1023  std::unique_ptr<weld::TreeIter> xIter = m_xTreeView->make_iterator();
1024  if (!m_xTreeView->get_iter_first(*xIter))
1025  return;
1026 
1027  do
1028  {
1029  OUString aEntryBas = m_xTreeView->get_text(*xIter);
1030  if (aEntryBas == aBasicName)
1031  {
1032  m_xTreeView->expand_row(*xIter);
1033  std::unique_ptr<weld::TreeIter> xLibIter = m_xTreeView->make_iterator(xIter.get());
1034  if (m_xTreeView->get_iter_first(*xLibIter))
1035  {
1036  do
1037  {
1038  OUString aEntryLib = m_xTreeView->get_text(*xLibIter);
1039  if (aEntryLib == aLib)
1040  {
1041  m_xTreeView->expand_row(*xLibIter);
1042  std::unique_ptr<weld::TreeIter> xModIter = m_xTreeView->make_iterator(xLibIter.get());
1043  if (m_xTreeView->get_iter_first(*xModIter))
1044  {
1045  do
1046  {
1047  OUString aEntryMod = m_xTreeView->get_text(*xModIter);
1048  if ( aEntryMod == aModule )
1049  {
1050  m_xTreeView->expand_row(*xModIter);
1051  m_xTreeView->scroll_to_row(*xModIter);
1052  m_xTreeView->select(*xModIter);
1053  for (int i = 0, nCount = m_pFunctionListBox->n_children(); i < nCount; ++i)
1054  {
1055  OUString aEntryMethod = m_pFunctionListBox->get_text(i);
1056  if (aEntryMethod == aMethod)
1057  {
1060  return;
1061  }
1062  }
1063  }
1064  } while (m_xTreeView->iter_next_sibling(*xModIter));
1065  }
1066  }
1067  } while (m_xTreeView->iter_next_sibling(*xLibIter));
1068  }
1069  }
1070  } while (m_xTreeView->iter_next_sibling(*xIter));
1071 }
1072 
1073 /*
1074  * Implementation of SvxScriptSelectorDialog
1075  *
1076  * This dialog is used for selecting Slot API commands
1077  * and Scripting Framework Scripts.
1078  */
1079 
1081  weld::Window* pParent, const css::uno::Reference< css::frame::XFrame >& xFrame)
1082  : GenericDialogController(pParent, "cui/ui/macroselectordialog.ui", "MacroSelectorDialog")
1083  , m_xDialogDescription(m_xBuilder->weld_label("helpmacro"))
1084  , m_xCategories(new CuiConfigGroupListBox(m_xBuilder->weld_tree_view("categories")))
1085  , m_xCommands(new CuiConfigFunctionListBox(m_xBuilder->weld_tree_view("commands")))
1086  , m_xLibraryFT(m_xBuilder->weld_label("libraryft"))
1087  , m_xCategoryFT(m_xBuilder->weld_label("categoryft"))
1088  , m_xMacronameFT(m_xBuilder->weld_label("macronameft"))
1089  , m_xCommandsFT(m_xBuilder->weld_label("commandsft"))
1090  , m_xOKButton(m_xBuilder->weld_button("ok"))
1091  , m_xCancelButton(m_xBuilder->weld_button("cancel"))
1092  , m_xDescriptionText(m_xBuilder->weld_text_view("description"))
1093 {
1094  m_xCancelButton->show();
1095  m_xDialogDescription->show();
1096  m_xOKButton->show();
1097 
1098  m_xLibraryFT->set_visible(true);
1099  m_xCategoryFT->set_visible(false);
1100  m_xMacronameFT->set_visible(true);
1101  m_xCommandsFT->set_visible(false);
1102 
1103  const OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame));
1104  m_xCategories->SetFunctionListBox(m_xCommands.get());
1105  m_xCategories->Init(comphelper::getProcessComponentContext(), xFrame, aModuleName, /*bShowSlots*/false);
1106 
1107  m_xCategories->connect_changed(
1108  LINK( this, SvxScriptSelectorDialog, SelectHdl ) );
1109  m_xCommands->connect_changed( LINK( this, SvxScriptSelectorDialog, SelectHdl ) );
1110  m_xCommands->connect_row_activated( LINK( this, SvxScriptSelectorDialog, FunctionDoubleClickHdl ) );
1111  m_xCommands->connect_popup_menu( LINK( this, SvxScriptSelectorDialog, ContextMenuHdl ) );
1112 
1113  m_xOKButton->connect_clicked( LINK( this, SvxScriptSelectorDialog, ClickHdl ) );
1114  m_xCancelButton->connect_clicked( LINK( this, SvxScriptSelectorDialog, ClickHdl ) );
1115 
1116  m_sDefaultDesc = m_xDescriptionText->get_text();
1117 
1118  // Support style commands
1119  uno::Reference<frame::XController> xController;
1120  uno::Reference<frame::XModel> xModel;
1121  if (xFrame.is())
1122  xController = xFrame->getController();
1123  if (xController.is())
1124  xModel = xController->getModel();
1125 
1126  m_aStylesInfo.init(aModuleName, xModel);
1127  m_xCategories->SetStylesInfo(&m_aStylesInfo);
1128 
1129  UpdateUI();
1130 }
1131 
1133 {
1134 }
1135 
1137 {
1138  if (&rCtrl == &m_xCategories->get_widget())
1139  {
1140  m_xCategories->GroupSelected();
1141  }
1142  UpdateUI();
1143 }
1144 
1146 {
1147  if (m_xOKButton->get_sensitive())
1148  ClickHdl(*m_xOKButton);
1149  return true;
1150 }
1151 
1152 IMPL_LINK(SvxScriptSelectorDialog, ContextMenuHdl, const CommandEvent&, rCEvt, bool)
1153 {
1154  weld::TreeView& xTreeView = m_xCommands->get_widget();
1155  if (rCEvt.GetCommand() != CommandEventId::ContextMenu || !xTreeView.n_children())
1156  return false;
1157 
1158  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(&xTreeView, "modules/BasicIDE/ui/sortmenu.ui"));
1159  std::unique_ptr<weld::Menu> xPopup(xBuilder->weld_menu("sortmenu"));
1160  std::unique_ptr<weld::Menu> xDropMenu(xBuilder->weld_menu("sortsubmenu"));
1161  xDropMenu->set_active("alphabetically", xTreeView.get_sort_order());
1162  xDropMenu->set_active("properorder", !xTreeView.get_sort_order());
1163 
1164  OString sCommand(xPopup->popup_at_rect(&xTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1))));
1165  if (sCommand == "alphabetically")
1166  {
1167  xTreeView.make_sorted();
1168  }
1169  else if (sCommand == "properorder")
1170  {
1171  xTreeView.make_unsorted();
1172  m_xCategories->GroupSelected();
1173  }
1174  else if (!sCommand.isEmpty())
1175  {
1176  SAL_WARN("cui.customize", "Unknown context menu action: " << sCommand );
1177  }
1178 
1179  return true;
1180 }
1181 
1182 // Check if command is selected and enable the OK button accordingly
1183 // Grab the help text for this id if available and update the description field
1184 void
1186 {
1187  OUString url = GetScriptURL();
1188  if ( !url.isEmpty() )
1189  {
1190  OUString sMessage = m_xCommands->GetHelpText();
1191  m_xDescriptionText->set_text(sMessage.isEmpty() ? m_sDefaultDesc : sMessage);
1192 
1193  m_xOKButton->set_sensitive(true);
1194  }
1195  else
1196  {
1198  m_xOKButton->set_sensitive(false);
1199  }
1200 }
1201 
1203 {
1204  if (&rButton == m_xCancelButton.get())
1205  {
1206  m_xDialog->response(RET_CANCEL);
1207  }
1208  else if (&rButton == m_xOKButton.get())
1209  {
1210  m_xDialog->response(RET_OK);
1211  }
1212 }
1213 
1214 void
1216 {
1217  m_xOKButton->set_label(CuiResId(RID_SVXSTR_SELECTOR_RUN));
1218 }
1219 
1220 OUString
1222 {
1223  OUString result;
1224 
1225  std::unique_ptr<weld::TreeIter> xIter = m_xCommands->make_iterator();
1226  if (m_xCommands->get_selected(xIter.get()))
1227  {
1228  SfxGroupInfo_Impl *pData = reinterpret_cast<SfxGroupInfo_Impl*>(m_xCommands->get_id(*xIter).toInt64());
1229  if ( ( pData->nKind == SfxCfgKind::FUNCTION_SLOT )
1230  || ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT )
1231  || ( pData->nKind == SfxCfgKind::GROUP_STYLES )
1232  )
1233  {
1234  result = pData->sCommand;
1235  }
1236  }
1237 
1238  return result;
1239 }
1240 
1241 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< SvxConfigGroupBoxResource_Impl > xImp
Definition: cfgutil.hxx:181
css::uno::Reference< css::container::XNameAccess > m_xGlobalCategoryInfo
Definition: cfgutil.hxx:187
OUString sMessage
std::vector< SfxStyleInfo_Impl > getStyleFamilies() const
Definition: cfgutil.cxx:154
OUString sStyle
Definition: cfgutil.hxx:42
OUString GetHelpText(bool bConsiderParent=true)
Definition: cfgutil.cxx:240
OUString sTooltip
Definition: cfgutil.hxx:96
std::unique_ptr< CuiConfigFunctionListBox > m_xCommands
Definition: cfgutil.hxx:239
std::unique_ptr< ContentProperties > pData
void FillScriptList(const css::uno::Reference< css::script::browse::XBrowseNode > &xRootNode, const weld::TreeIter *pParentEntry, bool bCheapChildrenOnDemand)
Definition: cfgutil.cxx:508
static Help * GetHelp()
OUString GetScriptURL() const
Definition: cfgutil.cxx:1221
css::uno::Reference< css::frame::XModel > m_xDoc
Definition: cfgutil.hxx:62
const char CMDURL_FPART_ONLY[]
Definition: cfgutil.cxx:75
SfxStylesInfo_Impl * m_pStylesInfo
Definition: cfgutil.hxx:190
css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription
Definition: cfgutil.hxx:189
virtual void make_unsorted()=0
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
void getLabel4Style(SfxStyleInfo_Impl &aStyle)
Definition: cfgutil.cxx:121
std::unique_ptr< weld::TreeIter > m_xScratchIter
Definition: cfgutil.hxx:192
OUString Name
RET_CANCEL
css::uno::Reference< css::container::XNameAccess > m_xModuleCategoryInfo
Definition: cfgutil.hxx:188
OUString MapCommand2UIName(const OUString &sCommand)
Definition: cfgutil.cxx:789
Reference< XController > xController
PropertiesInfo aProperties
OUString get_text(int nPos) const
Definition: cfgutil.hxx:147
std::unique_ptr< weld::Button > m_xOKButton
const char CMDURL_STYLEPROT_ONLY[]
Definition: cfgutil.cxx:73
size_t pos
int nCount
virtual int n_children() const =0
std::unique_ptr< CuiConfigGroupListBox > m_xCategories
Definition: cfgutil.hxx:238
void select(int pos)
Definition: cfgutil.hxx:162
css::uno::Reference< css::uno::XCurrentContext > NoEnableJavaInteractionContext()
int n_children() const
Definition: cfgutil.hxx:144
SfxGroupInfoArr_Impl aArr
Definition: cfgutil.hxx:183
OUString sFamily
Definition: cfgutil.hxx:41
OUString GetCurLabel() const
Definition: cfgutil.cxx:268
void Init(const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XFrame > &xFrame, const OUString &sModuleLongName, bool bEventMode)
Definition: cfgutil.cxx:629
std::unique_ptr< weld::TreeView > m_xTreeView
Definition: cfgutil.hxx:191
OUString sLabel
Definition: cfgutil.hxx:44
SvxScriptSelectorDialog(weld::Window *pParent, const css::uno::Reference< css::frame::XFrame > &xFrame)
Definition: cfgutil.cxx:1080
SfxStylesInfo_Impl m_aStylesInfo
Definition: cfgutil.hxx:235
tuple model
virtual OUString GetHelpText(const OUString &aHelpURL, const vcl::Window *pWindow)
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
#define TOOLS_WARN_EXCEPTION(area, stream)
std::unique_ptr< weld::Label > m_xLibraryFT
Definition: cfgutil.hxx:240
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
int i
OUString sHelpText
Definition: cfgutil.hxx:95
std::vector< SfxStyleInfo_Impl > getStyles(const OUString &sFamily)
Definition: cfgutil.cxx:196
virtual ~SvxScriptSelectorDialog() override
Definition: cfgutil.cxx:1132
constexpr OUStringLiteral STYLEPROP_UINAME
Definition: cfgutil.cxx:77
SfxCfgKind nKind
Definition: cfgutil.hxx:90
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: cfgutil.hxx:185
OUString GetCurCommand() const
Definition: cfgutil.cxx:260
void scroll_to_row(int pos)
Definition: cfgutil.hxx:141
OUString GetSelectedScriptURI() const
Definition: cfgutil.cxx:334
float u
OUString get_selected_id() const
Definition: cfgutil.hxx:156
sal_uInt16 nUniqueID
Definition: cfgutil.hxx:91
void SetStylesInfo(SfxStylesInfo_Impl *pStyles)
Definition: cfgutil.cxx:362
OUString m_sModuleLongName
Definition: cfgutil.hxx:184
OUString sCommand
Definition: cfgutil.hxx:43
void init(const OUString &rModuleName, const css::uno::Reference< css::frame::XModel > &xModel)
Definition: cfgutil.cxx:67
OUString CuiResId(const char *pKey)
Definition: cuiresmgr.cxx:23
const BasicManager * GetBasicManager() const
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
std::unique_ptr< weld::Label > m_xMacronameFT
Definition: cfgutil.hxx:242
void FillFunctionsList(const css::uno::Sequence< css::frame::DispatchInformation > &xCommands)
Definition: cfgutil.cxx:611
SfxGroupInfoArr_Impl aArr
Definition: cfgutil.hxx:107
CuiConfigFunctionListBox(std::unique_ptr< weld::TreeView > xTreeView)
Definition: cfgutil.cxx:278
OUString GetQualifiedName() const
OUString sCommand
Definition: cfgutil.hxx:93
virtual bool get_sort_order() const =0
std::unique_ptr< weld::Label > m_xCommandsFT
Definition: cfgutil.hxx:243
#define SAL_INFO(area, stream)
OUString aName
const OUString & GetName() const
static OUString generateCommand(std::u16string_view sFamily, std::u16string_view sStyle)
Definition: cfgutil.cxx:79
RET_OK
IMPL_LINK_NOARG(SvxScriptSelectorDialog, FunctionDoubleClickHdl, weld::TreeView &, bool)
Definition: cfgutil.cxx:1145
Reference< XExecutableDialog > m_xDialog
OUString aLabel
static OUString GetImage(const css::uno::Reference< css::script::browse::XBrowseNode > &node, css::uno::Reference< css::uno::XComponentContext > const &xCtx, bool bIsRootNode)
Definition: cfgutil.cxx:700
Reference< XComponentContext > getProcessComponentContext()
std::unique_ptr< weld::Label > m_xDialogDescription
Definition: cfgutil.hxx:237
CuiConfigFunctionListBox * m_pFunctionListBox
Definition: cfgutil.hxx:182
Any value
static css::uno::Reference< css::uno::XInterface > getDocumentModel(css::uno::Reference< css::uno::XComponentContext > const &xCtx, std::u16string_view docName)
Definition: cfgutil.cxx:762
const SvxPageUsage aArr[]
Definition: page.cxx:73
static bool parseStyleCommand(SfxStyleInfo_Impl &aStyle)
Definition: cfgutil.cxx:88
OUString sLabel
Definition: cfgutil.hxx:94
OUString sId
OUString m_aModuleName
Definition: cfgutil.hxx:61
std::unique_ptr< weld::Button > m_xOKButton
Definition: cfgutil.hxx:244
void SelectMacro(const SfxMacroInfoItem *)
Definition: cfgutil.cxx:997
Any result
#define SAL_WARN(area, stream)
Reference< XModel > xModel
std::unique_ptr< weld::Label > m_xCategoryFT
Definition: cfgutil.hxx:241
const char CMDURL_SPART_ONLY[]
Definition: cfgutil.cxx:74
std::unique_ptr< weld::Button > m_xCancelButton
Definition: cfgutil.hxx:245
CuiConfigGroupListBox(std::unique_ptr< weld::TreeView > xTreeView)
Definition: cfgutil.cxx:419
static SVT_DLLPUBLIC OUString GetFileImageId(const INetURLObject &rURL)
IMPL_LINK(CuiConfigFunctionListBox, QueryTooltip, const weld::TreeIter &, rIter, OUString)
Definition: cfgutil.cxx:292
virtual void make_sorted()=0
OUString GetTooltipForCommand(const OUString &rsCommandName, const css::uno::Sequence< css::beans::PropertyValue > &rProperties, const Reference< frame::XFrame > &rxFrame)
css::uno::Reference< css::frame::XFrame > m_xFrame
Definition: cfgutil.hxx:186
std::unique_ptr< weld::TreeView > m_xTreeView
Definition: cfgutil.hxx:109
std::unique_ptr< weld::TextView > m_xDescriptionText
Definition: cfgutil.hxx:246
exports com.sun.star. uri
void append(const OUString &rId, const OUString &rStr, const weld::TreeIter *pParent=nullptr)
Definition: cfgutil.hxx:120