Exemple #1
0
        //Reference is an indirect quotation
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;

            if (placeholderCitation == null)
            {
                return(false);
            }

            if (placeholderCitation.Entry == null)
            {
                return(false);
            }

            return(placeholderCitation.Entry.QuotationType == QuotationType.IndirectQuotation);
        }
Exemple #2
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }


            PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;

            if (placeholderCitation == null)
            {
                return(false);
            }
            if (!placeholderCitation.NoPar)
            {
                return(false);
            }
            if (!placeholderCitation.PersonOnly)
            {
                return(false);
            }

            //all conditions met
            return(true);
        }
Exemple #3
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(true);
            }
            if (citation.Reference == null)
            {
                return(true);
            }

            PlaceholderCitation thisCitation = citation as PlaceholderCitation;

            if (thisCitation == null)
            {
                return(true);                                  //only PlaceholderCitations can be part of a caption and can have a predecessor-PlaceholderCitation that can be part of a caption
            }
            //caution: the property thisCitation.PreviousPlaceholderCitation may give wrong results and should currently (C6.7) not be used
            PlaceholderCitation previousCitation = thisCitation.PreviousCitation as PlaceholderCitation;

            if (previousCitation == null)
            {
                return(true);                                      //ditto
            }
            if (previousCitation.IsPartOfCaption)
            {
                return(false);
            }

            return(true);
        }
Exemple #4
0
        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            bool doSuppressOnComments           = true;                 //Kommentare
            bool doSuppressOnIndirectQuotations = true;                 //Indirekte Zitate
            bool doSuppressOnSummaries          = true;                 //Zusammenfassungen
            bool doSuppressOnNonQuotations      = false;                //Nachweis ohne Wissenselement (auch Bildzitate)
            bool doSuppressOnDirectQuotations   = false;                //Wörtliche Zitate

            //do not edit
            handled = false;
            if (citation == null)
            {
                return(null);
            }
            if (componentPart == null)
            {
                return(null);
            }
            if (componentPart.Elements == null)
            {
                return(null);
            }
            if (!componentPart.Elements.Any())
            {
                return(null);
            }

            PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;

            if (placeholderCitation == null)
            {
                return(null);
            }
            if (placeholderCitation.Entry == null)
            {
                return(null);
            }

            if
            (
                (doSuppressOnComments && placeholderCitation.Entry.QuotationType == QuotationType.Comment) ||
                (doSuppressOnIndirectQuotations && placeholderCitation.Entry.QuotationType == QuotationType.IndirectQuotation) ||
                (doSuppressOnSummaries && placeholderCitation.Entry.QuotationType == QuotationType.Summary) ||
                (doSuppressOnNonQuotations && placeholderCitation.Entry.QuotationType == QuotationType.None) ||
                (doSuppressOnDirectQuotations && placeholderCitation.Entry.QuotationType == QuotationType.DirectQuotation)
            )
            {
                handled = true;
                return(null);
            }

            return(null);
        }
Exemple #5
0
        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            bool doSuppressOnPages      = false;                                //Seitennummern
            bool doSuppressOnColumns    = false;                                //Spaltennummern
            bool doSuppressOnParagraphs = false;                                //Paragraphen
            bool doSuppressOnMargins    = true;                                 //Randnummern
            bool doSuppressOnOthers     = false;                                //Andere

            //do not edit
            handled = false;
            if (citation == null)
            {
                return(null);
            }
            if (componentPart == null)
            {
                return(null);
            }
            if (componentPart.Elements == null)
            {
                return(null);
            }
            if (!componentPart.Elements.Any())
            {
                return(null);
            }

            PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;

            if (placeholderCitation == null)
            {
                return(null);
            }
            if (placeholderCitation.Entry == null)
            {
                return(null);
            }

            if
            (
                (doSuppressOnPages && placeholderCitation.Entry.PageRange.NumberingType == NumberingType.Page) ||
                (doSuppressOnColumns && placeholderCitation.Entry.PageRange.NumberingType == NumberingType.Column) ||
                (doSuppressOnParagraphs && placeholderCitation.Entry.PageRange.NumberingType == NumberingType.Paragraph) ||
                (doSuppressOnMargins && placeholderCitation.Entry.PageRange.NumberingType == NumberingType.Margin) ||
                (doSuppressOnOthers && placeholderCitation.Entry.PageRange.NumberingType == NumberingType.Other)
            )
            {
                handled = true;
                return(null);
            }

            return(null);
        }
Exemple #6
0
        public IEnumerable<ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            handled = true;

            if (citation == null) return null;
            if (citation.Reference == null) return null;

            if (componentPart == null || componentPart.Elements == null || !componentPart.Elements.Any()) return null;
            if (componentPart.Elements.Count != 1) return null;

            CitationKeyFieldElement citationKeyFieldElement = componentPart.Elements.ElementAt(0) as CitationKeyFieldElement;
            if (citationKeyFieldElement == null) return null;

            PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;
            if (placeholderCitation != null)
            {
                if (placeholderCitation.CorrespondingBibliographyCitation == null) return null;
                if (placeholderCitation.IsAmbiguityTest) return null;

                if (placeholderCitation.AmbiguityFound && !placeholderCitation.AmbiguityResolved)
                {
                    handled = false; //this will display the citation key
                    return null;
                }
            }

            if (citation.CitationManager == null) return null;

            BibliographyCitation bibliographyCitation = citation as BibliographyCitation;
            if (bibliographyCitation != null)
            {
                if (bibliographyCitation.AmbiguityFound && !bibliographyCitation.AmbiguityResolved)
                {
                    handled = false; //this will display the citation key
                    return null;
                }
            }

            return null;
        }
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            PlaceholderCitation currentPlaceholderCitation = citation as PlaceholderCitation;

            if (currentPlaceholderCitation == null)
            {
                return(false);
            }

            PlaceholderCitation previousPlaceholderCitation = currentPlaceholderCitation.PreviousPlaceholderCitation;

            while (previousPlaceholderCitation != null)
            {
                if (previousPlaceholderCitation.PageInPublication != currentPlaceholderCitation.PageInPublication)
                {
                    return(false);
                }
                if (previousPlaceholderCitation.Reference != null && previousPlaceholderCitation.Reference.Equals(currentPlaceholderCitation.Reference))
                {
                    return(true);
                }

                previousPlaceholderCitation = previousPlaceholderCitation.PreviousPlaceholderCitation;
            }

            //still here, then we had no luck iterating on same page & looking for same reference
            return(false);
        }
        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            handled = true;

            if (citation == null)
            {
                return(null);
            }
            if (citation.Reference == null)
            {
                return(null);
            }

            PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;

            if (placeholderCitation != null)
            {
                if (placeholderCitation.CorrespondingBibliographyCitation == null)
                {
                    return(null);
                }

                if (componentPart == null || componentPart.Elements == null || !componentPart.Elements.Any())
                {
                    return(null);
                }
                if (componentPart.Elements.Count != 1)
                {
                    return(null);
                }

                CitationKeyFieldElement citationKeyFieldElement = componentPart.Elements.ElementAt(0) as CitationKeyFieldElement;
                if (citationKeyFieldElement == null)
                {
                    return(null);
                }
                if (placeholderCitation.IsAmbiguityTest)
                {
                    return(null);
                }

                if (placeholderCitation.AmbiguityFound && !placeholderCitation.AmbiguityResolved)
                {
                    handled = false;                     //this will display the citation key
                }
            }

            if (citation.CitationManager == null)
            {
                return(null);
            }

            BibliographyCitation bibliographyCitation = citation as BibliographyCitation;

            if (bibliographyCitation != null)
            {
                var placeholderCitations = citation.CitationManager.PlaceholderCitations;
                if (placeholderCitations
                    .Where(item => item.Reference == bibliographyCitation.Reference)
                    .Any(item2 => item2.AmbiguityFound == true && item2.AmbiguityResolved == false))
                {
                    handled = false;                     //this will display the citation key
                }
            }


            return(null);
        }
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

//citation must be part of multiple citation
            PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;

            if (placeholderCitation == null)
            {
                return(false);
            }
            if (!placeholderCitation.IsPartOfMultipleCitation)
            {
                return(false);
            }

//citation must not be the first citation in a multiple citation and must have a predecessor
            if (placeholderCitation.IsFirstInMultipleCitation)
            {
                return(false);
            }
            PlaceholderCitation previousPlaceholderCitation = placeholderCitation.PreviousPlaceholderCitation;

            if (previousPlaceholderCitation == null)
            {
                return(false);
            }


            Reference thisReference     = placeholderCitation.Reference;
            Reference previousReference = previousPlaceholderCitation.Reference;

            if (previousReference == null)
            {
                return(false);
            }

//reference must have the same year as its predecessor
            string thisYear     = thisReference.YearResolved;
            string previousYear = previousReference.YearResolved;

            if (!thisYear.Equals(previousYear))
            {
                return(false);
            }

//reference must have the same authors as its predecessor
            IEnumerable <Person> thisAuthors     = thisReference.AuthorsOrEditorsOrOrganizations.ToList();
            IEnumerable <Person> previousAuthors = previousReference.AuthorsOrEditorsOrOrganizations.ToList();

            if (!thisAuthors.SequenceEqual(previousAuthors))
            {
                return(false);
            }

            return(true);
        }
Exemple #10
0
        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            //return handled = true if this macro generates the output (as an IEnumerable<ITextUnit>); the standard output will be suppressed
            //return handled = false if you want Citavi to produce the standard output;

            handled = false;

            if (componentPart == null)
            {
                return(null);
            }
            if (componentPart.Elements == null)
            {
                return(null);
            }

            if (citation == null)
            {
                return(null);
            }
            if (citation.Reference == null)
            {
                return(null);
            }


            PageRangeFieldElement pageRangeFieldElement = componentPart.Elements.OfType <PageRangeFieldElement>().FirstOrDefault();

            if (pageRangeFieldElement == null)
            {
                return(null);
            }


            PageRange pageRangeResolved = PageRange.Empty;

            if (pageRangeFieldElement is QuotationPageRangeFieldElement)
            {
                PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;
                if (placeholderCitation == null)
                {
                    return(null);
                }
                if (placeholderCitation.Entry == null)
                {
                    return(null);
                }
                pageRangeResolved = placeholderCitation.Entry.PageRange;
            }
            else
            {
                pageRangeResolved = citation.Reference.PageRange;
            }

            if (pageRangeResolved == null)
            {
                return(null);
            }
            if (pageRangeResolved == PageRange.Empty)
            {
                return(null);
            }
            if (pageRangeResolved.NumeralSystem != NumeralSystem.Omit)
            {
                return(null);
            }

            LiteralElement prefix = null;
            LiteralElement suffix = null;

            switch (pageRangeResolved.NumberingType)
            {
            case NumberingType.Page:
                prefix = pageRangeFieldElement.PageMultiPrefix;
                suffix = pageRangeFieldElement.PageMultiSuffix;
                break;

            case NumberingType.Column:
                prefix = pageRangeFieldElement.ColumnMultiPrefix;
                suffix = pageRangeFieldElement.ColumnMultiSuffix;
                break;

            case NumberingType.Paragraph:
                prefix = pageRangeFieldElement.ParagraphMultiPrefix;
                suffix = pageRangeFieldElement.ParagraphMultiSuffix;
                break;

            case NumberingType.Margin:
                prefix = pageRangeFieldElement.MarginMultiPrefix;
                suffix = pageRangeFieldElement.MarginMultiSuffix;
                break;

            case NumberingType.Other:
                prefix = pageRangeFieldElement.OtherMultiPrefix;
                suffix = pageRangeFieldElement.OtherMultiSuffix;
                break;
            }

            bool hasPrefix = prefix != null && !string.IsNullOrEmpty(prefix.Text);
            bool hasSuffix = suffix != null && !string.IsNullOrEmpty(suffix.Text);



            TextUnitCollection pageRangeTextUnits = pageRangeFieldElement.GetTextUnits(citation, template);

            if (pageRangeTextUnits == null || !pageRangeTextUnits.Any())
            {
                return(null);
            }



            foreach (ITextUnit unit in pageRangeTextUnits)
            {
                unit.Text = unit.Text.Replace(System.StringUtility.Divis, System.StringUtility.EnDash);
            }

            TextUnitCollection output = new TextUnitCollection();

            if (hasPrefix && pageRangeTextUnits.First().Text != prefix.Text)
            {
                TextUnitCollection prefixTextUnits = prefix.GetTextUnits(citation, template);
                if (prefixTextUnits != null && prefixTextUnits.Any())
                {
                    output.AddRange(prefixTextUnits);
                }
            }

            output.AddRange(pageRangeTextUnits);

            if (hasSuffix && pageRangeTextUnits.Last().Text != suffix.Text)
            {
                TextUnitCollection suffixTextUnits = suffix.GetTextUnits(citation, template);
                if (suffixTextUnits != null && suffixTextUnits.Any())
                {
                    output.AddRange(suffixTextUnits);
                }
            }

            componentPart.Elements.ReplaceItem(pageRangeFieldElement, TextUnitCollectionUtility.TextUnitsToLiteralElements(output, componentPart));
            handled = false;

            //all literal elements should always be output:
            foreach (LiteralElement literalElement in componentPart.Elements.OfType <LiteralElement>())
            {
                literalElement.ApplyCondition = ElementApplyCondition.Always;
            }

            return(null);
        }
