This commit is contained in:
parent
9d2f4faa33
commit
089c50befa
@ -819,4 +819,15 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
[Flags]
|
||||
public enum E_ROValueType : uint
|
||||
{
|
||||
All = 0,
|
||||
Text = 1,
|
||||
Table = 2,
|
||||
Graph = 4,
|
||||
Image = 8,
|
||||
Video = 16,
|
||||
Hologram = 32
|
||||
}
|
||||
}
|
||||
|
@ -132,12 +132,15 @@ namespace VEPROMS.CSLA.Library
|
||||
while (_CacheList.Count > 0) // Move Content(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||
{
|
||||
Content tmp = _CacheList[0]; // Get the first Content
|
||||
if (!tmp.Disposed)
|
||||
{
|
||||
string pKey = tmp.ContentID.ToString();
|
||||
if (!_CacheByPrimaryKey.ContainsKey(pKey))
|
||||
{
|
||||
_CacheByPrimaryKey[pKey] = new List<Content>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
|
||||
}
|
||||
_CacheList.RemoveAt(0); // Remove the first Content
|
||||
}
|
||||
}
|
||||
@ -842,6 +845,13 @@ namespace VEPROMS.CSLA.Library
|
||||
{/* require use of factory methods */
|
||||
AddToCache(this);
|
||||
}
|
||||
private bool _Disposed = false;
|
||||
|
||||
public bool Disposed
|
||||
{
|
||||
get { return _Disposed; }
|
||||
set { _Disposed = value; }
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
if (_MyGrid != null)
|
||||
@ -849,6 +859,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_MyGrid.Dispose();
|
||||
_MyGrid = null;
|
||||
}
|
||||
Disposed = true;
|
||||
RemoveFromDictionaries();
|
||||
}
|
||||
private void RemoveFromDictionaries()
|
||||
|
@ -235,7 +235,7 @@ namespace Volian.Controls.Library
|
||||
AddFontTable(selectedRtfSB, FormatFont, FontIsFixed(FormatFont));
|
||||
_RtfPrefix = selectedRtfSB.ToString();
|
||||
}
|
||||
return _RtfPrefix;
|
||||
return _RtfPrefix;// +@"{\colortbl ;\red255\green0\blue0;}";
|
||||
}
|
||||
}
|
||||
// August 5, 2009 - KBR & RHM:
|
||||
@ -1034,6 +1034,19 @@ namespace Volian.Controls.Library
|
||||
private int Ceiling(float f)
|
||||
{
|
||||
return (int)(Math.Ceiling(f));
|
||||
}
|
||||
public int MaxTextWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
int maxWidth = 0;
|
||||
for (int i = 0; i < TextLength; i++)
|
||||
{
|
||||
int w = GetPositionFromCharIndex(i).X;
|
||||
maxWidth = Math.Max(maxWidth, w);
|
||||
}
|
||||
return maxWidth+10; // add 10 to account for the last character
|
||||
}
|
||||
}
|
||||
public void AdjustWidthForContent()
|
||||
{
|
||||
|
@ -12,6 +12,7 @@ using System.IO;
|
||||
using Volian.Controls.Library;
|
||||
using VEPROMS.CSLA.Library;
|
||||
using C1.Win.C1FlexGrid;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Volian.Controls.Library
|
||||
{
|
||||
@ -161,10 +162,19 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
return height;
|
||||
}
|
||||
private int GetCellWidth(int row, int col)
|
||||
{
|
||||
int width = 0;
|
||||
CellRange cr = GetMergedRange(row, col);
|
||||
for (int c = cr.c1; c <= cr.c2; c++)
|
||||
{
|
||||
width += (Cols[c].Width == -1) ? Cols.DefaultSize - 3 : Cols[c].Width -3;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
private int BlankRowSpace()
|
||||
{
|
||||
int curRowHeight = (Rows[Row].Height == -1) ? Rows.DefaultSize - 3 : Rows[Row].Height - 3;
|
||||
int curRowHeightNLines = curRowHeight / (Rows.DefaultSize - 3);
|
||||
if (curRowHeight <= (Rows.DefaultSize - 3)) return 0; // never have row less than default height
|
||||
int blankRowSpace = curRowHeight;
|
||||
for (int c = 0; c < Cols.Count; c++)
|
||||
@ -173,7 +183,6 @@ namespace Volian.Controls.Library
|
||||
if (Row >= cr.r1 && Row <= cr.r2)
|
||||
{
|
||||
int cellHeight = GetCellHeight(Row, c);
|
||||
//int mergeCellHeightNLines = cellHeight / (Rows.DefaultSize - 3);
|
||||
int dataHeight = (cr.UserData == null) ? cellHeight : (int)cr.UserData;
|
||||
int ud = dataHeight / (Rows.DefaultSize - 3);
|
||||
//if (cellHeight < dataHeight)
|
||||
@ -184,6 +193,33 @@ namespace Volian.Controls.Library
|
||||
//Console.WriteLine("BlankRowSpace {0}", blankRowSpace);
|
||||
return blankRowSpace;
|
||||
}
|
||||
private int BlankColSpace()
|
||||
{
|
||||
int curColWidth = (Cols[Col].Width == -1) ? Cols.DefaultSize - 3 : Cols[Col].Width - 3;
|
||||
//int curRowHeightNLines = curRowHeight / (Rows.DefaultSize - 3);
|
||||
if (curColWidth <= Cols.DefaultSize - 3) return 0; // never have col less than default width
|
||||
int blankColSpace = curColWidth;
|
||||
for (int r = 0; r < Rows.Count; r++)
|
||||
{
|
||||
StepRTB srtb = new StepRTB();
|
||||
CellRange cr = GetMergedRange(r, Col);
|
||||
srtb.Rtf = GetCellRTFString(cr.r1,cr.c1);
|
||||
if (Col >= cr.c1 && Col <= cr.c2)
|
||||
{
|
||||
int cellWidth = GetCellWidth(r, Col);
|
||||
srtb.Width = cellWidth;
|
||||
Application.DoEvents();
|
||||
//int mergeCellHeightNLines = cellHeight / (Rows.DefaultSize - 3);
|
||||
//int dataHeight = (cr.UserData == null) ? cellHeight : (int)cr.UserData;
|
||||
//int ud = dataHeight / (Rows.DefaultSize - 3);
|
||||
//if (cellHeight < dataHeight)
|
||||
// Console.WriteLine("r {0}, c {1}, cell{2}, data{3}", Row, c, cellHeight, dataHeight);
|
||||
blankColSpace = Math.Min(blankColSpace, Math.Max(0, cellWidth - srtb.MaxTextWidth));
|
||||
}
|
||||
}
|
||||
//Console.WriteLine("BlankRowSpace {0}", blankRowSpace);
|
||||
return blankColSpace;
|
||||
}
|
||||
//private bool CanReduceRow()
|
||||
//{
|
||||
// int curRowHeight = (Rows[Row].Height == -1) ? Rows.DefaultSize - 3 : Rows[Row].Height -3;
|
||||
@ -650,7 +686,7 @@ namespace Volian.Controls.Library
|
||||
//this.Refresh();
|
||||
}
|
||||
|
||||
public void AdjustGridHeightWidth(int r, int c)
|
||||
public void ConvertTextCellToRTF(int r, int c)
|
||||
{
|
||||
StepRTB trtb = new StepRTB();
|
||||
string tstr = null;
|
||||
@ -660,32 +696,29 @@ namespace Volian.Controls.Library
|
||||
trtb.Clear();
|
||||
tstr = (string)this[r, c];
|
||||
trtb.Font = this.Font;
|
||||
//trtb.Rtf = trtb.RtfPrefixForSymbols;
|
||||
if (tstr != null && tstr.Length > 0)
|
||||
{
|
||||
string tsave = tstr;
|
||||
if (tstr.StartsWith(@"{\rtf"))
|
||||
trtb.Rtf = tstr; // already RTF text
|
||||
else
|
||||
trtb.Text = tstr; // this will convert regular text to RTF text
|
||||
//if (trtb.Rtf.Contains("SimSun"))
|
||||
// Console.WriteLine("here's SimSun! :-)");
|
||||
// regular text has special characters to toggle Bold, Underline, and Italics
|
||||
// we need to subtract the width of these characters (allow column/row to shrink)
|
||||
AllowWidthShrink = RemoveBoldUlineItalicChars(trtb.Rtf);
|
||||
|
||||
//AllowWidthShrink = RemoveBoldUlineItalicChars(trtb.Rtf);
|
||||
AllowWidthShrink = tstr.Contains("#Link:");
|
||||
// this will convert the special characters for Bold, Underline, and Italics
|
||||
// into RTF commands
|
||||
//VE_Font vf = new VE_Font(this.Font.FontFamily.Name, (int)this.Font.Size, E_Style.None);
|
||||
trtb.Rtf = trtb.RtfPrefix + ConvertTableText(trtb.Rtf) + "}";
|
||||
string fromRTF = trtb.Rtf;
|
||||
trtb.Rtf = trtb.RtfPrefix + ConvertTableText(tstr) + "}";
|
||||
string fromStr = trtb.Rtf;
|
||||
if (fromRTF.Contains("SimSun"))
|
||||
Console.WriteLine("SimSun");
|
||||
else
|
||||
Compare(fromRTF, fromStr, tsave);
|
||||
//ConvertTableText(trtb);
|
||||
//trtb.Rtf = trtb.RtfPrefix + ConvertTableText(trtb.Rtf) + "}";
|
||||
//string fromRTF = trtb.Rtf;
|
||||
//string prefix = trtb.RtfPrefix;
|
||||
//if (tstr.Contains("#Link:")) prefix += @"{\colortbl ;\red255\green0\blue0;}";
|
||||
//if (tstr.Contains("#Link:"))
|
||||
// Console.WriteLine("here");
|
||||
//string jText = trtb.RtfPrefix + ConvertTableText(tstr) + @"\par}";
|
||||
//trtb.Rtf = jText;
|
||||
trtb.Rtf = trtb.RtfPrefix + ConvertTableText(tstr) + @"\par}";
|
||||
//string fromStr = trtb.Rtf;
|
||||
//if (fromRTF.Contains("SimSun"))
|
||||
// Console.WriteLine("SimSun");
|
||||
//else
|
||||
// Compare(fromRTF, fromStr, tsave);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -703,7 +736,6 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
|
||||
this[r, c] = trtb.Rtf; // save the cleaned up and processed cell text as RTF
|
||||
|
||||
this.Select(r, c, false);
|
||||
CellRange sel = this.Selection;
|
||||
//sel.UserData = trtb.ContentsRectangle.Height;
|
||||
@ -777,6 +809,74 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
//private void AdjustCellHeightWidth(int r, int c, StepRTB trtb)
|
||||
//{
|
||||
// this.Select(r, c, false);
|
||||
// CellRange sel = this.Selection;
|
||||
// //sel.UserData = trtb.ContentsRectangle.Height;
|
||||
|
||||
// // Now see the the selected row,col is in the defined merge ranges
|
||||
// bool mrgrows = false;
|
||||
// bool mrgcols = false;
|
||||
// foreach (CellRange cr in this.MergedRanges)
|
||||
// {
|
||||
// if (cr.Contains(r, c))
|
||||
// {
|
||||
// if (cr.c1 != cr.c2)
|
||||
// mrgcols = true; // in a range of merged columns
|
||||
// if (cr.r1 != cr.r2)
|
||||
// mrgrows = true; // in a range of merged rows
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// if (!mrgcols || !mrgrows)
|
||||
// {
|
||||
// // IF the row of the selected cell is NOT in merged range
|
||||
// // then go ahead and adjust the row height (if needed)
|
||||
// if (!mrgrows)
|
||||
// {
|
||||
// // add adjustment for grid and cell borders
|
||||
// int newheight = trtb.Height + 3;
|
||||
|
||||
// //if (newheight > this.Rows[r].Height)
|
||||
// //{
|
||||
// this.Rows[r].Height = newheight;
|
||||
// //}
|
||||
// }
|
||||
// // IF the column of the selected cell is NOT in merged range
|
||||
// // then go ahead and adjust the column width (if needed)
|
||||
// if (!mrgcols)
|
||||
// {
|
||||
// // add adjustment for grid and cell borders
|
||||
// int newwidth = trtb.Width + 2;
|
||||
|
||||
// //if (newwidth > this.Cols[c].Width || AllowWidthShrink || r == 0)
|
||||
// this.Cols[c].Width = newwidth;
|
||||
// }
|
||||
// }
|
||||
// if (mrgrows && tstr != null)
|
||||
// {
|
||||
// CellRange cr = GetMergedRange(r, c);
|
||||
// if (cr.r1 == r && cr.c1 == c)
|
||||
// {
|
||||
// // if in merged rows, then make sure the cell's height is large enough
|
||||
// string[] strary = tstr.Split("\n".ToCharArray());
|
||||
// // count number of lines of text
|
||||
// int nlines = strary.Length;
|
||||
// // count number of rows in merge range
|
||||
// int nrows = (cr.r2 - cr.r1) + 1;
|
||||
// while (nlines > nrows)
|
||||
// {
|
||||
// // add length to first row in merged range
|
||||
// int h = this.Rows[cr.r1].Height;
|
||||
// int defH = Rows.DefaultSize - 3;
|
||||
// h = (h == -1) ? (defH * 2) + 3 : h + defH;
|
||||
// this.Rows[cr.r1].Height = h;
|
||||
// nrows++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
private void Compare(string fromRTF, string fromStr, string rawstr)
|
||||
{
|
||||
@ -797,7 +897,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
Console.WriteLine("fromStr:\r\n'{0}'\r\nfromRTF:\r\n'{1}'", fromStr, fromRTF);
|
||||
ShowRawString(rawstr, "rawstr");
|
||||
//Console.WriteLine("Str:'{0}' , RTF:'{1}'", fromStr.Substring(j, 10), fromRTF.Substring(i, 10));
|
||||
Console.WriteLine("Str:'{0}' , RTF:'{1}'", fromStr.Substring(j, Math.Min(10,fromStr.Length-j-1)), fromRTF.Substring(i, Math.Min(10,fromRTF.Length-i-1)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -836,51 +936,121 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
this.Rows[r].Height = Rows.DefaultSize;//_minRowHeight;//20;//10;
|
||||
for (int c = 0; c < this.Cols.Count; c++)
|
||||
this.AdjustGridHeightWidth(r, c);
|
||||
this.ConvertTextCellToRTF(r, c);
|
||||
}
|
||||
//this.Refresh();
|
||||
//Application.DoEvents();
|
||||
this.AdjustGridControlSize();
|
||||
SetupCellUserData();
|
||||
//RemoveBlankSpaceFromColumns();
|
||||
RemoveBlankSpaceFromRows();
|
||||
}
|
||||
|
||||
private bool RemoveBoldUlineItalicChars(string str)
|
||||
public void FixTableCellsHeightWidth()
|
||||
{
|
||||
int rtn = 0;
|
||||
|
||||
// Underline next word
|
||||
rtn += str.IndexOf(@"\'17");
|
||||
|
||||
// Bold next word
|
||||
rtn += str.IndexOf(@"\'13");
|
||||
|
||||
// Italics On
|
||||
rtn += str.IndexOf(@"\'1B4");
|
||||
|
||||
// Italics Off
|
||||
rtn += str.IndexOf(@"\'1B5");
|
||||
|
||||
// underline On
|
||||
rtn += str.IndexOf(@"\'ab");
|
||||
// underline Off
|
||||
rtn += str.IndexOf(@"\'bb");
|
||||
|
||||
return rtn > 0;
|
||||
|
||||
//StepRTB trtb = new StepRTB();
|
||||
////trtb.SetTableGridCellRTFPrefix(this.Font);
|
||||
//trtb.Font = this.Font;
|
||||
//// This will spin through all the cells in the grid:
|
||||
//// - adjust the grid dimensions based on the cell info.
|
||||
//for (int r = 0; r < this.Rows.Count; r++)
|
||||
//{
|
||||
// this.Rows[r].Height = Rows.DefaultSize;//_minRowHeight;//20;//10;
|
||||
// for (int c = 0; c < this.Cols.Count; c++)
|
||||
// {
|
||||
// trtb.Clear();
|
||||
// trtb.Rtf = (string)this[r, c];
|
||||
// this.AdjustCellHeightWidth(r, c, trtb);
|
||||
// }
|
||||
//}
|
||||
//this.AdjustGridControlSize();
|
||||
//SetupCellUserData();
|
||||
RemoveBlankSpaceFromColumns();
|
||||
RemoveBlankSpaceFromRows();
|
||||
}
|
||||
|
||||
private void RemoveBlankSpaceFromRows()
|
||||
{
|
||||
for (int r = 0; r < Rows.Count; r++)
|
||||
{
|
||||
Select(r, 0);
|
||||
int blankRowSpace = BlankRowSpace();
|
||||
if (blankRowSpace > 0)
|
||||
Rows[r].Height -= blankRowSpace;
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveBlankSpaceFromColumns()
|
||||
{
|
||||
for (int c = 0; c < Cols.Count; c++)
|
||||
{
|
||||
Select(0, c);
|
||||
int blankColSpace = BlankColSpace();
|
||||
if (blankColSpace > 0)
|
||||
Cols[c].Width -= blankColSpace;
|
||||
}
|
||||
}
|
||||
|
||||
//private bool RemoveBoldUlineItalicChars(string str)
|
||||
//{
|
||||
// int rtn = 0;
|
||||
|
||||
// // Underline next word
|
||||
// rtn += str.IndexOf(@"\'17");
|
||||
|
||||
// // Bold next word
|
||||
// rtn += str.IndexOf(@"\'13");
|
||||
|
||||
// // Italics On
|
||||
// rtn += str.IndexOf(@"\'1B4");
|
||||
|
||||
// // Italics Off
|
||||
// rtn += str.IndexOf(@"\'1B5");
|
||||
|
||||
// // underline On
|
||||
// rtn += str.IndexOf(@"\'ab");
|
||||
// // underline Off
|
||||
// rtn += str.IndexOf(@"\'bb");
|
||||
|
||||
// return rtn > 0;
|
||||
|
||||
//}
|
||||
|
||||
//private string ConvertTableText(string str, VE_Font vf)
|
||||
private string ConvertTableText(string str)
|
||||
{
|
||||
string rtn = str;
|
||||
//ShowRawString(str, "ConvertTableText IN");
|
||||
if (!str.StartsWith(@"{\rtf"))
|
||||
{
|
||||
//if (!str.StartsWith(@"{\rtf"))
|
||||
//{
|
||||
rtn = rtn.Replace(@"START]\v0", @"START]\cf1\v0");
|
||||
rtn = rtn.Replace(@"\v #Link:", @"\cf0\v #Link:");
|
||||
rtn = rtn.Replace("\n", "\\par\r\n");
|
||||
rtn = rtn.Replace("\xB3", @"\f1\u9474?\f0"); // Vert Bar
|
||||
rtn = rtn.Replace("\xF2", @"\f1\u8805?\f0 "); // greater than or equal
|
||||
rtn = rtn.Replace("\x7F", @"\f1\u916?\f0 "); // delta
|
||||
if (rtn.Contains("\xFF"))
|
||||
rtn = rtn.Replace("\xFF", @"\u160?");
|
||||
rtn = rtn.Replace("\xF3", @"\f1\u8804?\f0 "); // less than or equal
|
||||
rtn = rtn.Replace("\xE4", @"\f1\u931?\f0 "); // sigma
|
||||
rtn = rtn.Replace("\xE7", @"\f1\u947?\f0 "); // gamma
|
||||
rtn = rtn.Replace("\xFE", @"\f1\u9604?\f0 "); // accum 2584
|
||||
rtn = rtn.Replace("\x7", @"\f1\u9679?\f0 "); // bullet 25CF
|
||||
rtn = rtn.Replace("\xF7", @"\f1\u8776?\f0 "); // approx eq
|
||||
rtn = rtn.Replace("\xF0", @"\f1\u8773?\f0 "); // similar eq 2245
|
||||
rtn = rtn.Replace("\xFB", @"\f1\u8730?\f0 "); // square root
|
||||
rtn = rtn.Replace("\xE2", @"\f1\u961?\f0 "); // rho 3C1
|
||||
rtn = rtn.Replace("\xE3", @"\f1\u960?\f0 "); // pi
|
||||
rtn = rtn.Replace("\xE6", @"\f1\u956?\f0 "); // micro
|
||||
rtn = rtn.Replace("\xEB", @"\f1\u948?\f0 "); // lower case delta
|
||||
rtn = rtn.Replace("\xE5", @"\f1\u963?\f0 "); // lower case sigma
|
||||
rtn = rtn.Replace("\x90", @"\f1\u274?\f0 "); // energy, 112
|
||||
rtn = rtn.Replace("\xEE", @"\f1\u949?\f0 "); // epsilon
|
||||
rtn = rtn.Replace("\xE9", @"\f1\u952?\f0 "); // theta, 3B8
|
||||
rtn = rtn.Replace("\xEC", @"\f1\u8857?\f0 "); // dot in oval, 2299
|
||||
rtn = rtn.Replace("\xA8", @"\f1\u964?\f0 "); // tau, 3C4
|
||||
rtn = rtn.Replace("\xA9", @"\f1\u9830?\f0 "); // diamond, 2666
|
||||
rtn = rtn.Replace("\x18", @"\f1\u8593?\f0 "); // Up Arrow
|
||||
rtn = rtn.Replace("\x19", @"\f1\u8595?\f0 "); // Down Arrow
|
||||
rtn = rtn.Replace("\xFF", @"\u160?"); // hardspace
|
||||
//rtn = rtn.Replace(@"\'a0", @"\u160?");
|
||||
//rtn = rtn.Replace("\xff", @"\u160?");
|
||||
//rtn = rtn.Replace("\xA0", @"\u160?");
|
||||
@ -896,41 +1066,41 @@ namespace Volian.Controls.Library
|
||||
rtn = rtn.Replace("}", @"\}");
|
||||
rtn = rtn.Replace("\xd5", @"\b");
|
||||
rtn = rtn.Replace("\xd6", @"\b0");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Underline next word
|
||||
rtn = SomethingNextWord(rtn, @"\'17", @"\ul ", @"\ulnone ");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// // Underline next word
|
||||
// rtn = SomethingNextWord(rtn, @"\'17", @"\ul ", @"\ulnone ");
|
||||
|
||||
// Bold next word
|
||||
rtn = SomethingNextWord(rtn, @"\'13", @"\b ", @"\b0 ");
|
||||
// // Bold next word
|
||||
// rtn = SomethingNextWord(rtn, @"\'13", @"\b ", @"\b0 ");
|
||||
|
||||
// Italics On
|
||||
rtn = rtn.Replace(@"\'1B4", @"\i ");
|
||||
// // Italics On
|
||||
// rtn = rtn.Replace(@"\'1B4", @"\i ");
|
||||
|
||||
// Italics Off
|
||||
rtn = rtn.Replace(@"\'1B5", @"\i0 ");
|
||||
// // Italics Off
|
||||
// rtn = rtn.Replace(@"\'1B5", @"\i0 ");
|
||||
|
||||
// underline On
|
||||
rtn = rtn.Replace(@"\'ab", @"\ul");
|
||||
// underline Off
|
||||
rtn = rtn.Replace(@"\'bb", @"\ulnone");
|
||||
// // underline On
|
||||
// rtn = rtn.Replace(@"\'ab", @"\ul");
|
||||
// // underline Off
|
||||
// rtn = rtn.Replace(@"\'bb", @"\ulnone");
|
||||
|
||||
rtn = rtn.Replace(@"\'ef\'e6", @"\up2 ");
|
||||
rtn = rtn.Replace(@"\'ef\'e7", @"\up0 ");
|
||||
rtn = rtn.Replace(@"\'f2", @"\f1 \u8805?\f0 "); //greater than or equal
|
||||
//rtn = rtn.Replace("\xB0 ", @"\'b0 ");
|
||||
//rtn = rtn.Replace("\x2552", "\\b ");
|
||||
//rtn = rtn.Replace("\x2553", "\\b0 ");
|
||||
rtn = rtn.Replace(@"\'d5", @"\b");
|
||||
rtn = rtn.Replace(@"\'d6", @"\b0");
|
||||
//rtn = rtn.Replace("\xA0", @"\u160?");
|
||||
//rtn = rtn.Replace(@"\'a0", @"\u160?");
|
||||
rtn = rtn.Replace(@"\'ff", @"\u160?");
|
||||
//rtn = rtn.Replace("\xFF", @"\u160?");
|
||||
//rtn = rtn.Replace(@"\~", @"\u160?");
|
||||
rtn = rtn.Replace("\x7F", @"\f1 \u916?\f0 "); // delta
|
||||
}
|
||||
// rtn = rtn.Replace(@"\'ef\'e6", @"\up2 ");
|
||||
// rtn = rtn.Replace(@"\'ef\'e7", @"\up0 ");
|
||||
// rtn = rtn.Replace(@"\'f2", @"\f1 \u8805?\f0 "); //greater than or equal
|
||||
// //rtn = rtn.Replace("\xB0 ", @"\'b0 ");
|
||||
// //rtn = rtn.Replace("\x2552", "\\b ");
|
||||
// //rtn = rtn.Replace("\x2553", "\\b0 ");
|
||||
// rtn = rtn.Replace(@"\'d5", @"\b");
|
||||
// rtn = rtn.Replace(@"\'d6", @"\b0");
|
||||
// //rtn = rtn.Replace("\xA0", @"\u160?");
|
||||
// //rtn = rtn.Replace(@"\'a0", @"\u160?");
|
||||
// rtn = rtn.Replace(@"\'ff", @"\u160?");
|
||||
// //rtn = rtn.Replace("\xFF", @"\u160?");
|
||||
// //rtn = rtn.Replace(@"\~", @"\u160?");
|
||||
// rtn = rtn.Replace("\x7F", @"\f1 \u916?\f0 "); // delta
|
||||
//}
|
||||
|
||||
//ShowRawString(rtn, "ConvertTableText OUT");
|
||||
return rtn;
|
||||
@ -1626,7 +1796,7 @@ namespace Volian.Controls.Library
|
||||
trtb.AdjustWidthForContent();
|
||||
}
|
||||
this[r, c] = trtb.Rtf;
|
||||
this.AdjustGridHeightWidth(r, c);
|
||||
this.ConvertTextCellToRTF(r, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1845,7 +2015,7 @@ namespace Volian.Controls.Library
|
||||
/// <summary>
|
||||
/// This will parse a string containing the ascii text of the old style VE-PROMS (16-bit) tables.
|
||||
/// It will find the number of rows and columns base on newlines, vertical bars, and dashes.
|
||||
/// Then it will parse the the text, place them in celll, and attempt to merge cells were needed.
|
||||
/// Then it will parse the the text, place them in cells, and attempt to merge cells were needed.
|
||||
/// </summary>
|
||||
/// <param name="txtbuff"></param>
|
||||
public void ParseTableFromText(string txtbuff)
|
||||
@ -1956,6 +2126,15 @@ namespace Volian.Controls.Library
|
||||
for (tstidx = 0; (tstidx < tstr.Length) && (tstr[tstidx] == '-'); tstidx++) ;
|
||||
if (tstidx < tstr.Length) // not a full line (row) of '-' chars
|
||||
{
|
||||
// take a peek at the start of the next piece of table text to parse
|
||||
// if it starts with a '-' char, then flag to merge the columns up to
|
||||
// this point with the same columns in the next row
|
||||
if (idx < txtbuff.Length - 1 && txtbuff[idx + 1] == '-')
|
||||
{
|
||||
for (int c = curCol; c >= 0; c--)
|
||||
if (!tci[curRow, c].ColEnd)
|
||||
tci[curRow, c].MergeRowBellow = true;
|
||||
}
|
||||
// if this column is in a merged grouping of rows,
|
||||
// get the cell text in the first cell of the merged grouping of cells
|
||||
// we will append the newly parsed text to this cell's text.
|
||||
@ -1972,15 +2151,23 @@ namespace Volian.Controls.Library
|
||||
//jstr += "\n" + tstr; // multi line cell
|
||||
//this[rw, curCol] = jstr;
|
||||
this[rw, cl] = jstr;
|
||||
// take a peek at the start of the next piece of table text to parse
|
||||
// if it starts with a '-' char, then flag to merge the columns up to
|
||||
// this point with the same columns in the next row
|
||||
if (idx < txtbuff.Length - 1 && txtbuff[idx + 1] == '-')
|
||||
{
|
||||
for (int c = curCol; c >= -0; c--)
|
||||
if (!tci[curRow, c].ColEnd)
|
||||
tci[curRow, c].MergeRowBellow = true;
|
||||
}
|
||||
//// take a peek at the start of the next piece of table text to parse
|
||||
//// if it starts with a '-' char, then flag to merge the columns up to
|
||||
//// this point with the same columns in the next row
|
||||
//if (idx < txtbuff.Length - 1 && txtbuff[idx + 1] == '-')
|
||||
//{
|
||||
// for (int c = curCol; c >= 0; c--)
|
||||
// if (!tci[curRow, c].ColEnd)
|
||||
// tci[curRow, c].MergeRowBellow = true;
|
||||
//}
|
||||
//int tcol = dicCols[idx];
|
||||
//// if were are that the end of the 16-bit text line, but not in the last column,
|
||||
//// merge the remaining columns to the right
|
||||
//if (curCol < tcol)
|
||||
//{
|
||||
// for (int i = curCol; i <= tcol; i++)
|
||||
// tci[curRow, i].MergeColRight = true;
|
||||
//}
|
||||
}
|
||||
else // parsed text contains all dashes
|
||||
{
|
||||
@ -1991,19 +2178,26 @@ namespace Volian.Controls.Library
|
||||
case '\x02': // end of file
|
||||
case '\n': // new line of 16-bit table text
|
||||
colPos = idxst - strow;
|
||||
// see what column we are in - new line might occure before last grid column
|
||||
curCol = dicCols[colPos];
|
||||
// see what column we are in - new line might occure before last grid column
|
||||
strow = idx + 1;
|
||||
// parse out the cell text
|
||||
tstr = txtbuff.Substring(idxst, idx - idxst);
|
||||
if (tstr.EndsWith("\r")) // strip off carrage return
|
||||
tstr = tstr.Substring(0, tstr.Length - 1);
|
||||
tstr = tstr.TrimEnd(" ".ToCharArray());
|
||||
if (tstr.Length == 0)
|
||||
tstr += " ";
|
||||
// test for a string of '-' characters
|
||||
for (tstidx = 0; (tstidx < tstr.Length) && (tstr[tstidx] == '-'); tstidx++) ;
|
||||
if (tstidx < tstr.Length) // not a full line (row) of '-' chars
|
||||
{
|
||||
//curCol = dicCols[colPos];
|
||||
while (curCol > prevCol + 1)
|
||||
{
|
||||
tci[curRow, prevCol].MergeColRight = true;
|
||||
prevCol++;
|
||||
}
|
||||
// if this column is in a merged grouping of rows,
|
||||
// get the cell text in the first cell of the merged grouping of cells
|
||||
// we will append the newly parsed text to this cell's text.
|
||||
@ -2057,6 +2251,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
// parse out the remaining text
|
||||
tstr = txtbuff.Substring(idxst);
|
||||
tstr = tstr.TrimEnd(" ".ToCharArray());
|
||||
if (tstr.Length == 0)
|
||||
tstr += " ";
|
||||
// test for a string of '-' characters
|
||||
@ -2138,6 +2333,313 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//private Regex _RemoveComments = new Regex(@"\\v .*?\\v0( |$)");
|
||||
|
||||
//public void ParseTableFromText2(string rtfText)
|
||||
//{
|
||||
// //string txtbuff = _RemoveComments.Replace(rtfText, "");
|
||||
// string txtbuff = "";
|
||||
// int curRow = 0;
|
||||
// int curCol = 0;
|
||||
// int maxRow = 0;
|
||||
// int maxCol = 0;
|
||||
// // Get Max Rows and Max Cols
|
||||
// char[] test = "|\n\x02".ToCharArray();
|
||||
// int idx = 0;
|
||||
// int idxst = 0;
|
||||
// int colPos = 0;
|
||||
// int strow = 0;
|
||||
// Dictionary<int, int> dicCols = new Dictionary<int, int>();
|
||||
// //Dictionary<int, int> dicCols2 = new Dictionary<int, int>();
|
||||
|
||||
// //If this is not a table ro, then process the RTF version of the text so as to caputure Link references
|
||||
// if (!this.IsRoTable)
|
||||
// txtbuff = rtfText;
|
||||
// else
|
||||
// txtbuff = _RemoveComments.Replace(rtfText, "");
|
||||
// do
|
||||
// {
|
||||
// idx = txtbuff.IndexOfAny(test, idxst);
|
||||
// if (idx > -1)
|
||||
// {
|
||||
// switch (txtbuff[idx])
|
||||
// {
|
||||
// case '|': // end of a column
|
||||
// colPos = idxst - strow;
|
||||
// if (!dicCols.ContainsKey(colPos))
|
||||
// dicCols.Add(colPos, curCol);
|
||||
// else if (curCol > dicCols[colPos])
|
||||
// {
|
||||
// dicCols.Remove(colPos);
|
||||
// dicCols.Add(colPos, curCol);
|
||||
// }
|
||||
// curCol++;
|
||||
// break;
|
||||
// case '\x02':
|
||||
// case '\n': // end of a row
|
||||
// colPos = idxst - strow;
|
||||
// if (!dicCols.ContainsKey(colPos))
|
||||
// dicCols.Add(colPos, curCol);
|
||||
// else if (curCol > dicCols[colPos])
|
||||
// {
|
||||
// dicCols.Remove(colPos);
|
||||
// dicCols.Add(colPos, curCol);
|
||||
// }
|
||||
// curRow++;
|
||||
// strow = idx + 1;
|
||||
// if (curCol > maxCol)
|
||||
// maxCol = curCol;
|
||||
// curCol = 0;
|
||||
// break;
|
||||
// }
|
||||
// idxst = idx + 1;
|
||||
// if (idxst >= txtbuff.Length)
|
||||
// idx = -1;
|
||||
// }
|
||||
// } while (idx != -1);
|
||||
// maxRow = curRow + 1;
|
||||
// curRow = 0;
|
||||
// curCol = 0;
|
||||
// // The resulting Table Grid size in rows and columns
|
||||
// this.Cols.Count = maxCol + 1;
|
||||
// this.Rows.Count = maxRow + 1;
|
||||
|
||||
// // make all rows and columns editable
|
||||
// this.Rows.Fixed = 0;
|
||||
// this.Cols.Fixed = 0;
|
||||
|
||||
// // TableCellInfo is used to assign merge ranges
|
||||
// // Make a two dimensional array of TableCellinfo the same size as the table grid
|
||||
// TableCellInfo[,] tci = new TableCellInfo[maxRow + 1, maxCol + 1];
|
||||
// for (int r = 0; r <= maxRow; r++)
|
||||
// for (int c = 0; c <= maxCol; c++)
|
||||
// tci[r, c] = new TableCellInfo();
|
||||
|
||||
// // Read in each cell of the grid
|
||||
// idx = 0;
|
||||
// idxst = 0;
|
||||
// colPos = 0;
|
||||
// strow = 0;
|
||||
// int prevCol = 0;
|
||||
// int tstidx = 0;
|
||||
// string tstr = "";
|
||||
// bool incRow = false;
|
||||
// ////If this is not a table ro, then process the RTF version of the text so as to caputure Link references
|
||||
// //if (!this.IsRoTable)
|
||||
// // txtbuff = rtfText;
|
||||
// do
|
||||
// {
|
||||
// idx = txtbuff.IndexOfAny(test, idxst);
|
||||
// if (idx > -1)
|
||||
// {
|
||||
// switch (txtbuff[idx])
|
||||
// {
|
||||
// case '|': // end of column
|
||||
// colPos = idxst - strow;
|
||||
// // based on the position of the | char, find what column we are in.
|
||||
// // note that this will tell us if any columns to the left were merged
|
||||
// // the while loop will flag cell that need to be merged
|
||||
// curCol = dicCols[colPos];
|
||||
// while (curCol > prevCol + 1)
|
||||
// {
|
||||
// tci[curRow, prevCol].MergeColRight = true;
|
||||
// prevCol++;
|
||||
// }
|
||||
// prevCol = curCol;
|
||||
|
||||
// // parse out the text to be placed in the table cell
|
||||
// tstr = txtbuff.Substring(idxst, idx - idxst);
|
||||
// if (tstr.Length == 0)
|
||||
// tstr += " ";
|
||||
// // test for a string of '-' characters
|
||||
// for (tstidx = 0; (tstidx < tstr.Length) && (tstr[tstidx] == '-'); tstidx++) ;
|
||||
// if (tstidx < tstr.Length) // not a full line (row) of '-' chars
|
||||
// {
|
||||
// // if this column is in a merged grouping of rows,
|
||||
// // get the cell text in the first cell of the merged grouping of cells
|
||||
// // we will append the newly parsed text to this cell's text.
|
||||
// int rw = curRow;
|
||||
// while (rw - 1 >= 0 && tci[rw - 1, curCol].MergeRowBellow) rw--;
|
||||
// int cl = curCol;
|
||||
// while (cl - 1 >= 0 && tci[rw, cl - 1].MergeColRight) cl--;
|
||||
// //string jstr = (string)this[rw, curCol];
|
||||
// string jstr = (string)this[rw, cl];
|
||||
// if (jstr == null)
|
||||
// jstr = tstr;
|
||||
// else
|
||||
// jstr += ((cl == curCol) ? "\n" : "") + tstr; // multi line cell
|
||||
// //jstr += "\n" + tstr; // multi line cell
|
||||
// //this[rw, curCol] = jstr;
|
||||
// this[rw, cl] = jstr;
|
||||
// // take a peek at the start of the next piece of table text to parse
|
||||
// // if it starts with a '-' char, then flag to merge the columns up to
|
||||
// // this point with the same columns in the next row
|
||||
// if (idx < txtbuff.Length - 1 && txtbuff[idx + 1] == '-')
|
||||
// {
|
||||
// for (int c = curCol; c >= -0; c--)
|
||||
// if (!tci[curRow, c].ColEnd)
|
||||
// tci[curRow, c].MergeRowBellow = true;
|
||||
// }
|
||||
// }
|
||||
// else // parsed text contains all dashes
|
||||
// {
|
||||
// tci[curRow, curCol].ColEnd = true;
|
||||
// incRow = true;
|
||||
// }
|
||||
// break;
|
||||
// case '\x02': // end of file
|
||||
// case '\n': // new line of 16-bit table text
|
||||
// colPos = idxst - strow;
|
||||
// // see what column we are in - new line might occure before last grid column
|
||||
// curCol = dicCols[colPos];
|
||||
// strow = idx + 1;
|
||||
// // parse out the cell text
|
||||
// tstr = txtbuff.Substring(idxst, idx - idxst);
|
||||
// if (tstr.EndsWith("\r")) // strip off carrage return
|
||||
// tstr = tstr.Substring(0, tstr.Length - 1);
|
||||
// tstr = tstr.TrimEnd(" ".ToCharArray());
|
||||
// if (tstr.Length == 0)
|
||||
// tstr += " ";
|
||||
// // test for a string of '-' characters
|
||||
// for (tstidx = 0; (tstidx < tstr.Length) && (tstr[tstidx] == '-'); tstidx++) ;
|
||||
// if (tstidx < tstr.Length) // not a full line (row) of '-' chars
|
||||
// {
|
||||
// // if this column is in a merged grouping of rows,
|
||||
// // get the cell text in the first cell of the merged grouping of cells
|
||||
// // we will append the newly parsed text to this cell's text.
|
||||
// int rw = curRow;
|
||||
// while (rw - 1 >= 0 && tci[rw - 1, curCol].MergeRowBellow) rw--;
|
||||
// int cl = curCol;
|
||||
// while (cl - 1 >= 0 && tci[rw, cl - 1].MergeColRight) cl--;
|
||||
// //string jstr = (string)this[rw, curCol];
|
||||
// string jstr = (string)this[rw, cl];
|
||||
// if (jstr == null)
|
||||
// jstr = tstr;
|
||||
// else
|
||||
// jstr += ((cl == curCol) ? "\n" : "") + tstr; // multi line cell
|
||||
// //jstr += "\n" + tstr; // multi line cell
|
||||
|
||||
// //this[rw, curCol] = jstr;
|
||||
// this[rw, cl] = jstr;
|
||||
// }
|
||||
// else if (tstr.Length > 0) // parsed text is all dash characters
|
||||
// {
|
||||
// incRow = true;
|
||||
// if (curRow > 0) // merge the column in the previous row with this one
|
||||
// tci[curRow - 1, curCol].MergeRowBellow = false;
|
||||
// }
|
||||
// // if were are that the end of the 16-bit text line, but not in the last column,
|
||||
// // merge the remaining columns to the right
|
||||
// if ((curCol < maxCol) && (tstidx < tstr.Length))
|
||||
// {
|
||||
// for (int i = curCol; i < maxCol; i++)
|
||||
// tci[curRow, i].MergeColRight = true;
|
||||
// }
|
||||
// if (incRow)
|
||||
// curRow++;
|
||||
// curCol = 0;
|
||||
// incRow = false;
|
||||
// break;
|
||||
// }
|
||||
// idxst = idx + 1;
|
||||
// if (idxst >= txtbuff.Length)
|
||||
// idx = -1;
|
||||
// }
|
||||
// else if (idxst < txtbuff.Length - 1) // handle any remaining text not yet parsed
|
||||
// {
|
||||
// // find the curent column and merge remaining columns to the right
|
||||
// colPos = idxst - strow;
|
||||
// curCol = dicCols[colPos];
|
||||
// while (curCol > prevCol + 1)
|
||||
// {
|
||||
// tci[curRow, prevCol].MergeColRight = true;
|
||||
// prevCol++;
|
||||
// }
|
||||
// // parse out the remaining text
|
||||
// tstr = txtbuff.Substring(idxst);
|
||||
// tstr = tstr.TrimEnd(" ".ToCharArray());
|
||||
// if (tstr.Length == 0)
|
||||
// tstr += " ";
|
||||
// // test for a string of '-' characters
|
||||
// for (tstidx = 0; (tstidx < tstr.Length) && (tstr[tstidx] == '-'); tstidx++) ;
|
||||
// if (tstidx < tstr.Length)
|
||||
// {
|
||||
// // if this column is in a merged grouping of rows,
|
||||
// // get the cell text in the first cell of the merged grouping of cells
|
||||
// // we will append the newly parsed text to this cell's text.
|
||||
// int rw = curRow;
|
||||
// while (rw - 1 >= 0 && tci[rw - 1, curCol].MergeRowBellow) rw--;
|
||||
// int cl = curCol;
|
||||
// while (cl - 1 >= 0 && tci[rw, cl - 1].MergeColRight) cl--;
|
||||
// //string jstr = (string)this[rw, curCol];
|
||||
// string jstr = (string)this[rw, cl];
|
||||
// if (jstr == null)
|
||||
// jstr = tstr;
|
||||
// else
|
||||
// jstr += ((cl == curCol) ? "\n" : "") + tstr; // multi line cell
|
||||
// //jstr += "\n" + tstr; // multi line cell
|
||||
// //this[rw, curCol] = jstr;
|
||||
// this[rw, cl] = jstr;
|
||||
// }
|
||||
// }
|
||||
// } while (idx != -1);
|
||||
|
||||
// // we are done parsing the 16-bit text.
|
||||
// // now set the merge ranges in the table grid, based on the
|
||||
// // information saved in that two dimensional array of TableCellinfo
|
||||
// this.Rows.Count = curRow + 1;
|
||||
// this.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Custom;
|
||||
// maxRow = curRow;
|
||||
// int rR = 0;
|
||||
// int rC = 0;
|
||||
// for (int r = 0; r <= maxRow; r++)
|
||||
// for (int c = 0; c <= maxCol; c++)
|
||||
// {
|
||||
// if (tci[r, c].MergeColRight)
|
||||
// {
|
||||
// rC = c;
|
||||
// while ((rC < maxCol) && (tci[r, rC].MergeColRight)) rC++;
|
||||
// if (rC > c)
|
||||
// {
|
||||
// this.MergedRanges.Add(this.GetCellRange(r, c, r, rC));
|
||||
// string cellstr = this[r, c].ToString();
|
||||
// for (int x = c + 1; x <= rC; x++)
|
||||
// this[r, x] = cellstr;
|
||||
// c = rC;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for (int c = 0; c <= maxCol; c++)
|
||||
// for (int r = 0; r <= maxRow; r++)
|
||||
// {
|
||||
// if (tci[r, c].MergeRowBellow)
|
||||
// {
|
||||
// rR = r;
|
||||
// while ((rR < maxRow) && (tci[rR, c].MergeRowBellow)) rR++;
|
||||
// if (rR > r)
|
||||
// {
|
||||
// this.MergedRanges.Add(this.GetCellRange(r, c, rR, c));
|
||||
// string cellstr = this[r, c].ToString();
|
||||
// for (int x = r + 1; x <= rR; x++)
|
||||
// this[x, c] = cellstr;
|
||||
// r = rR;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for (int c = 0; c <= maxCol; c++)
|
||||
// for (int r = 0; r <= maxRow; r++)
|
||||
// {
|
||||
// if (this[r, c] != null)
|
||||
// {
|
||||
// string cellstr = this[r, c].ToString();
|
||||
// this[r, c] = cellstr.TrimEnd(" \r\n\t".ToCharArray());
|
||||
// CellRange cr = this.GetMergedRange(r, c);
|
||||
// if (cr.r1 != cr.r2)
|
||||
// TrimMergedRangeCellText(cr);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
private void TrimMergedRangeCellText(CellRange cr)
|
||||
{
|
||||
// count number of newlines
|
||||
|
Loading…
x
Reference in New Issue
Block a user