Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/awt/XControlModel.hpp>
30 : : #include <com/sun/star/awt/XWindow2.hpp>
31 : : #include <com/sun/star/view/XControlAccess.hpp>
32 : : #include <com/sun/star/container/XChild.hpp>
33 : : #include <com/sun/star/drawing/XShape.hpp>
34 : : #include <ooo/vba/XControlProvider.hpp>
35 : :
36 : : #include "vbaoleobject.hxx"
37 : :
38 : : using namespace com::sun::star;
39 : : using namespace ooo::vba;
40 : :
41 : 0 : ScVbaOLEObject::ScVbaOLEObject( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext,
42 : : css::uno::Reference< css::drawing::XControlShape > xControlShape )
43 : 0 : : OLEObjectImpl_BASE( xParent, xContext ), m_xControlShape( xControlShape )
44 : : {
45 : : //init m_xWindowPeer
46 [ # # ][ # # ]: 0 : uno::Reference< awt::XControlModel > xControlModel( xControlShape->getControl(), css::uno::UNO_QUERY_THROW );
[ # # ]
47 [ # # ]: 0 : uno::Reference< container::XChild > xChild( xControlModel, uno::UNO_QUERY_THROW );
48 [ # # ][ # # ]: 0 : xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW );
[ # # ]
49 [ # # ][ # # ]: 0 : xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW );
[ # # ]
50 [ # # ][ # # ]: 0 : css::uno::Reference< css::frame::XModel > xModel( xChild->getParent(), uno::UNO_QUERY_THROW );
[ # # ]
51 [ # # ][ # # ]: 0 : uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
[ # # ]
52 [ # # ][ # # ]: 0 : uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), mxContext ), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
53 [ # # ][ # # ]: 0 : m_xControl.set( xControlProvider->createControl( xControlShape, xModel ) );
[ # # ]
54 : 0 : }
55 : :
56 : : uno::Reference< uno::XInterface > SAL_CALL
57 : 0 : ScVbaOLEObject::getObject() throw (uno::RuntimeException)
58 : : {
59 : 0 : return uno::Reference< uno::XInterface >( m_xControl, uno::UNO_QUERY_THROW );
60 : : }
61 : :
62 : : sal_Bool SAL_CALL
63 : 0 : ScVbaOLEObject::getEnabled() throw (uno::RuntimeException)
64 : : {
65 : 0 : return m_xControl->getEnabled();
66 : : }
67 : :
68 : : void SAL_CALL
69 : 0 : ScVbaOLEObject::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException)
70 : : {
71 : 0 : m_xControl->setEnabled( _enabled );
72 : 0 : }
73 : :
74 : : sal_Bool SAL_CALL
75 : 0 : ScVbaOLEObject::getVisible() throw (uno::RuntimeException)
76 : : {
77 : : OSL_TRACE("OleObject %s returning visible %s", rtl::OUStringToOString( m_xControl->getName(), RTL_TEXTENCODING_UTF8 ).getStr(), m_xControl->getVisible() ? "true" : "false" );
78 : 0 : return m_xControl->getVisible();
79 : : }
80 : :
81 : : void SAL_CALL
82 : 0 : ScVbaOLEObject::setVisible( sal_Bool _visible ) throw (uno::RuntimeException)
83 : : {
84 : : OSL_TRACE("OleObject %s set visible %s", rtl::OUStringToOString( m_xControl->getName(), RTL_TEXTENCODING_UTF8 ).getStr(), _visible ? "true" : "false" );
85 : 0 : m_xControl->setVisible( _visible );
86 : 0 : }
87 : :
88 : : double SAL_CALL
89 : 0 : ScVbaOLEObject::getLeft() throw (uno::RuntimeException)
90 : : {
91 : 0 : return m_xControl->getLeft();
92 : : }
93 : :
94 : : void SAL_CALL
95 : 0 : ScVbaOLEObject::setLeft( double _left ) throw (uno::RuntimeException)
96 : : {
97 : 0 : m_xControl->setLeft( _left );
98 : :
99 : 0 : }
100 : :
101 : : double SAL_CALL
102 : 0 : ScVbaOLEObject::getTop() throw (uno::RuntimeException)
103 : : {
104 : 0 : return m_xControl->getTop();
105 : : }
106 : :
107 : : void SAL_CALL
108 : 0 : ScVbaOLEObject::setTop( double _top ) throw (uno::RuntimeException)
109 : : {
110 : 0 : m_xControl->setTop( _top );
111 : 0 : }
112 : :
113 : : double SAL_CALL
114 : 0 : ScVbaOLEObject::getHeight() throw (uno::RuntimeException)
115 : : {
116 : 0 : return m_xControl->getHeight();
117 : : }
118 : :
119 : : void SAL_CALL
120 : 0 : ScVbaOLEObject::setHeight( double _height ) throw (uno::RuntimeException)
121 : : {
122 : 0 : m_xControl->setHeight( _height );
123 : 0 : }
124 : :
125 : : double SAL_CALL
126 : 0 : ScVbaOLEObject::getWidth() throw (uno::RuntimeException)
127 : : {
128 : 0 : return m_xControl->getWidth();
129 : : }
130 : :
131 : : void SAL_CALL
132 : 0 : ScVbaOLEObject::setWidth( double _width ) throw (uno::RuntimeException)
133 : : {
134 : 0 : m_xControl->setWidth( _width );
135 : 0 : }
136 : :
137 : : rtl::OUString
138 : 0 : ScVbaOLEObject::getServiceImplName()
139 : : {
140 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaOLEObject"));
141 : : }
142 : :
143 : : uno::Sequence< rtl::OUString >
144 : 0 : ScVbaOLEObject::getServiceNames()
145 : : {
146 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
147 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
148 : : {
149 : 0 : aServiceNames.realloc( 1 );
150 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.OLEObject" ) );
151 : : }
152 : 0 : return aServiceNames;
153 : : }
154 : :
155 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|