Skip to content

Commit

Permalink
116 bugfix pagenum (#120)
Browse files Browse the repository at this point in the history
* fixes #116 and jumps to page if provided via argument.

* harden and fix page number handling.

* fixup for pagenum patch to reuse existing method invoked from TextView and correctly update pagelist selection and position.
  • Loading branch information
grexe authored Aug 28, 2024
1 parent 3c9eae4 commit faed874
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
6 changes: 3 additions & 3 deletions bepdf/beos/BepdfApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,9 @@ void BepdfApplication::RefsReceived(BMessage *msg)
}
// jump to page if provided
if (pageNum != 0) {
mWindow->LockLooper();
mWindow->SetPage(pageNum);
mWindow->UnlockLooper();
BMessage goToPageMsg(PDFWindow::GOTO_PAGE_CMD);
goToPageMsg.AddInt32("page", pageNum);
mWindow->MessageReceived(&goToPageMsg);
}
// stop after first document
mGotSomething = true;
Expand Down
39 changes: 24 additions & 15 deletions bepdf/beos/PDFWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1069,22 +1069,31 @@ PDFWindow::MessageReceived(BMessage* message)
mMainView->MoveToPage (mMainView->GetNumPages());
break;
case GOTO_PAGE_CMD: {
status_t err;
BTextControl * control;
BControl * ptr;

err = message->FindPointer ("source", (void **)&ptr);
control = dynamic_cast <BTextControl *> (ptr);
if (err == B_OK && control != NULL) {
const char *txt = control->Text ();
page = atoi (txt);
mMainView->MoveToPage (page);
mMainView->MakeFocus();
} else {
/* ERROR */
}
}
status_t result;
BTextControl * control;
BControl * ptr;

result = message->FindPointer ("source", (void **)&ptr);
if (result == B_OK) {
control = dynamic_cast <BTextControl *> (ptr);
if (result == B_OK && control != NULL) {
const char *txt = control->Text ();
page = atoi (txt);
}
} else { // may come from external source over page parameter
result = message->FindInt32("page", &page);
if (result == B_OK)
mMainView->WaitForPage();
}

if (result == B_OK) {
LockLooper();
mMainView->MoveToPage (page);
UnlockLooper();
mMainView->MakeFocus();
}
break;
}
case PAGE_SELECTED_CMD:
page = mPagesView->CurrentSelection(0) + 1;
mMainView->MoveToPage(page);
Expand Down

0 comments on commit faed874

Please sign in to comment.