2006-06-29 21:12:47 +00:00
|
|
|
// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*-
|
|
|
|
// SimplePageSize.cpp
|
|
|
|
//
|
|
|
|
// Part of KVIEWSHELL - A framework for multipage text/gfx viewers
|
|
|
|
//
|
|
|
|
// (C) 2002-2005 Stefan Kebekus
|
|
|
|
// Distributed under the GPL
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2014-09-11 19:12:27 +00:00
|
|
|
#include "debug_dvi.h"
|
2006-06-29 21:12:47 +00:00
|
|
|
#include "simplePageSize.h"
|
|
|
|
|
2018-08-31 09:23:45 +00:00
|
|
|
#include <QLoggingCategory>
|
2006-06-29 21:12:47 +00:00
|
|
|
#include <QPaintDevice>
|
|
|
|
|
|
|
|
double SimplePageSize::zoomForHeight(quint32 height, const QPaintDevice &pd) const
|
|
|
|
{
|
|
|
|
if (!isValid()) {
|
2014-09-11 19:12:27 +00:00
|
|
|
qCCritical(OkularDviShellDebug) << "SimplePageSize::zoomForHeight() called when paper height was invalid" << endl;
|
2006-06-29 21:12:47 +00:00
|
|
|
return 0.1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return double(height) / (pd.logicalDpiY() * pageHeight.getLength_in_inch());
|
|
|
|
}
|
|
|
|
|
|
|
|
double SimplePageSize::zoomForWidth(quint32 width, const QPaintDevice &pd) const
|
|
|
|
{
|
|
|
|
if (!isValid()) {
|
2014-09-11 19:12:27 +00:00
|
|
|
qCCritical(OkularDviShellDebug) << "SimplePageSize::zoomForWidth() called when paper width was invalid" << endl;
|
2006-06-29 21:12:47 +00:00
|
|
|
return 0.1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return double(width) / (pd.logicalDpiX() * pageWidth.getLength_in_inch());
|
|
|
|
}
|
|
|
|
|
|
|
|
double SimplePageSize::zoomToFitInto(const SimplePageSize &target) const
|
|
|
|
{
|
|
|
|
if (!isValid() || isSmall() || !target.isValid()) {
|
2014-09-11 19:12:27 +00:00
|
|
|
qCWarning(OkularDviShellDebug) << "SimplePageSize::zoomToFitInto(...) with unsuitable source of target";
|
2006-06-29 21:12:47 +00:00
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
double z1 = target.width() / pageWidth;
|
|
|
|
double z2 = target.height() / pageHeight;
|
|
|
|
|
|
|
|
return qMin(z1, z2);
|
|
|
|
}
|