2005-02-12 17:42:54 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2007-04-19 18:30:20 +00:00
|
|
|
#include "annotations.h"
|
2007-05-04 20:24:12 +00:00
|
|
|
#include "annotations_p.h"
|
2007-04-19 18:30:20 +00:00
|
|
|
|
2005-03-04 23:06:24 +00:00
|
|
|
// qt/kde includes
|
2006-09-21 08:45:36 +00:00
|
|
|
#include <QtGui/QApplication>
|
|
|
|
#include <QtGui/QColor>
|
|
|
|
|
2007-07-17 18:10:25 +00:00
|
|
|
// local includes
|
|
|
|
#include "page_p.h"
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
using namespace Okular;
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
//BEGIN AnnotationUtils implementation
|
|
|
|
Annotation * AnnotationUtils::createAnnotation( const QDomElement & annElement )
|
2005-04-04 23:55:40 +00:00
|
|
|
{
|
2005-04-07 19:27:54 +00:00
|
|
|
// safety check on annotation element
|
2005-04-04 23:55:40 +00:00
|
|
|
if ( !annElement.hasAttribute( "type" ) )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// build annotation of given type
|
|
|
|
Annotation * annotation = 0;
|
|
|
|
int typeNumber = annElement.attribute( "type" ).toInt();
|
|
|
|
switch ( typeNumber )
|
|
|
|
{
|
|
|
|
case Annotation::AText:
|
|
|
|
annotation = new TextAnnotation( annElement );
|
|
|
|
break;
|
|
|
|
case Annotation::ALine:
|
|
|
|
annotation = new LineAnnotation( annElement );
|
|
|
|
break;
|
|
|
|
case Annotation::AGeom:
|
|
|
|
annotation = new GeomAnnotation( annElement );
|
|
|
|
break;
|
|
|
|
case Annotation::AHighlight:
|
|
|
|
annotation = new HighlightAnnotation( annElement );
|
|
|
|
break;
|
|
|
|
case Annotation::AStamp:
|
|
|
|
annotation = new StampAnnotation( annElement );
|
|
|
|
break;
|
|
|
|
case Annotation::AInk:
|
|
|
|
annotation = new InkAnnotation( annElement );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return created annotation
|
|
|
|
return annotation;
|
|
|
|
}
|
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
void AnnotationUtils::storeAnnotation( const Annotation * ann, QDomElement & annElement,
|
2005-04-04 23:55:40 +00:00
|
|
|
QDomDocument & document )
|
|
|
|
{
|
2005-04-07 19:27:54 +00:00
|
|
|
// save annotation's type as element's attribute
|
|
|
|
annElement.setAttribute( "type", (uint)ann->subType() );
|
2005-03-04 23:06:24 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
// append all annotation data as children of this node
|
|
|
|
ann->store( annElement, document );
|
|
|
|
}
|
2005-04-04 23:55:40 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
QDomElement AnnotationUtils::findChildElement( const QDomNode & parentNode,
|
|
|
|
const QString & name )
|
|
|
|
{
|
|
|
|
// loop through the whole children and return a 'name' named element
|
|
|
|
QDomNode subNode = parentNode.firstChild();
|
|
|
|
while( subNode.isElement() )
|
|
|
|
{
|
|
|
|
QDomElement element = subNode.toElement();
|
|
|
|
if ( element.tagName() == name )
|
|
|
|
return element;
|
|
|
|
subNode = subNode.nextSibling();
|
|
|
|
}
|
|
|
|
// if the name can't be found, return a dummy null element
|
|
|
|
return QDomElement();
|
2005-04-04 23:55:40 +00:00
|
|
|
}
|
2006-10-07 11:00:39 +00:00
|
|
|
|
2006-11-21 21:35:45 +00:00
|
|
|
QRect AnnotationUtils::annotationGeometry( const Annotation * ann,
|
|
|
|
double scaledWidth, double scaledHeight )
|
|
|
|
{
|
2006-12-11 07:59:02 +00:00
|
|
|
if ( ann->subType() == Annotation::AText && ( ( (TextAnnotation*)ann )->textType() == TextAnnotation::Linked ) )
|
2006-11-21 21:35:45 +00:00
|
|
|
{
|
2006-12-05 11:05:50 +00:00
|
|
|
return QRect( (int)( ann->transformedBoundingRectangle().left * scaledWidth ),
|
|
|
|
(int)( ann->transformedBoundingRectangle().top * scaledHeight ), 24, 24 );
|
2006-11-21 21:35:45 +00:00
|
|
|
}
|
|
|
|
|
2006-12-05 11:05:50 +00:00
|
|
|
return ann->transformedBoundingRectangle().geometry( (int)scaledWidth, (int)scaledHeight );
|
2006-11-21 21:35:45 +00:00
|
|
|
}
|
2005-04-07 19:27:54 +00:00
|
|
|
//END AnnotationUtils implementation
|
2005-04-04 23:55:40 +00:00
|
|
|
|
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
//BEGIN Annotation implementation
|
2006-12-18 07:28:02 +00:00
|
|
|
|
|
|
|
class Annotation::Style::Private
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Private()
|
|
|
|
: m_opacity( 1.0 ), m_width( 1.0 ), m_style( Solid ), m_xCorners( 0.0 ),
|
|
|
|
m_yCorners( 0.0 ), m_marks( 3 ), m_spaces( 0 ), m_effect( NoEffect ),
|
|
|
|
m_effectIntensity( 1.0 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor m_color;
|
|
|
|
double m_opacity;
|
|
|
|
double m_width;
|
|
|
|
LineStyle m_style;
|
|
|
|
double m_xCorners;
|
|
|
|
double m_yCorners;
|
|
|
|
int m_marks;
|
|
|
|
int m_spaces;
|
|
|
|
LineEffect m_effect;
|
|
|
|
double m_effectIntensity;
|
|
|
|
};
|
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
Annotation::Style::Style()
|
2006-12-18 07:28:02 +00:00
|
|
|
: d( new Private )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::Style::~Style()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::Style::Style( const Style &other )
|
|
|
|
: d( new Private )
|
|
|
|
{
|
|
|
|
*d = *other.d;
|
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::Style& Annotation::Style::operator=( const Style &other )
|
2006-12-05 11:05:50 +00:00
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( this != &other )
|
|
|
|
*d = *other.d;
|
|
|
|
|
|
|
|
return *this;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Style::setColor( const QColor &color )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_color = color;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QColor Annotation::Style::color() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_color;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Style::setOpacity( double opacity )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_opacity = opacity;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double Annotation::Style::opacity() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_opacity;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Style::setWidth( double width )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_width = width;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double Annotation::Style::width() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_width;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Style::setLineStyle( LineStyle style )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_style = style;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::LineStyle Annotation::Style::lineStyle() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_style;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Style::setXCorners( double xCorners )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_xCorners = xCorners;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double Annotation::Style::xCorners() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_xCorners;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Style::setYCorners( double yCorners )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_yCorners = yCorners;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double Annotation::Style::yCorners() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_yCorners;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Style::setMarks( int marks )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_marks = marks;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Annotation::Style::marks() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_marks;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Style::setSpaces( int spaces )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_spaces = spaces;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Annotation::Style::spaces() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_spaces;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Style::setLineEffect( LineEffect effect )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_effect = effect;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::LineEffect Annotation::Style::lineEffect() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_effect;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Style::setEffectIntensity( double intensity )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_effectIntensity = intensity;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double Annotation::Style::effectIntensity() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_effectIntensity;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
class Annotation::Window::Private
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Private()
|
|
|
|
: m_flags( -1 ), m_width( 0 ), m_height( 0 )
|
|
|
|
{
|
|
|
|
}
|
2006-12-05 11:05:50 +00:00
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
int m_flags;
|
|
|
|
NormalizedPoint m_topLeft;
|
|
|
|
int m_width;
|
|
|
|
int m_height;
|
|
|
|
QString m_title;
|
|
|
|
QString m_summary;
|
|
|
|
QString m_text;
|
|
|
|
};
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
|
2005-04-04 23:55:40 +00:00
|
|
|
Annotation::Window::Window()
|
2006-12-18 07:28:02 +00:00
|
|
|
: d( new Private )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::Window::~Window()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::Window::Window( const Window &other )
|
|
|
|
: d( new Private )
|
2006-12-05 11:05:50 +00:00
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
*d = *other.d;
|
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::Window& Annotation::Window::operator=( const Window &other )
|
|
|
|
{
|
|
|
|
if ( this != &other )
|
|
|
|
*d = *other.d;
|
|
|
|
|
|
|
|
return *this;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Window::setFlags( int flags )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_flags = flags;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Annotation::Window::flags() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_flags;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Window::setTopLeft( const NormalizedPoint &point )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_topLeft = point;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NormalizedPoint Annotation::Window::topLeft() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_topLeft;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Window::setWidth( int width )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_width = width;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Annotation::Window::width() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_width;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Window::setHeight( int height )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_height = height;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Annotation::Window::height() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_height;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Window::setTitle( const QString &title )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_title = title;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Annotation::Window::title() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_title;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Window::setSummary( const QString &summary )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_summary = summary;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Annotation::Window::summary() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_summary;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Window::setText( const QString &text )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_text = text;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Annotation::Window::text() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_text;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
class Annotation::Revision::Private
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Private()
|
|
|
|
: m_annotation( 0 ), m_scope( Reply ), m_type( None )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Annotation *m_annotation;
|
|
|
|
RevisionScope m_scope;
|
|
|
|
RevisionType m_type;
|
|
|
|
};
|
2005-04-04 23:55:40 +00:00
|
|
|
|
|
|
|
Annotation::Revision::Revision()
|
2006-12-18 07:28:02 +00:00
|
|
|
: d( new Private )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::Revision::~Revision()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::Revision::Revision( const Revision &other )
|
|
|
|
: d( new Private )
|
2006-12-05 11:05:50 +00:00
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
*d = *other.d;
|
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::Revision& Annotation::Revision::operator=( const Revision &other )
|
|
|
|
{
|
|
|
|
if ( this != &other )
|
|
|
|
*d = *other.d;
|
|
|
|
|
|
|
|
return *this;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Revision::setAnnotation( Annotation *annotation )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_annotation = annotation;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Annotation *Annotation::Revision::annotation() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_annotation;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Revision::setScope( RevisionScope scope )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_scope = scope;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::RevisionScope Annotation::Revision::scope() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_scope;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::Revision::setType( RevisionType type )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_type = type;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::RevisionType Annotation::Revision::type() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_type;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
AnnotationPrivate::AnnotationPrivate()
|
2007-07-17 18:10:25 +00:00
|
|
|
: m_page( 0 ), m_flags( 0 )
|
2006-12-05 11:05:50 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
}
|
2006-12-18 07:28:02 +00:00
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
AnnotationPrivate::~AnnotationPrivate()
|
|
|
|
{
|
|
|
|
// delete all children revisions
|
|
|
|
if ( m_revisions.isEmpty() )
|
|
|
|
return;
|
2006-12-18 07:28:02 +00:00
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
QLinkedList< Annotation::Revision >::iterator it = m_revisions.begin(), end = m_revisions.end();
|
|
|
|
for ( ; it != end; ++it )
|
|
|
|
delete (*it).annotation();
|
|
|
|
}
|
2006-12-18 07:28:02 +00:00
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
Annotation::Annotation( AnnotationPrivate &dd )
|
|
|
|
: d_ptr( &dd )
|
2006-12-18 07:28:02 +00:00
|
|
|
{
|
2005-04-04 23:55:40 +00:00
|
|
|
}
|
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
Annotation::Annotation( AnnotationPrivate &dd, const QDomNode & annNode )
|
|
|
|
: d_ptr( &dd )
|
2005-04-07 19:27:54 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( Annotation );
|
2005-04-07 19:27:54 +00:00
|
|
|
// get the [base] element of the annotation node
|
|
|
|
QDomElement e = AnnotationUtils::findChildElement( annNode, "base" );
|
|
|
|
if ( e.isNull() )
|
|
|
|
return;
|
2005-03-18 18:49:45 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
// parse -contents- attributes
|
|
|
|
if ( e.hasAttribute( "author" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_author = e.attribute( "author" );
|
2005-04-07 19:27:54 +00:00
|
|
|
if ( e.hasAttribute( "contents" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_contents = e.attribute( "contents" );
|
2005-04-07 19:27:54 +00:00
|
|
|
if ( e.hasAttribute( "uniqueName" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_uniqueName = e.attribute( "uniqueName" );
|
2005-04-07 19:27:54 +00:00
|
|
|
if ( e.hasAttribute( "modifyDate" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_modifyDate = QDateTime::fromString( e.attribute("modifyDate"), Qt::ISODate );
|
2005-04-07 19:27:54 +00:00
|
|
|
if ( e.hasAttribute( "creationDate" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_creationDate = QDateTime::fromString( e.attribute("creationDate"), Qt::ISODate );
|
2005-04-07 19:27:54 +00:00
|
|
|
|
|
|
|
// parse -other- attributes
|
|
|
|
if ( e.hasAttribute( "flags" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_flags = e.attribute( "flags" ).toInt();
|
2005-04-07 19:27:54 +00:00
|
|
|
if ( e.hasAttribute( "color" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_style.setColor( QColor( e.attribute( "color" ) ) );
|
2005-04-07 19:27:54 +00:00
|
|
|
if ( e.hasAttribute( "opacity" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_style.setOpacity( e.attribute( "opacity" ).toDouble() );
|
2005-04-07 19:27:54 +00:00
|
|
|
|
|
|
|
// parse -the-subnodes- (describing Style, Window, Revision(s) structures)
|
|
|
|
// Note: all subnodes if present must be 'attributes complete'
|
|
|
|
QDomNode eSubNode = e.firstChild();
|
|
|
|
while ( eSubNode.isElement() )
|
|
|
|
{
|
|
|
|
QDomElement ee = eSubNode.toElement();
|
|
|
|
eSubNode = eSubNode.nextSibling();
|
2005-03-18 18:49:45 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
// parse boundary
|
|
|
|
if ( ee.tagName() == "boundary" )
|
2005-03-18 18:49:45 +00:00
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_boundary=NormalizedRect(ee.attribute( "l" ).toDouble(),
|
- GIGANTIC 2700 line diff with LOTS OF FEATURES!
- 1. editor-like text selection, and I do mean it, its not pseudo-editor
(like the ones acroread and kviewshell have) it doesnt intersect the
selection area with words under it, no, it does a lot more, including
work on cursors and searching for the text area closest to the given
cursor
- 2. rotation support, change the orientation of the documents if
you need too :)
- 3. the kfaxview backend works beautifully, porting kviewshell backends
is damn easy ! djvu and dvi will be next!
- 4. Hardware Blending of selection rectangles! We now use XRender
instead of KImageEffect, makes a damn faster blend!
- 5. Overview mode - as seen in Kviewshell, but quite a bit extended,
the kviewshell is only one state, while we support it in both
continous and non-continous form
- BTW. I coded all those features myself, (apart from kfaxview backend library)
it is an impressive bit right? but oKular cant be run by only one person,
join in on the fun! i can introduce you into the code just mail niedakh@gmail.com
svn path=/trunk/playground/graphics/oKular/kpdf/; revision=509871
2006-02-15 18:54:49 +00:00
|
|
|
ee.attribute( "t" ).toDouble(),
|
|
|
|
ee.attribute( "r" ).toDouble(),
|
|
|
|
ee.attribute( "b" ).toDouble());
|
2005-04-07 19:27:54 +00:00
|
|
|
}
|
|
|
|
// parse penStyle if not default
|
|
|
|
else if ( ee.tagName() == "penStyle" )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_style.setWidth( ee.attribute( "width" ).toDouble() );
|
|
|
|
d->m_style.setLineStyle( (LineStyle)ee.attribute( "style" ).toInt() );
|
|
|
|
d->m_style.setXCorners( ee.attribute( "xcr" ).toDouble() );
|
|
|
|
d->m_style.setYCorners( ee.attribute( "ycr" ).toDouble() );
|
|
|
|
d->m_style.setMarks( ee.attribute( "marks" ).toInt() );
|
|
|
|
d->m_style.setSpaces( ee.attribute( "spaces" ).toInt() );
|
2005-04-07 19:27:54 +00:00
|
|
|
}
|
|
|
|
// parse effectStyle if not default
|
|
|
|
else if ( ee.tagName() == "penEffect" )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_style.setLineEffect( (LineEffect)ee.attribute( "effect" ).toInt() );
|
|
|
|
d->m_style.setEffectIntensity( ee.attribute( "intensity" ).toDouble() );
|
2005-04-07 19:27:54 +00:00
|
|
|
}
|
|
|
|
// parse window if present
|
|
|
|
else if ( ee.tagName() == "window" )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_window.setFlags( ee.attribute( "flags" ).toInt() );
|
|
|
|
d->m_window.setTopLeft( NormalizedPoint( ee.attribute( "top" ).toDouble(),
|
2006-12-05 11:05:50 +00:00
|
|
|
ee.attribute( "left" ).toDouble() ) );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_window.setWidth( ee.attribute( "width" ).toInt() );
|
|
|
|
d->m_window.setHeight( ee.attribute( "height" ).toInt() );
|
|
|
|
d->m_window.setTitle( ee.attribute( "title" ) );
|
|
|
|
d->m_window.setSummary( ee.attribute( "summary" ) );
|
2005-04-07 19:27:54 +00:00
|
|
|
// parse window subnodes
|
|
|
|
QDomNode winNode = ee.firstChild();
|
|
|
|
for ( ; winNode.isElement(); winNode = winNode.nextSibling() )
|
2005-03-18 18:49:45 +00:00
|
|
|
{
|
2005-04-07 19:27:54 +00:00
|
|
|
QDomElement winElement = winNode.toElement();
|
|
|
|
if ( winElement.tagName() == "text" )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_window.setText( winElement.firstChild().toCDATASection().data() );
|
2005-03-18 18:49:45 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-07 19:27:54 +00:00
|
|
|
}
|
2005-04-04 23:55:40 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
// get the [revisions] element of the annotation node
|
|
|
|
QDomNode revNode = annNode.firstChild();
|
|
|
|
for ( ; revNode.isElement(); revNode = revNode.nextSibling() )
|
|
|
|
{
|
|
|
|
QDomElement revElement = revNode.toElement();
|
|
|
|
if ( revElement.tagName() != "revision" )
|
|
|
|
continue;
|
2005-03-18 18:49:45 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
// compile the Revision structure crating annotation
|
2006-12-05 11:05:50 +00:00
|
|
|
Revision revision;
|
|
|
|
revision.setScope( (RevisionScope)revElement.attribute( "revScope" ).toInt() );
|
|
|
|
revision.setType( (RevisionType)revElement.attribute( "revType" ).toInt() );
|
|
|
|
revision.setAnnotation( AnnotationUtils::createAnnotation( revElement ) );
|
2005-04-07 19:27:54 +00:00
|
|
|
|
|
|
|
// if annotation is valid, add revision to internal list
|
2007-02-09 14:53:26 +00:00
|
|
|
if ( revision.annotation() )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_revisions.append( revision );
|
2005-04-07 19:27:54 +00:00
|
|
|
}
|
2006-11-20 07:53:32 +00:00
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_transformedBoundary = d->m_boundary;
|
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::~Annotation()
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
delete d_ptr;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::setAuthor( const QString &author )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_author = author;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Annotation::author() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_author;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::setContents( const QString &contents )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_contents = contents;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Annotation::contents() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_contents;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::setUniqueName( const QString &name )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_uniqueName = name;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Annotation::uniqueName() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_uniqueName;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::setModificationDate( const QDateTime &date )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_modifyDate = date;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QDateTime Annotation::modificationDate() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_modifyDate;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::setCreationDate( const QDateTime &date )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_creationDate = date;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QDateTime Annotation::creationDate() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_creationDate;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::setFlags( int flags )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_flags = flags;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Annotation::flags() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_flags;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::setBoundingRectangle( const NormalizedRect &rectangle )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_boundary = rectangle;
|
2007-07-22 20:49:27 +00:00
|
|
|
d->resetTransformation();
|
2007-07-17 18:10:25 +00:00
|
|
|
if ( d->m_page )
|
|
|
|
{
|
|
|
|
d->transform( d->m_page->rotationMatrix() );
|
|
|
|
}
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NormalizedRect Annotation::boundingRectangle() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_boundary;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NormalizedRect Annotation::transformedBoundingRectangle() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_transformedBoundary;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
2007-07-17 18:10:25 +00:00
|
|
|
void Annotation::translate( const NormalizedPoint &coord )
|
|
|
|
{
|
|
|
|
Q_D( Annotation );
|
|
|
|
d->translate( coord );
|
2007-07-22 20:49:27 +00:00
|
|
|
d->resetTransformation();
|
2007-07-17 18:10:25 +00:00
|
|
|
if ( d->m_page )
|
|
|
|
{
|
|
|
|
d->transform( d->m_page->rotationMatrix() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-05 11:05:50 +00:00
|
|
|
Annotation::Style & Annotation::style()
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_style;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const Annotation::Style & Annotation::style() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_style;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::Window & Annotation::window()
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_window;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const Annotation::Window & Annotation::window() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_window;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QLinkedList< Annotation::Revision > & Annotation::revisions()
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_revisions;
|
2006-12-05 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const QLinkedList< Annotation::Revision > & Annotation::revisions() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const Annotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_revisions;
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
void Annotation::store( QDomNode & annNode, QDomDocument & document ) const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const Annotation );
|
2005-04-07 19:27:54 +00:00
|
|
|
// create [base] element of the annotation node
|
|
|
|
QDomElement e = document.createElement( "base" );
|
|
|
|
annNode.appendChild( e );
|
2005-03-18 18:49:45 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
// store -contents- attributes
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( !d->m_author.isEmpty() )
|
|
|
|
e.setAttribute( "author", d->m_author );
|
|
|
|
if ( !d->m_contents.isEmpty() )
|
|
|
|
e.setAttribute( "contents", d->m_contents );
|
|
|
|
if ( !d->m_uniqueName.isEmpty() )
|
|
|
|
e.setAttribute( "uniqueName", d->m_uniqueName );
|
|
|
|
if ( d->m_modifyDate.isValid() )
|
|
|
|
e.setAttribute( "modifyDate", d->m_modifyDate.toString(Qt::ISODate) );
|
|
|
|
if ( d->m_creationDate.isValid() )
|
|
|
|
e.setAttribute( "creationDate", d->m_creationDate.toString(Qt::ISODate) );
|
2005-04-07 19:27:54 +00:00
|
|
|
|
|
|
|
// store -other- attributes
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( d->m_flags )
|
|
|
|
e.setAttribute( "flags", d->m_flags );
|
|
|
|
if ( d->m_style.color().isValid() )
|
|
|
|
e.setAttribute( "color", d->m_style.color().name() );
|
|
|
|
if ( d->m_style.opacity() != 1.0 )
|
|
|
|
e.setAttribute( "opacity", d->m_style.opacity() );
|
2005-04-07 19:27:54 +00:00
|
|
|
|
|
|
|
// Sub-Node-1 - boundary
|
|
|
|
QDomElement bE = document.createElement( "boundary" );
|
|
|
|
e.appendChild( bE );
|
2006-12-18 07:28:02 +00:00
|
|
|
bE.setAttribute( "l", (double)d->m_boundary.left );
|
|
|
|
bE.setAttribute( "t", (double)d->m_boundary.top );
|
|
|
|
bE.setAttribute( "r", (double)d->m_boundary.right );
|
|
|
|
bE.setAttribute( "b", (double)d->m_boundary.bottom );
|
2005-04-07 19:27:54 +00:00
|
|
|
|
|
|
|
// Sub-Node-2 - penStyle
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( d->m_style.width() != 1 || d->m_style.lineStyle() != Solid || d->m_style.xCorners() != 0 ||
|
|
|
|
d->m_style.yCorners() != 0.0 || d->m_style.marks() != 3 || d->m_style.spaces() != 0 )
|
2005-03-18 18:49:45 +00:00
|
|
|
{
|
2005-04-07 19:27:54 +00:00
|
|
|
QDomElement psE = document.createElement( "penStyle" );
|
|
|
|
e.appendChild( psE );
|
2006-12-18 07:28:02 +00:00
|
|
|
psE.setAttribute( "width", d->m_style.width() );
|
|
|
|
psE.setAttribute( "style", (int)d->m_style.lineStyle() );
|
|
|
|
psE.setAttribute( "xcr", d->m_style.xCorners() );
|
|
|
|
psE.setAttribute( "ycr", d->m_style.yCorners() );
|
|
|
|
psE.setAttribute( "marks", d->m_style.marks() );
|
|
|
|
psE.setAttribute( "spaces", d->m_style.spaces() );
|
2005-03-18 18:49:45 +00:00
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
// Sub-Node-3 - penEffect
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( d->m_style.lineEffect() != NoEffect || d->m_style.effectIntensity() != 1.0 )
|
2005-03-18 18:49:45 +00:00
|
|
|
{
|
2005-04-07 19:27:54 +00:00
|
|
|
QDomElement peE = document.createElement( "penEffect" );
|
|
|
|
e.appendChild( peE );
|
2006-12-18 07:28:02 +00:00
|
|
|
peE.setAttribute( "effect", (int)d->m_style.lineEffect() );
|
|
|
|
peE.setAttribute( "intensity", d->m_style.effectIntensity() );
|
2005-04-07 19:27:54 +00:00
|
|
|
}
|
2005-03-18 18:49:45 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
// Sub-Node-4 - window
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( d->m_window.flags() != -1 || !d->m_window.title().isEmpty() ||
|
|
|
|
!d->m_window.summary().isEmpty() || !d->m_window.text().isEmpty() )
|
2005-04-07 19:27:54 +00:00
|
|
|
{
|
|
|
|
QDomElement wE = document.createElement( "window" );
|
|
|
|
e.appendChild( wE );
|
2006-12-18 07:28:02 +00:00
|
|
|
wE.setAttribute( "flags", d->m_window.flags() );
|
|
|
|
wE.setAttribute( "top", d->m_window.topLeft().x );
|
|
|
|
wE.setAttribute( "left", d->m_window.topLeft().y );
|
|
|
|
wE.setAttribute( "width", d->m_window.width() );
|
|
|
|
wE.setAttribute( "height", d->m_window.height() );
|
|
|
|
wE.setAttribute( "title", d->m_window.title() );
|
|
|
|
wE.setAttribute( "summary", d->m_window.summary() );
|
2005-04-07 19:27:54 +00:00
|
|
|
// store window.text as a subnode, because we need escaped data
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( !d->m_window.text().isEmpty() )
|
2005-03-18 18:49:45 +00:00
|
|
|
{
|
2005-04-07 19:27:54 +00:00
|
|
|
QDomElement escapedText = document.createElement( "text" );
|
|
|
|
wE.appendChild( escapedText );
|
2006-12-18 07:28:02 +00:00
|
|
|
QDomCDATASection textCData = document.createCDATASection( d->m_window.text() );
|
2005-04-07 19:27:54 +00:00
|
|
|
escapedText.appendChild( textCData );
|
2005-03-18 18:49:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
// create [revision] element of the annotation node (if any)
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( d->m_revisions.isEmpty() )
|
2005-04-07 19:27:54 +00:00
|
|
|
return;
|
2005-03-18 18:49:45 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
// add all revisions as children of revisions element
|
2006-12-18 07:28:02 +00:00
|
|
|
QLinkedList< Revision >::const_iterator it = d->m_revisions.begin(), end = d->m_revisions.end();
|
2005-04-07 19:27:54 +00:00
|
|
|
for ( ; it != end; ++it )
|
2005-04-04 23:55:40 +00:00
|
|
|
{
|
2005-04-07 19:27:54 +00:00
|
|
|
// create revision element
|
|
|
|
const Revision & revision = *it;
|
|
|
|
QDomElement r = document.createElement( "revision" );
|
|
|
|
annNode.appendChild( r );
|
|
|
|
// set element attributes
|
2006-12-05 11:05:50 +00:00
|
|
|
r.setAttribute( "revScope", (int)revision.scope() );
|
|
|
|
r.setAttribute( "revType", (int)revision.type() );
|
2005-04-07 19:27:54 +00:00
|
|
|
// use revision as the annotation element, so fill it up
|
2006-12-05 11:05:50 +00:00
|
|
|
AnnotationUtils::storeAnnotation( revision.annotation(), r, document );
|
2005-04-04 23:55:40 +00:00
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
2006-11-20 07:53:32 +00:00
|
|
|
|
2007-07-22 20:49:27 +00:00
|
|
|
void AnnotationPrivate::annotationTransform( const QMatrix &matrix )
|
|
|
|
{
|
|
|
|
resetTransformation();
|
|
|
|
transform( matrix );
|
|
|
|
}
|
|
|
|
|
2007-05-04 20:45:45 +00:00
|
|
|
void AnnotationPrivate::transform( const QMatrix &matrix )
|
2006-11-20 07:53:32 +00:00
|
|
|
{
|
2007-05-04 20:45:45 +00:00
|
|
|
m_transformedBoundary.transform( matrix );
|
2006-11-20 07:53:32 +00:00
|
|
|
}
|
|
|
|
|
2007-10-07 10:52:05 +00:00
|
|
|
void AnnotationPrivate::baseTransform( const QMatrix &matrix )
|
|
|
|
{
|
|
|
|
m_boundary.transform( matrix );
|
|
|
|
}
|
|
|
|
|
2007-07-22 20:49:27 +00:00
|
|
|
void AnnotationPrivate::resetTransformation()
|
|
|
|
{
|
|
|
|
m_transformedBoundary = m_boundary;
|
|
|
|
}
|
|
|
|
|
2007-07-17 18:10:25 +00:00
|
|
|
void AnnotationPrivate::translate( const NormalizedPoint &coord )
|
|
|
|
{
|
|
|
|
m_boundary.left = m_boundary.left + coord.x;
|
|
|
|
m_boundary.right = m_boundary.right + coord.x;
|
|
|
|
m_boundary.top = m_boundary.top + coord.y;
|
|
|
|
m_boundary.bottom = m_boundary.bottom + coord.y;
|
|
|
|
}
|
|
|
|
|
2006-11-20 07:53:32 +00:00
|
|
|
//END Annotation implementation
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
|
|
|
|
/** TextAnnotation [Annotation] */
|
2006-12-18 07:28:02 +00:00
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
class Okular::TextAnnotationPrivate : public Okular::AnnotationPrivate
|
2006-12-18 07:28:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-05-04 20:24:12 +00:00
|
|
|
TextAnnotationPrivate()
|
|
|
|
: AnnotationPrivate(), m_textType( TextAnnotation::Linked ),
|
|
|
|
m_textIcon( "Note" ), m_inplaceAlign( 0 ),
|
|
|
|
m_inplaceIntent( TextAnnotation::Unknown )
|
2006-12-18 07:28:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-04 20:45:45 +00:00
|
|
|
virtual void transform( const QMatrix &matrix );
|
2007-10-07 10:52:05 +00:00
|
|
|
virtual void baseTransform( const QMatrix &matrix );
|
2007-07-22 20:49:27 +00:00
|
|
|
virtual void resetTransformation();
|
2007-07-22 20:20:24 +00:00
|
|
|
virtual void translate( const NormalizedPoint &coord );
|
2007-05-04 20:45:45 +00:00
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
TextAnnotation::TextType m_textType;
|
2006-12-18 07:28:02 +00:00
|
|
|
QString m_textIcon;
|
|
|
|
QFont m_textFont;
|
|
|
|
int m_inplaceAlign;
|
|
|
|
QString m_inplaceText;
|
|
|
|
NormalizedPoint m_inplaceCallout[3];
|
|
|
|
NormalizedPoint m_transformedInplaceCallout[3];
|
2007-05-04 20:24:12 +00:00
|
|
|
TextAnnotation::InplaceIntent m_inplaceIntent;
|
2006-12-18 07:28:02 +00:00
|
|
|
};
|
|
|
|
|
2006-09-08 21:08:51 +00:00
|
|
|
/*
|
|
|
|
The default textIcon for text annotation is Note as the PDF Reference says
|
|
|
|
*/
|
2005-03-04 23:06:24 +00:00
|
|
|
TextAnnotation::TextAnnotation()
|
2007-05-04 20:24:12 +00:00
|
|
|
: Annotation( *new TextAnnotationPrivate() )
|
2006-12-11 07:59:02 +00:00
|
|
|
{
|
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
|
2005-03-18 18:49:45 +00:00
|
|
|
TextAnnotation::TextAnnotation( const QDomNode & node )
|
2007-05-04 20:24:12 +00:00
|
|
|
: Annotation( *new TextAnnotationPrivate(), node )
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( TextAnnotation );
|
2005-03-18 18:49:45 +00:00
|
|
|
// loop through the whole children looking for a 'text' element
|
|
|
|
QDomNode subNode = node.firstChild();
|
|
|
|
while( subNode.isElement() )
|
|
|
|
{
|
|
|
|
QDomElement e = subNode.toElement();
|
|
|
|
subNode = subNode.nextSibling();
|
|
|
|
if ( e.tagName() != "text" )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// parse the attributes
|
|
|
|
if ( e.hasAttribute( "type" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_textType = (TextAnnotation::TextType)e.attribute( "type" ).toInt();
|
2005-03-18 18:49:45 +00:00
|
|
|
if ( e.hasAttribute( "icon" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_textIcon = e.attribute( "icon" );
|
2005-04-08 15:35:54 +00:00
|
|
|
if ( e.hasAttribute( "font" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_textFont.fromString( e.attribute( "font" ) );
|
2005-03-18 18:49:45 +00:00
|
|
|
if ( e.hasAttribute( "align" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_inplaceAlign = e.attribute( "align" ).toInt();
|
2005-03-18 18:49:45 +00:00
|
|
|
if ( e.hasAttribute( "intent" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_inplaceIntent = (TextAnnotation::InplaceIntent)e.attribute( "intent" ).toInt();
|
2005-03-18 18:49:45 +00:00
|
|
|
|
|
|
|
// parse the subnodes
|
|
|
|
QDomNode eSubNode = e.firstChild();
|
|
|
|
while ( eSubNode.isElement() )
|
|
|
|
{
|
|
|
|
QDomElement ee = eSubNode.toElement();
|
|
|
|
eSubNode = eSubNode.nextSibling();
|
|
|
|
|
|
|
|
if ( ee.tagName() == "escapedText" )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_inplaceText = ee.firstChild().toCDATASection().data();
|
2005-03-18 18:49:45 +00:00
|
|
|
}
|
|
|
|
else if ( ee.tagName() == "callout" )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_inplaceCallout[0].x = ee.attribute( "ax" ).toDouble();
|
|
|
|
d->m_inplaceCallout[0].y = ee.attribute( "ay" ).toDouble();
|
|
|
|
d->m_inplaceCallout[1].x = ee.attribute( "bx" ).toDouble();
|
|
|
|
d->m_inplaceCallout[1].y = ee.attribute( "by" ).toDouble();
|
|
|
|
d->m_inplaceCallout[2].x = ee.attribute( "cx" ).toDouble();
|
|
|
|
d->m_inplaceCallout[2].y = ee.attribute( "cy" ).toDouble();
|
2005-03-18 18:49:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// loading complete
|
|
|
|
break;
|
|
|
|
}
|
2006-11-20 07:53:32 +00:00
|
|
|
|
|
|
|
for ( int i = 0; i < 3; ++i )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_transformedInplaceCallout[i] = d->m_inplaceCallout[i];
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TextAnnotation::~TextAnnotation()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void TextAnnotation::setTextType( TextType textType )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_textType = textType;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TextAnnotation::TextType TextAnnotation::textType() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_textType;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextAnnotation::setTextIcon( const QString &icon )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_textIcon = icon;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString TextAnnotation::textIcon() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_textIcon;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextAnnotation::setTextFont( const QFont &font )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_textFont = font;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QFont TextAnnotation::textFont() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_textFont;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextAnnotation::setInplaceAlignment( int alignment )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_inplaceAlign = alignment;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int TextAnnotation::inplaceAlignment() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_inplaceAlign;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextAnnotation::setInplaceText( const QString &text )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_inplaceText = text;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString TextAnnotation::inplaceText() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_inplaceText;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextAnnotation::setInplaceCallout( const NormalizedPoint &point, int index )
|
|
|
|
{
|
|
|
|
if ( index < 0 || index > 2 )
|
|
|
|
return;
|
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_inplaceCallout[ index ] = point;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NormalizedPoint TextAnnotation::inplaceCallout( int index ) const
|
|
|
|
{
|
|
|
|
if ( index < 0 || index > 2 )
|
|
|
|
return NormalizedPoint();
|
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_inplaceCallout[ index ];
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NormalizedPoint TextAnnotation::transformedInplaceCallout( int index ) const
|
|
|
|
{
|
|
|
|
if ( index < 0 || index > 2 )
|
|
|
|
return NormalizedPoint();
|
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_transformedInplaceCallout[ index ];
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextAnnotation::setInplaceIntent( InplaceIntent intent )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_inplaceIntent = intent;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TextAnnotation::InplaceIntent TextAnnotation::inplaceIntent() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const TextAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_inplaceIntent;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::SubType TextAnnotation::subType() const
|
|
|
|
{
|
|
|
|
return AText;
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
|
|
|
|
2005-03-13 13:14:44 +00:00
|
|
|
void TextAnnotation::store( QDomNode & node, QDomDocument & document ) const
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const TextAnnotation );
|
2005-03-18 18:49:45 +00:00
|
|
|
// recurse to parent objects storing properties
|
2005-04-04 23:55:40 +00:00
|
|
|
Annotation::store( node, document );
|
2005-03-18 18:49:45 +00:00
|
|
|
|
|
|
|
// create [text] element
|
|
|
|
QDomElement textElement = document.createElement( "text" );
|
|
|
|
node.appendChild( textElement );
|
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
// store the optional attributes
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( d->m_textType != Linked )
|
|
|
|
textElement.setAttribute( "type", (int)d->m_textType );
|
|
|
|
if ( d->m_textIcon != "Comment" )
|
|
|
|
textElement.setAttribute( "icon", d->m_textIcon );
|
|
|
|
if ( d->m_textFont != QApplication::font() )
|
|
|
|
textElement.setAttribute( "font", d->m_textFont.toString() );
|
|
|
|
if ( d->m_inplaceAlign )
|
|
|
|
textElement.setAttribute( "align", d->m_inplaceAlign );
|
|
|
|
if ( d->m_inplaceIntent != Unknown )
|
|
|
|
textElement.setAttribute( "intent", (int)d->m_inplaceIntent );
|
2005-04-07 19:27:54 +00:00
|
|
|
|
|
|
|
// Sub-Node-1 - escapedText
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( !d->m_inplaceText.isEmpty() )
|
2005-03-18 18:49:45 +00:00
|
|
|
{
|
|
|
|
QDomElement escapedText = document.createElement( "escapedText" );
|
|
|
|
textElement.appendChild( escapedText );
|
2006-12-18 07:28:02 +00:00
|
|
|
QDomCDATASection textCData = document.createCDATASection( d->m_inplaceText );
|
2005-04-07 19:27:54 +00:00
|
|
|
escapedText.appendChild( textCData );
|
2005-03-18 18:49:45 +00:00
|
|
|
}
|
2005-04-07 19:27:54 +00:00
|
|
|
|
|
|
|
// Sub-Node-2 - callout
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( d->m_inplaceCallout[0].x != 0.0 )
|
2005-03-18 18:49:45 +00:00
|
|
|
{
|
|
|
|
QDomElement calloutElement = document.createElement( "callout" );
|
|
|
|
textElement.appendChild( calloutElement );
|
2006-12-18 07:28:02 +00:00
|
|
|
calloutElement.setAttribute( "ax", d->m_inplaceCallout[0].x );
|
|
|
|
calloutElement.setAttribute( "ay", d->m_inplaceCallout[0].y );
|
|
|
|
calloutElement.setAttribute( "bx", d->m_inplaceCallout[1].x );
|
|
|
|
calloutElement.setAttribute( "by", d->m_inplaceCallout[1].y );
|
|
|
|
calloutElement.setAttribute( "cx", d->m_inplaceCallout[2].x );
|
|
|
|
calloutElement.setAttribute( "cy", d->m_inplaceCallout[2].y );
|
2005-03-18 18:49:45 +00:00
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2007-05-04 20:45:45 +00:00
|
|
|
void TextAnnotationPrivate::transform( const QMatrix &matrix )
|
2006-11-20 07:53:32 +00:00
|
|
|
{
|
2007-05-04 20:45:45 +00:00
|
|
|
AnnotationPrivate::transform( matrix );
|
2006-11-20 07:53:32 +00:00
|
|
|
|
|
|
|
for ( int i = 0; i < 3; ++i ) {
|
2007-05-04 20:45:45 +00:00
|
|
|
m_transformedInplaceCallout[i].transform( matrix );
|
2006-11-20 07:53:32 +00:00
|
|
|
}
|
|
|
|
}
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2007-10-07 10:52:05 +00:00
|
|
|
void TextAnnotationPrivate::baseTransform( const QMatrix &matrix )
|
|
|
|
{
|
|
|
|
AnnotationPrivate::baseTransform( matrix );
|
|
|
|
|
|
|
|
for ( int i = 0; i < 3; ++i ) {
|
|
|
|
m_inplaceCallout[i].transform( matrix );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-22 20:49:27 +00:00
|
|
|
void TextAnnotationPrivate::resetTransformation()
|
|
|
|
{
|
|
|
|
AnnotationPrivate::resetTransformation();
|
|
|
|
|
|
|
|
for ( int i = 0; i < 3; ++i ) {
|
|
|
|
m_transformedInplaceCallout[i] = m_inplaceCallout[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-22 20:20:24 +00:00
|
|
|
void TextAnnotationPrivate::translate( const NormalizedPoint &coord )
|
|
|
|
{
|
|
|
|
AnnotationPrivate::translate( coord );
|
|
|
|
|
|
|
|
#define ADD_COORD( c1, c2 ) \
|
|
|
|
{ \
|
|
|
|
c1.x = c1.x + c2.x; \
|
|
|
|
c1.y = c1.y + c2.y; \
|
|
|
|
}
|
|
|
|
ADD_COORD( m_inplaceCallout[0], coord )
|
|
|
|
ADD_COORD( m_inplaceCallout[1], coord )
|
|
|
|
ADD_COORD( m_inplaceCallout[2], coord )
|
|
|
|
#undef ADD_COORD
|
|
|
|
}
|
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
/** LineAnnotation [Annotation] */
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
class Okular::LineAnnotationPrivate : public Okular::AnnotationPrivate
|
2006-12-18 07:28:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-05-04 20:24:12 +00:00
|
|
|
LineAnnotationPrivate()
|
|
|
|
: AnnotationPrivate(),
|
|
|
|
m_lineStartStyle( LineAnnotation::None ), m_lineEndStyle( LineAnnotation::None ),
|
2007-09-07 13:13:50 +00:00
|
|
|
m_lineClosed( false ), m_lineShowCaption( false ), m_lineLeadingFwdPt( 0 ),
|
|
|
|
m_lineLeadingBackPt( 0 ), m_lineIntent( LineAnnotation::Unknown )
|
2006-12-18 07:28:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-04 20:45:45 +00:00
|
|
|
virtual void transform( const QMatrix &matrix );
|
2007-10-07 10:52:05 +00:00
|
|
|
virtual void baseTransform( const QMatrix &matrix );
|
2007-07-22 20:49:27 +00:00
|
|
|
virtual void resetTransformation();
|
2007-07-17 18:10:25 +00:00
|
|
|
virtual void translate( const NormalizedPoint &coord );
|
2007-05-04 20:45:45 +00:00
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
QLinkedList<NormalizedPoint> m_linePoints;
|
|
|
|
QLinkedList<NormalizedPoint> m_transformedLinePoints;
|
2007-05-04 20:24:12 +00:00
|
|
|
LineAnnotation::TermStyle m_lineStartStyle;
|
|
|
|
LineAnnotation::TermStyle m_lineEndStyle;
|
2007-09-07 13:13:50 +00:00
|
|
|
bool m_lineClosed : 1;
|
|
|
|
bool m_lineShowCaption : 1;
|
2006-12-18 07:28:02 +00:00
|
|
|
QColor m_lineInnerColor;
|
|
|
|
double m_lineLeadingFwdPt;
|
|
|
|
double m_lineLeadingBackPt;
|
2007-05-04 20:24:12 +00:00
|
|
|
LineAnnotation::LineIntent m_lineIntent;
|
2006-12-18 07:28:02 +00:00
|
|
|
};
|
|
|
|
|
2005-03-04 23:06:24 +00:00
|
|
|
LineAnnotation::LineAnnotation()
|
2007-05-04 20:24:12 +00:00
|
|
|
: Annotation( *new LineAnnotationPrivate() )
|
2006-12-11 07:59:02 +00:00
|
|
|
{
|
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
|
2005-03-18 18:49:45 +00:00
|
|
|
LineAnnotation::LineAnnotation( const QDomNode & node )
|
2007-05-04 20:24:12 +00:00
|
|
|
: Annotation( *new LineAnnotationPrivate(), node )
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( LineAnnotation );
|
2005-03-18 18:49:45 +00:00
|
|
|
// loop through the whole children looking for a 'line' element
|
|
|
|
QDomNode subNode = node.firstChild();
|
|
|
|
while( subNode.isElement() )
|
|
|
|
{
|
|
|
|
QDomElement e = subNode.toElement();
|
|
|
|
subNode = subNode.nextSibling();
|
|
|
|
if ( e.tagName() != "line" )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// parse the attributes
|
|
|
|
if ( e.hasAttribute( "startStyle" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineStartStyle = (LineAnnotation::TermStyle)e.attribute( "startStyle" ).toInt();
|
2005-03-18 18:49:45 +00:00
|
|
|
if ( e.hasAttribute( "endStyle" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineEndStyle = (LineAnnotation::TermStyle)e.attribute( "endStyle" ).toInt();
|
2005-03-18 18:49:45 +00:00
|
|
|
if ( e.hasAttribute( "closed" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineClosed = e.attribute( "closed" ).toInt();
|
2005-03-18 18:49:45 +00:00
|
|
|
if ( e.hasAttribute( "innerColor" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineInnerColor = QColor( e.attribute( "innerColor" ) );
|
2005-03-18 18:49:45 +00:00
|
|
|
if ( e.hasAttribute( "leadFwd" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineLeadingFwdPt = e.attribute( "leadFwd" ).toDouble();
|
2005-03-18 18:49:45 +00:00
|
|
|
if ( e.hasAttribute( "leadBack" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineLeadingBackPt = e.attribute( "leadBack" ).toDouble();
|
2005-03-18 18:49:45 +00:00
|
|
|
if ( e.hasAttribute( "showCaption" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineShowCaption = e.attribute( "showCaption" ).toInt();
|
2005-03-18 18:49:45 +00:00
|
|
|
if ( e.hasAttribute( "intent" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineIntent = (LineAnnotation::LineIntent)e.attribute( "intent" ).toInt();
|
2005-03-18 18:49:45 +00:00
|
|
|
|
|
|
|
// parse all 'point' subnodes
|
|
|
|
QDomNode pointNode = e.firstChild();
|
|
|
|
while ( pointNode.isElement() )
|
|
|
|
{
|
|
|
|
QDomElement pe = pointNode.toElement();
|
|
|
|
pointNode = pointNode.nextSibling();
|
|
|
|
|
|
|
|
if ( pe.tagName() != "point" )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
NormalizedPoint p;
|
|
|
|
p.x = pe.attribute( "x", "0.0" ).toDouble();
|
|
|
|
p.y = pe.attribute( "y", "0.0" ).toDouble();
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_linePoints.append( p );
|
2005-03-18 18:49:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// loading complete
|
|
|
|
break;
|
|
|
|
}
|
2006-11-20 07:53:32 +00:00
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_transformedLinePoints = d->m_linePoints;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LineAnnotation::~LineAnnotation()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void LineAnnotation::setLinePoints( const QLinkedList<NormalizedPoint> &points )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_linePoints = points;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QLinkedList<NormalizedPoint> LineAnnotation::linePoints() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_linePoints;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QLinkedList<NormalizedPoint> LineAnnotation::transformedLinePoints() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_transformedLinePoints;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LineAnnotation::setLineStartStyle( TermStyle style )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineStartStyle = style;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LineAnnotation::TermStyle LineAnnotation::lineStartStyle() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_lineStartStyle;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LineAnnotation::setLineEndStyle( TermStyle style )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineEndStyle = style;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LineAnnotation::TermStyle LineAnnotation::lineEndStyle() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_lineEndStyle;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LineAnnotation::setLineClosed( bool closed )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineClosed = closed;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool LineAnnotation::lineClosed() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_lineClosed;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LineAnnotation::setLineInnerColor( const QColor &color )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineInnerColor = color;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QColor LineAnnotation::lineInnerColor() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_lineInnerColor;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LineAnnotation::setLineLeadingForwardPoint( double point )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineLeadingFwdPt = point;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double LineAnnotation::lineLeadingForwardPoint() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_lineLeadingFwdPt;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LineAnnotation::setLineLeadingBackwardPoint( double point )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineLeadingBackPt = point;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double LineAnnotation::lineLeadingBackwardPoint() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_lineLeadingBackPt;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LineAnnotation::setShowCaption( bool show )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineShowCaption = show;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool LineAnnotation::showCaption() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_lineShowCaption;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LineAnnotation::setLineIntent( LineIntent intent )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_lineIntent = intent;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LineAnnotation::LineIntent LineAnnotation::lineIntent() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const LineAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_lineIntent;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::SubType LineAnnotation::subType() const
|
|
|
|
{
|
|
|
|
return ALine;
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
|
|
|
|
2005-03-13 13:14:44 +00:00
|
|
|
void LineAnnotation::store( QDomNode & node, QDomDocument & document ) const
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const LineAnnotation );
|
2005-03-18 18:49:45 +00:00
|
|
|
// recurse to parent objects storing properties
|
2005-04-04 23:55:40 +00:00
|
|
|
Annotation::store( node, document );
|
2005-03-18 18:49:45 +00:00
|
|
|
|
|
|
|
// create [line] element
|
|
|
|
QDomElement lineElement = document.createElement( "line" );
|
|
|
|
node.appendChild( lineElement );
|
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
// store the attributes
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( d->m_lineStartStyle != None )
|
|
|
|
lineElement.setAttribute( "startStyle", (int)d->m_lineStartStyle );
|
|
|
|
if ( d->m_lineEndStyle != None )
|
|
|
|
lineElement.setAttribute( "endStyle", (int)d->m_lineEndStyle );
|
|
|
|
if ( d->m_lineClosed )
|
|
|
|
lineElement.setAttribute( "closed", d->m_lineClosed );
|
|
|
|
if ( d->m_lineInnerColor.isValid() )
|
|
|
|
lineElement.setAttribute( "innerColor", d->m_lineInnerColor.name() );
|
|
|
|
if ( d->m_lineLeadingFwdPt != 0.0 )
|
|
|
|
lineElement.setAttribute( "leadFwd", d->m_lineLeadingFwdPt );
|
|
|
|
if ( d->m_lineLeadingBackPt != 0.0 )
|
|
|
|
lineElement.setAttribute( "leadBack", d->m_lineLeadingBackPt );
|
|
|
|
if ( d->m_lineShowCaption )
|
|
|
|
lineElement.setAttribute( "showCaption", d->m_lineShowCaption );
|
|
|
|
if ( d->m_lineIntent != Unknown )
|
|
|
|
lineElement.setAttribute( "intent", d->m_lineIntent );
|
2005-04-07 19:27:54 +00:00
|
|
|
|
|
|
|
// append the list of points
|
2006-12-18 07:28:02 +00:00
|
|
|
int points = d->m_linePoints.count();
|
2005-04-07 19:27:54 +00:00
|
|
|
if ( points > 1 )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
QLinkedList<NormalizedPoint>::const_iterator it = d->m_linePoints.begin(), end = d->m_linePoints.end();
|
2005-04-07 19:27:54 +00:00
|
|
|
while ( it != end )
|
|
|
|
{
|
|
|
|
const NormalizedPoint & p = *it;
|
|
|
|
QDomElement pElement = document.createElement( "point" );
|
|
|
|
lineElement.appendChild( pElement );
|
|
|
|
pElement.setAttribute( "x", p.x );
|
2006-08-10 15:12:37 +00:00
|
|
|
pElement.setAttribute( "y", p.y );
|
2006-12-11 07:59:02 +00:00
|
|
|
it++; //to avoid loop
|
2005-04-07 19:27:54 +00:00
|
|
|
}
|
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2007-05-04 20:45:45 +00:00
|
|
|
void LineAnnotationPrivate::transform( const QMatrix &matrix )
|
2006-11-20 07:53:32 +00:00
|
|
|
{
|
2007-05-04 20:45:45 +00:00
|
|
|
AnnotationPrivate::transform( matrix );
|
2006-11-20 07:53:32 +00:00
|
|
|
|
2007-05-04 20:45:45 +00:00
|
|
|
QMutableLinkedListIterator<NormalizedPoint> it( m_transformedLinePoints );
|
2006-11-20 07:53:32 +00:00
|
|
|
while ( it.hasNext() )
|
|
|
|
it.next().transform( matrix );
|
|
|
|
}
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2007-10-07 10:52:05 +00:00
|
|
|
void LineAnnotationPrivate::baseTransform( const QMatrix &matrix )
|
|
|
|
{
|
|
|
|
AnnotationPrivate::baseTransform( matrix );
|
|
|
|
|
|
|
|
QMutableLinkedListIterator<NormalizedPoint> it( m_linePoints );
|
|
|
|
while ( it.hasNext() )
|
|
|
|
it.next().transform( matrix );
|
|
|
|
}
|
|
|
|
|
2007-07-22 20:49:27 +00:00
|
|
|
void LineAnnotationPrivate::resetTransformation()
|
|
|
|
{
|
|
|
|
AnnotationPrivate::resetTransformation();
|
|
|
|
|
|
|
|
m_transformedLinePoints = m_linePoints;
|
|
|
|
}
|
|
|
|
|
2007-07-17 18:10:25 +00:00
|
|
|
void LineAnnotationPrivate::translate( const NormalizedPoint &coord )
|
|
|
|
{
|
|
|
|
AnnotationPrivate::translate( coord );
|
|
|
|
|
|
|
|
QMutableLinkedListIterator<NormalizedPoint> it( m_linePoints );
|
|
|
|
while ( it.hasNext() )
|
|
|
|
{
|
|
|
|
NormalizedPoint& p = it.next();
|
|
|
|
p.x = p.x + coord.x;
|
|
|
|
p.y = p.y + coord.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
/** GeomAnnotation [Annotation] */
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
class Okular::GeomAnnotationPrivate : public Okular::AnnotationPrivate
|
2006-12-18 07:28:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-05-04 20:24:12 +00:00
|
|
|
GeomAnnotationPrivate()
|
|
|
|
: AnnotationPrivate(), m_geomType( GeomAnnotation::InscribedSquare ),
|
|
|
|
m_geomWidthPt( 18 )
|
2006-12-18 07:28:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
GeomAnnotation::GeomType m_geomType;
|
2006-12-18 07:28:02 +00:00
|
|
|
QColor m_geomInnerColor;
|
|
|
|
int m_geomWidthPt;
|
|
|
|
};
|
|
|
|
|
2005-03-04 23:06:24 +00:00
|
|
|
GeomAnnotation::GeomAnnotation()
|
2007-05-04 20:24:12 +00:00
|
|
|
: Annotation( *new GeomAnnotationPrivate() )
|
2006-12-18 07:28:02 +00:00
|
|
|
{
|
|
|
|
}
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2005-03-18 18:49:45 +00:00
|
|
|
GeomAnnotation::GeomAnnotation( const QDomNode & node )
|
2007-05-04 20:24:12 +00:00
|
|
|
: Annotation( *new GeomAnnotationPrivate(), node )
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( GeomAnnotation );
|
2005-03-18 18:49:45 +00:00
|
|
|
// loop through the whole children looking for a 'geom' element
|
|
|
|
QDomNode subNode = node.firstChild();
|
|
|
|
while( subNode.isElement() )
|
|
|
|
{
|
|
|
|
QDomElement e = subNode.toElement();
|
|
|
|
subNode = subNode.nextSibling();
|
|
|
|
if ( e.tagName() != "geom" )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// parse the attributes
|
|
|
|
if ( e.hasAttribute( "type" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_geomType = (GeomAnnotation::GeomType)e.attribute( "type" ).toInt();
|
2005-03-18 18:49:45 +00:00
|
|
|
if ( e.hasAttribute( "color" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_geomInnerColor = QColor( e.attribute( "color" ) );
|
2005-03-18 18:49:45 +00:00
|
|
|
if ( e.hasAttribute( "width" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_geomWidthPt = e.attribute( "width" ).toInt();
|
2005-03-18 18:49:45 +00:00
|
|
|
|
|
|
|
// loading complete
|
|
|
|
break;
|
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2006-12-11 07:59:02 +00:00
|
|
|
GeomAnnotation::~GeomAnnotation()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void GeomAnnotation::setGeometricalType( GeomType type )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( GeomAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_geomType = type;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GeomAnnotation::GeomType GeomAnnotation::geometricalType() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const GeomAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_geomType;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeomAnnotation::setGeometricalInnerColor( const QColor &color )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( GeomAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_geomInnerColor = color;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QColor GeomAnnotation::geometricalInnerColor() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const GeomAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_geomInnerColor;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GeomAnnotation::setGeometricalPointWidth( int width )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( GeomAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_geomWidthPt = width;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int GeomAnnotation::geometricalPointWidth() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const GeomAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_geomWidthPt;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::SubType GeomAnnotation::subType() const
|
|
|
|
{
|
|
|
|
return AGeom;
|
|
|
|
}
|
|
|
|
|
2005-03-13 13:14:44 +00:00
|
|
|
void GeomAnnotation::store( QDomNode & node, QDomDocument & document ) const
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const GeomAnnotation );
|
2005-03-18 18:49:45 +00:00
|
|
|
// recurse to parent objects storing properties
|
2005-04-04 23:55:40 +00:00
|
|
|
Annotation::store( node, document );
|
2005-03-18 18:49:45 +00:00
|
|
|
|
|
|
|
// create [geom] element
|
|
|
|
QDomElement geomElement = document.createElement( "geom" );
|
|
|
|
node.appendChild( geomElement );
|
|
|
|
|
|
|
|
// append the optional attributes
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( d->m_geomType != InscribedSquare )
|
|
|
|
geomElement.setAttribute( "type", (int)d->m_geomType );
|
|
|
|
if ( d->m_geomInnerColor.isValid() )
|
|
|
|
geomElement.setAttribute( "color", d->m_geomInnerColor.name() );
|
|
|
|
if ( d->m_geomWidthPt != 18 )
|
|
|
|
geomElement.setAttribute( "width", d->m_geomWidthPt );
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
/** HighlightAnnotation [Annotation] */
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
class HighlightAnnotation::Quad::Private
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Private()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NormalizedPoint m_points[4];
|
|
|
|
NormalizedPoint m_transformedPoints[4];
|
2007-09-07 13:13:50 +00:00
|
|
|
bool m_capStart : 1;
|
|
|
|
bool m_capEnd : 1;
|
2006-12-18 07:28:02 +00:00
|
|
|
double m_feather;
|
|
|
|
};
|
|
|
|
|
2006-12-11 07:59:02 +00:00
|
|
|
HighlightAnnotation::Quad::Quad()
|
2006-12-18 07:28:02 +00:00
|
|
|
: d( new Private )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
HighlightAnnotation::Quad::~Quad()
|
2006-12-11 07:59:02 +00:00
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
HighlightAnnotation::Quad::Quad( const Quad &other )
|
|
|
|
: d( new Private )
|
|
|
|
{
|
|
|
|
*d = *other.d;
|
|
|
|
}
|
|
|
|
|
|
|
|
HighlightAnnotation::Quad& HighlightAnnotation::Quad::operator=( const Quad &other )
|
|
|
|
{
|
|
|
|
if ( this != &other )
|
|
|
|
*d = *other.d;
|
|
|
|
|
|
|
|
return *this;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HighlightAnnotation::Quad::setPoint( const NormalizedPoint &point, int index )
|
|
|
|
{
|
|
|
|
if ( index < 0 || index > 3 )
|
|
|
|
return;
|
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_points[ index ] = point;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NormalizedPoint HighlightAnnotation::Quad::point( int index ) const
|
|
|
|
{
|
|
|
|
if ( index < 0 || index > 3 )
|
|
|
|
return NormalizedPoint();
|
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_points[ index ];
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NormalizedPoint HighlightAnnotation::Quad::transformedPoint( int index ) const
|
|
|
|
{
|
|
|
|
if ( index < 0 || index > 3 )
|
|
|
|
return NormalizedPoint();
|
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_transformedPoints[ index ];
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HighlightAnnotation::Quad::setCapStart( bool value )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_capStart = value;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HighlightAnnotation::Quad::capStart() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_capStart;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HighlightAnnotation::Quad::setCapEnd( bool value )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_capEnd = value;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HighlightAnnotation::Quad::capEnd() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_capEnd;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HighlightAnnotation::Quad::setFeather( double width )
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_feather = width;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double HighlightAnnotation::Quad::feather() const
|
|
|
|
{
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_feather;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HighlightAnnotation::Quad::transform( const QMatrix &matrix )
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < 4; ++i ) {
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_transformedPoints[ i ] = d->m_points[ i ];
|
|
|
|
d->m_transformedPoints[ i ].transform( matrix );
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
class Okular::HighlightAnnotationPrivate : public Okular::AnnotationPrivate
|
2006-12-18 07:28:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-05-04 20:24:12 +00:00
|
|
|
HighlightAnnotationPrivate()
|
|
|
|
: AnnotationPrivate(), m_highlightType( HighlightAnnotation::Highlight )
|
2006-12-18 07:28:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-04 20:45:45 +00:00
|
|
|
virtual void transform( const QMatrix &matrix );
|
2007-10-07 10:52:05 +00:00
|
|
|
virtual void baseTransform( const QMatrix &matrix );
|
2007-05-04 20:45:45 +00:00
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
HighlightAnnotation::HighlightType m_highlightType;
|
|
|
|
QList< HighlightAnnotation::Quad > m_highlightQuads;
|
2006-12-18 07:28:02 +00:00
|
|
|
};
|
|
|
|
|
2005-03-04 23:06:24 +00:00
|
|
|
HighlightAnnotation::HighlightAnnotation()
|
2007-05-04 20:24:12 +00:00
|
|
|
: Annotation( *new HighlightAnnotationPrivate() )
|
2006-12-11 07:59:02 +00:00
|
|
|
{
|
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
|
2005-03-18 18:49:45 +00:00
|
|
|
HighlightAnnotation::HighlightAnnotation( const QDomNode & node )
|
2007-05-04 20:24:12 +00:00
|
|
|
: Annotation( *new HighlightAnnotationPrivate(), node )
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( HighlightAnnotation );
|
2005-03-18 18:49:45 +00:00
|
|
|
// loop through the whole children looking for a 'hl' element
|
|
|
|
QDomNode subNode = node.firstChild();
|
|
|
|
while( subNode.isElement() )
|
|
|
|
{
|
|
|
|
QDomElement e = subNode.toElement();
|
|
|
|
subNode = subNode.nextSibling();
|
|
|
|
if ( e.tagName() != "hl" )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// parse the attributes
|
|
|
|
if ( e.hasAttribute( "type" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_highlightType = (HighlightAnnotation::HighlightType)e.attribute( "type" ).toInt();
|
2005-03-18 18:49:45 +00:00
|
|
|
|
|
|
|
// parse all 'quad' subnodes
|
|
|
|
QDomNode quadNode = e.firstChild();
|
2005-04-07 19:27:54 +00:00
|
|
|
for ( ; quadNode.isElement(); quadNode = quadNode.nextSibling() )
|
2005-03-18 18:49:45 +00:00
|
|
|
{
|
|
|
|
QDomElement qe = quadNode.toElement();
|
|
|
|
if ( qe.tagName() != "quad" )
|
|
|
|
continue;
|
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
HighlightAnnotation::Quad q;
|
2006-12-11 07:59:02 +00:00
|
|
|
q.setPoint( NormalizedPoint( qe.attribute( "ax", "0.0" ).toDouble(), qe.attribute( "ay", "0.0" ).toDouble() ), 0 );
|
|
|
|
q.setPoint( NormalizedPoint( qe.attribute( "bx", "0.0" ).toDouble(), qe.attribute( "by", "0.0" ).toDouble() ), 1 );
|
|
|
|
q.setPoint( NormalizedPoint( qe.attribute( "cx", "0.0" ).toDouble(), qe.attribute( "cy", "0.0" ).toDouble() ), 2 );
|
|
|
|
q.setPoint( NormalizedPoint( qe.attribute( "dx", "0.0" ).toDouble(), qe.attribute( "dy", "0.0" ).toDouble() ), 3 );
|
|
|
|
q.setCapStart( qe.hasAttribute( "start" ) );
|
|
|
|
q.setCapEnd( qe.hasAttribute( "end" ) );
|
|
|
|
q.setFeather( qe.attribute( "feather", "0.1" ).toDouble() );
|
|
|
|
|
|
|
|
q.transform( QMatrix() );
|
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_highlightQuads.append( q );
|
2005-03-18 18:49:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// loading complete
|
|
|
|
break;
|
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
|
|
|
|
2006-12-11 07:59:02 +00:00
|
|
|
HighlightAnnotation::~HighlightAnnotation()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void HighlightAnnotation::setHighlightType( HighlightType type )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( HighlightAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_highlightType = type;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HighlightAnnotation::HighlightType HighlightAnnotation::highlightType() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const HighlightAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_highlightType;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QList< HighlightAnnotation::Quad > & HighlightAnnotation::highlightQuads()
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( HighlightAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_highlightQuads;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
2005-03-13 13:14:44 +00:00
|
|
|
void HighlightAnnotation::store( QDomNode & node, QDomDocument & document ) const
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const HighlightAnnotation );
|
2005-03-18 18:49:45 +00:00
|
|
|
// recurse to parent objects storing properties
|
2005-04-04 23:55:40 +00:00
|
|
|
Annotation::store( node, document );
|
2005-03-18 18:49:45 +00:00
|
|
|
|
|
|
|
// create [hl] element
|
|
|
|
QDomElement hlElement = document.createElement( "hl" );
|
|
|
|
node.appendChild( hlElement );
|
|
|
|
|
|
|
|
// append the optional attributes
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( d->m_highlightType != Highlight )
|
|
|
|
hlElement.setAttribute( "type", (int)d->m_highlightType );
|
|
|
|
if ( d->m_highlightQuads.count() < 1 )
|
2005-03-18 18:49:45 +00:00
|
|
|
return;
|
|
|
|
// append highlight quads, all children describe quads
|
2006-12-18 07:28:02 +00:00
|
|
|
QList< Quad >::const_iterator it = d->m_highlightQuads.begin(), end = d->m_highlightQuads.end();
|
2005-03-18 18:49:45 +00:00
|
|
|
for ( ; it != end; ++it )
|
|
|
|
{
|
|
|
|
QDomElement quadElement = document.createElement( "quad" );
|
|
|
|
hlElement.appendChild( quadElement );
|
2005-04-08 08:58:49 +00:00
|
|
|
const Quad & q = *it;
|
2006-12-11 07:59:02 +00:00
|
|
|
quadElement.setAttribute( "ax", q.point( 0 ).x );
|
|
|
|
quadElement.setAttribute( "ay", q.point( 0 ).y );
|
|
|
|
quadElement.setAttribute( "bx", q.point( 1 ).x );
|
|
|
|
quadElement.setAttribute( "by", q.point( 1 ).y );
|
|
|
|
quadElement.setAttribute( "cx", q.point( 2 ).x );
|
|
|
|
quadElement.setAttribute( "cy", q.point( 2 ).y );
|
|
|
|
quadElement.setAttribute( "dx", q.point( 3 ).x );
|
|
|
|
quadElement.setAttribute( "dy", q.point( 3 ).y );
|
|
|
|
if ( q.capStart() )
|
2005-04-08 08:58:49 +00:00
|
|
|
quadElement.setAttribute( "start", 1 );
|
2006-12-11 07:59:02 +00:00
|
|
|
if ( q.capEnd() )
|
2005-04-08 08:58:49 +00:00
|
|
|
quadElement.setAttribute( "end", 1 );
|
2006-12-11 07:59:02 +00:00
|
|
|
quadElement.setAttribute( "feather", q.feather() );
|
2005-03-18 18:49:45 +00:00
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2006-12-11 07:59:02 +00:00
|
|
|
Annotation::SubType HighlightAnnotation::subType() const
|
|
|
|
{
|
|
|
|
return AHighlight;
|
|
|
|
}
|
|
|
|
|
2007-05-04 20:45:45 +00:00
|
|
|
void HighlightAnnotationPrivate::transform( const QMatrix &matrix )
|
2006-11-20 07:53:32 +00:00
|
|
|
{
|
2007-05-04 20:45:45 +00:00
|
|
|
AnnotationPrivate::transform( matrix );
|
2006-11-20 07:53:32 +00:00
|
|
|
|
2007-05-04 20:45:45 +00:00
|
|
|
QMutableListIterator<HighlightAnnotation::Quad> it( m_highlightQuads );
|
2006-12-11 07:59:02 +00:00
|
|
|
while ( it.hasNext() )
|
|
|
|
it.next().transform( matrix );
|
2006-11-20 07:53:32 +00:00
|
|
|
}
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2007-10-07 10:52:05 +00:00
|
|
|
void HighlightAnnotationPrivate::baseTransform( const QMatrix &matrix )
|
|
|
|
{
|
|
|
|
AnnotationPrivate::baseTransform( matrix );
|
|
|
|
|
|
|
|
QMutableListIterator<HighlightAnnotation::Quad> it( m_highlightQuads );
|
|
|
|
while ( it.hasNext() )
|
|
|
|
it.next().transform( matrix );
|
|
|
|
}
|
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
/** StampAnnotation [Annotation] */
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
class Okular::StampAnnotationPrivate : public Okular::AnnotationPrivate
|
2006-12-18 07:28:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-05-04 20:24:12 +00:00
|
|
|
StampAnnotationPrivate()
|
|
|
|
: AnnotationPrivate(), m_stampIconName( "Draft" )
|
2006-12-18 07:28:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QString m_stampIconName;
|
|
|
|
};
|
|
|
|
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
StampAnnotation::StampAnnotation()
|
2007-05-04 20:24:12 +00:00
|
|
|
: Annotation( *new StampAnnotationPrivate() )
|
2006-12-11 07:59:02 +00:00
|
|
|
{
|
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
|
2005-03-18 18:49:45 +00:00
|
|
|
StampAnnotation::StampAnnotation( const QDomNode & node )
|
2007-05-04 20:24:12 +00:00
|
|
|
: Annotation( *new StampAnnotationPrivate(), node )
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( StampAnnotation );
|
2005-03-18 18:49:45 +00:00
|
|
|
// loop through the whole children looking for a 'stamp' element
|
|
|
|
QDomNode subNode = node.firstChild();
|
|
|
|
while( subNode.isElement() )
|
|
|
|
{
|
|
|
|
QDomElement e = subNode.toElement();
|
|
|
|
subNode = subNode.nextSibling();
|
|
|
|
if ( e.tagName() != "stamp" )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// parse the attributes
|
|
|
|
if ( e.hasAttribute( "icon" ) )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_stampIconName = e.attribute( "icon" );
|
2005-03-18 18:49:45 +00:00
|
|
|
|
|
|
|
// loading complete
|
|
|
|
break;
|
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2006-12-11 07:59:02 +00:00
|
|
|
StampAnnotation::~StampAnnotation()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void StampAnnotation::setStampIconName( const QString &name )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( StampAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_stampIconName = name;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString StampAnnotation::stampIconName() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const StampAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_stampIconName;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::SubType StampAnnotation::subType() const
|
|
|
|
{
|
|
|
|
return AStamp;
|
|
|
|
}
|
|
|
|
|
2005-03-13 13:14:44 +00:00
|
|
|
void StampAnnotation::store( QDomNode & node, QDomDocument & document ) const
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const StampAnnotation );
|
2005-03-18 18:49:45 +00:00
|
|
|
// recurse to parent objects storing properties
|
2005-04-04 23:55:40 +00:00
|
|
|
Annotation::store( node, document );
|
2005-03-18 18:49:45 +00:00
|
|
|
|
|
|
|
// create [stamp] element
|
|
|
|
QDomElement stampElement = document.createElement( "stamp" );
|
|
|
|
node.appendChild( stampElement );
|
|
|
|
|
|
|
|
// append the optional attributes
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( d->m_stampIconName != "Draft" )
|
|
|
|
stampElement.setAttribute( "icon", d->m_stampIconName );
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
2005-02-26 18:05:01 +00:00
|
|
|
|
2005-04-07 19:27:54 +00:00
|
|
|
/** InkAnnotation [Annotation] */
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
|
2007-05-04 20:24:12 +00:00
|
|
|
class Okular::InkAnnotationPrivate : public Okular::AnnotationPrivate
|
2006-12-18 07:28:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-05-04 20:24:12 +00:00
|
|
|
InkAnnotationPrivate()
|
|
|
|
: AnnotationPrivate()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-04 20:45:45 +00:00
|
|
|
virtual void transform( const QMatrix &matrix );
|
2007-10-07 10:52:05 +00:00
|
|
|
virtual void baseTransform( const QMatrix &matrix );
|
2007-07-22 20:49:27 +00:00
|
|
|
virtual void resetTransformation();
|
2007-07-17 21:52:22 +00:00
|
|
|
virtual void translate( const NormalizedPoint &coord );
|
2007-05-04 20:45:45 +00:00
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
QList< QLinkedList<NormalizedPoint> > m_inkPaths;
|
|
|
|
QList< QLinkedList<NormalizedPoint> > m_transformedInkPaths;
|
|
|
|
};
|
|
|
|
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
InkAnnotation::InkAnnotation()
|
2007-05-04 20:24:12 +00:00
|
|
|
: Annotation( *new InkAnnotationPrivate() )
|
2006-12-11 07:59:02 +00:00
|
|
|
{
|
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
|
2005-03-18 18:49:45 +00:00
|
|
|
InkAnnotation::InkAnnotation( const QDomNode & node )
|
2007-05-04 20:24:12 +00:00
|
|
|
: Annotation( *new InkAnnotationPrivate(), node )
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( InkAnnotation );
|
2005-03-18 18:49:45 +00:00
|
|
|
// loop through the whole children looking for a 'ink' element
|
|
|
|
QDomNode subNode = node.firstChild();
|
|
|
|
while( subNode.isElement() )
|
|
|
|
{
|
|
|
|
QDomElement e = subNode.toElement();
|
|
|
|
subNode = subNode.nextSibling();
|
|
|
|
if ( e.tagName() != "ink" )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// parse the 'path' subnodes
|
|
|
|
QDomNode pathNode = e.firstChild();
|
|
|
|
while ( pathNode.isElement() )
|
|
|
|
{
|
|
|
|
QDomElement pathElement = pathNode.toElement();
|
|
|
|
pathNode = pathNode.nextSibling();
|
|
|
|
|
|
|
|
if ( pathElement.tagName() != "path" )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// build each path parsing 'point' subnodes
|
2006-03-20 22:51:56 +00:00
|
|
|
QLinkedList<NormalizedPoint> path;
|
2005-03-18 18:49:45 +00:00
|
|
|
QDomNode pointNode = pathElement.firstChild();
|
|
|
|
while ( pointNode.isElement() )
|
|
|
|
{
|
|
|
|
QDomElement pointElement = pointNode.toElement();
|
|
|
|
pointNode = pointNode.nextSibling();
|
|
|
|
|
|
|
|
if ( pointElement.tagName() != "point" )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
NormalizedPoint p;
|
|
|
|
p.x = pointElement.attribute( "x", "0.0" ).toDouble();
|
|
|
|
p.y = pointElement.attribute( "y", "0.0" ).toDouble();
|
|
|
|
path.append( p );
|
|
|
|
}
|
|
|
|
|
|
|
|
// add the path to the path list if it contains at least 2 nodes
|
|
|
|
if ( path.count() >= 2 )
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_inkPaths.append( path );
|
2005-03-18 18:49:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// loading complete
|
|
|
|
break;
|
|
|
|
}
|
2006-11-27 08:01:27 +00:00
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_transformedInkPaths = d->m_inkPaths;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
InkAnnotation::~InkAnnotation()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void InkAnnotation::setInkPaths( const QList< QLinkedList<NormalizedPoint> > &paths )
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( InkAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
d->m_inkPaths = paths;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QList< QLinkedList<NormalizedPoint> > InkAnnotation::inkPaths() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const InkAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_inkPaths;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QList< QLinkedList<NormalizedPoint> > InkAnnotation::transformedInkPaths() const
|
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const InkAnnotation );
|
2006-12-18 07:28:02 +00:00
|
|
|
return d->m_transformedInkPaths;
|
2006-12-11 07:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Annotation::SubType InkAnnotation::subType() const
|
|
|
|
{
|
|
|
|
return AInk;
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
|
|
|
|
2005-03-13 13:14:44 +00:00
|
|
|
void InkAnnotation::store( QDomNode & node, QDomDocument & document ) const
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
{
|
2007-05-04 20:24:12 +00:00
|
|
|
Q_D( const InkAnnotation );
|
2005-03-18 18:49:45 +00:00
|
|
|
// recurse to parent objects storing properties
|
2005-04-04 23:55:40 +00:00
|
|
|
Annotation::store( node, document );
|
2005-03-13 13:14:44 +00:00
|
|
|
|
2005-03-18 18:49:45 +00:00
|
|
|
// create [ink] element
|
|
|
|
QDomElement inkElement = document.createElement( "ink" );
|
|
|
|
node.appendChild( inkElement );
|
|
|
|
|
|
|
|
// append the optional attributes
|
2006-12-18 07:28:02 +00:00
|
|
|
if ( d->m_inkPaths.count() < 1 )
|
2005-03-18 18:49:45 +00:00
|
|
|
return;
|
2006-12-11 07:59:02 +00:00
|
|
|
|
2006-12-18 07:28:02 +00:00
|
|
|
QList< QLinkedList<NormalizedPoint> >::const_iterator pIt = d->m_inkPaths.begin(), pEnd = d->m_inkPaths.end();
|
2005-03-18 18:49:45 +00:00
|
|
|
for ( ; pIt != pEnd; ++pIt )
|
|
|
|
{
|
|
|
|
QDomElement pathElement = document.createElement( "path" );
|
|
|
|
inkElement.appendChild( pathElement );
|
2006-03-20 22:51:56 +00:00
|
|
|
const QLinkedList<NormalizedPoint> & path = *pIt;
|
|
|
|
QLinkedList<NormalizedPoint>::const_iterator iIt = path.begin(), iEnd = path.end();
|
2005-03-18 18:49:45 +00:00
|
|
|
for ( ; iIt != iEnd; ++iIt )
|
|
|
|
{
|
|
|
|
const NormalizedPoint & point = *iIt;
|
|
|
|
QDomElement pointElement = document.createElement( "point" );
|
|
|
|
pathElement.appendChild( pointElement );
|
|
|
|
pointElement.setAttribute( "x", point.x );
|
|
|
|
pointElement.setAttribute( "y", point.y );
|
|
|
|
}
|
|
|
|
}
|
PDF 1.6 Annotation Parser and DSs: annotations are loaded from PDF file.
AFAIK the kpdf team is once again the first opensource reader to get
support for a cool feature. All annotations in pdf file are read and
converted to our internal data structures. Then they'll be rendered on
screen and changed/saved to our xml file.
Annotations completely supported and parsed from PDF: [markup], popup,
text, freetext, line, polygon, polyline, highlight, underline, squiggly,
strikeout, stamp, ink. Partial support for: [base], geom.
Annotations:
Added/Changed the passive annotation data structures to contain and
generalize the attributes of annotation classes. Missing attributes
(won't be handled by kpdf): base{P,AP,AS,A,AA,StructPar,OC}, geom{RD}.
Little changes to the PDF1.6 summary in header.
PDFGenerator:
Internal parser (discussed with Albert) directly in top of xpdf. Read
object nodes of type 'Annot' and parse the whole set of attributes as
defined in the PDF1.6 spec (for supported annotations).
svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=396909
2005-03-12 08:30:47 +00:00
|
|
|
}
|
2006-11-20 07:53:32 +00:00
|
|
|
|
2007-05-04 20:45:45 +00:00
|
|
|
void InkAnnotationPrivate::transform( const QMatrix &matrix )
|
2006-11-20 07:53:32 +00:00
|
|
|
{
|
2007-05-04 20:45:45 +00:00
|
|
|
AnnotationPrivate::transform( matrix );
|
2006-11-20 07:53:32 +00:00
|
|
|
|
2007-05-04 20:45:45 +00:00
|
|
|
for ( int i = 0; i < m_transformedInkPaths.count(); ++i )
|
|
|
|
{
|
|
|
|
QMutableLinkedListIterator<NormalizedPoint> it( m_transformedInkPaths[ i ] );
|
2006-11-20 07:53:32 +00:00
|
|
|
while ( it.hasNext() )
|
|
|
|
it.next().transform( matrix );
|
|
|
|
}
|
|
|
|
}
|
2007-07-17 21:52:22 +00:00
|
|
|
|
2007-10-07 10:52:05 +00:00
|
|
|
void InkAnnotationPrivate::baseTransform( const QMatrix &matrix )
|
|
|
|
{
|
|
|
|
AnnotationPrivate::baseTransform( matrix );
|
|
|
|
|
|
|
|
for ( int i = 0; i < m_inkPaths.count(); ++i )
|
|
|
|
{
|
|
|
|
QMutableLinkedListIterator<NormalizedPoint> it( m_inkPaths[ i ] );
|
|
|
|
while ( it.hasNext() )
|
|
|
|
it.next().transform( matrix );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-22 20:49:27 +00:00
|
|
|
void InkAnnotationPrivate::resetTransformation()
|
|
|
|
{
|
|
|
|
AnnotationPrivate::resetTransformation();
|
|
|
|
|
|
|
|
m_transformedInkPaths = m_inkPaths;
|
|
|
|
}
|
|
|
|
|
2007-07-17 21:52:22 +00:00
|
|
|
void InkAnnotationPrivate::translate( const NormalizedPoint &coord )
|
|
|
|
{
|
|
|
|
AnnotationPrivate::translate( coord );
|
|
|
|
|
|
|
|
for ( int i = 0; i < m_inkPaths.count(); ++i )
|
|
|
|
{
|
|
|
|
QMutableLinkedListIterator<NormalizedPoint> it( m_inkPaths[ i ] );
|
|
|
|
while ( it.hasNext() )
|
|
|
|
{
|
|
|
|
NormalizedPoint& p = it.next();
|
|
|
|
p.x = p.x + coord.x;
|
|
|
|
p.y = p.y + coord.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|