Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


would be very handy to have these in 3.5, these are a bunch of *mostly* vba api implementations ( some cases partial ) and as such should pose little/no risk to the core code. Please cherry pick

Noel

details...

0001-implement-VBA-Application.DisplayFullScreen-bnc-7578.patch ( backport of master 4fa65f95e86dc4e348c83814475b057e8f30c107 ) - should be very safe, just api implementation 0002-vba-api-Application.DisplayScrollBars-implementation.patch ( backport of master f2cf3f30a76cb257bf44f9651b295280fb12d4aa ) 0003-add-stub-vba-implementation-Application-methods.patch ( backport of 101132c28a8f084612106337f4cafe21c535dea8 ) - very safe just vba api ( that does nothing ) 0004-add-support-for-MousePointer-attribute-in-controls.patch ( backport of f39d0b837742c69488e43e919f7f1a927c2859ed ) - very safe, again just vba api 0005-add-vba-support-for-BackColor-AutoSize-Locked-attrib.patch ( backport or master 4a58577fc89d4ee00af5941b0205dd6dc4b1dc10 and squash with some various patches in master to add missing SAL_CALL(s) to some method added here ) - again very safe changes limited to vba api implementation 0006-vba-implementation-for-Application.OnKey.patch ( backport ( and squash ) of master 75fbed472cd689c8cc0b89e13a97969d77a0ea7c & master 14620c3b33cf0315a9b746a0a2418b78d6154821 - impacts a few things, the api part should be safe, there is additionally some tweaking of vbamodule import to try and import the keybinding if it exists, should be ok 0007-support-Sheets.PrintPreview-bnc-757844.patch ( backport of master 17c8f6745f9f98013c1b08de8ec03be66546c7fc ) - again just api, should be safe
From 75e5687c02377c04c47e6ac6fb4c70b3ec570e3e Mon Sep 17 00:00:00 2001
From: Noel Power <noel.power@novell.com>
Date: Fri, 11 May 2012 10:43:33 +0100
Subject: [PATCH 1/7] implement VBA Application.DisplayFullScreen bnc#757885

---
 oovbaapi/ooo/vba/excel/XApplication.idl |    1 +
 sc/source/ui/inc/viewutil.hxx           |    2 +-
 sc/source/ui/vba/vbaapplication.cxx     |   20 ++++++++++++++++++++
 sc/source/ui/vba/vbaapplication.hxx     |    2 ++
 4 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl
index e9bee9b..6453011 100644
--- a/oovbaapi/ooo/vba/excel/XApplication.idl
+++ b/oovbaapi/ooo/vba/excel/XApplication.idl
@@ -74,6 +74,7 @@ interface XApplication
     [attribute] boolean Visible;
     [attribute] boolean Iteration;
     [attribute] long EnableCancelKey;
+    [attribute] boolean DisplayFullScreen;
 
     void setDefaultFilePath([in] string DefaultFilePath) 
raises(com::sun::star::script::BasicErrorException);
 
diff --git a/sc/source/ui/inc/viewutil.hxx b/sc/source/ui/inc/viewutil.hxx
index d01faea..87d8f80 100644
--- a/sc/source/ui/inc/viewutil.hxx
+++ b/sc/source/ui/inc/viewutil.hxx
@@ -50,7 +50,7 @@ enum ScUpdateMode { SC_UPDATE_ALL, SC_UPDATE_CHANGED, SC_UPDATE_MARKS };
 
 // ---------------------------------------------------------------------------
 
-class ScViewUtil                                // static Methoden
+class SC_DLLPUBLIC ScViewUtil                                                          // static 
Methoden
 {
 public:
     static sal_Bool ExecuteCharMap( const SvxFontItem&  rOldFont,
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index d1102b7..8b5344c 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -123,6 +123,8 @@
 #include <basic/sbuno.hxx>
 
 #include "vbafiledialog.hxx"
+#include "viewutil.hxx"
+
 using namespace ::ooo::vba;
 using namespace ::com::sun::star;
 using ::com::sun::star::uno::Reference;
@@ -879,6 +881,24 @@ ScVbaApplication::getEnableEvents() throw (uno::RuntimeException)
 }
 
 sal_Bool SAL_CALL
+ScVbaApplication::getDisplayFullScreen()  throw (uno::RuntimeException)
+{
+    SfxViewShell* pShell  = excel::getCurrentBestViewShell( mxContext );
+    if ( pShell )
+        return ScViewUtil::IsFullScreen( *pShell );
+    return sal_False;
+}
+
+void SAL_CALL
+ScVbaApplication::setDisplayFullScreen( sal_Bool bSet )  throw (uno::RuntimeException)
+{
+    // #FIXME calling  ScViewUtil::SetFullScreen( *pShell, bSet );
+    // directly results in a strange crash, using dispatch instead
+    if ( bSet != getDisplayFullScreen() )
+        dispatchRequests( getCurrentDocument(), rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM(".uno:FullScreen") ) );
+}
+
+sal_Bool SAL_CALL
 ScVbaApplication::getVisible() throw (uno::RuntimeException)
 {
     sal_Bool bVisible = sal_True;
diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx
index 8481690..38765e5 100644
--- a/sc/source/ui/vba/vbaapplication.hxx
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -122,6 +122,8 @@ public:
     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 getDisplayFullScreen() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setDisplayFullScreen( 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);
-- 
1.7.3.4

From 1f3e5e1c9818491f01e060d97e0743129c65ddc9 Mon Sep 17 00:00:00 2001
From: Noel Power <noel.power@novell.com>
Date: Fri, 20 Apr 2012 17:57:02 +0100
Subject: [PATCH 2/7] vba api Application.DisplayScrollBars implementation bnc#757840

---
 oovbaapi/ooo/vba/excel/XApplication.idl |    1 +
 sc/source/ui/vba/vbaapplication.cxx     |   21 +++++++++++++++++++++
 sc/source/ui/vba/vbaapplication.hxx     |    2 ++
 3 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl
index 6453011..866ab21 100644
--- a/oovbaapi/ooo/vba/excel/XApplication.idl
+++ b/oovbaapi/ooo/vba/excel/XApplication.idl
@@ -75,6 +75,7 @@ interface XApplication
     [attribute] boolean Iteration;
     [attribute] long EnableCancelKey;
     [attribute] boolean DisplayFullScreen;
+    [attribute] boolean DisplayScrollBars;
 
     void setDefaultFilePath([in] string DefaultFilePath) 
raises(com::sun::star::script::BasicErrorException);
 
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 8b5344c..ce8be4e 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -899,6 +899,27 @@ ScVbaApplication::setDisplayFullScreen( sal_Bool bSet )  throw 
(uno::RuntimeExce
 }
 
 sal_Bool SAL_CALL
+ScVbaApplication::getDisplayScrollBars()  throw (uno::RuntimeException)
+{
+    ScTabViewShell* pShell  = excel::getCurrentBestViewShell( mxContext );
+    if ( pShell )
+    {
+        return ( pShell->GetViewData()->IsHScrollMode() && pShell->GetViewData()->IsVScrollMode() 
);
+    }
+    return true;
+}
+
+void SAL_CALL
+ScVbaApplication::setDisplayScrollBars( sal_Bool bSet )  throw (uno::RuntimeException)
+{
+    // use uno here as it does all he repainting etc. magic
+    uno::Reference< sheet::XSpreadsheetView > xView( getCurrentDocument()->getCurrentController(), 
uno::UNO_QUERY_THROW );
+    uno::Reference< beans::XPropertySet > xProps( xView, uno::UNO_QUERY );
+    xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HasVerticalScrollBar") 
), uno::makeAny( bSet ) );
+    xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HasHorizontalScrollBar") 
), uno::makeAny( bSet ) );
+}
+
+sal_Bool SAL_CALL
 ScVbaApplication::getVisible() throw (uno::RuntimeException)
 {
     sal_Bool bVisible = sal_True;
diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx
index 38765e5..9e5d7f7 100644
--- a/sc/source/ui/vba/vbaapplication.hxx
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -124,6 +124,8 @@ public:
 
     virtual sal_Bool SAL_CALL getDisplayFullScreen() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setDisplayFullScreen( sal_Bool bSet ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getDisplayScrollBars() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setDisplayScrollBars( 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);
-- 
1.7.3.4

From 2889bf3397dad2b5a83e045c3b45c7a34cf44f88 Mon Sep 17 00:00:00 2001
From: Noel Power <noel.power@novell.com>
Date: Fri, 20 Apr 2012 18:25:45 +0100
Subject: [PATCH 3/7] add stub vba implementation Application methods

added Application.DisplayExcel4Menus, Application.DisplayNoteIndicator, 
Application.ShowWindowsInTaskbar. Althought these attributes of the Application object don't do 
anything they allow setting and retrieval of the state. We could make a usable implementation for 
Application.DisplayNoteIndicator, the others though don't really seem to have any useful equivalent 
in the libreoffice world
---
 oovbaapi/ooo/vba/excel/XApplication.idl |    3 ++
 sc/source/ui/vba/vbaapplication.cxx     |   45 +++++++++++++++++++++++++++++-
 sc/source/ui/vba/vbaapplication.hxx     |    7 +++++
 3 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl
index 866ab21..baf6468 100644
--- a/oovbaapi/ooo/vba/excel/XApplication.idl
+++ b/oovbaapi/ooo/vba/excel/XApplication.idl
@@ -76,6 +76,9 @@ interface XApplication
     [attribute] long EnableCancelKey;
     [attribute] boolean DisplayFullScreen;
     [attribute] boolean DisplayScrollBars;
+    [attribute] boolean DisplayExcel4Menus;
+    [attribute] boolean DisplayNoteIndicator;
+    [attribute] boolean ShowWindowsInTaskbar;
 
     void setDefaultFilePath([in] string DefaultFilePath) 
raises(com::sun::star::script::BasicErrorException);
 
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index ce8be4e..20bb19c 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -158,14 +158,19 @@ struct ScVbaAppSettings
     sal_Int32 mnCalculation;
     sal_Bool mbDisplayAlerts;
     sal_Bool mbEnableEvents;
-
+    sal_Bool mbExcel4Menus;
+    sal_Bool mbDisplayNoteIndicator;
+    sal_Bool mbShowWindowsInTaskbar;
     explicit ScVbaAppSettings();
 };
 
 ScVbaAppSettings::ScVbaAppSettings() :
     mnCalculation( excel::XlCalculation::xlCalculationAutomatic ),
     mbDisplayAlerts( sal_True ),
-    mbEnableEvents( sal_True )
+    mbEnableEvents( sal_True ),
+    mbExcel4Menus( sal_False ),
+    mbDisplayNoteIndicator( sal_True ),
+    mbShowWindowsInTaskbar( sal_True )
 {
 }
 
@@ -920,6 +925,42 @@ ScVbaApplication::setDisplayScrollBars( sal_Bool bSet )  throw 
(uno::RuntimeExce
 }
 
 sal_Bool SAL_CALL
+ScVbaApplication::getDisplayExcel4Menus() throw (css::uno::RuntimeException)
+{
+    return mrAppSettings.mbExcel4Menus;
+}
+
+void SAL_CALL
+ScVbaApplication::setDisplayExcel4Menus( sal_Bool bSet ) throw (css::uno::RuntimeException)
+{
+    mrAppSettings.mbExcel4Menus = bSet;
+}
+
+sal_Bool SAL_CALL
+ScVbaApplication::getDisplayNoteIndicator() throw (css::uno::RuntimeException)
+{
+    return mrAppSettings.mbDisplayNoteIndicator;
+}
+
+void SAL_CALL
+ScVbaApplication::setDisplayNoteIndicator( sal_Bool bSet ) throw (css::uno::RuntimeException)
+{
+    mrAppSettings.mbDisplayNoteIndicator = bSet;
+}
+
+sal_Bool SAL_CALL
+ScVbaApplication::getShowWindowsInTaskbar() throw (css::uno::RuntimeException)
+{
+    return mrAppSettings.mbShowWindowsInTaskbar;
+}
+
+void SAL_CALL
+ScVbaApplication::setShowWindowsInTaskbar( sal_Bool bSet ) throw (css::uno::RuntimeException)
+{
+    mrAppSettings.mbShowWindowsInTaskbar = bSet;
+}
+
+sal_Bool SAL_CALL
 ScVbaApplication::getVisible() throw (uno::RuntimeException)
 {
     sal_Bool bVisible = sal_True;
diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx
index 9e5d7f7..95703f0 100644
--- a/sc/source/ui/vba/vbaapplication.hxx
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -126,6 +126,13 @@ public:
     virtual void SAL_CALL setDisplayFullScreen( sal_Bool bSet ) throw (css::uno::RuntimeException);
     virtual sal_Bool SAL_CALL getDisplayScrollBars() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setDisplayScrollBars( sal_Bool bSet ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getDisplayExcel4Menus() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setDisplayExcel4Menus( sal_Bool bSet ) throw 
(css::uno::RuntimeException);
+
+    virtual sal_Bool SAL_CALL getDisplayNoteIndicator() throw (css::uno::RuntimeException);
+    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 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);
-- 
1.7.3.4

From 9e9dda6c227ce9067f6cd9889bc9ffc13dbfd441 Mon Sep 17 00:00:00 2001
From: Noel Power <noel.power@novell.com>
Date: Thu, 5 Apr 2012 14:17:24 +0100
Subject: [PATCH 4/7] add support for MousePointer attribute in controls

For Useforms it doesn't quite work exactly as MSO, for examply if we set the MousePointer for the 
Userform it works as expected until we mouse over another control at which point the mouse pointer 
is changed to that of the control. In MSO it would appear that the Userform mousepointer is king, 
perhaps all that is necessary is to apply the mouse pointer to each contained control, needs some 
investigation. Also only a limited number of the possible mouse pointer styles are processed, the 
conversions of mso -> lo pointer styles ( and vice-versa ) and not really tested to see if they all 
make sense
---
 oovbaapi/ooo/vba/msforms/XControl.idl   |    1 +
 vbahelper/source/msforms/vbacontrol.cxx |   84 ++++++++++++++++++++++++++++++-
 vbahelper/source/msforms/vbacontrol.hxx |    2 +
 3 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/oovbaapi/ooo/vba/msforms/XControl.idl b/oovbaapi/ooo/vba/msforms/XControl.idl
index 5ece205..9f2c6ee 100644
--- a/oovbaapi/ooo/vba/msforms/XControl.idl
+++ b/oovbaapi/ooo/vba/msforms/XControl.idl
@@ -44,6 +44,7 @@ interface XControl
     [attribute] string RowSource;
     [attribute] boolean Enabled;
     [attribute] boolean Visible;
+    [attribute] long MousePointer;
     //Size. there are some defferent between Mso and OOo.
     //Mso use double but OOo use long. OOo 1 =  1/100mm but Mso use pt.
     //in Dialogs Mso uses pixels
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index 195e34e..03cd014 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -45,6 +45,7 @@
 #include <com/sun/star/document/XCodeNameQuery.hpp>
 #include <com/sun/star/form/XChangeListener.hpp>
 #include <ooo/vba/XControlProvider.hpp>
+#include <ooo/vba/msforms/fmMousePointer.hpp>
 #ifdef VBA_OOBUILD_HACK
 #include <svtools/bindablecontrolhelper.hxx>
 #endif
@@ -65,8 +66,8 @@
 #include "vbasystemaxcontrol.hxx"
 #include "vbaimage.hxx"
 #include <vbahelper/helperdecl.hxx>
-
-
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/window.hxx>
 using namespace com::sun::star;
 using namespace ooo::vba;
 
@@ -423,6 +424,85 @@ void SAL_CALL ScVbaControl::setForeColor( ::sal_Int32 _forecolor ) throw 
(::com:
      m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextColor" ) ), 
uno::makeAny( XLRGBToOORGB( _forecolor ) ) );
 }
 
+struct PointerStyles
+{
+   long msoPointerStyle;
+   PointerStyle loPointStyle;
+};
+
+// 1 -> 1 map of styles ( some dubious choices in there though )
+PointerStyles styles[] = {
+  /// assuming pointer default is Arrow
+  { msforms::fmMousePointer::fmMousePointerDefault, POINTER_ARROW },
+  { msforms::fmMousePointer::fmMousePointerArrow, POINTER_ARROW },
+  { msforms::fmMousePointer::fmMousePointerCross, POINTER_CROSS },
+  { msforms::fmMousePointer::fmMousePointerIBeam, POINTER_TEXT },
+  { msforms::fmMousePointer::fmMousePointerSizeNESW,  POINTER_AUTOSCROLL_NSWE   }, // #TODO not 
correct, need to check, need to find the right one
+  { msforms::fmMousePointer::fmMousePointerSizeNS,  POINTER_AUTOSCROLL_NS  },
+  { msforms::fmMousePointer::fmMousePointerSizeNWSE,  POINTER_AUTOSCROLL_NSWE  }, // #TODO not 
correct, need to check, need to find the right one
+  { msforms::fmMousePointer::fmMousePointerSizeWE,  POINTER_AUTOSCROLL_WE },
+  { msforms::fmMousePointer::fmMousePointerUpArrow, POINTER_WINDOW_NSIZE  },
+  { msforms::fmMousePointer::fmMousePointerHourGlass, POINTER_WAIT  },
+  { msforms::fmMousePointer::fmMousePointerNoDrop, POINTER_NOTALLOWED },
+  { msforms::fmMousePointer::fmMousePointerAppStarting, POINTER_WAIT },
+  { msforms::fmMousePointer::fmMousePointerHelp, POINTER_HELP },
+  { msforms::fmMousePointer::fmMousePointerSizeAll, POINTER_CROSS },
+  { msforms::fmMousePointer::fmMousePointerCustom, POINTER_ARROW }, // not supported I guess
+
+};
+
+long lcl_loPointerToMsoPointer( PointerStyle eType )
+{
+    long nRet = msforms::fmMousePointer::fmMousePointerDefault;
+    for ( int i = 0, nElems = SAL_N_ELEMENTS( styles ); i < nElems; ++i )
+    {
+        if ( styles[ i ].loPointStyle == eType )
+        {
+            nRet = styles[ i ].msoPointerStyle;
+            break;
+        }
+    }
+    return nRet;
+}
+
+Pointer lcl_msoPointerToLOPointer( long msoPointerStyle )
+{
+    Pointer aPointer( POINTER_ARROW );
+    for ( int i = 0, nElems = SAL_N_ELEMENTS( styles ); i < nElems; ++i )
+    {
+        if ( styles[ i ].msoPointerStyle == msoPointerStyle )
+        {
+            aPointer = Pointer( styles[ i ].loPointStyle );
+            break;
+         }
+    }
+    return aPointer;
+}
+
+::sal_Int32 SAL_CALL
+ScVbaControl::getMousePointer() throw (::com::sun::star::uno::RuntimeException)
+{
+    PointerStyle eType = POINTER_ARROW; // default ?
+    Window* pWindow = VCLUnoHelper::GetWindow( getWindowPeer() );
+    if ( pWindow )
+    {
+        eType = pWindow->GetPointer().GetStyle();
+    }
+    return lcl_loPointerToMsoPointer( eType );
+}
+
+void SAL_CALL
+ScVbaControl::setMousePointer( ::sal_Int32 _mousepointer ) throw 
(::com::sun::star::uno::RuntimeException)
+{
+    Window* pWindow = VCLUnoHelper::GetWindow( getWindowPeer() );
+    if ( pWindow )
+    {
+        Pointer aPointer( POINTER_ARROW );
+        aPointer = lcl_msoPointerToLOPointer( _mousepointer );
+        pWindow->SetPointer( aPointer );
+    }
+}
+
 void ScVbaControl::fireEvent( script::ScriptEvent& evt )
 {
     uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), 
uno::UNO_QUERY_THROW );
diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx
index 9076a3e..597c635 100644
--- a/vbahelper/source/msforms/vbacontrol.hxx
+++ b/vbahelper/source/msforms/vbacontrol.hxx
@@ -107,6 +107,8 @@ public:
     virtual void SAL_CALL setTag( const ::rtl::OUString& aTag ) throw (css::uno::RuntimeException);
     virtual sal_Int32 SAL_CALL getTabIndex() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setTabIndex( sal_Int32 nTabIndex ) throw (css::uno::RuntimeException);
