This commit is contained in:
Kathy Ruffing 2012-03-30 11:00:47 +00:00
parent 7f240997df
commit 8ad09e674f

View File

@ -110,7 +110,7 @@ namespace Volian.Print.Library
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)
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;
@ -120,6 +120,7 @@ namespace Volian.Print.Library
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");
@ -128,30 +129,63 @@ namespace Volian.Print.Library
else if ((myparent.MyItemInfo.FormatStepData != null) && (myparent.MyItemInfo.FormatStepData.TabData.IdentWidth ?? 0) > 0)
Width = (float)myparent.MyItemInfo.FormatStepData.TabData.IdentWidth;
else if (CCCs != IIIs)
Width = Text.Length * 6; //proportial font (7 chars * 6)
{
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.
// Tested for FPL & NSP
Width = 6 * (4+origTab1.Trim(" ".ToCharArray()).Length);
}
else
Width = GetTextWidth(MyFont, (Text != null ? Text : origTab), symblFontName);//MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length);
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 (MyParent.MyItemInfo.ItemID == 108)//120)
// Console.WriteLine("here");
if (origTab.Contains(@"{!"))
{
int mindx = origTab.IndexOf(@"{!");
int meindx = origTab.IndexOf(@"}", mindx);
string macro = origTab.Substring(mindx, meindx - mindx+1);
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);
MyMacro = new vlnMacro(xoffset - lwidth, yoffset, macro.Substring(2, macro.Length - 3));
origTab = origTab.Replace(macro,"");
origTab = origTab + " ";
//WCN Needs lwidth with -1 commented out:
//float lwidth = MyFont.CharsToTwips * (origTab.Length - meindx); // - 1);
// FPL, RGE Needs lwidth with -1
float lwidth = MyFont.CharsToTwips * (origTab.Length - meindx - 1);
//MyMacro = new vlnMacro(-2+xoffset - lwidth, yoffset, macro.Substring(2, macro.Length - 3)); // NSP
//MyMacro = new vlnMacro(30 + xoffset - lwidth, yoffset, macro.Substring(2, macro.Length - 3)); // TP
MyMacro = new vlnMacro(xoffset - lwidth, yoffset, macro.Substring(2, macro.Length - 3)); // WCN
origTab = origTab.Replace(macro, "");
//WCN Needs origTab = origTab + " ");
//origTab = origTab + " ";
//RGE tabs are too far over with origTab = origTab + " ";
// FPL does adjustment below:
cleanTab = origTab;
if (CCCs != IIIs)
Width = cleanTab.Length * 6; //proportial font (7 chars * 6)
{
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.
if (myparent.MyItemInfo.ItemID == 588) Console.WriteLine("here");
if (removedUnderline)
{
int sep = origTab.IndexOfAny(". ".ToCharArray());
origTab = @"\ul " + origTab.Substring(0, sep-1) + @"\ulnone" + origTab.Substring(sep-1);
}
Rtf = GetRtf(origTab, vFont);
Rtf = Rtf.Replace("\u0394", @"\f1\u916?\f0 "); // delta 0x0394
if (ScriptCaution)
@ -221,6 +255,8 @@ namespace Volian.Print.Library
}
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, 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;