Exemple #11
0
        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            handled = false;

            if (citation == null)
            {
                return(null);
            }
            if (componentPart == null)
            {
                return(null);
            }
            if (componentPart.Elements == null)
            {
                return(null);
            }
            if (!componentPart.Elements.Any())
            {
                return(null);
            }

            Reference reference = citation.Reference;

            if (reference == null)
            {
                return(null);
            }

            Reference parentReference = reference.ParentReference;

            string language = string.Empty;

            if (componentPart.Scope == ComponentPartScope.Reference)
            {
                language = reference.Language.ToUpperInvariant();
            }
            else if (componentPart.Scope == ComponentPartScope.ParentReference)
            {
                if (parentReference == null)
                {
                    return(null);
                }
                language = parentReference.Language.ToUpperInvariant();
            }

            if (string.IsNullOrEmpty(language))
            {
                return(null);
            }

            PageRangeFieldElement pageRangeFieldElement = componentPart.Elements.OfType <PageRangeFieldElement>().FirstOrDefault();

            if (pageRangeFieldElement == null)
            {
                return(null);
            }

            PageRange pageRange = null;

            if (pageRangeFieldElement is QuotationPageRangeFieldElement)
            {
                PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;
                if (placeholderCitation == null)
                {
                    return(null);
                }
                if (placeholderCitation.Entry == null)
                {
                    return(null);
                }

                pageRange = placeholderCitation.Entry.PageRange;
            }
            else if (pageRangeFieldElement is PageRangeFieldElement)
            {
                pageRange = citation.Reference.PageRange;
            }
            else
            {
                //what should that be ?
                return(null);
            }

            if (pageRange == null)
            {
                return(null);
            }

            #region German

            if (language.Contains("DE"))
            {
                #region Page

                pageRangeFieldElement.PageOneHasSpecialFormat = true;
                pageRangeFieldElement.PageOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageOnePrefix.Text      = "S.\u00A0";
                pageRangeFieldElement.PageOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageOneSuffix.Text      = "";
                pageRangeFieldElement.PageOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.PageTwoHasSpecialFormat = true;
                pageRangeFieldElement.PageTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageTwoPrefix.Text      = "S.\u00A0";
                pageRangeFieldElement.PageTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageTwoSuffix.Text      = "\u00A0f.";
                pageRangeFieldElement.PageTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.PageMultiNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageMultiPrefix.Text      = "S.\u00A0";
                pageRangeFieldElement.PageMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageMultiSuffix.Text      = "\u00A0ff.";
                pageRangeFieldElement.PageMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Column

                pageRangeFieldElement.ColumnOneHasSpecialFormat = true;
                pageRangeFieldElement.ColumnOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnOnePrefix.Text      = "Sp.\u00A0";
                pageRangeFieldElement.ColumnOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnOneSuffix.Text      = "";
                pageRangeFieldElement.ColumnOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ColumnTwoHasSpecialFormat = true;
                pageRangeFieldElement.ColumnTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnTwoPrefix.Text      = "Sp.\u00A0";
                pageRangeFieldElement.ColumnTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnTwoSuffix.Text      = "\u00A0f.";
                pageRangeFieldElement.ColumnTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ColumnMultiNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnMultiPrefix.Text      = "Sp.\u00A0";
                pageRangeFieldElement.ColumnMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnMultiSuffix.Text      = "\u00A0ff.";
                pageRangeFieldElement.ColumnMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Paragraph

                pageRangeFieldElement.ParagraphOneHasSpecialFormat = true;
                pageRangeFieldElement.ParagraphOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ParagraphOnePrefix.Text      = "§\u00A0";
                pageRangeFieldElement.ParagraphOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphOneSuffix.Text      = "";
                pageRangeFieldElement.ParagraphOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ParagraphTwoHasSpecialFormat = false;
                pageRangeFieldElement.ParagraphTwoNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.ParagraphTwoPrefix.Text      = "§§\u00A0";
                pageRangeFieldElement.ParagraphTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphTwoSuffix.Text      = "";
                pageRangeFieldElement.ParagraphTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ParagraphMultiNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.ParagraphMultiPrefix.Text      = "§§\u00A0";
                pageRangeFieldElement.ParagraphMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphMultiSuffix.Text      = "";
                pageRangeFieldElement.ParagraphMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Margin

                pageRangeFieldElement.MarginOneHasSpecialFormat = true;
                pageRangeFieldElement.MarginOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginOnePrefix.Text      = "Rn.\u00A0";
                pageRangeFieldElement.MarginOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginOneSuffix.Text      = "";
                pageRangeFieldElement.MarginOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.MarginTwoHasSpecialFormat = true;
                pageRangeFieldElement.MarginTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginTwoPrefix.Text      = "Rn.\u00A0";
                pageRangeFieldElement.MarginTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginTwoSuffix.Text      = "\u00A0f.";
                pageRangeFieldElement.MarginTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.MarginTwoNumberingStyle     = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginMultiPrefix.Text      = "Rn.\u00A0";
                pageRangeFieldElement.MarginMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginMultiSuffix.Text      = "\u00A0ff.";
                pageRangeFieldElement.MarginMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Other

                pageRangeFieldElement.OtherOneHasSpecialFormat = false;
                pageRangeFieldElement.OtherOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.OtherOnePrefix.Text      = "";
                pageRangeFieldElement.OtherOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherOneSuffix.Text      = "";
                pageRangeFieldElement.OtherOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.OtherTwoHasSpecialFormat = false;
                pageRangeFieldElement.OtherTwoNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.OtherTwoPrefix.Text      = "";
                pageRangeFieldElement.OtherTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherTwoSuffix.Text      = "";
                pageRangeFieldElement.OtherTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.OtherMultiNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.OtherMultiPrefix.Text      = "";
                pageRangeFieldElement.OtherMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherMultiSuffix.Text      = "";
                pageRangeFieldElement.OtherMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                return(null);
            }

            #endregion

            #region English

            if (language.Contains("EN"))
            {
                #region Page

                pageRangeFieldElement.PageOneHasSpecialFormat = true;
                pageRangeFieldElement.PageOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageOnePrefix.Text      = "p.\u00A0";
                pageRangeFieldElement.PageOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageOneSuffix.Text      = "";
                pageRangeFieldElement.PageOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.PageTwoHasSpecialFormat = true;
                pageRangeFieldElement.PageTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageTwoPrefix.Text      = "pp.\u00A0";
                pageRangeFieldElement.PageTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageTwoSuffix.Text      = "\u00A0f.";
                pageRangeFieldElement.PageTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.PageMultiNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageMultiPrefix.Text      = "pp.\u00A0";
                pageRangeFieldElement.PageMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageMultiSuffix.Text      = "\u00A0ff.";
                pageRangeFieldElement.PageMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Column

                pageRangeFieldElement.ColumnOneHasSpecialFormat = true;
                pageRangeFieldElement.ColumnOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnOnePrefix.Text      = "col.\u00A0";
                pageRangeFieldElement.ColumnOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnOneSuffix.Text      = "";
                pageRangeFieldElement.ColumnOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ColumnTwoHasSpecialFormat = true;
                pageRangeFieldElement.ColumnTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnTwoPrefix.Text      = "col.\u00A0";
                pageRangeFieldElement.ColumnTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnTwoSuffix.Text      = "\u00A0f.";
                pageRangeFieldElement.ColumnTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ColumnMultiNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnMultiPrefix.Text      = "col.\u00A0";
                pageRangeFieldElement.ColumnMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnMultiSuffix.Text      = "\u00A0ff.";
                pageRangeFieldElement.ColumnMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Paragraph

                pageRangeFieldElement.ParagraphOneHasSpecialFormat = true;
                pageRangeFieldElement.ParagraphOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ParagraphOnePrefix.Text      = "§\u00A0";
                pageRangeFieldElement.ParagraphOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphOneSuffix.Text      = "";
                pageRangeFieldElement.ParagraphOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ParagraphTwoHasSpecialFormat = false;
                pageRangeFieldElement.ParagraphTwoNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.ParagraphTwoPrefix.Text      = "§§\u00A0";
                pageRangeFieldElement.ParagraphTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphTwoSuffix.Text      = "";
                pageRangeFieldElement.ParagraphTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ParagraphMultiNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.ParagraphMultiPrefix.Text      = "§§\u00A0";
                pageRangeFieldElement.ParagraphMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphMultiSuffix.Text      = "";
                pageRangeFieldElement.ParagraphMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Margin

                pageRangeFieldElement.MarginOneHasSpecialFormat = true;
                pageRangeFieldElement.MarginOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginOnePrefix.Text      = "no.\u00A0";
                pageRangeFieldElement.MarginOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginOneSuffix.Text      = "";
                pageRangeFieldElement.MarginOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.MarginTwoHasSpecialFormat = true;
                pageRangeFieldElement.MarginTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginTwoPrefix.Text      = "no.\u00A0";
                pageRangeFieldElement.MarginTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginTwoSuffix.Text      = "\u00A0f.";
                pageRangeFieldElement.MarginTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.MarginTwoNumberingStyle     = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginMultiPrefix.Text      = "no.\u00A0";
                pageRangeFieldElement.MarginMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginMultiSuffix.Text      = "\u00A0ff.";
                pageRangeFieldElement.MarginMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Other

                pageRangeFieldElement.OtherOneHasSpecialFormat = false;
                pageRangeFieldElement.OtherOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.OtherOnePrefix.Text      = "";
                pageRangeFieldElement.OtherOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherOneSuffix.Text      = "";
                pageRangeFieldElement.OtherOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.OtherTwoHasSpecialFormat = false;
                pageRangeFieldElement.OtherTwoNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.OtherTwoPrefix.Text      = "";
                pageRangeFieldElement.OtherTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherTwoSuffix.Text      = "";
                pageRangeFieldElement.OtherTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.OtherMultiNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.OtherMultiPrefix.Text      = "";
                pageRangeFieldElement.OtherMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherMultiSuffix.Text      = "";
                pageRangeFieldElement.OtherMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                return(null);
            }

            #endregion

            #region French

            if (language.Contains("FR"))
            {
                #region Page

                pageRangeFieldElement.PageOneHasSpecialFormat = true;
                pageRangeFieldElement.PageOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageOnePrefix.Text      = "p.\u00A0";
                pageRangeFieldElement.PageOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageOneSuffix.Text      = "";
                pageRangeFieldElement.PageOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.PageTwoHasSpecialFormat = true;
                pageRangeFieldElement.PageTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageTwoPrefix.Text      = "p.\u00A0";
                pageRangeFieldElement.PageTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageTwoSuffix.Text      = "\u00A0sq.";
                pageRangeFieldElement.PageTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.PageMultiNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageMultiPrefix.Text      = "p.\u00A0";
                pageRangeFieldElement.PageMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageMultiSuffix.Text      = "\u00A0sqq.";
                pageRangeFieldElement.PageMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Column

                pageRangeFieldElement.ColumnOneHasSpecialFormat = true;
                pageRangeFieldElement.ColumnOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnOnePrefix.Text      = "col.\u00A0";
                pageRangeFieldElement.ColumnOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnOneSuffix.Text      = "";
                pageRangeFieldElement.ColumnOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ColumnTwoHasSpecialFormat = true;
                pageRangeFieldElement.ColumnTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnTwoPrefix.Text      = "col.\u00A0";
                pageRangeFieldElement.ColumnTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnTwoSuffix.Text      = "\u00A0sq.";
                pageRangeFieldElement.ColumnTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ColumnMultiNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnMultiPrefix.Text      = "col.\u00A0";
                pageRangeFieldElement.ColumnMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnMultiSuffix.Text      = "\u00A0sqq.";
                pageRangeFieldElement.ColumnMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Paragraph

                pageRangeFieldElement.ParagraphOneHasSpecialFormat = true;
                pageRangeFieldElement.ParagraphOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ParagraphOnePrefix.Text      = "§\u00A0";
                pageRangeFieldElement.ParagraphOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphOneSuffix.Text      = "";
                pageRangeFieldElement.ParagraphOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ParagraphTwoHasSpecialFormat = false;
                pageRangeFieldElement.ParagraphTwoNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.ParagraphTwoPrefix.Text      = "§§\u00A0";
                pageRangeFieldElement.ParagraphTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphTwoSuffix.Text      = "";
                pageRangeFieldElement.ParagraphTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ParagraphMultiNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.ParagraphMultiPrefix.Text      = "§§\u00A0";
                pageRangeFieldElement.ParagraphMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphMultiSuffix.Text      = "";
                pageRangeFieldElement.ParagraphMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Margin

                pageRangeFieldElement.MarginOneHasSpecialFormat = true;
                pageRangeFieldElement.MarginOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginOnePrefix.Text      = "n°\u00A0";
                pageRangeFieldElement.MarginOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginOneSuffix.Text      = "";
                pageRangeFieldElement.MarginOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.MarginTwoHasSpecialFormat = true;
                pageRangeFieldElement.MarginTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginTwoPrefix.Text      = "n°\u00A0";
                pageRangeFieldElement.MarginTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginTwoSuffix.Text      = "\u00A0sq.";
                pageRangeFieldElement.MarginTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.MarginTwoNumberingStyle     = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginMultiPrefix.Text      = "n°\u00A0";
                pageRangeFieldElement.MarginMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginMultiSuffix.Text      = "\u00A0sqq.";
                pageRangeFieldElement.MarginMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Other

                pageRangeFieldElement.OtherOneHasSpecialFormat = false;
                pageRangeFieldElement.OtherOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.OtherOnePrefix.Text      = "";
                pageRangeFieldElement.OtherOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherOneSuffix.Text      = "";
                pageRangeFieldElement.OtherOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.OtherTwoHasSpecialFormat = false;
                pageRangeFieldElement.OtherTwoNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.OtherTwoPrefix.Text      = "";
                pageRangeFieldElement.OtherTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherTwoSuffix.Text      = "";
                pageRangeFieldElement.OtherTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.OtherMultiNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.OtherMultiPrefix.Text      = "";
                pageRangeFieldElement.OtherMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherMultiSuffix.Text      = "";
                pageRangeFieldElement.OtherMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                return(null);
            }

            #endregion

            #region Italian

            if (language.Contains("IT"))
            {
                #region Page

                pageRangeFieldElement.PageOneHasSpecialFormat = true;
                pageRangeFieldElement.PageOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageOnePrefix.Text      = "p.\u00A0";
                pageRangeFieldElement.PageOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageOneSuffix.Text      = "";
                pageRangeFieldElement.PageOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.PageTwoHasSpecialFormat = true;
                pageRangeFieldElement.PageTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageTwoPrefix.Text      = "p.\u00A0";
                pageRangeFieldElement.PageTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageTwoSuffix.Text      = "\u00A0e\u00A0seg.";
                pageRangeFieldElement.PageTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.PageMultiNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageMultiPrefix.Text      = "p.\u00A0";
                pageRangeFieldElement.PageMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageMultiSuffix.Text      = "\u00A0e\u00A0segg.";
                pageRangeFieldElement.PageMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Column

                pageRangeFieldElement.ColumnOneHasSpecialFormat = true;
                pageRangeFieldElement.ColumnOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnOnePrefix.Text      = "col.\u00A0";
                pageRangeFieldElement.ColumnOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnOneSuffix.Text      = "";
                pageRangeFieldElement.ColumnOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ColumnTwoHasSpecialFormat = true;
                pageRangeFieldElement.ColumnTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnTwoPrefix.Text      = "col.\u00A0";
                pageRangeFieldElement.ColumnTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnTwoSuffix.Text      = "\u00A0e\u00A0seg.";
                pageRangeFieldElement.ColumnTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ColumnMultiNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnMultiPrefix.Text      = "col.\u00A0";
                pageRangeFieldElement.ColumnMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnMultiSuffix.Text      = "\u00A0e\u00A0segg.";
                pageRangeFieldElement.ColumnMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Paragraph

                pageRangeFieldElement.ParagraphOneHasSpecialFormat = true;
                pageRangeFieldElement.ParagraphOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ParagraphOnePrefix.Text      = "§\u00A0";
                pageRangeFieldElement.ParagraphOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphOneSuffix.Text      = "";
                pageRangeFieldElement.ParagraphOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ParagraphTwoHasSpecialFormat = false;
                pageRangeFieldElement.ParagraphTwoNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.ParagraphTwoPrefix.Text      = "§§\u00A0";
                pageRangeFieldElement.ParagraphTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphTwoSuffix.Text      = "";
                pageRangeFieldElement.ParagraphTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ParagraphMultiNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.ParagraphMultiPrefix.Text      = "§§\u00A0";
                pageRangeFieldElement.ParagraphMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphMultiSuffix.Text      = "";
                pageRangeFieldElement.ParagraphMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Margin

                pageRangeFieldElement.MarginOneHasSpecialFormat = true;
                pageRangeFieldElement.MarginOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginOnePrefix.Text      = "n.\u00A0marg.\u00A0";
                pageRangeFieldElement.MarginOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginOneSuffix.Text      = "";
                pageRangeFieldElement.MarginOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.MarginTwoHasSpecialFormat = true;
                pageRangeFieldElement.MarginTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginTwoPrefix.Text      = "n.\u00A0marg.\u00A0";
                pageRangeFieldElement.MarginTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginTwoSuffix.Text      = "\u00A0e\u00A0seg.";
                pageRangeFieldElement.MarginTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.MarginTwoNumberingStyle     = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginMultiPrefix.Text      = "n.\u00A0marg.\u00A0";
                pageRangeFieldElement.MarginMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginMultiSuffix.Text      = "\u00A0e\u00A0segg.";
                pageRangeFieldElement.MarginMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Other

                pageRangeFieldElement.OtherOneHasSpecialFormat = false;
                pageRangeFieldElement.OtherOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.OtherOnePrefix.Text      = "";
                pageRangeFieldElement.OtherOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherOneSuffix.Text      = "";
                pageRangeFieldElement.OtherOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.OtherTwoHasSpecialFormat = false;
                pageRangeFieldElement.OtherTwoNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.OtherTwoPrefix.Text      = "";
                pageRangeFieldElement.OtherTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherTwoSuffix.Text      = "";
                pageRangeFieldElement.OtherTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.OtherMultiNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.OtherMultiPrefix.Text      = "";
                pageRangeFieldElement.OtherMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherMultiSuffix.Text      = "";
                pageRangeFieldElement.OtherMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                return(null);
            }

            #endregion

            #region Spanish

            if (language.Contains("ES"))
            {
                #region Page

                pageRangeFieldElement.PageOneHasSpecialFormat = true;
                pageRangeFieldElement.PageOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageOnePrefix.Text      = "pág.\u00A0";
                pageRangeFieldElement.PageOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageOneSuffix.Text      = "";
                pageRangeFieldElement.PageOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.PageTwoHasSpecialFormat = true;
                pageRangeFieldElement.PageTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageTwoPrefix.Text      = "pág.\u00A0";
                pageRangeFieldElement.PageTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageTwoSuffix.Text      = "\u00A0e\u00A0s.";
                pageRangeFieldElement.PageTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.PageMultiNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageMultiPrefix.Text      = "pág.\u00A0";
                pageRangeFieldElement.PageMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageMultiSuffix.Text      = "\u00A0e\u00A0ss.";
                pageRangeFieldElement.PageMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Column

                pageRangeFieldElement.ColumnOneHasSpecialFormat = true;
                pageRangeFieldElement.ColumnOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnOnePrefix.Text      = "columna\u00A0";
                pageRangeFieldElement.ColumnOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnOneSuffix.Text      = "";
                pageRangeFieldElement.ColumnOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ColumnTwoHasSpecialFormat = true;
                pageRangeFieldElement.ColumnTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnTwoPrefix.Text      = "columna\u00A0";
                pageRangeFieldElement.ColumnTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnTwoSuffix.Text      = "\u00A0e\u00A0s.";
                pageRangeFieldElement.ColumnTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ColumnMultiNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnMultiPrefix.Text      = "columna\u00A0";
                pageRangeFieldElement.ColumnMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnMultiSuffix.Text      = "\u00A0e\u00A0ss.";
                pageRangeFieldElement.ColumnMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Paragraph

                pageRangeFieldElement.ParagraphOneHasSpecialFormat = true;
                pageRangeFieldElement.ParagraphOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ParagraphOnePrefix.Text      = "§\u00A0";
                pageRangeFieldElement.ParagraphOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphOneSuffix.Text      = "";
                pageRangeFieldElement.ParagraphOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ParagraphTwoHasSpecialFormat = false;
                pageRangeFieldElement.ParagraphTwoNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.ParagraphTwoPrefix.Text      = "§§\u00A0";
                pageRangeFieldElement.ParagraphTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphTwoSuffix.Text      = "";
                pageRangeFieldElement.ParagraphTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ParagraphMultiNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.ParagraphMultiPrefix.Text      = "§§\u00A0";
                pageRangeFieldElement.ParagraphMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphMultiSuffix.Text      = "";
                pageRangeFieldElement.ParagraphMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Margin

                pageRangeFieldElement.MarginOneHasSpecialFormat = true;
                pageRangeFieldElement.MarginOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginOnePrefix.Text      = "n.º\u00A0margin.\u00A0";
                pageRangeFieldElement.MarginOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginOneSuffix.Text      = "";
                pageRangeFieldElement.MarginOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.MarginTwoHasSpecialFormat = true;
                pageRangeFieldElement.MarginTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginTwoPrefix.Text      = "n.º\u00A0margin.\u00A0";
                pageRangeFieldElement.MarginTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginTwoSuffix.Text      = "\u00A0e\u00A0s.";
                pageRangeFieldElement.MarginTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.MarginTwoNumberingStyle     = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginMultiPrefix.Text      = "n.º\u00A0margin.\u00A0";
                pageRangeFieldElement.MarginMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginMultiSuffix.Text      = "\u00A0e\u00A0ss.";
                pageRangeFieldElement.MarginMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Other

                pageRangeFieldElement.OtherOneHasSpecialFormat = false;
                pageRangeFieldElement.OtherOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.OtherOnePrefix.Text      = "";
                pageRangeFieldElement.OtherOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherOneSuffix.Text      = "";
                pageRangeFieldElement.OtherOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.OtherTwoHasSpecialFormat = false;
                pageRangeFieldElement.OtherTwoNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.OtherTwoPrefix.Text      = "";
                pageRangeFieldElement.OtherTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherTwoSuffix.Text      = "";
                pageRangeFieldElement.OtherTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.OtherMultiNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.OtherMultiPrefix.Text      = "";
                pageRangeFieldElement.OtherMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherMultiSuffix.Text      = "";
                pageRangeFieldElement.OtherMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                return(null);
            }

            #endregion

            #region Other: Language is NOT EMPTY - treat like English?

            if (!string.IsNullOrWhiteSpace(language))
            {
                ;
            }
            {
                #region Page

                pageRangeFieldElement.PageOneHasSpecialFormat = true;
                pageRangeFieldElement.PageOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageOnePrefix.Text      = "p.\u00A0";
                pageRangeFieldElement.PageOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageOneSuffix.Text      = "";
                pageRangeFieldElement.PageOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.PageTwoHasSpecialFormat = true;
                pageRangeFieldElement.PageTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageTwoPrefix.Text      = "pp.\u00A0";
                pageRangeFieldElement.PageTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageTwoSuffix.Text      = "\u00A0f.";
                pageRangeFieldElement.PageTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.PageMultiNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.PageMultiPrefix.Text      = "pp.\u00A0";
                pageRangeFieldElement.PageMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.PageMultiSuffix.Text      = "\u00A0ff.";
                pageRangeFieldElement.PageMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Column

                pageRangeFieldElement.ColumnOneHasSpecialFormat = true;
                pageRangeFieldElement.ColumnOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnOnePrefix.Text      = "col.\u00A0";
                pageRangeFieldElement.ColumnOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnOneSuffix.Text      = "";
                pageRangeFieldElement.ColumnOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ColumnTwoHasSpecialFormat = true;
                pageRangeFieldElement.ColumnTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnTwoPrefix.Text      = "col.\u00A0";
                pageRangeFieldElement.ColumnTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnTwoSuffix.Text      = "\u00A0f.";
                pageRangeFieldElement.ColumnTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ColumnMultiNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ColumnMultiPrefix.Text      = "col.\u00A0";
                pageRangeFieldElement.ColumnMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ColumnMultiSuffix.Text      = "\u00A0ff.";
                pageRangeFieldElement.ColumnMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Paragraph

                pageRangeFieldElement.ParagraphOneHasSpecialFormat = true;
                pageRangeFieldElement.ParagraphOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.ParagraphOnePrefix.Text      = "§\u00A0";
                pageRangeFieldElement.ParagraphOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphOneSuffix.Text      = "";
                pageRangeFieldElement.ParagraphOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ParagraphTwoHasSpecialFormat = false;
                pageRangeFieldElement.ParagraphTwoNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.ParagraphTwoPrefix.Text      = "§§\u00A0";
                pageRangeFieldElement.ParagraphTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphTwoSuffix.Text      = "";
                pageRangeFieldElement.ParagraphTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.ParagraphMultiNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.ParagraphMultiPrefix.Text      = "§§\u00A0";
                pageRangeFieldElement.ParagraphMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.ParagraphMultiSuffix.Text      = "";
                pageRangeFieldElement.ParagraphMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Margin

                pageRangeFieldElement.MarginOneHasSpecialFormat = true;
                pageRangeFieldElement.MarginOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginOnePrefix.Text      = "no.\u00A0";
                pageRangeFieldElement.MarginOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginOneSuffix.Text      = "";
                pageRangeFieldElement.MarginOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.MarginTwoHasSpecialFormat = true;
                pageRangeFieldElement.MarginTwoNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginTwoPrefix.Text      = "no.\u00A0";
                pageRangeFieldElement.MarginTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginTwoSuffix.Text      = "\u00A0f.";
                pageRangeFieldElement.MarginTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.MarginTwoNumberingStyle     = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.MarginMultiPrefix.Text      = "no.\u00A0";
                pageRangeFieldElement.MarginMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.MarginMultiSuffix.Text      = "\u00A0ff.";
                pageRangeFieldElement.MarginMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                #region Other

                pageRangeFieldElement.OtherOneHasSpecialFormat = false;
                pageRangeFieldElement.OtherOneNumberingStyle   = NumberingStyle.StartPageOnly;
                pageRangeFieldElement.OtherOnePrefix.Text      = "";
                pageRangeFieldElement.OtherOnePrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherOneSuffix.Text      = "";
                pageRangeFieldElement.OtherOneSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.OtherTwoHasSpecialFormat = false;
                pageRangeFieldElement.OtherTwoNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.OtherTwoPrefix.Text      = "";
                pageRangeFieldElement.OtherTwoPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherTwoSuffix.Text      = "";
                pageRangeFieldElement.OtherTwoSuffix.FontStyle = FontStyle.Neutral;

                pageRangeFieldElement.OtherMultiNumberingStyle   = NumberingStyle.FullRange;
                pageRangeFieldElement.OtherMultiPrefix.Text      = "";
                pageRangeFieldElement.OtherMultiPrefix.FontStyle = FontStyle.Neutral;
                pageRangeFieldElement.OtherMultiSuffix.Text      = "";
                pageRangeFieldElement.OtherMultiSuffix.FontStyle = FontStyle.Neutral;

                #endregion

                return(null);
            }

            #endregion

            return(null);
        }
Exemple #12
0
        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            handled = false;
            bool   addAmbiguityResolvingLetter = true;
            string noYearString   = "o.J.";
            string noYearTemplate = "{0}{1}";                   //add a space if you do not want the ambiguity resolving letter to "stick" to the no-year-string: "{0} {1}"

            if (citation == null)
            {
                return(null);
            }

            if (componentPart == null)
            {
                return(null);
            }
            if (componentPart.Elements == null || componentPart.Elements.Count == 0)
            {
                return(null);
            }

            Reference reference = citation.Reference;

            if (reference == null)
            {
                return(null);
            }

            //Reference in Scope of ComponentPart
            Reference referenceInScope = componentPart.Scope == ComponentPartScope.Reference ? citation.Reference : citation.Reference.ParentReference;

            if (referenceInScope == null)
            {
                return(null);
            }

            var yearFieldElement = componentPart.Elements
                                   .OfType <DateTimeFieldElement>()
                                   .Where(item => item.PropertyId == ReferencePropertyId.Year || item.PropertyId == ReferencePropertyId.YearResolved)
                                   .FirstOrDefault() as DateTimeFieldElement;

            if (yearFieldElement == null)
            {
                return(null);
            }


            string yearValue = referenceInScope.GetValue(yearFieldElement.PropertyId) as string;

            if (!string.IsNullOrEmpty(yearValue))
            {
                return(null);
            }


            //for the identifying letter we need a corresponding bibliography citation
            BibliographyCitation correspondingBibliographyCitationInScope = null;
            BibliographyCitation thisBibliographyCitation = citation as BibliographyCitation;

            if (componentPart.Scope == ComponentPartScope.Reference)
            {
                #region ComponentPartScope.Reference

                if (thisBibliographyCitation == null)
                {
                    PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;
                    if (placeholderCitation != null)
                    {
                        correspondingBibliographyCitationInScope = placeholderCitation.CorrespondingBibliographyCitation;
                    }
                }
                else
                {
                    correspondingBibliographyCitationInScope = thisBibliographyCitation;
                }

                #endregion
            }
            else
            {
                #region ComponentPartScope.ParentReference

                if (citation.CitationManager != null)
                {
                    foreach (BibliographyCitation otherBibliographyCitation in citation.CitationManager.BibliographyCitations)
                    {
                        if (otherBibliographyCitation == null)
                        {
                            continue;
                        }
                        if (otherBibliographyCitation == thisBibliographyCitation)
                        {
                            continue;
                        }

                        if (otherBibliographyCitation.Reference == null)
                        {
                            continue;
                        }
                        if (otherBibliographyCitation.Reference == referenceInScope)
                        {
                            correspondingBibliographyCitationInScope = otherBibliographyCitation;
                        }
                    }
                }

                #endregion
            }
            string identifyingLetter = string.Empty;
            if (correspondingBibliographyCitationInScope != null)
            {
                identifyingLetter = correspondingBibliographyCitationInScope.IdentifyingLetter;
            }

            string         outputString         = string.Format(noYearTemplate, noYearString, identifyingLetter);
            LiteralElement outputLiteralElement = new LiteralElement(componentPart, outputString);
            outputLiteralElement.FontStyle = yearFieldElement.FontStyle;
            componentPart.Elements.ReplaceItem(yearFieldElement, outputLiteralElement);

            //all literal elements should always be output:
            foreach (LiteralElement literalElement in componentPart.Elements.OfType <LiteralElement>())
            {
                literalElement.ApplyCondition = ElementApplyCondition.Always;
            }

            return(null);
        }
