// Token: 0x060034B0 RID: 13488 RVA: 0x000EAA6C File Offset: 0x000E8C6C private void PreCoalesceRow(DocumentNode dn, ref bool fVMerged) { DocumentNodeArray rowsCells = dn.GetRowsCells(); RowFormat rowFormat = dn.FormatState.RowFormat; DocumentNode parentOfType = dn.GetParentOfType(DocumentNodeType.dnTable); ColumnStateArray columnStateArray = (parentOfType != null) ? parentOfType.ColumnStateArray : null; int num = (rowsCells.Count < rowFormat.CellCount) ? rowsCells.Count : rowFormat.CellCount; int i = 0; int j = 0; while (j < num) { DocumentNode documentNode = rowsCells.EntryAt(j); CellFormat cellFormat = rowFormat.NthCellFormat(j); long cellX = cellFormat.CellX; if (cellFormat.IsVMerge) { fVMerged = true; } if (cellFormat.IsHMergeFirst) { for (j++; j < num; j++) { cellFormat = rowFormat.NthCellFormat(j); if (cellFormat.IsVMerge) { fVMerged = true; } if (cellFormat.IsHMerge) { rowsCells.EntryAt(j).ColSpan = 0; } } } else { j++; } if (columnStateArray != null) { int num2 = i; while (i < columnStateArray.Count) { ColumnState columnState = columnStateArray.EntryAt(i); i++; if (columnState.CellX == cellX || columnState.CellX > cellX) { break; } } if (i - num2 > documentNode.ColSpan) { documentNode.ColSpan = i - num2; } } } }
//------------------------------------------------------ // // Constructors // //------------------------------------------------------ #region Constructors /// <summary> /// ConverterState Constructor /// </summary> internal ConverterState() { _rtfFormatStack = new RtfFormatStack(); _documentNodeArray = new DocumentNodeArray(); _documentNodeArray.IsMain = true; _fontTable = new FontTable(); _colorTable = new ColorTable(); _listTable = new ListTable(); _listOverrideTable = new ListOverrideTable(); _defaultFont = -1; _defaultLang = -1; _defaultLangFE = -1; _bMarkerWhiteSpace = false; _bMarkerPresent = false; _border = null; }
private void ProcessTableRowSpan(DocumentNodeArray dnaTables) { for (int i = 0; i < dnaTables.Count; i++) { DocumentNode dnTable = dnaTables.EntryAt(i); ColumnStateArray csa = dnTable.ColumnStateArray; if (csa == null || csa.Count == 0) { continue; } int nDim = csa.Count; DocumentNodeArray dnaRows = dnTable.GetTableRows(); DocumentNodeArray dnaSpanCells = new DocumentNodeArray(); for (int k = 0; k < nDim; k++) { dnaSpanCells.Add(null); } for (int j = 0; j < dnaRows.Count; j++) { DocumentNode dnRow = dnaRows.EntryAt(j); RowFormat rf = dnRow.FormatState.RowFormat; DocumentNodeArray dnaCells = dnRow.GetRowsCells(); int nCount = nDim; if (rf.CellCount < nCount) { nCount = rf.CellCount; } if (dnaCells.Count < nCount) { nCount = dnaCells.Count; } // Nominally, the index into dnaSpanCells, dnaCells and RowFormat.NthCellFormat // should all be the same. But in some cases we have spanning cells that don't // actually have an explicit cell associated with it (the span is implicit in the // cellx/width values). I can detect this case by finding a colspan > 1 that is // not then followed by a HMerged format. In this case, I need to apply a correction // to my iteration, since the ColumnStateArray will have an entry for that field. int kCSA = 0; // this might advance faster for (int k = 0; k < nCount && kCSA < dnaSpanCells.Count; k++) { DocumentNode dnCell = dnaCells.EntryAt(k); CellFormat cf = rf.NthCellFormat(k); if (cf.IsVMerge) { DocumentNode dnSpanningCell = dnaSpanCells.EntryAt(kCSA); if (dnSpanningCell != null) { dnSpanningCell.RowSpan = dnSpanningCell.RowSpan + 1; } kCSA += dnCell.ColSpan; dnCell.ColSpan = 0; } else { if (cf.IsVMergeFirst) { dnCell.RowSpan = 1; dnaSpanCells[kCSA] = dnCell; } else { dnaSpanCells[kCSA] = null; } for (int l = kCSA + 1; l < kCSA + dnCell.ColSpan; l++) { dnaSpanCells[l] = null; } kCSA += dnCell.ColSpan; } } } } }
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); } } }
internal void PreCoalesceChildren(ConverterState converterState, int nStart, bool bChild) { // We process tables twice to handle first colspan, then rowspan DocumentNodeArray dnaTables = new DocumentNodeArray(); bool fVMerged = false; // Try to move paragraph margin to containing list items DocumentNode dnCoalesce = EntryAt(nStart); int nChild = dnCoalesce.ChildCount; Debug.Assert(nStart + nChild < Count); if (nStart + nChild >= Count) { nChild = Count - nStart - 1; } int nEnd = nStart + nChild; // If bChild specified, we don't process parent if (bChild) { nStart++; } // This is vaguely N^2 in the sense that for each list item, I process all containing paragraphs, // including ones contained in other list items. But it's only a problem for very deep, very long // lists, so we can live with it. for (int nAt = nStart; nAt <= nEnd; nAt++) { DocumentNode dn = EntryAt(nAt); // Inline direction merging if (dn.IsInline && dn.RequiresXamlDir && dn.ClosedParent != null) { int nnAt = nAt + 1; for (; nnAt <= nEnd; nnAt++) { DocumentNode dnn = EntryAt(nnAt); if (!dnn.IsInline || dnn.Type == DocumentNodeType.dnHyperlink || dnn.FormatState.DirChar != dn.FormatState.DirChar || dnn.ClosedParent != dn.ClosedParent) { break; } } int nChildHere = nnAt - nAt; if (nChildHere > 1) { DocumentNode dnNewDir = new DocumentNode(DocumentNodeType.dnInline); dnNewDir.FormatState = new FormatState(dn.Parent.FormatState); dnNewDir.FormatState.DirChar = dn.FormatState.DirChar; InsertChildAt(dn.ClosedParent, dnNewDir, nAt, nChildHere); // Adjust the loop end to account for the newly inserted element nEnd += 1; } } else if (dn.Type == DocumentNodeType.dnListItem) { PreCoalesceListItem(dn); } else if (dn.Type == DocumentNodeType.dnList) { PreCoalesceList(dn); } else if (dn.Type == DocumentNodeType.dnTable) { dnaTables.Add(dn); nEnd += PreCoalesceTable(dn); } // Compute colspan else if (dn.Type == DocumentNodeType.dnRow) { PreCoalesceRow(dn, ref fVMerged); } } // Process tables to examine rowspan if (fVMerged) { ProcessTableRowSpan(dnaTables); } }
internal DocumentNodeArray GetRowsCells() { DocumentNodeArray dna = DNA; DocumentNodeArray retArray = new DocumentNodeArray(); if (Type == DocumentNodeType.dnRow) { int nStart = this.Index + 1; int nLast = this.Index + this.ChildCount; for (; nStart <= nLast; nStart++) { DocumentNode dnCell = dna.EntryAt(nStart); if (dnCell.Type == DocumentNodeType.dnCell && this == dnCell.GetParentOfType(DocumentNodeType.dnRow)) { retArray.Push(dnCell); } } } return retArray; }
private void AppendXamlPrefixCellProperties(StringBuilder xamlStringBuilder, DocumentNodeArray dna, ConverterState converterState) { Color cToUse = Color.FromArgb(0xff, 0, 0, 0); // Row stores cell properties. DocumentNode dnRow = GetParentOfType(DocumentNodeType.dnRow); Debug.Assert(dnRow != null); // Need row Debug.Assert(dnRow != null && !dnRow.IsPending); // Row props attached when row is closed Debug.Assert(dnRow != null && dnRow.FormatState.RowFormat != null); if (dnRow != null && dnRow.FormatState.HasRowFormat) { int nCol = GetCellColumn(); CellFormat cf = dnRow.FormatState.RowFormat.NthCellFormat(nCol); if (Converters.ColorToUse(converterState, cf.CB, cf.CF, cf.Shading, ref cToUse)) { xamlStringBuilder.Append(" Background=\""); xamlStringBuilder.Append(cToUse.ToString(CultureInfo.InvariantCulture)); xamlStringBuilder.Append("\""); } if (cf.HasBorder) { xamlStringBuilder.Append(cf.GetBorderAttributeString(converterState)); } xamlStringBuilder.Append(cf.GetPaddingAttributeString()); } else xamlStringBuilder.Append(" BorderBrush=\"#FF000000\" BorderThickness=\"1,1,1,1\""); if (ColSpan > 1) { xamlStringBuilder.Append(" ColumnSpan=\""); xamlStringBuilder.Append(ColSpan.ToString(CultureInfo.InvariantCulture)); xamlStringBuilder.Append("\""); } if (RowSpan > 1) { xamlStringBuilder.Append(" RowSpan=\""); xamlStringBuilder.Append(RowSpan.ToString(CultureInfo.InvariantCulture)); xamlStringBuilder.Append("\""); } }
private void EnsureListAndListItem(FormatState formatState, DocumentNodeArray dna, MarkerList mlHave, MarkerList mlWant, int nMatch) { int nInsertAt; bool added = false; int nLists = mlHave.Count; int nLevel = mlWant.Count; // Close any open lists that don't match the ones we want. bool bInField = dna.FindUnmatched(DocumentNodeType.dnFieldBegin) >= 0; if (nLists > nMatch) { DocumentNode documentNodePara = dna.Pop(); while (nLists > nMatch) { int nOpen = dna.FindPending(DocumentNodeType.dnList); if (nOpen >= 0) { dna.CloseAt(nOpen); // Only coalesce if this is a top-level list. Otherwise I want to get // the full structure to use for margin fixups so I delay coalescing. // No, don't coalesce since a later list may need to get merged with this one. // if (!bInField && dna.FindPending(DocumentNodeType.dnList) < 0) // dna.CoalesceChildren(_converterState, nOpen); } nLists--; mlHave.RemoveRange(mlHave.Count - 1, 1); } dna.Push(documentNodePara); } if (nLists < nLevel) { // Multiple immediately nested lists are handled poorly in Avalon and are usually an indication // of bad input from Word (or some other word processor). Clip the number of lists we'll create here. if (nLevel != nLists + 1) { // I'm going to truncate, but make the list I create here of the specific type at this level. if (nLevel <= mlWant.Count) { mlWant[nLists] = mlWant[mlWant.Count - 1]; } nLevel = nLists + 1; } // Ensure sufficient lists are open - this may be our first indication // Insert the list nodes right before the current paragraph nInsertAt = dna.Count - 1; while (nLists < nLevel) { added = true; DocumentNode dnList = new DocumentNode(DocumentNodeType.dnList); DocumentNode dnLI = new DocumentNode(DocumentNodeType.dnListItem); dna.InsertNode(nInsertAt, dnLI); dna.InsertNode(nInsertAt, dnList); // Set the list properties MarkerListEntry mle = mlWant.EntryAt(nLists); dnList.FormatState.Marker = mle.Marker; dnList.FormatState.StartIndex = mle.StartIndexToUse; dnList.FormatState.StartIndexDefault = mle.StartIndexDefault; dnList.VirtualListLevel = mle.VirtualListLevel; dnList.FormatState.ILS = mle.ILS; nLists++; } } // Ensure listitem is open nInsertAt = dna.Count - 1; int nList = dna.FindPending(DocumentNodeType.dnList); if (nList >= 0) { int nLI = dna.FindPending(DocumentNodeType.dnListItem, nList); if (nLI >= 0 && !added && !formatState.IsContinue) { DocumentNode documentNodePara = dna.Pop(); dna.CloseAt(nLI); // Don't coalesce - I may need to do margin fixup. // dna.CoalesceChildren(_converterState, nLI); dna.Push(documentNodePara); nLI = -1; nInsertAt = dna.Count - 1; } if (nLI == -1) { DocumentNode dnLI = new DocumentNode(DocumentNodeType.dnListItem); dna.InsertNode(nInsertAt, dnLI); } } }
// Helper for IXamlContentHandler.StartElement. private XamlToRtfError HandleAttributes(ConverterState converterState, IXamlAttributes attributes, DocumentNode documentNode, XamlTag xamlTag, DocumentNodeArray dna) { int nLen = 0; XamlToRtfError xamlToRtfError = attributes.GetLength(ref nLen); if (xamlToRtfError == XamlToRtfError.None) { string uri = string.Empty; string newLocalName = string.Empty; string newQName = string.Empty; string valueString = string.Empty; FormatState formatState = documentNode.FormatState; XamlAttribute attribute = XamlAttribute.XAUnknown; long valueData = 0; for (int i = 0; xamlToRtfError == XamlToRtfError.None && i < nLen; i++) { xamlToRtfError = attributes.GetName(i, ref uri, ref newLocalName, ref newQName); if (xamlToRtfError == XamlToRtfError.None) { xamlToRtfError = attributes.GetValue(i, ref valueString); if (xamlToRtfError == XamlToRtfError.None && XamlParserHelper.ConvertToAttribute(converterState, newLocalName, ref attribute)) { switch (attribute) { case XamlAttribute.XAUnknown: break; case XamlAttribute.XAFontWeight: if (string.Compare(valueString, "Normal", StringComparison.OrdinalIgnoreCase) == 0) { formatState.Bold = false; } else if (string.Compare(valueString, "Bold", StringComparison.OrdinalIgnoreCase) == 0) { formatState.Bold = true; } break; case XamlAttribute.XAFontSize: double fs = 0f; if (XamlParserHelper.ConvertToFontSize(converterState, valueString, ref fs)) { formatState.FontSize = (long)Math.Round(fs); } break; case XamlAttribute.XAFontStyle: if (string.Compare(valueString, "Italic", StringComparison.OrdinalIgnoreCase) == 0) { formatState.Italic = true; } break; case XamlAttribute.XAFontFamily: if (XamlParserHelper.ConvertToFont(converterState, valueString, ref valueData)) { formatState.Font = valueData; } break; case XamlAttribute.XAFontStretch: if (XamlParserHelper.ConvertToFontStretch(converterState, valueString, ref valueData)) { formatState.Expand = valueData; } break; case XamlAttribute.XABackground: if (XamlParserHelper.ConvertToColor(converterState, valueString, ref valueData)) { if (documentNode.IsInline) { formatState.CB = valueData; } else { formatState.CBPara = valueData; } } break; case XamlAttribute.XAForeground: if (XamlParserHelper.ConvertToColor(converterState, valueString, ref valueData)) { formatState.CF = valueData; } break; case XamlAttribute.XAFlowDirection: DirState dirState = DirState.DirDefault; if (XamlParserHelper.ConvertToDir(converterState, valueString, ref dirState)) { if (documentNode.IsInline) { formatState.DirChar = dirState; } else if (documentNode.Type == DocumentNodeType.dnTable) { formatState.RowFormat.Dir = dirState; } else { formatState.DirPara = dirState; // Set the default inline flow direction as the paragraph's flow direction formatState.DirChar = dirState; } if (documentNode.Type == DocumentNodeType.dnList) { // Reset the left/right margin for List as the default value(720) // on RTL flow direction. Actually LI is set as 720 as the default // CreateDocumentNode(). if (formatState.DirPara == DirState.DirRTL) { formatState.LI = 0; formatState.RI = 720; } } } break; case XamlAttribute.XATextDecorations: { ULState ulState = ULState.ULNormal; StrikeState strikeState = StrikeState.StrikeNormal; if (XamlParserHelper.ConvertToDecoration(converterState, valueString, ref ulState, ref strikeState)) { if (ulState != ULState.ULNone) { formatState.UL = ulState; } if (strikeState != StrikeState.StrikeNone) { formatState.Strike = strikeState; } } } break; case XamlAttribute.XALocation: { ULState ulState = ULState.ULNormal; StrikeState strikeState = StrikeState.StrikeNormal; if (XamlParserHelper.ConvertToDecoration(converterState, valueString, ref ulState, ref strikeState)) { if (ulState != ULState.ULNone) { formatState.UL = ulState; } if (strikeState != StrikeState.StrikeNone) { formatState.Strike = strikeState; } } } break; case XamlAttribute.XARowSpan: { int nRowSpan = 0; if (Converters.StringToInt(valueString, ref nRowSpan)) { if (documentNode.Type == DocumentNodeType.dnCell) { documentNode.RowSpan = nRowSpan; } } } break; case XamlAttribute.XAColumnSpan: { int nColSpan = 0; if (Converters.StringToInt(valueString, ref nColSpan)) { if (documentNode.Type == DocumentNodeType.dnCell) { documentNode.ColSpan = nColSpan; } } } break; case XamlAttribute.XACellSpacing: { double d = 0f; if (Converters.StringToDouble(valueString, ref d)) { if (documentNode.Type == DocumentNodeType.dnTable) { formatState.RowFormat.Trgaph = Converters.PxToTwipRounded(d); } } } break; case XamlAttribute.XANavigateUri: if (xamlTag == XamlTag.XTHyperlink && valueString.Length > 0) { StringBuilder sb = new StringBuilder(); XamlParserHelper.AppendRTFText(sb, valueString, 0); documentNode.NavigateUri = sb.ToString(); } break; case XamlAttribute.XAWidth: if (xamlTag == XamlTag.XTTableColumn) { double d = 0f; if (Converters.StringToDouble(valueString, ref d)) { int nTableAt = dna.FindPending(DocumentNodeType.dnTable); if (nTableAt >= 0) { DocumentNode dnTable = dna.EntryAt(nTableAt); RowFormat rf = dnTable.FormatState.RowFormat; CellFormat cf = rf.NextCellFormat(); cf.Width.Type = WidthType.WidthTwips; cf.Width.Value = Converters.PxToTwipRounded(d); } } } else if (xamlTag == XamlTag.XTImage) { double d = 0f; Converters.StringToDouble(valueString, ref d); documentNode.FormatState.ImageWidth = d; } break; case XamlAttribute.XAHeight: if (xamlTag == XamlTag.XTImage) { double d = 0f; Converters.StringToDouble(valueString, ref d); documentNode.FormatState.ImageHeight = d; } break; case XamlAttribute.XASource: if (xamlTag == XamlTag.XTImage) { documentNode.FormatState.ImageSource = valueString; } break; case XamlAttribute.XAUriSource: if (xamlTag == XamlTag.XTBitmapImage) { documentNode.FormatState.ImageSource = valueString; } break; case XamlAttribute.XAStretch: if (xamlTag == XamlTag.XTImage) { documentNode.FormatState.ImageStretch = valueString; } break; case XamlAttribute.XAStretchDirection: if (xamlTag == XamlTag.XTImage) { documentNode.FormatState.ImageStretchDirection = valueString; } break; case XamlAttribute.XATypographyVariants: RtfSuperSubscript ss = RtfSuperSubscript.None; if (XamlParserHelper.ConvertToSuperSub(converterState, valueString, ref ss)) { if (ss == RtfSuperSubscript.Super) { formatState.Super = true; } else if (ss == RtfSuperSubscript.Sub) { formatState.Sub = true; } else if (ss == RtfSuperSubscript.Normal) { formatState.Sub = false; formatState.Super = false; } } break; case XamlAttribute.XAMarkerStyle: MarkerStyle ms = MarkerStyle.MarkerBullet; if (XamlParserHelper.ConvertToMarkerStyle(converterState, valueString, ref ms)) { formatState.Marker = ms; } break; case XamlAttribute.XAStartIndex: int nStart = 0; if (XamlParserHelper.ConvertToStartIndex(converterState, valueString, ref nStart)) { formatState.StartIndex = nStart; } break; case XamlAttribute.XAMargin: { XamlThickness thickness = new XamlThickness(0f, 0f, 0f, 0f); if (XamlParserHelper.ConvertToThickness(converterState, valueString, ref thickness)) { formatState.LI = Converters.PxToTwipRounded(thickness.Left); formatState.RI = Converters.PxToTwipRounded(thickness.Right); formatState.SB = Converters.PxToTwipRounded(thickness.Top); formatState.SA = Converters.PxToTwipRounded(thickness.Bottom); } } break; case XamlAttribute.XAPadding: { XamlThickness t = new XamlThickness(0f, 0f, 0f, 0f); if (XamlParserHelper.ConvertToThickness(converterState, valueString, ref t)) { if (xamlTag == XamlTag.XTParagraph) { // RTF only supports a single border padding value. formatState.ParaBorder.Spacing = Converters.PxToTwipRounded(t.Left); } else { RowFormat rf = formatState.RowFormat; CellFormat cf = rf.RowCellFormat; cf.PaddingLeft = Converters.PxToTwipRounded(t.Left); cf.PaddingRight = Converters.PxToTwipRounded(t.Right); cf.PaddingTop = Converters.PxToTwipRounded(t.Top); cf.PaddingBottom = Converters.PxToTwipRounded(t.Bottom); } } } break; case XamlAttribute.XABorderThickness: { XamlThickness t = new XamlThickness(0f, 0f, 0f, 0f); if (XamlParserHelper.ConvertToThickness(converterState, valueString, ref t)) { if (xamlTag == XamlTag.XTParagraph) { ParaBorder pf = formatState.ParaBorder; pf.BorderLeft.Type = BorderType.BorderSingle; pf.BorderLeft.Width = Converters.PxToTwipRounded(t.Left); pf.BorderRight.Type = BorderType.BorderSingle; pf.BorderRight.Width = Converters.PxToTwipRounded(t.Right); pf.BorderTop.Type = BorderType.BorderSingle; pf.BorderTop.Width = Converters.PxToTwipRounded(t.Top); pf.BorderBottom.Type = BorderType.BorderSingle; pf.BorderBottom.Width = Converters.PxToTwipRounded(t.Bottom); } else { RowFormat rf = formatState.RowFormat; CellFormat cf = rf.RowCellFormat; cf.BorderLeft.Type = BorderType.BorderSingle; cf.BorderLeft.Width = Converters.PxToTwipRounded(t.Left); cf.BorderRight.Type = BorderType.BorderSingle; cf.BorderRight.Width = Converters.PxToTwipRounded(t.Right); cf.BorderTop.Type = BorderType.BorderSingle; cf.BorderTop.Width = Converters.PxToTwipRounded(t.Top); cf.BorderBottom.Type = BorderType.BorderSingle; cf.BorderBottom.Width = Converters.PxToTwipRounded(t.Bottom); } } } break; case XamlAttribute.XABorderBrush: if (XamlParserHelper.ConvertToColor(converterState, valueString, ref valueData)) { if (xamlTag == XamlTag.XTParagraph) { formatState.ParaBorder.CF = valueData; } else { RowFormat rf = formatState.RowFormat; CellFormat cf = rf.RowCellFormat; cf.BorderLeft.CF = valueData; cf.BorderRight.CF = valueData; cf.BorderTop.CF = valueData; cf.BorderBottom.CF = valueData; } } break; case XamlAttribute.XATextIndent: double ti = 0; if (XamlParserHelper.ConvertToTextIndent(converterState, valueString, ref ti)) { formatState.FI = Converters.PxToTwipRounded(ti); } break; case XamlAttribute.XALineHeight: double sl = 0; if (XamlParserHelper.ConvertToLineHeight(converterState, valueString, ref sl)) { formatState.SL = Converters.PxToTwipRounded(sl); formatState.SLMult = false; } break; case XamlAttribute.XALang: { try { CultureInfo ci = new CultureInfo(valueString); if (ci.LCID > 0) { // Extract LANGID from LCID formatState.Lang = (long)(ushort)ci.LCID; } } catch (System.ArgumentException) { // Just omit if this is not a legal language value } } break; case XamlAttribute.XATextAlignment: HAlign halign = HAlign.AlignDefault; if (XamlParserHelper.ConvertToHAlign(converterState, valueString, ref halign)) { formatState.HAlign = halign; } break; } } } } } return xamlToRtfError; }
private void PatchVerticallyMergedCells(DocumentNode dnThis) { DocumentNodeArray dna = _converterState.DocumentNodeArray; DocumentNodeArray dnaRows = dnThis.GetTableRows(); DocumentNodeArray dnaSpanCells = new DocumentNodeArray(); ArrayList spanCounts = new ArrayList(); int nCol = 0; int nColExtra = 0; for (int i = 0; i < dnaRows.Count; i++) { DocumentNode dnRow = dnaRows.EntryAt(i); DocumentNodeArray dnaCells = dnRow.GetRowsCells(); int nColHere = 0; for (int j = 0; j < dnaCells.Count; j++) { DocumentNode dnCell = dnaCells.EntryAt(j); // Insert vmerged cell placeholder if necessary nColExtra = nColHere; while (nColExtra < spanCounts.Count && ((int)spanCounts[nColExtra]) > 0) { DocumentNode dnSpanningCell = dnaSpanCells.EntryAt(nColExtra); DocumentNode dnNew = new DocumentNode(DocumentNodeType.dnCell); dna.InsertChildAt(dnRow, dnNew, dnCell.Index, 0); dnNew.FormatState = new FormatState(dnSpanningCell.FormatState); if (dnSpanningCell.FormatState.HasRowFormat) { dnNew.FormatState.RowFormat = new RowFormat(dnSpanningCell.FormatState.RowFormat); } dnNew.FormatState.RowFormat.RowCellFormat.IsVMergeFirst = false; dnNew.FormatState.RowFormat.RowCellFormat.IsVMerge = true; dnNew.ColSpan = dnSpanningCell.ColSpan; nColExtra += dnNew.ColSpan; } // Take care of any cells hanging down from above. while (nColHere < spanCounts.Count && ((int)spanCounts[nColHere]) > 0) { // Update span count for this row spanCounts[nColHere] = ((int)spanCounts[nColHere]) - 1; if ((int)spanCounts[nColHere] == 0) { dnaSpanCells[nColHere] = null; } nColHere++; } // Now update colHere and spanCounts for (int k = 0; k < dnCell.ColSpan; k++) { if (nColHere < spanCounts.Count) { spanCounts[nColHere] = dnCell.RowSpan - 1; dnaSpanCells[nColHere] = (dnCell.RowSpan > 1) ? dnCell : null; } else { spanCounts.Add(dnCell.RowSpan - 1); dnaSpanCells.Add((dnCell.RowSpan > 1) ? dnCell : null); } nColHere++; } // Mark this cell as first in vmerged list if necessary if (dnCell.RowSpan > 1) { CellFormat cf = dnCell.FormatState.RowFormat.RowCellFormat; cf.IsVMergeFirst = true; } } // Insert vmerged cell placeholder if necessary nColExtra = nColHere; while (nColExtra < spanCounts.Count) { if (((int)spanCounts[nColExtra]) > 0) { // Insert vmerged cell here. DocumentNode dnSpanningCell = dnaSpanCells.EntryAt(nColExtra); DocumentNode dnNew = new DocumentNode(DocumentNodeType.dnCell); dna.InsertChildAt(dnRow, dnNew, dnRow.Index + dnRow.ChildCount + 1, 0); dnNew.FormatState = new FormatState(dnSpanningCell.FormatState); if (dnSpanningCell.FormatState.HasRowFormat) { dnNew.FormatState.RowFormat = new RowFormat(dnSpanningCell.FormatState.RowFormat); } dnNew.FormatState.RowFormat.RowCellFormat.IsVMergeFirst = false; dnNew.FormatState.RowFormat.RowCellFormat.IsVMerge = true; dnNew.ColSpan = dnSpanningCell.ColSpan; nColExtra += dnNew.ColSpan; } else { nColExtra++; } } // Take care of remaining cells hanging down. while (nColHere < spanCounts.Count) { if (((int)spanCounts[nColHere]) > 0) { spanCounts[nColHere] = ((int)spanCounts[nColHere]) - 1; if ((int)spanCounts[nColHere] == 0) { dnaSpanCells[nColHere] = null; } } nColHere++; } // Track max if (nColHere > nCol) { nCol = nColHere; } } }
// Token: 0x060034B1 RID: 13489 RVA: 0x000EABA4 File Offset: 0x000E8DA4 private void ProcessTableRowSpan(DocumentNodeArray dnaTables) { for (int i = 0; i < dnaTables.Count; i++) { DocumentNode documentNode = dnaTables.EntryAt(i); ColumnStateArray columnStateArray = documentNode.ColumnStateArray; if (columnStateArray != null && columnStateArray.Count != 0) { int count = columnStateArray.Count; DocumentNodeArray tableRows = documentNode.GetTableRows(); DocumentNodeArray documentNodeArray = new DocumentNodeArray(); for (int j = 0; j < count; j++) { documentNodeArray.Add(null); } for (int k = 0; k < tableRows.Count; k++) { DocumentNode documentNode2 = tableRows.EntryAt(k); RowFormat rowFormat = documentNode2.FormatState.RowFormat; DocumentNodeArray rowsCells = documentNode2.GetRowsCells(); int num = count; if (rowFormat.CellCount < num) { num = rowFormat.CellCount; } if (rowsCells.Count < num) { num = rowsCells.Count; } int num2 = 0; int num3 = 0; while (num3 < num && num2 < documentNodeArray.Count) { DocumentNode documentNode3 = rowsCells.EntryAt(num3); CellFormat cellFormat = rowFormat.NthCellFormat(num3); if (cellFormat.IsVMerge) { DocumentNode documentNode4 = documentNodeArray.EntryAt(num2); if (documentNode4 != null) { documentNode4.RowSpan++; } num2 += documentNode3.ColSpan; documentNode3.ColSpan = 0; } else { if (cellFormat.IsVMergeFirst) { documentNode3.RowSpan = 1; documentNodeArray[num2] = documentNode3; } else { documentNodeArray[num2] = null; } for (int l = num2 + 1; l < num2 + documentNode3.ColSpan; l++) { documentNodeArray[l] = null; } num2 += documentNode3.ColSpan; } num3++; } } } } }
// Token: 0x06003490 RID: 13456 RVA: 0x000E997C File Offset: 0x000E7B7C internal void PreCoalesceChildren(ConverterState converterState, int nStart, bool bChild) { DocumentNodeArray documentNodeArray = new DocumentNodeArray(); bool flag = false; DocumentNode documentNode = this.EntryAt(nStart); int num = documentNode.ChildCount; if (nStart + num >= this.Count) { num = this.Count - nStart - 1; } int num2 = nStart + num; if (bChild) { nStart++; } for (int i = nStart; i <= num2; i++) { DocumentNode documentNode2 = this.EntryAt(i); if (documentNode2.IsInline && documentNode2.RequiresXamlDir && documentNode2.ClosedParent != null) { int j; for (j = i + 1; j <= num2; j++) { DocumentNode documentNode3 = this.EntryAt(j); if (!documentNode3.IsInline || documentNode3.Type == DocumentNodeType.dnHyperlink || documentNode3.FormatState.DirChar != documentNode2.FormatState.DirChar || documentNode3.ClosedParent != documentNode2.ClosedParent) { break; } } int num3 = j - i; if (num3 > 1) { DocumentNode documentNode4 = new DocumentNode(DocumentNodeType.dnInline); documentNode4.FormatState = new FormatState(documentNode2.Parent.FormatState); documentNode4.FormatState.DirChar = documentNode2.FormatState.DirChar; this.InsertChildAt(documentNode2.ClosedParent, documentNode4, i, num3); num2++; } } else if (documentNode2.Type == DocumentNodeType.dnListItem) { this.PreCoalesceListItem(documentNode2); } else if (documentNode2.Type == DocumentNodeType.dnList) { this.PreCoalesceList(documentNode2); } else if (documentNode2.Type == DocumentNodeType.dnTable) { documentNodeArray.Add(documentNode2); num2 += this.PreCoalesceTable(documentNode2); } else if (documentNode2.Type == DocumentNodeType.dnRow) { this.PreCoalesceRow(documentNode2, ref flag); } } if (flag) { this.ProcessTableRowSpan(documentNodeArray); } }