浏览代码

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 {
 unix {
     TEMP = $$[QT_INSTALL_LIBS] libQtGui.prl
     TEMP = $$[QT_INSTALL_LIBS] libQtGui.prl
     PRL  = $$[QT_INSTALL_LIBS] QtGui.framework/QtGui.prl
     PRL  = $$[QT_INSTALL_LIBS] QtGui.framework/QtGui.prl
@@ -6,7 +23,7 @@ unix {
 }
 }
 
 
 exists($$QMAKE_LIBDIR_QT/libQtGui.so) {
 exists($$QMAKE_LIBDIR_QT/libQtGui.so) {
-    DEFINES += QT_SHARED				      
+    DEFINES += QT_SHARED
 } else:exists($$QMAKE_LIBDIR_QT/../bin//QtGui4.dll) {
 } else:exists($$QMAKE_LIBDIR_QT/../bin//QtGui4.dll) {
     DEFINES += QT_SHARED
     DEFINES += QT_SHARED
 } else:contains(QMAKE_PRL_CONFIG, shared) {
 } else:contains(QMAKE_PRL_CONFIG, shared) {

+ 18 - 1
scripts/release.sh

@@ -1,4 +1,21 @@
 #!/bin/bash
 #!/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() {
 function usage() {
     echo "Usage $0: [Options] Major Minor Patch [Build]"
     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
 	[ -f "$l" ] && cp "$l" "$x" && continue
     wget "http://wkhtmltopdf.googlecode.com/files/$x" -O "$x" && continue
     wget "http://wkhtmltopdf.googlecode.com/files/$x" -O "$x" && continue
 done
 done
-makensis wkhtmltopdf.nsi 
+makensis wkhtmltopdf.nsi

+ 9 - 3
scripts/sourcefix.py

@@ -21,9 +21,10 @@ from sys import argv, exit
 import re
 import re
 from datetime import date
 from datetime import date
 import os
 import os
+import difflib
 
 
 cdate = re.compile(r"Copyright ([0-9 ,]*) wkhtmltopdf authors")
 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]*$")
 endif = re.compile(r"#endif.*[\r\n \t]*$")
 ws = re.compile(r"[ \t]*[\r\n]")
 ws = re.compile(r"[ \t]*[\r\n]")
 branchspace = re.compile(r"([ \t\r\n])(for|if|while|switch|foreach)[\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 = hexp.sub("", data,1)
 	ndata = ws.sub("\n", ndata)+"\n"
 	ndata = ws.sub("\n", ndata)+"\n"
 	if ext in ["hh","h","inl"]:
 	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
 		#Strip away generated ifdef
 		if ifdef.search(ndata):
 		if ifdef.search(ndata):
 			ndata = endif.sub("",ifdef.sub("",ndata,1),1)
 			ndata = endif.sub("",ifdef.sub("",ndata,1),1)
@@ -111,8 +116,9 @@ for path in argv[1:]:
 #endif //__%s__"""%(n,n,ndata,n)
 #endif //__%s__"""%(n,n,ndata,n)
 	ndata = header.replace("//",cc)+ndata+"\n"
 	ndata = header.replace("//",cc)+ndata+"\n"
 	if ndata != data:
 	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)
 		file(path, "w").write(ndata)
 
 
 if changes: exit(1)
 if changes: exit(1)

+ 10 - 7
scripts/static-build.sh

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

+ 15 - 12
scripts/test.sh

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

+ 21 - 3
scripts/upload.sh

@@ -1,4 +1,22 @@
 #!/bin/bash
 #!/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"
 cd "release-$1"
 wget http://support.googlecode.com/svn/trunk/scripts/googlecode_upload.py -O googlecode_upload.py
 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"
 	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-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-i386.tar.bz2" ] ||
    ! [ -f "wkhtmltoimage-$1-static-amd64.tar.bz2" ]; then
    ! [ -f "wkhtmltoimage-$1-static-amd64.tar.bz2" ]; then
 	echo "File Missing"
 	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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#include "commandlineparser.hh"
+
 #include "arghandler.inl"
 #include "arghandler.inl"
+#include "commandlineparser.hh"
 #include <qglobal.h>
 #include <qglobal.h>
 
 
 CommandLineParser::CommandLineParser(wkhtmltopdf::settings::Global & s):
 CommandLineParser::CommandLineParser(wkhtmltopdf::settings::Global & s):
-	settings(s)
-{
+	settings(s) {
 	mode(global);
 	mode(global);
 	section("General Options");
 	section("General Options");
 	addDocArgs();
 	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("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("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") );
 	addarg("quality",0,"Output image quality (between 0 and 100)", new IntSetter(s.quality, "int") );
-	
+
 	extended(true);
 	extended(true);
 	qthack(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));
 	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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparser.hh"
 #include "commandlineparser.hh"
-#include <qwebframe.h>
 #include "outputter.hh"
 #include "outputter.hh"
+#include <qwebframe.h>
 
 
 /*!
 /*!
   \file commandlineparser.hh
   \file commandlineparser.hh
@@ -83,17 +88,17 @@ void CommandLineParser::readme(FILE * fd, bool html) const {
 // void CommandLineParser::loadDefaults() {
 // void CommandLineParser::loadDefaults() {
 // 	d->settings.in = "-";
 // 	d->settings.in = "-";
 // 	d->settings.proxy.host = "";
 // 	d->settings.proxy.host = "";
-// 	foreach(ArgHandler * h, d->longToHandler) 
+// 	foreach (ArgHandler * h, d->longToHandler)
 // 		h->useDefault(*d);
 // 		h->useDefault(*d);
 
 
 // 	//Load configuration from enviornment
 // 	//Load configuration from enviornment
 // 	char * val;
 // 	char * val;
 // 	const char * vars[] = {"proxy","all_proxy","http_proxy", NULL};
 // 	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"))) {
 // 		if ((val = getenv("proxy"))) {
 // 			bool ok=false;
 // 			bool ok=false;
 // 			Settings::ProxySettings p = Settings::strToProxy(val, &ok);
 // 			Settings::ProxySettings p = Settings::strToProxy(val, &ok);
-// 			if(ok) 
+// 			if (ok)
 // 				d->settings.proxy = p;
 // 				d->settings.proxy = p;
 // 		}
 // 		}
 // 	}
 // 	}
@@ -109,7 +114,7 @@ void CommandLineParser::parseArguments(int argc, const char ** argv, bool final)
     settings.out="";
     settings.out="";
 	bool defaultMode=false;
 	bool defaultMode=false;
 	for (int i=1; i < argc; ++i) {
 	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];
             settings.in = argv[i];
         } else if (i==argc-1 && (argv[i][0] != '-' || argv[i][1] == '\0')) { // the last arg (out)
         } else if (i==argc-1 && (argv[i][0] != '-' || argv[i][1] == '\0')) { // the last arg (out)
             settings.out = argv[i];
             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");
         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);
         usage(stderr, false);
         exit(1);
         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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // 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 "commandlineparserbase.hh"
+#include "settings.hh"
 #include <cstdio>
 #include <cstdio>
 
 
 /*! \brief The class is responcible for parsing command line information
 /*! \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);
 	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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparser.hh"
 #include "commandlineparser.hh"
 #include "outputter.hh"
 #include "outputter.hh"
 #include <QWebFrame>
 #include <QWebFrame>
@@ -101,7 +106,7 @@ void CommandLineParser::outputInstallation(Outputter * o) const {
 	o->paragraph(
 	o->paragraph(
 		"There are several ways to install wkhtmltoimage.  You can download a "
 		"There are several ways to install wkhtmltoimage.  You can download a "
 		"already compiled binary, or you can compile wkhtmltoimage yourself. ");
 		"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->verbatim("wkhtmltoimage my.html my.png\n");
 	o->endSection();
 	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(../../version.pri)
 include(../../common.pri)
 include(../../common.pri)
 
 
@@ -42,5 +59,3 @@ include(../shared/shared.pri)
 HEADERS += imageconverter.hh imageconverter_p.hh settings.hh converter.hh
 HEADERS += imageconverter.hh imageconverter_p.hh settings.hh converter.hh
 SOURCES += wkhtmltoimage.cc arguments.cc commandlineparser.cc docparts.cc \
 SOURCES += wkhtmltoimage.cc arguments.cc commandlineparser.cc docparts.cc \
            imageconverter.cc settings.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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "imageconverter_p.hh"
 #include "imageconverter_p.hh"
 #include "settings.hh"
 #include "settings.hh"
-#include <QObject>
-#include <QWebPage>
-#include <QWebFrame>
-#include <QUrl>
-#include <QImage>
-#include <QPainter>
-#include <QObject>
+#include <QDebug>
 #include <QEventLoop>
 #include <QEventLoop>
 #include <QFileInfo>
 #include <QFileInfo>
-#include <QDebug>
-#include <qapplication.h>
+#include <QImage>
+#include <QObject>
+#include <QObject>
+#include <QPainter>
 #include <QSvgGenerator>
 #include <QSvgGenerator>
+#include <QUrl>
+#include <QWebFrame>
+#include <QWebPage>
+#include <qapplication.h>
 namespace wkhtmltopdf {
 namespace wkhtmltopdf {
 
 
 ImageConverterPrivate::ImageConverterPrivate(ImageConverter & o, wkhtmltopdf::settings::Global & s):
 ImageConverterPrivate::ImageConverterPrivate(ImageConverter & o, wkhtmltopdf::settings::Global & s):
 	settings(s),
 	settings(s),
 	loader(s.loadGlobal),
 	loader(s.loadGlobal),
 	out(o) {
 	out(o) {
-	
+
 	phaseDescriptions.push_back("Loading page");
 	phaseDescriptions.push_back("Loading page");
 	phaseDescriptions.push_back("Rendering");
 	phaseDescriptions.push_back("Rendering");
 	phaseDescriptions.push_back("Done");
 	phaseDescriptions.push_back("Done");
@@ -66,11 +70,11 @@ void ImageConverterPrivate::clearResources() {
 void ImageConverterPrivate::pagesLoaded(bool ok) {
 void ImageConverterPrivate::pagesLoaded(bool ok) {
 	if (errorCode == 0) errorCode = loader.httpErrorCode();
 	if (errorCode == 0) errorCode = loader.httpErrorCode();
 	if (!ok) {
 	if (!ok) {
-		fail(); 
+		fail();
 		return;
 		return;
 	}
 	}
 	// if fmt is empty try to get it from file extension in out
 	// if fmt is empty try to get it from file extension in out
-	if(settings.fmt==""){
+	if (settings.fmt=="") {
 		if (settings.out == "-")
 		if (settings.out == "-")
 			settings.fmt = "jpg";
 			settings.fmt = "jpg";
 		else {
 		else {
@@ -78,24 +82,24 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 			settings.fmt = fi.suffix();
 			settings.fmt = fi.suffix();
 		}
 		}
 	}
 	}
-	
+
 	// check whether image format is supported (for writing)
 	// check whether image format is supported (for writing)
 //	QImageWriter test;
 //	QImageWriter test;
 //	test.setFormat(settings.fmt);
 //	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;
 //		httpErrorCode=EFAULT;
 //		return false;
 //		return false;
 //	}
 //	}
 	// create webkit frame and load website
 	// create webkit frame and load website
-	
+
 	currentPhase=1;
 	currentPhase=1;
 	emit out. phaseChanged();
 	emit out. phaseChanged();
 	loadProgress(0);
 	loadProgress(0);
 
 
 	QWebFrame * frame = loaderObject->page.mainFrame();
 	QWebFrame * frame = loaderObject->page.mainFrame();
 	loaderObject->page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
 	loaderObject->page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
-	
+
 	loadProgress(25);
 	loadProgress(25);
 	// Calculate a good width for the image
 	// Calculate a good width for the image
 	int highWidth=settings.screenWidth;
 	int highWidth=settings.screenWidth;
@@ -113,7 +117,7 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 			loaderObject->page.setViewportSize(QSize(t, 10));
 			loaderObject->page.setViewportSize(QSize(t, 10));
 			if (frame->scrollBarMaximum(Qt::Horizontal) > 0)
 			if (frame->scrollBarMaximum(Qt::Horizontal) > 0)
 				lowWidth = t;
 				lowWidth = t;
-			else 
+			else
 				highWidth = t;
 				highWidth = t;
 		}
 		}
 		loaderObject->page.setViewportSize(QSize(highWidth, 10));
 		loaderObject->page.setViewportSize(QSize(highWidth, 10));
@@ -121,7 +125,7 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 	loaderObject->page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
 	loaderObject->page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
 	//Set the right height
 	//Set the right height
 	loaderObject->page.setViewportSize(QSize(highWidth, frame->contentsSize().height()));
 	loaderObject->page.setViewportSize(QSize(highWidth, frame->contentsSize().height()));
-	
+
 	QPainter painter;
 	QPainter painter;
 	QSvgGenerator generator;
 	QSvgGenerator generator;
 	QImage image;
 	QImage image;
@@ -149,7 +153,7 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 		emit out.error("Will not output an empty image");
 		emit out.error("Will not output an empty image");
 		fail();
 		fail();
 	}
 	}
-	
+
 	if (settings.fmt != "svg") {
 	if (settings.fmt != "svg") {
 		image = QImage(rect.size(), QImage::Format_ARGB32_Premultiplied);
 		image = QImage(rect.size(), QImage::Format_ARGB32_Premultiplied);
 		painter.begin(&image);
 		painter.begin(&image);
@@ -162,7 +166,7 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 #endif
 #endif
 		painter.begin(&generator);
 		painter.begin(&generator);
 	}
 	}
-	
+
 	if (!settings.transparent || (settings.fmt != "png" && settings.fmt != "svg"))
 	if (!settings.transparent || (settings.fmt != "png" && settings.fmt != "svg"))
 		painter.fillRect(QRect(QPoint(0,0),loaderObject->page.viewportSize()), Qt::white);
 		painter.fillRect(QRect(QPoint(0,0),loaderObject->page.viewportSize()), Qt::white);
 	painter.translate(-rect.left(), -rect.top());
 	painter.translate(-rect.left(), -rect.top());
@@ -171,7 +175,7 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 
 
 	//loadProgress(30);
 	//loadProgress(30);
 	// perform filter(s)
 	// 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);
 	//	image=image.copy(settings.crop.left,settings.crop.top,settings.crop.width,settings.crop.height);
 	//loadProgress(50);
 	//loadProgress(50);
 	//if (settings.scale.width > 0 && settings.scale.height > 0) {
 	//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)) {
 		if (!image.save(&file,fmt.data(), settings.quality)) {
 			emit out.error("Could not save image");
 			emit out.error("Could not save image");
 			fail();
 			fail();
-		} 
+		}
 	}
 	}
 	loadProgress(100);
 	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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __IMAGECONVERTER_HH__
 #ifndef __IMAGECONVERTER_HH__
 #define __IMAGECONVERTER_HH__
 #define __IMAGECONVERTER_HH__
-#include "settings.hh"
 #include "converter.hh"
 #include "converter.hh"
+#include "settings.hh"
 
 
 namespace wkhtmltopdf {
 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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __IMAGECONVERTER_P_HH__
 #ifndef __IMAGECONVERTER_P_HH__
 #define __IMAGECONVERTER_P_HH__
 #define __IMAGECONVERTER_P_HH__
-
-#include "multipageloader.hh"
-#include "imageconverter.hh"
 #include "converter_p.hh"
 #include "converter_p.hh"
+#include "imageconverter.hh"
+#include "multipageloader.hh"
 namespace wkhtmltopdf {
 namespace wkhtmltopdf {
-  
+
 class ImageConverterPrivate: public ConverterPrivate {
 class ImageConverterPrivate: public ConverterPrivate {
 	Q_OBJECT
 	Q_OBJECT
 public:
 public:
 	ImageConverterPrivate(ImageConverter & o, wkhtmltopdf::settings::Global & s);
 	ImageConverterPrivate(ImageConverter & o, wkhtmltopdf::settings::Global & s);
-	
+
 	wkhtmltopdf::settings::Global settings;
 	wkhtmltopdf::settings::Global settings;
 	MultiPageLoader loader;
 	MultiPageLoader loader;
 private:
 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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "settings.hh"
 #include "settings.hh"
 
 
 namespace wkhtmltopdf {
 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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __SETTINGS_HH__
 #ifndef __SETTINGS_HH__
 #define __SETTINGS_HH__
 #define __SETTINGS_HH__
 #include "loadsettings.hh"
 #include "loadsettings.hh"
@@ -49,7 +53,7 @@ struct CropSettings {
 /*! \brief Class holding all user settings.
 /*! \brief Class holding all user settings.
 
 
     This class holds all the user settings, settings can be filled in by hand,
     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()
     \sa CommandLineParser::parse()
 */
 */
 struct Global {
 struct Global {
@@ -59,14 +63,14 @@ struct Global {
 	CropSettings crop;
 	CropSettings crop;
 	//! Scale related settings
 	//! Scale related settings
 	// ScaleSettings scale;
 	// ScaleSettings scale;
-	
+
 	LoadGlobal loadGlobal;
 	LoadGlobal loadGlobal;
 	LoadPage loadPage;
 	LoadPage loadPage;
 	Web web;
 	Web web;
 
 
 	//! Be less verbose
 	//! Be less verbose
-	bool quiet; 
-	
+	bool quiet;
+
 	bool transparent;
 	bool transparent;
 
 
 	//! Should we use the graphics system
 	//! 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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparser.hh"
 #include "commandlineparser.hh"
-#include "settings.hh"
-#include "utilities.hh"
 #include "imageconverter.hh"
 #include "imageconverter.hh"
 #include "progressfeedback.hh"
 #include "progressfeedback.hh"
+#include "settings.hh"
+#include "utilities.hh"
 #include <QApplication>
 #include <QApplication>
 #include <QWebFrame>
 #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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 
 
-#include "commandlineparser.hh"
 #include "arghandler.inl"
 #include "arghandler.inl"
-#include <QFile>
+#include "commandlineparser.hh"
 #include "pdfconverter.hh"
 #include "pdfconverter.hh"
+#include <QFile>
 #include <qglobal.h>
 #include <qglobal.h>
 
 
 /*!
 /*!
@@ -45,7 +49,7 @@
   \brief The names of the arguments to the switch
   \brief The names of the arguments to the switch
 */
 */
 
 
-/*!											  
+/*!
   \var ArgHandler::display
   \var ArgHandler::display
   \brief Indicate that the argument is not hidden
   \brief Indicate that the argument is not hidden
 */
 */
@@ -55,7 +59,7 @@
   \brief Indicate if the argument is an extended argument
   \brief Indicate if the argument is an extended argument
 */
 */
 
 
-/*!											  
+/*!
   \var ArgHandler::qthack
   \var ArgHandler::qthack
   \brief Indicate that the argument is only available with hacked qt
   \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;
 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;
 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;
 typedef SomeSetter<OrientationTM> OrientationSetter;
 
 
@@ -163,8 +167,7 @@ struct BookFunc {
 CommandLineParser::CommandLineParser(Global & s, QList<Page> & ps):
 CommandLineParser::CommandLineParser(Global & s, QList<Page> & ps):
 	readArgsFromStdin(false),
 	readArgsFromStdin(false),
 	globalSettings(s),
 	globalSettings(s),
-	pageSettings(ps)
-{
+	pageSettings(ps) {
 	section("Global Options");
 	section("Global Options");
 	mode(global);
 	mode(global);
 
 
@@ -174,7 +177,7 @@ CommandLineParser::CommandLineParser(Global & s, QList<Page> & ps):
 	qthack(false);
 	qthack(false);
 
 
 	addarg("quiet", 'q', "Be less verbose", new ConstSetter<bool>(s.quiet,true));
 	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("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));
 	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-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("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));
 	addarg("no-pdf-compression", 0 , "Do not use lossless compression on pdf objects", new ConstSetter<bool>(s.useCompression,false));
 
 
  #ifdef Q_WS_X11
  #ifdef Q_WS_X11
@@ -243,7 +246,7 @@ CommandLineParser::CommandLineParser(Global & s, QList<Page> & ps):
  	qthack(true);
  	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("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("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("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));
 	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-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-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("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"));
 	addarg("replace",0, "Replace [name] with value in header and footer (repeatable)", new MapSetter<>(od.replacements, "name", "value"));
 
 
 	section("TOC Options");
 	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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparser.hh"
 #include "commandlineparser.hh"
 #include "outputter.hh"
 #include "outputter.hh"
 #include <qwebframe.h>
 #include <qwebframe.h>
@@ -64,7 +69,7 @@ void CommandLineParser::usage(FILE * fd, bool extended) const {
 	outputSynopsis(o);
 	outputSynopsis(o);
  	outputDescripton(o);
  	outputDescripton(o);
 	outputSwitches(o, extended, false);
 	outputSwitches(o, extended, false);
-#ifndef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__	
+#ifndef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 	outputNotPatched(o, true);
 	outputNotPatched(o, true);
 #endif
 #endif
 	if (extended) {
 	if (extended) {
@@ -111,7 +116,7 @@ void CommandLineParser::readme(FILE * fd, bool html) const {
 //void CommandLineParser::loadDefaults() {
 //void CommandLineParser::loadDefaults() {
 	//settings.in.clear();
 	//settings.in.clear();
 	//settings.proxy.host = "";
 	//settings.proxy.host = "";
-	//foreach(ArgHandler * h, longToHandler) 
+	//foreach(ArgHandler * h, longToHandler)
 	//	h->useDefault(*d);
 	//	h->useDefault(*d);
 
 
 	//Load configuration from enviornment
 	//Load configuration from enviornment
@@ -121,7 +126,7 @@ void CommandLineParser::readme(FILE * fd, bool html) const {
 	//	if ((val = getenv("proxy"))) {
 	//	if ((val = getenv("proxy"))) {
 	//		bool ok=false;
 	//		bool ok=false;
 	//		Settings::ProxySettings p = Settings::strToProxy(val, &ok);
 	//		Settings::ProxySettings p = Settings::strToProxy(val, &ok);
-	//		if(ok) 
+	//		if (ok)
 	//			settings.proxy = p;
 	//			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) {
 void CommandLineParser::parseArguments(int argc, const char ** argv, bool fromStdin) {
 	bool defaultMode = false;
 	bool defaultMode = false;
 	int arg=1;
 	int arg=1;
-	
+
 	Page def;
 	Page def;
-	
+
 	//Parse global options
 	//Parse global options
-	for(;arg < argc;++arg) {
+	for (;arg < argc;++arg) {
 		if (argv[arg][0] != '-' || argv[arg][1] == '\0' || defaultMode) break;
 		if (argv[arg][0] != '-' || argv[arg][1] == '\0' || defaultMode) break;
 		parseArg(global | page, argc, argv, defaultMode, arg, (char *)&def);
 		parseArg(global | page, argc, argv, defaultMode, arg, (char *)&def);
 	}
 	}
-	
+
 	if (readArgsFromStdin && !fromStdin) return;
 	if (readArgsFromStdin && !fromStdin) return;
 
 
 	//Parse page options
 	//Parse page options
-	while(arg < argc-1) {
+	while (arg < argc-1) {
 		pageSettings.push_back(def);
 		pageSettings.push_back(def);
 		Page & ps = pageSettings.back();
 		Page & ps = pageSettings.back();
 		int sections = page;
 		int sections = page;
 		if (!strcmp(argv[arg],"cover")) {
 		if (!strcmp(argv[arg],"cover")) {
 			++arg;
 			++arg;
-			if(arg >= argc-1) {
+			if (arg >= argc-1) {
 				fprintf(stderr, "You need to specify a input file to cover\n\n");
 				fprintf(stderr, "You need to specify a input file to cover\n\n");
 				usage(stderr, false);
 				usage(stderr, false);
 				exit(1);
 				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.line = ps.footer.line = false;
 			ps.header.htmlUrl = ps.footer.htmlUrl = "";
 			ps.header.htmlUrl = ps.footer.htmlUrl = "";
 			ps.includeInOutline = false;
 			ps.includeInOutline = false;
-				
+
 			//Setup varius cover settings her
 			//Setup varius cover settings her
 			++arg;
 			++arg;
 		} else if (!strcmp(argv[arg],"toc")) {
 		} else if (!strcmp(argv[arg],"toc")) {
@@ -176,7 +181,7 @@ void CommandLineParser::parseArguments(int argc, const char ** argv, bool fromSt
 		} else {
 		} else {
 			if (!strcmp(argv[arg],"page")) {
 			if (!strcmp(argv[arg],"page")) {
 				++arg;
 				++arg;
-				if(arg >= argc-1) {
+				if (arg >= argc-1) {
 					fprintf(stderr, "You need to specify a input file to page\n\n");
 					fprintf(stderr, "You need to specify a input file to page\n\n");
 					usage(stderr, false);
 					usage(stderr, false);
 					exit(1);
 					exit(1);
@@ -185,12 +190,12 @@ void CommandLineParser::parseArguments(int argc, const char ** argv, bool fromSt
 			ps.page = QString::fromLocal8Bit(argv[arg]);
 			ps.page = QString::fromLocal8Bit(argv[arg]);
 			++arg;
 			++arg;
 		}
 		}
-		for(;arg < argc;++arg) {
+		for (;arg < argc;++arg) {
 			if (argv[arg][0] != '-' || argv[arg][1] == '\0' || defaultMode) break;
 			if (argv[arg][0] != '-' || argv[arg][1] == '\0' || defaultMode) break;
 			parseArg(sections, argc, argv, defaultMode, arg, (char*)&ps);
 			parseArg(sections, argc, argv, defaultMode, arg, (char*)&ps);
 		}
 		}
 	}
 	}
-	
+
 	if (pageSettings.size() == 0 || argc < 2) {
 	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");
 		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);
 		usage(stderr, false);
@@ -198,5 +203,3 @@ void CommandLineParser::parseArguments(int argc, const char ** argv, bool fromSt
 	}
 	}
 	globalSettings.out = argv[argc-1];
 	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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // 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 "commandlineparserbase.hh"
+#include "settings.hh"
 #include <cstdio>
 #include <cstdio>
 
 
 class CommandLineParser: public CommandLineParserBase {
 class CommandLineParser: public CommandLineParserBase {
@@ -29,9 +34,9 @@ public:
 	QList<wkhtmltopdf::settings::Page> & pageSettings;
 	QList<wkhtmltopdf::settings::Page> & pageSettings;
 
 
 	wkhtmltopdf::settings::Page od;
 	wkhtmltopdf::settings::Page od;
-	
+
 	//Arguments.cc
 	//Arguments.cc
-	CommandLineParser(wkhtmltopdf::settings::Global & globalSettings, 
+	CommandLineParser(wkhtmltopdf::settings::Global & globalSettings,
 					  QList<wkhtmltopdf::settings::Page> & pageSettings);
 					  QList<wkhtmltopdf::settings::Page> & pageSettings);
 
 
 	//docparts.cc
 	//docparts.cc
@@ -49,7 +54,7 @@ public:
 	void outputCompilation(Outputter * o) const;
 	void outputCompilation(Outputter * o) const;
 	void outputInstallation(Outputter * o) const;
 	void outputInstallation(Outputter * o) const;
 	void outputExampels(Outputter * o) const;
 	void outputExampels(Outputter * o) const;
-	
+
 	//commandlineparser.cc
 	//commandlineparser.cc
 	virtual QString appName() const {return "wkhtmltopdf";}
 	virtual QString appName() const {return "wkhtmltopdf";}
 	virtual void usage(FILE * fd, bool extended) const;
 	virtual void usage(FILE * fd, bool extended) const;
@@ -60,10 +65,9 @@ public:
 
 
 	virtual char * mapAddress(char * d, char * ns) const {
 	virtual char * mapAddress(char * d, char * ns) const {
 		const char * _od = reinterpret_cast<const char *>(&od);
 		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;
 		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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparser.hh"
 #include "commandlineparser.hh"
 #include "outputter.hh"
 #include "outputter.hh"
 #include <QWebFrame>
 #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.");
 				 "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->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("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->paragraph("A table of content object inserts a table of content into the output document.");
 	o->verbatim("toc [TOC OPTION]...");
 	o->verbatim("toc [TOC OPTION]...");
 	o->beginParagraph();
 	o->beginParagraph();
@@ -107,7 +112,7 @@ void CommandLineParser::outputDescripton(Outputter * o) const {
 */
 */
 void CommandLineParser::outputNotPatched(Outputter * o, bool sure) const {
 void CommandLineParser::outputNotPatched(Outputter * o, bool sure) const {
 	o->beginSection("Reduced Functionality");
 	o->beginSection("Reduced Functionality");
-	if (sure) 
+	if (sure)
 		o->paragraph("This version of wkhtmltopdf has been compiled against a version of "
 		o->paragraph("This version of wkhtmltopdf has been compiled against a version of "
 					 "QT without the wkhtmltopdf patches. Therefore some features are missing, "
 					 "QT without the wkhtmltopdf patches. Therefore some features are missing, "
 					 "if you need these features please use the static version.");
 					 "if you need these features please use the static version.");
@@ -192,11 +197,11 @@ void CommandLineParser::outputHeaderFooterDoc(Outputter * o) const {
 "function subst() {\n"
 "function subst() {\n"
 "  var vars={};\n"
 "  var vars={};\n"
 "  var x=document.location.search.substring(1).split('&');\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"
 "  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"
 "    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"
 "}\n"
 "}\n"
 "</script></head><body style=\"border:0; margin: 0;\" onload=\"subst()\">\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 "
 		"binary, however you still need to install some other pieces of "
 		"software, to learn more about this read the static version section "
 		"software, to learn more about this read the static version section "
 		"of the manual.");
 		"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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outline_p.hh"
 #include "outline_p.hh"
 #include <fstream>
 #include <fstream>
 #include <iostream>
 #include <iostream>
@@ -32,8 +36,7 @@ namespace wkhtmltopdf {
 */
 */
 
 
 OutlineItem::OutlineItem():
 OutlineItem::OutlineItem():
-	parent(NULL), page(-1)
-{}
+	parent(NULL), page(-1) {}
 
 
 /*!
 /*!
   \brief Recursivily delete the subtree
   \brief Recursivily delete the subtree
@@ -49,9 +52,9 @@ bool OutlineItem::differentFrom(OutlineItem * other) const {
 		other->document != document ||
 		other->document != document ||
 		other->value != value ||
 		other->value != value ||
 		other->display != display) return true;
 		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 true;
 	return false;
 	return false;
 }
 }
@@ -67,7 +70,7 @@ OutlinePrivate::OutlinePrivate(const settings::Global & s):
 }
 }
 
 
 OutlinePrivate::~OutlinePrivate() {
 OutlinePrivate::~OutlinePrivate() {
-	foreach (OutlineItem * i, documentOutlines) 
+	foreach (OutlineItem * i, documentOutlines)
 		delete i;
 		delete i;
 }
 }
 
 
@@ -97,15 +100,15 @@ QString escape(QString & str) {
 }
 }
 
 
 void OutlinePrivate::dumpChildren(QTextStream & stream, const QList<OutlineItem *> & items, int level) const {
 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) << "\"";
 		stream << "<item title=\"" << escape(item->value) << "\" page=\"" << (item->page + prefixSum[item->document]) << "\" link=\"" << escape(item->anchor) << "\" backLink=\"" << escape(item->tocAnchor) << "\"";
 		if (item->children.empty())
 		if (item->children.empty())
 			stream << "/>" << endl;
 			stream << "/>" << endl;
 		else {
 		else {
 			stream << ">" << endl;
 			stream << ">" << endl;
 			dumpChildren(stream, item->children, level+1);
 			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;
 			stream << "</item>" << endl;
 		}
 		}
 	}
 	}
@@ -114,9 +117,9 @@ void OutlinePrivate::dumpChildren(QTextStream & stream, const QList<OutlineItem
 void Outline::dump(QTextStream & stream, const QString & xsl) const {
 void Outline::dump(QTextStream & stream, const QString & xsl) const {
 	d->prefixSum.clear();
 	d->prefixSum.clear();
 	d->prefixSum.push_back(0);
 	d->prefixSum.push_back(0);
-	foreach(int x, d->documentPages)
+	foreach (int x, d->documentPages)
 		d->prefixSum.push_back( d->prefixSum.back() + x );
 		d->prefixSum.push_back( d->prefixSum.back() + x );
-	
+
 	stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
 	stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
 	QString x = xsl;
 	QString x = xsl;
 	if (!x.isEmpty())
 	if (!x.isEmpty())
@@ -151,19 +154,19 @@ Outline::~Outline() {delete d;}
   \param wp A webprinter for the page
   \param wp A webprinter for the page
   \param frame The frame containing the webpage
   \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) {
 							 QHash<QString, QWebElement> & anchors) {
 	QMap< QPair<int, QPair<qreal,qreal> >, QWebElement> headings;
 	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);
 		QPair<int, QRectF> location = wp.elementLocation(e);
 		headings[ qMakePair(location.first, qMakePair(location.second.y(), location.second.x()) ) ] = 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,
 	//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
 	//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
 	//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;
 	root->display = true;
 
 
 	OutlineItem * old = root;
 	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) {
 		i != headings.end(); ++i) {
 		const QWebElement & element = i.value();
 		const QWebElement & element = i.value();
 		uint level = element.tagName().mid(1).toInt();
 		uint level = element.tagName().mid(1).toInt();
@@ -192,7 +195,7 @@ bool Outline::replaceWebPage(int document,
 
 
 		if (!d->linkNames[document].contains(value))
 		if (!d->linkNames[document].contains(value))
 			d->linkNames[document][value] = QString("__WKANCHOR_")+QString::number(d->anchorCounter++,36);
 			d->linkNames[document][value] = QString("__WKANCHOR_")+QString::number(d->anchorCounter++,36);
-		
+
 		if (!d->backLinkNames[document].contains(value))
 		if (!d->backLinkNames[document].contains(value))
 			d->backLinkNames[document][value] = QString("__WKANCHOR_")+QString::number(d->anchorCounter++,36);
 			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];
 		item->tocAnchor = d->backLinkNames[document][value];
 		if (ps.toc.forwardLinks)
 		if (ps.toc.forwardLinks)
 			anchors[item->anchor] = element;
 			anchors[item->anchor] = element;
-		if (ps.toc.backLinks) 
+		if (ps.toc.backLinks)
 			local.push_back( QPair<QWebElement, QString>(element, item->tocAnchor) );
 			local.push_back( QPair<QWebElement, QString>(element, item->tocAnchor) );
 
 
-		while(levelStack.back() >= level) {
+		while (levelStack.back() >= level) {
 			old = old->parent;
 			old = old->parent;
 			levelStack.pop_back();
 			levelStack.pop_back();
 		}
 		}
@@ -215,7 +218,7 @@ bool Outline::replaceWebPage(int document,
 
 
 	bool changed=d->documentOutlines[document]->differentFrom(root);
 	bool changed=d->documentOutlines[document]->differentFrom(root);
 	delete d->documentOutlines[document];
 	delete d->documentOutlines[document];
-	d->documentOutlines[document] = root; 
+	d->documentOutlines[document] = root;
 
 
 	if (d->documentPages[document] != wp.pageCount()) {
 	if (d->documentPages[document] != wp.pageCount()) {
 		d->pageCount -= d->documentPages[document];
 		d->pageCount -= d->documentPages[document];
@@ -233,7 +236,7 @@ bool Outline::replaceWebPage(int document,
   \param frame The frame containing the webpage
   \param frame The frame containing the webpage
 */
 */
 void Outline::addWebPage(const QString & name, QWebPrinter & wp, QWebFrame * frame, const settings::Page & ps,
 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) {
 						 QHash<QString, QWebElement> & anchors) {
 	Q_UNUSED(name);
 	Q_UNUSED(name);
 	addEmptyWebPage();
 	addEmptyWebPage();
@@ -260,8 +263,8 @@ void OutlinePrivate::buildHFCache(OutlineItem * i, int level) {
 	foreach (OutlineItem * j, i->children) {
 	foreach (OutlineItem * j, i->children) {
 		while (hfCache[level].size() < (int)j->page)
 		while (hfCache[level].size() < (int)j->page)
 			hfCache[level].push_back(hfCache[level].back());
 			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);
 			hfCache[level].push_back(j);
 		buildHFCache(j, level+1);
 		buildHFCache(j, level+1);
 	}
 	}
@@ -281,18 +284,18 @@ void Outline::fillHeaderFooterParms(int page, QHash<QString, QString> & parms, c
 			x.push_back(NULL);
 			x.push_back(NULL);
 			d->hfCache.push_back(x);
 			d->hfCache.push_back(x);
 		}
 		}
-		foreach (OutlineItem * i, d->documentOutlines) 
+		foreach (OutlineItem * i, d->documentOutlines)
 			d->buildHFCache(i, 0);
 			d->buildHFCache(i, 0);
 	}
 	}
 	for (int i=0; i < 3; ++i)
 	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());
 			d->hfCache[i].push_back(d->hfCache[i].back());
 
 
 	int off = d->settings.pageOffset;
 	int off = d->settings.pageOffset;
 	typedef QPair<QString,QString> SP;
 	typedef QPair<QString,QString> SP;
-	foreach (const SP & rep, ps.replacements) 
+	foreach (const SP & rep, ps.replacements)
 		parms[rep.first] = rep.second;
 		parms[rep.first] = rep.second;
-		
+
 	parms["frompage"] = QString::number(off+1);
 	parms["frompage"] = QString::number(off+1);
 	parms["topage"] = QString::number(off+d->pageCount);
 	parms["topage"] = QString::number(off+d->pageCount);
 	parms["page" ] = QString::number(page+off);
 	parms["page" ] = QString::number(page+off);
@@ -325,7 +328,7 @@ int Outline::pageCount() {
 */
 */
 void Outline::printOutline(QPrinter * printer) {
 void Outline::printOutline(QPrinter * printer) {
 	if (!d->settings.outline) return;
 	if (!d->settings.outline) return;
-	foreach(OutlineItem * i, d->documentOutlines)
+	foreach (OutlineItem * i, d->documentOutlines)
 		d->outlineChildren(i, printer, 0);
 		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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __OUTLINE_HH__
 #ifndef __OUTLINE_HH__
 #define __OUTLINE_HH__
 #define __OUTLINE_HH__
 #include <QWebFrame>
 #include <QWebFrame>
 #ifdef  __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #ifdef  __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
-#include <QWebElement>
 #include "settings.hh"
 #include "settings.hh"
+#include <QWebElement>
 
 
 namespace wkhtmltopdf {
 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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef __OUTLINE_P_HH__
+#define __OUTLINE_P_HH__
 #ifndef __OUTLINE_P_HH
 #ifndef __OUTLINE_P_HH
 #define __OUTLINE_P_HH
 #define __OUTLINE_P_HH
 #include "outline.hh"
 #include "outline.hh"
@@ -60,3 +66,4 @@ public:
 }
 }
 #endif //__EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #endif //__EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #endif //__OUTLINE_P_HH
 #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(../../version.pri)
 include(../../common.pri)
 include(../../common.pri)
 
 
@@ -42,5 +59,3 @@ SOURCES += settings.cc pdfconverter.cc \
 
 
 SOURCES += wkhtmltopdf.cc arguments.cc commandlineparser.cc \
 SOURCES += wkhtmltopdf.cc arguments.cc commandlineparser.cc \
            docparts.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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "pdfconverter_p.hh"
 #include "pdfconverter_p.hh"
 #include <QAuthenticator>
 #include <QAuthenticator>
 #include <QDateTime>
 #include <QDateTime>
@@ -29,8 +33,8 @@
 #include <qapplication.h>
 #include <qapplication.h>
 #include <qfileinfo.h>
 #include <qfileinfo.h>
 #ifdef Q_OS_WIN32
 #ifdef Q_OS_WIN32
-#include <io.h>
 #include <fcntl.h>
 #include <fcntl.h>
+#include <io.h>
 #endif
 #endif
 
 
 using namespace wkhtmltopdf;
 using namespace wkhtmltopdf;
@@ -48,7 +52,7 @@ struct StreamDumper {
 		stream.setCodec("UTF-8");
 		stream.setCodec("UTF-8");
 	}
 	}
 };
 };
- 
+
 /*!
 /*!
   \file pageconverter.hh
   \file pageconverter.hh
   \brief Defines the PdfConverter class
   \brief Defines the PdfConverter class
@@ -73,12 +77,12 @@ PdfConverterPrivate::PdfConverterPrivate(Global & s, PdfConverter & o) :
 	, outline(0), tocPrinter(0)
 	, outline(0), tocPrinter(0)
 #endif
 #endif
 {
 {
-		
+
 #ifdef  __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #ifdef  __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 	phaseDescriptions.push_back("Loading pages");
 	phaseDescriptions.push_back("Loading pages");
 	phaseDescriptions.push_back("Counting pages");
 	phaseDescriptions.push_back("Counting pages");
 	phaseDescriptions.push_back("Loading TOC");
 	phaseDescriptions.push_back("Loading TOC");
-	phaseDescriptions.push_back("Resolving links");	
+	phaseDescriptions.push_back("Resolving links");
 	phaseDescriptions.push_back("Loading headers and footers");
 	phaseDescriptions.push_back("Loading headers and footers");
 #else
 #else
 	phaseDescriptions.push_back("Loading page");
 	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(error(QString)), this, SLOT(forwardError(QString)));
 	connect(&pageLoader, SIGNAL(warning(QString)), this, SLOT(forwardWarning(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(loadProgress(int)), this, SLOT(loadProgress(int)));
 	connect(&hfLoader, SIGNAL(loadFinished(bool)), this, SLOT(headersLoaded(bool)));
 	connect(&hfLoader, SIGNAL(loadFinished(bool)), this, SLOT(headersLoaded(bool)));
 	connect(&hfLoader, SIGNAL(error(QString)), this, SLOT(forwardError(QString)));
 	connect(&hfLoader, SIGNAL(error(QString)), this, SLOT(forwardError(QString)));
@@ -120,7 +124,7 @@ void PdfConverterPrivate::beginConvert() {
 	currentPhase=0;
 	currentPhase=0;
 	errorCode=0;
 	errorCode=0;
 
 
-#ifndef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__	
+#ifndef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 	if (objects.size() > 1) {
 	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.");
 		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();
 		fail();
@@ -130,8 +134,8 @@ void PdfConverterPrivate::beginConvert() {
 
 
 	for (QList<PageObject>::iterator i=objects.begin(); i != objects.end(); ++i) {
 	for (QList<PageObject>::iterator i=objects.begin(); i != objects.end(); ++i) {
 		PageObject & o=*i;
 		PageObject & o=*i;
-		settings::Page & s = o.settings;		
-		
+		settings::Page & s = o.settings;
+
 		if (!s.header.htmlUrl.isEmpty() && looksLikeHtmlAndNotAUrl(s.header.htmlUrl)) {
 		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.");
 			emit out.error("--header-html should be a URL and not a string containing HTML code.");
 			fail();
 			fail();
@@ -152,7 +156,7 @@ void PdfConverterPrivate::beginConvert() {
 		}
 		}
 	}
 	}
 
 
-	
+
 	emit out.phaseChanged();
 	emit out.phaseChanged();
 	loadProgress(0);
 	loadProgress(0);
 
 
@@ -167,7 +171,7 @@ void PdfConverterPrivate::beginConvert() {
 void PdfConverterPrivate::pagesLoaded(bool ok) {
 void PdfConverterPrivate::pagesLoaded(bool ok) {
 	if (errorCode == 0) errorCode = pageLoader.httpErrorCode();
 	if (errorCode == 0) errorCode = pageLoader.httpErrorCode();
 	if (!ok) {
 	if (!ok) {
-		fail(); 
+		fail();
 		return;
 		return;
 	}
 	}
 
 
@@ -184,7 +188,7 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 	printer = new QPrinter(settings.resolution);
 	printer = new QPrinter(settings.resolution);
 	if (settings.dpi != -1) printer->setResolution(settings.dpi);
 	if (settings.dpi != -1) printer->setResolution(settings.dpi);
 	//Tell the printer object to print the file <out>
 	//Tell the printer object to print the file <out>
-	
+
 	printer->setOutputFormat(
 	printer->setOutputFormat(
 		(settings.outputFormat == "ps" || (settings.outputFormat == "" && settings.out.endsWith(".ps", Qt::CaseInsensitive)))?
 		(settings.outputFormat == "ps" || (settings.outputFormat == "" && settings.out.endsWith(".ps", Qt::CaseInsensitive)))?
 	    QPrinter::PostScriptFormat : QPrinter::PdfFormat
 	    QPrinter::PostScriptFormat : QPrinter::PdfFormat
@@ -204,14 +208,13 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 	printer->setPageMargins(settings.margin.left.first, settings.margin.top.first,
 	printer->setPageMargins(settings.margin.left.first, settings.margin.top.first,
 							settings.margin.right.first, settings.margin.bottom.first,
 							settings.margin.right.first, settings.margin.bottom.first,
 							settings.margin.left.second);
 							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);
 		printer->setPaperSize(QSizeF(settings.size.width.first,settings.size.height.first), settings.size.height.second);
-	}
-	else {
+	} else {
 		printer->setPaperSize(settings.size.pageSize);
 		printer->setPaperSize(settings.size.pageSize);
 	}
 	}
-	
+
 	printer->setOrientation(settings.orientation);
 	printer->setOrientation(settings.orientation);
 	printer->setColorMode(settings.colorMode);
 	printer->setColorMode(settings.colorMode);
 
 
@@ -233,11 +236,11 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 	printer->printEngine()->setProperty(QPrintEngine::PPK_ImageDPI, settings.imageDPI);
 	printer->printEngine()->setProperty(QPrintEngine::PPK_ImageDPI, settings.imageDPI);
 
 
 	painter = new QPainter();
 	painter = new QPainter();
-	
+
 	title = settings.documentTitle;
 	title = settings.documentTitle;
-	for(int d=0; d < objects.size(); ++d) {
+	for (int d=0; d < objects.size(); ++d) {
 		if (title != "") break;
 		if (title != "") break;
-		if (!objects[d].loaderObject || objects[d].loaderObject->skip || 
+		if (!objects[d].loaderObject || objects[d].loaderObject->skip ||
 			objects[d].settings.isTableOfContent) continue;
 			objects[d].settings.isTableOfContent) continue;
 		title = objects[d].page->mainFrame()->title();
 		title = objects[d].page->mainFrame()->title();
 	}
 	}
@@ -247,7 +250,7 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 		fail();
 		fail();
 		return;
 		return;
 	}
 	}
-	
+
 	currentPhase = 1;
 	currentPhase = 1;
 	emit out.phaseChanged();
 	emit out.phaseChanged();
 	outline = new Outline(settings);
 	outline = new Outline(settings);
@@ -256,7 +259,7 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 	// * A visual ordering of the header element
 	// * A visual ordering of the header element
 	// * The location and page number of each header
 	// * The location and page number of each header
 	pageCount = 0;
 	pageCount = 0;
-	for(int d=0; d < objects.size(); ++d) {
+	for (int d=0; d < objects.size(); ++d) {
 		PageObject & obj = objects[d];
 		PageObject & obj = objects[d];
 		if (obj.settings.isTableOfContent) {
 		if (obj.settings.isTableOfContent) {
 			obj.pageCount = 1;
 			obj.pageCount = 1;
@@ -265,7 +268,7 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 			continue;
 			continue;
 		}
 		}
 		if (!obj.loaderObject || obj.loaderObject->skip) continue;
 		if (!obj.loaderObject || obj.loaderObject->skip) continue;
-			
+
 		int tot = objects.size();
 		int tot = objects.size();
 		progressString = QString("Object ")+QString::number(d+1)+QString(" of ")+QString::number(tot);
 		progressString = QString("Object ")+QString::number(d+1)+QString(" of ")+QString::number(tot);
 		emit out.progressChanged((d+1)*100 / tot);
 		emit out.progressChanged((d+1)*100 / tot);
@@ -274,14 +277,14 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
 		QWebPrinter wp(obj.page->mainFrame(), printer, *painter);
 		QWebPrinter wp(obj.page->mainFrame(), printer, *painter);
 		obj.pageCount = objects[d].settings.pagesCount? wp.pageCount(): 0;
 		obj.pageCount = objects[d].settings.pagesCount? wp.pageCount(): 0;
 		pageCount += objects[d].pageCount;
 		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);
 							obj.settings, obj.localLinks, obj.anchors);
 		painter->restore();
 		painter->restore();
 	}
 	}
 
 
 	actualPages = pageCount * settings.copies;
 	actualPages = pageCount * settings.copies;
-	
+
 	loadTocs();
 	loadTocs();
 #endif
 #endif
 }
 }
@@ -293,10 +296,10 @@ void PdfConverterPrivate::loadHeaders() {
 	bool hf=false;
 	bool hf=false;
 
 
 	int pageNumber=1;
 	int pageNumber=1;
-	for(int d=0; d < objects.size(); ++d) {
+	for (int d=0; d < objects.size(); ++d) {
 		PageObject & obj = objects[d];
 		PageObject & obj = objects[d];
 		if (!obj.loaderObject || obj.loaderObject->skip) continue;
 		if (!obj.loaderObject || obj.loaderObject->skip) continue;
-				
+
 		settings::Page & ps = obj.settings;
 		settings::Page & ps = obj.settings;
 		for (int op=0; op < obj.pageCount; ++op) {
 		for (int op=0; op < obj.pageCount; ++op) {
 			if (!ps.header.htmlUrl.isEmpty() || !ps.footer.htmlUrl.isEmpty()) {
 			if (!ps.header.htmlUrl.isEmpty() || !ps.footer.htmlUrl.isEmpty()) {
@@ -314,9 +317,9 @@ void PdfConverterPrivate::loadHeaders() {
 	}
 	}
 	if (hf)
 	if (hf)
 		hfLoader.load();
 		hfLoader.load();
-	else 
+	else
 		printDocument();
 		printDocument();
-#endif	
+#endif
 }
 }
 
 
 
 
@@ -324,9 +327,9 @@ void PdfConverterPrivate::loadTocs() {
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 	std::swap(tocLoaderOld, tocLoader);
 	std::swap(tocLoaderOld, tocLoader);
 	tocLoader->clearResources();
 	tocLoader->clearResources();
-	
+
 	bool toc=false;
 	bool toc=false;
-	for(int d=0; d < objects.size(); ++d) {
+	for (int d=0; d < objects.size(); ++d) {
 		PageObject & obj = objects[d];
 		PageObject & obj = objects[d];
 		settings::Page & ps = obj.settings;
 		settings::Page & ps = obj.settings;
 		if (!ps.isTableOfContent) continue;
 		if (!ps.isTableOfContent) continue;
@@ -335,11 +338,11 @@ void PdfConverterPrivate::loadTocs() {
 		QString style = obj.tocStyleFile.create(".xsl");
 		QString style = obj.tocStyleFile.create(".xsl");
 		StreamDumper styleDump(style);
 		StreamDumper styleDump(style);
 		dumpDefaultTOCStyleSheet(styleDump.stream, ps.toc);
 		dumpDefaultTOCStyleSheet(styleDump.stream, ps.toc);
-		
+
 		QString path = obj.tocFile.create(".xml");
 		QString path = obj.tocFile.create(".xml");
 		StreamDumper sd(path);
 		StreamDumper sd(path);
 		outline->dump(sd.stream, style);
 		outline->dump(sd.stream, style);
-		
+
 		obj.loaderObject = tocLoader->addResource(path, ps.load);
 		obj.loaderObject = tocLoader->addResource(path, ps.load);
 		obj.page = &obj.loaderObject->page;
 		obj.page = &obj.loaderObject->page;
 		PageObject::webPageToObject[obj.page] = &obj;
 		PageObject::webPageToObject[obj.page] = &obj;
@@ -353,7 +356,7 @@ void PdfConverterPrivate::loadTocs() {
 			emit out.phaseChanged();
 			emit out.phaseChanged();
 		}
 		}
 		tocLoader->load();
 		tocLoader->load();
-	} else 
+	} else
 		tocLoaded(true);
 		tocLoaded(true);
 #endif
 #endif
 }
 }
@@ -381,11 +384,11 @@ void PdfConverterPrivate::findLinks(QWebFrame * frame, QVector<QPair<QWebElement
 				if (ulocal) {
 				if (ulocal) {
 					PageObject * p = urlToPageObj[href.toString(QUrl::RemoveFragment)];
 					PageObject * p = urlToPageObj[href.toString(QUrl::RemoveFragment)];
 					QWebElement e;
 					QWebElement e;
-					if (!href.hasFragment()) 
+					if (!href.hasFragment())
 						e = p->page->mainFrame()->findFirstElement("body");
 						e = p->page->mainFrame()->findFirstElement("body");
 					else {
 					else {
 						e = p->page->mainFrame()->findFirstElement("a[name=\""+href.fragment()+"\"]");
 						e = p->page->mainFrame()->findFirstElement("a[name=\""+href.fragment()+"\"]");
-						if(e.isNull()) 
+						if (e.isNull())
 							e = p->page->mainFrame()->findFirstElement("*[id=\""+href.fragment()+"\"]");
 							e = p->page->mainFrame()->findFirstElement("*[id=\""+href.fragment()+"\"]");
 					}
 					}
 					if (!e.isNull()) {
 					if (!e.isNull()) {
@@ -416,9 +419,9 @@ void PdfConverterPrivate::beginPage(int actualPage) {
 }
 }
 
 
 void PdfConverterPrivate::endPage(PageObject & object, bool hasHeaderFooter, int objectPage, int pageNumber) {
 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;
 	settings::Page & s = object.settings;
-	if(hasHeaderFooter) {
+	if (hasHeaderFooter) {
 		QHash<QString, QString> parms;
 		QHash<QString, QString> parms;
 		fillParms(parms, pageNumber, object);
 		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
 		//We save it here and restore some sane defaults
 		painter->save();
 		painter->save();
 		painter->resetTransform();
 		painter->resetTransform();
-						
+
 		int h=printer->height();
 		int h=printer->height();
 		int w=printer->width();
 		int w=printer->width();
-						
+
 		double spacing = s.header.spacing * printer->height() / printer->heightMM();
 		double spacing = s.header.spacing * printer->height() / printer->heightMM();
 		//If needed draw the header line
 		//If needed draw the header line
 		if (s.header.line) painter->drawLine(0, -spacing, w, -spacing);
 		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::AlignLeft, hfreplace(s.header.left, parms));
 		painter->drawText(r, Qt::AlignTop | Qt::AlignHCenter, hfreplace(s.header.center, 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));
 		painter->drawText(r, Qt::AlignTop | Qt::AlignRight, hfreplace(s.header.right, parms));
-		
+
 		spacing = s.footer.spacing * printer->height() / printer->heightMM();
 		spacing = s.footer.spacing * printer->height() / printer->heightMM();
 		//IF needed draw the footer line
 		//IF needed draw the footer line
 		if (s.footer.line) painter->drawLine(0, h + spacing, w, h + spacing);
 		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::AlignLeft, hfreplace(s.footer.left, parms));
 		painter->drawText(r, Qt::AlignBottom | Qt::AlignHCenter, hfreplace(s.footer.center, 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));
 		painter->drawText(r, Qt::AlignBottom | Qt::AlignRight, hfreplace(s.footer.right, parms));
-		
+
 		//Restore Webkit's crazy scaling and font settings
 		//Restore Webkit's crazy scaling and font settings
 		painter->restore();
 		painter->restore();
 	}
 	}
@@ -470,11 +473,11 @@ void PdfConverterPrivate::endPage(PageObject & object, bool hasHeaderFooter, int
 		QVector<p_t> external;
 		QVector<p_t> external;
 		QHash<QString, QWebElement> anchors;
 		QHash<QString, QWebElement> anchors;
 		findLinks(header->mainFrame(), local, external, 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;
 			QRectF r = wp.elementLocation(p.first).second;
 			painter->addLink(r, p.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;
 			QRectF r = wp.elementLocation(p.first).second;
 			painter->addHyperlink(r, QUrl(p.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();
 		double spacing = s.footer.spacing * printer->height() / printer->heightMM();
 		painter->translate(0, printer->height()+ spacing);
 		painter->translate(0, printer->height()+ spacing);
 		QWebPrinter wp(footer->mainFrame(), printer, *painter);
 		QWebPrinter wp(footer->mainFrame(), printer, *painter);
-		
+
 		QVector<p_t> local;
 		QVector<p_t> local;
 		QVector<p_t> external;
 		QVector<p_t> external;
 		QHash<QString, QWebElement> anchors;
 		QHash<QString, QWebElement> anchors;
 		findLinks(footer->mainFrame(), local, external, 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;
 			QRectF r = wp.elementLocation(p.first).second;
 			painter->addLink(r, p.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;
 			QRectF r = wp.elementLocation(p.first).second;
 			painter->addHyperlink(r, QUrl(p.second));
 			painter->addHyperlink(r, QUrl(p.second));
 		}
 		}
@@ -518,14 +521,14 @@ void PdfConverterPrivate::tocLoaded(bool ok) {
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 	bool changed=false;
 	bool changed=false;
 	pageCount = 0;
 	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].loaderObject || objects[d].loaderObject->skip) continue;
 
 
 		if (!objects[d].settings.isTableOfContent) {
 		if (!objects[d].settings.isTableOfContent) {
 			pageCount += objects[d].pageCount;
 			pageCount += objects[d].pageCount;
 			continue;
 			continue;
 		}
 		}
-			
+
 		painter->save();
 		painter->save();
 		QWebPrinter wp(objects[d].page->mainFrame(), printer, *painter);
 		QWebPrinter wp(objects[d].page->mainFrame(), printer, *painter);
 		int pc = objects[d].settings.pagesCount? wp.pageCount(): 0;
 		int pc = objects[d].settings.pagesCount? wp.pageCount(): 0;
@@ -545,15 +548,15 @@ void PdfConverterPrivate::tocLoaded(bool ok) {
 		//Find and resolve all local links
 		//Find and resolve all local links
 		currentPhase = 3;
 		currentPhase = 3;
 		emit out.phaseChanged();
 		emit out.phaseChanged();
-		
+
 		QHash<QString, int> urlToDoc;
 		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].loaderObject || objects[d].loaderObject->skip) continue;
 			if (objects[d].settings.isTableOfContent) continue;
 			if (objects[d].settings.isTableOfContent) continue;
 			urlToPageObj[ objects[d].page->mainFrame()->url().toString(QUrl::RemoveFragment) ] = &objects[d];
 			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;
 			if (!objects[d].loaderObject || objects[d].loaderObject->skip) continue;
 			progressString = QString("Object ")+QString::number(d+1)+QString(" of ")+QString::number(objects.size());
 			progressString = QString("Object ")+QString::number(d+1)+QString(" of ")+QString::number(objects.size());
 			emit out.progressChanged((d+1)*100 / objects.size());
 			emit out.progressChanged((d+1)*100 / objects.size());
@@ -584,7 +587,7 @@ void PdfConverterPrivate::printDocument() {
 	emit out.progressChanged(-1);
 	emit out.progressChanged(-1);
 #else
 #else
  	int actualPage=1;
  	int actualPage=1;
-		
+
  	int cc=settings.collate?settings.copies:1;
  	int cc=settings.collate?settings.copies:1;
  	int pc=settings.collate?1:settings.copies;
  	int pc=settings.collate?1:settings.copies;
 
 
@@ -594,9 +597,9 @@ void PdfConverterPrivate::printDocument() {
 	progressString = "Preparing";
 	progressString = "Preparing";
 	emit out.progressChanged(0);
 	emit out.progressChanged(0);
 
 
-	for(int cc_=0; cc_ < cc; ++cc_) {
+	for (int cc_=0; cc_ < cc; ++cc_) {
 		int pageNumber=1;
 		int pageNumber=1;
-		for(int d=0; d < objects.size(); ++d) {
+		for (int d=0; d < objects.size(); ++d) {
 			PageObject & obj = objects[d];
 			PageObject & obj = objects[d];
 			if (!obj.loaderObject || obj.loaderObject->skip) continue;
 			if (!obj.loaderObject || obj.loaderObject->skip) continue;
 			const settings::Page & ps = obj.settings;
 			const settings::Page & ps = obj.settings;
@@ -608,49 +611,49 @@ void PdfConverterPrivate::printDocument() {
 			painter->save();
 			painter->save();
 
 
 			if (ps.produceForms) {
 			if (ps.produceForms) {
-				foreach(QWebElement elm, obj.page->mainFrame()->findAllElements("input")) 
+				foreach (QWebElement elm, obj.page->mainFrame()->findAllElements("input"))
 				 	elm.setStyleProperty("color","white");
 				 	elm.setStyleProperty("color","white");
-				foreach(QWebElement elm, obj.page->mainFrame()->findAllElements("textarea")) 
+				foreach (QWebElement elm, obj.page->mainFrame()->findAllElements("textarea"))
 				 	elm.setStyleProperty("color","white");
 				 	elm.setStyleProperty("color","white");
 			}
 			}
 
 
-			//output 
+			//output
 			QWebPrinter wp(obj.page->mainFrame(), printer, *painter);
 			QWebPrinter wp(obj.page->mainFrame(), printer, *painter);
 			QString l1=obj.page->mainFrame()->url().path().split("/").back()+"#";
 			QString l1=obj.page->mainFrame()->url().path().split("/").back()+"#";
 			QString l2=obj.page->mainFrame()->url().toString() + "#";
 			QString l2=obj.page->mainFrame()->url().toString() + "#";
 
 
-			outline->fillAnchors(d, obj.anchors);				
+			outline->fillAnchors(d, obj.anchors);
 
 
 			//Sort anchors and links by page
 			//Sort anchors and links by page
 			QHash<int, QHash<QString, QWebElement> > myAnchors;
 			QHash<int, QHash<QString, QWebElement> > myAnchors;
 			QHash<int, QVector< QPair<QWebElement,QString> > > myLocalLinks;
 			QHash<int, QVector< QPair<QWebElement,QString> > > myLocalLinks;
 			QHash<int, QVector< QPair<QWebElement,QString> > > myExternalLinks;
 			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)
 				i != obj.anchors.end(); ++i)
 				myAnchors[ wp.elementLocation(i.value()).first][i.key()] = i.value();
 				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)
 				i != obj.localLinks.end(); ++i)
 				myLocalLinks[wp.elementLocation(i->first).first].push_back(*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)
 				i != obj.externalLinks.end(); ++i)
 				myExternalLinks[wp.elementLocation(i->first).first].push_back(*i);
 				myExternalLinks[wp.elementLocation(i->first).first].push_back(*i);
 
 
 			QHash<int, QVector<QWebElement> > myFormElements;
 			QHash<int, QVector<QWebElement> > myFormElements;
 			if (ps.produceForms) {
 			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);
 					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);
 					myFormElements[wp.elementLocation(elm).first].push_back(elm);
 			}
 			}
 			emit out.producingForms( obj.settings.produceForms);
 			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);
 					beginPage(actualPage);
 					wp.spoolPage(p+1);
 					wp.spoolPage(p+1);
 
 
-					foreach(QWebElement elm, myFormElements[p+1]) {
+					foreach (QWebElement elm, myFormElements[p+1]) {
 						QString type = elm.attribute("type");
 						QString type = elm.attribute("type");
 						QString tn = elm.tagName();
 						QString tn = elm.tagName();
 						QString name = elm.attribute("name");
 						QString name = elm.attribute("name");
@@ -658,8 +661,8 @@ void PdfConverterPrivate::printDocument() {
 							painter->addTextField(
 							painter->addTextField(
 								wp.elementLocation(elm).second,
 								wp.elementLocation(elm).second,
 								tn == "TEXTAREA"?elm.toPlainText():elm.attribute("value"),
 								tn == "TEXTAREA"?elm.toPlainText():elm.attribute("value"),
-								name, 
-								tn == "TEXTAREA",		   
+								name,
+								tn == "TEXTAREA",
 								type == "password",
 								type == "password",
 								elm.evaluateJavaScript("this.readonly;").toBool(),
 								elm.evaluateJavaScript("this.readonly;").toBool(),
 								elm.hasAttribute("maxlength")?elm.attribute("maxlength").toInt():-1
 								elm.hasAttribute("maxlength")?elm.attribute("maxlength").toInt():-1
@@ -667,23 +670,23 @@ void PdfConverterPrivate::printDocument() {
 						} else if (type == "checkbox") {
 						} else if (type == "checkbox") {
 							painter->addCheckBox(
 							painter->addCheckBox(
 								wp.elementLocation(elm).second,
 								wp.elementLocation(elm).second,
-								elm.evaluateJavaScript("this.checked;").toBool(), 
+								elm.evaluateJavaScript("this.checked;").toBool(),
 								name,
 								name,
 								elm.evaluateJavaScript("this.readonly;").toBool());
 								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) {
 						i != myAnchors[p+1].end(); ++i) {
 						QRectF r = wp.elementLocation(i.value()).second;
 						QRectF r = wp.elementLocation(i.value()).second;
 						painter->addAnchor(r, i.key());
 						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;
 						QRectF r = wp.elementLocation(i->first).second;
 						painter->addLink(r, i->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;
 						QRectF r = wp.elementLocation(i->first).second;
 						painter->addHyperlink(r, QUrl(i->second));
 						painter->addHyperlink(r, QUrl(i->second));
 					}
 					}
@@ -710,7 +713,7 @@ void PdfConverterPrivate::printDocument() {
 #ifdef Q_OS_WIN32
 #ifdef Q_OS_WIN32
 		_setmode(_fileno(stdout), _O_BINARY);
 		_setmode(_fileno(stdout), _O_BINARY);
 #endif
 #endif
-		if( !i.open(QIODevice::ReadOnly) || 
+		if ( !i.open(QIODevice::ReadOnly) ||
 			!o.open(stdout,QIODevice::WriteOnly) ||
 			!o.open(stdout,QIODevice::WriteOnly) ||
 			!MultiPageLoader::copyFile(i,o) ) {
 			!MultiPageLoader::copyFile(i,o) ) {
 			emit out.error("Count not write to stdout");
 			emit out.error("Count not write to stdout");
@@ -727,14 +730,14 @@ void PdfConverterPrivate::printDocument() {
 	emit out.phaseChanged();
 	emit out.phaseChanged();
 	convertionDone = true;
 	convertionDone = true;
 	emit out.finished(true);
 	emit out.finished(true);
-	
+
 	qApp->exit(0); // quit qt's event handling
 	qApp->exit(0); // quit qt's event handling
 }
 }
 
 
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 QWebPage * PdfConverterPrivate::loadHeaderFooter(QString url, const QHash<QString, QString> & parms, const settings::Page & ps) {
 QWebPage * PdfConverterPrivate::loadHeaderFooter(QString url, const QHash<QString, QString> & parms, const settings::Page & ps) {
 	QUrl u = MultiPageLoader::guessUrlFromString(url);
 	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());
 		u.addQueryItem(i.key(), i.value());
 	return &hfLoader.addResource(u, ps.load)->page;
 	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 PdfConverterPrivate::hfreplace(const QString & q, const QHash<QString, QString> & parms) {
 	QString r=q;
 	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);
 		r=r.replace("["+i.key()+"]", i.value(), Qt::CaseInsensitive);
 	return r;
 	return r;
 }
 }
@@ -762,13 +765,13 @@ void PdfConverterPrivate::clearResources() {
 
 
 	if (outline) delete outline;
 	if (outline) delete outline;
 	outline=0;
 	outline=0;
-	
+
 	tocPrinter = 0;
 	tocPrinter = 0;
 #endif
 #endif
 
 
 	if (printer) delete printer;
 	if (printer) delete printer;
 	printer = 0;
 	printer = 0;
-	
+
 	if (painter) delete painter;
 	if (painter) delete painter;
 	painter = 0;
 	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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // 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 "converter.hh"
+#include "settings.hh"
 
 
 namespace wkhtmltopdf {
 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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // 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 "multipageloader.hh"
 #include "outline.hh"
 #include "outline.hh"
 #include "pdfconverter.hh"
 #include "pdfconverter.hh"
-#include "converter_p.hh"
+#include "settings.hh"
 #include "tempfile.hh"
 #include "tempfile.hh"
 #include "tocprinter.hh"
 #include "tocprinter.hh"
 #include <QAtomicInt>
 #include <QAtomicInt>
@@ -30,7 +36,6 @@
 #include <QWaitCondition>
 #include <QWaitCondition>
 #include <QWebPage>
 #include <QWebPage>
 #include <qnetworkreply.h>
 #include <qnetworkreply.h>
-#include "settings.hh"
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #include <QWebElement>
 #include <QWebElement>
 #endif
 #endif
@@ -40,7 +45,7 @@ namespace wkhtmltopdf {
 class PageObject {
 class PageObject {
 public:
 public:
 	static QMap<QWebPage *, PageObject *> webPageToObject;
 	static QMap<QWebPage *, PageObject *> webPageToObject;
-	
+
 	settings::Page settings;
 	settings::Page settings;
 	LoaderObject * loaderObject;
 	LoaderObject * loaderObject;
 	QWebPage * page;
 	QWebPage * page;
@@ -77,7 +82,7 @@ public:
 	~PageObject() {
 	~PageObject() {
 		clear();
 		clear();
 	}
 	}
-	
+
 };
 };
 
 
 class PdfConverterPrivate: public ConverterPrivate {
 class PdfConverterPrivate: public ConverterPrivate {
@@ -111,7 +116,7 @@ private:
 	MultiPageLoader hfLoader;
 	MultiPageLoader hfLoader;
 	MultiPageLoader tocLoader1;
 	MultiPageLoader tocLoader1;
 	MultiPageLoader tocLoader2;
 	MultiPageLoader tocLoader2;
-	
+
 	MultiPageLoader * tocLoader;
 	MultiPageLoader * tocLoader;
 	MultiPageLoader * tocLoaderOld;
 	MultiPageLoader * tocLoaderOld;
 
 
@@ -133,7 +138,7 @@ public slots:
 	void pagesLoaded(bool ok);
 	void pagesLoaded(bool ok);
 	void tocLoaded(bool ok);
 	void tocLoaded(bool ok);
 	void headersLoaded(bool ok);
 	void headersLoaded(bool ok);
-	
+
 	void printDocument();
 	void printDocument();
 
 
 	void beginConvert();
 	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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#include <settings.hh>
+
 #include <QMap>
 #include <QMap>
+#include <settings.hh>
 #include <stdexcept>
 #include <stdexcept>
 namespace wkhtmltopdf {
 namespace wkhtmltopdf {
 namespace settings {
 namespace settings {
@@ -68,7 +72,7 @@ QMap<QString, QPrinter::PageSize> pageSizeMap() {
 */
 */
 QPrinter::PageSize strToPageSize(const char * s, bool * ok) {
 QPrinter::PageSize strToPageSize(const char * s, bool * ok) {
 	QMap<QString,QPrinter::PageSize> map = pageSizeMap();
 	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 (!i.key().compare(s, Qt::CaseInsensitive) ) continue;
 		if (ok) *ok=true;
 		if (ok) *ok=true;
 		return i.value();
 		return i.value();
@@ -79,7 +83,7 @@ QPrinter::PageSize strToPageSize(const char * s, bool * ok) {
 
 
 QString pageSizeToStr(QPrinter::PageSize ps) {
 QString pageSizeToStr(QPrinter::PageSize ps) {
 	QMap<QString,QPrinter::PageSize> map = pageSizeMap();
 	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();
 		if (i.value() == ps) return i.key();
 	}
 	}
 	return "";
 	return "";
@@ -140,7 +144,7 @@ UnitReal strToUnitReal(const char * o, bool * ok) {
 	else if (!strcasecmp(o+i,"point") || !strcasecmp(o+i,"pt"))
 	else if (!strcasecmp(o+i,"point") || !strcasecmp(o+i,"pt"))
 		u=QPrinter::Point;
 		u=QPrinter::Point;
 	else {
 	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()*s, u);
 	}
 	}
 	return UnitReal(QString(o).left(i).toDouble(ok)*s, u);
 	return UnitReal(QString(o).left(i).toDouble(ok)*s, u);
@@ -153,14 +157,14 @@ QString unitRealToStr(const UnitReal & ur, bool * ok) {
 		return "";
 		return "";
 	}
 	}
 	if (ok) *ok=true;
 	if (ok) *ok=true;
-	switch(ur.second) {
+	switch (ur.second) {
 	case QPrinter::Didot: c = "didot"; break;
 	case QPrinter::Didot: c = "didot"; break;
 	case QPrinter::Inch: c = "in"; break;
 	case QPrinter::Inch: c = "in"; break;
 	case QPrinter::Pica: c = "pica"; break;
 	case QPrinter::Pica: c = "pica"; break;
 	case QPrinter::DevicePixel: c = "px"; break;
 	case QPrinter::DevicePixel: c = "px"; break;
 	case QPrinter::Point: c = "pt"; break;
 	case QPrinter::Point: c = "pt"; break;
 	case QPrinter::Millimeter: c = "mm"; break;
 	case QPrinter::Millimeter: c = "mm"; break;
-	default: 
+	default:
 		if (ok) *ok=false; break;
 		if (ok) *ok=false; break;
 	}
 	}
 	return QString("%1%2").arg(ur.first).arg(c);
 	return QString("%1%2").arg(ur.first).arg(c);
@@ -168,7 +172,7 @@ QString unitRealToStr(const UnitReal & ur, bool * ok) {
 
 
 
 
 Size::Size():
 Size::Size():
-	pageSize(QPrinter::A4), 
+	pageSize(QPrinter::A4),
 	height(UnitReal(-1,QPrinter::Millimeter)),
 	height(UnitReal(-1,QPrinter::Millimeter)),
 	width(UnitReal(-1,QPrinter::Millimeter)) {}
 	width(UnitReal(-1,QPrinter::Millimeter)) {}
 
 
@@ -192,10 +196,10 @@ Global::Global():
 	quiet(false),
 	quiet(false),
 	useGraphics(false),
 	useGraphics(false),
 	orientation(QPrinter::Portrait),
 	orientation(QPrinter::Portrait),
-	colorMode(QPrinter::Color), 
+	colorMode(QPrinter::Color),
 	resolution(QPrinter::HighResolution),
 	resolution(QPrinter::HighResolution),
 	dpi(-1),
 	dpi(-1),
-	pageOffset(0), 
+	pageOffset(0),
 	copies(1),
 	copies(1),
 	collate(true),
 	collate(true),
 	outline(true),
 	outline(true),
@@ -204,9 +208,8 @@ Global::Global():
 	out("-"),
 	out("-"),
 	documentTitle(""),
 	documentTitle(""),
 	useCompression(true),
 	useCompression(true),
-	imageDPI(600), 
-	imageQuality(94)
-{};
+	imageDPI(600),
+	imageQuality(94) {};
 
 
 TableOfContent::TableOfContent():
 TableOfContent::TableOfContent():
 	useDottedLines(true),
 	useDottedLines(true),
@@ -214,8 +217,7 @@ TableOfContent::TableOfContent():
 	forwardLinks(true),
 	forwardLinks(true),
 	backLinks(false),
 	backLinks(false),
 	indentation("1em"),
 	indentation("1em"),
-	fontScale(0.8)
-{}
+	fontScale(0.8) {}
 
 
 Page::Page():
 Page::Page():
 	useExternalLinks(true),
 	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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __SETTINGS_HH__
 #ifndef __SETTINGS_HH__
 #define __SETTINGS_HH__
 #define __SETTINGS_HH__
-#include <QString>
-#include <QNetworkProxy>
-#include <QPrinter>
 #include "loadsettings.hh"
 #include "loadsettings.hh"
 #include "websettings.hh"
 #include "websettings.hh"
+#include <QNetworkProxy>
+#include <QPrinter>
+#include <QString>
 
 
 namespace wkhtmltopdf {
 namespace wkhtmltopdf {
 namespace settings {
 namespace settings {
@@ -39,12 +43,12 @@ struct Margin {
 	//!Margin applied to the leftp of the page
 	//!Margin applied to the leftp of the page
 	UnitReal left;
 	UnitReal left;
 };
 };
-	
+
 /*! \brief Settings considering page size */
 /*! \brief Settings considering page size */
 struct Size {
 struct Size {
 	Size();
 	Size();
 	//! What size paper should we use
 	//! What size paper should we use
-	QPrinter::PageSize pageSize; 
+	QPrinter::PageSize pageSize;
 	//!Height of the page
 	//!Height of the page
 	UnitReal height;
 	UnitReal height;
 	//!Width of the page
 	//!Width of the page
@@ -71,7 +75,7 @@ struct TableOfContent {
 
 
 /*! \brief Class holding all user setting.
 /*! \brief Class holding all user setting.
     This class holds all the user settings, settings can be filled in by hand,
     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()
     \sa CommandLineParser::parse()
 */
 */
 struct Global {
 struct Global {
@@ -81,23 +85,23 @@ struct Global {
 	Size size;
 	Size size;
 
 
 	//! Be less verbose
 	//! Be less verbose
-	bool quiet; 
-	
+	bool quiet;
+
 	//! Should we use the graphics system
 	//! Should we use the graphics system
 	bool useGraphics;
 	bool useGraphics;
 
 
 	//! Should we orientate in landscape or portrate
 	//! Should we orientate in landscape or portrate
-	QPrinter::Orientation orientation; 
+	QPrinter::Orientation orientation;
 
 
 	//! Color or grayscale
 	//! Color or grayscale
-	QPrinter::ColorMode colorMode; 
+	QPrinter::ColorMode colorMode;
 
 
 	//! What overall resolution should we use
 	//! What overall resolution should we use
-	QPrinter::PrinterMode resolution; 
+	QPrinter::PrinterMode resolution;
 
 
 	//! What dpi should be used when printing
 	//! What dpi should be used when printing
 	int dpi;
 	int dpi;
-	
+
 	//! When pagenumbers are printed, apply this offset to them all
 	//! When pagenumbers are printed, apply this offset to them all
 	int pageOffset;
 	int pageOffset;
 
 
@@ -118,13 +122,13 @@ struct Global {
 
 
 	//! The file where in to store the output
 	//! The file where in to store the output
 	QString out;
 	QString out;
-	
+
 	QString documentTitle;
 	QString documentTitle;
 
 
 	bool useCompression;
 	bool useCompression;
 
 
 	//! Margin related settings
 	//! Margin related settings
-	Margin margin;	
+	Margin margin;
 
 
 	//! Specify the output format we should use
 	//! Specify the output format we should use
 	QString outputFormat;
 	QString outputFormat;
@@ -160,29 +164,29 @@ struct Page {
 	Page();
 	Page();
 	//! Settings regarding the TOC
 	//! Settings regarding the TOC
 	TableOfContent toc;
 	TableOfContent toc;
-	
+
 	QString page;
 	QString page;
-	
+
 	//! Header related settings
 	//! Header related settings
 	HeaderFooter header;
 	HeaderFooter header;
-	
+
 	//! Header related settings
 	//! Header related settings
 	HeaderFooter footer;
 	HeaderFooter footer;
-	
+
 	//! Should external links be links in the PDF
 	//! Should external links be links in the PDF
 	bool useExternalLinks;
 	bool useExternalLinks;
-	
+
 	//! Should internal links be links in the PDF
 	//! Should internal links be links in the PDF
 	bool useLocalLinks;
 	bool useLocalLinks;
-			
+
 	//! Replacements
 	//! Replacements
 	QList< QPair<QString, QString> > replacements;
 	QList< QPair<QString, QString> > replacements;
-	
+
 	//! Convert forms on the pages into PDF forms
 	//! Convert forms on the pages into PDF forms
 	bool produceForms;
 	bool produceForms;
-	
+
 	LoadPage load;
 	LoadPage load;
-	
+
 	Web web;
 	Web web;
 
 
 	bool includeInOutline;
 	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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#include "tocprinter.hh"
+
 #include "outline_p.hh"
 #include "outline_p.hh"
 #include "settings.hh"
 #include "settings.hh"
+#include "tocprinter.hh"
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 
 
 
 
 typedef QPair<int, OutlineItem *> line_t;
 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,
   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 {
 class TocPrinterPrivate {
 public:
 public:
@@ -37,7 +42,7 @@ public:
 	QVector<OutlineItem *> pageItems;
 	QVector<OutlineItem *> pageItems;
 
 
 	QList< QList< line_t > > pages;
 	QList< QList< line_t > > pages;
-	
+
 	TocPrinterPrivate(Outline * o, QPrinter * pr, QPainter & pa);
 	TocPrinterPrivate(Outline * o, QPrinter * pr, QPainter & pa);
 	void revLinkChildren(OutlineItem * i, QVector<QPair<QWebElement, QString> > & links, int level);
 	void revLinkChildren(OutlineItem * i, QVector<QPair<QWebElement, QString> > & links, int level);
 	void renderPage(OutlineItem * & cur, bool first, bool dry);
 	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();
 	QRect pr = printer->pageRect();
 	foreach (OutlineItem * i, item->children) {
 	foreach (OutlineItem * i, item->children) {
 		y += step[level];
 		y += step[level];
-		if(y > pr.height()) {
+		if (y > pr.height()) {
 			pages.push_back( QList< QPair<int, OutlineItem *> >() );
 			pages.push_back( QList< QPair<int, OutlineItem *> >() );
 			y = step[level];
 			y = step[level];
 		}
 		}
@@ -74,13 +79,13 @@ TocPrinterPrivate::TocPrinterPrivate(Outline * o, QPrinter * pr, QPainter & pa):
 	painter.save();
 	painter.save();
 	painter.resetTransform();
 	painter.resetTransform();
 	QRectF pageRect = printer->pageRect();
 	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]));
 		painter.setFont(QFont(s.fontName, s.fontSize[level]));
 		step[level] = painter.fontMetrics().height();
 		step[level] = painter.fontMetrics().height();
 		dw[level] = painter.boundingRect(pageRect, Qt::AlignRight | Qt::AlignTop, ".").width();
 		dw[level] = painter.boundingRect(pageRect, Qt::AlignRight | Qt::AlignTop, ".").width();
 	}
 	}
 	painter.setFont(QFont(s.fontName, s.captionFontSize));
 	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;
 	double y = painter.boundingRect(pageRect, Qt::AlignTop | Qt::AlignHCenter, s.captionText).height() * 3;
 	painter.restore();
 	painter.restore();
 	pages.push_back( QList< QPair<int, OutlineItem *> >() );
 	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) );
 	pages.back().push_back( qMakePair(0, toc) );
 
 
 	foreach (OutlineItem * i, o->d->documentOutlines)
 	foreach (OutlineItem * i, o->d->documentOutlines)
-		layoutChildren(i, y, 0); 	
+		layoutChildren(i, y, 0);
 
 
 	outline->d->pageCount += pages.size();
 	outline->d->pageCount += pages.size();
 
 
-	foreach (OutlineItem * i, outline->d->documentOutlines) 
+	foreach (OutlineItem * i, outline->d->documentOutlines)
 		incChildren(i);
 		incChildren(i);
 
 
 	outline->d->documentOutlines.push_front(root);
 	outline->d->documentOutlines.push_front(root);
@@ -156,11 +161,11 @@ void TocPrinter::spoolPage(int page) {
 	double y = 0;
 	double y = 0;
 	const Settings::TOCSettings & s = d->outline->d->settings.toc;
 	const Settings::TOCSettings & s = d->outline->d->settings.toc;
 	QRect pr = d->printer->pageRect();
 	QRect pr = d->printer->pageRect();
-	
-	if(page == 0) {
+
+	if (page == 0) {
 		double h = d->painter.boundingRect(pr,Qt::AlignTop | Qt::AlignHCenter, s.captionText).height();
 		double h = d->painter.boundingRect(pr,Qt::AlignTop | Qt::AlignHCenter, s.captionText).height();
 		QRect r((int)h,0,pr.width(),(int)h*3);
 		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.setFont(QFont(s.captionFontName.isEmpty()?s.fontName:s.captionFontName, s.captionFontSize));
 		d->painter.drawText(r, Qt::AlignVCenter | Qt::AlignHCenter, s.captionText);
 		d->painter.drawText(r, Qt::AlignVCenter | Qt::AlignHCenter, s.captionText);
 		d->painter.addAnchor(r, "_WK_TOC");
 		d->painter.addAnchor(r, "_WK_TOC");
@@ -175,9 +180,9 @@ void TocPrinter::spoolPage(int page) {
 		}
 		}
 
 
 		double startX = pr.width()*s.indentation[lvl]/1000.0;
 		double startX = pr.width()*s.indentation[lvl]/1000.0;
-		
+
 		QRectF lineRect(startX,y,pr.width()-startX, d->step[lvl]);
 		QRectF lineRect(startX,y,pr.width()-startX, d->step[lvl]);
-		
+
 		QRectF br;
 		QRectF br;
 		d->painter.drawText(lineRect,Qt::AlignBottom | Qt::AlignRight, QString(" ") + QString::number(line.second->page),&br);
 		d->painter.drawText(lineRect,Qt::AlignBottom | Qt::AlignRight, QString(" ") + QString::number(line.second->page),&br);
 		QString v = line.second->value;
 		QString v = line.second->value;
@@ -189,7 +194,7 @@ void TocPrinter::spoolPage(int page) {
 			for (int i=0; i < ndots; ++i) v.append(".");
 			for (int i=0; i < ndots; ++i) v.append(".");
 		}
 		}
 		d->painter.drawText(lineRect,Qt::AlignBottom | Qt::AlignLeft, v);
 		d->painter.drawText(lineRect,Qt::AlignBottom | Qt::AlignLeft, v);
-		
+
 		QRectF r(0,y, pr.width(), d->step[lvl]);
 		QRectF r(0,y, pr.width(), d->step[lvl]);
 		if (s.forwardLinks)
 		if (s.forwardLinks)
 			d->painter.addLink(r, line.second->anchor);
 			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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __TOCPRINTER_HH__
 #ifndef __TOCPRINTER_HH__
 #define __TOCPRINTER_HH__
 #define __TOCPRINTER_HH__
 #include <QWebFrame>
 #include <QWebFrame>
@@ -38,4 +43,4 @@ private:
 
 
 }
 }
 #endif //__EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outline_p.hh"
 #include "outline_p.hh"
 #include "settings.hh"
 #include "settings.hh"
 #include <QTextOStream>
 #include <QTextOStream>
@@ -67,7 +71,7 @@ void dumpDefaultTOCStyleSheet(QTextStream & stream, settings::TableOfContent & s
 	if (s.forwardLinks)
 	if (s.forwardLinks)
 		stream << "            <xsl:if test=\"@link\">" << endl
 		stream << "            <xsl:if test=\"@link\">" << endl
 			   << "              <xsl:attribute name=\"href\"><xsl:value-of select=\"@link\"/></xsl:attribute>" << 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
 	stream << "            <xsl:if test=\"@backLink\">" << endl
 		   << "              <xsl:attribute name=\"name\"><xsl:value-of select=\"@backLink\"/></xsl:attribute>" << endl
 		   << "              <xsl:attribute name=\"name\"><xsl:value-of select=\"@backLink\"/></xsl:attribute>" << endl
 		   << "            </xsl:if>" << 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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparser.hh"
 #include "commandlineparser.hh"
 #include "pdfconverter.hh"
 #include "pdfconverter.hh"
 #include "progressfeedback.hh"
 #include "progressfeedback.hh"
 #include "settings.hh"
 #include "settings.hh"
+#include "utilities.hh"
 #include <QCleanlooksStyle>
 #include <QCleanlooksStyle>
 #include <QCommonStyle>
 #include <QCommonStyle>
 #include <QPainter>
 #include <QPainter>
@@ -28,7 +34,6 @@
 #include <qapplication.h>
 #include <qapplication.h>
 #include <qglobal.h>
 #include <qglobal.h>
 #include <string.h>
 #include <string.h>
-#include "utilities.hh"
 
 
 using namespace wkhtmltopdf::settings;
 using namespace wkhtmltopdf::settings;
 using namespace wkhtmltopdf;
 using namespace wkhtmltopdf;
@@ -150,10 +155,10 @@ int main(int argc, char * argv[]) {
 			//parser.loadDefaults();
 			//parser.loadDefaults();
 			//Parse the arguments
 			//Parse the arguments
 			parser.parseArguments(nargc, (const char**)nargv, true);
 			parser.parseArguments(nargc, (const char**)nargv, true);
-			
+
 			PdfConverter converter(globalSettings);
 			PdfConverter converter(globalSettings);
 			ProgressFeedback feedback(globalSettings.quiet, converter);
 			ProgressFeedback feedback(globalSettings.quiet, converter);
-			foreach(const Page & page, pageSettings) 
+			foreach (const Page & page, pageSettings)
 				converter.addResource(page);
 				converter.addResource(page);
 
 
 			if (!converter.convert())
 			if (!converter.convert())
@@ -165,7 +170,7 @@ int main(int argc, char * argv[]) {
 	PdfConverter converter(globalSettings);
 	PdfConverter converter(globalSettings);
 	QObject::connect(&converter, SIGNAL(producingForms(bool)), style, SLOT(producingForms(bool)));
 	QObject::connect(&converter, SIGNAL(producingForms(bool)), style, SLOT(producingForms(bool)));
 	ProgressFeedback feedback(globalSettings.quiet, converter);
 	ProgressFeedback feedback(globalSettings.quiet, converter);
-	foreach(const Page & page, pageSettings) 
+	foreach (const Page & page, pageSettings)
 		converter.addResource(page);
 		converter.addResource(page);
 
 
 	bool success = converter.convert();
 	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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outputter.hh"
 #include "outputter.hh"
 
 
 /*!
 /*!
   \fn ArgHandler::getDesc() const
   \fn ArgHandler::getDesc() const
   Get the description of this switch
   Get the description of this switch
-*/  
+*/
 QString ArgHandler::getDesc() const {
 QString ArgHandler::getDesc() const {
 	return desc;
 	return desc;
 }
 }
@@ -27,5 +31,5 @@ QString ArgHandler::getDesc() const {
 /*!
 /*!
   \fn ArgHandlerBase::~ArgHandlerBase()
   \fn ArgHandlerBase::~ArgHandlerBase()
   Dummy virtual destructor
   Dummy virtual destructor
-*/  
+*/
 ArgHandler::~ArgHandler() {}
 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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef __ARGHANDLER_INL__
+#define __ARGHANDLER_INL__
+#include "commandlineparserbase.hh"
 #include "loadsettings.hh"
 #include "loadsettings.hh"
 
 
 template <typename T> class DstArgHandler: public ArgHandler {
 template <typename T> class DstArgHandler: public ArgHandler {
 public:
 public:
  	T & dst;
  	T & dst;
  	DstArgHandler(T & d): dst(d) {};
  	DstArgHandler(T & d): dst(d) {};
-	
+
  	T & realDst(const CommandLineParserBase & cp, char * page) {
  	T & realDst(const CommandLineParserBase & cp, char * page) {
 		return * reinterpret_cast<T*>(cp.mapAddress(reinterpret_cast<char *>(&dst), page));
 		return * reinterpret_cast<T*>(cp.mapAddress(reinterpret_cast<char *>(&dst), page));
  	}
  	}
@@ -37,7 +45,7 @@ public:
 		p_t::realDst(cp, ps)=src;
 		p_t::realDst(cp, ps)=src;
 		return true;
 		return true;
 	}
 	}
-	
+
 	virtual QString getDesc() const {
 	virtual QString getDesc() const {
 		if (src != p_t::dst) return p_t::desc;
 		if (src != p_t::dst) return p_t::desc;
 		return p_t::desc + " (default)";
 		return p_t::desc + " (default)";
@@ -51,7 +59,7 @@ struct StringPairCreator {
 	}
 	}
 };
 };
 
 
-template <bool file> 
+template <bool file>
 struct PostItemCreator {
 struct PostItemCreator {
 	typedef wkhtmltopdf::settings::PostItem T;
 	typedef wkhtmltopdf::settings::PostItem T;
 	inline T operator()(const QString & key, const QString & value) const {
 	inline T operator()(const QString & key, const QString & value) const {
@@ -93,7 +101,7 @@ struct StringListSetter: public DstArgHandler<QList<QString> > {
 /*!
 /*!
   SomeSetter template method base
   SomeSetter template method base
 */
 */
-template <typename TT> 
+template <typename TT>
 struct SomeSetterTM {
 struct SomeSetterTM {
 	typedef TT T;
 	typedef TT T;
 	//T strToT(const char * val, bool & ok);
 	//T strToT(const char * val, bool & ok);
@@ -200,3 +208,4 @@ template <typename T> struct Caller: public ArgHandler {
 		return T()(vals, s, page);
 		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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#include <qwebframe.h>
+
 #include "commandlineparserbase.hh"
 #include "commandlineparserbase.hh"
 #include "outputter.hh"
 #include "outputter.hh"
+#include <qwebframe.h>
 
 
 bool ahsort(const ArgHandler * a, const ArgHandler * b) {
 bool ahsort(const ArgHandler * a, const ArgHandler * b) {
 	QRegExp e("^(no|enable|disable)-");
 	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
   \param doc Indicate to the outputter that it is writing documentation
 */
 */
 void CommandLineParserBase::outputSwitches(Outputter * o, bool extended, bool doc) const {
 void CommandLineParserBase::outputSwitches(Outputter * o, bool extended, bool doc) const {
-	foreach(const QString & section, sections) {
+	foreach (const QString & section, sections) {
 		QList<const ArgHandler *> display;
 		QList<const ArgHandler *> display;
-		foreach(const ArgHandler * handler, sectionArgumentHandles[section]) {
+		foreach (const ArgHandler * handler, sectionArgumentHandles[section]) {
 #ifndef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #ifndef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
-			if(!doc && handler->qthack) continue;
-#else 
+			if (!doc && handler->qthack) continue;
+#else
 			Q_UNUSED(doc);
 			Q_UNUSED(doc);
 #endif
 #endif
-			if(!extended && handler->extended) continue;
+			if (!extended && handler->extended) continue;
 			display.push_back(handler);
 			display.push_back(handler);
 		}
 		}
 		qSort(display.begin(), display.end(), ahsort);
 		qSort(display.begin(), display.end(), ahsort);
-		if(display.size() == 0) continue;
+		if (display.size() == 0) continue;
 		o->beginSection(section);
 		o->beginSection(section);
-		if(!sectionDesc[section].isEmpty()) {
+		if (!sectionDesc[section].isEmpty()) {
 			o->beginParagraph();
 			o->beginParagraph();
 			o->text(sectionDesc[section]);
 			o->text(sectionDesc[section]);
 			o->endParagraph();
 			o->endParagraph();
 		}
 		}
 		o->beginSwitch();
 		o->beginSwitch();
-		foreach(const ArgHandler * handler, display)
+		foreach (const ArgHandler * handler, display)
 			o->cswitch(handler);
 			o->cswitch(handler);
 		o->endSwitch();
 		o->endSwitch();
 		o->endSection();
 		o->endSection();
@@ -125,7 +130,7 @@ void CommandLineParserBase::parseArg(int sections, const int argc, const char **
 				usage(stderr, false);
 				usage(stderr, false);
 				exit(1);
 				exit(1);
 			}
 			}
-		
+
 			if (!(k.value()->section & sections)) {
 			if (!(k.value()->section & sections)) {
 				fprintf(stderr, "-%c specified in incorrect location\n\n", argv[c][j]);
 				fprintf(stderr, "-%c specified in incorrect location\n\n", argv[c][j]);
 				usage(stderr, false);
 				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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // 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 "loadsettings.hh"
 #include "websettings.hh"
 #include "websettings.hh"
 class Outputter;
 class Outputter;
@@ -41,32 +46,32 @@ public:
 	QString currentSection;
 	QString currentSection;
 	bool currentExtended;
 	bool currentExtended;
 	bool currentHack;
 	bool currentHack;
-	
+
 	QList<QString> sections;
 	QList<QString> sections;
 	QHash<QString, ArgHandler *> longToHandler;
 	QHash<QString, ArgHandler *> longToHandler;
 	QHash<char, ArgHandler *> shortToHandler;
 	QHash<char, ArgHandler *> shortToHandler;
 	QHash<QString, QList<ArgHandler *> > sectionArgumentHandles;
 	QHash<QString, QList<ArgHandler *> > sectionArgumentHandles;
 	QHash<QString, QString> sectionDesc;
 	QHash<QString, QString> sectionDesc;
-	
+
 	//basearguments.cc
 	//basearguments.cc
 	void section(QString s, QString desc="");
 	void section(QString s, QString desc="");
 	void mode(int m);
 	void mode(int m);
 	void qthack(bool);
 	void qthack(bool);
 	void extended(bool);
 	void extended(bool);
-	
+
 	void addarg(QString, char, QString, ArgHandler * h, bool display=true);
 	void addarg(QString, char, QString, ArgHandler * h, bool display=true);
 	void addDocArgs();
 	void addDocArgs();
 	void addWebArgs(wkhtmltopdf::settings::Web & s);
 	void addWebArgs(wkhtmltopdf::settings::Web & s);
 	void addGlobalLoadArgs(wkhtmltopdf::settings::LoadGlobal & s);
 	void addGlobalLoadArgs(wkhtmltopdf::settings::LoadGlobal & s);
 	void addPageLoadArgs(wkhtmltopdf::settings::LoadPage & s);
 	void addPageLoadArgs(wkhtmltopdf::settings::LoadPage & s);
-	
+
 	//commondocparts.cc
 	//commondocparts.cc
 	void outputName(Outputter * o) const;
 	void outputName(Outputter * o) const;
 	void outputLicense(Outputter * o) const;
 	void outputLicense(Outputter * o) const;
 	void outputAuthors(Outputter * o) const;
 	void outputAuthors(Outputter * o) const;
 	void outputStaticProblems(Outputter * o) const;
 	void outputStaticProblems(Outputter * o) const;
 	void outputProxyDoc(Outputter * o) const;
 	void outputProxyDoc(Outputter * o) const;
-	
+
 	//commandlineparserbase.cc
 	//commandlineparserbase.cc
 	void outputSwitches(Outputter * o, bool extended, bool doc) const;
 	void outputSwitches(Outputter * o, bool extended, bool doc) const;
 	virtual char * mapAddress(char * d, char *) const {return d;}
 	virtual char * mapAddress(char * d, char *) const {return d;}
@@ -78,4 +83,4 @@ public:
 	virtual void manpage(FILE * fd) const = 0;
 	virtual void manpage(FILE * fd) const = 0;
 	virtual void readme(FILE * fd, bool html) 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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
-#include "commandlineparserbase.hh"
+
 #include "arghandler.inl"
 #include "arghandler.inl"
+#include "commandlineparserbase.hh"
 #include "loadsettings.hh"
 #include "loadsettings.hh"
 using namespace wkhtmltopdf::settings;
 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;
 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
   be shown in a simple --help
   \param e Are the arguments extended
   \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->section = currentMode;
 	h->extended = currentExtended;
 	h->extended = currentExtended;
 	longToHandler[l] = h;
 	longToHandler[l] = h;
-	if(s) shortToHandler[s] = h;
+	if (s) shortToHandler[s] = h;
 	sectionArgumentHandles[currentSection].push_back(h);
 	sectionArgumentHandles[currentSection].push_back(h);
 }
 }
 
 
@@ -156,19 +161,19 @@ void CommandLineParserBase::addDocArgs() {
 void CommandLineParserBase::addGlobalLoadArgs(LoadGlobal & s) {
 void CommandLineParserBase::addGlobalLoadArgs(LoadGlobal & s) {
 	extended(true);
 	extended(true);
 	qthack(false);
 	qthack(false);
-	
+
     addarg("cookie-jar", 0, "Read and write cookies from and to the supplied cookie jar file", new QStrSetter(s.cookieJar, "path") );
     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) {
 void CommandLineParserBase::addWebArgs(Web & s) {
 	extended(true);
 	extended(true);
  	qthack(false);
  	qthack(false);
-	
+
 	addarg("enable-plugins",0,"Enable installed plugins (plugins will likely not work)", new ConstSetter<bool>(s.enablePlugins,true));
 	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("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"));
 	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
 #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"));
  	addarg("user-style-sheet",0,"Specify a user style sheet, to load with every page", new QStrSetter(s.userStyleSheet,"url"));
 #endif
 #endif
@@ -176,11 +181,11 @@ void CommandLineParserBase::addWebArgs(Web & s) {
 #if QT_VERSION >= 0x040600
 #if QT_VERSION >= 0x040600
 	addarg("no-images",0,"Do not load or print images", new ConstSetter<bool>(s.loadImages, false));
 	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));
 	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("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));
 	addarg("enable-javascript",'n',"Do allow web pages to run javascript", new ConstSetter<bool>(s.enableJavascript,true));
-	
+
 	extended(true);
 	extended(true);
  	qthack(true);
  	qthack(true);
 #if QT_VERSION >= 0x040600
 #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",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("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("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("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("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("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", 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("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("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("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("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("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));
 	addarg("no-debug-javascript", 0,"Do not show javascript debugging output", new ConstSetter<bool>(s.debugJavascript, false));
 #if QT_VERSION >= 0x040600
 #if QT_VERSION >= 0x040600
 	addarg("stop-slow-scripts", 0, "Stop slow running javascripts", new ConstSetter<bool>(s.stopSlowScripts, true));
 	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));
 	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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "commandlineparserbase.hh"
 #include "commandlineparserbase.hh"
 #include "outputter.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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "converter_p.hh"
 #include "converter_p.hh"
-#include <QWebFrame>
 #include "multipageloader.hh"
 #include "multipageloader.hh"
+#include <QWebFrame>
 #include <qapplication.h>
 #include <qapplication.h>
 namespace wkhtmltopdf {
 namespace wkhtmltopdf {
 
 
@@ -78,7 +82,7 @@ void ConverterPrivate::cancel() {
 bool ConverterPrivate::convert() {
 bool ConverterPrivate::convert() {
 	convertionDone=false;
 	convertionDone=false;
 	beginConvert();
 	beginConvert();
-	while(!convertionDone) {
+	while (!convertionDone) {
 		qApp->exec();
 		qApp->exec();
 		//qApp->processEvents(QEventLoop::WaitForMoreEvents | QEventLoop::AllEvents);
 		//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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __CONVERTER_HH__
 #ifndef __CONVERTER_HH__
 #define __CONVERTER_HH__
 #define __CONVERTER_HH__
 #include <QObject>
 #include <QObject>
@@ -23,7 +27,7 @@ namespace wkhtmltopdf {
 class ConverterPrivate;
 class ConverterPrivate;
 
 
 class Converter: public QObject {
 class Converter: public QObject {
-    Q_OBJECT 
+    Q_OBJECT
 public:
 public:
 	virtual ~Converter() {};
 	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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __CONVERTER_P_HH__
 #ifndef __CONVERTER_P_HH__
 #define __CONVERTER_P_HH__
 #define __CONVERTER_P_HH__
-#include <QFile>
 #include "converter.hh"
 #include "converter.hh"
 #include "websettings.hh"
 #include "websettings.hh"
+#include <QFile>
 #include <QWebSettings>
 #include <QWebSettings>
 
 
 namespace wkhtmltopdf {
 namespace wkhtmltopdf {
@@ -27,24 +31,24 @@ class ConverterPrivate: public QObject {
 	Q_OBJECT
 	Q_OBJECT
 public:
 public:
 	void copyFile(QFile & src, QFile & dst);
 	void copyFile(QFile & src, QFile & dst);
-	
+
 	QList<QString> phaseDescriptions;
 	QList<QString> phaseDescriptions;
 	int currentPhase;
 	int currentPhase;
-	
+
 	QString progressString;
 	QString progressString;
 protected:
 protected:
 	bool error;
 	bool error;
 	virtual void clearResources() = 0;
 	virtual void clearResources() = 0;
 	virtual Converter & outer() = 0;
 	virtual Converter & outer() = 0;
 	int errorCode;
 	int errorCode;
-	
+
 	bool convertionDone;
 	bool convertionDone;
-	
+
 	void updateWebSettings(QWebSettings * ws, const settings::Web & s) const;
 	void updateWebSettings(QWebSettings * ws, const settings::Web & s) const;
 public slots:
 public slots:
 	void fail();
 	void fail();
 	void loadProgress(int progress);
 	void loadProgress(int progress);
-	
+
 	virtual void beginConvert() = 0;
 	virtual void beginConvert() = 0;
 	void cancel();
 	void cancel();
 	bool convert();
 	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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outputter.hh"
 #include "outputter.hh"
 #include <QTextDocument>
 #include <QTextDocument>
 
 
@@ -63,15 +67,15 @@ public:
 	void text(const QString & t) {
 	void text(const QString & t) {
 		fprintf(fd, "%s", S(t));
 		fprintf(fd, "%s", S(t));
 	}
 	}
-	
+
 	void sectionLink(const QString & s) {
 	void sectionLink(const QString & s) {
 		fprintf(fd, "<a href=\"#%s\">%s</a>", S(s), S(s));
 		fprintf(fd, "<a href=\"#%s\">%s</a>", S(s), S(s));
 	}
 	}
-	
+
 	void bold(const QString & t) {
 	void bold(const QString & t) {
 		fprintf(fd, "<b>%s</b>", S(t));
 		fprintf(fd, "<b>%s</b>", S(t));
 	}
 	}
-	
+
 	void italic(const QString & t) {
 	void italic(const QString & t) {
 		fprintf(fd, "<i>%s</i>", S(t));
 		fprintf(fd, "<i>%s</i>", S(t));
 	}
 	}
@@ -79,7 +83,7 @@ public:
 	void link(const QString & t) {
 	void link(const QString & t) {
 		fprintf(fd, "<a href=\"%s\">%s</a>", S(t),S(t));
 		fprintf(fd, "<a href=\"%s\">%s</a>", S(t),S(t));
 	}
 	}
-	
+
 	void verbatim(const QString & t) {
 	void verbatim(const QString & t) {
 		fprintf(fd, "<pre>%s</pre>", S(t));
 		fprintf(fd, "<pre>%s</pre>", S(t));
 	}
 	}
@@ -88,26 +92,26 @@ public:
 		ordered = o;
 		ordered = o;
 		fprintf(fd, ordered?"<ol>":"<ul>");
 		fprintf(fd, ordered?"<ol>":"<ul>");
 	}
 	}
-	
+
 	void endList() {
 	void endList() {
 		fprintf(fd, ordered?"</ol>":"</ul>");
 		fprintf(fd, ordered?"</ol>":"</ul>");
 	}
 	}
-	
+
 	void listItem(const QString & s) {
 	void listItem(const QString & s) {
 		fprintf(fd, "<li>%s</li>\n", S(s));
 		fprintf(fd, "<li>%s</li>\n", S(s));
 	}
 	}
-	
+
 	void beginSwitch() {
 	void beginSwitch() {
 		fprintf(fd, "<table>\n");
 		fprintf(fd, "<table>\n");
 	}
 	}
 
 
 	void cswitch(const ArgHandler * h) {
 	void cswitch(const ArgHandler * h) {
 		fprintf(fd, "<tr><td class=\"short\">");
 		fprintf(fd, "<tr><td class=\"short\">");
-		if(h->shortSwitch)
+		if (h->shortSwitch)
 			fprintf(fd, "-%c,",h->shortSwitch);
 			fprintf(fd, "-%c,",h->shortSwitch);
 		fprintf(fd, "</td><td class=\"long\">--%s%s</td><td class=\"arg\">",S(h->longName),
 		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>":""));
 				(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, "&lt;%s&gt; ",S(arg));
 		fprintf(fd, "</td><td class=\"desc\">%s</td></tr>\n",S(h->getDesc()));
 		fprintf(fd, "</td><td class=\"desc\">%s</td></tr>\n",S(h->getDesc()));
 	}
 	}
@@ -116,7 +120,7 @@ public:
 		fprintf(fd, "</table>\n");
 		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>");
 		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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "loadsettings.hh"
 #include "loadsettings.hh"
 #include <QMap>
 #include <QMap>
 #include <stdexcept>
 #include <stdexcept>
@@ -30,7 +34,7 @@ LoadPage::LoadErrorHandling strToLoadErrorHandling(const char * s, bool * ok) {
 }
 }
 
 
 QString loadErrorHandlingToStr(LoadPage::LoadErrorHandling leh) {
 QString loadErrorHandlingToStr(LoadPage::LoadErrorHandling leh) {
-	switch(leh) {
+	switch (leh) {
 	case LoadPage::abort: return "abort";
 	case LoadPage::abort: return "abort";
 	case LoadPage::skip: return "skip";
 	case LoadPage::skip: return "skip";
 	case LoadPage::ignore: return "ignore";
 	case LoadPage::ignore: return "ignore";
@@ -45,13 +49,13 @@ QString loadErrorHandlingToStr(LoadPage::LoadErrorHandling leh) {
 */
 */
 Proxy strToProxy(const char * proxy, bool * ok) {
 Proxy strToProxy(const char * proxy, bool * ok) {
 	Proxy p;
 	Proxy p;
-	if(ok) *ok=true;
+	if (ok) *ok=true;
 	//Allow users to use no proxy, even if one is specified in the env
 	//Allow users to use no proxy, even if one is specified in the env
 	if (!strcmp(proxy,"none")) {
 	if (!strcmp(proxy,"none")) {
 		p.host = "";
 		p.host = "";
 		return p;
 		return p;
 	}
 	}
-	
+
 	p.type = QNetworkProxy::HttpProxy;
 	p.type = QNetworkProxy::HttpProxy;
 	//Read proxy type bit "http://" or "socks5://"
 	//Read proxy type bit "http://" or "socks5://"
 	if (!strncmp(proxy,"http://",7)) {
 	if (!strncmp(proxy,"http://",7)) {
@@ -67,9 +71,9 @@ Proxy strToProxy(const char * proxy, bool * ok) {
 	if (val != NULL) {
 	if (val != NULL) {
 		p.user = QString(proxy).left(val-proxy);
 		p.user = QString(proxy).left(val-proxy);
 		proxy = val+1;
 		proxy = val+1;
-		
+
 		int idx = p.user.indexOf(':');
 		int idx = p.user.indexOf(':');
-		if(idx != -1) {
+		if (idx != -1) {
 			p.password = p.user.mid(idx+1);
 			p.password = p.user.mid(idx+1);
 			p.user = p.user.left(idx);
 			p.user = p.user.left(idx);
 		}
 		}
@@ -81,13 +85,13 @@ Proxy strToProxy(const char * proxy, bool * ok) {
  	if (val == NULL) p.host = proxy;
  	if (val == NULL) p.host = proxy;
  	else {
  	else {
 		p.port = QString(val+1).toInt(ok);
 		p.port = QString(val+1).toInt(ok);
-		if(p.port < 0 || p.port > 65535) {
+		if (p.port < 0 || p.port > 65535) {
 			p.port = 1080;
 			p.port = 1080;
 			*ok = false;
 			*ok = false;
 		}
 		}
 		p.host = QString(proxy).left(val-proxy);
 		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;
 	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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __LOADSETTINGS_HH__
 #ifndef __LOADSETTINGS_HH__
 #define __LOADSETTINGS_HH__
 #define __LOADSETTINGS_HH__
-#include <QString>
 #include <QNetworkProxy>
 #include <QNetworkProxy>
+#include <QString>
 namespace wkhtmltopdf {
 namespace wkhtmltopdf {
 namespace settings {
 namespace settings {
 
 
@@ -25,15 +29,15 @@ namespace settings {
 struct Proxy {
 struct Proxy {
 	Proxy();
 	Proxy();
 	//! Type of proxy to use
 	//! Type of proxy to use
-	QNetworkProxy::ProxyType type; 
+	QNetworkProxy::ProxyType type;
 	//! The port of the proxy to use
 	//! The port of the proxy to use
-	int port; 
+	int port;
 	//! The host name of the proxy to use or NULL
 	//! The host name of the proxy to use or NULL
-	QString host; 
+	QString host;
 	//! Username for the said proxy or NULL
 	//! Username for the said proxy or NULL
-	QString user; 
+	QString user;
 	//! Password for the said proxy or NULL
 	//! Password for the said proxy or NULL
-	QString password; 
+	QString password;
 };
 };
 
 
 struct PostItem {
 struct PostItem {
@@ -59,20 +63,20 @@ struct LoadPage {
 
 
 	//! Username used for http auth login
 	//! Username used for http auth login
 	QString username;
 	QString username;
-	
+
 	//! Password used for http auth login
 	//! Password used for http auth login
 	QString password;
 	QString password;
-	
+
 	//! How many milliseconds should we wait for a Javascript redirect
 	//! How many milliseconds should we wait for a Javascript redirect
 	int jsdelay;
 	int jsdelay;
-	
+
 	//! What zoom factor should we apply when printing
 	//! What zoom factor should we apply when printing
 	// TODO MOVE
 	// TODO MOVE
 	float zoomFactor;
 	float zoomFactor;
 
 
 	//! Map of custum header variables
 	//! Map of custum header variables
 	QList< QPair<QString, QString> > customHeaders;
 	QList< QPair<QString, QString> > customHeaders;
-	
+
 	//! Set if the custom header should be repeated for each resource request
 	//! Set if the custom header should be repeated for each resource request
 	bool repeatCustomHeaders;
 	bool repeatCustomHeaders;
 
 
@@ -80,16 +84,16 @@ struct LoadPage {
 	QList< QPair<QString, QString> > cookies;
 	QList< QPair<QString, QString> > cookies;
 
 
 	QList< PostItem > post;
 	QList< PostItem > post;
-	
+
 	//! Block access to local files for the given page
 	//! Block access to local files for the given page
 	bool blockLocalFileAccess;
 	bool blockLocalFileAccess;
-	
+
 	//! If access to local files is not allowed in general, allow it for these files
 	//! If access to local files is not allowed in general, allow it for these files
 	QList< QString > allowed;
 	QList< QString > allowed;
-	
+
 	//! Stop Javascript from running too long
 	//! Stop Javascript from running too long
-	bool stopSlowScripts;		
-	
+	bool stopSlowScripts;
+
 	//! Output Javascript debug messages
 	//! Output Javascript debug messages
 	bool debugJavascript;
 	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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outputter.hh"
 #include "outputter.hh"
 #include <QStringList>
 #include <QStringList>
 #define S(x) ((x).toUtf8().constData())
 #define S(x) ((x).toUtf8().constData())
@@ -41,7 +45,7 @@ public:
 	void endParagraph() {
 	void endParagraph() {
 		fprintf(fd, "\n\n");
 		fprintf(fd, "\n\n");
 	}
 	}
-	
+
 	void text(const QString & t) {
 	void text(const QString & t) {
 		QString str = QString(t).replace("-", "\\-");
 		QString str = QString(t).replace("-", "\\-");
 		fprintf(fd, "%s", S(str));
 		fprintf(fd, "%s", S(str));
@@ -50,11 +54,11 @@ public:
 	void sectionLink(const QString & t) {
 	void sectionLink(const QString & t) {
 		text(t);
 		text(t);
 	}
 	}
-	
+
 	void bold(const QString & t) {
 	void bold(const QString & t) {
 		fprintf(fd, "\\fB%s\\fP", S(t));
 		fprintf(fd, "\\fB%s\\fP", S(t));
 	}
 	}
-	
+
 	void italic(const QString & t) {
 	void italic(const QString & t) {
 		fprintf(fd, "\\fB%s\\fP", S(t));
 		fprintf(fd, "\\fB%s\\fP", S(t));
 	}
 	}
@@ -67,11 +71,11 @@ public:
 		QString str = QString(t).replace("-", "\\-");
 		QString str = QString(t).replace("-", "\\-");
 		QStringList l = str.split('\n');
 		QStringList l = str.split('\n');
 		while ( l.back() == "") l.pop_back();
 		while ( l.back() == "") l.pop_back();
-		foreach(const QString & line, l)
+		foreach (const QString & line, l)
 			fprintf(fd, "  %s\n", S(line));
 			fprintf(fd, "  %s\n", S(line));
 		fprintf(fd, "\n");
 		fprintf(fd, "\n");
 	}
 	}
-	
+
 	void beginSwitch() {
 	void beginSwitch() {
 		fprintf(fd, ".PD 0\n");
 		fprintf(fd, ".PD 0\n");
 	}
 	}
@@ -83,28 +87,28 @@ public:
 	void endList() {
 	void endList() {
 		fprintf(fd, "\n");
 		fprintf(fd, "\n");
 	}
 	}
-	
+
 	void listItem(const QString & s) {
 	void listItem(const QString & s) {
 		if (order < 0) fprintf(fd, " * ");
 		if (order < 0) fprintf(fd, " * ");
 		else fprintf(fd, "%3d ", order++);
 		else fprintf(fd, "%3d ", order++);
 		fprintf(fd,"%s\n",S(s));
 		fprintf(fd,"%s\n",S(s));
 	}
 	}
-	
+
 	void cswitch(const ArgHandler * h) {
 	void cswitch(const ArgHandler * h) {
 		fprintf(fd, ".TP\n");
 		fprintf(fd, ".TP\n");
 		fprintf(fd, "\\fB");
 		fprintf(fd, "\\fB");
-		if(h->shortSwitch != 0)
+		if (h->shortSwitch != 0)
 			fprintf(fd, "\\-%c, ", h->shortSwitch);
 			fprintf(fd, "\\-%c, ", h->shortSwitch);
 		else
 		else
 			fprintf(fd, "    ");
 			fprintf(fd, "    ");
 		fprintf(fd,"\\-\\-%s\\fR", S(h->longName));
 		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," \\fI<%s>\\fR", S(*i));
-		
+
 		fprintf(fd, "\n%s\n", S(QString(h->desc).replace("-", "\\-")));
 		fprintf(fd, "\n%s\n", S(QString(h->desc).replace("-", "\\-")));
 	}
 	}
-	
+
 	void endSwitch() {
 	void endSwitch() {
 		fprintf(fd, ".PD\n");
 		fprintf(fd, ".PD\n");
 		fprintf(fd, "\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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "multipageloader_p.hh"
 #include "multipageloader_p.hh"
 #include <QFile>
 #include <QFile>
 #include <QFileInfo>
 #include <QFileInfo>
-#include <QTimer>
 #include <QNetworkCookie>
 #include <QNetworkCookie>
+#include <QTimer>
 #include <QUuid>
 #include <QUuid>
 
 
 namespace wkhtmltopdf {
 namespace wkhtmltopdf {
@@ -44,11 +48,11 @@ void MyNetworkAccessManager::allow(QString path) {
 }
 }
 
 
 QNetworkReply * MyNetworkAccessManager::createRequest(Operation op, const QNetworkRequest & req, QIODevice * outgoingData) {
 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;
 		bool ok=false;
 		QString path = QFileInfo(req.url().toLocalFile()).canonicalFilePath();
 		QString path = QFileInfo(req.url().toLocalFile()).canonicalFilePath();
 		QString old = "";
 		QString old = "";
-		while(path != old) {
+		while (path != old) {
 			if (allowed.contains(path)) {
 			if (allowed.contains(path)) {
 				ok=true;
 				ok=true;
 				break;
 				break;
@@ -69,7 +73,7 @@ QNetworkReply * MyNetworkAccessManager::createRequest(Operation op, const QNetwo
 		foreach (const HT & j, settings.customHeaders)
 		foreach (const HT & j, settings.customHeaders)
 			r3.setRawHeader(j.first.toAscii(), j.second.toAscii());
 			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;
 	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),
 	networkAccessManager(s),
 	url(u),
 	url(u),
-	loginTry(0), 
-	progress(0), 
+	loginTry(0),
+	progress(0),
 	finished(false),
 	finished(false),
 	signalPrint(false),
 	signalPrint(false),
-	multiPageLoader(mpl), 
+	multiPageLoader(mpl),
 	webPage(*this),
 	webPage(*this),
 	lo(webPage),
 	lo(webPage),
 	httpErrorCode(0),
 	httpErrorCode(0),
 	settings(s) {
 	settings(s) {
-	
+
 	connect(&networkAccessManager, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator *)),this,
 	connect(&networkAccessManager, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator *)),this,
 	        SLOT(handleAuthenticationRequired(QNetworkReply *, QAuthenticator *)));
 	        SLOT(handleAuthenticationRequired(QNetworkReply *, QAuthenticator *)));
-	foreach(const QString & path, s.allowed)
+	foreach (const QString & path, s.allowed)
 		networkAccessManager.allow(path);
 		networkAccessManager.allow(path);
 	if (url.scheme() == "file")
 	if (url.scheme() == "file")
 		networkAccessManager.allow(url.toLocalFile());
 		networkAccessManager.allow(url.toLocalFile());
@@ -135,7 +139,7 @@ ResourceObject::ResourceObject(MultiPageLoaderPrivate & mpl, const QUrl & u, con
 	connect(&networkAccessManager, SIGNAL(finished (QNetworkReply *)),
 	connect(&networkAccessManager, SIGNAL(finished (QNetworkReply *)),
 			this, SLOT(amfinished (QNetworkReply *) ) );
 			this, SLOT(amfinished (QNetworkReply *) ) );
 
 
-	connect(&networkAccessManager, SIGNAL(warning(const QString &)), 
+	connect(&networkAccessManager, SIGNAL(warning(const QString &)),
 			this, SLOT(warning(const QString &)));
 			this, SLOT(warning(const QString &)));
 
 
 	networkAccessManager.setCookieJar(multiPageLoader.cookieJar);
 	networkAccessManager.setCookieJar(multiPageLoader.cookieJar);
@@ -214,7 +218,7 @@ void ResourceObject::loadDone() {
 	if (finished) return;
 	if (finished) return;
 	finished=true;
 	finished=true;
 	--multiPageLoader.loading;
 	--multiPageLoader.loading;
-	if (multiPageLoader.loading == 0) 
+	if (multiPageLoader.loading == 0)
 		multiPageLoader.loadDone();
 		multiPageLoader.loadDone();
 }
 }
 
 
@@ -350,7 +354,7 @@ void MyCookieJar::saveToFile(const QString & path) {
 void MultiPageLoaderPrivate::loadDone() {
 void MultiPageLoaderPrivate::loadDone() {
 	 if (!settings.cookieJar.isEmpty())
 	 if (!settings.cookieJar.isEmpty())
 	 	cookieJar->saveToFile(settings.cookieJar);
 	 	cookieJar->saveToFile(settings.cookieJar);
-	
+
 	if (!finishedEmitted) {
 	if (!finishedEmitted) {
 		finishedEmitted = true;
 		finishedEmitted = true;
 		emit outer.loadFinished(!hasError);
 		emit outer.loadFinished(!hasError);
@@ -381,12 +385,12 @@ bool MultiPageLoader::copyFile(QFile & src, QFile & dst) {
 	return true;
 	return true;
 }
 }
 
 
-MultiPageLoaderPrivate::MultiPageLoaderPrivate(const settings::LoadGlobal & s, MultiPageLoader & o): 
+MultiPageLoaderPrivate::MultiPageLoaderPrivate(const settings::LoadGlobal & s, MultiPageLoader & o):
 	outer(o), settings(s) {
 	outer(o), settings(s) {
 
 
 	cookieJar = new MyCookieJar();
 	cookieJar = new MyCookieJar();
 
 
-	if (!settings.cookieJar.isEmpty()) 
+	if (!settings.cookieJar.isEmpty())
 		cookieJar->loadFromFile(settings.cookieJar);
 		cookieJar->loadFromFile(settings.cookieJar);
 }
 }
 
 
@@ -399,7 +403,7 @@ LoaderObject * MultiPageLoaderPrivate::addResource(const QUrl & url, const setti
 	resources.push_back(ro);
 	resources.push_back(ro);
 	return &ro->lo;
 	return &ro->lo;
 }
 }
-	
+
 void MultiPageLoaderPrivate::load() {
 void MultiPageLoaderPrivate::load() {
 	progressSum=0;
 	progressSum=0;
 	loadStartedEmitted=false;
 	loadStartedEmitted=false;
@@ -407,21 +411,21 @@ void MultiPageLoaderPrivate::load() {
 	hasError=false;
 	hasError=false;
 	loading=0;
 	loading=0;
 
 
-	for(int i=0; i < resources.size(); ++i)
+	for (int i=0; i < resources.size(); ++i)
 		resources[i]->load();
 		resources[i]->load();
 
 
 	if (resources.size() == 0) loadDone();
 	if (resources.size() == 0) loadDone();
 }
 }
 
 
 void MultiPageLoaderPrivate::clearResources() {
 void MultiPageLoaderPrivate::clearResources() {
-	for(int i=0; i < resources.size(); ++i)
+	for (int i=0; i < resources.size(); ++i)
 		delete resources[i];
 		delete resources[i];
 	resources.clear();
 	resources.clear();
 	tempIn.remove();
 	tempIn.remove();
 }
 }
 
 
 void MultiPageLoaderPrivate::cancel() {
 void MultiPageLoaderPrivate::cancel() {
-	//foreach (QWebPage * page, pages) 
+	//foreach (QWebPage * page, pages)
 	//	page->triggerAction(QWebPage::Stop);
 	//	page->triggerAction(QWebPage::Stop);
 }
 }
 
 
@@ -454,7 +458,7 @@ LoaderObject * MultiPageLoader::addResource(const QString & string, const settin
 		in.open(stdin,QIODevice::ReadOnly);
 		in.open(stdin,QIODevice::ReadOnly);
 		url = d->tempIn.create(".html");
 		url = d->tempIn.create(".html");
 		QFile tmp(url);
 		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");
 			emit error("Unable to create temporery file");
 			return NULL;
 			return NULL;
 		}
 		}
@@ -472,7 +476,7 @@ LoaderObject * MultiPageLoader::addResource(const QUrl & url, const settings::Lo
 
 
 /*!
 /*!
   \brief Guess a url, by looking at a string
   \brief Guess a url, by looking at a string
-  
+
   (shamelessly copied from Arora Project)
   (shamelessly copied from Arora Project)
   \param string The string the is suppose to be some kind of url
   \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 MultiPageLoader::httpErrorCode() {
 	int res=0;
 	int res=0;
-	foreach (const ResourceObject * ro, d->resources) 
+	foreach (const ResourceObject * ro, d->resources)
 		if (ro->httpErrorCode > res) res = ro->httpErrorCode;
 		if (ro->httpErrorCode > res) res = ro->httpErrorCode;
 	return res;
 	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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __MULTIPAGELOADER_HH__
 #ifndef __MULTIPAGELOADER_HH__
 #define __MULTIPAGELOADER_HH__
 #define __MULTIPAGELOADER_HH__
 #include "loadsettings.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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef __MULTIPAGELOADER_P_HH__
+#define __MULTIPAGELOADER_P_HH__
 #include "multipageloader.hh"
 #include "multipageloader.hh"
 #include "tempfile.hh"
 #include "tempfile.hh"
 #include <QAtomicInt>
 #include <QAtomicInt>
 #include <QAuthenticator>
 #include <QAuthenticator>
 #include <QFile>
 #include <QFile>
+#include <QFileInfo>
 #include <QNetworkAccessManager>
 #include <QNetworkAccessManager>
+#include <QNetworkCookieJar>
 #include <QNetworkReply>
 #include <QNetworkReply>
 #include <QWebFrame>
 #include <QWebFrame>
-#include <QNetworkCookieJar>
-#include <QFileInfo>
 namespace wkhtmltopdf {
 namespace wkhtmltopdf {
 
 
 class MyNetworkAccessManager: public QNetworkAccessManager {
 class MyNetworkAccessManager: public QNetworkAccessManager {
@@ -71,7 +77,7 @@ public:
 	MyQWebPage webPage;
 	MyQWebPage webPage;
 	LoaderObject lo;
 	LoaderObject lo;
 	int httpErrorCode;
 	int httpErrorCode;
-	const settings::LoadPage settings;	
+	const settings::LoadPage settings;
 public slots:
 public slots:
 	void load();
 	void load();
 	void loadStarted();
 	void loadStarted();
@@ -116,7 +122,7 @@ public:
 	TempFile tempIn;
 	TempFile tempIn;
 
 
 	MultiPageLoaderPrivate(const settings::LoadGlobal & settings, MultiPageLoader & o);
 	MultiPageLoaderPrivate(const settings::LoadGlobal & settings, MultiPageLoader & o);
-	~MultiPageLoaderPrivate(); 
+	~MultiPageLoaderPrivate();
 	LoaderObject * addResource(const QUrl & url, const settings::LoadPage & settings);
 	LoaderObject * addResource(const QUrl & url, const settings::LoadPage & settings);
 	void load();
 	void load();
 	void clearResources();
 	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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outputter.hh"
 #include "outputter.hh"
 
 
 /*!
 /*!
@@ -93,7 +98,7 @@
   Begin a section with command line switches
   Begin a section with command line switches
 */
 */
 
 
-	
+
 /*!
 /*!
   \fn Outputter::cswitch(const ArgHandler * h, bool doc)
   \fn Outputter::cswitch(const ArgHandler * h, bool doc)
   Output a switch description
   Output a switch description
@@ -115,4 +120,3 @@ void Outputter::paragraph(const QString & t) {
 	text(t);
 	text(t);
 	endParagraph();
 	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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __OUTPUTTER_HH__
 #ifndef __OUTPUTTER_HH__
 #define __OUTPUTTER_HH__
 #define __OUTPUTTER_HH__
+#include "commandlineparserbase.hh"
 #include <QString>
 #include <QString>
 #include <QVector>
 #include <QVector>
 #include <stdio.h>
 #include <stdio.h>
-#include "commandlineparserbase.hh"
 
 
 class Outputter {
 class Outputter {
 public:
 public:
@@ -45,5 +49,4 @@ public:
 	static Outputter * man(FILE * fd);
 	static Outputter * man(FILE * fd);
 	static Outputter * html(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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "progressfeedback.hh"
 #include "progressfeedback.hh"
 #include <cstdio>
 #include <cstdio>
 namespace wkhtmltopdf {
 namespace wkhtmltopdf {
@@ -28,7 +32,7 @@ namespace wkhtmltopdf {
 */
 */
 
 
 #define S(t) ((t).toLocal8Bit().constData())
 #define S(t) ((t).toLocal8Bit().constData())
-	
+
 /*!
 /*!
   \brief Write out a warning message
   \brief Write out a warning message
   \param message The warning message
   \param message The warning message
@@ -36,7 +40,7 @@ namespace wkhtmltopdf {
 void ProgressFeedback::warning(const QString &message) {
 void ProgressFeedback::warning(const QString &message) {
 	if (quiet) return;
 	if (quiet) return;
 	fprintf(stderr, "Warning: %s",S(message));
 	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, " ");
 	fprintf(stderr, "\n");
 	fprintf(stderr, "\n");
 	lw = 0;
 	lw = 0;
@@ -48,7 +52,7 @@ void ProgressFeedback::warning(const QString &message) {
 */
 */
 void ProgressFeedback::error(const QString &message) {
 void ProgressFeedback::error(const QString &message) {
 	fprintf(stderr, "Error: %s",S(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, " ");
 	fprintf(stderr, "\n");
 	fprintf(stderr, "\n");
 	lw = 0;
 	lw = 0;
@@ -61,11 +65,11 @@ void ProgressFeedback::phaseChanged() {
 	if (quiet) return;
 	if (quiet) return;
 	QString desc=converter.phaseDescription();
 	QString desc=converter.phaseDescription();
 	fprintf(stderr, "%s", S(desc));
 	fprintf(stderr, "%s", S(desc));
-	
+
 	int l = desc.size();
 	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);
 		l += fprintf(stderr," (%d/%d)",converter.currentPhase()+1,converter.phaseCount()-1);
-	for(; l < lw; ++l) 
+	for (; l < lw; ++l)
 		fprintf(stderr, " ");
 		fprintf(stderr, " ");
 	fprintf(stderr, "\n");
 	fprintf(stderr, "\n");
 	lw = 0;
 	lw = 0;
@@ -88,7 +92,7 @@ void ProgressFeedback::progressChanged(int progress) {
 	fprintf(stderr, "]");
 	fprintf(stderr, "]");
 	fprintf(stderr, " %s", S(converter.progressString()));
 	fprintf(stderr, " %s", S(converter.progressString()));
 	int l=1+w+2+converter.progressString().size();
 	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;
 	lw = l;
 	fprintf(stderr, "\r");
 	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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __PROGRESSFEEDBACK_HH__
 #ifndef __PROGRESSFEEDBACK_HH__
 #define __PROGRESSFEEDBACK_HH__
 #define __PROGRESSFEEDBACK_HH__
 #include "converter.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
 #Lbaray Part
 HEADERS += ../shared/multipageloader_p.hh ../shared/multipageloader.hh ../shared/converter.hh \
 HEADERS += ../shared/multipageloader_p.hh ../shared/multipageloader.hh ../shared/converter.hh \
 	 ../shared/converter_p.hh ../shared/progressfeedback.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 \
 SOURCES += ../shared/outputter.cc ../shared/manoutputter.cc ../shared/htmloutputter.cc \
            ../shared/textoutputter.cc ../shared/arghandler.cc ../shared/commondocparts.cc \
            ../shared/textoutputter.cc ../shared/arghandler.cc ../shared/commondocparts.cc \
  	   ../shared/commandlineparserbase.cc ../shared/commonarguments.cc ../shared/utilities.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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "tempfile.hh"
 #include "tempfile.hh"
-#include <QUuid>
-#include <QFile>
 #include <QDir>
 #include <QDir>
+#include <QFile>
+#include <QUuid>
 /*!
 /*!
   \file tempfile.hh
   \file tempfile.hh
   \brief Defines the TempFile class
   \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
   \brief Remove the temporery file hold by this object it it exists
 */
 */
 void TempFile::remove() {
 void TempFile::remove() {
-	if (!path.isEmpty())						
+	if (!path.isEmpty())
 		QFile::remove(path);
 		QFile::remove(path);
 	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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __TEMPFILE_HH__
 #ifndef __TEMPFILE_HH__
 #define __TEMPFILE_HH__
 #define __TEMPFILE_HH__
 #include <QString>
 #include <QString>
@@ -26,5 +31,4 @@ public:
 	QString create(const QString & ext);
 	QString create(const QString & ext);
 	void remove();
 	void remove();
 };
 };
-
 #endif //__TEMPFILE_HH__
 #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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "outputter.hh"
 #include "outputter.hh"
 #include <qstringlist.h>
 #include <qstringlist.h>
 
 
@@ -31,25 +35,25 @@ public:
 	TextOutputter(FILE * _, bool d, bool e): fd(_), doc(d), extended(e) {}
 	TextOutputter(FILE * _, bool d, bool e): fd(_), doc(d), extended(e) {}
 
 
 	void beginSection(const QString & name) {
 	void beginSection(const QString & name) {
-		if(doc) {
+		if (doc) {
 			int x= 80 - name.size() - 4;
 			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, "=");
 			fprintf(fd, "> %s <", S(name) );
 			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, "=");
 			fprintf(fd, "\n");
 			fprintf(fd, "\n");
-		} else 
+		} else
 			fprintf(fd, "%s:\n", S(name) );
 			fprintf(fd, "%s:\n", S(name) );
 	}
 	}
-	
+
 	void endSection() {
 	void endSection() {
 	}
 	}
 
 
 	void beginParagraph() {
 	void beginParagraph() {
 		first=true;
 		first=true;
-		if(doc) {
+		if (doc) {
 			w=0;
 			w=0;
 		} else {
 		} else {
 			w=2;
 			w=2;
@@ -60,10 +64,10 @@ public:
 	void text(const QString & t) {
 	void text(const QString & t) {
 		first=true;
 		first=true;
 		QStringList list = t.split(" ");
 		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");
 				fprintf(fd, "\n");
-				if(doc) {
+				if (doc) {
 					w=0;
 					w=0;
 				} else {
 				} else {
 					w=2;
 					w=2;
@@ -71,7 +75,7 @@ public:
 				}
 				}
 				first=true;
 				first=true;
 			}
 			}
-			if(first) first=false;
+			if (first) first=false;
 			else {
 			else {
 				fprintf(fd, " ");
 				fprintf(fd, " ");
 				++w;
 				++w;
@@ -80,19 +84,19 @@ public:
 			fprintf(fd, "%s", S(s));
 			fprintf(fd, "%s", S(s));
 		}
 		}
 	}
 	}
-	
+
 	void sectionLink(const QString & t) {
 	void sectionLink(const QString & t) {
 		text(t);
 		text(t);
 	}
 	}
-	
+
 	void bold(const QString & t) {
 	void bold(const QString & t) {
 		text("*"+t+"*");
 		text("*"+t+"*");
 	}
 	}
-	
+
 	void italic(const QString & t) {
 	void italic(const QString & t) {
 		text("_"+t+"_");
 		text("_"+t+"_");
 	}
 	}
-	
+
 	void link(const QString & t) {
 	void link(const QString & t) {
 		text("<"+t+">");
 		text("<"+t+">");
 	}
 	}
@@ -102,10 +106,10 @@ public:
 	}
 	}
 
 
 	void verbatim(const QString & t) {
 	void verbatim(const QString & t) {
-		if(doc)
+		if (doc)
 			fprintf(fd,"%s\n", S(t));
 			fprintf(fd,"%s\n", S(t));
 		else {
 		else {
-			foreach(const QString & s, t.split("\n"))
+			foreach (const QString & s, t.split("\n"))
 				fprintf(fd,"  %s\n",S(s));
 				fprintf(fd,"  %s\n",S(s));
 		}
 		}
 	}
 	}
@@ -121,36 +125,36 @@ public:
 		else fprintf(fd, "%3d ", order++);
 		else fprintf(fd, "%3d ", order++);
 		fprintf(fd,"%s\n",S(s));
 		fprintf(fd,"%s\n",S(s));
 	}
 	}
-	
+
 	void beginSwitch() {}
 	void beginSwitch() {}
 
 
 	void cswitch(const ArgHandler * h) {
 	void cswitch(const ArgHandler * h) {
 		w=0;
 		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);
 			fprintf(fd,"-%c, ",h->shortSwitch);
 		else
 		else
 			fprintf(fd,"    ");
 			fprintf(fd,"    ");
 		fprintf(fd,"--%s",S(h->longName));
 		fprintf(fd,"--%s",S(h->longName));
 		w+=4 + 2 + h->longName.size();
 		w+=4 + 2 + h->longName.size();
-		if (doc && h->qthack) { 
+		if (doc && h->qthack) {
 			fprintf(fd, " *");
 			fprintf(fd, " *");
 			w += 2;
 			w += 2;
 		}
 		}
-				
-		foreach(const QString & arg, h->argn) {
+
+		foreach (const QString & arg, h->argn) {
 			fprintf(fd," <%s>",S(arg));
 			fprintf(fd," <%s>",S(arg));
 			w+=3+arg.size();
 			w+=3+arg.size();
 		}
 		}
-		while(w < 37) {
+		while (w < 37) {
 			fprintf(fd," ");
 			fprintf(fd," ");
 			++w;
 			++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");
 				printf("\n");
 				w=0;
 				w=0;
-				while(w < 37) {
+				while (w < 37) {
 					fprintf(fd," ");
 					fprintf(fd," ");
 					++w;
 					++w;
 				}
 				}
@@ -165,8 +169,8 @@ public:
 		if (doc)
 		if (doc)
 			fprintf(fd, "\nItems marked * are only available using patched QT.\n");
 			fprintf(fd, "\nItems marked * are only available using patched QT.\n");
 		printf("\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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "utilities.hh"
 #include "utilities.hh"
 
 
 #ifdef QT_STATIC
 #ifdef QT_STATIC
@@ -35,14 +40,14 @@ void MyLooksStyle::drawPrimitive( PrimitiveElement element, const QStyleOption *
 	QRect r = option->rect;
 	QRect r = option->rect;
 	if (element == QStyle::PE_PanelLineEdit) {
 	if (element == QStyle::PE_PanelLineEdit) {
 		painter->drawRect(r);
 		painter->drawRect(r);
-	} else if(element == QStyle::PE_IndicatorCheckBox) {
+	} else if (element == QStyle::PE_IndicatorCheckBox) {
 		painter->drawRect(r);
 		painter->drawRect(r);
 		if (!weAreDrawingForms && (option->state & QStyle::State_On)) {
 		if (!weAreDrawingForms && (option->state & QStyle::State_On)) {
 			r.translate(int(r.width()*0.075), int(r.width()*0.075));
 			r.translate(int(r.width()*0.075), int(r.width()*0.075));
 			painter->drawLine(r.topLeft(), r.bottomRight());
 			painter->drawLine(r.topLeft(), r.bottomRight());
 			painter->drawLine(r.topRight(), r.bottomLeft());
 			painter->drawLine(r.topRight(), r.bottomLeft());
 		}
 		}
-	} else if(element == QStyle::PE_IndicatorRadioButton) {
+	} else if (element == QStyle::PE_IndicatorRadioButton) {
 		painter->drawEllipse(r);
 		painter->drawEllipse(r);
 		if (!weAreDrawingForms && (option->state & QStyle::State_On)) {
 		if (!weAreDrawingForms && (option->state & QStyle::State_On)) {
 			r.translate(int(r.width()*0.20), int(r.width()*0.20));
 			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();
 //   QList<QByteArray> formats = QImageWriter::supportedImageFormats();
 //   for ( QList<QByteArray>::Iterator f = formats.begin(); f != formats.end(); ++ f )
 //   for ( QList<QByteArray>::Iterator f = formats.begin(); f != formats.end(); ++ f )
 //     printf("%s , ", f->constData() );
 //     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.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __UTILITIES_HH__
 #ifndef __UTILITIES_HH__
 #define __UTILITIES_HH__
 #define __UTILITIES_HH__
-
 #include <QCleanlooksStyle>
 #include <QCleanlooksStyle>
 #include <QCommonStyle>
 #include <QCommonStyle>
-#include <QPainter>
-#include <QStyleOption>
-#include <QUrl>
 #include <QFile>
 #include <QFile>
 #include <QFileInfo>
 #include <QFileInfo>
 #include <QImageWriter>
 #include <QImageWriter>
+#include <QPainter>
+#include <QStyleOption>
+#include <QUrl>
 
 
 /**
 /**
  * Custom simplistic style
  * Custom simplistic style
@@ -40,5 +44,4 @@ public slots:
 };
 };
 
 
 int handleError(bool success, int errorCode);
 int handleError(bool success, int errorCode);
-
 #endif //__UTILITIES_HH__
 #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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "websettings.hh"
 #include "websettings.hh"
 namespace wkhtmltopdf {
 namespace wkhtmltopdf {
 namespace settings {
 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)); -*-
 // -*- 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 :
 // vi:set ts=4 sts=4 sw=4 noet :
+//
+// Copyright 2010 wkhtmltopdf authors
+//
 // This file is part of wkhtmltopdf.
 // This file is part of wkhtmltopdf.
 //
 //
 // wkhtmltopdf is free software: you can redistribute it and/or modify
 // 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
 // You should have received a copy of the GNU General Public License
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
 // along with wkhtmltopdf.  If not, see <http://www.gnu.org/licenses/>.
+
 #ifndef __WEBSETTINGS_HH__
 #ifndef __WEBSETTINGS_HH__
 #define __WEBSETTINGS_HH__
 #define __WEBSETTINGS_HH__
-#include <QString>
 #include <QNetworkProxy>
 #include <QNetworkProxy>
+#include <QString>
 namespace wkhtmltopdf {
 namespace wkhtmltopdf {
 namespace settings {
 namespace settings {
 
 
@@ -26,25 +30,25 @@ struct Web {
 
 
 	//! Should we print background images
 	//! Should we print background images
 	bool background;
 	bool background;
-	
+
 	//! Should we load images
 	//! Should we load images
 	bool loadImages;
 	bool loadImages;
 
 
 	//! Should we enable Javascript
 	//! Should we enable Javascript
-	bool enableJavascript; 
-	
+	bool enableJavascript;
+
 	//! Should the horrible intelligent shrinking feature be enabled?
 	//! Should the horrible intelligent shrinking feature be enabled?
 	bool enableIntelligentShrinking;
 	bool enableIntelligentShrinking;
-		
+
 	//! Minimum font size
 	//! Minimum font size
 	int minimumFontSize;
 	int minimumFontSize;
-	
+
 	//! Should we use the print or the screen media type
 	//! Should we use the print or the screen media type
 	bool printMediaType;
 	bool printMediaType;
-	
+
 	//! Encoding used to enterpit a document with do supplied encoding
 	//! Encoding used to enterpit a document with do supplied encoding
 	QString defaultEncoding;
 	QString defaultEncoding;
-	
+
 	//! Stylesheet supplied by the user
 	//! Stylesheet supplied by the user
 	QString userStyleSheet;
 	QString userStyleSheet;
 
 

+ 2 - 0
wkhtmltopdf.pro

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