001package com.hfg.xml.msofficexml.xlsx.part;
002
003import java.io.File;
004
005import com.hfg.xml.XMLTag;
006import com.hfg.xml.msofficexml.docx.RelationshipXML;
007import com.hfg.xml.msofficexml.docx.drawingml.DmlXML;
008import com.hfg.xml.msofficexml.xlsx.spreadsheetDrawing.WorksheetDrawing;
009import com.hfg.xml.msofficexml.part.OfficeXMLPart;
010import com.hfg.xml.msofficexml.xlsx.spreadsheetml.SsmlXML;
011
012//------------------------------------------------------------------------------
013/**
014 Represents an Office Open XML drawing part.
015
016 @author J. Alex Taylor, hairyfatguy.com
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
039public class SsmlDrawingPart extends OfficeXMLPart
040{
041   //###########################################################################
042   // PRIVATE FIELDS
043   //###########################################################################
044
045   private int                       mDrawingIndex;
046   private WorksheetPart             mParentWorksheetPart;
047
048   //###########################################################################
049   // CONSTRUCTORS
050   //###########################################################################
051
052   //---------------------------------------------------------------------------
053   public SsmlDrawingPart(WorksheetPart inParentWorksheetPart)
054   {
055      super(inParentWorksheetPart.getParentDoc());
056
057      mParentWorksheetPart = inParentWorksheetPart;
058
059      XMLTag rootNode = new WorksheetDrawing(this);
060
061      rootNode.addXMLNamespaceDeclaration(RelationshipXML.RELATIONSHIP_NAMESPACE);
062      rootNode.addXMLNamespaceDeclaration(DmlXML.DRAWINGML_NAMESPACE);
063
064      setRootNode(rootNode);
065   }
066
067   //###########################################################################
068   // PUBLIC METHODS
069   //###########################################################################
070
071   //---------------------------------------------------------------------------
072   public WorksheetPart getParentWorksheetPart()
073   {
074      return mParentWorksheetPart;
075   }
076
077   //---------------------------------------------------------------------------
078   public SsmlDrawingPart setDrawingIndex(int inValue)
079   {
080      mDrawingIndex = inValue;
081      return this;
082   }
083
084   //---------------------------------------------------------------------------
085   @Override
086   public File getFile()
087   {
088      return new File(SsmlXML.DRAWINGS_DIR, "drawing" + mDrawingIndex + ".xml");
089   }
090
091   //---------------------------------------------------------------------------
092   @Override
093   public WorksheetDrawing getRootNode()
094   {
095      WorksheetDrawing rootNode = (WorksheetDrawing) super.getRootNode();
096      if (null == rootNode)
097      {
098         rootNode = new WorksheetDrawing(this);
099         setRootNode(rootNode);
100      }
101
102      return rootNode;
103   }
104
105}