Esempio n. 1
0
        public override void Read(IDocumentReader reader)
        {
            if (!CanOpenContent)
                return;

            using (Stream str = m_fileData.BinaryFileData.AsStream())
            {
                EmailFormatHandler handler = EmailFormatHandler.ReadEmail(str);
                if (null == handler)
                    return;

                bool cancel = false;
                reader.OnContentData("Subject", handler.Subject, ref cancel);

                if (Utils.IsStringHTML(handler.Body))
                {
                    byte[] bytes = Encoding.Unicode.GetBytes(handler.Body);
                    ReadContent(reader, new HtmlReader(bytes));
                }
                else
                    reader.OnContentData("Body", handler.Body, ref cancel);

                foreach (string attachment in handler)
                {
                    reader.OnContentData("Attachments", attachment, ref cancel);
                }
            }
        }
Esempio n. 2
0
        public static void Paragraphs(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<string> list = _typeList2List(textType);

            foreach (string item in list)
            {
                if (!_isCommentOrParagraphMarker(item))
                {
                    string builtString = _putCDataSection(item);

                    reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                }
            }
        }
Esempio n. 3
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);
                }
            }
        }
Esempio n. 4
0
        public static void WhiteTexts(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<string> list = _typeList2List(textType);

            try
            {

                foreach (string item in list)
                {
                    if (!_isCommentOrParagraphMarker(item) && !_isCommentMarker(item))
                    {
                        string builtString = @"";
                        builtString += @"<" + typeText + @">";
                        builtString += _putCDataSection(item);
                        builtString += @"</" + typeText + @">";

                        reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                    }
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::WhiteTexts for " + typeText + ", " + textType);
				Logger.LogError(e);
            }
        }
Esempio n. 5
0
        public virtual void Read(IDocumentReader reader)
        {
            if (!((CanOpenContent) || (IsEncryptedFileAFormatWeCanReadCustomPropertiesFrom())))
                return;

                switch (m_fileData.FileType)
                {
                    case FileType.WordDocument:
                        ReadContent(reader, new WordDocumentReader(m_fileData.BinaryFileData));
                        break;
                    case FileType.WordDocumentX:
                    case FileType.WordDocumentMacroX:
                    case FileType.WordDocumentTemplateX:
                    case FileType.WordDocumentMacroTemplateX:
                        ReadContent(reader, new DocxDocumentReader(m_fileData.BinaryFileData));
                        break;
                    case FileType.PowerPoint:
                        ReadContent(reader, new PptDocumentReader(m_fileData.BinaryFileData));
                        break;
                    case FileType.PowerPointX:
                    case FileType.PowerPointMacroX:
                    case FileType.PowerPointTemplateX:
                    case FileType.PowerPointMacroTemplateX:
					case FileType.PowerPointShowX:
					case FileType.PowerPointMacroShowX:
                        ReadContent(reader, new PptxDocumentReader(m_fileData.BinaryFileData));
                        break;
                    case FileType.ExcelSheet:
                        ReadContent(reader, new ExcelDocumentReader(m_fileData.BinaryFileData));
                        break;
                    case FileType.ExcelSheetX:
                    case FileType.ExcelSheetMacroX:
                    case FileType.ExcelSheetTemplateX:
                    case FileType.ExcelSheetMacroTemplateX:
                        ReadContent(reader, new XlsxDocumentReader(m_fileData.BinaryFileData));
                        break;
                    case FileType.TextDocument:
                        bool cancel = false;
                        reader.OnContentData("Paragraph", m_fileData.BinaryFileData.AsString(m_fileData.BinaryFileData.Length, m_fileData.Encoding), ref cancel);
                        return;
                    case FileType.HTTPContent:
                        bool cancelHttp = false;
                        reader.OnContentData("HTTPContent", m_fileData.BinaryFileData.AsString(m_fileData.BinaryFileData.Length, m_fileData.Encoding), ref cancelHttp);
                        return;
					case FileType.PDFDocument:
                        ReadContent(reader, new PdfDocumentReader(m_fileData.Filename, m_fileData.Password));
						break;
					case FileType.RTFDocument:
						ReadContent(reader, new RtfReader(m_fileData.BinaryFileData));
						break;
					case FileType.HTMLDocument:
						ReadContent(reader, new HtmlReader(m_fileData.BinaryFileData));
						break;
					default:
						Logger.LogInfo(("Reading unknown file type " + m_fileData.FileType.ToString()));
                        ReadContent(reader, new FallbackReader(m_fileData.BinaryFileData));
                        break;
                }
        }
Esempio n. 6
0
        private static void HiddenSheet(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<string> list = _typeList2List(textType);

            foreach (string item in list)
            {
                string builtString = item;

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }

        }
Esempio n. 7
0
        private static void Links(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("Type", "Path", textType);

            for (int i = 0; i < pairList.Count; ++i)
            {
                KeyValuePair<string, string> pair = pairList[i];

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" Type=""";
                builtString += pair.Key;
                builtString += @""">";
                builtString += _putCDataSection(pair.Value);
                builtString += @"</" + typeText + @">";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }
        }
Esempio n. 8
0
        private static void Versions(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("Saved By", "Comment", textType);

            for (int i = 0; i < pairList.Count; ++i)
            {
                KeyValuePair<string, string> pair = pairList[i];

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" SavedBy=""";
                builtString += pair.Key;
                builtString += @"""";
                builtString += @" Comment=""";
                builtString += pair.Value;
                builtString += @"""";
                builtString += @" />";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }

            MetadataProcessor.Authors(pairList);
        }
Esempio n. 9
0
        private static void DocumentStatistics(
                                        IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("Name", "Value", textType);

            try
            {

                for (int i = 0; i < pairList.Count; ++i)
                {
                    KeyValuePair<string, string> pair = pairList[i];

                    string builtString = @"";
                    builtString += @"<" + typeText;
                    builtString += @" Name=""";
                    builtString += pair.Key;
                    builtString += @"""";
                    builtString += @" Value=""";
                    builtString += pair.Value;
                    builtString += @"""";
                    builtString += @" />";

                    reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::DocumentStatistics for " + typeText + ", " + textType);
				Logger.LogError(e);

            }
        }
Esempio n. 10
0
        /// -----------------------------------------------------------------------------
        private static void BuildInProperties(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            try
            {
                List<KeyValuePair<string, string>> pairList = _typeList2Pair("Name", "Value", textType);

                for (int i = 0; i < pairList.Count; ++i)
                {
                    KeyValuePair<string, string> pair = pairList[i];

                    if (!_isCommentOrParagraphMarker(pair.Value))
                    {
                        string builtString = @"";
                        builtString += @"<" + typeText;
                        builtString += @" Name=""";
                        builtString += pair.Key;
                        builtString += @""">";
                        builtString += _putCDataSection(pair.Value);
                        builtString += @"</" + typeText + @">";

                        reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                    }
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::BuildInProperties for " + typeText + ", " + textType);
				Logger.LogError(e);
            }
        }
Esempio n. 11
0
        private static void HiddenSlide(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            // ppt we get "SlideId" and "Title"
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("SlideId", "Title", textType);
            // pptx we get "SlideNumber" and "Content"
            if (pairList.Count != 0)
                CheckForPPTx(ref pairList, "SlideNumber", "Content", textType);

            for (int i = 0; i < pairList.Count; ++i)
            {
                KeyValuePair<string, string> pair = pairList[i];

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" SlideId=""";
                builtString += pair.Key;
                builtString += @""">";
                builtString += _putCDataSection(pair.Value);
                builtString += @"</" + typeText + @">";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }
        }
Esempio n. 12
0
        private static void SpeakerNote(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("SlideId", "SpeakerNote", textType);

            for (int i = 0; i < pairList.Count; ++i)
            {
                KeyValuePair<string, string> pair = pairList[i];               

                reader.OnContentData(typeText, pair.Value, ref MetadataProcessor._cancel);
            }
        }
Esempio n. 13
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);
            }
        }
Esempio n. 14
0
        private static void ProcessTextType(IDocumentReader reader, string textTypeStringified, FCS.Lite.Base.IAbstractTextType textType)
        {
            if (MetadataProcessor.OperMode == MetadataProcessor._OperMode.Professional)
            {
                Workshare.FCS.Lite.Base.ContentType type = textType.GetContentType();

                if (!((type == Workshare.FCS.Lite.Base.ContentType.TextBox) ||
                   (type == Workshare.FCS.Lite.Base.ContentType.CellText) ||
                   (type == Workshare.FCS.Lite.Base.ContentType.WorkshareProperty) ||
                   (type == Workshare.FCS.Lite.Base.ContentType.SmartTag)))
                {
                    MetadataProcessor.ProcessType(reader, textTypeStringified, textType);

                    return;
                }
            }

            bool cancel = false;

            FCS.Lite.Base.IAbstractTextType basicTextType = textType;
            if (basicTextType == null)
                return;

            for (int i = 0; i < textType.GetChildCount(); ++i)
            {
                FCS.Lite.Base.IAbstractTextNode textNode = basicTextType.GetChild(i);
                List<FCS.Lite.Base.NodeInfo>.Enumerator enumer = textNode.InfoEnumerator();

                StringBuilder builtString = new StringBuilder();

                while (enumer.MoveNext())
                {
                    if (((enumer.Current.name == "Content") && (textTypeStringified != "TrackChange")) ||
                        ((enumer.Current.name == "Comment") && ((textTypeStringified == "Comment") || (textTypeStringified == "CellText"))))
                        builtString.Append(enumer.Current.value);
                    else if (string.Compare(textTypeStringified, "TrackChange", true, CultureInfo.InvariantCulture) == 0)
                        builtString.Append(enumer.Current.value);
                }

                reader.OnContentData(textTypeStringified, builtString.ToString(), ref cancel);
            }
        }
Esempio n. 15
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);
            }
        }
Esempio n. 16
0
        private static void Footnotes(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<string> list = _typeList2List(textType);
            foreach (string item in list)
            {
                if (!_isCommentOrParagraphMarker(item) && !_isCommentMarker(item))
                {
                    string builtString = @"";
                    builtString += @"<" + typeText + @">";
                    builtString += _putCDataSection(item);
                    builtString += @"</" + typeText + @">";

                    reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                }
            }

        }
Esempio n. 17
0
        private static void Macros(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<string> list = _typeList2List(textType);

            try
            {
                foreach (string item in list)
                {
                    string builtString = item;
                    reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::Macros for " + typeText + ", " + textType);
				Logger.LogError(e);
            }
        }
Esempio n. 18
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);
            }
        }
Esempio n. 19
0
        private static void Fields(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("Instruction", "Content", textType);

            try
            {
                for (int i = 0; i < pairList.Count; ++i)
                {
                    KeyValuePair<string, string> pair = pairList[i];

                    // if (!_isCommentOrParagraphMarker(pair.Value))
					if (!_isHyperlink(pair.Value))	// hyperlinks added separately
                    {
                        string builtString = @"";
                        builtString += @"<" + typeText;
                        builtString += @" Instruction=""";
                        builtString += pair.Key;
                        builtString += @""">";
                        builtString += pair.Value;
                        builtString += @"</" + typeText + @">";

                        reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                    }
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::Fields for " + typeText + ", " + textType);
				Logger.LogError(e);
            }
        }
Esempio n. 20
0
        private static void AutoVersion(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            string builtString = _typeList2String(textType);

            reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
        }
Esempio n. 21
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);
            }
        }
Esempio n. 22
0
        private static void HiddenColumn(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("SheetName", "Column", textType);

            for (int i = 0; i < pairList.Count; ++i)
            {
                KeyValuePair<string, string> pair = pairList[i];

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" Column=""";
                builtString += pair.Value;
                builtString += @""">";
                builtString += pair.Key;
                builtString += @"</" + typeText + @">";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }
        }
Esempio n. 23
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);
            }
        }