How to print the differences in Object Text History

Dear all,

I really try to find same thread about it but I could not find it.

I need to create a Layout DXL column showing the differences in Object Text from the last history between the current, as I show in the attached file.

Does any one knows?
lupsanto - Wed Feb 09 05:56:56 EST 2011

Re: How to print the differences in Object Text History
SystemAdmin - Wed Feb 09 06:34:01 EST 2011

Such a script is available in module DXL Library.

Select Tools / DXL Library and then browse to Some example programs which.... / Example to create a layout DXL DXL column that shows changes to object text:

This tool creates a DXL column which uses a rich-text markup scheme
to show changes to Object Text with respect to some original version.

The original version can be selected from the following sources:

  • the current value of Object Text, so that all future changes are marked up in the history column

  • the Object Text as it was in a named baseline of the current Module

  • the value of a named attribute.

The original text is stored in a text attribute called "Old Text", and
can be over-written by a subsequent use of the tool.

The fonts used to mark up the changes in text can be selected. The
default is to show inserted text using underline, and deleted text
using strike-through.

Current limitations:
  • changes to fonts in the object text are ignored.
  • changes to attributes other than Object Text are not shown.
  • deleted and moved objects are not portrayed as changes.

Re: How to print the differences in Object Text History
Peter_Albert - Wed Feb 09 07:05:42 EST 2011

If you really want to display the latest modification of "Object Text" you can use the layout DXL below.

Similar limitations as in the previous post: No formatting changes are displayed, deleted and moved objects are not indicated as modifications.

Regards,

Peter

pragma runLim, 0
// -----------------------------------------------------------------------------
void RichText2Text(Buffer buf)
{ // Replace a rich text buffer by its plain text
  RichTextParagraph rp
  Buffer   tmp = create
  tmp = ""
  for rp in stringOf buf do
  { // Loop through rich text paragraphs
    if (length tmp > 0){tmp += "\n"}
    tmp += rp.text
  } // Loop through rich text paragraphs
  buf = stringOf tmp
  delete tmp
} // Replace a rich text buffer by its plain text
// -----------------------------------------------------------------------------
void displayLastHistory()
{ // Display the last Object Text modification from the history
  History     hist
  HistoryType histType
  string      histAttName
  Buffer      lastChangeBuf     = create
  Buffer      currObjectTextBuf = create
  Buffer      diffResultBuf     = create
  bool        foundObjTextHistory
  
  foundObjTextHistory = false
  for hist in obj do
  { // Loop through object history
    histType    = hist.type
    histAttName = ""
    if (histType == modifyObject)
    { // Object modification
      histAttName = hist.attrName
      if (histAttName == "Object Text")
      { // Modification of "Object Text"
        lastChangeBuf       = hist.oldValue
        currObjectTextBuf   = hist.newValue
        foundObjTextHistory = true
      } // Modification of "Object Text"
    } // Object modification
  } // Loop through object history
  if (foundObjTextHistory)
  { // History contains at least one modification of "Object Text"
    RichText2Text(lastChangeBuf)
    RichText2Text(currObjectTextBuf)
    if (lastChangeBuf != currObjectTextBuf)
    { // Do not show modifications of text formatting only
      diff(diffResultBuf, lastChangeBuf, currObjectTextBuf)
    } // Do not show modifications of text formatting only
    displayRich tempStringOf diffResultBuf
  } // History contains at least one modification of "Object Text"
  delete diffResultBuf
  delete lastChangeBuf
  delete currObjectTextBuf
} // Display the last Object Text modification from the history
// -----------------------------------------------------------------------------
displayLastHistory()

Re: How to print the differences in Object Text History
lupsanto - Wed Feb 09 07:10:02 EST 2011

SystemAdmin - Wed Feb 09 06:34:01 EST 2011
Such a script is available in module DXL Library.

Select Tools / DXL Library and then browse to Some example programs which.... / Example to create a layout DXL DXL column that shows changes to object text:

This tool creates a DXL column which uses a rich-text markup scheme
to show changes to Object Text with respect to some original version.

The original version can be selected from the following sources:

  • the current value of Object Text, so that all future changes are marked up in the history column

  • the Object Text as it was in a named baseline of the current Module

  • the value of a named attribute.

The original text is stored in a text attribute called "Old Text", and
can be over-written by a subsequent use of the tool.

The fonts used to mark up the changes in text can be selected. The
default is to show inserted text using underline, and deleted text
using strike-through.

Current limitations:
  • changes to fonts in the object text are ignored.
  • changes to attributes other than Object Text are not shown.
  • deleted and moved objects are not portrayed as changes.

Thank you. It really help.

I did a code a little bit easier than that. See below just for the record fo future users:
 

/**
 * Created by: lupsanto
 * Creation date: 09/02/2011
 *
 * DXL Editor is provided by SODIUS (www.dxleditor.com)
 */
pragma runLim, 0
// history DXL Example 
/*
  Example history DXL program.
  Generate a report of the current Module's
  history.
*/ 
 
