Thanks to those who reviewed the first patch in my series. I thought I had done so well, and yet... -typo:3df534a5ba
-unused/std::move:0232d4d198
-const&:d9c708f78d
Kendy pointed out there are different license headers, and new code should just use MPL. I had just copy/pasted the header from nearby code. All the work done in these new files was mine (composed by copy/paste as a template). Fixed. I noticed a few stray css:: in .cxx files that I missed. Those are unnecessary and I don't like them. Fixed In the second round of reviews -no need to specify virtual when override -cleaning up ALL of them in bookmark.hxx to be internally consistent - nothing worse than half and half in one file. -use #pragma once for new files -only use official documentation (but I don't like the layout of the official documentation and didn't use it, so the value of providing a web link seems dubious - removed. Change-Id: I3c7aa7d647bfa91b69848258aca6d79d8e7b0edd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142556 Reviewed-by: Justin Luth <jluth@mail.com> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
131 lines
3.8 KiB
C++
131 lines
3.8 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include <ooo/vba/word/WdTextFormFieldType.hpp>
|
|
|
|
#include <sal/log.hxx>
|
|
|
|
#include "vbaformfieldtextinput.hxx"
|
|
|
|
using namespace ::ooo::vba;
|
|
using namespace ::com::sun::star;
|
|
|
|
/**
|
|
* TextInput formfields are inline text objects that are only found in MS Word.
|
|
* They cannot be created in Excel or in Calc.
|
|
*
|
|
* Note that VBA might call this a TextInput, but it might not actually be one,
|
|
* so make good use of getValid()
|
|
*/
|
|
SwVbaFormFieldTextInput::SwVbaFormFieldTextInput(
|
|
const uno::Reference<ooo::vba::XHelperInterface>& rParent,
|
|
const uno::Reference<uno::XComponentContext>& rContext, sw::mark::IFieldmark& rFormField)
|
|
: SwVbaFormFieldTextInput_BASE(rParent, rContext)
|
|
, m_rTextInput(rFormField)
|
|
{
|
|
}
|
|
|
|
SwVbaFormFieldTextInput::~SwVbaFormFieldTextInput() {}
|
|
|
|
OUString SwVbaFormFieldTextInput::getDefaultPropertyName() { return "Valid"; }
|
|
|
|
sal_Bool SwVbaFormFieldTextInput::getValid()
|
|
{
|
|
return IDocumentMarkAccess::GetType(m_rTextInput)
|
|
== IDocumentMarkAccess::MarkType::TEXT_FIELDMARK;
|
|
}
|
|
|
|
OUString SwVbaFormFieldTextInput::getDefault()
|
|
{
|
|
if (!getValid())
|
|
return OUString();
|
|
|
|
return m_rTextInput.GetContent();
|
|
}
|
|
|
|
void SwVbaFormFieldTextInput::setDefault(const OUString& sSet)
|
|
{
|
|
// Hard to know what to do here, since LO doesn't have a default property for text input.
|
|
// This really only makes sense when macro-adding a text input.
|
|
// In that case, we want it to affect the actual text content.
|
|
// However, if the text has already been set by the user, then this shouldn't do anything.
|
|
// Assuming this is only ever set when adding a text input seems the sanest approach.
|
|
if (!getValid() || getDefault() == sSet)
|
|
return;
|
|
|
|
m_rTextInput.ReplaceContent(sSet);
|
|
}
|
|
|
|
OUString SwVbaFormFieldTextInput::getFormat()
|
|
{
|
|
if (!getValid())
|
|
return OUString();
|
|
|
|
SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::getFormat stub");
|
|
return OUString();
|
|
}
|
|
|
|
sal_Int32 SwVbaFormFieldTextInput::getType()
|
|
{
|
|
if (!getValid())
|
|
return word::WdTextFormFieldType::wdRegularText;
|
|
|
|
SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::getType stub");
|
|
return word::WdTextFormFieldType::wdRegularText;
|
|
}
|
|
|
|
sal_Int32 SwVbaFormFieldTextInput::getWidth()
|
|
{
|
|
if (!getValid())
|
|
return 0;
|
|
|
|
SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::getWidth stub");
|
|
return 11 * 50;
|
|
}
|
|
|
|
void SwVbaFormFieldTextInput::setWidth(sal_Int32 nWidth)
|
|
{
|
|
if (!getValid())
|
|
return;
|
|
|
|
SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::setWidth[" << nWidth << "] stub");
|
|
}
|
|
|
|
void SwVbaFormFieldTextInput::Clear()
|
|
{
|
|
if (!getValid() || m_rTextInput.GetContent().isEmpty())
|
|
return;
|
|
|
|
m_rTextInput.ReplaceContent("");
|
|
}
|
|
|
|
void SwVbaFormFieldTextInput::EditType(sal_Int32 nType, const uno::Any& rDefault,
|
|
const uno::Any& rFormat, const uno::Any& rEnabled)
|
|
{
|
|
OUString sDefault;
|
|
OUString sFormat;
|
|
bool bEnabled = true;
|
|
rDefault >>= sDefault;
|
|
rFormat >>= sFormat;
|
|
rEnabled >>= bEnabled;
|
|
SAL_INFO("sw.vba", "SwVbaFormFieldTextInput::EditType["
|
|
<< nType << "] sDefault[" << sDefault << "] sFormat[" << sFormat
|
|
<< "] bEnabled[" << bEnabled << "] stub");
|
|
}
|
|
|
|
OUString SwVbaFormFieldTextInput::getServiceImplName() { return "SwVbaFormFieldTextInput"; }
|
|
|
|
uno::Sequence<OUString> SwVbaFormFieldTextInput::getServiceNames()
|
|
{
|
|
static uno::Sequence<OUString> const aServiceNames{ "ooo.vba.word.TextInput" };
|
|
return aServiceNames;
|
|
}
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|