Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » RichText,QTF,RTF... » Possible Bug with Printing under linux (Possible Bug with Printing under linux)
Possible Bug with Printing under linux [message #44649] Tue, 05 May 2015 12:32 Go to next message
woffleys is currently offline  woffleys
Messages: 9
Registered: December 2014
Promising Member
Hi everyone,

every time I try to print using the uword demo, it will only use the first printer in the list, which is not my default printer or the one i chose.

* /home/kris/upp.out/examples/GCC.Debug.Debug_Full.Gui.Shared/ UWord 05.05.2015 10:59:41, user: kris

05.05.2015 10:59:41 PDF (inital printer)
05.05.2015 10:59:45 RICOH_Aficio_MP_C3000 (selected printer)
05.05.2015 10:59:45 -d PDF -o media=A4,1Tray -o number-up=1 -n 1 (lp options)

does anyone have any idea which files I would need to check to fix this?
Re: Possible Bug with Printing under linux [message #44650 is a reply to message #44649] Tue, 05 May 2015 14:24 Go to previous messageGo to next message
woffleys is currently offline  woffleys
Messages: 9
Registered: December 2014
Promising Member
I've managed to fix the default printer issue, by editing the file: PrinterJob.cpp

the default printer fetched by "lpstat -d" has a space at the front and new line/carrage return at the end.

by adding:

if(p.StartsWith(" ")){ p = p.Mid(1); }
p.Replace("\r","");
p.Replace("\n","");

after: String p = h.Mid(q + 1); (line: 288)

this is now fixed in my copy. but as Im new to ultimate++ / C++ if someone has a better / simpler way, it would be appreciated.

I still dont know why a chosen printer is not used and the default / first is.
Re: Possible Bug with Printing under linux [message #44651 is a reply to message #44649] Tue, 05 May 2015 15:15 Go to previous messageGo to next message
woffleys is currently offline  woffleys
Messages: 9
Registered: December 2014
Promising Member
Hi Everyone,

I've finally figured out the issue. the printer options were not always being updated, so it could easily have the wrong printer.

I've attached my PrinterJob.cpp which has the changes in.

I hope this helps anyone in the future.
Re: Possible Bug with Printing under linux [message #44652 is a reply to message #44651] Wed, 06 May 2015 00:12 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 797
Registered: September 2012
Location: Poland, Kraków
Contributor
Hello,

Maybe the error is in dlg.IsCanceled() expression. Shouldn't it returns false if dialog is canceled. I mean (PrinterJob.cpp line 378):
	if(dodlg) {
		dlg.Run();
		if(dlg.IsCanceled()) // instead of if(!dlg.IsCanceled)
			return false;
	}

Simpler, we want to skip processing when user push cancel button.

I think we want to remove first element of string in this situation:
if(p.StartsWith(" ")){ p = p.Mid(1); }

so,
// Do we really want to remove first empty space? Can you post what dose "lpstat -d" return on your system.
if(p.StartsWith(" "))
   p.Remove(0);


P.S. 1
I will make test of this code later. Firstly I will need to create more printers on my Linyx machine If I can do it virtually.

P.S. 2
I attached modify PrinterJob.cpp file.

Sincerely,
Klugier


Ultimate++ - one framework to rule them all.

[Updated on: Wed, 06 May 2015 00:12]

Report message to a moderator

Re: Possible Bug with Printing under linux [message #44653 is a reply to message #44649] Wed, 06 May 2015 11:14 Go to previous messageGo to next message
woffleys is currently offline  woffleys
Messages: 9
Registered: December 2014
Promising Member
Hi,

Thankyou for the example:

if(p.StartsWith(" "))
   p.Remove(0);


its alot better than mine. Smile and my "lpstat -d" outputs
 kris@woffleys-it:~$ lpstat -d
system default destination: RICOH_Aficio_MP_C3000
kris@woffleys-it:~$ 


there's always been a space after the colon, but I cant tell you if its the same across all distributions.

I worked out that, PrinterJob::Execute0 is actually called twice, once with the dialog and then in GetDraw.

I changed
	if(dodlg) {
		dlg.Run();
		if(!dlg.IsCanceled())
			return false;
	}


to:

	if(dodlg) { dlg.Run(); } 


then before the function returns true, i've added:

	if(dodlg) {
		if (!dlg.IsCanceled())
			return false;
	}



this allows it to run twice, setting up the options that have caused me so many problems, but also allows the printout to be cancelled. Smile
Re: Possible Bug with Printing under linux [message #44656 is a reply to message #44653] Thu, 07 May 2015 00:47 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 797
Registered: September 2012
Location: Poland, Kraków
Contributor
Hello,

I fixed problems with PrinterJob. Can you check and let me know if everything works well. I drew on your solution, so many thanks.

P.S.
I modified "CtrlLib/CtrlUtil.h", because we need to add "dlgSuccess" variable to PrinterJob.

P.S. 2
If you know how to use .diff with u++ you can use it instead of replacing files.

Sincerely,
Klugier


Ultimate++ - one framework to rule them all.

[Updated on: Thu, 07 May 2015 00:55]

Report message to a moderator

Re: Possible Bug with Printing under linux [message #44660 is a reply to message #44656] Fri, 08 May 2015 23:13 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 797
Registered: September 2012
Location: Poland, Kraków
Contributor
Hello one more time Wink

It can be written even smarter. We don't need argument in "Execute0" private method, because we are calling it only once.

I have enclosed zip with necessary files for testing.

P.S.
Woffleys please let me know if everything is OK in my patch.

Sincerely,
Klugier


Ultimate++ - one framework to rule them all.

[Updated on: Fri, 08 May 2015 23:13]

Report message to a moderator

Re: Possible Bug with Printing under linux [message #44664 is a reply to message #44660] Mon, 11 May 2015 16:11 Go to previous messageGo to next message
woffleys is currently offline  woffleys
Messages: 9
Registered: December 2014
Promising Member
Hi Klugier,

sorry, I was away for a few days and just got back. i'll test it tomorrow once i've caught up.
Re: Possible Bug with Printing under linux [message #44667 is a reply to message #44649] Tue, 12 May 2015 16:58 Go to previous messageGo to next message
woffleys is currently offline  woffleys
Messages: 9
Registered: December 2014
Promising Member
Hi Klugier,

I've done a few tests and the patch works fine. Smile

I've spotted 2 more errors, which are very easy to fix.

The PrinterLayout (in Ctrl.lay) has paper and slot droplists the wrong way around.

and for the printer options, i've changed line 254 from:

	Vector<String> l = Split(System("lpoptions -l -d " + String(~printer)), '\n');


to:

	Vector<String> l = Split(System("lpoptions -d " + String(~printer) + " -l"), '\n');


this way it always lists the selected printer's options, rather than the previously selected printer.
Re: Possible Bug with Printing under linux [message #44673 is a reply to message #44667] Wed, 13 May 2015 22:47 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 797
Registered: September 2012
Location: Poland, Kraków
Contributor
Hello Woffleys,

woffleys wrote on Tue, 12 May 2015 16:58

The PrinterLayout (in Ctrl.lay) has paper and slot droplists the wrong way around.

This change makes sense. Even "lpoptions --help" suggest yours order.

Final .diff is waiting for deployment to Upp trunk. However, firstly Mirek should accept this patch. I will give you link to the Upp bugtrack with bug discussed in this topic: http://www.ultimatepp.org/redmine/issues/1054. If status will change to "Accept" it means that patch is on the trunk.

Sincerely and thanks for co-op,
Klugier


Ultimate++ - one framework to rule them all.

[Updated on: Wed, 13 May 2015 22:54]

Report message to a moderator

Re: Possible Bug with Printing under linux [message #44675 is a reply to message #44673] Thu, 14 May 2015 11:45 Go to previous messageGo to next message
woffleys is currently offline  woffleys
Messages: 9
Registered: December 2014
Promising Member
Hi Klugier,

im glad I was of some help. Smile

Sincerely,

Kris. (woffleys)
Re: Possible Bug with Printing under linux [message #44759 is a reply to message #44675] Wed, 17 June 2015 23:07 Go to previous message
Klugier is currently offline  Klugier
Messages: 797
Registered: September 2012
Location: Poland, Kraków
Contributor
Hello Woffleys,

The patch is presenttly on the trunk, so it will be avaliable in next upp releases.

P.S.
You can write to Mirek if you want to be on contributors list.

Sincerely,
Klugier


Ultimate++ - one framework to rule them all.
Previous Topic: QTF to ODF (Open Document Format) converter
Next Topic: Clipboard: "RTF" before "IMAGES" format, patch provided
Goto Forum:
  


Current Time: Wed Dec 02 07:05:09 CET 2020

Total time taken to generate the page: 0.02848 seconds