LibreOffice Module sc (master)  1
vbaoleobject.cxx
Go to the documentation of this file.
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/container/XChild.hpp>
22 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
23 #include <ooo/vba/XControlProvider.hpp>
24 
25 #include "vbaoleobject.hxx"
26 
27 using namespace com::sun::star;
28 using namespace ooo::vba;
29 
30 ScVbaOLEObject::ScVbaOLEObject( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext,
31  css::uno::Reference< css::drawing::XControlShape > const & xControlShape )
32 : OLEObjectImpl_BASE( xParent, xContext )
33 {
34  //init m_xWindowPeer
35  uno::Reference< awt::XControlModel > xControlModel( xControlShape->getControl(), css::uno::UNO_SET_THROW );
36  uno::Reference< container::XChild > xChild( xControlModel, uno::UNO_QUERY_THROW );
37  xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW );
38  xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW );
39  uno::Reference<frame::XModel> xModel( xChild->getParent(), uno::UNO_QUERY_THROW );
40  uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
41  uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext("ooo.vba.ControlProvider", mxContext ), uno::UNO_QUERY_THROW );
42  m_xControl.set( xControlProvider->createControl( xControlShape, xModel ) );
43 }
44 
45 uno::Reference< uno::XInterface > SAL_CALL
47 {
48  return uno::Reference< uno::XInterface >( m_xControl, uno::UNO_QUERY_THROW );
49 }
50 
51 sal_Bool SAL_CALL
53 {
54  return m_xControl->getEnabled();
55 }
56 
57 void SAL_CALL
59 {
60  m_xControl->setEnabled( _enabled );
61 }
62 
63 sal_Bool SAL_CALL
65 {
66  return m_xControl->getVisible();
67 }
68 
69 void SAL_CALL
71 {
72  m_xControl->setVisible( _visible );
73 }
74 
75 double SAL_CALL
77 {
78  return m_xControl->getLeft();
79 }
80 
81 void SAL_CALL
82 ScVbaOLEObject::setLeft( double _left )
83 {
84  m_xControl->setLeft( _left );
85 
86 }
87 
88 double SAL_CALL
90 {
91  return m_xControl->getTop();
92 }
93 
94 void SAL_CALL
95 ScVbaOLEObject::setTop( double _top )
96 {
97  m_xControl->setTop( _top );
98 }
99 
100 double SAL_CALL
102 {
103  return m_xControl->getHeight();
104 }
105 
106 void SAL_CALL
107 ScVbaOLEObject::setHeight( double _height )
108 {
109  m_xControl->setHeight( _height );
110 }
111 
112 double SAL_CALL
114 {
115  return m_xControl->getWidth();
116 }
117 
118 void SAL_CALL
119 ScVbaOLEObject::setWidth( double _width )
120 {
121  m_xControl->setWidth( _width );
122 }
123 
124 OUString SAL_CALL ScVbaOLEObject::getLinkedCell()
125 {
126  return m_xControl->getControlSource();
127 }
128 
129 void SAL_CALL ScVbaOLEObject::setLinkedCell( const OUString& _linkedcell )
130 {
131  m_xControl->setControlSource( _linkedcell );
132 }
133 
134 OUString
136 {
137  return "ScVbaOLEObject";
138 }
139 
140 uno::Sequence< OUString >
142 {
143  static uno::Sequence< OUString > const aServiceNames
144  {
145  "ooo.vba.excel.OLEObject"
146  };
147  return aServiceNames;
148 }
149 
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() override
Sequence< OUString > aServiceNames
virtual double SAL_CALL getHeight() override
virtual OUString SAL_CALL getLinkedCell() override
ScVbaOLEObject(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, css::uno::Reference< css::drawing::XControlShape > const &xControlShape)
virtual sal_Bool SAL_CALL getEnabled() override
virtual double SAL_CALL getTop() override
virtual void SAL_CALL setVisible(sal_Bool _visible) override
unsigned char sal_Bool
virtual void SAL_CALL setHeight(double _height) override
virtual sal_Bool SAL_CALL getVisible() override
virtual OUString getServiceImplName() override
virtual double SAL_CALL getWidth() override
virtual void SAL_CALL setLinkedCell(const OUString &_linkedcell) override
virtual void SAL_CALL setEnabled(sal_Bool _enabled) override
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual void SAL_CALL setLeft(double _left) override
css::uno::Reference< ov::msforms::XControl > m_xControl
virtual void SAL_CALL setTop(double _top) override
virtual css::uno::Sequence< OUString > getServiceNames() override
Reference< XModel > xModel
virtual double SAL_CALL getLeft() override
virtual void SAL_CALL setWidth(double _width) override