Przeglądaj źródła

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 lat temu
rodzic
commit
c98cec6d15
5 zmienionych plików z 76 dodań i 7 usunięć
  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 Wyświetl plik

@@ -7,16 +7,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Global
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 3
SccNumberOfProjects = 2
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = https://tfs08.codeplex.com/
SccLocalPath0 = .
SccProjectUniqueName1 = DocX\\DocX.csproj
SccProjectName1 = DocX
SccLocalPath1 = DocX
SccProjectUniqueName2 = ConsoleApplication1\\ConsoleApplication1.csproj
SccProjectName2 = ConsoleApplication1
SccLocalPath2 = ConsoleApplication1
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

+ 5
- 0
DocX/DocX.cs Wyświetl plik

@@ -1008,6 +1008,11 @@ namespace Novacode
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)
{
XElement newTable =

+ 13
- 2
DocX/Formatting.cs Wyświetl plik

@@ -63,8 +63,19 @@ namespace Novacode
if (percentageScale.HasValue)
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)
rPr.Add(new XElement(XName.Get("vanish", DocX.w.NamespaceName)));

+ 34
- 1
DocX/Paragraph.cs Wyświetl plik

@@ -1840,6 +1840,29 @@ namespace Novacode
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)
{
foreach (XElement run in runs)
@@ -2047,7 +2070,17 @@ namespace Novacode
/// </example>
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;
}

+ 23
- 0
DocX/Table.cs Wyświetl plik

@@ -44,10 +44,33 @@ namespace Novacode
/// </example>
public void SetDirection(Direction direction)
{
XElement tblPr = GetOrCreate_tblPr();
tblPr.Add(new XElement(DocX.w + "bidiVisual"));
foreach (Row r in Rows)
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>
/// Returns the number of rows in this table.
/// </summary>

Ładowanie…
Anuluj
Zapisz