Rotate annotation to match page when setting annotation's properties

BUG:318828
REVIEW:110229
remotes/origin/epub-qtextdoc
Jon Mease 13 years ago committed by Albert Astals Cid
parent 36b445e5c0
commit 4296ac7e5d
  1. 3
      core/annotations.cpp
  2. 30
      tests/modifyannotationpropertiestest.cpp

@ -782,6 +782,9 @@ void Annotation::setAnnotationProperties( const QDomNode& node )
d_ptr->m_nativeId = nativeID;
d_ptr->m_flags = d_ptr->m_flags | internalFlags;
d_ptr->m_disposeFunc = disposeFunc;
// Transform annotation to current page rotation
d_ptr->transform( d_ptr->m_page->rotationMatrix() );
}
void AnnotationPrivate::annotationTransform( const QTransform &matrix )

@ -30,6 +30,7 @@ private slots:
void cleanup();
void testModifyAnnotationProperties();
void testModifyDefaultAnnotationProperties();
void testModifyAnnotationPropertiesWithRotation_Bug318828();
private:
Okular::Document *m_document;
Okular::TextAnnotation *m_annot1;
@ -134,5 +135,34 @@ void ModifyAnnotationPropertiesTest::testModifyDefaultAnnotationProperties()
QCOMPARE( origLine1Xml, TestingUtils::getAnnotationXml( m_annot1 ) );
}
void ModifyAnnotationPropertiesTest::testModifyAnnotationPropertiesWithRotation_Bug318828()
{
Okular::NormalizedRect boundingRect = Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 );
Okular::NormalizedRect transformedBoundingRect;
m_annot1->setBoundingRectangle( boundingRect );
m_document->addPageAnnotation( 0, m_annot1 );
transformedBoundingRect = m_annot1->transformedBoundingRectangle();
// Before page rotation boundingRect and transformedBoundingRect should be equal
QCOMPARE( boundingRect, transformedBoundingRect );
m_document->setRotation( 1 );
// After rotation boundingRect should remain unchanged but
// transformedBoundingRect should no longer equal boundingRect
QCOMPARE( boundingRect, m_annot1->boundingRectangle() );
transformedBoundingRect = m_annot1->transformedBoundingRectangle();
QVERIFY( !( boundingRect == transformedBoundingRect ) );
// Modifying the properties of m_annot1 while page is rotated shouldn't
// alter either boundingRect or transformedBoundingRect
m_document->prepareToModifyAnnotationProperties( m_annot1 );
m_annot1->style().setOpacity( 0.5 );
m_document->modifyPageAnnotationProperties( 0, m_annot1 );
QCOMPARE( boundingRect, m_annot1->boundingRectangle() );
QCOMPARE( transformedBoundingRect, m_annot1->transformedBoundingRectangle() );
}
QTEST_KDEMAIN( ModifyAnnotationPropertiesTest, GUI )
#include "modifyannotationpropertiestest.moc"

Loading…
Cancel
Save