diff options
author | Justin Luth <justin.luth@collabora.com> | 2022-11-21 19:57:15 -0500 |
---|---|---|
committer | Justin Luth <jluth@mail.com> | 2022-11-25 18:09:32 +0100 |
commit | 432e5e6e33c3687cdb67ee0a64d57169a82e641d (patch) | |
tree | 1450a8babe1911aebb35ae18f302058f0d3a0ee1 /oovbaapi | |
parent | 1e83197fdd4263ca4817a6ac16f274aaee3e66fd (diff) |
tdf#151548 vba ContentControls: Add word::XContentControlListEntry
make CppunitTest_sw_macros_test CPPUNIT_TEST_NAME=testVba
This now allows MS Word's modern content control list boxes
(combobox and dropbox) to be controlled by VBA basic.
-allows getting and setting the selected list entry
-allows adding/deleting/renaming/moving list entries
If .DropdownListEntries.Count <> 3 Then GoTo errorhandler:
.DropdownListEntries.Item(2).Select
.DropdownListEntries.Item(2).Delete
If .DropdownListEntries.Item(2).Text <> "infinity"
If .DropdownListEntries.Item(2).Value <> "infinity and beyond"
'With .DropdownListEntries.Add("third", "3rd", 2)
Dim LE As ContentControlListEntry
Set LE = .DropdownListEntries.Add("third", "3rd", 2)
With LE
If LE.Index <> 2 Then GoTo errorhandler:
If LE.Value <> "3rd" Then GoTo errorhandler:
.MoveUp
.MoveUp
.MoveUp
If .Index <> 1 Then GoTo errorhandler:
.MoveDown
.MoveDown
If .Index <> 3 Then GoTo errorhandler:
End With 'LE
If .DropdownListEntries.Item(3).Text <> "third" Then GoTo errorhandler:
End With 'Item 1
runOnceDropDown:
With ActiveDocument.ContentControls.Item(4)
If .Type <> wdContentControlComboBox Then GoTo errorhandler:
.DropdownListEntries.Clear
End With
Change-Id: Iffebb2bd69abec1cbcfaed05b58f940664852eae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143082
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oovbaapi')
-rw-r--r-- | oovbaapi/UnoApi_oovbaapi.mk | 2 | ||||
-rw-r--r-- | oovbaapi/ooo/vba/word/XContentControlListEntries.idl | 30 | ||||
-rw-r--r-- | oovbaapi/ooo/vba/word/XContentControlListEntry.idl | 43 |
3 files changed, 75 insertions, 0 deletions
diff --git a/oovbaapi/UnoApi_oovbaapi.mk b/oovbaapi/UnoApi_oovbaapi.mk index 063700762e46..dcd514f7ea3e 100644 --- a/oovbaapi/UnoApi_oovbaapi.mk +++ b/oovbaapi/UnoApi_oovbaapi.mk @@ -1060,6 +1060,8 @@ $(eval $(call gb_UnoApi_add_idlfiles,oovbaapi,ooo/vba/word,\ XFont \ XContentControl \ XContentControls \ + XContentControlListEntry \ + XContentControlListEntries \ XFormField \ XFormFields \ XFrame \ diff --git a/oovbaapi/ooo/vba/word/XContentControlListEntries.idl b/oovbaapi/ooo/vba/word/XContentControlListEntries.idl new file mode 100644 index 000000000000..fddf2318afe0 --- /dev/null +++ b/oovbaapi/ooo/vba/word/XContentControlListEntries.idl @@ -0,0 +1,30 @@ +/* -*- 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/. + */ + +module ooo { module vba { module word { + +interface XContentControlListEntry; +interface XContentControlListEntries +{ + interface ooo::vba::XCollection; + + /// Adds a new list item to a drop-down list or combo box content control + /// and returns a ContentControlListEntry object. + /// Entries must have a unique display Name, + /// Value is optional - uses Name if not specified. + /// Index is optional. It inserts at the end if not specified, otherwise inserted into list. + XContentControlListEntry Add( [in] string Name, [in] /*optional*/ any Value, [in] /*optional*/ any Index ); + + /// Remove all items from the dropdown list + void Clear(); +}; + +}; }; }; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oovbaapi/ooo/vba/word/XContentControlListEntry.idl b/oovbaapi/ooo/vba/word/XContentControlListEntry.idl new file mode 100644 index 000000000000..15b52a774cc1 --- /dev/null +++ b/oovbaapi/ooo/vba/word/XContentControlListEntry.idl @@ -0,0 +1,43 @@ +/* -*- 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/. + */ + +module ooo { module vba { module word { + +interface XContentControlListEntry +{ + interface ooo::vba::XHelperInterface; + + /// Returns or sets the ordinal position of a list item in the collection of list items. + [attribute] long Index; + + /// Returns or sets a String that represents the display text of the list item. + [attribute] string Text; + + /// Returns or sets a String that represents the programmatic value of the list item. + [attribute] string Value; + + /// Deletes the specified item in a combo box or drop-down list content control. + void Delete(); + + /// Moves an item in a drop-down list or combo box content control down one item, + /// so that it is after the item that originally followed it. + void MoveDown(); + + /// Moves an item in a drop-down list or combo box content control up one item, + /// so that it is before the item that originally preceded it. + void MoveUp(); + + /// Selects the list entry in a drop-down list or combo box content control + /// and sets the text of the content control to the value of the item. + void Select(); +}; + +}; }; }; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |