Browse Source

Fix issue 310: Sections in headers only work for the first document

Antialize 14 years ago
parent
commit
15e5d3321b
1 changed files with 9 additions and 3 deletions
  1. 9 3
      src/lib/outline.cc

+ 9 - 3
src/lib/outline.cc

@@ -278,12 +278,18 @@ void Outline::addEmptyWebPage() {
 }
 
 void OutlinePrivate::buildHFCache(OutlineItem * i, int level) {
+	if (prefixSum.empty()) {
+		prefixSum.push_back(0);
+		foreach (int x, documentPages)
+			prefixSum.push_back( prefixSum.back() + x );
+	}
+
 	if (level >= hfCache.size()) return;
 	foreach (OutlineItem * j, i->children) {
-		while (hfCache[level].size() < (int)j->page)
+		int page = j->page + prefixSum[j->document];
+		while (hfCache[level].size() < page)
 			hfCache[level].push_back(hfCache[level].back());
-
-		if (hfCache[level].size() == (int)j->page)
+		if (hfCache[level].size() == page)
 			hfCache[level].push_back(j);
 		buildHFCache(j, level+1);
 	}