KeepN replaces Keep in RTF?

  • I noticed that if I had a paragraph with the \keep attribute, and then use "ASet( WPAT_ParKeepN, 1 )" or "ASetAdd( WPAT_ParKeepN, 1 )" to add the KeepN property, the \keep was replace by \keepn in the RTF instead of having both. I would have expected both to be there because they seem to be mutually exclusive attributes; however, it still seems to act like the \keep is still there.

    I was using D7's debug to view the RTF using WPRichText1.AsString.

    WpTools 5.18.5

  • But it does... simple test will confirm.

    -Create a new D7 app.
    - Add a WPToolbar and a WPRichText (don't forget to link the toolbar to the Richtext
    - enable the SelParKeep property in the sel_OutlineIcons group
    - Add a button, and in the OnClick event do this:

    Code
    WPRichText1.SaveToFile( 'c:\keep.rtf' );
      WPRichText1.ActivePar.ASet(WPAT_ParKeepN, 1);
      WPRichText1.SaveToFile( 'c:\keepn.rtf' );


    - Run the app
    - Type in some text and slect to keep par together using the toolbar
    - click on the button, so that it will write two RTF files, one is the before, and the other is the after the keepN is applied.

    Before (keep.rtf file):

    Zitat

    {\rtf1\ansi\deff0\uc1\ansicpg1252\deftab720{\fonttbl{\f0\fnil\fcharset1 Arial;}{\f1\fnil\fcharset1 WingDings;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;}\wpprheadfoot1\paperw12240\paperh15840\margl1880\margr1880\margt1440\margb1440\headery720\footery720\endnhere\sectdefaultcl{\*\generator WPTools_5.18;}{\keep\plain\f0\fs22 Now is the time to keep this par together\par
    }}

    After (keepN.rtf file):

    Zitat

    {\rtf1\ansi\deff0\uc1\ansicpg1252\deftab720{\fonttbl{\f0\fnil\fcharset1 Arial;}{\f1\fnil\fcharset1 WingDings;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;}\wpprheadfoot1\paperw12240\paperh15840\margl1880\margr1880\margt1440\margb1440\headery720\footery720\endnhere\sectdefaultcl{\*\generator WPTools_5.18;}{\keepn\plain\f0\fs22 Now is the time to keep this par together\par
    }}

    Examine the two files (results should be as above)... the KeepN.rtf file will show that the \keep was replaced by the \keepn. What happened to the \keep????

    Eric

  • This is still a problem in 5.18.8. I will send you an example using your coloring the paragraph technique. You can see the problem by looking at the RTF, but this is more visual.

    The keep attribute saves-to-file and loads-from-file fine, but once you add a KeepN to the same paragraph, and SaveToFile, the keep is lost... only the keepN remains.

    Eric

    P.S. Even though this seems to be a problem, I am having a hard time trying to think why you would even need the keep attrib if you have the keepN anyway... other than to simply retain the keep should you remove the keepN later. I think a keepN encompases what a keep does, but not the other way around.

    • Offizieller Beitrag

    Hi,

    To make the Keep saved when KeepN is used please change line #638 in WPIOWriteRTF from "else" to ";//else".

    I tested the KeepN functionality without the use of "Keep". That works now due to the the way it is programmed: the page break is applied BEFORE the actual reformat routine using the height of the paragraph before the formatting.

    Keep is developer using a 'go back' algorithm - if a break happend to be inserted go back and format this par on a new page. This is a one pass algorithm.

    KeepN should work just file after the second reformat, Keep is used a fallback.

    Julian