Commit 5b35aa8b authored by Christophe Devriese's avatar Christophe Devriese

dded printing support (bug 65017)

-> we did not add or change any i18n() strings
-> ------- Additional Comment #1 From Stephan Kulow 2003-09-27 12:38 -------
that's more a blocker bug than a wishlist ;(

svn path=/trunk/kdegraphics/kpdf/; revision=276107
parent 884350d8
......@@ -2,7 +2,7 @@
INCLUDES = -I.. -I$(top_srcdir)/kpdf/goo -I$(top_srcdir)/kpdf/xpdf $(all_includes)
# these are the headers for your project
noinst_HEADERS = kpdf_shell.h kpdf_part.h kpdf_canvas.h kpdf_pagewidget.h QOutputDev.h
noinst_HEADERS = kpdf_shell.h kpdf_part.h kpdf_canvas.h kpdf_pagewidget.h QOutputDevPixmap.h QOutputDev.h
# let automoc handle all of the meta source files (moc)
METASOURCES = AUTO
......@@ -30,7 +30,7 @@ kpdf_LDADD = $(LIB_KPARTS)
kpdf_COMPILE_FIRST = ../aconf.h
EXTRA_DIST = kpdf.desktop
xdg_apps_DATA = kpdf.desktop
#xdg_apps_DATA = kpdf.desktop
# this is where the shell's XML-GUI resource file goes
shellrcdir = $(kde_datadir)/kpdf
......@@ -42,7 +42,7 @@ shellrc_DATA = kpdf_shell.rc
kde_module_LTLIBRARIES = libkpdfpart.la
# the Part's source, library search path, and link libraries
libkpdfpart_la_SOURCES = QOutputDev.cpp QOutputDevPixmap.cpp kpdf_canvas.cpp kpdf_part.cpp kpdf_pagewidget.cc part.ui
libkpdfpart_la_SOURCES = QOutputDev.cpp QOutputDevPixmap.cpp QOutputDevKPrinter.cpp kpdf_canvas.cpp kpdf_part.cpp kpdf_pagewidget.cc part.ui
libkpdfpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
libkpdfpart_la_LIBADD = ../xpdf/libxpdf.la $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT)
libkpdfpart_la_COMPILE_FIRST = ../aconf.h
......
This diff is collapsed.
......@@ -17,11 +17,10 @@
#include "aconf.h"
#include <stddef.h>
#include <qscrollview.h>
#include <qmemarray.h>
class Object;
#include <qobject.h>
#include "config.h"
#include "CharTypes.h"
#include "GlobalParams.h"
......@@ -40,7 +39,6 @@ class DisplayFontParam;
class UnicodeMap;
class CharCodeToUnicode;
class QPainter;
class QPixmap;
class QPointArray;
......@@ -61,13 +59,13 @@ typedef double fp_t;
// XOutputDev
//------------------------------------------------------------------------
class QOutputDev : public QScrollView, public OutputDev {
class QOutputDev : public QObject, public OutputDev {
Q_OBJECT
public:
// Constructor.
QOutputDev( QWidget *parent = 0, const char *name = 0, int flags = 0 );
QOutputDev( QPainter * p = 0 );
// Destructor.
virtual ~QOutputDev();
......@@ -84,7 +82,7 @@ public:
// 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; }
......@@ -150,7 +148,7 @@ public:
// 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 );
......@@ -161,15 +159,10 @@ public:
QString getText ( const QRect &r );
protected:
virtual void drawContents ( QPainter *p, int, int, int, int );
private:
QPixmap *m_pixmap; // pixmap to draw into
QPainter *m_painter;
TextPage *m_text; // text from the current page
private:
private:
QFont matchFont ( GfxFont *, fp_t m11, fp_t m12, fp_t m21, fp_t m22 );
void updateLineAttrs ( GfxState *state, GBool updateDash );
......
This diff is collapsed.
......@@ -32,39 +32,13 @@
#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>
#include "QOutputDev.h"
typedef double fp_t;
class QOutputDevPixmap : public OutputDev {
class QOutputDevPixmap : public QOutputDev {
Q_OBJECT
public:
// Constructor.
......@@ -73,7 +47,7 @@ public:
// Destructor.
virtual ~QOutputDevPixmap();
//---- get info about output device
//V---- 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.)
......@@ -94,90 +68,14 @@ public:
// Start a page.
virtual void startPage(int pageNum, GfxState *state);
// End a page.
// 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() const { 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, QMemArray<int> &lengths );
int convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArray &points );
};
#endif // QOUTPUTDEVPIXMAP
......@@ -15,7 +15,7 @@
#include <kconfig.h>
#include <kparts/genericfactory.h>
#include <kurldrag.h>
#include <kinputdialog.h>
#include <qinputdialog.h>
#include "part.h"
......@@ -25,6 +25,7 @@
#include "GlobalParams.h"
#include "PDFDoc.h"
#include "XOutputDev.h"
#include "QOutputDevKPrinter.h"
// #include "kpdf_canvas.h"
#include "kpdf_pagewidget.h"
......@@ -88,6 +89,9 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
KStdAction::forward (this, SLOT(forward()),
actionCollection(), "forward");
KStdAction::print( this, SLOT( print() ), actionCollection() );
KStdAction::printPreview( this, SLOT( printPreview() ), actionCollection() );
m_prevPage = KStdAction::prior(this, SLOT(slotPreviousPage()),
actionCollection(), "previous_page");
m_prevPage->setWhatsThis( i18n( "Moves to the previous page of the document" ) );
......@@ -162,8 +166,8 @@ void Part::slotGoToPage()
if ( m_doc )
{
bool ok = false;
int num = KInputDialog::getInteger(i18n("Go to Page"), i18n("Page:"), m_currentPage,
1, m_doc->getNumPages(), 1, 10, &ok/*, _part->widget()*/);
int num = QInputDialog::getInteger(i18n("Go to Page"), i18n("Page:"), m_currentPage,
1, m_doc->getNumPages(), 1, &ok/*, _part->widget()*/);
if (ok)
goToPage( num );
}
......@@ -510,24 +514,12 @@ Part::print()
KPrinter printer;
printer.setPageSelection(KPrinter::ApplicationSide);
printer.setCurrentPage(m_currentPage);
printer.setMinMax(1, m_doc->getNumPages());
printer.setCurrentPage(m_currentPage+1);
if (printer.setup(widget()))
{
/*
KTempFile tf(QString::null, ".ps");
if (tf.status() == 0)
{
savePages(tf.name(), printer.pageList());
printer.printFiles(QStringList( tf.name() ), true);
}
else
{
// TODO: Proper error handling
;
}
*/
doPrint( printer );
}
}
......@@ -663,4 +655,24 @@ BrowserExtension::print()
static_cast<Part*>(parent())->print();
}
void Part::printPreview()
{
KPrinter printer;
printer.setPreviewOnly( true );
doPrint( printer );
}
void Part::doPrint( KPrinter& printer )
{
QPainter painter( &printer );
QOutputDevKPrinter printdev( painter, printer );
QValueList<int> pages = printer.pageList();
for ( QValueList<int>::ConstIterator i = pages.begin(); i != pages.end();)
{
m_doc->displayPage( &printdev, *i, printer.resolution(), 0, true );
if ( ++i != pages.end() )
printer.newPage();
}
}
// vim:ts=2:sw=2:tw=78:et
......@@ -27,6 +27,7 @@ class PDFDoc;
class XOutputDev;
class PDFPartView;
class KPrinter;
namespace KPDF
{
......@@ -66,14 +67,16 @@ namespace KPDF
bool closeURL();
void print();
void displayPage(int pageNumber, float zoomFactor = 1.0);
void displayDestination(LinkDest*);
void updateActionPage();
void setFullScreen( bool fs );
PageWidget* pageWidget() const {return m_outputDev;}
public slots:
void print();
protected:
/**
* This must be implemented by each part
......@@ -87,6 +90,7 @@ namespace KPDF
bool previousPage();
void updateAction();
void goToPage( int page );
void doPrint( KPrinter& printer );
protected slots:
void find() { /* stub */ };
......@@ -102,6 +106,7 @@ namespace KPDF
void slotGoToPage();
void displayNextPage();
void displayPreviousPage();
void printPreview();
void executeAction(LinkAction*);
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kpdf_part" version="11">
<MenuBar>
<Menu name="file"><text>&amp;File</text>
<Action name="file_print"/>
<Action name="file_print_preview"/>
</Menu>
<Menu name="edit"><text>&amp;Edit</text>
<Action name="find"/>
<Action name="find_next"/>
......
......@@ -176,16 +176,15 @@ Shell::fileOpen()
void
Shell::fileSaveAs()
{
KURL saveURL = KFileDialog::getSaveURL(
m_part->url().isLocalFile()
? m_part->url().url()
: m_part->url().fileName(),
QString::null,
m_part->widget(),
KURL saveURL = KFileDialog::getSaveURL(
m_part->url().isLocalFile()
? m_part->url().url()
: m_part->url().fileName(),
QString::null,
m_part->widget(),
QString::null );
if( !KIO::NetAccess::upload( m_part->url().path(),
saveURL,
static_cast<QWidget*>( 0 ) ) )
saveURL ) )
; // TODO: Proper error dialog
}
......
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