HI, I have this sentence into DOORS : "click on the button XX and after do this" XX is an OLE (picture). How can I do, using DXL, to detect the OLE and replace XX with a 'string'. For exemple: "click on the button number one and after do this" I am waiting for your suggestion Thanks for help
Jacque2013 - Wed Nov 27 08:13:56 EST 2013 |
Re: replace an OLE by a string. Off the top of my head... It is rather difficult to contruct Rich Text with DXL. Way too many things to keep track of .. except for the few folks who can handle VooDoo. Get the RTP then each RT, then each Text, the text block characteriscits like Bolding; put in a buffer, find the OLE, replace the text. Yuuuuuuck. I think there may be a solution:
That does not seem realistic to me either; but there you go. I think you are stuck with a DXL that will open the module and find the "next" Object that contains an "OLE", and stop. You deal with it manually, then push the dialog button to find the "Next" one. Or you can filter for objects containing any OLE and deal with them all manually (if at all). -Louie |
Re: replace an OLE by a string. llandale - Thu Dec 05 13:07:59 EST 2013 Off the top of my head... It is rather difficult to contruct Rich Text with DXL. Way too many things to keep track of .. except for the few folks who can handle VooDoo. Get the RTP then each RT, then each Text, the text block characteriscits like Bolding; put in a buffer, find the OLE, replace the text. Yuuuuuuck. I think there may be a solution:
That does not seem realistic to me either; but there you go. I think you are stuck with a DXL that will open the module and find the "next" Object that contains an "OLE", and stop. You deal with it manually, then push the dialog button to find the "Next" one. Or you can filter for objects containing any OLE and deal with them all manually (if at all). -Louie
Sorry Louis , I'm not well expressed.
FIRST CASE:
My code works well When the "Object Text" contains only an OLE => In this case I can detect the OLE, replace it by a string (see filemane into my code) and I can export it into a word paragraph (void WE_WriteParagraph(string ).
SECOND CASE: But, My code doesn't work well When the "Object Text" doesn't contain only an OLE . I give you an example:
The "Object Text" contains this sentence: " click on the button XX and after do this", with XX is an OLE.
I wanna recuperate the content of the " Object Text"", replace XX by a string (for example: number one).
Generate the sentence: "click on the button number one and after do this" and export it into a word paragraph.
""""""""""Remark: The Sentence will not be changed into DOORS."""""""""""""""" YOUR HELP IS VERY IMPORTANT FOR ME, THANKS YOU.
THIS IS MY CODE: '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' void CheckisOLE (Object obj, string attribut)
{
EmbeddedOleObject ole
RichText rtf
string s = richTextWithOle obj.attribut
for rtf in s do
{
if (rtf.isOle)
{
ole = rtf.getEmbeddedOle
string filename = "C:\\File_Report\\EXPORT_object_number_" Index_OLE ".png"
string filename1 = "EXPORT_object_number_" Index_OLE ".png"
Index_OLE = Index_OLE +1
//print "Exporting " filename "\n"
exportPicture(ole,filename , formatPNG)
WE_WriteParagraph(filename1)
}
}
}
void WE_WriteParagraph(string parText)
{
if (parText!="")
{
//replace critical chars
parText=WEI_FixXMLChars(parText)
AddBuffer("<w:p wsp:rsidR=\"00851010\" wsp:rsidRDefault=\"00851010\" wsp:rsidP=\"00851010\">")
AddBuffer("<w:pPr>")
AddBuffer("<w:rPr>")
AddBuffer("<w:sz w:val=\"20\"/>")
AddBuffer("</w:rPr>")
AddBuffer("</w:pPr>")
AddBuffer("<w:r wsp:rsidRPr=\"00C54005\">")
AddBuffer("<w:rPr>")
AddBuffer("<w:sz w:val=\"20\"/>")
AddBuffer("</w:rPr>")
AddBuffer("<w:t>" parText "</w:t>")
AddBuffer(" </w:r>")
AddBuffer("</w:p>")
}
else
{
AddBuffer("<w:p/>")
}
}
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
Re: replace an OLE by a string. Jacque2013 - Fri Dec 06 08:56:56 EST 2013
Sorry Louis , I'm not well expressed.
FIRST CASE:
My code works well When the "Object Text" contains only an OLE => In this case I can detect the OLE, replace it by a string (see filemane into my code) and I can export it into a word paragraph (void WE_WriteParagraph(string ).
SECOND CASE: But, My code doesn't work well When the "Object Text" doesn't contain only an OLE . I give you an example:
The "Object Text" contains this sentence: " click on the button XX and after do this", with XX is an OLE.
I wanna recuperate the content of the " Object Text"", replace XX by a string (for example: number one).
Generate the sentence: "click on the button number one and after do this" and export it into a word paragraph.
""""""""""Remark: The Sentence will not be changed into DOORS."""""""""""""""" YOUR HELP IS VERY IMPORTANT FOR ME, THANKS YOU.
THIS IS MY CODE: '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' void CheckisOLE (Object obj, string attribut)
{
EmbeddedOleObject ole
RichText rtf
string s = richTextWithOle obj.attribut
for rtf in s do
{
if (rtf.isOle)
{
ole = rtf.getEmbeddedOle
string filename = "C:\\File_Report\\EXPORT_object_number_" Index_OLE ".png"
string filename1 = "EXPORT_object_number_" Index_OLE ".png"
Index_OLE = Index_OLE +1
//print "Exporting " filename "\n"
exportPicture(ole,filename , formatPNG)
WE_WriteParagraph(filename1)
}
}
}
void WE_WriteParagraph(string parText)
{
if (parText!="")
{
//replace critical chars
parText=WEI_FixXMLChars(parText)
AddBuffer("<w:p wsp:rsidR=\"00851010\" wsp:rsidRDefault=\"00851010\" wsp:rsidP=\"00851010\">")
AddBuffer("<w:pPr>")
AddBuffer("<w:rPr>")
AddBuffer("<w:sz w:val=\"20\"/>")
AddBuffer("</w:rPr>")
AddBuffer("</w:pPr>")
AddBuffer("<w:r wsp:rsidRPr=\"00C54005\">")
AddBuffer("<w:rPr>")
AddBuffer("<w:sz w:val=\"20\"/>")
AddBuffer("</w:rPr>")
AddBuffer("<w:t>" parText "</w:t>")
AddBuffer(" </w:r>")
AddBuffer("</w:p>")
}
else
{
AddBuffer("<w:p/>")
}
}
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' If I understood you correctly - you want to "cut out" the OLE object from the object text, replace it by some text? I figured I had an example code for this posted here: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014460097&ps=25 You can use a regular expression to detect OLE objects in richtext and of course cut / replace them. Maybe this helps, regards, Mathias |
Re: replace an OLE by a string. Mathias Mamsch - Tue Dec 10 07:51:28 EST 2013 If I understood you correctly - you want to "cut out" the OLE object from the object text, replace it by some text? I figured I had an example code for this posted here: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014460097&ps=25 You can use a regular expression to detect OLE objects in richtext and of course cut / replace them. Maybe this helps, regards, Mathias Thanks very much Mathis, In fact, I wanna recuperate the content of the " Object Text"", and export it with replacing the OLE by a string. I don't serach for replacing OLE into DOORS module... Just in export. |
Re: replace an OLE by a string. Jacque2013 - Tue Dec 10 08:58:16 EST 2013 Thanks very much Mathis, In fact, I wanna recuperate the content of the " Object Text"", and export it with replacing the OLE by a string. I don't serach for replacing OLE into DOORS module... Just in export. Yes, I was not talking about the module but about the string. By "cutting" I meant "replacing" in the string. So the code should be fine for you. Did you take a look? You will need to reformat though, since the old posts in the forum are still to be repaired by the developerworks team (they were 'reformatted' during the migration of the forum). Regards, Mathias |
Re: replace an OLE by a string. Mathias Mamsch - Tue Dec 10 10:37:30 EST 2013 Yes, I was not talking about the module but about the string. By "cutting" I meant "replacing" in the string. So the code should be fine for you. Did you take a look? You will need to reformat though, since the old posts in the forum are still to be repaired by the developerworks team (they were 'reformatted' during the migration of the forum). Regards, Mathias I take a look. But is not so easy :) I read what do you have write on "Apr 25, 2010 in response to aakhws" but i can't find a solution. It permets just to detect OLE type . Thanks you for help Mathias. |
Re: replace an OLE by a string. Jacque2013 - Tue Dec 10 11:17:19 EST 2013 I take a look. But is not so easy :) I read what do you have write on "Apr 25, 2010 in response to aakhws" but i can't find a solution. It permets just to detect OLE type . Thanks you for help Mathias. Sorry, I just realized that the regular expression posted were not complete. You can find the full regular expressions to parse OLE objects here: In the oleObject.inc attachment.
Using reOle and rePic you should now be able to parse the complete OLE Object and get the position in the richText and then be able to replace the OLE object by another string. If you encounter problems, just post again. By the way: I found this post, which also deals with getting the OLE object position inside the rich text: Regards, Mathias |
Re: replace an OLE by a string. Mathias Mamsch - Tue Dec 10 17:03:23 EST 2013 Sorry, I just realized that the regular expression posted were not complete. You can find the full regular expressions to parse OLE objects here: In the oleObject.inc attachment.
Using reOle and rePic you should now be able to parse the complete OLE Object and get the position in the richText and then be able to replace the OLE object by another string. If you encounter problems, just post again. By the way: I found this post, which also deals with getting the OLE object position inside the rich text: Regards, Mathias Thanks MATHIAS for your help, I try this, but it doesn't work correctly..
THIS IS MY CODE:
string CheckisOLE (Object o, string attribut)
{
Buffer b = create()
b = richTextWithOle o.attribut
string result = o.attribut ""
string filename1 = " EXPORT_object_number_" Index_OLE ".png"
string reData = "({\\\\\\*\\\\objdata([^}]+)})"
string reResult = "({\\\\result({[^}]+}))"
string reHeader = "{\\\\object\\\\objemb{\\\\\\*\\\\objclass ([^}]+)}\\\\objw([^\\\\{}]+)\\\\objh([^\\\\{}]+)"
string picData = "([^}]+)"
string picHeader = "{\\\\pict\\\\([^\\\\]+)(\\\\picw([^\\\\{}]+))?(\\\\pich([^\\\\]+))?\\\\picwgoal([-0-9]+)\\\\pichgoal([-0-9]+)"
Regexp reOle = regexp reHeader reData reResult "}"
Regexp rePic = regexp picHeader picData "}"
Regexp reOlePicFind = regexp "{\\\\(object|pict)"
Regexp expr
Index_OLE = Index_OLE +1
// check for picture OR ole Objects ...
if (reOlePicFind b)
{
// what did we find? '\pict' or '\object' ?
string type = b[match 1]
// use the right regular expression!
if (type == "pict") expr = rePic else expr = reOle
// this should always be true! Otherwise something is wrong with our regular expression.
if (expr b)
{
// get start and ending of the match
int oStart = start 0
//replace OLE by string.
string result1 = ""
int i
char j
if ((oStart)< 0)
{
result1 = filename1 result
}
else if ((oStart)>=length(result))
{
result1 = result filename1
}
else
{
for(i=0;i<length(result);i++)
{
if (i < (oStart))
{
j = result[i]
result1 = result1 j ""
}
if (i == (oStart))
{
j = result[i]
result1 = result1 j filename1 ""
}
if (i > (oStart))
{
j = result[i]
result1 = result1 j ""
}
}
}
//END ADD
result = result1
print "attribut:= " result "\n"
print "oStart:= " oStart "\n"
}
}
return result
}
|
Re: replace an OLE by a string. Jacque2013 - Thu Dec 12 05:03:12 EST 2013 Thanks MATHIAS for your help, I try this, but it doesn't work correctly..
THIS IS MY CODE:
string CheckisOLE (Object o, string attribut)
{
Buffer b = create()
b = richTextWithOle o.attribut
string result = o.attribut ""
string filename1 = " EXPORT_object_number_" Index_OLE ".png"
string reData = "({\\\\\\*\\\\objdata([^}]+)})"
string reResult = "({\\\\result({[^}]+}))"
string reHeader = "{\\\\object\\\\objemb{\\\\\\*\\\\objclass ([^}]+)}\\\\objw([^\\\\{}]+)\\\\objh([^\\\\{}]+)"
string picData = "([^}]+)"
string picHeader = "{\\\\pict\\\\([^\\\\]+)(\\\\picw([^\\\\{}]+))?(\\\\pich([^\\\\]+))?\\\\picwgoal([-0-9]+)\\\\pichgoal([-0-9]+)"
Regexp reOle = regexp reHeader reData reResult "}"
Regexp rePic = regexp picHeader picData "}"
Regexp reOlePicFind = regexp "{\\\\(object|pict)"
Regexp expr
Index_OLE = Index_OLE +1
// check for picture OR ole Objects ...
if (reOlePicFind b)
{
// what did we find? '\pict' or '\object' ?
string type = b[match 1]
// use the right regular expression!
if (type == "pict") expr = rePic else expr = reOle
// this should always be true! Otherwise something is wrong with our regular expression.
if (expr b)
{
// get start and ending of the match
int oStart = start 0
//replace OLE by string.
string result1 = ""
int i
char j
if ((oStart)< 0)
{
result1 = filename1 result
}
else if ((oStart)>=length(result))
{
result1 = result filename1
}
else
{
for(i=0;i<length(result);i++)
{
if (i < (oStart))
{
j = result[i]
result1 = result1 j ""
}
if (i == (oStart))
{
j = result[i]
result1 = result1 j filename1 ""
}
if (i > (oStart))
{
j = result[i]
result1 = result1 j ""
}
}
}
//END ADD
result = result1
print "attribut:= " result "\n"
print "oStart:= " oStart "\n"
}
}
return result
}
I think you are making things to complicated. We just need to find the start and end of the OLE object. So something like the below should get you on the right track. Hope this helps, regards, Mathias
Regexp reObj = regexp "({\\\\object)|({\\\\pict)"
Regexp reBrace = regexp "[{}]"
Buffer b = create();
b = richTextWithOle (current Object)."Object Text"
// print b ""; halt;
int pos = 0;
int iLen = length b
int oleStart = 0
Buffer result = create()
// Look for the start of an OLE object or picture
while (search(reObj, b, pos)) {
oleStart = pos + start 0
// add to the result the part before the OLE object
if (oleStart > pos) combine(result, b, pos, oleStart-1);
// look for the ending brace of the OLE object
int braceLevel = 1; // the start of the OLE had one opening brace
int bracePos = oleStart+1;
while (braceLevel > 0 && search(reBrace, b,bracePos)) {
char ch = b[bracePos + start 0];
braceLevel += (ch == '{') ? 1 : (-1);
bracePos += 1 + end 0
}
if (braceLevel != 0) error "Invalid RTF!";
pos = bracePos;
print "Found OLE object from " oleStart " to " bracePos "! Replacing...\n";
// make sure you use an RTF group ({...}) here!
// you might need to add a space otherwise
result += "{XXX}"
}
combine (result, b, pos); // add the rest...
print result "\n"
|
Re: replace an OLE by a string. Mathias Mamsch - Fri Dec 13 06:58:38 EST 2013 I think you are making things to complicated. We just need to find the start and end of the OLE object. So something like the below should get you on the right track. Hope this helps, regards, Mathias
Regexp reObj = regexp "({\\\\object)|({\\\\pict)"
Regexp reBrace = regexp "[{}]"
Buffer b = create();
b = richTextWithOle (current Object)."Object Text"
// print b ""; halt;
int pos = 0;
int iLen = length b
int oleStart = 0
Buffer result = create()
// Look for the start of an OLE object or picture
while (search(reObj, b, pos)) {
oleStart = pos + start 0
// add to the result the part before the OLE object
if (oleStart > pos) combine(result, b, pos, oleStart-1);
// look for the ending brace of the OLE object
int braceLevel = 1; // the start of the OLE had one opening brace
int bracePos = oleStart+1;
while (braceLevel > 0 && search(reBrace, b,bracePos)) {
char ch = b[bracePos + start 0];
braceLevel += (ch == '{') ? 1 : (-1);
bracePos += 1 + end 0
}
if (braceLevel != 0) error "Invalid RTF!";
pos = bracePos;
print "Found OLE object from " oleStart " to " bracePos "! Replacing...\n";
// make sure you use an RTF group ({...}) here!
// you might need to add a space otherwise
result += "{XXX}"
}
combine (result, b, pos); // add the rest...
print result "\n"
THANK YOU VERY MUCH MATHIAS.
Please last thing, how to convert, using dxl, ""result""" from rich text format to a plani format ?
exemple frich text:
{\rtf1\ansi\ansicpg1252\deff0\deflang3081{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}
exp plain format: a. abc b. def
c. ghi |
Re: replace an OLE by a string. Jacque2013 - Fri Dec 13 07:52:01 EST 2013 THANK YOU VERY MUCH MATHIAS.
Please last thing, how to convert, using dxl, ""result""" from rich text format to a plani format ?
exemple frich text:
{\rtf1\ansi\ansicpg1252\deff0\deflang3081{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}
exp plain format: a. abc b. def
c. ghi You could use the plainText(string) perm, however the native DOORS conversion will not render list items like you expect (since DXL does not support different list symbols). If this is acceptable then you will be fine.
string s =" {\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}}
\\viewkind4\\uc1\\pard{\\pntext\\f0 a.\\tab}{\\*\\pn\\pnlvlbody\\pnf0\\pnindent0\\pnstart1\\pnlcltr{\\pntxta.}}
\\fi-360\\li360\\f0\\fs20 abc\\par
{\\pntext\\f0 b.\\tab}def\\par
{\\pntext\\f0 c.\\tab}ghi\\par
{\\pntext\\f0 d.\\tab}jkl\\par
{\\pntext\\f0 e.\\tab}mno\\par
}"
print plainText s
If not you might try to construct the plaintext yourself by iterating over the richtext paragraph yourself, fixing that:
string s =" {\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}}
\\viewkind4\\uc1\\pard{\\pntext\\f0 a.\\tab}{\\*\\pn\\pnlvlbody\\pnf0\\pnindent0\\pnstart1\\pnlcltr{\\pntxta.}}
\\fi-360\\li360\\f0\\fs20 abc\\par
{\\pntext\\f0 b.\\tab}def\\par
{\\pntext\\f0 c.\\tab}ghi\\par
{\\pntext\\f0 d.\\tab}jkl\\par
{\\pntext\\f0 e.\\tab}mno\\par
}"
// (current Object)."Object Text" = richText s
RichTextParagraph rtp
RichText rt
Buffer result = create();
for rtp in s do {
if (rtp.isBullet) { result += "* "; }
for rt in rtp do result += rt.text
result +="\n"
}
print result "\n"
Maybe this helps, regards, Mathias |
Re: replace an OLE by a string. Mathias Mamsch - Fri Dec 13 08:22:16 EST 2013 You could use the plainText(string) perm, however the native DOORS conversion will not render list items like you expect (since DXL does not support different list symbols). If this is acceptable then you will be fine.
string s =" {\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}}
\\viewkind4\\uc1\\pard{\\pntext\\f0 a.\\tab}{\\*\\pn\\pnlvlbody\\pnf0\\pnindent0\\pnstart1\\pnlcltr{\\pntxta.}}
\\fi-360\\li360\\f0\\fs20 abc\\par
{\\pntext\\f0 b.\\tab}def\\par
{\\pntext\\f0 c.\\tab}ghi\\par
{\\pntext\\f0 d.\\tab}jkl\\par
{\\pntext\\f0 e.\\tab}mno\\par
}"
print plainText s
If not you might try to construct the plaintext yourself by iterating over the richtext paragraph yourself, fixing that:
string s =" {\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}}
\\viewkind4\\uc1\\pard{\\pntext\\f0 a.\\tab}{\\*\\pn\\pnlvlbody\\pnf0\\pnindent0\\pnstart1\\pnlcltr{\\pntxta.}}
\\fi-360\\li360\\f0\\fs20 abc\\par
{\\pntext\\f0 b.\\tab}def\\par
{\\pntext\\f0 c.\\tab}ghi\\par
{\\pntext\\f0 d.\\tab}jkl\\par
{\\pntext\\f0 e.\\tab}mno\\par
}"
// (current Object)."Object Text" = richText s
RichTextParagraph rtp
RichText rt
Buffer result = create();
for rtp in s do {
if (rtp.isBullet) { result += "* "; }
for rt in rtp do result += rt.text
result +="\n"
}
print result "\n"
Maybe this helps, regards, Mathias
Thank you very much Mister MATHIAS.
You deblock me.
|
Re: replace an OLE by a string. Hi , How to copy the embedded OLEObjects and paste it in another object . My OLEObject is static when I am pasting I am getting an error like unable to paste the oleobject why i am getting this error |