Esempio n. 1
0
        public static int LegacyChemistryCount(Word.Document doc)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            int count = 0;

            foreach (Word.ContentControl cc in doc.ContentControls)
            {
                Word.WdContentControlType?contentControlType = cc.Type;
                Debug.WriteLine($"{cc.ID} {cc.Range.Start} {DecodeContentControlType(contentControlType)} {cc.Tag}");
                try
                {
                    if (cc.Title != null && cc.Title.Equals(Constants.LegacyContentControlTitle))
                    {
                        count++;
                    }
                }
                catch (Exception ex)
                {
                    Globals.Chem4WordV3.Telemetry.Write(module, "Exception", $"{ex.Message}");
                    Globals.Chem4WordV3.Telemetry.Write(module, "Exception", $"{ex.StackTrace}");
                }
            }

            return(count);
        }
Esempio n. 2
0
        private static string DecodeContentControlType(Word.WdContentControlType?contentControlType)
        {
            // Date from https://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.wdcontentcontroltype(v=office.14).aspx
            string result = "";

            switch (contentControlType)
            {
            case Word.WdContentControlType.wdContentControlRichText:
                result = "Rich-Text";
                break;

            case Word.WdContentControlType.wdContentControlText:
                result = "Text";
                break;

            case Word.WdContentControlType.wdContentControlBuildingBlockGallery:
                result = "Picture";
                break;

            case Word.WdContentControlType.wdContentControlComboBox:
                result = "ComboBox";
                break;

            case Word.WdContentControlType.wdContentControlDropdownList:
                result = "Drop-Down List";
                break;

            case Word.WdContentControlType.wdContentControlPicture:
                result = "Building Block Gallery";
                break;

            case Word.WdContentControlType.wdContentControlDate:
                result = "Date";
                break;

            case Word.WdContentControlType.wdContentControlGroup:
                result = "Group";
                break;

            case Word.WdContentControlType.wdContentControlCheckBox:
                result = "CheckBox";
                break;

            case Word.WdContentControlType.wdContentControlRepeatingSection:
                result = "Repeating Section";
                break;

            default:
                result = contentControlType.ToString();
                break;
            }

            return(result);
        }