emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: [ox-odt] "optimal" width of tables
Date: Tue, 24 Feb 2015 17:17:27 +0100	[thread overview]
Message-ID: <87d24z2siw.fsf@gmx.us> (raw)
In-Reply-To: 87k2z72vht.fsf@gmx.us

Rasmus <rasmus@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. . .

      reply	other threads:[~2015-02-24 16:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-24 15:13 [ox-odt] "optimal" width of tables Rasmus
2015-02-24 16:17 ` Rasmus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d24z2siw.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).