Branch data 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 "vbahelper/vbawindowbase.hxx"
21 : : #include "vbahelper/helperdecl.hxx"
22 : : #include <com/sun/star/awt/PosSize.hpp>
23 : :
24 : : using namespace ::com::sun::star;
25 : : using namespace ::ooo::vba;
26 : :
27 : 0 : VbaWindowBase::VbaWindowBase(
28 : : const uno::Reference< XHelperInterface >& xParent,
29 : : const uno::Reference< uno::XComponentContext >& xContext,
30 : : const css::uno::Reference< css::frame::XModel >& xModel,
31 : : const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException) :
32 : : WindowBaseImpl_BASE( xParent, xContext ),
33 [ # # ][ # # ]: 0 : m_xModel( xModel, uno::UNO_SET_THROW )
[ # # ]
34 : : {
35 [ # # ]: 0 : construct( xController );
36 : 0 : }
37 : :
38 : 0 : VbaWindowBase::VbaWindowBase( uno::Sequence< uno::Any > const & args,
39 : : uno::Reference< uno::XComponentContext > const & xContext ) throw (uno::RuntimeException) :
40 : : WindowBaseImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0, false ), xContext ),
41 [ # # ][ # # ]: 0 : m_xModel( getXSomethingFromArgs< frame::XModel >( args, 1, false ) )
[ # # ][ # # ]
42 : : {
43 [ # # ][ # # ]: 0 : construct( getXSomethingFromArgs< frame::XController >( args, 2 ) );
44 : 0 : }
45 : :
46 : : sal_Bool SAL_CALL
47 : 0 : VbaWindowBase::getVisible() throw (uno::RuntimeException)
48 : : {
49 [ # # ][ # # ]: 0 : return getWindow2()->isVisible();
50 : : }
51 : :
52 : : void SAL_CALL
53 : 0 : VbaWindowBase::setVisible( sal_Bool _visible ) throw (uno::RuntimeException)
54 : : {
55 [ # # ][ # # ]: 0 : getWindow2()->setVisible( _visible );
56 : 0 : }
57 : :
58 : 0 : void setPosSize( const uno::Reference< awt::XWindow >& xWindow, sal_Int32 nValue, sal_Int16 nFlag )
59 : : {
60 [ # # ][ # # ]: 0 : css::awt::Rectangle aRect = xWindow->getPosSize();
61 [ # # # # : 0 : switch( nFlag )
# ]
62 : : {
63 : : case css::awt::PosSize::X:
64 [ # # ][ # # ]: 0 : xWindow->setPosSize( nValue, aRect.Y, 0, 0, css::awt::PosSize::X );
65 : 0 : break;
66 : : case css::awt::PosSize::Y:
67 [ # # ][ # # ]: 0 : xWindow->setPosSize( aRect.X, nValue, 0, 0, css::awt::PosSize::Y );
68 : 0 : break;
69 : : case css::awt::PosSize::WIDTH:
70 [ # # ][ # # ]: 0 : xWindow->setPosSize( 0, 0, nValue, aRect.Height, css::awt::PosSize::WIDTH );
71 : 0 : break;
72 : : case css::awt::PosSize::HEIGHT:
73 [ # # ][ # # ]: 0 : xWindow->setPosSize( 0, 0, aRect.Width, nValue, css::awt::PosSize::HEIGHT );
74 : 0 : break;
75 : : default:
76 : 0 : break;
77 : : }
78 : 0 : }
79 : :
80 : : sal_Int32 SAL_CALL
81 : 0 : VbaWindowBase::getHeight() throw (uno::RuntimeException)
82 : : {
83 [ # # ][ # # ]: 0 : return getWindow()->getPosSize().Height;
84 : : }
85 : :
86 : : void SAL_CALL
87 : 0 : VbaWindowBase::setHeight( sal_Int32 _height ) throw (uno::RuntimeException)
88 : : {
89 [ # # ]: 0 : setPosSize( getWindow(), _height, css::awt::PosSize::HEIGHT );
90 : 0 : }
91 : :
92 : : sal_Int32 SAL_CALL
93 : 0 : VbaWindowBase::getLeft() throw (uno::RuntimeException)
94 : : {
95 [ # # ][ # # ]: 0 : return getWindow()->getPosSize().X;
96 : : }
97 : :
98 : : void SAL_CALL
99 : 0 : VbaWindowBase::setLeft( sal_Int32 _left ) throw (uno::RuntimeException)
100 : : {
101 [ # # ]: 0 : setPosSize( getWindow(), _left, css::awt::PosSize::X );
102 : 0 : }
103 : :
104 : : sal_Int32 SAL_CALL
105 : 0 : VbaWindowBase::getTop() throw (uno::RuntimeException)
106 : : {
107 [ # # ][ # # ]: 0 : return getWindow()->getPosSize().Y;
108 : : }
109 : :
110 : : void SAL_CALL
111 : 0 : VbaWindowBase::setTop( sal_Int32 _top ) throw (uno::RuntimeException)
112 : : {
113 [ # # ]: 0 : setPosSize( getWindow(), _top, css::awt::PosSize::Y );
114 : 0 : }
115 : :
116 : : sal_Int32 SAL_CALL
117 : 0 : VbaWindowBase::getWidth() throw (uno::RuntimeException)
118 : : {
119 [ # # ][ # # ]: 0 : return getWindow()->getPosSize().Width;
120 : : }
121 : :
122 : : void SAL_CALL
123 : 0 : VbaWindowBase::setWidth( sal_Int32 _width ) throw (uno::RuntimeException)
124 : : {
125 [ # # ]: 0 : setPosSize( getWindow(), _width, css::awt::PosSize::WIDTH );
126 : 0 : }
127 : :
128 : : rtl::OUString
129 : 0 : VbaWindowBase::getServiceImplName()
130 : : {
131 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VbaWindowBase"));
132 : : }
133 : :
134 : : uno::Sequence< rtl::OUString >
135 : 0 : VbaWindowBase::getServiceNames()
136 : : {
137 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
138 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
139 : : {
140 : 0 : aServiceNames.realloc( 1 );
141 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.VbaWindowBase" ) );
142 : : }
143 : 0 : return aServiceNames;
144 : : }
145 : :
146 : 0 : uno::Reference< frame::XController > VbaWindowBase::getController() throw (css::uno::RuntimeException)
147 : : {
148 [ # # ]: 0 : return uno::Reference< frame::XController >( m_xController, uno::UNO_SET_THROW );
149 : : }
150 : :
151 : 0 : uno::Reference< awt::XWindow > VbaWindowBase::getWindow() throw (uno::RuntimeException)
152 : : {
153 [ # # ]: 0 : return uno::Reference< awt::XWindow >( m_xWindow, uno::UNO_SET_THROW );
154 : : }
155 : :
156 : 0 : uno::Reference< awt::XWindow2 > VbaWindowBase::getWindow2() throw (uno::RuntimeException)
157 : : {
158 [ # # ]: 0 : return uno::Reference< awt::XWindow2 >( getWindow(), uno::UNO_QUERY_THROW );
159 : : }
160 : :
161 : 0 : void VbaWindowBase::construct( const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException)
162 : : {
163 [ # # ][ # # ]: 0 : if( !xController.is() ) throw uno::RuntimeException();
164 [ # # ][ # # ]: 0 : uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW );
[ # # ]
165 [ # # ][ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
[ # # ]
166 [ # # ]: 0 : m_xController = xController;
167 [ # # ]: 0 : m_xWindow = xWindow;
168 : 0 : }
169 : :
170 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|