1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vbatextbox.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include <com/sun/star/text/XTextRange.hpp>
32 #include "vbatextbox.hxx"
35 using namespace com::sun::star
;
36 using namespace ooo::vba
;
40 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
)
46 ScVbaTextBox::getValue() throw (css::uno::RuntimeException
)
48 return uno::makeAny( getText() );
52 ScVbaTextBox::setValue( const uno::Any
& _value
) throw (css::uno::RuntimeException
)
54 rtl::OUString sVal
= getAnyAsString( _value
);
58 //getString() will cause some imfo lose.
59 rtl::OUString SAL_CALL
60 ScVbaTextBox::getText() throw (css::uno::RuntimeException
)
63 aValue
= m_xProps
->getPropertyValue
64 (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ) );
65 rtl::OUString sString
;
71 ScVbaTextBox::setText( const rtl::OUString
& _text
) throw (css::uno::RuntimeException
)
75 uno::Reference
< text::XTextRange
> xTextRange( m_xProps
, uno::UNO_QUERY_THROW
);
76 xTextRange
->setString( _text
);
79 m_xProps
->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Text") ), uno::makeAny( _text
) );
83 ScVbaTextBox::getMaxLength() throw (css::uno::RuntimeException
)
86 aValue
= m_xProps
->getPropertyValue
87 (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxTextLen" ) ) );
88 sal_Int32 nMaxLength
= 0;
89 aValue
>>= nMaxLength
;
94 ScVbaTextBox::setMaxLength( sal_Int32 _maxlength
) throw (css::uno::RuntimeException
)
96 sal_Int16 _maxlength16
= static_cast<sal_Int16
> (_maxlength
); //liuchen 2009-7-24, resolve the problem that MaxLength cannot be set correctly
97 uno::Any
aValue( _maxlength16
); //liuchen 2009-7-24, resolve the problem that MaxLength cannot be set correctly
98 m_xProps
->setPropertyValue
99 (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxTextLen" ) ), aValue
);
103 ScVbaTextBox::getMultiline() throw (css::uno::RuntimeException
)
106 aValue
= m_xProps
->getPropertyValue
107 (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ) );
108 sal_Bool bRet
= false;
114 ScVbaTextBox::setMultiline( sal_Bool _multiline
) throw (css::uno::RuntimeException
)
116 uno::Any
aValue( _multiline
);
117 m_xProps
->setPropertyValue
118 (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), aValue
);
122 ScVbaTextBox::getServiceImplName()
124 static rtl::OUString
sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaTextBox") );
128 uno::Sequence
< rtl::OUString
>
129 ScVbaTextBox::getServiceNames()
131 static uno::Sequence
< rtl::OUString
> aServiceNames
;
132 if ( aServiceNames
.getLength() == 0 )
134 aServiceNames
.realloc( 1 );
135 aServiceNames
[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.TextBox" ) );
137 return aServiceNames
;