Kaydet (Commit) a659ac90 authored tarafından Ariel Constenla-Haile's avatar Ariel Constenla-Haile Kaydeden (comit) Caolán McNamara

framework::PopupMenuController clean-up

Changed the name, it is not a PopupMenuController, but a ToolbarController that
shows a PopupMenu filled at runtime by a PopupMenuController

Make it a base class for other ToolbarController components, there is no sense
to make it a component by itself

Use this base class for three new pure UNO ToolbarController's

(cherry picked from commit 9d101505)

Conflicts:
	framework/Library_fwk.mk
	framework/inc/uielement/popupmenucontroller.hxx
	framework/source/uielement/popupmenucontroller.cxx
	officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu

Change-Id: I2f5ec06df098d65ffaa17a8f7f6f3ea8774b43c3
üst 44b2fb61
......@@ -104,11 +104,11 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\
framework/source/loadenv/loadenv \
framework/source/loadenv/targethelper \
framework/source/register/registerservices \
framework/source/services/ContextChangeEventMultiplexer \
framework/source/services/autorecovery \
framework/source/services/backingcomp \
framework/source/services/backingwindow \
framework/source/services/desktop \
framework/source/services/ContextChangeEventMultiplexer \
framework/source/services/frame \
framework/source/services/modulemanager \
framework/source/services/pathsettings \
......@@ -143,6 +143,7 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\
framework/source/uielement/menubarmerger \
framework/source/uielement/menubarwrapper \
framework/source/uielement/objectmenucontroller \
framework/source/uielement/popuptoolbarcontroller \
framework/source/uielement/progressbarwrapper \
framework/source/uielement/recentfilesmenucontroller \
framework/source/uielement/spinfieldtoolbarcontroller \
......@@ -161,8 +162,8 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\
framework/source/uifactory/factoryconfiguration \
framework/source/uifactory/menubarfactory \
framework/source/uifactory/statusbarfactory \
framework/source/uifactory/uicontrollerfactory \
framework/source/uifactory/toolboxfactory \
framework/source/uifactory/uicontrollerfactory \
framework/source/uifactory/uielementfactorymanager \
framework/source/uifactory/windowcontentfactorymanager \
framework/source/xml/acceleratorconfigurationreader \
......
......@@ -68,7 +68,6 @@ $(eval $(call gb_Library_add_exception_objects,fwl,\
framework/source/uielement/langselectionmenucontroller \
framework/source/uielement/macrosmenucontroller \
framework/source/uielement/newmenucontroller \
framework/source/uielement/popupmenucontroller \
framework/source/uielement/toolbarsmenucontroller \
))
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef __FRAMEWORK_POPUPMENUCONTROLLER_HXX_
#define __FRAMEWORK_POPUPMENUCONTROLLER_HXX_
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/frame/XPopupMenuController.hpp>
#include "svtools/toolboxcontroller.hxx"
#include "boost/scoped_ptr.hpp"
#include <macros/xserviceinfo.hxx>
class Window;
namespace framework
{
class PopupMenuControllerImpl;
class PopupMenuController : public svt::ToolboxController, public ::com::sun::star::lang::XServiceInfo
{
public:
PopupMenuController( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext );
~PopupMenuController();
// XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL acquire() throw ();
virtual void SAL_CALL release() throw ();
// XServiceInfo
DECLARE_XSERVICEINFO
// XComponent
virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
// XStatusListener
virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
// XToolbarController
virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createItemWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& Parent ) throw (::com::sun::star::uno::RuntimeException);
bool CreatePopupMenuController() throw (::com::sun::star::uno::Exception);
::com::sun::star::uno::Reference< ::com::sun::star::frame::XPopupMenuController > mxPopupMenuController;
::com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu > mxPopupMenu;
};
} // namespace framework
#endif // __FRAMEWORK_POPUPMENUCONTROLLER_HXX_
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef __FRAMEWORK_UIELEMENT_POPUPMENU_TOOLBARCONTROLLER_HXX__
#define __FRAMEWORK_UIELEMENT_POPUPMENU_TOOLBARCONTROLLER_HXX__
#include <com/sun/star/awt/XPopupMenu.hpp>
#include <com/sun/star/frame/XPopupMenuController.hpp>
#include <com/sun/star/frame/XUIControllerFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/implbase1.hxx>
#include <macros/xserviceinfo.hxx>
#include <svtools/toolboxcontroller.hxx>
namespace framework
{
class PopupMenuToolbarController : public svt::ToolboxController
{
public:
virtual ~PopupMenuToolbarController();
// XComponent
virtual void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException );
// XInitialization
virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
// XToolbarController
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException);
// XStatusListener
virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& rEvent ) throw ( ::com::sun::star::uno::RuntimeException );
protected:
PopupMenuToolbarController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
const OUString &rPopupCommand = OUString() );
virtual void functionExecuted( const OUString &rCommand );
virtual sal_uInt16 getDropDownStyle() const;
void createPopupMenuController();
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
sal_Bool m_bHasController;
com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu > m_xPopupMenu;
private:
OUString m_aPopupCommand;
com::sun::star::uno::Reference< com::sun::star::frame::XUIControllerFactory > m_xPopupMenuFactory;
com::sun::star::uno::Reference< com::sun::star::frame::XPopupMenuController > m_xPopupMenuController;
};
class OpenToolbarController : public PopupMenuToolbarController
{
public:
OpenToolbarController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
// XServiceInfo
DECLARE_XSERVICEINFO
};
class NewToolbarController : public PopupMenuToolbarController
{
public:
NewToolbarController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
// XServiceInfo
DECLARE_XSERVICEINFO
private:
void functionExecuted( const OUString &rCommand );
void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& rEvent ) throw ( ::com::sun::star::uno::RuntimeException );
void setItemImage( const OUString &rCommand );
};
class WizardsToolbarController : public PopupMenuToolbarController
{
public:
WizardsToolbarController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
// XServiceInfo
DECLARE_XSERVICEINFO
private:
sal_uInt16 getDropDownStyle() const;
};
}
#endif
......@@ -71,6 +71,7 @@
#include <services/substitutepathvars.hxx>
#include <services/pathsettings.hxx>
#include <services/ContextChangeEventMultiplexer.hxx>
#include <uielement/popuptoolbarcontroller.hxx>
COMPONENTGETFACTORY ( fwk,
IFFACTORY( ::framework::URLTransformer ) else
......@@ -112,7 +113,10 @@ COMPONENTGETFACTORY ( fwk,
IFFACTORY( ::framework::TabWindowService ) else
IFFACTORY( ::framework::SubstitutePathVariables ) else
IFFACTORY( ::framework::PathSettings ) else
IFFACTORY( ::framework::ContextChangeEventMultiplexer )
IFFACTORY( ::framework::ContextChangeEventMultiplexer ) else
IFFACTORY( ::framework::OpenToolbarController ) else
IFFACTORY( ::framework::NewToolbarController ) else
IFFACTORY( ::framework::WizardsToolbarController )
)
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -50,7 +50,6 @@
#include <uielement/macrosmenucontroller.hxx>
#include <uielement/newmenucontroller.hxx>
#include <uielement/toolbarsmenucontroller.hxx>
#include <uielement/popupmenucontroller.hxx>
COMPONENTGETFACTORY ( fwl,
IFFACTORY( ::framework::MediaTypeDetectionHelper )
......@@ -70,8 +69,7 @@ COMPONENTGETFACTORY ( fwl,
IFFACTORY( ::framework::FooterMenuController ) else
IFFACTORY( ::framework::HeaderMenuController ) else
IFFACTORY( ::framework::LanguageSelectionMenuController ) else
IFFACTORY( ::framework::Oxt_Handler ) else
IFFACTORY( ::framework::PopupMenuController )
IFFACTORY( ::framework::Oxt_Handler )
)
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <com/sun/star/awt/PopupMenu.hpp>
#include <com/sun/star/frame/PopupMenuControllerFactory.hpp>
#include <com/sun/star/frame/XPopupMenuController.hpp>
#include <toolkit/helper/vclunohelper.hxx>
#include <rtl/ref.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
#include <osl/mutex.hxx>
#include "uielement/popupmenucontroller.hxx"
#include "services.h"
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::beans;
// --------------------------------------------------------------------
namespace framework
{
DEFINE_XSERVICEINFO_MULTISERVICE_2 ( PopupMenuController ,
OWeakObject ,
OUString( "com.sun.star.frame.ToolbarController" ) ,
OUString( "com.sun.star.comp.framework.PopupMenuController" )
)
DEFINE_INIT_SERVICE ( PopupMenuController, {} )
class PopupMenuControllerImpl
{
};
//========================================================================
// class PopupMenuController REMOVE REMOVE REMOVE
//========================================================================
PopupMenuController::PopupMenuController( const Reference< uno::XComponentContext >& rxContext )
: svt::ToolboxController( rxContext, Reference< frame::XFrame >(), OUString() )
{
}
// --------------------------------------------------------------------
PopupMenuController::~PopupMenuController()
{
}
// --------------------------------------------------------------------
// XInterface
// --------------------------------------------------------------------
Any SAL_CALL PopupMenuController::queryInterface( const Type& aType ) throw (RuntimeException)
{
Any a( ToolboxController::queryInterface( aType ) );
if ( a.hasValue() )
return a;
return ::cppu::queryInterface( aType, static_cast< lang::XServiceInfo* >( this ));
}
// --------------------------------------------------------------------
void SAL_CALL PopupMenuController::acquire() throw ()
{
ToolboxController::acquire();
}
// --------------------------------------------------------------------
void SAL_CALL PopupMenuController::release() throw ()
{
ToolboxController::release();
}
// --------------------------------------------------------------------
// XComponent
// --------------------------------------------------------------------
void SAL_CALL PopupMenuController::dispose() throw (RuntimeException)
{
if( mxPopupMenuController.is() )
{
Reference< XComponent > xComponent( mxPopupMenuController, UNO_QUERY );
if( xComponent.is() )
xComponent->dispose();
mxPopupMenuController.clear();
}
mxPopupMenu.clear();
svt::ToolboxController::dispose();
}
// --------------------------------------------------------------------
// XStatusListener
// --------------------------------------------------------------------
void SAL_CALL PopupMenuController::statusChanged( const frame::FeatureStateEvent& rEvent ) throw ( RuntimeException )
{
svt::ToolboxController::statusChanged(rEvent);
enable( rEvent.IsEnabled );
}
// --------------------------------------------------------------------
// XToolbarController
// --------------------------------------------------------------------
void SAL_CALL PopupMenuController::execute( sal_Int16 KeyModifier ) throw (RuntimeException)
{
svt::ToolboxController::execute( KeyModifier );
}
// --------------------------------------------------------------------
void SAL_CALL PopupMenuController::click() throw (RuntimeException)
{
svt::ToolboxController::click();
}
// --------------------------------------------------------------------
void SAL_CALL PopupMenuController::doubleClick() throw (RuntimeException)
{
svt::ToolboxController::doubleClick();
}
// --------------------------------------------------------------------
bool PopupMenuController::CreatePopupMenuController() throw (Exception)
{
Reference< XMultiComponentFactory > xPopupMenuControllerRegistration = PopupMenuControllerFactory::create( m_xContext );
Sequence< Any > aSeq( 2 );
PropertyValue aPropValue;
aPropValue.Name = OUString( "ModuleIdentifier" );
aPropValue.Value <<= getModuleName();
aSeq[0] <<= aPropValue;
aPropValue.Name = OUString( "Frame" );
aPropValue.Value <<= m_xFrame;
aSeq[1] <<= aPropValue;
Reference< XPopupMenuController > xPopupMenuController( xPopupMenuControllerRegistration->createInstanceWithArgumentsAndContext( getCommandURL(), aSeq, m_xContext ), UNO_QUERY );
if ( xPopupMenuController.is() )
{
mxPopupMenuController = xPopupMenuController;
return true;
}
return false;
}
Reference< awt::XWindow > SAL_CALL PopupMenuController::createPopupWindow() throw (RuntimeException)
{
SolarMutexGuard aSolarLock;
Reference< awt::XWindow > xRet;
try
{
ToolBox* pToolBox = dynamic_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) );
if( !pToolBox )
return xRet;
// get selected button
sal_uInt16 nItemId = pToolBox->GetDownItemId();
if( !nItemId )
return xRet;
::Rectangle aRect( pToolBox->GetItemRect( nItemId ) );
if( !mxPopupMenuController.is() && !CreatePopupMenuController() )
return xRet;
if( !mxPopupMenu.is() )
{
mxPopupMenu = awt::PopupMenu::create(m_xContext);
mxPopupMenuController->setPopupMenu( mxPopupMenu );
}
else
{
mxPopupMenuController->updatePopupMenu();
}
pToolBox->SetItemDown( nItemId, sal_True );
Reference< awt::XWindowPeer > xPeer( getParent(), UNO_QUERY_THROW );
mxPopupMenu->execute( xPeer, VCLUnoHelper::ConvertToAWTRect( aRect ), 0 );
pToolBox->SetItemDown( nItemId, sal_False );
}
catch( const Exception& )
{
}
return xRet;
}
// --------------------------------------------------------------------
Reference< awt::XWindow > SAL_CALL PopupMenuController::createItemWindow( const Reference< awt::XWindow >& /*Parent*/ ) throw (RuntimeException)
{
return Reference< awt::XWindow >();
}
// --------------------------------------------------------------------
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -137,4 +137,13 @@
<implementation name="com.sun.star.comp.framework.TabWindowService">
<service name="com.sun.star.ui.dialogs.TabContainerWindow"/>
</implementation>
<implementation name="org.apache.openoffice.comp.framework.OpenToolbarController">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
<implementation name="org.apache.openoffice.comp.framework.NewToolbarController">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
<implementation name="org.apache.openoffice.comp.framework.WizardsToolbarController">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
</component>
......@@ -58,9 +58,6 @@
<implementation name="com.sun.star.comp.framework.OXTFileHandler">
<service name="com.sun.star.frame.ContentHandler"/>
</implementation>
<implementation name="com.sun.star.comp.framework.PopupMenuController">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
<implementation name="com.sun.star.comp.framework.PopupMenuControllerDispatcher">
<service name="com.sun.star.frame.ProtocolHandler"/>
</implementation>
......
......@@ -561,6 +561,39 @@
<value>com.sun.star.report.ReportToolboxController</value>
</prop>
</node>
<node oor:name="org.apache.openoffice.comp.framework.OpenToolbarController" oor:op="replace">
<prop oor:name="Command">
<value>.uno:Open</value>
</prop>
<prop oor:name="Module">
<value/>
</prop>
<prop oor:name="Controller">
<value>org.apache.openoffice.comp.framework.OpenToolbarController</value>
</prop>
</node>
<node oor:name="org.apache.openoffice.comp.framework.NewToolbarController" oor:op="replace">
<prop oor:name="Command">
<value>.uno:AddDirect</value>
</prop>
<prop oor:name="Module">
<value/>
</prop>
<prop oor:name="Controller">
<value>org.apache.openoffice.comp.framework.NewToolbarController</value>
</prop>
</node>
<node oor:name="org.apache.openoffice.comp.framework.WizardsToolbarController" oor:op="replace">
<prop oor:name="Command">
<value>.uno:AutoPilotMenu</value>
</prop>
<prop oor:name="Module">
<value/>
</prop>
<prop oor:name="Controller">
<value>org.apache.openoffice.comp.framework.WizardsToolbarController</value>
</prop>
</node>
</node>
<node oor:name="StatusBar">
<node oor:name="c1" oor:op="replace">
......
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