From da009a15eb1d8e3fa9535de2eb06385e3b8435a7 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 5 Apr 2012 19:45:28 +0000 Subject: [PATCH] =?UTF-8?q?fixed=20problem=20saving=20margins=20in=20word?= =?UTF-8?q?=20attachment=20=E2=80=93=20can=E2=80=99t=20do=20if=20in=20a=20?= =?UTF-8?q?frame=20sometines=20would=20get=20a=20weird=20file=20name=20for?= =?UTF-8?q?=20the=20opened=20word=20attachment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extension/DocumentExt.cs | 23 +++++++++++++++---- PROMS/Volian.Controls.Library/DSOTabPanel.cs | 6 ++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index 1851c21d..118eebf8 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -526,6 +526,9 @@ namespace VEPROMS.CSLA.Library //ItemInfo sect = doc.DocumentEntries[0].MyContent.ContentItems[0]; return ToPDFReplaceROs(sect, false, roids); } + + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public static string ToPDFReplaceROs(ItemInfo sect, bool openPdf, List roids) //, System.Drawing.Color overrideColor, System.Windows.Forms.Form myForm) { string fileName = GetFileName(sect); @@ -574,7 +577,14 @@ namespace VEPROMS.CSLA.Library } } LBDocumentClass myDoc = MyApp.Documents.Open(myFile.FullName, false); - AdjustMargins(myDocStyle, myDoc, true); + try + { + AdjustMargins(myDocStyle, myDoc, true); + } + catch (Exception ex) + { + _MyLog.Error("Could not Adjust Margins",ex); + } LBSelection selxy = hasRos ? FindXyPlot() : null; while (selxy != null) { @@ -733,10 +743,13 @@ namespace VEPROMS.CSLA.Library //Console.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", newTop, newLeft, newLength, newWidth, oldTop, oldLeft, oldBottom, oldRight,oldHeight,oldWidth); if (printingMode) { - myDoc.PageSetup.BottomMargin = 0;// 11 * 72 - (newTop + newLength); - myDoc.PageSetup.RightMargin = newRight; - myDoc.PageSetup.LeftMargin = newLeft; - myDoc.PageSetup.TopMargin = newTop; + if (myDoc.PageSetup.BottomMargin != 9999999) + { + myDoc.PageSetup.BottomMargin = 0; // 11 * 72 - (newTop + newLength); + myDoc.PageSetup.RightMargin = newRight; + myDoc.PageSetup.LeftMargin = newLeft; + myDoc.PageSetup.TopMargin = newTop; + } } else { diff --git a/PROMS/Volian.Controls.Library/DSOTabPanel.cs b/PROMS/Volian.Controls.Library/DSOTabPanel.cs index 0dde99d1..bef50d45 100644 --- a/PROMS/Volian.Controls.Library/DSOTabPanel.cs +++ b/PROMS/Volian.Controls.Library/DSOTabPanel.cs @@ -324,7 +324,11 @@ namespace Volian.Controls.Library return; } LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument); - MyDSOFile.FullName = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName"); + string tmp = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName"); + if (System.IO.File.Exists(tmp)) + MyDSOFile.FullName = tmp; + else + _MyLog.FatalFormat("File does not exist {0}\r\nFile was {1}", tmp, MyDSOFile.FullName); // if this was a library document, ask user if it should be saved for all usages. bool cvtLibDoc = false; EntryInfo myei = MyDisplayTabItem.MyItemInfo.MyContent.MyEntry;