summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2012-09-11 08:48:02 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-09-12 12:49:49 +0100
commit4597483e00bffcc4e30d379dcf6fad42bc565e56 (patch)
treeb590428b0e3ae3c7056e6c18f008d7179dc5ba38 /scripting
parentc414499bbd456389ac6cacf677327bff9e6b43f9 (diff)
targetted VBA re-work.
Diffstat (limited to 'scripting')
-rw-r--r--scripting/source/vbaevents/eventhelper.cxx79
-rw-r--r--scripting/source/vbaevents/vbamsformreturntypes.hxx76
2 files changed, 11 insertions, 144 deletions
diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx
index 4d93bbfffa3f..00981f075898 100644
--- a/scripting/source/vbaevents/eventhelper.cxx
+++ b/scripting/source/vbaevents/eventhelper.cxx
@@ -58,7 +58,7 @@
#include <com/sun/star/awt/XRadioButton.hpp>
#include <com/sun/star/awt/XListBox.hpp>
-#include "vbamsformreturntypes.hxx"
+#include <ooo/vba/msforms/ReturnInteger.hpp>
#include <sfx2/objsh.hxx>
#include <basic/sbstar.hxx>
@@ -68,9 +68,6 @@
#include <basic/sbx.hxx>
#include <filter/msfilter/msvbahelper.hxx>
-
-
-
// for debug
#include <comphelper/anytostring.hxx>
@@ -122,14 +119,6 @@ bool isMouseEventOk( awt::MouseEvent& evt, const Sequence< Any >& params )
return true;
}
-bool isFocusEventOk( awt::FocusEvent& evt, const Sequence< Any >& params )
-{
- if ( !( params.getLength() > 0 ) ||
- !( params[ 0 ] >>= evt ) )
- return false;
- return true;
-}
-
Sequence< Any > ooMouseEvtToVBADblClick( const Sequence< Any >& params )
{
Sequence< Any > translatedParams;
@@ -173,14 +162,9 @@ Sequence< Any > ooKeyPressedToVBAKeyPressed( const Sequence< Any >& params )
translatedParams.realloc(1);
- //The VBA events such as ComboBox_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) may cause an error because
- //the original input parameter data structure -- msforms::ReturnInteger -- is a struct, it cannot support default value.
- //So the newly defined VbaReturnIntege class is used here to support default value.
- VbaReturnInteger* pKeyCode = new VbaReturnInteger();
- pKeyCode->Value = evt.KeyChar;
- ::uno::Reference< msforms::XReturnInteger > xInteger =
- static_cast< ::uno::Reference< msforms::XReturnInteger > > (pKeyCode);
- translatedParams[0] <<= xInteger;
+ msforms::ReturnInteger keyCode;
+ keyCode.Value = evt.KeyCode;
+ translatedParams[0] <<= keyCode;
return translatedParams;
}
@@ -194,41 +178,18 @@ Sequence< Any > ooKeyPressedToVBAKeyUpDown( const Sequence< Any >& params )
translatedParams.realloc(2);
- //The VBA events such as ComboBox_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) may cause an error because
- //the original input parameter data structure -- msforms::ReturnInteger -- is a struct, it cannot support default value.
- //So the newly defined VbaReturnIntege class is used here to support default value.
- VbaReturnInteger* pKeyCode = new VbaReturnInteger();
- sal_Int8 shift = evt.Modifiers;
+ msforms::ReturnInteger keyCode;
+ sal_Int8 shift = sal::static_int_cast<sal_Int8>( evt.Modifiers );
- pKeyCode->Value = evt.KeyChar;
- ::uno::Reference< msforms::XReturnInteger > xInteger = static_cast< ::uno::Reference< msforms::XReturnInteger > > (pKeyCode);
- translatedParams[0] <<= xInteger;
+ // #TODO check whether values from OOO conform to values generated from vba
+ keyCode.Value = evt.KeyCode;
+ translatedParams[0] <<= keyCode;
translatedParams[1] <<= shift;
return translatedParams;
}
-Sequence< Any > ooFocusLostToVBAExit( const Sequence< Any >& params )
-{
- Sequence< Any > translatedParams;
- awt::FocusEvent evt;
-
- if ( !isFocusEventOk( evt, params ) )
- return Sequence< Any >();
-
- translatedParams.realloc(1);
-
- VbaReturnBoolean* pCancel = new VbaReturnBoolean();
-
- ::uno::Reference< msforms::XReturnBoolean > xBoolean=
- static_cast< ::uno::Reference< msforms::XReturnBoolean > > (pCancel);
- translatedParams[0] <<= xBoolean;
- return translatedParams;
-}
-
-
typedef Sequence< Any > (*Translator)(const Sequence< Any >&);
-
//expand the "TranslateInfo" struct to support more kinds of events
struct TranslateInfo
{
@@ -255,7 +216,6 @@ bool ApproveAll(const ScriptEvent& evt, void* pPara); //allow all types of contr
bool ApproveType(const ScriptEvent& evt, void* pPara); //certain types of controls should execute the event, those types are given by pPara
bool DenyType(const ScriptEvent& evt, void* pPara); //certain types of controls should not execute the event, those types are given by pPara
bool DenyMouseDrag(const ScriptEvent& evt, void* pPara); //used for VBA MouseMove event when "Shift" key is pressed
-bool DenyKeys(const ScriptEvent& evt, void* pPara); //For some keys, press them will cause Symphony keyPressed event, but will not cause any events in Excel, so deny these key events
struct TypeList
{
@@ -295,7 +255,7 @@ static TranslatePropMap aTranslatePropMap_Impl[] =
// focusLost ooo event
{ MAP_CHAR_LEN("focusLost"), { MAP_CHAR_LEN("_LostFocus"), NULL, ApproveAll, NULL } },
- { MAP_CHAR_LEN("focusLost"), { MAP_CHAR_LEN("_Exit"), ooFocusLostToVBAExit, ApproveType, (void*)(&textCompList) } },
+ { MAP_CHAR_LEN("focusLost"), { MAP_CHAR_LEN("_Exit"), NULL, ApproveType, (void*)(&textCompList) } }, // support VBA TextBox_Exit event
// adjustmentValueChanged ooo event
{ MAP_CHAR_LEN("adjustmentValueChanged"), { MAP_CHAR_LEN("_Scroll"), NULL, ApproveAll, NULL } },
@@ -321,7 +281,7 @@ static TranslatePropMap aTranslatePropMap_Impl[] =
// keyPressed ooo event
{ MAP_CHAR_LEN("keyPressed"), { MAP_CHAR_LEN("_KeyDown"), ooKeyPressedToVBAKeyUpDown, ApproveAll, NULL } },
- { MAP_CHAR_LEN("keyPressed"), { MAP_CHAR_LEN("_KeyPress"), ooKeyPressedToVBAKeyUpDown, DenyKeys, NULL } }
+ { MAP_CHAR_LEN("keyPressed"), { MAP_CHAR_LEN("_KeyPress"), ooKeyPressedToVBAKeyPressed, ApproveAll, NULL } }
};
EventInfoHash& getEventTransInfo()
@@ -885,23 +845,6 @@ bool DenyMouseDrag(const ScriptEvent& evt, void* )
}
}
-//For some keys, press them will cause Symphony keyPressed event, but will not cause any events in Excel, so deny these key events
-bool DenyKeys(const ScriptEvent& evt, void* /*pPara*/)
-{
- awt::KeyEvent aEvent;
- evt.Arguments[ 0 ] >>= aEvent;
- if (aEvent.KeyChar == 0 || aEvent.KeyChar == 8)
- {
- return false;
- }
- else
- {
- return true;
- }
-}
-
-
-
// EventListener
diff --git a/scripting/source/vbaevents/vbamsformreturntypes.hxx b/scripting/source/vbaevents/vbamsformreturntypes.hxx
deleted file mode 100644
index e6cab6ade314..000000000000
--- a/scripting/source/vbaevents/vbamsformreturntypes.hxx
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright IBM Corporation 2009, 2010.
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef VBA_MSFORM_RETURNTYPES_HXX
-#define VBA_MSFORM_RETURNTYPES_HXX
-
-#include <cppuhelper/implbase1.hxx>
-#include <ooo/vba/msforms/XReturnBoolean.hpp>
-#include <ooo/vba/msforms/XReturnInteger.hpp>
-
-
-typedef ::cppu::WeakImplHelper1<ooo::vba::msforms::XReturnBoolean> ReturnBoolean_BASE;
-
-class SAL_DLLPUBLIC_EXPORT VbaReturnBoolean : public ReturnBoolean_BASE
-{
-public:
- sal_Bool Value;
-
-public:
- VbaReturnBoolean() : Value(false) {} ;
-
- // XReturnBoolean
- virtual ::sal_Bool SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException) { return Value; }
- virtual void SAL_CALL setValue( ::sal_Bool _value ) throw (::com::sun::star::uno::RuntimeException) { Value = _value; }
-
- // XDefaultProperty
- ::rtl::OUString SAL_CALL getDefaultPropertyName() throw (com::sun::star::uno::RuntimeException) { return ::rtl::OUString("Value"); }
-};
-
-
-typedef ::cppu::WeakImplHelper1<ooo::vba::msforms::XReturnInteger> ReturnInteger_BASE;
-
-class SAL_DLLPUBLIC_EXPORT VbaReturnInteger : public ReturnInteger_BASE
-{
-public:
- sal_Int32 Value;
-
-public:
- VbaReturnInteger() : Value(0) {} ;
-
- // XReturnInteger
- virtual ::sal_Int32 SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException) { return Value; }
- virtual void SAL_CALL setValue( ::sal_Int32 _value ) throw (::com::sun::star::uno::RuntimeException) { Value = _value; }
-
- // XDefaultProperty
- ::rtl::OUString SAL_CALL getDefaultPropertyName() throw (com::sun::star::uno::RuntimeException) { return ::rtl::OUString("Value"); }
-};
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */