Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/awt/XControlModel.hpp>
21 : #include <com/sun/star/awt/XWindow2.hpp>
22 : #include <com/sun/star/view/XControlAccess.hpp>
23 : #include <com/sun/star/container/XChild.hpp>
24 : #include <com/sun/star/drawing/XShape.hpp>
25 : #include <ooo/vba/XControlProvider.hpp>
26 :
27 : #include "vbaoleobject.hxx"
28 : #include <svx/svdobj.hxx>
29 : #include "drwlayer.hxx"
30 : #include "excelvbahelper.hxx"
31 : #include <svtools/bindablecontrolhelper.hxx>
32 : using namespace com::sun::star;
33 : using namespace ooo::vba;
34 :
35 1 : ScVbaOLEObject::ScVbaOLEObject( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext,
36 : css::uno::Reference< css::drawing::XControlShape > xControlShape )
37 1 : : OLEObjectImpl_BASE( xParent, xContext ), m_xControlShape( xControlShape )
38 : {
39 : //init m_xWindowPeer
40 1 : uno::Reference< awt::XControlModel > xControlModel( xControlShape->getControl(), css::uno::UNO_QUERY_THROW );
41 2 : uno::Reference< container::XChild > xChild( xControlModel, uno::UNO_QUERY_THROW );
42 1 : xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW );
43 1 : xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW );
44 2 : uno::Reference<frame::XModel> xModel( xChild->getParent(), uno::UNO_QUERY_THROW );
45 2 : uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
46 2 : uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext("ooo.vba.ControlProvider", mxContext ), uno::UNO_QUERY_THROW );
47 2 : m_xControl.set( xControlProvider->createControl( xControlShape, xModel ) );
48 1 : }
49 :
50 : uno::Reference< uno::XInterface > SAL_CALL
51 1 : ScVbaOLEObject::getObject() throw (uno::RuntimeException, std::exception)
52 : {
53 1 : return uno::Reference< uno::XInterface >( m_xControl, uno::UNO_QUERY_THROW );
54 : }
55 :
56 : sal_Bool SAL_CALL
57 0 : ScVbaOLEObject::getEnabled() throw (uno::RuntimeException, std::exception)
58 : {
59 0 : return m_xControl->getEnabled();
60 : }
61 :
62 : void SAL_CALL
63 0 : ScVbaOLEObject::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException, std::exception)
64 : {
65 0 : m_xControl->setEnabled( _enabled );
66 0 : }
67 :
68 : sal_Bool SAL_CALL
69 0 : ScVbaOLEObject::getVisible() throw (uno::RuntimeException, std::exception)
70 : {
71 : OSL_TRACE("OleObject %s returning visible %s", OUStringToOString( m_xControl->getName(), RTL_TEXTENCODING_UTF8 ).getStr(), m_xControl->getVisible() ? "true" : "false" );
72 0 : return m_xControl->getVisible();
73 : }
74 :
75 : void SAL_CALL
76 0 : ScVbaOLEObject::setVisible( sal_Bool _visible ) throw (uno::RuntimeException, std::exception)
77 : {
78 : OSL_TRACE("OleObject %s set visible %s", OUStringToOString( m_xControl->getName(), RTL_TEXTENCODING_UTF8 ).getStr(), _visible ? "true" : "false" );
79 0 : m_xControl->setVisible( _visible );
80 0 : }
81 :
82 : double SAL_CALL
83 0 : ScVbaOLEObject::getLeft() throw (uno::RuntimeException, std::exception)
84 : {
85 0 : return m_xControl->getLeft();
86 : }
87 :
88 : void SAL_CALL
89 0 : ScVbaOLEObject::setLeft( double _left ) throw (uno::RuntimeException, std::exception)
90 : {
91 0 : m_xControl->setLeft( _left );
92 :
93 0 : }
94 :
95 : double SAL_CALL
96 0 : ScVbaOLEObject::getTop() throw (uno::RuntimeException, std::exception)
97 : {
98 0 : return m_xControl->getTop();
99 : }
100 :
101 : void SAL_CALL
102 0 : ScVbaOLEObject::setTop( double _top ) throw (uno::RuntimeException, std::exception)
103 : {
104 0 : m_xControl->setTop( _top );
105 0 : }
106 :
107 : double SAL_CALL
108 0 : ScVbaOLEObject::getHeight() throw (uno::RuntimeException, std::exception)
109 : {
110 0 : return m_xControl->getHeight();
111 : }
112 :
113 : void SAL_CALL
114 0 : ScVbaOLEObject::setHeight( double _height ) throw (uno::RuntimeException, std::exception)
115 : {
116 0 : m_xControl->setHeight( _height );
117 0 : }
118 :
119 : double SAL_CALL
120 0 : ScVbaOLEObject::getWidth() throw (uno::RuntimeException, std::exception)
121 : {
122 0 : return m_xControl->getWidth();
123 : }
124 :
125 : void SAL_CALL
126 0 : ScVbaOLEObject::setWidth( double _width ) throw (uno::RuntimeException, std::exception)
127 : {
128 0 : m_xControl->setWidth( _width );
129 0 : }
130 :
131 0 : OUString SAL_CALL ScVbaOLEObject::getLinkedCell() throw (uno::RuntimeException, std::exception)
132 : {
133 0 : return m_xControl->getControlSource();
134 : }
135 :
136 0 : void SAL_CALL ScVbaOLEObject::setLinkedCell( const OUString& _linkedcell ) throw (uno::RuntimeException, std::exception)
137 : {
138 0 : m_xControl->setControlSource( _linkedcell );
139 0 : }
140 :
141 : OUString
142 0 : ScVbaOLEObject::getServiceImplName()
143 : {
144 0 : return OUString("ScVbaOLEObject");
145 : }
146 :
147 : uno::Sequence< OUString >
148 0 : ScVbaOLEObject::getServiceNames()
149 : {
150 0 : static uno::Sequence< OUString > aServiceNames;
151 0 : if ( aServiceNames.getLength() == 0 )
152 : {
153 0 : aServiceNames.realloc( 1 );
154 0 : aServiceNames[ 0 ] = "ooo.vba.excel.OLEObject";
155 : }
156 0 : return aServiceNames;
157 9 : }
158 :
159 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|