예제 #1
0
        private bool IsExpectedFromRedaction(IAbstractTextType tt)
        {
            if (tt == null)
                return true;

            int iChildCount = tt.GetChildCount();
            ContentType contType = tt.GetContentType();

            switch (tt.GetContentType())
            {
                case ContentType.Header:
                case ContentType.Footer:
                case ContentType.Endnote:
                case ContentType.Footnote:
                case ContentType.Paragraph:
                case ContentType.WorkshareProperty:
                case ContentType.CellText:
                case ContentType.HiddenColumn:
                case ContentType.HiddenRow:
                    return true; // we don't clean any of these


                case ContentType.TextBox:
                    if (IsPowerPoint() || IsExcel())
                        return true;
                    break;

                case ContentType.AttachedTemplate:
                    if (IsThereASignificantAttachedTemplate(tt))
                        return false;
                    return true ;

                case ContentType.Field:
                    if (AreThereAnyNonQuoteFields(tt))
                        return false;
                    return true;

                case ContentType.HiddenText:
                    if (TypeHasNonWhitespaceContent(tt))
                        return false;
                    return true;

            }
            if (tt.GetChildCount() > 0)
                return false;

            return true;
        }
예제 #2
0
        static private List<KeyValuePair<string, string>> _typeList2Pair(
                                                        string key, string value, IAbstractTextType textType)
        {
           List<KeyValuePair<string, string>> pairList = new List<KeyValuePair<string, string>>();

            try
            {

                for (int i = 0; i < textType.GetChildCount(); ++i)
                {
                    IAbstractTextNode textNode = textType.GetChild(i);

                    string keyStr = _nodeValueFromName(textNode, key);
                    string valStr = _nodeValueFromName(textNode, value);

                    pairList.Add(new KeyValuePair<string, string>(keyStr, valStr));
                }
            }
            catch( System.Exception e )
            {
				Logger.LogError(e);
            }

            return pairList;
        }
예제 #3
0
파일: Task.cs 프로젝트: killbug2004/WSProf
 public static string DumpTextType(IAbstractTextType ttOrig)
 {
     StringBuilder bld = new StringBuilder();
     for (int i = 0; i < ttOrig.GetChildCount(); i++)
     {
         bld.Append(DumpNode(ttOrig.GetChild(i)));
     }
     return bld.ToString();
 }
예제 #4
0
        public static void CheckNode(IAbstractTextType ttype, string expectedName, string expectedValue)
        {
            for (int i = 0; i < ttype.GetChildCount(); i++)
            {
                IAbstractTextNode iAbstractTextNode = ttype.GetChild(i);
                Assert.IsNotNull(iAbstractTextNode);
                Assert.Greater(iAbstractTextNode.GetInfo("Name").Count, 0, "missing info for the property name");
                if (expectedName == iAbstractTextNode.GetInfo("Name")[0].value)
                {
                    Assert.Greater(iAbstractTextNode.GetInfo("Value").Count, 0, "missing info for the property value");
                    Assert.AreEqual(expectedValue, iAbstractTextNode.GetInfo("Value")[0].value, "Built in property name incorrect");

                    return;
                }
            }
            Assert.Fail("Didn't find the property type expected - " + expectedName);

        }
