001package com.hfg.xml.msofficexml.xlsx.part; 002 003 004import com.hfg.xml.msofficexml.OfficeOpenXmlRelationship; 005import com.hfg.xml.msofficexml.RelationshipType; 006import com.hfg.xml.msofficexml.part.OfficeOpenXmlRelationshipPart; 007import com.hfg.xml.msofficexml.xlsx.spreadsheetml.SsmlXML; 008 009import java.io.File; 010 011//------------------------------------------------------------------------------ 012/** 013 Represents an Office Open XML worksheet relationship part. 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 039public class WorksheetRelationshipPart extends OfficeOpenXmlRelationshipPart 040{ 041 private WorksheetPart mParentWorksheetPart; 042 043 //--------------------------------------------------------------------------- 044 public WorksheetRelationshipPart(WorksheetPart inParentWorksheetPart) 045 { 046 super(inParentWorksheetPart.getParentDoc()); 047 mParentWorksheetPart = inParentWorksheetPart; 048 } 049 050 //--------------------------------------------------------------------------- 051 @Override 052 public File getFile() 053 { 054 File worksheetRelsDir = new File(SsmlXML.WORKSHEETS_DIR, "_rels"); 055 056 return new File(worksheetRelsDir, mParentWorksheetPart.getFile().getName() + ".rels"); 057 } 058 059 //--------------------------------------------------------------------------- 060 public String addTable(TablePart inValue) 061 { 062 OfficeOpenXmlRelationship relationship = new OfficeOpenXmlRelationship(); 063 relationship.setPart(inValue) 064 .setType(RelationshipType.TABLE); 065 066 return addRelationship(relationship); 067 } 068 069 //--------------------------------------------------------------------------- 070 public String addDrawing(SsmlDrawingPart inValue) 071 { 072 OfficeOpenXmlRelationship relationship = new OfficeOpenXmlRelationship(); 073 relationship.setPart(inValue) 074 .setType(RelationshipType.DRAWING); 075 076 return addRelationship(relationship); 077 } 078 079}