svt::ToolboxController clean-up
Some small clean-up to use the PopupMenu ToolbarController (cherry picked from commit e1687ce159e787d98f79d29a3d2131cca4b6ec71) Conflicts: svtools/inc/svtools/toolboxcontroller.hxx svtools/source/uno/toolboxcontroller.cxx Change-Id: Ie5e0397c32352d52cf2664bdbab920923e74bd03
This commit is contained in:
parent
f45cad5126
commit
1e85fc5b2d
@ -362,8 +362,14 @@ MenuToolbarController::createPopupWindow() throw (::com::sun::star::uno::Runtime
|
||||
}
|
||||
}
|
||||
|
||||
if ( !pMenu || !m_pToolbar )
|
||||
return NULL;
|
||||
|
||||
OSL_ENSURE ( pMenu->GetItemCount(), "Empty PopupMenu!" );
|
||||
|
||||
::Rectangle aRect( m_pToolbar->GetItemRect( m_nID ) );
|
||||
pMenu->Execute( m_pToolbar, aRect, POPUPMENU_EXECUTE_DOWN );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
} // namespace
|
||||
|
@ -928,6 +928,9 @@ void ToolBarManager::CreateControllers()
|
||||
aPropValue.Name = OUString( "ParentWindow" );
|
||||
aPropValue.Value <<= xToolbarWindow;
|
||||
aPropertyVector.push_back( makeAny( aPropValue ));
|
||||
aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" ));
|
||||
aPropValue.Value = uno::makeAny( nId );
|
||||
aPropertyVector.push_back( uno::makeAny( aPropValue ) );
|
||||
|
||||
if ( nWidth > 0 )
|
||||
{
|
||||
@ -1041,6 +1044,9 @@ void ToolBarManager::CreateControllers()
|
||||
aPropValue.Name = OUString( "ModuleIdentifier" );
|
||||
aPropValue.Value <<= m_aModuleIdentifier;
|
||||
aPropertyVector.push_back( makeAny( aPropValue ));
|
||||
aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" ));
|
||||
aPropValue.Value = uno::makeAny( nId );
|
||||
aPropertyVector.push_back( uno::makeAny( aPropValue ) );
|
||||
|
||||
if ( nWidth > 0 )
|
||||
{
|
||||
@ -1248,9 +1254,12 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
|
||||
try
|
||||
{
|
||||
Reference< XIndexAccess > xMenuContainer;
|
||||
if ( m_xDocUICfgMgr.is() )
|
||||
if ( m_xDocUICfgMgr.is() &&
|
||||
m_xDocUICfgMgr->hasSettings( aCommandURL ) )
|
||||
xMenuContainer = m_xDocUICfgMgr->getSettings( aCommandURL, sal_False );
|
||||
if ( !xMenuContainer.is() && m_xUICfgMgr.is() )
|
||||
if ( !xMenuContainer.is() &&
|
||||
m_xUICfgMgr.is() &&
|
||||
m_xUICfgMgr->hasSettings( aCommandURL ) )
|
||||
xMenuContainer = m_xUICfgMgr->getSettings( aCommandURL, sal_False );
|
||||
if ( xMenuContainer.is() && xMenuContainer->getCount() )
|
||||
{
|
||||
@ -1297,7 +1306,10 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
|
||||
|
||||
sal_uInt16 nItemBits = ConvertStyleToToolboxItemBits( nStyle );
|
||||
if ( aMenuDesc.is() )
|
||||
{
|
||||
m_aMenuMap[ nId ] = aMenuDesc;
|
||||
nItemBits |= TIB_DROPDOWNONLY;
|
||||
}
|
||||
m_pToolBar->InsertItem( nId, aString, nItemBits );
|
||||
m_pToolBar->SetItemCommand( nId, aCommandURL );
|
||||
if ( !aTooltip.isEmpty() )
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <comphelper/property.hxx>
|
||||
#include <comphelper/propertycontainer.hxx>
|
||||
#include <cppuhelper/propshlp.hxx>
|
||||
#include <tools/link.hxx>
|
||||
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
@ -44,7 +45,8 @@ class ToolBox;
|
||||
|
||||
namespace svt
|
||||
{
|
||||
struct ToolboxController_Impl;
|
||||
|
||||
struct DispatchInfo;
|
||||
|
||||
class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusListener,
|
||||
public ::com::sun::star::frame::XToolbarController,
|
||||
@ -112,12 +114,15 @@ class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusL
|
||||
|
||||
|
||||
const OUString& getCommandURL() const { return m_aCommandURL; }
|
||||
const OUString& getModuleName() const;
|
||||
const OUString& getModuleName() const { return m_sModuleName; }
|
||||
|
||||
|
||||
void dispatchCommand( const OUString& sCommandURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs );
|
||||
|
||||
void enable( bool bEnable );
|
||||
|
||||
DECL_STATIC_LINK( ToolboxController, ExecuteHdl_Impl, DispatchInfo* );
|
||||
|
||||
protected:
|
||||
bool getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox );
|
||||
void setSupportVisibleProperty(sal_Bool bValue); //shizhoubo
|
||||
@ -142,17 +147,23 @@ class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusL
|
||||
void unbindListener();
|
||||
sal_Bool isBound() const;
|
||||
sal_Bool hasBigImages() const;
|
||||
// TODO remove
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > getURLTransformer() const;
|
||||
// TODO remove
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > getParent() const;
|
||||
|
||||
sal_Bool m_bInitialized : 1,
|
||||
m_bDisposed : 1;
|
||||
sal_uInt16 m_nToolBoxId;
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
|
||||
ToolboxController_Impl* m_pImpl;
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
|
||||
OUString m_aCommandURL;
|
||||
URLToDispatchMap m_aListenerMap;
|
||||
::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
|
||||
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xParentWindow;
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xUrlTransformer;
|
||||
OUString m_sModuleName;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -59,20 +59,6 @@ struct DispatchInfo
|
||||
: mxDispatch( xDispatch ), maURL( rURL ), maArgs( rArgs ) {}
|
||||
};
|
||||
|
||||
struct ToolboxController_Impl
|
||||
{
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xParentWindow;
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xUrlTransformer;
|
||||
OUString m_sModuleName;
|
||||
sal_uInt16 m_nToolBoxId;
|
||||
|
||||
DECL_STATIC_LINK( ToolboxController_Impl, ExecuteHdl_Impl, DispatchInfo* );
|
||||
|
||||
ToolboxController_Impl()
|
||||
: m_nToolBoxId( SAL_MAX_UINT16 )
|
||||
{}
|
||||
};
|
||||
|
||||
ToolboxController::ToolboxController(
|
||||
const Reference< XComponentContext >& rxContext,
|
||||
const Reference< XFrame >& xFrame,
|
||||
@ -82,6 +68,7 @@ ToolboxController::ToolboxController(
|
||||
, m_bSupportVisible(sal_False)
|
||||
, m_bInitialized( sal_False )
|
||||
, m_bDisposed( sal_False )
|
||||
, m_nToolBoxId( SAL_MAX_UINT16 )
|
||||
, m_xFrame(xFrame)
|
||||
, m_xContext( rxContext )
|
||||
, m_aCommandURL( aCommandURL )
|
||||
@ -93,11 +80,9 @@ ToolboxController::ToolboxController(
|
||||
css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY,
|
||||
&m_bSupportVisible, getCppuType(&m_bSupportVisible));
|
||||
|
||||
m_pImpl = new ToolboxController_Impl;
|
||||
|
||||
try
|
||||
{
|
||||
m_pImpl->m_xUrlTransformer = URLTransformer::create( rxContext );
|
||||
m_xUrlTransformer = URLTransformer::create( rxContext );
|
||||
}
|
||||
catch(const Exception&)
|
||||
{
|
||||
@ -110,19 +95,17 @@ ToolboxController::ToolboxController() :
|
||||
, m_bSupportVisible(sal_False)
|
||||
, m_bInitialized( sal_False )
|
||||
, m_bDisposed( sal_False )
|
||||
, m_nToolBoxId( SAL_MAX_UINT16 )
|
||||
, m_aListenerContainer( m_aMutex )
|
||||
{
|
||||
registerProperty( OUString(TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIBLE),
|
||||
TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE,
|
||||
css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY,
|
||||
&m_bSupportVisible, getCppuType(&m_bSupportVisible));
|
||||
|
||||
m_pImpl = new ToolboxController_Impl;
|
||||
}
|
||||
|
||||
ToolboxController::~ToolboxController()
|
||||
{
|
||||
delete m_pImpl;
|
||||
}
|
||||
|
||||
Reference< XFrame > ToolboxController::getFrameInterface() const
|
||||
@ -230,16 +213,18 @@ throw ( Exception, RuntimeException )
|
||||
m_xContext = comphelper::getComponentContext(xMSF);
|
||||
}
|
||||
else if ( aPropValue.Name == "ParentWindow" )
|
||||
m_pImpl->m_xParentWindow.set(aPropValue.Value,UNO_QUERY);
|
||||
m_xParentWindow.set(aPropValue.Value,UNO_QUERY);
|
||||
else if ( aPropValue.Name == "ModuleIdentifier" )
|
||||
aPropValue.Value >>= m_pImpl->m_sModuleName;
|
||||
aPropValue.Value >>= m_sModuleName;
|
||||
else if ( aPropValue.Name == "Identifier" )
|
||||
aPropValue.Value >>= m_nToolBoxId;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ( !m_pImpl->m_xUrlTransformer.is() && m_xContext.is() )
|
||||
m_pImpl->m_xUrlTransformer = URLTransformer::create( m_xContext );
|
||||
if ( !m_xUrlTransformer.is() && m_xContext.is() )
|
||||
m_xUrlTransformer = URLTransformer::create( m_xContext );
|
||||
}
|
||||
catch(const Exception&)
|
||||
{
|
||||
@ -289,8 +274,8 @@ throw (::com::sun::star::uno::RuntimeException)
|
||||
|
||||
com::sun::star::util::URL aTargetURL;
|
||||
aTargetURL.Complete = pIter->first;
|
||||
if ( m_pImpl->m_xUrlTransformer.is() )
|
||||
m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
if ( m_xUrlTransformer.is() )
|
||||
m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
|
||||
if ( xDispatch.is() && xStatusListener.is() )
|
||||
xDispatch->removeStatusListener( xStatusListener, aTargetURL );
|
||||
@ -388,8 +373,8 @@ throw (::com::sun::star::uno::RuntimeException)
|
||||
aArgs[0].Value = makeAny( KeyModifier );
|
||||
|
||||
aTargetURL.Complete = aCommandURL;
|
||||
if ( m_pImpl->m_xUrlTransformer.is() )
|
||||
m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
if ( m_xUrlTransformer.is() )
|
||||
m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
xDispatch->dispatch( aTargetURL, aArgs );
|
||||
}
|
||||
catch ( DisposedException& )
|
||||
@ -449,8 +434,8 @@ void ToolboxController::addStatusListener( const OUString& aCommandURL )
|
||||
if ( m_xContext.is() && xDispatchProvider.is() )
|
||||
{
|
||||
aTargetURL.Complete = aCommandURL;
|
||||
if ( m_pImpl->m_xUrlTransformer.is() )
|
||||
m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
if ( m_xUrlTransformer.is() )
|
||||
m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
|
||||
|
||||
xStatusListener = Reference< XStatusListener >( static_cast< OWeakObject* >( this ), UNO_QUERY );
|
||||
@ -501,8 +486,8 @@ void ToolboxController::removeStatusListener( const OUString& aCommandURL )
|
||||
{
|
||||
com::sun::star::util::URL aTargetURL;
|
||||
aTargetURL.Complete = aCommandURL;
|
||||
if ( m_pImpl->m_xUrlTransformer.is() )
|
||||
m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
if ( m_xUrlTransformer.is() )
|
||||
m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
|
||||
if ( xDispatch.is() && xStatusListener.is() )
|
||||
xDispatch->removeStatusListener( xStatusListener, aTargetURL );
|
||||
@ -534,8 +519,8 @@ void ToolboxController::bindListener()
|
||||
{
|
||||
com::sun::star::util::URL aTargetURL;
|
||||
aTargetURL.Complete = pIter->first;
|
||||
if ( m_pImpl->m_xUrlTransformer.is() )
|
||||
m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
if ( m_xUrlTransformer.is() )
|
||||
m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
|
||||
Reference< XDispatch > xDispatch( pIter->second );
|
||||
if ( xDispatch.is() )
|
||||
@ -623,8 +608,8 @@ void ToolboxController::unbindListener()
|
||||
{
|
||||
com::sun::star::util::URL aTargetURL;
|
||||
aTargetURL.Complete = pIter->first;
|
||||
if ( m_pImpl->m_xUrlTransformer.is() )
|
||||
m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
if ( m_xUrlTransformer.is() )
|
||||
m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
|
||||
Reference< XDispatch > xDispatch( pIter->second );
|
||||
if ( xDispatch.is() )
|
||||
@ -687,8 +672,8 @@ void ToolboxController::updateStatus( const OUString aCommandURL )
|
||||
if ( m_xContext.is() && xDispatchProvider.is() )
|
||||
{
|
||||
aTargetURL.Complete = aCommandURL;
|
||||
if ( m_pImpl->m_xUrlTransformer.is() )
|
||||
m_pImpl->m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
if ( m_xUrlTransformer.is() )
|
||||
m_xUrlTransformer->parseStrict( aTargetURL );
|
||||
xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
|
||||
}
|
||||
}
|
||||
@ -712,17 +697,12 @@ void ToolboxController::updateStatus( const OUString aCommandURL )
|
||||
|
||||
Reference< XURLTransformer > ToolboxController::getURLTransformer() const
|
||||
{
|
||||
return m_pImpl->m_xUrlTransformer;
|
||||
return m_xUrlTransformer;
|
||||
}
|
||||
|
||||
Reference< ::com::sun::star::awt::XWindow > ToolboxController::getParent() const
|
||||
{
|
||||
return m_pImpl->m_xParentWindow;
|
||||
}
|
||||
|
||||
const OUString& ToolboxController::getModuleName() const
|
||||
{
|
||||
return m_pImpl->m_sModuleName;
|
||||
return m_xParentWindow;
|
||||
}
|
||||
|
||||
void ToolboxController::dispatchCommand( const OUString& sCommandURL, const Sequence< PropertyValue >& rArgs )
|
||||
@ -736,7 +716,7 @@ void ToolboxController::dispatchCommand( const OUString& sCommandURL, const Sequ
|
||||
|
||||
Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch( aURL, OUString(), 0 ), UNO_QUERY_THROW );
|
||||
|
||||
Application::PostUserEvent( STATIC_LINK(0, ToolboxController_Impl, ExecuteHdl_Impl), new DispatchInfo( xDispatch, aURL, rArgs ) );
|
||||
Application::PostUserEvent( STATIC_LINK(0, ToolboxController, ExecuteHdl_Impl), new DispatchInfo( xDispatch, aURL, rArgs ) );
|
||||
|
||||
}
|
||||
catch( Exception& )
|
||||
@ -810,7 +790,7 @@ throw( com::sun::star::uno::Exception)
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
IMPL_STATIC_LINK_NOINSTANCE( ToolboxController_Impl, ExecuteHdl_Impl, DispatchInfo*, pDispatchInfo )
|
||||
IMPL_STATIC_LINK_NOINSTANCE( ToolboxController, ExecuteHdl_Impl, DispatchInfo*, pDispatchInfo )
|
||||
{
|
||||
pDispatchInfo->mxDispatch->dispatch( pDispatchInfo->maURL, pDispatchInfo->maArgs );
|
||||
delete pDispatchInfo;
|
||||
@ -829,12 +809,12 @@ void ToolboxController::enable( bool bEnable )
|
||||
|
||||
bool ToolboxController::getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox )
|
||||
{
|
||||
if( (m_pImpl->m_nToolBoxId != SAL_MAX_UINT16) && (ppToolBox == 0) )
|
||||
return m_pImpl->m_nToolBoxId;
|
||||
if( (m_nToolBoxId != SAL_MAX_UINT16) && (ppToolBox == 0) )
|
||||
return m_nToolBoxId;
|
||||
|
||||
ToolBox* pToolBox = static_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) );
|
||||
|
||||
if( (m_pImpl->m_nToolBoxId == SAL_MAX_UINT16) && pToolBox )
|
||||
if( (m_nToolBoxId == SAL_MAX_UINT16) && pToolBox )
|
||||
{
|
||||
const sal_uInt16 nCount = pToolBox->GetItemCount();
|
||||
for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
|
||||
@ -842,7 +822,7 @@ bool ToolboxController::getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox )
|
||||
const sal_uInt16 nItemId = pToolBox->GetItemId( nPos );
|
||||
if ( pToolBox->GetItemCommand( nItemId ) == String( m_aCommandURL ) )
|
||||
{
|
||||
m_pImpl->m_nToolBoxId = nItemId;
|
||||
m_nToolBoxId = nItemId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -851,7 +831,7 @@ bool ToolboxController::getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox )
|
||||
if( ppToolBox )
|
||||
*ppToolBox = pToolBox;
|
||||
|
||||
rItemId = m_pImpl->m_nToolBoxId;
|
||||
rItemId = m_nToolBoxId;
|
||||
|
||||
return (rItemId != SAL_MAX_UINT16) && (( ppToolBox == 0) || (*ppToolBox != 0) );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user