Issue 63866 - When printing through API, "CopyCount" does not work if "Collate" is used
Summary: When printing through API, "CopyCount" does not work if "Collate" is used
Status: CLOSED FIXED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC Windows XP
: P3 Trivial
Target Milestone: ---
Assignee: joerg.skottke
QA Contact: issues@api
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-31 14:15 UTC by cheepee
Modified: 2017-05-20 09:32 UTC (History)
4 users (show)

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


Attachments
Simple VB6.0 project that print a file with "CopyCount" and "Collate" property (2.80 KB, application/x-compressed)
2006-04-04 09:16 UTC, cheepee
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description cheepee 2006-03-31 14:15:52 UTC
i work with VB6.0 and Open Office 2.0.0. I want to print a document with 
selecting the page and the number of copy, but the property "CopyCount" does 
not not work.

Here is my code:
Dim odoc as object
Dim arg(2) as object
Dim arg1() as object

'change the printer name 
Set arg1(0) = MakePropertyValue("Name", nomImprim)
oDoc.Printer = arg3()
'number of copies to print
Set arg(0) = MakePropertyValue("CopyCount", "2")            
Set arg(1) = MakePropertyValue("Collate", True)
'page selection
Set arg(2) = MakePropertyValue("Pages", "1")
'call the print function
CallByName odoc, "print", VbMethod, arg()

I always have 1 copy of my page instead of 2. I tried without the "Collate" 
property but no success.
If I use the GUI of Open Office and select 2 copies, the result is correct.
Does someone have an idea?
Comment 1 lars 2006-03-31 16:16:43 UTC
record a macro where you print 2 copies using the dialogue and look at the code; 
here is the code :-)

dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Copies"
args1(0).Value = 2
args1(1).Name = "Collate"
args1(1).Value = false

dispatcher.executeDispatch(document, ".uno:Print", "", 0, args1()
Comment 2 stephan.wunderlich 2006-04-03 09:28:09 UTC
sw->cheepee: the following OOo-Basic macro works like a charm, so there seems to
be no general problem with that property ...

xDoc = ThisComponent
dim args(0) as new com.sun.star.beans.PropertyValue
args(0).Name = "CopyCount"
args(0).Value = 2
xDoc.print(args())

I noticed that you assign a String to the property instead of an Integer ...
could that already be the problem ? ... If not, could you attach a working VB6
sample to this issue to make the behaviour reproducible ?
Comment 3 cheepee 2006-04-04 09:13:35 UTC
It seems that the "Collate" property is the problem.

Here is the code that I tested:
'*********************************
Public Sub main()
Dim oSM As Object
Dim oDesk As Object
Dim oDoc As Object
Dim filename As String
Dim arg() As Object
Dim arg1(0) As Object
Dim arg2(0) As Object

'this is a 2 pages file
'******SET YOUR OWN FILE NAME******
filename = "C:\Projet_Impression_OO\test_2pages.RTF"
'************************************
Set oSM = CreateObject("com.sun.star.ServiceManager")
Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
'load the file in an empty OO frame
Set oDoc = oDesk.loadComponentFromURL("file:///" & Replace
(filename, "\", "/"), "_blank", 0, arg())

'set the printer name
'****SET YOUR PRINTER NAME*****************
Set arg1(0) = MakePropertyValue("Name", "Canon CLC-iR C3220-C1 PCL5c")
'******************************************
oDoc.Printer = arg1()

'I want to print two pages of each pages of the file: so 4 pages
Set arg2(0) = MakePropertyValue("CopyCount", 2)
'sort the pages
Set arg2(1) = MakePropertyValue("Collate", True)
'print the doc
CallByName oDoc, "print", VbMethod, arg2()
End Sub

Public Function MakePropertyValue(cName, uValue) As Object
    
  Dim oPropertyValue As Object
  Dim oSM2 As Object
    
  Set oSM2 = CreateObject("com.sun.star.ServiceManager")
  Set oPropertyValue = oSM2.Bridge_GetStruct
("com.sun.star.beans.PropertyValue")
  oPropertyValue.Name = cName
  oPropertyValue.Value = uValue
      
  Set MakePropertyValue = oPropertyValue

End Function
'***************************************************
'END PROGRAM

I tried to print without the Collate property and it seems to work fine 
without this property: I got 4 pages. 
Comment 4 cheepee 2006-04-04 09:16:21 UTC
Created attachment 35485 [details]
Simple VB6.0 project that print a file with "CopyCount" and "Collate" property
Comment 5 stephan.wunderlich 2006-04-04 14:08:55 UTC
sw->mba: seems the "Collate" property indeed invalidates the value of the
property "CopyCount" ...

xDoc = ThisComponent
dim args(1) as new com.sun.star.beans.PropertyValue
args(0).Name = "CopyCount"
args(0).Value = 2
args(1).Name = "Collate"
args(1).Value = true
xDoc.print(args())

only prints one copy of the document, but

sub main
xDoc = ThisComponent
dim args(0) as new com.sun.star.beans.PropertyValue
args(0).Name = "CopyCount"
args(0).Value = 2
xDoc.print(args())
end sub

prints two copies as expected.

Comment 6 Mathias_Bauer 2006-06-29 12:56:21 UTC
adjusting target
Comment 7 Martin Hollmichel 2007-11-09 17:28:45 UTC
set target from 2.x to 3.x according to
http://wiki.services.openoffice.org/wiki/Target_3x
Comment 8 Mathias_Bauer 2007-11-12 14:45:37 UTC
I would like to keep the 2.x target
Comment 9 cno 2007-11-12 14:55:35 UTC
changed summary
Comment 10 cno 2007-11-12 14:56:44 UTC
now removed typo from summary :-\
Comment 11 Mathias_Bauer 2008-01-11 10:13:33 UTC
target 3.0
Comment 12 Mathias_Bauer 2008-06-23 15:22:59 UTC
There's some strange code in the sfx2 code:



// if "Collate" was checked, the printer must handle the CopyCount itself,
// usually this is handled by the printer driver
if( bCollate )
    // set printer to default, handle multiple copies explicitly
    pPrinter->SetCopyCount( 1 );
else
    pPrinter->SetCopyCount( nCopies );

So far, so good. But where and how *is* that handled?

pl, any idea?
Comment 13 philipp.lohmann 2008-06-23 15:38:36 UTC
That depends on what you mean; SetCopyCount on a vcl printer will pass that
number of copies to the printer driver (windows speak), which will in turn
produce that number of copies. When collate is checked, writer produces n times
the same page sequence and sets the copy count to 1, thereby producing page
1-2-3-1-2-3-1-2-3 instead of 1-1-1-2-2-2-3-3-3 as would be with collation off.

see also issue 88333
Comment 14 Mathias_Bauer 2008-07-01 13:57:56 UTC
This bug obviously is fixed at least in 3.0 Beta. The macro from sw

xDoc = ThisComponent
dim args(1) as new com.sun.star.beans.PropertyValue
args(0).Name = "CopyCount"
args(0).Value = 2
args(1).Name = "Collate"
args(1).Value = true
xDoc.print(args())

prints two copies, as expected
Comment 15 Mathias_Bauer 2008-07-01 13:58:47 UTC
please verify