1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #include "vbaframe.hxx"
25 #include "vbanewfont.hxx"
26 #include "vbacontrols.hxx"
27 #include <ooo/vba/msforms/fmBorderStyle.hpp>
28 #include <ooo/vba/msforms/fmSpecialEffect.hpp>
29
30 using namespace com::sun::star;
31 using namespace ooo::vba;
32
33
34 const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
35
ScVbaFrame(const uno::Reference<XHelperInterface> & xParent,const uno::Reference<uno::XComponentContext> & xContext,const uno::Reference<uno::XInterface> & xControl,const uno::Reference<frame::XModel> & xModel,ov::AbstractGeometryAttributes * pGeomHelper,const css::uno::Reference<css::awt::XControl> & xDialog)36 ScVbaFrame::ScVbaFrame(
37 const uno::Reference< XHelperInterface >& xParent,
38 const uno::Reference< uno::XComponentContext >& xContext,
39 const uno::Reference< uno::XInterface >& xControl,
40 const uno::Reference< frame::XModel >& xModel,
41 ov::AbstractGeometryAttributes* pGeomHelper,
42 const css::uno::Reference< css::awt::XControl >& xDialog ) :
43 FrameImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ),
44 mxDialog( xDialog )
45 {
46 }
47
48 // XFrame attributes
49
getCaption()50 rtl::OUString SAL_CALL ScVbaFrame::getCaption() throw (css::uno::RuntimeException)
51 {
52 rtl::OUString Label;
53 m_xProps->getPropertyValue( LABEL ) >>= Label;
54 return Label;
55 }
56
setCaption(const rtl::OUString & _caption)57 void SAL_CALL ScVbaFrame::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
58 {
59 m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
60 }
61
getSpecialEffect()62 sal_Int32 SAL_CALL ScVbaFrame::getSpecialEffect() throw (uno::RuntimeException)
63 {
64 return msforms::fmSpecialEffect::fmSpecialEffectEtched;
65 }
66
setSpecialEffect(sal_Int32)67 void SAL_CALL ScVbaFrame::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException)
68 {
69 }
70
getBorderStyle()71 sal_Int32 SAL_CALL ScVbaFrame::getBorderStyle() throw (uno::RuntimeException)
72 {
73 return msforms::fmBorderStyle::fmBorderStyleNone;
74 }
75
setBorderStyle(sal_Int32)76 void SAL_CALL ScVbaFrame::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException)
77 {
78 }
79
getFont()80 uno::Reference< msforms::XNewFont > SAL_CALL ScVbaFrame::getFont() throw (uno::RuntimeException)
81 {
82 return new VbaNewFont( this, mxContext, m_xProps );
83 }
84
85 // XFrame methods
86
Controls(const uno::Any & rIndex)87 uno::Any SAL_CALL ScVbaFrame::Controls( const uno::Any& rIndex ) throw (uno::RuntimeException)
88 {
89 // horizontal anchor of frame children is inside border line (add one unit to compensate border line width)
90 double fOffsetX = mpGeometryHelper->getOffsetX() + getLeft() + 1.0;
91 // vertical anchor of frame children is inside border line (add half of text height and one unit to compensate border line width)
92 double fOffsetY = mpGeometryHelper->getOffsetY() + getTop() + (getFont()->getSize() / 2.0) + 1.0;
93
94 uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, mxDialog, m_xModel, fOffsetX, fOffsetY ) );
95 if( rIndex.hasValue() )
96 return uno::Any( xControls->Item( rIndex, uno::Any() ) );
97 return uno::Any( xControls );
98 }
99
100 // XHelperInterface
101
102 VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaFrame, "ooo.vba.msforms.Frame" )
103