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

com.hfg.xml.msofficexml.xlsx.spreadsheetml.SsmlSheetFormatProperties Maven / Gradle / Ivy

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


import com.hfg.graphics.TextUtil;
import com.hfg.graphics.units.GfxSize;
import com.hfg.graphics.units.GfxUnits;
import com.hfg.graphics.units.Points;
import com.hfg.xml.msofficexml.xlsx.Xlsx;

//------------------------------------------------------------------------------
/**
 Represents an Office Open XML sheet format properties (<ssml:sheetFormatPr>) 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 SsmlSheetFormatProperties extends SsmlXMLTag
{

   //##########################################################################
   // CONSTRUCTORS
   //##########################################################################

   //---------------------------------------------------------------------------
   public SsmlSheetFormatProperties(Xlsx inXlsx)
   {
      super(SsmlXML.SHEET_FORMAT_PROPS, inXlsx);

      setDefaults();
   }

   //---------------------------------------------------------------------------
   private void setDefaults()
   {
      setBaseColWidth(10);
      setDefaultRowHeight(new Points(13));
   }

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


   //---------------------------------------------------------------------------
   /**
    Specifies the number of characters of the maximum digit width of the normal style's font.
    This value does not include margin padding or extra padding for gridlines. It is only the number of characters.
    
From 18.3.1.81 of the Ecma-376 Office Open XML specification
@param inValue width in number of characters of maximum digit width. @return this properties object to allow method chaining. */ public SsmlSheetFormatProperties setBaseColWidth(int inValue) { setAttribute(SsmlXML.BASE_COL_WIDTH_ATT, inValue); return this; } //--------------------------------------------------------------------------- /** Specifies the number of characters of the maximum digit width of the normal style's font. This value does not include margin padding or extra padding for gridlines. It is only the number of characters.
From 18.3.1.81 of the Ecma-376 Office Open XML specification
@param inValue width in number of characters of maximum digit width. @return this properties object to allow method chaining. */ public SsmlSheetFormatProperties setBaseColWidth(float inValue) { setAttribute(SsmlXML.BASE_COL_WIDTH_ATT, inValue); return this; } //--------------------------------------------------------------------------- /** Specifies the number of characters of the maximum digit width of the normal style's font. This value does not include margin padding or extra padding for gridlines. It is only the number of characters.
From 18.3.1.81 of the Ecma-376 Office Open XML specification
@param inValue width in a user-specified system of measure. @return this properties object to allow method chaining. */ public SsmlSheetFormatProperties setBaseColWidth(GfxSize inValue) { float maxDigitWidth = (float) TextUtil.getStringRect("9", getParentDoc().getStylesPart().getCellFormats().get(0).getFont().toFont()).getWidth(); // Truncate(({pixels}-5)/{Maximum Digit Width} * 100+0.5)/100 float width = (float) Math.nextDown((inValue.to(GfxUnits.pixels) - 5) / maxDigitWidth * 100f + 0.5) / 100f; return setBaseColWidth(width); } //--------------------------------------------------------------------------- /** Sets the default column width measured as the number of characters of the maximum digit width of the normal style's font.
From 18.3.1.81 of the Ecma-376 Office Open XML specification
@param inValue width in number of characters of maximum digit width. @return this properties object to allow method chaining. */ public SsmlSheetFormatProperties setDefaultColWidth(int inValue) { setAttribute(SsmlXML.DEFAULT_COL_WIDTH_ATT, inValue); return this; } //--------------------------------------------------------------------------- /** Sets the default column width measured as the number of characters of the maximum digit width of the normal style's font.
From 18.3.1.81 of the Ecma-376 Office Open XML specification
@param inValue width in number of characters of maximum digit width. @return this properties object to allow method chaining. */ public SsmlSheetFormatProperties setDefaultColWidth(float inValue) { setAttribute(SsmlXML.DEFAULT_COL_WIDTH_ATT, inValue); return this; } //--------------------------------------------------------------------------- /** Sets the default column width measured as the number of characters of the maximum digit width of the normal style's font.
From 18.3.1.81 of the Ecma-376 Office Open XML specification
@param inValue width in a user-specified system of measure. @return this properties object to allow method chaining. */ public SsmlSheetFormatProperties setDefaultColWidth(GfxSize inValue) { float digitWidth = (float) TextUtil.getStringRect("9", getParentDoc().getStylesPart().getCellFormats().get(0).getFont().toFont()).getWidth(); float pixels = inValue.to(GfxUnits.pixels) - 5; return setDefaultColWidth(pixels / digitWidth); } //--------------------------------------------------------------------------- /** Sets the default row height (in points).
From 18.3.1.81 of the Ecma-376 Office Open XML specification
@param inValue row height in points. @return this properties object to allow method chaining. */ public SsmlSheetFormatProperties setDefaultRowHeight(int inValue) { setAttribute(SsmlXML.DEFAULT_ROW_HEIGHT_ATT, inValue); return this; } //--------------------------------------------------------------------------- /** Sets the default row height (in points).
From 18.3.1.81 of the Ecma-376 Office Open XML specification
@param inValue row height in points. @return this properties object to allow method chaining. */ public SsmlSheetFormatProperties setDefaultRowHeight(float inValue) { setAttribute(SsmlXML.DEFAULT_ROW_HEIGHT_ATT, inValue); return this; } //--------------------------------------------------------------------------- /** Sets the default row height.
From 18.3.1.81 of the Ecma-376 Office Open XML specification
@param inValue height in a user-specified system of measure. @return this properties object to allow method chaining. */ public SsmlSheetFormatProperties setDefaultRowHeight(GfxSize inValue) { setAttribute(SsmlXML.DEFAULT_ROW_HEIGHT_ATT, inValue.to(GfxUnits.points)); return this; } //--------------------------------------------------------------------------- public SsmlSheetFormatProperties setCustomHeight(boolean inValue) { setAttribute(SsmlXML.CUSTOM_HEIGHT_ATT, inValue); return this; } //--------------------------------------------------------------------------- public SsmlSheetFormatProperties setZeroHeight(boolean inValue) { setAttribute(SsmlXML.ZERO_HEIGHT_ATT, inValue); return this; } //--------------------------------------------------------------------------- public SsmlSheetFormatProperties setThickTop(boolean inValue) { setAttribute(SsmlXML.THICK_TOP_ATT, inValue); return this; } //--------------------------------------------------------------------------- public SsmlSheetFormatProperties setThickBottom(boolean inValue) { setAttribute(SsmlXML.THICK_BOTTOM_ATT, inValue); return this; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy