Commit de7a90fc authored by Albert Astals Cid's avatar Albert Astals Cid

2007-02-25 Albert Astals Cid <aacid@kde.org>

        * configure.ac:
        * glib/poppler-document.cc:
        * poppler/GlobalParams.cc:
        * poppler/GlobalParams.h:
        * poppler/PSOutputDev.cc:
        * qt/poppler-document.cc:
        * qt4/src/poppler-document.cc:
        * qt4/src/poppler-private.h:
        * qt4/src/poppler-qt4.h:
        * test/gtk-splash-test.cc:
        * test/pdf-inspector.cc:
        * utils/pdffonts.cc:
        * utils/pdfimages.cc:
        * utils/pdfinfo.cc:
        * utils/pdftohtml.cc:
        * utils/pdftoppm.cc:
        * utils/pdftops.cc:
        * utils/pdftotext.cc: Remove dependency on xpdfrc file and cleanup
                              GlobalParams accordingly
parent 74e70386
2007-02-25 Albert Astals Cid <aacid@kde.org>
* configure.ac:
* glib/poppler-document.cc:
* poppler/GlobalParams.cc:
* poppler/GlobalParams.h:
* poppler/PSOutputDev.cc:
* qt/poppler-document.cc:
* qt4/src/poppler-document.cc:
* qt4/src/poppler-private.h:
* qt4/src/poppler-qt4.h:
* test/gtk-splash-test.cc:
* test/pdf-inspector.cc:
* utils/pdffonts.cc:
* utils/pdfimages.cc:
* utils/pdfinfo.cc:
* utils/pdftohtml.cc:
* utils/pdftoppm.cc:
* utils/pdftops.cc:
* utils/pdftotext.cc: Remove dependency on xpdfrc file and cleanup
GlobalParams accordingly
2007-02-25 Julien Rebetez <julienr@svn.gnome.org>
reviewed by: <aacid@kde.org>
......
......@@ -34,7 +34,6 @@ AC_ARG_ENABLE(fixedpoint,
[ --enable-fixedpoint use fixed point (instead of floating point) arithmetic],
AC_DEFINE(USE_FIXEDPOINT, [1], [Use fixed point arithmetic]))
AC_DEFINE_DIR(SYSTEM_XPDFRC, "{sysconfdir}/xpdfrc", [System wide config file])
AC_DEFINE_DIR(POPPLER_DATADIR, "{datarootdir}/poppler", [Poppler data dir])
dnl ##### Checks for header files.
......
......@@ -127,7 +127,7 @@ poppler_document_new_from_file (const char *uri,
char *filename;
if (!globalParams) {
globalParams = new GlobalParams("/etc/xpdfrc");
globalParams = new GlobalParams();
}
filename = g_filename_from_uri (uri, NULL, error);
......@@ -175,7 +175,7 @@ poppler_document_new_from_data (char *data,
char *filename;
if (!globalParams) {
globalParams = new GlobalParams("/etc/xpdfrc");
globalParams = new GlobalParams();
}
// create stream
......
This diff is collapsed.
......@@ -118,7 +118,7 @@ public:
// Initialize the global parameters by attempting to read a config
// file.
GlobalParams(char *cfgFileName);
GlobalParams();
~GlobalParams();
......@@ -135,12 +135,6 @@ public:
FILE *findCMapFile(GooString *collection, GooString *cMapName);
FILE *findToUnicodeFile(GooString *name);
DisplayFontParam *getDisplayFont(GfxFont *font);
GooString *getPSFile();
int getPSPaperWidth();
int getPSPaperHeight();
void getPSImageableArea(int *llx, int *lly, int *urx, int *ury);
GBool getPSDuplex();
GBool getPSCrop();
GBool getPSExpandSmaller();
GBool getPSShrinkLarger();
GBool getPSCenter();
......@@ -158,13 +152,8 @@ public:
GBool getTextPageBreaks();
GBool getTextKeepTinyChars();
GooString *findFontFile(GooString *fontName, char **exts);
GooString *getInitialZoom();
GBool getContinuousView();
GBool getEnableT1lib();
GBool getEnableFreeType();
GBool getAntialias();
GooString *getURLCommand() { return urlCommand; }
GooString *getMovieCommand() { return movieCommand; }
GBool getMapNumericCharNames();
GBool getPrintCommands();
GBool getProfileCommands();
......@@ -180,14 +169,6 @@ public:
#endif
//----- functions to set parameters
void setPSFile(char *file);
GBool setPSPaperSize(char *size);
void setPSPaperWidth(int width);
void setPSPaperHeight(int height);
void setPSImageableArea(int llx, int lly, int urx, int ury);
void setPSDuplex(GBool duplex);
void setPSCrop(GBool crop);
void setPSExpandSmaller(GBool expand);
void setPSShrinkLarger(GBool shrink);
void setPSCenter(GBool center);
......@@ -202,9 +183,6 @@ public:
GBool setTextEOL(char *s);
void setTextPageBreaks(GBool pageBreaks);
void setTextKeepTinyChars(GBool keep);
void setInitialZoom(char *s);
void setContinuousView(GBool cont);
GBool setEnableT1lib(char *s);
GBool setEnableFreeType(char *s);
GBool setAntialias(char *s);
void setMapNumericCharNames(GBool map);
......@@ -219,28 +197,7 @@ public:
private:
void parseFile(GooString *fileName, FILE *f);
void parseNameToUnicode(GooString *name);
void parseCIDToUnicode(GooList *tokens, GooString *fileName, int line);
void parseUnicodeToUnicode(GooList *tokens, GooString *fileName, int line);
void parseUnicodeMap(GooList *tokens, GooString *fileName, int line);
void parseCMapDir(GooList *tokens, GooString *fileName, int line);
void parseToUnicodeDir(GooList *tokens, GooString *fileName, int line);
void parsePSFile(GooList *tokens, GooString *fileName, int line);
void parsePSPaperSize(GooList *tokens, GooString *fileName, int line);
void parsePSImageableArea(GooList *tokens, GooString *fileName, int line);
void parsePSLevel(GooList *tokens, GooString *fileName, int line);
void parsePSFont(GooList *tokens, GooString *fileName, int line);
void parsePSFont16(char *cmdName, GooList *fontList,
GooList *tokens, GooString *fileName, int line);
void parseTextEncoding(GooList *tokens, GooString *fileName, int line);
void parseTextEOL(GooList *tokens, GooString *fileName, int line);
void parseFontDir(GooList *tokens, GooString *fileName, int line);
void parseInitialZoom(GooList *tokens, GooString *fileName, int line);
void parseCommand(char *cmdName, GooString **val,
GooList *tokens, GooString *fileName, int line);
void parseYesNo(char *cmdName, GBool *flag,
GooList *tokens, GooString *fileName, int line);
GBool parseYesNo2(char *token, GBool *flag);
UnicodeMap *getUnicodeMap2(GooString *encodingName);
......@@ -273,18 +230,9 @@ private:
GooList *toUnicodeDirs; // list of ToUnicode CMap dirs [GooString]
GooHash *displayFonts; // display font info, indexed by font name
// [DisplayFontParam]
GooString *psFile; // PostScript file or command (for xpdf)
int psPaperWidth; // paper size, in PostScript points, for
int psPaperHeight; // PostScript output
int psImageableLLX, // imageable area, in PostScript points,
psImageableLLY, // for PostScript output
psImageableURX,
psImageableURY;
GBool psCrop; // crop PS output to CropBox
GBool psExpandSmaller; // expand smaller pages to fill paper
GBool psShrinkLarger; // shrink larger pages to fit paper
GBool psCenter; // center pages on the paper
GBool psDuplex; // enable duplexing in PostScript?
PSLevel psLevel; // PostScript level to generate
GooHash *psFonts; // PostScript font info, indexed by PDF
// font name [PSFontParam]
......@@ -303,13 +251,8 @@ private:
GBool textPageBreaks; // insert end-of-page markers?
GBool textKeepTinyChars; // keep all characters in text output
GooList *fontDirs; // list of font dirs [GooString]
GooString *initialZoom; // initial zoom level
GBool continuousView; // continuous view mode
GBool enableT1lib; // t1lib enable flag
GBool enableFreeType; // FreeType enable flag
GBool antialias; // anti-aliasing enable flag
GooString *urlCommand; // command executed for URL links
GooString *movieCommand; // command executed for movie annotations
GBool mapNumericCharNames; // map numeric char names (from font subsets)?
GBool printCommands; // print the drawing commands
GBool profileCommands; // profile the drawing commands
......
......@@ -1005,14 +1005,6 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA,
paperHeight = 1;
}
}
if (imgLLX == 0 && imgURX == 0 && imgLLY == 0 && imgURY == 0) {
globalParams->getPSImageableArea(&imgLLX, &imgLLY, &imgURX, &imgURY);
if (imgURX <= 0 || imgURY <= 0) {
imgLLX = imgLLY = 0;
imgURX = paperWidth;
imgURY = paperHeight;
}
}
manualCtrl = manualCtrlA;
if (mode == psModeForm) {
lastPage = firstPage;
......
......@@ -35,7 +35,7 @@ namespace Poppler {
Document *Document::load(const QString &filePath)
{
if (!globalParams) {
globalParams = new GlobalParams("/etc/xpdfrc");
globalParams = new GlobalParams();
}
DocumentData *doc = new DocumentData(new GooString(QFile::encodeName(filePath)), NULL);
......@@ -327,7 +327,7 @@ bool Document::print(const QString &file, QValueList<int> pageList, double hDPI,
if (psOut->isOk()) {
QValueList<int>::iterator it;
for (it = pageList.begin(); it != pageList.end(); ++it )
data->doc.displayPage(psOut, *it, hDPI, vDPI, rotate, gFalse, globalParams->getPSCrop(), gFalse);
data->doc.displayPage(psOut, *it, hDPI, vDPI, rotate, gFalse, gTrue, gFalse);
delete psOut;
return true;
......
......@@ -431,7 +431,7 @@ namespace Poppler {
{
foreach(int page, pageList)
{
m_doc->doc->displayPage(psOut, page, hDPI, vDPI, rotate, gFalse, globalParams->getPSCrop(), gFalse);
m_doc->doc->displayPage(psOut, page, hDPI, vDPI, rotate, gFalse, gTrue, gFalse);
}
delete psOut;
......
......@@ -95,7 +95,7 @@ namespace Poppler {
delete ownerPassword;
delete userPassword;
if ( count == 0 ) globalParams = new GlobalParams("/etc/xpdfrc");
if ( count == 0 ) globalParams = new GlobalParams();
count ++;
}
......
......@@ -450,8 +450,12 @@ namespace Poppler {
\param filePath the name (and path, if required) of the file to load
\return NULL on error
\warning The application owns the pointer to Document, and this should
be deleted when no longer required.
\warning The returning document may be locked.
*/
static Document *load(const QString & filePath,
const QByteArray &ownerPassword=QByteArray(),
......@@ -780,7 +784,7 @@ height = dummy.height();
/**
Container class for a sound file in a PDF document.
A sound can be either External (in that case should be loaded the file
A sound can be either External (in that case should be loaded the file
whose url is represented by url() ), or Embedded, and the player has to
play the data contained in data().
*/
......
......@@ -275,7 +275,7 @@ main (int argc, char *argv [])
gtk_init (&argc, &argv);
globalParams = new GlobalParams("/etc/xpdfrc");
globalParams = new GlobalParams();
if (argc == 1)
{
......
......@@ -331,7 +331,7 @@ main (int argc, char *argv [])
gtk_init (&argc, &argv);
globalParams = new GlobalParams("/etc/xpdfrc");
globalParams = new GlobalParams();
globalParams->setProfileCommands (true);
if (argc == 2)
......
......@@ -43,7 +43,6 @@ static int firstPage = 1;
static int lastPage = 0;
static char ownerPassword[33] = "\001";
static char userPassword[33] = "\001";
static char cfgFileName[256] = "";
static GBool printVersion = gFalse;
static GBool printHelp = gFalse;
......@@ -56,8 +55,6 @@ static ArgDesc argDesc[] = {
"owner password (for encrypted files)"},
{"-upw", argString, userPassword, sizeof(userPassword),
"user password (for encrypted files)"},
{"-cfg", argString, cfgFileName, sizeof(cfgFileName),
"configuration file to use in place of .xpdfrc"},
{"-v", argFlag, &printVersion, 0,
"print copyright and version info"},
{"-h", argFlag, &printHelp, 0,
......@@ -102,7 +99,7 @@ int main(int argc, char *argv[]) {
fileName = new GooString(argv[1]);
// read config file
globalParams = new GlobalParams(cfgFileName);
globalParams = new GlobalParams();
// open PDF file
if (ownerPassword[0] != '\001') {
......
......@@ -35,7 +35,6 @@ static GBool dumpJPEG = gFalse;
static char ownerPassword[33] = "\001";
static char userPassword[33] = "\001";
static GBool quiet = gFalse;
static char cfgFileName[256] = "";
static GBool printVersion = gFalse;
static GBool printHelp = gFalse;
......@@ -52,8 +51,6 @@ static ArgDesc argDesc[] = {
"user password (for encrypted files)"},
{"-q", argFlag, &quiet, 0,
"don't print any messages or errors"},
{"-cfg", argString, cfgFileName, sizeof(cfgFileName),
"configuration file to use in place of .xpdfrc"},
{"-v", argFlag, &printVersion, 0,
"print copyright and version info"},
{"-h", argFlag, &printHelp, 0,
......@@ -92,7 +89,7 @@ int main(int argc, char *argv[]) {
imgRoot = argv[2];
// read config file
globalParams = new GlobalParams(cfgFileName);
globalParams = new GlobalParams();
if (quiet) {
globalParams->setErrQuiet(quiet);
}
......
......@@ -43,7 +43,6 @@ static GBool printMetadata = gFalse;
static char textEncName[128] = "";
static char ownerPassword[33] = "\001";
static char userPassword[33] = "\001";
static char cfgFileName[256] = "";
static GBool printVersion = gFalse;
static GBool printHelp = gFalse;
......@@ -62,8 +61,6 @@ static ArgDesc argDesc[] = {
"owner password (for encrypted files)"},
{"-upw", argString, userPassword, sizeof(userPassword),
"user password (for encrypted files)"},
{"-cfg", argString, cfgFileName, sizeof(cfgFileName),
"configuration file to use in place of .xpdfrc"},
{"-v", argFlag, &printVersion, 0,
"print copyright and version info"},
{"-h", argFlag, &printHelp, 0,
......@@ -108,7 +105,7 @@ int main(int argc, char *argv[]) {
fileName = new GooString(argv[1]);
// read config file
globalParams = new GlobalParams(cfgFileName);
globalParams = new GlobalParams();
if (textEncName[0]) {
globalParams->setTextEncoding(textEncName);
}
......
......@@ -142,7 +142,7 @@ int main(int argc, char *argv[]) {
//errorInit();
// read config file
globalParams = new GlobalParams("");
globalParams = new GlobalParams();
if (errQuiet) {
globalParams->setErrQuiet(errQuiet);
......
......@@ -24,13 +24,11 @@ static int lastPage = 0;
static int resolution = 150;
static GBool mono = gFalse;
static GBool gray = gFalse;
static char enableT1libStr[16] = "";
static char enableFreeTypeStr[16] = "";
static char antialiasStr[16] = "";
static char ownerPassword[33] = "";
static char userPassword[33] = "";
static GBool quiet = gFalse;
static char cfgFileName[256] = "";
static GBool printVersion = gFalse;
static GBool printHelp = gFalse;
......@@ -45,10 +43,6 @@ static ArgDesc argDesc[] = {
"generate a monochrome PBM file"},
{"-gray", argFlag, &gray, 0,
"generate a grayscale PGM file"},
#if HAVE_T1LIB_H
{"-t1lib", argString, enableT1libStr, sizeof(enableT1libStr),
"enable t1lib font rasterizer: yes, no"},
#endif
#if HAVE_FREETYPE_FREETYPE_H | HAVE_FREETYPE_H
{"-freetype", argString, enableFreeTypeStr, sizeof(enableFreeTypeStr),
"enable FreeType font rasterizer: yes, no"},
......@@ -61,8 +55,6 @@ static ArgDesc argDesc[] = {
"user password (for encrypted files)"},
{"-q", argFlag, &quiet, 0,
"don't print any messages or errors"},
{"-cfg", argString, cfgFileName, sizeof(cfgFileName),
"configuration file to use in place of .xpdfrc"},
{"-v", argFlag, &printVersion, 0,
"print copyright and version info"},
{"-h", argFlag, &printHelp, 0,
......@@ -107,12 +99,7 @@ int main(int argc, char *argv[]) {
ppmRoot = argv[2];
// read config file
globalParams = new GlobalParams(cfgFileName);
if (enableT1libStr[0]) {
if (!globalParams->setEnableT1lib(enableT1libStr)) {
fprintf(stderr, "Bad '-t1lib' value on command line\n");
}
}
globalParams = new GlobalParams();
if (enableFreeTypeStr[0]) {
if (!globalParams->setEnableFreeType(enableFreeTypeStr)) {
fprintf(stderr, "Bad '-freetype' value on command line\n");
......
......@@ -29,6 +29,28 @@
#include "PSOutputDev.h"
#include "Error.h"
GBool setPSPaperSize(char *size, int &psPaperWidth, int &psPaperHeight) {
if (!strcmp(size, "match")) {
psPaperWidth = psPaperHeight = -1;
} else if (!strcmp(size, "letter")) {
psPaperWidth = 612;
psPaperHeight = 792;
} else if (!strcmp(size, "legal")) {
psPaperWidth = 612;
psPaperHeight = 1008;
} else if (!strcmp(size, "A4")) {
psPaperWidth = 595;
psPaperHeight = 842;
} else if (!strcmp(size, "A3")) {
psPaperWidth = 842;
psPaperHeight = 1190;
} else {
return gFalse;
}
return gTrue;
}
static int firstPage = 1;
static int lastPage = 0;
static GBool level1 = gFalse;
......@@ -57,7 +79,6 @@ static GBool duplex = gFalse;
static char ownerPassword[33] = "\001";
static char userPassword[33] = "\001";
static GBool quiet = gFalse;
static char cfgFileName[256] = "";
static GBool printVersion = gFalse;
static GBool printHelp = gFalse;
......@@ -116,8 +137,6 @@ static ArgDesc argDesc[] = {
"user password (for encrypted files)"},
{"-q", argFlag, &quiet, 0,
"don't print any messages or errors"},
{"-cfg", argString, cfgFileName, sizeof(cfgFileName),
"configuration file to use in place of .xpdfrc"},
{"-v", argFlag, &printVersion, 0,
"print copyright and version info"},
{"-h", argFlag, &printHelp, 0,
......@@ -191,23 +210,13 @@ int main(int argc, char *argv[]) {
fileName = new GooString(argv[1]);
// read config file
globalParams = new GlobalParams(cfgFileName);
globalParams = new GlobalParams();
if (paperSize[0]) {
if (!globalParams->setPSPaperSize(paperSize)) {
if (!setPSPaperSize(paperSize, paperWidth, paperHeight)) {
fprintf(stderr, "Invalid paper size\n");
delete fileName;
goto err0;
}
} else {
if (paperWidth) {
globalParams->setPSPaperWidth(paperWidth);
}
if (paperHeight) {
globalParams->setPSPaperHeight(paperHeight);
}
}
if (noCrop) {
globalParams->setPSCrop(gFalse);
}
if (expand) {
globalParams->setPSExpandSmaller(gTrue);
......@@ -218,9 +227,6 @@ int main(int argc, char *argv[]) {
if (noCenter) {
globalParams->setPSCenter(gFalse);
}
if (duplex) {
globalParams->setPSDuplex(duplex);
}
if (level1 || level1Sep || level2 || level2Sep || level3 || level3Sep) {
globalParams->setPSLevel(level);
}
......@@ -308,12 +314,12 @@ int main(int argc, char *argv[]) {
// write PostScript file
psOut = new PSOutputDev(psFileName->getCString(), doc->getXRef(),
doc->getCatalog(), firstPage, lastPage, mode,
globalParams->getPSPaperWidth(),
globalParams->getPSPaperHeight(),
globalParams->getPSDuplex());
paperWidth,
paperHeight,
duplex);
if (psOut->isOk()) {
doc->displayPages(psOut, firstPage, lastPage, 72, 72,
0, globalParams->getPSCrop(), gFalse, gFalse);
0, !noCrop, gFalse, gFalse);
} else {
delete psOut;
exitCode = 2;
......
......@@ -47,7 +47,6 @@ static GBool noPageBreaks = gFalse;
static char ownerPassword[33] = "\001";
static char userPassword[33] = "\001";
static GBool quiet = gFalse;
static char cfgFileName[256] = "";
static GBool printVersion = gFalse;
static GBool printHelp = gFalse;
......@@ -74,8 +73,6 @@ static ArgDesc argDesc[] = {
"user password (for encrypted files)"},
{"-q", argFlag, &quiet, 0,
"don't print any messages or errors"},
{"-cfg", argString, cfgFileName, sizeof(cfgFileName),
"configuration file to use in place of .xpdfrc"},
{"-v", argFlag, &printVersion, 0,
"print copyright and version info"},
{"-h", argFlag, &printHelp, 0,
......@@ -117,7 +114,7 @@ int main(int argc, char *argv[]) {
fileName = new GooString(argv[1]);
// read config file
globalParams = new GlobalParams(cfgFileName);
globalParams = new GlobalParams();
if (textEncName[0]) {
globalParams->setTextEncoding(textEncName);
}
......
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