summaryrefslogtreecommitdiff
path: root/sw/qa/core/text/text.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-10-24 08:45:26 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-10-24 10:57:34 +0200
commit122419be4f7bf576f7db5456b8b6b1f6f700487f (patch)
tree261b97d596382762235ebf01480f03f519ca85f1 /sw/qa/core/text/text.cxx
parent1ea0ea19f1dc13c4191ab9d4222adfd2579b802c (diff)
sw content controls, alias: add PDF export
Now that content controls have aliases, map that to PDF's description and then map the content to PDF's text when the content control is not in placeholder mode. This way the widget will have a description even if it's already filled in, which helps a11y. Change-Id: Ia66455eba26300c5dbb2d62b5858bac82546acf8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141716 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/qa/core/text/text.cxx')
-rw-r--r--sw/qa/core/text/text.cxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index a0f7726c42b1..8f3f18fd56d3 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -37,6 +37,9 @@
#include <IDocumentRedlineAccess.hxx>
#include <formatcontentcontrol.hxx>
#include <strings.hrc>
+#include <ndtxt.hxx>
+#include <txatbase.hxx>
+#include <textcontentcontrol.hxx>
constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/core/text/data/";
@@ -630,7 +633,17 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testContentControlPDF)
sal_Int32 nPlaceHolderLen = SwResId(STR_CONTENT_CONTROL_PLACEHOLDER).getLength();
pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, nPlaceHolderLen,
/*bBasicCall=*/false);
- pWrtShell->Insert("mydesc");
+ pWrtShell->Insert("mycontent");
+ const SwPosition* pStart = pWrtShell->GetCursor()->Start();
+ SwTextNode* pTextNode = pStart->GetNode().GetTextNode();
+ sal_Int32 nIndex = pStart->GetContentIndex();
+ SwTextAttr* pAttr
+ = pTextNode->GetTextAttrAt(nIndex, RES_TXTATR_CONTENTCONTROL, sw::GetTextAttrMode::Parent);
+ auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
+ const SwFormatContentControl& rFormatContentControl = pTextContentControl->GetContentControl();
+ std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl();
+ // Alias/title, to be mapped to PDF's description.
+ pContentControl->SetAlias("mydesc");
// When exporting to PDF:
StoreToTempFile("writer_pdf_Export");