oovbaapi/UnoApi_oovbaapi.mk | 8 +- 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/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 ++++++++ scripting/source/vbaevents/eventhelper.cxx | 13 +--- vbahelper/Package_inc.mk | 1 vbahelper/inc/vbahelper/vbareturntypes.hxx | 77 +++++++++++++++++++++++++++ vbahelper/source/msforms/vbacheckbox.cxx | 15 ++--- vbahelper/source/msforms/vbalistbox.cxx | 25 +++++++- vbahelper/source/msforms/vbalistbox.hxx | 4 - vbahelper/source/msforms/vbaradiobutton.cxx | 15 ++--- vbahelper/source/msforms/vbatextbox.cxx | 7 +- vbahelper/source/msforms/vbatogglebutton.cxx | 10 ++- 19 files changed, 240 insertions(+), 138 deletions(-)
New commits: commit 6d6a5b763f344f08c6f30e485773d98f9f1406b0 Author: Noel Power <[email protected]> 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 adbe4ea98fa9d2d1533daf617a72a8e1698dde4c Author: Noel Power <[email protected]> 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 1dc7c568b57ef812eb2c2def4d3760c8341850b7 Author: Noel Power <[email protected]> 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 ffc7a6e2a133ab443e253368217482454e646e88 Author: Noel Power <[email protected]> Date: Fri Apr 19 12:52:06 2013 +0100 handle various ReturnXXXX types for forms Change-Id: I6d017da640804d95c605739ca70566b34c4c5e5a diff --git a/oovbaapi/UnoApi_oovbaapi.mk b/oovbaapi/UnoApi_oovbaapi.mk index 75431a7..ac34518 100644 --- a/oovbaapi/UnoApi_oovbaapi.mk +++ b/oovbaapi/UnoApi_oovbaapi.mk @@ -520,10 +520,6 @@ $(eval $(call gb_UnoApi_add_idlfiles,oovbaapi,oovbaapi/ooo/vba/msforms,\ fmTransitionEffect \ fmVerticalScrollBarSide \ fmZOrder \ - ReturnBoolean \ - ReturnEffect \ - ReturnInteger \ - ReturnSingle \ XButton \ XCheckBox \ XColorFormat \ @@ -544,6 +540,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 575fe2f..e7f90e2 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> @@ -162,9 +161,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; } @@ -178,12 +176,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; } diff --git a/vbahelper/Package_inc.mk b/vbahelper/Package_inc.mk index 10c3ce1..6107236 100644 --- a/vbahelper/Package_inc.mk +++ b/vbahelper/Package_inc.mk @@ -34,6 +34,7 @@ $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbahelper.hxx,vbah $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbahelperinterface.hxx,vbahelper/vbahelperinterface.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbapagesetupbase.hxx,vbahelper/vbapagesetupbase.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbapropvalue.hxx,vbahelper/vbapropvalue.hxx)) +$(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbareturntypes.hxx,vbahelper/vbareturntypes.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbashape.hxx,vbahelper/vbashape.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbashaperange.hxx,vbahelper/vbashaperange.hxx)) $(eval $(call gb_Package_add_file,vbahelper_inc,inc/vbahelper/vbashapes.hxx,vbahelper/vbashapes.hxx)) diff --git a/vbahelper/inc/vbahelper/vbareturntypes.hxx b/vbahelper/inc/vbahelper/vbareturntypes.hxx new file mode 100644 index 0000000..82de8cd --- /dev/null +++ b/vbahelper/inc/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 ) { mnValue = nValue; } + virtual T1 SAL_CALL getValue() { 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: */ commit 1e2442a9f145bfc2d234cb09212bc3abd5e668d0 Author: Noel Power <[email protected]> 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 6bf65c1..9c2fc65 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; + } OSL_TRACE( "nState - %d", nState ); nState = ( nState == -1 ) ? 1 : 0; OSL_TRACE( "nState - %d", nState ); - m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) ); + m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) ); } sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
