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 "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 : rtl::OUString sVal = extractStringFromAny( _value, true );
45 : 0 : setText( sVal );
46 : 0 : }
47 : :
48 : : //getString() will cause some imfo lose.
49 : : rtl::OUString SAL_CALL
50 : 0 : ScVbaTextBox::getText() throw (css::uno::RuntimeException)
51 : : {
52 : 0 : uno::Any aValue;
53 : 0 : aValue = m_xProps->getPropertyValue
54 : 0 : (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ) );
55 : 0 : rtl::OUString sString;
56 : 0 : aValue >>= sString;
57 : 0 : return sString;
58 : : }
59 : :
60 : : void SAL_CALL
61 : 0 : ScVbaTextBox::setText( const rtl::OUString& _text ) throw (css::uno::RuntimeException)
62 : : {
63 : 0 : rtl::OUString sOldText = getText();
64 : :
65 : 0 : if ( !mbDialog )
66 : : {
67 : 0 : uno::Reference< text::XTextRange > xTextRange( m_xProps, uno::UNO_QUERY_THROW );
68 : 0 : xTextRange->setString( _text );
69 : : }
70 : : else
71 : 0 : m_xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ), uno::makeAny( _text ) );
72 : :
73 : 0 : if ( _text != sOldText )
74 : : {
75 : 0 : fireChangeEvent();
76 : 0 : }
77 : 0 : }
78 : :
79 : : sal_Int32 SAL_CALL
80 : 0 : ScVbaTextBox::getMaxLength() throw (css::uno::RuntimeException)
81 : : {
82 : 0 : uno::Any aValue;
83 : 0 : aValue = m_xProps->getPropertyValue
84 : 0 : (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxTextLen" ) ) );
85 : 0 : sal_Int32 nMaxLength = 0;
86 : 0 : aValue >>= nMaxLength;
87 : 0 : return nMaxLength;
88 : : }
89 : :
90 : : void SAL_CALL
91 : 0 : ScVbaTextBox::setMaxLength( sal_Int32 _maxlength ) throw (css::uno::RuntimeException)
92 : : {
93 : 0 : sal_Int16 _maxlength16 = static_cast<sal_Int16> (_maxlength);
94 : 0 : uno::Any aValue( _maxlength16 );
95 : 0 : m_xProps->setPropertyValue
96 : 0 : (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxTextLen" ) ), aValue);
97 : 0 : }
98 : :
99 : : sal_Bool SAL_CALL
100 : 0 : ScVbaTextBox::getMultiline() throw (css::uno::RuntimeException)
101 : : {
102 : 0 : uno::Any aValue;
103 : 0 : aValue = m_xProps->getPropertyValue
104 : 0 : (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ) );
105 : 0 : sal_Bool bRet = false;
106 : 0 : aValue >>= bRet;
107 : 0 : return bRet;
108 : : }
109 : :
110 : : void SAL_CALL
111 : 0 : ScVbaTextBox::setMultiline( sal_Bool _multiline ) throw (css::uno::RuntimeException)
112 : : {
113 : 0 : uno::Any aValue( _multiline );
114 : 0 : m_xProps->setPropertyValue
115 : 0 : (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), aValue);
116 : 0 : }
117 : :
118 : 0 : sal_Int32 SAL_CALL ScVbaTextBox::getSpecialEffect() throw (uno::RuntimeException)
119 : : {
120 : 0 : return msforms::fmSpecialEffect::fmSpecialEffectSunken;
121 : : }
122 : :
123 : 0 : void SAL_CALL ScVbaTextBox::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ ) throw (uno::RuntimeException)
124 : : {
125 : 0 : }
126 : :
127 : 0 : sal_Int32 SAL_CALL ScVbaTextBox::getBorderStyle() throw (uno::RuntimeException)
128 : : {
129 : 0 : return msforms::fmBorderStyle::fmBorderStyleNone;
130 : : }
131 : :
132 : 0 : void SAL_CALL ScVbaTextBox::setBorderStyle( sal_Int32 /*nBorderStyle*/ ) throw (uno::RuntimeException)
133 : : {
134 : 0 : }
135 : :
136 : 0 : sal_Int32 SAL_CALL ScVbaTextBox::getTextLength() throw (uno::RuntimeException)
137 : : {
138 : 0 : return getText().getLength();
139 : : }
140 : :
141 : 0 : uno::Reference< msforms::XNewFont > SAL_CALL ScVbaTextBox::getFont() throw (uno::RuntimeException)
142 : : {
143 : 0 : return new VbaNewFont( this, mxContext, m_xProps );
144 : : }
145 : :
146 : 0 : sal_Int32 SAL_CALL ScVbaTextBox::getBackColor() throw (uno::RuntimeException)
147 : : {
148 : 0 : return ScVbaControl::getBackColor();
149 : : }
150 : :
151 : 0 : void SAL_CALL ScVbaTextBox::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
152 : : {
153 : 0 : ScVbaControl::setBackColor( nBackColor );
154 : 0 : }
155 : :
156 : 0 : sal_Bool SAL_CALL ScVbaTextBox::getAutoSize() throw (uno::RuntimeException)
157 : : {
158 : 0 : return ScVbaControl::getAutoSize();
159 : : }
160 : :
161 : 0 : void SAL_CALL ScVbaTextBox::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
162 : : {
163 : 0 : ScVbaControl::setAutoSize( bAutoSize );
164 : 0 : }
165 : :
166 : 0 : sal_Bool SAL_CALL ScVbaTextBox::getLocked() throw (uno::RuntimeException)
167 : : {
168 : 0 : return ScVbaControl::getLocked();
169 : : }
170 : :
171 : 0 : void SAL_CALL ScVbaTextBox::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException)
172 : : {
173 : 0 : ScVbaControl::setLocked( bLocked );
174 : 0 : }
175 : :
176 : : rtl::OUString
177 : 0 : ScVbaTextBox::getServiceImplName()
178 : : {
179 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaTextBox"));
180 : : }
181 : :
182 : : uno::Sequence< rtl::OUString >
183 : 0 : ScVbaTextBox::getServiceNames()
184 : : {
185 : 0 : static uno::Sequence< rtl::OUString > aServiceNames;
186 : 0 : if ( aServiceNames.getLength() == 0 )
187 : : {
188 : 0 : aServiceNames.realloc( 1 );
189 : 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.TextBox" ) );
190 : : }
191 : 0 : return aServiceNames;
192 : : }
193 : :
194 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|