summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2023-06-02 20:29:34 -0400
committerJustin Luth <jluth@mail.com>2023-06-03 03:30:40 +0200
commit7daf830830609cbb13a01ae55634187718c84d8a (patch)
tree10f51852e9534f3159d0add3d413cff6b2734a9c /sw/source
parent00a44a080539fa5d7cbd9cc21442b500b66164ef (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/+/152566 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'sw/source')
-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 8563c6c22d7d..d5928c3e77e1 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -987,6 +987,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())
{
@@ -1010,9 +1017,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;
}
@@ -1059,15 +1070,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.