Added logic to handle cases when and RO value contains an X/Y Plot but with text before the plot language

fixed bad indexes - inserting the superscript On/Off commands
This commit is contained in:
John Jenko 2013-04-23 15:42:02 +00:00
parent fb4fbeefc4
commit 3dfb222834
2 changed files with 14 additions and 2 deletions

View File

@ -723,7 +723,11 @@ namespace VEPROMS.CSLA.Library
try
{
val = val.Replace("`", "\xB0");
sel.Text = "";
//sel.Text = "";
// An X/Y Plot RO type might have text preceding the Plot Commands
int pstart = val.IndexOf("<<G"); // find the starting Plot Command
sel.Text = val.Substring(0, pstart); // replace the RO token with what's in front of the X/Y Plot
val = val.Substring(pstart); // set val to the start of the plot commands
//float width = 72 * Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) / 12.0F;
//float height = 72 * lines / 6.0F;
string pngFile = VlnSettings.TemporaryFolder + @"\XYPlot1.png"; //@"C:\Temp\XYPlot1.png";
@ -732,6 +736,14 @@ namespace VEPROMS.CSLA.Library
float x = (float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToPage);
float y = (float)sel.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);
// if there is regular text before the plot, then count the number of lines
// and adjust the y position accordingly
int idx = sel.Text.IndexOf("\r");
while ((idx>0) && (idx < sel.Text.Length+1))
{
idx = sel.Text.IndexOf("\r", idx + 1);
y += (float)sel.ParagraphFormat.LineSpacing; // get_Information(LBWdLineSpacing.wdLineSpaceSingle);
}
//LBInlineShape shape = sel.InlineShapes.AddPicture(pngFile);
LBRange myRange = sel.Paragraphs.First.Range;
float yTop = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);

View File

@ -915,7 +915,7 @@ namespace XYPlots
private int addpower(int i)
{
int tlen;
powerstring = string.Format("x10{0}{1}{2}", SuperScript[1], i.ToString(), SuperScript[2]);
powerstring = string.Format("x10{0}{1}{2}", SuperScript[0], i.ToString(), SuperScript[1]);
valuestring = valuestring + powerstring;
tlen = SuperScript[0].Length + SuperScript[1].Length;
return (powerstring.Length - tlen);