public void TestReadWrite() { int size = _fileInformationBlock.GetSize(); byte[] buf = new byte[size]; _fileInformationBlock.Serialize(buf, 0); FileInformationBlock newFileInformationBlock = new FileInformationBlock(buf); FieldInfo[] fields = typeof(FileInformationBlock).BaseType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic); for (int x = 0; x < fields.Length; x++) { Assert.AreEqual(fields[x].GetValue(_fileInformationBlock), fields[x].GetValue(newFileInformationBlock)); } }
public void TestReadFields() { FileInformationBlock fib = _hWPFDocFixture._fib; byte[] tableStream = _hWPFDocFixture._tableStream; FieldsTables fieldsTables = new FieldsTables(tableStream, fib); Array values = Enum.GetValues(typeof(FieldsDocumentPart)); for (int i = 0; i < values.Length; i++) { FieldsDocumentPart part = (FieldsDocumentPart)values.GetValue(i); List <PlexOfField> fieldsPlexes = fieldsTables .GetFieldsPLCF(part); String result = DumpPlexes(fieldsPlexes); Assert.AreEqual(EXPECTED[i], result); } }
public HeaderStories(HWPFDocument doc) { this.headerStories = doc.GetHeaderStoryRange(); FileInformationBlock fib = doc.GetFileInformationBlock(); // If there's no PlcfHdd, nothing to do if (fib.GetCcpHdd() == 0) { return; } if (fib.GetPlcfHddSize() == 0) { return; } // Handle the PlcfHdd plcfHdd = new PlexOfCps( doc.GetTableStream(), fib.GetPlcfHddOffset(), fib.GetPlcfHddSize(), 0 ); }
public void TestReadWrite() { FileInformationBlock fib = _hWPFDocFixture._fib; byte[] tableStream = _hWPFDocFixture._tableStream; int fcSttbfffn = fib.GetFcSttbfffn(); int lcbSttbfffn = fib.GetLcbSttbfffn(); _fontTable = new FontTable(tableStream, fcSttbfffn, lcbSttbfffn); HWPFFileSystem fileSys = new HWPFFileSystem(); _fontTable.WriteTo(fileSys); HWPFStream tableOut = fileSys.GetStream("1Table"); byte[] newTableStream = tableOut.ToArray(); FontTable newFontTable = new FontTable(newTableStream, 0, newTableStream.Length); Assert.IsTrue(_fontTable.Equals(newFontTable)); }
/** * Adjust the value of the various FIB character count fields, eg * <code>FIB.CCPText</code> after an insert or a delete... * * Works on all CCP fields from this range onwards * * @param adjustment * The (signed) value that should be Added to the FIB CCP fields */ protected void AdjustFIB(int adjustment) { //Assert(_doc is HWPFDocument); // update the FIB.CCPText field (this should happen once per adjustment, // so we don't want it in // adjustForInsert() or it would get updated multiple times if the range // has a parent) // without this, OpenOffice.org (v. 2.2.x) does not see all the text in // the document //CPSplitCalculator cpS = ((HWPFDocument)_doc).GetCPSplitCalculator(); FileInformationBlock fib = _doc.GetFileInformationBlock(); // Do for each affected part //if (_start < cpS.GetMainDocumentEnd()) //{ // fib.SetCcpText(fib.GetCcpText() + adjustment); //} //if (_start < cpS.GetCommentsEnd()) //{ // fib.SetCcpAtn(fib.GetCcpAtn() + adjustment); //} //if (_start < cpS.GetEndNoteEnd()) //{ // fib.SetCcpEdn(fib.GetCcpEdn() + adjustment); //} //if (_start < cpS.GetFootnoteEnd()) //{ // fib.SetCcpFtn(fib.GetCcpFtn() + adjustment); //} //if (_start < cpS.GetHeaderStoryEnd()) //{ // fib.SetCcpHdd(fib.GetCcpHdd() + adjustment); //} //if (_start < cpS.GetHeaderTextboxEnd()) //{ // fib.SetCcpHdrTxtBx(fib.GetCcpHdrTxtBx() + adjustment); //} //if (_start < cpS.GetMainTextboxEnd()) //{ // fib.SetCcpTxtBx(fib.GetCcpTxtBx() + adjustment); //} int currentEnd = 0; foreach (SubdocumentType type in HWPFDocument.ORDERED) { int currentLength = fib.GetSubdocumentTextStreamLength(type); currentEnd += currentLength; // do we need to shift this part? if (_start > currentEnd) { continue; } fib.SetSubdocumentTextStreamLength(type, currentLength + adjustment); break; } }
public void TearDown() { _fileInformationBlock = null; _hWPFDocFixture = null; }