Commit f5337886 authored by Albert Astals Cid's avatar Albert Astals Cid

poppler: Convert Geom annotations via C++

Instead of via the magic XML cycle of Poppler::AnnotationUtils::storeAnnotation + Okular::AnnotationUtils::createAnnotation
parent 49c680fd
......@@ -410,6 +410,20 @@ static Okular::LineAnnotation::LineIntent popplerToOkular(Poppler::LineAnnotatio
return Okular::LineAnnotation::Unknown;
}
static Okular::GeomAnnotation::GeomType popplerToOkular(Poppler::GeomAnnotation::GeomType pgt)
{
switch (pgt) {
case Poppler::GeomAnnotation::InscribedSquare:
return Okular::GeomAnnotation::InscribedSquare;
case Poppler::GeomAnnotation::InscribedCircle:
return Okular::GeomAnnotation::InscribedCircle;
default:
qWarning() << Q_FUNC_INFO << "unknown value" << pgt;
}
return Okular::GeomAnnotation::InscribedSquare;
}
static Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::TextAnnotation *popplerAnnotation)
{
Okular::TextAnnotation *oTextAnn = new Okular::TextAnnotation();
......@@ -452,6 +466,16 @@ static Okular::Annotation *createAnnotationFromPopplerAnnotation(const Poppler::
return oLineAnn;
}
static Okular::Annotation *createAnnotationFromPopplerAnnotation(const Poppler::GeomAnnotation *popplerAnnotation)
{
Okular::GeomAnnotation *oGeomAnn = new Okular::GeomAnnotation();
oGeomAnn->setGeometricalType(popplerToOkular(popplerAnnotation->geomType()));
oGeomAnn->setGeometricalInnerColor(popplerAnnotation->geomInnerColor());
return oGeomAnn;
}
Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *popplerAnnotation, const Poppler::Page &popplerPage, bool *doDelete)
{
Okular::Annotation *okularAnnotation = nullptr;
......@@ -533,7 +557,13 @@ Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *p
okularAnnotation = createAnnotationFromPopplerAnnotation(static_cast<Poppler::LineAnnotation *>(popplerAnnotation));
break;
}
case Poppler::Annotation::AGeom:
case Poppler::Annotation::AGeom: {
externallyDrawn = true;
tieToOkularAnn = true;
*doDelete = false;
okularAnnotation = createAnnotationFromPopplerAnnotation(static_cast<Poppler::GeomAnnotation *>(popplerAnnotation));
break;
}
case Poppler::Annotation::AHighlight:
case Poppler::Annotation::AInk:
case Poppler::Annotation::ACaret:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment