[Libreoffice-commits] core.git: 44 commits - basic/source forms/source include/oox include/vbahelper oovbaapi/ooo oovbaapi/UnoApi_oovbaapi.mk oox/source sc/CppunitTest_sc_macros_test.mk sc/inc sc/qa scripting/source sc/source vbahelper/source

Noel Power noel.power at suse.com
Thu May 9 06:11:52 PDT 2013


 basic/source/runtime/methods.cxx                      |   22 ++++
 forms/source/misc/InterfaceContainer.cxx              |    3 
 include/oox/ole/vbacontrol.hxx                        |    3 
 include/vbahelper/vbadocumentbase.hxx                 |    2 
 include/vbahelper/vbareturntypes.hxx                  |   77 ++++++++++++++
 include/vbahelper/vbashape.hxx                        |    2 
 oovbaapi/UnoApi_oovbaapi.mk                           |    8 -
 oovbaapi/ooo/vba/XVBAToOOEventDescGen.idl             |    2 
 oovbaapi/ooo/vba/excel/XApplication.idl               |    6 -
 oovbaapi/ooo/vba/excel/XRange.idl                     |    2 
 oovbaapi/ooo/vba/excel/XWorkbook.idl                  |    6 +
 oovbaapi/ooo/vba/msforms/ReturnBoolean.idl            |   24 ----
 oovbaapi/ooo/vba/msforms/ReturnEffect.idl             |   25 ----
 oovbaapi/ooo/vba/msforms/ReturnInteger.idl            |   24 ----
 oovbaapi/ooo/vba/msforms/ReturnSingle.idl             |   24 ----
 oovbaapi/ooo/vba/msforms/XControl.idl                 |    5 
 oovbaapi/ooo/vba/msforms/XListBox.idl                 |    2 
 oovbaapi/ooo/vba/msforms/XReturnBoolean.idl           |   26 ++++
 oovbaapi/ooo/vba/msforms/XReturnEffect.idl            |   27 +++++
 oovbaapi/ooo/vba/msforms/XReturnInteger.idl           |   26 ++++
 oovbaapi/ooo/vba/msforms/XReturnSingle.idl            |   25 ++++
 oovbaapi/ooo/vba/msforms/XShape.idl                   |    1 
 oox/source/ole/vbacontrol.cxx                         |    1 
 sc/CppunitTest_sc_macros_test.mk                      |    3 
 sc/inc/rangelst.hxx                                   |    2 
 sc/inc/scmod.hxx                                      |    4 
 sc/qa/extras/macros-test.cxx                          |   36 ++++--
 sc/qa/extras/testdocuments/CheckOptionToggleValue.xls |binary
 sc/qa/extras/testdocuments/GeneratedEventTest.xls     |binary
 sc/qa/extras/testdocuments/MiscControlTests.xls       |binary
 sc/qa/extras/testdocuments/PageBreaks.xls             |binary
 sc/qa/extras/testdocuments/Ranges-3.xls               |binary
 sc/qa/extras/testdocuments/Ranges.xls                 |binary
 sc/qa/extras/testdocuments/Shapes.xls                 |binary
 sc/qa/extras/testdocuments/Workbooks.xls              |binary
 sc/source/core/tool/rangelst.cxx                      |    5 
 sc/source/ui/vba/vbaapplication.cxx                   |   74 +++++++++++++
 sc/source/ui/vba/vbaapplication.hxx                   |    8 +
 sc/source/ui/vba/vbaoleobject.cxx                     |    2 
 sc/source/ui/vba/vbapagebreaks.cxx                    |    7 -
 sc/source/ui/vba/vbarange.cxx                         |   97 ++++++++++++++++--
 sc/source/ui/vba/vbarange.hxx                         |    1 
 sc/source/ui/vba/vbaworkbook.cxx                      |   92 +++++++++++++++++
 sc/source/ui/vba/vbaworkbook.hxx                      |    2 
 scripting/source/vbaevents/eventhelper.cxx            |   51 +++++++--
 vbahelper/source/msforms/vbacheckbox.cxx              |   15 +-
 vbahelper/source/msforms/vbacombobox.cxx              |   12 ++
 vbahelper/source/msforms/vbacontrol.cxx               |   16 ++
 vbahelper/source/msforms/vbacontrol.hxx               |    2 
 vbahelper/source/msforms/vbalistbox.cxx               |   25 +++-
 vbahelper/source/msforms/vbalistbox.hxx               |    4 
 vbahelper/source/msforms/vbaradiobutton.cxx           |   15 +-
 vbahelper/source/msforms/vbatextbox.cxx               |   10 +
 vbahelper/source/msforms/vbatogglebutton.cxx          |   10 +
 vbahelper/source/msforms/vbauserform.cxx              |   18 +++
 vbahelper/source/msforms/vbauserform.hxx              |    2 
 vbahelper/source/vbahelper/vbadocumentbase.cxx        |   11 +-
 vbahelper/source/vbahelper/vbadocumentsbase.cxx       |    5 
 vbahelper/source/vbahelper/vbapictureformat.cxx       |   10 -
 vbahelper/source/vbahelper/vbashape.cxx               |   16 ++
 60 files changed, 708 insertions(+), 190 deletions(-)

New commits:
commit 959b25bc15a7778bb60386b346a40845ba399030
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 3 17:02:00 2013 +0100

    add simple Range.Name test
    
    Change-Id: I705e05878015f5c8aad993219ea89ea9d47f07fb

diff --git a/sc/qa/extras/testdocuments/Ranges-3.xls b/sc/qa/extras/testdocuments/Ranges-3.xls
index d58fb11..c23b70a 100644
Binary files a/sc/qa/extras/testdocuments/Ranges-3.xls and b/sc/qa/extras/testdocuments/Ranges-3.xls differ
commit b590a51bf37f5241ddb334a1886211fcbbba2c10
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 29 14:53:09 2013 +0100

    implement Range.Name
    
    Change-Id: I884f84e437dad9440951e60c8f92fd6487c48832

diff --git a/oovbaapi/ooo/vba/excel/XRange.idl b/oovbaapi/ooo/vba/excel/XRange.idl
index 5125ea6..eff93ee 100644
--- a/oovbaapi/ooo/vba/excel/XRange.idl
+++ b/oovbaapi/ooo/vba/excel/XRange.idl
@@ -43,6 +43,7 @@ interface XCharacters;
 interface XBorders;
 interface XValidation;
 interface XWorksheet;
+interface XName;
 
 interface XRange
 {
@@ -68,6 +69,7 @@ interface XRange
     [attribute] any ColumnWidth;
     [attribute, readonly ] any Width;
     [attribute, readonly] XWorksheet Worksheet;
+    [attribute, readonly] XName Name;
     [attribute] any RowHeight;
     [attribute, readonly ] any Height;
     [attribute, readonly ] any Top;
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 110512e..852fefa 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -161,6 +161,7 @@
 
 #include "vbaglobals.hxx"
 #include "vbastyle.hxx"
+#include "vbaname.hxx"
 #include <vector>
 #include <vbahelper/vbacollectionimpl.hxx>
 // begin test includes
@@ -4095,6 +4096,57 @@ ScVbaRange::getTop() throw (uno::RuntimeException)
     return uno::makeAny( lcl_hmmToPoints( aPoint.Y ) );
 }
 
+
+uno::Reference< sheet::XCellRangeReferrer > getNamedRange( const uno::Reference< uno::XInterface >& xIf, const uno::Reference< table::XCellRange >& thisRange )
+{
+    uno::Reference< beans::XPropertySet > xProps( xIf, uno::UNO_QUERY_THROW );
+    uno::Reference< container::XNameAccess > xNameAccess( xProps->getPropertyValue( "NamedRanges" ), uno::UNO_QUERY_THROW );
+
+    uno::Sequence< OUString > sNames = xNameAccess->getElementNames();
+//    uno::Reference< table::XCellRange > thisRange( getCellRange(), uno::UNO_QUERY_THROW );
+    uno::Reference< sheet::XCellRangeReferrer > xNamedRange;
+    for ( sal_Int32 i=0; i < sNames.getLength(); ++i )
+    {
+        uno::Reference< sheet::XCellRangeReferrer > xName( xNameAccess->getByName( sNames[ i ] ), uno::UNO_QUERY );
+        if ( xName.is() )
+        {
+            if ( thisRange == xName->getReferredCells() )
+            {
+                xNamedRange = xName;
+                break;
+            }
+        }
+    }
+    return xNamedRange;
+}
+
+uno::Reference< excel::XName >
+ScVbaRange::getName() throw (uno::RuntimeException)
+{
+    uno::Reference< beans::XPropertySet > xProps( getUnoModel(), uno::UNO_QUERY );
+    uno::Reference< table::XCellRange > thisRange( getCellRange(), uno::UNO_QUERY_THROW );
+    // Application range
+    uno::Reference< sheet::XCellRangeReferrer > xNamedRange = getNamedRange( xProps, thisRange );
+
+    if ( !xNamedRange.is() )
+    {
+        // not in application range then assume it might be in
+        // sheet namedranges
+        RangeHelper aRange( thisRange );
+        uno::Reference< sheet::XSpreadsheet > xSheet = aRange.getSpreadSheet();
+        xProps.set( xSheet, uno::UNO_QUERY );
+        // impl here
+        xNamedRange = getNamedRange( xProps, thisRange );
+    }
+    if ( xProps.is() && xNamedRange.is() )
+    {
+        uno::Reference< sheet::XNamedRanges > xNamedRanges( xProps, uno::UNO_QUERY_THROW );
+        uno::Reference< sheet::XNamedRange > xName( xNamedRange, uno::UNO_QUERY_THROW );
+        return new ScVbaName( mxParent, mxContext, xName, xNamedRanges, getUnoModel() );
+    }
+    return uno::Reference< excel::XName >();
+}
+
 uno::Reference< excel::XWorksheet >
 ScVbaRange::getWorksheet() throw (uno::RuntimeException)
 {
diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx
index 3459f52..9f1166a 100644
--- a/sc/source/ui/vba/vbarange.hxx
+++ b/sc/source/ui/vba/vbarange.hxx
@@ -183,6 +183,7 @@ public:
     virtual css::uno::Any SAL_CALL getTop() throw (css::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL getLeft() throw (css::uno::RuntimeException);
 
+    virtual css::uno::Reference< ov::excel::XName > SAL_CALL getName() throw (css::uno::RuntimeException);
     virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getWorksheet() throw (css::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL getPageBreak() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setPageBreak( const css::uno::Any& _pagebreak ) throw (css::uno::RuntimeException);
commit a667ce82bfca1c469d37b7e7c974b3146faefa88
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 3 16:14:03 2013 +0100

    stub implementation(s) for Application EnableCancelKey & International
    
    Change-Id: I810897b3981390fc39e59d9c8a4c0095547a407a

diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl
index 183db97..4e8c185 100644
--- a/oovbaapi/ooo/vba/excel/XApplication.idl
+++ b/oovbaapi/ooo/vba/excel/XApplication.idl
@@ -56,6 +56,7 @@ interface XApplication
     [attribute] any StatusBar;
     [attribute] long Cursor;
     [attribute] boolean EnableEvents;
+    [attribute] boolean EnableCancelKey;
     [attribute] boolean DisplayFullScreen;
     [attribute] boolean DisplayScrollBars;
     [attribute] boolean DisplayExcel4Menus;
@@ -70,7 +71,7 @@ interface XApplication
 
     string getDefaultFilePath() raises(com::sun::star::script::BasicErrorException);
 
-    //any CommandBars( [in] any Index );
+    any International( [in] long Index );
     any Workbooks( [in] any Index );
     any Worksheets( [in] any Index );
     any Windows( [in] any Index );
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 4885ce3..9db16fb 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -117,6 +117,7 @@ struct ScVbaAppSettings
     sal_Bool mbExcel4Menus;
     sal_Bool mbDisplayNoteIndicator;
     sal_Bool mbShowWindowsInTaskbar;
+    sal_Bool mbEnableCancelKey;
     explicit ScVbaAppSettings();
 };
 
@@ -126,7 +127,8 @@ ScVbaAppSettings::ScVbaAppSettings() :
     mbEnableEvents( sal_True ),
     mbExcel4Menus( sal_False ),
     mbDisplayNoteIndicator( sal_True ),
-    mbShowWindowsInTaskbar( sal_True )
+    mbShowWindowsInTaskbar( sal_True ),
+    mbEnableCancelKey( sal_False )
 {
 }
 
@@ -325,6 +327,15 @@ ScVbaApplication::getActiveCell() throw (uno::RuntimeException )
 }
 
 uno::Any SAL_CALL
+ScVbaApplication::International( sal_Int32 Index ) throw (uno::RuntimeException)
+{
+    // complete stub for now
+    // #TODO flesh out some of the Indices we could handle
+    uno::Any aRet;
+    return aRet;
+}
+
+uno::Any SAL_CALL
 ScVbaApplication::Workbooks( const uno::Any& aIndex ) throw (uno::RuntimeException)
 {
     uno::Reference< XCollection > xWorkBooks( new ScVbaWorkbooks( this, mxContext ) );
@@ -742,6 +753,19 @@ ScVbaApplication::getEnableEvents() throw (uno::RuntimeException)
     return mrAppSettings.mbEnableEvents;
 }
 
+void SAL_CALL
+ScVbaApplication::setEnableCancelKey(sal_Bool bEnable) throw (uno::RuntimeException)
+{
+    // Stub, does nothing
+    mrAppSettings.mbEnableCancelKey = bEnable;
+}
+
+sal_Bool SAL_CALL
+ScVbaApplication::getEnableCancelKey() throw (uno::RuntimeException)
+{
+    return mrAppSettings.mbEnableCancelKey;
+}
+
 sal_Bool SAL_CALL
 ScVbaApplication::getDisplayFullScreen()  throw (uno::RuntimeException)
 {
diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx
index 0b09a78..105b201 100644
--- a/sc/source/ui/vba/vbaapplication.hxx
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -85,6 +85,7 @@ public:
 
     virtual css::uno::Reference< ov::XAssistant > SAL_CALL getAssistant() throw (css::uno::RuntimeException);
     virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getThisWorkbook() throw (css::uno::RuntimeException);
+    virtual css::uno::Any SAL_CALL International( sal_Int32 Index ) 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);
     virtual css::uno::Any SAL_CALL WorksheetFunction( ) throw (css::uno::RuntimeException);
@@ -99,6 +100,8 @@ public:
     virtual void SAL_CALL OnKey( const OUString& Key, const css::uno::Any& Procedure ) throw (css::uno::RuntimeException);
     virtual sal_Bool SAL_CALL getEnableEvents() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setEnableEvents( sal_Bool bEnable ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getEnableCancelKey() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setEnableCancelKey( sal_Bool bEnable ) throw (css::uno::RuntimeException);
 
     virtual sal_Bool SAL_CALL getDisplayFullScreen() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setDisplayFullScreen( sal_Bool bSet ) throw (css::uno::RuntimeException);
commit ea558e4f50596d53c017e145b25de06776fa5680
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 3 15:47:12 2013 +0100

    implement Application.Iteration & Application.InchesToPoints
    
    Change-Id: I8d556a7a357fd7ad228a4fe95a54d6685a20e002

diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl
index d0c346b..183db97 100644
--- a/oovbaapi/ooo/vba/excel/XApplication.idl
+++ b/oovbaapi/ooo/vba/excel/XApplication.idl
@@ -61,6 +61,7 @@ interface XApplication
     [attribute] boolean DisplayExcel4Menus;
     [attribute] boolean DisplayNoteIndicator;
     [attribute] boolean ShowWindowsInTaskbar;
+    [attribute] boolean Iteration;
     [attribute, readonly] string LibraryPath;
     [attribute, readonly] string TemplatesPath;
     [attribute, readonly] string PathSeparator;
@@ -86,6 +87,7 @@ interface XApplication
         raises(com::sun::star::script::BasicErrorException);
     XRange Union([in] XRange Arg1, [in] XRange Arg2, [in] /*Optional*/ any Arg3, [in] /*Optional*/ any Arg4, [in] /*Optional*/ any Arg5, [in] /*Optional*/ any Arg6, [in] /*Optional*/ any Arg7, [in] /*Optional*/ any Arg8, [in] /*Optional*/ any Arg9, [in] /*Optional*/ any Arg10, [in] /*Optional*/ any Arg11, [in] /*Optional*/ any Arg12, [in] /*Optional*/ any Arg13, [in] /*Optional*/ any Arg14, [in] /*Optional*/ any Arg15, [in] /*Optional*/ any Arg16, [in] /*Optional*/ any Arg17, [in] /*Optional*/ any Arg18, [in] /*Optional*/ any Arg19, [in] /*Optional*/ any Arg20, [in] /*Optional*/ any Arg21, [in] /*Optional*/ any Arg22, [in] /*Optional*/ any Arg23, [in] /*Optional*/ any Arg24, [in] /*Optional*/ any Arg25, [in] /*Optional*/ any Arg26, [in] /*Optional*/ any Arg27, [in] /*Optional*/ any Arg28, [in] /*Optional*/ any Arg29, [in] /*Optional*/ any Arg30)
         raises(com::sun::star::script::BasicErrorException);
+    double InchesToPoints( [in] double Inches );
     void Volatile([in] any Volatile);
     any Caller( [in] any Index );
     any MenuBars( [in] any aIndex );
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index bb2462f..5f2e61a 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -170,14 +170,14 @@ public:
 
     // Options:
     const ScViewOptions&    GetViewOptions  ();
-    const ScDocOptions&     GetDocOptions   ();
+SC_DLLPUBLIC    const ScDocOptions&     GetDocOptions   ();
 SC_DLLPUBLIC    const ScAppOptions&     GetAppOptions   ();
 SC_DLLPUBLIC    const ScDefaultsOptions&   GetDefaultsOptions ();
     SC_DLLPUBLIC const ScFormulaOptions&   GetFormulaOptions ();
     const ScInputOptions&   GetInputOptions ();
 SC_DLLPUBLIC    const ScPrintOptions&   GetPrintOptions ();
     void                    SetViewOptions  ( const ScViewOptions& rOpt );
-    void                    SetDocOptions   ( const ScDocOptions& rOpt );
+SC_DLLPUBLIC    void                    SetDocOptions   ( const ScDocOptions& rOpt );
 SC_DLLPUBLIC    void                    SetAppOptions   ( const ScAppOptions& rOpt );
     void                    SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
     SC_DLLPUBLIC void                    SetFormulaOptions ( const ScFormulaOptions& rOpt );
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 3175f65..4885ce3 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
 #include <com/sun/star/sheet/XCalculatable.hpp>
 #include <com/sun/star/frame/XLayoutManager.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
 #include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
 #include <com/sun/star/task/XStatusIndicator.hpp>
 #include <ooo/vba/excel/XlMousePointer.hpp>
@@ -90,6 +91,7 @@
 #include <basic/sbxobj.hxx>
 
 #include "viewutil.hxx"
+#include "docoptio.hxx"
 
 using namespace ::ooo::vba;
 using namespace ::com::sun::star;
@@ -815,6 +817,36 @@ ScVbaApplication::setShowWindowsInTaskbar( sal_Bool bSet ) throw (css::uno::Runt
     mrAppSettings.mbShowWindowsInTaskbar = bSet;
 }
 
+sal_Bool SAL_CALL
+ScVbaApplication::getIteration() throw (css::uno::RuntimeException)
+{
+    return SC_MOD()->GetDocOptions().IsIter();
+}
+
+void SAL_CALL
+ScVbaApplication::setIteration( sal_Bool bSet ) throw (css::uno::RuntimeException)
+{
+    uno::Reference< lang::XMultiComponentFactory > xSMgr(
+        mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
+
+    uno::Reference< frame::XDesktop > xDesktop
+        (xSMgr->createInstanceWithContext( "com.sun.star.frame.Desktop" , mxContext), uno::UNO_QUERY_THROW );
+    uno::Reference< container::XEnumeration > xComponents = xDesktop->getComponents()->createEnumeration();
+    while ( xComponents->hasMoreElements() )
+    {
+        uno::Reference< lang::XServiceInfo > xServiceInfo( xComponents->nextElement(), uno::UNO_QUERY );
+        if ( xServiceInfo.is() && xServiceInfo->supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+        {
+            uno::Reference< beans::XPropertySet > xProps( xServiceInfo, uno::UNO_QUERY );
+            if ( xProps.is() )
+                xProps->setPropertyValue(  SC_UNO_ITERENABLED, uno::Any( bSet ) );
+        }
+    }
+    ScDocOptions aOpts( SC_MOD()->GetDocOptions() );
+    aOpts.SetIter( bSet );
+    SC_MOD()->SetDocOptions( aOpts );
+}
+
 void SAL_CALL
 ScVbaApplication::Calculate() throw(  script::BasicErrorException , uno::RuntimeException )
 {
@@ -1174,6 +1206,13 @@ uno::Reference< excel::XRange > SAL_CALL ScVbaApplication::Union(
     return lclCreateVbaRange( mxContext, getCurrentDocument(), aList );
 }
 
+double
+ScVbaApplication::InchesToPoints( double Inches ) throw (uno::RuntimeException )
+{
+   double result = ( Inches * 72.0 );
+   return result;
+}
+
 void
 ScVbaApplication::Volatile( const uno::Any& aVolatile )  throw ( uno::RuntimeException )
 {
diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx
index 3866403..0b09a78 100644
--- a/sc/source/ui/vba/vbaapplication.hxx
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -111,6 +111,9 @@ public:
     virtual void SAL_CALL setDisplayNoteIndicator( sal_Bool bSet ) throw (css::uno::RuntimeException);
     virtual sal_Bool SAL_CALL getShowWindowsInTaskbar() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setShowWindowsInTaskbar( sal_Bool bSet ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getIteration() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setIteration( sal_Bool bSet ) throw (css::uno::RuntimeException);
+
     virtual css::uno::Any SAL_CALL Windows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
     virtual void SAL_CALL wait( double time ) throw (css::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL Range( const css::uno::Any& Cell1, const css::uno::Any& Cell2 ) throw (css::uno::RuntimeException);
@@ -119,12 +122,13 @@ public:
     virtual void SAL_CALL Calculate() throw (css::script::BasicErrorException, css::uno::RuntimeException);
     virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicError
 Exception, css::uno::RuntimeException);
     virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorExce
 ption, css::uno::RuntimeException);
+    virtual double SAL_CALL InchesToPoints( double InchesToPoints ) throw (css::uno::RuntimeException );
     virtual void SAL_CALL Volatile( const css::uno::Any& Volatile ) throw (css::uno::RuntimeException );
     virtual css::uno::Any SAL_CALL MenuBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL Caller( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL GetOpenFilename( const css::uno::Any& rFileFilter, const css::uno::Any& rFilterIndex, const css::uno::Any& rTitle, const css::uno::Any& rButtonText, const css::uno::Any& rMultiSelect ) throw (css::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL GetSaveAsFilename( const css::uno::Any& rInitialFileName, const css::uno::Any& rFileFilter, const css::uno::Any& rFilterIndex, const css::uno::Any& rTitle, const css::uno::Any& rButtonText ) throw (css::uno::RuntimeException);
-    virtual void Undo() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL Undo() throw (css::uno::RuntimeException);
     // XHelperInterface
     virtual OUString getServiceImplName();
     virtual css::uno::Sequence<OUString> getServiceNames();
commit c087feeefb49e8d9cfe7bd1d374fa52d97fd87c3
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 3 15:32:29 2013 +0100

    implement Application.Undo
    
    Change-Id: Ibba3c5e2c617daea70fb75b3235636620a46f9ff

diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl
index d5c48a7..d0c346b 100644
--- a/oovbaapi/ooo/vba/excel/XApplication.idl
+++ b/oovbaapi/ooo/vba/excel/XApplication.idl
@@ -89,6 +89,7 @@ interface XApplication
     void Volatile([in] any Volatile);
     any Caller( [in] any Index );
     any MenuBars( [in] any aIndex );
+    void Undo();
 };
 
 }; }; };
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index a15aeff..3175f65 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -1309,6 +1309,15 @@ void SAL_CALL ScVbaApplication::OnKey( const OUString& Key, const uno::Any& Proc
     }
 }
 
+void SAL_CALL ScVbaApplication::Undo() throw (uno::RuntimeException)
+{
+    uno::Reference< frame::XModel > xModel( getThisExcelDoc( mxContext ), uno::UNO_SET_THROW );
+
+    ScTabViewShell* pViewShell = excel::getBestViewShell( xModel );
+    if ( pViewShell )
+        dispatchExecute( pViewShell, SID_UNDO );
+}
+
 OUString
 ScVbaApplication::getServiceImplName()
 {
diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx
index 1991714..3866403 100644
--- a/sc/source/ui/vba/vbaapplication.hxx
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -124,6 +124,7 @@ public:
     virtual css::uno::Any SAL_CALL Caller( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL GetOpenFilename( const css::uno::Any& rFileFilter, const css::uno::Any& rFilterIndex, const css::uno::Any& rTitle, const css::uno::Any& rButtonText, const css::uno::Any& rMultiSelect ) throw (css::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL GetSaveAsFilename( const css::uno::Any& rInitialFileName, const css::uno::Any& rFileFilter, const css::uno::Any& rFilterIndex, const css::uno::Any& rTitle, const css::uno::Any& rButtonText ) throw (css::uno::RuntimeException);
+    virtual void Undo() throw (css::uno::RuntimeException);
     // XHelperInterface
     virtual OUString getServiceImplName();
     virtual css::uno::Sequence<OUString> getServiceNames();
commit 894a0348dc86f60b35d48e51eea9cc465750b494
Author: Noel Power <noel.power at suse.com>
Date:   Thu Apr 25 17:10:46 2013 +0100

    fix VBA mode MkDir when passed folder is not a full path
    
    Change-Id: I7fd804999f1b96e6aab112445edcd9dcf7753c24

diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 9e1b3ba..19d52a8 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -641,6 +641,28 @@ RTLFUNC(MkDir)
     if (rPar.Count() == 2)
     {
         OUString aPath = rPar.Get(1)->GetOUString();
+        if ( SbiRuntime::isVBAEnabled() )
+        {
+            // In vba if the full path is not specified then
+            // folder is created relative to the curdir
+            INetURLObject aURLObj( getFullPath( aPath ) );
+            if ( aURLObj.GetProtocol() != INET_PROT_FILE )
+            {
+                SbxArrayRef pPar = new SbxArray();
+                SbxVariableRef pResult = new SbxVariable();
+                SbxVariableRef pParam = new SbxVariable();
+                pPar->Insert( pResult, pPar->Count() );
+                pPar->Insert( pParam, pPar->Count() );
+                SbRtl_CurDir( pBasic, *pPar, bWrite );
+
+                rtl::OUString sCurPathURL;
+                File::getFileURLFromSystemPath( pPar->Get(0)->GetOUString(), sCurPathURL );
+
+                aURLObj.SetURL( sCurPathURL );
+                aURLObj.Append( aPath );
+                File::getSystemPathFromFileURL(aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI  ),aPath ) ;
+            }
+        }
 
         if( hasUno() )
         {
commit 880da6c7b7ea950799bb43f2bc107da4c2f07a6c
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 3 15:14:26 2013 +0100

    fix userform data aware control import
    
    Change-Id: I86f5cc0c60bba48eaaf40a3471cc0fb22e5e4b9c

diff --git a/include/oox/ole/vbacontrol.hxx b/include/oox/ole/vbacontrol.hxx
index 0de8015..e31ee43 100644
--- a/include/oox/ole/vbacontrol.hxx
+++ b/include/oox/ole/vbacontrol.hxx
@@ -73,7 +73,8 @@ public:
                             const ControlConverter& rConv,
                             ApiControlType eCtrlType,
                             sal_Int32 nCtrlIndex ) const;
-
+    inline ::rtl::OUString getControlSource() { return  maControlSource; }
+    inline ::rtl::OUString getRowSource() { return  maRowSource; }
 protected:
     OUString     maName;             ///< Name of the control.
     OUString     maTag;              ///< User defined tag.
diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx
index 073f64e..6ce6615 100644
--- a/oox/source/ole/vbacontrol.cxx
+++ b/oox/source/ole/vbacontrol.cxx
@@ -493,6 +493,7 @@ bool VbaFormControl::convertProperties( const Reference< XControlModel >& rxCtrl
             // convert all properties
             PropertyMap aPropMap;
             mxSiteModel->convertProperties( aPropMap, rConv, mxCtrlModel->getControlType(), nCtrlIndex );
+            rConv.bindToSources( rxCtrlModel, mxSiteModel->getControlSource(), mxSiteModel->getRowSource() );
             mxCtrlModel->convertProperties( aPropMap, rConv );
             mxCtrlModel->convertSize( aPropMap, rConv );
             PropertySet aPropSet( rxCtrlModel );
commit f1c6bebcadfbf2c32b0295bafb128fe15d70b2ba
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 3 15:10:46 2013 +0100

    add some Range.value tests
    
    Change-Id: I4800ad80f1b447cae03664653285f1917ad3ee7e

diff --git a/sc/qa/extras/testdocuments/Ranges-3.xls b/sc/qa/extras/testdocuments/Ranges-3.xls
index e68f6a8..d58fb11 100644
Binary files a/sc/qa/extras/testdocuments/Ranges-3.xls and b/sc/qa/extras/testdocuments/Ranges-3.xls differ
commit 8cfc390a42097cf1b98896a62c70e1fb27fdc89b
Author: Noel Power <noel.power at suse.com>
Date:   Thu Apr 25 12:36:17 2013 +0100

    reset Logical format when setting a number value via Range vba api
    
    Change-Id: I0f9a68228c9cb6425b1d139744a92c4a3d4c6012

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 276cba8..110512e 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -782,7 +782,16 @@ CellValueSetter::processValue( const uno::Any& aValue, const uno::Reference< tab
         {
             double nDouble = 0.0;
             if ( aValue >>= nDouble )
+            {
+                uno::Reference< table::XCellRange > xRange( xCell, uno::UNO_QUERY_THROW );
+                NumFormatHelper cellFormat( xRange );
+                // If we are setting a number and the cell types was logical
+                // then we need to reset the logical format. ( see case uno::TypeClass_BOOLEAN:
+                // handling above )
+                if ( cellFormat.isBooleanType() )
+                    cellFormat.setNumberFormat("General");
                 xCell->setValue( nDouble );
+            }
             else
                 isExtracted = false;
             break;
commit 2f3359dbe86ad5b64b1c8e5c41b2fec3be9242a5
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 3 14:21:10 2013 +0100

    fix memory leak with orphaned controls created on the fly

diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx
index 43253b8..3a1361d 100644
--- a/forms/source/misc/InterfaceContainer.cxx
+++ b/forms/source/misc/InterfaceContainer.cxx
@@ -149,7 +149,8 @@ void OInterfaceContainer::impl_addVbEvents_nolck_nothrow(  const sal_Int32 i_nIn
             xProps->getPropertyValue( OUString("DefaultControl") ) >>= sServiceName;
 
             Reference< ooo::vba::XVBAToOOEventDescGen > xDescSupplier( m_xServiceFactory->createInstance( OUString("ooo.vba.VBAToOOEventDesc") ), UNO_QUERY_THROW );
-            Sequence< ScriptEventDescriptor > vbaEvents = xDescSupplier->getEventDescriptions( m_xServiceFactory->createInstance( sServiceName ), sCodeName );
+            Sequence< ScriptEventDescriptor > vbaEvents = xDescSupplier->getEventDescriptions( sServiceName , sCodeName );
+
             // register the vba script events
             m_xEventAttacher->registerScriptEvents( i_nIndex, vbaEvents );
         }
diff --git a/oovbaapi/ooo/vba/XVBAToOOEventDescGen.idl b/oovbaapi/ooo/vba/XVBAToOOEventDescGen.idl
index 5dd6dbb..dd92553 100644
--- a/oovbaapi/ooo/vba/XVBAToOOEventDescGen.idl
+++ b/oovbaapi/ooo/vba/XVBAToOOEventDescGen.idl
@@ -24,7 +24,7 @@
 module ooo {  module vba {
 interface XVBAToOOEventDescGen : com::sun::star::uno::XInterface
 {
-    sequence< com::sun::star::script::ScriptEventDescriptor >  getEventDescriptions( [in] com::sun::star::uno::XInterface xControl, [in] string sCodeName );
+    sequence< com::sun::star::script::ScriptEventDescriptor >  getEventDescriptions( [in] string controlServiceName, [in] string sCodeName );
     com::sun::star::script::XScriptEventsSupplier getEventSupplier( [in] com::sun::star::uno::XInterface xControl, [in] string sCodeName );
 };
 
diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx
index 207973c..5061fe8 100644
--- a/scripting/source/vbaevents/eventhelper.cxx
+++ b/scripting/source/vbaevents/eventhelper.cxx
@@ -314,11 +314,14 @@ class ScriptEventHelper
 {
 public:
     ScriptEventHelper( const Reference< XInterface >& xControl );
+    ScriptEventHelper( const OUString& sCntrlServiceName );
+    ~ScriptEventHelper();
     Sequence< ScriptEventDescriptor > createEvents( const OUString& sCodeName );
     Sequence< OUString > getEventListeners();
 private:
     Reference< XComponentContext > m_xCtx;
     Reference< XInterface > m_xControl;
+    bool m_bDispose;
 };
 
 bool
@@ -363,11 +366,36 @@ eventMethodToDescriptor( const OUString& rEventMethod, ScriptEventDescriptor& ev
 
 }
 
-ScriptEventHelper::ScriptEventHelper( const Reference< XInterface >& xControl ):
+ScriptEventHelper::ScriptEventHelper( const Reference< XInterface >& xControl ) :
     m_xCtx( comphelper::getProcessComponentContext() ),
-    m_xControl( xControl )
+    m_xControl( xControl ),
+    m_bDispose( false )
 {}
 
+ScriptEventHelper::ScriptEventHelper( const OUString& sCntrlServiceName ) :
+    m_xCtx( comphelper::getProcessComponentContext() ),
+    m_bDispose( true )
+{
+   m_xControl.set( m_xCtx->getServiceManager()->createInstanceWithContext( sCntrlServiceName, m_xCtx ), uno::UNO_QUERY );
+}
+
+ScriptEventHelper::~ScriptEventHelper()
+{
+    // dispose control ( and remove any associated event registrations )
+    if ( m_bDispose )
+    {
+        try
+        {
+            uno::Reference< lang::XComponent > xComp( m_xControl, uno::UNO_QUERY_THROW );
+            xComp->dispose();
+        }
+        // destructor can't throw
+        catch( uno::Exception& )
+        {
+        }
+    }
+}
+
 Sequence< OUString >
 ScriptEventHelper::getEventListeners()
 {
@@ -1002,7 +1030,7 @@ public:
     VBAToOOEventDescGen( const Reference< XComponentContext >& rxContext );
 
     // XVBAToOOEventDescGen
-    virtual Sequence< ScriptEventDescriptor > SAL_CALL getEventDescriptions( const Reference< XInterface >& control, const OUString& sCodeName ) throw (RuntimeException);
+    virtual Sequence< ScriptEventDescriptor > SAL_CALL getEventDescriptions( const OUString& sCtrlServiceName, const OUString& sCodeName ) throw (RuntimeException);
     virtual Reference< XScriptEventsSupplier > SAL_CALL getEventSupplier( const Reference< XInterface >& xControl,  const OUString& sCodeName ) throw (::com::sun::star::uno::RuntimeException);
 private:
     Reference< XComponentContext > m_xContext;
@@ -1012,9 +1040,9 @@ private:
 VBAToOOEventDescGen::VBAToOOEventDescGen( const Reference< XComponentContext >& rxContext ):m_xContext( rxContext ) {}
 
 Sequence< ScriptEventDescriptor > SAL_CALL
-VBAToOOEventDescGen::getEventDescriptions( const Reference< XInterface >& xControl, const OUString& sCodeName ) throw (RuntimeException)
+VBAToOOEventDescGen::getEventDescriptions( const OUString& sCntrlServiceName, const OUString& sCodeName ) throw (RuntimeException)
 {
-    ScriptEventHelper evntHelper( xControl );
+    ScriptEventHelper evntHelper( sCntrlServiceName );
     return evntHelper.createEvents( sCodeName );
 }
 
commit 7e735236e93754078dffa0c5c85316be87a5ce9f
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 3 14:08:25 2013 +0100

    add new test for Workbooks
    
    Change-Id: Id271f10ac82ebae9fedd68d30c7f44435d60751d

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index a610217..9fc8147 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -175,8 +175,21 @@ void ScMacrosTest::testVba()
             OUString("MiscControlTests."),
             OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
         },
+        {
+            OUString("Workbooks."),
+            OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
+        },
     };
-
+    OUString sTempDir;
+    OUString sTempDirURL;
+    osl::FileBase:: getTempDirURL( sTempDirURL );
+    osl::FileBase::getSystemPathFromFileURL( sTempDirURL, sTempDir );
+    Sequence< uno::Any > aParams;
+    if ( !sTempDir.isEmpty() )
+    {
+        aParams.realloc(1);
+        aParams[ 0 ] <<= sTempDir;
+    }
     for ( sal_uInt32  i=0; i<SAL_N_ELEMENTS( testInfo ); ++i )
     {
         OUString aFileName;
@@ -189,8 +202,6 @@ void ScMacrosTest::testVba()
         Any aRet;
         Sequence< sal_Int16 > aOutParamIndex;
         Sequence< Any > aOutParam;
-        Sequence< uno::Any > aParams;
-
         SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
 
         CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
diff --git a/sc/qa/extras/testdocuments/Workbooks.xls b/sc/qa/extras/testdocuments/Workbooks.xls
new file mode 100755
index 0000000..a732167
Binary files /dev/null and b/sc/qa/extras/testdocuments/Workbooks.xls differ
commit 569c019883f0c1bb624d2dddb12914facd30e82b
Author: Noel Power <noel.power at suse.com>
Date:   Wed Apr 24 17:59:49 2013 +0100

    add Workbook.Save method
    
    has limited support for paramaters ( only FileName and Format are processed )
    
    Change-Id: I669f264679101ab3697dfaa3a3fb3b2d75f5a14b

diff --git a/oovbaapi/ooo/vba/excel/XWorkbook.idl b/oovbaapi/ooo/vba/excel/XWorkbook.idl
index 76eaf2a..852ac69 100644
--- a/oovbaapi/ooo/vba/excel/XWorkbook.idl
+++ b/oovbaapi/ooo/vba/excel/XWorkbook.idl
@@ -52,6 +52,12 @@ interface XWorkbook
     any Colors( [in] any Index ) raises (com::sun::star::script::BasicErrorException);
     void SaveCopyAs( [in] string Filename );
     void Protect( [in] any Password );
+    void SaveAs( [in] any FileName, [in] any FileFormat, [in] any Password,
+                 [in] any WriteResPassword, [in] any ReadOnlyRecommended,
+                 [in] any CreateBackup, [in] any AccessMode,
+                 [in] any ConflictResolution, [in] any AddToMru,
+                 [in] any TextCodepage, [in] any TextVisualLayout,
+                 [in] any Local );
 };
 
 }; }; };
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index 96aa205..2df0bde 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <ooo/vba/excel/XlFileFormat.hpp>
+#include <ooo/vba/excel/XApplication.hpp>
 
 #include "scextopt.hxx"
 #include "vbaworksheet.hxx"
@@ -93,6 +94,48 @@ ScVbaWorkbook::Colors( const ::uno::Any& Index ) throw (::script::BasicErrorExce
     return aRet;
 }
 
+bool ScVbaWorkbook::setFilterPropsFromFormat( sal_Int32 nFormat, uno::Sequence< beans::PropertyValue >& rProps )
+{
+    bool bRes = false;
+    for ( sal_Int32 index = 0; index < rProps.getLength(); ++index )
+    {
+        if ( rProps[ index ].Name == "FilterName" )
+        {
+            switch( nFormat )
+            {
+                case excel::XlFileFormat::xlCSV:
+                    rProps[ index ].Value = uno::Any( OUString("Text - txt - csv (StarCalc)") );
+                    break;
+                case excel::XlFileFormat::xlDBF4:
+                    rProps[ index ].Value = uno::Any( OUString("DBF") );
+                    break;
+                case excel::XlFileFormat::xlDIF:
+                    rProps[ index ].Value = uno::Any( OUString("DIF") );
+                    break;
+                case excel::XlFileFormat::xlWK3:
+                    rProps[ index ].Value = uno::Any( OUString("Lotus") );
+                    break;
+                case excel::XlFileFormat::xlExcel4Workbook:
+                    rProps[ index ].Value = uno::Any( OUString("MS Excel 4.0") );
+                    break;
+                case excel::XlFileFormat::xlExcel5:
+                    rProps[ index ].Value = uno::Any( OUString("MS Excel 5.0/95") );
+                    break;
+                case excel::XlFileFormat::xlHtml:
+                    rProps[ index ].Value = uno::Any( OUString("HTML (StarCalc)") );
+                    break;
+                case excel::XlFileFormat::xlExcel9795:
+                default:
+                    rProps[ index ].Value = uno::Any( OUString("MS Excel 97") );
+                    break;
+            }
+            bRes = true;
+            break;
+        }
+    }
+    return bRes;
+}
+
 ::sal_Int32 SAL_CALL
 ScVbaWorkbook::getFileFormat(  ) throw (::uno::RuntimeException)
 {
@@ -262,6 +305,55 @@ ScVbaWorkbook::SaveCopyAs( const OUString& sFileName ) throw ( uno::RuntimeExcep
     xStor->storeToURL( aURL, storeProps );
 }
 
+void SAL_CALL
+ScVbaWorkbook::SaveAs( const uno::Any& FileName, const uno::Any& FileFormat, const uno::Any& /*Password*/, const uno::Any& /*WriteResPassword*/, const uno::Any& /*ReadOnlyRecommended*/, const uno::Any& /*CreateBackup*/, const uno::Any& /*AccessMode*/, const uno::Any& /*ConflictResolution*/, const uno::Any& /*AddToMru*/, const uno::Any& /*TextCodepage*/, const uno::Any& /*TextVisualLayout*/, const uno::Any& /*Local*/ )
+{
+    OUString sFileName;
+    FileName >>= sFileName;
+    OUString sURL;
+    osl::FileBase::getFileURLFromSystemPath( sFileName, sURL );
+    // detect if there is no path if there is no path then we need
+    // to use the current current folder
+    INetURLObject aURL( sURL );
+    sURL = aURL.GetMainURL( INetURLObject::DECODE_TO_IURI );
+    if( sURL.isEmpty() )
+    {
+        // need to add cur dir ( of this workbook ) or else the 'Work' dir
+        sURL = getModel()->getURL();
+
+        if ( sURL.isEmpty() )
+        {
+            // not path available from 'this' document
+            // need to add the 'document'/work directory then
+            uno::Reference< excel::XApplication > xApplication ( Application(),uno::UNO_QUERY_THROW );
+            OUString sWorkPath = xApplication->getDefaultFilePath();
+            OUString sWorkURL;
+            osl::FileBase::getFileURLFromSystemPath( sWorkPath, sWorkURL );
+            aURL.SetURL( sWorkURL );
+        }
+        else
+        {
+            aURL.SetURL( sURL );
+            aURL.Append( sFileName );
+        }
+        sURL = aURL.GetMainURL( INetURLObject::DECODE_TO_IURI );
+
+    }
+
+    sal_Int32 nFileFormat = excel::XlFileFormat::xlExcel9795;
+    FileFormat >>= nFileFormat;
+
+    uno::Sequence<  beans::PropertyValue > storeProps(1);
+    storeProps[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterName" ) );
+
+    setFilterPropsFromFormat( nFileFormat, storeProps );
+
+    uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
+    OUString sFilterName;
+    storeProps[0].Value >>= sFilterName;
+    xStor->storeAsURL( sURL, storeProps );
+}
+
 css::uno::Any SAL_CALL
 ScVbaWorkbook::Styles( const uno::Any& Item ) throw (uno::RuntimeException)
 {
diff --git a/sc/source/ui/vba/vbaworkbook.hxx b/sc/source/ui/vba/vbaworkbook.hxx
index 7288d2a..c2e367a 100644
--- a/sc/source/ui/vba/vbaworkbook.hxx
+++ b/sc/source/ui/vba/vbaworkbook.hxx
@@ -29,6 +29,7 @@ typedef cppu::ImplInheritanceHelper1< VbaDocumentBase, ov::excel::XWorkbook > Sc
 class ScVbaWorkbook : public ScVbaWorkbook_BASE
 {
     static css::uno::Sequence< sal_Int32 > ColorData;
+    bool setFilterPropsFromFormat( sal_Int32 nFormat, css::uno::Sequence< css::beans::PropertyValue >& rProps );
     void initColorData( const css::uno::Sequence< sal_Int32 >& sColors );
     void init();
 
@@ -50,6 +51,7 @@ public:
     virtual css::uno::Any SAL_CALL Windows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
     virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
     virtual void SAL_CALL Protect( const css::uno::Any & aPassword ) throw (css::uno::RuntimeException);
+    virtual void SAL_CALL SaveAs( const css::uno::Any& FileName, const css::uno::Any& FileFormat, const css::uno::Any& Password, const css::uno::Any& WriteResPassword, const css::uno::Any& ReadOnlyRecommended, const css::uno::Any& CreateBackup, const css::uno::Any& AccessMode, const css::uno::Any& ConflictResolution, const css::uno::Any& AddToMru, const css::uno::Any& TextCodepage, const css::uno::Any& TextVisualLayout, const css::uno::Any& Local );
     virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
 
     virtual css::uno::Any SAL_CALL Styles( const css::uno::Any& Item ) throw (css::uno::RuntimeException);
commit b2d1526203adfe462e744e8b14dabbd4fddf0406
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 3 12:31:27 2013 +0100

    Parse workbook name correctly, don't fall over spaces etc.
    
    Change-Id: I26213e4202ea2f2d15014ca722ab7878aa09cbf1

diff --git a/include/vbahelper/vbadocumentbase.hxx b/include/vbahelper/vbadocumentbase.hxx
index 77e7990..e4a9225 100644
--- a/include/vbahelper/vbadocumentbase.hxx
+++ b/include/vbahelper/vbadocumentbase.hxx
@@ -58,6 +58,8 @@ public:
     // XHelperInterface
     virtual OUString getServiceImplName();
     virtual css::uno::Sequence<OUString> getServiceNames();
+
+    static OUString getNameFromModel( const css::uno::Reference< css::frame::XModel >& xModel );
 };
 
 #endif /* VBA_DOCUMENTBASE_HXX */
diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx
index 5816b32..d9029ec 100644
--- a/vbahelper/source/vbahelper/vbadocumentbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx
@@ -54,16 +54,21 @@ VbaDocumentBase::VbaDocumentBase( uno::Sequence< uno::Any> const & args,
 OUString
 VbaDocumentBase::getName() throw (uno::RuntimeException)
 {
-    OUString sName = getModel()->getURL();
+    return VbaDocumentBase::getNameFromModel( getModel() );
+}
+
+OUString VbaDocumentBase::getNameFromModel( const uno::Reference< frame::XModel >& xModel )
+{
+    OUString sName = xModel.is() ? xModel->getURL() : OUString();
     if ( !sName.isEmpty() )
     {
 
-        INetURLObject aURL( getModel()->getURL() );
+        INetURLObject aURL( xModel->getURL() );
         ::osl::File::getSystemPathFromFileURL( aURL.GetLastName(), sName );
     }
     else
     {
-        uno::Reference< frame::XTitle > xTitle( getModel(), uno::UNO_QUERY_THROW );
+        uno::Reference< frame::XTitle > xTitle( xModel, uno::UNO_QUERY_THROW );
         sName = xTitle->getTitle();
         sName = sName.trim();
     }
diff --git a/vbahelper/source/vbahelper/vbadocumentsbase.cxx b/vbahelper/source/vbahelper/vbadocumentsbase.cxx
index e06e40c..90314a5 100644
--- a/vbahelper/source/vbahelper/vbadocumentsbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentsbase.cxx
@@ -50,6 +50,7 @@
 
 #include "vbahelper/vbahelper.hxx"
 #include "vbahelper/vbaapplicationbase.hxx"
+#include "vbahelper/vbadocumentbase.hxx"
 
 using namespace ::ooo::vba;
 using namespace ::com::sun::star;
@@ -138,8 +139,8 @@ public:
             {
                 uno::Reference< frame::XModel > xModel( xServiceInfo, uno::UNO_QUERY_THROW ); // that the spreadsheetdocument is a xmodel is a given
                 m_documents.push_back( xModel );
-                INetURLObject aURL( xModel->getURL() );
-                namesToIndices[ aURL.GetLastName() ] = nIndex++;
+                OUString sName = VbaDocumentBase::getNameFromModel( xModel );
+                namesToIndices[ sName ] = nIndex++;
             }
         }
 
commit 4d1e0ea98b963ef566d11fcd05f74bfab9ca813e
Author: Noel Power <noel.power at suse.com>
Date:   Wed Apr 24 11:44:59 2013 +0100

    support UserForm.Visible attribute
    
    Change-Id: I6e5a9d3e7908349a76a73a79b3b1319b44e1e3aa

diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx
index e2a7652..7b0031a 100644
--- a/vbahelper/source/msforms/vbauserform.cxx
+++ b/vbahelper/source/msforms/vbauserform.cxx
@@ -20,6 +20,7 @@
 #include "vbauserform.hxx"
 #include <com/sun/star/awt/XControl.hpp>
 #include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/XWindow2.hpp>
 #include <com/sun/star/awt/PosSize.hpp>
 #include <com/sun/star/beans/PropertyConcept.hpp>
 #include <com/sun/star/container/XNameContainer.hpp>
@@ -112,6 +113,23 @@ ScVbaUserForm::setCaption( const OUString& _caption ) throw (uno::RuntimeExcepti
     m_xProps->setPropertyValue( "Title", uno::makeAny( _caption ) );
 }
 
+sal_Bool SAL_CALL
+ScVbaUserForm::getVisible() throw (uno::RuntimeException)
+{
+    uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW );
+    uno::Reference< awt::XWindow2 > xControlWindow( xControl->getPeer(), uno::UNO_QUERY_THROW );
+    return xControlWindow->isVisible();
+}
+
+void SAL_CALL
+ScVbaUserForm::setVisible( sal_Bool bVis ) throw (uno::RuntimeException)
+{
+    if ( bVis )
+        Show();
+    else
+        Hide();
+}
+
 double SAL_CALL ScVbaUserForm::getInnerWidth() throw (uno::RuntimeException)
 {
     return mpGeometryHelper->getInnerWidth();
diff --git a/vbahelper/source/msforms/vbauserform.hxx b/vbahelper/source/msforms/vbauserform.hxx
index 59321fc..77826c3 100644
--- a/vbahelper/source/msforms/vbauserform.hxx
+++ b/vbahelper/source/msforms/vbauserform.hxx
@@ -56,6 +56,8 @@ public:
     virtual void SAL_CALL Hide(  ) throw (css::uno::RuntimeException);
     virtual void SAL_CALL UnloadObject(  ) throw (css::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL Controls( const css::uno::Any& index ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getVisible() throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setVisible( sal_Bool bVis ) throw (::com::sun::star::uno::RuntimeException);
     // XIntrospection
     virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection(  ) throw (css::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL invoke( const OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) throw (css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
commit a7cc0faeff0f02d82b9cad2a95359f73cc871e8a
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 3 10:24:33 2013 +0100

    support Shape.Alternative
    
    Change-Id: I6d822ef0d06e222f454c1279be16e33bcaae0037

diff --git a/include/vbahelper/vbashape.hxx b/include/vbahelper/vbashape.hxx
index 58e4f28..ff9c99e 100644
--- a/include/vbahelper/vbashape.hxx
+++ b/include/vbahelper/vbashape.hxx
@@ -62,6 +62,8 @@ public:
     // Attributes
     virtual OUString SAL_CALL getName() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setName( const OUString& _name ) throw (css::uno::RuntimeException);
+    virtual OUString SAL_CALL getAlternativeText() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setAlternativeText( const OUString& _name ) throw (css::uno::RuntimeException);
     virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setHeight( double _height ) throw (css::uno::RuntimeException);
     virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException);
diff --git a/oovbaapi/ooo/vba/msforms/XShape.idl b/oovbaapi/ooo/vba/msforms/XShape.idl
index 8b59f20..bdeba83 100644
--- a/oovbaapi/ooo/vba/msforms/XShape.idl
+++ b/oovbaapi/ooo/vba/msforms/XShape.idl
@@ -28,6 +28,7 @@ interface XShapeRange;
 interface XShape : ooo::vba::XHelperInterface
 {
     [attribute] string Name;
+    [attribute] string AlternativeText;
     [attribute] double Height;
     [attribute] double Width;
     [attribute] double Left;
diff --git a/vbahelper/source/vbahelper/vbashape.cxx b/vbahelper/source/vbahelper/vbashape.cxx
index 690f7b7..f94d96d 100644
--- a/vbahelper/source/vbahelper/vbashape.cxx
+++ b/vbahelper/source/vbahelper/vbashape.cxx
@@ -167,6 +167,22 @@ ScVbaShape::setName( const OUString& _name ) throw (uno::RuntimeException)
     xNamed->setName( _name );
 }
 
+OUString SAL_CALL
+ScVbaShape::getAlternativeText() throw (uno::RuntimeException)
+{
+    OUString sAltText;
+    uno::Reference< beans::XPropertySet > xProps( m_xShape, uno::UNO_QUERY_THROW );
+    xProps->getPropertyValue( OUString( "Title" ) ) >>= sAltText;
+    return sAltText;
+}
+
+void SAL_CALL
+ScVbaShape::setAlternativeText( const OUString& sAltText ) throw (uno::RuntimeException)
+{
+    uno::Reference< beans::XPropertySet > xProps( m_xShape, uno::UNO_QUERY_THROW );
+    xProps->setPropertyValue( OUString( "Title" ), uno::Any( sAltText ) );
+}
+
 double SAL_CALL
 ScVbaShape::getHeight() throw (uno::RuntimeException)
 {
commit ca3447eab2f34610dc21584a4be29bc32655038e
Author: Noel Power <noel.power at suse.com>
Date:   Fri May 3 10:18:05 2013 +0100

    add OLEObject related test
    
    Change-Id: I6ce22ecd6295bd8ad302d0f53c783f4ac2a1a036

diff --git a/sc/qa/extras/testdocuments/MiscControlTests.xls b/sc/qa/extras/testdocuments/MiscControlTests.xls
index 765009b..3503795 100755
Binary files a/sc/qa/extras/testdocuments/MiscControlTests.xls and b/sc/qa/extras/testdocuments/MiscControlTests.xls differ
commit 6094fc56db09c033b0baabb2cfcddd38559d752c
Author: Noel Power <noel.power at suse.com>
Date:   Tue Apr 23 20:19:45 2013 +0100

    return correct object ( was returning an uno object in the vba api )
    
    Fix typo ( or brain fart ) where the VBA api was returning the libreoffice
    uno object instead of the vba wrapper object
    
    Change-Id: I0e615368d636ad08b40842ef9b91f3818829d3ea

diff --git a/sc/source/ui/vba/vbaoleobject.cxx b/sc/source/ui/vba/vbaoleobject.cxx
index 0210fe1..0db97d2 100644
--- a/sc/source/ui/vba/vbaoleobject.cxx
+++ b/sc/source/ui/vba/vbaoleobject.cxx
@@ -50,7 +50,7 @@ ScVbaOLEObject::ScVbaOLEObject( const uno::Reference< XHelperInterface >& xParen
 uno::Reference< uno::XInterface > SAL_CALL
 ScVbaOLEObject::getObject() throw (uno::RuntimeException)
 {
-    return uno::Reference< uno::XInterface >( m_xControlShape, uno::UNO_QUERY_THROW );
+    return uno::Reference< uno::XInterface >( m_xControl, uno::UNO_QUERY_THROW );
 }
 
 sal_Bool SAL_CALL
commit a68c828baab8ccb35910a2ffbdbde261f9e24170
Author: Noel Power <noel.power at suse.com>
Date:   Thu May 2 18:46:28 2013 +0100

    some testcases for api generated changed & click events for vba controls
    
    Change-Id: I408c9aa0b80971f326b607b274ce046c27098f74

diff --git a/sc/qa/extras/testdocuments/MiscControlTests.xls b/sc/qa/extras/testdocuments/MiscControlTests.xls
index 332d0a8..765009b 100755
Binary files a/sc/qa/extras/testdocuments/MiscControlTests.xls and b/sc/qa/extras/testdocuments/MiscControlTests.xls differ
commit 13ee25626529ff9d3cca5a7039ca6519cb6b7e20
Author: Noel Power <noel.power at suse.com>
Date:   Tue Apr 23 19:50:13 2013 +0100

    tweak combox to selectively fire change or click event
    
    we need to fire a click event if just the item in the dropdown changed and
    a change event if the item we changed is really part of the list
    
    Change-Id: I19f950fca0857761d8f59a07513803f1f3ef135b

diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx
index 6933884..8c5401a 100644
--- a/vbahelper/source/msforms/vbacombobox.cxx
+++ b/vbahelper/source/msforms/vbacombobox.cxx
@@ -124,7 +124,15 @@ ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
     m_xProps->setPropertyValue( sSourceName, uno::Any( extractStringFromAny( _value, OUString(), true ) ) );
     OUString newValue = extractStringFromAny( getValue(), OUString(), true );
     if ( oldValue != newValue )
-        fireChangeEvent();
+    {
+        sal_Int32 index = 0;
+        uno::Any aIndex = getListIndex();
+        aIndex >>= index;
+        if ( index < 0 )
+            fireChangeEvent();
+        else
+            fireClickEvent();
+    }
 }
 
 // see Value
commit b3a635e203616d624170af2c78c99b50640b6cec
Author: Noel Power <noel.power at suse.com>
Date:   Thu May 2 17:40:12 2013 +0100

    tweak MiscControls to test simple textbox change event
    
    Change-Id: I256a029afefe5990dfb0c87859bae4508f5920bc

diff --git a/sc/qa/extras/testdocuments/MiscControlTests.xls b/sc/qa/extras/testdocuments/MiscControlTests.xls
index 44e6ef3..332d0a8 100755
Binary files a/sc/qa/extras/testdocuments/MiscControlTests.xls and b/sc/qa/extras/testdocuments/MiscControlTests.xls differ
commit 4bad1a8e314269f2538133eb241135a225ac3f4f
Author: Noel Power <noel.power at suse.com>
Date:   Tue Apr 23 18:13:37 2013 +0100

    support api initiated change_event for combox & textbox
    
    Change-Id: Iff51a184792e9d12accb902df1772fc07589443b

diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx
index 30f7237..6933884 100644
--- a/vbahelper/source/msforms/vbacombobox.cxx
+++ b/vbahelper/source/msforms/vbacombobox.cxx
@@ -120,7 +120,11 @@ void SAL_CALL
 ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
 {
     // booleans are converted to uppercase strings
+    OUString oldValue = extractStringFromAny( getValue(), OUString(), true );
     m_xProps->setPropertyValue( sSourceName, uno::Any( extractStringFromAny( _value, OUString(), true ) ) );
+    OUString newValue = extractStringFromAny( getValue(), OUString(), true );
+    if ( oldValue != newValue )
+        fireChangeEvent();
 }
 
 // see Value
diff --git a/vbahelper/source/msforms/vbatextbox.cxx b/vbahelper/source/msforms/vbatextbox.cxx
index d4d10c1..f61087e 100644
--- a/vbahelper/source/msforms/vbatextbox.cxx
+++ b/vbahelper/source/msforms/vbatextbox.cxx
@@ -59,6 +59,7 @@ ScVbaTextBox::getText() throw (css::uno::RuntimeException)
 void SAL_CALL
 ScVbaTextBox::setText( const OUString& _text ) throw (css::uno::RuntimeException)
 {
+    OUString oldText( getText() );
     if ( !mbDialog )
     {
         uno::Reference< text::XTextRange > xTextRange( m_xProps, uno::UNO_QUERY_THROW );
@@ -66,6 +67,8 @@ ScVbaTextBox::setText( const OUString& _text ) throw (css::uno::RuntimeException
     }
     else
         m_xProps->setPropertyValue( "Text" , uno::makeAny( _text ) );
+    if ( oldText != _text )
+        fireChangeEvent();
 }
 
 sal_Int32 SAL_CALL
commit 3fb03cc873280c49e04c59062c1ad21b53c7f5df
Author: Noel Power <noel.power at suse.com>
Date:   Tue Apr 23 17:07:02 2013 +0100

    handle non int32 values for Field in Range.AutoFilter
    
    Change-Id: I7288371ab32abd02b858c538f50a68eff66ecced

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 3322122..276cba8 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -4295,7 +4295,7 @@ static void lcl_setTableFieldsFromCriteria( OUString& sCriteria1, uno::Reference
 }
 
 void SAL_CALL
-ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const uno::Any& Operator, const uno::Any& Criteria2, const uno::Any& VisibleDropDown ) throw (uno::RuntimeException)
+ScVbaRange::AutoFilter( const uno::Any& aField, const uno::Any& Criteria1, const uno::Any& Operator, const uno::Any& Criteria2, const uno::Any& VisibleDropDown ) throw (uno::RuntimeException)
 {
     // Is there an existing autofilter
     RangeHelper thisRange( mxRange );
@@ -4391,12 +4391,24 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const
     if ( bHasCritValue )
         bCritHasNumericValue = ( Criteria1 >>= nCriteria1 );
 
-    if (  !Field.hasValue() && ( Criteria1.hasValue() || Operator.hasValue() || Criteria2.hasValue() ) )
+    if (  !aField.hasValue() && ( Criteria1.hasValue() || Operator.hasValue() || Criteria2.hasValue() ) )
         throw uno::RuntimeException();
+    bool bAll = false;
+    uno::Any Field( aField );
+    if ( !( Field >>= nField ) )
+    {
+        uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
+        try
+        {
+            Field = xConverter->convertTo( aField, getCppuType( (sal_Int32*)0 ) );
+        }
+        catch( uno::Exception& )
+        {
+        }
+    }
     // Use the normal uno api, sometimes e.g. when you want to use ALL as the filter
     // we can't use refresh as the uno interface doesn't have a concept of ALL
     // in this case we just call the core calc functionality -
-    bool bAll = false;
     if ( ( Field >>= nField )  )
     {
         uno::Reference< sheet::XSheetFilterDescriptor2 > xDesc(
commit 92c8becf8b1111fa98231258990d34ae771c0d1e
Author: Noel Power <noel.power at suse.com>
Date:   Thu May 2 16:48:26 2013 +0100

    Add check form contrast and IncrememtContrast behaviour in Shapes.xls
    
    Change-Id: I6ef275c6a978db0da59da953511105c407a66f72

diff --git a/sc/qa/extras/testdocuments/Shapes.xls b/sc/qa/extras/testdocuments/Shapes.xls
index ff15272..dbccf3d 100644
Binary files a/sc/qa/extras/testdocuments/Shapes.xls and b/sc/qa/extras/testdocuments/Shapes.xls differ
commit 8fdd62c5876ef61f432e7d66e8fef4dd0d617193
Author: Noel Power <noel.power at suse.com>
Date:   Thu May 2 14:10:33 2013 +0100

    fix contrast not increment to limit value between 0.0 & 1.0
    
    Change-Id: I1a8c08fb8f704e69ae1ae75d77784f07a1d99a12

diff --git a/vbahelper/source/vbahelper/vbapictureformat.cxx b/vbahelper/source/vbahelper/vbapictureformat.cxx
index 96495e1..9b2aa11 100644
--- a/vbahelper/source/vbahelper/vbapictureformat.cxx
+++ b/vbahelper/source/vbahelper/vbapictureformat.cxx
@@ -103,15 +103,15 @@ void SAL_CALL
 ScVbaPictureFormat::IncrementContrast( double increment ) throw (uno::RuntimeException)
 {
     double nContrast = getContrast();
-    if( increment < 0 )
+    nContrast += increment;
+    if( nContrast < 0 )
     {
-        increment = 0.0;
+        nContrast = 0.0;
     }
-    if( increment > 1 )
+    if( nContrast > 1 )
     {
-        increment = 1.0;
+        nContrast = 1.0;
     }
-    nContrast += increment;
     setContrast( nContrast );
 }
 
commit 8b94bfebf6e0d244182a19fc1743d7c67dc41857
Author: Noel Power <noel.power at suse.com>
Date:   Thu May 2 13:16:08 2013 +0100

    Tweak further the indices checked for break, also tweak test document
    
    <sigh> pagebreak implementation is still flawed here, the used
    range is used to determine whether the page break should be
    considered ( or not ) Problem is that it is not the used
    range but rather the rightmost column position that contains content
    ( but not necessarily the column that contains content but rather
    the righmost column that has content ( or even that is covered either
    by spillover from an adjacent column or drawing )
    
    Change-Id: I68c8ccc5911049bc4b2076992f839bc684d966a9

diff --git a/sc/qa/extras/testdocuments/PageBreaks.xls b/sc/qa/extras/testdocuments/PageBreaks.xls
index 2affd99..4e6ac0a 100644
Binary files a/sc/qa/extras/testdocuments/PageBreaks.xls and b/sc/qa/extras/testdocuments/PageBreaks.xls differ
diff --git a/sc/source/ui/vba/vbapagebreaks.cxx b/sc/source/ui/vba/vbapagebreaks.cxx
index a0c40b2..09100e2 100644
--- a/sc/source/ui/vba/vbapagebreaks.cxx
+++ b/sc/source/ui/vba/vbapagebreaks.cxx
@@ -49,7 +49,7 @@ public:
     sal_Int32 getAPIEndIndexofRange( const uno::Reference< excel::XRange >& xRange, sal_Int32 nUsedStart ) throw (uno::RuntimeException)
     {
         if( m_bColumn )
-            return nUsedStart + xRange->Columns( uno::Any() )->getCount();
+            return nUsedStart + xRange->Columns( uno::Any() )->getCount() - 1;
         return nUsedStart + xRange->Rows( uno::Any() )->getCount();
     }
 
@@ -107,7 +107,7 @@ 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 + 1 )
+        if( nPos > nUsedEnd + 1)
             return nCount;
         nCount++;
     }
commit 396224947e9522c48043291c2e2559d7f86fb3d1
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 22 16:46:40 2013 +0100

    fix limits check on breaks ( ignore breaks outside used area )
    
    Change-Id: I36154ba6999c9a74ecf2c55c0559b6c25d137283

diff --git a/sc/source/ui/vba/vbapagebreaks.cxx b/sc/source/ui/vba/vbapagebreaks.cxx
index d7ac4a0..a0c40b2 100644
--- a/sc/source/ui/vba/vbapagebreaks.cxx
+++ b/sc/source/ui/vba/vbapagebreaks.cxx
@@ -107,10 +107,9 @@ 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 )
+        if( nPos > nUsedEnd + 1 )
             return nCount;
-        if( nPos >= nUsedStart )
-            nCount++;
+        nCount++;
     }
 
     return nCount;
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 046f540..3322122 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1960,9 +1960,18 @@ 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)  ) ;
-    return aMatrix;
+    uno::Any aSingleValueOrMatrix;
+    // When dealing with a single element ( embedded in the sequence of sequence ) unwrap and return
+    // that value
+    uno::Sequence< uno::Sequence<rtl::OUString> > aTmpSeq = xCellRangeFormula->getFormulaArray();
+    if ( aTmpSeq.getLength() == 1 )
+    {
+        if ( aTmpSeq[ 0 ].getLength() == 1  )
+            aSingleValueOrMatrix <<= aTmpSeq[ 0 ][ 0 ];
+    }
+    else
+        aSingleValueOrMatrix = xConverter->convertTo( uno::makeAny( aTmpSeq ) , getCppuType((uno::Sequence< uno::Sequence< uno::Any > >*)0)  ) ;
+    return aSingleValueOrMatrix;
 }
 
 void
commit 683b016ae0c56f8422497b7a91e9497169d61975
Author: Noel Power <noel.power at suse.com>
Date:   Thu May 2 10:07:34 2013 +0100

    Renable Range-2 vba test as I589b93461b5f4125408f4fc2cb87cd84686f7b95 fixed it
    
    note: Change ID I589b93461b5f4125408f4fc2cb87cd84686f7b95
    " Fix ScRangeList::Parse wrt defaulted delimiter and default tab params" in addition
    to fixing problems with Ranges.xls appears also to solve the issue with Range-2.xls
    
    Change-Id: I28f53e09a6c7004f766d7e4f2ca9524cc8bbd83f

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index d4c9374..a610217 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -135,15 +135,10 @@ void ScMacrosTest::testVba()
             OUString("TestCalc_Rangetest2."),
             OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
         },
-#if defined FIXRANGEADDRESSING
-//ScVbaRange::getRangeForName()/getScRangeListForAddress() seems to get confused
-//about the addressing mode of the document vs the addressing mode of a named
-//range ( need to fix that )
         {
             OUString("Ranges-2."),
             OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
         },
-#endif
         {
             OUString("pagesetup."),
             OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
commit a2c34b3d9ac2d7e43e52846308cc63447fd51f23
Author: Noel Power <noel.power at suse.com>
Date:   Thu May 2 10:01:22 2013 +0100

    add Range.Cut check
    
    Change-Id: I6d33ce8fe2333e7920b5c6cf82531ee859352748

diff --git a/sc/qa/extras/testdocuments/Ranges.xls b/sc/qa/extras/testdocuments/Ranges.xls
index 87f9d2d..4d5583e 100644
Binary files a/sc/qa/extras/testdocuments/Ranges.xls and b/sc/qa/extras/testdocuments/Ranges.xls differ
commit fc36b2247d23045b5b9b302267dd38b9f2799450
Author: Noel Power <noel.power at suse.com>
Date:   Wed May 1 17:34:54 2013 +0100

    re-enable Ranges.xls vba testdocument, additionally remove some failing tests
    
    Change-Id: I6289aa7e7872cc0c6aacd89f0679609792d37c28

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 8385544..d4c9374 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -164,12 +164,10 @@ void ScMacrosTest::testVba()
             OUString("Shapes."),
             OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
         },
-#if defined VBA_TEST_WORKING
         {
             OUString("Ranges."),
             OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
         },
-#endif
         {
             OUString("CheckOptionToggleValue."),
             OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
diff --git a/sc/qa/extras/testdocuments/Ranges.xls b/sc/qa/extras/testdocuments/Ranges.xls
index cc12d3f..87f9d2d 100644
Binary files a/sc/qa/extras/testdocuments/Ranges.xls and b/sc/qa/extras/testdocuments/Ranges.xls differ
commit 96ece477356f3c5a1d2b70d0e977ebc3b83a752a
Author: Noel Power <noel.power at suse.com>
Date:   Wed May 1 17:17:58 2013 +0100

    Fix ScRangeList::Parse wrt defaulted delimiter and default tab params
    
    At some point in the past default tab was introduced, the VBA Range code calling
    ScRangeList::Parse was not adjusted to take care of this extra defaulted param and
    and the delimiter param was passed in place of default tab.
    
    Change-Id: I589b93461b5f4125408f4fc2cb87cd84686f7b95

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index a9a7844..046f540 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1154,7 +1154,7 @@ ScVbaRange::getCellRangesForAddress( sal_uInt16& rResFlags, const OUString& sAdd
     {
         pDoc = pDocSh->GetDocument();
         sal_uInt16 nMask = SCA_VALID;
-        rResFlags = rCellRanges.Parse( sAddress, pDoc, nMask, eConv, cDelimiter );
+        rResFlags = rCellRanges.Parse( sAddress, pDoc, nMask, eConv, 0, cDelimiter );
         if ( rResFlags & SCA_VALID )
         {
             return true;
commit dff7cc0d62eb52fb57c4856e48e068f26ccdd616
Author: Noel Power <noel.power at suse.com>
Date:   Wed May 1 16:29:47 2013 +0100

    Revert "remove unused parameter"
    
    This reverts commit 7c63d52506b66563eefcf29c803b23bb9b812491.
    actually it is used, it's used in vba

diff --git a/sc/inc/rangelst.hxx b/sc/inc/rangelst.hxx
index 2a20f45..9902eab 100644
--- a/sc/inc/rangelst.hxx
+++ b/sc/inc/rangelst.hxx
@@ -41,7 +41,7 @@ public:
     sal_uInt16 Parse( const String&, ScDocument* = NULL,
                       sal_uInt16 nMask = SCA_VALID,
                       formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO,
-                      SCTAB nDefaultTab = 0 );
+                      SCTAB nDefaultTab = 0, sal_Unicode cDelimiter = 0 );
 
     void            Format( String&, sal_uInt16 nFlags = 0, ScDocument* = NULL,
                             formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO,
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 8f37c13..4027d6f 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -183,11 +183,12 @@ ScRangeList::~ScRangeList()
 
 sal_uInt16 ScRangeList::Parse( const String& rStr, ScDocument* pDoc, sal_uInt16 nMask,
                            formula::FormulaGrammar::AddressConvention eConv,
-                           SCTAB nDefaultTab )
+                           SCTAB nDefaultTab, sal_Unicode cDelimiter )
 {
     if ( rStr.Len() )
     {
-        sal_Unicode cDelimiter = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+        if (!cDelimiter)
+            cDelimiter = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
 
         nMask |= SCA_VALID;             // falls das jemand vergessen sollte
         sal_uInt16 nResult = (sal_uInt16)~0;    // alle Bits setzen
commit df62945861706044e05f954433feaa6e1e179af5
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 22 14:02:07 2013 +0100

    fix range cut with destination paramater( missing else )
    
    Change-Id: I67829b3b15177977bc0e31ec6384c124cc61f1b5

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 5bc7e65..a9a7844 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -2515,6 +2515,7 @@ ScVbaRange::Cut(const ::uno::Any& Destination) throw (uno::RuntimeException)
         uno::Reference< sheet::XCellRangeAddressable > xSource( mxRange, uno::UNO_QUERY);
         xMover->moveRange( xDestination->getCellAddress(), xSource->getRangeAddress() );
     }
+    else
     {
         uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange );
         Select();
commit a6ee93e38d76342260a73931d9460fe902ee3ac0
Author: Noel Power <noel.power at suse.com>
Date:   Wed May 1 15:12:03 2013 +0100

    some extra tests for ListBox.MultiSelection and ListBox.Text api
    
    also tests ListBox.AddItem & ListBox.Clear ( plenty of room
    to flesh these tests out )
    
    Change-Id: Iddaa5a5e6b406359c6215ad726085d3696e633cf

diff --git a/sc/qa/extras/testdocuments/MiscControlTests.xls b/sc/qa/extras/testdocuments/MiscControlTests.xls
index 9d7b980..44e6ef3 100755
Binary files a/sc/qa/extras/testdocuments/MiscControlTests.xls and b/sc/qa/extras/testdocuments/MiscControlTests.xls differ
commit 4002ce1419b6ae986408bfe65f7a3068ca1332ab
Author: Noel Power <noel.power at suse.com>
Date:   Fri Apr 19 17:19:35 2013 +0100

    Setting TEXT causes exception, don't do it
    
    Change-Id: Idc5614a80e6e45d12f1323ffa9843c7fa7f9576e

diff --git a/vbahelper/source/msforms/vbalistbox.cxx b/vbahelper/source/msforms/vbalistbox.cxx
index 1525983..0f9c8b7 100644
--- a/vbahelper/source/msforms/vbalistbox.cxx
+++ b/vbahelper/source/msforms/vbalistbox.cxx
@@ -104,7 +104,6 @@ ScVbaListBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
     m_xProps->setPropertyValue( SELECTEDITEMS, uno::makeAny( nSelectedIndices ) );
     if ( nSelectedIndices != nOldSelectedIndices )
         fireClickEvent();
-    m_xProps->setPropertyValue( TEXT, uno::makeAny( sValue ) );
 }
 
 OUString SAL_CALL
@@ -141,7 +140,7 @@ ScVbaListBox::setMultiSelect( sal_Int32 _multiselect ) throw (css::uno::RuntimeE
             bBoolVal = sal_True;
             break;
         case msforms::fmMultiSelect::fmMultiSelectSingle:
-            bBoolVal = sal_True;
+            bBoolVal = sal_False;
             break;
         default:
             throw lang::IllegalArgumentException();
commit 2743241bd299b87da21c7888b4339a77f1e5c44c
Author: Noel Power <noel.power at suse.com>
Date:   Fri Apr 19 17:19:03 2013 +0100

    ListBox.MultiSelection takes fmMultiSelect enum not bool
    
    Change-Id: Ic9ea60feadc551b232b393faafea9760cc3b82f0

diff --git a/oovbaapi/ooo/vba/msforms/XListBox.idl b/oovbaapi/ooo/vba/msforms/XListBox.idl
index 6bf25e9..f7b312e 100644
--- a/oovbaapi/ooo/vba/msforms/XListBox.idl
+++ b/oovbaapi/ooo/vba/msforms/XListBox.idl
@@ -31,7 +31,7 @@ interface XListBox
 {
     [attribute] any Value;
     [attribute] string Text;
-    [attribute] boolean MultiSelect;
+    [attribute] long MultiSelect;
     [attribute] any ListIndex;
     [attribute, readonly] long ListCount;
     [attribute, readonly] XNewFont Font;
diff --git a/vbahelper/source/msforms/vbalistbox.cxx b/vbahelper/source/msforms/vbalistbox.cxx
index 483985e..1525983 100644
--- a/vbahelper/source/msforms/vbalistbox.cxx
+++ b/vbahelper/source/msforms/vbalistbox.cxx
@@ -22,6 +22,7 @@
 #include <comphelper/anytostring.hxx>
 #include <com/sun/star/script/ArrayWrapper.hpp>
 #include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
+#include <ooo/vba/msforms/fmMultiSelect.hpp>
 
 using namespace com::sun::star;
 using namespace ooo::vba;
@@ -120,18 +121,33 @@ ScVbaListBox::setText( const OUString& _text ) throw (uno::RuntimeException)
     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( "MultiSelection" ) >>= bMultiSelect;
-    return bMultiSelect;
+
+    return bMultiSelect ? msforms::fmMultiSelect::fmMultiSelectMulti : msforms::fmMultiSelect::fmMultiSelectSingle;
 }
 
 void SAL_CALL
-ScVbaListBox::setMultiSelect( sal_Bool _multiselect ) throw (css::uno::RuntimeException)
+ScVbaListBox::setMultiSelect( sal_Int32 _multiselect ) throw (css::uno::RuntimeException)
 {
-    m_xProps->setPropertyValue( "MultiSelection" , uno::makeAny( _multiselect ) );
+    sal_Bool bBoolVal = false;
+    switch ( _multiselect )
+    {
+        case  msforms::fmMultiSelect::fmMultiSelectMulti:
+        case  msforms::fmMultiSelect::fmMultiSelectExtended:
+            bBoolVal = sal_True;
+            break;
+        case msforms::fmMultiSelect::fmMultiSelectSingle:
+            bBoolVal = sal_True;
+            break;
+        default:
+            throw lang::IllegalArgumentException();
+            break;
+    }
+    m_xProps->setPropertyValue( "MultiSelection" , uno::makeAny( bBoolVal ) );
 }
 
 
diff --git a/vbahelper/source/msforms/vbalistbox.hxx b/vbahelper/source/msforms/vbalistbox.hxx
index 3b0ee74..2a46c0b 100644
--- a/vbahelper/source/msforms/vbalistbox.hxx
+++ b/vbahelper/source/msforms/vbalistbox.hxx
@@ -52,8 +52,8 @@ public:
     virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
     virtual OUString SAL_CALL getText() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setText( const 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);
+    virtual void SAL_CALL setMultiSelect( sal_Int32 _multiselect ) throw (css::uno::RuntimeException);
     virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
 
     // Methods
commit 37cc1bb26fe91ce02f68e37930f00951bdec63a0
Author: Noel Power <noel.power at suse.com>
Date:   Wed May 1 14:11:19 2013 +0100

    Add some misc control related vba tests
    
    Change-Id: I8a6e2aeb3766a3890c5026129794b25cfa5c7ba5

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index ebe1d1c..8385544 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -178,6 +178,10 @@ void ScMacrosTest::testVba()
             OUString("GeneratedEventTest."),
             OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
         },
+        {
+            OUString("MiscControlTests."),
+            OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
+        },
     };
 
     for ( sal_uInt32  i=0; i<SAL_N_ELEMENTS( testInfo ); ++i )
diff --git a/sc/qa/extras/testdocuments/MiscControlTests.xls b/sc/qa/extras/testdocuments/MiscControlTests.xls
new file mode 100755
index 0000000..9d7b980
Binary files /dev/null and b/sc/qa/extras/testdocuments/MiscControlTests.xls differ
commit 412ae1bf1c12c31f4f9d33e38e46c2ee083107b7
Author: Noel Power <noel.power at suse.com>
Date:   Fri Apr 19 15:54:55 2013 +0100

    fix TextBox value error, MaxLength is long in vba but short in libreoffice
    
    Change-Id: I550fe6833f240d085fadf55ab8d9421947318eef

diff --git a/vbahelper/source/msforms/vbatextbox.cxx b/vbahelper/source/msforms/vbatextbox.cxx
index 4e94a33..d4d10c1 100644
--- a/vbahelper/source/msforms/vbatextbox.cxx
+++ b/vbahelper/source/msforms/vbatextbox.cxx
@@ -73,15 +73,16 @@ ScVbaTextBox::getMaxLength() throw (css::uno::RuntimeException)
 {
     uno::Any aValue;
     aValue = m_xProps->getPropertyValue( "MaxTextLen" );
-    sal_Int32 nMaxLength = 0;
+    sal_Int16 nMaxLength = 0;
     aValue >>= nMaxLength;
-    return nMaxLength;
+    return (sal_Int32)nMaxLength;
 }
 
 void SAL_CALL
 ScVbaTextBox::setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException)
 {
-    uno::Any aValue( _maxlength );
+    sal_Int16 nTmp( _maxlength );
+    uno::Any aValue( nTmp );
     m_xProps->setPropertyValue( "MaxTextLen" , aValue);
 }
 
commit 27e2b40989c62c95a54e2212f26d21f90e161c32
Author: Noel Power <noel.power at suse.com>
Date:   Wed May 1 12:15:37 2013 +0100

    add test for new vba ReturnInteger type
    
    Change-Id: If8ce9e5ce35c438b31234aab410b37f12eb1b1f4

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 4e37760..ebe1d1c 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -174,6 +174,10 @@ void ScMacrosTest::testVba()
             OUString("CheckOptionToggleValue."),
             OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
         },
+        {
+            OUString("GeneratedEventTest."),
+            OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
+        },
     };
 
     for ( sal_uInt32  i=0; i<SAL_N_ELEMENTS( testInfo ); ++i )
diff --git a/sc/qa/extras/testdocuments/CheckOptionToggleValue.xls b/sc/qa/extras/testdocuments/CheckOptionToggleValue.xls
old mode 100755
new mode 100644
diff --git a/sc/qa/extras/testdocuments/GeneratedEventTest.xls b/sc/qa/extras/testdocuments/GeneratedEventTest.xls
new file mode 100755
index 0000000..9325de3
Binary files /dev/null and b/sc/qa/extras/testdocuments/GeneratedEventTest.xls differ
commit b1dc5ed5693c8ed23e0bd14f29ad796666c27785
Author: Noel Power <noel.power at suse.com>
Date:   Wed May 1 12:05:22 2013 +0100

    tweak vba Control implementation to aritificially fire events from api
    
    Previouslly there were some internal methods to allow event handlers
    to be triggered. To test some functionality from the unit tests we
    now expose some of that functionality via uno.
    
    Change-Id: I11022226260d3dacd82f42ce89413102ce34cc13

diff --git a/oovbaapi/ooo/vba/msforms/XControl.idl b/oovbaapi/ooo/vba/msforms/XControl.idl
index 319ff72..b703154 100644
--- a/oovbaapi/ooo/vba/msforms/XControl.idl
+++ b/oovbaapi/ooo/vba/msforms/XControl.idl
@@ -19,6 +19,7 @@
 #define __ooo_vba_msforms_XControl_idl__
 
 #include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/script/ScriptEvent.idl>
 #include <ooo/vba/XHelperInterface.idl>
 
 module ooo {  module vba {  module msforms {
@@ -29,7 +30,9 @@ interface XControl
     interface ::ooo::vba::XHelperInterface;
     void SetFocus();
     void Move( [in] double Left, [in] double Top, [in] any Width, [in] any Height );
-
+    // support for unit test harness ( and possibly internal clients )
+    // to generate events that will call appropriate event handlers
+    void fireEvent( [in] com::sun::star::script::ScriptEvent evt );
     [attribute, readonly ] com::sun::star::uno::XInterface Object;
     [attribute] string ControlSource;
     [attribute] string RowSource;
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index 516cfa6..ae0cc58 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -519,8 +519,9 @@ ScVbaControl::setMousePointer( ::sal_Int32 _mousepointer ) throw (::com::sun::st
     }
 }
 
-void ScVbaControl::fireEvent( script::ScriptEvent& evt )
+void SAL_CALL ScVbaControl::fireEvent( const script::ScriptEvent& rEvt ) throw (uno::RuntimeException)
 {
+    script::ScriptEvent evt( rEvt );
     uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
     uno::Reference< script::XScriptListener > xScriptListener( xServiceManager->createInstanceWithContext( "ooo.vba.EventListener" , mxContext ), uno::UNO_QUERY_THROW );
 
@@ -546,7 +547,9 @@ void ScVbaControl::fireEvent( script::ScriptEvent& evt )
             uno::Reference< document::XCodeNameQuery > xNameQuery(  xDocFac->createInstance( "ooo.vba.VBACodeNameProvider" ), uno::UNO_QUERY_THROW );
             uno::Reference< uno::XInterface > xIf( xControlShape->getControl(), uno::UNO_QUERY_THROW );
             evt.ScriptCode = xNameQuery->getCodeNameForObject( xIf );
-            evt.Arguments[ 0 ] = uno::makeAny( aEvt );
+            // handle if we passed in our own arguments
+            if ( !rEvt.Arguments.getLength() )
+                evt.Arguments[ 0 ] = uno::makeAny( aEvt );
             xScriptListener->firing( evt );
         }
         else
diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx
index bf6b8a3..7644b56 100644
--- a/vbahelper/source/msforms/vbacontrol.hxx
+++ b/vbahelper/source/msforms/vbacontrol.hxx
@@ -57,7 +57,6 @@ protected:
     virtual css::uno::Reference< css::awt::XWindowPeer > getWindowPeer() throw (css::uno::RuntimeException);
     void fireChangeEvent();
     void fireClickEvent();
-    void fireEvent( css::script::ScriptEvent& evt );
 public:
     ScVbaControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
                     const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pHelper );
@@ -84,6 +83,7 @@ public:
     virtual void SAL_CALL setTop( double _top ) throw (css::uno::RuntimeException);
     virtual void SAL_CALL SetFocus(  ) throw (css::uno::RuntimeException);
     virtual void SAL_CALL Move( double Left, double Top, const ::com::sun::star::uno::Any& Width, const ::com::sun::star::uno::Any& Height ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL fireEvent( const css::script::ScriptEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
 
     virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() throw (css::uno::RuntimeException);
     virtual OUString SAL_CALL getControlSource() throw (css::uno::RuntimeException);
commit 04eb03cc0b01e5dd862aa073810d3ab898661e8f
Author: Noel Power <noel.power at suse.com>
Date:   Fri Apr 19 12:52:06 2013 +0100

    handle various ReturnXXXX types for forms
    
    Change-Id: Idcbfbebafb02c734b42428c5b1d6df8d0d4a23d6

diff --git a/include/vbahelper/vbareturntypes.hxx b/include/vbahelper/vbareturntypes.hxx
new file mode 100644
index 0000000..d44252d
--- /dev/null
+++ b/include/vbahelper/vbareturntypes.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef RETURNTYPES_HXX
+#define RETURNTYPES_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/script/XDefaultProperty.hpp>
+#include <ooo/vba/msforms/XReturnInteger.hpp>
+#include <ooo/vba/msforms/XReturnBoolean.hpp>
+#include <ooo/vba/msforms/XReturnSingle.hpp>
+#include <ooo/vba/msforms/XReturnEffect.hpp>
+
+#include <vbahelper/vbahelper.hxx>
+#include <vbahelper/vbahelperinterface.hxx>
+
+namespace ooo
+{
+    namespace vba
+    {
+        template< typename T1,  typename T2 >
+        class DefaultReturnHelper : public ::cppu::WeakImplHelper2< T2, css::script::XDefaultProperty >
+        {
+            T1 mnValue;
+            public:
+            DefaultReturnHelper( const T1& nValue ) : mnValue( nValue ) {}
+            virtual void  SAL_CALL setValue( T1 nValue ) throw (::com::sun::star::uno::RuntimeException) { mnValue = nValue; }
+            virtual T1  SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException) { return mnValue; }
+            OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return OUString("Value"); }
+        };
+
+        typedef DefaultReturnHelper< sal_Int32, ov::msforms::XReturnInteger > ReturnInteger_BASE;
+        class ReturnInteger : public ReturnInteger_BASE
+        {
+            public:
+            ReturnInteger( sal_Int32 nValue ) : ReturnInteger_BASE( nValue ){}
+        };
+
+        typedef DefaultReturnHelper< sal_Bool, ov::msforms::XReturnBoolean > ReturnBoolean_BASE;
+        class ReturnBoolean : public ReturnBoolean_BASE
+        {
+            public:
+            ReturnBoolean( sal_Bool nValue ) : ReturnBoolean_BASE( nValue ){}
+        };
+        typedef DefaultReturnHelper< float, ov::msforms::XReturnSingle > ReturnSingle_BASE;
+        class ReturnSingle : public ReturnSingle_BASE
+        {
+            public:
+            ReturnSingle( float nValue ) : ReturnSingle_BASE( nValue ){}
+        };
+        typedef DefaultReturnHelper< short, ov::msforms::XReturnEffect > ReturnEffect_BASE;
+        class ReturnEffect : public ReturnEffect_BASE
+        {
+            public:
+            ReturnEffect( short nValue ) : ReturnEffect_BASE( nValue ){}
+        };
+    } // vba
+} // ooo
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oovbaapi/UnoApi_oovbaapi.mk b/oovbaapi/UnoApi_oovbaapi.mk
index 4df023b..b2a44e8 100644
--- a/oovbaapi/UnoApi_oovbaapi.mk
+++ b/oovbaapi/UnoApi_oovbaapi.mk
@@ -521,10 +521,6 @@ $(eval $(call gb_UnoApi_add_idlfiles,oovbaapi,oovbaapi/ooo/vba/msforms,\
     fmTransitionEffect \
     fmVerticalScrollBarSide \
     fmZOrder \
-	ReturnBoolean \
-	ReturnEffect \
-	ReturnInteger \
-	ReturnSingle \
 	XButton \
 	XCheckBox \
 	XColorFormat \
@@ -545,6 +541,10 @@ $(eval $(call gb_UnoApi_add_idlfiles,oovbaapi,oovbaapi/ooo/vba/msforms,\
 	XPictureFormat \
 	XProgressBar \
 	XRadioButton \
+	XReturnBoolean \
+	XReturnEffect \
+	XReturnInteger \
+	XReturnSingle \
 	XScrollBar \
 	XShape \
 	XShapeRange \
diff --git a/oovbaapi/ooo/vba/msforms/ReturnSingle.idl b/oovbaapi/ooo/vba/msforms/XReturnBoolean.idl
similarity index 89%
rename from oovbaapi/ooo/vba/msforms/ReturnSingle.idl
rename to oovbaapi/ooo/vba/msforms/XReturnBoolean.idl
index 6d2e07b..102cda1 100644
--- a/oovbaapi/ooo/vba/msforms/ReturnSingle.idl
+++ b/oovbaapi/ooo/vba/msforms/XReturnBoolean.idl
@@ -16,9 +16,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <com/sun/star/uno/XInterface.idl>
+
 module ooo { module vba { module msforms {
-    struct ReturnSingle
+    interface XReturnBoolean
     {
-        float Value;
+        [attribute] boolean Value;
     };
 }; }; };
diff --git a/oovbaapi/ooo/vba/msforms/ReturnEffect.idl b/oovbaapi/ooo/vba/msforms/XReturnEffect.idl
similarity index 89%
rename from oovbaapi/ooo/vba/msforms/ReturnEffect.idl
rename to oovbaapi/ooo/vba/msforms/XReturnEffect.idl
index 817b0cd..db656b9 100644
--- a/oovbaapi/ooo/vba/msforms/ReturnEffect.idl
+++ b/oovbaapi/ooo/vba/msforms/XReturnEffect.idl
@@ -16,10 +16,12 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <com/sun/star/uno/XInterface.idl>
+
 module ooo { module vba { module msforms {
-    struct ReturnEffect
+    interface XReturnEffect
     {
         //fmDropEffect Value;
-        short Value;
+        [attribute] short Value;
     };
 }; }; };
diff --git a/oovbaapi/ooo/vba/msforms/ReturnInteger.idl b/oovbaapi/ooo/vba/msforms/XReturnInteger.idl
similarity index 89%
rename from oovbaapi/ooo/vba/msforms/ReturnInteger.idl
rename to oovbaapi/ooo/vba/msforms/XReturnInteger.idl
index 3b949ad..f55a282 100644
--- a/oovbaapi/ooo/vba/msforms/ReturnInteger.idl
+++ b/oovbaapi/ooo/vba/msforms/XReturnInteger.idl
@@ -16,9 +16,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <com/sun/star/uno/XInterface.idl>
+
 module ooo { module vba { module msforms {
-    struct ReturnInteger
+    interface XReturnInteger
     {
-        long Value;
+        [attribute] long Value;
     };
 }; }; };
diff --git a/oovbaapi/ooo/vba/msforms/ReturnBoolean.idl b/oovbaapi/ooo/vba/msforms/XReturnSingle.idl
similarity index 89%
rename from oovbaapi/ooo/vba/msforms/ReturnBoolean.idl
rename to oovbaapi/ooo/vba/msforms/XReturnSingle.idl
index cd739dd..d92d2ea 100644
--- a/oovbaapi/ooo/vba/msforms/ReturnBoolean.idl
+++ b/oovbaapi/ooo/vba/msforms/XReturnSingle.idl
@@ -15,10 +15,11 @@
  *   except in compliance with the License. You may obtain a copy of
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
+#include <com/sun/star/uno/XInterface.idl>
 
 module ooo { module vba { module msforms {
-    struct ReturnBoolean
+    interface XReturnSingle
     {
-        boolean Value;
+        [attribute] float Value;
     };
 }; }; };
diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx
index 97fc38d..207973c 100644
--- a/scripting/source/vbaevents/eventhelper.cxx
+++ b/scripting/source/vbaevents/eventhelper.cxx
@@ -58,8 +58,6 @@
 #include <com/sun/star/awt/XRadioButton.hpp>
 #include <com/sun/star/awt/XListBox.hpp>
 
-#include <ooo/vba/msforms/ReturnInteger.hpp>
-
 #include <sfx2/objsh.hxx>
 #include <basic/sbstar.hxx>
 #include <basic/basmgr.hxx>
@@ -67,6 +65,7 @@
 #include <basic/sbmod.hxx>
 #include <basic/sbx.hxx>
 #include <filter/msfilter/msvbahelper.hxx>
+#include <vbahelper/vbareturntypes.hxx>
 
 // for debug
 #include <comphelper/anytostring.hxx>
@@ -160,9 +159,8 @@ Sequence< Any > ooKeyPressedToVBAKeyPressed( const Sequence< Any >& params )
 
     translatedParams.realloc(1);
 
-    msforms::ReturnInteger keyCode;
-    keyCode.Value = evt.KeyCode;
-    translatedParams[0] <<= keyCode;
+    Reference< msforms::XReturnInteger> xKeyCode = new ReturnInteger(  sal_Int32( evt.KeyCode ) );
+    translatedParams[0] <<= xKeyCode;
     return  translatedParams;
 }
 
@@ -176,12 +174,11 @@ Sequence< Any > ooKeyPressedToVBAKeyUpDown( const Sequence< Any >& params )
 
     translatedParams.realloc(2);
 
-    msforms::ReturnInteger keyCode;
+    Reference< msforms::XReturnInteger> xKeyCode = new ReturnInteger(  evt.KeyCode );
     sal_Int8 shift = sal::static_int_cast<sal_Int8>( evt.Modifiers );
 
     // #TODO check whether values from OOO conform to values generated from vba
-    keyCode.Value = evt.KeyCode;
-    translatedParams[0] <<= keyCode;
+    translatedParams[0] <<= xKeyCode;
     translatedParams[1] <<= shift;
     return  translatedParams;
 }
commit 063709590ea7064230eb427a26eb00ac5bbf455e
Author: Noel Power <noel.power at suse.com>
Date:   Tue Apr 30 15:32:15 2013 +0100

    adjust components needed for CheckOptionToggleValue.xls testfile
    
    Change-Id: Id9aa26cac2f59829e8b00057c82dc52bbbbc20cb

diff --git a/sc/CppunitTest_sc_macros_test.mk b/sc/CppunitTest_sc_macros_test.mk
index bdf969d..ace83ce 100644
--- a/sc/CppunitTest_sc_macros_test.mk
+++ b/sc/CppunitTest_sc_macros_test.mk
@@ -90,6 +90,8 @@ $(eval $(call gb_CppunitTest_use_components,sc_macros_test,\
 	    sc/util/vbaobj) \
     scripting/source/basprov/basprov \
     scripting/util/scriptframe \
+    scripting/source/vbaevents/vbaevents \
+    scripting/source/dlgprov/dlgprov \
     sfx2/util/sfx \
     sot/util/sot \
     svl/source/fsstor/fsstorage \
@@ -105,6 +107,7 @@ $(eval $(call gb_CppunitTest_use_components,sc_macros_test,\
     xmloff/util/xo \
     eventattacher/source/evtatt \
     i18npool/source/search/i18nsearch \
+    vbahelper/util/msforms \
 ))
 
 $(eval $(call gb_CppunitTest_use_configuration,sc_macros_test))
commit 28c4fd5effeeb03cf69ba3f3637df24c814436ce
Author: Noel Power <noel.power at suse.com>
Date:   Tue Apr 30 09:57:58 2013 +0100

    add new vba test file ( for testing input/output for 'Value' attributes )
    
    Change-Id: I7b06c463a11b5d6442f69130e9eee767004e426f

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 468eba0..4e37760 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -170,6 +170,10 @@ void ScMacrosTest::testVba()
             OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
         },
 #endif
+        {
+            OUString("CheckOptionToggleValue."),
+            OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
+        },
     };
 
     for ( sal_uInt32  i=0; i<SAL_N_ELEMENTS( testInfo ); ++i )
diff --git a/sc/qa/extras/testdocuments/CheckOptionToggleValue.xls b/sc/qa/extras/testdocuments/CheckOptionToggleValue.xls
new file mode 100755
index 0000000..14cf152
Binary files /dev/null and b/sc/qa/extras/testdocuments/CheckOptionToggleValue.xls differ
commit bb1ff2338396a665f2c83287c99945a2a7f7b73e
Author: Noel Power <noel.power at suse.com>
Date:   Mon Apr 29 19:41:45 2013 +0100

    create togglebutton class ( for togglebutton on sheet )
    
    Change-Id: If987eb6ed04d80e62b4b418e8f9de3a143ef68a7

diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index b788368..516cfa6 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -615,7 +615,14 @@ void SAL_CALL ScVbaControl::setTabIndex( sal_Int32 /*nTabIndex*/ ) throw (uno::R
         case form::FormComponentType::COMBOBOX:
             return new ScVbaComboBox( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
         case form::FormComponentType::COMMANDBUTTON:
-            return new ScVbaButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
+        {
+            sal_Bool bToggle = sal_False;
+            xProps->getPropertyValue( "Toggle" ) >>= bToggle;
+            if ( bToggle )
+                return new ScVbaToggleButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
+            else
+                return new ScVbaButton( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
+        }
         case form::FormComponentType::FIXEDTEXT:
             return new ScVbaLabel( xVbaParent, xContext, xControlShape, xModel, xGeoHelper.release() );
         case form::FormComponentType::TEXTFIELD:
commit 89e1382ebfb4d6d868bf4baee37fe31c6fec0bc8
Author: Noel Power <noel.power at suse.com>
Date:   Thu Apr 18 16:35:08 2013 +0100

    handle bool value for checkbox, radiobutton, togglebutton consistently
    
    Change-Id: I1f9057e58fe3625e0b76a09d79c7c56e1838d98a

diff --git a/vbahelper/source/msforms/vbacheckbox.cxx b/vbahelper/source/msforms/vbacheckbox.cxx
index de32e34..63ee9fd 100644
--- a/vbahelper/source/msforms/vbacheckbox.cxx
+++ b/vbahelper/source/msforms/vbacheckbox.cxx
@@ -65,17 +65,16 @@ ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeExcept
     sal_Int16 nValue = 0;
     sal_Int16 nOldValue = 0;
     m_xProps->getPropertyValue( STATE ) >>= nOldValue;
-    sal_Bool bValue = false;
-    if( _value >>= nValue )
-    {
-        if( nValue == -1)
-            nValue = 1;
-    }
-    else if ( _value >>= bValue )
+    if( !( _value >>= nValue ) )
     {
+        sal_Bool bValue = false;
+        _value >>= bValue;
         if ( bValue )
-            nValue = 1;
+            nValue = -1;
     }
+
+    if( nValue == -1)
+        nValue = 1;
     m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
     if ( nValue != nOldValue )
         fireClickEvent();
diff --git a/vbahelper/source/msforms/vbaradiobutton.cxx b/vbahelper/source/msforms/vbaradiobutton.cxx
index 10dabf8..f15d817 100644
--- a/vbahelper/source/msforms/vbaradiobutton.cxx
+++ b/vbahelper/source/msforms/vbaradiobutton.cxx
@@ -66,17 +66,16 @@ ScVbaRadioButton::setValue( const uno::Any& _value ) throw (uno::RuntimeExceptio
     sal_Int16 nOldValue = 0;
     m_xProps->getPropertyValue( STATE ) >>= nOldValue;
 
-    sal_Bool bValue = sal_False;
-    if( _value >>= nValue )
-    {
-        if( nValue == -1)
-        nValue = 1;
-    }
-    else if ( _value >>= bValue )
+    if( !( _value >>= nValue ) )
     {
+        sal_Bool bValue = sal_False;
+        _value >>= bValue;
         if ( bValue )
-            nValue = 1;
+            nValue = -1;
     }
+
+    if( nValue == -1)
+        nValue = 1;
     m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
     if ( nValue != nOldValue )
     {
diff --git a/vbahelper/source/msforms/vbatogglebutton.cxx b/vbahelper/source/msforms/vbatogglebutton.cxx
index 93073bc..ce9c007 100644
--- a/vbahelper/source/msforms/vbatogglebutton.cxx
+++ b/vbahelper/source/msforms/vbatogglebutton.cxx
@@ -66,11 +66,17 @@ void SAL_CALL
 ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
 {
     sal_Int16 nState = 0;
-    _value >>= nState;
+    if ( ! ( _value >>= nState ) )
+    {
+        sal_Bool bState = false;
+        _value >>= bState;
+        if ( bState )
+            nState = -1;
+    }
     SAL_INFO("vbahelper", "nState - " << nState );
     nState = ( nState == -1 ) ?  1 : 0;
     SAL_INFO("vbahelper", "nState - " << nState );
-    m_xProps->setPropertyValue( STATE, uno::makeAny(  nState ) );
+    m_xProps->setPropertyValue( STATE, uno::makeAny(   nState ) );
 }
 
 sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException)


More information about the Libreoffice-commits mailing list