Hi, Barry asked me in a PM how to get access to an odt-file. After several hours of head crashing I leave it as is and give you the low level sample. I wanted to get it paragraph by paragraph. But unfortunately, it's hard for me to translate Java samples to AutoLisp.
I think, Patrick has much more experiences with OpenOffice than I. Maybe he can uncover the secrets of the OpenOffice API.
Here is my sample:
(defun ooffice_writer_content (strDoc / strDocType strVer strNam strFile oDesktop oService oStruct
oWriter strContent oText arrProps string_subst)
(if (and ;; check if OOffice is installed
(setq strDocType "StarWriterDocument")
(setq strVer (vl-registry-read (strcat "HKEY_CLASSES_ROOT\\soffice." strDocType "\\CurVer")))
(setq strNam (vl-registry-read (strcat "HKEY_CLASSES_ROOT\\" strVer)))
(setq strFile (vl-registry-read (strcat "HKEY_CLASSES_ROOT\\" strVer "\\protocol\\StdFileEditing\\server")))
(findfile strFile))
(progn
(grtext -1 "I'm loading OpenOffice Writer, please wait...")
(defun string_subst (strNew strOld strText)
(while (vl-string-search strOld strText)
(setq strText (vl-string-subst strNew strOld strText))
); while
strText
); string_subst
(if (and strDoc (member (substr strDoc 2 1) (list ":" "\\")))
(setq strDoc (strcat "file:///" (string_subst "/" "\\" strDoc)))
(setq strDoc "private:factory/swriter")
); if
(setq oService (vlax-get-or-create-object "com.sun.star.ServiceManager"))
(setq oDesktop (vlax-invoke-method oService "createInstance" "com.sun.star.frame.Desktop"))
(setq oStruct (vlax-invoke-method oService "Bridge_GetStruct" "com.sun.star.beans.PropertyValue"))
(vlax-put-property oStruct "Name" "Hidden")
(vlax-put-property oStruct "Value" :vlax-false)
(setq arrProps (vlax-make-safearray vlax-vbvariant (cons 0 0)))
(vlax-safearray-put-element arrProps 0 oStruct)
(setq oWriter (vlax-invoke-method oDesktop "LoadComponentFromURL" strDoc "_blank" 0 arrProps))
(setq oText (vlax-invoke oWriter 'getText))
(setq strContent (vlax-invoke oText 'getString))
(vlax-release-object oText)
(vlax-release-object oWriter)
(vlax-release-object oStruct)
(vlax-release-object oDesktop)
(vlax-release-object oService)
); progn
(grtext -1 "")
); if
strContent
); ooffice_writer_content
Here you can find the Java sample:
{2} .
Regards, Fred