Exemplo n.º 1
0
        public static void WriteArtItemWithTopicLink(this MamlWriter writer,
                                                     ArtItem artItem, Topic topic, int indentLevel)
        {
            //writer.StartHtmlArtItem(artItem);
            //writer.WriteHtmlTopicLink(topic);
            //writer.EndHtmlArtItem();
            writer.WriteStartElement("notLocalizable"); //notLocalizable
            writer.WriteAttributeString("address", writer.GetNextNobrAddress());

            if (indentLevel > 0)
            {
                writer.WriteIndent(indentLevel);
            }

            // Write the inline-image...
            writer.WriteMediaLinkInline(artItem.Id);
            // Write a white space...
            //writer.WriteStartElement("phrase"); //phrase
            //writer.WriteRaw(NonBlockingSpaceEntityName);
            //writer.WriteEndElement();           //phrase
            // Write the line...
            writer.WriteLink(topic.Id, topic.LinkTitle);

            writer.WriteEndElement();                   //notLocalizable
        }
Exemplo n.º 2
0
        public static void EndArtItem(this MamlWriter writer)
        {
            //writer.WriteEndElement(); // nobr
            //writer.EndMarkup();

            writer.WriteEndElement();                   //notLocalizable
        }
Exemplo n.º 3
0
        public static void WriteHtmlTopicLink(this MamlWriter writer, Topic topic)
        {
            // Don't use the HTML prefix (/html/) because that would break website builds.
            //
            // The topic that uses the HTML based topic links are generated; the topics
            // it points to are generated as well. That means source and target must be
            // in the same folder anywyas.

            var url = String.Format(CultureInfo.InvariantCulture, "{0}.htm", topic.Id);

            writer.WriteStartElement("a", Namespaces.Maml);
            writer.WriteAttributeString("href", url);
            writer.WriteString(topic.LinkTitle);
            writer.WriteEndElement();
        }
        public static void WriteSimpleTypeStrucure(this MamlWriter writer,
                                                   Context context, SimpleTypeStructureNode root)
        {
            if (root == null || root.Children.Count == 0)
            {
                return;
            }

            if (root.Children.Count == 1)
            {
                var node        = root.Children[0];
                var isSingleRow = SimpleTypeStructureNode.GetIsSingleRow(node);
                if (isSingleRow)
                {
                    writer.StartParagraph();
                    writer.WriteSingle(context.TopicManager, node, 0);
                    writer.EndParagraph();

                    return;
                }
            }

            writer.StartTable();

            writer.StartTableHeader();
            writer.StartTableRow();

            writer.WriteRowEntry("Item");

            //writer.WriteRowEntry("Facet Value");
            writer.StartTableRowEntry();
            writer.StartParagraph();
            writer.WriteStartElement("notLocalizable"); //notLocalizable
            writer.WriteAttributeString("address", writer.GetNextNobrAddress());
            writer.WriteString("Facet Value");
            writer.WriteEndElement();                   //notLocalizable
            writer.EndParagraph();
            writer.EndTableRowEntry();

            writer.WriteRowEntry("Description");

            writer.EndTableRow();
            writer.EndTableHeader();

            writer.WriteNodes(context, root.Children, 0);

            writer.EndTable();
        }
Exemplo n.º 5
0
        //private const string XmlTopicType = "3272D745-2FFC-48C4-9E9D-CF2B2B784D5F";

        public static void WriteIndent(this MamlWriter writer, int level)
        {
            if (level <= 0)
            {
                return;
            }

            //writer.StartMarkup();
            writer.WriteStartElement("phrase");
            for (var i = 0; i < level * 6; i++)
            {
                writer.WriteRaw(NonBlockingSpaceEntityName);
            }
            //writer.EndMarkup();
            writer.WriteEndElement();
        }
Exemplo n.º 6
0
        public static void WriteArtItemWithText(this MamlWriter writer,
                                                ArtItem artItem, string text)
        {
            //writer.StartHtmlArtItem(artItem);
            //writer.WriteString(text);
            //writer.EndHtmlArtItem();
            writer.WriteStartElement("notLocalizable"); //notLocalizable
            writer.WriteAttributeString("address", writer.GetNextNobrAddress());

            // Write the inline-image...
            writer.WriteMediaLinkInline(artItem.Id);
            // Write a white space...
            //writer.WriteStartElement("phrase"); //phrase
            //writer.WriteRaw(NonBlockingSpaceEntityName);
            //writer.WriteEndElement();           //phrase
            // Write the line...
            writer.WriteString(text);

            writer.WriteEndElement();                   //notLocalizable
        }
