Page 7 of 39
Posted: Sat Sep 06, 2008 7:50 pm
by SFSxOI
ahhh...so you think maybe the monitor is not detected because the switcher is actually the device the OS is seeing and not the monitor?
That kind of makes sense in a way because the switcher would not be detected in the monitor class. (I don't think it would at least.)
Posted: Sat Sep 06, 2008 7:50 pm
by Num3
Need help:
Can't pass an array to the method
VB CODE
Code: Select all
Dim oSM, ODesk as Object 'root object from OOo API
Dim oDoc as Object 'The document to be opened
Dim OpenPar(2) As Object 'a Visual Basic array, with 3 elements
'Instanciate OOo : the first line is always required from Visual Basic for OOo
Set oSM = CreateObject("com.sun.star.ServiceManager")
Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
'We call the MakePropertyValue function, defined just before, to access the structure
Set OpenPar(0) = MakePropertyValue("ReadOnly", True)
Set OpenPar(1) = MakePropertyValue("Password", "secret")
Set OpenPar(2) = MakePropertyValue("Hidden", False)
'Now we can call the OOo loadComponentFromURL method, giving it as
'fourth argument the result of our precedent MakePropertyValue call
Set oDoc = oDesk.loadComponentFromURL("file:///c|test.sxw", "_blank", 0, OpenPar)
PB code (i want to pass an empty array)
Code: Select all
XIncludeFile "COMate.pbi"
XIncludeFile "VariantHelper_Include.pb"
Define.COMateObject oSM, oDesk, oDoc
Dim Array.SAFEARRAY(0)
document.s = "file:///" + GetCurrentDirectory() + "test.odt"
oSM = COMate_CreateObject("com.sun.star.ServiceManager")
If oSM
oDesk = oSM\GetObjectProperty("createInstance('com.sun.star.frame.Desktop')")
If oDesk
document.s = "file:///" + GetCurrentDirectory() + "test.ott"
document.s=ReplaceString(document,"\","/")
oDoc = oDesk\invoke("loadComponentFromURL('"+document+"','_blank',0,"+Str(@Array())+")")
;oDoc = oDesk\GetObjectProperty("loadComponentFromURL('"+document+"','_blank',0,"+Str(@Array())+")")
Debug oDoc
Debug COMate_GetLastErrorDescription()
EndIf
oDesk\Release()
oSM\Release()
EndIf
Old DispHelp code (works)
Code: Select all
Define ocurseur, mdoc, chaine.s, document.s
Define.l oSM, oDesk, oDoc, oSrch, oCursor, Hit
XIncludeFile "DispHelper_Include.pb"
XIncludeFile "VariantHelper_Include.pb"
Define.safearray *openpar
Define.variant openarray
V_ARRAY_DISP(openarray) = *openpar
dhToggleExceptions(#True)
oSM = dhCreateObject("com.sun.star.ServiceManager")
If oSM
;Creating instance of Desktop
dhGetValue("%o", @oDesk, oSM, ".CreateInstance(%T)", @"com.sun.star.frame.Desktop")
;Opening a new writer Document
document.s = "file:///" + GetCurrentDirectory() + "test.ott"
document.s = ReplaceString(document, "\", "/")
dhGetValue("%o", @oDoc, oDesk, ".loadComponentFromURL(%T,%T,%d,%v)", @document, @"_blank", 0, openarray)
dhReleaseObject(oDoc)
dhReleaseObject(oDesk)
dhReleaseObject(oSM)
EndIf
Posted: Sat Sep 06, 2008 9:41 pm
by srod
I read somewhere that some monitors will not report themselves to WMI - it wasn't put in quite these terms and I don't know where I saw this. The suggestion is though that the problem may just be the monitor itself.

Posted: Sat Sep 06, 2008 9:46 pm
by ts-soft
It's a high quality monitor from CTX with Plug & Pray support.
Not a Discounter Monitor with flickering Screen, is only a very old Monitor
Posted: Sat Sep 06, 2008 9:51 pm
by SFSxOI
monitors with drivers that are fully WDDM compliant should be OK though. Both of my Samsug 245 BW 24 inch give up the info to wmi here.
Posted: Sat Sep 06, 2008 10:18 pm
by srod
@Num3 : I've uploaded a test version of Comate.pbi
here for you to try with the following code :
Code: Select all
XIncludeFile "COMate.pbi"
XIncludeFile "VariantHelper_Include.pb"
Define.COMateObject oSM, oDesk, oDoc
Define.safearray *openpar
Define.variant openarray
V_ARRAY_DISP(openarray) = safearray
oSM = COMate_CreateObject("com.sun.star.ServiceManager")
If oSM
;Creating instance of Desktop
oDesk = oSM\GetObjectProperty("CreateInstance('com.sun.star.frame.Desktop')")
If oDesk
;Opening a new writer Document
document.s = "file:///" + GetCurrentDirectory() + "test.ott"
document.s = ReplaceString(document, "\", "/")
oDoc = oDesk\GetObjectProperty("loadComponentFromURL('" + document + "', '_blank', 0, " + Str(openarray) + " as variant)")
If oDoc
oDoc\Release()
EndIf
oDesk\Release()
EndIf
oSM\Release()
EndIf
I don't have open office with which to perform any tests on the code so it's down to you! It may take us a few attempts to get it working!
**EDIT : if this doesn't work then I am thinking there looks to be a problem with the VariantHelper include with the V_ARRAY_DISP macro. I think that Arg\ppdispVal should read Arg\parray; not that it will make much difference I guess because it is a structureunion anyhow!

Posted: Sat Sep 06, 2008 10:28 pm
by ts-soft
@Num3
All codes, incl. the new by srod doesn't work with OpenOffice 3, so i can't
test it. I think the code works only for OpenOffice 2.x
Posted: Sat Sep 06, 2008 10:33 pm
by srod
@ts-soft, does my code above (with the test version of COMate) work with OO 2? I had overlooked variant type method parameters! :roll:
Posted: Sat Sep 06, 2008 10:40 pm
by ts-soft
srod wrote:@ts-soft, does my code above (with the test version of COMate) work with OO 2? I had overlooked variant type method parameters! :roll:
As i say, i have no OO 2 to test, i have only OO 3 beta 2 installed. In OO 3
comes no object, so i think the name is another.
Posted: Sat Sep 06, 2008 10:41 pm
by srod
Sorry, I misunderstood your last post!

Posted: Sun Sep 07, 2008 12:24 am
by Sparkie
srod wrote:does my code above (with the test version of COMate) work with OO 2?
Sorry srod, it does not work with OO 2.01.
Posted: Sun Sep 07, 2008 9:27 am
by Num3
Found the problem!
I was forgetting to convert the filename to an URL encoded string!
I also spelled the document extension wrong .ott instead of .odt !
Here's a working example, works with OpenOffice 2/3 and also with IBM Symphony (aka Open Office with less bugs

)
Code: Select all
XIncludeFile "COMate.pbi"
XIncludeFile "VariantHelper_Include.pb"
Procedure.s ConvertToUrl(strFile.s)
strFile = ReplaceString(strFile, "\", "/")
strFile = ReplaceString(strFile, ":", "|")
strFile = ReplaceString(strFile, " ", "%20")
strFile = "file:///" + strFile
ProcedureReturn strFile
EndProcedure
Define.COMateObject oSM, oDesk, oDoc
Define.safearray *openpar
Define.variant openarray
V_ARRAY_DISP(openarray) = safearray
oSM = COMate_CreateObject("com.sun.star.ServiceManager")
If oSM
;Creating instance of Desktop
oDesk = oSM\GetObjectProperty("CreateInstance('com.sun.star.frame.Desktop')")
If oDesk
;Opening a exisiting Document
document.s = GetCurrentDirectory() + "test.odt"
oDoc = oDesk\GetObjectProperty("loadComponentFromURL('"+ConvertToUrl(document)+"', '_blank', 0, " + Str(openarray) + " as variant)")
Debug COMate_GetLastErrorDescription()
If oDoc
oDoc\Release()
EndIf
oDesk\Release()
EndIf
oSM\Release()
EndIf
Here's an example to open an empty document:
Code: Select all
XIncludeFile "COMate.pbi"
XIncludeFile "VariantHelper_Include.pb"
Procedure.s ConvertToUrl(strFile.s)
strFile = ReplaceString(strFile, "\", "/")
strFile = ReplaceString(strFile, ":", "|")
strFile = ReplaceString(strFile, " ", "%20")
strFile = "file:///" + strFile
ProcedureReturn strFile
EndProcedure
Define.COMateObject oSM, oDesk, oDoc
Define.safearray *openpar
Define.variant openarray
V_ARRAY_DISP(openarray) = safearray
oSM = COMate_CreateObject("com.sun.star.ServiceManager")
If oSM
;Creating instance of Desktop
oDesk = oSM\GetObjectProperty("CreateInstance('com.sun.star.frame.Desktop')")
If oDesk
;Opening a new writer Document
oDoc = oDesk\GetObjectProperty("loadComponentFromURL('private:factory/swriter', '_blank', 0, " + Str(openarray) + " as variant)")
If oDoc
oDoc\Release()
EndIf
oDesk\Release()
EndIf
oSM\Release()
EndIf
Posted: Sun Sep 07, 2008 9:34 am
by srod
@Num3 : it doesn't work when passing filenames?
Have just discovered that the whole COMate BYREF system is flawed and needs rewriting! DOH! Not that this should affect your Open Office code there.
Posted: Sun Sep 07, 2008 9:38 am
by Num3
srod wrote:@Num3 : it doesn't work when passing filenames?
Have just discovered that the whole COMate BYREF system is flawed and needs rewriting! DOH! Not that this should affect your Open Office code there.
Sorry i had a bug and edited my post...
I got it working, check above!
Posted: Sun Sep 07, 2008 9:42 am
by srod
Excellent!
Now to correct this damn BYREF business!