Skip to content

Commit

Permalink
Merged PR 347: V3.1.8 Beta 8
Browse files Browse the repository at this point in the history
- During saving of document, Save a copy of orphaned structures as cml to C:\Users{User}\AppData\Local\Chem4Word.V3\Backups
- Remove locked Content Control if edit operation removes structure #56
- Fix glitch in compatibility mode detection
- Deprecate internal Functional Groups [CH2, CH3, NH2, OH], they are converted to appropriate Element on import from CML or MOLFile
- Improvement to valency warning indication

Related work items: #702, #706, #707
  • Loading branch information
MikeWilliams-UK committed Apr 9, 2020
1 parent 11ac126 commit 82ebc92
Show file tree
Hide file tree
Showing 67 changed files with 1,015 additions and 788 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ assignees: ''
A clear and concise description [in English] of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
Steps to reproduce the behaviour:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand Down
1 change: 1 addition & 0 deletions src/Chem4Word.V3/Chem4Word.V3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@
<Compile Include="Helpers\TargetWord.cs" />
<Compile Include="Helpers\TaskPaneHelper.cs" />
<Compile Include="Helpers\UpdateHelper.cs" />
<Compile Include="Helpers\WordSettings.cs" />
<Compile Include="Library\Chemistry.cs" />
<Compile Include="Library\ChemistryByTag.cs" />
<Compile Include="Library\LibraryValidation.cs" />
Expand Down
373 changes: 192 additions & 181 deletions src/Chem4Word.V3/Chem4WordV3.cs

Large diffs are not rendered by default.

34 changes: 15 additions & 19 deletions src/Chem4Word.V3/Data/Chem4Word-Versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
<!-- This file must be uploaded to https://www.chem4word.co.uk/files3-1/ folder as Chem4Word-Versions.xml -->
<ChangeLog>
<Id>f3c4f4db-2fff-46db-b14a-feb8e09f7742</Id>
<Version>
<Number>3.1.8 Beta 8</Number>
<IsBeta>true</IsBeta>
<Released>09-Apr-2020</Released>
<Changes>
<Change>Warn when attempting to edit structure with broken link https://github.com/Chem4Word/Version3-1/issues/47 </Change>
<Change>Fix upgrade of V2 structure to have user's preferred bond length</Change>
<Change>Fix glitch in compatibility mode detection</Change>
<Change>Improvement to valency warning indication</Change>
<Change>Deprecate internal Functional Groups [CH2, CH3, NH2, OH], they are converted to appropriate Element on import from CML or MOLFile</Change>
<Change>During saving of document, Save a copy of orphaned structures as cml to C:\Users\{User}\AppData\Local\Chem4Word.V3\Backups</Change>
<Change>Remove locked Content Control if edit operation removes structure https://github.com/Chem4Word/Version3-1/issues/56 </Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.8.Beta.8.msi</Url>
</Version>
<Version>
<Number>3.1.7 Beta 7</Number>
<IsBeta>true</IsBeta>
Expand All @@ -10,7 +25,6 @@
<Change>Fix invisible bonds when certain unusual elements used https://github.com/Chem4Word/Version3-1/issues/44 </Change>
<Change>Fix broken ChEBI search https://github.com/Chem4Word/Version3-1/issues/45 </Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.7.Beta.7.msi</Url>
</Version>
<Version>
<Number>3.1.6 Beta 6</Number>
Expand All @@ -27,7 +41,6 @@
<Change>Correct rendering of terminal double bonds https://github.com/Chem4Word/Version3-1/issues/25 </Change>
<Change>Silently handle COMException in OnDocumentBeforeSave https://github.com/Chem4Word/Version3-1/issues/42 </Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.6.Beta.6.msi</Url>
</Version>
<Version>
<Number>3.1.5 Beta 5</Number>
Expand All @@ -43,7 +56,6 @@
<Change>Performance improvements</Change>
<Change>Fix doubling up of 2019 in Office detection</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.5.Beta.5.msi</Url>
</Version>
<Version>
<Number>3.1.4 Beta 4</Number>
Expand All @@ -54,7 +66,6 @@
<Change>Disable Explicit C when charge or isotope present https://github.com/Chem4Word/Version3-1/issues/18 </Change>
<Change>Fix joining of double bonds to rings https://github.com/Chem4Word/Version3-1/issues/12 </Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.4.Beta.4.msi</Url>
</Version>
<Version>
<Number>3.1.3 Beta 3</Number>
Expand All @@ -63,7 +74,6 @@
<Changes>
<Change>Fix Draw button is disabled for new document</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.3.Beta.3.msi</Url>
</Version>
<Version>
<Number>3.1.2 Beta 2</Number>
Expand All @@ -72,7 +82,6 @@
<Changes>
<Change>First public Beta</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.2.Beta.2.msi</Url>
</Version>
<Version>
<Number>3.1.1 Beta 1</Number>
Expand All @@ -81,7 +90,6 @@
<Changes>
<Change>Internal Beta</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.1.Beta.1.msi</Url>
</Version>
<Version>
<Number>3.1.0 Alpha 12</Number>
Expand All @@ -90,7 +98,6 @@
<Changes>
<Change>Alpha 12</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.0.Alpha.1.msi</Url>
</Version>
<Version>
<Number>3.1.0 Alpha 11</Number>
Expand All @@ -99,7 +106,6 @@
<Changes>
<Change>Alpha 11</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.0.Alpha.1.msi</Url>
</Version>
<Version>
<Number>3.1.0 Alpha 10</Number>
Expand All @@ -108,7 +114,6 @@
<Changes>
<Change>Alpha 10</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.0.Alpha.1.msi</Url>
</Version>
<Version>
<Number>3.1.0 Alpha 09</Number>
Expand All @@ -117,7 +122,6 @@
<Changes>
<Change>Alpha 09</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.0.Alpha.1.msi</Url>
</Version>
<Version>
<Number>3.1.0 Alpha 08</Number>
Expand All @@ -126,7 +130,6 @@
<Changes>
<Change>Alpha 08</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.0.Alpha.1.msi</Url>
</Version>
<Version>
<Number>3.1.0 Alpha 07</Number>
Expand All @@ -135,7 +138,6 @@
<Changes>
<Change>Alpha 07</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.0.Alpha.1.msi</Url>
</Version>
<Version>
<Number>3.1.0 Alpha 06</Number>
Expand All @@ -144,7 +146,6 @@
<Changes>
<Change>Alpha 06</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.0.Alpha.1.msi</Url>
</Version>
<Version>
<Number>3.1.0 Alpha 05</Number>
Expand All @@ -153,7 +154,6 @@
<Changes>
<Change>Alpha 05</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.0.Alpha.1.msi</Url>
</Version>
<Version>
<Number>3.1.0 Alpha 04</Number>
Expand All @@ -162,7 +162,6 @@
<Changes>
<Change>Alpha 04</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.0.Alpha.1.msi</Url>
</Version>
<Version>
<Number>3.1.0 Alpha 03</Number>
Expand All @@ -171,7 +170,6 @@
<Changes>
<Change>Alpha 03</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.0.Alpha.1.msi</Url>
</Version>
<Version>
<Number>3.1.0 Alpha 02</Number>
Expand All @@ -180,7 +178,6 @@
<Changes>
<Change>Alpha 02</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.0.Alpha.1.msi</Url>
</Version>
<Version>
<Number>3.1.0 Alpha 01</Number>
Expand All @@ -189,6 +186,5 @@
<Changes>
<Change>Alpha 01</Change>
</Changes>
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.0.Alpha.1.msi</Url>
</Version>
</ChangeLog>
4 changes: 2 additions & 2 deletions src/Chem4Word.V3/Data/This-Version.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Version>
<Number>3.1.7 Beta 7</Number>
<Number>3.1.8 Beta 8</Number>
<IsBeta>true</IsBeta>
<Released>06-Mar-2020</Released>
<Released>09-Apr-2020</Released>
</Version>
18 changes: 11 additions & 7 deletions src/Chem4Word.V3/Data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,37 @@ <h1>Chemistry for Word Add-In 2020</h1>
<td>Setup Bootstrapper</td>
<td><a href="/files3-1/Chem4Word-Setup.exe">Chem4Word-Setup</a></td>
</tr>
<tr>
<td>Version 3.1.8 - Beta 8</td>
<td><a href="/files3-1/Chem4Word-Setup.3.1.8.Beta.8.msi">Chem4Word-Setup 3.1.8 Beta 8</a></td>
</tr>
<tr>
<td>Version 3.1.7 - Beta 7</td>
<td><a href="/files3-1/Chem4Word-Setup.3.1.7.Beta.7.msi">Chem4Word-Setup 3.1.7 Beta 7</a></td>
<td>Chem4Word-Setup 3.1.7 Beta 7</td>
</tr>
<tr>
<td>Version 3.1.6 - Beta 6</td>
<td><a href="/files3-1/Chem4Word-Setup.3.1.6.Beta.6.msi">Chem4Word-Setup 3.1.6 Beta 6</a></td>
<td>Chem4Word-Setup 3.1.6 Beta 6</td>
</tr>
<tr>
<td>Version 3.1.5 - Beta 5</td>
<td><a href="/files3-1/Chem4Word-Setup.3.1.5.Beta.5.msi">Chem4Word-Setup 3.1.5 Beta 5</a></td>
<td>Chem4Word-Setup 3.1.5 Beta 5</td>
</tr>
<tr>
<td>Version 3.1.4 - Beta 4</td>
<td><a href="/files3-1/Chem4Word-Setup.3.1.4.Beta.4.msi">Chem4Word-Setup 3.1.4 Beta 4</a></td>
<td>Chem4Word-Setup 3.1.4 Beta 4</td>
</tr>
<tr>
<td>Version 3.1.3 - Beta 3</td>
<td><a href="/files3-1/Chem4Word-Setup.3.1.3.Beta.3.msi">Chem4Word-Setup 3.1.3 Beta 3</a></td>
<td>Chem4Word-Setup 3.1.3 Beta 3</td>
</tr>
<tr>
<td>Version 3.1.2 - Beta 2</td>
<td><a href="/files3-1/Chem4Word-Setup.3.1.2.Beta.2.msi">Chem4Word-Setup 3.1.2 Beta 2</a></td>
<td>Chem4Word-Setup 3.1.2 Beta 2</td>
</tr>
<tr>
<td>Version 3.1.1 - Beta 1</td>
<td><a href="/files3-1/Chem4Word-Setup.3.1.1.Beta.1.msi">Chem4Word-Setup 3.1.1 Beta 1</a></td>
<td>Chem4Word-Setup 3.1.1 Beta 1</td>
</tr>
</table>
<h1>Third Party</h1>
Expand Down
33 changes: 18 additions & 15 deletions src/Chem4Word.V3/Helpers/ChemistryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public static Word.ContentControl Insert2DChemistry(Word.Document doc, string cm
Word.ContentControl cc = null;
Word.Application app = doc.Application;

var wordSettings = new WordSettings(app);

IChem4WordRenderer renderer =
Globals.Chem4WordV3.GetRendererPlugIn(
Globals.Chem4WordV3.SystemOptions.SelectedRendererPlugIn);
Expand Down Expand Up @@ -115,6 +117,8 @@ public static Word.ContentControl Insert2DChemistry(Word.Document doc, string cm
}
}