// Function to print the DIFF
void print(History h, Object o) {
    HistoryType ht = h.type 
    Buffer result = create ()
    Buffer one = create ()
    Buffer two = create ()
    string s
 
    if (ht==modifyObject) { //Get only Modified Objects
 
                if (h.attrName == "Object Text"){ // Get mod only in Object Test
                                string oldV = h.plainOldValue
                                string newV = h.plainNewValue
                                one = oldV                      
                                two = newV
                                diff(result, one, two, true)
                                displayRichWithColor (stringOf(result) "\n \n")
                        }      
                
        }
    }
// Main program 
History h 
int cont = 1
int a = 1
string s
        
        for h in obj do{
        cont++ //Get all history entry
        }
        for h in obj do {
        a++     
        if (a == cont){ // get just the last change
                print (h, obj)
                //s = obj."Object Text"
                //print s
                }
        }
        cont = 1

Re: How to print the differences in Object Text History
lupsanto - Wed Feb 09 07:30:32 EST 2011

Peter_Albert - Wed Feb 09 07:05:42 EST 2011

If you really want to display the latest modification of "Object Text" you can use the layout DXL below.

Similar limitations as in the previous post: No formatting changes are displayed, deleted and moved objects are not indicated as modifications.

Regards,

Peter

pragma runLim, 0
// -----------------------------------------------------------------------------
void RichText2Text(Buffer buf)
{ // Replace a rich text buffer by its plain text
  RichTextParagraph rp
  Buffer   tmp = create
  tmp = ""
  for rp in stringOf buf do
  { // Loop through rich text paragraphs
    if (length tmp > 0){tmp += "\n"}
    tmp += rp.text
  } // Loop through rich text paragraphs
  buf = stringOf tmp
  delete tmp
} // Replace a rich text buffer by its plain text
// -----------------------------------------------------------------------------
void displayLastHistory()
{ // Display the last Object Text modification from the history
  History     hist
  HistoryType histType
  string      histAttName
  Buffer      lastChangeBuf     = create
  Buffer      currObjectTextBuf = create
  Buffer      diffResultBuf     = create
  bool        foundObjTextHistory
  
  foundObjTextHistory = false
  for hist in obj do
  { // Loop through object history
    histType    = hist.type
    histAttName = ""
    if (histType == modifyObject)
    { // Object modification
      histAttName = hist.attrName
      if (histAttName == "Object Text")
      { // Modification of "Object Text"
        lastChangeBuf       = hist.oldValue
        currObjectTextBuf   = hist.newValue
        foundObjTextHistory = true
      } // Modification of "Object Text"
    } // Object modification
  } // Loop through object history
  if (foundObjTextHistory)
  { // History contains at least one modification of "Object Text"
    RichText2Text(lastChangeBuf)
    RichText2Text(currObjectTextBuf)
    if (lastChangeBuf != currObjectTextBuf)
    { // Do not show modifications of text formatting only
      diff(diffResultBuf, lastChangeBuf, currObjectTextBuf)
    } // Do not show modifications of text formatting only
    displayRich tempStringOf diffResultBuf
  } // History contains at least one modification of "Object Text"
  delete diffResultBuf
  delete lastChangeBuf
  delete currObjectTextBuf
} // Display the last Object Text modification from the history
// -----------------------------------------------------------------------------
displayLastHistory()

Thank You!

It really helped me and a I got my code improved.

Thanks

Re: How to print the differences in Object Text History
Peter_Albert - Wed Feb 09 08:13:29 EST 2011

lupsanto - Wed Feb 09 07:30:32 EST 2011
Thank You!

It really helped me and a I got my code improved.

Thanks

Your script only reports the modification of "Object Text" if that is the last history entry at all. If there is a different modification after that one, e.g. the modification of a different attribute, or moving the object, then nothing is displayed.

But I also learned something new! I didn't know neither 'hist.plainOldValue', nor 'displayRichWithColor'.

With that, my version simplifies to

pragma runLim, 0
// -----------------------------------------------------------------------------
void displayLastHistory()
{ // Display the last Object Text modification from the history
  History     hist
  HistoryType histType
  string      histAttName
  Buffer      lastChangeBuf     = create
  Buffer      currObjectTextBuf = create
  Buffer      diffResultBuf     = create
  bool        foundObjTextHistory
  
  foundObjTextHistory = false
  for hist in obj do
  { // Loop through object history
    histType    = hist.type
    histAttName = ""
    if (histType == modifyObject)
    { // Object modification
      histAttName = hist.attrName
      if (histAttName == "Object Text")
      { // Modification of "Object Text"
        lastChangeBuf       = hist.plainOldValue
        currObjectTextBuf   = hist.plainNewValue
        foundObjTextHistory = true
      } // Modification of "Object Text"
    } // Object modification
  } // Loop through object history
  if (foundObjTextHistory)
  { // History contains at least one modification of "Object Text"
    if (lastChangeBuf != currObjectTextBuf)
    { // Do not show modifications of text formatting only
      diff(diffResultBuf, lastChangeBuf, currObjectTextBuf)
    } // Do not show modifications of text formatting only
    displayRichWithColor  tempStringOf diffResultBuf
  } // History contains at least one modification of "Object Text"
  delete diffResultBuf
  delete lastChangeBuf
  delete currObjectTextBuf
} // Display the last Object Text modification from the history
// -----------------------------------------------------------------------------
displayLastHistory()

 


Peter

 

Re: How to print the differences in Object Text History
lupsanto - Wed Feb 09 09:29:05 EST 2011

Peter_Albert - Wed Feb 09 08:13:29 EST 2011

Your script only reports the modification of "Object Text" if that is the last history entry at all. If there is a different modification after that one, e.g. the modification of a different attribute, or moving the object, then nothing is displayed.

But I also learned something new! I didn't know neither 'hist.plainOldValue', nor 'displayRichWithColor'.

With that, my version simplifies to

pragma runLim, 0
// -----------------------------------------------------------------------------
void displayLastHistory()
{ // Display the last Object Text modification from the history
  History     hist
  HistoryType histType
  string      histAttName
  Buffer      lastChangeBuf     = create
  Buffer      currObjectTextBuf = create
  Buffer      diffResultBuf     = create
  bool        foundObjTextHistory
  
  foundObjTextHistory = false
  for hist in obj do
  { // Loop through object history
    histType    = hist.type
    histAttName = ""
    if (histType == modifyObject)
    { // Object modification
      histAttName = hist.attrName
      if (histAttName == "Object Text")
      { // Modification of "Object Text"
        lastChangeBuf       = hist.plainOldValue
        currObjectTextBuf   = hist.plainNewValue
        foundObjTextHistory = true
      } // Modification of "Object Text"
    } // Object modification
  } // Loop through object history
  if (foundObjTextHistory)
  { // History contains at least one modification of "Object Text"
    if (lastChangeBuf != currObjectTextBuf)
    { // Do not show modifications of text formatting only
      diff(diffResultBuf, lastChangeBuf, currObjectTextBuf)
    } // Do not show modifications of text formatting only
    displayRichWithColor  tempStringOf diffResultBuf
  } // History contains at least one modification of "Object Text"
  delete diffResultBuf
  delete lastChangeBuf
  delete currObjectTextBuf
} // Display the last Object Text modification from the history
// -----------------------------------------------------------------------------
displayLastHistory()

 


Peter

 

Yes... you are right. I figure this out few minutes latter, but now I am using your new version.

However, I still have a problem... It is not working with OLE objects, such as figures and tables into DOC file for example. Do you have any idea how to also get this part of Object Text?

Thanks a million and I am happy that I also could bring something new to you.

Re: How to print the differences in Object Text History
Peter_Albert - Wed Feb 09 09:49:22 EST 2011

lupsanto - Wed Feb 09 09:29:05 EST 2011
Yes... you are right. I figure this out few minutes latter, but now I am using your new version.

However, I still have a problem... It is not working with OLE objects, such as figures and tables into DOC file for example. Do you have any idea how to also get this part of Object Text?

Thanks a million and I am happy that I also could bring something new to you.

Well, unfortuntately no.

There is no easy way for comparing OLE objects, and the situation is worse due to the fact that OLE objects seem to be modified just by looking at them. I vaguely remember a thread on the issue.

Regards,

Peter

Re: How to print the differences in Object Text History
lupsanto - Wed Feb 09 09:54:55 EST 2011

Peter_Albert - Wed Feb 09 09:49:22 EST 2011
Well, unfortuntately no.

There is no easy way for comparing OLE objects, and the situation is worse due to the fact that OLE objects seem to be modified just by looking at them. I vaguely remember a thread on the issue.

Regards,

Peter

Actually, I just want to show the OLE's in the old version and the OLEs in the new... like copy and paste all OLEs.

Any idea?

Re: How to print the differences in Object Text History
Peter_Albert - Wed Feb 09 10:33:00 EST 2011

lupsanto - Wed Feb 09 09:54:55 EST 2011
Actually, I just want to show the OLE's in the old version and the OLEs in the new... like copy and paste all OLEs.

Any idea?

Well, I have modified the script below such that if either the old or the new value of the last modification of Object Text contains OLE objects, then it displays both values instead of the difference.

Note that it is not sufficient to count the OLE objects in obj."Object Text", as you also want to detect deletions of OLE objects. Hence the 'int oleCount(string sInput)' routine.
Now, the strange thing I observed is the following:

When I add, delete or modify an OLE object (equation, embedded Word file) and don't save the module (i.e. the change bar is red), then everything works as expected.

However, when I save the module (i.e. the change bar becomes yellow), then the OLE objects are no longer displayed.
I think it has nothing to do with my routine, as the same behaviour is visible from the Object properties / History dialogue box. Prior to saving the module, the old and new OLE objects are properly displayed, after saving, nothing is displayed any more. It is as if the hist.oldValue and hist.newValue change when the module is saved.

BTW, this happens under 8.3

