[ooo-build-commit] 2 commits - patches/dev300 patches/vba
Pei Feng Lin
pflin at kemper.freedesktop.org
Thu Jul 16 20:29:16 PDT 2009
patches/dev300/apply | 6
patches/vba/uno-xmenu-getpopupMenu-fix.diff | 48 ++++
patches/vba/vba-commandbar-document-scope.diff | 252 ++++++++++++++++++++++++
patches/vba/vba-commandbarcontrol-enabled.diff | 255 ++++++++++++++++++++++++-
4 files changed, 550 insertions(+), 11 deletions(-)
New commits:
commit 99eb3574e6d7a3b673b5e6e176bde0dff8fb1919
Author: Fong Lin <pflin at novell.com>
Date: Fri Jul 17 11:29:20 2009 +0800
create toolbar/menubar in document scope
* patches/dev300/apply:
* patches/vba/vba-commandbar-document-scope.diff:
diff --git a/patches/dev300/apply b/patches/dev300/apply
index 1ae24f6..c9986d0 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -1876,6 +1876,8 @@ vba-workbook-precisionasdisplayed.diff, n#520228, Fong
uno-xmenu-getpopupMenu-fix.diff, i#103486, Fong
# support CommandbarControl.Enabled
vba-commandbarcontrol-enabled.diff, n#520228, Fong
+# create toolbar/menubar in document scope
+vba-commandbar-document-scope.diff, Fong
# fix for dim a variable as vba constant
vba-dim-as-contants-fix.diff, n#521820, Fong
[VBAUntested]
diff --git a/patches/vba/vba-commandbar-document-scope.diff b/patches/vba/vba-commandbar-document-scope.diff
new file mode 100644
index 0000000..ef21041
--- /dev/null
+++ b/patches/vba/vba-commandbar-document-scope.diff
@@ -0,0 +1,252 @@
+diff --git vbahelper/source/vbahelper/vbacommandbar.cxx vbahelper/source/vbahelper/vbacommandbar.cxx
+index 8c10277..63af635 100644
+--- vbahelper/source/vbahelper/vbacommandbar.cxx
++++ vbahelper/source/vbahelper/vbacommandbar.cxx
+@@ -61,7 +61,7 @@ ScVbaCommandBar::getName() throw ( uno::RuntimeException )
+ {
+ if( m_bIsMenu )
+ {
+- if( m_sResourceUrl.equals( VbaCommandBarHelper::getMenuBarUrl() ) )
++ if( m_sResourceUrl.equalsAscii( ITEM_MENUBAR_URL ) )
+ {
+ if( pCBarHelper->getModuleId().equalsAscii("com.sun.star.sheet.SpreadsheetDocument") )
+ sName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Worksheet Menu Bar") );
+@@ -87,18 +87,7 @@ ScVbaCommandBar::setName( const ::rtl::OUString& _name ) throw (uno::RuntimeExce
+ uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
+ xPropertySet->setPropertyValue( rtl::OUString::createFromAscii("UIName"), uno::makeAny( _name ) );
+
+- if( pCBarHelper->getAppCfgManager()->hasSettings( m_sResourceUrl ) )
+- {
+- pCBarHelper->getAppCfgManager()->replaceSettings( m_sResourceUrl, m_xBarSettings );
+- }
+- else
+- {
+- pCBarHelper->getAppCfgManager()->insertSettings( m_sResourceUrl, m_xBarSettings );
+- }
+- if( !m_bTemporary )
+- {
+- pCBarHelper->persistChanges();
+- }
++ pCBarHelper->ApplyChange( m_sResourceUrl, m_xBarSettings );
+ }
+ ::sal_Bool SAL_CALL
+ ScVbaCommandBar::getVisible() throw (uno::RuntimeException)
+@@ -163,20 +152,7 @@ ScVbaCommandBar::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException)
+ void SAL_CALL
+ ScVbaCommandBar::Delete( ) throw (script::BasicErrorException, uno::RuntimeException)
+ {
+- if( pCBarHelper->getAppCfgManager()->hasSettings( m_sResourceUrl ) )
+- {
+- pCBarHelper->getAppCfgManager()->removeSettings(m_sResourceUrl);
+- // make it permanent
+- if( !m_bTemporary )
+- {
+- pCBarHelper->persistChanges();
+- }
+- }
+- else
+- {
+- // toolbar not found
+- // TODO throw Error
+- }
++ pCBarHelper->removeSettings( m_sResourceUrl );
+ uno::Reference< container::XNameContainer > xNameContainer( pCBarHelper->getPersistentWindowState(), uno::UNO_QUERY_THROW );
+ if( xNameContainer->hasByName( m_sResourceUrl ) )
+ {
+diff --git vbahelper/source/vbahelper/vbacommandbarcontrol.cxx vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
+index 050af79..f6eb381 100644
+--- vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
++++ vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
+@@ -53,9 +53,7 @@ void ScVbaCommandBarControl::ApplyChange() throw ( uno::RuntimeException )
+ {
+ uno::Reference< container::XIndexContainer > xIndexContainer( m_xCurrentSettings, uno::UNO_QUERY_THROW );
+ xIndexContainer->replaceByIndex( m_nPosition, uno::makeAny( m_aPropertyValues ) );
+- pCBarHelper->getAppCfgManager()->replaceSettings( m_sResourceUrl, m_xBarSettings );
+- if( !m_bTemporary )
+- pCBarHelper->persistChanges();
++ pCBarHelper->ApplyChange( m_sResourceUrl, m_xBarSettings );
+ }
+
+ ::rtl::OUString SAL_CALL
+@@ -159,19 +157,7 @@ ScVbaCommandBarControl::Delete( ) throw (script::BasicErrorException, uno::Runt
+ uno::Reference< container::XIndexContainer > xIndexContainer( m_xCurrentSettings, uno::UNO_QUERY_THROW );
+ xIndexContainer->removeByIndex( m_nPosition );
+
+- if( pCBarHelper->getAppCfgManager()->hasSettings( m_sResourceUrl ) )
+- {
+- pCBarHelper->getAppCfgManager()->replaceSettings( m_sResourceUrl, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+- }
+- else
+- {
+- pCBarHelper->getAppCfgManager()->insertSettings( m_sResourceUrl, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
+- }
+- // make it permanent
+- if( !m_bTemporary )
+- {
+- pCBarHelper->persistChanges();
+- }
++ pCBarHelper->ApplyChange( m_sResourceUrl, m_xBarSettings );
+ }
+ }
+
+diff --git vbahelper/source/vbahelper/vbacommandbarcontrols.cxx vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
+index 488b56a..1aa7d7e 100644
+--- vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
++++ vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
+@@ -223,9 +223,7 @@ ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const un
+ uno::Reference< container::XIndexContainer > xIndexContainer( m_xIndexAccess, uno::UNO_QUERY_THROW );
+ xIndexContainer->insertByIndex( nPosition, uno::makeAny( aProps ) );
+
+- pCBarHelper->getAppCfgManager()->replaceSettings( m_sResourceUrl, m_xBarSettings );
+- if( !bTemporary )
+- pCBarHelper->persistChanges();
++ pCBarHelper->ApplyChange( m_sResourceUrl, m_xBarSettings );
+
+ // sometimes it would crash if passing m_xMenu instead of uno::Reference< awt::XMenu >() in Linux.
+ ScVbaCommandBarControl* pNewCommandBarControl = NULL;
+diff --git vbahelper/source/vbahelper/vbacommandbarhelper.cxx vbahelper/source/vbahelper/vbacommandbarhelper.cxx
+index 034e506..3cf12f6 100644
+--- vbahelper/source/vbahelper/vbacommandbarhelper.cxx
++++ vbahelper/source/vbahelper/vbacommandbarhelper.cxx
+@@ -138,14 +138,48 @@ void VbaCommandBarHelper::Init( ) throw (css::uno::RuntimeException)
+ m_xWindowState.set( xNameAccess->getByName( maModuleId ), uno::UNO_QUERY_THROW );
+ }
+
+-css::uno::Reference< css::container::XIndexAccess > VbaCommandBarHelper::getMenuBarSettings() throw (css::uno::RuntimeException)
++css::uno::Reference< css::container::XIndexAccess > VbaCommandBarHelper::getSettings( const rtl::OUString& sResourceUrl ) throw (css::uno::RuntimeException)
+ {
+- return m_xAppCfgMgr->getSettings( getMenuBarUrl(), sal_True );
++ if( m_xDocCfgMgr->hasSettings( sResourceUrl ) )
++ return m_xDocCfgMgr->getSettings( sResourceUrl, sal_True );
++ else if( m_xAppCfgMgr->hasSettings( sResourceUrl ) )
++ return m_xAppCfgMgr->getSettings( sResourceUrl, sal_True );
++ else
++ {
++ css::uno::Reference< css::container::XIndexAccess > xSettings( m_xAppCfgMgr->createSettings( ), uno::UNO_QUERY_THROW );
++ return xSettings;
++ }
++}
++
++void VbaCommandBarHelper::removeSettings( const rtl::OUString& sResourceUrl ) throw (css::uno::RuntimeException)
++{
++ if( m_xDocCfgMgr->hasSettings( sResourceUrl ) )
++ m_xDocCfgMgr->removeSettings( sResourceUrl );
++ else if( m_xAppCfgMgr->hasSettings( sResourceUrl ) )
++ m_xAppCfgMgr->removeSettings( sResourceUrl );
++
++ // persistChanges();
++}
++
++sal_Bool VbaCommandBarHelper::ApplyChange( const rtl::OUString& sResourceUrl, const css::uno::Reference< css::container::XIndexAccess >& xSettings, sal_Bool bTemporary ) throw (css::uno::RuntimeException)
++{
++ if( m_xDocCfgMgr->hasSettings( sResourceUrl ) )
++ {
++ m_xDocCfgMgr->replaceSettings( sResourceUrl, xSettings );
++ }
++ else
++ {
++ m_xDocCfgMgr->insertSettings( sResourceUrl, xSettings );
++ }
++ if( !bTemporary )
++ {
++ persistChanges();
++ }
+ }
+
+ sal_Bool VbaCommandBarHelper::persistChanges() throw (css::uno::RuntimeException)
+ {
+- uno::Reference< css::ui::XUIConfigurationPersistence > xConfigPersistence( m_xAppCfgMgr, uno::UNO_QUERY_THROW );
++ uno::Reference< css::ui::XUIConfigurationPersistence > xConfigPersistence( m_xDocCfgMgr, uno::UNO_QUERY_THROW );
+ sal_Bool result = sal_False;
+ if( xConfigPersistence->isModified() )
+ {
+@@ -163,12 +197,6 @@ uno::Reference< frame::XLayoutManager > VbaCommandBarHelper::getLayoutManager()
+ return xLayoutManager;
+ }
+
+-rtl::OUString VbaCommandBarHelper::getMenuBarUrl()
+-{
+- static const rtl::OUString sMenuBarUrl( RTL_CONSTASCII_USTRINGPARAM( ITEM_MENUBAR_URL ) );
+- return sMenuBarUrl;
+-}
+-
+ // return the resource url if found
+ rtl::OUString VbaCommandBarHelper::findToolbarByName( const css::uno::Reference< css::container::XNameAccess >& xNameAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException)
+ {
+@@ -187,9 +215,9 @@ rtl::OUString VbaCommandBarHelper::findToolbarByName( const css::uno::Reference<
+ if(sResourceUrl.indexOf( rtl::OUString::createFromAscii( ITEM_TOOLBAR_URL ) ) == 0 )
+ {
+ //OSL_TRACE("VbaCommandBarHelper::findToolbarByName, toolbar resource url: %s", rtl::OUStringToOString( sResourceUrl, RTL_TEXTENCODING_UTF8 ).getStr() );
+- if( m_xAppCfgMgr->hasSettings( sResourceUrl ) )
++ if( m_xDocCfgMgr->hasSettings( sResourceUrl ) )
+ {
+- uno::Reference< beans::XPropertySet > xPropertySet( m_xAppCfgMgr->getSettings( sResourceUrl, sal_False ), uno::UNO_QUERY_THROW );
++ uno::Reference< beans::XPropertySet > xPropertySet( m_xDocCfgMgr->getSettings( sResourceUrl, sal_False ), uno::UNO_QUERY_THROW );
+ xPropertySet->getPropertyValue( rtl::OUString::createFromAscii(ITEM_DESCRIPTOR_UINAME) ) >>= sUIName;
+ // OSL_TRACE("VbaCommandBarHelper::findToolbarByName, toolbar ui name: %s", rtl::OUStringToOString( sUIName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ if( sName.equalsIgnoreAsciiCase( sUIName ) )
+diff --git vbahelper/source/vbahelper/vbacommandbarhelper.hxx vbahelper/source/vbahelper/vbacommandbarhelper.hxx
+index 64a808d..10ed441 100644
+--- vbahelper/source/vbahelper/vbacommandbarhelper.hxx
++++ vbahelper/source/vbahelper/vbacommandbarhelper.hxx
+@@ -89,17 +89,18 @@ public:
+ {
+ return m_xAppCfgMgr;
+ }
+- css::uno::Reference< css::container::XIndexAccess > getMenuBarSettings() throw (css::uno::RuntimeException);
+ css::uno::Reference< css::container::XNameAccess > getPersistentWindowState() throw (css::uno::RuntimeException)
+ {
+ return m_xWindowState;
+ }
+ sal_Bool persistChanges() throw (css::uno::RuntimeException);
++ css::uno::Reference< css::container::XIndexAccess > getSettings( const rtl::OUString& sResourceUrl ) throw (css::uno::RuntimeException);
++ void removeSettings( const rtl::OUString& sResourceUrl ) throw (css::uno::RuntimeException);
++ sal_Bool ApplyChange( const rtl::OUString& sResourceUrl, const css::uno::Reference< css::container::XIndexAccess >& xSettings, sal_Bool bTemporary = sal_True ) throw (css::uno::RuntimeException);
+
+ css::uno::Reference< css::frame::XLayoutManager > getLayoutManager() throw (css::uno::RuntimeException);
+
+ const rtl::OUString getModuleId(){ return maModuleId; }
+- static rtl::OUString getMenuBarUrl();
+ rtl::OUString findToolbarByName( const css::uno::Reference< css::container::XNameAccess >& xNameAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException);
+ static sal_Int32 findControlByName( const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException);
+ static rtl::OUString generateCustomURL();
+diff --git vbahelper/source/vbahelper/vbacommandbars.cxx vbahelper/source/vbahelper/vbacommandbars.cxx
+index 0f7881e..e87e4a3 100644
+--- vbahelper/source/vbahelper/vbacommandbars.cxx
++++ vbahelper/source/vbahelper/vbacommandbars.cxx
+@@ -76,7 +76,7 @@ public:
+ rtl::OUString sResourceUrl( m_sNames[ m_nCurrentPosition++ ] );
+ if( sResourceUrl.indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 )
+ {
+- uno::Reference< container::XIndexAccess > xCBarSetting = pCBarHelper->getAppCfgManager()->getSettings( sResourceUrl, sal_True );
++ uno::Reference< container::XIndexAccess > xCBarSetting = pCBarHelper->getSettings( sResourceUrl );
+ uno::Reference< XCommandBar > xCommandBar( new ScVbaCommandBar( m_xParent, m_xContext, pCBarHelper, xCBarSetting, sResourceUrl, sal_False, sal_False ) );
+ }
+ else
+@@ -125,7 +125,7 @@ ScVbaCommandBars::createCollectionObject( const uno::Any& aSource )
+ || sBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Menu Bar") ) )
+ {
+ // menu bar
+- sResourceUrl = pCBarHelper->getMenuBarUrl();
++ sResourceUrl = rtl::OUString::createFromAscii( ITEM_MENUBAR_URL );
+ bMenu = sal_True;
+ }
+ else
+@@ -136,7 +136,7 @@ ScVbaCommandBars::createCollectionObject( const uno::Any& aSource )
+ }
+
+ if( sResourceUrl.getLength() )
+- xBarSettings = pCBarHelper->getAppCfgManager()->getSettings( sResourceUrl, sal_True );
++ xBarSettings = pCBarHelper->getSettings( sResourceUrl );
+ else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toolbar do not exist") ), uno::Reference< uno::XInterface >() );
+
+@@ -171,7 +171,7 @@ ScVbaCommandBars::Add( const css::uno::Any& Name, const css::uno::Any& /*Positio
+ Temporary >>= bTemporary;
+
+ sResourceUrl = VbaCommandBarHelper::generateCustomURL();
+- uno::Reference< container::XIndexAccess > xBarSettings( pCBarHelper->getAppCfgManager()->createSettings(), uno::UNO_QUERY_THROW );
++ uno::Reference< container::XIndexAccess > xBarSettings( pCBarHelper->getSettings( sResourceUrl ), uno::UNO_QUERY_THROW );
+ uno::Reference< XCommandBar > xCBar( new ScVbaCommandBar( this, mxContext, pCBarHelper, xBarSettings, sResourceUrl, sal_False, bTemporary ) );
+ xCBar->setName( sName );
+ return xCBar;
commit 482affde7c39c8d6006366e87982bcd19934e46e
Author: Fong Lin <pflin at novell.com>
Date: Fri Jul 17 11:25:52 2009 +0800
Fixed for i#103486, really support set Enabled/Disabled to menu item.
* patches/dev300/apply:
* patches/vba/uno-xmenu-getpopupMenu-fix.diff:
* patches/vba/vba-commandbarcontrol-enabled.diff:
diff --git a/patches/dev300/apply b/patches/dev300/apply
index 1640abe..1ae24f6 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -1872,7 +1872,9 @@ vba-workbook-auto-open-event.diff, n#520228, Fong
vba-buildin-toolbar-fix.diff, n#520228, Fong
# support WorkBook.PrecisionAsDisplayed
vba-workbook-precisionasdisplayed.diff, n#520228, Fong
-# support CommandbarControl.Enabled ( Stub )
+# fix for uno api in XMenu::getPopupMenu
+uno-xmenu-getpopupMenu-fix.diff, i#103486, Fong
+# support CommandbarControl.Enabled
vba-commandbarcontrol-enabled.diff, n#520228, Fong
# fix for dim a variable as vba constant
vba-dim-as-contants-fix.diff, n#521820, Fong
diff --git a/patches/vba/uno-xmenu-getpopupMenu-fix.diff b/patches/vba/uno-xmenu-getpopupMenu-fix.diff
new file mode 100644
index 0000000..32bd06e
--- /dev/null
+++ b/patches/vba/uno-xmenu-getpopupMenu-fix.diff
@@ -0,0 +1,48 @@
+diff --git toolkit/inc/toolkit/awt/vclxmenu.hxx toolkit/inc/toolkit/awt/vclxmenu.hxx
+index 2f2d6c6..84ca639 100644
+--- toolkit/inc/toolkit/awt/vclxmenu.hxx
++++ toolkit/inc/toolkit/awt/vclxmenu.hxx
+@@ -48,6 +48,7 @@
+ class Menu;
+ class MenuBar;
+ class VclSimpleEvent;
++class PopupMenu;
+
+ DECLARE_LIST( PopupMenuRefList, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >* )
+
+@@ -184,6 +185,7 @@ class TOOLKIT_DLLPUBLIC VCLXPopupMenu : public VCLXMenu
+ {
+ public:
+ VCLXPopupMenu();
++ VCLXPopupMenu( PopupMenu* pPopMenu );
+ };
+
+ #endif // _TOOLKIT_AWT_VCLXMENU_HXX_
+diff --git toolkit/source/awt/vclxmenu.cxx toolkit/source/awt/vclxmenu.cxx
+index 192beab..7bbfa60 100644
+--- toolkit/source/awt/vclxmenu.cxx
++++ toolkit/source/awt/vclxmenu.cxx
+@@ -529,6 +529,14 @@ void VCLXMenu::setPopupMenu( sal_Int16 nItemId, const ::com::sun::star::uno::Ref
+ break;
+ }
+ }
++ // it seems the popup menu is not insert into maPopupMenueRefs
++ // if the popup men is not created by stardiv.Toolkit.VCLXPopupMenu
++ if( !aRef.is() )
++ {
++ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > * pNewRef = new ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > ;
++ *pNewRef = new VCLXPopupMenu( (PopupMenu*)pMenu );
++ aRef = *pNewRef;
++ }
+ }
+ return aRef;
+ }
+@@ -1057,3 +1065,8 @@ VCLXPopupMenu::VCLXPopupMenu()
+ DBG_CTOR( VCLXPopupMenu, 0 );
+ ImplCreateMenu( TRUE );
+ }
++
++VCLXPopupMenu::VCLXPopupMenu( PopupMenu* pPopMenu ) : VCLXMenu( (Menu *)pPopMenu )
++{
++ DBG_CTOR( VCLXPopupMenu, 0 );
++}
diff --git a/patches/vba/vba-commandbarcontrol-enabled.diff b/patches/vba/vba-commandbarcontrol-enabled.diff
index 3f45fd2..d65a3d6 100644
--- a/patches/vba/vba-commandbarcontrol-enabled.diff
+++ b/patches/vba/vba-commandbarcontrol-enabled.diff
@@ -11,17 +11,28 @@ index 167bce8..b10750e 100644
void Delete() raises ( com::sun::star::script::BasicErrorException );
any Controls( [in] any Index ) raises ( com::sun::star::script::BasicErrorException );
diff --git vbahelper/source/vbahelper/vbacommandbar.cxx vbahelper/source/vbahelper/vbacommandbar.cxx
-index 43abe41..fcb3c62 100644
+index 43abe41..8c10277 100644
--- vbahelper/source/vbahelper/vbacommandbar.cxx
+++ vbahelper/source/vbahelper/vbacommandbar.cxx
-@@ -151,16 +151,14 @@ ScVbaCommandBar::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
+@@ -128,9 +128,7 @@ ScVbaCommandBar::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
+ {
+ try
+ {
+- uno::Reference< frame::XFrame > xFrame( pCBarHelper->getModel()->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
+- uno::Reference< beans::XPropertySet > xPropertySet( xFrame, uno::UNO_QUERY_THROW );
+- uno::Reference< frame::XLayoutManager > xLayoutManager( xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("LayoutManager") ), uno::UNO_QUERY_THROW );
++ uno::Reference< frame::XLayoutManager > xLayoutManager = pCBarHelper->getLayoutManager();
+ if( _visible )
+ {
+ xLayoutManager->createElement( m_sResourceUrl );
+@@ -151,16 +149,15 @@ ScVbaCommandBar::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
::sal_Bool SAL_CALL
ScVbaCommandBar::getEnabled() throw (uno::RuntimeException)
{
- // #FIXME: seems tha main menu is alwayse enabled.
- // for the toolbar, need to investigate
- return sal_True;
-+ // emulated by Visiable
++ // emulated with Visible
+ return getVisible();
}
@@ -31,39 +42,137 @@ index 43abe41..fcb3c62 100644
{
- // #FIXME: seems tha main menu is alwayse enabled.
- // for the toolbar, need to investigate
++ // emulated with Visible
+ setVisible( _enabled );
}
void SAL_CALL
+@@ -189,7 +186,14 @@ ScVbaCommandBar::Delete( ) throw (script::BasicErrorException, uno::RuntimeExce
+ uno::Any SAL_CALL
+ ScVbaCommandBar::Controls( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException)
+ {
+- uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, m_xBarSettings, pCBarHelper, m_xBarSettings, m_sResourceUrl ) );
++ uno::Reference< awt::XMenu > xMenu;
++ if( m_bIsMenu )
++ {
++ uno::Reference< frame::XLayoutManager > xLayoutManager = pCBarHelper->getLayoutManager();
++ uno::Reference< beans::XPropertySet > xPropertySet( xLayoutManager->getElement( m_sResourceUrl ), uno::UNO_QUERY_THROW );
++ xMenu.set( xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("XMenuBar") ), uno::UNO_QUERY );
++ }
++ uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, m_xBarSettings, pCBarHelper, m_xBarSettings, m_sResourceUrl, xMenu ) );
+ if( aIndex.hasValue() )
+ {
+ return xCommandBarControls->Item( aIndex, uno::Any() );
diff --git vbahelper/source/vbahelper/vbacommandbarcontrol.cxx vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
-index dd20256..111123c 100644
+index dd20256..050af79 100644
--- vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
+++ vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
-@@ -118,6 +118,19 @@ ScVbaCommandBarControl::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeExc
+@@ -118,6 +118,39 @@ ScVbaCommandBarControl::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeExc
}
}
+::sal_Bool SAL_CALL
+ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException)
+{
-+ // emulated by Visiable
-+ return getVisible();
++ sal_Bool bEnabled = sal_True;
++ if( m_xParentMenu.is() )
++ {
++ // currently only the menu in the MenuBat support Enable/Disable
++ // FIXME: how to support the menu item in Toolbar
++ bEnabled = m_xParentMenu->isItemEnabled( m_xParentMenu->getItemId( m_nPosition ) );
++ }
++ else
++ {
++ // emulated with Visible
++ bEnabled = getVisible();
++ }
++ return bEnabled;
+}
+
+void SAL_CALL
+ScVbaCommandBarControl::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException)
+{
-+ setVisible( _enabled );
++ if( m_xParentMenu.is() )
++ {
++ // currently only the menu in the MenuBat support Enable/Disable
++ m_xParentMenu->enableItem( m_xParentMenu->getItemId( m_nPosition ), _enabled );
++ }
++ else
++ {
++ // emulated with Visible
++ setVisible( _enabled );
++ }
+}
+
void SAL_CALL
ScVbaCommandBarControl::Delete( ) throw (script::BasicErrorException, uno::RuntimeException)
{
+@@ -150,8 +183,15 @@ ScVbaCommandBarControl::Controls( const uno::Any& aIndex ) throw (script::BasicE
+ getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_CONTAINER ) ) >>= xSubMenu;
+ if( !xSubMenu.is() )
+ throw uno::RuntimeException();
++
++ uno::Reference< awt::XMenu > xMenu;
++ if( m_xParentMenu.is() )
++ {
++ sal_Int32 nItemId = m_xParentMenu->getItemId( m_nPosition );
++ xMenu.set( m_xParentMenu->getPopupMenu( nItemId ), uno::UNO_QUERY );
++ }
+
+- uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, xSubMenu, pCBarHelper, m_xBarSettings, m_sResourceUrl ) );
++ uno::Reference< XCommandBarControls > xCommandBarControls( new ScVbaCommandBarControls( this, mxContext, xSubMenu, pCBarHelper, m_xBarSettings, m_sResourceUrl, xMenu ) );
+ if( aIndex.hasValue() )
+ {
+ return xCommandBarControls->Item( aIndex, uno::Any() );
+@@ -179,11 +219,12 @@ ScVbaCommandBarControl::getServiceNames()
+ }
+
+ //////////// ScVbaCommandBarPopup //////////////////////////////
+-ScVbaCommandBarPopup::ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
++ScVbaCommandBarPopup::ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException) : CommandBarPopup_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
+ {
+ m_nPosition = nPosition;
+ m_bTemporary = bTemporary;
+ m_xCurrentSettings->getByIndex( m_nPosition ) >>= m_aPropertyValues;
++ m_xParentMenu = xMenu;
+ }
+
+ rtl::OUString&
+@@ -205,11 +246,12 @@ ScVbaCommandBarPopup::getServiceNames()
+ }
+
+ //////////// ScVbaCommandBarButton //////////////////////////////
+-ScVbaCommandBarButton::ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
++ScVbaCommandBarButton::ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException) : CommandBarButton_BASE( xParent, xContext, xSettings, pHelper, xBarSettings, sResourceUrl )
+ {
+ m_nPosition = nPosition;
+ m_bTemporary = bTemporary;
+ m_xCurrentSettings->getByIndex( m_nPosition ) >>= m_aPropertyValues;
++ m_xParentMenu = xMenu;
+ }
+
+ rtl::OUString&
diff --git vbahelper/source/vbahelper/vbacommandbarcontrol.hxx vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
-index f40ad82..e125317 100644
+index f40ad82..0d2d30b 100644
--- vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
+++ vbahelper/source/vbahelper/vbacommandbarcontrol.hxx
-@@ -71,6 +71,8 @@ public:
+@@ -39,6 +39,7 @@
+ #include <ooo/vba/XCommandBarPopup.hpp>
+ #include <ooo/vba/XCommandBarButton.hpp>
+ #include <ooo/vba/office/MsoControlType.hpp>
++#include <com/sun/star/awt/XMenu.hpp>
+ #include <vbahelper/vbahelperinterface.hxx>
+ #include "vbacommandbarhelper.hxx"
+ #include <cppuhelper/implbase1.hxx>
+@@ -53,6 +54,7 @@ protected:
+ css::uno::Reference< css::container::XIndexAccess > m_xCurrentSettings;
+ css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
+ css::uno::Sequence< css::beans::PropertyValue > m_aPropertyValues;
++ css::uno::Reference< css::awt::XMenu > m_xParentMenu;
+
+ sal_Int32 m_nPosition;
+ sal_Bool m_bTemporary;
+@@ -71,6 +73,8 @@ public:
virtual void SAL_CALL setOnAction( const ::rtl::OUString& _onaction ) throw (css::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (css::uno::RuntimeException);
@@ -72,3 +181,129 @@ index f40ad82..e125317 100644
virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException)
{
return ov::office::MsoControlType::msoControlButton;
+@@ -89,7 +93,7 @@ typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarPop
+ class ScVbaCommandBarPopup : public CommandBarPopup_BASE
+ {
+ public:
+- ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
++ ScVbaCommandBarPopup( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException)
+ {
+@@ -104,7 +108,7 @@ typedef cppu::ImplInheritanceHelper1< ScVbaCommandBarControl, ov::XCommandBarBut
+ class ScVbaCommandBarButton : public CommandBarButton_BASE
+ {
+ public:
+- ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
++ ScVbaCommandBarButton( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xSettings, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, sal_Int32 nPosition, sal_Bool bTemporary, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw (css::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException)
+ {
+diff --git vbahelper/source/vbahelper/vbacommandbarcontrols.cxx vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
+index ea56a09..488b56a 100644
+--- vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
++++ vbahelper/source/vbahelper/vbacommandbarcontrols.cxx
+@@ -63,7 +63,7 @@ public:
+ }
+ };
+
+-ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess>& xIndexAccess, VbaCommandBarHelperRef pHelper, const uno::Reference< container::XIndexAccess>& xBarSettings, const rtl::OUString& sResourceUrl ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl )
++ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess>& xIndexAccess, VbaCommandBarHelperRef pHelper, const uno::Reference< container::XIndexAccess>& xBarSettings, const rtl::OUString& sResourceUrl, const uno::Reference< awt::XMenu >& xMenu ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext, xIndexAccess ), pCBarHelper( pHelper ), m_xBarSettings( xBarSettings ), m_sResourceUrl( sResourceUrl ), m_xMenu( xMenu )
+ {
+ m_bIsMenu = sResourceUrl.equalsAscii( ITEM_MENUBAR_URL ) ? sal_True : sal_False;
+ }
+@@ -132,9 +132,9 @@ ScVbaCommandBarControls::createCollectionObject( const uno::Any& aSource )
+ getPropertyValue( aProps, rtl::OUString::createFromAscii( ITEM_DESCRIPTOR_CONTAINER ) ) >>= xSubMenu;
+ ScVbaCommandBarControl* pNewCommandBarControl = NULL;
+ if( xSubMenu.is() )
+- pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True );
++ pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True, m_xMenu );
+ else
+- pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True );
++ pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, sal_True, m_xMenu );
+
+ return uno::makeAny( uno::Reference< XCommandBarControl > ( pNewCommandBarControl ) );
+ }
+@@ -227,11 +227,12 @@ ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const un
+ if( !bTemporary )
+ pCBarHelper->persistChanges();
+
++ // sometimes it would crash if passing m_xMenu instead of uno::Reference< awt::XMenu >() in Linux.
+ ScVbaCommandBarControl* pNewCommandBarControl = NULL;
+ if( nType == office::MsoControlType::msoControlPopup )
+- pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary );
++ pNewCommandBarControl = new ScVbaCommandBarPopup( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary, uno::Reference< awt::XMenu >() );
+ else
+- pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary );
++ pNewCommandBarControl = new ScVbaCommandBarButton( this, mxContext, m_xIndexAccess, pCBarHelper, m_xBarSettings, m_sResourceUrl, nPosition, bTemporary, uno::Reference< awt::XMenu >() );
+
+ return uno::Reference< XCommandBarControl >( pNewCommandBarControl );
+ }
+diff --git vbahelper/source/vbahelper/vbacommandbarcontrols.hxx vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
+index fa37f10..ce89794 100644
+--- vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
++++ vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
+@@ -36,6 +36,7 @@
+ #define SC_VBA_COMMANDBARCONTROLS_HXX
+
+ #include <ooo/vba/XCommandBarControls.hpp>
++#include <com/sun/star/awt/XMenu.hpp>
+ #include <vbahelper/vbahelperinterface.hxx>
+ #include <vbahelper/vbacollectionimpl.hxx>
+ #include "vbacommandbarhelper.hxx"
+@@ -48,13 +49,14 @@ private:
+ VbaCommandBarHelperRef pCBarHelper;
+ css::uno::Reference< css::container::XIndexAccess > m_xBarSettings;
+ rtl::OUString m_sResourceUrl;
++ css::uno::Reference< css::awt::XMenu > m_xMenu;
+ sal_Bool m_bIsMenu;
+
+ css::uno::Sequence< css::beans::PropertyValue > CreateMenuItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const css::uno::Any& aSubMenu );
+ css::uno::Sequence< css::beans::PropertyValue > CreateToolbarItemData( const rtl::OUString& sCommandURL, const rtl::OUString& sHelpURL, const rtl::OUString& sLabel, sal_uInt16 nType, const css::uno::Any& aSubMenu, sal_Bool isVisible, sal_Int32 nStyle );
+
+ public:
+- ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl ) throw( css::uno::RuntimeException );
++ ScVbaCommandBarControls( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess, VbaCommandBarHelperRef pHelper, const css::uno::Reference< css::container::XIndexAccess >& xBarSettings, const rtl::OUString& sResourceUrl, const css::uno::Reference< css::awt::XMenu >& xMenu ) throw( css::uno::RuntimeException );
+ sal_Bool IsMenu(){ return m_bIsMenu; }
+
+ // XEnumerationAccess
+diff --git vbahelper/source/vbahelper/vbacommandbarhelper.cxx vbahelper/source/vbahelper/vbacommandbarhelper.cxx
+index b4515b6..034e506 100644
+--- vbahelper/source/vbahelper/vbacommandbarhelper.cxx
++++ vbahelper/source/vbahelper/vbacommandbarhelper.cxx
+@@ -155,6 +155,14 @@ sal_Bool VbaCommandBarHelper::persistChanges() throw (css::uno::RuntimeException
+ return result;
+ }
+
++uno::Reference< frame::XLayoutManager > VbaCommandBarHelper::getLayoutManager() throw (uno::RuntimeException)
++{
++ uno::Reference< frame::XFrame > xFrame( getModel()->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
++ uno::Reference< beans::XPropertySet > xPropertySet( xFrame, uno::UNO_QUERY_THROW );
++ uno::Reference< frame::XLayoutManager > xLayoutManager( xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("LayoutManager") ), uno::UNO_QUERY_THROW );
++ return xLayoutManager;
++}
++
+ rtl::OUString VbaCommandBarHelper::getMenuBarUrl()
+ {
+ static const rtl::OUString sMenuBarUrl( RTL_CONSTASCII_USTRINGPARAM( ITEM_MENUBAR_URL ) );
+diff --git vbahelper/source/vbahelper/vbacommandbarhelper.hxx vbahelper/source/vbahelper/vbacommandbarhelper.hxx
+index a6304bc..64a808d 100644
+--- vbahelper/source/vbahelper/vbacommandbarhelper.hxx
++++ vbahelper/source/vbahelper/vbacommandbarhelper.hxx
+@@ -42,6 +42,7 @@
+ #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+ #include <com/sun/star/container/XIndexAccess.hpp>
+ #include <com/sun/star/container/XNameAccess.hpp>
++#include <com/sun/star/frame/XLayoutManager.hpp>
+ #include <boost/shared_ptr.hpp>
+
+
+@@ -95,6 +96,8 @@ public:
+ }
+ sal_Bool persistChanges() throw (css::uno::RuntimeException);
+
++ css::uno::Reference< css::frame::XLayoutManager > getLayoutManager() throw (css::uno::RuntimeException);
++
+ const rtl::OUString getModuleId(){ return maModuleId; }
+ static rtl::OUString getMenuBarUrl();
+ rtl::OUString findToolbarByName( const css::uno::Reference< css::container::XNameAccess >& xNameAccess, const rtl::OUString& sName ) throw (css::uno::RuntimeException);
More information about the ooo-build-commit
mailing list