public void TestDiscoverSimpleParaTCs2()
        {
            string fileName = TESTFILE_DIR + "TestDiscoverParaStyles2.doc";
            Workshare.FCS.Lite.WordDocumentReader docReader = new WordDocumentReader(fileName);
            DocumentText docText = docReader.Read();

            IAbstractTextType ttTC = docText.GetUniqueTextType(ContentType.TrackChange);
            Assert.IsNotNull(ttTC, "we unexpectedly found no track changes");

            Assert.AreEqual(5, ttTC.Count, "Expected to get 5 separate track change items");

            Assert.AreEqual("Style", ttTC.Nodes[0].GetInfo("Type")[0].value);
            Assert.AreEqual("Workshare", ttTC.Nodes[0].GetInfo("Author")[0].value);
            Assert.AreEqual("Paragraph 1\r", ttTC.Nodes[0].GetInfo("Content")[0].value);

            Assert.AreEqual("Paragraph Property", ttTC.Nodes[1].GetInfo("Type")[0].value);
            Assert.AreEqual("Workshare", ttTC.Nodes[1].GetInfo("Author")[0].value);
            Assert.AreEqual("Paragraph 2\r", ttTC.Nodes[1].GetInfo("Content")[0].value);

            Assert.AreEqual("ListNumber", ttTC.Nodes[2].GetInfo("Type")[0].value);
            Assert.AreEqual("Workshare", ttTC.Nodes[2].GetInfo("Author")[0].value);
            Assert.AreEqual("Paragraph 3\r", ttTC.Nodes[2].GetInfo("Content")[0].value);

            Assert.AreEqual("Paragraph Property", ttTC.Nodes[3].GetInfo("Type")[0].value);
            Assert.AreEqual("Workshare", ttTC.Nodes[3].GetInfo("Author")[0].value);
            Assert.AreEqual("Paragraph 4\r", ttTC.Nodes[3].GetInfo("Content")[0].value);

            Assert.AreEqual("ListNumber", ttTC.Nodes[4].GetInfo("Type")[0].value);
            Assert.AreEqual("Workshare", ttTC.Nodes[4].GetInfo("Author")[0].value);
            Assert.AreEqual("Paragraph 5\r", ttTC.Nodes[4].GetInfo("Content")[0].value);
        }
Example #2
0
        protected void TestCleanTextTypeFromDocument(string fileName, ContentType contentType, string[] textThatShouldntBeCleaned)
        {
            fileName = TESTFILE_DIR + fileName;
            string outFileName = fileName + "_cleaned.doc";
            File.Copy(fileName, outFileName, true);
            using (Workshare.FCS.Lite.WordDocumentReader docReader = new WordDocumentReader(outFileName, true))
            {
                docReader.Clean(BuildContentTypeList(contentType));
            }

            using (WordDocumentReader docReader2 = new WordDocumentReader(outFileName, false))
            {
                DocumentText dt = docReader2.Read();

                IAbstractTextType tt = dt.GetUniqueTextType(contentType);
                IAbstractTextType ttHid = dt.GetUniqueTextType(ContentType.HiddenText);
                if (tt == null && ttHid == null)
                {
                    CheckHaventCleanedTooMuch(dt.GetUniqueTextType(ContentType.Paragraph), textThatShouldntBeCleaned);

                    return;
                }

                if (tt != null)
                    Assert.AreEqual(0, tt.Nodes.Count, "Expected all the items of type " + contentType.ToString() + " to have been cleaned");

                if (ttHid != null)
                    Assert.AreEqual(0, ttHid.Nodes.Count, "Expected no significant hidden text to show up");


            }
        }
        public override void Execute(WorkItem workItem)
        {
            try
            {
                m_workItem = workItem;
                DocumentText dtCheck;
                switch (workItem.Extension)
                {
                    case "doc":
                        WordDocumentReader wrdRdr = new WordDocumentReader(workItem.BaseFileName);
                        try
                        {
                            dtCheck = wrdRdr.Read();
                        }
                        catch (Exception)
                        {
                            return; // failed to discover source document
                        }
                        CompareDiscoveryForDoc(workItem.BaseFileName, workItem.DiscoveredText, dtCheck);
                        break;

                    case "ppt":
                        PptDocumentReader pptRdr = new PptDocumentReader(workItem.BaseFileName);
                        try
                        {
                            dtCheck = pptRdr.Read();
                        }
                        catch (Exception)
                        {
                            return; // failed to discover source document
                        }
                        CompareDiscoveryForPpt(workItem.BaseFileName, workItem.DiscoveredText, dtCheck);
                        break;

                    case "xls":
                        ExcelDocumentReader xlsRdr = new ExcelDocumentReader(workItem.BaseFileName);
                        try
                        {
                            dtCheck = xlsRdr.Read();
                        }
                        catch (Exception)
                        {
                            return; // failed to discover source document
                        }
                        CompareDiscoveryForXls(workItem.BaseFileName, workItem.DiscoveredText, dtCheck);
                        break;

                    default:
                        throw new Exception("File extension not expected : " + workItem.Extension);
                }
            }
            catch (Exception e)
            {
                workItem.FailureMode = FailureMode.DiscoveryMismatch;
                throw e;
            }
        }
Example #4
0
        protected static IAbstractTextType GetDiscoveredTextType(string fileName, ContentType contentType)
        {
            Workshare.FCS.Lite.WordDocumentReader docReader = new WordDocumentReader(TESTFILE_DIR + fileName);
            DocumentText docText = docReader.Read();

            IAbstractTextType ttresult = docText.GetUniqueTextType(contentType);
            Assert.IsNotNull(ttresult, "we unexpectedly found no text of content type " + contentType.ToString());

            return ttresult;
        }
        public void TestDiscoverSmallTextWithParaCharInteractionAndMultiPara_tc1()
        {
            string fileName = TESTFILE_DIR + "MultiParaSmallText_tracked_1.doc";

            Workshare.FCS.Lite.WordDocumentReader docReader = new WordDocumentReader(fileName);
            DocumentText docText = docReader.Read();

            IAbstractTextType ttST = docText.GetUniqueTextType(ContentType.SmallText);
            Assert.IsNotNull(ttST, "we unexpectedly found no small text");

            Assert.AreEqual(1, ttST.Count, "Expected to get 1 separate small text items");
            Assert.AreEqual("but this large", ttST.Nodes[0].GetInfo("Content")[0].value);

        }
        public override bool VerifyFile(TempFileForActions tempFile)
        {
            try
            {
                using (WordDocumentReader reader = new WordDocumentReader(tempFile.TempFile, true))
                {
                    reader.Read();
                    return true;
                }
            }
            catch (System.Exception ex)
            {
                Logger.LogError("Word Verification failed");
				Logger.LogError(ex);
            }
            return false;
        }
        public void TestDiscoverSmallTextWithParaCharInteractionAndMultiPara()
        {
            string fileName = TESTFILE_DIR + "MultiParaSmallText.doc";

            Workshare.FCS.Lite.WordDocumentReader docReader = new WordDocumentReader(fileName);
            DocumentText docText = docReader.Read();

            IAbstractTextType ttST = docText.GetUniqueTextType(ContentType.SmallText);
            Assert.IsNotNull(ttST, "we unexpectedly found no hidden text");

            Assert.AreEqual(4, ttST.Count, "Expected to get 4 separate small text items");
            Assert.AreEqual("This is in small ", ttST.Nodes[0].GetInfo("Content")[0].value);
            Assert.AreEqual(" and more small\r", ttST.Nodes[1].GetInfo("Content")[0].value);
            Assert.AreEqual("An entirely small para\r", ttST.Nodes[2].GetInfo("Content")[0].value);
            Assert.AreEqual("And another\r", ttST.Nodes[3].GetInfo("Content")[0].value);

        }
        public void TestDiscoverHiddenTextWithHierarchichalStyles()
        {
            string fileName = TESTFILE_DIR + "HierarchicalHiddenStyles.doc";
            Workshare.FCS.Lite.WordDocumentReader docReader = new WordDocumentReader(fileName);
            DocumentText docText = docReader.Read();

            IAbstractTextType ttHT = docText.GetUniqueTextType(ContentType.HiddenText);
            Assert.IsNotNull(ttHT, "we unexpectedly found no hidden text");

            Assert.AreEqual(5, ttHT.Count, "Expected to get 5 separate hidden text items");

            Assert.AreEqual("Hidden style\r", ttHT.Nodes[0].GetInfo("Content")[0].value);
            Assert.AreEqual("Double opposite style\r", ttHT.Nodes[1].GetInfo("Content")[0].value);
            Assert.AreEqual("HiddenChar style\r", ttHT.Nodes[2].GetInfo("Content")[0].value);
            Assert.AreEqual("2Oppos ", ttHT.Nodes[3].GetInfo("Content")[0].value);
            Assert.AreEqual(" hidden", ttHT.Nodes[4].GetInfo("Content")[0].value);

        }
Example #9
0
        public void TestQuickDiscovery()
        {
            string fileName = TESTFILE_DIR + "Simple.doc";
            Workshare.FCS.Lite.WordDocumentReader docReader = new WordDocumentReader(fileName);
            DocumentText docText = docReader.Read();

            IAbstractTextType ttHidden = docText.GetUniqueTextType(ContentType.HiddenText);

            foreach (IAbstractTextNode tn in ttHidden)
            {
                foreach (NodeInfo ni in tn.GetInfo("Content"))
                {
                    if (ni.value == "Some hidden text\r")
                        return;
                }
            }

            Assert.Fail("Did not find expected hidden text");
        }
Example #10
0
        public DocumentText DiscoverDocument(string sFilename)
        {
            switch (m_ft)
            {
                case Workshare.Policy.FileType.WordDocument:
                    using (WordDocumentReader Word2003Reader1 = new WordDocumentReader(sFilename, false))
                    {
                        return Word2003Reader1.Read();
                    }

                case Workshare.Policy.FileType.ExcelSheet:
                    using (ExcelDocumentReader Excel2003Reader1 = new ExcelDocumentReader(sFilename, false))
                    {
                        return Excel2003Reader1.Read();
                    }

                case Workshare.Policy.FileType.PowerPoint:
                    using (Workshare.FCS.Lite.PptDocumentReader Ppt2003Reader1 = new PptDocumentReader(sFilename, false))
                    {
                        return Ppt2003Reader1.Read();
                    }

                default:
                    break;
            }
            return null;
        }
        private void TestCleanTCsFromDocument(string fileName, bool checkHiddenText)
        {
            string outFileName = fileName + "_cleaned.doc";
            File.Copy(fileName, outFileName, true);
            using (Workshare.FCS.Lite.WordDocumentReader docReader = new WordDocumentReader(outFileName, true))
            {
                docReader.Clean(BuildContentTypeList(ContentType.TrackChange));
            }

            using (WordDocumentReader docReader2 = new WordDocumentReader(outFileName, false))
            {
                DocumentText dt = docReader2.Read();

                IAbstractTextType tt = dt.GetUniqueTextType(ContentType.TrackChange);
                IAbstractTextType ttHid = dt.GetUniqueTextType(ContentType.HiddenText);
                if (tt == null && ttHid == null)
                    return;

                if (tt != null)
                    Assert.AreEqual(0, tt.Nodes.Count, "Expected all the track changes to have been cleaned");

                if (checkHiddenText)
                {
                    if (ttHid != null)
                        Assert.AreEqual(0, ttHid.Nodes.Count, "Expected no significant hidden text to show up");
                }


            }
        }
        public void TestDontDiscoverListNumTCsWhereTheyDontExist()
        {
            string fileName = TESTFILE_DIR + "AppSpec.doc";
            Workshare.FCS.Lite.WordDocumentReader docReader = new WordDocumentReader(fileName);
            DocumentText docText = docReader.Read();

            IAbstractTextType ttTC = docText.GetUniqueTextType(ContentType.TrackChange);
            if (ttTC == null)
                return; // all well

            Assert.AreEqual(0, ttTC.Count, "Expected to get no track change items");

        }
        public void TestDiscover2TableChangesInSameTable()
        {
            string fileName = TESTFILE_DIR + "2TableTCsInOneTable.doc";
            Workshare.FCS.Lite.WordDocumentReader docReader = new WordDocumentReader(fileName);
            DocumentText docText = docReader.Read();

            IAbstractTextType ttTC = docText.GetUniqueTextType(ContentType.TrackChange);
            Assert.IsNotNull(ttTC, "we unexpectedly found no track changes");

            Assert.AreEqual(2, ttTC.Count, "Expected to get 2 separate track change items");

            foreach (IAbstractTextNode node in ttTC.Nodes)
            {
                Assert.AreEqual("Table Properties", node.GetInfo("Type")[0].value);
            }
        }
        public void TestDiscoverListnumChanges()
        {
            string fileName = TESTFILE_DIR + "ChangesToListNums.doc";
            Workshare.FCS.Lite.WordDocumentReader docReader = new WordDocumentReader(fileName);
            DocumentText docText = docReader.Read();

            IAbstractTextType ttTC = docText.GetUniqueTextType(ContentType.TrackChange);
            Assert.IsNotNull(ttTC, "we unexpectedly found no track changes");

            Assert.AreEqual(2, ttTC.Count, "Expected to get 2 separate track change items");


            Assert.AreEqual("Insertion", ttTC.Nodes[0].GetInfo("Type")[0].value);
            Assert.AreEqual("Workshare", ttTC.Nodes[0].GetInfo("Author")[0].value);
            Assert.AreEqual("two and a half\r", ttTC.Nodes[0].GetInfo("Content")[0].value);

            Assert.AreEqual("ListNumber", ttTC.Nodes[1].GetInfo("Type")[0].value);
            Assert.AreEqual("Workshare", ttTC.Nodes[1].GetInfo("Author")[0].value);
            Assert.AreEqual("two and a half\r", ttTC.Nodes[1].GetInfo("Content")[0].value);

        }
        public void TestDiscoverCharFormattingTCs()
        {
            string fileName = TESTFILE_DIR + "DiscoverCharTCs.doc";
            Workshare.FCS.Lite.WordDocumentReader docReader = new WordDocumentReader(fileName);
            DocumentText docText = docReader.Read();

            IAbstractTextType ttTC = docText.GetUniqueTextType(ContentType.TrackChange);
            Assert.IsNotNull(ttTC, "we unexpectedly found no track changes");

            Assert.AreEqual(9, ttTC.Count, "Expected to get 9 separate track change items");

            for (int i = 0; i < 9; i++)
            {
                Assert.AreEqual("Property", ttTC.Nodes[i].GetInfo("Type")[0].value);
            }
        }
		DocumentText DiscoverDocument(string sFilename)
		{
			switch (m_ft)
			{
				case Workshare.Policy.FileType.WordDocument:
					using (WordDocumentReader Word2003Reader1 = new WordDocumentReader(sFilename, false))
					{
						return Word2003Reader1.Read();
					}

				case Workshare.Policy.FileType.ExcelSheet:
					using (ExcelDocumentReader Excel2003Reader1 = new ExcelDocumentReader(sFilename, false))
					{
						return Excel2003Reader1.Read();
					}

				case Workshare.Policy.FileType.PowerPoint:
					using (Workshare.FCS.Lite.PptDocumentReader Ppt2003Reader1 = new PptDocumentReader(sFilename, false))
					{
						return Ppt2003Reader1.Read();
					}

				case Workshare.Policy.FileType.WordDocumentX:
				case Workshare.Policy.FileType.WordDocumentMacroX:
				case Workshare.Policy.FileType.WordDocumentTemplateX:
				case Workshare.Policy.FileType.WordDocumentMacroTemplateX:
					using (DocxDocumentReader Word2007Reader1 = new DocxDocumentReader(sFilename))
					{
						return Word2007Reader1.Read();
					}

				case Workshare.Policy.FileType.ExcelSheetX:
				case Workshare.Policy.FileType.ExcelSheetMacroX:
				case Workshare.Policy.FileType.ExcelSheetTemplateX:
				case Workshare.Policy.FileType.ExcelSheetMacroTemplateX:
					using (XlsxDocumentReader Excel2007Reader1 = new XlsxDocumentReader(sFilename))
					{
						return Excel2007Reader1.Read();
					}

				case Workshare.Policy.FileType.PowerPointX:
				case Workshare.Policy.FileType.PowerPointMacroX:
				case Workshare.Policy.FileType.PowerPointTemplateX:
				case Workshare.Policy.FileType.PowerPointMacroTemplateX:
				case Workshare.Policy.FileType.PowerPointShowX:
				case Workshare.Policy.FileType.PowerPointMacroShowX:
					using (PptxDocumentReader Ppt2007Reader1 = new PptxDocumentReader(sFilename))
					{
						return Ppt2007Reader1.Read();
					}
				default:
					break;
			}
			return null;
		}
        public void TestDiscoverTableChanges()
        {
            string fileName = TESTFILE_DIR + "TestTableTCs.doc";
            Workshare.FCS.Lite.WordDocumentReader docReader = new WordDocumentReader(fileName);
            DocumentText docText = docReader.Read();

            IAbstractTextType ttTC = docText.GetUniqueTextType(ContentType.TrackChange);
            Assert.IsNotNull(ttTC, "we unexpectedly found no track changes");

            Assert.AreEqual(7, ttTC.Count, "Expected to get 7 separate track change items");

            Assert.AreEqual("Table Properties", ttTC.Nodes[1].GetInfo("Type")[0].value);
            Assert.AreEqual("Table Properties", ttTC.Nodes[6].GetInfo("Type")[0].value);

        }