Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions OpenXmlFormats/Drawing/GraphicalObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ namespace NPOI.OpenXmlFormats.Dml
[XmlRoot(Namespace = "http://schemas.openxmlformats.org/drawingml/2006/main", IsNullable = true)]
public class CT_GraphicalObjectData
{
public XmlNode DomNode { get; set; }
public static CT_GraphicalObjectData Parse(XmlNode node, XmlNamespaceManager namespaceManager)
{
if (node == null)
return null;
CT_GraphicalObjectData ctObj = new CT_GraphicalObjectData();
ctObj.DomNode = node;
ctObj.uri = XmlHelper.ReadString(node.Attributes["uri"]);
ctObj.Any = new List<string>();
foreach (XmlNode childNode in node.ChildNodes)
Expand Down
42 changes: 39 additions & 3 deletions OpenXmlFormats/Spreadsheet/Styles/CT_Dxfs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace NPOI.OpenXmlFormats.Spreadsheet

public class CT_Dxfs
{

private Dictionary<int, string> dictAlternateContent = [];
private List<CT_Dxf> dxfField;

private uint countField;
Expand All @@ -23,12 +23,38 @@ public static CT_Dxfs Parse(XmlNode node, XmlNamespaceManager namespaceManager)
if (node == null)
return null;
CT_Dxfs ctObj = new CT_Dxfs();
ctObj.InnerXml = node.InnerXml;
ctObj.count = XmlHelper.ReadUInt(node.Attributes["count"]);
ctObj.dxfField = new List<CT_Dxf>();
int index = 0;
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.LocalName == "dxf")
ctObj.dxf.Add(CT_Dxf.Parse(childNode, namespaceManager));
else if(childNode.LocalName == "AlternateContent")
{
//styleSheet:dxfs maybe have schema like this
//mc:AlternateContent
// mc:Choice
// x:dxf
// mc:Fallback
// x:dxf
foreach (XmlNode acChildNode in childNode.ChildNodes)
{
if (acChildNode.LocalName == "Fallback")
{
foreach(XmlNode fbChild in acChildNode.ChildNodes)
{
if(fbChild.LocalName == "dxf")
{
ctObj.dxf.Add(CT_Dxf.Parse(fbChild, namespaceManager));
}
}
}
}
ctObj.dictAlternateContent.Add(index, childNode.OuterXml);
}
index ++;
}
return ctObj;
}
Expand All @@ -43,10 +69,17 @@ internal void Write(StreamWriter sw, string nodeName)
if (this.dxf.Count > 0)
{
sw.Write(">");
foreach (CT_Dxf x in this.dxf)
for(int i=0; i<this.dxf.Count;i++)
{
x.Write(sw, "dxf");
if(dictAlternateContent.TryGetValue(i, out string value))
sw.Write(value);
else
dxf[i].Write(sw, "dxf");
}
//foreach(CT_Dxf x in this.dxf)
//{
// x.Write(sw, "dxf");
//}
sw.Write(string.Format("</{0}>", nodeName));
}
else
Expand All @@ -59,6 +92,9 @@ internal void Write(StreamWriter sw, string nodeName)
public CT_Dxfs()
{
}

public string InnerXml { get; set;}

