pdf: add PDF 2.0 support for /Em and /Strongstructure element
Add support to PDF export to handle /Em (Emphasis) and /Strong structure element and fallback to /Span if the PDF version is not PDF 2.0. Use /Em if "Emphasis" char style is used and /Strong if "Strong Emphasis" char style is used. Change-Id: I33d572748592bb20c7daf55716d1f2cc3e6bd989 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180123 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
3f254da09a
commit
02a20c0263
@@ -176,6 +176,7 @@ enum class StructElement
|
||||
// Inline level elements
|
||||
Span, Quote, Note, Reference, BibEntry, Code, Link, Annot,
|
||||
Ruby, RB, RT, RP, Warichu, WT, WP,
|
||||
Emphasis, Strong, // PDF 2.0
|
||||
|
||||
// Illustration elements
|
||||
Figure, Formula, Form
|
||||
|
||||
@@ -180,6 +180,8 @@ constexpr OUString aHeading = u"Heading"_ustr;
|
||||
constexpr OUString aQuotation = u"Quotation"_ustr;
|
||||
constexpr OUString aSourceText = u"Source Text"_ustr;
|
||||
constexpr OUString constTitleStyleName = u"Title"_ustr;
|
||||
constexpr OUString constEmphasisStyleName = u"Emphasis"_ustr;
|
||||
constexpr OUString constStrongEmphasisStyleName = u"Strong Emphasis"_ustr;
|
||||
|
||||
// PDF Tag Names:
|
||||
constexpr OUStringLiteral aDocumentString = u"Document";
|
||||
@@ -1921,6 +1923,26 @@ void SwTaggedPDFHelper::BeginInlineStructureElements()
|
||||
--m_nEndStructureElement;
|
||||
}
|
||||
}
|
||||
// Emphasis
|
||||
else if (sStyleName == constEmphasisStyleName)
|
||||
{
|
||||
if (!isContinueSpan)
|
||||
{
|
||||
nPDFType = sal_uInt16(vcl::pdf::StructElement::Emphasis);
|
||||
aPDFType = constEmphasisStyleName;
|
||||
CreateCurrentSpan(rInf, sStyleName);
|
||||
}
|
||||
}
|
||||
// Strong
|
||||
else if (sStyleName == constStrongEmphasisStyleName)
|
||||
{
|
||||
if (!isContinueSpan)
|
||||
{
|
||||
nPDFType = sal_uInt16(vcl::pdf::StructElement::Strong);
|
||||
aPDFType = constStrongEmphasisStyleName;
|
||||
CreateCurrentSpan(rInf, sStyleName);
|
||||
}
|
||||
}
|
||||
// Check for Quote/Code character style:
|
||||
else if (sStyleName == aQuotation)
|
||||
{
|
||||
|
||||
@@ -10768,6 +10768,8 @@ const char* PDFWriterImpl::getStructureTag(vcl::pdf::StructElement eType)
|
||||
{ StructElement::Formula, "Formula"},
|
||||
{ StructElement::Form, "Form" },
|
||||
{ StructElement::Title, "Title" },
|
||||
{ StructElement::Emphasis, "Em" },
|
||||
{ StructElement::Strong, "Strong" },
|
||||
});
|
||||
|
||||
// First handle fallbacks for elements that were added in a certain PDF version
|
||||
@@ -10779,11 +10781,14 @@ const char* PDFWriterImpl::getStructureTag(vcl::pdf::StructElement eType)
|
||||
// PDF 2.0 fallbacks
|
||||
if (m_aContext.Version < PDFWriter::PDFVersion::PDF_2_0)
|
||||
{
|
||||
switch(eType)
|
||||
switch (eType)
|
||||
{
|
||||
case StructElement::Title:
|
||||
eType = StructElement::Paragraph;
|
||||
break;
|
||||
eType = StructElement::Paragraph; break;
|
||||
case StructElement::Emphasis:
|
||||
eType = StructElement::Span; break;
|
||||
case StructElement::Strong:
|
||||
eType = StructElement::Span; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -11378,6 +11383,8 @@ bool PDFWriterImpl::setStructureAttribute( enum PDFWriter::StructAttribute eAttr
|
||||
eType == vcl::pdf::StructElement::TableData ||
|
||||
eType == vcl::pdf::StructElement::Span ||
|
||||
eType == vcl::pdf::StructElement::Quote ||
|
||||
eType == vcl::pdf::StructElement::Emphasis ||
|
||||
eType == vcl::pdf::StructElement::Strong ||
|
||||
eType == vcl::pdf::StructElement::Note ||
|
||||
eType == vcl::pdf::StructElement::Reference ||
|
||||
eType == vcl::pdf::StructElement::BibEntry ||
|
||||
@@ -11414,6 +11421,8 @@ bool PDFWriterImpl::setStructureAttribute( enum PDFWriter::StructAttribute eAttr
|
||||
eType == vcl::pdf::StructElement::TableData ||
|
||||
eType == vcl::pdf::StructElement::Span ||
|
||||
eType == vcl::pdf::StructElement::Quote ||
|
||||
eType == vcl::pdf::StructElement::Emphasis ||
|
||||
eType == vcl::pdf::StructElement::Strong ||
|
||||
eType == vcl::pdf::StructElement::Note ||
|
||||
eType == vcl::pdf::StructElement::Reference ||
|
||||
eType == vcl::pdf::StructElement::BibEntry ||
|
||||
@@ -11613,6 +11622,8 @@ bool PDFWriterImpl::setStructureAttributeNumerical( enum PDFWriter::StructAttrib
|
||||
eType == vcl::pdf::StructElement::TableData ||
|
||||
eType == vcl::pdf::StructElement::Span ||
|
||||
eType == vcl::pdf::StructElement::Quote ||
|
||||
eType == vcl::pdf::StructElement::Emphasis ||
|
||||
eType == vcl::pdf::StructElement::Strong ||
|
||||
eType == vcl::pdf::StructElement::Note ||
|
||||
eType == vcl::pdf::StructElement::Reference ||
|
||||
eType == vcl::pdf::StructElement::BibEntry ||
|
||||
|
||||
Reference in New Issue
Block a user