This commit is contained in:
parent
f4097b64ed
commit
9dc7aaa9c5
@ -1,441 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using VEPROMS.CSLA.Library;
|
|
||||||
//using Volian.Controls.Library;
|
|
||||||
using iTextSharp.text;
|
|
||||||
using iTextSharp.text.pdf;
|
|
||||||
using iTextSharp.text.factories;
|
|
||||||
using Itenso.Rtf;
|
|
||||||
using Itenso.Rtf.Parser;
|
|
||||||
using Itenso.Rtf.Interpreter;
|
|
||||||
using Itenso.Rtf.Support;
|
|
||||||
//using Volian.Svg.Library;
|
|
||||||
using Volian.Controls.Library;
|
|
||||||
|
|
||||||
namespace Volian.Print.Library
|
|
||||||
{
|
|
||||||
public abstract partial class vlnPrintObject
|
|
||||||
{
|
|
||||||
public static string GetRtf(string text, VE_Font vFont)
|
|
||||||
{
|
|
||||||
StringBuilder rtfSB = new StringBuilder();
|
|
||||||
//DisplayText vlntxt = new DisplayText(text.TrimStart(" ".ToCharArray()), vFont, false);
|
|
||||||
DisplayText vlntxt = new DisplayText(text, vFont, false);
|
|
||||||
rtfSB.Append(AddFontTable(vlntxt.TextFont.WindowsFont));
|
|
||||||
rtfSB.Append(vlntxt.StartText);
|
|
||||||
rtfSB.Append("}");
|
|
||||||
return rtfSB.ToString();
|
|
||||||
}
|
|
||||||
protected static string AddFontTable(System.Drawing.Font font)
|
|
||||||
{
|
|
||||||
StringBuilder rtfSB = new StringBuilder();
|
|
||||||
StringBuilder sbbeg = new StringBuilder();
|
|
||||||
StringBuilder sbend = new StringBuilder();
|
|
||||||
if (font.Bold)
|
|
||||||
{
|
|
||||||
sbbeg.Append(@"\b");
|
|
||||||
sbend.Append(@"\b0");
|
|
||||||
}
|
|
||||||
if (font.Underline)
|
|
||||||
{
|
|
||||||
sbbeg.Append(@"\ul");
|
|
||||||
sbend.Insert(0, @"\ulnone");
|
|
||||||
}
|
|
||||||
if (font.Italic)
|
|
||||||
{
|
|
||||||
sbbeg.Append(@"\i");
|
|
||||||
sbend.Insert(0, @"\i0");
|
|
||||||
}
|
|
||||||
rtfSB.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset2 " + font.FontFamily.Name + @";}"); //}\f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}}";
|
|
||||||
if (!FontIsFixed(font))
|
|
||||||
rtfSB.Append(@"{\f1\fnil\fcharset0 Arial Unicode MS;}}{\colortbl ;\red255\green0\blue0;}");
|
|
||||||
else
|
|
||||||
rtfSB.Append(@"{\f1\fnil\fcharset0 VESymbFix;}}{\colortbl ;\red255\green0\blue0;}");
|
|
||||||
rtfSB.Append("\r\n");
|
|
||||||
// use styles to construct rtf commands to insert into next line (where \b, etc is)
|
|
||||||
rtfSB.Append(@"\viewkind4\uc1\pard\sl-240\slmult0" + sbbeg.ToString() + @"\fs" + Convert.ToInt32(font.SizeInPoints * 2).ToString() + @" "); // \f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}";
|
|
||||||
return rtfSB.ToString();
|
|
||||||
}
|
|
||||||
private static bool FontIsFixed(System.Drawing.Font font)
|
|
||||||
{
|
|
||||||
iTextSharp.text.Font iFont = Rtf2iTextSharp.GetFont(font);
|
|
||||||
float fW = iFont.BaseFont.GetWidthPointKerned("W", 12);
|
|
||||||
float fE = iFont.BaseFont.GetWidthPointKerned("!", 12);
|
|
||||||
return fW == fE;
|
|
||||||
}
|
|
||||||
protected static iTextSharp.text.Paragraph RtfToParagraph(string rtf)
|
|
||||||
{
|
|
||||||
IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtf);
|
|
||||||
Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc);
|
|
||||||
iTextSharp.text.Paragraph para = rtf2IText.Convert();
|
|
||||||
para.SetLeading(_SixLinesPerInch, 0);
|
|
||||||
return para;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public partial class vlnParagraphs : List<vlnParagraph>
|
|
||||||
{
|
|
||||||
public float Add( PdfContentByte cb, ItemInfoList itemInfoList,float xoff,float yoff, float yoffRight, int rnoLevel, int maxRNO, FormatInfo formatInfo)
|
|
||||||
{
|
|
||||||
int? bxIndex = null;
|
|
||||||
foreach (ItemInfo childItemInfo in itemInfoList)
|
|
||||||
{
|
|
||||||
int? bxIndx = childItemInfo.FormatStepData.StepLayoutData.STBoxindex;
|
|
||||||
if (bxIndex != bxIndx)
|
|
||||||
{
|
|
||||||
if(bxIndex == null) // First boxed step
|
|
||||||
yoff += 2 * vlnPrintObject._SixLinesPerInch;
|
|
||||||
else // Change Box Style
|
|
||||||
yoff += 2 * vlnPrintObject._SixLinesPerInch;
|
|
||||||
bxIndex = bxIndx;
|
|
||||||
}
|
|
||||||
if (childItemInfo is SectionInfo) formatInfo = (childItemInfo as SectionInfo).LocalFormat ?? formatInfo;
|
|
||||||
if (rnoLevel < maxRNO && childItemInfo.RNOs != null) yoff = Math.Max(yoff, yoffRight);
|
|
||||||
vlnParagraph para = new vlnParagraph(Parent, cb, childItemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo);
|
|
||||||
Add(para);
|
|
||||||
yoff = para.YBottomMost;
|
|
||||||
}
|
|
||||||
if (bxIndex != null) // End Box Style
|
|
||||||
yoff += 2 * vlnPrintObject._SixLinesPerInch;
|
|
||||||
return yoff;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
public partial class vlnParagraph : vlnPrintObject
|
|
||||||
{
|
|
||||||
private int COL_WID_ADJ = 6; // adjusts for incorrect use of WidSTable when breaking a line (it breaks 6 chars too short)
|
|
||||||
public vlnParagraph(vlnParagraph parent, PdfContentByte cb, ItemInfo itemInfo, float xoff,float yoff, int rnoLevel, int maxRNO, FormatInfo formatInfo)
|
|
||||||
{
|
|
||||||
//int[] problemIDs = { 871, 877 };
|
|
||||||
//List<int> lProblemIDs = new List<int>( problemIDs );
|
|
||||||
//if (lProblemIDs.Contains(itemInfo.ItemID))
|
|
||||||
// Console.WriteLine("Found Item {0}", itemInfo.ItemID);
|
|
||||||
MyParent = parent;
|
|
||||||
MyContentByte = cb;
|
|
||||||
MyItemInfo = itemInfo;
|
|
||||||
XOffset = xoff;
|
|
||||||
YTopMost = YOffset = yoff;
|
|
||||||
vlnTab mytab = null;
|
|
||||||
vlnChangeBar myCB = null;
|
|
||||||
if (itemInfo.MyTab != null && itemInfo.MyTab.Text != null && itemInfo.MyTab.Text != "")
|
|
||||||
{
|
|
||||||
//if (itemInfo.IsHigh)
|
|
||||||
// Console.WriteLine("{0:00},'{1}'", itemInfo.Ordinal, itemInfo.MyTab.Text);
|
|
||||||
//mytab = new vlnTab(cb, itemInfo.MyTab.Text, itemInfo.MyTab.CleanText.TrimStart(" ".ToCharArray()), XOffset, yoff, itemInfo.MyTab.MyFont);
|
|
||||||
mytab = new vlnTab(cb, itemInfo.MyTab.Text, itemInfo.MyTab.CleanText, XOffset, yoff, itemInfo.MyTab.MyFont);
|
|
||||||
PartsLeft.Add(mytab);
|
|
||||||
}
|
|
||||||
AdjustWidth(itemInfo, maxRNO, formatInfo, mytab);
|
|
||||||
AdjustXOffsetForTab(itemInfo, maxRNO, formatInfo, mytab);
|
|
||||||
if (itemInfo.HasChangeBar())
|
|
||||||
{
|
|
||||||
myCB = DoChangeBar(itemInfo, xoff, yoff, maxRNO, formatInfo, myCB);
|
|
||||||
PartsRight.Add(myCB);
|
|
||||||
}
|
|
||||||
if (itemInfo.Cautions != null)
|
|
||||||
{
|
|
||||||
//yoff += 2 * _SixLinesPerInch;
|
|
||||||
yoff = ChildrenAbove.Add(cb, itemInfo.Cautions, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo);
|
|
||||||
//yoff += 2 * _SixLinesPerInch;
|
|
||||||
}
|
|
||||||
if (itemInfo.Notes != null)
|
|
||||||
{
|
|
||||||
//yoff += 2 * _SixLinesPerInch;
|
|
||||||
yoff = ChildrenAbove.Add(cb, itemInfo.Notes, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo);
|
|
||||||
//yoff += 2 * _SixLinesPerInch;
|
|
||||||
}
|
|
||||||
YTop = yoff;
|
|
||||||
if (itemInfo.MyHeader != null && itemInfo.MyHeader.Text != null)
|
|
||||||
// if (itemInfo.MyHeader != null && itemInfo.MyHeader.Text != null && itemInfo.MyHeader.Text != "") // EquipmentWBlank uses an empty string
|
|
||||||
yoff += SetHeader(this, cb, itemInfo, formatInfo);
|
|
||||||
YOffset = yoff;
|
|
||||||
AddMacros(itemInfo, mytab);
|
|
||||||
if (mytab != null) mytab.YOffset = yoff;
|
|
||||||
if (myCB != null) myCB.YOffset = yoff;
|
|
||||||
Rtf = GetRtf(itemInfo);
|
|
||||||
if (itemInfo.IsTablePart)
|
|
||||||
{
|
|
||||||
Width = GetTableWidth(cb, IParagraph);
|
|
||||||
vlnParagraph hls = MyParent;
|
|
||||||
bool aerTable = itemInfo.FormatStepData.Type.Contains("AER");
|
|
||||||
while (hls.MyParent != null)
|
|
||||||
{
|
|
||||||
if (aerTable && hls.MyItemInfo.IsHigh) break;
|
|
||||||
hls = hls.MyParent;
|
|
||||||
}
|
|
||||||
XOffset = hls.XOffset + hls.Width / 2 - Width / 2;
|
|
||||||
if (XOffset < (float)itemInfo.MyDocStyle.Layout.LeftMargin)
|
|
||||||
XOffsetBox = (float)itemInfo.MyDocStyle.Layout.LeftMargin;
|
|
||||||
}
|
|
||||||
//if (MyItemInfo.ItemID == 117)
|
|
||||||
//{
|
|
||||||
// Rtf = Rtf.Replace("3 psig", @"3\'A0psig");
|
|
||||||
// //Console.WriteLine("'{0}'", Rtf);
|
|
||||||
//}
|
|
||||||
if (!itemInfo.IsStepSection) // Don't add any lines for the Section Title
|
|
||||||
{
|
|
||||||
yoff += Height;
|
|
||||||
yoff += AdjustForBlankLines();
|
|
||||||
}
|
|
||||||
float yOffRight = yoff;
|
|
||||||
float RnoOffset = ToPrint(formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColRTable, maxRNO);
|
|
||||||
if (rnoLevel < maxRNO && itemInfo.RNOs != null) yOffRight= ChildrenRight.Add(cb, itemInfo.RNOs, XOffset + RnoOffset, YTop, YTop, rnoLevel + 1, maxRNO, formatInfo);
|
|
||||||
// Need code to determine if the table will overlap the Right Column if it does then
|
|
||||||
// use YOffRight rather than yoff
|
|
||||||
if (itemInfo.Tables != null) yoff = ChildrenBelow.Add(cb, itemInfo.Tables, XOffset, yoff, yOffRight, rnoLevel, maxRNO, formatInfo);
|
|
||||||
// Need code to determine if the step has an RNO and if so use YOffRight rather than yoff
|
|
||||||
if (itemInfo.Steps != null) yoff = ChildrenBelow.Add(cb, itemInfo.Steps, XOffset, yoff, yOffRight, rnoLevel, maxRNO, formatInfo);
|
|
||||||
yoff = Math.Max(yoff, yOffRight);
|
|
||||||
if (itemInfo.Sections != null) yoff = ChildrenBelow.Add(cb, itemInfo.Sections, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo);
|
|
||||||
if (itemInfo.Procedures != null) yoff = ChildrenBelow.Add(cb, itemInfo.Procedures, xoff, yoff, yoff, rnoLevel, maxRNO, formatInfo);
|
|
||||||
if (rnoLevel >= maxRNO && itemInfo.RNOs != null) yoff = ChildrenBelow.Add(cb, itemInfo.RNOs, XOffset, yoff, yoff, rnoLevel + 1, maxRNO, formatInfo);
|
|
||||||
// TODO - use RNOSepAfterAER flag too:
|
|
||||||
//string tmpRnoSepStr = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.RNOSepString;
|
|
||||||
//if (itemInfo.IsRNOPart && rnoLevel == 1 && tmpRnoSepStr != null)
|
|
||||||
//{
|
|
||||||
// float xsep = MyHighLevelParagraph.XOffset + RnoOffset;
|
|
||||||
// vlnRNOSeparator myRnoSep = new vlnRNOSeparator(this, cb, tmpRnoSepStr, xsep, yoff, formatInfo.PlantFormat.FormatData.Font);
|
|
||||||
// PartsBelow.Add(myRnoSep);
|
|
||||||
// yoff += myRnoSep.Height + (2*_SixLinesPerInch); // RNOSeparator has two lines before it, so account for it
|
|
||||||
//}
|
|
||||||
string tmpRnoSepStr = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData.RNOSepString;
|
|
||||||
if (rnoLevel < maxRNO && itemInfo.RNOs != null && tmpRnoSepStr != null)
|
|
||||||
{
|
|
||||||
float xsep = MyHighLevelParagraph.XOffset + RnoOffset;
|
|
||||||
vlnRNOSeparator myRnoSep = new vlnRNOSeparator(this, cb, tmpRnoSepStr, xsep, yoff, formatInfo.PlantFormat.FormatData.Font);
|
|
||||||
PartsBelow.Add(myRnoSep);
|
|
||||||
//if(!MyItemInfo.IsStepSection)
|
|
||||||
yoff += myRnoSep.Height + _SixLinesPerInch;
|
|
||||||
}
|
|
||||||
YBottomMost = yoff;
|
|
||||||
}
|
|
||||||
private float AdjustForBlankLines()
|
|
||||||
{
|
|
||||||
int everyNLines = MyItemInfo.FormatStepData == null ? 1 : MyItemInfo.FormatStepData.StepLayoutData.EveryNLines ?? 1;
|
|
||||||
if(MyItemInfo.Ordinal % everyNLines == 0 || MyItemInfo.NextItem == null)return _SixLinesPerInch;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
private void AddMacros(ItemInfo itemInfo, vlnTab mytab)
|
|
||||||
{
|
|
||||||
float y = YOffset;
|
|
||||||
float x = mytab == null ? XOffset : mytab.XOffset + mytab.TabOffset;
|
|
||||||
List<Macro> myMacros = itemInfo.MyMacros;
|
|
||||||
if (myMacros != null)
|
|
||||||
{
|
|
||||||
foreach (Macro myMacro in myMacros)
|
|
||||||
{
|
|
||||||
PartsLeft.Add(new vlnMacro(x, y, myMacro.MacroDef));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// HLP Change bar flags in format file:
|
|
||||||
//<ChangeBarData ChangeBarMessage="UserId" FixedChangeColumn="88" AbsoluteFixedChangeColumn="True" ContinuousChangeBars="True" ChgBarMessageFromEdit="True" ChangeBarToRNOSep="True" />
|
|
||||||
// Locations: With Text, Outside Box, AER on Left RNO on Right, To The Left of Text
|
|
||||||
// Text: Date & Change ID, Revision Number, Change ID, None, Custom (use input data)
|
|
||||||
// Flag AERChgBarMsgRNOChgBarNoMsg and AERMsgRNONoMsg are NOT Used in 16-bit.
|
|
||||||
private vlnChangeBar DoChangeBar(ItemInfo itemInfo, float xoff, float yoff, int maxRNO, FormatInfo formatInfo, vlnChangeBar myCB)
|
|
||||||
{
|
|
||||||
// find column for the change bar based on format flags - this is code from 16-bit
|
|
||||||
// if AbsoluteFixedChangeColumn
|
|
||||||
// if FixedAERChangeColumn
|
|
||||||
// if col>ColsS+ColR+COL_WID+ADJ
|
|
||||||
// FixedChangeColumn
|
|
||||||
// else
|
|
||||||
// AERLeftChangeBarLocation()
|
|
||||||
// else
|
|
||||||
// FixedChangeColumn
|
|
||||||
// else
|
|
||||||
// ChangeBarLocation()
|
|
||||||
int absFixedAERChgCol = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.FixedAERChangeColumn ?? 0;
|
|
||||||
int fixedChgCol = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.FixedChangeColumn ?? 0;
|
|
||||||
int cols = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS ?? 0;
|
|
||||||
int colr = ToPrint(formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColRTable, maxRNO);
|
|
||||||
float col = (formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.AbsoluteFixedChangeColumn) ?
|
|
||||||
(absFixedAERChgCol>0) ?
|
|
||||||
(xoff > (cols + colr + COL_WID_ADJ)) ?
|
|
||||||
fixedChgCol : AERLeftChangeBarLocation(formatInfo) :
|
|
||||||
fixedChgCol : ChangeBarLocation(xoff, this, formatInfo, maxRNO);
|
|
||||||
|
|
||||||
ProcedureConfig.PrintChangeBar pcb = itemInfo.PrintChangeBar;
|
|
||||||
ProcedureConfig.PrintChangeBarLoc pcbl = itemInfo.PrintChangeBarLoc;
|
|
||||||
ProcedureConfig.PrintChangeBarText pcbt = itemInfo.PrintChangeBarText;
|
|
||||||
string pcbum1 = itemInfo.PrintChangeBarUsrMsg1;
|
|
||||||
string pcbum2 = itemInfo.PrintChangeBarUsrMsg2;
|
|
||||||
// Now get the text.
|
|
||||||
// This is only the User Change Bar Message from the docversion config. Any other data is determined
|
|
||||||
// during printing, i.e. item or page specific.
|
|
||||||
|
|
||||||
//if (cbd.MyChangeBarText == DocVersionConfig.PrintChangeBarText.ChgID || cbd.MyChangeBarText == DocVersionConfig.PrintChangeBarText.DateChgID)
|
|
||||||
//{
|
|
||||||
// cbd.MyChangeBarMessage = myItemInfo.UserID;
|
|
||||||
// string mydts = null;
|
|
||||||
// if (changeBarData.ChgBarMessageFromEdit)
|
|
||||||
// {
|
|
||||||
// StepInfo si = (StepInfo)myItemInfo;
|
|
||||||
// if (si != null)
|
|
||||||
// {
|
|
||||||
// StepConfig sc = si.MyConfig as StepConfig;
|
|
||||||
// if (sc != null && sc.Step_MultipleChangeID != null) cbd.MyChangeBarMessage = sc.Step_MultipleChangeID;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (cbd.MyChangeBarText == DocVersionConfig.PrintChangeBarText.DateChgID) cbd.MyChangeBarMessage = cbd.MyChangeBarMessage + @"\" + myItemInfo.DTS.Date.ToString();
|
|
||||||
//}
|
|
||||||
//else if (cbd.MyChangeBarText == DocVersionConfig.PrintChangeBarText.RevNum)
|
|
||||||
//{
|
|
||||||
// //TODO
|
|
||||||
//}
|
|
||||||
//myCB = new vlnChangeBar(this, XOffset + Width + 5, yoff); // xoff varies depending on type of change bar
|
|
||||||
myCB = new vlnChangeBar(this, (float) itemInfo.MyDocStyle.Layout.LeftMargin+(col*_CharsToTwips), yoff);
|
|
||||||
return myCB;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int ChangeBarLocation(float c, vlnParagraph paragraph, FormatInfo formatInfo, int maxRNO)
|
|
||||||
{
|
|
||||||
int fixedChgCol = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.FixedChangeColumn ?? 0;
|
|
||||||
int cols = formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColS ?? 0;
|
|
||||||
int colr = ToPrint(formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.ColRTable, maxRNO);
|
|
||||||
if (fixedChgCol < -10 || fixedChgCol >= 0)
|
|
||||||
return ((fixedChgCol > 0) ? fixedChgCol :
|
|
||||||
(fixedChgCol == 0) ? (int)c + 1 :
|
|
||||||
(c > cols + colr + COL_WID_ADJ) ? -fixedChgCol :
|
|
||||||
AERLeftChangeBarLocation(formatInfo));
|
|
||||||
else
|
|
||||||
return (fixedChgCol + (((c < cols + Width + colr) || TableTest()
|
|
||||||
|| MyItemInfo.IsCaution || MyItemInfo.IsNote) ? 0 : cols+colr)); // || (GetColumnMode() == 0)) ? 0 : cols + colr));
|
|
||||||
/* Change bars to left of text -- ColS+WidS+ColR is the end of RNO col*/
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
** Centered tables whose width exceeds the end of the RNO column should
|
|
||||||
** still have their change bars printed on the left. This procedure checks
|
|
||||||
** to make sure the step is a table and that it is not an RNO.
|
|
||||||
*/
|
|
||||||
private bool TableTest()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
//return ((s->Type == TABLE || s->Type == BORDERLESSTABLE) &&
|
|
||||||
//!(strchr((char *)&s->dbseq[2],RNO_MARKER)));
|
|
||||||
}
|
|
||||||
private float GetBottomYoff(float bottomY)
|
|
||||||
{
|
|
||||||
foreach (vlnParagraph child in ChildrenBelow)
|
|
||||||
{
|
|
||||||
if (child.YOffset > bottomY) bottomY = child.YOffset;
|
|
||||||
bottomY = child.GetBottomYoff(bottomY);
|
|
||||||
}
|
|
||||||
return bottomY;
|
|
||||||
}
|
|
||||||
private int AERLeftChangeBarLocation(FormatInfo formatInfo)
|
|
||||||
{
|
|
||||||
// use -5 default unless it is format specified
|
|
||||||
int fixedAERChgCol = formatInfo.PlantFormat.FormatData.ProcData.ChangeBarData.FixedAERChangeColumn ?? 0;
|
|
||||||
return (fixedAERChgCol!=0) ?
|
|
||||||
(fixedAERChgCol > 100) ?
|
|
||||||
(fixedAERChgCol % 100) : -fixedAERChgCol : -5;
|
|
||||||
}
|
|
||||||
private StringBuilder _RtfSB = null;
|
|
||||||
|
|
||||||
// return rtf and use for tab and other text
|
|
||||||
public string GetRtf(ItemInfo itemInfo)
|
|
||||||
{
|
|
||||||
_RtfSB = new StringBuilder();
|
|
||||||
DisplayText vlntxt = new DisplayText(itemInfo, E_EditPrintMode.Print, E_ViewMode.View, true, E_FieldToEdit.StepText, false);
|
|
||||||
_RtfSB.Append(AddFontTable(vlntxt.TextFont.WindowsFont));
|
|
||||||
_RtfSB.Append(vlntxt.StartText);
|
|
||||||
_RtfSB.Append("}");
|
|
||||||
return _RtfSB.ToString();
|
|
||||||
|
|
||||||
//if (formatInfo.PlantFormat.FormatData.StepDataList[itemInfo.FormatStepType].Boxed) myParagraph.Parts.Add(new vlnBox(myParagraph));
|
|
||||||
//Console.WriteLine("{0} {1} - {2}, {3}", itemInfo.MyTab.CleanText, itemInfo.MyContent.Text, xoff, yoff);
|
|
||||||
}
|
|
||||||
private float _XOffsetBox = -24;
|
|
||||||
public float XOffsetBox
|
|
||||||
{
|
|
||||||
get { return _XOffsetBox; }
|
|
||||||
set { _XOffsetBox = value; }
|
|
||||||
}
|
|
||||||
private float SetHeader(vlnParagraph para, PdfContentByte cb, ItemInfo itemInfo, FormatInfo formatInfo)
|
|
||||||
{
|
|
||||||
float xoff = (float) itemInfo.MyDocStyle.Layout.LeftMargin;
|
|
||||||
float hdrWidth = (itemInfo.MyHeader.CleanText == null) ? 0 : itemInfo.MyHeader.CleanText.Length * _CharsToTwips; // convert to twips
|
|
||||||
int typ = ((int)itemInfo.MyContent.Type) % 10000;
|
|
||||||
int? bxIndx = formatInfo.PlantFormat.FormatData.StepDataList[typ].StepLayoutData.STBoxindex;
|
|
||||||
if (itemInfo.MyHeader.Justify == System.Drawing.ContentAlignment.MiddleCenter)
|
|
||||||
{
|
|
||||||
if (bxIndx != null)
|
|
||||||
{
|
|
||||||
Box bx = formatInfo.PlantFormat.FormatData.BoxList[(int)bxIndx];
|
|
||||||
if (bx.TabPos > 0)
|
|
||||||
xoff += (float)bx.TabPos; // xoff starts as left margin
|
|
||||||
else
|
|
||||||
{
|
|
||||||
xoff += (float)((bx.TxtStart + XOffsetBox + (bx.TxtWidth / 2)) - (hdrWidth / 2)); // xoff starts as left margin
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.Separator.Location > 0)
|
|
||||||
{
|
|
||||||
// if there is a separator location, use it - 16bit code used the separator location as a divisor:
|
|
||||||
xoff = XOffset + AdjustToCharPosition((float)((para.Width - hdrWidth) / formatInfo.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.Separator.Location));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
xoff = XOffset + (para.Width / 2) + (hdrWidth / 2); // XOffset has left margin included
|
|
||||||
}
|
|
||||||
else
|
|
||||||
xoff = XOffset; // XOffset has left margin included
|
|
||||||
vlnHeader myHeader = new vlnHeader(this, cb, itemInfo.MyHeader.Text, itemInfo.MyHeader.CleanText.TrimStart(" ".ToCharArray()), xoff, YOffset, itemInfo.MyHeader.MyFont, itemInfo.MyHeader.Justify);
|
|
||||||
PartsAbove.Add(myHeader);
|
|
||||||
return myHeader.Height + _SixLinesPerInch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public partial class vlnMacro : vlnPrintObject
|
|
||||||
{
|
|
||||||
public vlnMacro(float xoffset, float yoffset, string macroDef)
|
|
||||||
{
|
|
||||||
YOffset = yoffset;
|
|
||||||
XOffset = xoffset;
|
|
||||||
MacroDef = macroDef;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public partial class vlnTab : vlnPrintObject
|
|
||||||
{
|
|
||||||
public vlnTab(PdfContentByte cb, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont)
|
|
||||||
{
|
|
||||||
MyContentByte = cb;
|
|
||||||
YOffset = yoffset;
|
|
||||||
TabText = cleanTab;
|
|
||||||
Rtf = GetRtf(origTab, vFont);
|
|
||||||
XOffset = xoffset - TabWidth;
|
|
||||||
MyFont = vFont;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public partial class vlnHeader : vlnPrintObject
|
|
||||||
{
|
|
||||||
public vlnHeader(vlnParagraph myParent, PdfContentByte cb, string origStr, string cleanStr, float xoffset, float yoffset, VE_Font vFont, System.Drawing.ContentAlignment ca)
|
|
||||||
{
|
|
||||||
MyParent = myParent;
|
|
||||||
MyContentByte = cb;
|
|
||||||
YOffset = yoffset;
|
|
||||||
Width = MyParent.Width;
|
|
||||||
HeaderText = cleanStr;
|
|
||||||
Rtf = GetRtf(origStr, vFont);
|
|
||||||
XOffset = xoffset;
|
|
||||||
MyFont = vFont;
|
|
||||||
ContentAlignment = ca;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public partial class vlnRNOSeparator : vlnPrintObject
|
|
||||||
{
|
|
||||||
/* if flag set and separator defined then output separator */
|
|
||||||
/*if separator is a control-A use RNOSepLine*/
|
|
||||||
public vlnRNOSeparator(vlnParagraph parent, PdfContentByte cb, string sepStr, float xoffset, float yoffset, VE_Font vFont)
|
|
||||||
{
|
|
||||||
YOffset = yoffset;
|
|
||||||
XOffset = xoffset;
|
|
||||||
_MyParent = parent;
|
|
||||||
if (sepStr != null)
|
|
||||||
Rtf = GetRtf(sepStr, vFont);
|
|
||||||
else
|
|
||||||
Rtf = "--------------------------"; //TODO - What should this be: is this Ctrl-A?
|
|
||||||
MyFont = vFont;
|
|
||||||
Width = sepStr.Length * _CharsToTwips + _WidthAdjust;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,214 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using iTextSharp.text;
|
|
||||||
using iTextSharp.text.pdf;
|
|
||||||
using iTextSharp.text.factories;
|
|
||||||
using Itenso.Rtf;
|
|
||||||
using Itenso.Rtf.Parser;
|
|
||||||
using Itenso.Rtf.Interpreter;
|
|
||||||
using Itenso.Rtf.Support;
|
|
||||||
|
|
||||||
namespace Volian.Print.Library
|
|
||||||
{
|
|
||||||
public abstract partial class vlnPrintObject
|
|
||||||
{
|
|
||||||
public abstract float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin);
|
|
||||||
}
|
|
||||||
public partial class vlnPrintObjects : List<vlnPrintObject>
|
|
||||||
{
|
|
||||||
public float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
|
||||||
{
|
|
||||||
foreach (vlnPrintObject part in this)
|
|
||||||
{
|
|
||||||
yPageStart = part.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
|
||||||
}
|
|
||||||
return yPageStart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public partial class vlnParagraphs : List<vlnParagraph>
|
|
||||||
{
|
|
||||||
public float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
|
||||||
{
|
|
||||||
foreach (vlnParagraph child in this)
|
|
||||||
{
|
|
||||||
yPageStart = child.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
|
||||||
}
|
|
||||||
return yPageStart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public partial class vlnParagraph : vlnPrintObject
|
|
||||||
{
|
|
||||||
public float ParagraphToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
|
||||||
{
|
|
||||||
//Console.WriteLine("'{0}',{1},{2},{3},{4},{5},{6},{7},{8}", MyItemInfo.Path.Substring(_Prefix.Length).Trim(),
|
|
||||||
// cb.PdfWriter.CurrentPageNumber, yStart, YTop, yStart + YTop, yStart + YTop - _LastY, YTopMost, YSize, yPageStart);
|
|
||||||
//_LastY = yStart + YTop;
|
|
||||||
// 72 points per inchs. 504 is 7 inches wide. 3 1/2 inches wide: 252, 100);
|
|
||||||
if (_PartsAbove != null && _PartsAbove.Count > 0) yPageStart = PartsAbove.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
|
||||||
float yLocation = yPageStart - YOffset;
|
|
||||||
float retval = yLocation;
|
|
||||||
if (!MyItemInfo.IsStepSection) // Don't ouput the Step Section title
|
|
||||||
{
|
|
||||||
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, PdfDebugText);
|
|
||||||
if (retval == 0)
|
|
||||||
{
|
|
||||||
cb.PdfDocument.NewPage();
|
|
||||||
yPageStart = yTopMargin + YTop;
|
|
||||||
yLocation = yPageStart - YOffset;
|
|
||||||
//MyItemInfo.ItemID, YSize, yPageSize, yLocation
|
|
||||||
Console.WriteLine("-1,'Yes','Forced Pagination',{0},{1},,{3},'{4}'", MyItemInfo.ItemID,YSize,0,yLocation,MyItemInfo.ShortPath);
|
|
||||||
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, PdfDebugText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Height = yLocation - retval;
|
|
||||||
if (_PartsLeft != null && _PartsLeft.Count > 0) yPageStart = PartsLeft.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
|
||||||
if (_PartsRight != null && _PartsRight.Count > 0) yPageStart = PartsRight.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
|
||||||
if (_PartsBelow != null && _PartsBelow.Count > 0) yPageStart = PartsBelow.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
|
||||||
if (_PartsContainer != null && _PartsContainer.Count > 0) yPageStart = PartsContainer.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
|
||||||
return yPageStart;
|
|
||||||
}
|
|
||||||
private string PdfDebugText
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return string.Format("ID={0} Type={1} TypeName='{2}' EveryNLines= {3}", MyItemInfo.ItemID, MyItemInfo.FormatStepType, MyItemInfo.FormatStepData.Type, MyItemInfo.FormatStepData.StepLayoutData.EveryNLines);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
|
||||||
{
|
|
||||||
float yLocation = yPageStart - YTopMost;
|
|
||||||
int paginate = Paginate(yLocation, yTopMargin, yBottomMargin);
|
|
||||||
switch (paginate)
|
|
||||||
{
|
|
||||||
case 1: // Break on High Level Step
|
|
||||||
cb.PdfDocument.NewPage();
|
|
||||||
yPageStart = yTopMargin + YTopMost;
|
|
||||||
break;
|
|
||||||
case 2: // Break within a Step
|
|
||||||
cb.PdfDocument.NewPage();
|
|
||||||
yPageStart = yTopMargin + YTopMost - 2 * _SixLinesPerInch;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
yPageStart = ChildrenAbove.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
|
||||||
yPageStart = ChildrenLeft.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
|
||||||
yPageStart = ParagraphToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
|
||||||
yPageStart = ChildrenRight.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
|
||||||
yPageStart = ChildrenBelow.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
|
||||||
return yPageStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int Paginate(float yLocation, float yTopMargin, float yBottomMargin)
|
|
||||||
{
|
|
||||||
float yPageSize = yTopMargin - yBottomMargin;
|
|
||||||
float yWithinMargins = yLocation - yBottomMargin;
|
|
||||||
if (MyItemInfo.ItemID == 879)
|
|
||||||
Console.Write(",'Here'");
|
|
||||||
if (MyItemInfo.IsStepSection) return 0; // Don't Paginate on a Step Section
|
|
||||||
if (YSize <= yWithinMargins)
|
|
||||||
{
|
|
||||||
if(MyItemInfo.IsHigh)
|
|
||||||
Console.WriteLine("1,'No','HLS will fit on page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
|
||||||
return 0; // Don't Paginate if there is enough room
|
|
||||||
}
|
|
||||||
if (MyItemInfo.IsRNOPart && MyParent.XOffset < XOffset) return 0; // Don't paginate on an RNO to the right
|
|
||||||
if (MyItemInfo.IsHigh)
|
|
||||||
{
|
|
||||||
if (YSize < yPageSize) // if the entire step can fit on one page, do a page break
|
|
||||||
{
|
|
||||||
Console.WriteLine("2,'Yes','HLS will fit on 1 Page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
|
||||||
return 1; // Paginate on High Level Steps
|
|
||||||
}
|
|
||||||
else // The entire step cannot fit go ahead and kick to the next page
|
|
||||||
{
|
|
||||||
if (yWithinMargins > yPageSize / 2)
|
|
||||||
{
|
|
||||||
// If High level Step will not fit, kick to the next page
|
|
||||||
Console.WriteLine("3,'No','HLS will have to split anyway',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
|
||||||
return 0;// Otherwise stay on this page
|
|
||||||
}
|
|
||||||
Console.WriteLine("3,'Yes','HLS will have to split',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
|
||||||
return 1; // Paginate on High Level Steps
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (yWithinMargins > yPageSize / 4)
|
|
||||||
{
|
|
||||||
Console.WriteLine("4,'No','Not Half way down the page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
|
||||||
return 0; // More than half way down the page
|
|
||||||
}
|
|
||||||
//if (ChildrenBelow.Count > 0 && ChildrenBelow[0].YSize < yWithinMargins)
|
|
||||||
// return 0;
|
|
||||||
Console.WriteLine("5,'Yes','At least half the page is filled',{0},{1},{2},{3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public partial class vlnHeader : vlnPrintObject
|
|
||||||
{
|
|
||||||
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
|
||||||
{
|
|
||||||
float yLocation = yPageStart - YOffset;
|
|
||||||
Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, HeaderWidth, 100,"");
|
|
||||||
return yPageStart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public partial class vlnTab : vlnPrintObject
|
|
||||||
{
|
|
||||||
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
|
||||||
{
|
|
||||||
float yLocation = yPageStart - YOffset;
|
|
||||||
Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, TabWidth, 100, "");
|
|
||||||
return yPageStart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public partial class vlnBox : vlnPrintObject
|
|
||||||
{
|
|
||||||
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
|
||||||
{
|
|
||||||
return yPageStart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public partial class vlnChangeBar : vlnPrintObject
|
|
||||||
{
|
|
||||||
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
|
||||||
{
|
|
||||||
float yLocation = yPageStart - YOffset;
|
|
||||||
float yAdj = 3;
|
|
||||||
cb.SaveState();
|
|
||||||
cb.SetColorStroke(Color.GREEN);
|
|
||||||
cb.SetLineWidth(1);
|
|
||||||
cb.MoveTo(XOffset, yLocation-yAdj); // combination yStart and YOffset
|
|
||||||
cb.LineTo(XOffset, yLocation - MyParent.Height-yAdj);
|
|
||||||
cb.Stroke();
|
|
||||||
cb.RestoreState();
|
|
||||||
return yPageStart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public partial class vlnRNOSeparator : vlnPrintObject
|
|
||||||
{
|
|
||||||
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
|
||||||
{
|
|
||||||
float yLocation = yPageStart - YOffset;
|
|
||||||
Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, "");
|
|
||||||
return yPageStart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public partial class vlnMacro : vlnPrintObject
|
|
||||||
{
|
|
||||||
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
|
||||||
{
|
|
||||||
float yLocation = yPageStart - YOffset;
|
|
||||||
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
|
|
||||||
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
|
|
||||||
if (textLayer != null) cb.BeginLayer(textLayer);
|
|
||||||
MyContentByte = cb;
|
|
||||||
System.Drawing.Color push = PrintOverride.SvgColor;
|
|
||||||
PrintOverride.SvgColor = PrintOverride.TextColor == System.Drawing.Color.Empty ? System.Drawing.Color.Black : PrintOverride.TextColor ;
|
|
||||||
if (MyPageHelper != null && MyPageHelper.MySvg != null)
|
|
||||||
MyPageHelper.MySvg.DrawMacro(MacroDef, XOffset, yLocation, cb);
|
|
||||||
PrintOverride.SvgColor = push;
|
|
||||||
if (textLayer != null) cb.EndLayer();
|
|
||||||
return yPageStart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user