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

com.hfg.xml.msofficexml.xlsx.spreadsheetml.style.SsmlCellStyle Maven / Gradle / Ivy

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


import com.hfg.xml.msofficexml.xlsx.Xlsx;
import com.hfg.xml.msofficexml.xlsx.part.StylesPart;
import com.hfg.xml.msofficexml.xlsx.spreadsheetml.SsmlXML;
import com.hfg.xml.msofficexml.xlsx.spreadsheetml.SsmlXMLTag;


//------------------------------------------------------------------------------
/**
 Represents an Office Open XML spreadsheetml (<ssml:cellStyle>) tag.

 @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 class SsmlCellStyle extends SsmlXMLTag implements Cloneable
{
   private SsmlStyleFormat mStyleFormat;


   //---------------------------------------------------------------------------
   public SsmlCellStyle(Xlsx inXlsx)
   {
      this(inXlsx.getStylesPart());
   }

   //---------------------------------------------------------------------------
   public SsmlCellStyle(Xlsx inXlsx, String inName)
   {
      this(inXlsx.getStylesPart());
      setName(inName);
   }

   //---------------------------------------------------------------------------
   public SsmlCellStyle(StylesPart inStylesPart)
   {
      super(SsmlXML.CELL_STYLE, inStylesPart.getParentDoc());
      // Register with the styles part
      inStylesPart.defineCellStyle(this);
//      setBuiltinId(inStylesPart.defineCellStyle(this));

      setDefaults(inStylesPart);
   }

   //---------------------------------------------------------------------------
   private void setDefaults(StylesPart inStylesPart)
   {
      setStyleFormat(inStylesPart.getDefaultStyleFormat());
//      setStyleFormat(new SsmlStyleFormat(inStylesPart));

//      setAttribute(SsmlXML.CUSTOM_BUILTIN_ATT, "1");
   }

   //##########################################################################
   // PUBLIC METHODS
   //##########################################################################

   //---------------------------------------------------------------------------
   @Override
   public SsmlCellStyle clone()
   {
      SsmlCellStyle clone = (SsmlCellStyle) super.clone();

      // Register with the styles part
      getParentDoc().getStylesPart().defineCellStyle(clone);

      return clone;
   }

   //---------------------------------------------------------------------------
   public SsmlCellStyle setStyleFormat(SsmlStyleFormat inValue)
   {
      mStyleFormat = inValue;
      setAttribute(SsmlXML.STYLE_FORMAT_ID_ATT, inValue.getIndex());
      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlStyleFormat getStyleFormat()
   {
      return mStyleFormat;
   }

   //---------------------------------------------------------------------------
   public SsmlCellStyle setName(String inValue)
   {
      setAttribute(SsmlXML.NAME_ATT, inValue);
      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCellStyle setBuiltinId(int inValue)
   {
      setAttribute(SsmlXML.BUILTIN_ID_ATT, inValue);
      return this;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy