From c7402519ecf42703a56aa22c822aff6c4a047e73 Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Wed, 8 Dec 2021 19:37:18 +0100 Subject: [PATCH] XFA: Bugfixing - proper edge and corner drawing --- Pdf4QtLib/sources/pdfxfaengine.cpp | 73 +++++++++++++++--------------- xfa/xfa-spec.xml | 2 +- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/Pdf4QtLib/sources/pdfxfaengine.cpp b/Pdf4QtLib/sources/pdfxfaengine.cpp index 2416083..2148832 100644 --- a/Pdf4QtLib/sources/pdfxfaengine.cpp +++ b/Pdf4QtLib/sources/pdfxfaengine.cpp @@ -3814,7 +3814,7 @@ std::optional XFA_corner::parse(const QDomElement& element) parseAttribute(element, "presence", myClass.m_presence, "visible"); parseAttribute(element, "radius", myClass.m_radius, "0in"); parseAttribute(element, "stroke", myClass.m_stroke, "solid"); - parseAttribute(element, "thickness", myClass.m_thickness, "0.pt"); + parseAttribute(element, "thickness", myClass.m_thickness, "0.5pt"); parseAttribute(element, "use", myClass.m_use, ""); parseAttribute(element, "usehref", myClass.m_usehref, ""); @@ -12078,6 +12078,11 @@ void PDFXFAEngineImpl::drawItemRectEdges(const std::vectorgetPresence(); + switch (presence) + { + case xfa::XFA_BaseNode::PRESENCE::Visible: + break; + case xfa::XFA_BaseNode::PRESENCE::Hidden: + case xfa::XFA_BaseNode::PRESENCE::Inactive: + case xfa::XFA_BaseNode::PRESENCE::Invisible: + return pen; + + default: + Q_ASSERT(false); + return pen; + } + switch (edge->getCap()) { case pdf::xfa::XFA_BaseNode::CAP::Square: @@ -12264,23 +12284,6 @@ QPen PDFXFAEngineImpl::createPenFromEdge(const xfa::XFA_edge* edge, QListgetThickness().getValuePt(nullptr)); QColor color = createColor(edge->getColor()); - - if (color.isValid()) - { - const xfa::XFA_BaseNode::PRESENCE presence = edge->getPresence(); - switch (presence) - { - case xfa::XFA_BaseNode::PRESENCE::Visible: - color.setAlphaF(1.0); - break; - case xfa::XFA_BaseNode::PRESENCE::Hidden: - case xfa::XFA_BaseNode::PRESENCE::Inactive: - case xfa::XFA_BaseNode::PRESENCE::Invisible: - color.setAlphaF(0.0); - break; - } - } - pen.setColor(color); return pen; } @@ -12294,6 +12297,21 @@ QPen PDFXFAEngineImpl::createPenFromCorner(const xfa::XFA_corner* corner, QList< return pen; } + const xfa::XFA_BaseNode::PRESENCE presence = corner->getPresence(); + switch (presence) + { + case xfa::XFA_BaseNode::PRESENCE::Visible: + break; + case xfa::XFA_BaseNode::PRESENCE::Hidden: + case xfa::XFA_BaseNode::PRESENCE::Inactive: + case xfa::XFA_BaseNode::PRESENCE::Invisible: + return pen; + + default: + Q_ASSERT(false); + return pen; + } + switch (corner->getStroke()) { case pdf::xfa::XFA_BaseNode::STROKE::Solid: @@ -12323,23 +12341,6 @@ QPen PDFXFAEngineImpl::createPenFromCorner(const xfa::XFA_corner* corner, QList< pen.setWidthF(corner->getThickness().getValuePt(nullptr)); QColor color = createColor(corner->getColor()); - - if (color.isValid()) - { - const xfa::XFA_BaseNode::PRESENCE presence = corner->getPresence(); - switch (presence) - { - case xfa::XFA_BaseNode::PRESENCE::Visible: - color.setAlphaF(1.0); - break; - case xfa::XFA_BaseNode::PRESENCE::Hidden: - case xfa::XFA_BaseNode::PRESENCE::Inactive: - case xfa::XFA_BaseNode::PRESENCE::Invisible: - color.setAlphaF(0.0); - break; - } - } - pen.setColor(color); return pen; } diff --git a/xfa/xfa-spec.xml b/xfa/xfa-spec.xml index 1b9bb14..e337007 100644 --- a/xfa/xfa-spec.xml +++ b/xfa/xfa-spec.xml @@ -289,7 +289,7 @@ - +