Exemple #13
0
        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            string suffixForRangeOf3 = " ff.";

            handled = false;

            if (citation == null)
            {
                return(null);
            }
            if (citation.Reference == null)
            {
                return(null);
            }
            if (componentPart == null)
            {
                return(null);
            }
            if (componentPart.Elements == null || componentPart.Elements.Count == 0)
            {
                return(null);
            }

            FieldElement fieldElement;

            PageRangeFieldElement pageRangeFieldElement = componentPart.Elements.OfType <PageRangeFieldElement>().FirstOrDefault();

            if (pageRangeFieldElement == null)
            {
                return(null);
            }

            PageRange pageRange = null;

            if (pageRangeFieldElement is QuotationPageRangeFieldElement)
            {
                PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;
                if (placeholderCitation == null)
                {
                    return(null);
                }
                if (placeholderCitation.Entry == null)
                {
                    return(null);
                }

                pageRange = placeholderCitation.Entry.PageRange;
            }
            else if (pageRangeFieldElement is PageRangeFieldElement)
            {
                pageRange = citation.Reference.PageRange;
            }
            else
            {
                //what should that be ?
                return(null);
            }

            if (pageRange == null)
            {
                return(null);
            }

            if (pageRange.StartPage == null)
            {
                return(null);
            }
            if (!pageRange.StartPage.IsFullyNumeric)
            {
                return(null);
            }

            int startPage = pageRange.StartPage.Number ?? 0;

            if (startPage == 0)
            {
                return(null);
            }

            if (pageRange.EndPage == null)
            {
                return(null);
            }
            if (!pageRange.EndPage.IsFullyNumeric)
            {
                return(null);
            }

            int endPage = pageRange.EndPage.Number ?? 0;

            if (endPage == 0)
            {
                return(null);
            }

            int delta = 0;

            if (endPage > startPage)
            {
                delta = endPage - startPage;
            }
            else
            {
                delta = 0;
            }

            //we only treat the special case delta = 2 (over three pages)
            //delta = 0 (over one page) is handled directly from the elements settings
            //delta = 1 (over two pages) ditto
            //delta > 2 (over 4 or more pages) ditto

            if (delta == 2)
            {
                switch (pageRange.NumberingType)
                {
                case NumberingType.Column:
                {
                    pageRangeFieldElement.ColumnMultiNumberingStyle = NumberingStyle.StartPageOnly;
                    pageRangeFieldElement.ColumnMultiSuffix.Text    = suffixForRangeOf3;
                }
                break;

                case NumberingType.Margin:
                {
                    pageRangeFieldElement.MarginMultiNumberingStyle = NumberingStyle.StartPageOnly;
                    pageRangeFieldElement.MarginMultiSuffix.Text    = suffixForRangeOf3;
                }
                break;

                case NumberingType.Other:
                {
                    pageRangeFieldElement.OtherMultiNumberingStyle = NumberingStyle.StartPageOnly;
                    pageRangeFieldElement.OtherMultiSuffix.Text    = suffixForRangeOf3;
                }
                break;

                case NumberingType.Page:
                default:
                {
                    pageRangeFieldElement.PageMultiNumberingStyle = NumberingStyle.StartPageOnly;
                    pageRangeFieldElement.PageMultiSuffix.Text    = suffixForRangeOf3;
                }
                break;

                case NumberingType.Paragraph:
                {
                    pageRangeFieldElement.ParagraphMultiNumberingStyle = NumberingStyle.StartPageOnly;
                    pageRangeFieldElement.ParagraphMultiSuffix.Text    = suffixForRangeOf3;
                }
                break;
                }
            }
            return(null);            //handled remains false, because Citavi will do the formatting with the changed field element's properties
        }
