diff options
Diffstat (limited to 'vbahelper/source/vbahelper')
-rw-r--r-- | vbahelper/source/vbahelper/makefile.mk | 5 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbaapplicationbase.cxx | 9 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbadialogbase.cxx | 28 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbadocumentbase.cxx | 31 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbadocumentsbase.cxx | 11 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbahelper.cxx | 70 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbapictureformat.cxx | 9 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbashape.cxx | 123 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbashaperange.cxx | 31 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbashapes.cxx | 2 |
10 files changed, 255 insertions, 64 deletions
diff --git a/vbahelper/source/vbahelper/makefile.mk b/vbahelper/source/vbahelper/makefile.mk index 22ed40a3adfa..31fefa8430b1 100644 --- a/vbahelper/source/vbahelper/makefile.mk +++ b/vbahelper/source/vbahelper/makefile.mk @@ -33,11 +33,6 @@ ENABLE_EXCEPTIONS := TRUE VISIBILITY_HIDDEN=TRUE # --- Settings ----------------------------------------------------- -.IF "$(ENABLE_VBA)" == "NO" -dummy: - @echo "Nothing to build" -.ENDIF - .INCLUDE : settings.mk SLOFILES=\ diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 326c150edade..a8b04df6f493 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -200,6 +200,8 @@ void SAL_CALL VbaApplicationBase::setScreenUpdating(sal_Bool bUpdate) throw (uno::RuntimeException) { uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); + if( bUpdate != xModel->hasControllersLocked() ) + return; if (bUpdate) xModel->unlockControllers(); else @@ -293,7 +295,7 @@ VbaApplicationBase::getVersion() throw (uno::RuntimeException) return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(OFFICEVERSION)); } -void SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, const uno::Any& varg1, const uno::Any& varg2, const uno::Any& varg3, const uno::Any& varg4, const uno::Any& varg5, const uno::Any& varg6, const uno::Any& varg7, const uno::Any& varg8, const uno::Any& varg9, const uno::Any& varg10, const uno::Any& varg11, const uno::Any& varg12, const uno::Any& varg13, const uno::Any& varg14, const uno::Any& varg15, const uno::Any& varg16, const uno::Any& varg17, const uno::Any& varg18, const uno::Any& varg19, const uno::Any& varg20, const uno::Any& varg21, const uno::Any& varg22, const uno::Any& varg23, const uno::Any& varg24, const uno::Any& varg25, const uno::Any& varg26, const uno::Any& varg27, const uno::Any& varg28, const uno::Any& varg29, const uno::Any& varg30 ) throw (uno::RuntimeException) +uno::Any SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, const uno::Any& varg1, const uno::Any& varg2, const uno::Any& varg3, const uno::Any& varg4, const uno::Any& varg5, const uno::Any& varg6, const uno::Any& varg7, const uno::Any& varg8, const uno::Any& varg9, const uno::Any& varg10, const uno::Any& varg11, const uno::Any& varg12, const uno::Any& varg13, const uno::Any& varg14, const uno::Any& varg15, const uno::Any& varg16, const uno::Any& varg17, const uno::Any& varg18, const uno::Any& varg19, const uno::Any& varg20, const uno::Any& varg21, const uno::Any& varg22, const uno::Any& varg23, const uno::Any& varg24, const uno::Any& varg25, const uno::Any& varg26, const uno::Any& varg27, const uno::Any& varg28, const uno::Any& varg29, const uno::Any& varg30 ) throw (uno::RuntimeException) { ::rtl::OUString sSeparator = ::rtl::OUString::createFromAscii("/"); ::rtl::OUString sMacroSeparator = ::rtl::OUString::createFromAscii("!"); @@ -342,7 +344,8 @@ void SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, const u } - VBAMacroResolvedInfo aMacroInfo = resolveVBAMacro( getSfxObjShell( aMacroDocumentModel ), sMacro_only_Name ); + // search the global tempalte + VBAMacroResolvedInfo aMacroInfo = resolveVBAMacro( getSfxObjShell( aMacroDocumentModel ), sMacro_only_Name, sal_True ); if( aMacroInfo.IsResolved() ) { // handle the arguments @@ -370,6 +373,8 @@ void SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, const u uno::Any aRet; uno::Any aDummyCaller; executeMacro( aMacroInfo.MacroDocContext(), aMacroInfo.ResolvedMacro(), aArgs, aRet, aDummyCaller ); + + return aRet; } else { diff --git a/vbahelper/source/vbahelper/vbadialogbase.cxx b/vbahelper/source/vbahelper/vbadialogbase.cxx index e093e32c7443..d39fb273c7db 100644 --- a/vbahelper/source/vbahelper/vbadialogbase.cxx +++ b/vbahelper/source/vbahelper/vbadialogbase.cxx @@ -30,11 +30,10 @@ using namespace ::ooo::vba; using namespace ::com::sun::star; -// fails silently -void -VbaDialogBase::Show() throw(uno::RuntimeException) +sal_Bool SAL_CALL VbaDialogBase::Show() throw ( uno::RuntimeException ) { rtl::OUString aURL; + sal_Bool bSuccess = sal_False; if ( m_xModel.is() ) { aURL = mapIndexToName( mnIndex ); @@ -42,7 +41,26 @@ VbaDialogBase::Show() throw(uno::RuntimeException) throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " Unable to open the specified dialog " ) ), uno::Reference< XInterface > () ); - dispatchRequests( m_xModel, aURL ); + + uno::Sequence< beans::PropertyValue > dispatchProps(0); + if ( aURL.equalsAscii(".uno:PrinterSetup") ) + { + dispatchProps.realloc(1); + dispatchProps[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VBADialogResultRequest" ) ); + dispatchProps[0].Value <<= (sal_Bool) sal_True; + } + + VBADispatchListener *pNotificationListener = new VBADispatchListener(); + uno::Reference< frame::XDispatchResultListener > rListener = pNotificationListener; + dispatchRequests( m_xModel, aURL, dispatchProps, rListener, sal_False ); + + bSuccess = pNotificationListener->getState(); + uno::Any aResult = pNotificationListener->getResult(); + if ( bSuccess ) + { + if ( aResult.getValueTypeClass() == uno::TypeClass_BOOLEAN ) + aResult >>= bSuccess; + } } + return bSuccess; } - diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx index 65f7f4bcfbeb..b4a7a12872f6 100644 --- a/vbahelper/source/vbahelper/vbadocumentbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/util/XCloseable.hpp> #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XTitle.hpp> #include <com/sun/star/document/XEmbeddedScripts.hpp> //Michael E. Bohn #include <com/sun/star/beans/XPropertySet.hpp> @@ -68,13 +69,8 @@ VbaDocumentBase::getName() throw (uno::RuntimeException) } else { - const static rtl::OUString sTitle( RTL_CONSTASCII_USTRINGPARAM("Title" ) ); - // process "UntitledX - $(PRODUCTNAME)" - uno::Reference< frame::XFrame > xFrame( getModel()->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW ); - xProps->getPropertyValue(sTitle ) >>= sName; - sal_Int32 pos = 0; - sName = sName.getToken(0,' ',pos); + uno::Reference< frame::XTitle > xTitle( getModel(), uno::UNO_QUERY_THROW ); + sName = xTitle->getTitle(); } return sName; } @@ -130,12 +126,20 @@ VbaDocumentBase::Close( const uno::Any &rSaveArg, const uno::Any &rFileArg, uno::Reference< util::XCloseable > xCloseable( getModel(), uno::UNO_QUERY ); if( xCloseable.is() ) + { // 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. - xCloseable->close(sal_True); + try{ + xCloseable->close(sal_True); + } + catch( 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. @@ -143,7 +147,16 @@ VbaDocumentBase::Close( const uno::Any &rSaveArg, const uno::Any &rFileArg, { uno::Reference< lang::XComponent > xDisposable ( getModel(), uno::UNO_QUERY ); if ( xDisposable.is() ) - xDisposable->dispose(); + { + // To be on the safe side, catch possible veto exception anyway. + try + { + xDisposable->dispose(); + } + catch( uno::Exception& ) + { + } + } } } diff --git a/vbahelper/source/vbahelper/vbadocumentsbase.cxx b/vbahelper/source/vbahelper/vbadocumentsbase.cxx index 2d4175b90939..194651e957fb 100644 --- a/vbahelper/source/vbahelper/vbadocumentsbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentsbase.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XTitle.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/frame/XStorable.hpp> @@ -49,6 +50,7 @@ #include <sfx2/objsh.hxx> #include <tools/urlobj.hxx> #include <vbahelper/vbahelper.hxx> +#include <vbahelper/vbadocumentbase.hxx> #include <hash_map> #include <osl/file.hxx> @@ -143,8 +145,13 @@ 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 ); - INetURLObject aURL( xModel->getURL() ); - namesToIndices[ aURL.GetLastName() ] = nIndex++; + rtl::OUString sName; + uno::Reference< ::ooo::vba::XDocumentBase > xVbaDocument = new VbaDocumentBase( uno::Reference< XHelperInterface >(), xContext, xModel ); + if ( xVbaDocument.is() ) + { + sName = xVbaDocument->getName(); + } + namesToIndices[ sName ] = nIndex++; } } diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index 14f4e3ff1363..9ba6e3fbafe0 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/frame/XController.hpp> #include <com/sun/star/frame/XModel2.hpp> +#include <com/sun/star/frame/XNotifyingDispatch.hpp> #include <com/sun/star/script/XDefaultProperty.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp> @@ -311,7 +312,7 @@ void dispatchExecute(SfxViewShell* pViewShell, USHORT nSlot, SfxCallMode nCall) } void -dispatchRequests( const uno::Reference< frame::XModel>& xModel, const rtl::OUString& aUrl, const uno::Sequence< beans::PropertyValue >& sProps ) +dispatchRequests (const uno::Reference< frame::XModel>& xModel, const rtl::OUString & aUrl, const uno::Sequence< beans::PropertyValue >& sProps, const uno::Reference< frame::XDispatchResultListener >& rListener, const sal_Bool bSilent ) { util::URL url; url.Complete = aUrl; @@ -343,6 +344,7 @@ dispatchRequests( const uno::Reference< frame::XModel>& xModel, const rtl::OUStr } uno::Reference<frame::XDispatch> xDispatcher = xDispatchProvider->queryDispatch(url,emptyString,0); + uno::Reference< frame::XNotifyingDispatch > xNotifyingDispatcher( xDispatcher, uno::UNO_QUERY ); uno::Sequence<beans::PropertyValue> dispatchProps(1); @@ -358,11 +360,20 @@ dispatchRequests( const uno::Reference< frame::XModel>& xModel, const rtl::OUStr *pDest = *pSrc; } - (*pDest).Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Silent" )); - (*pDest).Value <<= (sal_Bool)sal_True; + if ( bSilent ) + { + (*pDest).Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Silent" )); + (*pDest).Value <<= (sal_Bool)sal_True; + } - if (xDispatcher.is()) + if ( !rListener.is() && xDispatcher.is() ) + { xDispatcher->dispatch( url, dispatchProps ); + } + else if ( rListener.is() && xNotifyingDispatcher.is() ) + { + xNotifyingDispatcher->dispatchWithNotification( url, dispatchProps, rListener ); + } } void @@ -959,6 +970,23 @@ 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 rtl::OUString& aName ) { uno::Any result; @@ -986,6 +1014,18 @@ sal_Bool setPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, const r return sal_False; } +void setOrAppendPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, const rtl::OUString& aName, const uno::Any& aValue ) +{ + if( setPropertyValue( aProp, aName, aValue ) ) + return; + + // append the property + sal_Int32 nLength = aProp.getLength(); + aProp.realloc( nLength + 1 ); + aProp[ nLength ].Name = aName; + aProp[ nLength ].Value = aValue; +} + // ====UserFormGeomentryHelper==== //--------------------------------------------- UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl ) @@ -1448,6 +1488,28 @@ void UserFormGeometryHelper::setHeight( double nHeight ) return xIf; } + // Listener for XNotifyingDispatch + VBADispatchListener::VBADispatchListener() : m_State( sal_False ) + { + } + + // Listener for XNotifyingDispatch + VBADispatchListener::~VBADispatchListener() + { + } + + // Listener for XNotifyingDispatch + void SAL_CALL VBADispatchListener::dispatchFinished( const frame::DispatchResultEvent& aEvent ) throw ( uno::RuntimeException ) + { + m_Result = aEvent.Result; + m_State = ( aEvent.State == frame::DispatchResultState::SUCCESS ) ? sal_True : sal_False; + } + + // Listener for XNotifyingDispatch + void SAL_CALL VBADispatchListener::disposing( const lang::EventObject& /*aEvent*/ ) throw( uno::RuntimeException ) + { + } + SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) { SfxObjectShell* pFoundShell = NULL; diff --git a/vbahelper/source/vbahelper/vbapictureformat.cxx b/vbahelper/source/vbahelper/vbapictureformat.cxx index 7ebbb62d1125..5c0eeffac958 100644 --- a/vbahelper/source/vbahelper/vbapictureformat.cxx +++ b/vbahelper/source/vbahelper/vbapictureformat.cxx @@ -112,13 +112,14 @@ ScVbaPictureFormat::IncrementContrast( double increment ) throw (uno::RuntimeExc { double nContrast = getContrast(); nContrast += increment; - if( increment < 0 ) + //VBA, minz@cn.ibm.com. + if( nContrast < 0 ) { - increment = 0.0; + nContrast = 0.0; } - if( increment > 1 ) + if( nContrast > 1 ) { - increment = 1.0; + nContrast = 1.0; } setContrast( nContrast ); } diff --git a/vbahelper/source/vbahelper/vbashape.cxx b/vbahelper/source/vbahelper/vbashape.cxx index 485ebee3ea8d..2073642251cf 100644 --- a/vbahelper/source/vbahelper/vbashape.cxx +++ b/vbahelper/source/vbahelper/vbashape.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> +#include <com/sun/star/text/RelOrientation.hpp> #include <ooo/vba/word/WdRelativeHorizontalPosition.hpp> #include <ooo/vba/word/WdRelativeVerticalPosition.hpp> @@ -219,25 +220,66 @@ ScVbaShape::setWidth( double _width ) throw (uno::RuntimeException) double SAL_CALL ScVbaShape::getLeft() throw (uno::RuntimeException) { - return m_pShapeHelper->getLeft(); + double left = 0; + try + { + left = m_pShapeHelper->getLeft(); + } + catch( uno::Exception& ) + { + // fail to get position by using XShape::getPosition() + sal_Int32 nLeft = 0; + m_xPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition") ) ) >>= nLeft; + left = Millimeter::getInPoints( nLeft ); + } + return left; } void SAL_CALL ScVbaShape::setLeft( double _left ) throw (uno::RuntimeException) { - m_pShapeHelper->setLeft( _left ); + try + { + m_pShapeHelper->setLeft( _left ); + } + catch( uno::Exception& ) + { + sal_Int32 nLeft = 0; + nLeft = Millimeter::getInHundredthsOfOneMillimeter( _left ); + m_xPropertySet->setPropertyValue( rtl::OUString::createFromAscii( "HoriOrientPosition" ), uno::makeAny( nLeft ) ); + } } double SAL_CALL ScVbaShape::getTop() throw (uno::RuntimeException) { - return m_pShapeHelper->getTop(); + double top = 0; + try + { + top = m_pShapeHelper->getTop(); + } + catch( uno::Exception& ) + { + sal_Int32 nTop = 0; + m_xPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition") ) ) >>= nTop; + top = Millimeter::getInPoints( nTop ); + } + return top; } void SAL_CALL ScVbaShape::setTop( double _top ) throw (uno::RuntimeException) { - return m_pShapeHelper->setTop( _top ); + try + { + m_pShapeHelper->setTop( _top ); + } + catch( uno::Exception& ) + { + sal_Int32 nTop = 0; + nTop = Millimeter::getInHundredthsOfOneMillimeter( _top ); + m_xPropertySet->setPropertyValue( rtl::OUString::createFromAscii( "VertOrientPosition" ), uno::makeAny( nTop ) ); + } } sal_Bool SAL_CALL @@ -474,6 +516,17 @@ 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. + rtl::OUString sUrl = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".uno:Copy") ); + dispatchRequests( m_xModel, sUrl ); + } +} + sal_Bool SAL_CALL ScVbaShape::getLockAspectRatio() throw (uno::RuntimeException) { @@ -504,35 +557,34 @@ sal_Int32 SAL_CALL ScVbaShape::getRelativeHorizontalPosition() throw (uno::RuntimeException) { sal_Int32 nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionMargin; - text::TextContentAnchorType eType = text::TextContentAnchorType_AT_PARAGRAPH; - m_xPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AnchorType") ) ) >>= eType; + sal_Int16 nType = text::RelOrientation::PAGE_LEFT; + m_xPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HoriOrientRelation") ) ) >>= nType; - switch( eType ) + switch( nType ) { - case text::TextContentAnchorType_AT_PARAGRAPH: + case text::RelOrientation::FRAME: { nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionColumn; break; } - case text::TextContentAnchorType_AT_PAGE: + case text::RelOrientation::PAGE_FRAME: { nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionPage; break; } - case text::TextContentAnchorType_AT_CHARACTER: + case text::RelOrientation::CHAR: { nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionCharacter; break; } - case text::TextContentAnchorType_AT_FRAME: - case text::TextContentAnchorType_AS_CHARACTER: + case text::RelOrientation::PAGE_PRINT_AREA: { nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionMargin; break; } default: { - nRelativeHorizontalPosition = word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionMargin; + throw uno::RuntimeException( rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Shape::RelativeHorizontalPosition: not implemented" ) ), uno::Reference< uno::XInterface >() ); } } return nRelativeHorizontalPosition; @@ -541,23 +593,27 @@ ScVbaShape::getRelativeHorizontalPosition() throw (uno::RuntimeException) void SAL_CALL ScVbaShape::setRelativeHorizontalPosition( ::sal_Int32 _relativehorizontalposition ) throw (uno::RuntimeException) { - text::TextContentAnchorType eType = text::TextContentAnchorType_AT_PARAGRAPH; + sal_Int16 nType = text::RelOrientation::PAGE_FRAME; switch( _relativehorizontalposition ) { case word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionCharacter: { - eType = text::TextContentAnchorType_AT_CHARACTER; + nType = text::RelOrientation::CHAR; break; } case word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionColumn: + { + nType = text::RelOrientation::PAGE_FRAME; + break; + } case word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionMargin: { - eType = text::TextContentAnchorType_AT_PARAGRAPH; + nType = text::RelOrientation::PAGE_PRINT_AREA; break; } case word::WdRelativeHorizontalPosition::wdRelativeHorizontalPositionPage: { - eType = text::TextContentAnchorType_AT_PAGE; + nType = text::RelOrientation::PAGE_FRAME; break; } default: @@ -565,42 +621,41 @@ ScVbaShape::setRelativeHorizontalPosition( ::sal_Int32 _relativehorizontalpositi DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString()); } } - m_xPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AnchorType") ), uno::makeAny( eType ) ); + m_xPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HoriOrientRelation") ), uno::makeAny( nType ) ); } sal_Int32 SAL_CALL ScVbaShape::getRelativeVerticalPosition() throw (uno::RuntimeException) { sal_Int32 nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionMargin; - text::TextContentAnchorType eType = text::TextContentAnchorType_AT_PARAGRAPH; - m_xPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AnchorType") ) ) >>= eType; + sal_Int16 nType = text::RelOrientation::PAGE_FRAME; + m_xPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VertOrientRelation") ) ) >>= nType; - switch( eType ) + switch( nType ) { - case text::TextContentAnchorType_AT_PARAGRAPH: + case text::RelOrientation::FRAME: { nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionParagraph; break; } - case text::TextContentAnchorType_AT_PAGE: + case text::RelOrientation::PAGE_FRAME: { nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionPage; break; } - case text::TextContentAnchorType_AT_CHARACTER: + case text::RelOrientation::TEXT_LINE: { nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionLine; break; } - case text::TextContentAnchorType_AT_FRAME: - case text::TextContentAnchorType_AS_CHARACTER: + case text::RelOrientation::PAGE_PRINT_AREA: { nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionMargin; break; } default: { - nRelativeVerticalPosition = word::WdRelativeVerticalPosition::wdRelativeVerticalPositionMargin; + throw uno::RuntimeException( rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Shape::RelativeVerticalPosition: not implemented" ) ), uno::Reference< uno::XInterface >() ); } } return nRelativeVerticalPosition; @@ -609,23 +664,27 @@ ScVbaShape::getRelativeVerticalPosition() throw (uno::RuntimeException) void SAL_CALL ScVbaShape::setRelativeVerticalPosition( ::sal_Int32 _relativeverticalposition ) throw (uno::RuntimeException) { - text::TextContentAnchorType eType = text::TextContentAnchorType_AT_PARAGRAPH; + sal_Int16 nType = text::RelOrientation::PAGE_FRAME; switch( _relativeverticalposition ) { case word::WdRelativeVerticalPosition::wdRelativeVerticalPositionLine: { - eType = text::TextContentAnchorType_AT_CHARACTER; + nType = text::RelOrientation::TEXT_LINE; break; } case word::WdRelativeVerticalPosition::wdRelativeVerticalPositionParagraph: + { + nType = text::RelOrientation::FRAME; + break; + } case word::WdRelativeVerticalPosition::wdRelativeVerticalPositionMargin: { - eType = text::TextContentAnchorType_AT_PARAGRAPH; + nType = text::RelOrientation::PAGE_PRINT_AREA; break; } case word::WdRelativeVerticalPosition::wdRelativeVerticalPositionPage: { - eType = text::TextContentAnchorType_AT_PAGE; + nType = text::RelOrientation::PAGE_FRAME; break; } default: @@ -633,7 +692,7 @@ ScVbaShape::setRelativeVerticalPosition( ::sal_Int32 _relativeverticalposition ) DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString()); } } - m_xPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AnchorType") ), uno::makeAny( eType ) ); + m_xPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VertOrientRelation") ), uno::makeAny( nType ) ); } uno::Any SAL_CALL diff --git a/vbahelper/source/vbahelper/vbashaperange.cxx b/vbahelper/source/vbahelper/vbashaperange.cxx index 3020cfa47eca..d8dd753f24eb 100644 --- a/vbahelper/source/vbahelper/vbashaperange.cxx +++ b/vbahelper/source/vbahelper/vbashaperange.cxx @@ -125,6 +125,27 @@ ScVbaShapeRange::IncrementTop( double Increment ) throw (uno::RuntimeException) } } +rtl::OUString SAL_CALL ScVbaShapeRange::getName() throw (uno::RuntimeException) +{ + sal_Int32 nLen = getCount(); + for ( sal_Int32 index = 1; index <= nLen; ++index ) + { + uno::Reference< msforms::XShape > xShape( Item( uno::makeAny( index ), uno::Any() ), uno::UNO_QUERY_THROW ); + return xShape->getName( ); + } + throw uno::RuntimeException(); +} + +void SAL_CALL ScVbaShapeRange::setName( const rtl::OUString& _name ) throw (uno::RuntimeException) +{ + sal_Int32 nLen = getCount(); + for ( sal_Int32 index = 1; index <= nLen; ++index ) + { + uno::Reference< msforms::XShape > xShape( Item( uno::makeAny( index ), uno::Any() ), uno::UNO_QUERY_THROW ); + xShape->setName( _name ); + } +} + double SAL_CALL ScVbaShapeRange::getHeight() throw (uno::RuntimeException) { sal_Int32 nLen = getCount(); @@ -337,6 +358,16 @@ uno::Any SAL_CALL ScVbaShapeRange::WrapFormat( ) throw (css::uno::RuntimeExcept throw uno::RuntimeException(); } +void SAL_CALL ScVbaShapeRange::ZOrder( sal_Int32 ZOrderCmd ) throw (uno::RuntimeException) +{ + sal_Int32 nLen = getCount(); + for ( sal_Int32 index = 1; index <= nLen; ++index ) + { + uno::Reference< msforms::XShape > xShape( Item( uno::makeAny( index ), uno::Any() ), uno::UNO_QUERY_THROW ); + xShape->ZOrder( ZOrderCmd ); + } +} + uno::Type SAL_CALL ScVbaShapeRange::getElementType() throw (uno::RuntimeException) { diff --git a/vbahelper/source/vbahelper/vbashapes.cxx b/vbahelper/source/vbahelper/vbashapes.cxx index 37952ee3d3a3..f3abf739635a 100644 --- a/vbahelper/source/vbahelper/vbashapes.cxx +++ b/vbahelper/source/vbahelper/vbashapes.cxx @@ -86,7 +86,7 @@ void ScVbaShapes::initBaseCollection() m_xNameAccess.set( xShapes, uno::UNO_QUERY ); } -ScVbaShapes::ScVbaShapes( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess > xShapes, const uno::Reference< frame::XModel>& xModel ): ScVbaShapes_BASE( xParent, xContext, xShapes ), m_nNewShapeCount(0), m_xModel( xModel ) +ScVbaShapes::ScVbaShapes( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess > xShapes, const uno::Reference< frame::XModel>& xModel ): ScVbaShapes_BASE( xParent, xContext, xShapes, sal_True ), m_nNewShapeCount(0), m_xModel( xModel ) { m_xShapes.set( xShapes, uno::UNO_QUERY_THROW ); m_xDrawPage.set( xShapes, uno::UNO_QUERY_THROW ); |