[ooo-build-commit] patches/dev300 patches/vba

Noel Power noelp at kemper.freedesktop.org
Wed Aug 19 07:08:47 PDT 2009


 patches/dev300/apply              |    9 
 patches/vba/ibm-misc-fixes-1.diff | 1367 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 1376 insertions(+)

New commits:
commit 77fe3b33d7ccdd47190f5a274e5ba8e8a2ee6923
Author: Noel Power <noel.power at novell.com>
Date:   Wed Aug 19 15:07:51 2009 +0100

    add new patches for #104203 i#103653 ( not applies yet, entries commented out)
    
    * patches/dev300/apply:
    * patches/vba/ibm-misc-fixes-1.diff:

diff --git a/patches/dev300/apply b/patches/dev300/apply
index 4a215d6..28600bf 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -1762,6 +1762,15 @@ tool-menu-bar-improvements.diff
 vba-styles-add-fix.diff, Fong
 vba-financial-functions.diff, n#525633, n#525635, n#525642, n#525647, 
 vba-typename-fix.diff, n#525649
+# disable untill master is updated
+# associated with vba-automation-set-fix.diff above, this patch
+# allows the automation bridge to tell the basic runtime about
+# default member of automation objects
+#vba-automation-defaultmember.diff, n#507501
+# disable untill master is updated
+# misc fixed from ibm
+#ibm-misc-fixes-1.diff,i#104203, i#103653
+
 
 [VBAUntested]
 SectionOwner => noelpwer
