Kaydet (Commit) 0c48c809 authored tarafından Samuel Mehrbrodt's avatar Samuel Mehrbrodt

tdf#95845 Use CommandInfoProvider to receive command properties

Change-Id: I41f9a661b7a5b355e50910d7f58f0d9d55dc62a6
üst 16f85dc4
...@@ -773,62 +773,8 @@ void ToolBarManager::RemoveControllers() ...@@ -773,62 +773,8 @@ void ToolBarManager::RemoveControllers()
m_aControllerMap.clear(); m_aControllerMap.clear();
} }
uno::Sequence< beans::PropertyValue > ToolBarManager::GetPropsForCommand( const OUString& rCmdURL )
{
Sequence< PropertyValue > aPropSeq;
// Retrieve properties for command
try
{
if ( !m_bModuleIdentified )
{
Reference< XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext );
Reference< XInterface > xIfac( m_xFrame, UNO_QUERY );
m_bModuleIdentified = true;
m_aModuleIdentifier = xModuleManager->identify( xIfac );
if ( !m_aModuleIdentifier.isEmpty() )
{
Reference< XNameAccess > xNameAccess = frame::theUICommandDescription::get( m_xContext );
xNameAccess->getByName( m_aModuleIdentifier ) >>= m_xUICommandLabels;
}
}
if ( m_xUICommandLabels.is() )
{
if ( !rCmdURL.isEmpty() )
m_xUICommandLabels->getByName( rCmdURL ) >>= aPropSeq;
}
}
catch (const Exception&)
{
}
return aPropSeq;
}
sal_Int32 ToolBarManager::RetrievePropertiesFromCommand( const OUString& aCmdURL )
{
sal_Int32 nProperties(0);
Sequence< PropertyValue > aPropSeq;
// Retrieve popup menu labels
aPropSeq = GetPropsForCommand( aCmdURL );
for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
{
if ( aPropSeq[i].Name == "Properties" )
{
aPropSeq[i].Value >>= nProperties;
break;
}
}
return nProperties;
}
void ToolBarManager::CreateControllers() void ToolBarManager::CreateControllers()
{ {
Reference< XWindow > xToolbarWindow = VCLUnoHelper::GetInterface( m_pToolBar ); Reference< XWindow > xToolbarWindow = VCLUnoHelper::GetInterface( m_pToolBar );
css::util::URL aURL; css::util::URL aURL;
...@@ -932,7 +878,7 @@ void ToolBarManager::CreateControllers() ...@@ -932,7 +878,7 @@ void ToolBarManager::CreateControllers()
new GenericToolbarController( m_xContext, m_xFrame, m_pToolBar, nId, aCommandURL )); new GenericToolbarController( m_xContext, m_xFrame, m_pToolBar, nId, aCommandURL ));
// Accessibility support: Set toggle button role for specific commands // Accessibility support: Set toggle button role for specific commands
sal_Int32 nProps = RetrievePropertiesFromCommand( aCommandURL ); sal_Int32 nProps = vcl::CommandInfoProvider::Instance().GetPropertiesForCommand(aCommandURL, m_xFrame);
if ( nProps & UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON ) if ( nProps & UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON )
m_pToolBar->SetItemBits( nId, m_pToolBar->GetItemBits( nId ) | ToolBoxItemBits::CHECKABLE ); m_pToolBar->SetItemBits( nId, m_pToolBar->GetItemBits( nId ) | ToolBoxItemBits::CHECKABLE );
} }
......
...@@ -84,6 +84,10 @@ public: ...@@ -84,6 +84,10 @@ public:
bool bLarge, bool bLarge,
const css::uno::Reference<css::frame::XFrame>& rxFrame); const css::uno::Reference<css::frame::XFrame>& rxFrame);
sal_Int32 GetPropertiesForCommand(
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
/** Do not call. Should be part of a local and hidden interface. /** Do not call. Should be part of a local and hidden interface.
*/ */
void SetFrame (const css::uno::Reference<css::frame::XFrame>& rxFrame); void SetFrame (const css::uno::Reference<css::frame::XFrame>& rxFrame);
......
...@@ -214,6 +214,25 @@ Image CommandInfoProvider::GetImageForCommand(const OUString& rsCommandName, boo ...@@ -214,6 +214,25 @@ Image CommandInfoProvider::GetImageForCommand(const OUString& rsCommandName, boo
return Image(); return Image();
} }
sal_Int32 CommandInfoProvider::GetPropertiesForCommand (
const OUString& rsCommandName,
const Reference<frame::XFrame>& rxFrame)
{
SetFrame(rxFrame);
const Sequence<beans::PropertyValue> aProperties (GetCommandProperties(rsCommandName));
for (sal_Int32 nIndex=0; nIndex<aProperties.getLength(); ++nIndex)
{
if (aProperties[nIndex].Name == "Properties")
{
sal_Int32 nValue;
aProperties[nIndex].Value >>= nValue;
return nValue;
}
}
return 0;
}
void CommandInfoProvider::SetFrame (const Reference<frame::XFrame>& rxFrame) void CommandInfoProvider::SetFrame (const Reference<frame::XFrame>& rxFrame)
{ {
if (rxFrame != mxCachedDataFrame) if (rxFrame != mxCachedDataFrame)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment