Hello,

 

I try to use the LinguServiceManager through OLE.

 

The following Delphi code fails at the marked line with:
 
[automation bridge] unexpected exception in
UnoConversionUtilities<T>::variantToAny !
 

========================================================================
======================

function TSampleCode.Hyphenate(S: string): string;
var
    H: Variant;
    Locale: Variant;
    Props: Variant;
    HW: Variant;
    CoreReflection: Variant;
    LSM: Variant;
begin
    LSM := StarOffice.createInstance(
            'com.sun.star.linguistic2.LinguServiceManager');
    if VarIsArray(LSM) then
        Exit;
    if (VarIsEmpty(LSM) or VarIsNull(LSM)) then
        Exit;
 
    CoreReflection := StarOffice.createInstance(
            'com.sun.star.reflection.CoreReflection');
    CoreReflection.forName('com.sun.star.lang.Locale').createObject(
            Locale);
    Locale.Language := 'de';
    Locale.Country := '';
    Locale.Variant := '';
 
    H := LSM.getHyphenator(); // <=============== here an error
 
    HW := H.hyphenate('Silbentrennung', Locale, 2, Props);
    H := Null;
    Props := Null;
    Locale := Null;
    LSM := Null;
end;

========================================================================
======================

 

 

I tried to program the same in Visual Basic Script but it doesn't work
either:

 
The following Visual Basic Script code does not work either (it shows
"Nothing"):
 

========================================================================
======================

Set StarOffice = WScript.CreateObject("com.sun.star.ServiceManager")
 
Set LSM =
StarOffice.createInstance("com.sun.star.linguistic2.LinguServiceManager"
)
Set CoreReflection =
StarOffice.createInstance("com.sun.star.reflection.CoreReflection")
 
Dim Locale
Set Cl = CoreReflection.forName("com.sun.star.lang.Locale")
Cl.createObject Locale
Locale.Language = "de"
Locale.Country = "DE"
Locale.Variant = ""
 
Dim PV
Set Cl = CoreReflection.forName("com.sun.star.beans.PropertyValue") 
Cl.createObject PV
 
Set H = LSM.getHyphenator()
Dim Props(0)
Set Props(0) = PV
Set xHW = H.hyphenate("Silbentrennung", Locale, 0, Props)
MsgBox TypeName(xHW)

========================================================================
======================

 

Does anybody know what I am doing wrong here?

Thanks in advance

 

--Tim

Reply via email to