diff --git a/PROMS/VEPROMS User Interface/frmSectionProperties.cs b/PROMS/VEPROMS User Interface/frmSectionProperties.cs index 86ba8592..ee6fde96 100644 --- a/PROMS/VEPROMS User Interface/frmSectionProperties.cs +++ b/PROMS/VEPROMS User Interface/frmSectionProperties.cs @@ -123,7 +123,7 @@ namespace VEPROMS Content cont = Content.Get(sectinfo.MyContent.ContentID); Byte[] tstbyte = System.Text.Encoding.Default.GetBytes(""); - Document doc = Document.MakeDocument(null, tstbyte, null, null, null); // tstbyte, null, null, null); + Document doc = Document.MakeDocument(null, tstbyte, null, null); // tstbyte, null, null, null); Entry entry = cont.MyEntry; entry.MyDocument = Document.Get(doc.DocID); cont.Save().Dispose(); @@ -476,7 +476,7 @@ namespace VEPROMS { // make new document with 'no' libtitle - use libtitle for the doc title. Then link this // to the item... - Document doc = Document.MakeDocument(null, doclibinfo.DocContent, doclibinfo.DocAscii, doclibinfo.Config, doclibinfo.DocPdf); + Document doc = Document.MakeDocument(null, doclibinfo.DocContent, doclibinfo.DocAscii, doclibinfo.Config); _SectionConfig.MySection.MyContent.MyEntry.MyDocument = doc; } ppCmbxLibDoc.Items.Clear(); diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 963284a4..fbabc4ed 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -132,7 +132,15 @@ namespace VEPROMS // When creating an XY Plot, a System.Drawing.Graphics is needed and it requires a form. Use the main // form. if (VlnSettings.DebugMode) + { + MSWordToPDF.DebugStatus = 1; MSWordToPDF.OverrideColor = Color.Red; + } + else + { + MSWordToPDF.DebugStatus = 0; + MSWordToPDF.OverrideColor = Color.Transparent; + } MSWordToPDF.FormForPlotGraphics = this; // set the color of the ribbon diff --git a/PROMS/VEPROMS.CSLA.Library/Config/DocumentConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/DocumentConfig.cs index 525a6ed3..48651481 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/DocumentConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/DocumentConfig.cs @@ -67,39 +67,40 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("LibDoc_Comment"); } } - [Category("Printing")] - [DisplayName("Length")] - [Description("Length of Document in Full and Partial Pages")] - public float Printing_Length - { - get - { - string s = _Xp["Printing", "Length"];// get the saved value + // RHM 20110415 - These are now stored in the PDF table. + //[Category("Printing")] + //[DisplayName("Length")] + //[Description("Length of Document in Full and Partial Pages")] + //public float Printing_Length + //{ + // get + // { + // string s = _Xp["Printing", "Length"];// get the saved value - return float.Parse(s); - } - set - { - _Xp["Printing", "Length"] = string.Format("{0:0.0000}", value); - OnPropertyChanged("Printing_Length"); - } - } - [Category("Printing")] - [DisplayName("Color")] - [Description("Color of Document Text")] - public Color Printing_Color - { - get - { - string sColor = _Xp["Printing", "Color"]; - return ColorConfig.ColorFromString(sColor); - } - set - { - _Xp["Printing", "Color"] = value.ToString(); - OnPropertyChanged("Printing_Color"); - } - } + // return float.Parse(s); + // } + // set + // { + // _Xp["Printing", "Length"] = string.Format("{0:0.0000}", value); + // OnPropertyChanged("Printing_Length"); + // } + //} + //[Category("Printing")] + //[DisplayName("Color")] + //[Description("Color of Document Text")] + //public Color Printing_Color + //{ + // get + // { + // string sColor = _Xp["Printing", "Color"]; + // return ColorConfig.ColorFromString(sColor); + // } + // set + // { + // _Xp["Printing", "Color"] = value.ToString(); + // OnPropertyChanged("Printing_Color"); + // } + //} #endregion #region ToString public override string ToString() diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index 3b37fe20..6ad33e4f 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -294,7 +294,7 @@ namespace VEPROMS.CSLA.Library _MyFile = new FileInfo(value); } } - public void SaveFile(float length,string ascii) + public void SaveFile(float length,string ascii,ItemInfo myItemInfo) { // TODO: Add Try & Catch logic if (_MyDocument == null) return; @@ -308,21 +308,22 @@ namespace VEPROMS.CSLA.Library doc.DocAscii = ascii; //doc.UpdateDocAscii(_MyFile.FullName); DocumentConfig cfg = new DocumentConfig(doc); - cfg.Printing_Length = length; - cfg.Printing_Color = MSWordToPDF.OverrideColor; doc.Config = cfg.ToString(); doc.UserID = Volian.Base.Library.VlnSettings.UserID; doc.DTS = _MyFile.LastWriteTime; - doc.Save(); + doc = doc.Save(); List roids = new List(); - string pdfTmp = MSWordToPDF.ToPDFReplaceROs(_MyDocument,roids); + string pdfTmp = MSWordToPDF.ToPDFReplaceROs(_MyDocument,roids,myItemInfo); FileInfo pdfFile = new FileInfo(pdfTmp); fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite); buf = new byte[pdfFile.Length]; fs.Read(buf, 0, buf.Length); fs.Close(); pdfFile.Delete(); - doc.DocPdf = buf; + Pdf.DeleteAll(doc.DocID); // clear the PDF table for DocID first + DocStyle myDocStyle = myItemInfo.MyActiveSection.MyDocStyle; + using (Pdf myPdf = Pdf.MakePdf(doc, MSWordToPDF.DebugStatus, (int) myDocStyle.Layout.TopRow, (int) myDocStyle.Layout.PageLength, + (int) myDocStyle.Layout.LeftMargin, (int) myDocStyle.Layout.PageWidth, (double)myItemInfo.MSWordPageCount, buf)) { ;} doc.UpdateDRoUsages(roids); doc.Save(); } @@ -372,6 +373,12 @@ namespace VEPROMS.CSLA.Library return _MyApp; } } + private static int _DebugStatus = 0; + public static int DebugStatus + { + get { return MSWordToPDF._DebugStatus; } + set { MSWordToPDF._DebugStatus = value; } + } private static System.Drawing.Color _OverrideColor = System.Drawing.Color.Transparent; public static System.Drawing.Color OverrideColor { @@ -387,31 +394,29 @@ namespace VEPROMS.CSLA.Library public static string GetDocPdf(SectionInfo sect, Color overrideColor) { DocumentInfo mydoc = sect.MyContent.MyEntry.MyDocument; - UpdateDocPdf(mydoc, overrideColor); + UpdateDocPdf(mydoc, overrideColor,sect); string fileName = GetFileName(sect); FileInfo fi = new FileInfo(fileName); FileStream fs = fi.Create(); - if (mydoc.DocPdf!=null)fs.Write(mydoc.DocPdf, 0, mydoc.DocPdf.Length); + PdfInfo myPdf = PdfInfo.Get(sect); + if (myPdf != null && myPdf.DocPdf != null) fs.Write(myPdf.DocPdf, 0, myPdf.DocPdf.Length); fs.Close(); return fileName; } - public static bool UpdateDocPdf(DocumentInfo mydoc, Color overrideColor) + public static bool UpdateDocPdf(DocumentInfo mydoc, Color overrideColor, ItemInfo sect) { - if (mydoc.DocPdf == null || overrideColor.ToArgb() != mydoc.DocumentConfig.Printing_Color.ToArgb()) - { - MSWordToPDF.OverrideColor = overrideColor; - return SetDocPdf(mydoc); - } + MSWordToPDF.OverrideColor = overrideColor; + PdfInfo myPdf = PdfInfo.Get(sect); return true; } - public static bool SetDocPdf(DocumentInfo docInfo) + public static bool SetDocPdf(DocumentInfo docInfo, ItemInfo sect) { string pdfTmp = null; List roids = new List(); try { - pdfTmp = MSWordToPDF.ToPDFReplaceROs(docInfo,roids); + pdfTmp = MSWordToPDF.ToPDFReplaceROs(docInfo,roids,sect); } catch (Exception ex) { @@ -426,19 +431,18 @@ namespace VEPROMS.CSLA.Library pdfFile.Delete(); using (Document doc = docInfo.Get()) { - DocumentConfig dc = new DocumentConfig(doc); - dc.Printing_Color = MSWordToPDF.OverrideColor; - doc.Config = dc.ToString(); - doc.DocPdf = buf; + DocStyle myDocStyle = sect.MyActiveSection.MyDocStyle; + using (Pdf myPdf = Pdf.MakePdf(doc, MSWordToPDF.DebugStatus, (int)myDocStyle.Layout.TopRow, (int)myDocStyle.Layout.PageLength, + (int)myDocStyle.Layout.LeftMargin, (int)myDocStyle.Layout.PageWidth, (double)sect.MSWordPageCount, buf)) { ;} doc.UpdateDRoUsages(roids); doc.Save(); } docInfo.RefreshConfig(); return true; } - public static string ToPDFReplaceROs(DocumentInfo doc,List roids) + public static string ToPDFReplaceROs(DocumentInfo doc,List roids, ItemInfo sect) { - ItemInfo sect = doc.DocumentEntries[0].MyContent.ContentItems[0]; + //ItemInfo sect = doc.DocumentEntries[0].MyContent.ContentItems[0]; return ToPDFReplaceROs(sect, false, roids); } public static string ToPDFReplaceROs(ItemInfo sect, bool openPdf, List roids) //, System.Drawing.Color overrideColor, System.Windows.Forms.Form myForm) @@ -588,6 +592,7 @@ namespace VEPROMS.CSLA.Library sel.Range.Font.Color = (LBWdColor)WordColor(OverrideColor == System.Drawing.Color.Transparent ? System.Drawing.Color.Black : OverrideColor); sel.ParagraphFormat.LineSpacingRule = LBWdLineSpacing.wdLineSpaceExactly; sel.ParagraphFormat.LineSpacing = 12; + sect.MSWordPageCount = myDoc.Length; fileName = CreatePDF(fileName, openPdf); MyApp.ActiveDocument.Close(false); if (CloseWordWhenDone) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 7bca80db..27eab4f9 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -297,6 +297,12 @@ namespace VEPROMS.CSLA.Library // return ii._ItemID == _ItemID; // return false; //} + private float _MSWordPageCount = 0; + public float MSWordPageCount + { + get { return _MSWordPageCount; } + set { _MSWordPageCount = value; } + } public event ItemInfoEvent OrdinalChanged; private void OnOrdinalChange() { diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs index 0e2df799..d471d731 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs @@ -247,14 +247,16 @@ namespace VEPROMS.CSLA.Library { foreach (DROUsageInfo droUsg in affected) { - using (Document document = Document.Get(droUsg.DocID)) - { - if (document.DocPdf != null) - { - document.DocPdf = null; - document.Save(); - } - } + //using (Document document = Document.Get(droUsg.DocID)) + //{ + Pdf.DeleteAll(droUsg.DocID); + // Delete PDFs + //if (document.DocPdf != null) + //{ + // document.DocPdf = null; + // document.Save(); + //} + //} } } }