summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2023-06-02 20:29:34 -0400
committerAndras Timar <andras.timar@collabora.com>2023-06-09 12:26:19 +0200
commit3123ab9ef82acbec4ee3de59e7d36ce49b591925 (patch)
treecc1bbddb66c6aff878a8e039f23ad4bf42fd544c /sw
parent0f948fc383c716cd6583969b258805c3501589ba (diff)
tdf#153040 sw content controls PDF export: output listbox entry
This fixes a 7.5 regression/wrong implementation. Prior to 7.5, content controls were just exported as plain text to PDF. Now that the content control is exported, the selected entry in the list box was not being printed - just a big hole in the text. Fixed by informing PDF of the selected entry. TODO: the content control starts too late (a somewhat wide space at the front), and ends too soon (the last portion of the text is cut off). The unit test for the TODO will cover this case, so skipping that for now since I found no examples to follow. Change-Id: I1412a57efc070010c6d0d0a37f48d63699b085b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152567 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/text/itrform2.cxx21
1 files changed, 12 insertions, 9 deletions
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index e0fb52b00bb3..56d40b88ec25 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -976,6 +976,13 @@ bool SwContentControlPortion::DescribePDFControl(const SwTextPaintInfo& rInf) co
return true;
}
+ const SwPaM aPam(*pTextNode, nEnd, *pTextNode, nStart);
+ static sal_Unicode const aForbidden[] = {
+ CH_TXTATR_BREAKWORD,
+ 0
+ };
+ const OUString aText = comphelper::string::removeAny(aPam.GetText(), aForbidden);
+
std::unique_ptr<vcl::PDFWriter::AnyWidget> pDescriptor;
switch (pContentControl->GetType())
{
@@ -999,9 +1006,13 @@ bool SwContentControlPortion::DescribePDFControl(const SwTextPaintInfo& rInf) co
pDescriptor = std::make_unique<vcl::PDFWriter::ListBoxWidget>();
auto pListWidget = static_cast<vcl::PDFWriter::ListBoxWidget*>(pDescriptor.get());
pListWidget->DropDown = true;
+ sal_Int32 nIndex = 0;
for (const auto& rItem : pContentControl->GetListItems())
{
pListWidget->Entries.push_back(rItem.m_aDisplayText);
+ if (rItem.m_aDisplayText == aText)
+ pListWidget->SelectedEntries.push_back(nIndex);
+ ++nIndex;
}
break;
}
@@ -1048,15 +1059,7 @@ bool SwContentControlPortion::DescribePDFControl(const SwTextPaintInfo& rInf) co
}
// Map the text of the content control to the descriptor's text.
- SwPosition aPoint(*pTextNode, nStart);
- SwPosition aMark(*pTextNode, nEnd);
- SwPaM aPam(aMark, aPoint);
- OUString aText = aPam.GetText();
- static sal_Unicode const aForbidden[] = {
- CH_TXTATR_BREAKWORD,
- 0
- };
- pDescriptor->Text = comphelper::string::removeAny(aText, aForbidden);
+ pDescriptor->Text = aText;
// Calculate the bounding rectangle of this content control, which can be one or more layout
// portions in one or more lines.