Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit d6e90c64 authored by Stefan Nikolaus's avatar Stefan Nikolaus

Zooming Add conversion methods for sizes.

svn path=/trunk/koffice/; revision=658698
parent 9e36083d
......@@ -59,6 +59,20 @@ public:
*/
virtual QRectF viewToDocument( const QRectF &viewRect ) const = 0;
/**
* Convert a size in pt to pixels.
* @param documentSize the size in pt.
* @return the size in pixels.
*/
virtual QSizeF documentToView( const QSizeF& documentSize ) const = 0;
/**
* Convert a size in pixels to pt.
* @param viewSize the size in pixels.
* @return the size in pt.
*/
virtual QSizeF viewToDocument( const QSizeF& viewSize ) const = 0;
/**
* Convert a single x coordinate in pt to pixels.
* @param documentX the x coordinate in pt.
......
......@@ -65,6 +65,8 @@ class MockViewConverter : public KoViewConverter {
QPointF viewToDocument( const QPointF &viewPoint ) const { return viewPoint; }
QRectF documentToView( const QRectF &documentRect ) const { return documentRect; }
QRectF viewToDocument( const QRectF &viewRect ) const { return viewRect; }
QSizeF documentToView( const QSizeF& documentSize ) const { return documentSize; }
QSizeF viewToDocument( const QSizeF& viewSize ) const { return viewSize; }
double documentToViewX( double documentX ) const { return documentX; }
double documentToViewY( double documentY ) const{ return documentY; }
double viewToDocumentX( double viewX ) const { return viewX; }
......
......@@ -76,9 +76,7 @@ void KoZoomController::setPageSize(const QSizeF &pageSize)
void KoZoomController::setDocumentSize( const QSizeF &documentSize )
{
m_documentSize = documentSize;
m_canvasController->setDocumentSize(
QSize( int(0.5 + m_zoomHandler->documentToViewX(m_documentSize.width())),
int(0.5 + m_zoomHandler->documentToViewY(m_documentSize.height())) ) );
m_canvasController->setDocumentSize( m_zoomHandler->documentToView(m_documentSize).toSize() );
}
void KoZoomController::setZoom(KoZoomMode::Mode mode, double zoom)
......
......@@ -116,6 +116,16 @@ QRectF KoZoomHandler::viewToDocument( const QRectF &viewRect ) const{
return r;
}
QSizeF KoZoomHandler::documentToView( const QSizeF &documentSize ) const {
return QSizeF( zoomItX( documentSize.width() ),
zoomItY( documentSize.height() ) );
}
QSizeF KoZoomHandler::viewToDocument( const QSizeF &viewSize ) const {
return QSizeF( unzoomItX( viewSize.width() ),
unzoomItY( viewSize.height() ) );
}
double KoZoomHandler::documentToViewX( double documentX ) const
{
return zoomItX( documentX );
......
......@@ -209,6 +209,20 @@ public:
*/
QRectF viewToDocument( const QRectF &viewRect ) const;
/**
* Convert a size in pt to pixels.
* @param documentSize the size in pt.
* @return the size in pixels.
*/
virtual QSizeF documentToView( const QSizeF& documentSize ) const;
/**
* Convert a size in pixels to pt.
* @param viewSize the size in pixels.
* @return the size in pt.
*/
virtual QSizeF viewToDocument( const QSizeF& viewSize ) const;
/**
* Convert a single x coordinate in pt to pixels.
* @param documentX the x coordinate in pt.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment