kviewshell
simplePageSize.cpp
Go to the documentation of this file.00001 // SimplePageSize.cpp 00002 // 00003 // Part of KVIEWSHELL - A framework for multipage text/gfx viewers 00004 // 00005 // (C) 2002-2005 Stefan Kebekus 00006 // Distributed under the GPL 00007 00008 // Add header files alphabetically 00009 00010 #include <config.h> 00011 00012 #include <kdebug.h> 00013 #include <qpaintdevice.h> 00014 00015 #include "simplePageSize.h" 00016 00017 00018 double SimplePageSize::zoomForHeight(Q_UINT32 height) const 00019 { 00020 if (!isValid()) { 00021 kdError(1223) << "SimplePageSize::zoomForHeight() called when paper height was invalid" << endl; 00022 return 0.1; 00023 } 00024 return (double)(height)/(QPaintDevice::x11AppDpiY()*(pageHeight.getLength_in_inch())); 00025 } 00026 00027 00028 double SimplePageSize::zoomForWidth(Q_UINT32 width) const 00029 { 00030 if (!isValid()) { 00031 kdError(1223) << "SimplePageSize::zoomForWidth() called when paper width was invalid" << endl; 00032 return 0.1; 00033 } 00034 return (double)(width)/(QPaintDevice::x11AppDpiX()*(pageWidth.getLength_in_inch())); 00035 } 00036 00037 00038 double SimplePageSize::zoomToFitInto(const SimplePageSize &target) const 00039 { 00040 if (!isValid() || isSmall() || !target.isValid()) { 00041 kdWarning(1223) << "SimplePageSize::zoomToFitInto(...) with unsuitable source of target" << endl; 00042 return 1.0; 00043 } 00044 00045 double z1 = target.width() / pageWidth; 00046 double z2 = target.height() / pageHeight; 00047 00048 return QMIN(z1,z2); 00049 }