6f9660620f
2006/02/10 14:25:14 os 1.3.4.2: #i59838# warnings removed 2005/10/13 09:53:20 os 1.3.4.1: #i53898# warnings removed
821 lines
20 KiB
C++
821 lines
20 KiB
C++
/*************************************************************************
|
||
*
|
||
* OpenOffice.org - a multi-platform office productivity suite
|
||
*
|
||
* $RCSfile: hwpread.cpp,v $
|
||
*
|
||
* $Revision: 1.4 $
|
||
*
|
||
* last change: $Author: hr $ $Date: 2006-06-20 00:55:15 $
|
||
*
|
||
* The Contents of this file are made available subject to
|
||
* the terms of GNU Lesser General Public License Version 2.1.
|
||
*
|
||
*
|
||
* GNU Lesser General Public License Version 2.1
|
||
* =============================================
|
||
* Copyright 2005 by Sun Microsystems, Inc.
|
||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||
*
|
||
* This library is free software; you can redistribute it and/or
|
||
* modify it under the terms of the GNU Lesser General Public
|
||
* License version 2.1, as published by the Free Software Foundation.
|
||
*
|
||
* This library is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
* Lesser General Public License for more details.
|
||
*
|
||
* You should have received a copy of the GNU Lesser General Public
|
||
* License along with this library; if not, write to the Free Software
|
||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||
* MA 02111-1307 USA
|
||
*
|
||
************************************************************************/
|
||
|
||
/* $Id: hwpread.cpp,v 1.4 2006-06-20 00:55:15 hr Exp $ */
|
||
|
||
#include "precompile.h"
|
||
|
||
#include "list.hxx"
|
||
|
||
#include "hwpfile.h"
|
||
#include "hbox.h"
|
||
#include "hpara.h"
|
||
#include "drawing.h"
|
||
#include "htags.h"
|
||
#include "hcode.h"
|
||
|
||
static short fboxnum = 1;
|
||
static int zindex = 1;
|
||
static int lnnumber = 0;
|
||
|
||
int HBox::Read(HWPFile & )
|
||
{
|
||
// already read
|
||
return 1;
|
||
}
|
||
|
||
|
||
// skip block
|
||
|
||
int SkipBlock::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read4b(&data_block_len, 1);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(IS_SP_SKIP_BLOCK(hh) && (hh == dummy))){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
|
||
data_block = new char[data_block_len];
|
||
|
||
return hwpf.Read1b(data_block, data_block_len);
|
||
}
|
||
|
||
|
||
// Field code(5)
|
||
int FieldCode::Read(HWPFile & hwpf)
|
||
{
|
||
ulong size;
|
||
hchar dummy;
|
||
ulong len1; /* hcharŸ<72><C5B8><EFBFBD><EFBFBD> <20><><EFBFBD>ڿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #1<><31> <20><><EFBFBD><EFBFBD> */
|
||
ulong len2; /* hcharŸ<72><C5B8><EFBFBD><EFBFBD> <20><><EFBFBD>ڿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #2<><32> <20><><EFBFBD><EFBFBD> */
|
||
ulong len3; /* hcharŸ<72><C5B8><EFBFBD><EFBFBD> <20><><EFBFBD>ڿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #3<><33> <20><><EFBFBD><EFBFBD> */
|
||
ulong binlen; /* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>̳ʸ<CCB3> <20><><EFBFBD><EFBFBD>Ÿ <20><><EFBFBD><EFBFBD> */
|
||
|
||
hwpf.Read4b(&size, 1);
|
||
hwpf.Read2b(&dummy, 1);
|
||
hwpf.Read1b(&type, 2);
|
||
hwpf.Read4b(reserved1, 1);
|
||
hwpf.Read2b(&location_info, 1);
|
||
hwpf.Read1b(reserved2, 22);
|
||
hwpf.Read4b(&len1, 1);
|
||
hwpf.Read4b(&len2, 1);
|
||
hwpf.Read4b(&len3, 1);
|
||
hwpf.Read4b(&binlen, 1);
|
||
|
||
str1 = new hchar[len1];
|
||
str2 = new hchar[len2];
|
||
str3 = new hchar[len3];
|
||
bin = new char[binlen];
|
||
|
||
hwpf.Read2b(str1, len1/2);
|
||
hwpf.Read2b(str2, len2/2);
|
||
hwpf.Read2b(str3, len3/2);
|
||
|
||
hwpf.ReadBlock(bin, binlen);
|
||
|
||
if( type[0] == 3 && type[1] == 2 ){ /* <20><><EFBFBD>糯¥<E7B3AF>μ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD> <20>Ѵ<EFBFBD>. */
|
||
DateCode *pDate = new DateCode;
|
||
for( int i = 0 ;i < (int)(len3/2) ; i++ ){
|
||
if(str3[i] == 0 ) break;
|
||
if( i >= DATE_SIZE ) break;
|
||
pDate->format[i] = str3[i];
|
||
}
|
||
hwpf.AddDateFormat(pDate);
|
||
m_pDate = pDate;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
|
||
// book mark(6)
|
||
int Bookmark::Read(HWPFile & hwpf)
|
||
{
|
||
long len;
|
||
|
||
hwpf.Read4b(&len, 1);
|
||
dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
|
||
|
||
if (!(len == 34))// 2 * (BMK_COMMENT_LEN + 1) + 2
|
||
{
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
if (!(hh == dummy && dummy == CH_BOOKMARK)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
|
||
hwpf.Read2b(id, BMK_COMMENT_LEN + 1);
|
||
hwpf.Read2b(&type, 1);
|
||
//return hwpf.Read2b(&type, 1);
|
||
return 1;
|
||
}
|
||
|
||
|
||
// date format(7)
|
||
|
||
int DateFormat::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(format, DATE_SIZE);
|
||
dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
|
||
if (!(hh == dummy && CH_DATE_FORM == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
return true;
|
||
}
|
||
|
||
|
||
// date code(8)
|
||
|
||
int DateCode::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(format, DATE_SIZE);
|
||
hwpf.Read2b(date, 6);
|
||
dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
|
||
if (!(hh == dummy && CH_DATE_CODE == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
hwpf.AddDateFormat(this);
|
||
return true;
|
||
}
|
||
|
||
|
||
// tab(9)
|
||
|
||
int Tab::Read(HWPFile & hwpf)
|
||
{
|
||
width = hwpf.Read2b();
|
||
leader = sal::static_int_cast<unsigned short>(hwpf.Read2b());
|
||
dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
|
||
if (!(hh == dummy && CH_TAB == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
return true;
|
||
}
|
||
|
||
|
||
// tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
|
||
|
||
static void UpdateBBox(FBox * fbox)
|
||
{
|
||
fbox->boundsy = fbox->pgy;
|
||
fbox->boundey = fbox->pgy + fbox->ys - 1;
|
||
}
|
||
|
||
|
||
void Cell::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(&p, 1);
|
||
hwpf.Read2b(&color, 1);
|
||
hwpf.Read2b(&x, 1);
|
||
hwpf.Read2b(&y, 1);
|
||
hwpf.Read2b(&w, 1);
|
||
hwpf.Read2b(&h, 1);
|
||
hwpf.Read2b(&txthigh, 1);
|
||
hwpf.Read2b(&cellhigh, 1);
|
||
|
||
hwpf.Read1b(&flag, 1);
|
||
hwpf.Read1b(&changed, 1);
|
||
hwpf.Read1b(&used, 1);
|
||
hwpf.Read1b(&ver_align, 1);
|
||
hwpf.Read1b(linetype, 4);
|
||
hwpf.Read1b(&shade, 1);
|
||
hwpf.Read1b(&diagonal, 1);
|
||
hwpf.Read1b(&protect, 1);
|
||
}
|
||
|
||
|
||
int TxtBox::Read(HWPFile & hwpf)
|
||
{
|
||
int ii, ncell;
|
||
|
||
hwpf.Read2b(reserved, 2);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy && CH_TEXT_BOX == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
hwpf.AddBox(this);
|
||
hwpf.Read2b(&style.cap_len, 1);
|
||
hwpf.Read2b(&dummy1, 1);
|
||
hwpf.Read2b(&next, 1);
|
||
hwpf.Read2b(&dummy2, 1);
|
||
|
||
style.boxnum = fboxnum++;
|
||
zorder = zindex++;
|
||
hwpf.Read1b(&style.anchor_type, 1);
|
||
hwpf.Read1b(&style.txtflow, 1);
|
||
hwpf.Read2b(&style.xpos, 1);
|
||
hwpf.Read2b(&style.ypos, 1);
|
||
hwpf.Read2b(&option, 1);
|
||
hwpf.Read2b(&ctrl_ch, 1);
|
||
hwpf.Read2b(style.margin, 12);
|
||
hwpf.AddFBoxStyle(&style);
|
||
hwpf.Read2b(&box_xs, 1);
|
||
hwpf.Read2b(&box_ys, 1);
|
||
hwpf.Read2b(&cap_xs, 1);
|
||
hwpf.Read2b(&cap_ys, 1);
|
||
hwpf.Read2b(&style.cap_len, 1);
|
||
hwpf.Read2b(&xs, 1);
|
||
hwpf.Read2b(&ys, 1);
|
||
hwpf.Read2b(&cap_margin, 1);
|
||
hwpf.Read1b(&xpos_type, 1);
|
||
hwpf.Read1b(&ypos_type, 1);
|
||
hwpf.Read1b(&smart_linesp, 1);
|
||
hwpf.Read1b(&reserved1, 1);
|
||
hwpf.Read2b(&pgx, 1);
|
||
hwpf.Read2b(&pgy, 1);
|
||
hwpf.Read2b(&pgno, 1);
|
||
if( ( pgno +1 ) != hwpf.getCurrentPage() )
|
||
pgno = sal::static_int_cast<short>(hwpf.getCurrentPage() -1) ;
|
||
|
||
hwpf.Read2b(&showpg, 1);
|
||
hwpf.Read2b(&cap_pos, 1);
|
||
hwpf.Read2b(&num, 1);
|
||
hwpf.Read2b(&dummy3, 1);
|
||
hwpf.Read2b(&baseline, 1);
|
||
hwpf.Read2b(&type, 1);
|
||
hwpf.Read2b(&nCell, 1);
|
||
hwpf.Read2b(&protect, 1);
|
||
switch (type)
|
||
{
|
||
case 0: //table
|
||
style.boxtype = 'T';
|
||
break;
|
||
case 1: // text-box
|
||
style.boxtype = 'X';
|
||
break;
|
||
case 2: // equation
|
||
style.boxtype = 'E';
|
||
break;
|
||
case 3: // button
|
||
style.boxtype = 'B';
|
||
break;
|
||
default: // other
|
||
style.boxtype = 'O';
|
||
break;
|
||
}
|
||
|
||
UpdateBBox(this);
|
||
|
||
ncell = NCell();
|
||
if (!(ncell > 0)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
|
||
cell = new Cell[ncell];
|
||
for (ii = 0; ii < ncell; ii++)
|
||
{
|
||
cell[ii].Read(hwpf);
|
||
cell[ii].key = sal::static_int_cast<unsigned char>(ii);
|
||
}
|
||
if (ncell == 1)
|
||
style.cell = &cell[0];
|
||
plists = new LinkedList < HWPPara >[ncell];
|
||
for (ii = 0; ii < ncell; ii++)
|
||
hwpf.ReadParaList(plists[ii]);
|
||
// caption
|
||
hwpf.ReadParaList(caption);
|
||
|
||
if( type == 0 ){ // if table?
|
||
Table *tbl = new Table;
|
||
for( ii = 0 ; ii < ncell; ii++)
|
||
{
|
||
tbl->columns.insert(cell[ii].x);
|
||
tbl->columns.insert(cell[ii].x + cell[ii].w);
|
||
tbl->rows.insert(cell[ii].y);
|
||
tbl->rows.insert(cell[ii].y + cell[ii].h);
|
||
}
|
||
TCell* *pArr = new TCell*[ncell];
|
||
for( ii = 0 ; ii < ncell; ii++)
|
||
{
|
||
TCell *tcell = new TCell;
|
||
tcell->nColumnIndex = tbl->columns.getIndex(cell[ii].x);
|
||
tcell->nColumnSpan = tbl->columns.getIndex(cell[ii].x + cell[ii].w) -
|
||
tcell->nColumnIndex;
|
||
tcell->nRowIndex = tbl->rows.getIndex(cell[ii].y);
|
||
tcell->nRowSpan = tbl->rows.getIndex(cell[ii].y + cell[ii].h) -
|
||
tcell->nRowIndex;
|
||
tcell->pCell = &cell[ii];
|
||
pArr[ii] = tcell;
|
||
}
|
||
TCell *tmp;
|
||
// Sort by row and column
|
||
for( ii = 0 ; ii < ncell - 1; ii++ ){
|
||
for( int jj = ii ; jj < ncell ; jj++){
|
||
if( pArr[ii]->nRowIndex > pArr[jj]->nRowIndex ){
|
||
tmp = pArr[ii];
|
||
pArr[ii] = pArr[jj];
|
||
pArr[jj] = tmp;
|
||
}
|
||
}
|
||
for( int kk = ii ; kk > 0 ; kk--){
|
||
if( ( pArr[kk]->nRowIndex == pArr[kk-1]->nRowIndex ) &&
|
||
(pArr[kk]->nColumnIndex < pArr[kk-1]->nColumnIndex )){
|
||
tmp = pArr[kk];
|
||
pArr[kk] = pArr[kk-1];
|
||
pArr[kk-1] = tmp;
|
||
}
|
||
}
|
||
}
|
||
for( ii = 0 ; ii < ncell ; ii++ ){
|
||
tbl->cells.insert(pArr[ii]);
|
||
}
|
||
tbl->box = this;
|
||
hwpf.AddTable(tbl);
|
||
m_pTable = tbl;
|
||
delete[] pArr;
|
||
}
|
||
else
|
||
m_pTable = 0L;
|
||
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// picture(11)
|
||
int Picture::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(reserved, 2);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy && CH_PICTURE == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
hwpf.AddBox(this);
|
||
|
||
hwpf.Read4b(&follow_block_size, 1);
|
||
hwpf.Read2b(&dummy1, 1); /* <20><><EFBFBD><EFBFBD> 4<><34><EFBFBD><EFBFBD>Ʈ */
|
||
hwpf.Read2b(&dummy2, 1);
|
||
|
||
style.boxnum = fboxnum++;
|
||
zorder = zindex++;
|
||
hwpf.Read1b(&style.anchor_type, 1); /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ */
|
||
hwpf.Read1b(&style.txtflow, 1); /* <20><EFBFBD><D7B8><EFBFBD><EFBFBD><EFBFBD>. 0-2(<28>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>,<2C><><EFBFBD>︲) */
|
||
hwpf.Read2b(&style.xpos, 1); /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ : 1 <20><><EFBFBD><EFBFBD>, 2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 3 <20><><EFBFBD>, <20>̿<EFBFBD> = <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&style.ypos, 1); /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ : 1 <20><>, 2 <20>Ʒ<EFBFBD>, 3 <20><><EFBFBD>, <20>̿<EFBFBD> <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&option, 1); /* <20><>Ÿ<EFBFBD>ɼ<EFBFBD> : <20>θ<D7B5>,<2C><EFBFBD><D7B8><EFBFBD><EFBFBD><EFBFBD>,<2C><>. bit<69><74> <20><><EFBFBD><EFBFBD>. */
|
||
hwpf.Read2b(&ctrl_ch, 1); /* <20><EFBFBD> 11 */
|
||
hwpf.Read2b(style.margin, 12); /* <20><><EFBFBD><EFBFBD> : [0-2][] out/in/<2F><>,[][0-3] <20><>/<2F><><EFBFBD><EFBFBD>/<2F><>/<2F>Ʒ<EFBFBD> <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&box_xs, 1); /* <20>ڽ<EFBFBD>ũ<EFBFBD><C5A9> <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&box_ys, 1); /* <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&cap_xs, 1); /* ĸ<><C4B8> ũ<><C5A9> <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&cap_ys, 1); /* <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&style.cap_len, 1); /* <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&xs, 1); /* <20><>ü ũ<><C5A9>(<28>ڽ<EFBFBD> ũ<><C5A9> + ĸ<><C4B8> + <20><><EFBFBD><EFBFBD>) <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&ys, 1); /* <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&cap_margin, 1); /* ĸ<><C4B8> <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read1b(&xpos_type, 1);
|
||
hwpf.Read1b(&ypos_type, 1);
|
||
hwpf.Read1b(&smart_linesp, 1); /* <20>ٰ<EFBFBD><D9B0><EFBFBD> <20><>ȣ : 0 <20>̺<EFBFBD>ȣ, 1 <20><>ȣ */
|
||
hwpf.Read1b(&reserved1, 1);
|
||
hwpf.Read2b(&pgx, 1); /* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڽ<EFBFBD> <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&pgy, 1); /* <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&pgno, 1); /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : 0<><30><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&showpg, 1); /* <20>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||
hwpf.Read2b(&cap_pos, 1); /* ĸ<><C4B8><EFBFBD><EFBFBD>ġ 0 - 7 <20><EFBFBD><DEB4><EFBFBD><EFBFBD><EFBFBD>. */
|
||
hwpf.Read2b(&num, 1); /* <20>ڽ<EFBFBD><DABD><EFBFBD>ȣ 0<><30><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD> <20>ű<EFBFBD><C5B1>Ϸù<CFB7>ȣ */
|
||
|
||
hwpf.Read1b(&pictype, 1); /* <20><EFBFBD><D7B8><EFBFBD><EFBFBD><EFBFBD> */
|
||
|
||
skip[0] = (short) hwpf.Read2b(); /* <20><EFBFBD><D7B8><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ǥ<>ø<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ġ <20><><EFBFBD><EFBFBD> */
|
||
skip[1] = (short) hwpf.Read2b(); /* <20><><EFBFBD><EFBFBD> */
|
||
scale[0] = (short) hwpf.Read2b(); /* Ȯ<><C8AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : 0 <20><><EFBFBD><EFBFBD>, <20>̿<EFBFBD> <20>ۼ<EFBFBD>Ʈ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
|
||
scale[1] = (short) hwpf.Read2b(); /* <20><><EFBFBD><EFBFBD> */
|
||
|
||
hwpf.Read1b(picinfo.picun.path, 256); /* <20><EFBFBD><D7B8><EFBFBD><EFBFBD><EFBFBD> <20≯<EFBFBD> : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Drawing<6E><67> <20>ƴҶ<C6B4>. */
|
||
hwpf.Read1b(reserved3, 9); /* <20><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD>/<2F><EFBFBD>ȿ<EFBFBD><C8BF> <20><> */
|
||
|
||
UpdateBBox(this);
|
||
if( pictype != PICTYPE_DRAW )
|
||
style.cell = reserved3;
|
||
|
||
if (follow_block_size != 0)
|
||
{
|
||
follow = new unsigned char[follow_block_size];
|
||
|
||
hwpf.Read1b(follow, follow_block_size);
|
||
if (pictype == PICTYPE_DRAW)
|
||
{
|
||
hmem = new HMemIODev((char *) follow, follow_block_size);
|
||
LoadDrawingObjectBlock(this);
|
||
style.cell = picinfo.picdraw.hdo;
|
||
delete hmem;
|
||
|
||
hmem = 0;
|
||
}
|
||
else
|
||
{
|
||
if ((follow[3] << 24 | follow[2] << 16 | follow[1] << 8 | follow[0]) == 0x269)
|
||
{
|
||
ishyper = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
if( pictype != 3 )
|
||
style.boxtype = 'G';
|
||
else
|
||
style.boxtype = 'D';
|
||
hwpf.AddFBoxStyle(&style);
|
||
|
||
// cation
|
||
hwpf.ReadParaList(caption);
|
||
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// line(15)
|
||
|
||
Line::Line():FBox(CH_LINE)
|
||
{
|
||
}
|
||
|
||
|
||
int Line::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(reserved, 2);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy && CH_LINE == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
hwpf.AddBox(this);
|
||
|
||
style.boxnum = fboxnum++;
|
||
zorder = zindex++;
|
||
style.boxtype = 'L';
|
||
hwpf.Read1b(&reserved2, 8);
|
||
hwpf.Read1b(&style.anchor_type, 1);
|
||
hwpf.Read1b(&style.txtflow, 1);
|
||
hwpf.Read2b(&style.xpos, 1);
|
||
hwpf.Read2b(&style.ypos, 1);
|
||
hwpf.Read2b(&option, 1);
|
||
hwpf.Read2b(&ctrl_ch, 1);
|
||
hwpf.Read2b(style.margin, 12);
|
||
hwpf.AddFBoxStyle(&style);
|
||
hwpf.Read2b(&box_xs, 1);
|
||
hwpf.Read2b(&box_ys, 1);
|
||
hwpf.Read2b(&cap_xs, 1);
|
||
hwpf.Read2b(&cap_ys, 1);
|
||
hwpf.Read2b(&style.cap_len, 1);
|
||
hwpf.Read2b(&xs, 1);
|
||
hwpf.Read2b(&ys, 1);
|
||
lnnumber = style.boxnum;
|
||
hwpf.linenumber = 1;
|
||
hwpf.Read2b(&boundsy, 1);
|
||
hwpf.Read2b(&boundey, 1);
|
||
hwpf.Read1b(&boundx, 1);
|
||
hwpf.Read1b(&draw, 1);
|
||
|
||
hwpf.Read2b(&pgx, 1);
|
||
hwpf.Read2b(&pgy, 1);
|
||
hwpf.Read2b(&pgno, 1);
|
||
hwpf.Read2b(&showpg, 1);
|
||
|
||
hwpf.Read2b(&sx, 1);
|
||
hwpf.Read2b(&sy, 1);
|
||
hwpf.Read2b(&ex, 1);
|
||
hwpf.Read2b(&sy, 1);
|
||
hwpf.Read2b(&width, 1);
|
||
hwpf.Read2b(&shade, 1);
|
||
hwpf.Read2b(&color, 1);
|
||
style.xpos = width;
|
||
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// hidden(15)
|
||
Hidden::Hidden():HBox(CH_HIDDEN)
|
||
{
|
||
}
|
||
|
||
|
||
int Hidden::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(reserved, 2);
|
||
hwpf.Read2b(&dummy, 1);
|
||
if (!(hh == dummy && CH_HIDDEN == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
|
||
hwpf.Read1b(info, 8);
|
||
hwpf.ReadParaList(plist);
|
||
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// header/footer(16)
|
||
HeaderFooter::HeaderFooter():HBox(CH_HEADER_FOOTER)
|
||
{
|
||
linenumber = 0;
|
||
}
|
||
|
||
|
||
int HeaderFooter::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(reserved, 2);
|
||
hwpf.Read2b(&dummy, 1);
|
||
if (!(hh == dummy && CH_HEADER_FOOTER == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
|
||
hwpf.Read1b(info, 8);
|
||
hwpf.Read1b(&type, 1);
|
||
hwpf.Read1b(&where, 1);
|
||
lnnumber = 0;
|
||
hwpf.ReadParaList(plist, CH_HEADER_FOOTER);
|
||
linenumber = sal::static_int_cast<unsigned char>(lnnumber);
|
||
m_nPageNumber = hwpf.getCurrentPage();
|
||
hwpf.setMaxSettedPage();
|
||
hwpf.AddHeaderFooter(this);
|
||
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// footnote(17)
|
||
Footnote::Footnote():HBox(CH_FOOTNOTE)
|
||
{
|
||
}
|
||
|
||
|
||
int Footnote::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(reserved, 2);
|
||
hwpf.Read2b(&dummy, 1);
|
||
if (!(hh == dummy && CH_FOOTNOTE == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
|
||
hwpf.Read1b(info, 8);
|
||
hwpf.Read2b(&number, 1);
|
||
hwpf.Read2b(&type, 1);
|
||
width = (short) hwpf.Read2b();
|
||
hwpf.ReadParaList(plist, CH_FOOTNOTE);
|
||
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// auto number(18)
|
||
AutoNum::AutoNum():HBox(CH_AUTO_NUM)
|
||
{
|
||
}
|
||
|
||
|
||
int AutoNum::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(&type, 1);
|
||
hwpf.Read2b(&number, 1);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// new number(19)
|
||
NewNum::NewNum():HBox(CH_NEW_NUM)
|
||
{
|
||
}
|
||
|
||
|
||
int NewNum::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(&type, 1);
|
||
hwpf.Read2b(&number, 1);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// show page number (20)
|
||
ShowPageNum::ShowPageNum():HBox(CH_SHOW_PAGE_NUM)
|
||
{
|
||
}
|
||
|
||
|
||
int ShowPageNum::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(&where, 1);
|
||
hwpf.Read2b(&shape, 1);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
m_nPageNumber = hwpf.getCurrentPage();
|
||
hwpf.setMaxSettedPage();
|
||
hwpf.AddPageNumber(this);
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
/* Ȧ<><C8A6><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>/<2F><><EFBFBD>߱<EFBFBD> (21) */
|
||
PageNumCtrl::PageNumCtrl():HBox(CH_PAGE_NUM_CTRL)
|
||
{
|
||
}
|
||
|
||
|
||
int PageNumCtrl::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(&kind, 1);
|
||
hwpf.Read2b(&what, 1);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// mail merge(22)
|
||
MailMerge::MailMerge():HBox(CH_MAIL_MERGE)
|
||
{
|
||
}
|
||
|
||
|
||
int MailMerge::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read1b(field_name, 20);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// char compositon(23)
|
||
Compose::Compose():HBox(CH_COMPOSE)
|
||
{
|
||
}
|
||
|
||
|
||
int Compose::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(compose, 3);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// hyphen(24)
|
||
Hyphen::Hyphen():HBox(CH_HYPHEN)
|
||
{
|
||
}
|
||
|
||
|
||
int Hyphen::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(&width, 1);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// toc mark(25)
|
||
TocMark::TocMark():HBox(CH_TOC_MARK)
|
||
{
|
||
}
|
||
|
||
|
||
int TocMark::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(&kind, 1);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// index mark(26)
|
||
IndexMark::IndexMark():HBox(CH_INDEX_MARK)
|
||
{
|
||
}
|
||
|
||
|
||
int IndexMark::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(&keyword1, 60);
|
||
hwpf.Read2b(&keyword2, 60);
|
||
hwpf.Read2b(&pgno, 1);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
// outline(28)
|
||
Outline::Outline():HBox(CH_OUTLINE)
|
||
{
|
||
}
|
||
|
||
|
||
int Outline::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(&kind, 1);
|
||
hwpf.Read1b(&shape, 1);
|
||
hwpf.Read1b(&level, 1);
|
||
hwpf.Read2b(number, 7);
|
||
hwpf.Read2b(user_shape, 7);
|
||
hwpf.Read2b(deco, 14);
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
/* <20><><EFBFBD><EFBFBD> <20><>ĭ(30) */
|
||
KeepSpace::KeepSpace():HBox(CH_KEEP_SPACE)
|
||
{
|
||
}
|
||
|
||
|
||
int KeepSpace::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
return !hwpf.State();
|
||
}
|
||
|
||
|
||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ĭ(31) */
|
||
FixedSpace::FixedSpace():HBox(CH_FIXED_SPACE)
|
||
{
|
||
}
|
||
|
||
|
||
int FixedSpace::Read(HWPFile & hwpf)
|
||
{
|
||
hwpf.Read2b(&dummy, 1);
|
||
|
||
if (!(hh == dummy)){
|
||
return hwpf.SetState(HWP_InvalidFileFormat);
|
||
}
|
||
return !hwpf.State();
|
||
}
|