import org.apache.poi.hssf.record.MulRKRecord;
import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.NumberRecord;
+import org.apache.poi.hssf.record.PaneRecord;
import org.apache.poi.hssf.record.PaletteRecord;
import org.apache.poi.hssf.record.PasswordRecord;
import org.apache.poi.hssf.record.PasswordRev4Record;
LeftMarginRecord.class, RightMarginRecord.class,
TopMarginRecord.class, BottomMarginRecord.class,
PaletteRecord.class, StringRecord.class, SharedFormulaRecord.class,
- WriteProtectRecord.class, FilePassRecord.class
+ WriteProtectRecord.class, FilePassRecord.class, PaneRecord.class
};
}
import org.apache.poi.hssf.record.aggregates.RowRecordsAggregate;
import org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate;
import org.apache.poi.hssf.record.formula.Ptg;
+import org.apache.poi.hssf.util.PaneInformation;
+
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
}
/**
- * Creates a split (freezepane).
+ * Creates a split (freezepane). Any existing freezepane or split pane is overwritten.
* @param colSplit Horizonatal position of split.
* @param rowSplit Vertical position of split.
* @param topRow Top row visible in bottom pane
*/
public void createFreezePane(int colSplit, int rowSplit, int topRow, int leftmostColumn )
{
+ int paneLoc = findFirstRecordLocBySid(PaneRecord.sid);
+ if (paneLoc != -1)
+ records.remove(paneLoc);
+
int loc = findFirstRecordLocBySid(WindowTwoRecord.sid);
PaneRecord pane = new PaneRecord();
pane.setX((short)colSplit);
}
/**
- * Creates a split pane.
+ * Creates a split pane. Any existing freezepane or split pane is overwritten.
* @param xSplitPos Horizonatal position of split (in 1/20th of a point).
* @param ySplitPos Vertical position of split (in 1/20th of a point).
* @param topRow Top row visible in bottom pane
*/
public void createSplitPane(int xSplitPos, int ySplitPos, int topRow, int leftmostColumn, int activePane )
{
+ int paneLoc = findFirstRecordLocBySid(PaneRecord.sid);
+ if (paneLoc != -1)
+ records.remove(paneLoc);
+
int loc = findFirstRecordLocBySid(WindowTwoRecord.sid);
PaneRecord r = new PaneRecord();
r.setX((short)xSplitPos);
sel.setPane(PANE_LOWER_RIGHT);
}
+
+ /**
+ * Returns the information regarding the currently configured pane (split or freeze).
+ * @return null if no pane configured, or the pane information.
+ */
+ public PaneInformation getPaneInformation() {
+ PaneRecord rec = (PaneRecord)findFirstRecordBySid(PaneRecord.sid);
+ if (rec == null)
+ return null;
+
+ return new PaneInformation(rec.getX(), rec.getY(), rec.getTopRow(),
+ rec.getLeftColumn(), (byte)rec.getActivePane(), windowTwo.getFreezePanes());
+ }
public SelectionRecord getSelection()
{
ObjRecord.class, TextObjectRecord.class,
PaletteRecord.class, StringRecord.class, RecalcIdRecord.class, SharedFormulaRecord.class,
HorizontalPageBreakRecord.class, VerticalPageBreakRecord.class,
- WriteProtectRecord.class, FilePassRecord.class
+ WriteProtectRecord.class, FilePassRecord.class, PaneRecord.class
};
}
private static Map recordsMap = recordsToMap(records);
import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.util.Region;
+import org.apache.poi.hssf.util.PaneInformation;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
}
/**
- * Creates a split (freezepane).
+ * Creates a split (freezepane). Any existing freezepane or split pane is overwritten.
* @param colSplit Horizonatal position of split.
* @param rowSplit Vertical position of split.
* @param topRow Top row visible in bottom pane
}
/**
- * Creates a split (freezepane).
+ * Creates a split (freezepane). Any existing freezepane or split pane is overwritten.
* @param colSplit Horizonatal position of split.
* @param rowSplit Vertical position of split.
*/
}
/**
- * Creates a split pane.
+ * Creates a split pane. Any existing freezepane or split pane is overwritten.
* @param xSplitPos Horizonatal position of split (in 1/20th of a point).
* @param ySplitPos Vertical position of split (in 1/20th of a point).
* @param topRow Top row visible in bottom pane
{
getSheet().createSplitPane( xSplitPos, ySplitPos, topRow, leftmostColumn, activePane );
}
+
+ /**
+ * Returns the information regarding the currently configured pane (split or freeze).
+ * @return null if no pane configured, or the pane information.
+ */
+ public PaneInformation getPaneInformation() {
+ return getSheet().getPaneInformation();
+ }
/**
* Sets whether the gridlines are shown in a viewer.
--- /dev/null
+/* ====================================================================\r
+ Copyright 2002-2004 Apache Software Foundation\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+==================================================================== */\r
+\r
+package org.apache.poi.hssf.util;\r
+\r
+/**\r
+ * Holds information regarding a split plane or freeze plane for a sheet.\r
+ *\r
+ */\r
+public class PaneInformation\r
+{\r
+ /** Constant for active pane being the lower right*/\r
+ public static final byte PANE_LOWER_RIGHT = (byte)0;\r
+ /** Constant for active pane being the upper right*/\r
+ public static final byte PANE_UPPER_RIGHT = (byte)1;\r
+ /** Constant for active pane being the lower left*/\r
+ public static final byte PANE_LOWER_LEFT = (byte)2;\r
+ /** Constant for active pane being the upper left*/\r
+ public static final byte PANE_UPPER_LEFT = (byte)3;\r
+ \r
+ private short x;\r
+ private short y;\r
+ private short topRow;\r
+ private short leftColumn;\r
+ private byte activePane;\r
+ private boolean frozen = false;\r
+ \r
+ public PaneInformation(short x, short y, short top, short left, byte active, boolean frozen) {\r
+ this.x = x;\r
+ this.y = y;\r
+ this.topRow = top;\r
+ this.leftColumn = left;\r
+ this.activePane = active;\r
+ this.frozen = frozen;\r
+ }\r
+\r
+\r
+ /**\r
+ * Returns the vertical position of the split.\r
+ * @return 0 if there is no vertical spilt,\r
+ * or for a freeze pane the number of columns in the TOP pane,\r
+ * or for a split plane the position of the split in 1/20th of a point.\r
+ */\r
+ public short getVerticalSplitPosition() {\r
+ return x;\r
+ }\r
+ \r
+ /**\r
+ * Returns the horizontal position of the split.\r
+ * @return 0 if there is no horizontal spilt,\r
+ * or for a freeze pane the number of rows in the LEFT pane,\r
+ * or for a split plane the position of the split in 1/20th of a point.\r
+ */\r
+ public short getHorizontalSplitPosition() {\r
+ return y;\r
+ }\r
+ \r
+ /**\r
+ * For a horizontal split returns the top row in the BOTTOM pane.\r
+ * @return 0 if there is no horizontal split, or the top row of the bottom pane.\r
+ */\r
+ public short getHorizontalSplitTopRow() {\r
+ return topRow;\r
+ }\r
+ \r
+ /**\r
+ * For a vertical split returns the left column in the RIGHT pane.\r
+ * @return 0 if there is no vertical split, or the left column in the RIGHT pane.\r
+ */\r
+ public short getVerticalSplitLeftColumn() {\r
+ return leftColumn;\r
+ }\r
+ \r
+ /**\r
+ * Returns the active pane\r
+ * @see PANE_LOWER_RIGHT\r
+ * @see PANE_UPPER_RIGHT\r
+ * @see PANE_LOWER_LEFT\r
+ * @see PANE_UPPER_LEFT\r
+ * @return the active pane.\r
+ */\r
+ public byte getActivePane() {\r
+ return activePane;\r
+ }\r
+ \r
+ /** Returns true if this is a Freeze pane, false if it is a split pane.\r
+ */\r
+ public boolean isFreezePane() {\r
+ return frozen;\r
+ }\r
+}\r