public void TestGetListOfEnabledElementsToClean() { CleanActionPropertySet cleanSet = new CleanActionPropertySet(); cleanSet.Clear(); cleanSet.Add(new KeyValuePair<string, Workshare.Policy.Action.IActionProperty>("FootNotes", new ActionProperty("FootNotes", typeof(bool), PropertyDisplayType.Checkbox, true, true, true, true))); cleanSet.Add(new KeyValuePair<string, Workshare.Policy.Action.IActionProperty>("Headers", new ActionProperty("Headers", typeof(bool), PropertyDisplayType.Checkbox, true, true, true, false))); cleanSet.Add(new KeyValuePair<string, Workshare.Policy.Action.IActionProperty>("Template", new ActionProperty("Template", typeof(bool), PropertyDisplayType.Checkbox, true, true, true, false))); cleanSet.Add(new KeyValuePair<string, Workshare.Policy.Action.IActionProperty>("CustomProperties", new ActionProperty("CustomProperties", typeof(bool), PropertyDisplayType.Checkbox, true, true, true, false))); cleanSet.Add(new KeyValuePair<string, Workshare.Policy.Action.IActionProperty>("DocumentVariables", new ActionProperty("DocumentVariables", typeof(bool), PropertyDisplayType.Checkbox, true, true, true, false))); cleanSet.Add(new KeyValuePair<string, Workshare.Policy.Action.IActionProperty>("RoutingSlip", new ActionProperty("RoutingSlip", typeof(bool), PropertyDisplayType.Checkbox, true, true, true, false))); cleanSet.Add(new KeyValuePair<string, Workshare.Policy.Action.IActionProperty>("Links", new ActionProperty("Links", typeof(bool), PropertyDisplayType.Checkbox, true, true, true, false))); cleanSet.Add(new KeyValuePair<string, Workshare.Policy.Action.IActionProperty>("HiddenText", new ActionProperty("HiddenText", typeof(bool), PropertyDisplayType.Checkbox, true, true, true, false))); cleanSet.Add(new KeyValuePair<string, Workshare.Policy.Action.IActionProperty>("ExcludeCustomProperties", new ActionProperty("ExcludeCustomProperties", typeof(string), PropertyDisplayType.TextBox, true, true, String.Empty, false))); WordXCleaningStrategy wxStrategy = new WordXCleaningStrategy(); Type type = typeof(CleanStrategyBase); MethodInfo mi = type.GetMethod("GetListOfEnabledElementsToClean", BindingFlags.NonPublic|BindingFlags.Instance); object returned = mi.Invoke(wxStrategy, new object[1] { cleanSet }); List<ContentType> contentTypes = (List<ContentType>)returned; Assert.IsTrue(contentTypes.Contains(ContentType.AttachedTemplate), "Missing AttachedTemplate expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.AutoVersion), "AutoVersion not expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.BuiltInProperty), "BuiltInProperty not expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.Comment), "Comment not expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.ContentRule), "Missing ContentRule expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.CustomProperty), "Missing CustomProperty expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.DocumentStatistic), "DocumentStatistic not expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.Endnote), "Missing Endnote expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.Field), "Field not expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.Footer), "Footer not expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.Footnote), "Missing Footnote expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.Header), "Missing Header expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.HiddenColumn), "Missing HiddenColumn expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.HiddenRow), "Missing HiddenRow expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.HiddenSheet), "Missing HiddenSheet expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.HiddenSlide), "HiddenSlide not expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.HiddenText), "Missing HiddenText expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.Hyperlink), "Missing Hyperlink expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.Links), "Missing Links expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.Macro), "Macro not expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.RedactedText), "Missing RedactedText expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.Reviewer), "Reviewer not expected ContentType"); // Assert.IsFalse(contentTypes.Contains(ContentType.RoutingSlip), "RoutingSlip not expected ContentType - isn't valid type in Office 2007"); Assert.IsFalse(contentTypes.Contains(ContentType.SmallText), "SmallText not expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.SmartTag), "SmartTag not expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.SpeakerNote), "SpeakerNote not expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.TrackChange), "TrackChange not expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.Variable), "Missing Variable expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.Version), "Version not expected ContentType"); Assert.IsFalse(contentTypes.Contains(ContentType.WhiteText), "WhiteText not expected ContentType"); Assert.IsTrue(contentTypes.Contains(ContentType.WorkshareProperty), "Missing WorkshareProperty expected ContentType"); }
public void TestRationalisezListToClean() { WordXCleaningStrategy wxStrategy = new WordXCleaningStrategy(); List<ContentType> elements = new List<ContentType>(); elements.Add(ContentType.Hyperlink); elements.Add(ContentType.Field); List<ContentType> rationalized1 = wxStrategy.GetRationalizedElementsToClean(elements, CleanActionPropertySet.TargetApplication.Word); Assert.IsTrue(rationalized1.Contains(ContentType.Hyperlink)); Assert.IsTrue(rationalized1.Contains(ContentType.Field)); elements.Remove(ContentType.Field); List<ContentType> rationalized2 = wxStrategy.GetRationalizedElementsToClean(elements, CleanActionPropertySet.TargetApplication.Word); Assert.IsTrue(rationalized2.Count == 0); List<ContentType> rationalized3 = wxStrategy.GetRationalizedElementsToClean(elements, CleanActionPropertySet.TargetApplication.Excel); Assert.IsTrue(rationalized3.Contains(ContentType.Hyperlink)); List<ContentType> rationalized4 = wxStrategy.GetRationalizedElementsToClean(elements, CleanActionPropertySet.TargetApplication.PowerPoint); Assert.IsTrue(rationalized4.Contains(ContentType.Hyperlink)); }
public void TestNonDomRemovalListToClean() { WordXCleaningStrategy wxStrategy = new WordXCleaningStrategy(); List<ContentType> elements = new List<ContentType>(); elements.Add(ContentType.Hyperlink); elements.Add(ContentType.Field); List<ContentType> nonDomRemovalList = wxStrategy.GetElementsNotRemovedByDomClean(elements); Assert.IsTrue(nonDomRemovalList.Count == 0); elements.Add(ContentType.BuiltInProperty); elements.Add(ContentType.CustomProperty); elements.Add(ContentType.DocumentStatistic); elements.Add(ContentType.Macro); nonDomRemovalList = wxStrategy.GetElementsNotRemovedByDomClean(elements); Assert.IsTrue(nonDomRemovalList.Contains(ContentType.BuiltInProperty)); Assert.IsTrue(nonDomRemovalList.Contains(ContentType.CustomProperty)); Assert.IsTrue(nonDomRemovalList.Contains(ContentType.DocumentStatistic)); Assert.IsTrue(nonDomRemovalList.Contains(ContentType.Macro)); Assert.IsTrue(nonDomRemovalList.Count == 4); }
string CleanFile(string file) { var tffa = new TempFileForActions(file); var caps = new CleanActionPropertySet(); caps[CleanOption.SkipDomCleaning].Value = true; var strategy = new WordXCleaningStrategy(); strategy.RemoveMetadata(tffa, caps); return file; }