diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs
index fab71599..9267e2cb 100644
--- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs
+++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs
@@ -160,6 +160,78 @@ namespace VEPROMS.CSLA.Library
}
}
}
+
+ // B2023-093 This method is called before editing or printing a Word section and will convert it the Word .DOCX format if needed.
+ // Note that the core logic was taken from frmSectionProperties.cs and modified to convert both .RTF and .DOC files
+ // The conversion to DOCX is needs to be done only one time per Word section
+ public static void ConvertWordSectionToDOCX(ItemInfo itmInfo)
+ {
+ // check the Word file extension that is saved in the tblDocuments SQL database table
+ DocumentInfo docInfo = itmInfo.MyContent.MyEntry.MyDocument;
+ if (docInfo.FileExtension.ToUpper() == ".DOCX") return; // already a DOCX - no need to convert
+
+ // show user a status window of the Word section being converted to DOCX
+ // use the section number (DisplayNumber) unless the length is zero, then use the section title (DisplayText)
+ string statMsg = itmInfo.DisplayNumber;
+ if (statMsg.Length == 0)
+ statMsg = itmInfo.DisplayText;
+ FrmPopupStatusMessage pmsg = new FrmPopupStatusMessage("Converting This Section to Word DOCX", statMsg);
+ pmsg.Show();
+
+ // Get Document as file - it's placed in the user's temporary folder (like we do when we edit a Word section)
+ DSOFile myfile = new DSOFile(docInfo);
+
+ // Open MSWord App
+ LBWordLibrary.LBApplicationClass ap = new LBWordLibrary.LBApplicationClass();
+ LBWordLibrary.LBDocumentClass doc = ap.Documents.Open(myfile.FullName);
+
+ // Older versions of PROMS saved the Word section as either a RTF or the old-style Word DOC file
+ // In either case, we want to convert it to a Word DOCX file
+ // So now create a file name with the .DOCX extension
+ string orgFilename = myfile.FullName.ToUpper();
+ string filename = orgFilename.Replace(".RTF", ".DOCX").Replace(".DOC", ".DOCX"); // we want to convert either .RTF or .DOC Word sections
+
+ // This calls Word's convert function to convert the opened .DOC or .RTF to DOCX and save it to our new DOCX file name
+ doc.SaveAs(filename, LBWordLibrary.LBWdSaveFormat.wdFormatXMLDocument); // Convert to Word DOCX
+ doc.Close();
+ ap.Quit(); // close the Word app
+
+ // Now read in the new .DOCX file and save the contents to the SQL database
+ FileInfo fi = new FileInfo(filename);
+ FileStream fs = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);// B2016-053
+ long len = fs.Length;
+ byte[] ByteArray = new byte[len];
+ int nBytesRead = fs.Read(ByteArray, 0, (int)len);
+ fs.Close();
+
+ bool isLibraryDocument = (docInfo.LibTitle != null && docInfo.LibTitle != "");
+ Document myDoc = null;
+ if (isLibraryDocument)
+ myDoc = Document.Get(docInfo.DocID);
+ else
+ myDoc = Document.MakeDocument(null, ByteArray, docInfo.DocAscii, docInfo.Config, ".DOCX");
+
+ // update the document information in the database
+ SectionInfo msi = itmInfo as SectionInfo;
+ Section sec = msi.Get();
+ SectionConfig cfg = sec.SectionConfig;
+ if (!isLibraryDocument)
+ cfg.MySection.MyContent.MyEntry.MyDocument = myDoc; // resetting MyDocument will clear the library doc link - so don't do if a library document
+ else
+ cfg.MySection.MyContent.MyEntry.MyDocument.DocContent = ByteArray; // only update .DocContent for library documents
+ cfg.MySection.MyContent.MyEntry.MyDocument.FileExtension = ".DOCX"; // make sure the Word file extension is .DOCX
+ cfg.MySection.MyContent.MyEntry.MyDocument.DTS = fi.LastWriteTimeUtc;
+ cfg.MySection.MyContent.MyEntry.MyDocument.MarkDirty();
+ cfg.MySection.MyContent.MyEntry.Save();
+
+ _MyLog.InfoFormat("Converted Word Section to DOCX - Old ID {0} - New ID {1} - {2}", docInfo.DocID, myDoc.DocID, statMsg); // record in log file (aka error log) that conversion was done
+ // delete the temporary files
+ fi.Delete();// delete the temporary .DOCX file
+ FileInfo orgFile = new FileInfo(orgFilename);
+ orgFile.Delete();// delete the old temporary Word file (.DOC or .RTF)
+ pmsg.Close(); // close the statue message
+ }
+
///
/// FixString processes the string returned and changes any symbols (0xF0??) to normal characters
///
diff --git a/PROMS/Volian.Base.Library/FrmPopupStatusMessage.Designer.cs b/PROMS/Volian.Base.Library/FrmPopupStatusMessage.Designer.cs
new file mode 100644
index 00000000..eb355a93
--- /dev/null
+++ b/PROMS/Volian.Base.Library/FrmPopupStatusMessage.Designer.cs
@@ -0,0 +1,72 @@
+
+namespace Volian.Base.Library
+{
+ partial class FrmPopupStatusMessage
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.popMsg = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // popMsg
+ //
+ this.popMsg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
+ this.popMsg.Location = new System.Drawing.Point(13, 13);
+ this.popMsg.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.popMsg.Name = "popMsg";
+ this.popMsg.Size = new System.Drawing.Size(536, 16);
+ this.popMsg.TabIndex = 0;
+ this.popMsg.Text = "label1";
+ this.popMsg.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.popMsg.UseWaitCursor = true;
+ //
+ // FrmPopupStatusMessage
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+ this.ClientSize = new System.Drawing.Size(562, 38);
+ this.ControlBox = false;
+ this.Controls.Add(this.popMsg);
+ this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "FrmPopupStatusMessage";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "FrmPopupStatusMessage";
+ this.TopMost = true;
+ this.UseWaitCursor = true;
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label popMsg;
+ }
+}
\ No newline at end of file
diff --git a/PROMS/Volian.Base.Library/FrmPopupStatusMessage.cs b/PROMS/Volian.Base.Library/FrmPopupStatusMessage.cs
new file mode 100644
index 00000000..4894102e
--- /dev/null
+++ b/PROMS/Volian.Base.Library/FrmPopupStatusMessage.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Volian.Base.Library
+{
+ public partial class FrmPopupStatusMessage : Form
+ {
+ // This creates a simple message box consisting of a title and the message
+ // The purpose is to allow the coder to pop up brief status message during the running of a method for a 3rd party.
+ // i.e. this is used when PROMS uses Word to convert to a DOCX file format for PROMS Word sections.
+ // The message is centered in the message box - we can expand on this class if needed
+ // The coder uses the Show method to display the message box and Close to remove it
+ // The user is not prompted for a response.
+ public FrmPopupStatusMessage(string title, string msg)
+ {
+ InitializeComponent();
+ Text = title;
+ popMsg.Text = msg;
+ }
+ }
+}
diff --git a/PROMS/Volian.Base.Library/FrmPopupStatusMessage.resx b/PROMS/Volian.Base.Library/FrmPopupStatusMessage.resx
new file mode 100644
index 00000000..1af7de15
--- /dev/null
+++ b/PROMS/Volian.Base.Library/FrmPopupStatusMessage.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/PROMS/Volian.Base.Library/Volian.Base.Library.csproj b/PROMS/Volian.Base.Library/Volian.Base.Library.csproj
index 9672f395..d4fcbc7b 100644
--- a/PROMS/Volian.Base.Library/Volian.Base.Library.csproj
+++ b/PROMS/Volian.Base.Library/Volian.Base.Library.csproj
@@ -95,6 +95,12 @@
Component
+
+ Form
+
+
+ FrmPopupStatusMessage.cs
+
Form
@@ -117,6 +123,9 @@
+
+ FrmPopupStatusMessage.cs
+
frmRtfEdit.cs
diff --git a/PROMS/Volian.Controls.Library/DisplayTabControl.cs b/PROMS/Volian.Controls.Library/DisplayTabControl.cs
index 90ed2439..c995e33d 100644
--- a/PROMS/Volian.Controls.Library/DisplayTabControl.cs
+++ b/PROMS/Volian.Controls.Library/DisplayTabControl.cs
@@ -655,6 +655,7 @@ namespace Volian.Controls.Library
}
else // Otherwise open it in the Word editor
{
+ Document.ConvertWordSectionToDOCX(myItemInfo); // B2023-093 Convert a Word section to the DOCX Word format if needed before opening it for edit
return OpenDSOTabPage(myItemInfo);
}
}
diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs
index 338b32bf..941347ee 100644
--- a/PROMS/Volian.Print.Library/PromsPrinter.cs
+++ b/PROMS/Volian.Print.Library/PromsPrinter.cs
@@ -761,6 +761,10 @@ namespace Volian.Print.Library
int cnt = 0;
foreach (SectionInfo mySection in myProcedure.Sections)
{
+ if (!mySection.MyDocStyle.IsStepSection && !mySection.IsAutoTOCSection)
+ {
+ VEPROMS.CSLA.Library.Document.ConvertWordSectionToDOCX((ItemInfo)mySection); // B2023-093 Convert a Word section to the DOCX Word format if needed before printing
+ }
//C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box
if ((myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.SectionLevelFoldouts && (mySection.MyConfig as SectionConfig).Section_IsFoldout == "Y")
|| (myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.AlternateFloatingFoldout && (mySection.MyConfig as SectionConfig).Section_IsFoldout == "Y"))