C2021-010: Print using standard pagination rules by removing trailing hard returns, spaces & manual page breaks
This commit is contained in:
@@ -265,8 +265,10 @@ namespace Volian.Print.Library
|
||||
StepConfig sc = firstChild.MyItemInfo.MyConfig as StepConfig;
|
||||
ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc == null ? false : sc.Step_ManualPagebreak) :
|
||||
sc == null ? false :
|
||||
MyPageHelper.MyPromsPrinter.RemoveTrailingHardReturnsAndManualPageBreaks ? false : sc.Step_NewManualPagebreak;
|
||||
|
||||
(MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null)? sc.Step_NewManualPagebreak : false;
|
||||
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
|
||||
if (sc != null && sc.Step_NewManualPagebreak && MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks != null &&
|
||||
!MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Contains(firstChild.MyItemInfo.ItemID)) MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Add(firstChild.MyItemInfo.ItemID);
|
||||
if (ManualPageBreak)
|
||||
{
|
||||
SectionPageBreak = true;
|
||||
@@ -390,7 +392,11 @@ namespace Volian.Print.Library
|
||||
//Console.WriteLine("{0} Paginate", MyPageHelper.HLSText);
|
||||
StepConfig sc1 = MyItemInfo.MyConfig as StepConfig;
|
||||
ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc1 == null ? false : sc1.Step_ManualPagebreak) :
|
||||
sc1 == null ? false : MyPageHelper.MyPromsPrinter.RemoveTrailingHardReturnsAndManualPageBreaks ? false : sc1.Step_NewManualPagebreak;
|
||||
sc1 == null ? false : (MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks == null) ? sc1.Step_NewManualPagebreak : false;
|
||||
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
|
||||
if (sc1 != null && sc1.Step_NewManualPagebreak &&
|
||||
MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks != null && !MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Contains(MyItemInfo.ItemID)) MyPageHelper.MyPromsPrinter.RemoveManualPageBreaks.Add(MyItemInfo.ItemID);
|
||||
|
||||
if (MyItemInfo.FirstSibling == MyItemInfo && ManualPageBreak)
|
||||
{
|
||||
// if parent/section used this pagebreak, skip it.
|
||||
|
@@ -116,11 +116,20 @@ namespace Volian.Print.Library
|
||||
get { return _SaveLinks; }
|
||||
set { _SaveLinks = value; }
|
||||
}
|
||||
private bool _RemoveTrailingHardReturnsAndManualPageBreaks = false;
|
||||
public bool RemoveTrailingHardReturnsAndManualPageBreaks
|
||||
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
|
||||
// Use these 2 lists to track the items that will need to be saved after removing trailing newlines/spaces or
|
||||
// manual page breaks, if the user selects to do that.
|
||||
private List<int> _RemoveTrailingHardReturnsAndSpaces = null;
|
||||
public List<int> RemoveTrailingHardReturnsAndSpaces
|
||||
{
|
||||
get { return _RemoveTrailingHardReturnsAndManualPageBreaks; }
|
||||
set { _RemoveTrailingHardReturnsAndManualPageBreaks = value; }
|
||||
get { return _RemoveTrailingHardReturnsAndSpaces; }
|
||||
set { _RemoveTrailingHardReturnsAndSpaces = value; }
|
||||
}
|
||||
private List<int> _RemoveManualPageBreaks = null;
|
||||
public List<int> RemoveManualPageBreaks
|
||||
{
|
||||
get { return _RemoveManualPageBreaks; }
|
||||
set { _RemoveManualPageBreaks = value; }
|
||||
}
|
||||
|
||||
private string _Prefix = ""; // RHM20150506 Multiline ItemID TextBox
|
||||
@@ -307,7 +316,7 @@ namespace Volian.Print.Library
|
||||
set { _MergedPdf = value; }
|
||||
}
|
||||
public PromsPrinter(ItemInfo myItem, string rev, string watermark, bool debugOutput, bool origPgBrk, string backgroundFolder, bool openPDF, bool overWrite,
|
||||
ChangeBarDefinition cbd, String pdfFile, bool insertBlankPages, bool batchPrint, string prefix, bool saveLinks, bool removeTrailngHardReturnsAndManualPageBreaks, string blankPageText, bool didAll, MergedPdf mergedPdf)
|
||||
ChangeBarDefinition cbd, String pdfFile, bool insertBlankPages, bool batchPrint, string prefix, bool saveLinks, int removeTrailngHardReturnsAndManualPageBreaks, string blankPageText, bool didAll, MergedPdf mergedPdf)
|
||||
{
|
||||
Prefix = prefix; // RHM20150506 Multiline ItemID TextBox
|
||||
_MyItem = myItem;
|
||||
@@ -324,7 +333,9 @@ namespace Volian.Print.Library
|
||||
_BatchPrint = batchPrint;
|
||||
_MyReaderHelper = new ReaderHelper(this);
|
||||
_SaveLinks = saveLinks;
|
||||
_RemoveTrailingHardReturnsAndManualPageBreaks = removeTrailngHardReturnsAndManualPageBreaks;
|
||||
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
|
||||
if (removeTrailngHardReturnsAndManualPageBreaks == 1 || removeTrailngHardReturnsAndManualPageBreaks == 3 ) RemoveTrailingHardReturnsAndSpaces = new List<int>();
|
||||
if (removeTrailngHardReturnsAndManualPageBreaks == 2 || removeTrailngHardReturnsAndManualPageBreaks == 3) RemoveManualPageBreaks = new List<int>();
|
||||
_BlankPageText = blankPageText;
|
||||
_DidAll = didAll;
|
||||
_MergeNotIncluded = false;
|
||||
@@ -2454,6 +2465,78 @@ namespace Volian.Print.Library
|
||||
*/
|
||||
return ms.ToArray();
|
||||
}
|
||||
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
|
||||
public void SavePaginationFixes()
|
||||
{
|
||||
// If manual page breaks were removed (during pagination), save those
|
||||
if (RemoveManualPageBreaks != null && RemoveManualPageBreaks.Count > 0)
|
||||
{
|
||||
foreach (int iid in RemoveManualPageBreaks)
|
||||
{
|
||||
ItemInfo ii = ItemInfo.Get(iid);
|
||||
StepConfig sc = ii.MyConfig as StepConfig;
|
||||
if (sc != null)
|
||||
{
|
||||
using (Item itm = Item.Get(iid))
|
||||
{
|
||||
VEPROMS.CSLA.Library.Annotation x = VEPROMS.CSLA.Library.Annotation.MakeAnnotation(itm, AnnotationType.GetByNameOrCreate("Manual Pagination Issues"), null, "Removed Manual Page Break", null);
|
||||
sc.Step_NewManualPagebreak = false; // reset the flag that was set in the config
|
||||
itm.MyContent.Config = sc.ToString();
|
||||
itm.MyContent.DTS = DateTime.Now;
|
||||
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||
itm.MyContent.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// If trailing newlines and/or spages were removed, save those
|
||||
if (RemoveTrailingHardReturnsAndSpaces != null && RemoveTrailingHardReturnsAndSpaces.Count > 0)
|
||||
{
|
||||
foreach (int iid in RemoveTrailingHardReturnsAndSpaces)
|
||||
{
|
||||
// first check if it exists, if the step was empty, it may have been deleted.
|
||||
ItemInfo iitmp = ItemInfo.Get(iid);
|
||||
if (iitmp != null)
|
||||
{
|
||||
string annot = "Removed Trailing Newlines and Spaces";
|
||||
if (RemoveManualPageBreaks != null && RemoveManualPageBreaks.Contains(iid)) annot = "Removed Trailing Newlines, Spaces and ManualPageBreak";
|
||||
string tmp = Regex.Replace(iitmp.MyContent.Text, "(\\\\line|\r|\n|\\\\u160\\?| )+$", "");
|
||||
// if the step ends up empty, set the text to a space (if null or "") step gets deleted. Also, flag
|
||||
// that this is an emtpy step so that print can handle it, i.e. when text is set for step during printing,
|
||||
// if it is emtpy the string is "", which prints without height. This is flagged so that the pdf will
|
||||
// look the same, i.e. printed when trailing newlines/spaces are removed (text = "") & after the changes
|
||||
// are saved (text = " ")
|
||||
if (tmp == null || tmp == "")
|
||||
{
|
||||
StepConfig sctmp = iitmp.MyConfig as StepConfig;
|
||||
if (sctmp == null) sctmp = new StepConfig();
|
||||
sctmp.Step_EmptyStep = true;
|
||||
annot = "Empty step. Consider deleting to restore standard pagination.";
|
||||
using (Item itm = Item.Get(iid))
|
||||
{
|
||||
VEPROMS.CSLA.Library.Annotation x = VEPROMS.CSLA.Library.Annotation.MakeAnnotation(itm, AnnotationType.GetByNameOrCreate("Manual Pagination Issues"), null, annot, null);
|
||||
itm.MyContent.Config = sctmp.ToString();
|
||||
itm.MyContent.Text = " ";
|
||||
itm.MyContent.DTS = DateTime.Now;
|
||||
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||
itm.MyContent.Save();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Item itm = Item.Get(iid))
|
||||
{
|
||||
VEPROMS.CSLA.Library.Annotation x = VEPROMS.CSLA.Library.Annotation.MakeAnnotation(itm, AnnotationType.GetByNameOrCreate("Manual Pagination Issues"), null, annot, null);
|
||||
itm.MyContent.Text = tmp;
|
||||
itm.MyContent.DTS = DateTime.Now;
|
||||
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||
itm.MyContent.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class ReaderHelper
|
||||
{
|
||||
|
@@ -5403,7 +5403,9 @@ namespace Volian.Print.Library
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> GetRtf");
|
||||
_RtfSB = new StringBuilder();
|
||||
DisplayText vlntxt = new DisplayText(itemInfo, E_EditPrintMode.Print, E_ViewMode.View, true, E_FieldToEdit.StepText, false, prefix, suffix, MyPageHelper.MyPromsPrinter.RemoveTrailingHardReturnsAndManualPageBreaks);
|
||||
DisplayText vlntxt = new DisplayText(itemInfo, E_EditPrintMode.Print, E_ViewMode.View, true, E_FieldToEdit.StepText, false, prefix, suffix, MyPageHelper.MyPromsPrinter.RemoveTrailingHardReturnsAndSpaces != null);
|
||||
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
|
||||
if (DisplayText.RemoveTrailingBlankID > 0 && !MyPageHelper.MyPromsPrinter.RemoveTrailingHardReturnsAndSpaces.Contains(itemInfo.ItemID)) MyPageHelper.MyPromsPrinter.RemoveTrailingHardReturnsAndSpaces.Add(DisplayText.RemoveTrailingBlankID);
|
||||
System.Drawing.Font myFont = vlntxt.TextFont.WindowsFont;
|
||||
if (!itemInfo.IsTable && StepRTB.MyFontFamily != null)
|
||||
// follow through in fixing an Out of Window Handles bug, use new function to see if
|
||||
|
Reference in New Issue
Block a user