| View previous topic :: View next topic |
| Author |
Message |
mo_dachary General User

Joined: 30 Nov 2006 Posts: 8
|
Posted: Sat Dec 09, 2006 5:16 am Post subject: Problem with Numbering Paragraphs in Delphi |
|
|
Hi all,
I'm trying to port a Basic code relative to change and apply NumberingType in paragraphs to Delphi, but I get the message 'com.sun.star.uno.RuntimeException' in the line where is the code: Numeracao.replaceByIndex(i, Prop);
Bellow follows the Basic and Delphi codes.
BASIC CODE
----------------
oNumeracao = oDoc.createInstance("com.sun.star.text.NumberingRules")
For i = 0 To 2
vProp = oNumeracao.getByIndex(i)
For j = 0 To UBound(vProp())
If vProp(j).Name = "NumberingType" Then
vProp(j).Value = com.sun.star.style.NumberingType.CHARS_LOWER_LETTER
oNumeracao.replaceByIndex(i, vProp())
End If
Next j
Next i
Cursor.setPropertyValue("NumberingRules", oNumeracao)
DELPHI CODE
-----------------
Numeracao := Document.createInstance('com.sun.star.text.NumberingRules');
for i := 0 to 2 do
begin
Prop := Numeracao.getByIndex(i);
for j := 0 to VarArrayHighBound(Prop, 1) do
begin
if Prop[j].Name = 'NumberingType' then
begin
Prop[j].Value := 1; //CHARS_LOWER_LETTER
Numeracao.replaceByIndex(i, Prop);
end;
end;
end;
Cursor.setPropertyValue('NumberingRules', Numeracao);
Please, can anyone help with this problem? It seens that it can't execute the replaceByIndex, and I don't know why. |
|
| Back to top |
|
 |
mo_dachary General User

Joined: 30 Nov 2006 Posts: 8
|
Posted: Sat Dec 09, 2006 5:20 am Post subject: |
|
|
Sorry,
I didn't seen the "Code" mark in the editing message.... so my code appears whithout indent.... But now I will do this the next time. |
|
| Back to top |
|
 |
rvc44 Power User


Joined: 15 May 2007 Posts: 62 Location: Tambov, Russia
|
Posted: Tue Jul 24, 2007 3:00 am Post subject: |
|
|
Problem with using replaceByIndex is in Visual FoxPro (VFP) too.
replaceByIndex don't work by using automatization in ANY language? |
|
| Back to top |
|
 |
Danad OOo Advocate

Joined: 22 Feb 2004 Posts: 293 Location: Brasil
|
|
| Back to top |
|
 |
B Marcelly Super User

Joined: 12 May 2004 Posts: 1414 Location: France
|
Posted: Wed Jul 25, 2007 10:11 am Post subject: |
|
|
Exactly !
This is the same problem : you have to pass an array of Uno objects, and the argument of replaceByIndex is defined as : any
So you have to tell the bridge what exactly you are passing.
This is a limitation of the COM bridge, whatever the language you use.
Solution | Code: | var unoWrap: Variant;
// here OpenOffice issupposed to be the Service Manager
if Prop[j].Name = 'NumberingType' then begin
Prop[j].Value := 1; //CHARS_LOWER_LETTER
unoWrap:= OpenOffice.Bridge_GetValueObject;
unoWrap.set('[]com.sun.star.beans.PropertyValue', Prop);
Numeracao.replaceByIndex(i, unoWrap);
end; |
By the way, a new version of Delphi_OOo will be published soon at OOoMacros
______
Bernard |
|
| Back to top |
|
 |
|