mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-25 10:55:37 +00:00
Fixed design a little bit. Still need to remove redundant components though.
svn path=/trunk/kdegraphics/kpdf/; revision=234795
This commit is contained in:
parent
298b1eb641
commit
65ba29ed03
|
@ -43,7 +43,7 @@ shellrc_DATA = kpdf_shell.rc
|
|||
kde_module_LTLIBRARIES = libkpdfpart.la
|
||||
|
||||
# the Part's source, library search path, and link libraries
|
||||
libkpdfpart_la_SOURCES = kpdf_canvas.cpp kpdf_part.cpp kpdf_pagewidget.cc QOutputDev.cpp part.ui
|
||||
libkpdfpart_la_SOURCES = kpdf_canvas.cpp kpdf_part.cpp kpdf_pagewidget.cc QOutputDev.cpp QOutputDevPixmap.cpp part.ui
|
||||
libkpdfpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
|
||||
libkpdfpart_la_LIBADD = ../xpdf/libxpdf.la $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT)
|
||||
|
||||
|
|
1014
kpdf/QOutputDevPixmap.cpp
Normal file
1014
kpdf/QOutputDevPixmap.cpp
Normal file
File diff suppressed because it is too large
Load diff
165
kpdf/QOutputDevPixmap.h
Normal file
165
kpdf/QOutputDevPixmap.h
Normal file
|
@ -0,0 +1,165 @@
|
|||
|
||||
//========================================================================
|
||||
//
|
||||
// XOutputDev.h
|
||||
//
|
||||
// Copyright 1996 Derek B. Noonburg
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef QOUTPUTDEVPIXMAP_H
|
||||
#define QOUTPUTDEVPIXMAP_H
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "aconf.h"
|
||||
#include <stddef.h>
|
||||
|
||||
class Object;
|
||||
|
||||
#include "config.h"
|
||||
#include "CharTypes.h"
|
||||
#include "GlobalParams.h"
|
||||
#include "OutputDev.h"
|
||||
|
||||
class GString;
|
||||
class GList;
|
||||
struct GfxRGB;
|
||||
class GfxFont;
|
||||
class GfxSubpath;
|
||||
class TextPage;
|
||||
class XOutputFontCache;
|
||||
class Link;
|
||||
class Catalog;
|
||||
class DisplayFontParam;
|
||||
class UnicodeMap;
|
||||
class CharCodeToUnicode;
|
||||
|
||||
class QPainter;
|
||||
class QPixmap;
|
||||
class QPointArray;
|
||||
|
||||
#include <qstring.h>
|
||||
#include <qrect.h>
|
||||
|
||||
typedef double fp_t;
|
||||
|
||||
class QOutputDevPixmap : public OutputDev {
|
||||
public:
|
||||
|
||||
// Constructor.
|
||||
QOutputDevPixmap( );
|
||||
|
||||
// Destructor.
|
||||
virtual ~QOutputDevPixmap();
|
||||
|
||||
//---- get info about output device
|
||||
|
||||
// Does this device use upside-down coordinates?
|
||||
// (Upside-down means (0,0) is the top left corner of the page.)
|
||||
virtual GBool upsideDown() { return gTrue; }
|
||||
|
||||
// Does this device use drawChar() or drawString()?
|
||||
virtual GBool useDrawChar() { return gTrue; }
|
||||
|
||||
// Does this device use beginType3Char/endType3Char? Otherwise,
|
||||
// text in Type 3 fonts will be drawn with drawChar/drawString.
|
||||
virtual GBool interpretType3Chars() { return gFalse; }
|
||||
|
||||
// Does this device need non-text content?
|
||||
virtual GBool needNonText() { return gFalse; }
|
||||
|
||||
//----- initialization and control
|
||||
|
||||
// Start a page.
|
||||
virtual void startPage(int pageNum, GfxState *state);
|
||||
|
||||
// End a page.
|
||||
virtual void endPage();
|
||||
|
||||
//----- link borders
|
||||
virtual void drawLink(Link *link, Catalog /* *catalog */);
|
||||
|
||||
//----- save/restore graphics state
|
||||
virtual void saveState(GfxState *state);
|
||||
virtual void restoreState(GfxState *state);
|
||||
|
||||
//----- update graphics state
|
||||
virtual void updateAll(GfxState *state);
|
||||
virtual void updateCTM(GfxState *state, fp_t m11, fp_t m12,
|
||||
fp_t m21, fp_t m22, fp_t m31, fp_t m32);
|
||||
virtual void updateLineDash(GfxState *state);
|
||||
virtual void updateFlatness(GfxState *state);
|
||||
virtual void updateLineJoin(GfxState *state);
|
||||
virtual void updateLineCap(GfxState *state);
|
||||
virtual void updateMiterLimit(GfxState *state);
|
||||
virtual void updateLineWidth(GfxState *state);
|
||||
virtual void updateFillColor(GfxState *state);
|
||||
virtual void updateStrokeColor(GfxState *state);
|
||||
|
||||
//----- update text state
|
||||
virtual void updateFont(GfxState *state);
|
||||
|
||||
//----- path painting
|
||||
virtual void stroke(GfxState *state);
|
||||
virtual void fill(GfxState *state);
|
||||
virtual void eoFill(GfxState *state);
|
||||
|
||||
//----- path clipping
|
||||
virtual void clip(GfxState *state);
|
||||
virtual void eoClip(GfxState *state);
|
||||
|
||||
//----- text drawing
|
||||
virtual void beginString(GfxState *state, GString *s);
|
||||
virtual void endString(GfxState *state);
|
||||
virtual void drawChar(GfxState *state, fp_t x, fp_t y,
|
||||
fp_t dx, fp_t dy,
|
||||
fp_t originX, fp_t originY,
|
||||
CharCode code, Unicode *u, int uLen);
|
||||
|
||||
//----- image drawing
|
||||
virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
|
||||
int width, int height, GBool invert,
|
||||
GBool inlineImg);
|
||||
virtual void drawImage(GfxState *state, Object *ref, Stream *str,
|
||||
int width, int height, GfxImageColorMap *colorMap,
|
||||
int *maskColors, GBool inlineImg);
|
||||
|
||||
// Find a string. If <top> is true, starts looking at <l>,<t>;
|
||||
// otherwise starts looking at top of page. If <bottom> is true,
|
||||
// stops looking at <l+w-1>,<t+h-1>; otherwise stops looking at bottom
|
||||
// of page. If found, sets the text bounding rectange and returns
|
||||
// true; otherwise returns false.
|
||||
GBool findText ( Unicode *s, int len, GBool top, GBool bottom, int *xMin, int *yMin, int *xMax, int *yMax );
|
||||
|
||||
//----- special QT access
|
||||
|
||||
bool findText ( const QString &str, int &l, int &t, int &w, int &h, bool top = 0, bool bottom = 0 );
|
||||
bool findText ( const QString &str, QRect &r, bool top = 0, bool bottom = 0 );
|
||||
|
||||
// Get the text which is inside the specified rectangle.
|
||||
QString getText ( int left, int top, int width, int height );
|
||||
QString getText ( const QRect &r );
|
||||
|
||||
public:
|
||||
QPixmap * getPixmap() { return m_pixmap; };
|
||||
|
||||
private:
|
||||
QPixmap * m_pixmap; // pixmap to draw into
|
||||
QPainter * m_painter; // painter to draw to the pixmap
|
||||
|
||||
TextPage * m_text; // text from the current page
|
||||
|
||||
private:
|
||||
QFont matchFont ( GfxFont *, fp_t m11, fp_t m12, fp_t m21, fp_t m22 );
|
||||
|
||||
void updateLineAttrs ( GfxState *state, GBool updateDash );
|
||||
void doFill ( GfxState *state, bool winding );
|
||||
void doClip ( GfxState *state, bool winding );
|
||||
int convertPath ( GfxState *state, QPointArray &points, QArray<int> &lengths );
|
||||
int convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArray &points );
|
||||
};
|
||||
|
||||
#endif // QOUTPUTDEVPIXMAP
|
|
@ -1,68 +1,133 @@
|
|||
#include "QOutputDevPixmap.h"
|
||||
|
||||
#include <qcursor.h>
|
||||
#include <qpainter.h>
|
||||
|
||||
#include "PDFDoc.h"
|
||||
|
||||
#include "kpdf_pagewidget.h"
|
||||
#include "kpdf_pagewidget.moc"
|
||||
|
||||
using namespace KPDF;
|
||||
#include "utils.h"
|
||||
|
||||
PageWidget::PageWidget(QWidget* parent, const char* name)
|
||||
: QWidget(parent, name),
|
||||
m_doc(0),
|
||||
m_pressedAction( 0 )
|
||||
namespace KPDF
|
||||
{
|
||||
setMouseTracking(true);
|
||||
}
|
||||
PageWidget::PageWidget(QWidget* parent, const char* name)
|
||||
: QScrollView(parent, name, WRepaintNoErase),
|
||||
m_doc(0),
|
||||
m_zoomFactor( 1.0 ),
|
||||
m_currentPage( 1 ),
|
||||
m_pressedAction( 0 )
|
||||
{
|
||||
m_outputdev = new QOutputDevPixmap();
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
void
|
||||
PageWidget::setPixmap(const QPixmap& pm)
|
||||
{
|
||||
m_pixmap = pm;
|
||||
}
|
||||
void
|
||||
PageWidget::setPDFDocument(PDFDoc* doc)
|
||||
{
|
||||
m_doc = doc;
|
||||
updatePixmap();
|
||||
}
|
||||
|
||||
void
|
||||
PageWidget::setPDFDocument(PDFDoc* doc)
|
||||
{
|
||||
m_doc = doc;
|
||||
}
|
||||
void
|
||||
PageWidget::setPixelsPerPoint(float ppp)
|
||||
{
|
||||
m_ppp = ppp;
|
||||
}
|
||||
|
||||
void
|
||||
PageWidget::setPixelsPerPoint(float ppp)
|
||||
{
|
||||
m_ppp = ppp;
|
||||
}
|
||||
void
|
||||
PageWidget::contentsMousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
if (m_doc == 0)
|
||||
return;
|
||||
|
||||
void
|
||||
PageWidget::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
if (m_doc == 0)
|
||||
return;
|
||||
m_pressedAction = m_doc->findLink(e->x()/m_ppp, e->y()/m_ppp);
|
||||
}
|
||||
|
||||
m_pressedAction = m_doc->findLink(e->x()/m_ppp, e->y()/m_ppp);
|
||||
}
|
||||
void
|
||||
PageWidget::contentsMouseReleaseEvent(QMouseEvent* e)
|
||||
{
|
||||
if (m_doc == 0)
|
||||
return;
|
||||
|
||||
void
|
||||
PageWidget::mouseReleaseEvent(QMouseEvent* e)
|
||||
{
|
||||
if (m_doc == 0)
|
||||
return;
|
||||
LinkAction* action = m_doc->findLink(e->x()/m_ppp, e->y()/m_ppp);
|
||||
if (action == m_pressedAction)
|
||||
emit linkClicked(action);
|
||||
|
||||
LinkAction* action = m_doc->findLink(e->x()/m_ppp, e->y()/m_ppp);
|
||||
if (action == m_pressedAction)
|
||||
emit linkClicked(action);
|
||||
m_pressedAction = 0;
|
||||
}
|
||||
|
||||
m_pressedAction = 0;
|
||||
}
|
||||
void
|
||||
PageWidget::contentsMouseMoveEvent(QMouseEvent* e)
|
||||
{
|
||||
if (m_doc == 0)
|
||||
return;
|
||||
|
||||
void
|
||||
PageWidget::mouseMoveEvent(QMouseEvent* e)
|
||||
{
|
||||
if (m_doc == 0)
|
||||
return;
|
||||
|
||||
LinkAction* action = m_doc->findLink(e->x()/m_ppp, e->y()/m_ppp);
|
||||
setCursor(action != 0 ? Qt::PointingHandCursor : Qt::ArrowCursor);
|
||||
LinkAction* action = m_doc->findLink(e->x()/m_ppp, e->y()/m_ppp);
|
||||
setCursor(action != 0 ? Qt::PointingHandCursor : Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void PageWidget::drawContents ( QPainter *p, int clipx, int clipy, int clipw, int cliph )
|
||||
{
|
||||
QPixmap * m_pixmap = NULL;
|
||||
if (m_outputdev)
|
||||
m_pixmap = m_outputdev->getPixmap();
|
||||
if ( m_pixmap != NULL && ! m_pixmap->isNull() )
|
||||
p->drawPixmap ( clipx, clipy, *m_pixmap, clipx, clipy, clipw, cliph );
|
||||
else
|
||||
p->fillRect ( clipx, clipy, clipw, cliph, white );
|
||||
}
|
||||
|
||||
void PageWidget::nextPage()
|
||||
{
|
||||
setPage( getPage() + 1);
|
||||
};
|
||||
|
||||
void PageWidget::previousPage()
|
||||
{
|
||||
setPage( getPage() - 1 );
|
||||
};
|
||||
|
||||
void PageWidget::zoomIn()
|
||||
{
|
||||
m_zoomFactor += 0.1;
|
||||
updatePixmap();
|
||||
};
|
||||
|
||||
void PageWidget::zoomOut()
|
||||
{
|
||||
m_zoomFactor -= 0.1;
|
||||
updatePixmap();
|
||||
};
|
||||
|
||||
void PageWidget::setPage(int page)
|
||||
{
|
||||
if (m_doc)
|
||||
{
|
||||
m_currentPage = max(0, min( page, m_doc->getNumPages()));
|
||||
} else {
|
||||
m_currentPage = 0;
|
||||
}
|
||||
updatePixmap();
|
||||
};
|
||||
|
||||
void PageWidget::updatePixmap()
|
||||
{
|
||||
const double pageWidth = m_doc->getPageWidth (m_currentPage) * m_zoomFactor;
|
||||
const double pageHeight = m_doc->getPageHeight(m_currentPage) * m_zoomFactor;
|
||||
|
||||
// Pixels per point when the zoomFactor is 1.
|
||||
const float basePpp = QPaintDevice::x11AppDpiX() / 72.0;
|
||||
|
||||
const float ppp = basePpp * m_zoomFactor; // pixels per point
|
||||
|
||||
m_doc->displayPage(m_outputdev, m_currentPage, int(ppp * 72.0), 0, true);
|
||||
|
||||
resizeContents ( m_outputdev->getPixmap()->width ( ), m_outputdev->getPixmap()->height ( ));
|
||||
|
||||
viewport()->update();
|
||||
}
|
||||
}
|
||||
|
||||
// vim:ts=2:sw=2:tw=78:et
|
||||
|
|
|
@ -3,42 +3,65 @@
|
|||
|
||||
#include <qpixmap.h>
|
||||
#include <qwidget.h>
|
||||
#include <qscrollview.h>
|
||||
|
||||
class LinkAction;
|
||||
class PDFDoc;
|
||||
|
||||
class QOutputDevPixmap;
|
||||
|
||||
namespace KPDF
|
||||
{
|
||||
/**
|
||||
* Widget displaying a pixmap containing a PDF page and Links.
|
||||
*/
|
||||
class PageWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
/**
|
||||
* Widget displaying a pixmap containing a PDF page and Links.
|
||||
*/
|
||||
class PageWidget : public QScrollView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
enum ZoomMode { FitInWindow, FitWidth, FitVisible, FixedFactor };
|
||||
|
||||
public:
|
||||
PageWidget(QWidget* parent = 0, const char* name = 0);
|
||||
public:
|
||||
PageWidget(QWidget* parent = 0, const char* name = 0);
|
||||
|
||||
void setPixmap(const QPixmap&);
|
||||
void setPDFDocument(PDFDoc*);
|
||||
void setPixelsPerPoint(float);
|
||||
// void setLinks();
|
||||
void setPDFDocument(PDFDoc*);
|
||||
void setPixelsPerPoint(float);
|
||||
/* void setLinks(); */
|
||||
|
||||
void setPage(int pagenum);
|
||||
int getPage() { return m_currentPage; };
|
||||
|
||||
signals:
|
||||
void linkClicked(LinkAction*);
|
||||
public slots:
|
||||
void nextPage();
|
||||
void previousPage();
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent*);
|
||||
void mouseReleaseEvent(QMouseEvent*);
|
||||
void mouseMoveEvent(QMouseEvent*);
|
||||
void updatePixmap();
|
||||
|
||||
private:
|
||||
QPixmap m_pixmap;
|
||||
PDFDoc* m_doc;
|
||||
float m_ppp; // Pixels per point
|
||||
signals:
|
||||
void linkClicked(LinkAction*);
|
||||
|
||||
LinkAction* m_pressedAction;
|
||||
};
|
||||
protected:
|
||||
void contentsMousePressEvent(QMouseEvent*);
|
||||
void contentsMouseReleaseEvent(QMouseEvent*);
|
||||
void contentsMouseMoveEvent(QMouseEvent*);
|
||||
|
||||
virtual void drawContents ( QPainter *p, int, int, int, int );
|
||||
|
||||
private:
|
||||
|
||||
QOutputDevPixmap * m_outputdev;
|
||||
PDFDoc* m_doc;
|
||||
|
||||
float m_ppp; // Pixels per point
|
||||
float m_zoomFactor;
|
||||
ZoomMode m_zoomMode;
|
||||
|
||||
int m_currentPage;
|
||||
|
||||
LinkAction* m_pressedAction;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <kstdaction.h>
|
||||
#include <kparts/genericfactory.h>
|
||||
|
||||
#include "part.h"
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#include "GString.h"
|
||||
|
@ -23,9 +25,8 @@
|
|||
#include "XOutputDev.h"
|
||||
|
||||
// #include "kpdf_canvas.h"
|
||||
// #include "kpdf_pagewidget.h"
|
||||
#include "kpdf_pagewidget.h"
|
||||
|
||||
#include "part.h"
|
||||
|
||||
typedef KParts::GenericFactory<KPDF::Part> KPDFPartFactory;
|
||||
K_EXPORT_COMPONENT_FACTORY(libkpdfpart, KPDFPartFactory);
|
||||
|
@ -54,6 +55,8 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
|
|||
this, SLOT( pageClicked ( QListBoxItem * ) ));
|
||||
|
||||
m_outputDev = pdfpartview->outputdev;
|
||||
|
||||
|
||||
setWidget(pdfpartview);
|
||||
|
||||
// create our actions
|
||||
|
@ -65,18 +68,18 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
|
|||
m_fitToWidth = new KToggleAction(i18n("Fit to Page &Width"), 0,
|
||||
this, SLOT(slotFitToWidthToggled()),
|
||||
actionCollection(), "fit_to_width");
|
||||
KStdAction::zoomIn (this, SLOT(zoomIn()),
|
||||
KStdAction::zoomIn (m_outputDev, SLOT(zoomIn()),
|
||||
actionCollection(), "zoom_in");
|
||||
KStdAction::zoomOut (this, SLOT(zoomOut()),
|
||||
KStdAction::zoomOut (m_outputDev, SLOT(zoomOut()),
|
||||
actionCollection(), "zoom_out");
|
||||
|
||||
KStdAction::back (this, SLOT(back()),
|
||||
actionCollection(), "back");
|
||||
KStdAction::forward (this, SLOT(forward()),
|
||||
actionCollection(), "forward");
|
||||
KStdAction::prior (this, SLOT(displayPreviousPage()),
|
||||
KStdAction::prior (m_outputDev, SLOT(previousPage()),
|
||||
actionCollection(), "previous_page");
|
||||
KStdAction::next (this, SLOT(displayNextPage()),
|
||||
KStdAction::next (m_outputDev, SLOT(nextPage()),
|
||||
actionCollection(), "next_page" );
|
||||
|
||||
// set our XML-UI resource file
|
||||
|
@ -121,7 +124,7 @@ Part::openFile()
|
|||
|
||||
if (!m_doc->isOk())
|
||||
return false;
|
||||
|
||||
|
||||
// just for fun, set the status bar
|
||||
// emit setStatusBarText( QString::number( m_doc->getNumPages() ) );
|
||||
|
||||
|
@ -136,6 +139,8 @@ Part::openFile()
|
|||
pdfpartview->pagesListBox->update();
|
||||
|
||||
displayPage(1);
|
||||
|
||||
m_outputDev->setPDFDocument(m_doc);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -143,25 +148,6 @@ Part::openFile()
|
|||
void
|
||||
Part::displayPage(int pageNumber, float /*zoomFactor*/)
|
||||
{
|
||||
kdDebug() << "display page" << endl;
|
||||
kdDebug() << "page : " << pageNumber << endl;
|
||||
kdDebug() << "zoom factor : " << m_zoomFactor << endl;
|
||||
|
||||
Page * p = m_doc->getCatalog()->getPage(pageNumber);
|
||||
|
||||
kdDebug() << "metadata stream : " << endl;
|
||||
char * md = new char[4096];
|
||||
|
||||
if (p->getMetadata())
|
||||
{
|
||||
while(p->getMetadata()->getLine(md, 4096) != NULL)
|
||||
{
|
||||
kdDebug() << md << endl;
|
||||
}
|
||||
}
|
||||
|
||||
kdDebug() << "------------" << endl;
|
||||
|
||||
if (pageNumber <= 0 || pageNumber > m_doc->getNumPages())
|
||||
return;
|
||||
|
||||
|
@ -172,48 +158,47 @@ Part::displayPage(int pageNumber, float /*zoomFactor*/)
|
|||
const float basePpp = QPaintDevice::x11AppDpiX() / 72.0;
|
||||
|
||||
switch (m_zoomMode)
|
||||
{
|
||||
case FitWidth:
|
||||
{
|
||||
const double pageAR = pageWidth/pageHeight; // Aspect ratio
|
||||
{
|
||||
case FitWidth:
|
||||
{
|
||||
const double pageAR = pageWidth/pageHeight; // Aspect ratio
|
||||
|
||||
const int canvasWidth = m_outputDev->contentsRect().width();
|
||||
const int canvasHeight = m_outputDev->contentsRect().height();
|
||||
const int scrollBarWidth = m_outputDev->verticalScrollBar()->width();
|
||||
const int canvasWidth = m_outputDev->contentsRect().width();
|
||||
const int canvasHeight = m_outputDev->contentsRect().height();
|
||||
const int scrollBarWidth = m_outputDev->verticalScrollBar()->width();
|
||||
|
||||
// Calculate the height so that the page fits the viewport width
|
||||
// assuming that we need a vertical scrollbar.
|
||||
float height = float(canvasWidth - scrollBarWidth) / pageAR;
|
||||
// Calculate the height so that the page fits the viewport width
|
||||
// assuming that we need a vertical scrollbar.
|
||||
float height = float(canvasWidth - scrollBarWidth) / pageAR;
|
||||
|
||||
// If the vertical scrollbar wasn't needed after all, calculate the page
|
||||
// size so that the page fits the viewport width without the scrollbar.
|
||||
if (ceil(height) <= canvasHeight)
|
||||
{
|
||||
height = float(canvasWidth) / pageAR;
|
||||
// If the vertical scrollbar wasn't needed after all, calculate the page
|
||||
// size so that the page fits the viewport width without the scrollbar.
|
||||
if (ceil(height) <= canvasHeight)
|
||||
{
|
||||
height = float(canvasWidth) / pageAR;
|
||||
|
||||
// Handle the rare case that enlarging the page resulted in the need of
|
||||
// a vertical scrollbar. We can fit the page to the viewport height in
|
||||
// this case.
|
||||
if (ceil(height) > canvasHeight)
|
||||
height = float(canvasHeight) * pageAR;
|
||||
}
|
||||
|
||||
m_zoomFactor = (height / pageHeight) / basePpp;
|
||||
break;
|
||||
}
|
||||
case FixedFactor:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// Handle the rare case that enlarging the page resulted in the need of
|
||||
// a vertical scrollbar. We can fit the page to the viewport height in
|
||||
// this case.
|
||||
if (ceil(height) > canvasHeight)
|
||||
height = float(canvasHeight) * pageAR;
|
||||
}
|
||||
|
||||
m_zoomFactor = (height / pageHeight) / basePpp;
|
||||
break;
|
||||
}
|
||||
case FixedFactor:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const float ppp = basePpp * m_zoomFactor; // pixels per point
|
||||
|
||||
m_doc->displayPage(m_outputDev, pageNumber, int(m_zoomFactor * ppp * 72.0), 0, true);
|
||||
// m_doc->displayPage(m_outputDev, pageNumber, int(m_zoomFactor * ppp * 72.0), 0, true);
|
||||
|
||||
m_outputDev->show();
|
||||
// m_outputDev->show();
|
||||
|
||||
m_currentPage = pageNumber;
|
||||
// m_currentPage = pageNumber;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -434,8 +419,7 @@ Part::redrawPage()
|
|||
void
|
||||
Part::pageClicked ( QListBoxItem * qbi )
|
||||
{
|
||||
m_currentPage = pdfpartview->pagesListBox->index(qbi);
|
||||
update();
|
||||
m_outputDev->setPage(pdfpartview->pagesListBox->index(qbi) + 1);
|
||||
}
|
||||
|
||||
BrowserExtension::BrowserExtension(Part* parent)
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace KPDF
|
|||
|
||||
private:
|
||||
PDFDoc* m_doc;
|
||||
QOutputDev* m_outputDev;
|
||||
PageWidget* m_outputDev;
|
||||
PDFPartView * pdfpartview;
|
||||
|
||||
KToggleAction* m_fitToWidth;
|
||||
|
|
81
kpdf/part.ui
Normal file
81
kpdf/part.ui
Normal file
|
@ -0,0 +1,81 @@
|
|||
<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
|
||||
<class>PDFPartView</class>
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>PDFPartView</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>623</width>
|
||||
<height>381</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>PDFPartView</string>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QListBox">
|
||||
<property name="name">
|
||||
<cstring>pagesListBox</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>1</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>32767</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="variableWidth">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KPDF::PageWidget">
|
||||
<property name="name">
|
||||
<cstring>outputdev</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>PageWidget</class>
|
||||
<header location="global">/home/oelewapperke/dev/kde/kdenonbeta/kpdf/kpdf/kpdf_pagewidget.h</header>
|
||||
<sizehint>
|
||||
<width>-1</width>
|
||||
<height>-1</height>
|
||||
</sizehint>
|
||||
<container>0</container>
|
||||
<sizepolicy>
|
||||
<hordata>7</hordata>
|
||||
<verdata>7</verdata>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<pixmap>image0</pixmap>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<images>
|
||||
<image name="image0">
|
||||
<data format="XPM.GZ" length="4462">789c9d97c76e24490e86effd1442f3d65870d2451a0ce6206f5adeb4cc620f8c34f2553225b5a4c1befb46927fe6a1d4c0ccac4287fa8a0c26834193f5dbb785b3fd9d856fbf7d799ec9ecba5ea8afe469e15bf3727ffffeeffffcf1e797af49b2d0ffc7d142f2f55f5fbe1ecc16ea85dde9a4ed81290045faa77ca49cf4ab67ba1e3953969173651ab9d4fdf1c8a27c3872ad7c3c72d3b32c2a67c3f3444636fbef23eb7e590267e68fcc4656395d8dacf6d938ef97eaef289781cddebdb2846fccff44b989ba58e3411f3dc75158e6df1d3889539517ca49bf54fe43398d1dec4f46567f685fd9c539f43fc025f80c1c3ce8d93f28e77185f8bf0c6cfae4c0b5f9c3c6e5c0542a4b5876fe13708df39d2bd7716372aa8c93c4e4723bb2f977aadc26ceec4bdb7310e6b0bfab9c2445ecd49f1370694cebca65d260ffa6711a41aef14d24e94cee6be3348e0ae5e9c8765f07ca3e8db17f0f9c825794eb3489351fe9bb7217e4969f29388bd51ee9fda5715a19730696b852fea95c6471647ca95cf64bcf43e0cef4657b647bfe6acf213d6bb32f9a9f5992b5a64f9a8f990b6cf9ecc15d6cf9acf6b2da55a8a75cb973dee4b2d1b38b5c05de02434e87e01aacfb351df5bebddea74b5c67f9c795711ea15e357e2ecde358fb87efc0a867df8cac728a074e62e527706afb59f3cf6583be5c28bb3c35f693812d1fbdc6dbe57966fec932d899ffa4f7e38adca17e34beaeca4b9c271a18f1d5fc739257b0d70d9c68be7bed7fcee7827ab91cd8e4740cf6b19d4ffb87ab07b9bf516e72d4a3ac821b9cef6e60d84f47367ded2fae1d9f7704f6163f79000ffde27660f387ed3c5dbf54dfeebb0bf6acbe6b706bfa5ef32f8f8b18f5bf0f463f20edb77956a4e68fbc80b3c4facd163847be6bfde72ec86dbeac82715fbc0286be683cf3bc081d44f7df80d344fb0b6b7de64581fb916765297263d6fccd9b7ee97e566e8b06cfdb1f59cf2bda2f8bbc2c11df0c5c41aefdb328ca22b1feb0012eedbce24736f91b18fb796d64eb87cb60817dcdafb07d906bfd14d22f659d8785ef97b2f6d7b2df6ef1d6fb2babaac6f92e8c25b27ecc1f239b7f3a5fca5a8678ea7c2d9bc0e6ef1238b3fca2c7814d5f4cbf9334b5f833384bed3c7a5f5514f4adbe2ec07962e7590457f06f6f649b977afe2a16f42f5e070bfc591e18f7a5f1a812a9e0df39d827da4fbd8c6ccfd7785569bf945f953371a9d5a3de67950bfa2d75c63eb2fb15bdcfaaf011e6c7263846bf8f4636f91618f3c7d3c0f047fb69550efab2074e12bd6fd27957553ec33c5b043bcc7f9d0795f818fdb501a3df8ae673e507ff69021eea37063bc45ffb73550736ff36c0a84f3e0317a86f8b5f139e6ffe1f821de6d9127898ff3be00a7c3ab2cd03e3d697560ff40016e47b3bb2e96bbd559d8f32bbff4b7065f193042c98873acf240af6adbf3c83c5f2954bb0c7bcd77c107d81d2fdebc63e33ff640aaecc9e1c8151df5c803dfaadc64b52dfa03ed64636ffb4ff4b2867f453ede7227586fcd3f9264ded91fffafe236d5da37fe83c91ceb7b9e5b7f6731ff92ed7f747d6fbf7e185cf58347e3e6932e47b3430fa893edf87d795c2fc3f003b67f5f902cec17abfde0dfa3c053b3c5ffb832fc2eb8fddcf233887fc195c801f46b6f3cdc02558fba72f7d2d1a7f7e321ee58fe0cad86bbff24dd3e2fe74fef836b0c6eb60d62fa6bf5e07b3419f853dd7dc70fb8bd5f1255fd90ed30f9f3c5ff30ddff21ddff384a7fcc08ffcc4cf61cdf8855ff9e79c7e1db4dff89d3f7891977899577895d7789d377893b7f83b6fcfe937bc13b477798ff7f9800ff928ac633ee11f7cca6761d7f99c7e1b3cb908da11c7413be1943376e153cc39175c72f549ff9e17c31744429e6a6aa8a58e2ee98aaee9866e7f617fc24b7417a4f734a1293dd0233dd133cd8285177aa5f9f3b63ca5377aa78f607b919668995682e62aadd17ab0b1419b9ff41f682b48bed336edd02eed05ed7d5ea3033a0cdf1ed1f127fd273ae123fa41a774a6b685cee982228a837e42e927fd47caf8985c38651eb40b2ac38e4a5842658a97fab33fd248cb87d2c9a55cc9b5dcc82d1fc99ddccb44a6f230af2f8ff224cf417f262ff22a3fe54ddee543166549966545567f617f4dd66523dc6b2c9bb225df655b7682f692ecca9eeccfe97772c09b722847722c27c1f3eb70f66bf9116c9fca999ccbc59cfe25bf4a143a5ef8992561324a78bd92522acf9ebc78efe7cf7b153276db37bef59dbff457fedadff85b7f27abfede4ffcd4cf9ff76faeff4fffefeff8c7f5fedfdfbffc0fa355c495</data>
|
||||
</image>
|
||||
</images>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">kpdf_pagewidget.h</include>
|
||||
</includes>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
<includehints>
|
||||
<includehint>kpdf_pagewidget.h</includehint>
|
||||
</includehints>
|
||||
</UI>
|
11
kpdf/utils.h
Normal file
11
kpdf/utils.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
template<class T>
|
||||
inline T min(T a, T b)
|
||||
{
|
||||
return ( a < b ? a : b );
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline T max(T a, T b)
|
||||
{
|
||||
return ( a > b ? a : b );
|
||||
};
|
Loading…
Reference in a new issue