浏览代码

Update style in source files

Jakob Truelsen 15 年之前
父节点
当前提交
1a4348b8ad
共有 63 个文件被更改,包括 857 次插入521 次删除
  1. 18 1
      common.pri
  2. 18 1
      scripts/release.sh
  3. 9 3
      scripts/sourcefix.py
  4. 10 7
      scripts/static-build.sh
  5. 15 12
      scripts/test.sh
  6. 21 3
      scripts/upload.sh
  7. 9 5
      src/image/arguments.cc
  8. 12 8
      src/image/commandlineparser.cc
  9. 10 5
      src/image/commandlineparser.hh
  10. 7 4
      src/image/docparts.cc
  11. 17 2
      src/image/image.pro
  12. 27 23
      src/image/imageconverter.cc
  13. 5 1
      src/image/imageconverter.hh
  14. 11 7
      src/image/imageconverter_p.hh
  15. 4 0
      src/image/settings.cc
  16. 8 4
      src/image/settings.hh
  17. 8 3
      src/image/wkhtmltoimage.cc
  18. 17 14
      src/pdf/arguments.cc
  19. 19 16
      src/pdf/commandlineparser.cc
  20. 15 11
      src/pdf/commandlineparser.hh
  21. 12 7
      src/pdf/docparts.cc
  22. 35 32
      src/pdf/outline.cc
  23. 5 1
      src/pdf/outline.hh
  24. 7 0
      src/pdf/outline_p.hh
  25. 17 2
      src/pdf/pdf.pro
  26. 85 82
      src/pdf/pdfconverter.cc
  27. 8 4
      src/pdf/pdfconverter.hh
  28. 15 10
      src/pdf/pdfconverter_p.hh
  29. 16 14
      src/pdf/settings.cc
  30. 27 23
      src/pdf/settings.hh
  31. 21 16
      src/pdf/tocprinter.cc
  32. 7 2
      src/pdf/tocprinter.hh
  33. 5 2
      src/pdf/tocstylesheet.cc
  34. 10 5
      src/pdf/wkhtmltopdf.cc
  35. 6 2
      src/shared/arghandler.cc
  36. 14 5
      src/shared/arghandler.inl
  37. 16 11
      src/shared/commandlineparserbase.cc
  38. 14 9
      src/shared/commandlineparserbase.hh
  39. 21 16
      src/shared/commonarguments.cc
  40. 4 0
      src/shared/commondocparts.cc
  41. 6 2
      src/shared/converter.cc
  42. 5 1
      src/shared/converter.hh
  43. 11 8
      src/shared/converter_p.hh
  44. 14 10
      src/shared/htmloutputter.cc
  45. 11 7
      src/shared/loadsettings.cc
  46. 19 15
      src/shared/loadsettings.hh
  47. 16 12
      src/shared/manoutputter.cc
  48. 26 22
      src/shared/multipageloader.cc
  49. 4 0
      src/shared/multipageloader.hh
  50. 11 4
      src/shared/multipageloader_p.hh
  51. 7 3
      src/shared/outputter.cc
  52. 6 3
      src/shared/outputter.hh
  53. 11 7
      src/shared/progressfeedback.cc
  54. 4 0
      src/shared/progressfeedback.hh
  55. 17 1
      src/shared/shared.pri
  56. 9 4
      src/shared/tempfile.cc
  57. 6 2
      src/shared/tempfile.hh
  58. 33 29
      src/shared/textoutputter.cc
  59. 9 4
      src/shared/utilities.cc
  60. 9 6
      src/shared/utilities.hh
  61. 4 0
      src/shared/websettings.cc
  62. 12 8
      src/shared/websettings.hh
  63. 2 0
      wkhtmltopdf.pro

+ 18 - 1
common.pri

@@ -1,3 +1,20 @@
+# Copyright 2010 wkhtmltopdf authors
+#
+# This file is part of wkhtmltopdf.
+#
+# wkhtmltopdf is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# wkhtmltopdf is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with wkhtmltopdf.  If not, see <http:#www.gnu.org/licenses/>.
+
 unix {
     TEMP = $$[QT_INSTALL_LIBS] libQtGui.prl
     PRL  = $$[QT_INSTALL_LIBS] QtGui.framework/QtGui.prl
@@ -6,7 +23,7 @@ unix {
 }
 
 exists($$QMAKE_LIBDIR_QT/libQtGui.so) {
-    DEFINES += QT_SHARED				      
+    DEFINES += QT_SHARED
 } else:exists($$QMAKE_LIBDIR_QT/../bin//QtGui4.dll) {
     DEFINES += QT_SHARED
 } else:contains(QMAKE_PRL_CONFIG, shared) {

+ 18 - 1
scripts/release.sh

@@ -1,4 +1,21 @@
 #!/bin/bash
+#
+# Copyright 2010 wkhtmltopdf authors
+#
+# This file is part of wkhtmltopdf.
+#
+# wkhtmltopdf is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# wkhtmltopdf is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with wkhtmltopdf.  If not, see <http:#www.gnu.org/licenses/>.
 
 function usage() {
     echo "Usage $0: [Options] Major Minor Patch [Build]"
@@ -81,4 +98,4 @@ for x in libgcc_s_dw2-1.dll ssleay32.dll libeay32.dll mingwm10.dll EnvVarUpdate.
 	[ -f "$l" ] && cp "$l" "$x" && continue
     wget "http://wkhtmltopdf.googlecode.com/files/$x" -O "$x" && continue
 done
-makensis wkhtmltopdf.nsi 
+makensis wkhtmltopdf.nsi

+ 9 - 3
scripts/sourcefix.py

@@ -21,9 +21,10 @@ from sys import argv, exit
 import re
 from datetime import date
 import os
+import difflib
 
 cdate = re.compile(r"Copyright ([0-9 ,]*) wkhtmltopdf authors")
-ifdef = re.compile(r"^#ifndef __(.*)__[\r\n]*#define __\1__[\r\n]*")
+ifdef = re.compile(r"^[\n\r \t]*#ifndef __(.*)__[\t ]*\n#define __(\1)__[\t ]*\n")
 endif = re.compile(r"#endif.*[\r\n \t]*$")
 ws = re.compile(r"[ \t]*[\r\n]")
 branchspace = re.compile(r"([ \t\r\n])(for|if|while|switch|foreach)[\t \r\n]*\(")
@@ -89,6 +90,10 @@ for path in argv[1:]:
 	ndata = hexp.sub("", data,1)
 	ndata = ws.sub("\n", ndata)+"\n"
 	if ext in ["hh","h","inl"]:
+		s=0
+		e=-1
+		while ndata[s] in ['\r','\n',' ','\t']: s+=1
+		while ndata[e] in ['\r','\n',' ','\t']: e-=1
 		#Strip away generated ifdef
 		if ifdef.search(ndata):
 			ndata = endif.sub("",ifdef.sub("",ndata,1),1)
@@ -111,8 +116,9 @@ for path in argv[1:]:
 #endif //__%s__"""%(n,n,ndata,n)
 	ndata = header.replace("//",cc)+ndata+"\n"
 	if ndata != data:
-		changes=True
-		print "Updated %s for style"%path
+		for x in difflib.unified_diff(data.split("\n"),ndata.split("\n"), "a/"+path, "b/"+path):
+			print x
+ 		changes=True
 		file(path, "w").write(ndata)
 
 if changes: exit(1)

+ 10 - 7
scripts/static-build.sh

@@ -1,4 +1,7 @@
 #!/bin/bash
+#
+# Copyright 2010 wkhtmltopdf authors
+#
 # This file is part of wkhtmltopdf.
 #
 # wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -93,7 +96,7 @@ function git_fetch_and_update() {
 	git clone "$2" "$1" || (rm -rf "$1" && return 1)
     fi
     cd "$1"
-    git fetch origin 
+    git fetch origin
     if ! (git checkout "$3" -f 2>/dev/null && git pull origin "$3" 2>/dev/null); then
 	git branch -a
 	git checkout origin/"$3" -f 2>/dev/null || return 1
@@ -138,7 +141,7 @@ function setup_build() {
 		git checkout "$VERSION" || exit 1
     fi
     cd ..
-    [ "$1" == "win" ] && return 
+    [ "$1" == "win" ] && return
     cat > build.sh <<EOF
 unset LANG
 unset LC_ALL
@@ -157,7 +160,7 @@ if ! cmp conf conf_new; then
   QTDIR=. bin/syncqt || exit 1
   do_configure
 fi
-    
+
 if ! make -j3 -q; then
    echo "Building QT"
    (make -j3 && make install) || (make distclean; do_configure && make -j3 && make install) || exit 1
@@ -192,7 +195,7 @@ function setup_chroot() {
 	sudo mkdir -p linux-$2/build || exit 1
 	sudo chown --reference=. linux-$2/build -Rv || exit 1
     fi
-    
+
     if [ ! -f linux-$2/installed ]; then
 	echo -e "deb http://ftp.debian.org $1 main non-free contrib\ndeb-src http://ftp.debian.org $1 main non-free contrib" | sudo tee linux-$2/etc/apt/sources.list || exit 1
 	sudo chroot linux-$2 apt-get -y update || exit 1
@@ -218,10 +221,10 @@ function build_linux_chroot() {
 
 function build_windows() {
     cd ${BUILD}
- 
+
     export WINEPREFIX=${BUILD}/windows
     if [ ! -f ${BUILD}/windows/create ]; then
-	    cat > tmp <<EOF 
+	    cat > tmp <<EOF
 REGEDIT4
 
 [HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment]
@@ -246,7 +249,7 @@ EOF
 
     cd ..
     setup_build win
-    
+
     unset CPLUS_INCLUDE_PATH
     unset C_INCLUDE_PATH
     export CPLUS_INCLUDE_PATH=

+ 15 - 12
scripts/test.sh

@@ -1,4 +1,7 @@
 #!/bin/bash
+#
+# Copyright 2010 wkhtmltopdf authors
+#
 # This file is part of wkhtmltopdf.
 #
 # wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -100,7 +103,7 @@ function testSSL() {
 function testHeaderFooter() {
     echo "<html><head><title>Local Test</title></head><body><h1>monster</h1></body></html>" > tmp.html
     wk tmp.html --footer-left hat --header-right emacs tmp.pdf 2>$LEVEL2 >$LEVEL1
-    ([ -f tmp.pdf ] && 
+    ([ -f tmp.pdf ] &&
 	pdftotext tmp.pdf /dev/stdout | grep -q monster &&
 	pdftotext tmp.pdf /dev/stdout | grep -q emacs &&
 	pdftotext tmp.pdf /dev/stdout | grep -q hat) && good $1 || bad $1
@@ -118,7 +121,7 @@ function testLoadError() {
 function testFontSpacing() {
 	echo "<html><body style=\"font-size: 7pt; font-family: Arial;\">vii vaa vuu vvv vee</body></html>" > tmp.html
     wk tmp.html tmp.pdf 2>$LEVEL2 >$LEVEL1
-    ([ -f tmp.pdf ] && 
+    ([ -f tmp.pdf ] &&
 	pdftotext tmp.pdf /dev/stdout | grep -q "vii vaa vuu vvv vee") && good $1 || bad $1 false
 
 }
@@ -126,7 +129,7 @@ function testFontSpacing() {
 function testToc() {
     echo "<html><head></head><body><h1>foo</h1><h2>bar</h2><h3>baz</h3></body>" > tmp.html
     wk toc tmp.html tmp.pdf 2>$LEVEL2 >$LEVEL1
-    ([ -f tmp.pdf ] && 
+    ([ -f tmp.pdf ] &&
 	[ "$(pdftotext tmp.pdf /dev/stdout | grep -c foo)" == 2 ] &&
 	[ "$(pdftotext tmp.pdf /dev/stdout | grep -c bar)" == 2 ]) && good $1 || bad $1
 }
@@ -134,7 +137,7 @@ function testToc() {
 function testOutline() {
     echo "<html><head></head><body><h1>foo</h1><h2>bar</h2><h3>baz</h3></body>" > tmp.html
     wk --outline --outline-depth 2 tmp.html tmp.pdf 2>$LEVEL2 >$LEVEL1
-    ([ -f tmp.pdf ] && 
+    ([ -f tmp.pdf ] &&
 	cat tmp.pdf | grep -q ".f.o.o" &&
 	cat tmp.pdf | grep -q ".b.a.r" &&
 	! cat tmp.pdf | grep -q ".b.a.z") && good $1 || bad $1
@@ -142,13 +145,13 @@ function testOutline() {
 
 function testJSRedirect() {
     wk http://madalgo.au.dk/~jakobt/jsredirect.html tmp.pdf 2>$LEVEL2 >$LEVEL1
-    ([ -f tmp.pdf ] && 
+    ([ -f tmp.pdf ] &&
 	pdftotext tmp.pdf /dev/stdout | grep -q Right) && good $1 || bad $1
 }
 
 function testServersideRedirect() {
     wk http://madalgo.au.dk/~jakobt/redirect.php tmp.pdf 2>$LEVEL2 >$LEVEL1
-    ([ -f tmp.pdf ] && 
+    ([ -f tmp.pdf ] &&
 	pdftotext tmp.pdf /dev/stdout | grep -q Right) && good $1 || bad $1
 }
 
@@ -165,7 +168,7 @@ function testMultipleInputDocuments() {
     echo "<html><head><title>Local Test</title></head><body><h1>Hello</h1></body></html>" > tmp.html
     echo "<html><head><title>Local Test</title></head><body><h1>world</h1></body></html>" > tmp2.html
     wk tmp.html tmp2.html tmp.pdf 2>$LEVEL2 >$LEVEL1
-    ([ -f tmp.pdf ] && 
+    ([ -f tmp.pdf ] &&
 	pdftotext tmp.pdf /dev/stdout | grep -q Hello &&
 	pdftotext tmp.pdf /dev/stdout | grep -q world) && good $1 || bad $1
 }
@@ -174,14 +177,14 @@ function testHtmlHeader() {
     echo "<html><body>Header</body></html>" > tmp.html
     echo "<html><head><title>Local Test</title></head><body><h1>world</h1></body></html>" > tmp2.html
     wk --header-html tmp.html tmp2.html tmp.pdf 2>$LEVEL2 >$LEVEL1
-    ([ -f tmp.pdf ] && 
+    ([ -f tmp.pdf ] &&
 	pdftotext tmp.pdf /dev/stdout | grep -q Header &&
 	pdftotext tmp.pdf /dev/stdout | grep -q world) && good $1 || bad $1
 }
 
 function testCustomHeader() {
     wk http://madalgo.au.dk/~jakobt/cookiewrite.php --custom-header "Cookie" "cookie=hello" tmp.pdf 2>$LEVEL2 >$LEVEL1
-    ([ -f tmp.pdf ] && 
+    ([ -f tmp.pdf ] &&
 	pdftotext tmp.pdf /dev/stdout | grep -q hello) && good $1 || bad $1
 }
 
@@ -238,7 +241,7 @@ LEVEL1=/dev/null
 LEVEL2=/dev/stdout
 LEVEL3=/dev/stdout
 
-export WK=../bin/wkhtmltopdf 
+export WK=../bin/wkhtmltopdf
 
 while getopts hvqw: O; do
     case "$O" in
@@ -261,7 +264,7 @@ while getopts hvqw: O; do
     esac
 done
 R=$1
-if [ -z "$R" ]; then 
+if [ -z "$R" ]; then
     R=.*
 fi
 
@@ -282,4 +285,4 @@ for test in $TESTS; do
     eval test$test $test
 done
 rm -rf $TMPFILES
-exit $failed 
+exit $failed

+ 21 - 3
scripts/upload.sh

@@ -1,4 +1,22 @@
 #!/bin/bash
+#
+# Copyright 2010 wkhtmltopdf authors
+#
+# This file is part of wkhtmltopdf.
+#
+# wkhtmltopdf is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# wkhtmltopdf is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with wkhtmltopdf.  If not, see <http:#www.gnu.org/licenses/>.
+
 cd "release-$1"
 wget http://support.googlecode.com/svn/trunk/scripts/googlecode_upload.py -O googlecode_upload.py
 
@@ -7,10 +25,10 @@ function ul() {
 	python googlecode_upload.py -u "$USER" -w "$PASS" -s "$1" -p "wkhtmltopdf" -l "$2" "$3"
 }
 
-if ! [ -f "wkhtmltopdf-$1.tar.bz2" ] || 
+if ! [ -f "wkhtmltopdf-$1.tar.bz2" ] ||
    ! [ -f "wkhtmltopdf-$1-static-i386.tar.bz2" ] ||
-   ! [ -f "wkhtmltopdf-$1-static-amd64.tar.bz2" ] || 
-   ! [ -f "wkhtmltox-$1-installer.exe" ] || 
+   ! [ -f "wkhtmltopdf-$1-static-amd64.tar.bz2" ] ||
+   ! [ -f "wkhtmltox-$1-installer.exe" ] ||
    ! [ -f "wkhtmltoimage-$1-static-i386.tar.bz2" ] ||
    ! [ -f "wkhtmltoimage-$1-static-amd64.tar.bz2" ]; then
 	echo "File Missing"

+ 9 - 5
src/image/arguments.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,13 +17,13 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#include "commandlineparser.hh"
+
 #include "arghandler.inl"
+#include "commandlineparser.hh"
 #include <qglobal.h>
 
 CommandLineParser::CommandLineParser(wkhtmltopdf::settings::Global & s):
-	settings(s)
-{
+	settings(s) {
 	mode(global);
 	section("General Options");
 	addDocArgs();
@@ -37,7 +41,7 @@ CommandLineParser::CommandLineParser(wkhtmltopdf::settings::Global & s):
 	addarg("crop-h",0,"Set height for croping", new IntSetter(s.crop.height,"int"));
 	addarg("format",'f',"Output file format (default is jpg)", new QStrSetter(s.fmt, "format") );
 	addarg("quality",0,"Output image quality (between 0 and 100)", new IntSetter(s.quality, "int") );
-	
+
 	extended(true);
 	qthack(true);
 	addarg("disable-smart-width", '0', "Use the specified width even if it is not large enough for the content", new ConstSetter<bool>(s.smartWidth, false));

+ 12 - 8
src/image/commandlineparser.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,9 +17,10 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparser.hh"
-#include <qwebframe.h>
 #include "outputter.hh"
+#include <qwebframe.h>
 
 /*!
   \file commandlineparser.hh
@@ -83,17 +88,17 @@ void CommandLineParser::readme(FILE * fd, bool html) const {
 // void CommandLineParser::loadDefaults() {
 // 	d->settings.in = "-";
 // 	d->settings.proxy.host = "";
-// 	foreach(ArgHandler * h, d->longToHandler) 
+// 	foreach (ArgHandler * h, d->longToHandler)
 // 		h->useDefault(*d);
 
 // 	//Load configuration from enviornment
 // 	char * val;
 // 	const char * vars[] = {"proxy","all_proxy","http_proxy", NULL};
-// 	for(int i=0; vars[i]; ++i) {
+// 	for (int i=0; vars[i]; ++i) {
 // 		if ((val = getenv("proxy"))) {
 // 			bool ok=false;
 // 			Settings::ProxySettings p = Settings::strToProxy(val, &ok);
-// 			if(ok) 
+// 			if (ok)
 // 				d->settings.proxy = p;
 // 		}
 // 	}
@@ -109,7 +114,7 @@ void CommandLineParser::parseArguments(int argc, const char ** argv, bool final)
     settings.out="";
 	bool defaultMode=false;
 	for (int i=1; i < argc; ++i) {
-        if(i==argc-2 && (argv[i][0] != '-' || argv[i][1] == '\0')) { // the arg before last (in)
+        if (i==argc-2 && (argv[i][0] != '-' || argv[i][1] == '\0')) { // the arg before last (in)
             settings.in = argv[i];
         } else if (i==argc-1 && (argv[i][0] != '-' || argv[i][1] == '\0')) { // the last arg (out)
             settings.out = argv[i];
@@ -118,10 +123,9 @@ void CommandLineParser::parseArguments(int argc, const char ** argv, bool final)
 		}
 	}
 
-	if(final || settings.in=="" || settings.out=="") {
+	if (final || settings.in=="" || settings.out=="") {
         fprintf(stderr, "You need to specify at least one input file, and exactly one output file\nUse - for stdin or stdout\n\n");
         usage(stderr, false);
         exit(1);
     }
 }
-

+ 10 - 5
src/image/commandlineparser.hh

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,10 +17,11 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#ifndef __COMMMAND_LINE_PARSER_HH__
-#define __COMMMAND_LINE_PARSER_HH__
-#include "settings.hh"
+
+#ifndef __COMMANDLINEPARSER_HH__
+#define __COMMANDLINEPARSER_HH__
 #include "commandlineparserbase.hh"
+#include "settings.hh"
 #include <cstdio>
 
 /*! \brief The class is responcible for parsing command line information
@@ -52,4 +57,4 @@ public:
 	void parseArguments(int argc, const char ** argv, bool final=false);
 
 };
-#endif //__COMMMAND_LINE_PARSER_HH__
+#endif //__COMMANDLINEPARSER_HH__

+ 7 - 4
src/image/docparts.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparser.hh"
 #include "outputter.hh"
 #include <QWebFrame>
@@ -101,7 +106,7 @@ void CommandLineParser::outputInstallation(Outputter * o) const {
 	o->paragraph(
 		"There are several ways to install wkhtmltoimage.  You can download a "
 		"already compiled binary, or you can compile wkhtmltoimage yourself. ");
-	o->endSection(); 
+	o->endSection();
 }
 
 /*!
@@ -117,5 +122,3 @@ void CommandLineParser::outputExamples(Outputter * o) const {
 	o->verbatim("wkhtmltoimage my.html my.png\n");
 	o->endSection();
 }
-
-

+ 17 - 2
src/image/image.pro

@@ -1,3 +1,20 @@
+# Copyright 2010 wkhtmltopdf authors
+#
+# This file is part of wkhtmltopdf.
+#
+# wkhtmltopdf is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# wkhtmltopdf is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with wkhtmltopdf.  If not, see <http:#www.gnu.org/licenses/>.
+
 include(../../version.pri)
 include(../../common.pri)
 
@@ -42,5 +59,3 @@ include(../shared/shared.pri)
 HEADERS += imageconverter.hh imageconverter_p.hh settings.hh converter.hh
 SOURCES += wkhtmltoimage.cc arguments.cc commandlineparser.cc docparts.cc \
            imageconverter.cc settings.cc
-
-

+ 27 - 23
src/image/imageconverter.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,27 +17,28 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "imageconverter_p.hh"
 #include "settings.hh"
-#include <QObject>
-#include <QWebPage>
-#include <QWebFrame>
-#include <QUrl>
-#include <QImage>
-#include <QPainter>
-#include <QObject>
+#include <QDebug>
 #include <QEventLoop>
 #include <QFileInfo>
-#include <QDebug>
-#include <qapplication.h>
+#include <QImage>
+#include <QObject>
+#include <QObject>
+#include <QPainter>
 #include <QSvgGenerator>
+#include <QUrl>
+#include <QWebFrame>
+#include <QWebPage>
+#include <qapplication.h>
 namespace wkhtmltopdf {
 
 ImageConverterPrivate::ImageConverterPrivate(ImageConverter & o, wkhtmltopdf::settings::Global & s):
 	settings(s),
 	loader(s.loadGlobal),
 	out(o) {
-	
+
 	phaseDescriptions.push_back("Loading page");
 	phaseDescriptions.push_back("Rendering");
 	phaseDescriptions.push_back("Done");
@@ -66,11 +70,11 @@ void ImageConverterPrivate::clearResources() {
 void ImageConverterPrivate::pagesLoaded(bool ok) {
 	if (errorCode == 0) errorCode = loader.httpErrorCode();
 	if (!ok) {
-		fail(); 
+		fail();
 		return;
 	}
 	// if fmt is empty try to get it from file extension in out
-	if(settings.fmt==""){
+	if (settings.fmt=="") {
 		if (settings.out == "-")
 			settings.fmt = "jpg";
 		else {
@@ -78,24 +82,24 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 			settings.fmt = fi.suffix();
 		}
 	}
-	
+
 	// check whether image format is supported (for writing)
 //	QImageWriter test;
 //	test.setFormat(settings.fmt);
-//	if(!test.canWrite()){
-//		if(!settings.quiet)printf("error: file format not supported\n");
+//	if (!test.canWrite()) {
+//		if (!settings.quiet)printf("error: file format not supported\n");
 //		httpErrorCode=EFAULT;
 //		return false;
 //	}
 	// create webkit frame and load website
-	
+
 	currentPhase=1;
 	emit out. phaseChanged();
 	loadProgress(0);
 
 	QWebFrame * frame = loaderObject->page.mainFrame();
 	loaderObject->page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
-	
+
 	loadProgress(25);
 	// Calculate a good width for the image
 	int highWidth=settings.screenWidth;
@@ -113,7 +117,7 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 			loaderObject->page.setViewportSize(QSize(t, 10));
 			if (frame->scrollBarMaximum(Qt::Horizontal) > 0)
 				lowWidth = t;
-			else 
+			else
 				highWidth = t;
 		}
 		loaderObject->page.setViewportSize(QSize(highWidth, 10));
@@ -121,7 +125,7 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 	loaderObject->page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
 	//Set the right height
 	loaderObject->page.setViewportSize(QSize(highWidth, frame->contentsSize().height()));
-	
+
 	QPainter painter;
 	QSvgGenerator generator;
 	QImage image;
@@ -149,7 +153,7 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 		emit out.error("Will not output an empty image");
 		fail();
 	}
-	
+
 	if (settings.fmt != "svg") {
 		image = QImage(rect.size(), QImage::Format_ARGB32_Premultiplied);
 		painter.begin(&image);
@@ -162,7 +166,7 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 #endif
 		painter.begin(&generator);
 	}
-	
+
 	if (!settings.transparent || (settings.fmt != "png" && settings.fmt != "svg"))
 		painter.fillRect(QRect(QPoint(0,0),loaderObject->page.viewportSize()), Qt::white);
 	painter.translate(-rect.left(), -rect.top());
@@ -171,7 +175,7 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 
 	//loadProgress(30);
 	// perform filter(s)
-	//if (settings.crop.width > 0 && settings.crop.height > 0) 
+	//if (settings.crop.width > 0 && settings.crop.height > 0)
 	//	image=image.copy(settings.crop.left,settings.crop.top,settings.crop.width,settings.crop.height);
 	//loadProgress(50);
 	//if (settings.scale.width > 0 && settings.scale.height > 0) {
@@ -185,7 +189,7 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 		if (!image.save(&file,fmt.data(), settings.quality)) {
 			emit out.error("Could not save image");
 			fail();
-		} 
+		}
 	}
 	loadProgress(100);
 

+ 5 - 1
src/image/imageconverter.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,10 +17,11 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __IMAGECONVERTER_HH__
 #define __IMAGECONVERTER_HH__
-#include "settings.hh"
 #include "converter.hh"
+#include "settings.hh"
 
 namespace wkhtmltopdf {
 

+ 11 - 7
src/image/imageconverter_p.hh

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,19 +17,19 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __IMAGECONVERTER_P_HH__
 #define __IMAGECONVERTER_P_HH__
-
-#include "multipageloader.hh"
-#include "imageconverter.hh"
 #include "converter_p.hh"
+#include "imageconverter.hh"
+#include "multipageloader.hh"
 namespace wkhtmltopdf {
-  
+
 class ImageConverterPrivate: public ConverterPrivate {
 	Q_OBJECT
 public:
 	ImageConverterPrivate(ImageConverter & o, wkhtmltopdf::settings::Global & s);
-	
+
 	wkhtmltopdf::settings::Global settings;
 	MultiPageLoader loader;
 private:
@@ -44,4 +48,4 @@ public slots:
 };
 
 }
-#endif //__IMAGECONVERTER_HH__
+#endif //__IMAGECONVERTER_P_HH__

+ 4 - 0
src/image/settings.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "settings.hh"
 
 namespace wkhtmltopdf {

+ 8 - 4
src/image/settings.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __SETTINGS_HH__
 #define __SETTINGS_HH__
 #include "loadsettings.hh"
@@ -49,7 +53,7 @@ struct CropSettings {
 /*! \brief Class holding all user settings.
 
     This class holds all the user settings, settings can be filled in by hand,
-    or with other methods. 
+    or with other methods.
     \sa CommandLineParser::parse()
 */
 struct Global {
@@ -59,14 +63,14 @@ struct Global {
 	CropSettings crop;
 	//! Scale related settings
 	// ScaleSettings scale;
-	
+
 	LoadGlobal loadGlobal;
 	LoadPage loadPage;
 	Web web;
 
 	//! Be less verbose
-	bool quiet; 
-	
+	bool quiet;
+
 	bool transparent;
 
 	//! Should we use the graphics system

+ 8 - 3
src/image/wkhtmltoimage.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,11 +17,12 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparser.hh"
-#include "settings.hh"
-#include "utilities.hh"
 #include "imageconverter.hh"
 #include "progressfeedback.hh"
+#include "settings.hh"
+#include "utilities.hh"
 #include <QApplication>
 #include <QWebFrame>
 

+ 17 - 14
src/pdf/arguments.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,10 +18,10 @@
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 
-#include "commandlineparser.hh"
 #include "arghandler.inl"
-#include <QFile>
+#include "commandlineparser.hh"
 #include "pdfconverter.hh"
+#include <QFile>
 #include <qglobal.h>
 
 /*!
@@ -45,7 +49,7 @@
   \brief The names of the arguments to the switch
 */
 
-/*!											  
+/*!
   \var ArgHandler::display
   \brief Indicate that the argument is not hidden
 */
@@ -55,7 +59,7 @@
   \brief Indicate if the argument is an extended argument
 */
 
-/*!											  
+/*!
   \var ArgHandler::qthack
   \brief Indicate that the argument is only available with hacked qt
 */
@@ -84,7 +88,7 @@ struct UnitRealTM: public SomeSetterTM<UnitReal> {
 	}
 };
 /*!
-  Argument handler setting a real-number/unit combo variable  
+  Argument handler setting a real-number/unit combo variable
  */
 typedef SomeSetter<UnitRealTM> UnitRealSetter;
 
@@ -98,7 +102,7 @@ struct PageSizeTM: public SomeSetterTM<QPrinter::PageSize> {
 	}
 };
 /*!
-  Argument handler setting a page size variable  
+  Argument handler setting a page size variable
  */
 typedef SomeSetter<PageSizeTM> PageSizeSetter;
 
@@ -112,7 +116,7 @@ struct OrientationTM: public SomeSetterTM<QPrinter::Orientation> {
 	}
 };
 /*!
-  Argument handler setting a orientation variable  
+  Argument handler setting a orientation variable
  */
 typedef SomeSetter<OrientationTM> OrientationSetter;
 
@@ -163,8 +167,7 @@ struct BookFunc {
 CommandLineParser::CommandLineParser(Global & s, QList<Page> & ps):
 	readArgsFromStdin(false),
 	globalSettings(s),
-	pageSettings(ps)
-{
+	pageSettings(ps) {
 	section("Global Options");
 	mode(global);
 
@@ -174,7 +177,7 @@ CommandLineParser::CommandLineParser(Global & s, QList<Page> & ps):
 	qthack(false);
 
 	addarg("quiet", 'q', "Be less verbose", new ConstSetter<bool>(s.quiet,true));
-	
+
 	addarg("no-collate", 0, "Do not collate when printing multiple copies", new ConstSetter<bool>(s.collate, false));
 	addarg("collate", 0, "Collate when printing multiple copies", new ConstSetter<bool>(s.collate, true));
 
@@ -211,7 +214,7 @@ CommandLineParser::CommandLineParser(Global & s, QList<Page> & ps):
 
 	addarg("image-quality", 0, "When jpeg compressing images use this quality", new IntSetter(s.imageQuality,"integer"));
 	addarg("image-dpi", 0, "When embedding images scale them down to this dpi", new IntSetter(s.imageDPI, "integer"));
-		   
+
 	addarg("no-pdf-compression", 0 , "Do not use lossless compression on pdf objects", new ConstSetter<bool>(s.useCompression,false));
 
  #ifdef Q_WS_X11
@@ -243,7 +246,7 @@ CommandLineParser::CommandLineParser(Global & s, QList<Page> & ps):
  	qthack(true);
 	addarg("disable-smart-shrinking", 0, "Disable the intelligent shrinking strategy used by WebKit that makes the pixel/dpi ratio none constant",new ConstSetter<bool>(od.web.enableIntelligentShrinking, false));
  	addarg("enable-smart-shrinking", 0, "Enable the intelligent shrinking strategy used by WebKit that makes the pixel/dpi ratio none constant",new ConstSetter<bool>(od.web.enableIntelligentShrinking, true));
-	
+
 	addarg("print-media-type",0,"Use print media-type instead of screen", new ConstSetter<bool>(od.web.printMediaType,true));
 	addarg("no-print-media-type",0,"Do not use print media-type instead of screen", new ConstSetter<bool>(od.web.printMediaType, false));
 
@@ -284,7 +287,7 @@ CommandLineParser::CommandLineParser(Global & s, QList<Page> & ps):
  	addarg("header-right",0,"Right aligned header text", new QStrSetter(od.header.right,"text"));
  	addarg("header-spacing",0,"Spacing between header and content in mm", new FloatSetter(od.header.spacing,"real"));
  	addarg("header-html",0,"Adds a html header", new QStrSetter(od.header.htmlUrl,"url"));
-	
+
 	addarg("replace",0, "Replace [name] with value in header and footer (repeatable)", new MapSetter<>(od.replacements, "name", "value"));
 
 	section("TOC Options");

+ 19 - 16
src/pdf/commandlineparser.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparser.hh"
 #include "outputter.hh"
 #include <qwebframe.h>
@@ -64,7 +69,7 @@ void CommandLineParser::usage(FILE * fd, bool extended) const {
 	outputSynopsis(o);
  	outputDescripton(o);
 	outputSwitches(o, extended, false);
-#ifndef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__	
+#ifndef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 	outputNotPatched(o, true);
 #endif
 	if (extended) {
@@ -111,7 +116,7 @@ void CommandLineParser::readme(FILE * fd, bool html) const {
 //void CommandLineParser::loadDefaults() {
 	//settings.in.clear();
 	//settings.proxy.host = "";
-	//foreach(ArgHandler * h, longToHandler) 
+	//foreach(ArgHandler * h, longToHandler)
 	//	h->useDefault(*d);
 
 	//Load configuration from enviornment
@@ -121,7 +126,7 @@ void CommandLineParser::readme(FILE * fd, bool html) const {
 	//	if ((val = getenv("proxy"))) {
 	//		bool ok=false;
 	//		Settings::ProxySettings p = Settings::strToProxy(val, &ok);
-	//		if(ok) 
+	//		if (ok)
 	//			settings.proxy = p;
 	//	}
 	//}
@@ -136,25 +141,25 @@ void CommandLineParser::readme(FILE * fd, bool html) const {
 void CommandLineParser::parseArguments(int argc, const char ** argv, bool fromStdin) {
 	bool defaultMode = false;
 	int arg=1;
-	
+
 	Page def;
-	
+
 	//Parse global options
-	for(;arg < argc;++arg) {
+	for (;arg < argc;++arg) {
 		if (argv[arg][0] != '-' || argv[arg][1] == '\0' || defaultMode) break;
 		parseArg(global | page, argc, argv, defaultMode, arg, (char *)&def);
 	}
-	
+
 	if (readArgsFromStdin && !fromStdin) return;
 
 	//Parse page options
-	while(arg < argc-1) {
+	while (arg < argc-1) {
 		pageSettings.push_back(def);
 		Page & ps = pageSettings.back();
 		int sections = page;
 		if (!strcmp(argv[arg],"cover")) {
 			++arg;
-			if(arg >= argc-1) {
+			if (arg >= argc-1) {
 				fprintf(stderr, "You need to specify a input file to cover\n\n");
 				usage(stderr, false);
 				exit(1);
@@ -166,7 +171,7 @@ void CommandLineParser::parseArguments(int argc, const char ** argv, bool fromSt
 			ps.header.line = ps.footer.line = false;
 			ps.header.htmlUrl = ps.footer.htmlUrl = "";
 			ps.includeInOutline = false;
-				
+
 			//Setup varius cover settings her
 			++arg;
 		} else if (!strcmp(argv[arg],"toc")) {
@@ -176,7 +181,7 @@ void CommandLineParser::parseArguments(int argc, const char ** argv, bool fromSt
 		} else {
 			if (!strcmp(argv[arg],"page")) {
 				++arg;
-				if(arg >= argc-1) {
+				if (arg >= argc-1) {
 					fprintf(stderr, "You need to specify a input file to page\n\n");
 					usage(stderr, false);
 					exit(1);
@@ -185,12 +190,12 @@ void CommandLineParser::parseArguments(int argc, const char ** argv, bool fromSt
 			ps.page = QString::fromLocal8Bit(argv[arg]);
 			++arg;
 		}
-		for(;arg < argc;++arg) {
+		for (;arg < argc;++arg) {
 			if (argv[arg][0] != '-' || argv[arg][1] == '\0' || defaultMode) break;
 			parseArg(sections, argc, argv, defaultMode, arg, (char*)&ps);
 		}
 	}
-	
+
 	if (pageSettings.size() == 0 || argc < 2) {
 		fprintf(stderr, "You need to specify atleast one input file, and exactly one output file\nUse - for stdin or stdout\n\n");
 		usage(stderr, false);
@@ -198,5 +203,3 @@ void CommandLineParser::parseArguments(int argc, const char ** argv, bool fromSt
 	}
 	globalSettings.out = argv[argc-1];
 }
-
-

+ 15 - 11
src/pdf/commandlineparser.hh

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,10 +17,11 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#ifndef __COMMMAND_LINE_PARSER_HH__
-#define __COMMMAND_LINE_PARSER_HH__
-#include "settings.hh"
+
+#ifndef __COMMANDLINEPARSER_HH__
+#define __COMMANDLINEPARSER_HH__
 #include "commandlineparserbase.hh"
+#include "settings.hh"
 #include <cstdio>
 
 class CommandLineParser: public CommandLineParserBase {
@@ -29,9 +34,9 @@ public:
 	QList<wkhtmltopdf::settings::Page> & pageSettings;
 
 	wkhtmltopdf::settings::Page od;
-	
+
 	//Arguments.cc
-	CommandLineParser(wkhtmltopdf::settings::Global & globalSettings, 
+	CommandLineParser(wkhtmltopdf::settings::Global & globalSettings,
 					  QList<wkhtmltopdf::settings::Page> & pageSettings);
 
 	//docparts.cc
@@ -49,7 +54,7 @@ public:
 	void outputCompilation(Outputter * o) const;
 	void outputInstallation(Outputter * o) const;
 	void outputExampels(Outputter * o) const;
-	
+
 	//commandlineparser.cc
 	virtual QString appName() const {return "wkhtmltopdf";}
 	virtual void usage(FILE * fd, bool extended) const;
@@ -60,10 +65,9 @@ public:
 
 	virtual char * mapAddress(char * d, char * ns) const {
 		const char * _od = reinterpret_cast<const char *>(&od);
-		if(_od > d || d >= _od + sizeof(wkhtmltopdf::settings::Page)) return d;;
+		if (_od > d || d >= _od + sizeof(wkhtmltopdf::settings::Page)) return d;;
 		return d - _od + ns;
 	}
- 
-};
 
-#endif //__COMMMAND_LINE_PARSER_HH__
+};
+#endif //__COMMANDLINEPARSER_HH__

+ 12 - 7
src/pdf/docparts.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparser.hh"
 #include "outputter.hh"
 #include <QWebFrame>
@@ -64,7 +69,7 @@ void CommandLineParser::outputSynopsis(Outputter * o) const {
 				 "the page does not appear in the table of content, and does not have headers and footers.");
 	o->verbatim("cover <input url/file name> [PAGE OPTION]...");
 	o->paragraph("All options that can be specified for a page object can also be specified for a cover.");
-	
+
 	o->paragraph("A table of content object inserts a table of content into the output document.");
 	o->verbatim("toc [TOC OPTION]...");
 	o->beginParagraph();
@@ -107,7 +112,7 @@ void CommandLineParser::outputDescripton(Outputter * o) const {
 */
 void CommandLineParser::outputNotPatched(Outputter * o, bool sure) const {
 	o->beginSection("Reduced Functionality");
-	if (sure) 
+	if (sure)
 		o->paragraph("This version of wkhtmltopdf has been compiled against a version of "
 					 "QT without the wkhtmltopdf patches. Therefore some features are missing, "
 					 "if you need these features please use the static version.");
@@ -192,11 +197,11 @@ void CommandLineParser::outputHeaderFooterDoc(Outputter * o) const {
 "function subst() {\n"
 "  var vars={};\n"
 "  var x=document.location.search.substring(1).split('&');\n"
-"  for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}\n"
+"  for (var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}\n"
 "  var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];\n"
-"  for(var i in x) {\n"
+"  for (var i in x) {\n"
 "    var y = document.getElementsByClassName(x[i]);\n"
-"    for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];\n"
+"    for (var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];\n"
 "  }\n"
 "}\n"
 "</script></head><body style=\"border:0; margin: 0;\" onload=\"subst()\">\n"
@@ -345,7 +350,7 @@ void CommandLineParser::outputInstallation(Outputter * o) const {
 		"binary, however you still need to install some other pieces of "
 		"software, to learn more about this read the static version section "
 		"of the manual.");
-	o->endSection(); 
+	o->endSection();
 }
 
 /*!

+ 35 - 32
src/pdf/outline.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outline_p.hh"
 #include <fstream>
 #include <iostream>
@@ -32,8 +36,7 @@ namespace wkhtmltopdf {
 */
 
 OutlineItem::OutlineItem():
-	parent(NULL), page(-1)
-{}
+	parent(NULL), page(-1) {}
 
 /*!
   \brief Recursivily delete the subtree
@@ -49,9 +52,9 @@ bool OutlineItem::differentFrom(OutlineItem * other) const {
 		other->document != document ||
 		other->value != value ||
 		other->display != display) return true;
-	
-	for(int i=0; i < children.size(); ++i) 
-		if (children[i]->differentFrom(other->children[i])) 
+
+	for (int i=0; i < children.size(); ++i)
+		if (children[i]->differentFrom(other->children[i]))
 			return true;
 	return false;
 }
@@ -67,7 +70,7 @@ OutlinePrivate::OutlinePrivate(const settings::Global & s):
 }
 
 OutlinePrivate::~OutlinePrivate() {
-	foreach (OutlineItem * i, documentOutlines) 
+	foreach (OutlineItem * i, documentOutlines)
 		delete i;
 }
 
@@ -97,15 +100,15 @@ QString escape(QString & str) {
 }
 
 void OutlinePrivate::dumpChildren(QTextStream & stream, const QList<OutlineItem *> & items, int level) const {
-	foreach(OutlineItem * item, items) {
-		for(int i=0; i < level; ++i) stream << "  ";
+	foreach (OutlineItem * item, items) {
+		for (int i=0; i < level; ++i) stream << "  ";
 		stream << "<item title=\"" << escape(item->value) << "\" page=\"" << (item->page + prefixSum[item->document]) << "\" link=\"" << escape(item->anchor) << "\" backLink=\"" << escape(item->tocAnchor) << "\"";
 		if (item->children.empty())
 			stream << "/>" << endl;
 		else {
 			stream << ">" << endl;
 			dumpChildren(stream, item->children, level+1);
-			for(int i=0; i < level; ++i) stream << "  ";
+			for (int i=0; i < level; ++i) stream << "  ";
 			stream << "</item>" << endl;
 		}
 	}
@@ -114,9 +117,9 @@ void OutlinePrivate::dumpChildren(QTextStream & stream, const QList<OutlineItem
 void Outline::dump(QTextStream & stream, const QString & xsl) const {
 	d->prefixSum.clear();
 	d->prefixSum.push_back(0);
-	foreach(int x, d->documentPages)
+	foreach (int x, d->documentPages)
 		d->prefixSum.push_back( d->prefixSum.back() + x );
-	
+
 	stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
 	QString x = xsl;
 	if (!x.isEmpty())
@@ -151,19 +154,19 @@ Outline::~Outline() {delete d;}
   \param wp A webprinter for the page
   \param frame The frame containing the webpage
 */
-bool Outline::replaceWebPage(int document, 
-							 const QString & name, 
-							 QWebPrinter & wp, 
-							 QWebFrame * frame, 
-							 const settings::Page & ps, 
-							 QVector<QPair<QWebElement, QString> > & local, 
+bool Outline::replaceWebPage(int document,
+							 const QString & name,
+							 QWebPrinter & wp,
+							 QWebFrame * frame,
+							 const settings::Page & ps,
+							 QVector<QPair<QWebElement, QString> > & local,
 							 QHash<QString, QWebElement> & anchors) {
 	QMap< QPair<int, QPair<qreal,qreal> >, QWebElement> headings;
-	foreach(const QWebElement & e, frame->findAllElements("h1,h2,h3,h4,h5,h6,h7,h8,h9")) {
+	foreach (const QWebElement & e, frame->findAllElements("h1,h2,h3,h4,h5,h6,h7,h8,h9")) {
 		QPair<int, QRectF> location = wp.elementLocation(e);
 		headings[ qMakePair(location.first, qMakePair(location.second.y(), location.second.x()) ) ] = e;
 	}
-	
+
 	//This huristic is a little strange, it tries to create a real tree,
 	//even though someone puts a h5 below a h1 or stuff like that
 	//The way this is handled is having a level stack, indicating what h-tags
@@ -177,7 +180,7 @@ bool Outline::replaceWebPage(int document,
 	root->display = true;
 
 	OutlineItem * old = root;
-	for(QMap< QPair<int, QPair<qreal,qreal> >, QWebElement>::iterator i = headings.begin(); 
+	for (QMap< QPair<int, QPair<qreal,qreal> >, QWebElement>::iterator i = headings.begin();
 		i != headings.end(); ++i) {
 		const QWebElement & element = i.value();
 		uint level = element.tagName().mid(1).toInt();
@@ -192,7 +195,7 @@ bool Outline::replaceWebPage(int document,
 
 		if (!d->linkNames[document].contains(value))
 			d->linkNames[document][value] = QString("__WKANCHOR_")+QString::number(d->anchorCounter++,36);
-		
+
 		if (!d->backLinkNames[document].contains(value))
 			d->backLinkNames[document][value] = QString("__WKANCHOR_")+QString::number(d->anchorCounter++,36);
 
@@ -200,10 +203,10 @@ bool Outline::replaceWebPage(int document,
 		item->tocAnchor = d->backLinkNames[document][value];
 		if (ps.toc.forwardLinks)
 			anchors[item->anchor] = element;
-		if (ps.toc.backLinks) 
+		if (ps.toc.backLinks)
 			local.push_back( QPair<QWebElement, QString>(element, item->tocAnchor) );
 
-		while(levelStack.back() >= level) {
+		while (levelStack.back() >= level) {
 			old = old->parent;
 			levelStack.pop_back();
 		}
@@ -215,7 +218,7 @@ bool Outline::replaceWebPage(int document,
 
 	bool changed=d->documentOutlines[document]->differentFrom(root);
 	delete d->documentOutlines[document];
-	d->documentOutlines[document] = root; 
+	d->documentOutlines[document] = root;
 
 	if (d->documentPages[document] != wp.pageCount()) {
 		d->pageCount -= d->documentPages[document];
@@ -233,7 +236,7 @@ bool Outline::replaceWebPage(int document,
   \param frame The frame containing the webpage
 */
 void Outline::addWebPage(const QString & name, QWebPrinter & wp, QWebFrame * frame, const settings::Page & ps,
-						 QVector<QPair<QWebElement, QString> > & local, 
+						 QVector<QPair<QWebElement, QString> > & local,
 						 QHash<QString, QWebElement> & anchors) {
 	Q_UNUSED(name);
 	addEmptyWebPage();
@@ -260,8 +263,8 @@ void OutlinePrivate::buildHFCache(OutlineItem * i, int level) {
 	foreach (OutlineItem * j, i->children) {
 		while (hfCache[level].size() < (int)j->page)
 			hfCache[level].push_back(hfCache[level].back());
-		
-		if (hfCache[level].size() == (int)j->page) 
+
+		if (hfCache[level].size() == (int)j->page)
 			hfCache[level].push_back(j);
 		buildHFCache(j, level+1);
 	}
@@ -281,18 +284,18 @@ void Outline::fillHeaderFooterParms(int page, QHash<QString, QString> & parms, c
 			x.push_back(NULL);
 			d->hfCache.push_back(x);
 		}
-		foreach (OutlineItem * i, d->documentOutlines) 
+		foreach (OutlineItem * i, d->documentOutlines)
 			d->buildHFCache(i, 0);
 	}
 	for (int i=0; i < 3; ++i)
-		while (d->hfCache[i].size() <= page) 
+		while (d->hfCache[i].size() <= page)
 			d->hfCache[i].push_back(d->hfCache[i].back());
 
 	int off = d->settings.pageOffset;
 	typedef QPair<QString,QString> SP;
-	foreach (const SP & rep, ps.replacements) 
+	foreach (const SP & rep, ps.replacements)
 		parms[rep.first] = rep.second;
-		
+
 	parms["frompage"] = QString::number(off+1);
 	parms["topage"] = QString::number(off+d->pageCount);
 	parms["page" ] = QString::number(page+off);
@@ -325,7 +328,7 @@ int Outline::pageCount() {
 */
 void Outline::printOutline(QPrinter * printer) {
 	if (!d->settings.outline) return;
-	foreach(OutlineItem * i, d->documentOutlines)
+	foreach (OutlineItem * i, d->documentOutlines)
 		d->outlineChildren(i, printer, 0);
 }
 

+ 5 - 1
src/pdf/outline.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,12 +17,13 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __OUTLINE_HH__
 #define __OUTLINE_HH__
 #include <QWebFrame>
 #ifdef  __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
-#include <QWebElement>
 #include "settings.hh"
+#include <QWebElement>
 
 namespace wkhtmltopdf {
 

+ 7 - 0
src/pdf/outline_p.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,9 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef __OUTLINE_P_HH__
+#define __OUTLINE_P_HH__
 #ifndef __OUTLINE_P_HH
 #define __OUTLINE_P_HH
 #include "outline.hh"
@@ -60,3 +66,4 @@ public:
 }
 #endif //__EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #endif //__OUTLINE_P_HH
+#endif //__OUTLINE_P_HH__

+ 17 - 2
src/pdf/pdf.pro

@@ -1,3 +1,20 @@
+# Copyright 2010 wkhtmltopdf authors
+#
+# This file is part of wkhtmltopdf.
+#
+# wkhtmltopdf is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# wkhtmltopdf is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with wkhtmltopdf.  If not, see <http:#www.gnu.org/licenses/>.
+
 include(../../version.pri)
 include(../../common.pri)
 
@@ -42,5 +59,3 @@ SOURCES += settings.cc pdfconverter.cc \
 
 SOURCES += wkhtmltopdf.cc arguments.cc commandlineparser.cc \
            docparts.cc
-           
-

+ 85 - 82
src/pdf/pdfconverter.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "pdfconverter_p.hh"
 #include <QAuthenticator>
 #include <QDateTime>
@@ -29,8 +33,8 @@
 #include <qapplication.h>
 #include <qfileinfo.h>
 #ifdef Q_OS_WIN32
-#include <io.h>
 #include <fcntl.h>
+#include <io.h>
 #endif
 
 using namespace wkhtmltopdf;
@@ -48,7 +52,7 @@ struct StreamDumper {
 		stream.setCodec("UTF-8");
 	}
 };
- 
+
 /*!
   \file pageconverter.hh
   \brief Defines the PdfConverter class
@@ -73,12 +77,12 @@ PdfConverterPrivate::PdfConverterPrivate(Global & s, PdfConverter & o) :
 	, outline(0), tocPrinter(0)
 #endif
 {
-		
+
 #ifdef  __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 	phaseDescriptions.push_back("Loading pages");
 	phaseDescriptions.push_back("Counting pages");
 	phaseDescriptions.push_back("Loading TOC");
-	phaseDescriptions.push_back("Resolving links");	
+	phaseDescriptions.push_back("Resolving links");
 	phaseDescriptions.push_back("Loading headers and footers");
 #else
 	phaseDescriptions.push_back("Loading page");
@@ -91,7 +95,7 @@ PdfConverterPrivate::PdfConverterPrivate(Global & s, PdfConverter & o) :
 	connect(&pageLoader, SIGNAL(error(QString)), this, SLOT(forwardError(QString)));
 	connect(&pageLoader, SIGNAL(warning(QString)), this, SLOT(forwardWarning(QString)));
 
-#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__	
+#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 	connect(&hfLoader, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int)));
 	connect(&hfLoader, SIGNAL(loadFinished(bool)), this, SLOT(headersLoaded(bool)));
 	connect(&hfLoader, SIGNAL(error(QString)), this, SLOT(forwardError(QString)));
@@ -120,7 +124,7 @@ void PdfConverterPrivate::beginConvert() {
 	currentPhase=0;
 	errorCode=0;
 
-#ifndef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__	
+#ifndef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 	if (objects.size() > 1) {
 		emit out.error("This version of wkhtmltopdf is build against an unpatched version of QT, and does not support more then one input document.");
 		fail();
@@ -130,8 +134,8 @@ void PdfConverterPrivate::beginConvert() {
 
 	for (QList<PageObject>::iterator i=objects.begin(); i != objects.end(); ++i) {
 		PageObject & o=*i;
-		settings::Page & s = o.settings;		
-		
+		settings::Page & s = o.settings;
+
 		if (!s.header.htmlUrl.isEmpty() && looksLikeHtmlAndNotAUrl(s.header.htmlUrl)) {
 			emit out.error("--header-html should be a URL and not a string containing HTML code.");
 			fail();
@@ -152,7 +156,7 @@ void PdfConverterPrivate::beginConvert() {
 		}
 	}
 
-	
+
 	emit out.phaseChanged();
 	loadProgress(0);
 
@@ -167,7 +171,7 @@ void PdfConverterPrivate::beginConvert() {
 void PdfConverterPrivate::pagesLoaded(bool ok) {
 	if (errorCode == 0) errorCode = pageLoader.httpErrorCode();
 	if (!ok) {
-		fail(); 
+		fail();
 		return;
 	}
 
@@ -184,7 +188,7 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 	printer = new QPrinter(settings.resolution);
 	if (settings.dpi != -1) printer->setResolution(settings.dpi);
 	//Tell the printer object to print the file <out>
-	
+
 	printer->setOutputFormat(
 		(settings.outputFormat == "ps" || (settings.outputFormat == "" && settings.out.endsWith(".ps", Qt::CaseInsensitive)))?
 	    QPrinter::PostScriptFormat : QPrinter::PdfFormat
@@ -204,14 +208,13 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 	printer->setPageMargins(settings.margin.left.first, settings.margin.top.first,
 							settings.margin.right.first, settings.margin.bottom.first,
 							settings.margin.left.second);
-	
-	if((settings.size.height.first != -1) && (settings.size.width.first != -1)) {
+
+	if ((settings.size.height.first != -1) && (settings.size.width.first != -1)) {
 		printer->setPaperSize(QSizeF(settings.size.width.first,settings.size.height.first), settings.size.height.second);
-	}
-	else {
+	} else {
 		printer->setPaperSize(settings.size.pageSize);
 	}
-	
+
 	printer->setOrientation(settings.orientation);
 	printer->setColorMode(settings.colorMode);
 
@@ -233,11 +236,11 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 	printer->printEngine()->setProperty(QPrintEngine::PPK_ImageDPI, settings.imageDPI);
 
 	painter = new QPainter();
-	
+
 	title = settings.documentTitle;
-	for(int d=0; d < objects.size(); ++d) {
+	for (int d=0; d < objects.size(); ++d) {
 		if (title != "") break;
-		if (!objects[d].loaderObject || objects[d].loaderObject->skip || 
+		if (!objects[d].loaderObject || objects[d].loaderObject->skip ||
 			objects[d].settings.isTableOfContent) continue;
 		title = objects[d].page->mainFrame()->title();
 	}
@@ -247,7 +250,7 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 		fail();
 		return;
 	}
-	
+
 	currentPhase = 1;
 	emit out.phaseChanged();
 	outline = new Outline(settings);
@@ -256,7 +259,7 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 	// * A visual ordering of the header element
 	// * The location and page number of each header
 	pageCount = 0;
-	for(int d=0; d < objects.size(); ++d) {
+	for (int d=0; d < objects.size(); ++d) {
 		PageObject & obj = objects[d];
 		if (obj.settings.isTableOfContent) {
 			obj.pageCount = 1;
@@ -265,7 +268,7 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 			continue;
 		}
 		if (!obj.loaderObject || obj.loaderObject->skip) continue;
-			
+
 		int tot = objects.size();
 		progressString = QString("Object ")+QString::number(d+1)+QString(" of ")+QString::number(tot);
 		emit out.progressChanged((d+1)*100 / tot);
@@ -274,14 +277,14 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 		QWebPrinter wp(obj.page->mainFrame(), printer, *painter);
 		obj.pageCount = objects[d].settings.pagesCount? wp.pageCount(): 0;
 		pageCount += objects[d].pageCount;
-		
-		outline->addWebPage(obj.page->mainFrame()->title(), wp, obj.page->mainFrame(), 
+
+		outline->addWebPage(obj.page->mainFrame()->title(), wp, obj.page->mainFrame(),
 							obj.settings, obj.localLinks, obj.anchors);
 		painter->restore();
 	}
 
 	actualPages = pageCount * settings.copies;
-	
+
 	loadTocs();
 #endif
 }
@@ -293,10 +296,10 @@ void PdfConverterPrivate::loadHeaders() {
 	bool hf=false;
 
 	int pageNumber=1;
-	for(int d=0; d < objects.size(); ++d) {
+	for (int d=0; d < objects.size(); ++d) {
 		PageObject & obj = objects[d];
 		if (!obj.loaderObject || obj.loaderObject->skip) continue;
-				
+
 		settings::Page & ps = obj.settings;
 		for (int op=0; op < obj.pageCount; ++op) {
 			if (!ps.header.htmlUrl.isEmpty() || !ps.footer.htmlUrl.isEmpty()) {
@@ -314,9 +317,9 @@ void PdfConverterPrivate::loadHeaders() {
 	}
 	if (hf)
 		hfLoader.load();
-	else 
+	else
 		printDocument();
-#endif	
+#endif
 }
 
 
@@ -324,9 +327,9 @@ void PdfConverterPrivate::loadTocs() {
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 	std::swap(tocLoaderOld, tocLoader);
 	tocLoader->clearResources();
-	
+
 	bool toc=false;
-	for(int d=0; d < objects.size(); ++d) {
+	for (int d=0; d < objects.size(); ++d) {
 		PageObject & obj = objects[d];
 		settings::Page & ps = obj.settings;
 		if (!ps.isTableOfContent) continue;
@@ -335,11 +338,11 @@ void PdfConverterPrivate::loadTocs() {
 		QString style = obj.tocStyleFile.create(".xsl");
 		StreamDumper styleDump(style);
 		dumpDefaultTOCStyleSheet(styleDump.stream, ps.toc);
-		
+
 		QString path = obj.tocFile.create(".xml");
 		StreamDumper sd(path);
 		outline->dump(sd.stream, style);
-		
+
 		obj.loaderObject = tocLoader->addResource(path, ps.load);
 		obj.page = &obj.loaderObject->page;
 		PageObject::webPageToObject[obj.page] = &obj;
@@ -353,7 +356,7 @@ void PdfConverterPrivate::loadTocs() {
 			emit out.phaseChanged();
 		}
 		tocLoader->load();
-	} else 
+	} else
 		tocLoaded(true);
 #endif
 }
@@ -381,11 +384,11 @@ void PdfConverterPrivate::findLinks(QWebFrame * frame, QVector<QPair<QWebElement
 				if (ulocal) {
 					PageObject * p = urlToPageObj[href.toString(QUrl::RemoveFragment)];
 					QWebElement e;
-					if (!href.hasFragment()) 
+					if (!href.hasFragment())
 						e = p->page->mainFrame()->findFirstElement("body");
 					else {
 						e = p->page->mainFrame()->findFirstElement("a[name=\""+href.fragment()+"\"]");
-						if(e.isNull()) 
+						if (e.isNull())
 							e = p->page->mainFrame()->findFirstElement("*[id=\""+href.fragment()+"\"]");
 					}
 					if (!e.isNull()) {
@@ -416,9 +419,9 @@ void PdfConverterPrivate::beginPage(int actualPage) {
 }
 
 void PdfConverterPrivate::endPage(PageObject & object, bool hasHeaderFooter, int objectPage, int pageNumber) {
-	typedef QPair<QWebElement, QString> p_t;		
+	typedef QPair<QWebElement, QString> p_t;
 	settings::Page & s = object.settings;
-	if(hasHeaderFooter) {
+	if (hasHeaderFooter) {
 		QHash<QString, QString> parms;
 		fillParms(parms, pageNumber, object);
 
@@ -426,10 +429,10 @@ void PdfConverterPrivate::endPage(PageObject & object, bool hasHeaderFooter, int
 		//We save it here and restore some sane defaults
 		painter->save();
 		painter->resetTransform();
-						
+
 		int h=printer->height();
 		int w=printer->width();
-						
+
 		double spacing = s.header.spacing * printer->height() / printer->heightMM();
 		//If needed draw the header line
 		if (s.header.line) painter->drawLine(0, -spacing, w, -spacing);
@@ -441,7 +444,7 @@ void PdfConverterPrivate::endPage(PageObject & object, bool hasHeaderFooter, int
 		painter->drawText(r, Qt::AlignTop | Qt::AlignLeft, hfreplace(s.header.left, parms));
 		painter->drawText(r, Qt::AlignTop | Qt::AlignHCenter, hfreplace(s.header.center, parms));
 		painter->drawText(r, Qt::AlignTop | Qt::AlignRight, hfreplace(s.header.right, parms));
-		
+
 		spacing = s.footer.spacing * printer->height() / printer->heightMM();
 		//IF needed draw the footer line
 		if (s.footer.line) painter->drawLine(0, h + spacing, w, h + spacing);
@@ -453,7 +456,7 @@ void PdfConverterPrivate::endPage(PageObject & object, bool hasHeaderFooter, int
 		painter->drawText(r, Qt::AlignBottom | Qt::AlignLeft, hfreplace(s.footer.left, parms));
 		painter->drawText(r, Qt::AlignBottom | Qt::AlignHCenter, hfreplace(s.footer.center, parms));
 		painter->drawText(r, Qt::AlignBottom | Qt::AlignRight, hfreplace(s.footer.right, parms));
-		
+
 		//Restore Webkit's crazy scaling and font settings
 		painter->restore();
 	}
@@ -470,11 +473,11 @@ void PdfConverterPrivate::endPage(PageObject & object, bool hasHeaderFooter, int
 		QVector<p_t> external;
 		QHash<QString, QWebElement> anchors;
 		findLinks(header->mainFrame(), local, external, anchors);
-		foreach(const p_t & p, local) {
+		foreach (const p_t & p, local) {
 			QRectF r = wp.elementLocation(p.first).second;
 			painter->addLink(r, p.second);
 		}
-		foreach(const p_t & p, external) {
+		foreach (const p_t & p, external) {
 			QRectF r = wp.elementLocation(p.first).second;
 			painter->addHyperlink(r, QUrl(p.second));
 		}
@@ -489,16 +492,16 @@ void PdfConverterPrivate::endPage(PageObject & object, bool hasHeaderFooter, int
 		double spacing = s.footer.spacing * printer->height() / printer->heightMM();
 		painter->translate(0, printer->height()+ spacing);
 		QWebPrinter wp(footer->mainFrame(), printer, *painter);
-		
+
 		QVector<p_t> local;
 		QVector<p_t> external;
 		QHash<QString, QWebElement> anchors;
 		findLinks(footer->mainFrame(), local, external, anchors);
-		foreach(const p_t & p, local) {
+		foreach (const p_t & p, local) {
 			QRectF r = wp.elementLocation(p.first).second;
 			painter->addLink(r, p.second);
 		}
-		foreach(const p_t & p, external) {
+		foreach (const p_t & p, external) {
 			QRectF r = wp.elementLocation(p.first).second;
 			painter->addHyperlink(r, QUrl(p.second));
 		}
@@ -518,14 +521,14 @@ void PdfConverterPrivate::tocLoaded(bool ok) {
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 	bool changed=false;
 	pageCount = 0;
-	for(int d=0; d < objects.size(); ++d) {
+	for (int d=0; d < objects.size(); ++d) {
 		if (!objects[d].loaderObject || objects[d].loaderObject->skip) continue;
 
 		if (!objects[d].settings.isTableOfContent) {
 			pageCount += objects[d].pageCount;
 			continue;
 		}
-			
+
 		painter->save();
 		QWebPrinter wp(objects[d].page->mainFrame(), printer, *painter);
 		int pc = objects[d].settings.pagesCount? wp.pageCount(): 0;
@@ -545,15 +548,15 @@ void PdfConverterPrivate::tocLoaded(bool ok) {
 		//Find and resolve all local links
 		currentPhase = 3;
 		emit out.phaseChanged();
-		
+
 		QHash<QString, int> urlToDoc;
-		for(int d=0; d < objects.size(); ++d) {
+		for (int d=0; d < objects.size(); ++d) {
 			if (!objects[d].loaderObject || objects[d].loaderObject->skip) continue;
 			if (objects[d].settings.isTableOfContent) continue;
 			urlToPageObj[ objects[d].page->mainFrame()->url().toString(QUrl::RemoveFragment) ] = &objects[d];
 		}
-		
-		for(int d=0; d < objects.size(); ++d) {
+
+		for (int d=0; d < objects.size(); ++d) {
 			if (!objects[d].loaderObject || objects[d].loaderObject->skip) continue;
 			progressString = QString("Object ")+QString::number(d+1)+QString(" of ")+QString::number(objects.size());
 			emit out.progressChanged((d+1)*100 / objects.size());
@@ -584,7 +587,7 @@ void PdfConverterPrivate::printDocument() {
 	emit out.progressChanged(-1);
 #else
  	int actualPage=1;
-		
+
  	int cc=settings.collate?settings.copies:1;
  	int pc=settings.collate?1:settings.copies;
 
@@ -594,9 +597,9 @@ void PdfConverterPrivate::printDocument() {
 	progressString = "Preparing";
 	emit out.progressChanged(0);
 
-	for(int cc_=0; cc_ < cc; ++cc_) {
+	for (int cc_=0; cc_ < cc; ++cc_) {
 		int pageNumber=1;
-		for(int d=0; d < objects.size(); ++d) {
+		for (int d=0; d < objects.size(); ++d) {
 			PageObject & obj = objects[d];
 			if (!obj.loaderObject || obj.loaderObject->skip) continue;
 			const settings::Page & ps = obj.settings;
@@ -608,49 +611,49 @@ void PdfConverterPrivate::printDocument() {
 			painter->save();
 
 			if (ps.produceForms) {
-				foreach(QWebElement elm, obj.page->mainFrame()->findAllElements("input")) 
+				foreach (QWebElement elm, obj.page->mainFrame()->findAllElements("input"))
 				 	elm.setStyleProperty("color","white");
-				foreach(QWebElement elm, obj.page->mainFrame()->findAllElements("textarea")) 
+				foreach (QWebElement elm, obj.page->mainFrame()->findAllElements("textarea"))
 				 	elm.setStyleProperty("color","white");
 			}
 
-			//output 
+			//output
 			QWebPrinter wp(obj.page->mainFrame(), printer, *painter);
 			QString l1=obj.page->mainFrame()->url().path().split("/").back()+"#";
 			QString l2=obj.page->mainFrame()->url().toString() + "#";
 
-			outline->fillAnchors(d, obj.anchors);				
+			outline->fillAnchors(d, obj.anchors);
 
 			//Sort anchors and links by page
 			QHash<int, QHash<QString, QWebElement> > myAnchors;
 			QHash<int, QVector< QPair<QWebElement,QString> > > myLocalLinks;
 			QHash<int, QVector< QPair<QWebElement,QString> > > myExternalLinks;
-			for(QHash<QString, QWebElement>::iterator i=obj.anchors.begin();
+			for (QHash<QString, QWebElement>::iterator i=obj.anchors.begin();
 				i != obj.anchors.end(); ++i)
 				myAnchors[ wp.elementLocation(i.value()).first][i.key()] = i.value();
 
-			for(QVector< QPair<QWebElement,QString> >::iterator i=obj.localLinks.begin();
+			for (QVector< QPair<QWebElement,QString> >::iterator i=obj.localLinks.begin();
 				i != obj.localLinks.end(); ++i)
 				myLocalLinks[wp.elementLocation(i->first).first].push_back(*i);
 
-			for(QVector< QPair<QWebElement,QString> >::iterator i=obj.externalLinks.begin();
+			for (QVector< QPair<QWebElement,QString> >::iterator i=obj.externalLinks.begin();
 				i != obj.externalLinks.end(); ++i)
 				myExternalLinks[wp.elementLocation(i->first).first].push_back(*i);
 
 			QHash<int, QVector<QWebElement> > myFormElements;
 			if (ps.produceForms) {
-				foreach(const QWebElement & elm, obj.page->mainFrame()->findAllElements("input")) 
+				foreach (const QWebElement & elm, obj.page->mainFrame()->findAllElements("input"))
 					myFormElements[wp.elementLocation(elm).first].push_back(elm);
-				foreach(const QWebElement & elm, obj.page->mainFrame()->findAllElements("textarea")) 
+				foreach (const QWebElement & elm, obj.page->mainFrame()->findAllElements("textarea"))
 					myFormElements[wp.elementLocation(elm).first].push_back(elm);
 			}
 			emit out.producingForms( obj.settings.produceForms);
-			for(int p=0; p < wp.pageCount(); ++p) {
-				for(int pc_=0; pc_ < pc; ++pc_) {
+			for (int p=0; p < wp.pageCount(); ++p) {
+				for (int pc_=0; pc_ < pc; ++pc_) {
 					beginPage(actualPage);
 					wp.spoolPage(p+1);
 
-					foreach(QWebElement elm, myFormElements[p+1]) {
+					foreach (QWebElement elm, myFormElements[p+1]) {
 						QString type = elm.attribute("type");
 						QString tn = elm.tagName();
 						QString name = elm.attribute("name");
@@ -658,8 +661,8 @@ void PdfConverterPrivate::printDocument() {
 							painter->addTextField(
 								wp.elementLocation(elm).second,
 								tn == "TEXTAREA"?elm.toPlainText():elm.attribute("value"),
-								name, 
-								tn == "TEXTAREA",		   
+								name,
+								tn == "TEXTAREA",
 								type == "password",
 								elm.evaluateJavaScript("this.readonly;").toBool(),
 								elm.hasAttribute("maxlength")?elm.attribute("maxlength").toInt():-1
@@ -667,23 +670,23 @@ void PdfConverterPrivate::printDocument() {
 						} else if (type == "checkbox") {
 							painter->addCheckBox(
 								wp.elementLocation(elm).second,
-								elm.evaluateJavaScript("this.checked;").toBool(), 
+								elm.evaluateJavaScript("this.checked;").toBool(),
 								name,
 								elm.evaluateJavaScript("this.readonly;").toBool());
 						}
 					}
-					for(QHash<QString, QWebElement>::iterator i=myAnchors[p+1].begin();
+					for (QHash<QString, QWebElement>::iterator i=myAnchors[p+1].begin();
 						i != myAnchors[p+1].end(); ++i) {
 						QRectF r = wp.elementLocation(i.value()).second;
 						painter->addAnchor(r, i.key());
 					}
-					for(QVector< QPair<QWebElement,QString> >::iterator i=myLocalLinks[p+1].begin();
-						i != myLocalLinks[p+1].end(); ++i)  {
+					for (QVector< QPair<QWebElement,QString> >::iterator i=myLocalLinks[p+1].begin();
+						i != myLocalLinks[p+1].end(); ++i) {
 						QRectF r = wp.elementLocation(i->first).second;
 						painter->addLink(r, i->second);
 					}
-					for(QVector< QPair<QWebElement,QString> >::iterator i=myExternalLinks[p+1].begin();
-						i != myExternalLinks[p+1].end(); ++i)  {
+					for (QVector< QPair<QWebElement,QString> >::iterator i=myExternalLinks[p+1].begin();
+						i != myExternalLinks[p+1].end(); ++i) {
 						QRectF r = wp.elementLocation(i->first).second;
 						painter->addHyperlink(r, QUrl(i->second));
 					}
@@ -710,7 +713,7 @@ void PdfConverterPrivate::printDocument() {
 #ifdef Q_OS_WIN32
 		_setmode(_fileno(stdout), _O_BINARY);
 #endif
-		if( !i.open(QIODevice::ReadOnly) || 
+		if ( !i.open(QIODevice::ReadOnly) ||
 			!o.open(stdout,QIODevice::WriteOnly) ||
 			!MultiPageLoader::copyFile(i,o) ) {
 			emit out.error("Count not write to stdout");
@@ -727,14 +730,14 @@ void PdfConverterPrivate::printDocument() {
 	emit out.phaseChanged();
 	convertionDone = true;
 	emit out.finished(true);
-	
+
 	qApp->exit(0); // quit qt's event handling
 }
 
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 QWebPage * PdfConverterPrivate::loadHeaderFooter(QString url, const QHash<QString, QString> & parms, const settings::Page & ps) {
 	QUrl u = MultiPageLoader::guessUrlFromString(url);
-	for(QHash<QString, QString>::const_iterator i=parms.begin(); i != parms.end(); ++i)
+	for (QHash<QString, QString>::const_iterator i=parms.begin(); i != parms.end(); ++i)
 		u.addQueryItem(i.key(), i.value());
 	return &hfLoader.addResource(u, ps.load)->page;
 
@@ -746,7 +749,7 @@ QWebPage * PdfConverterPrivate::loadHeaderFooter(QString url, const QHash<QStrin
  */
 QString PdfConverterPrivate::hfreplace(const QString & q, const QHash<QString, QString> & parms) {
 	QString r=q;
-	for(QHash<QString, QString>::const_iterator i=parms.begin(); i != parms.end(); ++i)
+	for (QHash<QString, QString>::const_iterator i=parms.begin(); i != parms.end(); ++i)
 		r=r.replace("["+i.key()+"]", i.value(), Qt::CaseInsensitive);
 	return r;
 }
@@ -762,13 +765,13 @@ void PdfConverterPrivate::clearResources() {
 
 	if (outline) delete outline;
 	outline=0;
-	
+
 	tocPrinter = 0;
 #endif
 
 	if (printer) delete printer;
 	printer = 0;
-	
+
 	if (painter) delete painter;
 	painter = 0;
 }

+ 8 - 4
src/pdf/pdfconverter.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,10 +17,11 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#ifndef __PAGECONVERTER_HH__
-#define __PAGECONVERTER_HH__
-#include "settings.hh"
+
+#ifndef __PDFCONVERTER_HH__
+#define __PDFCONVERTER_HH__
 #include "converter.hh"
+#include "settings.hh"
 
 namespace wkhtmltopdf {
 
@@ -42,4 +46,4 @@ signals:
 };
 
 }
-#endif //__PAGECONVERTER_HH__
+#endif //__PDFCONVERTER_HH__

+ 15 - 10
src/pdf/pdfconverter_p.hh

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,12 +17,14 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#ifndef __TEXTUALFEEDBACK_P_HH__
-#define __TEXTUALFEEDBACK_P_HH__
+
+#ifndef __PDFCONVERTER_P_HH__
+#define __PDFCONVERTER_P_HH__
+#include "converter_p.hh"
 #include "multipageloader.hh"
 #include "outline.hh"
 #include "pdfconverter.hh"
-#include "converter_p.hh"
+#include "settings.hh"
 #include "tempfile.hh"
 #include "tocprinter.hh"
 #include <QAtomicInt>
@@ -30,7 +36,6 @@
 #include <QWaitCondition>
 #include <QWebPage>
 #include <qnetworkreply.h>
-#include "settings.hh"
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #include <QWebElement>
 #endif
@@ -40,7 +45,7 @@ namespace wkhtmltopdf {
 class PageObject {
 public:
 	static QMap<QWebPage *, PageObject *> webPageToObject;
-	
+
 	settings::Page settings;
 	LoaderObject * loaderObject;
 	QWebPage * page;
@@ -77,7 +82,7 @@ public:
 	~PageObject() {
 		clear();
 	}
-	
+
 };
 
 class PdfConverterPrivate: public ConverterPrivate {
@@ -111,7 +116,7 @@ private:
 	MultiPageLoader hfLoader;
 	MultiPageLoader tocLoader1;
 	MultiPageLoader tocLoader2;
-	
+
 	MultiPageLoader * tocLoader;
 	MultiPageLoader * tocLoaderOld;
 
@@ -133,7 +138,7 @@ public slots:
 	void pagesLoaded(bool ok);
 	void tocLoaded(bool ok);
 	void headersLoaded(bool ok);
-	
+
 	void printDocument();
 
 	void beginConvert();
@@ -144,4 +149,4 @@ public slots:
 };
 
 }
-#endif //__TEXTUALFEEDBACK_P_HH__
+#endif //__PDFCONVERTER_P_HH__

+ 16 - 14
src/pdf/settings.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,8 +17,9 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#include <settings.hh>
+
 #include <QMap>
+#include <settings.hh>
 #include <stdexcept>
 namespace wkhtmltopdf {
 namespace settings {
@@ -68,7 +72,7 @@ QMap<QString, QPrinter::PageSize> pageSizeMap() {
 */
 QPrinter::PageSize strToPageSize(const char * s, bool * ok) {
 	QMap<QString,QPrinter::PageSize> map = pageSizeMap();
-	for(QMap<QString,QPrinter::PageSize>::const_iterator i=map.begin(); i != map.end(); ++i) {
+	for (QMap<QString,QPrinter::PageSize>::const_iterator i=map.begin(); i != map.end(); ++i) {
 		if (!i.key().compare(s, Qt::CaseInsensitive) ) continue;
 		if (ok) *ok=true;
 		return i.value();
@@ -79,7 +83,7 @@ QPrinter::PageSize strToPageSize(const char * s, bool * ok) {
 
 QString pageSizeToStr(QPrinter::PageSize ps) {
 	QMap<QString,QPrinter::PageSize> map = pageSizeMap();
-	for(QMap<QString,QPrinter::PageSize>::const_iterator i=map.begin(); i != map.end(); ++i) {
+	for (QMap<QString,QPrinter::PageSize>::const_iterator i=map.begin(); i != map.end(); ++i) {
 		if (i.value() == ps) return i.key();
 	}
 	return "";
@@ -140,7 +144,7 @@ UnitReal strToUnitReal(const char * o, bool * ok) {
 	else if (!strcasecmp(o+i,"point") || !strcasecmp(o+i,"pt"))
 		u=QPrinter::Point;
 	else {
-		if(ok) ok=false;
+		if (ok) ok=false;
 		return UnitReal(QString(o).left(i).toDouble()*s, u);
 	}
 	return UnitReal(QString(o).left(i).toDouble(ok)*s, u);
@@ -153,14 +157,14 @@ QString unitRealToStr(const UnitReal & ur, bool * ok) {
 		return "";
 	}
 	if (ok) *ok=true;
-	switch(ur.second) {
+	switch (ur.second) {
 	case QPrinter::Didot: c = "didot"; break;
 	case QPrinter::Inch: c = "in"; break;
 	case QPrinter::Pica: c = "pica"; break;
 	case QPrinter::DevicePixel: c = "px"; break;
 	case QPrinter::Point: c = "pt"; break;
 	case QPrinter::Millimeter: c = "mm"; break;
-	default: 
+	default:
 		if (ok) *ok=false; break;
 	}
 	return QString("%1%2").arg(ur.first).arg(c);
@@ -168,7 +172,7 @@ QString unitRealToStr(const UnitReal & ur, bool * ok) {
 
 
 Size::Size():
-	pageSize(QPrinter::A4), 
+	pageSize(QPrinter::A4),
 	height(UnitReal(-1,QPrinter::Millimeter)),
 	width(UnitReal(-1,QPrinter::Millimeter)) {}
 
@@ -192,10 +196,10 @@ Global::Global():
 	quiet(false),
 	useGraphics(false),
 	orientation(QPrinter::Portrait),
-	colorMode(QPrinter::Color), 
+	colorMode(QPrinter::Color),
 	resolution(QPrinter::HighResolution),
 	dpi(-1),
-	pageOffset(0), 
+	pageOffset(0),
 	copies(1),
 	collate(true),
 	outline(true),
@@ -204,9 +208,8 @@ Global::Global():
 	out("-"),
 	documentTitle(""),
 	useCompression(true),
-	imageDPI(600), 
-	imageQuality(94)
-{};
+	imageDPI(600),
+	imageQuality(94) {};
 
 TableOfContent::TableOfContent():
 	useDottedLines(true),
@@ -214,8 +217,7 @@ TableOfContent::TableOfContent():
 	forwardLinks(true),
 	backLinks(false),
 	indentation("1em"),
-	fontScale(0.8)
-{}
+	fontScale(0.8) {}
 
 Page::Page():
 	useExternalLinks(true),

+ 27 - 23
src/pdf/settings.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,13 +17,14 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __SETTINGS_HH__
 #define __SETTINGS_HH__
-#include <QString>
-#include <QNetworkProxy>
-#include <QPrinter>
 #include "loadsettings.hh"
 #include "websettings.hh"
+#include <QNetworkProxy>
+#include <QPrinter>
+#include <QString>
 
 namespace wkhtmltopdf {
 namespace settings {
@@ -39,12 +43,12 @@ struct Margin {
 	//!Margin applied to the leftp of the page
 	UnitReal left;
 };
-	
+
 /*! \brief Settings considering page size */
 struct Size {
 	Size();
 	//! What size paper should we use
-	QPrinter::PageSize pageSize; 
+	QPrinter::PageSize pageSize;
 	//!Height of the page
 	UnitReal height;
 	//!Width of the page
@@ -71,7 +75,7 @@ struct TableOfContent {
 
 /*! \brief Class holding all user setting.
     This class holds all the user settings, settings can be filled in by hand,
-    or with other methods. 
+    or with other methods.
     \sa CommandLineParser::parse()
 */
 struct Global {
@@ -81,23 +85,23 @@ struct Global {
 	Size size;
 
 	//! Be less verbose
-	bool quiet; 
-	
+	bool quiet;
+
 	//! Should we use the graphics system
 	bool useGraphics;
 
 	//! Should we orientate in landscape or portrate
-	QPrinter::Orientation orientation; 
+	QPrinter::Orientation orientation;
 
 	//! Color or grayscale
-	QPrinter::ColorMode colorMode; 
+	QPrinter::ColorMode colorMode;
 
 	//! What overall resolution should we use
-	QPrinter::PrinterMode resolution; 
+	QPrinter::PrinterMode resolution;
 
 	//! What dpi should be used when printing
 	int dpi;
-	
+
 	//! When pagenumbers are printed, apply this offset to them all
 	int pageOffset;
 
@@ -118,13 +122,13 @@ struct Global {
 
 	//! The file where in to store the output
 	QString out;
-	
+
 	QString documentTitle;
 
 	bool useCompression;
 
 	//! Margin related settings
-	Margin margin;	
+	Margin margin;
 
 	//! Specify the output format we should use
 	QString outputFormat;
@@ -160,29 +164,29 @@ struct Page {
 	Page();
 	//! Settings regarding the TOC
 	TableOfContent toc;
-	
+
 	QString page;
-	
+
 	//! Header related settings
 	HeaderFooter header;
-	
+
 	//! Header related settings
 	HeaderFooter footer;
-	
+
 	//! Should external links be links in the PDF
 	bool useExternalLinks;
-	
+
 	//! Should internal links be links in the PDF
 	bool useLocalLinks;
-			
+
 	//! Replacements
 	QList< QPair<QString, QString> > replacements;
-	
+
 	//! Convert forms on the pages into PDF forms
 	bool produceForms;
-	
+
 	LoadPage load;
-	
+
 	Web web;
 
 	bool includeInOutline;

+ 21 - 16
src/pdf/tocprinter.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,17 +17,18 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#include "tocprinter.hh"
+
 #include "outline_p.hh"
 #include "settings.hh"
+#include "tocprinter.hh"
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 
 
 typedef QPair<int, OutlineItem *> line_t;
 /*!
-  We imploy a cheep strategy of not using a render tree, 
+  We imploy a cheep strategy of not using a render tree,
   insted we just store the state render state for every page start,
-  the render state is uniquly defined by a OutlineItem, 
+  the render state is uniquly defined by a OutlineItem,
  */
 class TocPrinterPrivate {
 public:
@@ -37,7 +42,7 @@ public:
 	QVector<OutlineItem *> pageItems;
 
 	QList< QList< line_t > > pages;
-	
+
 	TocPrinterPrivate(Outline * o, QPrinter * pr, QPainter & pa);
 	void revLinkChildren(OutlineItem * i, QVector<QPair<QWebElement, QString> > & links, int level);
 	void renderPage(OutlineItem * & cur, bool first, bool dry);
@@ -59,7 +64,7 @@ void TocPrinterPrivate::layoutChildren(OutlineItem * item, double & y, int level
 	QRect pr = printer->pageRect();
 	foreach (OutlineItem * i, item->children) {
 		y += step[level];
-		if(y > pr.height()) {
+		if (y > pr.height()) {
 			pages.push_back( QList< QPair<int, OutlineItem *> >() );
 			y = step[level];
 		}
@@ -74,13 +79,13 @@ TocPrinterPrivate::TocPrinterPrivate(Outline * o, QPrinter * pr, QPainter & pa):
 	painter.save();
 	painter.resetTransform();
 	QRectF pageRect = printer->pageRect();
-	for(uint level=0; level < levels; ++level) {
+	for (uint level=0; level < levels; ++level) {
 		painter.setFont(QFont(s.fontName, s.fontSize[level]));
 		step[level] = painter.fontMetrics().height();
 		dw[level] = painter.boundingRect(pageRect, Qt::AlignRight | Qt::AlignTop, ".").width();
 	}
 	painter.setFont(QFont(s.fontName, s.captionFontSize));
-	//The height of the caption	
+	//The height of the caption
 	double y = painter.boundingRect(pageRect, Qt::AlignTop | Qt::AlignHCenter, s.captionText).height() * 3;
 	painter.restore();
 	pages.push_back( QList< QPair<int, OutlineItem *> >() );
@@ -97,11 +102,11 @@ TocPrinterPrivate::TocPrinterPrivate(Outline * o, QPrinter * pr, QPainter & pa):
 	pages.back().push_back( qMakePair(0, toc) );
 
 	foreach (OutlineItem * i, o->d->documentOutlines)
-		layoutChildren(i, y, 0); 	
+		layoutChildren(i, y, 0);
 
 	outline->d->pageCount += pages.size();
 
-	foreach (OutlineItem * i, outline->d->documentOutlines) 
+	foreach (OutlineItem * i, outline->d->documentOutlines)
 		incChildren(i);
 
 	outline->d->documentOutlines.push_front(root);
@@ -156,11 +161,11 @@ void TocPrinter::spoolPage(int page) {
 	double y = 0;
 	const Settings::TOCSettings & s = d->outline->d->settings.toc;
 	QRect pr = d->printer->pageRect();
-	
-	if(page == 0) {
+
+	if (page == 0) {
 		double h = d->painter.boundingRect(pr,Qt::AlignTop | Qt::AlignHCenter, s.captionText).height();
 		QRect r((int)h,0,pr.width(),(int)h*3);
-		
+
 		d->painter.setFont(QFont(s.captionFontName.isEmpty()?s.fontName:s.captionFontName, s.captionFontSize));
 		d->painter.drawText(r, Qt::AlignVCenter | Qt::AlignHCenter, s.captionText);
 		d->painter.addAnchor(r, "_WK_TOC");
@@ -175,9 +180,9 @@ void TocPrinter::spoolPage(int page) {
 		}
 
 		double startX = pr.width()*s.indentation[lvl]/1000.0;
-		
+
 		QRectF lineRect(startX,y,pr.width()-startX, d->step[lvl]);
-		
+
 		QRectF br;
 		d->painter.drawText(lineRect,Qt::AlignBottom | Qt::AlignRight, QString(" ") + QString::number(line.second->page),&br);
 		QString v = line.second->value;
@@ -189,7 +194,7 @@ void TocPrinter::spoolPage(int page) {
 			for (int i=0; i < ndots; ++i) v.append(".");
 		}
 		d->painter.drawText(lineRect,Qt::AlignBottom | Qt::AlignLeft, v);
-		
+
 		QRectF r(0,y, pr.width(), d->step[lvl]);
 		if (s.forwardLinks)
 			d->painter.addLink(r, line.second->anchor);

+ 7 - 2
src/pdf/tocprinter.hh

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __TOCPRINTER_HH__
 #define __TOCPRINTER_HH__
 #include <QWebFrame>
@@ -38,4 +43,4 @@ private:
 
 }
 #endif //__EXTENSIVE_WKHTMLTOPDF_QT_HACK__
-#endif //__TOCPRINTER_HH
+#endif //__TOCPRINTER_HH__

+ 5 - 2
src/pdf/tocstylesheet.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outline_p.hh"
 #include "settings.hh"
 #include <QTextOStream>
@@ -67,7 +71,7 @@ void dumpDefaultTOCStyleSheet(QTextStream & stream, settings::TableOfContent & s
 	if (s.forwardLinks)
 		stream << "            <xsl:if test=\"@link\">" << endl
 			   << "              <xsl:attribute name=\"href\"><xsl:value-of select=\"@link\"/></xsl:attribute>" << endl
-			   << "            </xsl:if>" << endl;	
+			   << "            </xsl:if>" << endl;
 	stream << "            <xsl:if test=\"@backLink\">" << endl
 		   << "              <xsl:attribute name=\"name\"><xsl:value-of select=\"@backLink\"/></xsl:attribute>" << endl
 		   << "            </xsl:if>" << endl
@@ -85,4 +89,3 @@ void dumpDefaultTOCStyleSheet(QTextStream & stream, settings::TableOfContent & s
 }
 
 }
-

+ 10 - 5
src/pdf/wkhtmltopdf.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,10 +17,12 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparser.hh"
 #include "pdfconverter.hh"
 #include "progressfeedback.hh"
 #include "settings.hh"
+#include "utilities.hh"
 #include <QCleanlooksStyle>
 #include <QCommonStyle>
 #include <QPainter>
@@ -28,7 +34,6 @@
 #include <qapplication.h>
 #include <qglobal.h>
 #include <string.h>
-#include "utilities.hh"
 
 using namespace wkhtmltopdf::settings;
 using namespace wkhtmltopdf;
@@ -150,10 +155,10 @@ int main(int argc, char * argv[]) {
 			//parser.loadDefaults();
 			//Parse the arguments
 			parser.parseArguments(nargc, (const char**)nargv, true);
-			
+
 			PdfConverter converter(globalSettings);
 			ProgressFeedback feedback(globalSettings.quiet, converter);
-			foreach(const Page & page, pageSettings) 
+			foreach (const Page & page, pageSettings)
 				converter.addResource(page);
 
 			if (!converter.convert())
@@ -165,7 +170,7 @@ int main(int argc, char * argv[]) {
 	PdfConverter converter(globalSettings);
 	QObject::connect(&converter, SIGNAL(producingForms(bool)), style, SLOT(producingForms(bool)));
 	ProgressFeedback feedback(globalSettings.quiet, converter);
-	foreach(const Page & page, pageSettings) 
+	foreach (const Page & page, pageSettings)
 		converter.addResource(page);
 
 	bool success = converter.convert();

+ 6 - 2
src/shared/arghandler.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,12 +17,13 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outputter.hh"
 
 /*!
   \fn ArgHandler::getDesc() const
   Get the description of this switch
-*/  
+*/
 QString ArgHandler::getDesc() const {
 	return desc;
 }
@@ -27,5 +31,5 @@ QString ArgHandler::getDesc() const {
 /*!
   \fn ArgHandlerBase::~ArgHandlerBase()
   Dummy virtual destructor
-*/  
+*/
 ArgHandler::~ArgHandler() {}

+ 14 - 5
src/shared/arghandler.inl

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,13 +17,17 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef __ARGHANDLER_INL__
+#define __ARGHANDLER_INL__
+#include "commandlineparserbase.hh"
 #include "loadsettings.hh"
 
 template <typename T> class DstArgHandler: public ArgHandler {
 public:
  	T & dst;
  	DstArgHandler(T & d): dst(d) {};
-	
+
  	T & realDst(const CommandLineParserBase & cp, char * page) {
 		return * reinterpret_cast<T*>(cp.mapAddress(reinterpret_cast<char *>(&dst), page));
  	}
@@ -37,7 +45,7 @@ public:
 		p_t::realDst(cp, ps)=src;
 		return true;
 	}
-	
+
 	virtual QString getDesc() const {
 		if (src != p_t::dst) return p_t::desc;
 		return p_t::desc + " (default)";
@@ -51,7 +59,7 @@ struct StringPairCreator {
 	}
 };
 
-template <bool file> 
+template <bool file>
 struct PostItemCreator {
 	typedef wkhtmltopdf::settings::PostItem T;
 	inline T operator()(const QString & key, const QString & value) const {
@@ -93,7 +101,7 @@ struct StringListSetter: public DstArgHandler<QList<QString> > {
 /*!
   SomeSetter template method base
 */
-template <typename TT> 
+template <typename TT>
 struct SomeSetterTM {
 	typedef TT T;
 	//T strToT(const char * val, bool & ok);
@@ -200,3 +208,4 @@ template <typename T> struct Caller: public ArgHandler {
 		return T()(vals, s, page);
 	}
 };
+#endif //__ARGHANDLER_INL__

+ 16 - 11
src/shared/commandlineparserbase.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,9 +17,10 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#include <qwebframe.h>
+
 #include "commandlineparserbase.hh"
 #include "outputter.hh"
+#include <qwebframe.h>
 
 bool ahsort(const ArgHandler * a, const ArgHandler * b) {
 	QRegExp e("^(no|enable|disable)-");
@@ -40,27 +45,27 @@ bool ahsort(const ArgHandler * a, const ArgHandler * b) {
   \param doc Indicate to the outputter that it is writing documentation
 */
 void CommandLineParserBase::outputSwitches(Outputter * o, bool extended, bool doc) const {
-	foreach(const QString & section, sections) {
+	foreach (const QString & section, sections) {
 		QList<const ArgHandler *> display;
-		foreach(const ArgHandler * handler, sectionArgumentHandles[section]) {
+		foreach (const ArgHandler * handler, sectionArgumentHandles[section]) {
 #ifndef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
-			if(!doc && handler->qthack) continue;
-#else 
+			if (!doc && handler->qthack) continue;
+#else
 			Q_UNUSED(doc);
 #endif
-			if(!extended && handler->extended) continue;
+			if (!extended && handler->extended) continue;
 			display.push_back(handler);
 		}
 		qSort(display.begin(), display.end(), ahsort);
-		if(display.size() == 0) continue;
+		if (display.size() == 0) continue;
 		o->beginSection(section);
-		if(!sectionDesc[section].isEmpty()) {
+		if (!sectionDesc[section].isEmpty()) {
 			o->beginParagraph();
 			o->text(sectionDesc[section]);
 			o->endParagraph();
 		}
 		o->beginSwitch();
-		foreach(const ArgHandler * handler, display)
+		foreach (const ArgHandler * handler, display)
 			o->cswitch(handler);
 		o->endSwitch();
 		o->endSection();
@@ -125,7 +130,7 @@ void CommandLineParserBase::parseArg(int sections, const int argc, const char **
 				usage(stderr, false);
 				exit(1);
 			}
-		
+
 			if (!(k.value()->section & sections)) {
 				fprintf(stderr, "-%c specified in incorrect location\n\n", argv[c][j]);
 				usage(stderr, false);

+ 14 - 9
src/shared/commandlineparserbase.hh

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,8 +17,9 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#ifndef __COMMANDLINEPARSER_BASE_HH__
-#define __COMMANDLINEPARSER_BASE_HH__
+
+#ifndef __COMMANDLINEPARSERBASE_HH__
+#define __COMMANDLINEPARSERBASE_HH__
 #include "loadsettings.hh"
 #include "websettings.hh"
 class Outputter;
@@ -41,32 +46,32 @@ public:
 	QString currentSection;
 	bool currentExtended;
 	bool currentHack;
-	
+
 	QList<QString> sections;
 	QHash<QString, ArgHandler *> longToHandler;
 	QHash<char, ArgHandler *> shortToHandler;
 	QHash<QString, QList<ArgHandler *> > sectionArgumentHandles;
 	QHash<QString, QString> sectionDesc;
-	
+
 	//basearguments.cc
 	void section(QString s, QString desc="");
 	void mode(int m);
 	void qthack(bool);
 	void extended(bool);
-	
+
 	void addarg(QString, char, QString, ArgHandler * h, bool display=true);
 	void addDocArgs();
 	void addWebArgs(wkhtmltopdf::settings::Web & s);
 	void addGlobalLoadArgs(wkhtmltopdf::settings::LoadGlobal & s);
 	void addPageLoadArgs(wkhtmltopdf::settings::LoadPage & s);
-	
+
 	//commondocparts.cc
 	void outputName(Outputter * o) const;
 	void outputLicense(Outputter * o) const;
 	void outputAuthors(Outputter * o) const;
 	void outputStaticProblems(Outputter * o) const;
 	void outputProxyDoc(Outputter * o) const;
-	
+
 	//commandlineparserbase.cc
 	void outputSwitches(Outputter * o, bool extended, bool doc) const;
 	virtual char * mapAddress(char * d, char *) const {return d;}
@@ -78,4 +83,4 @@ public:
 	virtual void manpage(FILE * fd) const = 0;
 	virtual void readme(FILE * fd, bool html) const = 0;
 };
-#endif //__COMMANDLINEPARSER_BASE_HH__
+#endif //__COMMANDLINEPARSERBASE_HH__

+ 21 - 16
src/shared/commonarguments.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,8 +17,9 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#include "commandlineparserbase.hh"
+
 #include "arghandler.inl"
+#include "commandlineparserbase.hh"
 #include "loadsettings.hh"
 using namespace wkhtmltopdf::settings;
 
@@ -35,7 +40,7 @@ struct ProxyTM: public SomeSetterTM<Proxy> {
 	}
 };
 /*!
-  Argument handler setting a proxy variable  
+  Argument handler setting a proxy variable
  */
 typedef SomeSetter<ProxyTM> ProxySetter;
 
@@ -108,7 +113,7 @@ void CommandLineParserBase::mode(int m) {
 }
 
 /*!
-  Indicate whether the next arguments we add are "extended" and should not 
+  Indicate whether the next arguments we add are "extended" and should not
   be shown in a simple --help
   \param e Are the arguments extended
 */
@@ -134,7 +139,7 @@ void CommandLineParserBase::addarg(QString l, char s, QString d, ArgHandler * h,
 	h->section = currentMode;
 	h->extended = currentExtended;
 	longToHandler[l] = h;
-	if(s) shortToHandler[s] = h;
+	if (s) shortToHandler[s] = h;
 	sectionArgumentHandles[currentSection].push_back(h);
 }
 
@@ -156,19 +161,19 @@ void CommandLineParserBase::addDocArgs() {
 void CommandLineParserBase::addGlobalLoadArgs(LoadGlobal & s) {
 	extended(true);
 	qthack(false);
-	
+
     addarg("cookie-jar", 0, "Read and write cookies from and to the supplied cookie jar file", new QStrSetter(s.cookieJar, "path") );
 }
 
 void CommandLineParserBase::addWebArgs(Web & s) {
 	extended(true);
  	qthack(false);
-	
+
 	addarg("enable-plugins",0,"Enable installed plugins (plugins will likely not work)", new ConstSetter<bool>(s.enablePlugins,true));
  	addarg("disable-plugins",0,"Disable installed plugins", new ConstSetter<bool>(s.enablePlugins,false));
-	
+
 	addarg("minimum-font-size",0,"Minimum font size", new IntSetter(s.minimumFontSize,"int"));
-	
+
 #if QT_VERSION >= 0x040500 //Not printing the background was added in QT4.5
  	addarg("user-style-sheet",0,"Specify a user style sheet, to load with every page", new QStrSetter(s.userStyleSheet,"url"));
 #endif
@@ -176,11 +181,11 @@ void CommandLineParserBase::addWebArgs(Web & s) {
 #if QT_VERSION >= 0x040600
 	addarg("no-images",0,"Do not load or print images", new ConstSetter<bool>(s.loadImages, false));
 	addarg("images",0,"Do load or print images", new ConstSetter<bool>(s.loadImages, true));
-#endif	
+#endif
 
 	addarg("disable-javascript",'n',"Do not allow web pages to run javascript", new ConstSetter<bool>(s.enableJavascript,false));
 	addarg("enable-javascript",'n',"Do allow web pages to run javascript", new ConstSetter<bool>(s.enableJavascript,true));
-	
+
 	extended(true);
  	qthack(true);
 #if QT_VERSION >= 0x040600
@@ -201,22 +206,22 @@ void CommandLineParserBase::addPageLoadArgs(LoadPage & s) {
 	addarg("custom-header",0,"Set an additional HTTP header (repeatable)", new MapSetter<>(s.customHeaders, "name", "value"));
 	addarg("custom-header-propagation",0,"Add HTTP headers specified by --custom-header for each resource request.", new ConstSetter<bool>(s.repeatCustomHeaders, true));
 	addarg("no-custom-header-propagation",0,"Do not add HTTP headers specified by --custom-header for each resource request.", new ConstSetter<bool>(s.repeatCustomHeaders, true));
-	
+
 	addarg("javascript-delay",0,"Wait some milliseconds for javascript finish", new IntSetter(s.jsdelay,"msec"));
-	
+
 	addarg("zoom",0,"Use this zoom factor", new FloatSetter(s.zoomFactor,"float",1.0));
 	addarg("cookie",0,"Set an additional cookie (repeatable)", new MapSetter<>(s.cookies, "name", "value"));
 	addarg("post", 0, "Add an additional post field (repeatable)", new MapSetter<PostItemCreator<false> >(s.post, "name", "value"));
 	addarg("post-file", 0, "Post an additional file (repeatable)", new MapSetter<PostItemCreator<true> >(s.post, "name", "path"));
-		
+
 	addarg("disable-local-file-access", 0, "Do not allowed conversion of a local file to read in other local files, unless explecitily allowed with --allow", new ConstSetter<bool>(s.blockLocalFileAccess, true));
 	addarg("enable-local-file-access", 0, "Allowed conversion of a local file to read in other local files.", new ConstSetter<bool>(s.blockLocalFileAccess, false));
 	addarg("allow", 0, "Allow the file or files from the specified folder to be loaded (repeatable)", new StringListSetter(s.allowed,"path"));
-	
+
 	addarg("debug-javascript", 0,"Show javascript debugging output", new ConstSetter<bool>(s.debugJavascript, true));
 	addarg("no-debug-javascript", 0,"Do not show javascript debugging output", new ConstSetter<bool>(s.debugJavascript, false));
 #if QT_VERSION >= 0x040600
 	addarg("stop-slow-scripts", 0, "Stop slow running javascripts", new ConstSetter<bool>(s.stopSlowScripts, true));
 	addarg("no-stop-slow-scripts", 0, "Do not Stop slow running javascripts", new ConstSetter<bool>(s.stopSlowScripts, true));
-#endif	
+#endif
 }

+ 4 - 0
src/shared/commondocparts.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparserbase.hh"
 #include "outputter.hh"
 

+ 6 - 2
src/shared/converter.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,9 +17,10 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "converter_p.hh"
-#include <QWebFrame>
 #include "multipageloader.hh"
+#include <QWebFrame>
 #include <qapplication.h>
 namespace wkhtmltopdf {
 
@@ -78,7 +82,7 @@ void ConverterPrivate::cancel() {
 bool ConverterPrivate::convert() {
 	convertionDone=false;
 	beginConvert();
-	while(!convertionDone) {
+	while (!convertionDone) {
 		qApp->exec();
 		//qApp->processEvents(QEventLoop::WaitForMoreEvents | QEventLoop::AllEvents);
 	}

+ 5 - 1
src/shared/converter.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __CONVERTER_HH__
 #define __CONVERTER_HH__
 #include <QObject>
@@ -23,7 +27,7 @@ namespace wkhtmltopdf {
 class ConverterPrivate;
 
 class Converter: public QObject {
-    Q_OBJECT 
+    Q_OBJECT
 public:
 	virtual ~Converter() {};
 

+ 11 - 8
src/shared/converter_p.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,11 +17,12 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __CONVERTER_P_HH__
 #define __CONVERTER_P_HH__
-#include <QFile>
 #include "converter.hh"
 #include "websettings.hh"
+#include <QFile>
 #include <QWebSettings>
 
 namespace wkhtmltopdf {
@@ -27,24 +31,24 @@ class ConverterPrivate: public QObject {
 	Q_OBJECT
 public:
 	void copyFile(QFile & src, QFile & dst);
-	
+
 	QList<QString> phaseDescriptions;
 	int currentPhase;
-	
+
 	QString progressString;
 protected:
 	bool error;
 	virtual void clearResources() = 0;
 	virtual Converter & outer() = 0;
 	int errorCode;
-	
+
 	bool convertionDone;
-	
+
 	void updateWebSettings(QWebSettings * ws, const settings::Web & s) const;
 public slots:
 	void fail();
 	void loadProgress(int progress);
-	
+
 	virtual void beginConvert() = 0;
 	void cancel();
 	bool convert();
@@ -55,5 +59,4 @@ private:
 };
 
 }
-#endif //__CONVERTER_P__HH__
-
+#endif //__CONVERTER_P_HH__

+ 14 - 10
src/shared/htmloutputter.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outputter.hh"
 #include <QTextDocument>
 
@@ -63,15 +67,15 @@ public:
 	void text(const QString & t) {
 		fprintf(fd, "%s", S(t));
 	}
-	
+
 	void sectionLink(const QString & s) {
 		fprintf(fd, "<a href=\"#%s\">%s</a>", S(s), S(s));
 	}
-	
+
 	void bold(const QString & t) {
 		fprintf(fd, "<b>%s</b>", S(t));
 	}
-	
+
 	void italic(const QString & t) {
 		fprintf(fd, "<i>%s</i>", S(t));
 	}
@@ -79,7 +83,7 @@ public:
 	void link(const QString & t) {
 		fprintf(fd, "<a href=\"%s\">%s</a>", S(t),S(t));
 	}
-	
+
 	void verbatim(const QString & t) {
 		fprintf(fd, "<pre>%s</pre>", S(t));
 	}
@@ -88,26 +92,26 @@ public:
 		ordered = o;
 		fprintf(fd, ordered?"<ol>":"<ul>");
 	}
-	
+
 	void endList() {
 		fprintf(fd, ordered?"</ol>":"</ul>");
 	}
-	
+
 	void listItem(const QString & s) {
 		fprintf(fd, "<li>%s</li>\n", S(s));
 	}
-	
+
 	void beginSwitch() {
 		fprintf(fd, "<table>\n");
 	}
 
 	void cswitch(const ArgHandler * h) {
 		fprintf(fd, "<tr><td class=\"short\">");
-		if(h->shortSwitch)
+		if (h->shortSwitch)
 			fprintf(fd, "-%c,",h->shortSwitch);
 		fprintf(fd, "</td><td class=\"long\">--%s%s</td><td class=\"arg\">",S(h->longName),
 				(h->qthack?"<span style=\"font-weight: normal; font-size: 80%; color:red;\">*</span>":""));
-		foreach(const QString & arg, h->argn)
+		foreach (const QString & arg, h->argn)
 			fprintf(fd, "&lt;%s&gt; ",S(arg));
 		fprintf(fd, "</td><td class=\"desc\">%s</td></tr>\n",S(h->getDesc()));
 	}
@@ -116,7 +120,7 @@ public:
 		fprintf(fd, "</table>\n");
 		fprintf(fd, "<p>Items marked <span style=\"font-weight: normal; font-size: 80%%; color:red;\">*</span> are only available using patched QT.</p>");
 	}
-	
+
 };
 
 /*!

+ 11 - 7
src/shared/loadsettings.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "loadsettings.hh"
 #include <QMap>
 #include <stdexcept>
@@ -30,7 +34,7 @@ LoadPage::LoadErrorHandling strToLoadErrorHandling(const char * s, bool * ok) {
 }
 
 QString loadErrorHandlingToStr(LoadPage::LoadErrorHandling leh) {
-	switch(leh) {
+	switch (leh) {
 	case LoadPage::abort: return "abort";
 	case LoadPage::skip: return "skip";
 	case LoadPage::ignore: return "ignore";
@@ -45,13 +49,13 @@ QString loadErrorHandlingToStr(LoadPage::LoadErrorHandling leh) {
 */
 Proxy strToProxy(const char * proxy, bool * ok) {
 	Proxy p;
-	if(ok) *ok=true;
+	if (ok) *ok=true;
 	//Allow users to use no proxy, even if one is specified in the env
 	if (!strcmp(proxy,"none")) {
 		p.host = "";
 		return p;
 	}
-	
+
 	p.type = QNetworkProxy::HttpProxy;
 	//Read proxy type bit "http://" or "socks5://"
 	if (!strncmp(proxy,"http://",7)) {
@@ -67,9 +71,9 @@ Proxy strToProxy(const char * proxy, bool * ok) {
 	if (val != NULL) {
 		p.user = QString(proxy).left(val-proxy);
 		proxy = val+1;
-		
+
 		int idx = p.user.indexOf(':');
-		if(idx != -1) {
+		if (idx != -1) {
 			p.password = p.user.mid(idx+1);
 			p.user = p.user.left(idx);
 		}
@@ -81,13 +85,13 @@ Proxy strToProxy(const char * proxy, bool * ok) {
  	if (val == NULL) p.host = proxy;
  	else {
 		p.port = QString(val+1).toInt(ok);
-		if(p.port < 0 || p.port > 65535) {
+		if (p.port < 0 || p.port > 65535) {
 			p.port = 1080;
 			*ok = false;
 		}
 		p.host = QString(proxy).left(val-proxy);
  	}
-	if(ok && p.host.size() == 0) *ok = false;
+	if (ok && p.host.size() == 0) *ok = false;
 	return p;
 }
 

+ 19 - 15
src/shared/loadsettings.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,10 +17,11 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __LOADSETTINGS_HH__
 #define __LOADSETTINGS_HH__
-#include <QString>
 #include <QNetworkProxy>
+#include <QString>
 namespace wkhtmltopdf {
 namespace settings {
 
@@ -25,15 +29,15 @@ namespace settings {
 struct Proxy {
 	Proxy();
 	//! Type of proxy to use
-	QNetworkProxy::ProxyType type; 
+	QNetworkProxy::ProxyType type;
 	//! The port of the proxy to use
-	int port; 
+	int port;
 	//! The host name of the proxy to use or NULL
-	QString host; 
+	QString host;
 	//! Username for the said proxy or NULL
-	QString user; 
+	QString user;
 	//! Password for the said proxy or NULL
-	QString password; 
+	QString password;
 };
 
 struct PostItem {
@@ -59,20 +63,20 @@ struct LoadPage {
 
 	//! Username used for http auth login
 	QString username;
-	
+
 	//! Password used for http auth login
 	QString password;
-	
+
 	//! How many milliseconds should we wait for a Javascript redirect
 	int jsdelay;
-	
+
 	//! What zoom factor should we apply when printing
 	// TODO MOVE
 	float zoomFactor;
 
 	//! Map of custum header variables
 	QList< QPair<QString, QString> > customHeaders;
-	
+
 	//! Set if the custom header should be repeated for each resource request
 	bool repeatCustomHeaders;
 
@@ -80,16 +84,16 @@ struct LoadPage {
 	QList< QPair<QString, QString> > cookies;
 
 	QList< PostItem > post;
-	
+
 	//! Block access to local files for the given page
 	bool blockLocalFileAccess;
-	
+
 	//! If access to local files is not allowed in general, allow it for these files
 	QList< QString > allowed;
-	
+
 	//! Stop Javascript from running too long
-	bool stopSlowScripts;		
-	
+	bool stopSlowScripts;
+
 	//! Output Javascript debug messages
 	bool debugJavascript;
 

+ 16 - 12
src/shared/manoutputter.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outputter.hh"
 #include <QStringList>
 #define S(x) ((x).toUtf8().constData())
@@ -41,7 +45,7 @@ public:
 	void endParagraph() {
 		fprintf(fd, "\n\n");
 	}
-	
+
 	void text(const QString & t) {
 		QString str = QString(t).replace("-", "\\-");
 		fprintf(fd, "%s", S(str));
@@ -50,11 +54,11 @@ public:
 	void sectionLink(const QString & t) {
 		text(t);
 	}
-	
+
 	void bold(const QString & t) {
 		fprintf(fd, "\\fB%s\\fP", S(t));
 	}
-	
+
 	void italic(const QString & t) {
 		fprintf(fd, "\\fB%s\\fP", S(t));
 	}
@@ -67,11 +71,11 @@ public:
 		QString str = QString(t).replace("-", "\\-");
 		QStringList l = str.split('\n');
 		while ( l.back() == "") l.pop_back();
-		foreach(const QString & line, l)
+		foreach (const QString & line, l)
 			fprintf(fd, "  %s\n", S(line));
 		fprintf(fd, "\n");
 	}
-	
+
 	void beginSwitch() {
 		fprintf(fd, ".PD 0\n");
 	}
@@ -83,28 +87,28 @@ public:
 	void endList() {
 		fprintf(fd, "\n");
 	}
-	
+
 	void listItem(const QString & s) {
 		if (order < 0) fprintf(fd, " * ");
 		else fprintf(fd, "%3d ", order++);
 		fprintf(fd,"%s\n",S(s));
 	}
-	
+
 	void cswitch(const ArgHandler * h) {
 		fprintf(fd, ".TP\n");
 		fprintf(fd, "\\fB");
-		if(h->shortSwitch != 0)
+		if (h->shortSwitch != 0)
 			fprintf(fd, "\\-%c, ", h->shortSwitch);
 		else
 			fprintf(fd, "    ");
 		fprintf(fd,"\\-\\-%s\\fR", S(h->longName));
-		
-		for(QVector<QString>::const_iterator i = h->argn.constBegin(); i != h->argn.constEnd(); ++i)
+
+		for (QVector<QString>::const_iterator i = h->argn.constBegin(); i != h->argn.constEnd(); ++i)
 			fprintf(fd," \\fI<%s>\\fR", S(*i));
-		
+
 		fprintf(fd, "\n%s\n", S(QString(h->desc).replace("-", "\\-")));
 	}
-	
+
 	void endSwitch() {
 		fprintf(fd, ".PD\n");
 		fprintf(fd, "\n");

+ 26 - 22
src/shared/multipageloader.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,11 +17,12 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "multipageloader_p.hh"
 #include <QFile>
 #include <QFileInfo>
-#include <QTimer>
 #include <QNetworkCookie>
+#include <QTimer>
 #include <QUuid>
 
 namespace wkhtmltopdf {
@@ -44,11 +48,11 @@ void MyNetworkAccessManager::allow(QString path) {
 }
 
 QNetworkReply * MyNetworkAccessManager::createRequest(Operation op, const QNetworkRequest & req, QIODevice * outgoingData) {
-	if (req.url().scheme() == "file" && settings.blockLocalFileAccess) { 
+	if (req.url().scheme() == "file" && settings.blockLocalFileAccess) {
 		bool ok=false;
 		QString path = QFileInfo(req.url().toLocalFile()).canonicalFilePath();
 		QString old = "";
-		while(path != old) {
+		while (path != old) {
 			if (allowed.contains(path)) {
 				ok=true;
 				break;
@@ -69,7 +73,7 @@ QNetworkReply * MyNetworkAccessManager::createRequest(Operation op, const QNetwo
 		foreach (const HT & j, settings.customHeaders)
 			r3.setRawHeader(j.first.toAscii(), j.second.toAscii());
 	}
-	return QNetworkAccessManager::createRequest(op, r3, outgoingData);	
+	return QNetworkAccessManager::createRequest(op, r3, outgoingData);
 }
 
 
@@ -103,22 +107,22 @@ bool MyQWebPage::shouldInterruptJavaScript() {
 	return false;
 }
 
-ResourceObject::ResourceObject(MultiPageLoaderPrivate & mpl, const QUrl & u, const settings::LoadPage & s): 
+ResourceObject::ResourceObject(MultiPageLoaderPrivate & mpl, const QUrl & u, const settings::LoadPage & s):
 	networkAccessManager(s),
 	url(u),
-	loginTry(0), 
-	progress(0), 
+	loginTry(0),
+	progress(0),
 	finished(false),
 	signalPrint(false),
-	multiPageLoader(mpl), 
+	multiPageLoader(mpl),
 	webPage(*this),
 	lo(webPage),
 	httpErrorCode(0),
 	settings(s) {
-	
+
 	connect(&networkAccessManager, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator *)),this,
 	        SLOT(handleAuthenticationRequired(QNetworkReply *, QAuthenticator *)));
-	foreach(const QString & path, s.allowed)
+	foreach (const QString & path, s.allowed)
 		networkAccessManager.allow(path);
 	if (url.scheme() == "file")
 		networkAccessManager.allow(url.toLocalFile());
@@ -135,7 +139,7 @@ ResourceObject::ResourceObject(MultiPageLoaderPrivate & mpl, const QUrl & u, con
 	connect(&networkAccessManager, SIGNAL(finished (QNetworkReply *)),
 			this, SLOT(amfinished (QNetworkReply *) ) );
 
-	connect(&networkAccessManager, SIGNAL(warning(const QString &)), 
+	connect(&networkAccessManager, SIGNAL(warning(const QString &)),
 			this, SLOT(warning(const QString &)));
 
 	networkAccessManager.setCookieJar(multiPageLoader.cookieJar);
@@ -214,7 +218,7 @@ void ResourceObject::loadDone() {
 	if (finished) return;
 	finished=true;
 	--multiPageLoader.loading;
-	if (multiPageLoader.loading == 0) 
+	if (multiPageLoader.loading == 0)
 		multiPageLoader.loadDone();
 }
 
@@ -350,7 +354,7 @@ void MyCookieJar::saveToFile(const QString & path) {
 void MultiPageLoaderPrivate::loadDone() {
 	 if (!settings.cookieJar.isEmpty())
 	 	cookieJar->saveToFile(settings.cookieJar);
-	
+
 	if (!finishedEmitted) {
 		finishedEmitted = true;
 		emit outer.loadFinished(!hasError);
@@ -381,12 +385,12 @@ bool MultiPageLoader::copyFile(QFile & src, QFile & dst) {
 	return true;
 }
 
-MultiPageLoaderPrivate::MultiPageLoaderPrivate(const settings::LoadGlobal & s, MultiPageLoader & o): 
+MultiPageLoaderPrivate::MultiPageLoaderPrivate(const settings::LoadGlobal & s, MultiPageLoader & o):
 	outer(o), settings(s) {
 
 	cookieJar = new MyCookieJar();
 
-	if (!settings.cookieJar.isEmpty()) 
+	if (!settings.cookieJar.isEmpty())
 		cookieJar->loadFromFile(settings.cookieJar);
 }
 
@@ -399,7 +403,7 @@ LoaderObject * MultiPageLoaderPrivate::addResource(const QUrl & url, const setti
 	resources.push_back(ro);
 	return &ro->lo;
 }
-	
+
 void MultiPageLoaderPrivate::load() {
 	progressSum=0;
 	loadStartedEmitted=false;
@@ -407,21 +411,21 @@ void MultiPageLoaderPrivate::load() {
 	hasError=false;
 	loading=0;
 
-	for(int i=0; i < resources.size(); ++i)
+	for (int i=0; i < resources.size(); ++i)
 		resources[i]->load();
 
 	if (resources.size() == 0) loadDone();
 }
 
 void MultiPageLoaderPrivate::clearResources() {
-	for(int i=0; i < resources.size(); ++i)
+	for (int i=0; i < resources.size(); ++i)
 		delete resources[i];
 	resources.clear();
 	tempIn.remove();
 }
 
 void MultiPageLoaderPrivate::cancel() {
-	//foreach (QWebPage * page, pages) 
+	//foreach (QWebPage * page, pages)
 	//	page->triggerAction(QWebPage::Stop);
 }
 
@@ -454,7 +458,7 @@ LoaderObject * MultiPageLoader::addResource(const QString & string, const settin
 		in.open(stdin,QIODevice::ReadOnly);
 		url = d->tempIn.create(".html");
 		QFile tmp(url);
-		if(!tmp.open(QIODevice::WriteOnly) || !copyFile(in, tmp)) {
+		if (!tmp.open(QIODevice::WriteOnly) || !copyFile(in, tmp)) {
 			emit error("Unable to create temporery file");
 			return NULL;
 		}
@@ -472,7 +476,7 @@ LoaderObject * MultiPageLoader::addResource(const QUrl & url, const settings::Lo
 
 /*!
   \brief Guess a url, by looking at a string
-  
+
   (shamelessly copied from Arora Project)
   \param string The string the is suppose to be some kind of url
 */
@@ -538,7 +542,7 @@ QUrl MultiPageLoader::guessUrlFromString(const QString &string) {
  */
 int MultiPageLoader::httpErrorCode() {
 	int res=0;
-	foreach (const ResourceObject * ro, d->resources) 
+	foreach (const ResourceObject * ro, d->resources)
 		if (ro->httpErrorCode > res) res = ro->httpErrorCode;
 	return res;
 }

+ 4 - 0
src/shared/multipageloader.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __MULTIPAGELOADER_HH__
 #define __MULTIPAGELOADER_HH__
 #include "loadsettings.hh"

+ 11 - 4
src/shared/multipageloader_p.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,16 +17,19 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef __MULTIPAGELOADER_P_HH__
+#define __MULTIPAGELOADER_P_HH__
 #include "multipageloader.hh"
 #include "tempfile.hh"
 #include <QAtomicInt>
 #include <QAuthenticator>
 #include <QFile>
+#include <QFileInfo>
 #include <QNetworkAccessManager>
+#include <QNetworkCookieJar>
 #include <QNetworkReply>
 #include <QWebFrame>
-#include <QNetworkCookieJar>
-#include <QFileInfo>
 namespace wkhtmltopdf {
 
 class MyNetworkAccessManager: public QNetworkAccessManager {
@@ -71,7 +77,7 @@ public:
 	MyQWebPage webPage;
 	LoaderObject lo;
 	int httpErrorCode;
-	const settings::LoadPage settings;	
+	const settings::LoadPage settings;
 public slots:
 	void load();
 	void loadStarted();
@@ -116,7 +122,7 @@ public:
 	TempFile tempIn;
 
 	MultiPageLoaderPrivate(const settings::LoadGlobal & settings, MultiPageLoader & o);
-	~MultiPageLoaderPrivate(); 
+	~MultiPageLoaderPrivate();
 	LoaderObject * addResource(const QUrl & url, const settings::LoadPage & settings);
 	void load();
 	void clearResources();
@@ -127,3 +133,4 @@ public slots:
 };
 
 }
+#endif //__MULTIPAGELOADER_P_HH__

+ 7 - 3
src/shared/outputter.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outputter.hh"
 
 /*!
@@ -93,7 +98,7 @@
   Begin a section with command line switches
 */
 
-	
+
 /*!
   \fn Outputter::cswitch(const ArgHandler * h, bool doc)
   Output a switch description
@@ -115,4 +120,3 @@ void Outputter::paragraph(const QString & t) {
 	text(t);
 	endParagraph();
 }
-	

+ 6 - 3
src/shared/outputter.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,12 +17,13 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __OUTPUTTER_HH__
 #define __OUTPUTTER_HH__
+#include "commandlineparserbase.hh"
 #include <QString>
 #include <QVector>
 #include <stdio.h>
-#include "commandlineparserbase.hh"
 
 class Outputter {
 public:
@@ -45,5 +49,4 @@ public:
 	static Outputter * man(FILE * fd);
 	static Outputter * html(FILE * fd);
 };
-
-#endif
+#endif //__OUTPUTTER_HH__

+ 11 - 7
src/shared/progressfeedback.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "progressfeedback.hh"
 #include <cstdio>
 namespace wkhtmltopdf {
@@ -28,7 +32,7 @@ namespace wkhtmltopdf {
 */
 
 #define S(t) ((t).toLocal8Bit().constData())
-	
+
 /*!
   \brief Write out a warning message
   \param message The warning message
@@ -36,7 +40,7 @@ namespace wkhtmltopdf {
 void ProgressFeedback::warning(const QString &message) {
 	if (quiet) return;
 	fprintf(stderr, "Warning: %s",S(message));
-	for(int l = 9 + message.size(); l < lw; ++l) 
+	for (int l = 9 + message.size(); l < lw; ++l)
 		fprintf(stderr, " ");
 	fprintf(stderr, "\n");
 	lw = 0;
@@ -48,7 +52,7 @@ void ProgressFeedback::warning(const QString &message) {
 */
 void ProgressFeedback::error(const QString &message) {
 	fprintf(stderr, "Error: %s",S(message));
-	for(int l = 7 + message.size(); l < lw; ++l) 
+	for (int l = 7 + message.size(); l < lw; ++l)
 		fprintf(stderr, " ");
 	fprintf(stderr, "\n");
 	lw = 0;
@@ -61,11 +65,11 @@ void ProgressFeedback::phaseChanged() {
 	if (quiet) return;
 	QString desc=converter.phaseDescription();
 	fprintf(stderr, "%s", S(desc));
-	
+
 	int l = desc.size();
-	if(converter.currentPhase() < converter.phaseCount() -1)
+	if (converter.currentPhase() < converter.phaseCount() -1)
 		l += fprintf(stderr," (%d/%d)",converter.currentPhase()+1,converter.phaseCount()-1);
-	for(; l < lw; ++l) 
+	for (; l < lw; ++l)
 		fprintf(stderr, " ");
 	fprintf(stderr, "\n");
 	lw = 0;
@@ -88,7 +92,7 @@ void ProgressFeedback::progressChanged(int progress) {
 	fprintf(stderr, "]");
 	fprintf(stderr, " %s", S(converter.progressString()));
 	int l=1+w+2+converter.progressString().size();
-	for(int i=l; i < lw; ++i) fprintf(stderr, " ");
+	for (int i=l; i < lw; ++i) fprintf(stderr, " ");
 	lw = l;
 	fprintf(stderr, "\r");
 }

+ 4 - 0
src/shared/progressfeedback.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __PROGRESSFEEDBACK_HH__
 #define __PROGRESSFEEDBACK_HH__
 #include "converter.hh"

+ 17 - 1
src/shared/shared.pri

@@ -1,3 +1,20 @@
+# Copyright 2010 wkhtmltopdf authors
+#
+# This file is part of wkhtmltopdf.
+#
+# wkhtmltopdf is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# wkhtmltopdf is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with wkhtmltopdf.  If not, see <http:#www.gnu.org/licenses/>.
+
 #Lbaray Part
 HEADERS += ../shared/multipageloader_p.hh ../shared/multipageloader.hh ../shared/converter.hh \
 	 ../shared/converter_p.hh ../shared/progressfeedback.hh
@@ -10,4 +27,3 @@ HEADERS +=  ../shared/utilities.hh
 SOURCES += ../shared/outputter.cc ../shared/manoutputter.cc ../shared/htmloutputter.cc \
            ../shared/textoutputter.cc ../shared/arghandler.cc ../shared/commondocparts.cc \
  	   ../shared/commandlineparserbase.cc ../shared/commonarguments.cc ../shared/utilities.cc
-           

+ 9 - 4
src/shared/tempfile.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,10 +17,11 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "tempfile.hh"
-#include <QUuid>
-#include <QFile>
 #include <QDir>
+#include <QFile>
+#include <QUuid>
 /*!
   \file tempfile.hh
   \brief Defines the TempFile class
@@ -49,7 +54,7 @@ QString TempFile::create(const QString & ext) {
   \brief Remove the temporery file hold by this object it it exists
 */
 void TempFile::remove() {
-	if (!path.isEmpty())						
+	if (!path.isEmpty())
 		QFile::remove(path);
 	path="";
 }

+ 6 - 2
src/shared/tempfile.hh

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __TEMPFILE_HH__
 #define __TEMPFILE_HH__
 #include <QString>
@@ -26,5 +31,4 @@ public:
 	QString create(const QString & ext);
 	void remove();
 };
-
 #endif //__TEMPFILE_HH__

+ 33 - 29
src/shared/textoutputter.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outputter.hh"
 #include <qstringlist.h>
 
@@ -31,25 +35,25 @@ public:
 	TextOutputter(FILE * _, bool d, bool e): fd(_), doc(d), extended(e) {}
 
 	void beginSection(const QString & name) {
-		if(doc) {
+		if (doc) {
 			int x= 80 - name.size() - 4;
-			if(x < 6) x = 60;
-			for(int i=0; i < x/2; ++i) 
+			if (x < 6) x = 60;
+			for (int i=0; i < x/2; ++i)
 				fprintf(fd, "=");
 			fprintf(fd, "> %s <", S(name) );
-			for(int i=0; i < (x+1)/2; ++i) 
+			for (int i=0; i < (x+1)/2; ++i)
 				fprintf(fd, "=");
 			fprintf(fd, "\n");
-		} else 
+		} else
 			fprintf(fd, "%s:\n", S(name) );
 	}
-	
+
 	void endSection() {
 	}
 
 	void beginParagraph() {
 		first=true;
-		if(doc) {
+		if (doc) {
 			w=0;
 		} else {
 			w=2;
@@ -60,10 +64,10 @@ public:
 	void text(const QString & t) {
 		first=true;
 		QStringList list = t.split(" ");
-		foreach(const QString & s, list) {
-			if( w + s.size() + (first?0:1) > lw) {
+		foreach (const QString & s, list) {
+			if ( w + s.size() + (first?0:1) > lw) {
 				fprintf(fd, "\n");
-				if(doc) {
+				if (doc) {
 					w=0;
 				} else {
 					w=2;
@@ -71,7 +75,7 @@ public:
 				}
 				first=true;
 			}
-			if(first) first=false;
+			if (first) first=false;
 			else {
 				fprintf(fd, " ");
 				++w;
@@ -80,19 +84,19 @@ public:
 			fprintf(fd, "%s", S(s));
 		}
 	}
-	
+
 	void sectionLink(const QString & t) {
 		text(t);
 	}
-	
+
 	void bold(const QString & t) {
 		text("*"+t+"*");
 	}
-	
+
 	void italic(const QString & t) {
 		text("_"+t+"_");
 	}
-	
+
 	void link(const QString & t) {
 		text("<"+t+">");
 	}
@@ -102,10 +106,10 @@ public:
 	}
 
 	void verbatim(const QString & t) {
-		if(doc)
+		if (doc)
 			fprintf(fd,"%s\n", S(t));
 		else {
-			foreach(const QString & s, t.split("\n"))
+			foreach (const QString & s, t.split("\n"))
 				fprintf(fd,"  %s\n",S(s));
 		}
 	}
@@ -121,36 +125,36 @@ public:
 		else fprintf(fd, "%3d ", order++);
 		fprintf(fd,"%s\n",S(s));
 	}
-	
+
 	void beginSwitch() {}
 
 	void cswitch(const ArgHandler * h) {
 		w=0;
-		if(!doc) {fprintf(fd,"  "); w=2;}
-		if(h->shortSwitch != 0)
+		if (!doc) {fprintf(fd,"  "); w=2;}
+		if (h->shortSwitch != 0)
 			fprintf(fd,"-%c, ",h->shortSwitch);
 		else
 			fprintf(fd,"    ");
 		fprintf(fd,"--%s",S(h->longName));
 		w+=4 + 2 + h->longName.size();
-		if (doc && h->qthack) { 
+		if (doc && h->qthack) {
 			fprintf(fd, " *");
 			w += 2;
 		}
-				
-		foreach(const QString & arg, h->argn) {
+
+		foreach (const QString & arg, h->argn) {
 			fprintf(fd," <%s>",S(arg));
 			w+=3+arg.size();
 		}
-		while(w < 37) {
+		while (w < 37) {
 			fprintf(fd," ");
 			++w;
 		}
-		foreach(const QString & s, h->getDesc().split(" ")) {
-			if(w+1+s.size() > lw) {
+		foreach (const QString & s, h->getDesc().split(" ")) {
+			if (w+1+s.size() > lw) {
 				printf("\n");
 				w=0;
-				while(w < 37) {
+				while (w < 37) {
 					fprintf(fd," ");
 					++w;
 				}
@@ -165,8 +169,8 @@ public:
 		if (doc)
 			fprintf(fd, "\nItems marked * are only available using patched QT.\n");
 		printf("\n");
-	}		
-	
+	}
+
 };
 
 /*!

+ 9 - 4
src/shared/utilities.cc

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "utilities.hh"
 
 #ifdef QT_STATIC
@@ -35,14 +40,14 @@ void MyLooksStyle::drawPrimitive( PrimitiveElement element, const QStyleOption *
 	QRect r = option->rect;
 	if (element == QStyle::PE_PanelLineEdit) {
 		painter->drawRect(r);
-	} else if(element == QStyle::PE_IndicatorCheckBox) {
+	} else if (element == QStyle::PE_IndicatorCheckBox) {
 		painter->drawRect(r);
 		if (!weAreDrawingForms && (option->state & QStyle::State_On)) {
 			r.translate(int(r.width()*0.075), int(r.width()*0.075));
 			painter->drawLine(r.topLeft(), r.bottomRight());
 			painter->drawLine(r.topRight(), r.bottomLeft());
 		}
-	} else if(element == QStyle::PE_IndicatorRadioButton) {
+	} else if (element == QStyle::PE_IndicatorRadioButton) {
 		painter->drawEllipse(r);
 		if (!weAreDrawingForms && (option->state & QStyle::State_On)) {
 			r.translate(int(r.width()*0.20), int(r.width()*0.20));
@@ -83,7 +88,7 @@ int handleError(bool success, int errorCode) {
 }
 
 
-// void printSupportedWriteformats(){
+// void printSupportedWriteformats() {
 //   QList<QByteArray> formats = QImageWriter::supportedImageFormats();
 //   for ( QList<QByteArray>::Iterator f = formats.begin(); f != formats.end(); ++ f )
 //     printf("%s , ", f->constData() );

+ 9 - 6
src/shared/utilities.hh

@@ -1,4 +1,8 @@
-//-*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
+// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
+// vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -13,17 +17,17 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __UTILITIES_HH__
 #define __UTILITIES_HH__
-
 #include <QCleanlooksStyle>
 #include <QCommonStyle>
-#include <QPainter>
-#include <QStyleOption>
-#include <QUrl>
 #include <QFile>
 #include <QFileInfo>
 #include <QImageWriter>
+#include <QPainter>
+#include <QStyleOption>
+#include <QUrl>
 
 /**
  * Custom simplistic style
@@ -40,5 +44,4 @@ public slots:
 };
 
 int handleError(bool success, int errorCode);
-
 #endif //__UTILITIES_HH__

+ 4 - 0
src/shared/websettings.cc

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,6 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "websettings.hh"
 namespace wkhtmltopdf {
 namespace settings {

+ 12 - 8
src/shared/websettings.hh

@@ -1,5 +1,8 @@
 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
@@ -14,10 +17,11 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __WEBSETTINGS_HH__
 #define __WEBSETTINGS_HH__
-#include <QString>
 #include <QNetworkProxy>
+#include <QString>
 namespace wkhtmltopdf {
 namespace settings {
 
@@ -26,25 +30,25 @@ struct Web {
 
 	//! Should we print background images
 	bool background;
-	
+
 	//! Should we load images
 	bool loadImages;
 
 	//! Should we enable Javascript
-	bool enableJavascript; 
-	
+	bool enableJavascript;
+
 	//! Should the horrible intelligent shrinking feature be enabled?
 	bool enableIntelligentShrinking;
-		
+
 	//! Minimum font size
 	int minimumFontSize;
-	
+
 	//! Should we use the print or the screen media type
 	bool printMediaType;
-	
+
 	//! Encoding used to enterpit a document with do supplied encoding
 	QString defaultEncoding;
-	
+
 	//! Stylesheet supplied by the user
 	QString userStyleSheet;
 

+ 2 - 0
wkhtmltopdf.pro

@@ -1,3 +1,5 @@
+# Copyright 2010 wkhtmltopdf authors
+#
 # This file is part of wkhtmltopdf.
 #
 # wkhtmltopdf is free software: you can redistribute it and/or modify