Patch level : 10.0 272

Files correlati     : xvaga.dll
Ricompilazione Demo : [ ]
Commento            :
0001220: Esportazione in PDF
Se imposto il foglio in orizzontale, l'esportazione in pdf sembra rigirare il foglio in verticale troncando la stampa. Impostando la stampante come pdf creator la stampa viene corretta.


git-svn-id: svn://10.65.10.50/trunk@18609 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2009-03-25 15:49:53 +00:00
parent 70a2cdd421
commit c5797bd448
5 changed files with 63 additions and 36 deletions

View File

@ -1393,7 +1393,17 @@ void xvt_dwin_draw_arc(WINDOW win, const RCT* r, int sx, int sy, int ex, int ey)
if (win != NULL_WIN && r != NULL)
{
CAST_DC(win, dc);
dc.DrawArc(sx, sy, ex, ey, (r->right+r->left)/2, (r->top+r->bottom)/2);
const wxRect rect = NormalizeRCT(r);
const wxPoint c(rect.x+rect.width/2, rect.y+rect.height/2);
if (abs(rect.width - rect.height) < 2)
dc.DrawArc(sx, sy, ex, ey, c.x, c.y);
else
{
const double pi = acos(-1.0);
double sa = atan2(double(c.y-sy), double(sx-c.x)) * 180 / pi; if (sa < 0) sa += 360;
double ea = atan2(double(c.y-ey), double(ex-c.x)) * 180 / pi; while (ea < sa) ea += 360;
dc.DrawEllipticArc(rect.x, rect.y, rect.width, rect.height, sa, ea);
}
}
}

View File

@ -23,7 +23,7 @@ static wxBitmap Image2Bitmap(XVT_IMAGE image, int maxx, int maxy, BOOLEAN trans)
int w = img.GetWidth(), h = img.GetHeight();
if (w > maxx || h > maxy)
{
const double mx = (maxx / 4) * 4, my = (maxy / 4) * 4;
const double mx = (maxx / 2) * 2, my = (maxy / 2) * 2;
const double rx = mx / w, ry = my / h;
const double r = rx < ry ? rx : ry;
w = int(w * r); h = int(h * r);

View File

@ -110,7 +110,6 @@ protected:
wxDC* CreateDC(const TPRINT_RCD* prcd, const char* title);
public:
void SetBadDriver(bool bd) { m_bBadDriver = bd; }
bool HasBadDriver() const { return m_bBadDriver; }
@ -118,7 +117,7 @@ public:
wxString PrinterName() const;
bool IsPDF() const { return !HasBadDriver() && xvt_print_is_pdf(m_prcd) != 0; }
void InitDC(const TPRINT_RCD* prcd, const char* title);
bool InitDC(const TPRINT_RCD* prcd, const char* title);
TwxPrintOut(const TPRINT_RCD* prcd = NULL);
virtual ~TwxPrintOut() {}
@ -147,7 +146,6 @@ void TwxPrintOut::ResetDC()
}
}
static void RCD2data(const TPRINT_RCD* prcd, wxPrintData& data)
{
#ifdef WIN32
@ -242,7 +240,7 @@ wxDC* TwxPrintOut::CreateDC(const TPRINT_RCD* prcd, const char* title)
return dc;
}
void TwxPrintOut::InitDC(const TPRINT_RCD* prcd, const char* title)
bool TwxPrintOut::InitDC(const TPRINT_RCD* prcd, const char* title)
{
ResetDC();
wxDC* dc = CreateDC(prcd, title);
@ -258,6 +256,7 @@ void TwxPrintOut::InitDC(const TPRINT_RCD* prcd, const char* title)
SetDC(dc);
}
m_bBadDriver = dc == NULL;
return !m_bBadDriver;
}
TwxPrintOut::TwxPrintOut(const TPRINT_RCD* prcd)
@ -423,9 +422,12 @@ BOOLEAN xvt_app_escape(int esc_code, PRINT_RCD* rcd, long* ph, long* pw, long* p
wxPrintData data;
RCD2data(prcd, data);
data.SetOrientation(*ph > *pw ? 1 : 2);
data.SetOrientation(*ph > *pw ? wxPORTRAIT : wxLANDSCAPE);
data.ConvertToNative();
data2RCD(data, prcd);
TwxPrintOut& po = m_PrintoutCache.Get((TPRINT_RCD*)rcd);
po.InitDC(prcd, _GetAppTitle());
return true;
}
@ -607,27 +609,38 @@ PRINT_RCD* xvt_print_create_by_name(int* sizep, const char* name)
WINDOW xvt_print_create_win(PRINT_RCD* precp, const char* title)
{
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
if (m_PrintoutCache.Printing())
bool ok = xvt_print_is_valid(precp) != FALSE;
if (ok)
{
TwxPrintOut& po = m_PrintoutCache.Get(NULL);
po.InitDC(rcd, title);
po.OnBeginPrinting();
po.OnBeginDocument(1, 32000);
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
if (m_PrintoutCache.Printing())
{
TwxPrintOut& po = m_PrintoutCache.Get(NULL);
ok = po.InitDC(rcd, title);
if (ok)
{
po.OnBeginPrinting();
po.OnBeginDocument(1, 32000);
}
}
else
{
TwxPrintOut& po = m_PrintoutCache.Get(rcd);
ok = po.InitDC(rcd, title);
}
}
else
{
TwxPrintOut& po = m_PrintoutCache.Get(rcd);
po.InitDC(rcd, title);
}
return PRINTER_WIN;
return ok ? PRINTER_WIN : NULL_WIN;
}
void xvt_print_destroy(PRINT_RCD* precp)
{
if (precp != NULL)
{
#ifndef NDEBUG
#endif
delete precp;
}
}
RCT* xvt_print_get_next_band(void)
@ -796,18 +809,21 @@ BOOLEAN xvt_print_start_thread(BOOLEAN(*print_fcn)(long), long data)
wxEndBusyCursor();
CreateAbortWindow();
const BOOLEAN aborted = print_fcn(data);
const BOOLEAN success = print_fcn(data);
DestroyAbortWindow();
po.OnEndDocument();
po.OnEndPrinting();
if (!po.HasBadDriver())
{
po.OnEndDocument();
po.OnEndPrinting();
}
m_PrintoutCache.Unlock();
m_PrintoutCache.Reset();
::wxSetWorkingDirectory(strDir); // Ripristino la directory corrente (Acrobat l'ha cambiata)
return aborted;
return success;
}
BOOLEAN xvt_print_suspend_thread()

