예제 #1
0
        private static void ExpandAuthors(PDFDocument doc, NodeControl node_control)
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();
            ASSERT.Test(doc != null);

            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Authors);

            if (doc != null)
            {
                string authors = doc.AuthorsCombined;
                if (String.IsNullOrEmpty(authors) || Constants.UNKNOWN_AUTHORS == authors)
                {
                    return;
                }

                WPFDoEvents.InvokeInUIThread(() =>
                {
                    WPFDoEvents.AssertThisCodeIsRunningInTheUIThread();

                    List <NameTools.Name> names = new List <NameTools.Name>();
                    string[] authors_split      = NameTools.SplitAuthors_LEGACY(authors);
                    foreach (string author_split in authors_split)
                    {
                        string first_names, last_name;
                        NameTools.SplitName_LEGACY(author_split, out first_names, out last_name);
                        string initial = String.IsNullOrEmpty(first_names) ? null : first_names.Substring(0, 1);
                        PDFAuthorNodeContent pdf_author = new PDFAuthorNodeContent(doc.LibraryRef.Id, last_name, initial);
                        NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, pdf_author, false);
                    }
                });
            }
        }
예제 #2
0
        private void ExpandAuthors()
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Authors);

            PDFDocument pdf_document = pdf_document_node_content.PDFDocument;

            string authors = pdf_document.AuthorsCombined;

            if (String.IsNullOrEmpty(authors) || 0 == PDFDocument.UNKNOWN_AUTHORS.CompareTo(authors))
            {
                return;
            }

            List <NameTools.Name> names = new List <NameTools.Name>();

            string[] authors_split = NameTools.SplitAuthors_LEGACY(authors);
            foreach (string author_split in authors_split)
            {
                string first_names, last_name;
                NameTools.SplitName_LEGACY(author_split, out first_names, out last_name);
                string initial = String.IsNullOrEmpty(first_names) ? null : first_names.Substring(0, 1);
                PDFAuthorNodeContent pdf_author = new PDFAuthorNodeContent(pdf_document.Library.WebLibraryDetail.Id, last_name, initial);
                NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, pdf_author, false);
            }
        }
예제 #3
0
        private static void ConvertEachBibTexPairIntoWord2007Pair(XmlDocument doc, XmlNode node_source, string fields)
        {
            List <string> field_list = SplitFields(fields);

            foreach (string field in field_list)
            {
                string[] field_split = field.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries);
                if (2 != field_split.Length)
                {
                    Logging.Warn("Unable to process BibTex field '{0}'", field);
                }
                else
                {
                    string key = field_split[0].Trim();
                    string val = field_split[1].Trim();
                    val = val.TrimStart('{').TrimEnd('}');
                    val = BibTexCharacterMap.BibTexToASCII(val);

                    string  field_type_word2007 = TranslateFieldType(key);
                    XmlNode node_record         = doc.CreateElement(NS_TAG, field_type_word2007, NS);

                    // Process authors specifically
                    if (key.Equals("author"))
                    {
                        XmlNode node_name_list = doc.CreateElement(NS_TAG, "NameList", NS);

                        XmlNode node_author = doc.CreateElement(NS_TAG, "Author", NS);
                        node_author.AppendChild(node_name_list);

                        node_record.AppendChild(node_author);

                        string[] authors = NameTools.SplitAuthors_LEGACY(val);
                        foreach (string author in authors)
                        {
                            string first_name;
                            string last_name;
                            NameTools.SplitName_LEGACY(author, out first_name, out last_name);

                            XmlNode node_last = doc.CreateElement(NS_TAG, "Last", NS);
                            node_last.AppendChild(doc.CreateTextNode(last_name));

                            XmlNode node_first = doc.CreateElement(NS_TAG, "First", NS);
                            node_first.AppendChild(doc.CreateTextNode(first_name));

                            XmlNode node_person = doc.CreateElement(NS_TAG, "Person", NS);
                            node_person.AppendChild(node_last);
                            node_person.AppendChild(node_first);

                            node_name_list.AppendChild(node_person);
                        }
                    }
                    else
                    {
                        node_record.AppendChild(doc.CreateTextNode(val));
                    }

                    node_source.AppendChild(node_record);
                }
            }
        }