summaryrefslogtreecommitdiffstats
path: root/lib/kofficecore/KoPictureEps.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kofficecore/KoPictureEps.cpp')
-rw-r--r--lib/kofficecore/KoPictureEps.cpp108
1 files changed, 54 insertions, 54 deletions
diff --git a/lib/kofficecore/KoPictureEps.cpp b/lib/kofficecore/KoPictureEps.cpp
index 752e2a45..4b47b228 100644
--- a/lib/kofficecore/KoPictureEps.cpp
+++ b/lib/kofficecore/KoPictureEps.cpp
@@ -21,16 +21,16 @@
#include <unistd.h>
#include <stdio.h>
-#include <qbuffer.h>
-#include <qpainter.h>
-#include <qpaintdevicemetrics.h>
-#include <qfile.h>
-#include <qtextstream.h>
-#include <qregexp.h>
-#include <qimage.h>
-#include <qpixmap.h>
-#include <qapplication.h>
-#include <qdragobject.h>
+#include <tqbuffer.h>
+#include <tqpainter.h>
+#include <tqpaintdevicemetrics.h>
+#include <tqfile.h>
+#include <tqtextstream.h>
+#include <tqregexp.h>
+#include <tqimage.h>
+#include <tqpixmap.h>
+#include <tqapplication.h>
+#include <tqdragobject.h>
#include <kglobal.h>
#include <kdebug.h>
@@ -48,8 +48,8 @@
KoPictureEps::KoPictureEps(void) : m_psStreamStart(0), m_psStreamLength(0), m_cacheIsInFastMode(true)
{
- // Forbid QPixmap to cache the X-Window resources (Yes, it is slower!)
- m_cachedPixmap.setOptimization(QPixmap::MemoryOptim);
+ // Forbid TQPixmap to cache the X-Window resources (Yes, it is slower!)
+ m_cachedPixmap.setOptimization(TQPixmap::MemoryOptim);
}
KoPictureEps::~KoPictureEps(void)
@@ -71,12 +71,12 @@ bool KoPictureEps::isNull(void) const
return m_rawData.isNull();
}
-QImage KoPictureEps::scaleWithGhostScript(const QSize& size, const int resolutionx, const int resolutiony )
+TQImage KoPictureEps::scaleWithGhostScript(const TQSize& size, const int resolutionx, const int resolutiony )
{
if (!m_boundingBox.width() || !m_boundingBox.height())
{
kdDebug(30003) << "EPS image has a null size! (in KoPictureEps::scaleWithGhostScript)" << endl;
- return QImage();
+ return TQImage();
}
// ### TODO: do not call GhostScript up to three times for each re-scaling (one call of GhostScript should be enough to know which device is available: gs --help)
@@ -86,7 +86,7 @@ QImage KoPictureEps::scaleWithGhostScript(const QSize& size, const int resolutio
const char* deviceTable[] = { "png16m", "bmp16m", "ppm", 0 };
- QImage img;
+ TQImage img;
for ( int i = 0; deviceTable[i]; ++i)
{
@@ -103,7 +103,7 @@ QImage KoPictureEps::scaleWithGhostScript(const QSize& size, const int resolutio
// Helper method for scaleWithGhostScript. Returns 1 on success, 0 on error, -1 if nothing generated
// (in which case another 'output device' can be tried)
-int KoPictureEps::tryScaleWithGhostScript(QImage &image, const QSize& size, const int resolutionx, const int resolutiony, const char* device )
+int KoPictureEps::tryScaleWithGhostScript(TQImage &image, const TQSize& size, const int resolutionx, const int resolutiony, const char* device )
// Based on the code of the file kdelibs/kimgio/eps.cpp
{
kdDebug(30003) << "Sampling with GhostScript, using device \"" << device << "\" (in KoPictureEps::tryScaleWithGhostScript)" << endl;
@@ -124,12 +124,12 @@ int KoPictureEps::tryScaleWithGhostScript(QImage &image, const QSize& size, cons
// create GS command line
- QString cmdBuf ( "gs -sOutputFile=" );
+ TQString cmdBuf ( "gs -sOutputFile=" );
cmdBuf += KProcess::quote(tmpFile.name());
cmdBuf += " -q -g";
- cmdBuf += QString::number( wantedWidth );
+ cmdBuf += TQString::number( wantedWidth );
cmdBuf += "x";
- cmdBuf += QString::number( wantedHeight );
+ cmdBuf += TQString::number( wantedHeight );
if ( ( resolutionx > 0) && ( resolutiony > 0) )
{
@@ -137,9 +137,9 @@ int KoPictureEps::tryScaleWithGhostScript(QImage &image, const QSize& size, cons
// Do not play with resolution for now.
// It brings more problems at print than solutions
cmdBuf += " -r";
- cmdBuf += QString::number( resolutionx );
+ cmdBuf += TQString::number( resolutionx );
cmdBuf += "x";
- cmdBuf += QString::number( resolutiony );
+ cmdBuf += TQString::number( resolutiony );
#endif
}
@@ -151,7 +151,7 @@ int KoPictureEps::tryScaleWithGhostScript(QImage &image, const QSize& size, cons
// run ghostview
- FILE* ghostfd = popen (QFile::encodeName(cmdBuf), "w");
+ FILE* ghostfd = popen (TQFile::encodeName(cmdBuf), "w");
if ( ghostfd == 0 )
{
@@ -160,7 +160,7 @@ int KoPictureEps::tryScaleWithGhostScript(QImage &image, const QSize& size, cons
}
// The translation is needed as GhostScript (7.07) cannot handle negative values in the bounding box otherwise.
- fprintf (ghostfd, "\n%d %d translate\n", -qRound(m_boundingBox.left()*xScale), -qRound(m_boundingBox.top()*yScale));
+ fprintf (ghostfd, "\n%d %d translate\n", -tqRound(m_boundingBox.left()*xScale), -tqRound(m_boundingBox.top()*yScale));
fprintf (ghostfd, "%g %g scale\n", xScale, yScale);
// write image to gs
@@ -185,9 +185,9 @@ int KoPictureEps::tryScaleWithGhostScript(QImage &image, const QSize& size, cons
return 1; // success
}
-void KoPictureEps::scaleAndCreatePixmap(const QSize& size, bool fastMode, const int resolutionx, const int resolutiony )
+void KoPictureEps::scaleAndCreatePixmap(const TQSize& size, bool fastMode, const int resolutionx, const int resolutiony )
{
- kdDebug(30003) << "KoPictureEps::scaleAndCreatePixmap " << size << " " << (fastMode?QString("fast"):QString("slow"))
+ kdDebug(30003) << "KoPictureEps::scaleAndCreatePixmap " << size << " " << (fastMode?TQString("fast"):TQString("slow"))
<< " resolutionx: " << resolutionx << " resolutiony: " << resolutiony << endl;
if ((size==m_cachedSize)
&& ((fastMode) || (!m_cacheIsInFastMode)))
@@ -211,20 +211,20 @@ void KoPictureEps::scaleAndCreatePixmap(const QSize& size, bool fastMode, const
if ( fastMode && !m_cachedSize.isEmpty())
{
kdDebug(30003) << "Fast scaling!" << endl;
- // Slower than caching a QImage, but faster than re-sampling!
- QImage image( m_cachedPixmap.convertToImage() );
+ // Slower than caching a TQImage, but faster than re-sampling!
+ TQImage image( m_cachedPixmap.convertToImage() );
m_cachedPixmap=image.scale( size );
m_cacheIsInFastMode=true;
m_cachedSize=size;
}
else
{
- QTime time;
+ TQTime time;
time.start();
- QApplication::setOverrideCursor( Qt::waitCursor );
+ TQApplication::setOverrideCursor( TQt::waitCursor );
m_cachedPixmap = scaleWithGhostScript( size, resolutionx, resolutiony );
- QApplication::restoreOverrideCursor();
+ TQApplication::restoreOverrideCursor();
m_cacheIsInFastMode=false;
m_cachedSize=size;
@@ -233,22 +233,22 @@ void KoPictureEps::scaleAndCreatePixmap(const QSize& size, bool fastMode, const
kdDebug(30003) << "New size: " << size << endl;
}
-void KoPictureEps::draw(QPainter& painter, int x, int y, int width, int height, int sx, int sy, int sw, int sh, bool fastMode)
+void KoPictureEps::draw(TQPainter& painter, int x, int y, int width, int height, int sx, int sy, int sw, int sh, bool fastMode)
{
if ( !width || !height )
return;
- QSize screenSize( width, height );
+ TQSize screenSize( width, height );
//kdDebug() << "KoPictureEps::draw screenSize=" << screenSize.width() << "x" << screenSize.height() << endl;
- QPaintDeviceMetrics metrics (painter.device());
+ TQPaintDeviceMetrics metrics (painter.device());
kdDebug(30003) << "Metrics: X: " << metrics.logicalDpiX() << " x Y: " << metrics.logicalDpiX() << " (in KoPictureEps::draw)" << endl;
- if ( painter.device()->isExtDev() ) // Is it an external device (i.e. printer)
+ if ( painter.tqdevice()->isExtDev() ) // Is it an external device (i.e. printer)
{
kdDebug(30003) << "Drawing for a printer (in KoPictureEps::draw)" << endl;
// For printing, always re-sample the image, as a printer has never the same resolution than a display.
- QImage image( scaleWithGhostScript( screenSize, metrics.logicalDpiX(), metrics.logicalDpiY() ) );
+ TQImage image( scaleWithGhostScript( screenSize, metrics.logicalDpiX(), metrics.logicalDpiY() ) );
// sx,sy,sw,sh is meant to be used as a cliprect on the pixmap, but drawImage
// translates it to the (x,y) point -> we need (x+sx, y+sy).
painter.drawImage( x + sx, y + sy, image, sx, sy, sw, sh );
@@ -266,9 +266,9 @@ void KoPictureEps::draw(QPainter& painter, int x, int y, int width, int height,
bool KoPictureEps::extractPostScriptStream( void )
{
kdDebug(30003) << "KoPictureEps::extractPostScriptStream" << endl;
- QDataStream data( m_rawData, IO_ReadOnly );
- data.setByteOrder( QDataStream::LittleEndian );
- Q_UINT32 magic, offset, length;
+ TQDataStream data( m_rawData, IO_ReadOnly );
+ data.setByteOrder( TQDataStream::LittleEndian );
+ TQ_UINT32 magic, offset, length;
data >> magic;
data >> offset;
data >> length;
@@ -287,10 +287,10 @@ bool KoPictureEps::extractPostScriptStream( void )
return true;
}
-QString KoPictureEps::readLine( const QByteArray& array, const uint start, const uint length, uint& pos, bool& lastCharWasCr )
+TQString KoPictureEps::readLine( const TQByteArray& array, const uint start, const uint length, uint& pos, bool& lastCharWasCr )
{
- QString strLine;
- const uint finish = kMin( start + length, array.size() );
+ TQString strLine;
+ const uint finish = kMin( start + length, (uint)array.size() );
for ( ; pos < finish; ++pos ) // We are starting at pos
{
const char ch = array[ pos ]; // Read one character
@@ -330,7 +330,7 @@ QString KoPictureEps::readLine( const QByteArray& array, const uint start, const
}
-bool KoPictureEps::loadData(const QByteArray& array, const QString& /* extension */ )
+bool KoPictureEps::loadData(const TQByteArray& array, const TQString& /* extension */ )
{
kdDebug(30003) << "KoPictureEps::load" << endl;
@@ -356,17 +356,17 @@ bool KoPictureEps::loadData(const QByteArray& array, const QString& /* extension
m_psStreamLength = m_rawData.size();
}
- QString lineBox; // Line with the bounding box
+ TQString lineBox; // Line with the bounding box
bool lastWasCr = false; // Was the last character of the line a carriage return?
uint pos = m_psStreamStart; // We start to search the bounding box at the start of the PostScript stream
- QString line( readLine( m_rawData, m_psStreamStart, m_psStreamLength, pos, lastWasCr ) );
+ TQString line( readLine( m_rawData, m_psStreamStart, m_psStreamLength, pos, lastWasCr ) );
kdDebug(30003) << "Header: " << line << endl;
if (!line.startsWith("%!"))
{
kdError(30003) << "Not a PostScript file!" << endl;
return false;
}
- QRect rect;
+ TQRect rect;
bool lineIsBoundingBox = false; // Does "line" has a %%BoundingBox line?
for(;;)
{
@@ -390,7 +390,7 @@ bool KoPictureEps::loadData(const QByteArray& array, const QString& /* extension
return false;
}
// Floating point values are not allowed in a Bounding Box, but ther are many such files out there...
- QRegExp exp("(\\-?[0-9]+\\.?[0-9]*)\\s(\\-?[0-9]+\\.?[0-9]*)\\s(\\-?[0-9]+\\.?[0-9]*)\\s(\\-?[0-9]+\\.?[0-9]*)");
+ TQRegExp exp("(\\-?[0-9]+\\.?[0-9]*)\\s(\\-?[0-9]+\\.?[0-9]*)\\s(\\-?[0-9]+\\.?[0-9]*)\\s(\\-?[0-9]+\\.?[0-9]*)");
if ( exp.search(line) == -1 )
{
// ### TODO: it might be an "(atend)" and the bounding box is in the trailer
@@ -399,7 +399,7 @@ bool KoPictureEps::loadData(const QByteArray& array, const QString& /* extension
kdError(30003) << "Not standard bounding box: " << line << endl;
return false;
}
- kdDebug(30003) << "Reg. Exp. Found: " << exp.capturedTexts() << endl;
+ kdDebug(30003) << "Reg. Exp. Found: " << exp.tqcapturedTexts() << endl;
rect.setLeft((int)exp.cap(1).toDouble());
rect.setTop((int)exp.cap(2).toDouble());
rect.setRight((int)exp.cap(3).toDouble());
@@ -410,30 +410,30 @@ bool KoPictureEps::loadData(const QByteArray& array, const QString& /* extension
return true;
}
-bool KoPictureEps::save(QIODevice* io) const
+bool KoPictureEps::save(TQIODevice* io) const
{
// We save the raw data, to avoid damaging the file by many load/save cycles
- Q_ULONG size=io->writeBlock(m_rawData); // WARNING: writeBlock returns Q_LONG but size() Q_ULONG!
+ TQ_ULONG size=io->writeBlock(m_rawData); // WARNING: writeBlock returns TQ_LONG but size() TQ_ULONG!
return (size==m_rawData.size());
}
-QSize KoPictureEps::getOriginalSize(void) const
+TQSize KoPictureEps::getOriginalSize(void) const
{
return m_originalSize;
}
-QPixmap KoPictureEps::generatePixmap(const QSize& size, bool smoothScale)
+TQPixmap KoPictureEps::generatePixmap(const TQSize& size, bool smoothScale)
{
scaleAndCreatePixmap(size,!smoothScale, 0, 0);
return m_cachedPixmap;
}
-QString KoPictureEps::getMimeType(const QString&) const
+TQString KoPictureEps::getMimeType(const TQString&) const
{
return "image/x-eps";
}
-QImage KoPictureEps::generateImage(const QSize& size)
+TQImage KoPictureEps::generateImage(const TQSize& size)
{
// 0, 0 == resolution unknown
return scaleWithGhostScript(size, 0, 0);
@@ -443,5 +443,5 @@ void KoPictureEps::clearCache(void)
{
m_cachedPixmap.resize(0, 0);
m_cacheIsInFastMode=true;
- m_cachedSize=QSize();
+ m_cachedSize=TQSize();
}