Commit bfdd033b authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

poppler: Convert Ink annotations via C++

Instead of via the magic XML cycle of Poppler::AnnotationUtils::storeAnnotation + Okular::AnnotationUtils::createAnnotation
parent a39708e7
...@@ -521,6 +521,25 @@ static Okular::Annotation *createAnnotationFromPopplerAnnotation(const Poppler:: ...@@ -521,6 +521,25 @@ static Okular::Annotation *createAnnotationFromPopplerAnnotation(const Poppler::
return oHighlightAnn; return oHighlightAnn;
} }
static Okular::Annotation *createAnnotationFromPopplerAnnotation(const Poppler::InkAnnotation *popplerAnnotation)
{
Okular::InkAnnotation *oInkAnn = new Okular::InkAnnotation();
const QList<QLinkedList<QPointF>> popplerInkPaths = popplerAnnotation->inkPaths();
QList<QLinkedList<Okular::NormalizedPoint>> okularInkPaths;
for (const QLinkedList<QPointF> &popplerInkPath : popplerInkPaths) {
QLinkedList<Okular::NormalizedPoint> okularInkPath;
for (const QPointF &popplerPoint : popplerInkPath) {
okularInkPath << Okular::NormalizedPoint(popplerPoint.x(), popplerPoint.y());
}
okularInkPaths << okularInkPath;
}
oInkAnn->setInkPaths(okularInkPaths);
return oInkAnn;
}
Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *popplerAnnotation, const Poppler::Page &popplerPage, bool *doDelete) Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *popplerAnnotation, const Poppler::Page &popplerPage, bool *doDelete)
{ {
Okular::Annotation *okularAnnotation = nullptr; Okular::Annotation *okularAnnotation = nullptr;
...@@ -616,7 +635,13 @@ Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *p ...@@ -616,7 +635,13 @@ Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *p
okularAnnotation = createAnnotationFromPopplerAnnotation(static_cast<Poppler::HighlightAnnotation *>(popplerAnnotation)); okularAnnotation = createAnnotationFromPopplerAnnotation(static_cast<Poppler::HighlightAnnotation *>(popplerAnnotation));
break; break;
} }
case Poppler::Annotation::AInk: case Poppler::Annotation::AInk: {
externallyDrawn = true;
tieToOkularAnn = true;
*doDelete = false;
okularAnnotation = createAnnotationFromPopplerAnnotation(static_cast<Poppler::InkAnnotation *>(popplerAnnotation));
break;
}
case Poppler::Annotation::ACaret: case Poppler::Annotation::ACaret:
externallyDrawn = true; externallyDrawn = true;
/* fallthrough */ /* fallthrough */
......
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