cleaning the code a bit

Change-Id: I4cc9c16fb79f669ae70d10a50ace3943075edd46
This commit is contained in:
Matúš Kukan
2014-02-12 12:01:00 +01:00
parent 5691ef0b4f
commit eb1799714c
4 changed files with 20 additions and 31 deletions

View File

@@ -23,7 +23,6 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/ui/XUIElementFactory.hpp>
#include <com/sun/star/frame/XModuleManager2.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <toolkit/awt/vclxmenu.hxx>
@@ -67,11 +66,10 @@ typedef ::cppu::WeakImplHelper2<
virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Args ) throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
static void CreateUIElement(const OUString& ResourceURL
, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Args
,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Args
,const char* _pExtraMode
,const char* _pAsciiName
,const OUString& ResourceType
,const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement >& _xMenuBar
,const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >& _xModuleManager
,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext);
protected:

View File

@@ -58,21 +58,17 @@ Reference< XUIElement > SAL_CALL MenuBarFactory::createUIElement(
const Sequence< PropertyValue >& Args )
throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{
// SAFE
SolarMutexClearableGuard g;
MenuBarWrapper* pMenuBarWrapper = new MenuBarWrapper( m_xContext );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pMenuBarWrapper, UNO_QUERY );
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext );
g.clear();
CreateUIElement(ResourceURL, Args, "MenuOnly", "private:resource/menubar/", xMenuBar, xModuleManager, m_xContext);
Reference< ::com::sun::star::ui::XUIElement > xMenuBar(
static_cast<OWeakObject *>(new MenuBarWrapper(m_xContext)), UNO_QUERY);
CreateUIElement(ResourceURL, Args, "MenuOnly", "private:resource/menubar/", xMenuBar, m_xContext);
return xMenuBar;
}
void MenuBarFactory::CreateUIElement(const OUString& ResourceURL
, const Sequence< PropertyValue >& Args
,const Sequence< PropertyValue >& Args
,const char* _pExtraMode
,const char* _pAsciiName
,const OUString& ResourceType
,const Reference< ::com::sun::star::ui::XUIElement >& _xMenuBar
,const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >& _xModuleManager
,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext)
{
Reference< XUIConfigurationManager > xCfgMgr;
@@ -95,7 +91,7 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL
else if ( _pExtraMode && Args[n].Name.equalsAscii( _pExtraMode ))
Args[n].Value >>= bExtraMode;
}
if ( aResourceURL.indexOf( OUString::createFromAscii(_pAsciiName)) != 0 )
if (!aResourceURL.startsWith(ResourceType))
throw IllegalArgumentException();
// Identify frame and determine document based ui configuration manager/module ui configuration manager
@@ -120,7 +116,9 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL
if ( !bHasSettings )
{
OUString aModuleIdentifier = _xModuleManager->identify( xFrame );
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager =
ModuleManager::create( _rxContext );
OUString aModuleIdentifier = xModuleManager->identify( xFrame );
if ( !aModuleIdentifier.isEmpty() )
{
Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier =

View File

@@ -77,14 +77,10 @@ Reference< XUIElement > SAL_CALL StatusBarFactory::createUIElement(
const Sequence< PropertyValue >& Args )
throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{
// SAFE
SolarMutexClearableGuard g;
StatusBarWrapper* pWrapper = new StatusBarWrapper( m_xContext );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY );
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext );
g.clear();
MenuBarFactory::CreateUIElement(ResourceURL, Args, NULL, "private:resource/statusbar/", xMenuBar, xModuleManager, m_xContext );
return xMenuBar;
Reference< ::com::sun::star::ui::XUIElement > xStatusBar(
static_cast<OWeakObject *>(new StatusBarWrapper(m_xContext)), UNO_QUERY);
MenuBarFactory::CreateUIElement(ResourceURL, Args, NULL, "private:resource/statusbar/", xStatusBar, m_xContext);
return xStatusBar;
}
}

View File

@@ -77,13 +77,10 @@ Reference< XUIElement > SAL_CALL ToolBarFactory::createUIElement(
const Sequence< PropertyValue >& Args )
throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{
SolarMutexClearableGuard g;
ToolBarWrapper* pWrapper = new ToolBarWrapper( m_xContext );
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY );
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = ModuleManager::create(m_xContext);
g.clear();
CreateUIElement(ResourceURL, Args, "PopupMode", "private:resource/toolbar/", xMenuBar, xModuleManager, m_xContext);
return xMenuBar;
Reference< ::com::sun::star::ui::XUIElement > xToolBar(
static_cast<OWeakObject *>(new ToolBarWrapper(m_xContext)), UNO_QUERY);
CreateUIElement(ResourceURL, Args, "PopupMode", "private:resource/toolbar/", xToolBar, m_xContext);
return xToolBar;
}
}