* Store resolution ID in libprint specific field in JobData;

as the pair of x/y resolutions might not be unique in all
  supported Gutenprint printer models 


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39142 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer
2010-10-25 14:46:26 +00:00
parent f53abcbdf8
commit f412257ccb
3 changed files with 30 additions and 12 deletions
+4
View File
@@ -226,6 +226,7 @@ public:
private:
bool fShowPreview;
Paper fPaper;
int32 fResolutionID;
int32 fXRes;
int32 fYRes;
Orientation fOrientation;
@@ -271,6 +272,9 @@ public:
Paper getPaper() const { return fPaper; }
void setPaper(Paper paper) { fPaper = paper; }
int32 getResolutionID() const { return fResolutionID; }
void setResolutionID(int32 resolution) { fResolutionID = resolution; }
int32 getXres() const { return fXRes; }
void setXres(int32 xres) { fXRes = xres; }
+17
View File
@@ -38,6 +38,7 @@ static const char* kJDPageSelection = "JJJJ_page_selection";
static const char* kJDMarginUnit = "JJJJ_margin_unit";
static const char* kJDPhysicalRect = "JJJJ_physical_rect";
static const char* kJDScaledPhysicalRect = "JJJJ_scaled_physical_rect";
static const char* kJDResolution = "JJJJ_resolution";
JobData::JobData(BMessage *msg, const PrinterCap *cap, Settings settings)
{
@@ -52,6 +53,7 @@ JobData::JobData(const JobData &job_data)
{
fShowPreview = job_data.fShowPreview;
fPaper = job_data.fPaper;
fResolutionID = job_data.fResolutionID;
fXRes = job_data.fXRes;
fYRes = job_data.fYRes;
fOrientation = job_data.fOrientation;
@@ -86,6 +88,7 @@ JobData &JobData::operator = (const JobData &job_data)
{
fShowPreview = job_data.fShowPreview;
fPaper = job_data.fPaper;
fResolutionID = job_data.fResolutionID;
fXRes = job_data.fXRes;
fYRes = job_data.fYRes;
fOrientation = job_data.fOrientation;
@@ -137,6 +140,17 @@ void JobData::load(BMessage *msg, const PrinterCap *cap, Settings settings)
} else
fPaper = kA4;
if (msg->HasInt32(kJDResolution)) {
int32 resolution;
msg->FindInt32(kJDResolution, &resolution);
fResolutionID = resolution;
} else if (cap->isSupport(PrinterCap::kResolution)) {
fResolutionID = cap->getDefaultCap(PrinterCap::kResolution)->ID();
} else {
// should not reach here!
fResolutionID = 0;
}
if (msg->HasInt64(kJDXRes)) {
int64 xres64;
msg->FindInt64(kJDXRes, &xres64);
@@ -311,6 +325,9 @@ void JobData::save(BMessage *msg)
msg->RemoveName(kJDPaper);
msg->AddInt32(kJDPaper, fPaper);
msg->RemoveName(kJDResolution);
msg->AddInt32(kJDResolution, fResolutionID);
msg->RemoveName(kJDXRes);
msg->AddInt64(kJDXRes, fXRes);
+9 -12
View File
@@ -14,6 +14,7 @@
#include <Bitmap.h>
#include <Box.h>
#include <Button.h>
#include <Debug.h>
#include <Font.h>
#include <GridView.h>
#include <GroupLayout.h>
@@ -266,18 +267,14 @@ PageSetupView::UpdateJobData()
BRect physical_rect = paperCap->fPhysicalRect;
fJobData->setPaper(paperCap->fPaper);
int count;
count = fPrinterCap->countCap(PrinterCap::kResolution);
ResolutionCap **resolution_cap = (ResolutionCap **)fPrinterCap->enumCap(PrinterCap::kResolution);
const char *resolution_label = fResolution->FindMarked()->Label();
while (count--) {
if (!strcmp((*resolution_cap)->fLabel.c_str(), resolution_label)) {
fJobData->setXres((*resolution_cap)->fXResolution);
fJobData->setYres((*resolution_cap)->fYResolution);
break;
}
resolution_cap++;
const char *resolutionLabel = fResolution->FindMarked()->Label();
const ResolutionCap* resolution = static_cast<const ResolutionCap*>(
fPrinterCap->findCap(PrinterCap::kResolution, resolutionLabel));
ASSERT(resolution != NULL);
if (resolution != NULL) {
fJobData->setXres(resolution->fXResolution);
fJobData->setYres(resolution->fYResolution);
fJobData->setResolutionID(resolution->ID());
}
// rotate paper and physical rectangle if landscape orientation