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 when inserting text at bookmarkposition

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


Joined: 08 May 2007
Posts: 6
Location: Vienna, Austria

PostPosted: Mon Aug 20, 2007 5:15 am    Post subject: Problem when inserting text at bookmarkposition Reply with quote

Greetz to all!

I have the problem that, now (before some time it worked) my program does everything correct, but does not insert the text at the right position.
It's inserted in the reversed order at the same cursor position, actually on the line of the first bookmark, but not in the right column.

Here's the snippet of the code:

Code:

    Reference <XTextDocument> xTextDocument (xComponent, UNO_QUERY);
    Reference <XBookmarksSupplier> xBookmarksSupplier (xTextDocument, UNO_QUERY);

    //now we get indexaccess to the existing bookmarks (we can run through all bookmarks)
    Reference <XIndexAccess> xIndexAccess (xBookmarksSupplier->getBookmarks(), UNO_QUERY);

    //get number of bookmarks
    max = xIndexAccess->getCount();

    fprintf(stderr, "Number of Bookmarks: %d\n", max);

    pszPatXml = NULL;
    pszArzXml = NULL;

    //run through all bookmarks
    for(i = 0; i < max; i++)
    {
        try
        {
            fprintf(stderr, "Run Number: %d\n", i+1);

            pszHelp = NULL;

            //get bookmark at index i
            Any abookmark = xIndexAccess->getByIndex(i);

            Reference <XTextContent> xTextContent (abookmark, UNO_QUERY);
            Reference <XTextRange> xTextRange = xTextContent->getAnchor(); //->getStart()
            Reference <XText> xText = xTextDocument->getText();

            //get the name of the bookmark
            Reference <XNamed> xNamed (abookmark, UNO_QUERY);
            OUString sBookmarkname = xNamed->getName();

            //find given values in string
            if(formprinter->getValues() && (pszHelp = findValue(sBookmarkname, formprinter->getValues(),
                            formprinter->getValuesLen())) && pszHelp)
            {
                fprintf(stderr, "pszHelp is: %s----\n", pszHelp);
                xText->insertString(xTextRange, OUString::createFromAscii(pszHelp), true);
            }
            //if first character is '{' => predefined tag
            else if(sBookmarkname.compareToAscii("{", 1) == 0)
            {
                pszHelp = NULL;
                pszHelp = processTag(sBookmarkname, formprinter->getPatkey());

                if(pszHelp && strlen(pszHelp))
                {
                    fprintf(stderr, "pszHelp is: %s--\n", pszHelp);
                    xText->insertString(xTextRange, OUString::createFromAscii(pszHelp), true);
                }
            }
        }
        catch (Exception &e)
        {
            if(iGlobDebug)
                //fprintf(stderr, "%s", e.Message);
                fprintf(stderr, "error1");
            continue;
        }
    }


The program forks, communicates via socket with another process and so on....then it loads a given document, searches bookmarks, fills them with the text, sets margins, sets the printer, copycount...., prints it, stores the document under a certain name and then exits Smile
This is one of the last problems i have!
I would be glad if someone could help me!
Back to top
View user's profile Send private message
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