001package com.hfg.xml.msofficexml.xlsx.spreadsheetDrawing;
002
003
004
005import com.hfg.xml.msofficexml.docx.RelationshipXML;
006import com.hfg.xml.msofficexml.docx.drawingml.DmlXML;
007import com.hfg.xml.msofficexml.xlsx.Xlsx;
008import com.hfg.xml.msofficexml.xlsx.part.SsmlDrawingPart;
009import com.hfg.xml.msofficexml.xlsx.spreadsheetml.SsmlXMLTag;
010
011//------------------------------------------------------------------------------
012/**
013 Represents an Office Open XML worksheet drawing (<xdr:wsDr>) tag.
014 <div>
015 @author J. Alex Taylor, hairyfatguy.com
016 </div>
017 */
018//------------------------------------------------------------------------------
019// com.hfg XML/HTML Coding Library
020//
021// This library is free software; you can redistribute it and/or
022// modify it under the terms of the GNU Lesser General Public
023// License as published by the Free Software Foundation; either
024// version 2.1 of the License, or (at your option) any later version.
025//
026// This library is distributed in the hope that it will be useful,
027// but WITHOUT ANY WARRANTY; without even the implied warranty of
028// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
029// Lesser General Public License for more details.
030//
031// You should have received a copy of the GNU Lesser General Public
032// License along with this library; if not, write to the Free Software
033// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
034//
035// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
036// jataylor@hairyfatguy.com
037//------------------------------------------------------------------------------
038/*
039  This is the root tag in a drawing part commonly found in xl/drawings/drawing1.xml (or drawing2.xml, etc.).
040  Simple example with a blue rectangle:
041<xdr:wsDr xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
042          xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
043  <xdr:twoCellAnchor editAs="absolute">
044    <xdr:from><xdr:col>1</xdr:col><xdr:colOff>188640</xdr:colOff><xdr:row>1</xdr:row><xdr:rowOff>360</xdr:rowOff></xdr:from>
045    <xdr:to><xdr:col>1</xdr:col><xdr:colOff>1041120</xdr:colOff><xdr:row>1</xdr:row><xdr:rowOff>143640</xdr:rowOff></xdr:to>
046    <xdr:sp>
047      <xdr:nvSpPr><xdr:cNvPr id="0" name="CustomShape 1"></xdr:cNvPr><xdr:cNvSpPr/></xdr:nvSpPr>
048      <xdr:spPr>
049        <a:xfrm><a:off x="1001160" y="162720"/><a:ext cx="852480" cy="143280"/></a:xfrm>
050        <a:prstGeom prst="rect"><a:avLst></a:avLst></a:prstGeom>
051        <a:solidFill><a:srgbClr val="729fcf"/></a:solidFill>
052        <a:ln><a:solidFill><a:srgbClr val="000000"/></a:solidFill></a:ln>
053      </xdr:spPr>
054      <xdr:style><a:lnRef idx="0"/><a:fillRef idx="0"/><a:effectRef idx="0"/><a:fontRef idx="minor"/></xdr:style>
055    </xdr:sp>
056    <xdr:clientData/>
057  </xdr:twoCellAnchor>
058</xdr:wsDr>
059*/
060public class WorksheetDrawing extends SsmlXMLTag
061{
062   private SsmlDrawingPart    mParentDrawingPart;
063
064   //###########################################################################
065   // CONSTRUCTORS
066   //###########################################################################
067
068   //---------------------------------------------------------------------------
069   public WorksheetDrawing(SsmlDrawingPart inParentDrawingPart)
070   {
071      super(SsDrawXML.WORKSHEET_DRAWING, (Xlsx) inParentDrawingPart.getParentDoc());
072
073      mParentDrawingPart = inParentDrawingPart;
074
075      addXMLNamespaceDeclaration(RelationshipXML.RELATIONSHIP_NAMESPACE);
076      addXMLNamespaceDeclaration(DmlXML.DRAWINGML_NAMESPACE);
077      addXMLNamespaceDeclaration(SsDrawXML.SPREADSHEET_DRAWING_NAMESPACE);
078
079   }
080
081   //###########################################################################
082   // PUBLIC METHODS
083   //###########################################################################
084
085   //---------------------------------------------------------------------------
086   public SsmlDrawingPart getParentDrawingPart()
087   {
088      return mParentDrawingPart;
089   }
090
091   //---------------------------------------------------------------------------
092   public void setDrawingAnchor(SsDrawDrawingAnchor inValue)
093   {
094      // TODO: Remove any pre-existing anchor tag
095      addSubtag(inValue);
096   }
097
098   //---------------------------------------------------------------------------
099   public SsDrawOneCellAnchor addOneCellDrawingAnchor()
100   {
101      // TODO: Remove any pre-existing anchor tag
102      SsDrawOneCellAnchor anchor = new SsDrawOneCellAnchor(getParentDoc());
103      addSubtag(anchor);
104      return anchor;
105   }
106
107   //---------------------------------------------------------------------------
108   public SsDrawTwoCellAnchor addTwoCellDrawingAnchor()
109   {
110      // TODO: Remove any pre-existing anchor tag
111      SsDrawTwoCellAnchor anchor = new SsDrawTwoCellAnchor(getParentDoc());
112      addSubtag(anchor);
113      return anchor;
114   }
115
116   //---------------------------------------------------------------------------
117   public SsDrawAbsoluteAnchor addAbsoluteDrawingAnchor()
118   {
119      // TODO: Remove any pre-existing anchor tag
120      SsDrawAbsoluteAnchor anchor = new SsDrawAbsoluteAnchor(getParentDoc());
121      addSubtag(anchor);
122      return anchor;
123   }
124
125}