wordSettings.RestoreSettings(app);

return cc;
}

Expand All @@ -129,18 +133,13 @@ public static Word.ContentControl Insert1DChemistry(Word.Document doc, string te

Word.Application app = Globals.Chem4WordV3.Application;

bool existingStateOfCorrectSentenceCaps = app.AutoCorrect.CorrectSentenceCaps;
bool existingStateOfSmartCutPaste = app.Options.SmartCutPaste;
var wordSettings = new WordSettings(app);

Word.ContentControl cc = doc.ContentControls.Add(Word.WdContentControlType.wdContentControlRichText, ref _missing);

app.AutoCorrect.CorrectSentenceCaps = false;
app.Options.SmartCutPaste = false;

SetRichText(cc, text, isFormula);

app.AutoCorrect.CorrectSentenceCaps = existingStateOfCorrectSentenceCaps;
app.Options.SmartCutPaste = existingStateOfSmartCutPaste;
wordSettings.RestoreSettings(app);

cc.Tag = tag;
cc.Title = Constants.ContentControlTitle;
Expand Down Expand Up @@ -239,6 +238,7 @@ public static void Insert2D(Word.ContentControl cc, string tempfileName, string
Globals.Chem4WordV3.Telemetry.Write(module, "Information", $"Inserting 2D structure in ContentControl {cc.ID} Tag {guid}");

Word.Document doc = cc.Application.ActiveDocument;
var wordSettings = new WordSettings(cc.Application);

string bookmarkName = Constants.OoXmlBookmarkPrefix + guid;

Expand All @@ -248,6 +248,8 @@ public static void Insert2D(Word.ContentControl cc, string tempfileName, string
doc.Bookmarks[bookmarkName].Delete();
}

wordSettings.RestoreSettings(cc.Application);

cc.Tag = guid;
cc.Title = Constants.ContentControlTitle;
cc.LockContents = true;
Expand All @@ -260,6 +262,7 @@ public static void Update2D(Word.ContentControl cc, string tempfileName, string
Globals.Chem4WordV3.Telemetry.Write(module, "Information", $"Updating 2D structure in ContentControl {cc.ID} Tag {guid}");

Word.Document doc = cc.Application.ActiveDocument;
var wordSettings = new WordSettings(cc.Application);

cc.LockContents = false;
if (cc.Type == Word.WdContentControlType.wdContentControlPicture)
Expand All @@ -284,6 +287,8 @@ public static void Update2D(Word.ContentControl cc, string tempfileName, string
doc.Bookmarks[bookmarkName].Delete();
}

wordSettings.RestoreSettings(cc.Application);

cc.Tag = guid;
cc.Title = Constants.ContentControlTitle;
cc.LockContents = true;
Expand All @@ -296,13 +301,12 @@ public static void Insert1D(Word.ContentControl cc, string text, bool isFormula,
Globals.Chem4WordV3.Telemetry.Write(module, "Information", $"Inserting 1D label in ContentControl {cc.ID} Tag {tag}");

Word.Application app = cc.Application;

bool existingState = app.AutoCorrect.CorrectSentenceCaps;
app.AutoCorrect.CorrectSentenceCaps = false;
var wordSettings = new WordSettings(app);

SetRichText(cc, text, isFormula);

app.AutoCorrect.CorrectSentenceCaps = existingState;
wordSettings.RestoreSettings(app);

cc.Tag = tag;
cc.Title = Constants.ContentControlTitle;
cc.LockContents = true;
Expand All @@ -315,16 +319,15 @@ public static void Update1D(Word.ContentControl cc, string text, bool isFormula,
Globals.Chem4WordV3.Telemetry.Write(module, "Information", $"Updating 1D label in ContentControl {cc.ID} Tag {tag}");

Word.Application app = cc.Application;
var wordSettings = new WordSettings(app);

cc.LockContents = false;
cc.Range.Delete();

bool existingState = app.AutoCorrect.CorrectSentenceCaps;
app.AutoCorrect.CorrectSentenceCaps = false;

SetRichText(cc, text, isFormula);

app.AutoCorrect.CorrectSentenceCaps = existingState;
wordSettings.RestoreSettings(app);

cc.Tag = tag;
cc.Title = Constants.ContentControlTitle;
cc.LockContents = true;
Expand Down
Loading

0 comments on commit 82ebc92

Please sign in to comment.