View File

@ -17,14 +17,13 @@ TwxPDFDC::TwxPDFDC()
}
TwxPDFDC::TwxPDFDC (const wxPrintData& printData, const char* strFilename)
: m_PDFlib(NULL), m_p(NULL)
: m_PDFlib(NULL), m_p(NULL), m_fileName(strFilename)
{
m_pageNumber = 0;
m_topDown = true;
m_clipping = false;
m_pageopen = false;
m_printData = printData;
m_fileName = strFilename;
for(int i=0; i < PDF_IMG_CACHE_SIZE; i++)
{
@ -32,16 +31,21 @@ TwxPDFDC::TwxPDFDC (const wxPrintData& printData, const char* strFilename)
m_handles[i] = 0;
}
m_cacheidx = 0;
m_PDFlib = PDF_new_dl(&m_p);
m_ok = m_PDFlib != NULL;
if (!m_ok)
wxLogError( _("Cannot create PDFlib object (DLL not found?)\n"));
::wxMessageBox(_("Cannot create PDFlib object (DLL not found?)"), "PDFlib", wxOK|wxICON_ERROR);
}
TwxPDFDC::~TwxPDFDC ()
{
if (m_PDFlib != NULL)
{
PDF_delete_dl(m_PDFlib, m_p);
m_PDFlib = NULL;
m_p = NULL;
}
}
//-- Status --------------------------------------------------------------
@ -65,7 +69,7 @@ bool TwxPDFDC::StartDoc( const wxString& message )
{
wxString strFontPath;
wxChar* lpszFontPath = strFontPath.GetWriteBuf(_MAX_PATH);
GetFontsFolder(lpszFontPath, _MAX_PATH);
::GetFontsFolder(lpszFontPath, _MAX_PATH);
strFontPath.UngetWriteBuf();
m_PDFlib->PDF_set_parameter(m_p, "SearchPath", strFontPath);
@ -103,21 +107,18 @@ void TwxPDFDC::EndDoc ()
void TwxPDFDC::StartPage()
{
wxCHECK_RET( m_ok, wxT("invalid PDF dc") );
if (m_pageopen)
return;
int size_x, size_y;
DoGetSize (&size_x, &size_y);
m_pageNumber++;
SetAxisOrientation(true, false);
PDF_TRY_DL(m_PDFlib, m_p)
{
m_PDFlib->PDF_begin_page_ext(m_p, size_x * 72.0 / PDF_DPI, size_y * 72.0 / PDF_DPI, "");
m_PDFlib->PDF_scale(m_p, (72.0 / PDF_DPI), (72.0 / PDF_DPI));
int size_x, size_y; DoGetSize(&size_x, &size_y);
const double scale = 72.0 / PDF_DPI;
m_PDFlib->PDF_begin_page_ext(m_p, size_x*scale, size_y*scale, "");
m_PDFlib->PDF_scale(m_p, scale, scale);
m_pageopen = true;
}
PDF_CATCH_DL(m_PDFlib, m_p)

View File

@ -95,7 +95,7 @@ public:
void SetBackgroundMode(int WXUNUSED(mode)) { }
void SetPalette(const wxPalette& WXUNUSED(palette)) { }
wxPrintData& GetPrintData() { return m_printData; }
const wxPrintData& GetPrintData() const { return m_printData; }
void SetPrintData(const wxPrintData& data) { m_printData = data; }
virtual int GetDepth() const { return 24; }