Kaydet (Commit) eb179971 authored tarafından Matúš Kukan's avatar Matúš Kukan

cleaning the code a bit

Change-Id: I4cc9c16fb79f669ae70d10a50ace3943075edd46
üst 5691ef0b
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/ui/XUIElementFactory.hpp> #include <com/sun/star/ui/XUIElementFactory.hpp>
#include <com/sun/star/frame/XModuleManager2.hpp>
#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/XComponentContext.hpp>
#include <toolkit/awt/vclxmenu.hxx> #include <toolkit/awt/vclxmenu.hxx>
...@@ -67,11 +66,10 @@ typedef ::cppu::WeakImplHelper2< ...@@ -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 ); 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 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* _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::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); ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext);
protected: protected:
......
...@@ -58,21 +58,17 @@ Reference< XUIElement > SAL_CALL MenuBarFactory::createUIElement( ...@@ -58,21 +58,17 @@ Reference< XUIElement > SAL_CALL MenuBarFactory::createUIElement(
const Sequence< PropertyValue >& Args ) const Sequence< PropertyValue >& Args )
throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ) throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{ {
// SAFE Reference< ::com::sun::star::ui::XUIElement > xMenuBar(
SolarMutexClearableGuard g; static_cast<OWeakObject *>(new MenuBarWrapper(m_xContext)), UNO_QUERY);
MenuBarWrapper* pMenuBarWrapper = new MenuBarWrapper( m_xContext ); CreateUIElement(ResourceURL, Args, "MenuOnly", "private:resource/menubar/", xMenuBar, 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);
return xMenuBar; return xMenuBar;
} }
void MenuBarFactory::CreateUIElement(const OUString& ResourceURL void MenuBarFactory::CreateUIElement(const OUString& ResourceURL
, const Sequence< PropertyValue >& Args ,const Sequence< PropertyValue >& Args
,const char* _pExtraMode ,const char* _pExtraMode
,const char* _pAsciiName ,const OUString& ResourceType
,const Reference< ::com::sun::star::ui::XUIElement >& _xMenuBar ,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) ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext)
{ {
Reference< XUIConfigurationManager > xCfgMgr; Reference< XUIConfigurationManager > xCfgMgr;
...@@ -95,7 +91,7 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL ...@@ -95,7 +91,7 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL
else if ( _pExtraMode && Args[n].Name.equalsAscii( _pExtraMode )) else if ( _pExtraMode && Args[n].Name.equalsAscii( _pExtraMode ))
Args[n].Value >>= bExtraMode; Args[n].Value >>= bExtraMode;
} }
if ( aResourceURL.indexOf( OUString::createFromAscii(_pAsciiName)) != 0 ) if (!aResourceURL.startsWith(ResourceType))
throw IllegalArgumentException(); throw IllegalArgumentException();
// Identify frame and determine document based ui configuration manager/module ui configuration manager // Identify frame and determine document based ui configuration manager/module ui configuration manager
...@@ -120,7 +116,9 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL ...@@ -120,7 +116,9 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL
if ( !bHasSettings ) 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() ) if ( !aModuleIdentifier.isEmpty() )
{ {
Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier = Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier =
......
...@@ -77,14 +77,10 @@ Reference< XUIElement > SAL_CALL StatusBarFactory::createUIElement( ...@@ -77,14 +77,10 @@ Reference< XUIElement > SAL_CALL StatusBarFactory::createUIElement(
const Sequence< PropertyValue >& Args ) const Sequence< PropertyValue >& Args )
throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ) throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{ {
// SAFE Reference< ::com::sun::star::ui::XUIElement > xStatusBar(
SolarMutexClearableGuard g; static_cast<OWeakObject *>(new StatusBarWrapper(m_xContext)), UNO_QUERY);
StatusBarWrapper* pWrapper = new StatusBarWrapper( m_xContext ); MenuBarFactory::CreateUIElement(ResourceURL, Args, NULL, "private:resource/statusbar/", xStatusBar, m_xContext);
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY ); return xStatusBar;
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;
} }
} }
......
...@@ -77,13 +77,10 @@ Reference< XUIElement > SAL_CALL ToolBarFactory::createUIElement( ...@@ -77,13 +77,10 @@ Reference< XUIElement > SAL_CALL ToolBarFactory::createUIElement(
const Sequence< PropertyValue >& Args ) const Sequence< PropertyValue >& Args )
throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ) throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException )
{ {
SolarMutexClearableGuard g; Reference< ::com::sun::star::ui::XUIElement > xToolBar(
ToolBarWrapper* pWrapper = new ToolBarWrapper( m_xContext ); static_cast<OWeakObject *>(new ToolBarWrapper(m_xContext)), UNO_QUERY);
Reference< ::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pWrapper, UNO_QUERY ); CreateUIElement(ResourceURL, Args, "PopupMode", "private:resource/toolbar/", xToolBar, m_xContext);
Reference< ::com::sun::star::frame::XModuleManager2 > xModuleManager = ModuleManager::create(m_xContext); return xToolBar;
g.clear();
CreateUIElement(ResourceURL, Args, "PopupMode", "private:resource/toolbar/", xMenuBar, xModuleManager, m_xContext);
return xMenuBar;
} }
} }
......
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