Beispiel #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;
        }
        /// -----------------------------------------------------------------------------
        public static void ProcessType(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            try
            {
                switch (textType.GetContentType())
                {
                    case ContentType.Paragraph:
                        MetadataProcessor.Paragraphs(reader, "Paragraph", textType);
                        break;
                    case ContentType.Header:
                        MetadataProcessor.Headers(reader, "Header", textType);
                        break;
                    case ContentType.Footer:
                        MetadataProcessor.Footers(reader, "Footer", textType);
                        break;
                    case ContentType.Comment:
                        MetadataProcessor.Comments(reader, "Comment", textType);
                        break;
                    case ContentType.TrackChange:
                        MetadataProcessor.TrackChanges(reader, "TrackChange", textType);
                        break;
                    case ContentType.Reviewer:
                        MetadataProcessor.Reviewers(reader, "Reviewer", textType);
                        break;
                    case ContentType.HiddenText:
                        MetadataProcessor.HiddenTexts(reader, "HiddenText", textType);
                        break;
                    case ContentType.SmallText:
                        MetadataProcessor.SmallTexts(reader, "SmallText", textType);
                        break;
                    case ContentType.WhiteText:
                        MetadataProcessor.WhiteTexts(reader, "WhiteText", textType);
                        break;
                    case ContentType.AttachedTemplate:
                        MetadataProcessor.AttachedTemplate(reader, "AttachedTemplate", textType);
                        break;
                    case ContentType.Version:
                        MetadataProcessor.Versions(reader, "Version", textType);
                        break;
                    case ContentType.AutoVersion:
                        MetadataProcessor.AutoVersion(reader, "AutoVersion", textType);
                        break;
                    case ContentType.Field:
                        MetadataProcessor.Fields(reader, "Field", textType);
                        break;
                    case ContentType.Hyperlink:
                        MetadataProcessor.HyperLinks(reader, "Hyperlink", textType);
                        break;
                    case ContentType.RoutingSlip:
                        MetadataProcessor.RoutingSlip(reader, "RoutingSlip", textType);
                        break;
                    case ContentType.Variable:
                        MetadataProcessor.Variables(reader, "Variable", textType);
                        break;
                    case ContentType.HiddenSlide:
                        MetadataProcessor.HiddenSlide(reader, "HiddenSlide", textType);
                        break;
                    case ContentType.SpeakerNote:
                        MetadataProcessor.SpeakerNote(reader, "SpeakerNote", textType);
                        break;
                    case ContentType.Links:
                        MetadataProcessor.Links(reader, "Link", textType);
                        break;
                    case ContentType.HiddenSheet:
                        MetadataProcessor.HiddenSheet(reader, "HiddenSheet", textType);
                        break;
                    case ContentType.HiddenRow:
                        MetadataProcessor.HiddenRow(reader, "HiddenRow", textType);
                        break;
                    case ContentType.HiddenColumn:
                        MetadataProcessor.HiddenColumn(reader, "HiddenColumn", textType);
                        break;
                    case ContentType.RedactedText:
                        MetadataProcessor.RedactedText(reader, "RedactedText", textType);
                        break;
                    case ContentType.CustomProperty:
                        MetadataProcessor.CustomProperties(reader, "CustomProperty", textType);
                        break;
                    case ContentType.Macro:
                        MetadataProcessor.Macros(reader, "Macro", textType);
                        break;
                    case ContentType.BuiltInProperty:
                        MetadataProcessor.BuildInProperties(reader, "BuiltInProperty", textType);
                        break;
                    case ContentType.DocumentStatistic:
                        MetadataProcessor.DocumentStatistics(reader, "DocumentStatistic", textType);
                        break;
                    case ContentType.Footnote:
                    case ContentType.Endnote:
                        MetadataProcessor.Footnotes(reader, "Footnote", textType);
                        break;
                    case ContentType.TextBox:
                        /// ProcessTextType(reader, "TextBox", textType);
                        break;
                    case ContentType.CellText:
                        //ProcessTextType(reader, "CellText", textType);
                        break;
                    case ContentType.WorkshareProperty:
                        /// ProcessTextType(reader, "WorkshareProperty", textType);
                        break;
                    case ContentType.SmartTag:
                        /// ProcessTextType(reader, "SmartTag", textType);
                        break;
					case ContentType.WorkshareStyle:
						MetadataProcessor.WhiteTexts(reader, "WorkshareStyle", textType);
						break;
                    default:
                        /// throw new ApplicationException("Invalid Content Type in DocumentText! Enums out of date.");
                        break;
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::ProcessType for " + textType.GetContentType());
				Logger.LogError(e);
            }
        }
        private static void DumpFoundText(string filename, IAbstractTextType ttOrig)
        {
            Logger.LogInfo(filename);

            Logger.LogInfo("Missing text type " + ttOrig.GetContentType().ToString());
            Logger.LogInfo(DumpTextType(ttOrig));
        }
        private void CheckTypeWasFound(string fileName, DocumentText discoveredText, IAbstractTextType ttOrig)
        {
            List<IAbstractTextType> ttList = discoveredText.GetTextTypes(ttOrig.GetContentType());
            if (ttList.Count == 0)
            {
                DumpFoundText(fileName, ttOrig);
                m_workItem.Info = DumpTextType(ttOrig);
                m_workItem.ContentType = ttOrig.GetContentType();

                throw new Exception("Failed to discover metadata found in base document");
            }
        }