Line data Source code
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/UICommandDescription.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/script/provider/XScriptProviderSupplier.hpp>
35 : #include <com/sun/star/script/provider/XScriptProvider.hpp>
36 : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
37 : #include <com/sun/star/uno/RuntimeException.hpp>
38 : #include <com/sun/star/ui/UICategoryDescription.hpp>
39 :
40 : #include "acccfg.hrc"
41 : #include "helpid.hrc"
42 : #include <basic/sbx.hxx>
43 : #include <basic/basicmanagerrepository.hxx>
44 : #include <basic/sbstar.hxx>
45 : #include <basic/sbxmeth.hxx>
46 : #include <basic/sbmod.hxx>
47 : #include <basic/basmgr.hxx>
48 : #include <tools/urlobj.hxx>
49 : #include "cuires.hrc"
50 : #include <sfx2/app.hxx>
51 : #include <sfx2/minfitem.hxx>
52 : #include <comphelper/documentinfo.hxx>
53 : #include <comphelper/processfactory.hxx>
54 : #include <comphelper/sequenceashashmap.hxx>
55 : #include <comphelper/string.hxx>
56 : #include <svtools/imagemgr.hxx>
57 : #include "svtools/treelistentry.hxx"
58 : #include <rtl/ustrbuf.hxx>
59 : #include <unotools/configmgr.hxx>
60 : #include "dialmgr.hxx"
61 : #include <svl/stritem.hxx>
62 :
63 : using namespace ::com::sun::star;
64 : using namespace ::com::sun::star::uno;
65 : using namespace ::com::sun::star::script;
66 : using namespace ::com::sun::star::frame;
67 : using namespace ::com::sun::star::document;
68 :
69 0 : SfxStylesInfo_Impl::SfxStylesInfo_Impl()
70 0 : {}
71 :
72 0 : void SfxStylesInfo_Impl::setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel)
73 : {
74 0 : m_xDoc = xModel;
75 0 : }
76 :
77 0 : static OUString CMDURL_SPART (".uno:StyleApply?Style:string=");
78 0 : static OUString CMDURL_FPART2 ("&FamilyName:string=");
79 :
80 0 : static OUString CMDURL_STYLEPROT_ONLY (".uno:StyleApply?");
81 0 : static OUString CMDURL_SPART_ONLY ("Style:string=");
82 0 : static OUString CMDURL_FPART_ONLY ("FamilyName:string=");
83 :
84 0 : static OUString STYLEPROP_UINAME ("DisplayName");
85 :
86 0 : OUString SfxStylesInfo_Impl::generateCommand(const OUString& sFamily, const OUString& sStyle)
87 : {
88 0 : OUStringBuffer sCommand(1024);
89 0 : sCommand.append(CMDURL_SPART );
90 0 : sCommand.append(sStyle );
91 0 : sCommand.append(CMDURL_FPART2);
92 0 : sCommand.append(sFamily );
93 0 : return sCommand.makeStringAndClear();
94 : }
95 :
96 0 : sal_Bool SfxStylesInfo_Impl::parseStyleCommand(SfxStyleInfo_Impl& aStyle)
97 : {
98 0 : static sal_Int32 LEN_STYLEPROT = CMDURL_STYLEPROT_ONLY.getLength();
99 0 : static sal_Int32 LEN_SPART = CMDURL_SPART_ONLY.getLength();
100 0 : static sal_Int32 LEN_FPART = CMDURL_FPART_ONLY.getLength();
101 :
102 0 : if (aStyle.sCommand.indexOf(CMDURL_STYLEPROT_ONLY, 0) != 0)
103 0 : return sal_False;
104 :
105 0 : aStyle.sFamily = OUString();
106 0 : aStyle.sStyle = OUString();
107 :
108 0 : sal_Int32 nCmdLen = aStyle.sCommand.getLength();
109 0 : OUString sCmdArgs = aStyle.sCommand.copy(LEN_STYLEPROT, nCmdLen-LEN_STYLEPROT);
110 0 : sal_Int32 i = sCmdArgs.indexOf('&');
111 0 : if (i<0)
112 0 : return sal_False;
113 :
114 0 : OUString sArg = sCmdArgs.copy(0, i);
115 0 : if (sArg.indexOf(CMDURL_SPART_ONLY) == 0)
116 0 : aStyle.sStyle = sArg.copy(LEN_SPART, sArg.getLength()-LEN_SPART);
117 0 : else if (sArg.indexOf(CMDURL_FPART_ONLY) == 0)
118 0 : aStyle.sFamily = sArg.copy(LEN_FPART, sArg.getLength()-LEN_FPART);
119 :
120 0 : sArg = sCmdArgs.copy(i+1, sCmdArgs.getLength()-i-1);
121 0 : if (sArg.indexOf(CMDURL_SPART_ONLY) == 0)
122 0 : aStyle.sStyle = sArg.copy(LEN_SPART, sArg.getLength()-LEN_SPART);
123 0 : else if (sArg.indexOf(CMDURL_FPART_ONLY) == 0)
124 0 : aStyle.sFamily = sArg.copy(LEN_FPART, sArg.getLength()-LEN_FPART);
125 :
126 0 : if (!(aStyle.sFamily.isEmpty() || aStyle.sStyle.isEmpty()))
127 0 : return sal_True;
128 :
129 0 : return sal_False;
130 : }
131 :
132 0 : void SfxStylesInfo_Impl::getLabel4Style(SfxStyleInfo_Impl& aStyle)
133 : {
134 : try
135 : {
136 0 : css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY);
137 :
138 0 : css::uno::Reference< css::container::XNameAccess > xFamilies;
139 0 : if (xModel.is())
140 0 : xFamilies = xModel->getStyleFamilies();
141 :
142 0 : css::uno::Reference< css::container::XNameAccess > xStyleSet;
143 0 : if (xFamilies.is())
144 0 : xFamilies->getByName(aStyle.sFamily) >>= xStyleSet;
145 :
146 0 : css::uno::Reference< css::beans::XPropertySet > xStyle;
147 0 : if (xStyleSet.is())
148 0 : xStyleSet->getByName(aStyle.sStyle) >>= xStyle;
149 :
150 0 : aStyle.sLabel = OUString();
151 0 : if (xStyle.is())
152 0 : xStyle->getPropertyValue(STYLEPROP_UINAME) >>= aStyle.sLabel;
153 : }
154 0 : catch(const css::uno::RuntimeException&)
155 0 : { throw; }
156 0 : catch(const css::uno::Exception&)
157 0 : { aStyle.sLabel = OUString(); }
158 :
159 0 : if (aStyle.sLabel.isEmpty())
160 : {
161 0 : aStyle.sLabel = aStyle.sCommand;
162 : }
163 0 : }
164 :
165 0 : ::std::vector< SfxStyleInfo_Impl > SfxStylesInfo_Impl::getStyleFamilies()
166 : {
167 : // Its an optional interface!
168 0 : css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY);
169 0 : if (!xModel.is())
170 0 : return ::std::vector< SfxStyleInfo_Impl >();
171 :
172 0 : css::uno::Reference< css::container::XNameAccess > xCont = xModel->getStyleFamilies();
173 0 : css::uno::Sequence< OUString > lFamilyNames = xCont->getElementNames();
174 0 : ::std::vector< SfxStyleInfo_Impl > lFamilies;
175 0 : sal_Int32 c = lFamilyNames.getLength();
176 0 : sal_Int32 i = 0;
177 0 : for(i=0; i<c; ++i)
178 : {
179 0 : SfxStyleInfo_Impl aFamilyInfo;
180 0 : aFamilyInfo.sFamily = lFamilyNames[i];
181 :
182 : try
183 : {
184 0 : css::uno::Reference< css::beans::XPropertySet > xFamilyInfo;
185 0 : xCont->getByName(aFamilyInfo.sFamily) >>= xFamilyInfo;
186 0 : if (!xFamilyInfo.is())
187 : {
188 : // TODO_AS currently there is no support for an UIName property .. use internal family name instead
189 0 : aFamilyInfo.sLabel = aFamilyInfo.sFamily;
190 : }
191 : else
192 0 : xFamilyInfo->getPropertyValue(STYLEPROP_UINAME) >>= aFamilyInfo.sLabel;
193 : }
194 0 : catch(const css::uno::RuntimeException&)
195 0 : { throw; }
196 0 : catch(const css::uno::Exception&)
197 0 : { return ::std::vector< SfxStyleInfo_Impl >(); }
198 :
199 0 : lFamilies.push_back(aFamilyInfo);
200 0 : }
201 :
202 0 : return lFamilies;
203 : }
204 :
205 0 : ::std::vector< SfxStyleInfo_Impl > SfxStylesInfo_Impl::getStyles(const OUString& sFamily)
206 : {
207 0 : static OUString PROP_UINAME ("DisplayName");
208 :
209 0 : css::uno::Sequence< OUString > lStyleNames;
210 0 : css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY_THROW);
211 0 : css::uno::Reference< css::container::XNameAccess > xFamilies = xModel->getStyleFamilies();
212 0 : css::uno::Reference< css::container::XNameAccess > xStyleSet;
213 : try
214 : {
215 0 : xFamilies->getByName(sFamily) >>= xStyleSet;
216 0 : lStyleNames = xStyleSet->getElementNames();
217 : }
218 0 : catch(const css::uno::RuntimeException&)
219 0 : { throw; }
220 0 : catch(const css::uno::Exception&)
221 0 : { return ::std::vector< SfxStyleInfo_Impl >(); }
222 :
223 0 : ::std::vector< SfxStyleInfo_Impl > lStyles;
224 0 : sal_Int32 c = lStyleNames.getLength();
225 0 : sal_Int32 i = 0;
226 0 : for (i=0; i<c; ++i)
227 : {
228 0 : SfxStyleInfo_Impl aStyleInfo;
229 0 : aStyleInfo.sFamily = sFamily;
230 0 : aStyleInfo.sStyle = lStyleNames[i];
231 0 : aStyleInfo.sCommand = SfxStylesInfo_Impl::generateCommand(aStyleInfo.sFamily, aStyleInfo.sStyle);
232 :
233 : try
234 : {
235 0 : css::uno::Reference< css::beans::XPropertySet > xStyle;
236 0 : xStyleSet->getByName(aStyleInfo.sStyle) >>= xStyle;
237 0 : if (!xStyle.is())
238 0 : continue;
239 0 : xStyle->getPropertyValue(PROP_UINAME) >>= aStyleInfo.sLabel;
240 : }
241 0 : catch(const css::uno::RuntimeException&)
242 0 : { throw; }
243 0 : catch(const css::uno::Exception&)
244 0 : { continue; }
245 :
246 0 : lStyles.push_back(aStyleInfo);
247 0 : }
248 0 : return lStyles;
249 : }
250 :
251 0 : SfxConfigFunctionListBox_Impl::SfxConfigFunctionListBox_Impl( Window* pParent, const ResId& rResId)
252 : : SvTreeListBox( pParent, rResId )
253 : , pCurEntry( 0 )
254 0 : , pStylesInfo( 0 )
255 : {
256 0 : SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT );
257 0 : GetModel()->SetSortMode( SortAscending );
258 :
259 : // Timer for the BallonHelp
260 0 : aTimer.SetTimeout( 200 );
261 : aTimer.SetTimeoutHdl(
262 0 : LINK( this, SfxConfigFunctionListBox_Impl, TimerHdl ) );
263 0 : }
264 :
265 0 : SfxConfigFunctionListBox_Impl::~SfxConfigFunctionListBox_Impl()
266 : {
267 0 : ClearAll();
268 0 : }
269 :
270 0 : void SfxConfigFunctionListBox_Impl::MouseMove( const MouseEvent& )
271 : {
272 0 : }
273 :
274 0 : IMPL_LINK( SfxConfigFunctionListBox_Impl, TimerHdl, Timer*, pTimer)
275 : /* Description
276 : Timer-handler for showing a help-text. If the mouse pointer is
277 : still on the currently selected entry after the timer has run out,
278 : the entry's help-text is shown as a balloon-help.
279 : */
280 : {
281 : (void)pTimer; // unused
282 0 : return 0L;
283 : }
284 :
285 0 : void SfxConfigFunctionListBox_Impl::ClearAll()
286 : /* Description
287 : Deletes all entries in the FunctionListBox, all UserData and all
288 : possibly existing MacroInfo.
289 : */
290 : {
291 0 : sal_uInt16 nCount = aArr.size();
292 0 : for ( sal_uInt16 i=0; i<nCount; ++i )
293 : {
294 0 : SfxGroupInfo_Impl *pData = &aArr[i];
295 :
296 0 : if ( pData->nKind == SFX_CFGFUNCTION_SCRIPT )
297 : {
298 0 : String* pScriptURI = (String*)pData->pObject;
299 0 : delete pScriptURI;
300 : }
301 :
302 0 : if ( pData->nKind == SFX_CFGGROUP_SCRIPTCONTAINER )
303 : {
304 0 : XInterface* xi = static_cast<XInterface *>(pData->pObject);
305 0 : if (xi != NULL)
306 : {
307 0 : xi->release();
308 : }
309 : }
310 : }
311 :
312 0 : aArr.clear();
313 0 : Clear();
314 0 : }
315 :
316 0 : String SfxConfigFunctionListBox_Impl::GetSelectedScriptURI()
317 : {
318 0 : SvTreeListEntry *pEntry = FirstSelected();
319 0 : if ( pEntry )
320 : {
321 0 : SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData();
322 0 : if ( pData && ( pData->nKind == SFX_CFGFUNCTION_SCRIPT ) )
323 0 : return *(String*)pData->pObject;
324 : }
325 0 : return String();
326 : }
327 :
328 0 : String SfxConfigFunctionListBox_Impl::GetCurCommand()
329 : {
330 0 : SvTreeListEntry *pEntry = FirstSelected();
331 0 : if (!pEntry)
332 0 : return String();
333 0 : SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData();
334 0 : if (!pData)
335 0 : return String();
336 0 : return pData->sCommand;
337 : }
338 :
339 0 : String SfxConfigFunctionListBox_Impl::GetCurLabel()
340 : {
341 0 : SvTreeListEntry *pEntry = FirstSelected();
342 0 : if (!pEntry)
343 0 : return String();
344 0 : SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData();
345 0 : if (!pData)
346 0 : return String();
347 0 : if (pData->sLabel.Len())
348 0 : return pData->sLabel;
349 0 : return pData->sCommand;
350 : }
351 :
352 0 : void SfxConfigFunctionListBox_Impl::FunctionSelected()
353 : /* Description
354 : Resets the balloon-help because it shall
355 : always show the help-text of the selected entry.
356 : */
357 : {
358 0 : }
359 :
360 0 : void SfxConfigFunctionListBox_Impl::SetStylesInfo(SfxStylesInfo_Impl* pStyles)
361 : {
362 0 : pStylesInfo = pStyles;
363 0 : }
364 :
365 : struct SvxConfigGroupBoxResource_Impl : public Resource
366 : {
367 : Image m_hdImage;
368 : Image m_libImage;
369 : Image m_macImage;
370 : Image m_docImage;
371 : OUString m_sMyMacros;
372 : OUString m_sProdMacros;
373 : String m_sMacros;
374 : String m_sDlgMacros;
375 : String m_aHumanAppName;
376 : String m_aStrGroupStyles;
377 : Image m_collapsedImage;
378 : Image m_expandedImage;
379 :
380 : SvxConfigGroupBoxResource_Impl();
381 : };
382 :
383 0 : SvxConfigGroupBoxResource_Impl::SvxConfigGroupBoxResource_Impl() :
384 0 : Resource(CUI_RES(RID_SVXPAGE_CONFIGGROUPBOX)),
385 0 : m_hdImage(CUI_RES(RID_CUIIMG_HARDDISK)),
386 0 : m_libImage(CUI_RES(RID_CUIIMG_LIB)),
387 0 : m_macImage(CUI_RES(RID_CUIIMG_MACRO)),
388 0 : m_docImage(CUI_RES(RID_CUIIMG_DOC)),
389 0 : m_sMyMacros(CUI_RESSTR(RID_SVXSTR_MYMACROS)),
390 0 : m_sProdMacros(CUI_RESSTR(RID_SVXSTR_PRODMACROS)),
391 0 : m_sMacros(CUI_RESSTR(STR_BASICMACROS)),
392 0 : m_sDlgMacros(CUI_RESSTR(RID_SVXSTR_PRODMACROS)),
393 0 : m_aHumanAppName(CUI_RESSTR(STR_HUMAN_APPNAME)),
394 0 : m_aStrGroupStyles(CUI_RESSTR(STR_GROUP_STYLES)),
395 0 : m_collapsedImage(CUI_RES(BMP_COLLAPSED)),
396 0 : m_expandedImage(CUI_RES(BMP_EXPANDED))
397 : {
398 0 : FreeResource();
399 0 : }
400 :
401 0 : SfxConfigGroupListBox_Impl::SfxConfigGroupListBox_Impl(
402 : Window* pParent, const ResId& rResId, sal_uLong nConfigMode )
403 : : SvTreeListBox( pParent, rResId )
404 0 : , pImp(new SvxConfigGroupBoxResource_Impl()), pFunctionListBox(0), nMode( nConfigMode ), pStylesInfo(0)
405 : {
406 0 : SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_HASBUTTONS | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONSATROOT );
407 0 : SetNodeBitmaps( pImp->m_collapsedImage, pImp->m_expandedImage );
408 0 : }
409 :
410 :
411 0 : SfxConfigGroupListBox_Impl::~SfxConfigGroupListBox_Impl()
412 : {
413 0 : ClearAll();
414 0 : }
415 :
416 0 : void SfxConfigGroupListBox_Impl::ClearAll()
417 : {
418 0 : sal_uInt16 nCount = aArr.size();
419 0 : for ( sal_uInt16 i=0; i<nCount; ++i )
420 : {
421 0 : SfxGroupInfo_Impl *pData = &aArr[i];
422 0 : if (pData->nKind == SFX_CFGGROUP_SCRIPTCONTAINER)
423 : {
424 0 : XInterface* xi = static_cast<XInterface *>(pData->pObject);
425 0 : if (xi != NULL)
426 : {
427 0 : xi->release();
428 : }
429 : }
430 : }
431 :
432 0 : aArr.clear();
433 0 : Clear();
434 0 : }
435 :
436 0 : void SfxConfigGroupListBox_Impl::SetStylesInfo(SfxStylesInfo_Impl* pStyles)
437 : {
438 0 : pStylesInfo = pStyles;
439 0 : }
440 :
441 : //-----------------------------------------------
442 0 : void SfxConfigGroupListBox_Impl::InitModule()
443 : {
444 : try
445 : {
446 0 : css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider(m_xFrame, css::uno::UNO_QUERY_THROW);
447 0 : css::uno::Sequence< sal_Int16 > lGroups = xProvider->getSupportedCommandGroups();
448 0 : sal_Int32 c1 = lGroups.getLength();
449 0 : sal_Int32 i1 = 0;
450 :
451 0 : for (i1=0; i1<c1; ++i1)
452 : {
453 0 : sal_Int16& rGroupID = lGroups[i1];
454 0 : OUString sGroupID = OUString::valueOf((sal_Int32)rGroupID);
455 0 : OUString sGroupName ;
456 :
457 : try
458 : {
459 0 : m_xModuleCategoryInfo->getByName(sGroupID) >>= sGroupName;
460 0 : if (sGroupName.isEmpty())
461 0 : continue;
462 : }
463 0 : catch(const css::container::NoSuchElementException&)
464 0 : { continue; }
465 :
466 0 : SvTreeListEntry* pEntry = InsertEntry(sGroupName, NULL);
467 0 : SfxGroupInfo_Impl* pInfo = new SfxGroupInfo_Impl(SFX_CFGGROUP_FUNCTION, rGroupID);
468 0 : pEntry->SetUserData(pInfo);
469 0 : }
470 : }
471 0 : catch(const css::uno::RuntimeException&)
472 0 : { throw; }
473 0 : catch(const css::uno::Exception&)
474 : {}
475 0 : }
476 :
477 : //-----------------------------------------------
478 0 : void SfxConfigGroupListBox_Impl::InitBasic()
479 : {
480 0 : }
481 :
482 : //-----------------------------------------------
483 0 : void SfxConfigGroupListBox_Impl::InitStyles()
484 : {
485 0 : }
486 :
487 : //-----------------------------------------------
488 : namespace
489 : {
490 : //...........................................
491 : /** examines a component whether it supports XEmbeddedScripts, or provides access to such a
492 : component by implementing XScriptInvocationContext.
493 : @return
494 : the model which supports the embedded scripts, or <NULL/> if it cannot find such a
495 : model
496 : */
497 0 : static Reference< XModel > lcl_getDocumentWithScripts_throw( const Reference< XInterface >& _rxComponent )
498 : {
499 0 : Reference< XEmbeddedScripts > xScripts( _rxComponent, UNO_QUERY );
500 0 : if ( !xScripts.is() )
501 : {
502 0 : Reference< XScriptInvocationContext > xContext( _rxComponent, UNO_QUERY );
503 0 : if ( xContext.is() )
504 0 : xScripts.set( xContext->getScriptContainer(), UNO_QUERY );
505 : }
506 :
507 0 : return Reference< XModel >( xScripts, UNO_QUERY );
508 : }
509 :
510 : //...........................................
511 0 : static Reference< XModel > lcl_getScriptableDocument_nothrow( const Reference< XFrame >& _rxFrame )
512 : {
513 0 : Reference< XModel > xDocument;
514 :
515 : // examine our associated frame
516 : try
517 : {
518 : OSL_ENSURE( _rxFrame.is(), "lcl_getScriptableDocument_nothrow: you need to pass a frame to this dialog/tab page!" );
519 0 : if ( _rxFrame.is() )
520 : {
521 : // first try the model in the frame
522 0 : Reference< XController > xController( _rxFrame->getController(), UNO_SET_THROW );
523 0 : xDocument = lcl_getDocumentWithScripts_throw( xController->getModel() );
524 :
525 0 : if ( !xDocument.is() )
526 : {
527 : // if there is no suitable document in the frame, try the controller
528 0 : xDocument = lcl_getDocumentWithScripts_throw( _rxFrame->getController() );
529 0 : }
530 : }
531 : }
532 0 : catch( const Exception& )
533 : {
534 : }
535 :
536 0 : return xDocument;
537 : }
538 : }
539 :
540 : //-----------------------------------------------
541 0 : void SfxConfigGroupListBox_Impl::Init(const css::uno::Reference< css::uno::XComponentContext >& xContext,
542 : const css::uno::Reference< css::frame::XFrame >& xFrame,
543 : const OUString& sModuleLongName)
544 : {
545 0 : SetUpdateMode(sal_False);
546 0 : ClearAll(); // Remove all old entries from treelist box
547 :
548 0 : m_xFrame = xFrame;
549 0 : if( xContext.is() )
550 : {
551 0 : m_xContext = xContext;
552 0 : m_sModuleLongName = sModuleLongName;
553 :
554 0 : m_xGlobalCategoryInfo = css::ui::UICategoryDescription::create( m_xContext );
555 0 : m_xModuleCategoryInfo = css::uno::Reference< css::container::XNameAccess >(m_xGlobalCategoryInfo->getByName(m_sModuleLongName), css::uno::UNO_QUERY_THROW);
556 0 : m_xUICmdDescription = css::frame::UICommandDescription::create( m_xContext );
557 :
558 0 : InitModule();
559 0 : InitBasic();
560 0 : InitStyles();
561 : }
562 :
563 : OSL_TRACE("** ** About to initialise SF Scripts");
564 : // Add Scripting Framework entries
565 0 : Reference< browse::XBrowseNode > rootNode;
566 : Reference< XComponentContext > xCtx(
567 0 : comphelper::getProcessComponentContext() );
568 : try
569 : {
570 0 : Reference< browse::XBrowseNodeFactory > xFac = browse::theBrowseNodeFactory::get( xCtx );
571 0 : rootNode.set( xFac->createView( browse::BrowseNodeFactoryViewTypes::MACROSELECTOR ) );
572 : }
573 0 : catch( Exception& e )
574 : {
575 : OSL_TRACE(" Caught some exception whilst retrieving browse nodes from factory... Exception: %s",
576 : OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).pData->buffer );
577 : // TODO exception handling
578 : }
579 :
580 :
581 0 : if ( rootNode.is() )
582 : {
583 0 : if ( nMode )
584 : {
585 : //We call acquire on the XBrowseNode so that it does not
586 : //get autodestructed and become invalid when accessed later.
587 0 : rootNode->acquire();
588 :
589 : SfxGroupInfo_Impl *pInfo =
590 : new SfxGroupInfo_Impl( SFX_CFGGROUP_SCRIPTCONTAINER, 0,
591 0 : static_cast<void *>(rootNode.get()));
592 :
593 0 : String aTitle(pImp->m_sDlgMacros);
594 0 : SvTreeListEntry *pNewEntry = InsertEntry( aTitle, NULL );
595 0 : pNewEntry->SetUserData( pInfo );
596 0 : pNewEntry->EnableChildrenOnDemand( sal_True );
597 0 : aArr.push_back( pInfo );
598 : }
599 : else
600 : {
601 : //We are only showing scripts not slot APIs so skip
602 : //Root node and show location nodes
603 : try {
604 0 : if ( rootNode->hasChildNodes() )
605 : {
606 : Sequence< Reference< browse::XBrowseNode > > children =
607 0 : rootNode->getChildNodes();
608 0 : sal_Bool bIsRootNode = sal_False;
609 :
610 0 : OUString user("user");
611 0 : OUString share("share");
612 0 : if ( rootNode->getName() == "Root" )
613 : {
614 0 : bIsRootNode = sal_True;
615 : }
616 :
617 : //To mimic current starbasic behaviour we
618 : //need to make sure that only the current document
619 : //is displayed in the config tree. Tests below
620 : //set the bDisplay flag to FALSE if the current
621 : //node is a first level child of the Root and is NOT
622 : //either the current document, user or share
623 0 : OUString currentDocTitle;
624 0 : Reference< XModel > xDocument( lcl_getScriptableDocument_nothrow( m_xFrame ) );
625 0 : if ( xDocument.is() )
626 : {
627 0 : currentDocTitle = ::comphelper::DocumentInfo::getDocumentTitle( xDocument );
628 : }
629 :
630 0 : for ( sal_Int32 n = 0; n < children.getLength(); ++n )
631 : {
632 0 : Reference< browse::XBrowseNode >& theChild = children[n];
633 0 : sal_Bool bDisplay = sal_True;
634 0 : OUString uiName = theChild->getName();
635 0 : if ( bIsRootNode )
636 : {
637 0 : if ( ! ((theChild->getName().equals( user ) || theChild->getName().equals( share ) ||
638 0 : theChild->getName().equals( currentDocTitle ) ) ) )
639 : {
640 0 : bDisplay=sal_False;
641 : }
642 : else
643 : {
644 0 : if ( uiName.equals( user ) )
645 : {
646 0 : uiName = pImp->m_sMyMacros;
647 : }
648 0 : else if ( uiName.equals( share ) )
649 : {
650 0 : uiName = pImp->m_sProdMacros;
651 : }
652 : }
653 : }
654 0 : if (children[n]->getType() != browse::BrowseNodeTypes::SCRIPT && bDisplay )
655 : {
656 : // We call acquire on the XBrowseNode so that it does not
657 : // get autodestructed and become invalid when accessed later.
658 0 : theChild->acquire();
659 :
660 : SfxGroupInfo_Impl* pInfo =
661 : new SfxGroupInfo_Impl(SFX_CFGGROUP_SCRIPTCONTAINER,
662 0 : 0, static_cast<void *>( theChild.get()));
663 :
664 0 : Image aImage = GetImage( theChild, xCtx, bIsRootNode );
665 : SvTreeListEntry* pNewEntry =
666 0 : InsertEntry( uiName, NULL);
667 0 : SetExpandedEntryBmp( pNewEntry, aImage );
668 0 : SetCollapsedEntryBmp( pNewEntry, aImage );
669 :
670 0 : pNewEntry->SetUserData( pInfo );
671 0 : aArr.push_back( pInfo );
672 :
673 0 : if ( children[n]->hasChildNodes() )
674 : {
675 : Sequence< Reference< browse::XBrowseNode > > grandchildren =
676 0 : children[n]->getChildNodes();
677 :
678 0 : for ( sal_Int32 m = 0; m < grandchildren.getLength(); ++m )
679 : {
680 0 : if ( grandchildren[m]->getType() == browse::BrowseNodeTypes::CONTAINER )
681 : {
682 0 : pNewEntry->EnableChildrenOnDemand( sal_True );
683 0 : m = grandchildren.getLength();
684 : }
685 0 : }
686 0 : }
687 : }
688 0 : }
689 : }
690 : }
691 0 : catch (RuntimeException&) {
692 : // do nothing, the entry will not be displayed in the UI
693 : }
694 : }
695 : }
696 :
697 : // add styles
698 0 : if ( m_xContext.is() )
699 : {
700 0 : String sStyle( pImp->m_aStrGroupStyles );
701 0 : SvTreeListEntry *pEntry = InsertEntry( sStyle, 0 );
702 0 : SfxGroupInfo_Impl *pInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_STYLES, 0, 0 ); // TODO last parameter should contain user data
703 0 : aArr.push_back( pInfo );
704 0 : pEntry->SetUserData( pInfo );
705 0 : pEntry->EnableChildrenOnDemand( sal_True );
706 : }
707 :
708 0 : MakeVisible( GetEntry( 0,0 ) );
709 0 : SetUpdateMode( sal_True );
710 0 : }
711 0 : Image SfxConfigGroupListBox_Impl::GetImage(
712 : Reference< browse::XBrowseNode > node,
713 : Reference< XComponentContext > xCtx,
714 : bool bIsRootNode
715 : )
716 : {
717 0 : Image aImage;
718 0 : if ( bIsRootNode )
719 : {
720 0 : OUString user("user");
721 0 : OUString share("share");
722 0 : if (node->getName().equals( user ) || node->getName().equals(share ) )
723 : {
724 0 : aImage = pImp->m_hdImage;
725 : }
726 : else
727 : {
728 0 : OUString factoryURL;
729 0 : OUString nodeName = node->getName();
730 0 : Reference<XInterface> xDocumentModel = getDocumentModel(xCtx, nodeName );
731 0 : if ( xDocumentModel.is() )
732 : {
733 0 : Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xCtx) );
734 : // get the long name of the document:
735 0 : OUString appModule( xModuleManager->identify(
736 0 : xDocumentModel ) );
737 0 : Sequence<beans::PropertyValue> moduleDescr;
738 0 : Any aAny = xModuleManager->getByName(appModule);
739 0 : if( sal_True != ( aAny >>= moduleDescr ) )
740 : {
741 0 : throw RuntimeException("SFTreeListBox::Init: failed to get PropertyValue", Reference< XInterface >());
742 : }
743 : beans::PropertyValue const * pmoduleDescr =
744 0 : moduleDescr.getConstArray();
745 0 : for ( sal_Int32 pos = moduleDescr.getLength(); pos--; )
746 : {
747 0 : if ( pmoduleDescr[ pos ].Name == "ooSetupFactoryEmptyDocumentURL" )
748 : {
749 0 : pmoduleDescr[ pos ].Value >>= factoryURL;
750 : OSL_TRACE("factory url for doc images is %s",
751 : OUStringToOString( factoryURL , RTL_TEXTENCODING_ASCII_US ).pData->buffer );
752 0 : break;
753 : }
754 0 : }
755 : }
756 0 : if( !factoryURL.isEmpty() )
757 : {
758 0 : aImage = SvFileInformationManager::GetFileImage( INetURLObject(factoryURL), false );
759 : }
760 : else
761 : {
762 0 : aImage = pImp->m_docImage;
763 0 : }
764 0 : }
765 : }
766 : else
767 : {
768 0 : if( node->getType() == browse::BrowseNodeTypes::SCRIPT )
769 0 : aImage = pImp->m_macImage;
770 : else
771 0 : aImage = pImp->m_libImage;
772 : }
773 0 : return aImage;
774 : }
775 :
776 : Reference< XInterface >
777 0 : SfxConfigGroupListBox_Impl::getDocumentModel( Reference< XComponentContext >& xCtx, OUString& docName )
778 : {
779 0 : Reference< XInterface > xModel;
780 0 : Reference< frame::XDesktop2 > desktop = frame::Desktop::create( xCtx );
781 :
782 : Reference< container::XEnumerationAccess > componentsAccess =
783 0 : desktop->getComponents();
784 : Reference< container::XEnumeration > components =
785 0 : componentsAccess->createEnumeration();
786 0 : while (components->hasMoreElements())
787 : {
788 : Reference< frame::XModel > model(
789 0 : components->nextElement(), UNO_QUERY );
790 0 : if ( model.is() )
791 : {
792 : OUString sTdocUrl =
793 0 : ::comphelper::DocumentInfo::getDocumentTitle( model );
794 0 : if( sTdocUrl.equals( docName ) )
795 : {
796 0 : xModel = model;
797 0 : break;
798 0 : }
799 : }
800 0 : }
801 0 : return xModel;
802 : }
803 :
804 : //-----------------------------------------------
805 0 : OUString SfxConfigGroupListBox_Impl::MapCommand2UIName(const OUString& sCommand)
806 : {
807 0 : OUString sUIName;
808 : try
809 : {
810 0 : css::uno::Reference< css::container::XNameAccess > xModuleConf;
811 0 : m_xUICmdDescription->getByName(m_sModuleLongName) >>= xModuleConf;
812 0 : if (xModuleConf.is())
813 : {
814 0 : ::comphelper::SequenceAsHashMap lProps(xModuleConf->getByName(sCommand));
815 0 : sUIName = lProps.getUnpackedValueOrDefault("Name", OUString());
816 0 : }
817 : }
818 0 : catch(const css::uno::RuntimeException&)
819 0 : { throw; }
820 0 : catch(css::uno::Exception&)
821 0 : { sUIName = OUString(); }
822 :
823 : // fallback for missing UINames !?
824 0 : if (sUIName.isEmpty())
825 : {
826 0 : sUIName = sCommand;
827 : }
828 :
829 0 : return sUIName;
830 : }
831 :
832 : //-----------------------------------------------
833 0 : void SfxConfigGroupListBox_Impl::GroupSelected()
834 : /* Description
835 : A function group or a basic module has been selected.
836 : All functions/macros are displayed in the functionlistbox.
837 : */
838 : {
839 0 : SvTreeListEntry *pEntry = FirstSelected();
840 0 : SfxGroupInfo_Impl *pInfo = (SfxGroupInfo_Impl*) pEntry->GetUserData();
841 0 : pFunctionListBox->SetUpdateMode(sal_False);
842 0 : pFunctionListBox->ClearAll();
843 0 : if ( pInfo->nKind != SFX_CFGGROUP_FUNCTION &&
844 0 : pInfo->nKind != SFX_CFGGROUP_SCRIPTCONTAINER &&
845 0 : pInfo->nKind != SFX_CFGGROUP_STYLES )
846 : {
847 0 : pFunctionListBox->SetUpdateMode(sal_True);
848 0 : return;
849 : }
850 :
851 0 : switch ( pInfo->nKind )
852 : {
853 : case SFX_CFGGROUP_FUNCTION :
854 : {
855 0 : sal_uInt16 nGroup = pInfo->nUniqueID;
856 0 : css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider (m_xFrame, css::uno::UNO_QUERY_THROW);
857 0 : css::uno::Sequence< css::frame::DispatchInformation > lCommands = xProvider->getConfigurableDispatchInformation(nGroup);
858 0 : sal_Int32 c = lCommands.getLength();
859 0 : sal_Int32 i = 0;
860 :
861 0 : for (i=0; i<c; ++i)
862 : {
863 0 : const css::frame::DispatchInformation& rInfo = lCommands[i];
864 0 : OUString sUIName = MapCommand2UIName(rInfo.Command);
865 0 : SvTreeListEntry* pFuncEntry = pFunctionListBox->InsertEntry(sUIName, NULL);
866 0 : SfxGroupInfo_Impl* pGrpInfo = new SfxGroupInfo_Impl(SFX_CFGFUNCTION_SLOT, 0);
867 0 : pGrpInfo->sCommand = rInfo.Command;
868 0 : pGrpInfo->sLabel = sUIName;
869 0 : pFuncEntry->SetUserData(pGrpInfo);
870 0 : }
871 :
872 0 : break;
873 : }
874 :
875 : case SFX_CFGGROUP_SCRIPTCONTAINER:
876 : {
877 0 : if ( !GetChildCount( pEntry ) )
878 : {
879 : Reference< browse::XBrowseNode > rootNode(
880 0 : reinterpret_cast< browse::XBrowseNode* >( pInfo->pObject ) ) ;
881 :
882 : try {
883 0 : if ( rootNode->hasChildNodes() )
884 : {
885 : Sequence< Reference< browse::XBrowseNode > > children =
886 0 : rootNode->getChildNodes();
887 :
888 0 : for ( sal_Int32 n = 0; n < children.getLength(); ++n )
889 : {
890 0 : if (children[n]->getType() == browse::BrowseNodeTypes::SCRIPT)
891 : {
892 0 : OUString uri;
893 :
894 0 : Reference < beans::XPropertySet >xPropSet( children[n], UNO_QUERY );
895 0 : if (!xPropSet.is())
896 : {
897 0 : continue;
898 : }
899 :
900 : Any value =
901 0 : xPropSet->getPropertyValue("URI");
902 0 : value >>= uri;
903 :
904 0 : String* pScriptURI = new String( uri );
905 0 : SfxGroupInfo_Impl* pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGFUNCTION_SCRIPT, 0, pScriptURI );
906 :
907 0 : Image aImage = GetImage( children[n], Reference< XComponentContext >(), sal_False );
908 : SvTreeListEntry* pNewEntry =
909 0 : pFunctionListBox->InsertEntry( children[n]->getName(), NULL );
910 0 : pFunctionListBox->SetExpandedEntryBmp( pNewEntry, aImage );
911 0 : pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage );
912 :
913 0 : pGrpInfo->sCommand = uri;
914 0 : pGrpInfo->sLabel = children[n]->getName();
915 0 : pNewEntry->SetUserData( pGrpInfo );
916 :
917 0 : pFunctionListBox->aArr.push_back( pGrpInfo );
918 :
919 : }
920 0 : }
921 : }
922 : }
923 0 : catch (RuntimeException&) {
924 : // do nothing, the entry will not be displayed in the UI
925 0 : }
926 : }
927 0 : break;
928 : }
929 :
930 : case SFX_CFGGROUP_STYLES :
931 : {
932 0 : SfxStyleInfo_Impl* pFamily = (SfxStyleInfo_Impl*)(pInfo->pObject);
933 0 : if (pFamily)
934 : {
935 0 : const ::std::vector< SfxStyleInfo_Impl > lStyles = pStylesInfo->getStyles(pFamily->sFamily);
936 0 : ::std::vector< SfxStyleInfo_Impl >::const_iterator pIt;
937 0 : for ( pIt = lStyles.begin();
938 0 : pIt != lStyles.end() ;
939 : ++pIt )
940 : {
941 0 : SfxStyleInfo_Impl* pStyle = new SfxStyleInfo_Impl(*pIt);
942 0 : SvTreeListEntry* pFuncEntry = pFunctionListBox->InsertEntry( pStyle->sLabel, NULL );
943 0 : SfxGroupInfo_Impl *pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_STYLES, 0, pStyle );
944 0 : pFunctionListBox->aArr.push_back( pGrpInfo );
945 0 : pGrpInfo->sCommand = pStyle->sCommand;
946 0 : pGrpInfo->sLabel = pStyle->sLabel;
947 0 : pFuncEntry->SetUserData( pGrpInfo );
948 0 : }
949 : }
950 0 : break;
951 : }
952 :
953 : default:
954 0 : return;
955 : }
956 :
957 0 : if ( pFunctionListBox->GetEntryCount() )
958 0 : pFunctionListBox->Select( pFunctionListBox->GetEntry( 0, 0 ) );
959 :
960 0 : pFunctionListBox->SetUpdateMode(sal_True);
961 : }
962 :
963 0 : sal_Bool SfxConfigGroupListBox_Impl::Expand( SvTreeListEntry* pParent )
964 : {
965 0 : sal_Bool bRet = SvTreeListBox::Expand( pParent );
966 0 : if ( bRet )
967 : {
968 0 : sal_uLong nEntries = GetOutputSizePixel().Height() / GetEntryHeight();
969 :
970 0 : sal_uLong nChildCount = GetVisibleChildCount( pParent );
971 :
972 0 : if ( nChildCount+1 > nEntries )
973 : {
974 0 : MakeVisible( pParent, sal_True );
975 : }
976 : else
977 : {
978 0 : SvTreeListEntry *pEntry = GetFirstEntryInView();
979 0 : sal_uLong nParentPos = 0;
980 0 : while ( pEntry && pEntry != pParent )
981 : {
982 0 : ++nParentPos;
983 0 : pEntry = GetNextEntryInView( pEntry );
984 : }
985 :
986 0 : if ( nParentPos + nChildCount + 1 > nEntries )
987 0 : ScrollOutputArea( (short)( nEntries - ( nParentPos + nChildCount + 1 ) ) );
988 : }
989 : }
990 :
991 0 : return bRet;
992 : }
993 :
994 0 : void SfxConfigGroupListBox_Impl::RequestingChildren( SvTreeListEntry *pEntry )
995 : /* Description
996 : A basic or a library is opened.
997 : */
998 : {
999 0 : SfxGroupInfo_Impl *pInfo = (SfxGroupInfo_Impl*) pEntry->GetUserData();
1000 0 : pInfo->bWasOpened = sal_True;
1001 0 : switch ( pInfo->nKind )
1002 : {
1003 : case SFX_CFGGROUP_SCRIPTCONTAINER:
1004 : {
1005 0 : if ( !GetChildCount( pEntry ) )
1006 : {
1007 : Reference< browse::XBrowseNode > rootNode(
1008 0 : reinterpret_cast< browse::XBrowseNode* >( pInfo->pObject ) ) ;
1009 :
1010 : try {
1011 0 : if ( rootNode->hasChildNodes() )
1012 : {
1013 : Sequence< Reference< browse::XBrowseNode > > children =
1014 0 : rootNode->getChildNodes();
1015 0 : sal_Bool bIsRootNode = sal_False;
1016 :
1017 0 : OUString user("user");
1018 0 : OUString share("share" );
1019 0 : if ( rootNode->getName() == "Root" )
1020 : {
1021 0 : bIsRootNode = sal_True;
1022 : }
1023 :
1024 : /* To mimic current starbasic behaviour we
1025 : need to make sure that only the current document
1026 : is displayed in the config tree. Tests below
1027 : set the bDisplay flag to sal_False if the current
1028 : node is a first level child of the Root and is NOT
1029 : either the current document, user or share */
1030 0 : OUString currentDocTitle;
1031 0 : Reference< XModel > xDocument( lcl_getScriptableDocument_nothrow( m_xFrame ) );
1032 0 : if ( xDocument.is() )
1033 : {
1034 0 : currentDocTitle = ::comphelper::DocumentInfo::getDocumentTitle( xDocument );
1035 : }
1036 :
1037 0 : sal_Int32 nLen = children.getLength();
1038 0 : for ( sal_Int32 n = 0; n < nLen; ++n )
1039 : {
1040 0 : Reference< browse::XBrowseNode >& theChild = children[n];
1041 0 : OUString aName( theChild->getName() );
1042 0 : sal_Bool bDisplay = sal_True;
1043 0 : if ( bIsRootNode )
1044 : {
1045 0 : if ( !( (aName.equals(user) || aName.equals(share) || aName.equals(currentDocTitle) ) ) )
1046 0 : bDisplay=sal_False;
1047 : }
1048 0 : if ( children[n].is() && children[n]->getType() != browse::BrowseNodeTypes::SCRIPT && bDisplay )
1049 : {
1050 :
1051 : /*
1052 : We call acquire on the XBrowseNode so that it does not
1053 : get autodestructed and become invalid when accessed later.
1054 : */
1055 0 : theChild->acquire();
1056 :
1057 : SfxGroupInfo_Impl* pGrpInfo =
1058 : new SfxGroupInfo_Impl(SFX_CFGGROUP_SCRIPTCONTAINER,
1059 0 : 0, static_cast<void *>( theChild.get()));
1060 :
1061 0 : Image aImage = GetImage( theChild, Reference< XComponentContext >(), sal_False );
1062 : SvTreeListEntry* pNewEntry =
1063 0 : InsertEntry( theChild->getName(), pEntry );
1064 0 : SetExpandedEntryBmp( pNewEntry, aImage );
1065 0 : SetCollapsedEntryBmp(pNewEntry, aImage );
1066 :
1067 0 : pNewEntry->SetUserData( pGrpInfo );
1068 0 : aArr.push_back( pGrpInfo );
1069 :
1070 0 : if ( children[n]->hasChildNodes() )
1071 : {
1072 : Sequence< Reference< browse::XBrowseNode > > grandchildren =
1073 0 : children[n]->getChildNodes();
1074 :
1075 0 : for ( sal_Int32 m = 0; m < grandchildren.getLength(); ++m )
1076 : {
1077 0 : if ( grandchildren[m]->getType() == browse::BrowseNodeTypes::CONTAINER )
1078 : {
1079 0 : pNewEntry->EnableChildrenOnDemand( sal_True );
1080 0 : m = grandchildren.getLength();
1081 : }
1082 0 : }
1083 0 : }
1084 : }
1085 0 : }
1086 : }
1087 : }
1088 0 : catch (RuntimeException&) {
1089 : // do nothing, the entry will not be displayed in the UI
1090 0 : }
1091 : }
1092 0 : break;
1093 : }
1094 :
1095 : case SFX_CFGGROUP_STYLES:
1096 : {
1097 0 : if ( !GetChildCount( pEntry ) )
1098 : {
1099 0 : const ::std::vector< SfxStyleInfo_Impl > lStyleFamilies = pStylesInfo->getStyleFamilies();
1100 0 : ::std::vector< SfxStyleInfo_Impl >::const_iterator pIt;
1101 0 : for ( pIt = lStyleFamilies.begin();
1102 0 : pIt != lStyleFamilies.end() ;
1103 : ++pIt )
1104 : {
1105 0 : SfxStyleInfo_Impl* pFamily = new SfxStyleInfo_Impl(*pIt);
1106 0 : SvTreeListEntry* pStyleEntry = InsertEntry( pFamily->sLabel, pEntry );
1107 0 : SfxGroupInfo_Impl *pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_STYLES, 0, pFamily );
1108 0 : aArr.push_back( pGrpInfo );
1109 0 : pStyleEntry->SetUserData( pGrpInfo );
1110 0 : pStyleEntry->EnableChildrenOnDemand( sal_False );
1111 0 : }
1112 : }
1113 0 : break;
1114 : }
1115 :
1116 : default:
1117 : OSL_FAIL( "Falscher Gruppentyp!" );
1118 0 : break;
1119 : }
1120 0 : }
1121 :
1122 0 : void SfxConfigGroupListBox_Impl::SelectMacro( const SfxMacroInfoItem *pItem )
1123 : {
1124 : SelectMacro( pItem->GetBasicManager()->GetName(),
1125 0 : pItem->GetQualifiedName() );
1126 0 : }
1127 :
1128 0 : void SfxConfigGroupListBox_Impl::SelectMacro( const String& rBasic,
1129 : const String& rMacro )
1130 : {
1131 0 : String aBasicName( rBasic );
1132 0 : aBasicName += ' ';
1133 0 : aBasicName += pImp->m_sMacros;
1134 0 : String aLib, aModule, aMethod;
1135 0 : sal_uInt16 nCount = comphelper::string::getTokenCount(rMacro, '.');
1136 0 : aMethod = rMacro.GetToken( nCount-1, '.' );
1137 0 : if ( nCount > 2 )
1138 : {
1139 0 : aLib = rMacro.GetToken( 0, '.' );
1140 0 : aModule = rMacro.GetToken( nCount-2, '.' );
1141 : }
1142 :
1143 0 : SvTreeListEntry *pEntry = FirstChild(0);
1144 0 : while ( pEntry )
1145 : {
1146 0 : String aEntryBas = GetEntryText( pEntry );
1147 0 : if ( aEntryBas == aBasicName )
1148 : {
1149 0 : Expand( pEntry );
1150 0 : SvTreeListEntry *pLib = FirstChild( pEntry );
1151 0 : while ( pLib )
1152 : {
1153 0 : String aEntryLib = GetEntryText( pLib );
1154 0 : if ( aEntryLib == aLib )
1155 : {
1156 0 : Expand( pLib );
1157 0 : SvTreeListEntry *pMod = FirstChild( pLib );
1158 0 : while ( pMod )
1159 : {
1160 0 : String aEntryMod = GetEntryText( pMod );
1161 0 : if ( aEntryMod == aModule )
1162 : {
1163 0 : Expand( pMod );
1164 0 : MakeVisible( pMod );
1165 0 : Select( pMod );
1166 0 : SvTreeListEntry *pMethod = pFunctionListBox->First();
1167 0 : while ( pMethod )
1168 : {
1169 0 : String aEntryMethod = GetEntryText( pMethod );
1170 0 : if ( aEntryMethod == aMethod )
1171 : {
1172 0 : pFunctionListBox->Select( pMethod );
1173 0 : pFunctionListBox->MakeVisible( pMethod );
1174 0 : return;
1175 : }
1176 0 : pMethod = pFunctionListBox->Next( pMethod );
1177 0 : }
1178 : }
1179 0 : pMod = NextSibling( pMod );
1180 0 : }
1181 : }
1182 0 : pLib = NextSibling( pLib );
1183 0 : }
1184 : }
1185 0 : pEntry = NextSibling( pEntry );
1186 0 : }
1187 0 : }
1188 :
1189 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|