Просмотр исходного кода

Bug fix: Fonts now work for non-standard characters such as ąęćłżźó in Polish.

Bug fix: Table.SetDirection(Direction) now changes the Direction of the Table and not just its contents.
master
coffeycathal_cp 15 лет назад
Родитель
Сommit
c98cec6d15
5 измененных файлов: 76 добавлений и 7 удалений
  1. 1
    4
      DocX.sln
  2. 5
    0
      DocX/DocX.cs
  3. 13
    2
      DocX/Formatting.cs
  4. 34
    1
      DocX/Paragraph.cs
  5. 23
    0
      DocX/Table.cs

+ 1
- 4
DocX.sln Просмотреть файл

EndProject EndProject
Global Global
GlobalSection(TeamFoundationVersionControl) = preSolution GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 3
SccNumberOfProjects = 2
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = https://tfs08.codeplex.com/ SccTeamFoundationServer = https://tfs08.codeplex.com/
SccLocalPath0 = . SccLocalPath0 = .
SccProjectUniqueName1 = DocX\\DocX.csproj SccProjectUniqueName1 = DocX\\DocX.csproj
SccProjectName1 = DocX SccProjectName1 = DocX
SccLocalPath1 = DocX SccLocalPath1 = DocX
SccProjectUniqueName2 = ConsoleApplication1\\ConsoleApplication1.csproj
SccProjectName2 = ConsoleApplication1
SccLocalPath2 = ConsoleApplication1
EndGlobalSection EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU

+ 5
- 0
DocX/DocX.cs Просмотреть файл

return new Table(this, newTable); return new Table(this, newTable);
} }
public Table AddTable(int rowCount, int coloumnCount)
{
return (new Table(this, CreateTable(rowCount, coloumnCount)));
}
internal static XElement CreateTable(int rowCount, int coloumnCount) internal static XElement CreateTable(int rowCount, int coloumnCount)
{ {
XElement newTable = XElement newTable =

+ 13
- 2
DocX/Formatting.cs Просмотреть файл

if (percentageScale.HasValue) if (percentageScale.HasValue)
rPr.Add(new XElement(XName.Get("w", DocX.w.NamespaceName), new XAttribute(XName.Get("val", DocX.w.NamespaceName), percentageScale))); rPr.Add(new XElement(XName.Get("w", DocX.w.NamespaceName), new XAttribute(XName.Get("val", DocX.w.NamespaceName), percentageScale)));
if(fontFamily != null)
rPr.Add(new XElement(XName.Get("rFonts", DocX.w.NamespaceName), new XAttribute(XName.Get("ascii", DocX.w.NamespaceName), fontFamily.Name)));
if (fontFamily != null)
{
rPr.Add
(
new XElement
(
XName.Get("rFonts", DocX.w.NamespaceName),
new XAttribute(XName.Get("ascii", DocX.w.NamespaceName), fontFamily.Name),
new XAttribute(XName.Get("hAnsi", DocX.w.NamespaceName), fontFamily.Name), // Added by Maurits Elbers to support non-standard characters. See http://docx.codeplex.com/Thread/View.aspx?ThreadId=70097&ANCHOR#Post453865
new XAttribute(XName.Get("cs", DocX.w.NamespaceName), fontFamily.Name) // Added by Maurits Elbers to support non-standard characters. See http://docx.codeplex.com/Thread/View.aspx?ThreadId=70097&ANCHOR#Post453865
)
);
}
if(hidden) if(hidden)
rPr.Add(new XElement(XName.Get("vanish", DocX.w.NamespaceName))); rPr.Add(new XElement(XName.Get("vanish", DocX.w.NamespaceName)));

+ 34
- 1
DocX/Paragraph.cs Просмотреть файл

return Append("\n" + text); return Append("\n" + text);
} }
/// <summary>
/// Append a new line to this Paragraph.
/// </summary>
/// <returns>This Paragraph with a new line appeneded.</returns>
/// <example>
/// Add a new Paragraph to this document and then append a new line to it.
/// <code>
/// // Load a document.
/// using (DocX document = DocX.Create(@"Test.docx"))
/// {
/// // Insert a new Paragraph and Append a new line with some text to it.
/// Paragraph p = document.InsertParagraph().AppendLine();
///
/// // Save this document.
/// document.Save();
/// }
/// </code>
/// </example>
public Paragraph AppendLine()
{
return Append("\n");
}
internal void ApplyTextFormattingProperty(XName textFormatPropName, string value, object content) internal void ApplyTextFormattingProperty(XName textFormatPropName, string value, object content)
{ {
foreach (XElement run in runs) foreach (XElement run in runs)
/// </example> /// </example>
public Paragraph Font(FontFamily fontFamily) public Paragraph Font(FontFamily fontFamily)
{ {
ApplyTextFormattingProperty(XName.Get("rFonts", DocX.w.NamespaceName), string.Empty, new XAttribute(XName.Get("ascii", DocX.w.NamespaceName), fontFamily.Name));
ApplyTextFormattingProperty
(
XName.Get("rFonts", DocX.w.NamespaceName),
string.Empty,
new[]
{
new XAttribute(XName.Get("ascii", DocX.w.NamespaceName), fontFamily.Name),
new XAttribute(XName.Get("hAnsi", DocX.w.NamespaceName), fontFamily.Name), // Added by Maurits Elbers to support non-standard characters. See http://docx.codeplex.com/Thread/View.aspx?ThreadId=70097&ANCHOR#Post453865
new XAttribute(XName.Get("cs", DocX.w.NamespaceName), fontFamily.Name), // Added by Maurits Elbers to support non-standard characters. See http://docx.codeplex.com/Thread/View.aspx?ThreadId=70097&ANCHOR#Post453865
}
);
return this; return this;
} }

+ 23
- 0
DocX/Table.cs Просмотреть файл

/// </example> /// </example>
public void SetDirection(Direction direction) public void SetDirection(Direction direction)
{ {
XElement tblPr = GetOrCreate_tblPr();
tblPr.Add(new XElement(DocX.w + "bidiVisual"));
foreach (Row r in Rows) foreach (Row r in Rows)
r.SetDirection(direction); r.SetDirection(direction);
} }
/// <summary>
/// If the tblPr element doesent exist it is created, either way it is returned by this function.
/// </summary>
/// <returns>The tblPr element for this Table.</returns>
internal XElement GetOrCreate_tblPr()
{
// Get the element.
XElement tblPr = Xml.Element(XName.Get("tblPr", DocX.w.NamespaceName));
// If it dosen't exist, create it.
if (tblPr == null)
{
Xml.AddFirst(new XElement(XName.Get("tblPr", DocX.w.NamespaceName)));
tblPr = Xml.Element(XName.Get("tblPr", DocX.w.NamespaceName));
}
// Return the pPr element for this Paragraph.
return tblPr;
}
/// <summary> /// <summary>
/// Returns the number of rows in this table. /// Returns the number of rows in this table.
/// </summary> /// </summary>

Загрузка…
Отмена
Сохранить