예제 #5
0
        static private List<string> _typeList2List(IAbstractTextType textType)
        {
            List<string> list = new List<string>();

            try
            {
                for (int i = 0; i < textType.GetChildCount(); ++i)
                {
                    IAbstractTextNode textNode = textType.GetChild(i);

                    for (int j = 0; j < textNode.GetInfoCount(); ++j)
                    {
                        NodeInfo nodeInfo = textNode.GetInfo(j);
                        string nodeValue = (nodeInfo != null) ? nodeInfo.value : "";
                        list.Add(EscapeXML(nodeValue));
                    }
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError(e);
            }

            return list;
        }
예제 #6
0
        private static void HyperLinks(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            /*
            DOC
            textNode.GetInfo(0)
                name: "Content"
                type: String
                value: "HYPERLINK"
            XLS
            textNode.GetInfo(0)
                name: "Description"
                type: String
                value: "www.bbc.co.uk/news"
            textNode.GetInfo(1)
                name: "Path"
                type: String
                value: "http://www.bbc.co.uk/news"
            PPT
            textNode.GetInfo(0)
                name: "Content"
                type: String
                value: "HL 1"
            textNode.GetInfo(1)
                name: "Path"
                type: String
                value: "http://www.btyahoo.com/welcome2"
            */
            /// List<KeyValuePair<string, string>> pairList = _typeList2Pair(textType);

            for (int i = 0; i < textType.GetChildCount(); ++i)
            {
                IAbstractTextNode textNode = textType.GetChild(i);

                string keyStr = textNode.GetInfo(0).name;
                string valStr = (textNode.GetInfoCount() > 1) ?
                    textNode.GetInfo(1).value : textNode.GetInfo(0).value;

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" Type=""";
                builtString += keyStr;
                builtString += @""">";
                builtString += _putCDataSection(valStr);
                builtString += @"</" + typeText + @">";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }
        }
예제 #7
0
        static private List<KeyValuePair<string, string>> _typeList2Pair(IAbstractTextType textType)
        {
            List<KeyValuePair<string, string>> pairList = new List<KeyValuePair<string, string>>();

            try
            {
                for (int i = 0; i < textType.GetChildCount(); ++i)
                {
                    IAbstractTextNode textNode = textType.GetChild(i);

                    for (int j = 0; j < textNode.GetInfoCount(); ++j)
                    {
                        NodeInfo nodeInfo = textNode.GetInfo(j);
                        pairList.Add(new KeyValuePair<string, string>(nodeInfo.name, EscapeXML(nodeInfo.value)));
                    }
                }
            }
            catch( System.Exception e )
            {
				Logger.LogError(e);
            }

            return pairList;
        }
예제 #8
0
        private bool HadJustThisDocumentMacro(IAbstractTextType ttOrig)
        {
            if (ttOrig.GetChildCount() != 1)
                return false;

            return (ttOrig.GetChild(0).GetInfo("Name")[0].value == "ThisDocument");
        }
예제 #9
0
        private static void RoutingSlip(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            for (int i = 0; i < textType.GetChildCount(); ++i)
            {
                IAbstractTextNode textNode = textType.GetChild(i);

                string message = _nodeValueFromName(textNode, "Message");
                string subject = _nodeValueFromName(textNode, "Subject");

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" Message=""";
                builtString += message;
                builtString += @"""";
                builtString += @" Subject=""";
                builtString += subject;
                builtString += @""">";

                builtString += @"<Recipients>";
                List<NodeInfo> nodeRecipients = textNode.GetInfo("Recipient");
                List<string> recipients = new List<string>();

                foreach (NodeInfo nodeRecipi in nodeRecipients)
                {
                    builtString += @"<Recipient>";
                    builtString += nodeRecipi.value;
                    builtString += @"</Recipient>";
                }

                builtString += @"</Recipients>";
                builtString += @"</" + typeText + @">";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }
        }
예제 #10
0
        public static void HiddenTexts(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            try
            {
                for (int loopi = 0; loopi < textType.GetChildCount(); ++loopi)
                {
                    IAbstractTextNode textNode = textType.GetChild(loopi);
                    string content = _nodeValueFromName(textNode, "Content");
                    if (!_isCommentOrParagraphMarker(content))
                    {
                        string builtString = @"";
                        builtString += @"<" + typeText;

                        for (int loopj = 0; loopj < textNode.GetInfoCount(); ++loopj)
                        {
                            NodeInfo nodeInfo = textNode.GetInfo(loopj);
                            string nodeValue = (nodeInfo != null) ? nodeInfo.value : "";
                            string nodeKey = (nodeInfo != null) ? nodeInfo.name : "";

                            if (!nodeKey.Equals("Content"))
                            {
                                builtString += @" ";
                                builtString += nodeKey;
                                builtString += @"=""";
                                builtString += nodeValue;
                                builtString += @"""";
                            }
                        }
                        builtString += @">";
                        builtString += _putCDataSection(content);
                        builtString += @"</" + typeText + @">";
                        reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                    }
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::HiddenTexts for " + typeText + ", " + textType);
				Logger.LogError(e);
            }
        }
예제 #11
0
        public static void TrackChanges(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            int trackChangeLimit = MetadataProcessor._TrackChangeLimit;

            for (int i = 0; i < textType.GetChildCount() && i < trackChangeLimit; ++i)
            {
                IAbstractTextNode textNode = textType.GetChild(i);

                string content = _nodeValueFromName(textNode, "Content");
                string author = _nodeValueFromName(textNode, "Author");
                string type = _nodeValueFromName(textNode, "Type");

                if (!_isCommentOrParagraphMarker(content))
                {
                    string builtString = @"";
                    builtString += @"<" + typeText;
                    builtString += @" Author=""";
                    builtString += author;
                    builtString += @"""";
                    builtString += @" Type=""";
                    builtString += type;
                    builtString += @""">";
                    builtString += _putCDataSection(content);
                    builtString += @"</" + typeText + @">";

                    reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                }
            }
        }
예제 #12
0
        static private string _typeList2String(IAbstractTextType textType)
        {
            NodeInfo nodeInfo = null;

            if (textType.GetChildCount() > 0)
            {
                IAbstractTextNode textNode = textType.GetChild(0);

                if (textNode.GetInfoCount() > 0)
                {
                    nodeInfo = textNode.GetInfo(0);
                }
            }

            string strValue = (nodeInfo == null) ? "" : nodeInfo.value;

            return EscapeXML(strValue);
        }
예제 #13
0
        private static void AttachedTemplate(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            if (textType.GetChildCount() > 0)
            {
                IAbstractTextNode textNode = textType.GetChild(0);

                string path = _nodeValueFromName(textNode, "Path");
                string name = _nodeValueFromName(textNode, "Name");

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" Name=""";
                builtString += name;
                builtString += @"""";
                builtString += @" Path=""";
                builtString += path;
                builtString += @"""";
                builtString += @" />";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }
        }
예제 #14
0
        private static void RedactedText(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            /*
            textNode.GetInfo(0)
                name: "Content"
                type: String
                value: "http://www.csub.edu/"
            textNode.GetInfo(1)
                name: "SheetName"
                type: String
                value: "Sheet1"
            textNode.GetInfo(2)
                name: "Row"
                type: Long
                value: "67"
            textNode.GetInfo(3)
                name: "Column"
                type: Long
                value: "1"
            */
            for (int i = 0; i < textType.GetChildCount(); ++i)
            {
                IAbstractTextNode textNode = textType.GetChild(i);

                string content = _nodeValueFromName(textNode, "Content");
                string sheet = _nodeValueFromName(textNode, "SheetName");
                string row = _nodeValueFromName(textNode, "Row");
                string column = _nodeValueFromName(textNode, "Column");

                StringBuilder builtString = new StringBuilder(@"");               
                builtString.Append(@"<" + typeText);
                builtString.Append(@" Row=""");
                builtString.Append(row);
                builtString.Append(@"""");
                builtString.Append(@" Column=""");
                builtString.Append(column);
                builtString.Append(@""">");

                builtString.Append(@"<Content>");
                builtString.Append(content);
                builtString.Append(@"</Content>");

                builtString.Append(@"<Sheet>");
                builtString.Append(sheet);
                builtString.Append(@"</Sheet>");

                builtString.Append(@"</" + typeText + @">");

                reader.OnContentData(typeText, builtString.ToString(), ref MetadataProcessor._cancel);
            }
        }
예제 #15
0
        private bool AreAllTextBoxesPictures(IAbstractTextType ttOrig)
        {
            for (int i = 0; i < ttOrig.GetChildCount(); i++)
            {
                if (!IsEmbeddingOrEmpty(ttOrig.GetChild(i)))
                    return false;

            }
            return true;
        }
 private void CheckContentNode(IAbstractTextType ttype, string expectedValue)
 {
     for (int i = 0; i < ttype.GetChildCount(); i++)
     {
         IAbstractTextNode iAbstractTextNode = ttype.GetChild(i);
         Assert.IsNotNull(iAbstractTextNode);
         Assert.Greater(iAbstractTextNode.GetInfo("Content").Count, 0, "missing info for the property name");
         string thisValue = iAbstractTextNode.GetInfo("Content")[0].value;
         if (expectedValue == thisValue)
             return;
     }
     Assert.Fail("Didn't find the content expected - " + expectedValue);
 }
예제 #17
0
        private bool IsThereASignificantAttachedTemplate(IAbstractTextType tt)
        {
            if (tt.GetChildCount() == 0)
                return false;

            for (int i = 0; i < tt.GetChildCount(); i++)
            {
                IAbstractTextNode node = tt.GetChild(i);
                for (int j = 0; j < node.GetInfoCount(); j++)
                {
                    NodeInfo ni = node.GetInfo(j);
                    if (ni.name == "Content")
                    {
                        if (ni.value.Trim() != "")
                            return true;

                    }

                }
            }
            return false;

        }
예제 #18
0
        private bool IsAllWhiteSpace(IAbstractTextType ttOrig)
        {
            for (int i = 0; i < ttOrig.GetChildCount(); i++)
            {
                if (!IsAllWhiteSpace(ttOrig.GetChild(i)))
                    return false;

            }
            return true;
        }
예제 #19
0
        private bool TypeHasNonWhitespaceContent(IAbstractTextType tt)
        {
            for (int i = 0; i < tt.GetChildCount(); i++)
            {
                IAbstractTextNode node = tt.GetChild(i);
                for (int j = 0; j < node.GetInfoCount(); j++)
                {
                    NodeInfo ni = node.GetInfo(j);
                    if (ni.name == "Content")
                    {
                        if (!string.IsNullOrEmpty(ni.value.Trim()))
                            return true;

                    }

                }
            }
            return false;
        }
예제 #20
0
        private bool AreThereAnyNonQuoteFields(IAbstractTextType tt)
        {
            for (int i = 0; i < tt.GetChildCount(); i++)
            {
                IAbstractTextNode node = tt.GetChild(i);
                for (int j = 0; j < node.GetInfoCount(); j++)
                {
                    NodeInfo ni = node.GetInfo(j);
                    if (ni.name == "Content")
                    {
                        if (ni.value != "QUOTE")
                            return true;

                    }

                }
            }
            return false;
        }