Support font table in RTF
This commit is contained in:
parent
930d683cfe
commit
05a9c4897f
@ -31,7 +31,25 @@ namespace UniversalEditor.DataFormats.Text.Formatted.RichText
|
||||
if (ftom == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Writer writer = base.Accessor.Writer;
|
||||
writer.WriteLine("{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 ");
|
||||
writer.Write("{\\rtf1");
|
||||
// writer.WriteLine("\\ansi\\ansicpg1252");
|
||||
|
||||
if (ftom.DefaultFont != null && ftom.Fonts.Contains(ftom.DefaultFont))
|
||||
{
|
||||
writer.Write("\\deff" + ftom.Fonts.IndexOf(ftom.DefaultFont));
|
||||
}
|
||||
// writer.Write("\\deflang1033\\uc1");
|
||||
|
||||
if (ftom.Fonts.Count > 0)
|
||||
{
|
||||
writer.Write("{\\fonttbl");
|
||||
foreach (FormattedTextFont font in ftom.Fonts)
|
||||
{
|
||||
writer.Write("{\\f" + ftom.Fonts.IndexOf(font).ToString() + " " + font.Name + ";}");
|
||||
}
|
||||
writer.Write("}");
|
||||
}
|
||||
|
||||
foreach (FormattedTextItem item in ftom.Items)
|
||||
{
|
||||
RenderItem(writer, item);
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Text.Formatted
|
||||
{
|
||||
public class FormattedTextFont : ICloneable
|
||||
{
|
||||
public class FormattedTextFontCollection
|
||||
: System.Collections.ObjectModel.Collection<FormattedTextFont>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private string mvarName = String.Empty;
|
||||
public string Name { get { return mvarName; } set { mvarName = value; } }
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
FormattedTextFont clone = new FormattedTextFont();
|
||||
clone.Name = (mvarName.Clone() as string);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19,20 +19,31 @@ namespace UniversalEditor.ObjectModels.Text.Formatted
|
||||
return _omr;
|
||||
}
|
||||
|
||||
private FormattedTextItem.FormattedTextItemCollection mvarSegments = new FormattedTextItem.FormattedTextItemCollection();
|
||||
public FormattedTextItem.FormattedTextItemCollection Items { get { return mvarSegments; } }
|
||||
private FormattedTextFont mvarDefaultFont = null;
|
||||
public FormattedTextFont DefaultFont { get { return mvarDefaultFont; } set { mvarDefaultFont = value; } }
|
||||
|
||||
private FormattedTextFont.FormattedTextFontCollection mvarFonts = new FormattedTextFont.FormattedTextFontCollection();
|
||||
public FormattedTextFont.FormattedTextFontCollection Fonts { get { return mvarFonts; } }
|
||||
|
||||
private FormattedTextItem.FormattedTextItemCollection mvarItems = new FormattedTextItem.FormattedTextItemCollection();
|
||||
public FormattedTextItem.FormattedTextItemCollection Items { get { return mvarItems; } }
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
mvarSegments.Clear();
|
||||
mvarFonts.Clear();
|
||||
mvarItems.Clear();
|
||||
}
|
||||
|
||||
public override void CopyTo(ObjectModel where)
|
||||
{
|
||||
FormattedTextObjectModel clone = (where as FormattedTextObjectModel);
|
||||
foreach (FormattedTextItem segment in mvarSegments)
|
||||
foreach (FormattedTextFont font in mvarFonts)
|
||||
{
|
||||
clone.Items.Add(segment.Clone() as FormattedTextItem);
|
||||
clone.Fonts.Add(font.Clone() as FormattedTextFont);
|
||||
}
|
||||
foreach (FormattedTextItem item in mvarItems)
|
||||
{
|
||||
clone.Items.Add(item.Clone() as FormattedTextItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,6 +103,7 @@
|
||||
<Compile Include="ObjectModels\SecurityCertificate\SecurityCertificateObjectModel.cs" />
|
||||
<Compile Include="ObjectModels\Shortcut\ShortcutObjectModel.cs" />
|
||||
<Compile Include="ObjectModels\Solution\SolutionObjectModel.cs" />
|
||||
<Compile Include="ObjectModels\Text\Formatted\FormattedTextFont.cs" />
|
||||
<Compile Include="ObjectModels\Text\Formatted\FormattedTextObjectModel.cs" />
|
||||
<Compile Include="ObjectModels\Text\Formatted\FormattedTextItem.cs" />
|
||||
<Compile Include="ObjectModels\Text\Formatted\FormattedTextStyle.cs" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user