Changeset View
Standalone View
generators/poppler/annots.cpp
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Line(s) | 139 | { | |||
---|---|---|---|---|---|
173 | // Set type-specific properties (if any) | 173 | // Set type-specific properties (if any) | ||
174 | switch ( ppl_ann->subType() ) | 174 | switch ( ppl_ann->subType() ) | ||
175 | { | 175 | { | ||
176 | case Poppler::Annotation::AText: | 176 | case Poppler::Annotation::AText: | ||
177 | { | 177 | { | ||
178 | const Okular::TextAnnotation * okl_txtann = static_cast<const Okular::TextAnnotation*>(okl_ann); | 178 | const Okular::TextAnnotation * okl_txtann = static_cast<const Okular::TextAnnotation*>(okl_ann); | ||
179 | Poppler::TextAnnotation * ppl_txtann = static_cast<Poppler::TextAnnotation*>(ppl_ann); | 179 | Poppler::TextAnnotation * ppl_txtann = static_cast<Poppler::TextAnnotation*>(ppl_ann); | ||
180 | ppl_txtann->setTextIcon( okl_txtann->textIcon() ); | 180 | ppl_txtann->setTextIcon( okl_txtann->textIcon() ); | ||
181 | ppl_txtann->setTextFont( okl_txtann->textFont() ); | 181 | ppl_txtann->setTextFont( okl_txtann->textFont(), okl_txtann->textColor() ); | ||
182 | ppl_txtann->setInplaceAlign( okl_txtann->inplaceAlignment() ); | 182 | ppl_txtann->setInplaceAlign( okl_txtann->inplaceAlignment() ); | ||
tobiasdeiminger: Poppler::TextAnnotation::setTextFont is brand new poppler API (actually not yet merged). We… | |||||
Ah, meant setTextColor, not setTextFont, sorry. Btw, (how) can I edit my inline comments here in case of typos? tobiasdeiminger: Ah, meant setTextColor, not setTextFont, sorry. Btw, (how) can I edit my inline comments here… | |||||
#ifdef HAVE_POPPLER_0_67 ppl_txtann->setTextColor( okl_txtann->textColor() ); #endif //HAVE_POPPLER_0_67
dileepsankhla: 1. Do I need to do something like this in okular/generators/poppler/annots.cpp:
```
#ifdef… | |||||
1.) yes
sander: 1.) yes
2) You need to write a test that sets the HAVE_POPPLER_0_67 flag. Have a look at that… | |||||
I have added the following lines in generator/poppler/CMakeLists.txt: check_cxx_source_compiles(" #include <poppler-qt5.h> #include <QColor> int main() { Poppler::TextAnnotation *annot = new Poppler::TextAnnotation( Poppler::TextAnnotation::InPlace ); annot->setTextColor(Qt::blue); return 0; } " HAVE_POPPLER_0_67) The typewriter text is created with the desired color but whenever I move the annotation, the text color falls back to "black". It means in `PopplerAnnotationProxy::notifyModification``, `ppl_txtann->setTextColor( okl_txtann->textColor() );`` is never get called. Why is this happening even after setting the flag in both CMakeLists.txt and annots.cpp? dileepsankhla: I have added the following lines in generator/poppler/CMakeLists.txt:
```… | |||||
Is the flag really set (check in build/generators/poppler/config-okular-poppler.h)? If not: throw away the content of your 'build' directory and try again from scratch. sander: Is the flag really set (check in build/generators/poppler/config-okular-poppler.h)? If not… | |||||
Hm, for me it works. By reading your comment I suppose you missed to add /* Defined if we have the 0.67 version of the Poppler library */ #cmakedefine HAVE_POPPLER_0_67 1 to config-okular-poppler.h.cmake, is it? From cmake hellp: #cmakedefine VAR ... will be replaced with either: #define VAR ... or: /* #undef VAR */ depending on whether VAR is set in CMake to any value not considered a false constant by the if() command tobiasdeiminger: Hm, for me it works. By reading your comment I suppose you missed to add
```
/* Defined if we… | |||||
183 | ppl_txtann->setCalloutPoints( QVector<QPointF>() ); | 183 | ppl_txtann->setCalloutPoints( QVector<QPointF>() ); | ||
184 | ppl_txtann->setInplaceIntent( (Poppler::TextAnnotation::InplaceIntent)okl_txtann->inplaceIntent() ); | 184 | ppl_txtann->setInplaceIntent( (Poppler::TextAnnotation::InplaceIntent)okl_txtann->inplaceIntent() ); | ||
185 | break; | 185 | break; | ||
186 | } | 186 | } | ||
187 | case Poppler::Annotation::ALine: | 187 | case Poppler::Annotation::ALine: | ||
188 | { | 188 | { | ||
189 | const Okular::LineAnnotation * okl_lineann = static_cast<const Okular::LineAnnotation*>(okl_ann); | 189 | const Okular::LineAnnotation * okl_lineann = static_cast<const Okular::LineAnnotation*>(okl_ann); | ||
190 | Poppler::LineAnnotation * ppl_lineann = static_cast<Poppler::LineAnnotation*>(ppl_ann); | 190 | Poppler::LineAnnotation * ppl_lineann = static_cast<Poppler::LineAnnotation*>(ppl_ann); | ||
▲ Show 20 Lines • Show All 237 Lines • Show Last 20 Lines |
Poppler::TextAnnotation::setTextFont is brand new poppler API (actually not yet merged). We still want to support builds with older poppler versions. So setTextFont needs to be surrounded by some
where 0_xy is the poppler release for which we assume the API to be released. Maybe 0_67, to be optimistic.
To detect poppler version at build time, add a check_cxx_source_compiles for Poppler::TextAnnotation::setTextFont and define HAVE_POPPLER_0_67 accordingly in generators/poppler/CMakeLists.txt. Also add a cmakedefine to generators/poppler/CMakeLists.txt. You'll find existing examples for other versions if you look at these files.