+    virtual ::sal_Int32 SAL_CALL getMousePointer() throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setMousePointer( ::sal_Int32 _mousepointer ) throw 
(::com::sun::star::uno::RuntimeException);
     //remove resouce because ooo.vba.excel.XControl is a wrapper of 
com.sun.star.drawing.XControlShape
     virtual void removeResouce() throw( css::uno::RuntimeException );
     virtual ::sal_Int32 SAL_CALL getForeColor() throw (::com::sun::star::uno::RuntimeException);
-- 
1.7.3.4

From 191afc2b10bab284ed44226bec556447e4a44f9f Mon Sep 17 00:00:00 2001
From: Noel Power <noel.power@novell.com>
Date: Tue, 20 Mar 2012 15:35:30 +0000
Subject: [PATCH 5/7] add vba support for BackColor, AutoSize, Locked attributes bnc#749960

---
 oovbaapi/UnoApi_oovbaapi.mk                  |    1 +
 oovbaapi/ooo/vba/SystemColorConstants.idl    |   31 +++++++++++++++++++
 oovbaapi/ooo/vba/msforms/XCheckBox.idl       |    3 ++
 oovbaapi/ooo/vba/msforms/XComboBox.idl       |    3 ++
 oovbaapi/ooo/vba/msforms/XCommandButton.idl  |    3 +-
 oovbaapi/ooo/vba/msforms/XImage.idl          |    1 +
 oovbaapi/ooo/vba/msforms/XLabel.idl          |    2 +
 oovbaapi/ooo/vba/msforms/XTextBox.idl        |    3 ++
 vbahelper/source/msforms/vbabutton.cxx       |   21 ++++++++++---
 vbahelper/source/msforms/vbabutton.hxx       |    2 +
 vbahelper/source/msforms/vbacheckbox.cxx     |   29 ++++++++++++++++++
 vbahelper/source/msforms/vbacheckbox.hxx     |    6 ++++
 vbahelper/source/msforms/vbacombobox.cxx     |   29 ++++++++++++++++++
 vbahelper/source/msforms/vbacombobox.hxx     |    6 ++++
 vbahelper/source/msforms/vbacontrol.cxx      |   42 ++++++++++++++++++++++++++
 vbahelper/source/msforms/vbacontrol.hxx      |    8 +++++
 vbahelper/source/msforms/vbaimage.cxx        |   10 ++++++
 vbahelper/source/msforms/vbaimage.hxx        |    2 +
 vbahelper/source/msforms/vbalabel.cxx        |   20 ++++++++++++
 vbahelper/source/msforms/vbalabel.hxx        |    4 ++
 vbahelper/source/msforms/vbatextbox.cxx      |   30 ++++++++++++++++++
 vbahelper/source/msforms/vbatextbox.hxx      |    7 ++++
 vbahelper/source/msforms/vbatogglebutton.cxx |   20 ++++++++++--
 vbahelper/source/msforms/vbatogglebutton.hxx |    2 +
 24 files changed, 275 insertions(+), 10 deletions(-)
 create mode 100644 oovbaapi/ooo/vba/SystemColorConstants.idl