Exemplo n.º 7
0
        public static void StartHtmlArtItem(this MamlWriter writer, ArtItem artItem)
        {
            writer.StartMarkup();

            // Emitting a <nobr> tag breaks the Open XML output. I'm pretty
            // sure that I've added this originally in order to avoid weird
            // breaks between the icon and whatever comes after (usually a
            // link or text). However, after visual inspection, I can't find
            // any cases where this can actually occur.
            //
            // If we need to add this back, we should probably either special
            // case the output type and suppress <nobr> for Open XML or find a
            // MAML way of doing it (which doesn't exist today).
            //
            // writer.WriteStartElement("nobr", String.Empty);

            writer.WriteStartElement("artLink");
            writer.WriteAttributeString("target", artItem.Id);
            writer.WriteEndElement();
            writer.WriteRaw(NonBlockingSpaceEntityName);
        }
Exemplo n.º 8
0
        private static void WriteQualifiedList(this MamlWriter writer,
                                               Context context, MultiMap <string, ListItem> listMap)
        {
            int index = 0;

            IEnumerable <string> keys = listMap.Keys;

            foreach (string key in keys)
            {
                IList <ListItem> qualifiedItems = listMap[key];

                if (qualifiedItems.Count == 1)
                {
                    ListItem item = qualifiedItems[0];
                    // Write a separator...
                    if (index > 0)
                    {
                        writer.WriteStartElement("phrase"); //phrase
                        writer.WriteString(" |");
                        writer.WriteEndElement();           //phrase
                    }

                    writer.WriteArtItemWithTopicLink(item.ArtItem, item.Topic);

                    index++;
                }
                else
                {
                    MultiMap <string, ListItem> listMapNext = new MultiMap <string, ListItem>();

                    for (int i = 0; i < qualifiedItems.Count; i++)
                    {
                        ListItem item = qualifiedItems[i];

                        listMapNext.Add(GetQualifiedListItem(
                                            context, item, item.Topic), item);
                    }

                    IEnumerable <string> keysNext = listMapNext.Keys;
                    foreach (string keyNext in keysNext)
                    {
                        IList <ListItem> qualifiedItemsNext = listMapNext[keyNext];

                        if (qualifiedItemsNext.Count == 1)
                        {
                            ListItem itemNext = qualifiedItemsNext[0];
                            // Write a separator...
                            if (index > 0)
                            {
                                writer.WriteStartElement("phrase"); //phrase
                                writer.WriteString(" |");
                                writer.WriteEndElement();           //phrase
                            }

                            writer.WriteQualifiedListItem(context, itemNext, itemNext.Topic);

                            index++;
                        }
                        else
                        {
                            for (int i = 0; i < qualifiedItemsNext.Count; i++)
                            {
                                ListItem itemNext = qualifiedItemsNext[i];
                                // Write a separator...
                                if (index > 0)
                                {
                                    writer.WriteStartElement("phrase"); //phrase
                                    writer.WriteString(" |");
                                    writer.WriteEndElement();           //phrase
                                }

                                writer.WriteQualifiedListItem(context, itemNext,
                                                              itemNext.Topic, keyNext);

                                index++;
                            }
                        }
                    }

                    //for (int i = 0; i < qualifiedItems.Count; i++)
                    //{
                    //    ListItem item = qualifiedItems[i];
                    //    // Write a separator...
                    //    if (index > 0)
                    //    {
                    //        writer.WriteStartElement("phrase"); //phrase
                    //        writer.WriteString(" |");
                    //        writer.WriteEndElement();           //phrase
                    //    }

                    //    //writer.WriteArtItemWithTopicLink(item.ArtItem, item.Topic);
                    //    writer.WriteQualifiedListItem(context, item, item.Topic);

                    //    index++;
                    //}
                }
            }
        }
