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