Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
antony-liu committed Oct 29, 2019
2 parents 8dcfded + 71508e9 commit 82d894f
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 32 deletions.
4 changes: 2 additions & 2 deletions OpenXmlFormats/Wordprocessing/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ internal void Write(StreamWriter sw)

public CT_Document()
{
//this.bodyField = new CT_Body();
this.bodyField = new CT_Body();
}

[XmlElement(Order = 0)]
Expand Down Expand Up @@ -147,7 +147,7 @@ public class CT_Body

public CT_Body()
{
//this.sectPrField = new CT_SectPr();
this.sectPrField = new CT_SectPr();
this.itemsElementNameField = new List<DocumentBodyItemChoiceType>();
this.itemsField = new ArrayList();
}
Expand Down
22 changes: 15 additions & 7 deletions OpenXmlFormats/Wordprocessing/Paragraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,11 @@ public class CT_PPr : CT_PPrBase
public CT_PPr()
{

}
public CT_SectPr createSectPr()
{
this.sectPrField = new CT_SectPr();
return this.sectPrField;
}
public override bool IsEmpty
{
Expand Down Expand Up @@ -1898,7 +1903,7 @@ public class CT_SectPrChange : CT_TrackChange

public CT_SectPrChange()
{
//this.sectPrField = new CT_SectPrBase();
this.sectPrField = new CT_SectPrBase();
}
public static new CT_SectPrChange Parse(XmlNode node, XmlNamespaceManager namespaceManager)
{
Expand Down Expand Up @@ -2004,12 +2009,12 @@ public CT_SectPrBase()
//this.docGridField = new CT_DocGrid();
//this.rtlGutterField = new CT_OnOff();
//this.bidiField = new CT_OnOff();
//this.textDirectionField = new CT_TextDirection();
this.textDirectionField = new CT_TextDirection();
//this.titlePgField = new CT_OnOff();
//this.noEndnoteField = new CT_OnOff();
//this.vAlignField = new CT_VerticalJc();
//this.formProtField = new CT_OnOff();
//this.colsField = new CT_Columns();
this.colsField = new CT_Columns();
//this.pgNumTypeField = new CT_PageNumber();
//this.lnNumTypeField = new CT_LineNumber();
//this.pgBordersField = new CT_PageBorders();
Expand Down Expand Up @@ -2481,7 +2486,7 @@ public class CT_SectPr

public CT_SectPr()
{
//this.sectPrChangeField = new CT_SectPrChange();
this.sectPrChangeField = new CT_SectPrChange();
//this.printerSettingsField = new CT_Rel();
this.docGridField = new CT_DocGrid();
this.docGrid.type = ST_DocGrid.lines;
Expand All @@ -2490,15 +2495,15 @@ public CT_SectPr()

//this.rtlGutterField = new CT_OnOff();
//this.bidiField = new CT_OnOff();
//this.textDirectionField = new CT_TextDirection();
this.textDirectionField = new CT_TextDirection();
//this.titlePgField = new CT_OnOff();
//this.noEndnoteField = new CT_OnOff();
//this.vAlignField = new CT_VerticalJc();
//this.formProtField = new CT_OnOff();
this.colsField = new CT_Columns();
this.cols.space = 425;
this.cols.spaceSpecified = true;
//this.pgNumTypeField = new CT_PageNumber();
this.pgNumTypeField = new CT_PageNumber();
//this.lnNumTypeField = new CT_LineNumber();
//this.pgBordersField = new CT_PageBorders();
//this.paperSrcField = new CT_PaperSource();
Expand Down Expand Up @@ -3502,7 +3507,10 @@ public bool IsSetLineRule()
{
return !(this.lineRuleField == ST_LineSpacingRule.nil);
}

public bool IsSetBetweenLines()
{
return !string.IsNullOrEmpty(this.lineField);
}
public bool IsSetAfter()
{
return !(this.afterField == 0);
Expand Down
4 changes: 2 additions & 2 deletions main/HSSF/UserModel/HSSFCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ public void SetCellValue(double value)
/// will Change the cell to a numeric cell and Set its value.</param>
public void SetCellValue(DateTime value)
{
SetCellValue(DateUtil.GetExcelDate(value, this.book.Workbook.IsUsing1904DateWindowing));
SetCellValue(DateUtil.GetExcelDate(value, this.book.IsDate1904()));
}


Expand Down Expand Up @@ -761,7 +761,7 @@ public DateTime DateCellValue
"You cannot get a date value from an error cell");
}
double value = this.NumericCellValue;
if (book.Workbook.IsUsing1904DateWindowing)
if (book.IsDate1904())
{
return DateUtil.GetJavaDate(value, true);
}
Expand Down
11 changes: 11 additions & 0 deletions main/HSSF/UserModel/HSSFWorkbook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2266,5 +2266,16 @@ public bool Remove(ISheet item)
{
return this._sheets.Remove((HSSFSheet)item);
}

/// <summary>
/// Gets a bool value that indicates whether the date systems used in the workbook starts in 1904.
/// The default value is false, meaning that the workbook uses the 1900 date system,
/// where 1/1/1900 is the first day in the system.
/// </summary>
/// <returns>True if the date systems used in the workbook starts in 1904</returns>
public bool IsDate1904()
{
return Workbook.IsUsing1904DateWindowing;
}
}
}
8 changes: 8 additions & 0 deletions main/SS/UserModel/Workbook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,14 @@ public interface IWorkbook : ICloseable
/// <param name="toopack">the toolpack to register</param>
void AddToolPack(UDFFinder toopack);