[XmlElement]
public List<CT_Dxf> dxf
{
Expand Down
228 changes: 137 additions & 91 deletions main/SS/UserModel/ClientAnchor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,127 +18,173 @@ namespace NPOI.SS.UserModel
{
public enum AnchorType : int
{
/**
* Move and Resize With Anchor Cells
* <p>
* Specifies that the current drawing shall move and
* resize to maintain its row and column anchors (i.e. the
* object is anchored to the actual from and to row and column)
* </p>
*/
/// <summary>
/// <para>
/// Move and Resize With Anchor Cells (0)
/// </para>
/// <para>
/// Specifies that the current Drawing shall Move and
/// resize to maintain its row and column anchors (i.e. the
/// object is anchored to the actual from and to row and column)
/// </para>
/// </summary>
MoveAndResize = 0,

/**
* Move With Cells but Do Not Resize
* <p>
* Specifies that the current drawing shall move with its
* row and column (i.e. the object is anchored to the
* actual from row and column), but that the size shall remain absolute.
* </p>
* <p>
* If Additional rows/columns are Added between the from and to locations of the drawing,
* the drawing shall move its to anchors as needed to maintain this same absolute size.
* </p>
*/
/// <summary>
/// <para>
/// Don't Move but do Resize With Anchor Cells (1)
/// </para>
/// <para>
/// Specifies that the current Drawing shall not Move with its
/// row and column, but should be resized. This option is not normally
/// used, but is included for completeness.
/// </para>
/// <para>
/// Note: Excel has no Setting for this combination, nor does the ECMA standard.
/// </para>
/// </summary>
DontMoveDoResize =1,

/// <summary>
/// <para>
/// Move With Cells but Do Not Resize (2)
/// </para>
/// <para>
/// Specifies that the current Drawing shall Move with its
/// row and column (i.e. the object is anchored to the
/// actual from row and column), but that the size shall remain absolute.
/// </para>
/// <para>
/// If additional rows/columns are added between the from and to locations of the Drawing,
/// the Drawing shall Move its to anchors as needed to maintain this same absolute size.
/// </para>
/// </summary>
MoveDontResize = 2,

/**
* Do Not Move or Resize With Underlying Rows/Columns
* <p>
* Specifies that the current start and end positions shall
* be maintained with respect to the distances from the
* absolute start point of the worksheet.
* </p>
* <p>
* If Additional rows/columns are Added before the
* drawing, the drawing shall move its anchors as needed
* to maintain this same absolute position.
* </p>
*/
/// <summary>
/// <para>
/// Do Not Move or Resize With Underlying Rows/Columns (3)
/// </para>
/// <para>
/// Specifies that the current start and end positions shall
/// be maintained with respect to the distances from the
/// absolute start point of the worksheet.
/// </para>
/// <para>
/// If additional rows/columns are added before the
/// Drawing, the Drawing shall Move its anchors as needed
/// to maintain this same absolute position.
/// </para>
/// </summary>
DontMoveAndResize = 3

}

/**
* A client anchor is attached to an excel worksheet. It anchors against a
* top-left and bottom-right cell.
*
* @author Yegor Kozlov
*/
/// <summary>
/// A client anchor is attached to an excel worksheet. It anchors against
/// absolute coordinates, a top-left cell and fixed height and width, or
/// a top-left and bottom-right cell, depending on the <see cref="AnchorType"/>:
/// <list type="number">
/// <item><description> <see cref="AnchorType.DontMoveAndResize" /> == absolute top-left coordinates and width/height, no cell references</description></item>
/// <item><description> <see cref="AnchorType.MoveDontResize" /> == fixed top-left cell reference, absolute width/height</description></item>
/// <item><description> <see cref="AnchorType.MoveAndResize" /> == fixed top-left and bottom-right cell references, dynamic width/height</description></item>
/// </list>
/// Note this class only reports the current values for possibly calculated positions and sizes.
/// If the sheet row/column sizes or positions shift, this needs updating via external calculations.
/// </summary>
public interface IClientAnchor
{

/**
* Returns the column (0 based) of the first cell.
*
* @return 0-based column of the first cell.
*/
/// <summary>
/// Get or set the column (0 based) of the first cell, or -1 if there is no top-left anchor cell.
/// This is the case for absolute positioning <see cref="AnchorType.MoveAndResize" />
/// </summary>
/// <return>0-based column of the first cell or -1 if none.</return>
int Col1 { get; set; }

/**
* Returns the column (0 based) of the second cell.
*
* @return 0-based column of the second cell.
*/
/// <summary>
/// Get or set the column (0 based) of the second cell, or -1 if there is no bottom-right anchor cell.
/// This is the case for absolute positioning (<see cref="AnchorType.DontMoveAndResize" />)
/// and absolute sizing (<see cref="AnchorType.MoveDontResize" />.
/// </summary>
/// <return>0-based column of the second cell or -1 if none.</return>
int Col2 { get; set; }

/**
* Returns the row (0 based) of the first cell.
*
* @return 0-based row of the first cell.
*/
/// <summary>
/// Get or set the row (0 based) of the first cell, or -1 if there is no bottom-right anchor cell.
/// This is the case for absolute positioning (<see cref="AnchorType.DontMoveAndResize" />).
/// </summary>
/// <return>0-based row of the first cell or -1 if none.</return>
int Row1 { get; set; }


/**
* Returns the row (0 based) of the second cell.
*
* @return 0-based row of the second cell.
*/
/// <summary>
/// Get or set the row (0 based) of the second cell, or -1 if there is no bottom-right anchor cell.
/// This is the case for absolute positioning (<see cref="AnchorType.DontMoveAndResize" />)
/// and absolute sizing (<see cref="AnchorType.MoveDontResize" />.
/// </summary>
/// <return>0-based row of the second cell or -1 if none.</return>
int Row2 { get; set; }


/**
* Returns the x coordinate within the first cell
*
* @return the x coordinate within the first cell
*/
/// <summary>
/// <para>
/// Get or set the x coordinate within the first cell.
/// </para>
/// <para>
/// Note - XSSF and HSSF have a slightly different coordinate
/// system, values in XSSF are larger by a factor of
/// <see cref="NPOI.Util.Units.EMU_PER_PIXEL" />
/// </para>
/// </summary>
/// <return>the x coordinate within the first cell</return>
int Dx1 { get; set; }


/**
* Returns the y coordinate within the first cell
*
* @return the y coordinate within the first cell
*/
/// <summary>
/// <para>
/// Get or set the y coordinate within the first cell
/// </para>
/// <para>
/// Note - XSSF and HSSF have a slightly different coordinate
/// system, values in XSSF are larger by a factor of
/// <see cref="NPOI.Util.Units.EMU_PER_PIXEL" />
/// </para>
/// </summary>
/// <return>the y coordinate within the first cell</return>
int Dy1 { get; set; }


/**
* Sets the y coordinate within the second cell
*
* @return the y coordinate within the second cell
*/
/// <summary>
/// <para>
/// Get or set the y coordinate within the second cell
/// </para>
/// <para>
/// Note - XSSF and HSSF have a slightly different coordinate
/// system, values in XSSF are larger by a factor of
/// <see cref="NPOI.Util.Units.EMU_PER_PIXEL" />
/// </para>
/// </summary>
/// <return>the y coordinate within the second cell</return>
int Dy2 { get; set; }

/**
* Returns the x coordinate within the second cell
*
* @return the x coordinate within the second cell
*/
/// <summary>
/// <para>
/// Get or set the x coordinate within the second cell
/// </para>
/// <para>
/// Note - XSSF and HSSF have a slightly different coordinate
/// system, values in XSSF are larger by a factor of
/// <see cref="NPOI.Util.Units.EMU_PER_PIXEL" />
/// </para>
/// </summary>
/// <return>the x coordinate within the second cell</return>
int Dx2 { get; set; }


/**
* s the anchor type
* <p>
* 0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.
* </p>
* @return the anchor type
* @see #MOVE_AND_RESIZE
* @see #MOVE_DONT_RESIZE
* @see #DONT_MOVE_AND_RESIZE
*/
/// <summary>
/// Get or set the anchor type
/// Changed from returning an int to an enum in POI 3.14 beta 1.
/// </summary>
/// <return>the anchor type</return>
AnchorType AnchorType { get; set; }

}
Expand Down
Loading
Loading