I would appreciate if you could give it a try and let me know of the result.

Regards,

Peter

pragma runLim, 0
// -----------------------------------------------------------------------------
int oleCount(string sInput)
{ // Count OLE objects in rich text string
  RichTextParagraph rp
  RichText          rt
  int               nOLE = 0
  for rp in sInput do
  { // Loop through rich text paragraphs
    for rt in rp do
    { // Loop through rich text chunks
      if (rt.isOle){nOLE++}
    } // Loop through rich text chunks
  } // Loop through rich text paragraphs
  return nOLE
} // Count OLE objects in rich text string
// -----------------------------------------------------------------------------
void displayLastHistory()
{ // Display the last Object Text modification from the history
  // If the "Object Text" contains an OLE object, just display the
  // old and new versions
  
  History     hist
  HistoryType histType
  string      histAttName
  Buffer      lastChangeBuf     = create
  Buffer      currObjectTextBuf = create
  Buffer      diffResultBuf     = create
  string      sOldValue
  string      sNewValue
  int         nOLE
  int         iHist
  int         nLastModificationOfObjectText
  
  iHist                         = 0
  nLastModificationOfObjectText = 0
  for hist in obj do
  { // Loop through object history and get last modification of Object Text
    iHist++
    histType    = hist.type
    histAttName = ""
    if (histType == modifyObject)
    { // Object modification
      histAttName = hist.attrName
      if (histAttName == "Object Text")
      { // Modification of "Object Text"
        nLastModificationOfObjectText = iHist
      } // Modification of "Object Text"
    } // Object modification
  } // Loop through object history and get last modification of Object Text
  iHist = 0
  for hist in obj do
  { // Loop through object history; only work on last modification of Object Text
    iHist++
    if (iHist == nLastModificationOfObjectText)
    { // Last modification of "Object Text"
      sOldValue = hist.oldValue
      sNewValue = hist.newValue
      nOLE = oleCount(sOldValue) + oleCount(sNewValue)
      //display nOLE "\n"
      if (nOLE == 0)
      { // No OLE objects
        lastChangeBuf      = hist.plainOldValue
        currObjectTextBuf  = hist.plainNewValue
        if (lastChangeBuf != currObjectTextBuf)
        { // Do not show modifications of text formatting only
          diff(diffResultBuf, lastChangeBuf, currObjectTextBuf)
          displayRichWithColor  tempStringOf diffResultBuf
        } // Do not show modifications of text formatting only
      } // No OLE objects
      else
      { // At least one OLE object in old or new value
        display "Old Value"
        displayRich sOldValue
        display "\nNew Value"
        displayRich sNewValue
      } // At least one OLE object in old or new value
    } // Last modification of "Object Text"
  }  // Loop through object history; only work on last modification of Object Text
  delete diffResultBuf
  delete lastChangeBuf
  delete currObjectTextBuf
} // Display the last Object Text modification from the history
 
displayLastHistory()

Re: How to print the differences in Object Text History
lupsanto - Wed Feb 09 11:04:44 EST 2011

Peter_Albert - Wed Feb 09 10:33:00 EST 2011

Well, I have modified the script below such that if either the old or the new value of the last modification of Object Text contains OLE objects, then it displays both values instead of the difference.

Note that it is not sufficient to count the OLE objects in obj."Object Text", as you also want to detect deletions of OLE objects. Hence the 'int oleCount(string sInput)' routine.
Now, the strange thing I observed is the following:

When I add, delete or modify an OLE object (equation, embedded Word file) and don't save the module (i.e. the change bar is red), then everything works as expected.

However, when I save the module (i.e. the change bar becomes yellow), then the OLE objects are no longer displayed.
I think it has nothing to do with my routine, as the same behaviour is visible from the Object properties / History dialogue box. Prior to saving the module, the old and new OLE objects are properly displayed, after saving, nothing is displayed any more. It is as if the hist.oldValue and hist.newValue change when the module is saved.

BTW, this happens under 8.3

I would appreciate if you could give it a try and let me know of the result.

Regards,

Peter

