From 30f135838d5e3c14d9cca4cda6a48d1a3651aba0 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 12 Oct 2004 11:08:09 +0000 Subject: [PATCH] Adding dcop functions to gotopage, get # pages and open document (only given the full path) svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=353886 --- kpdf/Makefile.am | 2 +- kpdf/TODO | 1 + kpdf/kpdf_dcop.h | 25 +++++++++++++++++++++++++ kpdf/kpdf_part.cpp | 19 ++++++++++++++++++- kpdf/kpdf_part.h | 8 +++++++- 5 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 kpdf/kpdf_dcop.h diff --git a/kpdf/Makefile.am b/kpdf/Makefile.am index 87d254e96..132b720dc 100644 --- a/kpdf/Makefile.am +++ b/kpdf/Makefile.am @@ -38,7 +38,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 QOutputDevKPrinter.cpp kpdf_part.cpp pixmapwidget.cpp pageview.cpp thumbnaillist.cpp kpdf_error.cpp xpdf_errors.cpp thumbnailgenerator.cpp document.cpp page.cpp searchwidget.cpp toc.cpp +libkpdfpart_la_SOURCES = QOutputDev.cpp QOutputDevKPrinter.cpp kpdf_part.cpp pixmapwidget.cpp pageview.cpp thumbnaillist.cpp kpdf_error.cpp xpdf_errors.cpp thumbnailgenerator.cpp document.cpp page.cpp searchwidget.cpp toc.cpp kpdf_dcop.skel libkpdfpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) libkpdfpart_la_LIBADD = ../xpdf/libxpdf.la $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT) $(LIB_KUTILS) -lm diff --git a/kpdf/TODO b/kpdf/TODO index 57095af5c..5d1d8e0ea 100644 --- a/kpdf/TODO +++ b/kpdf/TODO @@ -34,6 +34,7 @@ Porting / In progress on the branch (first item comes first): -> pageview: fix keys/mouse in single/continous modes Done (newest feature comes firts): +-> ADD: Some dcop functions (goToPage, openDocument and give # of pages) (Albert) -> MRG: link following ('actionMovie' kind is missing) -> ADD: text selection (rectangular blocks) in selection mode -> ADD: autoscroll page with Shift+Up/Dn keys (exact konqueror's behavior) diff --git a/kpdf/kpdf_dcop.h b/kpdf/kpdf_dcop.h new file mode 100644 index 000000000..95928c9f6 --- /dev/null +++ b/kpdf/kpdf_dcop.h @@ -0,0 +1,25 @@ +/*************************************************************************** + * Copyright (C) 2004 by Albert Astals Cid * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#ifndef MY_INTERFACE_H +#define MY_INTERFACE_H + +#include +#include + +class kpdf_dcop : virtual public DCOPObject +{ +K_DCOP + k_dcop: + virtual ASYNC goToPage(uint page) = 0; + virtual ASYNC openDocument(KURL doc) = 0; + virtual uint pages() = 0; +}; + +#endif diff --git a/kpdf/kpdf_part.cpp b/kpdf/kpdf_part.cpp index 3ab47baf8..b30c5651e 100644 --- a/kpdf/kpdf_part.cpp +++ b/kpdf/kpdf_part.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -66,7 +67,7 @@ unsigned int Part::m_count = 0; Part::Part(QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name, const QStringList & /*args*/ ) - : KParts::ReadOnlyPart(parent, name) + : DCOPObject("kpdf"), KParts::ReadOnlyPart(parent, name) { // create browser extension (for printing when embedded into browser) new BrowserExtension(this); @@ -204,6 +205,22 @@ Part::~Part() delete globalParams; } +void Part::goToPage(uint i) +{ + if (i <= document->pages()) + document->slotSetCurrentPage( i - 1 ); +} + +void Part::openDocument(KURL doc) +{ + openURL(doc); +} + +uint Part::pages() +{ + return document->pages(); +} + //this don't go anywhere but is required by genericfactory.h KAboutData* Part::createAboutData() { diff --git a/kpdf/kpdf_part.h b/kpdf/kpdf_part.h index e2c0366c7..c5fdf60cd 100644 --- a/kpdf/kpdf_part.h +++ b/kpdf/kpdf_part.h @@ -19,6 +19,8 @@ #include #include +#include "kpdf_dcop.h" + class QWidget; class QSplitter; class QToolBox; @@ -50,7 +52,7 @@ class BrowserExtension; * @author Wilco Greven * @version 0.2 */ -class Part : public KParts::ReadOnlyPart +class Part : public KParts::ReadOnlyPart, virtual public kpdf_dcop { Q_OBJECT @@ -63,6 +65,10 @@ public: ~Part(); static KAboutData* createAboutData(); + + ASYNC goToPage(uint page); + ASYNC openDocument(KURL doc); + uint pages(); protected: // reimplemented from KParts::ReadOnlyPart -- GitLab