How do I embed source code or HTML in Open Office Org Presentations without using screenshots?

前端 未结 9 849
忘了有多久
忘了有多久 2021-01-31 01:59

I need to write a lot of class courses presentations to my programming class, and I constantly need to show source code (mainly C

相关标签:
9条回答
  • 2021-01-31 02:47

    Pasting from Eclipse into OpenOffice Impress directly seems to lose the coloring. However, first pasting into OO Writer and from there into OO Impress does work.

    0 讨论(0)
  • 2021-01-31 02:48

    Update: I have released this macro as a LibreOffice extension. You can install it from the official site: Code Highlighter


    I had the same problem but for Java and finally I found a native solution using Python macro which is tested in LibreOffice 5.

    Installation

    Step 1: Install libreoffice-script-provider-python:

    sudo apt-get install libreoffice-script-provider-python
    

    Step 2: Install pygments for Python 3:

    sudo pip3 install python3-pygments
    

    Step 3: Download Highlight.py

    Step 4: Copy the Highlight.py to /usr/lib/libreoffice/share/Scripts/python/

    sudo cp Highlight.py /usr/lib/libreoffice/share/Scripts/python/
    

    Step 5: Set the Read-Only permission to the script.

    sudo chmod 0444 /usr/lib/libreoffice/share/Scripts/python/Highlight.py
    

    Step 6: Open the LibreOffice Writer and goto Tools -> Customize -> Keyboard

    • Select the LibreOffice option button (Available on top left corner)
    • Select any desired shortcut
    • Select share/Highlight/Highlight_source_code under the Functions Category
    • Click on the Modify button to set the shortcut

    Usage

    LibreOffice Impress

    • Open LibreOffice Impress.
    • Insert a Text Box (Insert -> Text Box).
    • Copy and paste any code snippet into that Text Box.
    • Create a new Style (Right click on an existing style -> New...)
    • Name the Style as code-<language>
    • Apply the style to your code snippet Text Box.
    • Select the Text Box.
    • Use your shortcut keys to execute the macro.

    LibreOffice Writer/Calc

    • Open LibreOffice Writer/Calc.
    • Insert a Text Box (Insert -> Text Box).
    • Copy and paste any code snippet into that Text Box.
    • Right click on the Text Box and select 'Description'.
    • Add a description in the following format: code-<language>
    • Select the Text Box
    • Use your shortcut keys to execute the macro.

    UPDATE:

    I have added custom style support to this extension. Use code-<language> for default style and code-<language>-<style> for custom style. Available styles are listed in my Git Hub page.

    For example Code-Java-Emacs will colorize the Java code using Emacs style.

    For more details, visit to the Git Hub link: libreoffice-code-highlighter

    0 讨论(0)
  • 2021-01-31 02:48

    You can easly use a table with 1 line and 1 column, copy and past your code from your favorit IDE, open office will preserve your code style.

    0 讨论(0)
提交回复
热议问题