diff --git a/oovbaapi/UnoApi_oovbaapi.mk b/oovbaapi/UnoApi_oovbaapi.mk
index 57a0c11..00eeb88 100644
--- a/oovbaapi/UnoApi_oovbaapi.mk
+++ b/oovbaapi/UnoApi_oovbaapi.mk
@@ -75,6 +75,7 @@ $(eval $(call gb_UnoApiTarget_add_idlfiles,oovbaapi,oovbaapi/ooo/vba,\
     VbMsgBoxStyle \
     VbQueryClose \
     VbStrConv \
+    SystemColorConstants \
     VbTriState \
     VbVarType \
        XApplicationBase \
diff --git a/oovbaapi/ooo/vba/SystemColorConstants.idl b/oovbaapi/ooo/vba/SystemColorConstants.idl
new file mode 100644
index 0000000..e0760f1
--- /dev/null
+++ b/oovbaapi/ooo/vba/SystemColorConstants.idl
@@ -0,0 +1,31 @@
+module ooo { module vba {
+    constants SystemColorConstants {
+
+    const long vbScrollBars = -2147483648;// 0x80000000;
+    const long vbDesktop = -2147483647; //0x80000001;
+    const long vbActiveTitleBar = -2147483646; //0x80000002;
+    const long vbInactiveTitleBar = -2147483645; //0x80000003;
+    const long vbMenuBar = -2147483644; //0x80000004;
+    const long vbWindowBackground = -2147483643; //0x80000005;
+    const long vbWindowFrame = -2147483642; //0x80000006;
+    const long vbMenuText = -2147483641; //0x80000007;
+    const long vbWindowText = -2147483640; //0x80000008;
+    const long vbTitleBarText = -2147483639; //0x80000009;
+    const long vbActiveBorder = -2147483638; //0x8000000A;
+    const long vbInactiveBorder = -2147483637; //0x8000000B;
+    const long vbApplicationWorkspace = -2147483636; //0x8000000C;
+    const long vbHighlight = -2147483635; //0x8000000D;
+    const long vbHighlightText = -2147483634; //0x8000000E;
+    const long vbButtonFace = -2147483633; //0x8000000F;
+    const long vbButtonShadow = -2147483632; //0x80000010;
+    const long vbGrayText = -2147483631; //0x80000011;
+    const long vbButtonText = -2147483630; //0x80000012;
+    const long vbInactiveCaptionText = -2147483629; //0x80000013;
+    const long vb3DHighlight = -2147483628; //0x80000014;
+    const long vb3DDKShadow = -2147483627; //0x80000015;
+    const long vb3DLight = -2147483626; //0x80000016;
+    const long vbInfoText = -2147483625; //0x80000017;
+    const long vbInfoBackground = -2147483624; //0x80000018;
+
+    };
+}; };
diff --git a/oovbaapi/ooo/vba/msforms/XCheckBox.idl b/oovbaapi/ooo/vba/msforms/XCheckBox.idl
index ec2c713..fc58d3e 100644
--- a/oovbaapi/ooo/vba/msforms/XCheckBox.idl
+++ b/oovbaapi/ooo/vba/msforms/XCheckBox.idl
@@ -39,6 +39,9 @@ interface XCheckBox: com::sun::star::uno::XInterface
 {
     [attribute] string Caption;
     [attribute] any Value;
+    [attribute] long BackColor;
+    [attribute] boolean AutoSize;
+    [attribute] boolean Locked;
     [attribute, readonly] XNewFont Font;
 };
 
diff --git a/oovbaapi/ooo/vba/msforms/XComboBox.idl b/oovbaapi/ooo/vba/msforms/XComboBox.idl
index 77b5e95..7eacf25 100644
--- a/oovbaapi/ooo/vba/msforms/XComboBox.idl
+++ b/oovbaapi/ooo/vba/msforms/XComboBox.idl
@@ -49,6 +49,9 @@ interface XComboBox
     [attribute] long EnterFieldBehavior;
     [attribute] long ListStyle;
     [attribute] long TextAlign;
+    [attribute] long BackColor;
+    [attribute] boolean AutoSize;
+    [attribute] boolean Locked;
     [attribute, readonly] long TextLength;
     [attribute, readonly] XNewFont Font;
 
diff --git a/oovbaapi/ooo/vba/msforms/XCommandButton.idl 
b/oovbaapi/ooo/vba/msforms/XCommandButton.idl
index 0e7697c..d71472e 100644
--- a/oovbaapi/ooo/vba/msforms/XCommandButton.idl
+++ b/oovbaapi/ooo/vba/msforms/XCommandButton.idl
@@ -39,11 +39,12 @@ module ooo {  module vba {  module msforms {
 interface XCommandButton
 {
     [attribute] string Caption;
-    [attribute] boolean AutoSize;
     [attribute] boolean Cancel;
     [attribute] boolean Default;
     [attribute] long BackColor;
     [attribute] long ForeColor;
+    [attribute] boolean AutoSize;
+    [attribute] boolean Locked;
     [attribute, readonly] XNewFont Font;
 };
 
diff --git a/oovbaapi/ooo/vba/msforms/XImage.idl b/oovbaapi/ooo/vba/msforms/XImage.idl
index 2c77aac..ec40c4a 100644
--- a/oovbaapi/ooo/vba/msforms/XImage.idl
+++ b/oovbaapi/ooo/vba/msforms/XImage.idl
@@ -35,6 +35,7 @@ module ooo {  module vba {  module msforms {
 //=============================================================================
 interface XImage: com::sun::star::uno::XInterface
 {
+    [attribute] long BackColor;
 };
 
 //=============================================================================
diff --git a/oovbaapi/ooo/vba/msforms/XLabel.idl b/oovbaapi/ooo/vba/msforms/XLabel.idl
index 10a92dc..c0ed739 100644
--- a/oovbaapi/ooo/vba/msforms/XLabel.idl
+++ b/oovbaapi/ooo/vba/msforms/XLabel.idl
@@ -42,6 +42,8 @@ interface XLabel
     [attribute] string Caption;
     [attribute] any Value;
     [attribute] string Accelerator;
+    [attribute] long BackColor;
+    [attribute] boolean AutoSize;
     [attribute, readonly] XNewFont Font;
 };
 
diff --git a/oovbaapi/ooo/vba/msforms/XTextBox.idl b/oovbaapi/ooo/vba/msforms/XTextBox.idl
index 75aaf83..1dceb86 100644
--- a/oovbaapi/ooo/vba/msforms/XTextBox.idl
+++ b/oovbaapi/ooo/vba/msforms/XTextBox.idl
@@ -45,6 +45,9 @@ interface XTextBox
     [attribute] boolean Multiline;
     [attribute] long SpecialEffect;
     [attribute] long BorderStyle;
+    [attribute] long BackColor;
+    [attribute] boolean AutoSize;
+    [attribute] boolean Locked;
     [attribute, readonly] long TextLength;
     [attribute, readonly] XNewFont Font;
 };
diff --git a/vbahelper/source/msforms/vbabutton.cxx b/vbahelper/source/msforms/vbabutton.cxx
index f076333..8912b6d 100644
--- a/vbahelper/source/msforms/vbabutton.cxx
+++ b/vbahelper/source/msforms/vbabutton.cxx
@@ -55,11 +55,22 @@ ScVbaButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star
 
 sal_Bool SAL_CALL ScVbaButton::getAutoSize() throw (uno::RuntimeException)
 {
-    return sal_False;
+    return ScVbaControl::getAutoSize();
+}
+
+void SAL_CALL ScVbaButton::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setAutoSize( bAutoSize );
+}
+
+sal_Bool SAL_CALL ScVbaButton::getLocked() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getLocked();
 }
 
-void SAL_CALL ScVbaButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException)
+void SAL_CALL ScVbaButton::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException)
 {
+    ScVbaControl::setLocked( bLocked );
 }
 
 sal_Bool SAL_CALL ScVbaButton::getCancel() throw (uno::RuntimeException)
@@ -82,16 +93,16 @@ void SAL_CALL ScVbaButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::Runti
 
 sal_Int32 SAL_CALL ScVbaButton::getBackColor() throw (uno::RuntimeException)
 {
-    return 0;
+    return ScVbaControl::getBackColor();
 }
 
-void SAL_CALL ScVbaButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw (uno::RuntimeException)
+void SAL_CALL ScVbaButton::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
 {
+    ScVbaControl::setBackColor( nBackColor );
 }
 
 sal_Int32 SAL_CALL ScVbaButton::getForeColor() throw (uno::RuntimeException)
 {
-    return 0;
 }
 
 void SAL_CALL ScVbaButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException)
diff --git a/vbahelper/source/msforms/vbabutton.hxx b/vbahelper/source/msforms/vbabutton.hxx
index e999acf..48bd099 100644
--- a/vbahelper/source/msforms/vbabutton.hxx
+++ b/vbahelper/source/msforms/vbabutton.hxx
@@ -52,6 +52,8 @@ public:
     virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
     virtual sal_Int32 SAL_CALL getForeColor() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getLocked() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setLocked( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
     virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw 
(css::uno::RuntimeException);
     //XHelperInterface
     virtual rtl::OUString& getServiceImplName();
diff --git a/vbahelper/source/msforms/vbacheckbox.cxx b/vbahelper/source/msforms/vbacheckbox.cxx
index 290cdd1..3d91943 100644
--- a/vbahelper/source/msforms/vbacheckbox.cxx
+++ b/vbahelper/source/msforms/vbacheckbox.cxx
@@ -114,4 +114,33 @@ ScVbaCheckbox::getServiceNames()
     return aServiceNames;
 }
 
+sal_Int32 SAL_CALL ScVbaCheckbox::getBackColor() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getBackColor();
+}
+
+void SAL_CALL ScVbaCheckbox::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setBackColor( nBackColor );
+}
+
+sal_Bool SAL_CALL ScVbaCheckbox::getAutoSize() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getAutoSize();
+}
+
+void SAL_CALL ScVbaCheckbox::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setAutoSize( bAutoSize );
+}
+
+sal_Bool SAL_CALL ScVbaCheckbox::getLocked() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getLocked();
+}
+
+void SAL_CALL ScVbaCheckbox::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setLocked( bLocked );
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbacheckbox.hxx b/vbahelper/source/msforms/vbacheckbox.hxx
index e6cc4fe..cc6cbee6 100644
--- a/vbahelper/source/msforms/vbacheckbox.hxx
+++ b/vbahelper/source/msforms/vbacheckbox.hxx
@@ -45,6 +45,12 @@ public:
     virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw 
