Bug 619902 - headless option does not work right
Summary: headless option does not work right
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: openoffice.org
Version: 13
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Caolan McNamara
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-07-30 20:16 UTC by Need Real Name
Modified: 2010-08-03 08:39 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2010-07-31 12:49:04 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
code for batch export (1.53 KB, text/plain)
2010-07-30 20:18 UTC, Need Real Name
no flags Details
replacement code (1.51 KB, text/plain)
2010-07-31 12:47 UTC, Caolan McNamara
no flags Details

Description Need Real Name 2010-07-30 20:16:28 UTC
I am using a .vba script to convert .xls to .html
assume the  /tmp/m.xls is input xls 
then the command

soffice -calc -nologo -nofirststartwizard -view -norestore -headless -nolockcheck -unaccept=all 'macro:///Standard.Module1.SaveAsHTML("/tmp/m.xls","/tmp/m.xls.html","HTML (StarCalc)")'

convert m.xls to m.xls.html just fine.

The problem is: in case the file m.xls has, for example HTML content inside then:

1. if there exist an "openoffice open window" then the command above 
give a dialogue "Filter not found" (because it cannot import .html as .xls) DESPITE THE OPTION -headless
if I click OK - it exits & fails to convert, as it should be.
But -headless should not give no dialogue at all.

2. This became much more problematic if there is no open openoffice window.
Then the command above NEVER EXITS,just hangs forever. Probably because it expects a click on "Filter not found", and there is no chance to click.
This create a very serious problem in using openoffice as batch format converter,
because if input format is wrong - soffice never exit.

Comment 1 Need Real Name 2010-07-30 20:18:15 UTC
Created attachment 435637 [details]
code for batch export

copy the content to Module1 (inside Tools->Macro)

Comment 2 Caolan McNamara 2010-07-31 12:46:45 UTC
1. Yes, OOo is always a single process, so if there is a non-headless instance already running, then a second headless is not created, so the -headless option doesn't affect the already running OOo that executes the macro.

2. No, it isn't stuck on a "Filter not found" dialog. Its the document is opened in writer successfully, the store to url fails, so it jumps to the ConversionError and the document isn't closed, so its still there idling.

Try this replacement code.

Comment 3 Caolan McNamara 2010-07-31 12:47:55 UTC
Created attachment 435749 [details]
replacement code

This might work better

Comment 4 Need Real Name 2010-07-31 19:15:05 UTC
Caolan,
Thanks a lot. The code you suggested works fine with invalid content inside input file.
The only problem left - if input file does not exist at all.
Then I get an error (and window opened) and stuck at
 oDoc.close( True )

I tries the handling below
----------------------
Sub SaveAsHTML(iFile, oFile, convertername)
   ON ERROR GOTO ConversionError
......conversion code....
   ConversionError:
   ON ERROR Resume Next
   oDoc.close( True )
   'exit sub
End Sub
------------------------------

but the result is the same - if input file does not exist -
the new window is opened and oDoc.close( True ) is highlited.
I can do a workaround to test file existence outside of OO,
but would much prefer to handle oDoc.close( True ) errors in basic.

Comment 5 Need Real Name 2010-08-01 20:10:20 UTC
I fixed mentioned problem this way, is it correct?

Sub SaveAsHTML(iFile as String, oFile as String, convertername as String)
   ON ERROR Resume Next
   Dim oDoc As Object
   oDoc = StarDesktop.loadComponentFromURL(ConvertToURL(iFile), "_blank", 0, Array(MakePropertyValue("Hidden",True),MakePropertyValue("ReadOnly",true),))

   if IsObject( oDoc ) Then
     oDoc.storeToURL(ConvertToURL(oFile), Array(MakePropertyValue("FilterName",convertername),))
     oDoc.close( True )
   EndIf
   'exit sub
End Sub

Comment 6 Caolan McNamara 2010-08-03 08:39:54 UTC
looks fairly reasonable


Note You need to log in before you can comment on or make changes to this bug.