Commit 2581597b authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Implement links that point inside the same document. This is again a read what...

Implement links that point inside the same document. This is again a read what xpdf does, guess how it works and try to port it @ kpdf, seems to work when using the links on the index inside idd.pdf file that comes with cups
Eros have a look as there is another function here using the cvtUserToDev thingy of OutputDev
CCMAIL: eros.kde@email.it

svn path=/trunk/kdegraphics/kpdf/; revision=346805
parent 5d3a315a
......@@ -386,6 +386,52 @@ namespace KPDF
return b;
}
void PageWidget::position(LinkDest* dest)
{
int dx, dy;
switch (dest->getKind())
{
case destXYZ:
m_outputdev->cvtUserToDev(dest->getLeft(), dest->getTop(), &dx, &dy);
if (dest->getChangeLeft())
{
horizontalScrollBar()->setValue( dx );
}
if (dest->getChangeTop())
{
verticalScrollBar()->setValue( dy );
}
//~ what is the zoom parameter?
break;
case destFit:
case destFitB:
//~ do fit
verticalScrollBar()->setValue( 0 );
horizontalScrollBar()->setValue( 0 );
break;
case destFitH:
case destFitBH:
//~ do fit
m_outputdev->cvtUserToDev(0, dest->getTop(), &dx, &dy);
verticalScrollBar()->setValue( dy );
horizontalScrollBar()->setValue( 0 );
break;
case destFitV:
case destFitBV:
//~ do fit
m_outputdev->cvtUserToDev(dest->getLeft(), 0, &dx, &dy);
verticalScrollBar()->setValue( 0 );
horizontalScrollBar()->setValue( dx );
break;
case destFitR:
//~ do fit
m_outputdev->cvtUserToDev(dest->getLeft(), dest->getTop(), &dx, &dy);
verticalScrollBar()->setValue( dy );
horizontalScrollBar()->setValue( dx );
break;
}
}
}
// vim:ts=2:sw=2:tw=78:et
......@@ -25,6 +25,7 @@ class QMutex;
class QWidget;
class LinkAction;
class LinkDest;
class PDFDoc;
class QOutputDevPixmap;
......@@ -57,6 +58,7 @@ namespace KPDF
void zoomTo( double _value );
bool find(Unicode *u, int len, bool next);
void position(LinkDest* dest);
public slots:
void zoomIn();
......
......@@ -485,80 +485,27 @@ Part::displayPage(int pageNumber, float /*zoomFactor*/)
// m_currentPage = pageNumber;
}
/*
void
Part::displayDestination(LinkDest* dest)
{
int pageNumber;
// int dx, dy;
Ref pageRef;
int pg;
if (dest->isPageRef())
{
Ref pageRef = dest->getPageRef();
pageNumber = m_doc->findPage(pageRef.num, pageRef.gen);
pageRef = dest->getPageRef();
pg = m_doc->findPage(pageRef.num, pageRef.gen);
}
else
{
pageNumber = dest->getPageNum();
pg = dest->getPageNum();
}
if (pg <= 0 || pg > m_doc->getNumPages()) pg = 1;
if (pg != m_currentPage) goToPage(pg);
if (pageNumber <= 0 || pageNumber > m_doc->getNumPages())
{
pageNumber = 1;
}
displayPage(pageNumber);
return;
if (fullScreen) {
return;
}
switch (dest->getKind()) {
case destXYZ:
out->cvtUserToDev(dest->getLeft(), dest->getTop(), &dx, &dy);
if (dest->getChangeLeft() || dest->getChangeTop()) {
if (dest->getChangeLeft()) {
hScrollbar->setPos(dx, canvas->getWidth());
}
if (dest->getChangeTop()) {
vScrollbar->setPos(dy, canvas->getHeight());
}
canvas->scroll(hScrollbar->getPos(), vScrollbar->getPos());
}
//~ what is the zoom parameter?
break;
case destFit:
case destFitB:
//~ do fit
hScrollbar->setPos(0, canvas->getWidth());
vScrollbar->setPos(0, canvas->getHeight());
canvas->scroll(hScrollbar->getPos(), vScrollbar->getPos());
break;
case destFitH:
case destFitBH:
//~ do fit
out->cvtUserToDev(0, dest->getTop(), &dx, &dy);
hScrollbar->setPos(0, canvas->getWidth());
vScrollbar->setPos(dy, canvas->getHeight());
canvas->scroll(hScrollbar->getPos(), vScrollbar->getPos());
break;
case destFitV:
case destFitBV:
//~ do fit
out->cvtUserToDev(dest->getLeft(), 0, &dx, &dy);
hScrollbar->setPos(dx, canvas->getWidth());
vScrollbar->setPos(0, canvas->getHeight());
canvas->scroll(hScrollbar->getPos(), vScrollbar->getPos());
break;
case destFitR:
//~ do fit
out->cvtUserToDev(dest->getLeft(), dest->getTop(), &dx, &dy);
hScrollbar->setPos(dx, canvas->getWidth());
vScrollbar->setPos(dy, canvas->getHeight());
canvas->scroll(hScrollbar->getPos(), vScrollbar->getPos());
break;
}
}*/
m_outputDev->position(dest);
}
void
Part::print()
......@@ -682,8 +629,7 @@ Part::executeAction(LinkAction* action)
}
if (dest)
{
// TODO implement
//displayDest(dest, zoom, rotate, gTrue);
displayDestination(dest);
delete dest;
}
else
......
......@@ -76,7 +76,7 @@ namespace KPDF
bool closeURL();
void displayPage(int pageNumber, float zoomFactor = 1.0);
/*void displayDestination(LinkDest*);*/
void displayDestination(LinkDest*);
void updateActionPage();
void setFullScreen( bool fs );
PageWidget* pageWidget() const {return m_outputDev;}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment