Exemplo n.º 1
0
        public static bool IsInFuzzyRange(DisplayFilterRowInfo row, string fuzzyMin, string fuzzyMax)
        {
            try
            {
                var segmentMatchPercent = Parse(row.SegmentPair.Properties.TranslationOrigin.MatchPercent.ToString());

                var fuzzyRange = new SegmentRange
                {
                    Min = Parse(fuzzyMin),
                    Max = Parse(fuzzyMax)
                };
                if (Enumerable.Range(fuzzyRange.Min, fuzzyRange.Max - fuzzyRange.Min + 1).Contains(segmentMatchPercent))
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                // ignored
            }

            return(false);
        }
Exemplo n.º 2
0
        public static bool IsSegmentWithSourceAndTargetTrackedChanges(this DisplayFilterRowInfo rowInfo, DisplayFilterSettings settings)
        {
            if (!rowInfo.IsSegment)
            {
                return(false);
            }

            var sourceContainsTrackChanges = SegmentContainsTrackedChanges(rowInfo.SegmentPair.Source);
            var targetContainsTrackChanges = SegmentContainsTrackedChanges(rowInfo.SegmentPair.Target);

            var hasSourceAndTargetOptionSelected = HasReviewTypeSelected(DisplayFilterSettings.SegmentReviewType.WithSourceAndTargetTrackedChanges.ToString(), settings.SegmentReviewTypes);

            var success = hasSourceAndTargetOptionSelected || AreBothSourceAndTargetTrackedSelected(settings);

            var containsTrackChanges = sourceContainsTrackChanges && targetContainsTrackChanges;

            if (success && !containsTrackChanges)
            {
                success = false;
            }

            return(success);
        }
Exemplo n.º 3
0
        public static bool IsPreviousOriginTypeFound(this DisplayFilterRowInfo rowInfo, DisplayFilterSettings settings)
        {
            if (!rowInfo.IsSegment)
            {
                return(false);
            }

            var success = false;

            if (rowInfo.SegmentPair.Properties.TranslationOrigin.OriginBeforeAdaptation != null)
            {
                var previousTranslationType = rowInfo.SegmentPair.GetPreviousTranslationOriginType();

                if (!IsCompoundOriginType(previousTranslationType) && settings.PreviousOriginTypes.ToList().Any(status
                                                                                                                => string.Compare(status, previousTranslationType.ToString(), StringComparison.OrdinalIgnoreCase) == 0))
                {
                    success = true;
                }

                if (!success)
                {
                    success = rowInfo.IsFuzzyMatchRepairPreviousOriginTypeFound(settings);
                }

                if (!success)
                {
                    success = rowInfo.IsPreviousEditedFuzzyMatchFound(settings);
                }

                if (!success)
                {
                    success = rowInfo.IsPreviousUnEditedFuzzyMatchFound(settings);
                }
            }

            return(success);
        }
Exemplo n.º 4
0
        public static bool IsSegmentContentTypeExcludingNumberOnly(this DisplayFilterRowInfo rowInfo, DisplayFilterSettings settings)
        {
            if (!rowInfo.IsSegment)
            {
                return(false);
            }

            var success = settings.SegmentContentTypes.ToList()
                          .Any(status => string.Compare(status, DisplayFilterSettings.SegmentContentType.ExcludeNumberOnly.ToString()
                                                        , StringComparison.OrdinalIgnoreCase) == 0);

            if (success)
            {
                success = rowInfo.SegmentPair.Source.IsValidFloatingNumber();
                if (success)
                {
                    return(false);
                }

                success = rowInfo.SegmentPair.Target.IsValidFloatingNumber();
            }

            return(!success);
        }
Exemplo n.º 5
0
        public static bool ContainsColor(DisplayFilterRowInfo rowInfo, List <string> colorsCode)
        {
            //get text from segment including tags
            var sourceText = rowInfo.SegmentPair.Source.GetString(true);

            foreach (var code in colorsCode)
            {
                if (sourceText.Contains(string.Format("color=\"{0}\"", code.Substring(1, code.Length - 1))))
                {
                    return(true);
                }
            }

            var targetText = rowInfo.SegmentPair.Target.GetString(true);

            foreach (var code in colorsCode)
            {
                if (targetText.Contains(string.Format("color=\"{0}\"", code.Substring(1, code.Length - 1))))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public bool EvaluateRow(DisplayFilterRowInfo rowInfo)
        {
            var success = Settings.ShowAllContent || rowInfo.IsSegment;

            if (rowInfo.IsSegment)
            {
                if (CustomSettings.QualitySamplingSegmentsIds != null)
                {
                    var segmentPairId = _qualitySamplingService.GetSegmentPairId(rowInfo.SegmentPair);
                    if (!CustomSettings.QualitySamplingSegmentsIds.Contains(segmentPairId))
                    {
                        return(false);
                    }
                }

                if (success)
                {
                    success = _customFilterService.FilterAttributeSuccess(rowInfo, true);
                }

                if (success && (!string.IsNullOrEmpty(Settings.SourceText) || !string.IsNullOrEmpty(Settings.TargetText)))
                {
                    if (!string.IsNullOrEmpty(Settings.SourceText) && !string.IsNullOrEmpty(Settings.TargetText))
                    {
                        if (CustomSettings.SourceTargetLogicalOperator == DisplayFilterSettings.LogicalOperators.OR)
                        {
                            var successSearchOnSource = _contentMatchingService.IsExpressionFound(Settings.SourceText, rowInfo.SegmentPair.Source, out var _);

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

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

                            if (!appliedFilter)
                            {
                                success = _contentMatchingService.FilterOnSourceAndTarget(rowInfo, true);
                            }
                        }
                    }
                    else
                    {
                        success = _contentMatchingService.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 = _customFilterService.Filter(rowInfo, true);
                }
            }

            if (_reverseSearch)
            {
                if (!Settings.ShowAllContent && !rowInfo.IsSegment)
                {
                    return(false);
                }

                return(!success);
            }

            return(success);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public bool EvaluateRow(DisplayFilterRowInfo rowInfo)
        {
            var success = !(!Settings.ShowAllContent && !rowInfo.IsSegment);

            if (rowInfo.IsSegment)
            {
                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())
                {
                    success = rowInfo.IsOriginTypeFound(Settings);
                }


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


                if (success && Settings.RepetitionTypes != null && Settings.RepetitionTypes.Any())
                {
                    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 (success && Settings.TargetText.Trim() != string.Empty)
                {
                    success = rowInfo.IsTextFoundInTarget(Settings);
                }


                if (success && 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);
                }
            }

            return(success);
        }
Exemplo n.º 10
0
        public bool Filter(DisplayFilterRowInfo rowInfo, bool success)
        {
            if (!rowInfo.IsSegment)
            {
                return(!HasCustomSettings());
            }

            var rowId = rowInfo.SegmentPair.Properties.Id.Id;

            if (success && _customSettings.EvenNo)
            {
                success = SegmentNumbersHelper.IsEven(rowId);
            }

            if (success && _customSettings.OddsNo)
            {
                success = SegmentNumbersHelper.IsOdd(rowId);
            }

            if (success && _customSettings.SplitSegments)
            {
                success = SegmentNumbersHelper.IsSplitSegment(rowId, _document);
            }

            if (success && (_customSettings.MergedSegments || _customSettings.MergedAcross))
            {
                success = SegmentNumbersHelper.IsMergedSegment(rowId, _document, _customSettings.MergedAcross);
            }

            if (success && _customSettings.SourceEqualsTarget)
            {
                success = SegmentNumbersHelper.IsSourceEqualsToTarget(rowInfo.SegmentPair, _customSettings.IsEqualsCaseSensitive);
            }

            if (success && _customSettings.Grouped && !string.IsNullOrWhiteSpace(_customSettings.GroupedList))
            {
                success = SegmentNumbersHelper.IdInRange(rowId, _customSettings.GroupedList);
            }

            if (success && _customSettings.UseRegexCommentSearch && !string.IsNullOrWhiteSpace(_customSettings.CommentRegex))
            {
                var visitor = new CommentDataVisitor();

                var commentsList = visitor.GetComments(rowInfo.SegmentPair.Source);
                commentsList.AddRange(visitor.GetComments(rowInfo.SegmentPair.Target));

                success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, _customSettings.CommentRegex);
            }

            if (success && _customSettings.Colors?.Count > 0)
            {
                success = ColorPickerHelper.ContainsColor(rowInfo, _customSettings.Colors, _customSettings.ColorsFoundIn);
            }

            if (success && !string.IsNullOrWhiteSpace(_customSettings.FuzzyMin) && !string.IsNullOrWhiteSpace(_customSettings.FuzzyMax))
            {
                success = FuzzyHelper.IsInFuzzyRange(rowInfo, _customSettings.FuzzyMin, _customSettings.FuzzyMax);
            }

            if (success && _customSettings.ContainsTags)
            {
                var containsTagVisitor = new TagVisitor();
                success = containsTagVisitor.ContainsTag(rowInfo.SegmentPair.Source);
            }

            if (success && _customSettings.CreatedByChecked && !string.IsNullOrWhiteSpace(_customSettings.CreatedBy))
            {
                var userVisitor = new TranslationOriginMetaDataVisitor();
                success = userVisitor.CreatedBy(rowInfo.SegmentPair.Source, _customSettings.CreatedBy);
            }

            if (success && _customSettings.ModifiedByChecked && !string.IsNullOrWhiteSpace(_customSettings.ModifiedBy))
            {
                var userVisitor = new TranslationOriginMetaDataVisitor();
                success = userVisitor.ModifiedBy(rowInfo.SegmentPair.Source, _customSettings.ModifiedBy);
            }

            if (success && !string.IsNullOrEmpty(_customSettings.DocumentStructureInformation))
            {
                success = _settings.IsRegularExpression
                                        ? DocumentStructureInfoRegexSearch(rowInfo, _customSettings.DocumentStructureInformation,
                                                                           _settings.IsCaseSensitive
                                                        ? RegexOptions.None
                                                        : RegexOptions.IgnoreCase)
                                        : DocumentStructureInfoSearch(rowInfo, _customSettings);
            }

            return(success);
        }
Exemplo n.º 11
0
        public bool EvaluateRow(DisplayFilterRowInfo rowInfo)
        {
            var success = !(!Settings.ShowAllContent && !rowInfo.IsSegment);

            if (rowInfo.IsSegment)
            {
                if (ReverseSearch)
                {
                    return(Reverse(success, rowInfo));
                }

                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())
                {
                    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
                var rowId = rowInfo.SegmentPair.Properties.Id.Id;
                if (success && CustomSettings.EvenNo)
                {
                    success = SegmentNumbersHelper.IsEven(rowId);
                }
                if (success && CustomSettings.OddsNo)
                {
                    success = SegmentNumbersHelper.IsOdd(rowId);
                }
                if (success && CustomSettings.SplitSegments)
                {
                    success = SegmentNumbersHelper.IsSplitSegment(rowId, ActiveDocument);
                }
                if (success && (CustomSettings.MergedSegments || CustomSettings.MergedAcross))
                {
                    success = SegmentNumbersHelper.IsMergedSegment(rowId, ActiveDocument, CustomSettings.MergedAcross);
                }

                if (success && CustomSettings.SourceEqualsTarget)
                {
                    success = SegmentNumbersHelper.IsSourceEqualsToTarget(rowInfo.SegmentPair, CustomSettings.IsEqualsCaseSensitive);
                }
                if (success && CustomSettings.Grouped && !string.IsNullOrWhiteSpace(CustomSettings.GroupedList))
                {
                    success = SegmentNumbersHelper.IdInRange(rowId, CustomSettings.GroupedList);
                }
                if (success && CustomSettings.UseRegexCommentSearch &&
                    !string.IsNullOrWhiteSpace(CustomSettings.CommentRegex))
                {
                    //create a list with source and target comments
                    var commentsList = rowInfo.SegmentPair.Source.GetComments();
                    commentsList.AddRange(rowInfo.SegmentPair.Target.GetComments());

                    success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, CustomSettings.CommentRegex);
                }
                if (success && CustomSettings.Colors.Count > 0)
                {
                    try
                    {
                        success = ColorPickerHelper.ContainsColor(rowInfo, CustomSettings.Colors);
                    }catch (Exception e) { }
                }

                //fuzzy
                if (success && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMin) &&
                    !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMax))
                {
                    success = FuzzyHelper.IsInFuzzyRange(rowInfo, CustomSettings.FuzzyMin, CustomSettings.FuzzyMax);
                }
                //unique
                if (success && CustomSettings.Unique)
                {
                    var settings = new DisplayFilterSettings
                    {
                        RepetitionTypes = new List <string>
                        {
                            "FirstOccurrences"
                        }
                    };

                    var isFirst = rowInfo.IsRepetitionsFirstOccurrences(settings);
                    if (isFirst)
                    {
                        return(true);
                    }

                    var isRepeted = rowInfo.SegmentPair.Properties.TranslationOrigin.IsRepeated;

                    if (!isRepeted)
                    {
                        return(true);
                    }

                    return(false);
                }
            }
            return(success);
        }
Exemplo n.º 12
0
        private bool Reverse(bool success, DisplayFilterRowInfo rowInfo)
        {
            success = false;
            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())
            {
                success = rowInfo.IsOriginTypeFound(Settings);
            }


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


            if (!success && Settings.RepetitionTypes != null && Settings.RepetitionTypes.Any())
            {
                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 (!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
            var rowId = rowInfo.SegmentPair.Properties.Id.Id;

            if (!success && CustomSettings.EvenNo)
            {
                success = SegmentNumbersHelper.IsEven(rowId);
            }
            if (!success && CustomSettings.OddsNo)
            {
                success = SegmentNumbersHelper.IsOdd(rowId);
            }
            if (!success && CustomSettings.SplitSegments)
            {
                success = SegmentNumbersHelper.IsSplitSegment(rowId, ActiveDocument);
            }
            if (!success && (CustomSettings.MergedSegments || CustomSettings.MergedAcross))
            {
                success = SegmentNumbersHelper.IsMergedSegment(rowId, ActiveDocument, CustomSettings.MergedAcross);
            }
            if (!success && CustomSettings.SourceEqualsTarget)
            {
                success = SegmentNumbersHelper.IsSourceEqualsToTarget(rowInfo.SegmentPair, CustomSettings.IsEqualsCaseSensitive);
            }
            if (!success && CustomSettings.Grouped && !string.IsNullOrWhiteSpace(CustomSettings.GroupedList))
            {
                success = SegmentNumbersHelper.IdInRange(rowId, CustomSettings.GroupedList);
            }
            if (!success && CustomSettings.UseRegexCommentSearch &&
                !string.IsNullOrWhiteSpace(CustomSettings.CommentRegex))
            {
                //create a list with source and target comments
                var commentsList = rowInfo.SegmentPair.Source.GetComments();
                commentsList.AddRange(rowInfo.SegmentPair.Target.GetComments());

                success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, CustomSettings.CommentRegex);
            }
            if (!success && CustomSettings.Colors.Count > 0)
            {
                try
                {
                    success = ColorPickerHelper.ContainsColor(rowInfo, CustomSettings.Colors);
                }catch (Exception e) { }
            }

            //fuzzy
            if (!success && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMin) &&
                !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMax))
            {
                success = FuzzyHelper.IsInFuzzyRange(rowInfo, CustomSettings.FuzzyMin, CustomSettings.FuzzyMax);
            }
            return(!success);
        }
Exemplo n.º 13
0
        public static bool Filter(CustomFilterSettings customSettings, DisplayFilterRowInfo rowInfo, bool success, Document activeDocument)
        {
            var rowId = rowInfo.SegmentPair.Properties.Id.Id;

            if (success && customSettings.EvenNo)
            {
                success = SegmentNumbersHelper.IsEven(rowId);
            }
            if (success && customSettings.OddsNo)
            {
                success = SegmentNumbersHelper.IsOdd(rowId);
            }
            if (success && customSettings.SplitSegments)
            {
                success = SegmentNumbersHelper.IsSplitSegment(rowId, activeDocument);
            }
            if (success && (customSettings.MergedSegments || customSettings.MergedAcross))
            {
                success = SegmentNumbersHelper.IsMergedSegment(rowId, activeDocument, customSettings.MergedAcross);
            }

            if (success && customSettings.SourceEqualsTarget)
            {
                success = SegmentNumbersHelper.IsSourceEqualsToTarget(rowInfo.SegmentPair, customSettings.IsEqualsCaseSensitive);
            }
            if (success && customSettings.Grouped && !string.IsNullOrWhiteSpace(customSettings.GroupedList))
            {
                success = SegmentNumbersHelper.IdInRange(rowId, customSettings.GroupedList);
            }
            if (success && customSettings.UseRegexCommentSearch &&
                !string.IsNullOrWhiteSpace(customSettings.CommentRegex))
            {
                //create a list with source and target comments
                var commentsList = rowInfo.SegmentPair.Source.GetComments();
                commentsList.AddRange(rowInfo.SegmentPair.Target.GetComments());

                success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, customSettings.CommentRegex);
            }
            if (success && customSettings.Colors.Count > 0)
            {
                try
                {
                    success = ColorPickerHelper.ContainsColor(rowInfo, customSettings.Colors);
                }
                catch (Exception e) { }
            }

            //fuzzy
            if (success && !string.IsNullOrWhiteSpace(customSettings.FuzzyMin) &&
                !string.IsNullOrWhiteSpace(customSettings.FuzzyMax))
            {
                success = FuzzyHelper.IsInFuzzyRange(rowInfo, customSettings.FuzzyMin, customSettings.FuzzyMax);
            }
            if (success && customSettings.ContainsTags)
            {
                var containsTagVisitor = new TagVisitor();
                success = containsTagVisitor.ContainsTag(rowInfo.SegmentPair.Source);
            }
            //unique
            if (success && customSettings.Unique)
            {
                var settings = new DisplayFilterSettings
                {
                    RepetitionTypes = new List <string>
                    {
                        "FirstOccurrences"
                    }
                };

                var isFirst = rowInfo.IsRepetitionsFirstOccurrences(settings);
                if (isFirst)
                {
                    return(true);
                }

                if (rowInfo.SegmentPair.Properties.TranslationOrigin != null)
                {
                    var isRepeated = rowInfo.SegmentPair.Properties.TranslationOrigin.IsRepeated;
                    return(!isRepeated);
                }

                return(false);
            }
            //created by
            if (success && customSettings.CreatedByChecked && !string.IsNullOrWhiteSpace(customSettings.CreatedBy))
            {
                var userVisitor = new UserVisitor();
                success = userVisitor.CreatedBy(rowInfo.SegmentPair.Source, customSettings.CreatedBy);
            }
            //modify by
            if (success && customSettings.ModifiedByChecked && !string.IsNullOrWhiteSpace(customSettings.ModifiedBy))
            {
                var userVisitor = new UserVisitor();
                success = userVisitor.ModifiedBy(rowInfo.SegmentPair.Source, customSettings.ModifiedBy);
            }
            if (success && customSettings.EditedFuzzy)
            {
                success = FuzzyHelper.ContainsFuzzy(rowInfo.SegmentPair.Target) && FuzzyHelper.IsEditedFuzzy(rowInfo.SegmentPair.Target);
            }
            if (success && customSettings.UnEditedFuzzy)
            {
                success = FuzzyHelper.ContainsFuzzy(rowInfo.SegmentPair.Target) && !FuzzyHelper.IsEditedFuzzy(rowInfo.SegmentPair.Target);
            }
            return(success);
        }
Exemplo n.º 14
0
        public static bool Reverse(DisplayFilterSettings settings, bool success, DisplayFilterRowInfo rowInfo, CustomFilterSettings customSettings, Document activeDocument)
        {
            success = false;
            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())
            {
                success = rowInfo.IsOriginTypeFound(settings);
            }


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


            if (!success && settings.RepetitionTypes != null && settings.RepetitionTypes.Any())
            {
                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 (!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
            var rowId = rowInfo.SegmentPair.Properties.Id.Id;

            if (!success && customSettings.EvenNo)
            {
                success = SegmentNumbersHelper.IsEven(rowId);
            }
            if (!success && customSettings.OddsNo)
            {
                success = SegmentNumbersHelper.IsOdd(rowId);
            }
            if (!success && customSettings.SplitSegments)
            {
                success = SegmentNumbersHelper.IsSplitSegment(rowId, activeDocument);
            }
            if (!success && (customSettings.MergedSegments || customSettings.MergedAcross))
            {
                success = SegmentNumbersHelper.IsMergedSegment(rowId, activeDocument, customSettings.MergedAcross);
            }
            if (!success && customSettings.SourceEqualsTarget)
            {
                success = SegmentNumbersHelper.IsSourceEqualsToTarget(rowInfo.SegmentPair, customSettings.IsEqualsCaseSensitive);
            }
            if (!success && customSettings.Grouped && !string.IsNullOrWhiteSpace(customSettings.GroupedList))
            {
                success = SegmentNumbersHelper.IdInRange(rowId, customSettings.GroupedList);
            }
            if (!success && customSettings.UseRegexCommentSearch &&
                !string.IsNullOrWhiteSpace(customSettings.CommentRegex))
            {
                //create a list with source and target comments
                var commentsList = rowInfo.SegmentPair.Source.GetComments();
                commentsList.AddRange(rowInfo.SegmentPair.Target.GetComments());

                success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, customSettings.CommentRegex);
            }
            if (!success && customSettings.Colors.Count > 0)
            {
                try
                {
                    success = ColorPickerHelper.ContainsColor(rowInfo, customSettings.Colors);
                }
                catch (Exception e) { }
            }

            //fuzzy
            if (!success && !string.IsNullOrWhiteSpace(customSettings.FuzzyMin) &&
                !string.IsNullOrWhiteSpace(customSettings.FuzzyMax))
            {
                success = FuzzyHelper.IsInFuzzyRange(rowInfo, customSettings.FuzzyMin, customSettings.FuzzyMax);
            }
            //tags
            if (!success && customSettings.ContainsTags)
            {
                var containsTagVisitor = new TagVisitor();
                success = containsTagVisitor.ContainsTag(rowInfo.SegmentPair.Source);
            }
            if (!success && customSettings.CreatedByChecked && !string.IsNullOrWhiteSpace(customSettings.CreatedBy))
            {
                var userVisitor = new UserVisitor();
                success = userVisitor.CreatedBy(rowInfo.SegmentPair.Source, customSettings.CreatedBy);
            }
            //modify by
            if (!success && customSettings.ModifiedByChecked && !string.IsNullOrWhiteSpace(customSettings.ModifiedBy))
            {
                var userVisitor = new UserVisitor();
                success = userVisitor.ModifiedBy(rowInfo.SegmentPair.Source, customSettings.ModifiedBy);
            }
            if (!success && customSettings.EditedFuzzy)
            {
                if (FuzzyHelper.ContainsFuzzy(rowInfo.SegmentPair.Target))
                {
                    success = FuzzyHelper.IsEditedFuzzy(rowInfo.SegmentPair.Target);
                }
                else
                {
                    return(false);
                }
            }
            if (!success && customSettings.UnEditedFuzzy)
            {
                if (FuzzyHelper.ContainsFuzzy(rowInfo.SegmentPair.Target))
                {
                    success = !FuzzyHelper.IsEditedFuzzy(rowInfo.SegmentPair.Target);
                }
                else
                {
                    return(false);
                }
            }
            return(!success);
        }
Exemplo n.º 15
0
 public static bool IsPreviousUnEditedFuzzyMatchFound(this DisplayFilterRowInfo rowInfo, DisplayFilterSettings settings)
 {
     return(settings.PreviousOriginTypes.Any(a => a == DisplayFilterSettings.OriginTypeExtended.UneditedFuzzy.ToString()) &&
            FuzzyHelper.ContainsFuzzyMatch(rowInfo.SegmentPair.Target?.Properties?.TranslationOrigin?.OriginBeforeAdaptation) &&
            !FuzzyHelper.IsEditedFuzzyMatch(rowInfo.SegmentPair.Target?.Properties?.TranslationOrigin?.OriginBeforeAdaptation));
 }
Exemplo n.º 16
0
        public bool EvaluateRow(DisplayFilterRowInfo rowInfo)
        {
            var success = !(!Settings.ShowAllContent && !rowInfo.IsSegment);

            if (rowInfo.IsSegment)
            {
                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())
                {
                    success = rowInfo.IsOriginTypeFound(Settings);
                }


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


                if (success && Settings.RepetitionTypes != null && Settings.RepetitionTypes.Any())
                {
                    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 is revert search use custom helper method
                if (success && !CustomSettings.RevertSerach)
                {
                    if (success && Settings.SourceText.Trim() != string.Empty)
                    {
                        success = rowInfo.IsTextFoundInSource(Settings);
                    }


                    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
                var rowId = rowInfo.SegmentPair.Properties.Id.Id;
                if (success && CustomSettings.EvenNo)
                {
                    success = SegmentNumbersHelper.IsEven(rowId);
                }
                if (success && CustomSettings.OddsNo)
                {
                    success = SegmentNumbersHelper.IsOdd(rowId);
                }
                if (success && CustomSettings.Grouped && !string.IsNullOrWhiteSpace(CustomSettings.GroupedList))
                {
                    success = SegmentNumbersHelper.IdInRange(rowId, CustomSettings.GroupedList);
                }
                if (success && CustomSettings.UseRegexCommentSearch &&
                    !string.IsNullOrWhiteSpace(CustomSettings.CommentRegex))
                {
                    //create a list with source and target comments
                    var commentsList = rowInfo.SegmentPair.Source.GetComments();
                    commentsList.AddRange(rowInfo.SegmentPair.Target.GetComments());

                    success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, CustomSettings.CommentRegex);
                }
                //revert search
                if (success && CustomSettings.RevertSerach && Settings.SourceText.Trim() != string.Empty)
                {
                    success = ContentHelper.ReverseSearch(rowInfo.SegmentPair.Source.GetString(), Settings.SourceText.Trim());
                }
                if (success && CustomSettings.RevertSerach && Settings.TargetText.Trim() != string.Empty)
                {
                    success = ContentHelper.ReverseSearch(rowInfo.SegmentPair.Target.GetString(), Settings.TargetText.Trim());
                }
                if (success && CustomSettings.Colors.Count > 0)
                {
                    if (CustomSettings.FileType != null)
                    {
                        if (CustomSettings.FileType.Contains("IDML"))
                        {
                            success = ColorPickerHelper.ContainsColorForIdmlFileType(rowInfo, CustomSettings.Colors);
                        }
                        else
                        {
                            success = ColorPickerHelper.ContainsColor(rowInfo, CustomSettings.Colors);
                        }
                    }
                }

                //fuzzy
                if (success && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMin) &&
                    !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMax))
                {
                    success = FuzzyHelper.IsInFuzzyRange(rowInfo, CustomSettings.FuzzyMin, CustomSettings.FuzzyMax);
                }
            }
            return(success);
        }