Ejemplo n.º 1
0
        public bool EvaluateRow(DisplayFilterRowInfo rowInfo)
        {
            var success = Settings.ShowAllContent || rowInfo.IsSegment;

            if (rowInfo.IsSegment)
            {
                if (ReverseSearch)
                {
                    return(CustomFilterHelper.Reverse(Settings, success, rowInfo, CustomSettings, ActiveDocument));
                }

                if (success && Settings.SegmentReviewTypes != null && Settings.SegmentReviewTypes.Any())
                {
                    success = rowInfo.IsSegmentReviewTypes(Settings);
                }

                if (success && Settings.ConfirmationLevels != null && Settings.ConfirmationLevels.Any())
                {
                    success = rowInfo.IsConfirmationLevelFound(Settings);
                }

                if (success && Settings.OriginTypes != null && Settings.OriginTypes.Any())
                {
                    if (!Settings.OriginTypes.Contains("EditedF") && !Settings.OriginTypes.Contains("UneditedF"))
                    {
                        success = rowInfo.IsOriginTypeFound(Settings);
                    }
                }

                if (success && Settings.PreviousOriginTypes != null && Settings.PreviousOriginTypes.Any())
                {
                    success = rowInfo.IsPreviousOriginTypeFound(Settings);
                }

                if (success && Settings.RepetitionTypes != null && Settings.RepetitionTypes.Any())
                {
                    if (!Settings.RepetitionTypes.Contains("Unique"))
                    {
                        success = rowInfo.IsRepetitionTypes(Settings);
                    }
                }

                if (success && Settings.SegmentLockingTypes != null && Settings.SegmentLockingTypes.Any())
                {
                    success = rowInfo.IsSegmentLockingTypes(Settings);
                }

                if (success && Settings.SegmentContentTypes != null && Settings.SegmentContentTypes.Any())
                {
                    success = rowInfo.IsSegmentContentTypes(Settings);
                }

                if (success && (!string.IsNullOrEmpty(Settings.SourceText) || !string.IsNullOrEmpty(Settings.TargetText)))
                {
                    if (!string.IsNullOrEmpty(Settings.SourceText) && !string.IsNullOrEmpty(Settings.TargetText))
                    {
                        if (CustomSettings.SourceAndTargetLogicalOperator == CustomFilterSettings.LogicalOperators.Or)
                        {
                            var successSearchOnSource = IsExpressionFound(Settings.SourceText, rowInfo.SegmentPair.Source, out var _);

                            var successSearchOnTarget = false;
                            if (!successSearchOnSource)
                            {
                                successSearchOnTarget = IsExpressionFound(Settings.TargetText, rowInfo.SegmentPair.Target, out var _);
                            }

                            success = successSearchOnSource || successSearchOnTarget;
                        }
                        else
                        {
                            var appliedFilter = false;
                            if (CustomSettings.UseBackreferences && Settings.IsRegularExpression)
                            {
                                success = FilterOnSourceAndTargetWithBackreferences(rowInfo, out appliedFilter);
                            }

                            if (!appliedFilter)
                            {
                                success = FilterOnSourceAndTarget(rowInfo, true);
                            }
                        }
                    }
                    else
                    {
                        success = FilterOnSourceAndTarget(rowInfo, true);
                    }
                }

                if (success && !CustomSettings.UseRegexCommentSearch && !string.IsNullOrEmpty(Settings.CommentText))
                {
                    success = rowInfo.IsTextFoundInComment(Settings);
                }

                if (success && !string.IsNullOrEmpty(Settings.CommentAuthor))
                {
                    success = rowInfo.IsAuthorFoundInComment(Settings);
                }

                if (success && Settings.CommentSeverity > 0)
                {
                    success = rowInfo.IsSeverityFoundInComment(Settings);
                }

                if (success && Settings.ContextInfoTypes.Any())
                {
                    success = rowInfo.IsContextInfoTypes(Settings);
                }

                // check custom settings
                if (success)
                {
                    success = CustomFilterHelper.Filter(CustomSettings, Settings, rowInfo, true, ActiveDocument);
                }
            }
            return(success);
        }
Ejemplo n.º 2
0
        public bool EvaluateRow(DisplayFilterRowInfo rowInfo)
        {
            var success = Settings.ShowAllContent || rowInfo.IsSegment;

            if (rowInfo.IsSegment)
            {
                if (ReverseSearch)
                {
                    return(CustomFilterHelper.Reverse(Settings, success, rowInfo, CustomSettings, ActiveDocument));
                }

                if (success && Settings.SegmentReviewTypes != null && Settings.SegmentReviewTypes.Any())
                {
                    success = rowInfo.IsSegmentReviewTypes(Settings);
                }

                if (success && Settings.ConfirmationLevels != null && Settings.ConfirmationLevels.Any())
                {
                    success = rowInfo.IsConfirmationLevelFound(Settings);
                }

                if (success && Settings.OriginTypes != null && Settings.OriginTypes.Any())
                {
                    if (!Settings.OriginTypes.Contains("EditedF") && !Settings.OriginTypes.Contains("UneditedF"))
                    {
                        success = rowInfo.IsOriginTypeFound(Settings);
                    }
                }

                if (success && Settings.PreviousOriginTypes != null && Settings.PreviousOriginTypes.Any())
                {
                    success = rowInfo.IsPreviousOriginTypeFound(Settings);
                }

                if (success && Settings.RepetitionTypes != null && Settings.RepetitionTypes.Any())
                {
                    if (!Settings.RepetitionTypes.Contains("Unique"))
                    {
                        success = rowInfo.IsRepetitionTypes(Settings);
                    }
                }

                if (success && Settings.SegmentLockingTypes != null && Settings.SegmentLockingTypes.Any())
                {
                    success = rowInfo.IsSegmentLockingTypes(Settings);
                }


                if (success && Settings.SegmentContentTypes != null && Settings.SegmentContentTypes.Any())
                {
                    success = rowInfo.IsSegmentContentTypes(Settings);
                }


                if (success && Settings.SourceText.Trim() != string.Empty)
                {
                    success = rowInfo.IsTextFoundInSource(Settings);

                    if (Settings.IsRegularExpression)
                    {
                        var textVisitor = new SegmentTextVisitor();
                        var text        = textVisitor.GetText(rowInfo.SegmentPair.Source);
                        success = ContentHelper.SearchContentRegularExpression(text,
                                                                               Settings.SourceText);
                    }
                }

                if (success && Settings.TargetText.Trim() != string.Empty)
                {
                    success = rowInfo.IsTextFoundInTarget(Settings);
                }


                if (success && !CustomSettings.UseRegexCommentSearch && Settings.CommentText.Trim() != string.Empty)
                {
                    success = rowInfo.IsTextFoundInComment(Settings);
                }


                if (success && Settings.CommentAuthor.Trim() != string.Empty)
                {
                    success = rowInfo.IsAuthorFoundInComment(Settings);
                }


                if (success && Settings.CommentSeverity > 0)
                {
                    success = rowInfo.IsSeverityFoundInComment(Settings);
                }


                if (success && Settings.ContextInfoTypes.Any())
                {
                    success = rowInfo.IsContextInfoTypes(Settings);
                }

                // check custom settings
                if (success)
                {
                    success = CustomFilterHelper.Filter(CustomSettings, rowInfo, success, ActiveDocument);
                }
            }
            return(success);
        }