pragma runLim, 0
// -----------------------------------------------------------------------------
int oleCount(string sInput)
{ // Count OLE objects in rich text string
  RichTextParagraph rp
  RichText          rt
  int               nOLE = 0
  for rp in sInput do
  { // Loop through rich text paragraphs
    for rt in rp do
    { // Loop through rich text chunks
      if (rt.isOle){nOLE++}
    } // Loop through rich text chunks
  } // Loop through rich text paragraphs
  return nOLE
} // Count OLE objects in rich text string
// -----------------------------------------------------------------------------
void displayLastHistory()
{ // Display the last Object Text modification from the history
  // If the "Object Text" contains an OLE object, just display the
  // old and new versions
  
  History     hist
  HistoryType histType
  string      histAttName
  Buffer      lastChangeBuf     = create
  Buffer      currObjectTextBuf = create
  Buffer      diffResultBuf     = create
  string      sOldValue
  string      sNewValue
  int         nOLE
  int         iHist
  int         nLastModificationOfObjectText
  
  iHist                         = 0
  nLastModificationOfObjectText = 0
  for hist in obj do
  { // Loop through object history and get last modification of Object Text
    iHist++
    histType    = hist.type
    histAttName = ""
    if (histType == modifyObject)
    { // Object modification
      histAttName = hist.attrName
      if (histAttName == "Object Text")
      { // Modification of "Object Text"
        nLastModificationOfObjectText = iHist
      } // Modification of "Object Text"
    } // Object modification
  } // Loop through object history and get last modification of Object Text
  iHist = 0
  for hist in obj do
  { // Loop through object history; only work on last modification of Object Text
    iHist++
    if (iHist == nLastModificationOfObjectText)
    { // Last modification of "Object Text"
      sOldValue = hist.oldValue
      sNewValue = hist.newValue
      nOLE = oleCount(sOldValue) + oleCount(sNewValue)
      //display nOLE "\n"
      if (nOLE == 0)
      { // No OLE objects
        lastChangeBuf      = hist.plainOldValue
        currObjectTextBuf  = hist.plainNewValue
        if (lastChangeBuf != currObjectTextBuf)
        { // Do not show modifications of text formatting only
          diff(diffResultBuf, lastChangeBuf, currObjectTextBuf)
          displayRichWithColor  tempStringOf diffResultBuf
        } // Do not show modifications of text formatting only
      } // No OLE objects
      else
      { // At least one OLE object in old or new value
        display "Old Value"
        displayRich sOldValue
        display "\nNew Value"
        displayRich sNewValue
      } // At least one OLE object in old or new value
    } // Last modification of "Object Text"
  }  // Loop through object history; only work on last modification of Object Text
  delete diffResultBuf
  delete lastChangeBuf
  delete currObjectTextBuf
} // Display the last Object Text modification from the history
 
displayLastHistory()

It works, but not at all.

Some OLE object are shown and other no... I dont really unsderstand why...

Thaks anyway.

Re: How to print the differences in Object Text History
lupsanto - Wed Feb 09 11:59:42 EST 2011

lupsanto - Wed Feb 09 11:04:44 EST 2011
It works, but not at all.

Some OLE object are shown and other no... I dont really unsderstand why...

Thaks anyway.

See below the final version that works perfectlly:
 

/**
 * Created by: lupsanto
 * Creation date: 09/02/2011
 *
 * DXL Editor is provided by SODIUS (www.dxleditor.com)
 */
 
 /*
  * This script crates a LAYOUT DXL column that shows the Object Text before the CP applied.
  * If the previous Object Text has no OLE object, the script shows the difference between the Old and the New Object Text
  * If the previous Object Text has at least one OLE object, the script shows the fully old Object Text and do not show
  *    the differences between the old and new.
 */
 
 pragma encoding, "UTF-8"
pragma runLim, 0
 
 
// -----------------------------------------------------------------------------
int oleCount(string sInput)
{ // Count OLE objects in rich text string
  RichTextParagraph rp
  RichText          rt
  int               nOLE = 0
  for rp in sInput do
  { // Loop through rich text paragraphs
    for rt in rp do
    { // Loop through rich text chunks
      if (rt.isOle){nOLE++}
    } // Loop through rich text chunks
  } // Loop through rich text paragraphs
  return nOLE
} // Count OLE objects in rich text string
 
 
 
// -----------------------------------------------------------------------------
void displayLastHistory()
{ // Display the last Object Text modification from the history
  History     hist
  HistoryType histType
  string      histAttName
  Buffer      lastChangeBuf     = create
  Buffer      currObjectTextBuf = create
  Buffer      diffResultBuf     = create
  bool        foundObjTextHistory = false
  bool    isOldEmpty = false
  string s //String to save the old value not in PLAIN
  int i = 0 // Counter off OLEs in Object Text
  
  for hist in obj do
  { // Loop through object history
    histType    = hist.type
    histAttName = ""
    if (histType == modifyObject)
    { // Object modification
      histAttName = hist.attrName
      if (histAttName == "Object Text" || histAttName == "Object Heading")
      { // Modification of "Object Text"
        lastChangeBuf       = hist.plainOldValue
        currObjectTextBuf   = hist.plainNewValue
        s = hist.oldValue
        i = oleCount (s)
        foundObjTextHistory = true
                if (null stringOf(lastChangeBuf)){
                        isOldEmpty = true
                        }            
      } // Modification of "Object Text"
    } // Object modification
  } // Loop through object history
  
  if (foundObjTextHistory)
  { // History contains at least one modification of "Object Text"
    if (lastChangeBuf != currObjectTextBuf)
    { // Do not show modifications of text formatting only
      diff(diffResultBuf, lastChangeBuf, currObjectTextBuf)
    } // Do not show modifications of text formatting only
                if (isOldEmpty){
                        display "Was: (Insertion)"
                        }
                else{
                        display "Was: (Modification)"
                }
                                
        if (i>0){
                displayRich "\n" s //In case of has an OLE, show the full OLD VALUE 
        }
        else{
                displayRichWithColor "\n" tempStringOf diffResultBuf
        }
  } // History contains at least one modification of "Object Text"
  delete diffResultBuf
  delete lastChangeBuf
  delete currObjectTextBuf
} 
 
