Docear4Word.DocumentController.InsertCitation C# (CSharp) Method

InsertCitation() public method

public InsertCitation ( List entryAndPagePairs ) : void
entryAndPagePairs List
return void
        public void InsertCitation(List<EntryAndPagePair> entryAndPagePairs)
        {
            if (entryAndPagePairs == null || entryAndPagePairs.Count == 0) return;

            var authorProcessorControl = entryAndPagePairs[0].AuthorProcessorControl;
            var isCreatingAuthorPair = false;

            if (authorProcessorControl == AuthorProcessorControl.SplitAuthor)
            {
                isCreatingAuthorPair = true;

                foreach (var entryAndPagePair in entryAndPagePairs)
                {
                    entryAndPagePair.AuthorProcessorControl = AuthorProcessorControl.AuthorOnly;
                }
            }

            var inlineCitation = CreateInlineCitation(entryAndPagePairs);
            InsertCitationCore(inlineCitation);

            if (isCreatingAuthorPair)
            {
                foreach (var entryAndPagePair in entryAndPagePairs)
                {
                    entryAndPagePair.AuthorProcessorControl = AuthorProcessorControl.SuppressAuthor;
                }

                inlineCitation = CreateInlineCitation(entryAndPagePairs);
                InsertCitationCore(inlineCitation);
            }
        }

Usage Example

Example #1
0
        public void DoInsertTestData()
        {
            Debug.Assert(currentDocumentController != null);

            var bibTexDatabase = currentDocumentController.GetDatabase();

            if (bibTexDatabase == null)
            {
                return;
            }

            var entries = new List <Entry>(bibTexDatabase.Entries);

            if (entries.Count < 1)
            {
                return;
            }

            var selectedEntry = new List <EntryAndPagePair>
            {
                new EntryAndPagePair(entries[0]),
            };

            currentDocumentController.InsertCitation(selectedEntry);

            if (entries.Count >= 3)
            {
                var selectedEntries = new List <EntryAndPagePair>
                {
                    new EntryAndPagePair(entries[1], pageNumberOverride: "123"),
                    new EntryAndPagePair(entries[2], pageNumberOverride: "456"),
                };

                currentDocumentController.InsertCitation(selectedEntries);
            }

            var document  = currentDocumentController.Document;
            var selection = document.Application.Selection;

            selection.Collapse(WdCollapseDirection.wdCollapseEnd);
            selection.Paragraphs.Add();

            currentDocumentController.InsertBibliography();
            OnWindowSelectionChange();
        }