protected string CleanFile(string inFile, ActionPropertySet actions) { PDFCleanUserAction action = new PDFCleanUserAction(); ActionDataImpl testData = new ActionDataImpl(Path.Combine(TestRoot, inFile)); testData.Properties.Add(strings.StrmProp_DisplayName, inFile); testData.Properties.Add("CorrectedDisplayName", inFile); return action.Execute(testData, actions); }
private IActionData3 BuildActionDataForComObject(object officeDocument) { ActionDataImpl result = new ActionDataImpl(); result.Properties.Add("DisplayName", "A Document"); result.Properties.Add("CorrectedDisplayName", "A Document"); result.Properties.Add("FileName", ""); return result; }
public void TestFallbackCleaningDoesntHappenInServerCtxt() { using (WsActivationContext wsac = new WsActivationContext()) { ActionPropertySet aps = new ActionPropertySet(new CleanActionPropertySet()); aps.SystemProperties["RunAt"] = new ActionProperty("RunAt", "Server"); // setup server execution context aps.SystemProperties.Add( "FileType", new ActionProperty("FileType", typeof(string), PropertyDisplayType.Default, false, false, ".ppt", true) ); // file is a password protected ppt document string tempFile = CopyFile(TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\Projects\Hygiene\src\TestDocuments\both.ppt")); ActionDataImpl adi = new ActionDataImpl(tempFile); adi.Properties["DisplayName"] = Path.GetFileName(tempFile); adi.Properties["FileName"] = tempFile; LightSpeedCleanUserAction lsua = new LightSpeedCleanUserAction(); try { // file is a password protected ppt document lsua.Execute(adi, aps); } catch (Exception ex) { // exceptions are ignored here as we are expecting the clean to blow up actually Console.WriteLine(ex.ToString()); } Assert.IsNotNull(lsua.FallbackTried); Assert.IsFalse(lsua.FallbackTried.Value, "Expecting no fallback"); } }
private void TestLoadAndCleanPPTFile(string fileName, FileType fileType, string ext) { using (WsActivationContext wsac = new WsActivationContext()) { using (TempResourceFile file = new TempResourceFile(fileName)) { // Force a create on the foreground thread Workshare.ApplicationControllers.OfficeApplicationCache.Instance.Create(fileType); CleanPropertiesDisplayTranslator displayTranslator = CleanPropertiesDisplayTranslator.Instance; CleanUserAction action = new CleanUserAction(); ActionPropertySet props = new ActionPropertySet(new CleanActionPropertySet()); props.SystemProperties.Add(displayTranslator.SysProp_FileType, new ActionProperty(displayTranslator.SysProp_FileType, typeof(string), PropertyDisplayType.Default, false, false, ext, true)); props[CleanOption.Comments].Value = true; ActionDataImpl testData = new ActionDataImpl(file.Filepath); testData.Properties.Add(displayTranslator.StrmProp_DisplayName, file.Filepath); testData.Properties.Add("CorrectedDisplayName", file.Filepath); action.Execute(testData, props); Workshare.ApplicationControllers.OfficeApplicationCache.Instance.ShutDown(); WaitForPowerPointToShutDown(30000); } } }
public void Test_02_TestForRegionalSettings() { System.Globalization.CultureInfo oldCultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fi-FI"); System.Globalization.CultureInfo newCultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; try { Assert.AreNotEqual(oldCultureInfo, newCultureInfo); Assert.AreEqual(newCultureInfo, System.Globalization.CultureInfo.GetCultureInfo("fi-FI")); Process[] pro = Process.GetProcessesByName("excel"); if (pro != null && pro.Length != 0) throw new System.InvalidOperationException("excel should not be running"); using (WsActivationContext wsac = new WsActivationContext()) { using (TempResourceFile file = new TempResourceFile()) { file.setTempDir("Temp.xls"); file.CreateFile(); // Force a create on the foreground thread Workshare.ApplicationControllers.OfficeApplicationCache.Instance.Create(FileType.ExcelSheet); CleanPropertiesDisplayTranslator displayTranslator = CleanPropertiesDisplayTranslator.Instance; CleanUserAction action = new CleanUserAction(); ActionPropertySet props = new ActionPropertySet(new CleanActionPropertySet()); props.SystemProperties.Add(displayTranslator.SysProp_FileType, new ActionProperty(displayTranslator.SysProp_FileType, typeof(string), PropertyDisplayType.Default, false, false, ".xls", true)); props[CleanOption.Comments].Value = true; props[CleanOption.TrackChanges].Value = true; ActionDataImpl testData = new ActionDataImpl(file.Filepath); testData.Properties.Add(displayTranslator.StrmProp_DisplayName, file.Filepath); string outputFile = action.Execute(testData, props); Workshare.ApplicationControllers.OfficeApplicationCache.Instance.ShutDown(); WaitForExcelToShutDown(30000); Assert.AreEqual(newCultureInfo, System.Globalization.CultureInfo.GetCultureInfo("fi-FI")); } } } catch { } finally { System.Threading.Thread.CurrentThread.CurrentCulture = oldCultureInfo; } }
public void Test_01_BasicRoundTripForActionObjectOnly() { Process[] pro = Process.GetProcessesByName("winword"); if (pro != null && pro.Length != 0) throw new System.InvalidOperationException("winword should not be running"); using (WsActivationContext wsac = new WsActivationContext()) { using (TempResourceFile file = new TempResourceFile("Doc.doc")) { int revisionCount = 0; int commentCount = 0; GetRevisionAndCommmentCounts(file.Filepath, ref revisionCount, ref commentCount); Assert.AreEqual(1, revisionCount, "There is one track change in the document."); Assert.AreEqual(1, commentCount, "There is one comment in the document."); // Force a create on the foreground thread Workshare.ApplicationControllers.OfficeApplicationCache.Instance.Create(FileType.WordDocument); CleanPropertiesDisplayTranslator displayTranslator = CleanPropertiesDisplayTranslator.Instance; CleanUserAction action = new CleanUserAction(); ActionPropertySet props = new ActionPropertySet(new CleanActionPropertySet()); props.SystemProperties.Add(displayTranslator.SysProp_FileType, new ActionProperty(displayTranslator.SysProp_FileType, typeof(string), PropertyDisplayType.Default, false, false, ".doc", true)); props[CleanOption.Comments].Value = true; props[CleanOption.TrackChanges].Value = true; ActionDataImpl testData = new ActionDataImpl(file.Filepath); testData.Properties.Add(displayTranslator.StrmProp_DisplayName, file.Filepath); testData.Properties.Add("CorrectedDisplayName", file.Filepath); string outFile = action.Execute(testData, props); Workshare.ApplicationControllers.OfficeApplicationCache.Instance.ShutDown(); WaitForWordToShutDown(30000); GetRevisionAndCommmentCounts(outFile, ref revisionCount, ref commentCount); Assert.AreEqual(0, revisionCount, "Track changes should have been removed."); Assert.AreEqual(0, commentCount, "Comments should have been removed."); } } }
protected static IActionData3 BuildActionData(string sourceFilePath) { IActionData3 input = new ActionDataImpl(sourceFilePath); input.Properties.Add("DisplayName", new FileInfo(sourceFilePath).Name); input.Properties.Add("CorrectedDisplayName", new FileInfo(sourceFilePath).Name); input.Properties.Add("FileName", sourceFilePath); return input; }