001package com.hfg.xml.msofficexml.xlsx.spreadsheetDrawing; 002 003 004 005import com.hfg.xml.msofficexml.docx.drawingml.DmlXML; 006import com.hfg.xml.msofficexml.docx.drawingml.color.DmlSchemeColor; 007import com.hfg.xml.msofficexml.docx.drawingml.color.DmlSchemeColorValue; 008import com.hfg.xml.msofficexml.docx.drawingml.effect.DmlEffectRef; 009import com.hfg.xml.msofficexml.docx.drawingml.fill.DmlFillRef; 010import com.hfg.xml.msofficexml.docx.drawingml.font.DmlFontCollectionIndex; 011import com.hfg.xml.msofficexml.docx.drawingml.font.DmlFontRef; 012import com.hfg.xml.msofficexml.docx.drawingml.line.DmlLineRef; 013import com.hfg.xml.msofficexml.xlsx.Xlsx; 014import com.hfg.xml.msofficexml.xlsx.spreadsheetml.SsmlXMLTag; 015 016//------------------------------------------------------------------------------ 017/** 018 Represents an Office Open XML worksheet drawing shape style (<xdr:style>) tag. 019 <div> 020 @author J. Alex Taylor, hairyfatguy.com 021 </div> 022 */ 023//------------------------------------------------------------------------------ 024// com.hfg XML/HTML Coding Library 025// 026// This library is free software; you can redistribute it and/or 027// modify it under the terms of the GNU Lesser General Public 028// License as published by the Free Software Foundation; either 029// version 2.1 of the License, or (at your option) any later version. 030// 031// This library is distributed in the hope that it will be useful, 032// but WITHOUT ANY WARRANTY; without even the implied warranty of 033// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 034// Lesser General Public License for more details. 035// 036// You should have received a copy of the GNU Lesser General Public 037// License along with this library; if not, write to the Free Software 038// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 039// 040// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 041// jataylor@hairyfatguy.com 042//------------------------------------------------------------------------------ 043 044public class SsDrawShapeStyle extends SsmlXMLTag 045{ 046 private DmlLineRef mLineRef; 047 private DmlFillRef mFillRef; 048 private DmlEffectRef mEffectRef; 049 private DmlFontRef mFontRef; 050 051 //--------------------------------------------------------------------------- 052 public SsDrawShapeStyle(Xlsx inXlsx) 053 { 054 super(SsDrawXML.STYLE, inXlsx); 055 init(); 056 } 057 058 //--------------------------------------------------------------------------- 059 private void init() 060 { 061 // Be sure that the styles part is initialized 062 getParentDoc().getStylesPart(); 063 064 // Initialize reference tags 065 getLineRef().setIndex(0).setColorModel(new DmlSchemeColor(DmlSchemeColorValue.accentColor1)); 066 getFillRef().setIndex(0).setColorModel(new DmlSchemeColor(DmlSchemeColorValue.accentColor1)); 067 getEffectRef().setIndex(0).setColorModel(new DmlSchemeColor(DmlSchemeColorValue.accentColor1)); 068 getFontRef().setIndex(DmlFontCollectionIndex.minor).setColorModel(new DmlSchemeColor(DmlSchemeColorValue.lightColor1)); 069 } 070 071 //--------------------------------------------------------------------------- 072 /** 073 * Returns the line reference (<a:lnRef>) tag. 074 * @return the line reference (<a:lnRef>) for this shape tag 075 */ 076 public DmlLineRef getLineRef() 077 { 078 if (null == mLineRef) 079 { 080 // Check if it has been added via addSubtag()... 081 mLineRef = getOptionalSubtagByName(DmlXML.LINE_REF); 082 if (null == mLineRef) 083 { 084 mLineRef = new DmlLineRef(); 085 addSubtag(mLineRef); 086 } 087 } 088 089 return mLineRef; 090 } 091 092 //--------------------------------------------------------------------------- 093 /** 094 * Returns the fill reference (<a:fillRef>) tag. 095 * @return the fill reference (<a:fillRef>) for this shape tag 096 */ 097 public DmlFillRef getFillRef() 098 { 099 if (null == mFillRef) 100 { 101 // Check if it has been added via addSubtag()... 102 mFillRef = getOptionalSubtagByName(DmlXML.FILL_REF); 103 if (null == mFillRef) 104 { 105 mFillRef = new DmlFillRef(); 106 addSubtag(mFillRef); 107 } 108 } 109 110 return mFillRef; 111 } 112 113 //--------------------------------------------------------------------------- 114 /** 115 * Returns the effect reference (<a:effectRef>) tag. 116 * @return the effect reference (<a:effectRef>) for this shape tag 117 */ 118 public DmlEffectRef getEffectRef() 119 { 120 if (null == mEffectRef) 121 { 122 // Check if it has been added via addSubtag()... 123 mEffectRef = getOptionalSubtagByName(DmlXML.EFFECT_REF); 124 if (null == mEffectRef) 125 { 126 mEffectRef = new DmlEffectRef(); 127 addSubtag(mEffectRef); 128 } 129 } 130 131 return mEffectRef; 132 } 133 134 //--------------------------------------------------------------------------- 135 /** 136 * Returns the font reference (<a:fontRef>) tag. 137 * @return the font reference (<a:fontRef>) for this shape tag 138 */ 139 public DmlFontRef getFontRef() 140 { 141 if (null == mFontRef) 142 { 143 // Check if it has been added via addSubtag()... 144 mFontRef = getOptionalSubtagByName(DmlXML.FONT_REF); 145 if (null == mFontRef) 146 { 147 mFontRef = new DmlFontRef(); 148 addSubtag(mFontRef); 149 } 150 } 151 152 return mFontRef; 153 } 154 155}