diff --git a/patches/vba/ibm-misc-fixes-1.diff b/patches/vba/ibm-misc-fixes-1.diff
new file mode 100644
index 0000000..5c0e5bc
--- /dev/null
+++ b/patches/vba/ibm-misc-fixes-1.diff
@@ -0,0 +1,1367 @@
+diff --git basic/inc/basic/sbobjmod.hxx basic/inc/basic/sbobjmod.hxx
+index 96cbe9b..5a9be63 100644
+--- basic/inc/basic/sbobjmod.hxx
++++ basic/inc/basic/sbobjmod.hxx
+@@ -79,6 +79,7 @@ public:
+     void Unload();
+     void load();
+     void triggerMethod( const String& );
++    void triggerMethod( const String&, css::uno::Sequence< css::uno::Any >&  );
+     void triggerActivateEvent();
+     void triggerDeActivateEvent();
+     void triggerInitializeEvent();
+diff --git basic/source/classes/sbxmod.cxx basic/source/classes/sbxmod.cxx
+index acb153a..29bb3c5 100644
+--- basic/source/classes/sbxmod.cxx
++++ basic/source/classes/sbxmod.cxx
+@@ -80,6 +80,9 @@
+ #include <com/sun/star/awt/XControl.hpp>
+ #include <cppuhelper/implbase1.hxx>
+ #include <comphelper/anytostring.hxx>
++#include <com/sun/star/document/XVbaMethodParameter.hpp> //liuchen 2009-7-21
++extern void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue ); //liuchen 2009-7-21
++extern ::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar );  //liuchen 2009-7-21
+ 
+ #include <com/sun/star/frame/XDesktop.hpp>
+ #include <vcl/svapp.hxx>
+@@ -1750,7 +1753,40 @@ public:
+             }
+         }
+     }
+-    virtual void SAL_CALL windowClosing( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) {}
++	
++    //liuchen 2009-7-21, support Excel VBA Form_QueryClose event
++    virtual void SAL_CALL windowClosing( const lang::EventObject& e ) throw (uno::RuntimeException)
++    {    
++		uno::Reference< awt::XDialog > xDialog( e.Source, uno::UNO_QUERY );
++		if ( xDialog.is() )
++		{
++			uno::Reference< awt::XControl > xControl( xDialog, uno::UNO_QUERY );
++			if ( xControl->getPeer().is() )
++			{
++				uno::Reference< document::XVbaMethodParameter > xVbaMethodParameter( xControl->getPeer(), uno::UNO_QUERY );
++				if ( xVbaMethodParameter.is() )
++				{	
++					sal_Int8 nCancel = 0;
++					sal_Int8 nCloseMode = 0;
++
++					Sequence< Any > aParams;
++					aParams.realloc(2);
++					aParams[0] <<= nCancel;
++					aParams[1] <<= nCloseMode;
++
++					mpUserForm->triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ),
++												aParams);
++					xVbaMethodParameter->setVbaMethodParameter( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Cancel")), aParams[0]);
++					return;
++	
++				}			
++			}		
++		}
++    	
++    	mpUserForm->triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ) );
++    }
++	//liuchen 2009-7-21
++	
+     virtual void SAL_CALL windowClosed( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { mbOpened = sal_False; mbShowing = sal_False; }
+     virtual void SAL_CALL windowMinimized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) {}
+     virtual void SAL_CALL windowNormalized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException){}
+@@ -1804,13 +1840,49 @@ void SbUserFormModule::ResetApiObj()
+ 
+ void SbUserFormModule::triggerMethod( const String& aMethodToRun )
+ {
++	Sequence< Any > aArguments;
++	triggerMethod( aMethodToRun, aArguments );
++}
++void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any >& aArguments)
++{
+ 	OSL_TRACE("*** trigger %s ***", rtl::OUStringToOString( aMethodToRun, RTL_TEXTENCODING_UTF8 ).getStr() );
+ 	// Search method
+ 	SbxVariable* pMeth = SbObjModule::Find( aMethodToRun, SbxCLASS_METHOD );
+ 	if( pMeth )
+-	{
+-		SbxValues aVals;
+-		pMeth->Get( aVals );
++	{		
++                 //liuchen 2009-7-21, support Excel VBA UserForm_QueryClose event with parameters
++		if ( aArguments.getLength() > 0 )   // Setup parameters
++		{
++			SbxArrayRef xArray = new SbxArray;
++			xArray->Put( pMeth, 0 );	// Method as parameter 0
++
++			for ( sal_Int32 i = 0; i < aArguments.getLength(); ++i )
++			{
++				SbxVariableRef xSbxVar = new SbxVariable( SbxVARIANT );
++                unoToSbxValue( static_cast< SbxVariable* >( xSbxVar ), aArguments[i] );
++                xArray->Put( xSbxVar, static_cast< USHORT >( i ) + 1 );
++
++				// Enable passing by ref
++				if ( xSbxVar->GetType() != SbxVARIANT )
++					xSbxVar->SetFlag( SBX_FIXED );
++			}
++			pMeth->SetParameters( xArray );
++
++			SbxValues aVals;
++			pMeth->Get( aVals );
++			
++			for ( sal_Int32 i = 0; i < aArguments.getLength(); ++i )
++			{
++				aArguments[i] = sbxToUnoValue( xArray->Get( static_cast< USHORT >(i) + 1) );
++			}		
++			pMeth->SetParameters( NULL );
++		}
++		else
++//liuchen 2009-7-21
++		{
++			SbxValues aVals;
++			pMeth->Get( aVals );
++		}
+ 	}
+ }
+ 
+@@ -1853,12 +1925,31 @@ void SbUserFormModule::load()
+     if ( !pDocObject )
+         InitObject();
+ }
++
++//liuchen 2009-7-21 change to accmordate VBA's beheavior
+ void SbUserFormModule::Unload()
+ {
+     OSL_TRACE("** Unload() ");
++
++	sal_Int8 nCancel = 0;
++	sal_Int8 nCloseMode = 1;
++
++	Sequence< Any > aParams;
++	aParams.realloc(2);
++	aParams[0] <<= nCancel;
++	aParams[1] <<= nCloseMode;
++
++	triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ), aParams);
++
++	aParams[0] >>= nCancel;
++	if (nCancel == 1)
++	{
++		return;
++	}
++	
+     if ( m_xDialog.is() )
+     {
+-	triggerTerminateEvent();
++		triggerTerminateEvent();
+     }
+ 	// Search method
+ 	SbxVariable* pMeth = SbObjModule::Find( String( RTL_CONSTASCII_USTRINGPARAM( "UnloadObject" ) ), SbxCLASS_METHOD );
+@@ -1883,6 +1974,7 @@ void SbUserFormModule::Unload()
+ 		OSL_TRACE("UnloadObject completed ( we hope )");
+ 	}
+ }
++//liuchen
+ 
+ void SbUserFormModule::InitObject()
+ {
+diff --git offapi/com/sun/star/document/XVbaMethodParameter.idl offapi/com/sun/star/document/XVbaMethodParameter.idl
+new file mode 100644
+index 0000000..96ca108
+--- /dev/null
++++ offapi/com/sun/star/document/XVbaMethodParameter.idl
+@@ -0,0 +1,68 @@
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * 
++ * Copyright IBM Corporation 2009
++ * Copyright 2009 by Sun Microsystems, Inc.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * $RCSfile: XVbaMethodParameter,v $
++ * $Revision: 1.13 $
++ *
++ * This file is part of OpenOffice.org.
++ *
++ * OpenOffice.org is free software: you can redistribute it and/or modify
++ * it under the terms of the GNU Lesser General Public License version 3
++ * only, as published by the Free Software Foundation.
++ *
++ * OpenOffice.org is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU Lesser General Public License version 3 for more details
++ * (a copy is included in the LICENSE file that accompanied this code).
++ *
++ * You should have received a copy of the GNU Lesser General Public License
++ * version 3 along with OpenOffice.org.  If not, see
++ * <http://www.openoffice.org/license.html>
++ * for a copy of the LGPLv3 License.
++ *
++ ************************************************************************/
++
++#ifndef __org_openoffice_vba_XVbaMethodParameter_idl__
++#define __org_openoffice_vba_XVbaMethodParameter_idl__
++
++#ifndef __com_sun_star_uno_XInterface_idl__
++#include <com/sun/star/uno/XInterface.idl>
++#endif
++
++//============================================================================= 
++
++module com {  module sun {  module star {  module document {
++
++//============================================================================= 
++//gives access to vba method input/output parameters
++//
++//some OO objects need to implement this interface to support the passing of input/output parameters
++//for certain VBA events
++
++interface XVbaMethodParameter : com::sun::star::uno::XInterface
++{
++	//------------------------------------------------------------------------- 
++	 
++	/** sets the value of the parameter with the specified name.
++	 */
++	void setVbaMethodParameter( [in] string PropertyName, 
++			 [in] any Value ); 
++ 
++	//------------------------------------------------------------------------- 
++
++	/** returns the value of the parameter with the specified name.
++     */
++	any getVbaMethodParameter( [in] string PropertyName ); 
++};
++
++//============================================================================= 
++
++}; }; }; };
++#endif
+diff --git offapi/com/sun/star/document/makefile.mk offapi/com/sun/star/document/makefile.mk
+index 9ab674c..9cbffa7 100644
+--- offapi/com/sun/star/document/makefile.mk
++++ offapi/com/sun/star/document/makefile.mk
+@@ -119,6 +119,7 @@ IDLFILES=\
+     XCodeNameQuery.idl \
+     XDocumentEventCompatibleHelper.idl \
+     XCompatWriterDocProperties.idl \
++    XVbaMethodParameter.idl \
+     VbaEventId.idl \
+     XVbaEventsHelper.idl \
+     VbaEventsHelper.idl \
+diff --git oovbaapi/ooo/vba/msforms/XLabel.idl oovbaapi/ooo/vba/msforms/XLabel.idl
+index 376802d..d2938d5 100644
+--- oovbaapi/ooo/vba/msforms/XLabel.idl
++++ oovbaapi/ooo/vba/msforms/XLabel.idl
+@@ -42,6 +42,7 @@ interface XLabel: com::sun::star::uno::XInterface
+ {
+ 	[attribute] string Caption;
+ 	[attribute] any Value;
++	[attribute] long ForeColor; //liuchen 2009-7-3
+ };
+ 
+ //=============================================================================
+diff --git oovbaapi/ooo/vba/msforms/XListBox.idl oovbaapi/ooo/vba/msforms/XListBox.idl
+index c68b258..6aedf42 100644
+--- oovbaapi/ooo/vba/msforms/XListBox.idl
++++ oovbaapi/ooo/vba/msforms/XListBox.idl
+@@ -43,7 +43,7 @@ interface XListBox: com::sun::star::uno::XInterface
+ {
+ 	[attribute] any Value;
+ 	[attribute] string Text;
+-	[attribute] boolean MultiSelect;
++	[attribute] long MultiSelect; //liuchen 2009-7-31 MultiSelect property in Excel VBA is type long
+ 	[attribute] any ListIndex;
+         [attribute, readonly ] long ListCount;
+ 	void AddItem( [in] any pvargItem, [in] any pvargIndex );
+diff --git sc/source/ui/vba/vbacomment.cxx sc/source/ui/vba/vbacomment.cxx
+index e8ca951..7e8a4c1 100644
+--- sc/source/ui/vba/vbacomment.cxx
++++ sc/source/ui/vba/vbacomment.cxx
+@@ -34,6 +34,7 @@
+ #include <com/sun/star/sheet/XSheetAnnotationAnchor.hpp>
+ #include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
+ #include <com/sun/star/sheet/XSheetCellRange.hpp>
++#include <com/sun/star/sheet/XCellAddressable.hpp>
+ #include <com/sun/star/table/CellAddress.hpp>
+ #include <com/sun/star/table/XCell.hpp>
+ #include <com/sun/star/text/XText.hpp>
+@@ -161,8 +162,7 @@ ScVbaComment::Text( const uno::Any& aText, const uno::Any& aStart, const uno::An
+ 	aText >>= sText;
+ 
+ 	uno::Reference< text::XSimpleText > xAnnoText( getAnnotation(), uno::UNO_QUERY_THROW );
+-	rtl::OUString sAnnoText = xAnnoText->getString();
+-
++        
+ 	if ( aStart.hasValue() )
+ 	{
+ 		sal_Int16 nStart = 0;
+@@ -194,8 +194,13 @@ ScVbaComment::Text( const uno::Any& aText, const uno::Any& aStart, const uno::An
+ 			throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScVbaComment::Text - bad Start value " ) ), uno::Reference< uno::XInterface >() );
+ 	}
+ 	else if ( aText.hasValue() )
+-		xAnnoText->setString( sText );
++	{
++		uno::Reference< sheet::XCellAddressable > xCellAddr(mxRange->getCellByPosition(0, 0), uno::UNO_QUERY_THROW );
++		table::CellAddress aAddress = xCellAddr->getCellAddress();
++		getAnnotations()->insertNew( aAddress, sText );
++	}
+ 
++	rtl::OUString sAnnoText = xAnnoText->getString();
+ 	return sAnnoText;
+ }
+ 
+diff --git sc/source/ui/vba/vbadialog.cxx sc/source/ui/vba/vbadialog.cxx
+index 4adfc4c..9ff110b 100644
+--- sc/source/ui/vba/vbadialog.cxx
++++ sc/source/ui/vba/vbadialog.cxx
+@@ -32,42 +32,58 @@
+ using namespace ::ooo::vba;
+ using namespace ::com::sun::star;
+ 
+-static const rtl::OUString aStringList[]=
++//liuchen 2009-7-27 
++//solve the problem that "Application.Dialogs.Item(***).Show" and "Application.Dialogs.Count" cannot get the correct result
++struct DialogMatch
+ {
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Open" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormatCellDialog" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertCell" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Print" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PasteSpecial" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ToolProtectionDocument" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColumnWidth" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DefineName" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConfigureDialog" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:HyperlinkDialog" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertGraphic" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertObject" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PageFormatDialog" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataSort" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:RowHeight" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoCorrectDlg" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConditionalFormatDialog" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataConsolidate" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CreateNames" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillSeries" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Validation") ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DefineLabelRange" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataFilterAutoFilter" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataFilterSpecialFilter" ) ),
+-	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoFormat" ) )	
++	sal_Int32 		nVbaDlgIndex;
++	rtl::OUString	aOODlgName;
+ };
+ 
+-const sal_Int32 nDialogSize = sizeof( aStringList ) / sizeof( aStringList[ 0 ] );
++static const DialogMatch aDialogMatchList[] = 
++{
++	{ 1, 	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Open" ) ) },						// xlDialogOpen -> .uno:Open
++	{ -1, 	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormatCellDialog" ) ) },			// ??? -> .uno:FormatCellDialog
++	{ 55, 	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertCell" ) ) },				// xlDialogInsert -> .uno:InsertCell
++	{ 8, 	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Print" ) ) },						// xlDialogPrint -> .uno:Print
++	{ 9,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PrinterSetup" ) ) }, 				// xlDialogPrinterSetup -> .uno:PrinterSetup
++	{ 53, 	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PasteSpecial" ) ) },				// xlDialogPasteSpecial -> .uno:PasteSpecial
++	{ 28, 	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ToolProtectionDocument" ) ) },	// xlDialogProtectDocument -> uno:ToolProtectionDocument
++	{ 47,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColumnWidth" ) ) },				// xlDialogColumnWidth -> .uno:ColumnWidth
++	{ 61,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DefineName" ) ) },				// xlDialogDefineName -> .uno:DefineName
++	{ -1, 	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConfigureDialog" ) ) },			// ??? -> .uno:ConfigureDialog
++	{ 596, 	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:HyperlinkDialog" ) ) },			// xlDialogInsertHyperlink -> .uno:HyperlinkDialog
++	{ 342,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertGraphic" ) ) },				// xlDialogInsertPicture -> .uno:InsertGraphic
++	{ 259, 	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertObject" ) ) },				// xlDialogInsertObject -> .uno:InsertObject
++	{ 7,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PageFormatDialog" ) ) },			// xlDialogPageSetup -> .uno:PageFormatDialog
++	{ 39,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataSort" ) ) },					// xlDialogSort -> .uno:DataSort
++	{ 127, 	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:RowHeight" ) ) },					// xlDialogRowHeight -> .uno:RowHeight
++	{ 485,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoCorrectDlg" ) ) },			// xlDialogAutoCorrect -> .uno:AutoCorrectDlg
++	{ 583, 	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConditionalFormatDialog" ) ) },	// xlDialogCondiationalFormatting -> .uno:ConditionalFormatDialog
++	{ 191,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataConsolidate" ) ) },			// xlDialogConsolidate -> .uno:DataConsolidate
++	{ 62,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CreateNames" ) ) },				// xlDialogCreateNames -> .uno:CreateNames
++	{ -1,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillSeries" ) ) },				// ??? -> .uno:FillSeries
++	{ -1,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Validation" ) ) },				// ??? -> .uno:Validation"
++	{ -1,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DefineLabelRange" ) ) },			// ??? -> .uno:DefineLabelRange
++	{ -1,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataFilterAutoFilter" ) ) },		// ??? -> .uno:DataFilterAutoFilter
++	{ -1,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataFilterSpecialFilter" ) ) }, 	// ??? -> .uno:DataFilterSpecialFilter
++	{ 269,	rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoFormat" ) ) }					// xlDialogFormatAuto -> .uno:AutoFormat
++};
+ 
++const sal_Int32 nDialogSize = sizeof( aDialogMatchList ) / sizeof( aDialogMatchList[ 0 ] );
++
++//liuchen modified 2009-2-27
+ rtl::OUString 
+ ScVbaDialog::mapIndexToName( sal_Int32 nIndex )
+ {
+-	if( nIndex < nDialogSize )
+-		return aStringList[ nIndex ];
++	for (int i = 0; i < nDialogSize; i++)
++	{
++		if ( aDialogMatchList[i].nVbaDlgIndex == nIndex )
++		{
++			return aDialogMatchList[i].aOODlgName;
++		}
++	}
++	
+ 	return rtl::OUString();
+ }
+ 
+@@ -89,3 +105,9 @@ ScVbaDialog::getServiceNames()
+ 	}
+ 	return aServiceNames;
+ }
++
++//liuchen add 2009-7-27
++sal_Int32 ScVbaDialog::GetSupportedDialogCount()
++{
++	return nDialogSize;
++}
+\ No newline at end of file
+diff --git sc/source/ui/vba/vbadialog.hxx sc/source/ui/vba/vbadialog.hxx
+index 648f038..1315303 100644
+--- sc/source/ui/vba/vbadialog.hxx
++++ sc/source/ui/vba/vbadialog.hxx
+@@ -48,6 +48,9 @@ public:
+ 	// XHelperInterface
+ 	virtual rtl::OUString& getServiceImplName();
+ 	virtual css::uno::Sequence<rtl::OUString> getServiceNames();
++
++	//liuchen 2009-7-27
++	static sal_Int32 GetSupportedDialogCount();
+ };
+ 
+ #endif /* SC_VBA_DIALOG_HXX */
+diff --git sc/source/ui/vba/vbadialogs.cxx sc/source/ui/vba/vbadialogs.cxx
+index 6f90e4b..ccd36ca 100644
+--- sc/source/ui/vba/vbadialogs.cxx
++++ sc/source/ui/vba/vbadialogs.cxx
+@@ -67,5 +67,13 @@ ScVbaDialogs::getServiceNames()
+ 	return aServiceNames;
+ }
+ 
++//liuchen 2009-7-27
++::sal_Int32
++ScVbaDialogs::getCount() throw (uno::RuntimeException)
++{	
++	return ScVbaDialog::GetSupportedDialogCount();
++}
++
++
+ 
+ 
+diff --git sc/source/ui/vba/vbadialogs.hxx sc/source/ui/vba/vbadialogs.hxx
+index c902b7a..c314178 100644
+--- sc/source/ui/vba/vbadialogs.hxx
++++ sc/source/ui/vba/vbadialogs.hxx
+@@ -47,6 +47,7 @@ public:
+ 
+ 	// XCollection
+ 	virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index ) throw (css::uno::RuntimeException);
++	virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException); //liuchen 2009-7-27
+ 
+ 	// XDialogs
+ 	virtual void SAL_CALL Dummy() throw (css::uno::RuntimeException);
+diff --git sc/source/ui/vba/vbapagebreaks.cxx sc/source/ui/vba/vbapagebreaks.cxx
+index 51eaffb..21fc9d7 100644
+--- sc/source/ui/vba/vbapagebreaks.cxx
++++ sc/source/ui/vba/vbapagebreaks.cxx
+@@ -118,10 +118,13 @@ sal_Int32 SAL_CALL RangePageBreaks::getCount(  ) throw (uno::RuntimeException)
+     for( sal_Int32 i=0; i<nLength; i++ )
+     {
+         sal_Int32 nPos = aTablePageBreakData[i].Position;
+-        if( nPos > nUsedEnd )
+-            return nCount;
+-        if( nPos >= nUsedStart )
+-            nCount++;
++
++		// VBA. minz at cn.ibm.com. All page breaks before the used range should be counted. 
++		// And the page break at the end of the used range also should be counted.
++		if(  nPos <= nUsedEnd + 1 )
++			nCount++;
++		else
++			return nCount;
+     }
+ 
+     return nCount;
+@@ -156,17 +159,9 @@ sheet::TablePageBreakData RangePageBreaks::getTablePageBreakData( sal_Int32 nAPI
+     uno::Sequence<sheet::TablePageBreakData> aTablePageBreakDataList = getAllPageBreaks();
+ 
+     sal_Int32 nLength = aTablePageBreakDataList.getLength();
+-    for( sal_Int32 i=0; i<nLength; i++ )
+-    {
+-        aTablePageBreakData = aTablePageBreakDataList[i];
+-        sal_Int32 nPos = aTablePageBreakData.Position;
+-        if( nPos >= nUsedStart )
+-            index++;
+-        if( nPos > nUsedEnd )
+-            DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+-        if( index == nAPIItemIndex )
+-            return aTablePageBreakData;
+-    }
++    //VBA. minz at cn.ibm.com. No need to filter the page break. All page breaks before the used range are counted.
++    if ( nAPIItemIndex < nLength && nAPIItemIndex>=0 )
++        aTablePageBreakData = aTablePageBreakDataList[nAPIItemIndex];
+ 
+     return aTablePageBreakData;
+ }
+diff --git sc/source/ui/vba/vbarange.cxx sc/source/ui/vba/vbarange.cxx
+index 61d2f35..d55101b 100644
+--- sc/source/ui/vba/vbarange.cxx
++++ sc/source/ui/vba/vbarange.cxx
+@@ -91,6 +91,8 @@
+ #include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
+ #include <com/sun/star/sheet/GeneralFunction.hdl>
+ 
++#include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
++#include <com/sun/star/sheet/XSheetAnnotations.hpp>
+ #include <ooo/vba/excel/XlPasteSpecialOperation.hpp>
+ #include <ooo/vba/excel/XlPasteType.hpp>
+ #include <ooo/vba/excel/Constants.hpp>
+@@ -1737,7 +1739,16 @@ ScVbaRange::getFormulaArray() throw (uno::RuntimeException)
+ 	uno::Reference< sheet::XCellRangeFormula> xCellRangeFormula( mxRange, uno::UNO_QUERY_THROW );
+ 	uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
+ 	uno::Any aMatrix;
+-	aMatrix = xConverter->convertTo( uno::makeAny( xCellRangeFormula->getFormulaArray() ) , getCppuType((uno::Sequence< uno::Sequence< uno::Any > >*)0)  ) ;
++
++	//VBA, minz at cn.ibm.com
++	uno::Sequence< uno::Sequence<rtl::OUString> > aFmArray = xCellRangeFormula->getFormulaArray();
++	if( aFmArray.getLength() )
++	{
++		if( aFmArray.getLength() == 1 && aFmArray[0].getLength() == 1 )
++			aMatrix <<= aFmArray[0][0];
++		else	
++			aMatrix = xConverter->convertTo( uno::makeAny( xCellRangeFormula->getFormulaArray() ) , getCppuType((uno::Sequence< uno::Sequence< uno::Any > >*)0)  ) ;
++	}	
+ 	return aMatrix;
+ }
+ 
+@@ -2240,7 +2251,8 @@ ScVbaRange::Cut(const ::uno::Any& Destination) throw (uno::RuntimeException)
+ 		uno::Reference< sheet::XCellRangeAddressable > xSource( mxRange, uno::UNO_QUERY);
+ 		xMover->moveRange( xDestination->getCellAddress(), xSource->getRangeAddress() );
+ 	}
+-	{
++	//VBA, minz at cn.ibm.com.
++	else {
+ 		uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange );
+ 		Select();
+ 		excel::implnCut( xModel );
+@@ -2628,11 +2640,12 @@ ScVbaRange::AddComment( const uno::Any& Text ) throw (uno::RuntimeException)
+ {
+ 
+ 	uno::Reference< excel::XComment > xComment( new ScVbaComment( this, mxContext, mxRange ) );
+-	// if you don't pass a valid text or if there is already a comment
+-	// associated with the range then return NULL
+-	if ( !xComment->Text( Text, uno::Any(), uno::Any() ).getLength() 
+-	||   xComment->Text( uno::Any(), uno::Any(), uno::Any() ).getLength() )
+-		return NULL;
++        // if there is existing text then error
++	if ( Text.hasValue() && xComment->Text( uno::Any(), uno::Any(), uno::Any() ).getLength() )
++            throw uno::RuntimeException(); 
++        // failed to write text? ( can this happen ?? )
++	if ( !xComment->Text( Text, uno::Any(), uno::Any() ).getLength()  )
++		return NULL;	
+ 	return xComment;
+ }
+ 
+diff --git sc/source/ui/vba/vbaworksheet.cxx sc/source/ui/vba/vbaworksheet.cxx
+index ff09315..f474c4b 100644
+--- sc/source/ui/vba/vbaworksheet.cxx
++++ sc/source/ui/vba/vbaworksheet.cxx
+@@ -77,7 +77,9 @@
+ 
+ #include "cellsuno.hxx"
+ #include "drwlayer.hxx"
+-
++#ifdef CWSSCSHEETPROTECTION
++#include "tabprotection.hxx"
++#endif
+ #include "scextopt.hxx"
+ #include "vbaoutline.hxx"
+ #include "vbarange.hxx"
+@@ -332,6 +334,22 @@ ScVbaWorksheet::getProtectContents()thro
+ sal_Bool 
+ ScVbaWorksheet::getProtectDrawingObjects() throw (uno::RuntimeException) 
+ {
++#ifdef CWSSCSHEETPROTECTION
++	SCTAB nTab = 0;
++	rtl::OUString aSheetName = getName();
++	uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
++	bool bSheetExists = nameExists (xSpreadDoc, aSheetName, nTab);
++	if ( bSheetExists )
++	{
++		uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
++		ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
++		ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
++		if ( pProtect )
++			return pProtect->getOption( ScTableProtection::OBJECTS ); 
++        }
++#else
++	return getProtectContents(); // fallback
++#endif 
+ 	return false;
+ }
+ 
+@@ -557,13 +560,25 @@ ScVbaWorksheet::getSheetAtOffset(SCTAB offset) throw (uno::RuntimeException)
+ uno::Reference< excel::XWorksheet >
+ ScVbaWorksheet::getNext() throw (uno::RuntimeException)
+ {
+-	return getSheetAtOffset(static_cast<SCTAB>(1));
++	//VBA, minz at cn.ibm.com. catch the exception for index out of bound
++	try{
++		return getSheetAtOffset(static_cast<SCTAB>(1));
++	}catch( lang::IndexOutOfBoundsException& /*e*/ )
++	{
++		return NULL;
++	}
+ }
+ 
+ uno::Reference< excel::XWorksheet >
+ ScVbaWorksheet::getPrevious() throw (uno::RuntimeException)
+ {
+-	return getSheetAtOffset(-1);
++	//VBA, minz at cn.ibm.com. catch the exception for index out of bound
++	try{
++		return getSheetAtOffset(-1);
++	}catch( lang::IndexOutOfBoundsException& /*e*/ )
++	{
++		return NULL;
++	}
+ }
+ 
+ 
+@@ -647,7 +662,7 @@ ScVbaWorksheet::ChartObjects( const uno::Any& Index ) throw (uno::RuntimeExcepti
+ 		uno::Reference< table::XTableChartsSupplier > xChartSupplier( getSheet(), uno::UNO_QUERY_THROW );
+ 		uno::Reference< table::XTableCharts > xTableCharts = xChartSupplier->getCharts();
+ 		
+-		uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxSheet, uno::UNO_QUERY_THROW );
++		uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( getSheet(), uno::UNO_QUERY_THROW ); //VBA, minz at cn.ibm.com.
+ 		mxCharts = new ScVbaChartObjects(  this, mxContext, xTableCharts, xDrawPageSupplier );
+ 	}
+ 	if ( Index.hasValue() )
+@@ -936,7 +951,7 @@ ScVbaWorksheet::setCodeName( const rtl::OUString& ) throw (css::uno::RuntimeExce
+ sal_Int16
+ ScVbaWorksheet::getSheetID() throw (uno::RuntimeException)
+ {
+-	uno::Reference< sheet::XCellRangeAddressable > xAddressable( mxSheet, uno::UNO_QUERY_THROW );
++	uno::Reference< sheet::XCellRangeAddressable > xAddressable( getSheet(), uno::UNO_QUERY_THROW ); //VBA. minz at cn.ibm.com. if ActiveSheet, mxSheet is null.
+ 	return xAddressable->getRangeAddress().Sheet;
+ }
+ 
+diff --git scripting/source/vbaevents/eventhelper.cxx scripting/source/vbaevents/eventhelper.cxx
+index f85ac51..6928530 100644
+--- scripting/source/vbaevents/eventhelper.cxx
++++ scripting/source/vbaevents/eventhelper.cxx
+@@ -26,6 +26,10 @@
+ #include <com/sun/star/awt/XDialog.hpp>
+ #include <com/sun/star/awt/KeyEvent.hpp>
+ #include <com/sun/star/awt/MouseEvent.hpp>
++#include <com/sun/star/awt/XFixedText.hpp> //liuchen 2009-6-5
++#include <com/sun/star/awt/XTextComponent.hpp> //liuchen 2009-6-5
++#include <com/sun/star/awt/XComboBox.hpp> //liuchen 2009-6-18
++#include <com/sun/star/awt/XRadioButton.hpp> //liuchen 2009-7-30
+ 
+ #include <msforms/ReturnInteger.hpp>
+ 
+@@ -63,6 +67,8 @@ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::uno;
+ using namespace ::ooo::vba;
+ 
++#define MAP_CHAR_LEN(x) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(x))//liuchen 2009-6-8
++#define GET_TYPE(x) ::getCppuType((uno::Reference< x > *)0);
+ 
+ // Some constants 
+ const static rtl::OUString DELIM = rtl::OUString::createFromAscii( "::" );
+@@ -227,10 +233,14 @@ Sequence< Any > ooKeyPressedToVBAKeyUpDown( const Sequence< Any >& params )
+ 
+ typedef Sequence< Any > (*Translator)(const Sequence< Any >&);
+ 
++//liuchen 2009-6-23
++//expand the "TranslateInfo" struct to support more kinds of events 
+ struct TranslateInfo
+ {
+-    rtl::OUString sVBAName;
+-    Translator toVBA;
++    rtl::OUString sVBAName; //vba event name
++    Translator toVBA;       //the method to convert OO event parameters to VBA event parameters	
++	bool (*ApproveRule)(const ScriptEvent& evt, void* pPara); //this method is used to determine which types of controls should execute the event 
++	void *pPara;			//Parameters for the above approve method
+ };
+ 
+ 
+@@ -239,104 +249,116 @@ std::list< TranslateInfo >,
+ ::rtl::OUStringHash,
+ ::std::equal_to< ::rtl::OUString > > EventInfoHash;
+ 
++//liuchen 2009-6-23
++struct TranslatePropMap
++{
++	rtl::OUString sEventInfo;   //OO event name
++	TranslateInfo aTransInfo;   
++};
++
++bool ApproveAll(const ScriptEvent& evt, void* pPara); //allow all types of controls to execute the event
++bool ApproveType(const ScriptEvent& evt, void* pPara); //certain types of controls should execute the event, those types are given by pPara
++bool DenyType(const ScriptEvent& evt, void* pPara);    //certain types of controls should not execute the event, those types are given by pPara
++bool DenyMouseDrag(const ScriptEvent& evt, void* pPara); //used for VBA MouseMove event when "Shift" key is pressed
++
++struct TypeList
++{
++	uno::Type* pTypeList;
++	int nListLength;
++};
++
++Type typeXFixedText = GET_TYPE(awt::XFixedText);
++Type typeXTextComponent = GET_TYPE(awt::XTextComponent);
++Type typeXComboBox = GET_TYPE(awt::XComboBox);
++Type typeXRadioButton = GET_TYPE(awt::XRadioButton);
++
++
++TypeList fixedTextList = {&typeXFixedText, 1};
++TypeList textCompList = {&typeXTextComponent, 1};
++TypeList radioButtonList = {&typeXRadioButton, 1};
++TypeList comboBoxList = {&typeXComboBox, 1};
++
++//this array stores the OO event to VBA event translation info
++static TranslatePropMap aTranslatePropMap_Impl[] = 
++{
++	// actionPerformed ooo event
++	{ MAP_CHAR_LEN("actionPerformed"), { MAP_CHAR_LEN("_Click"), NULL, ApproveAll, NULL } },	
++	{ MAP_CHAR_LEN("actionPerformed"), { MAP_CHAR_LEN("_Change"), NULL, DenyType, (void*)(&radioButtonList) } },  //liuchen 2009-7-30, OptionalButton_Change event is not the same as OptionalButton_Click event
++
++	// itemStateChanged ooo event
++	{ MAP_CHAR_LEN("itemStateChanged"), { MAP_CHAR_LEN("_Click"), NULL, ApproveType, (void*)(&comboBoxList) } },  //liuchen, add to support VBA ComboBox_Click event
++	{ MAP_CHAR_LEN("itemStateChanged"), { MAP_CHAR_LEN("_Change"), NULL, ApproveType, (void*)(&radioButtonList) } }, //liuchen 2009-7-30, OptionalButton_Change event should be triggered when the button state is changed
++	
++	// changed ooo event
++	{ MAP_CHAR_LEN("changed"), { MAP_CHAR_LEN("_Change"), NULL, ApproveAll, NULL } },	
++
++	// focusGained ooo event
++	{ MAP_CHAR_LEN("focusGained"), { MAP_CHAR_LEN("_GotFocus"), NULL, ApproveAll, NULL } },
++
++	// focusLost ooo event
++	{ MAP_CHAR_LEN("focusLost"), { MAP_CHAR_LEN("_LostFocus"), NULL, ApproveAll, NULL } },
++	{ MAP_CHAR_LEN("focusLost"), { MAP_CHAR_LEN("_Exit"), NULL, ApproveType, (void*)(&textCompList) } }, //liuchen, add to support VBA TextBox_Exit event
++
++	// adjustmentValueChanged ooo event
++	{ MAP_CHAR_LEN("adjustmentValueChanged"), { MAP_CHAR_LEN("_Scroll"), NULL, ApproveAll, NULL } },
++	{ MAP_CHAR_LEN("adjustmentValueChanged"), { MAP_CHAR_LEN("_Change"), NULL, ApproveAll, NULL } },
++
++	// textChanged ooo event
++	{ MAP_CHAR_LEN("textChanged"), { MAP_CHAR_LEN("_Change"), NULL, ApproveAll, NULL } },
++
++	// keyReleased ooo event
++	{ MAP_CHAR_LEN("keyReleased"), { MAP_CHAR_LEN("_KeyUp"), ooKeyPressedToVBAKeyUpDown, ApproveAll, NULL } },
++
++	// mouseReleased ooo event
++	{ MAP_CHAR_LEN("mouseReleased"), { MAP_CHAR_LEN("_Click"), ooMouseEvtToVBAMouseEvt, ApproveType, (void*)(&fixedTextList) } }, //liuchen, add to support VBA Label_Click event
++	{ MAP_CHAR_LEN("mouseReleased"), { MAP_CHAR_LEN("_MouseUp"), ooMouseEvtToVBAMouseEvt, ApproveAll, NULL } },
++
++	// mousePressed ooo event
++	{ MAP_CHAR_LEN("mousePressed"), { MAP_CHAR_LEN("_MouseDown"), ooMouseEvtToVBAMouseEvt, ApproveAll, NULL } },
++	{ MAP_CHAR_LEN("mousePressed"), { MAP_CHAR_LEN("_DblClick"), ooMouseEvtToVBADblClick, ApproveAll, NULL } },
++
++	// mouseMoved ooo event	
++	{ MAP_CHAR_LEN("mouseMoved"), { MAP_CHAR_LEN("_MouseMove"), ooMouseEvtToVBAMouseEvt, ApproveAll, NULL } },
++	{ MAP_CHAR_LEN("mouseDragged"), { MAP_CHAR_LEN("_MouseMove"), ooMouseEvtToVBAMouseEvt, DenyMouseDrag, NULL } }, //liuchen, add to support VBA MouseMove event when the "Shift" key is pressed
++
++	// keyPressed ooo event
++	{ MAP_CHAR_LEN("keyPressed"), { MAP_CHAR_LEN("_KeyDown"), ooKeyPressedToVBAKeyUpDown, ApproveAll, NULL } },
++	{ MAP_CHAR_LEN("keyPressed"), { MAP_CHAR_LEN("_KeyPress"), ooKeyPressedToVBAKeyUpDown, ApproveAll, NULL } }
++};
+ 
+ EventInfoHash& getEventTransInfo()
+ {
+     static bool initialised = false;
+     static EventInfoHash eventTransInfo;
+     if ( !initialised )
+-    {
+-        TranslateInfo  info;
+-        // actionPerformed ooo event
+-        std::list< TranslateInfo > actionInfos;
+-        info.sVBAName = rtl::OUString::createFromAscii("_Click");
+-        info.toVBA = NULL;
+-        actionInfos.push_back( info );
+-        info.sVBAName = rtl::OUString::createFromAscii("_Change");
+-        info.toVBA = NULL;
+-        actionInfos.push_back( info );
+-        eventTransInfo[ rtl::OUString::createFromAscii("actionPerformed") ] = actionInfos;
+-        // itemStateChanged ooo event
+-        std::list< TranslateInfo > stateChangedInfos;
+-        info.sVBAName = rtl::OUString::createFromAscii("_Change");
+-        info.toVBA = NULL;
+-        stateChangedInfos.push_back( info );
+-        eventTransInfo[ rtl::OUString::createFromAscii("itemStateChanged") ] = stateChangedInfos;
+-        // changed ooo event
+-        std::list< TranslateInfo > changeInfos;
+-        info.sVBAName = rtl::OUString::createFromAscii("_Change");
+-        info.toVBA = NULL;
+-        changeInfos.push_back( info );
+-        eventTransInfo[ rtl::OUString::createFromAscii("changed") ] = changeInfos;
+-        // focusGained ooo event
+-        std::list< TranslateInfo > focusGainedInfos;
+-        info.sVBAName = rtl::OUString::createFromAscii("_GotFocus");
+-        info.toVBA = NULL;
+-        focusGainedInfos.push_back( info );
+-        eventTransInfo[ rtl::OUString::createFromAscii("focusGained") ] = focusGainedInfos;
+-        // focusLost ooo event
+-        std::list< TranslateInfo > focusLostInfos;
+-        info.sVBAName = rtl::OUString::createFromAscii("_LostFocus");
+-        info.toVBA = NULL;
+-        focusLostInfos.push_back( info );
+-        eventTransInfo[ rtl::OUString::createFromAscii("focusGained") ] = focusLostInfos;
+-        // adjustmentValueChanged ooo event
+-        std::list< TranslateInfo > adjustInfos;
+-        info.sVBAName = rtl::OUString::createFromAscii("_Scroll");
+-        info.toVBA = NULL;
+-        adjustInfos.push_back( info );
+-        info.sVBAName = rtl::OUString::createFromAscii("_Change");
+-        info.toVBA = NULL;
+-        adjustInfos.push_back( info );
+-        eventTransInfo[ rtl::OUString::createFromAscii("adjustmentValueChanged") ] = adjustInfos;
+-        // textChanged ooo event
+-        std::list< TranslateInfo > txtChangedInfos;
+-        info.sVBAName = rtl::OUString::createFromAscii("_Change");
+-        info.toVBA = NULL;
+-        txtChangedInfos.push_back( info );
+-        eventTransInfo[ rtl::OUString::createFromAscii("textChanged") ] = txtChangedInfos;
+-
+-        // keyReleased ooo event
+-        std::list< TranslateInfo > keyReleasedInfos;
+-        info.sVBAName = rtl::OUString::createFromAscii("_KeyUp");
+-        info.toVBA = ooKeyPressedToVBAKeyUpDown;
+-        keyReleasedInfos.push_back( info );
+-        eventTransInfo[ rtl::OUString::createFromAscii("keyReleased") ] = keyReleasedInfos;
+-        // mouseReleased ooo event
+-        std::list< TranslateInfo > mouseReleasedInfos;
+-        info.sVBAName = rtl::OUString::createFromAscii("_MouseUp");
+-        info.toVBA = ooMouseEvtToVBAMouseEvt;
+-        mouseReleasedInfos.push_back( info );
+-        eventTransInfo[ rtl::OUString::createFromAscii("mouseReleased") ] = mouseReleasedInfos;
+-        // mousePressed ooo event
+-        std::list< TranslateInfo > mousePressedInfos;
+-        info.sVBAName = rtl::OUString::createFromAscii("_MouseDown");
+-        info.toVBA = ooMouseEvtToVBAMouseEvt;
+-        mousePressedInfos.push_back( info );
+-        info.sVBAName = rtl::OUString::createFromAscii("_DblClick");
+-        // emulate double click event
+-        info.toVBA = ooMouseEvtToVBADblClick;
+-        mousePressedInfos.push_back( info );
+-        eventTransInfo[ rtl::OUString::createFromAscii("mousePressed") ] = mousePressedInfos;
+-        // mouseMoved ooo event
+-        std::list< TranslateInfo > mouseMovedInfos;
+-        info.sVBAName = rtl::OUString::createFromAscii("_MouseMove");
+-        info.toVBA = ooMouseEvtToVBAMouseEvt;
+-        mouseMovedInfos.push_back( info );
+-        eventTransInfo[ rtl::OUString::createFromAscii("mouseMoved") ] = mouseMovedInfos;
+-        // keyPressed ooo event
+-        std::list< TranslateInfo > keyPressedInfos;
+-        info.sVBAName = rtl::OUString::createFromAscii("_KeyDown");
+-        info.toVBA = ooKeyPressedToVBAKeyUpDown;
+-        keyPressedInfos.push_back( info );
+-        info.sVBAName = rtl::OUString::createFromAscii("_KeyPress");
+-        info.toVBA = ooKeyPressedToVBAKeyPressed;
+-        keyPressedInfos.push_back( info );
+-        eventTransInfo[ rtl::OUString::createFromAscii("keyPressed") ] = keyPressedInfos;
++    {		
++		rtl::OUString sEventInfo = MAP_CHAR_LEN("");
++		TranslatePropMap* pTransProp = aTranslatePropMap_Impl;
++
++		int nCount = sizeof(aTranslatePropMap_Impl) / sizeof(aTranslatePropMap_Impl[0]);
++
++		int i = 0;
++		while (i < nCount)
++		{			
++			if (sEventInfo != pTransProp->sEventInfo)
++			{
++				sEventInfo = pTransProp->sEventInfo;
++				std::list< TranslateInfo > infoList;
++				do
++				{									
++					infoList.push_back( pTransProp->aTransInfo );
++                                        i++;
++					pTransProp++;
++				}
++				while( ( i < nCount ) && ( sEventInfo == pTransProp->sEventInfo ) );
++				eventTransInfo[sEventInfo] = infoList;
++			}
++		}		
+         initialised = true;
+     }
+     return eventTransInfo;
+ }
++//liuchen 2009-6-23 end
+ 
+ // Helper class
+ 
+@@ -764,7 +786,68 @@ EventListener::getPropertySetInfo(  ) throw (RuntimeException)
+     return xInfo;
+ }
+ 
++//liuchen 2009-6-23
++//decide if the control should execute the event
++bool ApproveAll(const ScriptEvent& evt, void* pPara)
++{
++	return true;
++}
++
++//for the given control type in evt.Arguments[0], look for if it appears in the type list in pPara
++bool FindControl(const ScriptEvent& evt, void* pPara)
++{
++	lang::EventObject aEvent;
++	evt.Arguments[ 0 ] >>= aEvent;
++	uno::Reference< uno::XInterface > xInterface( aEvent.Source, uno::UNO_QUERY );
++
++	TypeList* pTypeListInfo = static_cast<TypeList*>(pPara);
++	Type* pType = pTypeListInfo->pTypeList;
++	int nLen = pTypeListInfo->nListLength;
++
++	for (int i = 0; i < nLen; i++)
++	{
++		if ( xInterface->queryInterface( *pType ).hasValue() )
++		{
++			return true;
++		}
++		pType++;
++	}
++
++	return false;
++}
++
++//if the the given control type in evt.Arguments[0] appears in the type list in pPara, then approve the execution
++bool ApproveType(const ScriptEvent& evt, void* pPara)
++{
++	return FindControl(evt, pPara);
++}
++
++//if the the given control type in evt.Arguments[0] appears in the type list in pPara, then deny the execution
++bool DenyType(const ScriptEvent& evt, void* pPara)
++{
++	return !FindControl(evt, pPara);
++}
++
++//when mouse is moving, either the mouse button is pressed or some key is pressed can trigger the OO mouseDragged event,
++//the former should be denyed, and the latter allowed, only by doing so can the VBA MouseMove event when the "Shift" key is 
++//pressed can be correctly triggered
++bool DenyMouseDrag(const ScriptEvent& evt, void* pPara)
++{
++	awt::MouseEvent aEvent;
++	evt.Arguments[ 0 ] >>= aEvent;
++	if (aEvent.Buttons == 0 )
++	{
++		return true;
++	}
++	else
++	{
++		return false;
++	}
++}
++
++
+ 
++//liuchen 2009-6-23
+ // EventListener
+ 
+ void
+@@ -850,6 +933,12 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) throw(RuntimeExce
+             ooo::vba::VBAMacroResolvedInfo aMacroResolvedInfo = ooo::vba::resolveVBAMacro( mpShell, sToResolve ); 
+             if ( aMacroResolvedInfo.IsResolved() )
+             {
++				//liuchen 2009-6-8
++				if (! txInfo->ApproveRule(evt, txInfo->pPara) )
++				{
++					continue;
++				}
++				//liuchen 2009-6-8
+                 // !! translate arguments & emulate events where necessary 
+                 Sequence< Any > aArguments;
+                 if  ( (*txInfo).toVBA )
+diff --git toolkit/inc/toolkit/awt/vclxwindows.hxx toolkit/inc/toolkit/awt/vclxwindows.hxx
+index a7ab2fc..a41fabc 100644
+--- toolkit/inc/toolkit/awt/vclxwindows.hxx
++++ toolkit/inc/toolkit/awt/vclxwindows.hxx
+@@ -96,6 +96,7 @@
+ #include <vcl/imgcons.hxx>
+ #include <vcl/image.hxx>
+ 
++#include <com/sun/star/document/XVbaMethodParameter.hpp>  //liuchen 2009-6-22, add the support of input/output parameters to VBA Dialog_QueryClose event
+ class Button;
+ class CheckBox;
+ class RadioButton;
+@@ -391,6 +392,7 @@ public:
+ //	class VCLXDialog
+ //	----------------------------------------------------
+ class VCLXDialog :	public ::com::sun::star::awt::XDialog,
++						public ::com::sun::star::document::XVbaMethodParameter, //liuchen 2009-6-22, add the support of input/output parameters to VBA UserForm_QueryClose event
+ 					public VCLXTopWindow
+ {
+ public:
+@@ -424,6 +426,10 @@ public:
+ 	// ::com::sun::star::awt::XVclWindowPeer
+     void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException);
+ 
++	//liuchen 2009-6-23, support Excel VBA UserForm_QueryClose event
++	// ::com::sun::star::document::XVBAMethodParameter
++	void SAL_CALL setVbaMethodParameter( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException);
++	::com::sun::star::uno::Any SAL_CALL getVbaMethodParameter( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); 
+ };
+ 
+ //	----------------------------------------------------
+diff --git toolkit/source/awt/vclxwindows.cxx toolkit/source/awt/vclxwindows.cxx
+index bc673cf..3031d6f 100644
+--- toolkit/source/awt/vclxwindows.cxx
++++ toolkit/source/awt/vclxwindows.cxx
+@@ -2217,12 +2217,14 @@ VCLXDialog::~VCLXDialog()
+ ::com::sun::star::uno::Any VCLXDialog::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
+ {
+ 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
++										SAL_STATIC_CAST( ::com::sun::star::document::XVbaMethodParameter*, this ), //liuchen 2009-6-23
+ 										SAL_STATIC_CAST( ::com::sun::star::awt::XDialog*, this ) );
+ 	return (aRet.hasValue() ? aRet : VCLXTopWindow::queryInterface( rType ));
+ }
+ 
+ // ::com::sun::star::lang::XTypeProvider
+ IMPL_XTYPEPROVIDER_START( VCLXDialog )
++	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::document::XVbaMethodParameter>* ) NULL ), //liuchen 2009-6-23
+ 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDialog>* ) NULL ),
+ 	VCLXTopWindow::getTypes()
+ IMPL_XTYPEPROVIDER_END
+@@ -2310,6 +2312,40 @@ void SAL_CALL VCLXDialog::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::s
+ 	return aInfo;
+ }
+ 
++//liuchen 2009-7-22
++// ::com::sun::star::document::XVbaMethodParameter
++void SAL_CALL VCLXDialog::setVbaMethodParameter(
++	const ::rtl::OUString& PropertyName,
++	const ::com::sun::star::uno::Any& Value )
++throw(::com::sun::star::uno::RuntimeException)
++{
++	if (rtl::OUString::createFromAscii( "Cancel" ) == PropertyName)
++	{
++		::vos::OGuard aGuard( GetMutex() ); 
++		if ( GetWindow() )
++		{
++			sal_Int8 nCancel;
++			Value >>= nCancel;
++		
++			Dialog* pDlg = (Dialog*) GetWindow();
++			pDlg->SetCloseFlag(nCancel);
++		}
++	}
++}
++
++::com::sun::star::uno::Any SAL_CALL VCLXDialog::getVbaMethodParameter(
++	const ::rtl::OUString& PropertyName )
++throw(::com::sun::star::uno::RuntimeException)
++{
++	::vos::OGuard aGuard( GetMutex() );
++
++	::com::sun::star::uno::Any aRet;	
++	return aRet;
++}
++//liuchen 2009-7-22
++
++
++
+ 
+ void SAL_CALL VCLXDialog::setProperty(
+     const ::rtl::OUString& PropertyName,
+diff --git vbahelper/source/msforms/vbacontrol.cxx vbahelper/source/msforms/vbacontrol.cxx
+index 0989548..9ff662a 100644
+--- vbahelper/source/msforms/vbacontrol.cxx
++++ vbahelper/source/msforms/vbacontrol.cxx
+@@ -397,13 +397,20 @@ ScVbaControl* ScVbaControlFactory::createControl(const uno::Reference< drawing::
+     const static rtl::OUString sClassId( RTL_CONSTASCII_USTRINGPARAM("ClassId") );
+     xProps->getPropertyValue( sClassId ) >>= nClassId;
+     uno::Reference< XHelperInterface > xVbaParent; // #FIXME - should be worksheet I guess
+-    switch( nClassId )
++    sal_Bool bToggle = sal_False;  //liuchen 2009-8-11,  
++	switch( nClassId )
+     {
+         case form::FormComponentType::COMBOBOX:
+             return new ScVbaComboBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+         case form::FormComponentType::COMMANDBUTTON:
+-            return new ScVbaButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+-        case form::FormComponentType::FIXEDTEXT:
++			//liuchen 2009-8-11
++			xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Toggle") ) ) >>= bToggle;
++			if ( bToggle )
++				return new ScVbaToggleButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
++			else
++				return new ScVbaButton( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
++			//liuchen 2009-8-11
++		case form::FormComponentType::FIXEDTEXT:
+             return new ScVbaLabel( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+         case form::FormComponentType::TEXTFIELD:
+             return new ScVbaTextBox( xVbaParent, m_xContext, xControlShape, m_xModel, new ConcreteXShapeGeometryAttributes( m_xContext, uno::Reference< drawing::XShape >( xControlShape, uno::UNO_QUERY_THROW ) ) );
+diff --git vbahelper/source/msforms/vbaframe.cxx vbahelper/source/msforms/vbaframe.cxx
+index b2827d0..d765d9b 100644
+--- vbahelper/source/msforms/vbaframe.cxx
++++ vbahelper/source/msforms/vbaframe.cxx
+@@ -72,6 +72,17 @@ ScVbaFrame::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::Run
+     _value >>= sCaption;
+     setCaption( sCaption ); 
+ }
++//liuchen 2009-7-6 
++::sal_Int32 SAL_CALL ScVbaFrame::getForeColor() throw (::com::sun::star::uno::RuntimeException)
++{
++	return 0;
++}
++
++void SAL_CALL ScVbaFrame::setForeColor( ::sal_Int32 /*_forecolor*/ ) throw (::com::sun::star::uno::RuntimeException)
++{
++	return;
++}
++//liuchen 2009-7-6 end
+ 
+ rtl::OUString& 
+ ScVbaFrame::getServiceImplName()
+diff --git vbahelper/source/msforms/vbaframe.hxx vbahelper/source/msforms/vbaframe.hxx
+index 071b5b0..9b1b6bb 100644
+--- vbahelper/source/msforms/vbaframe.hxx
++++ vbahelper/source/msforms/vbaframe.hxx
+@@ -51,6 +51,10 @@ public:
+     virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
+     virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
+     virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
++	//liuchen 2009-7-6 
++	virtual ::sal_Int32 SAL_CALL getForeColor() throw (::com::sun::star::uno::RuntimeException);
++	virtual void SAL_CALL setForeColor( ::sal_Int32 _forecolor ) throw (::com::sun::star::uno::RuntimeException);
++	//liuchen 2009-7-6 end
+     //XHelperInterface
+     virtual rtl::OUString& getServiceImplName();
+     virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+diff --git vbahelper/source/msforms/vbalabel.cxx vbahelper/source/msforms/vbalabel.cxx
+index a5fa3c1..a9869f7 100644
+--- vbahelper/source/msforms/vbalabel.cxx
++++ vbahelper/source/msforms/vbalabel.cxx
+@@ -35,6 +35,7 @@ using namespace ooo::vba;
+ 
+ 
+ const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
++const static rtl::OUString FORECOLOR( RTL_CONSTASCII_USTRINGPARAM("TextColor") ); //liuchen 2009-7-6
+ ScVbaLabel::ScVbaLabel(  const css::uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : LabelImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
+ {
+ }
+@@ -68,6 +69,20 @@ ScVbaLabel::setValue( const uno::Any& _value ) throw (::com::sun::star::uno::Run
+ }
+ 
+ 
++//liuchen 2009-7-6
++::sal_Int32 SAL_CALL ScVbaLabel::getForeColor() throw (::com::sun::star::uno::RuntimeException)
++{
++	sal_Int32 nForeColor;
++	m_xProps->getPropertyValue( FORECOLOR ) >>= nForeColor; 
++	return OORGBToXLRGB( nForeColor );
++}
++
++void SAL_CALL ScVbaLabel::setForeColor( ::sal_Int32 _forecolor ) throw (::com::sun::star::uno::RuntimeException)
++{	
++	 m_xProps->setPropertyValue( FORECOLOR, uno::makeAny( XLRGBToOORGB( _forecolor ) ) );
++}
++//liuchenn 2009-7-6
++
+ rtl::OUString& 
+ ScVbaLabel::getServiceImplName()
+ {
+diff --git vbahelper/source/msforms/vbalabel.hxx vbahelper/source/msforms/vbalabel.hxx
+index 3afd652..9c8766d 100644
+--- vbahelper/source/msforms/vbalabel.hxx
++++ vbahelper/source/msforms/vbalabel.hxx
+@@ -47,6 +47,10 @@ public:
+     virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
+     virtual rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
+     virtual void SAL_CALL setCaption( const rtl::OUString& _caption ) throw (css::uno::RuntimeException);
++	//liuchen 2009-7-6 
++	virtual ::sal_Int32 SAL_CALL getForeColor() throw (::com::sun::star::uno::RuntimeException);
++	virtual void SAL_CALL setForeColor( ::sal_Int32 _forecolor ) throw (::com::sun::star::uno::RuntimeException);
++	//liuchen 2009-7-6 end
+     //XHelperInterface
+     virtual rtl::OUString& getServiceImplName();
+     virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+diff --git vbahelper/source/msforms/vbalistbox.cxx vbahelper/source/msforms/vbalistbox.cxx
+index 47f9847..175328f 100644
+--- vbahelper/source/msforms/vbalistbox.cxx
++++ vbahelper/source/msforms/vbalistbox.cxx
+@@ -113,7 +113,7 @@ ScVbaListBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
+     uno::Sequence< sal_Int16 > nSelectedIndices(1);
+     nSelectedIndices[ 0 ] = nValue;
+     m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( nSelectedIndices ) ); 
+-    m_xProps->setPropertyValue( TEXT, uno::makeAny( sValue ) ); 
++	//m_xProps->setPropertyValue( TEXT, uno::makeAny( sValue ) );   //liuchen 2009-8-12 solve the problem that ListBox.Text and ListBox.Value cannot be set
+ }
+ 
+ ::rtl::OUString SAL_CALL 
+@@ -130,20 +130,22 @@ ScVbaListBox::setText( const ::rtl::OUString& _text ) throw (uno::RuntimeExcepti
+ 	setValue( uno::makeAny( _text ) ); // seems the same
+ }
+ 
+-sal_Bool SAL_CALL 
++sal_Int32 SAL_CALL 
+ ScVbaListBox::getMultiSelect() throw (css::uno::RuntimeException)
+ {
+     sal_Bool bMultiSelect = sal_False;
+     m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiSelection" ) ) ) >>= bMultiSelect;
+-    return bMultiSelect;
++    return bMultiSelect ? 1 : 0 ;
+ }
+ 
+ void SAL_CALL 
+-ScVbaListBox::setMultiSelect( sal_Bool _multiselect ) throw (css::uno::RuntimeException)
++ScVbaListBox::setMultiSelect( sal_Int32 _multiselect ) throw (css::uno::RuntimeException)
+ {
+-    m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiSelection" ) ), uno::makeAny( _multiselect ) );
++	sal_Bool bMultiSelect = _multiselect == 1 ? 1 : 0;
++    m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiSelection" ) ), uno::makeAny( bMultiSelect ) );
+ }
+ 
++
+ css::uno::Any SAL_CALL 
+ ScVbaListBox::Selected( sal_Int32 index ) throw (css::uno::RuntimeException)
+ {
+diff --git vbahelper/source/msforms/vbalistbox.hxx vbahelper/source/msforms/vbalistbox.hxx
+index 93e80a3..009ee4f 100644
+--- vbahelper/source/msforms/vbalistbox.hxx
++++ vbahelper/source/msforms/vbalistbox.hxx
+@@ -61,8 +61,8 @@ public:
+ 	virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
+ 	virtual rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
+ 	virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException);
+-    virtual sal_Bool SAL_CALL getMultiSelect() throw (css::uno::RuntimeException);
+-    virtual void SAL_CALL setMultiSelect( sal_Bool _multiselect ) throw (css::uno::RuntimeException);
++    virtual ::sal_Int32 SAL_CALL getMultiSelect() throw (css::uno::RuntimeException);  //liuchen 2009-7-31
++    virtual void SAL_CALL setMultiSelect( ::sal_Int32 _multiselect ) throw (css::uno::RuntimeException); //liuchen 2009-7-31
+     virtual css::uno::Any SAL_CALL Selected( ::sal_Int32 index ) throw (css::uno::RuntimeException);
+ 
+ 	// Methods
+diff --git vbahelper/source/msforms/vbatextbox.cxx vbahelper/source/msforms/vbatextbox.cxx
+index d246970..eb1b393 100644
+--- vbahelper/source/msforms/vbatextbox.cxx
++++ vbahelper/source/msforms/vbatextbox.cxx
+@@ -93,7 +93,8 @@ ScVbaTextBox::getMaxLength() throw (css::uno::RuntimeException)
+ void SAL_CALL 
+ ScVbaTextBox::setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException)
+ {
+-    uno::Any aValue( _maxlength );
++	sal_Int16 _maxlength16 = static_cast<sal_Int16> (_maxlength); //liuchen 2009-7-24, resolve the problem that MaxLength cannot be set correctly
++    uno::Any aValue( _maxlength16 );                              //liuchen 2009-7-24, resolve the problem that MaxLength cannot be set correctly
+     m_xProps->setPropertyValue
+             (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxTextLen" ) ), aValue);
+ }
+diff --git vbahelper/source/msforms/vbatogglebutton.cxx vbahelper/source/msforms/vbatogglebutton.cxx
+index f938ad1..0d7cfaf 100644
+--- vbahelper/source/msforms/vbatogglebutton.cxx
++++ vbahelper/source/msforms/vbatogglebutton.cxx
+@@ -76,16 +76,33 @@ ScVbaToggleButton::getValue() throw (uno::RuntimeException)
+  	return uno::makeAny( nState ? sal_Int16( -1 ) : sal_Int16( 0 ) );
+ }
+ 
++//liuchen 2009-7-23, resolve the defect that ToggleButton.Value cannot be set correctly
+ void SAL_CALL 
+ ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
+ {
+ 	sal_Int16 nState = 0;
+-	_value >>= nState;
++	if (_value.getValueTypeClass() == typelib_TypeClass_BOOLEAN)
++	{
++		sal_Bool bValue;
++		_value >>= bValue;
++		nState = static_cast< sal_Int16 >(bValue);
++	}
++	else if (_value.getValueTypeClass() == typelib_TypeClass_BYTE)
++	{
++		sal_Int8 nValue;
++		_value >>= nValue;
++		nState = ( nValue == 1) ? 1 : 0;
++	}
++	else
++	{
++		_value >>= nState;
+         OSL_TRACE( "nState - %d", nState );
+-	nState = ( nState == -1 ) ?  1 : 0;
++		nState = ( nState == -1 ) ?  1 : 0;
+         OSL_TRACE( "nState - %d", nState );
++	}
+ 	m_xProps->setPropertyValue( STATE, uno::makeAny(  nState ) );
+ }
++//liuchen 2009-7-23
+ 
+ rtl::OUString& 
+ ScVbaToggleButton::getServiceImplName()
+diff --git vbahelper/source/vbahelper/vbapictureformat.cxx vbahelper/source/vbahelper/vbapictureformat.cxx
+index 2663682..3f4793a 100644
+--- vbahelper/source/vbahelper/vbapictureformat.cxx
++++ vbahelper/source/vbahelper/vbapictureformat.cxx
+@@ -115,13 +115,14 @@ ScVbaPictureFormat::IncrementContrast( double increment ) throw (uno::RuntimeExc
+ {
+     double nContrast = getContrast();
+     nContrast += increment;
+-    if( increment < 0 )
++	//VBA, minz at cn.ibm.com.
++    if( nContrast < 0 )
+     {
+-        increment = 0.0;
++        nContrast = 0.0;
+     }
+-    if( increment > 1 )
++    if( nContrast > 1 )
+     {
+-        increment = 1.0;
++        nContrast = 1.0;
+     }
+     setContrast( nContrast );
+ }
+diff --git vcl/inc/vcl/dialog.hxx vcl/inc/vcl/dialog.hxx
+index c765b2e..417093d 100644
+--- vcl/inc/vcl/dialog.hxx
++++ vcl/inc/vcl/dialog.hxx
+@@ -56,6 +56,7 @@ private:
+ 	BOOL			mbOldSaveBack;
+ 	BOOL			mbInClose;
+ 	BOOL			mbModalMode;
++	sal_Int8		mnCancelClose;  //liuchen 2009-7-22, support Excel VBA UserForm_QueryClose event
+ 
+ 	SAL_DLLPRIVATE void    ImplInitDialogData();
+ 	SAL_DLLPRIVATE void    ImplInitSettings();
+@@ -93,6 +94,9 @@ public:
+ 	virtual short	Execute();
+ 	BOOL			IsInExecute() const { return mbInExecute; }
+ 
++	sal_Int8		GetCloseFlag() const { return mnCancelClose; }  //liuchen 2009-7-22, support Excel VBA UserForm_QueryClose event
++	void			SetCloseFlag( sal_Int8 nCancel ) { mnCancelClose = nCancel; }  //liuchen 2009-7-22, support Excel VBA UserForm_QueryClose event
++
+     ////////////////////////////////////////
+     // Dialog::Execute replacement API
+ public:
+diff --git vcl/source/control/combobox.cxx vcl/source/control/combobox.cxx
+index f95887e..3fe2d5a 100644
+--- vcl/source/control/combobox.cxx
++++ vcl/source/control/combobox.cxx
+@@ -474,8 +474,11 @@ IMPL_LINK( ComboBox, ImplSelectHdl, void*, EMPTYARG )
+ 		mpSubEdit->SetModifyFlag();
+ 		mbSyntheticModify = TRUE;
+ 		Modify();
+-		mbSyntheticModify = FALSE;
+-		Select();
++		mbSyntheticModify = FALSE;		
++		if (ImplGetWindowImpl() != NULL) //liuchen 2009-7-28, resolve the problem that soffice get crashed if in ComboBox_Change event a Worksheets("SheetX").Activate sentence needs to be executed 
++		{
++			Select();
++		}
+ 	}
+ 
+ 	return 0;
+diff --git vcl/source/window/dialog.cxx vcl/source/window/dialog.cxx
+index f5395a9..f641adf 100644
+--- vcl/source/window/dialog.cxx
++++ vcl/source/window/dialog.cxx
+@@ -550,7 +550,14 @@ BOOL Dialog::Close()
+ {
+     ImplDelData aDelData;
+     ImplAddDel( &aDelData );
+-    ImplCallEventListeners( VCLEVENT_WINDOW_CLOSE );
++	//liuchen 2009-7-22, support Excel VBA UserForm_QueryClose event
++	mnCancelClose = 0;
++	ImplCallEventListeners( VCLEVENT_WINDOW_CLOSE );	
++	if (mnCancelClose == 1)
++	{
++		return FALSE;
++	}
++	//liuchen 2009-7-22
+     if ( aDelData.IsDelete() )
+         return FALSE;
+     ImplRemoveDel( &aDelData );


More information about the ooo-build-commit mailing list