Commit 99a10e18 authored by Albert Astals Cid's avatar Albert Astals Cid

All fixes done in HEAD come to annotations branch

svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=395067
parent c6191c48
......@@ -111,6 +111,14 @@
<string>Show &amp;hints and info messages</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_ObeyDRM</cstring>
</property>
<property name="text">
<string>&amp;Obey DRM limitations</string>
</property>
</widget>
</vbox>
</widget>
<widget class="QLayoutWidget">
......@@ -223,7 +231,11 @@
<includes>
<include location="global" impldecl="in implementation">kdialog.h</include>
<include location="global" impldecl="in implementation">kiconloader.h</include>
<include location="local" impldecl="in implementation">dlggeneral.ui.h</include>
</includes>
<functions>
<function access="protected" specifier="non virtual">showEvent( QShowEvent * )</function>
</functions>
<pixmapfunction>DesktopIcon</pixmapfunction>
<layoutdefaults spacing="6" margin="11"/>
</UI>
......@@ -53,6 +53,9 @@
<entry key="WatchFile" type="Bool" >
<default>true</default>
</entry>
<entry key="ObeyDRM" type="Bool" >
<default>true</default>
</entry>
</group>
<group name="MainView" >
<entry key="ShowLeftPanel" type="Bool" >
......@@ -70,7 +73,7 @@
<entry key="ShowScrollBars" type="Bool" >
<default>true</default>
</entry>
<entry key="ViewContinous" type="Bool" >
<entry key="ViewContinuous" type="Bool" >
<default>true</default>
</entry>
<entry key="ViewColumns" type="UInt" >
......
......@@ -77,35 +77,41 @@ else
AC_DEFINE(HAVE_FSEEK64, 0)
fi
dnl #### Check for libt1
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
kpdf_have_t1lib=
KDE_CHECK_LIB(t1, T1_InitLib, [LIBT1="-lt1"; kpdf_have_t1lib=yes],
[
kpdf_have_t1lib=no
])
AC_SUBST(LIBT1)
if test $kpdf_have_t1lib = yes; then
AC_DEFINE_UNQUOTED(HAVE_T1LIB_H, 1, [Defines if your system has the t1 library])
else
AC_DEFINE_UNQUOTED(HAVE_T1LIB_H, 0, [Defines if your system has the t1 library])
fi
AC_LANG_RESTORE
dnl #### Enable the user to enable multithearind on xpdf
AC_ARG_ENABLE(multithreaded-kpdf,
AC_HELP_STRING([--enable-multithreaded-kpdf],[include support for multithreading in kpdf]),
AC_HELP_STRING([--enable-multithreaded-kpdf],[include support for multithreading in xpdf code inside kpdf. Has nothing to do with threaded generation of contents, this is configurable via a dialog inside the program itself]),
[
case $enableval in
yes)
AC_DEFINE(MULTITHREADED, 1, [Defines if use multithreading in kpdf])
AC_DEFINE(MULTITHREADED, 1, [Defines if use multithreading in xpdf code inside kpdf])
;;
no)
AC_DEFINE(MULTITHREADED, 0, [Defines if use multithreading in xpdf code inside kpdf])
;;
*)
AC_DEFINE(MULTITHREADED, 0, [Defines if use multithreading in kpdf])
AC_DEFINE(MULTITHREADED, 1, [Defines if use multithreading in xpdf code inside kpdf])
;;
esac
]
, AC_DEFINE(MULTITHREADED, 0, [Defines if use multithreading in kpdf])
, AC_DEFINE(MULTITHREADED, 0, [Defines if use multithreading in xpdf code inside kpdf])
)
dnl #### Enable the user to decide if he wants to force drm or not
AC_ARG_ENABLE(force-kpdf-drm,
AC_HELP_STRING([--enable-force-kpdf-drm],[Forces kpdf to check for DRM to decide if you can copy/print protected pdf. (default=no)]),
[
case $enableval in
yes)
AC_DEFINE(KPDF_FORCE_DRM, 1, [Defines if force the use DRM in kpdf])
;;
no)
AC_DEFINE(KPDF_FORCE_DRM, 0, [Defines if force the use DRM in kpdf])
;;
*)
AC_DEFINE(KPDF_FORCE_DRM, 1, [Defines if force the use DRM in kpdf])
;;
esac
]
, AC_DEFINE(KPDF_FORCE_DRM, 0, [Defines if force the use DRM in kpdf])
)
......@@ -140,8 +140,8 @@ bool KPDFDocument::openDocument( const QString & docFile, const KURL & url )
QString mimeName = mime->name();
if ( mimeName == "application/pdf" )
generator = new PDFGenerator( this );
else if ( mimeName == "application/postscript" )
kdError() << "PS generator not available" << endl;
/* else if ( mimeName == "application/postscript" )
kdError() << "PS generator not available" << endl;*/
else
{
kdWarning() << "Unknown mimetype '" << mimeName << "'." << endl;
......@@ -361,9 +361,9 @@ uint KPDFDocument::pages() const
return pages_vector.size();
}
bool KPDFDocument::okToPrint() const
bool KPDFDocument::isAllowed( int flags ) const
{
return generator ? generator->isAllowed( Generator::Print ) : false;
return generator ? generator->isAllowed( flags ) : false;
}
bool KPDFDocument::historyAtBegin() const
......@@ -1006,11 +1006,19 @@ void KPDFDocument::processLink( const KPDFLink * link )
kapp->invokeMailer( browse->url() );
else
{
QString url = browse->url();
// fix for #100366, documents with relative links that are the form of http:foo.pdf
if (url.find("http:") == 0 && url.find("http://") == -1 && url.right(4) == ".pdf")
{
openRelativeFile(url.mid(5));
return;
}
// get service for web browsing
KService::Ptr ptr = KServiceTypeProfile::preferredService("text/html", "Application");
KURL::List lst;
// append 'url' parameter to the service and run it
lst.append( browse->url() );
lst.append( url );
KRun::run( *ptr, lst );
}
} break;
......
......@@ -61,6 +61,9 @@ class KPDFDocument : public QObject
void removeObserver( DocumentObserver * pObserver );
void reparseConfig();
// enum definitions
enum Permission { AllowModify = 1, AllowCopy = 2, AllowPrint = 4, AllowNotes = 8 };
// query methods (const ones)
bool isOpened() const;
const DocumentInfo * documentInfo() const;
......@@ -69,7 +72,7 @@ class KPDFDocument : public QObject
const DocumentViewport & viewport() const;
uint currentPage() const;
uint pages() const;
bool okToPrint() const;
bool isAllowed( int /*Document::Permisison(s)*/ ) const;
bool historyAtBegin() const;
bool historyAtEnd() const;
QString getMetaData( const QString & key, const QString & option = QString() ) const;
......
......@@ -51,8 +51,7 @@ class Generator : public QObject
virtual const DocumentSynopsis * generateDocumentSynopsis() { return 0L; }
// DRM handling
enum Permissions { Modify = 1, Copy = 2, Print = 4, AddNotes = 8 };
virtual bool isAllowed( int /*permisisons*/ ) { return true; }
virtual bool isAllowed( int /*Document::Permisison(s)*/ ) { return true; }
// page contents generation
virtual bool canGeneratePixmap() = 0;
......
......@@ -13,6 +13,9 @@
#include <qevent.h>
#include <qimage.h>
#include <qapplication.h>
#include <qpaintdevicemetrics.h>
#include <qregexp.h>
#include <kapplication.h>
#include <klocale.h>
#include <kpassdlg.h>
#include <kwallet.h>
......@@ -38,6 +41,8 @@
#include "core/pagetransition.h"
#include "conf/settings.h"
#include <config.h>
// id for DATA_READY PDFPixmapGeneratorThread Event
#define TGE_DATAREADY_ID 6969
......@@ -244,6 +249,20 @@ const DocumentSynopsis * PDFGenerator::generateDocumentSynopsis()
return &docSyn;
}
bool PDFGenerator::isAllowed( int permissions )
{
#if !KPDF_FORCE_DRM
if (kapp->authorize("skip_drm") && !Settings::obeyDRM()) return true;
#endif
bool b = true;
if (permissions & KPDFDocument::AllowModify) b = b && pdfdoc->okToChange();
if (permissions & KPDFDocument::AllowCopy) b = b && pdfdoc->okToCopy();
if (permissions & KPDFDocument::AllowPrint) b = b && pdfdoc->okToPrint();
if (permissions & KPDFDocument::AllowNotes) b = b && pdfdoc->okToAddNotes();
return b;
}
bool PDFGenerator::canGeneratePixmap()
{
return ready;
......@@ -321,6 +340,28 @@ void PDFGenerator::generateSyncTextPage( KPDFPage * page )
bool PDFGenerator::print( KPrinter& printer )
{
QString ps = printer.option("PageSize");
if (ps.find(QRegExp("w\\d+h\\d+")) == 0)
{
// size not supported by Qt, KPrinter gives us the size as wWIDTHhHEIGHT
// remove the w
ps = ps.mid(1);
int hPos = ps.find("h");
globalParams->setPSPaperWidth(ps.left(hPos).toInt());
globalParams->setPSPaperHeight(ps.mid(hPos+1).toInt());
}
else
{
// size is supported by Qt, we get either the pageSize name or nothing because the default pageSize is used
QPrinter dummy(QPrinter::PrinterResolution);
dummy.setFullPage(true);
dummy.setPageSize((QPrinter::PageSize)(ps.isEmpty() ? KGlobal::locale()->pageSize() : pageNameToPageSize(ps)));
QPaintDeviceMetrics metrics(&dummy);
globalParams->setPSPaperWidth(metrics.width());
globalParams->setPSPaperHeight(metrics.height());
}
KTempFile tf( QString::null, ".ps" );
PSOutputDev *psOut = new PSOutputDev(tf.name().latin1(), pdfdoc->getXRef(), pdfdoc->getCatalog(), 1, pdfdoc->getNumPages(), psModePS);
......
......@@ -54,6 +54,9 @@ class PDFGenerator : public Generator
const DocumentInfo * generateDocumentInfo();
const DocumentSynopsis * generateDocumentSynopsis();
// [INHERITED] document informations
bool isAllowed( int permissions );
// [INHERITED] perform actions on document / pages
bool canGeneratePixmap();
void generatePixmap( PixmapRequest * request );
......
......@@ -49,6 +49,7 @@
#include <kpopupmenu.h>
#include <kxmlguiclient.h>
#include <kxmlguifactory.h>
#include <ktrader.h>
// local includes
#include "xpdf/GlobalParams.h"
......@@ -78,7 +79,7 @@ unsigned int Part::m_count = 0;
Part::Part(QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name,
const QStringList & /*args*/ )
: DCOPObject("kpdf"), KParts::ReadOnlyPart(parent, name), m_showMenuBarAction(0),
: DCOPObject("kpdf"), KParts::ReadOnlyPart(parent, name), m_showMenuBarAction(0), m_showFullScreenAction(0),
m_actionsSearched(false), m_searchStarted(false)
{
// load catalog for translation
......@@ -251,15 +252,8 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
connect( m_dirtyHandler, SIGNAL( timeout() ),this, SLOT( slotDoFileDirty() ) );
// [SPEECH] check for KTTSD presence and usability
Settings::setUseKTTSD( true );
DCOPClient * client = DCOPClient::mainClient();
// Albert says is this ever necessary?
// we already attached on Part constructor
if ( !client->isAttached() )
client->attach();
if ( !client->isApplicationRegistered("kttsd") )
if ( KApplication::startServiceByName( "KTTSD" ) )
Settings::setUseKTTSD( false );
KTrader::OfferList offers = KTrader::self()->query("DCOP/Text-to-Speech", "Name == 'KTTSD'");
Settings::setUseKTTSD( (offers.count() > 0) );
// set our XML-UI resource file
setXMLFile("part.rc");
......@@ -646,19 +640,23 @@ void Part::slotShowMenu(const KPDFPage *page, const QPoint &point)
KActionCollection *ac;
KActionPtrList::const_iterator it, end, begin;
KActionPtrList actions;
QPtrList<KXMLGUIClient> clients(factory()->clients());
QPtrListIterator<KXMLGUIClient> clientsIt( clients );
for( ; (!m_showMenuBarAction || !m_showFullScreenAction) && clientsIt.current(); ++clientsIt)
if (factory())
{
client = clientsIt.current();
ac = client->actionCollection();
actions = ac->actions();
end = actions.end();
begin = actions.begin();
for ( it = begin; it != end; ++it )
QPtrList<KXMLGUIClient> clients(factory()->clients());
QPtrListIterator<KXMLGUIClient> clientsIt( clients );
for( ; (!m_showMenuBarAction || !m_showFullScreenAction) && clientsIt.current(); ++clientsIt)
{
if (QString((*it)->name()) == "options_show_menubar") m_showMenuBarAction = (KToggleAction*)(*it);
if (QString((*it)->name()) == "fullscreen") m_showFullScreenAction = (KToggleAction*)(*it);
client = clientsIt.current();
ac = client->actionCollection();
actions = ac->actions();
end = actions.end();
begin = actions.begin();
for ( it = begin; it != end; ++it )
{
if (QString((*it)->name()) == "options_show_menubar") m_showMenuBarAction = (KToggleAction*)(*it);
if (QString((*it)->name()) == "fullscreen") m_showFullScreenAction = (KToggleAction*)(*it);
}
}
}
m_actionsSearched = true;
......@@ -762,7 +760,7 @@ void Part::slotPrint()
void Part::doPrint(KPrinter &printer)
{
if (!m_document->okToPrint())
if (!m_document->isAllowed(KPDFDocument::AllowPrint))
{
KMessageBox::error(widget(), i18n("Printing this document is not allowed."));
return;
......
......@@ -20,7 +20,7 @@
<Action name="zoom_fit_page"/>
<Action name="zoom_fit_rect"/>
<Separator/>
<Action name="view_continous"/>
<Action name="view_continuous"/>
<Action name="view_twopages"/>
</Menu>
<Menu name="go"><text>&amp;Go</text>
......@@ -57,7 +57,7 @@
<!--Action name="zoom_fit_width"/-->
<!--Action name="zoom_fit_page"/-->
<Separator/>
<Action name="view_continous"/>
<Action name="view_continuous"/>
<Action name="view_twopages"/>
<Separator/>
<Action name="mouse_drag"/>
......
This diff is collapsed.
......@@ -31,7 +31,7 @@ class PageViewItem;
class PageViewPrivate;
/**
* @short The main view. Handles zoom and continous mode.. oh, and page
* @short The main view. Handles zoom and continuous mode.. oh, and page
* @short display of course :-)
* ...
*/
......@@ -125,7 +125,7 @@ class PageView : public QScrollView, public DocumentObserver
void slotFitToPageToggled( bool );
void slotFitToTextToggled( bool );
void slotTwoPagesToggled( bool );
void slotContinousToggled( bool );
void slotContinuousToggled( bool );
void slotSetMouseNormal();
void slotSetMouseZoom();
void slotSetMouseSelect();
......
......@@ -52,25 +52,11 @@ PresentationWidget::PresentationWidget( KPDFDocument * doc )
{
// set look and geometry
setBackgroundMode( Qt::NoBackground );
QRect d = KGlobalSettings::desktopGeometry(this);
m_width = d.width();
m_height = d.height();
// create top toolbar
m_topBar = new KToolBar( this, "presentationBar" );
m_topBar->setIconSize( 32 );
m_topBar->setMovingEnabled( false );
m_topBar->insertButton( "1leftarrow", 2, SIGNAL( clicked() ), this, SLOT( slotPrevPage() ) );
m_topBar->insertButton( "1rightarrow", 3, SIGNAL( clicked() ), this, SLOT( slotNextPage() ) );
m_topBar->insertButton( "exit", 1, SIGNAL( clicked() ), this, SLOT( close() ) );
m_topBar->setGeometry( 0, 0, m_width, 32 + 10 );
m_topBar->alignItemRight( 1 );
m_topBar->hide();
// change topbar background color
QPalette p = m_topBar->palette();
p.setColor( QPalette::Active, QColorGroup::Button, Qt::gray );
p.setColor( QPalette::Active, QColorGroup::Background, Qt::darkGray );
m_topBar->setPalette( p );
m_width = -1;
// show widget and take control
showFullScreen();
// misc stuff
setMouseTracking( true );
......@@ -79,9 +65,6 @@ PresentationWidget::PresentationWidget( KPDFDocument * doc )
m_overlayHideTimer = new QTimer( this );
connect( m_overlayHideTimer, SIGNAL( timeout() ), this, SLOT( slotHideOverlay() ) );
// show widget and take control
showFullScreen();
// handle cursor appearance as specified in configuration
if ( Settings::slidesCursor() == Settings::EnumSlidesCursor::HiddenDelay )
{
......@@ -92,13 +75,6 @@ PresentationWidget::PresentationWidget( KPDFDocument * doc )
{
setCursor( KCursor::blankCursor() );
}
// register this observer in document. events will come immediately
m_document->addObserver( this );
// show summary if requested
if ( Settings::slidesShowSummary() )
generatePage();
}
PresentationWidget::~PresentationWidget()
......@@ -194,6 +170,8 @@ bool PresentationWidget::canUnloadPixmap( int pageNumber )
// <widget events>
void PresentationWidget::keyPressEvent( QKeyEvent * e )
{
if (m_width == -1) return;
if ( e->key() == Key_Left || e->key() == Key_Backspace )
slotPrevPage();
else if ( e->key() == Key_Right || e->key() == Key_Space )
......@@ -244,6 +222,8 @@ void PresentationWidget::mousePressEvent( QMouseEvent * e )
void PresentationWidget::mouseMoveEvent( QMouseEvent * e )
{
if (m_width == -1) return;
// hide a shown bar when exiting the area
if ( m_topBar->isShown() )
{
......@@ -260,6 +240,36 @@ void PresentationWidget::mouseMoveEvent( QMouseEvent * e )
void PresentationWidget::paintEvent( QPaintEvent * pe )
{
if (m_width == -1)
{
QRect d = KGlobalSettings::desktopGeometry(this);
m_width = d.width();
m_height = d.height();
// create top toolbar
m_topBar = new KToolBar( this, "presentationBar" );
m_topBar->setIconSize( 32 );
m_topBar->setMovingEnabled( false );
m_topBar->insertButton( "1leftarrow", 2, SIGNAL( clicked() ), this, SLOT( slotPrevPage() ) );
m_topBar->insertButton( "1rightarrow", 3, SIGNAL( clicked() ), this, SLOT( slotNextPage() ) );
m_topBar->insertButton( "exit", 1, SIGNAL( clicked() ), this, SLOT( close() ) );
m_topBar->setGeometry( 0, 0, m_width, 32 + 10 );
m_topBar->alignItemRight( 1 );
m_topBar->hide();
// change topbar background color
QPalette p = m_topBar->palette();
p.setColor( QPalette::Active, QColorGroup::Button, Qt::gray );
p.setColor( QPalette::Active, QColorGroup::Background, Qt::darkGray );
m_topBar->setPalette( p );
// register this observer in document. events will come immediately
m_document->addObserver( this );
// show summary if requested
if ( Settings::slidesShowSummary() )
generatePage();
}
// check painting rect consistancy
QRect r = pe->rect().intersect( geometry() );
if ( r.isNull() || m_lastRenderedPixmap.isNull() )
......@@ -310,7 +320,7 @@ void PresentationWidget::overlayClick( const QPoint & position )
return;
// compute angle relative to indicator (note coord transformation)
float angle = 0.5 + 0.5 * atan2f( -xPos, -yPos ) / M_PI;
float angle = 0.5 + 0.5 * atan2( -xPos, -yPos ) / M_PI;
int pageIndex = (int)( angle * ( m_frames.count() - 1 ) + 0.5 );
// go to selected page
......@@ -473,7 +483,7 @@ void PresentationWidget::generateOverlay()
// draw PIE SLICES in blue levels (the levels will then be the alpha component)
int pages = m_document->pages();
if ( pages > 36 )
{ // draw continous slices
{ // draw continuous slices
int degrees = (int)( 360 * (float)(m_frameIndex + 1) / (float)pages );
pixmapPainter.setPen( 0x20 );
pixmapPainter.setBrush( 0x10 );
......
......@@ -3,6 +3,7 @@
#include <config.h>
#define HAVE_T1LIB_H 0
#define HAVE_FREETYPE_H HAVE_FREETYPE
#define HAVE_FREETYPE_FREETYPE_H HAVE_FREETYPE
#define OPI_SUPPORT 0
......
......@@ -13,6 +13,7 @@
#endif
#include <string.h>
#include <strings.h>
// KPDF: additional includes for Qt and Xft
#include <qstring.h>
#include <qregexp.h>
......@@ -1070,7 +1071,9 @@ DisplayFontParam *GlobalParams::getDisplayFont(GString *fontName) {
int weight=FC_WEIGHT_MEDIUM, slant=FC_SLANT_ROMAN;
QString name(fontName->getCString());
parseStyle(name,weight,slant);
p = FcPatternBuild(0,FC_FAMILY,FcTypeString, name.ascii(), FC_SLANT, FcTypeInteger, slant, FC_WEIGHT, FcTypeInteger, weight, (char*)0);
p = FcPatternBuild(0,FC_FAMILY,FcTypeString, name.ascii(),
FC_SLANT, FcTypeInteger, slant, FC_WEIGHT, FcTypeInteger, weight,
FC_LANG, FcTypeString, "xx", (char*)0);
if (!p) goto fin;
m = XftFontMatch(qt_xdisplay(),qt_xscreen(),p,&res);
if (!m) goto fin;
......
INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../fofi -I$(srcdir)/../splash -I$(srcdir)/../goo $(all_includes) $(LIBFREETYPE_CFLAGS) $(X_INCLUDES) $(QT_INCLUDES)
libxpdf_la_LDFLAGS = $(all_libraries)
libxpdf_la_LIBADD = $(LIB_X11) $(LIBFREETYPE_LIBS) $(LIBPAPER_LIBS) $(LIBT1) $(XFT_LIBS) ../goo/libgoo.la ../fofi/libfofi.la ../splash/libsplash.la
libxpdf_la_LIBADD = $(LIB_X11) $(LIBFREETYPE_LIBS) $(LIBPAPER_LIBS) $(XFT_LIBS) ../goo/libgoo.la ../fofi/libfofi.la ../splash/libsplash.la
libxpdf_la_SOURCES = Annot.cc Array.cc BuiltinFont.cc BuiltinFontTables.cc \
Catalog.cc CharCodeToUnicode.cc CMap.cc Decrypt.cc Dict.cc \
FontEncodingTables.cc Function.cc Gfx.cc \
......
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