B2015-103: indents (strip out rtf indent commands)
B2015-103: indents (handle rtf indent commands) B2015-103: indents (set/clear ribbon button for indents) B2015-103: setup rtf string for indents; display small identifying marks for indents B2015-103: remove page break from ribbon; move indent; support new indent; support for table grid indent B2015-103: Print for new indents in tables B2015-103: Print for new indents in paragraphs
This commit is contained in:
parent
49dcdd4f4a
commit
a58add8937
@ -2357,6 +2357,8 @@ namespace VEPROMS.CSLA.Library
|
||||
//retval = Regex.Replace(retval, @"\\nosupersub ?", "");
|
||||
retval = Regex.Replace(retval, @"\\up[320] ?", "");
|
||||
retval = Regex.Replace(retval, @"\\dn[320] ?", "");
|
||||
retval = Regex.Replace(retval, @"\\li[0-9]* ?", "");
|
||||
retval = Regex.Replace(retval, @"\\fi-[0-9]* ?", "");
|
||||
return retval;
|
||||
}
|
||||
public static string StripLinks(string rtf)
|
||||
|
@ -140,9 +140,9 @@ namespace Volian.Controls.Library
|
||||
string text = prefix + OriginalText + suffix;
|
||||
_MyFormat = itemInfo.ActiveFormat;
|
||||
|
||||
bool tableShouldBeOutlined = (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit) &&
|
||||
(_FieldToEdit == E_FieldToEdit.StepText || _FieldToEdit == E_FieldToEdit.Text) &&
|
||||
(!itemInfo.IsSection && !itemInfo.IsProcedure) && (itemInfo.IsTable || itemInfo.IsFigure);
|
||||
bool tableShouldBeOutlined = false; //(epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit) &&
|
||||
//(_FieldToEdit == E_FieldToEdit.StepText || _FieldToEdit == E_FieldToEdit.Text) &&
|
||||
//(!itemInfo.IsSection && !itemInfo.IsProcedure) && (itemInfo.IsTable || itemInfo.IsFigure);
|
||||
bool wordsShouldBeReplaced = epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit;
|
||||
if (_MyFormat == null)
|
||||
Console.WriteLine(this._MyItemInfo.MyItemInfoUnique);
|
||||
@ -1160,6 +1160,10 @@ namespace Volian.Controls.Library
|
||||
break;
|
||||
case 'l':
|
||||
if (Regex.IsMatch(token, @"^\\line ?$")) return token;
|
||||
if (Regex.IsMatch(token, @"^\\li[-0-9]+ ?$")) return token; // line indent
|
||||
break;
|
||||
case 'f':
|
||||
if (Regex.IsMatch(token, @"^\\fi[-0-9]+ ?$")) return token; // first line indent
|
||||
break;
|
||||
case 'p':
|
||||
if (Regex.IsMatch(token, @"^\\par ?$")) return "\r\n";
|
||||
|
@ -201,11 +201,13 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
MyFlexGrid.Styles["Focus"].ForeColor = MyFlexGrid.Styles["Focus"].BackColor =
|
||||
MyFlexGrid.Styles["Highlight"].ForeColor = MyFlexGrid.Styles["Highlight"].BackColor = Color.SkyBlue;
|
||||
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetRibbonForGridCellIndent();
|
||||
}
|
||||
else
|
||||
{
|
||||
MyFlexGrid.Styles["Focus"].ForeColor = MyFlexGrid.Styles["Highlight"].ForeColor = Color.Black;
|
||||
MyFlexGrid.Styles["Focus"].BackColor = MyFlexGrid.Styles["Highlight"].BackColor = Color.LightCyan;
|
||||
MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetRibbonForGridCellIndentClear();
|
||||
}
|
||||
}
|
||||
private string _OrigRtf; // used to store original rtf to allow for 'escape' key restore
|
||||
|
@ -474,7 +474,7 @@ namespace Volian.Controls.Library
|
||||
RemoveEventHandlers();
|
||||
OnAdjustTableWidth(this, new StepRTBTableWidthEventArgs(false));// View Mode
|
||||
SelectAll();
|
||||
if (SelectionHangingIndent !=0) SelectionHangingIndent = 0;
|
||||
//if (SelectionHangingIndent !=0) SelectionHangingIndent = 0;
|
||||
int indchar = 0;
|
||||
string indentToken = MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IndentToken;
|
||||
if (indentToken == null || indentToken=="0") indentToken = "\x5";
|
||||
@ -958,6 +958,16 @@ namespace Volian.Controls.Library
|
||||
this.ContentsResized -= new ContentsResizedEventHandler(StepRTB_ContentsResized);
|
||||
Text = "";
|
||||
this.ContentsResized += new ContentsResizedEventHandler(StepRTB_ContentsResized);
|
||||
// indents went from being handled by code support of an indent character (usually \05) to
|
||||
// using rtf commands to fix various indent bugs including B2015-103). The following code
|
||||
// puts the rtf indent characters that are stored at beginning of string into correct location
|
||||
// of rtf header (have to be after the \pard). Otherwise the indents did not show up.
|
||||
Match match = Regex.Match(txt,@"\\fi([-0-9]*) ?\\li([0-9]*)");
|
||||
if (match.Success)
|
||||
{
|
||||
string indentStr = @"\fi" + match.Groups[1].Value + @"\li" + match.Groups[2].Value;
|
||||
Rtf = Rtf.Replace(@"\pard", @"\pard" + indentStr);
|
||||
}
|
||||
SelectedRtf = _LastRtf = newRtf;
|
||||
_lastReadOnly = ReadOnly;
|
||||
}
|
||||
@ -976,6 +986,31 @@ namespace Volian.Controls.Library
|
||||
_RtfPrefix = selectedRtfSB.ToString();
|
||||
}
|
||||
}
|
||||
// The following code is used to display the little 'tic' marks to show indenting:
|
||||
private const int WM_PAINT = 15;
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
if (m.Msg == WM_PAINT)
|
||||
{
|
||||
this.Invalidate();
|
||||
base.WndProc(ref m);
|
||||
if ((FieldToEdit == E_FieldToEdit.StepText) && (SelectionHangingIndent > 0 || SelectionIndent > 0) && (ActiveMode || MyItemInfo.IsTable))
|
||||
{
|
||||
using (Graphics g = Graphics.FromHwnd(this.Handle))
|
||||
{
|
||||
int size = 2;
|
||||
g.DrawLine(Pens.DarkBlue, SelectionIndent, 0, SelectionIndent + size, 0);
|
||||
g.DrawLine(Pens.DarkBlue, SelectionIndent, 2 * size, SelectionIndent, 0);
|
||||
g.DrawLine(Pens.DarkBlue, SelectionHangingIndent, Height - 1, SelectionHangingIndent + size, Height - 1);
|
||||
g.DrawLine(Pens.DarkBlue, SelectionHangingIndent, Height - 1 - 2 * size, SelectionHangingIndent, Height - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
}
|
||||
private static void AddFontTable(StringBuilder selectedRtfSB, Font myFont, bool isFixed)
|
||||
{
|
||||
StringBuilder sbbeg = new StringBuilder();
|
||||
|
@ -449,7 +449,7 @@ namespace Volian.Controls.Library
|
||||
bool allow = (_MyStepRTB.TextLength > 0 && (MyEditItem == null || MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit));
|
||||
|
||||
// turn ribbon items on/off base on whether there is text in the edit window
|
||||
rbnSiblings.Enabled = rbnBreaks.Enabled = rbnStepParts.Enabled = allow;
|
||||
rbnSiblings.Enabled = rbnParagraph.Enabled = rbnStepParts.Enabled = allow;
|
||||
// only turn on the Insert Before/After and the CopyStep buttons if on a step part
|
||||
btnInsAftH.Enabled = btnInsBefH.Enabled = btnInsAfter.Enabled = btnInsBefore.Enabled = btnCpyStp.Enabled =
|
||||
allow && !(MyItemInfo.IsProcedure || MyItemInfo.IsSection || MyItemInfo.IsFigure || MyItemInfo.IsTable || MyItemInfo.IsRNOPart);
|
||||
@ -1118,6 +1118,8 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
btnInsPgBrk.Enabled = MyItemInfo.IsHigh;
|
||||
btnPageBreak.Enabled = MyItemInfo.IsHigh; // edit context menu
|
||||
|
||||
btnIndent.Checked = (_MyStepRTB.EditMode && _MyStepRTB.SelectionHangingIndent != 0);
|
||||
btnEditMode.Checked = btnCMEditMode1.Checked = MyEditItem.MyStepPanel.VwMode == E_ViewMode.View;
|
||||
// if on procedure, 'Delete' buttons should be disabled.
|
||||
btnDelelete.Enabled = btnDelStep.Enabled = !MyItemInfo.IsProcedure;
|
||||
@ -1493,12 +1495,22 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private void btnIndent_Click(object sender, EventArgs e)
|
||||
{
|
||||
StartGridEditing(SelectionOption.Start);
|
||||
_MyStepRTB.InsertIndent(MyEditItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IndentToken);
|
||||
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) return;
|
||||
// For now, use the button as a toggle, i.e. if indent is on - turn it off. If indent is off, use the current cursor location to
|
||||
// turn it on. Later, we may want to allow for multiple indents using the DisplayTags panel.
|
||||
if (_MyStepRTB.SelectionHangingIndent != 0)
|
||||
_MyStepRTB.SelectionHangingIndent = 0;
|
||||
else
|
||||
_MyStepRTB.SelectionHangingIndent = _MyStepRTB.GetPositionFromCharIndex(_MyStepRTB.SelectionStart).X;
|
||||
btnIndent.Checked = _MyStepRTB.SelectionHangingIndent != 0;
|
||||
}
|
||||
private void btnCMIndent_Click(object sender, EventArgs e)
|
||||
{
|
||||
_MyStepRTB.InsertIndent(MyEditItem.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IndentToken);
|
||||
if (_MyStepRTB.SelectionHangingIndent != 0)
|
||||
_MyStepRTB.SelectionHangingIndent = 0;
|
||||
else
|
||||
_MyStepRTB.SelectionHangingIndent = _MyStepRTB.GetPositionFromCharIndex(_MyStepRTB.SelectionStart).X;
|
||||
btnIndent.Checked = _MyStepRTB.SelectionHangingIndent != 0;
|
||||
}
|
||||
#endregion
|
||||
#region Home Tab
|
||||
@ -2841,6 +2853,15 @@ namespace Volian.Controls.Library
|
||||
btnTblDgnPaste.Enabled = ((VlnFlexGrid.MyCopyInfo.MyCopiedFlexGrid != null) && enable);
|
||||
btnTblDgnSplitCells.Enabled = enable;
|
||||
}
|
||||
public void SetRibbonForGridCellIndent()
|
||||
{
|
||||
if (_MyStepRTB != null)
|
||||
btnIndent.Checked = _MyStepRTB.SelectionHangingIndent != 0;
|
||||
}
|
||||
public void SetRibbonForGridCellIndentClear()
|
||||
{
|
||||
btnIndent.Checked = false;
|
||||
}
|
||||
public void SetRibbonForGrid()
|
||||
{
|
||||
// for paste, see if there is clipboard data, & if so, of a type we can use.
|
||||
|
BIN
PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs
generated
BIN
PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs
generated
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@ using Volian.Controls.Library;
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.pdf;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Volian.Print.Library
|
||||
{
|
||||
@ -433,7 +433,16 @@ namespace Volian.Print.Library
|
||||
myPara.IndentationLeft = chkW;
|
||||
myPara.FirstLineIndent = -chkW;
|
||||
}
|
||||
|
||||
Match match = Regex.Match(str, @"\\fi([-0-9]*) ?\\li([0-9]*)");
|
||||
if (match.Success)
|
||||
{
|
||||
float fi = float.Parse(match.Groups[1].Value) / 20; // 72 is dots per inch & 96 is standard DPI (120 is KBR's machine)
|
||||
float li = float.Parse(match.Groups[2].Value) / 20;
|
||||
// if there is a hanging indent, the iTextSharp paragraph properties must be set
|
||||
// to print the indent.
|
||||
myPara.IndentationLeft = li;
|
||||
myPara.FirstLineIndent = fi;
|
||||
}
|
||||
// RHM 20120925 - Line spacing should be 6 lines per inch. In order to get a valid value
|
||||
// for TotalLeading you have to set MultipliedLeading first:
|
||||
myPara.MultipliedLeading = 1.0f;
|
||||
@ -617,15 +626,19 @@ namespace Volian.Print.Library
|
||||
// but the text in that table cell will not be indented. - jsj 10/10/2014
|
||||
//IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 "));
|
||||
IRtfDocument rtfDoc2 = null;
|
||||
if (rtf.Contains(@"\f1\fnil\fcharset0 "))
|
||||
rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 "));
|
||||
else
|
||||
return 0; //rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", ""));
|
||||
//if (rtf.Contains(@"\f1\fnil\fcharset0 "))
|
||||
// rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 "));
|
||||
//else
|
||||
//{
|
||||
// first add the symbol font and then surround the indent as above.
|
||||
rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\par\u9999?\par"));
|
||||
//}
|
||||
|
||||
Rtf2iTextSharp rtf2IText2 = new Rtf2iTextSharp(rtfDoc2);
|
||||
iTextSharp.text.Paragraph para2 = rtf2IText2.Convert();
|
||||
foreach (Chunk chk in para2.Chunks)
|
||||
for (int ic = 0; ic < para2.Chunks.Count; ic++)
|
||||
{
|
||||
Chunk chk = para2.Chunks[ic] as Chunk;
|
||||
if (chk.Content[0] == 9999) break;
|
||||
if (chk.Content.Contains("\u270f"))
|
||||
{
|
||||
@ -634,7 +647,11 @@ namespace Volian.Print.Library
|
||||
chkW += chk.GetWidthPoint() * i / (n - i);
|
||||
break;
|
||||
}
|
||||
if (chk.Content.Contains("\n")) chkW = 0; //hard return - reset chkW (indent start)
|
||||
if (chk.Content.Contains("\n"))
|
||||
{
|
||||
if (ic < para2.Chunks.Count - 2 && (para2.Chunks[ic + 1] as Chunk).Content.StartsWith("\u270f")) return chkW;
|
||||
chkW = 0; //hard return - reset chkW (indent start)
|
||||
}
|
||||
chkW += chk.GetWidthPoint();
|
||||
}
|
||||
return chkW;
|
||||
|
@ -11,6 +11,7 @@ using Itenso.Rtf.Support;
|
||||
using Volian.Controls.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
using Volian.Base.Library;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Volian.Print.Library
|
||||
{
|
||||
@ -392,7 +393,7 @@ namespace Volian.Print.Library
|
||||
rtf2IText.HasIndent = hasIndent;
|
||||
iTextSharp.text.Paragraph para = rtf2IText.Convert();
|
||||
para.SetLeading(_SixLinesPerInch, 0);
|
||||
if (rtf.Contains("\x05"))
|
||||
if (rtf.Contains("\x05")) // note that this is for existing customer data as of August 2015.
|
||||
{
|
||||
// if there is a hanging indent, the iTextSharp paragraph properties must be set
|
||||
// to print the indent. Replace the indent 'token' with a non-used symbol, this will
|
||||
@ -406,6 +407,16 @@ namespace Volian.Print.Library
|
||||
para.IndentationLeft = chkW;
|
||||
para.FirstLineIndent = -chkW;
|
||||
}
|
||||
Match match = Regex.Match(rtf, @"\\fi([-0-9]*) ?\\li([0-9]*)");
|
||||
if (match.Success)
|
||||
{
|
||||
float fi = float.Parse(match.Groups[1].Value) / 20;
|
||||
float li = float.Parse(match.Groups[2].Value) / 20;
|
||||
// if there is a hanging indent, the iTextSharp paragraph properties must be set
|
||||
// to print the indent.
|
||||
para.IndentationLeft = li;
|
||||
para.FirstLineIndent = fi;
|
||||
}
|
||||
// Change the chunks to only split on spaces rather than spaces and hyphens
|
||||
foreach (Chunk chk in para)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user