Command Line switch to skip ReplaceWords function (Edit and Print)
Added Hanging Indent Logic for Grids.
This commit is contained in:
parent
d8b0f21619
commit
cb355b71aa
@ -1706,8 +1706,27 @@ namespace Volian.Controls.Library
|
|||||||
//}
|
//}
|
||||||
#endregion
|
#endregion
|
||||||
private Dictionary<ReplaceStr, Regex> dicReplaceRegex = new Dictionary<ReplaceStr, Regex>();
|
private Dictionary<ReplaceStr, Regex> dicReplaceRegex = new Dictionary<ReplaceStr, Regex>();
|
||||||
|
private static bool? _ProcessReplaceWords;
|
||||||
|
public static bool ProcessReplaceWords
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_ProcessReplaceWords == null)
|
||||||
|
{
|
||||||
|
string[] parameters = System.Environment.CommandLine.Split(" ".ToCharArray());
|
||||||
|
_ProcessReplaceWords = true;
|
||||||
|
foreach (string parameter in parameters)
|
||||||
|
{
|
||||||
|
if (parameter.ToUpper() == "/NRW")
|
||||||
|
_ProcessReplaceWords = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (bool) _ProcessReplaceWords;
|
||||||
|
}
|
||||||
|
}
|
||||||
private string DoReplaceWords2(string Text)
|
private string DoReplaceWords2(string Text)
|
||||||
{
|
{
|
||||||
|
if(!ProcessReplaceWords) return Text;
|
||||||
if (_MyItemInfo.MyContent.Type < 20000) return Text; // for now only replace in steps.
|
if (_MyItemInfo.MyContent.Type < 20000) return Text; // for now only replace in steps.
|
||||||
FoundMatches myMatches = new FoundMatches(Text,_MyItemInfo.FormatStepData.Font,_MyItemInfo);
|
FoundMatches myMatches = new FoundMatches(Text,_MyItemInfo.FormatStepData.Font,_MyItemInfo);
|
||||||
// Exclude Link Text from Replace Word process
|
// Exclude Link Text from Replace Word process
|
||||||
|
@ -9,6 +9,7 @@ using Itenso.Rtf.Interpreter;
|
|||||||
using Itenso.Rtf.Support;
|
using Itenso.Rtf.Support;
|
||||||
using Volian.Print.Library;
|
using Volian.Print.Library;
|
||||||
using Volian.Controls.Library;
|
using Volian.Controls.Library;
|
||||||
|
using iTextSharp.text;
|
||||||
using iTextSharp.text.pdf;
|
using iTextSharp.text.pdf;
|
||||||
|
|
||||||
|
|
||||||
@ -212,6 +213,20 @@ namespace Volian.Print.Library
|
|||||||
str = PreProcessRTF(w, str);
|
str = PreProcessRTF(w, str);
|
||||||
iTextSharp.text.Paragraph myPara = RtfToParagraph(str);
|
iTextSharp.text.Paragraph myPara = RtfToParagraph(str);
|
||||||
myColumnText1.SetSimpleColumn(0, 0, w - 2, MyContentByte.PdfDocument.PageSize.Top); // Padding = 4
|
myColumnText1.SetSimpleColumn(0, 0, w - 2, MyContentByte.PdfDocument.PageSize.Top); // Padding = 4
|
||||||
|
if (str.Contains(@"\'05"))
|
||||||
|
{
|
||||||
|
// 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
|
||||||
|
// create a chunk with that symbol. Then loop through all of the chunks until we find
|
||||||
|
// this symbol, adding up the widths to that point. This width is the value that
|
||||||
|
// needs to be used to set the indent.
|
||||||
|
// Notes:
|
||||||
|
// A hard return will reset the chkW (indent width) back to zero.
|
||||||
|
// We jump out of the processing loop after the first indent token is found and ignor any other ones
|
||||||
|
float chkW = CalculateHangingIndent(str);
|
||||||
|
myPara.IndentationLeft = chkW;
|
||||||
|
myPara.FirstLineIndent = -chkW;
|
||||||
|
}
|
||||||
|
|
||||||
// RHM 20120925 - Line spacing should be 6 lines per inch. In order to get a valid value
|
// 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:
|
// for TotalLeading you have to set MultipliedLeading first:
|
||||||
@ -234,6 +249,28 @@ namespace Volian.Print.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static float CalculateHangingIndent(string rtf)
|
||||||
|
{
|
||||||
|
float chkW = 0;
|
||||||
|
IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 "));
|
||||||
|
Rtf2iTextSharp rtf2IText2 = new Rtf2iTextSharp(rtfDoc2);
|
||||||
|
iTextSharp.text.Paragraph para2 = rtf2IText2.Convert();
|
||||||
|
foreach (Chunk chk in para2.Chunks)
|
||||||
|
{
|
||||||
|
if (chk.Content[0] == 9999) break;
|
||||||
|
if (chk.Content.Contains("\u270f"))
|
||||||
|
{
|
||||||
|
int i = chk.Content.IndexOf('\u270F');
|
||||||
|
int n = chk.Content.Length;
|
||||||
|
chkW += chk.GetWidthPoint() * i / (n - i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (chk.Content.Contains("\n")) chkW = 0; //hard return - reset chkW (indent start)
|
||||||
|
chkW += chk.GetWidthPoint();
|
||||||
|
}
|
||||||
|
return chkW;
|
||||||
|
}
|
||||||
|
|
||||||
private static StepRTB _StatRTB = new StepRTB();
|
private static StepRTB _StatRTB = new StepRTB();
|
||||||
private string PreProcessRTF(float w, string str)
|
private string PreProcessRTF(float w, string str)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user