Issue 119417 - Problems with PDF export using FilterData (VB-Script using COM interface)
Summary: Problems with PDF export using FilterData (VB-Script using COM interface)
Status: CLOSED NOT_AN_OOO_ISSUE
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC Windows XP
: P3 Normal
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-25 10:50 UTC by fs
Modified: 2013-02-24 21:08 UTC (History)
3 users (show)

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


Attachments
Windows VBS script (986 bytes, application/octet-stream)
2012-05-25 10:50 UTC, fs
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description fs 2012-05-25 10:50:23 UTC
Created attachment 77598 [details]
Windows VBS script

The problem is related to PDF export using COM Bridge on Windows: I am trying to export a doc file to PDF.
Basically, the export works fine but thenone of  FilterData properies take effect. Using the same code as an OpenOffice Macro works fine.

VBS Script
----------
I am executing the following VB script (see attached vbs file) on a Wndows XP PC with Apache OpenOffice 3.4:

=========================================================================================
  Set oSM = CreateObject("com.sun.star.ServiceManager")
  Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
  Dim OpenParam(0)
  Set OpenParam(0) = MakePropertyValue(oSM, "Hidden", false)  
  Set oDoc = oDesk.loadComponentFromURL("file:///c:/test.odt", "_blank", 0, OpenParam)

  ' Save the document using a filter.
  Dim SaveFilter(0)
  Dim SaveOptions(1)
  Set SaveFilter(0) = MakePropertyValue(oSM,  "PageRange", "1" )
  Set SaveOptions(0)= MakePropertyValue(oSM,  "FilterName", "writer_pdf_Export" )
  Set SaveOptions(1)= MakePropertyValue(oSM,  "FilterData", SaveFilter )
  Call oDoc.storeToURL( "file:///c:/test.pdf", SaveOptions)
  Call oDoc.close( false )
	
Function MakePropertyValue(oServiceManager, cName, uValue)
  Dim oPropertyValue
  Set oPropertyValue = oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
  oPropertyValue.Name = cName
  oPropertyValue.Value = uValue  
  Set MakePropertyValue = oPropertyValue
End Function
=========================================================================================

The problem is, that the FiltaData property does not take effect - all pages are exported as PDF even though I set the "PageRange" property to "1".
I tested some other properties, like "MaxImageResolution" or security related ones like "EncryptFile" and "DocumentOpenPassword" with no success. It seems that none of these work.


OpenOffice Macro
-----------------
I made the same code as a Macro within OpenOffice and it works fine and the FilterData works:

================================================================
Sub Main
    Dim OpenParam(0)
    Set OpenParam(0)=MakePropertyValue( "Hidden", false )
    oDoc = StarDesktop.loadComponentFromURL( "file:///c:/test.odt", "_blank", 0,OpenParam )
   
   ' Save the document using a filter.
    Dim SaveFilter(0)
    Dim SaveOptions(1)
    Set SaveFilter(0) = MakePropertyValue( "PageRange", "1" )
    Set SaveOptions(0)= MakePropertyValue( "FilterName", "writer_pdf_Export" )
    Set SaveOptions(1)= MakePropertyValue( "FilterData", SaveFilter )
    oDoc.storeToURL( "file:///c:/test.pdf", SaveOptions)
    oDoc.close( false )
End Sub

Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
   Dim oPropertyValue As New com.sun.star.beans.PropertyValue
   oPropertyValue.Name = cName
   oPropertyValue.Value = uValue
   MakePropertyValue() = oPropertyValue
End Function 
================================================================

It looks like the COM interface does not work as expected.
Comment 1 bmarcelly 2012-05-27 08:33:59 UTC
This is a subtlety of COM bridge. You have to specify explicitly that SaveFilter is an array of com.sun.star.beans.PropertyValue.

See thread [Solved] [PHP] Problem to export PDF /A with puno
http://user.services.openoffice.org/en/forum/viewtopic.php?f=44&t=36163

Your code should work with these changes:

Dim unoWrap

Set unoWrap = oSM.Bridge_GetValueObject
unoWrap.set "[]com.sun.star.beans.PropertyValue", SaveFilter

Set SaveOptions(1)= MakePropertyValue(oSM,  "FilterData", unoWrap)
Comment 2 fs 2012-05-27 16:25:17 UTC
Yes, this fixed the issue. Thanks