fif General User


Joined: 08 May 2007 Posts: 6 Location: Vienna, Austria
|
Posted: Mon Aug 20, 2007 5:15 am Post subject: Problem when inserting text at bookmarkposition |
|
|
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
This is one of the last problems i have!
I would be glad if someone could help me! |
|