LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / vbahelper / source / msforms / vbatextbox.cxx
blob59f736d48dcc5bc62251ce4358062ae64b4ae606
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
26 using namespace com::sun::star;
27 using namespace ooo::vba;
29 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, std::unique_ptr<AbstractGeometryAttributes> pGeomHelper, bool bDialog )
30 : TextBoxImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) ), mbDialog( bDialog )
34 // Attributes
35 uno::Any SAL_CALL
36 ScVbaTextBox::getValue()
38 return uno::makeAny( getText() );
41 void SAL_CALL
42 ScVbaTextBox::setValue( const uno::Any& _value )
44 // booleans are converted to uppercase strings
45 OUString sVal = extractStringFromAny( _value, true );
46 setText( sVal );
49 //getString() will cause some info lose.
50 OUString SAL_CALL
51 ScVbaTextBox::getText()
53 uno::Any aValue = m_xProps->getPropertyValue( "Text" );
54 OUString sString;
55 aValue >>= sString;
56 return sString;
59 void SAL_CALL
60 ScVbaTextBox::setText( const OUString& _text )
62 OUString oldText( getText() );
63 if ( !mbDialog )
65 uno::Reference< text::XTextRange > xTextRange( m_xProps, uno::UNO_QUERY_THROW );
66 xTextRange->setString( _text );
68 else
69 m_xProps->setPropertyValue( "Text" , uno::makeAny( _text ) );
70 if ( oldText != _text )
71 fireChangeEvent();
74 sal_Int32 SAL_CALL
75 ScVbaTextBox::getMaxLength()
77 uno::Any aValue = m_xProps->getPropertyValue( "MaxTextLen" );
78 sal_Int16 nMaxLength = 0;
79 aValue >>= nMaxLength;
80 return static_cast<sal_Int32>(nMaxLength);
83 void SAL_CALL
84 ScVbaTextBox::setMaxLength( sal_Int32 _maxlength )
86 sal_Int16 nTmp( _maxlength );
87 uno::Any aValue( nTmp );
88 m_xProps->setPropertyValue( "MaxTextLen" , aValue);
91 sal_Bool SAL_CALL
92 ScVbaTextBox::getMultiline()
94 uno::Any aValue = m_xProps->getPropertyValue( "MultiLine" );
95 bool bRet = false;
96 aValue >>= bRet;
97 return bRet;
100 void SAL_CALL
101 ScVbaTextBox::setMultiline( sal_Bool _multiline )
103 uno::Any aValue( _multiline );
104 m_xProps->setPropertyValue( "MultiLine" , aValue);
107 sal_Int32 SAL_CALL ScVbaTextBox::getSpecialEffect()
109 return msforms::fmSpecialEffect::fmSpecialEffectSunken;
112 void SAL_CALL ScVbaTextBox::setSpecialEffect( sal_Int32 /*nSpecialEffect*/ )
114 // #STUB
117 sal_Int32 SAL_CALL ScVbaTextBox::getBorderStyle()
119 return msforms::fmBorderStyle::fmBorderStyleNone;
122 void SAL_CALL ScVbaTextBox::setBorderStyle( sal_Int32 /*nBorderStyle*/ )
124 // #STUB
127 sal_Int32 SAL_CALL ScVbaTextBox::getTextLength()
129 return getText().getLength();
132 uno::Reference< msforms::XNewFont > SAL_CALL ScVbaTextBox::getFont()
134 return new VbaNewFont( m_xProps );
137 sal_Int32 SAL_CALL ScVbaTextBox::getBackColor()
139 return ScVbaControl::getBackColor();
142 void SAL_CALL ScVbaTextBox::setBackColor( sal_Int32 nBackColor )
144 ScVbaControl::setBackColor( nBackColor );
147 sal_Bool SAL_CALL ScVbaTextBox::getAutoSize()
149 return ScVbaControl::getAutoSize();
152 void SAL_CALL ScVbaTextBox::setAutoSize( sal_Bool bAutoSize )
154 ScVbaControl::setAutoSize( bAutoSize );
157 sal_Bool SAL_CALL ScVbaTextBox::getLocked()
159 return ScVbaControl::getLocked();
162 void SAL_CALL ScVbaTextBox::setLocked( sal_Bool bLocked )
164 ScVbaControl::setLocked( bLocked );
167 OUString
168 ScVbaTextBox::getServiceImplName()
170 return "ScVbaTextBox";
173 uno::Sequence< OUString >
174 ScVbaTextBox::getServiceNames()
176 static uno::Sequence< OUString > const aServiceNames
178 "ooo.vba.msforms.TextBox"
180 return aServiceNames;
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */