Topic
  • 26 replies
  • Latest Post - ‏2015-01-23T05:50:54Z by krishnap2w2
lupsanto
lupsanto
15 Posts

Pinned topic How to print the differences in Object Text History

‏2011-02-09T10:56:56Z |
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?
Updated on 2012-12-03T21:17:01Z at 2012-12-03T21:17:01Z by jester76
  • SystemAdmin
    SystemAdmin
    3180 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-09T11:34:01Z  
    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.
  • Peter_Albert
    Peter_Albert
    250 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-09T12:05:42Z  

    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()
    
    Updated on 2014-01-08T22:37:12Z at 2014-01-08T22:37:12Z by iron-man
  • lupsanto
    lupsanto
    15 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-09T12:10:02Z  
    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
    
    Updated on 2014-01-08T22:36:25Z at 2014-01-08T22:36:25Z by iron-man
  • lupsanto
    lupsanto
    15 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-09T12:30:32Z  

    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

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">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() </pre>
    Thank You!

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

    Thanks
  • Peter_Albert
    Peter_Albert
    250 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-09T13:13:29Z  
    • lupsanto
    • ‏2011-02-09T12:30:32Z
    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

     

    Updated on 2014-01-08T22:37:59Z at 2014-01-08T22:37:59Z by iron-man
  • lupsanto
    lupsanto
    15 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-09T14:29:05Z  

    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

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">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() </pre>

     


    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.
  • Peter_Albert
    Peter_Albert
    250 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-09T14:49:22Z  
    • lupsanto
    • ‏2011-02-09T14:29:05Z
    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
  • lupsanto
    lupsanto
    15 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-09T14:54:55Z  
    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?
  • Peter_Albert
    Peter_Albert
    250 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-09T15:33:00Z  
    • lupsanto
    • ‏2011-02-09T14:54:55Z
    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()
    
    Updated on 2014-01-08T22:38:50Z at 2014-01-08T22:38:50Z by iron-man
  • lupsanto
    lupsanto
    15 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-09T16:04:44Z  

    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

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">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() </pre>
    It works, but not at all.

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

    Thaks anyway.
  • lupsanto
    lupsanto
    15 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-09T16:59:42Z  
    • lupsanto
    • ‏2011-02-09T16:04:44Z
    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()
    
    Updated on 2014-01-08T22:39:46Z at 2014-01-08T22:39:46Z by iron-man
  • SystemAdmin
    SystemAdmin
    3180 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-09T20:23:26Z  
    • lupsanto
    • ‏2011-02-09T16:59:42Z

    See below the final version that works perfectlly:
     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">/** * 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() </pre>
    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
  • lupsanto
    lupsanto
    15 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-10T09:28:22Z  
    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
  • Peter_Albert
    Peter_Albert
    250 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-10T10:33:48Z  

    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

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">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() </pre>
    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
  • lupsanto
    lupsanto
    15 Posts

    Re: How to print the differences in Object Text History

    ‏2011-02-10T10:42:29Z  
    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
  • vasgyuszi
    vasgyuszi
    100 Posts

    Re: How to print the differences in Object Text History

    ‏2011-04-08T15:55:36Z  
    • lupsanto
    • ‏2011-02-10T10:42:29Z
    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
  • SystemAdmin
    SystemAdmin
    3180 Posts

    Re: How to print the differences in Object Text History

    ‏2011-04-10T07:57:43Z  
    • vasgyuszi
    • ‏2011-04-08T15:55:36Z
    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
  • lupsanto
    lupsanto
    15 Posts

    Re: How to print the differences in Object Text History

    ‏2011-04-11T11:00:35Z  
    • vasgyuszi
    • ‏2011-04-08T15:55:36Z
    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".
  • jester76
    jester76
    68 Posts

    Re: How to print the differences in Object Text History

    ‏2012-11-29T17:41:09Z  
    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
  • llandale
    llandale
    2979 Posts

    Re: How to print the differences in Object Text History

    ‏2012-11-29T20:54:05Z  
    • jester76
    • ‏2012-11-29T17:41:09Z
    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()
  • jester76
    jester76
    68 Posts

    Re: How to print the differences in Object Text History

    ‏2012-11-30T16:43:34Z  
    • llandale
    • ‏2012-11-29T20:54:05Z
    You mean?
    • bool setOLEHistorySave(bool bSetting)
    • bool getOLEHistorySave()
    Yup this is it.

    Thanks
    Jester
  • jester76
    jester76
    68 Posts

    Re: How to print the differences in Object Text History

    ‏2012-11-30T17:33:21Z  
    • jester76
    • ‏2012-11-30T16:43:34Z
    Yup this is it.

    Thanks
    Jester
    What is the function to check uncheck Baseline Deletion.

    Regards
    Jester
  • llandale
    llandale
    2979 Posts

    Re: How to print the differences in Object Text History

    ‏2012-11-30T18:49:47Z  
    • jester76
    • ‏2012-11-30T17:33:21Z
    What is the function to check uncheck Baseline Deletion.

    Regards
    Jester
    • string setBaselineDeletionEnabled(bool bSetting)
    • bool getBaselineDeletionEnabled()
  • jester76
    jester76
    68 Posts

    Re: How to print the differences in Object Text History

    ‏2012-12-03T21:17:01Z  
    • llandale
    • ‏2012-11-30T18:49:47Z
    • string setBaselineDeletionEnabled(bool bSetting)
    • bool getBaselineDeletionEnabled()
    Thanks
    Jester