[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [ox-odt] "optimal" width of tables
From: |
Rasmus |
Subject: |
Re: [O] [ox-odt] "optimal" width of tables |
Date: |
Tue, 24 Feb 2015 17:17:27 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Rasmus <address@hidden> writes:
> Libreoffice has a nice feature called AutoFit → Optimal width of columns.
> This seems to minimized the width of tables. By default Org sets the
> width to 100% which looks horrible for small tables. From this helpful
> post I gather that it can be fixed by a macro.
>
>
> http://ask.libreoffice.org/en/question/18664/optimal-column-width-for-all-tables-in-odt-documents/
>
> Is there any way to call macros from ox-odt? It seems you can call LO
> with the -invisible flag to apply macros without bothering the user...
So the particular problem can be solved using this macro under OrgMacros:
REM ***** BASIC *****
Sub OptimzeColumnWidth
Dim s As String
Dim i As Long
Dim oTables
Dim oTable
Dim oCell
oTables = ThisComponent.getTextTables()
If NOT oTables.hasElements() Then Exit Sub
For i = 0 To oTables.getCount() - 1
oTable = oTables.getByIndex(i)
ThisComponent.getCurrentController().select(oTable)
oFrame = ThisComponent.CurrentController.Frame
oDispHelper = createUnoService("com.sun.star.frame.DispatchHelper")
oDispHelper.executeDispatch(oFrame, ".uno:SelectTable", "", 0, Array())
oDispHelper.executeDispatch(oFrame, ".uno:SetOptimalColumnWidth", "",
0, Array())
Next
End Sub
Sub OptimizeColumnWidtSaveQuit
OptimzeColumnWidth()
ThisComponent.store()
ThisComponent.close(True)
StarDesktop.Terminate
end Sub
I couldn't figure out how to make comments in LO Basic, so that's why
there's not a back-reference to the url above...
It's called via
libreoffice --invisible --nofirststartwizard --headless --norestore
MYFILE.odt "macro:///Standard.OrgMacros.OptimizeColumnWidtSaveQuit()"
This is Makefile-friendly (and ox-publish), but it would be great if we
could (i) collect some useful macros like the above, and (ii) provide an
convenient way to call them on exported documents.
—Rasmus
--
Need more coffee. . .