public static string GetWhiteSpaceHtml(string text)
{
try
{
ArrayList matchList = new ArrayList();
string pat = @"<text:s text:c="+'"'.ToString()+@"\d+"+'"'.ToString()+" xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\" />";
Regex r = new Regex(pat, RegexOptions.IgnoreCase);
Match m = r.Match(text);
while (m.Success)
{
Regex r1 = new Regex(@"\d", RegexOptions.IgnoreCase);
Match m1 = r1.Match(m.Value);
string html = "";
while(m1.Success)
{
int cnt = Convert.ToInt32(m1.Value);
for(int i=0; i<cnt; i++)
html += " ";
//Console.WriteLine(html);
break;
}
if (html.Length > 0)
{
WhiteSpaceHelper w = new WhiteSpaceHelper();
w.Value = html;
w.Replacement = m.Value;
matchList.Add(w);
}
m = m.NextMatch();
}
foreach(WhiteSpaceHelper ws in matchList)
text = text.Replace(ws.Replacement, ws.Value);
}
catch(Exception)
{
//unhandled, only whitespaces arent displayed correct
}
return text;
}