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/.
10 #include <ooo/vba/word/WdTextFormFieldType.hpp>
12 #include <sal/log.hxx>
14 #include "vbaformfieldtextinput.hxx"
16 using namespace ::ooo::vba
;
17 using namespace ::com::sun::star
;
20 * TextInput formfields are inline text objects that are only found in MS Word.
21 * They cannot be created in Excel or in Calc.
23 * Note that VBA might call this a TextInput, but it might not actually be one,
24 * so make good use of getValid()
26 SwVbaFormFieldTextInput::SwVbaFormFieldTextInput(
27 const uno::Reference
<ooo::vba::XHelperInterface
>& rParent
,
28 const uno::Reference
<uno::XComponentContext
>& rContext
, sw::mark::IFieldmark
& rFormField
)
29 : SwVbaFormFieldTextInput_BASE(rParent
, rContext
)
30 , m_rTextInput(rFormField
)
34 SwVbaFormFieldTextInput::~SwVbaFormFieldTextInput() {}
36 OUString
SwVbaFormFieldTextInput::getDefaultPropertyName() { return "Valid"; }
38 sal_Bool
SwVbaFormFieldTextInput::getValid()
40 return IDocumentMarkAccess::GetType(m_rTextInput
)
41 == IDocumentMarkAccess::MarkType::TEXT_FIELDMARK
;
44 OUString
SwVbaFormFieldTextInput::getDefault()
49 return m_rTextInput
.GetContent();
52 void SwVbaFormFieldTextInput::setDefault(const OUString
& sSet
)
54 // Hard to know what to do here, since LO doesn't have a default property for text input.
55 // This really only makes sense when macro-adding a text input.
56 // In that case, we want it to affect the actual text content.
57 // However, if the text has already been set by the user, then this shouldn't do anything.
58 // Assuming this is only ever set when adding a text input seems the sanest approach.
59 if (!getValid() || getDefault() == sSet
)
62 m_rTextInput
.ReplaceContent(sSet
);
65 OUString
SwVbaFormFieldTextInput::getFormat()
70 SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::getFormat stub");
74 sal_Int32
SwVbaFormFieldTextInput::getType()
77 return word::WdTextFormFieldType::wdRegularText
;
79 SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::getType stub");
80 return word::WdTextFormFieldType::wdRegularText
;
83 sal_Int32
SwVbaFormFieldTextInput::getWidth()
88 SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::getWidth stub");
92 void SwVbaFormFieldTextInput::setWidth(sal_Int32 nWidth
)
97 SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::setWidth[" << nWidth
<< "] stub");
100 void SwVbaFormFieldTextInput::Clear()
102 if (!getValid() || m_rTextInput
.GetContent().isEmpty())
105 m_rTextInput
.ReplaceContent("");
108 void SwVbaFormFieldTextInput::EditType(sal_Int32 nType
, const uno::Any
& rDefault
,
109 const uno::Any
& rFormat
, const uno::Any
& rEnabled
)
113 bool bEnabled
= true;
114 rDefault
>>= sDefault
;
116 rEnabled
>>= bEnabled
;
117 SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::EditType["
118 << nType
<< "] sDefault[" << sDefault
<< "] sFormat[" << sFormat
119 << "] bEnabled[" << bEnabled
<< "] stub");
122 OUString
SwVbaFormFieldTextInput::getServiceImplName() { return "SwVbaFormFieldTextInput"; }
124 uno::Sequence
<OUString
> SwVbaFormFieldTextInput::getServiceNames()
126 static uno::Sequence
<OUString
> const aServiceNames
{ "ooo.vba.word.TextInput" };
127 return aServiceNames
;
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */