1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
, AbstractGeometryAttributes
* pGeomHelper
, bool bDialog
) : TextBoxImpl_BASE( xParent
, xContext
, xControl
, xModel
, pGeomHelper
), mbDialog( bDialog
)
35 ScVbaTextBox::getValue() throw (css::uno::RuntimeException
, std::exception
)
37 return uno::makeAny( getText() );
41 ScVbaTextBox::setValue( const uno::Any
& _value
) throw (css::uno::RuntimeException
, std::exception
)
43 // booleans are converted to uppercase strings
44 OUString sVal
= extractStringFromAny( _value
, true );
48 //getString() will cause some imfo lose.
50 ScVbaTextBox::getText() throw (css::uno::RuntimeException
, std::exception
)
53 aValue
= m_xProps
->getPropertyValue( "Text" );
60 ScVbaTextBox::setText( const OUString
& _text
) throw (css::uno::RuntimeException
, std::exception
)
62 OUString
oldText( getText() );
65 uno::Reference
< text::XTextRange
> xTextRange( m_xProps
, uno::UNO_QUERY_THROW
);
66 xTextRange
->setString( _text
);
69 m_xProps
->setPropertyValue( "Text" , uno::makeAny( _text
) );
70 if ( oldText
!= _text
)
75 ScVbaTextBox::getMaxLength() throw (css::uno::RuntimeException
, std::exception
)
78 aValue
= m_xProps
->getPropertyValue( "MaxTextLen" );
79 sal_Int16 nMaxLength
= 0;
80 aValue
>>= nMaxLength
;
81 return (sal_Int32
)nMaxLength
;
85 ScVbaTextBox::setMaxLength( sal_Int32 _maxlength
) throw (css::uno::RuntimeException
, std::exception
)
87 sal_Int16
nTmp( _maxlength
);
88 uno::Any
aValue( nTmp
);
89 m_xProps
->setPropertyValue( "MaxTextLen" , aValue
);
93 ScVbaTextBox::getMultiline() throw (css::uno::RuntimeException
, std::exception
)
96 aValue
= m_xProps
->getPropertyValue( "MultiLine" );
103 ScVbaTextBox::setMultiline( sal_Bool _multiline
) throw (css::uno::RuntimeException
, std::exception
)
105 uno::Any
aValue( _multiline
);
106 m_xProps
->setPropertyValue( "MultiLine" , aValue
);
109 sal_Int32 SAL_CALL
ScVbaTextBox::getSpecialEffect() throw (uno::RuntimeException
, std::exception
)
111 return msforms::fmSpecialEffect::fmSpecialEffectSunken
;
114 void SAL_CALL
ScVbaTextBox::setSpecialEffect( sal_Int32
/*nSpecialEffect*/ ) throw (uno::RuntimeException
, std::exception
)
119 sal_Int32 SAL_CALL
ScVbaTextBox::getBorderStyle() throw (uno::RuntimeException
, std::exception
)
121 return msforms::fmBorderStyle::fmBorderStyleNone
;
124 void SAL_CALL
ScVbaTextBox::setBorderStyle( sal_Int32
/*nBorderStyle*/ ) throw (uno::RuntimeException
, std::exception
)
129 sal_Int32 SAL_CALL
ScVbaTextBox::getTextLength() throw (uno::RuntimeException
, std::exception
)
131 return getText().getLength();
134 uno::Reference
< msforms::XNewFont
> SAL_CALL
ScVbaTextBox::getFont() throw (uno::RuntimeException
, std::exception
)
136 return new VbaNewFont( m_xProps
);
139 sal_Int32 SAL_CALL
ScVbaTextBox::getBackColor() throw (uno::RuntimeException
, std::exception
)
141 return ScVbaControl::getBackColor();
144 void SAL_CALL
ScVbaTextBox::setBackColor( sal_Int32 nBackColor
) throw (uno::RuntimeException
, std::exception
)
146 ScVbaControl::setBackColor( nBackColor
);
149 sal_Bool SAL_CALL
ScVbaTextBox::getAutoSize() throw (uno::RuntimeException
, std::exception
)
151 return ScVbaControl::getAutoSize();
154 void SAL_CALL
ScVbaTextBox::setAutoSize( sal_Bool bAutoSize
) throw (uno::RuntimeException
, std::exception
)
156 ScVbaControl::setAutoSize( bAutoSize
);
159 sal_Bool SAL_CALL
ScVbaTextBox::getLocked() throw (uno::RuntimeException
, std::exception
)
161 return ScVbaControl::getLocked();
164 void SAL_CALL
ScVbaTextBox::setLocked( sal_Bool bLocked
) throw (uno::RuntimeException
, std::exception
)
166 ScVbaControl::setLocked( bLocked
);
170 ScVbaTextBox::getServiceImplName()
172 return OUString( "ScVbaTextBox" );
175 uno::Sequence
< OUString
>
176 ScVbaTextBox::getServiceNames()
178 static uno::Sequence
< OUString
> aServiceNames
;
179 if ( aServiceNames
.getLength() == 0 )
181 aServiceNames
.realloc( 1 );
182 aServiceNames
[ 0 ] = "ooo.vba.msforms.TextBox";
184 return aServiceNames
;
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */