summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--offapi/com/sun/star/text/ContentControl.idl8
-rw-r--r--schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng6
-rw-r--r--sw/inc/formatcontentcontrol.hxx9
-rw-r--r--sw/inc/unoprnms.hxx1
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport17.cxx1
-rw-r--r--sw/source/core/crsr/viscrs.cxx4
-rw-r--r--sw/source/core/txtnode/attrcontentcontrol.cxx17
-rw-r--r--sw/source/core/unocore/unocontentcontrol.cxx40
-rw-r--r--sw/source/core/unocore/unomap1.cxx1
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx2
-rw-r--r--sw/source/ui/misc/contentcontroldlg.cxx2
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx2
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx13
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx6
-rw-r--r--xmloff/qa/unit/data/content-control-dropdown.fodt2
-rw-r--r--xmloff/qa/unit/text.cxx2
-rw-r--r--xmloff/source/text/txtparae.cxx9
-rw-r--r--xmloff/source/text/xmlcontentcontrolcontext.cxx13
-rw-r--r--xmloff/source/text/xmlcontentcontrolcontext.hxx1
19 files changed, 120 insertions, 19 deletions
diff --git a/offapi/com/sun/star/text/ContentControl.idl b/offapi/com/sun/star/text/ContentControl.idl
index ae8a0e1a9396..7bdb39fa5101 100644
--- a/offapi/com/sun/star/text/ContentControl.idl
+++ b/offapi/com/sun/star/text/ContentControl.idl
@@ -43,8 +43,6 @@ service ContentControl
[optional, property] string UncheckedState;
/** List items of a dropdown: DisplayText + Value pairs with string values for each item.
-
- If the list is non-empty, a dropdown control is provided on the UI.
*/
[optional, property] sequence< sequence< com::sun::star::beans::PropertyValue > > ListItems;
@@ -100,6 +98,12 @@ service ContentControl
*/
[optional, property] boolean ComboBox;
+ /** Drop-down that does not allow free-form text, i.e. not combo box.
+
+ @since LibreOffice 7.5
+ */
+ [optional, property] boolean DropDown;
+
/** The alias: kind of a human-readable title / description, show up on the UI.
@since LibreOffice 7.5
diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
index d475e90319b4..3b2e0d4b2bbc 100644
--- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
+++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
@@ -2993,6 +2993,12 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
</rng:attribute>
</rng:optional>
<rng:optional>
+ <!-- default value: false -->
+ <rng:attribute name="loext:dropdown">
+ <rng:ref name="boolean"/>
+ </rng:attribute>
+ </rng:optional>
+ <rng:optional>
<rng:attribute name="loext:alias">
<rng:ref name="string"/>
</rng:attribute>
diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx
index adbc4c10a3e6..2d5676a1e3dd 100644
--- a/sw/inc/formatcontentcontrol.hxx
+++ b/sw/inc/formatcontentcontrol.hxx
@@ -152,6 +152,9 @@ class SW_DLLPUBLIC SwContentControl : public sw::BroadcastingModify
/// Same as drop-down, but free-form input is also accepted.
bool m_bComboBox = false;
+ /// Same as combo box, but free-form input is not accepted.
+ bool m_bDropDown = false;
+
/// The placeholder's doc part: just remembered.
OUString m_aPlaceholderDocPart;
@@ -234,8 +237,6 @@ public:
const std::vector<SwContentControlListItem>& GetListItems() const { return m_aListItems; }
- bool HasListItems() const { return !m_aListItems.empty(); }
-
void SetListItems(const std::vector<SwContentControlListItem>& rListItems)
{
m_aListItems = rListItems;
@@ -278,6 +279,10 @@ public:
bool GetComboBox() const { return m_bComboBox; }
+ void SetDropDown(bool bDropDown) { m_bDropDown = bDropDown; }
+
+ bool GetDropDown() const { return m_bDropDown; }
+
void SetPlaceholderDocPart(const OUString& rPlaceholderDocPart)
{
m_aPlaceholderDocPart = rPlaceholderDocPart;
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 61cdcbb05938..4249949add6d 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -885,6 +885,7 @@
#define UNO_NAME_CURRENT_DATE "CurrentDate"
#define UNO_NAME_PLAIN_TEXT "PlainText"
#define UNO_NAME_COMBO_BOX "ComboBox"
+#define UNO_NAME_DROP_DOWN "DropDown"
#define UNO_NAME_PLACEHOLDER_DOC_PART "PlaceholderDocPart"
#define UNO_NAME_DATA_BINDING_PREFIX_MAPPINGS "DataBindingPrefixMappings"
#define UNO_NAME_DATA_BINDING_XPATH "DataBindingXpath"
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 9e4506cf6461..8772c37d51fa 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -327,6 +327,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDropdownContentControlExport)
xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY);
{
+ xContentControlProps->setPropertyValue("DropDown", uno::Any(true));
uno::Sequence<beans::PropertyValues> aListItems = {
{
comphelper::makePropertyValue("DisplayText", uno::Any(OUString("red"))),
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index b112ead80317..4d34e9b89d35 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -696,7 +696,7 @@ void SwSelPaintRects::HighlightContentControl()
aJson.put("action", "show");
aJson.put("rectangles", aPayload);
- if (pContentControl && pContentControl->HasListItems())
+ if (pContentControl && (pContentControl->GetComboBox() || pContentControl->GetDropDown()))
{
tools::ScopedJsonWriterArray aItems = aJson.startArray("items");
for (const auto& rItem : pContentControl->GetListItems())
@@ -741,7 +741,7 @@ void SwSelPaintRects::HighlightContentControl()
}
}
- if (pContentControl && pContentControl->HasListItems())
+ if (pContentControl && (pContentControl->GetComboBox() || pContentControl->GetDropDown()))
{
if (pWrtShell)
{
diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx
index 3807ee9f2dba..965c6adf8476 100644
--- a/sw/source/core/txtnode/attrcontentcontrol.cxx
+++ b/sw/source/core/txtnode/attrcontentcontrol.cxx
@@ -340,10 +340,17 @@ bool SwContentControl::IsInteractingCharacter(sal_Unicode cCh)
bool SwContentControl::ShouldOpenPopup(const vcl::KeyCode& rKeyCode)
{
- if (HasListItems() || GetDate())
+ switch (GetType())
{
- // Alt-down opens the popup.
- return rKeyCode.IsMod2() && rKeyCode.GetCode() == KEY_DOWN;
+ case SwContentControlType::DROP_DOWN_LIST:
+ case SwContentControlType::COMBO_BOX:
+ case SwContentControlType::DATE:
+ {
+ // Alt-down opens the popup.
+ return rKeyCode.IsMod2() && rKeyCode.GetCode() == KEY_DOWN;
+ }
+ default:
+ break;
}
return false;
@@ -361,7 +368,7 @@ SwContentControlType SwContentControl::GetType() const
return SwContentControlType::COMBO_BOX;
}
- if (!m_aListItems.empty())
+ if (m_bDropDown)
{
return SwContentControlType::DROP_DOWN_LIST;
}
@@ -413,6 +420,8 @@ void SwContentControl::dumpAsXml(xmlTextWriterPtr pWriter) const
BAD_CAST(OString::boolean(m_bPlainText).getStr()));
(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("combo-box"),
BAD_CAST(OString::boolean(m_bComboBox).getStr()));
+ (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("drop-down"),
+ BAD_CAST(OString::boolean(m_bDropDown).getStr()));
(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("placeholder-doc-part"),
BAD_CAST(m_aPlaceholderDocPart.toUtf8().getStr()));
(void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("data-binding-prefix-mappings"),
diff --git a/sw/source/core/unocore/unocontentcontrol.cxx b/sw/source/core/unocore/unocontentcontrol.cxx
index 62e93d33d68e..fbded5b45baf 100644
--- a/sw/source/core/unocore/unocontentcontrol.cxx
+++ b/sw/source/core/unocore/unocontentcontrol.cxx
@@ -170,6 +170,7 @@ public:
OUString m_aCurrentDate;
bool m_bPlainText;
bool m_bComboBox;
+ bool m_bDropDown;
OUString m_aPlaceholderDocPart;
OUString m_aDataBindingPrefixMappings;
OUString m_aDataBindingXpath;
@@ -193,6 +194,7 @@ public:
, m_bDate(false)
, m_bPlainText(false)
, m_bComboBox(false)
+ , m_bDropDown(false)
{
if (m_pContentControl)
{
@@ -480,6 +482,7 @@ void SwXContentControl::AttachImpl(const uno::Reference<text::XTextRange>& xText
pContentControl->SetCurrentDate(m_pImpl->m_aCurrentDate);
pContentControl->SetPlainText(m_pImpl->m_bPlainText);
pContentControl->SetComboBox(m_pImpl->m_bComboBox);
+ pContentControl->SetDropDown(m_pImpl->m_bDropDown);
pContentControl->SetPlaceholderDocPart(m_pImpl->m_aPlaceholderDocPart);
pContentControl->SetDataBindingPrefixMappings(m_pImpl->m_aDataBindingPrefixMappings);
pContentControl->SetDataBindingXpath(m_pImpl->m_aDataBindingXpath);
@@ -720,10 +723,21 @@ void SAL_CALL SwXContentControl::setPropertyValue(const OUString& rPropertyName,
if (m_pImpl->m_bIsDescriptor)
{
m_pImpl->m_aListItems = aItems;
+
+ if (!m_pImpl->m_bComboBox && !m_pImpl->m_bDropDown)
+ {
+ m_pImpl->m_bDropDown = true;
+ }
}
else
{
m_pImpl->m_pContentControl->SetListItems(aItems);
+
+ if (!m_pImpl->m_pContentControl->GetComboBox()
+ && !m_pImpl->m_pContentControl->GetDropDown())
+ {
+ m_pImpl->m_pContentControl->SetDropDown(true);
+ }
}
}
else if (rPropertyName == UNO_NAME_PICTURE)
@@ -831,6 +845,21 @@ void SAL_CALL SwXContentControl::setPropertyValue(const OUString& rPropertyName,
}
}
}
+ else if (rPropertyName == UNO_NAME_DROP_DOWN)
+ {
+ bool bValue;
+ if (rValue >>= bValue)
+ {
+ if (m_pImpl->m_bIsDescriptor)
+ {
+ m_pImpl->m_bDropDown = bValue;
+ }
+ else
+ {
+ m_pImpl->m_pContentControl->SetDropDown(bValue);
+ }
+ }
+ }
else if (rPropertyName == UNO_NAME_PLACEHOLDER_DOC_PART)
{
OUString aValue;
@@ -1092,6 +1121,17 @@ uno::Any SAL_CALL SwXContentControl::getPropertyValue(const OUString& rPropertyN
aRet <<= m_pImpl->m_pContentControl->GetComboBox();
}
}
+ else if (rPropertyName == UNO_NAME_DROP_DOWN)
+ {
+ if (m_pImpl->m_bIsDescriptor)
+ {
+ aRet <<= m_pImpl->m_bDropDown;
+ }
+ else
+ {
+ aRet <<= m_pImpl->m_pContentControl->GetDropDown();
+ }
+ }
else if (rPropertyName == UNO_NAME_PLACEHOLDER_DOC_PART)
{
if (m_pImpl->m_bIsDescriptor)
diff --git a/sw/source/core/unocore/unomap1.cxx b/sw/source/core/unocore/unomap1.cxx
index a860f2900754..92f41e52b7a2 100644
--- a/sw/source/core/unocore/unomap1.cxx
+++ b/sw/source/core/unocore/unomap1.cxx
@@ -1004,6 +1004,7 @@ o3tl::span<const SfxItemPropertyMapEntry> SwUnoPropertyMapProvider::GetContentCo
{ u"" UNO_NAME_CURRENT_DATE, 0, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 },
{ u"" UNO_NAME_PLAIN_TEXT, 0, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0 },
{ u"" UNO_NAME_COMBO_BOX, 0, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0 },
+ { u"" UNO_NAME_DROP_DOWN, 0, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0 },
{ u"" UNO_NAME_PLACEHOLDER_DOC_PART, 0, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 },
{ u"" UNO_NAME_DATA_BINDING_PREFIX_MAPPINGS, 0, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 },
{ u"" UNO_NAME_DATA_BINDING_XPATH, 0, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 },
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index a88049e31c09..4a0e4325d580 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2403,7 +2403,7 @@ void DocxAttributeOutput::WriteContentControlStart()
m_pSerializer->endElementNS(XML_w14, XML_checkbox);
}
- if (m_pContentControl->HasListItems())
+ if (m_pContentControl->GetComboBox() || m_pContentControl->GetDropDown())
{
if (m_pContentControl->GetComboBox())
{
diff --git a/sw/source/ui/misc/contentcontroldlg.cxx b/sw/source/ui/misc/contentcontroldlg.cxx
index c530795458a0..ec45e87066c4 100644
--- a/sw/source/ui/misc/contentcontroldlg.cxx
+++ b/sw/source/ui/misc/contentcontroldlg.cxx
@@ -120,7 +120,7 @@ SwContentControlDlg::SwContentControlDlg(weld::Window* pParent, SwWrtShell& rWrt
m_xCheckboxFrame->set_visible(false);
}
- if (m_pContentControl->HasListItems())
+ if (m_pContentControl->GetComboBox() || m_pContentControl->GetDropDown())
{
for (const auto& rListItem : m_pContentControl->GetListItems())
{
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index e74c490f2098..08746303cecf 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3415,7 +3415,7 @@ void SwXTextDocument::executeContentControlEvent(const StringMap& rArguments)
auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
const SwFormatContentControl& rFormatContentControl = pTextContentControl->GetContentControl();
std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl();
- if (!pContentControl->HasListItems())
+ if (!pContentControl->GetComboBox() && !pContentControl->GetDropDown())
{
return;
}
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 9ca81b72b4cd..8cfc57a7cea1 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -1059,12 +1059,17 @@ void SwWrtShell::InsertContentControl(SwContentControlType eType)
break;
}
case SwContentControlType::COMBO_BOX:
- {
- pContentControl->SetComboBox(true);
- [[fallthrough]];
- }
case SwContentControlType::DROP_DOWN_LIST:
{
+ if (eType == SwContentControlType::COMBO_BOX)
+ {
+ pContentControl->SetComboBox(true);
+ }
+ else if (eType == SwContentControlType::DROP_DOWN_LIST)
+ {
+ pContentControl->SetDropDown(true);
+ }
+
pContentControl->SetShowingPlaceHolder(true);
if (!HasSelection())
{
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 0e436fe165b9..e3e2ca0aa9dd 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -980,7 +980,11 @@ void DomainMapper_Impl::PopSdt()
pItems[i] = aItem;
}
xContentControlProps->setPropertyValue("ListItems", uno::Any(aItems));
- if (m_pSdtHelper->getControlType() == SdtControlType::comboBox)
+ if (m_pSdtHelper->getControlType() == SdtControlType::dropDown)
+ {
+ xContentControlProps->setPropertyValue("DropDown", uno::Any(true));
+ }
+ else
{
xContentControlProps->setPropertyValue("ComboBox", uno::Any(true));
}
diff --git a/xmloff/qa/unit/data/content-control-dropdown.fodt b/xmloff/qa/unit/data/content-control-dropdown.fodt
index 97344d1e8bec..73007b2c7c26 100644
--- a/xmloff/qa/unit/data/content-control-dropdown.fodt
+++ b/xmloff/qa/unit/data/content-control-dropdown.fodt
@@ -2,7 +2,7 @@
<office:document xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
<office:body>
<office:text>
- <text:p><loext:content-control><loext:list-item loext:display-text="red" loext:value="R"/><loext:list-item loext:display-text="green" loext:value="G"/><loext:list-item loext:display-text="blue" loext:value="B"/>choose a color</loext:content-control></text:p>
+ <text:p><loext:content-control loext:dropdown="true"><loext:list-item loext:display-text="red" loext:value="R"/><loext:list-item loext:display-text="green" loext:value="G"/><loext:list-item loext:display-text="blue" loext:value="B"/>choose a color</loext:content-control></text:p>
</office:text>
</office:body>
</office:document>
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx
index 16f830aa43cf..9befd99fc600 100644
--- a/xmloff/qa/unit/text.cxx
+++ b/xmloff/qa/unit/text.cxx
@@ -473,6 +473,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDropdownContentControlExport)
xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY);
{
+ xContentControlProps->setPropertyValue("DropDown", uno::Any(true));
uno::Sequence<beans::PropertyValues> aListItems = {
{
comphelper::makePropertyValue("DisplayText", uno::Any(OUString("red"))),
@@ -496,6 +497,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDropdownContentControlExport)
// Then make sure the expected markup is used:
xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
+ assertXPath(pXmlDoc, "//loext:content-control", "dropdown", "true");
// Without the accompanying fix in place, this failed with:
// - Expected: 1
// - Actual : 0
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index f2b10130f71b..b52a66249a1b 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -4037,6 +4037,15 @@ void XMLTextParagraphExport::ExportContentControl(
GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_COMBOBOX, aBuffer.makeStringAndClear());
}
+ bool bDropDown = false;
+ xPropertySet->getPropertyValue("DropDown") >>= bDropDown;
+ if (bDropDown)
+ {
+ OUStringBuffer aBuffer;
+ sax::Converter::convertBool(aBuffer, bDropDown);
+ GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_DROPDOWN, aBuffer.makeStringAndClear());
+ }
+
OUString aAlias;
xPropertySet->getPropertyValue("Alias") >>= aAlias;
if (!aAlias.isEmpty())
diff --git a/xmloff/source/text/xmlcontentcontrolcontext.cxx b/xmloff/source/text/xmlcontentcontrolcontext.cxx
index 379bbe309bd2..c069a6eba9c1 100644
--- a/xmloff/source/text/xmlcontentcontrolcontext.cxx
+++ b/xmloff/source/text/xmlcontentcontrolcontext.cxx
@@ -133,6 +133,14 @@ void XMLContentControlContext::startFastElement(
}
break;
}
+ case XML_ELEMENT(LO_EXT, XML_DROPDOWN):
+ {
+ if (sax::Converter::convertBool(bTmp, rIter.toView()))
+ {
+ m_bDropDown = bTmp;
+ }
+ break;
+ }
case XML_ELEMENT(LO_EXT, XML_ALIAS):
{
m_aAlias = rIter.toString();
@@ -239,6 +247,11 @@ void XMLContentControlContext::endFastElement(sal_Int32)
xPropertySet->setPropertyValue("ComboBox", uno::Any(m_bComboBox));
}
+ if (m_bDropDown)
+ {
+ xPropertySet->setPropertyValue("DropDown", uno::Any(m_bDropDown));
+ }
+
if (!m_aAlias.isEmpty())
{
xPropertySet->setPropertyValue("Alias", uno::Any(m_aAlias));
diff --git a/xmloff/source/text/xmlcontentcontrolcontext.hxx b/xmloff/source/text/xmlcontentcontrolcontext.hxx
index 0bfca015ec68..936fc03c781b 100644
--- a/xmloff/source/text/xmlcontentcontrolcontext.hxx
+++ b/xmloff/source/text/xmlcontentcontrolcontext.hxx
@@ -50,6 +50,7 @@ class XMLContentControlContext : public SvXMLImportContext
OUString m_aCurrentDate;
bool m_bPlainText = false;
bool m_bComboBox = false;
+ bool m_bDropDown = false;
OUString m_aAlias;
OUString m_aTag;