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
Good luck,
Stephan B.
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.
Stephan B.
-->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
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.