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 "vbatextbox.hxx"
21 : #include "vbanewfont.hxx"
22 : #include <com/sun/star/text/XTextRange.hpp>
23 : #include <ooo/vba/msforms/fmBorderStyle.hpp>
24 : #include <ooo/vba/msforms/fmSpecialEffect.hpp>
25 :
26 : using namespace com::sun::star;
27 : using namespace ooo::vba;
28 :
29 0 : ScVbaTextBox::ScVbaTextBox( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper, bool bDialog ) : TextBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper ), mbDialog( bDialog )
30 : {
31 0 : }
32 :
33 : // Attributes
34 : uno::Any SAL_CALL
35 0 : ScVbaTextBox::getValue() throw (css::uno::RuntimeException)
36 : {
37 0 : return uno::makeAny( getText() );
38 : }
39 :
40 : void SAL_CALL
41 0 : ScVbaTextBox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException)
42 : {
43 : // booleans are converted to uppercase strings
44 0 : OUString sVal = extractStringFromAny( _value, true );
45 0 : setText( sVal );
46 0 : }
47 :
48 : //getString() will cause some imfo lose.
49 : OUString SAL_CALL
50 0 : ScVbaTextBox::getText() throw (css::uno::RuntimeException)
51 : {
52 0 : uno::Any aValue;
53 0 : aValue = m_xProps->getPropertyValue( "Text" );
54 0 : OUString sString;
55 0 : aValue >>= sString;
56 0 : return sString;
57 : }
58 :
59 : void SAL_CALL
60 0 : ScVbaTextBox::setText( const OUString& _text ) throw (css::uno::RuntimeException)
61 : {
62 0 : if ( !mbDialog )
63 : {
64 0 : uno::Reference< text::XTextRange > xTextRange( m_xProps, uno::UNO_QUERY_THROW );
65 0 : xTextRange->setString( _text );
66 : }
67 : else
68 0 : m_xProps->setPropertyValue( "Text" , uno::makeAny( _text ) );
69 0 : }
70 :
71 : sal_Int32 SAL_CALL
72 0 : ScVbaTextBox::getMaxLength() throw (css::uno::RuntimeException)
73 : {
74 0 : uno::Any aValue;
75 0 : aValue = m_xProps->getPropertyValue( "MaxTextLen" );
76 0 : sal_Int32 nMaxLength = 0;
77 0 : aValue >>= nMaxLength;
78 0 : return nMaxLength;
79 : }
80 :
81 : void SAL_CALL
82 0 : ScVbaTextBox::setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException)
83 : {
84 0 : uno::Any aValue( _maxlength );
85 0 : m_xProps->setPropertyValue( "MaxTextLen" , aValue);
86 0 : }
87 :
88 : sal_Bool SAL_CALL
89 0 : ScVbaTextBox::getMultiline() throw (css::uno::RuntimeException)
90 : {
91 0 : uno::Any aValue;
92 0 : aValue = m_xProps->getPropertyValue( "MultiLine" );
93 0 : sal_Bool bRet = false;
94 0 : aValue >>= bRet;
95 0 : return bRet;
96 : }
97 :
98 : void SAL_CALL
99 0 : ScVbaTextBox::setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeException)
100 : {
101 0 : uno::Any aValue( _multiline );
102 0 : m_xProps->setPropertyValue( "MultiLine" , aValue);
103 0 : }
104 :
105 0 : sal_Int32 SAL_CALL ScVbaTextBox::getSpecialEffect() throw (uno::RuntimeException)
106 : {
107 0 : return msforms::fmSpecialEffect::fmSpecialEffectSunken;
108 : }
109 :
110 0 : void SAL_CALL ScVbaTextBox::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException)
111 : {
112 : // #STUB
113 0 : }
114 :
115 0 : sal_Int32 SAL_CALL ScVbaTextBox::getBorderStyle() throw (uno::RuntimeException)
116 : {
117 0 : return msforms::fmBorderStyle::fmBorderStyleNone;
118 : }
119 :
120 0 : void SAL_CALL ScVbaTextBox::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException)
121 : {
122 : // #STUB
123 0 : }
124 :
125 0 : sal_Int32 SAL_CALL ScVbaTextBox::getTextLength() throw (uno::RuntimeException)
126 : {
127 0 : return getText().getLength();
128 : }
129 :
130 0 : uno::Reference< msforms::XNewFont > SAL_CALL ScVbaTextBox::getFont() throw (uno::RuntimeException)
131 : {
132 0 : return new VbaNewFont( this, mxContext, m_xProps );
133 : }
134 :
135 0 : sal_Int32 SAL_CALL ScVbaTextBox::getBackColor() throw (uno::RuntimeException)
136 : {
137 0 : return ScVbaControl::getBackColor();
138 : }
139 :
140 0 : void SAL_CALL ScVbaTextBox::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
141 : {
142 0 : ScVbaControl::setBackColor( nBackColor );
143 0 : }
144 :
145 0 : sal_Bool SAL_CALL ScVbaTextBox::getAutoSize() throw (uno::RuntimeException)
146 : {
147 0 : return ScVbaControl::getAutoSize();
148 : }
149 :
150 0 : void SAL_CALL ScVbaTextBox::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
151 : {
152 0 : ScVbaControl::setAutoSize( bAutoSize );
153 0 : }
154 :
155 0 : sal_Bool SAL_CALL ScVbaTextBox::getLocked() throw (uno::RuntimeException)
156 : {
157 0 : return ScVbaControl::getLocked();
158 : }
159 :
160 0 : void SAL_CALL ScVbaTextBox::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException)
161 : {
162 0 : ScVbaControl::setLocked( bLocked );
163 0 : }
164 :
165 : OUString
166 0 : ScVbaTextBox::getServiceImplName()
167 : {
168 0 : return OUString( "ScVbaTextBox" );
169 : }
170 :
171 : uno::Sequence< OUString >
172 0 : ScVbaTextBox::getServiceNames()
173 : {
174 0 : static uno::Sequence< OUString > aServiceNames;
175 0 : if ( aServiceNames.getLength() == 0 )
176 : {
177 0 : aServiceNames.realloc( 1 );
178 0 : aServiceNames[ 0 ] = "ooo.vba.msforms.TextBox";
179 : }
180 0 : return aServiceNames;
181 : }
182 :
183 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|