summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qpdf
authorkergoth <kergoth>2003-08-09 16:24:58 (UTC)
committer kergoth <kergoth>2003-08-09 16:24:58 (UTC)
commite16d333ec2e8509fc665921ca106c25325bae9e0 (patch) (side-by-side diff)
tree9e9068190a15bc9b2a52ab33b40881128f732c0e /noncore/unsupported/qpdf
parent1c58d1407f9584fedcdae390a04e2b37e5853361 (diff)
downloadopie-e16d333ec2e8509fc665921ca106c25325bae9e0.zip
opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.gz
opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.bz2
Merge from BRANCH_1_0
Diffstat (limited to 'noncore/unsupported/qpdf') (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/qpdf/QOutputDev.cpp17
-rw-r--r--noncore/unsupported/qpdf/opie-qpdf.control2
-rw-r--r--noncore/unsupported/qpdf/qpdf.cpp0
3 files changed, 16 insertions, 3 deletions
diff --git a/noncore/unsupported/qpdf/QOutputDev.cpp b/noncore/unsupported/qpdf/QOutputDev.cpp
index 52237f5..022d938 100644
--- a/noncore/unsupported/qpdf/QOutputDev.cpp
+++ b/noncore/unsupported/qpdf/QOutputDev.cpp
@@ -74,228 +74,241 @@ static QOutFontSubst qStdFonts [] = {
{ "Helvetica", "Helvetica", false, false, QFont::Helvetica },
{ "Helvetica-Oblique", "Helvetica", false, true, QFont::Helvetica },
{ "Helvetica-Bold", "Helvetica", true, false, QFont::Helvetica },
{ "Helvetica-BoldOblique", "Helvetica", true, true, QFont::Helvetica },
{ "Times-Roman", "Times", false, false, QFont::Times },
{ "Times-Italic", "Times", false, true, QFont::Times },
{ "Times-Bold", "Times", true, false, QFont::Times },
{ "Times-BoldItalic", "Times", true, true, QFont::Times },
{ "Courier", "Courier", false, false, QFont::Courier },
{ "Courier-Oblique", "Courier", false, true, QFont::Courier },
{ "Courier-Bold", "Courier", true, false, QFont::Courier },
{ "Courier-BoldOblique", "Courier", true, true, QFont::Courier },
{ "Symbol", 0, false, false, QFont::AnyStyle },
{ "Zapf-Dingbats", 0, false, false, QFont::AnyStyle },
{ 0, 0, false, false, QFont::AnyStyle }
};
QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp_t m22 )
{
static QDict<QOutFontSubst> stdfonts;
// build dict for std. fonts on first invocation
if ( stdfonts. isEmpty ( )) {
for ( QOutFontSubst *ptr = qStdFonts; ptr-> m_name; ptr++ ) {
stdfonts. insert ( QString ( ptr-> m_name ), ptr );
}
}
// compute size and normalized transform matrix
int size = lrint ( sqrt ( m21 * m21 + m22 * m22 ));
QPDFDBG( printf ( "SET FONT: Name=%s, Size=%d, Bold=%d, Italic=%d, Mono=%d, Serif=%d, Symbol=%d, CID=%d, EmbFN=%s, M=(%f,%f,%f,%f)\n",
(( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ),
size,
gfxFont-> isBold ( ),
gfxFont-> isItalic ( ),
gfxFont-> isFixedWidth ( ),
gfxFont-> isSerif ( ),
gfxFont-> isSymbolic ( ),
gfxFont-> isCIDFont ( ),
- ( gfxFont-> getEmbeddedFontName ( ) ? gfxFont-> getEmbeddedFontName ( ) : "<n/a>" ),
+ ( gfxFont-> getEmbeddedFontName ( ) ? gfxFont-> getEmbeddedFontName()-> getCString ( ) : "<n/a>" ),
(double) m11, (double) m12, (double) m21, (double) m22 ));
QString fname (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" );
QFont f;
f. setPixelSize ( size > 0 ? size : 8 ); // type3 fonts misbehave sometimes
// fast lookup for std. fonts
QOutFontSubst *subst = stdfonts [fname];
if ( subst ) {
if ( subst-> m_sname )
f. setFamily ( subst-> m_sname );
f. setStyleHint ( subst-> m_hint, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality ));
f. setBold ( subst-> m_bold );
f. setItalic ( subst-> m_italic );
}
else {
QFont::StyleHint sty;
if ( gfxFont-> isSerif ( ))
sty = QFont::Serif;
else if ( gfxFont-> isFixedWidth ( ))
sty = QFont::TypeWriter;
else
sty = QFont::Helvetica;
f. setStyleHint ( sty, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality ));
f. setBold ( gfxFont-> isBold ( ) > 0 );
f. setItalic ( gfxFont-> isItalic ( ) > 0 );
f. setFixedPitch ( gfxFont-> isFixedWidth ( ) > 0 );
// common specifiers in font names
if ( fname. contains ( "Oblique" ) || fname. contains ( "Italic" ))
f. setItalic ( true );
if ( fname. contains ( "Bold" ))
f. setWeight ( QFont::Bold );
if ( fname. contains ( "Demi" ))
f. setWeight ( QFont::DemiBold );
if ( fname. contains ( "Light" ))
f. setWeight ( QFont::Light );
if ( fname. contains ( "Black" ))
f. setWeight ( QFont::Black );
}
// Treat x-sheared fonts as italic
if (( m12 > -0.1 ) && ( m12 < 0.1 ) && ((( m21 > -5.0 ) && ( m21 < -0.1 )) || (( m21 > 0.1 ) && ( m21 < 5.0 )))) {
f. setItalic ( true );
}
return f;
}
//------------------------------------------------------------------------
// QOutputDev
//------------------------------------------------------------------------
QOutputDev::QOutputDev ( QWidget *parent, const char *name, int flags ) : QScrollView ( parent, name, WRepaintNoErase | WResizeNoErase | flags )
{
m_pixmap = 0;
m_painter = 0;
// create text object
m_text = new TextPage ( gFalse );
}
QOutputDev::~QOutputDev ( )
{
delete m_painter;
delete m_pixmap;
delete m_text;
}
void QOutputDev::startPage ( int /*pageNum*/, GfxState *state )
{
delete m_pixmap;
delete m_painter;
m_pixmap = new QPixmap ( lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( )));
m_painter = new QPainter ( m_pixmap );
QPDFDBG( printf ( "NEW PIXMAP (%ld x %ld)\n", lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( ))));
resizeContents ( m_pixmap-> width ( ), m_pixmap-> height ( ));
setContentsPos ( 0, 0 );
m_pixmap-> fill ( white ); // clear window
m_text-> clear ( ); // cleat text object
viewport ( )-> repaint ( );
}
void QOutputDev::endPage ( )
{
+ QPDFDBG( printf("End page\n") );
m_text-> coalesce ( );
+ /*
+ * I get stupid crashes after endPage is called and then we do clipping
+ * and other stuff.....
+ */
+#if 0
delete m_painter;
m_painter = 0;
+#endif
updateContents ( 0, 0, contentsWidth ( ), contentsHeight ( ));
}
void QOutputDev::drawLink ( Link *link, Catalog */*catalog*/ )
{
fp_t x1, y1, x2, y2, w;
link-> getBorder ( &x1, &y1, &x2, &y2, &w );
if ( w > 0 ) {
int x, y, dx, dy;
cvtUserToDev ( x1, y1, &x, &y );
cvtUserToDev ( x2, y2, &dx, &dy );
QPen oldpen = m_painter-> pen ( );
m_painter-> setPen ( blue );
m_painter-> drawRect ( x, y, dx, dy );
m_painter-> setPen ( oldpen );
}
}
void QOutputDev::saveState ( GfxState */*state*/ )
{
+ if ( ! m_painter )
+ return;
+
QPDFDBG( printf ( "SAVE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( )));
m_painter-> save ( );
}
void QOutputDev::restoreState ( GfxState */*state*/ )
{
+ if( ! m_painter )
+ return;
+
m_painter-> restore ( );
// m_painter-> setClipRegion ( QRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( )));
// m_painter-> setClipping ( false );
QPDFDBG ( printf ( "RESTORE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( )));
}
void QOutputDev::updateAll ( GfxState *state )
{
updateLineAttrs ( state, gTrue );
// updateFlatness ( state );
// updateMiterLimit ( state );
updateFillColor ( state );
updateStrokeColor ( state );
updateFont ( state );
}
void QOutputDev::updateCTM ( GfxState *state, fp_t /*m11*/, fp_t /*m12*/, fp_t /*m21*/, fp_t /*m22*/, fp_t /*m31*/, fp_t /*m32*/ )
{
updateLineAttrs ( state, gTrue );
}
void QOutputDev::updateLineDash ( GfxState *state )
{
updateLineAttrs ( state, gTrue );
}
void QOutputDev::updateFlatness ( GfxState */*state*/ )
{
// not supported
QPDFDBG( printf ( "updateFlatness not supported !\n" ));
}
void QOutputDev::updateLineJoin ( GfxState *state )
{
updateLineAttrs ( state, gFalse );
}
void QOutputDev::updateLineCap ( GfxState *state )
{
updateLineAttrs ( state, gFalse );
}
// unimplemented
void QOutputDev::updateMiterLimit ( GfxState */*state*/ )
{
QPDFDBG( printf ( "updateMiterLimit not supported !\n" ));
}
@@ -476,97 +489,97 @@ void QOutputDev::doFill ( GfxState *state, bool winding )
}
m_painter-> setPen ( oldpen );
qApp-> processEvents ( );
}
void QOutputDev::clip ( GfxState *state )
{
doClip ( state, true );
}
void QOutputDev::eoClip ( GfxState *state )
{
doClip ( state, false );
}
void QOutputDev::doClip ( GfxState *state, bool winding )
{
QPointArray points;
QArray<int> lengths;
// transform points
int n = convertPath ( state, points, lengths );
QRegion region;
QPDFDBG( printf ( "CLIPPING: %d POLYS\n", n ));
// draw each subpath
int j = 0;
for ( int i = 0; i < n; i++ ) {
int len = lengths [i];
if ( len >= 3 ) {
QPointArray dummy;
dummy. setRawData ( points. data ( ) + j, len );
QPDFDBG( printf ( " - POLY %d: ", i ));
QPDFDBG( for ( int ii = 0; ii < len; ii++ ) printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )));
QPDFDBG( printf ( "\n" ));
region |= QRegion ( dummy, winding );
dummy. resetRawData ( points. data ( ) + j, len );
}
j += len;
}
- if ( m_painter-> hasClipping ( ))
+ if ( m_painter && m_painter-> hasClipping ( ))
region &= m_painter-> clipRegion ( );
// m_painter-> setClipRegion ( region );
// m_painter-> setClipping ( true );
// m_painter-> fillRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( ), red );
// m_painter-> drawText ( points [0]. x ( ) + 10, points [0]. y ( ) + 10, "Bla bla" );
qApp-> processEvents ( );
}
//
// Transform points in the path and convert curves to line segments.
// Builds a set of subpaths and returns the number of subpaths.
// If <fillHack> is set, close any unclosed subpaths and activate a
// kludge for polygon fills: First, it divides up the subpaths into
// non-overlapping polygons by simply comparing bounding rectangles.
// Then it connects subaths within a single compound polygon to a single
// point so that X can fill the polygon (sort of).
//
int QOutputDev::convertPath ( GfxState *state, QPointArray &points, QArray<int> &lengths )
{
GfxPath *path = state-> getPath ( );
int n = path-> getNumSubpaths ( );
lengths. resize ( n );
// do each subpath
for ( int i = 0; i < n; i++ ) {
// transform the points
lengths [i] = convertSubpath ( state, path-> getSubpath ( i ), points );
}
return n;
}
//
// Transform points in a single subpath and convert curves to line
// segments.
//
int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArray &points )
{
int oldcnt = points. count ( );
fp_t x0, y0, x1, y1, x2, y2, x3, y3;
int m = subpath-> getNumPoints ( );
int i = 0;
diff --git a/noncore/unsupported/qpdf/opie-qpdf.control b/noncore/unsupported/qpdf/opie-qpdf.control
index 33df3e1..208dcb1 100644
--- a/noncore/unsupported/qpdf/opie-qpdf.control
+++ b/noncore/unsupported/qpdf/opie-qpdf.control
@@ -1,9 +1,9 @@
Package: opie-qpdf
Files: bin/qpdf apps/Applications/qpdf.desktop pics/qpdf/qpdf_icon.png
Priority: optional
Section: opie/applications
Maintainer: Robert Griebl <sandman@handhelds.org>
Architecture: arm
-Version: $QPE_VERSION-$SUB_VERSION
Depends: task-opie-minimal, gzip
Description: A PDF viewer for OPIE.
+Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/unsupported/qpdf/qpdf.cpp b/noncore/unsupported/qpdf/qpdf.cpp
index 61f097b..de1dcf3 100644
--- a/noncore/unsupported/qpdf/qpdf.cpp
+++ b/noncore/unsupported/qpdf/qpdf.cpp