All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.xml.msofficexml.xlsx.spreadsheetDrawing.SsDrawDrawingAnchor Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.xml.msofficexml.xlsx.spreadsheetDrawing;


import com.hfg.graphics.units.GfxSize2D;
import com.hfg.graphics.units.GfxUnits;
import com.hfg.xml.XMLName;
import com.hfg.xml.XMLTag;
import com.hfg.xml.msofficexml.docx.drawingml.DmlShapeType;
import com.hfg.xml.msofficexml.xlsx.CellRef;
import com.hfg.xml.msofficexml.xlsx.Xlsx;
import com.hfg.xml.msofficexml.xlsx.spreadsheetml.SsmlXMLTag;

//------------------------------------------------------------------------------
/**
 Base class for Office Open XML spreadsheet drawing anchor tags.
 
@author J. Alex Taylor, hairyfatguy.com
*/ //------------------------------------------------------------------------------ // com.hfg XML/HTML Coding Library // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com // [email protected] //------------------------------------------------------------------------------ public abstract class SsDrawDrawingAnchor extends SsmlXMLTag { //--------------------------------------------------------------------------- public SsDrawDrawingAnchor(XMLName inName, Xlsx inParentDoc) { super(inName, inParentDoc); // The client data is just a stub for now. XMLTag clientDataTag = new XMLTag(SsDrawXML.CLIENT_DATA); addSubtag(clientDataTag); } //--------------------------------------------------------------------------- public SsDrawShape setShape(DmlShapeType inShapeType, GfxSize2D inSize2D) { SsDrawShape shape = new SsDrawShape(getParentDoc()); addSubtag(shape); shape.getShapeProperties().getOrCreateTransform().setWidth(inSize2D.getWidth()).setHeight(inSize2D.getHeight()); shape.getShapeProperties().getOrCreateTransform().setOffsetX(inSize2D.getWidth()).setOffsetY(inSize2D.getHeight()); // TODO: Necessary? shape.getShapeProperties().getOrCreatePresetGeometry().setShape(inShapeType); shape.getOrCreateStyle(); return shape; } //--------------------------------------------------------------------------- protected static void attachLocationSubtags(XMLTag inTag, CellRef inCellRef, GfxSize2D inOffsets) { XMLTag colTag = new XMLTag(SsDrawXML.COL); colTag.setContent(inCellRef.getColIndex()); inTag.addSubtag(colTag); XMLTag colOffsetTag = new XMLTag(SsDrawXML.COL_OFFSET); colOffsetTag.setContent(inOffsets != null ? inOffsets.getWidth().toInt(GfxUnits.dxa) : 0); inTag.addSubtag(colOffsetTag); XMLTag rowTag = new XMLTag(SsDrawXML.ROW); rowTag.setContent(inCellRef.getRowIndex()); inTag.addSubtag(rowTag); XMLTag rowOffsetTag = new XMLTag(SsDrawXML.ROW_OFFSET); rowOffsetTag.setContent(inOffsets != null ? inOffsets.getHeight().toInt(GfxUnits.dxa) : 0); inTag.addSubtag(rowOffsetTag); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy