Fernand Vanrie wrote:

Thanks for your reply!

Atte André Jensen wrote:
If someone could give a clue to what I',m doing wrong or help me a bit further, I'd greatly appreciate it.
No idee,

I think my problems might relate to the advice you gave me last week regarding "repeating part of document". I decided for a simple string insert instead of using dispatcher, since I thought I might get that working first (formatting of copied sections were lost, but I could live with that).

Now my problem is that each repeated part might contain one of these ###IMG_SOMETHING###-markers. So after first repeating the necessary parts (while modifying it slightly) I'm now trying to go over the document again an replacing the markers with images. And http://www.oooforum.org/forum/viewtopic.phtml?t=31682 leads me to believe that I cannot just copy the way I did, and then afterwards expect the document to be ok. I also tried saving it after the unfolding of repeats, and rereading if before replacing images, but that didn't seem to change anything.

So my office document can contain something like this:

###GROUP_LOOP_BEGIN###
Name of group: ###GROUP_NAME###
###IMG_GROUP?###
###GROUP_LOOP_END###

Provided I have two groups named GrA and GrB, this should end up as to:

Name of group: GrA
< inserted image IMG_GROUPGrA.png >
Name of group: GrB
< inserted image IMG_GROUPGrB.png >

Here's how I repeat the parts (ugly prototype code):

groupLoopBegin.setSearchString('###GROUP_LOOP_BEGIN###')
groupLoopEnd.setSearchString('###GROUP_LOOP_END###')
begin = doc.findFirst(groupLoopBegin)
groupNb = re.compile('(###IMG.*)GROUP[?](.*###)')
while begin:
    end = doc.findNext(begin.End,groupLoopEnd)
    if end:
        rangeCursor.gotoRange(begin,False)
        rangeCursor.gotoRange(end,True)

        loop = rangeCursor.String
        loop = loop.replace('###GROUP_LOOP_BEGIN###','')
        loop = loop.replace('###GROUP_LOOP_END###','')
        for j in range(len(groupNames)):
            i = len(groupNames)-j-1
            thisLoop = groupNb.sub(r"\g<1>"+'GROUP'+str(i+1)+"\g<2>",loop)
            thisLoop = thisLoop.replace('###GROUP_NAME###',groupNames[i])
            if j == 0:
                text.insertString(rangeCursor, thisLoop, True)
            else:
                text.insertString(rangeCursor, thisLoop, False)

    begin = doc.findNext(end.End,groupLoopBegin)


After running this my example document part looks like this (works):

Name of group: GrA
###IMG_GROUPGrA###
Name of group: GrB
###IMG_GROUPGrB###

So this is when replacing these ###IMG...-markes that the image is only inserted one time, and actually even at a wrong place, namely before the first "Name of group...".

I'm wondering:

1) Could this text.insertString be the reason my images are not inserted correctly?

2) I can't figure out how to do the copyint with dispatcher. Which would be the steps required for a) copying a cursor range to a dispatcher, modifying this content and inserting it a number of times instead of the cursor?

3) Since the save to odt + reload didn't work is there any other trick I could try to getting the document in a state where a regular image insert could work?

Obviously I'm confused about quite a few things working with this, hope my explanations make sense to some extend :-)

but why not using Document.GraphicObjects.getElementNames() and working directly with the images

Because the images are not in the document, but I have some text markers that should be replaced on images from disc. Or am I misunderstanding you?


--
peace, love & harmony
Atte

http://atte.dk       | http://myspace.com/attejensen
http://anagrammer.dk | http://modlys.dk

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to