diff options
Diffstat (limited to 'sc/source/ui/vba/vbaoleobject.cxx')
-rw-r--r-- | sc/source/ui/vba/vbaoleobject.cxx | 56 |
1 files changed, 18 insertions, 38 deletions
diff --git a/sc/source/ui/vba/vbaoleobject.cxx b/sc/source/ui/vba/vbaoleobject.cxx index 455141cf03fd..64e5f05f90e1 100644 --- a/sc/source/ui/vba/vbaoleobject.cxx +++ b/sc/source/ui/vba/vbaoleobject.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/view/XControlAccess.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/drawing/XShape.hpp> +#include <ooo/vba/XControlProvider.hpp> #include "vbaoleobject.hxx" @@ -61,8 +62,9 @@ ScVbaOLEObject::ScVbaOLEObject( const uno::Reference< XHelperInterface >& xParen xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW ); xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW ); css::uno::Reference< css::frame::XModel > xModel( xChild->getParent(), uno::UNO_QUERY_THROW ); - css::uno::Reference< css::view::XControlAccess > xControlAccess( xModel->getCurrentController(), css::uno::UNO_QUERY_THROW ); - m_xWindowPeer = xControlAccess->getControl( xControlModel )->getPeer(); + uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); + uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), mxContext ), uno::UNO_QUERY_THROW ); + m_xControl.set( xControlProvider->createControl( xControlShape, xModel ) ); } uno::Reference< uno::XInterface > SAL_CALL @@ -74,98 +76,76 @@ ScVbaOLEObject::getObject() throw (uno::RuntimeException) sal_Bool SAL_CALL ScVbaOLEObject::getEnabled() throw (uno::RuntimeException) { - uno::Reference< css::awt::XWindow2 > xWindow2( m_xWindowPeer, css::uno::UNO_QUERY_THROW ); - return xWindow2->isEnabled(); + return m_xControl->getEnabled(); } void SAL_CALL ScVbaOLEObject::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException) { - uno::Reference< css::awt::XWindow2 > xWindow2( m_xWindowPeer, css::uno::UNO_QUERY_THROW ); - xWindow2->setEnable( _enabled ); + m_xControl->setEnabled( _enabled ); } sal_Bool SAL_CALL ScVbaOLEObject::getVisible() throw (uno::RuntimeException) { - uno::Reference< css::awt::XWindow2 > xWindow2( m_xWindowPeer, css::uno::UNO_QUERY_THROW ); - return xWindow2->isVisible(); + OSL_TRACE("OleObject %s returning visible %s", rtl::OUStringToOString( m_xControl->getName(), RTL_TEXTENCODING_UTF8 ).getStr(), m_xControl->getVisible() ? "true" : "false" ); + return m_xControl->getVisible(); } void SAL_CALL ScVbaOLEObject::setVisible( sal_Bool _visible ) throw (uno::RuntimeException) { - uno::Reference< css::awt::XWindow2 > xWindow2( m_xWindowPeer, css::uno::UNO_QUERY_THROW ); - xWindow2->setVisible( _visible ); + OSL_TRACE("OleObject %s set visible %s", rtl::OUStringToOString( m_xControl->getName(), RTL_TEXTENCODING_UTF8 ).getStr(), _visible ? "true" : "false" ); + m_xControl->setVisible( _visible ); } double SAL_CALL ScVbaOLEObject::getLeft() throw (uno::RuntimeException) { - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - return mm2pt( xShape->getPosition().X / 100 ); + return m_xControl->getLeft(); } void SAL_CALL ScVbaOLEObject::setLeft( double _left ) throw (uno::RuntimeException) { - awt::Point oldPosition; - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - oldPosition = xShape->getPosition(); - oldPosition.X = pt2mm( _left ) * 100; - xShape->setPosition( oldPosition ); + m_xControl->setLeft( _left ); } double SAL_CALL ScVbaOLEObject::getTop() throw (uno::RuntimeException) { - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - return mm2pt( xShape->getPosition().Y / 100 ); + return m_xControl->getTop(); } void SAL_CALL ScVbaOLEObject::setTop( double _top ) throw (uno::RuntimeException) { - awt::Point oldPosition; - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - oldPosition = xShape->getPosition(); - oldPosition.Y = pt2mm( _top ) * 100;; - xShape->setPosition( oldPosition ); + m_xControl->setTop( _top ); } double SAL_CALL ScVbaOLEObject::getHeight() throw (uno::RuntimeException) { - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - return mm2pt( xShape->getSize().Height / 100 );//1pt = 1/72in + return m_xControl->getHeight(); } void SAL_CALL ScVbaOLEObject::setHeight( double _height ) throw (uno::RuntimeException) { - awt::Size oldSize; - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - oldSize = xShape->getSize(); - oldSize.Height = pt2mm( _height ) * 100; - xShape->setSize( oldSize ); + m_xControl->setHeight( _height ); } double SAL_CALL ScVbaOLEObject::getWidth() throw (uno::RuntimeException) { - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - return mm2pt ( xShape->getSize().Width / 100 ); + return m_xControl->getWidth(); } void SAL_CALL ScVbaOLEObject::setWidth( double _width ) throw (uno::RuntimeException) { - awt::Size oldSize; - uno::Reference< drawing::XShape > xShape( m_xControlShape, uno::UNO_QUERY_THROW ); - oldSize = xShape->getSize(); - oldSize.Width = pt2mm( _width ) * 100; - xShape->setSize( oldSize ); + m_xControl->setWidth( _width ); } rtl::OUString& ScVbaOLEObject::getServiceImplName() |