Commit for development environment setup

This commit is contained in:
2023-06-19 16:12:33 -04:00
parent be72063a3c
commit bbce2ad0a6
2209 changed files with 1171775 additions and 625 deletions

View File

@@ -0,0 +1,452 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using LBWordLibrary;
using VEPROMS.CSLA.Library;
using System.Text.RegularExpressions;
namespace Volian.Print.Library
{
public class ContinuousActionSummary : IDisposable
{
private LBApplicationClass _WordApp;
private LBDocumentClass _WordDoc;
private LBSelection _WordSel;
private LBTable _WordTbl;
private const string TheQuickBrownFox = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.";
private VE_Font _pkFont;
public ContinuousActionSummary()
{
_WordApp = new LBApplicationClass();
_WordDoc = _WordApp.Documents.Add();
_WordSel = _WordApp.Selection;
_pkFont = new VE_Font("Arial", 11, E_Style.None, 12); // copied from Calvert Placekeepers.
}
public void Visible()
{
_WordApp.Visible = true;
_WordApp.Activate();
}
public ContinuousActionSummary(pkParagraphs myContActSteps, VE_Font pkFont)
{
_WordApp = new LBApplicationClass();
_WordDoc = _WordApp.Documents.Add();
_WordSel = _WordApp.Selection;
//_WordApp.Visible = true;
_pkFont = pkFont;
AddTable();
AddHeader();
foreach (pkParagraph myContAct in myContActSteps)
{
if (myContAct.MyChildren.Count > 0) // only print the section title if it has Continuous Action Steps
AddSectionHeader(myContAct.MyParagraph.MyItemInfo.DisplayNumber, myContAct.MyParagraph.MyItemInfo.FormattedDisplayText);
foreach (pkParagraph pgh in myContAct.MyChildren) // within each section...
{
// start Continuous Action text table cell
//StartSubStep();
foreach (pkParagraph pghC in pgh.MyCautionsAndNotes) // this is a high level step with cautions and/or notes
{
StepConfig sc = pghC.MyParagraph.MyItemInfo.MyConfig as StepConfig;
string doneStr = "";
//string NoteCautionTab = string.Format("{0} NOTE: ",pghC.MyParagraph.MyParent.MyTab.Text.Trim());
//if (pghC.MyParagraph.MyItemInfo.IsCaution) NoteCautionTab = string.Format("{0} CAUTION: ", pghC.MyParagraph.MyParent.MyTab.Text.Trim());
string NoteCautionTab = string.Format((pghC.MyParagraph.MyItemInfo.IsCaution)?"{0} CAUTION: ":"{0} NOTE: ",pghC.MyParagraph.MyParent.MyTab.Text.Trim());
NoteCautionTab += " ";
AddContinuousAction(NoteCautionTab, GetContActStepText(pghC.MyParagraph.MyItemInfo), doneStr, (pghC.MyParagraph.MyItemInfo.PageNumber+1).ToString());
//AddCautionOrNote(NoteCautionTab, pghC.MyParagraph.MyItemInfo.FormattedDisplayText, doneStr, (pghC.MyParagraph.MyItemInfo.PageNumber+1).ToString());
}
string stpTab = pgh.MyParagraph.MyItemInfo.MyTab.CleanText.Trim() + " "; // this is either the High Level step tab or the sub-step tab
if (pgh.MyParagraph.MyItemInfo.IsNote || pgh.MyParagraph.MyItemInfo.IsCaution) // only the caution and/or note is on the CAS - high level step not selected
{
stpTab = string.Format("{0} ", pgh.MyParagraph.MyParent.MyTab.Text.Trim()) + " " + stpTab;
}
else if (!pgh.MyParagraph.MyItemInfo.IsHigh) // if the high level step was not included, adjust the tab for a sub-step/RNO
{
string tabPre = "";
ItemInfo ii = pgh.MyParagraph.MyItemInfo.MyParent;
if (pgh.MyParagraph.MyItemInfo.IsRNOPart)
{
stpTab = stpTab.TrimEnd() + "[R] ";
ii = ii.MyParent;
}
while (ii != null && !ii.IsSection)
{
tabPre = ii.MyTab.Text.Trim() + " " + tabPre;
ii = ii.MyParent;
}
stpTab = tabPre + stpTab;
}
AddContinuousAction(stpTab, GetContActStepText(pgh.MyParagraph.MyItemInfo), "", (pgh.MyParagraph.MyItemInfo.PageNumber + 1).ToString());
//AddHighLevelStep(stpTab, pgh.MyParagraph.MyItemInfo.FormattedDisplayText, "", (pgh.MyParagraph.MyItemInfo.PageNumber + 1).ToString());
//AddHighLevelStep(pgh.MyParagraph.MyItemInfo.MyTab.CleanText, pgh.MyParagraph.MyItemInfo.FormattedDisplayText, "", (pgh.MyParagraph.MyItemInfo.PageNumber + 1).ToString());
if (pgh.MyChildren.Count > 0) // process the sub-steps under this parent
{
//StartSubStep();
AddChildren(pgh, 1);
//FinishSubstep("", "");
}
}
}
RepeatHeader();
}
private void AddChildren(pkParagraph pgh, int level)
//private void AddChildren(pkParagraph pgh, int level, ref bool conAct)
{
foreach (pkParagraph cpgh in pgh.MyChildren)
{
if (cpgh.MyCautionsAndNotes.Count > 0)
AddNotesOrCautions(cpgh,level);
//AddNotesOrCautions(cpgh,level, ref conAct);
//if (!conAct)
// conAct = IsContinuousActionPlacekeeper(conAct, cpgh);
//ContinueSubStep(cpgh.MyParagraph.MyItemInfo.FormattedDisplayText, level);
string stpTab = cpgh.MyParagraph.MyItemInfo.MyTab.CleanText.Trim() + " ";
if (cpgh.MyParagraph.MyItemInfo.IsNote || cpgh.MyParagraph.MyItemInfo.IsCaution)
{
stpTab = string.Format("{0} ", cpgh.MyParagraph.MyParent.MyTab.Text.Trim()) + " " + stpTab;
}
//else if (!cpgh.MyParagraph.MyItemInfo.IsHigh)
//{
// string tabPre = "";
// ItemInfo ii = cpgh.MyParagraph.MyItemInfo.MyParent;
// while (ii != null && !ii.IsSection && !ii.IsHigh)
// {
// tabPre = ii.MyTab.Text.Trim() + " " + tabPre;
// ii = ii.MyParent;
// }
// stpTab = tabPre + stpTab;
//}
AddContinuousAction(stpTab, GetContActStepText(cpgh.MyParagraph.MyItemInfo), "", (cpgh.MyParagraph.MyItemInfo.PageNumber + 1).ToString());
AddChildren(cpgh, level + 1);
//AddChildren(cpgh, level+1, ref conAct);
}
}
private string GetContActStepText(ItemInfo myItemInfo)
{
string conActSumText = "";
StepConfig sc = myItemInfo.MyConfig as StepConfig;
if (sc != null && sc.Step_AlternateContActSumText != null)
conActSumText = sc.Step_AlternateContActSumText;
if (conActSumText == "")
conActSumText = myItemInfo.FormattedDisplayText;
return conActSumText;
}
private void AddNotesOrCautions(pkParagraph pgh, int level)
//private void AddNotesOrCautions(pkParagraph pgh, int level, ref bool conAct)
{
foreach (pkParagraph cpgh in pgh.MyCautionsAndNotes)
{
//if (!conAct)
// conAct = IsContinuousActionPlacekeeper(conAct, cpgh);
//ContinueNoteOrCaution(cpgh.MyParagraph.MyItemInfo, level);
string doneStr = "";
string NoteCautionTab = string.Format("{0} NOTE: ", cpgh.MyParagraph.MyParent.MyTab.Text);
if (cpgh.MyParagraph.MyItemInfo.IsCaution) NoteCautionTab = string.Format("{0} CAUTION: ", cpgh.MyParagraph.MyParent.MyTab.Text);
AddContinuousAction(NoteCautionTab, GetContActStepText(cpgh.MyParagraph.MyItemInfo), doneStr, (cpgh.MyParagraph.MyItemInfo.PageNumber + 1).ToString());
}
}
//private static bool IsContinuousActionPlacekeeper(bool conAct, pkParagraph pkPar)
//{
// StepConfig sc = pkPar.MyParagraph.MyItemInfo.MyConfig as StepConfig;
// conAct = (sc.Step_Placekeeper.ToUpper() == "C");
// return conAct;
//}
private void ContinueNoteOrCaution(ItemInfo ii, int level)
{
string NoteCautionTab = "NOTE: ";
if (ii.IsCaution) NoteCautionTab = "CAUTION: ";
if (!_FirstLine) _WordSel.TypeParagraph();
_FirstLine = false;
SetIndent(.33F + (.31F * level), -.31F);
WriteCell(NoteCautionTab + ii.FormattedDisplayText, false, false);
}
//public void BuildSample()
//{
// _WordSel.TypeText("Placekeeper");
// _WordSel.TypeParagraph();
// _WordApp.Visible = true;
// AddTable();
// AddHeader();
// AddSectionHeader("Section VI", "Title for section VI");
// AddHighLevelStep("A.", TheQuickBrownFox, "C", "5");
// AddSubStep(TheQuickBrownFox, "C", "");
// AddCautionOrNote("NOTE:", "The Note text has a hanging indent on all but the first line of text", "", "");
// AddHighLevelStep("B.", TheQuickBrownFox, "C", "7");
// StartSubStep();
// ContinueSubStep(TheQuickBrownFox, 1);
// ContinueSubStep(TheQuickBrownFox, 2);
// ContinueSubStep(TheQuickBrownFox, 2);
// ContinueSubStep(TheQuickBrownFox, 3);
// ContinueSubStep(TheQuickBrownFox, 3);
// ContinueSubStep(TheQuickBrownFox, 2);
// ContinueSubStep(TheQuickBrownFox, 1);
// FinishSubstep("", "");
// AddHighLevelStep("C.", TheQuickBrownFox, "C", "8");
// StartSubStep();
// ContinueSubStep(TheQuickBrownFox, 1);
// ContinueSubStep(TheQuickBrownFox, 2);
// ContinueSubStep(TheQuickBrownFox, 2);
// ContinueSubStep(TheQuickBrownFox, 3);
// ContinueSubStep(TheQuickBrownFox, 3);
// ContinueSubStep(TheQuickBrownFox, 2);
// ContinueSubStep(TheQuickBrownFox, 1);
// FinishSubstep("", "");
// RepeatHeader();
//}
private void RepeatHeader()
{
_WordTbl.Rows.First.Select();
_WordSel.Rows.HeadingFormat = -1;
}
private bool _FirstSection = true;
private void AddTable()
{
_FirstSection = true;
_WordTbl = _WordDoc.Tables.Add(_WordSel.Range, 1, 4, 1, 0);
_WordTbl.TopPadding = 6F;
_WordTbl.BottomPadding = 6F;
LBColumn col = _WordTbl.Columns.First;
//col.SetWidth(12F, LBWdRulerStyle.wdAdjustNone);
//col = col.Next;
col.SetWidth(72 * .91F, LBWdRulerStyle.wdAdjustNone);
col = col.Next;
col.SetWidth(72 * 4.1F, LBWdRulerStyle.wdAdjustNone);
col = col.Next;
//col.SetWidth(72 * .81F, LBWdRulerStyle.wdAdjustNone);
col.SetWidth(72 * .76F, LBWdRulerStyle.wdAdjustNone);
col = col.Next;
//col.SetWidth(72 * .81F, LBWdRulerStyle.wdAdjustNone);
col.SetWidth(72 * .76F, LBWdRulerStyle.wdAdjustNone);
_WordTbl.Rows.AllowBreakAcrossPages = 0;
}
private void AddHeader()
{
//Advance();
WriteCell("START", true, true);
//SetIndent(0.32F, -0F);
WriteCell("STEP CONTINUOUS ACTION", true, true);
WriteCell("DONE", true, true);
WriteCell("PAGE", true, false);
}
private void AddSectionHeader(string number, string title)
{
if (!_FirstSection)
{
Advance(5);
_WordSel.MoveLeft(LBWdUnits.wdCell, 1, false);
_WordSel.SelectRow();
_WordSel.Cells.Merge();
}
_FirstSection = false;
Advance(2);
SetIndent(0, 0);
WriteCell("SECTION " + number, true, false);
WriteCell(" " + title, false, true);
Advance();
}
private float GetTextWidth(string txt)
{
System.Drawing.Font font = new System.Drawing.Font(_pkFont.Family, (float)_pkFont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
float w = 0;
foreach (char c in txt)
{
w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)_pkFont.Size);
}
// indented text didn't always line up doing it this way
//float w = iFont.BaseFont.GetWidthPointKerned(txt, (float)_pkFont.Size);
return w;
}
private void AddHighLevelStep(string number, string text, string done, string page)
{
//// if the text contains prerequisite steps,
//// parse out the step numbers and place them in the first column
//if (text.Contains(@"\{Prerequisite Step: "))
//{
// string prereqToken = @"\{Prerequisite Step: ";
// string preqStp = "";
// int idx = text.IndexOf(prereqToken);
// while (idx >= 0)
// {
// int parseStart = idx+prereqToken.Length;
// int endx = text.IndexOf(@"\}",parseStart);
// int parseLen = endx - parseStart;
// preqStp += "("+text.Substring(parseStart, parseLen) + "), ";
// text = text.Remove(idx, endx+2 - idx);
// idx = text.IndexOf(prereqToken);
// }
// Advance(1);
// preqStp = preqStp.Substring(0, preqStp.Length - 2); // remove ending ", "
// WriteCell(preqStp, false, true);
//}
//else
Advance(2);
if (text.Contains("\x05")) // hanging indent character
{
string[] parts = text.Split("\x05".ToCharArray());
float ind = (GetTextWidth(number) + GetTextWidth(parts[0])) / 72f;
SetIndent(ind, -ind);
WriteCell(number + parts[0] + parts[1], false, true);
}
else
{
SetIndent(.33F, -.33F);
WriteCell(number + text, false, true);
}
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(done, false, true);
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(page, false, false);
}
private void AddSubStep(string text, string done, string page)
{
Advance(2);
//SetIndent(.64F, -.31F);
//_WordSel.InsertSymbol(8226, _WordSel.Font, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
//WriteCell("\u2022" + "\t" + text, false, true); // this will print out a bullet and a tab
WriteCell(text, false, true);
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(done, false, true);
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(page, false, false);
}
private bool _FirstLine = false;
private void StartSubStep()
{
_FirstLine = true;
Advance(2);
SetIndent(.64F, -.31F);
}
private void ContinueSubStep(string text, int level)
{
if(!_FirstLine) _WordSel.TypeParagraph();
_FirstLine = false;
SetIndent(.33F + (.31F * level), -.31F);
//WriteCell("\u2022" + "\t" + text, false, false); // this will print out a bullet and a tab
WriteCell(text, false, false);
}
private void FinishSubstep(string done, string page)
{
Advance();
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(done, false, true);
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(page, false, false);
}
private void AddCautionOrNote(string type, string text, string done, string page)
{
Advance(2);
SetIndent(.33F, -.33F);
WriteCell(type, true, false);
WriteCell(" " + text, false, true);
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(done, false, true);
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(page, false, false);
}
private void AddContinuousAction(string number, string text, string done, string page)
{
Advance(2);
//SetIndent(.33F, -.33F);
//WriteCell(type, true, false);
//WriteCell(" " + text, false, true);
if (text.Contains("\x05")) // hanging indent character
{
string[] parts = text.Split("\x05".ToCharArray());
float ind = (GetTextWidth(number) + GetTextWidth(parts[0])) / 72f;
SetIndent(ind, -ind);
WriteCell(number + parts[0] + parts[1], false, true);
}
else
{
SetIndent(.33F, -.33F);
WriteCell(number + text, false, true);
}
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(done, false, true);
SetAlignment(LBWdParagraphAlignment.wdAlignParagraphCenter, LBWdCellVerticalAlignment.wdCellAlignVerticalBottom);
WriteCell(page, false, false);
}
static Regex rgx = new Regex(@"\\(b|ul|up[1-9]|dn0|up0|dn[1-9]|b0|ulnone)( |$|(?=\\))");
private void WriteRTF(string text)
{
//if (text.Contains("\\"))
// Console.WriteLine("here");
Match m = rgx.Match(text);
while (m.Success)
{
if (m.Index > 0)
_WordSel.TypeText(text.Substring(0,m.Index));
switch (m.Groups[1].Value)
{
case "b": // bold on
_WordSel.Font.Bold = 1;
break;
case "b0": // bold off
_WordSel.Font.Bold = 0;
break;
case "ul": // underline on
_WordSel.Font.Underline = LBWdUnderline.wdUnderlineSingle;
break;
case "ulnone": // underline off
_WordSel.Font.Underline = LBWdUnderline.wdUnderlineNone;
break;
case "dn0": // superscript off
_WordSel.Font.Superscript = 0;
break;
case "up0": // subscript off
_WordSel.Font.Subscript = 0;
break;
default:
if (m.Groups[1].Value.StartsWith("dn"))// subscript on
_WordSel.Font.Subscript = 1;
else // superscript on
_WordSel.Font.Superscript = 1;
break;
}
text = text.Substring(m.Index+m.Length);
m = rgx.Match(text);
}
_WordSel.TypeText(text);
}
private void WriteCell(string text, bool bold, bool advance)
{
_WordSel.Font.Name = _pkFont.Family;//"Arial";
_WordSel.Font.Bold = bold ? 1 : 0;
//_WordSel.TypeText(text);
WriteRTF(text);
if (advance) Advance();
}
private void SetIndent(float left, float first)
{
_WordSel.ParagraphFormat.LeftIndent = left * 72;
_WordSel.ParagraphFormat.FirstLineIndent = first * 72;
}
private void SetAlignment(LBWdParagraphAlignment hAlign, LBWdCellVerticalAlignment vAlign)
{
_WordSel.ParagraphFormat.Alignment = hAlign;
_WordSel.Cells.VerticalAlignment = vAlign;
}
private void Advance(int count)
{
_WordSel.MoveRight(LBWdUnits.wdCell, count, false);
}
private void Advance()
{
Advance(1);
}
public void Dispose()
{
_WordApp.Quit(false);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,443 @@
using System;
using System.Collections.Generic;
using System.Text;
using VEPROMS.CSLA.Library;
using Volian.Base.Library;
using iTextSharp.text.pdf;
using Volian.Svg.Library;
namespace Volian.Print.Library
{
public partial class vlnParagraph
{
/// <summary>
/// This variable is used to match 16 bit pagination
/// </summary>
private bool _Match16BitPagination = false;
/// <summary>
/// Dtermines if the current step is preceded by a Page Break
/// </summary>
/// <param name="yLocation"></param>
/// <param name="yTopMargin"></param>
/// <param name="yBottomMargin"></param>
/// <returns>
/// 0 - No page break
/// 1 - Break on High Level Step
/// 2 - Break within a Step
/// 3 - Break on High Level Step (SevenLinesPerInch)
/// </returns>
private int Paginate(float yLocation, float yTopMargin, float yBottomMargin)
{
float yPageSize = yTopMargin - yBottomMargin;
// TODO: This does not account for a long step as the last step that would exceed more than one page and
// that has an end message that needs to be accounted for in determining pagination. To do that the last
// child should be the only paragraph that accounts for the End message.
//
// If last step & there should be an end message, pagination tests need to account for the 3 lines the end
// message uses. The 3 is for a line above, the end message line & the line below (in case there is a border/box line).
// The 3 was changed to 2 for the end line & the line below. The blank line below the step gives the blank
// line above the end message, thus 2 not 3. This change was made on July 20, 2011 by RHM & KBR. The
// procedure in questions was VEWCNEMG\EMGAPP.PRC, ES-01, Step 8.
bool ManualPageBreak = false;
float yEndMsg = !MyItemInfo.IsSection && MyItemInfo.MyHLS.NextItem == null && (MyItemInfo.MyDocStyle.End.Message ?? "") != "" ? 2 * SixLinesPerInch : 0;
float yWithinMargins = CalculateYLocation(yLocation, yTopMargin) - yBottomMargin; // -SixLinesPerInch;
bool isFirstChild = MyItemInfo.MyPrevious == null;
bool nearTheTop = (yWithinMargins < yPageSize) && (yWithinMargins > (yPageSize - 5 * SixLinesPerInch));
// if step is breaking over a number of pages, determine if the current step is the
// location of a pagebreak.
if (MyPageHelper.ParaBreaks.Count > 0)
{
if (this == MyPageHelper.ParaBreaks[0] || this.YTopMost > MyPageHelper.ParaBreaks[0].YTopMost)
{
MyPageHelper.ParaBreaks.RemoveAt(0);
//Console.WriteLine("'PageBreak',6,'Yes','Page Break within Step',{0},{1},{2},{3}, {4},'{5}'", MyItemInfo.ItemID, YSize, 0, 0, 0, MyItemInfo.ShortPath);
//Console.WriteLine("Prev = {0}", MyItemInfo.MyPrevious==null ? "''" : MyItemInfo.DBSequence);
ShowPageBreak(1, "Page Break within Step", "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
return 2; // break on this item within a step
}
return 0; // this is not an item with a break
}
float mySize = YSize * MyPageHelper.YMultiplier;
vlnParagraph firstChild = ChildrenBelow.Count > 0 ? ChildrenBelow[0] : null;
// Steps that have the smart template (the WCNCKL format for example), always include two children.
if (MyItemInfo.IsHigh && MyItemInfo.FormatStepData.UseSmartTemplate && ChildrenBelow.Count > 1)
firstChild = ChildrenBelow[1];
if (firstChild != null && !firstChild.MyItemInfo.IsNumbered) // If not numbered get the last child
firstChild = firstChild.MyParent.ChildrenBelow[firstChild.MyParent.ChildrenBelow.Count - 1];
float ySizeIncludingFirst = firstChild == null ? YSize : firstChild.YSize + (firstChild.YTopMost - YTopMost);
bool KeepStepsOnPage = MyItemInfo.ActiveFormat.MyStepSectionLayoutData.KeepStepsOnPage;
if (MyItemInfo.IsStepSection)
{
if (yLocation < yTopMargin) // continuous section
{
if (ChildrenBelow == null || ChildrenBelow.Count == 0)
{
// see if there is an end message. This is stored in the helper - if there is,
// we need to be sure that there is room for it.
if (MyPageHelper.BottomMessage != null)
{
if (mySize + yEndMsg <= yWithinMargins) return 1;
}
return 0;
}
// This is a continuous section. There may be cases where the user put a manual page
// break on the first step (child) in the section. if so, break on the section. The
// flag SectionPageBreak is set to true to flag that a pagebreak should not be done
// on that first step.
StepConfig sc = firstChild.MyItemInfo.MyConfig as StepConfig;
ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc == null ? false : sc.Step_ManualPagebreak) :
sc == null ? false : sc.Step_NewManualPagebreak;
if (ManualPageBreak)
{
SectionPageBreak = true;
ShowPageBreak(2, "Section Page Break", "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
return 1;
}
// can the title and the first step fit?
// add the first child's size + (the section title's size)
//if (ySizeIncludingFirst > (yLocation - yBottomMargin - SixLinesPerInch)) return 1;
//if (ySizeIncludingFirst > (yLocation - yBottomMargin) && ySizeIncludingFirst < yPageSize)
vlnParagraph firstStepChild = firstChild;
//while (firstStepChild.MyItemInfo.IsSection && firstStepChild.ChildrenBelow.Count > 0) firstStepChild = firstStepChild.ChildrenBelow[0];
if(firstStepChild.MyItemInfo.IsNumbered)
while (firstStepChild.ChildrenBelow.Count > 0 && (firstStepChild.MyItemInfo.IsSection || firstStepChild.MyItemInfo.IsHigh))
{
firstStepChild = firstStepChild.ChildrenBelow[0];
if (!firstStepChild.MyItemInfo.IsNumbered)
{
firstStepChild = firstStepChild.MyParent.ChildrenBelow[firstStepChild.MyParent.ChildrenBelow.Count-1];
break;
}
}
else
firstStepChild = firstStepChild.MyParent.ChildrenBelow[firstStepChild.MyParent.ChildrenBelow.Count-1];
float ySizeIncludingFirstStep = firstStepChild.YSize + (firstStepChild.YTopMost - YTopMost);
bool firstSubstepExceedsSpaceAvailable = ySizeIncludingFirstStep > yWithinMargins;
if (KeepStepsOnPage && firstSubstepExceedsSpaceAvailable && !isFirstChild)
KeepStepsOnPage = false;
if (!KeepStepsOnPage && ySizeIncludingFirst > (yLocation - yBottomMargin))
{
ShowPageBreak(4, "Page Break Before Continuous Step Section", "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak);
return 1;
}
}
return 0; // Don't Paginate (page break) on a Step Section if it's first thing on page
}
if (!MyItemInfo.IsHigh) return 0; // Don't Paginate on a Substep level
StepConfig sc1 = MyItemInfo.MyConfig as StepConfig;
ManualPageBreak = MyPageHelper.OriginalPageBreak ? (sc1 == null ? false : sc1.Step_ManualPagebreak) :
sc1 == null ? false : sc1.Step_NewManualPagebreak;
if (MyItemInfo.FirstSibling == MyItemInfo && ManualPageBreak)
{
// if parent/section used this pagebreak, skip it.
if (MyParent.SectionPageBreak)
{
ManualPageBreak = false;
MyParent.SectionPageBreak = false;
}
}
if (_Match16BitPagination) mySize = YSize;
float ySize7LPI = YSize; // +SixLinesPerInch;
if (_Match16BitPagination) ySize7LPI += SixLinesPerInch;
string firstStep = "No";
if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null)
firstStep = "Yes";
//if (!ManualPageBreak && mySize + yEndMsg <= yWithinMargins) // Don't Paginate if there is enough room, will fit on page
// Pagination Fix - Break1LineShort1
float yExtra = (yWithinMargins == yPageSize ? 0 : SixLinesPerInch - MyItemInfo.MyDocStyle.Layout.FooterLength) ?? 0;
float yExtra2 = (SixLinesPerInch - MyItemInfo.MyDocStyle.Layout.FooterLength) ?? 0;
if (KeepStepsOnPage && ySizeIncludingFirst > yWithinMargins)
KeepStepsOnPage = false;
bool KeepWithHeader = isFirstChild && nearTheTop;
if (!ManualPageBreak && mySize + yEndMsg <= yWithinMargins + yExtra) // Don't Paginate if there is enough room, will fit on page
//if (!ManualPageBreak && mySize + yEndMsg <= yWithinMargins + SixLinesPerInch) // Don't Paginate if there is enough room, will fit on page
{
//Console.WriteLine("'PageBreak',1,'No','HLS will fit on page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
ShowPageBreak(-1, "HLS will fit on page", firstStep, YSize, yPageSize, yWithinMargins,ManualPageBreak);
return 0;
}
// !MyItemInfo.IsHigh - if (MyItemInfo.IsRNOPart && MyParent.XOffset < XOffset) return 0; // Don't paginate on an RNO to the right
// YSize includes a blank line after the step which we don't want to include in the page break test, thus the
// YSize - SixLinesPerInch:
// yPageSizeNextPage is the page size of the 'next' page. A format variable exists off of the docstyle
// For UseOnFirstPage vs UseOnAllButFirstPage. If this is set for this format, and processing the FIRST
// page, the size of next page, which may be different, is used in pagination calculationstop.
// If this format flag is not set, or not printing the first page of the section with this flag,
// this next page size is the same as current page size.
float yPageSizeNextPage = yPageSize;
//if (firstStep == "No")
// ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin);
if (MyPageHelper.DidFirstPageDocStyle && (MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnAllButFirstPage) > 0)
yPageSizeNextPage = GetYPageSizeUseOnAllButFirstPage();
if (!KeepWithHeader && !KeepStepsOnPage && YSize - SixLinesPerInch + yEndMsg <= yPageSizeNextPage) // if the entire step can fit on one page, do a page break
{
// Don't want extra line before step
//Console.WriteLine("'PageBreak',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);
// A page break will occur before the step is put out. ShowPageBreak with first argument of -1 is NOT a page break.
ShowPageBreak(5, "HLS will fit on 1 Page at 6 LPI", "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
return 1;
}
// TODO - yEndMsg - compressed size?
// ySize7LPI includes a blank line after the step which we don't want to include in the page break test.
else if (!KeepStepsOnPage && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CompressSteps && (ySize7LPI - SixLinesPerInch) < (yPageSizeNextPage * SixLinesPerInch / _SevenLinesPerInch))
{
//Console.WriteLine("'PageBreak',3,'Yes','HLS will fit on 1 Page at 7 LPI',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
ShowPageBreak(7, "HLS will fit on 1 Page at 7 LPI", "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
//Console.WriteLine("'7LPI',{0},{1}", MyItemInfo.DBSequence, YSize);
return 3; // High Level Step can fit at SevenLinesPerInch
}
else // The entire step cannot fit on a blank page or KeepStepsOnPage is true.
{
// if there is more than half a page left, then start to print on the current page
float myFirstPieceSize = GetFirstPieceSize(); //Case 0
if (_Match16BitPagination) myFirstPieceSize += 2 * SixLinesPerInch;
// TODO: Put this line back to case 0, i.e. previous line. This fixes a 16-bit vs 32-bit pagination diff in EO30 Step 20.
//float myFirstPieceSize = GetFirstPieceSize() + 2 * SixLinesPerInch; //Case 10 - this is to match 16bit
//is the amount of space left (yWithinMargins) is greater than 1/2 of the current page (yPageSize / 2):
if (KeepWithHeader ||( !ManualPageBreak && ((MyItemInfo.ActiveFormat.MyStepSectionLayoutData.SpecialPageBreakFlag && yWithinMargins > yPageSize / 2 &&
myFirstPieceSize < yWithinMargins) || KeepStepsOnPage)))
{
//Console.WriteLine("'PageBreak',4,'No','HLS will have to split anyway',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
// yPageSize is space on next page. This may be different if the format flag 'UseOnAllButFirst' is
// set.
// yWithinMargins is space available on current page.
// if the HLS is part of a Smart Template (i.e. WCNCKL table), don't add in an extra line because
// that makes pagination work incorrectly because the Smart Template has a 'table' line after the
// text.
float ySpaceOnFirstPage = yWithinMargins + (MyItemInfo.FormatStepData.UseSmartTemplate ? 0 : SixLinesPerInch);
if (firstStep == "Yes")
{
ySpaceOnFirstPage = yWithinMargins; // Accounts for Section Title Line
ShowPageBreak(8, "First HLS has to split on current page", firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
}
else
ShowPageBreak(6, "HLS will have to split on current page", "Special", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
//BuildPageBreakList(yWithinMargins + SixLinesPerInch, yPageSizeNextPage + yExtra2, KeepStepsOnPage); // Case 5 - Determine items where page break(s) occur
BuildPageBreakList(ySpaceOnFirstPage, yPageSize + yExtra2, KeepStepsOnPage); // Case 5 - Determine items where page break(s) occur
return 0; // Stay on this page
}
// Less than half a page left, start printing on a new page.
//Console.WriteLine("'PageBreak',5,'Yes','HLS will have to split',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
if (firstStep == "Yes")
ShowPageBreak(9, "First HLS will have to split on new page", "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
else
ShowPageBreak(3, "HLS will have to split on new page", "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak);
// Determine items where page break(s) occur
//BuildPageBreakList(yPageSize, yPageSize - 2 * SixLinesPerInch); // Case Base
//BuildPageBreakList(yPageSize, yPageSize); // Case 1 :Works for ES05 Step 15 SubStep 7
// Pagination Fix Break1LineShort2
//BuildPageBreakList(yPageSize + yExtra, yPageSize); // Case 1 :Works for ES05 Step 15 SubStep 7
// Pagination Fix Break1LineShort4
BuildPageBreakList(yPageSize + yExtra, yPageSizeNextPage + yExtra2, KeepStepsOnPage); // Case 1 :Works for ES05 Step 15 SubStep 7
return 1; // Paginate on High Level Steps
}
//if (yWithinMargins > yPageSize / 2)
//{
// Console.WriteLine("'PageBreak',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("'PageBreak',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;
throw new Exception("PageBreak Logic Missing, vlnParagraph.cs");
}
private float GetYPageSizeUseOnAllButFirstPage()
{
float _PointsPerPage = 792;
int indx = (int)MyItemInfo.MyDocStyle.IndexOtherThanFirstPage;
foreach (DocStyle ds in MyItemInfo.ActiveFormat.PlantFormat.DocStyles.DocStyleList)
{
if (ds.Index == indx)
{
float yTopMargin = _PointsPerPage - (float)ds.Layout.TopMargin;
float yBottomMargin = Math.Max(0, yTopMargin - (float)ds.Layout.PageLength);
return yTopMargin - yBottomMargin;
}
}
return 0;
}
private void ForcePagination(PdfContentByte cb, ref float yPageStart, float yTopMargin, float yBottomMargin, ref float yLocation, ref float retval)
{
cb.PdfDocument.NewPage(); // pagination issue
DebugText.WriteLine("*****PaginateError");
yPageStart = yTopMargin + YVeryTop;
yLocation = yPageStart - YOffset;
//MyItemInfo.ItemID, YSize, yPageSize, yLocation
//_MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination - ItemID = {0}\r\nLocation = '{1}'", MyItemInfo.ItemID, MyItemInfo.ShortPath);
_MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination\r\n==>'Forced Pagination',{0},'{1}','{2}'"
, MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath);
DebugPagination.WriteLine("------,'Yes','Forced Pagination',{0},{1},,{3},{4}", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.DBSequence);
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin);
}
private void ShowPageBreak(int instance, string message, string breakOrNot, float YSize, float yPageSize, float yWithinMargins, bool manualPageBreak)
{
if (breakOrNot != "No")
{
// DebugPagination.WriteLine("{0}", MyItemInfo.DBSequence); //,instance);
DebugPagination.WriteLine("{0:D6},'{1}',{2},'{3}','{4}',{5},{6},{7},{8},{9}",
MyPageHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber - (breakOrNot == "Yes" ? 0 : 1),
MyItemInfo.ShortPath, instance,
(manualPageBreak ? "Manual " : "") + message, breakOrNot,
MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize));
}
// Console.WriteLine("{0},{1}", MyItemInfo.DBSequence, IsFirstSubStep(MyItemInfo)); //,instance);
}
private void BuildPageBreakList(float ySpaceOnCurPage, float yPageSize, bool KeepStepsOnPage)
{
ParagraphLocations myLocations = new ParagraphLocations();
BuildLocationList(YTopMost, myLocations);
StepLevelList myList = myLocations.BuildStepLevelList(KeepStepsOnPage);
// Find Break Locations in the list based upon StepLevel and yLocation
float yTop = 0;
float yLowerLimit = (yPageSize - 2 * SixLinesPerInch) / 2;
float yStart = Math.Max(0, (yPageSize - 2 * SixLinesPerInch) - ySpaceOnCurPage);
//Console.WriteLine("'yStart',{0},{1}", MyItemInfo.DBSequence, yStart);
// The following three lines make page breaking match 16-bit:
if (_Match16BitPagination)
{
yLowerLimit = yStart - SixLinesPerInch + ySpaceOnCurPage / 2;
if ((yStart + MyItemInfo.MyDocStyle.Layout.TopMargin + 2 * SixLinesPerInch) > ((MyItemInfo.MyDocStyle.Layout.TopMargin + yPageSize - 2 * SixLinesPerInch) / 2))
yLowerLimit = yStart + 2 * SixLinesPerInch;
}
// Make sure that the FirstPiece (Caution Note HLS and First Substeps) fit
float myFirstPieceSize = GetFirstPieceSize(); //Case 0
if (myFirstPieceSize < ySpaceOnCurPage) yLowerLimit = Math.Max(myFirstPieceSize + yStart, yLowerLimit);
//while ((YSize - yTop) >= ySpaceOnCurPage)
// Pagination Fix Break1LineShort3b
DocStyle docstyle = MyItemInfo.MyDocStyle;
string myBottomMsg = docstyle.Continue.Bottom.Message;
float myBottomMsgSpace = ((myBottomMsg ?? "") != "") ? 2 * SixLinesPerInch : 0;
switch (docstyle.Continue.Bottom.Location)
{
case E_ContBottomLoc.BottomOfPage: // place continue message at bottom of page
myBottomMsgSpace = 0;
break;
}
string myTopMsg = docstyle.Continue.Top.Message;
float myTopMsgSpace = ((myTopMsg ?? "") != "") ? 2 * SixLinesPerInch : 0;
while ((YSize - yTop) > ySpaceOnCurPage)
{
ySpaceOnCurPage -= myBottomMsgSpace;
vlnParagraph paraBreak = FindPageBreak(yStart, ySpaceOnCurPage, yLowerLimit, myList);
if (paraBreak == null)
{
_MyLog.ErrorFormat("<<< ERROR >>> Cannot find a place to break\r\n==>'Cannot Find Place to Break',{0},'{1}','{2}'"
, MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath);
break;
}
// yTopNew is y Location of this page break. YTopMost is top of HLS, including any Cautions/Notes/Boxes/etc
//float yTopNew = paraBreak.YVeryTop - YTopMost;
//float yTopNew = paraBreak.YTopMost - YTopMost;
float yTopNew = Math.Min(paraBreak.YTopMost, paraBreak.YVeryTop) - YTopMost;
RemoveProcessedParagraphs(myList, yTopNew - yTop);
yTop = yTopNew;
MyPageHelper.ParaBreaks.Add(paraBreak);
ySpaceOnCurPage = yPageSize - (myTopMsgSpace + SixLinesPerInch); // Allow for continue message and blank line.
//ySpaceOnCurPage = yPageSize - (myTopMsgSpace + SixLinesPerInch); // Allow for continue message and blank line.
//if (paraBreak.YTopMost != paraBreak.YVeryTop && MyPageHelper.TopMessage == null && MyPageHelper.BottomMessage == null)
// ySpaceOnCurPage = yPageSize;
//ySpaceOnCurPage = yPageSize; // Allow for continue message and blank line.
//DocStyle docstyle = MyItemInfo.MyDocStyle;
//string myMsg = docstyle.Continue.Bottom.Message;
//if ((myMsg ?? "") != "") ySpaceOnCurPage -= 2 * SixLinesPerInch; // Allow for continue message and blank line.
yLowerLimit = ySpaceOnCurPage / 2;
if (_Match16BitPagination) yLowerLimit -= 1.5F * SixLinesPerInch; // 276 for HLP
yStart = 0;
}
}
/// <summary>
/// Finds the highest StepLevel (lowest StepLevel number, 0 = HLS, 1 = first substep) that
/// fills the page sufficiently (more than half-full)
/// </summary>
/// <param name="yWithinMargins"></param>
/// <param name="yTop"></param>
/// <param name="myList"></param>
/// <returns></returns>
private static vlnParagraph FindPageBreak(float yStart, float yUpperLimit, float yLowerLimit, StepLevelList myList)
{
vlnParagraph minPara = null;
foreach (int stepLevel in myList.Keys) // loop thru StepLevels, starting with lowest.
{
foreach (float yLocation in myList[stepLevel].Keys) // loop thru yLocation
{
vlnParagraph myPara = myList[stepLevel][yLocation];
// The top of this step will fit onto page (-yLocation < yWithinMargins)
float wcnChkLstBorder = myPara.MyItemInfo.MyHLS.FormatStepData.UseSmartTemplate &&
(myPara.MyItemInfo.MyHLS.FormatStepData.Suffix ?? "") != "" ? 2*SixLinesPerInch : 0;
if (minPara == null || minPara.YTop > myPara.YTop)
minPara = myPara;
if (wcnChkLstBorder -yLocation <= yUpperLimit) // Fix for OFN-RJ-23
//if (-yLocation < yUpperLimit) // Before
//if (-yLocation < yWithinMargins && myList[stepLevel][yLocation].MyItemInfo.MyPrevious != null)
{
//ItemInfo prev = myList[stepLevel][yLocation].MyItemInfo.MyPrevious;
//if (myList[stepLevel][yLocation].MyItemInfo.ItemID == 5609) Console.WriteLine("aer");
//if (myList[stepLevel][yLocation].MyItemInfo.ItemID == 4312) Console.WriteLine("rno");
// The top of this step is more than 1/2 way down the page
if ((-yLocation + yStart) >= yLowerLimit)
return myPara;
// If this item will not fit on the current page, put a page break
if (myPara.YBottom - myPara.YTop > (yUpperLimit - (-yLocation + yStart)))
return myPara;
// if is a caution or note & parent is a substep and entire substep doesn't fit, break.
if ((myPara.MyItemInfo.IsNote || myPara.MyItemInfo.IsCaution) &&
!myPara.MyParent.MyItemInfo.IsHigh &&
myPara.MyParent.YSize > (yUpperLimit + yLocation))
{
return myList[stepLevel][yLocation];
}
}
}
}
return minPara;
}
//private void WalkStepLevel(float yTopMost)
//{
// foreach (vlnParagraph child in ChildrenAbove)
// child.WalkStepLevel(yTopMost);
// foreach (vlnParagraph child in ChildrenLeft)
// child.WalkStepLevel(yTopMost);
// ShowStepLevel(yTopMost);
// foreach (vlnParagraph child in ChildrenRight)
// child.WalkStepLevel(yTopMost);
// foreach (vlnParagraph child in ChildrenBelow)
// child.WalkStepLevel(yTopMost);
//}
//private void ShowStepLevel(float yTopMost)
//{
// ItemInfo item = MyItemInfo;
// ItemInfo parent = item.ActiveParent as ItemInfo;
// //if (para.MyItemInfo.ItemID == 205)
// // Console.Write("");
// DebugPagination.WriteLine("'StepLevel',{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", YVeryTop - yTopMost, YSize, YBottomMost - yTopMost, item.ItemID, item.DBSequence, item.StepLevel, item.MyContent.Type % 10000,
// parent.MyContent.Type % 10000, item.HasCautionOrNote ? 1 : 0, parent.Cautions == null ? 0 : 1);
//}
}
public partial class VlnSvgPageHelper : SvgPageHelper
{
private bool _OriginalPageBreak; // use 16bit page breaks.
public bool OriginalPageBreak
{
get { return _OriginalPageBreak; }
set { _OriginalPageBreak = value; }
}
// This handles Page Breaks within a Step
private List<vlnParagraph> _ParaBreaks = new List<vlnParagraph>();
public List<vlnParagraph> ParaBreaks
{
get { return _ParaBreaks; }
set { _ParaBreaks = value; }
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
C1.Win.C1FlexGrid.C1FlexGrid, C1.Win.C1FlexGrid.2, Version=2.6.20091.401, Culture=neutral, PublicKeyToken=79882d576c6336da

View File

@@ -0,0 +1 @@
C1.Win.C1FlexGrid.C1FlexGrid, C1.Win.C1FlexGrid.2

View File

@@ -0,0 +1 @@
C1.Win.C1FlexGrid.C1FlexGrid, C1.Win.C1FlexGrid.2, Version=2.0.20162.188, Culture=neutral, PublicKeyToken=79882d576c6336da

File diff suppressed because it is too large Load Diff

View File

@@ -15,7 +15,7 @@
<SccAuxPath>
</SccAuxPath>
<SccProvider>MSSCCI:Microsoft Visual SourceSafe</SccProvider>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
@@ -32,6 +32,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -40,6 +41,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
@@ -48,6 +50,7 @@
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\x86\Release\</OutputPath>
@@ -56,9 +59,12 @@
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="C1.Win.C1FlexGrid.2, Version=2.6.20142.835, Culture=neutral, PublicKeyToken=79882d576c6336da, processorArchitecture=MSIL" />
<Reference Include="C1.Win.C1FlexGrid.2, Version=2.0.20162.188, Culture=neutral, PublicKeyToken=79882d576c6336da, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Csla, Version=2.1.4.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Volian.Controls.Library\bin\Debug\Csla.dll</HintPath>
@@ -102,11 +108,13 @@
<Compile Include="CompleteRORpt.cs" />
<Compile Include="CPSGen.cs" />
<Compile Include="Grid2Pdf.cs" />
<Compile Include="MergedPdf.cs" />
<Compile Include="PageCount.cs" />
<Compile Include="Pagination.cs" />
<Compile Include="pdf.cs" />
<Compile Include="PDFChronologyReport.cs" />
<Compile Include="PDFConsistencyCheckReport.cs" />
<Compile Include="PDFPageSize.cs" />
<Compile Include="PDFReport.cs" />
<Compile Include="PDFTransitionReport.cs" />
<Compile Include="pkParagraph.cs" />

View File

@@ -0,0 +1,165 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{94830C07-6A3A-450E-9674-C9B4293A7726}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Volian.Print.Library</RootNamespace>
<AssemblyName>Volian.Print.Library</AssemblyName>
<SccProjectName>"%24/PROMS/Volian.Print.Library", NGEAAAAA</SccProjectName>
<SccLocalPath>.</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>MSSCCI:Microsoft Visual SourceSafe</SccProvider>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="C1.Win.C1FlexGrid.2, Version=2.0.20162.188, Culture=neutral, PublicKeyToken=79882d576c6336da, processorArchitecture=MSIL" />
<Reference Include="Csla, Version=2.1.4.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Volian.Controls.Library\bin\Debug\Csla.dll</HintPath>
</Reference>
<Reference Include="FlexableMessageBox">
<HintPath>..\FlexableMessageBox\bin\Debug\FlexableMessageBox.dll</HintPath>
</Reference>
<Reference Include="Itenso.Rtf.Interpreter, Version=1.1.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Proms3rdPartyLibraries\RtfConverter\bin\Debug\Itenso.Rtf.Interpreter.dll</HintPath>
</Reference>
<Reference Include="Itenso.Rtf.Parser, Version=1.1.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Proms3rdPartyLibraries\RtfConverter\bin\Debug\Itenso.Rtf.Parser.dll</HintPath>
</Reference>
<Reference Include="itextsharp, Version=4.1.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Proms3rdPartyLibraries\iTechSharp\itextsharp.dll</HintPath>
</Reference>
<Reference Include="LBWordLibrary, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\LBWordLibrary\bin\Debug\LBWordLibrary.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\DataLoader\bin\Debug\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data">
<Private>True</Private>
</Reference>
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="VlnStatus">
<HintPath>..\ReferencedObjects\LibSource\VlnStatus\bin\Debug\VlnStatus.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CompleteRORpt.cs" />
<Compile Include="CPSGen.cs" />
<Compile Include="Grid2Pdf.cs" />
<Compile Include="MergedPdf.cs" />
<Compile Include="PageCount.cs" />
<Compile Include="Pagination.cs" />
<Compile Include="pdf.cs" />
<Compile Include="PDFChronologyReport.cs" />
<Compile Include="PDFConsistencyCheckReport.cs" />
<Compile Include="PDFPageSize.cs" />
<Compile Include="PDFReport.cs" />
<Compile Include="PDFTransitionReport.cs" />
<Compile Include="pkParagraph.cs" />
<Compile Include="ContActionSum.cs" />
<Compile Include="Placekeeper.cs" />
<Compile Include="PromsPrinter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Rtf2iTextSharp.cs" />
<Compile Include="Rtf2Pdf.cs" />
<Compile Include="vlnBox.cs" />
<Compile Include="vlnChangeBar.cs" />
<Compile Include="vlnHeader.cs" />
<Compile Include="vlnMacro.cs" />
<Compile Include="vlnParagraph.cs" />
<Compile Include="vlnPrintObject.cs" />
<Compile Include="vlnRNOSeparator.cs" />
<Compile Include="VlnSvgPageHelper.cs" />
<Compile Include="vlnTab.cs" />
<Compile Include="vlnText.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VEPROMS.CSLA.Library\VEPROMS.CSLA.Library.csproj">
<Project>{41B2D786-1C03-4C1A-9247-DA9F0D6B06D5}</Project>
<Name>VEPROMS.CSLA.Library</Name>
</ProjectReference>
<ProjectReference Include="..\Volian.Base.Library\Volian.Base.Library.csproj">
<Project>{AEEE9FD1-6892-45E2-A67E-418C06D46FF9}</Project>
<Name>Volian.Base.Library</Name>
</ProjectReference>
<ProjectReference Include="..\Volian.Controls.Library\Volian.Controls.Library.csproj">
<Project>{8556527C-6615-487F-8AF7-22EBC3EF0268}</Project>
<Name>Volian.Controls.Library</Name>
</ProjectReference>
<ProjectReference Include="..\Volian.Svg.Library\Volian.Svg.Library.csproj">
<Project>{293911B5-C602-483F-A97F-F962EEFB3CAE}</Project>
<Name>Volian.Svg.Library</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\licenses.licx" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,221 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library;
namespace Volian.Print.Library
{
public partial class vlnBox : vlnPrintObject
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _LineType; /* how to represent?? */
private System.Drawing.Color _Color;
public System.Drawing.Color Color
{
get { return _Color; }
set { _Color = value; }
}
private Box _MyBox;
public Box MyBox
{
get { return _MyBox; }
set { _MyBox = value; }
}
// the following two fields are used if 'boxed' step, thus
// no 'Box' was defined in format file.
public string DefBox = null;
public float DefEnd = 0;
public vlnBox()
{
}
public vlnBox(vlnParagraph paragraph)
{
}
public const string BoxThin = "\x2510.\x2500.\x250c.\x2502. . .\x2518.\x2514. .\x2500. . ";
const string BoxThick = "\x2584.\x2584.\x2584.\x2588. . .\x2580.\x2580. .\x2580. . ";
const string BoxDouble = "\x2557.\x2550.\x2554.\x2551. . .\x255D.\x255A. .\x2550. . ";
const string BoxFPLNote = "\x2557.\x2550\xad.\x2554\xad.\x2551. . .\x255d.\x255a\xad. .\x2550\xad. . ";
const string BoxFPLCaution = "\x2588.\x2580.\x2588.\x2588. . .\x2588.\x2588. .\x2584. . ";
const string BoxAsterisk = " *.* .* . . . . *.* . .* . . ";
const string BoxAsteriskWithSides = " *.* .* .* . . . *.* . .* . . ";
public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
{
if (MyBox == null) return yPageStart;
cb.SaveState();
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
if (textLayer != null) cb.BeginLayer(textLayer);
MyContentByte = cb;
//Console.WriteLine("'{0}','{1}'", CharToAsc(MyBox.BoxStyle), MyParent.MyItemInfo.ShortPath);
float top = CalculateYOffset(yPageStart, yTopMargin) - (7*MyPageHelper.YMultiplier);
float bottom = top - (Height * MyPageHelper.YMultiplier);
float left = (float)((MyBox.Start ?? 0) + MyParent.MyItemInfo.MyDocStyle.Layout.LeftMargin);
float right = (float)MyParent.MyItemInfo.MyDocStyle.Layout.LeftMargin + (float)(MyBox.End ?? DefEnd);
iTextSharp.text.Color boxColor = new iTextSharp.text.Color(PrintOverride.OverrideBoxColor(System.Drawing.Color.Black));
cb.SetColorStroke(boxColor);
if (DefBox != null)
{
cb.SetLineWidth(.6F);
cb.Rectangle(left, bottom, right - left, Height * MyPageHelper.YMultiplier);
}
else
{
const float llxOffset = 3;
float lineThickness = 0;
switch (MyBox.BoxStyle)
{
case BoxThin:
lineThickness = .6F;
cb.SetLineWidth(lineThickness);
cb.Rectangle(left + llxOffset, bottom + (lineThickness / 2), right - left, (Height - lineThickness) * MyPageHelper.YMultiplier);
break;
case BoxThick:
lineThickness = 6;
cb.SetLineWidth(lineThickness);
cb.Rectangle(left + llxOffset, bottom + (lineThickness / 2), right - left, (Height - lineThickness) * MyPageHelper.YMultiplier);
break;
case BoxDouble:
lineThickness = .6F;
cb.SetLineWidth(lineThickness);
// outer rectangle (rectangle's are defined as x,y,w,h)
cb.Rectangle(left + llxOffset - lineThickness * 1.5F, bottom - lineThickness, right - left + lineThickness * 3, (Height + lineThickness * 2) * MyPageHelper.YMultiplier);
// inner rectangle
cb.Rectangle(left + llxOffset + lineThickness, bottom + lineThickness * 1.5F, right - left - lineThickness * 2, (Height - lineThickness * 3) * MyPageHelper.YMultiplier);
break;
case BoxFPLNote:
lineThickness = 2;
cb.SetLineWidth(lineThickness);
float[] linePattern = { 6, 1.75F, 2.5F, 1.75F };
cb.SetLineDash(linePattern,3);
cb.Rectangle(left + llxOffset, bottom + (lineThickness / 2) -1, right - left, (2 + Height - lineThickness) * MyPageHelper.YMultiplier);
break;
case BoxFPLCaution:
lineThickness = 3;
cb.SetLineWidth(lineThickness);
// use a Y adjustment (top & bottom) to make the caution box match the 16bit output.
float YbxAdjust = 6.5F;
cb.Rectangle(left + llxOffset, bottom - YbxAdjust + (lineThickness / 2), right - left, (Height - lineThickness + 2*YbxAdjust) * MyPageHelper.YMultiplier);
break;
case BoxAsterisk:
// this box is not drawn, it is a series of asterisks drawn above and below text.
// For this box, there are no vertical edges (RGE uses this box type)
DrawTopBottomAsterisk(cb, yPageStart, yTopMargin, yBottomMargin, ref top, ref bottom, left);
break;
case BoxAsteriskWithSides:
DrawTopBottomAsterisk(cb, yPageStart, yTopMargin, yBottomMargin, ref top, ref bottom, left);
DrawSideAsterisk(cb, yPageStart, yTopMargin, yBottomMargin, top, bottom, left, right);
break;
default:
// For other than thick, thin and double.
if (!_UnimplementedBoxStyles.Contains(MyBox.BoxStyle))
{
_UnimplementedBoxStyles.Add(MyBox.BoxStyle);
_MyLog.InfoFormat("Unimplemented Box Style {0} {1}", ShowBoxStyle(MyBox.BoxStyle), MyParent.MyItemInfo.ShortPath);
//Console.WriteLine("Unimplemented Box Style {0} {1}", ShowBoxStyle(MyBox.BoxStyle), MyParent.MyItemInfo.ShortPath);
}
break;
//throw new Exception("Missing vlnBox handler");
}
}
cb.Stroke();
if (textLayer != null) cb.EndLayer();
cb.RestoreState();
return yPageStart;
}
private void DrawSideAsterisk(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right)
{
top = CalculateYOffset(yPageStart, yTopMargin);
bottom = top - (Height * MyPageHelper.YMultiplier);
VE_Font vf = MyParent.MyItemInfo.FormatStepData.Font;
// Left side first:
string Rtf = GetRtf(MyBox.BXVert, vf);
float vertDiff = top;
float size = (float)(MyBox.BXVert.Length * (72 / vf.CPI));
while (vertDiff > bottom)
{
Rtf2Pdf.TextAt(cb, IParagraph, left, vertDiff, size, 100, "", yBottomMargin);
vertDiff -= (SixLinesPerInch * MyPageHelper.YMultiplier);
}
// right side:
vertDiff = top;
Rtf = GetRtf(MyBox.BXVert.TrimEnd(), vf);
while (vertDiff > bottom)
{
if (MyBox.End != null)Rtf2Pdf.TextAt(cb, IParagraph, (float) MyBox.End, vertDiff, size, 100, "", yBottomMargin);
vertDiff = (SixLinesPerInch * MyPageHelper.YMultiplier);
}
}
private void DrawTopBottomAsterisk(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, ref float top, ref float bottom, float left)
{
top = CalculateYOffset(yPageStart, yTopMargin);
bottom = top - (Height * MyPageHelper.YMultiplier);
VE_Font vf = MyParent.MyItemInfo.FormatStepData.Font;
// Top line first:
StringBuilder sb = new StringBuilder();
sb.Append(MyBox.BXVert);
float size = (float)(MyBox.BXULC.Length * (72 / vf.CPI));
while (size < MyBox.End)
{
sb.Append(MyBox.BXHorz);
size = size + (float)(MyBox.BXHorz.Length * (72 / vf.CPI));
}
// Tack on the right upper corner. For some reason, the upper right corner in the
// formats had the first character as a space, this would put two spaces in a row
// at the end of the string, so remove the space before tacking on the upper right
// corner:
string bxstr = sb.ToString().TrimEnd() + MyBox.BXURC;
size = size + (float)((MyBox.BXURC.Length) * (72 / vf.CPI));
Rtf = GetRtf(bxstr, vf);
Rtf2Pdf.TextAt(cb, IParagraph, left, top, size, 100, "", yBottomMargin);
// Bottom line now
sb.Remove(0, sb.Length);
sb.Append(MyBox.BXLLC);
size = (float)(MyBox.BXLLC.Length * (72 / vf.CPI));
while (size < MyBox.End)
{
sb.Append(MyBox.BXHorz);
size = size + (float)(MyBox.BXHorz.Length * (72 / vf.CPI));
}
bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC;
size = size + (float)((MyBox.BXLRC.Length) * (72 / vf.CPI));
Rtf = GetRtf(bxstr, vf);
Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size, 100, "", yBottomMargin);
}
private string ShowBoxStyle(string str)
{
StringBuilder sb = new StringBuilder();
foreach (Char c in str)
{
if (c >= ' ' && c < 128)
sb.Append(c);
else
sb.Append(string.Format("x{0:X0000}", (int)c));
}
return sb.ToString();
}
private static List<string> _UnimplementedBoxStyles = new List<string>();
private string CharToAsc(string p)
{
StringBuilder sb = new StringBuilder();
foreach (char c in p)
{
if (c >= ' ' && c < 127) sb.Append(c);
else sb.Append(string.Format("\\x{0:x}", (int)c));
}
return sb.ToString();
}
}
}

View File

@@ -0,0 +1,233 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library;
namespace Volian.Print.Library
{
public partial class vlnBox : vlnPrintObject
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _LineType; /* how to represent?? */
private System.Drawing.Color _Color;
public System.Drawing.Color Color
{
get { return _Color; }
set { _Color = value; }
}
private Box _MyBox;
public Box MyBox
{
get { return _MyBox; }
set { _MyBox = value; }
}
// the following two fields are used if 'boxed' step, thus
// no 'Box' was defined in format file.
public string DefBox = null;
public float DefEnd = 0;
public vlnBox()
{
}
public vlnBox(vlnParagraph paragraph)
{
}
public const string BoxThin = "\x2510.\x2500.\x250c.\x2502. . .\x2518.\x2514. .\x2500. . ";
const string BoxThick = "\x2584.\x2584.\x2584.\x2588. . .\x2580.\x2580. .\x2580. . ";
const string BoxDouble = "\x2557.\x2550.\x2554.\x2551. . .\x255D.\x255A. .\x2550. . ";
const string BoxFPLNote = "\x2557.\x2550\xad.\x2554\xad.\x2551. . .\x255d.\x255a\xad. .\x2550\xad. . ";
const string BoxFPLCaution = "\x2588.\x2580.\x2588.\x2588. . .\x2588.\x2588. .\x2584. . ";
const string BoxAsterisk = " *.* .* . . . . *.* . .* . . ";
const string BoxAsteriskWithSides1 = " *.* .* .* . . . *.* . .* . . "; // ip2
const string BoxAsteriskWithSides2 = "*. *.*.*. . .*.*. . *. . "; // ip3 (sub 15)
public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
{
if (MyBox == null) return yPageStart;
cb.SaveState();
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
if (textLayer != null) cb.BeginLayer(textLayer);
MyContentByte = cb;
//Console.WriteLine("'{0}','{1}'", CharToAsc(MyBox.BoxStyle), MyParent.MyItemInfo.ShortPath);
float top = CalculateYOffset(yPageStart, yTopMargin) - (7*MyPageHelper.YMultiplier);
float bottom = top - (Height * MyPageHelper.YMultiplier);
float left = (float)((MyBox.Start ?? 0) + MyParent.MyItemInfo.MyDocStyle.Layout.LeftMargin);
float right = (float)MyParent.MyItemInfo.MyDocStyle.Layout.LeftMargin + (float)(MyBox.End ?? DefEnd);
iTextSharp.text.Color boxColor = new iTextSharp.text.Color(PrintOverride.OverrideBoxColor(System.Drawing.Color.Black));
cb.SetColorStroke(boxColor);
_MyPageHelper.MyGaps.Add(top, bottom);
if (DefBox != null)
{
cb.SetLineWidth(.6F);
cb.Rectangle(left, bottom, right - left, Height * MyPageHelper.YMultiplier);
}
else
{
const float llxOffset = 3;
float lineThickness = 0;
switch (MyBox.BoxStyle)
{
case BoxThin:
lineThickness = .6F;
cb.SetLineWidth(lineThickness);
cb.Rectangle(left + llxOffset, bottom + (lineThickness / 2), right - left, (Height - lineThickness) * MyPageHelper.YMultiplier);
break;
case BoxThick:
lineThickness = 6;
cb.SetLineWidth(lineThickness);
cb.Rectangle(left + llxOffset, bottom + (lineThickness / 2), right - left, (Height - lineThickness) * MyPageHelper.YMultiplier);
break;
case BoxDouble:
lineThickness = .6F;
cb.SetLineWidth(lineThickness);
// outer rectangle (rectangle's are defined as x,y,w,h)
cb.Rectangle(left + llxOffset - lineThickness * 1.5F, bottom - lineThickness, right - left + lineThickness * 3, (Height + lineThickness * 2) * MyPageHelper.YMultiplier);
// inner rectangle
cb.Rectangle(left + llxOffset + lineThickness, bottom + lineThickness * 1.5F, right - left - lineThickness * 2, (Height - lineThickness * 3) * MyPageHelper.YMultiplier);
break;
case BoxFPLNote:
lineThickness = 2;
cb.SetLineWidth(lineThickness);
float[] linePattern = { 6, 1.75F, 2.5F, 1.75F };
cb.SetLineDash(linePattern,3);
cb.Rectangle(left + llxOffset, bottom + (lineThickness / 2) -1, right - left, (2 + Height - lineThickness) * MyPageHelper.YMultiplier);
break;
case BoxFPLCaution:
lineThickness = 3;
cb.SetLineWidth(lineThickness);
// use a Y adjustment (top & bottom) to make the caution box match the 16bit output.
float YbxAdjust = 6.5F;
cb.Rectangle(left + llxOffset, bottom - YbxAdjust + (lineThickness / 2), right - left, (Height - lineThickness + 2*YbxAdjust) * MyPageHelper.YMultiplier);
break;
case BoxAsterisk:
DrawAsteriskTopBottom(cb, yPageStart, yTopMargin, yBottomMargin, ref top, ref bottom, left);
break;
case BoxAsteriskWithSides1:
case BoxAsteriskWithSides2:
DrawAsteriskTopBottom(cb, yPageStart, yTopMargin, yBottomMargin, ref top, ref bottom, left);
DrawAsteriskSide(cb, yPageStart, yTopMargin, yBottomMargin, top, bottom, left, right);
break;
default:
// For other than thick, thin and double.
if (!_UnimplementedBoxStyles.Contains(MyBox.BoxStyle))
{
_UnimplementedBoxStyles.Add(MyBox.BoxStyle);
_MyLog.InfoFormat("Unimplemented Box Style {0} {1}", ShowBoxStyle(MyBox.BoxStyle), MyParent.MyItemInfo.ShortPath);
//Console.WriteLine("Unimplemented Box Style {0} {1}", ShowBoxStyle(MyBox.BoxStyle), MyParent.MyItemInfo.ShortPath);
}
break;
//throw new Exception("Missing vlnBox handler");
}
}
cb.Stroke();
if (textLayer != null) cb.EndLayer();
cb.RestoreState();
return yPageStart;
}
private void DrawAsteriskTopBottom(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, ref float top, ref float bottom, float left)
{
// this box is not drawn, it is a series of asterisks drawn above and below text.
// For this box, there are no vertical edges (RGE uses this box type)
top = CalculateYOffset(yPageStart, yTopMargin);
// Bug fix B2013-091
// added YMultiplier to handle compress pages
// bottom row of asterisks was in non-compressed line location
bottom = top - (Height * MyPageHelper.YMultiplier);//Height;
// create a new font without any styles such as underline.
VE_Font vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, E_Style.None, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
// Top line first:
StringBuilder sb = new StringBuilder();
sb.Append(MyBox.BXULC);
float size = (float)(MyBox.BXULC.Length * (72/vf.CPI));
while (size < (MyBox.End - MyBox.Start))
{
sb.Append(MyBox.BXHorz);
size = size + (float)(MyBox.BXHorz.Length * (72/vf.CPI));
}
// Tack on the right upper corner. For some reason, the upper right corner in the
// formats had the first character as a space, this would put two spaces in a row
// at the end of the string, so remove the space before tacking on the upper right
// corner:
string bxstr = sb.ToString().TrimEnd() + MyBox.BXURC;
size = size + (float)((MyBox.BXURC.Length) * (72/vf.CPI));
Rtf = GetRtf(bxstr, vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
Rtf2Pdf.TextAt(cb, IParagraph, left, top, size, 100, "", yBottomMargin);
// Bottom line now
sb.Remove(0, sb.Length);
sb.Append(MyBox.BXLLC);
size = (float)(MyBox.BXLLC.Length * (72 / vf.CPI));
while (size < (MyBox.End-MyBox.Start))
{
sb.Append(MyBox.BXHorz);
size = size + (float)(MyBox.BXHorz.Length * (72 / vf.CPI));
}
bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC;
size = size + (float)((MyBox.BXLRC.Length) * (72/vf.CPI));
Rtf = GetRtf(bxstr, vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size, 100, "", yBottomMargin);
}
private void DrawAsteriskSide(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right)
{
top = CalculateYOffset(yPageStart, yTopMargin);
bottom = top - (Height * MyPageHelper.YMultiplier);
float height = (SixLinesPerInch * MyPageHelper.YMultiplier) + 4; // just add a little on so that height is a little bigger than character
VE_Font vf = MyParent.MyItemInfo.FormatStepData.Font;
// Left side first:
Rtf = GetRtf(MyBox.BXVert, vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
// start down one line because the top/bottom code draws the corner
float vertDiff = top - (SixLinesPerInch * MyPageHelper.YMultiplier);
float width = (float)(MyBox.BXVert.Length * (72 / vf.CPI));
while (vertDiff > bottom)
{
Rtf2Pdf.TextAt(cb, IParagraph, left, vertDiff, width, height, "", yBottomMargin);
vertDiff -= (SixLinesPerInch * MyPageHelper.YMultiplier);
}
// right side:
vertDiff = top - (SixLinesPerInch * MyPageHelper.YMultiplier);
Rtf = GetRtf(MyBox.BXVert.TrimEnd(), vf);
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
while (vertDiff > bottom)
{
Rtf2Pdf.TextAt(cb, IParagraph, right, vertDiff, width, height, "", yBottomMargin);
vertDiff -= (SixLinesPerInch * MyPageHelper.YMultiplier);
}
}
private string ShowBoxStyle(string str)
{
StringBuilder sb = new StringBuilder();
foreach (Char c in str)
{
if (c >= ' ' && c < 128)
sb.Append(c);
else
sb.Append(string.Format("x{0:X0000}", (int)c));
}
return sb.ToString();
}
private static List<string> _UnimplementedBoxStyles = new List<string>();
private string CharToAsc(string p)
{
StringBuilder sb = new StringBuilder();
foreach (char c in p)
{
if (c >= ' ' && c < 127) sb.Append(c);
else sb.Append(string.Format("\\x{0:x}", (int)c));
}
return sb.ToString();
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,404 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf;
using iTextSharp.text;
using Itenso.Rtf;
using Itenso.Rtf.Parser;
using Itenso.Rtf.Interpreter;
using Itenso.Rtf.Support;
using Volian.Controls.Library;
using VEPROMS.CSLA.Library;
namespace Volian.Print.Library
{
public abstract partial class vlnPrintObject
{
// Used for debugging:
private static int _UniqueDebugId = 0;
public static int UniqueDebugId
{
get { return _UniqueDebugId++; }
set { _UniqueDebugId = value; }
}
private int _DebugId = UniqueDebugId;
public int DebugId
{
get { return _DebugId; }
set { _DebugId = value; }
}
protected static float _WidthAdjust = 1; // 1 Point - adjusted to match 16-bit line wrapping. For editting it's 3.
protected static float _WidthAdjustBox = 6;
private static float _SixLinesPerInch = 12; // twips
public static float SixLinesPerInch
{
get { return vlnPrintObject._SixLinesPerInch; }
set { vlnPrintObject._SixLinesPerInch = value; }
}
protected static float _SevenLinesPerInch = 10.1F;//72F / 7F;
protected float _XOffset;
public float XOffset
{
get { return _XOffset; }
set {_XOffset = value; }
}
protected float _YOffset;
public float YOffset
{
get { return _YOffset; }
set { _YOffset = value; }
}
protected vlnParagraph _MyParent;
public vlnParagraph MyParent
{
get { return _MyParent; }
set
{
_MyParent = value;
if (_MyParent != null)
{
}
}
}
private string _ImageText; // ro definition, value part of #Link in case of image/figure
public string ImageText
{
get { return _ImageText; }
set { _ImageText = value; }
}
private string _Rtf; // may become iTextSharp paragraph
public string Rtf
{
get { return _Rtf; }
set { _Rtf = value; }
}
iTextSharp.text.Paragraph _IParagraph;
public iTextSharp.text.Paragraph IParagraph
{
get
{
if (_IParagraph == null)
{
_IParagraph = RtfToParagraph(Rtf);
}
return _IParagraph;
}
set { _IParagraph = value; }
}
private float _Width;
public float Width
{
get { return _Width; }
set { _Width = value; }
}
protected float _Height;
public float Height
{
get
{
if (_Height == 0)
_Height = GetParagraphHeight(MyContentByte, IParagraph, Width);
return _Height;
}
set { _Height = value; }
}
public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, float width)
{
return GetParagraphHeight(cb, iParagraph, width, true);
}
public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, float width, bool throwException)
{
VlnSvgPageHelper ph = null;
if(cb != null) ph = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
float heightAll = GetHeight(cb, iParagraph, width, throwException);
if (ph != null && ph.MyPromsPrinter.DebugOutput && !MyPageHelper.Back32BitPROMS)
{
vlnParagraph myParagraph = this as vlnParagraph;
if (myParagraph != null)
{
//if (myParagraph.MyItemInfo.FormatStepData != null && myParagraph.MyItemInfo.FormatStepData.Font.Family == "Prestige Elite Tall")
if (!myParagraph.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.WrapSameAsEdit)
{
Chunk chk = RemoveLastCharacter(iParagraph);
float heightAllButOne = GetHeight(cb, iParagraph, width, throwException);
if (heightAll != heightAllButOne)
return heightAllButOne;
if (chk != null)
RestoreLastCharacter(iParagraph, chk);
}
}
}
return heightAll;
}
private static void RestoreLastCharacter(Paragraph iParagraph, Chunk chk)
{
iParagraph.RemoveAt(iParagraph.Count - 1);
iParagraph.Add(chk);
}
private static Chunk RemoveLastCharacter(Paragraph iParagraph)
{
if (iParagraph.Count == 0)
return null;
object obj = iParagraph[iParagraph.Count-1];
Chunk chk = obj as Chunk;
if (chk == null)
return null;
string s = chk.Content;
if (s.Length > 1 || iParagraph.Count > 1) // don't remove last character if it's the only one
{
iParagraph.RemoveAt(iParagraph.Count - 1);
if (s.Length > 0)
{
if (s == "\xA0") // If this is a space at the end put it back
{
iParagraph.Add(chk);
return null;
}
else
{
s = s.Substring(0, s.Length - 1);
iParagraph.Add(new Chunk(s, chk.Font));
}
}
}
return chk;
}
private static float GetHeight(PdfContentByte cb, Paragraph iParagraph, float width, bool throwException)
{
ColumnText myColumnText = new ColumnText(cb);
myColumnText.SetSimpleColumn(0, 792F, width, 0); // Bottom margin
myColumnText.AddElement(iParagraph);
//myColumnText.UseAscender = true;// Adjusts to the top of the text box.
int status = myColumnText.Go(true); // Check to see if it will fit on the page.
if (ColumnText.HasMoreText(status) && throwException)
//throw (new Exception("Paragraph longer than a page"));
Console.WriteLine("Paragraph longer than a page");
return 792F - myColumnText.YLine; // This gives the height of the Paragraph
}
public float GetTableWidth(PdfContentByte cb, Paragraph iParagraph, float? maxWidth)
{
int iWidth = (int)(maxWidth ?? 72 * 8.5F);
float h = GetParagraphHeight(cb, iParagraph, iWidth);
int iWidthMax = iWidth; // maximum width in Characters
int iDelta = iWidth / 2;
iWidth = iWidth / 2;
while (iDelta > 0)
{
float h2 = GetParagraphHeight(cb, iParagraph, iWidth,false);
iDelta = iDelta / 2;
if (h2 == h) iWidthMax = iWidth;
iWidth += (h2>h ? 1: -1) * iDelta;
}
return (float) iWidthMax;
}
private PdfContentByte _MyContentByte;
public PdfContentByte MyContentByte
{
get { return _MyContentByte; }
set { _MyContentByte = value; }
}
private VlnSvgPageHelper _MyPageHelper;
public VlnSvgPageHelper MyPageHelper
{
get
{
if(_MyPageHelper == null)
_MyPageHelper = MyContentByte.PdfWriter.PageEvent as VlnSvgPageHelper;
return _MyPageHelper;
}
set { _MyPageHelper = value; }
}
public vlnPrintObject()
{
}
/// <summary>
/// No conversion necessary: twips -> twips
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int ToInt(int value)
{
return value;
}
/// <summary>
/// No conversion necessary: int? twips -> int twips
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int ToInt(int? value)
{
return ToInt((int)value);
}
/// <summary>
/// No conversion necessary: string twips -> int twips
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int ToInt(string value)
{
return ToInt((int)Convert.ToSingle(value));
}
/// <summary>
/// No conversion necessary: value from a list in a string, twips -> int twips
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int ToInt(string value, int i)
{
string s = (value.Contains(",")) ? value.Split(",".ToCharArray())[i] : value;
return ToInt(s);
}
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(AddFontTable(vFont.WindowsFont));
rtfSB.Append(vlntxt.StartText);
rtfSB.Append("}");
return rtfSB.ToString();
}
public 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 = Volian.Svg.Library.VolianPdf.GetFont(font);
float fW = iFont.BaseFont.GetWidthPointKerned("W", 12);
float fE = iFont.BaseFont.GetWidthPointKerned("!", 12);
return fW == fE;
}
public 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);
if (rtf.Contains("\x05"))
{
// if there is a hanging indent, the iTextSharp paragraph properties must be set
// to print the indent. Replace the indent 'token' with a non-used symbol, this will
// create a chunk with that symbol. Then loop through all of the chunks until we find
// this symbol, adding up the widths to that point. This width is the value that
// needs to be used to set the indent.
// Notes:
// A hard return will reset the chkW (indent width) back to zero.
// We jump out of the processing loop after the first indent token is found and ignor any other ones
IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace("\x05", @"\f1 \u9999? \f0 "));
Rtf2iTextSharp rtf2IText2 = new Rtf2iTextSharp(rtfDoc2);
iTextSharp.text.Paragraph para2 = rtf2IText2.Convert();
float chkW = 0;
foreach (Chunk chk in para2.Chunks)
{
if (chk.Content[0] == 9999) break;
if (chk.Content.Contains("\n")) chkW = 0; //hard return - reset chkW (indent start)
chkW += chk.GetWidthPoint();
}
para.IndentationLeft = chkW;
para.FirstLineIndent = -chkW;
}
return para;
}
public abstract float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin);
protected float CalculateYOffset(float yPageStart, float yTopMargin)
{
float yLocation = yPageStart - YOffset;
if (MyPageHelper.YMultiplier != 1)
{
yLocation = -1 + yTopMargin - (yTopMargin - yLocation) * MyPageHelper.YMultiplier;
if (Rtf != null)
IParagraph.Leading = _SevenLinesPerInch;
}
return yLocation;
}
protected float CalculateYLocation(float yLocation, float yTopMargin)
{
if (MyPageHelper.YMultiplier != 1)
yLocation = -1 + yTopMargin - (yTopMargin - yLocation) * MyPageHelper.YMultiplier;
return yLocation;
}
public void DebugPdf(PdfContentByte cb, float left, float top)
{
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer;
if (debugLayer == null) return;
cb.SaveState();
cb.BeginLayer(debugLayer);
ColumnText ct = new ColumnText(cb);
ct.SetSimpleColumn(left, top, left+50, top - 50);
iTextSharp.text.Font font = FontFactory.GetFont("Arial", 2);
Chunk chk = new Chunk(DebugId.ToString(), font);
Phrase ph = new Phrase(chk);
ct.AddElement(ph);
cb.SetColorFill(new iTextSharp.text.Color(PrintOverride.OverrideDebugColor(System.Drawing.Color.Gray)));
ct.Go();
cb.EndLayer();
cb.RestoreState();
}
public virtual float YBottom
{ get { return YOffset + Height;} }
}
public partial class vlnPrintObjects : List<vlnPrintObject>
{
public float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
{
foreach (vlnPrintObject part in this)
{
yPageStart = part.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin);
}
return yPageStart;
}
}
public enum PartLocation : int
{
None = 0, // Non-printable
Below = 1, // RNO Separator
Above = 2, // Tab Headers, Separator?
Right = 3, // Change Bars
Left = 4, // Tabs, Checkoffs? (maybe part of tab)
Container = 5 // Box
};
public enum ChildLocation : int
{
None = 0,
Below = 1,
Above = 2,
Right = 3, // RNO
Left = 4
}
}

View File

@@ -0,0 +1,282 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library;
namespace Volian.Print.Library
{
public partial class vlnTab : vlnText
{
/// <summary>
/// Used to Align Tabs for numeric tabs that can go to 2 digits
/// </summary>
private float? _TabAlign;
public float TabAlign // Offset to Last printable character
{
get
{
if (_TabAlign == null)
{
_TabAlign = 0;
if (Text != null)
{
while (_TabAlign < Text.Length && Text[(int)_TabAlign] == ' ')
_TabAlign++;
if (_TabAlign < Text.Length)
{
if ("0123456789".Contains(Text[(int)_TabAlign].ToString()))
{
while ("0123456789".Contains(Text[(int)_TabAlign].ToString()))
_TabAlign++;
_TabAlign--;
}
}
else
_TabAlign = 0;
}
}
return (float)_TabAlign * MyFont.CharsToTwips;
}
}
private float? _TabOffset;
public float TabOffset // Offset to first printable character
{
get
{
if (_TabOffset == null)
{
_TabOffset = 0;
if (Text != null)
{
while (_TabOffset<Text.Length && Text[(int)_TabOffset] == ' ')
_TabOffset++;
}
}
if (_TabOffset >= Text.Length) _TabOffset = 0;
return (float)_TabOffset * MyFont.CharsToTwips;
}
}
private vlnMacro _MyMacro;
public vlnMacro MyMacro
{
get { return _MyMacro; }
set { _MyMacro = value; }
}
private string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab
// add symbol characters as needed
// "\u25CF" - solid bullet
// \x0394 - delta
private System.Drawing.FontStyle GetSysFontStyle(VE_Font f)
{
if (f.Style == E_Style.Italics)
return System.Drawing.FontStyle.Italic;
return FontStyle.Regular;
}
private float GetTextWidth(VE_Font vefont, string txt, string symblFontName)
{
System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont));
System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
iTextSharp.text.Font iSymblFont = Volian.Svg.Library.VolianPdf.GetFont(symbFont);
float w = 0;
foreach (char c in txt)
{
int idx = symblsStr.IndexOf(c);
if (idx >= 0) // symbol character - use symbol font to find its width
w += iSymblFont.BaseFont.GetWidthPointKerned(symblsStr[idx].ToString(), (float)vefont.Size);
else
w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size);
}
//float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size);
return w;
}
bool _ScriptCaution = false;
public bool ScriptCaution
{
get { return _ScriptCaution; }
set { _ScriptCaution = value; }
}
bool _SeparateBullet = false;
public bool SeparateBullet
{
get { return _SeparateBullet; }
set { _SeparateBullet = value; }
}
public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab, string symblFontName, bool removedUnderline)
{
ScriptCaution = (origTab.Contains("Caution") && vFont.Family == "VolianScript");
MyContentByte = cb;
MyParent = myparent;
YOffset = yoffset;
Text = cleanTab;
MyFont = vFont;
float CCCs = GetTextWidth(MyFont, "CCCCCCCCCC", symblFontName);
float IIIs = GetTextWidth(MyFont, "iiiiiiiiii", symblFontName);
string origTab1 = origTab;
if (ScriptCaution)
{
Text = origTab.Replace("Caution ", "\uF043\uF061\uF069\uF06E\uF06F\uF074\uF075\uF020\uF020");
Width = 90;
}
else if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0)
//if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0)
Width = (float)myparent.MyItemInfo.FormatStepData.TabData.IdentWidth;
else if (CCCs != IIIs)
{
float tPtPerChar = myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TabPtsPerChar ?? 6;
Width = tPtPerChar * origTab.Length;
// Check the following, it may be needed for FPL:
//origTab1 = origTab1.TrimStart(" ".ToCharArray());
// 6 = number of points per character. 4 characters between end of tab and beginning of text
// origTab1.Trim... is number of non-space characters of the tab string.
//Width = 6 * (4 + origTab1.Trim(" ".ToCharArray()).Length);
}
else
Width = GetTextWidth(MyFont, (Text != null ? Text : origTab), symblFontName); //MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length);
if ((myparent.MyItemInfo.FormatStepData != null) && myparent.MyItemInfo.FormatStepData.TabData.Bullet.Separate)
if (myparent.MyItemInfo.MyPrevious != null || myparent.MyItemInfo.NextItem != null)
SeparateBullet = true;
if (origTab.Contains(@"{!"))
{
int mindx = origTab.IndexOf(@"{!");
int meindx = origTab.IndexOf(@"}", mindx);
string macro = origTab.Substring(mindx, meindx - mindx + 1);
// Width for placement of macro should be position in the string where the macro was located.
float lwidth = MyFont.CharsToTwips * (origTab.Length - meindx - 1);
MyMacro = new vlnMacro(xoffset - lwidth, yoffset, macro.Substring(2, macro.Length - 3));
xoffset += myparent.MyItemInfo.FormatStepData.TabData.MacroTabAdjust ?? 0;
origTab = origTab.Replace(macro, "");
cleanTab = origTab;
if (CCCs != IIIs)
{
float? tPtPerChar1 = myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TabPtsPerChar;
if (tPtPerChar1!=null)
Width = (float)tPtPerChar1 * origTab.Length;
else
{
origTab = origTab + " ";
origTab = origTab.TrimStart(" ".ToCharArray());
if (mindx > 2) // ouch!
Width = 6f * (origTab.Length - 1); // FPL (macro is after {numeric}) FPL is good with genmac output!
else
Width = 3 + (6f * origTab.Length); // NSP (macro is before {numeric})
}
}
else
Width = GetTextWidth(MyFont, (cleanTab != null ? cleanTab : origTab), symblFontName);//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length);
}
else
{
origTab = origTab1;
}
// if this tab was underlined, we may need to add partial underlining back in, if it was
// removed when the bullet was added. This handles the case where the bullet was appended
// to the tab, for example "NOTE: o".
if (removedUnderline)
{
int sep = origTab.IndexOfAny(". ".ToCharArray());
origTab = @"\ul " + origTab.Substring(0, sep-1) + @"\ulnone" + origTab.Substring(sep-1);
}
// if this tab is underlined, the underlining should not underline the ':'. Check for "NOTE:"
// or "CAUTION:", i.e. only underline up to ':'
if (myparent.MyItemInfo.IsStep && ((myparent.MyItemInfo.FormatStepData.AlwaysTab || myparent.MyItemInfo.MyPrevious == null)
&& ((vFont.Style & E_Style.Underline) > 0) && (origTab.ToUpper().Contains("NOTE:") ||
origTab.ToUpper().Contains("CAUTION:"))))
{
FontStyle style = FontStyle.Regular;
if ((vFont.Style & E_Style.Bold) > 0) style |= FontStyle.Bold;
if ((vFont.Style & E_Style.Italics) > 0) style |= FontStyle.Italic;
vFont.WindowsFont = new System.Drawing.Font(vFont.Family, (float)vFont.Size, style);
int indxC = origTab.IndexOf(":");
origTab = @"\ul " + origTab.Substring(0, indxC) + @"\ulnone" + origTab.Substring(indxC);
}
Rtf = GetRtf(origTab, vFont);
Rtf = Rtf.Replace("\u0394", @"\f1\u916?\f0 "); // delta 0x0394
if (ScriptCaution)
{
Rtf = GetRtf("\u25CFCaution ", vFont);
Rtf = Rtf.Replace("\u25CF", @"\f1\fs20 \u9679?\f0\par\f0\fs64 "); // bullet 25CF // jsj- force bullet size (is different than tab text)
if (myparent.MyItemInfo.FormatStepData != null && !myparent.MyItemInfo.FormatStepData.AlwaysTab && myparent.MyItemInfo.MyPrevious != null)
Rtf = Rtf.Replace("Caution ", @"\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?");
else
{
if (myparent.MyItemInfo.FormatStepData != null && !myparent.MyItemInfo.FormatStepData.AlwaysTab && myparent.MyItemInfo.NextItem == null)
Rtf = Rtf.Replace(@"\u9679?", "");
Rtf = Rtf.Replace("Caution ", @"\u61507?\u61537?\u61557?\u61556?\u61545?\u61551?\u61550?\u61472?\u61472?");
}
}
else
{
if (SeparateBullet)
Rtf = Rtf.Replace("\u25CF", "");
else
Rtf = Rtf.Replace("\u25CF", @"\f1\u9679?\f0 "); // bullet 25CF // jsj- add space after \f0
//Rtf = Rtf.Replace("\u25CF", @"\f1\fs18\b0\i0 \u9679?\f0 "); // bullet 25CF // jsj- add space after \f0
if (myparent.MyItemInfo.FormatStepData != null && !myparent.MyItemInfo.FormatStepData.AlwaysTab && myparent.MyItemInfo.MyPrevious != null)
{
//if (scriptCaution)
// Rtf = Rtf.Replace("CAUTION ", @"\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?");
Rtf = Rtf.Replace("Caution:", " ");
Rtf = Rtf.Replace("Note:", " ");
Rtf = Rtf.Replace("CAUTION:", " ");
Rtf = Rtf.Replace("NOTE:", " ");
Rtf = Rtf.Replace("Caution", " ");
Rtf = Rtf.Replace("Note", " ");
Rtf = Rtf.Replace("CAUTION", " ");
Rtf = Rtf.Replace("NOTE", " ");
}
}
//if (ScriptCaution && Rtf.Contains("Caution"))
//{
// // NSP script caution
// iTextSharp.text.Font myfont = pdf.GetFont(vFont.Family, 28, 0, iTextSharp.text.Color.BLACK);
// if (!myfont.BaseFont.CharExists(0x43)) // Capital 'C' exists as text
// {
// //VE_Font vf = new VE_Font("VolianScript", 28, E_Style.Italics, 12);
// // Capital 'C' exists as Symbol
// Rtf = Rtf.Replace("Caution ", @"\u61507?\u61537?\u61557?\u61556?\u61545?\u61551?\u61550?\u61472?\u61472?");
// }
//}
// do positioning based on whether format has locations for section 'header'. If it's not centered, treat
// it's location more like a 'tab'.
if (doSectTab)
{
XOffset = xoffset;
// the width was just a little small, so it was wrapping - but only if there were no spaces at end
// so use this condition to do minimal impact (WCN1 format, for section tabs with three places, i.e. 6.1.2
if (!cleanTab.EndsWith(" "))Width += .1f;
}
else
{
//if (MyFont.Family == "Arial" && MyFont.Size == 14)
//{
// System.Drawing.Font font = new System.Drawing.Font("Arial", 14);
// iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
// float w = iFont.BaseFont.GetWidthPointKerned(Text, 14);
// Width = w;
//}
XOffset = xoffset - Width;
}
}
public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
{
if (MyParent.MyItemInfo.FormatStepData != null && MyParent.MyItemInfo.FormatStepData.StepPrintData != null)
XOffset += (float)(MyParent.MyItemInfo.FormatStepData.StepPrintData.PosAdjust ?? 0);
float yLocation = CalculateYOffset(yPageStart, yTopMargin);
Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, "", yBottomMargin);
return yPageStart;
}
}
}

View File

@@ -0,0 +1,323 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library;
namespace Volian.Print.Library
{
public partial class vlnTab : vlnText
{
/// <summary>
/// Used to Align Tabs for numeric tabs that can go to 2 digits
/// </summary>
private float? _TabAlign;
public float TabAlign // Offset to Last printable character
{
get
{
if (_TabAlign == null)
{
_TabAlign = 0;
if (Text != null)
{
while (_TabAlign < Text.Length && Text[(int)_TabAlign] == ' ')
_TabAlign++;
if (_TabAlign < Text.Length)
{
if ("0123456789".Contains(Text[(int)_TabAlign].ToString()))
{
while ("0123456789".Contains(Text[(int)_TabAlign].ToString()))
_TabAlign++;
_TabAlign--;
}
}
else
_TabAlign = 0;
}
}
return (float)_TabAlign * MyFont.CharsToTwips;
}
}
private float? _TabOffset;
public float TabOffset // Offset to first printable character
{
get
{
if (_TabOffset == null)
{
_TabOffset = 0;
if (Text != null)
{
while (_TabOffset<Text.Length && Text[(int)_TabOffset] == ' ')
_TabOffset++;
}
}
if (_TabOffset >= Text.Length) _TabOffset = 0;
return (float)_TabOffset * MyFont.CharsToTwips;
}
}
private vlnMacro _MyMacro;
public vlnMacro MyMacro
{
get { return _MyMacro; }
set { _MyMacro = value; }
}
private string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab
// add symbol characters as needed
// "\u25CF" - solid bullet
// \x0394 - delta
private System.Drawing.FontStyle GetSysFontStyle(VE_Font f)
{
if (f.Style == E_Style.Italics)
return System.Drawing.FontStyle.Italic;
return FontStyle.Regular;
}
private float GetTextWidth(VE_Font vefont, string txt, string symblFontName)
{
System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont));
System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
iTextSharp.text.Font iSymblFont = Volian.Svg.Library.VolianPdf.GetFont(symbFont);
float w = 0;
foreach (char c in txt)
{
int idx = symblsStr.IndexOf(c);
if (idx >= 0) // symbol character - use symbol font to find its width
w += iSymblFont.BaseFont.GetWidthPointKerned(symblsStr[idx].ToString(), (float)vefont.Size);
else
w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size);
}
//float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size);
return w;
}
bool _ScriptCaution = false;
public bool ScriptCaution
{
get { return _ScriptCaution; }
set { _ScriptCaution = value; }
}
bool _SeparateBullet = false;
public bool SeparateBullet
{
get { return _SeparateBullet; }
set { _SeparateBullet = value; }
}
public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab, string symblFontName, bool removedUnderline)
{
bool alignAsIfBulleted = false;
ScriptCaution = (origTab.Contains("Caution") && vFont.Family == "VolianScript");
MyContentByte = cb;
MyParent = myparent;
YOffset = yoffset;
Text = cleanTab;
MyFont = vFont;
float CCCs = GetTextWidth(MyFont, "CCCCCCCCCC", symblFontName);
float IIIs = GetTextWidth(MyFont, "iiiiiiiiii", symblFontName);
string origTab1 = origTab;
if (ScriptCaution)
{
Text = origTab.Replace("Caution ", "\uF043\uF061\uF069\uF06E\uF06F\uF074\uF075\uF020\uF020");
Width = 90;
}
else if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0)
//if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0)
Width = (float)myparent.MyItemInfo.FormatStepData.TabData.IdentWidth;
else if (CCCs != IIIs)
{
float tPtPerChar = myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TabPtsPerChar ?? 6;
Width = tPtPerChar * origTab.Length;
// Check the following, it may be needed for FPL:
//origTab1 = origTab1.TrimStart(" ".ToCharArray());
// 6 = number of points per character. 4 characters between end of tab and beginning of text
// origTab1.Trim... is number of non-space characters of the tab string.
//Width = 6 * (4 + origTab1.Trim(" ".ToCharArray()).Length);
}
else
Width = GetTextWidth(MyFont, (Text != null ? Text : origTab), symblFontName); //MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length);
// Pairie Island (NSP) Caution and Note tabs use a larger font
// When using a bullet, we need to use the font size of the Caution/Note text instead of the tab.
// To do this we set the TabData.Bullet.Separate to true (currently - 4/26/2013 - only NSP uses this).
// Because of the different font sizes, when the Caution/Note did have have a bullet, the positioning
// was off by the lenght of IdentB (the bullet string), thus the "alignAsIfBulleted" bool
if ((myparent.MyItemInfo.FormatStepData != null) && myparent.MyItemInfo.FormatStepData.TabData.Bullet.Separate)
if (myparent.MyItemInfo.MyPrevious != null || myparent.MyItemInfo.NextItem != null)
SeparateBullet = true;
else
alignAsIfBulleted = true;
if (origTab.Contains(@"{!"))
{
int mindx = origTab.IndexOf(@"{!");
int meindx = origTab.IndexOf(@"}", mindx);
string macro = origTab.Substring(mindx, meindx - mindx + 1);
// Width for placement of macro should be position in the string where the macro was located.
float lwidth = MyFont.CharsToTwips * (origTab.Length - meindx - 1);
MyMacro = new vlnMacro(xoffset - lwidth, yoffset, macro.Substring(2, macro.Length - 3));
xoffset += myparent.MyItemInfo.FormatStepData.TabData.MacroTabAdjust ?? 0;
origTab = origTab.Replace(macro, "");
cleanTab = origTab;
if (CCCs != IIIs)
{
float? tPtPerChar1 = myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TabPtsPerChar;
if (tPtPerChar1!=null)
Width = (float)tPtPerChar1 * origTab.Length;
else
{
origTab = origTab + " ";
origTab = origTab.TrimStart(" ".ToCharArray());
if (mindx > 2) // ouch!
Width = 6f * (origTab.Length - 1); // FPL (macro is after {numeric}) FPL is good with genmac output!
else
Width = 3 + (6f * origTab.Length); // NSP (macro is before {numeric})
}
}
else
Width = GetTextWidth(MyFont, (cleanTab != null ? cleanTab : origTab), symblFontName);//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length);
}
else
{
origTab = origTab1;
}
// if this tab was underlined, we may need to add partial underlining back in, if it was
// removed when the bullet was added. This handles the case where the bullet was appended
// to the tab, for example "NOTE: o".
if (removedUnderline)
{
int sep = origTab.IndexOfAny(". ".ToCharArray());
//origTab = @"\ul " + origTab.Substring(0, sep-1) + @"\ulnone" + origTab.Substring(sep-1);
origTab = @"\ul " + origTab.Substring(0, sep) + @"\ulnone" + origTab.Substring(sep);
}
UnderlineTerminateList utl = myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.UnderlineTerminateList;
// if this tab is underlined, the underlining should not underline the ':'. Check for "NOTE:"
// or "CAUTION:", i.e. only underline up to ':'
if (myparent.MyItemInfo.IsStep && ((myparent.MyItemInfo.FormatStepData.AlwaysTab || myparent.MyItemInfo.MyPrevious == null)
&& ((vFont.Style & E_Style.Underline) > 0) && (origTab.ToUpper().Contains("NOTE:") ||
origTab.ToUpper().Contains("CAUTION:"))))
{
FontStyle style = FontStyle.Regular;
if ((vFont.Style & E_Style.Bold) > 0) style |= FontStyle.Bold;
if ((vFont.Style & E_Style.Italics) > 0) style |= FontStyle.Italic;
vFont.WindowsFont = new System.Drawing.Font(vFont.Family, (float)vFont.Size, style);
int indxC = origTab.IndexOf(":");
origTab = @"\ul " + origTab.Substring(0, indxC) + @"\ulnone" + origTab.Substring(indxC);
}
else if (utl != null && utl.Count > 0 && ((vFont.Style & E_Style.Underline) > 0))
{
foreach (UnderlineTerminate ut in utl)
{
if (origTab.Contains(ut.Text))
{
FontStyle style = FontStyle.Regular;
if ((vFont.Style & E_Style.Bold) > 0) style |= FontStyle.Bold;
if ((vFont.Style & E_Style.Italics) > 0) style |= FontStyle.Italic;
vFont.WindowsFont = new System.Drawing.Font(vFont.Family, (float)vFont.Size, style);
int indxC = origTab.IndexOf(ut.Text);
origTab = @"\ul " + origTab.Substring(0, indxC) + @"\ulnone " + origTab.Substring(indxC);
break;
}
}
}
if (SeparateBullet)
Rtf = GetRtf(origTab, myparent.MyItemInfo.FormatStepData.TabData.Bullet.Font);
else
Rtf = GetRtf(origTab, vFont);
Rtf = Rtf.Replace("\u0394", @"\f1\u916?\f0 "); // delta 0x0394
if (ScriptCaution)
{
Rtf = GetRtf("\u25CFCaution ", vFont);
Rtf = Rtf.Replace("\u25CF", @"\f1\fs20 \u9679?\f0\par\f0\fs64 "); // bullet 25CF // jsj- force bullet size (is different than tab text)
if (myparent.MyItemInfo.FormatStepData != null && !myparent.MyItemInfo.FormatStepData.AlwaysTab && myparent.MyItemInfo.MyPrevious != null)
Rtf = Rtf.Replace("Caution ", @"\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?");
else
{
if (myparent.MyItemInfo.FormatStepData != null && !myparent.MyItemInfo.FormatStepData.AlwaysTab && myparent.MyItemInfo.NextItem == null)
Rtf = Rtf.Replace(@"\u9679?", "");
Rtf = Rtf.Replace("Caution ", @"\u61507?\u61537?\u61557?\u61556?\u61545?\u61551?\u61550?\u61472?\u61472?");
}
}
else
{
if (SeparateBullet)
Rtf = Rtf.Replace("\u25CF", "");
else
Rtf = Rtf.Replace("\u25CF", @"\f1\u9679?\f0 "); // bullet 25CF // jsj- add space after \f0
//Rtf = Rtf.Replace("\u25CF", @"\f1\fs18\b0\i0 \u9679?\f0 "); // bullet 25CF // jsj- add space after \f0
if (myparent.MyItemInfo.FormatStepData != null && !myparent.MyItemInfo.FormatStepData.AlwaysTab && myparent.MyItemInfo.MyPrevious != null)
{
//if (scriptCaution)
// Rtf = Rtf.Replace("CAUTION ", @"\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?");
Rtf = Rtf.Replace("Caution:", " ");
Rtf = Rtf.Replace("Note:", " ");
Rtf = Rtf.Replace("CAUTION:", " ");
Rtf = Rtf.Replace("NOTE:", " ");
Rtf = Rtf.Replace("Caution", " ");
Rtf = Rtf.Replace("Note", " ");
Rtf = Rtf.Replace("CAUTION", " ");
Rtf = Rtf.Replace("NOTE", " ");
}
}
//if (ScriptCaution && Rtf.Contains("Caution"))
//{
// // NSP script caution
// iTextSharp.text.Font myfont = pdf.GetFont(vFont.Family, 28, 0, iTextSharp.text.Color.BLACK);
// if (!myfont.BaseFont.CharExists(0x43)) // Capital 'C' exists as text
// {
// //VE_Font vf = new VE_Font("VolianScript", 28, E_Style.Italics, 12);
// // Capital 'C' exists as Symbol
// Rtf = Rtf.Replace("Caution ", @"\u61507?\u61537?\u61557?\u61556?\u61545?\u61551?\u61550?\u61472?\u61472?");
// }
//}
// do positioning based on whether format has locations for section 'header'. If it's not centered, treat
// it's location more like a 'tab'.
if (doSectTab)
{
XOffset = xoffset;
// the width was just a little small, so it was wrapping - but only if there were no spaces at end
// so use this condition to do minimal impact (WCN1 format, for section tabs with three places, i.e. 6.1.2
if (!cleanTab.EndsWith(" "))Width += .1f;
}
else
{
// if using a proportional font and the tab font/size is different than the text font/size
if (CCCs != IIIs &&
(MyFont.Family != myparent.MyItemInfo.FormatStepData.Font.Family ||
MyFont.Size != myparent.MyItemInfo.FormatStepData.Font.Size))
{
// This is needed for Prairie Island (NSP) Caution/Note tabs to consistantly position
// them at the same horizontal (column) position on the page
string txt = Text;
if (alignAsIfBulleted)
txt += myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IdentB;
System.Drawing.Font font = new System.Drawing.Font(MyFont.Family,(float)MyFont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
float w = iFont.BaseFont.GetWidthPointKerned(txt, (float)MyFont.Size);
Width = w;
}
XOffset = xoffset - Width;
}
}
public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
{
if (MyParent.MyItemInfo.FormatStepData != null && MyParent.MyItemInfo.FormatStepData.StepPrintData != null)
XOffset += (float)(MyParent.MyItemInfo.FormatStepData.StepPrintData.PosAdjust ?? 0);
float yLocation = CalculateYOffset(yPageStart, yTopMargin);
Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, "", yBottomMargin);
return yPageStart;
}
}
}

