DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:openofficemacro

This is an old revision of the document!


I just started to use DokuWiki and was looking for an OpenOffice to DokuWiki Converter, so after searching the web and trying I noticed that none of the existing converters was converting embedded pictures (using OpenOffice 3 and Windows XP)!

But I remembered that the Writer2MoinMoin Converter did, so I checked the Macro and found the difference.

I am absolutely no expert in Macros or anything, but I thought I would share the work I did. I basically added the routine to parse for the embedded pictures and put it in the DokuWiki Macro. I don't know how to make a super easy installable extension or anything else with this, but maybe someone knows and can improve this even further?

  * The Original routine is Copyright © 2005 Ian Laurenson
  * Improvements and replacements for MoinMoinWikiEngine: 2005 KlausHeinisch
See: http://moinmoin.wikiwikiweb.de/FeatureRequests/OpenOfficeConversion
  * Further improvements for MoinMoinWikiEngine: 2005 Marc Santhoff search for "[ms"
  * both put together by RG in December 2008

Since I can't upload anything I just put the changes I made in here:

add:
const sTYPE_PNG = ".png"

change the line:
if oTextElement.supportsService("com.sun.star.text.Paragraph") Then

with this:
' [ms, detecting graphics attached to paragraph]
	if oTextElement.supportsService("com.sun.star.text.Paragraph") Then
			
		en = oTextElement.createContentEnumeration("com.sun.star.text.TextContent")
		while en.hasMoreElements()
			el = en.nextElement()
			if el.supportsService("com.sun.star.text.TextGraphicObject") then
				if InStr(el.GraphicURL, "file:///") > 0 OR InStr(el.GraphicURL, "http://") > 0 then
					subAddString(sPICTURESTART & FileNameoutofPath(el.GraphicURL) & sPICTUREEND)
				else ' embedded picture, no location known
					subAddString(sPICTURESTART & el.getName() & sTYPE_PNG & sPICTUREEND)
				endif
				
			endif
		wend
	' [ms, end]
tips/openofficemacro.1230586665.txt.gz · Last modified: 2011-02-21 11:28 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki