android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / ui / vba / vbaformfieldtextinput.cxx
blob4f78761f4eb1d8943b3352e1bee6389fe5a04c2b
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/.
8 */
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;
19 /**
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()
46 if (!getValid())
47 return OUString();
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)
60 return;
62 m_rTextInput.ReplaceContent(sSet);
65 OUString SwVbaFormFieldTextInput::getFormat()
67 if (!getValid())
68 return OUString();
70 SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::getFormat stub");
71 return OUString();
74 sal_Int32 SwVbaFormFieldTextInput::getType()
76 if (!getValid())
77 return word::WdTextFormFieldType::wdRegularText;
79 SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::getType stub");
80 return word::WdTextFormFieldType::wdRegularText;
83 sal_Int32 SwVbaFormFieldTextInput::getWidth()
85 if (!getValid())
86 return 0;
88 SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::getWidth stub");
89 return 11 * 50;
92 void SwVbaFormFieldTextInput::setWidth(sal_Int32 nWidth)
94 if (!getValid())
95 return;
97 SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::setWidth[" << nWidth << "] stub");
100 void SwVbaFormFieldTextInput::Clear()
102 if (!getValid() || m_rTextInput.GetContent().isEmpty())
103 return;
105 m_rTextInput.ReplaceContent("");
108 void SwVbaFormFieldTextInput::EditType(sal_Int32 nType, const uno::Any& rDefault,
109 const uno::Any& rFormat, const uno::Any& rEnabled)
111 OUString sDefault;
112 OUString sFormat;
113 bool bEnabled = true;
114 rDefault >>= sDefault;
115 rFormat >>= sFormat;
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: */