summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-11-06 11:48:38 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-11-06 11:48:38 +0100
commit614e787c171d6316f2ff493865ebed3d35824349 (patch)
tree17f739ad7e4295bab3975b9a92d5674d1bc6999d /forms
parent595e1c2ebb346b3f7c69837fcf73d943bcade582 (diff)
#i106671# retrieve the images from the document's/module's XImageManager, not from some obscure SfxImageManager
Diffstat (limited to 'forms')
-rw-r--r--forms/source/helper/commandimageprovider.cxx178
-rw-r--r--forms/source/helper/makefile.mk1
-rw-r--r--forms/source/inc/commandimageprovider.hxx75
-rw-r--r--forms/source/solar/component/navbarcontrol.cxx23
-rw-r--r--forms/source/solar/component/navbarcontrol.hxx15
-rw-r--r--forms/source/solar/control/navtoolbar.cxx147
-rw-r--r--forms/source/solar/inc/navtoolbar.hxx38
7 files changed, 387 insertions, 90 deletions
diff --git a/forms/source/helper/commandimageprovider.cxx b/forms/source/helper/commandimageprovider.cxx
new file mode 100644
index 000000000000..9bc5e1c1f8a2
--- /dev/null
+++ b/forms/source/helper/commandimageprovider.cxx
@@ -0,0 +1,178 @@
+/*************************************************************************
+* 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.
+************************************************************************/
+
+#include "commandimageprovider.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ui/XImageManager.hpp>
+#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/ui/ImageType.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.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::ui::XImageManager;
+ using ::com::sun::star::ui::XUIConfigurationManagerSupplier;
+ using ::com::sun::star::ui::XUIConfigurationManager;
+ using ::com::sun::star::ui::XModuleUIConfigurationManagerSupplier;
+ using ::com::sun::star::frame::XModuleManager;
+ using ::com::sun::star::graphic::XGraphic;
+ /** === end UNO using === **/
+ namespace ImageType = ::com::sun::star::ui::ImageType;
+
+ //====================================================================
+ //= DocumentCommandImageProvider
+ //====================================================================
+ class DocumentCommandImageProvider : public ICommandImageProvider
+ {
+ public:
+ DocumentCommandImageProvider( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
+ {
+ impl_init_nothrow( _rContext, _rxDocument );
+ }
+ virtual ~DocumentCommandImageProvider()
+ {
+ }
+
+ // ICommandImageProvider
+ virtual CommandImages getCommandImages( const CommandURLs& _rCommandURLs, const bool _bLarge, const bool _bHiContrast ) const;
+
+ private:
+ void impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument );
+
+ private:
+ Reference< XImageManager > m_xDocumentImageManager;
+ Reference< XImageManager > m_xModuleImageManager;
+ };
+
+ //--------------------------------------------------------------------
+ void DocumentCommandImageProvider::impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
+ {
+ OSL_ENSURE( _rxDocument.is(), "DocumentCommandImageProvider::impl_init_nothrow: no document => no images!" );
+ if ( !_rxDocument.is() )
+ return;
+
+ // obtain the image manager of the document
+ try
+ {
+ Reference< XUIConfigurationManagerSupplier > xSuppUIConfig( _rxDocument, UNO_QUERY_THROW );
+ Reference< XUIConfigurationManager > xUIConfig( xSuppUIConfig->getUIConfigurationManager(), UNO_QUERY );
+ m_xDocumentImageManager.set( xUIConfig->getImageManager(), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // obtain the image manager or the module
+ try
+ {
+ Reference< XModuleManager > xModuleManager( _rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
+ ::rtl::OUString sModuleID = xModuleManager->identify( _rxDocument );
+
+ Reference< XModuleUIConfigurationManagerSupplier > xSuppUIConfig(
+ _rContext.createComponent( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ), UNO_QUERY_THROW );
+ Reference< XUIConfigurationManager > xUIConfig(
+ xSuppUIConfig->getUIConfigurationManager( sModuleID ), UNO_SET_THROW );
+ m_xModuleImageManager.set( xUIConfig->getImageManager(), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ CommandImages DocumentCommandImageProvider::getCommandImages( const CommandURLs& _rCommandURLs, const bool _bLarge, const bool _bHiContrast ) const
+ {
+ const size_t nCommandCount = _rCommandURLs.getLength();
+ CommandImages aImages( nCommandCount );
+ try
+ {
+ const sal_Int16 nImageType =
+ ( _bLarge ? ImageType::SIZE_LARGE : ImageType::SIZE_DEFAULT )
+ + ( _bHiContrast ? ImageType::COLOR_HIGHCONTRAST : ImageType::COLOR_NORMAL );
+
+ Sequence< Reference< XGraphic > > aDocImages( nCommandCount );
+ Sequence< Reference< XGraphic > > aModImages( nCommandCount );
+
+ // first try the document image manager
+ if ( m_xDocumentImageManager.is() )
+ aDocImages = m_xDocumentImageManager->getImages( nImageType, _rCommandURLs );
+
+ // then the module's image manager
+ if ( m_xModuleImageManager.is() )
+ aModImages = m_xModuleImageManager->getImages( nImageType, _rCommandURLs );
+
+ ENSURE_OR_THROW( aDocImages.getLength() == nCommandCount, "illegal array size returned by getImages (document image manager)" );
+ ENSURE_OR_THROW( aModImages.getLength() == nCommandCount, "illegal array size returned by getImages (module image manager)" );
+
+ for ( size_t i=0; i<nCommandCount; ++i )
+ {
+ if ( aDocImages[i].is() )
+ aImages[i] = Image( aDocImages[i] );
+ else
+ aImages[i] = Image( aModImages[i] );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return aImages;
+ }
+
+ //--------------------------------------------------------------------
+ ::boost::shared_ptr< ICommandImageProvider > createDocumentCommandImageProvider(
+ const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument )
+ {
+ ::boost::shared_ptr< ICommandImageProvider > pImageProvider( new DocumentCommandImageProvider( _rContext, _rxDocument ) );
+ return pImageProvider;
+ }
+
+//........................................................................
+} // namespace frm
+//........................................................................
diff --git a/forms/source/helper/makefile.mk b/forms/source/helper/makefile.mk
index 5739d1fcb6d0..5247261c8c3d 100644
--- a/forms/source/helper/makefile.mk
+++ b/forms/source/helper/makefile.mk
@@ -53,6 +53,7 @@ SLOFILES= $(SLO)$/formnavigation.obj \
$(SLO)$/urltransformer.obj \
$(SLO)$/windowstateguard.obj \
$(SLO)$/resettable.obj \
+ $(SLO)$/commandimageprovider.obj \
# --- Targets ----------------------------------
diff --git a/forms/source/inc/commandimageprovider.hxx b/forms/source/inc/commandimageprovider.hxx
new file mode 100644
index 000000000000..1d527a91e170
--- /dev/null
+++ b/forms/source/inc/commandimageprovider.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+* 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 COMMANDIMAGEPROVIDER_HXX
+#define COMMANDIMAGEPROVIDER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <vcl/image.hxx>
+
+#include <boost/shared_ptr.hpp>
+
+//........................................................................
+namespace frm
+{
+//........................................................................
+
+ //=====================================================================
+ //= ICommandImageProvider
+ //=====================================================================
+ typedef ::rtl::OUString CommandURL;
+ typedef ::com::sun::star::uno::Sequence< CommandURL > CommandURLs;
+ typedef ::std::vector< Image > CommandImages;
+
+ class SAL_NO_VTABLE ICommandImageProvider
+ {
+ public:
+ virtual CommandImages getCommandImages(
+ const CommandURLs& _rCommandURLs,
+ const bool _bLarge,
+ const bool _bHiContrast
+ ) const = 0;
+
+ virtual ~ICommandImageProvider() { }
+ };
+
+ //=====================================================================
+ //= factory
+ //=====================================================================
+ ::boost::shared_ptr< ICommandImageProvider >
+ createDocumentCommandImageProvider(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocument
+ );
+
+//........................................................................
+} // namespace frm
+//........................................................................
+
+#endif // COMMANDIMAGEPROVIDER_HXX
diff --git a/forms/source/solar/component/navbarcontrol.cxx b/forms/source/solar/component/navbarcontrol.cxx
index ecc1771fe955..7ff4e9e78cab 100644
--- a/forms/source/solar/component/navbarcontrol.cxx
+++ b/forms/source/solar/component/navbarcontrol.cxx
@@ -34,18 +34,21 @@
#include "navbarcontrol.hxx"
#include "frm_strings.hxx"
#include "frm_module.hxx"
-#include "navtoolbar.hxx"
#include "FormComponent.hxx"
+#include "componenttools.hxx"
+#include "navtoolbar.hxx"
/** === begin UNO includes === **/
#include <com/sun/star/awt/XView.hpp>
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/form/runtime/FormFeature.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
/** === end UNO includes === **/
#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
#include <vcl/svapp.hxx>
-#include <svx/svxids.hrc>
//--------------------------------------------------------------------------
extern "C" void SAL_CALL createRegistryInfo_ONavigationBarControl()
@@ -63,6 +66,7 @@ namespace frm
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::graphic;
namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
#define FORWARD_TO_PEER_1( unoInterface, method, param1 ) \
@@ -131,7 +135,8 @@ namespace frm
//------------------------------------------------------------------
namespace
{
- static WinBits getWinBits( const Reference< XControlModel >& _rxModel )
+ //..............................................................
+ static WinBits lcl_getWinBits_nothrow( const Reference< XControlModel >& _rxModel )
{
WinBits nBits = 0;
try
@@ -151,7 +156,7 @@ namespace frm
}
catch( const Exception& )
{
- DBG_ERROR( "::getWinBits: caught an exception!" );
+ DBG_UNHANDLED_EXCEPTION();
}
return nBits;
}
@@ -177,7 +182,7 @@ namespace frm
}
// create the peer
- ONavigationBarPeer* pPeer = ONavigationBarPeer::Create( m_xORB, pParentWin, getWinBits( getModel() ) );
+ ONavigationBarPeer* pPeer = ONavigationBarPeer::Create( m_xORB, pParentWin, getModel() );
DBG_ASSERT( pPeer, "ONavigationBarControl::createPeer: invalid peer returned!" );
if ( pPeer )
// by definition, the returned component is aquired once
@@ -269,7 +274,7 @@ namespace frm
DBG_NAME( ONavigationBarPeer )
//------------------------------------------------------------------
ONavigationBarPeer* ONavigationBarPeer::Create( const Reference< XMultiServiceFactory >& _rxORB,
- Window* _pParentWindow, WinBits _nStyle )
+ Window* _pParentWindow, const Reference< XControlModel >& _rxModel )
{
DBG_TESTSOLARMUTEX();
@@ -278,7 +283,11 @@ namespace frm
pPeer->acquire(); // by definition, the returned object is aquired once
// the VCL control for the peer
- NavigationToolBar* pNavBar = new NavigationToolBar( _pParentWindow, _nStyle );
+ NavigationToolBar* pNavBar = new NavigationToolBar(
+ _pParentWindow,
+ lcl_getWinBits_nothrow( _rxModel ),
+ createDocumentCommandImageProvider( _rxORB, getXModel( _rxModel ) )
+ );
// some knittings
pNavBar->setDispatcher( pPeer );
diff --git a/forms/source/solar/component/navbarcontrol.hxx b/forms/source/solar/component/navbarcontrol.hxx
index 37b62fa2668b..ff379c23a9f1 100644
--- a/forms/source/solar/component/navbarcontrol.hxx
+++ b/forms/source/solar/component/navbarcontrol.hxx
@@ -31,14 +31,17 @@
#ifndef FORMS_NAVBARCONTROL_HXX
#define FORMS_NAVBARCONTROL_HXX
+#include "formnavigation.hxx"
+#include "commandimageprovider.hxx"
+
+#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
+#include <com/sun/star/frame/XStatusListener.hpp>
+
#include <toolkit/controls/unocontrol.hxx>
#include <toolkit/awt/vclxwindow.hxx>
#include <comphelper/uno3.hxx>
#include <cppuhelper/implbase1.hxx>
#include <vcl/wintypes.hxx>
-#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
-#include <com/sun/star/frame/XStatusListener.hpp>
-#include "formnavigation.hxx"
//.........................................................................
namespace frm
@@ -111,11 +114,13 @@ namespace frm
static ONavigationBarPeer* Create(
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
Window* _pParentWindow,
- WinBits _nStyle
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel
);
protected:
- ONavigationBarPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB );
+ ONavigationBarPeer(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
~ONavigationBarPeer();
public:
diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx
index c5d52261d8a8..0cde5b58195b 100644
--- a/forms/source/solar/control/navtoolbar.cxx
+++ b/forms/source/solar/control/navtoolbar.cxx
@@ -35,12 +35,12 @@
#include "frm_resource.hxx"
#include "featuredispatcher.hxx"
#include "frm_resource.hrc"
+#include "commandimageprovider.hxx"
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/form/runtime/FormFeature.hpp>
#include <sfx2/imgmgr.hxx>
-#include <svx/svxids.hrc>
#include <vcl/fixed.hxx>
#include <memory>
@@ -79,32 +79,36 @@ namespace frm
return _rColor.IsDark();
}
- sal_Int32 lcl_getSlotId( const sal_Int16 _nFormFeature )
+ ::rtl::OUString lcl_getCommandURL( const sal_Int16 _nFormFeature )
{
+ const sal_Char* pAsciiCommandName = NULL;
switch ( _nFormFeature )
{
- case FormFeature::MoveAbsolute : return SID_FM_RECORD_ABSOLUTE;
- case FormFeature::TotalRecords : return SID_FM_RECORD_TOTAL;
- case FormFeature::MoveToFirst : return SID_FM_RECORD_FIRST;
- case FormFeature::MoveToPrevious : return SID_FM_RECORD_PREV;
- case FormFeature::MoveToNext : return SID_FM_RECORD_NEXT;
- case FormFeature::MoveToLast : return SID_FM_RECORD_LAST;
- case FormFeature::SaveRecordChanges : return SID_FM_RECORD_SAVE;
- case FormFeature::UndoRecordChanges : return SID_FM_RECORD_UNDO;
- case FormFeature::MoveToInsertRow : return SID_FM_RECORD_NEW;
- case FormFeature::DeleteRecord : return SID_FM_RECORD_DELETE;
- case FormFeature::ReloadForm : return SID_FM_REFRESH;
- case FormFeature::RefreshCurrentControl : return SID_FM_REFRESH_FORM_CONTROL;
- case FormFeature::SortAscending : return SID_FM_SORTUP;
- case FormFeature::SortDescending : return SID_FM_SORTDOWN;
- case FormFeature::InteractiveSort : return SID_FM_ORDERCRIT;
- case FormFeature::AutoFilter : return SID_FM_AUTOFILTER;
- case FormFeature::InteractiveFilter : return SID_FM_FILTERCRIT;
- case FormFeature::ToggleApplyFilter : return SID_FM_FORM_FILTERED;
- case FormFeature::RemoveFilterAndSort : return SID_FM_REMOVE_FILTER_SORT;
+ case FormFeature::MoveAbsolute : pAsciiCommandName = "AbsoluteRecord"; break;
+ case FormFeature::TotalRecords : pAsciiCommandName = "RecTotal"; break;
+ case FormFeature::MoveToFirst : pAsciiCommandName = "FirstRecord"; break;
+ case FormFeature::MoveToPrevious : pAsciiCommandName = "PrevRecord"; break;
+ case FormFeature::MoveToNext : pAsciiCommandName = "NextRecord"; break;
+ case FormFeature::MoveToLast : pAsciiCommandName = "LastRecord"; break;
+ case FormFeature::SaveRecordChanges : pAsciiCommandName = "RecSave"; break;
+ case FormFeature::UndoRecordChanges : pAsciiCommandName = "RecUndo"; break;
+ case FormFeature::MoveToInsertRow : pAsciiCommandName = "NewRecord"; break;
+ case FormFeature::DeleteRecord : pAsciiCommandName = "DeleteRecord"; break;
+ case FormFeature::ReloadForm : pAsciiCommandName = "Refresh"; break;
+ case FormFeature::RefreshCurrentControl : pAsciiCommandName = "RefreshFormControl"; break;
+ case FormFeature::SortAscending : pAsciiCommandName = "Sortup"; break;
+ case FormFeature::SortDescending : pAsciiCommandName = "SortDown"; break;
+ case FormFeature::InteractiveSort : pAsciiCommandName = "OrderCrit"; break;
+ case FormFeature::AutoFilter : pAsciiCommandName = "AutoFilter"; break;
+ case FormFeature::InteractiveFilter : pAsciiCommandName = "FilterCrit"; break;
+ case FormFeature::ToggleApplyFilter : pAsciiCommandName = "FormFiltered"; break;
+ case FormFeature::RemoveFilterAndSort : pAsciiCommandName = "RemoveFilterSort"; break;
}
- OSL_ENSURE( isArtificialItem( _nFormFeature ), "lcl_getSlotId: unknown FormFeature!" );
- return 0;
+ if ( pAsciiCommandName != NULL )
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ) ) + ::rtl::OUString::createFromAscii( pAsciiCommandName );
+
+ OSL_ENSURE( false, "lcl_getCommandURL: unknown FormFeature!" );
+ return ::rtl::OUString();
}
}
@@ -153,9 +157,10 @@ namespace frm
//=====================================================================
DBG_NAME( NavigationToolBar )
//---------------------------------------------------------------------
- NavigationToolBar::NavigationToolBar( Window* _pParent, WinBits _nStyle )
+ NavigationToolBar::NavigationToolBar( Window* _pParent, WinBits _nStyle, const ::boost::shared_ptr< const ICommandImageProvider >& _pImageProvider )
:Window( _pParent, _nStyle )
,m_pDispatcher( NULL )
+ ,m_pImageProvider( _pImageProvider )
,m_eImageSize( eSmall )
,m_pToolbar( NULL )
{
@@ -302,20 +307,11 @@ namespace frm
if ( pSupportedFeatures->nId )
{ // it's _not_ a separator
- // the text(s) of the item
- String sItemText;
- String sItemHelpText;
-
- // TODO/CLEANUP: this code does nothing(!) nowadays
- //SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( NULL );
- //sItemText = rSlotPool.GetSlotName( pSupportedFeatures->nId, &sItemHelpText );
-
// insert the entry
- m_pToolbar->InsertItem( pSupportedFeatures->nId, sItemText, pSupportedFeatures->bRepeat ? TIB_REPEAT : 0 );
- m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, sItemHelpText );
+ m_pToolbar->InsertItem( pSupportedFeatures->nId, String(), pSupportedFeatures->bRepeat ? TIB_REPEAT : 0 );
+ m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, String() ); // TODO
if ( !isArtificialItem( pSupportedFeatures->nId ) )
- m_pToolbar->SetHelpId( pSupportedFeatures->nId, lcl_getSlotId( pSupportedFeatures->nId ) );
-
+ m_pToolbar->SetItemCommand( pSupportedFeatures->nId, lcl_getCommandURL( pSupportedFeatures->nId ) );
if ( pSupportedFeatures->bItemWindow )
{
@@ -360,39 +356,66 @@ namespace frm
forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth, NULL );
- implSetImageSize( m_eImageSize, true );
+ implUpdateImages();
}
//---------------------------------------------------------------------
- void NavigationToolBar::implSetImageSize( ImageSize _eSize, bool _bForce )
+ void NavigationToolBar::implUpdateImages()
{
- if ( ( _eSize != m_eImageSize ) || _bForce )
+ OSL_ENSURE( m_pImageProvider, "NavigationToolBar::implUpdateImages: no image provider => no images!" );
+ if ( !m_pImageProvider )
+ return;
+
+ const bool bIsHighContrast = lcl_isHighContrast( GetBackground().GetColor() );
+
+ const USHORT nItemCount = m_pToolbar->GetItemCount();
+
+ // collect the FormFeatures in the toolbar
+ typedef ::std::vector< sal_Int16 > FormFeatures;
+ FormFeatures aFormFeatures;
+ aFormFeatures.reserve( nItemCount );
+
+ for ( USHORT i=0; i<nItemCount; ++i )
{
- m_eImageSize = _eSize;
+ USHORT nId = m_pToolbar->GetItemId( i );
+ if ( ( TOOLBOXITEM_BUTTON == m_pToolbar->GetItemType( i ) ) && !isArtificialItem( nId ) )
+ aFormFeatures.push_back( nId );
+ }
+
+ // translate them into command URLs
+ CommandURLs aCommandURLs( aFormFeatures.size() );
+ for ( FormFeatures::const_iterator formFeature = aFormFeatures.begin();
+ formFeature != aFormFeatures.end();
+ ++formFeature
+ )
+ {
+ aCommandURLs[ formFeature - aFormFeatures.begin() ] = lcl_getCommandURL( *formFeature );
+ }
- ::std::auto_ptr< SfxImageManager > pImageManager( new SfxImageManager( NULL ) );
- const bool bIsHighContrast = lcl_isHighContrast( GetBackground().GetColor() );
+ // retrieve the images for the command URLs
+ CommandImages aCommandImages = m_pImageProvider->getCommandImages( aCommandURLs, m_eImageSize == eLarge, bIsHighContrast );
- const USHORT nCount = m_pToolbar->GetItemCount();
- for ( USHORT i=0; i<nCount; ++i )
- {
- USHORT nId = m_pToolbar->GetItemId( i );
- if ( TOOLBOXITEM_BUTTON == m_pToolbar->GetItemType( i ) )
- {
- Image aItemImage;
- if ( !isArtificialItem( nId ) )
- aItemImage = pImageManager->GetImage( lcl_getSlotId( nId ), m_eImageSize == eLarge, bIsHighContrast );
- m_pToolbar->SetItemImage( nId, aItemImage );
- }
- }
+ // and set them at the toolbar
+ CommandImages::const_iterator commandImage = aCommandImages.begin();
+ for ( FormFeatures::const_iterator formFeature = aFormFeatures.begin();
+ formFeature != aFormFeatures.end();
+ ++formFeature, ++commandImage
+ )
+ {
+ m_pToolbar->SetItemImage( *formFeature, *commandImage );
+ }
- // TODO: using the "official" command URLs belonging to a FormFeature, it should be possible to obtain
- // the images from some global UNO service, instead of using the SfxImageManager, and SFX slot IDs.
- // Also, those URLs allow (/me thinks) to obtain the command texts, which we could set at the toolbox,
- // so they would appear as tooltip.
+ // parts of our layout is dependent on the size of our icons
+ Resize();
+ }
- // parts of our layout is dependent on the size of our icons
- Resize();
+ //---------------------------------------------------------------------
+ void NavigationToolBar::implSetImageSize( ImageSize _eSize )
+ {
+ if ( _eSize != m_eImageSize )
+ {
+ m_eImageSize = _eSize;
+ implUpdateImages();
}
}
@@ -524,7 +547,7 @@ namespace frm
// the contrast of the background color may have changed, so force
// the images to be rebuild (high contrast requires a possibly different
// image set)
- implSetImageSize( m_eImageSize, true );
+ implUpdateImages();
}
//---------------------------------------------------------------------
@@ -537,7 +560,7 @@ namespace frm
// the contrast of the background color may have changed, so force
// the images to be rebuild (high contrast requires a possibly different
// image set)
- implSetImageSize( m_eImageSize, true );
+ implUpdateImages();
}
//---------------------------------------------------------------------
diff --git a/forms/source/solar/inc/navtoolbar.hxx b/forms/source/solar/inc/navtoolbar.hxx
index 107a9cc2615b..b7b5af8e8d38 100644
--- a/forms/source/solar/inc/navtoolbar.hxx
+++ b/forms/source/solar/inc/navtoolbar.hxx
@@ -34,14 +34,18 @@
#include <vcl/toolbox.hxx>
#include <vcl/field.hxx>
+#include <boost/shared_ptr.hpp>
+
//.........................................................................
namespace frm
{
//.........................................................................
class IFeatureDispatcher;
+ class ICommandImageProvider;
class ImplNavToolBar;
+
//=====================================================================
//= NavigationToolBar
//=====================================================================
@@ -63,13 +67,15 @@ namespace frm
};
private:
- const IFeatureDispatcher* m_pDispatcher;
- ImageSize m_eImageSize;
- ImplNavToolBar* m_pToolbar;
- ::std::vector< Window* > m_aChildWins;
+ const IFeatureDispatcher* m_pDispatcher;
+ ::boost::shared_ptr< const ICommandImageProvider >
+ m_pImageProvider;
+ ImageSize m_eImageSize;
+ ImplNavToolBar* m_pToolbar;
+ ::std::vector< Window* > m_aChildWins;
public:
- NavigationToolBar( Window* _pParent, WinBits _nStyle );
+ NavigationToolBar( Window* _pParent, WinBits _nStyle, const ::boost::shared_ptr< const ICommandImageProvider >& _pImageProvider );
~NavigationToolBar( );
/** sets the dispatcher which is to be used for the features
@@ -82,19 +88,16 @@ namespace frm
ensuring the life time of the object does exceed the life time
of the tool bar instance.
*/
- void setDispatcher( const IFeatureDispatcher* _pDispatcher );
+ void setDispatcher( const IFeatureDispatcher* _pDispatcher );
- /** enables or disables a given feature
- */
- void enableFeature( sal_Int16 _nFeatureId, bool _bEnabled );
+ /// enables or disables a given feature
+ void enableFeature( sal_Int16 _nFeatureId, bool _bEnabled );
- /** checks or unchecks a given feature
- */
- void checkFeature( sal_Int16 _nFeatureId, bool _bEnabled );
+ /// checks or unchecks a given feature
+ void checkFeature( sal_Int16 _nFeatureId, bool _bEnabled );
- /** sets the text of a given feature
- */
- void setFeatureText( sal_Int16 _nFeatureId, const ::rtl::OUString& _rText );
+ /// sets the text of a given feature
+ void setFeatureText( sal_Int16 _nFeatureId, const ::rtl::OUString& _rText );
/** retrieves the current image size
*/
@@ -127,7 +130,10 @@ namespace frm
void implInit( );
/// impl version of SetImageSize
- void implSetImageSize( ImageSize _eSize, bool _bForce = false );
+ void implSetImageSize( ImageSize _eSize );
+
+ /// updates the images of our items
+ void implUpdateImages();
/// enables or disables an item, plus possible dependent items
void implEnableItem( USHORT _nItemId, bool _bEnabled );