1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <string_view>
24 #include <uielement/uicommanddescription.hxx>
26 #include <properties.h>
28 #include <helper/mischelper.hxx>
30 #include <com/sun/star/beans/PropertyValue.hpp>
31 #include <com/sun/star/frame/ModuleManager.hpp>
32 #include <com/sun/star/configuration/theDefaultProvider.hpp>
33 #include <com/sun/star/container/XNameAccess.hpp>
34 #include <com/sun/star/container/XContainer.hpp>
36 #include <cppuhelper/implbase.hxx>
37 #include <unotools/configmgr.hxx>
38 #include <unotools/syslocale.hxx>
40 #include <vcl/mnemonic.hxx>
41 #include <comphelper/propertysequence.hxx>
42 #include <comphelper/propertyvalue.hxx>
43 #include <comphelper/sequence.hxx>
44 #include <comphelper/string.hxx>
46 using namespace com::sun::star::uno
;
47 using namespace com::sun::star::lang
;
48 using namespace com::sun::star::beans
;
49 using namespace com::sun::star::configuration
;
50 using namespace com::sun::star::container
;
51 using namespace ::com::sun::star::frame
;
55 const char CONFIGURATION_ROOT_ACCESS
[] = "/org.openoffice.Office.UI.";
57 // Special resource URLs to retrieve additional information
58 constexpr OUStringLiteral PRIVATE_RESOURCE_URL
= u
"private:";
60 const sal_Int32 COMMAND_PROPERTY_IMAGE
= 1;
61 const sal_Int32 COMMAND_PROPERTY_ROTATE
= 2;
62 const sal_Int32 COMMAND_PROPERTY_MIRROR
= 4;
67 // Configuration access class for PopupMenuControllerFactory implementation
71 class ConfigurationAccess_UICommand
: // Order is necessary for right initialization!
72 public ::cppu::WeakImplHelper
<XNameAccess
,XContainerListener
>
76 ConfigurationAccess_UICommand( std::u16string_view aModuleName
, const Reference
< XNameAccess
>& xGenericUICommands
, const Reference
< XComponentContext
>& rxContext
);
77 virtual ~ConfigurationAccess_UICommand() override
;
80 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
82 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
84 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
87 virtual css::uno::Type SAL_CALL
getElementType() override
;
89 virtual sal_Bool SAL_CALL
hasElements() override
;
91 // container.XContainerListener
92 virtual void SAL_CALL
elementInserted( const ContainerEvent
& aEvent
) override
;
93 virtual void SAL_CALL
elementRemoved ( const ContainerEvent
& aEvent
) override
;
94 virtual void SAL_CALL
elementReplaced( const ContainerEvent
& aEvent
) override
;
96 // lang.XEventListener
97 virtual void SAL_CALL
disposing( const EventObject
& aEvent
) override
;
100 css::uno::Any
getByNameImpl( const OUString
& aName
);
104 CmdToInfoMap() : bPopup( false ),
105 bCommandNameCreated( false ),
106 bIsExperimental( false ),
110 OUString aContextLabel
;
111 OUString aCommandName
;
112 OUString aPopupLabel
;
113 OUString aTooltipLabel
;
116 bCommandNameCreated
: 1;
117 bool bIsExperimental
;
118 sal_Int32 nProperties
;
121 Any
getSequenceFromCache( const OUString
& aCommandURL
);
122 Any
getInfoFromCommand( const OUString
& rCommandURL
);
123 void fillInfoFromResult( CmdToInfoMap
& rCmdInfo
, const OUString
& aLabel
);
124 Sequence
< OUString
> getAllCommands();
126 void addGenericInfoToCache();
127 void impl_fill(const Reference
< XNameAccess
>& _xConfigAccess
,bool _bPopup
,
128 std::vector
< OUString
>& aImageCommandVector
,
129 std::vector
< OUString
>& aImageRotateVector
,
130 std::vector
< OUString
>& aImageMirrorVector
);
133 typedef std::unordered_map
< OUString
,
134 CmdToInfoMap
> CommandToInfoCache
;
136 void initializeConfigAccess();
138 OUString m_aConfigCmdAccess
;
139 OUString m_aConfigPopupAccess
;
140 OUString m_aPropProperties
;
141 Reference
< XNameAccess
> m_xGenericUICommands
;
142 Reference
< XMultiServiceFactory
> m_xConfigProvider
;
143 Reference
< XNameAccess
> m_xConfigAccess
;
144 Reference
< XContainerListener
> m_xConfigListener
;
145 Reference
< XNameAccess
> m_xConfigAccessPopups
;
146 Reference
< XContainerListener
> m_xConfigAccessListener
;
147 Sequence
< OUString
> m_aCommandImageList
;
148 Sequence
< OUString
> m_aCommandRotateImageList
;
149 Sequence
< OUString
> m_aCommandMirrorImageList
;
150 CommandToInfoCache m_aCmdInfoCache
;
151 bool m_bConfigAccessInitialized
;
153 bool m_bGenericDataRetrieved
;
159 // XInterface, XTypeProvider
161 ConfigurationAccess_UICommand::ConfigurationAccess_UICommand( std::u16string_view aModuleName
, const Reference
< XNameAccess
>& rGenericUICommands
, const Reference
< XComponentContext
>& rxContext
) :
162 // Create configuration hierarchical access name
164 OUString::Concat(CONFIGURATION_ROOT_ACCESS
) + aModuleName
+ "/UserInterface/Commands"),
165 m_aConfigPopupAccess(
166 OUString::Concat(CONFIGURATION_ROOT_ACCESS
) + aModuleName
+ "/UserInterface/Popups"),
167 m_aPropProperties( "Properties" ),
168 m_xGenericUICommands( rGenericUICommands
),
169 m_xConfigProvider( theDefaultProvider::get( rxContext
) ),
170 m_bConfigAccessInitialized( false ),
171 m_bCacheFilled( false ),
172 m_bGenericDataRetrieved( false )
176 ConfigurationAccess_UICommand::~ConfigurationAccess_UICommand()
179 std::unique_lock
g(m_aMutex
);
180 Reference
< XContainer
> xContainer( m_xConfigAccess
, UNO_QUERY
);
181 if ( xContainer
.is() )
182 xContainer
->removeContainerListener(m_xConfigListener
);
183 xContainer
.set( m_xConfigAccessPopups
, UNO_QUERY
);
184 if ( xContainer
.is() )
185 xContainer
->removeContainerListener(m_xConfigAccessListener
);
189 Any
ConfigurationAccess_UICommand::getByNameImpl( const OUString
& rCommandURL
)
191 std::unique_lock
g(m_aMutex
);
192 if ( !m_bConfigAccessInitialized
)
194 initializeConfigAccess();
195 m_bConfigAccessInitialized
= true;
199 if ( rCommandURL
.startsWith( PRIVATE_RESOURCE_URL
) )
201 // special keys to retrieve information about a set of commands
203 addGenericInfoToCache();
205 if ( rCommandURL
.equalsIgnoreAsciiCase( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDIMAGELIST
))
206 return Any( m_aCommandImageList
);
207 else if ( rCommandURL
.equalsIgnoreAsciiCase( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDROTATEIMAGELIST
))
208 return Any( m_aCommandRotateImageList
);
209 else if ( rCommandURL
.equalsIgnoreAsciiCase( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDMIRRORIMAGELIST
))
210 return Any( m_aCommandMirrorImageList
);
217 return getInfoFromCommand( rCommandURL
);
221 Any SAL_CALL
ConfigurationAccess_UICommand::getByName( const OUString
& rCommandURL
)
223 Any
aRet( getByNameImpl( rCommandURL
) );
224 if( !aRet
.hasValue() )
225 throw NoSuchElementException();
230 Sequence
< OUString
> SAL_CALL
ConfigurationAccess_UICommand::getElementNames()
232 return getAllCommands();
235 sal_Bool SAL_CALL
ConfigurationAccess_UICommand::hasByName( const OUString
& rCommandURL
)
237 return getByNameImpl( rCommandURL
).hasValue();
241 Type SAL_CALL
ConfigurationAccess_UICommand::getElementType()
243 return cppu::UnoType
<Sequence
< PropertyValue
>>::get();
246 sal_Bool SAL_CALL
ConfigurationAccess_UICommand::hasElements()
248 // There must are global commands!
252 void ConfigurationAccess_UICommand::fillInfoFromResult( CmdToInfoMap
& rCmdInfo
, const OUString
& aLabel
)
254 OUString
aStr(aLabel
.replaceAll("%PRODUCTNAME", utl::ConfigManager::getProductName()));
255 rCmdInfo
.aLabel
= aStr
;
256 aStr
= comphelper::string::stripEnd(aStr
, '.'); // Remove "..." from string
257 rCmdInfo
.aCommandName
= MnemonicGenerator::EraseAllMnemonicChars(aStr
);
258 rCmdInfo
.bCommandNameCreated
= true;
261 Any
ConfigurationAccess_UICommand::getSequenceFromCache( const OUString
& aCommandURL
)
263 CommandToInfoCache::iterator pIter
= m_aCmdInfoCache
.find( aCommandURL
);
264 if ( pIter
!= m_aCmdInfoCache
.end() )
266 if ( !pIter
->second
.bCommandNameCreated
)
267 fillInfoFromResult( pIter
->second
, pIter
->second
.aLabel
);
269 static constexpr OUStringLiteral sLabel
= u
"Label";
270 static constexpr OUStringLiteral sName
= u
"Name";
271 static constexpr OUStringLiteral sPopup
= u
"Popup";
272 static constexpr OUStringLiteral sPopupLabel
= u
"PopupLabel";
273 static constexpr OUStringLiteral sTooltipLabel
= u
"TooltipLabel";
274 static constexpr OUStringLiteral sTargetURL
= u
"TargetURL";
275 static constexpr OUStringLiteral sIsExperimental
= u
"IsExperimental";
276 Sequence
< PropertyValue
> aPropSeq
{
277 comphelper::makePropertyValue(sLabel
, !pIter
->second
.aContextLabel
.isEmpty()
278 ? Any(pIter
->second
.aContextLabel
)
279 : Any(pIter
->second
.aLabel
)),
280 comphelper::makePropertyValue(sName
, pIter
->second
.aCommandName
),
281 comphelper::makePropertyValue(sPopup
, pIter
->second
.bPopup
),
282 comphelper::makePropertyValue(m_aPropProperties
, pIter
->second
.nProperties
),
283 comphelper::makePropertyValue(sPopupLabel
, pIter
->second
.aPopupLabel
),
284 comphelper::makePropertyValue(sTooltipLabel
, pIter
->second
.aTooltipLabel
),
285 comphelper::makePropertyValue(sTargetURL
, pIter
->second
.aTargetURL
),
286 comphelper::makePropertyValue(sIsExperimental
, pIter
->second
.bIsExperimental
)
288 return Any( aPropSeq
);
293 void ConfigurationAccess_UICommand::impl_fill(const Reference
< XNameAccess
>& _xConfigAccess
,bool _bPopup
,
294 std::vector
< OUString
>& aImageCommandVector
,
295 std::vector
< OUString
>& aImageRotateVector
,
296 std::vector
< OUString
>& aImageMirrorVector
)
298 if ( !_xConfigAccess
.is() )
301 Sequence
< OUString
> aNameSeq
= _xConfigAccess
->getElementNames();
302 const sal_Int32 nCount
= aNameSeq
.getLength();
303 for ( sal_Int32 i
= 0; i
< nCount
; i
++ )
307 Reference
< XNameAccess
> xNameAccess(_xConfigAccess
->getByName( aNameSeq
[i
] ),UNO_QUERY
);
308 if ( xNameAccess
.is() )
310 CmdToInfoMap aCmdToInfo
;
312 aCmdToInfo
.bPopup
= _bPopup
;
313 xNameAccess
->getByName( "Label" ) >>= aCmdToInfo
.aLabel
;
314 xNameAccess
->getByName( "ContextLabel" ) >>= aCmdToInfo
.aContextLabel
;
315 xNameAccess
->getByName( "PopupLabel" ) >>= aCmdToInfo
.aPopupLabel
;
316 xNameAccess
->getByName( "TooltipLabel" ) >>= aCmdToInfo
.aTooltipLabel
;
317 xNameAccess
->getByName( "TargetURL" ) >>= aCmdToInfo
.aTargetURL
;
318 xNameAccess
->getByName( "IsExperimental" ) >>= aCmdToInfo
.bIsExperimental
;
319 xNameAccess
->getByName( m_aPropProperties
) >>= aCmdToInfo
.nProperties
;
321 m_aCmdInfoCache
.emplace( aNameSeq
[i
], aCmdToInfo
);
323 if ( aCmdToInfo
.nProperties
& COMMAND_PROPERTY_IMAGE
)
324 aImageCommandVector
.push_back( aNameSeq
[i
] );
325 if ( aCmdToInfo
.nProperties
& COMMAND_PROPERTY_ROTATE
)
326 aImageRotateVector
.push_back( aNameSeq
[i
] );
327 if ( aCmdToInfo
.nProperties
& COMMAND_PROPERTY_MIRROR
)
328 aImageMirrorVector
.push_back( aNameSeq
[i
] );
331 catch (const css::lang::WrappedTargetException
&)
334 catch (const css::container::NoSuchElementException
&)
339 void ConfigurationAccess_UICommand::fillCache()
342 if ( m_bCacheFilled
)
345 std::vector
< OUString
> aImageCommandVector
;
346 std::vector
< OUString
> aImageRotateVector
;
347 std::vector
< OUString
> aImageMirrorVector
;
349 impl_fill(m_xConfigAccess
,false,aImageCommandVector
,aImageRotateVector
,aImageMirrorVector
);
350 impl_fill(m_xConfigAccessPopups
,true,aImageCommandVector
,aImageRotateVector
,aImageMirrorVector
);
351 // Create cached sequences for fast retrieving
352 m_aCommandImageList
= comphelper::containerToSequence( aImageCommandVector
);
353 m_aCommandRotateImageList
= comphelper::containerToSequence( aImageRotateVector
);
354 m_aCommandMirrorImageList
= comphelper::containerToSequence( aImageMirrorVector
);
356 m_bCacheFilled
= true;
359 void ConfigurationAccess_UICommand::addGenericInfoToCache()
361 if ( !m_xGenericUICommands
.is() || m_bGenericDataRetrieved
)
364 Sequence
< OUString
> aCommandNameSeq
;
367 if ( m_xGenericUICommands
->getByName(
368 UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDROTATEIMAGELIST
) >>= aCommandNameSeq
)
369 m_aCommandRotateImageList
= comphelper::concatSequences
< OUString
>( m_aCommandRotateImageList
, aCommandNameSeq
);
371 catch (const RuntimeException
&)
375 catch (const Exception
&)
381 if ( m_xGenericUICommands
->getByName(
382 UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDMIRRORIMAGELIST
) >>= aCommandNameSeq
)
383 m_aCommandMirrorImageList
= comphelper::concatSequences
< OUString
>( m_aCommandMirrorImageList
, aCommandNameSeq
);
385 catch (const RuntimeException
&)
389 catch (const Exception
&)
393 m_bGenericDataRetrieved
= true;
396 Any
ConfigurationAccess_UICommand::getInfoFromCommand( const OUString
& rCommandURL
)
402 a
= getSequenceFromCache( rCommandURL
);
405 // First try to ask our global commands configuration access. It also caches maybe
406 // we find the entry in its cache first.
407 if ( m_xGenericUICommands
.is() && m_xGenericUICommands
->hasByName( rCommandURL
) )
411 return m_xGenericUICommands
->getByName( rCommandURL
);
413 catch (const css::lang::WrappedTargetException
&)
416 catch (const css::container::NoSuchElementException
&)
422 catch (const css::container::NoSuchElementException
&)
425 catch (const css::lang::WrappedTargetException
&)
432 Sequence
< OUString
> ConfigurationAccess_UICommand::getAllCommands()
435 std::unique_lock
g(m_aMutex
);
437 if ( !m_bConfigAccessInitialized
)
439 initializeConfigAccess();
440 m_bConfigAccessInitialized
= true;
444 if ( m_xConfigAccess
.is() )
448 Sequence
< OUString
> aNameSeq
= m_xConfigAccess
->getElementNames();
450 if ( m_xGenericUICommands
.is() )
452 // Create concat list of supported user interface commands of the module
453 Sequence
< OUString
> aGenericNameSeq
= m_xGenericUICommands
->getElementNames();
454 sal_uInt32 nCount1
= aNameSeq
.getLength();
455 sal_uInt32 nCount2
= aGenericNameSeq
.getLength();
457 aNameSeq
.realloc( nCount1
+ nCount2
);
458 OUString
* pNameSeq
= aNameSeq
.getArray();
459 const OUString
* pGenericSeq
= aGenericNameSeq
.getConstArray();
460 for ( sal_uInt32 i
= 0; i
< nCount2
; i
++ )
461 pNameSeq
[nCount1
+i
] = pGenericSeq
[i
];
466 catch (const css::container::NoSuchElementException
&)
469 catch (const css::lang::WrappedTargetException
&)
474 return Sequence
< OUString
>();
477 void ConfigurationAccess_UICommand::initializeConfigAccess()
481 Sequence
<Any
> aArgs(comphelper::InitAnyPropertySequence(
483 {"nodepath", Any(m_aConfigCmdAccess
)}
485 m_xConfigAccess
.set( m_xConfigProvider
->createInstanceWithArguments(
486 "com.sun.star.configuration.ConfigurationAccess", aArgs
),UNO_QUERY
);
487 if ( m_xConfigAccess
.is() )
489 // Add as container listener
490 Reference
< XContainer
> xContainer( m_xConfigAccess
, UNO_QUERY
);
491 if ( xContainer
.is() )
493 m_xConfigListener
= new WeakContainerListener(this);
494 xContainer
->addContainerListener(m_xConfigListener
);
498 Sequence
<Any
> aArgs2(comphelper::InitAnyPropertySequence(
500 {"nodepath", Any(m_aConfigPopupAccess
)}
502 m_xConfigAccessPopups
.set( m_xConfigProvider
->createInstanceWithArguments(
503 "com.sun.star.configuration.ConfigurationAccess", aArgs2
),UNO_QUERY
);
504 if ( m_xConfigAccessPopups
.is() )
506 // Add as container listener
507 Reference
< XContainer
> xContainer( m_xConfigAccessPopups
, UNO_QUERY
);
508 if ( xContainer
.is() )
510 m_xConfigAccessListener
= new WeakContainerListener(this);
511 xContainer
->addContainerListener(m_xConfigAccessListener
);
515 catch (const WrappedTargetException
&)
518 catch (const Exception
&)
523 // container.XContainerListener
524 void SAL_CALL
ConfigurationAccess_UICommand::elementInserted( const ContainerEvent
& )
526 std::unique_lock
g(m_aMutex
);
527 m_bCacheFilled
= false;
531 void SAL_CALL
ConfigurationAccess_UICommand::elementRemoved( const ContainerEvent
& )
533 std::unique_lock
g(m_aMutex
);
534 m_bCacheFilled
= false;
538 void SAL_CALL
ConfigurationAccess_UICommand::elementReplaced( const ContainerEvent
& )
540 std::unique_lock
g(m_aMutex
);
541 m_bCacheFilled
= false;
545 // lang.XEventListener
546 void SAL_CALL
ConfigurationAccess_UICommand::disposing( const EventObject
& aEvent
)
549 // remove our reference to the config access
550 std::unique_lock
g(m_aMutex
);
552 Reference
< XInterface
> xIfac1( aEvent
.Source
, UNO_QUERY
);
553 Reference
< XInterface
> xIfac2( m_xConfigAccess
, UNO_QUERY
);
554 if ( xIfac1
== xIfac2
)
555 m_xConfigAccess
.clear();
558 xIfac1
.set( m_xConfigAccessPopups
, UNO_QUERY
);
559 if ( xIfac1
== xIfac2
)
560 m_xConfigAccessPopups
.clear();
564 void UICommandDescription::ensureGenericUICommandsForLanguage(const LanguageTag
& rLanguage
)
566 auto xGenericUICommands
= m_xGenericUICommands
.find(rLanguage
);
567 if (xGenericUICommands
== m_xGenericUICommands
.end())
569 Reference
< XNameAccess
> xEmpty
;
570 m_xGenericUICommands
[rLanguage
] = new ConfigurationAccess_UICommand( u
"GenericCommands", xEmpty
, m_xContext
);
574 UICommandDescription::UICommandDescription(const Reference
< XComponentContext
>& rxContext
)
575 : m_aPrivateResourceURL(PRIVATE_RESOURCE_URL
)
576 , m_xContext(rxContext
)
578 SvtSysLocale aSysLocale
;
579 const LanguageTag
& rCurrentLanguage
= aSysLocale
.GetUILanguageTag();
581 ensureGenericUICommandsForLanguage(rCurrentLanguage
);
583 impl_fillElements("ooSetupFactoryCommandConfigRef");
585 // insert generic commands
586 auto& rMap
= m_aUICommandsHashMap
[rCurrentLanguage
];
587 UICommandsHashMap::iterator pIter
= rMap
.find( "GenericCommands" );
588 if ( pIter
!= rMap
.end() )
589 pIter
->second
= m_xGenericUICommands
[rCurrentLanguage
];
592 UICommandDescription::UICommandDescription(const Reference
< XComponentContext
>& rxContext
, bool)
593 : m_xContext(rxContext
)
597 UICommandDescription::~UICommandDescription()
599 std::unique_lock
g(m_aMutex
);
600 m_aModuleToCommandFileMap
.clear();
601 m_aUICommandsHashMap
.clear();
602 m_xGenericUICommands
.clear();
604 void UICommandDescription::impl_fillElements(const char* _pName
)
606 m_xModuleManager
.set( ModuleManager::create( m_xContext
) );
607 const Sequence
< OUString
> aElementNames
= m_xModuleManager
->getElementNames();
609 SvtSysLocale aSysLocale
;
611 for ( OUString
const & aModuleIdentifier
: aElementNames
)
613 Sequence
< PropertyValue
> aSeq
;
614 if ( m_xModuleManager
->getByName( aModuleIdentifier
) >>= aSeq
)
616 OUString aCommandStr
;
617 for ( PropertyValue
const & prop
: std::as_const(aSeq
) )
619 if ( prop
.Name
.equalsAscii(_pName
) )
621 prop
.Value
>>= aCommandStr
;
626 // Create first mapping ModuleIdentifier ==> Command File
627 m_aModuleToCommandFileMap
.emplace( aModuleIdentifier
, aCommandStr
);
629 // Create second mapping Command File ==> commands instance
630 const LanguageTag
& rCurrentLanguage
= aSysLocale
.GetUILanguageTag();
631 auto& rMap
= m_aUICommandsHashMap
[rCurrentLanguage
];
632 UICommandsHashMap::iterator pIter
= rMap
.find( aCommandStr
);
633 if ( pIter
== rMap
.end() )
634 rMap
.emplace( aCommandStr
, Reference
< XNameAccess
>() );
636 } // for ( sal_Int32 i = 0; i < aElementNames.(); i++ )
639 Any SAL_CALL
UICommandDescription::getByName( const OUString
& aName
)
641 SvtSysLocale aSysLocale
;
642 const LanguageTag
& rCurrentLanguage
= aSysLocale
.GetUILanguageTag();
645 std::unique_lock
g(m_aMutex
);
647 ModuleToCommandFileMap::const_iterator pM2CIter
= m_aModuleToCommandFileMap
.find( aName
);
648 if ( pM2CIter
!= m_aModuleToCommandFileMap
.end() )
650 OUString
aCommandFile( pM2CIter
->second
);
651 auto pMapIter
= m_aUICommandsHashMap
.find( rCurrentLanguage
);
652 if ( pMapIter
== m_aUICommandsHashMap
.end() )
653 impl_fillElements("ooSetupFactoryCommandConfigRef");
655 auto& rMap
= m_aUICommandsHashMap
[rCurrentLanguage
];
656 UICommandsHashMap::iterator pIter
= rMap
.find( aCommandFile
);
657 if ( pIter
!= rMap
.end() )
659 if ( pIter
->second
.is() )
663 ensureGenericUICommandsForLanguage(rCurrentLanguage
);
665 Reference
< XNameAccess
> xUICommands
= new ConfigurationAccess_UICommand( aCommandFile
,
666 m_xGenericUICommands
[rCurrentLanguage
],
668 pIter
->second
= xUICommands
;
673 else if ( !m_aPrivateResourceURL
.isEmpty() && aName
.startsWith( m_aPrivateResourceURL
) )
675 ensureGenericUICommandsForLanguage(rCurrentLanguage
);
677 // special keys to retrieve information about a set of commands
678 return m_xGenericUICommands
[rCurrentLanguage
]->getByName( aName
);
682 throw NoSuchElementException();
688 Sequence
< OUString
> SAL_CALL
UICommandDescription::getElementNames()
690 std::unique_lock
g(m_aMutex
);
692 return comphelper::mapKeysToSequence( m_aModuleToCommandFileMap
);
695 sal_Bool SAL_CALL
UICommandDescription::hasByName( const OUString
& aName
)
697 std::unique_lock
g(m_aMutex
);
699 ModuleToCommandFileMap::const_iterator pIter
= m_aModuleToCommandFileMap
.find( aName
);
700 return ( pIter
!= m_aModuleToCommandFileMap
.end() );
704 Type SAL_CALL
UICommandDescription::getElementType()
706 return cppu::UnoType
<XNameAccess
>::get();
709 sal_Bool SAL_CALL
UICommandDescription::hasElements()
711 // generic UI commands are always available!
715 } // namespace framework
717 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
718 com_sun_star_comp_framework_UICommandDescription_get_implementation(
719 css::uno::XComponentContext
*context
,
720 css::uno::Sequence
<css::uno::Any
> const &)
722 return cppu::acquire(new framework::UICommandDescription(context
));
725 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */