diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index c5c27f0d..de537553 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -507,6 +507,28 @@ namespace VEPROMS.CSLA.Library } LBDocumentClass myDoc = MyApp.Documents.Open(myFile.FullName, false); AdjustMargins(myDocStyle, myDoc, true); + LBSelection selxy = FindXyPlot(); + if (selxy != null) + { + string xyplot = selxy.Text; + xyplot = xyplot.Replace("`", "\xB0"); + selxy.Text = ""; + string pngFile = VlnSettings.TemporaryFolder + @"\XYPlot1.png"; //@"C:\Temp\XYPlot1.png"; + RectangleF plotRect = CreatePlot(pngFile, xyplot, 600F, FormForPlotGraphics); + //LBShape shape = myDoc.Shapes.AddPicture(@"C:\Temp\XYPlot.png", 0, 0, sel.Range); + float x = (float)selxy.get_Information(LBWdInformation.wdHorizontalPositionRelativeToPage); + float y = (float)selxy.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage); + LBRange myRange = selxy.Paragraphs.First.Range; + float yTop = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage); + float yTop1 = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToTextBoundary); + float xAdjust = (float)-sect.MyDocStyle.Layout.LeftMargin; + float yAdjust = selxy.Font.Size; + LBShape shape = myDoc.Shapes.AddPicture(pngFile, x + xAdjust + plotRect.X, yAdjust + y - yTop + plotRect.Y, selxy.Range); + File.Delete(pngFile); + shape.LockAspectRatio = LBMsoTriState.msoTrue; + shape.Width = plotRect.Width; + selxy.WholeStory(); + } LBSelection sel = FindRO(); while (sel != null) { @@ -789,6 +811,30 @@ namespace VEPROMS.CSLA.Library } } } + private static LBSelection FindXyPlot() + { + LBSelection sel = MyApp.Selection; + LBFind find = sel.Find; + find.ClearFormatting(); + // Search string format - this is MSWord wildcard format + // If you do a search in MSWord, make sure wildcard box is checked and then press the + // Special button to see the definitions of the various wildcards + // [<] - Less-Than Character + // [!<> ]@ - 1 or more characters not including Less-Than, Greater-Than or Space + // - Dash + // [!<> ]@ - 1 or more characters not including Less-Than, Greater-Than or Space + // [>] - Greater-Than Character + find.Text = "[<][<]*[>][>]"; + //find.Wrap = LBWdFindWrap.wdFindStop; + find.Wrap = LBWdFindWrap.wdFindContinue; + find.MatchCase = false; + find.MatchWholeWord = false; + find.MatchWildcards = true; + find.MatchSoundsLike = false; + find.MatchAllWordForms = false; + if (find.Execute()) return sel; + return null; + } private static LBSelection FindRO() { LBSelection sel = MyApp.Selection;