/// <summary>
/// Gets a bool value that indicates whether the date systems used in the workbook starts in 1904.
/// The default value is false, meaning that the workbook uses the 1900 date system,
/// where 1/1/1900 is the first day in the system.
/// </summary>
/// <returns>True if the date systems used in the workbook starts in 1904</returns>
bool IsDate1904();

void Close();

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions ooxml/XSSF/Streaming/SXSSFCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public DateTime DateCellValue
}

double value = NumericCellValue;
bool date1904= ((XSSFWorkbook)Sheet.Workbook).IsDate1904();
bool date1904 = Sheet.Workbook.IsDate1904();
return DateUtil.GetJavaDate(value, date1904);
}
}
Expand Down Expand Up @@ -475,8 +475,7 @@ public void SetCellValue(DateTime? value)
return;
}

bool date1904 = ((XSSFWorkbook)Sheet.Workbook).IsDate1904();
SetCellValue(DateUtil.GetExcelDate(value.Value, date1904));
SetCellValue(value.Value);
}

public void SetCellValue(double value)
Expand Down Expand Up @@ -788,7 +787,8 @@ private String ConvertCellValueToString(CellType cellType)

public void SetCellValue(DateTime value)
{
SetCellValue((DateTime?)value);
bool date1904 = Sheet.Workbook.IsDate1904();
SetCellValue(DateUtil.GetExcelDate(value, date1904));
}
}
}
2 changes: 1 addition & 1 deletion ooxml/XSSF/Streaming/SXSSFSheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ public void UngroupRow(int fromRow, int toRow)

public bool IsDate1904()
{
throw new NotImplementedException();
return _workbook.IsDate1904();
}
public int GetRowNum(SXSSFRow row)
{
Expand Down
14 changes: 10 additions & 4 deletions ooxml/XSSF/Streaming/SXSSFWorkbook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,6 @@ public ICreationHelper GetCreationHelper()
{
return new SXSSFCreationHelper(this);
}
protected bool IsDate1904()
{
return XssfWorkbook.IsDate1904();
}
public bool IsSheetHidden(int sheetIx)
{
return XssfWorkbook.IsSheetHidden(sheetIx);
Expand Down Expand Up @@ -777,6 +773,16 @@ public SpreadsheetVersion SpreadsheetVersion
}
}

/// <summary>
/// Gets a bool value that indicates whether the date systems used in the workbook starts in 1904.
/// The default value is false, meaning that the workbook uses the 1900 date system,
/// where 1/1/1900 is the first day in the system.
/// </summary>
/// <returns>True if the date systems used in the workbook starts in 1904</returns>
public bool IsDate1904()
{
return XssfWorkbook.IsDate1904();
}
//TODO: missing method isDate1904, isHidden, setHidden
}
}
4 changes: 2 additions & 2 deletions ooxml/XSSF/UserModel/XSSFCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ public DateTime DateCellValue
}