(css::uno::RuntimeException);
     virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw 
(css::uno::RuntimeException);
+    virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getLocked() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setLocked( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
     // XDefaultProperty
     rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); }
     //XHelperInterface
diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx
index 6f5049c..689e8c4 100644
--- a/vbahelper/source/msforms/vbacombobox.cxx
+++ b/vbahelper/source/msforms/vbacombobox.cxx
@@ -278,6 +278,35 @@ ScVbaComboBox::getServiceImplName()
     static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaComboBox") );
     return sImplName;
 }
+sal_Int32 SAL_CALL ScVbaComboBox::getBackColor() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getBackColor();
+}
+
+void SAL_CALL ScVbaComboBox::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setBackColor( nBackColor );
+}
+
+sal_Bool SAL_CALL ScVbaComboBox::getAutoSize() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getAutoSize();
+}
+
+void SAL_CALL ScVbaComboBox::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setAutoSize( bAutoSize );
+}
+
+sal_Bool SAL_CALL ScVbaComboBox::getLocked() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getLocked();
+}
+
+void SAL_CALL ScVbaComboBox::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setLocked( bLocked );
+}
 
 uno::Sequence< rtl::OUString >
 ScVbaComboBox::getServiceNames()
diff --git a/vbahelper/source/msforms/vbacombobox.hxx b/vbahelper/source/msforms/vbacombobox.hxx
index e2b1716..8ab8855 100644
--- a/vbahelper/source/msforms/vbacombobox.hxx
+++ b/vbahelper/source/msforms/vbacombobox.hxx
@@ -73,6 +73,12 @@ public:
     virtual void SAL_CALL setTextAlign( sal_Int32 nTextAlign ) throw (css::uno::RuntimeException);
     virtual sal_Int32 SAL_CALL getTextLength() throw (css::uno::RuntimeException);
     virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw 