View File

@@ -0,0 +1,323 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using iTextSharp.text.pdf;
using iTextSharp.text;
using VEPROMS.CSLA.Library;
namespace Volian.Print.Library
{
public partial class vlnTab : vlnText
{
/// <summary>
/// Used to Align Tabs for numeric tabs that can go to 2 digits
/// </summary>
private float? _TabAlign;
public float TabAlign // Offset to Last printable character
{
get
{
if (_TabAlign == null)
{
_TabAlign = 0;
if (Text != null)
{
while (_TabAlign < Text.Length && Text[(int)_TabAlign] == ' ')
_TabAlign++;
if (_TabAlign < Text.Length)
{
if ("0123456789".Contains(Text[(int)_TabAlign].ToString()))
{
while ("0123456789".Contains(Text[(int)_TabAlign].ToString()))
_TabAlign++;
_TabAlign--;
}
}
else
_TabAlign = 0;
}
}
return (float)_TabAlign * MyFont.CharsToTwips;
}
}
private float? _TabOffset;
public float TabOffset // Offset to first printable character
{
get
{
if (_TabOffset == null)
{
_TabOffset = 0;
if (Text != null)
{
while (_TabOffset<Text.Length && Text[(int)_TabOffset] == ' ')
_TabOffset++;
}
}
if (_TabOffset >= Text.Length) _TabOffset = 0;
return (float)_TabOffset * MyFont.CharsToTwips;
}
}
private vlnMacro _MyMacro;
public vlnMacro MyMacro
{
get { return _MyMacro; }
set { _MyMacro = value; }
}
private string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab
// add symbol characters as needed
// "\u25CF" - solid bullet
// \x0394 - delta
private System.Drawing.FontStyle GetSysFontStyle(VE_Font f)
{
if (f.Style == E_Style.Italics)
return System.Drawing.FontStyle.Italic;
return FontStyle.Regular;
}
private float GetTextWidth(VE_Font vefont, string txt, string symblFontName)
{
System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont));
System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
iTextSharp.text.Font iSymblFont = Volian.Svg.Library.VolianPdf.GetFont(symbFont);
float w = 0;
foreach (char c in txt)
{
int idx = symblsStr.IndexOf(c);
if (idx >= 0) // symbol character - use symbol font to find its width
w += iSymblFont.BaseFont.GetWidthPointKerned(symblsStr[idx].ToString(), (float)vefont.Size);
else
w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size);
}
//float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size);
return w;
}
bool _ScriptCaution = false;
public bool ScriptCaution
{
get { return _ScriptCaution; }
set { _ScriptCaution = value; }
}
bool _SeparateBullet = false;
public bool SeparateBullet
{
get { return _SeparateBullet; }
set { _SeparateBullet = value; }
}
public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab, string symblFontName, bool removedUnderline)
{
bool alignAsIfBulleted = false;
ScriptCaution = (origTab.Contains("Caution") && vFont.Family == "VolianScript");
MyContentByte = cb;
MyParent = myparent;
YOffset = yoffset;
Text = cleanTab;
MyFont = vFont;
float CCCs = GetTextWidth(MyFont, "CCCCCCCCCC", symblFontName);
float IIIs = GetTextWidth(MyFont, "iiiiiiiiii", symblFontName);
string origTab1 = origTab;
if (ScriptCaution)
{
Text = origTab.Replace("Caution ", "\uF043\uF061\uF069\uF06E\uF06F\uF074\uF075\uF020\uF020");
Width = 90;
}
else if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0)
//if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0)
Width = (float)myparent.MyItemInfo.FormatStepData.TabData.IdentWidth;
else if (CCCs != IIIs)
{
float tPtPerChar = myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TabPtsPerChar ?? 6;
Width = tPtPerChar * origTab.Length;
// Check the following, it may be needed for FPL:
//origTab1 = origTab1.TrimStart(" ".ToCharArray());
// 6 = number of points per character. 4 characters between end of tab and beginning of text
// origTab1.Trim... is number of non-space characters of the tab string.
//Width = 6 * (4 + origTab1.Trim(" ".ToCharArray()).Length);
}
else
Width = GetTextWidth(MyFont, (Text != null ? Text : origTab), symblFontName); //MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length);
// Pairie Island (NSP) Caution and Note tabs use a larger font
// When using a bullet, we need to use the font size of the Caution/Note text instead of the tab.
// To do this we set the TabData.Bullet.Separate to true (currently - 4/26/2013 - only NSP uses this).
// Because of the different font sizes, when the Caution/Note did have have a bullet, the positioning
// was off by the lenght of IdentB (the bullet string), thus the "alignAsIfBulleted" bool
if ((myparent.MyItemInfo.FormatStepData != null) && myparent.MyItemInfo.FormatStepData.TabData.Bullet.Separate)
if (myparent.MyItemInfo.MyPrevious != null || myparent.MyItemInfo.NextItem != null)
SeparateBullet = true;
else
alignAsIfBulleted = true;
if (origTab.Contains(@"{!"))
{
int mindx = origTab.IndexOf(@"{!");
int meindx = origTab.IndexOf(@"}", mindx);
string macro = origTab.Substring(mindx, meindx - mindx + 1);
// Width for placement of macro should be position in the string where the macro was located.
float lwidth = MyFont.CharsToTwips * (origTab.Length - meindx - 1);
MyMacro = new vlnMacro(xoffset - lwidth, yoffset, macro.Substring(2, macro.Length - 3));
xoffset += myparent.MyItemInfo.FormatStepData.TabData.MacroTabAdjust ?? 0;
origTab = origTab.Replace(macro, "");
cleanTab = origTab;
if (CCCs != IIIs)
{
float? tPtPerChar1 = myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.TabPtsPerChar;
if (tPtPerChar1!=null)
Width = (float)tPtPerChar1 * origTab.Length;
else
{
origTab = origTab + " ";
origTab = origTab.TrimStart(" ".ToCharArray());
if (mindx > 2) // ouch!
Width = 6f * (origTab.Length - 1); // FPL (macro is after {numeric}) FPL is good with genmac output!
else
Width = 3 + (6f * origTab.Length); // NSP (macro is before {numeric})
}
}
else
Width = GetTextWidth(MyFont, (cleanTab != null ? cleanTab : origTab), symblFontName);//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length);
}
else
{
origTab = origTab1;
}
// if this tab was underlined, we may need to add partial underlining back in, if it was
// removed when the bullet was added. This handles the case where the bullet was appended
// to the tab, for example "NOTE: o".
if (myparent.MyItemInfo.ItemID==124256) Console.WriteLine("here");
if (removedUnderline)
{
int sep = origTab.IndexOfAny(". ".ToCharArray());
// if last character before the sep is not a ':', then add one to separator because
// this was cutting the last character off (if there was no ':'.
//if (origTab[sep - 1] != ':') sep++;
origTab = @"\ul " + origTab.Substring(0, sep-1) + @"\ulnone" + origTab.Substring(sep-1);
}
UnderlineTerminateList utl = myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.UnderlineTerminateList;
// if this tab is underlined, the underlining should not underline the ':'. Check for "NOTE:"
// or "CAUTION:", i.e. only underline up to ':'
if (myparent.MyItemInfo.IsStep && ((myparent.MyItemInfo.FormatStepData.AlwaysTab || myparent.MyItemInfo.MyPrevious == null)
&& ((vFont.Style & E_Style.Underline) == E_Style.Underline) && (origTab.ToUpper().Contains("NOTE:") ||
origTab.ToUpper().Contains("CAUTION:"))))
{
FontStyle style = FontStyle.Regular;
if ((vFont.Style & E_Style.Bold) > 0) style |= FontStyle.Bold;
if ((vFont.Style & E_Style.Italics) > 0) style |= FontStyle.Italic;
vFont.WindowsFont = new System.Drawing.Font(vFont.Family, (float)vFont.Size, style);
int indxC = origTab.IndexOf(":");
origTab = @"\ul " + origTab.Substring(0, indxC) + @"\ulnone" + origTab.Substring(indxC);
}
else if (utl != null && ((vFont.Style & E_Style.Underline) > 0))
{
foreach (UnderlineTerminate ut in utl)
{
if (origTab.Contains(ut.Text))
{
FontStyle style = FontStyle.Regular;
if ((vFont.Style & E_Style.Bold) > 0) style |= FontStyle.Bold;
if ((vFont.Style & E_Style.Italics) > 0) style |= FontStyle.Italic;
vFont.WindowsFont = new System.Drawing.Font(vFont.Family, (float)vFont.Size, style);
int indxC = origTab.IndexOf(ut.Text);
origTab = @"\ul " + origTab.Substring(0, indxC) + @"\ulnone " + origTab.Substring(indxC);
break;
}
}
}
Rtf = GetRtf(origTab, vFont);
Rtf = Rtf.Replace("\u0394", @"\f1\u916?\f0 "); // delta 0x0394
if (ScriptCaution)
{
Rtf = GetRtf("\u25CFCaution ", vFont);
Rtf = Rtf.Replace("\u25CF", @"\f1\fs20 \u9679?\f0\par\f0\fs64 "); // bullet 25CF // jsj- force bullet size (is different than tab text)
if (myparent.MyItemInfo.FormatStepData != null && !myparent.MyItemInfo.FormatStepData.AlwaysTab && myparent.MyItemInfo.MyPrevious != null)
Rtf = Rtf.Replace("Caution ", @"\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?");
else
{
if (myparent.MyItemInfo.FormatStepData != null && !myparent.MyItemInfo.FormatStepData.AlwaysTab && myparent.MyItemInfo.NextItem == null)
Rtf = Rtf.Replace(@"\u9679?", "");
Rtf = Rtf.Replace("Caution ", @"\u61507?\u61537?\u61557?\u61556?\u61545?\u61551?\u61550?\u61472?\u61472?");
}
}
else
{
if (SeparateBullet)
Rtf = Rtf.Replace("\u25CF", "");
else
Rtf = Rtf.Replace("\u25CF", @"\f1\u9679?\f0 "); // bullet 25CF // jsj- add space after \f0
//Rtf = Rtf.Replace("\u25CF", @"\f1\fs18\b0\i0 \u9679?\f0 "); // bullet 25CF // jsj- add space after \f0
if (myparent.MyItemInfo.FormatStepData != null && !myparent.MyItemInfo.FormatStepData.AlwaysTab && myparent.MyItemInfo.MyPrevious != null)
{
//if (scriptCaution)
// Rtf = Rtf.Replace("CAUTION ", @"\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?\u61472?");
Rtf = Rtf.Replace("Caution:", " ");
Rtf = Rtf.Replace("Note:", " ");
Rtf = Rtf.Replace("CAUTION:", " ");
Rtf = Rtf.Replace("NOTE:", " ");
Rtf = Rtf.Replace("Caution", " ");
Rtf = Rtf.Replace("Note", " ");
Rtf = Rtf.Replace("CAUTION", " ");
Rtf = Rtf.Replace("NOTE", " ");
}
}
//if (ScriptCaution && Rtf.Contains("Caution"))
//{
// // NSP script caution
// iTextSharp.text.Font myfont = pdf.GetFont(vFont.Family, 28, 0, iTextSharp.text.Color.BLACK);
// if (!myfont.BaseFont.CharExists(0x43)) // Capital 'C' exists as text
// {
// //VE_Font vf = new VE_Font("VolianScript", 28, E_Style.Italics, 12);
// // Capital 'C' exists as Symbol
// Rtf = Rtf.Replace("Caution ", @"\u61507?\u61537?\u61557?\u61556?\u61545?\u61551?\u61550?\u61472?\u61472?");
// }
//}
// do positioning based on whether format has locations for section 'header'. If it's not centered, treat
// it's location more like a 'tab'.
if (doSectTab)
{
XOffset = xoffset;
// the width was just a little small, so it was wrapping - but only if there were no spaces at end
// so use this condition to do minimal impact (WCN1 format, for section tabs with three places, i.e. 6.1.2
if (!cleanTab.EndsWith(" "))Width += .1f;
}
else
{
// if using a proportional font and the tab font/size is different than the text font/size
if (CCCs != IIIs &&
(MyFont.Family != myparent.MyItemInfo.FormatStepData.Font.Family ||
MyFont.Size != myparent.MyItemInfo.FormatStepData.Font.Size))
{
// This is needed for Prairie Island (NSP) Caution/Note tabs to consistantly position
// them at the same horizontal (column) position on the page
string txt = Text;
if (alignAsIfBulleted)
txt += myparent.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IdentB;
System.Drawing.Font font = new System.Drawing.Font(MyFont.Family,(float)MyFont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
float w = iFont.BaseFont.GetWidthPointKerned(txt, (float)MyFont.Size);
Width = w;
}
XOffset = xoffset - Width;
}
}
public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
{
if (MyParent.MyItemInfo.FormatStepData != null && MyParent.MyItemInfo.FormatStepData.StepPrintData != null)
XOffset += (float)(MyParent.MyItemInfo.FormatStepData.StepPrintData.PosAdjust ?? 0);
float yLocation = CalculateYOffset(yPageStart, yTopMargin);
Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, "", yBottomMargin);
return yPageStart;
}
}
}