Docear4Word.DocumentController.InsertBibliography C# (CSharp) Method

InsertBibliography() public method

public InsertBibliography ( ) : void
return void
        public void InsertBibliography()
        {
            try
            {
                isUpdating = true;

                var selection = document.Application.Selection;
                selection.Collapse(WdCollapseDirection.wdCollapseEnd);
                var range = selection.Range;

                // Gotta clear the cache otherwise might show biblio
                Refresh(false);

                var inserter = new CitationInserter(this);
                inserter.InsertBibliography(range);
            }
            finally
            {
                isUpdating = false;
            }
        }

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