1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 /* $Id: hpara.cpp,v 1.6 2008-06-04 09:59:35 vg Exp $ */
30 #include "precompile.h"
39 bool LineInfo::Read(HWPFile
& hwpf
, HWPPara
*pPara
)
41 pos
= sal::static_int_cast
<unsigned short>(hwpf
.Read2b());
42 space_width
= (short) hwpf
.Read2b();
43 height
= (short) hwpf
.Read2b();
44 // internal informations
45 pgy
= (short) hwpf
.Read2b();
46 sx
= (short) hwpf
.Read2b();
47 psx
= (short) hwpf
.Read2b();
48 pex
= (short) hwpf
.Read2b();
51 if( pex
>> 15 & 0x01 )
55 pPara
->pshape
.reserved
[0] = sal::static_int_cast
<unsigned char>(pex
& 0x01);
56 pPara
->pshape
.reserved
[1] = sal::static_int_cast
<unsigned char>(pex
& 0x02);
59 return (!hwpf
.State());
63 HWPPara::HWPPara(void)
74 HWPPara::~HWPPara(void)
85 /* C++?? null?? ???????? ????????. */
86 for (ii
= 0; ii
< nch
; ++ii
)
95 int HWPPara::Read(HWPFile
& hwpf
, unsigned char flag
)
97 unsigned char same_cshape
;
100 // Paragraph Infomation
101 hwpf
.Read1b(&reuse_shape
, 1);
102 hwpf
.Read2b(&nch
, 1);
103 hwpf
.Read2b(&nline
, 1);
104 hwpf
.Read1b(&contain_cshape
, 1);
105 hwpf
.Read1b(&etcflag
, 1);
106 hwpf
.Read4b(&ctrlflag
, 1);
107 hwpf
.Read1b(&pstyno
, 1);
110 /* Paragraph ???? ???? */
113 hwpf
.AddCharShape(&cshape
);
115 /* Paragraph ???? ???? */
116 if (nch
&& !reuse_shape
)
119 pshape
.cshape
= &cshape
;
120 pshape
.pagebreak
= etcflag
;
123 linfo
= new LineInfo
[nline
];
124 for (ii
= 0; ii
< nline
; ii
++)
126 linfo
[ii
].Read(hwpf
, this);
128 if( etcflag
& 0x04 ){
129 hwpf
.AddColumnInfo();
132 if (nch
&& !reuse_shape
){
133 if( pshape
.coldef
.ncols
> 1 ){
134 hwpf
.SetColumnDef( &pshape
.coldef
);
141 begin_ypos
= linfo
[0].pgy
;
150 cshapep
= new CharShape
[nch
];
153 perror("Memory Allocation: cshape\n");
157 for (ii
= 0; ii
< nch
; ii
++)
160 hwpf
.Read1b(&same_cshape
, 1);
163 cshapep
[ii
].Read(hwpf
);
165 hwpf
.AddCharShape(&cshapep
[ii
]);
168 cshapep
[ii
] = cshape
;
170 cshapep
[ii
] = cshapep
[ii
- 1];
174 hhstr
= new HBox
*[nch
];
175 for (ii
= 0; ii
< nch
; ii
++)
180 if (0 == (hhstr
[ii
] = readHBox(hwpf
)))
182 if (hhstr
[ii
]->hh
== CH_END_PARA
)
184 if( hhstr
[ii
]->hh
< CH_END_PARA
)
185 pshape
.reserved
[0] = 0;
186 ii
+= hhstr
[ii
]->WSize();
188 return nch
&& !hwpf
.State();
192 HWPPara
*HWPPara::Next(void)
198 CharShape
*HWPPara::GetCharShape(int pos
)
200 if (contain_cshape
== 0)
202 return cshapep
+ pos
;
206 ParaShape
*HWPPara::GetParaShape(void)
212 HBox
*HWPPara::readHBox(HWPFile
& hwpf
)
214 hchar hh
= sal::static_int_cast
<hchar
>(hwpf
.Read2b());
217 if (hwpf
.State() != HWP_NoError
)
219 //hbox = new HBox(hh);
220 if (hh
> 31 || hh
== CH_END_PARA
)
222 else if (IS_SP_SKIP_BLOCK(hh
))
223 hbox
= new SkipBlock(hh
);
229 hbox
= new FieldCode
;
231 case CH_BOOKMARK
: // 6
234 case CH_DATE_FORM
: // 7
235 hbox
= new DateFormat
;
237 case CH_DATE_CODE
: // 8
243 case CH_TEXT_BOX
: // 10
246 case CH_PICTURE
: // 11
252 case CH_HIDDEN
: // 15
255 case CH_HEADER_FOOTER
: // 16
256 hbox
= new HeaderFooter
;
258 case CH_FOOTNOTE
: // 17
261 case CH_AUTO_NUM
: // 18
264 case CH_NEW_NUM
: // 19
267 case CH_SHOW_PAGE_NUM
: // 20
268 hbox
= new ShowPageNum
;
270 case CH_PAGE_NUM_CTRL
: // 21
271 hbox
= new PageNumCtrl
;
273 case CH_MAIL_MERGE
: // 22
274 hbox
= new MailMerge
;
276 case CH_COMPOSE
: // 23
279 case CH_HYPHEN
: // 24
282 case CH_TOC_MARK
: // 25
285 case CH_INDEX_MARK
: // 26
286 hbox
= new IndexMark
;
288 case CH_OUTLINE
: // 28
291 case CH_KEEP_SPACE
: // 30
292 hbox
= new KeepSpace
;
294 case CH_FIXED_SPACE
: // 31
295 hbox
= new FixedSpace
;
301 if (!hbox
|| !hbox
->Read(hwpf
))
307 if( hh
== CH_TEXT_BOX
|| hh
== CH_PICTURE
|| hh
== CH_LINE
)
309 FBox
*fbox
= static_cast<FBox
*>(hbox
);
310 if( ( fbox
->style
.anchor_type
== 1) && ( fbox
->pgy
>= begin_ypos
) )
312 //strange construct to compile without warning
313 int nTemp
= fbox
->pgy
;
315 fbox
->pgy
= sal::static_int_cast
<short>(nTemp
);