当前位置: 首页>>代码示例>>C#>>正文


C# Documents.DocumentNode类代码示例

本文整理汇总了C#中System.Windows.Documents.DocumentNode的典型用法代码示例。如果您正苦于以下问题:C# DocumentNode类的具体用法?C# DocumentNode怎么用?C# DocumentNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DocumentNode类属于System.Windows.Documents命名空间,在下文中一共展示了DocumentNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteUIContainerChild

        private void WriteUIContainerChild(DocumentNode documentNode)
        {
            _rtfBuilder.Append("{");
 
            DocumentNodeArray dna = _converterState.DocumentNodeArray;
 
            // Write child contents 
            int nStart = documentNode.Index + 1;
            int nEnd = documentNode.Index + documentNode.ChildCount; 

            for (; nStart <= nEnd; nStart++)
            {
                DocumentNode documentNodeChild = dna.EntryAt(nStart); 

                // Ignore non-direct children - they get written out by their parent 
                if (documentNodeChild.Parent == documentNode && documentNodeChild.Type == DocumentNodeType.dnImage) 
                {
                    // Write image control and image hex data to the rtf content 
                    WriteImage(documentNodeChild);
                }
            }
 
            if (documentNode.Type == DocumentNodeType.dnBlockUIContainer)
            { 
                _rtfBuilder.Append("\\par"); 
            }
 
            // Close Section writing
            _rtfBuilder.Append("}");
            _rtfBuilder.Append("\r\n");
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:31,代码来源:XamlToRtfWriter.cs

示例2: ConvertSymbolCharValueToText

        private void ConvertSymbolCharValueToText(DocumentNode dn, int nChar, EncodeType encodeType)
        {
            switch (encodeType)
            {
                case EncodeType.Unicode:
                    if (nChar < 0xFFFF)
                    {
                        char[] unicodeChar = new char[1];

                        unicodeChar[0] = (char)nChar;
                        dn.AppendXamlEncoded(new string(unicodeChar));
                    }
                    break;

                case EncodeType.ShiftJis:
                    if (nChar < 0xFFFF)
                    {
                        // NB: How to interpret this numeric value as Shift-JIS?
                        Encoding ec = Encoding.GetEncoding(932);
                        int nChars = nChar > 256 ? 2 : 1;
                        byte[] ba = new byte[2];
                        if (nChars == 1)
                        {
                            ba[0] = (byte)nChar;
                        }
                        else
                        {
                            ba[0] = (byte)((nChar >> 8) & 0xFF);
                            ba[1] = (byte)(nChar & 0xFF);
                        }
                        dn.AppendXamlEncoded(ec.GetString(ba, 0, nChars));
                    }
                    break;

                default:
                    if (nChar < 256)
                    {
                        // Keep the byte char value as the unicode
                        char singleChar = (char) nChar;
                        dn.AppendXamlEncoded(new string(singleChar, 1));
                    }
                    break;
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:44,代码来源:RtfToXamlReader.cs

示例3: HandleParagraphFromText

        internal void HandleParagraphFromText(FormatState formatState)
        {
            DocumentNodeArray dna = _converterState.DocumentNodeArray;
            DocumentNode dn;

            // Insert the paragraph before any text or inline nodes at the top of the stack.
            int nInsertAt = dna.Count;    // Default insertion location
            for (; nInsertAt > 0; nInsertAt--)
            {
                dn = dna.EntryAt(nInsertAt - 1);
                if (!dn.IsInline
                    || (dn.ClosedParent != null && !dn.ClosedParent.IsInline)
                    || !dn.IsMatched)
                {
                    break;
                }
            }

            dn = new DocumentNode(DocumentNodeType.dnParagraph);
            dn.FormatState = new FormatState(formatState);
            dn.ConstrainFontPropagation(formatState);
            dna.InsertNode(nInsertAt, dn);

            // Now close immediately.
            dna.CloseAt(nInsertAt);
            dna.CoalesceOnlyChildren(_converterState, nInsertAt);
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:27,代码来源:RtfToXamlReader.cs

示例4: ProcessHyperlinkField

        internal DocumentNode ProcessHyperlinkField(string instr)
        {
            DocumentNode dn = new DocumentNode(DocumentNodeType.dnHyperlink);
            dn.FormatState = new FormatState(_converterState.PreviousTopFormatState(0));
            string sUri = null;
            string sTarget = null;
            string sBookmark = null;

            bool bTargetNext = false;
            bool bBookmarkNext = false;

            // iterate, starting past " HYPERLINK"
            int i = 10;
            while (i < instr.Length)
            {
                // Skip spaces
                if (instr[i] == ' ')
                {
                    i++;
                }

                // NavigateUri?
                else if (instr[i] == '"')
                {
                    i++;
                    if (i < instr.Length)
                    {
                        int iStart = i;
                        int iEnd = i;

                        for (; iEnd < instr.Length; iEnd++)
                        {
                            if (instr[iEnd] == '"')
                            {
                                break;
                            }
                        }

                        string param = instr.Substring(iStart, iEnd - iStart);
                        if (bTargetNext)
                        {
                            sTarget = param;
                            bTargetNext = false;
                        }
                        else if (bBookmarkNext)
                        {
                            sBookmark = param;
                            bBookmarkNext = false;
                        }
                        else if (sUri == null)
                            sUri = param;
                        // else eat the string

                        i = iEnd + 1;
                    }
                }

                // Instructions
                else if (instr[i] == '\\')
                {
                    i++;
                    if (i < instr.Length)
                    {
                        switch (instr[i])
                        {
                            case 'l':   // bookmark
                                bBookmarkNext = true; bTargetNext = false;
                                break;
                            case 't':   // target
                                bBookmarkNext = false; bTargetNext = true;
                                break;
                        }
                        i++;
                    }
                }

                // Ignore other characters
                else
                    i++;
            }

            StringBuilder sb = new StringBuilder();
            if (sUri != null)
            {
                sb.Append(sUri);
            }
            if (sBookmark != null)
            {
                sb.Append("#");
                sb.Append(sBookmark);
            }

            // Remove the second backslash(which rtf specified) to keep only single backslash
            for (int uriIndex = 0; uriIndex < sb.Length; uriIndex++)
            {
                if (sb[uriIndex] == '\\' && uriIndex + 1 < sb.Length && sb[uriIndex + 1] == '\\')
                {
                    // Remove the sceond backslash
                    sb.Remove(uriIndex + 1, 1);
                }
//.........这里部分代码省略.........
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:101,代码来源:RtfToXamlReader.cs

示例5: ProcessSymbolFieldInstruction

        private void ProcessSymbolFieldInstruction(DocumentNode dn, string instr, ref int i, ref EncodeType encodeType)
        {
            int iStart = 0;

            switch (instr[i++])
            {
                case 'a':
                    encodeType = EncodeType.Ansi;
                    break;
                case 'u':
                    encodeType = EncodeType.Unicode;
                    break;
                case 'j':
                    encodeType = EncodeType.ShiftJis;
                    break;
                case 'h':
                    // linespacing instruction: ignore
                    break;
                case 's':
                    if (i < instr.Length && instr[i] == ' ')
                        i++;
                    // font size in points, not half-points
                    iStart = i;
                    for (; i < instr.Length && instr[i] != ' '; i++)
                    {
                        continue;
                    }
                    string ptString = instr.Substring(iStart, i - iStart);

                    // Now convert number part
                    bool ret = true;
                    double d = 0f;

                    try
                    {
                        d = System.Convert.ToDouble(ptString, CultureInfo.InvariantCulture);
                    }
                    catch (System.OverflowException)
                    {
                        ret = false;
                    }
                    catch (System.FormatException)
                    {
                        ret = false;
                    }

                    if (ret)
                    {
                        dn.FormatState.FontSize = (long)((d * 2) + 0.5);
                    }
                    break;
                case 'f':
                    // Font Name
                    if (i < instr.Length && instr[i] == ' ')
                    {
                        i++;
                    }
                    if (i < instr.Length && instr[i] == '"')
                    {
                        i++;
                    }
                    iStart = i;
                    for (; i < instr.Length && instr[i] != '"'; i++)
                    {
                        continue;
                    }
                    string name = instr.Substring(iStart, i - iStart);
                    // Move past trailing double-quote
                    i++;
                    if (name != null && name.Length > 0)
                    {
                        dn.FormatState.Font = _converterState.FontTable.DefineEntryByName(name);
                    }
                    break;
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:76,代码来源:RtfToXamlReader.cs

示例6: PreCoalesceListItem

        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------

        #region Private Methods

        // <Summary>
        //      The PreCoalesce process for a ListItem involves seeing if I can migrate the left indent
        //      from contained paragraphs to the ListItem itself.  This results in better bullet placement
        //      in the generated XAML.
        // </Summary>

        private void PreCoalesceListItem(DocumentNode dn)
        {
            int nAt = dn.Index;
            long nMargin = -1;
            int nEndItem = nAt + dn.ChildCount;

            for (int nnAt = nAt + 1; nnAt <= nEndItem; nnAt++)
            {
                DocumentNode ddn = EntryAt(nnAt);

                if (ddn.Type == DocumentNodeType.dnParagraph)
                {
                    if (nMargin == -1)
                    {
                        nMargin = ddn.NearMargin;
                    }
                    else if (ddn.NearMargin < nMargin && ddn.IsNonEmpty)
                    {
                        nMargin = ddn.NearMargin;
                    }
                }
            }
            dn.NearMargin = nMargin;
            for (int nnAt = nAt; nnAt <= nEndItem; nnAt++)
            {
                DocumentNode ddn = EntryAt(nnAt);

                if (ddn.Type == DocumentNodeType.dnParagraph)
                {
                    ddn.NearMargin = ddn.NearMargin - nMargin;
                }
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:47,代码来源:RtfToXamlReader.cs

示例7: PreCoalesceTable

        // <Summary>
        //      Table column handling.  RTF tables allow each row to be arbitrarily aligned.  XAML (like HTML)
        //      doesn't allow that.  You can achieve that effect in HTML by inserting extra rows with spurious
        //      cells propped to a specific width, but I'm not going to do that.  Instead, I'm going to split
        //      the rows into separate tables when combining some set of rows into a table would force me
        //      to fabricate a column that doesn't contain any defined cell.
        // </Summary>

        private int PreCoalesceTable(DocumentNode dn)
        {
            int nInserted = 0;
            int nAt = dn.Index;
            ColumnStateArray cols = dn.ComputeColumns();

            // OK, now I have a set of columns and information about which row caused the column to
            // be instantiated.  The naive algorithm is to strip the first N rows from the table until
            // the row that caused an uninstantiated column, break the table there, and then run the
            // algorithm again on the trailing table.
            int nUnfilledRowIndex = cols.GetMinUnfilledRowIndex();

            if (nUnfilledRowIndex > 0)
            {
                // OK, Need to insert a new table and table group around the remaining rows.
                DocumentNode dnNewTable = new DocumentNode(DocumentNodeType.dnTable);
                DocumentNode dnNewTableBody = new DocumentNode(DocumentNodeType.dnTableBody);
                dnNewTable.FormatState = new FormatState(dn.FormatState);
                dnNewTable.FormatState.RowFormat = EntryAt(nUnfilledRowIndex).FormatState.RowFormat;
                int nChildrenOldTable = nUnfilledRowIndex - dn.Index - 1;
                int nChildrenNewTable = dn.ChildCount - nChildrenOldTable;
                dn.ChildCount = nChildrenOldTable;  // Update old table child count
                EntryAt(nAt + 1).ChildCount = nChildrenOldTable - 1;    // Update old TableBody child count
                InsertNode(nUnfilledRowIndex, dnNewTableBody);
                CloseAtHelper(nUnfilledRowIndex, nChildrenNewTable);
                InsertNode(nUnfilledRowIndex, dnNewTable);
                CloseAtHelper(nUnfilledRowIndex, nChildrenNewTable + 1);

                // Adjust parent pointers
                dnNewTableBody.Parent = dnNewTable;
                dnNewTable.Parent = dn.ClosedParent;
                for (DocumentNode dnPa = dnNewTable.ClosedParent; dnPa != null; dnPa = dnPa.ClosedParent)
                {
                    dnPa.ChildCount = dnPa.ChildCount + 2;
                }

                // Adjust the loop end to account for the newly inserted elements
                nInserted = 2;

                // Need to recompute the ColumnStateArray for the newly truncated table.
                dn.ColumnStateArray = dn.ComputeColumns();
            }
            else
            {
                dn.ColumnStateArray = cols;
            }

            return nInserted;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:57,代码来源:RtfToXamlReader.cs

示例8: HandleTableNesting

        internal void HandleTableNesting(FormatState formatState)
        {
            DocumentNodeArray dna = _converterState.DocumentNodeArray;

            // If we're in a throw-away destination, just return.
            if (!formatState.IsContentDestination || formatState.IsHidden)
            {
                return;
            }

            // Make sure proper number of tables are open to reflect this paragraphs nest level
            int nTables = dna.CountOpenNodes(DocumentNodeType.dnTable);
            int nLevel = (int)formatState.TableLevel;

            // If we're not in a table, end early
            if (nTables == nLevel && nTables == 0)
            {
                return;
            }

            if (nTables > nLevel)
            {
                DocumentNode dnPara = dna.Pop();

                bool bInField = dna.FindUnmatched(DocumentNodeType.dnFieldBegin) >= 0;
                while (nTables > nLevel)
                {

                    int nOpen = dna.FindPending(DocumentNodeType.dnTable);
                    if (nOpen >= 0)
                    {
                        dna.CloseAt(nOpen);
                        if (!bInField)
                        {
                            dna.CoalesceChildren(_converterState, nOpen);
                        }
                    }
                    nTables--;
                }
                dna.Push(dnPara);
            }
            else
            {
                // Before opening the table, let's close any open lists.  Word (RTF) allows somewhat
                // arbitrary interleaving (because there's no explicit nesting), but when converting to
                // XAML we have to choose an explicit nesting.  We never create a table *inside* a list, so
                // let's just terminate any open lists right now.
                if (nTables < nLevel)
                {
                    int nListAt = dna.FindPending(DocumentNodeType.dnList);
                    if (nListAt >= 0)
                    {
                        // I want the currently pending paragraph to be part of the table, not part of the list
                        // I'm going to close.  So I temporarily pop it off while closing off the list and then
                        // push it back on before inserting the table(s).
                        DocumentNode dnPara = dna.Pop();

                        while (nListAt >= 0)
                        {
                            dna.CloseAt(nListAt);
                            nListAt = dna.FindPending(DocumentNodeType.dnList);
                        }

                        dna.Push(dnPara);
                    }
                }

                // Ensure sufficient tables are open - this may be our first indication
                // Insert the table nodes right before the current paragraph.
                Debug.Assert(dna.Count > 0 && dna.EntryAt(dna.Count - 1).Type == DocumentNodeType.dnParagraph);

                int nInsertAt = dna.Count - 1;

                // Ensure row is open
                int nTable = dna.FindPending(DocumentNodeType.dnTable);
                if (nTable >= 0)
                {
                    int nRow = dna.FindPending(DocumentNodeType.dnRow, nTable);
                    if (nRow == -1)
                    {
                        DocumentNode dnRow = new DocumentNode(DocumentNodeType.dnRow);
                        dna.InsertNode(nInsertAt++, dnRow);
                        nRow = nInsertAt - 1;
                    }

                    int nCell = dna.FindPending(DocumentNodeType.dnCell, nRow);
                    if (nCell == -1)
                    {
                        DocumentNode dnCell = new DocumentNode(DocumentNodeType.dnCell);
                        dna.InsertNode(nInsertAt, dnCell);
                    }
                }

                nInsertAt = dna.Count - 1;
                while (nTables < nLevel)
                {
                    DocumentNode dnTable = new DocumentNode(DocumentNodeType.dnTable);
                    DocumentNode dnTableBody = new DocumentNode(DocumentNodeType.dnTableBody);
                    DocumentNode dnRow = new DocumentNode(DocumentNodeType.dnRow);
                    DocumentNode dnCell = new DocumentNode(DocumentNodeType.dnCell);
//.........这里部分代码省略.........
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:101,代码来源:RtfToXamlReader.cs

示例9: HandleNormalTextRaw

        internal void HandleNormalTextRaw(string text, FormatState formatState)
        {
            DocumentNodeArray dna = _converterState.DocumentNodeArray;
            DocumentNode dnTop = dna.Top;

            // See if I can just append the text content if the format is the same.
            if (dnTop != null && (dnTop.Type == DocumentNodeType.dnText))
            {
                // If the format is not equal, close this text element and we'll open a new one.
                if (!dnTop.FormatState.IsEqual(formatState))
                {
                    dna.CloseAt(dna.Count - 1);
                    dnTop = null;
                }
            }

            // OK, create a text node if necessary
            if (dnTop == null || dnTop.Type != DocumentNodeType.dnText)
            {
                dnTop = new DocumentNode(DocumentNodeType.dnText);
                dnTop.FormatState = new FormatState(formatState);
                dna.Push(dnTop);
            }

            Debug.Assert(!dnTop.IsTerminated);
            dnTop.AppendXamlEncoded(text);
            dnTop.IsPending = false;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:28,代码来源:RtfToXamlReader.cs

示例10: HandleOldListTokens

        internal void HandleOldListTokens(RtfToken token, FormatState formatState)
        {
            FormatState fsCur = _converterState.PreviousTopFormatState(0);
            FormatState fsOld = _converterState.PreviousTopFormatState(1);
            if (fsCur == null || fsOld == null)
            {
                return;
            }

            // If we're in the PN destination, we push marker setting into the previous format state.
            if (formatState.RtfDestination == RtfDestination.DestPN)
            {
                formatState = fsOld;
            }

            switch (token.RtfControlWordInfo.Control)
            {
                case RtfControlWord.Ctrl_PNLVL:
                    formatState.PNLVL = token.Parameter;
                    break;
                case RtfControlWord.Ctrl_PNLVLBLT:
                    formatState.Marker = MarkerStyle.MarkerBullet;
                    formatState.IsContinue = false;
                    break;
                case RtfControlWord.Ctrl_PNLVLBODY:
                    formatState.Marker = MarkerStyle.MarkerArabic;
                    formatState.IsContinue = false;
                    break;
                case RtfControlWord.Ctrl_PNLVLCONT:
                    formatState.IsContinue = true;
                    break;
                case RtfControlWord.Ctrl_PNCARD:
                    formatState.Marker = MarkerStyle.MarkerCardinal;
                    break;
                case RtfControlWord.Ctrl_PNDEC:
                    formatState.Marker = MarkerStyle.MarkerArabic;
                    break;
                case RtfControlWord.Ctrl_PNUCLTR:
                    formatState.Marker = MarkerStyle.MarkerUpperAlpha;
                    break;
                case RtfControlWord.Ctrl_PNUCRM:
                    formatState.Marker = MarkerStyle.MarkerUpperRoman;
                    break;
                case RtfControlWord.Ctrl_PNLCLTR:
                    formatState.Marker = MarkerStyle.MarkerLowerAlpha;
                    break;
                case RtfControlWord.Ctrl_PNLCRM:
                    formatState.Marker = MarkerStyle.MarkerLowerRoman;
                    break;
                case RtfControlWord.Ctrl_PNORD:
                    formatState.Marker = MarkerStyle.MarkerOrdinal;
                    break;
                case RtfControlWord.Ctrl_PNORDT:
                    formatState.Marker = MarkerStyle.MarkerOrdinal;
                    break;
                case RtfControlWord.Ctrl_PNBIDIA:
                    formatState.Marker = MarkerStyle.MarkerArabic;
                    break;
                case RtfControlWord.Ctrl_PNBIDIB:
                    formatState.Marker = MarkerStyle.MarkerArabic;
                    break;
                case RtfControlWord.Ctrl_PN:
                    formatState.RtfDestination = RtfDestination.DestPN;
                    fsOld.Marker = MarkerStyle.MarkerBullet;
                    break;
                case RtfControlWord.Ctrl_PNTXTA:
                    // Leave with unknown destination so text is tossed.
                    break;
                case RtfControlWord.Ctrl_PNTXTB:
                    // Leave with unknown destination so text is tossed.
                    break;
                case RtfControlWord.Ctrl_PNTEXT:
                    if (fsOld.IsContentDestination || formatState.IsHidden)
                    {
                        fsCur.RtfDestination = RtfDestination.DestListText;
                        DocumentNodeArray dna = _converterState.DocumentNodeArray;
                        DocumentNode dnl = new DocumentNode(DocumentNodeType.dnListText);

                        dnl.FormatState = new FormatState(formatState);
                        dna.Push(dnl);
                    }
                    break;
                case RtfControlWord.Ctrl_PNSTART:
                    formatState.StartIndex = token.Parameter;
                    break;

                default:
                    formatState.Marker = MarkerStyle.MarkerBullet;
                    break;
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:91,代码来源:RtfToXamlReader.cs

示例11: HandleFieldTokens

        internal void HandleFieldTokens(RtfToken token, FormatState formatState)
        {
            // Don't start processing fields in non-normal destinatations
            FormatState fsCur = _converterState.PreviousTopFormatState(0);
            FormatState fsOld = _converterState.PreviousTopFormatState(1);
            if (fsCur == null || fsOld == null)
            {
                return;
            }

            switch (token.RtfControlWordInfo.Control)
            {
                case RtfControlWord.Ctrl_FIELD:
                    // Process fields in normal content or nested fields
                    if (!fsOld.IsContentDestination || formatState.IsHidden)
                    {
                        return;
                    }
                    formatState.RtfDestination = RtfDestination.DestField;
                    break;
                case RtfControlWord.Ctrl_FLDRSLT:
                    if (fsOld.RtfDestination != RtfDestination.DestField)
                    {
                        return;
                    }
                    formatState.RtfDestination = RtfDestination.DestFieldResult;
                    break;
                case RtfControlWord.Ctrl_FLDPRIV:
                    if (fsOld.RtfDestination != RtfDestination.DestField)
                    {
                        return;
                    }
                    formatState.RtfDestination = RtfDestination.DestFieldPrivate;
                    break;
                case RtfControlWord.Ctrl_FLDINST:
                    if (fsOld.RtfDestination != RtfDestination.DestField)
                    {
                        return;
                    }
                    formatState.RtfDestination = RtfDestination.DestFieldInstruction;
                    break;
                default:
                    return;
            }

            DocumentNodeArray dna = _converterState.DocumentNodeArray;
            DocumentNode dnf = new DocumentNode(DocumentNodeType.dnFieldBegin);

            dnf.FormatState = new FormatState(formatState);
            dnf.IsPending = false;  // Field start mark should not impact other tags open/close behavior
            dnf.IsTerminated = true;
            dna.Push(dnf);
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:53,代码来源:RtfToXamlReader.cs

示例12: HandleShapeTokens

        internal void HandleShapeTokens(RtfToken token, FormatState formatState)
        {
            DocumentNodeArray dna = _converterState.DocumentNodeArray;
            FormatState fsCur = _converterState.PreviousTopFormatState(0);
            FormatState fsOld = _converterState.PreviousTopFormatState(1);
            if (fsCur == null || fsOld == null)
            {
                return;
            }

            switch (token.RtfControlWordInfo.Control)
            {
                case RtfControlWord.Ctrl_DO:
                    // Just propagate destination through this keyword.
                    fsCur.RtfDestination = fsOld.RtfDestination;
                    break;
                case RtfControlWord.Ctrl_SHPRSLT:
                    if (fsOld.IsContentDestination)
                    {
                        fsCur.RtfDestination = RtfDestination.DestShape;
                    }
                    break;
                case RtfControlWord.Ctrl_DPTXBXTEXT:
                    if (fsOld.IsContentDestination)
                    {
                        // Track the destination so I can recognize when we leave this scope.
                        fsCur.RtfDestination = RtfDestination.DestShapeResult;

                        // Wrap any inline content that occurs before this shape anchor in a paragraph,
                        // since the shape content itself will be block level.
                        WrapPendingInlineInParagraph(token, formatState);

                        DocumentNodeType t = dna.GetTableScope();
                        if (t != DocumentNodeType.dnParagraph)
                        {
                            if (t == DocumentNodeType.dnTableBody)
                            {
                                // If row has been closed, close overall table as well.
                                int nAt = dna.FindPending(DocumentNodeType.dnTable);
                                if (nAt >= 0)
                                {
                                    dna.CloseAt(nAt);
                                    dna.CoalesceChildren(_converterState, nAt);
                                }
                            }
                            else
                            {
                                // If I'm inside a table, reopen last cell to insert shape contents.  Otherwise
                                // table gets torqued.
                                dna.OpenLastCell();
                            }
                        }

                        // The shape node generates no output but plays a large role in changing the
                        // behavior of the "FindPending" routines to keep from looking outside this scope.
                        DocumentNode dn = new DocumentNode(DocumentNodeType.dnShape);
                        formatState.SetParaDefaults();
                        formatState.SetCharDefaults();
                        dn.FormatState = new FormatState(formatState);
                        dna.Push(dn);
                    }
                    break;
                case RtfControlWord.Ctrl_SHPPICT:
                    // If this occurs in listtext context, mark listtext as non-empty.
                    int ndnListText = dna.FindPending(DocumentNodeType.dnListText);
                    if (ndnListText >= 0)
                    {
                        DocumentNode dnListText = dna.EntryAt(ndnListText);

                        dnListText.HasMarkerContent = true;
                    }

                    // Keep the rtf destination as the list picture to skip the list picture
                    if (fsOld.RtfDestination == RtfDestination.DestListPicture)
                    {
                        formatState.RtfDestination = RtfDestination.DestListPicture;
                    }
                    else
                    {
                        formatState.RtfDestination = RtfDestination.DestShapePicture;
                    }

                    break;
                case RtfControlWord.Ctrl_NONSHPPICT:
                    formatState.RtfDestination = RtfDestination.DestNoneShapePicture;
                    break;
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:88,代码来源:RtfToXamlReader.cs

示例13: HandleListTokens

        internal void HandleListTokens(RtfToken token, FormatState formatState)
        {
            ListTable listTable = _converterState.ListTable;
            ListOverrideTable listOverrideTable = _converterState.ListOverrideTable;

            FormatState fsCur = _converterState.PreviousTopFormatState(0);
            FormatState fsOld = _converterState.PreviousTopFormatState(1);
            if (fsCur == null || fsOld == null)
            {
                return;
            }

            switch (token.RtfControlWordInfo.Control)
            {
                case RtfControlWord.Ctrl_LIST:
                    if (formatState.RtfDestination == RtfDestination.DestListTable)
                    {
                        ListTableEntry listTableEntry = listTable.AddEntry();
                    }
                    break;

                case RtfControlWord.Ctrl_LISTTEMPLATEID:
                    {
                        ListTableEntry listTableEntry = listTable.CurrentEntry;
                        if (listTableEntry != null)
                        {
                            listTableEntry.TemplateID = token.Parameter;
                        }
                    }
                    break;

                case RtfControlWord.Ctrl_LISTHYBRID:
                case RtfControlWord.Ctrl_LISTSIMPLE:
                    {
                        ListTableEntry listTableEntry = listTable.CurrentEntry;
                        if (listTableEntry != null)
                        {
                            listTableEntry.Simple = token.RtfControlWordInfo.Control == RtfControlWord.Ctrl_LISTSIMPLE;
                        }
                    }
                    break;

                case RtfControlWord.Ctrl_LISTLEVEL:
                    {
                        formatState.RtfDestination = RtfDestination.DestListLevel;
                        ListLevelTable levels = GetControllingLevelTable();
                        if (levels != null)
                        {
                            ListLevel listLevel = levels.AddEntry();
                        }
                    }
                    break;

                case RtfControlWord.Ctrl_LISTTEXT:
                    if (fsOld.IsContentDestination || formatState.IsHidden)
                    {
                        formatState.RtfDestination = RtfDestination.DestListText;
                        DocumentNodeArray dna = _converterState.DocumentNodeArray;
                        DocumentNode dnl = new DocumentNode(DocumentNodeType.dnListText);

                        dnl.FormatState = new FormatState(formatState);
                        dna.Push(dnl);
                    }
                    break;

                case RtfControlWord.Ctrl_LEVELNFC:
                case RtfControlWord.Ctrl_LEVELNFCN:
                    {
                        ListLevelTable levels = GetControllingLevelTable();
                        if (levels != null)
                        {
                            ListLevel listLevel = levels.CurrentEntry;
                            if (listLevel != null)
                            {
                                listLevel.Marker = (MarkerStyle)token.Parameter;
                            }
                        }
                    }
                    break;
                case RtfControlWord.Ctrl_LEVELJC:
                case RtfControlWord.Ctrl_LEVELJCN:
                    // NB: Marker alignment not supported in XAML.
                    break;

                case RtfControlWord.Ctrl_LEVELFOLLOW:
                    break;

                case RtfControlWord.Ctrl_LEVELSTARTAT:
                    {
                        ListLevelTable levels = GetControllingLevelTable();
                        if (levels != null)
                        {
                            ListLevel listLevel = levels.CurrentEntry;
                            if (listLevel != null)
                            {
                                listLevel.StartIndex = token.Parameter;
                            }
                            else
                            {
                                // This is the case where the list override *only* specifies startat override.
//.........这里部分代码省略.........
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:101,代码来源:RtfToXamlReader.cs

示例14: WriteSection

        private void WriteSection(DocumentNode dnThis) 
        { 
            int nStart = dnThis.Index + 1;
            int nEnd = dnThis.Index + dnThis.ChildCount; 
            int nAt;

            FormatState fsThis = dnThis.FormatState;
            FormatState fsParent = dnThis.Parent != null ? dnThis.Parent.FormatState : FormatState.EmptyFormatState; 
            DocumentNodeArray dna = _converterState.DocumentNodeArray;
 
            _rtfBuilder.Append("{"); 

            // CultureInfo 
            if (fsThis.Lang != fsParent.Lang && fsThis.Lang > 0)
            {
                _rtfBuilder.Append("\\lang");
                _rtfBuilder.Append(fsThis.Lang.ToString(CultureInfo.InvariantCulture)); 
            }
 
            // FlowDirection 
            if (fsThis.DirPara == DirState.DirRTL)
            { 
                _rtfBuilder.Append("\\rtlpar");
            }

            // Write the font information 
            if (WriteParagraphFontInfo(dnThis, fsThis, fsParent))
            { 
                _rtfBuilder.Append(" "); 
            }
 
            // Foreground
            if (fsThis.CF != fsParent.CF)
            {
                _rtfBuilder.Append("\\cf"); 
                _rtfBuilder.Append(fsThis.CF.ToString(CultureInfo.InvariantCulture));
            } 
 
            // TextAlignment
            switch (fsThis.HAlign) 
            {
                case HAlign.AlignLeft:
                    if (fsThis.DirPara != DirState.DirRTL)
                    { 
                        _rtfBuilder.Append("\\ql");
                    } 
                    else 
                    {
                        _rtfBuilder.Append("\\qr"); 
                    }
                    break;

                case HAlign.AlignRight: 
                    if (fsThis.DirPara != DirState.DirRTL)
                    { 
                        _rtfBuilder.Append("\\qr"); 
                    }
                    else 
                    {
                        _rtfBuilder.Append("\\ql");
                    }
                    break; 

                case HAlign.AlignCenter: 
                    _rtfBuilder.Append("\\qc"); 
                    break;
 
                case HAlign.AlignJustify:
                    _rtfBuilder.Append("\\qj");
                    break;
            } 

            // LineHeight 
            if (fsThis.SL != 0) 
            {
                _rtfBuilder.Append("\\sl"); 
                _rtfBuilder.Append(fsThis.SL.ToString(CultureInfo.InvariantCulture));
                _rtfBuilder.Append("\\slmult0");
            }
 
            // Now write out the direct children.
            for (nAt = nStart; nAt <= nEnd; nAt++) 
            { 
                DocumentNode dnChild = dna.EntryAt(nAt);
 
                // Ignore non-direct children - they get written out by their parent
                if (dnChild.Parent == dnThis)
                {
                    WriteStructure(dnChild); 
                }
            } 
 
            // Close Section writing
            _rtfBuilder.Append("}"); 
            _rtfBuilder.Append("\r\n");
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:96,代码来源:XamlToRtfWriter.cs

示例15: InsertNode

        internal void InsertNode(int nAt, DocumentNode dn)
        {
            Insert(nAt, dn);

            // Match sure Index values remain up-to-date.
            if (_fMain)
            {
                dn.Index = nAt;
                dn.DNA = this;
                for (nAt++; nAt < Count; nAt++)
                {
                    EntryAt(nAt).Index = nAt;
                }

                // Track open nodes
                if (dn.IsTrackedAsOpen)
                {
                    if (_dnaOpen == null)
                    {
                        _dnaOpen = new DocumentNodeArray();
                    }
                    _dnaOpen.InsertOpenNode(dn);
                }
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:25,代码来源:RtfToXamlReader.cs


注:本文中的System.Windows.Documents.DocumentNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。