double value = NumericCellValue;
bool date1904 = ((XSSFWorkbook)Sheet.Workbook).IsDate1904();
bool date1904 = Sheet.Workbook.IsDate1904();
return DateUtil.GetJavaDate(value, date1904);
}
}
Expand All @@ -798,7 +798,7 @@ public DateTime DateCellValue
/// for numerics we'll Set its value. For other types we will change the cell to a numeric cell and Set its value. </param>
public void SetCellValue(DateTime value)
{
bool date1904 = ((XSSFWorkbook)Sheet.Workbook).IsDate1904();
bool date1904 = Sheet.Workbook.IsDate1904();
SetCellValue(DateUtil.GetExcelDate(value, date1904));
}
/// <summary>
Expand Down
14 changes: 6 additions & 8 deletions ooxml/XSSF/UserModel/XSSFWorkbook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1796,14 +1796,12 @@ private bool ContainsSheet(String name, int excludeSheetIdx)
return false;
}

/**
* Gets a bool value that indicates whether the date systems used in the workbook starts in 1904.
* <p>
* The default value is false, meaning that the workbook uses the 1900 date system,
* where 1/1/1900 is the first day in the system..
* </p>
* @return true if the date systems used in the workbook starts in 1904
*/
/// <summary>
/// Gets a bool value that indicates whether the date systems used in the workbook starts in 1904.
/// The default value is false, meaning that the workbook uses the 1900 date system,
/// where 1/1/1900 is the first day in the system.
/// </summary>
/// <returns>True if the date systems used in the workbook starts in 1904</returns>
public bool IsDate1904()
{
CT_WorkbookPr workbookPr = workbook.workbookPr;
Expand Down
40 changes: 40 additions & 0 deletions ooxml/XWPF/Usermodel/XWPFDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,48 @@ public CT_Document Document
{
return ctDocument;
}
set
{
ctDocument = value;
}
}
/**
* Sets columns on document base object
*/
public int ColumnCount
{
get
{
return int.Parse(ctDocument.body.sectPr.cols.num);
}
set
{
if (ctDocument != null)
{
ctDocument.body.sectPr.cols.num = value.ToString();
}

}

}
/**
* Sets Text Direction of Document
*/
public ST_TextDirection TextDirection
{
get
{
return ctDocument.body.sectPr.textDirection.val;
}
set
{
if (ctDocument != null)
{
ctDocument.body.sectPr.textDirection.val = value;
}
}

}
internal IdentifierManager DrawingIdManager
{
get
Expand Down
4 changes: 2 additions & 2 deletions ooxml/XWPF/Usermodel/XWPFHeaderFooter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public XWPFHeaderFooter(XWPFDocument doc, CT_HdrFtr hdrFtr)
protected XWPFHeaderFooter()
{

//headerFooter = new CT_HdrFtr();
//ReadHdrFtr();
headerFooter = new CT_HdrFtr();
ReadHdrFtr();
}

public XWPFHeaderFooter(POIXMLDocumentPart parent, PackagePart part)
Expand Down
32 changes: 32 additions & 0 deletions ooxml/XWPF/Usermodel/XWPFParagraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,11 @@ public ParagraphAlignment Alignment
}
}


/**
* @return The raw alignment value, {@link #getAlignment()} is suggested
*/

public int FontAlignment
{
get
Expand Down Expand Up @@ -987,6 +989,36 @@ public LineSpacingRule SpacingLineRule
}
}

///<summary>
/// Return the spacing between lines of a paragraph. The units of the return value depends on the
/// <see cref="LineSpacingRule"/>. If AUTO, the return value is in lines, otherwise the return
/// value is in points
///
/// <return>a double specifying points or lines.</return>
///</summary>
public double SpacingBetween
{
set
{
setSpacingBetween(value, LineSpacingRule.AUTO);
}

}
public void setSpacingBetween(double spacing, LineSpacingRule rule)
{
CT_Spacing ctSp = GetCTSpacing(true);
switch(rule)
{
case LineSpacingRule.AUTO:
ctSp.line = Math.Round(spacing * 240.0).ToString();
break;
default:
ctSp.line = Math.Round(spacing * 20.0).ToString();
break;
}
ctSp.lineRule = EnumConverter.ValueOf<ST_LineSpacingRule, LineSpacingRule>(rule);

}

/**
* Specifies the indentation which shall be placed between the left text
Expand Down

0 comments on commit 82d894f

Please sign in to comment.