1

Introduction

I have a docker container with a GUI in which I registered my macro through LibreOffice Calc. Using the GUI given by the docker container, I can successfully run the macro via the command line. When I load the image in a Kubernetes Pod, however, the macro hangs indefinitely when I try to run it.

Here is the macro:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module1" script:language="StarBasic">REM  *****  BASIC  *****

Sub FitToPage
    Dim document As Object, pageStyles As Object
    document = ThisComponent
    pageStyles = document.StyleFamilies.getByName(&quot;PageStyles&quot;)
    For i = 0 To Document.Sheets.Count - 1
        Dim sheet As Object, Style As Object
        sheet = document.Sheets(i)
        style = pageStyles.getByName(sheet.PageStyle)
        style.ScaleToPagesX = 1
        style.ScaleToPagesY = 999
    Next
    On Error Resume Next
    document.storeSelf(Array())
    document.close(true)
End Sub
</script:module>

Command to run macro:

soffice --headless --nologo --nofirststartwizard --norestore macro://Standard.Module1.FitToPage <file>.xlsx

The strange thing is, I am able to run other headless libreoffice commands just fine. For example, if I were to try to just convert the file to a pdf without changing the scaling using soffice --headless --nologo --nofirststartwizard --norestore --convert-to pdf --outdir . <file>.xlsx, then soffice runs perfectly fine.

Other Information:

  • Ubuntu 18.04
  • I instantiated and am running libre as root.
  • The module was loaded in via LibreOffice Calc.
  • The module can be found at ~/.config/libreoffice/4/user/basic/Standard/Module1.xba.
  • I have other pods running in the cluster just fine
  • I have not configured the GUI for the docker image in the cluster
  • I am dumping resources into it (15Gi mem, 15 CPU)

Conclusion

Any help at all would be much appreciated. I can provide any more information required upon request.

UPDATE

For me, running soffice & to run it in the background before running the macro seemed to work. It might have something to do with how libreoffice handles its state?

This isn't a perfect solution by any means, so I'm going to leave it open in case someone has a better solution.

P....
  • 17,421
  • 2
  • 32
  • 52

1 Answers1

1

Your call of the macro is missing a slash /.

The command line should be

    $ soffice --headless --nologo --nofirststartwizard --norestore macro:///Standard.Module1.FitToPage <file>.xlsx 

Running in headless mode will obscure any security messages about running macros, simply removing --headless allows you to check if there are any security messages possibly about running unknown macros that you need to authorsise, before a --headless run will proceed and complete.

X Tian
  • 766
  • 7
  • 13