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