// Display the last Object Text modification from the history
// -----------------------------------------------------------------------------
 
displayLastHistory()

Re: How to print the differences in Object Text History
SystemAdmin - Wed Feb 09 15:23:26 EST 2011

lupsanto - Wed Feb 09 11:59:42 EST 2011

See below the final version that works perfectlly:
 

/**
 * Created by: lupsanto
 * Creation date: 09/02/2011
 *
 * DXL Editor is provided by SODIUS (www.dxleditor.com)
 */
 
 /*
  * This script crates a LAYOUT DXL column that shows the Object Text before the CP applied.
  * If the previous Object Text has no OLE object, the script shows the difference between the Old and the New Object Text
  * If the previous Object Text has at least one OLE object, the script shows the fully old Object Text and do not show
  *    the differences between the old and new.
 */
 
 pragma encoding, "UTF-8"
pragma runLim, 0
 
 
// -----------------------------------------------------------------------------
int oleCount(string sInput)
{ // Count OLE objects in rich text string
  RichTextParagraph rp
  RichText          rt
  int               nOLE = 0
  for rp in sInput do
  { // Loop through rich text paragraphs
    for rt in rp do
    { // Loop through rich text chunks
      if (rt.isOle){nOLE++}
    } // Loop through rich text chunks
  } // Loop through rich text paragraphs
  return nOLE
} // Count OLE objects in rich text string
 
 
 
// -----------------------------------------------------------------------------
void displayLastHistory()
{ // Display the last Object Text modification from the history
  History     hist
  HistoryType histType
  string      histAttName
  Buffer      lastChangeBuf     = create
  Buffer      currObjectTextBuf = create
  Buffer      diffResultBuf     = create
  bool        foundObjTextHistory = false
  bool    isOldEmpty = false
  string s //String to save the old value not in PLAIN
  int i = 0 // Counter off OLEs in Object Text
  
  for hist in obj do
  { // Loop through object history
    histType    = hist.type
    histAttName = ""
    if (histType == modifyObject)
    { // Object modification
      histAttName = hist.attrName
      if (histAttName == "Object Text" || histAttName == "Object Heading")
      { // Modification of "Object Text"
        lastChangeBuf       = hist.plainOldValue
        currObjectTextBuf   = hist.plainNewValue
        s = hist.oldValue
        i = oleCount (s)
        foundObjTextHistory = true
                if (null stringOf(lastChangeBuf)){
                        isOldEmpty = true
                        }            
      } // Modification of "Object Text"
    } // Object modification
  } // Loop through object history
  
  if (foundObjTextHistory)
  { // History contains at least one modification of "Object Text"
    if (lastChangeBuf != currObjectTextBuf)
    { // Do not show modifications of text formatting only
      diff(diffResultBuf, lastChangeBuf, currObjectTextBuf)
    } // Do not show modifications of text formatting only
                if (isOldEmpty){
                        display "Was: (Insertion)"
                        }
                else{
                        display "Was: (Modification)"
                }
                                
        if (i>0){
                displayRich "\n" s //In case of has an OLE, show the full OLD VALUE 
        }
        else{
                displayRichWithColor "\n" tempStringOf diffResultBuf
        }
  } // History contains at least one modification of "Object Text"
  delete diffResultBuf
  delete lastChangeBuf
  delete currObjectTextBuf
} 
 
// Display the last Object Text modification from the history
// -----------------------------------------------------------------------------
 
displayLastHistory()

Nice scripts here!

But the last script from lupsanto only shows the change based on the last modification made instead of showing all changes made compared to a baseline - is this what was expected? I'm curious to know why it's important to only see the last change made.


Paul Miller
Melbourne, Australia

Re: How to print the differences in Object Text History
lupsanto - Thu Feb 10 04:28:22 EST 2011

SystemAdmin - Wed Feb 09 15:23:26 EST 2011
Nice scripts here!

But the last script from lupsanto only shows the change based on the last modification made instead of showing all changes made compared to a baseline - is this what was expected? I'm curious to know why it's important to only see the last change made.


Paul Miller
Melbourne, Australia

Yes... it did exactly what I want.

In my case, it is not necessary to check the changes of a changes... I just want to see the last modification, because it is the current requirement.

Due to we close the baselines very often, the last modification view almost is a comparison between the current and the last baseline.

Thanks a million about all of the help!

Lucas

Re: How to print the differences in Object Text History
Peter_Albert - Thu Feb 10 05:33:48 EST 2011

Peter_Albert - Wed Feb 09 10:33:00 EST 2011

Well, I have modified the script below such that if either the old or the new value of the last modification of Object Text contains OLE objects, then it displays both values instead of the difference.

Note that it is not sufficient to count the OLE objects in obj."Object Text", as you also want to detect deletions of OLE objects. Hence the 'int oleCount(string sInput)' routine.
Now, the strange thing I observed is the following:

When I add, delete or modify an OLE object (equation, embedded Word file) and don't save the module (i.e. the change bar is red), then everything works as expected.

However, when I save the module (i.e. the change bar becomes yellow), then the OLE objects are no longer displayed.
I think it has nothing to do with my routine, as the same behaviour is visible from the Object properties / History dialogue box. Prior to saving the module, the old and new OLE objects are properly displayed, after saving, nothing is displayed any more. It is as if the hist.oldValue and hist.newValue change when the module is saved.

BTW, this happens under 8.3

I would appreciate if you could give it a try and let me know of the result.

Regards,

Peter

pragma runLim, 0
// -----------------------------------------------------------------------------
int oleCount(string sInput)
{ // Count OLE objects in rich text string
  RichTextParagraph rp
  RichText          rt
  int               nOLE = 0
  for rp in sInput do
  { // Loop through rich text paragraphs
    for rt in rp do
    { // Loop through rich text chunks
      if (rt.isOle){nOLE++}
    } // Loop through rich text chunks
  } // Loop through rich text paragraphs
  return nOLE
} // Count OLE objects in rich text string
// -----------------------------------------------------------------------------
void displayLastHistory()
{ // Display the last Object Text modification from the history
  // If the "Object Text" contains an OLE object, just display the
  // old and new versions
  
  History     hist
  HistoryType histType
  string      histAttName
  Buffer      lastChangeBuf     = create
  Buffer      currObjectTextBuf = create
  Buffer      diffResultBuf     = create
  string      sOldValue
  string      sNewValue
  int         nOLE
  int         iHist
  int         nLastModificationOfObjectText
  
  iHist                         = 0
  nLastModificationOfObjectText = 0
  for hist in obj do
  { // Loop through object history and get last modification of Object Text
    iHist++
    histType    = hist.type
    histAttName = ""
    if (histType == modifyObject)
    { // Object modification
      histAttName = hist.attrName
      if (histAttName == "Object Text")
      { // Modification of "Object Text"
        nLastModificationOfObjectText = iHist
      } // Modification of "Object Text"
    } // Object modification
  } // Loop through object history and get last modification of Object Text
  iHist = 0
  for hist in obj do
  { // Loop through object history; only work on last modification of Object Text
    iHist++
    if (iHist == nLastModificationOfObjectText)
    { // Last modification of "Object Text"
      sOldValue = hist.oldValue
      sNewValue = hist.newValue
      nOLE = oleCount(sOldValue) + oleCount(sNewValue)
      //display nOLE "\n"
      if (nOLE == 0)
      { // No OLE objects
        lastChangeBuf      = hist.plainOldValue
        currObjectTextBuf  = hist.plainNewValue
        if (lastChangeBuf != currObjectTextBuf)
        { // Do not show modifications of text formatting only
          diff(diffResultBuf, lastChangeBuf, currObjectTextBuf)
          displayRichWithColor  tempStringOf diffResultBuf
        } // Do not show modifications of text formatting only
      } // No OLE objects
      else
      { // At least one OLE object in old or new value
        display "Old Value"
        displayRich sOldValue
        display "\nNew Value"
        displayRich sNewValue
      } // At least one OLE object in old or new value
    } // Last modification of "Object Text"
  }  // Loop through object history; only work on last modification of Object Text
  delete diffResultBuf
  delete lastChangeBuf
  delete currObjectTextBuf
} // Display the last Object Text modification from the history
 
displayLastHistory()

Just in case someone else also sees Object history on OLE objects disappearing: it is not a bug, but a feature: In the Database properties, there is a checkbox "OLE in History: Save OLE objects in attribute history" which controls the behaviour.

Peter

Re: How to print the differences in Object Text History
lupsanto - Thu Feb 10 05:42:29 EST 2011

Peter_Albert - Thu Feb 10 05:33:48 EST 2011
Just in case someone else also sees Object history on OLE objects disappearing: it is not a bug, but a feature: In the Database properties, there is a checkbox "OLE in History: Save OLE objects in attribute history" which controls the behaviour.

Peter

Good do know it.

Thanks,
Lucas, in Brazil

Re: How to print the differences in Object Text History
vasgyuszi - Fri Apr 08 11:55:36 EDT 2011

lupsanto - Thu Feb 10 05:42:29 EST 2011
Good do know it.

Thanks,
Lucas, in Brazil

Dear Experts!

First of all: an interesting thread about history here, very useful!

My question to the topic would be:

Is there any possibility to copy the history entries with the object?
If I do copy manually the module (ctrl+c / ctrl+v), all the module and object history will be copied with. How could I do this by dxl? I have a script to get all the objects of a module and copy them into a newly created module. But the history is gone. How could I place the old history into the new module?

Thanks in advance,
vasgyuszi

Re: How to print the differences in Object Text History
SystemAdmin - Sun Apr 10 03:57:43 EDT 2011

vasgyuszi - Fri Apr 08 11:55:36 EDT 2011
Dear Experts!

First of all: an interesting thread about history here, very useful!

My question to the topic would be:

Is there any possibility to copy the history entries with the object?
If I do copy manually the module (ctrl+c / ctrl+v), all the module and object history will be copied with. How could I do this by dxl? I have a script to get all the objects of a module and copy them into a newly created module. But the history is gone. How could I place the old history into the new module?

Thanks in advance,
vasgyuszi

vasgyuszi wrote: ...If I do copy manually the module (ctrl + c / ctrl + v), all the module and object history will be copied with...

Are you sure about this?

When an object is copied and then pasted, DOORS will reset the history of the created copy as this is effectively a new object. The very first history record in the created copy will indicate the Absolute Number (the UID without the prefix) of the object that was the source of the copy.

AFAIK, you cannot copy the history records of one object and write them into another object.

You wrote that you are copying objects from one module to a newly created module - instead of copying the objects to the newly created module, a possible alternative is to use the DOORS 'Archive' feature to store a copy of the module in a file outside of DOORS, then use the DOORS 'Restore' function to restore the archive in the same database which will be an exact copy of the module (including all history) - then you just delete the objects that you don't want. That's the only way that I can think of where you can keep the history of a copied object.
Paul Miller
Melbourne, Australia

Re: How to print the differences in Object Text History
lupsanto - Mon Apr 11 07:00:35 EDT 2011

vasgyuszi - Fri Apr 08 11:55:36 EDT 2011
Dear Experts!

First of all: an interesting thread about history here, very useful!

My question to the topic would be:

Is there any possibility to copy the history entries with the object?
If I do copy manually the module (ctrl+c / ctrl+v), all the module and object history will be copied with. How could I do this by dxl? I have a script to get all the objects of a module and copy them into a newly created module. But the history is gone. How could I place the old history into the new module?

Thanks in advance,
vasgyuszi

As far as I know, when you copy and paste the object, the history restarts, I mean, in the target module we get just one history instance, "create object".

Re: How to print the differences in Object Text History
jester76 - Thu Nov 29 12:41:09 EST 2012

Peter_Albert - Thu Feb 10 05:33:48 EST 2011
Just in case someone else also sees Object history on OLE objects disappearing: it is not a bug, but a feature: In the Database properties, there is a checkbox "OLE in History: Save OLE objects in attribute history" which controls the behaviour.

Peter

Peter,

Is there a way to program this option to check and uncheck it. Or better even monitor it.

Thanks
Jester

Re: How to print the differences in Object Text History
llandale - Thu Nov 29 15:54:05 EST 2012

jester76 - Thu Nov 29 12:41:09 EST 2012
Peter,

Is there a way to program this option to check and uncheck it. Or better even monitor it.

Thanks
Jester

You mean?
  • bool setOLEHistorySave(bool bSetting)
  • bool getOLEHistorySave()

Re: How to print the differences in Object Text History
jester76 - Fri Nov 30 11:43:34 EST 2012

llandale - Thu Nov 29 15:54:05 EST 2012
You mean?

  • bool setOLEHistorySave(bool bSetting)
  • bool getOLEHistorySave()

Yup this is it.

Thanks
Jester

Re: How to print the differences in Object Text History
jester76 - Fri Nov 30 12:33:21 EST 2012

jester76 - Fri Nov 30 11:43:34 EST 2012
Yup this is it.

Thanks
Jester

What is the function to check uncheck Baseline Deletion.

Regards
Jester

Re: How to print the differences in Object Text History
llandale - Fri Nov 30 13:49:47 EST 2012

jester76 - Fri Nov 30 12:33:21 EST 2012
What is the function to check uncheck Baseline Deletion.

Regards
Jester

  • string setBaselineDeletionEnabled(bool bSetting)
  • bool getBaselineDeletionEnabled()

Re: How to print the differences in Object Text History
jester76 - Mon Dec 03 16:17:01 EST 2012

llandale - Fri Nov 30 13:49:47 EST 2012

  • string setBaselineDeletionEnabled(bool bSetting)
  • bool getBaselineDeletionEnabled()

Thanks
Jester

Re: How to print the differences in Object Text History
KFedor - Thu Aug 14 12:41:33 EDT 2014

Would there be a way to use the original DXL script that DOORS has as an example, but only show objects with changed text? All of my objects are filtered as changed within the last hour because I deleted a linkset. And now I have no good way of filtering it.

Re: How to print the differences in Object Text History
krishnap2w2 - Fri Jan 23 00:50:54 EST 2015

How to Take Print Without Objects?
 
Follow the steps below if you do not want to print objects in a worksheet.
 
1 Suppose you have some data and a button in your worksheet and you wantonly the data to be printed without the button.
2 Right click on the button which you do not want to print and select 'Format Control'.
3 Select Properties in ' Format Control' . Uncheck ' Print Object'.
4 Click OK. When you select the 'print preview', Now you can see the print out without the object.
 

excel vba programmer


Attachments

How to Take Print without Objects.pdf