Rasmus <ras...@gmx.us> 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. . .