コード例 #1
0
        /// <summary>
        /// Create XML tags in the indd file,
        /// and mark up the text and style of indd file with special xml tags.
        /// </summary>
        private void MarkupInddFile()
        {
            // Get root element of the document.
            InDesign.XMLElements elements = (InDesign.XMLElements)m_inDesignDoc.XMLElements;
            InDesign.XMLElement  rootElm  = (InDesign.XMLElement)elements.FirstItem();

            // Get all stories in current document.
            InDesign.Stories stories = m_inDesignDoc.Stories;
            int storyCount           = stories.Count;

            InDesign.Story story = null;

            for (int i = 0; i < storyCount; i++)
            {
                if (i == 0)
                {
                    story = (InDesign.Story)stories.FirstItem();
                }
                else
                {
                    story = (InDesign.Story)stories.NextItem(story);
                }

                MarkupInddStory(rootElm, story);
            }
        }
コード例 #2
0
        /// <summary>
        /// Unmark up the special xml tags with the text and style of indd file .
        /// </summary>
        private void UnmarkInddFile()
        {
            InDesign.XMLElement root = (InDesign.XMLElement)m_inDesignDoc.XMLElements.FirstItem();

            InDesign.XMLElements elmts = null;
            InDesign.XMLElement  elm   = null;
            InDesign.XMLTag      tag   = null;

            tag = (InDesign.XMLTag)root.MarkupTag;

            elmts = root.XMLElements;
            for (int i = elmts.Count; i > 0; i--)
            {
                elm = (InDesign.XMLElement)elmts.FirstItem();
                IterateXmlElement(elm);
            }
        }
コード例 #3
0
        /// <summary>
        /// Mark up the paragraph and style of indd file with special xml tags.
        /// </summary>
        private void MarkupInddParagraph(InDesign.XMLElement p_parentElm, InDesign.Paragraph p_paragraph)
        {
            InDesign.XMLElement xmlElement = null;
            InDesign.Font       font       = null;

            // Add a new xml element which will be used to mark up a paragraph.
            InDesign.XMLElements subElements = p_parentElm.XMLElements;
            xmlElement = subElements.Add(INDD_PARAGRAPH_TAG, INDD_XMLCONTENT);

            // Get the paragraph's attributes to be translated.
            // For example
            // FontFamily:  Times New Roman
            // PointSize: 12
            font = (InDesign.Font)p_paragraph.AppliedFont;
            xmlElement.XMLAttributes.Add(FONT_FAMILY_ATTRIBUTE, font.FontFamily);
            xmlElement.XMLAttributes.Add(FONT_STYLE_ATTRIBUTE, p_paragraph.FontStyle);
            xmlElement.XMLAttributes.Add(FONT_SIZE_ATTRIBUTE, p_paragraph.PointSize.ToString());

            // Markup the paragraph with xml element
            // so that it can be exported into xml file.
            p_paragraph.Markup(xmlElement);
        }
コード例 #4
0
        /// <summary>
        /// Mark up the story and style of indd file with special xml tags.
        /// </summary>
        private void MarkupInddStory(InDesign.XMLElement p_parentElm, InDesign.Story p_story)
        {
            ArrayList paraList = new ArrayList();

            InDesign.Paragraph   paragraph   = null;
            InDesign.XMLElement  xmlElement  = null;
            InDesign.XMLElements subElements = null;

            subElements = p_parentElm.XMLElements;
            xmlElement  = subElements.Add(INDD_STORY_TAG, INDD_XMLCONTENT);
            p_story.Markup(xmlElement);

            // Get all paragraphes.
            for (int i = 0; i < p_story.Paragraphs.Count; i++)
            {
                if (i == 0)
                {
                    paragraph = (InDesign.Paragraph)p_story.Paragraphs.FirstItem();
                }
                else
                {
                    paragraph = (InDesign.Paragraph)p_story.Paragraphs.NextItem(paragraph);
                }

                paraList.Add(paragraph);
            }

            // Mark up each paragraph.
            foreach (InDesign.Paragraph eachparagraph in paraList)
            {
                if (eachparagraph.Contents.ToString().Trim().Length > 0)
                {
                    MarkupInddParagraph(xmlElement, eachparagraph);
                }
            }
        }