DokuWiki

It's better when it's simple

User Tools

Site Tools


Sidebar

Translations of this page?:

Learn about DokuWiki

Advanced Use

Corporate Use

Our Community


Follow us on Facebook, Twitter and other social networks.

tips:openofficemacro

OpenOffice Macro

See also: http://forum.dokuwiki.org/post/23443

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.txt · Last modified: 2011-02-21 11:28 by HåkanS