SVN_SILENT made messages (.desktop file)
[kdegraphics.git] / okular / generators / dvi / simplePageSize.cpp
blob3a2fe92ab23d653d375d83281a2142eda95a75d0
1 // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*-
2 // SimplePageSize.cpp
3 //
4 // Part of KVIEWSHELL - A framework for multipage text/gfx viewers
5 //
6 // (C) 2002-2005 Stefan Kebekus
7 // Distributed under the GPL
9 #include <config.h>
11 #include "simplePageSize.h"
12 #include "kvs_debug.h"
14 #include <QPaintDevice>
17 double SimplePageSize::zoomForHeight(quint32 height, const QPaintDevice& pd) const
19 if (!isValid()) {
20 kError(kvs::shell) << "SimplePageSize::zoomForHeight() called when paper height was invalid" << endl;
21 return 0.1;
24 return double(height) / (pd.logicalDpiY() * pageHeight.getLength_in_inch());
28 double SimplePageSize::zoomForWidth(quint32 width, const QPaintDevice& pd) const
30 if (!isValid()) {
31 kError(kvs::shell) << "SimplePageSize::zoomForWidth() called when paper width was invalid" << endl;
32 return 0.1;
35 return double(width) / (pd.logicalDpiX() * pageWidth.getLength_in_inch());
39 double SimplePageSize::zoomToFitInto(const SimplePageSize &target) const
41 if (!isValid() || isSmall() || !target.isValid()) {
42 kWarning(kvs::shell) << "SimplePageSize::zoomToFitInto(...) with unsuitable source of target" ;
43 return 1.0;
46 double z1 = target.width() / pageWidth;
47 double z2 = target.height() / pageHeight;
49 return qMin(z1,z2);