001package com.hfg.xml.msofficexml.xlsx.spreadsheetDrawing;
002
003
004import com.hfg.graphics.units.GfxSize2D;
005import com.hfg.graphics.units.GfxUnits;
006import com.hfg.xml.XMLTag;
007import com.hfg.xml.msofficexml.xlsx.CellRef;
008import com.hfg.xml.msofficexml.xlsx.Xlsx;
009
010//------------------------------------------------------------------------------
011/**
012 Represents an Office Open XML worksheet shape (<xdr:twoCellAnchor>) tag.
013 <div>
014 @author J. Alex Taylor, hairyfatguy.com
015 </div>
016 */
017//------------------------------------------------------------------------------
018// com.hfg XML/HTML Coding Library
019//
020// This library is free software; you can redistribute it and/or
021// modify it under the terms of the GNU Lesser General Public
022// License as published by the Free Software Foundation; either
023// version 2.1 of the License, or (at your option) any later version.
024//
025// This library is distributed in the hope that it will be useful,
026// but WITHOUT ANY WARRANTY; without even the implied warranty of
027// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
028// Lesser General Public License for more details.
029//
030// You should have received a copy of the GNU Lesser General Public
031// License along with this library; if not, write to the Free Software
032// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
033//
034// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
035// jataylor@hairyfatguy.com
036//------------------------------------------------------------------------------
037
038public class SsDrawTwoCellAnchor extends SsDrawDrawingAnchor
039{
040   private XMLTag mFromTag;
041   private XMLTag mToTag;
042
043   public enum EditMode
044   {
045      absolute,
046      oneCell,
047      twoCell
048   }
049
050   //---------------------------------------------------------------------------
051   public SsDrawTwoCellAnchor(Xlsx inParentDoc)
052   {
053      super(SsDrawXML.TWO_CELL_ANCHOR, inParentDoc);
054      setEditMode(EditMode.absolute);
055   }
056
057   //---------------------------------------------------------------------------
058   /**
059    Specifies how the drawing should be moved and/or resized when the rows and columns
060    between the start and end anchors are resized, or when additional rows or columns are added.
061    Defaults to 'absolute'.
062    @param inValue EditMode enumeration value
063    */
064   public void setEditMode(EditMode inValue)
065   {
066      setAttribute(SsDrawXML.EDIT_AS_ATT, inValue.name());
067   }
068
069   //---------------------------------------------------------------------------
070   public SsDrawTwoCellAnchor setFrom(CellRef inCellRef, GfxSize2D inOffsets)
071   {
072      removeSubtagsByName(SsDrawXML.FROM);
073
074      mFromTag = new XMLTag(SsDrawXML.FROM);
075
076      attachLocationSubtags(mFromTag, inCellRef, inOffsets);
077
078      addSubtag(mFromTag);
079      return this;
080   }
081
082   //---------------------------------------------------------------------------
083   public SsDrawTwoCellAnchor setTo(CellRef inCellRef, GfxSize2D inOffsets)
084   {
085      removeSubtagsByName(SsDrawXML.TO);
086
087      mToTag = new XMLTag(SsDrawXML.TO);
088
089      attachLocationSubtags(mToTag, inCellRef, inOffsets);
090
091      addSubtag(mFromTag);
092      return this;
093   }
094}
095// <xdr:from><xdr:col>1</xdr:col><xdr:colOff>188640</xdr:colOff><xdr:row>1</xdr:row><xdr:rowOff>360</xdr:rowOff></xdr:from>
096// <xdr:to><xdr:col>1</xdr:col><xdr:colOff>1041120</xdr:colOff><xdr:row>1</xdr:row><xdr:rowOff>143640</xdr:rowOff></xdr:to>