masterfix DEV300: #i10000# build fix
[LibreOffice.git] / cui / source / customize / cfgutil.cxx
blob59fc088abe1e28c06d870b4b7948a33ee7cc3854
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 #include "cfgutil.hxx"
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/frame/XDispatchInformationProvider.hpp>
35 #include <com/sun/star/uno/RuntimeException.hpp>
36 #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
37 #include <com/sun/star/script/provider/XScriptProvider.hpp>
38 #include <com/sun/star/script/browse/XBrowseNode.hpp>
39 #include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
41 #include <com/sun/star/script/browse/XBrowseNodeFactory.hpp>
42 #include <com/sun/star/script/browse/BrowseNodeFactoryViewTypes.hpp>
43 #include <com/sun/star/frame/XModuleManager.hpp>
44 #include <com/sun/star/frame/XDesktop.hpp>
45 #include <com/sun/star/container/XEnumerationAccess.hpp>
46 #include <com/sun/star/container/XEnumeration.hpp>
47 #include <com/sun/star/document/XDocumentInfoSupplier.hpp>
48 #include <com/sun/star/document/XScriptInvocationContext.hpp>
49 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
51 #include "acccfg.hrc"
52 #include "helpid.hrc"
53 #include <basic/sbx.hxx>
54 #include <basic/basicmanagerrepository.hxx>
55 #include <basic/sbstar.hxx>
56 #include <basic/sbxmeth.hxx>
57 #include <basic/sbmod.hxx>
58 #include <basic/basmgr.hxx>
59 #include <tools/urlobj.hxx>
60 #include "cuires.hrc"
61 #include <sfx2/app.hxx>
62 #include <sfx2/minfitem.hxx>
63 #include <unotools/processfactory.hxx>
64 #include <comphelper/documentinfo.hxx>
65 #include <svtools/imagemgr.hxx>
66 #include <rtl/ustrbuf.hxx>
67 #include <comphelper/sequenceashashmap.hxx>
68 #include <unotools/configmgr.hxx>
69 #include "dialmgr.hxx"
70 #include <svl/stritem.hxx>
72 #define _SVSTDARR_STRINGSDTOR
73 #include <svl/svstdarr.hxx>
75 using namespace ::com::sun::star;
76 using namespace ::com::sun::star::uno;
77 using namespace ::com::sun::star::script;
78 using namespace ::com::sun::star::frame;
79 using namespace ::com::sun::star::document;
80 namespace css = ::com::sun::star;
82 static ::rtl::OUString SERVICE_UICATEGORYDESCRIPTION = ::rtl::OUString::createFromAscii("com.sun.star.ui.UICategoryDescription" );
83 static ::rtl::OUString SERVICE_UICMDDESCRIPTION = ::rtl::OUString::createFromAscii("com.sun.star.frame.UICommandDescription");
85 SfxStylesInfo_Impl::SfxStylesInfo_Impl()
88 void SfxStylesInfo_Impl::setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel)
90 m_xDoc = xModel;
93 static ::rtl::OUString FAMILY_CHARACTERSTYLE = ::rtl::OUString::createFromAscii("CharacterStyles");
94 static ::rtl::OUString FAMILY_PARAGRAPHSTYLE = ::rtl::OUString::createFromAscii("ParagraphStyles");
95 static ::rtl::OUString FAMILY_FRAMESTYLE = ::rtl::OUString::createFromAscii("FrameStyles" );
96 static ::rtl::OUString FAMILY_PAGESTYLE = ::rtl::OUString::createFromAscii("PageStyles" );
97 static ::rtl::OUString FAMILY_NUMBERINGSTYLE = ::rtl::OUString::createFromAscii("NumberingStyles");
99 static ::rtl::OUString CMDURL_SPART = ::rtl::OUString::createFromAscii(".uno:StyleApply?Style:string=");
100 static ::rtl::OUString CMDURL_FPART2 = ::rtl::OUString::createFromAscii("&FamilyName:string=");
102 static ::rtl::OUString CMDURL_STYLEPROT_ONLY = ::rtl::OUString::createFromAscii(".uno:StyleApply?");
103 static ::rtl::OUString CMDURL_SPART_ONLY = ::rtl::OUString::createFromAscii("Style:string=");
104 static ::rtl::OUString CMDURL_FPART_ONLY = ::rtl::OUString::createFromAscii("FamilyName:string=");
106 static ::rtl::OUString STYLEPROP_UINAME = ::rtl::OUString::createFromAscii("DisplayName");
108 ::rtl::OUString SfxStylesInfo_Impl::generateCommand(const ::rtl::OUString& sFamily, const ::rtl::OUString& sStyle)
110 ::rtl::OUStringBuffer sCommand(1024);
111 sCommand.append(CMDURL_SPART );
112 sCommand.append(sStyle );
113 sCommand.append(CMDURL_FPART2);
114 sCommand.append(sFamily );
115 return sCommand.makeStringAndClear();
118 sal_Bool SfxStylesInfo_Impl::parseStyleCommand(SfxStyleInfo_Impl& aStyle)
120 static sal_Int32 LEN_STYLEPROT = CMDURL_STYLEPROT_ONLY.getLength();
121 static sal_Int32 LEN_SPART = CMDURL_SPART_ONLY.getLength();
122 static sal_Int32 LEN_FPART = CMDURL_FPART_ONLY.getLength();
124 if (aStyle.sCommand.indexOf(CMDURL_STYLEPROT_ONLY, 0) != 0)
125 return sal_False;
127 aStyle.sFamily = ::rtl::OUString();
128 aStyle.sStyle = ::rtl::OUString();
130 sal_Int32 nCmdLen = aStyle.sCommand.getLength();
131 ::rtl::OUString sCmdArgs = aStyle.sCommand.copy(LEN_STYLEPROT, nCmdLen-LEN_STYLEPROT);
132 sal_Int32 i = sCmdArgs.indexOf('&');
133 if (i<0)
134 return sal_False;
136 ::rtl::OUString sArg = sCmdArgs.copy(0, i);
137 if (sArg.indexOf(CMDURL_SPART_ONLY) == 0)
138 aStyle.sStyle = sArg.copy(LEN_SPART, sArg.getLength()-LEN_SPART);
139 else
140 if (sArg.indexOf(CMDURL_FPART_ONLY) == 0)
141 aStyle.sFamily = sArg.copy(LEN_FPART, sArg.getLength()-LEN_FPART);
143 sArg = sCmdArgs.copy(i+1, sCmdArgs.getLength()-i-1);
144 if (sArg.indexOf(CMDURL_SPART_ONLY) == 0)
145 aStyle.sStyle = sArg.copy(LEN_SPART, sArg.getLength()-LEN_SPART);
146 else
147 if (sArg.indexOf(CMDURL_FPART_ONLY) == 0)
148 aStyle.sFamily = sArg.copy(LEN_FPART, sArg.getLength()-LEN_FPART);
150 if (aStyle.sFamily.getLength() && aStyle.sStyle.getLength())
151 return sal_True;
153 return sal_False;
156 void SfxStylesInfo_Impl::getLabel4Style(SfxStyleInfo_Impl& aStyle)
160 css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY);
162 css::uno::Reference< css::container::XNameAccess > xFamilies;
163 if (xModel.is())
164 xFamilies = xModel->getStyleFamilies();
166 css::uno::Reference< css::container::XNameAccess > xStyleSet;
167 if (xFamilies.is())
168 xFamilies->getByName(aStyle.sFamily) >>= xStyleSet;
170 css::uno::Reference< css::beans::XPropertySet > xStyle;
171 if (xStyleSet.is())
172 xStyleSet->getByName(aStyle.sStyle) >>= xStyle;
174 aStyle.sLabel = ::rtl::OUString();
175 if (xStyle.is())
176 xStyle->getPropertyValue(STYLEPROP_UINAME) >>= aStyle.sLabel;
178 catch(const css::uno::RuntimeException& exRun)
179 { throw exRun; }
180 catch(const css::uno::Exception&)
181 { aStyle.sLabel = ::rtl::OUString(); }
183 if (!aStyle.sLabel.getLength())
185 aStyle.sLabel = aStyle.sCommand;
187 #if OSL_DEBUG_LEVEL > 1
188 ::rtl::OUStringBuffer sMsg(256);
189 sMsg.appendAscii("There is no UIName for the style command \"");
190 sMsg.append (aStyle.sCommand );
191 sMsg.appendAscii("\". The UI will be invalid then ..." );
192 OSL_ENSURE(sal_False, ::rtl::OUStringToOString(sMsg.makeStringAndClear(), RTL_TEXTENCODING_UTF8).getStr());
193 #endif
198 ::std::vector< SfxStyleInfo_Impl > SfxStylesInfo_Impl::getStyleFamilies()
200 // Its an optional interface!
201 css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY);
202 if (!xModel.is())
203 return ::std::vector< SfxStyleInfo_Impl >();
205 css::uno::Reference< css::container::XNameAccess > xCont = xModel->getStyleFamilies();
206 css::uno::Sequence< ::rtl::OUString > lFamilyNames = xCont->getElementNames();
207 ::std::vector< SfxStyleInfo_Impl > lFamilies;
208 sal_Int32 c = lFamilyNames.getLength();
209 sal_Int32 i = 0;
210 for(i=0; i<c; ++i)
212 SfxStyleInfo_Impl aFamilyInfo;
213 aFamilyInfo.sFamily = lFamilyNames[i];
217 css::uno::Reference< css::beans::XPropertySet > xFamilyInfo;
218 xCont->getByName(aFamilyInfo.sFamily) >>= xFamilyInfo;
219 if (!xFamilyInfo.is())
221 // TODO_AS currently there is no support for an UIName property .. use internal family name instead
222 aFamilyInfo.sLabel = aFamilyInfo.sFamily;
224 else
225 xFamilyInfo->getPropertyValue(STYLEPROP_UINAME) >>= aFamilyInfo.sLabel;
227 catch(const css::uno::RuntimeException& exRun)
228 { throw exRun; }
229 catch(const css::uno::Exception&)
230 { return ::std::vector< SfxStyleInfo_Impl >(); }
232 lFamilies.push_back(aFamilyInfo);
235 return lFamilies;
238 ::std::vector< SfxStyleInfo_Impl > SfxStylesInfo_Impl::getStyles(const ::rtl::OUString& sFamily)
240 static ::rtl::OUString PROP_UINAME = ::rtl::OUString::createFromAscii("DisplayName");
242 css::uno::Sequence< ::rtl::OUString > lStyleNames;
243 css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY_THROW);
244 css::uno::Reference< css::container::XNameAccess > xFamilies = xModel->getStyleFamilies();
245 css::uno::Reference< css::container::XNameAccess > xStyleSet;
248 xFamilies->getByName(sFamily) >>= xStyleSet;
249 lStyleNames = xStyleSet->getElementNames();
251 catch(const css::uno::RuntimeException& exRun)
252 { throw exRun; }
253 catch(const css::uno::Exception&)
254 { return ::std::vector< SfxStyleInfo_Impl >(); }
256 ::std::vector< SfxStyleInfo_Impl > lStyles;
257 sal_Int32 c = lStyleNames.getLength();
258 sal_Int32 i = 0;
259 for (i=0; i<c; ++i)
261 SfxStyleInfo_Impl aStyleInfo;
262 aStyleInfo.sFamily = sFamily;
263 aStyleInfo.sStyle = lStyleNames[i];
264 aStyleInfo.sCommand = SfxStylesInfo_Impl::generateCommand(aStyleInfo.sFamily, aStyleInfo.sStyle);
268 css::uno::Reference< css::beans::XPropertySet > xStyle;
269 xStyleSet->getByName(aStyleInfo.sStyle) >>= xStyle;
270 if (!xStyle.is())
271 continue;
272 xStyle->getPropertyValue(PROP_UINAME) >>= aStyleInfo.sLabel;
274 catch(const css::uno::RuntimeException& exRun)
275 { throw exRun; }
276 catch(const css::uno::Exception&)
277 { continue; }
279 lStyles.push_back(aStyleInfo);
281 return lStyles;
283 SV_IMPL_PTRARR(SfxGroupInfoArr_Impl, SfxGroupInfoPtr);
284 SfxConfigFunctionListBox_Impl::SfxConfigFunctionListBox_Impl( Window* pParent, const ResId& rResId)
285 : SvTreeListBox( pParent, rResId )
286 , pCurEntry( 0 )
287 , pStylesInfo( 0 )
289 SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT );
290 GetModel()->SetSortMode( SortAscending );
292 // Timer f"ur die BallonHelp
293 aTimer.SetTimeout( 200 );
294 aTimer.SetTimeoutHdl(
295 LINK( this, SfxConfigFunctionListBox_Impl, TimerHdl ) );
298 SfxConfigFunctionListBox_Impl::~SfxConfigFunctionListBox_Impl()
300 ClearAll();
303 void SfxConfigFunctionListBox_Impl::MouseMove( const MouseEvent& )
305 /* --> PB 2004-12-01 #i37000# - no own help text needed any longer
306 Point aMousePos = rMEvt.GetPosPixel();
307 pCurEntry = GetCurEntry();
309 if ( pCurEntry && GetEntry( aMousePos ) == pCurEntry )
310 aTimer.Start();
311 else
313 Help::ShowBalloon( this, aMousePos, String() );
314 aTimer.Stop();
320 IMPL_LINK( SfxConfigFunctionListBox_Impl, TimerHdl, Timer*, pTimer)
321 /* Beschreibung
322 Timer-Handler f"ur die Einblendung eines Hilfetextes. Wenn nach Ablauf des Timers
323 der Mauszeiger immer noch auf dem aktuell selektierten Eintrag steht, wird der
324 Helptext des Entries als Balloon-Help eingeblendet.
327 (void)pTimer; // unused
328 /* --> PB 2004-12-01 #i37000# - no own help text needed any longer
329 aTimer.Stop();
330 Point aMousePos = GetPointerPosPixel();
331 SvLBoxEntry *pEntry = GetCurEntry();
332 if ( pEntry && GetEntry( aMousePos ) == pEntry && pCurEntry == pEntry )
334 String sHelpText = GetHelpText( pEntry );
335 Help::ShowBalloon( this, OutputToScreenPixel( aMousePos ), sHelpText );
338 return 0L;
341 void SfxConfigFunctionListBox_Impl::ClearAll()
342 /* Beschreibung
343 L"oscht alle Eintr"age in der FunctionListBox, alle UserDaten und alle evtl.
344 vorhandenen MacroInfos.
347 sal_uInt16 nCount = aArr.Count();
348 for ( sal_uInt16 i=0; i<nCount; i++ )
350 SfxGroupInfo_Impl *pData = aArr[i];
352 if ( pData->nKind == SFX_CFGFUNCTION_SCRIPT )
354 String* pScriptURI = (String*)pData->pObject;
355 delete pScriptURI;
358 if ( pData->nKind == SFX_CFGGROUP_SCRIPTCONTAINER
361 XInterface* xi = static_cast<XInterface *>(pData->pObject);
362 if (xi != NULL)
364 xi->release();
368 delete pData;
371 aArr.Remove( 0, nCount );
372 Clear();
375 String SfxConfigFunctionListBox_Impl::GetSelectedScriptURI()
377 SvLBoxEntry *pEntry = FirstSelected();
378 if ( pEntry )
380 SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData();
381 if ( pData && ( pData->nKind == SFX_CFGFUNCTION_SCRIPT ) )
382 return *(String*)pData->pObject;
384 return String();
387 String SfxConfigFunctionListBox_Impl::GetCurCommand()
389 SvLBoxEntry *pEntry = FirstSelected();
390 if (!pEntry)
391 return String();
392 SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData();
393 if (!pData)
394 return String();
395 return pData->sCommand;
398 String SfxConfigFunctionListBox_Impl::GetCurLabel()
400 SvLBoxEntry *pEntry = FirstSelected();
401 if (!pEntry)
402 return String();
403 SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData();
404 if (!pData)
405 return String();
406 if (pData->sLabel.Len())
407 return pData->sLabel;
408 return pData->sCommand;
411 void SfxConfigFunctionListBox_Impl::FunctionSelected()
412 /* Beschreibung
413 Setzt die Balloonhelp zur"uck, da diese immer den Helptext des selektierten
414 Entry anzeigen soll.
417 /* --> PB 2004-12-01 #i37000# - no own help text needed any longer
418 Help::ShowBalloon( this, Point(), String() );
422 void SfxConfigFunctionListBox_Impl::SetStylesInfo(SfxStylesInfo_Impl* pStyles)
424 pStylesInfo = pStyles;
427 struct SvxConfigGroupBoxResource_Impl : public Resource
429 Image m_hdImage;
430 Image m_hdImage_hc;
431 Image m_libImage;
432 Image m_libImage_hc;
433 Image m_macImage;
434 Image m_macImage_hc;
435 Image m_docImage;
436 Image m_docImage_hc;
437 ::rtl::OUString m_sMyMacros;
438 ::rtl::OUString m_sProdMacros;
439 String m_sMacros;
440 String m_sDlgMacros;
441 String m_aHumanAppName;
442 String m_aStrGroupStyles;
443 Image m_collapsedImage;
444 Image m_collapsedImage_hc;
445 Image m_expandedImage;
446 Image m_expandedImage_hc;
448 SvxConfigGroupBoxResource_Impl();
451 SvxConfigGroupBoxResource_Impl::SvxConfigGroupBoxResource_Impl() :
452 Resource(CUI_RES(RID_SVXPAGE_CONFIGGROUPBOX)),
453 m_hdImage(CUI_RES(IMG_HARDDISK)),
454 m_hdImage_hc(CUI_RES(IMG_HARDDISK_HC)),
455 m_libImage(CUI_RES(IMG_LIB)),
456 m_libImage_hc(CUI_RES(IMG_LIB_HC)),
457 m_macImage(CUI_RES(IMG_MACRO)),
458 m_macImage_hc(CUI_RES(IMG_MACRO_HC)),
459 m_docImage(CUI_RES(IMG_DOC)),
460 m_docImage_hc(CUI_RES(IMG_DOC_HC)),
461 m_sMyMacros(String(CUI_RES(STR_MYMACROS))),
462 m_sProdMacros(String(CUI_RES(STR_PRODMACROS))),
463 m_sMacros(String(CUI_RES(STR_BASICMACROS))),
464 m_sDlgMacros(String(CUI_RES(STR_DLG_MACROS))),
465 m_aHumanAppName(String(CUI_RES(STR_HUMAN_APPNAME))),
466 m_aStrGroupStyles(String(CUI_RES(STR_GROUP_STYLES))),
467 m_collapsedImage(CUI_RES(BMP_COLLAPSED)),
468 m_collapsedImage_hc(CUI_RES(BMP_COLLAPSED_HC)),
469 m_expandedImage(CUI_RES(BMP_EXPANDED)),
470 m_expandedImage_hc(CUI_RES(BMP_EXPANDED_HC))
472 FreeResource();
475 SfxConfigGroupListBox_Impl::SfxConfigGroupListBox_Impl(
476 Window* pParent, const ResId& rResId, sal_uLong nConfigMode )
477 : SvTreeListBox( pParent, rResId )
478 , pImp(new SvxConfigGroupBoxResource_Impl()), pFunctionListBox(0), nMode( nConfigMode ), pStylesInfo(0)
480 SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_HASBUTTONS | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONSATROOT );
481 SetNodeBitmaps( pImp->m_collapsedImage, pImp->m_expandedImage, BMP_COLOR_NORMAL );
482 SetNodeBitmaps( pImp->m_collapsedImage_hc, pImp->m_expandedImage_hc, BMP_COLOR_HIGHCONTRAST );
486 SfxConfigGroupListBox_Impl::~SfxConfigGroupListBox_Impl()
488 ClearAll();
491 void SfxConfigGroupListBox_Impl::ClearAll()
493 sal_uInt16 nCount = aArr.Count();
494 for ( sal_uInt16 i=0; i<nCount; i++ )
496 SfxGroupInfo_Impl *pData = aArr[i];
497 if ( pData->nKind == SFX_CFGGROUP_SCRIPTCONTAINER
500 XInterface* xi = static_cast<XInterface *>(pData->pObject);
501 if (xi != NULL)
503 xi->release();
506 delete pData;
509 aArr.Remove( 0, nCount );
510 Clear();
513 void SfxConfigGroupListBox_Impl::SetStylesInfo(SfxStylesInfo_Impl* pStyles)
515 pStylesInfo = pStyles;
518 String SfxConfigGroupListBox_Impl::GetGroup()
519 /* Beschreibung
520 Gibt den Namen der selektierten Funktionsgruppe bzw. des selektierten
521 Basics zur"uck.
524 SvLBoxEntry *pEntry = FirstSelected();
525 while ( pEntry )
527 SfxGroupInfo_Impl *pInfo = (SfxGroupInfo_Impl*) pEntry->GetUserData();
528 if ( pInfo->nKind == SFX_CFGGROUP_FUNCTION )
529 return GetEntryText( pEntry );
531 pEntry = GetParent( pEntry );
534 return String();
537 //-----------------------------------------------
538 void SfxConfigGroupListBox_Impl::InitModule()
542 css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider(m_xFrame, css::uno::UNO_QUERY_THROW);
543 css::uno::Sequence< sal_Int16 > lGroups = xProvider->getSupportedCommandGroups();
544 sal_Int32 c1 = lGroups.getLength();
545 sal_Int32 i1 = 0;
547 for (i1=0; i1<c1; ++i1)
549 sal_Int16& rGroupID = lGroups[i1];
550 ::rtl::OUString sGroupID = ::rtl::OUString::valueOf((sal_Int32)rGroupID);
551 ::rtl::OUString sGroupName ;
555 m_xModuleCategoryInfo->getByName(sGroupID) >>= sGroupName;
556 if (!sGroupName.getLength())
557 continue;
559 catch(const css::container::NoSuchElementException&)
560 { continue; }
562 SvLBoxEntry* pEntry = InsertEntry(sGroupName, NULL);
563 SfxGroupInfo_Impl* pInfo = new SfxGroupInfo_Impl(SFX_CFGGROUP_FUNCTION, rGroupID);
564 pEntry->SetUserData(pInfo);
567 catch(const css::uno::RuntimeException& exRun)
568 { throw exRun; }
569 catch(const css::uno::Exception&)
573 //-----------------------------------------------
574 void SfxConfigGroupListBox_Impl::InitBasic()
578 //-----------------------------------------------
579 void SfxConfigGroupListBox_Impl::InitStyles()
583 //-----------------------------------------------
584 namespace
586 //...........................................
587 /** examines a component whether it supports XEmbeddedScripts, or provides access to such a
588 component by implementing XScriptInvocationContext.
589 @return
590 the model which supports the embedded scripts, or <NULL/> if it cannot find such a
591 model
593 static Reference< XModel > lcl_getDocumentWithScripts_throw( const Reference< XInterface >& _rxComponent )
595 Reference< XEmbeddedScripts > xScripts( _rxComponent, UNO_QUERY );
596 if ( !xScripts.is() )
598 Reference< XScriptInvocationContext > xContext( _rxComponent, UNO_QUERY );
599 if ( xContext.is() )
600 xScripts.set( xContext->getScriptContainer(), UNO_QUERY );
603 return Reference< XModel >( xScripts, UNO_QUERY );
606 //...........................................
607 static Reference< XModel > lcl_getScriptableDocument_nothrow( const Reference< XFrame >& _rxFrame )
609 Reference< XModel > xDocument;
611 // examine our associated frame
614 OSL_ENSURE( _rxFrame.is(), "lcl_getScriptableDocument_nothrow: you need to pass a frame to this dialog/tab page!" );
615 if ( _rxFrame.is() )
617 // first try the model in the frame
618 Reference< XController > xController( _rxFrame->getController(), UNO_SET_THROW );
619 xDocument = lcl_getDocumentWithScripts_throw( xController->getModel() );
621 if ( !xDocument.is() )
623 // if there is no suitable document in the frame, try the controller
624 xDocument = lcl_getDocumentWithScripts_throw( _rxFrame->getController() );
628 catch( const Exception& )
630 //DBG_UNHANDLED_EXCEPTION();
633 return xDocument;
637 //-----------------------------------------------
638 void SfxConfigGroupListBox_Impl::Init(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
639 const css::uno::Reference< css::frame::XFrame >& xFrame ,
640 const ::rtl::OUString& sModuleLongName)
642 SetUpdateMode(sal_False);
643 ClearAll(); // Remove all old entries from treelist box
645 m_xFrame = xFrame;
646 if ( xSMGR.is())
648 m_xSMGR = xSMGR;
649 m_sModuleLongName = sModuleLongName;
651 m_xGlobalCategoryInfo = css::uno::Reference< css::container::XNameAccess >(m_xSMGR->createInstance(SERVICE_UICATEGORYDESCRIPTION), css::uno::UNO_QUERY_THROW);
652 m_xModuleCategoryInfo = css::uno::Reference< css::container::XNameAccess >(m_xGlobalCategoryInfo->getByName(m_sModuleLongName) , css::uno::UNO_QUERY_THROW);
653 m_xUICmdDescription = css::uno::Reference< css::container::XNameAccess >(m_xSMGR->createInstance(SERVICE_UICMDDESCRIPTION) , css::uno::UNO_QUERY_THROW);
655 InitModule();
656 InitBasic();
657 InitStyles();
660 OSL_TRACE("** ** About to initialise SF Scripts");
661 // Add Scripting Framework entries
662 Reference< browse::XBrowseNode > rootNode;
663 Reference< XComponentContext > xCtx;
666 Reference < beans::XPropertySet > xProps(
667 ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
668 xCtx.set( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY_THROW );
669 Reference< browse::XBrowseNodeFactory > xFac( xCtx->getValueByName(
670 ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.script.browse.theBrowseNodeFactory") ), UNO_QUERY_THROW );
671 rootNode.set( xFac->createView( browse::BrowseNodeFactoryViewTypes::MACROSELECTOR ) );
672 //rootNode.set( xFac->createView( browse::BrowseNodeFactoryViewTypes::MACROORGANIZER ) );
674 catch( Exception& e )
676 OSL_TRACE(" Caught some exception whilst retrieving browse nodes from factory... Exception: %s",
677 ::rtl::OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).pData->buffer );
678 // TODO exception handling
682 if ( rootNode.is() )
684 if ( nMode )
686 //We call acquire on the XBrowseNode so that it does not
687 //get autodestructed and become invalid when accessed later.
688 rootNode->acquire();
690 SfxGroupInfo_Impl *pInfo =
691 new SfxGroupInfo_Impl( SFX_CFGGROUP_SCRIPTCONTAINER, 0,
692 static_cast<void *>(rootNode.get()));
694 String aTitle(pImp->m_sDlgMacros);
695 SvLBoxEntry *pNewEntry = InsertEntry( aTitle, NULL );
696 pNewEntry->SetUserData( pInfo );
697 pNewEntry->EnableChildsOnDemand( sal_True );
698 aArr.Insert( pInfo, aArr.Count() );
700 else
702 //We are only showing scripts not slot APIs so skip
703 //Root node and show location nodes
704 try {
705 if ( rootNode->hasChildNodes() )
707 Sequence< Reference< browse::XBrowseNode > > children =
708 rootNode->getChildNodes();
709 sal_Bool bIsRootNode = sal_False;
711 ::rtl::OUString user = ::rtl::OUString::createFromAscii("user");
712 ::rtl::OUString share = ::rtl::OUString::createFromAscii("share");
713 if ( rootNode->getName().equals(::rtl::OUString::createFromAscii("Root") ))
715 bIsRootNode = sal_True;
718 //To mimic current starbasic behaviour we
719 //need to make sure that only the current document
720 //is displayed in the config tree. Tests below
721 //set the bDisplay flag to FALSE if the current
722 //node is a first level child of the Root and is NOT
723 //either the current document, user or share
724 ::rtl::OUString currentDocTitle;
725 Reference< XModel > xDocument( lcl_getScriptableDocument_nothrow( m_xFrame ) );
726 if ( xDocument.is() )
728 currentDocTitle = ::comphelper::DocumentInfo::getDocumentTitle( xDocument );
731 for ( sal_Int32 n = 0; n < children.getLength(); n++ )
733 Reference< browse::XBrowseNode >& theChild = children[n];
734 sal_Bool bDisplay = sal_True;
735 ::rtl::OUString uiName = theChild->getName();
736 if ( bIsRootNode )
738 if ( ! ((theChild->getName().equals( user ) || theChild->getName().equals( share ) ||
739 theChild->getName().equals( currentDocTitle ) ) ) )
741 bDisplay=sal_False;
743 else
745 if ( uiName.equals( user ) )
747 uiName = pImp->m_sMyMacros;
749 else if ( uiName.equals( share ) )
751 uiName = pImp->m_sProdMacros;
755 if (children[n]->getType() != browse::BrowseNodeTypes::SCRIPT && bDisplay )
758 // We call acquire on the XBrowseNode so that it does not
759 // get autodestructed and become invalid when accessed later.
760 theChild->acquire();
762 SfxGroupInfo_Impl* pInfo =
763 new SfxGroupInfo_Impl(SFX_CFGGROUP_SCRIPTCONTAINER,
764 0, static_cast<void *>( theChild.get()));
766 Image aImage = GetImage( theChild, xCtx, bIsRootNode,BMP_COLOR_NORMAL );
767 SvLBoxEntry* pNewEntry =
768 InsertEntry( uiName, NULL);
769 SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
770 SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
771 aImage = GetImage( theChild, xCtx, bIsRootNode,BMP_COLOR_HIGHCONTRAST );
772 SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
773 SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
775 pNewEntry->SetUserData( pInfo );
776 aArr.Insert( pInfo, aArr.Count() );
778 if ( children[n]->hasChildNodes() )
780 Sequence< Reference< browse::XBrowseNode > > grandchildren =
781 children[n]->getChildNodes();
783 for ( sal_Int32 m = 0; m < grandchildren.getLength(); m++ )
785 if ( grandchildren[m]->getType() == browse::BrowseNodeTypes::CONTAINER )
787 pNewEntry->EnableChildsOnDemand( sal_True );
788 m = grandchildren.getLength();
796 catch (RuntimeException&) {
797 // do nothing, the entry will not be displayed in the UI
802 // add styles
803 if ( m_xSMGR.is() )
805 String sStyle( pImp->m_aStrGroupStyles );
806 SvLBoxEntry *pEntry = InsertEntry( sStyle, 0 );
807 SfxGroupInfo_Impl *pInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_STYLES, 0, 0 ); // TODO last parameter should contain user data
808 aArr.Insert( pInfo, aArr.Count() );
809 pEntry->SetUserData( pInfo );
810 pEntry->EnableChildsOnDemand( sal_True );
813 MakeVisible( GetEntry( 0,0 ) );
814 SetUpdateMode( sal_True );
816 Image SfxConfigGroupListBox_Impl::GetImage( Reference< browse::XBrowseNode > node, Reference< XComponentContext > xCtx, bool bIsRootNode, bool bHighContrast )
818 Image aImage;
819 if ( bIsRootNode )
821 ::rtl::OUString user = ::rtl::OUString::createFromAscii("user");
822 ::rtl::OUString share = ::rtl::OUString::createFromAscii("share");
823 if (node->getName().equals( user ) || node->getName().equals(share ) )
825 if( bHighContrast == BMP_COLOR_NORMAL )
826 aImage = pImp->m_hdImage;
827 else
828 aImage = pImp->m_hdImage_hc;
830 else
832 ::rtl::OUString factoryURL;
833 ::rtl::OUString nodeName = node->getName();
834 Reference<XInterface> xDocumentModel = getDocumentModel(xCtx, nodeName );
835 if ( xDocumentModel.is() )
837 Reference< ::com::sun::star::frame::XModuleManager >
838 xModuleManager(
839 xCtx->getServiceManager()
840 ->createInstanceWithContext(
841 ::rtl::OUString::createFromAscii("" // xxx todo
842 "com.sun.star.frame.ModuleManager"),
843 xCtx ),
844 UNO_QUERY_THROW );
845 Reference<container::XNameAccess> xModuleConfig(
846 xModuleManager, UNO_QUERY_THROW );
847 // get the long name of the document:
848 ::rtl::OUString appModule( xModuleManager->identify(
849 xDocumentModel ) );
850 Sequence<beans::PropertyValue> moduleDescr;
851 Any aAny = xModuleConfig->getByName(appModule);
852 if( sal_True != ( aAny >>= moduleDescr ) )
854 throw RuntimeException(::rtl::OUString::createFromAscii("SFTreeListBox::Init: failed to get PropertyValue"), Reference< XInterface >());
856 beans::PropertyValue const * pmoduleDescr =
857 moduleDescr.getConstArray();
858 for ( sal_Int32 pos = moduleDescr.getLength(); pos--; )
860 if (pmoduleDescr[ pos ].Name.equalsAsciiL(
861 RTL_CONSTASCII_STRINGPARAM(
862 "ooSetupFactoryEmptyDocumentURL") ))
864 pmoduleDescr[ pos ].Value >>= factoryURL;
865 OSL_TRACE("factory url for doc images is %s",
866 ::rtl::OUStringToOString( factoryURL , RTL_TEXTENCODING_ASCII_US ).pData->buffer );
867 break;
871 if( factoryURL.getLength() > 0 )
873 if( bHighContrast == BMP_COLOR_NORMAL )
874 aImage = SvFileInformationManager::GetFileImage(
875 INetURLObject(factoryURL), false,
876 BMP_COLOR_NORMAL );
877 else
878 aImage = SvFileInformationManager::GetFileImage(
879 INetURLObject(factoryURL), false,
880 BMP_COLOR_HIGHCONTRAST );
882 else
884 if( bHighContrast == BMP_COLOR_NORMAL )
885 aImage = pImp->m_docImage;
886 else
887 aImage = pImp->m_docImage_hc;
891 else
893 if( node->getType() == browse::BrowseNodeTypes::SCRIPT )
895 if( bHighContrast == BMP_COLOR_NORMAL )
896 aImage = pImp->m_macImage;
897 else
898 aImage = pImp->m_macImage_hc;
900 else
902 if( bHighContrast == BMP_COLOR_NORMAL )
903 aImage = pImp->m_libImage;
904 else
905 aImage = pImp->m_libImage_hc;
908 return aImage;
911 Reference< XInterface >
912 SfxConfigGroupListBox_Impl::getDocumentModel( Reference< XComponentContext >& xCtx, ::rtl::OUString& docName )
914 Reference< XInterface > xModel;
915 Reference< lang::XMultiComponentFactory > mcf =
916 xCtx->getServiceManager();
917 Reference< frame::XDesktop > desktop (
918 mcf->createInstanceWithContext(
919 ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop"), xCtx ),
920 UNO_QUERY );
922 Reference< container::XEnumerationAccess > componentsAccess =
923 desktop->getComponents();
924 Reference< container::XEnumeration > components =
925 componentsAccess->createEnumeration();
926 while (components->hasMoreElements())
928 Reference< frame::XModel > model(
929 components->nextElement(), UNO_QUERY );
930 if ( model.is() )
932 ::rtl::OUString sTdocUrl =
933 ::comphelper::DocumentInfo::getDocumentTitle( model );
934 if( sTdocUrl.equals( docName ) )
936 xModel = model;
937 break;
941 return xModel;
944 //-----------------------------------------------
945 ::rtl::OUString SfxConfigGroupListBox_Impl::MapCommand2UIName(const ::rtl::OUString& sCommand)
947 ::rtl::OUString sUIName;
950 css::uno::Reference< css::container::XNameAccess > xModuleConf;
951 m_xUICmdDescription->getByName(m_sModuleLongName) >>= xModuleConf;
952 if (xModuleConf.is())
954 ::comphelper::SequenceAsHashMap lProps(xModuleConf->getByName(sCommand));
955 sUIName = lProps.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("Name"), ::rtl::OUString());
958 catch(const css::uno::RuntimeException& exRun)
959 { throw exRun; }
960 catch(css::uno::Exception&)
961 { sUIName = ::rtl::OUString(); }
963 // fallback for missing UINames !?
964 if (!sUIName.getLength())
966 sUIName = sCommand;
968 #if OSL_DEBUG_LEVEL > 1
969 ::rtl::OUStringBuffer sMsg(256);
970 sMsg.appendAscii("There is no UIName for the internal command \"");
971 sMsg.append (sCommand );
972 sMsg.appendAscii("\". The UI will be invalid then ..." );
973 OSL_ENSURE(sal_False, ::rtl::OUStringToOString(sMsg.makeStringAndClear(), RTL_TEXTENCODING_UTF8).getStr());
974 #endif
978 return sUIName;
981 //-----------------------------------------------
982 void SfxConfigGroupListBox_Impl::GroupSelected()
983 /* Beschreibung
984 Eine Funktionsgruppe oder eine Basicmodul wurde selektiert. Alle Funktionen bzw.
985 Macros werden in der Functionlistbox anzeigt.
988 SvLBoxEntry *pEntry = FirstSelected();
989 SfxGroupInfo_Impl *pInfo = (SfxGroupInfo_Impl*) pEntry->GetUserData();
990 pFunctionListBox->SetUpdateMode(sal_False);
991 pFunctionListBox->ClearAll();
992 if ( pInfo->nKind != SFX_CFGGROUP_FUNCTION &&
993 pInfo->nKind != SFX_CFGGROUP_SCRIPTCONTAINER &&
994 pInfo->nKind != SFX_CFGGROUP_STYLES )
996 pFunctionListBox->SetUpdateMode(sal_True);
997 return;
1000 switch ( pInfo->nKind )
1002 case SFX_CFGGROUP_FUNCTION :
1004 sal_uInt16 nGroup = pInfo->nUniqueID;
1005 css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider (m_xFrame, css::uno::UNO_QUERY_THROW);
1006 css::uno::Sequence< css::frame::DispatchInformation > lCommands = xProvider->getConfigurableDispatchInformation(nGroup);
1007 sal_Int32 c = lCommands.getLength();
1008 sal_Int32 i = 0;
1010 for (i=0; i<c; ++i)
1012 const css::frame::DispatchInformation& rInfo = lCommands[i];
1013 ::rtl::OUString sUIName = MapCommand2UIName(rInfo.Command);
1014 SvLBoxEntry* pFuncEntry = pFunctionListBox->InsertEntry(sUIName, NULL);
1015 SfxGroupInfo_Impl* pGrpInfo = new SfxGroupInfo_Impl(SFX_CFGFUNCTION_SLOT, 0);
1016 pGrpInfo->sCommand = rInfo.Command;
1017 pGrpInfo->sLabel = sUIName;
1018 pFuncEntry->SetUserData(pGrpInfo);
1021 break;
1024 case SFX_CFGGROUP_SCRIPTCONTAINER:
1026 if ( !GetChildCount( pEntry ) )
1028 Reference< browse::XBrowseNode > rootNode(
1029 reinterpret_cast< browse::XBrowseNode* >( pInfo->pObject ) ) ;
1031 try {
1032 if ( rootNode->hasChildNodes() )
1034 Sequence< Reference< browse::XBrowseNode > > children =
1035 rootNode->getChildNodes();
1037 for ( sal_Int32 n = 0; n < children.getLength(); n++ )
1039 if (children[n]->getType() == browse::BrowseNodeTypes::SCRIPT)
1041 ::rtl::OUString uri;
1043 Reference < beans::XPropertySet >xPropSet( children[n], UNO_QUERY );
1044 if (!xPropSet.is())
1046 continue;
1049 Any value =
1050 xPropSet->getPropertyValue( String::CreateFromAscii( "URI" ) );
1051 value >>= uri;
1053 String* pScriptURI = new String( uri );
1054 SfxGroupInfo_Impl* pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGFUNCTION_SCRIPT, 0, pScriptURI );
1056 Image aImage = GetImage( children[n], Reference< XComponentContext >(), sal_False, BMP_COLOR_NORMAL );
1057 SvLBoxEntry* pNewEntry =
1058 pFunctionListBox->InsertEntry( children[n]->getName(), NULL );
1059 pFunctionListBox->SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
1060 pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
1061 aImage = GetImage( children[n], Reference< XComponentContext >(), sal_False, BMP_COLOR_HIGHCONTRAST );
1062 pFunctionListBox->SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
1063 pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
1065 pGrpInfo->sCommand = uri;
1066 pGrpInfo->sLabel = children[n]->getName();
1067 pNewEntry->SetUserData( pGrpInfo );
1069 pFunctionListBox->aArr.Insert(
1070 pGrpInfo, pFunctionListBox->aArr.Count() );
1076 catch (RuntimeException&) {
1077 // do nothing, the entry will not be displayed in the UI
1080 break;
1083 case SFX_CFGGROUP_STYLES :
1085 SfxStyleInfo_Impl* pFamily = (SfxStyleInfo_Impl*)(pInfo->pObject);
1086 if (pFamily)
1088 const ::std::vector< SfxStyleInfo_Impl > lStyles = pStylesInfo->getStyles(pFamily->sFamily);
1089 ::std::vector< SfxStyleInfo_Impl >::const_iterator pIt;
1090 for ( pIt = lStyles.begin();
1091 pIt != lStyles.end() ;
1092 ++pIt )
1094 SfxStyleInfo_Impl* pStyle = new SfxStyleInfo_Impl(*pIt);
1095 SvLBoxEntry* pFuncEntry = pFunctionListBox->InsertEntry( pStyle->sLabel, NULL );
1096 SfxGroupInfo_Impl *pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_STYLES, 0, pStyle );
1097 pFunctionListBox->aArr.Insert( pGrpInfo, pFunctionListBox->aArr.Count() );
1098 pGrpInfo->sCommand = pStyle->sCommand;
1099 pGrpInfo->sLabel = pStyle->sLabel;
1100 pFuncEntry->SetUserData( pGrpInfo );
1103 break;
1106 default:
1107 return;
1110 if ( pFunctionListBox->GetEntryCount() )
1111 pFunctionListBox->Select( pFunctionListBox->GetEntry( 0, 0 ) );
1113 pFunctionListBox->SetUpdateMode(sal_True);
1116 sal_Bool SfxConfigGroupListBox_Impl::Expand( SvLBoxEntry* pParent )
1118 sal_Bool bRet = SvTreeListBox::Expand( pParent );
1119 if ( bRet )
1121 // Wieviele Entries k"onnen angezeigt werden ?
1122 sal_uLong nEntries = GetOutputSizePixel().Height() / GetEntryHeight();
1124 // Wieviele Kinder sollen angezeigt werden ?
1125 sal_uLong nChildCount = GetVisibleChildCount( pParent );
1127 // Passen alle Kinder und der parent gleichzeitig in die View ?
1128 if ( nChildCount+1 > nEntries )
1130 // Wenn nicht, wenigstens parent ganz nach oben schieben
1131 MakeVisible( pParent, sal_True );
1133 else
1135 // An welcher relativen ViewPosition steht der aufzuklappende parent
1136 SvLBoxEntry *pEntry = GetFirstEntryInView();
1137 sal_uLong nParentPos = 0;
1138 while ( pEntry && pEntry != pParent )
1140 nParentPos++;
1141 pEntry = GetNextEntryInView( pEntry );
1144 // Ist unter dem parent noch genug Platz f"ur alle Kinder ?
1145 if ( nParentPos + nChildCount + 1 > nEntries )
1146 ScrollOutputArea( (short)( nEntries - ( nParentPos + nChildCount + 1 ) ) );
1150 return bRet;
1153 void SfxConfigGroupListBox_Impl::RequestingChilds( SvLBoxEntry *pEntry )
1154 /* Beschreibung
1155 Ein Basic oder eine Bibliothek werden ge"offnet
1158 SfxGroupInfo_Impl *pInfo = (SfxGroupInfo_Impl*) pEntry->GetUserData();
1159 pInfo->bWasOpened = sal_True;
1160 switch ( pInfo->nKind )
1162 case SFX_CFGGROUP_SCRIPTCONTAINER:
1164 if ( !GetChildCount( pEntry ) )
1166 Reference< browse::XBrowseNode > rootNode(
1167 reinterpret_cast< browse::XBrowseNode* >( pInfo->pObject ) ) ;
1169 try {
1170 if ( rootNode->hasChildNodes() )
1172 Sequence< Reference< browse::XBrowseNode > > children =
1173 rootNode->getChildNodes();
1174 sal_Bool bIsRootNode = sal_False;
1176 ::rtl::OUString user = ::rtl::OUString::createFromAscii("user");
1177 ::rtl::OUString share = ::rtl::OUString::createFromAscii("share");
1178 if ( rootNode->getName().equals(::rtl::OUString::createFromAscii("Root") ))
1180 bIsRootNode = sal_True;
1183 /* To mimic current starbasic behaviour we
1184 need to make sure that only the current document
1185 is displayed in the config tree. Tests below
1186 set the bDisplay flag to sal_False if the current
1187 node is a first level child of the Root and is NOT
1188 either the current document, user or share */
1189 ::rtl::OUString currentDocTitle;
1190 Reference< XModel > xDocument( lcl_getScriptableDocument_nothrow( m_xFrame ) );
1191 if ( xDocument.is() )
1193 currentDocTitle = ::comphelper::DocumentInfo::getDocumentTitle( xDocument );
1196 sal_Int32 nLen = children.getLength();
1197 for ( sal_Int32 n = 0; n < nLen; n++ )
1199 Reference< browse::XBrowseNode >& theChild = children[n];
1200 ::rtl::OUString aName( theChild->getName() );
1201 sal_Bool bDisplay = sal_True;
1202 if ( bIsRootNode )
1204 if ( !( (aName.equals(user) || aName.equals(share) || aName.equals(currentDocTitle) ) ) )
1205 bDisplay=sal_False;
1207 if ( children[n].is() && children[n]->getType() != browse::BrowseNodeTypes::SCRIPT && bDisplay )
1211 We call acquire on the XBrowseNode so that it does not
1212 get autodestructed and become invalid when accessed later.
1214 theChild->acquire();
1216 SfxGroupInfo_Impl* pGrpInfo =
1217 new SfxGroupInfo_Impl(SFX_CFGGROUP_SCRIPTCONTAINER,
1218 0, static_cast<void *>( theChild.get()));
1220 Image aImage = GetImage( theChild, Reference< XComponentContext >(), sal_False, BMP_COLOR_NORMAL );
1221 SvLBoxEntry* pNewEntry =
1222 InsertEntry( theChild->getName(), pEntry );
1223 SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
1224 SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
1225 aImage = GetImage( theChild, Reference< XComponentContext >(), sal_False, BMP_COLOR_HIGHCONTRAST );
1226 SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
1227 SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
1229 pNewEntry->SetUserData( pGrpInfo );
1230 aArr.Insert( pGrpInfo, aArr.Count() );
1232 if ( children[n]->hasChildNodes() )
1234 Sequence< Reference< browse::XBrowseNode > > grandchildren =
1235 children[n]->getChildNodes();
1237 for ( sal_Int32 m = 0; m < grandchildren.getLength(); m++ )
1239 if ( grandchildren[m]->getType() == browse::BrowseNodeTypes::CONTAINER )
1241 pNewEntry->EnableChildsOnDemand( sal_True );
1242 m = grandchildren.getLength();
1250 catch (RuntimeException&) {
1251 // do nothing, the entry will not be displayed in the UI
1254 break;
1257 case SFX_CFGGROUP_STYLES:
1259 if ( !GetChildCount( pEntry ) )
1261 const ::std::vector< SfxStyleInfo_Impl > lStyleFamilies = pStylesInfo->getStyleFamilies();
1262 ::std::vector< SfxStyleInfo_Impl >::const_iterator pIt;
1263 for ( pIt = lStyleFamilies.begin();
1264 pIt != lStyleFamilies.end() ;
1265 ++pIt )
1267 SfxStyleInfo_Impl* pFamily = new SfxStyleInfo_Impl(*pIt);
1268 SvLBoxEntry* pStyleEntry = InsertEntry( pFamily->sLabel, pEntry );
1269 SfxGroupInfo_Impl *pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_STYLES, 0, pFamily );
1270 aArr.Insert( pGrpInfo, aArr.Count() );
1271 pStyleEntry->SetUserData( pGrpInfo );
1272 pStyleEntry->EnableChildsOnDemand( sal_False );
1275 break;
1278 default:
1279 DBG_ERROR( "Falscher Gruppentyp!" );
1280 break;
1284 void SfxConfigGroupListBox_Impl::SelectMacro( const SfxMacroInfoItem *pItem )
1286 SelectMacro( pItem->GetBasicManager()->GetName(),
1287 pItem->GetQualifiedName() );
1290 void SfxConfigGroupListBox_Impl::SelectMacro( const String& rBasic,
1291 const String& rMacro )
1293 String aBasicName( rBasic );
1294 aBasicName += ' ';
1295 aBasicName += pImp->m_sMacros;
1296 String aLib, aModule, aMethod;
1297 sal_uInt16 nCount = rMacro.GetTokenCount('.');
1298 aMethod = rMacro.GetToken( nCount-1, '.' );
1299 if ( nCount > 2 )
1301 aLib = rMacro.GetToken( 0, '.' );
1302 aModule = rMacro.GetToken( nCount-2, '.' );
1305 SvLBoxEntry *pEntry = FirstChild(0);
1306 while ( pEntry )
1308 String aEntryBas = GetEntryText( pEntry );
1309 if ( aEntryBas == aBasicName )
1311 Expand( pEntry );
1312 SvLBoxEntry *pLib = FirstChild( pEntry );
1313 while ( pLib )
1315 String aEntryLib = GetEntryText( pLib );
1316 if ( aEntryLib == aLib )
1318 Expand( pLib );
1319 SvLBoxEntry *pMod = FirstChild( pLib );
1320 while ( pMod )
1322 String aEntryMod = GetEntryText( pMod );
1323 if ( aEntryMod == aModule )
1325 Expand( pMod );
1326 MakeVisible( pMod );
1327 Select( pMod );
1328 SvLBoxEntry *pMethod = pFunctionListBox->First();
1329 while ( pMethod )
1331 String aEntryMethod = GetEntryText( pMethod );
1332 if ( aEntryMethod == aMethod )
1334 pFunctionListBox->Select( pMethod );
1335 pFunctionListBox->MakeVisible( pMethod );
1336 return;
1338 pMethod = pFunctionListBox->Next( pMethod );
1341 pMod = NextSibling( pMod );
1344 pLib = NextSibling( pLib );
1347 pEntry = NextSibling( pEntry );