[Libreoffice-commits] core.git: 5 commits - dbaccess/Library_dbu.mk dbaccess/source dbaccess/util framework/inc framework/source include/sfx2 include/svtools officecfg/registry sfx2/source svtools/source svx/source svx/util
Ariel Constenla-Haile
arielch at apache.org
Mon Jun 24 03:25:56 PDT 2013
dbaccess/Library_dbu.mk | 1
dbaccess/source/ui/control/statusbarontroller.cxx | 40 -
dbaccess/source/ui/inc/statusbarontroller.hxx | 45 -
dbaccess/source/ui/misc/uiservices.cxx | 2
dbaccess/util/dbu.component | 3
framework/inc/uielement/popuptoolbarcontroller.hxx | 4
framework/source/uielement/popuptoolbarcontroller.cxx | 71 +
include/sfx2/mnuitem.hxx | 28
include/sfx2/tbxctrl.hxx | 38 -
include/svtools/toolboxcontroller.hxx | 24
officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu | 44 -
sfx2/source/appl/appreg.cxx | 2
sfx2/source/menu/mnuitem.cxx | 149 ++++
sfx2/source/toolbox/tbxitem.cxx | 357 ----------
svtools/source/uno/toolboxcontroller.cxx | 19
svx/source/tbxctrls/extrusioncontrols.cxx | 2
svx/util/svxcore.component | 2
17 files changed, 260 insertions(+), 571 deletions(-)
New commits:
commit 2f3e79ee907f6e483d8886984f262fd1763adccc
Author: Ariel Constenla-Haile <arielch at apache.org>
Date: Tue May 28 22:09:27 2013 +0000
Resolves: #i122401# framework::NewToolbarController needs...
early initialization of its PopupMenu
(cherry picked from commit 5149ad822bb66cca9561b7c181c6c2279affc29a)
Conflicts:
framework/inc/uielement/popuptoolbarcontroller.hxx
framework/source/uielement/popuptoolbarcontroller.cxx
Change-Id: I619fe7b86a19b146079792a73a50d23682d04a3c
diff --git a/framework/inc/uielement/popuptoolbarcontroller.hxx b/framework/inc/uielement/popuptoolbarcontroller.hxx
index f8e8bf9..56f3251 100644
--- a/framework/inc/uielement/popuptoolbarcontroller.hxx
+++ b/framework/inc/uielement/popuptoolbarcontroller.hxx
@@ -77,6 +77,7 @@ namespace framework
DECLARE_XSERVICEINFO
private:
void functionExecuted( const OUString &rCommand );
+ 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);
void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& rEvent ) throw ( ::com::sun::star::uno::RuntimeException );
void SAL_CALL execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException);
void setItemImage( const OUString &rCommand );
diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx b/framework/source/uielement/popuptoolbarcontroller.cxx
index b38c617..26ac39c 100644
--- a/framework/source/uielement/popuptoolbarcontroller.cxx
+++ b/framework/source/uielement/popuptoolbarcontroller.cxx
@@ -257,6 +257,17 @@ NewToolbarController::NewToolbarController(
}
void SAL_CALL
+NewToolbarController::initialize(
+ const css::uno::Sequence< css::uno::Any >& aArguments )
+throw ( css::uno::Exception, css::uno::RuntimeException )
+{
+ PopupMenuToolbarController::initialize( aArguments );
+
+ osl::MutexGuard aGuard( m_aMutex );
+ createPopupMenuController();
+}
+
+void SAL_CALL
NewToolbarController::statusChanged(
const css::frame::FeatureStateEvent& rEvent )
throw ( css::uno::RuntimeException )
@@ -401,10 +412,7 @@ void NewToolbarController::setItemImage( const OUString &rCommand )
Image aMenuImage;
sal_Bool bValid( Impl_ExistURLInMenu( m_xPopupMenu, aURL, sFallback, aMenuImage ) );
- // do not change aURL if Impl_ExistURLInMenu returned sal_False
- // this allows later initialization of the PopupMenuController on createPopupWindow()
- // and works even if SvFileInformationManager does not know the module
- if ( !aURL.getLength() )
+ if ( !bValid )
aURL = sFallback;
sal_Bool bBig = SvtMiscOptions().AreCurrentSymbolsLarge();
@@ -412,16 +420,9 @@ void NewToolbarController::setItemImage( const OUString &rCommand )
INetURLObject aURLObj( aURL );
Image aImage = SvFileInformationManager::GetImageNoDefault( aURLObj, bBig );
if ( !aImage )
- {
- if ( !!aMenuImage )
- aImage = aMenuImage;
- else if ( !bValid )
- // If SvFileInformationManager didn't know the module, try with the default
- aImage = SvFileInformationManager::GetImageNoDefault( INetURLObject( sFallback ), bBig );
-
- if ( !aImage )
- aImage = SvFileInformationManager::GetImage( aURLObj, bBig );
- }
+ aImage = !!aMenuImage ?
+ aMenuImage :
+ SvFileInformationManager::GetImage( aURLObj, bBig );
// if everything failed, just use the image associated with the toolbar item command
if ( !aImage )
commit 6b6ebeeaf94e1db3c90cfe3921ea6c956570a0c5
Author: Ariel Constenla-Haile <arielch at apache.org>
Date: Tue May 28 22:09:19 2013 +0000
svx::ExtrusionDepthController is a ToolbarController
This class is dereived from svt::PopupWindowController, derived in turn from
svt::ToolboxController, the base class of all css.frame.ToolbarController's.
Adapt getSupportedServiceNames() and the passive component registration to
reflect that fact.
(cherry picked from commit e0f9eb4cc5d2ea676a899c4cbecb97264a31fef3)
Conflicts:
svx/source/tbxctrls/extrusioncontrols.cxx
Change-Id: I866c1dc43d31dc269ec72890041b87292b02b2f9
diff --git a/svx/source/tbxctrls/extrusioncontrols.cxx b/svx/source/tbxctrls/extrusioncontrols.cxx
index 38ca514..2d70333 100644
--- a/svx/source/tbxctrls/extrusioncontrols.cxx
+++ b/svx/source/tbxctrls/extrusioncontrols.cxx
@@ -533,7 +533,7 @@ OUString SAL_CALL ExtrusionDepthController_getImplementationName()
Sequence< OUString > SAL_CALL ExtrusionDepthController_getSupportedServiceNames() throw( RuntimeException )
{
Sequence< OUString > aSNS( 1 );
- aSNS.getArray()[0] = OUString( "com.sun.star.frame.PopupMenuController" );
+ aSNS.getArray()[0] = OUString( "com.sun.star.frame.ToolbarController" );
return aSNS;
}
diff --git a/svx/util/svxcore.component b/svx/util/svxcore.component
index 8c33d0b..6190b54 100644
--- a/svx/util/svxcore.component
+++ b/svx/util/svxcore.component
@@ -19,7 +19,7 @@
<component loader="com.sun.star.loader.SharedLibrary" prefix="svxcore"
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.svx.ExtrusionDepthController">
- <service name="com.sun.star.frame.PopupMenuController"/>
+ <service name="com.sun.star.frame.ToolbarController"/>
</implementation>
<implementation name="com.sun.star.comp.svx.ExtrusionDirectionController">
<service name="com.sun.star.frame.ToolbarController"/>
commit 53ef9fa167cc68969cdc953b4c0b9ad339f2d27e
Author: Ariel Constenla-Haile <arielch at apache.org>
Date: Tue May 28 10:01:22 2013 +0000
Remove dbaui::OStatusbarController
It actually does not override any method in svt::StatusbarController, so there
is no point in keeping it
(cherry picked from commit 83bf5a7b85a0e3430cc807415e081a10a1775f9f)
Conflicts:
dbaccess/source/ui/control/makefile.mk
dbaccess/source/ui/control/statusbarontroller.cxx
dbaccess/source/ui/inc/statusbarontroller.hxx
Change-Id: Id6adc11c3a54f642ebdec9c6016996134908da71
diff --git a/dbaccess/Library_dbu.mk b/dbaccess/Library_dbu.mk
index d2e9285..fa7211b 100644
--- a/dbaccess/Library_dbu.mk
+++ b/dbaccess/Library_dbu.mk
@@ -116,7 +116,6 @@ $(eval $(call gb_Library_add_exception_objects,dbu,\
dbaccess/source/ui/control/ScrollHelper \
dbaccess/source/ui/control/sqledit \
dbaccess/source/ui/control/SqlNameEdit \
- dbaccess/source/ui/control/statusbarontroller \
dbaccess/source/ui/control/TableGrantCtrl \
dbaccess/source/ui/control/tabletree \
dbaccess/source/ui/control/toolboxcontroller \
diff --git a/dbaccess/source/ui/control/statusbarontroller.cxx b/dbaccess/source/ui/control/statusbarontroller.cxx
deleted file mode 100644
index c2c84ef..0000000
--- a/dbaccess/source/ui/control/statusbarontroller.cxx
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- 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 "statusbarontroller.hxx"
-#include "dbu_reghelper.hxx"
-
-extern "C" void SAL_CALL createRegistryInfo_OStatusbarController()
-{
- static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OStatusbarController> aAutoRegistration;
-}
-namespace dbaui
-{
- using namespace svt;
- using namespace com::sun::star::uno;
- using namespace com::sun::star::beans;
- using namespace com::sun::star::lang;
- using namespace ::com::sun::star::frame;
- using namespace ::com::sun::star::util;
-
- IMPLEMENT_SERVICE_INFO1_STATIC(OStatusbarController,"com.sun.star.sdb.ApplicationStatusbarController","com.sun.star.frame.StatusbarController")
- IMPLEMENT_FORWARD_XINTERFACE2(OStatusbarController,StatusbarController,OStatusbarController_BASE)
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/statusbarontroller.hxx b/dbaccess/source/ui/inc/statusbarontroller.hxx
deleted file mode 100644
index ecd10e9..0000000
--- a/dbaccess/source/ui/inc/statusbarontroller.hxx
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- 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 DBAUI_STATUSBARCONTROLLER_HXX
-#define DBAUI_STATUSBARCONTROLLER_HXX
-
-#include <svtools/statusbarcontroller.hxx>
-#include <comphelper/uno3.hxx>
-#include "apitools.hxx"
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <cppuhelper/implbase1.hxx>
-
-namespace dbaui
-{
- typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XServiceInfo> OStatusbarController_BASE;
- class OStatusbarController : public ::svt::StatusbarController,
- public OStatusbarController_BASE
- {
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
- public:
- OStatusbarController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB):m_xORB(_rxORB){}
-
- DECLARE_XINTERFACE()
- // ::com::sun::star::lang::XServiceInfo
- DECLARE_SERVICE_INFO_STATIC();
- };
-}
-#endif // DBAUI_STATUSBARCONTROLLER_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/uiservices.cxx b/dbaccess/source/ui/misc/uiservices.cxx
index 40c3a7a..766e38a 100644
--- a/dbaccess/source/ui/misc/uiservices.cxx
+++ b/dbaccess/source/ui/misc/uiservices.cxx
@@ -54,7 +54,6 @@ extern "C" void SAL_CALL createRegistryInfo_ODBTypeWizDialogSetup();
extern "C" void SAL_CALL createRegistryInfo_OColumnControlModel();
extern "C" void SAL_CALL createRegistryInfo_OColumnControl();
extern "C" void SAL_CALL createRegistryInfo_OToolboxController();
-extern "C" void SAL_CALL createRegistryInfo_OStatusbarController();
extern "C" void SAL_CALL createRegistryInfo_CopyTableWizard();
extern "C" void SAL_CALL createRegistryInfo_OTextConnectionSettingsDialog();
extern "C" void SAL_CALL createRegistryInfo_LimitBoxController();
@@ -87,7 +86,6 @@ extern "C" void SAL_CALL createRegistryInfo_DBU()
createRegistryInfo_OColumnControlModel();
createRegistryInfo_OColumnControl();
createRegistryInfo_OToolboxController();
- createRegistryInfo_OStatusbarController();
createRegistryInfo_CopyTableWizard();
createRegistryInfo_OTextConnectionSettingsDialog();
createRegistryInfo_LimitBoxController();
diff --git a/dbaccess/util/dbu.component b/dbaccess/util/dbu.component
index afd9002..73b65a1 100644
--- a/dbaccess/util/dbu.component
+++ b/dbaccess/util/dbu.component
@@ -42,9 +42,6 @@
<implementation name="com.sun.star.comp.sdb.DirectSQLDialog">
<service name="org.openoffice.comp.dbu.DirectSqlDialog"/>
</implementation>
- <implementation name="com.sun.star.sdb.ApplicationStatusbarController">
- <service name="com.sun.star.frame.StatusbarController"/>
- </implementation>
<implementation name="com.sun.star.sdb.ApplicationToolboxController">
<service name="com.sun.star.frame.ToolboxController"/>
</implementation>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
index 840191e..b9308fd 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
@@ -596,50 +596,6 @@
</node>
</node>
<node oor:name="StatusBar">
- <node oor:name="c1" oor:op="replace">
- <prop oor:name="Command">
- <value>.uno:DBStatusType</value>
- </prop>
- <prop oor:name="Module">
- <value>com.sun.star.sdb.OfficeDatabaseDocument</value>
- </prop>
- <prop oor:name="Controller">
- <value>com.sun.star.sdb.ApplicationStatusbarController</value>
- </prop>
- </node>
- <node oor:name="c2" oor:op="replace">
- <prop oor:name="Command">
- <value>.uno:DBStatusDBName</value>
- </prop>
- <prop oor:name="Module">
- <value>com.sun.star.sdb.OfficeDatabaseDocument</value>
- </prop>
- <prop oor:name="Controller">
- <value>com.sun.star.sdb.ApplicationStatusbarController</value>
- </prop>
- </node>
- <node oor:name="c3" oor:op="replace">
- <prop oor:name="Command">
- <value>.uno:DBStatusUserName</value>
- </prop>
- <prop oor:name="Module">
- <value>com.sun.star.sdb.OfficeDatabaseDocument</value>
- </prop>
- <prop oor:name="Controller">
- <value>com.sun.star.sdb.ApplicationStatusbarController</value>
- </prop>
- </node>
- <node oor:name="c4" oor:op="replace">
- <prop oor:name="Command">
- <value>.uno:DBStatusHostName</value>
- </prop>
- <prop oor:name="Module">
- <value>com.sun.star.sdb.OfficeDatabaseDocument</value>
- </prop>
- <prop oor:name="Controller">
- <value>com.sun.star.sdb.ApplicationStatusbarController</value>
- </prop>
- </node>
<node oor:name="c5" oor:op="replace">
<prop oor:name="Command">
<value>.uno:LanguageStatus</value>
commit 57207cab004cb78c3fa6d9ed43cc4bf81f4e6981
Author: Ariel Constenla-Haile <arielch at apache.org>
Date: Tue May 28 10:01:32 2013 +0000
Add missing copy&paste of SfxAppToolBoxControl_Impl::Select
(cherry picked from commit 47204c74d9e52f54f6983af19b66af2a96b42e61)
Conflicts:
framework/inc/uielement/popuptoolbarcontroller.hxx
svtools/inc/svtools/toolboxcontroller.hxx
Change-Id: I304d17c662450f29eeffb17f576b418986f3fb0a
diff --git a/framework/inc/uielement/popuptoolbarcontroller.hxx b/framework/inc/uielement/popuptoolbarcontroller.hxx
index 89acb76..f8e8bf9 100644
--- a/framework/inc/uielement/popuptoolbarcontroller.hxx
+++ b/framework/inc/uielement/popuptoolbarcontroller.hxx
@@ -78,7 +78,10 @@ namespace framework
private:
void functionExecuted( const OUString &rCommand );
void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& rEvent ) throw ( ::com::sun::star::uno::RuntimeException );
+ void SAL_CALL execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException);
void setItemImage( const OUString &rCommand );
+
+ OUString m_aLastURL;
};
class WizardsToolbarController : public PopupMenuToolbarController
diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx b/framework/source/uielement/popuptoolbarcontroller.cxx
index 0340c03..b38c617 100644
--- a/framework/source/uielement/popuptoolbarcontroller.cxx
+++ b/framework/source/uielement/popuptoolbarcontroller.cxx
@@ -17,6 +17,8 @@
*/
#include <uielement/popuptoolbarcontroller.hxx>
+#include <framework/menuconfiguration.hxx>
+#include <toolkit/awt/vclxmenu.hxx>
#include <comphelper/processfactory.hxx>
#include <svtools/imagemgr.hxx>
#include <svtools/miscopt.hxx>
@@ -28,9 +30,10 @@
#include <com/sun/star/awt/PopupMenuDirection.hpp>
#include <com/sun/star/frame/PopupMenuControllerFactory.hpp>
-
+#include <com/sun/star/frame/XDispatchProvider.hpp>
#define UNO_COMMAND_RECENT_FILE_LIST ".uno:RecentFileList"
+#define SFX_REFERER_USER "private:user"
namespace css = ::com::sun::star;
@@ -270,6 +273,39 @@ NewToolbarController::statusChanged(
enable( rEvent.IsEnabled );
}
+void SAL_CALL
+NewToolbarController::execute( sal_Int16 /*KeyModifier*/ )
+ throw ( css::uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_aLastURL.getLength() )
+ return;
+
+ OUString aTarget( RTL_CONSTASCII_USTRINGPARAM( "_default" ) );
+ if ( m_xPopupMenu.is() )
+ {
+ // TODO investigate how to wrap Get/SetUserValue in css::awt::XMenu
+ MenuConfiguration::Attributes* pMenuAttributes( 0 );
+ VCLXPopupMenu* pTkPopupMenu = dynamic_cast< VCLXPopupMenu * >(
+ VCLXMenu::GetImplementation( m_xPopupMenu ) );
+
+ SolarMutexGuard aSolarMutexGuard;
+ PopupMenu* pVCLPopupMenu = dynamic_cast< PopupMenu * >( pTkPopupMenu->GetMenu() );
+ if ( pVCLPopupMenu )
+ pMenuAttributes = reinterpret_cast< MenuConfiguration::Attributes* >(
+ pVCLPopupMenu->GetUserValue( pVCLPopupMenu->GetCurItemId() ) );
+
+ if ( pMenuAttributes )
+ aTarget = pMenuAttributes->aTargetFrame;
+ }
+
+ css::uno::Sequence< css::beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Referer" ));
+ aArgs[0].Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM( SFX_REFERER_USER ) );
+
+ dispatchCommand( m_aLastURL, aArgs, aTarget );
+}
+
void NewToolbarController::functionExecuted( const OUString &rCommand )
{
setItemImage( rCommand );
@@ -400,6 +436,8 @@ void NewToolbarController::setItemImage( const OUString &rCommand )
}
else
pToolBox->SetItemImage( m_nToolBoxId, aImage );
+
+ m_aLastURL = aURL;
}
diff --git a/include/svtools/toolboxcontroller.hxx b/include/svtools/toolboxcontroller.hxx
index 0212661..217d6cd 100644
--- a/include/svtools/toolboxcontroller.hxx
+++ b/include/svtools/toolboxcontroller.hxx
@@ -46,8 +46,6 @@ class ToolBox;
namespace svt
{
-struct DispatchInfo;
-
class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusListener,
public ::com::sun::star::frame::XToolbarController,
public ::com::sun::star::lang::XInitialization,
@@ -116,13 +114,10 @@ class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusL
const OUString& getCommandURL() const { return m_aCommandURL; }
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 dispatchCommand( const OUString& sCommandURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs, const OUString &rTarget = OUString() );
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
@@ -135,6 +130,23 @@ class SVT_DLLPUBLIC ToolboxController : public ::com::sun::star::frame::XStatusL
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch;
};
+ struct DispatchInfo
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > mxDispatch;
+ const ::com::sun::star::util::URL maURL;
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > maArgs;
+
+ DispatchInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& xDispatch,
+ const ::com::sun::star::util::URL& rURL,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs )
+ : mxDispatch( xDispatch )
+ , maURL( rURL )
+ , maArgs( rArgs )
+ {}
+ };
+
+ DECL_STATIC_LINK( ToolboxController, ExecuteHdl_Impl, DispatchInfo* );
+
typedef ::boost::unordered_map< OUString,
com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >,
OUStringHash,
diff --git a/svtools/source/uno/toolboxcontroller.cxx b/svtools/source/uno/toolboxcontroller.cxx
index f845aed..5a37162 100644
--- a/svtools/source/uno/toolboxcontroller.cxx
+++ b/svtools/source/uno/toolboxcontroller.cxx
@@ -49,16 +49,6 @@ using namespace ::com::sun::star::frame;
namespace svt
{
-struct DispatchInfo
-{
- Reference< XDispatch > mxDispatch;
- const URL maURL;
- const Sequence< PropertyValue > maArgs;
-
- DispatchInfo( const Reference< XDispatch >& xDispatch, const URL& rURL, const Sequence< PropertyValue >& rArgs )
- : mxDispatch( xDispatch ), maURL( rURL ), maArgs( rArgs ) {}
-};
-
ToolboxController::ToolboxController(
const Reference< XComponentContext >& rxContext,
const Reference< XFrame >& xFrame,
@@ -705,7 +695,7 @@ Reference< ::com::sun::star::awt::XWindow > ToolboxController::getParent() const
return m_xParentWindow;
}
-void ToolboxController::dispatchCommand( const OUString& sCommandURL, const Sequence< PropertyValue >& rArgs )
+void ToolboxController::dispatchCommand( const OUString& sCommandURL, const Sequence< PropertyValue >& rArgs, const OUString &sTarget )
{
try
{
@@ -714,9 +704,12 @@ void ToolboxController::dispatchCommand( const OUString& sCommandURL, const Sequ
aURL.Complete = sCommandURL;
getURLTransformer()->parseStrict( aURL );
- Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch( aURL, OUString(), 0 ), UNO_QUERY_THROW );
+ Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch( aURL, sTarget, 0 ), UNO_QUERY_THROW );
- Application::PostUserEvent( STATIC_LINK(0, ToolboxController, ExecuteHdl_Impl), new DispatchInfo( xDispatch, aURL, rArgs ) );
+ DispatchInfo *pDispatchInfo = new DispatchInfo( xDispatch, aURL, rArgs );
+ if ( !Application::PostUserEvent( STATIC_LINK(0, ToolboxController, ExecuteHdl_Impl),
+ pDispatchInfo ) )
+ delete pDispatchInfo;
}
catch( Exception& )
commit a1748501d81425d26d09509eec2fd141f2f28f05
Author: Ariel Constenla-Haile <arielch at apache.org>
Date: Sat May 25 22:11:58 2013 +0000
Kill SfxAppToolBoxControl_Impl
(cherry picked from commit 273121f8d7e277e35c8e5a8aad46ef0c103ebc03)
Conflicts:
sfx2/inc/sfx2/mnuitem.hxx
sfx2/inc/sfx2/tbxctrl.hxx
sfx2/source/appl/appreg.cxx
sfx2/source/menu/mnuitem.cxx
sfx2/source/toolbox/tbxitem.cxx
Change-Id: I6d0750d89ad009f82c5552d971537b78e45426f2
Silence warning C4706
(cherry picked from commit 0b373b3e4c45d09c40a8949e9366adb9b991de4b)
Change-Id: Id497469eba8288565145c47c84b7938a1316c21a
diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx b/framework/source/uielement/popuptoolbarcontroller.cxx
index d9189a3..0340c03 100644
--- a/framework/source/uielement/popuptoolbarcontroller.cxx
+++ b/framework/source/uielement/popuptoolbarcontroller.cxx
@@ -312,7 +312,7 @@ static sal_Bool Impl_ExistURLInMenu(
{
sal_Bool bValidFallback( sal_False );
sal_uInt16 nCount( 0 );
- if ( rPopupMenu.is() && ( nCount = rPopupMenu->getItemCount() ) && sURL.getLength() )
+ if ( rPopupMenu.is() && ( nCount = rPopupMenu->getItemCount() ) != 0 && sURL.getLength() )
{
for ( sal_uInt16 n = 0; n < nCount; ++n )
{
diff --git a/include/sfx2/mnuitem.hxx b/include/sfx2/mnuitem.hxx
index e65220b..557e876 100644
--- a/include/sfx2/mnuitem.hxx
+++ b/include/sfx2/mnuitem.hxx
@@ -33,6 +33,9 @@ struct SfxMenuCtrlFactory;
#include <tools/string.hxx>
#include <sfx2/ctrlitem.hxx>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/util/URL.hpp>
+
class SFX2_DLLPUBLIC SfxMenuControl: public SfxControllerItem
{
String aTitle;
@@ -116,6 +119,31 @@ inline SfxVirtualMenu* SfxMenuControl::GetPopupMenu() const
void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \
{ SfxMenuControl::RegisterMenuControl( pMod, new SfxMenuCtrlFactory( \
Class::CreateImpl, TYPE(nItemClass), nSlotId ) ); }
+
+class SfxAppMenuControl_Impl : public SfxMenuControl
+{
+ PopupMenu* pMenu;
+ sal_uIntPtr m_nSymbolsStyle;
+ sal_Bool m_bShowMenuImages;
+
+protected:
+ DECL_LINK( Activate, Menu * ); // Needed to support high contrast images
+
+public:
+ SFX_DECL_MENU_CONTROL();
+ SfxAppMenuControl_Impl( sal_uInt16 nPos, Menu& rMenu, SfxBindings& rBindings );
+ ~SfxAppMenuControl_Impl();
+
+ struct ExecuteInfo
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch;
+ ::com::sun::star::util::URL aTargetURL;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs;
+ };
+
+ DECL_STATIC_LINK( SfxAppMenuControl_Impl, ExecuteHdl_Impl, ExecuteInfo* );
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/tbxctrl.hxx b/include/sfx2/tbxctrl.hxx
index b67ed11..e7b6e69 100644
--- a/include/sfx2/tbxctrl.hxx
+++ b/include/sfx2/tbxctrl.hxx
@@ -313,44 +313,6 @@ public:
//------------------------------------------------------------------------
-class SfxAppToolBoxControl_Impl : public SfxToolBoxControl
-
-/* [Description]
-
- Internal helper class for the pop-up menu <AppMenu_Impl> under new
- start in the SDT.
-*/
-
-{
-public:
- SFX_DECL_TOOLBOX_CONTROL();
- SfxAppToolBoxControl_Impl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox );
- ~SfxAppToolBoxControl_Impl();
- void SetImage( const String& rFacName );
-
- struct ExecuteInfo
- {
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch;
- ::com::sun::star::util::URL aTargetURL;
- ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs;
- };
-
- DECL_STATIC_LINK( SfxAppToolBoxControl_Impl, ExecuteHdl_Impl, ExecuteInfo* );
-
-protected:
- virtual void Click();
- using SfxToolBoxControl::Select;
- virtual void Select( sal_Bool );
- virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
- virtual SfxPopupWindow* CreatePopupWindow();
- DECL_LINK( Activate, Menu * );
-private:
- String aLastURL;
- PopupMenu* pMenu;
- sal_uIntPtr m_nSymbolsStyle;
- sal_Bool m_bShowMenuImages;
-};
-
/** Toolbox that implements recent files menu for the Open file toolbar button.
To use that, the appropriate Sfx*Item (like Open, OpenFromCalc, or
diff --git a/sfx2/source/appl/appreg.cxx b/sfx2/source/appl/appreg.cxx
index f3e7365..9e0dcec 100644
--- a/sfx2/source/appl/appreg.cxx
+++ b/sfx2/source/appl/appreg.cxx
@@ -62,8 +62,6 @@ void SfxApplication::Registrations_Impl()
// Controller
SfxToolBoxControl::RegisterControl(SID_REPEAT);
SfxURLToolBoxControl_Impl::RegisterControl(SID_OPENURL);
- SfxAppToolBoxControl_Impl::RegisterControl( SID_NEWDOCDIRECT );
- SfxAppToolBoxControl_Impl::RegisterControl( SID_AUTOPILOTMENU );
SfxRecentFilesToolBoxControl::RegisterControl( SID_OPENDOC );
};
diff --git a/sfx2/source/menu/mnuitem.cxx b/sfx2/source/menu/mnuitem.cxx
index 1a48896..6530c88 100644
--- a/sfx2/source/menu/mnuitem.cxx
+++ b/sfx2/source/menu/mnuitem.cxx
@@ -24,13 +24,15 @@
#include <string>
#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/util/URL.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <comphelper/processfactory.hxx>
+#include <com/sun/star/util/URLTransformer.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
+#include <comphelper/processfactory.hxx>
#include <tools/urlobj.hxx>
#include <svl/eitem.hxx>
#include <svl/stritem.hxx>
@@ -291,6 +293,99 @@ PopupMenu* SfxMenuControl::GetPopup () const
return 0;
}
+long Select_Impl( void* pHdl, void* pVoid );
+
+SFX_IMPL_MENU_CONTROL( SfxAppMenuControl_Impl, SfxStringItem );
+
+SfxAppMenuControl_Impl::SfxAppMenuControl_Impl(
+ sal_uInt16 nPos, Menu& rMenu, SfxBindings& rBindings )
+ : SfxMenuControl( nPos, rBindings ), pMenu(0)
+{
+ String aText = rMenu.GetItemText( nPos );
+
+ // Determine the current background color setting for menus
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+ m_nSymbolsStyle = rSettings.GetSymbolsStyle();
+ m_bShowMenuImages = rSettings.GetUseImagesInMenus();
+
+ ::framework::MenuConfiguration aConf( ::comphelper::getProcessComponentContext() );
+ Reference<com::sun::star::frame::XFrame> aXFrame( GetBindings().GetDispatcher_Impl()->GetFrame()->GetFrame().GetFrameInterface() );
+ pMenu = aConf.CreateBookmarkMenu( aXFrame, GetId() == SID_NEWDOCDIRECT ? BOOKMARK_NEWMENU : BOOKMARK_WIZARDMENU );
+ if( pMenu )
+ {
+ pMenu->SetSelectHdl( Link( &(this->GetBindings()), Select_Impl ) );
+ pMenu->SetActivateHdl( LINK(this, SfxAppMenuControl_Impl, Activate) );
+ rMenu.SetPopupMenu( nPos, pMenu );
+ }
+}
+
+SfxAppMenuControl_Impl::~SfxAppMenuControl_Impl()
+{
+ delete pMenu;
+}
+
+IMPL_LINK( SfxAppMenuControl_Impl, Activate, Menu *, pActMenu )
+{
+ if ( pActMenu )
+ {
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+ sal_uIntPtr nSymbolsStyle = rSettings.GetSymbolsStyle();
+ sal_Bool bShowMenuImages = rSettings.GetUseImagesInMenus();
+
+ if (( nSymbolsStyle != m_nSymbolsStyle ) ||
+ ( bShowMenuImages != m_bShowMenuImages ))
+ {
+ m_nSymbolsStyle = nSymbolsStyle;
+ m_bShowMenuImages = bShowMenuImages;
+
+ sal_uInt16 nCount = pActMenu->GetItemCount();
+ for ( sal_uInt16 nSVPos = 0; nSVPos < nCount; nSVPos++ )
+ {
+ sal_uInt16 nItemId = pActMenu->GetItemId( nSVPos );
+ if ( pActMenu->GetItemType( nSVPos ) != MENUITEM_SEPARATOR )
+ {
+ if ( bShowMenuImages )
+ {
+ sal_Bool bImageSet = sal_False;
+ ::rtl::OUString aImageId;
+ ::framework::MenuConfiguration::Attributes* pMenuAttributes =
+ (::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( nItemId );
+
+ if ( pMenuAttributes )
+ aImageId = pMenuAttributes->aImageId; // Retrieve image id from menu attributes
+
+ if ( aImageId.getLength() > 0 )
+ {
+ Reference< ::com::sun::star::frame::XFrame > xFrame;
+ Image aImage = GetImage( xFrame, aImageId, sal_False );
+ if ( !!aImage )
+ {
+ bImageSet = sal_True;
+ pActMenu->SetItemImage( nItemId, aImage );
+ }
+ }
+
+ String aCmd( pActMenu->GetItemCommand( nItemId ) );
+ if ( !bImageSet && aCmd.Len() )
+ {
+ Image aImage = SvFileInformationManager::GetImage(
+ INetURLObject(aCmd), sal_False );
+ if ( !!aImage )
+ pActMenu->SetItemImage( nItemId, aImage );
+ }
+ }
+ else
+ pActMenu->SetItemImage( nItemId, Image() );
+ }
+ }
+ }
+
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
SfxUnoMenuControl* SfxMenuControl::CreateControl( const String& rCmd,
sal_uInt16 nId, Menu& rMenu, const String& sItemText,
SfxBindings& rBindings, SfxVirtualMenu* pVirt)
@@ -317,4 +412,54 @@ SfxUnoMenuControl::~SfxUnoMenuControl()
pUnoCtrl->release();
}
+long Select_Impl( void* /*pHdl*/, void* pVoid )
+{
+ Menu* pMenu = (Menu*)pVoid;
+ String aURL( pMenu->GetItemCommand( pMenu->GetCurItemId() ) );
+
+ if( !aURL.Len() )
+ return 0;
+
+ Reference < ::com::sun::star::frame::XDesktop2 > xDesktop =
+ ::com::sun::star::frame::Desktop::create( ::comphelper::getProcessComponentContext() );
+
+ URL aTargetURL;
+ aTargetURL.Complete = aURL;
+ Reference < XURLTransformer > xTrans( URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
+ xTrans->parseStrict( aTargetURL );
+
+ Reference < XDispatch > xDisp;
+ if ( aTargetURL.Protocol.compareToAscii("slot:") == COMPARE_EQUAL )
+ xDisp = xDesktop->queryDispatch( aTargetURL, OUString(), 0 );
+ else
+ {
+ OUString aTargetFrame( OUString("_blank") );
+ ::framework::MenuConfiguration::Attributes* pMenuAttributes =
+ (::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( pMenu->GetCurItemId() );
+
+ if ( pMenuAttributes )
+ aTargetFrame = pMenuAttributes->aTargetFrame;
+
+ xDisp = xDesktop->queryDispatch( aTargetURL, aTargetFrame , 0 );
+ }
+
+ if ( xDisp.is() )
+ {
+ SfxAppMenuControl_Impl::ExecuteInfo* pExecuteInfo = new SfxAppMenuControl_Impl::ExecuteInfo;
+ pExecuteInfo->xDispatch = xDisp;
+ pExecuteInfo->aTargetURL = aTargetURL;
+ pExecuteInfo->aArgs = Sequence< PropertyValue >();
+ Application::PostUserEvent( STATIC_LINK( 0, SfxAppMenuControl_Impl, ExecuteHdl_Impl), pExecuteInfo );
+ }
+
+ return sal_True;
+}
+
+IMPL_STATIC_LINK_NOINSTANCE( SfxAppMenuControl_Impl, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo )
+{
+ pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs );
+ delete pExecuteInfo;
+ return 0;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx
index b8913eb..e5b188b 100644
--- a/sfx2/source/toolbox/tbxitem.cxx
+++ b/sfx2/source/toolbox/tbxitem.cxx
@@ -108,7 +108,6 @@ using namespace ::com::sun::star::ui;
//====================================================================
SFX_IMPL_TOOLBOX_CONTROL_ARG(SfxToolBoxControl, SfxStringItem, sal_True);
-SFX_IMPL_TOOLBOX_CONTROL(SfxAppToolBoxControl_Impl, SfxStringItem);
SFX_IMPL_TOOLBOX_CONTROL(SfxRecentFilesToolBoxControl, SfxStringItem);
static Window* GetTopMostParentSystemWindow( Window* pWindow )
@@ -1392,362 +1391,6 @@ void SfxPopupWindow::Delete()
//--------------------------------------------------------------------
-SfxAppToolBoxControl_Impl::SfxAppToolBoxControl_Impl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox )
- : SfxToolBoxControl( nSlotId, nId, rBox )
- , pMenu( 0 )
-{
- rBox.SetHelpId( nId, HID_TBXCONTROL_FILENEW );
- rBox.SetItemBits( nId, rBox.GetItemBits( nId ) | TIB_DROPDOWN);
-
- // Determine the current background color of the menus
- const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
- m_nSymbolsStyle = rSettings.GetSymbolsStyle();
- m_bShowMenuImages = rSettings.GetUseImagesInMenus();
-
- SetImage( String() );
-}
-
-SfxAppToolBoxControl_Impl::~SfxAppToolBoxControl_Impl()
-{
- delete pMenu;
-}
-
-//_____________________________________________________
-/*
- it return the existing state of the given URL in the popupmenu of this toolbox control.
-
- If the given URL can be located as an action command of one menu item of the
- popup menu of this control, we return sal_True. Otherwhise we return sal_False.
- Further we return a fallback URL, in case we have to return sal_False. Because
- the outside code must select a valid item of the popup menu everytime ...
- and we define it here. By the way this m ethod was written to handle
- error situations gracefully. E.g. it can be called during creation time
- but then we have no valid menu. For this case we know another fallback URL.
- Then we return the private:factory/ URL of the default factory.
-
- @param *pMenu
- pounts to the popup menu, on which item we try to locate the given URL
- Can be NULL! Search will be supressed then.
-
- @param sURL
- the URL for searching
-
- @param pFallback
- contains the fallback URL in case we return FALSE
- Must point to valid memory!
-
- @param pImage
- contains the image of the menu for the URL.
-
- @return sal_True - if URL could be located as an item of the popup menu.
- sal_False - otherwise.
-*/
-sal_Bool Impl_ExistURLInMenu( const PopupMenu *pMenu ,
- String &sURL ,
- String *pFallback ,
- Image *pImage )
-{
- sal_Bool bValidFallback = sal_False;
- if (pMenu && sURL.Len())
- {
- sal_uInt16 c = pMenu->GetItemCount();
- for (sal_uInt16 p=0; p<c; ++p)
- {
- sal_uInt16 nId = pMenu->GetItemId(p);
- String aCmd( pMenu->GetItemCommand(nId) );
-
- if (!bValidFallback && aCmd.Len())
- {
- *pFallback = aCmd;
- bValidFallback = sal_True;
- }
-
- if (aCmd.Search(sURL)==0)//match even if the menu command is more detailed (maybe an additional query) #i28667#
- {
- sURL = aCmd;
- *pImage = pMenu->GetItemImage( nId );
- return sal_True;
- }
- }
- }
-
- if (!bValidFallback)
- {
- *pFallback = "private:factory/" + SvtModuleOptions().GetDefaultModuleName();
- }
-
- return sal_False;
-}
-
-long Select_Impl( void* pHdl, void* pVoid );
-
-SfxPopupWindow* SfxAppToolBoxControl_Impl::CreatePopupWindow()
-{
- ToolBox& rBox = GetToolBox();
- ::Rectangle aRect( rBox.GetItemRect( GetId() ) );
-
- if ( !pMenu )
- {
- ::framework::MenuConfiguration aConf( m_xContext );
- if ( m_aCommandURL == ".uno:AddDirect" )
- pMenu = aConf.CreateBookmarkMenu( m_xFrame, BOOKMARK_NEWMENU );
- else
- pMenu = aConf.CreateBookmarkMenu( m_xFrame, BOOKMARK_WIZARDMENU );
- }
-
- if ( pMenu )
- {
- pMenu->SetSelectHdl( Link( NULL, Select_Impl ) );
- pMenu->SetActivateHdl( LINK( this, SfxAppToolBoxControl_Impl, Activate ));
- rBox.SetItemDown( GetId(), sal_True );
- sal_uInt16 nSelected = pMenu->Execute( &rBox, aRect, POPUPMENU_EXECUTE_DOWN );
- if ( nSelected )
- {
- aLastURL = pMenu->GetItemCommand( nSelected );
- SetImage( pMenu->GetItemCommand( nSelected ) );
- }
-
- rBox.SetItemDown( GetId(), sal_False );
- }
-
- return 0;
-}
-
-void SfxAppToolBoxControl_Impl::SetImage( const String &rURL )
-{
- /* We accept URL's here only, which exist as items of our internal popup menu.
- All other ones will be ignored and a fallback is used ... */
- String aURL = rURL;
- String sFallback;
- Image aMenuImage;
- sal_Bool bValid = Impl_ExistURLInMenu(pMenu,aURL,&sFallback,&aMenuImage);
- if (!bValid)
- aURL = sFallback;
-
- sal_Bool bBig = SvtMiscOptions().AreCurrentSymbolsLarge();
- Image aImage = SvFileInformationManager::GetImageNoDefault( INetURLObject( aURL ), bBig );
- if ( !aImage )
- aImage = !!aMenuImage ? aMenuImage :
- SvFileInformationManager::GetImage( INetURLObject( aURL ), bBig );
- Size aBigSize( GetToolBox().GetDefaultImageSize() );
- if ( bBig && aImage.GetSizePixel() != aBigSize )
- {
- BitmapEx aScaleBmpEx( aImage.GetBitmapEx() );
- aScaleBmpEx.Scale( aBigSize, BMP_SCALE_BESTQUALITY );
- GetToolBox().SetItemImage( GetId(), Image( aScaleBmpEx ) );
- }
- else
- GetToolBox().SetItemImage( GetId(), aImage );
- aLastURL = aURL;
-}
-
-void SfxAppToolBoxControl_Impl::StateChanged
-(
- sal_uInt16 nSlotId,
- SfxItemState eState,
- const SfxPoolItem* pState
-)
-{
- if ( pState && pState->ISA(SfxStringItem) )
- {
- // Important step for following SetImage() call!
- // It needs the valid pMenu item to fullfill it's specification
- // to check for supported URLs ...
- if ( !pMenu )
- {
- ::framework::MenuConfiguration aConf( m_xContext );
- // This toolbox controller is used for two popup menus (new documents and wizards!). Create the correct
- // popup menu according to the slot ID our controller has been initialized with.
- if ( nSlotId == SID_NEWDOCDIRECT )
- pMenu = aConf.CreateBookmarkMenu( m_xFrame, BOOKMARK_NEWMENU );
- else
- pMenu = aConf.CreateBookmarkMenu( m_xFrame, BOOKMARK_WIZARDMENU );
- }
-
- GetToolBox().EnableItem( GetId(), eState != SFX_ITEM_DISABLED );
- SetImage(((const SfxStringItem*)pState)->GetValue());
- }
- else
- SfxToolBoxControl::StateChanged( nSlotId, eState, pState );
-}
-
-//--------------------------------------------------------------------
-
-void SfxAppToolBoxControl_Impl::Select( sal_Bool bMod1 )
-{
- if( aLastURL.Len() )
- {
- URL aTargetURL;
- Reference< XDispatch > xDispatch;
- Reference< XDispatchProvider > xDispatchProvider( getFrameInterface(), UNO_QUERY );
-
- if ( xDispatchProvider.is() )
- {
- aTargetURL.Complete = aLastURL;
- getURLTransformer()->parseStrict( aTargetURL );
-
- OUString aTarget( OUString("_default"));
- if ( pMenu )
- {
- ::framework::MenuConfiguration::Attributes* pMenuAttributes =
- (::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( pMenu->GetCurItemId() );
-
- if ( pMenuAttributes )
- aTarget = pMenuAttributes->aTargetFrame;
- }
-
- xDispatch = xDispatchProvider->queryDispatch( aTargetURL, aTarget, 0 );
-
- if ( xDispatch.is() )
- {
- Sequence< PropertyValue > aArgs( 1 );
-
- aArgs[0].Name = OUString("Referer");
- aArgs[0].Value = makeAny( OUString(SFX_REFERER_USER ) );
-
- ExecuteInfo* pExecuteInfo = new ExecuteInfo;
- pExecuteInfo->xDispatch = xDispatch;
- pExecuteInfo->aTargetURL = aTargetURL;
- pExecuteInfo->aArgs = aArgs;
- Application::PostUserEvent( STATIC_LINK(0, SfxAppToolBoxControl_Impl, ExecuteHdl_Impl), pExecuteInfo );
- }
- }
- }
- else
- SfxToolBoxControl::Select( bMod1 );
-}
-
-//--------------------------------------------------------------------
-long Select_Impl( void* /*pHdl*/, void* pVoid )
-{
- Menu* pMenu = (Menu*)pVoid;
- String aURL( pMenu->GetItemCommand( pMenu->GetCurItemId() ) );
-
- if( !aURL.Len() )
- return 0;
-
- Reference < ::com::sun::star::frame::XDesktop2 > xDesktop =
- ::com::sun::star::frame::Desktop::create( ::comphelper::getProcessComponentContext() );
-
- URL aTargetURL;
- aTargetURL.Complete = aURL;
- Reference < XURLTransformer > xTrans( URLTransformer::create( ::comphelper::getProcessComponentContext() ) );
- xTrans->parseStrict( aTargetURL );
-
- Reference < XDispatch > xDisp;
- if ( aTargetURL.Protocol.compareToAscii("slot:") == COMPARE_EQUAL )
- xDisp = xDesktop->queryDispatch( aTargetURL, OUString(), 0 );
- else
- {
- OUString aTargetFrame( OUString("_blank") );
- ::framework::MenuConfiguration::Attributes* pMenuAttributes =
- (::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( pMenu->GetCurItemId() );
-
- if ( pMenuAttributes )
- aTargetFrame = pMenuAttributes->aTargetFrame;
-
- xDisp = xDesktop->queryDispatch( aTargetURL, aTargetFrame , 0 );
- }
-
- if ( xDisp.is() )
- {
- SfxAppToolBoxControl_Impl::ExecuteInfo* pExecuteInfo = new SfxAppToolBoxControl_Impl::ExecuteInfo;
- pExecuteInfo->xDispatch = xDisp;
- pExecuteInfo->aTargetURL = aTargetURL;
- pExecuteInfo->aArgs = Sequence< PropertyValue >();
- Application::PostUserEvent( STATIC_LINK( 0, SfxAppToolBoxControl_Impl, ExecuteHdl_Impl), pExecuteInfo );
- }
-
- return sal_True;
-}
-
-IMPL_LINK( SfxAppToolBoxControl_Impl, Activate, Menu *, pActMenu )
-{
- if ( pActMenu )
- {
- const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
- sal_uIntPtr nSymbolsStyle = rSettings.GetSymbolsStyle();
- sal_Bool bShowMenuImages = rSettings.GetUseImagesInMenus();
-
- if (( nSymbolsStyle != m_nSymbolsStyle ) ||
- ( bShowMenuImages != m_bShowMenuImages ))
- {
- m_nSymbolsStyle = nSymbolsStyle;
- m_bShowMenuImages = bShowMenuImages;
-
- sal_uInt16 nCount = pActMenu->GetItemCount();
- for ( sal_uInt16 nSVPos = 0; nSVPos < nCount; nSVPos++ )
- {
- sal_uInt16 nId = pActMenu->GetItemId( nSVPos );
- if ( pActMenu->GetItemType( nSVPos ) != MENUITEM_SEPARATOR )
- {
- if ( bShowMenuImages )
- {
- sal_Bool bImageSet = sal_False;
- OUString aImageId;
- ::framework::MenuConfiguration::Attributes* pMenuAttributes =
- (::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( nId );
-
- if ( pMenuAttributes )
- aImageId = pMenuAttributes->aImageId; // Retrieve image id from menu attributes
-
- if ( !aImageId.isEmpty() )
- {
- Reference< ::com::sun::star::frame::XFrame > xFrame;
- Image aImage = GetImage( xFrame, aImageId, false );
- if ( !!aImage )
- {
- bImageSet = sal_True;
- pActMenu->SetItemImage( nId, aImage );
- }
- }
-
- String aCmd( pActMenu->GetItemCommand( nId ) );
- if ( !bImageSet && aCmd.Len() )
- {
- Image aImage = SvFileInformationManager::GetImage(
- INetURLObject(aCmd), false );
- if ( !!aImage )
- pActMenu->SetItemImage( nId, aImage );
- }
- }
- else
- pActMenu->SetItemImage( nId, Image() );
- }
- }
- }
-
- return sal_True;
- }
-
- return sal_False;
-}
-
-//--------------------------------------------------------------------
-
-IMPL_STATIC_LINK_NOINSTANCE( SfxAppToolBoxControl_Impl, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo )
-{
-/* i62706: Don't catch all exceptions. We hide all problems here and are not able
- to handle them on higher levels.
- try
- {
-*/
- // Asynchronous execution as this can lead to our own destruction!
- // Framework can recycle our current frame and the layout manager disposes all user interface
- // elements if a component gets detached from its frame!
- pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs );
- delete pExecuteInfo;
- return 0;
-}
-
-//--------------------------------------------------------------------
-
-void SfxAppToolBoxControl_Impl::Click( )
-{
-}
-
-//--------------------------------------------------------------------
-
SfxRecentFilesToolBoxControl::SfxRecentFilesToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox )
: SfxToolBoxControl( nSlotId, nId, rBox )
{
More information about the Libreoffice-commits
mailing list