Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 13e6b18

Browse files
committed
Merge remote-tracking branch 'mark/bugfix-16294' into bugfix-16294-8_0
Conflicts: engine/src/lnxflst.cpp engine/src/lnxpsprinter.cpp
2 parents 1be425d + 81569ea commit 13e6b18

File tree

9 files changed

+203
-1561
lines changed

9 files changed

+203
-1561
lines changed

engine/src/customprinter.cpp

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@ static bool dotextmark_callback(void *p_context, const MCTextLayoutSpan *p_span)
10291029
MCAutoStringRef t_string;
10301030
// SN-2014-06-17 [[ Bug 12595 ]] Not properly causing the bug, but it never hurts to get to use the right encoding
10311031
MCStringCreateWithBytes((byte_t*)p_span->chars, p_span->char_count * 2, kMCStringEncodingUTF16, false, &t_string);
1032+
10321033
byte_t *t_bytes;
10331034
uindex_t t_byte_count;
10341035
/* UNCHECKED */ MCStringConvertToBytes(*t_string, kMCStringEncodingUTF8, false, t_bytes, t_byte_count);
@@ -1037,7 +1038,10 @@ static bool dotextmark_callback(void *p_context, const MCTextLayoutSpan *p_span)
10371038
uint32_t *t_clusters;
10381039
t_clusters = nil;
10391040
if (!MCMemoryNewArray(t_byte_count, t_clusters))
1041+
{
1042+
MCMemoryDeleteArray(t_bytes);
10401043
return false;
1044+
}
10411045

10421046
// Now loop through and build up the cluster array. Notice we keep track of
10431047
// UTF-16 codepoint index by taking note of leading UTF-8 bytes.
@@ -1102,6 +1106,7 @@ static bool dotextmark_callback(void *p_context, const MCTextLayoutSpan *p_span)
11021106
t_success = context -> device -> DrawText((const MCCustomPrinterGlyph *)p_span -> glyphs, p_span -> glyph_count, (const char *)t_bytes, t_byte_count, t_clusters, t_font, context -> paint, context -> transform, context -> clip);
11031107

11041108
MCMemoryDeleteArray(t_clusters);
1109+
MCMemoryDeleteArray(t_bytes);
11051110

11061111
return t_success;
11071112
}
@@ -1577,38 +1582,6 @@ bool MCCustomPrinterDevice::StartPage(void)
15771582

15781583
////////////////////////////////////////////////////////////////////////////////
15791584