Exemple #14
0
        //Reference has been cited exactly once before

        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            PlaceholderCitation currentPlaceholderCitation = citation as PlaceholderCitation;

            if (currentPlaceholderCitation == null)
            {
                return(false);
            }

            CitationManager citationManager = citation.CitationManager;

            if (citationManager == null)
            {
                return(false);
            }
            if (citationManager.PlaceholderCitations == null || citationManager.PlaceholderCitations.Count <= 1)
            {
                return(false);                                                                                                             //no 2nd mention possible
            }
            if (currentPlaceholderCitation.IsUniquePlaceholderCitation)
            {
                return(false);                                                                                  //there is just one
            }
            if (!currentPlaceholderCitation.IsRepeatingCitation)
            {
                return(false);                                                                  //it has not been mentioned before, therefore in cannot be the 2nd (or higher) mention
            }
            //still here? we iterate over all footnote citations
            int previousMentions = 0;

            foreach (PlaceholderCitation otherPlaceholderCitation in citationManager.PlaceholderCitations)
            {
                if (otherPlaceholderCitation == null)
                {
                    continue;
                }
                if (otherPlaceholderCitation.Reference == null)
                {
                    continue;
                }
                if (otherPlaceholderCitation.Equals(currentPlaceholderCitation))
                {
                    break;                                                                              //we reached the current footnote citation
                }
                if (otherPlaceholderCitation.Reference.Equals(currentPlaceholderCitation.Reference))
                {
                    previousMentions++;                     //found another previous mention
                }
            }

            return(previousMentions == 1);
        }
        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            handled = false;

            if (citation == null)
            {
                return(null);
            }

            Reference currentReference = citation.Reference;

            if (currentReference == null)
            {
                return(null);
            }

            if (componentPart == null)
            {
                return(null);
            }
            if (componentPart.Elements == null || !componentPart.Elements.Any())
            {
                return(null);
            }

            PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;

            if (placeholderCitation == null)
            {
                return(null);
            }
            if (placeholderCitation.Entry == null)
            {
                return(null);
            }

            PageRangeFieldElement pageRangeFieldElement = componentPart.Elements.OfType <PageRangeFieldElement>().FirstOrDefault();

            if (pageRangeFieldElement == null)
            {
                return(null);
            }


            var outputString = "o. S.";

            if (placeholderCitation.PageRange != null || !string.IsNullOrWhiteSpace(placeholderCitation.PageRange.OriginalString))
            {
                return(null);
            }

            var outputLiteralElement = new LiteralElement(componentPart, outputString);

            outputLiteralElement.FontStyle = pageRangeFieldElement.PageMultiStartFontStyle;
            componentPart.Elements.ReplaceItem(pageRangeFieldElement, outputLiteralElement);


            //all literal elements should always be output:
            foreach (LiteralElement literalElement in componentPart.Elements.OfType <LiteralElement>())
            {
                literalElement.ApplyCondition = ElementApplyCondition.Always;
            }

            return(null);
        }
Exemple #16
0
		public IEnumerable<ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
		{
			handled = false;

			if (citation == null) return null;
			if (citation.Reference == null) return null;
			if (componentPart == null) return null;
			if (componentPart.Elements == null || componentPart.Elements.Count == 0) return null;
			
			bool ambiguityFound = false;
			BibliographyCitation bibliographyCitation = citation as BibliographyCitation;
			if (bibliographyCitation == null)
			{
				PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;
				if (placeholderCitation != null)
				{
					bibliographyCitation = placeholderCitation.CorrespondingBibliographyCitation;
				}
			}
			if (bibliographyCitation != null && 
				bibliographyCitation.AmbiguityFound && 
				!string.IsNullOrEmpty(bibliographyCitation.IdentifyingLetter)
			) ambiguityFound = true;
			
			#region Find field elements of type DateTime

			IEnumerable<DateTimeFieldElement> dateTimeFieldElements = componentPart.Elements.OfType<DateTimeFieldElement>();
			if (dateTimeFieldElements == null || dateTimeFieldElements.Count() != 1) return null;

			DateTimeFieldElement dateTimeFieldElement = dateTimeFieldElements.ElementAt(0);
			if (dateTimeFieldElement == null) return null;
			
			#endregion
			
			#region Determine reference to look at
			
			Reference reference;
			if (componentPart.Scope == ComponentPartScope.ParentReference)
			{
				if (citation.Reference.ParentReference == null) return null;
				reference = citation.Reference.ParentReference as Reference;
			}
			else
			{
				reference = citation.Reference as Reference;
			}
			if (reference == null) return null;			
			
			#endregion Determine reference to look at
			
			#region Determine reference language
			
			Language language;
			if (String.Equals(reference.LanguageCode, CultureInfo.GetCultureInfo("en").TwoLetterISOLanguageName, StringComparison.OrdinalIgnoreCase))
			{
				language = Language.English;
			}
			else if (String.Equals(reference.LanguageCode, CultureInfo.GetCultureInfo("de").TwoLetterISOLanguageName, StringComparison.OrdinalIgnoreCase))
			{
				language = Language.German;
			}
			else
			{
				language = Language.Other;
			}
			
			#endregion Determine reference language

			var propertyId = dateTimeFieldElement.PropertyId;
			var dateTimeStringValue = reference.GetValue(propertyId) as string;
			if (string.IsNullOrEmpty(dateTimeStringValue)) return null;


			//das folgende geht nicht, da DateTimeFieldFormatter leider "internal" ist
			//TextUnitCollection textUnits = DateTimeFieldFormatter.Format(citation, dateTimeFieldElement, dateTimeStringValue);

			List<Segment> segments = GetSegments(dateTimeStringValue);


			List<LiteralElement> literalElements = new List<LiteralElement>();

			TextUnitCollection debug = new TextUnitCollection();
			//int counter = 1;
			foreach (Segment segment in segments)
			{
				switch (segment.type)
				{
					case SegmentType.Text:
						{
							var literalElement = new LiteralElement(componentPart, segment.text);
							literalElement.FontStyle = dateTimeFieldElement.FontStyle;
							literalElements.Add(literalElement);
						}
						break;

					case SegmentType.DateTime:
						{
							string newDateString;
							
							#region YEAR information only
							
							if (!segment.ContainsMonthInformation && !segment.ContainsDayInformation)
							{
								switch (language)
								{
									default:
									case (Language.English):
									{
										newDateString = segment.dateTime.ToString("yyyy", new CultureInfo("en-US")); //or "en-UK"
									}
									break;
									
									case (Language.German):
									{
										newDateString = segment.dateTime.ToString("yyyy", new CultureInfo("de-DE")); // or "de-CH" or "de-AT"
									}
									break;
									
									case (Language.Other):
									{
										newDateString = segment.dateTime.ToString("yyyy", new CultureInfo("en-US"));
									}
									break;	
								}
							}
							
							#endregion
							
							#region YEAR and MONTH
							
							else if (!segment.ContainsDayInformation)
							{
								switch (language)
								{
									default:
									case (Language.English):
									{
										newDateString = segment.dateTime.ToString("MM/yyyy", new CultureInfo("en-US")); //or "en-UK"
									}
									break;
									
									case (Language.German):
									{
										newDateString = segment.dateTime.ToString("MMM yyyy", new CultureInfo("de-DE")); // or "de-CH" or "de-AT"
									}
									break;
									
									case (Language.Other):
									{
										newDateString = segment.dateTime.ToString("MM/yyyy", new CultureInfo("en-US"));
									}
									break;	
								}
							}
							
							#endregion
							
							#region YEAR and MONTH and DAY
							
							else
							{
								switch (language)
								{
									default:
									case (Language.English):
									{
										newDateString = segment.dateTime.ToString("d", new CultureInfo("en-US")); //or "en-UK"
									}
									break;
									
									case (Language.German):
									{
										newDateString = segment.dateTime.ToString("dd. MM yyyy", new CultureInfo("de-DE")); // or "de-CH" or "de-AT"
									}
									break;
									
									case (Language.Other):
									{
										newDateString = segment.dateTime.ToString("MM/dd/yyyy", new CultureInfo("en-US"));
									}
									break;	
								}
							}
							
							#endregion
							
							var literalElement = new LiteralElement(componentPart, newDateString);
							literalElement.FontStyle = dateTimeFieldElement.FontStyle;
							literalElements.Add(literalElement);
						}
						break;

				}
			}

			if (ambiguityFound) 
			{
				var literalElement = new LiteralElement(componentPart, bibliographyCitation.IdentifyingLetter);
				literalElement.FontStyle = dateTimeFieldElement.FontStyle;
				literalElements.Add(literalElement);
			}

			//replace the DateTimeFieldElement by the LiteralElements
			componentPart.Elements.ReplaceItem(dateTimeFieldElement, literalElements);


			//and Citavi handles the rest, therefore we say handled = false && return null
			handled = false;
			return null;
		}
        //Version 2.6	Fix bug that text before and after abbreviation is changed for all organisations in an authoring group
        //Version 2.5	If only the abbreviation of an organisation is to be shown, any text before and/or after is suppressed
        //Version 2.4   If Citavi demands that output is suppressed (e.g. when collapsing multiple citations of same author), this script will terminate
        //Version 2.3	Uses OnBeforeFormatOrganization to switch organization name output ot abbreviation only
        //Version 2.2	Uses PersonFormatter of PersonFieldElement
        //Version 2.1   Confine repetition detection to organizational names only, so that ambiguity of individual persons' names can be handled correctly again by Citavi
        //				Therefore, name of helper method was changed from  GetPreviouslyMentionedPersons to GetPreviouslyMentionedOrganizations
        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            handled = false;

            if (citation == null || citation.Reference == null)
            {
                return(null);
            }
            if (componentPart == null || componentPart.Elements == null || !componentPart.Elements.Any())
            {
                return(null);
            }

            PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;

            if (placeholderCitation == null)
            {
                return(null);
            }
            if (placeholderCitation.YearOnly)
            {
                return(null);
            }

            PersonFieldElement personFieldElement = componentPart.Elements[0] as PersonFieldElement;

            if (personFieldElement == null)
            {
                return(null);
            }
            if (personFieldElement.SuppressOutput)
            {
                return(null);
            }

            IEnumerable <Person> persons = personFieldElement.GetPersonsCited(citation);

            if (persons == null || !persons.Any())
            {
                return(null);
            }

            if (!persons.Any(p => p.IsOrganization))
            {
                return(null);
            }

            IEnumerable <Person> previouslyMentionedOrganizations = GetDistinctPreviouslyMentionedOrganizations(citation);

            if (previouslyMentionedOrganizations == null || !previouslyMentionedOrganizations.Any())
            {
                return(null);
            }

            var textBeforeAbbreviation = personFieldElement.OrganizationTextBeforeAbbreviation.Text;
            var textAfterAbbreviation  = personFieldElement.OrganizationTextAfterAbbreviation.Text;


            BeforeFormatOrganizationEventArgs b;

            personFieldElement.PersonFormatter.BeforeFormatOrganization +=
                (sender, e) =>
            {
                b = (BeforeFormatOrganizationEventArgs)e;
                if (b.Organization == null)
                {
                    return;
                }

                if (previouslyMentionedOrganizations.Contains(b.Organization))
                {
                    b.NameOrder = OrganizationNameOrder.AbbreviationOnly;
                    b.TextBeforeAbbreviation = null;
                    b.TextAfterAbbreviation  = null;
                }
                else
                {
                    b.NameOrder = personFieldElement.OrganizationNameOrder;
                    b.TextBeforeAbbreviation = textBeforeAbbreviation;
                    b.TextAfterAbbreviation  = textAfterAbbreviation;
                }
            };

            return(null);
        }
Exemple #18
0
        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            //if the following is set to true a placeholder citation's output will not show ders./dies. although this would normally be the case
            //as e.g. the second one of the following two: {Meier 2010 #2} and {Meier 2010 #2:17-19 /opt1}
            var deactivateFilterWithOption1Switch = true;                                           //default: true

            //if the following is set to true, the citation collapsing can take place (if the style is set to omit author names)
            //true:     (Mueller 2010, S. 10; 2011, S. 12f.; 2012, S. 17)o
            //false:    (Mueller 2010, S. 10; ders. 2011, S. 12 f; ders. 2012, S. 17)
            var deactivateFilterInsideMultipleCitations         = true;                             //default: true
            var deactivateFilterForFirstInsideMultipleCitations = true;                             //default: true; only applicable when deactivateFilterInsideMultipleCitations = false
            var deactivateFilterForFirstAfterMultipleCitations  = true;                             //default: true
            var deactivateFilterInIbidemIdemSequence            = false;                            //default: false
            var deactivateFilterAcrossFootnotes = false;                                            //default: false
            var deactivateFilterAcrossFootnotesIfSeparatedByMoreThanOneIndexNo = true;              //default: true; only applicable when deactivateFilterAcrossFootnotes = false
            var deactivateFilterAcrossFootnotesIfPreviousCitationNotSolitair   = true;              //default: true; ditto
            var outputInItalics   = true;                                                           //default: true
            var outputInSmallCaps = false;                                                          //default: false
            var outputInBold      = false;                                                          //default: false
            var outputUnderlined  = false;                                                          //default: false

            var missingPersonsInfo = "o.A.";                                                        //can be set to e.g. "o.A."/"ohne Autor"; leave empty otherwise
            var outputMissingPersonsInfoInItalics   = false;                                        //default: false
            var outputMissingPersonsInfoInSmallCaps = false;                                        //default: false
            var outputMissingPersonsInfoInBold      = false;                                        //default: false
            var outputMissingPersonsInfoUnderlined  = false;                                        //default: false

            var showGroupPrefixIfPresent = false;                                                   //default: false
            var showGroupSuffixIfPresent = true;                                                    //default: true

            var comparePersonsAgainstLastPersonField = true;

            handled = false;
            var thisCitationIsPartOfMultipleCitation = false;

            if (citation == null)
            {
                return(null);
            }
            if (citation.Reference == null)
            {
                return(null);
            }
            if (componentPart == null)
            {
                return(null);
            }
            if (componentPart.Elements == null || !componentPart.Elements.Any())
            {
                return(null);
            }

            PersonFieldElement personFieldElement = componentPart.Elements.OfType <PersonFieldElement>().FirstOrDefault();

            if (personFieldElement == null)
            {
                return(null);
            }



            //determine current persons to compare
            IEnumerable <Person> thesePersons = GetPersonsOfPersonFieldElement(citation, personFieldElement);

            if (thesePersons == null || !thesePersons.Any())
            {
                return(null);
            }
            bool usePlural = thesePersons.Count() > 1;

            PlaceholderCitation thisPlaceholderCitation = citation as PlaceholderCitation;


            #region deactivateFilterWithOption1Switch

            //SPECIAL: if this citation has the /opt1 switch set, this filter should be deactivated
            if (deactivateFilterWithOption1Switch && thisPlaceholderCitation != null && thisPlaceholderCitation.FormatOption1)
            {
                return(null);
            }

            #endregion deactivateFilterWithOption1Switch

            //handle missing persons
            #region MissingPersonsOutput

            var text   = string.Empty;
            var output = new TextUnitCollection();
            //SwissAcademic.Drawing.FontStyle fontStyle = outputInItalics ? SwissAcademic.Drawing.FontStyle.Italic : SwissAcademic.Drawing.FontStyle.Neutral;
            SwissAcademic.Drawing.FontStyle fontStyle;

            var personsMissing           = (thesePersons == null || !thesePersons.Any());
            var outputMissingPersonsInfo = personsMissing && !string.IsNullOrEmpty(missingPersonsInfo);

            if (personsMissing && outputMissingPersonsInfo)
            {
                text = missingPersonsInfo;

                fontStyle = SwissAcademic.Drawing.FontStyle.Neutral;
                if (outputMissingPersonsInfoInItalics)
                {
                    fontStyle |= SwissAcademic.Drawing.FontStyle.Italic;
                }
                if (outputMissingPersonsInfoInSmallCaps)
                {
                    fontStyle |= SwissAcademic.Drawing.FontStyle.SmallCaps;
                }
                if (outputMissingPersonsInfoInBold)
                {
                    fontStyle |= SwissAcademic.Drawing.FontStyle.Bold;
                }
                if (outputMissingPersonsInfoUnderlined)
                {
                    fontStyle |= SwissAcademic.Drawing.FontStyle.Underline;
                }

                output.Add(new LiteralTextUnit(text, fontStyle));

                handled = true;
                return(output);
            }
            else if (personsMissing)
            {
                return(null);
            }

            #endregion MissingPersonsOutput

            var previousVisibleCitation = GetPreviousVisibleCitation(citation);
            if (previousVisibleCitation == null)
            {
                return(null);
            }
            if (previousVisibleCitation.Reference == null)
            {
                return(null);
            }

            var secondPreviousVisibleCitation = GetPreviousVisibleCitation(previousVisibleCitation);

            #region MultipleCitation

            if (thisPlaceholderCitation != null)
            {
                var printingEntries = thisPlaceholderCitation.Entry.Placeholder.GetPrintingEntries();
                if (printingEntries == null)
                {
                    return(null);
                }
                if (printingEntries.Count() > 1)
                {
                    thisCitationIsPartOfMultipleCitation = true;
                }

                if (thisCitationIsPartOfMultipleCitation)
                {
                    if (deactivateFilterInsideMultipleCitations)
                    {
                        //We switch off "ders./dies." completely ... or ...
                        return(null);
                    }
                    else
                    {
                        //... at least for the very first printing entry in a multiple citation
                        var index = printingEntries.IndexOf(thisPlaceholderCitation.Entry);
                        if (index == 0 && deactivateFilterForFirstInsideMultipleCitations)
                        {
                            return(null);
                        }
                    }
                }
            }

            #endregion MultipleCitation

            #region deactivateFilterInIbidemIdemSequence

            //avoiding a sequence such as e.g.: [2] Ebd. -> [3] Ders.
            if (deactivateFilterInIbidemIdemSequence)
            {
                if (secondPreviousVisibleCitation != null && secondPreviousVisibleCitation.Reference != null)
                {
                    if (previousVisibleCitation.Reference == secondPreviousVisibleCitation.Reference)
                    {
                        return(null);
                    }
                }
            }

            #endregion deactivateFilterInIbidemIdemSequence

            #region FootnoteCitation

            var thisFootnoteCitation = citation as FootnoteCitation;
            if (thisFootnoteCitation != null && !thisCitationIsPartOfMultipleCitation)
            {
                var previousVisibleFootnoteCitation = previousVisibleCitation as FootnoteCitation;
                if (previousVisibleFootnoteCitation == null)
                {
                    return(null);
                }

                var printingEntries = previousVisibleFootnoteCitation.Entry.Placeholder.GetPrintingEntries();
                if (printingEntries != null && printingEntries.Count() > 1 && deactivateFilterForFirstAfterMultipleCitations)
                {
                    //previousVisibleFootnoteCitation IS part of a multiple citation
                    return(null);
                }

                int thisFootnoteIndex     = thisFootnoteCitation.FootnoteIndex;
                int previousFootnoteIndex = previousVisibleFootnoteCitation.FootnoteIndex;

                var secondPreviousVisibleFootnoteCitation = secondPreviousVisibleCitation as FootnoteCitation;
                int secondPreviousFootnoteIndex           = secondPreviousVisibleFootnoteCitation == null ? 0 : secondPreviousVisibleFootnoteCitation.FootnoteIndex;

                #region deactivateFilterAcrossFootnotes

                //enforce distance rules as given by user settings above
                if
                (
                    (
                        deactivateFilterAcrossFootnotes &&
                        thisFootnoteIndex != previousFootnoteIndex
                    ) ||
                    (
                        !deactivateFilterAcrossFootnotes &&
                        deactivateFilterAcrossFootnotesIfSeparatedByMoreThanOneIndexNo &&
                        thisFootnoteIndex - previousFootnoteIndex > 1
                    ) ||
                    (
                        !deactivateFilterAcrossFootnotes &&
                        deactivateFilterAcrossFootnotesIfPreviousCitationNotSolitair &&
                        thisFootnoteIndex - previousFootnoteIndex == 1 &&
                        secondPreviousFootnoteIndex == previousFootnoteIndex
                    )
                )
                {
                    return(null);
                }

                #endregion deactivateFilterAcrossFootnotes
            }

            #endregion FootnoteCitation

            #region InTextCitation

            var thisInTextCitation = citation as InTextCitation;
            //if this citations predecessor is part of a multiple citation, but THIS is NOT, switch off filter
            if (thisInTextCitation != null && !thisCitationIsPartOfMultipleCitation)
            {
                var previousVisibleInTextCitation = previousVisibleCitation as InTextCitation;
                if (previousVisibleInTextCitation == null)
                {
                    return(null);
                }

                var printingEntries = previousVisibleInTextCitation.Entry.Placeholder.GetPrintingEntries();
                if (printingEntries != null && printingEntries.Count() > 1 && deactivateFilterForFirstAfterMultipleCitations)
                {
                    //previousVisibleInTextCitation IS part of a multiple citation
                    return(null);
                }
            }

            #endregion InTextCitation

            //determine previous persons
            IEnumerable <Person> previousPersons = null;
            if (comparePersonsAgainstLastPersonField)
            {
                previousPersons = GetPersonsOfLastPersonFieldElement(previousVisibleCitation);
            }
            else
            {
                previousPersons = previousVisibleCitation.GetPersonsOfPersonFieldElement(0);
            }
            if (previousPersons == null || !previousPersons.Any())
            {
                return(null);
            }

            var equality = CheckPersonEquality(thesePersons, previousPersons);
            if (equality == PersonEquality.None)
            {
                return(null);
            }

            #region Equality detected - generate output

            //we DO have some equality, so let's check what we need to output instead of the person's name(s)

            switch (equality)
            {
            case PersonEquality.M:
                text = "ders.";
                break;

            case PersonEquality.N:
                text = "dass.";
                break;

            default:                     //all others
                text = "dies.";
                break;
            }



            fontStyle = SwissAcademic.Drawing.FontStyle.Neutral;
            if (outputInItalics)
            {
                fontStyle |= SwissAcademic.Drawing.FontStyle.Italic;
            }
            if (outputInSmallCaps)
            {
                fontStyle |= SwissAcademic.Drawing.FontStyle.SmallCaps;
            }
            if (outputInBold)
            {
                fontStyle |= SwissAcademic.Drawing.FontStyle.Bold;
            }
            if (outputUnderlined)
            {
                fontStyle |= SwissAcademic.Drawing.FontStyle.Underline;
            }

            #region GroupPrefix

            if (showGroupPrefixIfPresent && !string.IsNullOrEmpty(personFieldElement.GroupPrefixPlural.Text) && usePlural)
            {
                output.Add(new LiteralTextUnit(personFieldElement.GroupPrefixPlural.Text, personFieldElement.GroupPrefixPlural.FontStyle));
            }
            else if (showGroupPrefixIfPresent && !string.IsNullOrEmpty(personFieldElement.GroupPrefixSingular.Text) && !usePlural)
            {
                output.Add(new LiteralTextUnit(personFieldElement.GroupPrefixSingular.Text, personFieldElement.GroupPrefixSingular.FontStyle));
            }

            #endregion GroupPrefix

            output.Add(new LiteralTextUnit(text, fontStyle));

            #region GroupSuffix

            if (showGroupSuffixIfPresent && !string.IsNullOrEmpty(personFieldElement.GroupSuffixPlural.Text) && usePlural)
            {
                output.Add(new LiteralTextUnit(personFieldElement.GroupSuffixPlural.Text, personFieldElement.GroupSuffixPlural.FontStyle));
            }
            else if (showGroupSuffixIfPresent && !string.IsNullOrEmpty(personFieldElement.GroupSuffixSingular.Text) && !usePlural)
            {
                output.Add(new LiteralTextUnit(personFieldElement.GroupSuffixSingular.Text, personFieldElement.GroupSuffixSingular.FontStyle));
            }

            #endregion GroupSuffix

            handled = true;
            return(output);

            #endregion Equality detected - generate output
        }
Exemple #19
0
        //Version 3.0: complete overhaul, script considers different output for placehoder citations and bibliography citations
        //Version 2.0: script can be attached to both date/time field element as well as text field element

        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            //enter the culture the date info has been formatted and entered in, e.g. 12/05/2017 would be December, 12th in en-UK and May, 5th in en-US
            CultureInfo targetCulture = CultureInfo.CreateSpecificCulture("en-US");

            //list all possible date formats for this script to check; the scripts tries to parse the date beginning from left to right
            string[] formats = new string[] { "yyyy-MM-dd", "yyyy/MM/dd", "dd/MM/yyyy", "yyyy/dd/MM", "dd.MM.yyyy", "d.M.yyyy", "d.MM.yyyy", "dd.M.yyyy", "dd.MM.yy", "d.M.yy", "d.MM.yy", "dd.M.yy" };

            bool usePeriodAfterAbbreviatedMonthName = true;                     //if true, month names will be: Jan. Feb. Mar. Apr. May (!) Jun. Jul. Aug. Sept. Oct. Nov. Dec.

            ///IMPORTANT: Use the following indexed placeholders {n} and format strings xxxx as in {n:xxxx} for the templates.
            ///You can ommit placeholders and/or place them freely inside the templates below. Yet, it is not recommended to use the same placeholder more than once,
            ///because this script is not optimized for this.
            ///
            ///{0}: letter for ambiguity resolving
            ///{1}: year	of start or single date
            ///{2}: month	of start or single date
            ///{3}: day     of start or single date
            ///{4}: year	of end date
            ///{5}: month	of end date
            ///{6}: day     of end date
            ///use the following formatting for "6 June 2018"
            ///YEAR:	yyyy = 2018, yy = 18
            ///MONTH:	MMMM = June, MMM = Jun, MM = 06, %M = 6
            ///DAY:		dd = 06, %d = 6, %do = 6th

            //SINGLE DATE - output format templates
            string outputFormatSingleDatePlaceholder  = "{1:yyyy}{0}";                                                                                                                                                          //e.g. 2013a
            string outputFormatSingleDateBibliography = "{1:yyyy}{0}, {2:MMMM} {3:%do}";                                                                                                                                        //e.g. 2013a, January 6th

            //DATE RANGE - output format templates
            //same year, same month
            string outputFormatDateRangeSameYearSameMonthPlaceholder  = "{1:yyyy}{0}";                                                                                                                  //e.g. 2013a
            string outputFormatDateRangeSameYearSameMonthBibliography = "{1:yyyy}{0}, {2:MMMM} {3:%do} - {6:%do}";                                                                                      //e.g. 2013a, January 6th - 9th

            //same year, different month
            string outputFormatDateRangeSameYearDifferentMonthPlaceholder  = "{1:yyyy}{0}";                                                                                             //e.g. 2013a
            string outputFormatDateRangeSameYearDifferentMonthBibliography = "{1:yyyy}{0}, {2:MMMM} {3:%do} - {5:MMMM} {6:%do}";                                                        //e.g. 2013a, September 28th - October 3rd

            //different years
            string outputFormatDateRangeDifferentYearsPlaceholder  = "{1:yyyy}/{4:yyyy}{0}";                                                                            //e.g. 2013/2014a
            string outputFormatDateRangeDifferentYearsBibliography = "{1:yyyy}/{4:yyyy}{0}; {1:yyyy}, {2:MMMM} {3:%do} - {4:yyyy}, {5:MMMM} {6:%do}";                   //e.g. 2013/2014a; 2013, December 29th - 2014, January 4th

            handled = false;

            if (citation == null)
            {
                return(null);
            }

            Reference referenceInScope = GetReferenceInScope(componentPart, citation);

            if (referenceInScope == null)
            {
                return(null);
            }

            FieldElement dateFieldElement = GetDateFieldElement(componentPart);

            if (dateFieldElement == null)
            {
                return(null);
            }

            ReferencePropertyId referencePropertyId = dateFieldElement.PropertyId;
            string dateString = referenceInScope.GetValue(referencePropertyId) as string;

            if (string.IsNullOrEmpty(dateString))
            {
                return(null);
            }

            TextUnitCollection output = null;

            PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;
            bool isPlaceholderCitation = placeholderCitation != null;

            PreviewCitation previewCitation = citation as PreviewCitation;
            bool            isPreviewBibliographyCitation = previewCitation != null && citation.CitationType == CitationType.Bibliography;

            BibliographyCitation bibliographyCitation = citation as BibliographyCitation;
            bool isBibliographyCitation = bibliographyCitation != null;

            if (bibliographyCitation == null && placeholderCitation != null)
            {
                bibliographyCitation = placeholderCitation.CorrespondingBibliographyCitation;
            }
            if (bibliographyCitation == null && !isPreviewBibliographyCitation)
            {
                return(null);
            }


            string          identifyingLetter         = bibliographyCitation != null ? bibliographyCitation.IdentifyingLetter : string.Empty;
            LiteralTextUnit identifyingLetterTextUnit = new LiteralTextUnit(identifyingLetter, Drawing.FontStyle.Neutral);
            bool            hasIdentifyingLetter      = !string.IsNullOrEmpty(identifyingLetter);

            #region Tread n.d. + letter for disambiguation ("IdentifyingLetter")

            if (hasIdentifyingLetter && ContainsND(dateString))
            {
                //we make sure the IdentifyingLetter is separated from n.d. by a space char or hyphen: Smith n.d.-a, Smith n.d.-b
                //go to method SeparateIdentifyingLetterFromND below to customize
                output = componentPart.GetTextUnitsUnfiltered(citation, template);
                if (output == null || !output.Any())
                {
                    return(null);
                }

                handled = true;
                return(SeparateIdentifyingLetterFromND(output, identifyingLetter));
            }

            #endregion

            FontStyle fontStyle = dateFieldElement is DateTimeFieldElement ? ((DateTimeFieldElement)dateFieldElement).FontStyle : ((TextFieldElement)dateFieldElement).FontStyle;

            DateTime dateSingle;
            DateTime dateStart;
            DateTime dateEnd;

            string outputText = string.Empty;

            #region Check for Single Date

            if (TryParseSingleDate(dateString, formats, targetCulture, out dateSingle))
            {
                #region BibliographyCitation

                if (isBibliographyCitation || isPreviewBibliographyCitation)
                {
                    outputText = FormatDate(dateSingle, outputFormatSingleDateBibliography, targetCulture, identifyingLetter, usePeriodAfterAbbreviatedMonthName);
                }

                #endregion

                #region PlaceholderCitation

                else if (isPlaceholderCitation)
                {
                    outputText = FormatDate(dateSingle, outputFormatSingleDatePlaceholder, targetCulture, identifyingLetter, usePeriodAfterAbbreviatedMonthName);
                }

                #endregion

                #region Other

                else
                {
                    handled = false;
                    return(null);
                }

                #endregion
            }

            #endregion

            #region Check for Date Range

            else if (TryParseDateRange(dateString, formats, targetCulture, out dateStart, out dateEnd))
            {
                #region BibliographyCitation

                if (isBibliographyCitation || isPreviewBibliographyCitation)
                {
                    #region same year, same month

                    if (dateStart.Year == dateEnd.Year && dateStart.Month == dateEnd.Month && dateStart.Day != dateEnd.Day)
                    {
                        outputText = FormatDateRange(dateStart, dateEnd, outputFormatDateRangeSameYearSameMonthBibliography, targetCulture, identifyingLetter, usePeriodAfterAbbreviatedMonthName);
                    }

                    #endregion

                    #region same year, different months

                    else if (dateStart.Year == dateEnd.Year && dateStart.Month != dateEnd.Month)
                    {
                        outputText = FormatDateRange(dateStart, dateEnd, outputFormatDateRangeSameYearDifferentMonthBibliography, targetCulture, identifyingLetter, usePeriodAfterAbbreviatedMonthName);
                    }

                    #endregion

                    #region different years

                    else
                    {
                        outputText = FormatDateRange(dateStart, dateEnd, outputFormatDateRangeDifferentYearsBibliography, targetCulture, identifyingLetter, usePeriodAfterAbbreviatedMonthName);
                    }

                    #endregion
                }

                #endregion

                #region PlaceholderCitation

                else if (isPlaceholderCitation)
                {
                    #region same year, same month

                    if (dateStart.Year == dateEnd.Year && dateStart.Month == dateEnd.Month && dateStart.Day != dateEnd.Day)
                    {
                        outputText = FormatDateRange(dateStart, dateEnd, outputFormatDateRangeSameYearSameMonthPlaceholder, targetCulture, identifyingLetter, usePeriodAfterAbbreviatedMonthName);
                    }

                    #endregion

                    #region same year, different months

                    else if (dateStart.Year == dateEnd.Year && dateStart.Month != dateEnd.Month)
                    {
                        outputText = FormatDateRange(dateStart, dateEnd, outputFormatDateRangeSameYearDifferentMonthPlaceholder, targetCulture, identifyingLetter, usePeriodAfterAbbreviatedMonthName);
                    }

                    #endregion

                    #region different years

                    else
                    {
                        outputText = FormatDateRange(dateStart, dateEnd, outputFormatDateRangeDifferentYearsPlaceholder, targetCulture, identifyingLetter, usePeriodAfterAbbreviatedMonthName);
                    }

                    #endregion
                }

                #endregion

                #region Other

                else
                {
                    handled = false;
                    return(null);
                }

                #endregion
            }

            #endregion

            #region Do the output

            if (!string.IsNullOrEmpty(outputText))
            {
                var outputTextUnits = new TextUnitCollection();
                outputTextUnits = TextUnitCollectionUtility.TaggedTextToTextUnits(dateFieldElement, outputText, fontStyle);

                if (outputTextUnits.Any())
                {
                    List <ITextUnit> componentPartOutput = new List <ITextUnit>();
                    foreach (IElement element in componentPart.Elements)
                    {
                        if (element == dateFieldElement)
                        {
                            componentPartOutput.AddRange(outputTextUnits);
                        }
                        else
                        {
                            componentPartOutput.AddRange(element.GetTextUnits(citation, template));
                        }
                    }
                    handled = true;
                    return(componentPartOutput);
                }
            }

            #endregion

            handled = false;
            return(null);
        }
        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            handled = false;

            bool   addInPrintNote       = true;                                 //only if set to true you are able to separate the in-print-note and the ambiguity resolving letter by a space, if required.
            bool   addInPrintNoteCustom = false;                                //only applicable if addInPrintNote = true, if set to false, the output well be as specified on the date/time field element in component
            string noYearString         = "o.\u00A0J.";                         //"o.J.", "n.d." - \u00A0 = non-breaking space (geschütztes Leerzeichen)
            string noYearTemplate       = "{0}\u00A0{1}";                       //add a space if you do not want the ambiguity resolving letter to "stick" to the no-year-string:	"{0} {1}" -> o. J. a
            //remove the space if you want the ambiguity resolving letter to "stick" to the no-year-string:		"{0}{1}"  -> o.J.a
            string noYearNoIdentifyingLetterTemplate = "{0}";
            string inPrintTemplate = "{0}\u00A0{1}";                            //add a space if you do not want the ambiguity resolving letter to "stick" to the in-print-note:	"{0} {1}" -> in press a
            //remove the space if you want the ambiguity resolving letter to "stick" to the in-print-note:		"{0}{1}"  -> in pressa
            string inPrintNoIdentifyingLetterTemplate = "{0}";
            string inPrintNoteCustom = "im\u00A0Druck";                         //"im Druck", ", in press"

            if (citation == null)
            {
                return(null);
            }

            if (componentPart == null)
            {
                return(null);
            }
            if (componentPart.Elements == null || componentPart.Elements.Count == 0)
            {
                return(null);
            }

            Reference reference = citation.Reference;

            if (reference == null)
            {
                return(null);
            }

            //Reference in Scope of ComponentPart
            Reference referenceInScope = componentPart.Scope == ComponentPartScope.Reference ? citation.Reference : citation.Reference.ParentReference;

            if (referenceInScope == null)
            {
                return(null);
            }

            var yearFieldElement = componentPart.Elements
                                   .OfType <DateTimeFieldElement>()
                                   .Where(item => item.PropertyId == ReferencePropertyId.Year || item.PropertyId == ReferencePropertyId.YearResolved)
                                   .FirstOrDefault() as DateTimeFieldElement;

            if (yearFieldElement == null)
            {
                return(null);
            }

            string inPrintNoteStandard = yearFieldElement.InPrintReplacement.Text;

            string yearValue = referenceInScope.GetValue(yearFieldElement.PropertyId) as string;

            //for the identifying letter we need a corresponding bibliography citation
            BibliographyCitation correspondingBibliographyCitationInScope = null;
            BibliographyCitation thisBibliographyCitation = citation as BibliographyCitation;

            if (componentPart.Scope == ComponentPartScope.Reference)
            {
                #region ComponentPartScope.Reference

                if (thisBibliographyCitation == null)
                {
                    PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;
                    if (placeholderCitation != null)
                    {
                        correspondingBibliographyCitationInScope = placeholderCitation.CorrespondingBibliographyCitation;
                    }
                }
                else
                {
                    correspondingBibliographyCitationInScope = thisBibliographyCitation;
                }

                #endregion
            }
            else
            {
                #region ComponentPartScope.ParentReference

                if (citation.CitationManager != null)
                {
                    foreach (BibliographyCitation otherBibliographyCitation in citation.CitationManager.BibliographyCitations)
                    {
                        if (otherBibliographyCitation == null)
                        {
                            continue;
                        }
                        if (otherBibliographyCitation == thisBibliographyCitation)
                        {
                            continue;
                        }

                        if (otherBibliographyCitation.Reference == null)
                        {
                            continue;
                        }
                        if (otherBibliographyCitation.Reference == referenceInScope)
                        {
                            correspondingBibliographyCitationInScope = otherBibliographyCitation;
                        }
                    }
                }

                #endregion
            }
            string identifyingLetter = string.Empty;
            if (correspondingBibliographyCitationInScope != null)
            {
                identifyingLetter = correspondingBibliographyCitationInScope.IdentifyingLetter;
            }

            string outputString = string.Empty;


            if (string.IsNullOrEmpty(yearValue))
            {
                //"o.J." or "n.d."
                if (string.IsNullOrEmpty(identifyingLetter))
                {
                    outputString = string.Format(noYearNoIdentifyingLetterTemplate, noYearString);
                }
                else
                {
                    outputString = string.Format(noYearTemplate, noYearString, identifyingLetter);
                }
            }

            else if (addInPrintNote && StringUtility.ContainsInPrintInformation(yearValue))
            {
                if (addInPrintNoteCustom)
                {
                    //"im Druck" or "in print"
                    if (string.IsNullOrEmpty(identifyingLetter))
                    {
                        outputString = string.Format(inPrintNoIdentifyingLetterTemplate, inPrintNoteCustom);
                    }
                    else
                    {
                        outputString = string.Format(inPrintTemplate, inPrintNoteCustom, identifyingLetter);
                    }
                }
                else
                {
                    //"im Druck" or "in print" as specified on the date/time field element in component
                    if (string.IsNullOrEmpty(inPrintNoteStandard))
                    {
                        return(null);
                    }

                    if (string.IsNullOrEmpty(identifyingLetter))
                    {
                        outputString = string.Format(inPrintNoIdentifyingLetterTemplate, inPrintNoteStandard);
                    }
                    else
                    {
                        outputString = string.Format(inPrintTemplate, inPrintNoteStandard, identifyingLetter);
                    }
                }
            }

            else
            {
                //if neither "o.J."/"n.d." nor "im Druck"/"in print" applies
                return(null);
            }

            LiteralElement outputLiteralElement = new LiteralElement(componentPart, outputString);
            outputLiteralElement.FontStyle = yearFieldElement.FontStyle;
            componentPart.Elements.ReplaceItem(yearFieldElement, outputLiteralElement);

            //all literal elements should always be output:
            foreach (LiteralElement literalElement in componentPart.Elements.OfType <LiteralElement>())
            {
                literalElement.ApplyCondition = ElementApplyCondition.Always;
            }

            return(null);
        }
Exemple #21
0
        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            string suffixForRangeOf3or4   = "\u00A0ff.";                        //inkl. geschütztem Leerzeichen (ggf. durch normales Leerzeichen ersetzen)
            bool   rangeToTreatIsExactly3 = true;                               //wenn false, dann soll ein Bereich von 3 ODER 4 Seiten mit " ff." verkürzt werden (sonst nur bei genau 3 Seiten)

            handled = false;

            if (citation == null)
            {
                return(null);
            }
            if (citation.Reference == null)
            {
                return(null);
            }
            if (componentPart == null)
            {
                return(null);
            }
            if (componentPart.Elements == null || componentPart.Elements.Count == 0)
            {
                return(null);
            }

            FieldElement fieldElement;

            PageRangeFieldElement pageRangeFieldElement = componentPart.Elements.OfType <PageRangeFieldElement>().FirstOrDefault();

            if (pageRangeFieldElement == null)
            {
                return(null);
            }

            PageRange pageRange = null;

            if (pageRangeFieldElement is QuotationPageRangeFieldElement)
            {
                PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;
                if (placeholderCitation == null)
                {
                    return(null);
                }
                if (placeholderCitation.Entry == null)
                {
                    return(null);
                }

                pageRange = placeholderCitation.Entry.PageRange;
            }
            else if (pageRangeFieldElement is PageRangeFieldElement)
            {
                pageRange = citation.Reference.PageRange;
            }
            else
            {
                //what should that be ?
                return(null);
            }

            if (pageRange == null)
            {
                return(null);
            }

            if (pageRange.StartPage == null)
            {
                return(null);
            }
            if (!pageRange.StartPage.IsFullyNumeric)
            {
                return(null);
            }

            int startPage = pageRange.StartPage.Number ?? 0;

            if (startPage == 0)
            {
                return(null);
            }

            if (pageRange.EndPage == null)
            {
                return(null);
            }
            if (!pageRange.EndPage.IsFullyNumeric)
            {
                return(null);
            }

            int endPage = pageRange.EndPage.Number ?? 0;

            if (endPage == 0)
            {
                return(null);
            }

            int delta = 0;

            if (endPage > startPage)
            {
                delta = endPage - startPage;
            }
            else
            {
                delta = 0;
            }

            //we only treat the special case delta = 2 (optional 2 or 3) (three pages, optional three or four pages)
            //delta = 0 (over one page) is handled directly from the elements settings
            //delta = 1 (over two pages) ditto
            //delta > 2 or 3 (over 4 or 5 or more pages) ditto

            if ((rangeToTreatIsExactly3 == true && delta == 2) || (rangeToTreatIsExactly3 == false && (delta == 2 || delta == 3)))
            {
                switch (pageRange.NumberingType)
                {
                case NumberingType.Page:
                default:
                {
                    pageRangeFieldElement.PageMultiNumberingStyle = NumberingStyle.StartPageOnly;
                    pageRangeFieldElement.PageMultiSuffix.Text    = suffixForRangeOf3or4;
                }
                break;

                case NumberingType.Column:
                {
                    pageRangeFieldElement.ColumnMultiNumberingStyle = NumberingStyle.StartPageOnly;
                    pageRangeFieldElement.ColumnMultiSuffix.Text    = suffixForRangeOf3or4;
                }
                break;

                case NumberingType.Paragraph:
                {
                    pageRangeFieldElement.ParagraphMultiNumberingStyle = NumberingStyle.StartPageOnly;
                    pageRangeFieldElement.ParagraphMultiSuffix.Text    = suffixForRangeOf3or4;
                }
                break;

                case NumberingType.Margin:
                {
                    pageRangeFieldElement.MarginMultiNumberingStyle = NumberingStyle.StartPageOnly;
                    pageRangeFieldElement.MarginMultiSuffix.Text    = suffixForRangeOf3or4;
                }
                break;

                case NumberingType.Other:
                {
                    pageRangeFieldElement.OtherMultiNumberingStyle = NumberingStyle.StartPageOnly;
                    pageRangeFieldElement.OtherMultiSuffix.Text    = suffixForRangeOf3or4;
                }
                break;
                }
            }

            return(null);            //handled remains false, because Citavi will do the formatting with the changed field element's properties
        }