Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

openoffice

127 views
Skip to first unread message

Mariano

unread,
Apr 19, 2004, 1:15:33 PM4/19/04
to
hi pals,

I'm looking some explames to integrate open office (writer) and pb 7
do you have some of it or have an idea where i can find examples?
thanks
mariano


Stephan Beck

unread,
Apr 20, 2004, 2:37:41 AM4/20/04
to
Mariano schrieb:
Here
(http://udk.openoffice.org/common/man/tutorial/office_automation.html)
you can find a VBS-Sample (OLE). See also
http://development.openoffice.org/ ... there are some links that might
be helpful... especially the Basic Programmer's Guide and the SDK.

Good luck,
Stephan B.

Stephan Beck

unread,
Apr 20, 2004, 2:38:24 AM4/20/04
to
Mariano schrieb:

Stephan Beck

unread,
Apr 20, 2004, 7:24:21 AM4/20/04
to
Stephan Beck schrieb:
Here's an untested code snippet ...
------------BEGIN---------------------->>>
OLEObject l_objServiceManager
OLEObject l_objDesktop
OLEObject l_objCoreReflection
OLEObject l_objDocument
OLEObject l_objPropertyValue[]
OLEObject l_objText
OLEObject l_objCursor
long l_lRet

l_objServiceManager = CREATE OLEObject
l_lRet = l_objServiceManager.ConnectToNewObject
("com.sun.star.ServiceManager")

IF l_lRet = 0 Then
l_objDesktop =
l_objServiceManager.createInstance("com.sun.star.frame.Desktop")
l_objCoreReflection =
l_objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")


/* Set Properties for Open (!!! OR search for "Bridge_GetStruct" (since
OpenOffice1.1) on http://www.oooforum.org/forum/viewforum.php?f=9 */
l_objPropertyValue[1] = f_oo_makepropertyvalue("ReadOnly", true)

l_objDocument =
l_objDesktop.loadComponentFromURL("private:factory/swriter", "_blank",
0, l_objPropertyValue)

IF IsValid(l_objDocument) THEN

'Create a text object
l_objText= l_objDocument.getText()

'Create a cursor object
l_objCursor= l_objText.createTextCursor()

'Inserting some Text
l_objText.insertString(l_objCursor, "The first line in the newly
created text document.")


END IF

l_objServiceManager.disconnectobject()
END IF
<<<------------------------------------------END-------------


/////////////////////////////////////////////////////////////
oleobject f_oo_makepropertyvalue(string sName, any aAnyValue)
// Create PropertyValue
OLEObject l_objPropertyValue
OLEObject l_objPropertyClass

IF IsValid(i_objCoreReflection) THEN
l_objPropertyClass =
i_objCoreReflection.forName("com.sun.star.beans.PropertyValue")

//!!!! CreateObject takes an OUT parameter.
// refer to the UNO IDL interface descriptions, to find
// the proper parameter types
l_objPropertyClass.createObject(REF l_objPropertyValue)

l_objPropertyValue.Name = sName
l_objPropertyValue.Value = aAnyValue
END IF

RETURN l_objPropertyValue
//////////////////////////////////////////////////////////////

Hope this helps,
Stephan B.

Mariano

unread,
Apr 20, 2004, 11:17:12 AM4/20/04
to
stephan,
thanks for your answer. should i create an user object to integrate it or i
can do in a window???
thanks for your answer
mariano


Stephan Beck

unread,
Apr 21, 2004, 7:55:18 AM4/21/04
to
Mariano schrieb:
Hi Mariano,
Both variants are possible...But I would prefer a UserObject. Maybe you
create a basis class that contain a collection of simple functions (like
the f_oo_makepropertyvalue(...) - see my sample code) and that holds the
most important instance variables (i_objServiceManager, i_objDesktop,
i_objCoreReflection) ... after that you can inherit more classes ... for
example one class for sWriter, one for sCalc and so on ...
Maybe you decide to use your OpenOffice-UserObject in multiple ways in
your Application ...so it's easier to integrate it.

Stephan B.

Mariano

unread,
Apr 22, 2004, 12:38:12 PM4/22/04
to
Stephan
this is mariano from sybase groups
I'm having problmes with your code . with the function for example
OLEObject l_objPropertyValue
OLEObject l_objPropertyClass

-->IF IsValid(i_objCoreReflection) THEN
whta's the type of i_objCoreReflection or this should be l_


l_objPropertyClass =
i_objCoreReflection.forName("com.sun.star.beans.PropertyValue")

//!!!! CreateObject takes an OUT parameter.
// refer to the UNO IDL interface descriptions, to find
// the proper parameter types
l_objPropertyClass.createObject(REF l_objPropertyValue)

l_objPropertyValue.Name = sName
l_objPropertyValue.Value = aAnyValue
END IF

RETURN l_objPropertyValue this seems to be a long but pb tellme it's
imcompatible

thanks for your help
mariano

Stephan Beck

unread,
Apr 23, 2004, 3:45:27 AM4/23/04
to
Mariano schrieb:

Regarding my last Posting I have created a NonVisualObject that holds
the important Instance-Variables ... The i_objCoreReflection (PB-Type =
"OLEObject") is one of them.
I use the constructor-event of my NVO to create all relevant
objects...therefore I declared the following instance-variables for my NVO:
//Declaration of Instance-Variables
OLEObject i_objServiceManager
OLEObject i_objDesktop
OLEObject i_objCoreReflection
...

//My constructor-event creates the Objects ...
// first step is the connection to OpenOffice-ServiceManager
i_objServiceManager = CREATE OLEObject
//Success? - ConnectToNewObject() returns 0 (see PB-Help)
IF i_objServiceManager.ConnectToNewObject
("com.sun.star.ServiceManager") = 0 Then

//see
http://api.openoffice.org/docs/common/ref/com/sun/star/frame/Desktop.html
i_objDesktop =
i_objServiceManager.createInstance("com.sun.star.frame.Desktop")
//see
http://api.openoffice.org/docs/common/ref/com/sun/star/reflection/CoreReflection.html
i_objCoreReflection =
i_objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")


//...and all other things you need
END IF

But don't forget to call i_objServiceManager.DisconnectObject () in the
destrutor-event of the NVO!


My function f_oo_makepropertyvalue(string sName, any aAnyValue) returns
also an OLEObject. The PropertyValue is often used in OpenOffice-Methods
(see
http://api.openoffice.org/docs/common/ref/com/sun/star/beans/PropertyValue.html)
... That's why I created the CoreReflection-Object as an
Instance-Variable of my NVO.
One method that uses a Sequence/an Array of PropertyValues is for
example the method "loadComponentFromURL"
(http://api.openoffice.org/docs/common/ref/com/sun/star/frame/XComponentLoader.html#loadComponentFromURL)

an example ... the creation of a new sWriter-Document in a new Frame

OLEObject l_objDocument
OLEObject l_objPropertyValue //one
OLEObject l_objPropertyValues[] //use this Variable as argument for
loadComponentFromURL/collection of "l_objPropertyValue"

l_objPropertyValues[1] = f_oo_makepropertyvalue("ReadOnly", true)

l_objDocument = i_objDesktop.loadComponentFromURL(
"private:factory/swriter", "_blank", 0, l_objPropertyValues)


Hope this helps.
Stephan B.

Mariano

unread,
Apr 26, 2004, 12:05:40 PM4/26/04
to
hi stephan,
thanks for your sanswer. is it posible to you to send me that objects by
email to try?
if so thanks vaery much
my email is mrk...@yahoo.com.ar
thanks for all your help
mariano


0 new messages