Support '#page=<pagenum>' fragment to open at page <pagenum>
AbandonedPublic

Authored by michaelweghorn on Apr 27 2019, 2:07 PM.

Details

Reviewers
aacid
Group Reviewers
Okular
Summary

Support the '#page=<pagenum>' fragment to specify which page
to open the document at, in addition to the existing '#<pagenum>'
syntax.
For PDF, the '#page=<pagenum>' fragment is specified in RFC 8118,
section 3.

BUG: 406831

Test Plan
  1. Put a test file that has multiple pages at '/tmp/testfile.pdf'
  2. Check that all of the following commands open the test file on page 2:

    okular /tmp/testfile.pdf#2 okular /tmp/testfile.pdf#page=2 okular file:///tmp/testfile.pdf#2 okular file:///tmp/testfile.pdf#page=2

Diff Detail

Repository
R223 Okular
Branch
michaelweghorn/kdebug406831_support_rfc_compliant_way_to_open_at_page
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 11300
Build 11318: arc lint + arc unit
michaelweghorn created this revision.Apr 27 2019, 2:07 PM
Restricted Application added a project: Okular. · View Herald TranscriptApr 27 2019, 2:07 PM
Restricted Application added a subscriber: okular-devel. · View Herald Transcript
michaelweghorn requested review of this revision.Apr 27 2019, 2:07 PM

How about the following approach (not tested)? This way, other parameters (like nameddest) wouldn’t break it and can be added later.

const QString fragment = url.fragment(QUrl::EncodeDelimiters);

bool gotOpenPageNumber = false;
int openPageNumber = fragment.toInt(&gotOpenPageNumber);

for ( QString parameter : fragment.split(QChar('&') )
{
    if ( parameter.startsWith("page=", Qt::CaseInsensitive) )
    {
        bool ok = false;
        int page = parameter.mid(5).toInt(&ok);
        if ( ok )
        {
            openPageNumber = page;
            gotOpenPageNumber = true;
        }
    }
}

I`m not sure whether QUrl::EncodeDelimiters is optimal.

aacid added a subscriber: aacid.Apr 28 2019, 4:07 PM

needs autotest

aacid requested changes to this revision.Feb 21 2020, 6:55 PM

Please move as a Merge Request in https://invent.kde.org/kde/okular

We have pre-commit CI and lots of checks including clazy and clang-tidy there so it's a much better place for doing the review/approval/merge of the code.

This revision now requires changes to proceed.Feb 21 2020, 6:55 PM
michaelweghorn abandoned this revision.Sep 9 2020, 12:07 PM

Please move as a Merge Request in https://invent.kde.org/kde/okular

We have pre-commit CI and lots of checks including clazy and clang-tidy there so it's a much better place for doing the review/approval/merge of the code.

Finally moved there: https://invent.kde.org/graphics/okular/-/merge_requests/265
Sorry for the extreme delay!