Эх сурвалжийг харах

Fix issue 426: Reenable --page-offset

Antialize 15 жил өмнө
parent
commit
f1cdf59fd0

+ 10 - 12
src/lib/outline.cc

@@ -135,7 +135,7 @@ 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) {
 	foreach (OutlineItem * item, items) {
 		for (int i=0; i < level; ++i) stream << "  ";
 		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]+ settings.pageOffset) << "\" link=\"" << escape(item->anchor) << "\" backLink=\"" << escape(item->tocAnchor) << "\"";
 		if (item->children.empty())
 		if (item->children.empty())
 			stream << "/>" << endl;
 			stream << "/>" << endl;
 		else {
 		else {
@@ -147,12 +147,15 @@ void OutlinePrivate::dumpChildren(QTextStream & stream, const QList<OutlineItem
 	}
 	}
 }
 }
 
 
-void Outline::dump(QTextStream & stream, const QString & xsl) const {
-	d->prefixSum.clear();
-	d->prefixSum.push_back(0);
-	foreach (int x, d->documentPages)
-		d->prefixSum.push_back( d->prefixSum.back() + x );
+void OutlinePrivate::buildPrefixSum() {
+	prefixSum.clear();
+	prefixSum.push_back(0);
+	foreach (int x, documentPages)
+		prefixSum.push_back( prefixSum.back() + x);
+}
 
 
+void Outline::dump(QTextStream & stream, const QString & xsl) const {
+	d->buildPrefixSum();
 	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())
@@ -278,12 +281,7 @@ void Outline::addEmptyWebPage() {
 }
 }
 
 
 void OutlinePrivate::buildHFCache(OutlineItem * i, int level) {
 void OutlinePrivate::buildHFCache(OutlineItem * i, int level) {
-	if (prefixSum.empty()) {
-		prefixSum.push_back(0);
-		foreach (int x, documentPages)
-			prefixSum.push_back( prefixSum.back() + x );
-	}
-
+	buildPrefixSum();
 	if (level >= hfCache.size()) return;
 	if (level >= hfCache.size()) return;
 	foreach (OutlineItem * j, i->children) {
 	foreach (OutlineItem * j, i->children) {
 		int page = j->page + prefixSum[j->document];
 		int page = j->page + prefixSum[j->document];

+ 1 - 0
src/lib/outline_p.hh

@@ -66,6 +66,7 @@ public:
 
 
 	OutlinePrivate(const settings::PdfGlobal & settings);
 	OutlinePrivate(const settings::PdfGlobal & settings);
 	~OutlinePrivate();
 	~OutlinePrivate();
+	void buildPrefixSum();
 	void fillChildAnchors(OutlineItem * item, QHash<QString, QWebElement> & anchors);
 	void fillChildAnchors(OutlineItem * item, QHash<QString, QWebElement> & anchors);
 	void outlineChildren(OutlineItem * item, QPrinter * printer, int level);
 	void outlineChildren(OutlineItem * item, QPrinter * printer, int level);
 	void buildHFCache(OutlineItem * i, int level);
 	void buildHFCache(OutlineItem * i, int level);

+ 2 - 3
src/pdf/pdfarguments.cc

@@ -138,7 +138,7 @@ struct DefaultTocFunc {
 struct DefaultHeaderFunc {
 struct DefaultHeaderFunc {
 	bool operator()(const char **, CommandLineParserBase & p, char * page) {
 	bool operator()(const char **, CommandLineParserBase & p, char * page) {
 		reinterpret_cast<PdfObject*>(page)->header.left="[webpage]";
 		reinterpret_cast<PdfObject*>(page)->header.left="[webpage]";
-		reinterpret_cast<PdfObject*>(page)->header.right="[page]/[toPdfObject]";
+		reinterpret_cast<PdfObject*>(page)->header.right="[page]/[topage]";
 		reinterpret_cast<PdfObject*>(page)->header.line=true;
 		reinterpret_cast<PdfObject*>(page)->header.line=true;
 		static_cast<PdfCommandLineParser&>(p).globalSettings.margin.top = strToUnitReal("2cm");
 		static_cast<PdfCommandLineParser&>(p).globalSettings.margin.top = strToUnitReal("2cm");
 		return true;
 		return true;
@@ -266,8 +266,7 @@ PdfCommandLineParser::PdfCommandLineParser(PdfGlobal & s, QList<PdfObject> & ps)
 	addarg("disable-toc-back-links",0,"Do not link from section header to toc", new ConstSetter<bool>(od.toc.backLinks,false));
 	addarg("disable-toc-back-links",0,"Do not link from section header to toc", new ConstSetter<bool>(od.toc.backLinks,false));
 
 
 	addPageLoadArgs(od.load);
 	addPageLoadArgs(od.load);
-// 	addarg("page-offset",0,"Set the starting page number", new IntSetter(s.pageOffset,"offset",1));
-
+ 	addarg("page-offset",0,"Set the starting page number", new IntSetter(s.pageOffset,"offset",1));
 
 
 	section("Headers And Footer Options");
 	section("Headers And Footer Options");
  	qthack(true);
  	qthack(true);