private void ClearFirstComa(XsltItem x) { XsltItem lc; // у первого потомка после заголовка убрать запятую if (x.Children.Count > 0 && x.IsHeader() == true) { lc = x.Children[0]; lc.ComaBefore = false; } // у первого потомка после оглавления убрать запятую if (x.Children.Count > 0 && x.IsTOC() == true) { lc = x.Children[0]; lc.ComaBefore = false; } if (x.Children.Count > 0 && x.DotAfter == true) { lc = x.Children[0]; if (lc.ComaBefore) { lc.ComaBefore = false; } } foreach (XsltItem nc in x.Children) { ClearFirstComa(nc); } }
private void DotBeforeHeader(XsltItem x) { XsltItem lc; XsltItem cc; if (x.Children.Count > 0) { Int16 i; for (i = 0; i < x.Children.Count - 1; i++) { lc = x.Children[i + 1]; cc = x.Children[i]; // стаавим точку перед соседом - заголовком if (lc.IsHeader() && cc.IsHeader() == false) { lc.Capitalize = true; cc.DotAfter = true; } } foreach (XsltItem nc in x.Children) { DotBeforeHeader(nc); } } }
protected override string TocEnd(XsltItem sX) { string sOut = ""; sOut += "</td></tr>"; return(sOut); }
private void CapAfterDot(XsltItem x) { int i; XsltItem cur; XsltItem prev; for (i = 1; i < x.Children.Count; i++) { cur = x.Children[i]; prev = x.Children[i - 1]; if ((prev.Children.Count > 0 || prev.DotAfter)) { cur.ComaBefore = false; cur.Capitalize = true; } } // shift capitalization down from generic header if (x.Children.Count > 0) { if (x.Capitalize && (x.Path == "" || x.Path.ToLower().Contains("generic"))) { x.Children[0].Capitalize = true; } } foreach (XsltItem nc in x.Children) { CapAfterDot(nc); } }
private void cmdAddZero_Click(object sender, EventArgs e) { if (items == null) { return; } XsltItem t; t = new XsltItem(); t.FormInfo = "[пункт «оглавления» Жалобы в колонке слева]"; t.Caption = "Жалобы"; t.FactorInfo = "[ 0..1 ] Заголовок раздела"; t.ItemID = "0"; List <XsltItem> items2 = new List <XsltItem>(); items2.Add(t); foreach (XsltItem t2 in items) { items2.Add(t2); } items = items2; LoadTree(true); }
protected override string HeaderStart(string Caption, XsltItem sX) { string sOut = ""; sOut += "<p><span class='part'>" + Caption + "</span></p>"; return(sOut); }
private void UpLevel(XsltItem x) { x.ItemID = "Up." + x.ItemID; foreach (XsltItem nc in x.Children) { UpLevel(nc); } }
public XsltItem NextSibling() { if (nextSiblingOk) { return(_nextSibling); } _nextSibling = FindNextSibling(); nextSiblingOk = true; return(_nextSibling); }
protected override string ItemEnd(XsltItem sX) { string sOut = @""; if (sX.DotAfter) { sOut += ". "; } return(sOut); }
public XsltItem PrevSibling() { if (prevSiblingOk) { return(_prevSibling); } _prevSibling = FindPrevSibling(); prevSiblingOk = true; return(_prevSibling); }
protected override string HeaderEnd(string Caption, XsltItem sX) { string sOut = @""; if (sX.DotAfter) { sOut += ". "; } //if(sX.NextSibling() != null ) //if(sX.Level()==2) // sOut += "<p class='gap'></p>"; return(sOut); }
protected override string ItemStart(string Caption, XsltItem sX) { string sOut = ""; if (sX.ComaBefore) { sOut += ", "; } if (Caption.Trim() != "") { sOut += @"<span>" + Caption + "-</span>"; } return(sOut); }
private void ClearLastDot(XsltItem x) { XsltItem lc; if (x.Children.Count >= 1 && x.DotAfter == true) { // чтобы не было двух точек, убираем её у последнего дочернего узла lc = x.Children[x.Children.Count - 1]; lc.DotAfter = false; foreach (XsltItem nc in x.Children) { ClearLastDot(nc); } } }
private void ShiftDotToChildren(XsltItem x) { XsltItem lc; if (x.Children.Count >= 1) { x.DotAfter = false; // будем брать точку у последнего сына-дочки //// последний потомок всегда с точкой lc = x.Children[x.Children.Count - 1]; lc.DotAfter = true; foreach (XsltItem nc in x.Children) { ShiftDotToChildren(nc); } } }
private void RenameNode(TreeNode n, XsltItem t) { String Flags = ""; if (t.ComaBefore) { Flags += "Cm"; } if (t.IsTOC()) { Flags += "T"; } if (t.IsHeader()) { Flags += "H"; } if (t.IsBold()) { Flags += "B"; } if (t.IsNewLine()) { Flags += "Lf"; } if (t.Capitalize) { Flags += "^"; } if (t.WithCaption() && t.IsHeader() == false && t.IsTOC() == false && t.IsBoolean() == false) { Flags += "N"; } if (t.IsMulty()) { Flags += "*"; } if (t.DotAfter) { Flags += "Dt"; } n.Text = t.ItemID + " " + Flags + " " + t.Caption; }
private void LeftLevel(XsltItem x) { int idx = x.ItemID.IndexOf('.'); String newID; if (idx >= 0) { newID = x.ItemID.Substring(0, idx) + "_" + x.ItemID.Substring(idx + 1); } else { newID = x.ItemID; } x.ItemID = newID; foreach (XsltItem nc in x.Children) { LeftLevel(nc); } }
private void DropInput(XsltItem x) { List <XsltItem> ToDrop = new List <XsltItem>(); foreach (XsltItem c in x.Children) { if ((c.Caption.ToLower() == "input" || c.Caption.ToLower().Contains("кнопка добавления") || c.Caption.ToLower() == "input_text") && c.Children.Count == 0) { ToDrop.Add(c); } } foreach (XsltItem c in ToDrop) { x.Children.Remove(c); } foreach (XsltItem c in x.Children) { DropInput(c); } }
private void Show_Message(XsltItem sX) { Text = sX.ItemID + " " + sX.Caption; Application.DoEvents(); }
private void AddChildren(TreeNode n, XsltItem t, bool NoChanges) { foreach (XsltItem c in t.Children) { String Flags = ""; if (NoChanges == false) { c.ComaBefore = true; if (c.IsHeader()) { c.ComaBefore = false; c.DotAfter = true; } if (c.IsTOC()) { c.ComaBefore = false; c.DotAfter = true; } } if (c.ComaBefore) { Flags += "Cm"; } if (c.IsTOC()) { Flags += "T"; } if (c.IsHeader()) { Flags += "H"; } if (c.IsBold()) { Flags += "B"; } if (c.IsNewLine()) { Flags += "Lf"; } if (c.Capitalize) { Flags += "^"; } if (c.WithCaption() && c.IsHeader() == false && c.IsTOC() == false && c.IsBoolean() == false) { Flags += "N"; } if (c.IsMulty()) { Flags += "*"; } if (c.DotAfter) { Flags += "Dt"; } TreeNode n2 = new TreeNode(c.ItemID); n2.Text = c.ItemID + " " + Flags + " " + c.Caption; n2.Tag = c; n.Nodes.Add(n2); AddChildren(n2, c, NoChanges); } }
private void cmdRead_Click(object sender, EventArgs e) { if (txtDocx.Text == "") { return; } DocX doc; try { doc = DocX.Load(txtDocx.Text); } catch (System.Exception ex) { txtOut.Text = ex.Message; return; } int tIdx = 0; int rIdx; int cIdx; XsltItem[] Levels = new XsltItem[10]; XsltItem x; foreach (var T in doc.Tables) { items = new List <XsltItem>(); tIdx += 1; //txtOut.Text = txtOut.Text + vbCrLf + "Table begin " + tIdx.ToString(); rIdx = 0; foreach (Row r in T.Rows) { rIdx += 1; // txtOut.Text = txtOut.Text & vbCrLf & "Row begin " & rIdx.ToString() if (rIdx > 1) { cIdx = 0; x = new XsltItem(); foreach (Cell c in r.Cells) { cIdx += 1; if (cIdx == 1) { x.ItemID = c.Xml.Value.Trim(); } if (cIdx == 3) { x.Caption = c.Xml.Value.Trim(); } if (cIdx == 4) { x.FormInfo = c.Xml.Value.Trim(); } if (cIdx == 5) { x.FactorInfo = c.Xml.Value.Trim(); } if (cIdx == 7) { x.Path = c.Xml.Value.Trim(); } if (cIdx > 7) { if (c.Xml.Value.Contains("show-decimals")) { x.FactorInfo += "; show-decimals"; } } } if (x.FormInfo != "-") { Levels[x.Level()] = x; if (x.Level() > 1) { Levels[x.Level() - 1].Children.Add(x); x.Parent = Levels[x.Level() - 1]; } else { items.Add(x); } } } } LoadTree(false); break; } }