Added 3 custom attributes to the Highlight annotation. Adapted pdf parser

and xml storage stuff.

svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=403983
remotes/origin/kpdf-annotations
Enrico Ros 21 years ago
parent 57f0453b73
commit 850b7b7f53
  1. 48
      core/annotations.cpp
  2. 9
      core/annotations.h
  3. 14
      core/generator_pdf/generator_pdf.cpp

@ -604,16 +604,19 @@ HighlightAnnotation::HighlightAnnotation( const QDomNode & node )
if ( qe.tagName() != "quad" ) if ( qe.tagName() != "quad" )
continue; continue;
NormalizedPoint p[4]; Quad q;
p[0].x = qe.attribute( "ax", "0.0" ).toDouble(); q.points[0].x = qe.attribute( "ax", "0.0" ).toDouble();
p[0].y = qe.attribute( "ay", "0.0" ).toDouble(); q.points[0].y = qe.attribute( "ay", "0.0" ).toDouble();
p[1].x = qe.attribute( "bx", "0.0" ).toDouble(); q.points[1].x = qe.attribute( "bx", "0.0" ).toDouble();
p[1].y = qe.attribute( "by", "0.0" ).toDouble(); q.points[1].y = qe.attribute( "by", "0.0" ).toDouble();
p[2].x = qe.attribute( "cx", "0.0" ).toDouble(); q.points[2].x = qe.attribute( "cx", "0.0" ).toDouble();
p[2].y = qe.attribute( "cy", "0.0" ).toDouble(); q.points[2].y = qe.attribute( "cy", "0.0" ).toDouble();
p[3].x = qe.attribute( "dx", "0.0" ).toDouble(); q.points[3].x = qe.attribute( "dx", "0.0" ).toDouble();
p[3].y = qe.attribute( "dy", "0.0" ).toDouble(); q.points[3].y = qe.attribute( "dy", "0.0" ).toDouble();
highlightQuads.append( p ); q.capStart = qe.hasAttribute( "start" );
q.capEnd = qe.hasAttribute( "end" );
q.feather = qe.attribute( "feather", "0.1" ).toDouble();
highlightQuads.append( q );
} }
// loading complete // loading complete
@ -636,20 +639,25 @@ void HighlightAnnotation::store( QDomNode & node, QDomDocument & document ) cons
if ( highlightQuads.count() < 1 ) if ( highlightQuads.count() < 1 )
return; return;
// append highlight quads, all children describe quads // append highlight quads, all children describe quads
QValueList<NormalizedPoint[4]>::const_iterator it = highlightQuads.begin(), end = highlightQuads.end(); QValueList< Quad >::const_iterator it = highlightQuads.begin(), end = highlightQuads.end();
for ( ; it != end; ++it ) for ( ; it != end; ++it )
{ {
QDomElement quadElement = document.createElement( "quad" ); QDomElement quadElement = document.createElement( "quad" );
hlElement.appendChild( quadElement ); hlElement.appendChild( quadElement );
const NormalizedPoint * p = *it; const Quad & q = *it;
quadElement.setAttribute( "ax", p[0].x ); quadElement.setAttribute( "ax", q.points[0].x );
quadElement.setAttribute( "ay", p[0].y ); quadElement.setAttribute( "ay", q.points[0].y );
quadElement.setAttribute( "bx", p[1].x ); quadElement.setAttribute( "bx", q.points[1].x );
quadElement.setAttribute( "by", p[1].y ); quadElement.setAttribute( "by", q.points[1].y );
quadElement.setAttribute( "cx", p[2].x ); quadElement.setAttribute( "cx", q.points[2].x );
quadElement.setAttribute( "cy", p[2].y ); quadElement.setAttribute( "cy", q.points[2].y );
quadElement.setAttribute( "dx", p[3].x ); quadElement.setAttribute( "dx", q.points[3].x );
quadElement.setAttribute( "dy", p[3].y ); quadElement.setAttribute( "dy", q.points[3].y );
if ( q.capStart )
quadElement.setAttribute( "start", 1 );
if ( q.capEnd )
quadElement.setAttribute( "end", 1 );
quadElement.setAttribute( "feather", q.feather );
} }
} }

@ -210,7 +210,14 @@ struct HighlightAnnotation : public Annotation
// data fields // data fields
HighlightType highlightType; // Highlight HighlightType highlightType; // Highlight
QValueList<NormalizedPoint[4]> highlightQuads; struct Quad
{
NormalizedPoint points[4]; // 8 valid coords
bool capStart; // false (vtx 1-4) [K]
bool capEnd; // false (vtx 2-3) [K]
double feather; // 0.1 (in range 0..1) [K]
};
QValueList< Quad > highlightQuads; // not empty
}; };
struct StampAnnotation : public Annotation struct StampAnnotation : public Annotation

@ -1068,12 +1068,16 @@ void PDFGenerator::addAnnotations( Page * pdfPage, KPDFPage * page )
annot.free(); annot.free();
continue; continue;
} }
for ( int p = 0; p < num; p += 8 ) for ( int q = 0; q < num; q += 8 )
{ {
NormalizedPoint quad[4]; HighlightAnnotation::Quad quad;
for ( int q = 0; q < 4; q++ ) for ( int p = 0; p < 4; p++ )
XPDFReader::transform( MTX, c[ p + q*2 ], c[ p + q*2 + 1 ], &quad[q].x, &quad[q].y ); XPDFReader::transform( MTX, c[ q + p*2 ], c[ q + p*2 + 1 ],
h->highlightQuads.push_back( quad ); &quad.points[ p ].x, &quad.points[ p ].y );
quad.capStart = true; // unlinked quads are always capped
quad.capEnd = true; // unlinked quads are always capped
quad.feather = 0.1; // default feather
h->highlightQuads.append( quad );
} }
} }
else if ( subType == "Stamp" ) else if ( subType == "Stamp" )

Loading…
Cancel
Save