Added button to convert MSWord sections to DocX
This commit is contained in:
parent
f989e52a13
commit
54334cc233
@ -79,6 +79,7 @@ namespace VEPROMS
|
|||||||
this.ppLblDefaultNumColumns = new System.Windows.Forms.Label();
|
this.ppLblDefaultNumColumns = new System.Windows.Forms.Label();
|
||||||
this.ppCbDefaultStepSection = new System.Windows.Forms.CheckBox();
|
this.ppCbDefaultStepSection = new System.Windows.Forms.CheckBox();
|
||||||
this.txbxTOC_Group_Title = new DevComponents.DotNetBar.Controls.TextBoxX();
|
this.txbxTOC_Group_Title = new DevComponents.DotNetBar.Controls.TextBoxX();
|
||||||
|
this.ppBtnConvertToDocX = new DevComponents.DotNetBar.ButtonX();
|
||||||
this.panSectBtns = new System.Windows.Forms.Panel();
|
this.panSectBtns = new System.Windows.Forms.Panel();
|
||||||
this.btnAutomation = new DevComponents.DotNetBar.ButtonX();
|
this.btnAutomation = new DevComponents.DotNetBar.ButtonX();
|
||||||
this.btnLibDocs = new DevComponents.DotNetBar.ButtonX();
|
this.btnLibDocs = new DevComponents.DotNetBar.ButtonX();
|
||||||
@ -751,6 +752,19 @@ namespace VEPROMS
|
|||||||
"all will be grouped under this title.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
|
"all will be grouped under this title.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
|
||||||
this.txbxTOC_Group_Title.TabIndex = 54;
|
this.txbxTOC_Group_Title.TabIndex = 54;
|
||||||
//
|
//
|
||||||
|
// btnConvertToDocX
|
||||||
|
//
|
||||||
|
this.ppBtnConvertToDocX.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||||
|
this.ppBtnConvertToDocX.Location = new System.Drawing.Point(17, 271);
|
||||||
|
this.ppBtnConvertToDocX.Margin = new System.Windows.Forms.Padding(2);
|
||||||
|
this.ppBtnConvertToDocX.Name = "btnConvertToDocX";
|
||||||
|
this.ppBtnConvertToDocX.Size = new System.Drawing.Size(209, 36);
|
||||||
|
this.superTooltip1.SetSuperTooltip(this.ppBtnConvertToDocX, new DevComponents.DotNetBar.SuperTooltipInfo("Convert To Library Document button", "", "This button will convert the current section to a library document, allowing it t" +
|
||||||
|
"o be shared with other procedures.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, false, new System.Drawing.Size(250, 76)));
|
||||||
|
this.ppBtnConvertToDocX.TabIndex = 42;
|
||||||
|
this.ppBtnConvertToDocX.Text = "Convert to DocX";
|
||||||
|
this.ppBtnConvertToDocX.Click += new System.EventHandler(this.ppBtnConvertToDocX_Click);
|
||||||
|
//
|
||||||
// panSectBtns
|
// panSectBtns
|
||||||
//
|
//
|
||||||
this.panSectBtns.BackColor = System.Drawing.Color.Transparent;
|
this.panSectBtns.BackColor = System.Drawing.Color.Transparent;
|
||||||
@ -1064,6 +1078,7 @@ namespace VEPROMS
|
|||||||
this.tcpGeneral.Controls.Add(this.ppTxtBxUserID);
|
this.tcpGeneral.Controls.Add(this.ppTxtBxUserID);
|
||||||
this.tcpGeneral.Controls.Add(this.lblUserID);
|
this.tcpGeneral.Controls.Add(this.lblUserID);
|
||||||
this.tcpGeneral.Controls.Add(this.lblLastModDate);
|
this.tcpGeneral.Controls.Add(this.lblLastModDate);
|
||||||
|
this.tcpGeneral.Controls.Add(this.ppBtnConvertToDocX);
|
||||||
this.tcpGeneral.DisabledBackColor = System.Drawing.Color.Empty;
|
this.tcpGeneral.DisabledBackColor = System.Drawing.Color.Empty;
|
||||||
this.tcpGeneral.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.tcpGeneral.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.tcpGeneral.Location = new System.Drawing.Point(0, 22);
|
this.tcpGeneral.Location = new System.Drawing.Point(0, 22);
|
||||||
@ -1557,5 +1572,6 @@ namespace VEPROMS
|
|||||||
private DevComponents.DotNetBar.Controls.GroupPanel gpTOC;
|
private DevComponents.DotNetBar.Controls.GroupPanel gpTOC;
|
||||||
private DevComponents.DotNetBar.LabelX labelX1;
|
private DevComponents.DotNetBar.LabelX labelX1;
|
||||||
private DevComponents.DotNetBar.Controls.TextBoxX txbxTOC_Group_Title;
|
private DevComponents.DotNetBar.Controls.TextBoxX txbxTOC_Group_Title;
|
||||||
|
private DevComponents.DotNetBar.ButtonX ppBtnConvertToDocX;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ using DevComponents.DotNetBar;
|
|||||||
using DevComponents.DotNetBar.Controls;
|
using DevComponents.DotNetBar.Controls;
|
||||||
using Volian.Controls.Library;
|
using Volian.Controls.Library;
|
||||||
using DescriptiveEnum;
|
using DescriptiveEnum;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace VEPROMS
|
namespace VEPROMS
|
||||||
{
|
{
|
||||||
@ -206,7 +207,7 @@ namespace VEPROMS
|
|||||||
using (Content cont = Content.Get(sectinfo.MyContent.ContentID))
|
using (Content cont = Content.Get(sectinfo.MyContent.ContentID))
|
||||||
{
|
{
|
||||||
Byte[] tstbyte = System.Text.Encoding.Default.GetBytes("");
|
Byte[] tstbyte = System.Text.Encoding.Default.GetBytes("");
|
||||||
Document doc = Document.MakeDocument(null, tstbyte, null, null,".RTF"); // tstbyte, null, null, null);
|
Document doc = Document.MakeDocument(null, tstbyte, null, null,".DOCX"); // RTF Caused B2016-196 Changed to DOCX for default
|
||||||
Entry entry = cont.MyEntry;
|
Entry entry = cont.MyEntry;
|
||||||
entry.MyDocument = Document.Get(doc.DocID);
|
entry.MyDocument = Document.Get(doc.DocID);
|
||||||
cont.Save();
|
cont.Save();
|
||||||
@ -490,6 +491,7 @@ namespace VEPROMS
|
|||||||
if (_SectionConfig.MySection.MyContent.MyEntry!=null && _SectionConfig.MySection.MyContent.MyEntry.MyDocument!=null && (_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle != null) && (_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle != "")) isLib = true;
|
if (_SectionConfig.MySection.MyContent.MyEntry!=null && _SectionConfig.MySection.MyContent.MyEntry.MyDocument!=null && (_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle != null) && (_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle != "")) isLib = true;
|
||||||
if (isLib)
|
if (isLib)
|
||||||
{
|
{
|
||||||
|
ppBtnConvertToDocX.Visible = false; // Don't allow save as DOCX for libraries documents
|
||||||
ppBtnCvrtToLibDoc.Text = "Convert this Section To A Non-Library Document";
|
ppBtnCvrtToLibDoc.Text = "Convert this Section To A Non-Library Document";
|
||||||
lblLibraryDocument.Text = "Library Document";
|
lblLibraryDocument.Text = "Library Document";
|
||||||
superTooltip1.SetSuperTooltip(this.ppBtnCvrtToLibDoc, new DevComponents.DotNetBar.SuperTooltipInfo("Convert To Non-Library Document", "", "This button will convert the current section from a library document to a non-library document",
|
superTooltip1.SetSuperTooltip(this.ppBtnCvrtToLibDoc, new DevComponents.DotNetBar.SuperTooltipInfo("Convert To Non-Library Document", "", "This button will convert the current section from a library document to a non-library document",
|
||||||
@ -497,6 +499,10 @@ namespace VEPROMS
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (_SectionConfig.MySection.MyContent.MyEntry.MyDocument != null && _SectionConfig.MySection.MyContent.MyEntry.MyDocument.FileExtension == ".RTF")
|
||||||
|
this.ppBtnConvertToDocX.Visible = true; // Only allow save as DocX for normal word sections when the exissting text is RTF.
|
||||||
|
else
|
||||||
|
this.ppBtnConvertToDocX.Visible = false;
|
||||||
if (_SectionConfig.MySection.MyContent.MyEntry.MyDocument == null)
|
if (_SectionConfig.MySection.MyContent.MyEntry.MyDocument == null)
|
||||||
ppBtnCvrtToLibDoc.Visible = false;
|
ppBtnCvrtToLibDoc.Visible = false;
|
||||||
else
|
else
|
||||||
@ -1167,7 +1173,39 @@ namespace VEPROMS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void ppBtnConvertToDocX_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// Get Document as file
|
||||||
|
ItemInfo ii = ItemInfo.Get(_SectionConfig.MySection.ItemID);
|
||||||
|
DocumentInfo doclibinfo = ii.MyContent.MyEntry.MyDocument;
|
||||||
|
DSOFile myfile = new DSOFile(doclibinfo);
|
||||||
|
// When trying to fix this , the update of the document waas causing a CSLA crash so I switched
|
||||||
|
// to make document
|
||||||
|
//using (Document myDoc = doclibinfo.Get())
|
||||||
|
//{
|
||||||
|
// Open MSWord App
|
||||||
|
LBWordLibrary.LBApplicationClass ap = new LBWordLibrary.LBApplicationClass();
|
||||||
|
LBWordLibrary.LBDocumentClass doc = ap.Documents.Open(myfile.FullName);
|
||||||
|
string filename = myfile.FullName.ToUpper().Replace(".RTF", ".DOCX");
|
||||||
|
doc.SaveAs(filename, LBWordLibrary.LBWdSaveFormat.wdFormatXMLDocument); // Convert to DocX
|
||||||
|
doc.Close();
|
||||||
|
ap.Quit();
|
||||||
|
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();
|
||||||
|
Document myDoc = Document.MakeDocument(null, ByteArray, doclibinfo.DocAscii, doclibinfo.Config, ".DOCX");
|
||||||
|
_SectionConfig.MySection.MyContent.MyEntry.MyDocument = myDoc;
|
||||||
|
_SectionConfig.MySection.MyContent.MyEntry.Save();
|
||||||
|
//myDoc.DocContent = ByteArray;
|
||||||
|
//myDoc.FileExtension = ".DOCX";
|
||||||
|
//myDoc.Save();
|
||||||
|
fi.Delete();// Cleanup afterwards
|
||||||
|
ppBtnConvertToDocX.Visible = false; // Hide the button after the execution is complete.
|
||||||
|
//}
|
||||||
|
}
|
||||||
//private void ppBtnDefaultPrintSize_Click(object sender, EventArgs e)
|
//private void ppBtnDefaultPrintSize_Click(object sender, EventArgs e)
|
||||||
//{
|
//{
|
||||||
// // Get the parent setting
|
// // Get the parent setting
|
||||||
|
Loading…
x
Reference in New Issue
Block a user