summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authornpower Developer <npower@openoffice.org>2009-11-18 11:25:15 +0000
committernpower Developer <npower@openoffice.org>2009-11-18 11:25:15 +0000
commite6438d8b7b8d56929793a1328f7026fd0355bb98 (patch)
treeb6cb687b6f17df01793d124f2cdfe546484e7988 /framework
parentb4083630cb439a9f54340db6840e8bc6cfcc42c8 (diff)
menuincustomtoolbar: #i105626#: implement menu for custom toolbar ( and some item style override capability )
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/uielement/generictoolbarcontroller.hxx27
-rw-r--r--framework/inc/uielement/toolbarmanager.hxx7
-rw-r--r--framework/inc/xml/menuconfiguration.hxx1
-rw-r--r--framework/inc/xml/menudocumenthandler.hxx5
-rw-r--r--framework/inc/xml/toolboxconfigurationdefines.hxx3
-rw-r--r--framework/inc/xml/toolboxdocumenthandler.hxx6
-rw-r--r--framework/source/classes/menumanager.cxx22
-rw-r--r--framework/source/uielement/generictoolbarcontroller.cxx66
-rw-r--r--framework/source/uielement/menubarmanager.cxx26
-rw-r--r--framework/source/uielement/toolbarmanager.cxx65
-rw-r--r--framework/source/xml/menudocumenthandler.cxx135
-rw-r--r--framework/source/xml/toolboxdocumenthandler.cxx83
12 files changed, 408 insertions, 38 deletions
diff --git a/framework/inc/uielement/generictoolbarcontroller.hxx b/framework/inc/uielement/generictoolbarcontroller.hxx
index f1f014fb7707..109e4f9bf69b 100644
--- a/framework/inc/uielement/generictoolbarcontroller.hxx
+++ b/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 a/framework/inc/uielement/toolbarmanager.hxx b/framework/inc/uielement/toolbarmanager.hxx
index 553da978b8ce..5a835c1f1cf5 100644
--- a/framework/inc/uielement/toolbarmanager.hxx
+++ b/framework/inc/uielement/toolbarmanager.hxx
@@ -50,10 +50,12 @@
#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>
#include <com/sun/star/ui/XImageManager.hpp>
+#include <com/sun/star/ui/XUIConfigurationManager.hpp>
#include <com/sun/star/frame/XStatusListener.hpp>
#include <com/sun/star/frame/XSubToolbarController.hpp>
#include <com/sun/star/frame/XToolbarController.hpp>
@@ -200,6 +202,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,
@@ -225,10 +228,14 @@ class ToolBarManager : public ::com::sun::star::frame::XFrameActionListener
::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager > m_xModuleImageManager;
::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager > m_xDocImageManager;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xImageOrientationListener;
+ ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xUICfgMgr;
+ ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xDocUICfgMgr;
+
CommandToInfoMap m_aCommandMap;
SubToolBarToSubToolBarControllerMap m_aSubToolBarControllerMap;
Timer m_aAsyncUpdateControllersTimer;
sal_Int16 m_nSymbolsStyle;
+ MenuDescriptionMap m_aMenuMap;
};
}
diff --git a/framework/inc/xml/menuconfiguration.hxx b/framework/inc/xml/menuconfiguration.hxx
index 954fc2ae5e3e..1ce511618112 100644
--- a/framework/inc/xml/menuconfiguration.hxx
+++ b/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 a/framework/inc/xml/menudocumenthandler.hxx b/framework/inc/xml/menudocumenthandler.hxx
index a85a4c200086..cd73d4b8df66 100644
--- a/framework/inc/xml/menudocumenthandler.hxx
+++ b/framework/inc/xml/menudocumenthandler.hxx
@@ -109,13 +109,14 @@ class ReadMenuDocumentHandlerBase : public ThreadHelpBase, // Struct for right
::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler> m_xReader;
void initPropertyCommon( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > &rProps,
const rtl::OUString &rCommandURL, const rtl::OUString &rHelpId,
- const rtl::OUString &rLabel);
+ const rtl::OUString &rLabel, sal_Int16 nItemStyleBits );
private:
rtl::OUString m_aType;
rtl::OUString m_aLabel;
rtl::OUString m_aContainer;
rtl::OUString m_aHelpURL;
rtl::OUString m_aCommandURL;
+ rtl::OUString m_aStyle;
::com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > m_aItemProp;
};
@@ -306,7 +307,7 @@ class OWriteMenuDocumentHandler
virtual void WriteMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rSubMenuContainer ) throw
( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
- virtual void WriteMenuItem( const rtl::OUString& aCommandURL, const rtl::OUString& aLabel, const rtl::OUString& aHelpURL );
+ virtual void WriteMenuItem( const rtl::OUString& aCommandURL, const rtl::OUString& aLabel, const rtl::OUString& aHelpURL, sal_Int16 nStyle = 0 );
virtual void WriteMenuSeparator();
com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xMenuBarContainer;
diff --git a/framework/inc/xml/toolboxconfigurationdefines.hxx b/framework/inc/xml/toolboxconfigurationdefines.hxx
index be8292ada8de..c3cd030f6213 100644
--- a/framework/inc/xml/toolboxconfigurationdefines.hxx
+++ b/framework/inc/xml/toolboxconfigurationdefines.hxx
@@ -29,6 +29,7 @@
#define ATTRIBUTE_WIDTH "width"
#define ATTRIBUTE_USER "userdefined"
#define ATTRIBUTE_HELPID "helpid"
+#define ATTRIBUTE_TOOLTIP "tooltip"
#define ATTRIBUTE_ITEMSTYLE "style"
#define ATTRIBUTE_ID "id"
@@ -78,6 +79,8 @@
#define ATTRIBUTE_ITEMSTYLE_AUTOSIZE "autosize"
#define ATTRIBUTE_ITEMSTYLE_DROPDOWN "dropdown"
#define ATTRIBUTE_ITEMSTYLE_REPEAT "repeat"
+#define ATTRIBUTE_ITEMSTYLE_TEXT "text"
#define ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY "dropdownonly"
+#define ATTRIBUTE_ITEMSTYLE_IMAGE "image"
#endif // __FRAMEWORK_XML_TOOLBOXCONFIGURATIONDEFINES_HXX_
diff --git a/framework/inc/xml/toolboxdocumenthandler.hxx b/framework/inc/xml/toolboxdocumenthandler.hxx
index ccf64e6d0033..ae5231ed8b24 100644
--- a/framework/inc/xml/toolboxdocumenthandler.hxx
+++ b/framework/inc/xml/toolboxdocumenthandler.hxx
@@ -77,6 +77,7 @@ class OReadToolBoxDocumentHandler : private ThreadHelpBase, // Struct for right
TB_ATTRIBUTE_HELPID,
TB_ATTRIBUTE_STYLE,
TB_ATTRIBUTE_UINAME,
+ TB_ATTRIBUTE_TOOLTIP,
TB_XML_ENTRY_COUNT
};
@@ -159,10 +160,13 @@ class OReadToolBoxDocumentHandler : private ThreadHelpBase, // Struct for right
sal_Int32 m_nHashCode_Style_DropDown;
sal_Int32 m_nHashCode_Style_Repeat;
sal_Int32 m_nHashCode_Style_DropDownOnly;
+ sal_Int32 m_nHashCode_Style_Text;
+ sal_Int32 m_nHashCode_Style_Image;
rtl::OUString m_aType;
rtl::OUString m_aLabel;
rtl::OUString m_aStyle;
rtl::OUString m_aHelpURL;
+ rtl::OUString m_aTooltip;
rtl::OUString m_aIsVisible;
rtl::OUString m_aCommandURL;
};
@@ -181,7 +185,7 @@ class OWriteToolBoxDocumentHandler : private ThreadHelpBase // Struct for right
::com::sun::star::uno::RuntimeException );
protected:
- virtual void WriteToolBoxItem( const rtl::OUString& aCommandURL, const rtl::OUString& aLabel, const rtl::OUString& aHelpURL,
+ virtual void WriteToolBoxItem( const rtl::OUString& aCommandURL, const rtl::OUString& aLabel, const rtl::OUString& aHelpURL, const rtl::OUString& aTooltip, sal_Int16 nStyle,
sal_Int16 nWidth, sal_Bool bVisible ) throw
( ::com::sun::star::xml::sax::SAXException,
::com::sun::star::uno::RuntimeException );
diff --git a/framework/source/classes/menumanager.cxx b/framework/source/classes/menumanager.cxx
index bb850b876e5c..732941eefa23 100644
--- a/framework/source/classes/menumanager.cxx
+++ b/framework/source/classes/menumanager.cxx
@@ -171,6 +171,12 @@ MenuManager::MenuManager(
for ( USHORT i = 0; i < nItemCount; i++ )
{
USHORT nItemId = FillItemCommand(aItemCommand,pMenu, i );
+ bool bShowMenuImages( m_bShowMenuImages );
+ MenuItemBits nBits = pMenu->GetItemBits( nItemId );
+ // overwrite the default?
+ if ( nBits )
+ bShowMenuImages = ( ( nBits & MIB_ICON ) == MIB_ICON );
+
PopupMenu* pPopupMenu = pMenu->GetPopupMenu( nItemId );
if ( pPopupMenu )
@@ -217,7 +223,7 @@ MenuManager::MenuManager(
aQueryLabelItemIdVector.push_back( nItemId );
#endif
// Set image for the addon popup menu item
- if ( m_bShowMenuImages && !pPopupMenu->GetItemImage( ITEMID_ADDONLIST ))
+ if ( bShowMenuImages && !pPopupMenu->GetItemImage( ITEMID_ADDONLIST ))
{
Image aImage = GetImageFromURL( rFrame, aItemCommand, FALSE, m_bWasHiContrast );
if ( !!aImage )
@@ -249,7 +255,7 @@ MenuManager::MenuManager(
aQueryLabelItemIdVector.push_back( nItemId );
#endif
- if ( m_bShowMenuImages && !pMenu->GetItemImage( nItemId ))
+ if ( bShowMenuImages && !pMenu->GetItemImage( nItemId ))
{
Image aImage = GetImageFromURL( rFrame, aItemCommand, FALSE, m_bWasHiContrast );
if ( !!aImage )
@@ -274,7 +280,7 @@ MenuManager::MenuManager(
aQueryLabelItemIdVector.push_back( nItemId );
#endif
- if ( m_bShowMenuImages && !pMenu->GetItemImage( nItemId ))
+ if ( bShowMenuImages && !pMenu->GetItemImage( nItemId ))
{
Image aImage = GetImageFromURL( rFrame, aItemCommand, FALSE, m_bWasHiContrast );
if ( !!aImage )
@@ -283,7 +289,7 @@ MenuManager::MenuManager(
}
else if ( pMenu->GetItemType( i ) != MENUITEM_SEPARATOR )
{
- if ( m_bShowMenuImages )
+ if ( bShowMenuImages )
{
if ( AddonMenuManager::IsAddonMenuId( nItemId ))
{
@@ -1131,7 +1137,13 @@ void MenuManager::FillMenuImages(Reference< XFrame >& _xFrame,Menu* _pMenu,sal_B
USHORT nId = _pMenu->GetItemId( nPos );
if ( _pMenu->GetItemType( nPos ) != MENUITEM_SEPARATOR )
{
- if ( bShowMenuImages )
+ bool bTmpShowMenuImages( bShowMenuImages );
+ MenuItemBits nBits = _pMenu->GetItemBits( nId );
+ // overwrite the default?
+ if ( nBits )
+ bTmpShowMenuImages = ( ( nBits & MIB_ICON ) == MIB_ICON );
+
+ if ( bTmpShowMenuImages )
{
sal_Bool bImageSet = sal_False;
::rtl::OUString aImageId;
diff --git a/framework/source/uielement/generictoolbarcontroller.cxx b/framework/source/uielement/generictoolbarcontroller.cxx
index 311776c1bdaf..d1c4d9d6c2da 100644
--- a/framework/source/uielement/generictoolbarcontroller.cxx
+++ b/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 a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index 4c20b96f00dc..6bc21c8735c7 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/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 a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 55c8d16af2ec..964c85d6950d 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/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>
@@ -122,6 +121,7 @@ namespace framework
static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL";
+static const char ITEM_DESCRIPTOR_TOOLTIP[] = "Tooltip";
static const char ITEM_DESCRIPTOR_CONTAINER[] = "ItemDescriptorContainer";
static const char ITEM_DESCRIPTOR_LABEL[] = "Label";
static const char ITEM_DESCRIPTOR_TYPE[] = "Type";
@@ -131,6 +131,7 @@ static const char ITEM_DESCRIPTOR_STYLE[] = "Style";
static const sal_Int32 ITEM_DESCRIPTOR_COMMANDURL_LEN = 10;
static const sal_Int32 ITEM_DESCRIPTOR_HELPURL_LEN = 7;
+static const sal_Int32 ITEM_DESCRIPTOR_TOOLTIP_LEN = 7;
static const sal_Int32 ITEM_DESCRIPTOR_CONTAINER_LEN = 23;
static const sal_Int32 ITEM_DESCRIPTOR_LABEL_LEN = 5;
static const sal_Int32 ITEM_DESCRIPTOR_TYPE_LEN = 4;
@@ -143,6 +144,7 @@ static const char HELPID_PREFIX_TESTTOOL[] = ".HelpId:";
//static sal_Int32 HELPID_PREFIX_LENGTH = 7;
static const USHORT STARTID_CUSTOMIZE_POPUPMENU = 1000;
+#define MENUPREFIX "private:resource/menubar/"
class ImageOrientationListener : public svt::FrameStatusListener
{
@@ -966,8 +968,13 @@ void ToolBarManager::CreateControllers()
}
else
{
+ 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 )
@@ -1099,6 +1106,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;
}
@@ -1128,8 +1139,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
Reference< XUIConfigurationManagerSupplier > xSupplier( xModel, UNO_QUERY );
if ( xSupplier.is() )
{
- Reference< XUIConfigurationManager > xDocUICfgMgr( xSupplier->getUIConfigurationManager(), UNO_QUERY );
- m_xDocImageManager = Reference< XImageManager >( xDocUICfgMgr->getImageManager(), UNO_QUERY );
+ m_xDocUICfgMgr.set( xSupplier->getUIConfigurationManager(), UNO_QUERY );
+ m_xDocImageManager = Reference< XImageManager >( m_xDocUICfgMgr->getImageManager(), UNO_QUERY );
m_xDocImageManager->addConfigurationListener(
Reference< XUIConfigurationListener >(
static_cast< OWeakObject* >( this ), UNO_QUERY ));
@@ -1151,8 +1162,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier( m_xServiceManager->createInstance(
SERVICENAME_MODULEUICONFIGURATIONMANAGERSUPPLIER ),
UNO_QUERY );
- Reference< XUIConfigurationManager > xUICfgMgr = xModuleCfgMgrSupplier->getUIConfigurationManager( m_aModuleIdentifier );
- m_xModuleImageManager = Reference< XImageManager >( xUICfgMgr->getImageManager(), UNO_QUERY );
+ m_xUICfgMgr = xModuleCfgMgrSupplier->getUIConfigurationManager( m_aModuleIdentifier );
+ m_xModuleImageManager = Reference< XImageManager >( m_xUICfgMgr->getImageManager(), UNO_QUERY );
m_xModuleImageManager->addConfigurationListener( Reference< XUIConfigurationListener >(
static_cast< OWeakObject* >( this ), UNO_QUERY ));
}
@@ -1164,6 +1175,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++ )
{
@@ -1171,11 +1184,13 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
rtl::OUString aCommandURL;
rtl::OUString aLabel;
rtl::OUString aHelpURL;
+ rtl::OUString aTooltip;
sal_uInt16 nType( ::com::sun::star::ui::ItemType::DEFAULT );
sal_uInt16 nWidth( 0 );
sal_Bool bIsVisible( sal_True );
sal_uInt32 nStyle( 0 );
+ Reference< XIndexAccess > aMenuDesc;
try
{
if ( rItemContainer->getByIndex( n ) >>= aProp )
@@ -1183,9 +1198,44 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
for ( int i = 0; i < aProp.getLength(); i++ )
{
if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_COMMANDURL, ITEM_DESCRIPTOR_COMMANDURL_LEN ))
+ {
aProp[i].Value >>= aCommandURL;
+ if ( aCommandURL.compareToAscii(MENUPREFIX, RTL_CONSTASCII_LENGTH(MENUPREFIX) ) == 0 )
+ {
+ try
+ {
+ Reference< XIndexAccess > xMenuContainer;
+ if ( m_xDocUICfgMgr.is() )
+ xMenuContainer = m_xDocUICfgMgr->getSettings( aCommandURL, sal_False );
+ if ( !xMenuContainer.is() && m_xUICfgMgr.is() )
+ xMenuContainer = m_xUICfgMgr->getSettings( aCommandURL, sal_False );
+ if ( xMenuContainer.is() && xMenuContainer->getCount() )
+ {
+ Sequence< PropertyValue > aProps;
+ // drop down menu info is currently
+ // the first ( and only ) menu
+ // in the menusettings container
+ xMenuContainer->getByIndex(0) >>= aProps;
+ for ( sal_Int32 index=0; index<aProps.getLength(); ++index )
+ {
+ if ( aProps[ index ].Name.equalsAsciiL( ITEM_DESCRIPTOR_CONTAINER, ITEM_DESCRIPTOR_CONTAINER_LEN ))
+
+ {
+ aProps[ index ].Value >>= aMenuDesc;
+ break;
+ }
+ }
+ }
+ }
+ catch( Exception& e )
+ {
+ }
+ }
+ }
else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_HELPURL, ITEM_DESCRIPTOR_HELPURL_LEN ))
aProp[i].Value >>= aHelpURL;
+ else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_TOOLTIP, ITEM_DESCRIPTOR_TOOLTIP_LEN ))
+ aProp[i].Value >>= aTooltip;
else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_LABEL, ITEM_DESCRIPTOR_LABEL_LEN ))
aProp[i].Value >>= aLabel;
else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_TYPE, ITEM_DESCRIPTOR_TYPE_LEN ))
@@ -1203,8 +1253,13 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine
::rtl::OUString aString( RetrieveLabelFromCommand( aCommandURL ));
sal_uInt16 nItemBits = ConvertStyleToToolboxItemBits( nStyle );
+ if ( aMenuDesc.is() )
+ m_aMenuMap[ nId ] = aMenuDesc;
m_pToolBar->InsertItem( nId, aString, nItemBits );
m_pToolBar->SetItemCommand( nId, aCommandURL );
+ if ( aTooltip.getLength() )
+ m_pToolBar->SetQuickHelpText( nId, aTooltip );
+ else
m_pToolBar->SetQuickHelpText( nId, aString );
if ( aLabel.getLength() > 0 )
m_pToolBar->SetItemText( nId, aLabel );
diff --git a/framework/source/xml/menudocumenthandler.cxx b/framework/source/xml/menudocumenthandler.cxx
index 2422d516d0ac..47d8c93f71e0 100644
--- a/framework/source/xml/menudocumenthandler.cxx
+++ b/framework/source/xml/menudocumenthandler.cxx
@@ -47,6 +47,7 @@
#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
#include <com/sun/star/lang/XSingleComponentFactory.hpp>
#include <com/sun/star/ui/ItemType.hpp>
+#include <com/sun/star/ui/ItemStyle.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -80,11 +81,13 @@
#define ATTRIBUTE_LABEL "http://openoffice.org/2001/menu^label"
#define ATTRIBUTE_HELPID "http://openoffice.org/2001/menu^helpid"
#define ATTRIBUTE_LINEBREAK "http://openoffice.org/2001/menu^linebreak"
+#define ATTRIBUTE_STYLE "http://openoffice.org/2001/menu^style"
#define ATTRIBUTE_NS_ID "menu:id"
#define ATTRIBUTE_NS_LABEL "menu:label"
#define ATTRIBUTE_NS_HELPID "menu:helpid"
#define ATTRIBUTE_NS_LINEBREAK "menu:linebreak"
+#define ATTRIBUTE_NS_STYLE "menu:style"
#define ATTRIBUTE_XMLNS_MENU "xmlns:menu"
@@ -92,12 +95,16 @@
#define MENUBAR_DOCTYPE "<!DOCTYPE menu:menubar PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"menubar.dtd\">"
+#define ATTRIBUTE_ITEMSTYLE_TEXT "text"
+#define ATTRIBUTE_ITEMSTYLE_IMAGE "image"
+
// Property names of a menu/menu item ItemDescriptor
static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL";
static const char ITEM_DESCRIPTOR_CONTAINER[] = "ItemDescriptorContainer";
static const char ITEM_DESCRIPTOR_LABEL[] = "Label";
static const char ITEM_DESCRIPTOR_TYPE[] = "Type";
+static const char ITEM_DESCRIPTOR_STYLE[] = "Style";
// special popup menus (filled during runtime) must be saved as an empty popup menu or menuitem!!!
static const sal_Int32 CMD_PROTOCOL_SIZE = 5;
@@ -121,12 +128,27 @@ using namespace ::com::sun::star::ui;
namespace framework
{
+struct MenuStyleItem
+{
+ sal_Int16 nBit;
+ const char* attrName;
+};
+
+MenuStyleItem MenuItemStyles[ ] = {
+ { ::com::sun::star::ui::ItemStyle::ICON, ATTRIBUTE_ITEMSTYLE_IMAGE },
+ { ::com::sun::star::ui::ItemStyle::TEXT, ATTRIBUTE_ITEMSTYLE_TEXT },
+};
+
+
+sal_Int32 nMenuStyleItemEntries = sizeof( MenuItemStyles ) / sizeof( MenuItemStyles[ 0 ] );
+
static void ExtractMenuParameters( const Sequence< PropertyValue > rProp,
::rtl::OUString& rCommandURL,
::rtl::OUString& rLabel,
::rtl::OUString& rHelpURL,
Reference< XIndexAccess >& rSubMenu,
- sal_Int16& rType )
+ sal_Int16& rType,
+ sal_Int16& rStyle )
{
for ( sal_Int32 i = 0; i < rProp.getLength(); i++ )
{
@@ -151,6 +173,10 @@ static void ExtractMenuParameters( const Sequence< PropertyValue > rProp,
{
rProp[i].Value >>= rType;
}
+ else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE ))
+ {
+ rProp[i].Value >>= rStyle;
+ }
}
}
@@ -165,7 +191,8 @@ ReadMenuDocumentHandlerBase::ReadMenuDocumentHandlerBase() :
m_aLabel( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_LABEL )),
m_aContainer( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_CONTAINER )),
m_aHelpURL( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_HELPURL )),
- m_aCommandURL( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL ))
+ m_aCommandURL( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL )),
+ m_aStyle( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_STYLE ))
{
}
@@ -207,20 +234,22 @@ throw( SAXException, RuntimeException )
void ReadMenuDocumentHandlerBase::initPropertyCommon(
Sequence< PropertyValue > &rProps, const rtl::OUString &rCommandURL,
- const rtl::OUString &rHelpId, const rtl::OUString &rLabel)
+ const rtl::OUString &rHelpId, const rtl::OUString &rLabel, sal_Int16 nItemStyleBits )
{
rProps[0].Name = m_aCommandURL;
rProps[1].Name = m_aHelpURL;
rProps[2].Name = m_aContainer;
rProps[3].Name = m_aLabel;
- rProps[4].Name = m_aType;
+ rProps[4].Name = m_aStyle;
+ rProps[5].Name = m_aType;
// Common values
rProps[0].Value <<= rCommandURL.intern();
rProps[1].Value <<= rHelpId;
rProps[2].Value <<= Reference< XIndexContainer >();
rProps[3].Value <<= rLabel;
- rProps[4].Value <<= ::com::sun::star::ui::ItemType::DEFAULT;
+ rProps[4].Value <<= nItemStyleBits;
+ rProps[5].Value <<= ::com::sun::star::ui::ItemType::DEFAULT;
}
// -----------------------------------------------------------------------------
@@ -373,6 +402,7 @@ throw( SAXException, RuntimeException )
::rtl::OUString aHelpId;
::rtl::OUString aCommandId;
::rtl::OUString aLabel;
+ sal_Int16 nItemBits(0);
m_bMenuMode = sal_True;
@@ -399,12 +429,29 @@ throw( SAXException, RuntimeException )
aLabel = aValue;
else if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_HELPID )))
aHelpId = aValue;
+ else if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_STYLE )))
+ {
+ ::rtl::OUString aTemp( aValue );
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ::rtl::OUString aToken = aTemp.getToken( 0, '+', nIndex );
+ if ( aToken.getLength() > 0 )
+ {
+ if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_TEXT ) ) )
+ nItemBits |= ::com::sun::star::ui::ItemStyle::TEXT;
+ if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_IMAGE ) ) )
+ nItemBits |= ::com::sun::star::ui::ItemStyle::ICON;
+ }
+ }
+ while ( nIndex >= 0 );
+ }
}
if ( aCommandId.getLength() > 0 )
{
- Sequence< PropertyValue > aSubMenuProp( 5 );
- initPropertyCommon( aSubMenuProp, aCommandId, aHelpId, aLabel );
+ Sequence< PropertyValue > aSubMenuProp( 6 );
+ initPropertyCommon( aSubMenuProp, aCommandId, aHelpId, aLabel, nItemBits );
aSubMenuProp[2].Value <<= xSubItemContainer;
m_xMenuBarContainer->insertByIndex( m_xMenuBarContainer->getCount(), makeAny( aSubMenuProp ) );
@@ -589,6 +636,7 @@ throw( SAXException, RuntimeException )
::rtl::OUString aHelpId;
::rtl::OUString aCommandId;
::rtl::OUString aLabel;
+ sal_Int16 nItemBits(0);
m_bMenuMode = sal_True;
@@ -614,12 +662,30 @@ throw( SAXException, RuntimeException )
aLabel = aValue;
else if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_HELPID )))
aHelpId = aValue;
+ else if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_STYLE )))
+ {
+ ::rtl::OUString aTemp( aValue );
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ::rtl::OUString aToken = aTemp.getToken( 0, '+', nIndex );
+ if ( aToken.getLength() > 0 )
+ {
+ if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_TEXT ) ) )
+ nItemBits |= ::com::sun::star::ui::ItemStyle::TEXT;
+ if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_IMAGE ) ) )
+ nItemBits |= ::com::sun::star::ui::ItemStyle::ICON;
+ }
+ }
+ while ( nIndex >= 0 );
+ }
+
}
if ( aCommandId.getLength() > 0 )
{
- Sequence< PropertyValue > aSubMenuProp( 5 );
- initPropertyCommon( aSubMenuProp, aCommandId, aHelpId, aLabel );
+ Sequence< PropertyValue > aSubMenuProp( 6 );
+ initPropertyCommon( aSubMenuProp, aCommandId, aHelpId, aLabel, nItemBits );
aSubMenuProp[2].Value <<= xSubItemContainer;
m_xMenuContainer->insertByIndex( m_xMenuContainer->getCount(), makeAny( aSubMenuProp ) );
@@ -639,7 +705,7 @@ throw( SAXException, RuntimeException )
::rtl::OUString aHelpId;
::rtl::OUString aCommandId;
::rtl::OUString aLabel;
-
+ sal_Int16 nItemBits(0);
// read attributes for menu item
for ( sal_Int16 i=0; i< xAttrList->getLength(); i++ )
{
@@ -651,12 +717,30 @@ throw( SAXException, RuntimeException )
aLabel = aValue;
else if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_HELPID )))
aHelpId = aValue;
+ else if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_STYLE )))
+ {
+ ::rtl::OUString aTemp( aValue );
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ::rtl::OUString aToken = aTemp.getToken( 0, '+', nIndex );
+ if ( aToken.getLength() > 0 )
+ {
+ if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_TEXT ) ) )
+ nItemBits |= ::com::sun::star::ui::ItemStyle::TEXT;
+ if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_IMAGE ) ) )
+ nItemBits |= ::com::sun::star::ui::ItemStyle::ICON;
+ }
+ }
+ while ( nIndex >= 0 );
+ }
+
}
if ( aCommandId.getLength() > 0 )
{
- Sequence< PropertyValue > aMenuItem( 5 );
- initPropertyCommon( aMenuItem, aCommandId, aHelpId, aLabel );
+ Sequence< PropertyValue > aMenuItem( 6 );
+ initPropertyCommon( aMenuItem, aCommandId, aHelpId, aLabel, nItemBits );
aMenuItem[2].Value <<= Reference< XIndexContainer >();
m_xMenuContainer->insertByIndex( m_xMenuContainer->getCount(), makeAny( aMenuItem ) );
@@ -809,15 +893,16 @@ throw ( SAXException, RuntimeException )
::rtl::OUString aLabel;
::rtl::OUString aHelpURL;
sal_Int16 nType( ::com::sun::star::ui::ItemType::DEFAULT );
+ sal_Int16 nItemBits( 0 );
Reference< XIndexAccess > xSubMenu;
- ExtractMenuParameters( aProps, aCommandURL, aLabel, aHelpURL, xSubMenu, nType );
+ ExtractMenuParameters( aProps, aCommandURL, aLabel, aHelpURL, xSubMenu, nType, nItemBits );
if ( xSubMenu.is() )
{
if ( aCommandURL.equalsAscii( ADDDIRECT_CMD ) ||
aCommandURL.equalsAscii( AUTOPILOTMENU_CMD ))
{
- WriteMenuItem( aCommandURL, aLabel, aHelpURL );
+ WriteMenuItem( aCommandURL, aLabel, aHelpURL, nItemBits );
bSeparator = sal_False;
}
else if (( aCommandURL.getLength() > 0 ) && !AddonPopupMenu::IsCommandURLPrefix ( aCommandURL ))
@@ -857,7 +942,7 @@ throw ( SAXException, RuntimeException )
if ( aCommandURL.getLength() > 0 )
{
bSeparator = FALSE;
- WriteMenuItem( aCommandURL, aLabel, aHelpURL );
+ WriteMenuItem( aCommandURL, aLabel, aHelpURL, nItemBits );
}
}
else if ( !bSeparator )
@@ -872,7 +957,7 @@ throw ( SAXException, RuntimeException )
}
-void OWriteMenuDocumentHandler::WriteMenuItem( const ::rtl::OUString& aCommandURL, const ::rtl::OUString& aLabel, const ::rtl::OUString& aHelpURL)
+void OWriteMenuDocumentHandler::WriteMenuItem( const ::rtl::OUString& aCommandURL, const ::rtl::OUString& aLabel, const ::rtl::OUString& aHelpURL, sal_Int16 nStyle )
{
::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY );
@@ -894,6 +979,24 @@ void OWriteMenuDocumentHandler::WriteMenuItem( const ::rtl::OUString& aCommandUR
m_aAttributeType,
aLabel );
}
+ if (( nStyle > 0 ) && !( aCommandURL.copy( CMD_PROTOCOL_SIZE ).equalsAscii( CMD_PROTOCOL )))
+ {
+ rtl::OUString aValue;
+ MenuStyleItem* pStyle = MenuItemStyles;
+
+ for ( sal_Int32 nIndex = 0; nIndex < nMenuStyleItemEntries; ++nIndex, ++pStyle )
+ {
+ if ( nStyle & pStyle->nBit )
+ {
+ if ( aValue.getLength() )
+ aValue = aValue.concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("+") ) );
+ aValue += rtl::OUString::createFromAscii( pStyle->attrName );
+ }
+ }
+ pList->AddAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_NS_STYLE )),
+ m_aAttributeType,
+ aValue );
+ }
m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_MENUITEM )), xList );
diff --git a/framework/source/xml/toolboxdocumenthandler.cxx b/framework/source/xml/toolboxdocumenthandler.cxx
index 78d6f8158413..ba01284accdb 100644
--- a/framework/source/xml/toolboxdocumenthandler.cxx
+++ b/framework/source/xml/toolboxdocumenthandler.cxx
@@ -79,6 +79,7 @@ namespace framework
// Property names of a menu/menu item ItemDescriptor
static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL";
+static const char ITEM_DESCRIPTOR_TOOLTIP[] = "Tooltip";
static const char ITEM_DESCRIPTOR_LABEL[] = "Label";
static const char ITEM_DESCRIPTOR_TYPE[] = "Type";
static const char ITEM_DESCRIPTOR_STYLE[] = "Style";
@@ -89,6 +90,8 @@ static void ExtractToolbarParameters( const Sequence< PropertyValue > rProp,
::rtl::OUString& rCommandURL,
::rtl::OUString& rLabel,
::rtl::OUString& rHelpURL,
+ ::rtl::OUString& rTooltip,
+ sal_Int16& rStyle,
sal_Int16& rWidth,
sal_Bool& rVisible,
sal_Int16& rType )
@@ -102,6 +105,8 @@ static void ExtractToolbarParameters( const Sequence< PropertyValue > rProp,
}
else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_HELPURL ))
rProp[i].Value >>= rHelpURL;
+ else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TOOLTIP ))
+ rProp[i].Value >>= rTooltip;
else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ))
rProp[i].Value >>= rLabel;
else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TYPE ))
@@ -110,9 +115,30 @@ static void ExtractToolbarParameters( const Sequence< PropertyValue > rProp,
rProp[i].Value >>= rVisible;
else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_WIDTH ))
rProp[i].Value >>= rWidth;
+ else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE ))
+ rProp[i].Value >>= rStyle;
}
}
+struct ToolboxStyleItem
+{
+ sal_Int16 nBit;
+ const char* attrName;
+};
+
+ToolboxStyleItem Styles[ ] = {
+ { ::com::sun::star::ui::ItemStyle::RADIO_CHECK, ATTRIBUTE_ITEMSTYLE_RADIO },
+ { ::com::sun::star::ui::ItemStyle::ALIGN_LEFT, ATTRIBUTE_ITEMSTYLE_LEFT },
+ { ::com::sun::star::ui::ItemStyle::AUTO_SIZE, ATTRIBUTE_ITEMSTYLE_AUTO },
+ { ::com::sun::star::ui::ItemStyle::REPEAT, ATTRIBUTE_ITEMSTYLE_REPEAT },
+ { ::com::sun::star::ui::ItemStyle::DROPDOWN_ONLY, ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY },
+ { ::com::sun::star::ui::ItemStyle::DROP_DOWN, ATTRIBUTE_ITEMSTYLE_DROPDOWN },
+ { ::com::sun::star::ui::ItemStyle::ICON, ATTRIBUTE_ITEMSTYLE_IMAGE },
+ { ::com::sun::star::ui::ItemStyle::TEXT, ATTRIBUTE_ITEMSTYLE_TEXT },
+};
+
+sal_Int32 nStyleItemEntries = sizeof( Styles ) / sizeof( Styles[ 0 ] );
+
struct ToolBarEntryProperty
{
OReadToolBoxDocumentHandler::ToolBox_XML_Namespace nNamespace;
@@ -135,7 +161,8 @@ ToolBarEntryProperty ToolBoxEntries[OReadToolBoxDocumentHandler::TB_XML_ENTRY_CO
{ OReadToolBoxDocumentHandler::TB_NS_TOOLBAR, ATTRIBUTE_USER },
{ OReadToolBoxDocumentHandler::TB_NS_TOOLBAR, ATTRIBUTE_HELPID },
{ OReadToolBoxDocumentHandler::TB_NS_TOOLBAR, ATTRIBUTE_ITEMSTYLE },
- { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR, ATTRIBUTE_UINAME }
+ { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR, ATTRIBUTE_UINAME },
+ { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR, ATTRIBUTE_TOOLTIP },
};
OReadToolBoxDocumentHandler::OReadToolBoxDocumentHandler( const Reference< XIndexContainer >& rItemContainer ) :
@@ -145,6 +172,7 @@ OReadToolBoxDocumentHandler::OReadToolBoxDocumentHandler( const Reference< XInde
m_aLabel( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_LABEL )),
m_aStyle( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_STYLE )),
m_aHelpURL( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_HELPURL )),
+ m_aTooltip( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_TOOLTIP )),
m_aIsVisible( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_VISIBLE )),
m_aCommandURL( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL ))
{
@@ -179,6 +207,8 @@ OReadToolBoxDocumentHandler::OReadToolBoxDocumentHandler( const Reference< XInde
m_nHashCode_Style_DropDown = ::rtl::OUString::createFromAscii( ATTRIBUTE_ITEMSTYLE_DROPDOWN ).hashCode();
m_nHashCode_Style_Repeat = ::rtl::OUString::createFromAscii( ATTRIBUTE_ITEMSTYLE_REPEAT ).hashCode();
m_nHashCode_Style_DropDownOnly = ::rtl::OUString::createFromAscii( ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY ).hashCode();
+ m_nHashCode_Style_Text = ::rtl::OUString::createFromAscii( ATTRIBUTE_ITEMSTYLE_TEXT ).hashCode();
+ m_nHashCode_Style_Image = ::rtl::OUString::createFromAscii( ATTRIBUTE_ITEMSTYLE_IMAGE ).hashCode();
m_bToolBarStartFound = sal_False;
m_bToolBarEndFound = sal_False;
@@ -298,6 +328,7 @@ throw( SAXException, RuntimeException )
::rtl::OUString aLabel;
::rtl::OUString aCommandURL;
::rtl::OUString aHelpURL;
+ ::rtl::OUString aTooltip;
::rtl::OUString aBitmapName;
sal_uInt16 nItemBits( 0 );
sal_uInt16 nWidth( 0 );
@@ -369,6 +400,12 @@ throw( SAXException, RuntimeException )
}
break;
+ case TB_ATTRIBUTE_TOOLTIP:
+ {
+ aTooltip = xAttribs->getValueByIndex( n );
+ }
+ break;
+
case TB_ATTRIBUTE_STYLE:
{
// read space seperated item style list
@@ -393,6 +430,12 @@ throw( SAXException, RuntimeException )
nItemBits |= ::com::sun::star::ui::ItemStyle::REPEAT;
else if ( nHashCode == m_nHashCode_Style_DropDownOnly )
nItemBits |= ::com::sun::star::ui::ItemStyle::DROPDOWN_ONLY;
+ else if ( nHashCode == m_nHashCode_Style_DropDown )
+ nItemBits |= ::com::sun::star::ui::ItemStyle::DROP_DOWN;
+ else if ( nHashCode == m_nHashCode_Style_Text )
+ nItemBits |= ::com::sun::star::ui::ItemStyle::TEXT;
+ else if ( nHashCode == m_nHashCode_Style_Image )
+ nItemBits |= ::com::sun::star::ui::ItemStyle::ICON;
}
}
while ( nIndex >= 0 );
@@ -414,13 +457,14 @@ throw( SAXException, RuntimeException )
if ( aCommandURL.getLength() > 0 )
{
- Sequence< PropertyValue > aToolbarItemProp( 6 );
+ Sequence< PropertyValue > aToolbarItemProp( 7 );
aToolbarItemProp[0].Name = m_aCommandURL;
aToolbarItemProp[1].Name = m_aHelpURL;
aToolbarItemProp[2].Name = m_aLabel;
aToolbarItemProp[3].Name = m_aType;
aToolbarItemProp[4].Name = m_aStyle;
aToolbarItemProp[5].Name = m_aIsVisible;
+ aToolbarItemProp[6].Name = m_aTooltip;
aToolbarItemProp[0].Value <<= aCommandURL;
aToolbarItemProp[1].Value <<= aHelpURL;
@@ -428,6 +472,7 @@ throw( SAXException, RuntimeException )
aToolbarItemProp[3].Value = makeAny( ::com::sun::star::ui::ItemType::DEFAULT );
aToolbarItemProp[4].Value <<= nItemBits;
aToolbarItemProp[5].Value <<= bVisible;
+ aToolbarItemProp[6].Value <<= aTooltip;
m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) );
}
@@ -718,13 +763,15 @@ void OWriteToolBoxDocumentHandler::WriteToolBoxDocument() throw
::rtl::OUString aCommandURL;
::rtl::OUString aLabel;
::rtl::OUString aHelpURL;
+ ::rtl::OUString aTooltip;
sal_Bool bVisible( sal_True );
sal_Int16 nType( ::com::sun::star::ui::ItemType::DEFAULT );
sal_Int16 nWidth( 0 );
+ sal_Int16 nStyle( 0 );
- ExtractToolbarParameters( aProps, aCommandURL, aLabel, aHelpURL, nWidth, bVisible, nType );
+ ExtractToolbarParameters( aProps, aCommandURL, aLabel, aHelpURL, aTooltip, nStyle, nWidth, bVisible, nType );
if ( nType == ::com::sun::star::ui::ItemType::DEFAULT )
- WriteToolBoxItem( aCommandURL, aLabel, aHelpURL, nWidth, bVisible );
+ WriteToolBoxItem( aCommandURL, aLabel, aHelpURL, aTooltip, nStyle, nWidth, bVisible );
else if ( nType == ::com::sun::star::ui::ItemType::SEPARATOR_SPACE )
WriteToolBoxSpace();
else if ( nType == ::com::sun::star::ui::ItemType::SEPARATOR_LINE )
@@ -748,6 +795,8 @@ void OWriteToolBoxDocumentHandler::WriteToolBoxItem(
const ::rtl::OUString& rCommandURL,
const ::rtl::OUString& rLabel,
const ::rtl::OUString& rHelpURL,
+ const ::rtl::OUString& rTooltip,
+ sal_Int16 nStyle,
sal_Int16 nWidth,
sal_Bool bVisible )
throw ( SAXException, RuntimeException )
@@ -785,6 +834,32 @@ throw ( SAXException, RuntimeException )
rHelpURL );
}
+ if ( rTooltip.getLength() > 0 )
+ {
+ pList->AddAttribute( m_aXMLToolbarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_TOOLTIP )),
+ m_aAttributeType,
+ rTooltip );
+ }
+
+ if ( nStyle > 0 )
+ {
+ rtl::OUString aValue;
+ ToolboxStyleItem* pStyle = Styles;
+
+ for ( sal_Int32 nIndex = 0; nIndex < nStyleItemEntries; ++nIndex, ++pStyle )
+ {
+ if ( nStyle & pStyle->nBit )
+ {
+ if ( aValue.getLength() )
+ aValue = aValue.concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" ") ) );
+ aValue += rtl::OUString::createFromAscii( pStyle->attrName );
+ }
+ }
+ pList->AddAttribute( m_aXMLToolbarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ITEMSTYLE )),
+ m_aAttributeType,
+ aValue );
+ }
+
if ( nWidth > 0 )
{
pList->AddAttribute( m_aXMLToolbarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_WIDTH )),