From 4597483e00bffcc4e30d379dcf6fad42bc565e56 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Tue, 11 Sep 2012 08:48:02 +0100 Subject: targetted VBA re-work. --- vbahelper/inc/vbahelper/vbadialogbase.hxx | 2 +- vbahelper/inc/vbahelper/vbahelper.hxx | 1 - vbahelper/inc/vbahelper/vbashape.hxx | 1 - vbahelper/source/msforms/vbacombobox.cxx | 23 +----------- vbahelper/source/msforms/vbaframe.cxx | 12 ------ vbahelper/source/msforms/vbaframe.hxx | 2 - vbahelper/source/msforms/vbalistbox.cxx | 11 +++--- vbahelper/source/msforms/vbalistbox.hxx | 4 +- vbahelper/source/msforms/vbatextbox.cxx | 10 +---- vbahelper/source/msforms/vbatogglebutton.cxx | 23 ++---------- vbahelper/source/msforms/vbauserform.cxx | 15 -------- vbahelper/source/msforms/vbauserform.hxx | 2 - vbahelper/source/vbahelper/vbadialogbase.cxx | 4 +- vbahelper/source/vbahelper/vbadocumentbase.cxx | 49 ++++++++++++------------- vbahelper/source/vbahelper/vbadocumentsbase.cxx | 10 +---- vbahelper/source/vbahelper/vbahelper.cxx | 17 --------- vbahelper/source/vbahelper/vbapictureformat.cxx | 8 ++-- vbahelper/source/vbahelper/vbashape.cxx | 11 ------ 18 files changed, 45 insertions(+), 160 deletions(-) (limited to 'vbahelper') diff --git a/vbahelper/inc/vbahelper/vbadialogbase.hxx b/vbahelper/inc/vbahelper/vbadialogbase.hxx index 01aa5f784e6d..b196c6bc3371 100644 --- a/vbahelper/inc/vbahelper/vbadialogbase.hxx +++ b/vbahelper/inc/vbahelper/vbadialogbase.hxx @@ -36,7 +36,7 @@ public: virtual ~VbaDialogBase() {} // Methods - virtual sal_Bool SAL_CALL Show() throw (css::uno::RuntimeException); + virtual void SAL_CALL Show() throw (css::uno::RuntimeException); virtual rtl::OUString mapIndexToName( sal_Int32 nIndex ) = 0; }; diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx index d1d15f549b17..be84387d9f6a 100644 --- a/vbahelper/inc/vbahelper/vbahelper.hxx +++ b/vbahelper/inc/vbahelper/vbahelper.hxx @@ -108,7 +108,6 @@ namespace ooo VBAHELPER_DLLPUBLIC sal_Int32 getPointerStyle( const css::uno::Reference< css::frame::XModel >& ); VBAHELPER_DLLPUBLIC void setCursorHelper( const css::uno::Reference< css::frame::XModel >& xModel, const Pointer& rPointer, sal_Bool bOverWrite ); VBAHELPER_DLLPUBLIC void setDefaultPropByIntrospection( const css::uno::Any& aObj, const css::uno::Any& aValue ) throw ( css::uno::RuntimeException ); - VBAHELPER_DLLPUBLIC css::uno::Any getDefaultPropByIntrospection( const css::uno::Any& aObj ) throw ( css::uno::RuntimeException ); VBAHELPER_DLLPUBLIC css::uno::Any getPropertyValue( const css::uno::Sequence< css::beans::PropertyValue >& aProp, const rtl::OUString& aName ); VBAHELPER_DLLPUBLIC sal_Bool setPropertyValue( css::uno::Sequence< css::beans::PropertyValue >& aProp, const rtl::OUString& aName, const css::uno::Any& aValue ); VBAHELPER_DLLPUBLIC void setOrAppendPropertyValue( css::uno::Sequence< css::beans::PropertyValue >& aProp, const rtl::OUString& aName, const css::uno::Any& aValue ); diff --git a/vbahelper/inc/vbahelper/vbashape.hxx b/vbahelper/inc/vbahelper/vbashape.hxx index db08475030b4..423807229ef3 100644 --- a/vbahelper/inc/vbahelper/vbashape.hxx +++ b/vbahelper/inc/vbahelper/vbashape.hxx @@ -101,7 +101,6 @@ public: // Replace?? virtual void SAL_CALL Select( const css::uno::Any& Replace ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL ShapeRange( const css::uno::Any& index ) throw ( css::uno::RuntimeException ); - virtual void SAL_CALL Copy( ) throw (css::uno::RuntimeException); // XEventListener virtual void SAL_CALL disposing( const css::lang::EventObject& rEventObject ) throw( css::uno::RuntimeException ); }; diff --git a/vbahelper/source/msforms/vbacombobox.cxx b/vbahelper/source/msforms/vbacombobox.cxx index a0dc30b79ebe..b78dea3111f8 100644 --- a/vbahelper/source/msforms/vbacombobox.cxx +++ b/vbahelper/source/msforms/vbacombobox.cxx @@ -119,29 +119,8 @@ ScVbaComboBox::getListIndex() throw (uno::RuntimeException) void SAL_CALL ScVbaComboBox::setValue( const uno::Any& _value ) throw (uno::RuntimeException) { - OUString sOldValue, sNewValue; // booleans are converted to uppercase strings - sOldValue = extractStringFromAny( getValue(), OUString(), true ); - // booleans are converted to uppercase strings - sNewValue = extractStringFromAny( _value, OUString(), true ); - - m_xProps->setPropertyValue( sSourceName, uno::Any( sNewValue ) ); - - if ( sNewValue != sOldValue ) - { - // If the new value is in current list, we should fire click event, otherwise fire the change event. - sal_Int32 nListIndex = -1; - getListIndex() >>= nListIndex; - sal_Bool bIsInList = ( nListIndex >= 0 ); - if ( bIsInList ) - { - fireClickEvent(); - } - else - { - fireChangeEvent(); - } - } + m_xProps->setPropertyValue( sSourceName, uno::Any( extractStringFromAny( _value, ::rtl::OUString(), true ) ) ); } // see Value diff --git a/vbahelper/source/msforms/vbaframe.cxx b/vbahelper/source/msforms/vbaframe.cxx index 27ef523bce54..c7998c3c781b 100644 --- a/vbahelper/source/msforms/vbaframe.cxx +++ b/vbahelper/source/msforms/vbaframe.cxx @@ -60,18 +60,6 @@ sal_Int32 SAL_CALL ScVbaFrame::getSpecialEffect() throw (uno::RuntimeException) return msforms::fmSpecialEffect::fmSpecialEffectEtched; } -::sal_Int32 SAL_CALL ScVbaFrame::getForeColor() throw (::com::sun::star::uno::RuntimeException) -{ - // #STUB - return 0; -} - -void SAL_CALL ScVbaFrame::setForeColor( ::sal_Int32 /*_forecolor*/ ) throw (::com::sun::star::uno::RuntimeException) -{ - // #STUB - return; -} - void SAL_CALL ScVbaFrame::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException) { diff --git a/vbahelper/source/msforms/vbaframe.hxx b/vbahelper/source/msforms/vbaframe.hxx index 02a27b8afa6d..c5c226c3980d 100644 --- a/vbahelper/source/msforms/vbaframe.hxx +++ b/vbahelper/source/msforms/vbaframe.hxx @@ -41,8 +41,6 @@ public: virtual OUString SAL_CALL getCaption() throw (css::uno::RuntimeException); virtual void SAL_CALL setCaption( const OUString& _caption ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getForeColor() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setForeColor( ::sal_Int32 _forecolor ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Int32 SAL_CALL getSpecialEffect() throw (css::uno::RuntimeException); virtual void SAL_CALL setSpecialEffect( sal_Int32 nSpecialEffect ) throw (css::uno::RuntimeException); virtual sal_Int32 SAL_CALL getBorderStyle() throw (css::uno::RuntimeException); diff --git a/vbahelper/source/msforms/vbalistbox.cxx b/vbahelper/source/msforms/vbalistbox.cxx index 4e704a94f5cc..483985ea26cd 100644 --- a/vbahelper/source/msforms/vbalistbox.cxx +++ b/vbahelper/source/msforms/vbalistbox.cxx @@ -103,7 +103,7 @@ 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 ) ); + m_xProps->setPropertyValue( TEXT, uno::makeAny( sValue ) ); } OUString SAL_CALL @@ -120,19 +120,18 @@ ScVbaListBox::setText( const OUString& _text ) throw (uno::RuntimeException) setValue( uno::makeAny( _text ) ); // seems the same } -sal_Int32 SAL_CALL +sal_Bool SAL_CALL ScVbaListBox::getMultiSelect() throw (css::uno::RuntimeException) { sal_Bool bMultiSelect = sal_False; m_xProps->getPropertyValue( "MultiSelection" ) >>= bMultiSelect; - return bMultiSelect ? 1 : 0 ; + return bMultiSelect; } void SAL_CALL -ScVbaListBox::setMultiSelect( sal_Int32 _multiselect ) throw (css::uno::RuntimeException) +ScVbaListBox::setMultiSelect( sal_Bool _multiselect ) throw (css::uno::RuntimeException) { - sal_Bool bMultiSelect = _multiselect == 1 ? 1 : 0; - m_xProps->setPropertyValue( "MultiSelection" , uno::makeAny( bMultiSelect ) ); + m_xProps->setPropertyValue( "MultiSelection" , uno::makeAny( _multiselect ) ); } diff --git a/vbahelper/source/msforms/vbalistbox.hxx b/vbahelper/source/msforms/vbalistbox.hxx index c337e929e377..3b0ee742e1a1 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_Int32 SAL_CALL getMultiSelect() throw (css::uno::RuntimeException); - virtual void SAL_CALL setMultiSelect( ::sal_Int32 _multiselect ) 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 css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() throw (css::uno::RuntimeException); // Methods diff --git a/vbahelper/source/msforms/vbatextbox.cxx b/vbahelper/source/msforms/vbatextbox.cxx index d820e26ee99f..4e94a3380c8f 100644 --- a/vbahelper/source/msforms/vbatextbox.cxx +++ b/vbahelper/source/msforms/vbatextbox.cxx @@ -59,8 +59,6 @@ ScVbaTextBox::getText() throw (css::uno::RuntimeException) void SAL_CALL ScVbaTextBox::setText( const OUString& _text ) throw (css::uno::RuntimeException) { - OUString sOldText = getText(); - if ( !mbDialog ) { uno::Reference< text::XTextRange > xTextRange( m_xProps, uno::UNO_QUERY_THROW ); @@ -68,11 +66,6 @@ ScVbaTextBox::setText( const OUString& _text ) throw (css::uno::RuntimeException } else m_xProps->setPropertyValue( "Text" , uno::makeAny( _text ) ); - - if ( _text != sOldText ) - { - fireChangeEvent(); - } } sal_Int32 SAL_CALL @@ -88,8 +81,7 @@ ScVbaTextBox::getMaxLength() throw (css::uno::RuntimeException) void SAL_CALL ScVbaTextBox::setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException) { - sal_Int16 _maxlength16 = static_cast (_maxlength); - uno::Any aValue( _maxlength16 ); + uno::Any aValue( _maxlength ); m_xProps->setPropertyValue( "MaxTextLen" , aValue); } diff --git a/vbahelper/source/msforms/vbatogglebutton.cxx b/vbahelper/source/msforms/vbatogglebutton.cxx index f0d9eefd5966..6bf65c1e6d01 100644 --- a/vbahelper/source/msforms/vbatogglebutton.cxx +++ b/vbahelper/source/msforms/vbatogglebutton.cxx @@ -66,25 +66,10 @@ void SAL_CALL ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException) { sal_Int16 nState = 0; - if (_value.getValueTypeClass() == uno::TypeClass_BOOLEAN) - { - sal_Bool bValue; - _value >>= bValue; - nState = static_cast< sal_Int16 >(bValue); - } - else if (_value.getValueTypeClass() == uno::TypeClass_BYTE) - { - sal_Int8 nValue; - _value >>= nValue; - nState = ( nValue == 1) ? 1 : 0; - } - else - { - _value >>= nState; - OSL_TRACE( "nState - %d", nState ); - nState = ( nState == -1 ) ? 1 : 0; - OSL_TRACE( "nState - %d", nState ); - } + _value >>= nState; + OSL_TRACE( "nState - %d", nState ); + nState = ( nState == -1 ) ? 1 : 0; + OSL_TRACE( "nState - %d", nState ); m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) ); } diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx index a55f55d79556..988e83748223 100644 --- a/vbahelper/source/msforms/vbauserform.cxx +++ b/vbahelper/source/msforms/vbauserform.cxx @@ -20,7 +20,6 @@ #include "vbauserform.hxx" #include #include -#include #include #include #include @@ -141,20 +140,6 @@ ScVbaUserForm::Hide( ) throw (uno::RuntimeException) m_xDialog->endExecute(); } -sal_Bool SAL_CALL ScVbaUserForm::getVisible() throw (uno::RuntimeException) -{ - uno::Reference< awt::XWindow2 > xWindow2( getWindowPeer(), uno::UNO_QUERY_THROW ); - return xWindow2->isVisible(); -} - -void SAL_CALL ScVbaUserForm::setVisible( sal_Bool bVisible ) throw (uno::RuntimeException) -{ - if ( bVisible ) - Show(); - else - Hide(); -} - void SAL_CALL ScVbaUserForm::RePaint( ) throw (uno::RuntimeException) { diff --git a/vbahelper/source/msforms/vbauserform.hxx b/vbahelper/source/msforms/vbauserform.hxx index 7ed74ea7fd52..59321fc4d67b 100644 --- a/vbahelper/source/msforms/vbauserform.hxx +++ b/vbahelper/source/msforms/vbauserform.hxx @@ -42,8 +42,6 @@ public: ScVbaUserForm( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException ); virtual ~ScVbaUserForm(); static css::uno::Reference< css::awt::XControl > nestedSearch( const OUString& aPropertyName, css::uno::Reference< css::awt::XControlContainer >& xContainer ); - virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); - virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException); // XUserForm virtual void SAL_CALL RePaint( ) throw (css::uno::RuntimeException); virtual void SAL_CALL Show( ) throw (css::uno::RuntimeException); diff --git a/vbahelper/source/vbahelper/vbadialogbase.cxx b/vbahelper/source/vbahelper/vbadialogbase.cxx index ffee84eee758..6cfb3c8166fc 100644 --- a/vbahelper/source/vbahelper/vbadialogbase.cxx +++ b/vbahelper/source/vbahelper/vbadialogbase.cxx @@ -22,7 +22,7 @@ using namespace ::ooo::vba; using namespace ::com::sun::star; -sal_Bool SAL_CALL VbaDialogBase::Show() throw ( uno::RuntimeException ) +void SAL_CALL VbaDialogBase::Show() throw ( uno::RuntimeException ) { OUString aURL; if ( m_xModel.is() ) @@ -35,8 +35,6 @@ sal_Bool SAL_CALL VbaDialogBase::Show() throw ( uno::RuntimeException ) uno::Sequence< beans::PropertyValue > dispatchProps(0); dispatchRequests( m_xModel, aURL, dispatchProps ); - } - return sal_True; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx index f3883f5fb683..7d1088314155 100644 --- a/vbahelper/source/vbahelper/vbadocumentbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx @@ -150,39 +150,38 @@ VbaDocumentBase::Close( const uno::Any &rSaveArg, const uno::Any &rFileArg, if ( !bUIClose ) { // if it is not possible to use UI dispatch, try to close the model directly - uno::Reference< util::XCloseable > xCloseable( getModel(), uno::UNO_QUERY ); - if( xCloseable.is() ) + bool bCloseable = false; + uno::Reference< frame::XModel > xModel = getModel(); + try { - // use close(boolean DeliverOwnership) + uno::Reference< util::XCloseable > xCloseable( xModel, uno::UNO_QUERY ); - // The boolean parameter DeliverOwnership tells objects vetoing the close process that they may - // assume ownership if they object the closure by throwing a CloseVetoException - // Here we give up ownership. To be on the safe side, catch possible veto exception anyway. - try + // use close(boolean DeliverOwnership) + // The boolean parameter DeliverOwnership tells objects vetoing the close + // process that they may assume ownership if they object the closure by + // throwing a CloseVetoException. Here we give up ownership. To be on the + // safe side, catch possible veto exception anyway. + if ( xCloseable.is() ) { + bCloseable = true; xCloseable->close(sal_True); } - catch(const util::CloseVetoException&) - { - //close is cancelled, nothing to do - } } - // If close is not supported by this model - try to dispose it. - // But if the model disagree with a reset request for the modify state - // we shouldn't do so. Otherwhise some strange things can happen. - else + catch (const uno::Exception &) + { + // vetoed + } + if (!bCloseable) { - uno::Reference< lang::XComponent > xDisposable ( getModel(), uno::UNO_QUERY ); - if ( xDisposable.is() ) + try { + // If close is not supported by this model - try to dispose it. + // But if the model disagree with a reset request for the modify state + // we shouldn't do so. Otherwhise some strange things can happen. + uno::Reference< lang::XComponent > xDisposable ( xModel, uno::UNO_QUERY_THROW ); + xDisposable->dispose(); + } + catch(const uno::Exception&) { - // To be on the safe side, catch possible veto exception anyway. - try - { - xDisposable->dispose(); - } - catch(const uno::Exception&) - { - } } } } diff --git a/vbahelper/source/vbahelper/vbadocumentsbase.cxx b/vbahelper/source/vbahelper/vbadocumentsbase.cxx index dee89256be3e..479074f72a15 100644 --- a/vbahelper/source/vbahelper/vbadocumentsbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentsbase.cxx @@ -44,7 +44,6 @@ #include #include #include -#include #include #include @@ -142,13 +141,8 @@ public: { uno::Reference< frame::XModel > xModel( xServiceInfo, uno::UNO_QUERY_THROW ); // that the spreadsheetdocument is a xmodel is a given m_documents.push_back( xModel ); - OUString sName; - uno::Reference< ::ooo::vba::XDocumentBase > xVbaDocument = new VbaDocumentBase( uno::Reference< XHelperInterface >(), xContext, xModel ); - if ( xVbaDocument.is() ) - { - sName = xVbaDocument->getName(); - } - namesToIndices[ sName ] = nIndex++; + INetURLObject aURL( xModel->getURL() ); + namesToIndices[ aURL.GetLastName() ] = nIndex++; } } diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index 301cd76f02cd..9db368e72b68 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -782,23 +782,6 @@ void setDefaultPropByIntrospection( const uno::Any& aObj, const uno::Any& aValue throw uno::RuntimeException(); } -uno::Any getDefaultPropByIntrospection( const uno::Any& aObj ) throw ( uno::RuntimeException ) -{ - uno::Any aValue; - uno::Reference< beans::XIntrospectionAccess > xUnoAccess( getIntrospectionAccess( aObj ) ); - uno::Reference< script::XDefaultProperty > xDefaultProperty( aObj, uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xPropSet; - - if ( xUnoAccess.is() ) - xPropSet.set( xUnoAccess->queryAdapter( ::getCppuType( (const uno::Reference< beans::XPropertySet > *)0 ) ), uno::UNO_QUERY ); - - if ( xPropSet.is() ) - aValue = xPropSet->getPropertyValue( xDefaultProperty->getDefaultPropertyName() ); - else - throw uno::RuntimeException(); - return aValue; -} - uno::Any getPropertyValue( const uno::Sequence< beans::PropertyValue >& aProp, const OUString& aName ) { uno::Any result; diff --git a/vbahelper/source/vbahelper/vbapictureformat.cxx b/vbahelper/source/vbahelper/vbapictureformat.cxx index 9b2aa114f6e0..d8501a85a947 100644 --- a/vbahelper/source/vbahelper/vbapictureformat.cxx +++ b/vbahelper/source/vbahelper/vbapictureformat.cxx @@ -104,13 +104,13 @@ ScVbaPictureFormat::IncrementContrast( double increment ) throw (uno::RuntimeExc { double nContrast = getContrast(); nContrast += increment; - if( nContrast < 0 ) + if( increment < 0 ) { - nContrast = 0.0; + increment = 0.0; } - if( nContrast > 1 ) + if( increment > 1 ) { - nContrast = 1.0; + increment = 1.0; } setContrast( nContrast ); } diff --git a/vbahelper/source/vbahelper/vbashape.cxx b/vbahelper/source/vbahelper/vbashape.cxx index 04462432a81c..bd7458e21309 100644 --- a/vbahelper/source/vbahelper/vbashape.cxx +++ b/vbahelper/source/vbahelper/vbashape.cxx @@ -492,17 +492,6 @@ ScVbaShape::ShapeRange( const uno::Any& index ) throw ( uno::RuntimeException ) return uno::makeAny( xShapeRange ); } -void SAL_CALL ScVbaShape::Copy() throw (uno::RuntimeException) -{ - if ( m_xModel.is() ) - { - Select( uno::Any() ); - // Copy this Shape. - OUString sUrl( ".uno:Copy" ); - dispatchRequests( m_xModel, sUrl ); - } -} - sal_Bool SAL_CALL ScVbaShape::getLockAspectRatio() throw (uno::RuntimeException) { -- cgit