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 <sal/log.hxx>
12 #include "vbaformfieldcheckbox.hxx"
14 using namespace ::ooo::vba
;
15 using namespace ::com::sun::star
;
18 * CheckBoxes are inline text objects that are only found in MS Word.
19 * They cannot be created in Excel or in Calc.
21 * Note that VBA might call this a Checkbox, but it might not actually be one,
22 * so make good use of getValid()
24 SwVbaFormFieldCheckBox::SwVbaFormFieldCheckBox(
25 const uno::Reference
<ooo::vba::XHelperInterface
>& rParent
,
26 const uno::Reference
<uno::XComponentContext
>& rContext
, sw::mark::Fieldmark
& rFormField
)
27 : SwVbaFormFieldCheckBox_BASE(rParent
, rContext
)
28 , m_pCheckBox(dynamic_cast<sw::mark::CheckboxFieldmark
*>(&rFormField
))
32 SwVbaFormFieldCheckBox::~SwVbaFormFieldCheckBox() {}
34 OUString
SwVbaFormFieldCheckBox::getDefaultPropertyName() { return u
"Valid"_ustr
; }
36 sal_Bool
SwVbaFormFieldCheckBox::getValid()
39 && IDocumentMarkAccess::GetType(*m_pCheckBox
)
40 == IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK
;
43 sal_Bool
SwVbaFormFieldCheckBox::getAutoSize()
48 SAL_INFO("sw.vba", "SwVbaFormFieldCheckBox::getAutoSize stub");
52 void SwVbaFormFieldCheckBox::setAutoSize(sal_Bool
/*bSet*/)
57 SAL_INFO("sw.vba", "SwVbaFormFieldCheckBox::setAutoSize stub");
60 sal_Bool
SwVbaFormFieldCheckBox::getDefault()
68 void SwVbaFormFieldCheckBox::setDefault(sal_Bool bSet
)
73 // Hard to know what to do here, since LO doesn't have a default property for checkboxes.
74 // Setting this really only makes sense when macro-adding a checkbox.
75 // In that case, we want it to affect the actual checkbox.
76 // However, if the checkbox has already been set by the user, then this shouldn't do anything.
77 // Assuming this is only ever called when adding a checkbox seems the sanest approach.
81 // Returns the size of a check box, in points
82 sal_Int32
SwVbaFormFieldCheckBox::getSize()
87 SAL_INFO("sw.vba", "SwVbaFormFieldCheckBox::getSize stub");
91 void SwVbaFormFieldCheckBox::setSize(sal_Int32 nSet
)
96 SAL_INFO("sw.vba", "SwVbaFormFieldCheckBox::setSize[" << nSet
<< "] stub");
99 sal_Bool
SwVbaFormFieldCheckBox::getValue() { return getValid() && m_pCheckBox
->IsChecked(); }
101 void SwVbaFormFieldCheckBox::setValue(sal_Bool bSet
)
103 if (!getValid() || !getValue() == !bSet
)
106 m_pCheckBox
->SetChecked(bSet
);
109 OUString
SwVbaFormFieldCheckBox::getServiceImplName() { return u
"SwVbaFormFieldCheckBox"_ustr
; }
111 uno::Sequence
<OUString
> SwVbaFormFieldCheckBox::getServiceNames()
113 static uno::Sequence
<OUString
> const aServiceNames
{ u
"ooo.vba.word.CheckBox"_ustr
};
114 return aServiceNames
;
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */