summaryrefslogtreecommitdiff
path: root/patches/vba/vba-toolbar-menu-support.diff
diff options
context:
space:
mode:
Diffstat (limited to 'patches/vba/vba-toolbar-menu-support.diff')
-rw-r--r--patches/vba/vba-toolbar-menu-support.diff1469
1 files changed, 0 insertions, 1469 deletions
diff --git a/patches/vba/vba-toolbar-menu-support.diff b/patches/vba/vba-toolbar-menu-support.diff
deleted file mode 100644
index 09dc19624..000000000
--- a/patches/vba/vba-toolbar-menu-support.diff
+++ /dev/null
@@ -1,1469 +0,0 @@
-diff --git framework/inc/uielement/generictoolbarcontroller.hxx framework/inc/uielement/generictoolbarcontroller.hxx
-index 316c60d..377b685 100644
---- framework/inc/uielement/generictoolbarcontroller.hxx
-+++ framework/inc/uielement/generictoolbarcontroller.hxx
-@@ -37,6 +37,9 @@
-
- #include <svtools/toolboxcontroller.hxx>
- #include <vcl/toolbox.hxx>
-+#include <memory>
-+
-+class PopupMenu;
-
- namespace framework
- {
-@@ -64,7 +67,7 @@ class GenericToolbarController : public svt::ToolboxController
-
- DECL_STATIC_LINK( GenericToolbarController, ExecuteHdl_Impl, ExecuteInfo* );
-
-- private:
-+ protected:
- ToolBox* m_pToolbar;
- sal_uInt16 m_nID;
- sal_Bool m_bEnumCommand : 1,
-@@ -72,6 +75,28 @@ class GenericToolbarController : public svt::ToolboxController
- rtl::OUString m_aEnumCommand;
- };
-
-+class MenuToolbarController : public GenericToolbarController
-+{
-+ com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > m_xMenuDesc;
-+ PopupMenu* pMenu;
-+ com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xMenuManager;
-+ rtl::OUString m_aModuleIdentifier;
-+ public:
-+ MenuToolbarController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
-+ const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
-+ ToolBox* pToolBar,
-+ USHORT nID,
-+ const rtl::OUString& aCommand,
-+ const rtl::OUString& aModuleIdentifier,
-+ const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& xMenuDesc );
-+
-+ ~MenuToolbarController();
-+ // XToolbarController
-+ virtual void SAL_CALL click() throw ( ::com::sun::star::uno::RuntimeException );
-+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException);
-+
-+};
-+
- }
-
- #endif // __FRAMEWORK_UIELEMENT_GENERICTOOLBARCONTROLLER_HXX_
-diff --git framework/inc/uielement/toolbarmanager.hxx framework/inc/uielement/toolbarmanager.hxx
-index 9f1c2cd..3bdb284 100644
---- framework/inc/uielement/toolbarmanager.hxx
-+++ framework/inc/uielement/toolbarmanager.hxx
-@@ -50,6 +50,7 @@
- #include <com/sun/star/lang/XComponent.hpp>
- #include <com/sun/star/container/XIndexAccess.hpp>
- #include <com/sun/star/container/XNameAccess.hpp>
-+#include <com/sun/star/container/XIndexContainer.hpp>
- #include <com/sun/star/frame/XModuleManager.hpp>
- #include <com/sun/star/lang/XMultiServiceFactory.hpp>
- #include <com/sun/star/frame/XUIControllerRegistration.hpp>
-@@ -200,6 +201,7 @@ class ToolBarManager : public ::com::sun::star::frame::XFrameActionListener
- typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XSubToolbarController > > SubToolBarControllerVector;
- typedef BaseHash< SubToolBarControllerVector > SubToolBarToSubToolBarControllerMap;
-
-+ typedef ::std::hash_map< sal_uInt16, ::com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > > MenuDescriptionMap;
- sal_Bool m_bDisposed : 1,
- m_bIsHiContrast : 1,
- m_bSmallSymbols : 1,
-@@ -229,6 +231,7 @@ class ToolBarManager : public ::com::sun::star::frame::XFrameActionListener
- SubToolBarToSubToolBarControllerMap m_aSubToolBarControllerMap;
- Timer m_aAsyncUpdateControllersTimer;
- sal_Int16 m_nSymbolsStyle;
-+ MenuDescriptionMap m_aMenuMap;
- };
-
- }
-diff --git framework/inc/xml/menuconfiguration.hxx framework/inc/xml/menuconfiguration.hxx
-index cff0e8d..f24994b 100644
---- framework/inc/xml/menuconfiguration.hxx
-+++ framework/inc/xml/menuconfiguration.hxx
-@@ -85,6 +85,7 @@ class MenuConfiguration
- ::rtl::OUString aTargetFrame;
- ::rtl::OUString aImageId;
- ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProvider > xDispatchProvider;
-+ sal_Int16 nStyle;
- };
-
- MenuConfiguration(
-diff --git framework/source/uielement/generictoolbarcontroller.cxx framework/source/uielement/generictoolbarcontroller.cxx
-index 311776c..0a6d929 100644
---- framework/source/uielement/generictoolbarcontroller.cxx
-+++ framework/source/uielement/generictoolbarcontroller.cxx
-@@ -68,6 +68,9 @@
- #include <classes/fwkresid.hxx>
- #include <dispatch/uieventloghelper.hxx>
-
-+#include <xml/menuconfiguration.hxx>
-+#include <uielement/menubarmanager.hxx>
-+
- using namespace ::com::sun::star::awt;
- using namespace ::com::sun::star::uno;
- using namespace ::com::sun::star::beans;
-@@ -75,6 +78,7 @@ using namespace ::com::sun::star::lang;
- using namespace ::com::sun::star::frame;
- using namespace ::com::sun::star::frame::status;
- using namespace ::com::sun::star::util;
-+using namespace ::com::sun::star::container;
-
- namespace framework
- {
-@@ -326,5 +330,67 @@ IMPL_STATIC_LINK_NOINSTANCE( GenericToolbarController, ExecuteHdl_Impl, ExecuteI
- return 0;
- }
-
-+MenuToolbarController::MenuToolbarController( const Reference< XMultiServiceFactory >& rServiceManager, const Reference< XFrame >& rFrame, ToolBox* pToolBar, USHORT nID, const rtl::OUString& aCommand, const rtl::OUString& aModuleIdentifier, const Reference< XIndexAccess >& xMenuDesc ) : GenericToolbarController( rServiceManager, rFrame, pToolBar, nID, aCommand ), m_xMenuDesc( xMenuDesc ), pMenu( NULL ), m_aModuleIdentifier( aModuleIdentifier )
-+{
-+}
-+
-+MenuToolbarController::~MenuToolbarController()
-+{
-+ try
-+ {
-+ if ( m_xMenuManager.is() )
-+ m_xMenuManager->dispose();
-+ }
-+ catch( Exception& ) {}
-+ if ( pMenu )
-+ {
-+ delete pMenu;
-+ pMenu = NULL;
-+ }
-+
-+}
-+
-+class Toolbarmenu : public PopupMenu
-+{
-+ public:
-+ Toolbarmenu();
-+ ~Toolbarmenu();
-+};
-+
-+Toolbarmenu::Toolbarmenu()
-+{
-+ OSL_TRACE("**** contstructing Toolbarmenu 0x%x", this );
-+}
-+
-+Toolbarmenu::~Toolbarmenu()
-+{
-+ OSL_TRACE("**** destructing Toolbarmenu 0x%x", this );
-+}
-+
-+void SAL_CALL MenuToolbarController::click() throw (RuntimeException)
-+{
-+ createPopupWindow();
-+}
-+
-+Reference< XWindow > SAL_CALL
-+MenuToolbarController::createPopupWindow() throw (::com::sun::star::uno::RuntimeException)
-+{
-+ if ( !pMenu )
-+ {
-+ Reference< XDispatchProvider > xDispatch;
-+ Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), UNO_QUERY );
-+ pMenu = new Toolbarmenu();
-+ m_xMenuManager.set( new MenuBarManager( m_xServiceManager, m_xFrame, xURLTransformer, xDispatch, m_aModuleIdentifier, pMenu, sal_True, sal_True ) );
-+ if ( m_xMenuManager.is() )
-+ {
-+ MenuBarManager* pMgr = dynamic_cast< MenuBarManager* >( m_xMenuManager.get() );
-+ pMgr->SetItemContainer( m_xMenuDesc );
-+ }
-+ }
-+
-+ ::Rectangle aRect( m_pToolbar->GetItemRect( m_nID ) );
-+ pMenu->Execute( m_pToolbar, aRect, POPUPMENU_EXECUTE_DOWN );
-+ return NULL;
-+}
- } // namespace
-
-diff --git framework/source/uielement/menubarmanager.cxx framework/source/uielement/menubarmanager.cxx
-index f1add0d..0b4620d 100644
---- framework/source/uielement/menubarmanager.cxx
-+++ framework/source/uielement/menubarmanager.cxx
-@@ -74,6 +74,7 @@
- #include <com/sun/star/frame/XModuleManager.hpp>
- #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
- #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
-+#include <com/sun/star/ui/ItemStyle.hpp>
- #include <com/sun/star/frame/status/Visibility.hpp>
-
- //_________________________________________________________________________________________________________________
-@@ -136,6 +137,7 @@ static const char ITEM_DESCRIPTOR_LABEL[] = "Label";
- static const char ITEM_DESCRIPTOR_TYPE[] = "Type";
- static const char ITEM_DESCRIPTOR_MODULEIDENTIFIER[] = "ModuleIdentifier";
- static const char ITEM_DESCRIPTOR_DISPATCHPROVIDER[] = "DispatchProvider";
-+static const char ITEM_DESCRIPTOR_STYLE[] = "Style";
-
- const sal_Int32 LEN_DESCRIPTOR_COMMANDURL = 10;
- const sal_Int32 LEN_DESCRIPTOR_HELPURL = 7;
-@@ -144,6 +146,7 @@ const sal_Int32 LEN_DESCRIPTOR_LABEL = 5;
- const sal_Int32 LEN_DESCRIPTOR_TYPE = 4;
- const sal_Int32 LEN_DESCRIPTOR_MODULEIDENTIFIER = 16;
- const sal_Int32 LEN_DESCRIPTOR_DISPATCHPROVIDER = 16;
-+static const sal_Int32 ITEM_DESCRIPTOR_STYLE_LEN = 5;
-
- const sal_uInt16 ADDONMENU_MERGE_ITEMID_START = 1500;
-
-@@ -1327,6 +1330,11 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF
- Reference< XDispatch > xDispatch;
- Reference< XStatusListener > xStatusListener;
- PopupMenu* pPopup = pMenu->GetPopupMenu( nItemId );
-+ bool bItemShowMenuImages = m_bShowMenuImages;
-+ MenuItemBits nBits = pMenu->GetItemBits( nItemId );
-+ // overwrite the show icons on menu option?
-+ if ( nBits )
-+ bItemShowMenuImages = ( ( nBits & MIB_ICON ) == MIB_ICON );
- if ( pPopup )
- {
- // Retrieve module identifier from Help Command entry
-@@ -1422,7 +1430,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF
- pSubMenuManager->m_aMenuItemCommand = ::rtl::OUString();
-
- // Set image for the addon popup menu item
-- if ( m_bShowMenuImages && !pPopup->GetItemImage( ITEMID_ADDONLIST ))
-+ if ( bItemShowMenuImages && !pPopup->GetItemImage( ITEMID_ADDONLIST ))
- {
- Reference< XFrame > xTemp( rFrame );
- Image aImage = GetImageFromURL( xTemp, aItemCommand, FALSE, m_bWasHiContrast );
-@@ -1441,7 +1449,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF
- }
- else if ( pMenu->GetItemType( i ) != MENUITEM_SEPARATOR )
- {
-- if ( m_bShowMenuImages )
-+ if ( bItemShowMenuImages )
- {
- if ( AddonMenuManager::IsAddonMenuId( nItemId ))
- {
-@@ -1752,7 +1760,7 @@ void MenuBarManager::FillMenu(
- sal_uInt16 nType = 0;
- Reference< XIndexAccess > xIndexContainer;
- Reference< XDispatchProvider > xDispatchProvider( rDispatchProvider );
--
-+ sal_Int16 nStyle = 0;
- try
- {
- if ( rItemContainer->getByIndex( n ) >>= aProp )
-@@ -1781,6 +1789,8 @@ void MenuBarManager::FillMenu(
- else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_DISPATCHPROVIDER,
- LEN_DESCRIPTOR_DISPATCHPROVIDER ))
- aProp[i].Value >>= xDispatchProvider;
-+ else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_STYLE, ITEM_DESCRIPTOR_STYLE_LEN ))
-+ aProp[i].Value >>= nStyle;
- }
-
- if ( nType == ::com::sun::star::ui::ItemType::DEFAULT )
-@@ -1791,7 +1801,15 @@ void MenuBarManager::FillMenu(
- sal_Int32 nHelpId = aHelpURL.toInt32();
- if ( nHelpId > 0 )
- pMenu->SetHelpId( nId, (USHORT)nHelpId );
--
-+ if ( nStyle )
-+ {
-+ MenuItemBits nBits = pMenu->GetItemBits( nId );
-+ if ( nStyle & ::com::sun::star::ui::ItemStyle::ICON )
-+ nBits |= MIB_ICON;
-+ if ( nStyle & ::com::sun::star::ui::ItemStyle::TEXT )
-+ nBits |= MIB_TEXT;
-+ pMenu->SetItemBits( nId, nBits );
-+ }
- if ( xIndexContainer.is() )
- {
- PopupMenu* pNewPopupMenu = new PopupMenu;
-diff --git framework/source/uielement/toolbarmanager.cxx framework/source/uielement/toolbarmanager.cxx
-index b8e268f..7b74c20 100644
---- framework/source/uielement/toolbarmanager.cxx
-+++ framework/source/uielement/toolbarmanager.cxx
-@@ -71,7 +71,6 @@
- #include <com/sun/star/lang/XMultiComponentFactory.hpp>
- #include <com/sun/star/frame/XModuleManager.hpp>
- #include <com/sun/star/ui/XUIElementSettings.hpp>
--#include <com/sun/star/container/XIndexContainer.hpp>
- #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
- #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
- #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
-@@ -986,8 +985,13 @@ void ToolBarManager::CreateControllers()
- }
- else
- {
-- xController = Reference< XStatusListener >(
-- new GenericToolbarController( m_xServiceManager, m_xFrame, m_pToolBar, nId, aCommandURL ));
-+ MenuDescriptionMap::iterator it = m_aMenuMap.find( nId );
-+ if ( it == m_aMenuMap.end() )
-+ xController = Reference< XStatusListener >(
-+ new GenericToolbarController( m_xServiceManager, m_xFrame, m_pToolBar, nId, aCommandURL ));
-+ else
-+ xController = Reference< XStatusListener >(
-+ new MenuToolbarController( m_xServiceManager, m_xFrame, m_pToolBar, nId, aCommandURL, m_aModuleIdentifier, m_aMenuMap[ nId ] ));
- }
- }
- else if ( pController )
-@@ -1119,6 +1123,10 @@ sal_uInt16 ToolBarManager::ConvertStyleToToolboxItemBits( sal_Int32 nStyle )
- nItemBits |= TIB_REPEAT;
- if ( nStyle & ::com::sun::star::ui::ItemStyle::DROPDOWN_ONLY )
- nItemBits |= TIB_DROPDOWNONLY;
-+ if ( nStyle & ::com::sun::star::ui::ItemStyle::TEXT )
-+ nItemBits |= TIB_TEXT_ONLY;
-+ if ( nStyle & ::com::sun::star::ui::ItemStyle::ICON )
-+ nItemBits |= TIB_ICON_ONLY;
-
- return nItemBits;
- }
-@@ -1184,6 +1192,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
- m_aControllerMap.clear();
- m_aCommandMap.clear();
-
-+ m_aMenuMap.clear();
-+
- CommandInfo aCmdInfo;
- for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ )
- {
-@@ -1197,6 +1207,7 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
- sal_Bool bIsVisible( sal_True );
- sal_uInt32 nStyle( 0 );
-
-+ Reference< XIndexAccess > aMenuDesc;
- try
- {
- if ( rItemContainer->getByIndex( n ) >>= aProp )
-@@ -1219,6 +1230,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
- aProp[i].Value >>= nWidth;
- else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_STYLE, ITEM_DESCRIPTOR_STYLE_LEN ))
- aProp[i].Value >>= nStyle;
-+ else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_CONTAINER, ITEM_DESCRIPTOR_CONTAINER_LEN ))
-+ aProp[i].Value >>= aMenuDesc;
- }
-
- if (( nType == ::com::sun::star::ui::ItemType::DEFAULT ) && ( aCommandURL.getLength() > 0 ))
-@@ -1226,7 +1239,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
- ::rtl::OUString aString( RetrieveLabelFromCommand( aCommandURL ));
-
- sal_uInt16 nItemBits = ConvertStyleToToolboxItemBits( nStyle );
-- OSL_TRACE("** style for command url %s is 0x%x", rtl::OUStringToOString( aCommandURL, RTL_TEXTENCODING_UTF8 ).getStr(), nItemBits );
-+ if ( aMenuDesc.is() )
-+ m_aMenuMap[ nId ] = aMenuDesc;
- m_pToolBar->InsertItem( nId, aString, nItemBits );
- m_pToolBar->SetItemCommand( nId, aCommandURL );
- if ( aTooltip.getLength() )
-diff --git offapi/com/sun/star/ui/ItemStyle.idl offapi/com/sun/star/ui/ItemStyle.idl
-index 1243c67..5728b4a 100644
---- offapi/com/sun/star/ui/ItemStyle.idl
-+++ offapi/com/sun/star/ui/ItemStyle.idl
-@@ -149,6 +149,7 @@ constants ItemStyle
- <p>This style is only valid if the item describes a toolbar item.</p>
- */
- const short DROPDOWN_ONLY = 1024;
-+ const short TEXT = 2048;
- };
-
- }; }; }; };
-diff --git sc/source/filter/excel/excimp8.cxx sc/source/filter/excel/excimp8.cxx
-index 28771cb..c06fcc4 100644
---- sc/source/filter/excel/excimp8.cxx
-+++ sc/source/filter/excel/excimp8.cxx
-@@ -306,7 +306,7 @@ void ImportExcel8::ReadBasic( void )
- uno::Any aModel = uno::makeAny( pShell->GetModel() );
- pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aModel );
- }
--#if 0
-+#if 1
- // see if we have the XCB stream
- SvStorageStreamRef xXCB = xRootStrg->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "XCB" ) ), STREAM_STD_READ | STREAM_NOCREATE );
- if ( xXCB.Is()|| SVSTREAM_OK == xXCB->GetError() )
-diff --git sc/source/filter/excel/xltoolbar.cxx sc/source/filter/excel/xltoolbar.cxx
-index 6591539..b7eacb1 100644
---- sc/source/filter/excel/xltoolbar.cxx
-+++ sc/source/filter/excel/xltoolbar.cxx
-@@ -122,16 +122,32 @@ void CTB::Print( FILE* fp )
- }
- }
-
--bool CTB::ImportCustomToolBar( CustomToolBarImportHelper& helper )
-+bool CTB::IsMenuToolbar()
- {
-+ return tb.IsMenuToolbar();
-+}
-+
-+bool CTB::ImportMenuTB( CTBWrapper& rWrapper, const css::uno::Reference< css::container::XIndexContainer >& xMenuDesc, CustomToolBarImportHelper& helper )
-+{
-+ sal_Int32 index = 0;
-+ for ( std::vector< TBC >::iterator it = rTBC.begin(); it != rTBC.end(); ++it, ++index )
-+ {
-+ if ( !it->ImportToolBarControl( rWrapper, xMenuDesc, helper, IsMenuToolbar() ) )
-+ return false;
-+ }
-+ return true;
-+}
-+
-+bool CTB::ImportCustomToolBar( CTBWrapper& rWrapper, CustomToolBarImportHelper& helper )
-+{
-+
- static rtl::OUString sToolbarPrefix( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/custom_" ) );
- bool bRes = false;
- try
- {
-- // #Fixme same issue here as in word, some deleted data
-- // seems to still exist
- if ( !tb.IsEnabled() )
- return true; // didn't fail, just ignoring
-+
- // Create default setting
- uno::Reference< container::XIndexContainer > xIndexContainer( helper.getCfgManager()->createSettings(), uno::UNO_QUERY_THROW );
- uno::Reference< container::XIndexAccess > xIndexAccess( xIndexContainer, uno::UNO_QUERY_THROW );
-@@ -143,8 +159,7 @@ bool CTB::ImportCustomToolBar( CustomToolBarImportHelper& helper )
- rtl::OUString sToolBarName = sToolbarPrefix.concat( name.getString() );
- for ( std::vector< TBC >::iterator it = rTBC.begin(); it != rTBC.end(); ++it )
- {
-- // createToolBar item for control
-- if ( !it->ImportToolBarControl( xIndexContainer, helper ) )
-+ if ( !it->ImportToolBarControl( rWrapper, xIndexContainer, helper, IsMenuToolbar() ) )
- return false;
- }
-
-@@ -152,12 +167,13 @@ bool CTB::ImportCustomToolBar( CustomToolBarImportHelper& helper )
-
- helper.getCfgManager()->insertSettings( sToolBarName, xIndexAccess );
- helper.applyIcons();
--
-+#if 0
- uno::Reference< ui::XUIConfigurationPersistence > xPersistence( helper.getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
- xPersistence->store();
-
- xPersistence.set( helper.getCfgManager(), uno::UNO_QUERY_THROW );
- xPersistence->store();
-+#endif
-
- bRes = true;
- }
-@@ -233,7 +249,7 @@ TBC::Print(FILE* fp)
- tbcd->Print( fp );
- }
-
--bool TBC::ImportToolBarControl( const css::uno::Reference< css::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper )
-+bool TBC::ImportToolBarControl( CTBWrapper& rWrapper, const css::uno::Reference< css::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper, bool bIsMenuToolbar )
- {
- // how to identify built-in-command ?
- // bool bBuiltin = false;
-@@ -256,8 +272,31 @@ bool TBC::ImportToolBarControl( const css::uno::Reference< css::container::XInde
- }
- */
- bool bBeginGroup = false;
-- if ( ! tbcd->ImportToolBarControl( toolbarcontainer, helper, props, bBeginGroup ) )
-+ if ( ! tbcd->ImportToolBarControl( helper, props, bBeginGroup, bIsMenuToolbar ) )
- return false;
-+ TBCMenuSpecific* pMenu = tbcd->getMenuSpecific();
-+ if ( pMenu )
-+ {
-+ // search for CTB with the appropriate name ( it contains the
-+ // menu items, although we cannot import ( or create ) a menu on
-+ // a custom toolbar we can import the menu items in a separate
-+ // toolbar ( better than nothing )
-+ CTB* pCustTB = rWrapper.GetCustomizationData( pMenu->Name() );
-+ if ( pCustTB )
-+ {
-+ uno::Reference< container::XIndexContainer > xMenuDesc;
-+ uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
-+ xMenuDesc.set( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.IndexedPropertyValues" ) ) ), uno::UNO_QUERY_THROW );
-+ if ( !pCustTB->ImportMenuTB( rWrapper, xMenuDesc, helper ) )
-+ return false;
-+ OSL_TRACE("*** Read menu, no. items is %d", xMenuDesc->getCount() );
-+ beans::PropertyValue aProp;
-+
-+ aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ItemDescriptorContainer") );
-+ aProp.Value <<= xMenuDesc;
-+ props.push_back( aProp );
-+ }
-+ }
-
- if ( bBeginGroup )
- {
-@@ -346,6 +385,20 @@ CTBWrapper::Print( FILE* fp )
- }
- }
-
-+CTB* CTBWrapper::GetCustomizationData( const rtl::OUString& sTBName )
-+{
-+ CTB* pCTB = NULL;
-+ for ( std::vector< CTB >::iterator it = rCTB.begin(); it != rCTB.end(); ++it )
-+ {
-+ if ( it->GetName().equals( sTBName ) )
-+ {
-+ pCTB = &(*it);
-+ break;
-+ }
-+ }
-+ return pCTB;
-+}
-+
- bool CTBWrapper::ImportCustomToolBar( SfxObjectShell& rDocSh )
- {
- std::vector<CTB>::iterator it_end = rCTB.end();
-@@ -356,8 +409,17 @@ bool CTBWrapper::ImportCustomToolBar( SfxObjectShell& rDocSh )
- uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xAppCfgSupp( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ) ) ), uno::UNO_QUERY_THROW );
- CustomToolBarImportHelper helper( rDocSh, xAppCfgSupp->getUIConfigurationManager( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument" ) ) ) );
- helper.setMSOCommandMap( new MSOExcelCommandConvertor() );
-- if ( !(*it).ImportCustomToolBar( helper ) )
-- return false;
-+ // Ignore menu toolbars, excel doesn't ( afaics ) store
-+ // menu customizations ( but you can have menus in a customtoolbar
-+ // such menus will be dealt with when they are encountered
-+ // as part of importing the appropriate MenuSpecific toolbar control )
-+
-+
-+ if ( !(*it).IsMenuToolbar() )
-+ {
-+ if ( !(*it).ImportCustomToolBar( *this, helper ) )
-+ return false;
-+ }
- }
- return true;
- }
-diff --git sc/source/filter/excel/xltoolbar.hxx sc/source/filter/excel/xltoolbar.hxx
-index af986c7..deef46c 100644
---- sc/source/filter/excel/xltoolbar.hxx
-+++ sc/source/filter/excel/xltoolbar.hxx
-@@ -5,6 +5,7 @@
-
- namespace css = ::com::sun::star;
-
-+class CTBWrapper;
- // hmm I don't normally use these packed structures
- // but.. hey always good to do something different
- class TBCCmd : public TBBase
-@@ -31,7 +32,7 @@ public:
- ~TBC(){}
- void Print( FILE* );
- bool Read(SvStream *pS);
-- bool ImportToolBarControl( const com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper );
-+ bool ImportToolBarControl( CTBWrapper&, const com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper, bool bIsMenuBar );
- };
-
- class CTB : public TBBase
-@@ -41,13 +42,19 @@ class CTB : public TBBase
- std::vector<TBVisualData> rVisualData;
- sal_uInt32 ectbid;
- std::vector< TBC > rTBC;
-+ bool ImportCustomToolBar_Impl( CTBWrapper&, CustomToolBarImportHelper& );
- public:
- CTB();
- CTB(sal_uInt16);
- ~CTB(){}
- void Print( FILE* );
- bool Read(SvStream *pS);
-- bool ImportCustomToolBar( CustomToolBarImportHelper& );
-+ bool IsMenuToolbar();
-+ bool ImportCustomToolBar( CTBWrapper&, CustomToolBarImportHelper& );
-+ bool ImportMenuTB( CTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
-+ rtl::OUString GetName() { return tb.getName().getString(); }
-+
-+
- };
-
- class CTBS : public TBBase
-@@ -81,6 +88,7 @@ public:
- bool Read(SvStream *pS);
- void Print( FILE* );
- bool ImportCustomToolBar( SfxObjectShell& rDocSh );
-+ CTB* GetCustomizationData( const rtl::OUString& name );
- };
-
-
-diff --git svx/inc/svx/mstoolbar.hxx svx/inc/svx/mstoolbar.hxx
-index c102ade..01ef608 100644
---- svx/inc/svx/mstoolbar.hxx
-+++ svx/inc/svx/mstoolbar.hxx
-@@ -10,9 +10,11 @@
- #include <com/sun/star/frame/XModel.hpp>
- #include <com/sun/star/container/XIndexContainer.hpp>
- #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
-+#include <com/sun/star/ui/ImageType.hpp>
- #include <com/sun/star/graphic/XGraphic.hpp>
- #include <com/sun/star/beans/XPropertySet.hpp>
- #include <vcl/bitmap.hxx>
-+#include <cppuhelper/implbase1.hxx>
-
- namespace css = ::com::sun::star;
-
-@@ -41,6 +43,7 @@ class SVX_DLLPUBLIC CustomToolBarImportHelper
- css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > m_xCfgSupp;
- css::uno::Reference< css::ui::XUIConfigurationManager > m_xAppCfgMgr;
- SfxObjectShell& mrDocSh;
-+ void ScaleImage( css::uno::Reference< css::graphic::XGraphic >& xGraphic, long nNewSize );
- public:
- CustomToolBarImportHelper( SfxObjectShell& rDocSh, const css::uno::Reference< css::ui::XUIConfigurationManager >& rxAppCfgMgr );
-
-@@ -56,6 +59,7 @@ public:
- rtl::OUString MSOCommandToOOCommand( sal_Int16 msoCmd );
- rtl::OUString MSOTCIDToOOCommand( sal_Int16 msoTCID );
- SfxObjectShell& GetDocShell() { return mrDocSh; }
-+ void showToolbar( const rtl::OUString& rName );
- };
-
- class SVX_DLLPUBLIC TBBase
-@@ -163,6 +167,7 @@ public:
- ~TBCMenuSpecific(){}
- bool Read(SvStream *pS);
- void Print( FILE* );
-+ rtl::OUString Name();
- };
-
- class SVX_DLLPUBLIC TBCCDData : public TBBase
-@@ -268,8 +273,9 @@ public:
- ~TBCData(){}
- bool Read(SvStream *pS);
- void Print( FILE* );
-- bool ImportToolBarControl( const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >&, bool& bBeginGroup );
-+ bool ImportToolBarControl( CustomToolBarImportHelper&, std::vector< css::beans::PropertyValue >&, bool& bBeginGroup, bool bIsMenuBar );
- TBCGeneralInfo& getGeneralInfo() { return controlGeneralInfo; }
-+ TBCMenuSpecific* getMenuSpecific();
- };
-
- class SVX_DLLPUBLIC TB : public TBBase
-@@ -290,6 +296,7 @@ public:
- sal_Int16 getcCL(){ return cCL; }
- WString& getName(){ return name; }
- bool IsEnabled();
-+ bool IsMenuToolbar(){ return ( ( ltbtr & 0x2000000 ) == 0x2000000 ); }
- bool NeedsPositioning();
- };
-
-@@ -305,6 +312,8 @@ public:
- void Print( FILE* fo );
- };
-
-+typedef cppu::WeakImplHelper1< css::container::XIndexContainer > PropertyValueIndexContainer_BASE;
-+
- class SVX_DLLPUBLIC TBVisualData : public TBBase
- {
- sal_Int8 tbds;
-diff --git svx/source/cui/cfg.cxx svx/source/cui/cfg.cxx
-index 2931be6..80280d3 100644
---- svx/source/cui/cfg.cxx
-+++ svx/source/cui/cfg.cxx
-@@ -5724,7 +5724,7 @@ bool SvxIconSelectorDialog::ReplaceGraphicItem(
- if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) )
- {
- BitmapEx aBitmap = aImage.GetBitmapEx();
-- BitmapEx aBitmapex = AutoScaleBitmap(aBitmap, m_nExpectedSize);
-+ BitmapEx aBitmapex = BitmapEx::AutoScaleBitmap(aBitmap, m_nExpectedSize);
- aImage = Image( aBitmapex);
- }
- aTbSymbol.InsertItem( nId,aImage, aURL, 0, 0 ); //modify
-@@ -5888,7 +5888,7 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
- if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) )
- {
- BitmapEx aBitmap = aImage.GetBitmapEx();
-- BitmapEx aBitmapex = AutoScaleBitmap(aBitmap, m_nExpectedSize);
-+ BitmapEx aBitmapex = BitmapEx::AutoScaleBitmap(aBitmap, m_nExpectedSize);
- aImage = Image( aBitmapex);
- }
- if ( bOK && !!aImage )
-@@ -6004,56 +6004,56 @@ SvxIconChangeDialog::SvxIconChangeDialog(
-
- BitmapEx SvxIconSelectorDialog::AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize)
- {
-- Point aEmptyPoint(0,0);
-- sal_Int32 imgNewWidth = 0;
-- sal_Int32 imgNewHeight = 0;
-- double imgposX = 0;
-- double imgposY = 0;
-+ Point aEmptyPoint(0,0);
-+ sal_Int32 imgNewWidth = 0;
-+ sal_Int32 imgNewHeight = 0;
-+ double imgposX = 0;
-+ double imgposY = 0;
- BitmapEx aRet = aBitmap;
-- double imgOldWidth = aRet.GetSizePixel().Width();
-- double imgOldHeight =aRet.GetSizePixel().Height();
-+ double imgOldWidth = aRet.GetSizePixel().Width();
-+ double imgOldHeight =aRet.GetSizePixel().Height();
-
- Size aScaledSize;
- if (imgOldWidth >= aStandardSize || imgOldHeight >= aStandardSize)
-- {
-- if (imgOldWidth >= imgOldHeight)
-- {
-- imgNewWidth = aStandardSize;
-- imgNewHeight = sal_Int32(imgOldHeight / (imgOldWidth / aStandardSize) + 0.5);
-- imgposX = 0;
-- imgposY = (aStandardSize - (imgOldHeight / (imgOldWidth / aStandardSize) + 0.5)) / 2 + 0.5;
-- }
-- else
-- {
-- imgNewHeight = aStandardSize;
-- imgNewWidth = sal_Int32(imgOldWidth / (imgOldHeight / aStandardSize) + 0.5);
-- imgposY = 0;
-- imgposX = (aStandardSize - (imgOldWidth / (imgOldHeight / aStandardSize) + 0.5)) / 2 + 0.5;
-- }
--
-- aScaledSize = Size( imgNewWidth, imgNewHeight );
-+ {
-+ if (imgOldWidth >= imgOldHeight)
-+ {
-+ imgNewWidth = aStandardSize;
-+ imgNewHeight = sal_Int32(imgOldHeight / (imgOldWidth / aStandardSize) + 0.5);
-+ imgposX = 0;
-+ imgposY = (aStandardSize - (imgOldHeight / (imgOldWidth / aStandardSize) + 0.5)) / 2 + 0.5;
-+ }
-+ else
-+ {
-+ imgNewHeight = aStandardSize;
-+ imgNewWidth = sal_Int32(imgOldWidth / (imgOldHeight / aStandardSize) + 0.5);
-+ imgposY = 0;
-+ imgposX = (aStandardSize - (imgOldWidth / (imgOldHeight / aStandardSize) + 0.5)) / 2 + 0.5;
-+ }
-+
-+ aScaledSize = Size( imgNewWidth, imgNewHeight );
- aRet.Scale( aScaledSize, BMP_SCALE_INTERPOLATE );
-- }
-- else
-- {
-- imgposX = (aStandardSize - imgOldWidth) / 2 + 0.5;
-- imgposY = (aStandardSize - imgOldHeight) / 2 + 0.5;
-- }
-+ }
-+ else
-+ {
-+ imgposX = (aStandardSize - imgOldWidth) / 2 + 0.5;
-+ imgposY = (aStandardSize - imgOldHeight) / 2 + 0.5;
-+ }
-
- Size aBmpSize = aRet.GetSizePixel();
- Size aStdSize( aStandardSize, aStandardSize );
- Rectangle aRect(aEmptyPoint, aStdSize );
-
- VirtualDevice aVirDevice( *Application::GetDefaultDevice(), 0, 1 );
-- aVirDevice.SetOutputSizePixel( aStdSize );
-- aVirDevice.SetFillColor( COL_TRANSPARENT );
-+ aVirDevice.SetOutputSizePixel( aStdSize );
-+ aVirDevice.SetFillColor( COL_TRANSPARENT );
- aVirDevice.SetLineColor( COL_TRANSPARENT );
-
- //draw a rect into virDevice
-- aVirDevice.DrawRect( aRect );
-- Point aPointPixel( (long)imgposX, (long)imgposY );
-- aVirDevice.DrawBitmapEx( aPointPixel, aRet );
-- aRet = aVirDevice.GetBitmapEx( aEmptyPoint, aStdSize );
-+ aVirDevice.DrawRect( aRect );
-+ Point aPointPixel( (long)imgposX, (long)imgposY );
-+ aVirDevice.DrawBitmapEx( aPointPixel, aRet );
-+ aRet = aVirDevice.GetBitmapEx( aEmptyPoint, aStdSize );
-
-- return aRet;
-+ return aRet;
- }
-diff --git svx/source/msfilter/mstoolbar.cxx svx/source/msfilter/mstoolbar.cxx
-index 1d5c801..0d45af7 100644
---- svx/source/msfilter/mstoolbar.cxx
-+++ svx/source/msfilter/mstoolbar.cxx
-@@ -4,19 +4,55 @@
- #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
- #include <com/sun/star/ui/XImageManager.hpp>
- #include <com/sun/star/ui/ItemType.hpp>
-+#include <com/sun/star/ui/ItemStyle.hpp>
-+#include <com/sun/star/frame/XLayoutManager.hpp>
- #include <fstream>
- #include <vcl/graph.hxx>
- #include <vcl/bitmapex.hxx>
-+#include <vcl/image.hxx>
- #include <map>
- #include <sfx2/objsh.hxx>
- #include <basic/basmgr.hxx>
- #include <svtools/filterutils.hxx>
- #include <boost/scoped_array.hpp>
- #include <svx/msvbahelper.hxx>
-+#include <svtools/miscopt.hxx>
-+#include <vcl/svapp.hxx>
-+#include <vcl/window.hxx>
-+
-+using namespace com::sun::star;
-
- int TBBase::nIndent = 0;
-
--using namespace com::sun::star;
-+void CustomToolBarImportHelper::showToolbar( const rtl::OUString& rName )
-+{
-+ try
-+ {
-+ uno::Reference< frame::XController > xCntrller( mrDocSh.GetModel()->getCurrentController(), uno::UNO_QUERY_THROW );
-+ uno::Reference< beans::XPropertySet > xProps( xCntrller->getFrame(), uno::UNO_QUERY_THROW );
-+ uno::Reference< frame::XLayoutManager > xLayoutMgr( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LayoutManager") ) ), uno::UNO_QUERY_THROW );
-+ xLayoutMgr->showElement( rName );
-+ }
-+ catch( uno::Exception& ) {}
-+}
-+
-+void CustomToolBarImportHelper::ScaleImage( uno::Reference< graphic::XGraphic >& xGraphic, long nNewSize )
-+{
-+ Graphic aGraphic( xGraphic );
-+ Size aSize = aGraphic.GetSizePixel();
-+ if ( aSize.Height() && ( aSize.Height() == aSize.Width() ) )
-+ {
-+ Image aImage( xGraphic );
-+ if ( aSize.Height() != nNewSize )
-+ {
-+ BitmapEx aBitmap = aImage.GetBitmapEx();
-+ BitmapEx aBitmapex = BitmapEx::AutoScaleBitmap(aBitmap, nNewSize );
-+ aImage = Image( aBitmapex);
-+ xGraphic = aImage.GetXGraphic();
-+ }
-+ }
-+}
-+
- void CustomToolBarImportHelper::applyIcons()
- {
- for ( std::vector< iconcontrolitem >::iterator it = iconcommands.begin(); it != iconcommands.end(); ++it )
-@@ -25,14 +61,19 @@ void CustomToolBarImportHelper::applyIcons()
- commands[ 0 ] = it->sCommand;
- uno::Sequence< uno::Reference< graphic::XGraphic > > images(1);
- images[ 0 ] = it->image;
-+
- OSL_TRACE("About to applyIcons for command %s, have image ? %s", rtl::OUStringToOString( commands[ 0 ], RTL_TEXTENCODING_UTF8 ).getStr(), images[ 0 ].is() ? "yes" : "no" );
- uno::Reference< ui::XImageManager > xImageManager( getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
-- // 1 seems to work best for MSO images, otherwise they don't get displayed ( I guess the default size
-- // in ooo is different )
-- //xImageManager->insertImages( 1, commands, images ); // #FIXME and scale images based on default icon size
-- xImageManager->replaceImages( 1, commands, images );
-- xImageManager->replaceImages( 2, commands, images );
-- xImageManager->replaceImages( 3, commands, images );
-+ sal_uInt16 nColor = ui::ImageType::COLOR_NORMAL;
-+
-+ Window* topwin = Application::GetActiveTopWindow();
-+ if ( topwin != NULL && topwin->GetDisplayBackground().GetColor().IsDark() )
-+ nColor = css::ui::ImageType::COLOR_HIGHCONTRAST;
-+
-+ ScaleImage( images[ 0 ], 16 );
-+ xImageManager->replaceImages( ui::ImageType::SIZE_DEFAULT | nColor, commands, images );
-+ ScaleImage( images[ 0 ], 26 );
-+ xImageManager->replaceImages( ui::ImageType::SIZE_LARGE | nColor, commands, images );
- }
- }
-
-@@ -196,23 +237,27 @@ bool TBCData::Read(SvStream *pS)
- return true;
- }
-
--bool TBCData::ImportToolBarControl( const css::uno::Reference< css::container::XIndexContainer >& /*toolbarcontainer*/, CustomToolBarImportHelper& helper, std::vector< css::beans::PropertyValue >& props, bool& bBeginGroup )
-+TBCMenuSpecific* TBCData::getMenuSpecific()
-+{
-+ TBCMenuSpecific* pMenu = dynamic_cast< TBCMenuSpecific* >( controlSpecificInfo.get() );
-+ return pMenu;
-+}
-+bool TBCData::ImportToolBarControl( CustomToolBarImportHelper& helper, std::vector< css::beans::PropertyValue >& props, bool& bBeginGroup, bool bIsMenuBar )
- {
-+ sal_uInt16 nStyle = 0;
- bBeginGroup = rHeader.isBeginGroup();
- controlGeneralInfo.ImportToolBarControlData( helper, props );
- beans::PropertyValue aProp;
- aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Visible") ) ;
- aProp.Value = uno::makeAny( rHeader.isVisible() ); // where is the visible attribute stored
--
-+ props.push_back( aProp );
- if ( rHeader.getTct() == 0x01
- || rHeader.getTct() == 0x10 )
- {
- TBCBSpecific* pSpecificInfo = dynamic_cast< TBCBSpecific* >( controlSpecificInfo.get() );
- if ( pSpecificInfo )
- {
-- // if we have a icon then lets set it for the command ( but I
-- // have a nasty suspicion the toolbar actually needs to be set
-- // up ( and added ) before you can asssign an image :-/
-+ // if we have a icon then lets set it for the command
- rtl::OUString sCommand;
- for ( std::vector< css::beans::PropertyValue >::iterator it = props.begin(); it != props.end(); ++it )
- {
-@@ -252,6 +297,32 @@ bool TBCData::ImportToolBarControl( const css::uno::Reference< css::container::X
- }
- }
- }
-+ else if ( rHeader.getTct() == 0x0a )
-+ {
-+ aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CommandURL") ) ;
-+ aProp.Value = uno::makeAny( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("private:" ) ) ); // dummy command
-+ nStyle |= ui::ItemStyle::DROP_DOWN;
-+ props.push_back( aProp );
-+ }
-+
-+ short icontext = ( rHeader.getTbct() & 0x03 );
-+ aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Style") ) ;
-+ if ( bIsMenuBar )
-+ {
-+ nStyle |= ui::ItemStyle::TEXT;
-+ if ( !icontext || icontext == 0x3 )
-+ // Text And image
-+ nStyle |= ui::ItemStyle::ICON;
-+ }
-+ else
-+ {
-+ if ( ( icontext & 0x02 ) == 0x02 )
-+ nStyle |= ui::ItemStyle::TEXT;
-+ if ( !icontext || ( icontext & 0x03 ) == 0x03 )
-+ nStyle |= ui::ItemStyle::ICON;
-+ }
-+ aProp.Value <<= nStyle;
-+ props.push_back( aProp );
- return true; // just ignore
- }
-
-@@ -391,9 +462,6 @@ TBCGeneralInfo::ImportToolBarControlData( CustomToolBarImportHelper& helper, std
- aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Tooltip") );
- aProp.Value = uno::makeAny( tooltip.getString() );
- sControlData.push_back( aProp );
--
-- // #TODO find out what is the property for tooltip?
-- sControlData.push_back( aProp );
- /*
- aToolbarItem(0).Name = "CommandURL" wstrOnAction
- aToolbarItem(0).Value = Command
-@@ -437,6 +505,13 @@ TBCMenuSpecific::Print( FILE* fp )
-
- }
-
-+rtl::OUString TBCMenuSpecific::Name()
-+{
-+ rtl::OUString aName;
-+ if ( name.get() )
-+ aName = name->getString();
-+ return aName;
-+}
- TBCBSpecific::TBCBSpecific() : bFlags( 0 )
- {
- }
-diff --git sw/source/filter/ww8/ww8toolbar.cxx sw/source/filter/ww8/ww8toolbar.cxx
-index 22581ea..e6b047a 100644
---- sw/source/filter/ww8/ww8toolbar.cxx
-+++ sw/source/filter/ww8/ww8toolbar.cxx
-@@ -15,6 +15,9 @@
- #include <map>
- using namespace com::sun::star;
-
-+// no. of visual data elements in a CTB ( fixed )
-+const short nVisualData = 5;
-+
- typedef std::map< sal_Int16, rtl::OUString > IdToString;
-
- class MSOWordCommandConvertor : public MSOCommandConvertor
-@@ -81,6 +84,20 @@ Customization* CTBWrapper::GetCustomizaton( sal_Int16 index )
- return &rCustomizations[ index ];
- }
-
-+CTB* CTBWrapper::GetCustomizationData( const rtl::OUString& sTBName )
-+{
-+ CTB* pCTB = NULL;
-+ for ( std::vector< Customization >::iterator it = rCustomizations.begin(); it != rCustomizations.end(); ++it )
-+ {
-+ if ( it->GetCustomizationData() && it->GetCustomizationData()->GetName().equals( sTBName ) )
-+ {
-+ pCTB = it->GetCustomizationData();
-+ break;
-+ }
-+ }
-+ return pCTB;
-+}
-+
- bool CTBWrapper::Read( SvStream* pS )
- {
- OSL_TRACE("CTBWrapper::Read() stream pos 0x%x", pS->Tell() );
-@@ -178,14 +195,14 @@ void CTBWrapper::Print( FILE* fp )
-
- bool CTBWrapper::ImportCustomToolBar( SfxObjectShell& rDocSh )
- {
--
- for ( std::vector< Customization >::iterator it = rCustomizations.begin(); it != rCustomizations.end(); ++it )
- {
- uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
- uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xAppCfgSupp( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ) ) ), uno::UNO_QUERY_THROW );
- CustomToolBarImportHelper helper( rDocSh, xAppCfgSupp->getUIConfigurationManager( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument" ) ) ) );
-- helper.setMSOCommandMap( new MSOWordCommandConvertor() );
-- if ( !(*it).ImportCustomToolBar( helper ) )
-+ helper.setMSOCommandMap( new MSOWordCommandConvertor() );
-+
-+ if ( !(*it).ImportCustomToolBar( *this, helper ) )
- return false;
- }
- return false;
-@@ -263,17 +280,8 @@ void Customization::Print( FILE* fp )
-
- }
-
--bool Customization::ImportMenu( const uno::Reference< container::XIndexContainer >& xIndexContainer, CustomToolBarImportHelper& helper )
-+bool Customization::ImportMenu( CTBWrapper& rWrapper, CustomToolBarImportHelper& helper )
- {
-- if ( !customizationDataCTB.get() )
-- return false;
-- return customizationDataCTB->ImportMenu( xIndexContainer, helper );
--}
--
--bool Customization::ImportCustomToolBar( CustomToolBarImportHelper& helper )
--{
-- if ( bIsDroppedMenuTB )
-- return true; // ignore ( will be processed by the ImportMenu )
- if ( tbidForTBD == 0x25 ) // we can handle in a limited way additions the built-in menu bar
- {
- for ( std::vector< TBDelta >::iterator it = customizationDataTBDelta.begin(); it != customizationDataTBDelta.end(); ++it )
-@@ -287,8 +295,6 @@ bool Customization::ImportCustomToolBar( CustomToolBarImportHelper& helper )
- {
- // currently only support built-in menu
- rtl::OUString sMenuBar( RTL_CONSTASCII_USTRINGPARAM("private:resource/menubar/") );
-- if ( tbidForTBD != 0x25 )
-- return false;
-
- sMenuBar = sMenuBar.concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("menubar") ) );
- // Get menu name
-@@ -329,7 +335,7 @@ bool Customization::ImportCustomToolBar( CustomToolBarImportHelper& helper )
- aPopupMenu[3].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ItemDescriptorContainer") );
- uno::Reference< container::XIndexContainer > xMenuContainer( xSCF->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW );
- aPopupMenu[3].Value <<= xMenuContainer;
-- if ( !pCust->ImportMenu( xMenuContainer, helper ) )
-+ if ( pCust->customizationDataCTB.get() && !pCust->customizationDataCTB->ImportMenuTB( rWrapper, xMenuContainer, helper ) )
- return false;
- OSL_TRACE("** there are %d menu items on the bar, inserting after that", xIndexContainer->getCount() );
- xIndexContainer->insertByIndex( xIndexContainer->getCount(), uno::makeAny( aPopupMenu ) );
-@@ -338,14 +344,28 @@ bool Customization::ImportCustomToolBar( CustomToolBarImportHelper& helper )
- helper.getCfgManager()->replaceSettings( sMenuBar, uno::Reference< container::XIndexAccess >( xIndexContainer, uno::UNO_QUERY_THROW ) );
- else
- helper.getCfgManager()->insertSettings( sMenuBar, uno::Reference< container::XIndexAccess >( xIndexContainer, uno::UNO_QUERY_THROW ) );
-+ uno::Reference< ui::XUIConfigurationPersistence > xPersistence( helper.getCfgManager(), uno::UNO_QUERY_THROW );
-+ xPersistence->store();
- }
- }
- }
- return true;
- }
-+ return true;
-+}
-+
-+bool Customization::ImportCustomToolBar( CTBWrapper& rWrapper, CustomToolBarImportHelper& helper )
-+{
-+ if ( GetTBIDForTB() == 0x25 )
-+ return ImportMenu( rWrapper, helper );
- if ( !customizationDataCTB.get() )
- return false;
-- return customizationDataCTB->ImportCustomToolBar( helper );
-+ if ( !customizationDataCTB->IsMenuToolbar() )
-+ {
-+ if ( !customizationDataCTB->ImportCustomToolBar( rWrapper, helper ) )
-+ return false;
-+ }
-+ return true;
- }
-
- TBDelta::TBDelta() : doprfatendFlags(0)
-@@ -431,6 +451,12 @@ CTB::~CTB()
- {
- }
-
-+bool CTB::IsMenuToolbar()
-+{
-+ return tb.IsMenuToolbar();
-+}
-+
-+
- bool CTB::Read( SvStream *pS)
- {
- OSL_TRACE("CTB::Read() stream pos 0x%x", pS->Tell() );
-@@ -438,10 +464,14 @@ bool CTB::Read( SvStream *pS)
- if ( !name.Read( pS ) )
- return false;
- *pS >> cbTBData;
-- // sal_Int32 nTBSize = cbTBData - sizeof(rVisualData) - 12;
- if ( !tb.Read( pS ) )
- return false;
-- pS->Read( &rVisualData, sizeof( rVisualData ) );
-+ for ( short index = 0; index < nVisualData; ++index )
-+ {
-+ TBVisualData aVisData;
-+ aVisData.Read( pS );
-+ rVisualData.push_back( aVisData );
-+ }
-
- *pS >> iWCTBl >> reserved >> unused >> cCtls;
-
-@@ -467,6 +497,12 @@ CTB::Print( FILE* fp )
- indent_printf(fp, " cbTBData size, in bytes, of this structure excluding the name, cCtls, and rTBC fields. %x\n", static_cast< unsigned int >( cbTBData ) );
-
- tb.Print(fp);
-+ for ( short counter = 0; counter < nVisualData; ++counter )
-+ {
-+ indent_printf( fp, " TBVisualData [%d]\n", counter);
-+ Indent b;
-+ rVisualData[ counter ].Print( fp );
-+ }
- indent_printf(fp, " iWCTBl 0x%x reserved 0x%x unused 0x%x cCtls( toolbar controls ) 0x%x \n", static_cast< unsigned int >( iWCTBl ), reserved, unused, static_cast< unsigned int >( cCtls ) );
- if ( cCtls )
- {
-@@ -479,18 +515,13 @@ CTB::Print( FILE* fp )
- }
- }
-
--bool CTB::ImportCustomToolBar( CustomToolBarImportHelper& helper )
-+bool CTB::ImportCustomToolBar( CTBWrapper& rWrapper, CustomToolBarImportHelper& helper )
- {
- static rtl::OUString sToolbarPrefix( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/custom_" ) );
- bool bRes = false;
- try
- {
-- // #FIXME this is a bogus check ( but is seems to work )
-- // the fNeedsPositioning seems always to be set for toolbars that
-- // have been deleted ( sofar I fail to find something else to indicate
-- // not to read them ) - e.g. We can have CTB records which relate to
-- // deleted items ( usually associated with popups )
-- if ( !tb.IsEnabled() || tb.NeedsPositioning() )
-+ if ( !tb.IsEnabled() )
- return true; // didn't fail, just ignoring
- // Create default setting
- uno::Reference< container::XIndexContainer > xIndexContainer( helper.getCfgManager()->createSettings(), uno::UNO_QUERY_THROW );
-@@ -504,7 +535,7 @@ bool CTB::ImportCustomToolBar( CustomToolBarImportHelper& helper )
- for ( std::vector< TBC >::iterator it = rTBC.begin(); it != rTBC.end(); ++it )
- {
- // createToolBar item for control
-- if ( !it->ImportToolBarControl( xIndexContainer, helper ) )
-+ if ( !it->ImportToolBarControl( rWrapper, xIndexContainer, helper, IsMenuToolbar() ) )
- return false;
- }
-
-@@ -512,27 +543,29 @@ bool CTB::ImportCustomToolBar( CustomToolBarImportHelper& helper )
-
- helper.getCfgManager()->insertSettings( sToolBarName, xIndexAccess );
- helper.applyIcons();
--
-+#if 1 // don't think this is necessary
- uno::Reference< ui::XUIConfigurationPersistence > xPersistence( helper.getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
- xPersistence->store();
--
-+
- xPersistence.set( helper.getCfgManager(), uno::UNO_QUERY_THROW );
- xPersistence->store();
-+#endif
- bRes = true;
- }
-- catch( uno::Exception& )
-+ catch( uno::Exception& e )
- {
-+ OSL_TRACE("***** For some reason we have an exception %s", rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
- bRes = false;
- }
- return bRes;
- }
-
--bool CTB::ImportMenu( const css::uno::Reference< css::container::XIndexContainer >& xIndexContainer, CustomToolBarImportHelper& rHelper )
-+bool CTB::ImportMenuTB( CTBWrapper& rWrapper, const css::uno::Reference< css::container::XIndexContainer >& xIndexContainer, CustomToolBarImportHelper& rHelper )
- {
- for ( std::vector< TBC >::iterator it = rTBC.begin(); it != rTBC.end(); ++it )
- {
- // createToolBar item for control
-- if ( !it->ImportToolBarControl( xIndexContainer, rHelper ) )
-+ if ( !it->ImportToolBarControl( rWrapper, xIndexContainer, rHelper, true ) )
- return false;
- }
- return true;
-@@ -583,7 +616,7 @@ void TBC::Print( FILE* fp )
- }
-
- bool
--TBC::ImportToolBarControl( const css::uno::Reference< css::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper )
-+TBC::ImportToolBarControl( CTBWrapper& rWrapper, const css::uno::Reference< css::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper, bool bIsMenuBar )
- {
- // cmtFci 0x1 Command based on a built-in command. See CidFci.
- // cmtMacro 0x2 Macro command. See CidMacro.
-@@ -634,12 +667,35 @@ TBC::ImportToolBarControl( const css::uno::Reference< css::container::XIndexCont
- aProp.Value <<= sCommand;
- props.push_back( aProp );
- }
--
- }
- bool bBeginGroup = false;
-- if ( ! tbcd->ImportToolBarControl( toolbarcontainer, helper, props, bBeginGroup ) )
-+ if ( ! tbcd->ImportToolBarControl( helper, props, bBeginGroup, bIsMenuBar ) )
- return false;
-
-+ TBCMenuSpecific* pMenu = tbcd->getMenuSpecific();
-+ if ( pMenu )
-+ {
-+ OSL_TRACE("** control has a menu, name of toolbar with menu items is %s", rtl::OUStringToOString( pMenu->Name(), RTL_TEXTENCODING_UTF8 ).getStr() );
-+ // search for CTB with the appropriate name ( it contains the
-+ // menu items, although we cannot import ( or create ) a menu on
-+ // a custom toolbar we can import the menu items in a separate
-+ // toolbar ( better than nothing )
-+ CTB* pCustTB = rWrapper.GetCustomizationData( pMenu->Name() );
-+ if ( pCustTB )
-+ {
-+ uno::Reference< container::XIndexContainer > xMenuDesc;
-+ uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
-+ xMenuDesc.set( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.IndexedPropertyValues" ) ) ), uno::UNO_QUERY_THROW );
-+ if ( !pCustTB->ImportMenuTB( rWrapper,xMenuDesc, helper ) )
-+ return false;
-+ beans::PropertyValue aProp;
-+
-+ aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ItemDescriptorContainer") );
-+ aProp.Value <<= xMenuDesc;
-+ props.push_back( aProp );
-+ }
-+ }
-+
- if ( bBeginGroup )
- {
- // insert spacer
-diff --git sw/source/filter/ww8/ww8toolbar.hxx sw/source/filter/ww8/ww8toolbar.hxx
-index b533cbf..3dcf2de 100644
---- sw/source/filter/ww8/ww8toolbar.hxx
-+++ sw/source/filter/ww8/ww8toolbar.hxx
-@@ -15,6 +15,7 @@ public:
- void Print( FILE* fp );
- };
-
-+class CTBWrapper;
- class TBC : public TBBase
- {
- TBCHeader tbch;
-@@ -25,7 +26,7 @@ public:
- ~TBC();
- bool Read(SvStream *pS);
- void Print( FILE* );
-- bool ImportToolBarControl( const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
-+ bool ImportToolBarControl( CTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper&, bool );
- rtl::OUString GetCustomText();
- };
-
-@@ -34,7 +35,7 @@ class CTB : public TBBase
- Xst name;
- sal_Int32 cbTBData;
- TB tb;
-- sal_uInt8 rVisualData[ 100 ];
-+ std::vector<TBVisualData> rVisualData;
- sal_Int32 iWCTBl;
- sal_uInt16 reserved;
- sal_uInt16 unused;
-@@ -48,8 +49,10 @@ public:
- ~CTB();
- bool Read(SvStream *pS);
- void Print( FILE* fp );
-- bool ImportCustomToolBar( CustomToolBarImportHelper& );
-- bool ImportMenu( const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
-+ bool IsMenuToolbar();
-+ bool ImportCustomToolBar( CTBWrapper&, CustomToolBarImportHelper& );
-+ bool ImportMenuTB( CTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
-+ rtl::OUString GetName() { return tb.getName().getString(); }
- };
-
- class TBDelta : public TBBase
-@@ -102,13 +105,16 @@ friend class CTBWrapper;
- boost::shared_ptr< CTB > customizationDataCTB;
- std::vector< TBDelta > customizationDataTBDelta;
- bool bIsDroppedMenuTB;
-+ bool ImportMenu( CTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
- public:
- Customization( CTBWrapper* rapper );
- ~Customization();
- bool Read(SvStream *pS);
-- bool ImportCustomToolBar( CustomToolBarImportHelper& );
-- bool ImportMenu( const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
-+ bool ImportCustomToolBar( CTBWrapper&, CustomToolBarImportHelper& );
-+ bool ImportMenu( CTBWrapper&, CustomToolBarImportHelper& );
- void Print( FILE* );
-+ sal_Int32 GetTBIDForTB(){ return tbidForTBD; }
-+ CTB* GetCustomizationData() { return customizationDataCTB.get(); };
- };
-
- class SfxObjectShell;
-@@ -138,7 +144,9 @@ public:
- TBC* GetTBCAtOffset( sal_uInt32 nStreamOffset );
- bool Read(SvStream *pS);
- bool ImportCustomToolBar( SfxObjectShell& rDocSh );
-+
- Customization* GetCustomizaton( sal_Int16 index );
-+ CTB* GetCustomizationData( const rtl::OUString& name );
- void Print( FILE* );
- };
-
-diff --git vcl/inc/vcl/bitmapex.hxx vcl/inc/vcl/bitmapex.hxx
-index 82287c5..1381e55 100644
---- vcl/inc/vcl/bitmapex.hxx
-+++ vcl/inc/vcl/bitmapex.hxx
-@@ -385,6 +385,7 @@ public:
-
- friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const BitmapEx& rBitmapEx );
- friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, BitmapEx& rBitmapEx );
-+ static BitmapEx AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize);
- };
-
- #endif // _SV_BITMAPEX_HXX
-diff --git vcl/inc/vcl/menu.hxx vcl/inc/vcl/menu.hxx
-index 4f8ad3a..106080c 100644
---- vcl/inc/vcl/menu.hxx
-+++ vcl/inc/vcl/menu.hxx
-@@ -93,6 +93,8 @@ typedef USHORT MenuItemBits;
- #define MIB_POPUPSELECT ((MenuItemBits)0x0020)
- // not in rsc/vclsrc.hxx because only a prelimitary solution
- #define MIB_NOSELECT ((MenuItemBits)0x0040)
-+#define MIB_ICON ((MenuItemBits)0x0080)
-+#define MIB_TEXT ((MenuItemBits)0x0100)
-
- #define MENU_FLAG_NOAUTOMNEMONICS 0x0001
- #define MENU_FLAG_HIDEDISABLEDENTRIES 0x0002
-diff --git vcl/inc/vcl/toolbox.hxx vcl/inc/vcl/toolbox.hxx
-index 105f9da..b2b27f0 100644
---- vcl/inc/vcl/toolbox.hxx
-+++ vcl/inc/vcl/toolbox.hxx
-@@ -124,6 +124,9 @@ typedef USHORT ToolBoxItemBits;
- #define TIB_DROPDOWN ((ToolBoxItemBits)0x0020)
- #define TIB_REPEAT ((ToolBoxItemBits)0x0040)
- #define TIB_DROPDOWNONLY ((ToolBoxItemBits)0x0080 | TIB_DROPDOWN) // this button has only drop down functionality
-+#define TIB_TEXT_ONLY ((ToolBoxItemBits)0x0100)
-+#define TIB_ICON_ONLY ((ToolBoxItemBits)0x0200)
-+#define TIB_TEXTICON ((ToolBoxItemBits) TIB_TEXT_ONLY | TIB_ICON_ONLY )
-
- // -----------------
- // - ToolBox-Types -
-diff --git vcl/source/gdi/bitmapex.cxx vcl/source/gdi/bitmapex.cxx
-index 1af5b19..aaae40f 100644
---- vcl/source/gdi/bitmapex.cxx
-+++ vcl/source/gdi/bitmapex.cxx
-@@ -47,6 +47,7 @@
- #include <tools/rc.h>
- #endif
- #include <vcl/svapp.hxx>
-+#include <vcl/virdev.hxx>
-
- // ------------
- // - BitmapEx -
-@@ -759,6 +760,61 @@ void BitmapEx::Draw( OutputDevice* pOutDev,
- pOutDev->DrawBitmapEx( rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, *this );
- }
-
-+BitmapEx BitmapEx:: AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize)
-+{
-+ Point aEmptyPoint(0,0);
-+ sal_Int32 imgNewWidth = 0;
-+ sal_Int32 imgNewHeight = 0;
-+ double imgposX = 0;
-+ double imgposY = 0;
-+ BitmapEx aRet = aBitmap;
-+ double imgOldWidth = aRet.GetSizePixel().Width();
-+ double imgOldHeight =aRet.GetSizePixel().Height();
-+
-+ Size aScaledSize;
-+ if (imgOldWidth >= aStandardSize || imgOldHeight >= aStandardSize)
-+ {
-+ if (imgOldWidth >= imgOldHeight)
-+ {
-+ imgNewWidth = aStandardSize;
-+ imgNewHeight = sal_Int32(imgOldHeight / (imgOldWidth / aStandardSize) + 0.5);
-+ imgposX = 0;
-+ imgposY = (aStandardSize - (imgOldHeight / (imgOldWidth / aStandardSize) + 0.5)) / 2 + 0.5;
-+ }
-+ else
-+ {
-+ imgNewHeight = aStandardSize;
-+ imgNewWidth = sal_Int32(imgOldWidth / (imgOldHeight / aStandardSize) + 0.5);
-+ imgposY = 0;
-+ imgposX = (aStandardSize - (imgOldWidth / (imgOldHeight / aStandardSize) + 0.5)) / 2 + 0.5;
-+ }
-+
-+ aScaledSize = Size( imgNewWidth, imgNewHeight );
-+ aRet.Scale( aScaledSize, BMP_SCALE_INTERPOLATE );
-+ }
-+ else
-+ {
-+ imgposX = (aStandardSize - imgOldWidth) / 2 + 0.5;
-+ imgposY = (aStandardSize - imgOldHeight) / 2 + 0.5;
-+ }
-+
-+ Size aBmpSize = aRet.GetSizePixel();
-+ Size aStdSize( aStandardSize, aStandardSize );
-+ Rectangle aRect(aEmptyPoint, aStdSize );
-+
-+ VirtualDevice aVirDevice( *Application::GetDefaultDevice(), 0, 1 );
-+ aVirDevice.SetOutputSizePixel( aStdSize );
-+ aVirDevice.SetFillColor( COL_TRANSPARENT );
-+ aVirDevice.SetLineColor( COL_TRANSPARENT );
-+
-+ //draw a rect into virDevice
-+ aVirDevice.DrawRect( aRect );
-+ Point aPointPixel( (long)imgposX, (long)imgposY );
-+ aVirDevice.DrawBitmapEx( aPointPixel, aRet );
-+ aRet = aVirDevice.GetBitmapEx( aEmptyPoint, aStdSize );
-+
-+ return aRet;
-+}
- // ------------------------------------------------------------------
-
- SvStream& operator<<( SvStream& rOStm, const BitmapEx& rBitmapEx )
-diff --git vcl/source/window/toolbox.cxx vcl/source/window/toolbox.cxx
-index ea27948..904a78e 100644
---- vcl/source/window/toolbox.cxx
-+++ vcl/source/window/toolbox.cxx
-@@ -229,6 +229,22 @@ int ToolBox::ImplGetDragWidth( ToolBox* pThis )
- }
- return width;
- }
-+
-+ButtonType determineButtonType( ImplToolItem* pItem, ButtonType defaultType )
-+{
-+ ButtonType tmpButtonType = defaultType;
-+ ToolBoxItemBits nBits( pItem->mnBits & 0x300 );
-+ if ( nBits & TIB_TEXTICON ) // item has custom setting
-+ {
-+ tmpButtonType = BUTTON_SYMBOLTEXT;
-+ if ( nBits == TIB_TEXT_ONLY )
-+ tmpButtonType = BUTTON_TEXT;
-+ else if ( nBits == TIB_ICON_ONLY )
-+ tmpButtonType = BUTTON_SYMBOL;
-+ }
-+ return tmpButtonType;
-+}
-+
- // -----------------------------------------------------------------------
-
- void ToolBox::ImplUpdateDragArea( ToolBox *pThis )
-@@ -1992,12 +2008,13 @@ BOOL ToolBox::ImplCalcItem()
- bText = FALSE;
- else
- bText = TRUE;
--
-+ ButtonType tmpButtonType = determineButtonType( &(*it), meButtonType ); // default to toolbox setting
- if ( bImage || bText )
- {
-+
- it->mbEmptyBtn = FALSE;
-
-- if ( meButtonType == BUTTON_SYMBOL )
-+ if ( tmpButtonType == BUTTON_SYMBOL )
- {
- // we're drawing images only
- if ( bImage || !bText )
-@@ -2011,7 +2028,7 @@ BOOL ToolBox::ImplCalcItem()
- it->mbVisibleText = TRUE;
- }
- }
-- else if ( meButtonType == BUTTON_TEXT )
-+ else if ( tmpButtonType == BUTTON_TEXT )
- {
- // we're drawing text only
- if ( bText || !bImage )
-@@ -3625,7 +3642,8 @@ void ToolBox::ImplDrawItem( USHORT nPos, BOOL bHighlight, BOOL bPaint, BOOL bLay
- // determine what has to be drawn on the button: image, text or both
- BOOL bImage;
- BOOL bText;
-- pItem->DetermineButtonDrawStyle( meButtonType, bImage, bText );
-+ ButtonType tmpButtonType = determineButtonType( pItem, meButtonType ); // default to toolbox setting
-+ pItem->DetermineButtonDrawStyle( tmpButtonType, bImage, bText );
-
- // compute output values
- long nBtnWidth = aBtnSize.Width()-SMALLBUTTON_HSIZE;
-diff --git vcl/source/window/toolbox2.cxx vcl/source/window/toolbox2.cxx
-index 16d4b42..31e061d 100644
---- vcl/source/window/toolbox2.cxx
-+++ vcl/source/window/toolbox2.cxx
-@@ -59,6 +59,8 @@ using namespace rtl;
-
- #define TB_SEP_SIZE 8
-
-+ButtonType determineButtonType( ImplToolItem* pItem, ButtonType defaultType );
-+
- // -----------------------------------------------------------------------
-
- ImplToolBoxPrivateData::ImplToolBoxPrivateData() :