qt3support--

svn path=/trunk/KDE/kdegraphics/kviewshell/plugins/dvi/; revision=536075
This commit is contained in:
Wilfried Huss 2006-05-01 09:22:49 +00:00
parent 888f9b2ca4
commit 24931b0e39
9 changed files with 57 additions and 59 deletions

View file

@ -51,7 +51,7 @@ TeXFont_TFM::TeXFont_TFM(TeXFontDefinition *parent)
}
// Data from the HEADER section of the TFM data.
file.at(24);
file.seek(24);
stream >> checksum >> design_size_in_TeX_points.value;
#ifdef DEBUG_TFM
kDebug(kvs::dvi) << "checksum = " << checksum << endl
@ -64,7 +64,7 @@ TeXFont_TFM::TeXFont_TFM(TeXFontDefinition *parent)
for(unsigned int i=0; i<TeXFontDefinition::max_num_of_chars_in_font; i++)
widthTable_in_units_of_design_size[i].value = 0;
file.at( 24 + 4*lh + 4*(ec-bc) );
file.seek( 24 + 4*lh + 4*(ec-bc) );
for(unsigned int i=0; i<nw; i++) {
stream >> widthTable_in_units_of_design_size[i].value;
@ -86,7 +86,7 @@ TeXFont_TFM::TeXFont_TFM(TeXFontDefinition *parent)
}
// Char-Info table
file.at( 24 + 4*lh );
file.seek( 24 + 4*lh );
for(unsigned int characterCode=bc; characterCode<ec; characterCode++) {
glyph *g = glyphtable+characterCode;

View file

@ -61,6 +61,7 @@
#include <klocale.h>
#include <QProcess>
#include <QSysInfo>
#include <QTemporaryFile>
#include <cstdlib>
@ -281,7 +282,7 @@ dvifile::dvifile(const QString& fname, fontPool* pool)
have_complainedAboutMissingPDF2PS = false;
QFile file(fname);
filename = file.name();
filename = file.fileName();
file.open( QIODevice::ReadOnly );
size_of_file = file.size();
dviData.resize(size_of_file);
@ -292,9 +293,9 @@ dvifile::dvifile(const QString& fname, fontPool* pool)
kError(kvs::dvi) << i18n("Not enough memory to load the DVI-file.");
return;
}
file.readBlock((char *)dvi_Data(), size_of_file);
file.read((char *)dvi_Data(), size_of_file);
file.close();
if (file.status() != QFile::Status(IO_Ok)) {
if (file.error() != QFile::NoError) {
kError(kvs::dvi) << i18n("Could not load the DVI-file.");
return;
}
@ -336,9 +337,7 @@ void dvifile::renumber()
// Write the page number to the file, taking good care of byte
// orderings.
int wordSize;
bool bigEndian;
qSysInfo (&wordSize, &bigEndian);
bool bigEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian);
for(int i=1; i<=total_pages; i++) {
quint8 *ptr = dviData.data() + page_offset[i-1]+1;
@ -365,7 +364,7 @@ QString dvifile::convertPDFtoPS(const QString &PDFFilename, QString *converrorms
QMap<QString, QString>::Iterator it = convertedFiles.find(PDFFilename);
if (it != convertedFiles.end()) {
// PDF-File is known. Good.
return it.data();
return it.value();
}
// Get the name of a temporary file.
@ -436,7 +435,7 @@ bool dvifile::saveAs(const QString &filename)
QFile out(filename);
if (out.open( QIODevice::WriteOnly ) == false)
return false;
if (out.writeBlock ( (char *)(dvi_Data()), size_of_file ) == -1)
if (out.write ( (char *)(dvi_Data()), size_of_file ) == -1)
return false;
out.close();
return true;

View file

@ -58,7 +58,7 @@ void dviRenderer::prescan_embedPS(char *cp, quint8 *beginningOfSpecialCommand)
// (already the simplified() above is wrong). If you have
// files like this, go away.
QString EPSfilename = include_command;
EPSfilename.truncate(EPSfilename.find(' '));
EPSfilename.truncate(EPSfilename.indexOf(' '));
// Strip enclosing quotation marks which are included by some LaTeX
// macro packages (but not by others). This probably means that
@ -118,7 +118,7 @@ void dviRenderer::prescan_embedPS(char *cp, quint8 *beginningOfSpecialCommand)
int angle = 0;
// just to avoid ambiguities; the filename could contain keywords
include_command = include_command.mid(include_command.find(' '));
include_command = include_command.mid(include_command.indexOf(' '));
parse_special_argument(include_command, "llx=", &llx);
parse_special_argument(include_command, "lly=", &lly);
@ -128,7 +128,7 @@ void dviRenderer::prescan_embedPS(char *cp, quint8 *beginningOfSpecialCommand)
parse_special_argument(include_command, "rhi=", &rhi);
parse_special_argument(include_command, "angle=", &angle);
int clip=include_command.find(" clip"); // -1 if clip keyword is not present, >= 0 otherwise
int clip=include_command.indexOf(" clip"); // -1 if clip keyword is not present, >= 0 otherwise
// Generate the PostScript commands to be included
QString PS = QString("ps: @beginspecial %1 @llx %2 @lly %3 @urx %4 @ury").arg(llx).arg(lly).arg(urx).arg(ury);
@ -169,7 +169,7 @@ void dviRenderer::prescan_embedPS(char *cp, quint8 *beginningOfSpecialCommand)
command_pointer[0] = XXX4;
command_pointer++;
writeUINT32(PS.length());
memcpy(newDVI.data()+(beginningOfSpecialCommand-dviFile->dvi_Data())+5, PS.latin1(), PS.length() );
memcpy(newDVI.data()+(beginningOfSpecialCommand-dviFile->dvi_Data())+5, PS.toLatin1(), PS.length() );
memcpy(newDVI.data()+(beginningOfSpecialCommand-dviFile->dvi_Data())+lengthOfNewSpecial, beginningOfSpecialCommand+lengthOfOldSpecial,
dviFile->size_of_file-(beginningOfSpecialCommand-dviFile->dvi_Data())-lengthOfOldSpecial );
@ -270,7 +270,7 @@ void dviRenderer::prescan_ParseBackgroundSpecial(const QString& cp)
void dviRenderer::prescan_ParseHTMLAnchorSpecial(const QString& _cp)
{
QString cp = _cp;
cp.truncate(cp.find('"'));
cp.truncate(cp.indexOf('"'));
Length l;
l.setLength_in_inch(currinf.data.dvi_v/(resolutionInDPI*shrinkfactor));
anchorList[cp] = Anchor(current_page+1, l);
@ -373,14 +373,14 @@ void dviRenderer::prescan_ParsePSSpecial(const QString& cp)
double PS_H = (currinf.data.dvi_h*300.0)/(65536*1200)-300;
double PS_V = (currinf.data.dvi_v*300.0)/1200 - 300;
if (cp.find("ps::[begin]", 0, false) == 0) {
if (cp.indexOf("ps::[begin]", 0, Qt::CaseInsensitive) == 0) {
PostScriptOutPutString->append( QString(" %1 %2 moveto\n").arg(PS_H).arg(PS_V) );
PostScriptOutPutString->append( QString(" %1\n").arg(cp.mid(11)) );
} else {
if (cp.find("ps::[end]", 0, false) == 0) {
if (cp.indexOf("ps::[end]", 0, Qt::CaseInsensitive) == 0) {
PostScriptOutPutString->append( QString(" %1\n").arg(cp.mid(9)) );
} else {
if (cp.find("ps::", 0, false) == 0) {
if (cp.indexOf("ps::", 0, Qt::CaseInsensitive) == 0) {
PostScriptOutPutString->append( QString(" %1\n").arg(cp.mid(4)) );
} else {
PostScriptOutPutString->append( QString(" %1 %2 moveto\n").arg(PS_H).arg(PS_V) );
@ -405,7 +405,7 @@ void dviRenderer::prescan_ParsePSFileSpecial(const QString& cp)
// (already the simplified() above is wrong). If you have
// files like this, go away.
QString EPSfilename = include_command;
EPSfilename.truncate(EPSfilename.find(' '));
EPSfilename.truncate(EPSfilename.indexOf(' '));
// Strip enclosing quotation marks which are included by some LaTeX
// macro packages (but not by others). This probably means that
@ -417,7 +417,7 @@ void dviRenderer::prescan_ParsePSFileSpecial(const QString& cp)
// If the file name ends in 'png', 'gif', 'jpg' or 'jpeg', we assume
// that this is NOT a PostScript file, and we exit here.
QString ending = EPSfilename.section('.', -1).lower();
QString ending = EPSfilename.section('.', -1).toLower();
if ((ending == "png") || (ending == "gif") || (ending == "jpg") || (ending == "jpeg")) {
dviFile->numberOfExternalNONPSFiles++;
return;
@ -455,7 +455,7 @@ void dviRenderer::prescan_ParsePSFileSpecial(const QString& cp)
int angle = 0;
// just to avoid ambiguities; the filename could contain keywords
include_command = include_command.mid(include_command.find(' '));
include_command = include_command.mid(include_command.indexOf(' '));
parse_special_argument(include_command, "llx=", &llx);
parse_special_argument(include_command, "lly=", &lly);
@ -465,7 +465,7 @@ void dviRenderer::prescan_ParsePSFileSpecial(const QString& cp)
parse_special_argument(include_command, "rhi=", &rhi);
parse_special_argument(include_command, "angle=", &angle);
int clip=include_command.find(" clip"); // -1 if clip keyword is not present, >= 0 otherwise
int clip=include_command.indexOf(" clip"); // -1 if clip keyword is not present, >= 0 otherwise
if (QFile::exists(EPSfilename)) {
double PS_H = (currinf.data.dvi_h*300.0)/(65536*1200)-300;

View file

@ -268,7 +268,7 @@ DVIExportToPDF::DVIExportToPDF(dviRenderer& parent, QWidget* parent_widget)
}
// Generate a suggestion for a reasonable file name
const QString suggested_name = dvi.filename.left(dvi.filename.find(".")) + ".pdf";
const QString suggested_name = dvi.filename.left(dvi.filename.indexOf(".")) + ".pdf";
const QString output_name = KFileDialog::getSaveFileName(suggested_name, i18n("*.pdf|Portable Document Format (*.pdf)"), parent_widget, i18n("Export File As"));
if (output_name.isEmpty())
return;
@ -300,7 +300,7 @@ DVIExportToPDF::DVIExportToPDF(dviRenderer& parent, QWidget* parent_widget)
QStringList() << "-o"
<< output_name
<< dvi.filename,
QFileInfo(dvi.filename).dirPath(true),
QFileInfo(dvi.filename).absolutePath(),
i18n("<qt>The external program 'dvipdfm', which was used to export the file, reported an error. "
"You might wish to look at the <strong>document info dialog</strong> which you will "
"find in the File-Menu for a precise error report.</qt>"));
@ -353,7 +353,7 @@ DVIExportToPS::DVIExportToPS(dviRenderer& parent,
} else {
// Generate a suggestion for a reasonable file name
const QString suggested_name = dvi.filename.left(dvi.filename.find(".")) + ".ps";
const QString suggested_name = dvi.filename.left(dvi.filename.indexOf(".")) + ".ps";
output_name_ = KFileDialog::getSaveFileName(suggested_name, i18n("*.ps|PostScript (*.ps)"), parent_widget, i18n("Export File As"));
if (output_name_.isEmpty())
return;
@ -465,7 +465,7 @@ DVIExportToPS::DVIExportToPS(dviRenderer& parent,
start("dvips",
args,
QFileInfo(dvi.filename).dirPath(true),
QFileInfo(dvi.filename).absolutePath(),
i18n("<qt>The external program 'dvips', which was used to export the file, reported an error. "
"You might wish to look at the <strong>document info dialog</strong> which you will "
"find in the File-Menu for a precise error report.</qt>"));

View file

@ -50,7 +50,7 @@ DVI_SourceFileSplitter::DVI_SourceFileSplitter(const QString &srclink, const QSt
#endif
//test if the file exists
m_fileInfo.setFile(QFileInfo(dviFile).dir(true), filepart);
m_fileInfo.setFile(QFileInfo(dviFile).absoluteDir(), filepart);
bool fiExists = m_fileInfo.exists();
//if it doesn't exist, but adding ".tex"

View file

@ -89,7 +89,7 @@ fontMap::fontMap()
encodingName = encodingName.mid(1);
double slant = 0.0;
int i = line.find("SlantFont");
int i = line.indexOf("SlantFont");
if (i >= 0) {
bool ok;
slant = line.left(i).section(' ', -1, -1 ,QString::SectionSkipEmpty).toDouble(&ok);
@ -129,7 +129,7 @@ const QString &fontMap::findFileName(const QString &TeXName)
QMap<QString, fontMapEntry>::Iterator it = fontMapEntries.find(TeXName);
if (it != fontMapEntries.end())
return it.data().fontFileName;
return it.value().fontFileName;
static const QString nullstring(QString::null);
return nullstring;
@ -141,7 +141,7 @@ const QString &fontMap::findFontName(const QString &TeXName)
QMap<QString, fontMapEntry>::Iterator it = fontMapEntries.find(TeXName);
if (it != fontMapEntries.end())
return it.data().fullFontName;
return it.value().fullFontName;
static const QString nullstring(QString::null);
return nullstring;
@ -153,7 +153,7 @@ const QString &fontMap::findEncoding(const QString &TeXName)
QMap<QString, fontMapEntry>::Iterator it = fontMapEntries.find(TeXName);
if (it != fontMapEntries.end())
return it.data().fontEncoding;
return it.value().fontEncoding;
static const QString nullstring(QString::null);
return nullstring;
@ -165,7 +165,7 @@ double fontMap::findSlant(const QString &TeXName)
QMap<QString, fontMapEntry>::Iterator it = fontMapEntries.find(TeXName);
if (it != fontMapEntries.end())
return it.data().slant;
return it.value().slant;
else
return 0.0;
}

View file

@ -47,7 +47,7 @@ fontPool::fontPool()
kDebug(kvs::dvi) << "fontPool::fontPool() called" << endl;
#endif
setName("Font Pool");
setObjectName("Font Pool");
displayResolution_in_dpi = 100.0; // A not-too-bad-default
useFontHints = true;
@ -75,8 +75,7 @@ fontPool::fontPool()
// of QT at compile and runtime or the availability of the XFt
// extension, alpha channels are either supported, or silently
// ignored.
QImage start(1, 1, 32); // Generate a 1x1 image, black with alpha=0x10
start.setAlphaBuffer(true);
QImage start(1, 1, QImage::Format_ARGB32); // Generate a 1x1 image, black with alpha=0x10
quint32 *destScanLine = (quint32 *)start.scanLine(0);
*destScanLine = 0x80000000;
QPixmap intermediate = QPixmap::fromImage(start);
@ -85,7 +84,7 @@ fontPool::fontPool()
QPainter paint( &dest );
paint.drawPixmap(0, 0, intermediate);
paint.end();
start = dest.toImage().convertDepth(32);
start = dest.toImage().convertToFormat(QImage::Format_ARGB32);
quint8 result = *(start.scanLine(0)) & 0xff;
if ((result == 0xff) || (result == 0x00)) {
@ -400,10 +399,10 @@ void fontPool::locateFonts(bool makePK, bool locateTFMonly, bool *virtualFontsFo
#ifdef HAVE_FREETYPE
const QString &fn = fontsByTeXName.findFileName(fontp->fontname);
if (!fn.isEmpty())
matchingFiles = fileNameList.grep(fn);
matchingFiles = fileNameList.filter(fn);
#endif
if (matchingFiles.isEmpty() == true)
matchingFiles += fileNameList.grep(fontp->fontname+".");
matchingFiles += fileNameList.filter(fontp->fontname+".");
if (matchingFiles.isEmpty() != true) {
#ifdef DEBUG_FONTPOOL
@ -533,23 +532,23 @@ void fontPool::mf_output_receiver()
// We'd like to print only full lines of text.
int numleft;
bool show_prog = false;
while( (numleft = MetafontOutput.find('\n')) != -1) {
while( (numleft = MetafontOutput.indexOf('\n')) != -1) {
QString line = MetafontOutput.left(numleft+1);
#ifdef DEBUG_FONTPOOL
kDebug(kvs::dvi) << "MF OUTPUT RECEIVED: " << line;
#endif
// Search for a line which marks the beginning of a MetaFont run
// and show the progress dialog at the end of this method.
if (line.find("kpathsea:") == 0)
if (line.indexOf("kpathsea:") == 0)
show_prog = true;
// If the Output of the kpsewhich program contains a line starting
// with "kpathsea:", this means that a new MetaFont-run has been
// started. We filter these lines out and update the display
// accordingly.
int startlineindex = line.find("kpathsea:");
int startlineindex = line.indexOf("kpathsea:");
if (startlineindex != -1) {
int endstartline = line.find("\n",startlineindex);
int endstartline = line.indexOf("\n",startlineindex);
QString startLine = line.mid(startlineindex,endstartline-startlineindex);
// The last word in the startline is the name of the font which we

View file

@ -192,18 +192,18 @@ void ghostscript_interface::gs_generate_graphics_file(const PageNumber& page, co
<< "1 0 bop 0 0 a \n";
if (PostScriptHeaderString->latin1() != NULL)
os << PostScriptHeaderString->latin1();
os << PostScriptHeaderString->toLatin1();
if (info->background != Qt::white) {
QString colorCommand = QString("gsave %1 %2 %3 setrgbcolor clippath fill grestore\n").
arg(info->background.red()/255.0).
arg(info->background.green()/255.0).
arg(info->background.blue()/255.0);
os << colorCommand.latin1();
os << colorCommand.toLatin1();
}
if (info->PostScriptString->latin1() != NULL)
os << info->PostScriptString->latin1();
os << info->PostScriptString->toLatin1();
os << "end\n"
<< "showpage \n";
@ -211,7 +211,7 @@ void ghostscript_interface::gs_generate_graphics_file(const PageNumber& page, co
PSfile.close();
// Step 2: Call GS with the File
QFile::remove(filename.ascii());
QFile::remove(filename.toAscii());
KProcIO proc;
QStringList argus;
argus << "gs";
@ -222,7 +222,7 @@ void ghostscript_interface::gs_generate_graphics_file(const PageNumber& page, co
argus << QString("-g%1x%2").arg(pixel_page_w).arg(pixel_page_h); // page size in pixels
argus << QString("-r%1").arg(resolution); // resolution in dpi
argus << "-c" << "<< /PermitFileReading [ ExtraIncludePath ] /PermitFileWriting [] /PermitFileControl [] >> setuserparams .locksafe";
argus << "-f" << PSfile.name();
argus << "-f" << PSfileName;
#ifdef DEBUG_PSGS
kdDebug(kvs::dvi) << argus.join(" ") << endl;
@ -232,7 +232,7 @@ void ghostscript_interface::gs_generate_graphics_file(const PageNumber& page, co
if (proc.start(KProcess::Block) == false) {
// Starting ghostscript did not work.
// TODO: Issue error message, switch PS support off.
kdError(kvs::dvi) << "ghostview could not be started" << endl;
kError(kvs::dvi) << "ghostview could not be started" << endl;
}
PSfile.remove();

View file

@ -119,7 +119,7 @@ QColor dviRenderer::parseColorSpecification(const QString& colorSpec)
QString specType = colorSpec.section(' ', 0, 0);
if (specType.find("rgb", false) == 0) {
if (specType.indexOf("rgb", 0, Qt::CaseInsensitive) == 0) {
bool ok;
double r = colorSpec.section(' ', 1, 1).toDouble(&ok);
@ -137,7 +137,7 @@ QColor dviRenderer::parseColorSpecification(const QString& colorSpec)
return QColor((int)(r*255.0+0.5), (int)(g*255.0+0.5), (int)(b*255.0+0.5));
}
if (specType.find("hsb", false) == 0) {
if (specType.indexOf("hsb", 0, Qt::CaseInsensitive) == 0) {
bool ok;
double h = colorSpec.section(' ', 1, 1).toDouble(&ok);
@ -155,7 +155,7 @@ QColor dviRenderer::parseColorSpecification(const QString& colorSpec)
return QColor((int)(h*359.0+0.5), (int)(s*255.0+0.5), (int)(b*255.0+0.5), QColor::Hsv);
}
if (specType.find("cmyk", false) == 0) {
if (specType.indexOf("cmyk", 0, Qt::CaseInsensitive) == 0) {
bool ok;
double c = colorSpec.section(' ', 1, 1).toDouble(&ok);
@ -188,7 +188,7 @@ QColor dviRenderer::parseColorSpecification(const QString& colorSpec)
return QColor((int)(r*255.0+0.5), (int)(g*255.0+0.5), (int)(b*255.0+0.5));
}
if (specType.find("gray", false) == 0) {
if (specType.indexOf("gray", 0, Qt::CaseInsensitive) == 0) {
bool ok;
double g = colorSpec.section(' ', 1, 1).toDouble(&ok);
@ -249,10 +249,10 @@ void dviRenderer::color_special(const QString& _cp)
void dviRenderer::html_href_special(const QString& _cp)
{
QString cp = _cp;
cp.truncate(cp.find('"'));
cp.truncate(cp.indexOf('"'));
#ifdef DEBUG_SPECIAL
kDebug(kvs::dvi) << "HTML-special, href " << cp.latin1() << endl;
kDebug(kvs::dvi) << "HTML-special, href " << cp.toLatin1() << endl;
#endif
HTML_href = new QString(cp);
}
@ -287,10 +287,10 @@ void dviRenderer::source_special(const QString& cp)
void parse_special_argument(const QString& strg, const char* argument_name, int* variable)
{
int index = strg.find(argument_name);
int index = strg.indexOf(argument_name);
if (index >= 0) {
QString tmp = strg.mid(index + strlen(argument_name));
index = tmp.find(' ');
index = tmp.indexOf(' ');
if (index >= 0)
tmp.truncate(index);
@ -322,7 +322,7 @@ void dviRenderer::epsf_special(const QString& cp)
// (already the simplified() above is wrong). If you have
// files like this, go away.
QString EPSfilename_orig = include_command;
EPSfilename_orig.truncate(EPSfilename_orig.find(' '));
EPSfilename_orig.truncate(EPSfilename_orig.indexOf(' '));
// Strip enclosing quotation marks which are included by some LaTeX
// macro packages (but not by others). This probably means that
@ -343,7 +343,7 @@ void dviRenderer::epsf_special(const QString& cp)
int angle = 0;
// just to avoid ambiguities; the filename could contain keywords
include_command = include_command.mid(include_command.find(' '));
include_command = include_command.mid(include_command.indexOf(' '));
parse_special_argument(include_command, "llx=", &llx);
parse_special_argument(include_command, "lly=", &lly);