ASF Bugzilla – Attachment 2371 Details for
Bug 10884
[PATCH] Ability to read and set margins for sheets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for Sheet, HSSFSheet, BiffViewer, and RecordFactory for the new records
patch.txt (text/plain), 8.15 KB, created by
Shawn Laubach
on 2002-07-17 04:34:42 UTC
(
hide
)
Description:
Patch for Sheet, HSSFSheet, BiffViewer, and RecordFactory for the new records
Filename:
MIME Type:
Creator:
Shawn Laubach
Created:
2002-07-17 04:34:42 UTC
Size:
8.15 KB
patch
obsolete
>Index: src/java/org/apache/poi/hssf/dev/BiffViewer.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/dev/BiffViewer.java,v >retrieving revision 1.22 >diff -u -r1.22 BiffViewer.java >--- src/java/org/apache/poi/hssf/dev/BiffViewer.java 19 May 2002 18:50:37 -0000 1.22 >+++ src/java/org/apache/poi/hssf/dev/BiffViewer.java 17 Jul 2002 04:31:11 -0000 >@@ -609,7 +609,18 @@ > case LegendRecord.sid: > retval = new LegendRecord(rectype, size, data); > break; >- >+ case LeftMarginRecord.sid: >+ retval = new LeftMarginRecord(rectype, size, data); >+ break; >+ case RightMarginRecord.sid: >+ retval = new RightMarginRecord(rectype, size, data); >+ break; >+ case TopMarginRecord.sid: >+ retval = new TopMarginRecord(rectype, size, data); >+ break; >+ case BottomMarginRecord.sid: >+ retval = new BottomMarginRecord(rectype, size, data); >+ break; > > default: > retval = new UnknownRecord(rectype, size, data); >Index: src/java/org/apache/poi/hssf/model/Sheet.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/model/Sheet.java,v >retrieving revision 1.11 >diff -u -r1.11 Sheet.java >--- src/java/org/apache/poi/hssf/model/Sheet.java 15 Jul 2002 00:14:38 -0000 1.11 >+++ src/java/org/apache/poi/hssf/model/Sheet.java 17 Jul 2002 04:31:14 -0000 >@@ -92,6 +92,11 @@ > public class Sheet > extends java.lang.Object > { >+ public static final short LeftMargin = 0; >+ public static final short RightMargin = 1; >+ public static final short TopMargin = 2; >+ public static final short BottomMargin = 3; >+ > protected ArrayList records = null; > int preoffset = > 0; // offset of the sheet in a new file >@@ -2031,4 +2036,86 @@ > printGridlines = newPrintGridlines; > } > >+ /** >+ * Sets whether the sheet is selected >+ * @param sel True to select the sheet, false otherwise. >+ */ >+ public void setSelected(boolean sel) { >+ WindowTwoRecord windowTwo = (WindowTwoRecord) findFirstRecordBySid(WindowTwoRecord.sid); >+ windowTwo.setSelected(sel); >+ } >+ >+ /** >+ * Gets the size of the margin in inches. >+ * @param margin which margin to get >+ * @return the size of the margin >+ */ >+ public double getMargin(short margin) { >+ Margin m; >+ switch (margin) { >+ case LeftMargin : >+ m = (Margin)findFirstRecordBySid(LeftMarginRecord.sid); >+ if (m == null) >+ return .75; >+ break; >+ case RightMargin : >+ m = (Margin)findFirstRecordBySid(RightMarginRecord.sid); >+ if (m == null) >+ return .75; >+ break; >+ case TopMargin : >+ m = (Margin)findFirstRecordBySid(TopMarginRecord.sid); >+ if (m == null) >+ return 1.0; >+ break; >+ case BottomMargin : >+ m = (Margin)findFirstRecordBySid(BottomMarginRecord.sid); >+ if (m == null) >+ return 1.0; >+ break; >+ default : throw new RuntimeException("Unknown margin constant: " + margin); >+ } >+ return m.getMargin(); >+ } >+ >+ /** >+ * Sets the size of the margin in inches. >+ * @param margin which margin to get >+ * @param size the size of the margin >+ */ >+ public void setMargin(short margin, double size) { >+ Margin m; >+ switch (margin) { >+ case LeftMargin : >+ m = (Margin)findFirstRecordBySid(LeftMarginRecord.sid); >+ if (m == null) { >+ m = new LeftMarginRecord(); >+ records.add(getDimsLoc() + 1, (Record)m); >+ } >+ break; >+ case RightMargin : >+ m = (Margin)findFirstRecordBySid(RightMarginRecord.sid); >+ if (m == null) { >+ m = new RightMarginRecord(); >+ records.add(getDimsLoc() + 1, (Record)m); >+ } >+ break; >+ case TopMargin : >+ m = (Margin)findFirstRecordBySid(TopMarginRecord.sid); >+ if (m == null) { >+ m = new TopMarginRecord(); >+ records.add(getDimsLoc() + 1, (Record)m); >+ } >+ break; >+ case BottomMargin : >+ m = (Margin)findFirstRecordBySid(BottomMarginRecord.sid); >+ if (m == null) { >+ m = new BottomMarginRecord(); >+ records.add(getDimsLoc() + 1, (Record)m); >+ } >+ break; >+ default : throw new RuntimeException("Unknown margin constant: " + margin); >+ } >+ m.setMargin(size); >+ } > } >Index: src/java/org/apache/poi/hssf/record/RecordFactory.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/RecordFactory.java,v >retrieving revision 1.8 >diff -u -r1.8 RecordFactory.java >--- src/java/org/apache/poi/hssf/record/RecordFactory.java 10 May 2002 12:34:03 -0000 1.8 >+++ src/java/org/apache/poi/hssf/record/RecordFactory.java 17 Jul 2002 04:31:21 -0000 >@@ -107,7 +107,8 @@ > LabelRecord.class, BlankRecord.class, ColumnInfoRecord.class, > MulRKRecord.class, MulBlankRecord.class, MergeCellsRecord.class, > FormulaRecord.class, BoolErrRecord.class, ExternSheetRecord.class, >- NameRecord.class >+ NameRecord.class, LeftMarginRecord.class, RightMarginRecord.class, >+ TopMarginRecord.class, BottomMarginRecord.class > }; > } else { > records = new Class[] >@@ -135,7 +136,9 @@ > WindowTwoRecord.class, SelectionRecord.class, ContinueRecord.class, > LabelRecord.class, BlankRecord.class, ColumnInfoRecord.class, > MulRKRecord.class, MulBlankRecord.class, MergeCellsRecord.class, >- BoolErrRecord.class, ExternSheetRecord.class, NameRecord.class >+ BoolErrRecord.class, ExternSheetRecord.class, NameRecord.class, >+ LeftMarginRecord.class, RightMarginRecord.class, >+ TopMarginRecord.class, BottomMarginRecord.class > }; > > } >Index: src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java,v >retrieving revision 1.8 >diff -u -r1.8 HSSFSheet.java >--- src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java 10 May 2002 03:01:10 -0000 1.8 >+++ src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java 17 Jul 2002 04:31:26 -0000 >@@ -65,6 +65,7 @@ > import org.apache.poi.hssf.record.Record; > import org.apache.poi.hssf.record.RowRecord; > import org.apache.poi.hssf.record.VCenterRecord; >+import org.apache.poi.hssf.record.WindowTwoRecord; > import org.apache.poi.hssf.record.WSBoolRecord; > import org.apache.poi.hssf.util.Region; > import org.apache.poi.util.POILogFactory; >@@ -85,6 +86,12 @@ > { > private static final int DEBUG = POILogger.DEBUG; > >+ /* Constants for margins */ >+ public static final short LeftMargin = Sheet.LeftMargin; >+ public static final short RightMargin = Sheet.RightMargin; >+ public static final short TopMargin = Sheet.TopMargin; >+ public static final short BottomMargin = Sheet.BottomMargin; >+ > /** > * Used for compile-time optimization. This is the initial size for the collection of > * rows. It is currently set to 20. If you generate larger sheets you may benefit >@@ -784,5 +791,31 @@ > */ > public HSSFFooter getFooter() { > return new HSSFFooter(getSheet().getFooter()); >+ } >+ /** >+ * Sets whether sheet is selected. >+ * @param sel Whether to select the sheet or deselect the sheet. >+ */ >+ public void setSelected(boolean sel) { >+ getSheet().setSelected(sel); >+ >+ } >+ >+ /** >+ * Gets the size of the margin in inches. >+ * @param margin which margin to get >+ * @return the size of the margin >+ */ >+ public double getMargin(short margin) { >+ return getSheet().getMargin(margin); >+ } >+ >+ /** >+ * Sets the size of the margin in inches. >+ * @param margin which margin to get >+ * @param size the size of the margin >+ */ >+ public void setMargin(short margin, double size) { >+ getSheet().setMargin(margin, size); > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 10884
: 2371 |
2372
|
2439