B2018-034 Use _IParagraph when PDF Link info is added

B2018-034 Copy the attributes from old to new when IParagraph is refreshed (IsCompressed)
This commit is contained in:
Rich 2018-03-14 13:41:42 +00:00
parent 678018c4a1
commit f9ef66880b
2 changed files with 41 additions and 8 deletions

View File

@ -942,7 +942,6 @@ namespace Volian.Print.Library
vcb.Messages.Add(key + heightDif, msd[key]);
}
}
private float DrawText(PdfContentByte cb, ref float yPageStart, float yTopMargin, float yBottomMargin, ref float yLocation)
{
if (DebugText.IsOpen) DebugText.WriteLine("{0},'{1}','{2}','<<END>>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, FormattedText);
@ -1009,11 +1008,17 @@ namespace Volian.Print.Library
// Need to have a way to get to sections which do not have any output (header only)
// Need to have a way to identify procedures
//
if (IParagraph.Chunks.Count > 0 && MyPageHelper.MyPromsPrinter.SaveLinks)
// B2018-034 The following code previously used IParagraph rather than _IParagraph. If the variable IsCompressed (7LPI) is true for this step
// IParagraph would be refreshed each time it was referenced. Thus the link information would be lost when the IParagraph was re-created.
// This resulted in PDFLinks to steps that were not not identified with a LocalDestination. This was changed from the original code to
// fix B2015-076 when the Byron Flex Procedure 0BFSG-6 was printed. The issue for this bug was that the underlining at 7LPI was overlaping the
// top of the next line of text. I was not able to find the case referencedd in the source safe document. However, by adding a line of
// text "One more line" to the end of step 2 in attachment C, I was able to see the effect.
if (_IParagraph.Chunks.Count > 0 && MyPageHelper.MyPromsPrinter.SaveLinks)
{
Chunk chk1 = IParagraph.Chunks[0] as Chunk;
//Console.WriteLine("\"Desination\"\t{0}", MyItemInfo.ItemID);
if (MyItemInfo.MyContent.Text.ToUpper().Contains("LINK:TR"))
// B2018-034 The following code previously used IParagraph rather than _IParagraph. See first Comment
Chunk chk1 = _IParagraph.Chunks[0] as Chunk;
if (MyItemInfo.MyContent.Text.ToUpper().Contains("LINK:TR") && MyItemInfo.MyContent.ContentTransitionCount==0)
Console.WriteLine("Missing Transition {0}", MyItemInfo.ItemID);
chk1.SetLocalDestination(string.Format("ItemID={0}", MyItemInfo.ItemID)); // Destination
if (MyItemInfo.MyContent.ContentTransitionCount > 0)
@ -1024,7 +1029,8 @@ namespace Volian.Print.Library
!MyItemInfo.ActiveSection.DisplayNumber.ToUpper().StartsWith("FOLDOUT"))
{ // Local Go To
if (ti.MyItemToID.MyContent.Type > 19999)
foreach (Chunk chk in IParagraph.Chunks)
// B2018-034 The following code previously used IParagraph rather than _IParagraph. See first Comment
foreach (Chunk chk in _IParagraph.Chunks)
{
//Console.WriteLine("\"LocalGoTo\"\t{0}", tiDefault.ItemID);
chk.SetLocalGoto(string.Format("ItemID={0}", tiDefault.ItemID));
@ -1045,7 +1051,8 @@ namespace Volian.Print.Library
if (MyItemInfo.MyContent.ContentRoUsageCount > 0)
{
RoUsageInfo ru = MyItemInfo.MyContent.ContentRoUsages[0];
foreach (Chunk chk in IParagraph.Chunks)
// B2018-034 The following code previously used IParagraph rather than _IParagraph. See first Comment
foreach (Chunk chk in _IParagraph.Chunks)
{
if (ru.ROID.Substring(0, 4) != "FFFF")
{
@ -2263,6 +2270,7 @@ namespace Volian.Print.Library
ProfileTimer.Pop(profileDepth);
return yPageStart;
}
private bool IsPrintedStepItemForSupInfo()
{
bool printedMySectTitle = true;

View File

@ -106,7 +106,10 @@ namespace Volian.Print.Library
}
}
public static VlnSplitCharacter mySplitter = new VlnSplitCharacter();
iTextSharp.text.Paragraph _IParagraph;
// B2018-034 Attributes were being lost when the IsCompressed flag was true.
// The following variable was changed to a public so that it could be used
// for setting PDF Links without creating IParagraph when IsCompressed was true.
public iTextSharp.text.Paragraph _IParagraph;
public iTextSharp.text.Paragraph IParagraph
{
get
@ -124,13 +127,35 @@ namespace Volian.Print.Library
myRtf= myRtf.Replace(@"\line \line ", @"\line \u160? \line ");
if (myRtf.Contains(@"\pard\line ")) // Bug fix: B2016-145 for VC.Summer End Message
myRtf = myRtf.Replace(@"\pard\line ", @"\par ");
// B2018-034 Attributes were being lost when the IsCompressed flag was true.
// CopyAttributesToNewIParagraph retains any attribute which have been set
Paragraph oldParagraph = _IParagraph;
_IParagraph = RtfToParagraph(myRtf, HasIndent);
// B2018-034 Attributes were being lost when the IsCompressed flag was true.
// CopyAttributesToNewIParagraph retains any attribute which have been set
CopyAttributesToNewIParagraph(oldParagraph, _IParagraph);
ProfileTimer.Pop(profileDepth);
}
return _IParagraph;
}
set { _IParagraph = value; }
}
// B2018-034 Attributes were being lost when the IsCompressed flag was true.
// CopyAttributesToNewIParagraph retains any attribute which have been set
private void CopyAttributesToNewIParagraph(Paragraph oldParagraph, Paragraph newParagraph)
{
if (oldParagraph == null) return;
if (oldParagraph.Chunks.Count != newParagraph.Chunks.Count) return;
for (int i = 0; i < oldParagraph.Chunks.Count; i++)
{
System.Collections.Hashtable oldTable = (oldParagraph.Chunks[i] as Chunk).Attributes;
System.Collections.Hashtable newTable = (newParagraph.Chunks[i] as Chunk).Attributes;
if (oldTable.Count == newTable.Count) return;
foreach (System.Collections.DictionaryEntry de in oldTable)
if (!newTable.ContainsKey(de.Key))
newTable.Add(de.Key, de.Value);
}
}
private float _Width;
public float Width
{