(css::uno::RuntimeException);
+    virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getLocked() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setLocked( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
 
     // Methods
     virtual void SAL_CALL AddItem( const css::uno::Any& pvargItem, const css::uno::Any& pvargIndex 
) throw (css::uno::RuntimeException);
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index 03cd014..a2dc55f 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -614,6 +614,8 @@ void SAL_CALL ScVbaControl::setTabIndex( sal_Int32 /*nTabIndex*/ ) throw (uno::R
             return new ScVbaSpinButton( xVbaParent, xContext, xControlShape, xModel, 
xGeoHelper.release() );
         case form::FormComponentType::IMAGECONTROL:
             return new ScVbaImage( xVbaParent, xContext, xControlShape, xModel, 
xGeoHelper.release() );
+        case form::FormComponentType::SCROLLBAR:
+            return new ScVbaScrollBar( xVbaParent, xContext, xControlShape, xModel, 
xGeoHelper.release() );
     }
     throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unsupported 
control.")), uno::Reference< uno::XInterface >() );
 }
@@ -699,6 +701,46 @@ ScVbaControl::getServiceNames()
     return aServiceNames;
 }
 
+sal_Int32 nSysCols[] = { 0xC8D0D4, 0x0, 0x6A240A, 0x808080, 0xE4E4E4, 0xFFFFFF, 0x0, 0x0, 0x0, 
0xFFFFFF, 0xE4E4E4, 0xE4E4E4, 0x808080, 0x6A240A, 0xFFFFFF, 0xE4E4E4, 0x808080, 0x808080, 0x0, 
0xC8D0D4, 0xFFFFFF, 0x404040, 0xE4E4E4, 0x0, 0xE1FFFF };
+
+sal_Int32 ScVbaControl::getBackColor() throw (uno::RuntimeException)
+{
+    sal_Int32 nBackColor = 0;
+    m_xProps->getPropertyValue(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ) ) 
= nBackColor;
+    return nBackColor;
+}
+
+void ScVbaControl::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
+{
+    if ( ( nBackColor >= (sal_Int32)0x80000000 ) && ( nBackColor <= (sal_Int32)0x80000018 ) )
+    {
+        nBackColor = nSysCols[ nBackColor - 0x80000000 ];
+    }
+    m_xProps->setPropertyValue(  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BackgroundColor") ), 
uno::makeAny( XLRGBToOORGB( nBackColor ) ) );
+}
+
+sal_Bool ScVbaControl::getAutoSize() throw (uno::RuntimeException)
+{
+    return sal_False;
+}
+
+// currently no implementation for this
+void ScVbaControl::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException)
+{
+}
+
+sal_Bool ScVbaControl::getLocked() throw (uno::RuntimeException)
+{
+    sal_Bool bRes( sal_False );
+    m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ) ) >>= 
bRes;
+    return bRes;
+}
+
+void ScVbaControl::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException)
+{
+    m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") ), 
uno::makeAny( bLocked ) );
+}
+
 typedef cppu::WeakImplHelper1< XControlProvider > ControlProvider_BASE;
 class ControlProviderImpl : public ControlProvider_BASE
 {
diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx
index 597c635..9c7c84d 100644
--- a/vbahelper/source/msforms/vbacontrol.hxx
+++ b/vbahelper/source/msforms/vbacontrol.hxx
@@ -116,6 +116,14 @@ public:
     //XHelperInterface
     virtual rtl::OUString& getServiceImplName();
     virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+    //General helper methods for properties ( may or maynot be relevant for all
+    //controls
+    sal_Int32 getBackColor() throw (css::uno::RuntimeException);
+    void setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
+    sal_Bool getAutoSize() throw (css::uno::RuntimeException);
+    void setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+    sal_Bool getLocked() throw (css::uno::RuntimeException);
+    void setLocked( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
 };
 
 
diff --git a/vbahelper/source/msforms/vbaimage.cxx b/vbahelper/source/msforms/vbaimage.cxx
index 08a3007..7dfc64f 100644
--- a/vbahelper/source/msforms/vbaimage.cxx
+++ b/vbahelper/source/msforms/vbaimage.cxx
@@ -56,4 +56,14 @@ ScVbaImage::getServiceNames()
     return aServiceNames;
 }
 
+sal_Int32 SAL_CALL ScVbaImage::getBackColor() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getBackColor();
+}
+
+void SAL_CALL ScVbaImage::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setBackColor( nBackColor );
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vbahelper/source/msforms/vbaimage.hxx b/vbahelper/source/msforms/vbaimage.hxx
index e360fe4..c5a9b1b 100644
--- a/vbahelper/source/msforms/vbaimage.hxx
+++ b/vbahelper/source/msforms/vbaimage.hxx
@@ -39,6 +39,8 @@ class ScVbaImage : public ImageImpl_BASE
 {
 public:
     ScVbaImage( 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* pGeomHelper  );
+    virtual SAL_CALL sal_Int32 getBackColor() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
     //XHelperInterface
     virtual rtl::OUString& getServiceImplName();
     virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/vbahelper/source/msforms/vbalabel.cxx b/vbahelper/source/msforms/vbalabel.cxx
index 4795a25..860c090 100644
--- a/vbahelper/source/msforms/vbalabel.cxx
+++ b/vbahelper/source/msforms/vbalabel.cxx
@@ -90,6 +90,26 @@ rtl::OUString& ScVbaLabel::getServiceImplName()
     return sImplName;
 }
 
+sal_Int32 SAL_CALL ScVbaLabel::getBackColor() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getBackColor();
+}
+
+void SAL_CALL ScVbaLabel::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setBackColor( nBackColor );
+}
+
+sal_Bool SAL_CALL ScVbaLabel::getAutoSize() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getAutoSize();
+}
+
+void SAL_CALL ScVbaLabel::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setAutoSize( bAutoSize );
+}
+
 uno::Sequence< rtl::OUString >
 ScVbaLabel::getServiceNames()
 {
diff --git a/vbahelper/source/msforms/vbalabel.hxx b/vbahelper/source/msforms/vbalabel.hxx
index 1166f04..f656aaf 100644
--- a/vbahelper/source/msforms/vbalabel.hxx
+++ b/vbahelper/source/msforms/vbalabel.hxx
@@ -48,6 +48,10 @@ public:
     virtual rtl::OUString SAL_CALL getAccelerator() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setAccelerator( const rtl::OUString& _accelerator ) throw 
(css::uno::RuntimeException);
     virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw 
(css::uno::RuntimeException);
+    virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
     //XHelperInterface
     virtual rtl::OUString& getServiceImplName();
     virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/vbahelper/source/msforms/vbatextbox.cxx b/vbahelper/source/msforms/vbatextbox.cxx
index 39861b9..8ba1407 100644
--- a/vbahelper/source/msforms/vbatextbox.cxx
+++ b/vbahelper/source/msforms/vbatextbox.cxx
@@ -152,6 +152,36 @@ uno::Reference< msforms::XNewFont > SAL_CALL ScVbaTextBox::getFont() throw 
(uno:
     return new VbaNewFont( this, mxContext, m_xProps );
 }
 
+sal_Int32 SAL_CALL ScVbaTextBox::getBackColor() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getBackColor();
+}
+
+void SAL_CALL ScVbaTextBox::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setBackColor( nBackColor );
+}
+
+sal_Bool SAL_CALL ScVbaTextBox::getAutoSize() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getAutoSize();
+}
+
+void SAL_CALL ScVbaTextBox::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setAutoSize( bAutoSize );
+}
+
+sal_Bool SAL_CALL ScVbaTextBox::getLocked() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getLocked();
+}
+
+void SAL_CALL ScVbaTextBox::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setLocked( bLocked );
+}
+
 rtl::OUString&
 ScVbaTextBox::getServiceImplName()
 {
diff --git a/vbahelper/source/msforms/vbatextbox.hxx b/vbahelper/source/msforms/vbatextbox.hxx
index bdbff16..a9e21ad 100644
--- a/vbahelper/source/msforms/vbatextbox.hxx
+++ b/vbahelper/source/msforms/vbatextbox.hxx
@@ -54,6 +54,13 @@ public:
     virtual void SAL_CALL setBorderStyle( sal_Int32 nBorderStyle ) throw 
(css::uno::RuntimeException);
     virtual sal_Int32 SAL_CALL getTextLength() throw (css::uno::RuntimeException);
     virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw 
(css::uno::RuntimeException);
+    virtual sal_Int32 SAL_CALL getBackColor() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getLocked() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setLocked( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+
     // XDefaultProperty
     rtl::OUString SAL_CALL getDefaultPropertyName(  ) throw (css::uno::RuntimeException) { return 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); }
     //XHelperInterface
diff --git a/vbahelper/source/msforms/vbatogglebutton.cxx 
b/vbahelper/source/msforms/vbatogglebutton.cxx
index b989616..0e2b056 100644
--- a/vbahelper/source/msforms/vbatogglebutton.cxx
+++ b/vbahelper/source/msforms/vbatogglebutton.cxx
@@ -99,11 +99,12 @@ ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeExcepti
 
 sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException)
 {
-    return sal_False;
+    return ScVbaControl::getAutoSize();
 }
 
