1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hpara.cpp,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 /* $Id: hpara.cpp,v 1.6 2008-06-04 09:59:35 vg Exp $ */
33 #include "precompile.h"
42 bool LineInfo::Read(HWPFile
& hwpf
, HWPPara
*pPara
)
44 pos
= sal::static_int_cast
<unsigned short>(hwpf
.Read2b());
45 space_width
= (short) hwpf
.Read2b();
46 height
= (short) hwpf
.Read2b();
47 // internal informations
48 pgy
= (short) hwpf
.Read2b();
49 sx
= (short) hwpf
.Read2b();
50 psx
= (short) hwpf
.Read2b();
51 pex
= (short) hwpf
.Read2b();
54 if( pex
>> 15 & 0x01 )
58 pPara
->pshape
.reserved
[0] = sal::static_int_cast
<unsigned char>(pex
& 0x01);
59 pPara
->pshape
.reserved
[1] = sal::static_int_cast
<unsigned char>(pex
& 0x02);
62 return (!hwpf
.State());
66 HWPPara::HWPPara(void)
77 HWPPara::~HWPPara(void)
88 /* C++?? null?? ???????? ????????. */
89 for (ii
= 0; ii
< nch
; ++ii
)
98 int HWPPara::Read(HWPFile
& hwpf
, unsigned char flag
)
100 unsigned char same_cshape
;
103 // Paragraph Infomation
104 hwpf
.Read1b(&reuse_shape
, 1);
105 hwpf
.Read2b(&nch
, 1);
106 hwpf
.Read2b(&nline
, 1);
107 hwpf
.Read1b(&contain_cshape
, 1);
108 hwpf
.Read1b(&etcflag
, 1);
109 hwpf
.Read4b(&ctrlflag
, 1);
110 hwpf
.Read1b(&pstyno
, 1);
113 /* Paragraph ???? ???? */
116 hwpf
.AddCharShape(&cshape
);
118 /* Paragraph ???? ???? */
119 if (nch
&& !reuse_shape
)
122 pshape
.cshape
= &cshape
;
123 pshape
.pagebreak
= etcflag
;
126 linfo
= new LineInfo
[nline
];
127 for (ii
= 0; ii
< nline
; ii
++)
129 linfo
[ii
].Read(hwpf
, this);
131 if( etcflag
& 0x04 ){
132 hwpf
.AddColumnInfo();
135 if (nch
&& !reuse_shape
){
136 if( pshape
.coldef
.ncols
> 1 ){
137 hwpf
.SetColumnDef( &pshape
.coldef
);
144 begin_ypos
= linfo
[0].pgy
;
153 cshapep
= new CharShape
[nch
];
156 perror("Memory Allocation: cshape\n");
160 for (ii
= 0; ii
< nch
; ii
++)
163 hwpf
.Read1b(&same_cshape
, 1);
166 cshapep
[ii
].Read(hwpf
);
168 hwpf
.AddCharShape(&cshapep
[ii
]);
171 cshapep
[ii
] = cshape
;
173 cshapep
[ii
] = cshapep
[ii
- 1];
177 hhstr
= new HBox
*[nch
];
178 for (ii
= 0; ii
< nch
; ii
++)
183 if (0 == (hhstr
[ii
] = readHBox(hwpf
)))
185 if (hhstr
[ii
]->hh
== CH_END_PARA
)
187 if( hhstr
[ii
]->hh
< CH_END_PARA
)
188 pshape
.reserved
[0] = 0;
189 ii
+= hhstr
[ii
]->WSize();
191 return nch
&& !hwpf
.State();
195 HWPPara
*HWPPara::Next(void)
201 CharShape
*HWPPara::GetCharShape(int pos
)
203 if (contain_cshape
== 0)
205 return cshapep
+ pos
;
209 ParaShape
*HWPPara::GetParaShape(void)
215 HBox
*HWPPara::readHBox(HWPFile
& hwpf
)
217 hchar hh
= sal::static_int_cast
<hchar
>(hwpf
.Read2b());
220 if (hwpf
.State() != HWP_NoError
)
222 //hbox = new HBox(hh);
223 if (hh
> 31 || hh
== CH_END_PARA
)
225 else if (IS_SP_SKIP_BLOCK(hh
))
226 hbox
= new SkipBlock(hh
);
232 hbox
= new FieldCode
;
234 case CH_BOOKMARK
: // 6
237 case CH_DATE_FORM
: // 7
238 hbox
= new DateFormat
;
240 case CH_DATE_CODE
: // 8
246 case CH_TEXT_BOX
: // 10
249 case CH_PICTURE
: // 11
255 case CH_HIDDEN
: // 15
258 case CH_HEADER_FOOTER
: // 16
259 hbox
= new HeaderFooter
;
261 case CH_FOOTNOTE
: // 17
264 case CH_AUTO_NUM
: // 18
267 case CH_NEW_NUM
: // 19
270 case CH_SHOW_PAGE_NUM
: // 20
271 hbox
= new ShowPageNum
;
273 case CH_PAGE_NUM_CTRL
: // 21
274 hbox
= new PageNumCtrl
;
276 case CH_MAIL_MERGE
: // 22
277 hbox
= new MailMerge
;
279 case CH_COMPOSE
: // 23
282 case CH_HYPHEN
: // 24
285 case CH_TOC_MARK
: // 25
288 case CH_INDEX_MARK
: // 26
289 hbox
= new IndexMark
;
291 case CH_OUTLINE
: // 28
294 case CH_KEEP_SPACE
: // 30
295 hbox
= new KeepSpace
;
297 case CH_FIXED_SPACE
: // 31
298 hbox
= new FixedSpace
;
304 if (!hbox
|| !hbox
->Read(hwpf
))
310 if( hh
== CH_TEXT_BOX
|| hh
== CH_PICTURE
|| hh
== CH_LINE
)
312 FBox
*fbox
= static_cast<FBox
*>(hbox
);
313 if( ( fbox
->style
.anchor_type
== 1) && ( fbox
->pgy
>= begin_ypos
) )
315 //strange construct to compile without warning
316 int nTemp
= fbox
->pgy
;
318 fbox
->pgy
= sal::static_int_cast
<short>(nTemp
);