Exemplo n.º 1
0
		private void LoadChangeSummaryItems(object redlineML)
		{
            if (redlineML is RedlineDocument)
            {
                RedlineDoc = redlineML as RedlineDocument;
            }
            else
            {
                using (TextReader tr = BuildTextReader(redlineML))
                {
                    _redlineML = tr.ReadToEnd();
                    RedlineMLReader reader = new RedlineMLReader(new StringReader(_redlineML));
                    RedlineDoc = reader.Execute();
                }
            }
            SummaryItemBuilder sib = new SummaryItemBuilder(RedlineDoc);
            m_changeSummaryItems = sib.Execute();
        }
Exemplo n.º 2
0
        private static void ValidateRedlineMLRegeneratedFromRTF(string origFileName, string modFileName, string path, bool changeNumbersInRedline = true)
        {


            List<ISummaryItem> result = Helpers.ValidateSummaryList(origFileName, modFileName, path, 
                (x) => x.SetOption((int) WsCompose.OptIds.OPTID_NUMBER_CHANGES, changeNumbersInRedline ? -1 : 0));

            Dictionary<int, ChangeType> expectedChangeTypes = new Dictionary<int, ChangeType>();
            foreach (ISummaryItem isi in result)
            {
                foreach (Change ch in isi.Changes)
                {
                    expectedChangeTypes[ch.Number] = ch.Type;
                }
            }

            using (WsActivationContext ac = new WsActivationContext())
            {
                string sRedline = Helpers.LastRTFRedline;
                WsCompose.WSRTFFile file = new WsCompose.WSRTFFile();
                file.InputFileName = sRedline;
                file.ReadFile();

                var pTarget = Helpers.MakeComStreamOnHGlobal();
                file.GetRedlineML(pTarget as WsCompose.IStream);

                string sCreatedRedlineML = Helpers.ExtractTextFromIStream(pTarget);

                Assert.IsFalse(sCreatedRedlineML.Contains("Summary of deletions"));
                Assert.IsFalse(sCreatedRedlineML.Contains("Document comparison by"));
                Assert.IsFalse(sCreatedRedlineML.Contains("Redline Summary"));
                Assert.IsFalse(sCreatedRedlineML.Contains("Legend:"));
                Assert.IsFalse(sCreatedRedlineML.Contains("Statistics:"));
                Assert.IsFalse(sCreatedRedlineML.Contains(">80<"), "shouldn't be leaving change numbers in");


                Helpers.ValidateRedlineML(sCreatedRedlineML);

                RedlineMLReader reader = new RedlineMLReader(new StringReader(sCreatedRedlineML));
                RedlineDocument rd = reader.Execute();

                SummaryItemBuilder bld = new SummaryItemBuilder(rd);
                List<ISummaryItem> result2 = bld.Execute();
                Helpers.ValidateChangeNumbers(result2);

                foreach (ISummaryItem isi in result2)
                {
                    foreach (Change ch in isi.Changes)
                    {
                        Assert.AreEqual(expectedChangeTypes[ch.Number], ch.Type, "Mismatched change type on " + ch.Number.ToString());
                    }
                }

                Assert.AreEqual(result.Count, result2.Count);
            }
        }
Exemplo n.º 3
0
 public void TestSimpleFilterChangesFromSearchResults()
 {
     RedlineDocument rd = Helpers.DoTest("simple1.doc", "simple2.doc", UnitTestFileDir);
     var result = RedlineMLSearch.Execute(new List<string>() { "three" }, rd, (ChangeType t) => Utils.IsInOriginalDocument(t), (x) => false)["three"];
     Assert.AreEqual(2, result.MatchLocations.Count);
     List<ISummaryItem> changeSummary = new SummaryItemBuilder(rd).Execute();
     result.FilterOutMatchesInChanges();
     Assert.AreEqual(1, result.MatchLocations.Count);
 }