summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2012-03-05 14:54:04 +0000
committerMiklos Vajna <vmiklos@suse.cz>2012-05-14 11:29:24 +0200
commit4dc7a53b066c0241fc55b41b41d57a690ca512b1 (patch)
treea4eb385d67add62b3c16495e115cadc4032da1d6 /vbahelper
parent162c9e3c025370dcbe962990c4c8f6df29c6c7cc (diff)
vba implementation for Application.OnKey
support import of key shortcut for macro ( Excel only ) Signed-off-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'vbahelper')
-rw-r--r--vbahelper/inc/vbahelper/vbaapplicationbase.hxx1
-rw-r--r--vbahelper/source/vbahelper/vbaapplicationbase.cxx23
2 files changed, 24 insertions, 0 deletions
diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx
index 7d21d3ed453b..a27afa5d5b01 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 162ea28919ef..039494c5c8b2 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)
{