Issue 35813 - Insert source code in OOo Writer with syntaxic coloration
Summary: Insert source code in OOo Writer with syntaxic coloration
Status: CONFIRMED
Alias: None
Product: Writer
Classification: Application
Component: formatting (show other issues)
Version: OOo 1.1.2
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords: oooqa
Depends on:
Blocks:
 
Reported: 2004-10-19 17:41 UTC by scls19fr
Modified: 2013-02-07 22:43 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description scls19fr 2004-10-19 17:41:53 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
Comment 1 michael.ruess 2004-10-20 06:40:13 UTC
reassigned to BH.
Comment 2 scls19fr 2004-12-21 08:05:36 UTC
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

Comment 3 lohmaier 2004-12-26 20:44:21 UTC
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).
Comment 4 aladdin2k7 2008-05-07 08:45:19 UTC
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
Comment 5 aladdin2k7 2008-05-09 17:01:39 UTC
Andrew has made it available as an extension[1].

[1] http://extensions.services.openoffice.org/project/CodeFormatter
Comment 6 bettina.haberer 2010-05-21 15:17:22 UTC
To grep the issues easier via "requirements" I put the issues currently lying on
my owner to the owner "requirements".