OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Problem with Numbering Paragraphs in Delphi

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
mo_dachary
General User
General User


Joined: 30 Nov 2006
Posts: 8

PostPosted: Sat Dec 09, 2006 5:16 am    Post subject: Problem with Numbering Paragraphs in Delphi Reply with quote

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
View user's profile Send private message
mo_dachary
General User
General User


Joined: 30 Nov 2006
Posts: 8

PostPosted: Sat Dec 09, 2006 5:20 am    Post subject: Reply with quote

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
View user's profile Send private message
rvc44
Power User
Power User


Joined: 15 May 2007
Posts: 62
Location: Tambov, Russia

PostPosted: Tue Jul 24, 2007 3:00 am    Post subject: Reply with quote

Problem with using replaceByIndex is in Visual FoxPro (VFP) too.

replaceByIndex don't work by using automatization in ANY language?
Back to top
View user's profile Send private message
Danad
OOo Advocate
OOo Advocate


Joined: 22 Feb 2004
Posts: 293
Location: Brasil

PostPosted: Wed Jul 25, 2007 6:19 am    Post subject: Reply with quote

Hi,

I guess that problem is related with one in this thread:

http://www.oooforum.org/forum/viewtopic.phtml?t=58792&highlight=

Follow the tips from B Marcelly and let us know if it works here.

HTH
Back to top
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1453
Location: France

PostPosted: Wed Jul 25, 2007 10:11 am    Post subject: Reply with quote

Danad wrote:
I guess that problem is related with one in this thread:

http://www.oooforum.org/forum/viewtopic.phtml?t=58792&highlight=

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 Wink
______
Bernard
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group