bug 23631: support for getting the current pane information in excel
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@437930 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2bbff11ea5
commit
d22cec2588
@ -70,6 +70,7 @@ import org.apache.poi.hssf.record.MulBlankRecord;
|
||||
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;
|
||||
@ -156,7 +157,7 @@ public class EventRecordFactory
|
||||
LeftMarginRecord.class, RightMarginRecord.class,
|
||||
TopMarginRecord.class, BottomMarginRecord.class,
|
||||
PaletteRecord.class, StringRecord.class, SharedFormulaRecord.class,
|
||||
WriteProtectRecord.class, FilePassRecord.class
|
||||
WriteProtectRecord.class, FilePassRecord.class, PaneRecord.class
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
|
||||
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;
|
||||
|
||||
@ -2383,7 +2385,7 @@ public class Sheet implements Model
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -2391,6 +2393,10 @@ public class Sheet implements Model
|
||||
*/
|
||||
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);
|
||||
@ -2422,7 +2428,7 @@ public class Sheet implements Model
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -2436,6 +2442,10 @@ public class Sheet implements Model
|
||||
*/
|
||||
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);
|
||||
@ -2452,6 +2462,19 @@ public class Sheet implements Model
|
||||
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()
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ public class RecordFactory
|
||||
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);
|
||||
|
@ -26,6 +26,7 @@ import org.apache.poi.hssf.model.Sheet;
|
||||
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;
|
||||
|
||||
@ -1076,7 +1077,7 @@ public class HSSFSheet
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -1092,7 +1093,7 @@ public class HSSFSheet
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@ -1102,7 +1103,7 @@ public class HSSFSheet
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -1118,6 +1119,14 @@ public class HSSFSheet
|
||||
{
|
||||
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.
|
||||
|
104
src/java/org/apache/poi/hssf/util/PaneInformation.java
Normal file
104
src/java/org/apache/poi/hssf/util/PaneInformation.java
Normal file
@ -0,0 +1,104 @@
|
||||
/* ====================================================================
|
||||
Copyright 2002-2004 Apache Software Foundation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.hssf.util;
|
||||
|
||||
/**
|
||||
* Holds information regarding a split plane or freeze plane for a sheet.
|
||||
*
|
||||
*/
|
||||
public class PaneInformation
|
||||
{
|
||||
/** Constant for active pane being the lower right*/
|
||||
public static final byte PANE_LOWER_RIGHT = (byte)0;
|
||||
/** Constant for active pane being the upper right*/
|
||||
public static final byte PANE_UPPER_RIGHT = (byte)1;
|
||||
/** Constant for active pane being the lower left*/
|
||||
public static final byte PANE_LOWER_LEFT = (byte)2;
|
||||
/** Constant for active pane being the upper left*/
|
||||
public static final byte PANE_UPPER_LEFT = (byte)3;
|
||||
|
||||
private short x;
|
||||
private short y;
|
||||
private short topRow;
|
||||
private short leftColumn;
|
||||
private byte activePane;
|
||||
private boolean frozen = false;
|
||||
|
||||
public PaneInformation(short x, short y, short top, short left, byte active, boolean frozen) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.topRow = top;
|
||||
this.leftColumn = left;
|
||||
this.activePane = active;
|
||||
this.frozen = frozen;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the vertical position of the split.
|
||||
* @return 0 if there is no vertical spilt,
|
||||
* or for a freeze pane the number of columns in the TOP pane,
|
||||
* or for a split plane the position of the split in 1/20th of a point.
|
||||
*/
|
||||
public short getVerticalSplitPosition() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the horizontal position of the split.
|
||||
* @return 0 if there is no horizontal spilt,
|
||||
* or for a freeze pane the number of rows in the LEFT pane,
|
||||
* or for a split plane the position of the split in 1/20th of a point.
|
||||
*/
|
||||
public short getHorizontalSplitPosition() {
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a horizontal split returns the top row in the BOTTOM pane.
|
||||
* @return 0 if there is no horizontal split, or the top row of the bottom pane.
|
||||
*/
|
||||
public short getHorizontalSplitTopRow() {
|
||||
return topRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a vertical split returns the left column in the RIGHT pane.
|
||||
* @return 0 if there is no vertical split, or the left column in the RIGHT pane.
|
||||
*/
|
||||
public short getVerticalSplitLeftColumn() {
|
||||
return leftColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the active pane
|
||||
* @see PANE_LOWER_RIGHT
|
||||
* @see PANE_UPPER_RIGHT
|
||||
* @see PANE_LOWER_LEFT
|
||||
* @see PANE_UPPER_LEFT
|
||||
* @return the active pane.
|
||||
*/
|
||||
public byte getActivePane() {
|
||||
return activePane;
|
||||
}
|
||||
|
||||
/** Returns true if this is a Freeze pane, false if it is a split pane.
|
||||
*/
|
||||
public boolean isFreezePane() {
|
||||
return frozen;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user