Workaround for Dano/Zeta is required because it does not store all fields from the BMessage returned by config_job in the spool file, we add the missing fields that are stored in an attribute of the printer folder.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5490 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -50,8 +50,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
Cache::Cache()
|
Cache::Cache()
|
||||||
: fNextID(0)
|
: fPass(0)
|
||||||
, fPass(0)
|
, fNextID(0)
|
||||||
{};
|
{};
|
||||||
|
|
||||||
void Cache::NextPass() {
|
void Cache::NextPass() {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ THE SOFTWARE.
|
|||||||
#include "InterfaceUtils.h"
|
#include "InterfaceUtils.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#if HAVE_FULLVERSION_PDF_LIB
|
||||||
// pdflib 5.x supports password protection and permissions in the commercial license only!
|
// pdflib 5.x supports password protection and permissions in the commercial license only!
|
||||||
static const PermissionLabels gPermissionLabels[] = {
|
static const PermissionLabels gPermissionLabels[] = {
|
||||||
PermissionLabels("Prevent printing the file.", "noprint"),
|
PermissionLabels("Prevent printing the file.", "noprint"),
|
||||||
@@ -76,6 +77,7 @@ void Permissions::Encode(BString* s) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
DocInfoWindow::DocInfoWindow(BMessage *doc_info)
|
DocInfoWindow::DocInfoWindow(BMessage *doc_info)
|
||||||
@@ -90,16 +92,20 @@ DocInfoWindow::DocInfoWindow(BMessage *doc_info)
|
|||||||
BString permissions;
|
BString permissions;
|
||||||
fDocInfo = doc_info;
|
fDocInfo = doc_info;
|
||||||
|
|
||||||
|
#if HAVE_FULLVERSION_PDF_LIB
|
||||||
if (DocInfo()->FindString("permissions", &permissions) == B_OK) {
|
if (DocInfo()->FindString("permissions", &permissions) == B_OK) {
|
||||||
fPermissions.Decode(permissions.String());
|
fPermissions.Decode(permissions.String());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
r = Bounds();
|
r = Bounds();
|
||||||
tabView = new BTabView(r, "tab_view");
|
tabView = new BTabView(r, "tab_view");
|
||||||
|
|
||||||
SetupDocInfoView(CreateTabPanel(tabView, "Information"));
|
SetupDocInfoView(CreateTabPanel(tabView, "Information"));
|
||||||
//SetupPasswordView(CreateTabPanel(tabView, "Password"));
|
#if HAVE_FULLVERSION_PDF_LIB
|
||||||
//SetupPermissionsView(CreateTabPanel(tabView, "Permissions"));
|
SetupPasswordView(CreateTabPanel(tabView, "Password"));
|
||||||
|
SetupPermissionsView(CreateTabPanel(tabView, "Permissions"));
|
||||||
|
#endif
|
||||||
|
|
||||||
AddChild(tabView);
|
AddChild(tabView);
|
||||||
MoveTo(320, 320);
|
MoveTo(320, 320);
|
||||||
@@ -207,6 +213,7 @@ DocInfoWindow::SetupDocInfoView(BBox* panel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if HAVE_FULLVERSION_PDF_LIB
|
||||||
BTextControl*
|
BTextControl*
|
||||||
DocInfoWindow::AddPasswordControl(BRect r, BView* panel, const char* name, const char* label) {
|
DocInfoWindow::AddPasswordControl(BRect r, BView* panel, const char* name, const char* label) {
|
||||||
BString s;
|
BString s;
|
||||||
@@ -242,6 +249,7 @@ DocInfoWindow::SetupPermissionsView(BBox* panel) {
|
|||||||
|
|
||||||
SetupButtons(panel);
|
SetupButtons(panel);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
bool
|
bool
|
||||||
@@ -268,9 +276,12 @@ DocInfoWindow::MessageReceived(BMessage *msg)
|
|||||||
case OK_MSG: {
|
case OK_MSG: {
|
||||||
BMessage doc_info;
|
BMessage doc_info;
|
||||||
ReadFieldsFromTable(&doc_info);
|
ReadFieldsFromTable(&doc_info);
|
||||||
DocInfo()->ReplaceMessage("doc_info", &doc_info);
|
DocInfo()->RemoveName("doc_info");
|
||||||
|
DocInfo()->AddMessage("doc_info", &doc_info);
|
||||||
|
#if HAVE_FULLVERSION_PDF_LIB
|
||||||
ReadPasswords();
|
ReadPasswords();
|
||||||
ReadPermissions();
|
ReadPermissions();
|
||||||
|
#endif
|
||||||
Quit();
|
Quit();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -320,7 +331,7 @@ DocInfoWindow::BuildTable(BMessage *docInfo)
|
|||||||
y = 5;
|
y = 5;
|
||||||
w = r.Width() - 10;
|
w = r.Width() - 10;
|
||||||
|
|
||||||
for (int32 i = 0; docInfo->GetInfo(B_STRING_TYPE, i, &name, &type, &count) != B_BAD_INDEX; i++) {
|
for (int32 i = 0; docInfo->GetInfo(B_STRING_TYPE, i, &name, &type, &count) == B_OK; i++) {
|
||||||
if (type == B_STRING_TYPE) {
|
if (type == B_STRING_TYPE) {
|
||||||
BString value;
|
BString value;
|
||||||
if (docInfo->FindString(name, &value) == B_OK) {
|
if (docInfo->FindString(name, &value) == B_OK) {
|
||||||
@@ -352,12 +363,13 @@ DocInfoWindow::BuildTable(BMessage *docInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if HAVE_FULLVERSION_PDF_LIB
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
void
|
void
|
||||||
DocInfoWindow::ReadPasswords()
|
DocInfoWindow::ReadPasswords()
|
||||||
{
|
{
|
||||||
//AddString(DocInfo(), "master_password", fMasterPassword->TextView()->Text());
|
AddString(DocInfo(), "master_password", fMasterPassword->TextView()->Text());
|
||||||
//AddString(DocInfo(), "user_password", fUserPassword->TextView()->Text());
|
AddString(DocInfo(), "user_password", fUserPassword->TextView()->Text());
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
@@ -366,9 +378,9 @@ DocInfoWindow::ReadPermissions()
|
|||||||
{
|
{
|
||||||
BString permissions;
|
BString permissions;
|
||||||
fPermissions.Encode(&permissions);
|
fPermissions.Encode(&permissions);
|
||||||
// AddString(DocInfo(), "permissions", permissions.String());
|
AddString(DocInfo(), "permissions", permissions.String());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ THE SOFTWARE.
|
|||||||
#include "InterfaceUtils.h"
|
#include "InterfaceUtils.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
|
#define HAVE_FULLVERSION_PDF_LIB 0
|
||||||
|
|
||||||
|
#if HAVE_FULLVERSION_PDF_LIB
|
||||||
class PermissionLabels {
|
class PermissionLabels {
|
||||||
private:
|
private:
|
||||||
const char* fName;
|
const char* fName;
|
||||||
@@ -84,6 +87,7 @@ public:
|
|||||||
void Decode(const char* s);
|
void Decode(const char* s);
|
||||||
void Encode(BString* s);
|
void Encode(BString* s);
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
class DocInfoWindow : public HWindow
|
class DocInfoWindow : public HWindow
|
||||||
{
|
{
|
||||||
@@ -114,22 +118,28 @@ private:
|
|||||||
BView *fTable;
|
BView *fTable;
|
||||||
BScrollView *fTableScrollView;
|
BScrollView *fTableScrollView;
|
||||||
BMenu *fKeyList;
|
BMenu *fKeyList;
|
||||||
|
#if HAVE_FULLVERSION_PDF_LIB
|
||||||
BTextControl *fMasterPassword;
|
BTextControl *fMasterPassword;
|
||||||
BTextControl *fUserPassword;
|
BTextControl *fUserPassword;
|
||||||
Permissions fPermissions;
|
Permissions fPermissions;
|
||||||
|
#endif
|
||||||
|
|
||||||
BMessage* DocInfo() { return fDocInfo; }
|
BMessage* DocInfo() { return fDocInfo; }
|
||||||
|
|
||||||
BBox* CreateTabPanel(BTabView* tabView, const char* label);
|
BBox* CreateTabPanel(BTabView* tabView, const char* label);
|
||||||
void SetupButtons(BBox* panel);
|
void SetupButtons(BBox* panel);
|
||||||
void SetupDocInfoView(BBox* panel);
|
void SetupDocInfoView(BBox* panel);
|
||||||
|
#if HAVE_FULLVERSION_PDF_LIB
|
||||||
BTextControl* AddPasswordControl(BRect r, BView* panel, const char* name, const char* label);
|
BTextControl* AddPasswordControl(BRect r, BView* panel, const char* name, const char* label);
|
||||||
void SetupPasswordView(BBox* panel);
|
void SetupPasswordView(BBox* panel);
|
||||||
void SetupPermissionsView(BBox* panel);
|
void SetupPermissionsView(BBox* panel);
|
||||||
|
#endif
|
||||||
void BuildTable(BMessage *fromDocInfo);
|
void BuildTable(BMessage *fromDocInfo);
|
||||||
void ReadFieldsFromTable(BMessage* doc_info);
|
void ReadFieldsFromTable(BMessage* doc_info);
|
||||||
|
#if HAVE_FULLVERSION_PDF_LIB
|
||||||
void ReadPasswords();
|
void ReadPasswords();
|
||||||
void ReadPermissions();
|
void ReadPermissions();
|
||||||
|
#endif
|
||||||
void EmptyKeyList();
|
void EmptyKeyList();
|
||||||
bool IsValidKey(const char *key);
|
bool IsValidKey(const char *key);
|
||||||
void AddKey(BMessage* msg, bool textControl);
|
void AddKey(BMessage* msg, bool textControl);
|
||||||
|
|||||||
@@ -87,18 +87,7 @@ config_page(BNode *spoolDir, BMessage *msg)
|
|||||||
|
|
||||||
pagesetupMsg = new BMessage(*msg);
|
pagesetupMsg = new BMessage(*msg);
|
||||||
|
|
||||||
// Validate the message so that it is good for PDF Writer GUI
|
PrinterSettings::Update(spoolDir, msg);
|
||||||
PrinterSettings *ps = new PrinterSettings(*spoolDir);
|
|
||||||
if (ps->Validate(pagesetupMsg) != B_OK) {
|
|
||||||
// check for previously saved settings
|
|
||||||
if (ps->ReadSettings(pagesetupMsg) != B_OK) {
|
|
||||||
// if there were none, then create a default set...
|
|
||||||
ps->GetDefaults(pagesetupMsg);
|
|
||||||
// ...and save them
|
|
||||||
ps->WriteSettings(pagesetupMsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete ps;
|
|
||||||
|
|
||||||
/* ======== For testing only ==================
|
/* ======== For testing only ==================
|
||||||
|
|
||||||
@@ -142,18 +131,7 @@ config_job(BNode *spoolDir, BMessage *msg)
|
|||||||
|
|
||||||
jobsetupMsg = new BMessage(*msg);
|
jobsetupMsg = new BMessage(*msg);
|
||||||
|
|
||||||
// Validate the message so that it is good for PDF Writer GUI
|
PrinterSettings::Update(spoolDir, jobsetupMsg);
|
||||||
PrinterSettings *ps = new PrinterSettings(*spoolDir);
|
|
||||||
if (ps->Validate(jobsetupMsg) != B_OK) {
|
|
||||||
// check for previously saved settings
|
|
||||||
if (ps->ReadSettings(jobsetupMsg) != B_OK) {
|
|
||||||
// if there were none, then create a default set...
|
|
||||||
ps->GetDefaults(jobsetupMsg);
|
|
||||||
// ...and save them
|
|
||||||
ps->WriteSettings(jobsetupMsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete ps;
|
|
||||||
|
|
||||||
/* ======== For testing only ==================
|
/* ======== For testing only ==================
|
||||||
|
|
||||||
@@ -209,19 +187,9 @@ instanciate_driver(BNode *spoolDir)
|
|||||||
BMessage*
|
BMessage*
|
||||||
default_settings(BNode* printer)
|
default_settings(BNode* printer)
|
||||||
{
|
{
|
||||||
// (new BAlert("", "default_settings()", "Driver.cpp"))->Go();
|
|
||||||
|
|
||||||
PrinterSettings *ps = new PrinterSettings(*printer);
|
|
||||||
BMessage *msg = new BMessage();
|
BMessage *msg = new BMessage();
|
||||||
|
|
||||||
// first read the settings from the spool dir
|
PrinterSettings::Update(printer, msg);
|
||||||
if (ps->ReadSettings(msg) != B_OK) {
|
|
||||||
// if there were none, then create a default set...
|
|
||||||
ps->GetDefaults(msg);
|
|
||||||
// ...and save them
|
|
||||||
ps->WriteSettings(msg);
|
|
||||||
}
|
|
||||||
delete ps;
|
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ CacheItem* ImageDescription::NewItem(int id) {
|
|||||||
if (image == NULL) {
|
if (image == NULL) {
|
||||||
REPORT(kDebug, -1, "Could not store image in cache!");
|
REPORT(kDebug, -1, "Could not store image in cache!");
|
||||||
}
|
}
|
||||||
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image* ImageDescription::Store(PDF* pdf, int id, BBitmap* bitmap, int mask) {
|
Image* ImageDescription::Store(PDF* pdf, int id, BBitmap* bitmap, int mask) {
|
||||||
|
|||||||
@@ -73,12 +73,11 @@ HWindow::MessageReceived(BMessage* msg)
|
|||||||
static const char*
|
static const char*
|
||||||
kAbout =
|
kAbout =
|
||||||
"PDF Writer for BeOS\n"
|
"PDF Writer for BeOS\n"
|
||||||
"© 2001, 2002 OpenBeOS\n"
|
"© 2001-2003 OpenBeOS\n"
|
||||||
"\n"
|
"\n"
|
||||||
"\tPhilippe Houdoin - Project Leader\n"
|
"\tPhilippe Houdoin - Project Leader\n"
|
||||||
"\tSimon Gauvin - GUI Design\n"
|
"\tSimon Gauvin - GUI Design\n"
|
||||||
"\tMichael Pfeiffer - PDF Generation, Configuration, Interactive Features\n"
|
"\tMichael Pfeiffer - PDF Generation, Configuration, Interactive Features\n"
|
||||||
"\tCelerick Stephens - Documentation\n"
|
|
||||||
;
|
;
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
PDF Writer printer driver.
|
PDF Writer printer driver.
|
||||||
|
|
||||||
Copyright (c) 2001 OpenBeOS.
|
Copyright (c) 2001-2003 OpenBeOS.
|
||||||
|
|
||||||
Authors:
|
Authors:
|
||||||
Philippe Houdoin
|
Philippe Houdoin
|
||||||
@@ -34,11 +34,16 @@ THE SOFTWARE.
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "PrinterDriver.h"
|
#include "PrinterDriver.h"
|
||||||
|
#include "PrinterSettings.h"
|
||||||
#include "JobSetupWindow.h"
|
#include "JobSetupWindow.h"
|
||||||
#include "DocInfoWindow.h"
|
#include "DocInfoWindow.h"
|
||||||
|
|
||||||
static const char* includeKeys[] = {
|
static const char* includeKeys[] = {
|
||||||
"doc_info", "master_password", "user_password", "permissions", NULL
|
"doc_info",
|
||||||
|
#if HAVE_FULLVERSION_PDF_LIB
|
||||||
|
"master_password", "user_password", "permissions",
|
||||||
|
#endif
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
@@ -55,6 +60,7 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
|
|||||||
BString title;
|
BString title;
|
||||||
title << printerName << " Job Setup";
|
title << printerName << " Job Setup";
|
||||||
SetTitle(title.String());
|
SetTitle(title.String());
|
||||||
|
fPrinterName = printerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- Ok, build a default job setup user interface
|
// ---- Ok, build a default job setup user interface
|
||||||
@@ -82,9 +88,9 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
|
|||||||
doc_info.AddString("Author", "");
|
doc_info.AddString("Author", "");
|
||||||
doc_info.AddString("Subject", "");
|
doc_info.AddString("Subject", "");
|
||||||
doc_info.AddString("Keywords", "");
|
doc_info.AddString("Keywords", "");
|
||||||
msg->AddMessage("doc_info", &doc_info);
|
fSetupMsg->AddMessage("doc_info", &doc_info);
|
||||||
}
|
}
|
||||||
AddFields(&fDocInfo, fSetupMsg, NULL, includeKeys);
|
AddFields(&fDocInfo, fSetupMsg, true, NULL, includeKeys);
|
||||||
|
|
||||||
allPages = firstPage == 1 && lastPage == MAX_INT32;
|
allPages = firstPage == 1 && lastPage == MAX_INT32;
|
||||||
|
|
||||||
@@ -237,8 +243,6 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
|
|||||||
void
|
void
|
||||||
JobSetupWindow::UpdateJobMessage()
|
JobSetupWindow::UpdateJobMessage()
|
||||||
{
|
{
|
||||||
// int32 copies = atoi(fCopies->Text());
|
|
||||||
// if (copies <= 0)
|
|
||||||
int32 copies = 1;
|
int32 copies = 1;
|
||||||
|
|
||||||
int32 from;
|
int32 from;
|
||||||
@@ -256,6 +260,12 @@ JobSetupWindow::UpdateJobMessage()
|
|||||||
fSetupMsg->ReplaceInt32("first_page", from);
|
fSetupMsg->ReplaceInt32("first_page", from);
|
||||||
fSetupMsg->ReplaceInt32("last_page", to);
|
fSetupMsg->ReplaceInt32("last_page", to);
|
||||||
AddFields(fSetupMsg, &fDocInfo);
|
AddFields(fSetupMsg, &fDocInfo);
|
||||||
|
|
||||||
|
// save the settings to the new defaults
|
||||||
|
PrinterSettings ps(fPrinterName.String());
|
||||||
|
if (ps.InitCheck() == B_OK) {
|
||||||
|
ps.WriteSettings(fSetupMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -296,7 +306,6 @@ JobSetupWindow::MessageReceived(BMessage *msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DOC_INFO_MSG:
|
case DOC_INFO_MSG:
|
||||||
fDocInfo.PrintToStream(); fflush(stdout);
|
|
||||||
(new DocInfoWindow(&fDocInfo))->Show();
|
(new DocInfoWindow(&fDocInfo))->Show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ public:
|
|||||||
|
|
||||||
// From here, it's none of your business! ;-)
|
// From here, it's none of your business! ;-)
|
||||||
private:
|
private:
|
||||||
|
BString fPrinterName;
|
||||||
long fExitSem;
|
long fExitSem;
|
||||||
status_t fResult;
|
status_t fResult;
|
||||||
BMessage *fSetupMsg;
|
BMessage *fSetupMsg;
|
||||||
|
|||||||
@@ -264,7 +264,6 @@ PDFWriter::FindFont(char* fontName, bool embed, font_encoding encoding)
|
|||||||
if (embed) embed = EmbedFont(fontName);
|
if (embed) embed = EmbedFont(fontName);
|
||||||
|
|
||||||
BString s;
|
BString s;
|
||||||
char user_defined[80];
|
|
||||||
const char* encoding_name;
|
const char* encoding_name;
|
||||||
if (encoding < user_defined_encoding_start) {
|
if (encoding < user_defined_encoding_start) {
|
||||||
encoding_name = encoding_names[encoding];
|
encoding_name = encoding_names[encoding];
|
||||||
|
|||||||
@@ -427,7 +427,6 @@ PDFWriter::DeclareFonts()
|
|||||||
|
|
||||||
for (int i = 0; i < fFonts->Length(); i++) {
|
for (int i = 0; i < fFonts->Length(); i++) {
|
||||||
FontFile* f = fFonts->At(i);
|
FontFile* f = fFonts->At(i);
|
||||||
// LOG((fLog, "path= %s\n", f->Path()));
|
|
||||||
if (f->Type() == true_type_type) {
|
if (f->Type() == true_type_type) {
|
||||||
parameter_name = "FontOutline";
|
parameter_name = "FontOutline";
|
||||||
} else { // f->Type() == type1_type
|
} else { // f->Type() == type1_type
|
||||||
@@ -443,8 +442,6 @@ PDFWriter::DeclareFonts()
|
|||||||
#else
|
#else
|
||||||
sprintf(buffer, "%s==%s", f->Name(), f->Path());
|
sprintf(buffer, "%s==%s", f->Name(), f->Path());
|
||||||
#endif
|
#endif
|
||||||
// LOG((fLog, "%s: %s\n", parameter_name, buffer));
|
|
||||||
|
|
||||||
PDF_set_parameter(fPdf, parameter_name, buffer);
|
PDF_set_parameter(fPdf, parameter_name, buffer);
|
||||||
}
|
}
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
@@ -504,11 +504,10 @@ PageSetupWindow::UpdateSetupMessage()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save the settings to the new defaults
|
// save the settings to the new defaults
|
||||||
PrinterSettings *ps = new PrinterSettings(fPrinterDirName.String());
|
PrinterSettings ps(fPrinterDirName.String());
|
||||||
if (ps->InitCheck() == B_OK) {
|
if (ps.InitCheck() == B_OK) {
|
||||||
ps->WriteSettings(fSetupMsg);
|
ps.WriteSettings(fSetupMsg);
|
||||||
}
|
}
|
||||||
delete ps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
PDF Writer printer driver.
|
PDF Writer printer driver.
|
||||||
|
|
||||||
Copyright (c) 2001 OpenBeOS.
|
Copyright (c) 2001-2003 OpenBeOS.
|
||||||
|
|
||||||
Authors:
|
Authors:
|
||||||
Philippe Houdoin
|
Philippe Houdoin
|
||||||
@@ -133,6 +133,13 @@ PrinterDriver::PrintJob
|
|||||||
// read job message
|
// read job message
|
||||||
fJobMsg = msg = new BMessage();
|
fJobMsg = msg = new BMessage();
|
||||||
msg->Unflatten(fJobFile);
|
msg->Unflatten(fJobFile);
|
||||||
|
// We have to load the settings here for Dano/Zeta because they don't store
|
||||||
|
// all fields from the message returned by config_job in the job file!
|
||||||
|
printf("JobMsg\n");
|
||||||
|
msg->PrintToStream();
|
||||||
|
PrinterSettings::Update(printerNode, msg);
|
||||||
|
printf("\n\nAfter Update:\n");
|
||||||
|
msg->PrintToStream();
|
||||||
|
|
||||||
if (msg->HasInt32("copies")) {
|
if (msg->HasInt32("copies")) {
|
||||||
copies = msg->FindInt32("copies");
|
copies = msg->FindInt32("copies");
|
||||||
@@ -242,36 +249,6 @@ PrinterDriver::PrinterSetup(char *printerName)
|
|||||||
status_t
|
status_t
|
||||||
PrinterDriver::PageSetup(BMessage *setupMsg, const char *printerName)
|
PrinterDriver::PageSetup(BMessage *setupMsg, const char *printerName)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
BRect paperRect;
|
|
||||||
BRect printRect;
|
|
||||||
|
|
||||||
// const float kScale = 8.3333f;
|
|
||||||
const float kScreen = 72.0f;
|
|
||||||
const float kLetterWidth = 8.5;
|
|
||||||
const float kLetterHeight = 11;
|
|
||||||
|
|
||||||
// set default value if property not set
|
|
||||||
if (!setupMsg->HasInt64("xres"))
|
|
||||||
setupMsg->AddInt64("xres", 360);
|
|
||||||
|
|
||||||
if (!setupMsg->HasInt64("yres"))
|
|
||||||
setupMsg->AddInt64("yres", 360);
|
|
||||||
|
|
||||||
if (!setupMsg->HasInt32("orientation"))
|
|
||||||
setupMsg->AddInt32("orientation", PORTRAIT_ORIENTATION);
|
|
||||||
|
|
||||||
paperRect = BRect(0, 0, kLetterWidth * kScreen, kLetterHeight * kScreen);
|
|
||||||
printRect = BRect(0, 0, kLetterWidth * kScreen, kLetterHeight * kScreen);
|
|
||||||
|
|
||||||
if (!setupMsg->HasRect("paper_rect"))
|
|
||||||
setupMsg->AddRect("paper_rect", paperRect);
|
|
||||||
|
|
||||||
if (!setupMsg->HasRect("printable_rect"))
|
|
||||||
setupMsg->AddRect("printable_rect", printRect);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// check to see if the messag is built correctly...
|
// check to see if the messag is built correctly...
|
||||||
if (setupMsg->HasFloat("scaling") != B_OK) {
|
if (setupMsg->HasFloat("scaling") != B_OK) {
|
||||||
PrinterSettings *ps = new PrinterSettings(printerName);
|
PrinterSettings *ps = new PrinterSettings(printerName);
|
||||||
@@ -284,9 +261,6 @@ PrinterDriver::PageSetup(BMessage *setupMsg, const char *printerName)
|
|||||||
// ...and save them
|
// ...and save them
|
||||||
ps->WriteSettings(setupMsg);
|
ps->WriteSettings(setupMsg);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Temp
|
|
||||||
//(new BAlert("", "Problem Loading Settings", "PrinterDriver"))->Go();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
PDF Writer printer driver.
|
PDF Writer printer driver.
|
||||||
|
|
||||||
Copyright (c) 2001 OpenBeOS.
|
Copyright (c) 2001-2003 OpenBeOS.
|
||||||
|
|
||||||
Authors:
|
Authors:
|
||||||
Philippe Houdoin
|
Philippe Houdoin
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Printer Settings helper class
|
Printer Settings helper class
|
||||||
|
|
||||||
Copyright (c) 2001 OpenBeOS.
|
Copyright (c) 2001-2003 OpenBeOS.
|
||||||
|
|
||||||
Authors:
|
Authors:
|
||||||
Philippe Houdoin
|
Philippe Houdoin
|
||||||
@@ -36,6 +36,7 @@ THE SOFTWARE.
|
|||||||
#include <fs_attr.h>
|
#include <fs_attr.h>
|
||||||
|
|
||||||
#include "PrinterPrefs.h"
|
#include "PrinterPrefs.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -277,3 +278,22 @@ PrinterSettings::Validate(const BMessage *msg)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PrinterSettings::Update(BNode* node, BMessage* msg)
|
||||||
|
{
|
||||||
|
// Validate the message so that it is good for PDF Writer GUI
|
||||||
|
PrinterSettings ps(*node);
|
||||||
|
if (ps.Validate(msg) != B_OK) {
|
||||||
|
BMessage settings;
|
||||||
|
// check for previously saved settings
|
||||||
|
if (ps.ReadSettings(&settings) != B_OK) {
|
||||||
|
// if there were none, then create a default set...
|
||||||
|
ps.GetDefaults(&settings);
|
||||||
|
// ...and save them
|
||||||
|
ps.WriteSettings(&settings);
|
||||||
|
}
|
||||||
|
AddFields(&settings, msg, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
PrinterSettings.h
|
PrinterSettings.h
|
||||||
|
|
||||||
Copyright (c) 2001 OpenBeOS.
|
Copyright (c) 2001-2003 OpenBeOS.
|
||||||
|
|
||||||
Authors:
|
Authors:
|
||||||
Philippe Houdoin
|
Philippe Houdoin
|
||||||
@@ -82,7 +82,10 @@ public:
|
|||||||
status_t ReadSettings(BMessage *msg);
|
status_t ReadSettings(BMessage *msg);
|
||||||
status_t GetDefaults(BMessage *msg);
|
status_t GetDefaults(BMessage *msg);
|
||||||
status_t Validate(const BMessage *msg);
|
status_t Validate(const BMessage *msg);
|
||||||
|
|
||||||
|
static void Update(BNode* node, BMessage* msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
PDF Writer printer driver.
|
PDF Writer printer driver.
|
||||||
|
|
||||||
Copyright (c) 2001, 2002 OpenBeOS.
|
Copyright (c) 2001-2003 OpenBeOS.
|
||||||
|
|
||||||
Authors:
|
Authors:
|
||||||
Philippe Houdoin
|
Philippe Houdoin
|
||||||
@@ -66,28 +66,36 @@ static bool InList(const char* list[], const char* name) {
|
|||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
// copied from BeUtils.cpp
|
// copied from BeUtils.cpp
|
||||||
void AddFields(BMessage* to, const BMessage* from, const char* excludeList[], const char* includeList[]) {
|
void AddFields(BMessage* to, const BMessage* from, bool overwrite = true, const char* excludeList[], const char* includeList[]) {
|
||||||
if (to == from) return;
|
if (to == from) return;
|
||||||
char* name;
|
char* name;
|
||||||
type_code type;
|
type_code type;
|
||||||
int32 count;
|
int32 count;
|
||||||
for (int32 i = 0; from->GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK; i ++) {
|
for (int32 i = 0; from->GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK; i ++) {
|
||||||
|
const void* data;
|
||||||
|
ssize_t size;
|
||||||
|
|
||||||
if (excludeList && InList(excludeList, name)) continue;
|
if (excludeList && InList(excludeList, name)) continue;
|
||||||
if (includeList && !InList(includeList, name)) continue;
|
if (includeList && !InList(includeList, name)) continue;
|
||||||
|
|
||||||
|
if (!overwrite && to->FindData(name, type, 0, &data, &size) == B_OK) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// replace existing data
|
// replace existing data
|
||||||
to->RemoveName(name);
|
to->RemoveName(name);
|
||||||
|
|
||||||
const void* data;
|
|
||||||
ssize_t size;
|
|
||||||
for (int32 j = 0; j < count; j ++) {
|
for (int32 j = 0; j < count; j ++) {
|
||||||
if (from->FindData(name, type, j, &data, &size) == B_OK) {
|
if (from->FindData(name, type, j, &data, &size) == B_OK) {
|
||||||
// WTF why works AddData not for B_STRING_TYPE in R5.0.3?
|
// WTF why works AddData not for B_STRING_TYPE in R5.0.3?
|
||||||
if (type == B_STRING_TYPE) to->AddString(name, (const char*)data);
|
if (type == B_STRING_TYPE) {
|
||||||
else if (type == B_MESSAGE_TYPE) {
|
to->AddString(name, (const char*)data);
|
||||||
|
} else if (type == B_MESSAGE_TYPE) {
|
||||||
BMessage m;
|
BMessage m;
|
||||||
from->FindMessage(name, j, &m);
|
from->FindMessage(name, j, &m);
|
||||||
to->AddMessage(name, &m);
|
to->AddMessage(name, &m);
|
||||||
} else to->AddData(name, type, data, size);
|
} else {
|
||||||
|
to->AddData(name, type, data, size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
PDF Writer printer driver.
|
PDF Writer printer driver.
|
||||||
|
|
||||||
Copyright (c) 2001, 2002 OpenBeOS.
|
Copyright (c) 2001-2003 OpenBeOS.
|
||||||
|
|
||||||
Authors:
|
Authors:
|
||||||
Philippe Houdoin
|
Philippe Houdoin
|
||||||
@@ -38,7 +38,7 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
|
|
||||||
// adds fields to message or replaces existing fields (copy BeUtils.h)
|
// adds fields to message or replaces existing fields (copy BeUtils.h)
|
||||||
void AddFields(BMessage* to, const BMessage* from, const char* excludeList[] = NULL, const char* includeList[] = NULL);
|
void AddFields(BMessage* to, const BMessage* from, bool overwrite = true, const char* excludeList[] = NULL, const char* includeList[] = NULL);
|
||||||
void AddString(BMessage* m, const char* name, const char* value);
|
void AddString(BMessage* m, const char* name, const char* value);
|
||||||
|
|
||||||
class EscapeMessageFilter : public BMessageFilter
|
class EscapeMessageFilter : public BMessageFilter
|
||||||
|
|||||||
Reference in New Issue
Block a user