ooo-build r11489 - in trunk: . patches/src680 patches/vba



Author: jiaojh
Date: Sat Feb  2 01:57:20 2008
New Revision: 11489
URL: http://svn.gnome.org/viewvc/ooo-build?rev=11489&view=rev

Log:
    * patches/src680/vba/vba-commandbar-bundle.diff
    * patches/src680/apply: Missing APIs for CommandBar
    and CommandBarControl.


Added:
   trunk/patches/vba/vba-commandbar-bundle.diff
Modified:
   trunk/ChangeLog
   trunk/patches/src680/apply

Modified: trunk/patches/src680/apply
==============================================================================
--- trunk/patches/src680/apply	(original)
+++ trunk/patches/src680/apply	Sat Feb  2 01:57:20 2008
@@ -1461,6 +1461,9 @@
 n353254-dateserial.diff, n#353254, Fong
 # fix for n#353260
 n353260-datevalue.diff, n#353260, Fong
+# fix for n#353242. missing APIs
+# a set of CommandBar APIs.
+vba-commandbar-bundle.diff, n#353242, Jianhua
 
 
 # Is function only valid for objects

Added: trunk/patches/vba/vba-commandbar-bundle.diff
==============================================================================
--- (empty file)
+++ trunk/patches/vba/vba-commandbar-bundle.diff	Sat Feb  2 01:57:20 2008
@@ -0,0 +1,1773 @@
+--- oovbaapi/org/openoffice/vba/makefile.mk.orig	2008-01-21 14:43:02.000000000 +0800
++++ oovbaapi/org/openoffice/vba/makefile.mk	2008-01-21 14:52:35.000000000 +0800
+@@ -52,6 +52,10 @@ IDLFILES=\
+ 	XPropValue.idl\
+ 	XHelperInterface.idl\
+ 	XAssistant.idl\
++	XCommandBarControl.idl\
++	XCommandBarControls.idl\
++	XCommandBar.idl\
++	XCommandBars.idl\
+ 	Globals.idl\
+ 
+ # ------------------------------------------------------------------
+--- /dev/null	2007-05-04 18:54:36.000000000 +0800
++++ oovbaapi/org/openoffice/vba/XCommandBarControl.idl	2008-01-21 14:49:10.000000000 +0800
+@@ -0,0 +1,65 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef __org_openoffice_vba_XCommandBarControl_idl__
++#define __org_openoffice_vba_XCommandBarControl_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __org_openoffice_vba_XHelperInterface_idl__
++#include <org/openoffice/vba/XHelperInterface.idl>
++#endif
++//=============================================================================
++
++module org {  module openoffice {  module vba { 
++//=============================================================================
++interface XCommandBarControls;
++
++interface XCommandBarControl
++{
++	interface XHelperInterface;
++
++    [attribute] string Caption;
++    [attribute] string OnAction;
++    [attribute] boolean Visible;
++    
++    void Delete() raises ( com::sun::star::script::BasicErrorException );
++    XCommandBarControls Controls() raises ( com::sun::star::script::BasicErrorException );
++};
++
++}; }; };
++
++#endif
+--- /dev/null	2007-05-04 18:54:36.000000000 +0800
++++ oovbaapi/org/openoffice/vba/XCommandBarControls.idl	2008-01-25 14:02:36.000000000 +0800
+@@ -0,0 +1,63 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef __org_openoffice_vba_XCommandBarControls_idl__
++#define __org_openoffice_vba_XCommandBarControls_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __org_openoffice_vba_XHelperInterface_idl__
++#include <org/openoffice/vba/XHelperInterface.idl>
++#endif
++//=============================================================================
++
++module org {  module openoffice {  module vba { 
++//=============================================================================
++interface XCommandBarControl;
++
++interface XCommandBarControls
++{
++	interface XHelperInterface;
++
++    [attribute, readonly] long Count;
++    XCommandBarControl Item( [in] any Index );
++
++    XCommandBarControl Add( [in] any Type, [in] any Id, [in] any Parameter, [in] any Before, [in] any Temporary ) raises ( com::sun::star::script::BasicErrorException );
++};
++
++}; }; };
++
++#endif
+--- /dev/null	2007-05-04 18:54:36.000000000 +0800
++++ oovbaapi/org/openoffice/vba/XCommandBar.idl	2008-01-21 14:49:16.000000000 +0800
+@@ -0,0 +1,64 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef __org_openoffice_vba_XCommandBar_idl__
++#define __org_openoffice_vba_XCommandBar_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __org_openoffice_vba_XHelperInterface_idl__
++#include <org/openoffice/vba/XHelperInterface.idl>
++#endif
++//=============================================================================
++
++module org {  module openoffice {  module vba { 
++//=============================================================================
++interface XCommandBarControls;
++
++interface XCommandBar
++{
++	interface XHelperInterface;
++
++    [attribute] string Name;
++    [attribute] boolean Visible;
++    
++    void Delete() raises ( com::sun::star::script::BasicErrorException );
++    XCommandBarControls Controls() raises ( com::sun::star::script::BasicErrorException );
++};
++
++}; }; };
++
++#endif
+--- /dev/null	2007-05-04 18:54:36.000000000 +0800
++++ oovbaapi/org/openoffice/vba/XCommandBars.idl	2008-01-25 14:02:58.000000000 +0800
+@@ -0,0 +1,63 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile$
++ *
++ *  $Revision$
++ *
++ *  last change: $Author$ $Date$
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef __org_openoffice_vba_XCommandBars_idl__
++#define __org_openoffice_vba_XCommandBars_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++#ifndef __org_openoffice_vba_XHelperInterface_idl__
++#include <org/openoffice/vba/XHelperInterface.idl>
++#endif
++
++//=============================================================================
++
++module org {  module openoffice {  module vba { 
++//=============================================================================
++interface XCommandBar;
++
++interface XCommandBars
++{
++    interface XHelperInterface;
++
++	[attribute, readonly] long Count;
++	XCommandBar Item( [in] any Index );
++    XCommandBar Add( [in] any Name, [in] any Position,  [in] any MenuBar, [in] any Temporary ) raises ( com::sun::star::script::BasicErrorException );
++};
++
++}; }; };
++
++#endif
+--- oovbaapi/org/openoffice/excel/XApplication.idl.orig	2008-01-21 17:34:01.000000000 +0800
++++ oovbaapi/org/openoffice/excel/XApplication.idl	2008-01-24 14:32:11.000000000 +0800
+@@ -47,6 +47,10 @@
+ #include <org/openoffice/vba/XAssistant.idl>
+ #endif
+ 
++#ifndef __org_openoffice_vba_XCommandBars_idl__
++#include <org/openoffice/vba/XCommandBars.idl>
++#endif
++
+ module org {  module openoffice {  module excel { 
+ 
+ interface XRange;
+@@ -91,6 +95,7 @@ interface XApplication
+ 	string LibraryPath() raises(com::sun::star::script::BasicErrorException);
+ 	string TemplatesPath() raises(com::sun::star::script::BasicErrorException);
+ 	string PathSeparator() raises(com::sun::star::script::BasicErrorException);
++    any CommandBars( [in] any aIndex );
+ 	any Workbooks( [in] any aIndex );
+ 	any Worksheets( [in] any aIndex );
+ 	any Windows( [in] any aIndex );
+--- sc/source/ui/vba/makefile.mk.orig	2008-01-21 14:42:17.000000000 +0800
++++ sc/source/ui/vba/makefile.mk	2008-01-21 16:25:24.000000000 +0800
+@@ -116,6 +116,10 @@ SLOFILES= \
+                 $(SLO)$/vbastyle.obj \
+                 $(SLO)$/vbastyles.obj \
+                 $(SLO)$/vbaassistant.obj \
++                $(SLO)$/vbacommandbarcontrol.obj \
++                $(SLO)$/vbacommandbarcontrols.obj \
++                $(SLO)$/vbacommandbar.obj \
++                $(SLO)$/vbacommandbars.obj \
+ 		$(SLO)$/service.obj \
+  
+ 
+--- /dev/null	2007-05-04 18:54:36.000000000 +0800
++++ sc/source/ui/vba/vbacommandbarcontrol.hxx	2008-01-28 15:40:00.000000000 +0800
+@@ -0,0 +1,90 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: vbacommandbarcontrol.hxx,v $
++ *
++ *  $Revision: 1.2 $
++ *
++ *  last change: $Author: vg $ $Date: 2007/12/07 11:02:09 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef SC_VBA_COMMANDBARCONTROL_HXX
++#define SC_VBA_COMMANDBARCONTROL_HXX
++
++#include <org/openoffice/vba/XCommandBarControl.hpp>
++
++#include "vbahelperinterface.hxx"
++#include "vbacommandbarcontrols.hxx"
++
++typedef InheritedHelperInterfaceImpl1< oo::vba::XCommandBarControl > CommandBarControl_BASE;
++
++class ScVbaCommandBarControl : public CommandBarControl_BASE
++{
++private:
++    rtl::OUString       m_sName;
++    rtl::OUString       m_sBarName;
++    rtl::OUString       m_sCommand;
++    sal_Int32           m_nType;
++    sal_Int32           m_nPosition;
++    sal_Bool            m_bTemporary;
++    sal_Bool            m_bIsMenu;
++    ScVbaCommandBarControls*        m_pCommandBarControls;
++    css::uno::Reference< oo::vba::XHelperInterface >               m_xParentHardRef;
++    css::uno::Reference< css::ui::XUIConfigurationManager >         m_xUICfgManager;
++    css::uno::Reference< css::ui::XUIConfigurationPersistence >     m_xUICfgPers;
++    css::uno::Reference< css::container::XIndexContainer >          m_xBarSettings;
++    css::uno::Reference< css::container::XIndexContainer >          m_xCurrentSettings;
++    css::beans::PropertyValues                                      m_aPropertyValues;
++    
++    void initObjects() throw (css::uno::RuntimeException);
++    void createNewMenuBarControl();
++    void createNewToolBarControl();
++public:
++    ScVbaCommandBarControl( const css::uno::Reference< oo::vba::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName ) throw (css::uno::RuntimeException);
++    ScVbaCommandBarControl( const css::uno::Reference< oo::vba::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sName, rtl::OUString sCommand, sal_Int32 nPosition, sal_Bool bTemporary ) throw (css::uno::RuntimeException);
++    sal_Int32 GetPosition() { return m_nPosition; };
++    css::uno::Reference< css::container::XIndexContainer > GetCurrentSettings() { return m_xCurrentSettings; };
++    css::beans::PropertyValues GetPropertyValues() { return m_aPropertyValues; };
++    void SetPropertyValues( css::beans::PropertyValues aPropertyValues ) { m_aPropertyValues = aPropertyValues; };
++    
++    // Attributes
++    virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setCaption( const ::rtl::OUString& _caption ) throw (css::uno::RuntimeException);
++    virtual ::rtl::OUString SAL_CALL getOnAction() throw (css::uno::RuntimeException);
++    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);
++
++    // Methods
++    virtual void SAL_CALL Delete(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++    virtual ::com::sun::star::uno::Reference< oo::vba::XCommandBarControls > SAL_CALL Controls(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif//SC_VBA_COMMANDBARCONTROL_HXX
+--- /dev/null	2007-05-04 18:54:36.000000000 +0800
++++ sc/source/ui/vba/vbacommandbarcontrol.cxx	2008-01-28 17:12:23.000000000 +0800
+@@ -0,0 +1,391 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: vbacommandbarcontrol.cxx,v $
++ *
++ *  $Revision: 1.2 $
++ *
++ *  last change: $Author: vg $ $Date: 2007/12/07 11:02:09 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#include "vbacommandbarcontrol.hxx"
++
++using namespace com::sun::star;
++using namespace org::openoffice;
++
++uno::Any lcl_getPropertyValue( beans::PropertyValues aPropertyValues, rtl::OUString sPropertyName )
++{
++    sal_Int32 nCount = aPropertyValues.getLength();
++    for( sal_Int32 i = 0; i < nCount; i++ )
++    {
++        if( aPropertyValues[i].Name.equalsIgnoreAsciiCase( sPropertyName ) )
++        {
++            return aPropertyValues[i].Value;
++        }
++    }
++    return uno::Any();
++}
++
++beans::PropertyValues lcl_repalcePropertyValue( beans::PropertyValues aPropertyValues, rtl::OUString sPropertyName, uno::Any aValue )
++{
++    sal_Int32 nCount = aPropertyValues.getLength();
++    for( sal_Int32 i = 0; i < nCount; i++ )
++    {
++        if( aPropertyValues[i].Name.equalsIgnoreAsciiCase( sPropertyName ) )
++        {
++            aPropertyValues[i].Value = aValue;
++            return aPropertyValues;
++        }
++    }
++    return aPropertyValues;
++}
++
++ScVbaCommandBarControl::ScVbaCommandBarControl( const uno::Reference< vba::XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName ) throw (uno::RuntimeException) : CommandBarControl_BASE( xParent, xContext ), m_sName( sName )
++{
++    // exsiting CommandBarBarControl
++    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
++    initObjects();
++    if( m_xBarSettings->hasElements() )
++    {
++        ScVbaCommandBarControl* pParentCommandBarControl = m_pCommandBarControls->GetParentCommandBarControl();
++        if( pParentCommandBarControl )
++        {
++            beans::PropertyValues aPropertyValues;
++            pParentCommandBarControl->GetCurrentSettings()->getByIndex( pParentCommandBarControl->GetPosition() ) >>= aPropertyValues;
++            pParentCommandBarControl->SetPropertyValues( aPropertyValues );
++            m_xCurrentSettings.set( lcl_getPropertyValue( pParentCommandBarControl->GetPropertyValues(), rtl::OUString::createFromAscii( "ItemDescriptorContainer" ) ), uno::UNO_QUERY_THROW );
++        }
++        if( !m_xCurrentSettings.is() )
++        {
++            m_xCurrentSettings.set( m_xUICfgManager->getSettings( m_pCommandBarControls->GetParentToolBarName(), sal_True ), uno::UNO_QUERY_THROW );
++        }
++        for( sal_Int32 i = 0; i < m_xCurrentSettings->getCount(); i++ )
++        {
++            beans::PropertyValues aPropertyValuesTemp;
++            m_xCurrentSettings->getByIndex( i ) >>= aPropertyValuesTemp;
++            // Label always empty in OOo
++            rtl::OUString sLabel;
++            lcl_getPropertyValue( aPropertyValuesTemp, rtl::OUString::createFromAscii( "Label" ) ) >>= sLabel;
++            if( sLabel.equalsIgnoreAsciiCase( sName ) )
++            {
++                m_nPosition = i;
++                break;
++            }
++            // using CammandURL to find
++            rtl::OUString sCommandURL;
++            lcl_getPropertyValue( aPropertyValuesTemp, rtl::OUString::createFromAscii( "CommandURL" ) ) >>= sCommandURL;
++            sal_Int32 nLastIndex = sCommandURL.lastIndexOf( rtl::OUString::createFromAscii(":") );
++            if( ( nLastIndex != -1 ) && ( ( nLastIndex + 1 ) < sCommandURL.getLength() ) )
++            {
++                sCommandURL = sCommandURL.copy( nLastIndex + 1 );
++            }
++            if( sCommandURL.equalsIgnoreAsciiCase( sName ) )
++            {
++                m_nPosition = i;
++                break;
++            }
++        }
++        if( m_nPosition  == -1 )
++            throw uno::RuntimeException( rtl::OUString::createFromAscii("The CommandBarControl do not exist"), uno::Reference< uno::XInterface >() );
++    }
++    if( m_bIsMenu )
++    {
++        m_sBarName = rtl::OUString::createFromAscii("private:resource/menubar/menubar");
++    }
++    else
++    {
++        m_sBarName = m_pCommandBarControls->GetParentToolBarName();
++    }
++    m_bTemporary = sal_True;
++}
++ScVbaCommandBarControl::ScVbaCommandBarControl( const uno::Reference< vba::XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sName, rtl::OUString sCommand, sal_Int32 nPosition, sal_Bool bTemporary ) throw (uno::RuntimeException) :  CommandBarControl_BASE( xParent, xContext ), m_nPosition( nPosition ), m_bTemporary( bTemporary )
++{
++    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
++    initObjects();
++    if( sName.getLength() > 0 )
++    {
++        m_sName = sName;
++    }
++    if( sCommand.getLength() > 0 )
++    {
++        m_sCommand = sCommand;
++    }
++    else
++    {
++        m_sCommand = rtl::OUString::createFromAscii("vnd.openoffice.org:") + sName;
++    }
++    if( m_bIsMenu )
++    {
++        m_sBarName = rtl::OUString::createFromAscii("private:resource/menubar/menubar");
++        createNewMenuBarControl();
++    }
++    else
++    {
++        m_sBarName = m_pCommandBarControls->GetParentToolBarName();
++        createNewToolBarControl();
++    }
++}
++
++void
++ScVbaCommandBarControl::initObjects() throw (uno::RuntimeException)
++{
++    m_pCommandBarControls = dynamic_cast< ScVbaCommandBarControls* >( m_xParentHardRef.get() );
++    if( !m_pCommandBarControls )
++        throw uno::RuntimeException( rtl::OUString::createFromAscii( "Parent needs to be a ScVbaCommandBarControls"), uno::Reference< uno::XInterface >() );
++    m_xUICfgManager.set( m_pCommandBarControls->GetUICfgManager(), uno::UNO_QUERY_THROW );
++    m_xUICfgPers.set( m_pCommandBarControls->GetUICfgPers(), uno::UNO_QUERY_THROW );
++    m_xBarSettings.set( m_pCommandBarControls->GetBarSettings(), uno::UNO_QUERY_THROW );
++    m_bIsMenu = m_pCommandBarControls->IsMenu();
++    m_sName = rtl::OUString::createFromAscii( "Custom" );
++    m_nPosition = -1;
++}
++
++void
++ScVbaCommandBarControl::createNewMenuBarControl()
++{
++    uno::Sequence< beans::PropertyValue > aPropertys(4);
++    aPropertys[0].Name = rtl::OUString::createFromAscii("CommandURL");
++    aPropertys[0].Value <<= m_sCommand; 
++    aPropertys[1].Name = rtl::OUString::createFromAscii("Label");
++    aPropertys[1].Value <<= m_sName; 
++    aPropertys[2].Name = rtl::OUString::createFromAscii("Type");
++    aPropertys[2].Value <<= m_nType; 
++    aPropertys[3].Name = rtl::OUString::createFromAscii("ItemDescriptorContainer");
++
++    m_xBarSettings->insertByIndex( m_nPosition, uno::makeAny( aPropertys ) );
++    uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
++    rtl::OUString sUIName;
++    xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("UIName") ) >>= sUIName;
++
++    uno::Reference< lang::XSingleComponentFactory > xMenuMSF( m_xBarSettings, uno::UNO_QUERY_THROW );
++    if( m_pCommandBarControls->GetParentCommandBar() != NULL )
++    {
++        // create a new menu
++        m_xBarSettings->insertByIndex( m_nPosition, uno::makeAny( aPropertys ) );
++        m_xCurrentSettings.set( m_xBarSettings, uno::UNO_QUERY_THROW );
++    }
++    else if( m_pCommandBarControls->GetParentCommandBarControl() != NULL )
++    {
++        // create a new menu entry
++        // change the parent MenuItem to a PopupMenu
++        ScVbaCommandBarControl* pPc = m_pCommandBarControls->GetParentCommandBarControl();
++        beans::PropertyValues aPropertyValues;
++        pPc->GetCurrentSettings()->getByIndex( pPc->GetPosition() ) >>= aPropertyValues;
++        pPc->SetPropertyValues( aPropertyValues );
++        
++        // has the property already been set?
++        if( lcl_getPropertyValue( pPc->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") ).hasValue() )
++        {
++            lcl_repalcePropertyValue(  pPc->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer"), uno::makeAny( xMenuMSF->createInstanceWithContext( mxContext ) ) );
++            pPc->GetCurrentSettings()->replaceByIndex( pPc->GetPosition(), uno::makeAny( pPc->GetPropertyValues() ) );
++        }
++        m_xCurrentSettings.set( lcl_getPropertyValue( pPc->GetPropertyValues(), rtl::OUString::createFromAscii("ItemDescriptorContainer") ), uno::UNO_QUERY_THROW );
++        m_xCurrentSettings->insertByIndex( m_nPosition, uno::makeAny( m_aPropertyValues ) );
++    }
++    if( m_xUICfgManager->hasSettings( m_sBarName ) )
++    {
++        m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++    }
++    else
++    {
++        m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++    }
++    if( !m_bTemporary )
++    {
++        m_xUICfgPers->store();
++    }
++}
++
++void
++ScVbaCommandBarControl::createNewToolBarControl()
++{
++    uno::Sequence< beans::PropertyValue > aPropertys(4);
++    aPropertys[0].Name = rtl::OUString::createFromAscii("CommandURL");
++    aPropertys[0].Value <<= m_sCommand; 
++    aPropertys[1].Name = rtl::OUString::createFromAscii("Label");
++    aPropertys[1].Value <<= m_sName; 
++    aPropertys[2].Name = rtl::OUString::createFromAscii("Type");
++    aPropertys[2].Value <<= m_nType; 
++    aPropertys[3].Name = rtl::OUString::createFromAscii("IsVisible");
++    aPropertys[3].Value <<= sal_True; 
++
++    m_xBarSettings->insertByIndex( m_nPosition, uno::makeAny( aPropertys ) );
++    uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
++    rtl::OUString sUIName;
++    xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("UIName") ) >>= sUIName;
++
++    m_xCurrentSettings.set( m_xBarSettings, uno::UNO_QUERY_THROW );
++    if( m_xUICfgManager->hasSettings( m_sBarName ) )
++    {
++        m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++    }
++    else
++    {
++        m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++    }
++    if( !m_bTemporary )
++    {
++        m_xUICfgPers->store();
++    }
++}
++
++::rtl::OUString SAL_CALL
++ScVbaCommandBarControl::getCaption() throw ( uno::RuntimeException )
++{
++    // "Label" always empty
++    rtl::OUString sCaption;
++    beans::PropertyValues aPropertyValues;
++    if( m_xCurrentSettings.is() )
++    {
++        m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
++        lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii("Label") ) >>= sCaption;
++    }
++    else if( m_xBarSettings.is() )
++    {
++        m_xBarSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
++        lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii("Label") ) >>= sCaption;
++    }
++    return sCaption;
++}
++void SAL_CALL 
++ScVbaCommandBarControl::setCaption( const ::rtl::OUString& _caption ) throw (uno::RuntimeException)
++{
++    if( m_xCurrentSettings.is() )
++    {
++        beans::PropertyValues aPropertyValues;
++        m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
++        beans::PropertyValues aNewPropertyValues;
++        aNewPropertyValues = lcl_repalcePropertyValue( aPropertyValues, rtl::OUString::createFromAscii("Label"), uno::makeAny( _caption ) );
++        m_xCurrentSettings->replaceByIndex( m_nPosition, uno::makeAny( aNewPropertyValues ) );
++        if( m_xUICfgManager->hasSettings( m_sBarName ) )
++        {
++            m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++        }
++        else
++        {
++            m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++        }
++        // make it permanent
++        if( !m_bTemporary )
++        {
++            m_xUICfgPers->store();
++        }
++    }
++}
++::rtl::OUString SAL_CALL 
++ScVbaCommandBarControl::getOnAction() throw (uno::RuntimeException)
++{
++    if( m_xCurrentSettings.is() )
++    {
++        beans::PropertyValues aPropertyValues;
++        m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
++        rtl::OUString sCommandURL;
++        lcl_getPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( "CommandURL" ) ) >>= sCommandURL;
++        return sCommandURL;
++    }
++    return ::rtl::OUString();
++}
++void SAL_CALL 
++ScVbaCommandBarControl::setOnAction( const ::rtl::OUString& _onaction ) throw (uno::RuntimeException)
++{
++    if( m_xCurrentSettings.is() )
++    {
++        beans::PropertyValues aPropertyValues;
++        m_xCurrentSettings->getByIndex( m_nPosition ) >>= aPropertyValues;
++        beans::PropertyValues aNewPropertyValues;
++        aNewPropertyValues = lcl_repalcePropertyValue( aPropertyValues, rtl::OUString::createFromAscii("CommandURL"), uno::makeAny( _onaction ) );
++        m_xCurrentSettings->replaceByIndex( m_nPosition, uno::makeAny( aNewPropertyValues ) );
++        if( m_xUICfgManager->hasSettings( m_sBarName ) )
++        {
++            m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++        }
++        else
++        {
++            m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++        }
++        // make it permanent
++        if( !m_bTemporary )
++        {
++            m_xUICfgPers->store();
++        }
++    }
++}
++::sal_Bool SAL_CALL 
++ScVbaCommandBarControl::getVisible() throw (uno::RuntimeException)
++{
++    // not possible in UNO?
++    return sal_True;
++}
++void SAL_CALL 
++ScVbaCommandBarControl::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
++{
++    // "IsVisilbe"
++}
++void SAL_CALL 
++ScVbaCommandBarControl::Delete(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
++{
++    if( m_xCurrentSettings.is() )
++    {
++        m_xCurrentSettings->removeByIndex( m_nPosition );
++
++        if( m_xUICfgManager->hasSettings( m_sBarName ) )
++        {
++            m_xUICfgManager->replaceSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++        }
++        else
++        {
++            m_xUICfgManager->insertSettings( m_sBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++        }
++        // make it permanent
++        if( !m_bTemporary )
++        {
++            m_xUICfgPers->store();
++        }
++    }
++}
++uno::Reference< vba::XCommandBarControls > SAL_CALL 
++ScVbaCommandBarControl::Controls(  ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    return uno::Reference< vba::XCommandBarControls >( new ScVbaCommandBarControls( this, mxContext ) );
++}
++rtl::OUString& 
++ScVbaCommandBarControl::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBarControl") );
++	return sImplName;
++}
++uno::Sequence<rtl::OUString> 
++ScVbaCommandBarControl::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.vba.CommandBarControl" ) );
++	}
++	return aServiceNames;
++}
+--- /dev/null	2007-05-04 18:54:36.000000000 +0800
++++ sc/source/ui/vba/vbacommandbarcontrols.hxx	2008-01-28 16:33:52.000000000 +0800
+@@ -0,0 +1,84 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: vbacommandbarcontrols.hxx,v $
++ *
++ *  $Revision: 1.2 $
++ *
++ *  last change: $Author: vg $ $Date: 2007/12/07 11:02:56 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef SC_VBA_COMMANDBARCONTROLS_HXX
++#define SC_VBA_COMMANDBARCONTROLS_HXX
++
++#include <org/openoffice/vba/XCommandBarControls.hpp>
++
++#include "vbahelperinterface.hxx"
++#include "vbacommandbar.hxx"
++
++class ScVbaCommandBarControl;
++
++typedef InheritedHelperInterfaceImpl1< oo::vba::XCommandBarControls > CommandBarControls_BASE;
++
++class ScVbaCommandBarControls : public CommandBarControls_BASE
++{
++private:
++    sal_Bool                    m_bIsMenu;
++    sal_Bool                    m_bHasElements;
++    ScVbaCommandBar*            m_pCommandBar; 
++    ScVbaCommandBarControl*     m_pCommandBarControl; 
++    css::uno::Reference< oo::vba::XHelperInterface >               m_xParentHardRef;
++    css::uno::Reference< css::ui::XUIConfigurationManager >         m_xUICfgManager;
++    css::uno::Reference< css::ui::XUIConfigurationPersistence >     m_xUICfgPers;
++    css::uno::Reference< css::container::XIndexContainer >          m_xBarSettings;
++
++public:
++    ScVbaCommandBarControls( const css::uno::Reference< oo::vba::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext ) throw( css::uno::RuntimeException );
++    css::uno::Reference< css::ui::XUIConfigurationManager > GetUICfgManager() { return m_xUICfgManager; };
++    css::uno::Reference< css::ui::XUIConfigurationPersistence > GetUICfgPers() { return m_xUICfgPers; };
++    css::uno::Reference< css::container::XIndexContainer >  GetBarSettings() { return m_xBarSettings; };
++    sal_Bool IsMenu() { return m_bIsMenu; };
++    ScVbaCommandBar* GetParentCommandBar() { return m_pCommandBar; };
++    ScVbaCommandBarControl* GetParentCommandBarControl() { return m_pCommandBarControl; };
++    rtl::OUString GetParentToolBarName() 
++    { 
++        if( m_pCommandBar ) return m_pCommandBar->GetToolBarName();
++        else return rtl::OUString();
++    }
++
++    // Attributes
++    virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
++
++    // Methods     
++    virtual css::uno::Reference< oo::vba::XCommandBarControl > SAL_CALL Item( const css::uno::Any& Index ) throw (css::uno::RuntimeException); 
++    virtual css::uno::Reference< oo::vba::XCommandBarControl > SAL_CALL Add( const css::uno::Any& Type, const css::uno::Any& Id, const css::uno::Any& Parameter, const css::uno::Any& Before, const css::uno::Any& Temporary ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++    // XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++
++#endif//SC_VBA_COMMANDBARCONTROLS_HXX
+--- /dev/null	2007-05-04 18:54:36.000000000 +0800
++++ sc/source/ui/vba/vbacommandbarcontrols.cxx	2008-01-28 15:00:16.000000000 +0800
+@@ -0,0 +1,162 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: vbacommandbarcontrols.cxx,v $
++ *
++ *  $Revision: 1.2 $
++ *
++ *  last change: $Author: vg $ $Date: 2007/12/07 11:02:56 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#include "vbacommandbarcontrols.hxx"
++#include "vbacommandbarcontrol.hxx"
++
++using namespace com::sun::star;
++using namespace org::openoffice;
++
++ScVbaCommandBarControls::ScVbaCommandBarControls( const uno::Reference< vba::XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext ) throw (uno::RuntimeException) : CommandBarControls_BASE( xParent, xContext )
++{
++    m_bIsMenu = sal_False;
++    m_bHasElements = sal_False;
++    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
++    m_pCommandBar = dynamic_cast< ScVbaCommandBar* >( m_xParentHardRef.get() );
++    m_pCommandBarControl = dynamic_cast< ScVbaCommandBarControl* >( m_xParentHardRef.get() );
++    if( m_pCommandBar )
++    {
++        m_xUICfgManager.set( m_pCommandBar->GetUICfgManager(), uno::UNO_QUERY_THROW );
++        m_xUICfgPers.set( m_pCommandBar->GetUICfgPers(), uno::UNO_QUERY_THROW );
++        m_xBarSettings.set( m_pCommandBar->GetBarSettings(), uno::UNO_QUERY_THROW );
++        m_bIsMenu = m_pCommandBar->IsMenu();
++        if( m_xBarSettings->hasElements() )
++        {
++            m_bHasElements = sal_True;
++        }
++    }
++    else if( m_pCommandBarControl )
++    {
++    }
++    else
++    {
++        throw uno::RuntimeException( rtl::OUString::createFromAscii("Parent needs to be a ScVbaCommandBar or a ScVbaCommandBarControl"), uno::Reference< uno::XInterface >() );
++    }
++}
++
++// Attributes
++sal_Int32 SAL_CALL 
++ScVbaCommandBarControls::getCount() throw (uno::RuntimeException)
++{
++    sal_Int32 nCount = 0;
++    if( m_bHasElements )
++    {
++        sal_Int32 nBarSettingsCount = m_xBarSettings->getCount();
++        for( sal_Int32 i = 0; i < nBarSettingsCount; i++ )
++        {
++            beans::PropertyValues aMenuValues;
++            m_xBarSettings->getByIndex( i ) >>= aMenuValues;
++            for( sal_Int32 j = 0; j < aMenuValues.getLength(); j++ )
++            {
++                if( aMenuValues[j].Name.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii( "CommandURL" ) ) )
++                {
++                    nCount++;
++                }
++            }
++        } 
++    }
++    return nCount;
++}
++
++// Methods
++uno::Reference< vba::XCommandBarControl > SAL_CALL 
++ScVbaCommandBarControls::Item( const uno::Any& aIndex ) throw (uno::RuntimeException)
++{
++    rtl::OUString sName;
++    if( aIndex >>= sName )
++    {
++        return new ScVbaCommandBarControl( this, mxContext, sName );
++    }
++    sal_Int32 nIndex;
++    if( aIndex >>= nIndex )
++    {
++        // do nothing at this time
++    }
++    
++    return uno::Reference< vba::XCommandBarControl > ();
++}
++uno::Reference< vba::XCommandBarControl > SAL_CALL 
++ScVbaCommandBarControls::Add( const uno::Any& Type, const uno::Any& Id, const uno::Any& Parameter, const uno::Any& Before, const uno::Any& Temporary ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    // Parameter is not supported
++    // the following name needs to be individually created;
++    rtl::OUString sCaption( rtl::OUString::createFromAscii("custom Control") );
++    rtl::OUString sCommand( rtl::OUString::createFromAscii("macro:///Standard.Module1.Test()") );
++    sal_Int32 nType =0;
++    sal_Int32 nPosition = 0;
++    sal_Int32 nId;
++    sal_Bool bTemporary = sal_True;
++    
++    if( Type.hasValue() )
++        if( Type >>= nType )
++        {
++            // evalute the type of the new control
++        }
++    if( Id.hasValue() )
++        if( Id >>= nId )
++        {
++            // evalute the action of the new control
++        }
++    if( Before.hasValue() )
++        if( Before >>= nPosition )
++        {
++            // evalute the position of the new Control
++        }
++    if( Temporary.hasValue() )
++        if( Temporary >>= bTemporary )
++        {
++            // evalute the temporary of the new Control
++        }
++    return uno::Reference< vba::XCommandBarControl > ( new ScVbaCommandBarControl( this, mxContext, sCaption, sCommand, nPosition, bTemporary ) );
++}
++   
++// XHelperInterface
++rtl::OUString& 
++ScVbaCommandBarControls::getServiceImplName()
++{
++    static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBarControls") );
++    return sImplName;
++}
++uno::Sequence<rtl::OUString> 
++ScVbaCommandBarControls::getServiceNames()
++{
++    static uno::Sequence< rtl::OUString > aServiceNames;
++    if ( aServiceNames.getLength() == 0 )
++    {
++        aServiceNames.realloc( 1 );
++        aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.vba.CommandBarControls" ) );
++    }
++    return aServiceNames;
++}
++
+--- /dev/null	2007-05-04 18:54:36.000000000 +0800
++++ sc/source/ui/vba/vbacommandbar.hxx	2008-01-29 18:02:29.000000000 +0800
+@@ -0,0 +1,105 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: vbacommandbar.hxx,v $
++ *
++ *  $Revision: 1.2 $
++ *
++ *  last change: $Author: vg $ $Date: 2007/12/07 11:02:09 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef SC_VBA_COMMANDBAR_HXX
++#define SC_VBA_COMMANDBAR_HXX
++
++#include <org/openoffice/vba/XCommandBar.hpp>
++#include <com/sun/star/ui/XUIConfigurationManager.hpp>
++#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
++#include <com/sun/star/container/XIndexContainer.hpp>
++#include <com/sun/star/beans/PropertyValues.hpp>
++
++#include "vbahelperinterface.hxx"
++#include "vbacommandbars.hxx"
++
++#include <map>
++typedef std::map< const rtl::OUString, rtl::OUString > CommandBarNameMap;
++typedef std::pair< const rtl::OUString, rtl::OUString > CommandBarNamePair;
++const CommandBarNamePair namePair[] = { 
++    CommandBarNamePair(  rtl::OUString::createFromAscii("standard"), rtl::OUString::createFromAscii("standardbar") ),
++    CommandBarNamePair(  rtl::OUString::createFromAscii("formatting"), rtl::OUString::createFromAscii("formatobjectbar") ),
++};
++static const CommandBarNameMap mCommandBarNameMap( namePair, ( namePair + sizeof(namePair) / sizeof(namePair[0]) ) );
++
++
++typedef InheritedHelperInterfaceImpl1<  oo::vba::XCommandBar > CommandBar_BASE;
++
++class ScVbaCommandBar : public CommandBar_BASE
++{
++private:
++    rtl::OUString       m_sToolBarName;
++    rtl::OUString       m_sMenuModuleName;
++    rtl::OUString       m_sUIName;
++    sal_Bool            m_bTemporary;
++    sal_Bool            m_bIsMenu;
++    sal_Bool            m_bCustom;
++    sal_Bool            m_bCreate;
++    ScVbaCommandBars*   m_pScVbaCommandBars;
++    css::beans::PropertyValues  m_aToolBar;
++    // hard reference for parent
++    css::uno::Reference< oo::vba::XHelperInterface >               m_xParentHardRef;
++    css::uno::Reference< css::ui::XUIConfigurationManager >         m_xUICfgManager;
++    css::uno::Reference< css::ui::XUIConfigurationPersistence >     m_xUICfgPers;
++    css::uno::Reference< css::container::XIndexContainer >          m_xBarSettings;
++    void initCommandBar() throw( css::uno::RuntimeException );
++protected:
++    void getToolBarSettings( rtl::OUString sToolBarName ) throw( css::uno::RuntimeException );
++    void getMenuSettings();
++    void addCustomBar();
++public:
++    ScVbaCommandBar( const css::uno::Reference< oo::vba::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, sal_Int32 nModuleType ) throw( css::uno::RuntimeException );
++    ScVbaCommandBar( const css::uno::Reference< oo::vba::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, rtl::OUString sToolBarName, sal_Bool bTemporary, sal_Bool bCreate ) throw( css::uno::RuntimeException );
++    
++    sal_Bool IsMenu() { return m_bIsMenu; };
++    css::uno::Reference< css::ui::XUIConfigurationManager > GetUICfgManager() { return m_xUICfgManager; };
++    css::uno::Reference< css::ui::XUIConfigurationPersistence > GetUICfgPers() { return m_xUICfgPers; };
++    css::uno::Reference< css::container::XIndexContainer > GetBarSettings() { return m_xBarSettings; };
++    rtl::OUString GetToolBarName() { return m_sToolBarName; };
++
++    // Attributes
++    virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
++    virtual void SAL_CALL setName( const ::rtl::OUString& _name ) 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);
++
++    // Methods
++    virtual void SAL_CALL Delete(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++    virtual ::com::sun::star::uno::Reference< oo::vba::XCommandBarControls > SAL_CALL Controls(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++
++	// XHelperInterface
++	virtual rtl::OUString& getServiceImplName();
++	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++#endif//SC_VBA_COMMANDBAR_HXX
+--- /dev/null	2007-05-04 18:54:36.000000000 +0800
++++ sc/source/ui/vba/vbacommandbar.cxx	2008-01-30 10:42:36.000000000 +0800
+@@ -0,0 +1,317 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: vbacommandbar.cxx,v $
++ *
++ *  $Revision: 1.2 $
++ *
++ *  last change: $Author: vg $ $Date: 2007/12/07 11:02:09 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
++#include <com/sun/star/frame/XFrame.hpp>
++#include <com/sun/star/frame/XDesktop.hpp>
++#include <com/sun/star/frame/XLayoutManager.hpp>
++#include <com/sun/star/beans/XPropertySet.hpp>
++
++#include "vbacommandbar.hxx"
++#include "vbacommandbarcontrols.hxx"
++#include "vbahelper.hxx"
++
++
++using namespace com::sun::star;
++using namespace org::openoffice;
++
++ScVbaCommandBar::ScVbaCommandBar( const uno::Reference< vba::XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, sal_Int32 nModuleType ) throw (uno::RuntimeException) : CommandBar_BASE( xParent, xContext )
++{
++    // it's a menu bar
++    // only supporting factory menus ( no custom menus )
++    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
++    initCommandBar();
++    switch( nModuleType )
++    {
++        case 0:
++            m_sMenuModuleName = rtl::OUString::createFromAscii( "com.sun.star.sheet.SpreadsheetDocument" );
++            break;
++        case 1:
++            m_sMenuModuleName = rtl::OUString::createFromAscii( "com.sun.star.text.TextDocument" );
++            break;
++        default:
++            m_sMenuModuleName = rtl::OUString::createFromAscii( "com.sun.star.text.TextDocument" );
++    }
++    getMenuSettings();
++    m_bIsMenu = sal_True;
++    m_bCustom = sal_False;
++}
++ScVbaCommandBar::ScVbaCommandBar( const uno::Reference< vba::XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, rtl::OUString sToolBarName, sal_Bool bTemporary, sal_Bool bCreate ) throw (uno::RuntimeException) :  CommandBar_BASE( xParent, xContext )
++{
++    // it's a tool bar
++    m_xParentHardRef.set( xParent, uno::UNO_QUERY_THROW );
++    initCommandBar();
++    m_bTemporary = bTemporary;
++    m_bCreate = bCreate;
++    // get OOo ToolBarName
++    CommandBarNameMap::const_iterator iter = mCommandBarNameMap.find( sToolBarName.toAsciiLowerCase() );
++    if( iter != mCommandBarNameMap.end() )
++    {
++        m_sToolBarName = iter->second;
++    }
++    else
++    {
++        m_sToolBarName = sToolBarName;
++    }
++    m_sUIName = m_sToolBarName;
++    m_bIsMenu = sal_False;
++    getToolBarSettings( m_sToolBarName );
++}
++void
++ScVbaCommandBar::initCommandBar() throw (uno::RuntimeException)
++{
++    m_pScVbaCommandBars = dynamic_cast< ScVbaCommandBars* >( m_xParentHardRef.get() );
++    if ( !m_pScVbaCommandBars )
++        throw uno::RuntimeException( rtl::OUString::createFromAscii( "Parent needs to be a ScVbaCommandBars"), uno::Reference< uno::XInterface >() );
++    m_bIsMenu = sal_False;
++    m_bCustom = sal_False;
++    m_bTemporary = sal_True;
++    m_sToolBarName = rtl::OUString::createFromAscii("");
++    m_sUIName = rtl::OUString::createFromAscii("");
++    m_sMenuModuleName = rtl::OUString::createFromAscii( "com.sun.star.sheet.SpreadsheetDocument" );
++}
++void
++ScVbaCommandBar::getToolBarSettings( rtl::OUString sToolBarName ) throw( uno::RuntimeException )
++{
++    rtl::OUString sFactoryToolBar = rtl::OUString::createFromAscii("private:resource/toolbar/") + sToolBarName.toAsciiLowerCase();
++    rtl::OUString sCustomToolBar = rtl::OUString::createFromAscii("private:resource/toolbar/custom_toolbar_") + sToolBarName;
++    uno::Reference< lang::XMultiServiceFactory > xMSF( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
++    uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xUICfgManagerSup( xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier") ), uno::UNO_QUERY_THROW );
++    m_xUICfgManager.set( xUICfgManagerSup->getUIConfigurationManager( m_pScVbaCommandBars->GetModuleName() ), uno::UNO_QUERY_THROW );
++    m_xUICfgPers.set( m_xUICfgManager, uno::UNO_QUERY_THROW );
++    if( m_xUICfgManager->hasSettings( sFactoryToolBar ) )
++    {
++        // exsiting standard ToolBar
++        m_xBarSettings.set( m_xUICfgManager->getSettings( sFactoryToolBar, sal_True ), uno::UNO_QUERY_THROW );
++        m_sToolBarName = sFactoryToolBar;
++    }
++    else if( m_xUICfgManager->hasSettings( sCustomToolBar ) )
++    {
++        // exisiting custom ToolBar
++        m_xBarSettings.set( m_xUICfgManager->getSettings( sCustomToolBar, sal_True ), uno::UNO_QUERY_THROW );
++        m_sToolBarName = sCustomToolBar;
++        m_bCustom = sal_True;
++    }
++    else if( m_bCreate )
++    {
++        // new custom ToolBar
++        m_xBarSettings.set( m_xUICfgManager->createSettings(), uno::UNO_QUERY_THROW );
++        m_sToolBarName = sCustomToolBar;
++        m_bCustom = sal_True;
++        addCustomBar();
++    }
++    else
++        throw uno::RuntimeException( rtl::OUString::createFromAscii("ToolBar do not exist"), uno::Reference< uno::XInterface >() );
++    if( m_pScVbaCommandBars->GetWindows()->hasByName( m_sToolBarName ) )
++    {
++        uno::Any aToolBar = m_pScVbaCommandBars->GetWindows()->getByName( m_sToolBarName );
++        aToolBar >>= m_aToolBar; 
++    }
++}
++void
++ScVbaCommandBar::addCustomBar()
++{
++    uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
++    xPropertySet->setPropertyValue(rtl::OUString::createFromAscii("UIName"), uno::makeAny( m_sUIName ));
++
++    if( m_xUICfgManager->hasSettings(m_sToolBarName) )
++    {
++        m_xUICfgManager->replaceSettings( m_sToolBarName, uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++    }
++    else
++    {
++        m_xUICfgManager->insertSettings( m_sToolBarName,  uno::Reference< container::XIndexAccess > (m_xBarSettings, uno::UNO_QUERY_THROW ) );
++    }
++    if( !m_bTemporary )
++    {
++        m_xUICfgPers->store();
++    }
++}
++void 
++ScVbaCommandBar::getMenuSettings()
++{
++    try
++    {
++        rtl::OUString sMenuBar = rtl::OUString::createFromAscii( "private:resource/menubar/menubar" );
++        uno::Reference< lang::XMultiServiceFactory > xMSF( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
++        uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xUICfgManagerSup( xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier") ), uno::UNO_QUERY_THROW );
++        m_xUICfgManager.set( xUICfgManagerSup->getUIConfigurationManager( m_sMenuModuleName ), uno::UNO_QUERY_THROW );
++        m_xUICfgPers.set( m_xUICfgManager, uno::UNO_QUERY_THROW );
++        m_xBarSettings.set( m_xUICfgManager->getSettings( sMenuBar, sal_True ), uno::UNO_QUERY_THROW );
++    } 
++    catch ( uno::Exception e)
++    {
++        OSL_TRACE( "getMenuSetting got a error\n" );
++    }
++}
++::rtl::OUString SAL_CALL
++ScVbaCommandBar::getName() throw ( uno::RuntimeException )
++{
++    // This will get a "NULL length string" when Name is not set. 
++    uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
++    uno::Any aName = xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("UIName") );
++    rtl::OUString sName;
++    aName >>= sName;
++    if( sName.getLength() < 1 && !m_bIsMenu )
++    {
++        uno::Reference< container::XNameAccess > xNameAccess( m_pScVbaCommandBars->GetWindows(), uno::UNO_QUERY_THROW );
++        if( xNameAccess->hasByName( m_sToolBarName ) )
++        {
++            beans::PropertyValues aToolBar; 
++            xNameAccess->getByName( m_sToolBarName ) >>= aToolBar;
++            sal_Int32 nCount = aToolBar.getLength();
++            beans::PropertyValue aPropertyValue;
++            for( sal_Int32 i = 0; i < nCount; i++ )
++            {
++                aPropertyValue = aToolBar[i];
++                if( aPropertyValue.Name.equals( rtl::OUString::createFromAscii("UIName") ) )
++                {
++                    aPropertyValue.Value >>= sName;
++                    return sName;
++                }
++            }
++        }
++    }
++    return sName;
++}
++void SAL_CALL 
++ScVbaCommandBar::setName( const ::rtl::OUString& _name ) throw (uno::RuntimeException)
++{
++    uno::Reference< beans::XPropertySet > xPropertySet( m_xBarSettings, uno::UNO_QUERY_THROW );
++    xPropertySet->setPropertyValue( rtl::OUString::createFromAscii("UIName"), uno::makeAny( _name ) );
++    uno::Reference< container::XIndexAccess > xIndexAccess( m_xBarSettings, uno::UNO_QUERY_THROW );
++    
++    if( m_xUICfgManager->hasSettings( m_sToolBarName ) )
++    {
++        m_xUICfgManager->replaceSettings( m_sToolBarName, xIndexAccess );
++    }
++    else
++    {
++        // toolbar not found
++    }
++    if( !m_bTemporary )
++    {
++        m_xUICfgPers->store();
++    }
++}
++::sal_Bool SAL_CALL 
++ScVbaCommandBar::getVisible() throw (uno::RuntimeException)
++{
++    sal_Bool bVisible = sal_False;
++    try
++    {
++        sal_Int32 i = 0;
++        while( !m_aToolBar[i].Name.equals( rtl::OUString::createFromAscii( "Visible" ) ) )
++        {
++            i++;
++        }
++        m_aToolBar[i].Value >>= bVisible;
++    }
++    catch ( uno::Exception e )
++    {
++    }
++    return bVisible;
++}
++void SAL_CALL 
++ScVbaCommandBar::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
++{
++    try
++    {
++        uno::Reference< frame::XFrame > xFrame( getCurrentDocument()->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 );
++        if( _visible )
++        {
++            xLayoutManager->createElement( m_sToolBarName );
++            xLayoutManager->showElement( m_sToolBarName );
++        }
++        else
++        {
++            xLayoutManager->hideElement( m_sToolBarName );
++            xLayoutManager->destroyElement( m_sToolBarName );
++        }
++    }
++    catch( uno::Exception e )
++    {
++        OSL_TRACE( "SetVisible get an exception\n" );
++    }
++}
++void SAL_CALL 
++ScVbaCommandBar::Delete(  ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
++{
++    if( m_bCustom )
++    {
++        if( m_xUICfgManager->hasSettings( m_sToolBarName ) )
++        {
++            m_xUICfgManager->removeSettings(m_sToolBarName);
++            // make it permanent
++            if( !m_bTemporary )
++            {
++                m_xUICfgPers->store();
++            }
++        }
++        else
++        {
++            // toolbar not found
++            // TODO throw Error
++        }
++        uno::Reference< container::XNameContainer > xNameContainer( m_pScVbaCommandBars->GetWindows(), uno::UNO_QUERY_THROW );
++        if( xNameContainer->hasByName( m_sToolBarName ) )
++        {
++            xNameContainer->removeByName( m_sToolBarName );
++        }
++    }
++}
++uno::Reference< vba::XCommandBarControls > SAL_CALL 
++ScVbaCommandBar::Controls(  ) throw (script::BasicErrorException, uno::RuntimeException)
++{
++    return uno::Reference< vba::XCommandBarControls >( new ScVbaCommandBarControls( this, mxContext ) );
++}
++rtl::OUString& 
++ScVbaCommandBar::getServiceImplName()
++{
++	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBar") );
++	return sImplName;
++}
++uno::Sequence<rtl::OUString> 
++ScVbaCommandBar::getServiceNames()
++{
++	static uno::Sequence< rtl::OUString > aServiceNames;
++	if ( aServiceNames.getLength() == 0 )
++	{
++		aServiceNames.realloc( 1 );
++		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.vba.CommandBar" ) );
++	}
++	return aServiceNames;
++}
+--- /dev/null	2007-05-04 18:54:36.000000000 +0800
++++ sc/source/ui/vba/vbacommandbars.hxx	2008-01-30 10:45:13.000000000 +0800
+@@ -0,0 +1,72 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: vbacommandbars.hxx,v $
++ *
++ *  $Revision: 1.2 $
++ *
++ *  last change: $Author: vg $ $Date: 2007/12/07 11:02:56 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#ifndef SC_VBA_COMMANDBARS_HXX
++#define SC_VBA_COMMANDBARS_HXX
++
++#include <org/openoffice/vba/XCommandBars.hpp>
++#include <com/sun/star/container/XNameAccess.hpp>
++
++#include <cppuhelper/implbase1.hxx>
++
++#include "vbahelperinterface.hxx"
++
++typedef InheritedHelperInterfaceImpl1< oo::vba::XCommandBars > CommandBars_BASE;
++
++class ScVbaCommandBars : public CommandBars_BASE
++{
++private:
++    css::uno::Reference< css::container::XNameAccess > m_xNameAccess;
++    rtl::OUString m_sModuleName;
++    void retrieveObjects() throw( css::uno::RuntimeException );
++public:
++    ScVbaCommandBars( const css::uno::Reference< oo::vba::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext );
++
++    sal_Bool checkToolBarExist( rtl::OUString sToolBarName );
++    rtl::OUString GetModuleName(){ return m_sModuleName; };
++    css::uno::Reference< css::container::XNameAccess > GetWindows() 
++    { 
++        retrieveObjects();
++        return m_xNameAccess; 
++    };
++    // XCommandBars
++    virtual css::uno::Reference< oo::vba::XCommandBar > SAL_CALL Add( const css::uno::Any& Name, const css::uno::Any& Position, const css::uno::Any& MenuBar, const css::uno::Any& Temporary ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
++    virtual sal_Int32 SAL_CALL getCount() throw(css::uno::RuntimeException);
++    virtual css::uno::Reference< oo::vba::XCommandBar > SAL_CALL Item( const css::uno::Any& aIndex ) throw( css::uno::RuntimeException);
++    // XHelperInterface
++    virtual rtl::OUString& getServiceImplName();
++    virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++};
++
++#endif//SC_VBA_COMMANDBARS_HXX
+--- /dev/null	2007-05-04 18:54:36.000000000 +0800
++++ sc/source/ui/vba/vbacommandbars.cxx	2008-01-29 18:00:48.000000000 +0800
+@@ -0,0 +1,171 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: vbacommandbars.cxx,v $
++ *
++ *  $Revision: 1.2 $
++ *
++ *  last change: $Author: vg $ $Date: 2007/12/07 11:02:56 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2005 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++#include <com/sun/star/lang/XServiceInfo.hpp>
++#include <com/sun/star/frame/XDesktop.hpp>
++#include <com/sun/star/container/XNameAccess.hpp>
++
++#include "vbacommandbars.hxx"
++#include "vbacommandbar.hxx"
++
++using namespace com::sun::star;
++using namespace org::openoffice;
++
++static rtl::OUString sSpreadsheetDocumentUrl( rtl::OUString::createFromAscii( "com.sun.star.sheet.SpreadsheetDocument" ) );
++static rtl::OUString sTextDocumentUrl( rtl::OUString::createFromAscii( "com.sun.star.text.TextDocument" ) );
++static rtl::OUString sWindowStateConfUrl( rtl::OUString::createFromAscii( "com.sun.star.ui.WindowStateConfiguration" ) );
++
++ScVbaCommandBars::ScVbaCommandBars( const uno::Reference< vba::XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext ) : CommandBars_BASE( xParent, xContext )
++{
++    retrieveObjects();
++}
++void
++ScVbaCommandBars::retrieveObjects() throw ( uno::RuntimeException )
++{
++    uno::Reference< lang::XServiceInfo > xServiceInfo( getCurrentDocument(), uno::UNO_QUERY_THROW );
++    if( xServiceInfo->supportsService( sSpreadsheetDocumentUrl ) )
++    {
++        m_sModuleName = sSpreadsheetDocumentUrl;
++    }
++    else if( xServiceInfo->supportsService( sTextDocumentUrl ) )
++    {
++        m_sModuleName = sTextDocumentUrl;
++    }
++    else
++        throw uno::RuntimeException( rtl::OUString::createFromAscii( "Unsupported Document" ), uno::Reference< uno::XInterface >() );
++    
++    uno::Reference < lang::XMultiServiceFactory > xMSF( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
++    uno::Reference < container::XNameAccess > xNameAccess( xMSF->createInstance( sWindowStateConfUrl ), uno::UNO_QUERY_THROW );
++    m_xNameAccess.set( xNameAccess->getByName( m_sModuleName ), uno::UNO_QUERY_THROW );
++}
++
++// XCommandBars
++uno::Reference< vba::XCommandBar > SAL_CALL 
++ScVbaCommandBars::Add( const css::uno::Any& Name, const css::uno::Any& /*Position*/, const css::uno::Any& /*MenuBar*/, const css::uno::Any& Temporary ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
++{
++    // Position - MsoBar MenuBar - sal_Bool
++    // Currently only the Name is supported.
++    rtl::OUString sName;
++    if( !( Name >>= sName ) )
++    {
++        sName = rtl::OUString::createFromAscii("Custom1");
++    }
++    sal_Bool bTemporary;
++    if( !( Temporary >>= bTemporary ) )
++    {
++        bTemporary = sal_True;
++    }
++    return uno::Reference< vba::XCommandBar >( new ScVbaCommandBar( this, mxContext, sName.toAsciiLowerCase(), bTemporary, sal_True ) );
++}
++sal_Int32 SAL_CALL 
++ScVbaCommandBars::getCount() throw(css::uno::RuntimeException)
++{
++    // Filter out all toolbars from the window collection
++    sal_Int32 nCount = 0;
++    uno::Sequence< ::rtl::OUString > allNames = m_xNameAccess->getElementNames();
++    for( sal_Int32 i = 0; i < allNames.getLength(); i++ )
++    {
++        if(allNames[i].indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 )
++        {
++            nCount++;
++        }
++    }
++    return nCount;
++}
++
++// ScVbaCollectionBaseImpl
++uno::Reference< vba::XCommandBar > SAL_CALL
++ScVbaCommandBars::Item( const uno::Any& aSource ) throw( uno::RuntimeException )
++{
++    rtl::OUString sToolBarName;
++    if( aSource >>= sToolBarName )
++    {
++        sToolBarName = sToolBarName.toAsciiLowerCase();
++        if( sToolBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Worksheet Menu Bar") ) )
++        {
++            return uno::Reference< vba::XCommandBar > ( new ScVbaCommandBar( this, mxContext, 0 ) );
++        }
++        else if( sToolBarName.equalsIgnoreAsciiCase( rtl::OUString::createFromAscii("Menu Bar") ) )
++        {
++            return uno::Reference< vba::XCommandBar > ( new ScVbaCommandBar( this, mxContext, 1 ) );
++        }
++        else if( checkToolBarExist( sToolBarName ) )
++        {
++            return uno::Reference< vba::XCommandBar > (new ScVbaCommandBar( this, mxContext, sToolBarName, sal_True, sal_False ) );
++        }
++    }
++    return uno::Reference< vba::XCommandBar >();
++}
++
++sal_Bool
++ScVbaCommandBars::checkToolBarExist( rtl::OUString sToolBarName )
++{
++    CommandBarNameMap::const_iterator iter = mCommandBarNameMap.find( sToolBarName.toAsciiLowerCase() );
++    if( iter != mCommandBarNameMap.end() )
++    {
++        return sal_True;
++    }    
++    uno::Sequence< ::rtl::OUString > allNames = m_xNameAccess->getElementNames();
++    for( sal_Int32 i = 0; i < allNames.getLength(); i++ )
++    {
++        if(allNames[i].indexOf( rtl::OUString::createFromAscii("private:resource/toolbar/") ) != -1 )
++        {
++            if( allNames[i].indexOf( sToolBarName ) != -1 )
++            {
++                return sal_True;
++            }
++        }
++    }
++    return sal_False;
++}
++    
++// XHelperInterface
++rtl::OUString& 
++ScVbaCommandBars::getServiceImplName()
++{
++    static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCommandBars") );
++    return sImplName;
++}
++uno::Sequence<rtl::OUString> 
++ScVbaCommandBars::getServiceNames()
++{
++    static uno::Sequence< rtl::OUString > aServiceNames;
++    if ( aServiceNames.getLength() == 0 )
++    {
++        aServiceNames.realloc( 1 );
++        aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.vba.CommandBars" ) );
++    }
++    return aServiceNames;
++}
++
+--- sc/source/ui/vba/vbaapplication.hxx.orig	2008-01-21 17:48:09.000000000 +0800
++++ sc/source/ui/vba/vbaapplication.hxx	2008-01-24 14:33:26.000000000 +0800
+@@ -81,6 +81,7 @@ public:
+ 	virtual void SAL_CALL setDisplayFormulaBar( ::sal_Bool _displayformulabar ) throw ( css::uno::RuntimeException );
+ 
+     virtual css::uno::Reference< oo::vba::XAssistant > SAL_CALL getAssistant() throw (css::uno::RuntimeException);
++    virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ 	virtual css::uno::Reference< oo::excel::XWorkbook > SAL_CALL getThisWorkbook() throw (css::uno::RuntimeException);
+ 	virtual css::uno::Any SAL_CALL Workbooks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ 	virtual css::uno::Any SAL_CALL Worksheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+--- sc/source/ui/vba/vbaapplication.cxx.orig	2008-01-21 17:48:18.000000000 +0800
++++ sc/source/ui/vba/vbaapplication.cxx	2008-01-25 18:14:07.000000000 +0800
+@@ -63,6 +63,7 @@
+ #include "vbanames.hxx"
+ #include "vbashape.hxx"
+ #include "vbaassistant.hxx"
++#include "vbacommandbars.hxx"
+ #include "sc.hrc"
+ 
+ #include <osl/file.hxx>
+@@ -131,12 +132,21 @@ ScVbaApplication::getThisWorkbook() thro
+ }
+ 
+ uno::Reference< vba::XAssistant > SAL_CALL
+-ScVbaApplication::getAssistant() throw (css::uno::RuntimeException)
++ScVbaApplication::getAssistant() throw (uno::RuntimeException)
+ {
+     return uno::Reference< vba::XAssistant >( new ScVbaAssistant( this, mxContext ) );
+ }
+ 
+ uno::Any SAL_CALL
++ScVbaApplication::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
++{
++    uno::Reference< vba::XCommandBars > xCommandBars( new ScVbaCommandBars( this, mxContext ) );
++    if( aIndex.hasValue() )
++        return uno::makeAny( xCommandBars->Item( aIndex ) );
++    return uno::makeAny( xCommandBars );
++}
++
++uno::Any SAL_CALL
+ ScVbaApplication::getSelection() throw (uno::RuntimeException)
+ {
+     uno::Reference< lang::XServiceInfo > xServiceInfo( getCurrentDocument()->getCurrentSelection(), uno::UNO_QUERY_THROW );



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]