From 47d455dd55be855e4cc691c32f687f723d9247ee Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kviewshell/simplePageSize.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 kviewshell/simplePageSize.cpp (limited to 'kviewshell/simplePageSize.cpp') diff --git a/kviewshell/simplePageSize.cpp b/kviewshell/simplePageSize.cpp new file mode 100644 index 00000000..cc235ef8 --- /dev/null +++ b/kviewshell/simplePageSize.cpp @@ -0,0 +1,49 @@ +// SimplePageSize.cpp +// +// Part of KVIEWSHELL - A framework for multipage text/gfx viewers +// +// (C) 2002-2005 Stefan Kebekus +// Distributed under the GPL + +// Add header files alphabetically + +#include + +#include +#include + +#include "simplePageSize.h" + + +double SimplePageSize::zoomForHeight(Q_UINT32 height) const +{ + if (!isValid()) { + kdError(1223) << "SimplePageSize::zoomForHeight() called when paper height was invalid" << endl; + return 0.1; + } + return (double)(height)/(QPaintDevice::x11AppDpiY()*(pageHeight.getLength_in_inch())); +} + + +double SimplePageSize::zoomForWidth(Q_UINT32 width) const +{ + if (!isValid()) { + kdError(1223) << "SimplePageSize::zoomForWidth() called when paper width was invalid" << endl; + return 0.1; + } + return (double)(width)/(QPaintDevice::x11AppDpiX()*(pageWidth.getLength_in_inch())); +} + + +double SimplePageSize::zoomToFitInto(const SimplePageSize &target) const +{ + if (!isValid() || isSmall() || !target.isValid()) { + kdWarning(1223) << "SimplePageSize::zoomToFitInto(...) with unsuitable source of target" << endl; + return 1.0; + } + + double z1 = target.width() / pageWidth; + double z2 = target.height() / pageHeight; + + return QMIN(z1,z2); +} -- cgit v1.2.3