1580-
class MCCustomPrinter: public MCPrinter
1581-
{
1582-
public:
1583-
MCCustomPrinter(MCStringRef p_name, MCCustomPrintingDevice *p_device);
1584-
~MCCustomPrinter(void);
1585-
1586-
void SetDeviceOptions(MCArrayRef p_options);
1587-
1588-
protected:
1589-
void DoInitialize(void);
1590-
void DoFinalize(void);
1591-
1592-
bool DoReset(MCStringRef p_name);
1593-
bool DoResetSettings(MCDataRef p_settings);
1594-
1595-
const char *DoFetchName(void);
1596-
void DoFetchSettings(void*& r_bufer, uint4& r_length);
1597-
1598-
void DoResync(void);
1599-
1600-
MCPrinterDialogResult DoPrinterSetup(bool p_window_modal, Window p_owner);
1601-
MCPrinterDialogResult DoPageSetup(bool p_window_modal, Window p_owner);
1602-
1603-
MCPrinterResult DoBeginPrint(MCStringRef p_document, MCPrinterDevice*& r_device);
1604-
MCPrinterResult DoEndPrint(MCPrinterDevice* p_device);
1605-
1606-
private:
1607-
MCStringRef m_device_name;
1608-
MCCustomPrintingDevice *m_device;
1609-
MCArrayRef m_device_options;
1610-
};
1611-
16121585
MCCustomPrinter::MCCustomPrinter(MCStringRef p_name, MCCustomPrintingDevice *p_device)
16131586
{
16141587
m_device_options = nil;
@@ -2140,7 +2113,7 @@ class MCDebugPrintingDevice: public MCCustomPrintingDevice
21402113

21412114
typedef MCCustomPrintingDevice *(*MCCustomPrinterCreateProc)(void);
21422115

2143-
Exec_stat MCCustomPrinterCreate(MCStringRef p_destination, MCStringRef p_filename, MCArrayRef p_options, MCPrinter*& r_printer)
2116+
Exec_stat MCCustomPrinterCreate(MCStringRef p_destination, MCStringRef p_filename, MCArrayRef p_options, MCCustomPrinter*& r_printer)
21442117
{
21452118
MCCustomPrintingDevice *t_device;
21462119
t_device = nil;

engine/src/exec-printing.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,7 @@ void MCPrintingExecPrintCardIntoRect(MCExecContext& ctxt, MCCard *p_card, MCRect
702702

703703
void MCPrintingExecOpenPrintingToDestination(MCExecContext& ctxt, MCStringRef p_destination, MCStringRef p_filename, MCArrayRef p_options)
704704
{
705-
extern Exec_stat MCCustomPrinterCreate(MCStringRef, MCStringRef, MCArrayRef , MCPrinter*&);
706-
if (MCCustomPrinterCreate(p_destination, p_filename, p_options, MCprinter) == ES_NORMAL)
705+
if (MCCustomPrinterCreate(p_destination, p_filename, p_options, (MCCustomPrinter*&)MCprinter) == ES_NORMAL)
707706
MCPrintingExecOpenPrinting(ctxt);
708707
}
709708

@@ -739,7 +738,7 @@ void MCPrintingExecClosePrinting(MCExecContext& ctxt)
739738
{
740739
MCprinter -> Close();
741740
if (MCsystemprinter != MCprinter)
742-
{
741+
{
743742
delete MCprinter;
744743
MCprinter = MCsystemprinter;
745744
}

engine/src/linux.stubs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,14 +520,23 @@ gtk libgtk-x11-2.0.so.0
520520
gtk_print_dialog libgtk-x11-2.0.so.0
521521
gtk_print_unix_dialog_new: (pointer, pointer) -> (pointer)
522522
gtk_print_unix_dialog_get_selected_printer: (pointer) -> (pointer)
523+
gtk_print_unix_dialog_set_settings: (pointer, pointer) -> ()
523524
gtk_print_unix_dialog_get_settings: (pointer) -> (pointer)
524525

526+
gtk_print_settings_new: () -> (pointer)
527+
gtk_print_settings_set_n_copies: (pointer, integer) -> ()
525528
gtk_print_settings_get_n_copies: (pointer) -> (integer)
529+
gtk_print_settings_set_collate: (pointer, integer) -> ()
526530
gtk_print_settings_get_collate: (pointer) -> (integer)
527-
gtk_print_settings_get_paper_width: (pointer) -> (double)
528-
gtk_print_settings_get_paper_height: (pointer) -> (double)
531+
gtk_print_settings_set_paper_width: (pointer, double, integer) -> ()
532+
gtk_print_settings_get_paper_width: (pointer, integer) -> (double)
533+
gtk_print_settings_set_paper_height: (pointer, double, integer) -> ()
534+
gtk_print_settings_get_paper_height: (pointer, integer) -> (double)
535+
gtk_print_settings_set_use_color: (pointer, integer) -> ()
529536
gtk_print_settings_get_use_color: (pointer) -> (integer)
537+
gtk_print_settings_set_orientation: (pointer, integer) -> ()
530538
gtk_print_settings_get_orientation: (pointer) -> (integer)
539+
gtk_print_settings_set_duplex: (pointer, integer) -> ()
531540
gtk_print_settings_get_duplex: (pointer) -> (integer)
532541

533542
gtk_page_setup_unix_dialog_new: (pointer, pointer) -> (pointer)

engine/src/lnxans.cpp

Lines changed: 44 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -824,56 +824,42 @@ void MCA_getcolordialogcolors(MCColor*& r_colors, uindex_t& r_count)
824824

825825
MCPrinterDialogResult MCA_gtk_printer_setup ( PSPrinterSettings &p_settings )
826826
{
827-
if (!MCModeMakeLocalWindows())
828-
{
829-
bool t_success;
830-
t_success = true;
831-
832-
MCLinuxPrintSetup t_setup;
833-
834-
MCAutoDataRef t_data_in;
835-
836-
if (t_success)
837-
t_success = MCLinuxPrintSetupEncode(t_setup, &t_data_in);
838-
839-
uint32_t t_result;
840-
t_result = PRINTER_DIALOG_RESULT_ERROR;
841-
if (t_success)
842-
{
843-
MCAutoDataRef t_data_out;
844-
845-
MCRemotePrintSetupDialog(*t_data_in, &t_data_out, t_result);
846-
847-
if (t_result == PRINTER_DIALOG_RESULT_OKAY)
848-
{
849-
if (MCLinuxPrintSetupDecode(*t_data_out, t_setup))
850-
{
851-
}
852-
else
853-
t_result = PRINTER_DIALOG_RESULT_ERROR;
854-
855-
}
856-
}
857-
858-
859-
return (MCPrinterDialogResult)t_result;
860-
}
861-
862-
GtkWidget * dialog ;
827+
GtkPrintUnixDialog * dialog ;
863828
gint ret_code ;
864829
MCPrinterDialogResult result = PRINTER_DIALOG_RESULT_CANCEL ;
865830

866831
gtk_init();
867832

868-
dialog = gtk_print_unix_dialog_new ( "Printer setup", NULL );
869-
make_front_widget ( dialog ) ;
833+
dialog = (GtkPrintUnixDialog *)gtk_print_unix_dialog_new ( "Printer setup", NULL );
834+
make_front_widget ( (GtkWidget *)dialog ) ;
870835

871-
gtk_print_unix_dialog_set_manual_capabilities ( GTK_PRINT_UNIX_DIALOG(dialog), GTK_PRINT_CAPABILITY_GENERATE_PS);
872-
836+
gtk_print_unix_dialog_set_manual_capabilities ( GTK_PRINT_UNIX_DIALOG(dialog), GTK_PRINT_CAPABILITY_GENERATE_PDF);
837+
838+
#if NOT_WORKING
839+
// Capture existing settings and ensure they are presented in the dialog.
840+
GtkPrintSettings *t_settings;
841+
t_settings = gtk_print_settings_new();
842+
//gtk_print_settings_set_printer(t_settings, p_settings, printername);
843+
gtk_print_settings_set_n_copies(t_settings, p_settings . copies);
844+
gtk_print_settings_set_collate(t_settings, p_settings . collate);
845+
gtk_print_settings_set_orientation(t_settings,
846+
p_settings . orientation == PRINTER_ORIENTATION_PORTRAIT ? GTK_PAGE_ORIENTATION_PORTRAIT :
847+
p_settings . orientation == PRINTER_ORIENTATION_LANDSCAPE ? GTK_PAGE_ORIENTATION_LANDSCAPE :
848+
p_settings . orientation == PRINTER_ORIENTATION_REVERSE_PORTRAIT ? GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT :
849+
/*p_settings . orientation == PRINTER_ORIENTATION_REVERSE_LANDSCAPE ?*/ GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE);
850+
gtk_print_settings_set_duplex(t_settings,
851+
p_settings . duplex_mode == PRINTER_DUPLEX_MODE_SIMPLEX ? GTK_PRINT_DUPLEX_SIMPLEX :
852+
p_settings . duplex_mode == PRINTER_DUPLEX_MODE_LONG_EDGE ? GTK_PRINT_DUPLEX_HORIZONTAL :
853+
/* p_settings . duplex_mode == PRINTER_DUPLEX_MODE_SHORT_EDGE ? */ GTK_PRINT_DUPLEX_VERTICAL);
854+
gtk_print_settings_set_paper_width(t_settings, p_settings . paper_size_width, GTK_UNIT_POINTS);
855+
gtk_print_settings_set_paper_height(t_settings, p_settings . paper_size_height, GTK_UNIT_POINTS);
856+
gtk_print_unix_dialog_set_settings(dialog, t_settings);
857+
g_object_unref(t_settings);
858+
#endif
859+
873860
g_timeout_add(100, gtk_idle_callback, NULL);
874861
ret_code = gtk_dialog_run(GTK_DIALOG (dialog)) ;
875-
876-
862+
877863
if ( ret_code == GTK_RESPONSE_OK )
878864
{
879865
result = PRINTER_DIALOG_RESULT_OKAY ;
@@ -882,29 +868,28 @@ MCPrinterDialogResult MCA_gtk_printer_setup ( PSPrinterSettings &p_settings )
882868
t_printer = gtk_print_unix_dialog_get_selected_printer ( GTK_PRINT_UNIX_DIALOG ( dialog ) ) ;
883869
p_settings . printername = strdup ( gtk_printer_get_name ( t_printer ) ) ;
884870

885-
886-
GtkPrintSettings* t_printer_settings ;
887-
t_printer_settings = gtk_print_unix_dialog_get_settings ( GTK_PRINT_UNIX_DIALOG ( dialog )) ;
888-
889-
890871
if ( p_settings . outputfilename != NULL )
891872
delete (p_settings . outputfilename - 7 );
892873
p_settings . outputfilename = NULL ;
893874
p_settings . printertype = PRINTER_OUTPUT_DEVICE ;
894875

876+
GtkPrintSettings* t_printer_settings ;
877+
t_printer_settings = gtk_print_unix_dialog_get_settings ( GTK_PRINT_UNIX_DIALOG ( dialog )) ;
878+
895879
if ( strcmp( p_settings . printername, "Print to File") == 0 )
896880
{
897881
p_settings . printertype = PRINTER_OUTPUT_FILE ;
898882
p_settings . outputfilename = strdup ( gtk_print_settings_get ( t_printer_settings, GTK_PRINT_SETTINGS_OUTPUT_URI) ) ;
899883
p_settings . outputfilename += 7 ;
900884
}
885+
886+
#ifdef NOT_WORKING
887+
901888

902-
903-
GtkPageRange* t_ranges ;
889+
/* GtkPageRange* t_ranges ;
904890
MCInterval * t_rev_ranges ;
905891
906-
int4 t_range_count ;
907-
892+
int4 t_range_count;
908893
t_ranges = gtk_print_settings_get_page_ranges ( t_printer_settings , &t_range_count ) ;
909894
if ( t_range_count > 0 )
910895
{
@@ -917,13 +902,10 @@ MCPrinterDialogResult MCA_gtk_printer_setup ( PSPrinterSettings &p_settings )
917902
p_settings . page_ranges[a] . from++;
918903
p_settings . page_ranges[a] . to++;
919904
}
920-
}
921-
922-
923-
905+
}*/
906+
924907
p_settings . copies = gtk_print_settings_get_n_copies ( t_printer_settings ) ;
925908
p_settings . collate = gtk_print_settings_get_collate ( t_printer_settings ) ;
926-
927909
GtkPageOrientation tGtkOr = gtk_print_settings_get_orientation ( t_printer_settings ) ;
928910
switch(tGtkOr)
929911
{
@@ -943,8 +925,6 @@ MCPrinterDialogResult MCA_gtk_printer_setup ( PSPrinterSettings &p_settings )
943925
p_settings . orientation = PRINTER_ORIENTATION_REVERSE_LANDSCAPE ;
944926
break ;
945927
}
946-
947-
948928
switch ( gtk_print_settings_get_duplex ( t_printer_settings ) )
949929
{
950930
case GTK_PRINT_DUPLEX_SIMPLEX:
@@ -958,12 +938,15 @@ MCPrinterDialogResult MCA_gtk_printer_setup ( PSPrinterSettings &p_settings )
958938
case GTK_PRINT_DUPLEX_VERTICAL:
959939
p_settings . duplex_mode = PRINTER_DUPLEX_MODE_LONG_EDGE ;
960940
break ;
961-
962941
}
963-
942+
p_settings . paper_size_width = (uint4)ceil(gtk_print_settings_get_paper_width(t_printer_settings, GTK_UNIT_POINTS));
943+
p_settings . paper_size_height = (uint4)ceil(gtk_print_settings_get_paper_height(t_printer_settings, GTK_UNIT_POINTS));
944+
#endif
945+
946+
g_object_unref(t_printer_settings);
964947
}
965948

966-
gtk_widget_destroy(dialog);
949+
gtk_widget_destroy((GtkWidget *)dialog);
967950

968951
while (gtk_events_pending())
969952
gtk_main_iteration();
@@ -979,47 +962,6 @@ MCPrinterDialogResult MCA_gtk_printer_setup ( PSPrinterSettings &p_settings )
979962

980963
MCPrinterDialogResult MCA_gtk_page_setup (PSPrinterSettings &p_settings)
981964
{
982-
if (!MCModeMakeLocalWindows())
983-
{
984-
bool t_success;
985-
t_success = true;
986-
987-
MCLinuxPageSetup t_setup;
988-
t_setup . paper_width = p_settings . paper_size_width;
989-
t_setup . paper_height = p_settings . paper_size_height;
990-
t_setup . orientation = p_settings . orientation;
991-
t_setup . left_margin = t_setup . top_margin = t_setup . right_margin = t_setup . bottom_margin = 0;
992-
993-
MCAutoDataRef t_data_in;
994-
995-
if (t_success)
996-
t_success = MCLinuxPageSetupEncode(t_setup, &t_data_in);
997-
998-
uint32_t t_result;
999-
t_result = PRINTER_DIALOG_RESULT_ERROR;
1000-
if (t_success)
1001-
{
1002-
MCAutoDataRef t_data_out;
1003-
1004-
MCRemotePageSetupDialog(*t_data_in, &t_data_out, t_result);
1005-
1006-
if (t_result == PRINTER_DIALOG_RESULT_OKAY)
1007-
{
1008-
if (MCLinuxPageSetupDecode(*t_data_out, t_setup))
1009-
{
1010-
p_settings . paper_size_width = t_setup . paper_width;
1011-
p_settings . paper_size_height = t_setup . paper_height;
1012-
p_settings . orientation = (MCPrinterOrientation)t_setup . orientation;
1013-
}
1014-
else
1015-
t_result = PRINTER_DIALOG_RESULT_ERROR;
1016-
1017-
}
1018-
}
1019-
1020-
return (MCPrinterDialogResult)t_result;
1021-
}
1022-
1023965
GtkWidget * dialog ;
1024966

1025967
gint ret_code ;

0 commit comments

Comments
 (0)