-void SAL_CALL ScVbaToggleButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw 
(uno::RuntimeException)
+void SAL_CALL ScVbaToggleButton::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
 {
+    ScVbaControl::setAutoSize( bAutoSize );
 }
 
 sal_Bool SAL_CALL ScVbaToggleButton::getCancel() throw (uno::RuntimeException)
@@ -126,11 +127,12 @@ void SAL_CALL ScVbaToggleButton::setDefault( sal_Bool /*bDefault*/ ) throw 
(uno:
 
 sal_Int32 SAL_CALL ScVbaToggleButton::getBackColor() throw (uno::RuntimeException)
 {
-    return 0;
+    return ScVbaControl::getBackColor();
 }
 
-void SAL_CALL ScVbaToggleButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw 
(uno::RuntimeException)
+void SAL_CALL ScVbaToggleButton::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
 {
+    ScVbaControl::setBackColor( nBackColor );
 }
 
 sal_Int32 SAL_CALL ScVbaToggleButton::getForeColor() throw (uno::RuntimeException)
@@ -147,6 +149,16 @@ uno::Reference< msforms::XNewFont > SAL_CALL ScVbaToggleButton::getFont() throw
     return new VbaNewFont( this, mxContext, m_xProps );
 }
 
+sal_Bool SAL_CALL ScVbaToggleButton::getLocked() throw (uno::RuntimeException)
+{
+    return ScVbaControl::getLocked();
+}
+
+void SAL_CALL ScVbaToggleButton::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException)
+{
+    ScVbaControl::setLocked( bLocked );
+}
+
 rtl::OUString&
 ScVbaToggleButton::getServiceImplName()
 {
diff --git a/vbahelper/source/msforms/vbatogglebutton.hxx 
b/vbahelper/source/msforms/vbatogglebutton.hxx
index 6e8a0cb..7394bea 100644
--- a/vbahelper/source/msforms/vbatogglebutton.hxx
+++ b/vbahelper/source/msforms/vbatogglebutton.hxx
@@ -56,6 +56,8 @@ public:
     virtual void SAL_CALL setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
     virtual sal_Int32 SAL_CALL getForeColor() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setForeColor( sal_Int32 nForeColor ) throw (css::uno::RuntimeException);
+    virtual sal_Bool SAL_CALL getLocked() throw (css::uno::RuntimeException);
+    virtual void SAL_CALL setLocked( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
     virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw 
(css::uno::RuntimeException);
     //XHelperInterface
     virtual rtl::OUString& getServiceImplName();
-- 
1.7.3.4

From a1d3cb47d2fd49ac06a49725f5ceac1376a1138d Mon Sep 17 00:00:00 2001
From: Noel Power <noel.power@novell.com>
Date: Mon, 5 Mar 2012 14:54:04 +0000
Subject: [PATCH 6/7] vba implementation for Application.OnKey

support import of key shortcut for macro ( Excel only )
---
 filter/inc/filter/msfilter/msvbahelper.hxx        |    6 +-
 filter/source/msfilter/msvbahelper.cxx            |  176 +++++++++++++++++++++
 oovbaapi/ooo/vba/XApplicationBase.idl             |    2 +-
 oox/source/ole/vbamodule.cxx                      |   36 ++++-
 vbahelper/inc/vbahelper/vbaapplicationbase.hxx    |    1 +
 vbahelper/source/vbahelper/vbaapplicationbase.cxx |   23 +++
 6 files changed, 240 insertions(+), 4 deletions(-)

diff --git a/filter/inc/filter/msfilter/msvbahelper.hxx b/filter/inc/filter/msfilter/msvbahelper.hxx
index affc8b2..e7e6533 100644
--- a/filter/inc/filter/msfilter/msvbahelper.hxx
+++ b/filter/inc/filter/msfilter/msvbahelper.hxx
@@ -33,8 +33,9 @@
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/script/vba/XVBAMacroResolver.hpp>
+#include <com/sun/star/awt/KeyEvent.hpp>
+#include <com/sun/star/frame/XModel.hpp>
 #include "filter/msfilter/msfilterdllapi.h"
-
 namespace ooo {
 namespace vba {
 
@@ -55,7 +56,8 @@ MSFILTER_DLLPUBLIC ::rtl::OUString getDefaultProjectName( SfxObjectShell* pShell
 MSFILTER_DLLPUBLIC ::rtl::OUString resolveVBAMacro( SfxObjectShell* pShell, const ::rtl::OUString& 
rLibName, const ::rtl::OUString& rModuleName, const ::rtl::OUString& rMacroName );
 MSFILTER_DLLPUBLIC MacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const 
::rtl::OUString& rMacroName, bool bSearchGlobalTemplates = false );
 MSFILTER_DLLPUBLIC sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, 
com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArgs, com::sun::star::uno::Any& aRet, 
const com::sun::star::uno::Any& aCaller );
-
+MSFILTER_DLLPUBLIC ::com::sun::star::awt::KeyEvent parseKeyEvent( const ::rtl::OUString& sKey ) 
throw (::com::sun::star::uno::RuntimeException);
+MSFILTER_DLLPUBLIC void applyShortCutKeyBinding ( const ::com::sun::star::uno::Reference< 
com::sun::star::frame::XModel >& rxDoc, const ::com::sun::star::awt::KeyEvent& rKeyEvent, const 
::rtl::OUString& sMacro ) throw (::com::sun::star::uno::RuntimeException);
 // ============================================================================
 
 typedef ::cppu::WeakImplHelper3<
diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx
index ca0288f..962d211 100644
--- a/filter/source/msfilter/msvbahelper.cxx
+++ b/filter/source/msfilter/msvbahelper.cxx
@@ -42,6 +42,12 @@
 #include <osl/file.hxx>
 #include <unotools/pathoptions.hxx>
 
+#include <com/sun/star/awt/KeyModifier.hpp>
+#include <svtools/acceleratorexecute.hxx>
+#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/ui/XUIConfigurationManager.hpp>
+#include <map>
+
 using namespace ::com::sun::star;
 
 namespace ooo {
@@ -581,6 +587,176 @@ void SAL_CALL VBAMacroResolver::initialize( const uno::Sequence< uno::Any >& 
rAr
     throw uno::RuntimeException();
 }
 
+bool getModifier( char c, sal_uInt16& mod )
+{
+    static const char modifiers[] = "+^%";
+    static const sal_uInt16 KEY_MODS[] = {KEY_SHIFT, KEY_MOD1, KEY_MOD2};
+
+    for ( unsigned int i=0; i<SAL_N_ELEMENTS(modifiers); ++i )
+    {
+        if ( c == modifiers[i] )
+        {
+            mod = mod | KEY_MODS[ i ];
+            return true;
+        }
+    }
+    return false;
+}
+
+typedef std::map< rtl::OUString, sal_uInt16 > MSKeyCodeMap;
+
+sal_uInt16 parseChar( char c ) throw ( uno::RuntimeException )
+{
+    sal_uInt16 nVclKey = 0;
+    // do we care about locale here for isupper etc. ? probably not
+    if ( isalpha( c ) )
+    {
+        nVclKey |= ( toupper( c ) - 'A' ) + KEY_A;
+        if ( isupper( c ) )
+            nVclKey |= KEY_SHIFT;
+    }
+    else if ( isdigit( c ) )
+        nVclKey |= ( c  - '0' ) + KEY_0;
+    else if ( c == '~' ) // special case
+        nVclKey = KEY_RETURN;
+    else if ( c == ' ' ) // special case
+        nVclKey = KEY_SPACE;
+    else // I guess we have a problem ( but not sure if locale specific keys might come into play 
here )
+        throw uno::RuntimeException();
+    return nVclKey;
+}
+
+struct KeyCodeEntry
+{
+   const char* sName;
+   sal_uInt16 nCode;
+};
+
+KeyCodeEntry aMSKeyCodesData[] = {
+    { "BACKSPACE", KEY_BACKSPACE },
+    { "BS", KEY_BACKSPACE },
+    { "DELETE", KEY_DELETE },
+    { "DEL", KEY_DELETE },
+    { "DOWN", KEY_DOWN },
+    { "UP", KEY_UP },
+    { "LEFT", KEY_LEFT },
+    { "RIGHT", KEY_RIGHT },
+    { "END", KEY_END },
+    { "ESCAPE", KEY_ESCAPE },
+    { "ESC", KEY_ESCAPE },
+    { "HELP", KEY_HELP },
+    { "HOME", KEY_HOME },
+    { "PGDN", KEY_PAGEDOWN },
+    { "PGUP", KEY_PAGEUP },
+    { "INSERT", KEY_INSERT },
+    { "SCROLLLOCK", KEY_SCROLLLOCK },
+    { "NUMLOCK", KEY_NUMLOCK },
+    { "TAB", KEY_TAB },
+    { "F1", KEY_F1 },
+    { "F2", KEY_F2 },
+    { "F3", KEY_F3 },
+    { "F4", KEY_F4 },
+    { "F5", KEY_F5 },
+    { "F6", KEY_F6 },
+    { "F7", KEY_F7 },
+    { "F8", KEY_F8 },
+    { "F9", KEY_F1 },
+    { "F10", KEY_F10 },
+    { "F11", KEY_F11 },
+    { "F12", KEY_F12 },
+    { "F13", KEY_F13 },
+    { "F14", KEY_F14 },
+    { "F15", KEY_F15 },
+};
+
+awt::KeyEvent parseKeyEvent( const ::rtl::OUString& Key ) throw ( uno::RuntimeException )
+{
+    static MSKeyCodeMap msKeyCodes;
+    if ( msKeyCodes.empty() )
+    {
+        for ( unsigned int i = 0; i < SAL_N_ELEMENTS( aMSKeyCodesData ); ++i )
+        {
+            msKeyCodes[ rtl::OUString::createFromAscii( aMSKeyCodesData[ i ].sName ) ] = 
aMSKeyCodesData[ i ].nCode;
+        }
+    }
+    rtl::OUString sKeyCode;
+    sal_uInt16 nVclKey = 0;
+
+    // parse the modifier if any
+    for ( int i=0; i<Key.getLength(); ++i )
+    {
+        if ( ! getModifier( Key[ i ], nVclKey ) )
+        {
+            sKeyCode = Key.copy( i );
+            break;
+        }
+    }
+
+    // check if keycode is surrounded by '{}', if so scoop out the contents
+    // else it should be just one char of ( 'a-z,A-Z,0-9' )
+    if ( sKeyCode.getLength() == 1 ) // ( a single char )
+    {
+        char c = (char)( sKeyCode[ 0 ] );
+        nVclKey |= parseChar( c );
+    }
+    else // key should be enclosed in '{}'
+    {
+        if ( sKeyCode.getLength() < 3 ||  !( sKeyCode[0] == '{' && sKeyCode[sKeyCode.getLength() - 
1 ] == '}' ) )
+            throw uno::RuntimeException();
+
+        sKeyCode = sKeyCode.copy(1, sKeyCode.getLength() - 2 );
+
+        if ( sKeyCode.getLength() == 1 )
+            nVclKey |= parseChar( (char)( sKeyCode[ 0 ] ) );
+        else
+        {
+            MSKeyCodeMap::iterator it = msKeyCodes.find( sKeyCode );
+            if ( it == msKeyCodes.end() ) // unknown or unsupported
+                throw uno::RuntimeException();
+            nVclKey |= it->second;
+        }
+    }
+
+    awt::KeyEvent aKeyEvent = svt::AcceleratorExecute::st_VCLKey2AWTKey( KeyCode( nVclKey ) );
+    return aKeyEvent;
+}
+
+void applyShortCutKeyBinding ( const uno::Reference< frame::XModel >& rxModel, const 
awt::KeyEvent& rKeyEvent, const ::rtl::OUString& rMacroName ) throw (uno::RuntimeException)
+{
+    rtl::OUString MacroName( rMacroName );
+    if ( !MacroName.isEmpty() )
+    {
+        ::rtl::OUString sSeparator(RTL_CONSTASCII_USTRINGPARAM("/"));
+        ::rtl::OUString sMacroSeparator(RTL_CONSTASCII_USTRINGPARAM("!"));
+        ::rtl::OUString aMacroName = MacroName.trim();
+        if (0 == aMacroName.indexOf('!'))
+            MacroName = aMacroName.copy(1).trim();
+        SfxObjectShell* pShell = NULL;
+        if ( rxModel.is() )
+        {
+            uno::Reference< lang::XUnoTunnel >  xObjShellTunnel( rxModel, uno::UNO_QUERY_THROW );
+            pShell = reinterpret_cast<SfxObjectShell*>( 
xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId()));
+            if ( !pShell )
+                throw uno::RuntimeException();
+        }
+        MacroResolvedInfo aMacroInfo = resolveVBAMacro( pShell, aMacroName );
+        if( !aMacroInfo.mbFound )
+            throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("The procedure 
doesn't exist") ), uno::Reference< uno::XInterface >() );
+       MacroName = aMacroInfo.msResolvedMacro;
+    }
+    uno::Reference< ui::XUIConfigurationManagerSupplier > xCfgSupplier(rxModel, 
uno::UNO_QUERY_THROW);
+    uno::Reference< ui::XUIConfigurationManager > xCfgMgr = 
xCfgSupplier->getUIConfigurationManager();
+
+    uno::Reference< ui::XAcceleratorConfiguration > xAcc( xCfgMgr->getShortCutManager(), 
uno::UNO_QUERY_THROW );
+    if ( MacroName.isEmpty() )
+        // I believe this should really restore the [application] default. Since
+        // afaik we don't actually setup application default bindings on import
+        // we don't even know what the 'default' would be for this key
+        xAcc->removeKeyEvent( rKeyEvent );
+    else
+        xAcc->setKeyEvent( rKeyEvent, ooo::vba::makeMacroURL( MacroName ) );
+
+}
 // ============================================================================
 
 } // namespace vba
diff --git a/oovbaapi/ooo/vba/XApplicationBase.idl b/oovbaapi/ooo/vba/XApplicationBase.idl
index d46eb24..93f39ae 100644
--- a/oovbaapi/ooo/vba/XApplicationBase.idl
+++ b/oovbaapi/ooo/vba/XApplicationBase.idl
@@ -47,7 +47,7 @@ interface XApplicationBase
     [attribute, readonly] any VBE;
 
     void Quit();
-
+    void OnKey( [in] string Key, [in] any Procedure );
     any CommandBars( [in] any Index );
     any Run([in] string MacroName, [in] /*Optional*/ any varg1, [in] /*Optional*/ any varg2, [in] 
/*Optional*/ any varg3, [in] /*Optional*/ any varg4, [in] /*Optional*/ any varg5, [in] /*Optional*/ 
any varg6, [in] /*Optional*/ any varg7, [in] /*Optional*/ any varg8, [in] /*Optional*/ any varg9, 
[in] /*Optional*/ any varg10, [in] /*Optional*/ any varg11, [in] /*Optional*/ any varg12, [in] 
/*Optional*/ any varg13, [in] /*Optional*/ any varg14, [in] /*Optional*/ any varg15, [in] 
/*Optional*/ any varg16, [in] /*Optional*/ any varg17, [in] /*Optional*/ any varg18, [in] 
/*Optional*/ any varg19, [in] /*Optional*/ any varg20, [in] /*Optional*/ any varg21, [in] 
/*Optional*/ any varg22, [in] /*Optional*/ any varg23, [in] /*Optional*/ any varg24, [in] 
/*Optional*/ any varg25, [in] /*Optional*/ any varg26, [in] /*Optional*/ any varg27, [in] 
/*Optional*/ any varg28, [in] /*Optional*/ any varg29, [in] /*Optional*/ any varg30);
     void OnTime( [in] any EarliestTime, [in] string Procedure, [in] any LatestTime, [in] any 
Schedule );
diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx
index cbd9744..5672f59 100644
--- a/oox/source/ole/vbamodule.cxx
+++ b/oox/source/ole/vbamodule.cxx
@@ -33,7 +33,9 @@
 #include <com/sun/star/script/ModuleInfo.hpp>
 #include <com/sun/star/script/ModuleType.hpp>
 #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
+#include <com/sun/star/awt/KeyEvent.hpp>
 #include <cppuhelper/implbase1.hxx>
+#include <filter/msfilter/msvbahelper.hxx>
 #include "oox/helper/binaryinputstream.hxx"
 #include "oox/helper/storagebase.hxx"
 #include "oox/helper/textinputstream.hxx"
@@ -54,6 +56,7 @@ using namespace ::com::sun::star::uno;
 
 using ::rtl::OUString;
 using ::rtl::OUStringBuffer;
+using ::com::sun::star::awt::KeyEvent;
 // ============================================================================
 typedef ::cppu::WeakImplHelper1< XIndexContainer > OleIdToNameContainer_BASE;
 typedef boost::unordered_map< sal_Int32, rtl::OUString >  ObjIdToName;
@@ -237,7 +240,38 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg, const Reference< 
XNam
                 if( aCodeLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "Attribute " ) ) )
                 {
                     // attribute
-                    extractOleOverrideFromAttr( aCodeLine, rxOleNameOverrides );
+                    int index = aCodeLine.indexOf( ".VB_ProcData.VB_Invoke_Func = " );
+                    if ( index != -1 )
+                    {
+                        // format is
+                        //    'Attribute Procedure.VB_ProcData.VB_Invoke_Func = "*\n14"'
+                        //    where 'Procedure' is the procedure name and '*' is the shortcut key
+                        // note: his is only relevant for Excel, seems that
+                        // word doesn't store the shortcut in the module
+                        // attributes
+                        int nSpaceIndex = aCodeLine.indexOf(' ');
+                        rtl::OUString sProc = aCodeLine.copy( nSpaceIndex + 1, index - nSpaceIndex 
- 1);
+                        // for Excel short cut key seems limited to cntrl+'a-z, A-Z'
+                        rtl::OUString sKey = aCodeLine.copy( aCodeLine.lastIndexOf("= ") + 3, 1 );
+                        // only alpha key valid for key shortcut, however the api will accept 
other keys
+                        if ( !isalpha( (char)sKey[ 0 ] ) )
+                        {
+                            // cntrl modifier is explicit ( but could be cntrl+shift ), 
parseKeyEvent
+                            // will handle and uppercase letter appropriately
+                            rtl::OUString sApiKey = "^";
+                            sApiKey += sKey;
+                            try
+                            {
+                                KeyEvent aKeyEvent = ooo::vba::parseKeyEvent( sApiKey );
+                                ooo::vba::applyShortCutKeyBinding( mxDocModel, aKeyEvent, sProc );
+                            }
+                            catch( Exception& )
+                            {
+                            }
+                        }
+                    }
+                    else
+                        extractOleOverrideFromAttr( aCodeLine, rxOleNameOverrides );
                 }
                 else
                 {
diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx 
b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx
index 7d21d3e..a27afa5 100644
--- a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx
+++ b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx
@@ -58,6 +58,7 @@ public:
     virtual void SAL_CALL setInteractive( ::sal_Bool bInteractive ) throw 
(css::uno::RuntimeException);
     virtual ::sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
     virtual void SAL_CALL setVisible( ::sal_Bool bVisible ) throw (css::uno::RuntimeException);
+    virtual void SAL_CALL OnKey( const ::rtl::OUString& Key, const ::com::sun::star::uno::Any& 
Procedure ) throw (::com::sun::star::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw 
(css::uno::RuntimeException);
     virtual ::rtl::OUString SAL_CALL getVersion() throw (css::uno::RuntimeException);
     virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException);
diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx 
b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
index 162ea28..039494c 100644
--- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx
+++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
@@ -277,6 +277,29 @@ void SAL_CALL VbaApplicationBase::setVisible( sal_Bool bVisible ) throw 
(uno::Ru
     m_pImpl->mbVisible = bVisible;  // dummy implementation
 }
 
+
+void SAL_CALL
+VbaApplicationBase::OnKey( const ::rtl::OUString& Key, const uno::Any& Procedure ) throw 
(uno::RuntimeException)
+{
+    // parse the Key & modifiers
+    awt::KeyEvent aKeyEvent = parseKeyEvent( Key );
+    rtl::OUString MacroName;
+    Procedure >>= MacroName;
+    uno::Reference< frame::XModel > xModel;
+    SbMethod* pMeth = StarBASIC::GetActiveMethod();
+    if ( pMeth )
+    {
+        SbModule* pMod = dynamic_cast< SbModule* >( pMeth->GetParent() );
+        if ( pMod )
+            xModel = StarBASIC::GetModelFromBasic( pMod );
+    }
+
+    if ( !xModel.is() )
+        xModel = getCurrentDocument();
+
+    applyShortCutKeyBinding( xModel, aKeyEvent, MacroName );
+}
+
 uno::Any SAL_CALL
 VbaApplicationBase::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
 {
-- 
1.7.3.4

From 878199d629dbda4a9775a25b35684543d27cbaca Mon Sep 17 00:00:00 2001
From: Noel Power <noel.power@novell.com>
Date: Fri, 11 May 2012 10:57:15 +0100
Subject: [PATCH 7/7] support Sheets.PrintPreview bnc#757844

there is still a little wrinkle, the preview shell always shows what sheets are selected, it's 
currently not possible to specify the sheets to preview
---
 oovbaapi/ooo/vba/excel/XWorksheets.idl   |    1 +
 sc/source/ui/vba/vbaworksheets.cxx       |    7 +++++++
 sc/source/ui/vba/vbaworksheets.hxx       |    1 +
 vbahelper/source/vbahelper/vbahelper.cxx |   13 ++++++++++++-
 4 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/oovbaapi/ooo/vba/excel/XWorksheets.idl b/oovbaapi/ooo/vba/excel/XWorksheets.idl
index 17c80ce..cca74f9 100644
--- a/oovbaapi/ooo/vba/excel/XWorksheets.idl
+++ b/oovbaapi/ooo/vba/excel/XWorksheets.idl
@@ -45,6 +45,7 @@ interface XWorksheets
     void PrintOut( [in] any From, [in] any To, [in] any Copies, [in] any Preview, [in] any 
ActivePrinter, [in] any PrintToFile, [in] any Collate, [in] any PrToFileName );
     void Select( [in] any Replace );
     void Copy( [in] any Before, [in] any After);
+    void PrintPreview( [in] any EnableChanges );
 };
 }; }; };
 
diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx
index 02828ef..b9c8342 100644
--- a/sc/source/ui/vba/vbaworksheets.cxx
+++ b/sc/source/ui/vba/vbaworksheets.cxx
@@ -538,4 +538,11 @@ bool ScVbaWorksheets::nameExists( uno::Reference <sheet::XSpreadsheetDocument>&
     return false;
 }
 
+void ScVbaWorksheets::PrintPreview( const css::uno::Any& EnableChanges ) throw 
(css::uno::RuntimeException)
+{
+    // need test, print preview current active sheet
+    // !! TODO !! get view shell from controller
+    PrintPreviewHelper( EnableChanges, excel::getBestViewShell( mxModel ) );
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaworksheets.hxx b/sc/source/ui/vba/vbaworksheets.hxx
index c15d713..37834da 100644
--- a/sc/source/ui/vba/vbaworksheets.hxx
+++ b/sc/source/ui/vba/vbaworksheets.hxx
@@ -73,6 +73,7 @@ public:
     virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
     virtual void SAL_CALL Select( const css::uno::Any& Replace ) throw 
(css::uno::RuntimeException);
     virtual void SAL_CALL Copy ( const css::uno::Any& Before, const css::uno::Any& After) throw 
(css::uno::RuntimeException);
+    virtual void SAL_CALL PrintPreview( const css::uno::Any& EnableChanges ) throw 
(css::uno::RuntimeException);
     // ScVbaWorksheets_BASE
     virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& Index2 
) throw
 (css::uno::RuntimeException);
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index adc1d63..eef065a 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -482,7 +482,18 @@ void PrintOutHelper( SfxViewShell* pViewShell, const uno::Any& From, const 
uno::
 
  void PrintPreviewHelper( const css::uno::Any& /*EnableChanges*/, SfxViewShell* pViewShell )
 {
-    dispatchExecute( pViewShell, SID_VIEWSHELL1 );
+    SfxViewFrame* pViewFrame = NULL;
+    if ( pViewShell )
+        pViewFrame = pViewShell->GetViewFrame();
+    if ( pViewFrame )
+    {
+        if ( !pViewFrame->GetFrame().IsInPlace() )
+        {
+            dispatchExecute( pViewShell, SID_VIEWSHELL1 );
+            while ( isInPrintPreview( pViewFrame ) )
+                Application::Yield();
+        }
+    }
 }
 
 sal_Int32 extractIntFromAny( const uno::Any& rAny ) throw (uno::RuntimeException)
-- 
1.7.3.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.