oleCopy(ole)

Hi,

I want to import an rtf with OLE images into a string then parse the data. This works OK, except for the OLE images. With the code
snippet below, the OLE images are found and their dimensions etc are OK, but after using oleCopy() the clipboard is always empty.
Wanted to thereafter use olePaste but since the clipboard is empty it doesn't do a lot. Does anybody have any ideas as to what I'm
doing wrong or am I misunderstanding something ?
 

RichText rtf
    for rtf in szRTF do{
        if (rtf.isOle) {
 
            int width, height
            clearClipboard()
            EmbeddedOleObject ole = rtf.getEmbeddedOle
            if( oleCopy(ole) ){
                print "Copy OK\n"
            }
            if( clipboardIsEmpty() ){
                print " Clipboard is empty\n"
            } 
            olePaste( oNew )
            
            getOleWidthHeight(ole, width, height) 
            print("width = " width ", height = " height "\n")
            //break
        }
    }

 


Thanks, Paul

PS we don't do a direct rtf import because we want to control the formatting

 


SystemAdmin - Tue Feb 09 07:36:47 EST 2010

Re: oleCopy(ole)
mgomes - Tue Feb 09 07:48:53 EST 2010

Try to loop first on paragraphs and then loop inside paragraphs, thats the way i do it.

RichTextParagraph rp
RichText rtf
for rp in strRichParaGraphText do
{
for rtf in rp do{
if (rtf.isOle) {

int width, height
clearClipboard()
EmbeddedOleObject ole = rtf.getEmbeddedOle
if( oleCopy(ole) ){
print "Copy OK\n"
}
if( clipboardIsEmpty() ){
print " Clipboard is empty\n"
}
olePaste( oNew )

getOleWidthHeight(ole, width, height)
print("width = " width ", height = " height "\n")
//break
}
}

Re: oleCopy(ole)
SystemAdmin - Wed Feb 10 01:53:58 EST 2010

mgomes - Tue Feb 09 07:48:53 EST 2010
Try to loop first on paragraphs and then loop inside paragraphs, thats the way i do it.

RichTextParagraph rp
RichText rtf
for rp in strRichParaGraphText do
{
for rtf in rp do{
if (rtf.isOle) {

int width, height
clearClipboard()
EmbeddedOleObject ole = rtf.getEmbeddedOle
if( oleCopy(ole) ){
print "Copy OK\n"
}
if( clipboardIsEmpty() ){
print " Clipboard is empty\n"
}
olePaste( oNew )

getOleWidthHeight(ole, width, height)
print("width = " width ", height = " height "\n")
//break
}
}

I had also used the loops as you suggested but only posted a smaller code snippet. Here's the complete small test code that still always maintains that the clipboard is empty and doesn't paste the OLE object

void checkOLECopy(Object o, string szRTF) {
RichTextParagraph rp
RichText rtf
    for rp in szRTF do {
        for rtf in rp do{
            if (rtf.isOle) {
                int width, height
                clearClipboard()
                EmbeddedOleObject ole = rtf.getEmbeddedOle
                if( oleCopy(ole) ){ print "Copy OK\n" }
                if( clipboardIsEmpty() ){ print " Clipboard is empty\n" } 
                olePaste( o )
                getOleWidthHeight(ole, width, height) 
                print("width = " width ", height = " height "\n")
                return
            }
        }
    }
} 
 
string szFileName = "D:\\DOORS_OLE_Import\\Import_Small.rtf"
string szRtfData = readFile( szFileName ) 
 
Object oNew = create( current Module  )
checkOLECopy( oNew, szRtfData )

Re: oleCopy(ole)
mgomes - Wed Feb 10 05:29:21 EST 2010

SystemAdmin - Wed Feb 10 01:53:58 EST 2010

I had also used the loops as you suggested but only posted a smaller code snippet. Here's the complete small test code that still always maintains that the clipboard is empty and doesn't paste the OLE object

void checkOLECopy(Object o, string szRTF) {
RichTextParagraph rp
RichText rtf
    for rp in szRTF do {
        for rtf in rp do{
            if (rtf.isOle) {
                int width, height
                clearClipboard()
                EmbeddedOleObject ole = rtf.getEmbeddedOle
                if( oleCopy(ole) ){ print "Copy OK\n" }
                if( clipboardIsEmpty() ){ print " Clipboard is empty\n" } 
                olePaste( o )
                getOleWidthHeight(ole, width, height) 
                print("width = " width ", height = " height "\n")
                return
            }
        }
    }
} 
 
string szFileName = "D:\\DOORS_OLE_Import\\Import_Small.rtf"
string szRtfData = readFile( szFileName ) 
 
Object oNew = create( current Module  )
checkOLECopy( oNew, szRtfData )

Below is the code similar to yours that i run on an DOORS object with ole and it works. The message saying that the clipboard is empty remains, but the new onject with the ole is created.

Try it over an DOORS object with an ole.

void checkOLECopy(Object o, string szRTF) {
RichTextParagraph rp
RichText rtf
for rp in szRTF do {
for rtf in rp do{
if (rtf.isOle) {
int width, height
clearClipboard()
EmbeddedOleObject ole = rtf.getEmbeddedOle
if( oleCopy(ole) ){ print "Copy OK\n" }
if( clipboardIsEmpty() ){ print " Clipboard is empty\n" }
olePaste( o )
getOleWidthHeight(ole, width, height)
print("width = " width ", height = " height "\n")
return
}
}
}
}

Object o = current
string szRtfData = richTextWithOle(o."Object Text")

Object oNew = create( current Module )
checkOLECopy( oNew, szRtfData )

Perhaps the problem is on the file that you are reading!?

Re: oleCopy(ole)
SystemAdmin - Thu Feb 11 07:27:23 EST 2010

mgomes - Wed Feb 10 05:29:21 EST 2010
Below is the code similar to yours that i run on an DOORS object with ole and it works. The message saying that the clipboard is empty remains, but the new onject with the ole is created.

Try it over an DOORS object with an ole.

void checkOLECopy(Object o, string szRTF) {
RichTextParagraph rp
RichText rtf
for rp in szRTF do {
for rtf in rp do{
if (rtf.isOle) {
int width, height
clearClipboard()
EmbeddedOleObject ole = rtf.getEmbeddedOle
if( oleCopy(ole) ){ print "Copy OK\n" }
if( clipboardIsEmpty() ){ print " Clipboard is empty\n" }
olePaste( o )
getOleWidthHeight(ole, width, height)
print("width = " width ", height = " height "\n")
return
}
}
}
}

Object o = current
string szRtfData = richTextWithOle(o."Object Text")

Object oNew = create( current Module )
checkOLECopy( oNew, szRtfData )

Perhaps the problem is on the file that you are reading!?

I still can't get the olePaste() to work. The oleCopy() puts the ole image in the clipboard viewer but the olePaste() doesn't take this image from the clipboard. If I manually "ctrl C" an image into the clipboard then the olePaste() works OK. Just can't get the oleCopy() and olePaste() to work together.
We are using DOORS 9.1 - which version are you using ?

Re: oleCopy(ole)
mgomes - Thu Feb 11 09:08:57 EST 2010

SystemAdmin - Thu Feb 11 07:27:23 EST 2010
I still can't get the olePaste() to work. The oleCopy() puts the ole image in the clipboard viewer but the olePaste() doesn't take this image from the clipboard. If I manually "ctrl C" an image into the clipboard then the olePaste() works OK. Just can't get the oleCopy() and olePaste() to work together.
We are using DOORS 9.1 - which version are you using ?

I'm using DOORS 9.2.

Try to check if there is any patch that correct that error on DOORS 9.1!?

Re: oleCopy(ole)
SystemAdmin - Fri Feb 12 00:43:26 EST 2010

mgomes - Thu Feb 11 09:08:57 EST 2010
I'm using DOORS 9.2.

Try to check if there is any patch that correct that error on DOORS 9.1!?

OK, thanks for your help

Paul