Issue 117783 - Printer properties ignored from macros
Summary: Printer properties ignored from macros
Status: CLOSED FIXED
Alias: None
Product: General
Classification: Code
Component: code (show other issues)
Version: OOo 3.3
Hardware: PC Linux, all
: P3 Normal (vote)
Target Milestone: 3.4.0
Assignee: Oliver-Rainer Wittmann
QA Contact: issues@framework
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2011-04-09 14:31 UTC by andrew
Modified: 2017-05-20 10:32 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description andrew 2011-04-09 14:31:35 UTC
This macro prints a Write document. The document should print two pages per sheet in Landscape mode. The document prints normally. Note that this is a regression issue.

Sub PrintTwoPerPage
  Dim Props(0 To 1) As New com.sun.star.beans.PropertyValue
  Props(0).Name = "PageColumns" : Props(0).Value = 2
  Props(1).Name = "IsLandscape" : Props(1).Value = True
  If HasUnoInterfaces(ThisComponent, "com.sun.star.text.XPagePrintable") Then
    ThisComponent.setPagePrintSettings(Props())  '
    ThisComponent.printPages(Array())            'Use default properties
  Else
    Print "Sorry, this document does not support the XPagePrintable interface"
  End If
End Sub

Does the macro look familiar? The macro worked when this bug was fixed five years ago!

http://openoffice.org/bugzilla/show_bug.cgi?id=23411 

Note that I also tried this variant

Sub PrintTwoPerPage_second_try
  Dim Props
  Props = ThisComponent.getPagePrintSettings()
  For i = 0 To UBound(Props)
    If props(i).Name = "PageColumns" Then
      props(i).value = 2
    ElseIf props(i).Name = "IsLandscape" Then
      props(i).value = True
    End If
  Next
  ThisComponent.setPagePrintSettings(Props())
  ThisComponent.printPages(Array())
End Sub

In the deep dark recess of my mind, I keep thinking that Philipp Lohmann is aware of this problem and may even be working on it.
Comment 1 andrew 2011-04-09 15:03:03 UTC
Side note: I also tested against 3.4 alpha.

I took a look at sw/source/ui/uno/unotxdoc.cxx and it looks like this modifies this structure then puts it back.

const SwPagePreViewPrtData* pData = pDocShell->GetDoc()->GetPreViewPrtData();

At that point, I stopped tracing the code.
Comment 2 Oliver Brinzing 2011-04-10 14:08:43 UTC
,
Comment 3 Olaf Felka 2011-04-11 05:45:57 UTC
@ hi: Please have a look.
Comment 4 philipp.lohmann 2011-04-11 12:25:55 UTC
@od: I think this might have broken with the print changes in 3.3 in writer, could you please have a look ?
Comment 5 mdxonefour 2011-04-12 06:16:54 UTC
adding keyword "regression"
Comment 6 Mathias_Bauer 2011-05-04 11:08:57 UTC
Just a question: I don't get from the description since when this problem exists; I had a look at the code and from what I saw it is not surprising that the macro doesn't work: the settings are just ignored.

I browsed the source code of 3.2 and couldn't spot any important difference in that area; so before I dive deeper into that, I would like to know: which is the last OOo version that is known to execute the macro properly?
Comment 7 Oliver-Rainer Wittmann 2011-05-04 11:15:29 UTC
the print settings are ignored since the introduction of the new printing.

a fix for this issue is available and will be committed soon.
Comment 8 Oliver-Rainer Wittmann 2011-05-04 11:25:47 UTC
fixed in cws sw34bf06 - changed files:
sw/inc/unotxdoc.hxx,
sw/source/ui/uno/unotxdoc.cxx,
sfx2/source/view/viewprn.cxx,
vcl/inc/vcl/print.hxx,
vcl/source/gdi/print3.cxx,
vcl/source/window/printdlg.cxx,
change set http://hg.services.openoffice.org/cws/sw34bf06/rev/766a0b3ad79f

od->pl/mba: one of you, please review the fix
Comment 9 Oliver-Rainer Wittmann 2011-05-04 11:32:44 UTC
forgot to adjust the issue status
Comment 10 philipp.lohmann 2011-05-04 11:47:42 UTC
Reviewed, ok for me
Comment 11 Mathias_Bauer 2011-05-04 11:58:02 UTC
Reviewed, looks OK for me too.
Though checking only the first three characters of a parameter name looks a bid hackish.
Comment 12 andrew 2011-05-04 12:42:14 UTC
mba, you asked when this last worked..... I last tested with working code in late 1.x or early 2.x versions. Note that the original report claims that it worked five years ago.

Some items stopped working (I believe) when the new print dialog was introduced, but, I don't remember if that was this particular code.
Comment 13 Mathias_Bauer 2011-05-04 13:02:42 UTC
Thanks Andrew; as Oliver already fixed the issue, we don't need to know more about that.
Comment 14 Oliver-Rainer Wittmann 2012-06-13 12:29:17 UTC
getting rid of value "enhancement" for field "severity".
For enhancement the field "issue type" shall be used.