Apache OpenOffice (AOO) Bugzilla – Issue 35813
Insert source code in OOo Writer with syntaxic coloration
Last modified: 2013-02-07 22:43:34 UTC
Hello, I would like a new feature not present in M$ Word neither in OOo. It could be usefull to add a source code in OOo Writer. The source code could be copy and paste and mark with a style "Source Code" (a sort of verbatim environment in LaTeX) The source code could also be linked with a file (instead of copy and paste) The "Source Code" style could have some properties likes : Language highlighter (C C++ Java C# Python ...) Highlighter properties (colors / black and white / colors and bold and italic / black and white and bold and italic, etc...)... it could be usefull to have some predefined mode. (It should also works fine with a black and white printer using bold/italic) I think such a work could be done using emacs / kate / kwrite / scite code or ideas. It will be very usefull for computer science students who need to give a review. Regards
reassigned to BH.
Some ideas to do it : vim is a very powerfull text editor. === We can use it as a command line interface to export source code to html. Then, OOo will import the html in the document. An example with a Java applet 'CMonApplet.java' using vim vim -c ":let html_use_css = 1" -c ":runtime syntax/2html.vim" -c ":w" -c ":q"-c ":q" CMonApplet.java Emacs ===== We can also have a look at Emacs and 'htmlize.el' or 'ps-print' for ps export a2ps ==== We can also have a look at a2ps (for source code export to ps) code2color ========== code2color is an other way to get syntaxic coloration (same package that 'less') documentation at : perldoc -F /usr/bin/code2color use Perl My example : CMonAppplet.java import javax.swing.*; import java.awt.*; public class CMonApplet extends JApplet { public void init() { Container c = getContentPane(); c.add(new JLabel("hello")); } } I believe that due to licensing problem OOo can't provide emacs, vim or anything else BUT OOo should provide a script file that could run them... The script will ask for a source code to import ask for a highlighter command line ask for the output name (CMonApple.java.html for example) Hoping it will helps you Regars
I think using an external program is the only option for this one. This indeed should be quite easy to implement using a macro. But unfortunately OOo-developers are busy fixing bugs and don't have the time to handle even small issues. I added the easy2dev keyword so the casual developer can find this issue easier. You may ask on the various mailinglists or forums for help (maybe someone already implemented a similar thing).
There is some example in the document "Useful Macro Information For OpenOffice By Andrew Pitonyak" [1] Chapter 9. Formatting macros (Basic, CPP and Java) [1] http://www.pitonyak.org/AndrewMacro.odt
Andrew has made it available as an extension[1]. [1] http://extensions.services.openoffice.org/project/CodeFormatter
To grep the issues easier via "requirements" I put the issues currently lying on my owner to the owner "requirements".