View | Details | Raw Unified | Return to bug 46548
Collapse All | Expand All

(-)src/testcases/org/apache/poi/hssf/record/aggregates/TestPageSettingBlock.java (+40 lines)
Line 0 Link Here
1
package org.apache.poi.hssf.record.aggregates;
2
import junit.framework.TestCase;
3
4
import org.apache.poi.hssf.HSSFTestDataSamples;
5
import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
6
import org.apache.poi.hssf.usermodel.HSSFSheet;
7
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
8
import org.junit.Assert;
9
10
public class TestPageSettingBlock extends TestCase
11
{
12
	// PageSettingBlock in this file contains PLS (sid=x004D) record 
13
	// followed by ContinueRecord (sid=x003C)  
14
	private static final String PRINTSETTINGBLOCK_WITH_CONTINUE_RECORD_TEST_FILE = "46548.xls";
15
	
16
	public void testPrintSetup()
17
	{
18
		
19
		try
20
		{
21
			HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(PRINTSETTINGBLOCK_WITH_CONTINUE_RECORD_TEST_FILE);
22
			HSSFSheet sheet = wb.getSheetAt(0);
23
			HSSFPrintSetup ps = sheet.getPrintSetup();
24
			
25
			try
26
			{
27
				ps.getCopies();
28
			}
29
			catch(NullPointerException e)
30
			{
31
				e.printStackTrace();
32
				Assert.fail("PageSettingBlock missing PrintSetupRecord record");
33
			}
34
		}
35
		catch (Exception e) 
36
		{
37
			Assert.fail(e.getMessage());
38
		}
39
	}
40
}
(-)src/java/org/apache/poi/hssf/record/aggregates/PageSettingsBlock.java (+18 lines)
Lines 19-29 Link Here
19
19
20
import java.util.ArrayList;
20
import java.util.ArrayList;
21
import java.util.Iterator;
21
import java.util.Iterator;
22
import java.util.LinkedList;
22
import java.util.List;
23
import java.util.List;
23
24
24
import org.apache.poi.hssf.model.RecordStream;
25
import org.apache.poi.hssf.model.RecordStream;
25
import org.apache.poi.hssf.model.Sheet;
26
import org.apache.poi.hssf.model.Sheet;
26
import org.apache.poi.hssf.record.BottomMarginRecord;
27
import org.apache.poi.hssf.record.BottomMarginRecord;
28
import org.apache.poi.hssf.record.ContinueRecord;
27
import org.apache.poi.hssf.record.FooterRecord;
29
import org.apache.poi.hssf.record.FooterRecord;
28
import org.apache.poi.hssf.record.HCenterRecord;
30
import org.apache.poi.hssf.record.HCenterRecord;
29
import org.apache.poi.hssf.record.HeaderRecord;
31
import org.apache.poi.hssf.record.HeaderRecord;
Lines 60-65 Link Here
60
	private TopMarginRecord _topMargin;
62
	private TopMarginRecord _topMargin;
61
	private BottomMarginRecord _bottomMargin;
63
	private BottomMarginRecord _bottomMargin;
62
	private Record _pls;
64
	private Record _pls;
65
	private List<ContinueRecord> _pls_cont;
63
	private PrintSetupRecord printSetup;
66
	private PrintSetupRecord printSetup;
64
	private Record _bitmap;
67
	private Record _bitmap;
65
68
Lines 142-147 Link Here
142
				break;
145
				break;
143
			case 0x004D: // PLS
146
			case 0x004D: // PLS
144
				_pls = rs.getNext();
147
				_pls = rs.getNext();
148
				while( rs.peekNextSid()==ContinueRecord.sid)
149
				{
150
					if( _pls_cont==null)
151
					{
152
						_pls_cont = new LinkedList<ContinueRecord>();
153
					}
154
					_pls_cont.add((ContinueRecord)rs.getNext());
155
				}
145
				break;
156
				break;
146
			case PrintSetupRecord.sid:
157
			case PrintSetupRecord.sid:
147
				printSetup = (PrintSetupRecord)rs.getNext();
158
				printSetup = (PrintSetupRecord)rs.getNext();
Lines 202-207 Link Here
202
		visitIfPresent(_topMargin, rv);
213
		visitIfPresent(_topMargin, rv);
203
		visitIfPresent(_bottomMargin, rv);
214
		visitIfPresent(_bottomMargin, rv);
204
		visitIfPresent(_pls, rv);
215
		visitIfPresent(_pls, rv);
216
		if( _pls_cont!=null )
217
		{
218
			for( ContinueRecord cr : _pls_cont )
219
			{
220
				visitIfPresent(cr, rv);
221
			}
222
		}
205
		visitIfPresent(printSetup, rv);
223
		visitIfPresent(printSetup, rv);
206
		visitIfPresent(_bitmap, rv);
224
		visitIfPresent(_bitmap, rv);
207
	}
225
	}
(-)src/testcases/org/apache/poi/hssf/record/aggregates/AllRecordAggregateTests.java (+1 lines)
Lines 36-41 Link Here
36
		result.addTestSuite(TestRowRecordsAggregate.class);
36
		result.addTestSuite(TestRowRecordsAggregate.class);
37
		result.addTestSuite(TestSharedValueManager.class);
37
		result.addTestSuite(TestSharedValueManager.class);
38
		result.addTestSuite(TestValueRecordsAggregate.class);
38
		result.addTestSuite(TestValueRecordsAggregate.class);
39
		result.addTestSuite(TestPageSettingBlock.class);
39
		return result;
40
		return result;
40
	}
41
	}
41
}
42
}

Return to bug 46548