summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-11-06 13:06:51 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-11-06 13:06:51 +0100
commite7be53a227f52d055dbce58398526775feac279b (patch)
tree3021ca0e553f1344f7de8be527953cde963567fb /forms
parent0364e81992fbc3cada8983321366d32545d44b0d (diff)
#i106671# use proper UNO API to not only retrieve images for our slots, but also the command descriptions, which are to be used as quick help text
Diffstat (limited to 'forms')
-rw-r--r--forms/source/helper/commanddescriptionprovider.cxx139
-rw-r--r--forms/source/helper/commandimageprovider.cxx8
-rw-r--r--forms/source/helper/makefile.mk1
-rw-r--r--forms/source/inc/commanddescriptionprovider.hxx68
-rw-r--r--forms/source/inc/commandimageprovider.hxx4
-rw-r--r--forms/source/solar/component/navbarcontrol.cxx6
-rw-r--r--forms/source/solar/component/navbarcontrol.hxx3
-rw-r--r--forms/source/solar/control/navtoolbar.cxx13
-rw-r--r--forms/source/solar/inc/navtoolbar.hxx12
9 files changed, 244 insertions, 10 deletions
diff --git a/forms/source/helper/commanddescriptionprovider.cxx b/forms/source/helper/commanddescriptionprovider.cxx
new file mode 100644
index 000000000000..87692c5b5b82
--- /dev/null
+++ b/forms/source/helper/commanddescriptionprovider.cxx
@@ -0,0 +1,139 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_forms.hxx"
+
+#include "commanddescriptionprovider.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/namedvaluecollection.hxx>
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace frm
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::frame::XModuleManager;
+ using ::com::sun::star::beans::PropertyValue;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= DefaultCommandDescriptionProvider
+ //====================================================================
+ class DefaultCommandDescriptionProvider : public ICommandDescriptionProvider
+ {
+ public:
+ DefaultCommandDescriptionProvider( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
+ {
+ impl_init_nothrow( _rContext, _rxDocument );
+ }
+
+ ~DefaultCommandDescriptionProvider()
+ {
+ }
+
+ // ICommandDescriptionProvider
+ virtual ::rtl::OUString getCommandDescription( const ::rtl::OUString& _rCommandURL ) const;
+
+ private:
+ void impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument );
+
+ private:
+ Reference< XNameAccess > m_xCommandAccess;
+ };
+
+
+ //--------------------------------------------------------------------
+ void DefaultCommandDescriptionProvider::impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
+ {
+ OSL_ENSURE( _rxDocument.is(), "DefaultCommandDescriptionProvider::impl_init_nothrow: no document => no command descriptions!" );
+ if ( !_rxDocument.is() )
+ return;
+
+ try
+ {
+ Reference< XModuleManager > xModuleManager( _rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
+ ::rtl::OUString sModuleID = xModuleManager->identify( _rxDocument );
+
+ Reference< XNameAccess > xUICommandDescriptions( _rContext.createComponent( "com.sun.star.frame.UICommandDescription" ), UNO_QUERY_THROW );
+ m_xCommandAccess.set( xUICommandDescriptions->getByName( sModuleID ), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString DefaultCommandDescriptionProvider::getCommandDescription( const ::rtl::OUString& _rCommandURL ) const
+ {
+ if ( !m_xCommandAccess.is() )
+ return ::rtl::OUString();
+
+ try
+ {
+ ::comphelper::NamedValueCollection aCommandProperties( m_xCommandAccess->getByName( _rCommandURL ) );
+ return aCommandProperties.getOrDefault( "Name", ::rtl::OUString() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return ::rtl::OUString();
+ }
+
+ //--------------------------------------------------------------------
+ PCommandDescriptionProvider createDocumentCommandDescriptionProvider(
+ const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
+ {
+ PCommandDescriptionProvider pDescriptionProvider( new DefaultCommandDescriptionProvider( _rContext, _rxDocument ) );
+ return pDescriptionProvider;
+ }
+
+//........................................................................
+} // namespace frm
+//........................................................................
diff --git a/forms/source/helper/commandimageprovider.cxx b/forms/source/helper/commandimageprovider.cxx
index 9bc5e1c1f8a2..1da9b7348587 100644
--- a/forms/source/helper/commandimageprovider.cxx
+++ b/forms/source/helper/commandimageprovider.cxx
@@ -23,6 +23,9 @@
* for a copy of the LGPLv3 License.
************************************************************************/
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_forms.hxx"
+
#include "commandimageprovider.hxx"
/** === begin UNO includes === **/
@@ -33,7 +36,6 @@
#include <com/sun/star/ui/ImageType.hpp>
/** === end UNO includes === **/
-#include <comphelper/componentcontext.hxx>
#include <tools/diagnose_ex.h>
//........................................................................
@@ -166,10 +168,10 @@ namespace frm
}
//--------------------------------------------------------------------
- ::boost::shared_ptr< ICommandImageProvider > createDocumentCommandImageProvider(
+ PCommandImageProvider createDocumentCommandImageProvider(
const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
{
- ::boost::shared_ptr< ICommandImageProvider > pImageProvider( new DocumentCommandImageProvider( _rContext, _rxDocument ) );
+ PCommandImageProvider pImageProvider( new DocumentCommandImageProvider( _rContext, _rxDocument ) );
return pImageProvider;
}
diff --git a/forms/source/helper/makefile.mk b/forms/source/helper/makefile.mk
index 5247261c8c3d..e451048dd0de 100644
--- a/forms/source/helper/makefile.mk
+++ b/forms/source/helper/makefile.mk
@@ -54,6 +54,7 @@ SLOFILES= $(SLO)$/formnavigation.obj \
$(SLO)$/windowstateguard.obj \
$(SLO)$/resettable.obj \
$(SLO)$/commandimageprovider.obj \
+ $(SLO)$/commanddescriptionprovider.obj \
# --- Targets ----------------------------------
diff --git a/forms/source/inc/commanddescriptionprovider.hxx b/forms/source/inc/commanddescriptionprovider.hxx
new file mode 100644
index 000000000000..64d28e2aabdc
--- /dev/null
+++ b/forms/source/inc/commanddescriptionprovider.hxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2009 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+#ifndef COMMANDDESCRIPTIONPROVIDER_HXX
+#define COMMANDDESCRIPTIONPROVIDER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+
+#include <boost/shared_ptr.hpp>
+
+//........................................................................
+namespace frm
+{
+//........................................................................
+
+ //====================================================================
+ //= ICommandDescriptionProvider
+ //====================================================================
+ class SAL_NO_VTABLE ICommandDescriptionProvider
+ {
+ public:
+ virtual ::rtl::OUString getCommandDescription( const ::rtl::OUString& _rCommandURL ) const = 0;
+
+ virtual ~ICommandDescriptionProvider() { }
+ };
+
+ typedef ::boost::shared_ptr< const ICommandDescriptionProvider > PCommandDescriptionProvider;
+
+ //=====================================================================
+ //= factory
+ //=====================================================================
+ PCommandDescriptionProvider
+ createDocumentCommandDescriptionProvider(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocument
+ );
+
+//........................................................................
+} // namespace frm
+//........................................................................
+
+#endif // COMMANDDESCRIPTIONPROVIDER_HXX
diff --git a/forms/source/inc/commandimageprovider.hxx b/forms/source/inc/commandimageprovider.hxx
index 1d527a91e170..7bbb719e410d 100644
--- a/forms/source/inc/commandimageprovider.hxx
+++ b/forms/source/inc/commandimageprovider.hxx
@@ -59,10 +59,12 @@ namespace frm
virtual ~ICommandImageProvider() { }
};
+ typedef ::boost::shared_ptr< const ICommandImageProvider > PCommandImageProvider;
+
//=====================================================================
//= factory
//=====================================================================
- ::boost::shared_ptr< ICommandImageProvider >
+ PCommandImageProvider
createDocumentCommandImageProvider(
const ::comphelper::ComponentContext& _rContext,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocument
diff --git a/forms/source/solar/component/navbarcontrol.cxx b/forms/source/solar/component/navbarcontrol.cxx
index 7ff4e9e78cab..eb975910a5da 100644
--- a/forms/source/solar/component/navbarcontrol.cxx
+++ b/forms/source/solar/component/navbarcontrol.cxx
@@ -37,6 +37,8 @@
#include "FormComponent.hxx"
#include "componenttools.hxx"
#include "navtoolbar.hxx"
+#include "commandimageprovider.hxx"
+#include "commanddescriptionprovider.hxx"
/** === begin UNO includes === **/
#include <com/sun/star/awt/XView.hpp>
@@ -283,10 +285,12 @@ namespace frm
pPeer->acquire(); // by definition, the returned object is aquired once
// the VCL control for the peer
+ Reference< XModel > xContextDocument( getXModel( _rxModel ) );
NavigationToolBar* pNavBar = new NavigationToolBar(
_pParentWindow,
lcl_getWinBits_nothrow( _rxModel ),
- createDocumentCommandImageProvider( _rxORB, getXModel( _rxModel ) )
+ createDocumentCommandImageProvider( _rxORB, xContextDocument ),
+ createDocumentCommandDescriptionProvider( _rxORB, xContextDocument )
);
// some knittings
diff --git a/forms/source/solar/component/navbarcontrol.hxx b/forms/source/solar/component/navbarcontrol.hxx
index ff379c23a9f1..62d44774d0b3 100644
--- a/forms/source/solar/component/navbarcontrol.hxx
+++ b/forms/source/solar/component/navbarcontrol.hxx
@@ -32,10 +32,11 @@
#define FORMS_NAVBARCONTROL_HXX
#include "formnavigation.hxx"
-#include "commandimageprovider.hxx"
+/** === begin UNO includes === **/
#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
#include <com/sun/star/frame/XStatusListener.hpp>
+/** === end UNO includes === **/
#include <toolkit/controls/unocontrol.hxx>
#include <toolkit/awt/vclxwindow.hxx>
diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx
index 0cde5b58195b..bfefb05f8ab6 100644
--- a/forms/source/solar/control/navtoolbar.cxx
+++ b/forms/source/solar/control/navtoolbar.cxx
@@ -36,6 +36,7 @@
#include "featuredispatcher.hxx"
#include "frm_resource.hrc"
#include "commandimageprovider.hxx"
+#include "commanddescriptionprovider.hxx"
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/form/runtime/FormFeature.hpp>
@@ -157,10 +158,12 @@ namespace frm
//=====================================================================
DBG_NAME( NavigationToolBar )
//---------------------------------------------------------------------
- NavigationToolBar::NavigationToolBar( Window* _pParent, WinBits _nStyle, const ::boost::shared_ptr< const ICommandImageProvider >& _pImageProvider )
+ NavigationToolBar::NavigationToolBar( Window* _pParent, WinBits _nStyle, const PCommandImageProvider& _pImageProvider,
+ const PCommandDescriptionProvider& _pDescriptionProvider )
:Window( _pParent, _nStyle )
,m_pDispatcher( NULL )
,m_pImageProvider( _pImageProvider )
+ ,m_pDescriptionProvider( _pDescriptionProvider )
,m_eImageSize( eSmall )
,m_pToolbar( NULL )
{
@@ -310,8 +313,14 @@ namespace frm
// insert the entry
m_pToolbar->InsertItem( pSupportedFeatures->nId, String(), pSupportedFeatures->bRepeat ? TIB_REPEAT : 0 );
m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, String() ); // TODO
+
if ( !isArtificialItem( pSupportedFeatures->nId ) )
- m_pToolbar->SetItemCommand( pSupportedFeatures->nId, lcl_getCommandURL( pSupportedFeatures->nId ) );
+ {
+ ::rtl::OUString sCommandURL( lcl_getCommandURL( pSupportedFeatures->nId ) );
+ m_pToolbar->SetItemCommand( pSupportedFeatures->nId, sCommandURL );
+ if ( m_pDescriptionProvider )
+ m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, m_pDescriptionProvider->getCommandDescription( sCommandURL ) );
+ }
if ( pSupportedFeatures->bItemWindow )
{
diff --git a/forms/source/solar/inc/navtoolbar.hxx b/forms/source/solar/inc/navtoolbar.hxx
index b7b5af8e8d38..eaa3717bc4d2 100644
--- a/forms/source/solar/inc/navtoolbar.hxx
+++ b/forms/source/solar/inc/navtoolbar.hxx
@@ -43,6 +43,7 @@ namespace frm
class IFeatureDispatcher;
class ICommandImageProvider;
+ class ICommandDescriptionProvider;
class ImplNavToolBar;
@@ -68,14 +69,21 @@ namespace frm
private:
const IFeatureDispatcher* m_pDispatcher;
- ::boost::shared_ptr< const ICommandImageProvider >
+ const ::boost::shared_ptr< const ICommandImageProvider >
m_pImageProvider;
+ const ::boost::shared_ptr< const ICommandDescriptionProvider >
+ m_pDescriptionProvider;
ImageSize m_eImageSize;
ImplNavToolBar* m_pToolbar;
::std::vector< Window* > m_aChildWins;
public:
- NavigationToolBar( Window* _pParent, WinBits _nStyle, const ::boost::shared_ptr< const ICommandImageProvider >& _pImageProvider );
+ NavigationToolBar(
+ Window* _pParent,
+ WinBits _nStyle,
+ const ::boost::shared_ptr< const ICommandImageProvider >& _pImageProvider,
+ const ::boost::shared_ptr< const ICommandDescriptionProvider >& _pDescriptionProvider
+ );
~NavigationToolBar( );
/** sets the dispatcher which is to be used for the features