Exemplo n.º 9
0
        public static void WriteList(this MamlWriter writer,
                                     Context context, IList <ListItem> listItems)
        {
            int itemCount = listItems.Count;

            if (itemCount > 1)
            {
                writer.WriteStartElement("phrase"); //phrase
                writer.WriteString("|");
                writer.WriteEndElement();           //phrase
            }

            if (itemCount == 1)
            {
                ListItem item = listItems[0];
                writer.WriteArtItemWithTopicLink(item.ArtItem, item.Topic);
            }
            else if (itemCount == 2)
            {
                ListItem item1  = listItems[0];
                ListItem item2  = listItems[1];
                Topic    topic1 = item1.Topic;
                Topic    topic2 = item2.Topic;

                if (String.Equals(topic1.LinkTitle, topic2.LinkTitle,
                                  StringComparison.Ordinal))
                {
                    writer.WriteQualifiedListItem(context, item1, topic1);

                    writer.WriteStartElement("phrase"); //phrase
                    writer.WriteString(" |");
                    writer.WriteEndElement();           //phrase

                    writer.WriteQualifiedListItem(context, item2, topic2);
                }
                else
                {
                    writer.WriteArtItemWithTopicLink(item1.ArtItem, topic1);

                    writer.WriteStartElement("phrase"); //phrase
                    writer.WriteString(" |");
                    writer.WriteEndElement();           //phrase

                    writer.WriteArtItemWithTopicLink(item2.ArtItem, topic2);
                }
            }
            else
            {
                MultiMap <string, ListItem> listMap = new MultiMap <string, ListItem>();

                for (int i = 0; i < itemCount; i++)
                {
                    ListItem item = listItems[i];

                    listMap.Add(item.Topic.LinkTitle, item);
                }

                if (listMap.IsMultiValue)
                {
                    writer.WriteQualifiedList(context, listMap);
                }
                else
                {
                    for (int i = 0; i < itemCount; i++)
                    {
                        ListItem item = listItems[i];
                        // Write a separator...
                        if (i > 0)
                        {
                            writer.WriteStartElement("phrase"); //phrase
                            writer.WriteString(" |");
                            writer.WriteEndElement();           //phrase
                        }

                        writer.WriteArtItemWithTopicLink(item.ArtItem, item.Topic);
                    }
                }
            }
            if (itemCount > 1)
            {
                writer.WriteStartElement("phrase"); //phrase
                writer.WriteString(" |");
                writer.WriteEndElement();           //phrase
            }
        }
Exemplo n.º 10
0
        private static void WriteJumpTableSection(this MamlWriter writer,
                                                  Context context, ICollection <ListItem> listItems,
                                                  string title, string address)
        {
            if (listItems.Count == 0)
            {
                return;
            }

            writer.StartSection(title, address);

            writer.StartTable();

            writer.StartTableHeader();
            writer.StartTableRow();

            //writer.WriteRowEntry(String.Empty);
            writer.StartTableRowEntry();
            writer.StartParagraph();
            writer.WriteToken("iconColumn");
            writer.EndParagraph();
            writer.EndTableRowEntry();

            if (title.EndsWith("s", StringComparison.Ordinal))
            {
                if (title.IndexOf(' ') < 0)  // if it is a single word...
                {
                    writer.WriteRowEntry(title.Remove(title.Length - 1));
                }
                else
                {
                    // Write non-breaking title text...
                    writer.StartTableRowEntry();
                    writer.StartParagraph();
                    writer.WriteStartElement("notLocalizable"); //notLocalizable
                    writer.WriteAttributeString("address", writer.GetNextNobrAddress());
                    writer.WriteString(title.Remove(title.Length - 1));
                    writer.WriteEndElement();                   //notLocalizable
                    writer.EndParagraph();
                    writer.EndTableRowEntry();
                }
            }
            else
            {
                writer.WriteRowEntry("Element");
            }
            writer.WriteRowEntry("Description");

            writer.EndTableRow();
            writer.EndTableHeader();

            foreach (var listItem in listItems)
            {
                writer.StartTableRow();

                writer.StartTableRowEntry();
                writer.StartParagraph();
                writer.WriteArtItemInline(listItem.ArtItem);
                writer.EndParagraph();
                writer.EndTableRowEntry();

                writer.StartTableRowEntry();
                writer.StartParagraph();
                writer.WriteTopicLink(listItem.Topic);
                writer.EndParagraph();
                writer.EndTableRowEntry();

                writer.StartTableRowEntry();
                writer.StartParagraph();
                writer.WriteRaw(listItem.SummaryMarkup);
                writer.EndParagraph();
                writer.EndTableRowEntry();

                writer.EndTableRow();
            }

            writer.EndTable();

            writer.StartParagraph();
            if (context.MoveToTopLink)
            {
                // Create a link to the introduction, it is the top...
                writer.WriteLink("#introduction", "Top");
            }
            writer.EndParagraph();

            writer.EndSection();
        }