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 @@ ...@@ -2,7 +2,7 @@
INCLUDES = -I.. -I$(top_srcdir)/kpdf/goo -I$(top_srcdir)/kpdf/xpdf $(all_includes) INCLUDES = -I.. -I$(top_srcdir)/kpdf/goo -I$(top_srcdir)/kpdf/xpdf $(all_includes)
# these are the headers for your project # 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) # let automoc handle all of the meta source files (moc)
METASOURCES = AUTO METASOURCES = AUTO
...@@ -30,7 +30,7 @@ kpdf_LDADD = $(LIB_KPARTS) ...@@ -30,7 +30,7 @@ kpdf_LDADD = $(LIB_KPARTS)
kpdf_COMPILE_FIRST = ../aconf.h kpdf_COMPILE_FIRST = ../aconf.h
EXTRA_DIST = kpdf.desktop 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 # this is where the shell's XML-GUI resource file goes
shellrcdir = $(kde_datadir)/kpdf shellrcdir = $(kde_datadir)/kpdf
...@@ -42,7 +42,7 @@ shellrc_DATA = kpdf_shell.rc ...@@ -42,7 +42,7 @@ shellrc_DATA = kpdf_shell.rc
kde_module_LTLIBRARIES = libkpdfpart.la kde_module_LTLIBRARIES = libkpdfpart.la
# the Part's source, library search path, and link libraries # 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_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
libkpdfpart_la_LIBADD = ../xpdf/libxpdf.la $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT) libkpdfpart_la_LIBADD = ../xpdf/libxpdf.la $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT)
libkpdfpart_la_COMPILE_FIRST = ../aconf.h libkpdfpart_la_COMPILE_FIRST = ../aconf.h
......
This diff is collapsed.
...@@ -17,11 +17,10 @@ ...@@ -17,11 +17,10 @@
#include "aconf.h" #include "aconf.h"
#include <stddef.h> #include <stddef.h>
#include <qscrollview.h>
#include <qmemarray.h>
class Object; class Object;
#include <qobject.h>
#include "config.h" #include "config.h"
#include "CharTypes.h" #include "CharTypes.h"
#include "GlobalParams.h" #include "GlobalParams.h"
...@@ -40,7 +39,6 @@ class DisplayFontParam; ...@@ -40,7 +39,6 @@ class DisplayFontParam;
class UnicodeMap; class UnicodeMap;
class CharCodeToUnicode; class CharCodeToUnicode;
class QPainter; class QPainter;
class QPixmap; class QPixmap;
class QPointArray; class QPointArray;
...@@ -61,13 +59,13 @@ typedef double fp_t; ...@@ -61,13 +59,13 @@ typedef double fp_t;
// XOutputDev // XOutputDev
//------------------------------------------------------------------------ //------------------------------------------------------------------------
class QOutputDev : public QScrollView, public OutputDev { class QOutputDev : public QObject, public OutputDev {
Q_OBJECT Q_OBJECT
public: public:
// Constructor. // Constructor.
QOutputDev( QWidget *parent = 0, const char *name = 0, int flags = 0 ); QOutputDev( QPainter * p = 0 );
// Destructor. // Destructor.
virtual ~QOutputDev(); virtual ~QOutputDev();
...@@ -84,7 +82,7 @@ public: ...@@ -84,7 +82,7 @@ public:
// Does this device use beginType3Char/endType3Char? Otherwise, // Does this device use beginType3Char/endType3Char? Otherwise,
// text in Type 3 fonts will be drawn with drawChar/drawString. // text in Type 3 fonts will be drawn with drawChar/drawString.
virtual GBool interpretType3Chars() { return gFalse; } virtual GBool interpretType3Chars() { return gFalse; }
// Does this device need non-text content? // Does this device need non-text content?
virtual GBool needNonText() { return gFalse; } virtual GBool needNonText() { return gFalse; }
...@@ -150,7 +148,7 @@ public: ...@@ -150,7 +148,7 @@ public:
// of page. If found, sets the text bounding rectange and returns // of page. If found, sets the text bounding rectange and returns
// true; otherwise returns false. // true; otherwise returns false.
GBool findText ( Unicode *s, int len, GBool top, GBool bottom, int *xMin, int *yMin, int *xMax, int *yMax ); GBool findText ( Unicode *s, int len, GBool top, GBool bottom, int *xMin, int *yMin, int *xMax, int *yMax );
//----- special QT access //----- 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, int &l, int &t, int &w, int &h, bool top = 0, bool bottom = 0 );
...@@ -161,15 +159,10 @@ public: ...@@ -161,15 +159,10 @@ public:
QString getText ( const QRect &r ); QString getText ( const QRect &r );
protected: protected:
virtual void drawContents ( QPainter *p, int, int, int, int );
private:
QPixmap *m_pixmap; // pixmap to draw into
QPainter *m_painter; QPainter *m_painter;
TextPage *m_text; // text from the current page 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 ); QFont matchFont ( GfxFont *, fp_t m11, fp_t m12, fp_t m21, fp_t m22 );
void updateLineAttrs ( GfxState *state, GBool updateDash ); void updateLineAttrs ( GfxState *state, GBool updateDash );
......
This diff is collapsed.
...@@ -32,39 +32,13 @@ ...@@ -32,39 +32,13 @@
#pragma interface #pragma interface
#endif #endif
#include "aconf.h" #include "QOutputDev.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; typedef double fp_t;
class QOutputDevPixmap : public OutputDev { class QOutputDevPixmap : public QOutputDev {
Q_OBJECT
public: public:
// Constructor. // Constructor.
...@@ -73,7 +47,7 @@ public: ...@@ -73,7 +47,7 @@ public:
// Destructor. // Destructor.
virtual ~QOutputDevPixmap(); virtual ~QOutputDevPixmap();
//---- get info about output device //V---- get info about output device
// Does this device use upside-down coordinates? // Does this device use upside-down coordinates?
// (Upside-down means (0,0) is the top left corner of the page.) // (Upside-down means (0,0) is the top left corner of the page.)
...@@ -94,90 +68,14 @@ public: ...@@ -94,90 +68,14 @@ public:
// Start a page. // Start a page.
virtual void startPage(int pageNum, GfxState *state); virtual void startPage(int pageNum, GfxState *state);
// End a page. // End a page
virtual void endPage(); 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: public:
QPixmap * getPixmap() const { return m_pixmap; }; QPixmap * getPixmap() const { return m_pixmap; };
private: private:
QPixmap * m_pixmap; // pixmap to draw into 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 #endif // QOUTPUTDEVPIXMAP
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <kconfig.h> #include <kconfig.h>
#include <kparts/genericfactory.h> #include <kparts/genericfactory.h>
#include <kurldrag.h> #include <kurldrag.h>
#include <kinputdialog.h> #include <qinputdialog.h>
#include "part.h" #include "part.h"
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "GlobalParams.h" #include "GlobalParams.h"
#include "PDFDoc.h" #include "PDFDoc.h"
#include "XOutputDev.h" #include "XOutputDev.h"
#include "QOutputDevKPrinter.h"
// #include "kpdf_canvas.h" // #include "kpdf_canvas.h"
#include "kpdf_pagewidget.h" #include "kpdf_pagewidget.h"
...@@ -88,6 +89,9 @@ Part::Part(QWidget *parentWidget, const char *widgetName, ...@@ -88,6 +89,9 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
KStdAction::forward (this, SLOT(forward()), KStdAction::forward (this, SLOT(forward()),
actionCollection(), "forward"); actionCollection(), "forward");
KStdAction::print( this, SLOT( print() ), actionCollection() );
KStdAction::printPreview( this, SLOT( printPreview() ), actionCollection() );
m_prevPage = KStdAction::prior(this, SLOT(slotPreviousPage()), m_prevPage = KStdAction::prior(this, SLOT(slotPreviousPage()),
actionCollection(), "previous_page"); actionCollection(), "previous_page");
m_prevPage->setWhatsThis( i18n( "Moves to the previous page of the document" ) ); m_prevPage->setWhatsThis( i18n( "Moves to the previous page of the document" ) );
...@@ -162,8 +166,8 @@ void Part::slotGoToPage() ...@@ -162,8 +166,8 @@ void Part::slotGoToPage()
if ( m_doc ) if ( m_doc )
{ {
bool ok = false; bool ok = false;
int num = KInputDialog::getInteger(i18n("Go to Page"), i18n("Page:"), m_currentPage, int num = QInputDialog::getInteger(i18n("Go to Page"), i18n("Page:"), m_currentPage,
1, m_doc->getNumPages(), 1, 10, &ok/*, _part->widget()*/); 1, m_doc->getNumPages(), 1, &ok/*, _part->widget()*/);
if (ok) if (ok)
goToPage( num ); goToPage( num );
} }
...@@ -510,24 +514,12 @@ Part::print() ...@@ -510,24 +514,12 @@ Part::print()
KPrinter printer; KPrinter printer;
printer.setPageSelection(KPrinter::ApplicationSide); printer.setPageSelection(KPrinter::ApplicationSide);
printer.setCurrentPage(m_currentPage);
printer.setMinMax(1, m_doc->getNumPages()); printer.setMinMax(1, m_doc->getNumPages());
printer.setCurrentPage(m_currentPage+1);
if (printer.setup(widget())) if (printer.setup(widget()))
{ {
/* doPrint( printer );
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
;
}
*/
} }
} }
...@@ -663,4 +655,24 @@ BrowserExtension::print() ...@@ -663,4 +655,24 @@ BrowserExtension::print()
static_cast<Part*>(parent())->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 // vim:ts=2:sw=2:tw=78:et
...@@ -27,6 +27,7 @@ class PDFDoc; ...@@ -27,6 +27,7 @@ class PDFDoc;
class XOutputDev; class XOutputDev;
class PDFPartView; class PDFPartView;
class KPrinter;
namespace KPDF namespace KPDF
{ {
...@@ -66,14 +67,16 @@ namespace KPDF ...@@ -66,14 +67,16 @@ namespace KPDF
bool closeURL(); bool closeURL();
void print();
void displayPage(int pageNumber, float zoomFactor = 1.0); void displayPage(int pageNumber, float zoomFactor = 1.0);
void displayDestination(LinkDest*); void displayDestination(LinkDest*);
void updateActionPage(); void updateActionPage();
void setFullScreen( bool fs ); void setFullScreen( bool fs );
PageWidget* pageWidget() const {return m_outputDev;} PageWidget* pageWidget() const {return m_outputDev;}
public slots:
void print();
protected: protected:
/** /**
* This must be implemented by each part * This must be implemented by each part
...@@ -87,6 +90,7 @@ namespace KPDF ...@@ -87,6 +90,7 @@ namespace KPDF
bool previousPage(); bool previousPage();
void updateAction(); void updateAction();
void goToPage( int page ); void goToPage( int page );
void doPrint( KPrinter& printer );
protected slots: protected slots:
void find() { /* stub */ }; void find() { /* stub */ };
...@@ -102,6 +106,7 @@ namespace KPDF ...@@ -102,6 +106,7 @@ namespace KPDF
void slotGoToPage(); void slotGoToPage();
void displayNextPage(); void displayNextPage();
void displayPreviousPage(); void displayPreviousPage();
void printPreview();
void executeAction(LinkAction*); void executeAction(LinkAction*);
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kpdf_part" version="11"> <kpartgui name="kpdf_part" version="11">
<MenuBar> <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> <Menu name="edit"><text>&amp;Edit</text>
<Action name="find"/> <Action name="find"/>
<Action name="find_next"/> <Action name="find_next"/>
......
...@@ -176,16 +176,15 @@ Shell::fileOpen() ...@@ -176,16 +176,15 @@ Shell::fileOpen()
void void
Shell::fileSaveAs() Shell::fileSaveAs()
{ {
KURL saveURL = KFileDialog::getSaveURL( KURL saveURL = KFileDialog::getSaveURL(
m_part->url().isLocalFile() m_part->url().isLocalFile()
? m_part->url().url() ? m_part->url().url()
: m_part->url().fileName(), : m_part->url().fileName(),
QString::null, QString::null,
m_part->widget(), m_part->widget(),
QString::null ); QString::null );
if( !KIO::NetAccess::upload( m_part->url().path(), if( !KIO::NetAccess::upload( m_part->url().path(),
saveURL, saveURL ) )
static_cast<QWidget*>( 0 ) ) )
; // TODO: Proper error dialog ; // 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