fix 2 glitches in pdf page numer handling
This commit is contained in:
parent
99f36613e8
commit
580615da28
2 changed files with 20 additions and 12 deletions
|
@ -105,7 +105,7 @@ void SnippetsW::init()
|
||||||
|
|
||||||
void SnippetsW::linkWasClicked(const QUrl &url)
|
void SnippetsW::linkWasClicked(const QUrl &url)
|
||||||
{
|
{
|
||||||
string ascurl = (const char *)url.toString().toAscii();;
|
string ascurl = (const char *)url.toString().toAscii();
|
||||||
LOGDEB(("Snippets::linkWasClicked: [%s]\n", ascurl.c_str()));
|
LOGDEB(("Snippets::linkWasClicked: [%s]\n", ascurl.c_str()));
|
||||||
|
|
||||||
if (ascurl.size() > 3) {
|
if (ascurl.size() > 3) {
|
||||||
|
@ -113,7 +113,10 @@ void SnippetsW::linkWasClicked(const QUrl &url)
|
||||||
switch (what) {
|
switch (what) {
|
||||||
case 'P':
|
case 'P':
|
||||||
{
|
{
|
||||||
int page = atoi(ascurl.c_str()+2);
|
string::size_type numpos = ascurl.find_first_of("0123456789");
|
||||||
|
if (numpos == string::npos)
|
||||||
|
return;
|
||||||
|
int page = atoi(ascurl.c_str() + numpos);
|
||||||
emit startNativeViewer(m_doc, page);
|
emit startNativeViewer(m_doc, page);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,7 @@ bool Db::Native::getPagePositions(Xapian::docid docid, vector<int>& vpos)
|
||||||
doc.getmeta(cstr_mbreaks, &mbreaks)) {
|
doc.getmeta(cstr_mbreaks, &mbreaks)) {
|
||||||
vector<string> values;
|
vector<string> values;
|
||||||
stringToTokens(mbreaks, values, ",");
|
stringToTokens(mbreaks, values, ",");
|
||||||
for (unsigned int i = 0; i < values.size() / 2; i += 2) {
|
for (unsigned int i = 0; i < values.size() - 1; i += 2) {
|
||||||
int pos = atoi(values[i].c_str()) + baseTextPosition;
|
int pos = atoi(values[i].c_str()) + baseTextPosition;
|
||||||
int incr = atoi(values[i+1].c_str());
|
int incr = atoi(values[i+1].c_str());
|
||||||
mbreaksmap[pos] = incr;
|
mbreaksmap[pos] = incr;
|
||||||
|
@ -216,6 +216,8 @@ bool Db::Native::getPagePositions(Xapian::docid docid, vector<int>& vpos)
|
||||||
pos != xrdb.positionlist_end(docid, qterm); pos++) {
|
pos != xrdb.positionlist_end(docid, qterm); pos++) {
|
||||||
int ipos = *pos;
|
int ipos = *pos;
|
||||||
if (ipos < int(baseTextPosition)) {
|
if (ipos < int(baseTextPosition)) {
|
||||||
|
LOGDEB(("getPagePositions: got page position %d not in body\n",
|
||||||
|
ipos));
|
||||||
// Not in text body. Strange...
|
// Not in text body. Strange...
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -687,9 +689,10 @@ public:
|
||||||
void newpage(int pos)
|
void newpage(int pos)
|
||||||
{
|
{
|
||||||
pos += m_ts->basepos;
|
pos += m_ts->basepos;
|
||||||
LOGDEB2(("newpage: %d\n", pos));
|
if (pos < int(baseTextPosition)) {
|
||||||
if (pos < int(baseTextPosition))
|
LOGDEB(("newpage: not in body\n", pos));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_ts->doc.add_posting(m_ts->prefix + page_break_term, pos);
|
m_ts->doc.add_posting(m_ts->prefix + page_break_term, pos);
|
||||||
if (pos == m_lastpagepos) {
|
if (pos == m_lastpagepos) {
|
||||||
|
@ -701,9 +704,10 @@ public:
|
||||||
m_pageincr, m_lastpagepos));
|
m_pageincr, m_lastpagepos));
|
||||||
if (m_pageincr > 0) {
|
if (m_pageincr > 0) {
|
||||||
// Remember the multiple page break at this position
|
// Remember the multiple page break at this position
|
||||||
m_pageincrvec.push_back(
|
unsigned int relpos = m_lastpagepos - baseTextPosition;
|
||||||
pair<int, int>(m_lastpagepos - baseTextPosition,
|
LOGDEB2(("Remembering multiple page break. Relpos %u cnt %d\n",
|
||||||
m_pageincr));
|
relpos, m_pageincr));
|
||||||
|
m_pageincrvec.push_back(pair<int, int>(relpos, m_pageincr));
|
||||||
}
|
}
|
||||||
m_pageincr = 0;
|
m_pageincr = 0;
|
||||||
}
|
}
|
||||||
|
@ -713,9 +717,10 @@ public:
|
||||||
virtual bool flush()
|
virtual bool flush()
|
||||||
{
|
{
|
||||||
if (m_pageincr > 0) {
|
if (m_pageincr > 0) {
|
||||||
m_pageincrvec.push_back(
|
unsigned int relpos = m_lastpagepos - baseTextPosition;
|
||||||
pair<int, int>(m_lastpagepos - baseTextPosition,
|
LOGDEB2(("Remembering multiple page break. Position %u cnt %d\n",
|
||||||
m_pageincr));
|
relpos, m_pageincr));
|
||||||
|
m_pageincrvec.push_back(pair<int, int>(relpos, m_pageincr));
|
||||||
m_pageincr = 0;
|
m_pageincr = 0;
|
||||||
}
|
}
|
||||||
return TermProc::flush();
|
return TermProc::flush();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue