From 94355bce657c4de09f8923267a25aab9e06a2ea8 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Fri, 4 May 2007 20:45:45 +0000 Subject: [PATCH] move the transform() hierarchy within the private class; allow AnnotationObjectRect to use the trasform() stuff svn path=/trunk/KDE/kdegraphics/okular/; revision=661202 --- core/annotations.cpp | 62 ++++++++++++++++++++------------------------ core/annotations.h | 45 +++----------------------------- core/annotations_p.h | 8 ++++++ core/area.cpp | 3 ++- 4 files changed, 41 insertions(+), 77 deletions(-) diff --git a/core/annotations.cpp b/core/annotations.cpp index 24fbbe8d5..c84405600 100644 --- a/core/annotations.cpp +++ b/core/annotations.cpp @@ -783,11 +783,10 @@ void Annotation::store( QDomNode & annNode, QDomDocument & document ) const } } -void Annotation::transform( const QMatrix &matrix ) +void AnnotationPrivate::transform( const QMatrix &matrix ) { - Q_D( Annotation ); - d->m_transformedBoundary = d->m_boundary; - d->m_transformedBoundary.transform( matrix ); + m_transformedBoundary = m_boundary; + m_transformedBoundary.transform( matrix ); } //END Annotation implementation @@ -805,6 +804,8 @@ class Okular::TextAnnotationPrivate : public Okular::AnnotationPrivate { } + virtual void transform( const QMatrix &matrix ); + TextAnnotation::TextType m_textType; QString m_textIcon; QFont m_textFont; @@ -1031,14 +1032,13 @@ void TextAnnotation::store( QDomNode & node, QDomDocument & document ) const } } -void TextAnnotation::transform( const QMatrix &matrix ) +void TextAnnotationPrivate::transform( const QMatrix &matrix ) { - Q_D( TextAnnotation ); - Annotation::transform( matrix ); + AnnotationPrivate::transform( matrix ); for ( int i = 0; i < 3; ++i ) { - d->m_transformedInplaceCallout[i] = d->m_inplaceCallout[i]; - d->m_transformedInplaceCallout[i].transform( matrix ); + m_transformedInplaceCallout[i] = m_inplaceCallout[i]; + m_transformedInplaceCallout[i].transform( matrix ); } } @@ -1055,6 +1055,8 @@ class Okular::LineAnnotationPrivate : public Okular::AnnotationPrivate { } + virtual void transform( const QMatrix &matrix ); + QLinkedList m_linePoints; QLinkedList m_transformedLinePoints; LineAnnotation::TermStyle m_lineStartStyle; @@ -1294,14 +1296,13 @@ void LineAnnotation::store( QDomNode & node, QDomDocument & document ) const } } -void LineAnnotation::transform( const QMatrix &matrix ) +void LineAnnotationPrivate::transform( const QMatrix &matrix ) { - Q_D( LineAnnotation ); - Annotation::transform( matrix ); + AnnotationPrivate::transform( matrix ); - d->m_transformedLinePoints = d->m_linePoints; + m_transformedLinePoints = m_linePoints; - QMutableLinkedListIterator it( d->m_transformedLinePoints ); + QMutableLinkedListIterator it( m_transformedLinePoints ); while ( it.hasNext() ) it.next().transform( matrix ); } @@ -1417,11 +1418,6 @@ void GeomAnnotation::store( QDomNode & node, QDomDocument & document ) const geomElement.setAttribute( "width", d->m_geomWidthPt ); } -void GeomAnnotation::transform( const QMatrix &matrix ) -{ - Annotation::transform( matrix ); -} - /** HighlightAnnotation [Annotation] */ class HighlightAnnotation::Quad::Private @@ -1533,6 +1529,8 @@ class Okular::HighlightAnnotationPrivate : public Okular::AnnotationPrivate { } + virtual void transform( const QMatrix &matrix ); + HighlightAnnotation::HighlightType m_highlightType; QList< HighlightAnnotation::Quad > m_highlightQuads; }; @@ -1651,12 +1649,11 @@ Annotation::SubType HighlightAnnotation::subType() const return AHighlight; } -void HighlightAnnotation::transform( const QMatrix &matrix ) +void HighlightAnnotationPrivate::transform( const QMatrix &matrix ) { - Q_D( HighlightAnnotation ); - Annotation::transform( matrix ); + AnnotationPrivate::transform( matrix ); - QMutableListIterator it( d->m_highlightQuads ); + QMutableListIterator it( m_highlightQuads ); while ( it.hasNext() ) it.next().transform( matrix ); } @@ -1737,11 +1734,6 @@ void StampAnnotation::store( QDomNode & node, QDomDocument & document ) const stampElement.setAttribute( "icon", d->m_stampIconName ); } -void StampAnnotation::transform( const QMatrix &matrix ) -{ - Annotation::transform( matrix ); -} - /** InkAnnotation [Annotation] */ class Okular::InkAnnotationPrivate : public Okular::AnnotationPrivate @@ -1752,6 +1744,8 @@ class Okular::InkAnnotationPrivate : public Okular::AnnotationPrivate { } + virtual void transform( const QMatrix &matrix ); + QList< QLinkedList > m_inkPaths; QList< QLinkedList > m_transformedInkPaths; }; @@ -1872,15 +1866,15 @@ void InkAnnotation::store( QDomNode & node, QDomDocument & document ) const } } -void InkAnnotation::transform( const QMatrix &matrix ) +void InkAnnotationPrivate::transform( const QMatrix &matrix ) { - Q_D( InkAnnotation ); - Annotation::transform( matrix ); + AnnotationPrivate::transform( matrix ); - d->m_transformedInkPaths = d->m_inkPaths; + m_transformedInkPaths = m_inkPaths; - for ( int i = 0; i < d->m_transformedInkPaths.count(); ++i ) { - QMutableLinkedListIterator it( d->m_transformedInkPaths[ i ] ); + for ( int i = 0; i < m_transformedInkPaths.count(); ++i ) + { + QMutableLinkedListIterator it( m_transformedInkPaths[ i ] ); while ( it.hasNext() ) it.next().transform( matrix ); } diff --git a/core/annotations.h b/core/annotations.h index 5339d29b6..db52a1dc3 100644 --- a/core/annotations.h +++ b/core/annotations.h @@ -24,6 +24,7 @@ namespace Okular { class Annotation; +class AnnotationObjectRect; class AnnotationPrivate; class TextAnnotationPrivate; class LineAnnotationPrivate; @@ -78,6 +79,8 @@ class OKULAR_EXPORT AnnotationUtils */ class OKULAR_EXPORT Annotation { + friend class AnnotationObjectRect; + public: /** * Describes the type of annotation as defined in PDF standard. @@ -559,12 +562,6 @@ class OKULAR_EXPORT Annotation */ virtual void store( QDomNode & node, QDomDocument & document ) const; - /** - * Transforms the annotation coordinates with the transformation defined - * by @p matrix. - */ - virtual void transform( const QMatrix &matrix ); - protected: Annotation( AnnotationPrivate &dd ); Annotation( AnnotationPrivate &dd, const QDomNode &description ); @@ -705,12 +702,6 @@ class OKULAR_EXPORT TextAnnotation : public Annotation */ void store( QDomNode &node, QDomDocument &document ) const; - /** - * Transforms the text annotation coordinates with the transformation defined - * by @p matrix. - */ - virtual void transform( const QMatrix &matrix ); - private: Q_DECLARE_PRIVATE( TextAnnotation ) Q_DISABLE_COPY( TextAnnotation ) @@ -871,12 +862,6 @@ class OKULAR_EXPORT LineAnnotation : public Annotation */ void store( QDomNode &node, QDomDocument &document ) const; - /** - * Transforms the line annotation coordinates with the transformation defined - * by @p matrix. - */ - virtual void transform( const QMatrix &matrix ); - private: Q_DECLARE_PRIVATE( LineAnnotation ) Q_DISABLE_COPY( LineAnnotation ) @@ -949,12 +934,6 @@ class OKULAR_EXPORT GeomAnnotation : public Annotation */ void store( QDomNode &node, QDomDocument &document ) const; - /** - * Transforms the geometrical annotation coordinates with the transformation defined - * by @p matrix. - */ - virtual void transform( const QMatrix &matrix ); - private: Q_DECLARE_PRIVATE( GeomAnnotation ) Q_DISABLE_COPY( GeomAnnotation ) @@ -1098,12 +1077,6 @@ class OKULAR_EXPORT HighlightAnnotation : public Annotation */ void store( QDomNode &node, QDomDocument &document ) const; - /** - * Transforms the highlight annotation coordinates with the transformation defined - * by @p matrix. - */ - virtual void transform( const QMatrix &matrix ); - private: Q_DECLARE_PRIVATE( HighlightAnnotation ) Q_DISABLE_COPY( HighlightAnnotation ) @@ -1148,12 +1121,6 @@ class OKULAR_EXPORT StampAnnotation : public Annotation */ void store( QDomNode &node, QDomDocument &document ) const; - /** - * Transforms the stamp annotation coordinates with the transformation defined - * by @p matrix. - */ - virtual void transform( const QMatrix &matrix ); - private: Q_DECLARE_PRIVATE( StampAnnotation ) Q_DISABLE_COPY( StampAnnotation ) @@ -1204,12 +1171,6 @@ class OKULAR_EXPORT InkAnnotation : public Annotation */ void store( QDomNode &node, QDomDocument &document ) const; - /** - * Transforms the ink annotation coordinates with the transformation defined - * by @p matrix. - */ - virtual void transform( const QMatrix &matrix ); - private: Q_DECLARE_PRIVATE( InkAnnotation ) Q_DISABLE_COPY( InkAnnotation ) diff --git a/core/annotations_p.h b/core/annotations_p.h index 58199b968..ec628354d 100644 --- a/core/annotations_p.h +++ b/core/annotations_p.h @@ -18,6 +18,8 @@ #include #include +class QMatrix; + namespace Okular { class AnnotationPrivate @@ -27,6 +29,12 @@ class AnnotationPrivate virtual ~AnnotationPrivate(); + /** + * Transforms the annotation coordinates with the transformation + * defined by @p matrix. + */ + virtual void transform( const QMatrix &matrix ); + QString m_author; QString m_contents; QString m_uniqueName; diff --git a/core/area.cpp b/core/area.cpp index adb130988..add29a9e2 100644 --- a/core/area.cpp +++ b/core/area.cpp @@ -16,6 +16,7 @@ #include "action.h" #include "annotations.h" +#include "annotations_p.h" #include "sourcereference.h" using namespace Okular; @@ -297,7 +298,7 @@ AnnotationObjectRect::~AnnotationObjectRect() void AnnotationObjectRect::transform( const QMatrix &matrix ) { - m_annotation->transform( matrix ); + m_annotation->d_func()->transform( matrix ); } /** class SourceRefObjectRect **/