Fixed crash when you selected the Open button on the Library Document tab in the Tools panel. Open button is only available for library documents with zero references.

If the open library document is not referenced, then save changes but don’t generate a PDF.
This commit is contained in:
John Jenko 2016-05-26 15:25:47 +00:00
parent 008a1e67eb
commit f763a9a868
3 changed files with 14 additions and 7 deletions

View File

@ -413,11 +413,14 @@ namespace Volian.Controls.Library
_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;
if (myei != null && myei.MyDocument != null && myei.MyDocument.LibTitle != null && myei.MyDocument.LibTitle != "")
if (MyDisplayTabItem.MyItemInfo != null) // B2016-131 if myiteminfo is null then the lib doc is not referenced, so just save the changes - don't generate a pdf
{
DialogResult ans = MessageBox.Show("Save as Library Document for all usages?", "Document Save", MessageBoxButtons.YesNo);
if (ans == DialogResult.No) cvtLibDoc = true;
EntryInfo myei = MyDisplayTabItem.MyItemInfo.MyContent.MyEntry;
if (myei != null && myei.MyDocument != null && myei.MyDocument.LibTitle != null && myei.MyDocument.LibTitle != "")
{
DialogResult ans = MessageBox.Show("Save as Library Document for all usages?", "Document Save", MessageBoxButtons.YesNo);
if (ans == DialogResult.No) cvtLibDoc = true;
}
}
MyDSOFile.SaveFile(doc.Length, doc.Ascii, MyDisplayTabItem.MyItemInfo, cvtLibDoc, StatusChanged);
if (cvtLibDoc)

View File

@ -810,7 +810,7 @@ namespace Volian.Controls.Library
foreach (object itm in b.Items)
{
DisplayTabItem myTabItem = itm as DisplayTabItem;
if (myTabItem != null && myTabItem.MyStepTabPanel != null)
if (myTabItem != null && myTabItem.MyStepTabPanel != null && myItemInfo != null)
if (myTabItem.MyStepTabPanel.MyProcedureItemInfo.ItemID == myItemInfo.MyProcedure.ItemID)
return b;
}
@ -1041,6 +1041,7 @@ namespace Volian.Controls.Library
}
public DisplayTabItem OpenDSOTabPage(DocumentInfo myDocumentInfo)
{
_MyBar = GetParentBar(null); // B2016-131 - allow open of a non-referenced library document
CleanUpClosedItems();
DisplayTabItem pg = null;
string key = "Doc - " + myDocumentInfo.DocID;
@ -1048,7 +1049,7 @@ namespace Volian.Controls.Library
pg = _MyDisplayTabItems[key];
else
{
if (DSOTabPanel.Count > 18) // Limit the number of open document pages to 18
if (DSOTabPanel.Count > DSOTabPanel.MSWordLimit) //18) // Limit the number of open document pages to 18
{
MessageBox.Show("Too many Word Documents Open. Please close one of the Documents before attempting to open another");
return null;

View File

@ -326,7 +326,10 @@ namespace Volian.Controls.Library
private void SetupLibraryDocumentDSOTabPanel()
{
UserInfo ui = UserInfo.GetByUserID(OwnerInfo.Get(OwnerID).SessionUserID);
_MyDSOTabPanel = new DSOTabPanel(_MyDocumentInfo, _MyDisplayTabControl, _MyItemInfo, UserInfo.CanEdit(ui, MyItemInfo.MyDocVersion));
// B2016-131 if myiteminfo is null, then the lib doc is not referenced.
// - Allow editting only if you are an Administrator
// - Cannot check if you are a Writer or Set Aministrator because we don't have a Doc Verion
_MyDSOTabPanel = new DSOTabPanel(_MyDocumentInfo, _MyDisplayTabControl, _MyItemInfo, (MyItemInfo != null) ? UserInfo.CanEdit(ui, MyItemInfo.MyDocVersion):ui.IsAdministrator());
//
// tabItem
//