• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegraphics API Reference
  • KDE Home
  • Contact Us
 

okular

  • sources
  • kde-4.12
  • kdegraphics
  • okular
  • core
annotations.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  ***************************************************************************/
9 
10 #include "annotations.h"
11 #include "annotations_p.h"
12 
13 // qt/kde includes
14 #include <QtGui/QApplication>
15 #include <QtGui/QColor>
16 
17 // DBL_MAX
18 #include <float.h>
19 
20 // local includes
21 #include "action.h"
22 #include "document.h"
23 #include "document_p.h"
24 #include "movie.h"
25 #include "page_p.h"
26 #include "sound.h"
27 
28 using namespace Okular;
29 
34 static bool isLeftOfVector( const NormalizedPoint& a, const NormalizedPoint& b, const NormalizedPoint& c )
35 {
36  //cross product
37  return ( (b.x - a.x) * ( c.y - a.y) - ( b.y - a.y ) * ( c.x - a.x ) ) > 0;
38 }
39 
45 static double distanceSqr( double x, double y, double xScale, double yScale, const QLinkedList<NormalizedPoint>& path )
46 {
47  double distance = DBL_MAX;
48  double thisDistance;
49  QLinkedList<NormalizedPoint>::const_iterator i = path.constBegin();
50  NormalizedPoint lastPoint = *i;
51 
52  for (++i; i != path.constEnd(); ++i) {
53  thisDistance = NormalizedPoint::distanceSqr( x, y, xScale, yScale, lastPoint, (*i) );
54 
55  if ( thisDistance < distance )
56  distance = thisDistance;
57 
58  lastPoint = *i;
59  }
60  return distance;
61 }
62 
84 static double strokeDistance( double distance, double penWidth )
85 {
86  return fmax(distance - pow( penWidth, 2 ), 0);
87 }
88 
89 //BEGIN AnnotationUtils implementation
90 Annotation * AnnotationUtils::createAnnotation( const QDomElement & annElement )
91 {
92  // safety check on annotation element
93  if ( !annElement.hasAttribute( "type" ) )
94  return 0;
95 
96  // build annotation of given type
97  Annotation * annotation = 0;
98  int typeNumber = annElement.attribute( "type" ).toInt();
99  switch ( typeNumber )
100  {
101  case Annotation::AText:
102  annotation = new TextAnnotation( annElement );
103  break;
104  case Annotation::ALine:
105  annotation = new LineAnnotation( annElement );
106  break;
107  case Annotation::AGeom:
108  annotation = new GeomAnnotation( annElement );
109  break;
110  case Annotation::AHighlight:
111  annotation = new HighlightAnnotation( annElement );
112  break;
113  case Annotation::AStamp:
114  annotation = new StampAnnotation( annElement );
115  break;
116  case Annotation::AInk:
117  annotation = new InkAnnotation( annElement );
118  break;
119  case Annotation::ACaret:
120  annotation = new CaretAnnotation( annElement );
121  break;
122  }
123 
124  // return created annotation
125  return annotation;
126 }
127 
128 void AnnotationUtils::storeAnnotation( const Annotation * ann, QDomElement & annElement,
129  QDomDocument & document )
130 {
131  // save annotation's type as element's attribute
132  annElement.setAttribute( "type", (uint)ann->subType() );
133 
134  // append all annotation data as children of this node
135  ann->store( annElement, document );
136 }
137 
138 QDomElement AnnotationUtils::findChildElement( const QDomNode & parentNode,
139  const QString & name )
140 {
141  // loop through the whole children and return a 'name' named element
142  QDomNode subNode = parentNode.firstChild();
143  while( subNode.isElement() )
144  {
145  QDomElement element = subNode.toElement();
146  if ( element.tagName() == name )
147  return element;
148  subNode = subNode.nextSibling();
149  }
150  // if the name can't be found, return a dummy null element
151  return QDomElement();
152 }
153 
154 QRect AnnotationUtils::annotationGeometry( const Annotation * ann,
155  double scaledWidth, double scaledHeight )
156 {
157  const QRect rect = ann->transformedBoundingRectangle().geometry( (int)scaledWidth, (int)scaledHeight );
158  if ( ann->subType() == Annotation::AText && ( ( (TextAnnotation*)ann )->textType() == TextAnnotation::Linked ) )
159  {
160  // To be honest i have no clue of why the 24,24 is here, maybe to make sure it's not too small?
161  // But why only for linked text?
162  const QRect rect24 = QRect( (int)( ann->transformedBoundingRectangle().left * scaledWidth ),
163  (int)( ann->transformedBoundingRectangle().top * scaledHeight ), 24, 24 );
164  return rect24.united(rect);
165  }
166 
167  return rect;
168 }
169 //END AnnotationUtils implementation
170 
171 AnnotationProxy::~AnnotationProxy()
172 {
173 }
174 
175 //BEGIN Annotation implementation
176 
177 class Annotation::Style::Private
178 {
179  public:
180  Private()
181  : m_opacity( 1.0 ), m_width( 1.0 ), m_style( Solid ), m_xCorners( 0.0 ),
182  m_yCorners( 0.0 ), m_marks( 3 ), m_spaces( 0 ), m_effect( NoEffect ),
183  m_effectIntensity( 1.0 )
184  {
185  }
186 
187  QColor m_color;
188  double m_opacity;
189  double m_width;
190  LineStyle m_style;
191  double m_xCorners;
192  double m_yCorners;
193  int m_marks;
194  int m_spaces;
195  LineEffect m_effect;
196  double m_effectIntensity;
197 };
198 
199 Annotation::Style::Style()
200  : d( new Private )
201 {
202 }
203 
204 Annotation::Style::~Style()
205 {
206  delete d;
207 }
208 
209 Annotation::Style::Style( const Style &other )
210  : d( new Private )
211 {
212  *d = *other.d;
213 }
214 
215 Annotation::Style& Annotation::Style::operator=( const Style &other )
216 {
217  if ( this != &other )
218  *d = *other.d;
219 
220  return *this;
221 }
222 
223 void Annotation::Style::setColor( const QColor &color )
224 {
225  d->m_color = color;
226 }
227 
228 QColor Annotation::Style::color() const
229 {
230  return d->m_color;
231 }
232 
233 void Annotation::Style::setOpacity( double opacity )
234 {
235  d->m_opacity = opacity;
236 }
237 
238 double Annotation::Style::opacity() const
239 {
240  return d->m_opacity;
241 }
242 
243 void Annotation::Style::setWidth( double width )
244 {
245  d->m_width = width;
246 }
247 
248 double Annotation::Style::width() const
249 {
250  return d->m_width;
251 }
252 
253 void Annotation::Style::setLineStyle( LineStyle style )
254 {
255  d->m_style = style;
256 }
257 
258 Annotation::LineStyle Annotation::Style::lineStyle() const
259 {
260  return d->m_style;
261 }
262 
263 void Annotation::Style::setXCorners( double xCorners )
264 {
265  d->m_xCorners = xCorners;
266 }
267 
268 double Annotation::Style::xCorners() const
269 {
270  return d->m_xCorners;
271 }
272 
273 void Annotation::Style::setYCorners( double yCorners )
274 {
275  d->m_yCorners = yCorners;
276 }
277 
278 double Annotation::Style::yCorners() const
279 {
280  return d->m_yCorners;
281 }
282 
283 void Annotation::Style::setMarks( int marks )
284 {
285  d->m_marks = marks;
286 }
287 
288 int Annotation::Style::marks() const
289 {
290  return d->m_marks;
291 }
292 
293 void Annotation::Style::setSpaces( int spaces )
294 {
295  d->m_spaces = spaces;
296 }
297 
298 int Annotation::Style::spaces() const
299 {
300  return d->m_spaces;
301 }
302 
303 void Annotation::Style::setLineEffect( LineEffect effect )
304 {
305  d->m_effect = effect;
306 }
307 
308 Annotation::LineEffect Annotation::Style::lineEffect() const
309 {
310  return d->m_effect;
311 }
312 
313 void Annotation::Style::setEffectIntensity( double intensity )
314 {
315  d->m_effectIntensity = intensity;
316 }
317 
318 double Annotation::Style::effectIntensity() const
319 {
320  return d->m_effectIntensity;
321 }
322 
323 
324 class Annotation::Window::Private
325 {
326  public:
327  Private()
328  : m_flags( -1 ), m_width( 0 ), m_height( 0 )
329  {
330  }
331 
332  int m_flags;
333  NormalizedPoint m_topLeft;
334  int m_width;
335  int m_height;
336  QString m_title;
337  QString m_summary;
338 };
339 
340 Annotation::Window::Window()
341  : d( new Private )
342 {
343 }
344 
345 Annotation::Window::~Window()
346 {
347  delete d;
348 }
349 
350 Annotation::Window::Window( const Window &other )
351  : d( new Private )
352 {
353  *d = *other.d;
354 }
355 
356 Annotation::Window& Annotation::Window::operator=( const Window &other )
357 {
358  if ( this != &other )
359  *d = *other.d;
360 
361  return *this;
362 }
363 
364 void Annotation::Window::setFlags( int flags )
365 {
366  d->m_flags = flags;
367 }
368 
369 int Annotation::Window::flags() const
370 {
371  return d->m_flags;
372 }
373 
374 void Annotation::Window::setTopLeft( const NormalizedPoint &point )
375 {
376  d->m_topLeft = point;
377 }
378 
379 NormalizedPoint Annotation::Window::topLeft() const
380 {
381  return d->m_topLeft;
382 }
383 
384 void Annotation::Window::setWidth( int width )
385 {
386  d->m_width = width;
387 }
388 
389 int Annotation::Window::width() const
390 {
391  return d->m_width;
392 }
393 
394 void Annotation::Window::setHeight( int height )
395 {
396  d->m_height = height;
397 }
398 
399 int Annotation::Window::height() const
400 {
401  return d->m_height;
402 }
403 
404 void Annotation::Window::setTitle( const QString &title )
405 {
406  d->m_title = title;
407 }
408 
409 QString Annotation::Window::title() const
410 {
411  return d->m_title;
412 }
413 
414 void Annotation::Window::setSummary( const QString &summary )
415 {
416  d->m_summary = summary;
417 }
418 
419 QString Annotation::Window::summary() const
420 {
421  return d->m_summary;
422 }
423 
424 class Annotation::Revision::Private
425 {
426  public:
427  Private()
428  : m_annotation( 0 ), m_scope( Reply ), m_type( None )
429  {
430  }
431 
432  Annotation *m_annotation;
433  RevisionScope m_scope;
434  RevisionType m_type;
435 };
436 
437 Annotation::Revision::Revision()
438  : d( new Private )
439 {
440 }
441 
442 Annotation::Revision::~Revision()
443 {
444  delete d;
445 }
446 
447 Annotation::Revision::Revision( const Revision &other )
448  : d( new Private )
449 {
450  *d = *other.d;
451 }
452 
453 Annotation::Revision& Annotation::Revision::operator=( const Revision &other )
454 {
455  if ( this != &other )
456  *d = *other.d;
457 
458  return *this;
459 }
460 
461 void Annotation::Revision::setAnnotation( Annotation *annotation )
462 {
463  d->m_annotation = annotation;
464 }
465 
466 Annotation *Annotation::Revision::annotation() const
467 {
468  return d->m_annotation;
469 }
470 
471 void Annotation::Revision::setScope( RevisionScope scope )
472 {
473  d->m_scope = scope;
474 }
475 
476 Annotation::RevisionScope Annotation::Revision::scope() const
477 {
478  return d->m_scope;
479 }
480 
481 void Annotation::Revision::setType( RevisionType type )
482 {
483  d->m_type = type;
484 }
485 
486 Annotation::RevisionType Annotation::Revision::type() const
487 {
488  return d->m_type;
489 }
490 
491 
492 AnnotationPrivate::AnnotationPrivate()
493  : m_page( 0 ), m_flags( 0 ), m_disposeFunc( 0 )
494 {
495 }
496 
497 AnnotationPrivate::~AnnotationPrivate()
498 {
499  // delete all children revisions
500  if ( m_revisions.isEmpty() )
501  return;
502 
503  QLinkedList< Annotation::Revision >::iterator it = m_revisions.begin(), end = m_revisions.end();
504  for ( ; it != end; ++it )
505  delete (*it).annotation();
506 }
507 
508 Annotation::Annotation( AnnotationPrivate &dd )
509  : d_ptr( &dd )
510 {
511 }
512 
513 Annotation::Annotation( AnnotationPrivate &dd, const QDomNode & annNode )
514  : d_ptr( &dd )
515 {
516  d_ptr->setAnnotationProperties( annNode );
517 }
518 
519 Annotation::~Annotation()
520 {
521  if ( d_ptr->m_disposeFunc )
522  d_ptr->m_disposeFunc( this );
523 
524  delete d_ptr;
525 }
526 
527 void Annotation::setAuthor( const QString &author )
528 {
529  Q_D( Annotation );
530  d->m_author = author;
531 }
532 
533 QString Annotation::author() const
534 {
535  Q_D( const Annotation );
536  return d->m_author;
537 }
538 
539 void Annotation::setContents( const QString &contents )
540 {
541  Q_D( Annotation );
542  d->m_contents = contents;
543 }
544 
545 QString Annotation::contents() const
546 {
547  Q_D( const Annotation );
548  return d->m_contents;
549 }
550 
551 void Annotation::setUniqueName( const QString &name )
552 {
553  Q_D( Annotation );
554  d->m_uniqueName = name;
555 }
556 
557 QString Annotation::uniqueName() const
558 {
559  Q_D( const Annotation );
560  return d->m_uniqueName;
561 }
562 
563 void Annotation::setModificationDate( const QDateTime &date )
564 {
565  Q_D( Annotation );
566  d->m_modifyDate = date;
567 }
568 
569 QDateTime Annotation::modificationDate() const
570 {
571  Q_D( const Annotation );
572  return d->m_modifyDate;
573 }
574 
575 void Annotation::setCreationDate( const QDateTime &date )
576 {
577  Q_D( Annotation );
578  d->m_creationDate = date;
579 }
580 
581 QDateTime Annotation::creationDate() const
582 {
583  Q_D( const Annotation );
584  return d->m_creationDate;
585 }
586 
587 void Annotation::setFlags( int flags )
588 {
589  Q_D( Annotation );
590  d->m_flags = flags;
591 }
592 
593 int Annotation::flags() const
594 {
595  Q_D( const Annotation );
596  return d->m_flags;
597 }
598 
599 void Annotation::setBoundingRectangle( const NormalizedRect &rectangle )
600 {
601  Q_D( Annotation );
602  d->m_boundary = rectangle;
603  d->resetTransformation();
604  if ( d->m_page )
605  {
606  d->transform( d->m_page->rotationMatrix() );
607  }
608 }
609 
610 NormalizedRect Annotation::boundingRectangle() const
611 {
612  Q_D( const Annotation );
613  return d->m_boundary;
614 }
615 
616 NormalizedRect Annotation::transformedBoundingRectangle() const
617 {
618  Q_D( const Annotation );
619  return d->m_transformedBoundary;
620 }
621 
622 void Annotation::translate( const NormalizedPoint &coord )
623 {
624  Q_D( Annotation );
625  d->translate( coord );
626  d->resetTransformation();
627  if ( d->m_page )
628  {
629  d->transform( d->m_page->rotationMatrix() );
630  }
631 }
632 
633 bool Annotation::openDialogAfterCreation() const
634 {
635  Q_D( const Annotation );
636  return d->openDialogAfterCreation();
637 }
638 
639 Annotation::Style & Annotation::style()
640 {
641  Q_D( Annotation );
642  return d->m_style;
643 }
644 
645 const Annotation::Style & Annotation::style() const
646 {
647  Q_D( const Annotation );
648  return d->m_style;
649 }
650 
651 Annotation::Window & Annotation::window()
652 {
653  Q_D( Annotation );
654  return d->m_window;
655 }
656 
657 const Annotation::Window & Annotation::window() const
658 {
659  Q_D( const Annotation );
660  return d->m_window;
661 }
662 
663 QLinkedList< Annotation::Revision > & Annotation::revisions()
664 {
665  Q_D( Annotation );
666  return d->m_revisions;
667 }
668 
669 const QLinkedList< Annotation::Revision > & Annotation::revisions() const
670 {
671  Q_D( const Annotation );
672  return d->m_revisions;
673 }
674 
675 void Annotation::setNativeId( const QVariant &id )
676 {
677  Q_D( Annotation );
678  d->m_nativeId = id;
679 }
680 
681 QVariant Annotation::nativeId() const
682 {
683  Q_D( const Annotation );
684  return d->m_nativeId;
685 }
686 
687 void Annotation::setDisposeDataFunction( DisposeDataFunction func )
688 {
689  Q_D( Annotation );
690  d->m_disposeFunc = func;
691 }
692 
693 bool Annotation::canBeMoved() const
694 {
695  Q_D( const Annotation );
696 
697  // Don't move annotations if they cannot be modified
698  if ( !d->m_page || !d->m_page->m_doc->m_parent->canModifyPageAnnotation(this) )
699  return false;
700 
701  // highlight "requires" to be "bounded" to text, and that's tricky for now
702  if ( subType() == AHighlight )
703  return false;
704 
705  return true;
706 }
707 
708 void Annotation::store( QDomNode & annNode, QDomDocument & document ) const
709 {
710  Q_D( const Annotation );
711  // create [base] element of the annotation node
712  QDomElement e = document.createElement( "base" );
713  annNode.appendChild( e );
714 
715  // store -contents- attributes
716  if ( !d->m_author.isEmpty() )
717  e.setAttribute( "author", d->m_author );
718  if ( !d->m_contents.isEmpty() )
719  e.setAttribute( "contents", d->m_contents );
720  if ( !d->m_uniqueName.isEmpty() )
721  e.setAttribute( "uniqueName", d->m_uniqueName );
722  if ( d->m_modifyDate.isValid() )
723  e.setAttribute( "modifyDate", d->m_modifyDate.toString(Qt::ISODate) );
724  if ( d->m_creationDate.isValid() )
725  e.setAttribute( "creationDate", d->m_creationDate.toString(Qt::ISODate) );
726 
727  // store -other- attributes
728  if ( d->m_flags ) // Strip internal flags
729  e.setAttribute( "flags", d->m_flags & ~(External | ExternallyDrawn | BeingMoved) );
730  if ( d->m_style.color().isValid() )
731  e.setAttribute( "color", d->m_style.color().name() );
732  if ( d->m_style.opacity() != 1.0 )
733  e.setAttribute( "opacity", QString::number( d->m_style.opacity() ) );
734 
735  // Sub-Node-1 - boundary
736  QDomElement bE = document.createElement( "boundary" );
737  e.appendChild( bE );
738  bE.setAttribute( "l", QString::number( d->m_boundary.left ) );
739  bE.setAttribute( "t", QString::number( d->m_boundary.top ) );
740  bE.setAttribute( "r", QString::number( d->m_boundary.right ) );
741  bE.setAttribute( "b", QString::number( d->m_boundary.bottom ) );
742 
743  // Sub-Node-2 - penStyle
744  if ( d->m_style.width() != 1 || d->m_style.lineStyle() != Solid || d->m_style.xCorners() != 0 ||
745  d->m_style.yCorners() != 0.0 || d->m_style.marks() != 3 || d->m_style.spaces() != 0 )
746  {
747  QDomElement psE = document.createElement( "penStyle" );
748  e.appendChild( psE );
749  psE.setAttribute( "width", QString::number( d->m_style.width() ) );
750  psE.setAttribute( "style", (int)d->m_style.lineStyle() );
751  psE.setAttribute( "xcr", QString::number( d->m_style.xCorners() ) );
752  psE.setAttribute( "ycr", QString::number( d->m_style.yCorners() ) );
753  psE.setAttribute( "marks", d->m_style.marks() );
754  psE.setAttribute( "spaces", d->m_style.spaces() );
755  }
756 
757  // Sub-Node-3 - penEffect
758  if ( d->m_style.lineEffect() != NoEffect || d->m_style.effectIntensity() != 1.0 )
759  {
760  QDomElement peE = document.createElement( "penEffect" );
761  e.appendChild( peE );
762  peE.setAttribute( "effect", (int)d->m_style.lineEffect() );
763  peE.setAttribute( "intensity", QString::number( d->m_style.effectIntensity() ) );
764  }
765 
766  // Sub-Node-4 - window
767  if ( d->m_window.flags() != -1 || !d->m_window.title().isEmpty() ||
768  !d->m_window.summary().isEmpty() )
769  {
770  QDomElement wE = document.createElement( "window" );
771  e.appendChild( wE );
772  wE.setAttribute( "flags", d->m_window.flags() );
773  wE.setAttribute( "top", QString::number( d->m_window.topLeft().x ) );
774  wE.setAttribute( "left", QString::number( d->m_window.topLeft().y ) );
775  wE.setAttribute( "width", d->m_window.width() );
776  wE.setAttribute( "height", d->m_window.height() );
777  wE.setAttribute( "title", d->m_window.title() );
778  wE.setAttribute( "summary", d->m_window.summary() );
779  }
780 
781  // create [revision] element of the annotation node (if any)
782  if ( d->m_revisions.isEmpty() )
783  return;
784 
785  // add all revisions as children of revisions element
786  QLinkedList< Revision >::const_iterator it = d->m_revisions.begin(), end = d->m_revisions.end();
787  for ( ; it != end; ++it )
788  {
789  // create revision element
790  const Revision & revision = *it;
791  QDomElement r = document.createElement( "revision" );
792  annNode.appendChild( r );
793  // set element attributes
794  r.setAttribute( "revScope", (int)revision.scope() );
795  r.setAttribute( "revType", (int)revision.type() );
796  // use revision as the annotation element, so fill it up
797  AnnotationUtils::storeAnnotation( revision.annotation(), r, document );
798  }
799 }
800 
801 QDomNode Annotation::getAnnotationPropertiesDomNode() const
802 {
803  QDomDocument doc( "documentInfo" );
804  QDomElement node = doc.createElement( "annotation" );
805 
806  store(node, doc);
807  return node;
808 }
809 
810 void Annotation::setAnnotationProperties( const QDomNode& node )
811 {
812  // Save off internal properties that aren't contained in node
813  Okular::PagePrivate *p = d_ptr->m_page;
814  QVariant nativeID = d_ptr->m_nativeId;
815  int internalFlags = d_ptr->m_flags & (External | ExternallyDrawn | BeingMoved);
816  Annotation::DisposeDataFunction disposeFunc = d_ptr->m_disposeFunc;
817 
818  // Replace AnnotationPrivate object with a fresh copy
819  AnnotationPrivate *new_d_ptr = d_ptr->getNewAnnotationPrivate();
820  delete( d_ptr );
821  d_ptr = new_d_ptr;
822 
823  // Set the annotations properties from node
824  d_ptr->setAnnotationProperties(node);
825 
826  // Restore internal properties
827  d_ptr->m_page = p;
828  d_ptr->m_nativeId = nativeID;
829  d_ptr->m_flags = d_ptr->m_flags | internalFlags;
830  d_ptr->m_disposeFunc = disposeFunc;
831 
832  // Transform annotation to current page rotation
833  d_ptr->transform( d_ptr->m_page->rotationMatrix() );
834 }
835 
836 double AnnotationPrivate::distanceSqr( double x, double y, double xScale, double yScale )
837 {
838  return m_transformedBoundary.distanceSqr( x, y, xScale, yScale );
839 }
840 
841 void AnnotationPrivate::annotationTransform( const QTransform &matrix )
842 {
843  resetTransformation();
844  transform( matrix );
845 }
846 
847 void AnnotationPrivate::transform( const QTransform &matrix )
848 {
849  m_transformedBoundary.transform( matrix );
850 }
851 
852 void AnnotationPrivate::baseTransform( const QTransform &matrix )
853 {
854  m_boundary.transform( matrix );
855 }
856 
857 void AnnotationPrivate::resetTransformation()
858 {
859  m_transformedBoundary = m_boundary;
860 }
861 
862 void AnnotationPrivate::translate( const NormalizedPoint &coord )
863 {
864  m_boundary.left = m_boundary.left + coord.x;
865  m_boundary.right = m_boundary.right + coord.x;
866  m_boundary.top = m_boundary.top + coord.y;
867  m_boundary.bottom = m_boundary.bottom + coord.y;
868 }
869 
870 bool AnnotationPrivate::openDialogAfterCreation() const
871 {
872  return false;
873 }
874 
875 void AnnotationPrivate::setAnnotationProperties( const QDomNode& node )
876 {
877  // get the [base] element of the annotation node
878  QDomElement e = AnnotationUtils::findChildElement( node, "base" );
879  if ( e.isNull() )
880  return;
881 
882  // parse -contents- attributes
883  if ( e.hasAttribute( "author" ) )
884  m_author = e.attribute( "author" );
885  if ( e.hasAttribute( "contents" ) )
886  m_contents = e.attribute( "contents" );
887  if ( e.hasAttribute( "uniqueName" ) )
888  m_uniqueName = e.attribute( "uniqueName" );
889  if ( e.hasAttribute( "modifyDate" ) )
890  m_modifyDate = QDateTime::fromString( e.attribute("modifyDate"), Qt::ISODate );
891  if ( e.hasAttribute( "creationDate" ) )
892  m_creationDate = QDateTime::fromString( e.attribute("creationDate"), Qt::ISODate );
893 
894  // parse -other- attributes
895  if ( e.hasAttribute( "flags" ) )
896  m_flags = e.attribute( "flags" ).toInt();
897  if ( e.hasAttribute( "color" ) )
898  m_style.setColor( QColor( e.attribute( "color" ) ) );
899  if ( e.hasAttribute( "opacity" ) )
900  m_style.setOpacity( e.attribute( "opacity" ).toDouble() );
901 
902  // parse -the-subnodes- (describing Style, Window, Revision(s) structures)
903  // Note: all subnodes if present must be 'attributes complete'
904  QDomNode eSubNode = e.firstChild();
905  while ( eSubNode.isElement() )
906  {
907  QDomElement ee = eSubNode.toElement();
908  eSubNode = eSubNode.nextSibling();
909 
910  // parse boundary
911  if ( ee.tagName() == "boundary" )
912  {
913  m_boundary=NormalizedRect(ee.attribute( "l" ).toDouble(),
914  ee.attribute( "t" ).toDouble(),
915  ee.attribute( "r" ).toDouble(),
916  ee.attribute( "b" ).toDouble());
917  }
918  // parse penStyle if not default
919  else if ( ee.tagName() == "penStyle" )
920  {
921  m_style.setWidth( ee.attribute( "width" ).toDouble() );
922  m_style.setLineStyle( (Annotation::LineStyle)ee.attribute( "style" ).toInt() );
923  m_style.setXCorners( ee.attribute( "xcr" ).toDouble() );
924  m_style.setYCorners( ee.attribute( "ycr" ).toDouble() );
925  m_style.setMarks( ee.attribute( "marks" ).toInt() );
926  m_style.setSpaces( ee.attribute( "spaces" ).toInt() );
927  }
928  // parse effectStyle if not default
929  else if ( ee.tagName() == "penEffect" )
930  {
931  m_style.setLineEffect( (Annotation::LineEffect)ee.attribute( "effect" ).toInt() );
932  m_style.setEffectIntensity( ee.attribute( "intensity" ).toDouble() );
933  }
934  // parse window if present
935  else if ( ee.tagName() == "window" )
936  {
937  m_window.setFlags( ee.attribute( "flags" ).toInt() );
938  m_window.setTopLeft( NormalizedPoint( ee.attribute( "top" ).toDouble(),
939  ee.attribute( "left" ).toDouble() ) );
940  m_window.setWidth( ee.attribute( "width" ).toInt() );
941  m_window.setHeight( ee.attribute( "height" ).toInt() );
942  m_window.setTitle( ee.attribute( "title" ) );
943  m_window.setSummary( ee.attribute( "summary" ) );
944  }
945  }
946 
947  // get the [revisions] element of the annotation node
948  QDomNode revNode = node.firstChild();
949  for ( ; revNode.isElement(); revNode = revNode.nextSibling() )
950  {
951  QDomElement revElement = revNode.toElement();
952  if ( revElement.tagName() != "revision" )
953  continue;
954 
955  // compile the Revision structure crating annotation
956  Annotation::Revision revision;
957  revision.setScope( (Annotation::RevisionScope)revElement.attribute( "revScope" ).toInt() );
958  revision.setType( (Annotation::RevisionType)revElement.attribute( "revType" ).toInt() );
959  revision.setAnnotation( AnnotationUtils::createAnnotation( revElement ) );
960 
961  // if annotation is valid, add revision to internal list
962  if ( revision.annotation() )
963  m_revisions.append( revision );
964  }
965 
966  m_transformedBoundary = m_boundary;
967 }
968 
969 //END Annotation implementation
970 
971 
974 class Okular::TextAnnotationPrivate : public Okular::AnnotationPrivate
975 {
976  public:
977  TextAnnotationPrivate()
978  : AnnotationPrivate(), m_textType( TextAnnotation::Linked ),
979  m_textIcon( "Comment" ), m_inplaceAlign( 0 ),
980  m_inplaceIntent( TextAnnotation::Unknown )
981  {
982  }
983 
984  virtual void transform( const QTransform &matrix );
985  virtual void baseTransform( const QTransform &matrix );
986  virtual void resetTransformation();
987  virtual void translate( const NormalizedPoint &coord );
988  virtual bool openDialogAfterCreation() const;
989  virtual void setAnnotationProperties( const QDomNode& node );
990  virtual AnnotationPrivate* getNewAnnotationPrivate();
991 
992  TextAnnotation::TextType m_textType;
993  QString m_textIcon;
994  QFont m_textFont;
995  int m_inplaceAlign;
996  NormalizedPoint m_inplaceCallout[3];
997  NormalizedPoint m_transformedInplaceCallout[3];
998  TextAnnotation::InplaceIntent m_inplaceIntent;
999 };
1000 
1001 /*
1002  The default textIcon for text annotation is Note as the PDF Reference says
1003 */
1004 TextAnnotation::TextAnnotation()
1005  : Annotation( *new TextAnnotationPrivate() )
1006 {
1007 }
1008 
1009 TextAnnotation::TextAnnotation( const QDomNode & node )
1010  : Annotation( *new TextAnnotationPrivate(), node )
1011 {
1012 }
1013 
1014 TextAnnotation::~TextAnnotation()
1015 {
1016 }
1017 
1018 void TextAnnotation::setTextType( TextType textType )
1019 {
1020  Q_D( TextAnnotation );
1021  d->m_textType = textType;
1022 }
1023 
1024 TextAnnotation::TextType TextAnnotation::textType() const
1025 {
1026  Q_D( const TextAnnotation );
1027  return d->m_textType;
1028 }
1029 
1030 void TextAnnotation::setTextIcon( const QString &icon )
1031 {
1032  Q_D( TextAnnotation );
1033  d->m_textIcon = icon;
1034 }
1035 
1036 QString TextAnnotation::textIcon() const
1037 {
1038  Q_D( const TextAnnotation );
1039  return d->m_textIcon;
1040 }
1041 
1042 void TextAnnotation::setTextFont( const QFont &font )
1043 {
1044  Q_D( TextAnnotation );
1045  d->m_textFont = font;
1046 }
1047 
1048 QFont TextAnnotation::textFont() const
1049 {
1050  Q_D( const TextAnnotation );
1051  return d->m_textFont;
1052 }
1053 
1054 void TextAnnotation::setInplaceAlignment( int alignment )
1055 {
1056  Q_D( TextAnnotation );
1057  d->m_inplaceAlign = alignment;
1058 }
1059 
1060 int TextAnnotation::inplaceAlignment() const
1061 {
1062  Q_D( const TextAnnotation );
1063  return d->m_inplaceAlign;
1064 }
1065 
1066 void TextAnnotation::setInplaceCallout( const NormalizedPoint &point, int index )
1067 {
1068  if ( index < 0 || index > 2 )
1069  return;
1070 
1071  Q_D( TextAnnotation );
1072  d->m_inplaceCallout[ index ] = point;
1073 }
1074 
1075 NormalizedPoint TextAnnotation::inplaceCallout( int index ) const
1076 {
1077  if ( index < 0 || index > 2 )
1078  return NormalizedPoint();
1079 
1080  Q_D( const TextAnnotation );
1081  return d->m_inplaceCallout[ index ];
1082 }
1083 
1084 NormalizedPoint TextAnnotation::transformedInplaceCallout( int index ) const
1085 {
1086  if ( index < 0 || index > 2 )
1087  return NormalizedPoint();
1088 
1089  Q_D( const TextAnnotation );
1090  return d->m_transformedInplaceCallout[ index ];
1091 }
1092 
1093 void TextAnnotation::setInplaceIntent( InplaceIntent intent )
1094 {
1095  Q_D( TextAnnotation );
1096  d->m_inplaceIntent = intent;
1097 }
1098 
1099 TextAnnotation::InplaceIntent TextAnnotation::inplaceIntent() const
1100 {
1101  Q_D( const TextAnnotation );
1102  return d->m_inplaceIntent;
1103 }
1104 
1105 Annotation::SubType TextAnnotation::subType() const
1106 {
1107  return AText;
1108 }
1109 
1110 void TextAnnotation::store( QDomNode & node, QDomDocument & document ) const
1111 {
1112  Q_D( const TextAnnotation );
1113  // recurse to parent objects storing properties
1114  Annotation::store( node, document );
1115 
1116  // create [text] element
1117  QDomElement textElement = document.createElement( "text" );
1118  node.appendChild( textElement );
1119 
1120  // store the optional attributes
1121  if ( d->m_textType != Linked )
1122  textElement.setAttribute( "type", (int)d->m_textType );
1123  if ( !d->m_textIcon.isEmpty() )
1124  textElement.setAttribute( "icon", d->m_textIcon );
1125  if ( d->m_textFont != QApplication::font() )
1126  textElement.setAttribute( "font", d->m_textFont.toString() );
1127  if ( d->m_inplaceAlign )
1128  textElement.setAttribute( "align", d->m_inplaceAlign );
1129  if ( d->m_inplaceIntent != Unknown )
1130  textElement.setAttribute( "intent", (int)d->m_inplaceIntent );
1131 
1132  // Sub-Node - callout
1133  if ( d->m_inplaceCallout[0].x != 0.0 )
1134  {
1135  QDomElement calloutElement = document.createElement( "callout" );
1136  textElement.appendChild( calloutElement );
1137  calloutElement.setAttribute( "ax", QString::number( d->m_inplaceCallout[0].x ) );
1138  calloutElement.setAttribute( "ay", QString::number( d->m_inplaceCallout[0].y ) );
1139  calloutElement.setAttribute( "bx", QString::number( d->m_inplaceCallout[1].x ) );
1140  calloutElement.setAttribute( "by", QString::number( d->m_inplaceCallout[1].y ) );
1141  calloutElement.setAttribute( "cx", QString::number( d->m_inplaceCallout[2].x ) );
1142  calloutElement.setAttribute( "cy", QString::number( d->m_inplaceCallout[2].y ) );
1143  }
1144 }
1145 
1146 void TextAnnotationPrivate::transform( const QTransform &matrix )
1147 {
1148  AnnotationPrivate::transform( matrix );
1149 
1150  for ( int i = 0; i < 3; ++i ) {
1151  m_transformedInplaceCallout[i].transform( matrix );
1152  }
1153 }
1154 
1155 void TextAnnotationPrivate::baseTransform( const QTransform &matrix )
1156 {
1157  AnnotationPrivate::baseTransform( matrix );
1158 
1159  for ( int i = 0; i < 3; ++i ) {
1160  m_inplaceCallout[i].transform( matrix );
1161  }
1162 }
1163 
1164 void TextAnnotationPrivate::resetTransformation()
1165 {
1166  AnnotationPrivate::resetTransformation();
1167 
1168  for ( int i = 0; i < 3; ++i ) {
1169  m_transformedInplaceCallout[i] = m_inplaceCallout[i];
1170  }
1171 }
1172 
1173 void TextAnnotationPrivate::translate( const NormalizedPoint &coord )
1174 {
1175  AnnotationPrivate::translate( coord );
1176 
1177 #define ADD_COORD( c1, c2 ) \
1178 { \
1179  c1.x = c1.x + c2.x; \
1180  c1.y = c1.y + c2.y; \
1181 }
1182  ADD_COORD( m_inplaceCallout[0], coord )
1183  ADD_COORD( m_inplaceCallout[1], coord )
1184  ADD_COORD( m_inplaceCallout[2], coord )
1185 #undef ADD_COORD
1186 }
1187 
1188 bool TextAnnotationPrivate::openDialogAfterCreation() const
1189 {
1190  return ( m_textType == Okular::TextAnnotation::Linked );
1191 }
1192 
1193 void TextAnnotationPrivate::setAnnotationProperties( const QDomNode& node )
1194 {
1195  Okular::AnnotationPrivate::setAnnotationProperties(node);
1196 
1197  // loop through the whole children looking for a 'text' element
1198  QDomNode subNode = node.firstChild();
1199  while( subNode.isElement() )
1200  {
1201  QDomElement e = subNode.toElement();
1202  subNode = subNode.nextSibling();
1203  if ( e.tagName() != "text" )
1204  continue;
1205 
1206  // parse the attributes
1207  if ( e.hasAttribute( "type" ) )
1208  m_textType = (TextAnnotation::TextType)e.attribute( "type" ).toInt();
1209  if ( e.hasAttribute( "icon" ) )
1210  m_textIcon = e.attribute( "icon" );
1211  if ( e.hasAttribute( "font" ) )
1212  m_textFont.fromString( e.attribute( "font" ) );
1213  if ( e.hasAttribute( "align" ) )
1214  m_inplaceAlign = e.attribute( "align" ).toInt();
1215  if ( e.hasAttribute( "intent" ) )
1216  m_inplaceIntent = (TextAnnotation::InplaceIntent)e.attribute( "intent" ).toInt();
1217 
1218  // parse the subnodes
1219  QDomNode eSubNode = e.firstChild();
1220  while ( eSubNode.isElement() )
1221  {
1222  QDomElement ee = eSubNode.toElement();
1223  eSubNode = eSubNode.nextSibling();
1224 
1225  if ( ee.tagName() == "escapedText" )
1226  {
1227  m_contents = ee.firstChild().toCDATASection().data();
1228  }
1229  else if ( ee.tagName() == "callout" )
1230  {
1231  m_inplaceCallout[0].x = ee.attribute( "ax" ).toDouble();
1232  m_inplaceCallout[0].y = ee.attribute( "ay" ).toDouble();
1233  m_inplaceCallout[1].x = ee.attribute( "bx" ).toDouble();
1234  m_inplaceCallout[1].y = ee.attribute( "by" ).toDouble();
1235  m_inplaceCallout[2].x = ee.attribute( "cx" ).toDouble();
1236  m_inplaceCallout[2].y = ee.attribute( "cy" ).toDouble();
1237  }
1238  }
1239 
1240  // loading complete
1241  break;
1242  }
1243 
1244  for ( int i = 0; i < 3; ++i )
1245  m_transformedInplaceCallout[i] = m_inplaceCallout[i];
1246 }
1247 
1248 AnnotationPrivate* TextAnnotationPrivate::getNewAnnotationPrivate()
1249 {
1250  return new TextAnnotationPrivate();
1251 }
1252 
1255 class Okular::LineAnnotationPrivate : public Okular::AnnotationPrivate
1256 {
1257  public:
1258  LineAnnotationPrivate()
1259  : AnnotationPrivate(),
1260  m_lineStartStyle( LineAnnotation::None ), m_lineEndStyle( LineAnnotation::None ),
1261  m_lineClosed( false ), m_lineShowCaption( false ), m_lineLeadingFwdPt( 0 ),
1262  m_lineLeadingBackPt( 0 ), m_lineIntent( LineAnnotation::Unknown )
1263  {
1264  }
1265 
1266  virtual void transform( const QTransform &matrix );
1267  virtual void baseTransform( const QTransform &matrix );
1268  virtual void resetTransformation();
1269  virtual void translate( const NormalizedPoint &coord );
1270  virtual double distanceSqr( double x, double y, double xScale, double yScale );
1271  virtual void setAnnotationProperties( const QDomNode& node );
1272  virtual AnnotationPrivate* getNewAnnotationPrivate();
1273 
1274  QLinkedList<NormalizedPoint> m_linePoints;
1275  QLinkedList<NormalizedPoint> m_transformedLinePoints;
1276  LineAnnotation::TermStyle m_lineStartStyle;
1277  LineAnnotation::TermStyle m_lineEndStyle;
1278  bool m_lineClosed : 1;
1279  bool m_lineShowCaption : 1;
1280  QColor m_lineInnerColor;
1281  double m_lineLeadingFwdPt;
1282  double m_lineLeadingBackPt;
1283  LineAnnotation::LineIntent m_lineIntent;
1284 };
1285 
1286 LineAnnotation::LineAnnotation()
1287  : Annotation( *new LineAnnotationPrivate() )
1288 {
1289 }
1290 
1291 LineAnnotation::LineAnnotation( const QDomNode & node )
1292  : Annotation( *new LineAnnotationPrivate(), node )
1293 {
1294 }
1295 
1296 LineAnnotation::~LineAnnotation()
1297 {
1298 }
1299 
1300 void LineAnnotation::setLinePoints( const QLinkedList<NormalizedPoint> &points )
1301 {
1302  Q_D( LineAnnotation );
1303  d->m_linePoints = points;
1304 }
1305 
1306 QLinkedList<NormalizedPoint> LineAnnotation::linePoints() const
1307 {
1308  Q_D( const LineAnnotation );
1309  return d->m_linePoints;
1310 }
1311 
1312 QLinkedList<NormalizedPoint> LineAnnotation::transformedLinePoints() const
1313 {
1314  Q_D( const LineAnnotation );
1315  return d->m_transformedLinePoints;
1316 }
1317 
1318 void LineAnnotation::setLineStartStyle( TermStyle style )
1319 {
1320  Q_D( LineAnnotation );
1321  d->m_lineStartStyle = style;
1322 }
1323 
1324 LineAnnotation::TermStyle LineAnnotation::lineStartStyle() const
1325 {
1326  Q_D( const LineAnnotation );
1327  return d->m_lineStartStyle;
1328 }
1329 
1330 void LineAnnotation::setLineEndStyle( TermStyle style )
1331 {
1332  Q_D( LineAnnotation );
1333  d->m_lineEndStyle = style;
1334 }
1335 
1336 LineAnnotation::TermStyle LineAnnotation::lineEndStyle() const
1337 {
1338  Q_D( const LineAnnotation );
1339  return d->m_lineEndStyle;
1340 }
1341 
1342 void LineAnnotation::setLineClosed( bool closed )
1343 {
1344  Q_D( LineAnnotation );
1345  d->m_lineClosed = closed;
1346 }
1347 
1348 bool LineAnnotation::lineClosed() const
1349 {
1350  Q_D( const LineAnnotation );
1351  return d->m_lineClosed;
1352 }
1353 
1354 void LineAnnotation::setLineInnerColor( const QColor &color )
1355 {
1356  Q_D( LineAnnotation );
1357  d->m_lineInnerColor = color;
1358 }
1359 
1360 QColor LineAnnotation::lineInnerColor() const
1361 {
1362  Q_D( const LineAnnotation );
1363  return d->m_lineInnerColor;
1364 }
1365 
1366 void LineAnnotation::setLineLeadingForwardPoint( double point )
1367 {
1368  Q_D( LineAnnotation );
1369  d->m_lineLeadingFwdPt = point;
1370 }
1371 
1372 double LineAnnotation::lineLeadingForwardPoint() const
1373 {
1374  Q_D( const LineAnnotation );
1375  return d->m_lineLeadingFwdPt;
1376 }
1377 
1378 void LineAnnotation::setLineLeadingBackwardPoint( double point )
1379 {
1380  Q_D( LineAnnotation );
1381  d->m_lineLeadingBackPt = point;
1382 }
1383 
1384 double LineAnnotation::lineLeadingBackwardPoint() const
1385 {
1386  Q_D( const LineAnnotation );
1387  return d->m_lineLeadingBackPt;
1388 }
1389 
1390 void LineAnnotation::setShowCaption( bool show )
1391 {
1392  Q_D( LineAnnotation );
1393  d->m_lineShowCaption = show;
1394 }
1395 
1396 bool LineAnnotation::showCaption() const
1397 {
1398  Q_D( const LineAnnotation );
1399  return d->m_lineShowCaption;
1400 }
1401 
1402 void LineAnnotation::setLineIntent( LineIntent intent )
1403 {
1404  Q_D( LineAnnotation );
1405  d->m_lineIntent = intent;
1406 }
1407 
1408 LineAnnotation::LineIntent LineAnnotation::lineIntent() const
1409 {
1410  Q_D( const LineAnnotation );
1411  return d->m_lineIntent;
1412 }
1413 
1414 Annotation::SubType LineAnnotation::subType() const
1415 {
1416  return ALine;
1417 }
1418 
1419 void LineAnnotation::store( QDomNode & node, QDomDocument & document ) const
1420 {
1421  Q_D( const LineAnnotation );
1422  // recurse to parent objects storing properties
1423  Annotation::store( node, document );
1424 
1425  // create [line] element
1426  QDomElement lineElement = document.createElement( "line" );
1427  node.appendChild( lineElement );
1428 
1429  // store the attributes
1430  if ( d->m_lineStartStyle != None )
1431  lineElement.setAttribute( "startStyle", (int)d->m_lineStartStyle );
1432  if ( d->m_lineEndStyle != None )
1433  lineElement.setAttribute( "endStyle", (int)d->m_lineEndStyle );
1434  if ( d->m_lineClosed )
1435  lineElement.setAttribute( "closed", d->m_lineClosed );
1436  if ( d->m_lineInnerColor.isValid() )
1437  lineElement.setAttribute( "innerColor", d->m_lineInnerColor.name() );
1438  if ( d->m_lineLeadingFwdPt != 0.0 )
1439  lineElement.setAttribute( "leadFwd", QString::number( d->m_lineLeadingFwdPt ) );
1440  if ( d->m_lineLeadingBackPt != 0.0 )
1441  lineElement.setAttribute( "leadBack", QString::number( d->m_lineLeadingBackPt ) );
1442  if ( d->m_lineShowCaption )
1443  lineElement.setAttribute( "showCaption", d->m_lineShowCaption );
1444  if ( d->m_lineIntent != Unknown )
1445  lineElement.setAttribute( "intent", d->m_lineIntent );
1446 
1447  // append the list of points
1448  int points = d->m_linePoints.count();
1449  if ( points > 1 )
1450  {
1451  QLinkedList<NormalizedPoint>::const_iterator it = d->m_linePoints.begin(), end = d->m_linePoints.end();
1452  while ( it != end )
1453  {
1454  const NormalizedPoint & p = *it;
1455  QDomElement pElement = document.createElement( "point" );
1456  lineElement.appendChild( pElement );
1457  pElement.setAttribute( "x", QString::number( p.x ) );
1458  pElement.setAttribute( "y", QString::number( p.y ) );
1459  it++; //to avoid loop
1460  }
1461  }
1462 }
1463 
1464 void LineAnnotationPrivate::transform( const QTransform &matrix )
1465 {
1466  AnnotationPrivate::transform( matrix );
1467 
1468  QMutableLinkedListIterator<NormalizedPoint> it( m_transformedLinePoints );
1469  while ( it.hasNext() )
1470  it.next().transform( matrix );
1471 }
1472 
1473 void LineAnnotationPrivate::baseTransform( const QTransform &matrix )
1474 {
1475  AnnotationPrivate::baseTransform( matrix );
1476 
1477  QMutableLinkedListIterator<NormalizedPoint> it( m_linePoints );
1478  while ( it.hasNext() )
1479  it.next().transform( matrix );
1480 }
1481 
1482 void LineAnnotationPrivate::resetTransformation()
1483 {
1484  AnnotationPrivate::resetTransformation();
1485 
1486  m_transformedLinePoints = m_linePoints;
1487 }
1488 
1489 void LineAnnotationPrivate::translate( const NormalizedPoint &coord )
1490 {
1491  AnnotationPrivate::translate( coord );
1492 
1493  QMutableLinkedListIterator<NormalizedPoint> it( m_linePoints );
1494  while ( it.hasNext() )
1495  {
1496  NormalizedPoint& p = it.next();
1497  p.x = p.x + coord.x;
1498  p.y = p.y + coord.y;
1499  }
1500 }
1501 
1502 void LineAnnotationPrivate::setAnnotationProperties( const QDomNode& node )
1503 {
1504  Okular::AnnotationPrivate::setAnnotationProperties(node);
1505 
1506  // loop through the whole children looking for a 'line' element
1507  QDomNode subNode = node.firstChild();
1508  while( subNode.isElement() )
1509  {
1510  QDomElement e = subNode.toElement();
1511  subNode = subNode.nextSibling();
1512  if ( e.tagName() != "line" )
1513  continue;
1514 
1515  // parse the attributes
1516  if ( e.hasAttribute( "startStyle" ) )
1517  m_lineStartStyle = (LineAnnotation::TermStyle)e.attribute( "startStyle" ).toInt();
1518  if ( e.hasAttribute( "endStyle" ) )
1519  m_lineEndStyle = (LineAnnotation::TermStyle)e.attribute( "endStyle" ).toInt();
1520  if ( e.hasAttribute( "closed" ) )
1521  m_lineClosed = e.attribute( "closed" ).toInt();
1522  if ( e.hasAttribute( "innerColor" ) )
1523  m_lineInnerColor = QColor( e.attribute( "innerColor" ) );
1524  if ( e.hasAttribute( "leadFwd" ) )
1525  m_lineLeadingFwdPt = e.attribute( "leadFwd" ).toDouble();
1526  if ( e.hasAttribute( "leadBack" ) )
1527  m_lineLeadingBackPt = e.attribute( "leadBack" ).toDouble();
1528  if ( e.hasAttribute( "showCaption" ) )
1529  m_lineShowCaption = e.attribute( "showCaption" ).toInt();
1530  if ( e.hasAttribute( "intent" ) )
1531  m_lineIntent = (LineAnnotation::LineIntent)e.attribute( "intent" ).toInt();
1532 
1533  // parse all 'point' subnodes
1534  QDomNode pointNode = e.firstChild();
1535  while ( pointNode.isElement() )
1536  {
1537  QDomElement pe = pointNode.toElement();
1538  pointNode = pointNode.nextSibling();
1539 
1540  if ( pe.tagName() != "point" )
1541  continue;
1542 
1543  NormalizedPoint p;
1544  p.x = pe.attribute( "x", "0.0" ).toDouble();
1545  p.y = pe.attribute( "y", "0.0" ).toDouble();
1546  m_linePoints.append( p );
1547  }
1548 
1549  // loading complete
1550  break;
1551  }
1552 
1553  m_transformedLinePoints = m_linePoints;
1554 }
1555 
1556 AnnotationPrivate* LineAnnotationPrivate::getNewAnnotationPrivate()
1557 {
1558  return new LineAnnotationPrivate();
1559 }
1560 
1561 double LineAnnotationPrivate::distanceSqr( double x, double y, double xScale, double yScale )
1562 {
1563  QLinkedList<NormalizedPoint> transformedLinePoints = m_transformedLinePoints;
1564 
1565  if ( m_lineClosed ) // Close the path
1566  transformedLinePoints.append( transformedLinePoints.first() );
1567 
1568  if ( m_lineInnerColor.isValid() )
1569  {
1570  QPolygonF polygon;
1571  foreach ( const NormalizedPoint &p, transformedLinePoints )
1572  polygon.append( QPointF( p.x, p.y ) );
1573 
1574  if ( polygon.containsPoint( QPointF( x, y ), Qt::WindingFill ) )
1575  return 0;
1576  }
1577 
1578  return strokeDistance( ::distanceSqr( x, y, xScale, yScale, transformedLinePoints ),
1579  m_style.width() * xScale / ( m_page->m_width * 2 ) );
1580 }
1581 
1584 class Okular::GeomAnnotationPrivate : public Okular::AnnotationPrivate
1585 {
1586  public:
1587  GeomAnnotationPrivate()
1588  : AnnotationPrivate(), m_geomType( GeomAnnotation::InscribedSquare )
1589  {
1590  }
1591  virtual void setAnnotationProperties( const QDomNode& node );
1592  virtual AnnotationPrivate* getNewAnnotationPrivate();
1593  virtual double distanceSqr( double x, double y, double xScale, double yScale );
1594 
1595  GeomAnnotation::GeomType m_geomType;
1596  QColor m_geomInnerColor;
1597 };
1598 
1599 GeomAnnotation::GeomAnnotation()
1600  : Annotation( *new GeomAnnotationPrivate() )
1601 {
1602 }
1603 
1604 GeomAnnotation::GeomAnnotation( const QDomNode & node )
1605  : Annotation( *new GeomAnnotationPrivate(), node )
1606 {
1607 }
1608 
1609 GeomAnnotation::~GeomAnnotation()
1610 {
1611 }
1612 
1613 void GeomAnnotation::setGeometricalType( GeomType type )
1614 {
1615  Q_D( GeomAnnotation );
1616  d->m_geomType = type;
1617 }
1618 
1619 GeomAnnotation::GeomType GeomAnnotation::geometricalType() const
1620 {
1621  Q_D( const GeomAnnotation );
1622  return d->m_geomType;
1623 }
1624 
1625 void GeomAnnotation::setGeometricalInnerColor( const QColor &color )
1626 {
1627  Q_D( GeomAnnotation );
1628  d->m_geomInnerColor = color;
1629 }
1630 
1631 QColor GeomAnnotation::geometricalInnerColor() const
1632 {
1633  Q_D( const GeomAnnotation );
1634  return d->m_geomInnerColor;
1635 }
1636 
1637 Annotation::SubType GeomAnnotation::subType() const
1638 {
1639  return AGeom;
1640 }
1641 
1642 void GeomAnnotation::store( QDomNode & node, QDomDocument & document ) const
1643 {
1644  Q_D( const GeomAnnotation );
1645  // recurse to parent objects storing properties
1646  Annotation::store( node, document );
1647 
1648  // create [geom] element
1649  QDomElement geomElement = document.createElement( "geom" );
1650  node.appendChild( geomElement );
1651 
1652  // append the optional attributes
1653  if ( d->m_geomType != InscribedSquare )
1654  geomElement.setAttribute( "type", (int)d->m_geomType );
1655  if ( d->m_geomInnerColor.isValid() )
1656  geomElement.setAttribute( "color", d->m_geomInnerColor.name() );
1657 }
1658 
1659 void GeomAnnotationPrivate::setAnnotationProperties( const QDomNode& node )
1660 {
1661  Okular::AnnotationPrivate::setAnnotationProperties(node);
1662  // loop through the whole children looking for a 'geom' element
1663  QDomNode subNode = node.firstChild();
1664  while( subNode.isElement() )
1665  {
1666  QDomElement e = subNode.toElement();
1667  subNode = subNode.nextSibling();
1668  if ( e.tagName() != "geom" )
1669  continue;
1670 
1671  // parse the attributes
1672  if ( e.hasAttribute( "type" ) )
1673  m_geomType = (GeomAnnotation::GeomType)e.attribute( "type" ).toInt();
1674  if ( e.hasAttribute( "color" ) )
1675  m_geomInnerColor = QColor( e.attribute( "color" ) );
1676  // compatibility
1677  if ( e.hasAttribute( "width" ) )
1678  m_style.setWidth( e.attribute( "width" ).toInt() );
1679 
1680  // loading complete
1681  break;
1682  }
1683 }
1684 
1685 AnnotationPrivate* GeomAnnotationPrivate::getNewAnnotationPrivate()
1686 {
1687  return new GeomAnnotationPrivate();
1688 }
1689 
1690 double GeomAnnotationPrivate::distanceSqr( double x, double y, double xScale, double yScale )
1691 {
1692  double distance = 0;
1693  //the line thickness is applied unevenly (only on the "inside") - account for this
1694  bool withinShape = false;
1695  switch (m_geomType) {
1696  case GeomAnnotation::InscribedCircle:
1697  {
1698  //calculate the center point and focus lengths of the ellipse
1699  const double centerX = ( m_transformedBoundary.left + m_transformedBoundary.right ) / 2.0;
1700  const double centerY = ( m_transformedBoundary.top + m_transformedBoundary.bottom ) / 2.0;
1701  const double focusX = ( m_transformedBoundary.right - centerX);
1702  const double focusY = ( m_transformedBoundary.bottom - centerY);
1703 
1704  const double focusXSqr = pow( focusX, 2 );
1705  const double focusYSqr = pow( focusY, 2 );
1706 
1707  // to calculate the distance from the ellipse, we will first find the point "projection"
1708  // that lies on the ellipse and is closest to the point (x,y)
1709  // This point can obviously be written as "center + lambda(inputPoint - center)".
1710  // Because the point lies on the ellipse, we know that:
1711  // 1 = ((center.x - projection.x)/focusX)^2 + ((center.y - projection.y)/focusY)^2
1712  // After filling in projection.x = center.x + lambda * (inputPoint.x - center.x)
1713  // and its y-equivalent, we can solve for lambda:
1714  const double lambda = sqrt( focusXSqr * focusYSqr /
1715  ( focusYSqr * pow( x - centerX, 2 ) + focusXSqr * pow( y - centerY, 2 ) ) );
1716 
1717  // if the ellipse is filled, we treat all points within as "on" it
1718  if ( lambda > 1 )
1719  {
1720  if ( m_geomInnerColor.isValid() )
1721  return 0;
1722  else
1723  withinShape = true;
1724  }
1725 
1726  //otherwise we calculate the squared distance from the projected point on the ellipse
1727  NormalizedPoint projection( centerX, centerY );
1728  projection.x += lambda * ( x - centerX );
1729  projection.y += lambda * ( y - centerY );
1730 
1731  distance = projection.distanceSqr( x, y, xScale, yScale );
1732  break;
1733  }
1734 
1735  case GeomAnnotation::InscribedSquare:
1736  //if the square is filled, only check the bounding box
1737  if ( m_geomInnerColor.isValid() )
1738  return AnnotationPrivate::distanceSqr( x, y, xScale, yScale );
1739 
1740  QLinkedList<NormalizedPoint> edges;
1741  edges << NormalizedPoint( m_transformedBoundary.left, m_transformedBoundary.top );
1742  edges << NormalizedPoint( m_transformedBoundary.right, m_transformedBoundary.top );
1743  edges << NormalizedPoint( m_transformedBoundary.right, m_transformedBoundary.bottom );
1744  edges << NormalizedPoint( m_transformedBoundary.left, m_transformedBoundary.bottom );
1745  edges << NormalizedPoint( m_transformedBoundary.left, m_transformedBoundary.top );
1746  distance = ::distanceSqr( x, y, xScale, yScale, edges );
1747 
1748  if ( m_transformedBoundary.contains( x, y ) )
1749  withinShape = true;
1750 
1751  break;
1752  }
1753  if ( withinShape )
1754  distance = strokeDistance( distance, m_style.width() * xScale / m_page->m_width );
1755 
1756  return distance;
1757 }
1758 
1761 class HighlightAnnotation::Quad::Private
1762 {
1763  public:
1764  Private()
1765  {
1766  }
1767 
1768  NormalizedPoint m_points[4];
1769  NormalizedPoint m_transformedPoints[4];
1770  bool m_capStart : 1;
1771  bool m_capEnd : 1;
1772  double m_feather;
1773 };
1774 
1775 HighlightAnnotation::Quad::Quad()
1776  : d( new Private )
1777 {
1778 }
1779 
1780 HighlightAnnotation::Quad::~Quad()
1781 {
1782  delete d;
1783 }
1784 
1785 HighlightAnnotation::Quad::Quad( const Quad &other )
1786  : d( new Private )
1787 {
1788  *d = *other.d;
1789 }
1790 
1791 HighlightAnnotation::Quad& HighlightAnnotation::Quad::operator=( const Quad &other )
1792 {
1793  if ( this != &other )
1794  *d = *other.d;
1795 
1796  return *this;
1797 }
1798 
1799 void HighlightAnnotation::Quad::setPoint( const NormalizedPoint &point, int index )
1800 {
1801  if ( index < 0 || index > 3 )
1802  return;
1803 
1804  d->m_points[ index ] = point;
1805 }
1806 
1807 NormalizedPoint HighlightAnnotation::Quad::point( int index ) const
1808 {
1809  if ( index < 0 || index > 3 )
1810  return NormalizedPoint();
1811 
1812  return d->m_points[ index ];
1813 }
1814 
1815 NormalizedPoint HighlightAnnotation::Quad::transformedPoint( int index ) const
1816 {
1817  if ( index < 0 || index > 3 )
1818  return NormalizedPoint();
1819 
1820  return d->m_transformedPoints[ index ];
1821 }
1822 
1823 void HighlightAnnotation::Quad::setCapStart( bool value )
1824 {
1825  d->m_capStart = value;
1826 }
1827 
1828 bool HighlightAnnotation::Quad::capStart() const
1829 {
1830  return d->m_capStart;
1831 }
1832 
1833 void HighlightAnnotation::Quad::setCapEnd( bool value )
1834 {
1835  d->m_capEnd = value;
1836 }
1837 
1838 bool HighlightAnnotation::Quad::capEnd() const
1839 {
1840  return d->m_capEnd;
1841 }
1842 
1843 void HighlightAnnotation::Quad::setFeather( double width )
1844 {
1845  d->m_feather = width;
1846 }
1847 
1848 double HighlightAnnotation::Quad::feather() const
1849 {
1850  return d->m_feather;
1851 }
1852 
1853 void HighlightAnnotation::Quad::transform( const QTransform &matrix )
1854 {
1855  for ( int i = 0; i < 4; ++i ) {
1856  d->m_transformedPoints[ i ] = d->m_points[ i ];
1857  d->m_transformedPoints[ i ].transform( matrix );
1858  }
1859 }
1860 
1861 
1862 class Okular::HighlightAnnotationPrivate : public Okular::AnnotationPrivate
1863 {
1864  public:
1865  HighlightAnnotationPrivate()
1866  : AnnotationPrivate(), m_highlightType( HighlightAnnotation::Highlight )
1867  {
1868  }
1869 
1870  virtual void transform( const QTransform &matrix );
1871  virtual void baseTransform( const QTransform &matrix );
1872  virtual double distanceSqr( double x, double y, double xScale, double yScale );
1873  virtual void setAnnotationProperties( const QDomNode& node );
1874  virtual AnnotationPrivate* getNewAnnotationPrivate();
1875 
1876  HighlightAnnotation::HighlightType m_highlightType;
1877  QList< HighlightAnnotation::Quad > m_highlightQuads;
1878 };
1879 
1880 HighlightAnnotation::HighlightAnnotation()
1881  : Annotation( *new HighlightAnnotationPrivate() )
1882 {
1883 }
1884 
1885 HighlightAnnotation::HighlightAnnotation( const QDomNode & node )
1886  : Annotation( *new HighlightAnnotationPrivate(), node )
1887 {
1888 }
1889 
1890 HighlightAnnotation::~HighlightAnnotation()
1891 {
1892 }
1893 
1894 void HighlightAnnotation::setHighlightType( HighlightType type )
1895 {
1896  Q_D( HighlightAnnotation );
1897  d->m_highlightType = type;
1898 }
1899 
1900 HighlightAnnotation::HighlightType HighlightAnnotation::highlightType() const
1901 {
1902  Q_D( const HighlightAnnotation );
1903  return d->m_highlightType;
1904 }
1905 
1906 QList< HighlightAnnotation::Quad > & HighlightAnnotation::highlightQuads()
1907 {
1908  Q_D( HighlightAnnotation );
1909  return d->m_highlightQuads;
1910 }
1911 
1912 void HighlightAnnotation::store( QDomNode & node, QDomDocument & document ) const
1913 {
1914  Q_D( const HighlightAnnotation );
1915  // recurse to parent objects storing properties
1916  Annotation::store( node, document );
1917 
1918  // create [hl] element
1919  QDomElement hlElement = document.createElement( "hl" );
1920  node.appendChild( hlElement );
1921 
1922  // append the optional attributes
1923  if ( d->m_highlightType != Highlight )
1924  hlElement.setAttribute( "type", (int)d->m_highlightType );
1925  if ( d->m_highlightQuads.count() < 1 )
1926  return;
1927  // append highlight quads, all children describe quads
1928  QList< Quad >::const_iterator it = d->m_highlightQuads.begin(), end = d->m_highlightQuads.end();
1929  for ( ; it != end; ++it )
1930  {
1931  QDomElement quadElement = document.createElement( "quad" );
1932  hlElement.appendChild( quadElement );
1933  const Quad & q = *it;
1934  quadElement.setAttribute( "ax", QString::number( q.point( 0 ).x ) );
1935  quadElement.setAttribute( "ay", QString::number( q.point( 0 ).y ) );
1936  quadElement.setAttribute( "bx", QString::number( q.point( 1 ).x ) );
1937  quadElement.setAttribute( "by", QString::number( q.point( 1 ).y ) );
1938  quadElement.setAttribute( "cx", QString::number( q.point( 2 ).x ) );
1939  quadElement.setAttribute( "cy", QString::number( q.point( 2 ).y ) );
1940  quadElement.setAttribute( "dx", QString::number( q.point( 3 ).x ) );
1941  quadElement.setAttribute( "dy", QString::number( q.point( 3 ).y ) );
1942  if ( q.capStart() )
1943  quadElement.setAttribute( "start", 1 );
1944  if ( q.capEnd() )
1945  quadElement.setAttribute( "end", 1 );
1946  quadElement.setAttribute( "feather", QString::number( q.feather() ) );
1947  }
1948 }
1949 
1950 Annotation::SubType HighlightAnnotation::subType() const
1951 {
1952  return AHighlight;
1953 }
1954 
1955 void HighlightAnnotationPrivate::transform( const QTransform &matrix )
1956 {
1957  AnnotationPrivate::transform( matrix );
1958 
1959  QMutableListIterator<HighlightAnnotation::Quad> it( m_highlightQuads );
1960  while ( it.hasNext() )
1961  it.next().transform( matrix );
1962 }
1963 
1964 void HighlightAnnotationPrivate::baseTransform( const QTransform &matrix )
1965 {
1966  AnnotationPrivate::baseTransform( matrix );
1967 
1968  QMutableListIterator<HighlightAnnotation::Quad> it( m_highlightQuads );
1969  while ( it.hasNext() )
1970  it.next().transform( matrix );
1971 }
1972 
1973 void HighlightAnnotationPrivate::setAnnotationProperties( const QDomNode& node )
1974 {
1975  Okular::AnnotationPrivate::setAnnotationProperties(node);
1976  m_highlightQuads.clear();
1977 
1978  // loop through the whole children looking for a 'hl' element
1979  QDomNode subNode = node.firstChild();
1980  while( subNode.isElement() )
1981  {
1982  QDomElement e = subNode.toElement();
1983  subNode = subNode.nextSibling();
1984  if ( e.tagName() != "hl" )
1985  continue;
1986 
1987  // parse the attributes
1988  if ( e.hasAttribute( "type" ) )
1989  m_highlightType = (HighlightAnnotation::HighlightType)e.attribute( "type" ).toInt();
1990 
1991  // parse all 'quad' subnodes
1992  QDomNode quadNode = e.firstChild();
1993  for ( ; quadNode.isElement(); quadNode = quadNode.nextSibling() )
1994  {
1995  QDomElement qe = quadNode.toElement();
1996  if ( qe.tagName() != "quad" )
1997  continue;
1998 
1999  HighlightAnnotation::Quad q;
2000  q.setPoint( NormalizedPoint( qe.attribute( "ax", "0.0" ).toDouble(), qe.attribute( "ay", "0.0" ).toDouble() ), 0 );
2001  q.setPoint( NormalizedPoint( qe.attribute( "bx", "0.0" ).toDouble(), qe.attribute( "by", "0.0" ).toDouble() ), 1 );
2002  q.setPoint( NormalizedPoint( qe.attribute( "cx", "0.0" ).toDouble(), qe.attribute( "cy", "0.0" ).toDouble() ), 2 );
2003  q.setPoint( NormalizedPoint( qe.attribute( "dx", "0.0" ).toDouble(), qe.attribute( "dy", "0.0" ).toDouble() ), 3 );
2004  q.setCapStart( qe.hasAttribute( "start" ) );
2005  q.setCapEnd( qe.hasAttribute( "end" ) );
2006  q.setFeather( qe.attribute( "feather", "0.1" ).toDouble() );
2007 
2008  q.transform( QTransform() );
2009 
2010  m_highlightQuads.append( q );
2011  }
2012 
2013  // loading complete
2014  break;
2015  }
2016 }
2017 
2018 AnnotationPrivate* HighlightAnnotationPrivate::getNewAnnotationPrivate()
2019 {
2020  return new HighlightAnnotationPrivate();
2021 }
2022 
2023 double HighlightAnnotationPrivate::distanceSqr( double x, double y, double xScale, double yScale )
2024 {
2025  NormalizedPoint point( x, y );
2026  double outsideDistance = DBL_MAX;
2027  foreach ( const HighlightAnnotation::Quad& quad, m_highlightQuads )
2028  {
2029  QLinkedList<NormalizedPoint> pathPoints;
2030 
2031  //first, we check if the point is within the area described by the 4 quads
2032  //this is the case, if the point is always on one side of each segments delimiting the polygon:
2033  pathPoints << quad.transformedPoint( 0 );
2034  int directionVote = 0;
2035  for ( int i = 1; i < 5; ++i )
2036  {
2037  NormalizedPoint thisPoint = quad.transformedPoint( i % 4 );
2038  directionVote += (isLeftOfVector( pathPoints.back(), thisPoint, point )) ? 1 : -1;
2039  pathPoints << thisPoint;
2040  }
2041  if ( abs( directionVote ) == 4 )
2042  return 0;
2043 
2044  //if that's not the case, we treat the outline as path and simply determine
2045  //the distance from the path to the point
2046  const double thisOutsideDistance = ::distanceSqr( x, y, xScale, yScale, pathPoints );
2047  if ( thisOutsideDistance < outsideDistance )
2048  outsideDistance = thisOutsideDistance;
2049  }
2050 
2051  return outsideDistance;
2052 }
2053 
2056 class Okular::StampAnnotationPrivate : public Okular::AnnotationPrivate
2057 {
2058  public:
2059  StampAnnotationPrivate()
2060  : AnnotationPrivate(), m_stampIconName( "Draft" )
2061  {
2062  }
2063  virtual void setAnnotationProperties( const QDomNode& node );
2064  virtual AnnotationPrivate* getNewAnnotationPrivate();
2065 
2066  QString m_stampIconName;
2067 };
2068 
2069 StampAnnotation::StampAnnotation()
2070  : Annotation( *new StampAnnotationPrivate() )
2071 {
2072 }
2073 
2074 StampAnnotation::StampAnnotation( const QDomNode & node )
2075  : Annotation( *new StampAnnotationPrivate(), node )
2076 {
2077 }
2078 
2079 StampAnnotation::~StampAnnotation()
2080 {
2081 }
2082 
2083 void StampAnnotation::setStampIconName( const QString &name )
2084 {
2085  Q_D( StampAnnotation );
2086  d->m_stampIconName = name;
2087 }
2088 
2089 QString StampAnnotation::stampIconName() const
2090 {
2091  Q_D( const StampAnnotation );
2092  return d->m_stampIconName;
2093 }
2094 
2095 Annotation::SubType StampAnnotation::subType() const
2096 {
2097  return AStamp;
2098 }
2099 
2100 void StampAnnotation::store( QDomNode & node, QDomDocument & document ) const
2101 {
2102  Q_D( const StampAnnotation );
2103  // recurse to parent objects storing properties
2104  Annotation::store( node, document );
2105 
2106  // create [stamp] element
2107  QDomElement stampElement = document.createElement( "stamp" );
2108  node.appendChild( stampElement );
2109 
2110  // append the optional attributes
2111  if ( d->m_stampIconName != "Draft" )
2112  stampElement.setAttribute( "icon", d->m_stampIconName );
2113 }
2114 
2115 void StampAnnotationPrivate::setAnnotationProperties( const QDomNode& node )
2116 {
2117  Okular::AnnotationPrivate::setAnnotationProperties(node);
2118 
2119  // loop through the whole children looking for a 'stamp' element
2120  QDomNode subNode = node.firstChild();
2121  while( subNode.isElement() )
2122  {
2123  QDomElement e = subNode.toElement();
2124  subNode = subNode.nextSibling();
2125  if ( e.tagName() != "stamp" )
2126  continue;
2127 
2128  // parse the attributes
2129  if ( e.hasAttribute( "icon" ) )
2130  m_stampIconName = e.attribute( "icon" );
2131 
2132  // loading complete
2133  break;
2134  }
2135 }
2136 
2137 AnnotationPrivate* StampAnnotationPrivate::getNewAnnotationPrivate()
2138 {
2139  return new StampAnnotationPrivate();
2140 }
2141 
2144 class Okular::InkAnnotationPrivate : public Okular::AnnotationPrivate
2145 {
2146  public:
2147  InkAnnotationPrivate()
2148  : AnnotationPrivate()
2149  {
2150  }
2151 
2152  virtual void transform( const QTransform &matrix );
2153  virtual void baseTransform( const QTransform &matrix );
2154  virtual void resetTransformation();
2155  virtual double distanceSqr( double x, double y, double xScale, double yScale );
2156  virtual void translate( const NormalizedPoint &coord );
2157  virtual void setAnnotationProperties( const QDomNode& node );
2158  virtual AnnotationPrivate* getNewAnnotationPrivate();
2159 
2160  QList< QLinkedList<NormalizedPoint> > m_inkPaths;
2161  QList< QLinkedList<NormalizedPoint> > m_transformedInkPaths;
2162 };
2163 
2164 InkAnnotation::InkAnnotation()
2165  : Annotation( *new InkAnnotationPrivate() )
2166 {
2167 }
2168 
2169 InkAnnotation::InkAnnotation( const QDomNode & node )
2170  : Annotation( *new InkAnnotationPrivate(), node )
2171 {
2172 }
2173 
2174 InkAnnotation::~InkAnnotation()
2175 {
2176 }
2177 
2178 void InkAnnotation::setInkPaths( const QList< QLinkedList<NormalizedPoint> > &paths )
2179 {
2180  Q_D( InkAnnotation );
2181  d->m_inkPaths = paths;
2182 }
2183 
2184 QList< QLinkedList<NormalizedPoint> > InkAnnotation::inkPaths() const
2185 {
2186  Q_D( const InkAnnotation );
2187  return d->m_inkPaths;
2188 }
2189 
2190 QList< QLinkedList<NormalizedPoint> > InkAnnotation::transformedInkPaths() const
2191 {
2192  Q_D( const InkAnnotation );
2193  return d->m_transformedInkPaths;
2194 }
2195 
2196 Annotation::SubType InkAnnotation::subType() const
2197 {
2198  return AInk;
2199 }
2200 
2201 void InkAnnotation::store( QDomNode & node, QDomDocument & document ) const
2202 {
2203  Q_D( const InkAnnotation );
2204  // recurse to parent objects storing properties
2205  Annotation::store( node, document );
2206 
2207  // create [ink] element
2208  QDomElement inkElement = document.createElement( "ink" );
2209  node.appendChild( inkElement );
2210 
2211  // append the optional attributes
2212  if ( d->m_inkPaths.count() < 1 )
2213  return;
2214 
2215  QList< QLinkedList<NormalizedPoint> >::const_iterator pIt = d->m_inkPaths.begin(), pEnd = d->m_inkPaths.end();
2216  for ( ; pIt != pEnd; ++pIt )
2217  {
2218  QDomElement pathElement = document.createElement( "path" );
2219  inkElement.appendChild( pathElement );
2220  const QLinkedList<NormalizedPoint> & path = *pIt;
2221  QLinkedList<NormalizedPoint>::const_iterator iIt = path.begin(), iEnd = path.end();
2222  for ( ; iIt != iEnd; ++iIt )
2223  {
2224  const NormalizedPoint & point = *iIt;
2225  QDomElement pointElement = document.createElement( "point" );
2226  pathElement.appendChild( pointElement );
2227  pointElement.setAttribute( "x", QString::number( point.x ) );
2228  pointElement.setAttribute( "y", QString::number( point.y ) );
2229  }
2230  }
2231 }
2232 
2233 double InkAnnotationPrivate::distanceSqr( double x, double y, double xScale, double yScale )
2234 {
2235  double distance = DBL_MAX;
2236  foreach ( const QLinkedList<NormalizedPoint>& path, m_transformedInkPaths )
2237  {
2238  const double thisDistance = ::distanceSqr( x, y, xScale, yScale, path );
2239  if ( thisDistance < distance )
2240  distance = thisDistance;
2241  }
2242  return strokeDistance( distance, m_style.width() * xScale / ( m_page->m_width * 2 ) );
2243 }
2244 
2245 void InkAnnotationPrivate::transform( const QTransform &matrix )
2246 {
2247  AnnotationPrivate::transform( matrix );
2248 
2249  for ( int i = 0; i < m_transformedInkPaths.count(); ++i )
2250  {
2251  QMutableLinkedListIterator<NormalizedPoint> it( m_transformedInkPaths[ i ] );
2252  while ( it.hasNext() )
2253  it.next().transform( matrix );
2254  }
2255 }
2256 
2257 void InkAnnotationPrivate::baseTransform( const QTransform &matrix )
2258 {
2259  AnnotationPrivate::baseTransform( matrix );
2260 
2261  for ( int i = 0; i < m_inkPaths.count(); ++i )
2262  {
2263  QMutableLinkedListIterator<NormalizedPoint> it( m_inkPaths[ i ] );
2264  while ( it.hasNext() )
2265  it.next().transform( matrix );
2266  }
2267 }
2268 
2269 void InkAnnotationPrivate::resetTransformation()
2270 {
2271  AnnotationPrivate::resetTransformation();
2272 
2273  m_transformedInkPaths = m_inkPaths;
2274 }
2275 
2276 void InkAnnotationPrivate::translate( const NormalizedPoint &coord )
2277 {
2278  AnnotationPrivate::translate( coord );
2279 
2280  for ( int i = 0; i < m_inkPaths.count(); ++i )
2281  {
2282  QMutableLinkedListIterator<NormalizedPoint> it( m_inkPaths[ i ] );
2283  while ( it.hasNext() )
2284  {
2285  NormalizedPoint& p = it.next();
2286  p.x = p.x + coord.x;
2287  p.y = p.y + coord.y;
2288  }
2289  }
2290 }
2291 
2292 void InkAnnotationPrivate::setAnnotationProperties( const QDomNode& node )
2293 {
2294  Okular::AnnotationPrivate::setAnnotationProperties(node);
2295  m_inkPaths.clear();
2296 
2297  // loop through the whole children looking for a 'ink' element
2298  QDomNode subNode = node.firstChild();
2299  while( subNode.isElement() )
2300  {
2301  QDomElement e = subNode.toElement();
2302  subNode = subNode.nextSibling();
2303  if ( e.tagName() != "ink" )
2304  continue;
2305 
2306  // parse the 'path' subnodes
2307  QDomNode pathNode = e.firstChild();
2308  while ( pathNode.isElement() )
2309  {
2310  QDomElement pathElement = pathNode.toElement();
2311  pathNode = pathNode.nextSibling();
2312 
2313  if ( pathElement.tagName() != "path" )
2314  continue;
2315 
2316  // build each path parsing 'point' subnodes
2317  QLinkedList<NormalizedPoint> path;
2318  QDomNode pointNode = pathElement.firstChild();
2319  while ( pointNode.isElement() )
2320  {
2321  QDomElement pointElement = pointNode.toElement();
2322  pointNode = pointNode.nextSibling();
2323 
2324  if ( pointElement.tagName() != "point" )
2325  continue;
2326 
2327  NormalizedPoint p;
2328  p.x = pointElement.attribute( "x", "0.0" ).toDouble();
2329  p.y = pointElement.attribute( "y", "0.0" ).toDouble();
2330  path.append( p );
2331  }
2332 
2333  // add the path to the path list if it contains at least 2 nodes
2334  if ( path.count() >= 2 )
2335  m_inkPaths.append( path );
2336  }
2337 
2338  // loading complete
2339  break;
2340  }
2341 
2342  m_transformedInkPaths = m_inkPaths;
2343 }
2344 
2345 AnnotationPrivate* InkAnnotationPrivate::getNewAnnotationPrivate()
2346 {
2347  return new InkAnnotationPrivate();
2348 }
2349 
2352 class Okular::CaretAnnotationPrivate : public Okular::AnnotationPrivate
2353 {
2354  public:
2355  CaretAnnotationPrivate()
2356  : AnnotationPrivate(), m_symbol( CaretAnnotation::None )
2357  {
2358  }
2359 
2360  virtual void setAnnotationProperties( const QDomNode& node );
2361  virtual AnnotationPrivate* getNewAnnotationPrivate();
2362 
2363  CaretAnnotation::CaretSymbol m_symbol;
2364 };
2365 
2366 static QString caretSymbolToString( CaretAnnotation::CaretSymbol symbol )
2367 {
2368  switch ( symbol )
2369  {
2370  case CaretAnnotation::None:
2371  return QString::fromLatin1( "None" );
2372  case CaretAnnotation::P:
2373  return QString::fromLatin1( "P" );
2374  }
2375  return QString();
2376 }
2377 
2378 static CaretAnnotation::CaretSymbol caretSymbolFromString( const QString &symbol )
2379 {
2380  if ( symbol == QLatin1String( "None" ) )
2381  return CaretAnnotation::None;
2382  else if ( symbol == QLatin1String( "P" ) )
2383  return CaretAnnotation::P;
2384  return CaretAnnotation::None;
2385 }
2386 
2387 void CaretAnnotationPrivate::setAnnotationProperties( const QDomNode& node )
2388 {
2389  Okular::AnnotationPrivate::setAnnotationProperties(node);
2390 
2391  // loop through the whole children looking for a 'caret' element
2392  QDomNode subNode = node.firstChild();
2393  while( subNode.isElement() )
2394  {
2395  QDomElement e = subNode.toElement();
2396  subNode = subNode.nextSibling();
2397  if ( e.tagName() != "caret" )
2398  continue;
2399 
2400  // parse the attributes
2401  if ( e.hasAttribute( "symbol" ) )
2402  m_symbol = caretSymbolFromString( e.attribute( "symbol" ) );
2403 
2404  // loading complete
2405  break;
2406  }
2407 }
2408 
2409 AnnotationPrivate* CaretAnnotationPrivate::getNewAnnotationPrivate()
2410 {
2411  return new CaretAnnotationPrivate();
2412 }
2413 
2414 CaretAnnotation::CaretAnnotation()
2415  : Annotation( *new CaretAnnotationPrivate() )
2416 {
2417 }
2418 
2419 CaretAnnotation::CaretAnnotation( const QDomNode & node )
2420  : Annotation( *new CaretAnnotationPrivate(), node )
2421 {
2422 }
2423 
2424 CaretAnnotation::~CaretAnnotation()
2425 {
2426 }
2427 
2428 void CaretAnnotation::setCaretSymbol( CaretAnnotation::CaretSymbol symbol )
2429 {
2430  Q_D( CaretAnnotation );
2431  d->m_symbol = symbol;
2432 }
2433 
2434 CaretAnnotation::CaretSymbol CaretAnnotation::caretSymbol() const
2435 {
2436  Q_D( const CaretAnnotation );
2437  return d->m_symbol;
2438 }
2439 
2440 Annotation::SubType CaretAnnotation::subType() const
2441 {
2442  return ACaret;
2443 }
2444 
2445 void CaretAnnotation::store( QDomNode & node, QDomDocument & document ) const
2446 {
2447  Q_D( const CaretAnnotation );
2448  // recurse to parent objects storing properties
2449  Annotation::store( node, document );
2450 
2451  // create [caret] element
2452  QDomElement caretElement = document.createElement( "caret" );
2453  node.appendChild( caretElement );
2454 
2455  // append the optional attributes
2456  if ( d->m_symbol != None )
2457  caretElement.setAttribute( "symbol", caretSymbolToString( d->m_symbol ) );
2458 }
2459 
2462 class Okular::FileAttachmentAnnotationPrivate : public Okular::AnnotationPrivate
2463 {
2464  public:
2465  FileAttachmentAnnotationPrivate()
2466  : AnnotationPrivate(), icon( "PushPin" ), embfile( 0 )
2467  {
2468  }
2469  ~FileAttachmentAnnotationPrivate()
2470  {
2471  delete embfile;
2472  }
2473 
2474  virtual void setAnnotationProperties( const QDomNode& node );
2475  virtual AnnotationPrivate* getNewAnnotationPrivate();
2476 
2477  // data fields
2478  QString icon;
2479  EmbeddedFile *embfile;
2480 };
2481 
2482 void FileAttachmentAnnotationPrivate::setAnnotationProperties( const QDomNode& node )
2483 {
2484  Okular::AnnotationPrivate::setAnnotationProperties(node);
2485 
2486  // loop through the whole children looking for a 'fileattachment' element
2487  QDomNode subNode = node.firstChild();
2488  while( subNode.isElement() )
2489  {
2490  QDomElement e = subNode.toElement();
2491  subNode = subNode.nextSibling();
2492  if ( e.tagName() != "fileattachment" )
2493  continue;
2494 
2495  // loading complete
2496  break;
2497  }
2498 }
2499 
2500 AnnotationPrivate* FileAttachmentAnnotationPrivate::getNewAnnotationPrivate()
2501 {
2502  return new FileAttachmentAnnotationPrivate();
2503 }
2504 
2505 FileAttachmentAnnotation::FileAttachmentAnnotation()
2506  : Annotation( *new FileAttachmentAnnotationPrivate() )
2507 {
2508 }
2509 
2510 FileAttachmentAnnotation::FileAttachmentAnnotation( const QDomNode & node )
2511  : Annotation( *new FileAttachmentAnnotationPrivate(), node )
2512 {
2513 }
2514 
2515 FileAttachmentAnnotation::~FileAttachmentAnnotation()
2516 {
2517 }
2518 
2519 void FileAttachmentAnnotation::store( QDomNode & node, QDomDocument & document ) const
2520 {
2521  // recurse to parent objects storing properties
2522  Annotation::store( node, document );
2523 
2524  // create [fileattachment] element
2525  QDomElement fileAttachmentElement = document.createElement( "fileattachment" );
2526  node.appendChild( fileAttachmentElement );
2527 }
2528 
2529 Annotation::SubType FileAttachmentAnnotation::subType() const
2530 {
2531  return AFileAttachment;
2532 }
2533 
2534 QString FileAttachmentAnnotation::fileIconName() const
2535 {
2536  Q_D( const FileAttachmentAnnotation );
2537  return d->icon;
2538 }
2539 
2540 void FileAttachmentAnnotation::setFileIconName( const QString &icon )
2541 {
2542  Q_D( FileAttachmentAnnotation );
2543  d->icon = icon;
2544 }
2545 
2546 EmbeddedFile* FileAttachmentAnnotation::embeddedFile() const
2547 {
2548  Q_D( const FileAttachmentAnnotation );
2549  return d->embfile;
2550 }
2551 
2552 void FileAttachmentAnnotation::setEmbeddedFile( EmbeddedFile *ef )
2553 {
2554  Q_D( FileAttachmentAnnotation );
2555  d->embfile = ef;
2556 }
2557 
2558 
2561 class Okular::SoundAnnotationPrivate : public Okular::AnnotationPrivate
2562 {
2563  public:
2564  SoundAnnotationPrivate()
2565  : AnnotationPrivate(), icon( "Speaker" ), sound( 0 )
2566  {
2567  }
2568  ~SoundAnnotationPrivate()
2569  {
2570  delete sound;
2571  }
2572 
2573  virtual void setAnnotationProperties( const QDomNode& node );
2574  virtual AnnotationPrivate* getNewAnnotationPrivate();
2575 
2576  // data fields
2577  QString icon;
2578  Sound *sound;
2579 };
2580 
2581 void SoundAnnotationPrivate::setAnnotationProperties( const QDomNode& node )
2582 {
2583  Okular::AnnotationPrivate::setAnnotationProperties(node);
2584 
2585  // loop through the whole children looking for a 'sound' element
2586  QDomNode subNode = node.firstChild();
2587  while( subNode.isElement() )
2588  {
2589  QDomElement e = subNode.toElement();
2590  subNode = subNode.nextSibling();
2591  if ( e.tagName() != "sound" )
2592  continue;
2593 
2594  // loading complete
2595  break;
2596  }
2597 }
2598 
2599 AnnotationPrivate* SoundAnnotationPrivate::getNewAnnotationPrivate()
2600 {
2601  return new SoundAnnotationPrivate();
2602 }
2603 
2604 SoundAnnotation::SoundAnnotation()
2605  : Annotation( *new SoundAnnotationPrivate() )
2606 {
2607 }
2608 
2609 SoundAnnotation::SoundAnnotation( const QDomNode & node )
2610  : Annotation( *new SoundAnnotationPrivate(), node )
2611 {
2612 }
2613 
2614 SoundAnnotation::~SoundAnnotation()
2615 {
2616 }
2617 
2618 void SoundAnnotation::store( QDomNode & node, QDomDocument & document ) const
2619 {
2620  // recurse to parent objects storing properties
2621  Annotation::store( node, document );
2622 
2623  // create [sound] element
2624  QDomElement soundElement = document.createElement( "sound" );
2625  node.appendChild( soundElement );
2626 }
2627 
2628 Annotation::SubType SoundAnnotation::subType() const
2629 {
2630  return ASound;
2631 }
2632 
2633 QString SoundAnnotation::soundIconName() const
2634 {
2635  Q_D( const SoundAnnotation );
2636  return d->icon;
2637 }
2638 
2639 void SoundAnnotation::setSoundIconName( const QString &icon )
2640 {
2641  Q_D( SoundAnnotation );
2642  d->icon = icon;
2643 }
2644 
2645 Sound* SoundAnnotation::sound() const
2646 {
2647  Q_D( const SoundAnnotation );
2648  return d->sound;
2649 }
2650 
2651 void SoundAnnotation::setSound( Sound *s )
2652 {
2653  Q_D( SoundAnnotation );
2654  d->sound = s;
2655 }
2656 
2659 class Okular::MovieAnnotationPrivate : public Okular::AnnotationPrivate
2660 {
2661  public:
2662  MovieAnnotationPrivate()
2663  : AnnotationPrivate(), movie( 0 )
2664  {
2665  }
2666  ~MovieAnnotationPrivate()
2667  {
2668  delete movie;
2669  }
2670 
2671  virtual void setAnnotationProperties( const QDomNode& node );
2672  virtual AnnotationPrivate* getNewAnnotationPrivate();
2673 
2674  // data fields
2675  Movie *movie;
2676 };
2677 
2678 void MovieAnnotationPrivate::setAnnotationProperties( const QDomNode& node )
2679 {
2680  Okular::AnnotationPrivate::setAnnotationProperties(node);
2681 
2682  // loop through the whole children looking for a 'movie' element
2683  QDomNode subNode = node.firstChild();
2684  while( subNode.isElement() )
2685  {
2686  QDomElement e = subNode.toElement();
2687  subNode = subNode.nextSibling();
2688  if ( e.tagName() != "movie" )
2689  continue;
2690 
2691  // loading complete
2692  break;
2693  }
2694 }
2695 
2696 AnnotationPrivate* MovieAnnotationPrivate::getNewAnnotationPrivate()
2697 {
2698  return new MovieAnnotationPrivate();
2699 }
2700 
2701 MovieAnnotation::MovieAnnotation()
2702  : Annotation( *new MovieAnnotationPrivate() )
2703 {
2704 }
2705 
2706 MovieAnnotation::MovieAnnotation( const QDomNode & node )
2707  : Annotation( *new MovieAnnotationPrivate(), node )
2708 {
2709 }
2710 
2711 MovieAnnotation::~MovieAnnotation()
2712 {
2713 }
2714 
2715 void MovieAnnotation::store( QDomNode & node, QDomDocument & document ) const
2716 {
2717  // recurse to parent objects storing properties
2718  Annotation::store( node, document );
2719 
2720  // create [movie] element
2721  QDomElement movieElement = document.createElement( "movie" );
2722  node.appendChild( movieElement );
2723 }
2724 
2725 Annotation::SubType MovieAnnotation::subType() const
2726 {
2727  return AMovie;
2728 }
2729 
2730 Movie* MovieAnnotation::movie() const
2731 {
2732  Q_D( const MovieAnnotation );
2733  return d->movie;
2734 }
2735 
2736 void MovieAnnotation::setMovie( Movie *movie )
2737 {
2738  Q_D( MovieAnnotation );
2739  d->movie = movie;
2740 }
2741 
2744 class Okular::ScreenAnnotationPrivate : public Okular::AnnotationPrivate
2745 {
2746  public:
2747  ScreenAnnotationPrivate();
2748  ~ScreenAnnotationPrivate();
2749 
2750  virtual void setAnnotationProperties( const QDomNode& node );
2751  virtual AnnotationPrivate* getNewAnnotationPrivate();
2752 
2753  Okular::Action* m_action;
2754  QMap< Okular::Annotation::AdditionalActionType, Okular::Action* > m_additionalActions;
2755 };
2756 
2757 ScreenAnnotationPrivate::ScreenAnnotationPrivate()
2758  : m_action( 0 )
2759 {
2760 }
2761 
2762 ScreenAnnotationPrivate::~ScreenAnnotationPrivate()
2763 {
2764  delete m_action;
2765  qDeleteAll( m_additionalActions );
2766 }
2767 
2768 void ScreenAnnotationPrivate::setAnnotationProperties( const QDomNode& node )
2769 {
2770  Okular::AnnotationPrivate::setAnnotationProperties(node);
2771 
2772  // loop through the whole children looking for a 'screen' element
2773  QDomNode subNode = node.firstChild();
2774  while( subNode.isElement() )
2775  {
2776  QDomElement e = subNode.toElement();
2777  subNode = subNode.nextSibling();
2778  if ( e.tagName() != "screen" )
2779  continue;
2780 
2781  // loading complete
2782  break;
2783  }
2784 }
2785 
2786 AnnotationPrivate* ScreenAnnotationPrivate::getNewAnnotationPrivate()
2787 {
2788  return new ScreenAnnotationPrivate();
2789 }
2790 
2791 ScreenAnnotation::ScreenAnnotation()
2792  : Annotation( *new ScreenAnnotationPrivate() )
2793 {
2794 }
2795 
2796 ScreenAnnotation::ScreenAnnotation( const QDomNode & node )
2797  : Annotation( *new ScreenAnnotationPrivate(), node )
2798 {
2799 }
2800 
2801 ScreenAnnotation::~ScreenAnnotation()
2802 {
2803 }
2804 
2805 void ScreenAnnotation::store( QDomNode & node, QDomDocument & document ) const
2806 {
2807  // recurse to parent objects storing properties
2808  Annotation::store( node, document );
2809 
2810  // create [screen] element
2811  QDomElement movieElement = document.createElement( "screen" );
2812  node.appendChild( movieElement );
2813 }
2814 
2815 Annotation::SubType ScreenAnnotation::subType() const
2816 {
2817  return AScreen;
2818 }
2819 
2820 void ScreenAnnotation::setAdditionalAction( AdditionalActionType type, Action *action )
2821 {
2822  Q_D( ScreenAnnotation );
2823  if ( d->m_additionalActions.contains( type ) )
2824  delete d->m_additionalActions.value( type );
2825 
2826  d->m_additionalActions.insert( type, action );
2827 }
2828 
2829 Action* ScreenAnnotation::additionalAction( AdditionalActionType type ) const
2830 {
2831  Q_D( const ScreenAnnotation );
2832  if ( !d->m_additionalActions.contains( type ) )
2833  return 0;
2834  else
2835  return d->m_additionalActions.value( type );
2836 }
2837 
2838 void ScreenAnnotation::setAction( Action *action )
2839 {
2840  Q_D( ScreenAnnotation );
2841 
2842  delete d->m_action;
2843  d->m_action = action;
2844 }
2845 
2846 Action* ScreenAnnotation::action() const
2847 {
2848  Q_D( const ScreenAnnotation );
2849  return d->m_action;
2850 }
2851 
2854 class Okular::WidgetAnnotationPrivate : public Okular::AnnotationPrivate
2855 {
2856  public:
2857  ~WidgetAnnotationPrivate();
2858  virtual void setAnnotationProperties( const QDomNode& node );
2859  virtual AnnotationPrivate* getNewAnnotationPrivate();
2860 
2861  QMap< Okular::Annotation::AdditionalActionType, Okular::Action* > m_additionalActions;
2862 };
2863 
2864 WidgetAnnotationPrivate::~WidgetAnnotationPrivate()
2865 {
2866  qDeleteAll( m_additionalActions );
2867 }
2868 
2869 void WidgetAnnotationPrivate::setAnnotationProperties( const QDomNode& node )
2870 {
2871  Okular::AnnotationPrivate::setAnnotationProperties(node);
2872 
2873  // loop through the whole children looking for a 'widget' element
2874  QDomNode subNode = node.firstChild();
2875  while( subNode.isElement() )
2876  {
2877  QDomElement e = subNode.toElement();
2878  subNode = subNode.nextSibling();
2879  if ( e.tagName() != "widget" )
2880  continue;
2881 
2882  // loading complete
2883  break;
2884  }
2885 }
2886 
2887 AnnotationPrivate* WidgetAnnotationPrivate::getNewAnnotationPrivate()
2888 {
2889  return new WidgetAnnotationPrivate();
2890 }
2891 
2892 WidgetAnnotation::WidgetAnnotation()
2893  : Annotation( *new WidgetAnnotationPrivate() )
2894 {
2895 }
2896 
2897 WidgetAnnotation::WidgetAnnotation( const QDomNode & node )
2898  : Annotation( *new WidgetAnnotationPrivate, node )
2899 {
2900 }
2901 
2902 WidgetAnnotation::~WidgetAnnotation()
2903 {
2904 }
2905 
2906 void WidgetAnnotation::store( QDomNode & node, QDomDocument & document ) const
2907 {
2908  // recurse to parent objects storing properties
2909  Annotation::store( node, document );
2910 
2911  // create [widget] element
2912  QDomElement movieElement = document.createElement( "widget" );
2913  node.appendChild( movieElement );
2914 }
2915 
2916 Annotation::SubType WidgetAnnotation::subType() const
2917 {
2918  return AWidget;
2919 }
2920 
2921 void WidgetAnnotation::setAdditionalAction( AdditionalActionType type, Action *action )
2922 {
2923  Q_D( WidgetAnnotation );
2924  if ( d->m_additionalActions.contains( type ) )
2925  delete d->m_additionalActions.value( type );
2926 
2927  d->m_additionalActions.insert( type, action );
2928 }
2929 
2930 Action* WidgetAnnotation::additionalAction( AdditionalActionType type ) const
2931 {
2932  Q_D( const WidgetAnnotation );
2933  if ( !d->m_additionalActions.contains( type ) )
2934  return 0;
2935  else
2936  return d->m_additionalActions.value( type );
2937 }
Okular::LineAnnotation::setLineStartStyle
void setLineStartStyle(TermStyle style)
Sets the line starting style of the line annotation.
Definition: annotations.cpp:1318
Okular::Annotation::Window::width
int width() const
Returns the width of the window.
Definition: annotations.cpp:389
Okular::Annotation::modificationDate
QDateTime modificationDate() const
Returns the last modification date of the annotation.
Definition: annotations.cpp:569
Okular::Annotation::Style::opacity
double opacity() const
Returns the opacity of the style.
Definition: annotations.cpp:238
Okular::Annotation::AStamp
A stamp annotation.
Definition: annotations.h:111
Okular::GeomAnnotation::GeomAnnotation
GeomAnnotation()
Creates a new geometrical annotation.
Definition: annotations.cpp:1599
Okular::NormalizedPoint
NormalizedPoint is a helper class which stores the coordinates of a normalized point.
Definition: area.h:47
Okular::HighlightAnnotation::HighlightType
HighlightType
Describes the highlighting style of the annotation.
Definition: annotations.h:1084
Okular::Annotation::setUniqueName
void setUniqueName(const QString &name)
Sets the unique name of the annotation.
Definition: annotations.cpp:551
Okular::TextAnnotation::Unknown
Unknown style.
Definition: annotations.h:748
Okular::None
Definition: page_p.h:44
Okular::Annotation::author
QString author() const
Returns the author of the annotation.
Definition: annotations.cpp:533
Okular::AnnotationUtils::findChildElement
static QDomElement findChildElement(const QDomNode &parentNode, const QString &name)
Returns the child element with the given name from the direct children of parentNode or a null elemen...
Definition: annotations.cpp:138
Okular::Annotation::Revision
The Revision class contains all information about the revision of the annotation. ...
Definition: annotations.h:535
Okular::SoundAnnotation::SoundAnnotation
SoundAnnotation()
Creates a new sound annotation.
Definition: annotations.cpp:2604
Okular::CaretAnnotation
Definition: annotations.h:1315
Okular::Annotation::Style::setSpaces
void setSpaces(int spaces)
Sets the spaces of the style.
Definition: annotations.cpp:293
Okular::Annotation::AFileAttachment
A file attachment annotation.
Definition: annotations.h:114
Okular::TextAnnotation::inplaceCallout
NormalizedPoint inplaceCallout(int index) const
Returns the inplace callout point for index.
Definition: annotations.cpp:1075
Okular::ScreenAnnotation::setAction
void setAction(Action *action)
Sets the action that is executed when the annotation is triggered.
Definition: annotations.cpp:2838
Okular::GeomAnnotation::~GeomAnnotation
~GeomAnnotation()
Destroys the geometrical annotation.
Definition: annotations.cpp:1609
Okular::PagePrivate
Definition: page_p.h:55
Okular::TextAnnotation::textIcon
QString textIcon() const
Returns the icon of the text annotation.
Definition: annotations.cpp:1036
Okular::Annotation::AMovie
A movie annotation.
Definition: annotations.h:116
sound.h
Okular::CaretAnnotation::CaretSymbol
CaretSymbol
Describes the highlighting style of the annotation.
Definition: annotations.h:1321
Okular::AnnotationPrivate::m_flags
int m_flags
Definition: annotations_p.h:64
Okular::TextAnnotation::InplaceIntent
InplaceIntent
Describes the style of the text.
Definition: annotations.h:746
Okular::AnnotationProxy::~AnnotationProxy
virtual ~AnnotationProxy()
Destroys the annotation proxy.
Definition: annotations.cpp:171
Okular::HighlightAnnotation::subType
SubType subType() const
Returns the sub type of the highlight annotation.
Definition: annotations.cpp:1950
Okular::Annotation::Style::setWidth
void setWidth(double width)
Sets the width of the style.
Definition: annotations.cpp:243
Okular::TextAnnotation::setTextFont
void setTextFont(const QFont &font)
Sets the font of the text annotation.
Definition: annotations.cpp:1042
Okular::LineAnnotation::lineLeadingForwardPoint
double lineLeadingForwardPoint() const
Returns the leading forward point of the line annotation.
Definition: annotations.cpp:1372
Okular::CaretAnnotation::CaretAnnotation
CaretAnnotation()
Creates a new caret annotation.
Definition: annotations.cpp:2414
Okular::GeomAnnotation::GeomType
GeomType
Definition: annotations.h:1020
Okular::Annotation::AScreen
A screen annotation.
Definition: annotations.h:117
Okular::Annotation::Style::marks
int marks() const
Returns the marks of the style.
Definition: annotations.cpp:288
Okular::GeomAnnotation::subType
SubType subType() const
Returns the sub type of the geometrical annotation.
Definition: annotations.cpp:1637
Okular::PagePrivate::m_page
Page * m_page
Definition: page_p.h:122
Okular::Annotation::Window::setWidth
void setWidth(int width)
Sets the width of the window.
Definition: annotations.cpp:384
Okular::Annotation::creationDate
QDateTime creationDate() const
Returns the creation date of the annotation.
Definition: annotations.cpp:581
Okular::GeomAnnotation::geometricalInnerColor
QColor geometricalInnerColor() const
Returns the inner color of the geometrical annotation.
Definition: annotations.cpp:1631
Okular::Annotation::Style::color
QColor color() const
Returns the color of the style.
Definition: annotations.cpp:228
Okular::FileAttachmentAnnotation
Definition: annotations.h:1368
Okular::LineAnnotation::lineClosed
bool lineClosed() const
Returns whether the line shall be closed.
Definition: annotations.cpp:1348
Okular::NormalizedRect::transform
void transform(const QTransform &matrix)
Transforms the normalized rectangle with the operations defined by matrix.
Definition: area.cpp:259
Okular::SoundAnnotation::setSound
void setSound(Sound *object)
Sets the object representing the sound of the file attachment annotation.
Definition: annotations.cpp:2651
Okular::AnnotationPrivate::m_boundary
NormalizedRect m_boundary
Definition: annotations_p.h:65
Okular::LineAnnotation::setLineClosed
void setLineClosed(bool closed)
Sets whether the line shall be closed.
Definition: annotations.cpp:1342
Okular::Annotation::nativeId
QVariant nativeId() const
Returns the "native" id of the annotation.
Definition: annotations.cpp:681
Okular::FileAttachmentAnnotation::store
void store(QDomNode &node, QDomDocument &document) const
Stores the file attachment annotation as xml in document under the given parent node.
Definition: annotations.cpp:2519
Okular::CaretAnnotation::store
void store(QDomNode &node, QDomDocument &document) const
Stores the caret annotation as xml in document under the given parent node.
Definition: annotations.cpp:2445
Okular::Annotation::BeingMoved
Is being moved (mouse drag and drop). If ExternallyDrawn, the generator must not draw it...
Definition: annotations.h:136
Okular::SoundAnnotation::subType
SubType subType() const
Returns the sub type of the sound annotation.
Definition: annotations.cpp:2628
caretSymbolFromString
static CaretAnnotation::CaretSymbol caretSymbolFromString(const QString &symbol)
Definition: annotations.cpp:2378
Okular::GeomAnnotation::setGeometricalType
void setGeometricalType(GeomType type)
Sets the geometrical type of the geometrical annotation.
Definition: annotations.cpp:1613
Okular::Annotation::AText
A textual annotation.
Definition: annotations.h:107
Okular::AnnotationPrivate::resetTransformation
virtual void resetTransformation()
Definition: annotations.cpp:857
Okular::HighlightAnnotation::Quad::~Quad
~Quad()
Destroys the quad.
Definition: annotations.cpp:1780
Okular::Annotation::Style::setLineEffect
void setLineEffect(LineEffect effect)
Sets the line effect of the style.
Definition: annotations.cpp:303
Okular::InkAnnotation::transformedInkPaths
QList< QLinkedList< NormalizedPoint > > transformedInkPaths() const
Returns the paths of transformed (e.g.
Definition: annotations.cpp:2190
Okular::NormalizedRect::left
double left
The normalized left coordinate.
Definition: area.h:305
Okular::HighlightAnnotation::setHighlightType
void setHighlightType(HighlightType type)
Sets the type of the highlight annotation.
Definition: annotations.cpp:1894
Okular::Annotation::Window::setFlags
void setFlags(int flags)
Sets the flags of the window.
Definition: annotations.cpp:364
Okular::LineAnnotation::showCaption
bool showCaption() const
Returns whether the caption shall be shown.
Definition: annotations.cpp:1396
Okular::Annotation::setDisposeDataFunction
void setDisposeDataFunction(DisposeDataFunction func)
Sets a function to be called when the annotation is destroyed.
Definition: annotations.cpp:687
Okular::MovieAnnotation::subType
SubType subType() const
Returns the sub type of the movie annotation.
Definition: annotations.cpp:2725
Okular::Annotation::setModificationDate
void setModificationDate(const QDateTime &date)
Sets the last modification date of the annotation.
Definition: annotations.cpp:563
Okular::NormalizedRect
NormalizedRect is a helper class which stores the coordinates of a normalized rect, which is a rectangle of.
Definition: area.h:105
Okular::AnnotationPrivate::m_style
Okular::Annotation::Style m_style
Definition: annotations_p.h:68
Okular::GeomAnnotation::InscribedCircle
Draw a circle.
Definition: annotations.h:1023
Okular::ScreenAnnotation::subType
SubType subType() const
Returns the sub type of the screen annotation.
Definition: annotations.cpp:2815
Okular::TextAnnotation::~TextAnnotation
~TextAnnotation()
Destroys the text annotation.
Definition: annotations.cpp:1014
Okular::WidgetAnnotation::WidgetAnnotation
WidgetAnnotation()
Creates a new widget annotation.
Definition: annotations.cpp:2892
Okular::Annotation::Window::height
int height() const
Returns the height of the window.
Definition: annotations.cpp:399
Okular::SoundAnnotation::store
void store(QDomNode &node, QDomDocument &document) const
Stores the sound annotation as xml in document under the given parent node.
Definition: annotations.cpp:2618
annotations_p.h
Okular::Annotation::style
Style & style()
Returns a reference to the style object of the annotation.
Definition: annotations.cpp:639
Okular::HighlightAnnotation::Quad::setCapEnd
void setCapEnd(bool value)
Sets whether a cap should be used at the end.
Definition: annotations.cpp:1833
Okular::NormalizedPoint::y
double y
The normalized y coordinate.
Definition: area.h:97
Okular::LineAnnotation::None
No special ending style.
Definition: annotations.h:869
Okular::CaretAnnotation::setCaretSymbol
void setCaretSymbol(CaretAnnotation::CaretSymbol symbol)
Sets the symbol for the caret annotation.
Definition: annotations.cpp:2428
Okular::Annotation::Window::summary
QString summary() const
Returns the summary of the window.
Definition: annotations.cpp:419
Okular::HighlightAnnotation::Quad::Quad
Quad()
Creates a new quad.
Definition: annotations.cpp:1775
Okular::AnnotationPrivate::getNewAnnotationPrivate
virtual AnnotationPrivate * getNewAnnotationPrivate()=0
page_p.h
Okular::LineAnnotation::linePoints
QLinkedList< NormalizedPoint > linePoints() const
Returns the normalized line points of the line annotation.
Definition: annotations.cpp:1306
Okular::ScreenAnnotation::store
void store(QDomNode &parentNode, QDomDocument &document) const
Stores the screen annotation as xml in document under the given parentNode.
Definition: annotations.cpp:2805
Okular::AnnotationPrivate::annotationTransform
void annotationTransform(const QTransform &matrix)
Transforms the annotation coordinates with the transformation defined by matrix.
Definition: annotations.cpp:841
Okular::AnnotationPrivate::~AnnotationPrivate
virtual ~AnnotationPrivate()
Definition: annotations.cpp:497
Okular::Annotation::ALine
A line annotation.
Definition: annotations.h:108
Okular::LineAnnotation::store
void store(QDomNode &node, QDomDocument &document) const
Stores the line annotation as xml in document under the given parent node.
Definition: annotations.cpp:1419
Okular::ScreenAnnotation::additionalAction
Action * additionalAction(AdditionalActionType type) const
Returns the additional action of the given type or 0 if no action has been defined.
Definition: annotations.cpp:2829
Okular::CaretAnnotation::P
A 'paragraph' symbol.
Definition: annotations.h:1324
ADD_COORD
#define ADD_COORD(c1, c2)
Okular::StampAnnotation::subType
SubType subType() const
Returns the sub type of the stamp annotation.
Definition: annotations.cpp:2095
Okular::EmbeddedFile
An embedded file into the document.
Definition: document.h:1178
Okular::Annotation::Style::setOpacity
void setOpacity(double opacity)
Sets the opacity of the style.
Definition: annotations.cpp:233
Okular::AnnotationPrivate::setAnnotationProperties
virtual void setAnnotationProperties(const QDomNode &node)
Definition: annotations.cpp:875
Okular::Annotation::Style::setYCorners
void setYCorners(double yCorners)
Sets the y-corners of the style.
Definition: annotations.cpp:273
Okular::HighlightAnnotation::Quad::capEnd
bool capEnd() const
Returns whether a cap should be used at the end.
Definition: annotations.cpp:1838
Okular::Annotation::setContents
void setContents(const QString &contents)
Sets the contents of the annotation.
Definition: annotations.cpp:539
Okular::Annotation::None
Not specified.
Definition: annotations.h:175
Okular::LineAnnotation::setLineInnerColor
void setLineInnerColor(const QColor &color)
Sets the inner line color of the line annotation.
Definition: annotations.cpp:1354
Okular::TextAnnotation::textType
TextType textType() const
Returns the text type of the text annotation.
Definition: annotations.cpp:1024
Okular::HighlightAnnotation
Definition: annotations.h:1078
Okular::StampAnnotation::setStampIconName
void setStampIconName(const QString &name)
Sets the name of the icon for the stamp annotation.
Definition: annotations.cpp:2083
Okular::Annotation::Revision::Revision
Revision()
Creates a new revision.
Definition: annotations.cpp:437
Okular::AnnotationPrivate
Definition: annotations_p.h:28
Okular::LineAnnotation
Definition: annotations.h:856
Okular::AnnotationPrivate::m_transformedBoundary
NormalizedRect m_transformedBoundary
Definition: annotations_p.h:66
Okular::MovieAnnotation::setMovie
void setMovie(Movie *movie)
Sets the new movie object.
Definition: annotations.cpp:2736
Okular::Annotation::setFlags
void setFlags(int flags)
Sets the flags of the annotation.
Definition: annotations.cpp:587
Okular::Annotation::Window
The Window class contains all information about the popup window of the annotation that is used to ed...
Definition: annotations.h:440
Okular::LineAnnotation::lineInnerColor
QColor lineInnerColor() const
Returns the inner line color of the line annotation.
Definition: annotations.cpp:1360
Okular::StampAnnotation
Definition: annotations.h:1221
Okular::Annotation::Revision::type
RevisionType type() const
Returns the type of the revision.
Definition: annotations.cpp:486
Okular::Annotation::RevisionType
RevisionType
Describes the type of revision information.
Definition: annotations.h:173
Okular::LineAnnotation::~LineAnnotation
~LineAnnotation()
Destroys the line annotation.
Definition: annotations.cpp:1296
Okular::Annotation::SubType
SubType
Describes the type of annotation as defined in PDF standard.
Definition: annotations.h:105
Okular::HighlightAnnotation::highlightType
HighlightType highlightType() const
Returns the type of the highlight annotation.
Definition: annotations.cpp:1900
Okular::StampAnnotation::stampIconName
QString stampIconName() const
Returns the name of the icon.
Definition: annotations.cpp:2089
Okular::AnnotationPrivate::openDialogAfterCreation
virtual bool openDialogAfterCreation() const
Definition: annotations.cpp:870
Okular::AnnotationUtils::annotationGeometry
static QRect annotationGeometry(const Annotation *annotation, double scaleX, double scaleY)
Returns the geometry of the given annotation scaled by scaleX and scaleY.
Definition: annotations.cpp:154
Okular::TextAnnotation::textFont
QFont textFont() const
Returns the font of the text annotation.
Definition: annotations.cpp:1048
Okular::LineAnnotation::TermStyle
TermStyle
Describes the line ending style.
Definition: annotations.h:862
Okular::HighlightAnnotation::Quad::setCapStart
void setCapStart(bool value)
Sets whether a cap should be used at the start.
Definition: annotations.cpp:1823
Okular::WidgetAnnotation::setAdditionalAction
void setAdditionalAction(AdditionalActionType type, Action *action)
Sets the additional action of the given type.
Definition: annotations.cpp:2921
Okular::MovieAnnotation::store
void store(QDomNode &parentNode, QDomDocument &document) const
Stores the movie annotation as xml in document under the given parentNode.
Definition: annotations.cpp:2715
Okular::LineAnnotation::lineStartStyle
TermStyle lineStartStyle() const
Returns the line starting style of the line annotation.
Definition: annotations.cpp:1324
Okular::NormalizedRect::right
double right
The normalized right coordinate.
Definition: area.h:315
Okular::ScreenAnnotation::action
Action * action() const
Returns the action that is executed when the annotation is triggered or 0 if not action has been defi...
Definition: annotations.cpp:2846
Okular::Annotation::translate
void translate(const NormalizedPoint &coord)
Move the annotation by the specified coordinates.
Definition: annotations.cpp:622
Okular::FileAttachmentAnnotation::FileAttachmentAnnotation
FileAttachmentAnnotation()
Creates a new file attachment annotation.
Definition: annotations.cpp:2505
Okular::SoundAnnotation
Sound annotation.
Definition: annotations.h:1428
Okular::Annotation::setNativeId
void setNativeId(const QVariant &id)
Sets the "native" id of the annotation.
Definition: annotations.cpp:675
Okular::WidgetAnnotation::additionalAction
Action * additionalAction(AdditionalActionType type) const
Returns the additional action of the given type or 0 if no action has been defined.
Definition: annotations.cpp:2930
Okular::TextAnnotation::inplaceIntent
InplaceIntent inplaceIntent() const
Returns the inplace intent of the text annotation.
Definition: annotations.cpp:1099
Okular::SoundAnnotation::soundIconName
QString soundIconName() const
Gets the name of the icon.
Definition: annotations.cpp:2633
Okular::FileAttachmentAnnotation::subType
SubType subType() const
Returns the sub type of the file attachment annotation.
Definition: annotations.cpp:2529
Okular::Annotation::Window::flags
int flags() const
Returns the flags of the window.
Definition: annotations.cpp:369
Okular::Annotation::DisposeDataFunction
void(* DisposeDataFunction)(const Okular::Annotation *)
A function to be called when the annotation is destroyed.
Definition: annotations.h:203
Okular::GeomAnnotation
Definition: annotations.h:1016
Okular::SoundAnnotation::sound
Sound * sound() const
Gets the sound object.
Definition: annotations.cpp:2645
Okular::Annotation::AGeom
A geometrical annotation.
Definition: annotations.h:109
Okular::AnnotationPrivate::m_contents
QString m_contents
Definition: annotations_p.h:59
Okular::LineAnnotation::setLineIntent
void setLineIntent(LineIntent intent)
Sets the line intent of the line annotation.
Definition: annotations.cpp:1402
Okular::GeomAnnotation::geometricalType
GeomType geometricalType() const
Returns the geometrical type of the geometrical annotation.
Definition: annotations.cpp:1619
Okular::HighlightAnnotation::Quad::capStart
bool capStart() const
Returns whether a cap should be used at the start.
Definition: annotations.cpp:1828
Okular::HighlightAnnotation::Quad::setPoint
void setPoint(const NormalizedPoint &point, int index)
Sets the normalized point at index.
Definition: annotations.cpp:1799
distanceSqr
static double distanceSqr(double x, double y, double xScale, double yScale, const QLinkedList< NormalizedPoint > &path)
Calculates distance of the given point x y xScale yScale to the path.
Definition: annotations.cpp:45
Okular::TextAnnotation::setTextType
void setTextType(TextType type)
Sets the text type of the text annotation.
Definition: annotations.cpp:1018
Okular::HighlightAnnotation::Quad::transform
void transform(const QTransform &matrix)
Transforms the quad coordinates with the transformation defined by matrix.
Definition: annotations.cpp:1853
Okular::Annotation::Style::yCorners
double yCorners() const
Returns the y-corners of the style.
Definition: annotations.cpp:278
Okular::InkAnnotation::InkAnnotation
InkAnnotation()
Creates a new ink annotation.
Definition: annotations.cpp:2164
Okular::Annotation::Style::setXCorners
void setXCorners(double xCorners)
Sets the x-corners of the style.
Definition: annotations.cpp:263
Okular::Annotation::subType
virtual SubType subType() const =0
Returns the sub type of the annotation.
Okular::Annotation::getAnnotationPropertiesDomNode
QDomNode getAnnotationPropertiesDomNode() const
Retrieve the QDomNode representing this annotation's properties.
Definition: annotations.cpp:801
Okular::Annotation::Style::setEffectIntensity
void setEffectIntensity(double intensity)
Sets the effect intensity of the style.
Definition: annotations.cpp:313
Okular::InkAnnotation::setInkPaths
void setInkPaths(const QList< QLinkedList< NormalizedPoint > > &paths)
Sets the paths of points for the ink annotation.
Definition: annotations.cpp:2178
Okular::Annotation::setAuthor
void setAuthor(const QString &author)
Sets the author of the annotation.
Definition: annotations.cpp:527
Okular::AnnotationPrivate::m_author
QString m_author
Definition: annotations_p.h:58
Okular::GeomAnnotation::InscribedSquare
Draw a square.
Definition: annotations.h:1022
Okular::FileAttachmentAnnotation::~FileAttachmentAnnotation
virtual ~FileAttachmentAnnotation()
Destroys the file attachment annotation.
Definition: annotations.cpp:2515
Okular::LineAnnotation::LineAnnotation
LineAnnotation()
Creates a new line annotation.
Definition: annotations.cpp:1286
action.h
annotations.h
Okular::AnnotationPrivate::m_window
Okular::Annotation::Window m_window
Definition: annotations_p.h:69
Okular::AnnotationPrivate::baseTransform
virtual void baseTransform(const QTransform &matrix)
Definition: annotations.cpp:852
isLeftOfVector
static bool isLeftOfVector(const NormalizedPoint &a, const NormalizedPoint &b, const NormalizedPoint &c)
True, if point c lies to the left of the vector from a to b.
Definition: annotations.cpp:34
caretSymbolToString
static QString caretSymbolToString(CaretAnnotation::CaretSymbol symbol)
Definition: annotations.cpp:2366
Okular::Annotation::External
Is stored external.
Definition: annotations.h:134
Okular::CaretAnnotation::~CaretAnnotation
~CaretAnnotation()
Destroys the caret annotation.
Definition: annotations.cpp:2424
Okular::Annotation::flags
int flags() const
Returns the flags of the annotation.
Definition: annotations.cpp:593
Okular::Annotation::Window::setTopLeft
void setTopLeft(const NormalizedPoint &point)
Sets the top-left point of the window.
Definition: annotations.cpp:374
Okular::HighlightAnnotation::Quad::operator=
Quad & operator=(const Quad &other)
Definition: annotations.cpp:1791
Okular::Annotation::AWidget
A widget annotation.
Definition: annotations.h:118
Okular::NormalizedRect::distanceSqr
double distanceSqr(double x, double y, double xScale, double yScale) const
Returns the distance of the point x y xScale yScale to the closest edge or 0 if the point is within t...
Definition: area.h:286
Okular::HighlightAnnotation::store
void store(QDomNode &node, QDomDocument &document) const
Stores the highlight annotation as xml in document under the given parent node.
Definition: annotations.cpp:1912
Okular::InkAnnotation::subType
SubType subType() const
Returns the sub type of the ink annotation.
Definition: annotations.cpp:2196
Okular::Annotation::Style::setLineStyle
void setLineStyle(LineStyle style)
Sets the line style of the style.
Definition: annotations.cpp:253
Okular::AnnotationUtils::storeAnnotation
static void storeAnnotation(const Annotation *annotation, QDomElement &element, QDomDocument &document)
Saves the annotation as a child of element taking care of saving all revisions if it has any...
Definition: annotations.cpp:128
Okular::Annotation::Reply
Belongs to a reply.
Definition: annotations.h:165
Okular::SoundAnnotation::setSoundIconName
void setSoundIconName(const QString &name)
Sets the name of the icon for the sound annotation.
Definition: annotations.cpp:2639
Okular::FileAttachmentAnnotation::setFileIconName
void setFileIconName(const QString &name)
Sets the name of the icon for the file attachment annotation.
Definition: annotations.cpp:2540
Okular::TextAnnotation::TextType
TextType
Describes the type of the text.
Definition: annotations.h:737
Okular::Annotation::RevisionScope
RevisionScope
Describes the scope of revision information.
Definition: annotations.h:163
Okular::Annotation::Revision::setAnnotation
void setAnnotation(Annotation *annotation)
Sets the annotation the revision belongs to.
Definition: annotations.cpp:461
Okular::Sound
Contains information about a sound object.
Definition: sound.h:26
document.h
Okular::Annotation::AInk
An ink annotation.
Definition: annotations.h:112
Okular::AnnotationPrivate::m_modifyDate
QDateTime m_modifyDate
Definition: annotations_p.h:61
Okular::StampAnnotation::~StampAnnotation
~StampAnnotation()
Destroys the stamp annotation.
Definition: annotations.cpp:2079
Okular::CaretAnnotation::subType
SubType subType() const
Returns the sub type of the caret annotation.
Definition: annotations.cpp:2440
Okular::GeomAnnotation::setGeometricalInnerColor
void setGeometricalInnerColor(const QColor &color)
Sets the inner color of the geometrical annotation.
Definition: annotations.cpp:1625
Okular::Annotation::AHighlight
A highlight annotation.
Definition: annotations.h:110
Okular::Annotation::Style::setColor
void setColor(const QColor &color)
Sets the color of the style.
Definition: annotations.cpp:223
Okular::Annotation::Style::xCorners
double xCorners() const
Returns the x-corners of the style.
Definition: annotations.cpp:268
Okular::Annotation::Revision::setScope
void setScope(RevisionScope scope)
Sets the scope of the revision.
Definition: annotations.cpp:471
Okular::InkAnnotation
Definition: annotations.h:1265
Okular::LineAnnotation::setShowCaption
void setShowCaption(bool shown)
Sets whether the caption shall be shown.
Definition: annotations.cpp:1390
Okular::NormalizedPoint::distanceSqr
double distanceSqr(double x, double y, double xScale, double yScale) const
Returns squared distance to point x y xScale yScale.
Definition: area.cpp:52
Okular::NormalizedRect::geometry
QRect geometry(int xScale, int yScale) const
Returns the rectangle that accrues when the normalized rectangle is multiplyed with the scaling xScal...
Definition: area.cpp:239
Okular::AnnotationPrivate::AnnotationPrivate
AnnotationPrivate()
Definition: annotations.cpp:492
Okular::SoundAnnotation::~SoundAnnotation
virtual ~SoundAnnotation()
Destroys the sound annotation.
Definition: annotations.cpp:2614
Okular::WidgetAnnotation::~WidgetAnnotation
virtual ~WidgetAnnotation()
Destroys the widget annotation.
Definition: annotations.cpp:2902
Okular::Annotation::NoEffect
No effect.
Definition: annotations.h:156
Okular::StampAnnotation::StampAnnotation
StampAnnotation()
Creates a new stamp annotation.
Definition: annotations.cpp:2069
Okular::TextAnnotation::setInplaceIntent
void setInplaceIntent(InplaceIntent intent)
Returns the inplace intent of the text annotation.
Definition: annotations.cpp:1093
Okular::Annotation::Style::width
double width() const
Returns the width of the style.
Definition: annotations.cpp:248
Okular::Annotation::ExternallyDrawn
Is drawn externally (by the generator which provided it)
Definition: annotations.h:135
Okular::Annotation::Revision::~Revision
~Revision()
Destroys the revision.
Definition: annotations.cpp:442
Okular::LineAnnotation::lineIntent
LineIntent lineIntent() const
Returns the line intent of the line annotation.
Definition: annotations.cpp:1408
Okular::Annotation::Style::~Style
~Style()
Destroys the style.
Definition: annotations.cpp:204
strokeDistance
static double strokeDistance(double distance, double penWidth)
Given the squared distance from the idealized 0-width line and a pen width penWidth, (not squared!), returns the final distance.
Definition: annotations.cpp:84
Okular::TextAnnotation::Linked
The annotation is linked to a text.
Definition: annotations.h:739
Okular::LineAnnotation::setLineEndStyle
void setLineEndStyle(TermStyle style)
Sets the line ending style of the line annotation.
Definition: annotations.cpp:1330
Okular::Annotation::AdditionalActionType
AdditionalActionType
Describes the type of additional actions.
Definition: annotations.h:189
Okular::NormalizedRect::top
double top
The normalized top coordinate.
Definition: area.h:310
Okular::Action
Encapsulates data that describes an action.
Definition: action.h:43
Okular::WidgetAnnotation::store
void store(QDomNode &parentNode, QDomDocument &document) const
Stores the widget annotation as xml in document under the given parentNode.
Definition: annotations.cpp:2906
Okular::AnnotationPrivate::distanceSqr
virtual double distanceSqr(double x, double y, double xScale, double yScale)
Determines the distance of the closest point of the annotation to the given point x y xScale yScale...
Definition: annotations.cpp:836
Okular::Annotation::Revision::setType
void setType(RevisionType type)
Sets the type of the revision.
Definition: annotations.cpp:481
Okular::InkAnnotation::store
void store(QDomNode &node, QDomDocument &document) const
Stores the ink annotation as xml in document under the given parent node.
Definition: annotations.cpp:2201
Okular::WidgetAnnotation::subType
SubType subType() const
Returns the sub type of the widget annotation.
Definition: annotations.cpp:2916
Okular::HighlightAnnotation::highlightQuads
QList< Quad > & highlightQuads()
Returns a reference to the quad list of the highlight annotation.
Definition: annotations.cpp:1906
Okular::LineAnnotation::setLineLeadingBackwardPoint
void setLineLeadingBackwardPoint(double point)
Sets the leading backward point of the line annotation.
Definition: annotations.cpp:1378
Okular::Annotation::window
Window & window()
Returns a reference to the window object of the annotation.
Definition: annotations.cpp:651
Okular::InkAnnotation::~InkAnnotation
~InkAnnotation()
Destroys the ink annotation.
Definition: annotations.cpp:2174
Okular::LineAnnotation::lineLeadingBackwardPoint
double lineLeadingBackwardPoint() const
Returns the leading backward point of the line annotation.
Definition: annotations.cpp:1384
Okular::LineAnnotation::transformedLinePoints
QLinkedList< NormalizedPoint > transformedLinePoints() const
Returns the transformed (e.g.
Definition: annotations.cpp:1312
Okular::AnnotationUtils::createAnnotation
static Annotation * createAnnotation(const QDomElement &element)
Restore an annotation (with revisions if needed) from the dom element.
Definition: annotations.cpp:90
Okular::TextAnnotation::setInplaceCallout
void setInplaceCallout(const NormalizedPoint &point, int index)
Sets the inplace callout point at index.
Definition: annotations.cpp:1066
Okular::LineAnnotation::LineIntent
LineIntent
Describes the line intent.
Definition: annotations.h:879
Okular::LineAnnotation::lineEndStyle
TermStyle lineEndStyle() const
Returns the line ending style of the line annotation.
Definition: annotations.cpp:1336
Okular::MovieAnnotation::movie
Movie * movie() const
Gets the movie object.
Definition: annotations.cpp:2730
Okular::HighlightAnnotation::Quad::transformedPoint
NormalizedPoint transformedPoint(int index) const
Returns the transformed (e.g.
Definition: annotations.cpp:1815
Okular::AnnotationPrivate::m_revisions
QLinkedList< Okular::Annotation::Revision > m_revisions
Definition: annotations_p.h:70
Okular::Annotation::transformedBoundingRectangle
NormalizedRect transformedBoundingRectangle() const
Returns the transformed bounding rectangle of the annotation.
Definition: annotations.cpp:616
Okular::FileAttachmentAnnotation::fileIconName
QString fileIconName() const
Gets the name of the icon.
Definition: annotations.cpp:2534
Okular::NormalizedPoint::x
double x
The normalized x coordinate.
Definition: area.h:92
Okular::AnnotationPrivate::translate
virtual void translate(const NormalizedPoint &coord)
Definition: annotations.cpp:862
document_p.h
Okular::TextAnnotation::store
void store(QDomNode &node, QDomDocument &document) const
Stores the text annotation as xml in document under the given parent node.
Definition: annotations.cpp:1110
Okular::Annotation::ACaret
A caret annotation.
Definition: annotations.h:113
Okular::Annotation::Style::spaces
int spaces() const
Returns the spaces of the style.
Definition: annotations.cpp:298
Okular::AnnotationPrivate::m_uniqueName
QString m_uniqueName
Definition: annotations_p.h:60
Okular::TextAnnotation::setTextIcon
void setTextIcon(const QString &icon)
Sets the icon of the text annotation.
Definition: annotations.cpp:1030
Okular::TextAnnotation::transformedInplaceCallout
NormalizedPoint transformedInplaceCallout(int index) const
Returns the transformed (e.g.
Definition: annotations.cpp:1084
Okular::MovieAnnotation
Movie annotation.
Definition: annotations.h:1488
Okular::ScreenAnnotation::ScreenAnnotation
ScreenAnnotation()
Creates a new screen annotation.
Definition: annotations.cpp:2791
Okular::Annotation::Style::setMarks
void setMarks(int marks)
Sets the marks of the style.
Definition: annotations.cpp:283
Okular::Annotation::Revision::operator=
Revision & operator=(const Revision &other)
Definition: annotations.cpp:453
Okular::TextAnnotation::inplaceAlignment
int inplaceAlignment() const
Returns the inplace alignment of the text annotation.
Definition: annotations.cpp:1060
Okular::Annotation::setCreationDate
void setCreationDate(const QDateTime &date)
Sets the creation date of the annotation.
Definition: annotations.cpp:575
Okular::ScreenAnnotation::setAdditionalAction
void setAdditionalAction(AdditionalActionType type, Action *action)
Sets the additional action of the given type.
Definition: annotations.cpp:2820
Okular::Annotation
Annotation struct holds properties shared by all annotations.
Definition: annotations.h:90
Okular::LineAnnotation::setLinePoints
void setLinePoints(const QLinkedList< NormalizedPoint > &points)
Sets the normalized line points of the line annotation.
Definition: annotations.cpp:1300
Okular::Annotation::Window::setHeight
void setHeight(int height)
Sets the height of the window.
Definition: annotations.cpp:394
Okular::Annotation::Style::effectIntensity
double effectIntensity() const
Returns the effect intensity of the style.
Definition: annotations.cpp:318
Okular::LineAnnotation::setLineLeadingForwardPoint
void setLineLeadingForwardPoint(double point)
Sets the leading forward point of the line annotation.
Definition: annotations.cpp:1366
Okular::Annotation::Solid
A solid line.
Definition: annotations.h:144
Okular::HighlightAnnotation::Highlight
Highlights the text.
Definition: annotations.h:1086
Okular::Annotation::LineStyle
LineStyle
Describes possible line styles for.
Definition: annotations.h:142
Okular::Annotation::Window::setSummary
void setSummary(const QString &summary)
Sets the summary of the window.
Definition: annotations.cpp:414
Okular::HighlightAnnotation::~HighlightAnnotation
~HighlightAnnotation()
Destroys the highlight annotation.
Definition: annotations.cpp:1890
Okular::InkAnnotation::inkPaths
QList< QLinkedList< NormalizedPoint > > inkPaths() const
Returns the paths of points of the ink annotation.
Definition: annotations.cpp:2184
Okular::LineAnnotation::Unknown
Unknown intent.
Definition: annotations.h:881
Okular::LineAnnotation::subType
SubType subType() const
Returns the sub type of the line annotation.
Definition: annotations.cpp:1414
Okular::Annotation::revisions
QLinkedList< Revision > & revisions()
Returns a reference to the revision list of the annotation.
Definition: annotations.cpp:663
Okular::Annotation::Window::~Window
~Window()
Destroys the window.
Definition: annotations.cpp:345
Okular::Annotation::store
virtual void store(QDomNode &node, QDomDocument &document) const
Stores the annotation as xml in document under the given parent node.
Definition: annotations.cpp:708
Okular::Annotation::Style
The Style class contains all information about style of the annotation.
Definition: annotations.h:305
Okular::AnnotationPrivate::transform
virtual void transform(const QTransform &matrix)
Definition: annotations.cpp:847
Okular::Annotation::Style::Style
Style()
Creates a new style.
Definition: annotations.cpp:199
Okular::Annotation::uniqueName
QString uniqueName() const
Returns the unique name of the annotation.
Definition: annotations.cpp:557
Okular::Annotation::~Annotation
virtual ~Annotation()
Destroys the annotation.
Definition: annotations.cpp:519
Okular::Annotation::Style::lineEffect
LineEffect lineEffect() const
Returns the line effect of the style.
Definition: annotations.cpp:308
Okular::TextAnnotation::TextAnnotation
TextAnnotation()
Creates a new text annotation.
Definition: annotations.cpp:1004
Okular::Annotation::Window::title
QString title() const
Returns the title of the window.
Definition: annotations.cpp:409
Okular::FileAttachmentAnnotation::embeddedFile
EmbeddedFile * embeddedFile() const
Gets the embedded file object.
Definition: annotations.cpp:2546
Okular::Annotation::Style::operator=
Style & operator=(const Style &other)
Definition: annotations.cpp:215
Okular::HighlightAnnotation::Quad::point
NormalizedPoint point(int index) const
Returns the normalized point at index.
Definition: annotations.cpp:1807
Okular::NormalizedRect::bottom
double bottom
The normalized bottom coordinate.
Definition: area.h:320
Okular::Annotation::contents
QString contents() const
Returns the contents of the annotation.
Definition: annotations.cpp:545
Okular::MovieAnnotation::~MovieAnnotation
virtual ~MovieAnnotation()
Destroys the movie annotation.
Definition: annotations.cpp:2711
Okular::TextAnnotation::setInplaceAlignment
void setInplaceAlignment(int alignment)
Sets the inplace alignment of the text annotation.
Definition: annotations.cpp:1054
Okular::Annotation::Style::lineStyle
LineStyle lineStyle() const
Returns the line style of the style.
Definition: annotations.cpp:258
Okular::MovieAnnotation::MovieAnnotation
MovieAnnotation()
Creates a new movie annotation.
Definition: annotations.cpp:2701
Okular::Annotation::Window::operator=
Window & operator=(const Window &other)
Definition: annotations.cpp:356
Okular::TextAnnotation
Definition: annotations.h:731
Okular::TextAnnotation::subType
SubType subType() const
Returns the sub type of the text annotation.
Definition: annotations.cpp:1105
Okular::HighlightAnnotation::Quad::setFeather
void setFeather(double width)
Sets the width of the drawing feather.
Definition: annotations.cpp:1843
movie.h
Okular::HighlightAnnotation::HighlightAnnotation
HighlightAnnotation()
Creates a new highlight annotation.
Definition: annotations.cpp:1880
Okular::Annotation::ASound
A sound annotation.
Definition: annotations.h:115
Okular::ScreenAnnotation::~ScreenAnnotation
virtual ~ScreenAnnotation()
Destroys the screen annotation.
Definition: annotations.cpp:2801
Okular::Annotation::Window::setTitle
void setTitle(const QString &title)
Sets the title of the window.
Definition: annotations.cpp:404
Okular::ScreenAnnotation
Screen annotation.
Definition: annotations.h:1534
Okular::FileAttachmentAnnotation::setEmbeddedFile
void setEmbeddedFile(EmbeddedFile *object)
Sets the object representing the embedded file of the file attachment annotation. ...
Definition: annotations.cpp:2552
Okular::Annotation::Revision::annotation
Annotation * annotation() const
Returns the annotation the revision belongs to.
Definition: annotations.cpp:466
Okular::Annotation::canBeMoved
bool canBeMoved() const
Returns whether the annotation can be moved.
Definition: annotations.cpp:693
Okular::Annotation::LineEffect
LineEffect
Describes possible line effects for.
Definition: annotations.h:154
Okular::CaretAnnotation::None
No symbol to be associated with the text.
Definition: annotations.h:1323
Okular::HighlightAnnotation::Quad::feather
double feather() const
Returns the width of the drawing feather.
Definition: annotations.cpp:1848
Okular::Annotation::boundingRectangle
NormalizedRect boundingRectangle() const
Returns the bounding rectangle of the annotation.
Definition: annotations.cpp:610
Okular::AnnotationPrivate::m_creationDate
QDateTime m_creationDate
Definition: annotations_p.h:62
Okular::Annotation::Revision::scope
RevisionScope scope() const
Returns the scope of the revision.
Definition: annotations.cpp:476
Okular::HighlightAnnotation::Quad
The Quad class contains 8 coordinates and style definitions which describe a line part of the whole h...
Definition: annotations.h:1122
Okular::StampAnnotation::store
void store(QDomNode &node, QDomDocument &document) const
Stores the stamp annotation as xml in document under the given parent node.
Definition: annotations.cpp:2100
Okular::Annotation::setBoundingRectangle
void setBoundingRectangle(const NormalizedRect &rectangle)
Sets the bounding rectangle of the annotation.
Definition: annotations.cpp:599
Okular::CaretAnnotation::caretSymbol
CaretAnnotation::CaretSymbol caretSymbol() const
Returns the symbol of the annotation.
Definition: annotations.cpp:2434
Okular::WidgetAnnotation
Widget annotation.
Definition: annotations.h:1603
Okular::Movie
Contains information about a movie object.
Definition: movie.h:28
Okular::Annotation::Window::Window
Window()
Creates a new window.
Definition: annotations.cpp:340
Okular::Annotation::openDialogAfterCreation
bool openDialogAfterCreation() const
Returns whether the annotation dialog should be open after creation of the annotation or not...
Definition: annotations.cpp:633
Okular::Annotation::Window::topLeft
NormalizedPoint topLeft() const
Returns the top-left point of the window.
Definition: annotations.cpp:379
Okular::GeomAnnotation::store
void store(QDomNode &node, QDomDocument &document) const
Stores the geometrical annotation as xml in document under the given parent node. ...
Definition: annotations.cpp:1642
Okular::Annotation::setAnnotationProperties
void setAnnotationProperties(const QDomNode &node)
Sets annotations internal properties according to the contents of node.
Definition: annotations.cpp:810
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:45:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal