コード例 #1
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);
            }
        }
コード例 #2
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);
                }
            }
        }
コード例 #3
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);
                    }
                });
            }
        }
コード例 #4
0
        private static void ProcessAuthors(StringBuilder sb, KeyValuePair <string, string> field_pair)
        {
            // Appends this

            /*
             *      "author": [
             *                      {
             *                              "family": ""Zelle"",
             *                              "given": "Rintze M."
             *                      },
             *                      {
             *                              "family": ""Hulster"",
             *                              "given": "Erik",
             *                              "non-dropping-particle":"de"        <--- we dont do this - we double quote the "family" instead
             *                      },
             *                      {
             *                              "family": ""Kloezen"",
             *                              "given": "Wendy"
             *                      },
             *                      {
             *                              "family":""Pronk"",
             *                              "given":"Jack T."
             *                      },
             *                      {
             *                              "family": ""Maris"",
             *                              "given":"Antonius J. A.",            <---- note that initials must be separated with a space...
             *                              "non-dropping-particle":"van"       <--- we dont do this - we double quote the "family" instead
             *                      }
             *              ]
             */

            sb.AppendLine(" \"author\": [");

            string value = field_pair.Value;

            // Replace the {}s
            value = value.Replace("{", "");
            value = value.Replace("}", "");

            string[] authors_split             = NameTools.SplitAuthors_LEGACY(value);
            bool     is_additional_author_item = false;

            foreach (string author_split in authors_split)
            {
                if (is_additional_author_item)
                {
                    sb.Append(",");
                }
                else
                {
                    sb.Append(" ");
                    is_additional_author_item = true;
                }

                sb.Append("  { ");
                NameTools.Name name = NameTools.SplitName(author_split);
                sb.Append(MakeQuotedPair("family", name.last_name));

                // Make sure the initials have a space between them
                string first_names_with_initials_separated = name.first_names;
                if (!String.IsNullOrEmpty(first_names_with_initials_separated))
                {
                    first_names_with_initials_separated = first_names_with_initials_separated.Replace(".", ". ");
                    first_names_with_initials_separated = first_names_with_initials_separated.Trim();
                }

                sb.Append(", " + MakeQuotedPair("given", first_names_with_initials_separated));
                sb.Append("} ");
                sb.AppendLine();
            }

            sb.AppendLine("   ]");
        }