Added ( and Page Size) to the section property dialog for the checkbox to use MS Word Margins.
Changed logic for embedding ROs (Tables, Plots and Images) within a MSWord section. If the Word Section is set to use MSWord Margins (and Page Size) the locations of the embeded ROs will be determined from the physical location on the page rather than the offset from the margins.
This commit is contained in:
parent
7572b4cafb
commit
5d2b0bc1b0
@ -987,7 +987,7 @@ namespace VEPROMS
|
|||||||
this.cbKeepWordDocMargins.Name = "cbKeepWordDocMargins";
|
this.cbKeepWordDocMargins.Name = "cbKeepWordDocMargins";
|
||||||
this.cbKeepWordDocMargins.Size = new System.Drawing.Size(223, 21);
|
this.cbKeepWordDocMargins.Size = new System.Drawing.Size(223, 21);
|
||||||
this.cbKeepWordDocMargins.TabIndex = 59;
|
this.cbKeepWordDocMargins.TabIndex = 59;
|
||||||
this.cbKeepWordDocMargins.Text = "Keep Word Document Margins";
|
this.cbKeepWordDocMargins.Text = "Keep Word Document Margins (and Page Size)";
|
||||||
this.cbKeepWordDocMargins.UseVisualStyleBackColor = false;
|
this.cbKeepWordDocMargins.UseVisualStyleBackColor = false;
|
||||||
this.cbKeepWordDocMargins.Visible = false;
|
this.cbKeepWordDocMargins.Visible = false;
|
||||||
this.cbKeepWordDocMargins.CheckedChanged += new System.EventHandler(this.cbKeepWordDocMargins_CheckedChanged);
|
this.cbKeepWordDocMargins.CheckedChanged += new System.EventHandler(this.cbKeepWordDocMargins_CheckedChanged);
|
||||||
|
@ -720,6 +720,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
LBDocumentClass myDoc = MyApp.Documents.Open(myFile.FullName, false);
|
LBDocumentClass myDoc = MyApp.Documents.Open(myFile.FullName, false);
|
||||||
|
//MyApp.Visible = true;
|
||||||
|
bool adjustMargins = true; // Use positions relative to margins
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SectionConfig sc = sect.ActiveSection.MyConfig as SectionConfig;
|
SectionConfig sc = sect.ActiveSection.MyConfig as SectionConfig;
|
||||||
@ -727,6 +729,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
AdjustMargins(myDocStyle, myDoc, true);
|
AdjustMargins(myDocStyle, myDoc, true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
adjustMargins = false; // Use absolute positions
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -754,11 +758,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
// Setting the selected text to "" actually sets it to "\r", thus cnt-- (subtract one
|
// Setting the selected text to "" actually sets it to "\r", thus cnt-- (subtract one
|
||||||
// from cnt since there's already a return in the string.
|
// from cnt since there's already a return in the string.
|
||||||
cnt--;
|
cnt--;
|
||||||
float x = (float)selxy.get_Information(LBWdInformation.wdHorizontalPositionRelativeToPage);
|
float x = adjustMargins ? (float)selxy.get_Information(LBWdInformation.wdHorizontalPositionRelativeToTextBoundary) :
|
||||||
float y = (float)selxy.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);
|
(float)selxy.get_Information(LBWdInformation.wdHorizontalPositionRelativeToPage);
|
||||||
|
float y = adjustMargins ? (float)selxy.get_Information(LBWdInformation.wdVerticalPositionRelativeToTextBoundary) :
|
||||||
|
(float)selxy.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);
|
||||||
LBRange myRange = selxy.Paragraphs.First.Range;
|
LBRange myRange = selxy.Paragraphs.First.Range;
|
||||||
float yTop = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);
|
float yTop = adjustMargins ?(float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToTextBoundary) :
|
||||||
float yTop1 = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToTextBoundary);
|
(float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);
|
||||||
|
//float yTop1 = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToTextBoundary);
|
||||||
|
|
||||||
// some data had regular text embedded in the xyplot definition. If so, the plain text must
|
// some data had regular text embedded in the xyplot definition. If so, the plain text must
|
||||||
// be left in the file. Otherwise, we can replace with empty text.
|
// be left in the file. Otherwise, we can replace with empty text.
|
||||||
@ -781,7 +788,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
filecount++;
|
filecount++;
|
||||||
RectangleF plotRect = CreatePlot(pngFile, xyplot, 600F, FormForPlotGraphics);
|
RectangleF plotRect = CreatePlot(pngFile, xyplot, 600F, FormForPlotGraphics);
|
||||||
|
|
||||||
float xAdjust = (float)-sect.MyDocStyle.Layout.LeftMargin;
|
float xAdjust = 0; //(float)-sect.MyDocStyle.Layout.LeftMargin;
|
||||||
float yAdjust = selxy.Font.Size;
|
float yAdjust = selxy.Font.Size;
|
||||||
LBShape shape = myDoc.Shapes.AddPicture(pngFile, x + xAdjust + plotRect.X, yAdjust + y - yTop + plotRect.Y, selxy.Range);
|
LBShape shape = myDoc.Shapes.AddPicture(pngFile, x + xAdjust + plotRect.X, yAdjust + y - yTop + plotRect.Y, selxy.Range);
|
||||||
File.Delete(pngFile);
|
File.Delete(pngFile);
|
||||||
@ -845,15 +852,25 @@ namespace VEPROMS.CSLA.Library
|
|||||||
float width = 72 * Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) / 12.0F;
|
float width = 72 * Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) / 12.0F;
|
||||||
int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier);
|
int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier);
|
||||||
float height = 72 * lines / 6.0F;
|
float height = 72 * lines / 6.0F;
|
||||||
float x = (float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToTextBoundary);
|
float x = adjustMargins ? (float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToTextBoundary):
|
||||||
|
(float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToPage);
|
||||||
// 9.25 is the approximate offset of the base line of the font, i.e. doesn't include descender.
|
// 9.25 is the approximate offset of the base line of the font, i.e. doesn't include descender.
|
||||||
float locvertpage = (float)sel.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);
|
float locvertpage = adjustMargins ? (float)sel.get_Information(LBWdInformation.wdVerticalPositionRelativeToTextBoundary) :
|
||||||
|
(float)sel.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);
|
||||||
float y = locvertpage + ((sel.Font.Size * 9.25F) / 12);
|
float y = locvertpage + ((sel.Font.Size * 9.25F) / 12);
|
||||||
sel.Text = "";
|
sel.Text = "";
|
||||||
LBShape shape = myDoc.Shapes.AddPicture(roImageFile.MyFile.FullName, x, y, sel.Range);
|
LBShape shape = myDoc.Shapes.AddPicture(roImageFile.MyFile.FullName, x, y, sel.Range);
|
||||||
shape.RelativeVerticalPosition = LBWdRelativeVerticalPosition.wdRelativeVerticalPositionPage;
|
if (adjustMargins)
|
||||||
|
{
|
||||||
|
shape.RelativeVerticalPosition = LBWdRelativeVerticalPosition.wdRelativeVerticalPositionMargin;
|
||||||
|
shape.RelativeHorizontalPosition = LBWdRelativeHorizontalPosition.wdRelativeHorizontalPositionMargin;// .wdRelativeHorizontalPositionMargin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shape.RelativeVerticalPosition = LBWdRelativeVerticalPosition.wdRelativeVerticalPositionPage;
|
||||||
|
shape.RelativeHorizontalPosition = LBWdRelativeHorizontalPosition.wdRelativeHorizontalPositionPage;// .wdRelativeHorizontalPositionMargin;
|
||||||
|
}
|
||||||
shape.Top = y; // Reset value after setting flag RelativeVerticalPosition
|
shape.Top = y; // Reset value after setting flag RelativeVerticalPosition
|
||||||
shape.RelativeHorizontalPosition = LBWdRelativeHorizontalPosition.wdRelativeHorizontalPositionMargin;
|
|
||||||
shape.Left = x;
|
shape.Left = x;
|
||||||
shape.Width = width;
|
shape.Width = width;
|
||||||
shape.Height = height;
|
shape.Height = height;
|
||||||
@ -880,9 +897,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//_MyLog.WarnFormat("PNG Name = {0}, size = {1}", fi.Name, fi.Length);
|
//_MyLog.WarnFormat("PNG Name = {0}, size = {1}", fi.Name, fi.Length);
|
||||||
|
|
||||||
//LBShape shape = myDoc.Shapes.AddPicture(@"C:\Temp\XYPlot.png", 0, 0, sel.Range);
|
//LBShape shape = myDoc.Shapes.AddPicture(@"C:\Temp\XYPlot.png", 0, 0, sel.Range);
|
||||||
float x = (float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToPage);
|
float x = adjustMargins ? (float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToTextBoundary) :
|
||||||
|
(float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToPage);
|
||||||
float y = (float)sel.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);
|
float y = adjustMargins ? (float)sel.get_Information(LBWdInformation.wdVerticalPositionRelativeToTextBoundary):
|
||||||
|
(float)sel.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);
|
||||||
// if there is regular text before the plot, then count the number of lines
|
// if there is regular text before the plot, then count the number of lines
|
||||||
// and adjust the y position accordingly
|
// and adjust the y position accordingly
|
||||||
int idx = sel.Text.IndexOf("\r");
|
int idx = sel.Text.IndexOf("\r");
|
||||||
@ -893,9 +911,9 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
//LBInlineShape shape = sel.InlineShapes.AddPicture(pngFile);
|
//LBInlineShape shape = sel.InlineShapes.AddPicture(pngFile);
|
||||||
LBRange myRange = sel.Paragraphs.First.Range;
|
LBRange myRange = sel.Paragraphs.First.Range;
|
||||||
float yTop = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);
|
float yTop = adjustMargins ? (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToTextBoundary) :
|
||||||
float yTop1 = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToTextBoundary);
|
(float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);
|
||||||
float xAdjust = (float)-sect.MyDocStyle.Layout.LeftMargin;
|
float xAdjust = 0;// = (float)-sect.MyDocStyle.Layout.LeftMargin;
|
||||||
float yAdjust = sel.Font.Size;
|
float yAdjust = sel.Font.Size;
|
||||||
// The following two lines made the xyplot location for WCN2 match the 16bit output. However, how the
|
// The following two lines made the xyplot location for WCN2 match the 16bit output. However, how the
|
||||||
// xTweak value is determined is phantom of Rich's mind. Word document location of the RO token
|
// xTweak value is determined is phantom of Rich's mind. Word document location of the RO token
|
||||||
@ -904,6 +922,20 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//LBShape shape = myDoc.Shapes.AddPicture(pngFile, x + xAdjust + plotRect.X + xTweak, yAdjust + y - yTop + plotRect.Y, sel.Range);
|
//LBShape shape = myDoc.Shapes.AddPicture(pngFile, x + xAdjust + plotRect.X + xTweak, yAdjust + y - yTop + plotRect.Y, sel.Range);
|
||||||
LBShape shape = myDoc.Shapes.AddPicture(pngFile, x + xAdjust + plotRect.X, yAdjust + y - yTop + plotRect.Y, sel.Range);
|
LBShape shape = myDoc.Shapes.AddPicture(pngFile, x + xAdjust + plotRect.X, yAdjust + y - yTop + plotRect.Y, sel.Range);
|
||||||
File.Delete(pngFile);
|
File.Delete(pngFile);
|
||||||
|
//shape.RelativeHorizontalPosition = LBWdRelativeHorizontalPosition.wdRelativeHorizontalPositionPage;// .wdRelativeHorizontalPositionMargin;
|
||||||
|
if (adjustMargins)
|
||||||
|
{
|
||||||
|
shape.RelativeVerticalPosition = LBWdRelativeVerticalPosition.wdRelativeVerticalPositionMargin;
|
||||||
|
shape.RelativeHorizontalPosition = LBWdRelativeHorizontalPosition.wdRelativeHorizontalPositionMargin;// .wdRelativeHorizontalPositionMargin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shape.RelativeVerticalPosition = LBWdRelativeVerticalPosition.wdRelativeVerticalPositionPage;
|
||||||
|
shape.RelativeHorizontalPosition = LBWdRelativeHorizontalPosition.wdRelativeHorizontalPositionPage;// .wdRelativeHorizontalPositionMargin;
|
||||||
|
}
|
||||||
|
shape.Left = x + xAdjust + plotRect.X;
|
||||||
|
//shape.Top = yAdjust + y - yTop + plotRect.Y;
|
||||||
|
shape.Top = yAdjust + y + plotRect.Y;
|
||||||
shape.LockAspectRatio = LBMsoTriState.msoTrue;
|
shape.LockAspectRatio = LBMsoTriState.msoTrue;
|
||||||
//shape.Width = .89F * shape.Width;
|
//shape.Width = .89F * shape.Width;
|
||||||
//shape.Width = float.Parse(tbAdjust.Text) * shape.Width;
|
//shape.Width = float.Parse(tbAdjust.Text) * shape.Width;
|
||||||
@ -933,7 +965,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
//AddInfo("\tRO Found {0} = '{1}'", sel.Text, val);
|
//AddInfo("\tRO Found {0} = '{1}'", sel.Text, val);
|
||||||
// if val is null, then InsertROValue will put in "RO Not Found" for the value
|
// if val is null, then InsertROValue will put in "RO Not Found" for the value
|
||||||
float indent = (float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToPage) - (float)sect.MyDocStyle.Layout.LeftMargin;;
|
float indent = (float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToTextBoundary);
|
||||||
InsertROValue(sel, val, sect.ActiveFormat.PlantFormat.FormatData.ROData.UpRoIfPrevUpper, indent);
|
InsertROValue(sel, val, sect.ActiveFormat.PlantFormat.FormatData.ROData.UpRoIfPrevUpper, indent);
|
||||||
}
|
}
|
||||||
sel = FindRO();
|
sel = FindRO();
|
||||||
@ -1060,7 +1092,17 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (val.IndexOf("_") == -1) // Is some of the text underlined?
|
if (val.IndexOf("_") == -1) // Is some of the text underlined?
|
||||||
{
|
{
|
||||||
sel.Text = val; // nothing is underlined, use text as is
|
if (val.Contains("\r\n"))
|
||||||
|
{
|
||||||
|
int ind = val.IndexOf("\r\n");
|
||||||
|
sel.TypeText(val.Substring(1, ind + 2));
|
||||||
|
sel.Text = val.Substring(ind + 2);
|
||||||
|
sel.ParagraphFormat.LeftIndent = indent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sel.Text = val; // nothing is underlined, use text as is
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Back in the DOS days, an underbar was used to toggle underlining on/off
|
// Back in the DOS days, an underbar was used to toggle underlining on/off
|
||||||
|
Loading…
x
Reference in New Issue
Block a user