From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: [ox-odt] "optimal" width of tables Date: Tue, 24 Feb 2015 17:17:27 +0100 Message-ID: <87d24z2siw.fsf@gmx.us> References: <87k2z72vht.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQIBI-0003uD-Lc for emacs-orgmode@gnu.org; Tue, 24 Feb 2015 11:17:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQIBE-000508-Jk for emacs-orgmode@gnu.org; Tue, 24 Feb 2015 11:17:56 -0500 Received: from plane.gmane.org ([80.91.229.3]:53195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQIBE-0004zv-Ce for emacs-orgmode@gnu.org; Tue, 24 Feb 2015 11:17:52 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YQIBA-0002xe-G9 for emacs-orgmode@gnu.org; Tue, 24 Feb 2015 17:17:48 +0100 Received: from ip5b4025d5.dynamic.kabel-deutschland.de ([91.64.37.213]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 24 Feb 2015 17:17:48 +0100 Received: from rasmus by ip5b4025d5.dynamic.kabel-deutschland.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 24 Feb 2015 17:17:48 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Rasmus 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. . .