1
/* poppler-annotation.cc: qt interface to poppler
2
* Copyright (C) 2006, 2009 Albert Astals Cid <aacid@kde.org>
3
* Copyright (C) 2006, 2008, 2010 Pino Toscano <pino@kde.org>
5
* Copyright (C) 2004 by Enrico Ros <eros.kde@email.it>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2, or (at your option)
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
23
#include <QtXml/QDomElement>
24
#include <QtGui/QColor>
27
#include "poppler-annotation.h"
28
#include "poppler-link.h"
29
#include "poppler-qt4.h"
30
#include "poppler-annotation-private.h"
38
//BEGIN AnnotationUtils implementation
39
Annotation * AnnotationUtils::createAnnotation( const QDomElement & annElement )
41
// safety check on annotation element
42
if ( !annElement.hasAttribute( "type" ) )
45
// build annotation of given type
46
Annotation * annotation = 0;
47
int typeNumber = annElement.attribute( "type" ).toInt();
50
case Annotation::AText:
51
annotation = new TextAnnotation( annElement );
53
case Annotation::ALine:
54
annotation = new LineAnnotation( annElement );
56
case Annotation::AGeom:
57
annotation = new GeomAnnotation( annElement );
59
case Annotation::AHighlight:
60
annotation = new HighlightAnnotation( annElement );
62
case Annotation::AStamp:
63
annotation = new StampAnnotation( annElement );
65
case Annotation::AInk:
66
annotation = new InkAnnotation( annElement );
68
case Annotation::ACaret:
69
annotation = new CaretAnnotation( annElement );
73
// return created annotation
77
void AnnotationUtils::storeAnnotation( const Annotation * ann, QDomElement & annElement,
78
QDomDocument & document )
80
// save annotation's type as element's attribute
81
annElement.setAttribute( "type", (uint)ann->subType() );
83
// append all annotation data as children of this node
84
ann->store( annElement, document );
87
QDomElement AnnotationUtils::findChildElement( const QDomNode & parentNode,
88
const QString & name )
90
// loop through the whole children and return a 'name' named element
91
QDomNode subNode = parentNode.firstChild();
92
while( subNode.isElement() )
94
QDomElement element = subNode.toElement();
95
if ( element.tagName() == name )
97
subNode = subNode.nextSibling();
99
// if the name can't be found, return a dummy null element
100
return QDomElement();
102
//END AnnotationUtils implementation
105
//BEGIN Annotation implementation
106
AnnotationPrivate::AnnotationPrivate()
111
AnnotationPrivate::~AnnotationPrivate()
116
Annotation::Style::Style()
117
: opacity( 1.0 ), width( 1.0 ), style( Solid ), xCorners( 0.0 ),
118
yCorners( 0.0 ), marks( 3 ), spaces( 0 ), effect( NoEffect ),
119
effectIntensity( 1.0 ) {}
121
Annotation::Window::Window()
122
: flags( -1 ), width( 0 ), height( 0 ) {}
124
Annotation::Revision::Revision()
125
: annotation( 0 ), scope( Reply ), type( None ) {}
127
Annotation::Annotation( AnnotationPrivate &dd )
132
Annotation::~Annotation()
135
// delete all children revisions
136
QLinkedList< Annotation::Revision >::iterator it = d->revisions.begin(), end = d->revisions.end();
137
for ( ; it != end; ++it )
138
delete (*it).annotation;
143
Annotation::Annotation( AnnotationPrivate &dd, const QDomNode &annNode )
147
// get the [base] element of the annotation node
148
QDomElement e = AnnotationUtils::findChildElement( annNode, "base" );
152
// parse -contents- attributes
153
if ( e.hasAttribute( "author" ) )
154
d->author = e.attribute( "author" );
155
if ( e.hasAttribute( "contents" ) )
156
d->contents = e.attribute( "contents" );
157
if ( e.hasAttribute( "uniqueName" ) )
158
d->uniqueName = e.attribute( "uniqueName" );
159
if ( e.hasAttribute( "modifyDate" ) )
160
d->modDate = QDateTime::fromString( e.attribute( "modifyDate" ) );
161
if ( e.hasAttribute( "creationDate" ) )
162
d->creationDate = QDateTime::fromString( e.attribute( "creationDate" ) );
164
// parse -other- attributes
165
if ( e.hasAttribute( "flags" ) )
166
d->flags = e.attribute( "flags" ).toInt();
167
if ( e.hasAttribute( "color" ) )
168
style.color = QColor( e.attribute( "color" ) );
169
if ( e.hasAttribute( "opacity" ) )
170
style.opacity = e.attribute( "opacity" ).toDouble();
172
// parse -the-subnodes- (describing Style, Window, Revision(s) structures)
173
// Note: all subnodes if present must be 'attributes complete'
174
QDomNode eSubNode = e.firstChild();
175
while ( eSubNode.isElement() )
177
QDomElement ee = eSubNode.toElement();
178
eSubNode = eSubNode.nextSibling();
181
if ( ee.tagName() == "boundary" )
183
d->boundary.setLeft(ee.attribute( "l" ).toDouble());
184
d->boundary.setTop(ee.attribute( "t" ).toDouble());
185
d->boundary.setRight(ee.attribute( "r" ).toDouble());
186
d->boundary.setBottom(ee.attribute( "b" ).toDouble());
188
// parse penStyle if not default
189
else if ( ee.tagName() == "penStyle" )
191
style.width = ee.attribute( "width" ).toDouble();
192
style.style = (LineStyle)ee.attribute( "style" ).toInt();
193
style.xCorners = ee.attribute( "xcr" ).toDouble();
194
style.yCorners = ee.attribute( "ycr" ).toDouble();
195
style.marks = ee.attribute( "marks" ).toInt();
196
style.spaces = ee.attribute( "spaces" ).toInt();
198
// parse effectStyle if not default
199
else if ( ee.tagName() == "penEffect" )
201
style.effect = (LineEffect)ee.attribute( "effect" ).toInt();
202
style.effectIntensity = ee.attribute( "intensity" ).toDouble();
204
// parse window if present
205
else if ( ee.tagName() == "window" )
207
window.flags = ee.attribute( "flags" ).toInt();
208
window.topLeft.setX(ee.attribute( "top" ).toDouble());
209
window.topLeft.setY(ee.attribute( "left" ).toDouble());
210
window.width = ee.attribute( "width" ).toInt();
211
window.height = ee.attribute( "height" ).toInt();
212
window.title = ee.attribute( "title" );
213
window.summary = ee.attribute( "summary" );
214
// parse window subnodes
215
QDomNode winNode = ee.firstChild();
216
for ( ; winNode.isElement(); winNode = winNode.nextSibling() )
218
QDomElement winElement = winNode.toElement();
219
if ( winElement.tagName() == "text" )
220
window.text = winElement.firstChild().toCDATASection().data();
225
// get the [revisions] element of the annotation node
226
QDomNode revNode = annNode.firstChild();
227
for ( ; revNode.isElement(); revNode = revNode.nextSibling() )
229
QDomElement revElement = revNode.toElement();
230
if ( revElement.tagName() != "revision" )
233
// compile the Revision structure crating annotation
235
rev.scope = (RevScope)revElement.attribute( "revScope" ).toInt();
236
rev.type = (RevType)revElement.attribute( "revType" ).toInt();
237
rev.annotation = AnnotationUtils::createAnnotation( revElement );
239
// if annotation is valid, add revision to internal list
240
if ( rev.annotation )
241
d->revisions.append( rev );
245
void Annotation::store( QDomNode & annNode, QDomDocument & document ) const
247
Q_D( const Annotation );
248
// create [base] element of the annotation node
249
QDomElement e = document.createElement( "base" );
250
annNode.appendChild( e );
252
// store -contents- attributes
253
if ( !d->author.isEmpty() )
254
e.setAttribute( "author", d->author );
255
if ( !d->contents.isEmpty() )
256
e.setAttribute( "contents", d->contents );
257
if ( !d->uniqueName.isEmpty() )
258
e.setAttribute( "uniqueName", d->uniqueName );
259
if ( d->modDate.isValid() )
260
e.setAttribute( "modifyDate", d->modDate.toString() );
261
if ( d->creationDate.isValid() )
262
e.setAttribute( "creationDate", d->creationDate.toString() );
264
// store -other- attributes
266
e.setAttribute( "flags", d->flags );
267
if ( style.color.isValid() && style.color != Qt::black )
268
e.setAttribute( "color", style.color.name() );
269
if ( style.opacity != 1.0 )
270
e.setAttribute( "opacity", QString::number( style.opacity ) );
272
// Sub-Node-1 - boundary
273
QDomElement bE = document.createElement( "boundary" );
275
bE.setAttribute( "l", QString::number( (double)d->boundary.left() ) );
276
bE.setAttribute( "t", QString::number( (double)d->boundary.top() ) );
277
bE.setAttribute( "r", QString::number( (double)d->boundary.right() ) );
278
bE.setAttribute( "b", QString::number( (double)d->boundary.bottom() ) );
280
// Sub-Node-2 - penStyle
281
if ( style.width != 1 || style.style != Solid || style.xCorners != 0 ||
282
style.yCorners != 0.0 || style.marks != 3 || style.spaces != 0 )
284
QDomElement psE = document.createElement( "penStyle" );
285
e.appendChild( psE );
286
psE.setAttribute( "width", QString::number( style.width ) );
287
psE.setAttribute( "style", (int)style.style );
288
psE.setAttribute( "xcr", QString::number( style.xCorners ) );
289
psE.setAttribute( "ycr", QString::number( style.yCorners ) );
290
psE.setAttribute( "marks", style.marks );
291
psE.setAttribute( "spaces", style.spaces );
294
// Sub-Node-3 - penEffect
295
if ( style.effect != NoEffect || style.effectIntensity != 1.0 )
297
QDomElement peE = document.createElement( "penEffect" );
298
e.appendChild( peE );
299
peE.setAttribute( "effect", (int)style.effect );
300
peE.setAttribute( "intensity", QString::number( style.effectIntensity ) );
303
// Sub-Node-4 - window
304
if ( window.flags != -1 || !window.title.isEmpty() ||
305
!window.summary.isEmpty() || !window.text.isEmpty() )
307
QDomElement wE = document.createElement( "window" );
309
wE.setAttribute( "flags", window.flags );
310
wE.setAttribute( "top", QString::number( window.topLeft.x() ) );
311
wE.setAttribute( "left", QString::number( window.topLeft.y() ) );
312
wE.setAttribute( "width", window.width );
313
wE.setAttribute( "height", window.height );
314
wE.setAttribute( "title", window.title );
315
wE.setAttribute( "summary", window.summary );
316
// store window.text as a subnode, because we need escaped data
317
if ( !window.text.isEmpty() )
319
QDomElement escapedText = document.createElement( "text" );
320
wE.appendChild( escapedText );
321
QDomCDATASection textCData = document.createCDATASection( window.text );
322
escapedText.appendChild( textCData );
326
// create [revision] element of the annotation node (if any)
327
if ( d->revisions.isEmpty() )
330
// add all revisions as children of revisions element
331
QLinkedList< Revision >::const_iterator it = d->revisions.begin(), end = d->revisions.end();
332
for ( ; it != end; ++it )
334
// create revision element
335
const Revision & revision = *it;
336
QDomElement r = document.createElement( "revision" );
337
annNode.appendChild( r );
338
// set element attributes
339
r.setAttribute( "revScope", (int)revision.scope );
340
r.setAttribute( "revType", (int)revision.type );
341
// use revision as the annotation element, so fill it up
342
AnnotationUtils::storeAnnotation( revision.annotation, r, document );
346
QString Annotation::author() const
348
Q_D( const Annotation );
352
void Annotation::setAuthor( const QString &author )
358
QString Annotation::contents() const
360
Q_D( const Annotation );
364
void Annotation::setContents( const QString &contents )
367
d->contents = contents;
370
QString Annotation::uniqueName() const
372
Q_D( const Annotation );
373
return d->uniqueName;
376
void Annotation::setUniqueName( const QString &uniqueName )
379
d->uniqueName = uniqueName;
382
QDateTime Annotation::modificationDate() const
384
Q_D( const Annotation );
388
void Annotation::setModificationDate( const QDateTime &date )
394
QDateTime Annotation::creationDate() const
396
Q_D( const Annotation );
397
return d->creationDate;
400
void Annotation::setCreationDate( const QDateTime &date )
403
d->creationDate = date;
406
int Annotation::flags() const
408
Q_D( const Annotation );
412
void Annotation::setFlags( int flags )
418
QRectF Annotation::boundary() const
420
Q_D( const Annotation );
424
void Annotation::setBoundary( const QRectF &boundary )
427
d->boundary = boundary;
430
QLinkedList< Annotation::Revision >& Annotation::revisions()
436
const QLinkedList< Annotation::Revision >& Annotation::revisions() const
438
Q_D( const Annotation );
442
//END AnnotationUtils implementation
445
/** TextAnnotation [Annotation] */
446
class TextAnnotationPrivate : public AnnotationPrivate
449
TextAnnotationPrivate();
452
TextAnnotation::TextType textType;
455
int inplaceAlign; // 0:left, 1:center, 2:right
456
QString inplaceText; // overrides contents
457
QPointF inplaceCallout[3];
458
TextAnnotation::InplaceIntent inplaceIntent;
461
TextAnnotationPrivate::TextAnnotationPrivate()
462
: AnnotationPrivate(), textType( TextAnnotation::Linked ),
463
textIcon( "Note" ), inplaceAlign( 0 ),
464
inplaceIntent( TextAnnotation::Unknown )
468
TextAnnotation::TextAnnotation()
469
: Annotation( *new TextAnnotationPrivate() )
472
TextAnnotation::TextAnnotation( const QDomNode & node )
473
: Annotation( *new TextAnnotationPrivate, node )
475
Q_D( TextAnnotation );
477
// loop through the whole children looking for a 'text' element
478
QDomNode subNode = node.firstChild();
479
while( subNode.isElement() )
481
QDomElement e = subNode.toElement();
482
subNode = subNode.nextSibling();
483
if ( e.tagName() != "text" )
486
// parse the attributes
487
if ( e.hasAttribute( "type" ) )
488
d->textType = (TextAnnotation::TextType)e.attribute( "type" ).toInt();
489
if ( e.hasAttribute( "icon" ) )
490
d->textIcon = e.attribute( "icon" );
491
if ( e.hasAttribute( "font" ) )
492
d->textFont.fromString( e.attribute( "font" ) );
493
if ( e.hasAttribute( "align" ) )
494
d->inplaceAlign = e.attribute( "align" ).toInt();
495
if ( e.hasAttribute( "intent" ) )
496
d->inplaceIntent = (TextAnnotation::InplaceIntent)e.attribute( "intent" ).toInt();
498
// parse the subnodes
499
QDomNode eSubNode = e.firstChild();
500
while ( eSubNode.isElement() )
502
QDomElement ee = eSubNode.toElement();
503
eSubNode = eSubNode.nextSibling();
505
if ( ee.tagName() == "escapedText" )
507
d->inplaceText = ee.firstChild().toCDATASection().data();
509
else if ( ee.tagName() == "callout" )
511
d->inplaceCallout[0].setX(ee.attribute( "ax" ).toDouble());
512
d->inplaceCallout[0].setY(ee.attribute( "ay" ).toDouble());
513
d->inplaceCallout[1].setX(ee.attribute( "bx" ).toDouble());
514
d->inplaceCallout[1].setY(ee.attribute( "by" ).toDouble());
515
d->inplaceCallout[2].setX(ee.attribute( "cx" ).toDouble());
516
d->inplaceCallout[2].setY(ee.attribute( "cy" ).toDouble());
525
TextAnnotation::~TextAnnotation()
529
void TextAnnotation::store( QDomNode & node, QDomDocument & document ) const
531
Q_D( const TextAnnotation );
533
// recurse to parent objects storing properties
534
Annotation::store( node, document );
536
// create [text] element
537
QDomElement textElement = document.createElement( "text" );
538
node.appendChild( textElement );
540
// store the optional attributes
541
if ( d->textType != Linked )
542
textElement.setAttribute( "type", (int)d->textType );
543
if ( d->textIcon != "Comment" )
544
textElement.setAttribute( "icon", d->textIcon );
545
if ( d->inplaceAlign )
546
textElement.setAttribute( "align", d->inplaceAlign );
547
if ( d->inplaceIntent != Unknown )
548
textElement.setAttribute( "intent", (int)d->inplaceIntent );
550
textElement.setAttribute( "font", d->textFont.toString() );
552
// Sub-Node-1 - escapedText
553
if ( !d->inplaceText.isEmpty() )
555
QDomElement escapedText = document.createElement( "escapedText" );
556
textElement.appendChild( escapedText );
557
QDomCDATASection textCData = document.createCDATASection( d->inplaceText );
558
escapedText.appendChild( textCData );
561
// Sub-Node-2 - callout
562
if ( d->inplaceCallout[0].x() != 0.0 )
564
QDomElement calloutElement = document.createElement( "callout" );
565
textElement.appendChild( calloutElement );
566
calloutElement.setAttribute( "ax", QString::number( d->inplaceCallout[0].x() ) );
567
calloutElement.setAttribute( "ay", QString::number( d->inplaceCallout[0].y() ) );
568
calloutElement.setAttribute( "bx", QString::number( d->inplaceCallout[1].x() ) );
569
calloutElement.setAttribute( "by", QString::number( d->inplaceCallout[1].y() ) );
570
calloutElement.setAttribute( "cx", QString::number( d->inplaceCallout[2].x() ) );
571
calloutElement.setAttribute( "cy", QString::number( d->inplaceCallout[2].y() ) );
575
Annotation::SubType TextAnnotation::subType() const
580
TextAnnotation::TextType TextAnnotation::textType() const
582
Q_D( const TextAnnotation );
586
void TextAnnotation::setTextType( TextAnnotation::TextType type )
588
Q_D( TextAnnotation );
592
QString TextAnnotation::textIcon() const
594
Q_D( const TextAnnotation );
598
void TextAnnotation::setTextIcon( const QString &icon )
600
Q_D( TextAnnotation );
604
QFont TextAnnotation::textFont() const
606
Q_D( const TextAnnotation );
610
void TextAnnotation::setTextFont( const QFont &font )
612
Q_D( TextAnnotation );
616
int TextAnnotation::inplaceAlign() const
618
Q_D( const TextAnnotation );
619
return d->inplaceAlign;
622
void TextAnnotation::setInplaceAlign( int align )
624
Q_D( TextAnnotation );
625
d->inplaceAlign = align;
628
QString TextAnnotation::inplaceText() const
630
Q_D( const TextAnnotation );
631
return d->inplaceText;
634
void TextAnnotation::setInplaceText( const QString &text )
636
Q_D( TextAnnotation );
637
d->inplaceText = text;
640
QPointF TextAnnotation::calloutPoint( int id ) const
642
if ( id < 0 || id >= 3 )
645
Q_D( const TextAnnotation );
646
return d->inplaceCallout[id];
649
void TextAnnotation::setCalloutPoint( int id, const QPointF &point )
651
if ( id < 0 || id >= 3 )
654
Q_D( TextAnnotation );
655
d->inplaceCallout[id] = point;
658
TextAnnotation::InplaceIntent TextAnnotation::inplaceIntent() const
660
Q_D( const TextAnnotation );
661
return d->inplaceIntent;
664
void TextAnnotation::setInplaceIntent( TextAnnotation::InplaceIntent intent )
666
Q_D( TextAnnotation );
667
d->inplaceIntent = intent;
671
/** LineAnnotation [Annotation] */
672
class LineAnnotationPrivate : public AnnotationPrivate
675
LineAnnotationPrivate();
677
// data fields (note uses border for rendering style)
678
QLinkedList<QPointF> linePoints;
679
LineAnnotation::TermStyle lineStartStyle;
680
LineAnnotation::TermStyle lineEndStyle;
681
bool lineClosed : 1; // (if true draw close shape)
682
bool lineShowCaption : 1;
683
QColor lineInnerColor;
684
double lineLeadingFwdPt;
685
double lineLeadingBackPt;
686
LineAnnotation::LineIntent lineIntent;
689
LineAnnotationPrivate::LineAnnotationPrivate()
690
: AnnotationPrivate(), lineStartStyle( LineAnnotation::None ),
691
lineEndStyle( LineAnnotation::None ), lineClosed( false ),
692
lineShowCaption( false ), lineLeadingFwdPt( 0 ), lineLeadingBackPt( 0 ),
693
lineIntent( LineAnnotation::Unknown )
697
LineAnnotation::LineAnnotation()
698
: Annotation( *new LineAnnotationPrivate() )
701
LineAnnotation::LineAnnotation( const QDomNode & node )
702
: Annotation( *new LineAnnotationPrivate(), node )
704
Q_D( LineAnnotation );
706
// loop through the whole children looking for a 'line' element
707
QDomNode subNode = node.firstChild();
708
while( subNode.isElement() )
710
QDomElement e = subNode.toElement();
711
subNode = subNode.nextSibling();
712
if ( e.tagName() != "line" )
715
// parse the attributes
716
if ( e.hasAttribute( "startStyle" ) )
717
d->lineStartStyle = (LineAnnotation::TermStyle)e.attribute( "startStyle" ).toInt();
718
if ( e.hasAttribute( "endStyle" ) )
719
d->lineEndStyle = (LineAnnotation::TermStyle)e.attribute( "endStyle" ).toInt();
720
if ( e.hasAttribute( "closed" ) )
721
d->lineClosed = e.attribute( "closed" ).toInt();
722
if ( e.hasAttribute( "innerColor" ) )
723
d->lineInnerColor = QColor( e.attribute( "innerColor" ) );
724
if ( e.hasAttribute( "leadFwd" ) )
725
d->lineLeadingFwdPt = e.attribute( "leadFwd" ).toDouble();
726
if ( e.hasAttribute( "leadBack" ) )
727
d->lineLeadingBackPt = e.attribute( "leadBack" ).toDouble();
728
if ( e.hasAttribute( "showCaption" ) )
729
d->lineShowCaption = e.attribute( "showCaption" ).toInt();
730
if ( e.hasAttribute( "intent" ) )
731
d->lineIntent = (LineAnnotation::LineIntent)e.attribute( "intent" ).toInt();
733
// parse all 'point' subnodes
734
QDomNode pointNode = e.firstChild();
735
while ( pointNode.isElement() )
737
QDomElement pe = pointNode.toElement();
738
pointNode = pointNode.nextSibling();
740
if ( pe.tagName() != "point" )
743
QPointF p(pe.attribute( "x", "0.0" ).toDouble(), pe.attribute( "y", "0.0" ).toDouble());
744
d->linePoints.append( p );
752
LineAnnotation::~LineAnnotation()
756
void LineAnnotation::store( QDomNode & node, QDomDocument & document ) const
758
Q_D( const LineAnnotation );
760
// recurse to parent objects storing properties
761
Annotation::store( node, document );
763
// create [line] element
764
QDomElement lineElement = document.createElement( "line" );
765
node.appendChild( lineElement );
767
// store the attributes
768
if ( d->lineStartStyle != None )
769
lineElement.setAttribute( "startStyle", (int)d->lineStartStyle );
770
if ( d->lineEndStyle != None )
771
lineElement.setAttribute( "endStyle", (int)d->lineEndStyle );
773
lineElement.setAttribute( "closed", d->lineClosed );
774
if ( d->lineInnerColor.isValid() )
775
lineElement.setAttribute( "innerColor", d->lineInnerColor.name() );
776
if ( d->lineLeadingFwdPt != 0.0 )
777
lineElement.setAttribute( "leadFwd", QString::number( d->lineLeadingFwdPt ) );
778
if ( d->lineLeadingBackPt != 0.0 )
779
lineElement.setAttribute( "leadBack", QString::number( d->lineLeadingBackPt ) );
780
if ( d->lineShowCaption )
781
lineElement.setAttribute( "showCaption", d->lineShowCaption );
782
if ( d->lineIntent != Unknown )
783
lineElement.setAttribute( "intent", d->lineIntent );
785
// append the list of points
786
int points = d->linePoints.count();
789
QLinkedList<QPointF>::const_iterator it = d->linePoints.begin(), end = d->linePoints.end();
792
const QPointF & p = *it;
793
QDomElement pElement = document.createElement( "point" );
794
lineElement.appendChild( pElement );
795
pElement.setAttribute( "x", QString::number( p.x() ) );
796
pElement.setAttribute( "y", QString::number( p.y() ) );
802
Annotation::SubType LineAnnotation::subType() const
807
QLinkedList<QPointF> LineAnnotation::linePoints() const
809
Q_D( const LineAnnotation );
810
return d->linePoints;
813
void LineAnnotation::setLinePoints( const QLinkedList<QPointF> &points )
815
Q_D( LineAnnotation );
816
d->linePoints = points;
819
LineAnnotation::TermStyle LineAnnotation::lineStartStyle() const
821
Q_D( const LineAnnotation );
822
return d->lineStartStyle;
825
void LineAnnotation::setLineStartStyle( LineAnnotation::TermStyle style )
827
Q_D( LineAnnotation );
828
d->lineStartStyle = style;
831
LineAnnotation::TermStyle LineAnnotation::lineEndStyle() const
833
Q_D( const LineAnnotation );
834
return d->lineEndStyle;
837
void LineAnnotation::setLineEndStyle( LineAnnotation::TermStyle style )
839
Q_D( LineAnnotation );
840
d->lineEndStyle = style;
843
bool LineAnnotation::isLineClosed() const
845
Q_D( const LineAnnotation );
846
return d->lineClosed;
849
void LineAnnotation::setLineClosed( bool closed )
851
Q_D( LineAnnotation );
852
d->lineClosed = closed;
855
QColor LineAnnotation::lineInnerColor() const
857
Q_D( const LineAnnotation );
858
return d->lineInnerColor;
861
void LineAnnotation::setLineInnerColor( const QColor &color )
863
Q_D( LineAnnotation );
864
d->lineInnerColor = color;
867
double LineAnnotation::lineLeadingForwardPoint() const
869
Q_D( const LineAnnotation );
870
return d->lineLeadingFwdPt;
873
void LineAnnotation::setLineLeadingForwardPoint( double point )
875
Q_D( LineAnnotation );
876
d->lineLeadingFwdPt = point;
879
double LineAnnotation::lineLeadingBackPoint() const
881
Q_D( const LineAnnotation );
882
return d->lineLeadingBackPt;
885
void LineAnnotation::setLineLeadingBackPoint( double point )
887
Q_D( LineAnnotation );
888
d->lineLeadingBackPt = point;
891
bool LineAnnotation::lineShowCaption() const
893
Q_D( const LineAnnotation );
894
return d->lineShowCaption;
897
void LineAnnotation::setLineShowCaption( bool show )
899
Q_D( LineAnnotation );
900
d->lineShowCaption = show;
903
LineAnnotation::LineIntent LineAnnotation::lineIntent() const
905
Q_D( const LineAnnotation );
906
return d->lineIntent;
909
void LineAnnotation::setLineIntent( LineAnnotation::LineIntent intent )
911
Q_D( LineAnnotation );
912
d->lineIntent = intent;
916
/** GeomAnnotation [Annotation] */
917
class GeomAnnotationPrivate : public AnnotationPrivate
920
GeomAnnotationPrivate();
922
// data fields (note uses border for rendering style)
923
GeomAnnotation::GeomType geomType;
924
QColor geomInnerColor;
928
GeomAnnotationPrivate::GeomAnnotationPrivate()
929
: AnnotationPrivate(), geomType( GeomAnnotation::InscribedSquare ),
934
GeomAnnotation::GeomAnnotation()
935
: Annotation( *new GeomAnnotationPrivate() )
938
GeomAnnotation::GeomAnnotation( const QDomNode & node )
939
: Annotation( *new GeomAnnotationPrivate(), node )
941
Q_D( GeomAnnotation );
943
// loop through the whole children looking for a 'geom' element
944
QDomNode subNode = node.firstChild();
945
while( subNode.isElement() )
947
QDomElement e = subNode.toElement();
948
subNode = subNode.nextSibling();
949
if ( e.tagName() != "geom" )
952
// parse the attributes
953
if ( e.hasAttribute( "type" ) )
954
d->geomType = (GeomAnnotation::GeomType)e.attribute( "type" ).toInt();
955
if ( e.hasAttribute( "color" ) )
956
d->geomInnerColor = QColor( e.attribute( "color" ) );
957
if ( e.hasAttribute( "width" ) )
958
d->geomWidthPt = e.attribute( "width" ).toInt();
965
GeomAnnotation::~GeomAnnotation()
969
void GeomAnnotation::store( QDomNode & node, QDomDocument & document ) const
971
Q_D( const GeomAnnotation );
973
// recurse to parent objects storing properties
974
Annotation::store( node, document );
976
// create [geom] element
977
QDomElement geomElement = document.createElement( "geom" );
978
node.appendChild( geomElement );
980
// append the optional attributes
981
if ( d->geomType != InscribedSquare )
982
geomElement.setAttribute( "type", (int)d->geomType );
983
if ( d->geomInnerColor.isValid() )
984
geomElement.setAttribute( "color", d->geomInnerColor.name() );
985
if ( d->geomWidthPt != 18 )
986
geomElement.setAttribute( "width", d->geomWidthPt );
989
Annotation::SubType GeomAnnotation::subType() const
994
GeomAnnotation::GeomType GeomAnnotation::geomType() const
996
Q_D( const GeomAnnotation );
1000
void GeomAnnotation::setGeomType( GeomAnnotation::GeomType type )
1002
Q_D( GeomAnnotation );
1006
QColor GeomAnnotation::geomInnerColor() const
1008
Q_D( const GeomAnnotation );
1009
return d->geomInnerColor;
1012
void GeomAnnotation::setGeomInnerColor( const QColor &color )
1014
Q_D( GeomAnnotation );
1015
d->geomInnerColor = color;
1018
int GeomAnnotation::geomPointWidth() const
1020
Q_D( const GeomAnnotation );
1021
return d->geomWidthPt;
1024
void GeomAnnotation::setGeomPointWidth( int width )
1026
Q_D( GeomAnnotation );
1027
d->geomWidthPt = width;
1032
/** HighlightAnnotation [Annotation] */
1033
class HighlightAnnotationPrivate : public AnnotationPrivate
1036
HighlightAnnotationPrivate();
1039
HighlightAnnotation::HighlightType highlightType;
1040
QList< HighlightAnnotation::Quad > highlightQuads; // not empty
1043
HighlightAnnotationPrivate::HighlightAnnotationPrivate()
1044
: AnnotationPrivate(), highlightType( HighlightAnnotation::Highlight )
1048
HighlightAnnotation::HighlightAnnotation()
1049
: Annotation( *new HighlightAnnotationPrivate() )
1052
HighlightAnnotation::HighlightAnnotation( const QDomNode & node )
1053
: Annotation( *new HighlightAnnotationPrivate(), node )
1055
Q_D( HighlightAnnotation );
1057
// loop through the whole children looking for a 'hl' element
1058
QDomNode subNode = node.firstChild();
1059
while( subNode.isElement() )
1061
QDomElement e = subNode.toElement();
1062
subNode = subNode.nextSibling();
1063
if ( e.tagName() != "hl" )
1066
// parse the attributes
1067
if ( e.hasAttribute( "type" ) )
1068
d->highlightType = (HighlightAnnotation::HighlightType)e.attribute( "type" ).toInt();
1070
// parse all 'quad' subnodes
1071
QDomNode quadNode = e.firstChild();
1072
for ( ; quadNode.isElement(); quadNode = quadNode.nextSibling() )
1074
QDomElement qe = quadNode.toElement();
1075
if ( qe.tagName() != "quad" )
1079
q.points[0].setX(qe.attribute( "ax", "0.0" ).toDouble());
1080
q.points[0].setY(qe.attribute( "ay", "0.0" ).toDouble());
1081
q.points[1].setX(qe.attribute( "bx", "0.0" ).toDouble());
1082
q.points[1].setY(qe.attribute( "by", "0.0" ).toDouble());
1083
q.points[2].setX(qe.attribute( "cx", "0.0" ).toDouble());
1084
q.points[2].setY(qe.attribute( "cy", "0.0" ).toDouble());
1085
q.points[3].setX(qe.attribute( "dx", "0.0" ).toDouble());
1086
q.points[3].setY(qe.attribute( "dy", "0.0" ).toDouble());
1087
q.capStart = qe.hasAttribute( "start" );
1088
q.capEnd = qe.hasAttribute( "end" );
1089
q.feather = qe.attribute( "feather", "0.1" ).toDouble();
1090
d->highlightQuads.append( q );
1098
HighlightAnnotation::~HighlightAnnotation()
1102
void HighlightAnnotation::store( QDomNode & node, QDomDocument & document ) const
1104
Q_D( const HighlightAnnotation );
1106
// recurse to parent objects storing properties
1107
Annotation::store( node, document );
1109
// create [hl] element
1110
QDomElement hlElement = document.createElement( "hl" );
1111
node.appendChild( hlElement );
1113
// append the optional attributes
1114
if ( d->highlightType != Highlight )
1115
hlElement.setAttribute( "type", (int)d->highlightType );
1116
if ( d->highlightQuads.count() < 1 )
1118
// append highlight quads, all children describe quads
1119
QList< HighlightAnnotation::Quad >::const_iterator it = d->highlightQuads.begin(), end = d->highlightQuads.end();
1120
for ( ; it != end; ++it )
1122
QDomElement quadElement = document.createElement( "quad" );
1123
hlElement.appendChild( quadElement );
1124
const Quad & q = *it;
1125
quadElement.setAttribute( "ax", QString::number( q.points[0].x() ) );
1126
quadElement.setAttribute( "ay", QString::number( q.points[0].y() ) );
1127
quadElement.setAttribute( "bx", QString::number( q.points[1].x() ) );
1128
quadElement.setAttribute( "by", QString::number( q.points[1].y() ) );
1129
quadElement.setAttribute( "cx", QString::number( q.points[2].x() ) );
1130
quadElement.setAttribute( "cy", QString::number( q.points[2].y() ) );
1131
quadElement.setAttribute( "dx", QString::number( q.points[3].x() ) );
1132
quadElement.setAttribute( "dy", QString::number( q.points[3].y() ) );
1134
quadElement.setAttribute( "start", 1 );
1136
quadElement.setAttribute( "end", 1 );
1137
quadElement.setAttribute( "feather", QString::number( q.feather ) );
1141
Annotation::SubType HighlightAnnotation::subType() const
1146
HighlightAnnotation::HighlightType HighlightAnnotation::highlightType() const
1148
Q_D( const HighlightAnnotation );
1149
return d->highlightType;
1152
void HighlightAnnotation::setHighlightType( HighlightAnnotation::HighlightType type )
1154
Q_D( HighlightAnnotation );
1155
d->highlightType = type;
1158
QList< HighlightAnnotation::Quad > HighlightAnnotation::highlightQuads() const
1160
Q_D( const HighlightAnnotation );
1161
return d->highlightQuads;
1164
void HighlightAnnotation::setHighlightQuads( const QList< HighlightAnnotation::Quad > &quads )
1166
Q_D( HighlightAnnotation );
1167
d->highlightQuads = quads;
1171
/** StampAnnotation [Annotation] */
1172
class StampAnnotationPrivate : public AnnotationPrivate
1175
StampAnnotationPrivate();
1178
QString stampIconName;
1181
StampAnnotationPrivate::StampAnnotationPrivate()
1182
: AnnotationPrivate(), stampIconName( "Draft" )
1186
StampAnnotation::StampAnnotation()
1187
: Annotation( *new StampAnnotationPrivate() )
1190
StampAnnotation::StampAnnotation( const QDomNode & node )
1191
: Annotation( *new StampAnnotationPrivate(), node )
1193
Q_D( StampAnnotation );
1195
// loop through the whole children looking for a 'stamp' element
1196
QDomNode subNode = node.firstChild();
1197
while( subNode.isElement() )
1199
QDomElement e = subNode.toElement();
1200
subNode = subNode.nextSibling();
1201
if ( e.tagName() != "stamp" )
1204
// parse the attributes
1205
if ( e.hasAttribute( "icon" ) )
1206
d->stampIconName = e.attribute( "icon" );
1213
StampAnnotation::~StampAnnotation()
1217
void StampAnnotation::store( QDomNode & node, QDomDocument & document ) const
1219
Q_D( const StampAnnotation );
1221
// recurse to parent objects storing properties
1222
Annotation::store( node, document );
1224
// create [stamp] element
1225
QDomElement stampElement = document.createElement( "stamp" );
1226
node.appendChild( stampElement );
1228
// append the optional attributes
1229
if ( d->stampIconName != "Draft" )
1230
stampElement.setAttribute( "icon", d->stampIconName );
1233
Annotation::SubType StampAnnotation::subType() const
1238
QString StampAnnotation::stampIconName() const
1240
Q_D( const StampAnnotation );
1241
return d->stampIconName;
1244
void StampAnnotation::setStampIconName( const QString &name )
1246
Q_D( StampAnnotation );
1247
d->stampIconName = name;
1250
/** InkAnnotation [Annotation] */
1251
class InkAnnotationPrivate : public AnnotationPrivate
1254
InkAnnotationPrivate();
1257
QList< QLinkedList<QPointF> > inkPaths;
1260
InkAnnotationPrivate::InkAnnotationPrivate()
1261
: AnnotationPrivate()
1265
InkAnnotation::InkAnnotation()
1266
: Annotation( *new InkAnnotationPrivate() )
1269
InkAnnotation::InkAnnotation( const QDomNode & node )
1270
: Annotation( *new InkAnnotationPrivate(), node )
1272
Q_D( InkAnnotation );
1274
// loop through the whole children looking for a 'ink' element
1275
QDomNode subNode = node.firstChild();
1276
while( subNode.isElement() )
1278
QDomElement e = subNode.toElement();
1279
subNode = subNode.nextSibling();
1280
if ( e.tagName() != "ink" )
1283
// parse the 'path' subnodes
1284
QDomNode pathNode = e.firstChild();
1285
while ( pathNode.isElement() )
1287
QDomElement pathElement = pathNode.toElement();
1288
pathNode = pathNode.nextSibling();
1290
if ( pathElement.tagName() != "path" )
1293
// build each path parsing 'point' subnodes
1294
QLinkedList<QPointF> path;
1295
QDomNode pointNode = pathElement.firstChild();
1296
while ( pointNode.isElement() )
1298
QDomElement pointElement = pointNode.toElement();
1299
pointNode = pointNode.nextSibling();
1301
if ( pointElement.tagName() != "point" )
1304
QPointF p(pointElement.attribute( "x", "0.0" ).toDouble(), pointElement.attribute( "y", "0.0" ).toDouble());
1308
// add the path to the path list if it contains at least 2 nodes
1309
if ( path.count() >= 2 )
1310
d->inkPaths.append( path );
1318
InkAnnotation::~InkAnnotation()
1322
void InkAnnotation::store( QDomNode & node, QDomDocument & document ) const
1324
Q_D( const InkAnnotation );
1326
// recurse to parent objects storing properties
1327
Annotation::store( node, document );
1329
// create [ink] element
1330
QDomElement inkElement = document.createElement( "ink" );
1331
node.appendChild( inkElement );
1333
// append the optional attributes
1334
if ( d->inkPaths.count() < 1 )
1336
QList< QLinkedList<QPointF> >::const_iterator pIt = d->inkPaths.begin(), pEnd = d->inkPaths.end();
1337
for ( ; pIt != pEnd; ++pIt )
1339
QDomElement pathElement = document.createElement( "path" );
1340
inkElement.appendChild( pathElement );
1341
const QLinkedList<QPointF> & path = *pIt;
1342
QLinkedList<QPointF>::const_iterator iIt = path.begin(), iEnd = path.end();
1343
for ( ; iIt != iEnd; ++iIt )
1345
const QPointF & point = *iIt;
1346
QDomElement pointElement = document.createElement( "point" );
1347
pathElement.appendChild( pointElement );
1348
pointElement.setAttribute( "x", QString::number( point.x() ) );
1349
pointElement.setAttribute( "y", QString::number( point.y() ) );
1354
Annotation::SubType InkAnnotation::subType() const
1359
QList< QLinkedList<QPointF> > InkAnnotation::inkPaths() const
1361
Q_D( const InkAnnotation );
1365
void InkAnnotation::setInkPaths( const QList< QLinkedList<QPointF> > &paths )
1367
Q_D( InkAnnotation );
1368
d->inkPaths = paths;
1372
/** LinkAnnotation [Annotation] */
1373
class LinkAnnotationPrivate : public AnnotationPrivate
1376
LinkAnnotationPrivate();
1377
~LinkAnnotationPrivate();
1380
Link * linkDestination;
1381
LinkAnnotation::HighlightMode linkHLMode;
1382
QPointF linkRegion[4];
1385
LinkAnnotationPrivate::LinkAnnotationPrivate()
1386
: AnnotationPrivate(), linkDestination( 0 ), linkHLMode( LinkAnnotation::Invert )
1390
LinkAnnotationPrivate::~LinkAnnotationPrivate()
1392
delete linkDestination;
1395
LinkAnnotation::LinkAnnotation()
1396
: Annotation( *new LinkAnnotationPrivate() )
1399
LinkAnnotation::LinkAnnotation( const QDomNode & node )
1400
: Annotation( *new LinkAnnotationPrivate(), node )
1402
Q_D( LinkAnnotation );
1404
// loop through the whole children looking for a 'link' element
1405
QDomNode subNode = node.firstChild();
1406
while( subNode.isElement() )
1408
QDomElement e = subNode.toElement();
1409
subNode = subNode.nextSibling();
1410
if ( e.tagName() != "link" )
1413
// parse the attributes
1414
if ( e.hasAttribute( "hlmode" ) )
1415
d->linkHLMode = (LinkAnnotation::HighlightMode)e.attribute( "hlmode" ).toInt();
1417
// parse all 'quad' subnodes
1418
QDomNode quadNode = e.firstChild();
1419
for ( ; quadNode.isElement(); quadNode = quadNode.nextSibling() )
1421
QDomElement qe = quadNode.toElement();
1422
if ( qe.tagName() == "quad" )
1424
d->linkRegion[0].setX(qe.attribute( "ax", "0.0" ).toDouble());
1425
d->linkRegion[0].setY(qe.attribute( "ay", "0.0" ).toDouble());
1426
d->linkRegion[1].setX(qe.attribute( "bx", "0.0" ).toDouble());
1427
d->linkRegion[1].setY(qe.attribute( "by", "0.0" ).toDouble());
1428
d->linkRegion[2].setX(qe.attribute( "cx", "0.0" ).toDouble());
1429
d->linkRegion[2].setY(qe.attribute( "cy", "0.0" ).toDouble());
1430
d->linkRegion[3].setX(qe.attribute( "dx", "0.0" ).toDouble());
1431
d->linkRegion[3].setY(qe.attribute( "dy", "0.0" ).toDouble());
1433
else if ( qe.tagName() == "link" )
1435
QString type = qe.attribute( "type" );
1436
if ( type == "GoTo" )
1438
Poppler::LinkGoto * go = new Poppler::LinkGoto( QRect(), qe.attribute( "filename" ), LinkDestination( qe.attribute( "destination" ) ) );
1439
d->linkDestination = go;
1441
else if ( type == "Exec" )
1443
Poppler::LinkExecute * exec = new Poppler::LinkExecute( QRect(), qe.attribute( "filename" ), qe.attribute( "parameters" ) );
1444
d->linkDestination = exec;
1446
else if ( type == "Browse" )
1448
Poppler::LinkBrowse * browse = new Poppler::LinkBrowse( QRect(), qe.attribute( "url" ) );
1449
d->linkDestination = browse;
1451
else if ( type == "Action" )
1453
Poppler::LinkAction::ActionType act;
1454
QString actString = qe.attribute( "action" );
1456
if ( actString == "PageFirst" )
1457
act = Poppler::LinkAction::PageFirst;
1458
else if ( actString == "PagePrev" )
1459
act = Poppler::LinkAction::PagePrev;
1460
else if ( actString == "PageNext" )
1461
act = Poppler::LinkAction::PageNext;
1462
else if ( actString == "PageLast" )
1463
act = Poppler::LinkAction::PageLast;
1464
else if ( actString == "HistoryBack" )
1465
act = Poppler::LinkAction::HistoryBack;
1466
else if ( actString == "HistoryForward" )
1467
act = Poppler::LinkAction::HistoryForward;
1468
else if ( actString == "Quit" )
1469
act = Poppler::LinkAction::Quit;
1470
else if ( actString == "Presentation" )
1471
act = Poppler::LinkAction::Presentation;
1472
else if ( actString == "EndPresentation" )
1473
act = Poppler::LinkAction::EndPresentation;
1474
else if ( actString == "Find" )
1475
act = Poppler::LinkAction::Find;
1476
else if ( actString == "GoToPage" )
1477
act = Poppler::LinkAction::GoToPage;
1478
else if ( actString == "Close" )
1479
act = Poppler::LinkAction::Close;
1480
else if ( actString == "Print" )
1481
act = Poppler::LinkAction::Print;
1486
Poppler::LinkAction * action = new Poppler::LinkAction( QRect(), act );
1487
d->linkDestination = action;
1491
else if ( type == "Movie" )
1493
Poppler::LinkMovie * movie = new Poppler::LinkMovie( QRect() );
1494
d->linkDestination = movie;
1505
LinkAnnotation::~LinkAnnotation()
1509
void LinkAnnotation::store( QDomNode & node, QDomDocument & document ) const
1511
Q_D( const LinkAnnotation );
1513
// recurse to parent objects storing properties
1514
Annotation::store( node, document );
1516
// create [hl] element
1517
QDomElement linkElement = document.createElement( "link" );
1518
node.appendChild( linkElement );
1520
// append the optional attributes
1521
if ( d->linkHLMode != Invert )
1522
linkElement.setAttribute( "hlmode", (int)d->linkHLMode );
1525
QDomElement quadElement = document.createElement( "quad" );
1526
linkElement.appendChild( quadElement );
1527
quadElement.setAttribute( "ax", QString::number( d->linkRegion[0].x() ) );
1528
quadElement.setAttribute( "ay", QString::number( d->linkRegion[0].y() ) );
1529
quadElement.setAttribute( "bx", QString::number( d->linkRegion[1].x() ) );
1530
quadElement.setAttribute( "by", QString::number( d->linkRegion[1].y() ) );
1531
quadElement.setAttribute( "cx", QString::number( d->linkRegion[2].x() ) );
1532
quadElement.setAttribute( "cy", QString::number( d->linkRegion[2].y() ) );
1533
quadElement.setAttribute( "dx", QString::number( d->linkRegion[3].x() ) );
1534
quadElement.setAttribute( "dy", QString::number( d->linkRegion[3].y() ) );
1537
QDomElement hyperlinkElement = document.createElement( "link" );
1538
linkElement.appendChild( hyperlinkElement );
1539
if ( d->linkDestination )
1541
switch( d->linkDestination->linkType() )
1543
case Poppler::Link::Goto:
1545
Poppler::LinkGoto * go = static_cast< Poppler::LinkGoto * >( d->linkDestination );
1546
hyperlinkElement.setAttribute( "type", "GoTo" );
1547
hyperlinkElement.setAttribute( "filename", go->fileName() );
1548
hyperlinkElement.setAttribute( "destionation", go->destination().toString() );
1551
case Poppler::Link::Execute:
1553
Poppler::LinkExecute * exec = static_cast< Poppler::LinkExecute * >( d->linkDestination );
1554
hyperlinkElement.setAttribute( "type", "Exec" );
1555
hyperlinkElement.setAttribute( "filename", exec->fileName() );
1556
hyperlinkElement.setAttribute( "parameters", exec->parameters() );
1559
case Poppler::Link::Browse:
1561
Poppler::LinkBrowse * browse = static_cast< Poppler::LinkBrowse * >( d->linkDestination );
1562
hyperlinkElement.setAttribute( "type", "Browse" );
1563
hyperlinkElement.setAttribute( "url", browse->url() );
1566
case Poppler::Link::Action:
1568
Poppler::LinkAction * action = static_cast< Poppler::LinkAction * >( d->linkDestination );
1569
hyperlinkElement.setAttribute( "type", "Action" );
1570
switch ( action->actionType() )
1572
case Poppler::LinkAction::PageFirst:
1573
hyperlinkElement.setAttribute( "action", "PageFirst" );
1575
case Poppler::LinkAction::PagePrev:
1576
hyperlinkElement.setAttribute( "action", "PagePrev" );
1578
case Poppler::LinkAction::PageNext:
1579
hyperlinkElement.setAttribute( "action", "PageNext" );
1581
case Poppler::LinkAction::PageLast:
1582
hyperlinkElement.setAttribute( "action", "PageLast" );
1584
case Poppler::LinkAction::HistoryBack:
1585
hyperlinkElement.setAttribute( "action", "HistoryBack" );
1587
case Poppler::LinkAction::HistoryForward:
1588
hyperlinkElement.setAttribute( "action", "HistoryForward" );
1590
case Poppler::LinkAction::Quit:
1591
hyperlinkElement.setAttribute( "action", "Quit" );
1593
case Poppler::LinkAction::Presentation:
1594
hyperlinkElement.setAttribute( "action", "Presentation" );
1596
case Poppler::LinkAction::EndPresentation:
1597
hyperlinkElement.setAttribute( "action", "EndPresentation" );
1599
case Poppler::LinkAction::Find:
1600
hyperlinkElement.setAttribute( "action", "Find" );
1602
case Poppler::LinkAction::GoToPage:
1603
hyperlinkElement.setAttribute( "action", "GoToPage" );
1605
case Poppler::LinkAction::Close:
1606
hyperlinkElement.setAttribute( "action", "Close" );
1608
case Poppler::LinkAction::Print:
1609
hyperlinkElement.setAttribute( "action", "Print" );
1614
case Poppler::Link::Movie:
1616
hyperlinkElement.setAttribute( "type", "Movie" );
1619
case Poppler::Link::Sound:
1621
// FIXME: implement me
1624
case Poppler::Link::None:
1630
Annotation::SubType LinkAnnotation::subType() const
1635
Link* LinkAnnotation::linkDestionation() const
1637
Q_D( const LinkAnnotation );
1638
return d->linkDestination;
1641
void LinkAnnotation::setLinkDestination( Link *link )
1643
Q_D( LinkAnnotation );
1644
delete d->linkDestination;
1645
d->linkDestination = link;
1648
LinkAnnotation::HighlightMode LinkAnnotation::linkHighlightMode() const
1650
Q_D( const LinkAnnotation );
1651
return d->linkHLMode;
1654
void LinkAnnotation::setLinkHighlightMode( LinkAnnotation::HighlightMode mode )
1656
Q_D( LinkAnnotation );
1657
d->linkHLMode = mode;
1660
QPointF LinkAnnotation::linkRegionPoint( int id ) const
1662
if ( id < 0 || id >= 4 )
1665
Q_D( const LinkAnnotation );
1666
return d->linkRegion[id];
1669
void LinkAnnotation::setLinkRegionPoint( int id, const QPointF &point )
1671
if ( id < 0 || id >= 4 )
1674
Q_D( LinkAnnotation );
1675
d->linkRegion[id] = point;
1678
/** CaretAnnotation [Annotation] */
1679
class CaretAnnotationPrivate : public AnnotationPrivate
1682
CaretAnnotationPrivate();
1685
CaretAnnotation::CaretSymbol symbol;
1688
static QString caretSymbolToString( CaretAnnotation::CaretSymbol symbol )
1692
case CaretAnnotation::None:
1693
return QString::fromLatin1( "None" );
1694
case CaretAnnotation::P:
1695
return QString::fromLatin1( "P" );
1700
static CaretAnnotation::CaretSymbol caretSymbolFromString( const QString &symbol )
1702
if ( symbol == QLatin1String( "None" ) )
1703
return CaretAnnotation::None;
1704
else if ( symbol == QLatin1String( "P" ) )
1705
return CaretAnnotation::P;
1706
return CaretAnnotation::None;
1709
CaretAnnotationPrivate::CaretAnnotationPrivate()
1710
: AnnotationPrivate(), symbol( CaretAnnotation::None )
1714
CaretAnnotation::CaretAnnotation()
1715
: Annotation( *new CaretAnnotationPrivate() )
1719
CaretAnnotation::CaretAnnotation( const QDomNode & node )
1720
: Annotation( *new CaretAnnotationPrivate(), node )
1722
Q_D( CaretAnnotation );
1724
// loop through the whole children looking for a 'caret' element
1725
QDomNode subNode = node.firstChild();
1726
while( subNode.isElement() )
1728
QDomElement e = subNode.toElement();
1729
subNode = subNode.nextSibling();
1730
if ( e.tagName() != "caret" )
1733
// parse the attributes
1734
if ( e.hasAttribute( "symbol" ) )
1735
d->symbol = caretSymbolFromString( e.attribute( "symbol" ) );
1742
CaretAnnotation::~CaretAnnotation()
1746
void CaretAnnotation::store( QDomNode & node, QDomDocument & document ) const
1748
Q_D( const CaretAnnotation );
1750
// recurse to parent objects storing properties
1751
Annotation::store( node, document );
1753
// create [caret] element
1754
QDomElement caretElement = document.createElement( "caret" );
1755
node.appendChild( caretElement );
1757
// append the optional attributes
1758
if ( d->symbol != CaretAnnotation::None )
1759
caretElement.setAttribute( "symbol", caretSymbolToString( d->symbol ) );
1762
Annotation::SubType CaretAnnotation::subType() const
1767
CaretAnnotation::CaretSymbol CaretAnnotation::caretSymbol() const
1769
Q_D( const CaretAnnotation );
1773
void CaretAnnotation::setCaretSymbol( CaretAnnotation::CaretSymbol symbol )
1775
Q_D( CaretAnnotation );
1779
/** FileAttachmentAnnotation [Annotation] */
1780
class FileAttachmentAnnotationPrivate : public AnnotationPrivate
1783
FileAttachmentAnnotationPrivate();
1784
~FileAttachmentAnnotationPrivate();
1788
EmbeddedFile *embfile;
1791
FileAttachmentAnnotationPrivate::FileAttachmentAnnotationPrivate()
1792
: AnnotationPrivate(), icon( "PushPin" ), embfile( 0 )
1796
FileAttachmentAnnotationPrivate::~FileAttachmentAnnotationPrivate()
1801
FileAttachmentAnnotation::FileAttachmentAnnotation()
1802
: Annotation( *new FileAttachmentAnnotationPrivate() )
1806
FileAttachmentAnnotation::FileAttachmentAnnotation( const QDomNode & node )
1807
: Annotation( *new FileAttachmentAnnotationPrivate(), node )
1809
// loop through the whole children looking for a 'fileattachment' element
1810
QDomNode subNode = node.firstChild();
1811
while( subNode.isElement() )
1813
QDomElement e = subNode.toElement();
1814
subNode = subNode.nextSibling();
1815
if ( e.tagName() != "fileattachment" )
1823
FileAttachmentAnnotation::~FileAttachmentAnnotation()
1827
void FileAttachmentAnnotation::store( QDomNode & node, QDomDocument & document ) const
1829
// recurse to parent objects storing properties
1830
Annotation::store( node, document );
1832
// create [fileattachment] element
1833
QDomElement fileAttachmentElement = document.createElement( "fileattachment" );
1834
node.appendChild( fileAttachmentElement );
1837
Annotation::SubType FileAttachmentAnnotation::subType() const
1839
return AFileAttachment;
1842
QString FileAttachmentAnnotation::fileIconName() const
1844
Q_D( const FileAttachmentAnnotation );
1848
void FileAttachmentAnnotation::setFileIconName( const QString &icon )
1850
Q_D( FileAttachmentAnnotation );
1854
EmbeddedFile* FileAttachmentAnnotation::embeddedFile() const
1856
Q_D( const FileAttachmentAnnotation );
1860
void FileAttachmentAnnotation::setEmbeddedFile( EmbeddedFile *ef )
1862
Q_D( FileAttachmentAnnotation );
1866
/** SoundAnnotation [Annotation] */
1867
class SoundAnnotationPrivate : public AnnotationPrivate
1870
SoundAnnotationPrivate();
1871
~SoundAnnotationPrivate();
1878
SoundAnnotationPrivate::SoundAnnotationPrivate()
1879
: AnnotationPrivate(), icon( "Speaker" ), sound( 0 )
1883
SoundAnnotationPrivate::~SoundAnnotationPrivate()
1888
SoundAnnotation::SoundAnnotation()
1889
: Annotation( *new SoundAnnotationPrivate() )
1893
SoundAnnotation::SoundAnnotation( const QDomNode & node )
1894
: Annotation( *new SoundAnnotationPrivate(), node )
1896
// loop through the whole children looking for a 'sound' element
1897
QDomNode subNode = node.firstChild();
1898
while( subNode.isElement() )
1900
QDomElement e = subNode.toElement();
1901
subNode = subNode.nextSibling();
1902
if ( e.tagName() != "sound" )
1910
SoundAnnotation::~SoundAnnotation()
1914
void SoundAnnotation::store( QDomNode & node, QDomDocument & document ) const
1916
// recurse to parent objects storing properties
1917
Annotation::store( node, document );
1919
// create [sound] element
1920
QDomElement soundElement = document.createElement( "sound" );
1921
node.appendChild( soundElement );
1924
Annotation::SubType SoundAnnotation::subType() const
1929
QString SoundAnnotation::soundIconName() const
1931
Q_D( const SoundAnnotation );
1935
void SoundAnnotation::setSoundIconName( const QString &icon )
1937
Q_D( SoundAnnotation );
1941
SoundObject* SoundAnnotation::sound() const
1943
Q_D( const SoundAnnotation );
1947
void SoundAnnotation::setSound( SoundObject *s )
1949
Q_D( SoundAnnotation );
1953
/** MovieAnnotation [Annotation] */
1954
class MovieAnnotationPrivate : public AnnotationPrivate
1957
MovieAnnotationPrivate();
1958
~MovieAnnotationPrivate();
1965
MovieAnnotationPrivate::MovieAnnotationPrivate()
1966
: AnnotationPrivate(), movie( 0 )
1970
MovieAnnotationPrivate::~MovieAnnotationPrivate()
1975
MovieAnnotation::MovieAnnotation()
1976
: Annotation( *new MovieAnnotationPrivate() )
1980
MovieAnnotation::MovieAnnotation( const QDomNode & node )
1981
: Annotation( *new MovieAnnotationPrivate(), node )
1983
// loop through the whole children looking for a 'movie' element
1984
QDomNode subNode = node.firstChild();
1985
while( subNode.isElement() )
1987
QDomElement e = subNode.toElement();
1988
subNode = subNode.nextSibling();
1989
if ( e.tagName() != "movie" )
1997
MovieAnnotation::~MovieAnnotation()
2001
void MovieAnnotation::store( QDomNode & node, QDomDocument & document ) const
2003
// recurse to parent objects storing properties
2004
Annotation::store( node, document );
2006
// create [movie] element
2007
QDomElement movieElement = document.createElement( "movie" );
2008
node.appendChild( movieElement );
2011
Annotation::SubType MovieAnnotation::subType() const
2016
MovieObject* MovieAnnotation::movie() const
2018
Q_D( const MovieAnnotation );
2022
void MovieAnnotation::setMovie( MovieObject *movie )
2024
Q_D( MovieAnnotation );
2028
QString MovieAnnotation::movieTitle() const
2030
Q_D( const MovieAnnotation );
2034
void MovieAnnotation::setMovieTitle( const QString &title )
2036
Q_D( MovieAnnotation );
2040
//BEGIN utility annotation functions
2041
QColor convertAnnotColor( AnnotColor *color )
2047
const double *color_data = color->getValues();
2048
switch ( color->getSpace() )
2050
case AnnotColor::colorTransparent: // = 0,
2051
newcolor = Qt::transparent;
2053
case AnnotColor::colorGray: // = 1,
2054
newcolor.setRgbF( color_data[0], color_data[0], color_data[0] );
2056
case AnnotColor::colorRGB: // = 3,
2057
newcolor.setRgbF( color_data[0], color_data[1], color_data[2] );
2059
case AnnotColor::colorCMYK: // = 4
2060
newcolor.setCmykF( color_data[0], color_data[1], color_data[2], color_data[3] );
2065
//END utility annotation functions